@open-wa/schema 5.0.0-alpha.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/CHANGELOG.md +23 -0
- package/LICENSE.md +67 -0
- package/README.md +19 -0
- package/client_migration_doc.md +467 -0
- package/codecs_and_params_plan.md +936 -0
- package/migration_plan_doc.md +223 -0
- package/package.json +90 -0
- package/scripts/gen-client-implementation.ts +129 -0
- package/scripts/gen-client-reference-docs.ts +621 -0
- package/scripts/gen-openapi.ts +96 -0
- package/scripts/gen-types.ts +43 -0
- package/scripts/verify-v5-pipeline.ts +85 -0
- 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 +280 -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 +72 -0
- package/src/events/registry.ts +114 -0
- package/src/events/state.ts +59 -0
- package/src/generated/AliasMap.ts +214 -0
- package/src/generated/BaseClient.ts +868 -0
- package/src/generated/BaseNamespacedClient.ts +212 -0
- package/src/generated/index.ts +5 -0
- package/src/generated/openapi.json +7799 -0
- package/src/generated/types.ts +377 -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 +43 -0
- package/src/methods/business.ts +51 -0
- package/src/methods/chats.ts +263 -0
- package/src/methods/communities.ts +119 -0
- package/src/methods/contacts.ts +158 -0
- package/src/methods/groups.ts +376 -0
- package/src/methods/index.ts +33 -0
- package/src/methods/labels.ts +86 -0
- package/src/methods/media.ts +36 -0
- package/src/methods/messaging.ts +828 -0
- package/src/methods/session.ts +261 -0
- package/src/methods/status.ts +120 -0
- package/src/open-wa-utils.d.ts +4 -0
- package/src/parameters.ts +237 -0
- package/src/registry.test.ts +30 -0
- package/src/registry.ts +601 -0
- package/tsconfig.generated.json +11 -0
- package/tsconfig.json +15 -0
- package/tsdown.config.ts +16 -0
- package/vitest.config.ts +10 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export * from './registry';
|
|
2
|
+
export * from './config';
|
|
3
|
+
export * from './client-config';
|
|
4
|
+
export * from './common-types';
|
|
5
|
+
export * from './methods';
|
|
6
|
+
export * from './events';
|
|
7
|
+
export * from './enums';
|
|
8
|
+
export * from './implementor';
|
|
9
|
+
export {
|
|
10
|
+
chatIdCodec,
|
|
11
|
+
contactIdCodec,
|
|
12
|
+
groupIdCodec,
|
|
13
|
+
messageIdCodec,
|
|
14
|
+
createFileCodec,
|
|
15
|
+
fileToDataUrlCodec,
|
|
16
|
+
fileToBase64Codec,
|
|
17
|
+
fileToBufferCodec,
|
|
18
|
+
fileToTempPathCodec,
|
|
19
|
+
fileToStreamCodec,
|
|
20
|
+
base64ToDataUrlCodec,
|
|
21
|
+
urlToDataUrlCodec,
|
|
22
|
+
isoDatetimeToDate,
|
|
23
|
+
unixSecondsToDate,
|
|
24
|
+
unixMillisToDate,
|
|
25
|
+
hexColorCodec,
|
|
26
|
+
jsonStringCodec,
|
|
27
|
+
ChatIdSchema,
|
|
28
|
+
ContactIdSchema,
|
|
29
|
+
GroupIdSchema,
|
|
30
|
+
MessageIdSchema,
|
|
31
|
+
ChatIdCodecSchema,
|
|
32
|
+
ContactIdCodecSchema,
|
|
33
|
+
GroupIdCodecSchema,
|
|
34
|
+
MessageIdCodecSchema,
|
|
35
|
+
FileToDataUrlSchema,
|
|
36
|
+
Base64ToDataUrlSchema,
|
|
37
|
+
HexColorSchema,
|
|
38
|
+
IsoDatetimeToDateSchema,
|
|
39
|
+
UnixSecondsToDateSchema,
|
|
40
|
+
UnixMillisToDateSchema
|
|
41
|
+
} from './codecs';
|
|
42
|
+
export * from './parameters';
|
|
43
|
+
export * from './http-manifest';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineMethodV2 } from '../registry';
|
|
3
|
+
import { contactIdParam, messageIdParam } from '../parameters';
|
|
4
|
+
|
|
5
|
+
export const getBusinessProfile = defineMethodV2('getBusinessProfile', {
|
|
6
|
+
meta: {
|
|
7
|
+
description: 'Get business profile',
|
|
8
|
+
action: 'read',
|
|
9
|
+
namespace: 'business',
|
|
10
|
+
license: 'none',
|
|
11
|
+
functionality: 'both',
|
|
12
|
+
httpMethod: 'GET',
|
|
13
|
+
},
|
|
14
|
+
input: z.object({ contactId: contactIdParam }),
|
|
15
|
+
parameterOrder: ['contactId'],
|
|
16
|
+
output: z.any(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const getBusinessProducts = defineMethodV2('getBusinessProducts', {
|
|
20
|
+
meta: {
|
|
21
|
+
description: 'Get business products',
|
|
22
|
+
action: 'read',
|
|
23
|
+
namespace: 'business',
|
|
24
|
+
license: 'none',
|
|
25
|
+
functionality: 'both',
|
|
26
|
+
httpMethod: 'GET',
|
|
27
|
+
aliases: {
|
|
28
|
+
deprecated: ['getBusinessProfilesProducts'],
|
|
29
|
+
},
|
|
30
|
+
wapiOverride: 'getBusinessProfilesProducts',
|
|
31
|
+
},
|
|
32
|
+
input: z.object({ contactId: contactIdParam }),
|
|
33
|
+
parameterOrder: ['contactId'],
|
|
34
|
+
output: z.any(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const getOrder = defineMethodV2('getOrder', {
|
|
38
|
+
meta: {
|
|
39
|
+
description: 'Get order details',
|
|
40
|
+
action: 'read',
|
|
41
|
+
namespace: 'business',
|
|
42
|
+
license: 'insiders',
|
|
43
|
+
functionality: 'both',
|
|
44
|
+
httpMethod: 'GET',
|
|
45
|
+
},
|
|
46
|
+
input: z.object({
|
|
47
|
+
id: z.union([messageIdParam, z.string()]).describe('Order or message ID'),
|
|
48
|
+
}),
|
|
49
|
+
parameterOrder: ['id'],
|
|
50
|
+
output: z.any(),
|
|
51
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineMethodV2 } from '../registry';
|
|
3
|
+
import { chatIdParam, withNewMessagesOnlyParam } from '../parameters';
|
|
4
|
+
|
|
5
|
+
export const getAllChats = defineMethodV2('getAllChats', {
|
|
6
|
+
meta: {
|
|
7
|
+
description: 'Retrieves all chats',
|
|
8
|
+
action: 'read',
|
|
9
|
+
namespace: 'chats',
|
|
10
|
+
license: 'none',
|
|
11
|
+
functionality: 'both',
|
|
12
|
+
httpMethod: 'GET',
|
|
13
|
+
},
|
|
14
|
+
input: z.object({ withNewMessagesOnly: withNewMessagesOnlyParam }),
|
|
15
|
+
parameterOrder: ['withNewMessagesOnly'],
|
|
16
|
+
output: z.array(z.any()),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const getAllChatIds = defineMethodV2('getAllChatIds', {
|
|
20
|
+
meta: {
|
|
21
|
+
description: 'Get all chat IDs',
|
|
22
|
+
action: 'read',
|
|
23
|
+
namespace: 'chatIds',
|
|
24
|
+
license: 'none',
|
|
25
|
+
functionality: 'both',
|
|
26
|
+
httpMethod: 'GET',
|
|
27
|
+
aliases: {
|
|
28
|
+
explicit: ['chats.ids'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
input: z.object({}),
|
|
32
|
+
parameterOrder: [],
|
|
33
|
+
output: z.array(z.string()),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// export const getAllChatsWithMessages = defineMethodV2('getAllChatsWithMessages', {
|
|
37
|
+
// meta: {
|
|
38
|
+
// description: 'Get chats with messages',
|
|
39
|
+
// action: 'read',
|
|
40
|
+
// namespace: 'chats',
|
|
41
|
+
// license: 'none',
|
|
42
|
+
// functionality: 'both',
|
|
43
|
+
// httpMethod: 'GET',
|
|
44
|
+
// },
|
|
45
|
+
// input: z.object({
|
|
46
|
+
// withNewMessagesOnly: withNewMessagesOnlyParam,
|
|
47
|
+
// }),
|
|
48
|
+
// parameterOrder: ['withNewMessagesOnly'],
|
|
49
|
+
// output: z.array(z.any()),
|
|
50
|
+
// });
|
|
51
|
+
|
|
52
|
+
export const getChat = defineMethodV2('getChat', {
|
|
53
|
+
meta: {
|
|
54
|
+
description: 'Get specific chat by ID',
|
|
55
|
+
action: 'read',
|
|
56
|
+
namespace: 'chats',
|
|
57
|
+
license: 'none',
|
|
58
|
+
functionality: 'both',
|
|
59
|
+
httpMethod: 'GET',
|
|
60
|
+
aliases: {
|
|
61
|
+
explicit: ['getChatById'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
input: z.object({
|
|
65
|
+
chatId: chatIdParam,
|
|
66
|
+
}),
|
|
67
|
+
parameterOrder: ['chatId'],
|
|
68
|
+
output: z.any(),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const getChatWithNonContacts = defineMethodV2('getChatWithNonContacts', {
|
|
72
|
+
meta: {
|
|
73
|
+
description: 'Get chats with non-contacts',
|
|
74
|
+
action: 'read',
|
|
75
|
+
namespace: 'chats',
|
|
76
|
+
license: 'none',
|
|
77
|
+
functionality: 'both',
|
|
78
|
+
httpMethod: 'GET',
|
|
79
|
+
},
|
|
80
|
+
input: z.object({}),
|
|
81
|
+
parameterOrder: [],
|
|
82
|
+
output: z.array(z.any()),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const archiveChat = defineMethodV2('archiveChat', {
|
|
86
|
+
meta: {
|
|
87
|
+
description: 'Archive a chat',
|
|
88
|
+
action: 'update',
|
|
89
|
+
namespace: 'chats',
|
|
90
|
+
license: 'none',
|
|
91
|
+
functionality: 'both',
|
|
92
|
+
httpMethod: 'PUT',
|
|
93
|
+
},
|
|
94
|
+
input: z.object({ chatId: chatIdParam }),
|
|
95
|
+
parameterOrder: ['chatId'],
|
|
96
|
+
output: z.boolean(),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const unarchiveChat = defineMethodV2('unarchiveChat', {
|
|
100
|
+
meta: {
|
|
101
|
+
description: 'Unarchive a chat',
|
|
102
|
+
action: 'update',
|
|
103
|
+
namespace: 'chats',
|
|
104
|
+
license: 'none',
|
|
105
|
+
functionality: 'both',
|
|
106
|
+
httpMethod: 'PUT',
|
|
107
|
+
},
|
|
108
|
+
input: z.object({ chatId: chatIdParam }),
|
|
109
|
+
parameterOrder: ['chatId'],
|
|
110
|
+
output: z.boolean(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const clearChat = defineMethodV2('clearChat', {
|
|
114
|
+
meta: {
|
|
115
|
+
description: 'Clear chat history',
|
|
116
|
+
action: 'delete',
|
|
117
|
+
namespace: 'chats',
|
|
118
|
+
license: 'none',
|
|
119
|
+
functionality: 'both',
|
|
120
|
+
httpMethod: 'DELETE',
|
|
121
|
+
},
|
|
122
|
+
input: z.object({ chatId: chatIdParam }),
|
|
123
|
+
parameterOrder: ['chatId'],
|
|
124
|
+
output: z.boolean(),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const deleteChat = defineMethodV2('deleteChat', {
|
|
128
|
+
meta: {
|
|
129
|
+
description: 'Delete a chat',
|
|
130
|
+
action: 'delete',
|
|
131
|
+
namespace: 'chats',
|
|
132
|
+
license: 'none',
|
|
133
|
+
functionality: 'both',
|
|
134
|
+
httpMethod: 'DELETE',
|
|
135
|
+
},
|
|
136
|
+
input: z.object({ chatId: chatIdParam }),
|
|
137
|
+
parameterOrder: ['chatId'],
|
|
138
|
+
output: z.boolean(),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
export const pinChat = defineMethodV2('pinChat', {
|
|
142
|
+
meta: {
|
|
143
|
+
description: 'Pin a chat',
|
|
144
|
+
action: 'update',
|
|
145
|
+
namespace: 'chats',
|
|
146
|
+
license: 'none',
|
|
147
|
+
functionality: 'both',
|
|
148
|
+
httpMethod: 'PUT',
|
|
149
|
+
},
|
|
150
|
+
input: z.object({ chatId: chatIdParam }),
|
|
151
|
+
parameterOrder: ['chatId'],
|
|
152
|
+
output: z.boolean(),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const unpinChat = defineMethodV2('unpinChat', {
|
|
156
|
+
meta: {
|
|
157
|
+
description: 'Unpin a chat',
|
|
158
|
+
action: 'update',
|
|
159
|
+
namespace: 'chats',
|
|
160
|
+
license: 'none',
|
|
161
|
+
functionality: 'both',
|
|
162
|
+
httpMethod: 'PUT',
|
|
163
|
+
},
|
|
164
|
+
input: z.object({ chatId: chatIdParam }),
|
|
165
|
+
parameterOrder: ['chatId'],
|
|
166
|
+
output: z.boolean(),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export const muteChat = defineMethodV2('muteChat', {
|
|
170
|
+
meta: {
|
|
171
|
+
description: 'Mute a chat',
|
|
172
|
+
action: 'update',
|
|
173
|
+
namespace: 'chats',
|
|
174
|
+
license: 'none',
|
|
175
|
+
functionality: 'both',
|
|
176
|
+
httpMethod: 'PUT',
|
|
177
|
+
},
|
|
178
|
+
input: z.object({
|
|
179
|
+
chatId: chatIdParam,
|
|
180
|
+
muteDuration: z.union([z.number(), z.string()]).describe('Mute duration'),
|
|
181
|
+
}),
|
|
182
|
+
parameterOrder: ['chatId', 'muteDuration'],
|
|
183
|
+
output: z.union([z.string(), z.boolean(), z.number()]),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
export const unmuteChat = defineMethodV2('unmuteChat', {
|
|
187
|
+
meta: {
|
|
188
|
+
description: 'Unmute a chat',
|
|
189
|
+
action: 'update',
|
|
190
|
+
namespace: 'chats',
|
|
191
|
+
license: 'none',
|
|
192
|
+
functionality: 'both',
|
|
193
|
+
httpMethod: 'PUT',
|
|
194
|
+
},
|
|
195
|
+
input: z.object({ chatId: chatIdParam }),
|
|
196
|
+
parameterOrder: ['chatId'],
|
|
197
|
+
output: z.union([z.string(), z.boolean(), z.number()]),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
export const markAsRead = defineMethodV2('markAsRead', {
|
|
201
|
+
meta: {
|
|
202
|
+
description: 'Mark chat as read',
|
|
203
|
+
action: 'update',
|
|
204
|
+
namespace: 'chats',
|
|
205
|
+
license: 'none',
|
|
206
|
+
functionality: 'both',
|
|
207
|
+
httpMethod: 'PUT',
|
|
208
|
+
aliases: {
|
|
209
|
+
namespacedName: 'markAsRead',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
input: z.object({ chatId: chatIdParam }),
|
|
213
|
+
parameterOrder: ['chatId'],
|
|
214
|
+
output: z.boolean(),
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export const markAsUnread = defineMethodV2('markAsUnread', {
|
|
218
|
+
meta: {
|
|
219
|
+
description: 'Mark chat as unread',
|
|
220
|
+
action: 'update',
|
|
221
|
+
namespace: 'chats',
|
|
222
|
+
license: 'none',
|
|
223
|
+
functionality: 'both',
|
|
224
|
+
httpMethod: 'PUT',
|
|
225
|
+
aliases: {
|
|
226
|
+
namespacedName: 'markAsUnread',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
input: z.object({ chatId: chatIdParam }),
|
|
230
|
+
parameterOrder: ['chatId'],
|
|
231
|
+
output: z.boolean(),
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
export const setChatEphemeral = defineMethodV2('setChatEphemeral', {
|
|
235
|
+
meta: {
|
|
236
|
+
description: 'Set ephemeral messages for chat',
|
|
237
|
+
action: 'update',
|
|
238
|
+
namespace: 'chats',
|
|
239
|
+
license: 'none',
|
|
240
|
+
functionality: 'both',
|
|
241
|
+
httpMethod: 'PUT',
|
|
242
|
+
},
|
|
243
|
+
input: z.object({
|
|
244
|
+
chatId: chatIdParam,
|
|
245
|
+
ephemeral: z.union([z.boolean(), z.number()]).describe('Ephemeral setting'),
|
|
246
|
+
}),
|
|
247
|
+
parameterOrder: ['chatId', 'ephemeral'],
|
|
248
|
+
output: z.boolean(),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
export const isChatOnline = defineMethodV2('isChatOnline', {
|
|
252
|
+
meta: {
|
|
253
|
+
description: 'Check if chat is online',
|
|
254
|
+
action: 'read',
|
|
255
|
+
namespace: 'chats',
|
|
256
|
+
license: 'none',
|
|
257
|
+
functionality: 'both',
|
|
258
|
+
httpMethod: 'GET',
|
|
259
|
+
},
|
|
260
|
+
input: z.object({ chatId: chatIdParam }),
|
|
261
|
+
parameterOrder: ['chatId'],
|
|
262
|
+
output: z.union([z.boolean(), z.string()]),
|
|
263
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineMethodV2 } from '../registry';
|
|
3
|
+
import { communityIdParam } from '../parameters';
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Community Methods
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get all communities
|
|
11
|
+
*/
|
|
12
|
+
export const getAllCommunities = defineMethodV2('getAllCommunities', {
|
|
13
|
+
meta: {
|
|
14
|
+
description: 'Get all communities',
|
|
15
|
+
action: 'read',
|
|
16
|
+
namespace: 'communities',
|
|
17
|
+
license: 'none',
|
|
18
|
+
functionality: 'both',
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
},
|
|
21
|
+
input: z.object({}),
|
|
22
|
+
parameterOrder: [],
|
|
23
|
+
output: z.array(z.string())
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get community info
|
|
28
|
+
*/
|
|
29
|
+
export const getCommunityInfo = defineMethodV2('getCommunityInfo', {
|
|
30
|
+
meta: {
|
|
31
|
+
description: 'Get community metadata',
|
|
32
|
+
action: 'read',
|
|
33
|
+
namespace: 'communities',
|
|
34
|
+
license: 'none',
|
|
35
|
+
functionality: 'both',
|
|
36
|
+
httpMethod: 'GET',
|
|
37
|
+
},
|
|
38
|
+
input: z.object({
|
|
39
|
+
communityId: communityIdParam
|
|
40
|
+
}),
|
|
41
|
+
parameterOrder: ['communityId'],
|
|
42
|
+
output: z.any()
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get community participant IDs
|
|
47
|
+
*/
|
|
48
|
+
export const getCommunityParticipantIds = defineMethodV2('getCommunityParticipantIds', {
|
|
49
|
+
meta: {
|
|
50
|
+
description: 'Get community participant IDs',
|
|
51
|
+
action: 'read',
|
|
52
|
+
namespace: 'communities',
|
|
53
|
+
license: 'none',
|
|
54
|
+
functionality: 'both',
|
|
55
|
+
httpMethod: 'GET',
|
|
56
|
+
},
|
|
57
|
+
input: z.object({
|
|
58
|
+
communityId: communityIdParam
|
|
59
|
+
}),
|
|
60
|
+
parameterOrder: ['communityId'],
|
|
61
|
+
output: z.any()
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get community admin IDs
|
|
66
|
+
*/
|
|
67
|
+
export const getCommunityAdminIds = defineMethodV2('getCommunityAdminIds', {
|
|
68
|
+
meta: {
|
|
69
|
+
description: 'Get community admin IDs',
|
|
70
|
+
action: 'read',
|
|
71
|
+
namespace: 'communities',
|
|
72
|
+
license: 'none',
|
|
73
|
+
functionality: 'both',
|
|
74
|
+
httpMethod: 'GET',
|
|
75
|
+
},
|
|
76
|
+
input: z.object({
|
|
77
|
+
communityId: communityIdParam
|
|
78
|
+
}),
|
|
79
|
+
parameterOrder: ['communityId'],
|
|
80
|
+
output: z.any()
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get community participants
|
|
85
|
+
*/
|
|
86
|
+
export const getCommunityParticipants = defineMethodV2('getCommunityParticipants', {
|
|
87
|
+
meta: {
|
|
88
|
+
description: 'Get community participants',
|
|
89
|
+
action: 'read',
|
|
90
|
+
namespace: 'communities',
|
|
91
|
+
license: 'none',
|
|
92
|
+
functionality: 'both',
|
|
93
|
+
httpMethod: 'GET',
|
|
94
|
+
},
|
|
95
|
+
input: z.object({
|
|
96
|
+
communityId: communityIdParam
|
|
97
|
+
}),
|
|
98
|
+
parameterOrder: ['communityId'],
|
|
99
|
+
output: z.any()
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Get community admins
|
|
104
|
+
*/
|
|
105
|
+
export const getCommunityAdmins = defineMethodV2('getCommunityAdmins', {
|
|
106
|
+
meta: {
|
|
107
|
+
description: 'Get community admins',
|
|
108
|
+
action: 'read',
|
|
109
|
+
namespace: 'communities',
|
|
110
|
+
license: 'none',
|
|
111
|
+
functionality: 'both',
|
|
112
|
+
httpMethod: 'GET',
|
|
113
|
+
},
|
|
114
|
+
input: z.object({
|
|
115
|
+
communityId: communityIdParam
|
|
116
|
+
}),
|
|
117
|
+
parameterOrder: ['communityId'],
|
|
118
|
+
output: z.any()
|
|
119
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineMethodV2 } from '../registry';
|
|
3
|
+
import { chatIdParam, contactIdParam } from '../parameters';
|
|
4
|
+
|
|
5
|
+
export const getAllContacts = defineMethodV2('getAllContacts', {
|
|
6
|
+
meta: {
|
|
7
|
+
description: 'Retrieves all contacts',
|
|
8
|
+
action: 'read',
|
|
9
|
+
namespace: 'contacts',
|
|
10
|
+
license: 'none',
|
|
11
|
+
functionality: 'both',
|
|
12
|
+
httpMethod: 'GET',
|
|
13
|
+
},
|
|
14
|
+
input: z.object({}),
|
|
15
|
+
parameterOrder: [],
|
|
16
|
+
output: z.array(z.any()),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const getContact = defineMethodV2('getContact', {
|
|
20
|
+
meta: {
|
|
21
|
+
description: 'Get specific contact',
|
|
22
|
+
action: 'read',
|
|
23
|
+
namespace: 'contacts',
|
|
24
|
+
license: 'none',
|
|
25
|
+
functionality: 'both',
|
|
26
|
+
httpMethod: 'GET',
|
|
27
|
+
},
|
|
28
|
+
input: z.object({ contactId: contactIdParam }),
|
|
29
|
+
parameterOrder: ['contactId'],
|
|
30
|
+
output: z.any(),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const getCommonGroups = defineMethodV2('getCommonGroups', {
|
|
34
|
+
meta: {
|
|
35
|
+
description: 'Get common groups with contact',
|
|
36
|
+
action: 'read',
|
|
37
|
+
namespace: 'contacts',
|
|
38
|
+
license: 'none',
|
|
39
|
+
functionality: 'both',
|
|
40
|
+
httpMethod: 'GET',
|
|
41
|
+
},
|
|
42
|
+
input: z.object({ contactId: contactIdParam }),
|
|
43
|
+
parameterOrder: ['contactId'],
|
|
44
|
+
output: z.any(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const getNumberProfile = defineMethodV2('getNumberProfile', {
|
|
48
|
+
meta: {
|
|
49
|
+
description: 'Get profile of number',
|
|
50
|
+
action: 'read',
|
|
51
|
+
namespace: 'contacts',
|
|
52
|
+
license: 'insiders',
|
|
53
|
+
functionality: 'both',
|
|
54
|
+
httpMethod: 'GET',
|
|
55
|
+
},
|
|
56
|
+
input: z.object({ contactId: contactIdParam }),
|
|
57
|
+
parameterOrder: ['contactId'],
|
|
58
|
+
output: z.any(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const getBlockedIds = defineMethodV2('getBlockedIds', {
|
|
62
|
+
meta: {
|
|
63
|
+
description: 'Get blocked contact IDs',
|
|
64
|
+
action: 'read',
|
|
65
|
+
namespace: 'contacts',
|
|
66
|
+
license: 'none',
|
|
67
|
+
functionality: 'both',
|
|
68
|
+
httpMethod: 'GET',
|
|
69
|
+
},
|
|
70
|
+
input: z.object({}),
|
|
71
|
+
parameterOrder: [],
|
|
72
|
+
output: z.array(z.string()),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const blockContact = defineMethodV2('blockContact', {
|
|
76
|
+
meta: {
|
|
77
|
+
description: 'Block a contact',
|
|
78
|
+
action: 'update',
|
|
79
|
+
namespace: 'contacts',
|
|
80
|
+
license: 'none',
|
|
81
|
+
functionality: 'both',
|
|
82
|
+
httpMethod: 'PUT',
|
|
83
|
+
aliases: {
|
|
84
|
+
deprecated: ['contactBlock'],
|
|
85
|
+
},
|
|
86
|
+
wapiOverride: 'contactBlock',
|
|
87
|
+
},
|
|
88
|
+
input: z.object({ contactId: contactIdParam }),
|
|
89
|
+
parameterOrder: ['contactId'],
|
|
90
|
+
output: z.boolean(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const unblockContact = defineMethodV2('unblockContact', {
|
|
94
|
+
meta: {
|
|
95
|
+
description: 'Unblock a contact',
|
|
96
|
+
action: 'update',
|
|
97
|
+
namespace: 'contacts',
|
|
98
|
+
license: 'none',
|
|
99
|
+
functionality: 'both',
|
|
100
|
+
httpMethod: 'PUT',
|
|
101
|
+
aliases: {
|
|
102
|
+
deprecated: ['contactUnblock'],
|
|
103
|
+
},
|
|
104
|
+
wapiOverride: 'contactUnblock',
|
|
105
|
+
},
|
|
106
|
+
input: z.object({ contactId: contactIdParam }),
|
|
107
|
+
parameterOrder: ['contactId'],
|
|
108
|
+
output: z.boolean(),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const checkReadReceipts = defineMethodV2('checkReadReceipts', {
|
|
112
|
+
meta: {
|
|
113
|
+
description: 'Check read receipts setting',
|
|
114
|
+
action: 'read',
|
|
115
|
+
namespace: 'contacts',
|
|
116
|
+
license: 'none',
|
|
117
|
+
functionality: 'both',
|
|
118
|
+
httpMethod: 'GET',
|
|
119
|
+
aliases: {
|
|
120
|
+
explicit: ['getReadReceipts'],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
input: z.object({ contactId: contactIdParam }),
|
|
124
|
+
parameterOrder: ['contactId'],
|
|
125
|
+
output: z.union([z.boolean(), z.string()]),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const checkNumberStatus = defineMethodV2('checkNumberStatus', {
|
|
129
|
+
meta: {
|
|
130
|
+
description: 'Check if number is on WhatsApp',
|
|
131
|
+
action: 'read',
|
|
132
|
+
namespace: 'contacts',
|
|
133
|
+
license: 'insiders',
|
|
134
|
+
functionality: 'both',
|
|
135
|
+
httpMethod: 'GET',
|
|
136
|
+
},
|
|
137
|
+
input: z.object({ contactId: contactIdParam }),
|
|
138
|
+
parameterOrder: ['contactId'],
|
|
139
|
+
output: z.any(),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const getProfilePicture = defineMethodV2('getProfilePicture', {
|
|
143
|
+
meta: {
|
|
144
|
+
description: 'Get profile picture from server',
|
|
145
|
+
action: 'read',
|
|
146
|
+
namespace: 'contacts',
|
|
147
|
+
license: 'none',
|
|
148
|
+
functionality: 'both',
|
|
149
|
+
httpMethod: 'GET',
|
|
150
|
+
aliases: {
|
|
151
|
+
deprecated: ['getProfilePicFromServer'],
|
|
152
|
+
},
|
|
153
|
+
wapiOverride: 'getProfilePicFromServer',
|
|
154
|
+
},
|
|
155
|
+
input: z.object({ chatId: chatIdParam }),
|
|
156
|
+
parameterOrder: ['chatId'],
|
|
157
|
+
output: z.string(),
|
|
158
|
+
});
|