@open-wa/schema 5.1.0 → 5.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.
Files changed (50) hide show
  1. package/dist/generated/index.cjs +1 -1
  2. package/dist/generated/index.cjs.map +1 -1
  3. package/dist/generated/index.d.cts +7491 -1331
  4. package/dist/generated/index.d.cts.map +1 -1
  5. package/dist/generated/index.d.mts +7491 -1331
  6. package/dist/generated/index.d.mts.map +1 -1
  7. package/dist/generated/index.mjs +1 -1
  8. package/dist/generated/index.mjs.map +1 -1
  9. package/dist/index-C9Ad0lEr.d.cts +4729 -0
  10. package/dist/index-C9Ad0lEr.d.cts.map +1 -0
  11. package/dist/index-D0QN2PaW.d.mts +4729 -0
  12. package/dist/index-D0QN2PaW.d.mts.map +1 -0
  13. package/dist/index.cjs +59 -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 +31 -2
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/methods/index.cjs +2 -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-DO0JONvB.cjs → methods-BGmdzjd3.cjs} +433 -76
  24. package/dist/methods-BGmdzjd3.cjs.map +1 -0
  25. package/dist/{methods-BSv5O3bS.mjs → methods-BhLsQNtL.mjs} +272 -77
  26. package/dist/methods-BhLsQNtL.mjs.map +1 -0
  27. package/package.json +3 -3
  28. package/src/common-types.ts +22 -15
  29. package/src/generated/BaseClient.ts +2 -2
  30. package/src/generated/openapi.json +24726 -3626
  31. package/src/index.ts +2 -0
  32. package/src/methods/business.ts +4 -3
  33. package/src/methods/chats.ts +6 -5
  34. package/src/methods/communities.ts +8 -6
  35. package/src/methods/contacts.ts +8 -6
  36. package/src/methods/groups.ts +11 -9
  37. package/src/methods/labels.ts +4 -2
  38. package/src/methods/media.ts +2 -2
  39. package/src/methods/messaging.ts +20 -12
  40. package/src/methods/session.ts +7 -6
  41. package/src/methods/status.ts +9 -7
  42. package/src/output-json-schema.ts +27 -0
  43. package/src/parameters.ts +2 -2
  44. package/src/return-types.ts +125 -0
  45. package/dist/index-DTztyYhw.d.cts +0 -2155
  46. package/dist/index-DTztyYhw.d.cts.map +0 -1
  47. package/dist/index-nVKR0RmZ.d.mts +0 -2155
  48. package/dist/index-nVKR0RmZ.d.mts.map +0 -1
  49. package/dist/methods-BSv5O3bS.mjs.map +0 -1
  50. package/dist/methods-DO0JONvB.cjs.map +0 -1
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ export * from './registry';
2
2
  export * from './config';
3
3
  export * from './client-config';
4
4
  export * from './common-types';
5
+ export * from './return-types';
6
+ export * from './output-json-schema';
5
7
  export * from './methods';
6
8
  export * from './events';
7
9
  export * from './enums';
@@ -1,3 +1,4 @@
1
+ import { BusinessProfileSchema, OrderSchema, ProductSchema } from '../return-types';
1
2
  import { z } from 'zod';
2
3
  import { defineMethodV2 } from '../registry';
3
4
  import { contactIdParam, messageIdParam } from '../parameters';
@@ -13,7 +14,7 @@ export const getBusinessProfile = defineMethodV2('getBusinessProfile', {
13
14
  },
14
15
  input: z.object({ contactId: contactIdParam }),
15
16
  parameterOrder: ['contactId'],
16
- output: z.any(),
17
+ output: BusinessProfileSchema,
17
18
  });
18
19
 
