@open-wa/schema 5.0.0 → 5.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.
Files changed (70) hide show
  1. package/dist/generated/index.cjs +8 -2
  2. package/dist/generated/index.cjs.map +1 -1
  3. package/dist/generated/index.d.cts +715 -1
  4. package/dist/generated/index.d.cts.map +1 -1
  5. package/dist/generated/index.d.mts +715 -1
  6. package/dist/generated/index.d.mts.map +1 -1
  7. package/dist/generated/index.mjs +8 -2
  8. package/dist/generated/index.mjs.map +1 -1
  9. package/dist/{index-ChYFQM1K.d.cts → index-DTztyYhw.d.cts} +893 -3
  10. package/dist/index-DTztyYhw.d.cts.map +1 -0
  11. package/dist/{index-BHcd0h7x.d.mts → index-nVKR0RmZ.d.mts} +893 -3
  12. package/dist/index-nVKR0RmZ.d.mts.map +1 -0
  13. package/dist/index.cjs +51 -1
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +2 -2
  16. package/dist/index.d.mts +2 -2
  17. package/dist/index.mjs +24 -2
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/methods/index.cjs +5 -1
  20. package/dist/methods/index.d.cts +2 -2
  21. package/dist/methods/index.d.mts +2 -2
  22. package/dist/methods/index.mjs +2 -2
  23. package/dist/{methods-CZqeUhKy.mjs → methods-BSv5O3bS.mjs} +317 -2
  24. package/dist/methods-BSv5O3bS.mjs.map +1 -0
  25. package/dist/{methods-Dizm7Fn9.cjs → methods-DO0JONvB.cjs} +472 -1
  26. package/dist/methods-DO0JONvB.cjs.map +1 -0
  27. package/package.json +4 -3
  28. package/src/__tests__/generators.contract.test.ts +181 -0
  29. package/src/__tests__/registry.contract.test.ts +81 -0
  30. package/src/client-config.ts +30 -0
  31. package/src/codecs.test.ts +41 -0
  32. package/src/codecs.ts +191 -0
  33. package/src/common-types.ts +280 -0
  34. package/src/config.ts +47 -0
  35. package/src/enums.ts +63 -0
  36. package/src/events/groups.ts +33 -0
  37. package/src/events/index.ts +4 -0
  38. package/src/events/messaging.ts +86 -0
  39. package/src/events/registry.ts +124 -0
  40. package/src/events/state.ts +59 -0
  41. package/src/generated/AliasMap.ts +216 -0
  42. package/src/generated/BaseClient.ts +878 -0
  43. package/src/generated/BaseNamespacedClient.ts +214 -0
  44. package/src/generated/index.ts +5 -0
  45. package/src/generated/openapi.json +8949 -0
  46. package/src/generated/types.ts +383 -0
  47. package/src/http-manifest.ts +97 -0
  48. package/src/implementor.test.ts +88 -0
  49. package/src/implementor.ts +75 -0
  50. package/src/index.ts +44 -0
  51. package/src/interactive.ts +151 -0
  52. package/src/methods/business.ts +51 -0
  53. package/src/methods/chats.ts +263 -0
  54. package/src/methods/communities.ts +119 -0
  55. package/src/methods/contacts.ts +158 -0
  56. package/src/methods/groups.ts +376 -0
  57. package/src/methods/index.ts +34 -0
  58. package/src/methods/interactive.ts +21 -0
  59. package/src/methods/labels.ts +86 -0
  60. package/src/methods/media.ts +36 -0
  61. package/src/methods/messaging.ts +828 -0
  62. package/src/methods/session.ts +261 -0
  63. package/src/methods/status.ts +120 -0
  64. package/src/parameters.ts +237 -0
  65. package/src/registry.test.ts +30 -0
  66. package/src/registry.ts +601 -0
  67. package/dist/index-BHcd0h7x.d.mts.map +0 -1
  68. package/dist/index-ChYFQM1K.d.cts.map +0 -1
  69. package/dist/methods-CZqeUhKy.mjs.map +0 -1
  70. package/dist/methods-Dizm7Fn9.cjs.map +0 -1
