@kyan-du/agent-wechat-wechaty-puppet 0.14.0 → 0.14.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.
Files changed (2) hide show
  1. package/dist/mod.js +16 -4
  2. package/package.json +1 -1
package/dist/mod.js CHANGED
@@ -4150,6 +4150,14 @@ var openChatResultSchema = external_exports.object({
4150
4150
  errorCode: external_exports.string().optional(),
4151
4151
  error: external_exports.string().optional()
4152
4152
  });
4153
+ var downloadFileParamsSchema = external_exports.object({
4154
+ chatId: external_exports.string().min(1),
4155
+ filename: external_exports.string().min(1).optional(),
4156
+ executionTimeoutMs: external_exports.number().int().positive().optional()
4157
+ });
4158
+ var downloadFileResultSchema = openChatResultSchema.extend({
4159
+ clicked: external_exports.boolean().optional()
4160
+ });
4153
4161
  var idempotencyKeySchema = external_exports.string().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/);
4154
4162
  var forwardedMessageNodeSchema = external_exports.lazy(() => external_exports.object({
4155
4163
  sender: external_exports.string().optional(),
@@ -4336,11 +4344,12 @@ var WeChatClient = class {
4336
4344
  await throwHttpError(res);
4337
4345
  return res.json();
4338
4346
  }
4339
- async post(path, body) {
4347
+ async post(path, body, signal) {
4340
4348
  const res = await fetch(`${this.base}${path}`, {
4341
4349
  method: "POST",
4342
4350
  headers: this.headers,
4343
- body: body != null ? JSON.stringify(body) : void 0
4351
+ body: body != null ? JSON.stringify(body) : void 0,
4352
+ signal
4344
4353
  });
4345
4354
  if (!res.ok)
4346
4355
  await throwHttpError(res);
@@ -4385,8 +4394,11 @@ var WeChatClient = class {
4385
4394
  async markChatRead(chatId) {
4386
4395
  return this.post(`/api/chats/${encodeURIComponent(chatId)}/mark-read`);
4387
4396
  }
4388
- async openChat(chatId, clearUnreads) {
4389
- return this.post(`/api/chats/${encodeURIComponent(chatId)}/open${qs({ clearUnreads })}`);
4397
+ async openChat(chatId, clearUnreads, signal, executionTimeoutMs) {
4398
+ return this.post(`/api/chats/${encodeURIComponent(chatId)}/open${qs({ clearUnreads, executionTimeoutMs })}`, void 0, signal);
4399
+ }
4400
+ async downloadFile(chatId, filename, signal, executionTimeoutMs) {
4401
+ return this.post(`/api/chats/${encodeURIComponent(chatId)}/download-file${qs({ filename, executionTimeoutMs })}`, void 0, signal);
4390
4402
  }
4391
4403
  async listGroupMembersPage(groupId, limit, cursor) {
4392
4404
  const page = groupMembersPageSchema.parse(await this.get(`/api/groups/${encodeURIComponent(groupId)}/members${qs({ limit, cursor })}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyan-du/agent-wechat-wechaty-puppet",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "Wechaty Puppet for agent-wechat — bridges Wechaty bots to WeChat via the agent-wechat REST/WebSocket server",
5
5
  "type": "module",
6
6
  "main": "./dist/mod.js",