@open-wa/schema 5.0.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.
- package/dist/generated/index.cjs +8 -2
- package/dist/generated/index.cjs.map +1 -1
- package/dist/generated/index.d.cts +7868 -994
- package/dist/generated/index.d.cts.map +1 -1
- package/dist/generated/index.d.mts +7868 -994
- package/dist/generated/index.d.mts.map +1 -1
- package/dist/generated/index.mjs +8 -2
- package/dist/generated/index.mjs.map +1 -1
- package/dist/index-C9Ad0lEr.d.cts +4729 -0
- package/dist/index-C9Ad0lEr.d.cts.map +1 -0
- package/dist/index-D0QN2PaW.d.mts +4729 -0
- package/dist/index-D0QN2PaW.d.mts.map +1 -0
- package/dist/index.cjs +109 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/dist/methods/index.cjs +6 -1
- package/dist/methods/index.d.cts +2 -2
- package/dist/methods/index.d.mts +2 -2
- package/dist/methods/index.mjs +2 -2
- package/dist/{methods-Dizm7Fn9.cjs → methods-BGmdzjd3.cjs} +904 -76
- package/dist/methods-BGmdzjd3.cjs.map +1 -0
- package/dist/{methods-CZqeUhKy.mjs → methods-BhLsQNtL.mjs} +587 -77
- package/dist/methods-BhLsQNtL.mjs.map +1 -0
- package/package.json +4 -3
- package/src/__tests__/generators.contract.test.ts +181 -0
- package/src/__tests__/registry.contract.test.ts +81 -0
- package/src/client-config.ts +30 -0
- package/src/codecs.test.ts +41 -0
- package/src/codecs.ts +191 -0
- package/src/common-types.ts +287 -0
- package/src/config.ts +47 -0
- package/src/enums.ts +63 -0
- package/src/events/groups.ts +33 -0
- package/src/events/index.ts +4 -0
- package/src/events/messaging.ts +86 -0
- package/src/events/registry.ts +124 -0
- package/src/events/state.ts +59 -0
- package/src/generated/AliasMap.ts +216 -0
- package/src/generated/BaseClient.ts +878 -0
- package/src/generated/BaseNamespacedClient.ts +214 -0
- package/src/generated/index.ts +5 -0
- package/src/generated/openapi.json +30049 -0
- package/src/generated/types.ts +383 -0
- package/src/http-manifest.ts +97 -0
- package/src/implementor.test.ts +88 -0
- package/src/implementor.ts +75 -0
- package/src/index.ts +46 -0
- package/src/interactive.ts +151 -0
- package/src/methods/business.ts +52 -0
- package/src/methods/chats.ts +264 -0
- package/src/methods/communities.ts +121 -0
- package/src/methods/contacts.ts +160 -0
- package/src/methods/groups.ts +378 -0
- package/src/methods/index.ts +34 -0
- package/src/methods/interactive.ts +21 -0
- package/src/methods/labels.ts +88 -0
- package/src/methods/media.ts +36 -0
- package/src/methods/messaging.ts +836 -0
- package/src/methods/session.ts +262 -0
- package/src/methods/status.ts +122 -0
- package/src/output-json-schema.ts +27 -0
- package/src/parameters.ts +237 -0
- package/src/registry.test.ts +30 -0
- package/src/registry.ts +601 -0
- package/src/return-types.ts +125 -0
- package/dist/index-BHcd0h7x.d.mts +0 -1265
- package/dist/index-BHcd0h7x.d.mts.map +0 -1
- package/dist/index-ChYFQM1K.d.cts +0 -1265
- package/dist/index-ChYFQM1K.d.cts.map +0 -1
- package/dist/methods-CZqeUhKy.mjs.map +0 -1
- package/dist/methods-Dizm7Fn9.cjs.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ContactIdSchema, ContactSchema } from '../common-types';
|
|
2
|
+
import { CommonGroupSchema, NumberCheckSchema, NumberProfileSchema } from '../return-types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { defineMethodV2 } from '../registry';
|
|
5
|
+
import { chatIdParam, contactIdParam } from '../parameters';
|
|
6
|
+
|
|
7
|
+
export const getAllContacts = defineMethodV2('getAllContacts', {
|
|
8
|
+
meta: {
|
|
9
|
+
description: 'Retrieves all contacts',
|
|
10
|
+
action: 'read',
|
|
11
|
+
namespace: 'contacts',
|
|
12
|
+
license: 'none',
|
|
13
|
+
functionality: 'both',
|
|
14
|
+
httpMethod: 'GET',
|
|
15
|
+
},
|
|
16
|
+
input: z.object({}),
|
|
17
|
+
parameterOrder: [],
|
|
18
|
+
output: z.array(ContactSchema),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const getContact = defineMethodV2('getContact', {
|
|
22
|
+
meta: {
|
|
23
|
+
description: 'Get specific contact',
|
|
24
|
+
action: 'read',
|
|
25
|
+
namespace: 'contacts',
|
|
26
|
+
license: 'none',
|
|
27
|
+
functionality: 'both',
|
|
28
|
+
httpMethod: 'GET',
|
|
29
|
+
},
|
|
30
|
+
input: z.object({ contactId: contactIdParam }),
|
|
31
|
+
parameterOrder: ['contactId'],
|
|
32
|
+
output: ContactSchema.nullable(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const getCommonGroups = defineMethodV2('getCommonGroups', {
|
|
36
|
+
meta: {
|
|
37
|
+
description: 'Get common groups with contact',
|
|
38
|
+
action: 'read',
|
|
39
|
+
namespace: 'contacts',
|
|
40
|
+
license: 'none',
|
|
41
|
+
functionality: 'both',
|
|
42
|
+
httpMethod: 'GET',
|
|
43
|
+
},
|
|
44
|
+
input: z.object({ contactId: contactIdParam }),
|
|
45
|
+
parameterOrder: ['contactId'],
|
|
46
|
+
output: z.array(CommonGroupSchema).or(z.literal(false)),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const getNumberProfile = defineMethodV2('getNumberProfile', {
|
|
50
|
+
meta: {
|
|
51
|
+
description: 'Get profile of number',
|
|
52
|
+
action: 'read',
|
|
53
|
+
namespace: 'contacts',
|
|
54
|
+
license: 'insiders',
|
|
55
|
+
functionality: 'both',
|
|
56
|
+
httpMethod: 'GET',
|
|
57
|
+
},
|
|
58
|
+
input: z.object({ contactId: contactIdParam }),
|
|
59
|
+
parameterOrder: ['contactId'],
|
|
60
|
+
output: NumberProfileSchema,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const getBlockedIds = defineMethodV2('getBlockedIds', {
|
|
64
|
+
meta: {
|
|
65
|
+
description: 'Get blocked contact IDs',
|
|
66
|
+
action: 'read',
|
|
67
|
+
namespace: 'contacts',
|
|
68
|
+
license: 'none',
|
|
69
|
+
functionality: 'both',
|
|
70
|
+
httpMethod: 'GET',
|
|
71
|
+
},
|
|
72
|
+
input: z.object({}),
|
|
73
|
+
parameterOrder: [],
|
|
74
|
+
output: z.array(ContactIdSchema).or(z.literal(false)),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const blockContact = defineMethodV2('blockContact', {
|
|
78
|
+
meta: {
|
|
79
|
+
description: 'Block a contact',
|
|
80
|
+
action: 'update',
|
|
81
|
+
namespace: 'contacts',
|
|
82
|
+
license: 'none',
|
|
83
|
+
functionality: 'both',
|
|
84
|
+
httpMethod: 'PUT',
|
|
85
|
+
aliases: {
|
|
86
|
+
deprecated: ['contactBlock'],
|
|
87
|
+
},
|
|
88
|
+
wapiOverride: 'contactBlock',
|
|
89
|
+
},
|
|
90
|
+
input: z.object({ contactId: contactIdParam }),
|
|
91
|
+
parameterOrder: ['contactId'],
|
|
92
|
+
output: z.boolean(),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const unblockContact = defineMethodV2('unblockContact', {
|
|
96
|
+
meta: {
|
|
97
|
+
description: 'Unblock a contact',
|
|
98
|
+
action: 'update',
|
|
99
|
+
namespace: 'contacts',
|
|
100
|
+
license: 'none',
|
|
101
|
+
functionality: 'both',
|
|
102
|
+
httpMethod: 'PUT',
|
|
103
|
+
aliases: {
|
|
104
|
+
deprecated: ['contactUnblock'],
|
|
105
|
+
},
|
|
106
|
+
wapiOverride: 'contactUnblock',
|
|
107
|
+
},
|
|
108
|
+
input: z.object({ contactId: contactIdParam }),
|
|
109
|
+
parameterOrder: ['contactId'],
|
|
110
|
+
output: z.boolean(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const checkReadReceipts = defineMethodV2('checkReadReceipts', {
|
|
114
|
+
meta: {
|
|
115
|
+
description: 'Check read receipts setting',
|
|
116
|
+
action: 'read',
|
|
117
|
+
namespace: 'contacts',
|
|
118
|
+
license: 'none',
|
|
119
|
+
functionality: 'both',
|
|
120
|
+
httpMethod: 'GET',
|
|
121
|
+
aliases: {
|
|
122
|
+
explicit: ['getReadReceipts'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
input: z.object({ contactId: contactIdParam }),
|
|
126
|
+
parameterOrder: ['contactId'],
|
|
127
|
+
output: z.union([z.boolean(), z.string()]),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export const checkNumberStatus = defineMethodV2('checkNumberStatus', {
|
|
131
|
+
meta: {
|
|
132
|
+
description: 'Check if number is on WhatsApp',
|
|
133
|
+
action: 'read',
|
|
134
|
+
namespace: 'contacts',
|
|
135
|
+
license: 'insiders',
|
|
136
|
+
functionality: 'both',
|
|
137
|
+
httpMethod: 'GET',
|
|
138
|
+
},
|
|
139
|
+
input: z.object({ contactId: contactIdParam }),
|
|
140
|
+
parameterOrder: ['contactId'],
|
|
141
|
+
output: NumberCheckSchema,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const getProfilePicture = defineMethodV2('getProfilePicture', {
|
|
145
|
+
meta: {
|
|
146
|
+
description: 'Get profile picture from server',
|
|
147
|
+
action: 'read',
|
|
148
|
+
namespace: 'contacts',
|
|
149
|
+
license: 'none',
|
|
150
|
+
functionality: 'both',
|
|
151
|
+
httpMethod: 'GET',
|
|
152
|
+
aliases: {
|
|
153
|
+
deprecated: ['getProfilePicFromServer'],
|
|
154
|
+
},
|
|
155
|
+
wapiOverride: 'getProfilePicFromServer',
|
|
156
|
+
},
|
|
157
|
+
input: z.object({ chatId: chatIdParam }),
|
|
158
|
+
parameterOrder: ['chatId'],
|
|
159
|
+
output: z.string(),
|
|
160
|
+
});
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { ChatSchema, ContactIdSchema, ContactSchema, GroupChatIdSchema, GroupMetadataSchema } from '../common-types';
|
|
2
|
+
import { GroupCreationResultSchema } from '../return-types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { defineMethodV2 } from '../registry';
|
|
5
|
+
import { contactIdParam, groupIdParam, withNewMessagesOnlyParam } from '../parameters';
|
|
6
|
+
|
|
7
|
+
export const getGroupMembers = defineMethodV2('getGroupMembers', {
|
|
8
|
+
meta: {
|
|
9
|
+
description: 'Retrieves members of a group',
|
|
10
|
+
action: 'read',
|
|
11
|
+
namespace: 'groups',
|
|
12
|
+
license: 'none',
|
|
13
|
+
functionality: 'both',
|
|
14
|
+
httpMethod: 'GET',
|
|
15
|
+
},
|
|
16
|
+
input: z.object({ groupId: groupIdParam }),
|
|
17
|
+
parameterOrder: ['groupId'],
|
|
18
|
+
output: z.array(ContactSchema),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const getAllGroups = defineMethodV2('getAllGroups', {
|
|
22
|
+
meta: {
|
|
23
|
+
description: 'Get all groups',
|
|
24
|
+
action: 'read',
|
|
25
|
+
namespace: 'groups',
|
|
26
|
+
license: 'none',
|
|
27
|
+
functionality: 'both',
|
|
28
|
+
httpMethod: 'GET',
|
|
29
|
+
},
|
|
30
|
+
input: z.object({ withNewMessagesOnly: withNewMessagesOnlyParam }),
|
|
31
|
+
parameterOrder: ['withNewMessagesOnly'],
|
|
32
|
+
output: z.array(ChatSchema),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const getGroupMembersId = defineMethodV2('getGroupMembersId', {
|
|
36
|
+
meta: {
|
|
37
|
+
description: 'Get group member IDs',
|
|
38
|
+
action: 'read',
|
|
39
|
+
namespace: 'groups',
|
|
40
|
+
license: 'none',
|
|
41
|
+
functionality: 'both',
|
|
42
|
+
httpMethod: 'GET',
|
|
43
|
+
aliases: {
|
|
44
|
+
explicit: ['getGroupMemberIds'],
|
|
45
|
+
namespacedName: 'getMemberIds',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
input: z.object({ groupId: groupIdParam }),
|
|
49
|
+
parameterOrder: ['groupId'],
|
|
50
|
+
output: z.array(ContactIdSchema),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const getGroupInfo = defineMethodV2('getGroupInfo', {
|
|
54
|
+
meta: {
|
|
55
|
+
description: 'Get group metadata',
|
|
56
|
+
action: 'read',
|
|
57
|
+
namespace: 'groups',
|
|
58
|
+
license: 'none',
|
|
59
|
+
functionality: 'both',
|
|
60
|
+
httpMethod: 'GET',
|
|
61
|
+
},
|
|
62
|
+
input: z.object({ groupId: groupIdParam }),
|
|
63
|
+
parameterOrder: ['groupId'],
|
|
64
|
+
output: GroupMetadataSchema.nullable(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const getGroupAdmins = defineMethodV2('getGroupAdmins', {
|
|
68
|
+
meta: {
|
|
69
|
+
description: 'Get group admins',
|
|
70
|
+
action: 'read',
|
|
71
|
+
namespace: 'groups',
|
|
72
|
+
license: 'none',
|
|
73
|
+
functionality: 'both',
|
|
74
|
+
httpMethod: 'GET',
|
|
75
|
+
},
|
|
76
|
+
input: z.object({ groupId: groupIdParam }),
|
|
77
|
+
parameterOrder: ['groupId'],
|
|
78
|
+
output: z.array(ContactIdSchema),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const getKickedGroups = defineMethodV2('getKickedGroups', {
|
|
82
|
+
meta: {
|
|
83
|
+
description: 'Get groups where kicked',
|
|
84
|
+
action: 'read',
|
|
85
|
+
namespace: 'groups',
|
|
86
|
+
license: 'none',
|
|
87
|
+
functionality: 'both',
|
|
88
|
+
httpMethod: 'GET',
|
|
89
|
+
},
|
|
90
|
+
input: z.object({}),
|
|
91
|
+
parameterOrder: [],
|
|
92
|
+
output: z.array(GroupChatIdSchema),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const getGroupInviteLink = defineMethodV2('getGroupInviteLink', {
|
|
96
|
+
meta: {
|
|
97
|
+
description: 'Get group invite link',
|
|
98
|
+
action: 'read',
|
|
99
|
+
namespace: 'groups',
|
|
100
|
+
license: 'none',
|
|
101
|
+
functionality: 'both',
|
|
102
|
+
httpMethod: 'GET',
|
|
103
|
+
},
|
|
104
|
+
input: z.object({ groupId: groupIdParam }),
|
|
105
|
+
parameterOrder: ['groupId'],
|
|
106
|
+
output: z.string(),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export const createGroup = defineMethodV2('createGroup', {
|
|
110
|
+
meta: {
|
|
111
|
+
description: 'Create new group',
|
|
112
|
+
action: 'send',
|
|
113
|
+
namespace: 'groups',
|
|
114
|
+
license: 'restricted',
|
|
115
|
+
functionality: 'both',
|
|
116
|
+
httpMethod: 'POST',
|
|
117
|
+
},
|
|
118
|
+
input: z.object({
|
|
119
|
+
name: z.string().describe('Group name'),
|
|
120
|
+
contacts: z.array(contactIdParam).describe('Contact IDs to add'),
|
|
121
|
+
}),
|
|
122
|
+
parameterOrder: ['name', 'contacts'],
|
|
123
|
+
output: GroupCreationResultSchema.nullable(),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export const leaveGroup = defineMethodV2('leaveGroup', {
|
|
127
|
+
meta: {
|
|
128
|
+
description: 'Leave a group',
|
|
129
|
+
action: 'update',
|
|
130
|
+
namespace: 'groups',
|
|
131
|
+
license: 'none',
|
|
132
|
+
functionality: 'both',
|
|
133
|
+
httpMethod: 'PUT',
|
|
134
|
+
},
|
|
135
|
+
input: z.object({ groupId: groupIdParam }),
|
|
136
|
+
parameterOrder: ['groupId'],
|
|
137
|
+
output: z.void(),
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const joinGroupViaLink = defineMethodV2('joinGroupViaLink', {
|
|
141
|
+
meta: {
|
|
142
|
+
description: 'Join group via invite link',
|
|
143
|
+
action: 'send',
|
|
144
|
+
namespace: 'groups',
|
|
145
|
+
license: 'restricted',
|
|
146
|
+
functionality: 'both',
|
|
147
|
+
httpMethod: 'POST',
|
|
148
|
+
aliases: {
|
|
149
|
+
explicit: ['joinGroup'],
|
|
150
|
+
namespacedName: 'join',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
input: z.object({
|
|
154
|
+
link: z.string().url().describe('Group invite link'),
|
|
155
|
+
returnChatObj: z.boolean().optional().describe('Return chat object'),
|
|
156
|
+
}),
|
|
157
|
+
parameterOrder: ['link', 'returnChatObj'],
|
|
158
|
+
output: z.union([GroupChatIdSchema, z.boolean(), z.number(), ChatSchema]),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
export const revokeGroupInviteLink = defineMethodV2('revokeGroupInviteLink', {
|
|
162
|
+
meta: {
|
|
163
|
+
description: 'Revoke group invite link',
|
|
164
|
+
action: 'update',
|
|
165
|
+
namespace: 'groups',
|
|
166
|
+
license: 'none',
|
|
167
|
+
functionality: 'both',
|
|
168
|
+
httpMethod: 'PUT',
|
|
169
|
+
},
|
|
170
|
+
input: z.object({ groupId: groupIdParam }),
|
|
171
|
+
parameterOrder: ['groupId'],
|
|
172
|
+
output: z.union([z.string(), z.boolean()]),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export const setGroupTitle = defineMethodV2('setGroupTitle', {
|
|
176
|
+
meta: {
|
|
177
|
+
description: 'Set group title',
|
|
178
|
+
action: 'update',
|
|
179
|
+
namespace: 'groups',
|
|
180
|
+
license: 'none',
|
|
181
|
+
functionality: 'both',
|
|
182
|
+
httpMethod: 'PUT',
|
|
183
|
+
},
|
|
184
|
+
input: z.object({
|
|
185
|
+
groupId: groupIdParam,
|
|
186
|
+
title: z.string().describe('New group title'),
|
|
187
|
+
}),
|
|
188
|
+
parameterOrder: ['groupId', 'title'],
|
|
189
|
+
output: z.boolean(),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export const setGroupDescription = defineMethodV2('setGroupDescription', {
|
|
193
|
+
meta: {
|
|
194
|
+
description: 'Set group description',
|
|
195
|
+
action: 'update',
|
|
196
|
+
namespace: 'groups',
|
|
197
|
+
license: 'none',
|
|
198
|
+
functionality: 'both',
|
|
199
|
+
httpMethod: 'PUT',
|
|
200
|
+
},
|
|
201
|
+
input: z.object({
|
|
202
|
+
groupId: groupIdParam,
|
|
203
|
+
description: z.string().describe('New group description'),
|
|
204
|
+
}),
|
|
205
|
+
parameterOrder: ['groupId', 'description'],
|
|
206
|
+
output: z.boolean(),
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
export const setGroupIcon = defineMethodV2('setGroupIcon', {
|
|
210
|
+
meta: {
|
|
211
|
+
description: 'Set group icon',
|
|
212
|
+
action: 'update',
|
|
213
|
+
namespace: 'groups',
|
|
214
|
+
license: 'none',
|
|
215
|
+
functionality: 'both',
|
|
216
|
+
httpMethod: 'PUT',
|
|
217
|
+
},
|
|
218
|
+
input: z.object({
|
|
219
|
+
groupId: groupIdParam,
|
|
220
|
+
image: z.string().describe('Image data URL'),
|
|
221
|
+
}),
|
|
222
|
+
parameterOrder: ['groupId', 'image'],
|
|
223
|
+
output: z.boolean(),
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export const setGroupToAdminsOnly = defineMethodV2('setGroupToAdminsOnly', {
|
|
227
|
+
meta: {
|
|
228
|
+
description: 'Restrict group to admins only',
|
|
229
|
+
action: 'update',
|
|
230
|
+
namespace: 'groups',
|
|
231
|
+
license: 'none',
|
|
232
|
+
functionality: 'both',
|
|
233
|
+
httpMethod: 'PUT',
|
|
234
|
+
aliases: {
|
|
235
|
+
namespacedName: 'setAdminsOnly',
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
input: z.object({
|
|
239
|
+
groupId: groupIdParam,
|
|
240
|
+
onlyAdmins: z.boolean().describe('Admins only setting'),
|
|
241
|
+
}),
|
|
242
|
+
parameterOrder: ['groupId', 'onlyAdmins'],
|
|
243
|
+
output: z.boolean(),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
export const setGroupEditToAdminsOnly = defineMethodV2('setGroupEditToAdminsOnly', {
|
|
247
|
+
meta: {
|
|
248
|
+
description: 'Restrict group editing to admins only',
|
|
249
|
+
action: 'update',
|
|
250
|
+
namespace: 'groups',
|
|
251
|
+
license: 'none',
|
|
252
|
+
functionality: 'both',
|
|
253
|
+
httpMethod: 'PUT',
|
|
254
|
+
aliases: {
|
|
255
|
+
namespacedName: 'setEditAdminsOnly',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
input: z.object({
|
|
259
|
+
groupId: groupIdParam,
|
|
260
|
+
onlyAdmins: z.boolean().describe('Admins only setting'),
|
|
261
|
+
}),
|
|
262
|
+
parameterOrder: ['groupId', 'onlyAdmins'],
|
|
263
|
+
output: z.boolean(),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
export const addParticipant = defineMethodV2('addParticipant', {
|
|
267
|
+
meta: {
|
|
268
|
+
description: 'Add participant to group',
|
|
269
|
+
action: 'update',
|
|
270
|
+
namespace: 'groups',
|
|
271
|
+
license: 'none',
|
|
272
|
+
functionality: 'both',
|
|
273
|
+
httpMethod: 'PUT',
|
|
274
|
+
aliases: {
|
|
275
|
+
explicit: ['addGroupParticipant'],
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
input: z.object({
|
|
279
|
+
groupId: groupIdParam,
|
|
280
|
+
contactId: contactIdParam,
|
|
281
|
+
}),
|
|
282
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
283
|
+
output: z.boolean(),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
export const removeParticipant = defineMethodV2('removeParticipant', {
|
|
287
|
+
meta: {
|
|
288
|
+
description: 'Remove participant from group',
|
|
289
|
+
action: 'update',
|
|
290
|
+
namespace: 'groups',
|
|
291
|
+
license: 'none',
|
|
292
|
+
functionality: 'both',
|
|
293
|
+
httpMethod: 'PUT',
|
|
294
|
+
aliases: {
|
|
295
|
+
explicit: ['removeGroupParticipant'],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
input: z.object({
|
|
299
|
+
groupId: groupIdParam,
|
|
300
|
+
contactId: contactIdParam,
|
|
301
|
+
}),
|
|
302
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
303
|
+
output: z.boolean(),
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
export const promoteParticipant = defineMethodV2('promoteParticipant', {
|
|
307
|
+
meta: {
|
|
308
|
+
description: 'Promote participant to admin',
|
|
309
|
+
action: 'update',
|
|
310
|
+
namespace: 'groups',
|
|
311
|
+
license: 'none',
|
|
312
|
+
functionality: 'both',
|
|
313
|
+
httpMethod: 'PUT',
|
|
314
|
+
aliases: {
|
|
315
|
+
explicit: ['promoteGroupParticipant'],
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
input: z.object({
|
|
319
|
+
groupId: groupIdParam,
|
|
320
|
+
contactId: contactIdParam,
|
|
321
|
+
}),
|
|
322
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
323
|
+
output: z.union([z.boolean(), z.string()]),
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
export const demoteParticipant = defineMethodV2('demoteParticipant', {
|
|
327
|
+
meta: {
|
|
328
|
+
description: 'Demote participant from admin',
|
|
329
|
+
action: 'update',
|
|
330
|
+
namespace: 'groups',
|
|
331
|
+
license: 'none',
|
|
332
|
+
functionality: 'both',
|
|
333
|
+
httpMethod: 'PUT',
|
|
334
|
+
aliases: {
|
|
335
|
+
explicit: ['demoteGroupParticipant'],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
input: z.object({
|
|
339
|
+
groupId: groupIdParam,
|
|
340
|
+
contactId: contactIdParam,
|
|
341
|
+
}),
|
|
342
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
343
|
+
output: z.union([z.boolean(), z.string()]),
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
export const approveGroupJoinRequest = defineMethodV2('approveGroupJoinRequest', {
|
|
347
|
+
meta: {
|
|
348
|
+
description: 'Approve group join request',
|
|
349
|
+
action: 'update',
|
|
350
|
+
namespace: 'groups',
|
|
351
|
+
license: 'none',
|
|
352
|
+
functionality: 'both',
|
|
353
|
+
httpMethod: 'PUT',
|
|
354
|
+
},
|
|
355
|
+
input: z.object({
|
|
356
|
+
groupId: groupIdParam,
|
|
357
|
+
contactId: contactIdParam,
|
|
358
|
+
}),
|
|
359
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
360
|
+
output: z.union([z.string(), z.boolean()]),
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
export const rejectGroupJoinRequest = defineMethodV2('rejectGroupJoinRequest', {
|
|
364
|
+
meta: {
|
|
365
|
+
description: 'Reject group join request',
|
|
366
|
+
action: 'update',
|
|
367
|
+
namespace: 'groups',
|
|
368
|
+
license: 'none',
|
|
369
|
+
functionality: 'both',
|
|
370
|
+
httpMethod: 'PUT',
|
|
371
|
+
},
|
|
372
|
+
input: z.object({
|
|
373
|
+
groupId: groupIdParam,
|
|
374
|
+
contactId: contactIdParam,
|
|
375
|
+
}),
|
|
376
|
+
parameterOrder: ['groupId', 'contactId'],
|
|
377
|
+
output: z.union([z.string(), z.boolean()]),
|
|
378
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Method Exports
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
// Messaging Methods
|
|
6
|
+
export * from './messaging';
|
|
7
|
+
|
|
8
|
+
// Chat Methods
|
|
9
|
+
export * from './chats';
|
|
10
|
+
|
|
11
|
+
// Contact Methods
|
|
12
|
+
export * from './contacts';
|
|
13
|
+
|
|
14
|
+
// Group Methods
|
|
15
|
+
export * from './groups';
|
|
16
|
+
|
|
17
|
+
// Community Methods
|
|
18
|
+
export * from './communities';
|
|
19
|
+
|
|
20
|
+
// Status/Story Methods
|
|
21
|
+
export * from './status';
|
|
22
|
+
|
|
23
|
+
// Label Methods
|
|
24
|
+
export * from './labels';
|
|
25
|
+
|
|
26
|
+
// Business Methods
|
|
27
|
+
export * from './business';
|
|
28
|
+
|
|
29
|
+
// Session Methods
|
|
30
|
+
export * from './session';
|
|
31
|
+
|
|
32
|
+
// Media Methods
|
|
33
|
+
export * from './media';
|
|
34
|
+
export * from './interactive';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineMethodV2 } from '../registry';
|
|
3
|
+
import { toParam } from '../parameters';
|
|
4
|
+
import { InteractiveContentSchema, JsonObjectSchema } from '../interactive';
|
|
5
|
+
|
|
6
|
+
export const SendInteractiveInputSchema = z.object({ to: toParam, content: InteractiveContentSchema }).strict();
|
|
7
|
+
export const SendRawMessageInputSchema = z.object({ to: toParam, payload: JsonObjectSchema }).strict();
|
|
8
|
+
export const sendInteractive = defineMethodV2('sendInteractive', {
|
|
9
|
+
meta: {
|
|
10
|
+
description: 'Send a portable interactive message document (Insiders and above)',
|
|
11
|
+
namespace: 'messages', action: 'send', license: 'insiders', functionality: 'both', httpMethod: 'POST',
|
|
12
|
+
},
|
|
13
|
+
input: SendInteractiveInputSchema, parameterOrder: ['to', 'content'], output: z.string(),
|
|
14
|
+
});
|
|
15
|
+
export const sendRawMessage = defineMethodV2('sendRawMessage', {
|
|
16
|
+
meta: {
|
|
17
|
+
description: 'Send a constructed WhatsApp protobuf Message payload (Insiders and above); media must already be uploaded',
|
|
18
|
+
namespace: 'messages', action: 'send', license: 'insiders', functionality: 'both', httpMethod: 'POST',
|
|
19
|
+
},
|
|
20
|
+
input: SendRawMessageInputSchema, parameterOrder: ['to', 'payload'], output: z.string(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ChatSchema } from '../common-types';
|
|
2
|
+
import { LabelSchema } from '../return-types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { defineMethodV2 } from '../registry';
|
|
5
|
+
import { toParam } from '../parameters';
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Label Methods
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get all labels
|
|
13
|
+
*/
|
|
14
|
+
export const getAllLabels = defineMethodV2('getAllLabels', {
|
|
15
|
+
meta: {
|
|
16
|
+
description: 'Get all labels',
|
|
17
|
+
action: 'read',
|
|
18
|
+
namespace: 'labels',
|
|
19
|
+
license: 'none',
|
|
20
|
+
functionality: 'business-only',
|
|
21
|
+
httpMethod: 'GET',
|
|
22
|
+
},
|
|
23
|
+
input: z.object({}),
|
|
24
|
+
parameterOrder: [],
|
|
25
|
+
output: z.array(LabelSchema),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get chats by label
|
|
30
|
+
*/
|
|
31
|
+
export const getChatsByLabel = defineMethodV2('getChatsByLabel', {
|
|
32
|
+
meta: {
|
|
33
|
+
description: 'Get chats by label',
|
|
34
|
+
action: 'read',
|
|
35
|
+
namespace: 'labels',
|
|
36
|
+
license: 'none',
|
|
37
|
+
functionality: 'business-only',
|
|
38
|
+
httpMethod: 'GET',
|
|
39
|
+
aliases: {
|
|
40
|
+
namespacedName: 'getChats',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
input: z.object({
|
|
44
|
+
label: z.string().describe('Label name')
|
|
45
|
+
}),
|
|
46
|
+
parameterOrder: ['label'],
|
|
47
|
+
output: z.array(ChatSchema),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Add label
|
|
52
|
+
*/
|
|
53
|
+
export const addLabel = defineMethodV2('addLabel', {
|
|
54
|
+
meta: {
|
|
55
|
+
description: 'Add label to chat',
|
|
56
|
+
action: 'update',
|
|
57
|
+
namespace: 'labels',
|
|
58
|
+
license: 'none',
|
|
59
|
+
functionality: 'business-only',
|
|
60
|
+
httpMethod: 'PUT',
|
|
61
|
+
},
|
|
62
|
+
input: z.object({
|
|
63
|
+
label: z.string().describe('Label ID or name'),
|
|
64
|
+
chatId: toParam
|
|
65
|
+
}),
|
|
66
|
+
parameterOrder: ['label', 'chatId'],
|
|
67
|
+
output: z.boolean()
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Remove label
|
|
72
|
+
*/
|
|
73
|
+
export const removeLabel = defineMethodV2('removeLabel', {
|
|
74
|
+
meta: {
|
|
75
|
+
description: 'Remove label from chat',
|
|
76
|
+
action: 'update',
|
|
77
|
+
namespace: 'labels',
|
|
78
|
+
license: 'none',
|
|
79
|
+
functionality: 'business-only',
|
|
80
|
+
httpMethod: 'PUT',
|
|
81
|
+
},
|
|
82
|
+
input: z.object({
|
|
83
|
+
label: z.string().describe('Label ID or name'),
|
|
84
|
+
chatId: toParam
|
|
85
|
+
}),
|
|
86
|
+
parameterOrder: ['label', 'chatId'],
|
|
87
|
+
output: z.boolean()
|
|
88
|
+
});
|