@@ -0,0 +1,828 @@
1
+ import { z } from 'zod';
2
+ import { defineMethodV2 } from '../registry';
3
+ import { MessageIdReturnSchema } from '../common-types';
4
+ import {
5
+ chatIdParam,
6
+ toParam,
7
+ contentParam,
8
+ messageOptionsParam,
9
+ imageDataParam,
10
+ filenameParam,
11
+ captionParam,
12
+ messageIdParam,
13
+ waitForIdParam,
14
+ messageIdsParam,
15
+ skipMyMessagesParam,
16
+ latitudeParam,
17
+ longitudeParam,
18
+ locationNameParam,
19
+ contactIdParam,
20
+ mentionedJidListParam,
21
+ fileDataParam,
22
+ audioDataParam,
23
+ videoDataParam
24
+ } from '../parameters';
25
+
26
+ // ============================================================================
27
+ // Messaging Methods
28
+ // ============================================================================
29
+
30
+ /**
31
+ * Sends a text message to a chat
32
+ */
33
+ export const sendText = defineMethodV2('sendText', {
34
+ meta: {
35
+ description: 'Sends a text message to a chat',
36
+ action: 'send',
37
+ namespace: 'messages',
38
+ license: 'none',
39
+ functionality: 'both',
40
+ httpMethod: 'POST',
41
+ },
42
+ input: z.object({
43
+ to: toParam,
44
+ content: contentParam,
45
+ options: messageOptionsParam
46
+ }),
47
+ parameterOrder: ['to', 'content', 'options'],
48
+ output: MessageIdReturnSchema.or(z.boolean()).or(z.string())
49
+ });
50
+
51
+ /**
52
+ * Sends a text message with mentions
53
+ */
54
+ export const sendTextWithMentions = defineMethodV2('sendTextWithMentions', {
55
+ meta: {
56
+ description: 'Sends a text message that includes @mentions',
57
+ action: 'send',
58
+ namespace: 'messages',
59
+ license: 'none',
60
+ functionality: 'both',
61
+ httpMethod: 'POST',
62
+ },
63
+ input: z.object({
64
+ to: toParam,
65
+ content: contentParam,
66
+ hideTags: z.boolean().optional().describe('Removes all tags within the message'),
67
+ mentions: mentionedJidListParam
68
+ }),
69
+ parameterOrder: ['to', 'content', 'hideTags', 'mentions'],
70
+ output: MessageIdReturnSchema.or(z.boolean())
71
+ });
72
+
73
+ /**
74
+ * Sends a reply with mentions
75
+ */
76
+ export const sendReplyWithMentions = defineMethodV2('sendReplyWithMentions', {
77
+ meta: {
78
+ description: 'Sends a reply to a message that includes @mentions',
79
+ action: 'send',
80
+ namespace: 'messages',
81
+ license: 'none',
82
+ functionality: 'both',
83
+ httpMethod: 'POST',
84
+ },
85
+ input: z.object({
86
+ to: toParam,
87
+ content: contentParam,
88
+ replyMessageId: messageIdParam,
89
+ hideTags: z.boolean().optional().describe('Removes all tags within the message'),
90
+ mentions: mentionedJidListParam
91
+ }),
92
+ parameterOrder: ['to', 'content', 'replyMessageId', 'hideTags', 'mentions'],
93
+ output: MessageIdReturnSchema.or(z.boolean())
94
+ });
95
+
96
+ /**
97
+ * Sends a payment request
98
+ */
99
+ export const sendPaymentRequest = defineMethodV2('sendPaymentRequest', {
100
+ meta: {
101
+ description: 'Sends a payment request message',
102
+ action: 'send',
103
+ namespace: 'messages',
104
+ license: 'none',
105
+ functionality: 'both',
106
+ httpMethod: 'POST',
107
+ },
108
+ input: z.object({
109
+ to: toParam,
110
+ amount: z.number().describe('Amount in 1000 format (e.g £10 => 10000)'),
111
+ currency: z.string().length(3).describe('3 letter currency code'),
112
+ message: z.string().optional().describe('Optional message')
113
+ }),
114
+ parameterOrder: ['to', 'amount', 'currency', 'message'],
115
+ output: MessageIdReturnSchema.or(z.boolean())
116
+ });
117
+
118
+ /**
119
+ * Sends an image to a chat
120
+ */
121
+ export const sendImage = defineMethodV2('sendImage', {
122
+ meta: {
123
+ description: 'Sends an image to a chat',
124
+ action: 'send',
125
+ namespace: 'messages',
126
+ license: 'none',
127
+ functionality: 'both',
128
+ httpMethod: 'POST',
129
+ },
130
+ input: z.object({
131
+ to: toParam,
132
+ imgData: imageDataParam,
133
+ filename: filenameParam,
134
+ caption: captionParam,
135
+ id: messageIdParam.optional(),
136
+ waitForId: waitForIdParam
137
+ }),
138
+ parameterOrder: ['to', 'imgData', 'filename', 'caption', 'id', 'waitForId'],
139
+ output: MessageIdReturnSchema.or(z.boolean()).or(z.string())
140
+ });
141
+
142
+ /**
143
+ * Sends a file/document
144
+ */
145
+ export const sendFile = defineMethodV2('sendFile', {
146
+ meta: {
147
+ description: 'Sends a file or document to a chat',
148
+ action: 'send',
149
+ namespace: 'messages',
150
+ license: 'none',
151
+ functionality: 'both',
152
+ httpMethod: 'POST',
153
+ },
154
+ input: z.object({
155
+ to: toParam,
156
+ file: fileDataParam,
157
+ filename: filenameParam,
158
+ caption: captionParam
159
+ }),
160
+ parameterOrder: ['to', 'file', 'filename', 'caption'],
161
+ output: MessageIdReturnSchema.or(z.string())
162
+ });
163
+
164
+ /**
165
+ * Sends an audio file
166
+ */
167
+ export const sendAudio = defineMethodV2('sendAudio', {
168
+ meta: {
169
+ description: 'Sends an audio file to a chat',
170
+ action: 'send',
171
+ namespace: 'messages',
172
+ license: 'none',
173
+ functionality: 'both',
174
+ httpMethod: 'POST',
175
+ },
176
+ input: z.object({
177
+ to: toParam,
178
+ file: audioDataParam,
179
+ filename: filenameParam,
180
+ quotedMsgId: messageIdParam.optional()
181
+ }),
182
+ parameterOrder: ['to', 'file', 'filename', 'quotedMsgId'],
183
+ output: MessageIdReturnSchema.or(z.boolean())
184
+ });
185
+
186
+ /**
187
+ * Sends a voice note (PTT)
188
+ */
189
+ export const sendPtt = defineMethodV2('sendPtt', {
190
+ meta: {
191
+ description: 'Sends a voice note (push-to-talk) to a chat',
192
+ action: 'send',
193
+ namespace: 'messages',
194
+ license: 'none',
195
+ functionality: 'both',
196
+ httpMethod: 'POST',
197
+ aliases: {
198
+ explicit: ['sendVoiceNote'],
199
+ },
200
+ },
201
+ input: z.object({
202
+ to: toParam,
203
+ file: audioDataParam,
204
+ quotedMsgId: messageIdParam.optional()
205
+ }),
206
+ parameterOrder: ['to', 'file', 'quotedMsgId'],
207
+ output: MessageIdReturnSchema.or(z.boolean())
208
+ });
209
+
210
+ /**
211
+ * Sends a video as GIF
212
+ */
213
+ export const sendVideoAsGif = defineMethodV2('sendVideoAsGif', {
214
+ meta: {
215
+ description: 'Sends a video as an animated GIF',
216
+ action: 'send',
217
+ namespace: 'messages',
218
+ license: 'none',
219
+ functionality: 'both',
220
+ httpMethod: 'POST',
221
+ },
222
+ input: z.object({
223
+ to: toParam,
224
+ file: videoDataParam,
225
+ filename: filenameParam,
226
+ caption: captionParam,
227
+ quotedMsgId: messageIdParam.optional()
228
+ }),
229
+ parameterOrder: ['to', 'file', 'filename', 'caption', 'quotedMsgId'],
230
+ output: MessageIdReturnSchema.or(z.boolean())
231
+ });
232
+
233
+ /**
234
+ * Sends a location
235
+ */
236
+ export const sendLocation = defineMethodV2('sendLocation', {
237
+ meta: {
238
+ description: 'Sends a location to a chat',
239
+ action: 'send',
240
+ namespace: 'messages',
241
+ license: 'none',
242
+ functionality: 'both',
243
+ httpMethod: 'POST',
244
+ },
245
+ input: z.object({
246
+ to: toParam,
247
+ lat: latitudeParam,
248
+ lng: longitudeParam,
249
+ loc: locationNameParam,
250
+ address: z.string().optional().describe('Address text'),
251
+ url: z.string().url().optional().describe('Address link')
252
+ }),
253
+ parameterOrder: ['to', 'lat', 'lng', 'loc', 'address', 'url'],
254
+ output: MessageIdReturnSchema.or(z.boolean())
255
+ });
256
+
257
+ /**
258
+ * Sends a vCard
259
+ */
260
+ export const sendVCard = defineMethodV2('sendVCard', {
261
+ meta: {
262
+ description: 'Sends a contact card (vCard)',
263
+ action: 'send',
264
+ namespace: 'messages',
265
+ license: 'none',
266
+ functionality: 'both',
267
+ httpMethod: 'POST',
268
+ },
269
+ input: z.object({
270
+ to: toParam,
271
+ vcard: z.string().describe('vCard string'),
272
+ contactName: z.string().optional().describe('Contact display name'),
273
+ contactNumber: z.string().optional().describe('Contact number with country code')
274
+ }),
275
+ parameterOrder: ['to', 'vcard', 'contactName', 'contactNumber'],
276
+ output: z.boolean()
277
+ });
278
+
279
+ /**
280
+ * Sends a contact
281
+ */
282
+ export const sendContact = defineMethodV2('sendContact', {
283
+ meta: {
284
+ description: 'Sends a single contact',
285
+ action: 'send',
286
+ namespace: 'messages',
287
+ license: 'none',
288
+ functionality: 'both',
289
+ httpMethod: 'POST',
290
+ },
291
+ input: z.object({
292
+ to: toParam,
293
+ contactId: contactIdParam.or(z.array(contactIdParam))
294
+ }),
295
+ parameterOrder: ['to', 'contactId'],
296
+ output: MessageIdReturnSchema.or(z.boolean())
297
+ });
298
+
299
+ /**
300
+ * Sends multiple contacts
301
+ */
302
+ export const sendMultipleContacts = defineMethodV2('sendMultipleContacts', {
303
+ meta: {
304
+ description: 'Sends multiple contacts',
305
+ action: 'send',
306
+ namespace: 'messages',
307
+ license: 'none',
308
+ functionality: 'both',
309
+ httpMethod: 'POST',
310
+ aliases: {
311
+ explicit: ['sendContacts'],
312
+ namespacedName: 'sendContacts',
313
+ },
314
+ },
315
+ input: z.object({
316
+ to: toParam,
317
+ contactIds: z.array(contactIdParam)
318
+ }),
319
+ parameterOrder: ['to', 'contactIds'],
320
+ output: MessageIdReturnSchema.or(z.boolean())
321
+ });
322
+
323
+ /**
324
+ * Sends button message
325
+ */
326
+ export const sendButtons = defineMethodV2('sendButtons', {
327
+ meta: {
328
+ description: 'Sends a button message (deprecated)',
329
+ action: 'send',
330
+ namespace: 'messages',
331
+ license: 'insiders',
332
+ functionality: 'both',
333
+ httpMethod: 'POST',
334
+ },
335
+ input: z.object({
336
+ to: toParam,
337
+ body: z.union([z.string(), z.any()]).describe('Message body or location'),
338
+ buttons: z.array(z.any()).max(3).describe('Array of buttons (max 3)'),
339
+ title: z.string().optional().describe('Message title'),
340
+ footer: z.string().optional().describe('Message footer')
341
+ }),
342
+ parameterOrder: ['to', 'body', 'buttons', 'title', 'footer'],
343
+ output: MessageIdReturnSchema.or(z.boolean())
344
+ });
345
+
346
+ /**
347
+ * Sends advanced button message
348
+ */
349
+ export const sendAdvancedButtons = defineMethodV2('sendAdvancedButtons', {
350
+ meta: {
351
+ description: 'Sends an advanced button message with media (deprecated)',
352
+ action: 'send',
353
+ namespace: 'messages',
354
+ license: 'insiders',
355
+ functionality: 'both',
356
+ httpMethod: 'POST',
357
+ },
358
+ input: z.object({
359
+ to: toParam,
360
+ body: z.union([z.string(), z.any()]).describe('Message body, location, or media'),
361
+ buttons: z.array(z.any()).max(3).describe('Array of advanced buttons (max 3)'),
362
+ text: z.string().describe('Message text'),
363
+ footer: z.string().describe('Message footer'),
364
+ filename: z.string().describe('Filename if body is a file')
365
+ }),
366
+ parameterOrder: ['to', 'body', 'buttons', 'text', 'footer', 'filename'],
367
+ output: MessageIdReturnSchema.or(z.boolean())
368
+ });
369
+
370
+ /**
371
+ * Sends list message
372
+ */
373
+ export const sendListMessage = defineMethodV2('sendListMessage', {
374
+ meta: {
375
+ description: 'Sends a list/menu message (deprecated)',
376
+ action: 'send',
377
+ namespace: 'messages',
378
+ license: 'insiders',
379
+ functionality: 'both',
380
+ httpMethod: 'POST',
381
+ aliases: {
382
+ explicit: ['sendList'],
383
+ },
384
+ },
385
+ input: z.object({
386
+ to: toParam,
387
+ sections: z.array(z.any()).describe('List sections'),
388
+ title: z.string().describe('List title'),
389
+ description: z.string().describe('List description'),
390
+ actionText: z.string().describe('Action button text')
391
+ }),
392
+ parameterOrder: ['to', 'sections', 'title', 'description', 'actionText'],
393
+ output: MessageIdReturnSchema.or(z.boolean())
394
+ });
395
+
396
+ /**
397
+ * Sends a poll
398
+ */
399
+ export const sendPoll = defineMethodV2('sendPoll', {
400
+ meta: {
401
+ description: 'Sends a poll message',
402
+ action: 'send',
403
+ namespace: 'messages',
404
+ license: 'none',
405
+ functionality: 'both',
406
+ httpMethod: 'POST',
407
+ },
408
+ input: z.object({
409
+ to: toParam,
410
+ name: z.string().describe('Poll question'),
411
+ options: z.array(z.string()).min(2).max(12).describe('Poll options (2-12)'),
412
+ selectableCount: z.number().optional().default(1).describe('Number of selectable options')
413
+ }),
414
+ parameterOrder: ['to', 'name', 'options', 'selectableCount'],
415
+ output: MessageIdReturnSchema.or(z.boolean())
416
+ });
417
+
418
+ /**
419
+ * Sends a banner image
420
+ */
421
+ export const sendBanner = defineMethodV2('sendBanner', {
422
+ meta: {
423
+ description: 'Sends a banner image',
424
+ action: 'send',
425
+ namespace: 'messages',
426
+ license: 'none',
427
+ functionality: 'both',
428
+ httpMethod: 'POST',
429
+ },
430
+ input: z.object({
431
+ to: toParam,
432
+ base64: z.string().describe('Base64 encoded JPEG')
433
+ }),
434
+ parameterOrder: ['to', 'base64'],
435
+ output: MessageIdReturnSchema.or(z.boolean())
436
+ });
437
+
438
+ /**
439
+ * Sends YouTube link with preview
440
+ */
441
+ export const sendYouTubeLink = defineMethodV2('sendYouTubeLink', {
442
+ meta: {
443
+ description: 'Sends a YouTube link with auto-generated preview',
444
+ action: 'send',
445
+ namespace: 'messages',
446
+ license: 'none',
447
+ functionality: 'both',
448
+ httpMethod: 'POST',
449
+ aliases: {
450
+ deprecated: ['sendYoutubeLink'],
451
+ },
452
+ wapiOverride: 'sendYoutubeLink',
453
+ },
454
+ input: z.object({
455
+ to: toParam,
456
+ url: z.string().url().describe('YouTube URL'),
457
+ text: contentParam.optional().default(''),
458
+ thumbnail: z.string().optional().describe('Base64 thumbnail override'),
459
+ quotedMsgId: messageIdParam.optional(),
460
+ customSize: z.object({
461
+ height: z.number(),
462
+ width: z.number()
463
+ }).optional().describe('Custom thumbnail size')
464
+ }),
465
+ parameterOrder: ['to', 'url', 'text', 'thumbnail', 'quotedMsgId', 'customSize'],
466
+ output: MessageIdReturnSchema.or(z.boolean())
467
+ });
468
+
469
+ /**
470
+ * Sends link with auto preview
471
+ */
472
+ export const sendLinkWithAutoPreview = defineMethodV2('sendLinkWithAutoPreview', {
473
+ meta: {
474
+ description: 'Sends a link with auto-generated preview',
475
+ action: 'send',
476
+ namespace: 'messages',
477
+ license: 'none',
478
+ functionality: 'both',
479
+ httpMethod: 'POST',
480
+ aliases: {
481
+ explicit: ['sendLink'],
482
+ },
483
+ },
484
+ input: z.object({
485
+ to: toParam,
486
+ url: z.string().url().describe('Link URL'),
487
+ text: contentParam.optional(),
488
+ thumbnail: z.string().optional().describe('Base64 thumbnail override'),
489
+ quotedMsgId: messageIdParam.optional(),
490
+ customSize: z.object({
491
+ height: z.number(),
492
+ width: z.number()
493
+ }).optional().describe('Custom thumbnail size')
494
+ }),
495
+ parameterOrder: ['to', 'url', 'text', 'thumbnail', 'quotedMsgId', 'customSize'],
496
+ output: MessageIdReturnSchema.or(z.boolean())
497
+ });
498
+
499
+ /**
500
+ * Sends message with custom thumbnail
501
+ */
502
+ export const sendMessageWithThumb = defineMethodV2('sendMessageWithThumb', {
503
+ meta: {
504
+ description: 'Sends a link preview message with custom thumbnail',
505
+ action: 'send',
506
+ namespace: 'messages',
507
+ license: 'none',
508
+ functionality: 'both',
509
+ httpMethod: 'POST',
510
+ aliases: {
511
+ explicit: ['sendLinkWithThumbnail'],
512
+ namespacedName: 'sendLinkWithThumbnail',
513
+ },
514
+ },
515
+ input: z.object({
516
+ thumb: z.string().describe('Base64 thumbnail (max 200x200px)'),
517
+ url: z.string().url().describe('Link URL'),
518
+ title: z.string().describe('Link title'),
519
+ description: z.string().describe('Link description'),
520
+ content: contentParam,
521
+ to: toParam,
522
+ quotedMsgId: messageIdParam.optional(),
523
+ customSize: z.object({
524
+ height: z.number(),
525
+ width: z.number()
526
+ }).optional().describe('Custom thumbnail size')
527
+ }),
528
+ parameterOrder: ['thumb', 'url', 'title', 'description', 'content', 'to', 'quotedMsgId', 'customSize'],
529
+ output: MessageIdReturnSchema.or(z.boolean())
530
+ });
531
+
532
+ /**
533
+ * Forwards messages to a chat
534
+ */
535
+ export const forwardMessages = defineMethodV2('forwardMessages', {
536
+ meta: {
537
+ description: 'Forwards messages to a chat',
538
+ action: 'send',
539
+ namespace: 'messages',
540
+ license: 'none',
541
+ functionality: 'both',
542
+ httpMethod: 'POST',
543
+ aliases: {
544
+ namespacedName: 'forward',
545
+ },
546
+ },
547
+ input: z.object({
548
+ to: toParam,
549
+ messages: messageIdsParam,
550
+ skipMyMessages: skipMyMessagesParam
551
+ }),
552
+ parameterOrder: ['to', 'messages', 'skipMyMessages'],
553
+ output: z.array(MessageIdReturnSchema).or(z.boolean())
554
+ });
555
+
556
+ /**
557
+ * Deletes a message
558
+ */
559
+ export const deleteMessage = defineMethodV2('deleteMessage', {
560
+ meta: {
561
+ description: 'Deletes a message',
562
+ action: 'delete',
563
+ namespace: 'messages',
564
+ license: 'none',
565
+ functionality: 'both',
566
+ httpMethod: 'DELETE',
567
+ aliases: {
568
+ namespacedName: 'delete',
569
+ },
570
+ },
571
+ input: z.object({
572
+ chatId: chatIdParam,
573
+ messageId: messageIdsParam,
574
+ onlyLocal: z.boolean().optional().default(false).describe('Delete only locally')
575
+ }),
576
+ parameterOrder: ['chatId', 'messageId', 'onlyLocal'],
577
+ output: z.boolean()
578
+ });
579
+
580
+ /**
581
+ * Retrieves a specific message by ID
582
+ */
583
+ export const getMessageById = defineMethodV2('getMessageById', {
584
+ meta: {
585
+ description: 'Retrieves a specific message by ID',
586
+ action: 'read',
587
+ namespace: 'messages',
588
+ license: 'none',
589
+ functionality: 'both',
590
+ httpMethod: 'GET',
591
+ aliases: {
592
+ explicit: ['getMessage'],
593
+ namespacedName: 'get',
594
+ },
595
+ },
596
+ input: z.object({
597
+ messageId: messageIdParam
598
+ }),
599
+ parameterOrder: ['messageId'],
600
+ output: z.any() // MessageSchema causes circular dependency
601
+ });
602
+
603
+ /**
604
+ * Retrieves all messages in the session
605
+ */
606
+ export const getAllMessages = defineMethodV2('getAllMessages', {
607
+ meta: {
608
+ description: 'Retrieves all messages in the session',
609
+ action: 'read',
610
+ namespace: 'messages',
611
+ license: 'none',
612
+ functionality: 'both',
613
+ httpMethod: 'GET',
614
+ },
615
+ input: z.object({
616
+ chatId: chatIdParam.optional(),
617
+ includeMe: z.boolean().optional().default(true).describe('Include own messages'),
618
+ includeNotifications: z.boolean().optional().default(false).describe('Include notification messages'),
619
+ }),
620
+ parameterOrder: ['chatId', 'includeMe', 'includeNotifications'],
621
+ output: z.array(z.any()) // MessageSchema causes circular dependency
622
+ });
623
+
624
+ export const getMyLastMessage = defineMethodV2('getMyLastMessage', {
625
+ meta: {
626
+ description: 'Get last message sent by host',
627
+ action: 'read',
628
+ namespace: 'messages',
629
+ license: 'none',
630
+ functionality: 'both',
631
+ httpMethod: 'GET',
632
+ },
633
+ input: z.object({
634
+ chatId: chatIdParam.optional(),
635
+ }),
636
+ parameterOrder: ['chatId'],
637
+ output: z.any(),
638
+ });
639
+
640
+ export const getStarredMessages = defineMethodV2('getStarredMessages', {
641
+ meta: {
642
+ description: 'Get starred messages',
643
+ action: 'read',
644
+ namespace: 'messages',
645
+ license: 'insiders',
646
+ functionality: 'both',
647
+ httpMethod: 'GET',
648
+ },
649
+ input: z.object({
650
+ chatId: chatIdParam.optional(),
651
+ }),
652
+ parameterOrder: ['chatId'],
653
+ output: z.array(z.any()),
654
+ });
655
+
656
+ export const getUnsentMessages = defineMethodV2('getUnsentMessages', {
657
+ meta: {
658
+ description: 'Get unsent/pending messages',
659
+ action: 'read',
660
+ namespace: 'messages',
661
+ license: 'none',
662
+ functionality: 'both',
663
+ httpMethod: 'GET',
664
+ },
665
+ input: z.object({}),
666
+ parameterOrder: [],
667
+ output: z.array(z.any()),
668
+ });
669
+
670
+ export const getMessageInfo = defineMethodV2('getMessageInfo', {
671
+ meta: {
672
+ description: 'Get message delivery info',
673
+ action: 'read',
674
+ namespace: 'messages',
675
+ license: 'none',
676
+ functionality: 'both',
677
+ httpMethod: 'GET',
678
+ },
679
+ input: z.object({
680
+ messageId: messageIdParam,
681
+ }),
682
+ parameterOrder: ['messageId'],
683
+ output: z.any(),
684
+ });
685
+
686
+ export const getVCards = defineMethodV2('getVCards', {
687
+ meta: {
688
+ description: 'Extract vCards from message',
689
+ action: 'read',
690
+ namespace: 'messages',
691
+ license: 'none',
692
+ functionality: 'both',
693
+ httpMethod: 'GET',
694
+ },
695
+ input: z.object({
696
+ messageId: messageIdParam,
697
+ }),
698
+ parameterOrder: ['messageId'],
699
+ output: z.array(z.string()),
700
+ });
701
+
702
+ export const getMessagesForLLM = defineMethodV2('getMessagesForLLM', {
703
+ meta: {
704
+ description: 'Get messages formatted for LLMs',
705
+ action: 'read',
706
+ namespace: 'messages',
707
+ license: 'none',
708
+ functionality: 'both',
709
+ httpMethod: 'GET',
710
+ aliases: {
711
+ deprecated: ['getGptArray'],
712
+ },
713
+ wapiOverride: 'getGptArray',
714
+ },
715
+ input: z.object({
716
+ chatId: chatIdParam,
717
+ last: z.number().optional().default(10),
718
+ }),
719
+ parameterOrder: ['chatId', 'last'],
720
+ output: z.any(),
721
+ });
722
+
723
+ export const starMessage = defineMethodV2('starMessage', {
724
+ meta: {
725
+ description: 'Star a message',
726
+ action: 'update',
727
+ namespace: 'messages',
728
+ license: 'none',
729
+ functionality: 'both',
730
+ httpMethod: 'PUT',
731
+ },
732
+ input: z.object({
733
+ messageId: messageIdParam,
734
+ }),
735
+ parameterOrder: ['messageId'],
736
+ output: z.boolean(),
737
+ });
738
+
739
+ export const unstarMessage = defineMethodV2('unstarMessage', {
740
+ meta: {
741
+ description: 'Unstar a message',
742
+ action: 'update',
743
+ namespace: 'messages',
744
+ license: 'none',
745
+ functionality: 'both',
746
+ httpMethod: 'PUT',
747
+ },
748
+ input: z.object({
749
+ messageId: messageIdParam,
750
+ }),
751
+ parameterOrder: ['messageId'],
752
+ output: z.boolean(),
753
+ });
754
+
755
+ export const react = defineMethodV2('react', {
756
+ meta: {
757
+ description: 'React to message with emoji',
758
+ action: 'send',
759
+ namespace: 'messages',
760
+ license: 'none',
761
+ functionality: 'both',
762
+ httpMethod: 'POST',
763
+ },
764
+ input: z.object({
765
+ messageId: messageIdParam,
766
+ emoji: z.string().describe('Emoji reaction'),
767
+ }),
768
+ parameterOrder: ['messageId', 'emoji'],
769
+ output: z.boolean(),
770
+ });
771
+
772
+ export const sendSeen = defineMethodV2('sendSeen', {
773
+ meta: {
774
+ description: 'Mark message as seen',
775
+ action: 'update',
776
+ namespace: 'messages',
777
+ license: 'none',
778
+ functionality: 'both',
779
+ httpMethod: 'PUT',
780
+ },
781
+ input: z.object({
782
+ chatId: chatIdParam,
783
+ }),
784
+ parameterOrder: ['chatId'],
785
+ output: z.boolean(),
786
+ });
787
+
788
+ export const loadEarlierMessages = defineMethodV2('loadEarlierMessages', {
789
+ meta: {
790
+ description: 'Loads earlier messages from a chat',
791
+ action: 'read',
792
+ namespace: 'messages',
793
+ license: 'none',
794
+ functionality: 'both',
795
+ httpMethod: 'POST',
796
+ aliases: {
797
+ explicit: ['loadOlderMessages'],
798
+ namespacedName: 'loadEarlier',
799
+ },
800
+ },
801
+ input: z.object({
802
+ chatId: chatIdParam,
803
+ count: z.number().positive().optional().describe('Number of messages to load (default: 20)'),
804
+ includeMe: z.boolean().optional().describe('Whether to include messages from the host account (default: false)'),
805
+ }),
806
+ parameterOrder: ['chatId', 'count', 'includeMe'],
807
+ output: z.array(z.any()),
808
+ });
809
+
810
+ export const sendFileFromUrl = defineMethodV2('sendFileFromUrl', {
811
+ meta: {
812
+ description: 'Downloads a file from a URL and sends it to a chat',
813
+ action: 'send',
814
+ namespace: 'messages',
815
+ license: 'none',
816
+ functionality: 'both',
817
+ httpMethod: 'POST',
818
+ },
819
+ input: z.object({
820
+ to: toParam,
821
+ url: z.string().url().describe('URL of the file to download'),
822
+ filename: z.string().describe('Filename for the sent file'),
823
+ caption: z.string().optional().describe('Caption for the file'),
824
+ headers: z.record(z.string(), z.string()).optional().describe('HTTP headers for the download request'),
825
+ }),
826
+ parameterOrder: ['to', 'url', 'filename', 'caption', 'headers'],
827
+ output: z.string().or(z.boolean()).describe('Message ID or success status'),
828
+ });