meta-cloud-api 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +405 -0
- package/dist/BusinessProfileApi-WXscSgo-.d.ts +353 -0
- package/dist/EncryptionApi-D7pt-OXT.d.ts +22 -0
- package/dist/FlowApi-UAvzhJfV.d.ts +136 -0
- package/dist/MediaApi-BrEKpqi_.d.ts +90 -0
- package/dist/MessageApi-Circorzz.d.ts +587 -0
- package/dist/PhoneNumberApi-DKlu9PHl.d.ts +142 -0
- package/dist/QrCodeApi-7vDwIBHR.d.ts +98 -0
- package/dist/RegistrationApi-qO_qoti9.d.ts +47 -0
- package/dist/TemplateApi-xGgIZt89.d.ts +161 -0
- package/dist/TwoStepVerificationApi-DfNPIz-C.d.ts +33 -0
- package/dist/WabaApi-DqQi_68m.d.ts +175 -0
- package/dist/WebhookProcessor-ByAe7Kf_.d.ts +707 -0
- package/dist/WhatsApp-BIBtT-y9.d.ts +82 -0
- package/dist/api/encryption/index.d.ts +10 -0
- package/dist/api/encryption/index.js +2 -0
- package/dist/api/encryption/index.js.map +1 -0
- package/dist/api/flow/index.d.ts +10 -0
- package/dist/api/flow/index.js +2 -0
- package/dist/api/flow/index.js.map +1 -0
- package/dist/api/index.d.ts +16 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/media/index.d.ts +10 -0
- package/dist/api/media/index.js +2 -0
- package/dist/api/media/index.js.map +1 -0
- package/dist/api/messages/index.d.ts +10 -0
- package/dist/api/messages/index.js +2 -0
- package/dist/api/messages/index.js.map +1 -0
- package/dist/api/phone/index.d.ts +10 -0
- package/dist/api/phone/index.js +2 -0
- package/dist/api/phone/index.js.map +1 -0
- package/dist/api/profile/index.d.ts +10 -0
- package/dist/api/profile/index.js +2 -0
- package/dist/api/profile/index.js.map +1 -0
- package/dist/api/qrCode/index.d.ts +10 -0
- package/dist/api/qrCode/index.js +2 -0
- package/dist/api/qrCode/index.js.map +1 -0
- package/dist/api/registration/index.d.ts +10 -0
- package/dist/api/registration/index.js +2 -0
- package/dist/api/registration/index.js.map +1 -0
- package/dist/api/template/index.d.ts +215 -0
- package/dist/api/template/index.js +2 -0
- package/dist/api/template/index.js.map +1 -0
- package/dist/api/twoStepVerification/index.d.ts +10 -0
- package/dist/api/twoStepVerification/index.js +2 -0
- package/dist/api/twoStepVerification/index.js.map +1 -0
- package/dist/api/waba/index.d.ts +10 -0
- package/dist/api/waba/index.js +2 -0
- package/dist/api/waba/index.js.map +1 -0
- package/dist/base-CdGDdVEl.d.ts +18 -0
- package/dist/chunk-7QBIZCJ4.js +2 -0
- package/dist/chunk-7QBIZCJ4.js.map +1 -0
- package/dist/chunk-AMHQGG6Z.js +2 -0
- package/dist/chunk-AMHQGG6Z.js.map +1 -0
- package/dist/chunk-B7DCL6I7.js +10 -0
- package/dist/chunk-B7DCL6I7.js.map +1 -0
- package/dist/chunk-CRZ7EUYR.js +2 -0
- package/dist/chunk-CRZ7EUYR.js.map +1 -0
- package/dist/chunk-FKXSL2JK.js +3 -0
- package/dist/chunk-FKXSL2JK.js.map +1 -0
- package/dist/chunk-FSKBLPGE.js +2 -0
- package/dist/chunk-FSKBLPGE.js.map +1 -0
- package/dist/chunk-HJGN3PO4.js +3 -0
- package/dist/chunk-HJGN3PO4.js.map +1 -0
- package/dist/chunk-IYSR44P6.js +2 -0
- package/dist/chunk-IYSR44P6.js.map +1 -0
- package/dist/chunk-JC6YMVID.js +2 -0
- package/dist/chunk-JC6YMVID.js.map +1 -0
- package/dist/chunk-JPAV644F.js +2 -0
- package/dist/chunk-JPAV644F.js.map +1 -0
- package/dist/chunk-JXCLRKQ7.js +2 -0
- package/dist/chunk-JXCLRKQ7.js.map +1 -0
- package/dist/chunk-KMAH6636.js +2 -0
- package/dist/chunk-KMAH6636.js.map +1 -0
- package/dist/chunk-L4ESAO2S.js +2 -0
- package/dist/chunk-L4ESAO2S.js.map +1 -0
- package/dist/chunk-LV3TULSI.js +2 -0
- package/dist/chunk-LV3TULSI.js.map +1 -0
- package/dist/chunk-MJEG3K4V.js +2 -0
- package/dist/chunk-MJEG3K4V.js.map +1 -0
- package/dist/chunk-NLF2JGYY.js +2 -0
- package/dist/chunk-NLF2JGYY.js.map +1 -0
- package/dist/chunk-OA2SW4AF.js +2 -0
- package/dist/chunk-OA2SW4AF.js.map +1 -0
- package/dist/chunk-PHPQ5HP3.js +2 -0
- package/dist/chunk-PHPQ5HP3.js.map +1 -0
- package/dist/chunk-RIL6QABY.js +2 -0
- package/dist/chunk-RIL6QABY.js.map +1 -0
- package/dist/chunk-RWCVPWRC.js +2 -0
- package/dist/chunk-RWCVPWRC.js.map +1 -0
- package/dist/chunk-SNNRWNGZ.js +2 -0
- package/dist/chunk-SNNRWNGZ.js.map +1 -0
- package/dist/chunk-UCBYECNQ.js +2 -0
- package/dist/chunk-UCBYECNQ.js.map +1 -0
- package/dist/chunk-VHAODWCN.js +2 -0
- package/dist/chunk-VHAODWCN.js.map +1 -0
- package/dist/chunk-WGGN32O2.js +2 -0
- package/dist/chunk-WGGN32O2.js.map +1 -0
- package/dist/common-DDXsNyLF.d.ts +376 -0
- package/dist/core/webhook/frameworks/express.d.ts +48 -0
- package/dist/core/webhook/frameworks/express.js +2 -0
- package/dist/core/webhook/frameworks/express.js.map +1 -0
- package/dist/core/webhook/frameworks/nextjs.d.ts +44 -0
- package/dist/core/webhook/frameworks/nextjs.js +2 -0
- package/dist/core/webhook/frameworks/nextjs.js.map +1 -0
- package/dist/core/webhook/index.d.ts +26 -0
- package/dist/core/webhook/index.js +2 -0
- package/dist/core/webhook/index.js.map +1 -0
- package/dist/core/whatsapp/index.d.ts +40 -0
- package/dist/core/whatsapp/index.js +2 -0
- package/dist/core/whatsapp/index.js.map +1 -0
- package/dist/enums-BZd9T2ul.d.ts +707 -0
- package/dist/httpsClient-v4gmltzS.d.ts +19 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/logger-BdE0Vyim.d.ts +9 -0
- package/dist/request-vYMaEfk5.d.ts +50 -0
- package/dist/types/config.d.ts +78 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/enums.d.ts +1 -0
- package/dist/types/enums.js +2 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +98 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +240 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/profile/BusinessProfileApi.ts","../src/api/profile/index.ts"],"names":["BusinessProfileApi","BaseAPI","config","client","fields","buildFieldsQueryString","updateRequest","fileLength","fileType","fileName","queryParams","objectToQueryString","uploadId","file","profile_default"],"mappings":"0HAoBA,IAAqBA,CAAAA,CAArB,cAAgDC,CAA2C,CACtE,QAAA,CAAW,2BAAA,CAE5B,WAAA,CAAYC,CAAAA,CAAwBC,CAAAA,CAAwB,CACxD,KAAA,CAAMD,CAAAA,CAAQC,CAAM,EACxB,CAsBA,MAAM,kBAAA,CAAmBC,CAAAA,CAA6E,CAClG,OAAO,IAAA,CAAK,QAAA,CAAA,KAAA,CAER,CAAA,EAAG,IAAA,CAAK,MAAA,CAAO,kBAA6B,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,CAAA,EAAGC,GAAAA,CAAuBD,CAAM,CAAC,CAAA,CAAA,CAC9F,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,IACJ,CACJ,CA4BA,MAAM,qBAAA,CAAsBE,CAAAA,CAA0E,CAClG,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,EAAG,IAAA,CAAK,MAAA,CAAO,kBAA6B,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,CAAA,CAAA,CAC7D,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,IAAA,CAAK,SAAA,CAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,mBAAA,CACFC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACiC,CACjC,IAAMC,CAAAA,CAAcC,GAAAA,CAAoB,CACpC,WAAA,CAAaJ,CAAAA,CACb,SAAA,CAAWC,CAAAA,CACX,SAAA,CAAWC,CACf,CAAC,CAAA,CAED,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,YAAA,EAAeC,CAAW,CAAA,CAAA,CAC1B,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,IACJ,CACJ,CAmBA,MAAM,WAAA,CAAYE,CAAAA,CAAkBC,CAAAA,CAAyD,CACzF,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAA+B,CAAA,EAAGD,CAAQ,CAAA,CAAA,CAAI,IAAA,CAAK,MAAA,CAAO,eAAA,CAAgCC,CAAI,CAC9G,CAoCA,MAAM,eAAA,CAAgBD,CAAAA,CAA4C,CAC9D,OAAO,IAAA,CAAK,QAAA,CAAA,KAAA,CAA8B,CAAA,EAAGA,CAAQ,CAAA,CAAA,CAAI,IAAA,CAAK,MAAA,CAAO,eAAA,CAAgC,IAAI,CAC7G,CACJ,MCzLOE,CAAAA,CAAQd","file":"chunk-LV3TULSI.js","sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { buildFieldsQueryString } from '../../utils/buildFieldsQueryString';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\n\nimport type * as bp from './types';\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 bp.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?: bp.BusinessProfileFieldsParam): Promise<bp.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: bp.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(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<bp.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<bp.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<bp.UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import BusinessProfileApi from './BusinessProfileApi';\n\nexport default BusinessProfileApi;\n\nexport { BusinessProfileApi };\n\nexport type {\n BusinessProfileClass,\n BusinessProfileData,\n BusinessProfileField,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n CreateUploadSessionParams,\n GetUploadHandleParams,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadMediaParams,\n UploadSession,\n UploadSessionResponse,\n} from './types';\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=e=>{if(!e||Object.keys(e).length===0)return "";let n=[];for(let[o,t]of Object.entries(e))if(t!==void 0){let r=encodeURIComponent(o),c=encodeURIComponent(String(t));n.push(`${r}=${c}`);}return n.length>0?`?${n.join("&")}`:""};export{i as a};//# sourceMappingURL=chunk-MJEG3K4V.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-MJEG3K4V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/objectToQueryString.ts"],"names":["objectToQueryString","params","queryParts","key","value","encodedKey","encodedValue"],"mappings":"AAAO,IAAMA,CAAAA,CAAuBC,CAAAA,EAAwC,CACxE,GAAI,CAACA,CAAAA,EAAU,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,MAAA,GAAW,CAAA,CAC1C,OAAO,EAAA,CAGX,IAAMC,CAAAA,CAAuB,EAAC,CAE9B,IAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC5C,GAAIG,CAAAA,GAAU,MAAA,CAAW,CACrB,IAAMC,CAAAA,CAAa,kBAAA,CAAmBF,CAAG,CAAA,CACnCG,CAAAA,CAAe,kBAAA,CAAmB,MAAA,CAAOF,CAAK,CAAC,CAAA,CACrDF,CAAAA,CAAW,IAAA,CAAK,CAAA,EAAGG,CAAU,CAAA,CAAA,EAAIC,CAAY,CAAA,CAAE,EACnD,CAGJ,OAAOJ,CAAAA,CAAW,MAAA,CAAS,CAAA,CAAI,CAAA,CAAA,EAAIA,CAAAA,CAAW,IAAA,CAAK,GAAG,CAAC,GAAK,EAChE","file":"chunk-MJEG3K4V.js","sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const queryParts: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n const encodedKey = encodeURIComponent(key);\n const encodedValue = encodeURIComponent(String(value));\n queryParts.push(`${encodedKey}=${encodedValue}`);\n }\n }\n\n return queryParts.length > 0 ? `?${queryParts.join('&')}` : '';\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/flow/types/common.ts"],"names":["FlowTypeEnum"],"mappings":"AAsCO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GAERA,CAAAA,CAAA,IAAA,CAAO,MAAA,CAEPA,CAAAA,CAAA,MAAA,CAAS,eAAA,CAETA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAERA,CAAAA,CAAA,GAAA,CAAM,IAREA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA","file":"chunk-NLF2JGYY.js","sourcesContent":["import { ResponseSuccess } from '../../../types';\nimport { IncomingHttpHeaders, IncomingMessage } from 'http';\n\n/**\n * Enum for Flow Status\n */\nexport enum FlowStatusEnum {\n Draft = 'DRAFT',\n Published = 'PUBLISHED',\n Throttled = 'THROTTLED',\n Blocked = 'BLOCKED',\n Deprecated = 'DEPRECATED',\n}\n\n/**\n * Enum for Flow Categories\n */\nexport enum FlowCategoryEnum {\n SignUp = 'SIGN_UP',\n SignIn = 'SIGN_IN',\n AppointmentBooking = 'APPOINTMENT_BOOKING',\n LeadGeneration = 'LEAD_GENERATION',\n ContactUs = 'CONTACT_US',\n CustomerSupport = 'CUSTOMER_SUPPORT',\n Survey = 'SURVEY',\n Other = 'OTHER',\n}\n\nexport enum FlowActionEnum {\n INIT = 'INIT',\n BACK = 'BACK',\n DATA_EXCHANGE = 'data_exchange',\n}\n\n/**\n * Enum for Flow Types in webhook handlers\n * Used to register handlers for specific flow events\n */\nexport enum FlowTypeEnum {\n /** Health check/ping requests */\n Ping = 'ping',\n /** Data exchange requests */\n Change = 'data_exchange',\n /** Error notification requests */\n Error = 'error',\n /** Match all flow action types */\n All = '*',\n}\n\nexport type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];\n\n/**\n * Flow Validation Error Pointer\n */\nexport interface FlowValidationErrorPointer {\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n path: string;\n}\n\n/**\n * Flow Validation Error\n */\nexport interface FlowValidationError {\n error: string;\n error_type: string;\n message: string;\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n pointers: FlowValidationErrorPointer[];\n}\n\n/**\n * Flow Item\n */\nexport interface Flow {\n id: string;\n name: string;\n status: FlowStatusEnum;\n categories: FlowCategoryEnum[];\n validation_errors: FlowValidationError[];\n}\n\n/**\n * Pagination Cursors\n */\nexport interface PaginationCursors {\n before: string;\n after: string;\n}\n\n/**\n * Pagination Object\n */\nexport interface Pagination {\n cursors: PaginationCursors;\n}\n\n/**\n * Flows List Response\n */\nexport interface FlowsListResponse {\n data: Flow[];\n paging: Pagination;\n}\n\n/**\n * Flow Asset\n */\nexport interface FlowAsset {\n name: string;\n asset_type: string;\n download_url: string;\n}\n\n/**\n * Flow Assets Response\n */\nexport interface FlowAssetsResponse {\n data: FlowAsset[];\n paging: Pagination;\n}\n\n/**\n * Flow Preview\n */\nexport interface FlowPreview {\n preview_url: string;\n expires_at: string;\n}\n\n/**\n * Flow Preview Response\n */\nexport interface FlowPreviewResponse {\n preview: FlowPreview;\n id: string;\n}\n\n/**\n * Flow Migration Result\n */\nexport interface FlowMigrationResult {\n source_name: string;\n source_id: string;\n migrated_id: string;\n}\n\n/**\n * Flow Migration Failure\n */\nexport interface FlowMigrationFailure {\n source_name: string;\n error_code: string;\n error_message: string;\n}\n\n/**\n * Create Flow Response\n */\nexport interface CreateFlowResponse {\n id: string;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Update Flow Response\n */\nexport interface UpdateFlowResponse {\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Flow Migration Response\n */\nexport interface FlowMigrationResponse {\n migrated_flows: FlowMigrationResult[];\n failed_flows: FlowMigrationFailure[];\n}\n\n/**\n * Validate Flow JSON Response\n */\nexport interface ValidateFlowJsonResponse {\n valid: boolean;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * WhatsApp Flow Endpoint - Encrypted Request Payload\n * Represents the raw encrypted data received from WhatsApp\n */\nexport interface FlowEncryptedRequestPayload {\n encrypted_aes_key: string;\n encrypted_flow_data: string;\n initial_vector: string;\n}\n\n/**\n * WhatsApp Flow Endpoint - Decrypted Request Response\n * Represents the successfully decrypted data and encryption keys\n */\nexport interface FlowDecryptedRequestResponse {\n decryptedBody: any;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n}\n\n/**\n * WhatsApp Flow Endpoint - HTTP Request with Body\n * Represents an HTTP request with the encrypted payload\n */\nexport interface FlowHttpRequest extends IncomingMessage {\n body: FlowEncryptedRequestPayload;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Request\n * Represents the structure of a health check request\n */\nexport interface FlowHealthCheckRequest {\n action: 'ping';\n version: '3.0';\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Response\n * The expected response structure for health check requests\n */\nexport interface FlowHealthCheckResponse {\n data: {\n status: 'active';\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Request\n * Represents the structure of a data exchange request\n */\nexport interface FlowDataExchangeRequest {\n version: '3.0';\n action: FlowActionEnum;\n screen: string;\n flow_token: string;\n data?: Record<string, any> & { error_message?: string };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Response\n * The expected response structure for data exchange requests\n */\nexport interface FlowDataExchangeResponse {\n screen?: string;\n data?: Record<string, any | { error_message?: string }>;\n}\n\n/**\n * WhatsApp Flow Endpoint - Success Screen Response\n * The expected response structure for success screen requests\n */\nexport interface FlowSuccessScreenResponse {\n screen: 'SUCCESS';\n data: {\n extension_message_response?: {\n params?: {\n flow_token: string;\n [key: string]: string;\n };\n };\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Request\n * Represents the structure of an error notification request\n */\nexport interface FlowErrorNotificationRequest {\n version: '3.0';\n action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Response\n * The expected response structure for error notification requests\n */\nexport interface FlowErrorNotificationResponse {\n acknowledged: boolean;\n}\n\n/**\n * WhatsApp Flow Endpoint - Comprehensive Request Object\n * A combined type that includes all possible fields from different request types\n * with all fields being optional for flexibility\n */\nexport interface FlowEndpointRequest {\n // Common fields\n version?: '3.0';\n action?: 'ping' | FlowActionEnum;\n\n screen?: string;\n flow_token?: string;\n\n data?: Record<string, any> & {\n error_key?: string;\n error_message?: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Response\n * Union type for all possible response types from a Flow endpoint\n */\nexport type FlowEndpointResponse =\n | FlowHealthCheckResponse\n | FlowDataExchangeResponse\n | FlowErrorNotificationResponse\n | FlowSuccessScreenResponse;\n\nexport interface FlowClass {\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n listFlows(wabaId: string): Promise<FlowsListResponse>;\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse>;\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<ResponseSuccess>;\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deleteFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n listAssets(flowId: string): Promise<FlowAssetsResponse>;\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object;\n name?: string;\n },\n ): Promise<UpdateFlowResponse>;\n\n /**\n * Validate Flow JSON by attempting an update without publishing.\n * This is a convenience method; the API doesn't have a dedicated validation endpoint.\n *\n * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).\n * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n publishFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deprecateFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse>;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {d,c}from'./chunk-HJGN3PO4.js';function b(h){let d$1=new d(h);return {webhook:async(e,r,i)=>{try{if(e.method==="GET"){let{"hub.mode":s,"hub.verify_token":n,"hub.challenge":t}=e.query,o=await d$1.processVerification(s||null,n||null,t||null);return Object.entries(o.headers).forEach(([a,l])=>{r.setHeader(a,l);}),r.status(o.status).send(o.body)}if(e.method==="POST"){let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),t=await d$1.processWebhook(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}return r.status(405).json({error:"Method Not Allowed"})}catch(s){i(s);return}},flow:async(e,r,i)=>{try{let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),t=await d$1.processFlow(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}catch(s){i(s);return}},processor:d$1}}export{b as a};//# sourceMappingURL=chunk-OA2SW4AF.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-OA2SW4AF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/webhook/frameworks/express.ts"],"names":["webhookHandler","config","processor","WebhookProcessor","req","res","next","mode","token","challenge","result","key","value","fullUrl","constructFullUrl","webRequest","error"],"mappings":"sCA6BO,SAASA,CAAAA,CAAeC,CAAAA,CAA8B,CACzD,IAAMC,GAAAA,CAAY,IAAIC,CAAAA,CAAiBF,CAAM,CAAA,CAE7C,OAAO,CAEH,OAAA,CAAS,MAAOG,CAAAA,CAAqBC,CAAAA,CAAsBC,CAAAA,GAAuB,CAC9E,GAAI,CACA,GAAIF,CAAAA,CAAI,MAAA,GAAW,KAAA,CAAO,CACtB,GAAM,CAAE,UAAA,CAAYG,CAAAA,CAAM,kBAAA,CAAoBC,CAAAA,CAAO,eAAA,CAAiBC,CAAU,CAAA,CAAIL,CAAAA,CAAI,KAAA,CAElFM,CAAAA,CAAS,MAAMR,GAAAA,CAAU,mBAAA,CAC1BK,CAAAA,EAAmB,IAAA,CACnBC,CAAAA,EAAoB,IAAA,CACpBC,CAAAA,EAAwB,IAC7B,CAAA,CAEA,OAAA,MAAA,CAAO,OAAA,CAAQC,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDP,CAAAA,CAAI,SAAA,CAAUM,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMP,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAEA,GAAIN,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAQ,CAEvB,IAAMS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,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CAAA,CAAI,KAAA,CAC7D,CAAC,CAAA,CAEKM,CAAAA,CAAS,MAAMR,GAAAA,CAAU,WAAA,CAAYa,CAAU,CAAA,CAErD,OAAA,MAAA,CAAO,OAAA,CAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDP,CAAAA,CAAI,SAAA,CAAUM,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMP,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAAA,MAASM,CAAAA,CAAO,CACZV,CAAAA,CAAKU,CAAK,CAAA,CACV,MACJ,CACJ,CAAA,CAGA,SAAA,CAAAd,GACJ,CACJ","file":"chunk-OA2SW4AF.js","sourcesContent":["import { WhatsAppConfig } from '../../../types/config';\nimport { WebhookProcessor } from '../WebhookProcessor';\nimport { constructFullUrl } from '../utils/webhookUtils';\n\n// Express-like interfaces to avoid direct Express dependency\nexport interface ExpressRequest {\n method: string;\n url: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Record<string, any>;\n rawBody?: any;\n}\n\nexport interface ExpressResponse {\n status(code: number): ExpressResponse;\n json(data: any): ExpressResponse;\n send(data?: any): ExpressResponse;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextFunction {\n (error?: any): void;\n}\n\nexport interface ExpressWebhookConfig extends WhatsAppConfig {\n path?: string;\n}\n\nexport function webhookHandler(config: ExpressWebhookConfig) {\n const processor = new WebhookProcessor(config);\n\n return {\n // Main webhook handler\n webhook: async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {\n try {\n if (req.method === 'GET') {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await processor.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n if (req.method === 'POST') {\n // Create Web Standard Request from Express request with proper full URL\n const fullUrl = constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await processor.processWebhook(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n return res.status(405).json({ error: 'Method Not Allowed' });\n } catch (error) {\n next(error);\n return;\n }\n },\n\n // Flow handler\n flow: async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {\n try {\n // Create Web Standard Request from Express request with proper full URL\n const fullUrl = constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await processor.processFlow(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n } catch (error) {\n next(error);\n return;\n }\n },\n\n // Expose processor for handler registration\n processor,\n };\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-RIL6QABY.js';var e=class extends a{constructor(t,s){super(t,s);}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var m=e;export{e as a,m as b};//# sourceMappingURL=chunk-PHPQ5HP3.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-PHPQ5HP3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/registration/RegistrationApi.ts","../src/api/registration/index.ts"],"names":["RegistrationApi","BaseAPI","config","client","pin","dataLocalizationRegion","body","registration_default"],"mappings":"oCAcA,IAAqBA,CAAAA,CAArB,cAA6CC,CAAkD,CAC3F,YAAYC,CAAAA,CAAwBC,CAAAA,CAAwB,CACxD,KAAA,CAAMD,CAAAA,CAAQC,CAAM,EACxB,CAYA,MAAM,QAAA,CAASC,CAAAA,CAAaC,CAAAA,CAA+E,CACvG,IAAMC,CAAAA,CAAyC,CAC3C,iBAAA,CAAmB,WACnB,GAAA,CAAAF,CAAAA,CACA,GAAIC,CAAAA,EAA0B,CAAE,wBAAA,CAA0BA,CAAuB,CACrF,EAEA,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,EAAG,IAAA,CAAK,MAAA,CAAO,kBAA6B,CAAA,SAAA,CAAA,CAC5C,KAAK,MAAA,CAAO,eAAA,CACZ,IAAA,CAAK,SAAA,CAAUC,CAAI,CACvB,CACJ,CAUA,MAAM,UAAA,EAAuC,CACzC,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,EAAG,IAAA,CAAK,MAAA,CAAO,kBAA6B,CAAA,WAAA,CAAA,CAC5C,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,IACJ,CACJ,CACJ,MC1DOC,CAAAA,CAAQP","file":"chunk-PHPQ5HP3.js","sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { DataLocalizationRegionEnum, HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as registration from './types';\n\n/**\n * API for managing WhatsApp Business Account registration.\n *\n * This API allows you to:\n * - Register a WhatsApp Business Account with a PIN\n * - Deregister a WhatsApp Business Account\n */\nexport default class RegistrationApi extends BaseAPI implements registration.RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Register a WhatsApp Business Account using a PIN.\n *\n * @param pin The registration PIN received via SMS or voice call\n * @param dataLocalizationRegion Optional data localization region\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.register('123456', DataLocalizationRegionEnum.Asia);\n */\n async register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess> {\n const body: registration.RegistrationRequest = {\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 /**\n * Deregister a WhatsApp Business Account.\n *\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.deregister();\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 RegistrationApi from './RegistrationApi';\n\nexport default RegistrationApi;\n\nexport { RegistrationApi };\n\nexport type { RegistrationClass, RegistrationRequest } from './types';\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n=class{config;client;constructor(e,t){this.config=e,this.client=t;}sendJson(e,t,s,r){return this.client.getJson(e,t,s,r)}sendFormData(e,t,s,r){return this.client.sendFormData(e,t,s,r)}sendUrlEncodedForm(e,t,s,r){return this.client.sendUrlEncodedForm(e,t,s,r)}};export{n as a};//# sourceMappingURL=chunk-RIL6QABY.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-RIL6QABY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/base.ts"],"names":["BaseAPI","config","client","method","endpoint","timeout","body"],"mappings":"AASO,IAAMA,CAAAA,CAAN,KAAmC,CAC5B,MAAA,CACA,MAAA,CAEV,WAAA,CAAYC,CAAAA,CAAwBC,CAAAA,CAAwB,CACxD,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,MAAA,CAASC,EAClB,CAEU,QAAA,CAAYC,CAAAA,CAAyBC,CAAAA,CAAkBC,CAAAA,CAAiBC,CAAAA,CAAwB,CACtG,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAWH,CAAAA,CAAQC,CAAAA,CAAUC,EAASC,CAAI,CACjE,CAEU,YAAA,CAAgBH,CAAAA,CAAyBC,CAAAA,CAAkBC,CAAAA,CAAiBC,CAAAA,CAAwB,CAC1G,OAAO,IAAA,CAAK,MAAA,CAAO,YAAA,CAAgBH,CAAAA,CAAQC,CAAAA,CAAUC,CAAAA,CAASC,CAAI,CACtE,CAEU,kBAAA,CACNH,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACU,CACV,OAAO,IAAA,CAAK,MAAA,CAAO,kBAAA,CAAsBH,CAAAA,CAAQC,CAAAA,CAAUC,CAAAA,CAASC,CAAI,CAC5E,CACJ","file":"chunk-RIL6QABY.js","sourcesContent":["import type { WabaConfigType } from './config';\n\nexport declare class BaseClass {\n constructor(config: WabaConfigType);\n}\n\nimport { HttpMethodsEnum } from './enums';\nimport type { RequesterClass } from './request';\n\nexport 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 }\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/webhook/utils/generateXHub256Sig.ts"],"names":["generateXHub256Sig","body","appSecret"],"mappings":"yBAEO,IAAMA,CAAAA,CAAqB,CAACC,EAAcC,CAAAA,GAC/B,CAAA,CAAA,UAAA,CAAW,QAAA,CAAUA,CAAS,EAAE,MAAA,CAAOD,CAAAA,CAAM,OAAO,CAAA,CAAE,OAAO,KAAK","file":"chunk-RWCVPWRC.js","sourcesContent":["import * as crypto from 'crypto';\n\nexport const generateXHub256Sig = (body: string, appSecret: string) => {\n return crypto.createHmac('sha256', appSecret).update(body, 'utf-8').digest('hex');\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-RIL6QABY.js';var e=class extends a$1{constructor(t,o){super(t,o);}async setTwoStepVerificationCode(t){let o={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(o))}};var a=e;export{e as a,a as b};//# sourceMappingURL=chunk-SNNRWNGZ.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-SNNRWNGZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/twoStepVerification/TwoStepVerificationApi.ts","../src/api/twoStepVerification/index.ts"],"names":["TwoStepVerificationApi","BaseAPI","config","client","pin","body","twoStepVerification_default"],"mappings":"2CAcA,IAAqBA,EAArB,cAAoDC,GAAgE,CAChH,WAAA,CAAYC,CAAAA,CAAwBC,EAAwB,CACxD,KAAA,CAAMD,EAAQC,CAAM,EACxB,CAWA,MAAM,0BAAA,CAA2BC,EAAuC,CACpE,IAAMC,EAAO,CACT,GAAA,CAAAD,CACJ,CAAA,CAEA,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,GAAG,IAAA,CAAK,MAAA,CAAO,kBAA6B,CAAA,CAAA,CAC5C,IAAA,CAAK,OAAO,eAAA,CACZ,IAAA,CAAK,UAAUC,CAAI,CACvB,CACJ,CACJ,MCtCOC,CAAAA,CAAQN","file":"chunk-SNNRWNGZ.js","sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as twoStepVerification from './types';\n\n/**\n * API for managing WhatsApp Two-Step Verification.\n *\n * This API allows you to:\n * - Set a two-step verification PIN code\n * - Manage two-step verification settings\n */\nexport default class TwoStepVerificationApi extends BaseAPI implements twoStepVerification.TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Set a two-step verification PIN code.\n *\n * @param pin The PIN code to set for two-step verification (6-digit numeric string)\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.twoStepVerification.setTwoStepVerificationCode('123456');\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 TwoStepVerificationApi from './TwoStepVerificationApi';\n\nexport default TwoStepVerificationApi;\n\nexport { TwoStepVerificationApi };\n\nexport type { TwoStepVerificationClass, TwoStepVerificationRequest } from './types';\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {d,c}from'./chunk-HJGN3PO4.js';function y(c$1){let d$1=new d(c$1);return {webhook:async(e,t)=>{try{if(e.method==="GET"){let{"hub.mode":s,"hub.verify_token":n,"hub.challenge":r}=e.query,o=await d$1.processVerification(s||null,n||null,r||null);return Object.entries(o.headers).forEach(([a,h])=>{t.setHeader(a,h);}),t.status(o.status).send(o.body)}if(e.method==="POST"){let s=c(e.headers,e.url),n=new Request(s,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),r=await d$1.processWebhook(n);return Object.entries(r.headers).forEach(([o,a])=>{t.setHeader(o,a);}),t.status(r.status).send(r.body)}return t.status(405).json({error:"Method Not Allowed"})}catch(s){return console.error("Webhook error:",s),t.status(500).json({error:"Internal Server Error"})}},flow:async(e,t)=>{try{let s=c(e.headers,e.url),n=new Request(s,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),r=await d$1.processFlow(n);return Object.entries(r.headers).forEach(([o,a])=>{t.setHeader(o,a);}),t.status(r.status).send(r.body)}catch(s){return console.error("Flow error:",s),t.status(500).json({error:"Internal Server Error"})}},processor:d$1}}export{y as a};//# sourceMappingURL=chunk-UCBYECNQ.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-UCBYECNQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/webhook/frameworks/nextjs.ts"],"names":["webhookHandler","config","processor","WebhookProcessor","req","res","mode","token","challenge","result","key","value","fullUrl","constructFullUrl","webRequest","error"],"mappings":"sCA0BO,SAASA,CAAAA,CACZC,GAAAA,CACF,CACE,IAAMC,GAAAA,CAAY,IAAIC,CAAAA,CAAiBF,GAAM,CAAA,CAE7C,OAAO,CAEH,OAAA,CAAS,MAAOG,CAAAA,CAAeC,CAAAA,GAAmB,CAC9C,GAAI,CACA,GAAID,CAAAA,CAAI,MAAA,GAAW,KAAA,CAAO,CACtB,GAAM,CAAE,UAAA,CAAYE,CAAAA,CAAM,kBAAA,CAAoBC,EAAO,eAAA,CAAiBC,CAAU,CAAA,CAAIJ,CAAAA,CAAI,KAAA,CAElFK,CAAAA,CAAS,MAAMP,GAAAA,CAAU,mBAAA,CAC1BI,CAAAA,EAAmB,IAAA,CACnBC,CAAAA,EAAoB,IAAA,CACpBC,CAAAA,EAAwB,IAC7B,CAAA,CAEA,cAAO,OAAA,CAAQC,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,C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AA,CAGA,IAAA,CAAM,MAAOD,CAAAA,CAAeC,CAAAA,GAAmB,CAC3C,GAAI,CACA,IAAMO,EAAUC,CAAAA,CAAiBT,CAAAA,CAAI,OAAA,CAASA,CAAAA,CAAI,GAAG,CAAA,CAE/CU,CAAAA,CAAa,IAAI,OAAA,CAAQF,CAAAA,CAAS,CACpC,MAAA,CAAQR,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,CAAAA,CAAI,QACb,IAAA,CAAMA,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAS,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CAAA,CAAI,KAAA,CAC7D,CAAC,CAAA,CAEKK,CAAAA,CAAS,MAAMP,GAAAA,CAAU,WAAA,CAAYY,CAAU,CAAA,CAErD,OAAA,MAAA,CAAO,OAAA,CAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDN,CAAAA,CAAI,SAAA,CAAUK,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMN,CAAAA,CAAI,MAAA,CAAOI,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAAA,MAASM,CAAAA,CAAO,CACZ,OAAA,OAAA,CAAQ,MAAM,aAAA,CAAeA,CAAK,CAAA,CAC3BV,CAAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,CAAE,KAAA,CAAO,uBAAwB,CAAC,CAClE,CACJ,CAAA,CAGA,SAAA,CAAAH,GACJ,CACJ","file":"chunk-UCBYECNQ.js","sourcesContent":["import { WhatsAppConfig } from '../../../types/config';\nimport { WebhookProcessor } from '../WebhookProcessor';\nimport { constructFullUrl } from '../utils/webhookUtils';\n\n// Generic interfaces for better type compatibility\nexport interface BaseApiRequest {\n method?: string;\n url?: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Partial<Record<string, string | string[]>>;\n rawBody?: any;\n}\n\nexport interface BaseApiResponse {\n status(code: number): any;\n json(data: any): void | any;\n send(data?: any): void | any;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextJsWebhookConfig extends WhatsAppConfig {\n // Next.js specific config can be added here\n}\n\n// Generic webhook handler that accepts any compatible request/response types\nexport function webhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(\n config: NextJsWebhookConfig,\n) {\n const processor = new WebhookProcessor(config);\n\n return {\n // Main webhook handler\n webhook: async (req: TRequest, res: TResponse) => {\n try {\n if (req.method === 'GET') {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await processor.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n if (req.method === 'POST') {\n // Create Web Standard Request from Next.js request\n const fullUrl = constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await processor.processWebhook(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n return res.status(405).json({ error: 'Method Not Allowed' });\n } catch (error) {\n console.error('Webhook error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n },\n\n // Flow handler\n flow: async (req: TRequest, res: TResponse) => {\n try {\n const fullUrl = constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await processor.processFlow(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Flow error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n },\n\n // Expose processor for handler registration\n processor,\n };\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-MJEG3K4V.js';import {a}from'./chunk-RIL6QABY.js';var p=class extends a{endpoint="message_templates";constructor(t,a){super(t,a);}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,a){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(a))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${a$1(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}${a$1(t)}`,this.config.REQUEST_TIMEOUT,null)}};function o(e){let t={type:"HEADER",format:e.format};return e.text&&(t.text=e.text),e.example&&(t.example=e.example),t}function n(e){let t={type:"BODY",text:e.text};return e.example&&(t.example=e.example),t}function m(e){return {type:"FOOTER",text:e.text}}function i(e){let t=[];if(e.phone_number&&t.push({type:"PHONE_NUMBER",text:e.phone_number.text,phone_number:e.phone_number.phone_number}),e.url){let a={type:"URL",text:e.url.text,url:e.url.url};e.url.example&&(a.example=[e.url.example]),t.push(a);}if(e.quick_reply&&e.quick_reply.forEach(a=>{t.push({type:"QUICK_REPLY",text:a.text});}),e.copy_code&&t.push({type:"COPY_CODE",example:e.copy_code.example}),e.flow){let a={type:"FLOW",text:e.flow.text};e.flow.flow_id&&(a.flow_id=e.flow.flow_id),e.flow.flow_name&&(a.flow_name=e.flow.flow_name),e.flow.flow_json&&(a.flow_json=e.flow.flow_json),e.flow.flow_action&&(a.flow_action=e.flow.flow_action),e.flow.navigate_screen&&(a.navigate_screen=e.flow.navigate_screen),t.push(a);}return e.mpm&&t.push({type:"MPM"}),e.otp&&t.push({type:"OTP"}),e.spm&&t.push({type:"SPM"}),t.length>0?[{type:"BUTTONS",buttons:t}]:[]}function f(e){return e.map(t=>{switch(t.type){case "text":return t.value;case "currency":return t.fallback_value;case "date_time":return t.fallback_value;case "image":case "video":case "document":return t.handle||t.link||"";case "location":return t.name||"";case "product":return t.product_retailer_id;default:return ""}})}function T(e){let t=[];if(e.header&&t.push(o(e.header)),e.body&&t.push(n(e.body)),e.footer&&t.push(m(e.footer)),e.buttons&&t.push(...i(e.buttons)),e.carousel){let a=[];e.carousel.cards.forEach((r,s)=>{if(r.image||r.video||r.product){let u=r.image?"IMAGE":r.video?"VIDEO":"DOCUMENT",d=r.image||r.video||r.product||"";a.push({type:"HEADER",format:u,example:{header_handle:[d]}});}r.body&&a.push({type:"BODY",text:r.body,example:r.bodyParameters?{body_text:[f(r.bodyParameters)]}:void 0}),r.buttons&&a.push(...i(r.buttons));}),t.push(...a);}return e.limitedTimeOffer&&t.push({type:"LIMITED_TIME_OFFER",limited_time_offer:{expiration_time_ms:e.limitedTimeOffer.expiration_time_ms}}),{name:e.name,language:e.language,category:e.category,components:t.length>0?t:void 0}}function y(e){let t=[],a="*{{1}}* is your verification code.";return e.add_security_recommendation&&(a+=" For your security, do not share this code."),e.code_expiration_minutes&&(a+=` This code expires in ${e.code_expiration_minutes} minutes.`),t.push({type:"BODY",text:a,example:{body_text:[["123456"]]}}),t.push({type:"BUTTONS",buttons:[{type:"OTP"}]}),{name:e.name,language:e.language,category:"AUTHENTICATION",components:t}}function h(e){let t=[],a="Your security code is *{{1}}*.";return e.add_security_recommendation&&(a+=" Do not share this code with anyone."),e.code_expiration_minutes&&(a+=` This code expires in ${e.code_expiration_minutes} minutes.`),t.push({type:"BODY",text:a,example:{body_text:[["ABCD1234"]]}}),e.copy_code_button&&t.push({type:"BUTTONS",buttons:[{type:"COPY_CODE",example:"ABCD1234"}]}),{name:e.name,language:e.language,category:"AUTHENTICATION",components:t}}function g(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"CATALOG",action:{thumbnail_product_retailer_id:e.thumbnail_product_retailer_id}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function _(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"COPY_CODE",example:e.coupon_code}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function x(e){let t=[];return t.push({type:"LIMITED_TIME_OFFER",limited_time_offer:{expiration_time_ms:e.expiration_time_ms}}),e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),{name:e.name,language:e.language,category:"MARKETING",components:t}}function C(e){let t=[],a=[];return e.cards.forEach((r,s)=>{let u=[];u.push({type:"HEADER",format:r.header.format,example:r.header.example}),u.push(n(r.body)),r.buttons&&u.push(...i(r.buttons)),a.push({card_index:s,components:u});}),t.push({type:"CAROUSEL",cards:a}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function O(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"MPM",action:{thumbnail_product_retailer_id:e.thumbnail_product_retailer_id,sections:e.sections}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function P(e){let t=[];e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer));let a=e.cards.map((r,s)=>({card_index:s,components:[{type:"HEADER",format:"PRODUCT",example:{header_handle:[r.product_retailer_id]}}]}));return t.push({type:"CAROUSEL",cards:a}),{name:e.name,language:e.language,category:"MARKETING",components:t}}function B(e){let t=[];return e.header&&t.push(o({...e.header,format:"TEXT"})),t.push(n(e.body)),e.footer&&t.push(m(e.footer)),t.push({type:"BUTTONS",buttons:[{type:"SPM",action:{product_retailer_id:e.product_retailer_id}}]}),{name:e.name,language:e.language,category:"MARKETING",components:t}}export{p as a,T as b,y as c,h as d,g as e,_ as f,x as g,C as h,O as i,P as j,B as k};//# sourceMappingURL=chunk-VHAODWCN.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-VHAODWCN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/template/TemplateApi.ts","../src/api/template/factories/index.ts"],"names":["TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","createHeader","options","header","createBody","body","createFooter","createButtons","buttons","urlButton","qr","flowButton","formatParameterExamples","parameters","param","createTemplate","components","carouselComponents","card","index","format","handle","createOTPTemplate","bodyText","createAuthenticationTemplate","createCatalogTemplate","createCouponTemplate","createLimitedTimeOfferTemplate","createMediaCardCarouselTemplate","carouselCards","cardComponents","createMPMTemplate","createProductCardCarouselTemplate","createSPMTemplate"],"mappings":"+EAaA,IAAqBA,EAArB,cAAyCC,CAAiC,CACrD,QAAA,CAAW,oBAE5B,WAAA,CAAYC,CAAAA,CAAwBC,CAAAA,CAAwB,CACxD,MAAMD,CAAAA,CAAQC,CAAM,EACxB,CAEA,MAAM,WAAA,CAAYC,CAAAA,CAA+C,CAC7D,OAAO,KAAK,QAAA,CAAA,KAAA,CAA8B,CAAA,EAAGA,CAAU,CAAA,CAAA,CAAI,KAAK,MAAA,CAAO,eAAA,CAAgC,IAAI,CAC/G,CAEA,MAAM,cAAA,CAAeA,CAAAA,CAAoBC,CAAAA,CAAkE,CACvG,OAAO,IAAA,CAAK,QAAA,CAAA,MAAA,CAER,CAAA,EAAGD,CAAU,CAAA,CAAA,CACb,IAAA,CAAK,MAAA,CAAO,eAAA,CACZ,KAAK,SAAA,CAAUC,CAAQ,CAC3B,CACJ,CAEA,MAAM,YAAA,CAAaC,CAAAA,CAA2E,CAC1F,OAAO,IAAA,CAAK,QAA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,CAAAA,IAAW,CAC7E,WAAYA,CAAAA,CACZ,UAAA,CAAY,CACR,CACI,KAAM,QAAA,CACN,MAAA,CAAQ,SAAA,CACR,OAAA,CAAS,CACL,aAAA,CAAe,CAACD,CAAAA,CAAK,mBAAmB,CAC5C,CACJ,CACJ,CACJ,CAAA,CAAE,EAEF,OAAAF,CAAAA,CAAW,IAAA,CAAK,CACZ,KAAM,UAAA,CACN,KAAA,CAAOa,CACX,CAAC,EAEM,CACH,IAAA,CAAM3B,CAAAA,CAAQ,IAAA,CACd,SAAUA,CAAAA,CAAQ,QAAA,CAClB,QAAA,CAAA,WAAA,CACA,UAAA,CAAAc,CACJ,CACJ,CAGO,SAASiB,CAAAA,CAAkB/B,EAAkD,CAChF,IAAMc,CAAAA,CAA+B,GAErC,OAAId,CAAAA,CAAQ,MAAA,EACRc,CAAAA,CAAW,KAAKf,CAAAA,CAAa,CAAE,GAAGC,CAAAA,CAAQ,OAAQ,MAAA,CAAQ,MAAO,CAAC,CAAC,EAGvEc,CAAAA,CAAW,IAAA,CAAKZ,CAAAA,CAAWF,CAAAA,CAAQ,IAAI,CAAC,CAAA,CAEpCA,CAAAA,CAAQ,MAAA,EACRc,EAAW,IAAA,CAAKV,CAAAA,CAAaJ,CAAAA,CAAQ,MAAM,CAAC,CAAA,CAIhDc,CAAAA,CAAW,IAAA,CAAK,CACZ,KAAM,SAAA,CACN,OAAA,CAAS,CACL,CACI,KAAM,KAAA,CACN,MAAA,CAAQ,CACJ,mBAAA,CAAqBd,EAAQ,mBACjC,CACJ,CACJ,CACJ,CAAC,CAAA,CAEM,CACH,IAAA,CAAMA,CAAAA,CAAQ,KACd,QAAA,CAAUA,CAAAA,CAAQ,SAClB,QAAA,CAAA,WAAA,CACA,UAAA,CAAAc,CACJ,CACJ","file":"chunk-VHAODWCN.js","sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponsePagination, ResponseSuccess } from '../../types/request';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from './types';\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 { CategoryEnum } from '../../../types/enums';\nimport type {\n ComponentTypes,\n MediaCarouselCard,\n ProductCarouselCard,\n TemplateBody,\n TemplateButton,\n TemplateButtons,\n TemplateFooter,\n TemplateHeader,\n TemplateRequestBody,\n} from '../types';\nimport type {\n AuthenticationTemplateOptions,\n BodyOptions,\n ButtonOptions,\n CatalogTemplateOptions,\n CouponTemplateOptions,\n FooterOptions,\n HeaderOptions,\n LimitedTimeOfferTemplateOptions,\n MediaCardCarouselTemplateOptions,\n MPMTemplateOptions,\n OTPTemplateOptions,\n ProductCardCarouselTemplateOptions,\n SPMTemplateOptions,\n TemplateOptions,\n TemplateParameter,\n} from '../types';\n\n// Helper function to create header component\nfunction createHeader(options: HeaderOptions): TemplateHeader {\n const header: TemplateHeader = {\n type: 'HEADER',\n format: options.format,\n };\n\n if (options.text) {\n header.text = options.text;\n }\n\n if (options.example) {\n header.example = options.example;\n }\n\n return header;\n}\n\n// Helper function to create body component\nfunction createBody(options: BodyOptions): TemplateBody {\n const body: TemplateBody = {\n type: 'BODY',\n text: options.text,\n };\n\n if (options.example) {\n body.example = options.example;\n }\n\n return body;\n}\n\n// Helper function to create footer component\nfunction createFooter(options: FooterOptions): TemplateFooter {\n return {\n type: 'FOOTER',\n text: options.text,\n };\n}\n\n// Helper function to create buttons\nfunction createButtons(options: ButtonOptions): ComponentTypes[] {\n const buttons: TemplateButton[] = [];\n\n if (options.phone_number) {\n buttons.push({\n type: 'PHONE_NUMBER',\n text: options.phone_number.text,\n phone_number: options.phone_number.phone_number,\n });\n }\n\n if (options.url) {\n const urlButton: any = {\n type: 'URL',\n text: options.url.text,\n url: options.url.url,\n };\n if (options.url.example) {\n urlButton.example = [options.url.example];\n }\n buttons.push(urlButton);\n }\n\n if (options.quick_reply) {\n options.quick_reply.forEach((qr) => {\n buttons.push({\n type: 'QUICK_REPLY',\n text: qr.text,\n });\n });\n }\n\n if (options.copy_code) {\n buttons.push({\n type: 'COPY_CODE',\n example: options.copy_code.example,\n });\n }\n\n if (options.flow) {\n const flowButton: any = {\n type: 'FLOW',\n text: options.flow.text,\n };\n if (options.flow.flow_id) flowButton.flow_id = options.flow.flow_id;\n if (options.flow.flow_name) flowButton.flow_name = options.flow.flow_name;\n if (options.flow.flow_json) flowButton.flow_json = options.flow.flow_json;\n if (options.flow.flow_action) flowButton.flow_action = options.flow.flow_action;\n if (options.flow.navigate_screen) flowButton.navigate_screen = options.flow.navigate_screen;\n buttons.push(flowButton);\n }\n\n if (options.mpm) {\n buttons.push({ type: 'MPM' });\n }\n\n if (options.otp) {\n buttons.push({ type: 'OTP' });\n }\n\n if (options.spm) {\n buttons.push({ type: 'SPM' });\n }\n\n return buttons.length > 0\n ? [\n {\n type: 'BUTTONS',\n buttons: buttons,\n },\n ]\n : [];\n}\n\n// Helper function to format parameter examples\nfunction formatParameterExamples(parameters: TemplateParameter[]): string[] {\n return parameters.map((param) => {\n switch (param.type) {\n case 'text':\n return param.value;\n case 'currency':\n return param.fallback_value;\n case 'date_time':\n return param.fallback_value;\n case 'image':\n case 'video':\n case 'document':\n return param.handle || param.link || '';\n case 'location':\n return param.name || '';\n case 'product':\n return param.product_retailer_id;\n default:\n return '';\n }\n });\n}\n\n// Generic template factory\nexport function createTemplate(options: TemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader(options.header));\n }\n\n if (options.body) {\n components.push(createBody(options.body));\n }\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n if (options.buttons) {\n components.push(...createButtons(options.buttons));\n }\n\n if (options.carousel) {\n // Handle carousel components\n const carouselComponents: ComponentTypes[] = [];\n options.carousel.cards.forEach((card, index) => {\n if (card.image || card.video || card.product) {\n const format = card.image ? 'IMAGE' : card.video ? 'VIDEO' : 'DOCUMENT';\n const handle = card.image || card.video || card.product || '';\n carouselComponents.push({\n type: 'HEADER',\n format: format,\n example: {\n header_handle: [handle],\n },\n });\n }\n if (card.body) {\n carouselComponents.push({\n type: 'BODY',\n text: card.body,\n example: card.bodyParameters\n ? {\n body_text: [formatParameterExamples(card.bodyParameters)],\n }\n : undefined,\n });\n }\n if (card.buttons) {\n carouselComponents.push(...createButtons(card.buttons));\n }\n });\n components.push(...carouselComponents);\n }\n\n if (options.limitedTimeOffer) {\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.limitedTimeOffer.expiration_time_ms,\n },\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: options.category,\n components: components.length > 0 ? components : undefined,\n };\n}\n\n// OTP Template Factory\nexport function createOTPTemplate(options: OTPTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security recommendation if requested\n let bodyText = '*{{1}}* is your verification code.';\n if (options.add_security_recommendation) {\n bodyText += ' For your security, do not share this code.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['123456']], // Example OTP code\n },\n });\n\n // Add OTP button\n components.push({\n type: 'BUTTONS',\n buttons: [{ type: 'OTP' }],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Authentication Template Factory\nexport function createAuthenticationTemplate(options: AuthenticationTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security message\n let bodyText = 'Your security code is *{{1}}*.';\n if (options.add_security_recommendation) {\n bodyText += ' Do not share this code with anyone.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['ABCD1234']], // Example auth code\n },\n });\n\n // Add copy code button if requested\n if (options.copy_code_button) {\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: 'ABCD1234',\n },\n ],\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Catalog Template Factory\nexport function createCatalogTemplate(options: CatalogTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add catalog button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'CATALOG',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Coupon Template Factory\nexport function createCouponTemplate(options: CouponTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add copy code button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: options.coupon_code,\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Limited Time Offer Template Factory\nexport function createLimitedTimeOfferTemplate(options: LimitedTimeOfferTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add limited time offer component first\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.expiration_time_ms,\n },\n });\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Media Card Carousel Template Factory\nexport function createMediaCardCarouselTemplate(options: MediaCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add carousel component\n const carouselCards: MediaCarouselCard[] = [];\n options.cards.forEach((card, index) => {\n const cardComponents: (TemplateHeader | TemplateBody | TemplateButtons)[] = [];\n\n // Add header (media)\n cardComponents.push({\n type: 'HEADER' as const,\n format: card.header.format,\n example: card.header.example,\n });\n\n // Add body\n cardComponents.push(createBody(card.body));\n\n // Add buttons if any\n if (card.buttons) {\n cardComponents.push(...(createButtons(card.buttons) as TemplateButtons[]));\n }\n\n carouselCards.push({\n card_index: index,\n components: cardComponents,\n });\n });\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// MPM (Multi-Product Message) Template Factory\nexport function createMPMTemplate(options: MPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add MPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'MPM',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n sections: options.sections,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Product Card Carousel Template Factory\nexport function createProductCardCarouselTemplate(options: ProductCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add carousel with product cards\n const carouselCards: ProductCarouselCard[] = options.cards.map((card, index) => ({\n card_index: index,\n components: [\n {\n type: 'HEADER' as const,\n format: 'PRODUCT' as const,\n example: {\n header_handle: [card.product_retailer_id],\n },\n },\n ],\n }));\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// SPM (Single-Product Message) Template Factory\nexport function createSPMTemplate(options: SPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add SPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'SPM',\n action: {\n product_retailer_id: options.product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function c(n){return typeof n=="object"&&n!==null}function o(n){return typeof n=="string"}var f=["data_exchange","INIT","BACK"],E=["data_exchange","INIT"];function w(n){if(!("flow_token"in n&&o(n.flow_token)&&"action"in n))return false;let{action:e,version:i,screen:t,data:s}=n,r=i==="3.0",a=f.includes(e),l=typeof t>"u"||o(t)&&t!=="SUCCESS",u=e==="data_exchange"||c(s);return r&&a&&l&&u}function A(n){if(!("flow_token"in n&&o(n.flow_token)&&"action"in n))return false;let{action:e,screen:i,data:t}=n,s=E.includes(e),r=o(i),a=c(t)&&"error_key"in t&&o(t.error)&&"error_message"in t&&o(t.error_message);return s&&r&&a}function d(n){return "action"in n&&n.action==="ping"}export{w as a,A as b,d as c};//# sourceMappingURL=chunk-WGGN32O2.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-WGGN32O2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/flowTypeGuards.ts"],"names":["isObject","value","isString","DATA_EXCHANGE_ACTIONS","ERROR_ACTIONS","isFlowDataExchangeRequest","request","action","version","screen","data","hasValidVersion","hasValidAction","hasValidScreen","hasValidData","isFlowErrorRequest","isFlowPingRequest"],"mappings":"AAaA,SAASA,CAAAA,CAASC,CAAAA,CAAkD,CAChE,OAAO,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,GAAU,IAClD,CAOA,SAASC,CAAAA,CAASD,CAAAA,CAAiC,CAC/C,OAAO,OAAOA,CAAAA,EAAU,QAC5B,CAGA,IAAME,CAAAA,CAAwB,CAAA,eAAA,C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AA,CAAK,aAAa,CAAA,CAG/B,OAAOE,CAAAA,EAAkBC,CAAAA,EAAkBC,CAC/C,CASO,SAASE,CAAAA,CAAkBV,CAAAA,CAAiE,CAE/F,OAAO,QAAA,GAAYA,CAAAA,EAAWA,CAAAA,CAAQ,SAAW,MACrD","file":"chunk-WGGN32O2.js","sourcesContent":["import {\n FlowActionEnum,\n FlowDataExchangeRequest,\n FlowEndpointRequest,\n FlowErrorNotificationRequest,\n FlowHealthCheckRequest,\n} from '@api/flow/types';\n\n/**\n * Helper function to check if a value is an object\n * @param value The value to check\n * @returns True if the value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Helper function to check if a value is a string\n * @param value The value to check\n * @returns True if the value is a string\n */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n// Array of allowed action types for data exchange requests\nconst DATA_EXCHANGE_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK] as const;\n\n// Array of allowed action types for error notification requests\nconst ERROR_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT] as const;\n\n/**\n * Type guard to check if a request is a Data Exchange request\n * Validates the request structure according to the Flow API specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Data Exchange request, false otherwise\n */\nexport function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {\n action: (typeof DATA_EXCHANGE_ACTIONS)[number];\n screen?: string;\n flow_token: string;\n data?: Record<string, any>;\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, version, screen, data } = request;\n\n // Validate API version\n const hasValidVersion = version === '3.0';\n\n // Check if the action is one of the allowed actions for data exchange\n const hasValidAction = DATA_EXCHANGE_ACTIONS.includes(action as any);\n\n // Screen is optional, but when present must be a string and not 'SUCCESS'\n const hasValidScreen = typeof screen === 'undefined' || (isString(screen) && screen !== 'SUCCESS');\n\n // Data is required except for DATA_EXCHANGE action\n const hasValidData = action === FlowActionEnum.DATA_EXCHANGE || isObject(data);\n\n // All conditions must be met for a valid data exchange request\n return hasValidVersion && hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is an Error Notification request\n * Validates the request structure according to the Flow API error specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Error Notification request, false otherwise\n */\nexport function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {\n action: (typeof ERROR_ACTIONS)[number];\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, screen, data } = request;\n\n // Check if the action is one of the allowed actions for error notifications\n const hasValidAction = ERROR_ACTIONS.includes(action as any);\n\n // Screen is required for error notifications\n const hasValidScreen = isString(screen);\n\n // Validate error data structure\n const hasValidData =\n isObject(data) &&\n 'error_key' in data &&\n isString(data.error) &&\n 'error_message' in data &&\n isString(data.error_message);\n\n // All conditions must be met for a valid error notification request\n return hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is a Ping (health check) request\n * Simple validation for health check endpoints in the Flow API\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a Ping request, false otherwise\n */\nexport function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest {\n // A ping request only requires the 'action' field with value 'ping'\n return 'action' in request && request.action === 'ping';\n}\n"]}
|