polyv-live-api-sdk 1.0.3 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -0
- package/dist/index.cjs +104 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4901 -4803
- package/dist/index.js +104 -9
- package/dist/index.js.map +1 -1
- package/dist/services/live-interaction.service.d.ts.map +1 -1
- package/dist/services/v4/user.service.d.ts +31 -1
- package/dist/services/v4/user.service.d.ts.map +1 -1
- package/dist/services/web.service.d.ts +11 -1
- package/dist/services/web.service.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/v4-user.d.ts +42 -0
- package/dist/types/v4-user.d.ts.map +1 -1
- package/dist/types/web.d.ts +9 -5
- package/dist/types/web.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# PolyV Live API SDK
|
|
2
|
+
|
|
3
|
+
TypeScript/Node.js SDK for PolyV Live Streaming API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install polyv-live-api-sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add polyv-live-api-sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add polyv-live-api-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { PolyVClient } from 'polyv-live-api-sdk';
|
|
19
|
+
|
|
20
|
+
const client = new PolyVClient({
|
|
21
|
+
appId: 'your-app-id',
|
|
22
|
+
appSecret: 'your-app-secret'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// List channels
|
|
26
|
+
const channels = await client.channel.listChannels({ pageNumber: 1, pageSize: 10 });
|
|
27
|
+
|
|
28
|
+
// Get channel details
|
|
29
|
+
const channel = await client.channel.getChannel({ channelId: 'your-channel-id' });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Full TypeScript support with type definitions
|
|
35
|
+
- Automatic API signature generation
|
|
36
|
+
- Promise-based API
|
|
37
|
+
- Comprehensive error handling
|
|
38
|
+
- Support for both V3 and V4 APIs
|
|
39
|
+
|
|
40
|
+
## Services
|
|
41
|
+
|
|
42
|
+
### V3 Services
|
|
43
|
+
|
|
44
|
+
| Service | Description |
|
|
45
|
+
|---------|-------------|
|
|
46
|
+
| `channel` | Channel management (CRUD, settings, streams) |
|
|
47
|
+
| `chat` | Chat operations (messages, bans, kicks) |
|
|
48
|
+
| `account` | Account operations |
|
|
49
|
+
| `group` | Group management |
|
|
50
|
+
| `platform` | Platform operations |
|
|
51
|
+
| `finance` | Financial operations |
|
|
52
|
+
| `web` | Web settings |
|
|
53
|
+
| `player` | Player configuration |
|
|
54
|
+
| `liveInteraction` | Live interactions (check-in, lottery, Q&A) |
|
|
55
|
+
| `statistics` | Statistics and reports |
|
|
56
|
+
|
|
57
|
+
### V4 Services
|
|
58
|
+
|
|
59
|
+
| Service | Description |
|
|
60
|
+
|---------|-------------|
|
|
61
|
+
| `v4Platform` | Coupon management |
|
|
62
|
+
| `v4Channel` | V4 channel APIs |
|
|
63
|
+
| `v4Chat` | V4 chat APIs |
|
|
64
|
+
| `v4User` | User management |
|
|
65
|
+
| `v4Group` | V4 group APIs |
|
|
66
|
+
| `v4AI` | AI features |
|
|
67
|
+
| `v4Robot` | Robot features |
|
|
68
|
+
| `v4Material` | Materials management |
|
|
69
|
+
| `v4Statistics` | V4 statistics |
|
|
70
|
+
| `v4WebApp` | WebApp settings |
|
|
71
|
+
| `v4Global` | Global settings |
|
|
72
|
+
|
|
73
|
+
## Usage Examples
|
|
74
|
+
|
|
75
|
+
### Channel Management
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// Create a channel
|
|
79
|
+
const newChannel = await client.channel.createChannel({
|
|
80
|
+
name: 'My Live Channel',
|
|
81
|
+
channelPass: 'password123'
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// List channels with pagination
|
|
85
|
+
const result = await client.channel.listChannels({
|
|
86
|
+
pageNumber: 1,
|
|
87
|
+
pageSize: 20
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Update channel
|
|
91
|
+
await client.channel.updateChannel({
|
|
92
|
+
channelId: 'xxx',
|
|
93
|
+
name: 'Updated Name'
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Coupon Operations (V4)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// Create a coupon
|
|
101
|
+
const couponId = await client.v4Platform.createCoupon({
|
|
102
|
+
name: 'Discount Coupon',
|
|
103
|
+
discount: 100,
|
|
104
|
+
total: 1000
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Search coupons
|
|
108
|
+
const coupons = await client.v4Platform.searchCoupons({
|
|
109
|
+
pageNumber: 1,
|
|
110
|
+
pageSize: 10
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Product Management
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Get product list
|
|
118
|
+
const products = await client.channel.getProductList({
|
|
119
|
+
channelId: 'your-channel-id'
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Add product
|
|
123
|
+
const product = await client.channel.addProduct({
|
|
124
|
+
channelId: 'your-channel-id',
|
|
125
|
+
name: 'Product Name',
|
|
126
|
+
price: '99.00'
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Statistics
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Get channel statistics
|
|
134
|
+
const stats = await client.statistics.getChannelStats({
|
|
135
|
+
channelId: 'your-channel-id',
|
|
136
|
+
startDate: '2024-01-01',
|
|
137
|
+
endDate: '2024-01-31'
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Error Handling
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { PolyVAPIError, PolyVErrorCode } from 'polyv-live-api-sdk';
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await client.channel.getChannel({ channelId: 'invalid-id' });
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (error instanceof PolyVAPIError) {
|
|
150
|
+
console.log('Error code:', error.code);
|
|
151
|
+
console.log('Error message:', error.message);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Pagination Utilities
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { paginate, collectAll } from 'polyv-live-api-sdk';
|
|
160
|
+
|
|
161
|
+
// Auto-paginate through all results
|
|
162
|
+
const allChannels = await collectAll(
|
|
163
|
+
(page) => client.channel.listChannels({ pageNumber: page, pageSize: 100 }),
|
|
164
|
+
(response) => response.contents
|
|
165
|
+
);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Configuration Options
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const client = new PolyVClient({
|
|
172
|
+
appId: 'your-app-id',
|
|
173
|
+
appSecret: 'your-app-secret',
|
|
174
|
+
userId: 'your-user-id', // Optional
|
|
175
|
+
timeout: 30000, // Request timeout in ms (default: 30000)
|
|
176
|
+
baseURL: 'https://api.polyv.net' // Custom base URL (optional)
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Requirements
|
|
181
|
+
|
|
182
|
+
- Node.js >= 18.0.0
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -5292,6 +5292,9 @@ var LiveInteractionService = class {
|
|
|
5292
5292
|
* ```
|
|
5293
5293
|
*/
|
|
5294
5294
|
async getCheckinList(params) {
|
|
5295
|
+
if (!params.channelId) {
|
|
5296
|
+
throw new Error("channelId is required");
|
|
5297
|
+
}
|
|
5295
5298
|
const response = await this.client.httpClient.get(
|
|
5296
5299
|
"/live/v2/chat/getCheckinList",
|
|
5297
5300
|
{ params }
|
|
@@ -7626,7 +7629,8 @@ var WebService = class {
|
|
|
7626
7629
|
* ```typescript
|
|
7627
7630
|
* const result = await client.web.updateWhiteList({
|
|
7628
7631
|
* rank: 1,
|
|
7629
|
-
*
|
|
7632
|
+
* oldCode: '13800138000',
|
|
7633
|
+
* code: '13900139000',
|
|
7630
7634
|
* name: 'Updated Name',
|
|
7631
7635
|
* channelId: '123456',
|
|
7632
7636
|
* });
|
|
@@ -7636,6 +7640,9 @@ var WebService = class {
|
|
|
7636
7640
|
if (params.rank !== 1 && params.rank !== 2) {
|
|
7637
7641
|
throw new PolyVValidationError("rank must be 1 or 2");
|
|
7638
7642
|
}
|
|
7643
|
+
if (!params.oldCode || params.oldCode.trim() === "") {
|
|
7644
|
+
throw new PolyVValidationError("oldCode is required");
|
|
7645
|
+
}
|
|
7639
7646
|
if (!params.code || params.code.trim() === "") {
|
|
7640
7647
|
throw new PolyVValidationError("code is required");
|
|
7641
7648
|
}
|
|
@@ -7647,6 +7654,7 @@ var WebService = class {
|
|
|
7647
7654
|
}
|
|
7648
7655
|
const apiParams = {
|
|
7649
7656
|
rank: params.rank,
|
|
7657
|
+
oldCode: params.oldCode,
|
|
7650
7658
|
code: params.code
|
|
7651
7659
|
};
|
|
7652
7660
|
if (params.name) {
|
|
@@ -7671,24 +7679,39 @@ var WebService = class {
|
|
|
7671
7679
|
*
|
|
7672
7680
|
* @example
|
|
7673
7681
|
* ```typescript
|
|
7682
|
+
* // Delete specific codes
|
|
7674
7683
|
* const result = await client.web.deleteWhiteList({
|
|
7675
7684
|
* rank: 1,
|
|
7685
|
+
* isClear: 'N',
|
|
7676
7686
|
* codes: '13800138000,13800138001',
|
|
7677
7687
|
* channelId: '123456',
|
|
7678
7688
|
* });
|
|
7689
|
+
*
|
|
7690
|
+
* // Clear all
|
|
7691
|
+
* const result = await client.web.deleteWhiteList({
|
|
7692
|
+
* rank: 1,
|
|
7693
|
+
* isClear: 'Y',
|
|
7694
|
+
* channelId: '123456',
|
|
7695
|
+
* });
|
|
7679
7696
|
* ```
|
|
7680
7697
|
*/
|
|
7681
7698
|
async deleteWhiteList(params) {
|
|
7682
7699
|
if (params.rank !== 1 && params.rank !== 2) {
|
|
7683
7700
|
throw new PolyVValidationError("rank must be 1 or 2");
|
|
7684
7701
|
}
|
|
7685
|
-
if (!params.
|
|
7686
|
-
throw new PolyVValidationError("
|
|
7702
|
+
if (!params.isClear) {
|
|
7703
|
+
throw new PolyVValidationError("isClear is required");
|
|
7704
|
+
}
|
|
7705
|
+
if (params.isClear === "N" && (!params.codes || params.codes.trim() === "")) {
|
|
7706
|
+
throw new PolyVValidationError("codes is required when isClear=N");
|
|
7687
7707
|
}
|
|
7688
7708
|
const apiParams = {
|
|
7689
7709
|
rank: params.rank,
|
|
7690
|
-
|
|
7710
|
+
isClear: params.isClear
|
|
7691
7711
|
};
|
|
7712
|
+
if (params.codes) {
|
|
7713
|
+
apiParams.code = params.codes;
|
|
7714
|
+
}
|
|
7692
7715
|
if (params.channelId) {
|
|
7693
7716
|
apiParams.channelId = params.channelId;
|
|
7694
7717
|
}
|
|
@@ -13126,7 +13149,7 @@ var V4UserService = class {
|
|
|
13126
13149
|
*/
|
|
13127
13150
|
async listViewerLabels() {
|
|
13128
13151
|
const response = await this.client.httpClient.get(
|
|
13129
|
-
"/live/v4/user/viewer-
|
|
13152
|
+
"/live/v4/user/viewer-label/list",
|
|
13130
13153
|
{}
|
|
13131
13154
|
);
|
|
13132
13155
|
return response;
|
|
@@ -13206,8 +13229,11 @@ var V4UserService = class {
|
|
|
13206
13229
|
this.validateRequiredString(params.viewerUnionId, "viewerUnionId");
|
|
13207
13230
|
this.validateRequiredNumber(params.labelId, "labelId");
|
|
13208
13231
|
await this.client.httpClient.post(
|
|
13209
|
-
"/live/v4/user/viewer-
|
|
13210
|
-
|
|
13232
|
+
"/live/v4/user/viewer-label/add-viewers-label",
|
|
13233
|
+
{
|
|
13234
|
+
viewerUnionIds: [params.viewerUnionId],
|
|
13235
|
+
labelIds: [params.labelId]
|
|
13236
|
+
}
|
|
13211
13237
|
);
|
|
13212
13238
|
}
|
|
13213
13239
|
/**
|
|
@@ -13227,8 +13253,11 @@ var V4UserService = class {
|
|
|
13227
13253
|
this.validateRequiredString(params.viewerUnionId, "viewerUnionId");
|
|
13228
13254
|
this.validateRequiredNumber(params.labelId, "labelId");
|
|
13229
13255
|
await this.client.httpClient.post(
|
|
13230
|
-
"/live/v4/user/viewer-
|
|
13231
|
-
|
|
13256
|
+
"/live/v4/user/viewer-label/remove-viewers-label",
|
|
13257
|
+
{
|
|
13258
|
+
viewerUnionIds: [params.viewerUnionId],
|
|
13259
|
+
labelIds: [params.labelId]
|
|
13260
|
+
}
|
|
13232
13261
|
);
|
|
13233
13262
|
}
|
|
13234
13263
|
// ============================================
|
|
@@ -14242,6 +14271,47 @@ var V4UserService = class {
|
|
|
14242
14271
|
return response;
|
|
14243
14272
|
}
|
|
14244
14273
|
// ============================================
|
|
14274
|
+
// Story 13-3: Global Channel Settings APIs
|
|
14275
|
+
// ============================================
|
|
14276
|
+
/**
|
|
14277
|
+
* Get global channel settings
|
|
14278
|
+
*
|
|
14279
|
+
* @returns Global channel settings
|
|
14280
|
+
*
|
|
14281
|
+
* @example
|
|
14282
|
+
* ```typescript
|
|
14283
|
+
* const settings = await client.v4User.getGlobalChannelSettings();
|
|
14284
|
+
* ```
|
|
14285
|
+
*/
|
|
14286
|
+
async getGlobalChannelSettings() {
|
|
14287
|
+
const response = await this.client.httpClient.get(
|
|
14288
|
+
"/live/v4/user/global-setting/switch/get",
|
|
14289
|
+
{}
|
|
14290
|
+
);
|
|
14291
|
+
return response;
|
|
14292
|
+
}
|
|
14293
|
+
/**
|
|
14294
|
+
* Update global channel settings
|
|
14295
|
+
*
|
|
14296
|
+
* @param params - Update parameters
|
|
14297
|
+
*
|
|
14298
|
+
* @example
|
|
14299
|
+
* ```typescript
|
|
14300
|
+
* await client.v4User.updateGlobalChannelSettings({
|
|
14301
|
+
* channelConcurrencesEnabled: 'Y',
|
|
14302
|
+
* donateEnabled: 'N',
|
|
14303
|
+
* coverImgType: 'contain',
|
|
14304
|
+
* });
|
|
14305
|
+
* ```
|
|
14306
|
+
*/
|
|
14307
|
+
async updateGlobalChannelSettings(params) {
|
|
14308
|
+
this.validateGlobalSettingsParams(params);
|
|
14309
|
+
await this.client.httpClient.post(
|
|
14310
|
+
"/live/v4/user/global-setting/switch/update",
|
|
14311
|
+
params
|
|
14312
|
+
);
|
|
14313
|
+
}
|
|
14314
|
+
// ============================================
|
|
14245
14315
|
// Private Validation Helpers
|
|
14246
14316
|
// ============================================
|
|
14247
14317
|
/**
|
|
@@ -14271,6 +14341,31 @@ var V4UserService = class {
|
|
|
14271
14341
|
throw new PolyVValidationError(`${fieldName} is required`, fieldName, value);
|
|
14272
14342
|
}
|
|
14273
14343
|
}
|
|
14344
|
+
/**
|
|
14345
|
+
* Validate global settings update parameters
|
|
14346
|
+
*/
|
|
14347
|
+
validateGlobalSettingsParams(params) {
|
|
14348
|
+
const booleanFields = [
|
|
14349
|
+
"channelConcurrencesEnabled",
|
|
14350
|
+
"timelyConvertEnabled",
|
|
14351
|
+
"donateEnabled",
|
|
14352
|
+
"rebirthAutoUploadEnabled",
|
|
14353
|
+
"rebirthAutoConvertEnabled",
|
|
14354
|
+
"pptCoveredEnabled",
|
|
14355
|
+
"testModeButtonEnabled"
|
|
14356
|
+
];
|
|
14357
|
+
for (const field of booleanFields) {
|
|
14358
|
+
const value = params[field];
|
|
14359
|
+
if (value !== void 0 && value !== "Y" && value !== "N") {
|
|
14360
|
+
throw new PolyVValidationError(`${field} must be 'Y' or 'N'`, field, value);
|
|
14361
|
+
}
|
|
14362
|
+
}
|
|
14363
|
+
if (params.coverImgType !== void 0) {
|
|
14364
|
+
if (params.coverImgType !== "contain" && params.coverImgType !== "cover") {
|
|
14365
|
+
throw new PolyVValidationError("coverImgType must be 'contain' or 'cover'", "coverImgType", params.coverImgType);
|
|
14366
|
+
}
|
|
14367
|
+
}
|
|
14368
|
+
}
|
|
14274
14369
|
};
|
|
14275
14370
|
|
|
14276
14371
|
// src/services/v4/global.service.ts
|