diff --git a/.eslintignore b/.eslintignore index 7d7d260..a0b0973 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ errors.log .eslintrc.js packages/** apps/** +template/** \ No newline at end of file diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint.yml similarity index 62% rename from .github/workflows/lint-and-build.yml rename to .github/workflows/lint.yml index d0b6794..5288668 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,16 @@ -name: Check Build +name: Build and Lint on: push: branches-ignore: - "master" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - lint-and-build: + build-and-lint: timeout-minutes: 10 runs-on: ubuntu-latest steps: @@ -26,6 +30,12 @@ jobs: - name: Install Dependencies run: pnpm install --frozen-lockfile + # need to build before lint check because packages is using interlinked workspace dependencies + - name: Build the packages + id: build + if: ${{ success() && !failure() }} + run: pnpm build + - name: Lint id: lint run: pnpm run lint @@ -51,31 +61,3 @@ jobs: } else { throw new Error('Pull request data not found') } - - - name: Build the packages - id: build - if: ${{ success() && !failure() }} - run: pnpm build - - - name: Build Failed - if: ${{ failure() && !steps.lint.outcome == 'failure' }} - uses: actions/github-script@v6 - with: - script: | - const { data: pullRequestData } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - commit_sha: context.payload.after - }) - - if(pullRequestData[0]){ - await github.rest.issues.createComment({ - issue_number: pullRequestData[0].number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `#### ❌ Build failed: - ` - }) - } else { - throw new Error('Pull request data not found') - } diff --git a/.gitignore b/.gitignore index 5fcd15f..96e5452 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ cache docs.json docs.api.json docs/** +temp/** .DS_Store diff --git a/.npmignore b/.npmignore index 0f620f7..88180e4 100644 --- a/.npmignore +++ b/.npmignore @@ -28,4 +28,5 @@ #-------------------------------------------- # (Add your project-specific overrides here) -!/template/** +!/template/** +node_modules diff --git a/apps/.DS_Store b/apps/.DS_Store new file mode 100644 index 0000000..6a8cdeb Binary files /dev/null and b/apps/.DS_Store differ diff --git a/packages/create-wapi-app/.eslintignore b/packages/create-wapi-app/.eslintignore index 1623c04..17f2e55 100644 --- a/packages/create-wapi-app/.eslintignore +++ b/packages/create-wapi-app/.eslintignore @@ -1,5 +1,5 @@ template/ -.eslintrc.js +.eslintrc.json dist/ build/ node_modules/ \ No newline at end of file diff --git a/packages/create-wapi-app/.eslintrc.js b/packages/create-wapi-app/.eslintrc.js deleted file mode 100644 index e9b2cd4..0000000 --- a/packages/create-wapi-app/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import("eslint").Linter.Config} */ -module.exports = { - extends: ["@wapijs/eslint-config/config.node.js"], -}; diff --git a/packages/create-wapi-app/.eslintrc.json b/packages/create-wapi-app/.eslintrc.json new file mode 100644 index 0000000..4190278 --- /dev/null +++ b/packages/create-wapi-app/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["@wapijs/eslint-config/config.node.js"] +} diff --git a/packages/create-wapi-app/package.json b/packages/create-wapi-app/package.json index 38aadb3..df1769b 100644 --- a/packages/create-wapi-app/package.json +++ b/packages/create-wapi-app/package.json @@ -1,6 +1,6 @@ { "name": "create-wapi-app", - "version": "0.1.0", + "version": "0.1.1", "description": "a utility to quickly initiate a whatsapp bot", "type": "module", "author": { diff --git a/packages/create-wapi-app/src/create-bot.ts b/packages/create-wapi-app/src/create-bot.ts index 7d51d48..a0ae546 100644 --- a/packages/create-wapi-app/src/create-bot.ts +++ b/packages/create-wapi-app/src/create-bot.ts @@ -10,13 +10,11 @@ import { import path from "node:path"; import process from "node:process"; import { URL } from "node:url"; -import fastGlob from "fast-glob"; +import { glob } from "fast-glob"; import chalk from "chalk"; import { installPackages } from "./reusable-function.js"; import { PackageManagerEnum } from "./type.js"; -const glob = fastGlob.glob; - export async function createWhatsappBot(options: { directory: string; doInstallPackage: boolean; diff --git a/packages/create-wapi-app/template/typescript/package.json b/packages/create-wapi-app/template/typescript/package.json index dd7c3fb..c578b23 100644 --- a/packages/create-wapi-app/template/typescript/package.json +++ b/packages/create-wapi-app/template/typescript/package.json @@ -1,24 +1,26 @@ { - "$schema": "https://json.schemastore.org/package.json", - "name": "[REPLACE_ME]", - "version": "0.1.0", - "private": true, - "type": "module", - "scripts": { - "lint": "prettier --check . && eslint --ext .js,.mjs,.cjs --format=pretty src", - "format": "prettier --write . && eslint --ext .js,.mjs,.cjs --fix --format=pretty src", - "start": "node --require dotenv/config src/index.js", - "deploy": "node --require dotenv/config src/util/deploy.js" - }, - "dependencies": { - "@wapijs/wapi.js": "^0.0.2", - "dotenv": "^16.3.1" - }, - "devDependencies": { - "eslint": "^8.53.0", - "eslint-config-neon": "^0.1.57", - "eslint-formatter-pretty": "^5.0.0", - "prettier": "^3.1.0", - "zod": "^3.22.4" - } + "$schema": "https://json.schemastore.org/package.json", + "name": "my-whatsapp-bot", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "lint": "prettier --check . && eslint --ext .js,.mjs,.cjs --format=pretty src", + "format": "prettier --write . && eslint --ext .js,.mjs,.cjs --fix --format=pretty src", + "start": "pnpm build && node dist/index.js", + "build": "tsc -p ./tsconfig.json" + }, + "dependencies": { + "@wapijs/wapi.js": "^0.0.7", + "dotenv": "^16.3.1" + }, + "devDependencies": { + "@types/node": "^20.5.9", + "eslint": "^8.53.0", + "eslint-config-neon": "^0.1.57", + "eslint-formatter-pretty": "^5.0.0", + "prettier": "^3.1.0", + "typescript": "5.4.5", + "zod": "^3.22.4" + } } diff --git a/packages/create-wapi-app/template/typescript/src/index.ts b/packages/create-wapi-app/template/typescript/src/index.ts index 9df1613..9eb82db 100644 --- a/packages/create-wapi-app/template/typescript/src/index.ts +++ b/packages/create-wapi-app/template/typescript/src/index.ts @@ -1,5 +1,5 @@ import { whatsappClient } from "./utils/client.js" -import { TextMessage } from '@wapijs/wapi.js' +import { TextMessage, type WapiEventDataMap } from '@wapijs/wapi.js' import { readdir } from 'node:fs/promises' @@ -7,7 +7,7 @@ async function loadEventListeners() { const events = await readdir(`${__dirname}/events/`) events .filter((file) => file.endsWith('.js')) - .map((file) => whatsappClient.on(file.split('.js')[0], require(`${__dirname}/events/${file}`).default)) + .map((file) => whatsappClient.on(file.split('.js')[0] as keyof WapiEventDataMap, require(`${__dirname}/events/${file}`).default)) } async function init() { diff --git a/packages/create-wapi-app/tsconfig.json b/packages/create-wapi-app/tsconfig.json index d110f64..7e8e1be 100644 --- a/packages/create-wapi-app/tsconfig.json +++ b/packages/create-wapi-app/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "@wapijs/typescript-config/node.base.json", - "include": ["src/", "*.ts", "./.eslintrc.js", "bin"], + "include": ["src/", "*.ts", ".eslintrc.js", "bin"], "exclude": ["template/"], "compilerOptions": { "module": "NodeNext", diff --git a/packages/example-chat-bot/src/index.ts b/packages/example-chat-bot/src/index.ts index 0bd310c..0032d8c 100644 --- a/packages/example-chat-bot/src/index.ts +++ b/packages/example-chat-bot/src/index.ts @@ -47,8 +47,7 @@ function init() { ], 'Help & Support': [ { - question: - 'Is wapi.js free and open-source? qwerrqwrf3r3r32r23r23r23r23r2rqrqrerere23re23r23re', + question: 'Is wapi.js free and open-source?', answer: "Yes, it's completely free and open-source under the Apache 2.0 License." }, { @@ -77,13 +76,18 @@ function init() { }) }) + whatsappClient.on('Error', error => { + console.log('Error', error.message) + }) + whatsappClient.on('TextMessage', async message => { console.log('Text Message') if (message.text.data.text.toLowerCase() === 'hello') { - await message.client.message.send({ + const response = await message.client.message.send({ message: listMessage, phoneNumber: message.context.from }) + console.log({ response }) } else { await message.reply({ message: new TextMessage({ @@ -112,10 +116,6 @@ function init() { }) }) - whatsappClient.on('Error', error => { - console.error(error) - }) - whatsappClient.initiate() } diff --git a/packages/example-chat-bot/src/media.png b/packages/example-chat-bot/src/media.png new file mode 100644 index 0000000..b29682d Binary files /dev/null and b/packages/example-chat-bot/src/media.png differ diff --git a/packages/wapi.js/index.ts b/packages/wapi.js/index.ts index 94f37c8..36ffbfd 100644 --- a/packages/wapi.js/index.ts +++ b/packages/wapi.js/index.ts @@ -1,5 +1,4 @@ export * from './src/client/index' -export * from './src/manager' export * from './src/structures' export * from './src/webhook/events/audio/interface' export * from './src/webhook/events/audio/index' @@ -43,6 +42,4 @@ export * from './src/webhook/events/unknown/interface' export * from './src/webhook/events/unknown/index' export * from './src/webhook/events/video/interface' export * from './src/webhook/events/video/index' -export * from './src/webhook/index' -export * from './src/webhook/schema' export * from './src/webhook/type' \ No newline at end of file diff --git a/packages/wapi.js/src/client/index.ts b/packages/wapi.js/src/client/index.ts index e921aa0..7a7bd59 100644 --- a/packages/wapi.js/src/client/index.ts +++ b/packages/wapi.js/src/client/index.ts @@ -1,7 +1,6 @@ import { EventEmitter } from "node:events"; import { Webhook } from "../webhook"; -import { PhoneNumberManager } from "../manager/phone"; import { MediaManager } from "../manager/media"; import { RequestClient } from "./request-client"; import { ClientStatusEnum, type ClientInterface } from "./interface"; @@ -15,13 +14,6 @@ import { type WapiEventDataMap } from "../webhook/type"; * @class Client */ export class Client extends EventEmitter implements ClientInterface { - /** - * Phone number manager to verify phone numbers for your - * @type {PhoneNumberManager} - * @memberof Client - */ - phone: PhoneNumberManager; - /** * Media manager to upload, get and media via whatsapp cloud api * @type {MediaManager} @@ -110,7 +102,6 @@ export class Client extends EventEmitter implements ClientInterface { webhookEndpoint: params.webhookEndpoint, port: params.port, }); - this.phone = new PhoneNumberManager({ client: this }); this.media = new MediaManager({ client: this, }); diff --git a/packages/wapi.js/src/client/interface.ts b/packages/wapi.js/src/client/interface.ts index f274125..e651b0d 100644 --- a/packages/wapi.js/src/client/interface.ts +++ b/packages/wapi.js/src/client/interface.ts @@ -1,22 +1,15 @@ import { type WapiEventDataMap } from "../webhook/type"; -import { type PhoneNumberManager } from "../manager/phone"; import { type MediaManager } from "../manager/media"; import { type Webhook } from "../webhook"; import { type MessageManager } from "../manager/message"; import { type Client } from "./index"; -import { type RequestClient } from "./request-client"; -import { type z } from "zod"; -import { type WapiMessageResponseSchemaType } from "./schema"; +import { type CloudApiRequesterResourceTypeToResponseTypeMap } from "./schema"; /** * Represents the interface for the Wapi client. * @interface ClientInterface */ export interface ClientInterface { - /** - * The phone number manager. - */ - phone: PhoneNumberManager; /** * The media manager. */ @@ -40,7 +33,7 @@ export interface ClientInterface { /** * The request client. */ - requester: RequestClient; + requester: RequestClientInterface; /** * Emits an event with the specified event name and data. * @param {T} eventName - The name of the event. @@ -113,11 +106,13 @@ export interface RequestClientInterface { * @param {'GET' | 'POST' | 'DELETE'} params.method - The HTTP method of the request. * @returns Returns a promise that resolves when the request is completed. */ - requestCloudApi(params: { + requestCloudApi< + T extends keyof CloudApiRequesterResourceTypeToResponseTypeMap, + >(params: { path: string; body: string; method: "GET" | "POST" | "DELETE"; - }): Promise>; + }): Promise; } /** diff --git a/packages/wapi.js/src/client/request-client.ts b/packages/wapi.js/src/client/request-client.ts index ab8d418..796b70b 100644 --- a/packages/wapi.js/src/client/request-client.ts +++ b/packages/wapi.js/src/client/request-client.ts @@ -1,14 +1,9 @@ -import { type z } from "zod"; import { type Client } from "./index"; import { type RequestClientInterface, type RequestClientConfigOptions, } from "./interface"; -import { - CloudApiResponseSchemaType, - type WapiMessageResponseSchemaType, -} from "./schema"; -import { MessageStatusEnum } from "../webhook/type"; +import { type CloudApiRequesterResourceTypeToResponseTypeMap } from "./schema"; /** * Request client used to communicate with WhatsApp Cloud API using HTTP requests. @@ -59,7 +54,9 @@ export class RequestClient implements RequestClientInterface { * @param {'GET' | 'POST' | 'DELETE'} [options.method='POST'] - The request method. * @returns {Promise} A promise that resolves to the response body. */ - async requestCloudApi({ + async requestCloudApi< + T extends keyof CloudApiRequesterResourceTypeToResponseTypeMap, + >({ body, path, method = "POST", @@ -67,9 +64,10 @@ export class RequestClient implements RequestClientInterface { path: string; body?: string; method?: "GET" | "POST" | "DELETE"; - }): Promise> { + }): Promise { try { const requestUrl = this.getRequestUrl(); + const response = await fetch(`${requestUrl}${path}`, { method: method, body, @@ -81,51 +79,11 @@ export class RequestClient implements RequestClientInterface { }); const responseBody = await response.json(); - const parsedResponse = CloudApiResponseSchemaType.safeParse(responseBody); - if (parsedResponse.success) { - const responseData = parsedResponse.data; - if ( - responseData && - typeof responseData === "object" && - "error" in responseData - ) { - // api returned errored response - return { - status: "error", - error: { - description: responseData.error.error_data.details, - title: responseData.error.message, - errorCode: responseData.error.code, - errorSubCode: responseData.error.error_subcode, - }, - }; - } else { - return { - status: "success", - data: { - messageId: responseData.messages[0].id, - receiverPhoneNumber: responseData.contacts[0].input, - senderPhoneNumber: responseData.contacts[0].wa_id, - status: MessageStatusEnum.Sent, - }, - }; - } - } else { - throw new Error( - "Failed to parse response, Report to sarthak@softlancer.co urgently. or raise an issue on github.", - ); - } + + return responseBody as CloudApiRequesterResourceTypeToResponseTypeMap[T]; } catch (error) { if (error instanceof Error) this.client.emit("Error", error); - return { - status: "error", - error: { - title: "Request Error", - description: error instanceof Error ? error.message : "", - errorCode: 0, - errorSubCode: "", - }, - }; + throw error; } } } diff --git a/packages/wapi.js/src/client/schema.ts b/packages/wapi.js/src/client/schema.ts index 94770d4..019763c 100644 --- a/packages/wapi.js/src/client/schema.ts +++ b/packages/wapi.js/src/client/schema.ts @@ -1,7 +1,9 @@ import { z } from "zod"; -import { MessageStatusEnum } from "../webhook/type"; -export const CloudApiSuccessResponseSchemaType = z.object({ +/** + * The response body structure received on a successful message request. + */ +export const CloudApiMessageRequestSuccessResponseSchemaType = z.object({ messages: z.array( z.object({ id: z.string(), @@ -16,6 +18,43 @@ export const CloudApiSuccessResponseSchemaType = z.object({ ), }); +/** + * The response body structure received on a successful media delete request. + */ +export const CloudApiMediaDeleteRequestSuccessResponseSchemaType = z.object({ + success: z.literal(true), +}); + +/** + * The response body structure received on a successful media upload request. + */ +export const CloudApiMediaUploadRequestSuccessResponseSchemaType = z.object({ + id: z.string(), +}); + +/** + * The response body structure received on a successful get media url request. + */ +export const CloudApiGetMediaUrlRequestSuccessResponseSchemaType = z.object({ + url: z.string(), + mime_type: z.string(), + sha256: z.string(), + file_size: z.number(), + id: z.string(), + messaging_product: z.literal("whatsapp"), +}); + +/** + * The response body structure received on a successful media request. + */ +export const RequesterMediaRequestsSuccessResponseBodySchemaType = + CloudApiMediaDeleteRequestSuccessResponseSchemaType.or( + CloudApiMediaUploadRequestSuccessResponseSchemaType, + ).or(CloudApiGetMediaUrlRequestSuccessResponseSchemaType); + +/** + * The Cloud API error response body structure. + */ export const CloudApiErrorResponseSchemaType = z.object({ error: z.object({ message: z.string(), @@ -30,32 +69,24 @@ export const CloudApiErrorResponseSchemaType = z.object({ }), }); -export const CloudApiResponseSchemaType = CloudApiSuccessResponseSchemaType.or( - CloudApiErrorResponseSchemaType, -); - -export const WapiMessageErrorResponseSchemaType = z.object({ - title: z.string(), - description: z.string(), - errorCode: z.number(), - errorSubCode: z.string().optional(), -}); +export const CloudApiResponseSchemaType = + CloudApiMessageRequestSuccessResponseSchemaType.or( + CloudApiErrorResponseSchemaType, + ); -export const WapiMessageSuccessResponseSchemaType = z.object({ - messageId: z.string(), - receiverPhoneNumber: z.string(), - senderPhoneNumber: z.string(), - status: z.nativeEnum(MessageStatusEnum), -}); +export enum CloudApiRequestResourceType { + Message = "message", + Media = "media", + Phone = "phone", +} -export const WapiMessageResponseSchemaType = z - .object({ - status: z.literal("success"), - data: WapiMessageSuccessResponseSchemaType, - }) - .or( - z.object({ - status: z.literal("error"), - error: WapiMessageErrorResponseSchemaType, - }), - ); +export type CloudApiRequesterResourceTypeToResponseTypeMap = { + [CloudApiRequestResourceType.Media]: z.infer< + | typeof RequesterMediaRequestsSuccessResponseBodySchemaType + | typeof CloudApiErrorResponseSchemaType + >; + [CloudApiRequestResourceType.Message]: z.infer< + | typeof CloudApiMessageRequestSuccessResponseSchemaType + | typeof CloudApiErrorResponseSchemaType + >; +}; diff --git a/packages/wapi.js/src/manager/index.ts b/packages/wapi.js/src/manager/index.ts deleted file mode 100644 index 7ccba7e..0000000 --- a/packages/wapi.js/src/manager/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from "./base/index"; -export * from "./base/interface"; - -export * from "./media/index"; -export * from "./media/interface"; - -export * from "./phone/index"; -export * from "./phone/interface"; - -export * from "./message/index"; -export * from "./message/interface"; diff --git a/packages/wapi.js/src/manager/media/index.ts b/packages/wapi.js/src/manager/media/index.ts index 0d9290b..4fa3d21 100644 --- a/packages/wapi.js/src/manager/media/index.ts +++ b/packages/wapi.js/src/manager/media/index.ts @@ -2,7 +2,10 @@ import { type z } from "zod"; import { type Client } from "../../client"; import { BaseManager } from "../base"; import { type MediaManagerInterface } from "./interface"; -import { GetMediaUrlResponseBodySchemaType } from "./schema"; +import { + CloudApiGetMediaUrlRequestSuccessResponseSchemaType, + type CloudApiRequestResourceType, +} from "../../client/schema"; /** * Manager to handle media. @@ -32,14 +35,19 @@ export class MediaManager extends BaseManager implements MediaManagerInterface { */ async getUrl( mediaId: string, - ): Promise> { - const response = await this.client.requester.requestCloudApi({ - path: `/${mediaId}`, - method: "GET", - }); + ): Promise< + z.infer + > { + const response = + await this.client.requester.requestCloudApi( + { + path: `/${mediaId}`, + method: "GET", + }, + ); const parsedResponse = - GetMediaUrlResponseBodySchemaType.safeParse(response); + CloudApiGetMediaUrlRequestSuccessResponseSchemaType.safeParse(response); if (parsedResponse.success) { return parsedResponse.data; @@ -55,36 +63,18 @@ export class MediaManager extends BaseManager implements MediaManagerInterface { * @returns {Promise} - A promise that resolves to true if the media is deleted successfully. */ async delete(mediaId: string): Promise { - const response = await this.client.requester.requestCloudApi({ - path: `/${mediaId}`, - method: "DELETE", - }); - console.log(response); + const response = + await this.client.requester.requestCloudApi( + { + path: `/${mediaId}`, + method: "DELETE", + }, + ); - // TODO: Acknowledge the response here and then resolve the promise - return true; - } - - /** - * Upload media to WhatsApp. - * @param {Object} params - The parameters for uploading media. - * @param {string} params.filePath - The file path of the media to upload. - * @param {string} params.mediaType - The type of the media. - * @memberof MediaManager - * @returns {Promise} - A promise that resolves to the media ID of the uploaded media. - */ - async upload(params: { - filePath: string; - mediaType: string; - }): Promise { - await Promise.resolve(); - - console.log({ params }); - - return ""; - - // TODO: The messaging_product property would always be WhatsApp in this case, so send it in the request - - // TODO: Sanitize the path here and then check if the file path exists + if ("success" in response) { + return true; + } else { + return false; + } } } diff --git a/packages/wapi.js/src/manager/media/interface.ts b/packages/wapi.js/src/manager/media/interface.ts index 9f99f41..f21ccca 100644 --- a/packages/wapi.js/src/manager/media/interface.ts +++ b/packages/wapi.js/src/manager/media/interface.ts @@ -1,6 +1,6 @@ import { type z } from "zod"; import { type BaseManagerInterface } from "../base/interface"; -import { type GetMediaUrlResponseBodySchemaType } from "./schema"; +import { type CloudApiGetMediaUrlRequestSuccessResponseSchemaType } from "../../client/schema"; /** * Media manager interface @@ -15,16 +15,9 @@ export interface MediaManagerInterface extends BaseManagerInterface { */ getUrl: ( mediaId: string, - ) => Promise>; - - /** - * Upload a media file - * @param {Object} params - The parameters for uploading the media file - * @param {string} params.filePath - The file path of the media file - * @param {string} params.mediaType - The type of the media file - * @returns {Promise} The ID of the uploaded media file - */ - upload: (params: { filePath: string; mediaType: string }) => Promise; + ) => Promise< + z.infer + >; /** * Delete a media file by its ID diff --git a/packages/wapi.js/src/manager/media/schema.ts b/packages/wapi.js/src/manager/media/schema.ts index a2c3ea0..5415517 100644 --- a/packages/wapi.js/src/manager/media/schema.ts +++ b/packages/wapi.js/src/manager/media/schema.ts @@ -1,13 +1,46 @@ import { z } from "zod"; +import { ErrorSchemaType } from "../message/schema"; -/** - * Represents the schema for the response body of the GetMediaUrl API. - */ -export const GetMediaUrlResponseBodySchemaType = z.object({ - url: z.string(), - mime_type: z.string(), - sha256: z.string(), - file_size: z.number(), - id: z.string(), - messaging_product: z.literal("whatsapp"), +export enum MediaTypeEnum { + // Audio + AAC = "audio/aac", + AMR = "audio/amr", + MP3 = "audio/mpeg", + MP4_AUDIO = "audio/mp4", + OGG_AUDIO = "audio/ogg", + + // Document + TEXT = "text/plain", + MS_EXCEL = "application/vnd.ms-excel", + MS_EXCEL_X = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + MS_WORD = "application/msword", + MS_WORD_X = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + MS_POWERPOINT = "application/vnd.ms-powerpoint", + MS_POWERPOINT_X = "application/vnd.openxmlformats-officedocument.presentationml.presentation", + PDF = "application/pdf", + + // Image + JPEG = "image/jpeg", + PNG = "image/png", + WEBP = "image/webp", + + // Video + _3GPP = "video/3gp", + MP4_VIDEO = "video/mp4", +} + +export const MediaUploadSuccessResponseSchemaType = z.object({ + mediaId: z.string(), }); + +export const MediaUploadResponseSchemaType = z + .object({ + status: z.literal("success"), + data: MediaUploadSuccessResponseSchemaType, + }) + .or( + z.object({ + status: z.literal("error"), + error: ErrorSchemaType, + }), + ); diff --git a/packages/wapi.js/src/manager/message/index.ts b/packages/wapi.js/src/manager/message/index.ts index 9985a43..dc0161a 100644 --- a/packages/wapi.js/src/manager/message/index.ts +++ b/packages/wapi.js/src/manager/message/index.ts @@ -3,7 +3,12 @@ import { type Client } from "../../client"; import { type BaseMessage } from "../../structures/message"; import { BaseManager } from "../base"; import { type MessageManagerInterface } from "./interface"; -import { type WapiMessageResponseSchemaType } from "../../client/schema"; +import { + type CloudApiRequestResourceType, + CloudApiResponseSchemaType, +} from "../../client/schema"; +import { MessageStatusEnum } from "../../webhook/type"; +import { type MessageResponseSchemaType } from "./schema"; /** * Manager to handle outgoing messages for wapi. @@ -31,14 +36,51 @@ export class MessageManager async send>(props: { message: T; phoneNumber: string; - }): Promise> { - const response = await this.client.requester.requestCloudApi({ - path: `/${this.client.phoneNumberId}/messages`, - body: JSON.stringify(props.message.toJson({ to: props.phoneNumber })), - method: "POST", - }); + }): Promise> { + const response = + await this.client.requester.requestCloudApi( + { + path: `/${this.client.phoneNumberId}/messages`, + body: JSON.stringify(props.message.toJson({ to: props.phoneNumber })), + method: "POST", + }, + ); - return response; + const parsedResponse = CloudApiResponseSchemaType.safeParse(response); + if (parsedResponse.success) { + const responseData = parsedResponse.data; + + if ( + responseData && + typeof responseData === "object" && + "error" in responseData + ) { + // api returned errored response + return { + status: "error", + error: { + description: responseData.error.error_data.details, + title: responseData.error.message, + errorCode: responseData.error.code, + errorSubCode: responseData.error.error_subcode, + }, + }; + } else { + return { + status: "success", + data: { + messageId: responseData.messages[0].id, + receiverPhoneNumber: responseData.contacts[0].input, + senderPhoneNumber: responseData.contacts[0].wa_id, + status: MessageStatusEnum.Sent, + }, + }; + } + } else { + throw new Error( + "Failed to parse response, Report to sarthak@softlancer.co urgently. or raise an issue on github.", + ); + } } /** @@ -53,18 +95,54 @@ export class MessageManager replyToMessageId: string; message: T; phoneNumber: string; - }): Promise> { - const response = await this.client.requester.requestCloudApi({ - path: `/${this.client.phoneNumberId}/messages`, - body: JSON.stringify( - props.message.toJson({ - to: props.phoneNumber, - replyToMessageId: props.replyToMessageId, - }), - ), - method: "POST", - }); + }): Promise> { + const response = + await this.client.requester.requestCloudApi( + { + path: `/${this.client.phoneNumberId}/messages`, + body: JSON.stringify( + props.message.toJson({ + to: props.phoneNumber, + replyToMessageId: props.replyToMessageId, + }), + ), + method: "POST", + }, + ); - return response; + const parsedResponse = CloudApiResponseSchemaType.safeParse(response); + if (parsedResponse.success) { + const responseData = parsedResponse.data; + if ( + responseData && + typeof responseData === "object" && + "error" in responseData + ) { + // api returned errored response + return { + status: "error", + error: { + description: responseData.error.error_data.details, + title: responseData.error.message, + errorCode: responseData.error.code, + errorSubCode: responseData.error.error_subcode, + }, + }; + } else { + return { + status: "success", + data: { + messageId: responseData.messages[0].id, + receiverPhoneNumber: responseData.contacts[0].input, + senderPhoneNumber: responseData.contacts[0].wa_id, + status: MessageStatusEnum.Sent, + }, + }; + } + } else { + throw new Error( + "Failed to parse response, Report to sarthak@softlancer.co urgently. or raise an issue on github.", + ); + } } } diff --git a/packages/wapi.js/src/manager/message/interface.ts b/packages/wapi.js/src/manager/message/interface.ts index 3454969..840f9dc 100644 --- a/packages/wapi.js/src/manager/message/interface.ts +++ b/packages/wapi.js/src/manager/message/interface.ts @@ -2,7 +2,7 @@ import { type z } from "zod"; import { type Client } from "../../client"; import { type BaseMessage } from "../../structures/message"; import { type BaseManagerInterface } from "../base/interface"; -import { type WapiMessageResponseSchemaType } from "../../client/schema"; +import { type MessageResponseSchemaType } from "./schema"; /** * Message manager interface @@ -23,7 +23,7 @@ export interface MessageManagerInterface extends BaseManagerInterface { send>(props: { message: T; phoneNumber: string; - }): Promise>; + }): Promise>; /** * Replies to a message with the specified message. @@ -34,5 +34,5 @@ export interface MessageManagerInterface extends BaseManagerInterface { replyToMessageId: string; message: T; phoneNumber: string; - }): Promise>; + }): Promise>; } diff --git a/packages/wapi.js/src/manager/message/schema.ts b/packages/wapi.js/src/manager/message/schema.ts new file mode 100644 index 0000000..cc9a8ce --- /dev/null +++ b/packages/wapi.js/src/manager/message/schema.ts @@ -0,0 +1,28 @@ +import { z } from "zod"; +import { MessageStatusEnum } from "../../webhook/type"; + +export const ErrorSchemaType = z.object({ + title: z.string(), + description: z.string(), + errorCode: z.number(), + errorSubCode: z.string().optional(), +}); + +export const MessageSuccessResponseSchemaType = z.object({ + messageId: z.string(), + receiverPhoneNumber: z.string(), + senderPhoneNumber: z.string(), + status: z.nativeEnum(MessageStatusEnum), +}); + +export const MessageResponseSchemaType = z + .object({ + status: z.literal("success"), + data: MessageSuccessResponseSchemaType, + }) + .or( + z.object({ + status: z.literal("error"), + error: ErrorSchemaType, + }), + ); diff --git a/packages/wapi.js/src/manager/phone/index.ts b/packages/wapi.js/src/manager/phone/index.ts deleted file mode 100644 index 05e865e..0000000 --- a/packages/wapi.js/src/manager/phone/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { type Client } from "../../client"; -import { BaseManager } from "../base"; -import { type PhoneNumberManagerInterface } from "./interface"; - -/** - * Represents a manager for handling phone numbers. - * @implements {PhoneNumberManagerInterface} - * @class PhoneNumberManager - * @extends {BaseManager} - */ -export class PhoneNumberManager - extends BaseManager - implements PhoneNumberManagerInterface -{ - /** - * Creates a new instance of PhoneNumberManager. - * @param props - The properties for initializing the PhoneNumberManager. - */ - constructor(props: { client: Client }) { - super(props.client); - } - - /** - * Sends a verification code to the specified phone number. - * @param phoneNumber - The phone number to send the verification code to. - * @returns A promise that resolves to a boolean indicating if the verification code was sent successfully. - */ - async sendVerificationCode(phoneNumber: string) { - console.log(phoneNumber); - await Promise.resolve(false); - return false; - } - - /** - * Verifies the provided verification code. - * @param code - The verification code to verify. - * @returns A promise that resolves to a boolean indicating if the verification code is valid. - */ - async verifyCode(code: string) { - console.log(code); - await Promise.resolve(true); - return true; - } -} diff --git a/packages/wapi.js/src/manager/phone/interface.ts b/packages/wapi.js/src/manager/phone/interface.ts deleted file mode 100644 index eb99307..0000000 --- a/packages/wapi.js/src/manager/phone/interface.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { type BaseManagerInterface } from "../base/interface"; - -/** - * Represents the interface for managing phone numbers. - * @extends {BaseManagerInterface} - */ -export interface PhoneNumberManagerInterface extends BaseManagerInterface { - /** - * Sends a verification code to the specified phone number. - * @param phoneNumber - The phone number to send the verification code to. - * @returns A Promise that resolves to a boolean indicating whether the verification code was sent successfully. - */ - sendVerificationCode: (phoneNumber: string) => Promise; - - /** - * Verifies the provided verification code. - * @param code - The verification code to verify. - * @returns A Promise that resolves to a boolean indicating whether the verification code is valid. - */ - verifyCode: (code: string) => Promise; -} diff --git a/packages/wapi.js/src/structures/interaction/index.ts b/packages/wapi.js/src/structures/interaction/index.ts index 9f9f45c..9e227c4 100644 --- a/packages/wapi.js/src/structures/interaction/index.ts +++ b/packages/wapi.js/src/structures/interaction/index.ts @@ -225,7 +225,7 @@ export class ListInteractionMessage footerText: params.footerText, bodyText: params.bodyText, }); - // this.parseConstructorPayload(this._constructorPayloadSchema, params); + this.parseConstructorPayload(this._constructorPayloadSchema, params); this.data = { buttonText: params.buttonText, sections: params.sections, diff --git a/packages/wapi.js/src/webhook/events/base/index.ts b/packages/wapi.js/src/webhook/events/base/index.ts index 98f7ee4..267aaa6 100644 --- a/packages/wapi.js/src/webhook/events/base/index.ts +++ b/packages/wapi.js/src/webhook/events/base/index.ts @@ -1,6 +1,5 @@ import { type z } from "zod"; import { type Client } from "../../../client"; -import { type WapiMessageResponseSchemaType } from "../../../client/schema"; import { ReactionMessage } from "../../../structures"; import { type BaseMessage } from "../../../structures/message"; import { @@ -10,6 +9,7 @@ import { type MessageContext, type MediaMessageEventInterface, } from "./interface"; +import { type MessageResponseSchemaType } from "../../../manager/message/schema"; /** * Represents the base event for webhook events. @@ -74,7 +74,7 @@ export abstract class MessageEvent */ async reply>(props: { message: T; - }): Promise> { + }): Promise> { if (!this.context.from) { throw new Error( "No context message id found while replying to message!!", diff --git a/packages/wapi.js/src/webhook/index.ts b/packages/wapi.js/src/webhook/index.ts index 4e8f6c1..2adc5fa 100644 --- a/packages/wapi.js/src/webhook/index.ts +++ b/packages/wapi.js/src/webhook/index.ts @@ -1,4 +1,3 @@ -import * as EventEmitter from "events"; import { type Client } from "../client"; import { WhatsappApiNotificationPayloadSchemaType } from "./schema"; import * as express from "express"; @@ -60,7 +59,7 @@ import { type WebhookInterface } from "./interface"; * @extends {EventEmitter} * @implements {WebhookInterface} */ -export class Webhook extends EventEmitter implements WebhookInterface { +export class Webhook implements WebhookInterface { private endpoint: string; private port = 3000; private server: Express; @@ -83,7 +82,6 @@ export class Webhook extends EventEmitter implements WebhookInterface { webhookEndpoint: string; port: number; }) { - super(); this.client = params.client; this.endpoint = params.webhookEndpoint; this.webhookSecret = params.webhookSecret; diff --git a/packages/wapi.js/src/webhook/interface.ts b/packages/wapi.js/src/webhook/interface.ts index 53fa367..5087490 100644 --- a/packages/wapi.js/src/webhook/interface.ts +++ b/packages/wapi.js/src/webhook/interface.ts @@ -1,11 +1,9 @@ -import type EventEmitter from "events"; - /** * Represents the interface for a Webhook. * @interface WebhookInterface * @extends {EventEmitter} */ -export interface WebhookInterface extends EventEmitter { +export interface WebhookInterface { /** * Gets the endpoint of the webhook. * @returns The endpoint URL. diff --git a/packages/wapi.js/temp/wapi.js.api.md b/packages/wapi.js/temp/wapi.js.api.md deleted file mode 100644 index a2fd6f3..0000000 --- a/packages/wapi.js/temp/wapi.js.api.md +++ /dev/null @@ -1,4626 +0,0 @@ -## API Report File for "@wapijs/wapi.js" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -/// - -import type { default as default_2 } from 'events'; -import { EventEmitter } from 'node:events'; -import * as EventEmitter_2 from 'events'; -import { HeaderTypeEnum } from './structures/interaction/schema'; -import { MessageStatusEnum as MessageStatusEnum_2 } from '../../type'; -import { Request as Request_2 } from 'express'; -import { Response as Response_2 } from 'express'; -import { z } from 'zod'; -import { ZodSchema } from 'zod'; - -// @public -export class AdInteractionEvent extends MessageEvent implements AdInteractionEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - id: string; - timestamp: string; - isForwarded: boolean; - text: string; - source: { - url: string; - id: string; - type: AdInteractionSourceTypeEnum; - title: string; - description: string; - mediaUrl?: string; - mediaType: AdInteractionSourceMediaTypeEnum; - thumbnailUrl: string; - ctwaClid: string; - }; - }; - }); - // (undocumented) - source: { - url: string; - id: string; - type: AdInteractionSourceTypeEnum; - title: string; - description: string; - mediaUrl?: string; - mediaType: AdInteractionSourceMediaTypeEnum; - thumbnailUrl: string; - ctwaClid: string; - }; - // (undocumented) - text: string; -} - -// @public -export interface AdInteractionEventInterface extends InteractionMessageEventInterface { - // (undocumented) - source: { - url: string; - id: string; - type: AdInteractionSourceTypeEnum; - title: string; - description: string; - mediaUrl?: string; - mediaType: AdInteractionSourceMediaTypeEnum; - thumbnailUrl: string; - ctwaClid: string; - }; - // (undocumented) - text: string; -} - -// @public -export enum AdInteractionSourceMediaTypeEnum { - // (undocumented) - Image = "image", - // (undocumented) - Video = "video" -} - -// @public -export enum AdInteractionSourceTypeEnum { - // (undocumented) - Ad = "ad", - // (undocumented) - Post = "post" -} - -// Warning: (ae-forgotten-export) The symbol "BaseMessage" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "MessageTypeEnum" needs to be exported by the entry point index.d.ts -// -// @public -export class AudioMessage extends BaseMessage implements AudioMessageInterface { - constructor(params: z.infer); - // Warning: (ae-forgotten-export) The symbol "MetaAudioMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "ExternalAudioMediaObjectType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - data: z.infer; - // Warning: (ae-forgotten-export) The symbol "WhatsappCloudApiRequestPayloadSchemaType" needs to be exported by the entry point index.d.ts - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: MessageTypeEnum.Audio; - }>; -} - -// @public -export class AudioMessageEvent extends MediaMessageEvent implements AudioMessageEventInterface { - constructor(params: { - client: Client; - data: { - audio: AudioMessage; - from: string; - messageId: string; - timestamp: string; - mimeType: string; - sha256: string; - mediaId: string; - isForwarded: boolean; - }; - }); - // (undocumented) - audio: AudioMessage; -} - -// @public -export interface AudioMessageEventInterface extends MediaMessageEventInterface { - audio: AudioMessage; -} - -// Warning: (ae-forgotten-export) The symbol "BaseMessageInterface" needs to be exported by the entry point index.d.ts -// -// @public -export interface AudioMessageInterface extends BaseMessageInterface { - // (undocumented) - data: z.infer; -} - -// @public -export class BaseEvent implements BaseEventInterface { - constructor(params: { - client: Client; - }); - // (undocumented) - client: Client; -} - -// @public -export interface BaseEventInterface { - client: Client; -} - -// @public -export class BaseManager implements BaseManagerInterface { - constructor(client: Client); - client: Client; -} - -// @public -export interface BaseManagerInterface { - client: Client; -} - -// Warning: (ae-forgotten-export) The symbol "InteractiveMessage" needs to be exported by the entry point index.d.ts -// -// @public -export class ButtonInteractionMessage extends InteractiveMessage implements ButtonInteractionMessageInterface { - constructor(params: { - buttons: { - id: string; - title: string; - }[]; - footerText?: string; - bodyText: string; - }); - addFooter(footerText: string): void; - addHeader(): void; - // (undocumented) - data: { - buttons: { - id: string; - title: string; - }[]; - }; - // Warning: (ae-forgotten-export) The symbol "InteractiveMessageApiPayloadSchemaType" needs to be exported by the entry point index.d.ts - toJson(params: { - to: string; - replyToMessageId?: string; - }): z.infer & { - interactive: z.infer; - }; -} - -// @public -export interface ButtonInteractionMessageInterface extends InteractiveMessageInterface { - // (undocumented) - data: { - buttons: { - id: string; - title: string; - }[]; - }; -} - -// @public -export interface ButtonReplyInteractionMessageEventInterface extends InteractionMessageEventInterface { - // (undocumented) - buttonId: string; - // (undocumented) - title: string; -} - -// Warning: (ae-forgotten-export) The symbol "ClientInterface" needs to be exported by the entry point index.d.ts -// -// @public -export class Client extends EventEmitter implements ClientInterface { - constructor(params: { - webhookSecret: string; - webhookEndpoint: string; - apiAccessToken: string; - phoneNumberId: string; - businessAccountId: string; - port: number; - }); - emit(eventName: T, data: WapiEventDataMap[T]): boolean; - static getClient(): typeof Client; - get getReadyAtTimestamp(): 0 | Date | null; - initiate(): void; - media: MediaManager; - message: MessageManager; - on(eventName: T, listener: (data: WapiEventDataMap[T]) => void): this; - phone: PhoneNumberManager; - get phoneNumberId(): string; - readyAtTimeStamp: number | null; - // Warning: (ae-forgotten-export) The symbol "RequestClient" needs to be exported by the entry point index.d.ts - requester: RequestClient; - // Warning: (ae-forgotten-export) The symbol "ClientStatusEnum" needs to be exported by the entry point index.d.ts - status: ClientStatusEnum | null; - set updateAccessToken(accessToken: string); - set updateSenderPhoneNumberId(phoneNumber: string); - get uptime(): number | null; - webhook: Webhook; -} - -// @public -export class Contact { - constructor(params: { - name: z.infer; - }); - addAddress(address: z.infer): void; - addEmail(email: z.infer): void; - addPhone(phone: z.infer): void; - // Warning: (ae-forgotten-export) The symbol "ContactAddressSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - addresses?: z.infer[]; - addUrl(url: z.infer): void; - // (undocumented) - birthday?: string; - // Warning: (ae-forgotten-export) The symbol "ContactEmailPayloadSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - emails?: z.infer[]; - // Warning: (ae-forgotten-export) The symbol "ContactNamePayloadSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - name: z.infer; - // Warning: (ae-forgotten-export) The symbol "ContactOrgPayloadSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - org?: z.infer; - // Warning: (ae-forgotten-export) The symbol "ContactPhonePayloadSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - phones?: z.infer[]; - setBirthday(date: string): void; - setFirstName(firstName: string): void; - setLastName(lastName: string): void; - setMiddleName(middleName: string): void; - setNamePrefix(prefix: string): void; - setNameSuffix(suffix: string): void; - setOrg(org: z.infer): void; - // Warning: (ae-forgotten-export) The symbol "ContactUrlPayloadSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - urls?: z.infer[]; -} - -// Warning: (ae-forgotten-export) The symbol "ContactMessageInterface" needs to be exported by the entry point index.d.ts -// -// @public -export class ContactMessage extends BaseMessage<"contacts"> implements ContactMessageInterface { - constructor(params: { - contacts: Contact[]; - }); - addContact(contact: Contact): void; - // (undocumented) - contacts: Contact[]; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: "contacts"; - }>; -} - -// @public -export class ContactMessageEvent extends MessageEvent implements ContactMessageEventInterface { - constructor(params: { - client: Client; - data: { - contact: ContactMessage; - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - }; - }); - contact: ContactMessage; -} - -// @public -export interface ContactMessageEventInterface extends MessageEventInterface { - contact: ContactMessage; -} - -// @public -export class CustomerIdentityChangeEvent implements CustomerIdentityChangeEventInterface { - constructor(params: { - client: Client; - acknowledged: string; - creationTimestamp: string; - hash: string; - timestamp: string; - }); - acknowledged: string; - client: Client; - creationTimestamp: string; - hash: string; -} - -// @public -export interface CustomerIdentityChangeEventInterface { - acknowledged: string; - client: Client; - creationTimestamp: string; - hash: string; -} - -// @public -export class CustomerNumberChangeEvent implements CustomerNumberChangeEventInterface { - constructor(params: { - client: Client; - changeDescription: string; - newWaId: string; - timestamp: string; - oldWaId: string; - }); - changeDescription: string; - client: Client; - newWaId: string; - oldWaId: string; - timestamp: number; -} - -// @public -export interface CustomerNumberChangeEventInterface { - changeDescription: string; - client: Client; - newWaId: string; - oldWaId: string; - timestamp: number; -} - -// @public -export class DocumentMessage extends BaseMessage implements DocumentMessageInterface { - constructor(params: z.infer); - // Warning: (ae-forgotten-export) The symbol "MetaDocumentMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "ExternalDocumentMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - data: z.infer; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: MessageTypeEnum.Document; - }>; -} - -// @public -export class DocumentMessageEvent extends MediaMessageEvent implements DocumentMessageEventInterface { - constructor(params: { - client: Client; - data: { - document: DocumentMessage; - from: string; - messageId: string; - timestamp: string; - mediaId: string; - mimeType: string; - sha256: string; - isForwarded: boolean; - }; - }); - document: DocumentMessage; -} - -// @public -export interface DocumentMessageEventInterface extends MediaMessageEventInterface { - document: DocumentMessage; -} - -// @public -export interface DocumentMessageInterface extends BaseMessageInterface { - // (undocumented) - data: z.infer; -} - -// @public -export class ImageMessage extends BaseMessage implements ImageMessageInterface { - constructor(params: z.infer); - // Warning: (ae-forgotten-export) The symbol "MetaImageMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "ExternalImageMediaObjectType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - data: z.infer; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: MessageTypeEnum.Image; - }>; -} - -// @public -export class ImageMessageEvent extends MediaMessageEvent implements ImageMessageEventInterface { - constructor(params: { - client: Client; - data: { - image: ImageMessage; - from: string; - messageId: string; - timestamp: string; - mediaId: string; - mimeType: string; - sha256: string; - isForwarded: boolean; - }; - }); - image: ImageMessage; -} - -// @public -export interface ImageMessageEventInterface extends MediaMessageEventInterface { - image: ImageMessage; -} - -// @public -export interface ImageMessageInterface extends BaseMessageInterface { - // (undocumented) - data: z.infer; -} - -// @public -export abstract class InteractionEvent extends MessageEvent implements InteractionMessageEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - }; - }); -} - -// @public -export type InteractionMessageEventInterface = MessageEventInterface; - -// @public -export enum InteractionNotificationTypeEnum { - // (undocumented) - ButtonReply = "button_reply", - // (undocumented) - ListReply = "list_reply" -} - -// @public -export interface InteractiveMessageInterface extends BaseMessageInterface { - // (undocumented) - interactiveMessageData: { - type: InteractiveMessageTypeEnum; - footerText?: string; - bodyText: string; - }; -} - -// @public -export enum InteractiveMessageTypeEnum { - // (undocumented) - Button = "button", - // (undocumented) - Catalog = "catalog_message", - // (undocumented) - Flow = "flow", - // (undocumented) - List = "list", - // (undocumented) - Product = "product", - // (undocumented) - ProductList = "product_list" -} - -// @public -export class ListInteractionEvent extends InteractionEvent implements ListInteractionMessageEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - messageId: string; - timestamp: string; - title: string; - listId: string; - description: string; - isForwarded: boolean; - }; - }); - // (undocumented) - description: string; - // (undocumented) - listId: string; - // (undocumented) - title: string; -} - -// @public -export class ListInteractionMessage extends InteractiveMessage implements ListInteractionMessageInterface { - constructor(params: { - buttonText: string; - footerText?: string; - bodyText: string; - sections: z.infer[]; - }); - addFooter(footerText: string): void; - addHeader(): void; - addSection(section: z.infer): void; - // (undocumented) - data: { - buttonText: string; - sections: z.infer[]; - }; - toJson(params: { - to: string; - replyToMessageId?: string; - }): z.infer & { - interactive: z.infer; - }; -} - -// @public -export interface ListInteractionMessageEventInterface extends InteractionMessageEventInterface { - // (undocumented) - description: string; - // (undocumented) - listId: string; - // (undocumented) - title: string; -} - -// @public -export interface ListInteractionMessageInterface extends InteractiveMessageInterface { - // (undocumented) - data: { - buttonText: string; - sections: z.infer[]; - }; -} - -// @public -export class LocationMessage extends BaseMessage<"location"> implements LocationMessageInterface { - // Warning: (ae-forgotten-export) The symbol "LocationSchemaType" needs to be exported by the entry point index.d.ts - constructor(params: z.infer); - // (undocumented) - data: { - address?: string; - latitude: number; - longitude: number; - name?: string; - }; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: "location"; - }>; -} - -// @public -export class LocationMessageEvent extends MessageEvent implements LocationMessageEventInterface { - constructor(params: { - client: Client; - data: { - location: LocationMessage; - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - }; - }); - location: LocationMessage; -} - -// @public -export interface LocationMessageEventInterface extends MessageEventInterface { - location: LocationMessage; -} - -// @public -export interface LocationMessageInterface extends BaseMessageInterface { - // (undocumented) - data: { - address?: string; - latitude: number; - longitude: number; - name?: string; - }; -} - -// @public -export class MediaManager extends BaseManager implements MediaManagerInterface { - constructor(props: { - client: Client; - }); - // (undocumented) - client: Client; - delete(mediaId: string): Promise; - // Warning: (ae-forgotten-export) The symbol "GetMediaUrlResponseBodySchemaType" needs to be exported by the entry point index.d.ts - getUrl(mediaId: string): Promise>; - upload(params: { - filePath: string; - mediaType: string; - }): Promise; -} - -// @public -export interface MediaManagerInterface extends BaseManagerInterface { - delete: (mediaId: string) => Promise; - getUrl: (mediaId: string) => Promise>; - upload: (params: { - filePath: string; - mediaType: string; - }) => Promise; -} - -// @public -export abstract class MediaMessageEvent extends MessageEvent implements MediaMessageEventInterface { - constructor(params: { - client: Client; - from: string; - messageId: string; - timestamp: string; - mediaId: string; - mimeType: string; - sha256: string; - isForwarded: boolean; - }); - getUrl(): Promise; - // (undocumented) - mediaId: string; - // (undocumented) - mimeType: string; - // (undocumented) - sha256: string; -} - -// @public -export interface MediaMessageEventInterface extends MessageEventInterface { - getUrl: () => Promise; - mediaId: string; - mimeType: string; - sha256: string; -} - -// @public -export interface MediaMessageInterface { - // (undocumented) - caption?: string; - // (undocumented) - fileName?: string; - // (undocumented) - id?: string; - // (undocumented) - link?: string; - // (undocumented) - type: MediaTypeEnum; -} - -// @public -export enum MediaTypeEnum { - // (undocumented) - Audio = "audio", - // (undocumented) - Document = "document", - // (undocumented) - Image = "image", - // (undocumented) - Sticker = "sticker", - // (undocumented) - Video = "video" -} - -// @public -export type MessageContext = { - from: string; -}; - -// @public -export class MessageDeliveryEvent extends StatusUpdateEvent implements MessageDeliveryEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - timestamp: string; - }; - }); -} - -// @public -export type MessageDeliveryEventInterface = StatusUpdateEventInterface; - -// @public -export abstract class MessageEvent extends BaseEvent implements MessageEventInterface { - constructor(params: { - client: Client; - id: string; - from: string; - timestamp: string; - isForwarded: boolean; - }); - // (undocumented) - context: MessageContext; - // (undocumented) - isForwarded: boolean; - // (undocumented) - messageId: string; - react(params: { - emoji: string; - phoneNumber: string; - }): Promise<{ - status: "success"; - data: { - status: MessageStatusEnum_2; - messageId: string; - receiverPhoneNumber: string; - senderPhoneNumber: string; - }; - } | { - status: "error"; - error: { - title: string; - description: string; - errorCode: number; - errorSubCode?: string | undefined; - }; - }>; - read(): Promise<{ - status: "success"; - data: { - status: MessageStatusEnum_2; - messageId: string; - receiverPhoneNumber: string; - senderPhoneNumber: string; - }; - } | { - status: "error"; - error: { - title: string; - description: string; - errorCode: number; - errorSubCode?: string | undefined; - }; - }>; - // Warning: (ae-forgotten-export) The symbol "WapiMessageResponseSchemaType" needs to be exported by the entry point index.d.ts - reply>(props: { - message: T; - }): Promise>; - // (undocumented) - timestamp: number; -} - -// @public -export interface MessageEventInterface extends BaseEventInterface { - context: MessageContext; - messageId: string; - timestamp: number; -} - -// @public -export class MessageFailedEvent extends StatusUpdateEvent implements MessageFailedEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - timestamp: string; - failReason: string; - }; - }); - // (undocumented) - failReason: string; -} - -// @public -export interface MessageFailedEventInterface extends StatusUpdateEventInterface { - failReason: string; -} - -// @public -export class MessageManager extends BaseManager implements MessageManagerInterface { - constructor(props: { - client: Client; - }); - // (undocumented) - client: Client; - reply>(props: { - replyToMessageId: string; - message: T; - phoneNumber: string; - }): Promise>; - send>(props: { - message: T; - phoneNumber: string; - }): Promise>; -} - -// @public -export interface MessageManagerInterface extends BaseManagerInterface { - client: Client; - reply>(props: { - replyToMessageId: string; - message: T; - phoneNumber: string; - }): Promise>; - send>(props: { - message: T; - phoneNumber: string; - }): Promise>; -} - -// @public -export class MessageReadEvent extends StatusUpdateEvent implements MessageReadEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - timestamp: string; - }; - }); -} - -// @public -export type MessageReadEventInterface = StatusUpdateEventInterface; - -// @public -export class MessageSentEvent extends StatusUpdateEvent implements MessageSentEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - timestamp: string; - }; - }); -} - -// @public -export type MessageSentEventInterface = StatusUpdateEventInterface; - -// @public -export enum MessageStatusCategoryEnum { - // (undocumented) - Authentication = "authentication", - // (undocumented) - Marketing = "marketing", - // (undocumented) - ReferralConversion = "referral_conversion", - // (undocumented) - Service = "service", - // (undocumented) - Utility = "utility" -} - -// @public -export enum MessageStatusEnum { - // (undocumented) - Delivered = "delivered", - // (undocumented) - Failed = "failed", - // (undocumented) - Read = "read", - // (undocumented) - Sent = "sent" -} - -// @public -export class MessageUndeliveredEvent extends StatusUpdateEvent implements MessageUndeliveredEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - timestamp: string; - }; - }); -} - -// @public -export type MessageUndeliveredEventInterface = StatusUpdateEventInterface; - -// @public -export enum NotificationEventTypeEnum { - // (undocumented) - AdInteraction = "AdInteraction", - // (undocumented) - AudioMessage = "AudioMessage", - // (undocumented) - ButtonInteraction = "ButtonInteraction", - // (undocumented) - ContactsMessage = "ContactsMessage", - // (undocumented) - CustomerIdentityChanged = "CustomerIdentityChanged", - // (undocumented) - CustomerNumberChanged = "CustomerNumberChanged", - // (undocumented) - DocumentMessage = "DocumentMessage", - // (undocumented) - ImageMessage = "ImageMessage", - // (undocumented) - ListInteraction = "ListInteraction", - // (undocumented) - LocationMessage = "LocationMessage", - // (undocumented) - MessageDeleted = "MessageDeleted", - // (undocumented) - MessageDelivered = "MessageDelivered", - // (undocumented) - MessageFailed = "MessageFailed", - // (undocumented) - MessageRead = "MessageRead", - // (undocumented) - MessageSent = "MessageSent", - // (undocumented) - MessageUndelivered = "MessageUndelivered", - // (undocumented) - OrderReceived = "OrderReceived", - // (undocumented) - ProductInquiry = "ProductInquiry", - // (undocumented) - Reaction = "Reaction", - // (undocumented) - ReplyMessage = "ReplyMessage", - // (undocumented) - StickerMessage = "StickerMessage", - // (undocumented) - TextMessage = "TextMessage", - // (undocumented) - UnknownEvent = "UnknownEvent", - // (undocumented) - VideoMessage = "VideoMessage" -} - -// @public -export enum NotificationMessageTypeEnum { - // (undocumented) - Audio = "audio", - // (undocumented) - Button = "button", - // (undocumented) - Contacts = "contacts", - // (undocumented) - Document = "document", - // (undocumented) - Image = "image", - // (undocumented) - Interactive = "interactive", - // (undocumented) - Location = "location", - // (undocumented) - Order = "order", - // (undocumented) - Reaction = "reaction", - // (undocumented) - Sticker = "sticker", - // (undocumented) - System = "system", - // (undocumented) - Text = "text", - // (undocumented) - Unknown = "unknown", - // (undocumented) - Video = "Video" -} - -// @public (undocumented) -export const NotificationPayloadAudioMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - audio: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - }, { - id: string; - mime_type: string; - sha256: string; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; -}, { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadButtonMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - button: z.ZodObject<{ - payload: z.ZodString; - text: z.ZodString; - }, "strip", z.ZodTypeAny, { - text: string; - payload: string; - }, { - text: string; - payload: string; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; -}, { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadContactMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - contacts: z.ZodArray, "many">; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; -}, { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; -}>; - -// @public (undocumented) -export const NotificationPayloadDocumentMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - document: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - filename: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; -}, { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadErrorSchemaType: z.ZodObject<{ - code: z.ZodNumber; - title: z.ZodString; - message: z.ZodString; - error_data: z.ZodObject<{ - details: z.ZodString; - }, "strip", z.ZodTypeAny, { - details: string; - }, { - details: string; - }>; -}, "strip", z.ZodTypeAny, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; -}, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; -}>; - -// @public (undocumented) -export const NotificationPayloadImageMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - image: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; -}, { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadInteractionMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - interactive: z.ZodIntersection; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum; - }, { - type: InteractionNotificationTypeEnum; - }>, z.ZodUnion<[z.ZodObject<{ - type: z.ZodLiteral; - button_reply: z.ZodObject<{ - id: z.ZodString; - title: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - title: string; - }, { - id: string; - title: string; - }>; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - }, { - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - }>, z.ZodObject<{ - type: z.ZodLiteral; - list_reply: z.ZodObject<{ - id: z.ZodString; - title: z.ZodString; - description: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - title: string; - description: string; - }, { - id: string; - title: string; - description: string; - }>; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }, { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }>]>>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); -}, { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); -}>; - -// @public (undocumented) -export const NotificationPayloadLocationMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - location: z.ZodObject<{ - latitude: z.ZodNumber; - longitude: z.ZodNumber; - name: z.ZodOptional; - address: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }, { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; -}, { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadMessageContextSchemaType: z.ZodOptional; - frequently_forwarded: z.ZodOptional; - from: z.ZodOptional; - id: z.ZodString; - referred_product: z.ZodOptional>; -}, "strip", z.ZodTypeAny, { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; -}, { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; -}>>; - -// @public (undocumented) -export const NotificationPayloadOrderMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - text: z.ZodString; - order: z.ZodObject<{ - catalog_id: z.ZodString; - product_items: z.ZodArray, "many">; - }, "strip", z.ZodTypeAny, { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }, { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; -}, { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadReactionMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - reaction: z.ZodObject<{ - message_id: z.ZodString; - emoji: z.ZodString; - }, "strip", z.ZodTypeAny, { - message_id: string; - emoji: string; - }, { - message_id: string; - emoji: string; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; -}, { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadStickerMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - sticker: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - animated: z.ZodBoolean; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }, { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; -}, { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadSystemMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - system: z.ZodObject<{ - identity: z.ZodString; - body: z.ZodString; - customer: z.ZodString; - type: z.ZodNativeEnum; - wa_id: z.ZodString; - }, "strip", z.ZodTypeAny, { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }, { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }>; - identity: z.ZodObject<{ - acknowledged: z.ZodString; - created_timestamp: z.ZodString; - hash: z.ZodString; - }, "strip", z.ZodTypeAny, { - acknowledged: string; - created_timestamp: string; - hash: string; - }, { - acknowledged: string; - created_timestamp: string; - hash: string; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; -}, { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; -}>; - -// @public (undocumented) -export const NotificationPayloadTextMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - text: z.ZodObject<{ - body: z.ZodString; - }, "strip", z.ZodTypeAny, { - body: string; - }, { - body: string; - }>; - referral: z.ZodOptional; - source_id: z.ZodString; - headline: z.ZodString; - body: z.ZodString; - image_url: z.ZodOptional; - video_url: z.ZodOptional; - thumbnail_url: z.ZodString; - ctwa_clid: z.ZodString; - media_type: z.ZodNativeEnum; - }, "strip", z.ZodTypeAny, { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - }, { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - }>>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; -}, { - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; -}>; - -// @public (undocumented) -export const NotificationPayloadUnknownMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Unknown; -}, { - type: NotificationMessageTypeEnum.Unknown; -}>; - -// @public (undocumented) -export const NotificationPayloadVideoMessageSchemaType: z.ZodObject<{ - type: z.ZodLiteral; - video: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - filename: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }>; -}, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; -}, { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; -}>; - -// @public (undocumented) -export const NotificationReasonEnum: z.ZodEnum<["message"]>; - -// @public -export class OrderMessageEvent extends MessageEvent implements OrderMessageEventInterface { - constructor(params: { - client: Client; - data: { - order: Order; - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - }; - }); - // Warning: (ae-forgotten-export) The symbol "Order" needs to be exported by the entry point index.d.ts - // - // (undocumented) - order: Order; -} - -// @public -export interface OrderMessageEventInterface extends MessageEventInterface { - order: Order; -} - -// @public -export class PhoneNumberManager extends BaseManager implements PhoneNumberManagerInterface { - constructor(props: { - client: Client; - }); - sendVerificationCode(phoneNumber: string): Promise; - verifyCode(code: string): Promise; -} - -// @public -export interface PhoneNumberManagerInterface extends BaseManagerInterface { - sendVerificationCode: (phoneNumber: string) => Promise; - verifyCode: (code: string) => Promise; -} - -// @public -export class ProductInquiryEvent extends MessageEvent implements ProductInquiryEventInterface { - constructor(params: { - client: Client; - data: { - productId: string; - catalogId: string; - from: string; - id: string; - timestamp: string; - isForwarded: boolean; - text: string; - }; - }); - catalogId: string; - productId: string; - text: string; -} - -// @public -export interface ProductInquiryEventInterface extends MessageEventInterface { - catalogId: string; - productId: string; - text: string; -} - -// @public -export class ProductInteractionMessage extends InteractiveMessage implements ProductInteractionMessageInterface { - constructor(params: { - buttonText: string; - footerText?: string; - bodyText: string; - catalogId: string; - productRetailerId: string; - }); - addFooter(footerText: string): void; - addHeader(): void; - // (undocumented) - data: { - catalogId: string; - productRetailerId: string; - }; - toJson(params: { - to: string; - replyToMessageId?: string; - }): z.infer & { - interactive: z.infer; - }; -} - -// @public -export interface ProductInteractionMessageInterface extends InteractiveMessageInterface { - // (undocumented) - data: { - catalogId: string; - productRetailerId: string; - }; -} - -// @public -export class ProductListInteractionMessage extends InteractiveMessage implements ProductListInteractionMessageInterface { - constructor(params: { - buttonText: string; - footerText?: string; - bodyText: string; - catalogId: string; - productRetailerId: string; - sections: z.infer[]; - header: z.infer; - }); - addFooter(footerText: string): void; - addSection(section: z.infer): void; - // (undocumented) - data: { - catalogId: string; - productRetailerId: string; - sections: z.infer[]; - }; - toJson(params: { - to: string; - replyToMessageId?: string; - }): z.infer & { - interactive: z.infer; - }; -} - -// @public -export interface ProductListInteractionMessageInterface extends InteractiveMessageInterface { - // (undocumented) - data: { - catalogId: string; - productRetailerId: string; - sections: z.infer[]; - }; -} - -// @public -export class QuickReplyButtonInteractionEvent extends InteractionEvent implements QuickReplyButtonInteractionEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - buttonText: string; - buttonPayload: string; - }; - }); - // (undocumented) - button: { - text: string; - payload: string; - }; -} - -// @public -export interface QuickReplyButtonInteractionEventInterface extends InteractionMessageEventInterface { - // (undocumented) - button: { - text: string; - payload: string; - }; -} - -// @public -export class ReactionEvent extends MessageEvent implements ReactionEventInterface { - constructor(params: { - client: Client; - data: { - reaction: ReactionMessage; - from: string; - id: string; - timestamp: string; - isForwarded: boolean; - }; - }); - reaction: ReactionMessage; -} - -// @public -export interface ReactionEventInterface extends MessageEventInterface { - reaction: ReactionMessage; -} - -// @public -export class ReactionMessage extends BaseMessage implements ReactionMessageInterface { - constructor(params: { - messageId: string; - emoji: string; - }); - // (undocumented) - data: { - messageId: string; - emoji: string; - }; - toJson(params: { - to: string; - }): Extract, { - type: MessageTypeEnum.Reaction; - }>; -} - -// @public -export interface ReactionMessageInterface extends BaseMessageInterface { - // (undocumented) - data: { - messageId: string; - emoji: string; - }; -} - -// @public -export class ReplyButtonInteractionEvent extends InteractionEvent implements ButtonReplyInteractionMessageEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - messageId: string; - timestamp: string; - isForwarded: boolean; - title: string; - buttonId: string; - }; - }); - // (undocumented) - buttonId: string; - // (undocumented) - title: string; -} - -// @public -export abstract class StatusUpdateEvent extends BaseEvent implements StatusUpdateEventInterface { - constructor(params: { - client: Client; - from: string; - timestamp: string; - }); - // (undocumented) - context: MessageContext; - // (undocumented) - timestamp: number; -} - -// @public -export interface StatusUpdateEventInterface extends BaseEventInterface { - context: MessageContext; - timestamp: number; -} - -// @public -export class StickerMessage extends BaseMessage implements StickerMessageInterface { - constructor(params: z.infer); - // Warning: (ae-forgotten-export) The symbol "MetaStickerMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "ExternalStickerMediaObjectType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - data: z.infer; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: MessageTypeEnum.Sticker; - }>; -} - -// @public -export class StickerMessageEvent extends MediaMessageEvent implements StickerMessageEventInterface { - constructor(params: { - client: Client; - data: { - sticker: StickerMessage; - from: string; - messageId: string; - timestamp: string; - mediaId: string; - mimeType: string; - sha256: string; - isForwarded: boolean; - }; - }); - sticker: StickerMessage; -} - -// @public -export interface StickerMessageEventInterface extends MediaMessageEventInterface { - sticker: StickerMessage; -} - -// @public -export interface StickerMessageInterface extends BaseMessageInterface { - // (undocumented) - data: z.infer; -} - -// @public -export enum SystemNotificationTypeEnum { - // (undocumented) - CustomerIdentityChange = "customer_identity_changed", - // (undocumented) - CustomerNumberChange = "user_changed_number" -} - -// @public -export class TextMessage extends BaseMessage<"text"> implements TextMessageInterface { - constructor(params: { - text: string; - allowPreview?: true; - }); - // (undocumented) - readonly data: { - text: string; - allowPreview?: true; - }; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: "text"; - }>; -} - -// @public -export class TextMessageEvent extends MessageEvent implements TextMessageEventInterface { - constructor(params: { - client: Client; - data: { - from: string; - messageId: string; - text: TextMessage; - timestamp: string; - isForwarded: boolean; - }; - }); - text: TextMessage; -} - -// @public -export interface TextMessageEventInterface extends MessageEventInterface { - // (undocumented) - text: TextMessage; -} - -// @public -export interface TextMessageInterface extends BaseMessageInterface { - data: { - text: string | null; - }; - toJson: (params: { - to: string; - }) => Extract, { - type: "text"; - }>; -} - -// @public -export class UnknownEvent implements UnknownEventInterface { - constructor(params: { - code: string; - message: string; - title: string; - }); - code: string; - message: string; - title: string; -} - -// @public -export interface UnknownEventInterface { - code: string; - message: string; - title: string; -} - -// @public -export class VideoMessage extends BaseMessage implements VideoMessageInterface { - constructor(params: z.infer); - // Warning: (ae-forgotten-export) The symbol "MetaVideoMediaObjectSchemaType" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "ExternalVideoMediaObjectType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - data: z.infer; - toJson(params: { - to: string; - replyToMessageId?: string; - }): Extract, { - type: MessageTypeEnum.Video; - }>; -} - -// @public -export class VideoMessageEvent extends MediaMessageEvent implements VideoMessageEventInterface { - constructor(params: { - client: Client; - data: { - video: VideoMessage; - from: string; - messageId: string; - timestamp: string; - mediaId: string; - mimeType: string; - sha256: string; - isForwarded: boolean; - }; - }); - video: VideoMessage; -} - -// @public -export interface VideoMessageEventInterface extends MediaMessageEventInterface { - video: VideoMessage; -} - -// @public -export interface VideoMessageInterface extends BaseMessageInterface { - // (undocumented) - data: z.infer; -} - -// @public -export type WapiEventDataMap = { - TextMessage: TextMessageEvent; - AudioMessage: AudioMessageEvent; - AdInteraction: AdInteractionEvent; - ContactsMessage: ContactMessageEvent; - QuickReplyButtonInteraction: QuickReplyButtonInteractionEvent; - ReplyButtonInteraction: ReplyButtonInteractionEvent; - CustomerIdentityChanged: CustomerIdentityChangeEvent; - CustomerNumberChanged: CustomerNumberChangeEvent; - DocumentMessage: DocumentMessageEvent; - ImageMessage: ImageMessageEvent; - ListInteraction: ListInteractionEvent; - LocationMessage: LocationMessageEvent; - MessageDelivered: MessageDeliveryEvent; - MessageFailed: MessageFailedEvent; - MessageRead: MessageReadEvent; - MessageSent: MessageSentEvent; - MessageUndelivered: MessageUndeliveredEvent; - OrderReceived: OrderMessageEvent; - ProductInquiry: ProductInquiryEvent; - Reaction: ReactionEvent; - StickerMessage: StickerMessageEvent; - UnknownEvent: UnknownEvent; - VideoMessage: VideoMessageEvent; - ["Error"]: Error; - ["Warn"]: string; - ["Ready"]: null; -}; - -// Warning: (ae-forgotten-export) The symbol "WebhookInterface" needs to be exported by the entry point index.d.ts -// -// @public -export class Webhook extends EventEmitter_2 implements WebhookInterface { - constructor(params: { - client: Client; - webhookSecret: string; - webhookEndpoint: string; - port: number; - }); - getEndpoint(): string; - getPort(): number; - isListening(): boolean; - listen(cb: () => void): void; - _postRequestHandler(request: Request_2, response: Response_2): void; - setEndpoint(path: string): void; - setPort(port: number): void; -} - -// @public (undocumented) -export const WhatsappApiNotificationPayloadSchemaType: z.ZodObject<{ - object: z.ZodString; - entry: z.ZodArray; - contacts: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - wa_id: string; - profile: { - name: string; - }; - }, { - wa_id: string; - profile: { - name: string; - }; - }>, "many">>; - statuses: z.ZodOptional; - expiration_timestamp: z.ZodOptional>; - }, "strip", z.ZodTypeAny, { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }, { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }>; - }, "strip", z.ZodTypeAny, { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - }, { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - }>>; - errors: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }>, "many">>; - status: z.ZodNativeEnum; - timestamp: z.ZodString; - recipient_id: z.ZodString; - pricing: z.ZodOptional; - category: z.ZodNativeEnum; - }, "strip", z.ZodTypeAny, { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - }, { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - }>>; - }, "strip", z.ZodTypeAny, { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }, { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }>, "many">>; - messages: z.ZodOptional; - context: z.ZodOptional; - frequently_forwarded: z.ZodOptional; - from: z.ZodOptional; - id: z.ZodString; - referred_product: z.ZodOptional>; - }, "strip", z.ZodTypeAny, { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - }, { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - }>>; - errors: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }>, "many">>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - }, { - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - }>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{ - type: z.ZodLiteral; - audio: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - }, { - id: string; - mime_type: string; - sha256: string; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - }, { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - }>, z.ZodObject<{ - type: z.ZodLiteral; - text: z.ZodObject<{ - body: z.ZodString; - }, "strip", z.ZodTypeAny, { - body: string; - }, { - body: string; - }>; - referral: z.ZodOptional; - source_id: z.ZodString; - headline: z.ZodString; - body: z.ZodString; - image_url: z.ZodOptional; - video_url: z.ZodOptional; - thumbnail_url: z.ZodString; - ctwa_clid: z.ZodString; - media_type: z.ZodNativeEnum; - }, "strip", z.ZodTypeAny, { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - }, { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - }>>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - }, { - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - image: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - }, { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - button: z.ZodObject<{ - payload: z.ZodString; - text: z.ZodString; - }, "strip", z.ZodTypeAny, { - text: string; - payload: string; - }, { - text: string; - payload: string; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - }, { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - document: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - filename: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - }, { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - text: z.ZodString; - order: z.ZodObject<{ - catalog_id: z.ZodString; - product_items: z.ZodArray, "many">; - }, "strip", z.ZodTypeAny, { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }, { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - }, { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - sticker: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - animated: z.ZodBoolean; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }, { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - }, { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - system: z.ZodObject<{ - identity: z.ZodString; - body: z.ZodString; - customer: z.ZodString; - type: z.ZodNativeEnum; - wa_id: z.ZodString; - }, "strip", z.ZodTypeAny, { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }, { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }>; - identity: z.ZodObject<{ - acknowledged: z.ZodString; - created_timestamp: z.ZodString; - hash: z.ZodString; - }, "strip", z.ZodTypeAny, { - acknowledged: string; - created_timestamp: string; - hash: string; - }, { - acknowledged: string; - created_timestamp: string; - hash: string; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - }, { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - video: z.ZodObject<{ - id: z.ZodString; - mime_type: z.ZodString; - sha256: z.ZodString; - caption: z.ZodOptional; - filename: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }, { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - }, { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - interactive: z.ZodIntersection; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum; - }, { - type: InteractionNotificationTypeEnum; - }>, z.ZodUnion<[z.ZodObject<{ - type: z.ZodLiteral; - button_reply: z.ZodObject<{ - id: z.ZodString; - title: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - title: string; - }, { - id: string; - title: string; - }>; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - }, { - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - }>, z.ZodObject<{ - type: z.ZodLiteral; - list_reply: z.ZodObject<{ - id: z.ZodString; - title: z.ZodString; - description: z.ZodString; - }, "strip", z.ZodTypeAny, { - id: string; - title: string; - description: string; - }, { - id: string; - title: string; - description: string; - }>; - }, "strip", z.ZodTypeAny, { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }, { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }>]>>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - }, { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Unknown; - }, { - type: NotificationMessageTypeEnum.Unknown; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - location: z.ZodObject<{ - latitude: z.ZodNumber; - longitude: z.ZodNumber; - name: z.ZodOptional; - address: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }, { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - }, { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - reaction: z.ZodObject<{ - message_id: z.ZodString; - emoji: z.ZodString; - }, "strip", z.ZodTypeAny, { - message_id: string; - emoji: string; - }, { - message_id: string; - emoji: string; - }>; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - }, { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - }>]>, z.ZodObject<{ - type: z.ZodLiteral; - contacts: z.ZodArray, "many">; - }, "strip", z.ZodTypeAny, { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }, { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }>]>>, "many">>; - errors: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }, { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }>, "many">>; - }, "strip", z.ZodTypeAny, { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }, { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }>; - field: z.ZodLiteral<"messages">; - }, "strip", z.ZodTypeAny, { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }, { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }>, "many">; - }, "strip", z.ZodTypeAny, { - id: string; - changes: { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }[]; - }, { - id: string; - changes: { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }[]; - }>, "many">; -}, "strip", z.ZodTypeAny, { - object: string; - entry: { - id: string; - changes: { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }[]; - }[]; -}, { - object: string; - entry: { - id: string; - changes: { - value: { - messaging_product: string; - metadata: { - display_phone_number: string; - phone_number_id: string; - }; - messages?: ({ - type: NotificationMessageTypeEnum; - id: string; - from: string; - timestamp: string; - context?: { - id: string; - forwarded?: boolean | undefined; - frequently_forwarded?: boolean | undefined; - from?: string | undefined; - referred_product?: { - product_retailer_id: string; - catalog_id: string; - } | undefined; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - } & ({ - type: NotificationMessageTypeEnum.Text; - text: { - body: string; - }; - referral?: { - body: string; - source_url: string; - source_type: AdInteractionSourceTypeEnum; - source_id: string; - headline: string; - thumbnail_url: string; - ctwa_clid: string; - media_type: AdInteractionSourceMediaTypeEnum; - image_url?: string | undefined; - video_url?: string | undefined; - } | undefined; - } | { - type: NotificationMessageTypeEnum.Audio; - audio: { - id: string; - mime_type: string; - sha256: string; - }; - } | { - type: NotificationMessageTypeEnum.Image; - image: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Button; - button: { - text: string; - payload: string; - }; - } | { - type: NotificationMessageTypeEnum.Document; - document: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Order; - text: string; - order: { - product_items: { - currency: string; - product_retailer_id: string; - quantity: string; - item_price: string; - }[]; - catalog_id: string; - }; - } | { - type: NotificationMessageTypeEnum.Sticker; - sticker: { - id: string; - mime_type: string; - sha256: string; - animated: boolean; - }; - } | { - type: NotificationMessageTypeEnum.System; - system: { - type: SystemNotificationTypeEnum; - wa_id: string; - body: string; - identity: string; - customer: string; - }; - identity: { - acknowledged: string; - created_timestamp: string; - hash: string; - }; - } | { - type: NotificationMessageTypeEnum.Video; - video: { - id: string; - mime_type: string; - sha256: string; - caption?: string | undefined; - filename?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Reaction; - reaction: { - message_id: string; - emoji: string; - }; - } | { - type: NotificationMessageTypeEnum.Interactive; - interactive: { - type: InteractionNotificationTypeEnum; - } & ({ - type: InteractionNotificationTypeEnum.ButtonReply; - button_reply: { - id: string; - title: string; - }; - } | { - type: InteractionNotificationTypeEnum.ListReply; - list_reply: { - id: string; - title: string; - description: string; - }; - }); - } | { - type: NotificationMessageTypeEnum.Unknown; - } | { - type: NotificationMessageTypeEnum.Location; - location: { - latitude: number; - longitude: number; - name?: string | undefined; - address?: string | undefined; - }; - } | { - type: NotificationMessageTypeEnum.Contacts; - contacts: Contact[]; - }))[] | undefined; - contacts?: { - wa_id: string; - profile: { - name: string; - }; - }[] | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - statuses?: { - status: MessageStatusEnum; - timestamp: string; - recipient_id: string; - conversation?: { - id: string; - origin: { - type: MessageStatusCategoryEnum; - expiration_timestamp?: string | null | undefined; - }; - } | undefined; - errors?: { - code: number; - message: string; - error_data: { - details: string; - }; - title: string; - }[] | undefined; - pricing?: { - pricing_model: "CBP"; - category: MessageStatusCategoryEnum; - } | undefined; - }[] | undefined; - }; - field: "messages"; - }[]; - }[]; -}>; - -// Warnings were encountered during analysis: -// -// dist/esm/index.d.ts:370:9 - (ae-forgotten-export) The symbol "ButtonInteractiveMessagePayload" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:4539:9 - (ae-forgotten-export) The symbol "ListInteractiveMessageSection" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:4584:9 - (ae-forgotten-export) The symbol "ListInteractiveMessagePayload" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:6655:9 - (ae-forgotten-export) The symbol "ProductInteractiveMessagePayload" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:7000:9 - (ae-forgotten-export) The symbol "ProductListInteractiveMessageSection" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:7022:9 - (ae-forgotten-export) The symbol "InteractiveMessageHeaderSchemaType" needs to be exported by the entry point index.d.ts -// dist/esm/index.d.ts:7047:9 - (ae-forgotten-export) The symbol "ProductListInteractiveMessagePayload" needs to be exported by the entry point index.d.ts - -// (No @packageDocumentation comment for this package) - -``` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 102b91f..74728ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -406,7 +406,7 @@ importers: dependencies: '@microsoft/api-extractor': specifier: ^7.43.1 - version: 7.43.4(@types/node@20.12.12) + version: 7.43.4 express: specifier: ^4.18.2 version: 4.19.2 @@ -1065,6 +1065,16 @@ packages: react: 18.3.1 dev: false + /@microsoft/api-extractor-model@7.28.16: + resolution: {integrity: sha512-4/5gbW9zazr7hHHdv32QoCFDQl4vsrMOFp7g9k/uIQR2mn7AqQVN6NvNOAnFi1xwCM6X3K1BN1ZWf9ARF5hUmA==} + dependencies: + '@microsoft/tsdoc': 0.14.2 + '@microsoft/tsdoc-config': 0.16.2(patch_hash=fbrhds4pfv5d2ie5aolb6q2rxi) + '@rushstack/node-core-library': 4.2.1 + transitivePeerDependencies: + - '@types/node' + dev: false + /@microsoft/api-extractor-model@7.28.16(@types/node@20.12.12): resolution: {integrity: sha512-4/5gbW9zazr7hHHdv32QoCFDQl4vsrMOFp7g9k/uIQR2mn7AqQVN6NvNOAnFi1xwCM6X3K1BN1ZWf9ARF5hUmA==} dependencies: @@ -1074,6 +1084,27 @@ packages: transitivePeerDependencies: - '@types/node' + /@microsoft/api-extractor@7.43.4: + resolution: {integrity: sha512-HMzeVcTbzpiVvAUOnUVOxhPGPjOlPQQjiHVZy3fsXm6D5MUiEqX0OWEuupV8Ba3LM7h1Vk8xnNghlwpCkY73UA==} + hasBin: true + dependencies: + '@microsoft/api-extractor-model': 7.28.16 + '@microsoft/tsdoc': 0.14.2 + '@microsoft/tsdoc-config': 0.16.2(patch_hash=fbrhds4pfv5d2ie5aolb6q2rxi) + '@rushstack/node-core-library': 4.2.1 + '@rushstack/rig-package': 0.5.2 + '@rushstack/terminal': 0.10.3 + '@rushstack/ts-command-line': 4.19.5 + lodash: 4.17.21 + minimatch: 3.0.8 + resolve: 1.22.8 + semver: 7.5.4 + source-map: 0.6.1 + typescript: 5.4.2 + transitivePeerDependencies: + - '@types/node' + dev: false + /@microsoft/api-extractor@7.43.4(@types/node@20.12.12): resolution: {integrity: sha512-HMzeVcTbzpiVvAUOnUVOxhPGPjOlPQQjiHVZy3fsXm6D5MUiEqX0OWEuupV8Ba3LM7h1Vk8xnNghlwpCkY73UA==} hasBin: true @@ -1093,6 +1124,7 @@ packages: typescript: 5.4.2 transitivePeerDependencies: - '@types/node' + dev: true /@microsoft/tsdoc-config@0.16.2(patch_hash=fbrhds4pfv5d2ie5aolb6q2rxi): resolution: {integrity: sha512-OGiIzzoBLgWWR0UdRJX98oYO+XKGf7tiK4Zk6tQ/E4IJqGCe7dvkTvgDZV5cFJUzLGDOjeAXrnZoA6QkVySuxw==} @@ -1879,6 +1911,22 @@ packages: resolution: {integrity: sha512-hw437iINopmQuxWPSUEvqE56NCPsiU8N4AYtfHmJFckclktzK9YQJieD3XkDCDH4OjL+C7zgPUh73R/nrcHrqw==} dev: true + /@rushstack/node-core-library@4.2.1: + resolution: {integrity: sha512-jO8tR7ySxwy2c34QXSQDT9C22EfyisQruKT39FpipPOJAwKejug86eM+FL0QmkqbWGwpmfzkp3pyV71I5ZD9FA==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + dependencies: + fs-extra: 7.0.1 + import-lazy: 4.0.0 + jju: 1.4.0 + resolve: 1.22.8 + semver: 7.5.4 + z-schema: 5.0.5 + dev: false + /@rushstack/node-core-library@4.2.1(@types/node@20.12.12): resolution: {integrity: sha512-jO8tR7ySxwy2c34QXSQDT9C22EfyisQruKT39FpipPOJAwKejug86eM+FL0QmkqbWGwpmfzkp3pyV71I5ZD9FA==} peerDependencies: @@ -1901,6 +1949,18 @@ packages: resolve: 1.22.8 strip-json-comments: 3.1.1 + /@rushstack/terminal@0.10.3: + resolution: {integrity: sha512-4wEPvn9bTD4cixW+FQxlCtZmVIp73gUEAFutPXDo7Nik5bqmbP+fkZcd3Zjr+hOQyyu85d6+1R1DOPcchJX5ww==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + dependencies: + '@rushstack/node-core-library': 4.2.1 + supports-color: 8.1.1 + dev: false + /@rushstack/terminal@0.10.3(@types/node@20.12.12): resolution: {integrity: sha512-4wEPvn9bTD4cixW+FQxlCtZmVIp73gUEAFutPXDo7Nik5bqmbP+fkZcd3Zjr+hOQyyu85d6+1R1DOPcchJX5ww==} peerDependencies: @@ -1912,6 +1972,18 @@ packages: '@rushstack/node-core-library': 4.2.1(@types/node@20.12.12) '@types/node': 20.12.12 supports-color: 8.1.1 + dev: true + + /@rushstack/ts-command-line@4.19.5: + resolution: {integrity: sha512-0baDWdyMeB2LFHn1T8PKmy2rGclJoDruOjxwARrM4Oe66YjO9GfVZYwpM8ePdzJprWhkCnYLSxGUKJiWmUpapg==} + dependencies: + '@rushstack/terminal': 0.10.3 + '@types/argparse': 1.0.38 + argparse: 1.0.10 + string-argv: 0.3.2 + transitivePeerDependencies: + - '@types/node' + dev: false /@rushstack/ts-command-line@4.19.5(@types/node@20.12.12): resolution: {integrity: sha512-0baDWdyMeB2LFHn1T8PKmy2rGclJoDruOjxwARrM4Oe66YjO9GfVZYwpM8ePdzJprWhkCnYLSxGUKJiWmUpapg==} @@ -1922,6 +1994,7 @@ packages: string-argv: 0.3.2 transitivePeerDependencies: - '@types/node' + dev: true /@semantic-release/commit-analyzer@11.1.0(semantic-release@22.0.12): resolution: {integrity: sha512-cXNTbv3nXR2hlzHjAMgbuiQVtvWHTlwwISt60B+4NZv01y/QRY7p2HcJm8Eh2StzcTJoNnflvKjHH/cjFS7d5g==} @@ -3589,6 +3662,18 @@ packages: ms: 2.1.3 dev: true + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: true + /debug@4.3.4(supports-color@5.5.0): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -5845,7 +5930,7 @@ packages: dependencies: chalk: 5.3.0 commander: 11.0.0 - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.4 execa: 7.2.0 lilconfig: 2.1.0 listr2: 6.6.1