@perk-net/perk-pushplus-sdk 1.0.0 → 1.1.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/dist/index.d.cts CHANGED
@@ -70,6 +70,18 @@ interface HttpRequestOptions {
70
70
  headers?: Record<string, string>;
71
71
  body?: string | null;
72
72
  }
73
+ /**
74
+ * 二进制请求体(multipart 上传等场景使用)。
75
+ *
76
+ * 接受 fetch `BodyInit` 中的常见二进制形态。
77
+ */
78
+ type HttpRawBody = Uint8Array | ArrayBuffer | Blob | null;
79
+ interface HttpRawRequestOptions {
80
+ method: string;
81
+ url: string;
82
+ headers?: Record<string, string>;
83
+ body?: HttpRawBody;
84
+ }
73
85
  interface HttpResponse {
74
86
  statusCode: number;
75
87
  body: string;
@@ -79,10 +91,24 @@ interface HttpResponse {
79
91
  *
80
92
  * SDK 默认提供基于 `fetch` 的实现(Node 18+ 内置 / 浏览器原生)。
81
93
  * 调用方也可以自行实现并通过 `PushPlusClient` 注入以使用其它客户端(如 axios/undici/got)。
94
+ *
95
+ * `executeRaw` 用于二进制请求体场景(如图片 multipart 上传)。
96
+ * 自定义实现可选择覆写以正确处理二进制;未覆写时调用方应通过
97
+ * {@link callExecuteRaw} 适配回退到 `execute`。
82
98
  */
83
99
  interface HttpRequester {
84
100
  execute(options: HttpRequestOptions): Promise<HttpResponse>;
101
+ /** 可选:执行带二进制 body 的请求。 */
102
+ executeRaw?(options: HttpRawRequestOptions): Promise<HttpResponse>;
85
103
  }
104
+ /**
105
+ * 调用 {@link HttpRequester} 的二进制通道。
106
+ *
107
+ * - 若实现类提供了 `executeRaw`(推荐对二进制场景覆写),则直接使用;
108
+ * - 否则按 UTF-8 把字节解码成字符串后回退到 {@link HttpRequester.execute},
109
+ * 适用于 body 本身是文本的场景。
110
+ */
111
+ declare function callExecuteRaw(requester: HttpRequester, options: HttpRawRequestOptions): Promise<HttpResponse>;
86
112
  /**
87
113
  * 基于 fetch 的请求执行器。
88
114
  *
@@ -98,6 +124,8 @@ declare class FetchHttpRequester implements HttpRequester {
98
124
  private readonly fetchImpl;
99
125
  constructor(config: ResolvedPushPlusConfig, fetchImpl?: typeof fetch);
100
126
  execute(options: HttpRequestOptions): Promise<HttpResponse>;
127
+ executeRaw(options: HttpRawRequestOptions): Promise<HttpResponse>;
128
+ private doExecute;
101
129
  }
102
130
  /**
103
131
  * 是否处于成功的 HTTP 状态码区间(2xx)。
@@ -148,7 +176,9 @@ declare enum Template {
148
176
  /** 路由器插件定制模板。 */
149
177
  ROUTE = "route",
150
178
  /** 支付成功通知模板。 */
151
- PAY = "pay"
179
+ PAY = "pay",
180
+ /** 表单格式模板;发送时需传 pushId(表单编码)。 */
181
+ FORM = "form"
152
182
  }
153
183
  /**
154
184
  * 消息投递状态。
@@ -280,6 +310,8 @@ interface SendRequest {
280
310
  to?: string;
281
311
  /** 预处理编码(仅会员)。 */
282
312
  pre?: string;
313
+ /** push 表单编码;template 为 form 时必传。 */
314
+ pushId?: string;
283
315
  }
284
316
  declare class SendRequestBuilder {
285
317
  private req;
@@ -294,6 +326,7 @@ declare class SendRequestBuilder {
294
326
  timestamp(v?: number): this;
295
327
  to(v?: string): this;
296
328
  pre(v?: string): this;
329
+ pushId(v?: string): this;
297
330
  build(): SendRequest;
298
331
  }
299
332
  /**
@@ -317,6 +350,8 @@ interface BatchSendRequest {
317
350
  timestamp?: number;
318
351
  to?: string;
319
352
  pre?: string;
353
+ /** push 表单编码;template 为 form 时必传。 */
354
+ pushId?: string;
320
355
  }
