meta-cloud-api 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/BusinessProfileApi-DDkv2WQK.d.ts +352 -0
  2. package/dist/EncryptionApi-CwxQlC-2.d.ts +21 -0
  3. package/dist/FlowApi-BIBrWYEv.d.ts +471 -0
  4. package/dist/MediaApi-VqxndaBJ.d.ts +89 -0
  5. package/dist/MessageApi-CHc6bn3g.d.ts +591 -0
  6. package/dist/PhoneNumberApi-C-bs6YAe.d.ts +141 -0
  7. package/dist/QrCodeApi-BjlyPUXV.d.ts +97 -0
  8. package/dist/RegistrationApi-D7Bg8BUz.d.ts +46 -0
  9. package/dist/TemplateApi-dmZbvMkO.d.ts +117 -0
  10. package/dist/TwoStepVerificationApi-DaYWPjY_.d.ts +32 -0
  11. package/dist/WabaApi-CMoTCWiH.d.ts +174 -0
  12. package/dist/base-BG2gtoDs.d.ts +46 -0
  13. package/dist/chunk-2NJVBJUN.js +2 -0
  14. package/dist/chunk-2NJVBJUN.js.map +1 -0
  15. package/dist/chunk-3MO3BTBC.js +2 -0
  16. package/dist/chunk-3MO3BTBC.js.map +1 -0
  17. package/dist/chunk-4C666HHU.js +2 -0
  18. package/dist/chunk-4C666HHU.js.map +1 -0
  19. package/dist/chunk-5JGM556C.js +2 -0
  20. package/dist/chunk-5JGM556C.js.map +1 -0
  21. package/dist/chunk-7GL74SXM.js +2 -0
  22. package/dist/chunk-7GL74SXM.js.map +1 -0
  23. package/dist/chunk-7NQLQPLH.js +2 -0
  24. package/dist/chunk-7NQLQPLH.js.map +1 -0
  25. package/dist/chunk-A264MT4Q.js +2 -0
  26. package/dist/chunk-A264MT4Q.js.map +1 -0
  27. package/dist/chunk-BZ5QDXNR.js +2 -0
  28. package/dist/chunk-BZ5QDXNR.js.map +1 -0
  29. package/dist/chunk-EYGUX4EA.js +2 -0
  30. package/dist/chunk-EYGUX4EA.js.map +1 -0
  31. package/dist/chunk-FFOE5YKT.js +2 -0
  32. package/dist/chunk-FFOE5YKT.js.map +1 -0
  33. package/dist/chunk-GIQLIMOD.js +2 -0
  34. package/dist/chunk-GIQLIMOD.js.map +1 -0
  35. package/dist/chunk-KFPOVYEJ.js +2 -0
  36. package/dist/chunk-KFPOVYEJ.js.map +1 -0
  37. package/dist/chunk-O2OTHNWM.js +2 -0
  38. package/dist/chunk-O2OTHNWM.js.map +1 -0
  39. package/dist/chunk-UQPD6GIF.js +2 -0
  40. package/dist/chunk-UQPD6GIF.js.map +1 -0
  41. package/dist/chunk-VW3LGHTJ.js +2 -0
  42. package/dist/chunk-VW3LGHTJ.js.map +1 -0
  43. package/dist/chunk-XIIJD6SG.js +2 -0
  44. package/dist/chunk-XIIJD6SG.js.map +1 -0
  45. package/dist/chunk-XPPDOFBN.js +2 -0
  46. package/dist/chunk-XPPDOFBN.js.map +1 -0
  47. package/dist/enums-Z1f7QuVx.d.ts +687 -0
  48. package/dist/features/encryption/index.d.ts +9 -0
  49. package/dist/features/encryption/index.js +2 -0
  50. package/dist/{types/index.mjs.map → features/encryption/index.js.map} +1 -1
  51. package/dist/features/flow/index.d.ts +9 -0
  52. package/dist/features/flow/index.js +2 -0
  53. package/dist/{utils/index.mjs.map → features/flow/index.js.map} +1 -1
  54. package/dist/features/media/index.d.ts +9 -0
  55. package/dist/features/media/index.js +2 -0
  56. package/dist/{api/index.mjs.map → features/media/index.js.map} +1 -1
  57. package/dist/features/messages/index.d.ts +9 -0
  58. package/dist/features/messages/index.js +2 -0
  59. package/dist/features/messages/index.js.map +1 -0
  60. package/dist/features/phone/index.d.ts +9 -0
  61. package/dist/features/phone/index.js +2 -0
  62. package/dist/features/phone/index.js.map +1 -0
  63. package/dist/features/profile/index.d.ts +9 -0
  64. package/dist/features/profile/index.js +2 -0
  65. package/dist/features/profile/index.js.map +1 -0
  66. package/dist/features/qrCode/index.d.ts +9 -0
  67. package/dist/features/qrCode/index.js +2 -0
  68. package/dist/features/qrCode/index.js.map +1 -0
  69. package/dist/features/registration/index.d.ts +9 -0
  70. package/dist/features/registration/index.js +2 -0
  71. package/dist/features/registration/index.js.map +1 -0
  72. package/dist/features/template/index.d.ts +9 -0
  73. package/dist/features/template/index.js +2 -0
  74. package/dist/features/template/index.js.map +1 -0
  75. package/dist/features/twoStepVerification/index.d.ts +9 -0
  76. package/dist/features/twoStepVerification/index.js +2 -0
  77. package/dist/features/twoStepVerification/index.js.map +1 -0
  78. package/dist/features/waba/index.d.ts +9 -0
  79. package/dist/features/waba/index.js +2 -0
  80. package/dist/features/waba/index.js.map +1 -0
  81. package/dist/{types/index.d.mts → index.d.ts} +222 -72
  82. package/dist/index.js +3 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/shared/types/config.d.ts +78 -0
  85. package/dist/shared/types/config.js +2 -0
  86. package/dist/shared/types/config.js.map +1 -0
  87. package/dist/shared/types/enums.d.ts +1 -0
  88. package/dist/shared/types/enums.js +2 -0
  89. package/dist/shared/types/enums.js.map +1 -0
  90. package/dist/shared/utils/isMetaError.d.ts +21 -0
  91. package/dist/shared/utils/isMetaError.js +2 -0
  92. package/dist/shared/utils/isMetaError.js.map +1 -0
  93. package/package.json +81 -15
  94. package/dist/api/index.d.mts +0 -496
  95. package/dist/api/index.mjs +0 -2
  96. package/dist/chunk-KZQQJAPX.mjs +0 -2
  97. package/dist/chunk-KZQQJAPX.mjs.map +0 -1
  98. package/dist/chunk-N7A7DQDX.mjs +0 -2
  99. package/dist/chunk-N7A7DQDX.mjs.map +0 -1
  100. package/dist/chunk-QE4PKOSW.mjs +0 -2
  101. package/dist/chunk-QE4PKOSW.mjs.map +0 -1
  102. package/dist/chunk-R4CFE2XP.mjs +0 -2
  103. package/dist/chunk-R4CFE2XP.mjs.map +0 -1
  104. package/dist/chunk-XVYL7ZTG.mjs +0 -2
  105. package/dist/chunk-XVYL7ZTG.mjs.map +0 -1
  106. package/dist/index.d.mts +0 -145
  107. package/dist/index.mjs +0 -3
  108. package/dist/index.mjs.map +0 -1
  109. package/dist/types/index.mjs +0 -2
  110. package/dist/utils/index.d.mts +0 -71
  111. package/dist/utils/index.mjs +0 -2
  112. package/dist/waba-RRlZTQUG.d.mts +0 -2229
  113. package/dist/whatsapp-BNHXjrds.d.mts +0 -46
