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