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.cjs CHANGED
@@ -583,6 +583,32 @@ var ChannelService = class {
583
583
  throw PolyVValidationError.required(field);
584
584
  }
585
585
  }
586
+ buildSignedFormBody(params) {
587
+ const timestamp = Date.now();
588
+ const signatureParams = {
589
+ appId: this.client.config.appId,
590
+ timestamp,
591
+ ...params
592
+ };
593
+ const { sign } = generateSignature(signatureParams, {
594
+ appSecret: this.client.config.appSecret
595
+ });
596
+ const form = new URLSearchParams();
597
+ for (const [key, value] of Object.entries({ ...signatureParams, sign })) {
598
+ if (value !== void 0 && value !== null) {
599
+ form.append(key, String(value));
600
+ }
601
+ }
602
+ return form;
603
+ }
604
+ buildSignedFormConfig() {
605
+ return {
606
+ headers: {
607
+ "Content-Type": "application/x-www-form-urlencoded",
608
+ "X-Skip-Auth": "true"
609
+ }
610
+ };
611
+ }
586
612
  validateRequiredText(value, field, maxLength) {
587
613
  if (!value || value.trim() === "") {
588
614
  throw PolyVValidationError.required(field);
@@ -2080,8 +2106,8 @@ var ChannelService = class {
2080
2106
  }
2081
2107
  const response = await this.client.httpClient.post(
2082
2108
  `/live/v2/channel/recordFile/${params.channelId}/convert`,
2083
- null,
2084
- { params: query }
2109
+ this.buildSignedFormBody(query),
2110
+ this.buildSignedFormConfig()
2085
2111
  );
2086
2112
  return response;
2087
2113
  }
@@ -2720,7 +2746,9 @@ var ChannelService = class {
2720
2746
  * @example
2721
2747
  * ```typescript
2722
2748
  * const result = await channelService.recordConvert('ch123456', {
2723
- * fileId: 'file123',
2749
+ * userId: 'user123',
2750
+ * fileName: 'my-vod',
2751
+ * sessionId: 'fvlyin8qz3',
2724
2752
  * });
2725
2753
  * ```
2726
2754
  */
@@ -2728,37 +2756,62 @@ var ChannelService = class {
2728
2756
  if (!channelId || channelId.trim() === "") {
2729
2757
  throw PolyVValidationError.required("channelId");
2730
2758
  }
2731
- if (!options.fileId || options.fileId.trim() === "") {
2732
- throw PolyVValidationError.required("fileId");
2759
+ if (!options.userId || options.userId.trim() === "") {
2760
+ throw PolyVValidationError.required("userId");
2733
2761
  }
2734
- const params = { channelId, fileId: options.fileId };
2735
- if (options.fileName !== void 0) {
2736
- params.fileName = options.fileName;
2762
+ if (!options.fileName || options.fileName.trim() === "") {
2763
+ throw PolyVValidationError.required("fileName");
2737
2764
  }
2738
- if (options.callbackUrl !== void 0) {
2739
- params.callbackUrl = options.callbackUrl;
2765
+ const hasSessionId = options.sessionId && options.sessionId.trim() !== "";
2766
+ const hasFileUrl = options.fileUrl && options.fileUrl.trim() !== "";
2767
+ if (!hasSessionId && !hasFileUrl) {
2768
+ throw PolyVValidationError.required("sessionId or fileUrl");
2769
+ }
2770
+ const params = {
2771
+ userId: options.userId,
2772
+ fileName: options.fileName
2773
+ };
2774
+ if (options.sessionId) {
2775
+ params.sessionId = options.sessionId;
2776
+ }
2777
+ if (options.fileUrl) {
2778
+ params.fileUrl = options.fileUrl;
2779
+ }
2780
+ if (options.cataid !== void 0) {
2781
+ params.cataid = options.cataid;
2782
+ }
2783
+ if (options.cataname !== void 0) {
2784
+ params.cataname = options.cataname;
2785
+ }
2786
+ if (options.toPlayList !== void 0) {
2787
+ params.toPlayList = options.toPlayList;
2788
+ }
2789
+ if (options.setAsDefault !== void 0) {
2790
+ params.setAsDefault = options.setAsDefault;
2740
2791
  }
2741
2792
  const response = await this.client.httpClient.post(
2742
- "/live/v3/channel/record/convert",
2743
- null,
2744
- { params }
2793
+ `/live/v2/channel/recordFile/${channelId}/convert`,
2794
+ this.buildSignedFormBody(params),
2795
+ this.buildSignedFormConfig()
2745
2796
  );
2746
- return response;
2797
+ const obj = typeof response === "object" && response !== null ? response : void 0;
2798
+ const vid = typeof response === "string" ? response : String(obj?.["vid"] ?? obj?.["fileId"] ?? "");
2799
+ return { vid };
2747
2800
  }
2748
2801
  /**
2749
2802
  * Record convert async
2750
2803
  *
2751
- * Converts a recording file to VOD asynchronously.
2804
+ * Converts recording files to VOD asynchronously.
2752
2805
  *
2753
2806
  * @param channelId - The channel ID
2754
- * @param options - Convert options
2807
+ * @param options - Convert options (requires comma-separated fileIds)
2755
2808
  * @returns true if submitted successfully
2756
2809
  * @throws PolyVValidationError if required parameters are empty
2757
2810
  *
2758
2811
  * @example
2759
2812
  * ```typescript
2760
2813
  * const result = await channelService.recordConvertAsync('ch123456', {
2761
- * fileId: 'file123',
2814
+ * fileIds: 'file1,file2',
2762
2815
  * });
2763
2816
  * ```
2764
2817
  */
@@ -2766,20 +2819,24 @@ var ChannelService = class {
2766
2819
  if (!channelId || channelId.trim() === "") {
2767
2820
  throw PolyVValidationError.required("channelId");
2768
2821
  }
2769
- if (!options.fileId || options.fileId.trim() === "") {
2770
- throw PolyVValidationError.required("fileId");
2822
+ if (!options.fileIds || options.fileIds.trim() === "") {
2823
+ throw PolyVValidationError.required("fileIds");
2771
2824
  }
2772
- const params = { channelId, fileId: options.fileId };
2825
+ const params = { channelId, fileIds: options.fileIds };
2773
2826
  if (options.fileName !== void 0) {
2774
2827
  params.fileName = options.fileName;
2775
2828
  }
2829
+ if (options.cataId !== void 0) {
2830
+ params.cataId = options.cataId;
2831
+ }
2776
2832
  if (options.callbackUrl !== void 0) {
2777
2833
  params.callbackUrl = options.callbackUrl;
2778
2834
  }
2835
+ params.canRepeat = options.canRepeat ?? 1;
2779
2836
  await this.client.httpClient.post(
2780
- "/live/v3/channel/record/convert-async",
2781
- null,
2782
- { params }
2837
+ "/live/v3/channel/record/convert",
2838
+ this.buildSignedFormBody(params),
2839
+ this.buildSignedFormConfig()
2783
2840
  );
2784
2841
  return true;
2785
2842
  }
@@ -7593,26 +7650,26 @@ var AccountService = class {
7593
7650
  return { success: response };
7594
7651
  }
7595
7652
  /**
7596
- * Update category rank (sort order)
7597
- *
7598
- * @param params - Update parameters
7599
- * @returns Update result
7600
- *
7601
- * @example
7602
- * ```typescript
7603
- * const result = await client.account.updateCategoryRank({
7604
- * categoryId: 12345,
7605
- * rank: 1,
7606
- * });
7607
- * console.log(result.success);
7608
- * ```
7609
- */
7653
+ * Update category rank (sort order)
7654
+ *
7655
+ * @param params - Update parameters
7656
+ * @returns Update result
7657
+ *
7658
+ * @example
7659
+ * ```typescript
7660
+ * const result = await client.account.updateCategoryRank({
7661
+ * categoryId: 12345,
7662
+ * afterCategoryId: 67890,
7663
+ * });
7664
+ * console.log(result.success);
7665
+ * ```
7666
+ */
7610
7667
  async updateCategoryRank(params) {
7611
7668
  if (!params.categoryId || params.categoryId <= 0) {
7612
7669
  throw new PolyVValidationError("categoryId must be a positive number");
7613
7670
  }
7614
- if (params.rank === void 0 || params.rank === null) {
7615
- throw new PolyVValidationError("rank is required");
7671
+ if (params.afterCategoryId === void 0 || params.afterCategoryId === null) {
7672
+ throw new PolyVValidationError("afterCategoryId is required");
7616
7673
  }
7617
7674
  const response = await this.client.httpClient.post(
7618
7675
  "/live/v3/user/category/update-rank",
@@ -10855,31 +10912,32 @@ var PlayerService = class {
10855
10912
  if (params.autoZoomEnabled !== void 0) {
10856
10913
  this.validateYNValue(params.autoZoomEnabled, "autoZoomEnabled");
10857
10914
  }
10858
- const body = {
10915
+ const requestParams = {
10916
+ channelId,
10859
10917
  antiRecordType: params.antiRecordType,
10860
10918
  modelType: params.modelType,
10861
10919
  content: params.content,
10862
10920
  fontSize: params.fontSize
10863
10921
  };
10864
10922
  if (params.opacity !== void 0) {
10865
- body.opacity = params.opacity;
10923
+ requestParams.opacity = params.opacity;
10866
10924
  }
10867
10925
  if (params.fontColor !== void 0) {
10868
- body.fontColor = params.fontColor;
10926
+ requestParams.fontColor = params.fontColor;
10869
10927
  }
10870
10928
  if (params.showMode !== void 0) {
10871
- body.showMode = params.showMode;
10929
+ requestParams.showMode = params.showMode;
10872
10930
  }
10873
10931
  if (params.doubleEnabled !== void 0) {
10874
- body.doubleEnabled = params.doubleEnabled;
10932
+ requestParams.doubleEnabled = params.doubleEnabled;
10875
10933
  }
10876
10934
  if (params.autoZoomEnabled !== void 0) {
10877
- body.autoZoomEnabled = params.autoZoomEnabled;
10935
+ requestParams.autoZoomEnabled = params.autoZoomEnabled;
10878
10936
  }
10879
10937
  const response = await this.client.httpClient.post(
10880
10938
  "/live/v3/channel/anti/record/setting",
10881
- body,
10882
- { params: { channelId } }
10939
+ null,
10940
+ { params: requestParams }
10883
10941
  );
10884
10942
  return response;
10885
10943
  }
@@ -11900,7 +11958,7 @@ var V4AiService = class {
11900
11958
  }
11901
11959
  await this.client.httpClient.post(
11902
11960
  "/live/v4/ai/digital-human/set-organizations",
11903
- params
11961
+ { setOrganizations: params.items }
11904
11962
  );
11905
11963
  }
11906
11964
  // ============================================
@@ -13943,7 +14001,8 @@ var V4ChannelService = class {
13943
14001
  this.validateChannelId(params.channelId);
13944
14002
  await this.client.httpClient.post(
13945
14003
  "/live/v4/channel/role-config/update-by-role",
13946
- params
14004
+ params.config,
14005
+ { params: { channelId: params.channelId, role: params.role } }
13947
14006
  );
13948
14007
  }
13949
14008
  /**
@@ -16705,14 +16764,14 @@ var V4UserService = class {
16705
16764
  );
16706
16765
  }
16707
16766
  /**
16708
- * Add channel label refs
16767
+ * Add account label refs to channels
16709
16768
  *
16710
16769
  * @param params - Add parameters
16711
16770
  *
16712
16771
  * @example
16713
16772
  * ```typescript
16714
16773
  * await client.v4User.addChannelLabelRefs({
16715
- * labelIds: ['label_001'],
16774
+ * labelIds: ['zylw8zzi3p7mrqr4'],
16716
16775
  * channelIds: ['123456', '789012'],
16717
16776
  * });
16718
16777
  * ```
@@ -19122,31 +19181,37 @@ var StatisticsService = class {
19122
19181
  "/live/v3/channel/session/stats/export",
19123
19182
  { params }
19124
19183
  );
19125
- if (response && typeof response === "object" && "data" in response) {
19126
- const responseData = response;
19127
- if (responseData.data && typeof responseData.data === "object") {
19128
- const innerData = responseData.data;
19129
- if (innerData.code && innerData.code !== 200) {
19130
- throw new Error(innerData.message || "API Error");
19131
- }
19132
- if ("downloadUrl" in innerData) {
19133
- return innerData;
19134
- }
19135
- if (typeof innerData.data === "string" && innerData.data) {
19136
- return { downloadUrl: innerData.data };
19137
- }
19184
+ if (typeof response === "string") {
19185
+ if (response.trim() === "") {
19186
+ throw new Error("\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25\uFF1A\u62A5\u8868\u5C1A\u672A\u751F\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
19138
19187
  }
19188
+ return { downloadUrl: response };
19139
19189
  }
19140
- if (response && typeof response === "object" && "code" in response) {
19141
- const apiResponse = response;
19142
- if (apiResponse.code && apiResponse.code !== 200) {
19143
- throw new Error(String(apiResponse.message || "API Error"));
19190
+ if (response && typeof response === "object") {
19191
+ const obj = response;
19192
+ if (typeof obj["downloadUrl"] === "string" && obj["downloadUrl"]) {
19193
+ return { downloadUrl: obj["downloadUrl"] };
19194
+ }
19195
+ if (obj["code"] !== void 0 && obj["code"] !== 200) {
19196
+ throw new Error(String(obj["message"] || "\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25"));
19144
19197
  }
19145
- if (typeof apiResponse.data === "string" && apiResponse.data) {
19146
- return { downloadUrl: apiResponse.data };
19198
+ if (typeof obj["data"] === "string" && obj["data"]) {
19199
+ return { downloadUrl: obj["data"] };
19200
+ }
19201
+ const inner = obj["data"];
19202
+ if (inner && typeof inner === "object") {
19203
+ if (inner["code"] !== void 0 && inner["code"] !== 200) {
19204
+ throw new Error(String(inner["message"] || "\u573A\u6B21\u62A5\u8868\u5BFC\u51FA\u5931\u8D25"));
19205
+ }
19206
+ if (typeof inner["downloadUrl"] === "string" && inner["downloadUrl"]) {
19207
+ return { downloadUrl: inner["downloadUrl"] };
19208
+ }
19209
+ if (typeof inner["data"] === "string" && inner["data"]) {
19210
+ return { downloadUrl: inner["data"] };
19211
+ }
19147
19212
  }
19148
19213
  }
19149
- return response;
19214
+ 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");
19150
19215
  }
19151
19216
  /**
19152
19217
  * Validate parameters for exportSessionStats