19
20
  export const getBusinessProducts = defineMethodV2('getBusinessProducts', {
@@ -31,7 +32,7 @@ export const getBusinessProducts = defineMethodV2('getBusinessProducts', {
31
32
  },
32
33
  input: z.object({ contactId: contactIdParam }),
33
34
  parameterOrder: ['contactId'],
34
- output: z.any(),
35
+ output: z.array(ProductSchema).or(z.literal(false)),
35
36
  });
36
37
 
37
38
  export const getOrder = defineMethodV2('getOrder', {
@@ -47,5 +48,5 @@ export const getOrder = defineMethodV2('getOrder', {
47
48
  id: z.union([messageIdParam, z.string()]).describe('Order or message ID'),
48
49
  }),
49
50
  parameterOrder: ['id'],
50
- output: z.any(),
51
+ output: OrderSchema,
51
52
  });
@@ -1,10 +1,11 @@
1
+ import { ChatIdSchema, ChatSchema, ContactSchema } from '../common-types';
1
2
  import { z } from 'zod';
2
3
  import { defineMethodV2 } from '../registry';
3
4
  import { chatIdParam, withNewMessagesOnlyParam } from '../parameters';
4
5
 
5
6
  export const getAllChats = defineMethodV2('getAllChats', {
6
7
  meta: {
7
- description: 'Retrieves all chats',
8
+ description: 'Returns serialized Chat objects from the current session, optionally limited to chats with unread messages.',
8
9
  action: 'read',
9
10
  namespace: 'chats',
10
11
  license: 'none',
@@ -13,7 +14,7 @@ export const getAllChats = defineMethodV2('getAllChats', {
13
14
  },
14
15
  input: z.object({ withNewMessagesOnly: withNewMessagesOnlyParam }),
15
16
  parameterOrder: ['withNewMessagesOnly'],
16
- output: z.array(z.any()),
17
+ output: z.array(ChatSchema),
17
18
  });
18
19
 
19
20
  export const getAllChatIds = defineMethodV2('getAllChatIds', {
@@ -30,7 +31,7 @@ export const getAllChatIds = defineMethodV2('getAllChatIds', {
30
31
  },
31
32
  input: z.object({}),
32
33
  parameterOrder: [],
33
- output: z.array(z.string()),
34
+ output: z.array(ChatIdSchema),
34
35
  });
35
36
 
36
37
  // export const getAllChatsWithMessages = defineMethodV2('getAllChatsWithMessages', {
@@ -65,7 +66,7 @@ export const getChat = defineMethodV2('getChat', {
65
66
  chatId: chatIdParam,
66
67
  }),
67
68
  parameterOrder: ['chatId'],
68
- output: z.any(),
69
+ output: ChatSchema.nullable().optional().or(z.literal(false)),
69
70
  });
70
71
 
71
72
  export const getChatWithNonContacts = defineMethodV2('getChatWithNonContacts', {
@@ -79,7 +80,7 @@ export const getChatWithNonContacts = defineMethodV2('getChatWithNonContacts', {
79
80
  },
80
81
  input: z.object({}),
81
82
  parameterOrder: [],
82
- output: z.array(z.any()),
83
+ output: z.array(ContactSchema),
83
84
  });
84
85
 
85
86
  export const archiveChat = defineMethodV2('archiveChat', {
@@ -1,3 +1,5 @@
1
+ import { GroupChatIdSchema } from '../common-types';
2
+ import { CommunityAdminIdsSchema, CommunityAdminsSchema, CommunityMetadataSchema, CommunityParticipantIdsSchema, CommunityParticipantsSchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
5
  import { communityIdParam } from '../parameters';
@@ -20,7 +22,7 @@ export const getAllCommunities = defineMethodV2('getAllCommunities', {
20
22
  },
21
23
  input: z.object({}),
22
24
  parameterOrder: [],
23
- output: z.array(z.string())
25
+ output: z.array(GroupChatIdSchema),
24
26
  });
25
27
 
26
28
  /**
@@ -39,7 +41,7 @@ export const getCommunityInfo = defineMethodV2('getCommunityInfo', {
39
41
  communityId: communityIdParam
40
42
  }),
41
43
  parameterOrder: ['communityId'],
42
- output: z.any()
44
+ output: CommunityMetadataSchema,
43
45
  });
44
46
 
45
47
  /**
@@ -58,7 +60,7 @@ export const getCommunityParticipantIds = defineMethodV2('getCommunityParticipan
58
60
  communityId: communityIdParam
59
61
  }),
60
62
  parameterOrder: ['communityId'],
61
- output: z.any()
63
+ output: z.array(CommunityParticipantIdsSchema),
62
64
  });
63
65
 
64
66
  /**
@@ -77,7 +79,7 @@ export const getCommunityAdminIds = defineMethodV2('getCommunityAdminIds', {
77
79
  communityId: communityIdParam
78
80
  }),
79
81
  parameterOrder: ['communityId'],
80
- output: z.any()
82
+ output: z.array(CommunityAdminIdsSchema),
81
83
  });
82
84
 
83
85
  /**
@@ -96,7 +98,7 @@ export const getCommunityParticipants = defineMethodV2('getCommunityParticipants
96
98
  communityId: communityIdParam
97
99
  }),
98
100
  parameterOrder: ['communityId'],
99
- output: z.any()
101
+ output: z.array(CommunityParticipantsSchema),
100
102
  });
101
103
 
102
104
  /**
@@ -115,5 +117,5 @@ export const getCommunityAdmins = defineMethodV2('getCommunityAdmins', {
115
117
  communityId: communityIdParam
116
118
  }),
117
119
  parameterOrder: ['communityId'],
118
- output: z.any()
120
+ output: z.array(CommunityAdminsSchema),
119
121
  });
@@ -1,3 +1,5 @@
1
+ import { ContactIdSchema, ContactSchema } from '../common-types';
2
+ import { CommonGroupSchema, NumberCheckSchema, NumberProfileSchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
5
  import { chatIdParam, contactIdParam } from '../parameters';
@@ -13,7 +15,7 @@ export const getAllContacts = defineMethodV2('getAllContacts', {
13
15
  },
14
16
  input: z.object({}),
15
17
  parameterOrder: [],
16
- output: z.array(z.any()),
18
+ output: z.array(ContactSchema),
17
19
  });
18
20
 
19
21
  export const getContact = defineMethodV2('getContact', {
@@ -27,7 +29,7 @@ export const getContact = defineMethodV2('getContact', {
27
29
  },
28
30
  input: z.object({ contactId: contactIdParam }),
29
31
  parameterOrder: ['contactId'],
30
- output: z.any(),
32
+ output: ContactSchema.nullable(),
31
33
  });
32
34
 
33
35
  export const getCommonGroups = defineMethodV2('getCommonGroups', {
@@ -41,7 +43,7 @@ export const getCommonGroups = defineMethodV2('getCommonGroups', {
41
43
  },
42
44
  input: z.object({ contactId: contactIdParam }),
43
45
  parameterOrder: ['contactId'],
44
- output: z.any(),
46
+ output: z.array(CommonGroupSchema).or(z.literal(false)),
45
47
  });
46
48
 
47
49
  export const getNumberProfile = defineMethodV2('getNumberProfile', {
@@ -55,7 +57,7 @@ export const getNumberProfile = defineMethodV2('getNumberProfile', {
55
57
  },
56
58
  input: z.object({ contactId: contactIdParam }),
57
59
  parameterOrder: ['contactId'],
58
- output: z.any(),
60
+ output: NumberProfileSchema,
59
61
  });
60
62
 
61
63
  export const getBlockedIds = defineMethodV2('getBlockedIds', {
@@ -69,7 +71,7 @@ export const getBlockedIds = defineMethodV2('getBlockedIds', {
69
71
  },
70
72
  input: z.object({}),
71
73
  parameterOrder: [],
72
- output: z.array(z.string()),
74
+ output: z.array(ContactIdSchema).or(z.literal(false)),
73
75
  });
74
76
 
75
77
  export const blockContact = defineMethodV2('blockContact', {
@@ -136,7 +138,7 @@ export const checkNumberStatus = defineMethodV2('checkNumberStatus', {
136
138
  },
137
139
  input: z.object({ contactId: contactIdParam }),
138
140
  parameterOrder: ['contactId'],
139
- output: z.any(),
141
+ output: NumberCheckSchema,
140
142
  });
141
143
 
142
144
  export const getProfilePicture = defineMethodV2('getProfilePicture', {
@@ -1,3 +1,5 @@
1
+ import { ChatSchema, ContactIdSchema, ContactSchema, GroupChatIdSchema, GroupMetadataSchema } from '../common-types';
2
+ import { GroupCreationResultSchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
5
  import { contactIdParam, groupIdParam, withNewMessagesOnlyParam } from '../parameters';
@@ -13,7 +15,7 @@ export const getGroupMembers = defineMethodV2('getGroupMembers', {
13
15
  },
14
16
  input: z.object({ groupId: groupIdParam }),
15
17
  parameterOrder: ['groupId'],
16
- output: z.array(z.any()),
18
+ output: z.array(ContactSchema),
17
19
  });
18
20
 
19
21
  export const getAllGroups = defineMethodV2('getAllGroups', {
@@ -27,7 +29,7 @@ export const getAllGroups = defineMethodV2('getAllGroups', {
27
29
  },
28
30
  input: z.object({ withNewMessagesOnly: withNewMessagesOnlyParam }),
29
31
  parameterOrder: ['withNewMessagesOnly'],
30
- output: z.array(z.any()),
32
+ output: z.array(ChatSchema),
31
33
  });
32
34
 
33
35
  export const getGroupMembersId = defineMethodV2('getGroupMembersId', {
@@ -45,7 +47,7 @@ export const getGroupMembersId = defineMethodV2('getGroupMembersId', {
45
47
  },
46
48
  input: z.object({ groupId: groupIdParam }),
47
49
  parameterOrder: ['groupId'],
48
- output: z.array(z.string()),
50
+ output: z.array(ContactIdSchema),
49
51
  });
50
52
 
51
53
  export const getGroupInfo = defineMethodV2('getGroupInfo', {
@@ -59,7 +61,7 @@ export const getGroupInfo = defineMethodV2('getGroupInfo', {
59
61
  },
60
62
  input: z.object({ groupId: groupIdParam }),
61
63
  parameterOrder: ['groupId'],
62
- output: z.any(),
64
+ output: GroupMetadataSchema.nullable(),
63
65
  });
64
66
 
65
67
  export const getGroupAdmins = defineMethodV2('getGroupAdmins', {
@@ -73,7 +75,7 @@ export const getGroupAdmins = defineMethodV2('getGroupAdmins', {
73
75
  },
74
76
  input: z.object({ groupId: groupIdParam }),
75
77
  parameterOrder: ['groupId'],
76
- output: z.array(z.any()),
78
+ output: z.array(ContactIdSchema),
77
79
  });
78
80
 
79
81
  export const getKickedGroups = defineMethodV2('getKickedGroups', {
@@ -87,7 +89,7 @@ export const getKickedGroups = defineMethodV2('getKickedGroups', {
87
89
  },
88
90
  input: z.object({}),
89
91
  parameterOrder: [],
90
- output: z.array(z.string()),
92
+ output: z.array(GroupChatIdSchema),
91
93
  });
92
94
 
93
95
  export const getGroupInviteLink = defineMethodV2('getGroupInviteLink', {
@@ -118,7 +120,7 @@ export const createGroup = defineMethodV2('createGroup', {
118
120
  contacts: z.array(contactIdParam).describe('Contact IDs to add'),
119
121
  }),
120
122
  parameterOrder: ['name', 'contacts'],
121
- output: z.any(),
123
+ output: GroupCreationResultSchema.nullable(),
122
124
  });
123
125
 
124
126
  export const leaveGroup = defineMethodV2('leaveGroup', {
@@ -132,7 +134,7 @@ export const leaveGroup = defineMethodV2('leaveGroup', {
132
134
  },
133
135
  input: z.object({ groupId: groupIdParam }),
134
136
  parameterOrder: ['groupId'],
135
- output: z.any(),
137
+ output: z.void(),
136
138
  });
137
139
 
138
140
  export const joinGroupViaLink = defineMethodV2('joinGroupViaLink', {
@@ -153,7 +155,7 @@ export const joinGroupViaLink = defineMethodV2('joinGroupViaLink', {
153
155
  returnChatObj: z.boolean().optional().describe('Return chat object'),
154
156
  }),
155
157
  parameterOrder: ['link', 'returnChatObj'],
156
- output: z.union([z.string(), z.boolean(), z.number(), z.any()]),
158
+ output: z.union([GroupChatIdSchema, z.boolean(), z.number(), ChatSchema]),
157
159
  });
158
160
 
159
161
  export const revokeGroupInviteLink = defineMethodV2('revokeGroupInviteLink', {
@@ -1,3 +1,5 @@
1
+ import { ChatSchema } from '../common-types';
2
+ import { LabelSchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
5
  import { toParam } from '../parameters';
@@ -20,7 +22,7 @@ export const getAllLabels = defineMethodV2('getAllLabels', {
20
22
  },
21
23
  input: z.object({}),
22
24
  parameterOrder: [],
23
- output: z.array(z.any())
25
+ output: z.array(LabelSchema),
24
26
  });
25
27
 
26
28
  /**
@@ -42,7 +44,7 @@ export const getChatsByLabel = defineMethodV2('getChatsByLabel', {
42
44
  label: z.string().describe('Label name')
43
45
  }),
44
46
  parameterOrder: ['label'],
45
- output: z.array(z.any())
47
+ output: z.array(ChatSchema),
46
48
  });
47
49
 
48
50
  /**
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { defineMethodV2 } from '../registry';
3
- import { MessageSchema } from '../common-types';
3
+ import { DataURLSchema, MessageSchema } from '../common-types';
4
4
 
5
5
  export const decryptMedia = defineMethodV2('decryptMedia', {
6
6
  meta: {
@@ -15,7 +15,7 @@ export const decryptMedia = defineMethodV2('decryptMedia', {
15
15
  message: MessageSchema.describe('Message object containing media'),
16
16
  }),
17
17
  parameterOrder: ['message'],
18
- output: z.string().describe('Base64 encoded decrypted media'),
18
+ output: DataURLSchema,
19
19
  });
20
20
 
21
21
  export const downloadMedia = defineMethodV2('downloadMedia', {
@@ -1,6 +1,8 @@
1
+ import { MessageIdReturnSchema, MessageSchema } from '../common-types';
2
+ import { LLMMessageSchema, MessageInfoSchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
- import { MessageIdReturnSchema } from '../common-types';
5
+
4
6
  import {
5
7
  chatIdParam,
6
8
  toParam,
@@ -27,12 +29,18 @@ import {
27
29
  // Messaging Methods
28
30
  // ============================================================================
29
31
 
32
+ /** The normalized serialized message key returned by the public sendText client. */
33
+ export const SendTextResultSchema = z.string()
34
+ .regex(/^(true|false)_[^\s_]+@[^\s_]+_[^\s]+$/)
35
+ .brand('MessageId')
36
+ .describe('Validated serialized message ID. This confirms the send returned an ID, not delivery or reading.');
37
+
30
38
  /**
31
39
  * Sends a text message to a chat
32
40
  */
33
41
  export const sendText = defineMethodV2('sendText', {
34
42
  meta: {
35
- description: 'Sends a text message to a chat',
43
+ description: 'Sends a text message and returns a validated serialized message ID. The in-process Client throws SendTextError on failure. An unknown outcome means the message may have been sent: check the chat before retrying. Starting a chat with a new number requires an applied restricted or premium license.',
36
44
  action: 'send',
37
45
  namespace: 'messages',
38
46
  license: 'none',
@@ -45,7 +53,7 @@ export const sendText = defineMethodV2('sendText', {
45
53
  options: messageOptionsParam
46
54
  }),
47
55
  parameterOrder: ['to', 'content', 'options'],
48
- output: MessageIdReturnSchema.or(z.boolean()).or(z.string())
56
+ output: SendTextResultSchema
49
57
  });
50
58
 
51
59
  /**
@@ -293,7 +301,7 @@ export const sendContact = defineMethodV2('sendContact', {
293
301
  contactId: contactIdParam.or(z.array(contactIdParam))
294
302
  }),
295
303
  parameterOrder: ['to', 'contactId'],
296
- output: MessageIdReturnSchema.or(z.boolean())
304
+ output: MessageIdReturnSchema.or(z.boolean()).or(z.void())
297
305
  });
298
306
 
299
307
  /**
@@ -597,7 +605,7 @@ export const getMessageById = defineMethodV2('getMessageById', {
597
605
  messageId: messageIdParam
598
606
  }),
599
607
  parameterOrder: ['messageId'],
600
- output: z.any() // MessageSchema causes circular dependency
608
+ output: MessageSchema.nullable().or(z.literal(false)),
601
609
  });
602
610
 
603
611
  /**
@@ -618,7 +626,7 @@ export const getAllMessages = defineMethodV2('getAllMessages', {
618
626
  includeNotifications: z.boolean().optional().default(false).describe('Include notification messages'),
619
627
  }),
620
628
  parameterOrder: ['chatId', 'includeMe', 'includeNotifications'],
621
- output: z.array(z.any()) // MessageSchema causes circular dependency
629
+ output: z.array(MessageSchema),
622
630
  });
623
631
 
624
632
  export const getMyLastMessage = defineMethodV2('getMyLastMessage', {
@@ -634,7 +642,7 @@ export const getMyLastMessage = defineMethodV2('getMyLastMessage', {
634
642
  chatId: chatIdParam.optional(),
635
643
  }),
636
644
  parameterOrder: ['chatId'],
637
- output: z.any(),
645
+ output: MessageSchema.optional(),
638
646
  });
639
647
 
640
648
  export const getStarredMessages = defineMethodV2('getStarredMessages', {
@@ -650,7 +658,7 @@ export const getStarredMessages = defineMethodV2('getStarredMessages', {
650
658
  chatId: chatIdParam.optional(),
651
659
  }),
652
660
  parameterOrder: ['chatId'],
653
- output: z.array(z.any()),
661
+ output: z.array(MessageSchema),
654
662
  });
655
663
 
656
664
  export const getUnsentMessages = defineMethodV2('getUnsentMessages', {
@@ -664,7 +672,7 @@ export const getUnsentMessages = defineMethodV2('getUnsentMessages', {
664
672
  },
665
673
  input: z.object({}),
666
674
  parameterOrder: [],
667
- output: z.array(z.any()),
675
+ output: z.array(MessageSchema),
668
676
  });
669
677
 
670
678
  export const getMessageInfo = defineMethodV2('getMessageInfo', {
@@ -680,7 +688,7 @@ export const getMessageInfo = defineMethodV2('getMessageInfo', {
680
688
  messageId: messageIdParam,
681
689
  }),
682
690
  parameterOrder: ['messageId'],
683
- output: z.any(),
691
+ output: MessageInfoSchema,
684
692
  });
685
693
 
686
694
  export const getVCards = defineMethodV2('getVCards', {
@@ -717,7 +725,7 @@ export const getMessagesForLLM = defineMethodV2('getMessagesForLLM', {
717
725
  last: z.number().optional().default(10),
718
726
  }),
719
727
  parameterOrder: ['chatId', 'last'],
720
- output: z.any(),
728
+ output: z.array(LLMMessageSchema),
721
729
  });
722
730
 
723
731
  export const starMessage = defineMethodV2('starMessage', {
@@ -804,7 +812,7 @@ export const loadEarlierMessages = defineMethodV2('loadEarlierMessages', {
804
812
  includeMe: z.boolean().optional().describe('Whether to include messages from the host account (default: false)'),
805
813
  }),
806
814
  parameterOrder: ['chatId', 'count', 'includeMe'],
807
- output: z.array(z.any()),
815
+ output: z.array(MessageSchema),
808
816
  });
809
817
 
810
818
  export const sendFileFromUrl = defineMethodV2('sendFileFromUrl', {
@@ -1,3 +1,4 @@
1
+ import { FeatureFlagsSchema, HealthCheckSchema, HostAccountSchema, LicenseTypeSchema, ProcessStatsSchema } from '../return-types';
1
2
  import { z } from 'zod';
2
3
  import { defineMethodV2 } from '../registry';
3
4
  import { chatIdParam, imageDataParam, nameParam, statusTextParam, userAgentParam } from '../parameters';
@@ -13,7 +14,7 @@ export const getMe = defineMethodV2('getMe', {
13
14
  },
14
15
  input: z.object({}),
15
16
  parameterOrder: [],
16
- output: z.any(),
17
+ output: HostAccountSchema,
17
18
  });
18
19
 
19
20
  export const getHostNumber = defineMethodV2('getHostNumber', {
@@ -41,7 +42,7 @@ export const getConnectionState = defineMethodV2('getConnectionState', {
41
42
  },
42
43
  input: z.object({}),
43
44
  parameterOrder: [],
44
- output: z.any(),
45
+ output: z.string(),
45
46
  });
46
47
 
47
48
  export const getWAVersion = defineMethodV2('getWAVersion', {
@@ -104,7 +105,7 @@ export const getFeatures = defineMethodV2('getFeatures', {
104
105
  },
105
106
  input: z.object({}),
106
107
  parameterOrder: [],
107
- output: z.any(),
108
+ output: FeatureFlagsSchema,
108
109
  });
109
110
 
110
111
  export const getLicenseType = defineMethodV2('getLicenseType', {
@@ -118,7 +119,7 @@ export const getLicenseType = defineMethodV2('getLicenseType', {
118
119
  },
119
120
  input: z.object({}),
120
121
  parameterOrder: [],
121
- output: z.union([z.any(), z.boolean()]),
122
+ output: LicenseTypeSchema.or(z.literal(false)),
122
123
  });
123
124
 
124
125
  export const getUserAgent = defineMethodV2('getUserAgent', {
@@ -150,7 +151,7 @@ export const getProcessStats = defineMethodV2('getProcessStats', {
150
151
  },
151
152
  input: z.object({}),
152
153
  parameterOrder: [],
153
- output: z.any(),
154
+ output: ProcessStatsSchema,
154
155
  });
155
156
 
156
157
  export const getLoadedMessageCount = defineMethodV2('getLoadedMessageCount', {
@@ -203,7 +204,7 @@ export const healthCheck = defineMethodV2('healthCheck', {
203
204
  },
204
205
  input: z.object({}),
205
206
  parameterOrder: [],
206
- output: z.any(),
207
+ output: HealthCheckSchema,
207
208
  });
208
209
 
209
210
  export const setMyName = defineMethodV2('setMyName', {
@@ -1,3 +1,5 @@
1
+ import { MessageIdSchema } from '../common-types';
2
+ import { ContactStatusSchema, StorySchema } from '../return-types';
1
3
  import { z } from 'zod';
2
4
  import { defineMethodV2 } from '../registry';
3
5
  import { contactIdParam } from '../parameters';
@@ -17,7 +19,7 @@ export const postTextStatus = defineMethodV2('postTextStatus', {
17
19
  font: z.number().optional().describe('Font style'),
18
20
  }),
19
21
  parameterOrder: ['text', 'backgroundColor', 'font'],
20
- output: z.any(),
22
+ output: MessageIdSchema.or(z.string()).or(z.boolean()),
21
23
  });
22
24
 
23
25
  export const postImageStatus = defineMethodV2('postImageStatus', {
@@ -34,7 +36,7 @@ export const postImageStatus = defineMethodV2('postImageStatus', {
34
36
  caption: z.string().optional().describe('Status caption'),
35
37
  }),
36
38
  parameterOrder: ['image', 'caption'],
37
- output: z.any(),
39
+ output: MessageIdSchema.or(z.string()).or(z.boolean()),
38
40
  });
39
41
 
40
42
  export const postVideoStatus = defineMethodV2('postVideoStatus', {
@@ -51,7 +53,7 @@ export const postVideoStatus = defineMethodV2('postVideoStatus', {
51
53
  caption: z.string().optional().describe('Status caption'),
52
54
  }),
53
55
  parameterOrder: ['video', 'caption'],
54
- output: z.any(),
56
+ output: MessageIdSchema.or(z.string()).or(z.boolean()),
55
57
  });
56
58
 
57
59
  export const getStories = defineMethodV2('getStories', {
@@ -69,7 +71,7 @@ export const getStories = defineMethodV2('getStories', {
69
71
  },
70
72
  input: z.object({}),
71
73
  parameterOrder: [],
72
- output: z.array(z.any()),
74
+ output: z.array(StorySchema),
73
75
  });
74
76
 
75
77
  export const getStatus = defineMethodV2('getStatus', {
@@ -83,7 +85,7 @@ export const getStatus = defineMethodV2('getStatus', {
83
85
  },
84
86
  input: z.object({ contactId: contactIdParam }),
85
87
  parameterOrder: ['contactId'],
86
- output: z.any(),
88
+ output: ContactStatusSchema,
87
89
  });
88
90
 
89
91
  export const deleteStatus = defineMethodV2('deleteStatus', {
@@ -99,7 +101,7 @@ export const deleteStatus = defineMethodV2('deleteStatus', {
99
101
  statusesToDelete: z.union([z.string(), z.array(z.string())]).describe('Status ID(s)'),
100
102
  }),
101
103
  parameterOrder: ['statusesToDelete'],
102
- output: z.any(),
104
+ output: z.boolean(),
103
105
  });
104
106
 
105
107
  export const deleteAllStatus = defineMethodV2('deleteAllStatus', {
@@ -116,5 +118,5 @@ export const deleteAllStatus = defineMethodV2('deleteAllStatus', {
116
118
  },
117
119
  input: z.object({}),
118
120
  parameterOrder: [],
119
- output: z.any(),
121
+ output: z.boolean(),
120
122
  });
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+
3
+ /** HTTP omits undefined results; void/undefined are not JSON data values. */
4
+ export function outputJsonSchema(schema: z.ZodType) {
5
+ return z.toJSONSchema(schema, {
6
+ target: 'openapi-3.0',
7
+ unrepresentable: 'any',
8
+ override: ({ zodSchema, jsonSchema }) => {
9
+ const kind = zodSchema._zod.def.type;
10
+ if (kind === 'void' || kind === 'undefined') {
11
+ jsonSchema.not = {};
12
+ jsonSchema.description = 'No JSON value; the response data property is omitted.';
13
+ }
14
+ },
15
+ });
16
+ }
17
+
18
+ export function successResponseSchema(schema: z.ZodType) {
19
+ return {
20
+ type: 'object',
21
+ required: schema.isOptional() ? ['success'] : ['success', 'data'],
22
+ properties: {
23
+ success: { type: 'boolean', enum: [true] },
24
+ data: outputJsonSchema(schema),
25
+ },
26
+ };
27
+ }
package/src/parameters.ts CHANGED
@@ -229,9 +229,9 @@ export const mentionedJidListParam = z
229
229
  example: ['447123456789@c.us', '441234567890@c.us'],
230
230
  });
231
231
 
232
- export const messageOptionsParam = z.any().optional().describe('Additional message options').register(
232
+ export const messageOptionsParam = z.unknown().optional().describe('Reserved for compatibility with legacy request shapes. The current sendText Client implementation ignores this argument; use reply() or sendTextWithMentions() for quoted replies and mentions.').register(
233
233
  parameterRegistry,
234
234
  {
235
- example: { quotedMsg: 'messageId', mentionedJidList: ['447123456789@c.us'] },
235
+ formatDescription: 'Accepted as unknown for compatibility; currently ignored by sendText. Use reply() or sendTextWithMentions() for supported reply and mention behavior.',
236
236
  }
237
237
  );