meta-cloud-api 2.0.0 → 2.0.1

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.
@@ -1,91 +1,6 @@
1
- import { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum } from "./enums-DyHU9JT1.js";
2
- import { IncomingHttpHeaders, IncomingMessage } from "http";
1
+ import { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum } from "./enums.js";
2
+ import { IncomingHttpHeaders, IncomingMessage } from "node:http";
3
3
 
4
- //#region src/types/config.d.ts
5
- type WhatsAppConfig = {
6
- accessToken: string;
7
- appId?: string;
8
- appSecret?: string;
9
- phoneNumberId?: number;
10
- businessAcctId?: string;
11
- apiVersion?: string;
12
- webhookEndpoint?: string;
13
- webhookVerificationToken?: string;
14
- listenerPort?: number;
15
- debug?: boolean;
16
- maxRetriesAfterWait?: number;
17
- requestTimeout?: number;
18
- privatePem?: string;
19
- passphrase?: string;
20
- };
21
- type WabaConfigType = {
22
- /**
23
- * The Meta for Developers business application Id for this registered application.
24
- */
25
- [WabaConfigEnum.AppId]: string;
26
- /**
27
- * The Meta for Developers business application secret for this registered application.
28
- */
29
- [WabaConfigEnum.AppSecret]: string;
30
- /**
31
- * The Meta for Developers phone number id used by the registered business.
32
- */
33
- [WabaConfigEnum.PhoneNumberId]: number;
34
- /**
35
- * The Meta for Developers business id for the registered business.
36
- */
37
- [WabaConfigEnum.BusinessAcctId]: string;
38
- /**
39
- * The version of the Cloud API being used. Starts with a "v" and follows the major number.
40
- */
41
- [WabaConfigEnum.APIVersion]: string;
42
- /**
43
- * The access token to make calls on behalf of the signed in Meta for Developers account or business.
44
- */
45
- [WabaConfigEnum.AccessToken]: string;
46
- /**
47
- * The endpoint path (e.g. if the value here is webhook, the webhook URL would look like http/https://{host}/webhook).
48
- */
49
- [WabaConfigEnum.WebhookEndpoint]: string;
50
- /**
51
- * The verification token that needs to match what is sent by the Cloud API webhook in order to subscribe.
52
- */
53
- [WabaConfigEnum.WebhookVerificationToken]: string;
54
- /**
55
- * The listener port for the webhook web server.
56
- */
57
- [WabaConfigEnum.ListenerPort]: number;
58
- /**
59
- * To turn on global debugging of the logger to print verbose output across the APIs.
60
- */
61
- [WabaConfigEnum.Debug]: boolean;
62
- /**
63
- * The total number of times a request should be retried after the wait period if it fails.
64
- */
65
- [WabaConfigEnum.MaxRetriesAfterWait]: number;
66
- /**
67
- * The timeout period for a request to quit and destroy the attempt in ms.
68
- */
69
- [WabaConfigEnum.RequestTimeout]: number;
70
- /**
71
- * The private key for the Meta for Developers business.
72
- */
73
- [WabaConfigEnum.PrivatePem]: string;
74
- /**
75
- * The passphrase for the Meta for Developers business.
76
- */
77
- [WabaConfigEnum.Passphrase]: string;
78
- };
79
- //#endregion
80
- //#region src/types/logger.d.ts
81
- interface LoggerInterface {
82
- log(...data: any[]): void;
83
- error(...data: any[]): void;
84
- warn(...data: any[]): void;
85
- info(...data: any[]): void;
86
- debug(...data: any[]): void;
87
- }
88
- //#endregion
89
4
  //#region src/types/request.d.ts
90
5
  type GeneralRequestBody = Record<string, unknown>;
