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

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.d.cts CHANGED
@@ -155,7 +155,9 @@ declare enum Channel {
155
155
  /** App 渠道(安卓/鸿蒙/iOS)。 */
156
156
  APP = "app",
157
157
  /** 微信 ClawBot。 */
158
- CLAWBOT = "clawbot"
158
+ CLAWBOT = "clawbot",
159
+ /** QQ 机器人;不带 option 发给自己,option 填配置编码则发到对应 QQ 群。 */
160
+ QQ = "qq"
159
161
  }
160
162
  /**
161
163
  * PushPlus 消息模板枚举。
@@ -511,6 +513,7 @@ interface SendCount {
511
513
  cpSendCount?: number;
512
514
  webhookSendCount?: number;
513
515
  mailSendCount?: number;
516
+ qqBotSendCount?: number;
514
517
  }
515
518
  interface UserLimitTime {
516
519
  /** 1-无限制,2-短期限制,3-永久限制。 */
@@ -645,6 +648,18 @@ interface TopicUserListQuery {
645
648
  /** 例如 { topicId }。 */
646
649
  params?: Record<string, unknown>;
647
650
  }
651
+ /** 群组订阅人黑名单列表项。 */
652
+ interface TopicUserBlacklistItem {
653
+ /** 黑名单记录 ID;解除黑名单时使用。 */
654
+ id?: number;
655
+ /** 被拉黑用户 ID。 */
656
+ userId?: number;
657
+ nickName?: string;
658
+ openId?: string;
659
+ headImgUrl?: string;
660
+ /** 拉黑时间。 */
661
+ createTime?: string;
662
+ }
648
663
  interface WebhookItem {
649
664
  id?: number;
650
665
  webhookCode?: string;
@@ -685,6 +700,17 @@ interface FriendItem {
685
700
  interface FriendQrCode {
686
701
  qrCodeImgUrl?: string;
687
702
  }
703
+ /** 好友黑名单列表项。 */
704
+ interface FriendBlacklistItem {
705
+ /** 黑名单记录 ID;解除黑名单时使用。 */
706
+ id?: number;
707
+ /** 被拉黑好友 ID。 */
708
+ friendId?: number;
709
+ nickName?: string;
710
+ headImgUrl?: string;
711
+ /** 拉黑时间。 */
712
+ createTime?: string;
713
+ }
688
714
  interface ClawBotInfo {
689
715
  createTime?: string;
690
716
  /** 是否有对话令牌(文档为字符串/数字混用,统一用 number 兼容)。 */
@@ -699,6 +725,74 @@ interface ClawBotQrCode {
699
725
  url?: string;
700
726
  qrcode?: string;
701
727
  }
728
+ interface QqBotBindLink {
729
+ /** 带参分享链接,用于生成扫码二维码;已绑定用户再次获取时可能为空。 */
730
+ url?: string;
731
+ /** 绑定码。已是好友时扫码收不到加好友事件,需私聊发送该码;认领 QQ 群也用此码。 */
732
+ bindCode?: string;
733
+ /** 有效期秒数,默认 300。 */
734
+ expireSeconds?: number;
735
+ /** 为当前用户分配的官方机器人 appId。 */
736
+ botAppId?: string;
737
+ botName?: string;
738
+ botAvatar?: string;
739
+ }
740
+ interface QqBotInfo {
741
+ botId?: string;
742
+ username?: string;
743
+ avatar?: string;
744
+ appId?: string;
745
+ /** 官方分享链接,可用于拉机器人进群。 */
746
+ shareUrl?: string;
747
+ }
748
+ interface QqBotBindInfo {
749
+ /** 0-未绑定,1-已绑定。 */
750
+ isBind?: number;
751
+ /** 1-可接收,0-用户已关闭单聊接收。 */
752
+ receiveStatus?: number;
753
+ createTime?: string;
754
+ botInfo?: QqBotInfo;
755
+ }
756
+ interface QqGroupItem {
757
+ /** 群编号;新增渠道配置时作为 qqGroupId 使用。 */
758
+ id?: number;
759
+ groupOpenId?: string;
760
+ groupRemark?: string;
761
+ /** 1-在群,2-群消息接收关闭。 */
762
+ status?: number;
763
+ /** 群名称,接口未授权时为空。 */
764
+ groupName?: string;
765
+ groupFingerMemo?: string;
766
+ groupClassText?: string;
767
+ groupTags?: string[];
768
+ groupMemberNum?: number;
769
+ createTime?: string;
770
+ }
771
+ interface QqBotItem {
772
+ id?: number;
773
+ qqName?: string;
774
+ /** 配置编码;发送消息时作为 option 传入。 */
775
+ qqCode?: string;
776
+ /** 2-发到 QQ 群。 */
777
+ sendType?: number;
778
+ qqGroupId?: number;
779
+ groupRemark?: string;
780
+ groupOpenId?: string;
781
+ groupName?: string;
782
+ updateTime?: string;
783
+ }
784
+ interface QqBotSaveRequest {
785
+ /** 修改时必填。 */
786
+ id?: number;
787
+ /** 配置名称,必填,最多 64 个字符。 */
788
+ qqName?: string;
789
+ /** 配置编码,新增必填;仅支持字母、数字、下划线和中划线,创建后不可修改。 */
790
+ qqCode?: string;
791
+ /** 发送类型;留空时 SDK 自动填 2(发到 QQ 群)。 */
792
+ sendType?: number;
793
+ /** QQ 群编号,必填,取自 groupList 返回的 id。 */
794
+ qqGroupId?: number;
795
+ }
702
796
  interface MpItem {
703
797
  id?: number;
704
798
  nickName?: string;
@@ -843,16 +937,19 @@ interface ImageItem {
843
937
  /** 创建时间。 */
844
938
  createTime?: string;
845
939
  }
846
- /** 我的表单分页查询。 */
940
+ /** 我的表单分页查询。官方结构为 `{current, pageSize, params:{keyword, status}}`。 */
847
941
  interface FormListQuery {
848
- /** 页码,从 1 开始。 */
849
- pageNum?: number;
850
- /** 每页条数。 */
942
+ /** 当前所在分页数,默认 1 */
943
+ current?: number;
944
+ /** 每页大小,默认 20,最大 50。 */
851
945
  pageSize?: number;
852
- /** 按标题关键词搜索。 */
853
- keyword?: string;
854
- /** 表单状态:0草稿 / 1收集中 / 2已停止。 */
855
- status?: number;
946
+ params?: {
947
+ /** 按标题关键词搜索。 */
948
+ keyword?: string;
949
+ /** 表单状态:0草稿 / 1收集中 / 2已停止。 */
950
+ status?: number;
951
+ [key: string]: unknown;
952
+ };
856
953
  }
857
954
  /** 表单封面页配置。 */
858
955
  interface FormCover {
@@ -956,13 +1053,18 @@ interface FormPublishResult {
956
1053
  publishDirty?: boolean;
957
1054
  publishTime?: string;
958
1055
  }
959
- /** 文档 / 表格分页查询。 */
1056
+ /** 文档 / 表格分页查询。官方结构为 `{current, pageSize, params:{keyword, shareEnabled}}`。 */
960
1057
  interface DocListQuery {
961
- pageNum?: number;
1058
+ /** 当前所在分页数,默认 1。 */
1059
+ current?: number;
1060
+ /** 每页大小,默认 20,最大 50。 */
962
1061
  pageSize?: number;
963
- keyword?: string;
964
- /** true 时仅返回已开启分享的记录。 */
965
- shareEnabled?: boolean;
1062
+ params?: {
1063
+ keyword?: string;
1064
+ /** true 时仅返回已开启分享的记录。 */
1065
+ shareEnabled?: boolean;
1066
+ [key: string]: unknown;
1067
+ };
966
1068
  }
967
1069
  /** 文档 / 表格列表项。 */
968
1070
  interface DocListItem {
@@ -1022,6 +1124,11 @@ declare abstract class AbstractApi {
1022
1124
  * 执行请求并返回原始 ApiResponse(不进行 code 校验)。
1023
1125
  */
1024
1126
  protected execute<T>(method: string, path: string, headers: Record<string, string> | undefined | null, body: unknown): Promise<ApiResponse<T>>;
1127
+ /**
1128
+ * 执行带二进制请求体的请求并返回原始 ApiResponse(不进行 code 校验)。
1129
+ * 用于 multipart 上传等场景。
1130
+ */
1131
+ protected executeRaw<T>(method: string, path: string, headers: Record<string, string> | undefined | null, body: Uint8Array): Promise<ApiResponse<T>>;
1025
1132
  /** 执行请求并直接返回 data;非 200 抛出异常。 */
1026
1133
  protected executeForData<T>(method: string, path: string, headers: Record<string, string> | undefined | null, body: unknown): Promise<T>;
1027
1134
  }
@@ -1066,6 +1173,13 @@ declare class AccessKeyManager {
1066
1173
  private isValid;
1067
1174
  }
1068
1175
 
1176
+ /** 二进制文件输入。 */
1177
+ type FileInput = Uint8Array | ArrayBuffer | Blob;
1178
+ interface FileMultipart {
1179
+ contentType: string;
1180
+ body: Uint8Array;
1181
+ }
1182
+
1069
1183
  /**
1070
1184
  * 开放接口基类。会自动在 header 中带上 access-key,
1071
1185
  * 并在收到 401 类业务错误时尝试重试一次(刷新 AccessKey 后重试)。
@@ -1081,6 +1195,12 @@ declare abstract class OpenAbstractApi extends AbstractApi {
1081
1195
  * 执行带 access-key 的请求;当返回 code=401 时自动刷新 key 并重试一次。
1082
1196
  */
1083
1197
  protected executeOpen<T>(method: string, path: string, body?: unknown): Promise<T>;
1198
+ /** 以 multipart 上传文件(自动携带 access-key;code=401 时刷新后重试一次)。 */
1199
+ protected executeOpenMultipart<T>(path: string, multipart: FileMultipart): Promise<T>;
1200
+ /**
1201
+ * 执行带二进制 body 的开放接口请求;当返回 code=401 时自动刷新 key 并重试一次。
1202
+ */
1203
+ protected executeOpenRaw<T>(method: string, path: string, body: Uint8Array, extraHeaders?: Record<string, string>): Promise<T>;
1084
1204
  }
1085
1205
 
1086
1206
  /**
@@ -1120,6 +1240,9 @@ declare class ClawBotApi extends OpenAbstractApi {
1120
1240
  *
1121
1241
  * 文档:https://www.pushplus.plus/doc/ecosystem/doc/
1122
1242
  * 基础路径:`/push/api/open/doc`
1243
+ *
1244
+ * 文档开放接口不单独提供推送接口。发布后请通过 `client.send` 推送分享页:
1245
+ * `template=doc`,`pushId=docCode`。
1123
1246
  */
1124
1247
  declare class DocApi extends OpenAbstractApi {
1125
1248
  constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
@@ -1127,6 +1250,12 @@ declare class DocApi extends OpenAbstractApi {
1127
1250
  list(query?: DocListQuery): Promise<PageResult<DocListItem>>;
1128
1251
  /** 创建空白文档。 */
1129
1252
  create(title: string): Promise<DocVo>;
1253
+ /**
1254
+ * 导入 Word(.docx)创建文档。
1255
+ *
1256
+ * 标题默认取文件名;创建后默认关闭分享,需再调用 publish 才会同步到分享页。
1257
+ */
1258
+ importWord(file: FileInput, fileName?: string): Promise<DocVo>;
1130
1259
  /** 获取文档元信息与 HTML 草稿正文。 */
1131
1260
  content(docCode: string): Promise<DocContent>;
1132
1261
  /** 保存 HTML 草稿(不影响分享页,需再 publish)。 */
@@ -1151,6 +1280,9 @@ declare class DocApi extends OpenAbstractApi {
1151
1280
  *
1152
1281
  * 文档:https://www.pushplus.plus/doc/ecosystem/sheet/
1153
1282
  * 基础路径:`/push/api/open/excel`
1283
+ *
1284
+ * 表格开放接口不单独提供推送接口。发布后请通过 `client.send` 推送分享页:
1285
+ * `template=excel`,`pushId=docCode`。
1154
1286
  */
1155
1287
  declare class ExcelApi extends OpenAbstractApi {
1156
1288
  constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
@@ -1158,6 +1290,12 @@ declare class ExcelApi extends OpenAbstractApi {
1158
1290
  list(query?: DocListQuery): Promise<PageResult<DocListItem>>;
1159
1291
  /** 创建空白表格。 */
1160
1292
  create(title: string): Promise<ExcelVo>;
1293
+ /**
1294
+ * 导入 Excel(.xlsx / .xls)创建表格。
1295
+ *
1296
+ * 标题默认取文件名;创建后默认关闭分享,需再调用 publish 才会同步到分享页。
1297
+ */
1298
+ importExcel(file: FileInput, fileName?: string): Promise<ExcelVo>;
1161
1299
  /** 获取表格元信息与整表 JSON 草稿。 */
1162
1300
  content(docCode: string): Promise<ExcelContent>;
1163
1301
  /**
@@ -1194,6 +1332,9 @@ declare class ExcelApi extends OpenAbstractApi {
1194
1332
  *
1195
1333
  * 文档:https://www.pushplus.plus/doc/ecosystem/form/
1196
1334
  * 基础路径:`/push/api/open/form`
1335
+ *
1336
+ * 表单开放接口不单独提供推送接口。发布后请通过 `client.send` 推送填写页:
1337
+ * `template=form`,`pushId=formCode`。
1197
1338
  */
1198
1339
  declare class FormApi extends OpenAbstractApi {
1199
1340
  constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
@@ -1235,6 +1376,24 @@ declare class FriendApi extends OpenAbstractApi {
1235
1376
  delete(friendId: number): Promise<void>;
1236
1377
  /** 4. 修改好友备注。 */
1237
1378
  editRemark(id: number, remark: string): Promise<void>;
1379
+ /**
1380
+ * 5. 将好友加入黑名单。
1381
+ *
1382
+ * 加入后将解除双方好友关系,对方无法再添加你。不能将自己加入黑名单,仅可将已有好友加入黑名单。
1383
+ *
1384
+ * @param friendId 好友 id(好友列表中的 friendId 字段)
1385
+ */
1386
+ addBlacklist(friendId: number): Promise<void>;
1387
+ /** 6. 好友黑名单列表。 */
1388
+ blacklistList(query?: PageQuery): Promise<PageResult<FriendBlacklistItem>>;
1389
+ /**
1390
+ * 7. 解除好友黑名单。
1391
+ *
1392
+ * 解除后不会自动恢复好友关系,需重新扫码添加。
1393
+ *
1394
+ * @param id 黑名单记录 ID(黑名单列表中的 id 字段)
1395
+ */
1396
+ removeBlacklist(id: number): Promise<void>;
1238
1397
  }
1239
1398
 
1240
1399
  /**
@@ -1423,6 +1582,29 @@ declare class PreApi extends OpenAbstractApi {
1423
1582
  test(req: PreTestRequest): Promise<string>;
1424
1583
  }
1425
1584
 
1585
+ /**
1586
+ * 开放接口 - QQ 机器人(文档「九. QQ机器人接口」)。
1587
+ */
1588
+ declare class QqBotApi extends OpenAbstractApi {
1589
+ constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
1590
+ /** 1. 获取绑定链接与绑定码;refresh 为 true 时旧绑定码失效并重新生成。 */
1591
+ getBindLink(refresh?: boolean): Promise<QqBotBindLink>;
1592
+ /** 2. 查询绑定状态。 */
1593
+ botInfo(): Promise<QqBotBindInfo>;
1594
+ /** 3. 解绑 QQ 机器人。 */
1595
+ unbind(): Promise<void>;
1596
+ /** 4. 获取机器人已加入的 QQ 群列表。 */
1597
+ groupList(): Promise<QqGroupItem[]>;
1598
+ /** 5. 获取 QQ 机器人渠道配置列表。 */
1599
+ list(q?: PageQuery): Promise<PageResult<QqBotItem>>;
1600
+ /** 6. 新增渠道配置,用于把消息发送到指定 QQ 群;发给自己无需创建配置。 */
1601
+ add(req: QqBotSaveRequest): Promise<void>;
1602
+ /** 7. 修改渠道配置;配置编码不可修改。 */
1603
+ edit(req: QqBotSaveRequest): Promise<void>;
1604
+ /** 8. 删除渠道配置。 */
1605
+ delete(id: number): Promise<void>;
1606
+ }
1607
+
1426
1608
  /**
1427
1609
  * 开放接口 - 功能设置(文档「九. 功能设置接口」)。
1428
1610
  */
@@ -1504,6 +1686,28 @@ declare class TopicUserApi extends OpenAbstractApi {
1504
1686
  deleteUser(topicRelationId: number): Promise<string>;
1505
1687
  /** 3. 修改订阅人备注。 */
1506
1688
  editRemark(id: number, remark: string): Promise<void>;
1689
+ /**
1690
+ * 4. 将订阅人加入黑名单。
1691
+ *
1692
+ * 加入后将移出群组,对方无法再加入该群组。积分群组不支持黑名单。不能将自己加入黑名单。
1693
+ *
1694
+ * @param topicRelationId 用户编号(订阅人列表中的 id 字段)
1695
+ */
1696
+ addBlacklist(topicRelationId: number): Promise<void>;
1697
+ /**
1698
+ * 5. 订阅人黑名单列表。
1699
+ *
1700
+ * `query.params.topicId` 必填。
1701
+ */
1702
+ blacklistList(query: TopicUserListQuery): Promise<PageResult<TopicUserBlacklistItem>>;
1703
+ /**
1704
+ * 6. 解除订阅人黑名单。
1705
+ *
1706
+ * 解除后不会自动恢复群组订阅,对方可重新加入该群组。
1707
+ *
1708
+ * @param id 黑名单记录 ID(黑名单列表中的 id 字段)
1709
+ */
1710
+ removeBlacklist(id: number): Promise<void>;
1507
1711
  }
1508
1712
 
1509
1713
  /**
@@ -1575,6 +1779,7 @@ declare class PushPlusClient {
1575
1779
  readonly webhook: WebhookApi;
1576
1780
  readonly channel: ChannelApi;
1577
1781
  readonly clawBot: ClawBotApi;
1782
+ readonly qqBot: QqBotApi;
1578
1783
  readonly setting: SettingApi;
1579
1784
  readonly pre: PreApi;
1580
1785
  readonly image: ImageApi;
@@ -1671,4 +1876,4 @@ declare const CallbackParser: {
1671
1876
  parse: typeof parseCallback;
1672
1877
  };
1673
1878
 
1674
- export { AbstractApi, AccessKeyApi, AccessKeyManager, type AccessKeyResult, type ApiResponse, type BatchSendRequest, BatchSendRequestBuilder, type BatchSendResult, CallbackEvent, CallbackParser, type CallbackPayload, Channel, ChannelApi, ClawBotApi, type ClawBotInfo, type ClawBotMessage, type ClawBotQrCode, type CpItem, DEFAULT_BASE_URL, DocApi, type DocContent, type DocListItem, type DocListQuery, type DocVo, ErrorCode, ExcelApi, type ExcelContent, type ExcelVo, type ExcelWriteCellsRequest, FetchHttpRequester, FormApi, type FormCover, type FormDetail, type FormItem, type FormListItem, type FormListQuery, type FormPublishDiff, type FormPublishResult, type FormSaveRequest, type FormSettings, FormStatus, FormStatusDescription, type FormTheme, FriendApi, type FriendInfo, type FriendItem, type FriendQrCode, type HttpRawBody, type HttpRawRequestOptions, type HttpRequestOptions, type HttpRequester, type HttpResponse, ImageApi, type ImageFileInput, type ImageItem, type ImageUploadOptions, type ImageUploadResult, type ImageUploadToken, type MailDetail, type MailItem, MessageApi, type MessageCompleteInfo, type MessageItem, type MessageTokenAddRequest, MessageTokenApi, type MessageTokenEditRequest, type MessageTokenItem, type MessageTokenOption, type MpItem, OpenAbstractApi, OpenMessageApi, type PageQuery, type PageResult, PreApi, type PreDetail, type PreItem, type PreSaveRequest, type PreTestRequest, PushPlusClient, PushPlusClientBuilder, type PushPlusClientOptions, type PushPlusConfig, PushPlusError, PushPlusException, RateLimitGuard, type ResolvedPushPlusConfig, type SendCount, type SendMessageResult, type SendRequest, SendRequestBuilder, SendStatus, SendStatusDescription, SettingApi, ShareLogin, SharePerm, Template, type TopicAddRequest, TopicApi, type TopicDetail, type TopicEditRequest, type TopicItem, type TopicListQuery, type TopicQrCode, TopicUserApi, type TopicUserInfo, type TopicUserItem, type TopicUserListQuery, UserApi, type UserDefaultDetail, type UserDefaultItem, type UserDefaultSaveRequest, type UserInfo, type UserLimitTime, type VipInfo, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, callExecuteRaw, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };
1879
+ export { AbstractApi, AccessKeyApi, AccessKeyManager, type AccessKeyResult, type ApiResponse, type BatchSendRequest, BatchSendRequestBuilder, type BatchSendResult, CallbackEvent, CallbackParser, type CallbackPayload, Channel, ChannelApi, ClawBotApi, type ClawBotInfo, type ClawBotMessage, type ClawBotQrCode, type CpItem, DEFAULT_BASE_URL, DocApi, type DocContent, type DocListItem, type DocListQuery, type DocVo, ErrorCode, ExcelApi, type ExcelContent, type ExcelVo, type ExcelWriteCellsRequest, FetchHttpRequester, type FileInput, FormApi, type FormCover, type FormDetail, type FormItem, type FormListItem, type FormListQuery, type FormPublishDiff, type FormPublishResult, type FormSaveRequest, type FormSettings, FormStatus, FormStatusDescription, type FormTheme, FriendApi, type FriendBlacklistItem, type FriendInfo, type FriendItem, type FriendQrCode, type HttpRawBody, type HttpRawRequestOptions, type HttpRequestOptions, type HttpRequester, type HttpResponse, ImageApi, type ImageFileInput, type ImageItem, type ImageUploadOptions, type ImageUploadResult, type ImageUploadToken, type MailDetail, type MailItem, MessageApi, type MessageCompleteInfo, type MessageItem, type MessageTokenAddRequest, MessageTokenApi, type MessageTokenEditRequest, type MessageTokenItem, type MessageTokenOption, type MpItem, OpenAbstractApi, OpenMessageApi, type PageQuery, type PageResult, PreApi, type PreDetail, type PreItem, type PreSaveRequest, type PreTestRequest, PushPlusClient, PushPlusClientBuilder, type PushPlusClientOptions, type PushPlusConfig, PushPlusError, PushPlusException, QqBotApi, type QqBotBindInfo, type QqBotBindLink, type QqBotInfo, type QqBotItem, type QqBotSaveRequest, type QqGroupItem, RateLimitGuard, type ResolvedPushPlusConfig, type SendCount, type SendMessageResult, type SendRequest, SendRequestBuilder, SendStatus, SendStatusDescription, SettingApi, ShareLogin, SharePerm, Template, type TopicAddRequest, TopicApi, type TopicDetail, type TopicEditRequest, type TopicItem, type TopicListQuery, type TopicQrCode, TopicUserApi, type TopicUserBlacklistItem, type TopicUserInfo, type TopicUserItem, type TopicUserListQuery, UserApi, type UserDefaultDetail, type UserDefaultItem, type UserDefaultSaveRequest, type UserInfo, type UserLimitTime, type VipInfo, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, callExecuteRaw, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };