meta-cloud-api 0.1.7 → 0.1.9

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 (85) hide show
  1. package/dist/api/base.d.mts +3 -1
  2. package/dist/api/base.d.ts +3 -1
  3. package/dist/api/base.js +1 -1
  4. package/dist/api/base.js.map +1 -1
  5. package/dist/api/base.mjs +1 -1
  6. package/dist/api/base.mjs.map +1 -1
  7. package/dist/api/businessProfile.d.mts +5 -2
  8. package/dist/api/businessProfile.d.ts +5 -2
  9. package/dist/api/businessProfile.js +1 -1
  10. package/dist/api/businessProfile.js.map +1 -1
  11. package/dist/api/businessProfile.mjs +1 -1
  12. package/dist/api/businessProfile.mjs.map +1 -1
  13. package/dist/api/encryption.js +1 -1
  14. package/dist/api/encryption.js.map +1 -1
  15. package/dist/api/encryption.mjs +1 -1
  16. package/dist/api/encryption.mjs.map +1 -1
  17. package/dist/api/flow.js +1 -1
  18. package/dist/api/flow.js.map +1 -1
  19. package/dist/api/flow.mjs +1 -1
  20. package/dist/api/flow.mjs.map +1 -1
  21. package/dist/api/index.d.mts +1 -1
  22. package/dist/api/index.d.ts +1 -1
  23. package/dist/api/index.js +1 -1
  24. package/dist/api/index.js.map +1 -1
  25. package/dist/api/index.mjs +1 -1
  26. package/dist/api/index.mjs.map +1 -1
  27. package/dist/api/media.js +1 -1
  28. package/dist/api/media.js.map +1 -1
  29. package/dist/api/media.mjs +1 -1
  30. package/dist/api/media.mjs.map +1 -1
  31. package/dist/api/messages.js +1 -1
  32. package/dist/api/messages.js.map +1 -1
  33. package/dist/api/messages.mjs +1 -1
  34. package/dist/api/messages.mjs.map +1 -1
  35. package/dist/api/phoneNumber.js +1 -1
  36. package/dist/api/phoneNumber.js.map +1 -1
  37. package/dist/api/phoneNumber.mjs +1 -1
  38. package/dist/api/phoneNumber.mjs.map +1 -1
  39. package/dist/api/qrCode.js +1 -1
  40. package/dist/api/qrCode.js.map +1 -1
  41. package/dist/api/qrCode.mjs +1 -1
  42. package/dist/api/qrCode.mjs.map +1 -1
  43. package/dist/api/registration.js +1 -1
  44. package/dist/api/registration.js.map +1 -1
  45. package/dist/api/registration.mjs +1 -1
  46. package/dist/api/registration.mjs.map +1 -1
  47. package/dist/api/template.js +1 -1
  48. package/dist/api/template.js.map +1 -1
  49. package/dist/api/template.mjs +1 -1
  50. package/dist/api/template.mjs.map +1 -1
  51. package/dist/api/twoStepVerification.js +1 -1
  52. package/dist/api/twoStepVerification.js.map +1 -1
  53. package/dist/api/twoStepVerification.mjs +1 -1
  54. package/dist/api/twoStepVerification.mjs.map +1 -1
  55. package/dist/api/waba.js +1 -1
  56. package/dist/api/waba.js.map +1 -1
  57. package/dist/api/waba.mjs +1 -1
  58. package/dist/api/waba.mjs.map +1 -1
  59. package/dist/index.d.mts +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +1 -1
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/request.d.mts +5 -3
  66. package/dist/request.d.ts +5 -3
  67. package/dist/request.js +1 -1
  68. package/dist/request.js.map +1 -1
  69. package/dist/request.mjs +1 -1
  70. package/dist/request.mjs.map +1 -1
  71. package/dist/types/businessProfile.d.mts +8 -4
  72. package/dist/types/businessProfile.d.ts +8 -4
  73. package/dist/types/businessProfile.js +1 -1
  74. package/dist/types/businessProfile.js.map +1 -1
  75. package/dist/types/index.d.mts +1 -1
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/types/request.d.mts +5 -3
  78. package/dist/types/request.d.ts +5 -3
  79. package/dist/types/request.js +1 -1
  80. package/dist/types/request.js.map +1 -1
  81. package/dist/whatsapp.js +1 -1
  82. package/dist/whatsapp.js.map +1 -1
  83. package/dist/whatsapp.mjs +1 -1
  84. package/dist/whatsapp.mjs.map +1 -1
  85. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/flow.ts"],"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","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n","import { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateFlowResponse,\n Flow,\n FlowAssetsResponse,\n FlowCategoryEnum,\n FlowClass,\n FlowMigrationResponse,\n FlowPreviewResponse,\n FlowsListResponse,\n UpdateFlowResponse,\n ValidateFlowJsonResponse,\n} from '../types/flow';\nimport { RequesterClass, ResponseSuccess } from '../types/request';\nimport Logger from '../utils/logger';\nimport BaseAPI from './base';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<FlowsListResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `/${wabaId}/flows`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\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 and validation errors if any\n */\n async 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; // Flow JSON as a string\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse> {\n // The API expects application/json for this endpoint based on documentation examples\n // Let's ensure we send JSON, not FormData, unless specifically required by an endpoint variation.\n const payload = {\n name: data.name,\n categories: data.categories,\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.clone_flow_id && { clone_flow_id: data.clone_flow_id }),\n ...(data.flow_json && { flow_json: data.flow_json }),\n ...(data.publish !== undefined && { publish: data.publish }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Get Flow details\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details or preview response\n */\n async getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get Flow Preview URL\n *\n * @param flowId - The flow ID\n * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.\n * @returns Promise with the flow preview details\n */\n async getFlowPreview(flowId: string, invalidate: boolean = false): Promise<FlowPreviewResponse> {\n const fields = `preview.invalidate(${invalidate})`;\n // Type assertion needed as getFlow can return Flow or FlowPreviewResponse\n return this.getFlow(flowId, fields) as Promise<FlowPreviewResponse>;\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)\n * @returns Promise with the success status\n */\n async 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 // The API expects application/json for this endpoint based on documentation examples\n const payload = {\n ...(data.name && { name: data.name }),\n ...(data.categories && { categories: data.categories }),\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.application_id && { application_id: data.application_id }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Delete Flow (only works if the Flow is in DRAFT status)\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * List Assets (e.g., get Flow JSON download URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<FlowAssetsResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.\n *\n * @param flowId - The flow ID\n * @param data - Object containing the file data and optional name.\n * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @param data.name - Optional name for the asset, defaults to 'flow.json'.\n * @returns Promise with the success status and validation errors, if any.\n */\n async updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object; // JSON object, Buffer, or Blob\n name?: string; // Default to \"flow.json\"\n },\n ): Promise<UpdateFlowResponse> {\n const formData = new FormData();\n let fileContent: Blob;\n\n // Handle different input types for the file\n if (data.file instanceof Buffer) {\n // Buffer\n // Create a Blob from the Buffer and cast it to the global Blob type\n fileContent = new globalThis.Blob([data.file]);\n formData.append('file', fileContent as unknown as Blob);\n } else if (typeof data.file === 'object' && !(data.file instanceof Blob)) {\n // JSON object - stringify and create Blob\n try {\n // Create a Blob from the JSON string and cast it to the global Blob type\n fileContent = new globalThis.Blob([JSON.stringify(data.file, null, 2)], { type: 'application/json' });\n formData.append('file', fileContent as unknown as Blob);\n } catch (e) {\n throw new Error('Failed to stringify JSON object for Flow JSON update.');\n }\n } else if (data.file instanceof Blob) {\n // Blob (already in correct format)\n fileContent = data.file;\n formData.append('file', fileContent as unknown as Blob);\n } else {\n throw new Error('Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.');\n }\n\n formData.append('asset_type', 'FLOW_JSON'); // Required by API\n formData.append('name', data.name || 'flow.json'); // Required by API\n\n // The underlying.sendJson needs to correctly handle FormData\n // It might need specific headers like `Content-Type: multipart/form-data; boundary=...`\n // which FormData library usually helps generate.\n // Assuming.sendJson handles FormData correctly:\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData, // Pass FormData directly\n // Headers might be set automatically by the client when FormData is detected,\n // or might need to be explicitly set depending on the client implementation.\n // e.g., { 'Content-Type': `multipart/form-data; boundary=${formData.getBoundary()}` }\n );\n }\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 file path (string), Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n async validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse> {\n try {\n const result = await this.updateFlowJson(flowId, {\n file: flowJsonData,\n });\n\n const isValid = !result.validation_errors || result.validation_errors.length === 0;\n\n const enhancedResponse = {\n ...result,\n valid: isValid,\n };\n\n return enhancedResponse;\n } catch (error) {\n LOGGER.error('Error during Flow JSON validation attempt:', error);\n throw error;\n }\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Migrate Flows between WABAs\n *\n * @param destinationWabaId - 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 (successes and failures)\n */\n async migrateFlows(\n destinationWabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse> {\n // API documentation suggests this endpoint might expect application/json\n // Let's double-check or assume JSON based on typical Graph API patterns unless FormData is confirmed.\n // Assuming JSON for now:\n const payload = {\n source_waba_id: data.source_waba_id,\n ...(data.source_flow_names && { source_flow_names: data.source_flow_names }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${destinationWabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload),\n );\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MA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","endpoint","timeout","body","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","payload","flowId","fields","dateFormat","params","queryString","invalidate","formData","fileContent","flowJsonData","result","isValid","error","destinationWabaId"]}