91
6
  interface GeneralHeaderInterface {
@@ -143,657 +58,353 @@ declare class RequesterClass {
143
58
  getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
144
59
  sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
145
60
  sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
61
+ updateTimeout(timeout: number): void;
62
+ updateAccessToken(accessToken: string): void;
146
63
  }
147
64
  //#endregion
148
- //#region src/types/httpsClient.d.ts
149
- type ResponseHeaderValue = string | string[] | undefined;
150
- type ResponseHeaders = Record<string, ResponseHeaderValue>;
151
- type ResponseJSONBody = Record<string, unknown>;
152
- declare class HttpsClientResponseClass {
153
- constructor(resp: Response);
154
- statusCode: () => number;
155
- headers: () => ResponseHeaders;
156
- rawResponse: () => Response;
157
- json: () => Promise<ResponseJSONBody>;
158
- }
159
- declare class HttpsClientClass {
160
- constructor();
161
- clearSockets: () => boolean;
162
- sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
163
- }
164
- //#endregion
165
- //#region src/types/base.d.ts
166
- declare class BaseClass {
167
- constructor(config: WabaConfigType);
168
- }
169
- //#endregion
170
- //#region src/api/profile/types/upload.d.ts
65
+ //#region src/api/blockUsers/types/blockUsers.d.ts
171
66
  /**
172
- * Response from creating an upload session.
67
+ * Blocked user information in response
173
68
  */
174
- interface UploadSessionResponse {
175
- id: string;
176
- }
69
+ type BlockedUserInfo = {
70
+ input: string;
71
+ wa_id: string;
72
+ };
177
73
  /**
178
- * Response from uploading business profile media.
74
+ * Failed user information with error details
75
+ * Uses common MetaErrorDetail type for consistency across APIs
179
76
  */
180
- interface UploadBusinessProfileResponse {
181
- h: string;
182
- }
77
+ type FailedUserInfo = BlockedUserInfo & {
78
+ errors?: MetaErrorDetail[];
79
+ };
183
80
  /**
184
- * Upload handle information containing file details and handle.
81
+ * Response for block/unblock operations
185
82
  */
186
- interface UploadHandle {
187
- handle: string;
188
- file_size: number;
189
- upload_result: {
190
- handle_type: string;
191
- name: string;
83
+ type BlockUsersResponse = {
84
+ messaging_product: 'whatsapp';
85
+ block_users: {
86
+ added_users?: BlockedUserInfo[];
87
+ failed_users?: FailedUserInfo[];
192
88
  };
193
- }
194
- //#endregion
195
- //#region src/api/profile/types/common.d.ts
89
+ };
196
90
  /**
197
- * Available fields that can be requested when retrieving a business profile.
91
+ * Pagination cursors for list operations
198
92
  */
199
- type BusinessProfileField = 'about' | 'address' | 'description' | 'email' | 'messaging_product' | 'profile_picture_url' | 'websites' | 'vertical';
200
- type BusinessProfileFieldsParam = BusinessProfileField[] | string;
93
+ type PagingCursors = {
94
+ after?: string;
95
+ before?: string;
96
+ };
201
97
  /**
202
- * Business profile data structure containing all profile information.
98
+ * Pagination information
203
99
  */
204
- interface BusinessProfileData {
205
- /**
206
- * The business's About text. This text appears in the business's profile, beneath its profile image,
207
- * phone number, and contact buttons.
208
- * - String cannot be empty
209
- * - Strings must be between 1 and 139 characters
210
- * - Rendered emojis are supported however their unicode values are not.
211
- * Emoji unicode values must be Java- or JavaScript-escape encoded
212
- * - Hyperlinks can be included but will not render as clickable links
213
- * - Markdown is not supported
214
- */
215
- about?: string;
216
- /**
217
- * Address of the business. Character limit 256.
218
- */
219
- address?: string;
220
- /**
221
- * Description of the business. Character limit 512.
222
- */
223
- description?: string;
224
- /**
225
- * The contact email address (in valid email format) of the business. Character limit 128.
226
- */
227
- email?: string;
228
- /**
229
- * The messaging service used for the request. Always set it to "whatsapp" if you are using
230
- * the WhatsApp Business API.
231
- */
232
- messaging_product: string;
233
- /**
234
- * Profile picture URL.
235
- */
236
- profile_picture_url?: string;
237
- /**
238
- * The URLs associated with the business. For instance, a website, Facebook Page, or Instagram.
239
- * - You must include the http:// or https:// portion of the URL
240
- * - There is a maximum of 2 websites with a maximum of 256 characters each
241
- */
242
- websites?: string[];
243
- /**
244
- * Business category. This can be either an empty string or one of the predefined business categories.
245
- * @see BusinessVerticalEnum for all available options
246
- */
247
- vertical?: BusinessVerticalEnum | string;
248
- }
100
+ type PagingInfo$1 = {
101
+ cursors?: PagingCursors;
102
+ previous?: string;
103
+ next?: string;
104
+ };
249
105
  /**
250
- * Response structure for business profile GET requests.
106
+ * List blocked users response
251
107
  */
252
- interface BusinessProfileResponse {
253
- data: BusinessProfileData[];
254
- }
108
+ type ListBlockedUsersResponse = {
109
+ data: Array<{
110
+ block_users: BlockedUserInfo[];
111
+ }>;
112
+ paging?: PagingInfo$1;
113
+ };
255
114
  /**
256
- * Request structure for updating business profile.
115
+ * Query parameters for listing blocked users
257
116
  */
258
- interface UpdateBusinessProfileRequest {
117
+ type ListBlockedUsersParams = {
118
+ limit?: number;
119
+ after?: string;
120
+ before?: string;
121
+ };
122
+ /**
123
+ * Block Users API Interface
124
+ */
125
+ interface BlockUsersClass {
259
126
  /**
260
- * The messaging service used for the request. Always set it to "whatsapp" if you are using
261
- * the WhatsApp Business API.
262
- * @required
127
+ * Block one or more WhatsApp users
128
+ * @param users - Array of phone numbers or WhatsApp IDs to block
129
+ * @returns Response with successfully blocked and failed users
130
+ * @throws Error if users have not messaged in last 24 hours
131
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
263
132
  */
264
- messaging_product: string;
133
+ block(users: string[]): Promise<BlockUsersResponse>;
265
134
  /**
266
- * The business's About text. This text appears in the business's profile, beneath its profile image,
267
- * phone number, and contact buttons.
268
- * - String cannot be empty
269
- * - Strings must be between 1 and 139 characters
270
- * - Rendered emojis are supported however their unicode values are not.
271
- * Emoji unicode values must be Java- or JavaScript-escape encoded
272
- * - Hyperlinks can be included but will not render as clickable links
273
- * - Markdown is not supported
135
+ * Unblock one or more WhatsApp users
136
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
137
+ * @returns Response with successfully unblocked and failed users
138
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
274
139
  */
275
- about?: string;
140
+ unblock(users: string[]): Promise<BlockUsersResponse>;
276
141
  /**
277
- * Address of the business. Character limit 256.
142
+ * Get list of blocked WhatsApp users with pagination
143
+ * @param params - Optional pagination parameters
144
+ * @returns List of blocked users with pagination info
145
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
278
146
  */
279
- address?: string;
280
- /**
281
- * Description of the business. Character limit 512.
282
- */
283
- description?: string;
284
- /**
285
- * Business category. This can be either an empty string or one of the predefined business categories.
286
- * @see BusinessVerticalEnum for all available options
287
- */
288
- vertical?: BusinessVerticalEnum | string;
289
- /**
290
- * The contact email address (in valid email format) of the business. Character limit 128.
291
- */
292
- email?: string;
293
- /**
294
- * The URLs associated with the business. For instance, a website, Facebook Page, or Instagram.
295
- * - You must include the http:// or https:// portion of the URL
296
- * - There is a maximum of 2 websites with a maximum of 256 characters each
297
- */
298
- websites?: string[];
299
- /**
300
- * Handle of the profile picture. This handle is generated when you upload the binary file
301
- * for the profile picture to Meta using the Resumable Upload API.
302
- */
303
- profile_picture_handle?: string;
304
- }
305
- declare class BusinessProfileClass extends BaseClass {
306
- /**
307
- * Get your business profile.
308
- * @param fields Specific fields to be returned in the response. If not specified, all fields will be returned.
309
- */
310
- getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
311
- /**
312
- * Update your business profile.
313
- * @param updateRequest The request object containing the fields to update.
314
- */
315
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
316
- /**
317
- * Create an upload session for profile picture.
318
- * @param fileLength Length of the file to be uploaded in bytes.
319
- * @param fileType MIME type of the file (e.g., 'image/jpeg').
320
- * @param fileName Name of the file.
321
- */
322
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
323
- /**
324
- * Upload media file to the upload session.
325
- * @param uploadId The ID of the upload session.
326
- * @param file The binary data of the file.
327
- */
328
- uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
329
- /**
330
- * Get the upload handle information.
331
- * @param uploadId The ID of the upload session.
332
- */
333
- getUploadHandle(uploadId: string): Promise<UploadHandle>;
147
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
334
148
  }
335
149
  //#endregion
336
- //#region src/api/phone/types/common.d.ts
337
- type QualityRating = 'GREEN' | 'YELLOW' | 'RED' | 'NA';
338
- type AccountMode = 'LIVE' | 'SANDBOX';
339
- type CodeVerificationStatus = 'NOT_VERIFIED' | 'VERIFIED' | 'EXPIRED' | 'PENDING' | 'DELETED' | 'MIGRATED' | 'BANNED' | 'RESTRICTED' | 'RATE_LIMITED' | 'FLAGGED' | 'CONNECTED' | 'DISCONNECTED' | 'UNKNOWN' | 'UNVERIFIED';
340
- type MessagingLimitTier = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED';
341
- type PlatformType = 'CLOUD_API' | 'ON_PREMISE' | 'NOT_APPLICABLE';
342
- type ThroughputLevel = 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE';
343
- type HealthStatusEntity = {
344
- entity_type: string;
345
- id: string;
346
- can_send_message: string;
347
- additional_info?: string[];
348
- errors?: Array<{
349
- error_code: number;
350
- error_description: string;
351
- possible_solution: string;
352
- }>;
353
- };
354
- type HealthStatus = {
355
- can_send_message: string;
356
- entities: HealthStatusEntity[];
150
+ //#region src/api/calling/types/calling.d.ts
151
+ /**
152
+ * Calling API Types
153
+ * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
154
+ */
155
+ type CallingStatus = 'ENABLED' | 'DISABLED';
156
+ type CallIconVisibility = 'DEFAULT' | 'DISABLE_ALL';
157
+ type CallbackPermissionStatus = 'ENABLED' | 'DISABLED';
158
+ type CallHoursStatus = 'ENABLED' | 'DISABLED';
159
+ type SipStatus = 'ENABLED' | 'DISABLED';
160
+ type CallHoursDay = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
161
+ type WeeklyOperatingHours = {
162
+ day_of_week: CallHoursDay;
163
+ open_time: string;
164
+ close_time: string;
357
165
  };
358
- type QualityScore = {
359
- score: QualityRating;
166
+ type HolidaySchedule = {
167
+ date: string;
168
+ start_time: string;
169
+ end_time: string;
360
170
  };
361
- type Throughput = {
362
- level: ThroughputLevel;
171
+ type CallHours = {
172
+ status: CallHoursStatus;
173
+ timezone_id: string;
174
+ weekly_operating_hours: WeeklyOperatingHours[];
175
+ holiday_schedule?: HolidaySchedule[];
363
176
  };
364
- type PhoneNumberField = 'display_phone_number' | 'id' | 'quality_rating' | 'verified_name' | 'account_mode' | 'certificate' | 'code_verification_status' | 'conversational_automation' | 'eligibility_for_api_business_global_search' | 'health_status' | 'is_official_business_account' | 'is_on_biz_app' | 'is_pin_enabled' | 'is_preverified_number' | 'last_onboarded_time' | 'messaging_limit_tier' | 'name_status' | 'new_certificate' | 'new_name_status' | 'platform_type' | 'quality_score' | 'search_visibility' | 'status' | 'throughput';
365
- type PhoneNumberFieldsParam = PhoneNumberField[] | string;
366
- type PhoneNumberResponse = {
367
- display_phone_number: string;
368
- id: string;
369
- quality_rating: QualityRating;
370
- verified_name: string;
371
- account_mode?: AccountMode;
372
- certificate?: string;
373
- code_verification_status?: CodeVerificationStatus;
374
- conversational_automation?: Record<string, unknown>;
375
- eligibility_for_api_business_global_search?: string;
376
- health_status?: HealthStatus;
377
- is_official_business_account?: boolean;
378
- is_on_biz_app?: boolean;
379
- is_pin_enabled?: boolean;
380
- is_preverified_number?: boolean;
381
- last_onboarded_time?: string;
382
- messaging_limit_tier?: MessagingLimitTier;
383
- name_status?: string;
384
- new_certificate?: string;
385
- new_name_status?: string;
386
- platform_type?: PlatformType;
387
- quality_score?: QualityScore;
388
- search_visibility?: string;
389
- status?: CodeVerificationStatus;
390
- throughput?: Throughput;
177
+ type SipServer = {
178
+ hostname: string;
179
+ port?: number;
180
+ request_uri_user_params?: Record<string, string>;
181
+ sip_user_password?: string;
391
182
  };
392
- type Cursors = {
393
- before: string;
394
- after: string;
183
+ type SipSettings = {
184
+ status: SipStatus;
185
+ servers?: SipServer[];
395
186
  };
396
- type PhoneNumbersResponse = {
397
- data: PhoneNumberResponse[];
398
- paging: Paging;
187
+ type CallingSettings = {
188
+ status?: CallingStatus;
189
+ call_icon_visibility?: CallIconVisibility;
190
+ call_hours?: CallHours;
191
+ callback_permission_status?: CallbackPermissionStatus;
192
+ sip?: SipSettings;
399
193
  };
400
- type RequestVerificationCodeRequest = {
401
- code_method: 'SMS' | 'VOICE';
402
- language: string;
194
+ type UpdateCallingSettingsRequest = {
195
+ calling: CallingSettings;
403
196
  };
404
- type VerifyCodeRequest = {
405
- code: string;
197
+ type CallingSettingsResponse = {
198
+ calling?: CallingSettings;
199
+ [key: string]: unknown;
406
200
  };
407
- type TwoStepVerificationParams = {
408
- pin: string;
201
+ type CallPermission = {
202
+ status: string;
203
+ expiration_time?: number;
409
204
  };
410
- /**
411
- * Conversational Components - Commands
412
- */
413
- type ConversationalCommand = {
414
- command_name: string;
415
- command_description: string;
205
+ type CallPermissionLimit = {
206
+ time_period: string;
207
+ max_allowed: number;
208
+ current_usage: number;
209
+ limit_expiration_time?: number;
416
210
  };
417
- /**
418
- * Conversational Components - Ice Breakers (Prompts)
419
- */
420
- type ConversationalPrompt = string;
421
- /**
422
- * Request payload for configuring conversational automation
423
- */
424
- type ConversationalAutomationRequest = {
425
- enable_welcome_message?: boolean;
426
- commands?: ConversationalCommand[];
427
- prompts?: ConversationalPrompt[];
211
+ type CallPermissionAction = {
212
+ action_name: string;
213
+ can_perform_action: boolean;
214
+ limits?: CallPermissionLimit[];
428
215
  };
429
- /**
430
- * Response from conversational automation GET endpoint
431
- */
432
- type ConversationalAutomationResponse = {
433
- enable_welcome_message?: boolean;
434
- commands?: ConversationalCommand[];
435
- prompts?: ConversationalPrompt[];
436
- id: string;
216
+ type CallPermissionsResponse = {
217
+ messaging_product: 'whatsapp';
218
+ permission: CallPermission;
219
+ actions?: CallPermissionAction[];
437
220
  };
438
- /**
439
- * Response from throughput GET endpoint
440
- */
441
- type ThroughputResponse = {
442
- throughput: Throughput;
443
- id: string;
221
+ type CallSdpType = 'offer' | 'answer';
222
+ type CallSession = {
223
+ sdp_type: CallSdpType;
224
+ sdp: string;
444
225
  };
445
- interface PhoneNumberClass {
446
- getPhoneNumberById(fields?: PhoneNumberFieldsParam): Promise<PhoneNumberResponse>;
447
- getPhoneNumbers(): Promise<PhoneNumbersResponse>;
448
- requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
449
- verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>;
450
- setConversationalAutomation(params: ConversationalAutomationRequest): Promise<ResponseSuccess>;
451
- getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
452
- getThroughput(): Promise<ThroughputResponse>;
453
- }
454
- //#endregion
455
- //#region src/api/template/types/common.d.ts
456
- type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION' | 'PRODUCT';
457
- type PhoneNumberButton = {
458
- type: 'PHONE_NUMBER';
459
- text: string;
460
- phone_number: string;
226
+ type CallAction = 'connect' | 'pre_accept' | 'accept' | 'reject' | 'terminate';
227
+ type InitiateCallRequest = {
228
+ to: string;
229
+ session: CallSession;
230
+ biz_opaque_callback_data?: string;
461
231
  };
462
- type URLButton = {
463
- type: 'URL';
464
- text: string;
465
- url: string;
466
- example?: string[];
232
+ type PreAcceptCallRequest = {
233
+ call_id: string;
234
+ session?: CallSession;
467
235
  };
468
- type QuickReplyButton = {
469
- type: 'QUICK_REPLY';
470
- text: string;
236
+ type AcceptCallRequest = {
237
+ call_id: string;
238
+ session?: CallSession;
239
+ biz_opaque_callback_data?: string;
471
240
  };
472
- type CopyCodeButton = {
473
- type: 'COPY_CODE';
474
- example: string;
241
+ type RejectCallRequest = {
242
+ call_id: string;
475
243
  };
476
- type FlowButton = {
477
- type: 'FLOW';
478
- text: string;
479
- flow_id?: string;
480
- flow_name?: string;
481
- flow_json?: string;
482
- flow_action?: 'navigate' | 'data_exchange';
483
- navigate_screen?: string;
244
+ type TerminateCallRequest = {
245
+ call_id: string;
484
246
  };
485
- type MPMButton = {
486
- type: 'MPM';
487
- action?: {
488
- thumbnail_product_retailer_id: string;
489
- sections: Array<{
490
- title?: string;
491
- product_items: Array<{
492
- product_retailer_id: string;
493
- }>;
494
- }>;
495
- };
247
+ type InitiateCallResponse = {
248
+ messaging_product: 'whatsapp';
249
+ calls: Array<{
250
+ id: string;
251
+ }>;
496
252
  };
497
- type OTPButton = {
498
- type: 'OTP';
253
+ type CallActionResponse = {
254
+ messaging_product: 'whatsapp';
255
+ success: boolean;
499
256
  };
500
- type SPMButton = {
501
- type: 'SPM';
502
- action?: {
503
- product_retailer_id: string;
504
- };
257
+ interface CallingClass {
258
+ updateCallingSettings(params: UpdateCallingSettingsRequest): Promise<ResponseSuccess>;
259
+ getCallingSettings(params?: {
260
+ fields?: string[] | string;
261
+ include_sip_credentials?: boolean;
262
+ }): Promise<CallingSettingsResponse>;
263
+ getCallPermissions(params: {
264
+ userWaId: string;
265
+ }): Promise<CallPermissionsResponse>;
266
+ initiateCall(params: InitiateCallRequest): Promise<InitiateCallResponse>;
267
+ preAcceptCall(params: PreAcceptCallRequest): Promise<CallActionResponse>;
268
+ acceptCall(params: AcceptCallRequest): Promise<CallActionResponse>;
269
+ rejectCall(params: RejectCallRequest): Promise<CallActionResponse>;
270
+ terminateCall(params: TerminateCallRequest): Promise<CallActionResponse>;
271
+ }
272
+ //#endregion
273
+ //#region src/api/commerce/types/commerce.d.ts
274
+ /**
275
+ * Commerce Settings API Types
276
+ * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
277
+ */
278
+ type CommerceSetting = {
279
+ id: string;
280
+ is_cart_enabled?: boolean;
281
+ is_catalog_visible?: boolean;
505
282
  };
506
- type CatalogButton = {
507
- type: 'CATALOG';
508
- action?: {
509
- thumbnail_product_retailer_id: string;
510
- };
283
+ type CommerceSettingsResponse = {
284
+ data: CommerceSetting[];
511
285
  };
512
- type TemplateButton = PhoneNumberButton | URLButton | QuickReplyButton | CopyCodeButton | FlowButton | MPMButton | OTPButton | SPMButton | CatalogButton;
513
- type TemplateHeaderExample = {
514
- header_text?: string[];
515
- header_text_named_params?: Array<{
516
- param_name: string;
517
- example: string;
518
- }>;
519
- header_handle?: string[];
286
+ type UpdateCommerceSettingsRequest = {
287
+ is_cart_enabled?: boolean;
288
+ is_catalog_visible?: boolean;
520
289
  };
521
- type TemplateHeader = {
522
- type: 'HEADER';
523
- format: TemplateFormat;
524
- text?: string;
525
- example?: TemplateHeaderExample;
290
+ interface CommerceClass {
291
+ getCommerceSettings(): Promise<CommerceSettingsResponse>;
292
+ updateCommerceSettings(params: UpdateCommerceSettingsRequest): Promise<ResponseSuccess>;
293
+ }
294
+ //#endregion
295
+ //#region src/api/encryption/types/publicKey.d.ts
296
+ type EncryptionPublicKeyResponse = ResponseData<{
297
+ business_public_key: string;
298
+ business_public_key_signature_status: 'VALID' | 'MISMATCH';
299
+ }>;
300
+ //#endregion
301
+ //#region src/api/groups/types/groups.d.ts
302
+ /**
303
+ * Groups API Types
304
+ * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
305
+ */
306
+ type GroupJoinApprovalMode = 'approval_required' | 'auto_approve';
307
+ type GroupCreateRequest = {
308
+ subject: string;
309
+ description?: string;
310
+ join_approval_mode?: GroupJoinApprovalMode;
526
311
  };
527
- type TemplateBody = {
528
- type: 'BODY';
529
- text: string;
530
- example?: {
531
- body_text?: Array<Array<string>>;
532
- body_text_named_params?: Array<{
533
- param_name: string;
534
- example: string;
535
- }>;
536
- };
312
+ type GroupCreateResponse = {
313
+ messaging_product: 'whatsapp';
314
+ id: string;
315
+ invite_link?: string;
537
316
  };
538
- type TemplateFooter = {
539
- type: 'FOOTER';
540
- text: string;
317
+ type GroupInfoField = 'join_approval_mode' | 'subject' | 'description' | 'suspended' | 'creation_timestamp' | 'participants' | 'total_participant_count';
318
+ type GroupInfoFieldsParam = GroupInfoField[] | string;
319
+ type GroupParticipant = {
320
+ wa_id: string;
541
321
  };
542
- type TemplateButtons = {
543
- type: 'BUTTONS';
544
- buttons: TemplateButton[];
322
+ type GroupInfoResponse = {
323
+ messaging_product: 'whatsapp';
324
+ id: string;
325
+ subject?: string;
326
+ description?: string;
327
+ suspended?: boolean;
328
+ creation_timestamp?: number;
329
+ participants?: GroupParticipant[];
330
+ total_participant_count?: number;
331
+ join_approval_mode?: GroupJoinApprovalMode;
545
332
  };
546
- type TemplateLimitedTimeOffer = {
547
- type: 'LIMITED_TIME_OFFER';
548
- limited_time_offer: {
549
- expiration_time_ms: number;
550
- };
333
+ type GroupInviteLinkResponse = {
334
+ messaging_product: 'whatsapp';
335
+ invite_link: string;
551
336
  };
552
- type TemplateCarousel = {
553
- type: 'CAROUSEL';
554
- cards: Array<{
555
- card_index: number;
556
- components: ComponentTypes[];
557
- }>;
337
+ type GroupJoinRequest = {
338
+ join_request_id: string;
339
+ wa_id: string;
340
+ creation_timestamp: number;
558
341
  };
559
- type MediaCarouselCard = {
560
- card_index: number;
561
- components: (TemplateHeader | TemplateBody | TemplateButtons)[];
342
+ type GroupJoinRequestError = {
343
+ code: number;
344
+ message: string;
345
+ title?: string;
346
+ error_data?: {
347
+ details?: string;
348
+ };
562
349
  };
563
- type ProductCarouselCard = {
564
- card_index: number;
565
- components: TemplateHeader[];
350
+ type GroupJoinRequestFailure = {
351
+ join_request_id: string;
352
+ errors: GroupJoinRequestError[];
566
353
  };
567
- type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButtons | TemplateLimitedTimeOffer | TemplateCarousel;
568
- type TemplateRequestBody = GeneralRequestBody & {
569
- name: string;
570
- language: LanguagesEnum;
571
- category?: CategoryEnum;
572
- components?: ComponentTypes[];
354
+ type GroupJoinRequestsResponse = {
355
+ data: GroupJoinRequest[];
356
+ paging?: PagingInfo;
573
357
  };
574
- type TemplateResponse = {
358
+ type GroupJoinRequestsActionResponse = {
359
+ messaging_product: 'whatsapp';
360
+ approved_join_requests?: string[];
361
+ rejected_join_requests?: string[];
362
+ failed_join_requests?: GroupJoinRequestFailure[];
363
+ errors?: GroupJoinRequestError[];
364
+ };
365
+ type GroupSummary = {
575
366
  id: string;
576
- status: string;
577
- language: LanguagesEnum;
578
- category: CategoryEnum;
579
- name: string;
580
- components: ComponentTypes[];
367
+ subject: string;
368
+ created_at: number;
581
369
  };
582
- type TemplateGetParams = {
370
+ type GroupListResponse = {
371
+ data: {
372
+ groups: GroupSummary[];
373
+ };
374
+ paging?: PagingInfo;
375
+ };
376
+ type GroupListParams = {
583
377
  limit?: number;
584
- name?: string;
585
- language?: LanguagesEnum;
586
- category?: CategoryEnum;
587
- status?: TemplateStatusEnum;
378
+ after?: string;
379
+ before?: string;
588
380
  };
589
- type TemplateDeleteParams = {
590
- hsm_id: string;
591
- name: string;
381
+ type UpdateGroupSettingsRequest = {
382
+ subject?: string;
383
+ description?: string;
384
+ profilePictureFile?: Blob | Buffer;
592
385
  };
593
- declare class TemplateClass {
594
- getTemplate(templateId: string): Promise<TemplateResponse>;
595
- updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
596
- getTemplates(params?: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
597
- createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
598
- deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
599
- }
600
- //#endregion
601
- //#region src/api/template/types/factory.d.ts
602
- interface TextParameter {
603
- type: 'text';
604
- value: string;
605
- }
606
- interface CurrencyParameter {
607
- type: 'currency';
608
- amount_1000: number;
609
- code: CurrencyCodesEnum;
610
- fallback_value: string;
611
- }
612
- interface DateTimeParameter {
613
- type: 'date_time';
614
- fallback_value: string;
615
- }
616
- interface MediaParameter {
617
- type: 'image' | 'video' | 'document';
618
- handle?: string;
619
- link?: string;
620
- }
621
- interface LocationParameter {
622
- type: 'location';
623
- latitude?: number;
624
- longitude?: number;
625
- name?: string;
626
- address?: string;
627
- }
628
- interface ProductParameter {
629
- type: 'product';
630
- product_retailer_id: string;
631
- }
632
- type TemplateParameter = TextParameter | CurrencyParameter | DateTimeParameter | MediaParameter | LocationParameter | ProductParameter;
633
- interface HeaderOptions {
634
- format: TemplateFormat;
635
- text?: string;
636
- parameters?: TemplateParameter[];
637
- example?: {
638
- header_text?: string[];
639
- header_text_named_params?: Array<{
640
- param_name: string;
641
- example: string;
642
- }>;
643
- header_handle?: string[];
644
- };
645
- }
646
- interface BodyOptions {
647
- text: string;
648
- parameters?: TemplateParameter[];
649
- example?: {
650
- body_text?: string[][];
651
- body_text_named_params?: Array<{
652
- param_name: string;
653
- example: string;
654
- }>;
655
- };
656
- }
657
- interface FooterOptions {
658
- text: string;
659
- }
660
- interface ButtonOptions {
661
- phone_number?: {
662
- text: string;
663
- phone_number: string;
664
- };
665
- url?: {
666
- text: string;
667
- url: string;
668
- example?: string;
669
- };
670
- quick_reply?: {
671
- text: string;
672
- }[];
673
- copy_code?: {
674
- example: string;
675
- };
676
- flow?: {
677
- text: string;
678
- flow_id?: string;
679
- flow_name?: string;
680
- flow_json?: string;
681
- flow_action?: 'navigate' | 'data_exchange';
682
- navigate_screen?: string;
683
- };
684
- mpm?: boolean;
685
- otp?: boolean;
686
- spm?: boolean;
687
- }
688
- interface CarouselCard {
689
- image?: string;
690
- video?: string;
691
- product?: string;
692
- body?: string;
693
- bodyParameters?: TemplateParameter[];
694
- buttons?: ButtonOptions;
695
- }
696
- interface CarouselOptions {
697
- cards: CarouselCard[];
698
- }
699
- interface LimitedTimeOfferOptions {
700
- expiration_time_ms: number;
701
- }
702
- interface ProductSection {
703
- title?: string;
704
- product_items: Array<{
705
- product_retailer_id: string;
706
- }>;
707
- }
708
- interface TemplateOptions {
709
- name: string;
710
- language: LanguagesEnum;
711
- category: CategoryEnum;
712
- header?: HeaderOptions;
713
- body?: BodyOptions;
714
- footer?: FooterOptions;
715
- buttons?: ButtonOptions;
716
- carousel?: CarouselOptions;
717
- limitedTimeOffer?: LimitedTimeOfferOptions;
718
- }
719
- interface OTPTemplateOptions {
720
- name: string;
721
- language: LanguagesEnum;
722
- code_expiration_minutes?: number;
723
- add_security_recommendation?: boolean;
724
- }
725
- interface AuthenticationTemplateOptions {
726
- name: string;
727
- language: LanguagesEnum;
728
- code_expiration_minutes?: number;
729
- add_security_recommendation?: boolean;
730
- copy_code_button?: boolean;
731
- }
732
- interface CatalogTemplateOptions {
733
- name: string;
734
- language: LanguagesEnum;
735
- header?: Omit<HeaderOptions, 'format'>;
736
- body: BodyOptions;
737
- footer?: FooterOptions;
738
- thumbnail_product_retailer_id: string;
739
- }
740
- interface CouponTemplateOptions {
741
- name: string;
742
- language: LanguagesEnum;
743
- header?: Omit<HeaderOptions, 'format'>;
744
- body: BodyOptions;
745
- footer?: FooterOptions;
746
- coupon_code: string;
747
- }
748
- interface LimitedTimeOfferTemplateOptions {
749
- name: string;
750
- language: LanguagesEnum;
751
- header?: Omit<HeaderOptions, 'format'>;
752
- body: BodyOptions;
753
- footer?: FooterOptions;
754
- expiration_time_ms: number;
755
- }
756
- interface MediaCardCarouselTemplateOptions {
757
- name: string;
758
- language: LanguagesEnum;
759
- cards: Array<{
760
- header: {
761
- format: 'IMAGE' | 'VIDEO';
762
- example: {
763
- header_handle: string[];
764
- };
765
- };
766
- body: BodyOptions;
767
- buttons?: ButtonOptions;
768
- }>;
769
- }
770
- interface MPMTemplateOptions {
771
- name: string;
772
- language: LanguagesEnum;
773
- header?: Omit<HeaderOptions, 'format'>;
774
- body: BodyOptions;
775
- footer?: FooterOptions;
776
- thumbnail_product_retailer_id: string;
777
- sections: ProductSection[];
778
- }
779
- interface ProductCardCarouselTemplateOptions {
780
- name: string;
781
- language: LanguagesEnum;
782
- header?: Omit<HeaderOptions, 'format'>;
783
- body: BodyOptions;
784
- footer?: FooterOptions;
785
- cards: Array<{
786
- product_retailer_id: string;
787
- }>;
788
- }
789
- interface SPMTemplateOptions {
790
- name: string;
791
- language: LanguagesEnum;
792
- header?: Omit<HeaderOptions, 'format'>;
793
- body: BodyOptions;
794
- footer?: FooterOptions;
795
- product_retailer_id: string;
386
+ type GroupSettingsResponse = ResponseSuccess;
387
+ interface GroupsClass {
388
+ createGroup(params: GroupCreateRequest): Promise<GroupCreateResponse>;
389
+ deleteGroup(groupId: string): Promise<ResponseSuccess>;
390
+ getGroupInfo(groupId: string, fields?: GroupInfoFieldsParam): Promise<GroupInfoResponse>;
391
+ getActiveGroups(params?: GroupListParams): Promise<GroupListResponse>;
392
+ getGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
393
+ resetGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
394
+ getJoinRequests(groupId: string): Promise<GroupJoinRequestsResponse>;
395
+ approveJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
396
+ rejectJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
397
+ removeParticipants(groupId: string, participants: string[]): Promise<ResponseSuccess>;
398
+ updateGroupSettings(groupId: string, params: UpdateGroupSettingsRequest): Promise<GroupSettingsResponse>;
796
399
  }
400
+ type PagingInfo = {
401
+ cursors?: {
402
+ before?: string;
403
+ after?: string;
404
+ };
405
+ previous?: string;
406
+ next?: string;
407
+ };
797
408
  //#endregion
798
409
  //#region src/api/messages/types/text.d.ts
799
410
  type TextObject = {
@@ -1184,58 +795,139 @@ interface ReactionParams {
1184
795
  to: string;
1185
796
  }
1186
797
  //#endregion
1187
- //#region src/api/messages/types/common.d.ts
1188
- type GeneralMessageBody = GeneralRequestBody & {
798
+ //#region src/types/config.d.ts
799
+ type WhatsAppConfig = {
800
+ accessToken: string;
801
+ appId?: string;
802
+ appSecret?: string;
803
+ phoneNumberId?: number;
804
+ businessAcctId?: string;
805
+ apiVersion?: string;
806
+ webhookEndpoint?: string;
807
+ webhookVerificationToken?: string;
808
+ listenerPort?: number;
809
+ debug?: boolean;
810
+ maxRetriesAfterWait?: number;
811
+ requestTimeout?: number;
812
+ privatePem?: string;
813
+ passphrase?: string;
814
+ };
815
+ type WabaConfigType = {
1189
816
  /**
1190
- * The Meta messaging product name.
1191
- * @default 'whatsapp'
817
+ * The Meta for Developers business application Id for this registered application.
1192
818
  */
1193
- messaging_product: 'whatsapp';
1194
- };
1195
- type ConTextObject = {
1196
- message_id: string;
1197
- };
1198
- type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {
1199
- recipient_type?: string;
1200
- to: string;
1201
- context?: ConTextObject;
1202
- type?: T;
1203
- };
1204
- interface MessageRequestParams<T> {
1205
- body: T;
1206
- to: string;
1207
- replyMessageId?: string;
1208
- }
1209
- interface StatusParams {
1210
- status: string;
1211
- messageId: string;
1212
- typingIndicator?: {
1213
- type: string;
1214
- };
1215
- }
1216
- type MessagesResponse = GeneralMessageBody & {
1217
- contacts: [{
1218
- input: string;
1219
- wa_id: string;
1220
- }];
1221
- messages: [{
1222
- id: string;
1223
- }];
1224
- };
1225
- declare class MessagesClass extends BaseClass {
1226
- text(params: TextMessageParams): Promise<MessagesResponse>;
1227
- template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
1228
- audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
1229
- document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
1230
- image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
1231
- video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
1232
- sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
1233
- contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
1234
- location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
1235
- interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
1236
- interactiveList(params: MessageRequestParams<InteractiveObject & {
1237
- type: InteractiveTypesEnum.List;
1238
- }>): Promise<MessagesResponse>;
819
+ [WabaConfigEnum.AppId]: string;
820
+ /**
821
+ * The Meta for Developers business application secret for this registered application.
822
+ */
823
+ [WabaConfigEnum.AppSecret]: string;
824
+ /**
825
+ * The Meta for Developers phone number id used by the registered business.
826
+ */
827
+ [WabaConfigEnum.PhoneNumberId]: number;
828
+ /**
829
+ * The Meta for Developers business id for the registered business.
830
+ */
831
+ [WabaConfigEnum.BusinessAcctId]: string;
832
+ /**
833
+ * The version of the Cloud API being used. Starts with a "v" and follows the major number.
834
+ */
835
+ [WabaConfigEnum.APIVersion]: string;
836
+ /**
837
+ * The access token to make calls on behalf of the signed in Meta for Developers account or business.
838
+ */
839
+ [WabaConfigEnum.AccessToken]: string;
840
+ /**
841
+ * The endpoint path (e.g. if the value here is webhook, the webhook URL would look like http/https://{host}/webhook).
842
+ */
843
+ [WabaConfigEnum.WebhookEndpoint]: string;
844
+ /**
845
+ * The verification token that needs to match what is sent by the Cloud API webhook in order to subscribe.
846
+ */
847
+ [WabaConfigEnum.WebhookVerificationToken]: string;
848
+ /**
849
+ * The listener port for the webhook web server.
850
+ */
851
+ [WabaConfigEnum.ListenerPort]: number;
852
+ /**
853
+ * To turn on global debugging of the logger to print verbose output across the APIs.
854
+ */
855
+ [WabaConfigEnum.Debug]: boolean;
856
+ /**
857
+ * The total number of times a request should be retried after the wait period if it fails.
858
+ */
859
+ [WabaConfigEnum.MaxRetriesAfterWait]: number;
860
+ /**
861
+ * The timeout period for a request to quit and destroy the attempt in ms.
862
+ */
863
+ [WabaConfigEnum.RequestTimeout]: number;
864
+ /**
865
+ * The private key for the Meta for Developers business.
866
+ */
867
+ [WabaConfigEnum.PrivatePem]: string;
868
+ /**
869
+ * The passphrase for the Meta for Developers business.
870
+ */
871
+ [WabaConfigEnum.Passphrase]: string;
872
+ };
873
+ //#endregion
874
+ //#region src/types/base.d.ts
875
+ declare class BaseClass {
876
+ constructor(config: WabaConfigType);
877
+ }
878
+ //#endregion
879
+ //#region src/api/messages/types/common.d.ts
880
+ type GeneralMessageBody = GeneralRequestBody & {
881
+ /**
882
+ * The Meta messaging product name.
883
+ * @default 'whatsapp'
884
+ */
885
+ messaging_product: 'whatsapp';
886
+ };
887
+ type ConTextObject = {
888
+ message_id: string;
889
+ };
890
+ type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {
891
+ recipient_type?: string;
892
+ to: string;
893
+ context?: ConTextObject;
894
+ type?: T;
895
+ };
896
+ interface MessageRequestParams<T> {
897
+ body: T;
898
+ to: string;
899
+ replyMessageId?: string;
900
+ }
901
+ interface StatusParams {
902
+ status: string;
903
+ messageId: string;
904
+ typingIndicator?: {
905
+ type: string;
906
+ };
907
+ }
908
+ type MessagesResponse = GeneralMessageBody & {
909
+ contacts: [{
910
+ input: string;
911
+ wa_id: string;
912
+ }];
913
+ messages: [{
914
+ id: string;
915
+ }];
916
+ };
917
+ declare class MessagesClass extends BaseClass {
918
+ text(params: TextMessageParams): Promise<MessagesResponse>;
919
+ template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
920
+ audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
921
+ document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
922
+ image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
923
+ video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
924
+ sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
925
+ contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
926
+ location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
927
+ interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
928
+ interactiveList(params: MessageRequestParams<InteractiveObject & {
929
+ type: InteractiveTypesEnum.List;
930
+ }>): Promise<MessagesResponse>;
1239
931
  interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
1240
932
  type: InteractiveTypesEnum.CtaUrl;
1241
933
  }>): Promise<MessagesResponse>;
@@ -1264,6 +956,20 @@ declare class MessagesClass extends BaseClass {
1264
956
  status(params: StatusParams): Promise<MessagesResponse>;
1265
957
  }
1266
958
  //#endregion
959
+ //#region src/api/marketingMessages/types/marketingMessages.d.ts
960
+ /**
961
+ * Marketing Messages API Types
962
+ * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages/
963
+ */
964
+ type MarketingMessageRequest = {
965
+ to: string;
966
+ template: MessageTemplateObject<ComponentTypesEnum>;
967
+ message_activity_sharing?: boolean;
968
+ };
969
+ interface MarketingMessagesClass {
970
+ sendTemplateMessage(params: MarketingMessageRequest): Promise<MessagesResponse>;
971
+ }
972
+ //#endregion
1267
973
  //#region src/api/media/types/common.d.ts
1268
974
  type MediaResponse = {
1269
975
  id: string;
@@ -1286,319 +992,867 @@ type UploadMediaResponse = {
1286
992
  id: string;
1287
993
  };
1288
994
  interface MediaClass {
1289
- getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
995
+ getMediaById(mediaId: string): Promise<MediaResponse>;
1290
996
  uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
1291
- deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
997
+ deleteMedia(mediaId: string): Promise<ResponseSuccess>;
1292
998
  downloadMedia(mediaUrl: string): Promise<Blob>;
1293
999
  }
1294
1000
  //#endregion
1295
- //#region src/core/webhook/types/common.d.ts
1296
- /**
1297
- * WhatsApp contact information
1298
- */
1299
- interface WebhookContact {
1300
- wa_id: string;
1301
- profile: {
1302
- name: string;
1303
- };
1304
- identity_key_hash?: string;
1305
- }
1306
- /**
1307
- * Metadata included in all webhooks
1308
- */
1309
- interface WebhookMetadata {
1310
- display_phone_number: string;
1311
- phone_number_id: string;
1312
- }
1313
- /**
1314
- * Error object structure
1315
- */
1316
- interface WebhookError {
1317
- code: number;
1318
- title: string;
1319
- message: string;
1320
- error_data?: {
1321
- details: string;
1322
- };
1323
- href?: string;
1324
- }
1325
- /**
1326
- * Click to WhatsApp ad referral information
1327
- */
1328
- interface ReferralInfo {
1329
- source_url: string;
1330
- source_id: string;
1331
- source_type: 'ad';
1332
- body?: string;
1333
- headline?: string;
1334
- media_type?: 'image' | 'video';
1335
- image_url?: string;
1336
- video_url?: string;
1337
- thumbnail_url?: string;
1338
- ctwa_clid?: string;
1339
- welcome_message?: {
1340
- text: string;
1341
- };
1342
- }
1001
+ //#region src/api/payments/types/payments.d.ts
1343
1002
  /**
1344
- * Context for forwarded messages
1003
+ * Payments API Types (India Payment Configuration)
1004
+ * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
1345
1005
  */
1346
- interface ForwardedContext {
1347
- forwarded?: true;
1348
- frequently_forwarded?: true;
1006
+ type PaymentConfigurationProvider = 'upi_vpa' | 'razorpay' | 'payu' | 'zaakpay';
1007
+ type PaymentConfigurationStatus = 'Active' | 'Needs_Connecting' | 'Needs_Testing';
1008
+ type PaymentConfigurationCode = {
1009
+ code: string;
1010
+ description?: string;
1011
+ };
1012
+ type PaymentConfiguration = {
1013
+ configuration_name: string;
1014
+ provider_name: string;
1015
+ provider_mid?: string;
1016
+ status?: PaymentConfigurationStatus;
1017
+ merchant_category_code?: PaymentConfigurationCode;
1018
+ purpose_code?: PaymentConfigurationCode;
1019
+ created_timestamp?: number;
1020
+ updated_timestamp?: number;
1021
+ };
1022
+ type PaymentConfigurationsResponse = {
1023
+ data: Array<{
1024
+ payment_configurations: PaymentConfiguration[];
1025
+ }>;
1026
+ };
1027
+ type PaymentConfigurationCreateRequest = {
1028
+ configuration_name: string;
1029
+ provider_name: PaymentConfigurationProvider;
1030
+ purpose_code?: string;
1031
+ merchant_category_code?: string;
1032
+ redirect_url?: string;
1033
+ merchant_vpa?: string;
1034
+ };
1035
+ type PaymentConfigurationUpdateRequest = {
1036
+ provider_name?: PaymentConfigurationProvider;
1037
+ purpose_code?: string;
1038
+ merchant_category_code?: string;
1039
+ redirect_url?: string;
1040
+ merchant_vpa?: string;
1041
+ };
1042
+ type PaymentConfigurationCreateResponse = {
1043
+ success: boolean;
1044
+ oauth_url?: string;
1045
+ expiration?: number;
1046
+ };
1047
+ type PaymentConfigurationUpdateResponse = PaymentConfigurationCreateResponse;
1048
+ type PaymentConfigurationOauthLinkRequest = {
1049
+ configuration_name: string;
1050
+ redirect_url?: string;
1051
+ };
1052
+ type PaymentConfigurationOauthLinkResponse = {
1053
+ oauth_url: string;
1054
+ expiration?: number;
1055
+ };
1056
+ type PaymentConfigurationDeleteRequest = {
1057
+ configuration_name: string;
1058
+ };
1059
+ interface PaymentsClass {
1060
+ listPaymentConfigurations(wabaId: string): Promise<PaymentConfigurationsResponse>;
1061
+ getPaymentConfiguration(wabaId: string, configurationName: string): Promise<PaymentConfigurationsResponse>;
1062
+ createPaymentConfiguration(wabaId: string, params: PaymentConfigurationCreateRequest): Promise<PaymentConfigurationCreateResponse>;
1063
+ updatePaymentConfiguration(wabaId: string, configurationName: string, params: PaymentConfigurationUpdateRequest): Promise<PaymentConfigurationUpdateResponse>;
1064
+ generatePaymentConfigurationOauthLink(wabaId: string, params: PaymentConfigurationOauthLinkRequest): Promise<PaymentConfigurationOauthLinkResponse>;
1065
+ deletePaymentConfiguration(wabaId: string, params: PaymentConfigurationDeleteRequest): Promise<ResponseSuccess>;
1349
1066
  }
1350
- /**
1351
- * Context for product inquiry messages
1352
- */
1353
- interface ProductContext {
1354
- from: string;
1067
+ //#endregion
1068
+ //#region src/api/phone/types/common.d.ts
1069
+ type QualityRating = 'GREEN' | 'YELLOW' | 'RED' | 'NA';
1070
+ type AccountMode = 'LIVE' | 'SANDBOX';
1071
+ type CodeVerificationStatus = 'NOT_VERIFIED' | 'VERIFIED' | 'EXPIRED' | 'PENDING' | 'DELETED' | 'MIGRATED' | 'BANNED' | 'RESTRICTED' | 'RATE_LIMITED' | 'FLAGGED' | 'CONNECTED' | 'DISCONNECTED' | 'UNKNOWN' | 'UNVERIFIED';
1072
+ type MessagingLimitTier = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED';
1073
+ type PlatformType = 'CLOUD_API' | 'ON_PREMISE' | 'NOT_APPLICABLE';
1074
+ type ThroughputLevel = 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE';
1075
+ type HealthStatusEntity = {
1076
+ entity_type: string;
1355
1077
  id: string;
1356
- referred_product: {
1357
- catalog_id: string;
1358
- product_retailer_id: string;
1359
- };
1360
- }
1078
+ can_send_message: string;
1079
+ additional_info?: string[];
1080
+ errors?: Array<{
1081
+ error_code: number;
1082
+ error_description: string;
1083
+ possible_solution: string;
1084
+ }>;
1085
+ };
1086
+ type HealthStatus = {
1087
+ can_send_message: string;
1088
+ entities: HealthStatusEntity[];
1089
+ };
1090
+ type QualityScore = {
1091
+ score: QualityRating;
1092
+ };
1093
+ type Throughput = {
1094
+ level: ThroughputLevel;
1095
+ };
1096
+ type PhoneNumberField = 'display_phone_number' | 'id' | 'quality_rating' | 'verified_name' | 'account_mode' | 'certificate' | 'code_verification_status' | 'conversational_automation' | 'eligibility_for_api_business_global_search' | 'health_status' | 'is_official_business_account' | 'is_on_biz_app' | 'is_pin_enabled' | 'is_preverified_number' | 'last_onboarded_time' | 'messaging_limit_tier' | 'name_status' | 'new_certificate' | 'new_name_status' | 'platform_type' | 'quality_score' | 'search_visibility' | 'status' | 'throughput';
1097
+ type PhoneNumberFieldsParam = PhoneNumberField[] | string;
1098
+ type PhoneNumberResponse = {
1099
+ display_phone_number: string;
1100
+ id: string;
1101
+ quality_rating: QualityRating;
1102
+ verified_name: string;
1103
+ account_mode?: AccountMode;
1104
+ certificate?: string;
1105
+ code_verification_status?: CodeVerificationStatus;
1106
+ conversational_automation?: Record<string, unknown>;
1107
+ eligibility_for_api_business_global_search?: string;
1108
+ health_status?: HealthStatus;
1109
+ is_official_business_account?: boolean;
1110
+ is_on_biz_app?: boolean;
1111
+ is_pin_enabled?: boolean;
1112
+ is_preverified_number?: boolean;
1113
+ last_onboarded_time?: string;
1114
+ messaging_limit_tier?: MessagingLimitTier;
1115
+ name_status?: string;
1116
+ new_certificate?: string;
1117
+ new_name_status?: string;
1118
+ platform_type?: PlatformType;
1119
+ quality_score?: QualityScore;
1120
+ search_visibility?: string;
1121
+ status?: CodeVerificationStatus;
1122
+ throughput?: Throughput;
1123
+ };
1124
+ type Cursors = {
1125
+ before: string;
1126
+ after: string;
1127
+ };
1128
+ type PhoneNumbersResponse = {
1129
+ data: PhoneNumberResponse[];
1130
+ paging: Paging;
1131
+ };
1132
+ type RequestVerificationCodeRequest = {
1133
+ code_method: 'SMS' | 'VOICE';
1134
+ language: string;
1135
+ };
1136
+ type VerifyCodeRequest = {
1137
+ code: string;
1138
+ };
1139
+ type TwoStepVerificationParams = {
1140
+ pin: string;
1141
+ };
1361
1142
  /**
1362
- * Context for interactive/button replies
1143
+ * Conversational Components - Commands
1363
1144
  */
1364
- interface ReplyContext {
1365
- from: string;
1145
+ type ConversationalCommand = {
1146
+ command_name: string;
1147
+ command_description: string;
1148
+ };
1149
+ /**
1150
+ * Conversational Components - Ice Breakers (Prompts)
1151
+ */
1152
+ type ConversationalPrompt = string;
1153
+ /**
1154
+ * Request payload for configuring conversational automation
1155
+ */
1156
+ type ConversationalAutomationRequest = {
1157
+ enable_welcome_message?: boolean;
1158
+ commands?: ConversationalCommand[];
1159
+ prompts?: ConversationalPrompt[];
1160
+ };
1161
+ /**
1162
+ * Response from conversational automation GET endpoint
1163
+ */
1164
+ type ConversationalAutomationResponse = {
1165
+ enable_welcome_message?: boolean;
1166
+ commands?: ConversationalCommand[];
1167
+ prompts?: ConversationalPrompt[];
1366
1168
  id: string;
1169
+ };
1170
+ /**
1171
+ * Response from throughput GET endpoint
1172
+ */
1173
+ type ThroughputResponse = {
1174
+ throughput: Throughput;
1175
+ id: string;
1176
+ };
1177
+ interface PhoneNumberClass {
1178
+ getPhoneNumberById(fields?: PhoneNumberFieldsParam): Promise<PhoneNumberResponse>;
1179
+ getPhoneNumbers(): Promise<PhoneNumbersResponse>;
1180
+ requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
1181
+ verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>;
1182
+ setConversationalAutomation(params: ConversationalAutomationRequest): Promise<ResponseSuccess>;
1183
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
1184
+ getThroughput(): Promise<ThroughputResponse>;
1367
1185
  }
1368
1186
  //#endregion
1369
- //#region src/core/webhook/types/message.d.ts
1187
+ //#region src/api/profile/types/upload.d.ts
1370
1188
  /**
1371
- * Base message properties common to all message types
1189
+ * Response from creating an upload session.
1372
1190
  */
1373
- interface BaseMessage {
1374
- from: string;
1191
+ interface UploadSessionResponse {
1375
1192
  id: string;
1376
- timestamp: string;
1377
- }
1378
- interface TextMessage extends BaseMessage {
1379
- type: MessageTypesEnum.Text;
1380
- text: {
1381
- body: string;
1382
- };
1383
- context?: ForwardedContext | ProductContext;
1384
- referral?: ReferralInfo;
1385
1193
  }
1386
- interface ImageMessage extends BaseMessage {
1387
- type: MessageTypesEnum.Image;
1388
- image: {
1389
- caption?: string;
1390
- mime_type: string;
1391
- sha256: string;
1392
- id: string;
1393
- url: string;
1394
- };
1395
- context?: ForwardedContext;
1396
- referral?: ReferralInfo;
1397
- }
1398
- interface VideoMessage extends BaseMessage {
1399
- type: MessageTypesEnum.Video;
1400
- video: {
1401
- caption?: string;
1402
- mime_type: string;
1403
- sha256: string;
1404
- id: string;
1405
- url: string;
1406
- };
1407
- context?: ForwardedContext;
1408
- referral?: ReferralInfo;
1194
+ /**
1195
+ * Response from uploading business profile media.
1196
+ */
1197
+ interface UploadBusinessProfileResponse {
1198
+ h: string;
1409
1199
  }
1410
- interface AudioMessage extends BaseMessage {
1411
- type: MessageTypesEnum.Audio;
1412
- audio: {
1413
- mime_type: string;
1414
- sha256: string;
1415
- id: string;
1416
- url: string;
1417
- voice: boolean;
1200
+ /**
1201
+ * Upload handle information containing file details and handle.
1202
+ */
1203
+ interface UploadHandle {
1204
+ handle: string;
1205
+ file_size: number;
1206
+ upload_result: {
1207
+ handle_type: string;
1208
+ name: string;
1418
1209
  };
1419
- referral?: ReferralInfo;
1420
1210
  }
1421
- interface DocumentMessage extends BaseMessage {
1422
- type: MessageTypesEnum.Document;
1423
- document: {
1424
- caption?: string;
1425
- filename: string;
1426
- mime_type: string;
1427
- sha256: string;
1428
- id: string;
1429
- url: string;
1430
- };
1431
- referral?: ReferralInfo;
1211
+ //#endregion
1212
+ //#region src/api/profile/types/common.d.ts
1213
+ /**
1214
+ * Available fields that can be requested when retrieving a business profile.
1215
+ */
1216
+ type BusinessProfileField = 'about' | 'address' | 'description' | 'email' | 'messaging_product' | 'profile_picture_url' | 'websites' | 'vertical';
1217
+ type BusinessProfileFieldsParam = BusinessProfileField[] | string;
1218
+ /**
1219
+ * Business profile data structure containing all profile information.
1220
+ */
1221
+ interface BusinessProfileData {
1222
+ /**
1223
+ * The business's About text. This text appears in the business's profile, beneath its profile image,
1224
+ * phone number, and contact buttons.
1225
+ * - String cannot be empty
1226
+ * - Strings must be between 1 and 139 characters
1227
+ * - Rendered emojis are supported however their unicode values are not.
1228
+ * Emoji unicode values must be Java- or JavaScript-escape encoded
1229
+ * - Hyperlinks can be included but will not render as clickable links
1230
+ * - Markdown is not supported
1231
+ */
1232
+ about?: string;
1233
+ /**
1234
+ * Address of the business. Character limit 256.
1235
+ */
1236
+ address?: string;
1237
+ /**
1238
+ * Description of the business. Character limit 512.
1239
+ */
1240
+ description?: string;
1241
+ /**
1242
+ * The contact email address (in valid email format) of the business. Character limit 128.
1243
+ */
1244
+ email?: string;
1245
+ /**
1246
+ * The messaging service used for the request. Always set it to "whatsapp" if you are using
1247
+ * the WhatsApp Business API.
1248
+ */
1249
+ messaging_product: string;
1250
+ /**
1251
+ * Profile picture URL.
1252
+ */
1253
+ profile_picture_url?: string;
1254
+ /**
1255
+ * The URLs associated with the business. For instance, a website, Facebook Page, or Instagram.
1256
+ * - You must include the http:// or https:// portion of the URL
1257
+ * - There is a maximum of 2 websites with a maximum of 256 characters each
1258
+ */
1259
+ websites?: string[];
1260
+ /**
1261
+ * Business category. This can be either an empty string or one of the predefined business categories.
1262
+ * @see BusinessVerticalEnum for all available options
1263
+ */
1264
+ vertical?: BusinessVerticalEnum | string;
1432
1265
  }
1433
- interface StickerMessage extends BaseMessage {
1434
- type: MessageTypesEnum.Sticker;
1435
- sticker: {
1436
- mime_type: string;
1437
- sha256: string;
1438
- id: string;
1439
- url: string;
1440
- animated: boolean;
1441
- };
1442
- referral?: ReferralInfo;
1266
+ /**
1267
+ * Response structure for business profile GET requests.
1268
+ */
1269
+ interface BusinessProfileResponse {
1270
+ data: BusinessProfileData[];
1443
1271
  }
1444
- interface InteractiveListReplyMessage extends BaseMessage {
1445
- type: MessageTypesEnum.Interactive;
1446
- context: ReplyContext;
1447
- interactive: {
1448
- type: 'list_reply';
1449
- list_reply: {
1450
- id: string;
1451
- title: string;
1452
- description?: string;
1453
- };
1272
+ /**
1273
+ * Request structure for updating business profile.
1274
+ */
1275
+ interface UpdateBusinessProfileRequest {
1276
+ /**
1277
+ * The messaging service used for the request. Always set it to "whatsapp" if you are using
1278
+ * the WhatsApp Business API.
1279
+ * @required
1280
+ */
1281
+ messaging_product: string;
1282
+ /**
1283
+ * The business's About text. This text appears in the business's profile, beneath its profile image,
1284
+ * phone number, and contact buttons.
1285
+ * - String cannot be empty
1286
+ * - Strings must be between 1 and 139 characters
1287
+ * - Rendered emojis are supported however their unicode values are not.
1288
+ * Emoji unicode values must be Java- or JavaScript-escape encoded
1289
+ * - Hyperlinks can be included but will not render as clickable links
1290
+ * - Markdown is not supported
1291
+ */
1292
+ about?: string;
1293
+ /**
1294
+ * Address of the business. Character limit 256.
1295
+ */
1296
+ address?: string;
1297
+ /**
1298
+ * Description of the business. Character limit 512.
1299
+ */
1300
+ description?: string;
1301
+ /**
1302
+ * Business category. This can be either an empty string or one of the predefined business categories.
1303
+ * @see BusinessVerticalEnum for all available options
1304
+ */
1305
+ vertical?: BusinessVerticalEnum | string;
1306
+ /**
1307
+ * The contact email address (in valid email format) of the business. Character limit 128.
1308
+ */
1309
+ email?: string;
1310
+ /**
1311
+ * The URLs associated with the business. For instance, a website, Facebook Page, or Instagram.
1312
+ * - You must include the http:// or https:// portion of the URL
1313
+ * - There is a maximum of 2 websites with a maximum of 256 characters each
1314
+ */
1315
+ websites?: string[];
1316
+ /**
1317
+ * Handle of the profile picture. This handle is generated when you upload the binary file
1318
+ * for the profile picture to Meta using the Resumable Upload API.
1319
+ */
1320
+ profile_picture_handle?: string;
1321
+ }
1322
+ declare class BusinessProfileClass extends BaseClass {
1323
+ /**
1324
+ * Get your business profile.
1325
+ * @param fields Specific fields to be returned in the response. If not specified, all fields will be returned.
1326
+ */
1327
+ getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
1328
+ /**
1329
+ * Update your business profile.
1330
+ * @param updateRequest The request object containing the fields to update.
1331
+ */
1332
+ updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
1333
+ /**
1334
+ * Create an upload session for profile picture.
1335
+ * @param fileLength Length of the file to be uploaded in bytes.
1336
+ * @param fileType MIME type of the file (e.g., 'image/jpeg').
1337
+ * @param fileName Name of the file.
1338
+ */
1339
+ createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
1340
+ /**
1341
+ * Upload media file to the upload session.
1342
+ * @param uploadId The ID of the upload session.
1343
+ * @param file The binary data of the file.
1344
+ */
1345
+ uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
1346
+ /**
1347
+ * Get the upload handle information.
1348
+ * @param uploadId The ID of the upload session.
1349
+ */
1350
+ getUploadHandle(uploadId: string): Promise<UploadHandle>;
1351
+ }
1352
+ //#endregion
1353
+ //#region src/api/qrCode/types/common.d.ts
1354
+ type QrCodeResponse = {
1355
+ code: string;
1356
+ prefilled_message: string;
1357
+ deep_link_url: string;
1358
+ qr_image_url?: string;
1359
+ };
1360
+ type QrCodesResponse = ResponseData<QrCodeResponse[]>;
1361
+ type CreateQrCodeRequest = {
1362
+ prefilled_message: string;
1363
+ generate_qr_image?: 'SVG' | 'PNG';
1364
+ };
1365
+ type UpdateQrCodeRequest = {
1366
+ code: string;
1367
+ prefilled_message: string;
1368
+ };
1369
+ interface QrCodeClass {
1370
+ createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
1371
+ getQrCodes(): Promise<QrCodesResponse>;
1372
+ getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
1373
+ updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
1374
+ deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
1375
+ }
1376
+ //#endregion
1377
+ //#region src/api/registration/types/common.d.ts
1378
+ type RegistrationRequest = {
1379
+ messaging_product: 'whatsapp';
1380
+ pin: string;
1381
+ data_localization_region?: DataLocalizationRegionEnum;
1382
+ };
1383
+ interface RegistrationClass {
1384
+ register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
1385
+ deregister(): Promise<ResponseSuccess>;
1386
+ }
1387
+ //#endregion
1388
+ //#region src/api/template/types/common.d.ts
1389
+ type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION' | 'PRODUCT';
1390
+ type PhoneNumberButton = {
1391
+ type: 'PHONE_NUMBER';
1392
+ text: string;
1393
+ phone_number: string;
1394
+ };
1395
+ type URLButton = {
1396
+ type: 'URL';
1397
+ text: string;
1398
+ url: string;
1399
+ example?: string[];
1400
+ };
1401
+ type QuickReplyButton = {
1402
+ type: 'QUICK_REPLY';
1403
+ text: string;
1404
+ };
1405
+ type CopyCodeButton = {
1406
+ type: 'COPY_CODE';
1407
+ example: string;
1408
+ };
1409
+ type FlowButton = {
1410
+ type: 'FLOW';
1411
+ text: string;
1412
+ flow_id?: string;
1413
+ flow_name?: string;
1414
+ flow_json?: string;
1415
+ flow_action?: 'navigate' | 'data_exchange';
1416
+ navigate_screen?: string;
1417
+ };
1418
+ type MPMButton = {
1419
+ type: 'MPM';
1420
+ action?: {
1421
+ thumbnail_product_retailer_id: string;
1422
+ sections: Array<{
1423
+ title?: string;
1424
+ product_items: Array<{
1425
+ product_retailer_id: string;
1426
+ }>;
1427
+ }>;
1428
+ };
1429
+ };
1430
+ type OTPButton = {
1431
+ type: 'OTP';
1432
+ };
1433
+ type SPMButton = {
1434
+ type: 'SPM';
1435
+ action?: {
1436
+ product_retailer_id: string;
1437
+ };
1438
+ };
1439
+ type CatalogButton = {
1440
+ type: 'CATALOG';
1441
+ action?: {
1442
+ thumbnail_product_retailer_id: string;
1443
+ };
1444
+ };
1445
+ type TemplateButton = PhoneNumberButton | URLButton | QuickReplyButton | CopyCodeButton | FlowButton | MPMButton | OTPButton | SPMButton | CatalogButton;
1446
+ type TemplateHeaderExample = {
1447
+ header_text?: string[];
1448
+ header_text_named_params?: Array<{
1449
+ param_name: string;
1450
+ example: string;
1451
+ }>;
1452
+ header_handle?: string[];
1453
+ };
1454
+ type TemplateHeader = {
1455
+ type: 'HEADER';
1456
+ format: TemplateFormat;
1457
+ text?: string;
1458
+ example?: TemplateHeaderExample;
1459
+ };
1460
+ type TemplateBody = {
1461
+ type: 'BODY';
1462
+ text: string;
1463
+ example?: {
1464
+ body_text?: Array<Array<string>>;
1465
+ body_text_named_params?: Array<{
1466
+ param_name: string;
1467
+ example: string;
1468
+ }>;
1454
1469
  };
1470
+ };
1471
+ type TemplateFooter = {
1472
+ type: 'FOOTER';
1473
+ text: string;
1474
+ };
1475
+ type TemplateButtons = {
1476
+ type: 'BUTTONS';
1477
+ buttons: TemplateButton[];
1478
+ };
1479
+ type TemplateLimitedTimeOffer = {
1480
+ type: 'LIMITED_TIME_OFFER';
1481
+ limited_time_offer: {
1482
+ expiration_time_ms: number;
1483
+ };
1484
+ };
1485
+ type TemplateCarousel = {
1486
+ type: 'CAROUSEL';
1487
+ cards: Array<{
1488
+ card_index: number;
1489
+ components: ComponentTypes[];
1490
+ }>;
1491
+ };
1492
+ type MediaCarouselCard = {
1493
+ card_index: number;
1494
+ components: (TemplateHeader | TemplateBody | TemplateButtons)[];
1495
+ };
1496
+ type ProductCarouselCard = {
1497
+ card_index: number;
1498
+ components: TemplateHeader[];
1499
+ };
1500
+ type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButtons | TemplateLimitedTimeOffer | TemplateCarousel;
1501
+ type TemplateRequestBody = GeneralRequestBody & {
1502
+ name: string;
1503
+ language: LanguagesEnum;
1504
+ category?: CategoryEnum;
1505
+ components?: ComponentTypes[];
1506
+ };
1507
+ type TemplateResponse = {
1508
+ id: string;
1509
+ status: string;
1510
+ language: LanguagesEnum;
1511
+ category: CategoryEnum;
1512
+ name: string;
1513
+ components: ComponentTypes[];
1514
+ };
1515
+ type TemplateGetParams = {
1516
+ limit?: number;
1517
+ name?: string;
1518
+ language?: LanguagesEnum;
1519
+ category?: CategoryEnum;
1520
+ status?: TemplateStatusEnum;
1521
+ };
1522
+ type TemplateDeleteParams = {
1523
+ hsm_id: string;
1524
+ name: string;
1525
+ };
1526
+ declare class TemplateClass {
1527
+ getTemplate(templateId: string): Promise<TemplateResponse>;
1528
+ updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
1529
+ getTemplates(params?: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
1530
+ createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
1531
+ deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
1455
1532
  }
1456
- interface InteractiveButtonReplyMessage extends BaseMessage {
1457
- type: MessageTypesEnum.Interactive;
1458
- context: ReplyContext;
1459
- interactive: {
1460
- type: 'button_reply';
1461
- button_reply: {
1462
- id: string;
1463
- title: string;
1464
- };
1533
+ //#endregion
1534
+ //#region src/api/template/types/factory.d.ts
1535
+ interface TextParameter {
1536
+ type: 'text';
1537
+ value: string;
1538
+ }
1539
+ interface CurrencyParameter {
1540
+ type: 'currency';
1541
+ amount_1000: number;
1542
+ code: CurrencyCodesEnum;
1543
+ fallback_value: string;
1544
+ }
1545
+ interface DateTimeParameter {
1546
+ type: 'date_time';
1547
+ fallback_value: string;
1548
+ }
1549
+ interface MediaParameter {
1550
+ type: 'image' | 'video' | 'document';
1551
+ handle?: string;
1552
+ link?: string;
1553
+ }
1554
+ interface LocationParameter {
1555
+ type: 'location';
1556
+ latitude?: number;
1557
+ longitude?: number;
1558
+ name?: string;
1559
+ address?: string;
1560
+ }
1561
+ interface ProductParameter {
1562
+ type: 'product';
1563
+ product_retailer_id: string;
1564
+ }
1565
+ type TemplateParameter = TextParameter | CurrencyParameter | DateTimeParameter | MediaParameter | LocationParameter | ProductParameter;
1566
+ interface HeaderOptions {
1567
+ format: TemplateFormat;
1568
+ text?: string;
1569
+ parameters?: TemplateParameter[];
1570
+ example?: {
1571
+ header_text?: string[];
1572
+ header_text_named_params?: Array<{
1573
+ param_name: string;
1574
+ example: string;
1575
+ }>;
1576
+ header_handle?: string[];
1465
1577
  };
1466
1578
  }
1467
- interface InteractiveNfmReplyMessage extends BaseMessage {
1468
- type: MessageTypesEnum.Interactive;
1469
- context: ReplyContext;
1470
- interactive: {
1471
- type: 'nfm_reply';
1472
- nfm_reply: {
1473
- name: string;
1474
- body: string;
1475
- response_json: string;
1476
- };
1579
+ interface BodyOptions {
1580
+ text: string;
1581
+ parameters?: TemplateParameter[];
1582
+ example?: {
1583
+ body_text?: string[][];
1584
+ body_text_named_params?: Array<{
1585
+ param_name: string;
1586
+ example: string;
1587
+ }>;
1477
1588
  };
1478
1589
  }
1479
- type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage | InteractiveNfmReplyMessage;
1480
- interface ButtonMessage extends BaseMessage {
1481
- type: MessageTypesEnum.Button;
1482
- context: ReplyContext;
1483
- button: {
1484
- payload: string;
1590
+ interface FooterOptions {
1591
+ text: string;
1592
+ }
1593
+ interface ButtonOptions {
1594
+ phone_number?: {
1485
1595
  text: string;
1596
+ phone_number: string;
1486
1597
  };
1487
- }
1488
- interface LocationMessage extends BaseMessage {
1489
- type: MessageTypesEnum.Location;
1490
- location: {
1491
- latitude: number;
1492
- longitude: number;
1493
- name?: string;
1494
- address?: string;
1495
- url?: string;
1598
+ url?: {
1599
+ text: string;
1600
+ url: string;
1601
+ example?: string;
1496
1602
  };
1497
- referral?: ReferralInfo;
1603
+ quick_reply?: {
1604
+ text: string;
1605
+ }[];
1606
+ copy_code?: {
1607
+ example: string;
1608
+ };
1609
+ flow?: {
1610
+ text: string;
1611
+ flow_id?: string;
1612
+ flow_name?: string;
1613
+ flow_json?: string;
1614
+ flow_action?: 'navigate' | 'data_exchange';
1615
+ navigate_screen?: string;
1616
+ };
1617
+ mpm?: boolean;
1618
+ otp?: boolean;
1619
+ spm?: boolean;
1498
1620
  }
1499
- interface ContactsMessage extends BaseMessage {
1500
- type: MessageTypesEnum.Contacts;
1501
- contacts: Array<{
1502
- addresses?: Array<{
1503
- city?: string;
1504
- country?: string;
1505
- country_code?: string;
1506
- state?: string;
1507
- street?: string;
1508
- type?: string;
1509
- zip?: string;
1510
- }>;
1511
- birthday?: string;
1512
- emails?: Array<{
1513
- email: string;
1514
- type?: string;
1515
- }>;
1516
- name: {
1517
- formatted_name: string;
1518
- first_name?: string;
1519
- last_name?: string;
1520
- middle_name?: string;
1521
- suffix?: string;
1522
- prefix?: string;
1523
- };
1524
- org?: {
1525
- company?: string;
1526
- department?: string;
1527
- title?: string;
1621
+ interface CarouselCard {
1622
+ image?: string;
1623
+ video?: string;
1624
+ product?: string;
1625
+ body?: string;
1626
+ bodyParameters?: TemplateParameter[];
1627
+ buttons?: ButtonOptions;
1628
+ }
1629
+ interface CarouselOptions {
1630
+ cards: CarouselCard[];
1631
+ }
1632
+ interface LimitedTimeOfferOptions {
1633
+ expiration_time_ms: number;
1634
+ }
1635
+ interface ProductSection {
1636
+ title?: string;
1637
+ product_items: Array<{
1638
+ product_retailer_id: string;
1639
+ }>;
1640
+ }
1641
+ interface TemplateOptions {
1642
+ name: string;
1643
+ language: LanguagesEnum;
1644
+ category: CategoryEnum;
1645
+ header?: HeaderOptions;
1646
+ body?: BodyOptions;
1647
+ footer?: FooterOptions;
1648
+ buttons?: ButtonOptions;
1649
+ carousel?: CarouselOptions;
1650
+ limitedTimeOffer?: LimitedTimeOfferOptions;
1651
+ }
1652
+ interface OTPTemplateOptions {
1653
+ name: string;
1654
+ language: LanguagesEnum;
1655
+ code_expiration_minutes?: number;
1656
+ add_security_recommendation?: boolean;
1657
+ }
1658
+ interface AuthenticationTemplateOptions {
1659
+ name: string;
1660
+ language: LanguagesEnum;
1661
+ code_expiration_minutes?: number;
1662
+ add_security_recommendation?: boolean;
1663
+ copy_code_button?: boolean;
1664
+ }
1665
+ interface CatalogTemplateOptions {
1666
+ name: string;
1667
+ language: LanguagesEnum;
1668
+ header?: Omit<HeaderOptions, 'format'>;
1669
+ body: BodyOptions;
1670
+ footer?: FooterOptions;
1671
+ thumbnail_product_retailer_id: string;
1672
+ }
1673
+ interface CouponTemplateOptions {
1674
+ name: string;
1675
+ language: LanguagesEnum;
1676
+ header?: Omit<HeaderOptions, 'format'>;
1677
+ body: BodyOptions;
1678
+ footer?: FooterOptions;
1679
+ coupon_code: string;
1680
+ }
1681
+ interface LimitedTimeOfferTemplateOptions {
1682
+ name: string;
1683
+ language: LanguagesEnum;
1684
+ header?: Omit<HeaderOptions, 'format'>;
1685
+ body: BodyOptions;
1686
+ footer?: FooterOptions;
1687
+ expiration_time_ms: number;
1688
+ }
1689
+ interface MediaCardCarouselTemplateOptions {
1690
+ name: string;
1691
+ language: LanguagesEnum;
1692
+ cards: Array<{
1693
+ header: {
1694
+ format: 'IMAGE' | 'VIDEO';
1695
+ example: {
1696
+ header_handle: string[];
1697
+ };
1528
1698
  };
1529
- phones?: Array<{
1530
- phone: string;
1531
- wa_id?: string;
1532
- type?: string;
1533
- }>;
1534
- urls?: Array<{
1535
- url: string;
1536
- type?: string;
1537
- }>;
1699
+ body: BodyOptions;
1700
+ buttons?: ButtonOptions;
1538
1701
  }>;
1539
- referral?: ReferralInfo;
1540
1702
  }
1541
- interface ReactionMessage extends BaseMessage {
1542
- type: MessageTypesEnum.Reaction;
1543
- reaction: {
1544
- message_id: string;
1545
- emoji?: string;
1546
- };
1703
+ interface MPMTemplateOptions {
1704
+ name: string;
1705
+ language: LanguagesEnum;
1706
+ header?: Omit<HeaderOptions, 'format'>;
1707
+ body: BodyOptions;
1708
+ footer?: FooterOptions;
1709
+ thumbnail_product_retailer_id: string;
1710
+ sections: ProductSection[];
1711
+ }
1712
+ interface ProductCardCarouselTemplateOptions {
1713
+ name: string;
1714
+ language: LanguagesEnum;
1715
+ header?: Omit<HeaderOptions, 'format'>;
1716
+ body: BodyOptions;
1717
+ footer?: FooterOptions;
1718
+ cards: Array<{
1719
+ product_retailer_id: string;
1720
+ }>;
1721
+ }
1722
+ interface SPMTemplateOptions {
1723
+ name: string;
1724
+ language: LanguagesEnum;
1725
+ header?: Omit<HeaderOptions, 'format'>;
1726
+ body: BodyOptions;
1727
+ footer?: FooterOptions;
1728
+ product_retailer_id: string;
1729
+ }
1730
+ //#endregion
1731
+ //#region src/api/twoStepVerification/types/common.d.ts
1732
+ type TwoStepVerificationRequest = {
1733
+ pin: string;
1734
+ };
1735
+ interface TwoStepVerificationClass {
1736
+ setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
1737
+ }
1738
+ //#endregion
1739
+ //#region src/api/waba/types/common.d.ts
1740
+ /**
1741
+ * WhatsApp Business Account subscription configuration
1742
+ */
1743
+ type WabaSubscription = {
1744
+ whatsapp_business_api_data: {
1745
+ id: string;
1746
+ link: string;
1747
+ name: string;
1748
+ category: string;
1749
+ };
1750
+ override_callback_uri?: string;
1751
+ };
1752
+ /**
1753
+ * Parameters for updating WABA subscription
1754
+ */
1755
+ interface UpdateWabaSubscription {
1756
+ override_callback_uri: string;
1757
+ verify_token: string;
1758
+ }
1759
+ /**
1760
+ * Response containing all WABA subscriptions
1761
+ */
1762
+ interface WabaSubscriptions {
1763
+ data: Array<WabaSubscription>;
1764
+ }
1765
+ /**
1766
+ * WABA account review status enumeration
1767
+ */
1768
+ declare enum WabaAccountReviewStatus {
1769
+ Approved = "APPROVED",
1770
+ Active = "ACTIVE",
1771
+ Inactive = "INACTIVE",
1772
+ Disabled = "DISABLED",
1773
+ }
1774
+ /**
1775
+ * WABA health status for message sending capability
1776
+ */
1777
+ declare enum WabaHealthStatusCanSendMessage {
1778
+ Blocked = "BLOCKED",
1779
+ Limited = "LIMITED",
1780
+ Available = "AVAILABLE",
1781
+ }
1782
+ /**
1783
+ * WABA account status enumeration
1784
+ */
1785
+ declare enum WabaAccountStatus {
1786
+ Approved = "APPROVED",
1787
+ Active = "ACTIVE",
1788
+ Inactive = "INACTIVE",
1789
+ Disabled = "DISABLED",
1790
+ }
1791
+ /**
1792
+ * Business verification status enumeration
1793
+ */
1794
+ declare enum WabaBusinessVerificationStatus {
1795
+ Verified = "verified",
1796
+ PendingSubmission = "pending_submission",
1797
+ Unverified = "unverified",
1798
+ Rejected = "rejected",
1547
1799
  }
1548
- interface OrderMessage extends BaseMessage {
1549
- type: MessageTypesEnum.Order;
1550
- order: {
1551
- catalog_id: string;
1552
- text?: string;
1553
- product_items: Array<{
1554
- product_retailer_id: string;
1555
- quantity: number;
1556
- item_price: number;
1557
- currency: string;
1558
- }>;
1559
- };
1800
+ /**
1801
+ * WABA health status error details
1802
+ */
1803
+ interface WabaHealthStatusError {
1804
+ error_code?: number;
1805
+ error_description?: string;
1806
+ possible_solution?: string;
1560
1807
  }
1561
- interface SystemMessage extends BaseMessage {
1562
- type: MessageTypesEnum.System;
1563
- system: {
1564
- body: string;
1565
- wa_id: string;
1566
- type: 'user_changed_number';
1567
- };
1808
+ /**
1809
+ * WABA health status entity information
1810
+ */
1811
+ interface WabaHealthStatusEntity {
1812
+ entity_type?: string;
1813
+ id?: string;
1814
+ can_send_message?: string;
1815
+ errors?: WabaHealthStatusError[];
1568
1816
  }
1569
- interface UnsupportedMessage extends BaseMessage {
1570
- type: MessageTypesEnum.Unsupported;
1571
- errors: Array<WebhookError>;
1817
+ /**
1818
+ * Overall WABA health status
1819
+ */
1820
+ interface WabaHealthStatus {
1821
+ can_send_message?: WabaHealthStatusCanSendMessage;
1822
+ entities?: WabaHealthStatusEntity[];
1572
1823
  }
1573
- type GroupMessage = {
1574
- group_id: string;
1575
- } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
1576
- type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1577
- //#endregion
1578
- //#region src/core/webhook/types/status.d.ts
1579
- interface StatusWebhook {
1580
- id: string;
1581
- status: 'sent' | 'delivered' | 'read' | 'failed';
1582
- timestamp: string;
1583
- recipient_id: string;
1584
- recipient_type?: 'group';
1585
- recipient_participant_id?: string;
1586
- recipient_identity_key_hash?: string;
1587
- biz_opaque_callback_data?: string;
1588
- conversation?: {
1589
- id: string;
1590
- expiration_timestamp?: string;
1591
- origin: {
1592
- type: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1593
- };
1594
- };
1595
- pricing?: {
1596
- billable: boolean;
1597
- pricing_model: 'CBP' | 'PMP';
1598
- type: 'regular' | 'free_customer_service' | 'free_entry_point';
1599
- category: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1600
- };
1601
- errors?: Array<WebhookError>;
1824
+ /**
1825
+ * WhatsApp Business Account information
1826
+ */
1827
+ interface WabaAccount {
1828
+ account_review_status?: WabaAccountReviewStatus;
1829
+ id?: string;
1830
+ health_status?: WabaHealthStatus;
1831
+ status?: WabaAccountStatus;
1832
+ business_verification_status?: WabaBusinessVerificationStatus;
1833
+ message_template_namespace?: string;
1834
+ name?: string;
1835
+ ownership_type?: string;
1836
+ timezone_id?: string;
1837
+ primary_business_location?: Record<string, unknown> | string;
1838
+ currency?: string;
1839
+ }
1840
+ /**
1841
+ * Available fields for WABA account queries
1842
+ */
1843
+ type WabaAccountFields = 'id' | 'name' | 'timezone_id' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace' | 'primary_business_location';
1844
+ /**
1845
+ * Parameter type for specifying which WABA account fields to retrieve
1846
+ */
1847
+ type WabaAccountFieldsParam = WabaAccountFields[];
1848
+ /**
1849
+ * Interface defining all WABA API methods
1850
+ */
1851
+ interface WABAClass {
1852
+ getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
1853
+ getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
1854
+ updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
1855
+ unsubscribeFromWaba(): Promise<ResponseSuccess>;
1602
1856
  }
1603
1857
  //#endregion
1604
1858
  //#region src/core/webhook/types/account.d.ts
@@ -1690,119 +1944,131 @@ interface AccountAlertsWebhookValue {
1690
1944
  value: AccountAlertsValue;
1691
1945
  }
1692
1946
  //#endregion
1693
- //#region src/core/webhook/types/business.d.ts
1947
+ //#region src/core/webhook/types/common.d.ts
1694
1948
  /**
1695
- * Business capability limits
1696
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#business-capability-updates
1949
+ * WhatsApp contact information
1697
1950
  */
1698
- interface BusinessCapabilityUpdateValue {
1699
- max_daily_conversation_per_phone?: number;
1700
- max_phone_numbers_per_business?: number;
1701
- max_phone_numbers_per_waba?: number;
1702
- }
1703
- interface BusinessCapabilityUpdateWebhookValue {
1704
- field: 'business_capability_update';
1705
- value: BusinessCapabilityUpdateValue;
1951
+ interface WebhookContact {
1952
+ wa_id: string;
1953
+ profile: {
1954
+ name: string;
1955
+ };
1956
+ identity_key_hash?: string;
1706
1957
  }
1707
- //#endregion
1708
- //#region src/core/webhook/types/phoneNumber.d.ts
1709
1958
  /**
1710
- * Phone number name update decision
1711
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#phone-number-updates
1959
+ * Metadata included in all webhooks
1712
1960
  */
1713
- type PhoneNumberDecision = 'APPROVED' | 'REJECTED' | 'DEFERRED';
1714
- interface PhoneNumberNameUpdateValue {
1961
+ interface WebhookMetadata {
1715
1962
  display_phone_number: string;
1716
- decision: PhoneNumberDecision;
1717
- requested_verified_name: string;
1718
- rejection_reason: string | null;
1719
- }
1720
- interface PhoneNumberNameUpdateWebhookValue {
1721
- field: 'phone_number_name_update';
1722
- value: PhoneNumberNameUpdateValue;
1963
+ phone_number_id: string;
1723
1964
  }
1724
1965
  /**
1725
- * Phone number quality events
1726
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1966
+ * Error object structure
1727
1967
  */
1728
- type PhoneNumberQualityEvent = 'FLAGGED' | 'UNFLAGGED' | 'UPGRADE' | 'DOWNGRADE' | 'ONBOARDING';
1968
+ interface WebhookError {
1969
+ code: number;
1970
+ title: string;
1971
+ message: string;
1972
+ error_data?: {
1973
+ details: string;
1974
+ };
1975
+ href?: string;
1976
+ }
1729
1977
  /**
1730
- * Messaging tier limits
1731
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--current_limit
1978
+ * Click to WhatsApp ad referral information
1732
1979
  */
1733
- type CurrentLimit = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED';
1734
- interface PhoneNumberQualityUpdateValue {
1735
- display_phone_number: string;
1736
- event: PhoneNumberQualityEvent;
1737
- current_limit: CurrentLimit;
1980
+ interface ReferralInfo {
1981
+ source_url: string;
1982
+ source_id: string;
1983
+ source_type: 'ad';
1984
+ body?: string;
1985
+ headline?: string;
1986
+ media_type?: 'image' | 'video';
1987
+ image_url?: string;
1988
+ video_url?: string;
1989
+ thumbnail_url?: string;
1990
+ ctwa_clid?: string;
1991
+ welcome_message?: {
1992
+ text: string;
1993
+ };
1738
1994
  }
1739
- interface PhoneNumberQualityUpdateWebhookValue {
1740
- field: 'phone_number_quality_update';
1741
- value: PhoneNumberQualityUpdateValue;
1995
+ /**
1996
+ * Context for forwarded messages
1997
+ */
1998
+ interface ForwardedContext {
1999
+ forwarded?: true;
2000
+ frequently_forwarded?: true;
1742
2001
  }
1743
- //#endregion
1744
- //#region src/core/webhook/types/template.d.ts
1745
2002
  /**
1746
- * Message template status events
1747
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2003
+ * Context for product inquiry messages
1748
2004
  */
1749
- type TemplateStatusEvent = 'APPROVED' | 'REJECTED' | 'PENDING' | 'DISABLED' | 'REINSTATED' | 'IN_APPEAL' | 'FLAGGED' | 'PAUSED' | 'PENDING_DELETION';
2005
+ interface ProductContext {
2006
+ from: string;
2007
+ id: string;
2008
+ referred_product: {
2009
+ catalog_id: string;
2010
+ product_retailer_id: string;
2011
+ };
2012
+ }
1750
2013
  /**
1751
- * Template rejection reasons
1752
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--reason
2014
+ * Context for interactive/button replies
1753
2015
  */
1754
- type TemplateRejectionReason = 'NONE' | 'ABUSIVE_CONTENT' | 'INCORRECT_CATEGORY' | 'INVALID_FORMAT' | 'SCAM';
1755
- interface TemplateDisableInfo {
1756
- disable_date: string;
2016
+ interface ReplyContext {
2017
+ from: string;
2018
+ id: string;
1757
2019
  }
1758
- interface TemplatePauseInfo {
1759
- title: string;
1760
- description: string;
2020
+ //#endregion
2021
+ //#region src/core/webhook/types/appStateSync.d.ts
2022
+ /**
2023
+ * Contact data in state sync
2024
+ */
2025
+ interface StateSyncContact {
2026
+ full_name: string;
2027
+ first_name: string;
2028
+ phone_number: string;
1761
2029
  }
1762
- interface MessageTemplateStatusUpdateValue {
1763
- event: TemplateStatusEvent;
1764
- message_template_id: number;
1765
- message_template_name: string;
1766
- message_template_language: string;
1767
- reason: TemplateRejectionReason | null;
1768
- disable_info?: TemplateDisableInfo;
1769
- other_info?: TemplatePauseInfo;
2030
+ /**
2031
+ * State sync metadata
2032
+ */
2033
+ interface StateSyncMetadata {
2034
+ timestamp: string;
2035
+ version: number;
1770
2036
  }
1771
- interface MessageTemplateStatusUpdateWebhookValue {
1772
- field: 'message_template_status_update';
1773
- value: MessageTemplateStatusUpdateValue;
2037
+ /**
2038
+ * State sync data
2039
+ */
2040
+ interface StateSyncData {
2041
+ type: string;
2042
+ contact: StateSyncContact;
2043
+ action: string;
2044
+ metadata: StateSyncMetadata;
1774
2045
  }
1775
2046
  /**
1776
- * Template categories
1777
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2047
+ * SMB App State Sync value
1778
2048
  */
1779
- type TemplateCategory = 'MARKETING' | 'OTP' | 'TRANSACTIONAL' | 'AUTHENTICATION' | 'UTILITY';
1780
- interface TemplateCategoryUpdateValue {
1781
- message_template_id: number;
1782
- message_template_name: string;
1783
- message_template_language: string;
1784
- previous_category: TemplateCategory;
1785
- new_category: TemplateCategory;
2049
+ interface SmbAppStateSyncValue {
2050
+ messaging_product: string;
2051
+ metadata: WebhookMetadata;
2052
+ state_sync: StateSyncData[];
1786
2053
  }
1787
- interface TemplateCategoryUpdateWebhookValue {
1788
- field: 'template_category_update';
1789
- value: TemplateCategoryUpdateValue;
2054
+ interface SmbAppStateSyncWebhookValue {
2055
+ field: 'smb_app_state_sync';
2056
+ value: SmbAppStateSyncValue;
1790
2057
  }
2058
+ //#endregion
2059
+ //#region src/core/webhook/types/business.d.ts
1791
2060
  /**
1792
- * Template quality scores
1793
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2061
+ * Business capability limits
2062
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#business-capability-updates
1794
2063
  */
1795
- type TemplateQualityScore = 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
1796
- interface MessageTemplateQualityUpdateValue {
1797
- previous_quality_score: TemplateQualityScore;
1798
- new_quality_score: TemplateQualityScore;
1799
- message_template_id: number;
1800
- message_template_name: string;
1801
- message_template_language: string;
2064
+ interface BusinessCapabilityUpdateValue {
2065
+ max_daily_conversation_per_phone?: number;
2066
+ max_phone_numbers_per_business?: number;
2067
+ max_phone_numbers_per_waba?: number;
1802
2068
  }
1803
- interface MessageTemplateQualityUpdateWebhookValue {
1804
- field: 'message_template_quality_update';
1805
- value: MessageTemplateQualityUpdateValue;
2069
+ interface BusinessCapabilityUpdateWebhookValue {
2070
+ field: 'business_capability_update';
2071
+ value: BusinessCapabilityUpdateValue;
1806
2072
  }
1807
2073
  //#endregion
1808
2074
  //#region src/core/webhook/types/flows.d.ts
@@ -1853,20 +2119,214 @@ interface FlowsWebhookValue {
1853
2119
  value: FlowsValue;
1854
2120
  }
1855
2121
  //#endregion
1856
- //#region src/core/webhook/types/security.d.ts
2122
+ //#region src/core/webhook/types/message.d.ts
1857
2123
  /**
1858
- * Two-step verification security events
1859
- * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2124
+ * Base message properties common to all message types
1860
2125
  */
1861
- type SecurityEvent = 'PIN_CHANGED' | 'PIN_RESET_REQUEST' | 'PIN_RESET_SUCCESS';
1862
- interface SecurityValue {
1863
- event: SecurityEvent;
1864
- requester?: string;
2126
+ interface BaseMessage {
2127
+ from: string;
2128
+ id: string;
2129
+ timestamp: string;
1865
2130
  }
1866
- interface SecurityWebhookValue {
1867
- field: 'security';
1868
- value: SecurityValue;
2131
+ interface TextMessage extends BaseMessage {
2132
+ type: MessageTypesEnum.Text;
2133
+ text: {
2134
+ body: string;
2135
+ };
2136
+ context?: ForwardedContext | ProductContext;
2137
+ referral?: ReferralInfo;
2138
+ }
2139
+ interface ImageMessage extends BaseMessage {
2140
+ type: MessageTypesEnum.Image;
2141
+ image: {
2142
+ caption?: string;
2143
+ mime_type: string;
2144
+ sha256: string;
2145
+ id: string;
2146
+ url: string;
2147
+ };
2148
+ context?: ForwardedContext;
2149
+ referral?: ReferralInfo;
2150
+ }
2151
+ interface VideoMessage extends BaseMessage {
2152
+ type: MessageTypesEnum.Video;
2153
+ video: {
2154
+ caption?: string;
2155
+ mime_type: string;
2156
+ sha256: string;
2157
+ id: string;
2158
+ url: string;
2159
+ };
2160
+ context?: ForwardedContext;
2161
+ referral?: ReferralInfo;
2162
+ }
2163
+ interface AudioMessage extends BaseMessage {
2164
+ type: MessageTypesEnum.Audio;
2165
+ audio: {
2166
+ mime_type: string;
2167
+ sha256: string;
2168
+ id: string;
2169
+ url: string;
2170
+ voice: boolean;
2171
+ };
2172
+ referral?: ReferralInfo;
2173
+ }
2174
+ interface DocumentMessage extends BaseMessage {
2175
+ type: MessageTypesEnum.Document;
2176
+ document: {
2177
+ caption?: string;
2178
+ filename: string;
2179
+ mime_type: string;
2180
+ sha256: string;
2181
+ id: string;
2182
+ url: string;
2183
+ };
2184
+ referral?: ReferralInfo;
2185
+ }
2186
+ interface StickerMessage extends BaseMessage {
2187
+ type: MessageTypesEnum.Sticker;
2188
+ sticker: {
2189
+ mime_type: string;
2190
+ sha256: string;
2191
+ id: string;
2192
+ url: string;
2193
+ animated: boolean;
2194
+ };
2195
+ referral?: ReferralInfo;
2196
+ }
2197
+ interface InteractiveListReplyMessage extends BaseMessage {
2198
+ type: MessageTypesEnum.Interactive;
2199
+ context: ReplyContext;
2200
+ interactive: {
2201
+ type: 'list_reply';
2202
+ list_reply: {
2203
+ id: string;
2204
+ title: string;
2205
+ description?: string;
2206
+ };
2207
+ };
2208
+ }
2209
+ interface InteractiveButtonReplyMessage extends BaseMessage {
2210
+ type: MessageTypesEnum.Interactive;
2211
+ context: ReplyContext;
2212
+ interactive: {
2213
+ type: 'button_reply';
2214
+ button_reply: {
2215
+ id: string;
2216
+ title: string;
2217
+ };
2218
+ };
2219
+ }
2220
+ interface InteractiveNfmReplyMessage extends BaseMessage {
2221
+ type: MessageTypesEnum.Interactive;
2222
+ context: ReplyContext;
2223
+ interactive: {
2224
+ type: 'nfm_reply';
2225
+ nfm_reply: {
2226
+ name: string;
2227
+ body: string;
2228
+ response_json: string;
2229
+ };
2230
+ };
2231
+ }
2232
+ type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage | InteractiveNfmReplyMessage;
2233
+ interface ButtonMessage extends BaseMessage {
2234
+ type: MessageTypesEnum.Button;
2235
+ context: ReplyContext;
2236
+ button: {
2237
+ payload: string;
2238
+ text: string;
2239
+ };
2240
+ }
2241
+ interface LocationMessage extends BaseMessage {
2242
+ type: MessageTypesEnum.Location;
2243
+ location: {
2244
+ latitude: number;
2245
+ longitude: number;
2246
+ name?: string;
2247
+ address?: string;
2248
+ url?: string;
2249
+ };
2250
+ referral?: ReferralInfo;
2251
+ }
2252
+ interface ContactsMessage extends BaseMessage {
2253
+ type: MessageTypesEnum.Contacts;
2254
+ contacts: Array<{
2255
+ addresses?: Array<{
2256
+ city?: string;
2257
+ country?: string;
2258
+ country_code?: string;
2259
+ state?: string;
2260
+ street?: string;
2261
+ type?: string;
2262
+ zip?: string;
2263
+ }>;
2264
+ birthday?: string;
2265
+ emails?: Array<{
2266
+ email: string;
2267
+ type?: string;
2268
+ }>;
2269
+ name: {
2270
+ formatted_name: string;
2271
+ first_name?: string;
2272
+ last_name?: string;
2273
+ middle_name?: string;
2274
+ suffix?: string;
2275
+ prefix?: string;
2276
+ };
2277
+ org?: {
2278
+ company?: string;
2279
+ department?: string;
2280
+ title?: string;
2281
+ };
2282
+ phones?: Array<{
2283
+ phone: string;
2284
+ wa_id?: string;
2285
+ type?: string;
2286
+ }>;
2287
+ urls?: Array<{
2288
+ url: string;
2289
+ type?: string;
2290
+ }>;
2291
+ }>;
2292
+ referral?: ReferralInfo;
2293
+ }
2294
+ interface ReactionMessage extends BaseMessage {
2295
+ type: MessageTypesEnum.Reaction;
2296
+ reaction: {
2297
+ message_id: string;
2298
+ emoji?: string;
2299
+ };
2300
+ }
2301
+ interface OrderMessage extends BaseMessage {
2302
+ type: MessageTypesEnum.Order;
2303
+ order: {
2304
+ catalog_id: string;
2305
+ text?: string;
2306
+ product_items: Array<{
2307
+ product_retailer_id: string;
2308
+ quantity: number;
2309
+ item_price: number;
2310
+ currency: string;
2311
+ }>;
2312
+ };
2313
+ }
2314
+ interface SystemMessage extends BaseMessage {
2315
+ type: MessageTypesEnum.System;
2316
+ system: {
2317
+ body: string;
2318
+ wa_id: string;
2319
+ type: 'user_changed_number';
2320
+ };
2321
+ }
2322
+ interface UnsupportedMessage extends BaseMessage {
2323
+ type: MessageTypesEnum.Unsupported;
2324
+ errors: Array<WebhookError>;
1869
2325
  }
2326
+ type GroupMessage = {
2327
+ group_id: string;
2328
+ } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
2329
+ type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1870
2330
  //#endregion
1871
2331
  //#region src/core/webhook/types/history.d.ts
1872
2332
  /**
@@ -1914,717 +2374,318 @@ interface HistoryMessageEcho {
1914
2374
  * History sync thread data
1915
2375
  */
1916
2376
  interface HistorySyncThread {
1917
- id: string;
1918
- messages: WhatsAppMessage[];
1919
- }
1920
- /**
1921
- * History sync error data
1922
- */
1923
- interface HistorySyncError {
1924
- message: string;
1925
- error_data?: {
1926
- details: string;
1927
- };
1928
- }
1929
- /**
1930
- * History sync data
1931
- */
1932
- interface HistorySyncData {
1933
- metadata: HistorySyncMetadata;
1934
- threads?: HistorySyncThread[];
1935
- errors?: HistorySyncError[];
1936
- }
1937
- /**
1938
- * History webhook value
1939
- */
1940
- interface HistoryValue {
1941
- messaging_product: string;
1942
- metadata: HistorySyncMetadata;
1943
- history?: HistorySyncData[];
1944
- messages?: WhatsAppMessage[];
1945
- message_echoes?: HistoryMessageEcho[];
1946
- }
1947
- interface HistoryWebhookValue {
1948
- field: 'history';
1949
- value: HistoryValue;
1950
- }
1951
- //#endregion
1952
- //#region src/core/webhook/types/messageEchoes.d.ts
1953
- /**
1954
- * Message echo error
1955
- */
1956
- interface MessageEchoError {
1957
- message: string;
1958
- error_data?: {
1959
- details: string;
1960
- };
1961
- }
1962
- /**
1963
- * Message echo data (sent messages from business)
1964
- */
1965
- interface MessageEcho {
1966
- from: string;
1967
- to: string;
1968
- id: string;
1969
- timestamp: string;
1970
- text?: {
1971
- body: string;
1972
- };
1973
- interactive?: any;
1974
- location?: any;
1975
- image?: any;
1976
- document?: any;
1977
- voice?: any;
1978
- audio?: any;
1979
- video?: any;
1980
- sticker?: any;
1981
- button?: any;
1982
- contacts?: any;
1983
- reaction?: {
1984
- message_id: string;
1985
- emoji: string;
1986
- };
1987
- order?: any;
1988
- biz_opaque_callback_data?: string;
1989
- template?: any;
1990
- system?: {
1991
- type: string;
1992
- };
1993
- user_actions?: any[];
1994
- }
1995
- /**
1996
- * SMB Message Echoes value
1997
- */
1998
- interface SmbMessageEchoesValue {
1999
- metadata: WebhookMetadata;
2000
- errors?: MessageEchoError[];
2001
- message_echoes: MessageEcho[];
2002
- }
2003
- interface SmbMessageEchoesWebhookValue {
2004
- field: 'smb_message_echoes';
2005
- value: SmbMessageEchoesValue;
2006
- }
2007
- //#endregion
2008
- //#region src/core/webhook/types/appStateSync.d.ts
2009
- /**
2010
- * Contact data in state sync
2011
- */
2012
- interface StateSyncContact {
2013
- full_name: string;
2014
- first_name: string;
2015
- phone_number: string;
2016
- }
2017
- /**
2018
- * State sync metadata
2019
- */
2020
- interface StateSyncMetadata {
2021
- timestamp: string;
2022
- version: number;
2023
- }
2024
- /**
2025
- * State sync data
2026
- */
2027
- interface StateSyncData {
2028
- type: string;
2029
- contact: StateSyncContact;
2030
- action: string;
2031
- metadata: StateSyncMetadata;
2032
- }
2033
- /**
2034
- * SMB App State Sync value
2035
- */
2036
- interface SmbAppStateSyncValue {
2037
- messaging_product: string;
2038
- metadata: WebhookMetadata;
2039
- state_sync: StateSyncData[];
2040
- }
2041
- interface SmbAppStateSyncWebhookValue {
2042
- field: 'smb_app_state_sync';
2043
- value: SmbAppStateSyncValue;
2044
- }
2045
- //#endregion
2046
- //#region src/core/webhook/types/index.d.ts
2047
- /**
2048
- * Webhook value for incoming messages
2049
- */
2050
- interface MessageWebhookValue {
2051
- messaging_product: 'whatsapp';
2052
- metadata: WebhookMetadata;
2053
- contacts: Array<WebhookContact>;
2054
- messages: Array<WhatsAppMessage>;
2055
- }
2056
- /**
2057
- * Webhook value for status updates
2058
- */
2059
- interface StatusWebhookValue {
2060
- messaging_product: 'whatsapp';
2061
- metadata: WebhookMetadata;
2062
- statuses: Array<StatusWebhook>;
2063
- }
2064
- /**
2065
- * Webhook value for errors (no contacts or messages)
2066
- */
2067
- interface ErrorWebhookValue {
2068
- messaging_product: 'whatsapp';
2069
- metadata: WebhookMetadata;
2070
- errors: Array<WebhookError>;
2071
- }
2072
- /**
2073
- * Union type for all webhook value types
2074
- */
2075
- type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
2076
- /**
2077
- * Union type for all webhook field values
2078
- */
2079
- type WebhookFieldValue = AccountUpdateWebhookValue | AccountReviewUpdateWebhookValue | AccountAlertsWebhookValue | BusinessCapabilityUpdateWebhookValue | PhoneNumberNameUpdateWebhookValue | PhoneNumberQualityUpdateWebhookValue | MessageTemplateStatusUpdateWebhookValue | TemplateCategoryUpdateWebhookValue | MessageTemplateQualityUpdateWebhookValue | FlowsWebhookValue | SecurityWebhookValue | HistoryWebhookValue | SmbMessageEchoesWebhookValue | SmbAppStateSyncWebhookValue;
2080
- interface WebhookPayload {
2081
- object: 'whatsapp_business_account';
2082
- entry: Array<{
2083
- id: string;
2084
- changes: Array<{
2085
- value: WebhookValue;
2086
- field: 'messages';
2087
- } | WebhookFieldValue>;
2088
- }>;
2089
- }
2090
- /**
2091
- * @deprecated Use specific message types instead
2092
- * Represents a message received through the webhook
2093
- */
2094
- interface WebhookMessage {
2095
- wabaId: string;
2096
- id: string;
2097
- from: string;
2098
- timestamp: string;
2099
- type: any;
2100
- phoneNumberId: string;
2101
- displayPhoneNumber: string;
2102
- profileName: string;
2103
- text?: any;
2104
- image?: any;
2105
- video?: any;
2106
- audio?: any;
2107
- document?: any;
2108
- sticker?: any;
2109
- location?: any;
2110
- contacts?: any;
2111
- interactive?: any;
2112
- button?: any;
2113
- order?: any;
2114
- system?: any;
2115
- reaction?: any;
2116
- statuses?: StatusWebhook;
2117
- originalData: any;
2118
- }
2119
- /**
2120
- * Webhook event received from WhatsApp
2121
- */
2122
- interface WebhookEvent {
2123
- field: string;
2124
- value: any;
2125
- timestamp: number;
2126
- }
2127
- //#endregion
2128
- //#region src/api/qrCode/types/common.d.ts
2129
- type QrCodeResponse = {
2130
- code: string;
2131
- prefilled_message: string;
2132
- deep_link_url: string;
2133
- qr_image_url?: string;
2134
- };
2135
- type QrCodesResponse = ResponseData<QrCodeResponse[]>;
2136
- type CreateQrCodeRequest = {
2137
- prefilled_message: string;
2138
- generate_qr_image?: 'SVG' | 'PNG';
2139
- };
2140
- type UpdateQrCodeRequest = {
2141
- code: string;
2142
- prefilled_message: string;
2143
- };
2144
- interface QrCodeClass {
2145
- createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
2146
- getQrCodes(): Promise<QrCodesResponse>;
2147
- getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
2148
- updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
2149
- deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
2150
- }
2151
- //#endregion
2152
- //#region src/api/waba/types/common.d.ts
2153
- /**
2154
- * WhatsApp Business Account subscription configuration
2155
- */
2156
- type WabaSubscription = {
2157
- whatsapp_business_api_data: {
2158
- id: string;
2159
- link: string;
2160
- name: string;
2161
- category: string;
2162
- };
2163
- override_callback_uri?: string;
2164
- };
2165
- /**
2166
- * Parameters for updating WABA subscription
2167
- */
2168
- interface UpdateWabaSubscription {
2169
- override_callback_uri: string;
2170
- verify_token: string;
2377
+ id: string;
2378
+ messages: WhatsAppMessage[];
2171
2379
  }
2172
2380
  /**
2173
- * Response containing all WABA subscriptions
2381
+ * History sync error data
2174
2382
  */
2175
- interface WabaSubscriptions {
2176
- data: Array<WabaSubscription>;
2383
+ interface HistorySyncError {
2384
+ message: string;
2385
+ error_data?: {
2386
+ details: string;
2387
+ };
2177
2388
  }
2178
2389
  /**
2179
- * WABA account review status enumeration
2390
+ * History sync data
2180
2391
  */
2181
- declare enum WabaAccountReviewStatus {
2182
- Approved = "APPROVED",
2183
- Active = "ACTIVE",
2184
- Inactive = "INACTIVE",
2185
- Disabled = "DISABLED",
2392
+ interface HistorySyncData {
2393
+ metadata: HistorySyncMetadata;
2394
+ threads?: HistorySyncThread[];
2395
+ errors?: HistorySyncError[];
2186
2396
  }
2187
2397
  /**
2188
- * WABA health status for message sending capability
2398
+ * History webhook value
2189
2399
  */
2190
- declare enum WabaHealthStatusCanSendMessage {
2191
- Blocked = "BLOCKED",
2192
- Limited = "LIMITED",
2193
- Available = "AVAILABLE",
2400
+ interface HistoryValue {
2401
+ messaging_product: string;
2402
+ metadata: HistorySyncMetadata;
2403
+ history?: HistorySyncData[];
2404
+ messages?: WhatsAppMessage[];
2405
+ message_echoes?: HistoryMessageEcho[];
2406
+ }
2407
+ interface HistoryWebhookValue {
2408
+ field: 'history';
2409
+ value: HistoryValue;
2194
2410
  }
2411
+ //#endregion
2412
+ //#region src/core/webhook/types/messageEchoes.d.ts
2195
2413
  /**
2196
- * WABA account status enumeration
2414
+ * Message echo error
2197
2415
  */
2198
- declare enum WabaAccountStatus {
2199
- Approved = "APPROVED",
2200
- Active = "ACTIVE",
2201
- Inactive = "INACTIVE",
2202
- Disabled = "DISABLED",
2416
+ interface MessageEchoError {
2417
+ message: string;
2418
+ error_data?: {
2419
+ details: string;
2420
+ };
2203
2421
  }
2204
2422
  /**
2205
- * Business verification status enumeration
2423
+ * Message echo data (sent messages from business)
2206
2424
  */
2207
- declare enum WabaBusinessVerificationStatus {
2208
- Verified = "verified",
2209
- PendingSubmission = "pending_submission",
2210
- Unverified = "unverified",
2211
- Rejected = "rejected",
2425
+ interface MessageEcho {
2426
+ from: string;
2427
+ to: string;
2428
+ id: string;
2429
+ timestamp: string;
2430
+ text?: {
2431
+ body: string;
2432
+ };
2433
+ interactive?: any;
2434
+ location?: any;
2435
+ image?: any;
2436
+ document?: any;
2437
+ voice?: any;
2438
+ audio?: any;
2439
+ video?: any;
2440
+ sticker?: any;
2441
+ button?: any;
2442
+ contacts?: any;
2443
+ reaction?: {
2444
+ message_id: string;
2445
+ emoji: string;
2446
+ };
2447
+ order?: any;
2448
+ biz_opaque_callback_data?: string;
2449
+ template?: any;
2450
+ system?: {
2451
+ type: string;
2452
+ };
2453
+ user_actions?: any[];
2212
2454
  }
2213
2455
  /**
2214
- * WABA health status error details
2456
+ * SMB Message Echoes value
2215
2457
  */
2216
- interface WabaHealthStatusError {
2217
- error_code?: number;
2218
- error_description?: string;
2219
- possible_solution?: string;
2458
+ interface SmbMessageEchoesValue {
2459
+ metadata: WebhookMetadata;
2460
+ errors?: MessageEchoError[];
2461
+ message_echoes: MessageEcho[];
2462
+ }
2463
+ interface SmbMessageEchoesWebhookValue {
2464
+ field: 'smb_message_echoes';
2465
+ value: SmbMessageEchoesValue;
2220
2466
  }
2467
+ //#endregion
2468
+ //#region src/core/webhook/types/phoneNumber.d.ts
2221
2469
  /**
2222
- * WABA health status entity information
2470
+ * Phone number name update decision
2471
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#phone-number-updates
2223
2472
  */
2224
- interface WabaHealthStatusEntity {
2225
- entity_type?: string;
2226
- id?: string;
2227
- can_send_message?: string;
2228
- errors?: WabaHealthStatusError[];
2473
+ type PhoneNumberDecision = 'APPROVED' | 'REJECTED' | 'DEFERRED';
2474
+ interface PhoneNumberNameUpdateValue {
2475
+ display_phone_number: string;
2476
+ decision: PhoneNumberDecision;
2477
+ requested_verified_name: string;
2478
+ rejection_reason: string | null;
2479
+ }
2480
+ interface PhoneNumberNameUpdateWebhookValue {
2481
+ field: 'phone_number_name_update';
2482
+ value: PhoneNumberNameUpdateValue;
2229
2483
  }
2230
2484
  /**
2231
- * Overall WABA health status
2485
+ * Phone number quality events
2486
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2232
2487
  */
2233
- interface WabaHealthStatus {
2234
- can_send_message?: WabaHealthStatusCanSendMessage;
2235
- entities?: WabaHealthStatusEntity[];
2488
+ type PhoneNumberQualityEvent = 'FLAGGED' | 'UNFLAGGED' | 'UPGRADE' | 'DOWNGRADE' | 'ONBOARDING';
2489
+ /**
2490
+ * Messaging tier limits
2491
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--current_limit
2492
+ */
2493
+ type CurrentLimit = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED';
2494
+ interface PhoneNumberQualityUpdateValue {
2495
+ display_phone_number: string;
2496
+ event: PhoneNumberQualityEvent;
2497
+ current_limit: CurrentLimit;
2498
+ }
2499
+ interface PhoneNumberQualityUpdateWebhookValue {
2500
+ field: 'phone_number_quality_update';
2501
+ value: PhoneNumberQualityUpdateValue;
2236
2502
  }
2503
+ //#endregion
2504
+ //#region src/core/webhook/types/security.d.ts
2237
2505
  /**
2238
- * WhatsApp Business Account information
2506
+ * Two-step verification security events
2507
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2239
2508
  */
2240
- interface WabaAccount {
2241
- account_review_status?: WabaAccountReviewStatus;
2242
- id?: string;
2243
- health_status?: WabaHealthStatus;
2244
- status?: WabaAccountStatus;
2245
- business_verification_status?: WabaBusinessVerificationStatus;
2246
- message_template_namespace?: string;
2247
- name?: string;
2248
- ownership_type?: string;
2249
- timezone_id?: string;
2250
- primary_business_location?: Record<string, unknown> | string;
2251
- currency?: string;
2509
+ type SecurityEvent = 'PIN_CHANGED' | 'PIN_RESET_REQUEST' | 'PIN_RESET_SUCCESS';
2510
+ interface SecurityValue {
2511
+ event: SecurityEvent;
2512
+ requester?: string;
2513
+ }
2514
+ interface SecurityWebhookValue {
2515
+ field: 'security';
2516
+ value: SecurityValue;
2517
+ }
2518
+ //#endregion
2519
+ //#region src/core/webhook/types/status.d.ts
2520
+ interface StatusWebhook {
2521
+ id: string;
2522
+ status: 'sent' | 'delivered' | 'read' | 'failed';
2523
+ timestamp: string;
2524
+ recipient_id: string;
2525
+ recipient_type?: 'group';
2526
+ recipient_participant_id?: string;
2527
+ recipient_identity_key_hash?: string;
2528
+ biz_opaque_callback_data?: string;
2529
+ conversation?: {
2530
+ id: string;
2531
+ expiration_timestamp?: string;
2532
+ origin: {
2533
+ type: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
2534
+ };
2535
+ };
2536
+ pricing?: {
2537
+ billable: boolean;
2538
+ pricing_model: 'CBP' | 'PMP';
2539
+ type: 'regular' | 'free_customer_service' | 'free_entry_point';
2540
+ category: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
2541
+ };
2542
+ errors?: Array<WebhookError>;
2252
2543
  }
2544
+ //#endregion
2545
+ //#region src/core/webhook/types/template.d.ts
2253
2546
  /**
2254
- * Available fields for WABA account queries
2547
+ * Message template status events
2548
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2255
2549
  */
2256
- type WabaAccountFields = 'id' | 'name' | 'timezone_id' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace' | 'primary_business_location';
2550
+ type TemplateStatusEvent = 'APPROVED' | 'REJECTED' | 'PENDING' | 'DISABLED' | 'REINSTATED' | 'IN_APPEAL' | 'FLAGGED' | 'PAUSED' | 'PENDING_DELETION';
2257
2551
  /**
2258
- * Parameter type for specifying which WABA account fields to retrieve
2552
+ * Template rejection reasons
2553
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--reason
2259
2554
  */
2260
- type WabaAccountFieldsParam = WabaAccountFields[];
2555
+ type TemplateRejectionReason = 'NONE' | 'ABUSIVE_CONTENT' | 'INCORRECT_CATEGORY' | 'INVALID_FORMAT' | 'SCAM';
2556
+ interface TemplateDisableInfo {
2557
+ disable_date: string;
2558
+ }
2559
+ interface TemplatePauseInfo {
2560
+ title: string;
2561
+ description: string;
2562
+ }
2563
+ interface MessageTemplateStatusUpdateValue {
2564
+ event: TemplateStatusEvent;
2565
+ message_template_id: number;
2566
+ message_template_name: string;
2567
+ message_template_language: string;
2568
+ reason: TemplateRejectionReason | null;
2569
+ disable_info?: TemplateDisableInfo;
2570
+ other_info?: TemplatePauseInfo;
2571
+ }
2572
+ interface MessageTemplateStatusUpdateWebhookValue {
2573
+ field: 'message_template_status_update';
2574
+ value: MessageTemplateStatusUpdateValue;
2575
+ }
2261
2576
  /**
2262
- * Interface defining all WABA API methods
2577
+ * Template categories
2578
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2263
2579
  */
2264
- interface WABAClass {
2265
- getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
2266
- getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
2267
- updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
2268
- unsubscribeFromWaba(): Promise<ResponseSuccess>;
2580
+ type TemplateCategory = 'MARKETING' | 'OTP' | 'TRANSACTIONAL' | 'AUTHENTICATION' | 'UTILITY';
2581
+ interface TemplateCategoryUpdateValue {
2582
+ message_template_id: number;
2583
+ message_template_name: string;
2584
+ message_template_language: string;
2585
+ previous_category: TemplateCategory;
2586
+ new_category: TemplateCategory;
2269
2587
  }
2270
- //#endregion
2271
- //#region src/api/registration/types/common.d.ts
2272
- type RegistrationRequest = {
2273
- messaging_product: 'whatsapp';
2274
- pin: string;
2275
- data_localization_region?: DataLocalizationRegionEnum;
2276
- };
2277
- interface RegistrationClass {
2278
- register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
2279
- deregister(): Promise<ResponseSuccess>;
2588
+ interface TemplateCategoryUpdateWebhookValue {
2589
+ field: 'template_category_update';
2590
+ value: TemplateCategoryUpdateValue;
2591
+ }
2592
+ /**
2593
+ * Template quality scores
2594
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
2595
+ */
2596
+ type TemplateQualityScore = 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
2597
+ interface MessageTemplateQualityUpdateValue {
2598
+ previous_quality_score: TemplateQualityScore;
2599
+ new_quality_score: TemplateQualityScore;
2600
+ message_template_id: number;
2601
+ message_template_name: string;
2602
+ message_template_language: string;
2280
2603
  }
2281
- //#endregion
2282
- //#region src/api/twoStepVerification/types/common.d.ts
2283
- type TwoStepVerificationRequest = {
2284
- pin: string;
2285
- };
2286
- interface TwoStepVerificationClass {
2287
- setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
2604
+ interface MessageTemplateQualityUpdateWebhookValue {
2605
+ field: 'message_template_quality_update';
2606
+ value: MessageTemplateQualityUpdateValue;
2288
2607
  }
2289
2608
  //#endregion
2290
- //#region src/api/encryption/types/publicKey.d.ts
2291
- type EncryptionPublicKeyResponse = ResponseData<{
2292
- business_public_key: string;
2293
- business_public_key_signature_status: 'VALID' | 'MISMATCH';
2294
- }>;
2295
- //#endregion
2296
- //#region src/api/groups/types/groups.d.ts
2609
+ //#region src/core/webhook/types/index.d.ts
2297
2610
  /**
2298
- * Groups API Types
2299
- * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
2611
+ * Webhook value for incoming messages
2300
2612
  */
2301
- type GroupJoinApprovalMode = 'approval_required' | 'auto_approve';
2302
- type GroupCreateRequest = {
2303
- subject: string;
2304
- description?: string;
2305
- join_approval_mode?: GroupJoinApprovalMode;
2306
- };
2307
- type GroupCreateResponse = {
2308
- messaging_product: 'whatsapp';
2309
- id: string;
2310
- invite_link?: string;
2311
- };
2312
- type GroupInfoField = 'join_approval_mode' | 'subject' | 'description' | 'suspended' | 'creation_timestamp' | 'participants' | 'total_participant_count';
2313
- type GroupInfoFieldsParam = GroupInfoField[] | string;
2314
- type GroupParticipant = {
2315
- wa_id: string;
2316
- };
2317
- type GroupInfoResponse = {
2318
- messaging_product: 'whatsapp';
2319
- id: string;
2320
- subject?: string;
2321
- description?: string;
2322
- suspended?: boolean;
2323
- creation_timestamp?: number;
2324
- participants?: GroupParticipant[];
2325
- total_participant_count?: number;
2326
- join_approval_mode?: GroupJoinApprovalMode;
2327
- };
2328
- type GroupInviteLinkResponse = {
2329
- messaging_product: 'whatsapp';
2330
- invite_link: string;
2331
- };
2332
- type GroupJoinRequest = {
2333
- join_request_id: string;
2334
- wa_id: string;
2335
- creation_timestamp: number;
2336
- };
2337
- type GroupJoinRequestError = {
2338
- code: number;
2339
- message: string;
2340
- title?: string;
2341
- error_data?: {
2342
- details?: string;
2343
- };
2344
- };
2345
- type GroupJoinRequestFailure = {
2346
- join_request_id: string;
2347
- errors: GroupJoinRequestError[];
2348
- };
2349
- type GroupJoinRequestsResponse = {
2350
- data: GroupJoinRequest[];
2351
- paging?: PagingInfo$1;
2352
- };
2353
- type GroupJoinRequestsActionResponse = {
2613
+ interface MessageWebhookValue {
2354
2614
  messaging_product: 'whatsapp';
2355
- approved_join_requests?: string[];
2356
- rejected_join_requests?: string[];
2357
- failed_join_requests?: GroupJoinRequestFailure[];
2358
- errors?: GroupJoinRequestError[];
2359
- };
2360
- type GroupSummary = {
2361
- id: string;
2362
- subject: string;
2363
- created_at: number;
2364
- };
2365
- type GroupListResponse = {
2366
- data: {
2367
- groups: GroupSummary[];
2368
- };
2369
- paging?: PagingInfo$1;
2370
- };
2371
- type GroupListParams = {
2372
- limit?: number;
2373
- after?: string;
2374
- before?: string;
2375
- };
2376
- type UpdateGroupSettingsRequest = {
2377
- subject?: string;
2378
- description?: string;
2379
- profilePictureFile?: Blob | Buffer;
2380
- };
2381
- type GroupSettingsResponse = ResponseSuccess;
2382
- interface GroupsClass {
2383
- createGroup(params: GroupCreateRequest): Promise<GroupCreateResponse>;
2384
- deleteGroup(groupId: string): Promise<ResponseSuccess>;
2385
- getGroupInfo(groupId: string, fields?: GroupInfoFieldsParam): Promise<GroupInfoResponse>;
2386
- getActiveGroups(params?: GroupListParams): Promise<GroupListResponse>;
2387
- getGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
2388
- resetGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
2389
- getJoinRequests(groupId: string): Promise<GroupJoinRequestsResponse>;
2390
- approveJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
2391
- rejectJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
2392
- removeParticipants(groupId: string, participants: string[]): Promise<ResponseSuccess>;
2393
- updateGroupSettings(groupId: string, params: UpdateGroupSettingsRequest): Promise<GroupSettingsResponse>;
2615
+ metadata: WebhookMetadata;
2616
+ contacts: Array<WebhookContact>;
2617
+ messages: Array<WhatsAppMessage>;
2394
2618
  }
2395
- type PagingInfo$1 = {
2396
- cursors?: {
2397
- before?: string;
2398
- after?: string;
2399
- };
2400
- previous?: string;
2401
- next?: string;
2402
- };
2403
- //#endregion
2404
- //#region src/api/calling/types/calling.d.ts
2405
2619
  /**
2406
- * Calling API Types
2407
- * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
2620
+ * Webhook value for status updates
2408
2621
  */
2409
- type CallingStatus = 'ENABLED' | 'DISABLED';
2410
- type CallIconVisibility = 'DEFAULT' | 'DISABLE_ALL';
2411
- type CallbackPermissionStatus = 'ENABLED' | 'DISABLED';
2412
- type CallHoursStatus = 'ENABLED' | 'DISABLED';
2413
- type SipStatus = 'ENABLED' | 'DISABLED';
2414
- type CallHoursDay = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
2415
- type WeeklyOperatingHours = {
2416
- day_of_week: CallHoursDay;
2417
- open_time: string;
2418
- close_time: string;
2419
- };
2420
- type HolidaySchedule = {
2421
- date: string;
2422
- start_time: string;
2423
- end_time: string;
2424
- };
2425
- type CallHours = {
2426
- status: CallHoursStatus;
2427
- timezone_id: string;
2428
- weekly_operating_hours: WeeklyOperatingHours[];
2429
- holiday_schedule?: HolidaySchedule[];
2430
- };
2431
- type SipServer = {
2432
- hostname: string;
2433
- port?: number;
2434
- request_uri_user_params?: Record<string, string>;
2435
- sip_user_password?: string;
2436
- };
2437
- type SipSettings = {
2438
- status: SipStatus;
2439
- servers?: SipServer[];
2440
- };
2441
- type CallingSettings = {
2442
- status?: CallingStatus;
2443
- call_icon_visibility?: CallIconVisibility;
2444
- call_hours?: CallHours;
2445
- callback_permission_status?: CallbackPermissionStatus;
2446
- sip?: SipSettings;
2447
- };
2448
- type UpdateCallingSettingsRequest = {
2449
- calling: CallingSettings;
2450
- };
2451
- type CallingSettingsResponse = {
2452
- calling?: CallingSettings;
2453
- [key: string]: unknown;
2454
- };
2455
- type CallPermission = {
2456
- status: string;
2457
- expiration_time?: number;
2458
- };
2459
- type CallPermissionLimit = {
2460
- time_period: string;
2461
- max_allowed: number;
2462
- current_usage: number;
2463
- limit_expiration_time?: number;
2464
- };
2465
- type CallPermissionAction = {
2466
- action_name: string;
2467
- can_perform_action: boolean;
2468
- limits?: CallPermissionLimit[];
2469
- };
2470
- type CallPermissionsResponse = {
2471
- messaging_product: 'whatsapp';
2472
- permission: CallPermission;
2473
- actions?: CallPermissionAction[];
2474
- };
2475
- type CallSdpType = 'offer' | 'answer';
2476
- type CallSession = {
2477
- sdp_type: CallSdpType;
2478
- sdp: string;
2479
- };
2480
- type CallAction = 'connect' | 'pre_accept' | 'accept' | 'reject' | 'terminate';
2481
- type InitiateCallRequest = {
2482
- to: string;
2483
- session: CallSession;
2484
- biz_opaque_callback_data?: string;
2485
- };
2486
- type PreAcceptCallRequest = {
2487
- call_id: string;
2488
- session?: CallSession;
2489
- };
2490
- type AcceptCallRequest = {
2491
- call_id: string;
2492
- session?: CallSession;
2493
- biz_opaque_callback_data?: string;
2494
- };
2495
- type RejectCallRequest = {
2496
- call_id: string;
2497
- };
2498
- type TerminateCallRequest = {
2499
- call_id: string;
2500
- };
2501
- type InitiateCallResponse = {
2502
- messaging_product: 'whatsapp';
2503
- calls: Array<{
2504
- id: string;
2505
- }>;
2506
- };
2507
- type CallActionResponse = {
2508
- messaging_product: 'whatsapp';
2509
- success: boolean;
2510
- };
2511
- interface CallingClass {
2512
- updateCallingSettings(params: UpdateCallingSettingsRequest): Promise<ResponseSuccess>;
2513
- getCallingSettings(params?: {
2514
- fields?: string[] | string;
2515
- include_sip_credentials?: boolean;
2516
- }): Promise<CallingSettingsResponse>;
2517
- getCallPermissions(params: {
2518
- userWaId: string;
2519
- }): Promise<CallPermissionsResponse>;
2520
- initiateCall(params: InitiateCallRequest): Promise<InitiateCallResponse>;
2521
- preAcceptCall(params: PreAcceptCallRequest): Promise<CallActionResponse>;
2522
- acceptCall(params: AcceptCallRequest): Promise<CallActionResponse>;
2523
- rejectCall(params: RejectCallRequest): Promise<CallActionResponse>;
2524
- terminateCall(params: TerminateCallRequest): Promise<CallActionResponse>;
2622
+ interface StatusWebhookValue {
2623
+ messaging_product: 'whatsapp';
2624
+ metadata: WebhookMetadata;
2625
+ statuses: Array<StatusWebhook>;
2525
2626
  }
2526
- //#endregion
2527
- //#region src/api/marketingMessages/types/marketingMessages.d.ts
2528
2627
  /**
2529
- * Marketing Messages API Types
2530
- * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages/
2628
+ * Webhook value for errors (no contacts or messages)
2531
2629
  */
2532
- type MarketingMessageRequest = {
2533
- to: string;
2534
- template: MessageTemplateObject<ComponentTypesEnum>;
2535
- message_activity_sharing?: boolean;
2536
- };
2537
- interface MarketingMessagesClass {
2538
- sendTemplateMessage(params: MarketingMessageRequest): Promise<MessagesResponse>;
2630
+ interface ErrorWebhookValue {
2631
+ messaging_product: 'whatsapp';
2632
+ metadata: WebhookMetadata;
2633
+ errors: Array<WebhookError>;
2539
2634
  }
2540
- //#endregion
2541
- //#region src/api/commerce/types/commerce.d.ts
2542
2635
  /**
2543
- * Commerce Settings API Types
2544
- * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
2636
+ * Union type for all webhook value types
2545
2637
  */
2546
- type CommerceSetting = {
2638
+ type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
2639
+ /**
2640
+ * Union type for all webhook field values
2641
+ */
2642
+ type WebhookFieldValue = AccountUpdateWebhookValue | AccountReviewUpdateWebhookValue | AccountAlertsWebhookValue | BusinessCapabilityUpdateWebhookValue | PhoneNumberNameUpdateWebhookValue | PhoneNumberQualityUpdateWebhookValue | MessageTemplateStatusUpdateWebhookValue | TemplateCategoryUpdateWebhookValue | MessageTemplateQualityUpdateWebhookValue | FlowsWebhookValue | SecurityWebhookValue | HistoryWebhookValue | SmbMessageEchoesWebhookValue | SmbAppStateSyncWebhookValue;
2643
+ interface WebhookPayload {
2644
+ object: 'whatsapp_business_account';
2645
+ entry: Array<{
2646
+ id: string;
2647
+ changes: Array<{
2648
+ value: WebhookValue;
2649
+ field: 'messages';
2650
+ } | WebhookFieldValue>;
2651
+ }>;
2652
+ }
2653
+ /**
2654
+ * @deprecated Use specific message types instead
2655
+ * Represents a message received through the webhook
2656
+ */
2657
+ interface WebhookMessage {
2658
+ wabaId: string;
2547
2659
  id: string;
2548
- is_cart_enabled?: boolean;
2549
- is_catalog_visible?: boolean;
2550
- };
2551
- type CommerceSettingsResponse = {
2552
- data: CommerceSetting[];
2553
- };
2554
- type UpdateCommerceSettingsRequest = {
2555
- is_cart_enabled?: boolean;
2556
- is_catalog_visible?: boolean;
2557
- };
2558
- interface CommerceClass {
2559
- getCommerceSettings(): Promise<CommerceSettingsResponse>;
2560
- updateCommerceSettings(params: UpdateCommerceSettingsRequest): Promise<ResponseSuccess>;
2660
+ from: string;
2661
+ timestamp: string;
2662
+ type: any;
2663
+ phoneNumberId: string;
2664
+ displayPhoneNumber: string;
2665
+ profileName: string;
2666
+ text?: any;
2667
+ image?: any;
2668
+ video?: any;
2669
+ audio?: any;
2670
+ document?: any;
2671
+ sticker?: any;
2672
+ location?: any;
2673
+ contacts?: any;
2674
+ interactive?: any;
2675
+ button?: any;
2676
+ order?: any;
2677
+ system?: any;
2678
+ reaction?: any;
2679
+ statuses?: StatusWebhook;
2680
+ originalData: any;
2561
2681
  }
2562
- //#endregion
2563
- //#region src/api/payments/types/payments.d.ts
2564
2682
  /**
2565
- * Payments API Types (India Payment Configuration)
2566
- * @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
2683
+ * Webhook event received from WhatsApp
2567
2684
  */
2568
- type PaymentConfigurationProvider = 'upi_vpa' | 'razorpay' | 'payu' | 'zaakpay';
2569
- type PaymentConfigurationStatus = 'Active' | 'Needs_Connecting' | 'Needs_Testing';
2570
- type PaymentConfigurationCode = {
2571
- code: string;
2572
- description?: string;
2573
- };
2574
- type PaymentConfiguration = {
2575
- configuration_name: string;
2576
- provider_name: string;
2577
- provider_mid?: string;
2578
- status?: PaymentConfigurationStatus;
2579
- merchant_category_code?: PaymentConfigurationCode;
2580
- purpose_code?: PaymentConfigurationCode;
2581
- created_timestamp?: number;
2582
- updated_timestamp?: number;
2583
- };
2584
- type PaymentConfigurationsResponse = {
2585
- data: Array<{
2586
- payment_configurations: PaymentConfiguration[];
2587
- }>;
2588
- };
2589
- type PaymentConfigurationCreateRequest = {
2590
- configuration_name: string;
2591
- provider_name: PaymentConfigurationProvider;
2592
- purpose_code?: string;
2593
- merchant_category_code?: string;
2594
- redirect_url?: string;
2595
- merchant_vpa?: string;
2596
- };
2597
- type PaymentConfigurationUpdateRequest = {
2598
- provider_name?: PaymentConfigurationProvider;
2599
- purpose_code?: string;
2600
- merchant_category_code?: string;
2601
- redirect_url?: string;
2602
- merchant_vpa?: string;
2603
- };
2604
- type PaymentConfigurationCreateResponse = {
2605
- success: boolean;
2606
- oauth_url?: string;
2607
- expiration?: number;
2608
- };
2609
- type PaymentConfigurationUpdateResponse = PaymentConfigurationCreateResponse;
2610
- type PaymentConfigurationOauthLinkRequest = {
2611
- configuration_name: string;
2612
- redirect_url?: string;
2613
- };
2614
- type PaymentConfigurationOauthLinkResponse = {
2615
- oauth_url: string;
2616
- expiration?: number;
2617
- };
2618
- type PaymentConfigurationDeleteRequest = {
2619
- configuration_name: string;
2620
- };
2621
- interface PaymentsClass {
2622
- listPaymentConfigurations(wabaId: string): Promise<PaymentConfigurationsResponse>;
2623
- getPaymentConfiguration(wabaId: string, configurationName: string): Promise<PaymentConfigurationsResponse>;
2624
- createPaymentConfiguration(wabaId: string, params: PaymentConfigurationCreateRequest): Promise<PaymentConfigurationCreateResponse>;
2625
- updatePaymentConfiguration(wabaId: string, configurationName: string, params: PaymentConfigurationUpdateRequest): Promise<PaymentConfigurationUpdateResponse>;
2626
- generatePaymentConfigurationOauthLink(wabaId: string, params: PaymentConfigurationOauthLinkRequest): Promise<PaymentConfigurationOauthLinkResponse>;
2627
- deletePaymentConfiguration(wabaId: string, params: PaymentConfigurationDeleteRequest): Promise<ResponseSuccess>;
2685
+ interface WebhookEvent {
2686
+ field: string;
2687
+ value: any;
2688
+ timestamp: number;
2628
2689
  }
2629
2690
  //#endregion
2630
2691
  //#region src/utils/isMetaError.d.ts
@@ -3046,90 +3107,31 @@ interface FlowClass {
3046
3107
  }): Promise<FlowMigrationResponse>;
3047
3108
  }
3048
3109
  //#endregion
3049
- //#region src/api/blockUsers/types/blockUsers.d.ts
3050
- /**
3051
- * Blocked user information in response
3052
- */
3053
- type BlockedUserInfo = {
3054
- input: string;
3055
- wa_id: string;
3056
- };
3057
- /**
3058
- * Failed user information with error details
3059
- * Uses common MetaErrorDetail type for consistency across APIs
3060
- */
3061
- type FailedUserInfo = BlockedUserInfo & {
3062
- errors?: MetaErrorDetail[];
3063
- };
3064
- /**
3065
- * Response for block/unblock operations
3066
- */
3067
- type BlockUsersResponse = {
3068
- messaging_product: 'whatsapp';
3069
- block_users: {
3070
- added_users?: BlockedUserInfo[];
3071
- failed_users?: FailedUserInfo[];
3072
- };
3073
- };
3074
- /**
3075
- * Pagination cursors for list operations
3076
- */
3077
- type PagingCursors = {
3078
- after?: string;
3079
- before?: string;
3080
- };
3081
- /**
3082
- * Pagination information
3083
- */
3084
- type PagingInfo = {
3085
- cursors?: PagingCursors;
3086
- previous?: string;
3087
- next?: string;
3088
- };
3089
- /**
3090
- * List blocked users response
3091
- */
3092
- type ListBlockedUsersResponse = {
3093
- data: Array<{
3094
- block_users: BlockedUserInfo[];
3095
- }>;
3096
- paging?: PagingInfo;
3097
- };
3098
- /**
3099
- * Query parameters for listing blocked users
3100
- */
3101
- type ListBlockedUsersParams = {
3102
- limit?: number;
3103
- after?: string;
3104
- before?: string;
3105
- };
3106
- /**
3107
- * Block Users API Interface
3108
- */
3109
- interface BlockUsersClass {
3110
- /**
3111
- * Block one or more WhatsApp users
3112
- * @param users - Array of phone numbers or WhatsApp IDs to block
3113
- * @returns Response with successfully blocked and failed users
3114
- * @throws Error if users have not messaged in last 24 hours
3115
- * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
3116
- */
3117
- block(users: string[]): Promise<BlockUsersResponse>;
3118
- /**
3119
- * Unblock one or more WhatsApp users
3120
- * @param users - Array of phone numbers or WhatsApp IDs to unblock
3121
- * @returns Response with successfully unblocked and failed users
3122
- * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
3123
- */
3124
- unblock(users: string[]): Promise<BlockUsersResponse>;
3125
- /**
3126
- * Get list of blocked WhatsApp users with pagination
3127
- * @param params - Optional pagination parameters
3128
- * @returns List of blocked users with pagination info
3129
- * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
3130
- */
3131
- listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
3110
+ //#region src/types/httpsClient.d.ts
3111
+ type ResponseHeaderValue = string | string[] | undefined;
3112
+ type ResponseHeaders = Record<string, ResponseHeaderValue>;
3113
+ type ResponseJSONBody = Record<string, unknown>;
3114
+ declare class HttpsClientResponseClass {
3115
+ constructor(resp: Response);
3116
+ statusCode: () => number;
3117
+ headers: () => ResponseHeaders;
3118
+ rawResponse: () => Response;
3119
+ json: () => Promise<ResponseJSONBody>;
3120
+ }
3121
+ declare class HttpsClientClass {
3122
+ constructor();
3123
+ clearSockets: () => boolean;
3124
+ sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
3125
+ }
3126
+ //#endregion
3127
+ //#region src/types/logger.d.ts
3128
+ interface LoggerInterface {
3129
+ log(...data: any[]): void;
3130
+ error(...data: any[]): void;
3131
+ warn(...data: any[]): void;
3132
+ info(...data: any[]): void;
3133
+ debug(...data: any[]): void;
3132
3134
  }
3133
3135
  //#endregion
3134
3136
  export { type AcceptCallRequest, type AccountMode, type ApiPermissionErrorCode, type AudioMediaObject, AudioMediaTypesEnum, type AudioMessage, type AuthenticationTemplateOptions, type BaseClass, type BlockUsersClass, type BlockUsersResponse, type BlockedUserInfo, type BodyOptions, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, BusinessVerticalEnum, type ButtonMessage, type ButtonOptions, ButtonPositionEnum, type CallAction, type CallActionResponse, type CallHours, type CallHoursDay, type CallHoursStatus, type CallIconVisibility, type CallPermission, type CallPermissionAction, type CallPermissionLimit, type CallPermissionsResponse, type CallSdpType, type CallSession, type CallbackPermissionStatus, type CallingClass, type CallingSettings, type CallingSettingsResponse, type CallingStatus, type CarouselCard, type CarouselOptions, type CatalogButton, type CatalogTemplateOptions, CategoryEnum, type CodeVerificationStatus, type CommerceClass, type CommerceSetting, type CommerceSettingsResponse, type ComponentTypes, ComponentTypesEnum, type ContactObject, type ContactsMessage, ConversationTypesEnum, type CopyCodeButton, type CouponTemplateOptions, CreateFlowResponse, type CreateQrCodeRequest, CurrencyCodesEnum, type CurrencyParameter, type Cursors, DataLocalizationRegionEnum, type DateTimeParameter, type DocumentMediaObject, DocumentMediaTypesEnum, type DocumentMessage, type EncryptionPublicKeyResponse, type ErrorWebhookValue, type FailedUserInfo, type Flow, FlowActionEnum, type FlowAsset, type FlowAssetsResponse, type FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type GroupCreateRequest, type GroupCreateResponse, type GroupInfoField, type GroupInfoFieldsParam, type GroupInfoResponse, type GroupInviteLinkResponse, type GroupJoinApprovalMode, type GroupJoinRequest, type GroupJoinRequestError, type GroupJoinRequestFailure, type GroupJoinRequestsActionResponse, type GroupJoinRequestsResponse, type GroupListParams, type GroupListResponse, type GroupMessage, type GroupParticipant, type GroupSettingsResponse, type GroupsClass, type HeaderOptions, type HealthStatus, type HealthStatusEntity, type HolidaySchedule, HttpMethodsEnum, type HttpsClientClass, type HttpsClientResponseClass, type ImageMediaObject, ImageMediaTypesEnum, type ImageMessage, type InitiateCallRequest, type InitiateCallResponse, type InteractiveButtonReplyMessage, type InteractiveListReplyMessage, type InteractiveMessage, type InteractiveObject, InteractiveTypesEnum, LanguagesEnum, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, type ListBlockedUsersParams, type ListBlockedUsersResponse, type LocationMessage, type LocationObject, type LocationParameter, type LoggerInterface, type MPMButton, type MPMTemplateOptions, type MarketingMessageRequest, type MarketingMessagesClass, type MediaCardCarouselTemplateOptions, type MediaCarouselCard, MediaClass, type MediaParameter, MediaResponse, MediasResponse, type MessageRequestBody, type MessageRequestParams, type MessageTemplateObject, MessageTypesEnum, type MessageWebhookValue, type MessagesClass, type MessagesResponse, type MessagingLimitTier, type MetaError, type MetaErrorData, type MetaErrorDetail, type OTPButton, type OTPTemplateOptions, type OrderMessage, type Pagination, type PaginationCursors, type Paging, ParametersTypesEnum, type PaymentConfiguration, type PaymentConfigurationCode, type PaymentConfigurationCreateRequest, type PaymentConfigurationCreateResponse, type PaymentConfigurationDeleteRequest, type PaymentConfigurationOauthLinkRequest, type PaymentConfigurationOauthLinkResponse, type PaymentConfigurationProvider, type PaymentConfigurationStatus, type PaymentConfigurationUpdateRequest, type PaymentConfigurationUpdateResponse, type PaymentConfigurationsResponse, type PaymentsClass, type PhoneNumberButton, type PhoneNumberClass, type PhoneNumberResponse, type PhoneNumbersResponse, type PlatformType, type PreAcceptCallRequest, type ProductCardCarouselTemplateOptions, type ProductCarouselCard, type ProductParameter, type ProductSection, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, type QualityRating, type QualityScore, type QuickReplyButton, type ReactionMessage, type ReactionParams, ReferralSourceTypesEnum, type RegistrationClass, type RegistrationRequest, type RejectCallRequest, RequestCodeMethodsEnum, type RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, type SPMButton, type SPMTemplateOptions, type SipServer, type SipSettings, type SipStatus, StatusEnum, type StatusParams, type StatusWebhook, type StatusWebhookValue, type StickerMediaObject, StickerMediaTypesEnum, type StickerMessage, SubTypeEnum, SystemChangeTypesEnum, type SystemMessage, type TemplateBody, type TemplateButton, type TemplateButtons, type TemplateCarousel, type TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateLimitedTimeOffer, type TemplateOptions, type TemplateParameter, type TemplateRequestBody, type TemplateResponse, TemplateStatusEnum, type TerminateCallRequest, type TextMessage, type TextMessageParams, type TextObject, type TextParameter, type Throughput, type ThroughputLevel, type TwoStepVerificationClass, type TwoStepVerificationParams, type TwoStepVerificationRequest, type URLButton, type UnsupportedMessage, type UpdateBusinessProfileRequest, type UpdateCallingSettingsRequest, type UpdateCommerceSettingsRequest, type UpdateFlowResponse, type UpdateGroupSettingsRequest, type UpdateQrCodeRequest, type UpdateWabaSubscription, UploadMediaResponse, type ValidateFlowJsonResponse, type VerifyCodeRequest, type VideoMediaObject, VideoMediaTypesEnum, type VideoMessage, type WABAClass, type WabaAccount, type WabaAccountFields, type WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, type WabaHealthStatus, WabaHealthStatusCanSendMessage, type WabaHealthStatusEntity, type WabaHealthStatusError, type WabaSubscription, type WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookMessage, type WebhookPayload, WebhookTypesEnum, type WebhookValue, type WeeklyOperatingHours, type WhatsAppConfig, type WhatsAppErrorCode, type WhatsAppMessage };
3135
- //# sourceMappingURL=index-CNpKf-Cm.d.ts.map
3137
+ //# sourceMappingURL=index.d.ts.map