321
356
  /**
322
357
  * 链式 Builder:支持以 `channel(Channel)` / `option(string)` 形式累积调用,
@@ -338,6 +373,7 @@ declare class BatchSendRequestBuilder {
338
373
  timestamp(v?: number): this;
339
374
  to(v?: string): this;
340
375
  pre(v?: string): this;
376
+ pushId(v?: string): this;
341
377
  /** 追加一个 channel。 */
342
378
  channel(ch: Channel | string): this;
343
379
  /** 追加一个 option,与最近一次 channel() 配对;可传空串。 */
@@ -706,6 +742,63 @@ interface PreTestRequest {
706
742
  contentType?: number;
707
743
  message?: string;
708
744
  }
745
+ /**
746
+ * 图片服务 - 获取上传凭证响应。
747
+ *
748
+ * 对应文档「十二. 图片服务接口 / 1. 获取上传凭证」。
749
+ * 返回七牛云表单上传所需的 token 及上传域名、存储桶等信息。
750
+ */
751
+ interface ImageUploadToken {
752
+ /** 七牛云上传凭证。 */
753
+ uploadToken?: string;
754
+ /** 七牛云上传域名,例如 `https://upload.qiniup.com`。 */
755
+ uploadHost?: string;
756
+ /** 七牛云上传地址,一般等同于 `uploadHost + "/"`。 */
757
+ uploadUrl?: string;
758
+ /** 七牛云存储桶名称。 */
759
+ bucket?: string;
760
+ /** 凭证有效时间(秒)。 */
761
+ expiresIn?: number;
762
+ }
763
+ /**
764
+ * 图片服务 - 上传图片响应(由七牛云直接返回)。
765
+ *
766
+ * 注意:该响应不是 PushPlus 统一的 `{code, msg, data}` 结构,
767
+ * 判断成功使用 `errno === 0`。
768
+ */
769
+ interface ImageUploadResult {
770
+ /** 错误码;0 表示成功。 */
771
+ errno?: number;
772
+ /** 文件扩展名,例如 `.png`。 */
773
+ ext?: string;
774
+ /** 文件名。 */
775
+ fname?: string;
776
+ /** 文件大小(字节)。 */
777
+ fsize?: number;
778
+ /** 七牛云文件 hash。 */
779
+ hash?: string;
780
+ /** 对象存储中的路径 key。 */
781
+ key?: string;
782
+ /** MIME 类型,例如 `image/png`。 */
783
+ mimeType?: string;
784
+ /** 响应说明。 */
785
+ msg?: string;
786
+ /** 缩略图地址。 */
787
+ thumbnail?: string;
788
+ /** 图片访问地址。 */
789
+ url?: string;
790
+ }
791
+ /** 图片服务 - 图片列表项。 */
792
+ interface ImageItem {
793
+ /** 图片 id。 */
794
+ id?: number;
795
+ /** 图片地址。 */
796
+ imgUrl?: string;
797
+ /** 缩略图地址。 */
798
+ thumbnail?: string;
799
+ /** 创建时间。 */
800
+ createTime?: string;
801
+ }
709
802
 
