meta-cloud-api 0.2.34 → 0.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/{BusinessProfileApi-DDkv2WQK.d.ts → BusinessProfileApi-BJ9zy6c2.d.ts} +3 -3
  2. package/dist/{EncryptionApi-CwxQlC-2.d.ts → EncryptionApi-1aZ13Qyh.d.ts} +1 -1
  3. package/dist/{FlowApi-C5-2BGAw.d.ts → FlowApi-QDjrvCLp.d.ts} +2 -2
  4. package/dist/{MediaApi-VqxndaBJ.d.ts → MediaApi-V44kQnsN.d.ts} +1 -1
  5. package/dist/{MessageApi-CHc6bn3g.d.ts → MessageApi-BhSK0pfd.d.ts} +2 -2
  6. package/dist/{PhoneNumberApi-C-bs6YAe.d.ts → PhoneNumberApi-CPAIS17R.d.ts} +2 -2
  7. package/dist/{QrCodeApi-BjlyPUXV.d.ts → QrCodeApi-BjPYQIWF.d.ts} +1 -1
  8. package/dist/{RegistrationApi-D7Bg8BUz.d.ts → RegistrationApi-CGlvAgaz.d.ts} +2 -2
  9. package/dist/{TemplateApi-dmZbvMkO.d.ts → TemplateApi-D_23Ys02.d.ts} +3 -3
  10. package/dist/{TwoStepVerificationApi-DaYWPjY_.d.ts → TwoStepVerificationApi-CXMjxkUl.d.ts} +1 -1
  11. package/dist/{WabaApi-Qyk7PXMh.d.ts → WabaApi-BwnBkMPm.d.ts} +2 -2
  12. package/dist/WebhookHandler-Dn1NlyGm.d.ts +733 -0
  13. package/dist/{base-BG2gtoDs.d.ts → base-DtfdeScM.d.ts} +2 -2
  14. package/dist/{chunk-FFOE5YKT.js → chunk-GT3XQN7Y.js} +2 -2
  15. package/dist/chunk-GT3XQN7Y.js.map +1 -0
  16. package/dist/chunk-H55VIWDI.js +2 -0
  17. package/dist/chunk-H55VIWDI.js.map +1 -0
  18. package/dist/chunk-I222VSWK.js +2 -0
  19. package/dist/chunk-I222VSWK.js.map +1 -0
  20. package/dist/{chunk-AQTZR5SI.js → chunk-LGLRGXCE.js} +2 -2
  21. package/dist/{chunk-AQTZR5SI.js.map → chunk-LGLRGXCE.js.map} +1 -1
  22. package/dist/chunk-LYB4T5PE.js +3 -0
  23. package/dist/chunk-LYB4T5PE.js.map +1 -0
  24. package/dist/{chunk-XIIJD6SG.js → chunk-R36L2XYO.js} +2 -2
  25. package/dist/chunk-R36L2XYO.js.map +1 -0
  26. package/dist/chunk-SMHCU5MN.js +2 -0
  27. package/dist/chunk-SMHCU5MN.js.map +1 -0
  28. package/dist/chunk-YJWNS2MK.js +3 -0
  29. package/dist/chunk-YJWNS2MK.js.map +1 -0
  30. package/dist/core/webhook/index.d.ts +21 -0
  31. package/dist/core/webhook/index.js +2 -0
  32. package/dist/core/webhook/index.js.map +1 -0
  33. package/dist/core/whatsapp/index.d.ts +100 -0
  34. package/dist/core/whatsapp/index.js +2 -0
  35. package/dist/core/whatsapp/index.js.map +1 -0
  36. package/dist/{enums-Z1f7QuVx.d.ts → enums-DcRC4vFO.d.ts} +2 -1
  37. package/dist/features/encryption/index.d.ts +4 -4
  38. package/dist/features/encryption/index.js +1 -1
  39. package/dist/features/flow/index.d.ts +4 -4
  40. package/dist/features/flow/index.js +1 -1
  41. package/dist/features/media/index.d.ts +4 -4
  42. package/dist/features/media/index.js +1 -1
  43. package/dist/features/messages/index.d.ts +4 -4
  44. package/dist/features/messages/index.js +1 -1
  45. package/dist/features/phone/index.d.ts +4 -4
  46. package/dist/features/phone/index.js +1 -1
  47. package/dist/features/profile/index.d.ts +4 -4
  48. package/dist/features/profile/index.js +1 -1
  49. package/dist/features/qrCode/index.d.ts +4 -4
  50. package/dist/features/qrCode/index.js +1 -1
  51. package/dist/features/registration/index.d.ts +4 -4
  52. package/dist/features/registration/index.js +1 -1
  53. package/dist/features/template/index.d.ts +4 -4
  54. package/dist/features/template/index.js +1 -1
  55. package/dist/features/twoStepVerification/index.d.ts +4 -4
  56. package/dist/features/twoStepVerification/index.js +1 -1
  57. package/dist/features/waba/index.d.ts +4 -4
  58. package/dist/features/waba/index.js +1 -1
  59. package/dist/index.d.ts +35 -698
  60. package/dist/index.js +1 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/shared/types/config.d.ts +1 -1
  63. package/dist/shared/types/enums.d.ts +1 -1
  64. package/dist/shared/types/enums.js +1 -1
  65. package/package.json +1 -2
  66. package/dist/chunk-EYGUX4EA.js +0 -2
  67. package/dist/chunk-EYGUX4EA.js.map +0 -1
  68. package/dist/chunk-FFOE5YKT.js.map +0 -1
  69. package/dist/chunk-XIIJD6SG.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,560 +1,44 @@
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';
4
- import { IncomingMessage } from 'http';
5
- import { F as FlowApi, a as FlowEndpointRequest, b as FlowDataExchangeRequest, c as FlowActionEnum, d as FlowErrorNotificationRequest, e as FlowHealthCheckRequest, f as FlowType } from './FlowApi-C5-2BGAw.js';
6
- export { g as Flow, h as FlowClass, i as FlowEndpointResponse, j as FlowTypeEnum } from './FlowApi-C5-2BGAw.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-Qyk7PXMh.js';
24
- export { a as WABAClass, b as WabaAccount } from './WabaApi-Qyk7PXMh.js';
25
- import { Agent } from 'https';
26
- import { R as RequesterClass } from './base-BG2gtoDs.js';
1
+ export { W as WebhookContact, a as WebhookEvent, c as WebhookHandler, b as WebhookMessage } from './WebhookHandler-Dn1NlyGm.js';
2
+ import { g as FlowEndpointRequest, o as FlowDataExchangeRequest, c as FlowActionEnum, p as FlowErrorNotificationRequest, q as FlowHealthCheckRequest } from './FlowApi-QDjrvCLp.js';
3
+ export { a as Flow, F as FlowApi, f as FlowClass, h as FlowEndpointResponse, b as FlowType, n as FlowTypeEnum } from './FlowApi-QDjrvCLp.js';
4
+ export { WabaConfigType, WhatsAppConfig } from './shared/types/config.js';
5
+ export { A as AudioMediaTypesEnum, B as BusinessVerticalEnum, a as ButtonPositionEnum, b as ButtonTypesEnum, C as CategoryEnum, c as ComponentTypesEnum, d as ConversationTypesEnum, e as CurrencyCodesEnum, D as DataLocalizationRegionEnum, f as DocumentMediaTypesEnum, H as HttpMethodsEnum, I as ImageMediaTypesEnum, g as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, R as ReferralSourceTypesEnum, h as RequestCodeMethodsEnum, S as StatusEnum, i as StickerMediaTypesEnum, j as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, k as WebhookTypesEnum } from './enums-DcRC4vFO.js';
6
+ export { E as EncryptionApi } from './EncryptionApi-1aZ13Qyh.js';
7
+ export { a as MediaClass, b as MediaResponse, c as MediasResponse, U as UploadMediaResponse } from './MediaApi-V44kQnsN.js';
8
+ 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, M as MessagesApi, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, f as TextObject, V as VideoMediaObject } from './MessageApi-BhSK0pfd.js';
9
+ export { P as PhoneNumberApi, c as PhoneNumberClass, d as PhoneNumberResponse } from './PhoneNumberApi-CPAIS17R.js';
10
+ export { B as BusinessProfileApi, a as BusinessProfileClass, e as BusinessProfileResponse } from './BusinessProfileApi-BJ9zy6c2.js';
11
+ export { Q as QrCodeApi, a as QrCodeClass, b as QrCodeResponse } from './QrCodeApi-BjPYQIWF.js';
12
+ export { R as RegistrationApi, a as RegistrationClass } from './RegistrationApi-CGlvAgaz.js';
13
+ export { T as TemplateApi, a as TemplateClass, e as TemplateResponse } from './TemplateApi-D_23Ys02.js';
14
+ export { T as TwoStepVerificationApi } from './TwoStepVerificationApi-CXMjxkUl.js';
15
+ export { b as WABAClass, a as WabaAccount, W as WabaApi } from './WabaApi-BwnBkMPm.js';
16
+ export { WhatsApp } from './core/whatsapp/index.js';
27
17
  export { MetaError, isMetaError } from './shared/utils/isMetaError.js';
