meta-cloud-api 0.1.8 → 0.1.10
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/api/base.d.mts +3 -1
- package/dist/api/base.d.ts +3 -1
- package/dist/api/base.js +1 -1
- package/dist/api/base.js.map +1 -1
- package/dist/api/base.mjs +1 -1
- package/dist/api/base.mjs.map +1 -1
- package/dist/api/businessProfile.js +1 -1
- package/dist/api/businessProfile.js.map +1 -1
- package/dist/api/businessProfile.mjs +1 -1
- package/dist/api/businessProfile.mjs.map +1 -1
- package/dist/api/encryption.js +1 -1
- package/dist/api/encryption.js.map +1 -1
- package/dist/api/encryption.mjs +1 -1
- package/dist/api/encryption.mjs.map +1 -1
- package/dist/api/flow.js +1 -1
- package/dist/api/flow.js.map +1 -1
- package/dist/api/flow.mjs +1 -1
- package/dist/api/flow.mjs.map +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/media.js +1 -1
- package/dist/api/media.js.map +1 -1
- package/dist/api/media.mjs +1 -1
- package/dist/api/media.mjs.map +1 -1
- package/dist/api/messages.js +1 -1
- package/dist/api/messages.js.map +1 -1
- package/dist/api/messages.mjs +1 -1
- package/dist/api/messages.mjs.map +1 -1
- package/dist/api/phoneNumber.js +1 -1
- package/dist/api/phoneNumber.js.map +1 -1
- package/dist/api/phoneNumber.mjs +1 -1
- package/dist/api/phoneNumber.mjs.map +1 -1
- package/dist/api/qrCode.js +1 -1
- package/dist/api/qrCode.js.map +1 -1
- package/dist/api/qrCode.mjs +1 -1
- package/dist/api/qrCode.mjs.map +1 -1
- package/dist/api/registration.js +1 -1
- package/dist/api/registration.js.map +1 -1
- package/dist/api/registration.mjs +1 -1
- package/dist/api/registration.mjs.map +1 -1
- package/dist/api/template.js +1 -1
- package/dist/api/template.js.map +1 -1
- package/dist/api/template.mjs +1 -1
- package/dist/api/template.mjs.map +1 -1
- package/dist/api/twoStepVerification.js +1 -1
- package/dist/api/twoStepVerification.js.map +1 -1
- package/dist/api/twoStepVerification.mjs +1 -1
- package/dist/api/twoStepVerification.mjs.map +1 -1
- package/dist/api/waba.js +1 -1
- package/dist/api/waba.js.map +1 -1
- package/dist/api/waba.mjs +1 -1
- package/dist/api/waba.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/request.d.mts +5 -3
- package/dist/request.d.ts +5 -3
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -1
- package/dist/request.mjs +1 -1
- package/dist/request.mjs.map +1 -1
- package/dist/types/request.d.mts +5 -3
- package/dist/types/request.d.ts +5 -3
- package/dist/types/request.js +1 -1
- package/dist/types/request.js.map +1 -1
- package/dist/types/webhook.d.mts +453 -0
- package/dist/types/webhook.d.ts +453 -0
- package/dist/types/webhook.js +2 -0
- package/dist/types/webhook.js.map +1 -0
- package/dist/types/webhook.mjs +2 -0
- package/dist/types/webhook.mjs.map +1 -0
- package/dist/utils/filters.d.mts +143 -0
- package/dist/utils/filters.d.ts +143 -0
- package/dist/utils/filters.js +2 -0
- package/dist/utils/filters.js.map +1 -0
- package/dist/utils/filters.mjs +2 -0
- package/dist/utils/filters.mjs.map +1 -0
- package/dist/webhook.d.mts +93 -0
- package/dist/webhook.d.ts +93 -0
- package/dist/webhook.js +2 -0
- package/dist/webhook.js.map +1 -0
- package/dist/webhook.mjs +2 -0
- package/dist/webhook.mjs.map +1 -0
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a message received through the webhook
|
|
3
|
+
* Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
|
|
4
|
+
*/
|
|
5
|
+
interface WebhookMessage {
|
|
6
|
+
/**
|
|
7
|
+
* The message ID
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The sender's phone number
|
|
12
|
+
*/
|
|
13
|
+
from: string;
|
|
14
|
+
/**
|
|
15
|
+
* The timestamp of the message
|
|
16
|
+
*/
|
|
17
|
+
timestamp: string;
|
|
18
|
+
/**
|
|
19
|
+
* The type of message (text, image, etc.)
|
|
20
|
+
*/
|
|
21
|
+
type: MessageType;
|
|
22
|
+
/**
|
|
23
|
+
* The phone number ID that received the message
|
|
24
|
+
*/
|
|
25
|
+
phoneNumberId: string;
|
|
26
|
+
/**
|
|
27
|
+
* Text object for text messages
|
|
28
|
+
*/
|
|
29
|
+
text?: {
|
|
30
|
+
/**
|
|
31
|
+
* The text content of the message
|
|
32
|
+
*/
|
|
33
|
+
body: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Image object for image messages
|
|
37
|
+
*/
|
|
38
|
+
image?: {
|
|
39
|
+
/**
|
|
40
|
+
* The image caption (if provided)
|
|
41
|
+
*/
|
|
42
|
+
caption?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The SHA256 hash of the image
|
|
45
|
+
*/
|
|
46
|
+
sha256?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The ID for the image
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
/**
|
|
52
|
+
* The MIME type of the image
|
|
53
|
+
*/
|
|
54
|
+
mime_type: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Video object for video messages
|
|
58
|
+
*/
|
|
59
|
+
video?: {
|
|
60
|
+
/**
|
|
61
|
+
* The video caption (if provided)
|
|
62
|
+
*/
|
|
63
|
+
caption?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The SHA256 hash of the video
|
|
66
|
+
*/
|
|
67
|
+
sha256?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The ID for the video
|
|
70
|
+
*/
|
|
71
|
+
id: string;
|
|
72
|
+
/**
|
|
73
|
+
* The MIME type of the video
|
|
74
|
+
*/
|
|
75
|
+
mime_type: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Audio object for audio messages
|
|
79
|
+
*/
|
|
80
|
+
audio?: {
|
|
81
|
+
/**
|
|
82
|
+
* The ID for the audio file
|
|
83
|
+
*/
|
|
84
|
+
id: string;
|
|
85
|
+
/**
|
|
86
|
+
* The MIME type of the audio file
|
|
87
|
+
*/
|
|
88
|
+
mime_type: string;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the audio is a voice message
|
|
91
|
+
*/
|
|
92
|
+
voice?: boolean;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Document object for document messages
|
|
96
|
+
*/
|
|
97
|
+
document?: {
|
|
98
|
+
/**
|
|
99
|
+
* The document caption (if provided)
|
|
100
|
+
*/
|
|
101
|
+
caption?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The document filename
|
|
104
|
+
*/
|
|
105
|
+
filename: string;
|
|
106
|
+
/**
|
|
107
|
+
* The SHA256 hash of the document
|
|
108
|
+
*/
|
|
109
|
+
sha256?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The ID for the document
|
|
112
|
+
*/
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* The MIME type of the document
|
|
116
|
+
*/
|
|
117
|
+
mime_type: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Sticker object for sticker messages
|
|
121
|
+
*/
|
|
122
|
+
sticker?: {
|
|
123
|
+
/**
|
|
124
|
+
* The ID for the sticker
|
|
125
|
+
*/
|
|
126
|
+
id: string;
|
|
127
|
+
/**
|
|
128
|
+
* Whether this is an animated sticker
|
|
129
|
+
*/
|
|
130
|
+
animated: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The MIME type of the sticker
|
|
133
|
+
*/
|
|
134
|
+
mime_type: string;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Contacts object for contact messages
|
|
138
|
+
*/
|
|
139
|
+
contacts?: Array<{
|
|
140
|
+
/**
|
|
141
|
+
* The contact's name
|
|
142
|
+
*/
|
|
143
|
+
name: {
|
|
144
|
+
formatted_name: string;
|
|
145
|
+
first_name?: string;
|
|
146
|
+
last_name?: string;
|
|
147
|
+
middle_name?: string;
|
|
148
|
+
suffix?: string;
|
|
149
|
+
prefix?: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* The contact's phone numbers
|
|
153
|
+
*/
|
|
154
|
+
phones?: Array<{
|
|
155
|
+
phone: string;
|
|
156
|
+
type?: string;
|
|
157
|
+
wa_id?: string;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* The contact's emails
|
|
161
|
+
*/
|
|
162
|
+
emails?: Array<{
|
|
163
|
+
email: string;
|
|
164
|
+
type?: string;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* The contact's addresses
|
|
168
|
+
*/
|
|
169
|
+
addresses?: Array<{
|
|
170
|
+
street?: string;
|
|
171
|
+
city?: string;
|
|
172
|
+
state?: string;
|
|
173
|
+
zip?: string;
|
|
174
|
+
country?: string;
|
|
175
|
+
country_code?: string;
|
|
176
|
+
type?: string;
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* The contact's organizations
|
|
180
|
+
*/
|
|
181
|
+
org?: {
|
|
182
|
+
company?: string;
|
|
183
|
+
department?: string;
|
|
184
|
+
title?: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* The contact's URLs
|
|
188
|
+
*/
|
|
189
|
+
urls?: Array<{
|
|
190
|
+
url: string;
|
|
191
|
+
type?: string;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* The contact's birthday (YYYY-MM-DD format)
|
|
195
|
+
*/
|
|
196
|
+
birthday?: string;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Location object for location messages
|
|
200
|
+
*/
|
|
201
|
+
location?: {
|
|
202
|
+
/**
|
|
203
|
+
* Latitude of the location
|
|
204
|
+
*/
|
|
205
|
+
latitude: number;
|
|
206
|
+
/**
|
|
207
|
+
* Longitude of the location
|
|
208
|
+
*/
|
|
209
|
+
longitude: number;
|
|
210
|
+
/**
|
|
211
|
+
* Name of the location
|
|
212
|
+
*/
|
|
213
|
+
name?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Address of the location
|
|
216
|
+
*/
|
|
217
|
+
address?: string;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Interactive object for interactive messages
|
|
221
|
+
*/
|
|
222
|
+
interactive?: {
|
|
223
|
+
/**
|
|
224
|
+
* Type of the interactive message
|
|
225
|
+
*/
|
|
226
|
+
type: string;
|
|
227
|
+
/**
|
|
228
|
+
* ID for the button that was clicked
|
|
229
|
+
*/
|
|
230
|
+
button_reply?: {
|
|
231
|
+
id: string;
|
|
232
|
+
title: string;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* ID for the list item that was selected
|
|
236
|
+
*/
|
|
237
|
+
list_reply?: {
|
|
238
|
+
id: string;
|
|
239
|
+
title: string;
|
|
240
|
+
description?: string;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* System object for system messages (like user phone number changes)
|
|
245
|
+
*/
|
|
246
|
+
system?: {
|
|
247
|
+
/**
|
|
248
|
+
* The type of system update
|
|
249
|
+
*/
|
|
250
|
+
type: string;
|
|
251
|
+
/**
|
|
252
|
+
* User's identity if the update is a customer identity change
|
|
253
|
+
*/
|
|
254
|
+
identity?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Old and new phone numbers if the update is a phone number change
|
|
257
|
+
*/
|
|
258
|
+
customer?: {
|
|
259
|
+
/**
|
|
260
|
+
* The previous phone number
|
|
261
|
+
*/
|
|
262
|
+
previous_wa_id: string;
|
|
263
|
+
/**
|
|
264
|
+
* The new phone number
|
|
265
|
+
*/
|
|
266
|
+
wa_id: string;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Order object for order messages
|
|
271
|
+
*/
|
|
272
|
+
order?: {
|
|
273
|
+
/**
|
|
274
|
+
* Catalog ID
|
|
275
|
+
*/
|
|
276
|
+
catalog_id: string;
|
|
277
|
+
/**
|
|
278
|
+
* Product items in the order
|
|
279
|
+
*/
|
|
280
|
+
product_items: Array<{
|
|
281
|
+
/**
|
|
282
|
+
* Product ID
|
|
283
|
+
*/
|
|
284
|
+
product_retailer_id: string;
|
|
285
|
+
/**
|
|
286
|
+
* Quantity of the product
|
|
287
|
+
*/
|
|
288
|
+
quantity: number;
|
|
289
|
+
/**
|
|
290
|
+
* Item price
|
|
291
|
+
*/
|
|
292
|
+
item_price: number;
|
|
293
|
+
/**
|
|
294
|
+
* Currency code
|
|
295
|
+
*/
|
|
296
|
+
currency: string;
|
|
297
|
+
}>;
|
|
298
|
+
/**
|
|
299
|
+
* Text message included with the order
|
|
300
|
+
*/
|
|
301
|
+
text?: string;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Context object, included when a user replies or interacts
|
|
305
|
+
*/
|
|
306
|
+
context?: {
|
|
307
|
+
/**
|
|
308
|
+
* ID of the message being replied to or interacted with
|
|
309
|
+
*/
|
|
310
|
+
message_id: string;
|
|
311
|
+
/**
|
|
312
|
+
* ID of the forwarded message, if applicable
|
|
313
|
+
*/
|
|
314
|
+
forwarded?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Frequently forwarded status
|
|
317
|
+
*/
|
|
318
|
+
frequently_forwarded?: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Original message information if the message was referred
|
|
321
|
+
*/
|
|
322
|
+
referred_product?: {
|
|
323
|
+
/**
|
|
324
|
+
* Catalog ID
|
|
325
|
+
*/
|
|
326
|
+
catalog_id: string;
|
|
327
|
+
/**
|
|
328
|
+
* Product ID
|
|
329
|
+
*/
|
|
330
|
+
product_retailer_id: string;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Errors array, if the message had errors
|
|
335
|
+
*/
|
|
336
|
+
errors?: Array<{
|
|
337
|
+
/**
|
|
338
|
+
* Error code
|
|
339
|
+
*/
|
|
340
|
+
code: number;
|
|
341
|
+
/**
|
|
342
|
+
* Error title
|
|
343
|
+
*/
|
|
344
|
+
title: string;
|
|
345
|
+
/**
|
|
346
|
+
* Error message
|
|
347
|
+
*/
|
|
348
|
+
message: string;
|
|
349
|
+
/**
|
|
350
|
+
* Error details object
|
|
351
|
+
*/
|
|
352
|
+
error_data?: {
|
|
353
|
+
/**
|
|
354
|
+
* Describes the error details
|
|
355
|
+
*/
|
|
356
|
+
details: string;
|
|
357
|
+
};
|
|
358
|
+
}>;
|
|
359
|
+
/**
|
|
360
|
+
* Button object for button messages
|
|
361
|
+
*/
|
|
362
|
+
button?: {
|
|
363
|
+
/**
|
|
364
|
+
* The payload for the button
|
|
365
|
+
*/
|
|
366
|
+
payload: string;
|
|
367
|
+
/**
|
|
368
|
+
* Button text
|
|
369
|
+
*/
|
|
370
|
+
text: string;
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* The original message data as received from the webhook
|
|
374
|
+
*/
|
|
375
|
+
originalData: any;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Represents a non-message event received through the webhook
|
|
379
|
+
*/
|
|
380
|
+
interface WebhookEvent {
|
|
381
|
+
/**
|
|
382
|
+
* The field type of the event
|
|
383
|
+
*/
|
|
384
|
+
field: string;
|
|
385
|
+
/**
|
|
386
|
+
* The event data
|
|
387
|
+
*/
|
|
388
|
+
value: any;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Configuration for the webhook handler
|
|
392
|
+
*/
|
|
393
|
+
interface WebhookConfig {
|
|
394
|
+
/**
|
|
395
|
+
* The URL path to listen on
|
|
396
|
+
*/
|
|
397
|
+
path?: string;
|
|
398
|
+
/**
|
|
399
|
+
* The verification token for the webhook
|
|
400
|
+
*/
|
|
401
|
+
verifyToken: string;
|
|
402
|
+
/**
|
|
403
|
+
* The public URL for the webhook
|
|
404
|
+
*/
|
|
405
|
+
callbackUrl: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Handler function for processing messages
|
|
409
|
+
*/
|
|
410
|
+
type MessageHandler = (message: WebhookMessage) => void | Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Handler function for processing events
|
|
413
|
+
*/
|
|
414
|
+
type EventHandler = (event: WebhookEvent) => void | Promise<void>;
|
|
415
|
+
/**
|
|
416
|
+
* Message types that can be received through the webhook
|
|
417
|
+
*/
|
|
418
|
+
declare enum MessageType {
|
|
419
|
+
TEXT = "text",
|
|
420
|
+
IMAGE = "image",
|
|
421
|
+
AUDIO = "audio",
|
|
422
|
+
VIDEO = "video",
|
|
423
|
+
DOCUMENT = "document",
|
|
424
|
+
STICKER = "sticker",
|
|
425
|
+
LOCATION = "location",
|
|
426
|
+
CONTACTS = "contacts",
|
|
427
|
+
BUTTON = "button",
|
|
428
|
+
INTERACTIVE = "interactive",
|
|
429
|
+
ORDER = "order",
|
|
430
|
+
SYSTEM = "system",
|
|
431
|
+
UNKNOWN = "unknown"
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Statuses that can be received in status updates
|
|
435
|
+
*/
|
|
436
|
+
declare enum MessageStatus {
|
|
437
|
+
DELIVERED = "delivered",
|
|
438
|
+
READ = "read",
|
|
439
|
+
SENT = "sent"
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Event fields that can be received through the webhook
|
|
443
|
+
*/
|
|
444
|
+
declare enum EventField {
|
|
445
|
+
MESSAGES = "messages",
|
|
446
|
+
STATUSES = "statuses",
|
|
447
|
+
MESSAGE_TEMPLATE_STATUS_UPDATE = "message_template_status_update",
|
|
448
|
+
PHONE_NUMBER_QUALITY_UPDATE = "phone_number_quality_update",
|
|
449
|
+
PHONE_NUMBER_NAME_UPDATE = "phone_number_name_update",
|
|
450
|
+
UNKNOWN = "unknown"
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export { EventField, type EventHandler, type MessageHandler, MessageStatus, MessageType, type WebhookConfig, type WebhookEvent, type WebhookMessage };
|