meta-cloud-api 1.0.0 → 1.0.2

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 (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -0
  3. package/dist/BusinessProfileApi-WXscSgo-.d.ts +353 -0
  4. package/dist/EncryptionApi-D7pt-OXT.d.ts +22 -0
  5. package/dist/FlowApi-B2ffO-HD.d.ts +136 -0
  6. package/dist/MediaApi-BrEKpqi_.d.ts +90 -0
  7. package/dist/MessageApi-BgsSpDno.d.ts +171 -0
  8. package/dist/PhoneNumberApi-DKlu9PHl.d.ts +142 -0
  9. package/dist/QrCodeApi-7vDwIBHR.d.ts +98 -0
  10. package/dist/RegistrationApi-qO_qoti9.d.ts +47 -0
  11. package/dist/TemplateApi-xGgIZt89.d.ts +161 -0
  12. package/dist/TwoStepVerificationApi-DfNPIz-C.d.ts +33 -0
  13. package/dist/WabaApi-DqQi_68m.d.ts +175 -0
  14. package/dist/WebhookProcessor-BXYunz4N.d.ts +707 -0
  15. package/dist/WhatsApp-pTZPQm81.d.ts +82 -0
  16. package/dist/api/encryption/index.d.ts +10 -0
  17. package/dist/api/encryption/index.js +2 -0
  18. package/dist/api/encryption/index.js.map +1 -0
  19. package/dist/api/flow/index.d.ts +10 -0
  20. package/dist/api/flow/index.js +2 -0
  21. package/dist/api/flow/index.js.map +1 -0
  22. package/dist/api/index.d.ts +17 -0
  23. package/dist/api/index.js +2 -0
  24. package/dist/api/index.js.map +1 -0
  25. package/dist/api/media/index.d.ts +10 -0
  26. package/dist/api/media/index.js +2 -0
  27. package/dist/api/media/index.js.map +1 -0
  28. package/dist/api/messages/builders/index.d.ts +536 -0
  29. package/dist/api/messages/builders/index.js +4 -0
  30. package/dist/api/messages/builders/index.js.map +1 -0
  31. package/dist/api/messages/index.d.ts +10 -0
  32. package/dist/api/messages/index.js +2 -0
  33. package/dist/api/messages/index.js.map +1 -0
  34. package/dist/api/phone/index.d.ts +10 -0
  35. package/dist/api/phone/index.js +2 -0
  36. package/dist/api/phone/index.js.map +1 -0
  37. package/dist/api/profile/index.d.ts +10 -0
  38. package/dist/api/profile/index.js +2 -0
  39. package/dist/api/profile/index.js.map +1 -0
  40. package/dist/api/qrCode/index.d.ts +10 -0
  41. package/dist/api/qrCode/index.js +2 -0
  42. package/dist/api/qrCode/index.js.map +1 -0
  43. package/dist/api/registration/index.d.ts +10 -0
  44. package/dist/api/registration/index.js +2 -0
  45. package/dist/api/registration/index.js.map +1 -0
  46. package/dist/api/template/index.d.ts +215 -0
  47. package/dist/api/template/index.js +2 -0
  48. package/dist/api/template/index.js.map +1 -0
  49. package/dist/api/twoStepVerification/index.d.ts +10 -0
  50. package/dist/api/twoStepVerification/index.js +2 -0
  51. package/dist/api/twoStepVerification/index.js.map +1 -0
  52. package/dist/api/waba/index.d.ts +10 -0
  53. package/dist/api/waba/index.js +2 -0
  54. package/dist/api/waba/index.js.map +1 -0
  55. package/dist/base-CdGDdVEl.d.ts +18 -0
  56. package/dist/chunk-7QBIZCJ4.js +2 -0
  57. package/dist/chunk-7QBIZCJ4.js.map +1 -0
  58. package/dist/chunk-AMHQGG6Z.js +2 -0
  59. package/dist/chunk-AMHQGG6Z.js.map +1 -0
  60. package/dist/chunk-BAOZ4U74.js +10 -0
  61. package/dist/chunk-BAOZ4U74.js.map +1 -0
  62. package/dist/chunk-CRZ7EUYR.js +2 -0
  63. package/dist/chunk-CRZ7EUYR.js.map +1 -0
  64. package/dist/chunk-FKXSL2JK.js +3 -0
  65. package/dist/chunk-FKXSL2JK.js.map +1 -0
  66. package/dist/chunk-FSKBLPGE.js +2 -0
  67. package/dist/chunk-FSKBLPGE.js.map +1 -0
  68. package/dist/chunk-IYSR44P6.js +2 -0
  69. package/dist/chunk-IYSR44P6.js.map +1 -0
  70. package/dist/chunk-JC6YMVID.js +2 -0
  71. package/dist/chunk-JC6YMVID.js.map +1 -0
  72. package/dist/chunk-JPAV644F.js +2 -0
  73. package/dist/chunk-JPAV644F.js.map +1 -0
  74. package/dist/chunk-JPGXONBQ.js +3 -0
  75. package/dist/chunk-JPGXONBQ.js.map +1 -0
  76. package/dist/chunk-JXCLRKQ7.js +2 -0
  77. package/dist/chunk-JXCLRKQ7.js.map +1 -0
  78. package/dist/chunk-KMAH6636.js +2 -0
  79. package/dist/chunk-KMAH6636.js.map +1 -0
  80. package/dist/chunk-L4ESAO2S.js +2 -0
  81. package/dist/chunk-L4ESAO2S.js.map +1 -0
  82. package/dist/chunk-LV3TULSI.js +2 -0
  83. package/dist/chunk-LV3TULSI.js.map +1 -0
  84. package/dist/chunk-MJEG3K4V.js +2 -0
  85. package/dist/chunk-MJEG3K4V.js.map +1 -0
  86. package/dist/chunk-NLF2JGYY.js +2 -0
  87. package/dist/chunk-NLF2JGYY.js.map +1 -0
  88. package/dist/chunk-NOJFGTRT.js +2 -0
  89. package/dist/chunk-NOJFGTRT.js.map +1 -0
  90. package/dist/chunk-PHPQ5HP3.js +2 -0
  91. package/dist/chunk-PHPQ5HP3.js.map +1 -0
  92. package/dist/chunk-RIL6QABY.js +2 -0
  93. package/dist/chunk-RIL6QABY.js.map +1 -0
  94. package/dist/chunk-RWCVPWRC.js +2 -0
  95. package/dist/chunk-RWCVPWRC.js.map +1 -0
  96. package/dist/chunk-SNNRWNGZ.js +2 -0
  97. package/dist/chunk-SNNRWNGZ.js.map +1 -0
  98. package/dist/chunk-VHAODWCN.js +2 -0
  99. package/dist/chunk-VHAODWCN.js.map +1 -0
  100. package/dist/chunk-WGGN32O2.js +2 -0
  101. package/dist/chunk-WGGN32O2.js.map +1 -0
  102. package/dist/chunk-YXZ4L2OK.js +2 -0
  103. package/dist/chunk-YXZ4L2OK.js.map +1 -0
  104. package/dist/common-BiRA_uz3.d.ts +425 -0
  105. package/dist/common-lV0NsO7t.d.ts +376 -0
  106. package/dist/core/webhook/frameworks/express.d.ts +49 -0
  107. package/dist/core/webhook/frameworks/express.js +2 -0
  108. package/dist/core/webhook/frameworks/express.js.map +1 -0
  109. package/dist/core/webhook/frameworks/nextjs.d.ts +45 -0
  110. package/dist/core/webhook/frameworks/nextjs.js +2 -0
  111. package/dist/core/webhook/frameworks/nextjs.js.map +1 -0
  112. package/dist/core/webhook/index.d.ts +27 -0
  113. package/dist/core/webhook/index.js +2 -0
  114. package/dist/core/webhook/index.js.map +1 -0
  115. package/dist/core/whatsapp/index.d.ts +41 -0
  116. package/dist/core/whatsapp/index.js +2 -0
  117. package/dist/core/whatsapp/index.js.map +1 -0
  118. package/dist/enums-BZd9T2ul.d.ts +707 -0
  119. package/dist/flowTypeGuards-B5hBzkZ4.d.ts +43 -0
  120. package/dist/httpsClient-v4gmltzS.d.ts +19 -0
  121. package/dist/index.d.ts +24 -0
  122. package/dist/index.js +2 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/logger-BdE0Vyim.d.ts +9 -0
  125. package/dist/request-vYMaEfk5.d.ts +50 -0
  126. package/dist/types/config.d.ts +78 -0
  127. package/dist/types/config.js +2 -0
  128. package/dist/types/config.js.map +1 -0
  129. package/dist/types/enums.d.ts +1 -0
  130. package/dist/types/enums.js +2 -0
  131. package/dist/types/enums.js.map +1 -0
  132. package/dist/types/index.d.ts +6 -0
  133. package/dist/types/index.js +2 -0
  134. package/dist/types/index.js.map +1 -0
  135. package/dist/utils/index.d.ts +59 -0
  136. package/dist/utils/index.js +2 -0
  137. package/dist/utils/index.js.map +1 -0
  138. package/package.json +247 -8
@@ -0,0 +1,536 @@
1
+ import { N as NameObject, h as AddressesObject, C as ContactObject, a as InteractiveObject, L as LocationObject, A as AudioMediaObject, D as DocumentMediaObject, I as ImageMediaObject, V as VideoMediaObject, d as StickerMediaObject, c as MessageTemplateObject, e as TextObject } from '../../../common-BiRA_uz3.js';
2
+ import { I as InteractiveTypesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, C as ComponentTypesEnum } from '../../../enums-BZd9T2ul.js';
3
+ import '../../../base-CdGDdVEl.js';
4
+ import '../../../types/config.js';
5
+ import '../../../request-vYMaEfk5.js';
6
+
7
+ /**
8
+ * Builder class for creating contact messages with a fluent API
9
+ */
10
+ declare class ContactMessageBuilder {
11
+ private contact;
12
+ /**
13
+ * Set the contact name (required)
14
+ */
15
+ setName(name: NameObject): this;
16
+ /**
17
+ * Set simple name with first name only
18
+ */
19
+ setSimpleName(firstName: string, lastName?: string): this;
20
+ /**
21
+ * Set full name details
22
+ */
23
+ setFullName(firstName: string, lastName?: string, middleName?: string, suffix?: string, prefix?: string): this;
24
+ /**
25
+ * Add phone numbers
26
+ */
27
+ addPhone(phone: string, type?: string, waId?: string): this;
28
+ /**
29
+ * Add email addresses
30
+ */
31
+ addEmail(email: string, type?: string): this;
32
+ /**
33
+ * Add address
34
+ */
35
+ addAddress(address: AddressesObject): this;
36
+ /**
37
+ * Add simple address
38
+ */
39
+ addSimpleAddress(street: string, city: string, country: string, type?: string): this;
40
+ /**
41
+ * Set organization details
42
+ */
43
+ setOrganization(company: string, department?: string, title?: string): this;
44
+ /**
45
+ * Add URL
46
+ */
47
+ addUrl(url: string, type?: string): this;
48
+ /**
49
+ * Set birthday (format: YYYY-MM-DD)
50
+ */
51
+ setBirthday(year: number, month: number, day: number): this;
52
+ /**
53
+ * Build the final contact object
54
+ */
55
+ build(): ContactObject;
56
+ /**
57
+ * Reset the builder for reuse
58
+ */
59
+ reset(): this;
60
+ }
61
+ /**
62
+ * Factory class for common contact patterns
63
+ */
64
+ declare class ContactMessageFactory {
65
+ /**
66
+ * Create a simple contact with name and phone
67
+ */
68
+ static createSimpleContact(firstName: string, phone: string): ContactObject;
69
+ /**
70
+ * Create a business contact
71
+ */
72
+ static createBusinessContact(firstName: string, lastName: string, company: string, title: string, phone: string, email: string): ContactObject;
73
+ /**
74
+ * Create a personal contact with full details
75
+ */
76
+ static createPersonalContact(firstName: string, lastName: string, mobilePhone: string, email?: string, birthday?: {
77
+ year: number;
78
+ month: number;
79
+ day: number;
80
+ }): ContactObject;
81
+ }
82
+
83
+ /**
84
+ * Builder class for creating interactive messages with a fluent API
85
+ */
86
+ declare class InteractiveMessageBuilder {
87
+ private message;
88
+ /**
89
+ * Set the interactive message type
90
+ */
91
+ setType(type: InteractiveTypesEnum): this;
92
+ /**
93
+ * Set the body text of the message
94
+ */
95
+ setBody(text: string): this;
96
+ /**
97
+ * Set the footer text of the message
98
+ */
99
+ setFooter(text: string): this;
100
+ /**
101
+ * Set a text header
102
+ */
103
+ setTextHeader(text: string): this;
104
+ /**
105
+ * Set an image header
106
+ */
107
+ setImageHeader(imageUrl: string): this;
108
+ /**
109
+ * Add reply buttons (for button type messages)
110
+ */
111
+ addReplyButtons(buttons: Array<{
112
+ id: string;
113
+ title: string;
114
+ }>): this;
115
+ /**
116
+ * Add list sections (for list type messages)
117
+ * Note: This creates a single section with multiple rows
118
+ */
119
+ addListSections(sections: Array<{
120
+ title?: string;
121
+ rows: Array<{
122
+ id: string;
123
+ title: string;
124
+ description?: string;
125
+ }>;
126
+ }>): this;
127
+ /**
128
+ * Set the button text for list messages
129
+ */
130
+ setListButtonText(buttonText: string): this;
131
+ /**
132
+ * Set CTA URL action
133
+ */
134
+ setCTAUrl(displayText: string, url: string): this;
135
+ /**
136
+ * Build the final interactive object
137
+ */
138
+ build(): InteractiveObject;
139
+ /**
140
+ * Reset the builder for reuse
141
+ */
142
+ reset(): this;
143
+ }
144
+ /**
145
+ * Convenience factory functions for common interactive message types
146
+ */
147
+ declare class InteractiveMessageFactory {
148
+ /**
149
+ * Create a button message with reply buttons
150
+ */
151
+ static createButtonMessage(bodyText: string, buttons: Array<{
152
+ id: string;
153
+ title: string;
154
+ }>, options?: {
155
+ headerText?: string;
156
+ footerText?: string;
157
+ }): InteractiveObject;
158
+ /**
159
+ * Create a list message with sections
160
+ */
161
+ static createListMessage(bodyText: string, buttonText: string, sections: Array<{
162
+ title?: string;
163
+ rows: Array<{
164
+ id: string;
165
+ title: string;
166
+ description?: string;
167
+ }>;
168
+ }>, options?: {
169
+ headerText?: string;
170
+ footerText?: string;
171
+ }): InteractiveObject;
172
+ /**
173
+ * Create a CTA URL message
174
+ */
175
+ static createCTAUrlMessage(bodyText: string, displayText: string, url: string, options?: {
176
+ headerText?: string;
177
+ footerText?: string;
178
+ }): InteractiveObject;
179
+ }
180
+
181
+ /**
182
+ * Builder class for creating location messages with a fluent API
183
+ */
184
+ declare class LocationMessageBuilder {
185
+ private location;
186
+ /**
187
+ * Set the latitude coordinate
188
+ */
189
+ setLatitude(latitude: number): this;
190
+ /**
191
+ * Set the longitude coordinate
192
+ */
193
+ setLongitude(longitude: number): this;
194
+ /**
195
+ * Set coordinates using latitude and longitude
196
+ */
197
+ setCoordinates(latitude: number, longitude: number): this;
198
+ /**
199
+ * Set the location name
200
+ */
201
+ setName(name: string): this;
202
+ /**
203
+ * Set the location address
204
+ */
205
+ setAddress(address: string): this;
206
+ /**
207
+ * Build the final location object
208
+ */
209
+ build(): LocationObject;
210
+ /**
211
+ * Reset the builder for reuse
212
+ */
213
+ reset(): this;
214
+ }
215
+ /**
216
+ * Factory class for common location patterns
217
+ */
218
+ declare class LocationMessageFactory {
219
+ /**
220
+ * Create a simple location with just coordinates
221
+ */
222
+ static createSimpleLocation(latitude: number, longitude: number): LocationObject;
223
+ /**
224
+ * Create a location with name and address
225
+ */
226
+ static createNamedLocation(latitude: number, longitude: number, name: string, address: string): LocationObject;
227
+ /**
228
+ * Create a business location
229
+ */
230
+ static createBusinessLocation(latitude: number, longitude: number, businessName: string, fullAddress: string): LocationObject;
231
+ }
232
+
233
+ /**
234
+ * Base builder for media messages
235
+ */
236
+ declare abstract class BaseMediaBuilder<T> {
237
+ protected media: Partial<T>;
238
+ /**
239
+ * Set media ID (for uploaded media)
240
+ */
241
+ setId(id: string): this;
242
+ /**
243
+ * Set media URL
244
+ */
245
+ setLink(url: string): this;
246
+ /**
247
+ * Set media caption
248
+ */
249
+ setCaption(caption: string): this;
250
+ /**
251
+ * Build the media object
252
+ */
253
+ build(): T;
254
+ /**
255
+ * Reset the builder
256
+ */
257
+ reset(): this;
258
+ }
259
+ /**
260
+ * Builder for image messages
261
+ */
262
+ declare class ImageMessageBuilder extends BaseMediaBuilder<ImageMediaObject> {
263
+ }
264
+ /**
265
+ * Builder for video messages
266
+ */
267
+ declare class VideoMessageBuilder extends BaseMediaBuilder<VideoMediaObject> {
268
+ }
269
+ /**
270
+ * Builder for audio messages
271
+ */
272
+ declare class AudioMessageBuilder extends BaseMediaBuilder<AudioMediaObject> {
273
+ setCaption(caption: string): this;
274
+ }
275
+ /**
276
+ * Builder for document messages
277
+ */
278
+ declare class DocumentMessageBuilder extends BaseMediaBuilder<DocumentMediaObject> {
279
+ /**
280
+ * Set document filename
281
+ */
282
+ setFilename(filename: string): this;
283
+ }
284
+ /**
285
+ * Builder for sticker messages
286
+ */
287
+ declare class StickerMessageBuilder extends BaseMediaBuilder<StickerMediaObject> {
288
+ setCaption(caption: string): this;
289
+ }
290
+ /**
291
+ * Factory class for common media patterns
292
+ */
293
+ declare class MediaMessageFactory {
294
+ /**
295
+ * Create an image with caption
296
+ */
297
+ static createImageWithCaption(linkOrId: string, caption: string, isId?: boolean): ImageMediaObject;
298
+ /**
299
+ * Create a video with caption
300
+ */
301
+ static createVideoWithCaption(linkOrId: string, caption: string, isId?: boolean): VideoMediaObject;
302
+ /**
303
+ * Create a document with filename
304
+ */
305
+ static createDocument(linkOrId: string, filename: string, caption?: string, isId?: boolean): DocumentMediaObject;
306
+ /**
307
+ * Create an audio message
308
+ */
309
+ static createAudio(linkOrId: string, isId?: boolean): AudioMediaObject;
310
+ /**
311
+ * Create a sticker message
312
+ */
313
+ static createSticker(linkOrId: string, isId?: boolean): StickerMediaObject;
314
+ }
315
+
316
+ /**
317
+ * Builder class for creating reaction messages with a fluent API
318
+ */
319
+ declare class ReactionMessageBuilder {
320
+ private reaction;
321
+ /**
322
+ * Set the message ID to react to
323
+ */
324
+ setMessageId(messageId: string): this;
325
+ /**
326
+ * Set the emoji for the reaction
327
+ */
328
+ setEmoji(emoji: string): this;
329
+ /**
330
+ * Remove a reaction (by sending empty emoji)
331
+ */
332
+ removeReaction(): this;
333
+ /**
334
+ * Build the final reaction object
335
+ */
336
+ build(): {
337
+ message_id: string;
338
+ emoji: string;
339
+ };
340
+ /**
341
+ * Reset the builder for reuse
342
+ */
343
+ reset(): this;
344
+ }
345
+ /**
346
+ * Factory class for common reaction patterns
347
+ */
348
+ declare class ReactionMessageFactory {
349
+ /**
350
+ * Create a like reaction
351
+ */
352
+ static createLike(messageId: string): {
353
+ message_id: string;
354
+ emoji: string;
355
+ };
356
+ /**
357
+ * Create a heart reaction
358
+ */
359
+ static createHeart(messageId: string): {
360
+ message_id: string;
361
+ emoji: string;
362
+ };
363
+ /**
364
+ * Create a laughing reaction
365
+ */
366
+ static createLaugh(messageId: string): {
367
+ message_id: string;
368
+ emoji: string;
369
+ };
370
+ /**
371
+ * Create a wow reaction
372
+ */
373
+ static createWow(messageId: string): {
374
+ message_id: string;
375
+ emoji: string;
376
+ };
377
+ /**
378
+ * Create a sad reaction
379
+ */
380
+ static createSad(messageId: string): {
381
+ message_id: string;
382
+ emoji: string;
383
+ };
384
+ /**
385
+ * Create an angry reaction
386
+ */
387
+ static createAngry(messageId: string): {
388
+ message_id: string;
389
+ emoji: string;
390
+ };
391
+ /**
392
+ * Remove a reaction
393
+ */
394
+ static removeReaction(messageId: string): {
395
+ message_id: string;
396
+ emoji: string;
397
+ };
398
+ }
399
+
400
+ type CurrencyParameterHelper = {
401
+ type: ParametersTypesEnum.Currency;
402
+ currency: {
403
+ fallback_value: string;
404
+ code: CurrencyCodesEnum;
405
+ amount_1000: number;
406
+ };
407
+ };
408
+ type DateTimeParameterHelper = {
409
+ type: ParametersTypesEnum.DateTime;
410
+ date_time: {
411
+ fallback_value: string;
412
+ timestamp: number;
413
+ };
414
+ };
415
+ /**
416
+ * Builder class for creating template messages with a fluent API
417
+ */
418
+ declare class TemplateMessageBuilder {
419
+ private template;
420
+ /**
421
+ * Set the template name
422
+ */
423
+ setName(name: string): this;
424
+ /**
425
+ * Set the template language
426
+ */
427
+ setLanguage(code: string): this;
428
+ /**
429
+ * Add a header component with text parameters
430
+ */
431
+ addTextHeader(parameters: string[]): this;
432
+ /**
433
+ * Add a header component with image
434
+ */
435
+ addImageHeader(imageUrl: string): this;
436
+ /**
437
+ * Add a body component with text parameters
438
+ */
439
+ addBody(parameters: string[]): this;
440
+ /**
441
+ * Add a footer component (usually no parameters needed)
442
+ */
443
+ addFooter(): this;
444
+ /**
445
+ * Add button components (for quick replies, URLs, etc.)
446
+ */
447
+ addButtons(buttons: Array<{
448
+ index: number;
449
+ type: 'quick_reply' | 'url';
450
+ parameters?: string[];
451
+ }>): this;
452
+ /**
453
+ * Add a currency parameter for header/body
454
+ */
455
+ addCurrencyParameter(fallbackValue: string, currencyCode: string, amount: number): CurrencyParameterHelper;
456
+ /**
457
+ * Add a date time parameter
458
+ */
459
+ addDateTimeParameter(fallbackValue: string, timestamp: number): DateTimeParameterHelper;
460
+ /**
461
+ * Build the final template object
462
+ */
463
+ build(): MessageTemplateObject<ComponentTypesEnum>;
464
+ /**
465
+ * Reset the builder for reuse
466
+ */
467
+ reset(): this;
468
+ }
469
+ /**
470
+ * Factory class for common template patterns
471
+ */
472
+ declare class TemplateMessageFactory {
473
+ /**
474
+ * Create a simple text-only template
475
+ */
476
+ static createSimpleTextTemplate(name: string, language: string, bodyParameters: string[]): MessageTemplateObject<ComponentTypesEnum>;
477
+ /**
478
+ * Create a template with header, body and buttons
479
+ */
480
+ static createCompleteTemplate(name: string, language: string, options: {
481
+ headerParameters?: string[];
482
+ headerImage?: string;
483
+ bodyParameters: string[];
484
+ buttons?: Array<{
485
+ index: number;
486
+ type: 'quick_reply' | 'url';
487
+ parameters?: string[];
488
+ }>;
489
+ }): MessageTemplateObject<ComponentTypesEnum>;
490
+ /**
491
+ * Create an order confirmation template
492
+ */
493
+ static createOrderConfirmationTemplate(language: string, customerName: string, orderNumber: string, amount: number, currencyCode: string): MessageTemplateObject<ComponentTypesEnum>;
494
+ }
495
+
496
+ /**
497
+ * Builder class for creating text messages with a fluent API
498
+ */
499
+ declare class TextMessageBuilder {
500
+ private textMessage;
501
+ /**
502
+ * Set the message body text
503
+ */
504
+ setBody(text: string): this;
505
+ /**
506
+ * Enable or disable URL preview
507
+ */
508
+ setPreviewUrl(enable?: boolean): this;
509
+ /**
510
+ * Build the final text object
511
+ */
512
+ build(): TextObject;
513
+ /**
514
+ * Reset the builder for reuse
515
+ */
516
+ reset(): this;
517
+ }
518
+ /**
519
+ * Factory class for common text message patterns
520
+ */
521
+ declare class TextMessageFactory {
522
+ /**
523
+ * Create a simple text message
524
+ */
525
+ static createSimpleText(body: string): TextObject;
526
+ /**
527
+ * Create a text message with URL preview
528
+ */
529
+ static createTextWithPreview(body: string): TextObject;
530
+ /**
531
+ * Create a notification message
532
+ */
533
+ static createNotification(title: string, message: string): TextObject;
534
+ }
535
+
536
+ export { AudioMessageBuilder, ContactMessageBuilder, ContactMessageFactory, DocumentMessageBuilder, ImageMessageBuilder, InteractiveMessageBuilder, InteractiveMessageFactory, LocationMessageBuilder, LocationMessageFactory, MediaMessageFactory, ReactionMessageBuilder, ReactionMessageFactory, StickerMessageBuilder, TemplateMessageBuilder, TemplateMessageFactory, TextMessageBuilder, TextMessageFactory, VideoMessageBuilder };
@@ -0,0 +1,4 @@
1
+ import {v,g as g$1}from'../../../chunk-KMAH6636.js';var u=class{contact={};setName(t){if(!t||typeof t!="object")throw new Error("Name must be an object");return this.contact.name=t,this}setSimpleName(t,e){if(!t||typeof t!="string")throw new Error("First name must be a non-empty string");let r={formatted_name:e?`${t} ${e}`:t,first_name:t};return e&&(r.last_name=e),this.setName(r)}setFullName(t,e,r,s,i){if(!t||typeof t!="string")throw new Error("First name must be a non-empty string");let c={formatted_name:[i,t,r,e,s].filter(Boolean).join(" "),first_name:t};return e&&(c.last_name=e),r&&(c.middle_name=r),s&&(c.suffix=s),i&&(c.prefix=i),this.setName(c)}addPhone(t,e,r){if(!t||typeof t!="string")throw new Error("Phone number must be a non-empty string");let s={phone:"PHONE_NUMBER"};return e&&(s.type=e),r&&(s.wa_id=r),this.contact.phones||(this.contact.phones=[]),this.contact.phones.push(s),this}addEmail(t,e){if(!t||typeof t!="string")throw new Error("Email must be a non-empty string");if(!t.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/))throw new Error("Invalid email format");let r={email:t};return e&&(r.type=e),this.contact.emails||(this.contact.emails=[]),this.contact.emails.push(r),this}addAddress(t){if(!t||typeof t!="object")throw new Error("Address must be an object");return this.contact.addresses||(this.contact.addresses=[]),this.contact.addresses.push(t),this}addSimpleAddress(t,e,r,s){let i={street:t,city:e,country:r};return s&&(i.type=s),this.addAddress(i)}setOrganization(t,e,r){let s={};return t&&(s.company=t),e&&(s.department=e),r&&(s.title=r),this.contact.org=s,this}addUrl(t,e){if(!t||typeof t!="string")throw new Error("URL must be a non-empty string");let r={url:t};return e&&(r.type=e),this.contact.urls||(this.contact.urls=[]),this.contact.urls.push(r),this}setBirthday(t,e,r){let s=e.toString().padStart(2,"0"),i=r.toString().padStart(2,"0");return this.contact.birthday=`${t}-${s}-${i}`,this}build(){if(!this.contact.name)throw new Error("Contact name is required");return this.contact}reset(){return this.contact={},this}},E=class{static createSimpleContact(t,e){return new u().setSimpleName(t).addPhone(e).build()}static createBusinessContact(t,e,r,s,i,o){return new u().setSimpleName(t,e).setOrganization(r,void 0,s).addPhone(i,"WORK").addEmail(o,"WORK").build()}static createPersonalContact(t,e,r,s,i){let o=new u().setSimpleName(t,e).addPhone(r,"MOBILE");return s&&o.addEmail(s,"HOME"),i&&o.setBirthday(i.year,i.month,i.day),o.build()}};function l(n){return !("name"in n)}var d=class{message={};setType(t){return this.message.type=t,this}setBody(t){return this.message.body={text:t},this}setFooter(t){return this.message.footer={text:t},this}setTextHeader(t){return this.message.header={type:"text",text:t},this}setImageHeader(t){return this.message.header={type:"image",image:{link:t}},this}addReplyButtons(t){this.message.action||(this.message.action={});let e=this.message.action;return l(e)&&(e.buttons=t.map(r=>({type:"reply",reply:{id:r.id,title:r.title}}))),this}addListSections(t){this.message.action||(this.message.action={});let e=this.message.action;return l(e)&&(e.sections=t.map(r=>({title:r.title,rows:r.rows}))),this}setListButtonText(t){this.message.action||(this.message.action={});let e=this.message.action;return l(e)&&(e.button=t),this}setCTAUrl(t,e){return this.message.action={name:"cta_url",parameters:{display_text:t,url:e}},this}build(){if(!this.message.type)throw new Error("Interactive message type is required");if(!this.message.body)throw new Error("Interactive message body is required");if(!this.message.action)throw new Error("Interactive message action is required");return this.message}reset(){return this.message={},this}},O=class{static createButtonMessage(t,e,r){let s=new d().setType("button").setBody(t).addReplyButtons(e);return r?.headerText&&s.setTextHeader(r.headerText),r?.footerText&&s.setFooter(r.footerText),s.build()}static createListMessage(t,e,r,s){let i=new d().setType("list").setBody(t).addListSections(r);s?.headerText&&i.setTextHeader(s.headerText),s?.footerText&&i.setFooter(s.footerText);let o=i.build(),c=o.action;return l(c)&&(c.button=e),o}static createCTAUrlMessage(t,e,r,s){let i=new d().setType("cta_url").setBody(t).setCTAUrl(e,r);return s?.headerText&&i.setTextHeader(s.headerText),s?.footerText&&i.setFooter(s.footerText),i.build()}};var g=class{location={};setLatitude(t){if(typeof t!="number"||t<-90||t>90)throw new Error("Latitude must be a number between -90 and 90");return this.location.latitude=t,this}setLongitude(t){if(typeof t!="number"||t<-180||t>180)throw new Error("Longitude must be a number between -180 and 180");return this.location.longitude=t,this}setCoordinates(t,e){return this.setLatitude(t).setLongitude(e)}setName(t){if(t&&typeof t!="string")throw new Error("Location name must be a string");return this.location.name=t,this}setAddress(t){if(t&&typeof t!="string")throw new Error("Location address must be a string");return this.location.address=t,this}build(){if(this.location.latitude===void 0)throw new Error("Latitude is required");if(this.location.longitude===void 0)throw new Error("Longitude is required");return this.location}reset(){return this.location={},this}},x=class{static createSimpleLocation(t,e){return new g().setCoordinates(t,e).build()}static createNamedLocation(t,e,r,s){return new g().setCoordinates(t,e).setName(r).setAddress(s).build()}static createBusinessLocation(t,e,r,s){return new g().setCoordinates(t,e).setName(r).setAddress(s).build()}};var m=class{media={};setId(t){if(!t||typeof t!="string")throw new Error("Media ID must be a non-empty string");return this.media.id=t,this}setLink(t){if(!t||typeof t!="string")throw new Error("Media URL must be a non-empty string");if(!t.match(/^https?:\/\//))throw new Error("Media URL must be a valid HTTP/HTTPS URL");return this.media.link=t,this}setCaption(t){if(t&&typeof t!="string")throw new Error("Caption must be a string");return this.media.caption=t,this}build(){if(!this.media.id&&!this.media.link)throw new Error("Either media ID or link is required");return this.media}reset(){return this.media={},this}},b=class extends m{},y=class extends m{},f=class extends m{setCaption(t){throw new Error("Audio messages do not support captions")}},w=class extends m{setFilename(t){if(!t||typeof t!="string")throw new Error("Filename must be a non-empty string");return this.media.filename=t,this}},j=class extends m{setCaption(t){throw new Error("Sticker messages do not support captions")}},T=class{static createImageWithCaption(t,e,r=false){let s=new b;return r?s.setId(t):s.setLink(t),s.setCaption(e).build()}static createVideoWithCaption(t,e,r=false){let s=new y;return r?s.setId(t):s.setLink(t),s.setCaption(e).build()}static createDocument(t,e,r,s=false){let i=new w;return s?i.setId(t):i.setLink(t),i.setFilename(e),r&&i.setCaption(r),i.build()}static createAudio(t,e=false){let r=new f;return e?r.setId(t):r.setLink(t),r.build()}static createSticker(t,e=false){let r=new j;return e?r.setId(t):r.setLink(t),r.build()}};var a=class{reaction={};setMessageId(t){if(!t||typeof t!="string")throw new Error("Message ID must be a non-empty string");return this.reaction.message_id=t,this}setEmoji(t){if(!t||typeof t!="string")throw new Error("Emoji must be a non-empty string");if(t.length>4)throw new Error("Please provide a single emoji character");return this.reaction.emoji=t,this}removeReaction(){return this.reaction.emoji="",this}build(){if(!this.reaction.message_id)throw new Error("Message ID is required");if(this.reaction.emoji===void 0)throw new Error("Emoji is required (use empty string to remove reaction)");return this.reaction}reset(){return this.reaction={},this}},A=class{static createLike(t){return new a().setMessageId(t).setEmoji("\u{1F44D}").build()}static createHeart(t){return new a().setMessageId(t).setEmoji("\u2764\uFE0F").build()}static createLaugh(t){return new a().setMessageId(t).setEmoji("\u{1F602}").build()}static createWow(t){return new a().setMessageId(t).setEmoji("\u{1F62E}").build()}static createSad(t){return new a().setMessageId(t).setEmoji("\u{1F622}").build()}static createAngry(t){return new a().setMessageId(t).setEmoji("\u{1F620}").build()}static removeReaction(t){return new a().setMessageId(t).removeReaction().build()}};function P(n){return Object.values(v).includes(n)}function _(n){return Object.values(g$1).includes(n)}var p=class{template={components:[]};setName(t){if(!t||t.trim().length===0)throw new Error("Template name cannot be empty");return this.template.name=t,this}setLanguage(t){if(!P(t))throw new Error(`Invalid language code: ${t}. Must be a valid LanguagesEnum value.`);return this.template.language={policy:"deterministic",code:t},this}addTextHeader(t){if(!Array.isArray(t))throw new Error("Parameters must be an array");let e={type:"HEADER",parameters:t.map(r=>{if(typeof r!="string")throw new Error("All parameters must be strings");return {type:"TEXT",text:r}})};return this.template.components||(this.template.components=[]),this.template.components.push(e),this}addImageHeader(t){if(!t||typeof t!="string")throw new Error("Image URL must be a non-empty string");let e={type:"HEADER",parameters:[{type:"IMAGE",image:{link:t}}]};return this.template.components||(this.template.components=[]),this.template.components.push(e),this}addBody(t){if(!Array.isArray(t))throw new Error("Parameters must be an array");let e={type:"BODY",parameters:t.map(r=>{if(typeof r!="string")throw new Error("All parameters must be strings");return {type:"TEXT",text:r}})};return this.template.components||(this.template.components=[]),this.template.components.push(e),this}addFooter(){let t={type:"FOOTER"};return this.template.components||(this.template.components=[]),this.template.components.push(t),this}addButtons(t){if(!Array.isArray(t))throw new Error("Buttons must be an array");return t.forEach(e=>{if(typeof e.index!="number"||!_(e.index))throw new Error(`Button index must be a valid ButtonPositionEnum value: ${e.index}`);let r=e.type==="quick_reply"?"QUICK_REPLY":"URL",s={type:"BUTTON",sub_type:r,index:e.index};if(e.parameters&&e.parameters.length>0){if(!Array.isArray(e.parameters))throw new Error("Button parameters must be an array");e.type==="quick_reply"?s.parameters=e.parameters.map(i=>{if(typeof i!="string")throw new Error("All button parameters must be strings");return {type:"PAYLOAD",payload:i}}):e.type==="url"&&(s.parameters=e.parameters.map(i=>{if(typeof i!="string")throw new Error("All button parameters must be strings");return {type:"TEXT",text:i}}));}this.template.components||(this.template.components=[]),this.template.components.push(s);}),this}addCurrencyParameter(t,e,r){if(!t||typeof t!="string")throw new Error("Fallback value must be a non-empty string");if(!e||typeof e!="string")throw new Error("Currency code must be a non-empty string");if(typeof r!="number"||r<0)throw new Error("Amount must be a non-negative number");return {type:"CURRENCY",currency:{fallback_value:t,code:e,amount_1000:r*1e3}}}addDateTimeParameter(t,e){if(!t||typeof t!="string")throw new Error("Fallback value must be a non-empty string");if(typeof e!="number"||e<=0)throw new Error("Timestamp must be a positive number");return {type:"DATE_TIME",date_time:{fallback_value:t,timestamp:e}}}build(){if(!this.template.name)throw new Error("Template name is required");if(!this.template.language)throw new Error("Template language is required");return this.template}reset(){return this.template={components:[]},this}},C=class{static createSimpleTextTemplate(t,e,r){if(!t||!e||!Array.isArray(r))throw new Error("Invalid parameters for simple text template");return new p().setName(t).setLanguage(e).addBody(r).build()}static createCompleteTemplate(t,e,r){if(!t||!e||!r.bodyParameters)throw new Error("Invalid parameters for complete template");let s=new p().setName(t).setLanguage(e).addBody(r.bodyParameters);return r.headerParameters?s.addTextHeader(r.headerParameters):r.headerImage&&s.addImageHeader(r.headerImage),r.buttons&&s.addButtons(r.buttons),s.build()}static createOrderConfirmationTemplate(t,e,r,s,i){if(!t||!e||!r||typeof s!="number"||!i)throw new Error("Invalid parameters for order confirmation template");return new p().setName("order_confirmation").setLanguage(t).addBody([e,r,s.toString(),i]).addButtons([{index:0,type:"quick_reply"},{index:1,type:"url",parameters:[r]}]).build()}};var h=class{textMessage={};setBody(t){if(!t||typeof t!="string")throw new Error("Message body must be a non-empty string");return this.textMessage.body=t,this}setPreviewUrl(t=true){return this.textMessage.preview_url=t,this}build(){if(!this.textMessage.body)throw new Error("Message body is required");return this.textMessage}reset(){return this.textMessage={},this}},L=class{static createSimpleText(t){return new h().setBody(t).build()}static createTextWithPreview(t){return new h().setBody(t).setPreviewUrl(true).build()}static createNotification(t,e){return new h().setBody(`*${t}*
2
+
3
+ ${e}`).build()}};export{f as AudioMessageBuilder,u as ContactMessageBuilder,E as ContactMessageFactory,w as DocumentMessageBuilder,b as ImageMessageBuilder,d as InteractiveMessageBuilder,O as InteractiveMessageFactory,g as LocationMessageBuilder,x as LocationMessageFactory,T as MediaMessageFactory,a as ReactionMessageBuilder,A as ReactionMessageFactory,j as StickerMessageBuilder,p as TemplateMessageBuilder,C as TemplateMessageFactory,h as TextMessageBuilder,L as TextMessageFactory,y as VideoMessageBuilder};//# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map