710
803
  /**
711
804
  * API 基类,提供请求执行与统一错误处理。
@@ -837,6 +930,68 @@ declare class FriendApi extends OpenAbstractApi {
837
930
  editRemark(id: number, remark: string): Promise<void>;
838
931
  }
839
932
 
933
+ /**
934
+ * 二进制图片输入。
935
+ *
936
+ * - `Uint8Array`:Node 与浏览器通用(Buffer 是 Uint8Array 的子类)
937
+ * - `ArrayBuffer`:原始字节缓冲
938
+ * - `Blob`/`File`:浏览器与 Node 18+ 都支持
939
+ */
940
+ type ImageFileInput = Uint8Array | ArrayBuffer | Blob;
941
+ /** 通用上传选项。 */
942
+ interface ImageUploadOptions {
943
+ /** 文件名(建议带扩展名,如 `logo.png`)。 */
944
+ fileName: string;
945
+ /** 文件 MIME 类型;未指定时按文件名后缀猜测。 */
946
+ contentType?: string;
947
+ }
948
+ /**
949
+ * 开放接口 - 图片服务(文档「十二. 图片服务接口」)。
950
+ *
951
+ * 包含 4 个接口:
952
+ *
953
+ * 1. {@link ImageApi.getUploadToken} 获取上传凭证
954
+ * 2. {@link ImageApi.upload} 上传图片到七牛云(multipart/form-data,**不**带 access-key)
955
+ * 3. {@link ImageApi.list} 已上传图片列表
956
+ * 4. {@link ImageApi.delete} 主动删除图片
957
+ *
958
+ * 另外提供 {@link ImageApi.uploadBytes} 等便捷方法,
959
+ * 内部自动「先取凭证 → 再上传」。仅支持图片类型,30 天有效期。
960
+ */
961
+ declare class ImageApi extends OpenAbstractApi {
962
+ constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
963
+ /** 1. 获取上传凭证。 */
964
+ getUploadToken(): Promise<ImageUploadToken>;
965
+ /**
966
+ * 2. 上传图片到七牛云。
967
+ *
968
+ * 使用「获取上传凭证」返回的 `uploadUrl` 与 `uploadToken`,
969
+ * 按七牛云表单上传规范以 `multipart/form-data` 提交。该请求
970
+ * **不会** 携带 PushPlus 的 `access-key` 头。
971
+ */
972
+ upload(token: ImageUploadToken, file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
973
+ /**
974
+ * 2. 上传图片到七牛云(低层方法)。直接指定上传地址与 token。
975
+ */
976
+ uploadToQiniu(uploadUrl: string, uploadToken: string, file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
977
+ /**
978
+ * 便捷方法:自动获取上传凭证后上传字节数组 / Blob / ArrayBuffer。
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * await client.image.uploadBytes(buffer, { fileName: 'a.png' });
983
+ * await client.image.uploadBytes(blob, { fileName: 'b.jpg', contentType: 'image/jpeg' });
984
+ * ```
985
+ */
986
+ uploadBytes(file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
987
+ /** 3. 图片列表。 */
988
+ list(query?: PageQuery): Promise<PageResult<ImageItem>>;
989
+ /**
990
+ * 4. 主动删除图片;未删除的图片默认 30 天后由系统自动清理。
991
+ */
992
+ delete(id: number): Promise<void>;
993
+ }
994
+
840
995
  /**
841
996
  * 本地限流守卫:当 PushPlus 服务端返回 ErrorCode.RATE_LIMITED(code=900)时,
842
997
  * 在内存里按 token 维度记录"解禁时间",期间任何发送类调用都会直接抛 PushPlusError,
@@ -1115,6 +1270,7 @@ declare class PushPlusClient {
1115
1270
  readonly clawBot: ClawBotApi;
1116
1271
  readonly setting: SettingApi;
1117
1272
  readonly pre: PreApi;
1273
+ readonly image: ImageApi;
1118
1274
  constructor(options?: PushPlusClientOptions);
1119
1275
  /** 与 Java SDK 风格一致的 Builder 入口。 */
1120
1276
  static builder(): PushPlusClientBuilder;
@@ -1205,4 +1361,4 @@ declare const CallbackParser: {
1205
1361
  parse: typeof parseCallback;
1206
1362
  };
1207
1363
 
1208
- 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, ErrorCode, FetchHttpRequester, FriendApi, type FriendInfo, type FriendItem, type FriendQrCode, type HttpRequestOptions, type HttpRequester, type HttpResponse, 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, 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, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };
1364
+ 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, ErrorCode, FetchHttpRequester, 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, 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, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, callExecuteRaw, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };
package/dist/index.d.ts CHANGED
@@ -70,6 +70,18 @@ interface HttpRequestOptions {
70
70
  headers?: Record<string, string>;
71
71
  body?: string | null;
72
72
  }
73
+ /**
74
+ * 二进制请求体(multipart 上传等场景使用)。
75
+ *
76
+ * 接受 fetch `BodyInit` 中的常见二进制形态。
77
+ */
78
+ type HttpRawBody = Uint8Array | ArrayBuffer | Blob | null;
79
+ interface HttpRawRequestOptions {
80
+ method: string;
81
+ url: string;
82
+ headers?: Record<string, string>;
83
+ body?: HttpRawBody;
84
+ }
73
85
  interface HttpResponse {
74
86
  statusCode: number;
75
87
  body: string;
@@ -79,10 +91,24 @@ interface HttpResponse {
79
91
  *
80
92
  * SDK 默认提供基于 `fetch` 的实现(Node 18+ 内置 / 浏览器原生)。
81
93
  * 调用方也可以自行实现并通过 `PushPlusClient` 注入以使用其它客户端(如 axios/undici/got)。
94
+ *
95
+ * `executeRaw` 用于二进制请求体场景(如图片 multipart 上传)。
96
+ * 自定义实现可选择覆写以正确处理二进制;未覆写时调用方应通过
97
+ * {@link callExecuteRaw} 适配回退到 `execute`。
82
98
  */
83
99
  interface HttpRequester {
84
100
  execute(options: HttpRequestOptions): Promise<HttpResponse>;
101
+ /** 可选:执行带二进制 body 的请求。 */
102
+ executeRaw?(options: HttpRawRequestOptions): Promise<HttpResponse>;
85
103
  }
104
+ /**
105
+ * 调用 {@link HttpRequester} 的二进制通道。
106
+ *
107
+ * - 若实现类提供了 `executeRaw`(推荐对二进制场景覆写),则直接使用;
108
+ * - 否则按 UTF-8 把字节解码成字符串后回退到 {@link HttpRequester.execute},
109
+ * 适用于 body 本身是文本的场景。
110
+ */
111
+ declare function callExecuteRaw(requester: HttpRequester, options: HttpRawRequestOptions): Promise<HttpResponse>;
86
112
  /**
87
113
  * 基于 fetch 的请求执行器。
88
114
  *
@@ -98,6 +124,8 @@ declare class FetchHttpRequester implements HttpRequester {
98
124
  private readonly fetchImpl;
99
125
  constructor(config: ResolvedPushPlusConfig, fetchImpl?: typeof fetch);
100
126
  execute(options: HttpRequestOptions): Promise<HttpResponse>;
127
+ executeRaw(options: HttpRawRequestOptions): Promise<HttpResponse>;
128
+ private doExecute;
101
129
  }
102
130
  /**
103
131
  * 是否处于成功的 HTTP 状态码区间(2xx)。
@@ -148,7 +176,9 @@ declare enum Template {
148
176
  /** 路由器插件定制模板。 */
149
177
  ROUTE = "route",
150
178
  /** 支付成功通知模板。 */
151
- PAY = "pay"
179
+ PAY = "pay",
180
+ /** 表单格式模板;发送时需传 pushId(表单编码)。 */
181
+ FORM = "form"
152
182
  }
153
183
  /**
154
184
  * 消息投递状态。
@@ -280,6 +310,8 @@ interface SendRequest {
280
310
  to?: string;
281
311
  /** 预处理编码(仅会员)。 */
282
312
  pre?: string;
313
+ /** push 表单编码;template 为 form 时必传。 */
314
+ pushId?: string;
283
315
  }
284
316
  declare class SendRequestBuilder {
285
317
  private req;
@@ -294,6 +326,7 @@ declare class SendRequestBuilder {
294
326
  timestamp(v?: number): this;
295
327
  to(v?: string): this;
296
328
  pre(v?: string): this;
329
+ pushId(v?: string): this;
297
330
  build(): SendRequest;
298
331
  }
299
332
  /**
@@ -317,6 +350,8 @@ interface BatchSendRequest {
317
350
  timestamp?: number;
318
351
  to?: string;
319
352
  pre?: string;
353
+ /** push 表单编码;template 为 form 时必传。 */
354
+ pushId?: string;
320
355
  }
321
356
  /**
322
357
  * 链式 Builder:支持以 `channel(Channel)` / `option(string)` 形式累积调用,
@@ -338,6 +373,7 @@ declare class BatchSendRequestBuilder {
338
373
  timestamp(v?: number): this;
339
374
  to(v?: string): this;
340
375
  pre(v?: string): this;
376
+ pushId(v?: string): this;
341
377
  /** 追加一个 channel。 */
342
378
  channel(ch: Channel | string): this;
343
379
  /** 追加一个 option,与最近一次 channel() 配对;可传空串。 */
@@ -706,6 +742,63 @@ interface PreTestRequest {
706
742
  contentType?: number;
707
743
  message?: string;
708
744
  }
745
+ /**
746
+ * 图片服务 - 获取上传凭证响应。
747
+ *
748
+ * 对应文档「十二. 图片服务接口 / 1. 获取上传凭证」。
749
+ * 返回七牛云表单上传所需的 token 及上传域名、存储桶等信息。
750
+ */
751
+ interface ImageUploadToken {
752
+ /** 七牛云上传凭证。 */
753
+ uploadToken?: string;
754
+ /** 七牛云上传域名,例如 `https://upload.qiniup.com`。 */
755
+ uploadHost?: string;
756
+ /** 七牛云上传地址,一般等同于 `uploadHost + "/"`。 */
757
+ uploadUrl?: string;
758
+ /** 七牛云存储桶名称。 */
759
+ bucket?: string;
760
+ /** 凭证有效时间(秒)。 */
761
+ expiresIn?: number;
762
+ }
763
+ /**
764
+ * 图片服务 - 上传图片响应(由七牛云直接返回)。
765
+ *
766
+ * 注意:该响应不是 PushPlus 统一的 `{code, msg, data}` 结构,
767
+ * 判断成功使用 `errno === 0`。
768
+ */
769
+ interface ImageUploadResult {
770
+ /** 错误码;0 表示成功。 */
771
+ errno?: number;
772
+ /** 文件扩展名,例如 `.png`。 */
773
+ ext?: string;
774
+ /** 文件名。 */
775
+ fname?: string;
776
+ /** 文件大小(字节)。 */
777
+ fsize?: number;
778
+ /** 七牛云文件 hash。 */
779
+ hash?: string;
780
+ /** 对象存储中的路径 key。 */
781
+ key?: string;
782
+ /** MIME 类型,例如 `image/png`。 */
783
+ mimeType?: string;
784
+ /** 响应说明。 */
785
+ msg?: string;
786
+ /** 缩略图地址。 */
787
+ thumbnail?: string;
788
+ /** 图片访问地址。 */
789
+ url?: string;
790
+ }
791
+ /** 图片服务 - 图片列表项。 */
792
+ interface ImageItem {
793
+ /** 图片 id。 */
794
+ id?: number;
795
+ /** 图片地址。 */
796
+ imgUrl?: string;
797
+ /** 缩略图地址。 */
798
+ thumbnail?: string;
799
+ /** 创建时间。 */
800
+ createTime?: string;
801
+ }
709
802
 
710
803
  /**
711
804
  * API 基类,提供请求执行与统一错误处理。
@@ -837,6 +930,68 @@ declare class FriendApi extends OpenAbstractApi {
837
930
  editRemark(id: number, remark: string): Promise<void>;
838
931
  }
839
932
 
933
+ /**
934
+ * 二进制图片输入。
935
+ *
936
+ * - `Uint8Array`:Node 与浏览器通用(Buffer 是 Uint8Array 的子类)
937
+ * - `ArrayBuffer`:原始字节缓冲
938
+ * - `Blob`/`File`:浏览器与 Node 18+ 都支持
939
+ */
940
+ type ImageFileInput = Uint8Array | ArrayBuffer | Blob;
941
+ /** 通用上传选项。 */
942
+ interface ImageUploadOptions {
943
+ /** 文件名(建议带扩展名,如 `logo.png`)。 */
944
+ fileName: string;
945
+ /** 文件 MIME 类型;未指定时按文件名后缀猜测。 */
946
+ contentType?: string;
947
+ }
948
+ /**
949
+ * 开放接口 - 图片服务(文档「十二. 图片服务接口」)。
950
+ *
951
+ * 包含 4 个接口:
952
+ *
953
+ * 1. {@link ImageApi.getUploadToken} 获取上传凭证
954
+ * 2. {@link ImageApi.upload} 上传图片到七牛云(multipart/form-data,**不**带 access-key)
955
+ * 3. {@link ImageApi.list} 已上传图片列表
956
+ * 4. {@link ImageApi.delete} 主动删除图片
957
+ *
958
+ * 另外提供 {@link ImageApi.uploadBytes} 等便捷方法,
959
+ * 内部自动「先取凭证 → 再上传」。仅支持图片类型,30 天有效期。
960
+ */
961
+ declare class ImageApi extends OpenAbstractApi {
962
+ constructor(config: ResolvedPushPlusConfig, http: HttpRequester, mgr: AccessKeyManager);
963
+ /** 1. 获取上传凭证。 */
964
+ getUploadToken(): Promise<ImageUploadToken>;
965
+ /**
966
+ * 2. 上传图片到七牛云。
967
+ *
968
+ * 使用「获取上传凭证」返回的 `uploadUrl` 与 `uploadToken`,
969
+ * 按七牛云表单上传规范以 `multipart/form-data` 提交。该请求
970
+ * **不会** 携带 PushPlus 的 `access-key` 头。
971
+ */
972
+ upload(token: ImageUploadToken, file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
973
+ /**
974
+ * 2. 上传图片到七牛云(低层方法)。直接指定上传地址与 token。
975
+ */
976
+ uploadToQiniu(uploadUrl: string, uploadToken: string, file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
977
+ /**
978
+ * 便捷方法:自动获取上传凭证后上传字节数组 / Blob / ArrayBuffer。
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * await client.image.uploadBytes(buffer, { fileName: 'a.png' });
983
+ * await client.image.uploadBytes(blob, { fileName: 'b.jpg', contentType: 'image/jpeg' });
984
+ * ```
985
+ */
986
+ uploadBytes(file: ImageFileInput, options: ImageUploadOptions): Promise<ImageUploadResult>;
987
+ /** 3. 图片列表。 */
988
+ list(query?: PageQuery): Promise<PageResult<ImageItem>>;
989
+ /**
990
+ * 4. 主动删除图片;未删除的图片默认 30 天后由系统自动清理。
991
+ */
992
+ delete(id: number): Promise<void>;
993
+ }
994
+
840
995
  /**
841
996
  * 本地限流守卫:当 PushPlus 服务端返回 ErrorCode.RATE_LIMITED(code=900)时,
842
997
  * 在内存里按 token 维度记录"解禁时间",期间任何发送类调用都会直接抛 PushPlusError,
@@ -1115,6 +1270,7 @@ declare class PushPlusClient {
1115
1270
  readonly clawBot: ClawBotApi;
1116
1271
  readonly setting: SettingApi;
1117
1272
  readonly pre: PreApi;
1273
+ readonly image: ImageApi;
1118
1274
  constructor(options?: PushPlusClientOptions);
1119
1275
  /** 与 Java SDK 风格一致的 Builder 入口。 */
1120
1276
  static builder(): PushPlusClientBuilder;
@@ -1205,4 +1361,4 @@ declare const CallbackParser: {
1205
1361
  parse: typeof parseCallback;
1206
1362
  };
1207
1363
 
1208
- 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, ErrorCode, FetchHttpRequester, FriendApi, type FriendInfo, type FriendItem, type FriendQrCode, type HttpRequestOptions, type HttpRequester, type HttpResponse, 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, 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, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };
1364
+ 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, ErrorCode, FetchHttpRequester, 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, 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, WebhookApi, type WebhookItem, type WebhookSaveRequest, WebhookType, WebhookTypeDescription, batchSendRequest, callExecuteRaw, errorCodeFromValue, isRateLimitedCode, isSuccessfulHttpStatus, parseCallback, resolveConfig, sendRequest };