polyv-live-api-sdk 1.0.17 → 1.0.19

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/dist/index.d.cts CHANGED
@@ -1422,18 +1422,54 @@ interface ClipRecordFileResponse {
1422
1422
  fileId: string;
1423
1423
  }
1424
1424
  /**
1425
- * Record Convert Request
1425
+ * Record Convert Request (synchronous)
1426
+ *
1427
+ * Backed by `POST /live/v2/channel/recordFile/{channelId}/convert`. Either
1428
+ * `sessionId` or `fileUrl` must be provided; when only `sessionId` is given the
1429
+ * backend converts that session's recording to VOD.
1426
1430
  */
1427
1431
  interface RecordConvertRequest {
1428
- fileId: string;
1432
+ /** Account user ID (required, included in signature) */
1433
+ userId: string;
1434
+ /** Converted VOD video name (required) */
1435
+ fileName: string;
1436
+ /** Live session ID (one of sessionId/fileUrl is required) */
1437
+ sessionId?: string;
1438
+ /** Recording file URL (one of sessionId/fileUrl is required) */
1439
+ fileUrl?: string;
1440
+ /** Catalog ID */
1441
+ cataid?: string;
1442
+ /** Catalog name */
1443
+ cataname?: string;
1444
+ /** Add to playback list (Y/N) */
1445
+ toPlayList?: 'Y' | 'N';
1446
+ /** Set as default playback video (Y/N) */
1447
+ setAsDefault?: 'Y' | 'N';
1448
+ }
1449
+ /**
1450
+ * Record Convert Async Request
1451
+ *
1452
+ * Backed by `POST /live/v3/channel/record/convert`. Requires `fileIds`
1453
+ * (comma-separated), obtained from the "查询频道录制视频信息" endpoint.
1454
+ */
1455
+ interface RecordConvertAsyncRequest {
1456
+ /** Recording file IDs, comma-separated (required) */
1457
+ fileIds: string;
1458
+ /** Converted file name */
1429
1459
  fileName?: string;
1460
+ /** VOD catalog ID */
1461
+ cataId?: string;
1462
+ /** Callback URL invoked on completion */
1430
1463
  callbackUrl?: string;
1464
+ /** Whether to return success when the VOD already exists (1=yes, 0=no) */
1465
+ canRepeat?: number;
1431
1466
  }
1432
1467
  /**
1433
1468
  * Record Convert Response
1434
1469
  */
1435
1470
  interface RecordConvertResponse {
1436
- fileId: string;
1471
+ /** Converted VOD video ID (vid) */
1472
+ vid: string;
1437
1473
  }
1438
1474
  /**
1439
1475
  * Record Merge Request (for array input)
@@ -3855,7 +3891,8 @@ interface UpdateCategoryNameResponse {
3855
3891
  }
3856
3892
  interface UpdateCategoryRankParams {
3857
3893
  categoryId: number;
3858
- rank: number;
3894
+ /** Move the category to AFTER this category ID (PolyV update-rank contract). */
3895
+ afterCategoryId: number;
3859
3896
  }