1
+ {"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/flow.ts"],"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","import { HttpMethodsEnum } from 'src/types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\n}\n","import { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateFlowResponse,\n Flow,\n FlowAssetsResponse,\n FlowCategoryEnum,\n FlowClass,\n FlowMigrationResponse,\n FlowPreviewResponse,\n FlowsListResponse,\n UpdateFlowResponse,\n ValidateFlowJsonResponse,\n} from '../types/flow';\nimport { RequesterClass, ResponseSuccess } from '../types/request';\nimport Logger from '../utils/logger';\nimport BaseAPI from './base';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<FlowsListResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `/${wabaId}/flows`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\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 and validation errors if any\n */\n async 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; // Flow JSON as a string\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse> {\n // The API expects application/json for this endpoint based on documentation examples\n // Let's ensure we send JSON, not FormData, unless specifically required by an endpoint variation.\n const payload = {\n name: data.name,\n categories: data.categories,\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.clone_flow_id && { clone_flow_id: data.clone_flow_id }),\n ...(data.flow_json && { flow_json: data.flow_json }),\n ...(data.publish !== undefined && { publish: data.publish }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Get Flow details\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details or preview response\n */\n async getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get Flow Preview URL\n *\n * @param flowId - The flow ID\n * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.\n * @returns Promise with the flow preview details\n */\n async getFlowPreview(flowId: string, invalidate: boolean = false): Promise<FlowPreviewResponse> {\n const fields = `preview.invalidate(${invalidate})`;\n // Type assertion needed as getFlow can return Flow or FlowPreviewResponse\n return this.getFlow(flowId, fields) as Promise<FlowPreviewResponse>;\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)\n * @returns Promise with the success status\n */\n async 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 // The API expects application/json for this endpoint based on documentation examples\n const payload = {\n ...(data.name && { name: data.name }),\n ...(data.categories && { categories: data.categories }),\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.application_id && { application_id: data.application_id }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Delete Flow (only works if the Flow is in DRAFT status)\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * List Assets (e.g., get Flow JSON download URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<FlowAssetsResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.\n *\n * @param flowId - The flow ID\n * @param data - Object containing the file data and optional name.\n * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @param data.name - Optional name for the asset, defaults to 'flow.json'.\n * @returns Promise with the success status and validation errors, if any.\n */\n async updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object; // JSON object, Buffer, or Blob\n name?: string; // Default to \"flow.json\"\n },\n ): Promise<UpdateFlowResponse> {\n const formData = new FormData();\n let fileContent: Blob;\n\n // Handle different input types for the file\n if (data.file instanceof Buffer) {\n // Buffer\n // Create a Blob from the Buffer and cast it to the global Blob type\n fileContent = new globalThis.Blob([data.file]);\n formData.append('file', fileContent as unknown as Blob);\n } else if (typeof data.file === 'object' && !(data.file instanceof Blob)) {\n // JSON object - stringify and create Blob\n try {\n // Create a Blob from the JSON string and cast it to the global Blob type\n fileContent = new globalThis.Blob([JSON.stringify(data.file, null, 2)], { type: 'application/json' });\n formData.append('file', fileContent as unknown as Blob);\n } catch (e) {\n throw new Error('Failed to stringify JSON object for Flow JSON update.');\n }\n } else if (data.file instanceof Blob) {\n // Blob (already in correct format)\n fileContent = data.file;\n formData.append('file', fileContent as unknown as Blob);\n } else {\n throw new Error('Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.');\n }\n\n formData.append('asset_type', 'FLOW_JSON'); // Required by API\n formData.append('name', data.name || 'flow.json'); // Required by API\n\n return this.sendFormData(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\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 file path (string), Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n async validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse> {\n try {\n const result = await this.updateFlowJson(flowId, {\n file: flowJsonData,\n });\n\n const isValid = !result.validation_errors || result.validation_errors.length === 0;\n\n const enhancedResponse = {\n ...result,\n valid: isValid,\n };\n\n return enhancedResponse;\n } catch (error) {\n LOGGER.error('Error during Flow JSON validation attempt:', error);\n throw error;\n }\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Migrate Flows between WABAs\n *\n * @param destinationWabaId - 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 (successes and failures)\n */\n async migrateFlows(\n destinationWabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse> {\n // API documentation suggests this endpoint might expect application/json\n // Let's double-check or assume JSON based on typical Graph API patterns unless FormData is confirmed.\n // Assuming JSON for now:\n const payload = {\n source_waba_id: data.source_waba_id,\n ...(data.source_flow_names && { source_flow_names: data.source_flow_names }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${destinationWabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload),\n );\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,I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,cAAcA,EAA0C,CAE1D,OAAO,KAAK,gBAER,IAAIA,CAAM,aACV,KAAK,OAAO,gBACZ,KAAK,UAAU,CAAC,CAAC,CACrB,CACJ,CASA,MAAM,aACFY,EACAd,EAI8B,CAI9B,IAAMC,EAAU,CACZ,eAAgBD,EAAK,eACrB,GAAIA,EAAK,mBAAqB,CAAE,kBAAmBA,EAAK,iBAAkB,CAC9E,EAEA,OAAO,KAAK,gBAER,IAAIc,CAAiB,iBACrB,KAAK,OAAO,gBACZ,KAAK,UAAUb,CAAO,CAC1B,CACJ,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","payload","flowId","fields","dateFormat","params","queryString","invalidate","formData","fileContent","flowJsonData","result","isValid","error","destinationWabaId"]}
@@ -10,9 +10,9 @@ export { default as RegistrationAPI } from './registration.mjs';
10
10
  export { default as TemplateAPI } from './template.mjs';
