This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the PolyV Live Monorepo - a TypeScript/Node.js project containing:
- SDK (
polyv-live-api-sdk): PolyV Live API SDK - CLI (
polyv-live-cli): Command-line interface for PolyV live streaming services
polyv-cli/
├── packages/
│ ├── sdk/ # polyv-live-api-sdk
│ │ ├── src/
│ │ │ ├── services/ # API services (v3, v4)
│ │ │ ├── types/ # TypeScript type definitions
│ │ │ └── index.ts # SDK entry point
│ │ └── package.json
│ └── cli/ # polyv-live-cli
│ ├── src/
│ │ ├── commands/ # CLI command definitions
│ │ ├── handlers/ # Business logic
│ │ ├── config/ # Configuration management
│ │ └── index.ts # CLI entry point
│ └── package.json
├── docs/ # Project documentation
│ └── api/ # API documentation
│ ├── coupon/ # Coupon API docs
│ ├── product/ # Product API docs
│ └── channel/ # Channel API docs
├── pnpm-workspace.yaml # Workspace configuration
└── package.json # Root package.json
# Install dependencies (from root)
pnpm install
# Build all packages
pnpm build
# Build specific package
pnpm --filter polyv-live-api-sdk build
pnpm --filter polyv-live-cli build
# Run unit tests
pnpm test:unit
# Run tests for specific package
pnpm --filter polyv-live-cli test:unit| Service | Location | Description |
|---|---|---|
| ChannelService | packages/sdk/src/services/channel.service.ts |
Channel CRUD operations |
| V4PlatformService | packages/sdk/src/services/v4/platform.service.ts |
Coupon management |
| AccountService | packages/sdk/src/services/account.service.ts |
Account operations |
| Type File | Description |
|---|---|
types/channel.ts |
Channel and Product types |
types/v4-platform.ts |
Coupon types |
types/auth.ts |
Authentication types |
import { PolyVClient } from 'polyv-live-api-sdk';
const client = new PolyVClient({
appId: 'your-app-id',
appSecret: 'your-app-secret'
});
// Channel operations
const channels = await client.channel.listChannels({ pageNumber: 1, pageSize: 10 });
// Coupon operations (V4)
const couponId = await client.v4Platform.createCoupon({ ... });
const coupons = await client.v4Platform.searchCoupons({ pageNumber: 1 });
// Product operations
const products = await client.channel.getProductList({ channelId: 'xxx' });Commands are defined in packages/cli/src/commands/*.commands.ts:
- Use Commander.js framework
- Follow the pattern:
program.command('resource action').description('...').action(handler) - Handler files in
packages/cli/src/handlers/
- Create command file:
src/commands/coupon.commands.ts - Create handler file:
src/handlers/coupon.handler.ts - Register in
src/index.ts - Add types if needed: reference SDK types
CLI supports multiple auth sources (priority order):
- Command-line parameters:
--appId,--appSecret,--userId - Session account:
polyv-live-cli use <account-name> - Environment variables:
POLYV_APP_ID,POLYV_APP_SECRET - Default account:
polyv-live-cli account set-default <name> - Global config:
polyv-live-cli config set
When implementing new features, always refer to the API docs:
| Feature | Doc Location |
|---|---|
| Coupon | docs/api/coupon/README.md |
| Product | docs/api/product/ |
| Channel | docs/api/channel/ |
PolyV API uses MD5-based signature authentication:
- Sort parameters by key name
- Concatenate:
key1value1key2value2... - Build:
appSecret + concatenated_params + appSecret - Generate MD5 hash (uppercase)
- Use
workspace:*for internal package dependencies - Follow existing command patterns in CLI
- Reference SDK types from
polyv-live-api-sdk - Run
pnpm test:unitbefore committing - Coverage target: 80%
This project uses pnpm with workspace support:
- Use
pnpminstead ofnpm - Workspace protocol:
"polyv-live-api-sdk": "workspace:*" - Changesets for versioning:
pnpm changeset