meta-cloud-api 0.2.15 → 0.2.16
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/BusinessProfileApi-DDkv2WQK.d.ts +352 -0
- package/dist/EncryptionApi-CwxQlC-2.d.ts +21 -0
- package/dist/FlowApi-BIBrWYEv.d.ts +471 -0
- package/dist/MediaApi-VqxndaBJ.d.ts +89 -0
- package/dist/MessageApi-CHc6bn3g.d.ts +591 -0
- package/dist/PhoneNumberApi-C-bs6YAe.d.ts +141 -0
- package/dist/QrCodeApi-BjlyPUXV.d.ts +97 -0
- package/dist/RegistrationApi-D7Bg8BUz.d.ts +46 -0
- package/dist/TemplateApi-dmZbvMkO.d.ts +117 -0
- package/dist/TwoStepVerificationApi-DaYWPjY_.d.ts +32 -0
- package/dist/WabaApi-CMoTCWiH.d.ts +174 -0
- package/dist/base-BG2gtoDs.d.ts +46 -0
- package/dist/chunk-2NJVBJUN.js +2 -0
- package/dist/chunk-2NJVBJUN.js.map +1 -0
- package/dist/chunk-3MO3BTBC.js +2 -0
- package/dist/chunk-3MO3BTBC.js.map +1 -0
- package/dist/chunk-4C666HHU.js +2 -0
- package/dist/chunk-4C666HHU.js.map +1 -0
- package/dist/chunk-5JGM556C.js +2 -0
- package/dist/chunk-5JGM556C.js.map +1 -0
- package/dist/chunk-7GL74SXM.js +2 -0
- package/dist/chunk-7GL74SXM.js.map +1 -0
- package/dist/chunk-7NQLQPLH.js +2 -0
- package/dist/chunk-7NQLQPLH.js.map +1 -0
- package/dist/chunk-A264MT4Q.js +2 -0
- package/dist/chunk-A264MT4Q.js.map +1 -0
- package/dist/chunk-BZ5QDXNR.js +2 -0
- package/dist/chunk-BZ5QDXNR.js.map +1 -0
- package/dist/chunk-EYGUX4EA.js +2 -0
- package/dist/chunk-EYGUX4EA.js.map +1 -0
- package/dist/chunk-FFOE5YKT.js +2 -0
- package/dist/chunk-FFOE5YKT.js.map +1 -0
- package/dist/chunk-GIQLIMOD.js +2 -0
- package/dist/chunk-GIQLIMOD.js.map +1 -0
- package/dist/chunk-KFPOVYEJ.js +2 -0
- package/dist/chunk-KFPOVYEJ.js.map +1 -0
- package/dist/chunk-O2OTHNWM.js +2 -0
- package/dist/chunk-O2OTHNWM.js.map +1 -0
- package/dist/chunk-UQPD6GIF.js +2 -0
- package/dist/chunk-UQPD6GIF.js.map +1 -0
- package/dist/chunk-VW3LGHTJ.js +2 -0
- package/dist/chunk-VW3LGHTJ.js.map +1 -0
- package/dist/chunk-XIIJD6SG.js +2 -0
- package/dist/chunk-XIIJD6SG.js.map +1 -0
- package/dist/chunk-XPPDOFBN.js +2 -0
- package/dist/chunk-XPPDOFBN.js.map +1 -0
- package/dist/enums-Z1f7QuVx.d.ts +687 -0
- package/dist/features/encryption/index.d.ts +9 -0
- package/dist/features/encryption/index.js +2 -0
- package/dist/features/flow/index.d.ts +9 -0
- package/dist/features/flow/index.js +2 -0
- package/dist/features/media/index.d.ts +9 -0
- package/dist/features/media/index.js +2 -0
- package/dist/features/messages/index.d.ts +9 -0
- package/dist/features/messages/index.js +2 -0
- package/dist/features/messages/index.js.map +1 -0
- package/dist/features/phone/index.d.ts +9 -0
- package/dist/features/phone/index.js +2 -0
- package/dist/features/phone/index.js.map +1 -0
- package/dist/features/profile/index.d.ts +9 -0
- package/dist/features/profile/index.js +2 -0
- package/dist/features/profile/index.js.map +1 -0
- package/dist/features/qrCode/index.d.ts +9 -0
- package/dist/features/qrCode/index.js +2 -0
- package/dist/features/qrCode/index.js.map +1 -0
- package/dist/features/registration/index.d.ts +9 -0
- package/dist/features/registration/index.js +2 -0
- package/dist/features/registration/index.js.map +1 -0
- package/dist/features/template/index.d.ts +9 -0
- package/dist/features/template/index.js +2 -0
- package/dist/features/template/index.js.map +1 -0
- package/dist/features/twoStepVerification/index.d.ts +9 -0
- package/dist/features/twoStepVerification/index.js +2 -0
- package/dist/features/twoStepVerification/index.js.map +1 -0
- package/dist/features/waba/index.d.ts +9 -0
- package/dist/features/waba/index.js +2 -0
- package/dist/features/waba/index.js.map +1 -0
- package/dist/index.d.ts +546 -28
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/shared/types/config.d.ts +78 -0
- package/dist/shared/types/config.js +2 -0
- package/dist/shared/types/config.js.map +1 -0
- package/dist/shared/types/enums.d.ts +1 -0
- package/dist/shared/types/enums.js +2 -0
- package/dist/shared/types/enums.js.map +1 -0
- package/dist/shared/utils/isMetaError.d.ts +21 -0
- package/dist/shared/utils/isMetaError.js +2 -0
- package/dist/shared/utils/isMetaError.js.map +1 -0
- package/package.json +80 -15
- package/dist/api/index.d.ts +0 -496
- package/dist/api/index.js +0 -2
- package/dist/chunk-IE2YYEC7.js +0 -2
- package/dist/chunk-IE2YYEC7.js.map +0 -1
- package/dist/chunk-IMPHLXRA.js +0 -2
- package/dist/chunk-IMPHLXRA.js.map +0 -1
- package/dist/chunk-KW56EPP7.js +0 -2
- package/dist/chunk-KW56EPP7.js.map +0 -1
- package/dist/chunk-SLDCD6XR.js +0 -2
- package/dist/chunk-SLDCD6XR.js.map +0 -1
- package/dist/chunk-UVPYV4PL.js +0 -2
- package/dist/chunk-UVPYV4PL.js.map +0 -1
- package/dist/types/index.d.ts +0 -513
- package/dist/types/index.js +0 -2
- package/dist/utils/index.d.ts +0 -71
- package/dist/utils/index.js +0 -2
- package/dist/waba-RRlZTQUG.d.ts +0 -2229
- package/dist/whatsapp-DmeO83A8.d.ts +0 -46
- /package/dist/{api → features/encryption}/index.js.map +0 -0
- /package/dist/{types → features/flow}/index.js.map +0 -0
- /package/dist/{utils → features/media}/index.js.map +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,524 @@
|
|
|
1
|
+
import { M as MessageTypesEnum, H as HttpMethodsEnum, S as SDKEnums } from './enums-Z1f7QuVx.js';
|
|
2
|
+
export { a as StatusEnum, W as WebhookTypesEnum } from './enums-Z1f7QuVx.js';
|
|
3
|
+
import { WhatsAppConfig, WabaConfigType } from './shared/types/config.js';
|
|
1
4
|
import { IncomingMessage } from 'http';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
5
|
+
import { F as FlowApi, a as FlowEndpointRequest, b as FlowTypeEnum } from './FlowApi-BIBrWYEv.js';
|
|
6
|
+
export { c as Flow, d as FlowClass, e as FlowEndpointResponse } from './FlowApi-BIBrWYEv.js';
|
|
7
|
+
import { E as EncryptionApi } from './EncryptionApi-CwxQlC-2.js';
|
|
8
|
+
import { M as MediaApi } from './MediaApi-VqxndaBJ.js';
|
|
9
|
+
export { a as MediaClass, b as MediaResponse, c as MediasResponse, U as UploadMediaResponse } from './MediaApi-VqxndaBJ.js';
|
|
10
|
+
import { M as MessagesApi } from './MessageApi-CHc6bn3g.js';
|
|
11
|
+
export { A as AudioMediaObject, C as ContactObject, D as DocumentMediaObject, I as ImageMediaObject, a as InteractiveObject, L as LocationObject, b as MessageRequestParams, d as MessageTemplateObject, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, f as TextObject, V as VideoMediaObject } from './MessageApi-CHc6bn3g.js';
|
|
12
|
+
import { P as PhoneNumberApi } from './PhoneNumberApi-C-bs6YAe.js';
|
|
13
|
+
export { a as PhoneNumberClass, b as PhoneNumberResponse } from './PhoneNumberApi-C-bs6YAe.js';
|
|
14
|
+
import { B as BusinessProfileApi } from './BusinessProfileApi-DDkv2WQK.js';
|
|
15
|
+
export { a as BusinessProfileClass, b as BusinessProfileResponse } from './BusinessProfileApi-DDkv2WQK.js';
|
|
16
|
+
import { Q as QrCodeApi } from './QrCodeApi-BjlyPUXV.js';
|
|
17
|
+
export { a as QrCodeClass, b as QrCodeResponse } from './QrCodeApi-BjlyPUXV.js';
|
|
18
|
+
import { R as RegistrationApi } from './RegistrationApi-D7Bg8BUz.js';
|
|
19
|
+
export { a as RegistrationClass } from './RegistrationApi-D7Bg8BUz.js';
|
|
20
|
+
import { T as TemplateApi } from './TemplateApi-dmZbvMkO.js';
|
|
21
|
+
export { a as TemplateClass, b as TemplateResponse } from './TemplateApi-dmZbvMkO.js';
|
|
22
|
+
import { T as TwoStepVerificationApi } from './TwoStepVerificationApi-DaYWPjY_.js';
|
|
23
|
+
import { W as WabaApi } from './WabaApi-CMoTCWiH.js';
|
|
24
|
+
export { b as WABAClass, a as WabaAccount } from './WabaApi-CMoTCWiH.js';
|
|
8
25
|
import { Agent } from 'https';
|
|
9
|
-
|
|
26
|
+
import { R as RequesterClass } from './base-BG2gtoDs.js';
|
|
27
|
+
export { MetaError, isMetaError } from './shared/utils/isMetaError.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents a message received through the webhook
|
|
31
|
+
* Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
|
|
32
|
+
*/
|
|
33
|
+
interface WebhookMessage {
|
|
34
|
+
/**
|
|
35
|
+
* The message ID
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* The sender's phone number
|
|
40
|
+
*/
|
|
41
|
+
from: string;
|
|
42
|
+
/**
|
|
43
|
+
* The timestamp of the message
|
|
44
|
+
*/
|
|
45
|
+
timestamp: string;
|
|
46
|
+
/**
|
|
47
|
+
* The type of message (text, image, etc.)
|
|
48
|
+
*/
|
|
49
|
+
type: MessageTypesEnum;
|
|
50
|
+
/**
|
|
51
|
+
* The phone number ID that received the message
|
|
52
|
+
*/
|
|
53
|
+
phoneNumberId: string;
|
|
54
|
+
/**
|
|
55
|
+
* The display phone number that received the message
|
|
56
|
+
*/
|
|
57
|
+
displayPhoneNumber: string;
|
|
58
|
+
/**
|
|
59
|
+
* The profile name of the sender
|
|
60
|
+
*/
|
|
61
|
+
profileName: string;
|
|
62
|
+
/**
|
|
63
|
+
* Text object for text messages
|
|
64
|
+
*/
|
|
65
|
+
text?: {
|
|
66
|
+
/**
|
|
67
|
+
* The text content of the message
|
|
68
|
+
*/
|
|
69
|
+
body: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Image object for image messages
|
|
73
|
+
*/
|
|
74
|
+
image?: {
|
|
75
|
+
/**
|
|
76
|
+
* The image caption (if provided)
|
|
77
|
+
*/
|
|
78
|
+
caption?: string;
|
|
79
|
+
/**
|
|
80
|
+
* The SHA256 hash of the image
|
|
81
|
+
*/
|
|
82
|
+
sha256?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The ID for the image
|
|
85
|
+
*/
|
|
86
|
+
id: string;
|
|
87
|
+
/**
|
|
88
|
+
* The MIME type of the image
|
|
89
|
+
*/
|
|
90
|
+
mime_type: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Video object for video messages
|
|
94
|
+
*/
|
|
95
|
+
video?: {
|
|
96
|
+
/**
|
|
97
|
+
* The video caption (if provided)
|
|
98
|
+
*/
|
|
99
|
+
caption?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The SHA256 hash of the video
|
|
102
|
+
*/
|
|
103
|
+
sha256?: string;
|
|
104
|
+
/**
|
|
105
|
+
* The ID for the video
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* The MIME type of the video
|
|
110
|
+
*/
|
|
111
|
+
mime_type: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Audio object for audio messages
|
|
115
|
+
*/
|
|
116
|
+
audio?: {
|
|
117
|
+
/**
|
|
118
|
+
* The ID for the audio file
|
|
119
|
+
*/
|
|
120
|
+
id: string;
|
|
121
|
+
/**
|
|
122
|
+
* The MIME type of the audio file
|
|
123
|
+
*/
|
|
124
|
+
mime_type: string;
|
|
125
|
+
/**
|
|
126
|
+
* Whether the audio is a voice message
|
|
127
|
+
*/
|
|
128
|
+
voice?: boolean;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Document object for document messages
|
|
132
|
+
*/
|
|
133
|
+
document?: {
|
|
134
|
+
/**
|
|
135
|
+
* The document caption (if provided)
|
|
136
|
+
*/
|
|
137
|
+
caption?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The document filename
|
|
140
|
+
*/
|
|
141
|
+
filename: string;
|
|
142
|
+
/**
|
|
143
|
+
* The SHA256 hash of the document
|
|
144
|
+
*/
|
|
145
|
+
sha256?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The ID for the document
|
|
148
|
+
*/
|
|
149
|
+
id: string;
|
|
150
|
+
/**
|
|
151
|
+
* The MIME type of the document
|
|
152
|
+
*/
|
|
153
|
+
mime_type: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Sticker object for sticker messages
|
|
157
|
+
*/
|
|
158
|
+
sticker?: {
|
|
159
|
+
/**
|
|
160
|
+
* The ID for the sticker
|
|
161
|
+
*/
|
|
162
|
+
id: string;
|
|
163
|
+
/**
|
|
164
|
+
* Whether this is an animated sticker
|
|
165
|
+
*/
|
|
166
|
+
animated: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* The MIME type of the sticker
|
|
169
|
+
*/
|
|
170
|
+
mime_type: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Reaction object for reaction messages
|
|
174
|
+
*/
|
|
175
|
+
reaction?: {
|
|
176
|
+
/**
|
|
177
|
+
* The ID of the message being reacted to
|
|
178
|
+
*/
|
|
179
|
+
message_id: string;
|
|
180
|
+
/**
|
|
181
|
+
* Emoji used for the reaction
|
|
182
|
+
*/
|
|
183
|
+
emoji: string;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Contacts object for contact messages
|
|
187
|
+
*/
|
|
188
|
+
contacts?: Array<{
|
|
189
|
+
/**
|
|
190
|
+
* The contact's name
|
|
191
|
+
*/
|
|
192
|
+
name: {
|
|
193
|
+
/**
|
|
194
|
+
* The formatted name
|
|
195
|
+
*/
|
|
196
|
+
formatted_name: string;
|
|
197
|
+
/**
|
|
198
|
+
* The first name
|
|
199
|
+
*/
|
|
200
|
+
first_name?: string;
|
|
201
|
+
/**
|
|
202
|
+
* The last name
|
|
203
|
+
*/
|
|
204
|
+
last_name?: string;
|
|
205
|
+
/**
|
|
206
|
+
* The middle name
|
|
207
|
+
*/
|
|
208
|
+
middle_name?: string;
|
|
209
|
+
/**
|
|
210
|
+
* The suffix
|
|
211
|
+
*/
|
|
212
|
+
suffix?: string;
|
|
213
|
+
/**
|
|
214
|
+
* The prefix
|
|
215
|
+
*/
|
|
216
|
+
prefix?: string;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* The contact's phone numbers
|
|
220
|
+
*/
|
|
221
|
+
phones?: Array<{
|
|
222
|
+
phone: string;
|
|
223
|
+
type?: string;
|
|
224
|
+
wa_id?: string;
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* The contact's emails
|
|
228
|
+
*/
|
|
229
|
+
emails?: Array<{
|
|
230
|
+
email: string;
|
|
231
|
+
type?: string;
|
|
232
|
+
}>;
|
|
233
|
+
/**
|
|
234
|
+
* The contact's addresses
|
|
235
|
+
*/
|
|
236
|
+
addresses?: Array<{
|
|
237
|
+
street?: string;
|
|
238
|
+
city?: string;
|
|
239
|
+
state?: string;
|
|
240
|
+
zip?: string;
|
|
241
|
+
country?: string;
|
|
242
|
+
country_code?: string;
|
|
243
|
+
type?: string;
|
|
244
|
+
}>;
|
|
245
|
+
/**
|
|
246
|
+
* The contact's organizations
|
|
247
|
+
*/
|
|
248
|
+
org?: {
|
|
249
|
+
company?: string;
|
|
250
|
+
department?: string;
|
|
251
|
+
title?: string;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* The contact's URLs
|
|
255
|
+
*/
|
|
256
|
+
urls?: Array<{
|
|
257
|
+
url: string;
|
|
258
|
+
type?: string;
|
|
259
|
+
}>;
|
|
260
|
+
/**
|
|
261
|
+
* The contact's birthday (YYYY-MM-DD format)
|
|
262
|
+
*/
|
|
263
|
+
birthday?: string;
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Location object for location messages
|
|
267
|
+
*/
|
|
268
|
+
location?: {
|
|
269
|
+
/**
|
|
270
|
+
* Latitude of the location
|
|
271
|
+
*/
|
|
272
|
+
latitude: number;
|
|
273
|
+
/**
|
|
274
|
+
* Longitude of the location
|
|
275
|
+
*/
|
|
276
|
+
longitude: number;
|
|
277
|
+
/**
|
|
278
|
+
* Name of the location
|
|
279
|
+
*/
|
|
280
|
+
name?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Address of the location
|
|
283
|
+
*/
|
|
284
|
+
address?: string;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Interactive object for interactive messages
|
|
288
|
+
*/
|
|
289
|
+
interactive?: {
|
|
290
|
+
/**
|
|
291
|
+
* Type of the interactive message
|
|
292
|
+
* Can be: button_reply, list_reply, flow, nfm_reply, etc.
|
|
293
|
+
*/
|
|
294
|
+
type: string;
|
|
295
|
+
/**
|
|
296
|
+
* ID for the button that was clicked
|
|
297
|
+
*/
|
|
298
|
+
button_reply?: {
|
|
299
|
+
id: string;
|
|
300
|
+
title: string;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* ID for the list item that was selected
|
|
304
|
+
*/
|
|
305
|
+
list_reply?: {
|
|
306
|
+
id: string;
|
|
307
|
+
title: string;
|
|
308
|
+
description?: string;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* NFM (No-Code Flow Message) reply data
|
|
312
|
+
*/
|
|
313
|
+
nfm_reply?: {
|
|
314
|
+
/**
|
|
315
|
+
* Response data in JSON format
|
|
316
|
+
*/
|
|
317
|
+
response_json: string;
|
|
318
|
+
/**
|
|
319
|
+
* Body text of the reply
|
|
320
|
+
*/
|
|
321
|
+
body: string;
|
|
322
|
+
/**
|
|
323
|
+
* Name of the flow
|
|
324
|
+
*/
|
|
325
|
+
name: string;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* System object for system messages (like user phone number changes)
|
|
330
|
+
*/
|
|
331
|
+
system?: {
|
|
332
|
+
/**
|
|
333
|
+
* The type of system update
|
|
334
|
+
*/
|
|
335
|
+
type: string;
|
|
336
|
+
/**
|
|
337
|
+
* User's identity if the update is a customer identity change
|
|
338
|
+
*/
|
|
339
|
+
identity?: string;
|
|
340
|
+
/**
|
|
341
|
+
* Old and new phone numbers if the update is a phone number change
|
|
342
|
+
*/
|
|
343
|
+
customer?: {
|
|
344
|
+
/**
|
|
345
|
+
* The previous phone number
|
|
346
|
+
*/
|
|
347
|
+
previous_wa_id: string;
|
|
348
|
+
/**
|
|
349
|
+
* The new phone number
|
|
350
|
+
*/
|
|
351
|
+
wa_id: string;
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Order object for order messages
|
|
356
|
+
*/
|
|
357
|
+
order?: {
|
|
358
|
+
/**
|
|
359
|
+
* Catalog ID
|
|
360
|
+
*/
|
|
361
|
+
catalog_id: string;
|
|
362
|
+
/**
|
|
363
|
+
* Product items in the order
|
|
364
|
+
*/
|
|
365
|
+
product_items: Array<{
|
|
366
|
+
/**
|
|
367
|
+
* Product ID
|
|
368
|
+
*/
|
|
369
|
+
product_retailer_id: string;
|
|
370
|
+
/**
|
|
371
|
+
* Quantity of the product
|
|
372
|
+
*/
|
|
373
|
+
quantity: number;
|
|
374
|
+
/**
|
|
375
|
+
* Item price
|
|
376
|
+
*/
|
|
377
|
+
item_price: number;
|
|
378
|
+
/**
|
|
379
|
+
* Currency code
|
|
380
|
+
*/
|
|
381
|
+
currency: string;
|
|
382
|
+
}>;
|
|
383
|
+
/**
|
|
384
|
+
* Text message included with the order
|
|
385
|
+
*/
|
|
386
|
+
text?: string;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Context object, included when a user replies or interacts
|
|
390
|
+
*/
|
|
391
|
+
context?: {
|
|
392
|
+
/**
|
|
393
|
+
* ID of the message
|
|
394
|
+
*/
|
|
395
|
+
id?: string;
|
|
396
|
+
/**
|
|
397
|
+
* ID of the sender
|
|
398
|
+
*/
|
|
399
|
+
from?: string;
|
|
400
|
+
/**
|
|
401
|
+
* ID of the message being replied to or interacted with
|
|
402
|
+
*/
|
|
403
|
+
message_id: string;
|
|
404
|
+
/**
|
|
405
|
+
* ID of the forwarded message, if applicable
|
|
406
|
+
*/
|
|
407
|
+
forwarded?: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Frequently forwarded status
|
|
410
|
+
*/
|
|
411
|
+
frequently_forwarded?: boolean;
|
|
412
|
+
/**
|
|
413
|
+
* Original message information if the message was referred
|
|
414
|
+
*/
|
|
415
|
+
referred_product?: {
|
|
416
|
+
/**
|
|
417
|
+
* Catalog ID
|
|
418
|
+
*/
|
|
419
|
+
catalog_id: string;
|
|
420
|
+
/**
|
|
421
|
+
* Product ID
|
|
422
|
+
*/
|
|
423
|
+
product_retailer_id: string;
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* Errors array, if the message had errors
|
|
428
|
+
*/
|
|
429
|
+
errors?: Array<{
|
|
430
|
+
/**
|
|
431
|
+
* Error code
|
|
432
|
+
*/
|
|
433
|
+
code: number;
|
|
434
|
+
/**
|
|
435
|
+
* Error title
|
|
436
|
+
*/
|
|
437
|
+
title: string;
|
|
438
|
+
/**
|
|
439
|
+
* Error message
|
|
440
|
+
*/
|
|
441
|
+
message: string;
|
|
442
|
+
/**
|
|
443
|
+
* Error details object
|
|
444
|
+
*/
|
|
445
|
+
error_data?: {
|
|
446
|
+
/**
|
|
447
|
+
* Describes the error details
|
|
448
|
+
*/
|
|
449
|
+
details: string;
|
|
450
|
+
};
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Button object for button messages
|
|
454
|
+
*/
|
|
455
|
+
button?: {
|
|
456
|
+
/**
|
|
457
|
+
* The payload for the button
|
|
458
|
+
*/
|
|
459
|
+
payload: string;
|
|
460
|
+
/**
|
|
461
|
+
* Button text
|
|
462
|
+
*/
|
|
463
|
+
text: string;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* The original message data as received from the webhook
|
|
467
|
+
*/
|
|
468
|
+
originalData: any;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Webhook event received from WhatsApp
|
|
472
|
+
*/
|
|
473
|
+
interface WebhookEvent {
|
|
474
|
+
/**
|
|
475
|
+
* The field type of the event
|
|
476
|
+
*/
|
|
477
|
+
field: string;
|
|
478
|
+
/**
|
|
479
|
+
* The event data
|
|
480
|
+
*/
|
|
481
|
+
value: any;
|
|
482
|
+
/**
|
|
483
|
+
* The timestamp when the event was received
|
|
484
|
+
*/
|
|
485
|
+
timestamp: number;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
type ResponseHeaderValue = string | string[] | undefined;
|
|
489
|
+
type ResponseHeaders = Record<string, ResponseHeaderValue>;
|
|
490
|
+
type ResponseJSONBody = Record<string, unknown>;
|
|
491
|
+
declare class HttpsClientResponseClass {
|
|
492
|
+
constructor(resp: Response);
|
|
493
|
+
statusCode: () => number;
|
|
494
|
+
headers: () => ResponseHeaders;
|
|
495
|
+
rawResponse: () => Response;
|
|
496
|
+
json: () => Promise<ResponseJSONBody>;
|
|
497
|
+
}
|
|
498
|
+
declare class HttpsClientClass {
|
|
499
|
+
constructor();
|
|
500
|
+
clearSockets: () => boolean;
|
|
501
|
+
sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
declare class WhatsAppClass {
|
|
505
|
+
constructor(config?: WhatsAppConfig);
|
|
506
|
+
readonly messages: MessagesApi;
|
|
507
|
+
readonly templates: TemplateApi;
|
|
508
|
+
readonly phoneNumber: PhoneNumberApi;
|
|
509
|
+
readonly qrCode: QrCodeApi;
|
|
510
|
+
readonly encryption: EncryptionApi;
|
|
511
|
+
readonly twoStepVerification: TwoStepVerificationApi;
|
|
512
|
+
readonly registration: RegistrationApi;
|
|
513
|
+
readonly media: MediaApi;
|
|
514
|
+
readonly waba: WabaApi;
|
|
515
|
+
readonly flow: FlowApi;
|
|
516
|
+
readonly businessProfile: BusinessProfileApi;
|
|
517
|
+
updateTimeout(ms: number): boolean;
|
|
518
|
+
updatePhoneNumberId(phoneNumberId: number): boolean;
|
|
519
|
+
updateAccessToken(accessToken: string): boolean;
|
|
520
|
+
updateWabaId(wabaId: string): boolean;
|
|
521
|
+
}
|
|
10
522
|
|
|
11
523
|
declare class HttpsClient implements HttpsClientClass {
|
|
12
524
|
agent: Agent;
|
|
@@ -15,6 +527,8 @@ declare class HttpsClient implements HttpsClientClass {
|
|
|
15
527
|
sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
|
|
16
528
|
}
|
|
17
529
|
|
|
530
|
+
declare const importConfig: (inputConfig?: WhatsAppConfig) => WabaConfigType;
|
|
531
|
+
|
|
18
532
|
declare class Requester implements RequesterClass {
|
|
19
533
|
client: Readonly<HttpsClient>;
|
|
20
534
|
accessToken: Readonly<string>;
|
|
@@ -39,14 +553,14 @@ declare class WhatsApp implements WhatsAppClass {
|
|
|
39
553
|
readonly messages: MessagesApi;
|
|
40
554
|
readonly templates: TemplateApi;
|
|
41
555
|
readonly phoneNumber: PhoneNumberApi;
|
|
42
|
-
readonly qrCode:
|
|
43
|
-
readonly encryption:
|
|
44
|
-
readonly twoStepVerification:
|
|
45
|
-
readonly registration:
|
|
46
|
-
readonly media:
|
|
47
|
-
readonly waba:
|
|
48
|
-
readonly flow:
|
|
49
|
-
readonly businessProfile:
|
|
556
|
+
readonly qrCode: QrCodeApi;
|
|
557
|
+
readonly encryption: EncryptionApi;
|
|
558
|
+
readonly twoStepVerification: TwoStepVerificationApi;
|
|
559
|
+
readonly registration: RegistrationApi;
|
|
560
|
+
readonly media: MediaApi;
|
|
561
|
+
readonly waba: WabaApi;
|
|
562
|
+
readonly flow: FlowApi;
|
|
563
|
+
readonly businessProfile: BusinessProfileApi;
|
|
50
564
|
static readonly Enums: typeof SDKEnums;
|
|
51
565
|
constructor(config?: WhatsAppConfig);
|
|
52
566
|
private userAgent;
|
|
@@ -99,47 +613,51 @@ declare class WebhookHandler {
|
|
|
99
613
|
* Process incoming messages
|
|
100
614
|
*/
|
|
101
615
|
private processMessages;
|
|
616
|
+
/**
|
|
617
|
+
* Process other webhook events
|
|
618
|
+
*/
|
|
102
619
|
private processEvent;
|
|
103
620
|
/**
|
|
104
621
|
* Register a message handler for a specific message type
|
|
105
|
-
* @param type Message type to handle, or '*' for all types
|
|
106
|
-
* @param handler The handler function
|
|
107
622
|
*/
|
|
108
623
|
onMessage(type: MessageTypesEnum, handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
|
|
109
624
|
/**
|
|
110
|
-
* Register
|
|
111
|
-
* @param field Event field to handle, or '*' for all fields
|
|
112
|
-
* @param handler The handler function
|
|
625
|
+
* Register an event handler for a specific field
|
|
113
626
|
*/
|
|
114
627
|
onEvent(field: string, handler: (event: WebhookEvent) => void | Promise<void>): void;
|
|
115
628
|
/**
|
|
116
|
-
* Register a pre-
|
|
117
|
-
* @param handler The handler function
|
|
629
|
+
* Register a pre-process handler that runs before all message handlers
|
|
118
630
|
*/
|
|
119
631
|
onMessagePreProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
|
|
120
632
|
/**
|
|
121
|
-
* Register a post-
|
|
122
|
-
* @param handler The handler function
|
|
633
|
+
* Register a post-process handler that runs after all message handlers
|
|
123
634
|
*/
|
|
124
635
|
onMessagePostProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
|
|
125
636
|
handleFlowRequest<Req extends IRequest & {
|
|
126
637
|
rawBody: string;
|
|
127
638
|
}, Res extends IResponse>(req: Req, res: Res): Promise<void>;
|
|
639
|
+
/**
|
|
640
|
+
* Validate the request signature
|
|
641
|
+
*/
|
|
128
642
|
isRequestSignatureValid(req: IRequest & {
|
|
129
643
|
rawBody: string;
|
|
130
644
|
}): boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Decrypt a flow request
|
|
647
|
+
*/
|
|
131
648
|
decryptRequest(body: any): {
|
|
132
649
|
decryptedBody: FlowEndpointRequest;
|
|
133
650
|
aesKeyBuffer: Buffer;
|
|
134
651
|
initialVectorBuffer: Buffer;
|
|
135
652
|
};
|
|
653
|
+
/**
|
|
654
|
+
* Encrypt a flow response
|
|
655
|
+
*/
|
|
136
656
|
private encryptResponse;
|
|
137
657
|
/**
|
|
138
|
-
* Register a
|
|
139
|
-
* @param type The flow type to handle (ping, change, error), or '*' for all types
|
|
140
|
-
* @param handler The handler function that receives the WhatsApp client and the Flow request
|
|
658
|
+
* Register a flow handler for a specific flow type
|
|
141
659
|
*/
|
|
142
660
|
onFlow(type: FlowTypeEnum, handler: (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>): void;
|
|
143
661
|
}
|
|
144
662
|
|
|
145
|
-
export {
|
|
663
|
+
export { BusinessProfileApi, EncryptionApi, FlowApi, FlowEndpointRequest, HttpMethodsEnum, type IRequest, type IResponse, MessageTypesEnum, MessagesApi, PhoneNumberApi, QrCodeApi, RegistrationApi, TemplateApi, TwoStepVerificationApi, WabaApi, WabaConfigType, WebhookHandler, WhatsApp as default, importConfig };
|