meta-cloud-api 0.2.15 → 0.2.17

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 (111) 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/features/flow/index.d.ts +9 -0
  51. package/dist/features/flow/index.js +2 -0
  52. package/dist/features/media/index.d.ts +9 -0
  53. package/dist/features/media/index.js +2 -0
  54. package/dist/features/messages/index.d.ts +9 -0
  55. package/dist/features/messages/index.js +2 -0
  56. package/dist/features/messages/index.js.map +1 -0
  57. package/dist/features/phone/index.d.ts +9 -0
  58. package/dist/features/phone/index.js +2 -0
  59. package/dist/features/phone/index.js.map +1 -0
  60. package/dist/features/profile/index.d.ts +9 -0
  61. package/dist/features/profile/index.js +2 -0
  62. package/dist/features/profile/index.js.map +1 -0
  63. package/dist/features/qrCode/index.d.ts +9 -0
  64. package/dist/features/qrCode/index.js +2 -0
  65. package/dist/features/qrCode/index.js.map +1 -0
  66. package/dist/features/registration/index.d.ts +9 -0
  67. package/dist/features/registration/index.js +2 -0
  68. package/dist/features/registration/index.js.map +1 -0
  69. package/dist/features/template/index.d.ts +9 -0
  70. package/dist/features/template/index.js +2 -0
  71. package/dist/features/template/index.js.map +1 -0
  72. package/dist/features/twoStepVerification/index.d.ts +9 -0
  73. package/dist/features/twoStepVerification/index.js +2 -0
  74. package/dist/features/twoStepVerification/index.js.map +1 -0
  75. package/dist/features/waba/index.d.ts +9 -0
  76. package/dist/features/waba/index.js +2 -0
  77. package/dist/features/waba/index.js.map +1 -0
  78. package/dist/index.d.ts +546 -28
  79. package/dist/index.js +2 -2
  80. package/dist/index.js.map +1 -1
  81. package/dist/shared/types/config.d.ts +78 -0
  82. package/dist/shared/types/config.js +2 -0
  83. package/dist/shared/types/config.js.map +1 -0
  84. package/dist/shared/types/enums.d.ts +1 -0
  85. package/dist/shared/types/enums.js +2 -0
  86. package/dist/shared/types/enums.js.map +1 -0
  87. package/dist/shared/utils/isMetaError.d.ts +21 -0
  88. package/dist/shared/utils/isMetaError.js +2 -0
  89. package/dist/shared/utils/isMetaError.js.map +1 -0
  90. package/package.json +80 -15
  91. package/dist/api/index.d.ts +0 -496
  92. package/dist/api/index.js +0 -2
  93. package/dist/chunk-IE2YYEC7.js +0 -2
  94. package/dist/chunk-IE2YYEC7.js.map +0 -1
  95. package/dist/chunk-IMPHLXRA.js +0 -2
  96. package/dist/chunk-IMPHLXRA.js.map +0 -1
  97. package/dist/chunk-KW56EPP7.js +0 -2
  98. package/dist/chunk-KW56EPP7.js.map +0 -1
  99. package/dist/chunk-SLDCD6XR.js +0 -2
  100. package/dist/chunk-SLDCD6XR.js.map +0 -1
  101. package/dist/chunk-UVPYV4PL.js +0 -2
  102. package/dist/chunk-UVPYV4PL.js.map +0 -1
  103. package/dist/types/index.d.ts +0 -513
  104. package/dist/types/index.js +0 -2
  105. package/dist/utils/index.d.ts +0 -71
  106. package/dist/utils/index.js +0 -2
  107. package/dist/waba-RRlZTQUG.d.ts +0 -2229
  108. package/dist/whatsapp-DmeO83A8.d.ts +0 -46
  109. /package/dist/{api → features/encryption}/index.js.map +0 -0
  110. /package/dist/{types → features/flow}/index.js.map +0 -0
  111. /package/dist/{utils → features/media}/index.js.map +0 -0