18
+ import './base-DtfdeScM.js';
19
+ import 'https';
28
20
 
29
- interface WebhookContact {
30
- /**
31
- * WhatsApp ID of the contact. Business can respond to this contact using this ID.
32
- */
33
- wa_id: string;
34
- /**
35
- * Additional unique, alphanumeric identifier for a WhatsApp user
36
- */
37
- user_id?: string;
38
- /**
39
- * Profile of Whatsapp user
40
- */
41
- profile: {
42
- /**
43
- * The display name of the contact
44
- */
45
- name: string;
46
- };
47
- }
48
- /**
49
- * Represents a message received through the webhook
50
- * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
51
- */
52
- interface WebhookMessage {
53
- /**
54
- * The message ID
55
- */
56
- id: string;
57
- /**
58
- * The sender's phone number
59
- */
60
- from: string;
61
- /**
62
- * The timestamp of the message
63
- */
64
- timestamp: string;
65
- /**
66
- * The type of message (text, image, etc.)
67
- */
68
- type: MessageTypesEnum;
69
- /**
70
- * The phone number ID that received the message
71
- */
72
- phoneNumberId: string;
73
- /**
74
- * The display phone number that received the message
75
- */
76
- displayPhoneNumber: string;
77
- /**
78
- * The profile name of the sender
79
- */
80
- profileName: string;
81
- /**
82
- * Text object for text messages
83
- */
84
- text?: {
85
- /**
86
- * The text content of the message
87
- */
88
- body: string;
89
- };
90
- /**
91
- * Image object for image messages
92
- */
93
- image?: {
94
- /**
95
- * The image caption (if provided)
96
- */
97
- caption?: string;
98
- /**
99
- * The SHA256 hash of the image
100
- */
101
- sha256?: string;
102
- /**
103
- * The ID for the image
104
- */
105
- id: string;
106
- /**
107
- * The MIME type of the image
108
- */
109
- mime_type: string;
110
- };
111
- /**
112
- * Video object for video messages
113
- */
114
- video?: {
115
- /**
116
- * The video caption (if provided)
117
- */
118
- caption?: string;
119
- /**
120
- * The SHA256 hash of the video
121
- */
122
- sha256?: string;
123
- /**
124
- * The ID for the video
125
- */
126
- id: string;
127
- /**
128
- * The MIME type of the video
129
- */
130
- mime_type: string;
131
- };
132
- /**
133
- * Audio object for audio messages
134
- */
135
- audio?: {
136
- /**
137
- * The ID for the audio file
138
- */
139
- id: string;
140
- /**
141
- * The MIME type of the audio file
142
- */
143
- mime_type: string;
144
- /**
145
- * Whether the audio is a voice message
146
- */
147
- voice?: boolean;
148
- };
149
- /**
150
- * Document object for document messages
151
- */
152
- document?: {
153
- /**
154
- * The document caption (if provided)
155
- */
156
- caption?: string;
157
- /**
158
- * The document filename
159
- */
160
- filename: string;
161
- /**
162
- * The SHA256 hash of the document
163
- */
164
- sha256?: string;
165
- /**
166
- * The ID for the document
167
- */
168
- id: string;
169
- /**
170
- * The MIME type of the document
171
- */
172
- mime_type: string;
173
- };
174
- /**
175
- * Sticker object for sticker messages
176
- */
177
- sticker?: {
178
- /**
179
- * The ID for the sticker
180
- */
181
- id: string;
182
- /**
183
- * Whether this is an animated sticker
184
- */
185
- animated: boolean;
186
- /**
187
- * The MIME type of the sticker
188
- */
189
- mime_type: string;
190
- };
191
- /**
192
- * Reaction object for reaction messages
193
- */
194
- reaction?: {
195
- /**
196
- * The ID of the message being reacted to
197
- */
198
- message_id: string;
199
- /**
200
- * Emoji used for the reaction
201
- */
202
- emoji: string;
203
- };
204
- /**
205
- * Contacts object for contact messages
206
- */
207
- contacts?: Array<{
208
- /**
209
- * The contact's name
210
- */
211
- name: {
212
- /**
213
- * The formatted name
214
- */
215
- formatted_name: string;
216
- /**
217
- * The first name
218
- */
219
- first_name?: string;
220
- /**
221
- * The last name
222
- */
223
- last_name?: string;
224
- /**
225
- * The middle name
226
- */
227
- middle_name?: string;
228
- /**
229
- * The suffix
230
- */
231
- suffix?: string;
232
- /**
233
- * The prefix
234
- */
235
- prefix?: string;
236
- };
237
- /**
238
- * The contact's phone numbers
239
- */
240
- phones?: Array<{
241
- phone: string;
242
- type?: string;
243
- wa_id?: string;
244
- }>;
245
- /**
246
- * The contact's emails
247
- */
248
- emails?: Array<{
249
- email: string;
250
- type?: string;
251
- }>;
252
- /**
253
- * The contact's addresses
254
- */
255
- addresses?: Array<{
256
- street?: string;
257
- city?: string;
258
- state?: string;
259
- zip?: string;
260
- country?: string;
261
- country_code?: string;
262
- type?: string;
263
- }>;
264
- /**
265
- * The contact's organizations
266
- */
267
- org?: {
268
- company?: string;
269
- department?: string;
270
- title?: string;
271
- };
272
- /**
273
- * The contact's URLs
274
- */
275
- urls?: Array<{
276
- url: string;
277
- type?: string;
278
- }>;
279
- /**
280
- * The contact's birthday (YYYY-MM-DD format)
281
- */
282
- birthday?: string;
283
- }>;
284
- /**
285
- * Location object for location messages
286
- */
287
- location?: {
288
- /**
289
- * Latitude of the location
290
- */
291
- latitude: number;
292
- /**
293
- * Longitude of the location
294
- */
295
- longitude: number;
296
- /**
297
- * Name of the location
298
- */
299
- name?: string;
300
- /**
301
- * Address of the location
302
- */
303
- address?: string;
304
- };
305
- /**
306
- * Interactive object for interactive messages
307
- */
308
- interactive?: {
309
- /**
310
- * Type of the interactive message
311
- * Can be: button_reply, list_reply, flow, nfm_reply, etc.
312
- */
313
- type: string;
314
- /**
315
- * ID for the button that was clicked
316
- */
317
- button_reply?: {
318
- id: string;
319
- title: string;
320
- };
321
- /**
322
- * ID for the list item that was selected
323
- */
324
- list_reply?: {
325
- id: string;
326
- title: string;
327
- description?: string;
328
- };
329
- /**
330
- * NFM (No-Code Flow Message) reply data
331
- */
332
- nfm_reply?: {
333
- /**
334
- * Response data in JSON format
335
- */
336
- response_json: string;
337
- /**
338
- * Body text of the reply
339
- */
340
- body: string;
341
- /**
342
- * Name of the flow
343
- */
344
- name: string;
345
- };
346
- };
347
- /**
348
- * System object for system messages (like user phone number changes)
349
- */
350
- system?: {
351
- /**
352
- * The type of system update
353
- */
354
- type: string;
355
- /**
356
- * User's identity if the update is a customer identity change
357
- */
358
- identity?: string;
359
- /**
360
- * Old and new phone numbers if the update is a phone number change
361
- */
362
- customer?: {
363
- /**
364
- * The previous phone number
365
- */
366
- previous_wa_id: string;
367
- /**
368
- * The new phone number
369
- */
370
- wa_id: string;
371
- };
372
- };
373
- /**
374
- * Order object for order messages
375
- */
376
- order?: {
377
- /**
378
- * Catalog ID
379
- */
380
- catalog_id: string;
381
- /**
382
- * Product items in the order
383
- */
384
- product_items: Array<{
385
- /**
386
- * Product ID
387
- */
388
- product_retailer_id: string;
389
- /**
390
- * Quantity of the product
391
- */
392
- quantity: number;
393
- /**
394
- * Item price
395
- */
396
- item_price: number;
397
- /**
398
- * Currency code
399
- */
400
- currency: string;
401
- }>;
402
- /**
403
- * Text message included with the order
404
- */
405
- text?: string;
406
- };
407
- /**
408
- * Context object, included when a user replies or interacts
409
- */
410
- context?: {
411
- /**
412
- * ID of the message
413
- */
414
- id?: string;
415
- /**
416
- * ID of the sender
417
- */
418
- from?: string;
419
- /**
420
- * ID of the message being replied to or interacted with
421
- */
422
- message_id: string;
423
- /**
424
- * ID of the forwarded message, if applicable
425
- */
426
- forwarded?: boolean;
427
- /**
428
- * Frequently forwarded status
429
- */
430
- frequently_forwarded?: boolean;
431
- /**
432
- * Original message information if the message was referred
433
- */
434
- referred_product?: {
435
- /**
436
- * Catalog ID
437
- */
438
- catalog_id: string;
439
- /**
440
- * Product ID
441
- */
442
- product_retailer_id: string;
443
- };
444
- };
445
- /**
446
- * Errors array, if the message had errors
447
- */
448
- errors?: Array<{
449
- /**
450
- * Error code
451
- */
452
- code: number;
453
- /**
454
- * Error title
455
- */
456
- title: string;
457
- /**
458
- * Error message
459
- */
460
- message: string;
461
- /**
462
- * Error details object
463
- */
464
- error_data?: {
465
- /**
466
- * Describes the error details
467
- */
468
- details: string;
469
- };
470
- }>;
471
- /**
472
- * Button object for button messages
473
- */
474
- button?: {
475
- /**
476
- * The payload for the button
477
- */
478
- payload: string;
479
- /**
480
- * Button text
481
- */
482
- text: string;
483
- };
484
- /**
485
- * The original message data as received from the webhook
486
- */
487
- originalData: any;
488
- }
489
- /**
490
- * Webhook event received from WhatsApp
491
- */
492
- interface WebhookEvent {
493
- /**
494
- * The field type of the event
495
- */
496
- field: string;
497
- /**
498
- * The event data
499
- */
500
- value: any;
501
- /**
502
- * The timestamp when the event was received
503
- */
504
- timestamp: number;
505
- }
506
- /**
507
- * Message handler function type
508
- */
509
- type MessageHandler = (message: WebhookMessage) => void | Promise<void>;
510
- /**
511
- * Event handler function type
512
- */
513
- type EventHandler = (event: WebhookEvent) => void | Promise<void>;
514
-
515
- type ResponseHeaderValue = string | string[] | undefined;
516
- type ResponseHeaders = Record<string, ResponseHeaderValue>;
517
- type ResponseJSONBody = Record<string, unknown>;
518
- declare class HttpsClientResponseClass {
519
- constructor(resp: Response);
520
- statusCode: () => number;
521
- headers: () => ResponseHeaders;
522
- rawResponse: () => Response;
523
- json: () => Promise<ResponseJSONBody>;
524
- }
525
- declare class HttpsClientClass {
526
- constructor();
527
- clearSockets: () => boolean;
528
- sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
21
+ interface LoggerInterface {
22
+ log(...data: any[]): void;
23
+ error(...data: any[]): void;
24
+ warn(...data: any[]): void;
25
+ info(...data: any[]): void;
26
+ debug(...data: any[]): void;
529
27
  }
530
28
 
531
- declare class WhatsAppClass {
532
- constructor(config?: WhatsAppConfig);
533
- readonly messages: MessagesApi;
534
- readonly templates: TemplateApi;
535
- readonly phoneNumber: PhoneNumberApi;
536
- readonly qrCode: QrCodeApi;
537
- readonly encryption: EncryptionApi;
538
- readonly twoStepVerification: TwoStepVerificationApi;
539
- readonly registration: RegistrationApi;
540
- readonly media: MediaApi;
541
- readonly waba: WabaApi;
542
- readonly flow: FlowApi;
543
- readonly businessProfile: BusinessProfileApi;
544
- updateTimeout(ms: number): boolean;
545
- updatePhoneNumberId(phoneNumberId: number): boolean;
546
- updateAccessToken(accessToken: string): boolean;
547
- updateWabaId(wabaId: string): boolean;
548
- }
29
+ declare function buildFieldsQueryString(fields?: string[] | string): string;
549
30
 
550
- declare class HttpsClient implements HttpsClientClass {
551
- agent: Agent;
552
- constructor();
553
- clearSockets(): boolean;
554
- sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
31
+ declare class Logger implements LoggerInterface {
32
+ private name;
33
+ private debug;
34
+ constructor(name: string, debug?: boolean);
35
+ log(...data: any[]): void;
36
+ error(...data: any[]): void;
37
+ warn(...data: any[]): void;
38
+ info(...data: any[]): void;
555
39
  }
556
40
 
557
- declare const importConfig: (inputConfig?: WhatsAppConfig) => WabaConfigType;
41
+ declare const objectToQueryString: (params: Record<string, any>) => string;
558
42
 
559
43
  declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
560
44
  declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
@@ -596,151 +80,4 @@ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is Fl
596
80
  */
597
81
  declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
598
82
 
599
- declare class Requester implements RequesterClass {
600
- client: Readonly<HttpsClient>;
601
- accessToken: Readonly<string>;
602
- phoneNumberId: Readonly<number>;
603
- businessAcctId: Readonly<string>;
604
- apiVersion: Readonly<string>;
605
- userAgent: Readonly<string>;
606
- host: Readonly<string>;
607
- protocol: Readonly<string>;
608
- constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
609
- buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
610
- buildCAPIPath(endpoint: string): string;
611
- sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
612
- getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
613
- sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
614
- sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
615
- }
616
-
617
- declare class WhatsApp implements WhatsAppClass {
618
- config: WabaConfigType;
619
- requester: Readonly<Requester>;
620
- readonly messages: MessagesApi;
621
- readonly templates: TemplateApi;
622
- readonly phoneNumber: PhoneNumberApi;
623
- readonly qrCode: QrCodeApi;
624
- readonly encryption: EncryptionApi;
625
- readonly twoStepVerification: TwoStepVerificationApi;
626
- readonly registration: RegistrationApi;
627
- readonly media: MediaApi;
628
- readonly waba: WabaApi;
629
- readonly flow: FlowApi;
630
- readonly businessProfile: BusinessProfileApi;
631
- static readonly Enums: typeof SDKEnums;
632
- constructor(config?: WhatsAppConfig);
633
- private userAgent;
634
- updateTimeout(ms: number): boolean;
635
- updatePhoneNumberId(phoneNumberId: number): boolean;
636
- updateAccessToken(accessToken: string): boolean;
637
- updateWabaId(wabaId: string): boolean;
638
- }
639
-
640
- interface IRequest extends IncomingMessage {
641
- body: any;
642
- query: Record<string, any>;
643
- method?: string;
644
- }
645
- interface IResponse {
646
- status: (code: number) => IResponse;
647
- send: (body: any) => IResponse | void;
648
- json: (body: any) => IResponse | void;
649
- end: () => void;
650
- }
651
- /**
652
- * Webhook handler for WhatsApp Cloud API
653
- */
654
- declare class WebhookHandler {
655
- private config;
656
- private client;
657
- private messageHandlers;
658
- private eventHandlers;
659
- private preProcessHandler;
660
- private postProcessHandler;
661
- private flowHandlers;
662
- /**
663
- * Create a new WebhookHandler
664
- * @param config The WhatsApp configuration
665
- */
666
- constructor(config: WhatsAppConfig);
667
- /**
668
- * Handle a GET request for webhook verification
669
- */
670
- handleVerificationRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): void;
671
- handleVerificationRequest<Req extends IRequest>(req: Req): string;
672
- /**
673
- * Handle a POST request for webhook events
674
- */
675
- handleWebhookRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): Promise<void>;
676
- handleWebhookRequest<Req extends IRequest>(req: Req): Promise<{
677
- success: boolean;
678
- errors?: string[];
679
- }>;
680
- /**
681
- * Handle webhook requests (both verification and events)
682
- */
683
- handleRequest<Req extends IRequest, Res extends IResponse>(req: Req, res: Res): void | Promise<void>;
684
- handleRequest<Req extends IRequest>(req: Req): string | Promise<{
685
- success: boolean;
686
- errors?: string[];
687
- }>;
688
- /**
689
- * Process incoming messages
690
- */
691
- private processMessages;
692
- /**
693
- * Process other webhook events
694
- */
695
- private processEvent;
696
- /**
697
- * Register a message handler for a specific message type
698
- */
699
- onMessage(type: MessageTypesEnum, handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
700
- /**
701
- * Register an event handler for a specific field
702
- */
703
- onEvent(field: string, handler: (event: WebhookEvent) => void | Promise<void>): void;
704
- /**
705
- * Register a pre-process handler that runs before all message handlers
706
- */
707
- onMessagePreProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
708
- /**
709
- * Register a post-process handler that runs after all message handlers
710
- */
711
- onMessagePostProcess(handler: (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>): void;
712
- handleFlowRequest<Req extends IRequest & {
713
- rawBody: string;
714
- }, Res extends IResponse>(req: Req, res: Res): Promise<void>;
715
- handleFlowRequest<Req extends IRequest & {
716
- rawBody: string;
717
- }>(req: Req): Promise<{
718
- statusCode: number;
719
- body: any;
720
- headers?: Record<string, string>;
721
- }>;
722
- /**
723
- * Validate the request signature
724
- */
725
- isRequestSignatureValid(req: IRequest & {
726
- rawBody: string;
727
- }): boolean;
728
- /**
729
- * Decrypt a flow request
730
- */
731
- decryptRequest(body: any): {
732
- decryptedBody: FlowEndpointRequest;
733
- aesKeyBuffer: Buffer;
734
- initialVectorBuffer: Buffer;
735
- };
736
- /**
737
- * Encrypt a flow response
738
- */
739
- private encryptResponse;
740
- /**
741
- * Register a flow handler for a specific flow type
742
- */
743
- onFlow(type: FlowType, handler: (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>): void;
744
- }
745
-
746
- export { BusinessProfileApi, EncryptionApi, type EventHandler, FlowApi, FlowEndpointRequest, FlowType, HttpMethodsEnum, type IRequest, type IResponse, type MessageHandler, MessageTypesEnum, MessagesApi, PhoneNumberApi, QrCodeApi, RegistrationApi, TemplateApi, TwoStepVerificationApi, WabaApi, WabaConfigType, type WebhookContact, type WebhookEvent, WebhookHandler, type WebhookMessage, WhatsApp, WhatsAppConfig, importConfig, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest };
83
+ export { FlowEndpointRequest, Logger, buildFieldsQueryString, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, objectToQueryString };