@@ -1,496 +0,0 @@
1
- import { h as BaseClass, d as WabaConfigType, c as RequesterClass, H as HttpMethodsEnum, B as BusinessProfileClass, j as BusinessProfileFieldsParam, l as BusinessProfileResponse, U as UpdateBusinessProfileRequest, bm as ResponseSuccess, n as UploadSessionResponse, o as UploadBusinessProfileResponse, p as UploadHandle, E as EncryptionClass, q as EncryptionPublicKeyResponse, F as FlowClass, a6 as FlowsListResponse, $ as FlowCategoryEnum, ad as CreateFlowResponse, a3 as Flow, aa as FlowPreviewResponse, a8 as FlowAssetsResponse, ae as UpdateFlowResponse, ag as ValidateFlowJsonResponse, af as FlowMigrationResponse, b as MediaClass, as as MediaResponse, au as UploadMediaResponse, M as MessagesClass, e as MessageTypesEnum, aA as AudioMediaObject, aC as ContactObject, aE as DocumentMediaObject, aG as ImageMediaObject, aI as InteractiveObject, aT as LocationObject, aR as MessageTemplateObject, v as ComponentTypesEnum, aK as StickerMediaObject, aN as TextObject, aP as VideoMediaObject, az as MessageRequestBody, aW as MessageRequestParams, aV as MessagesResponse, aX as TextMessageParams, aZ as StatusParams, I as InteractiveTypesEnum, aY as ReactionParams, P as PhoneNumberClass, b8 as PhoneNumberResponse, ba as PhoneNumbersResponse, bb as RequestVerificationCodeRequest, bc as VerifyCodeRequest, Q as QrCodeClass, bg as CreateQrCodeRequest, be as QrCodeResponse, bf as QrCodesResponse, bh as UpdateQrCodeRequest, R as RegistrationClass, Y as DataLocalizationRegionEnum, T as TemplateClass, bG as TemplateResponse, bF as TemplateRequestBody, bH as TemplateGetParams, bo as ResponsePagination, bI as TemplateDeleteParams, a as TwoStepVerificationClass, W as WABAClass, bW as WabaAccountFieldsParam, bU as WabaAccount, bM as WabaSubscriptions, bL as UpdateWabaSubscription } from '../waba-RRlZTQUG.mjs';
2
- import 'http';
3
-
4
- declare class BaseAPI implements BaseClass {
5
- protected config: WabaConfigType;
6
- protected client: RequesterClass;
7
- constructor(config: WabaConfigType, client: RequesterClass);
8
- protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
9
- protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
10
- protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
11
- }
12
-
13
- /**
14
- * API for managing WhatsApp Business Profiles and profile pictures.
15
- *
16
- * This API allows you to:
17
- * - Get business profile information
18
- * - Update business profile details
19
- * - Upload profile pictures using a three-step process:
20
- * 1. Create an upload session
21
- * 2. Upload the image binary data
22
- * 3. Get the upload handle to use when updating the profile
23
- */
24
- declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {
25
- private readonly endpoint;
26
- constructor(config: WabaConfigType, client: RequesterClass);
27
- /**
28
- * Get your business profile information.
29
- *
30
- * Use this method to retrieve details about your WhatsApp business profile, including
31
- * about text, address, description, email, profile picture URL, websites, and vertical.
32
- *
33
- * @param fields Fields to be returned in the response. If not specified, all fields will be returned.
34
- * Possible values: about, address, description, email, profile_picture_url, websites, vertical
35
- * @returns The business profile information.
36
- *
37
- * @example
38
- * // Get all business profile fields
39
- * const profile = await whatsappClient.businessProfile.getBusinessProfile();
40
- *
41
- * // Get specific business profile fields
42
- * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
43
- *
44
- * // Using the BusinessProfileFieldsParam type
45
- * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);
46
- */
47
- getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
48
- /**
49
- * Update your business profile.
50
- *
51
- * Use this method to update one or more fields of your WhatsApp business profile.
52
- *
53
- * @param updateRequest The request object containing the fields to update.
54
- * - messaging_product: Required. Always set to "whatsapp".
55
- * - about: Optional. Business's About text (1-139 characters).
56
- * - address: Optional. Business address (max 256 characters).
57
- * - description: Optional. Business description (max 512 characters).
58
- * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
59
- * - email: Optional. Contact email (valid format, max 128 characters).
60
- * - websites: Optional. Up to 2 URLs (max 256 characters each).
61
- * - profile_picture_handle: Optional. Handle from upload process.
62
- * @returns Response indicating success or failure.
63
- *
64
- * @example
65
- * // Update business profile with multiple fields including vertical using enum
66
- * await whatsappClient.businessProfile.updateBusinessProfile({
67
- * messaging_product: 'whatsapp',
68
- * about: 'We provide excellent service',
69
- * email: 'contact@example.com',
70
- * websites: ['https://example.com'],
71
- * vertical: BusinessVerticalEnum.RETAIL
72
- * });
73
- */
74
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
75
- /**
76
- * Create an upload session for a profile picture.
77
- *
78
- * This is the first step in the profile picture upload process.
79
- *
80
- * @param fileLength Length of the file to be uploaded in bytes.
81
- * @param fileType MIME type of the file (e.g., 'image/jpeg').
82
- * @param fileName Name of the file with extension.
83
- * @returns Response containing the upload session ID needed for the next step.
84
- *
85
- * @example
86
- * // Create upload session for profile picture
87
- * const session = await whatsappClient.businessProfile.createUploadSession(
88
- * fileBuffer.length,
89
- * 'image/jpeg',
90
- * 'profile.jpg'
91
- * );
92
- * const uploadSessionId = session.upload_session_id;
93
- */
94
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
95
- /**
96
- * Upload media file to the upload session.
97
- *
98
- * This is the second step in the profile picture upload process.
99
- * Upload the binary content of the file to the previously created upload session.
100
- *
101
- * @param uploadId The upload session ID from createUploadSession response.
102
- * @param file The binary data of the file (Buffer).
103
- * @returns Response indicating success or failure.
104
- *
105
- * @example
106
- * // Upload the actual file content
107
- * await whatsappClient.businessProfile.uploadMedia(
108
- * uploadSessionId,
109
- * fileBuffer
110
- * );
111
- */
112
- uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
113
- /**
114
- * Get the upload handle information.
115
- *
116
- * This is the third step in the profile picture upload process.
117
- * After uploading the file, get the handle to use when updating the profile.
118
- *
119
- * @param uploadId The upload session ID from createUploadSession response.
120
- * @returns Response containing the upload handle information.
121
- *
122
- * @example
123
- * // Complete profile picture update process
124
- * // 1. Create upload session
125
- * const session = await whatsappClient.businessProfile.createUploadSession(
126
- * fileBuffer.length, 'image/jpeg', 'profile.jpg'
127
- * );
128
- *
129
- * // 2. Upload the image data
130
- * await whatsappClient.businessProfile.uploadMedia(
131
- * session.upload_session_id, fileBuffer
132
- * );
133
- *
134
- * // 3. Get the handle for the uploaded file
135
- * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
136
- * session.upload_session_id
137
- * );
138
- *
139
- * // 4. Update profile with new picture and business information
140
- * await whatsappClient.businessProfile.updateBusinessProfile({
141
- * messaging_product: 'whatsapp',
142
- * profile_picture_handle: handleInfo.handle,
143
- * vertical: BusinessVerticalEnum.RESTAURANT,
144
- * about: 'Delicious food served daily'
145
- * });
146
- */
147
- getUploadHandle(uploadId: string): Promise<UploadHandle>;
148
- }
149
-
150
- declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
151
- private readonly endpoint;
152
- constructor(config: WabaConfigType, client: RequesterClass);
153
- getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
154
- setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
155
- }
156
-
157
- declare class FlowAPI extends BaseAPI implements FlowClass {
158
- constructor(config: WabaConfigType, client: RequesterClass);
159
- /**
160
- * List Flows
161
- *
162
- * @param wabaId - The WABA ID
163
- * @returns Promise with the list of flows
164
- */
165
- listFlows(wabaId: string): Promise<FlowsListResponse>;
166
- /**
167
- * Create Flow
168
- *
169
- * @param wabaId - The WABA ID
170
- * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
171
- * @returns Promise with the created flow ID and validation errors if any
172
- */
173
- createFlow(wabaId: string, data: {
174
- name: string;
175
- categories?: FlowCategoryEnum[];
176
- endpoint_uri?: string;
177
- clone_flow_id?: string;
178
- flow_json?: string;
179
- publish?: boolean;
180
- }): Promise<CreateFlowResponse>;
181
- /**
182
- * Get Flow details
183
- *
184
- * @param flowId - The flow ID
185
- * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')
186
- * @param dateFormat - Optional date format
187
- * @returns Promise with the flow details or preview response
188
- */
189
- getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
190
- /**
191
- * Get Flow Preview URL
192
- *
193
- * @param flowId - The flow ID
194
- * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.
195
- * @returns Promise with the flow preview details
196
- */
197
- getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
198
- /**
199
- * Update Flow Metadata
200
- *
201
- * @param flowId - The flow ID
202
- * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)
203
- * @returns Promise with the success status
204
- */
205
- updateFlowMetadata(flowId: string, data: {
206
- name?: string;
207
- categories?: FlowCategoryEnum[];
208
- endpoint_uri?: string;
209
- application_id?: string;
210
- }): Promise<ResponseSuccess>;
211
- /**
212
- * Delete Flow (only works if the Flow is in DRAFT status)
213
- *
214
- * @param flowId - The flow ID
215
- * @returns Promise with the success status
216
- */
217
- deleteFlow(flowId: string): Promise<ResponseSuccess>;
218
- /**
219
- * List Assets (e.g., get Flow JSON download URL)
220
- *
221
- * @param flowId - The flow ID
222
- * @returns Promise with the list of assets
223
- */
224
- listAssets(flowId: string): Promise<FlowAssetsResponse>;
225
- /**
226
- * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.
227
- *
228
- * @param flowId - The flow ID
229
- * @param data - Object containing the file data and optional name.
230
- * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.
231
- * @param data.name - Optional name for the asset, defaults to 'flow.json'.
232
- * @returns Promise with the success status and validation errors, if any.
233
- */
234
- updateFlowJson(flowId: string, data: {
235
- file: Blob | Buffer | object;
236
- name?: string;
237
- }): Promise<UpdateFlowResponse>;
238
- /**
239
- * Validate Flow JSON by attempting an update without publishing.
240
- * This is a convenience method; the API doesn't have a dedicated validation endpoint.
241
- *
242
- * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
243
- * @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob.
244
- * @returns Promise indicating if the JSON is valid and includes validation errors if any.
245
- */
246
- validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
247
- /**
248
- * Publish Flow
249
- *
250
- * @param flowId - The flow ID
251
- * @returns Promise with the success status
252
- */
253
- publishFlow(flowId: string): Promise<ResponseSuccess>;
254
- /**
255
- * Deprecate Flow
256
- *
257
- * @param flowId - The flow ID
258
- * @returns Promise with the success status
259
- */
260
- deprecateFlow(flowId: string): Promise<ResponseSuccess>;
261
- /**
262
- * Migrate Flows between WABAs
263
- *
264
- * @param destinationWabaId - The destination WABA ID
265
- * @param data - The migration data including source_waba_id and optional source_flow_names
266
- * @returns Promise with migration results (successes and failures)
267
- */
268
- migrateFlows(destinationWabaId: string, data: {
269
- source_waba_id: string;
270
- source_flow_names?: string[];
271
- }): Promise<FlowMigrationResponse>;
272
- }
273
-
274
- declare class MediaAPI extends BaseAPI implements MediaClass {
275
- private readonly endpoint;
276
- constructor(config: WabaConfigType, client: RequesterClass);
277
- getMediaById(mediaId: string): Promise<MediaResponse>;
278
- uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
279
- deleteMedia(mediaId: string): Promise<ResponseSuccess>;
280
- downloadMedia(mediaUrl: string): Promise<Blob>;
281
- }
282
-
283
- /**
284
- * Maps each message type to its appropriate payload type
285
- */
286
- type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
287
- message_id: string;
288
- emoji: string;
289
- } : never;
290
- declare class MessagesApi extends BaseAPI implements MessagesClass {
291
- private readonly commonMethod;
292
- private readonly commonEndpoint;
293
- constructor(config: WabaConfigType, client: RequesterClass);
294
- /**
295
- * Builds the request body for WhatsApp API messages
296
- * @param type The type of message to send
297
- * @param payload The message payload object
298
- * @param to The recipient's phone number
299
- * @param replyMessageId Optional message ID to reply to
300
- * @returns The formatted request body
301
- */
302
- bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
303
- /**
304
- * Sends a request to the WhatsApp API
305
- * @param body The request body to send
306
- * @returns Promise with the API response
307
- */
308
- private send;
309
- /**
310
- * Sends an audio message via WhatsApp
311
- * @param params The audio message parameter object
312
- * @returns Promise with the message response
313
- */
314
- audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
315
- /**
316
- * Sends a contact card via WhatsApp
317
- * @param params The contact message parameter object
318
- * @returns Promise with the message response
319
- */
320
- contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
321
- /**
322
- * Sends a document via WhatsApp
323
- * @param params The document message parameter object
324
- * @returns Promise with the message response
325
- */
326
- document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
327
- /**
328
- * Sends an image via WhatsApp
329
- * @param params The image message parameter object
330
- * @returns Promise with the message response
331
- */
332
- image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
333
- /**
334
- * Sends an interactive message via WhatsApp
335
- * @param params The interactive message parameter object
336
- * @returns Promise with the message response
337
- */
338
- interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
339
- /**
340
- * Sends a location via WhatsApp
341
- * @param params The location message parameter object
342
- * @returns Promise with the message response
343
- */
344
- location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
345
- /**
346
- * Sends a sticker via WhatsApp
347
- * @param params The sticker message parameter object
348
- * @returns Promise with the message response
349
- */
350
- sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
351
- /**
352
- * Sends a template message via WhatsApp
353
- * @param params The template message parameter object
354
- * @returns Promise with the message response
355
- */
356
- template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
357
- /**
358
- * Sends a text message via WhatsApp
359
- * @param params The text message parameter object
360
- * @returns Promise with the message response
361
- */
362
- text(params: TextMessageParams): Promise<MessagesResponse>;
363
- /**
364
- * Sends a video via WhatsApp
365
- * @param params The video message parameter object
366
- * @returns Promise with the message response
367
- */
368
- video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
369
- /**
370
- * Updates message status (used for read receipts and typing indicators)
371
- * @param params The status update parameter object
372
- * @returns Promise with the response
373
- */
374
- status(params: StatusParams): Promise<MessagesResponse>;
375
- /**
376
- * Marks a message as read in WhatsApp
377
- * @param params The parameter object to mark message as read
378
- * @returns Promise with the response
379
- */
380
- markAsRead(params: {
381
- messageId: string;
382
- }): Promise<MessagesResponse>;
383
- /**
384
- * Marks a message as read and shows a typing indicator in WhatsApp
385
- * @param params The typing indicator parameter object
386
- * @returns Promise with the response
387
- */
388
- showTypingIndicator(params: {
389
- messageId: string;
390
- }): Promise<MessagesResponse>;
391
- /**
392
- * Sends an interactive list message
393
- * @param params The list message parameter object
394
- * @returns Promise with the response
395
- */
396
- interactiveList(params: MessageRequestParams<InteractiveObject & {
397
- type: InteractiveTypesEnum.List;
398
- }>): Promise<MessagesResponse>;
399
- /**
400
- * Sends an interactive CTA URL message
401
- * @param params The CTA URL message parameter object
402
- * @returns Promise with the response
403
- */
404
- interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
405
- type: InteractiveTypesEnum.CtaUrl;
406
- }>): Promise<MessagesResponse>;
407
- /**
408
- * Sends a location request message
409
- * @param params The location request message parameter object
410
- * @returns Promise with the response
411
- */
412
- interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
413
- type: InteractiveTypesEnum.LocationRequest;
414
- }>): Promise<MessagesResponse>;
415
- /**
416
- * Sends an address message to request shipping address from the user
417
- * Note: This feature is only available for businesses based in India and their India customers
418
- * @param params The address message parameter object
419
- * @returns Promise with the response
420
- */
421
- interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
422
- type: InteractiveTypesEnum.AddressMessage;
423
- }>): Promise<MessagesResponse>;
424
- /**
425
- * Sends an interactive reply buttons message
426
- * @param params The reply buttons message parameter object
427
- * @returns Promise with the response
428
- */
429
- interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
430
- type: InteractiveTypesEnum.Button;
431
- }>): Promise<MessagesResponse>;
432
- /**
433
- * Sends an interactive Flow message
434
- * @param params The Flow message parameter object
435
- * @returns Promise with the response
436
- */
437
- interactiveFlow(params: MessageRequestParams<InteractiveObject & {
438
- type: InteractiveTypesEnum.Flow;
439
- }>): Promise<MessagesResponse>;
440
- /**
441
- * Sends a reaction to a message (emoji response)
442
- * @param params The reaction message parameter object
443
- * @returns Promise with the response
444
- */
445
- reaction(params: ReactionParams): Promise<MessagesResponse>;
446
- }
447
-
448
- declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
449
- private readonly endpoint;
450
- constructor(config: WabaConfigType, client: RequesterClass);
451
- getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>;
452
- getPhoneNumbers(): Promise<PhoneNumbersResponse>;
453
- requestVerificationCode(requestVerificationCodeRequest: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
454
- verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<ResponseSuccess>;
455
- }
456
-
457
- declare class QrCodeAPI extends BaseAPI implements QrCodeClass {
458
- private readonly endpoint;
459
- constructor(config: WabaConfigType, client: RequesterClass);
460
- createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
461
- getQrCodes(): Promise<QrCodesResponse>;
462
- getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
463
- updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
464
- deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
465
- }
466
-
467
- declare class RegistrationAPI extends BaseAPI implements RegistrationClass {
468
- constructor(config: WabaConfigType, client: RequesterClass);
469
- register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
470
- deregister(): Promise<ResponseSuccess>;
471
- }
472
-
473
- declare class TemplateApi extends BaseAPI implements TemplateClass {
474
- private readonly endpoint;
475
- constructor(config: WabaConfigType, client: RequesterClass);
476
- getTemplate(templateId: string): Promise<TemplateResponse>;
477
- updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
478
- getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
479
- createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
480
- deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
481
- }
482
-
483
- declare class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {
484
- constructor(config: WabaConfigType, client: RequesterClass);
485
- setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
486
- }
487
-
488
- declare class WabaAPI extends BaseAPI implements WABAClass {
489
- constructor(config: WabaConfigType, client: RequesterClass);
490
- getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
491
- getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
492
- updateWabaSubscription({ override_callback_uri, verify_token, }: UpdateWabaSubscription): Promise<ResponseSuccess>;
493
- unsubscribeFromWaba(): Promise<ResponseSuccess>;
494
- }
495
-
496
- export { BaseAPI, BusinessProfileAPI, EncryptionAPI, FlowAPI, MediaAPI, MessagesApi as MessagesAPI, PhoneNumberApi as PhoneNumberAPI, QrCodeAPI, RegistrationAPI, TemplateApi as TemplateAPI, TwoStepVerificationAPI, WabaAPI };
@@ -1,2 +0,0 @@
1
- export{a as BaseAPI,b as BusinessProfileAPI,c as EncryptionAPI,d as FlowAPI,e as MediaAPI,f as MessagesAPI,g as PhoneNumberAPI,h as QrCodeAPI,i as RegistrationAPI,j as TemplateAPI,k as TwoStepVerificationAPI,l as WabaAPI}from'../chunk-R4CFE2XP.mjs';import'../chunk-QE4PKOSW.mjs';import'../chunk-XVYL7ZTG.mjs';//# sourceMappingURL=index.mjs.map
2
- //# sourceMappingURL=index.mjs.map
@@ -1,2 +0,0 @@
1
- var n=(s=>(s.Draft="DRAFT",s.Published="PUBLISHED",s.Throttled="THROTTLED",s.Blocked="BLOCKED",s.Deprecated="DEPRECATED",s))(n||{}),o=(t=>(t.SignUp="SIGN_UP",t.SignIn="SIGN_IN",t.AppointmentBooking="APPOINTMENT_BOOKING",t.LeadGeneration="LEAD_GENERATION",t.ContactUs="CONTACT_US",t.CustomerSupport="CUSTOMER_SUPPORT",t.Survey="SURVEY",t.Other="OTHER",t))(o||{}),a=(r=>(r.INIT="INIT",r.BACK="BACK",r.DATA_EXCHANGE="data_exchange",r))(a||{}),g=(e=>(e.Ping="ping",e.Change="data_exchange",e.Error="error",e.All="*",e))(g||{});var p=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(p||{}),l=(r=>(r.Blocked="BLOCKED",r.Limited="LIMITED",r.Available="AVAILABLE",r))(l||{}),c=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(c||{}),d=(e=>(e.Verified="verified",e.PendingSubmission="pending_submission",e.Unverified="unverified",e.Rejected="rejected",e))(d||{});var m=(r=>(r.DELIVERED="delivered",r.READ="read",r.SENT="sent",r))(m||{}),_=(i=>(i.MESSAGES="messages",i.STATUSES="statuses",i.MESSAGE_TEMPLATE_STATUS_UPDATE="message_template_status_update",i.PHONE_NUMBER_QUALITY_UPDATE="phone_number_quality_update",i.PHONE_NUMBER_NAME_UPDATE="phone_number_name_update",i.UNKNOWN="unknown",i))(_||{});export{n as a,o as b,a as c,g as d,p as e,l as f,c as g,d as h,m as i,_ as j};//# sourceMappingURL=chunk-KZQQJAPX.mjs.map
2
- //# sourceMappingURL=chunk-KZQQJAPX.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/flow.ts","../src/types/waba.ts","../src/types/webhook.ts"],"names":["FlowStatusEnum","FlowCategoryEnum","FlowActionEnum","FlowTypeEnum","WabaAccountReviewStatus","WabaHealthStatusCanSendMessage","WabaAccountStatus","WabaBusinessVerificationStatus","MessageStatus","EventField"],"mappings":"AAMO,IAAKA,OACRA,CAAA,CAAA,KAAA,CAAQ,OACRA,CAAAA,CAAAA,CAAA,UAAY,WACZA,CAAAA,CAAAA,CAAA,SAAY,CAAA,WAAA,CACZA,EAAA,OAAU,CAAA,SAAA,CACVA,CAAA,CAAA,UAAA,CAAa,aALLA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAWAC,CACRA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,OAAS,SACTA,CAAAA,CAAAA,CAAA,MAAS,CAAA,SAAA,CACTA,EAAA,kBAAqB,CAAA,qBAAA,CACrBA,CAAA,CAAA,cAAA,CAAiB,kBACjBA,CAAA,CAAA,SAAA,CAAY,aACZA,CAAA,CAAA,eAAA,CAAkB,mBAClBA,CAAA,CAAA,MAAA,CAAS,QACTA,CAAAA,CAAAA,CAAA,MAAQ,OARAA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAWAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACRA,EAAA,IAAO,CAAA,MAAA,CACPA,CAAA,CAAA,IAAA,CAAO,OACPA,CAAA,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CAAAA,CAAAA,GAAAA,CAAAA,CAAA,SAAW,UACXA,CAAAA,CAAAA,CAAA,QAAW,CAAA,UAAA,CACXA,EAAA,8BAAiC,CAAA,gCAAA,CACjCA,CAAA,CAAA,2BAAA,CAA8B,8BAC9BA,CAAA,CAAA,wBAAA,CAA2B,2BAC3BA,CAAA,CAAA,OAAA,CAAU,UANFA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"chunk-KZQQJAPX.mjs","sourcesContent":["import { IncomingHttpHeaders, IncomingMessage } from 'http';\nimport { ResponseSuccess } from './request';\n\n/**\n * Enum for Flow Status\n */\nexport enum FlowStatusEnum {\n Draft = 'DRAFT',\n Published = 'PUBLISHED',\n Throttled = 'THROTTLED',\n Blocked = 'BLOCKED',\n Deprecated = 'DEPRECATED',\n}\n\n/**\n * Enum for Flow Categories\n */\nexport enum FlowCategoryEnum {\n SignUp = 'SIGN_UP',\n SignIn = 'SIGN_IN',\n AppointmentBooking = 'APPOINTMENT_BOOKING',\n LeadGeneration = 'LEAD_GENERATION',\n ContactUs = 'CONTACT_US',\n CustomerSupport = 'CUSTOMER_SUPPORT',\n Survey = 'SURVEY',\n Other = 'OTHER',\n}\n\nexport enum FlowActionEnum {\n INIT = 'INIT',\n BACK = 'BACK',\n DATA_EXCHANGE = 'data_exchange',\n}\n\n/**\n * Enum for Flow Types in webhook handlers\n * Used to register handlers for specific flow events\n */\nexport enum FlowTypeEnum {\n /** Health check/ping requests */\n Ping = 'ping',\n /** Data exchange requests */\n Change = 'data_exchange',\n /** Error notification requests */\n Error = 'error',\n /** Match all flow action types */\n All = '*',\n}\n\n/**\n * Flow Validation Error Pointer\n */\nexport interface FlowValidationErrorPointer {\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n path: string;\n}\n\n/**\n * Flow Validation Error\n */\nexport interface FlowValidationError {\n error: string;\n error_type: string;\n message: string;\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n pointers: FlowValidationErrorPointer[];\n}\n\n/**\n * Flow Item\n */\nexport interface Flow {\n id: string;\n name: string;\n status: FlowStatusEnum;\n categories: FlowCategoryEnum[];\n validation_errors: FlowValidationError[];\n}\n\n/**\n * Pagination Cursors\n */\nexport interface PaginationCursors {\n before: string;\n after: string;\n}\n\n/**\n * Pagination Object\n */\nexport interface Pagination {\n cursors: PaginationCursors;\n}\n\n/**\n * Flows List Response\n */\nexport interface FlowsListResponse {\n data: Flow[];\n paging: Pagination;\n}\n\n/**\n * Flow Asset\n */\nexport interface FlowAsset {\n name: string;\n asset_type: string;\n download_url: string;\n}\n\n/**\n * Flow Assets Response\n */\nexport interface FlowAssetsResponse {\n data: FlowAsset[];\n paging: Pagination;\n}\n\n/**\n * Flow Preview\n */\nexport interface FlowPreview {\n preview_url: string;\n expires_at: string;\n}\n\n/**\n * Flow Preview Response\n */\nexport interface FlowPreviewResponse {\n preview: FlowPreview;\n id: string;\n}\n\n/**\n * Flow Migration Result\n */\nexport interface FlowMigrationResult {\n source_name: string;\n source_id: string;\n migrated_id: string;\n}\n\n/**\n * Flow Migration Failure\n */\nexport interface FlowMigrationFailure {\n source_name: string;\n error_code: string;\n error_message: string;\n}\n\n/**\n * Create Flow Response\n */\nexport interface CreateFlowResponse {\n id: string;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Update Flow Response\n */\nexport interface UpdateFlowResponse {\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Flow Migration Response\n */\nexport interface FlowMigrationResponse {\n migrated_flows: FlowMigrationResult[];\n failed_flows: FlowMigrationFailure[];\n}\n\n/**\n * Validate Flow JSON Response\n */\nexport interface ValidateFlowJsonResponse {\n valid: boolean;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * WhatsApp Flow Endpoint - Encrypted Request Payload\n * Represents the raw encrypted data received from WhatsApp\n */\nexport interface FlowEncryptedRequestPayload {\n encrypted_aes_key: string;\n encrypted_flow_data: string;\n initial_vector: string;\n}\n\n/**\n * WhatsApp Flow Endpoint - Decrypted Request Response\n * Represents the successfully decrypted data and encryption keys\n */\nexport interface FlowDecryptedRequestResponse {\n decryptedBody: any;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n}\n\n/**\n * WhatsApp Flow Endpoint - HTTP Request with Body\n * Represents an HTTP request with the encrypted payload\n */\nexport interface FlowHttpRequest extends IncomingMessage {\n body: FlowEncryptedRequestPayload;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Request\n * Represents the structure of a health check request\n */\nexport interface FlowHealthCheckRequest {\n action: 'ping';\n version: '3.0';\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Response\n * The expected response structure for health check requests\n */\nexport interface FlowHealthCheckResponse {\n data: {\n status: 'active';\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Request\n * Represents the structure of a data exchange request\n */\nexport interface FlowDataExchangeRequest {\n version: '3.0';\n action: FlowActionEnum;\n screen: string;\n flow_token: string;\n data?: Record<string, any> & { error_message?: string };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Response\n * The expected response structure for data exchange requests\n */\nexport interface FlowDataExchangeResponse {\n screen?: string;\n data?: Record<string, any | { error_message?: string }>;\n}\n\n/**\n * WhatsApp Flow Endpoint - Success Screen Response\n * The expected response structure for success screen requests\n */\nexport interface FlowSuccessScreenResponse {\n screen: 'SUCCESS';\n data: {\n extension_message_response?: {\n params?: {\n flow_token: string;\n [key: string]: string;\n };\n };\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Request\n * Represents the structure of an error notification request\n */\nexport interface FlowErrorNotificationRequest {\n version: '3.0';\n action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Response\n * The expected response structure for error notification requests\n */\nexport interface FlowErrorNotificationResponse {\n acknowledged: boolean;\n}\n\n/**\n * WhatsApp Flow Endpoint - Comprehensive Request Object\n * A combined type that includes all possible fields from different request types\n * with all fields being optional for flexibility\n */\nexport interface FlowEndpointRequest {\n // Common fields\n version?: '3.0';\n action?: 'ping' | FlowActionEnum;\n\n screen?: string;\n flow_token?: string;\n\n data?: Record<string, any> & {\n error_key?: string;\n error_message?: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Response\n * Union type for all possible response types from a Flow endpoint\n */\nexport type FlowEndpointResponse =\n | FlowHealthCheckResponse\n | FlowDataExchangeResponse\n | FlowErrorNotificationResponse\n | FlowSuccessScreenResponse;\n\nexport interface FlowClass {\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n listFlows(wabaId: string): Promise<FlowsListResponse>;\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse>;\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<ResponseSuccess>;\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deleteFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n listAssets(flowId: string): Promise<FlowAssetsResponse>;\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n updateFlowJson(\n flowId: string,\n data: {\n asset_type: 'FLOW_JSON';\n file: Blob;\n name: string;\n },\n ): Promise<UpdateFlowResponse>;\n\n /**\n * Validate Flow JSON by attempting an update without publishing.\n * This is a convenience method; the API doesn't have a dedicated validation endpoint.\n *\n * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).\n * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n publishFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deprecateFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse>;\n}\n","import type { ResponseSuccess } from './request';\n\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n}\n\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n currency?: string;\n}\n\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace';\n\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n","import { MessageTypesEnum } from './enums';\n\nexport interface WebhookContact {\n /**\n * WhatsApp ID of the contact. Business can respond to this contact using this ID.\n */\n wa_id: string;\n /**\n * Additional unique, alphanumeric identifier for a WhatsApp user\n */\n user_id?: string;\n /**\n * Profile of Whatsapp user\n */\n profile: {\n /**\n * The display name of the contact\n */\n name: string;\n };\n}\n\n/**\n * Represents a message received through the webhook\n * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object\n */\nexport interface WebhookMessage {\n /**\n * The message ID\n */\n id: string;\n\n /**\n * The sender's phone number\n */\n from: string;\n\n /**\n * The timestamp of the message\n */\n timestamp: string;\n\n /**\n * The type of message (text, image, etc.)\n */\n type: MessageTypesEnum;\n\n /**\n * The phone number ID that received the message\n */\n phoneNumberId: string;\n\n /**\n * The display phone number that received the message\n */\n displayPhoneNumber: string;\n\n /**\n * The profile name of the sender\n */\n profileName: string;\n\n /**\n * Text object for text messages\n */\n text?: {\n /**\n * The text content of the message\n */\n body: string;\n };\n\n /**\n * Image object for image messages\n */\n image?: {\n /**\n * The image caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the image\n */\n sha256?: string;\n /**\n * The ID for the image\n */\n id: string;\n /**\n * The MIME type of the image\n */\n mime_type: string;\n };\n\n /**\n * Video object for video messages\n */\n video?: {\n /**\n * The video caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the video\n */\n sha256?: string;\n /**\n * The ID for the video\n */\n id: string;\n /**\n * The MIME type of the video\n */\n mime_type: string;\n };\n\n /**\n * Audio object for audio messages\n */\n audio?: {\n /**\n * The ID for the audio file\n */\n id: string;\n /**\n * The MIME type of the audio file\n */\n mime_type: string;\n /**\n * Whether the audio is a voice message\n */\n voice?: boolean;\n };\n\n /**\n * Document object for document messages\n */\n document?: {\n /**\n * The document caption (if provided)\n */\n caption?: string;\n /**\n * The document filename\n */\n filename: string;\n /**\n * The SHA256 hash of the document\n */\n sha256?: string;\n /**\n * The ID for the document\n */\n id: string;\n /**\n * The MIME type of the document\n */\n mime_type: string;\n };\n\n /**\n * Sticker object for sticker messages\n */\n sticker?: {\n /**\n * The ID for the sticker\n */\n id: string;\n /**\n * Whether this is an animated sticker\n */\n animated: boolean;\n /**\n * The MIME type of the sticker\n */\n mime_type: string;\n };\n\n /**\n * Reaction object for reaction messages\n */\n reaction?: {\n /**\n * The ID of the message being reacted to\n */\n message_id: string;\n /**\n * Emoji used for the reaction\n */\n emoji: string;\n };\n\n /**\n * Contacts object for contact messages\n */\n contacts?: Array<{\n /**\n * The contact's name\n */\n name: {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n };\n /**\n * The contact's phone numbers\n */\n phones?: Array<{\n phone: string;\n type?: string;\n wa_id?: string;\n }>;\n /**\n * The contact's emails\n */\n emails?: Array<{\n email: string;\n type?: string;\n }>;\n /**\n * The contact's addresses\n */\n addresses?: Array<{\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: string;\n }>;\n /**\n * The contact's organizations\n */\n org?: {\n company?: string;\n department?: string;\n title?: string;\n };\n /**\n * The contact's URLs\n */\n urls?: Array<{\n url: string;\n type?: string;\n }>;\n /**\n * The contact's birthday (YYYY-MM-DD format)\n */\n birthday?: string;\n }>;\n\n /**\n * Location object for location messages\n */\n location?: {\n /**\n * Latitude of the location\n */\n latitude: number;\n /**\n * Longitude of the location\n */\n longitude: number;\n /**\n * Name of the location\n */\n name?: string;\n /**\n * Address of the location\n */\n address?: string;\n };\n\n /**\n * Interactive object for interactive messages\n */\n interactive?: {\n /**\n * Type of the interactive message\n * Can be: button_reply, list_reply, flow, nfm_reply, etc.\n */\n type: string;\n /**\n * ID for the button that was clicked\n */\n button_reply?: {\n id: string;\n title: string;\n };\n /**\n * ID for the list item that was selected\n */\n list_reply?: {\n id: string;\n title: string;\n description?: string;\n };\n\n /**\n * NFM (No-Code Flow Message) reply data\n */\n nfm_reply?: {\n /**\n * Response data in JSON format\n */\n response_json: string;\n /**\n * Body text of the reply\n */\n body: string;\n /**\n * Name of the flow\n */\n name: string;\n };\n };\n\n /**\n * System object for system messages (like user phone number changes)\n */\n system?: {\n /**\n * The type of system update\n */\n type: string;\n /**\n * User's identity if the update is a customer identity change\n */\n identity?: string;\n /**\n * Old and new phone numbers if the update is a phone number change\n */\n customer?: {\n /**\n * The previous phone number\n */\n previous_wa_id: string;\n /**\n * The new phone number\n */\n wa_id: string;\n };\n };\n\n /**\n * Order object for order messages\n */\n order?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product items in the order\n */\n product_items: Array<{\n /**\n * Product ID\n */\n product_retailer_id: string;\n /**\n * Quantity of the product\n */\n quantity: number;\n /**\n * Item price\n */\n item_price: number;\n /**\n * Currency code\n */\n currency: string;\n }>;\n /**\n * Text message included with the order\n */\n text?: string;\n };\n\n /**\n * Context object, included when a user replies or interacts\n */\n context?: {\n /**\n * ID of the message\n */\n id?: string;\n /**\n * ID of the sender\n */\n from?: string;\n /**\n * ID of the message being replied to or interacted with\n */\n message_id: string;\n /**\n * ID of the forwarded message, if applicable\n */\n forwarded?: boolean;\n /**\n * Frequently forwarded status\n */\n frequently_forwarded?: boolean;\n /**\n * Original message information if the message was referred\n */\n referred_product?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product ID\n */\n product_retailer_id: string;\n };\n };\n\n /**\n * Errors array, if the message had errors\n */\n errors?: Array<{\n /**\n * Error code\n */\n code: number;\n /**\n * Error title\n */\n title: string;\n /**\n * Error message\n */\n message: string;\n /**\n * Error details object\n */\n error_data?: {\n /**\n * Describes the error details\n */\n details: string;\n };\n }>;\n\n /**\n * Button object for button messages\n */\n button?: {\n /**\n * The payload for the button\n */\n payload: string;\n /**\n * Button text\n */\n text: string;\n };\n\n /**\n * The original message data as received from the webhook\n */\n originalData: any;\n}\n\n/**\n * Represents a non-message event received through the webhook\n */\nexport interface WebhookEvent {\n /**\n * The field type of the event\n */\n field: string;\n\n /**\n * The event data\n */\n value: any;\n}\n\n/**\n * Handler function for processing messages\n */\nexport type MessageHandler = (message: WebhookMessage) => void | Promise<void>;\n\n/**\n * Handler function for processing events\n */\nexport type EventHandler = (event: WebhookEvent) => void | Promise<void>;\n\n/**\n * Statuses that can be received in status updates\n */\nexport enum MessageStatus {\n DELIVERED = 'delivered',\n READ = 'read',\n SENT = 'sent',\n}\n\n/**\n * Event fields that can be received through the webhook\n */\nexport enum EventField {\n MESSAGES = 'messages',\n STATUSES = 'statuses',\n MESSAGE_TEMPLATE_STATUS_UPDATE = 'message_template_status_update',\n PHONE_NUMBER_QUALITY_UPDATE = 'phone_number_quality_update',\n PHONE_NUMBER_NAME_UPDATE = 'phone_number_name_update',\n UNKNOWN = 'unknown',\n}\n"]}
@@ -1,2 +0,0 @@
1
- import {a}from'./chunk-QE4PKOSW.mjs';import*as p from'crypto';var b=(e,r)=>p.createHmac("sha256",r).update(e,"utf-8").digest("hex");var f="UTILS",u=false,_=new a(f,process.env.DEBUG==="true"||u),l=3e3,T=30,m=2e4,g=e=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!e?.accessToken)throw _.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},N=e=>{g(e);let r={M4D_APP_ID:e?.appId||process.env.M4D_APP_ID||"",M4D_APP_SECRET:e?.appSecret||process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:e?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),WA_BUSINESS_ACCOUNT_ID:e?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:e?.apiVersion||process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:e?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:e?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:e?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:e?.listenerPort||parseInt(process.env.LISTENER_PORT||"")||l,MAX_RETRIES_AFTER_WAIT:e?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||T,REQUEST_TIMEOUT:e?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||"")||m,DEBUG:e?.debug||process.env.DEBUG==="true",FLOW_API_PRIVATE_PEM:e?.privatePem||process.env.FLOW_API_PRIVATE_PEM||"",FLOW_API_PASSPHRASE:e?.passphrase||process.env.FLOW_API_PASSPHRASE||""};return _.log(`Configuration loaded for App Id ${r.M4D_APP_ID}`),r};function P(e){return e!=null&&typeof e=="object"&&"error"in e&&typeof e.error=="object"&&e.error!=null&&"message"in e.error&&typeof e.error.message=="string"&&"type"in e.error&&typeof e.error.type=="string"&&"code"in e.error&&typeof e.error.code=="number"&&"fbtrace_id"in e.error&&typeof e.error.fbtrace_id=="string"&&(!("error_data"in e.error)||typeof e.error.error_data=="object"&&e.error.error_data!=null&&"messaging_product"in e.error.error_data&&e.error.error_data.messaging_product==="whatsapp"&&"details"in e.error.error_data&&typeof e.error.error_data.details=="string")&&(!("error_subcode"in e.error)||typeof e.error.error_subcode=="number")}function E(e){return typeof e=="object"&&e!==null}function t(e){return typeof e=="string"}var I=["data_exchange","INIT","BACK"],R=["data_exchange","INIT"];function L(e){if(!("flow_token"in e&&t(e.flow_token)&&"action"in e))return false;let{action:r,version:n,screen:o,data:s}=e,a=n==="3.0",i=I.includes(r),d=typeof o>"u"||t(o)&&o!=="SUCCESS",A=r==="data_exchange"||E(s);return a&&i&&d&&A}function U(e){if(!("flow_token"in e&&t(e.flow_token)&&"action"in e))return false;let{action:r,screen:n,data:o}=e,s=R.includes(r),a=t(n),i=E(o)&&"error_key"in o&&t(o.error)&&"error_message"in o&&t(o.error_message);return s&&a&&i}function V(e){return "action"in e&&e.action==="ping"}export{b as a,N as b,P as c,L as d,U as e,V as f};//# sourceMappingURL=chunk-N7A7DQDX.mjs.map
2
- //# sourceMappingURL=chunk-N7A7DQDX.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/generateXHub256Sig.ts","../src/utils/importConfig.ts","../src/utils/isMetaError.ts","../src/utils/flowTypeGuards.ts"],"names":["generateXHub256Sig","body","appSecret","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig","isMetaError","error","isObject","value","isString","DATA_EXCHANGE_ACTIONS","ERROR_ACTIONS","isFlowDataExchangeRequest","request","action","version","screen","data","hasValidVersion","hasValidAction","hasValidScreen","hasValidData","isFlowErrorRequest","isFlowPingRequest"],"mappings":"8DAEaA,IAAAA,CAAAA,CAAqB,CAACC,CAAcC,CAAAA,CAAAA,GAC/B,CAAW,CAAA,UAAA,CAAA,QAAA,CAAUA,CAAS,CAAA,CAAE,OAAOD,CAAM,CAAA,OAAO,CAAE,CAAA,MAAA,CAAO,KAAK,MCE9EE,CAAW,CAAA,OAAA,CACXC,CAAY,CAAA,KAAA,CACZC,CAAS,CAAA,IAAIC,EAAOH,CAAU,CAAA,OAAA,CAAQ,IAAI,KAAU,GAAA,MAAA,EAAUC,CAAS,CACvEG,CAAAA,CAAAA,CAAwB,GACxBC,CAAAA,CAAAA,CAAiC,EACjCC,CAAAA,CAAAA,CAA0B,IAE1BC,CAAsBC,CAAAA,CAAAA,EAAuC,CAC/D,GAAI,CAAC,OAAA,CAAQ,IAAI,sBAA+B,EAAA,CAACA,CAAQ,EAAA,WAAA,CACrD,MAAAN,CAAAA,CAAO,IAAI,2FAA2F,CAAA,CAChG,IAAI,KAAM,CAAA,gCAAgC,CAExD,CAEaO,CAAAA,CAAAA,CAAgBC,CAAiC,EAAA,CAC1DH,CAAmBG,CAAAA,CAAW,EAE9B,IAAMC,CAAAA,CAA6B,CAC9B,UAAA,CAAuBD,CAAa,EAAA,KAAA,EAAS,QAAQ,GAAI,CAAA,UAAA,EAAc,EACvE,CAAA,cAAA,CAA2BA,CAAa,EAAA,SAAA,EAAa,QAAQ,GAAI,CAAA,cAAA,EAAkB,GACnF,kBAA+BA,CAAAA,CAAAA,EAAa,eAAiB,MAAO,CAAA,OAAA,CAAQ,GAAI,CAAA,kBAAkB,C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AAYA,GAAAA,CAAAA,EAAWA,CAAQ,CAAA,MAAA,GAAW,MACrD","file":"chunk-N7A7DQDX.mjs","sourcesContent":["import * as crypto from 'crypto';\n\nexport const generateXHub256Sig = (body: string, appSecret: string) => {\n return crypto.createHmac('sha256', appSecret).update(body, 'utf-8').digest('hex');\n};\n","import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n [WabaConfigEnum.PrivatePem]: inputConfig?.privatePem || process.env.FLOW_API_PRIVATE_PEM || '',\n [WabaConfigEnum.Passphrase]: inputConfig?.passphrase || process.env.FLOW_API_PASSPHRASE || '',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n","export interface MetaError extends Error {\n error: {\n message: string;\n type: string;\n code: number;\n error_data?: {\n messaging_product: 'whatsapp';\n details: string;\n };\n error_subcode?: number;\n fbtrace_id: string;\n };\n}\n\n/**\n * Determines if the error is a Meta API error response\n * @param error Any error object to check\n * @returns Type guard indicating if error is a Meta API error\n */\nexport function isMetaError(error: any): error is MetaError {\n return (\n error != null &&\n typeof error === 'object' &&\n 'error' in error &&\n typeof error.error === 'object' &&\n error.error != null &&\n 'message' in error.error &&\n typeof error.error.message === 'string' &&\n 'type' in error.error &&\n typeof error.error.type === 'string' &&\n 'code' in error.error &&\n typeof error.error.code === 'number' &&\n 'fbtrace_id' in error.error &&\n typeof error.error.fbtrace_id === 'string' &&\n (!('error_data' in error.error) ||\n (typeof error.error.error_data === 'object' &&\n error.error.error_data != null &&\n 'messaging_product' in error.error.error_data &&\n error.error.error_data.messaging_product === 'whatsapp' &&\n 'details' in error.error.error_data &&\n typeof error.error.error_data.details === 'string')) &&\n (!('error_subcode' in error.error) || typeof error.error.error_subcode === 'number')\n );\n}\n","import {\n FlowActionEnum,\n FlowDataExchangeRequest,\n FlowEndpointRequest,\n FlowErrorNotificationRequest,\n FlowHealthCheckRequest,\n} from 'src/types';\n\n/**\n * Helper function to check if a value is an object\n * @param value The value to check\n * @returns True if the value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Helper function to check if a value is a string\n * @param value The value to check\n * @returns True if the value is a string\n */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n// Array of allowed action types for data exchange requests\nconst DATA_EXCHANGE_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK] as const;\n\n// Array of allowed action types for error notification requests\nconst ERROR_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT] as const;\n\n/**\n * Type guard to check if a request is a Data Exchange request\n * Validates the request structure according to the Flow API specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Data Exchange request, false otherwise\n */\nexport function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {\n action: (typeof DATA_EXCHANGE_ACTIONS)[number];\n screen?: string;\n flow_token: string;\n data?: Record<string, any>;\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, version, screen, data } = request;\n\n // Validate API version\n const hasValidVersion = version === '3.0';\n\n // Check if the action is one of the allowed actions for data exchange\n const hasValidAction = DATA_EXCHANGE_ACTIONS.includes(action as any);\n\n // Screen is optional, but when present must be a string and not 'SUCCESS'\n const hasValidScreen = typeof screen === 'undefined' || (isString(screen) && screen !== 'SUCCESS');\n\n // Data is required except for DATA_EXCHANGE action\n const hasValidData = action === FlowActionEnum.DATA_EXCHANGE || isObject(data);\n\n // All conditions must be met for a valid data exchange request\n return hasValidVersion && hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is an Error Notification request\n * Validates the request structure according to the Flow API error specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Error Notification request, false otherwise\n */\nexport function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {\n action: (typeof ERROR_ACTIONS)[number];\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, screen, data } = request;\n\n // Check if the action is one of the allowed actions for error notifications\n const hasValidAction = ERROR_ACTIONS.includes(action as any);\n\n // Screen is required for error notifications\n const hasValidScreen = isString(screen);\n\n // Validate error data structure\n const hasValidData =\n isObject(data) &&\n 'error_key' in data &&\n isString(data.error) &&\n 'error_message' in data &&\n isString(data.error_message);\n\n // All conditions must be met for a valid error notification request\n return hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is a Ping (health check) request\n * Simple validation for health check endpoints in the Flow API\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a Ping request, false otherwise\n */\nexport function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest {\n // A ping request only requires the 'action' field with value 'ping'\n return 'action' in request && request.action === 'ping';\n}\n"]}
@@ -1,2 +0,0 @@
1
- var o=class{name;debug;constructor(n,e=false){this.name=n,this.debug=e;}log(...n){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...n]);}}error(...n){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...n]);}warn(...n){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...n]);}info(...n){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...n]);}};var s=t=>{if(!t||Object.keys(t).length===0)return "";let n=new URLSearchParams;for(let[a,r]of Object.entries(t))r!==void 0&&n.append(a,String(r));let e=n.toString();return e?`?${e}`:""};export{o as a,s as b};//# sourceMappingURL=chunk-QE4PKOSW.mjs.map
2
- //# sourceMappingURL=chunk-QE4PKOSW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/logger.ts","../src/utils/objectToQueryString.ts"],"names":["Logger","name","debug","data","prefix","objectToQueryString","params","searchParams","key","value","queryString"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,KAER,CAAA,WAAA,CAAYC,EAAcC,CAAiB,CAAA,KAAA,CAAO,CAC9C,IAAK,CAAA,IAAA,CAAOD,EACZ,IAAK,CAAA,KAAA,CAAQC,EACjB,CAEA,GAAA,CAAA,GAAOC,EAAa,CAChB,GAAI,KAAK,KAAO,CAAA,CACZ,IAAIC,CAAS,CAAA,CAAA,EAAA,EAAK,KAAK,GAAI,EAAC,KACxB,IAAK,CAAA,IAAA,GACLA,GAAU,CAAM,GAAA,EAAA,IAAA,CAAK,IAAI,CAE7B,CAAA,CAAA,CAAA,OAAA,CAAQ,IAAI,KAAM,CAAA,OAAA,CAAS,CAACA,CAAQ,CAAA,IAAA,CAAM,GAAGD,CAAI,CAAC,EACtD,CACJ,CAEA,SAASA,CAAa,CAAA,CAClB,IAAIC,CAAS,CAAA,CAAA,EAAA,EAAK,KAAK,GAAI,EAAC,aACxB,IAAK,CAAA,IAAA,GACLA,GAAU,CAAM,GAAA,EAAA,IAAA,CAAK,IAAI,CAE7B,CAAA,CAAA,CAAA,OAAA,CAAQ,MAAM,KAAM,CAAA,OAAA,CAAS,CAACA,CAAQ,CAAA,IAAA,CAAM,GAAGD,CAAI,CAAC,EACxD,CAEA,IAAA,CAAA,GAAQA,EAAa,CACjB,IAAIC,EAAS,CAAK,EAAA,EAAA,IAAA,CAAK,KAAK,CAAA,SAAA,CAAA,CACxB,KAAK,IACLA,GAAAA,CAAAA,EAAU,CAAM,GAAA,EAAA,IAAA,CAAK,IAAI,CAE7B,CAAA,CAAA,CAAA,OAAA,CAAQ,KAAK,KAAM,CAAA,OAAA,CAAS,CAACA,CAAQ,CAAA,IAAA,CAAM,GAAGD,CAAI,CAAC,EACvD,CAEA,IAAA,CAAA,GAAQA,EAAa,CACjB,IAAIC,EAAS,CAAK,EAAA,EAAA,IAAA,CAAK,KAAK,CAAA,SAAA,CAAA,CACxB,KAAK,IACLA,GAAAA,CAAAA,EAAU,MAAM,IAAK,CAAA,IAAI,IAE7B,OAAQ,CAAA,IAAA,CAAK,MAAM,OAAS,CAAA,CAACA,EAAQ,IAAM,CAAA,GAAGD,CAAI,CAAC,EACvD,CACJ,EC7CO,IAAME,EAAuBC,CAAwC,EAAA,CACxE,GAAI,CAACA,CAAAA,EAAU,OAAO,IAAKA,CAAAA,CAAM,EAAE,MAAW,GAAA,CAAA,CAC1C,OAAO,EAGX,CAAA,IAAMC,EAAe,IAAI,eAAA,CAEzB,OAAW,CAACC,CAAAA,CAAKC,CAAK,CAAK,GAAA,MAAA,CAAO,QAAQH,CAAM,CAAA,CACxCG,IAAU,MACVF,EAAAA,CAAAA,CAAa,OAAOC,CAAK,CAAA,MAAA,CAAOC,CAAK,CAAC,CAAA,CAI9C,IAAMC,CAAcH,CAAAA,CAAAA,CAAa,UACjC,CAAA,OAAOG,EAAc,CAAIA,CAAAA,EAAAA,CAAW,GAAK,EAC7C","file":"chunk-QE4PKOSW.mjs","sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n"]}