11
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.mjs';
12
12
  export { default as WabaAPI } from './waba.mjs';
13
+ import '../enums-D7paGoTY.mjs';
13
14
  import '../types/base.mjs';
14
15
  import '../types/config.mjs';
15
- import '../enums-D7paGoTY.mjs';
16
16
  import '../types/request.mjs';
17
17
  import '../types/businessProfile.mjs';
18
18
  import '../types/encryption.mjs';
@@ -10,9 +10,9 @@ export { default as RegistrationAPI } from './registration.js';
10
10
  export { default as TemplateAPI } from './template.js';
11
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.js';
12
12
  export { default as WabaAPI } from './waba.js';
13
+ import '../enums-D7paGoTY.js';
13
14
  import '../types/base.js';
14
15
  import '../types/config.js';
15
- import '../enums-D7paGoTY.js';
16
16
  import '../types/request.js';
17
17
  import '../types/businessProfile.js';
18
18
  import '../types/encryption.js';
package/dist/api/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var M=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var U=(o,t)=>{for(var e in t)M(o,e,{get:t[e],enumerable:!0})},G=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of D(t))!m.call(o,i)&&i!==e&&M(o,i,{get:()=>t[i],enumerable:!(s=_(t,i))||s.enumerable});return o};var w=o=>G(M({},"__esModule",{value:!0}),o);var v={};U(v,{BaseAPI:()=>a,BusinessProfileAPI:()=>f,EncryptionAPI:()=>P,FlowAPI:()=>h,MediaAPI:()=>c,MessagesAPI:()=>g,PhoneNumberAPI:()=>S,QrCodeAPI:()=>T,RegistrationAPI:()=>A,TemplateAPI:()=>b,TwoStepVerificationAPI:()=>d,WabaAPI:()=>I});module.exports=w(v);var n=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var q="BaseAPI",F=!1,J=new n(q,process.env.DEBUG==="true"||F),a=class{config;client;constructor(t,e){this.config=t,this.client=e,J.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}};var R=o=>{if(!o||Object.keys(o).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(o))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var f=class extends a{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${e}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var P=class extends a{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var x="FlowAPI",K=!1,B=new n(x,process.env.DEBUG==="true"||K),h=class extends a{constructor(t,e){super(t,e),B.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendJson("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw B.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var c=class extends a{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var g=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,N;return typeof e=="string"?N={body:e,preview_url:s}:N=e,this.send(JSON.stringify(this.bodyBuilder("text",N,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var S=class extends a{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var T=class extends a{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends a{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends a{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var d=class extends a{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};function O(o){if(!o)return"";let t="";return Array.isArray(o)?t=o.join(","):t=Object.entries(o).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var I=class extends a{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=O(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};0&&(module.exports={BaseAPI,BusinessProfileAPI,EncryptionAPI,FlowAPI,MediaAPI,MessagesAPI,PhoneNumberAPI,QrCodeAPI,RegistrationAPI,TemplateAPI,TwoStepVerificationAPI,WabaAPI});
1
+ "use strict";var B=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var U=(o,t)=>{for(var e in t)B(o,e,{get:t[e],enumerable:!0})},G=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of m(t))!D.call(o,i)&&i!==e&&B(o,i,{get:()=>t[i],enumerable:!(s=_(t,i))||s.enumerable});return o};var w=o=>G(B({},"__esModule",{value:!0}),o);var H={};U(H,{BaseAPI:()=>a,BusinessProfileAPI:()=>f,EncryptionAPI:()=>P,FlowAPI:()=>h,MediaAPI:()=>c,MessagesAPI:()=>g,PhoneNumberAPI:()=>S,QrCodeAPI:()=>T,RegistrationAPI:()=>d,TemplateAPI:()=>A,TwoStepVerificationAPI:()=>b,WabaAPI:()=>I});module.exports=w(H);var n=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var F="BaseAPI",q=!1,J=new n(F,process.env.DEBUG==="true"||q),a=class{config;client;constructor(t,e){this.config=t,this.client=e,J.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function M(o){if(!o)return"";let t="";return Array.isArray(o)?t=o.join(","):t=Object.entries(o).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=o=>{if(!o||Object.keys(o).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(o))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var f=class extends a{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${M(t)}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var P=class extends a{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var x="FlowAPI",K=!1,O=new n(x,process.env.DEBUG==="true"||K),h=class extends a{constructor(t,e){super(t,e),O.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw O.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var c=class extends a{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var g=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,N;return typeof e=="string"?N={body:e,preview_url:s}:N=e,this.send(JSON.stringify(this.bodyBuilder("text",N,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var S=class extends a{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var T=class extends a{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var d=class extends a{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends a{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends a{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var I=class extends a{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=M(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};0&&(module.exports={BaseAPI,BusinessProfileAPI,EncryptionAPI,FlowAPI,MediaAPI,MessagesAPI,PhoneNumberAPI,QrCodeAPI,RegistrationAPI,TemplateAPI,TwoStepVerificationAPI,WabaAPI});
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/index.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/utils/objectToQueryString.ts","../../src/api/businessProfile.ts","../../src/api/encryption.ts","../../src/api/flow.ts","../../src/api/media.ts","../../src/api/messages.ts","../../src/api/phoneNumber.ts","../../src/api/qrCode.ts","../../src/api/registration.ts","../../src/api/template.ts","../../src/api/twoStepVerification.ts","../../src/utils/buildFieldsQueryString.ts","../../src/api/waba.ts"],"sourcesContent":["import BaseAPI from './base';\nimport BusinessProfileAPI from './businessProfile';\nimport EncryptionAPI from './encryption';\nimport FlowAPI from './flow';\nimport MediaAPI from './media';\nimport MessagesAPI from './messages';\nimport PhoneNumberAPI from './phoneNumber';\nimport QrCodeAPI from './qrCode';\nimport RegistrationAPI from './registration';\nimport TemplateAPI from './template';\nimport TwoStepVerificationAPI from './twoStepVerification';\nimport WabaAPI from './waba';\n\nexport {\n BaseAPI,\n BusinessProfileAPI,\n EncryptionAPI,\n FlowAPI,\n MediaAPI,\n MessagesAPI,\n PhoneNumberAPI,\n QrCodeAPI,\n RegistrationAPI,\n TemplateAPI,\n TwoStepVerificationAPI,\n WabaAPI,\n};\n","// @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","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\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","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<BusinessProfileResponse> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateFlowResponse,\n Flow,\n FlowAssetsResponse,\n FlowCategoryEnum,\n FlowClass,\n FlowMigrationResponse,\n FlowPreviewResponse,\n FlowsListResponse,\n UpdateFlowResponse,\n ValidateFlowJsonResponse,\n} from '../types/flow';\nimport { RequesterClass, ResponseSuccess } from '../types/request';\nimport Logger from '../utils/logger';\nimport BaseAPI from './base';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<FlowsListResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `/${wabaId}/flows`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\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 and validation errors if any\n */\n async 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; // Flow JSON as a string\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse> {\n // The API expects application/json for this endpoint based on documentation examples\n // Let's ensure we send JSON, not FormData, unless specifically required by an endpoint variation.\n const payload = {\n name: data.name,\n categories: data.categories,\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.clone_flow_id && { clone_flow_id: data.clone_flow_id }),\n ...(data.flow_json && { flow_json: data.flow_json }),\n ...(data.publish !== undefined && { publish: data.publish }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Get Flow details\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details or preview response\n */\n async getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get Flow Preview URL\n *\n * @param flowId - The flow ID\n * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.\n * @returns Promise with the flow preview details\n */\n async getFlowPreview(flowId: string, invalidate: boolean = false): Promise<FlowPreviewResponse> {\n const fields = `preview.invalidate(${invalidate})`;\n // Type assertion needed as getFlow can return Flow or FlowPreviewResponse\n return this.getFlow(flowId, fields) as Promise<FlowPreviewResponse>;\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)\n * @returns Promise with the success status\n */\n async 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 // The API expects application/json for this endpoint based on documentation examples\n const payload = {\n ...(data.name && { name: data.name }),\n ...(data.categories && { categories: data.categories }),\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.application_id && { application_id: data.application_id }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Delete Flow (only works if the Flow is in DRAFT status)\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * List Assets (e.g., get Flow JSON download URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<FlowAssetsResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.\n *\n * @param flowId - The flow ID\n * @param data - Object containing the file data and optional name.\n * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @param data.name - Optional name for the asset, defaults to 'flow.json'.\n * @returns Promise with the success status and validation errors, if any.\n */\n async updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object; // JSON object, Buffer, or Blob\n name?: string; // Default to \"flow.json\"\n },\n ): Promise<UpdateFlowResponse> {\n const formData = new FormData();\n let fileContent: Blob;\n\n // Handle different input types for the file\n if (data.file instanceof Buffer) {\n // Buffer\n // Create a Blob from the Buffer and cast it to the global Blob type\n fileContent = new globalThis.Blob([data.file]);\n formData.append('file', fileContent as unknown as Blob);\n } else if (typeof data.file === 'object' && !(data.file instanceof Blob)) {\n // JSON object - stringify and create Blob\n try {\n // Create a Blob from the JSON string and cast it to the global Blob type\n fileContent = new globalThis.Blob([JSON.stringify(data.file, null, 2)], { type: 'application/json' });\n formData.append('file', fileContent as unknown as Blob);\n } catch (e) {\n throw new Error('Failed to stringify JSON object for Flow JSON update.');\n }\n } else if (data.file instanceof Blob) {\n // Blob (already in correct format)\n fileContent = data.file;\n formData.append('file', fileContent as unknown as Blob);\n } else {\n throw new Error('Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.');\n }\n\n formData.append('asset_type', 'FLOW_JSON'); // Required by API\n formData.append('name', data.name || 'flow.json'); // Required by API\n\n // The underlying.sendJson needs to correctly handle FormData\n // It might need specific headers like `Content-Type: multipart/form-data; boundary=...`\n // which FormData library usually helps generate.\n // Assuming.sendJson handles FormData correctly:\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData, // Pass FormData directly\n // Headers might be set automatically by the client when FormData is detected,\n // or might need to be explicitly set depending on the client implementation.\n // e.g., { 'Content-Type': `multipart/form-data; boundary=${formData.getBoundary()}` }\n );\n }\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 file path (string), Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n async validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse> {\n try {\n const result = await this.updateFlowJson(flowId, {\n file: flowJsonData,\n });\n\n const isValid = !result.validation_errors || result.validation_errors.length === 0;\n\n const enhancedResponse = {\n ...result,\n valid: isValid,\n };\n\n return enhancedResponse;\n } catch (error) {\n LOGGER.error('Error during Flow JSON validation attempt:', error);\n throw error;\n }\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Migrate Flows between WABAs\n *\n * @param destinationWabaId - 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 (successes and failures)\n */\n async migrateFlows(\n destinationWabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse> {\n // API documentation suggests this endpoint might expect application/json\n // Let's double-check or assume JSON based on typical Graph API patterns unless FormData is confirmed.\n // Assuming JSON for now:\n const payload = {\n source_waba_id: data.source_waba_id,\n ...(data.source_flow_names && { source_flow_names: data.source_flow_names }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${destinationWabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload),\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { MediaClass, MediaResponse, UploadMediaResponse } from '../types/media';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class MediaAPI extends BaseAPI implements MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getMediaById(mediaId: string): Promise<MediaResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async uploadMedia(file: File, messagingProduct: string = 'whatsapp'): Promise<UploadMediaResponse> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n async deleteMedia(mediaId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async downloadMedia(mediaUrl: string): Promise<Blob> {\n return this.sendJson(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\n// Request object interface type definitions\nexport interface MessageRequestParams<T> {\n body: T;\n to: string;\n replyMessageId?: string;\n}\n\nexport interface TextMessageParams extends MessageRequestParams<m.TextObject | string> {\n previewUrl?: boolean;\n}\n\nexport interface ReactionParams {\n messageId: string;\n emoji: string;\n to: string;\n}\n\nexport interface StatusParams {\n status: string;\n messageId: string;\n typingIndicator?: {\n type: string;\n };\n}\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param to The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<m.MessagesResponse> {\n return this.sendJson(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n async audio(params: m.MessageRequestParams<m.AudioMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n async contacts(params: m.MessageRequestParams<[m.ContactObject]>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n async document(params: m.MessageRequestParams<m.DocumentMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n async image(params: m.MessageRequestParams<m.ImageMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n async interactive(params: m.MessageRequestParams<m.InteractiveObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n async location(params: m.MessageRequestParams<m.LocationObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n async sticker(params: m.MessageRequestParams<m.StickerMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n async template(\n params: m.MessageRequestParams<m.MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n async text(params: m.TextMessageParams): Promise<m.MessagesResponse> {\n const { body, previewUrl, to, replyMessageId } = params;\n\n let textObject: m.TextObject;\n if (typeof body === 'string') {\n textObject = {\n body: body,\n preview_url: previewUrl,\n };\n } else {\n textObject = body;\n }\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, textObject, to, replyMessageId)));\n }\n\n /**\n * Sends a video via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n async video(params: m.MessageRequestParams<m.VideoMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param params The status update parameter object\n * @returns Promise with the response\n */\n async status(params: m.StatusParams): Promise<m.MessagesResponse> {\n const { status, messageId, typingIndicator } = params;\n\n const bodyToSend = {\n messaging_product: 'whatsapp',\n status: status,\n message_id: messageId,\n ...(typingIndicator && { typing_indicator: typingIndicator }),\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param params The parameter object to mark message as read\n * @returns Promise with the response\n */\n async markAsRead(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param params The typing indicator parameter object\n * @returns Promise with the response\n */\n async showTypingIndicator(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n typingIndicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param params The list message parameter object\n * @returns Promise with the response\n */\n async interactiveList(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param params The CTA URL message parameter object\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location request message\n * @param params The location request message parameter object\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param params The address message parameter object\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param params The reply buttons message parameter object\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive Flow message\n * @param params The Flow message parameter object\n * @returns Promise with the response\n */\n async interactiveFlow(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n\n // Apply default values for FlowParameters\n if (body.action.parameters.flow_message_version === undefined) {\n body.action.parameters.flow_message_version = '3';\n }\n if (body.action.parameters.mode === undefined) {\n body.action.parameters.mode = 'published';\n }\n if (body.action.parameters.flow_action === undefined) {\n body.action.parameters.flow_action = 'navigate';\n }\n\n // Only include flow_action_payload when flow_action is navigate\n if (body.action.parameters.flow_action === 'navigate') {\n if (body.action.parameters.flow_action_payload?.screen === undefined) {\n body.action.parameters.flow_action_payload = {\n ...body.action.parameters.flow_action_payload,\n screen: 'INIT',\n };\n }\n } else if (body.action.parameters.flow_action === 'data_exchange') {\n // Remove flow_action_payload when flow_action is data_exchange\n delete body.action.parameters.flow_action_payload;\n }\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param params The reaction message parameter object\n * @returns Promise with the response\n */\n async reaction(params: m.ReactionParams): Promise<m.MessagesResponse> {\n const { messageId, emoji, to } = params;\n\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: to,\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","import {\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n RequestVerificationCodeRequest,\n VerifyCodeRequest,\n} from 'src/types/phoneNumber';\nimport { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getPhoneNumbers(): Promise<PhoneNumbersResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async requestVerificationCode(\n requestVerificationCodeRequest: RequestVerificationCodeRequest,\n ): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(requestVerificationCodeRequest),\n );\n }\n\n async verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(verifyCodeRequest),\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateQrCodeRequest,\n QrCodeClass,\n QrCodeResponse,\n QrCodesResponse,\n UpdateQrCodeRequest,\n} from '../types/qrCode';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class QrCodeAPI extends BaseAPI implements QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async getQrCodes(): Promise<QrCodesResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getQrCode(qrCodeId: string): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async deleteQrCode(qrCodeId: string): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { DataLocalizationRegionEnum, HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport { RegistrationClass } from '../types/registration';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class RegistrationAPI extends BaseAPI implements RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess> {\n const body = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async deregister(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponsePagination, ResponseSuccess } from '../types/request';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from '../types/template';\nimport BaseAPI from './base';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<TemplateResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${templateId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<TemplateResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport { TwoStepVerificationClass } from '../types/twoStepVerification';\nimport BaseAPI from './base';\n\nexport default class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess> {\n const body = {\n pin,\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n","export function buildFieldsQueryString(fields?: string[]): string {\n if (!fields) return '';\n\n let fieldParams = '';\n\n if (Array.isArray(fields)) {\n fieldParams = fields.join(',');\n } else {\n fieldParams = Object.entries(fields)\n .filter(([_, value]) => value)\n .map(([key]) => key)\n .join(',');\n }\n\n return fieldParams ? `?fields=${fieldParams}` : '';\n}\n","import { buildFieldsQueryString } from 'src/utils/buildFieldsQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport type {\n UpdateWabaSubscription,\n WABAClass,\n WabaAccount,\n WabaAccountFieldsParam,\n WabaSubscriptions,\n} from '../types/waba';\nimport BaseAPI from './base';\n\nexport default class WabaAPI extends BaseAPI implements WABAClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount> {\n const queryString = buildFieldsQueryString(fields)?.replace(/,/g, '%2C');\n\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getAllWabaSubscriptions(): Promise<WabaSubscriptions> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateWabaSubscription({\n override_callback_uri,\n verify_token,\n }: UpdateWabaSubscription): Promise<ResponseSuccess> {\n const body = {\n override_callback_uri,\n verify_token,\n };\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async unsubscribeFromWaba(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfig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__export","BaseAPI","BusinessProfileAPI","EncryptionAPI","FlowAPI","MediaAPI","MessagesApi","PhoneNumberApi","QrCodeAPI","RegistrationAPI","TemplateApi","TwoStepVerificationAPI","WabaAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","objectToQueryString","params","searchParams","key","value","queryString","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","payload","flowId","fields","dateFormat","params","queryString","invalidate","formData","fileContent","flowJsonData","result","isValid","error","destinationWabaId","MediaAPI","BaseAPI","config","client","mediaId","file","messagingProduct","formData","mediaUrl","MessagesApi","BaseAPI","config","client","type","payload","to","replyMessageId","body","params","previewUrl","textObject","status","messageId","typingIndicator","bodyToSend","emoji","PhoneNumberApi","BaseAPI","config","client","fields","queryParams","objectToQueryString","requestVerificationCodeRequest","verifyCodeRequest","QrCodeAPI","BaseAPI","config","client","request","qrCodeId","RegistrationAPI","BaseAPI","config","client","pin","dataLocalizationRegion","body","TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","TwoStepVerificationAPI","BaseAPI","config","client","pin","body","buildFieldsQueryString","fields","fieldParams","_","value","key","WabaAPI","BaseAPI","config","client","fields","queryString","buildFieldsQueryString","override_callback_uri","verify_token","body"]}
1
+ {"version":3,"sources":["../../src/api/index.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/utils/buildFieldsQueryString.ts","../../src/utils/objectToQueryString.ts","../../src/api/businessProfile.ts","../../src/api/encryption.ts","../../src/api/flow.ts","../../src/api/media.ts","../../src/api/messages.ts","../../src/api/phoneNumber.ts","../../src/api/qrCode.ts","../../src/api/registration.ts","../../src/api/template.ts","../../src/api/twoStepVerification.ts","../../src/api/waba.ts"],"sourcesContent":["import BaseAPI from './base';\nimport BusinessProfileAPI from './businessProfile';\nimport EncryptionAPI from './encryption';\nimport FlowAPI from './flow';\nimport MediaAPI from './media';\nimport MessagesAPI from './messages';\nimport PhoneNumberAPI from './phoneNumber';\nimport QrCodeAPI from './qrCode';\nimport RegistrationAPI from './registration';\nimport TemplateAPI from './template';\nimport TwoStepVerificationAPI from './twoStepVerification';\nimport WabaAPI from './waba';\n\nexport {\n BaseAPI,\n BusinessProfileAPI,\n EncryptionAPI,\n FlowAPI,\n MediaAPI,\n MessagesAPI,\n PhoneNumberAPI,\n QrCodeAPI,\n RegistrationAPI,\n TemplateAPI,\n TwoStepVerificationAPI,\n WabaAPI,\n};\n","// @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","import { HttpMethodsEnum } from 'src/types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\n}\n","export function buildFieldsQueryString(fields?: string[]): string {\n if (!fields) return '';\n\n let fieldParams = '';\n\n if (Array.isArray(fields)) {\n fieldParams = fields.join(',');\n } else {\n fieldParams = Object.entries(fields)\n .filter(([_, value]) => value)\n .map(([key]) => key)\n .join(',');\n }\n\n return fieldParams ? `?fields=${fieldParams}` : '';\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","import { buildFieldsQueryString } from 'src/utils/buildFieldsQueryString';\nimport {\n BusinessProfileClass,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n *\n * // Using the BusinessProfileFieldsParam type\n * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);\n */\n async getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${buildFieldsQueryString(fields)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateFlowResponse,\n Flow,\n FlowAssetsResponse,\n FlowCategoryEnum,\n FlowClass,\n FlowMigrationResponse,\n FlowPreviewResponse,\n FlowsListResponse,\n UpdateFlowResponse,\n ValidateFlowJsonResponse,\n} from '../types/flow';\nimport { RequesterClass, ResponseSuccess } from '../types/request';\nimport Logger from '../utils/logger';\nimport BaseAPI from './base';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<FlowsListResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `/${wabaId}/flows`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\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 and validation errors if any\n */\n async 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; // Flow JSON as a string\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse> {\n // The API expects application/json for this endpoint based on documentation examples\n // Let's ensure we send JSON, not FormData, unless specifically required by an endpoint variation.\n const payload = {\n name: data.name,\n categories: data.categories,\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.clone_flow_id && { clone_flow_id: data.clone_flow_id }),\n ...(data.flow_json && { flow_json: data.flow_json }),\n ...(data.publish !== undefined && { publish: data.publish }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Get Flow details\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details or preview response\n */\n async getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get Flow Preview URL\n *\n * @param flowId - The flow ID\n * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.\n * @returns Promise with the flow preview details\n */\n async getFlowPreview(flowId: string, invalidate: boolean = false): Promise<FlowPreviewResponse> {\n const fields = `preview.invalidate(${invalidate})`;\n // Type assertion needed as getFlow can return Flow or FlowPreviewResponse\n return this.getFlow(flowId, fields) as Promise<FlowPreviewResponse>;\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)\n * @returns Promise with the success status\n */\n async 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 // The API expects application/json for this endpoint based on documentation examples\n const payload = {\n ...(data.name && { name: data.name }),\n ...(data.categories && { categories: data.categories }),\n ...(data.endpoint_uri && { endpoint_uri: data.endpoint_uri }),\n ...(data.application_id && { application_id: data.application_id }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload), // Send as JSON\n );\n }\n\n /**\n * Delete Flow (only works if the Flow is in DRAFT status)\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * List Assets (e.g., get Flow JSON download URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<FlowAssetsResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.\n *\n * @param flowId - The flow ID\n * @param data - Object containing the file data and optional name.\n * @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @param data.name - Optional name for the asset, defaults to 'flow.json'.\n * @returns Promise with the success status and validation errors, if any.\n */\n async updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object; // JSON object, Buffer, or Blob\n name?: string; // Default to \"flow.json\"\n },\n ): Promise<UpdateFlowResponse> {\n const formData = new FormData();\n let fileContent: Blob;\n\n // Handle different input types for the file\n if (data.file instanceof Buffer) {\n // Buffer\n // Create a Blob from the Buffer and cast it to the global Blob type\n fileContent = new globalThis.Blob([data.file]);\n formData.append('file', fileContent as unknown as Blob);\n } else if (typeof data.file === 'object' && !(data.file instanceof Blob)) {\n // JSON object - stringify and create Blob\n try {\n // Create a Blob from the JSON string and cast it to the global Blob type\n fileContent = new globalThis.Blob([JSON.stringify(data.file, null, 2)], { type: 'application/json' });\n formData.append('file', fileContent as unknown as Blob);\n } catch (e) {\n throw new Error('Failed to stringify JSON object for Flow JSON update.');\n }\n } else if (data.file instanceof Blob) {\n // Blob (already in correct format)\n fileContent = data.file;\n formData.append('file', fileContent as unknown as Blob);\n } else {\n throw new Error('Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.');\n }\n\n formData.append('asset_type', 'FLOW_JSON'); // Required by API\n formData.append('name', data.name || 'flow.json'); // Required by API\n\n return this.sendFormData(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\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 file path (string), Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n async validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse> {\n try {\n const result = await this.updateFlowJson(flowId, {\n file: flowJsonData,\n });\n\n const isValid = !result.validation_errors || result.validation_errors.length === 0;\n\n const enhancedResponse = {\n ...result,\n valid: isValid,\n };\n\n return enhancedResponse;\n } catch (error) {\n LOGGER.error('Error during Flow JSON validation attempt:', error);\n throw error;\n }\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<ResponseSuccess> {\n // This endpoint expects an empty JSON body or no body\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}), // Send empty JSON object\n );\n }\n\n /**\n * Migrate Flows between WABAs\n *\n * @param destinationWabaId - 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 (successes and failures)\n */\n async migrateFlows(\n destinationWabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse> {\n // API documentation suggests this endpoint might expect application/json\n // Let's double-check or assume JSON based on typical Graph API patterns unless FormData is confirmed.\n // Assuming JSON for now:\n const payload = {\n source_waba_id: data.source_waba_id,\n ...(data.source_flow_names && { source_flow_names: data.source_flow_names }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${destinationWabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(payload),\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { MediaClass, MediaResponse, UploadMediaResponse } from '../types/media';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class MediaAPI extends BaseAPI implements MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getMediaById(mediaId: string): Promise<MediaResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async uploadMedia(file: File, messagingProduct: string = 'whatsapp'): Promise<UploadMediaResponse> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n async deleteMedia(mediaId: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async downloadMedia(mediaUrl: string): Promise<Blob> {\n return this.sendJson(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\n// Request object interface type definitions\nexport interface MessageRequestParams<T> {\n body: T;\n to: string;\n replyMessageId?: string;\n}\n\nexport interface TextMessageParams extends MessageRequestParams<m.TextObject | string> {\n previewUrl?: boolean;\n}\n\nexport interface ReactionParams {\n messageId: string;\n emoji: string;\n to: string;\n}\n\nexport interface StatusParams {\n status: string;\n messageId: string;\n typingIndicator?: {\n type: string;\n };\n}\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param to The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<m.MessagesResponse> {\n return this.sendJson(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n async audio(params: m.MessageRequestParams<m.AudioMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n async contacts(params: m.MessageRequestParams<[m.ContactObject]>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n async document(params: m.MessageRequestParams<m.DocumentMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n async image(params: m.MessageRequestParams<m.ImageMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n async interactive(params: m.MessageRequestParams<m.InteractiveObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n async location(params: m.MessageRequestParams<m.LocationObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n async sticker(params: m.MessageRequestParams<m.StickerMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n async template(\n params: m.MessageRequestParams<m.MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n async text(params: m.TextMessageParams): Promise<m.MessagesResponse> {\n const { body, previewUrl, to, replyMessageId } = params;\n\n let textObject: m.TextObject;\n if (typeof body === 'string') {\n textObject = {\n body: body,\n preview_url: previewUrl,\n };\n } else {\n textObject = body;\n }\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, textObject, to, replyMessageId)));\n }\n\n /**\n * Sends a video via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n async video(params: m.MessageRequestParams<m.VideoMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param params The status update parameter object\n * @returns Promise with the response\n */\n async status(params: m.StatusParams): Promise<m.MessagesResponse> {\n const { status, messageId, typingIndicator } = params;\n\n const bodyToSend = {\n messaging_product: 'whatsapp',\n status: status,\n message_id: messageId,\n ...(typingIndicator && { typing_indicator: typingIndicator }),\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param params The parameter object to mark message as read\n * @returns Promise with the response\n */\n async markAsRead(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param params The typing indicator parameter object\n * @returns Promise with the response\n */\n async showTypingIndicator(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n typingIndicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param params The list message parameter object\n * @returns Promise with the response\n */\n async interactiveList(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param params The CTA URL message parameter object\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location request message\n * @param params The location request message parameter object\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param params The address message parameter object\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param params The reply buttons message parameter object\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive Flow message\n * @param params The Flow message parameter object\n * @returns Promise with the response\n */\n async interactiveFlow(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n\n // Apply default values for FlowParameters\n if (body.action.parameters.flow_message_version === undefined) {\n body.action.parameters.flow_message_version = '3';\n }\n if (body.action.parameters.mode === undefined) {\n body.action.parameters.mode = 'published';\n }\n if (body.action.parameters.flow_action === undefined) {\n body.action.parameters.flow_action = 'navigate';\n }\n\n // Only include flow_action_payload when flow_action is navigate\n if (body.action.parameters.flow_action === 'navigate') {\n if (body.action.parameters.flow_action_payload?.screen === undefined) {\n body.action.parameters.flow_action_payload = {\n ...body.action.parameters.flow_action_payload,\n screen: 'INIT',\n };\n }\n } else if (body.action.parameters.flow_action === 'data_exchange') {\n // Remove flow_action_payload when flow_action is data_exchange\n delete body.action.parameters.flow_action_payload;\n }\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param params The reaction message parameter object\n * @returns Promise with the response\n */\n async reaction(params: m.ReactionParams): Promise<m.MessagesResponse> {\n const { messageId, emoji, to } = params;\n\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: to,\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","import {\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n RequestVerificationCodeRequest,\n VerifyCodeRequest,\n} from 'src/types/phoneNumber';\nimport { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getPhoneNumbers(): Promise<PhoneNumbersResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async requestVerificationCode(\n requestVerificationCodeRequest: RequestVerificationCodeRequest,\n ): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(requestVerificationCodeRequest),\n );\n }\n\n async verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(verifyCodeRequest),\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n CreateQrCodeRequest,\n QrCodeClass,\n QrCodeResponse,\n QrCodesResponse,\n UpdateQrCodeRequest,\n} from '../types/qrCode';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class QrCodeAPI extends BaseAPI implements QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async getQrCodes(): Promise<QrCodesResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getQrCode(qrCodeId: string): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async deleteQrCode(qrCodeId: string): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { DataLocalizationRegionEnum, HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport { RegistrationClass } from '../types/registration';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class RegistrationAPI extends BaseAPI implements RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess> {\n const body = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async deregister(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponsePagination, ResponseSuccess } from '../types/request';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from '../types/template';\nimport BaseAPI from './base';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<TemplateResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${templateId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<TemplateResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport { TwoStepVerificationClass } from '../types/twoStepVerification';\nimport BaseAPI from './base';\n\nexport default class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess> {\n const body = {\n pin,\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n","import { buildFieldsQueryString } from 'src/utils/buildFieldsQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../types/request';\nimport type {\n UpdateWabaSubscription,\n WABAClass,\n WabaAccount,\n WabaAccountFieldsParam,\n WabaSubscriptions,\n} from '../types/waba';\nimport BaseAPI from './base';\n\nexport default class WabaAPI extends BaseAPI implements WABAClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount> {\n const queryString = buildFieldsQueryString(fields)?.replace(/,/g, '%2C');\n\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getAllWabaSubscriptions(): Promise<WabaSubscriptions> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateWabaSubscription({\n override_callback_uri,\n verify_token,\n }: UpdateWabaSubscription): Promise<ResponseSuccess> {\n const body = {\n override_callback_uri,\n verify_token,\n };\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async unsubscribeFromWaba(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,uBAAAC,EAAA,kBAAAC,EAAA,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BaseAPI","BusinessProfileAPI","EncryptionAPI","FlowAPI","MediaAPI","MessagesApi","PhoneNumberApi","QrCodeAPI","RegistrationAPI","TemplateApi","TwoStepVerificationAPI","WabaAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","buildFieldsQueryString","fields","fieldParams","_","value","key","objectToQueryString","params","searchParams","key","value","queryString","BusinessProfileAPI","BaseAPI","config","client","fields","buildFieldsQueryString","updateRequest","fileLength","fileType","fileName","queryParams","objectToQueryString","uploadId","file","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","payload","flowId","fields","dateFormat","params","queryString","invalidate","formData","fileContent","flowJsonData","result","isValid","error","destinationWabaId","MediaAPI","BaseAPI","config","client","mediaId","file","messagingProduct","formData","mediaUrl","MessagesApi","BaseAPI","config","client","type","payload","to","replyMessageId","body","params","previewUrl","textObject","status","messageId","typingIndicator","bodyToSend","emoji","PhoneNumberApi","BaseAPI","config","client","fields","queryParams","objectToQueryString","requestVerificationCodeRequest","verifyCodeRequest","QrCodeAPI","BaseAPI","config","client","request","qrCodeId","RegistrationAPI","BaseAPI","config","client","pin","dataLocalizationRegion","body","TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","TwoStepVerificationAPI","BaseAPI","config","client","pin","body","WabaAPI","BaseAPI","config","client","fields","queryString","buildFieldsQueryString","override_callback_uri","verify_token","body"]}