@@ -0,0 +1,471 @@
1
+ import { b as ResponseSuccess, a as BaseAPI, R as RequesterClass } from './base-BG2gtoDs.js';
2
+ import { WabaConfigType } from './shared/types/config.js';
3
+
4
+ /**
5
+ * Enum for Flow Status
6
+ */
7
+ declare enum FlowStatusEnum {
8
+ Draft = "DRAFT",
9
+ Published = "PUBLISHED",
10
+ Throttled = "THROTTLED",
11
+ Blocked = "BLOCKED",
12
+ Deprecated = "DEPRECATED"
13
+ }
14
+ /**
15
+ * Enum for Flow Categories
16
+ */
17
+ declare enum FlowCategoryEnum {
18
+ SignUp = "SIGN_UP",
19
+ SignIn = "SIGN_IN",
20
+ AppointmentBooking = "APPOINTMENT_BOOKING",
21
+ LeadGeneration = "LEAD_GENERATION",
22
+ ContactUs = "CONTACT_US",
23
+ CustomerSupport = "CUSTOMER_SUPPORT",
24
+ Survey = "SURVEY",
25
+ Other = "OTHER"
26
+ }
27
+ declare enum FlowActionEnum {
28
+ INIT = "INIT",
29
+ BACK = "BACK",
30
+ DATA_EXCHANGE = "data_exchange"
31
+ }
32
+ /**
33
+ * Enum for Flow Types in webhook handlers
34
+ * Used to register handlers for specific flow events
35
+ */
36
+ declare enum FlowTypeEnum {
37
+ /** Health check/ping requests */
38
+ Ping = "ping",
39
+ /** Data exchange requests */
40
+ Change = "data_exchange",
41
+ /** Error notification requests */
42
+ Error = "error",
43
+ /** Match all flow action types */
44
+ All = "*"
45
+ }
46
+ /**
47
+ * Flow Validation Error Pointer
48
+ */
49
+ interface FlowValidationErrorPointer {
50
+ line_start: number;
51
+ line_end: number;
52
+ column_start: number;
53
+ column_end: number;
54
+ path: string;
55
+ }
56
+ /**
57
+ * Flow Validation Error
58
+ */
59
+ interface FlowValidationError {
60
+ error: string;
61
+ error_type: string;
62
+ message: string;
63
+ line_start: number;
64
+ line_end: number;
65
+ column_start: number;
66
+ column_end: number;
67
+ pointers: FlowValidationErrorPointer[];
68
+ }
69
+ /**
70
+ * Flow Item
71
+ */
72
+ interface Flow {
73
+ id: string;
74
+ name: string;
75
+ status: FlowStatusEnum;
76
+ categories: FlowCategoryEnum[];
77
+ validation_errors: FlowValidationError[];
78
+ }
79
+ /**
80
+ * Pagination Cursors
81
+ */
82
+ interface PaginationCursors {
83
+ before: string;
84
+ after: string;
85
+ }
86
+ /**
87
+ * Pagination Object
88
+ */
89
+ interface Pagination {
90
+ cursors: PaginationCursors;
91
+ }
92
+ /**
93
+ * Flows List Response
94
+ */
95
+ interface FlowsListResponse {
96
+ data: Flow[];
97
+ paging: Pagination;
98
+ }
99
+ /**
100
+ * Flow Asset
101
+ */
102
+ interface FlowAsset {
103
+ name: string;
104
+ asset_type: string;
105
+ download_url: string;
106
+ }
107
+ /**
108
+ * Flow Assets Response
109
+ */
110
+ interface FlowAssetsResponse {
111
+ data: FlowAsset[];
112
+ paging: Pagination;
113
+ }
114
+ /**
115
+ * Flow Preview
116
+ */
117
+ interface FlowPreview {
118
+ preview_url: string;
119
+ expires_at: string;
120
+ }
121
+ /**
122
+ * Flow Preview Response
123
+ */
124
+ interface FlowPreviewResponse {
125
+ preview: FlowPreview;
126
+ id: string;
127
+ }
128
+ /**
129
+ * Flow Migration Result
130
+ */
131
+ interface FlowMigrationResult {
132
+ source_name: string;
133
+ source_id: string;
134
+ migrated_id: string;
135
+ }
136
+ /**
137
+ * Flow Migration Failure
138
+ */
139
+ interface FlowMigrationFailure {
140
+ source_name: string;
141
+ error_code: string;
142
+ error_message: string;
143
+ }
144
+ /**
145
+ * Create Flow Response
146
+ */
147
+ interface CreateFlowResponse {
148
+ id: string;
149
+ success: boolean;
150
+ validation_errors?: FlowValidationError[];
151
+ }
152
+ /**
153
+ * Update Flow Response
154
+ */
155
+ interface UpdateFlowResponse {
156
+ success: boolean;
157
+ validation_errors?: FlowValidationError[];
158
+ }
159
+ /**
160
+ * Flow Migration Response
161
+ */
162
+ interface FlowMigrationResponse {
163
+ migrated_flows: FlowMigrationResult[];
164
+ failed_flows: FlowMigrationFailure[];
165
+ }
166
+ /**
167
+ * Validate Flow JSON Response
168
+ */
169
+ interface ValidateFlowJsonResponse {
170
+ valid: boolean;
171
+ success: boolean;
172
+ validation_errors?: FlowValidationError[];
173
+ }
174
+ /**
175
+ * WhatsApp Flow Endpoint - Health Check Response
176
+ * The expected response structure for health check requests
177
+ */
178
+ interface FlowHealthCheckResponse {
179
+ data: {
180
+ status: 'active';
181
+ };
182
+ }
183
+ /**
184
+ * WhatsApp Flow Endpoint - Data Exchange Response
185
+ * The expected response structure for data exchange requests
186
+ */
187
+ interface FlowDataExchangeResponse {
188
+ screen?: string;
189
+ data?: Record<string, any | {
190
+ error_message?: string;
191
+ }>;
192
+ }
193
+ /**
194
+ * WhatsApp Flow Endpoint - Success Screen Response
195
+ * The expected response structure for success screen requests
196
+ */
197
+ interface FlowSuccessScreenResponse {
198
+ screen: 'SUCCESS';
199
+ data: {
200
+ extension_message_response?: {
201
+ params?: {
202
+ flow_token: string;
203
+ [key: string]: string;
204
+ };
205
+ };
206
+ };
207
+ }
208
+ /**
209
+ * WhatsApp Flow Endpoint - Error Notification Response
210
+ * The expected response structure for error notification requests
211
+ */
212
+ interface FlowErrorNotificationResponse {
213
+ acknowledged: boolean;
214
+ }
215
+ /**
216
+ * WhatsApp Flow Endpoint - Comprehensive Request Object
217
+ * A combined type that includes all possible fields from different request types
218
+ * with all fields being optional for flexibility
219
+ */
220
+ interface FlowEndpointRequest {
221
+ version?: '3.0';
222
+ action?: 'ping' | FlowActionEnum;
223
+ screen?: string;
224
+ flow_token?: string;
225
+ data?: Record<string, any> & {
226
+ error_key?: string;
227
+ error_message?: string;
228
+ };
229
+ }
230
+ /**
231
+ * WhatsApp Flow Endpoint - Response
232
+ * Union type for all possible response types from a Flow endpoint
233
+ */
234
+ type FlowEndpointResponse = FlowHealthCheckResponse | FlowDataExchangeResponse | FlowErrorNotificationResponse | FlowSuccessScreenResponse;
235
+ interface FlowClass {
236
+ /**
237
+ * List Flows
238
+ *
239
+ * @param wabaId - The WABA ID
240
+ * @returns Promise with the list of flows
241
+ */
242
+ listFlows(wabaId: string): Promise<FlowsListResponse>;
243
+ /**
244
+ * Create Flow
245
+ *
246
+ * @param wabaId - The WABA ID
247
+ * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
248
+ * @returns Promise with the created flow ID
249
+ */
250
+ createFlow(wabaId: string, data: {
251
+ name: string;
252
+ categories?: FlowCategoryEnum[];
253
+ endpoint_uri?: string;
254
+ clone_flow_id?: string;
255
+ flow_json?: string;
256
+ publish?: boolean;
257
+ }): Promise<CreateFlowResponse>;
258
+ /**
259
+ * Get Flow
260
+ *
261
+ * @param flowId - The flow ID
262
+ * @param fields - Optional fields to return
263
+ * @param dateFormat - Optional date format
264
+ * @returns Promise with the flow details
265
+ */
266
+ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
267
+ /**
268
+ * Update Flow Metadata
269
+ *
270
+ * @param flowId - The flow ID
271
+ * @param data - The flow metadata to update
272
+ * @returns Promise with the success status
273
+ */
274
+ updateFlowMetadata(flowId: string, data: {
275
+ name?: string;
276
+ categories?: FlowCategoryEnum[];
277
+ endpoint_uri?: string;
278
+ application_id?: string;
279
+ }): Promise<ResponseSuccess>;
280
+ /**
281
+ * Delete Flow
282
+ *
283
+ * @param flowId - The flow ID
284
+ * @returns Promise with the success status
285
+ */
286
+ deleteFlow(flowId: string): Promise<ResponseSuccess>;
287
+ /**
288
+ * List Assets (Get Flow JSON URL)
289
+ *
290
+ * @param flowId - The flow ID
291
+ * @returns Promise with the list of assets
292
+ */
293
+ listAssets(flowId: string): Promise<FlowAssetsResponse>;
294
+ /**
295
+ * Update Flow JSON
296
+ *
297
+ * @param flowId - The flow ID
298
+ * @param data - The asset data including asset_type, file, and name
299
+ * @returns Promise with the success status and validation errors
300
+ */
301
+ updateFlowJson(flowId: string, data: {
302
+ file: Blob | Buffer | object;
303
+ name?: string;
304
+ }): Promise<UpdateFlowResponse>;
305
+ /**
306
+ * Validate Flow JSON by attempting an update without publishing.
307
+ * This is a convenience method; the API doesn't have a dedicated validation endpoint.
308
+ *
309
+ * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
310
+ * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
311
+ * @returns Promise indicating if the JSON is valid and includes validation errors if any.
312
+ */
313
+ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
314
+ /**
315
+ * Publish Flow
316
+ *
317
+ * @param flowId - The flow ID
318
+ * @returns Promise with the success status
319
+ */
320
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
321
+ /**
322
+ * Deprecate Flow
323
+ *
324
+ * @param flowId - The flow ID
325
+ * @returns Promise with the success status
326
+ */
327
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
328
+ /**
329
+ * Migrate Flows
330
+ *
331
+ * @param wabaId - The destination WABA ID
332
+ * @param data - The migration data including source_waba_id and optional source_flow_names
333
+ * @returns Promise with migration results
334
+ */
335
+ migrateFlows(wabaId: string, data: {
336
+ source_waba_id: string;
337
+ source_flow_names?: string[];
338
+ }): Promise<FlowMigrationResponse>;
339
+ }
340
+
341
+ /**
342
+ * API for managing WhatsApp Flows.
343
+ *
344
+ * This API allows you to:
345
+ * - List flows
346
+ * - Create flows
347
+ * - Get flow details and previews
348
+ * - Update flow metadata and JSON
349
+ * - Delete flows
350
+ * - Publish and deprecate flows
351
+ * - Migrate flows between WABAs
352
+ * - Validate flow JSON
353
+ */
354
+ declare class FlowApi extends BaseAPI implements FlowClass {
355
+ constructor(config: WabaConfigType, client: RequesterClass);
356
+ /**
357
+ * List Flows
358
+ *
359
+ * @param wabaId - The WABA ID
360
+ * @returns Promise with the list of flows
361
+ */
362
+ listFlows(wabaId: string): Promise<FlowsListResponse>;
363
+ /**
364
+ * Create Flow
365
+ *
366
+ * @param wabaId - The WABA ID
367
+ * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
368
+ * @returns Promise with the created flow ID and validation errors if any
369
+ */
370
+ createFlow(wabaId: string, data: {
371
+ name: string;
372
+ categories?: FlowCategoryEnum[];
373
+ endpoint_uri?: string;
374
+ clone_flow_id?: string;
375
+ flow_json?: string;
376
+ publish?: boolean;
377
+ }): Promise<CreateFlowResponse>;
378
+ /**
379
+ * Get Flow details
380
+ *
381
+ * @param flowId - The flow ID
382
+ * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')
383
+ * @param dateFormat - Optional date format
384
+ * @returns Promise with the flow details or preview response
385
+ */
386
+ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
387
+ /**
388
+ * Get Flow Preview URL
389
+ *
390
+ * @param flowId - The flow ID
391
+ * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.
392
+ * @returns Promise with the flow preview details
393
+ */
394
+ getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
395
+ /**
396
+ * Update Flow Metadata
397
+ *
398
+ * @param flowId - The flow ID
399
+ * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)
400
+ * @returns Promise with the success status
401
+ */
402
+ updateFlowMetadata(flowId: string, data: {
403
+ name?: string;
404
+ categories?: FlowCategoryEnum[];
405
+ endpoint_uri?: string;
406
+ application_id?: string;
407
+ }): Promise<ResponseSuccess>;
408
+ /**
409
+ * Delete Flow (only works if the Flow is in DRAFT status)
410
+ *
411
+ * @param flowId - The flow ID
412
+ * @returns Promise with the success status
413
+ */
414
+ deleteFlow(flowId: string): Promise<ResponseSuccess>;
415
+ /**
416
+ * List Assets (e.g., get Flow JSON download URL)
417
+ *
418
+ * @param flowId - The flow ID
419
+ * @returns Promise with the list of assets
420
+ */
421
+ listAssets(flowId: string): Promise<FlowAssetsResponse>;
422
+ /**
423
+ * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.
424
+ *
425
+ * @param flowId - The flow ID
426
+ * @param data - Object containing the file data and optional name.
427
+ * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.
428
+ * @param data.name - Optional name for the asset, defaults to 'flow.json'.
429
+ * @returns Promise with the success status and validation errors, if any.
430
+ */
431
+ updateFlowJson(flowId: string, data: {
432
+ file: Blob | Buffer | object;
433
+ name?: string;
434
+ }): Promise<UpdateFlowResponse>;
435
+ /**
436
+ * Validate Flow JSON by attempting an update without publishing.
437
+ * This is a convenience method; the API doesn't have a dedicated validation endpoint.
438
+ *
439
+ * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
440
+ * @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob.
441
+ * @returns Promise indicating if the JSON is valid and includes validation errors if any.
442
+ */
443
+ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
444
+ /**
445
+ * Publish Flow
446
+ *
447
+ * @param flowId - The flow ID
448
+ * @returns Promise with the success status
449
+ */
450
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
451
+ /**
452
+ * Deprecate Flow
453
+ *
454
+ * @param flowId - The flow ID
455
+ * @returns Promise with the success status
456
+ */
457
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
458
+ /**
459
+ * Migrate Flows between WABAs
460
+ *
461
+ * @param destinationWabaId - The destination WABA ID
462
+ * @param data - The migration data including source_waba_id and optional source_flow_names
463
+ * @returns Promise with migration results (successes and failures)
464
+ */
465
+ migrateFlows(destinationWabaId: string, data: {
466
+ source_waba_id: string;
467
+ source_flow_names?: string[];
468
+ }): Promise<FlowMigrationResponse>;
469
+ }
470
+
471
+ export { type CreateFlowResponse as C, FlowApi as F, type UpdateFlowResponse as U, type ValidateFlowJsonResponse as V, type FlowEndpointRequest as a, FlowTypeEnum as b, type Flow as c, type FlowClass as d, type FlowEndpointResponse as e, FlowActionEnum as f, type FlowAssetsResponse as g, FlowCategoryEnum as h, type FlowMigrationResponse as i, type FlowPreviewResponse as j, type FlowsListResponse as k, FlowStatusEnum as l, type FlowValidationError as m };
@@ -0,0 +1,89 @@
1
+ import { b as ResponseSuccess, a as BaseAPI, R as RequesterClass } from './base-BG2gtoDs.js';
2
+ import { WabaConfigType } from './shared/types/config.js';
3
+
4
+ type MediaResponse = {
5
+ id: string;
6
+ url: string;
7
+ mime_type: string;
8
+ sha256: string;
9
+ file_size: number;
10
+ messaging_product: 'whatsapp';
11
+ };
12
+ type MediasResponse = {
13
+ data: MediaResponse[];
14
+ paging: {
15
+ cursors: {
16
+ before: string;
17
+ after: string;
18
+ };
19
+ };
20
+ };
21
+ type UploadMediaResponse = {
22
+ id: string;
23
+ };
24
+ interface MediaClass {
25
+ getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
26
+ uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
27
+ deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
28
+ downloadMedia(mediaUrl: string): Promise<Blob>;
29
+ }
30
+
31
+ /**
32
+ * API for managing WhatsApp Media.
33
+ *
34
+ * This API allows you to:
35
+ * - Get media information by ID
36
+ * - Upload media files
37
+ * - Delete media files
38
+ * - Download media files from URLs
39
+ */
40
+ declare class MediaApi extends BaseAPI implements MediaClass {
41
+ private readonly endpoint;
42
+ constructor(config: WabaConfigType, client: RequesterClass);
43
+ /**
44
+ * Retrieve media information by media ID.
45
+ *
46
+ * @param mediaId The media ID to retrieve information for
47
+ * @param phone_number_id Optional phone number ID (defaults to configured one)
48
+ * @returns Media information including URL, mime type, file size, etc.
49
+ *
50
+ * @example
51
+ * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');
52
+ */
53
+ getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
54
+ /**
55
+ * Upload a media file to WhatsApp.
56
+ *
57
+ * @param file The file to upload
58
+ * @param messagingProduct The messaging product (default: 'whatsapp')
59
+ * @returns Upload response containing the media ID
60
+ *
61
+ * @example
62
+ * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
63
+ * const result = await whatsappClient.media.uploadMedia(file);
64
+ */
65
+ uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
66
+ /**
67
+ * Delete a media file.
68
+ *
69
+ * @param mediaId The media ID to delete
70
+ * @param phone_number_id Optional phone number ID (defaults to configured one)
71
+ * @returns Response indicating success or failure
72
+ *
73
+ * @example
74
+ * await whatsappClient.media.deleteMedia('media_id_123');
75
+ */
76
+ deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
77
+ /**
78
+ * Download media from a URL.
79
+ *
80
+ * @param mediaUrl The URL to download media from
81
+ * @returns Blob containing the media data
82
+ *
83
+ * @example
84
+ * const blob = await whatsappClient.media.downloadMedia('https://...');
85
+ */
86
+ downloadMedia(mediaUrl: string): Promise<Blob>;
87
+ }
88
+
89
+ export { MediaApi as M, type UploadMediaResponse as U, type MediaClass as a, type MediaResponse as b, type MediasResponse as c };