uapi-browser-sdk 0.1.16 → 0.1.17

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/src/index.js CHANGED
@@ -21,6 +21,12 @@ function applyCacheControl(method, params, defaultDisableCache = false, requestD
21
21
  _t: Date.now(),
22
22
  };
23
23
  }
24
+ function toMultipartText(value) {
25
+ if (typeof value === 'boolean') {
26
+ return value ? 'true' : 'false';
27
+ }
28
+ return String(value);
29
+ }
24
30
  export class UapiClient {
25
31
  constructor(baseURL, tokenOrOptions, maybeOptions = {}) {
26
32
  this.baseURL = normalizeBaseURL(baseURL);
@@ -89,14 +95,18 @@ export class UapiClient {
89
95
  }
90
96
  });
91
97
  }
98
+ const isFormDataBody = typeof FormData !== 'undefined' && body instanceof FormData;
99
+ const requestHeaders = {
100
+ ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
101
+ ...(headers ?? {}),
102
+ };
103
+ if (!isFormDataBody && body !== undefined && requestHeaders['Content-Type'] === undefined) {
104
+ requestHeaders['Content-Type'] = 'application/json';
105
+ }
92
106
  const res = await fetch(url.toString(), {
93
107
  method,
94
- headers: {
95
- 'Content-Type': 'application/json',
96
- ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
97
- ...(headers ?? {}),
98
- },
99
- body: body ? JSON.stringify(body) : undefined,
108
+ headers: requestHeaders,
109
+ body: body === undefined ? undefined : (isFormDataBody ? body : JSON.stringify(body)),
100
110
  });
