polyv-live-api-sdk 1.0.18 → 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",
@@ -11901,7 +11958,7 @@ var V4AiService = class {
11901
11958
  }
11902
11959
  await this.client.httpClient.post(
11903
11960
  "/live/v4/ai/digital-human/set-organizations",
11904
- params
11961
+ { setOrganizations: params.items }
11905
11962
  );
11906
11963
  }
11907
11964
  // ============================================
@@ -13944,7 +14001,8 @@ var V4ChannelService = class {
13944
14001
  this.validateChannelId(params.channelId);
13945
14002
  await this.client.httpClient.post(
13946
14003
  "/live/v4/channel/role-config/update-by-role",
13947
- params
14004
+ params.config,
14005
+ { params: { channelId: params.channelId, role: params.role } }
13948
14006
  );
13949
14007
  }
13950
14008
  /**
@@ -19123,31 +19181,37 @@ var StatisticsService = class {
19123
19181
  "/live/v3/channel/session/stats/export",
19124
19182
  { params }
19125
19183
  );
19126
- if (response && typeof response === "object" && "data" in response) {
19127
- const responseData = response;
19128
- if (responseData.data && typeof responseData.data === "object") {
19129
- const innerData = responseData.data;
19130
- if (innerData.code && innerData.code !== 200) {
19131
- throw new Error(innerData.message || "API Error");
19132
- }
19133
- if ("downloadUrl" in innerData) {
19134
- return innerData;
19135
- }
19136
- if (typeof innerData.data === "string" && innerData.data) {
19137
- return { downloadUrl: innerData.data };
19138
- }
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");
19139
19187
  }
19188
+ return { downloadUrl: response };
19140
19189
  }
19141
- if (response && typeof response === "object" && "code" in response) {
19142
- const apiResponse = response;
19143
- if (apiResponse.code && apiResponse.code !== 200) {
19144
- 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"));
19145
19197
  }
19146
- if (typeof apiResponse.data === "string" && apiResponse.data) {
19147
- 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
+ }
19148
19212
  }
19149
19213
  }
19150
- 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");
19151
19215
  }
19152
19216
  /**
19153
19217
  * Validate parameters for exportSessionStats