3860
3897
  interface UpdateCategoryRankResponse {
3861
3898
  success: boolean;
@@ -9730,7 +9767,7 @@ interface DeleteLabelParams {
9730
9767
  * Parameters for adding channel label refs
9731
9768
  */
9732
9769
  interface AddChannelLabelRefsParams {
9733
- /** Label IDs */
9770
+ /** Account label IDs from listLabels */
9734
9771
  labelIds: string[];
9735
9772
  /** Channel IDs */
9736
9773
  channelIds: Array<string | number>;
@@ -13955,6 +13992,8 @@ declare class ChannelService {
13955
13992
  private validateChannelViewerScope;
13956
13993
  private buildLiveBgConfig;
13957
13994
  private validateRequiredValue;
13995
+ private buildSignedFormBody;
13996
+ private buildSignedFormConfig;
13958
13997
  private validateRequiredText;
13959
13998
  private validateOptionalText;
13960
13999
  private validateOptionalYn;
@@ -14941,7 +14980,9 @@ declare class ChannelService {
14941
14980
  * @example
14942
14981
  * ```typescript
14943
14982
  * const result = await channelService.recordConvert('ch123456', {
14944
- * fileId: 'file123',
14983
+ * userId: 'user123',
14984
+ * fileName: 'my-vod',
14985
+ * sessionId: 'fvlyin8qz3',
14945
14986
  * });
14946
14987
  * ```
14947
14988
  */
@@ -14949,21 +14990,21 @@ declare class ChannelService {
14949
14990
  /**
14950
14991
  * Record convert async
14951
14992
  *
14952
- * Converts a recording file to VOD asynchronously.
14993
+ * Converts recording files to VOD asynchronously.
14953
14994
  *
14954
14995
  * @param channelId - The channel ID
14955
- * @param options - Convert options
14996
+ * @param options - Convert options (requires comma-separated fileIds)
14956
14997
  * @returns true if submitted successfully
14957
14998
  * @throws PolyVValidationError if required parameters are empty
14958
14999
  *
14959
15000
  * @example
14960
15001
  * ```typescript
14961
15002
  * const result = await channelService.recordConvertAsync('ch123456', {
14962
- * fileId: 'file123',
15003
+ * fileIds: 'file1,file2',
14963
15004
  * });
14964
15005
  * ```
14965
15006
  */
14966
- recordConvertAsync(channelId: string, options: RecordConvertRequest): Promise<boolean>;
15007
+ recordConvertAsync(channelId: string, options: RecordConvertAsyncRequest): Promise<boolean>;
14967
15008
  /**
14968
15009
  * Record file merge (synchronous)
14969
15010
  *
@@ -17446,10 +17487,10 @@ declare class AccountService {
17446
17487
  *
17447
17488
  * @example
17448
17489
  * ```typescript
17449
- * const result = await client.account.updateCategoryRank({
17450
- * categoryId: 12345,
17451
- * rank: 1,
17452
- * });
17490
+ * const result = await client.account.updateCategoryRank({
17491
+ * categoryId: 12345,
17492
+ * afterCategoryId: 67890,
17493
+ * });
17453
17494
  * console.log(result.success);
17454
17495
  * ```
17455
17496
  */
@@ -22384,14 +22425,14 @@ declare class V4UserService {
22384
22425
  */
22385
22426
  deleteLabel(params: DeleteLabelParams): Promise<void>;
22386
22427
  /**
22387
- * Add channel label refs
22428
+ * Add account label refs to channels
22388
22429
  *
22389
22430
  * @param params - Add parameters
22390
22431
  *
22391
22432
  * @example
22392
22433
  * ```typescript
22393
22434
  * await client.v4User.addChannelLabelRefs({
22394
- * labelIds: ['label_001'],
22435
+ * labelIds: ['zylw8zzi3p7mrqr4'],
22395
22436
  * channelIds: ['123456', '789012'],
22396
22437
  * });
22397
22438
  * ```
package/dist/index.js CHANGED
@@ -576,6 +576,32 @@ var ChannelService = class {
576
576
  throw PolyVValidationError.required(field);
577
577
  }
578
578
  }
579
+ buildSignedFormBody(params) {
580
+ const timestamp = Date.now();
581
+ const signatureParams = {
582
+ appId: this.client.config.appId,
583
+ timestamp,
584
+ ...params
585
+ };
586
+ const { sign } = generateSignature(signatureParams, {
587
+ appSecret: this.client.config.appSecret
588
+ });
589
+ const form = new URLSearchParams();
590
+ for (const [key, value] of Object.entries({ ...signatureParams, sign })) {
591
+ if (value !== void 0 && value !== null) {
592
+ form.append(key, String(value));
593
+ }
594
+ }
595
+ return form;
596
+ }
597
+ buildSignedFormConfig() {
598
+ return {
599
+ headers: {
600
+ "Content-Type": "application/x-www-form-urlencoded",
601
+ "X-Skip-Auth": "true"
602
+ }
603
+ };
604
+ }
579
605
  validateRequiredText(value, field, maxLength) {
580
606
  if (!value || value.trim() === "") {
581
607
  throw PolyVValidationError.required(field);
@@ -2073,8 +2099,8 @@ var ChannelService = class {
2073
2099
  }
2074
2100
  const response = await this.client.httpClient.post(
2075
2101
  `/live/v2/channel/recordFile/${params.channelId}/convert`,
2076
- null,
2077
- { params: query }
2102
+ this.buildSignedFormBody(query),
2103
+ this.buildSignedFormConfig()
2078
2104
  );
2079
2105
  return response;
2080
2106
  }
@@ -2713,7 +2739,9 @@ var ChannelService = class {
2713
2739
  * @example
2714
2740
  * ```typescript
2715
2741
  * const result = await channelService.recordConvert('ch123456', {
2716
- * fileId: 'file123',
2742
+ * userId: 'user123',
2743
+ * fileName: 'my-vod',
2744
+ * sessionId: 'fvlyin8qz3',
2717
2745
  * });
2718
2746
  * ```
2719
2747
  */
@@ -2721,37 +2749,62 @@ var ChannelService = class {
2721
2749
  if (!channelId || channelId.trim() === "") {
2722
2750
  throw PolyVValidationError.required("channelId");
2723
2751
  }
2724
- if (!options.fileId || options.fileId.trim() === "") {
2725
- throw PolyVValidationError.required("fileId");
2752
+ if (!options.userId || options.userId.trim() === "") {
2753
+ throw PolyVValidationError.required("userId");
2726
2754
  }
2727
- const params = { channelId, fileId: options.fileId };
2728
- if (options.fileName !== void 0) {
2729
- params.fileName = options.fileName;
2755
+ if (!options.fileName || options.fileName.trim() === "") {
2756
+ throw PolyVValidationError.required("fileName");
2730
2757
  }
2731
- if (options.callbackUrl !== void 0) {
2732
- params.callbackUrl = options.callbackUrl;
2758
+ const hasSessionId = options.sessionId && options.sessionId.trim() !== "";
2759
+ const hasFileUrl = options.fileUrl && options.fileUrl.trim() !== "";
2760
+ if (!hasSessionId && !hasFileUrl) {
2761
+ throw PolyVValidationError.required("sessionId or fileUrl");
2762
+ }
2763
+ const params = {
2764
+ userId: options.userId,
2765
+ fileName: options.fileName
2766
+ };
2767
+ if (options.sessionId) {
2768
+ params.sessionId = options.sessionId;
2769
+ }
2770
+ if (options.fileUrl) {
2771
+ params.fileUrl = options.fileUrl;
2772
+ }
2773
+ if (options.cataid !== void 0) {
2774
+ params.cataid = options.cataid;
2775
+ }
2776
+ if (options.cataname !== void 0) {
2777
+ params.cataname = options.cataname;
2778
+ }
2779
+ if (options.toPlayList !== void 0) {
2780
+ params.toPlayList = options.toPlayList;
2781
+ }
2782
+ if (options.setAsDefault !== void 0) {
2783
+ params.setAsDefault = options.setAsDefault;
2733
2784
  }
2734
2785
  const response = await this.client.httpClient.post(
2735
- "/live/v3/channel/record/convert",
2736
- null,
2737
- { params }
2786
+ `/live/v2/channel/recordFile/${channelId}/convert`,
2787
+ this.buildSignedFormBody(params),
2788
+ this.buildSignedFormConfig()
2738
2789
  );
2739
- return response;
2790
+ const obj = typeof response === "object" && response !== null ? response : void 0;
2791
+ const vid = typeof response === "string" ? response : String(obj?.["vid"] ?? obj?.["fileId"] ?? "");
2792
+ return { vid };
2740
2793
  }
2741
2794
  /**
2742
2795
  * Record convert async
2743
2796
  *
2744
- * Converts a recording file to VOD asynchronously.
2797
+ * Converts recording files to VOD asynchronously.
2745
2798
  *
2746
2799
  * @param channelId - The channel ID
2747
- * @param options - Convert options
2800
+ * @param options - Convert options (requires comma-separated fileIds)
2748
2801
  * @returns true if submitted successfully
2749
2802
  * @throws PolyVValidationError if required parameters are empty
2750
2803
  *
2751
2804
  * @example
2752
2805
  * ```typescript
2753
2806
  * const result = await channelService.recordConvertAsync('ch123456', {
2754
- * fileId: 'file123',
2807
+ * fileIds: 'file1,file2',
2755
2808
  * });
2756
2809
  * ```
2757
2810
  */
@@ -2759,20 +2812,24 @@ var ChannelService = class {
2759
2812
  if (!channelId || channelId.trim() === "") {
2760
2813
  throw PolyVValidationError.required("channelId");
2761
2814
  }
2762
- if (!options.fileId || options.fileId.trim() === "") {
2763
- throw PolyVValidationError.required("fileId");
2815
+ if (!options.fileIds || options.fileIds.trim() === "") {
2816
+ throw PolyVValidationError.required("fileIds");
2764
2817
  }
2765
- const params = { channelId, fileId: options.fileId };
2818
+ const params = { channelId, fileIds: options.fileIds };
2766
2819
  if (options.fileName !== void 0) {
2767
2820
  params.fileName = options.fileName;
2768
2821
  }
2822
+ if (options.cataId !== void 0) {
2823
+ params.cataId = options.cataId;
2824
+ }
2769
2825
  if (options.callbackUrl !== void 0) {
2770
2826
  params.callbackUrl = options.callbackUrl;
2771
2827
  }
2828
+ params.canRepeat = options.canRepeat ?? 1;
2772
2829
  await this.client.httpClient.post(
2773
- "/live/v3/channel/record/convert-async",
2774
- null,
2775
- { params }
2830
+ "/live/v3/channel/record/convert",
2831
+ this.buildSignedFormBody(params),
2832
+ this.buildSignedFormConfig()
2776
2833
  );
2777
2834
  return true;
2778
2835
  }
@@ -7586,26 +7643,26 @@ var AccountService = class {
7586
7643
  return { success: response };
7587
7644
  }
7588
7645
  /**
7589
- * Update category rank (sort order)
7590
- *
7591
- * @param params - Update parameters
7592
- * @returns Update result
7593
- *
7594
- * @example
7595
- * ```typescript
7596
- * const result = await client.account.updateCategoryRank({
7597
- * categoryId: 12345,
7598
- * rank: 1,
7599
- * });
7600
- * console.log(result.success);
7601
- * ```
7602
- */
7646
+ * Update category rank (sort order)
7647
+ *
7648
+ * @param params - Update parameters
7649
+ * @returns Update result
7650
+ *
7651
+ * @example
7652
+ * ```typescript
7653
+ * const result = await client.account.updateCategoryRank({
7654
+ * categoryId: 12345,
7655
+ * afterCategoryId: 67890,
7656
+ * });
7657
+ * console.log(result.success);
7658
+ * ```
7659
+ */
7603
7660
  async updateCategoryRank(params) {
7604
7661
  if (!params.categoryId || params.categoryId <= 0) {
7605
7662
  throw new PolyVValidationError("categoryId must be a positive number");
7606
7663
  }
7607
- if (params.rank === void 0 || params.rank === null) {
7608
- throw new PolyVValidationError("rank is required");
7664
+ if (params.afterCategoryId === void 0 || params.afterCategoryId === null) {
7665
+ throw new PolyVValidationError("afterCategoryId is required");
7609
7666
  }
7610
7667
  const response = await this.client.httpClient.post(
7611
7668
  "/live/v3/user/category/update-rank",
@@ -10848,31 +10905,32 @@ var PlayerService = class {
10848
10905
  if (params.autoZoomEnabled !== void 0) {
10849
10906
  this.validateYNValue(params.autoZoomEnabled, "autoZoomEnabled");
10850
10907
  }
10851
- const body = {
10908
+ const requestParams = {
10909
+ channelId,
10852
10910
  antiRecordType: params.antiRecordType,
10853
10911
  modelType: params.modelType,
10854
10912
  content: params.content,
10855
10913
  fontSize: params.fontSize
10856
10914
  };
10857
10915
  if (params.opacity !== void 0) {
10858
- body.opacity = params.opacity;
10916
+ requestParams.opacity = params.opacity;
10859
10917
  }
10860
10918
  if (params.fontColor !== void 0) {
10861
- body.fontColor = params.fontColor;
10919
+ requestParams.fontColor = params.fontColor;
10862
10920
  }
10863
10921
  if (params.showMode !== void 0) {
10864
- body.showMode = params.showMode;
10922
+ requestParams.showMode = params.showMode;
10865
10923
  }
10866
10924
  if (params.doubleEnabled !== void 0) {
10867
- body.doubleEnabled = params.doubleEnabled;
10925
+ requestParams.doubleEnabled = params.doubleEnabled;
10868
10926
  }
10869
10927
  if (params.autoZoomEnabled !== void 0) {
10870
- body.autoZoomEnabled = params.autoZoomEnabled;
10928
+ requestParams.autoZoomEnabled = params.autoZoomEnabled;
10871
10929
  }
10872
10930
  const response = await this.client.httpClient.post(
10873
10931
  "/live/v3/channel/anti/record/setting",
10874
- body,
10875
- { params: { channelId } }
10932
+ null,
10933
+ { params: requestParams }
10876
10934
  );
10877
10935
  return response;
10878
10936
  }
@@ -11893,7 +11951,7 @@ var V4AiService = class {
11893
11951
  }
11894
11952
  await this.client.httpClient.post(
11895
11953
  "/live/v4/ai/digital-human/set-organizations",
11896
- params
11954
+ { setOrganizations: params.items }
11897
11955
  );
11898
11956
  }
11899
11957
  // ============================================
@@ -13936,7 +13994,8 @@ var V4ChannelService = class {
13936
13994
  this.validateChannelId(params.channelId);
13937
13995
  await this.client.httpClient.post(
13938
13996
  "/live/v4/channel/role-config/update-by-role",
13939
- params
13997
+ params.config,
13998
+ { params: { channelId: params.channelId, role: params.role } }
13940
13999
  );
13941
14000
  }
13942
14001
  /**
@@ -16698,14 +16757,14 @@ var V4UserService = class {
16698
16757
  );
16699
16758
  }
16700
16759
  /**
16701
- * Add channel label refs
16760
+ * Add account label refs to channels
16702
16761
  *
16703
16762
  * @param params - Add parameters
16704
16763
  *
16705
16764
  * @example
16706
16765
  * ```typescript
16707
16766
  * await client.v4User.addChannelLabelRefs({
16708
- * labelIds: ['label_001'],
16767
+ * labelIds: ['zylw8zzi3p7mrqr4'],
16709
16768
  * channelIds: ['123456', '789012'],
16710
16769
  * });
16711
16770
  * ```
@@ -19115,31 +19174,37 @@ var StatisticsService = class {
19115
19174
  "/live/v3/channel/session/stats/export",
19116
19175
  { params }
19117
19176
  );
19118
- if (response && typeof response === "object" && "data" in response) {
19119
- const responseData = response;
19120
- if (responseData.data && typeof responseData.data === "object") {
19121
- const innerData = responseData.data;
19122
- if (innerData.code && innerData.code !== 200) {
19123
- throw new Error(innerData.message || "API Error");
19124
- }
19125
- if ("downloadUrl" in innerData) {
19126
- return innerData;
19127
- }
19128
- if (typeof innerData.data === "string" && innerData.data) {
19129
- return { downloadUrl: innerData.data };
19130
- }
19177
+ if (typeof response === "string") {
19178
+ if (response.trim() === "") {
19179
+ throw new Error("\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25\uFF1A\u62A5\u8868\u5C1A\u672A\u751F\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
19131
19180
  }
19181
+ return { downloadUrl: response };
19132
19182
  }
19133
- if (response && typeof response === "object" && "code" in response) {
19134
- const apiResponse = response;
19135
- if (apiResponse.code && apiResponse.code !== 200) {
19136
- throw new Error(String(apiResponse.message || "API Error"));
19183
+ if (response && typeof response === "object") {
19184
+ const obj = response;
19185
+ if (typeof obj["downloadUrl"] === "string" && obj["downloadUrl"]) {
19186
+ return { downloadUrl: obj["downloadUrl"] };
19187
+ }
19188
+ if (obj["code"] !== void 0 && obj["code"] !== 200) {
19189
+ throw new Error(String(obj["message"] || "\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25"));
19137
19190
  }
19138
- if (typeof apiResponse.data === "string" && apiResponse.data) {
19139
- return { downloadUrl: apiResponse.data };
19191
+ if (typeof obj["data"] === "string" && obj["data"]) {
19192
+ return { downloadUrl: obj["data"] };
19193
+ }
19194
+ const inner = obj["data"];
19195
+ if (inner && typeof inner === "object") {
19196
+ if (inner["code"] !== void 0 && inner["code"] !== 200) {
19197
+ throw new Error(String(inner["message"] || "\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25"));
19198
+ }
19199
+ if (typeof inner["downloadUrl"] === "string" && inner["downloadUrl"]) {
19200
+ return { downloadUrl: inner["downloadUrl"] };
19201
+ }
19202
+ if (typeof inner["data"] === "string" && inner["data"]) {
19203
+ return { downloadUrl: inner["data"] };
19204
+ }
19140
19205
  }
19141
19206
  }
19142
- return response;
19207
+ throw new Error("\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25\uFF1A\u63A5\u53E3\u672A\u8FD4\u56DE\u4E0B\u8F7D\u94FE\u63A5\uFF0C\u62A5\u8868\u53EF\u80FD\u5C1A\u672A\u751F\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
19143
19208
  }
19144
19209
  /**
19145
19210
  * Validate parameters for exportSessionStats