@perk-net/perk-pushplus-sdk 1.1.1 → 1.2.0

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.
@@ -76,6 +76,27 @@ var PerkPushPlus = (function (exports) {
76
76
  [11 /* WX_PUSHER */]: "WxPusher",
77
77
  [12 /* CUSTOM */]: "\u81EA\u5B9A\u4E49"
78
78
  };
79
+ var FormStatus = /* @__PURE__ */ ((FormStatus2) => {
80
+ FormStatus2[FormStatus2["DRAFT"] = 0] = "DRAFT";
81
+ FormStatus2[FormStatus2["COLLECTING"] = 1] = "COLLECTING";
82
+ FormStatus2[FormStatus2["STOPPED"] = 2] = "STOPPED";
83
+ return FormStatus2;
84
+ })(FormStatus || {});
85
+ var FormStatusDescription = {
86
+ [0 /* DRAFT */]: "\u8349\u7A3F",
87
+ [1 /* COLLECTING */]: "\u6536\u96C6\u4E2D",
88
+ [2 /* STOPPED */]: "\u5DF2\u505C\u6B62"
89
+ };
90
+ var SharePerm = /* @__PURE__ */ ((SharePerm2) => {
91
+ SharePerm2[SharePerm2["CLOSED"] = 0] = "CLOSED";
92
+ SharePerm2[SharePerm2["VIEW"] = 1] = "VIEW";
93
+ return SharePerm2;
94
+ })(SharePerm || {});
95
+ var ShareLogin = /* @__PURE__ */ ((ShareLogin2) => {
96
+ ShareLogin2[ShareLogin2["ANONYMOUS"] = 0] = "ANONYMOUS";
97
+ ShareLogin2[ShareLogin2["REQUIRED"] = 1] = "REQUIRED";
98
+ return ShareLogin2;
99
+ })(ShareLogin || {});
79
100
  var ErrorCode = /* @__PURE__ */ ((ErrorCode3) => {
80
101
  ErrorCode3[ErrorCode3["OK"] = 200] = "OK";
81
102
  ErrorCode3[ErrorCode3["NOT_LOGIN"] = 302] = "NOT_LOGIN";
@@ -547,6 +568,218 @@ var PerkPushPlus = (function (exports) {
547
568
  }
548
569
  };
549
570
 
571
+ // src/api/doc-api.ts
572
+ var DocApi = class extends OpenAbstractApi {
573
+ constructor(config, http, mgr) {
574
+ super(config, http, mgr);
575
+ }
576
+ /** 我的文档分页。 */
577
+ list(query) {
578
+ return this.executeOpen(
579
+ "POST",
580
+ "/push/api/open/doc/list",
581
+ query != null ? query : {}
582
+ );
583
+ }
584
+ /** 创建空白文档。 */
585
+ create(title) {
586
+ return this.executeOpen("POST", "/push/api/open/doc/create", { title });
587
+ }
588
+ /** 获取文档元信息与 HTML 草稿正文。 */
589
+ content(docCode) {
590
+ return this.executeOpen(
591
+ "GET",
592
+ this.appendQuery("/push/api/open/doc/content", { docCode })
593
+ );
594
+ }
595
+ /** 保存 HTML 草稿(不影响分享页,需再 publish)。 */
596
+ saveContent(docCode, content) {
597
+ return this.executeOpen("POST", "/push/api/open/doc/saveContent", { docCode, content });
598
+ }
599
+ /** 将草稿同步为分享页快照。 */
600
+ publish(docCode) {
601
+ return this.executeOpen(
602
+ "POST",
603
+ this.appendQuery("/push/api/open/doc/publish", { docCode })
604
+ );
605
+ }
606
+ /** 重命名。 */
607
+ async rename(docCode, title) {
608
+ await this.executeOpen("POST", "/push/api/open/doc/rename", { docCode, title });
609
+ }
610
+ /** 删除文档。 */
611
+ async delete(docCode) {
612
+ await this.executeOpen(
613
+ "POST",
614
+ this.appendQuery("/push/api/open/doc/delete", { docCode })
615
+ );
616
+ }
617
+ /**
618
+ * 更新分享设置。
619
+ *
620
+ * @param sharePerm 0 关闭 / 1 开启(仅可查看)
621
+ * @param shareLogin 0 免登录 / 1 需登录;不传则沿用原值
622
+ */
623
+ updateShare(docCode, sharePerm, shareLogin) {
624
+ const body = { docCode, sharePerm };
625
+ if (shareLogin != null) body.shareLogin = shareLogin;
626
+ return this.executeOpen("POST", "/push/api/open/doc/updateShare", body);
627
+ }
628
+ };
629
+
630
+ // src/api/excel-api.ts
631
+ var ExcelApi = class extends OpenAbstractApi {
632
+ constructor(config, http, mgr) {
633
+ super(config, http, mgr);
634
+ }
635
+ /** 我的表格分页。 */
636
+ list(query) {
637
+ return this.executeOpen(
638
+ "POST",
639
+ "/push/api/open/excel/list",
640
+ query != null ? query : {}
641
+ );
642
+ }
643
+ /** 创建空白表格。 */
644
+ create(title) {
645
+ return this.executeOpen("POST", "/push/api/open/excel/create", { title });
646
+ }
647
+ /** 获取表格元信息与整表 JSON 草稿。 */
648
+ content(docCode) {
649
+ return this.executeOpen(
650
+ "GET",
651
+ this.appendQuery("/push/api/open/excel/content", { docCode })
652
+ );
653
+ }
654
+ /**
655
+ * 整表覆盖保存草稿。
656
+ *
657
+ * `content` 可为 JSON 字符串,或工作簿对象(SDK 会序列化)。
658
+ */
659
+ saveContent(docCode, content) {
660
+ return this.executeOpen("POST", "/push/api/open/excel/saveContent", {
661
+ docCode,
662
+ content: stringifyJsonContent(content)
663
+ });
664
+ }
665
+ /**
666
+ * 从指定起始单元格起,按二维数组向右向下写入(草稿)。
667
+ *
668
+ * @param range 起始单元格,如 A1
669
+ * @param values 外层为行、内层为列
670
+ * @param sheetName 工作表名称;不传则写入活动表 / 第一张表
671
+ */
672
+ writeCells(docCode, range, values, sheetName) {
673
+ const body = { docCode, range, values };
674
+ if (sheetName != null) body.sheetName = sheetName;
675
+ return this.executeOpen("POST", "/push/api/open/excel/writeCells", body);
676
+ }
677
+ /** 将草稿同步为分享页快照。 */
678
+ publish(docCode) {
679
+ return this.executeOpen(
680
+ "POST",
681
+ this.appendQuery("/push/api/open/excel/publish", { docCode })
682
+ );
683
+ }
684
+ /** 重命名。 */
685
+ async rename(docCode, title) {
686
+ await this.executeOpen("POST", "/push/api/open/excel/rename", { docCode, title });
687
+ }
688
+ /** 删除表格。 */
689
+ async delete(docCode) {
690
+ await this.executeOpen(
691
+ "POST",
692
+ this.appendQuery("/push/api/open/excel/delete", { docCode })
693
+ );
694
+ }
695
+ /**
696
+ * 更新分享设置。
697
+ *
698
+ * @param sharePerm 0 关闭 / 1 开启(仅可查看)
699
+ * @param shareLogin 0 免登录 / 1 需登录;不传则沿用原值
700
+ */
701
+ updateShare(docCode, sharePerm, shareLogin) {
702
+ const body = { docCode, sharePerm };
703
+ if (shareLogin != null) body.shareLogin = shareLogin;
704
+ return this.executeOpen("POST", "/push/api/open/excel/updateShare", body);
705
+ }
706
+ };
707
+ function stringifyJsonContent(content) {
708
+ if (typeof content === "string") {
709
+ return content;
710
+ }
711
+ try {
712
+ return JSON.stringify(content);
713
+ } catch (e) {
714
+ throw new PushPlusError(`\u5E8F\u5217\u5316\u8868\u683C\u5185\u5BB9\u5931\u8D25: ${e.message}`, -1, { cause: e });
715
+ }
716
+ }
717
+
718
+ // src/api/form-api.ts
719
+ var FormApi = class extends OpenAbstractApi {
720
+ constructor(config, http, mgr) {
721
+ super(config, http, mgr);
722
+ }
723
+ /** 我的表单分页。 */
724
+ list(query) {
725
+ return this.executeOpen(
726
+ "POST",
727
+ "/push/api/open/form/list",
728
+ query != null ? query : {}
729
+ );
730
+ }
731
+ /** 创建空白表单(草稿)。 */
732
+ create(title) {
733
+ return this.executeOpen("POST", "/push/api/open/form/create", { title });
734
+ }
735
+ /** 基于已有表单复制一份新草稿。 */
736
+ copy(id) {
737
+ return this.executeOpen(
738
+ "POST",
739
+ this.appendQuery("/push/api/open/form/copy", { id })
740
+ );
741
+ }
742
+ /** 保存表单设计(仅更新草稿;已发布需再调用 publish)。 */
743
+ async save(req) {
744
+ await this.executeOpen("POST", "/push/api/open/form/save", req);
745
+ }
746
+ /** 表单详情(含草稿题目、主题、设置)。 */
747
+ detail(id) {
748
+ return this.executeOpen(
749
+ "GET",
750
+ this.appendQuery("/push/api/open/form/detail", { id })
751
+ );
752
+ }
753
+ /** 草稿与发布快照的题目差异。 */
754
+ publishDiff(id) {
755
+ return this.executeOpen(
756
+ "GET",
757
+ this.appendQuery("/push/api/open/form/publishDiff", { id })
758
+ );
759
+ }
760
+ /** 发布表单,开始收集。 */
761
+ publish(id) {
762
+ return this.executeOpen(
763
+ "POST",
764
+ this.appendQuery("/push/api/open/form/publish", { id })
765
+ );
766
+ }
767
+ /** 停止收集。 */
768
+ async stop(id) {
769
+ await this.executeOpen(
770
+ "POST",
771
+ this.appendQuery("/push/api/open/form/stop", { id })
772
+ );
773
+ }
774
+ /** 删除表单(不可恢复)。 */
775
+ async delete(id) {
776
+ await this.executeOpen(
777
+ "POST",
778
+ this.appendQuery("/push/api/open/form/delete", { id })
779
+ );
780
+ }
781
+ };
782
+
550
783
  // src/api/friend-api.ts
551
784
  var FriendApi = class extends OpenAbstractApi {
552
785
  constructor(config, http, mgr) {
@@ -1139,7 +1372,7 @@ var PerkPushPlus = (function (exports) {
1139
1372
  logRequest: (_g = cfg.logRequest) != null ? _g : false,
1140
1373
  rateLimitGuardEnabled: (_h = cfg.rateLimitGuardEnabled) != null ? _h : true,
1141
1374
  rateLimitCooldownMs: (_i = cfg.rateLimitCooldownMs) != null ? _i : 0,
1142
- userAgent: (_j = cfg.userAgent) != null ? _j : `@perk-net/perk-pushplus-sdk/1.1.1`
1375
+ userAgent: (_j = cfg.userAgent) != null ? _j : `@perk-net/perk-pushplus-sdk/1.2.0`
1143
1376
  };
1144
1377
  }
1145
1378
 
@@ -1234,6 +1467,9 @@ var PerkPushPlus = (function (exports) {
1234
1467
  this.setting = new SettingApi(this.config, this.httpRequester, this.accessKeyManager);
1235
1468
  this.pre = new PreApi(this.config, this.httpRequester, this.accessKeyManager);
1236
1469
  this.image = new ImageApi(this.config, this.httpRequester, this.accessKeyManager);
1470
+ this.form = new FormApi(this.config, this.httpRequester, this.accessKeyManager);
1471
+ this.doc = new DocApi(this.config, this.httpRequester, this.accessKeyManager);
1472
+ this.excel = new ExcelApi(this.config, this.httpRequester, this.accessKeyManager);
1237
1473
  }
1238
1474
  /** 与 Java SDK 风格一致的 Builder 入口。 */
1239
1475
  static builder() {
@@ -1477,8 +1713,13 @@ var PerkPushPlus = (function (exports) {
1477
1713
  exports.ChannelApi = ChannelApi;
1478
1714
  exports.ClawBotApi = ClawBotApi;
1479
1715
  exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
1716
+ exports.DocApi = DocApi;
1480
1717
  exports.ErrorCode = ErrorCode;
1718
+ exports.ExcelApi = ExcelApi;
1481
1719
  exports.FetchHttpRequester = FetchHttpRequester;
1720
+ exports.FormApi = FormApi;
1721
+ exports.FormStatus = FormStatus;
1722
+ exports.FormStatusDescription = FormStatusDescription;
1482
1723
  exports.FriendApi = FriendApi;
1483
1724
  exports.ImageApi = ImageApi;
1484
1725
  exports.MessageApi = MessageApi;
@@ -1495,6 +1736,8 @@ var PerkPushPlus = (function (exports) {
1495
1736
  exports.SendStatus = SendStatus;
1496
1737
  exports.SendStatusDescription = SendStatusDescription;
1497
1738
  exports.SettingApi = SettingApi;
1739
+ exports.ShareLogin = ShareLogin;
1740
+ exports.SharePerm = SharePerm;
1498
1741
  exports.Template = Template;
1499
1742
  exports.TopicApi = TopicApi;
1500
1743
  exports.TopicUserApi = TopicUserApi;