101
111
  if (!res.ok) {
102
112
  let data = null;
@@ -170,11 +180,13 @@ export class ClipzyZaiXianJianTieBanApi {
170
180
  if (argCacheBuster !== undefined)
171
181
  query["_t"] = argCacheBuster;
172
182
  const argCompressedData = args.compressedData;
173
- if (argCompressedData !== undefined)
183
+ if (argCompressedData !== undefined) {
174
184
  body["compressedData"] = argCompressedData;
185
+ }
175
186
  const argTtl = args.ttl;
176
- if (argTtl !== undefined)
187
+ if (argTtl !== undefined) {
177
188
  body["ttl"] = argTtl;
189
+ }
178
190
  let requestPath = '/api/v1/api/store';
179
191
  const responseKind = 'json';
180
192
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -212,8 +224,9 @@ export class ConvertApi {
212
224
  if (argCacheBuster !== undefined)
213
225
  query["_t"] = argCacheBuster;
214
226
  const argContent = args.content;
215
- if (argContent !== undefined)
227
+ if (argContent !== undefined) {
216
228
  body["content"] = argContent;
229
+ }
217
230
  let requestPath = '/api/v1/convert/json';
218
231
  const responseKind = 'json';
219
232
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -484,7 +497,7 @@ export class ImageApi {
484
497
  async postImageCompress(args) {
485
498
  const query = {};
486
499
  const headers = {};
487
- const body = {};
500
+ const body = new FormData();
488
501
  let disableCache;
489
502
  disableCache = args.disableCache ?? args["disable_cache"];
490
503
  const argCacheBuster = args._t;
@@ -497,17 +510,18 @@ export class ImageApi {
497
510
  if (argFormat !== undefined)
498
511
  query["format"] = argFormat;
499
512
  const argFile = args.file;
500
- if (argFile !== undefined)
501
- body["file"] = argFile;
513
+ if (argFile !== undefined) {
514
+ body.append("file", argFile);
515
+ }
502
516
  let requestPath = '/api/v1/image/compress';
503
517
  const responseKind = 'arrayBuffer';
504
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
518
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
505
519
  }
506
520
  /** 解码并缩放图片 */
507
521
  async postImageDecode(args) {
508
522
  const query = {};
509
523
  const headers = {};
510
- const body = {};
524
+ const body = new FormData();
511
525
  let disableCache;
512
526
  disableCache = args.disableCache ?? args["disable_cache"];
513
527
  const argCacheBuster = args._t;
@@ -538,14 +552,16 @@ export class ImageApi {
538
552
  if (argBackground !== undefined)
539
553
  query["background"] = argBackground;
540
554
  const argFile = args.file;
541
- if (argFile !== undefined)
542
- body["file"] = argFile;
555
+ if (argFile !== undefined) {
556
+ body.append("file", argFile);
557
+ }
543
558
  const argUrl = args.url;
544
- if (argUrl !== undefined)
545
- body["url"] = argUrl;
559
+ if (argUrl !== undefined) {
560
+ body.append("url", toMultipartText(argUrl));
561
+ }
546
562
  let requestPath = '/api/v1/image/decode';
547
563
  const responseKind = 'arrayBuffer';
548
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
564
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
549
565
  }
550
566
  /** 通过Base64编码上传图片 */
551
567
  async postImageFrombase64(args) {
@@ -558,8 +574,9 @@ export class ImageApi {
558
574
  if (argCacheBuster !== undefined)
559
575
  query["_t"] = argCacheBuster;
560
576
  const argImageData = args.imageData;
561
- if (argImageData !== undefined)
577
+ if (argImageData !== undefined) {
562
578
  body["imageData"] = argImageData;
579
+ }
563
580
  let requestPath = '/api/v1/image/frombase64';
564
581
  const responseKind = 'json';
565
582
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -568,79 +585,91 @@ export class ImageApi {
568
585
  async postImageMotou(args) {
569
586
  const query = {};
570
587
  const headers = {};
571
- const body = {};
588
+ const body = new FormData();
572
589
  let disableCache;
573
590
  disableCache = args.disableCache ?? args["disable_cache"];
574
591
  const argCacheBuster = args._t;
575
592
  if (argCacheBuster !== undefined)
576
593
  query["_t"] = argCacheBuster;
577
594
  const argBgColor = args.bgColor ?? args["bg_color"];
578
- if (argBgColor !== undefined)
579
- body["bg_color"] = argBgColor;
595
+ if (argBgColor !== undefined) {
596
+ body.append("bg_color", toMultipartText(argBgColor));
597
+ }
580
598
  const argFile = args.file;
581
- if (argFile !== undefined)
582
- body["file"] = argFile;
599
+ if (argFile !== undefined) {
600
+ body.append("file", argFile);
601
+ }
583
602
  const argImageUrl = args.imageUrl ?? args["image_url"];
584
- if (argImageUrl !== undefined)
585
- body["image_url"] = argImageUrl;
603
+ if (argImageUrl !== undefined) {
604
+ body.append("image_url", toMultipartText(argImageUrl));
605
+ }
586
606
  let requestPath = '/api/v1/image/motou';
587
607
  const responseKind = 'arrayBuffer';
588
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
608
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
589
609
  }
590
610
  /** 图片敏感检测 */
591
611
  async postImageNsfw(args) {
592
612
  const query = {};
593
613
  const headers = {};
594
- const body = {};
614
+ const body = new FormData();
595
615
  let disableCache;
596
616
  disableCache = args.disableCache ?? args["disable_cache"];
597
617
  const argCacheBuster = args._t;
598
618
  if (argCacheBuster !== undefined)
599
619
  query["_t"] = argCacheBuster;
600
620
  const argFile = args.file;
601
- if (argFile !== undefined)
602
- body["file"] = argFile;
621
+ if (argFile !== undefined) {
622
+ body.append("file", argFile);
623
+ }
603
624
  const argUrl = args.url;
604
- if (argUrl !== undefined)
605
- body["url"] = argUrl;
625
+ if (argUrl !== undefined) {
626
+ body.append("url", toMultipartText(argUrl));
627
+ }
606
628
  let requestPath = '/api/v1/image/nsfw';
607
629
  const responseKind = 'json';
608
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
630
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
609
631
  }
610
632
  /** 通用 OCR 文字识别 */
611
633
  async postImageOcr(args) {
612
634
  const query = {};
613
635
  const headers = {};
614
- const body = {};
636
+ const body = new FormData();
615
637
  let disableCache;
616
638
  disableCache = args.disableCache ?? args["disable_cache"];
617
639
  const argCacheBuster = args._t;
618
640
  if (argCacheBuster !== undefined)
619
641
  query["_t"] = argCacheBuster;
620
642
  const argEnableCls = args.enableCls ?? args["enable_cls"];
621
- if (argEnableCls !== undefined)
622
- body["enable_cls"] = argEnableCls;
643
+ if (argEnableCls !== undefined) {
644
+ body.append("enable_cls", toMultipartText(argEnableCls));
645
+ }
623
646
  const argFile = args.file;
624
- if (argFile !== undefined)
625
- body["file"] = argFile;
647
+ if (argFile !== undefined) {
648
+ body.append("file", argFile);
649
+ }
626
650
  const argImageBase64 = args.imageBase64 ?? args["image_base64"];
627
- if (argImageBase64 !== undefined)
628
- body["image_base64"] = argImageBase64;
651
+ if (argImageBase64 !== undefined) {
652
+ body.append("image_base64", toMultipartText(argImageBase64));
653
+ }
629
654
  const argImageName = args.imageName ?? args["image_name"];
630
- if (argImageName !== undefined)
631
- body["image_name"] = argImageName;
655
+ if (argImageName !== undefined) {
656
+ body.append("image_name", toMultipartText(argImageName));
657
+ }
632
658
  const argNeedLocation = args.needLocation ?? args["need_location"];
633
- if (argNeedLocation !== undefined)
634
- body["need_location"] = argNeedLocation;
659
+ if (argNeedLocation !== undefined) {
660
+ body.append("need_location", toMultipartText(argNeedLocation));
661
+ }
635
662
  const argReturnMarkdown = args.returnMarkdown ?? args["return_markdown"];
636
- if (argReturnMarkdown !== undefined)
637
- body["return_markdown"] = argReturnMarkdown;
663
+ if (argReturnMarkdown !== undefined) {
664
+ body.append("return_markdown", toMultipartText(argReturnMarkdown));
665
+ }
638
666
  const argUrl = args.url;
639
- if (argUrl !== undefined)
640
- body["url"] = argUrl;
667
+ if (argUrl !== undefined) {
668
+ body.append("url", toMultipartText(argUrl));
669
+ }
641
670
  let requestPath = '/api/v1/image/ocr';
642
671
  const responseKind = 'json';
643
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
672
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
644
673
  }
645
674
  /** 生成你们怎么不说话了表情包 */
646
675
  async postImageSpeechless(args) {
@@ -653,11 +682,13 @@ export class ImageApi {
653
682
  if (argCacheBuster !== undefined)
654
683
  query["_t"] = argCacheBuster;
655
684
  const argBottomText = args.bottomText ?? args["bottom_text"];
656
- if (argBottomText !== undefined)
685
+ if (argBottomText !== undefined) {
657
686
  body["bottom_text"] = argBottomText;
687
+ }
658
688
  const argTopText = args.topText ?? args["top_text"];
659
- if (argTopText !== undefined)
689
+ if (argTopText !== undefined) {
660
690
  body["top_text"] = argTopText;
691
+ }
661
692
  let requestPath = '/api/v1/image/speechless';
662
693
  const responseKind = 'arrayBuffer';
663
694
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -666,7 +697,7 @@ export class ImageApi {
666
697
  async postImageSvg(args = {}) {
667
698
  const query = {};
668
699
  const headers = {};
669
- const body = {};
700
+ const body = new FormData();
670
701
  let disableCache;
671
702
  disableCache = args.disableCache ?? args["disable_cache"];
672
703
  const argCacheBuster = args._t;
@@ -685,11 +716,12 @@ export class ImageApi {
685
716
  if (argQuality !== undefined)
686
717
  query["quality"] = argQuality;
687
718
  const argFile = args.file;
688
- if (argFile !== undefined)
689
- body["file"] = argFile;
719
+ if (argFile !== undefined) {
720
+ body.append("file", argFile);
721
+ }
690
722
  let requestPath = '/api/v1/image/svg';
691
723
  const responseKind = 'arrayBuffer';
692
- return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
724
+ return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, body, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
693
725
  }
694
726
  }
695
727
  export class MiscApi {
@@ -1036,14 +1068,17 @@ export class MiscApi {
1036
1068
  if (argCacheBuster !== undefined)
1037
1069
  query["_t"] = argCacheBuster;
1038
1070
  const argEndDate = args.endDate ?? args["end_date"];
1039
- if (argEndDate !== undefined)
1071
+ if (argEndDate !== undefined) {
1040
1072
  body["end_date"] = argEndDate;
1073
+ }
1041
1074
  const argFormat = args.format;
1042
- if (argFormat !== undefined)
1075
+ if (argFormat !== undefined) {
1043
1076
  body["format"] = argFormat;
1077
+ }
1044
1078
  const argStartDate = args.startDate ?? args["start_date"];
1045
- if (argStartDate !== undefined)
1079
+ if (argStartDate !== undefined) {
1046
1080
  body["start_date"] = argStartDate;
1081
+ }
1047
1082
  let requestPath = '/api/v1/misc/date-diff';
1048
1083
  const responseKind = 'json';
1049
1084
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1319,8 +1354,9 @@ export class RandomApi {
1319
1354
  if (argCacheBuster !== undefined)
1320
1355
  query["_t"] = argCacheBuster;
1321
1356
  const argQuestion = args.question;
1322
- if (argQuestion !== undefined)
1357
+ if (argQuestion !== undefined) {
1323
1358
  body["question"] = argQuestion;
1359
+ }
1324
1360
  let requestPath = '/api/v1/answerbook/ask';
1325
1361
  const responseKind = 'json';
1326
1362
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1591,14 +1627,17 @@ export class TextApi {
1591
1627
  if (argCacheBuster !== undefined)
1592
1628
  query["_t"] = argCacheBuster;
1593
1629
  const argKey = args.key;
1594
- if (argKey !== undefined)
1630
+ if (argKey !== undefined) {
1595
1631
  body["key"] = argKey;
1632
+ }
1596
1633
  const argNonce = args.nonce;
1597
- if (argNonce !== undefined)
1634
+ if (argNonce !== undefined) {
1598
1635
  body["nonce"] = argNonce;
1636
+ }
1599
1637
  const argText = args.text;
1600
- if (argText !== undefined)
1638
+ if (argText !== undefined) {
1601
1639
  body["text"] = argText;
1640
+ }
1602
1641
  let requestPath = '/api/v1/text/aes/decrypt';
1603
1642
  const responseKind = 'json';
1604
1643
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1614,20 +1653,25 @@ export class TextApi {
1614
1653
  if (argCacheBuster !== undefined)
1615
1654
  query["_t"] = argCacheBuster;
1616
1655
  const argIv = args.iv;
1617
- if (argIv !== undefined)
1656
+ if (argIv !== undefined) {
1618
1657
  body["iv"] = argIv;
1658
+ }
1619
1659
  const argKey = args.key;
1620
- if (argKey !== undefined)
1660
+ if (argKey !== undefined) {
1621
1661
  body["key"] = argKey;
1662
+ }
1622
1663
  const argMode = args.mode;
1623
- if (argMode !== undefined)
1664
+ if (argMode !== undefined) {
1624
1665
  body["mode"] = argMode;
1666
+ }
1625
1667
  const argPadding = args.padding;
1626
- if (argPadding !== undefined)
1668
+ if (argPadding !== undefined) {
1627
1669
  body["padding"] = argPadding;
1670
+ }
1628
1671
  const argText = args.text;
1629
- if (argText !== undefined)
1672
+ if (argText !== undefined) {
1630
1673
  body["text"] = argText;
1674
+ }
1631
1675
  let requestPath = '/api/v1/text/aes/decrypt-advanced';
1632
1676
  const responseKind = 'json';
1633
1677
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1643,11 +1687,13 @@ export class TextApi {
1643
1687
  if (argCacheBuster !== undefined)
1644
1688
  query["_t"] = argCacheBuster;
1645
1689
  const argKey = args.key;
1646
- if (argKey !== undefined)
1690
+ if (argKey !== undefined) {
1647
1691
  body["key"] = argKey;
1692
+ }
1648
1693
  const argText = args.text;
1649
- if (argText !== undefined)
1694
+ if (argText !== undefined) {
1650
1695
  body["text"] = argText;
1696
+ }
1651
1697
  let requestPath = '/api/v1/text/aes/encrypt';
1652
1698
  const responseKind = 'json';
1653
1699
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1663,23 +1709,29 @@ export class TextApi {
1663
1709
  if (argCacheBuster !== undefined)
1664
1710
  query["_t"] = argCacheBuster;
1665
1711
  const argIv = args.iv;
1666
- if (argIv !== undefined)
1712
+ if (argIv !== undefined) {
1667
1713
  body["iv"] = argIv;
1714
+ }
1668
1715
  const argKey = args.key;
1669
- if (argKey !== undefined)
1716
+ if (argKey !== undefined) {
1670
1717
  body["key"] = argKey;
1718
+ }
1671
1719
  const argMode = args.mode;
1672
- if (argMode !== undefined)
1720
+ if (argMode !== undefined) {
1673
1721
  body["mode"] = argMode;
1722
+ }
1674
1723
  const argOutputFormat = args.outputFormat ?? args["output_format"];
1675
- if (argOutputFormat !== undefined)
1724
+ if (argOutputFormat !== undefined) {
1676
1725
  body["output_format"] = argOutputFormat;
1726
+ }
1677
1727
  const argPadding = args.padding;
1678
- if (argPadding !== undefined)
1728
+ if (argPadding !== undefined) {
1679
1729
  body["padding"] = argPadding;
1730
+ }
1680
1731
  const argText = args.text;
1681
- if (argText !== undefined)
1732
+ if (argText !== undefined) {
1682
1733
  body["text"] = argText;
1734
+ }
1683
1735
  let requestPath = '/api/v1/text/aes/encrypt-advanced';
1684
1736
  const responseKind = 'json';
1685
1737
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1695,8 +1747,9 @@ export class TextApi {
1695
1747
  if (argCacheBuster !== undefined)
1696
1748
  query["_t"] = argCacheBuster;
1697
1749
  const argText = args.text;
1698
- if (argText !== undefined)
1750
+ if (argText !== undefined) {
1699
1751
  body["text"] = argText;
1752
+ }
1700
1753
  let requestPath = '/api/v1/text/analyze';
1701
1754
  const responseKind = 'json';
1702
1755
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1712,8 +1765,9 @@ export class TextApi {
1712
1765
  if (argCacheBuster !== undefined)
1713
1766
  query["_t"] = argCacheBuster;
1714
1767
  const argText = args.text;
1715
- if (argText !== undefined)
1768
+ if (argText !== undefined) {
1716
1769
  body["text"] = argText;
1770
+ }
1717
1771
  let requestPath = '/api/v1/text/base64/decode';
1718
1772
  const responseKind = 'json';
1719
1773
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1729,8 +1783,9 @@ export class TextApi {
1729
1783
  if (argCacheBuster !== undefined)
1730
1784
  query["_t"] = argCacheBuster;
1731
1785
  const argText = args.text;
1732
- if (argText !== undefined)
1786
+ if (argText !== undefined) {
1733
1787
  body["text"] = argText;
1788
+ }
1734
1789
  let requestPath = '/api/v1/text/base64/encode';
1735
1790
  const responseKind = 'json';
1736
1791
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1746,17 +1801,21 @@ export class TextApi {
1746
1801
  if (argCacheBuster !== undefined)
1747
1802
  query["_t"] = argCacheBuster;
1748
1803
  const argFrom = args.from;
1749
- if (argFrom !== undefined)
1804
+ if (argFrom !== undefined) {
1750
1805
  body["from"] = argFrom;
1806
+ }
1751
1807
  const argOptions = args.options;
1752
- if (argOptions !== undefined)
1808
+ if (argOptions !== undefined) {
1753
1809
  body["options"] = argOptions;
1810
+ }
1754
1811
  const argText = args.text;
1755
- if (argText !== undefined)
1812
+ if (argText !== undefined) {
1756
1813
  body["text"] = argText;
1814
+ }
1757
1815
  const argTo = args.to;
1758
- if (argTo !== undefined)
1816
+ if (argTo !== undefined) {
1759
1817
  body["to"] = argTo;
1818
+ }
1760
1819
  let requestPath = '/api/v1/text/convert';
1761
1820
  const responseKind = 'json';
1762
1821
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1772,14 +1831,17 @@ export class TextApi {
1772
1831
  if (argCacheBuster !== undefined)
1773
1832
  query["_t"] = argCacheBuster;
1774
1833
  const argFormat = args.format;
1775
- if (argFormat !== undefined)
1834
+ if (argFormat !== undefined) {
1776
1835
  body["format"] = argFormat;
1836
+ }
1777
1837
  const argSanitize = args.sanitize;
1778
- if (argSanitize !== undefined)
1838
+ if (argSanitize !== undefined) {
1779
1839
  body["sanitize"] = argSanitize;
1840
+ }
1780
1841
  const argText = args.text;
1781
- if (argText !== undefined)
1842
+ if (argText !== undefined) {
1782
1843
  body["text"] = argText;
1844
+ }
1783
1845
  let requestPath = '/api/v1/text/markdown-to-html';
1784
1846
  const responseKind = 'json';
1785
1847
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1795,14 +1857,17 @@ export class TextApi {
1795
1857
  if (argCacheBuster !== undefined)
1796
1858
  query["_t"] = argCacheBuster;
1797
1859
  const argPaperSize = args.paperSize ?? args["paper_size"];
1798
- if (argPaperSize !== undefined)
1860
+ if (argPaperSize !== undefined) {
1799
1861
  body["paper_size"] = argPaperSize;
1862
+ }
1800
1863
  const argText = args.text;
1801
- if (argText !== undefined)
1864
+ if (argText !== undefined) {
1802
1865
  body["text"] = argText;
1866
+ }
1803
1867
  const argTheme = args.theme;
1804
- if (argTheme !== undefined)
1868
+ if (argTheme !== undefined) {
1805
1869
  body["theme"] = argTheme;
1870
+ }
1806
1871
  let requestPath = '/api/v1/text/markdown-to-pdf';
1807
1872
  const responseKind = 'arrayBuffer';
1808
1873
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1818,8 +1883,9 @@ export class TextApi {
1818
1883
  if (argCacheBuster !== undefined)
1819
1884
  query["_t"] = argCacheBuster;
1820
1885
  const argText = args.text;
1821
- if (argText !== undefined)
1886
+ if (argText !== undefined) {
1822
1887
  body["text"] = argText;
1888
+ }
1823
1889
  let requestPath = '/api/v1/text/md5';
1824
1890
  const responseKind = 'json';
1825
1891
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1835,11 +1901,13 @@ export class TextApi {
1835
1901
  if (argCacheBuster !== undefined)
1836
1902
  query["_t"] = argCacheBuster;
1837
1903
  const argHash = args.hash;
1838
- if (argHash !== undefined)
1904
+ if (argHash !== undefined) {
1839
1905
  body["hash"] = argHash;
1906
+ }
1840
1907
  const argText = args.text;
1841
- if (argText !== undefined)
1908
+ if (argText !== undefined) {
1842
1909
  body["text"] = argText;
1910
+ }
1843
1911
  let requestPath = '/api/v1/text/md5/verify';
1844
1912
  const responseKind = 'json';
1845
1913
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1873,20 +1941,25 @@ export class TranslateApi {
1873
1941
  if (argTargetLang !== undefined)
1874
1942
  query["target_lang"] = argTargetLang;
1875
1943
  const argContext = args.context;
1876
- if (argContext !== undefined)
1944
+ if (argContext !== undefined) {
1877
1945
  body["context"] = argContext;
1946
+ }
1878
1947
  const argPreserveFormat = args.preserveFormat ?? args["preserve_format"];
1879
- if (argPreserveFormat !== undefined)
1948
+ if (argPreserveFormat !== undefined) {
1880
1949
  body["preserve_format"] = argPreserveFormat;
1950
+ }
1881
1951
  const argSourceLang = args.sourceLang ?? args["source_lang"];
1882
- if (argSourceLang !== undefined)
1952
+ if (argSourceLang !== undefined) {
1883
1953
  body["source_lang"] = argSourceLang;
1954
+ }
1884
1955
  const argStyle = args.style;
1885
- if (argStyle !== undefined)
1956
+ if (argStyle !== undefined) {
1886
1957
  body["style"] = argStyle;
1958
+ }
1887
1959
  const argText = args.text;
1888
- if (argText !== undefined)
1960
+ if (argText !== undefined) {
1889
1961
  body["text"] = argText;
1962
+ }
1890
1963
  let requestPath = '/api/v1/ai/translate';
1891
1964
  const responseKind = 'json';
1892
1965
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1902,17 +1975,21 @@ export class TranslateApi {
1902
1975
  if (argCacheBuster !== undefined)
1903
1976
  query["_t"] = argCacheBuster;
1904
1977
  const argFromLang = args.fromLang ?? args["from_lang"];
1905
- if (argFromLang !== undefined)
1978
+ if (argFromLang !== undefined) {
1906
1979
  body["from_lang"] = argFromLang;
1980
+ }
1907
1981
  const argQuery = args.query;
1908
- if (argQuery !== undefined)
1982
+ if (argQuery !== undefined) {
1909
1983
  body["query"] = argQuery;
1984
+ }
1910
1985
  const argToLang = args.toLang ?? args["to_lang"];
1911
- if (argToLang !== undefined)
1986
+ if (argToLang !== undefined) {
1912
1987
  body["to_lang"] = argToLang;
1988
+ }
1913
1989
  const argTone = args.tone;
1914
- if (argTone !== undefined)
1990
+ if (argTone !== undefined) {
1915
1991
  body["tone"] = argTone;
1992
+ }
1916
1993
  let requestPath = '/api/v1/translate/stream';
1917
1994
  const responseKind = 'json';
1918
1995
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -1931,8 +2008,9 @@ export class TranslateApi {
1931
2008
  if (argToLang !== undefined)
1932
2009
  query["to_lang"] = argToLang;
1933
2010
  const argText = args.text;
1934
- if (argText !== undefined)
2011
+ if (argText !== undefined) {
1935
2012
  body["text"] = argText;
2013
+ }
1936
2014
  let requestPath = '/api/v1/translate/text';
1937
2015
  const responseKind = 'json';
1938
2016
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -2043,8 +2121,9 @@ export class MinGanCiShiBieApi {
2043
2121
  if (argCacheBuster !== undefined)
2044
2122
  query["_t"] = argCacheBuster;
2045
2123
  const argKeywords = args.keywords;
2046
- if (argKeywords !== undefined)
2124
+ if (argKeywords !== undefined) {
2047
2125
  body["keywords"] = argKeywords;
2126
+ }
2048
2127
  let requestPath = '/api/v1/sensitive-word/analyze';
2049
2128
  const responseKind = 'json';
2050
2129
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -2060,8 +2139,9 @@ export class MinGanCiShiBieApi {
2060
2139
  if (argCacheBuster !== undefined)
2061
2140
  query["_t"] = argCacheBuster;
2062
2141
  const argText = args.text;
2063
- if (argText !== undefined)
2142
+ if (argText !== undefined) {
2064
2143
  body["text"] = argText;
2144
+ }
2065
2145
  let requestPath = '/api/v1/text/profanitycheck';
2066
2146
  const responseKind = 'json';
2067
2147
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);
@@ -2092,23 +2172,29 @@ export class ZhiNengSouSuoApi {
2092
2172
  if (argCacheBuster !== undefined)
2093
2173
  query["_t"] = argCacheBuster;
2094
2174
  const argFetchFull = args.fetchFull ?? args["fetch_full"];
2095
- if (argFetchFull !== undefined)
2175
+ if (argFetchFull !== undefined) {
2096
2176
  body["fetch_full"] = argFetchFull;
2177
+ }
2097
2178
  const argFiletype = args.filetype;
2098
- if (argFiletype !== undefined)
2179
+ if (argFiletype !== undefined) {
2099
2180
  body["filetype"] = argFiletype;
2181
+ }
2100
2182
  const argQuery = args.query;
2101
- if (argQuery !== undefined)
2183
+ if (argQuery !== undefined) {
2102
2184
  body["query"] = argQuery;
2185
+ }
2103
2186
  const argSite = args.site;
2104
- if (argSite !== undefined)
2187
+ if (argSite !== undefined) {
2105
2188
  body["site"] = argSite;
2189
+ }
2106
2190
  const argSort = args.sort;
2107
- if (argSort !== undefined)
2191
+ if (argSort !== undefined) {
2108
2192
  body["sort"] = argSort;
2193
+ }
2109
2194
  const argTimeRange = args.timeRange ?? args["time_range"];
2110
- if (argTimeRange !== undefined)
2195
+ if (argTimeRange !== undefined) {
2111
2196
  body["time_range"] = argTimeRange;
2197
+ }
2112
2198
  let requestPath = '/api/v1/search/aggregate';
2113
2199
  const responseKind = 'json';
2114
2200
  return await this.c._request('POST', requestPath, Object.keys(query).length > 0 ? query : undefined, Object.keys(body).length > 0 ? body : undefined, Object.keys(headers).length > 0 ? headers : undefined, responseKind, disableCache !== undefined ? { disableCache } : undefined);