meta-cloud-api 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/base.d.mts +1 -1
- package/dist/api/base.d.ts +1 -1
- package/dist/api/businessProfile.d.mts +1 -1
- package/dist/api/businessProfile.d.ts +1 -1
- package/dist/api/encryption.d.mts +1 -1
- package/dist/api/encryption.d.ts +1 -1
- package/dist/api/flow.d.mts +1 -1
- package/dist/api/flow.d.ts +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/media.d.mts +1 -1
- package/dist/api/media.d.ts +1 -1
- package/dist/api/media.js +1 -1
- package/dist/api/media.mjs +1 -1
- package/dist/api/messages.d.mts +1 -1
- package/dist/api/messages.d.ts +1 -1
- package/dist/api/messages.js +1 -1
- package/dist/api/messages.js.map +1 -1
- package/dist/api/messages.mjs +1 -1
- package/dist/api/messages.mjs.map +1 -1
- package/dist/api/phoneNumber.d.mts +1 -1
- package/dist/api/phoneNumber.d.ts +1 -1
- package/dist/api/qrCode.d.mts +1 -1
- package/dist/api/qrCode.d.ts +1 -1
- package/dist/api/qrCode.js +1 -1
- package/dist/api/qrCode.mjs +1 -1
- package/dist/api/registration.d.mts +1 -1
- package/dist/api/registration.d.ts +1 -1
- package/dist/api/registration.js +1 -1
- package/dist/api/registration.mjs +1 -1
- package/dist/api/template.d.mts +1 -1
- package/dist/api/template.d.ts +1 -1
- package/dist/api/twoStepVerification.d.mts +1 -1
- package/dist/api/twoStepVerification.d.ts +1 -1
- package/dist/api/twoStepVerification.js +1 -1
- package/dist/api/twoStepVerification.mjs +1 -1
- package/dist/api/waba.d.mts +1 -1
- package/dist/api/waba.d.ts +1 -1
- package/dist/api/waba.js +1 -1
- package/dist/api/waba.mjs +1 -1
- package/dist/{enums-DLut7LZL.d.mts → enums-D7paGoTY.d.mts} +18 -18
- package/dist/{enums-DLut7LZL.d.ts → enums-D7paGoTY.d.ts} +18 -18
- package/dist/httpsClient.d.mts +1 -1
- package/dist/httpsClient.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/request.d.mts +1 -1
- package/dist/request.d.ts +1 -1
- package/dist/types/base.d.mts +1 -1
- package/dist/types/base.d.ts +1 -1
- package/dist/types/businessProfile.d.mts +1 -1
- package/dist/types/businessProfile.d.ts +1 -1
- package/dist/types/config.d.mts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/encryption.d.mts +1 -1
- package/dist/types/encryption.d.ts +1 -1
- package/dist/types/enums.d.mts +1 -1
- package/dist/types/enums.d.ts +1 -1
- package/dist/types/enums.js +1 -1
- package/dist/types/enums.js.map +1 -1
- package/dist/types/enums.mjs +1 -1
- package/dist/types/enums.mjs.map +1 -1
- package/dist/types/flow.d.mts +1 -1
- package/dist/types/flow.d.ts +1 -1
- package/dist/types/httpsClient.d.mts +1 -1
- package/dist/types/httpsClient.d.ts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/media.d.mts +1 -1
- package/dist/types/media.d.ts +1 -1
- package/dist/types/messages.d.mts +11 -6
- package/dist/types/messages.d.ts +11 -6
- package/dist/types/messages.js.map +1 -1
- package/dist/types/phoneNumber.d.mts +1 -1
- package/dist/types/phoneNumber.d.ts +1 -1
- package/dist/types/qrCode.d.mts +1 -1
- package/dist/types/qrCode.d.ts +1 -1
- package/dist/types/registration.d.mts +1 -1
- package/dist/types/registration.d.ts +1 -1
- package/dist/types/request.d.mts +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/template.d.mts +1 -1
- package/dist/types/template.d.ts +1 -1
- package/dist/types/twoStepVerification.d.mts +1 -1
- package/dist/types/twoStepVerification.d.ts +1 -1
- package/dist/types/waba.d.mts +1 -1
- package/dist/types/waba.d.ts +1 -1
- package/dist/types/whatsapp.d.mts +1 -1
- package/dist/types/whatsapp.d.ts +1 -1
- package/dist/utils/importConfig.d.mts +1 -1
- package/dist/utils/importConfig.d.ts +1 -1
- package/dist/utils/importConfig.js +1 -1
- package/dist/utils/importConfig.mjs +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/whatsapp.d.mts +1 -1
- package/dist/whatsapp.d.ts +1 -1
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/messages.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { BaseClass } from './base';\nimport {\n ButtonPositionEnum,\n ButtonTypesEnum,\n ComponentTypesEnum,\n CurrencyCodesEnum,\n InteractiveTypesEnum,\n LanguagesEnum,\n MessageTypesEnum,\n ParametersTypesEnum,\n} from './enums';\nimport { GeneralRequestBody, RequesterResponseInterface } from './request';\n\nexport type GeneralMessageBody = GeneralRequestBody & {\n /**\n * The Meta messaging product name.\n * @default 'whatsapp'\n */\n messaging_product: 'whatsapp';\n};\n\nexport type StatusObject = {\n status: 'read';\n message_id: string;\n typing_indicator?: TypingIndicatorObject;\n};\n\nexport type TypingIndicatorObject = {\n type: 'text';\n};\n\nexport type StatusRequestBody = GeneralMessageBody & StatusObject;\n\ntype ConTextObject = {\n message_id: string;\n};\n\nexport type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {\n recipient_type?: string;\n to: string;\n context?: ConTextObject;\n type?: T;\n};\n\ntype MetaAudioMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedAudioMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type AudioMediaObject = MetaAudioMediaObject | HostedAudioMediaObject;\n\nexport type AudioMessageRequestBody = MessageRequestBody<MessageTypesEnum.Audio> & {\n [MessageTypesEnum.Audio]: [AudioMediaObject];\n};\n\ntype AddressesObject = {\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype EmailObject = {\n email?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype NameObject = {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n};\n\ntype OrgObject = {\n company?: string;\n department?: string;\n title?: string;\n};\n\ntype PhoneObject = {\n phone?: 'PHONE_NUMBER';\n type?: 'CELL' | 'MAIN' | 'IPHONE' | 'HOME' | 'WORK' | string;\n wa_id?: string;\n};\n\ntype URLObject = {\n url?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\nexport type ContactObject = {\n addresses?: AddressesObject[];\n birthday?: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;\n emails?: EmailObject[];\n name: NameObject;\n org?: OrgObject;\n phones?: PhoneObject[];\n urls?: URLObject[];\n};\n\nexport type ContactsMessageRequestBody = MessageRequestBody<MessageTypesEnum.Contacts> & {\n [MessageTypesEnum.Contacts]: [ContactObject];\n};\n\ntype MetaDocumentMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n filename?: string;\n};\n\ntype HostedDocumentMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n filename?: string;\n};\n\nexport type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject;\n\nexport type DocumentMessageRequestBody = MessageRequestBody<MessageTypesEnum.Document> & {\n [MessageTypesEnum.Document]: [DocumentMediaObject];\n};\n\ntype MetaImageMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype HostedImageMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject;\n\nexport type ImageMessageRequestBody = MessageRequestBody<MessageTypesEnum.Image> & {\n [MessageTypesEnum.Image]: [ImageMediaObject];\n};\n\ntype ProductObject = {\n product_retailer_id: string;\n};\n\ntype SimpleTextObject = {\n text: string;\n};\n\ntype RowObject = {\n id: string;\n title: string;\n description?: string;\n};\n\ntype MultiProductSectionObject = {\n product_items: ProductObject[];\n rows?: never;\n title?: string;\n};\n\ntype ListSectionObject = {\n product_items?: never;\n rows: RowObject[];\n title?: string;\n};\n\ntype SectionObject = MultiProductSectionObject | ListSectionObject;\n\ntype ButtonObject = {\n title: string;\n id: string;\n};\n\ntype ReplyButtonObject = {\n type: 'reply';\n reply: ButtonObject;\n};\n\ntype ActionObject = {\n button?: string;\n buttons?: ReplyButtonObject[];\n catalog_id?: string;\n product_retailer_id?: string;\n sections?: SectionObject;\n};\n\ntype HeaderObject = {\n type: 'document' | 'image' | 'text' | 'video';\n document?: DocumentMediaObject;\n image?: ImageMediaObject;\n text?: string;\n video?: VideoMediaObject;\n};\n\ntype ButtonInteractiveObject = {\n type: InteractiveTypesEnum.Button;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ListInteractiveObject = {\n type: InteractiveTypesEnum.List;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductInteractiveObject = {\n type: InteractiveTypesEnum.Product;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductListInteractiveObject = {\n type: InteractiveTypesEnum.ProductList;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header: HeaderObject;\n action: ActionObject;\n};\n\ntype CtaUrlParameters = {\n display_text: string;\n url: string;\n};\n\ntype CtaUrlActionObject = {\n name: 'cta_url';\n parameters: CtaUrlParameters;\n};\n\ntype CtaUrlInteractiveObject = {\n type: InteractiveTypesEnum.CtaUrl;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: CtaUrlActionObject;\n};\n\ntype LocationRequestActionObject = {\n name: 'send_location';\n};\n\ntype LocationRequestInteractiveObject = {\n type: InteractiveTypesEnum.LocationRequest;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: LocationRequestActionObject;\n};\n\n// Address message types\ntype AddressValues = {\n name?: string;\n phone_number?: string;\n in_pin_code?: string;\n house_number?: string;\n floor_number?: string;\n tower_number?: string;\n building_name?: string;\n address?: string;\n landmark_area?: string;\n city?: string;\n state?: string;\n};\n\ntype SavedAddress = {\n id: string;\n value: AddressValues;\n};\n\ntype ValidationErrors = {\n [key in keyof AddressValues]?: string;\n};\n\ntype AddressMessageParameters = {\n country: string; // ISO country code, e.g., \"IN\" for India\n values?: AddressValues;\n saved_addresses?: SavedAddress[];\n validation_errors?: ValidationErrors;\n};\n\ntype AddressMessageActionObject = {\n name: 'address_message';\n parameters: AddressMessageParameters;\n};\n\ntype AddressMessageInteractiveObject = {\n type: InteractiveTypesEnum.AddressMessage;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: AddressMessageActionObject;\n};\n\n// Flow message types\ntype FlowParameters = {\n flow_token: string;\n flow_id?: string;\n flow_cta?: string;\n screen?: string;\n mode?: 'fullscreen' | 'drawer';\n data?: Record<string, string>;\n};\n\ntype FlowActionObject = {\n name: 'flow';\n parameters: FlowParameters;\n};\n\ntype FlowInteractiveObject = {\n type: InteractiveTypesEnum.Flow;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: FlowActionObject;\n};\n\n// Update InteractiveObject type\nexport type InteractiveObject =\n | ButtonInteractiveObject\n | ListInteractiveObject\n | ProductInteractiveObject\n | ProductListInteractiveObject\n | CtaUrlInteractiveObject\n | LocationRequestInteractiveObject\n | AddressMessageInteractiveObject\n | FlowInteractiveObject;\n\nexport type InteractiveMessageRequestBody = MessageRequestBody<MessageTypesEnum.Interactive> & {\n [MessageTypesEnum.Interactive]: InteractiveObject;\n};\n\ntype MetaStickerMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedStickerMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type StickerMediaObject = MetaStickerMediaObject | HostedStickerMediaObject;\n\nexport type StickerMessageRequestBody = MessageRequestBody<MessageTypesEnum.Sticker> & {\n [MessageTypesEnum.Sticker]: [StickerMediaObject];\n};\n\ntype ReActionObject = {\n message_id: string;\n emoji: string;\n};\n\nexport type ReactionMessageRequestBody = MessageRequestBody<MessageTypesEnum.Reaction> & ReActionObject;\n\nexport type TextObject = {\n body: string;\n preview_url?: boolean;\n};\n\nexport type TextMessageRequestBody = MessageRequestBody<MessageTypesEnum.Text> & {\n [MessageTypesEnum.Text]: [TextObject];\n};\n\ntype MetaHostedVideoMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype SelfHostedVideoMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type VideoMediaObject = MetaHostedVideoMediaObject | SelfHostedVideoMediaObject;\n\nexport type VideoMessageRequestBody = MessageRequestBody<MessageTypesEnum.Video> & {\n [MessageTypesEnum.Video]: [VideoMediaObject];\n};\n\ntype LanguageObject = {\n policy: 'deterministic';\n code: LanguagesEnum;\n};\n\ntype ParametersObject<T extends ParametersTypesEnum> = {\n type: T;\n};\n\ntype TextParametersObject = ParametersObject<ParametersTypesEnum.Text> & SimpleTextObject;\n\ntype CurrencyObject = {\n fallback_value: string;\n code: CurrencyCodesEnum;\n amount_1000: number;\n};\n\ntype CurrencyParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n currency: CurrencyObject;\n};\n\ntype DateTimeObject = {\n fallback_value: string;\n};\n\ntype DateTimeParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n date_time: DateTimeObject;\n};\n\ntype DocumentParametersObject = ParametersObject<ParametersTypesEnum.Document> & DocumentMediaObject;\n\ntype ImageParametersObject = ParametersObject<ParametersTypesEnum.Image> & ImageMediaObject;\n\ntype VideoParametersObject = ParametersObject<ParametersTypesEnum.Video> & VideoMediaObject;\n\ntype QuickReplyButtonParametersObject = {\n type: ParametersTypesEnum.Payload;\n payload: string;\n};\n\ntype URLButtonParametersObject = SimpleTextObject & {\n type: ParametersTypesEnum.Text;\n};\n\ntype ButtonParameterObject = QuickReplyButtonParametersObject | URLButtonParametersObject;\n\ntype ComponentObject<T extends ComponentTypesEnum> = {\n type: T;\n parameters: (\n | CurrencyParametersObject\n | DateTimeParametersObject\n | DocumentParametersObject\n | ImageParametersObject\n | TextParametersObject\n | VideoParametersObject\n )[];\n};\n\ntype ButtonComponentObject = ComponentObject<ComponentTypesEnum.Button> & {\n parameters: ButtonParameterObject;\n sub_type: ButtonTypesEnum;\n index: ButtonPositionEnum;\n};\n\nexport type MessageTemplateObject<T extends ComponentTypesEnum> = {\n name: string;\n language: LanguageObject;\n components?: (ComponentObject<T> | ButtonComponentObject)[];\n};\n\nexport type MessageTemplateRequestBody<T extends ComponentTypesEnum> = MessageRequestBody<MessageTypesEnum.Template> &\n MessageTemplateObject<T>;\n\nexport type LocationObject = {\n longitude: number;\n latitude: number;\n name?: string;\n address?: string;\n};\n\nexport type LocationMessageRequestBody = MessageRequestBody<MessageTypesEnum.Location> & {\n [MessageTypesEnum.Location]: [LocationObject];\n};\n\nexport type MessagesResponse = GeneralMessageBody & {\n contacts: [\n {\n input: string;\n wa_id: string;\n },\n ];\n messages: [\n {\n id: string;\n },\n ];\n};\n\n// Request parameter interface definitions\nexport interface MessageRequestParams<T> {\n body: T;\n to: string;\n replyMessageId?: string;\n}\n\nexport interface TextMessageParams extends MessageRequestParams<TextObject | string> {\n previewUrl?: boolean;\n}\n\nexport interface ReactionParams {\n messageId: string;\n emoji: string;\n to: string;\n}\n\nexport interface StatusParams {\n status: string;\n messageId: string;\n typingIndicator?: {\n type: string;\n };\n}\n\nexport declare class MessagesClass extends BaseClass {\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n audio(params: MessageRequestParams<AudioMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n contacts(params: MessageRequestParams<[ContactObject]>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n document(params: MessageRequestParams<DocumentMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n image(params: MessageRequestParams<ImageMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n interactive(params: MessageRequestParams<InteractiveObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n location(params: MessageRequestParams<LocationObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param params The status update parameter object\n * @returns Promise with the response\n */\n status(params: StatusParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n sticker(params: MessageRequestParams<StickerMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n template(\n params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n text(params: TextMessageParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a video via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n video(params: MessageRequestParams<VideoMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n // New methods\n /**\n * Marks a message as read in WhatsApp\n * @param params The parameter object to mark message as read\n * @returns Promise with the response\n */\n markAsRead(params: { messageId: string }): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param params The typing indicator parameter object\n * @returns Promise with the response\n */\n showTypingIndicator(params: { messageId: string }): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive list message\n * @param params The list message parameter object\n * @returns Promise with the response\n */\n interactiveList(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive CTA URL message\n * @param params The CTA URL message parameter object\n * @returns Promise with the response\n */\n interactiveCtaUrl(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a location request message\n * @param params The location request message parameter object\n * @returns Promise with the response\n */\n interactiveLocationRequest(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param params The address message parameter object\n * @returns Promise with the response\n */\n interactiveAddressMessage(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive reply buttons message\n * @param params The reply buttons message parameter object\n * @returns Promise with the response\n */\n interactiveReplyButtons(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param params The reaction message parameter object\n * @returns Promise with the response\n */\n reaction(params: ReactionParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive Flow message\n * @param params The Flow message parameter object\n * @returns Promise with the response\n */\n interactiveFlow(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["messages_exports","__toCommonJS"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/messages.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { BaseClass } from './base';\nimport {\n ButtonPositionEnum,\n ButtonTypesEnum,\n ComponentTypesEnum,\n CurrencyCodesEnum,\n InteractiveTypesEnum,\n LanguagesEnum,\n MessageTypesEnum,\n ParametersTypesEnum,\n} from './enums';\nimport { GeneralRequestBody, RequesterResponseInterface } from './request';\n\nexport type GeneralMessageBody = GeneralRequestBody & {\n /**\n * The Meta messaging product name.\n * @default 'whatsapp'\n */\n messaging_product: 'whatsapp';\n};\n\nexport type StatusObject = {\n status: 'read';\n message_id: string;\n typing_indicator?: TypingIndicatorObject;\n};\n\nexport type TypingIndicatorObject = {\n type: 'text';\n};\n\nexport type StatusRequestBody = GeneralMessageBody & StatusObject;\n\ntype ConTextObject = {\n message_id: string;\n};\n\nexport type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {\n recipient_type?: string;\n to: string;\n context?: ConTextObject;\n type?: T;\n};\n\ntype MetaAudioMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedAudioMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type AudioMediaObject = MetaAudioMediaObject | HostedAudioMediaObject;\n\nexport type AudioMessageRequestBody = MessageRequestBody<MessageTypesEnum.Audio> & {\n [MessageTypesEnum.Audio]: [AudioMediaObject];\n};\n\ntype AddressesObject = {\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype EmailObject = {\n email?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype NameObject = {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n};\n\ntype OrgObject = {\n company?: string;\n department?: string;\n title?: string;\n};\n\ntype PhoneObject = {\n phone?: 'PHONE_NUMBER';\n type?: 'CELL' | 'MAIN' | 'IPHONE' | 'HOME' | 'WORK' | string;\n wa_id?: string;\n};\n\ntype URLObject = {\n url?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\nexport type ContactObject = {\n addresses?: AddressesObject[];\n birthday?: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;\n emails?: EmailObject[];\n name: NameObject;\n org?: OrgObject;\n phones?: PhoneObject[];\n urls?: URLObject[];\n};\n\nexport type ContactsMessageRequestBody = MessageRequestBody<MessageTypesEnum.Contacts> & {\n [MessageTypesEnum.Contacts]: [ContactObject];\n};\n\ntype MetaDocumentMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n filename?: string;\n};\n\ntype HostedDocumentMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n filename?: string;\n};\n\nexport type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject;\n\nexport type DocumentMessageRequestBody = MessageRequestBody<MessageTypesEnum.Document> & {\n [MessageTypesEnum.Document]: [DocumentMediaObject];\n};\n\ntype MetaImageMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype HostedImageMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject;\n\nexport type ImageMessageRequestBody = MessageRequestBody<MessageTypesEnum.Image> & {\n [MessageTypesEnum.Image]: [ImageMediaObject];\n};\n\ntype ProductObject = {\n product_retailer_id: string;\n};\n\ntype SimpleTextObject = {\n text: string;\n};\n\ntype RowObject = {\n id: string;\n title: string;\n description?: string;\n};\n\ntype MultiProductSectionObject = {\n product_items: ProductObject[];\n rows?: never;\n title?: string;\n};\n\ntype ListSectionObject = {\n product_items?: never;\n rows: RowObject[];\n title?: string;\n};\n\ntype SectionObject = MultiProductSectionObject | ListSectionObject;\n\ntype ButtonObject = {\n title: string;\n id: string;\n};\n\ntype ReplyButtonObject = {\n type: 'reply';\n reply: ButtonObject;\n};\n\ntype ActionObject = {\n button?: string;\n buttons?: ReplyButtonObject[];\n catalog_id?: string;\n product_retailer_id?: string;\n sections?: SectionObject;\n};\n\ntype HeaderObject = {\n type: 'document' | 'image' | 'text' | 'video';\n document?: DocumentMediaObject;\n image?: ImageMediaObject;\n text?: string;\n video?: VideoMediaObject;\n};\n\ntype ButtonInteractiveObject = {\n type: InteractiveTypesEnum.Button;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ListInteractiveObject = {\n type: InteractiveTypesEnum.List;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductInteractiveObject = {\n type: InteractiveTypesEnum.Product;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductListInteractiveObject = {\n type: InteractiveTypesEnum.ProductList;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header: HeaderObject;\n action: ActionObject;\n};\n\ntype CtaUrlParameters = {\n display_text: string;\n url: string;\n};\n\ntype CtaUrlActionObject = {\n name: 'cta_url';\n parameters: CtaUrlParameters;\n};\n\ntype CtaUrlInteractiveObject = {\n type: InteractiveTypesEnum.CtaUrl;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: CtaUrlActionObject;\n};\n\ntype LocationRequestActionObject = {\n name: 'send_location';\n};\n\ntype LocationRequestInteractiveObject = {\n type: InteractiveTypesEnum.LocationRequest;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: LocationRequestActionObject;\n};\n\n// Address message types\ntype AddressValues = {\n name?: string;\n phone_number?: string;\n in_pin_code?: string;\n house_number?: string;\n floor_number?: string;\n tower_number?: string;\n building_name?: string;\n address?: string;\n landmark_area?: string;\n city?: string;\n state?: string;\n};\n\ntype SavedAddress = {\n id: string;\n value: AddressValues;\n};\n\ntype ValidationErrors = {\n [key in keyof AddressValues]?: string;\n};\n\ntype AddressMessageParameters = {\n country: string; // ISO country code, e.g., \"IN\" for India\n values?: AddressValues;\n saved_addresses?: SavedAddress[];\n validation_errors?: ValidationErrors;\n};\n\ntype AddressMessageActionObject = {\n name: 'address_message';\n parameters: AddressMessageParameters;\n};\n\ntype AddressMessageInteractiveObject = {\n type: InteractiveTypesEnum.AddressMessage;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: AddressMessageActionObject;\n};\n\ntype FlowParameters = {\n flow_message_version: string;\n flow_id?: string;\n flow_name?: string;\n flow_cta: string;\n mode?: 'draft' | 'published';\n flow_token: string;\n flow_action: 'navigate' | 'data_exchange';\n flow_action_payload?: {\n screen?: string;\n data?: Record<string, string>;\n };\n};\n\ntype FlowActionObject = {\n name: 'flow';\n parameters: FlowParameters;\n};\n\ntype FlowInteractiveObject = {\n type: InteractiveTypesEnum.Flow;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: FlowActionObject;\n};\n\n// Update InteractiveObject type\nexport type InteractiveObject =\n | ButtonInteractiveObject\n | ListInteractiveObject\n | ProductInteractiveObject\n | ProductListInteractiveObject\n | CtaUrlInteractiveObject\n | LocationRequestInteractiveObject\n | AddressMessageInteractiveObject\n | FlowInteractiveObject;\n\nexport type InteractiveMessageRequestBody = MessageRequestBody<MessageTypesEnum.Interactive> & {\n [MessageTypesEnum.Interactive]: InteractiveObject;\n};\n\ntype MetaStickerMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedStickerMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type StickerMediaObject = MetaStickerMediaObject | HostedStickerMediaObject;\n\nexport type StickerMessageRequestBody = MessageRequestBody<MessageTypesEnum.Sticker> & {\n [MessageTypesEnum.Sticker]: [StickerMediaObject];\n};\n\ntype ReActionObject = {\n message_id: string;\n emoji: string;\n};\n\nexport type ReactionMessageRequestBody = MessageRequestBody<MessageTypesEnum.Reaction> & ReActionObject;\n\nexport type TextObject = {\n body: string;\n preview_url?: boolean;\n};\n\nexport type TextMessageRequestBody = MessageRequestBody<MessageTypesEnum.Text> & {\n [MessageTypesEnum.Text]: [TextObject];\n};\n\ntype MetaHostedVideoMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype SelfHostedVideoMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type VideoMediaObject = MetaHostedVideoMediaObject | SelfHostedVideoMediaObject;\n\nexport type VideoMessageRequestBody = MessageRequestBody<MessageTypesEnum.Video> & {\n [MessageTypesEnum.Video]: [VideoMediaObject];\n};\n\ntype LanguageObject = {\n policy: 'deterministic';\n code: LanguagesEnum;\n};\n\ntype ParametersObject<T extends ParametersTypesEnum> = {\n type: T;\n};\n\ntype TextParametersObject = ParametersObject<ParametersTypesEnum.Text> & SimpleTextObject;\n\ntype CurrencyObject = {\n fallback_value: string;\n code: CurrencyCodesEnum;\n amount_1000: number;\n};\n\ntype CurrencyParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n currency: CurrencyObject;\n};\n\ntype DateTimeObject = {\n fallback_value: string;\n};\n\ntype DateTimeParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n date_time: DateTimeObject;\n};\n\ntype DocumentParametersObject = ParametersObject<ParametersTypesEnum.Document> & DocumentMediaObject;\n\ntype ImageParametersObject = ParametersObject<ParametersTypesEnum.Image> & ImageMediaObject;\n\ntype VideoParametersObject = ParametersObject<ParametersTypesEnum.Video> & VideoMediaObject;\n\ntype QuickReplyButtonParametersObject = {\n type: ParametersTypesEnum.Payload;\n payload: string;\n};\n\ntype URLButtonParametersObject = SimpleTextObject & {\n type: ParametersTypesEnum.Text;\n};\n\ntype ButtonParameterObject = QuickReplyButtonParametersObject | URLButtonParametersObject;\n\ntype ComponentObject<T extends ComponentTypesEnum> = {\n type: T;\n parameters: (\n | CurrencyParametersObject\n | DateTimeParametersObject\n | DocumentParametersObject\n | ImageParametersObject\n | TextParametersObject\n | VideoParametersObject\n )[];\n};\n\ntype ButtonComponentObject = ComponentObject<ComponentTypesEnum.Button> & {\n parameters: ButtonParameterObject;\n sub_type: ButtonTypesEnum;\n index: ButtonPositionEnum;\n};\n\nexport type MessageTemplateObject<T extends ComponentTypesEnum> = {\n name: string;\n language: LanguageObject;\n components?: (ComponentObject<T> | ButtonComponentObject)[];\n};\n\nexport type MessageTemplateRequestBody<T extends ComponentTypesEnum> = MessageRequestBody<MessageTypesEnum.Template> &\n MessageTemplateObject<T>;\n\nexport type LocationObject = {\n longitude: number;\n latitude: number;\n name?: string;\n address?: string;\n};\n\nexport type LocationMessageRequestBody = MessageRequestBody<MessageTypesEnum.Location> & {\n [MessageTypesEnum.Location]: [LocationObject];\n};\n\nexport type MessagesResponse = GeneralMessageBody & {\n contacts: [\n {\n input: string;\n wa_id: string;\n },\n ];\n messages: [\n {\n id: string;\n },\n ];\n};\n\n// Request parameter interface definitions\nexport interface MessageRequestParams<T> {\n body: T;\n to: string;\n replyMessageId?: string;\n}\n\nexport interface TextMessageParams extends MessageRequestParams<TextObject | string> {\n previewUrl?: boolean;\n}\n\nexport interface ReactionParams {\n messageId: string;\n emoji: string;\n to: string;\n}\n\nexport interface StatusParams {\n status: string;\n messageId: string;\n typingIndicator?: {\n type: string;\n };\n}\n\nexport declare class MessagesClass extends BaseClass {\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n audio(params: MessageRequestParams<AudioMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n contacts(params: MessageRequestParams<[ContactObject]>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n document(params: MessageRequestParams<DocumentMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n image(params: MessageRequestParams<ImageMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n interactive(params: MessageRequestParams<InteractiveObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n location(params: MessageRequestParams<LocationObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param params The status update parameter object\n * @returns Promise with the response\n */\n status(params: StatusParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n sticker(params: MessageRequestParams<StickerMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n template(\n params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n text(params: TextMessageParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a video via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n video(params: MessageRequestParams<VideoMediaObject>): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n // New methods\n /**\n * Marks a message as read in WhatsApp\n * @param params The parameter object to mark message as read\n * @returns Promise with the response\n */\n markAsRead(params: { messageId: string }): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param params The typing indicator parameter object\n * @returns Promise with the response\n */\n showTypingIndicator(params: { messageId: string }): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive list message\n * @param params The list message parameter object\n * @returns Promise with the response\n */\n interactiveList(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive CTA URL message\n * @param params The CTA URL message parameter object\n * @returns Promise with the response\n */\n interactiveCtaUrl(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a location request message\n * @param params The location request message parameter object\n * @returns Promise with the response\n */\n interactiveLocationRequest(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param params The address message parameter object\n * @returns Promise with the response\n */\n interactiveAddressMessage(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive reply buttons message\n * @param params The reply buttons message parameter object\n * @returns Promise with the response\n */\n interactiveReplyButtons(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param params The reaction message parameter object\n * @returns Promise with the response\n */\n reaction(params: ReactionParams): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n /**\n * Sends an interactive Flow message\n * @param params The Flow message parameter object\n * @returns Promise with the response\n */\n interactiveFlow(\n params: MessageRequestParams<InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["messages_exports","__toCommonJS"]}
|
package/dist/types/qrCode.d.mts
CHANGED
package/dist/types/qrCode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequesterResponseInterface, ResponseSuccess } from './request.mjs';
|
|
2
|
-
import { j as DataLocalizationRegionEnum } from '../enums-
|
|
2
|
+
import { j as DataLocalizationRegionEnum } from '../enums-D7paGoTY.mjs';
|
|
3
3
|
|
|
4
4
|
type RegistrationRequest = {
|
|
5
5
|
messaging_product: 'whatsapp';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequesterResponseInterface, ResponseSuccess } from './request.js';
|
|
2
|
-
import { j as DataLocalizationRegionEnum } from '../enums-
|
|
2
|
+
import { j as DataLocalizationRegionEnum } from '../enums-D7paGoTY.js';
|
|
3
3
|
|
|
4
4
|
type RegistrationRequest = {
|
|
5
5
|
messaging_product: 'whatsapp';
|
package/dist/types/request.d.mts
CHANGED
package/dist/types/request.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D7paGoTY.mjs';
|
|
2
2
|
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.mjs';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
package/dist/types/template.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D7paGoTY.js';
|
|
2
2
|
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.js';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
package/dist/types/waba.d.mts
CHANGED
package/dist/types/waba.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { RegistrationClass } from './registration.mjs';
|
|
|
9
9
|
import { TemplateClass } from './template.mjs';
|
|
10
10
|
import { TwoStepVerificationClass } from './twoStepVerification.mjs';
|
|
11
11
|
import { WABAClass } from './waba.mjs';
|
|
12
|
-
import '../enums-
|
|
12
|
+
import '../enums-D7paGoTY.mjs';
|
|
13
13
|
import './request.mjs';
|
|
14
14
|
import './base.mjs';
|
|
15
15
|
import './config.mjs';
|
package/dist/types/whatsapp.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { RegistrationClass } from './registration.js';
|
|
|
9
9
|
import { TemplateClass } from './template.js';
|
|
10
10
|
import { TwoStepVerificationClass } from './twoStepVerification.js';
|
|
11
11
|
import { WABAClass } from './waba.js';
|
|
12
|
-
import '../enums-
|
|
12
|
+
import '../enums-D7paGoTY.js';
|
|
13
13
|
import './request.js';
|
|
14
14
|
import './base.js';
|
|
15
15
|
import './config.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WhatsAppConfig } from '../types/whatsapp.mjs';
|
|
2
2
|
import { WabaConfigType } from '../types/config.mjs';
|
|
3
3
|
import '../types/businessProfile.mjs';
|
|
4
|
-
import '../enums-
|
|
4
|
+
import '../enums-D7paGoTY.mjs';
|
|
5
5
|
import '../types/request.mjs';
|
|
6
6
|
import '../types/encryption.mjs';
|
|
7
7
|
import '../types/flow.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WhatsAppConfig } from '../types/whatsapp.js';
|
|
2
2
|
import { WabaConfigType } from '../types/config.js';
|
|
3
3
|
import '../types/businessProfile.js';
|
|
4
|
-
import '../enums-
|
|
4
|
+
import '../enums-D7paGoTY.js';
|
|
5
5
|
import '../types/request.js';
|
|
6
6
|
import '../types/encryption.js';
|
|
7
7
|
import '../types/flow.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var G=(S,A)=>{for(var R in A)N(S,R,{get:A[R],enumerable:!0})},T=(S,A,R,U)=>{if(A&&typeof A=="object"||typeof A=="function")for(let D of t(A))!B.call(S,D)&&D!==R&&N(S,D,{get:()=>A[D],enumerable:!(U=O(A,D))||U.enumerable});return S};var _=S=>T(N({},"__esModule",{value:!0}),S);var Y={};G(Y,{importConfig:()=>X});module.exports=_(Y);var P=class{name;debug;constructor(A,R=!1){this.name=A,this.debug=R}log(...A){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...A])}}error(...A){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...A])}warn(...A){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...A])}info(...A){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...A])}};var K="UTILS",M=!1,I=new P(K,process.env.DEBUG==="true"||M),i="graph.facebook.com",p=3e3,F=30,H=2e4,L=S=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!S?.accessToken)throw I.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},X=S=>{L(S);let A={WA_BASE_URL:process.env.WA_BASE_URL||i,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:S?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:S?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:S?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||p,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||F,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||H,DEBUG:process.env.DEBUG==="true"};return I.log(`Configuration loaded for App Id ${A.M4D_APP_ID}`),A};0&&(module.exports={importConfig});
|
|
2
2
|
//# sourceMappingURL=importConfig.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var D=class{name;debug;constructor(R,A=!1){this.name=R,this.debug=A}log(...R){if(this.debug){let A=`[ ${Date.now()} ]`;this.name&&(A+=` - ${this.name}`),console.log.apply(console,[A,": ",...R])}}error(...R){let A=`[ ${Date.now()} ] - ERROR`;this.name&&(A+=` - ${this.name}`),console.error.apply(console,[A,": ",...R])}warn(...R){let A=`[ ${Date.now()} ] - WARN`;this.name&&(A+=` - ${this.name}`),console.warn.apply(console,[A,": ",...R])}info(...R){let A=`[ ${Date.now()} ] - INFO`;this.name&&(A+=` - ${this.name}`),console.info.apply(console,[A,": ",...R])}};var N="UTILS",
|
|
1
|
+
var D=class{name;debug;constructor(R,A=!1){this.name=R,this.debug=A}log(...R){if(this.debug){let A=`[ ${Date.now()} ]`;this.name&&(A+=` - ${this.name}`),console.log.apply(console,[A,": ",...R])}}error(...R){let A=`[ ${Date.now()} ] - ERROR`;this.name&&(A+=` - ${this.name}`),console.error.apply(console,[A,": ",...R])}warn(...R){let A=`[ ${Date.now()} ] - WARN`;this.name&&(A+=` - ${this.name}`),console.warn.apply(console,[A,": ",...R])}info(...R){let A=`[ ${Date.now()} ] - INFO`;this.name&&(A+=` - ${this.name}`),console.info.apply(console,[A,": ",...R])}};var N="UTILS",U=!1,P=new D(N,process.env.DEBUG==="true"||U),I="graph.facebook.com",O=3e3,t=30,B=2e4,G=S=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!S?.accessToken)throw P.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},p=S=>{G(S);let R={WA_BASE_URL:process.env.WA_BASE_URL||I,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:S?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:S?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:S?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||O,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||t,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||B,DEBUG:process.env.DEBUG==="true"};return P.log(`Configuration loaded for App Id ${R.M4D_APP_ID}`),R};export{p as importConfig};
|
|
2
2
|
//# sourceMappingURL=importConfig.mjs.map
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ export { MetaError, isMetaError } from './isMetaError.mjs';
|
|
|
4
4
|
export { objectToQueryString } from './objectToQueryString.mjs';
|
|
5
5
|
import '../types/whatsapp.mjs';
|
|
6
6
|
import '../types/businessProfile.mjs';
|
|
7
|
-
import '../enums-
|
|
7
|
+
import '../enums-D7paGoTY.mjs';
|
|
8
8
|
import '../types/request.mjs';
|
|
9
9
|
import '../types/encryption.mjs';
|
|
10
10
|
import '../types/flow.mjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { MetaError, isMetaError } from './isMetaError.js';
|
|
|
4
4
|
export { objectToQueryString } from './objectToQueryString.js';
|
|
5
5
|
import '../types/whatsapp.js';
|
|
6
6
|
import '../types/businessProfile.js';
|
|
7
|
-
import '../enums-
|
|
7
|
+
import '../enums-D7paGoTY.js';
|
|
8
8
|
import '../types/request.js';
|
|
9
9
|
import '../types/encryption.js';
|
|
10
10
|
import '../types/flow.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.create;var N=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var p=(t
|
|
1
|
+
"use strict";var i=Object.create;var N=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var p=(A,t)=>{for(var R in t)N(A,R,{get:t[R],enumerable:!0})},U=(A,t,R,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of T(t))!G.call(A,S)&&S!==R&&N(A,S,{get:()=>t[S],enumerable:!(P=I(t,S))||P.enumerable});return A};var K=(A,t,R)=>(R=A!=null?i(B(A)):{},U(t||!A||!A.__esModule?N(R,"default",{value:A,enumerable:!0}):R,A)),M=A=>U(N({},"__esModule",{value:!0}),A);var v={};p(v,{generateXHub256Sig:()=>F,importConfig:()=>h,isMetaError:()=>Z,objectToQueryString:()=>W});module.exports=M(v);var _=K(require("crypto")),F=(A,t)=>_.createHmac("sha256",t).update(A,"utf-8").digest("hex");var D=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var H="UTILS",L=!1,O=new D(H,process.env.DEBUG==="true"||L),f="graph.facebook.com",l=3e3,X=30,Y=2e4,x=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw O.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},h=A=>{x(A);let t={WA_BASE_URL:process.env.WA_BASE_URL||f,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:A?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:A?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||l,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||X,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Y,DEBUG:process.env.DEBUG==="true"};return O.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};function Z(A){return A!=null&&typeof A=="object"&&"error"in A&&typeof A.error=="object"&&A.error!=null&&"message"in A.error&&typeof A.error.message=="string"&&"type"in A.error&&typeof A.error.type=="string"&&"code"in A.error&&typeof A.error.code=="number"&&"fbtrace_id"in A.error&&typeof A.error.fbtrace_id=="string"&&(!("error_data"in A.error)||typeof A.error.error_data=="object"&&A.error.error_data!=null&&"messaging_product"in A.error.error_data&&A.error.error_data.messaging_product==="whatsapp"&&"details"in A.error.error_data&&typeof A.error.error_data.details=="string")&&(!("error_subcode"in A.error)||typeof A.error.error_subcode=="number")}var W=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[P,S]of Object.entries(A))S!==void 0&&t.append(P,String(S));let R=t.toString();return R?`?${R}`:""};0&&(module.exports={generateXHub256Sig,importConfig,isMetaError,objectToQueryString});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as P from"crypto";var p=(t
|
|
1
|
+
import*as P from"crypto";var p=(A,t)=>P.createHmac("sha256",t).update(A,"utf-8").digest("hex");var S=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var _="UTILS",O=!1,N=new S(_,process.env.DEBUG==="true"||O),i="graph.facebook.com",I=3e3,T=30,B=2e4,G=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw N.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},l=A=>{G(A);let t={WA_BASE_URL:process.env.WA_BASE_URL||i,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:A?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:A?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||I,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||T,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||B,DEBUG:process.env.DEBUG==="true"};return N.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};function Y(A){return A!=null&&typeof A=="object"&&"error"in A&&typeof A.error=="object"&&A.error!=null&&"message"in A.error&&typeof A.error.message=="string"&&"type"in A.error&&typeof A.error.type=="string"&&"code"in A.error&&typeof A.error.code=="number"&&"fbtrace_id"in A.error&&typeof A.error.fbtrace_id=="string"&&(!("error_data"in A.error)||typeof A.error.error_data=="object"&&A.error.error_data!=null&&"messaging_product"in A.error.error_data&&A.error.error_data.messaging_product==="whatsapp"&&"details"in A.error.error_data&&typeof A.error.error_data.details=="string")&&(!("error_subcode"in A.error)||typeof A.error.error_subcode=="number")}var h=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[U,D]of Object.entries(A))D!==void 0&&t.append(U,String(D));let R=t.toString();return R?`?${R}`:""};export{p as generateXHub256Sig,l as importConfig,Y as isMetaError,h as objectToQueryString};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/whatsapp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WabaConfigType } from './types/config.mjs';
|
|
2
|
-
import { l as SDKEnums } from './enums-
|
|
2
|
+
import { l as SDKEnums } from './enums-D7paGoTY.mjs';
|
|
3
3
|
import BusinessProfileAPI from './api/businessProfile.mjs';
|
|
4
4
|
import EncryptionAPI from './api/encryption.mjs';
|
|
5
5
|
import FlowAPI from './api/flow.mjs';
|
package/dist/whatsapp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WabaConfigType } from './types/config.js';
|
|
2
|
-
import { l as SDKEnums } from './enums-
|
|
2
|
+
import { l as SDKEnums } from './enums-D7paGoTY.js';
|
|
3
3
|
import BusinessProfileAPI from './api/businessProfile.js';
|
|
4
4
|
import EncryptionAPI from './api/encryption.js';
|
|
5
5
|
import FlowAPI from './api/flow.js';
|
package/dist/whatsapp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var W=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var $=(a,t)=>{for(var s in t)W(a,s,{get:t[s],enumerable:!0})},Ie=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of he(t))!Pe.call(a,o)&&o!==s&&W(a,o,{get:()=>t[o],enumerable:!(i=ge(t,o))||i.enumerable});return a};var de=a=>Ie(W({},"__esModule",{value:!0}),a);var $e={};$($e,{default:()=>L});module.exports=de($e);var x={};$(x,{AudioMediaTypesEnum:()=>ee,BusinessVerticalEnum:()=>pe,ButtonPositionEnum:()=>V,ButtonTypesEnum:()=>k,CategoryEnum:()=>J,ComponentTypesEnum:()=>Z,ConversationTypesEnum:()=>y,CurrencyCodesEnum:()=>ae,DataLocalizationRegionEnum:()=>ne,DocumentMediaTypesEnum:()=>C,HttpMethodsEnum:()=>I,ImageMediaTypesEnum:()=>E,InteractiveTypesEnum:()=>Y,LanguagesEnum:()=>re,MessageTypesEnum:()=>K,ParametersTypesEnum:()=>j,ReferralSourceTypesEnum:()=>ie,RequestCodeMethodsEnum:()=>oe,StatusEnum:()=>Q,StickerMediaTypesEnum:()=>u,SystemChangeTypesEnum:()=>se,TemplateStatusEnum:()=>X,VideoMediaTypesEnum:()=>z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>te});var J=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(J||{}),X=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(X||{}),I=(o=>(o.Get="GET",o.Post="POST",o.Put="PUT",o.Delete="DELETE",o))(I||{}),K=(l=>(l.Audio="audio",l.Contacts="contacts",l.Document="document",l.Image="image",l.Interactive="interactive",l.Location="location",l.Reaction="sticker",l.Sticker="sticker",l.Template="template",l.Text="text",l.Video="video",l))(K||{}),j=(f=>(f.Currency="currency",f.DateTime="date_time",f.Document="document",f.Image="image",f.Text="text",f.Video="video",f.Payload="payload",f))(j||{}),Y=(R=>(R.Button="button",R.List="list",R.Product="product",R.ProductList="product_list",R.CtaUrl="cta_url",R.LocationRequest="location_request_message",R.AddressMessage="address_message",R.Flow="flow",R))(Y||{}),k=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(k||{}),V=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(V||{}),Z=(o=>(o.Header="HEADER",o.Body="BODY",o.Button="BUTTON",o.Footer="FOOTER",o))(Z||{}),h=(n=>(n.BaseURL="WA_BASE_URL",n.AppId="M4D_APP_ID",n.Port="WA_PORT",n.AppSecret="M4D_APP_SECRET",n.PhoneNumberId="WA_PHONE_NUMBER_ID",n.BusinessAcctId="WA_BUSINESS_ACCOUNT_ID",n.APIVersion="CLOUD_API_VERSION",n.AccessToken="CLOUD_API_ACCESS_TOKEN",n.WebhookEndpoint="WEBHOOK_ENDPOINT",n.WebhookVerificationToken="WEBHOOK_VERIFICATION_TOKEN",n.ListenerPort="LISTENER_PORT",n.MaxRetriesAfterWait="MAX_RETRIES_AFTER_WAIT",n.RequestTimeout="REQUEST_TIMEOUT",n.Debug="DEBUG",n))(h||{}),y=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(y||{}),Q=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(Q||{}),z=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(z||{}),u=(t=>(t.Webp="image/webp",t))(u||{}),E=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(E||{}),C=(R=>(R.Text="text/plain",R.Pdf="application/pdf",R.Ppt="application/vnd.ms-powerpoint",R.Word="application/msword",R.Excel="application/vnd.ms-excel",R.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",R.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",R.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",R))(C||{}),ee=(c=>(c.Aac="audio/aac",c.Mp4="audio/mp4",c.Mpeg="audio/mpeg",c.Amr="audio/amr",c.Ogg="audio/ogg",c))(ee||{}),te=(l=>(l.Audio="audio",l.Button="button",l.Document="document",l.Text="text",l.Image="image",l.Interactive="interactive",l.Order="order",l.Sticker="sticker",l.System="system",l.Unknown="unknown",l.Video="video",l))(te||{}),se=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(se||{}),ie=(s=>(s.Ad="ad",s.Post="post",s))(ie||{}),oe=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(oe||{}),re=(r=>(r.Afrikaans="af",r.Albanian="sq",r.Arabic="ar",r.Azerbaijani="az",r.Bengali="bn",r.Bulgarian="bg",r.Catalan="ca",r.Chinese_CHN="zh_CN",r.Chinese_HKG="zh_HK",r.Chinese_TAI="zh_TW",r.Croatian="hr",r.Czech="cs",r.Danish="da",r.Dutch="nl",r.English="en",r.English_UK="en_GB",r.English_US="en_US",r.Estonian="et",r.Filipino="fil",r.Finnish="fi",r.French="fr",r.Georgian="ka",r.German="de",r.Greek="el",r.Gujarati="gu",r.Hausa="ha",r.Hebrew="he",r.Hindi="hi",r.Hungarian="hu",r.Indonesian="id",r.Irish="ga",r.Italian="it",r.Japanese="ja",r.Kannada="kn",r.Kazakh="kk",r.Kinyarwanda="rw_RW",r.Korean="ko",r.Kyrgyz_Kyrgyzstan="ky_KG",r.Lao="lo",r.Latvian="lv",r.Lithuanian="lt",r.Macedonian="mk",r.Malay="ms",r.Malayalam="ml",r.Marathi="mr",r.Norwegian="nb",r.Persian="fa",r.Polish="pl",r.Portuguese_BR="pt_BR",r.Portuguese_POR="pt_PT",r.Punjabi="pa",r.Romanian="ro",r.Russian="ru",r.Serbian="sr",r.Slovak="sk",r.Slovenian="sl",r.Spanish="es",r.Spanish_ARG="es_AR",r.Spanish_SPA="es_ES",r.Spanish_MEX="es_MX",r.Swahili="sw",r.Swedish="sv",r.Tamil="ta",r.Telugu="te",r.Thai="th",r.Turkish="tr",r.Ukrainian="uk",r.Urdu="ur",r.Uzbek="uz",r.Vietnamese="vi",r.Zulu="zu",r))(re||{}),ae=(e=>(e.AFN="AFN",e.EUR="EUR",e.ALL="ALL",e.DZD="DZD",e.USD="USD",e.AOA="AOA",e.XCD="XCD",e.ARS="ARS",e.AMD="AMD",e.AWG="AWG",e.AUD="AUD",e.AZN="AZN",e.BSD="BSD",e.BHD="BHD",e.BDT="BDT",e.BBD="BBD",e.BYN="BYN",e.BZD="BZD",e.XOF="XOF",e.BMD="BMD",e.INR="INR",e.BTN="BTN",e.BOB="BOB",e.BOV="BOV",e.BAM="BAM",e.BWP="BWP",e.NOK="NOK",e.BRL="BRL",e.BND="BND",e.BGN="BGN",e.BIF="BIF",e.CVE="CVE",e.KHR="KHR",e.XAF="XAF",e.CAD="CAD",e.KYD="KYD",e.CLP="CLP",e.CLF="CLF",e.CNY="CNY",e.COP="COP",e.COU="COU",e.KMF="KMF",e.CDF="CDF",e.NZD="NZD",e.CRC="CRC",e.HRK="HRK",e.CUP="CUP",e.CUC="CUC",e.ANG="ANG",e.CZK="CZK",e.DKK="DKK",e.DJF="DJF",e.DOP="DOP",e.EGP="EGP",e.SVC="SVC",e.ERN="ERN",e.SZL="SZL",e.ETB="ETB",e.FKP="FKP",e.FJD="FJD",e.XPF="XPF",e.GMD="GMD",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GTQ="GTQ",e.GBP="GBP",e.GNF="GNF",e.GYD="GYD",e.HTG="HTG",e.HNL="HNL",e.HKD="HKD",e.HUF="HUF",e.ISK="ISK",e.IDR="IDR",e.XDR="XDR",e.IRR="IRR",e.IQD="IQD",e.ILS="ILS",e.JMD="JMD",e.JPY="JPY",e.JOD="JOD",e.KZT="KZT",e.KES="KES",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KGS="KGS",e.LAK="LAK",e.LBP="LBP",e.LSL="LSL",e.ZAR="ZAR",e.LRD="LRD",e.LYD="LYD",e.CHF="CHF",e.MOP="MOP",e.MKD="MKD",e.MGA="MGA",e.MWK="MWK",e.MYR="MYR",e.MVR="MVR",e.MRU="MRU",e.MUR="MUR",e.XUA="XUA",e.MXN="MXN",e.MXV="MXV",e.MDL="MDL",e.MNT="MNT",e.MAD="MAD",e.MZN="MZN",e.MMK="MMK",e.NAD="NAD",e.NPR="NPR",e.NIO="NIO",e.NGN="NGN",e.OMR="OMR",e.PKR="PKR",e.PAB="PAB",e.PGK="PGK",e.PYG="PYG",e.PEN="PEN",e.PHP="PHP",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RUB="RUB",e.RWF="RWF",e.SHP="SHP",e.WST="WST",e.STN="STN",e.SAR="SAR",e.RSD="RSD",e.SCR="SCR",e.SLL="SLL",e.SGD="SGD",e.XSU="XSU",e.SBD="SBD",e.SOS="SOS",e.SSP="SSP",e.LKR="LKR",e.SDG="SDG",e.SRD="SRD",e.SEK="SEK",e.CHE="CHE",e.CHW="CHW",e.SYP="SYP",e.TWD="TWD",e.TJS="TJS",e.TZS="TZS",e.THB="THB",e.TOP="TOP",e.TTD="TTD",e.TND="TND",e.TRY="TRY",e.TMT="TMT",e.UGX="UGX",e.UAH="UAH",e.AED="AED",e.USN="USN",e.UYU="UYU",e.UYI="UYI",e.UYW="UYW",e.UZS="UZS",e.VUV="VUV",e.VES="VES",e.VND="VND",e.YER="YER",e.ZMW="ZMW",e.ZWL="ZWL",e.XBA="XBA",e.XBB="XBB",e.XBC="XBC",e.XBD="XBD",e.XTS="XTS",e.XXX="XXX",e.XAU="XAU",e.XPD="XPD",e.XPT="XPT",e.XAG="XAG",e.AFA="AFA",e.FIM="FIM",e.ALK="ALK",e.ADP="ADP",e.ESP="ESP",e.FRF="FRF",e.AOK="AOK",e.AON="AON",e.AOR="AOR",e.ARA="ARA",e.ARP="ARP",e.ARY="ARY",e.RUR="RUR",e.ATS="ATS",e.AYM="AYM",e.AZM="AZM",e.BYB="BYB",e.BYR="BYR",e.BEC="BEC",e.BEF="BEF",e.BEL="BEL",e.BOP="BOP",e.BAD="BAD",e.BRB="BRB",e.BRC="BRC",e.BRE="BRE",e.BRN="BRN",e.BRR="BRR",e.BGJ="BGJ",e.BGK="BGK",e.BGL="BGL",e.BUK="BUK",e.HRD="HRD",e.CYP="CYP",e.CSJ="CSJ",e.CSK="CSK",e.ECS="ECS",e.ECV="ECV",e.GQE="GQE",e.EEK="EEK",e.XEU="XEU",e.GEK="GEK",e.DDM="DDM",e.DEM="DEM",e.GHC="GHC",e.GHP="GHP",e.GRD="GRD",e.GNE="GNE",e.GNS="GNS",e.GWE="GWE",e.GWP="GWP",e.ITL="ITL",e.ISJ="ISJ",e.IEP="IEP",e.ILP="ILP",e.ILR="ILR",e.LAJ="LAJ",e.LVL="LVL",e.LVR="LVR",e.LSM="LSM",e.ZAL="ZAL",e.LTL="LTL",e.LTT="LTT",e.LUC="LUC",e.LUF="LUF",e.LUL="LUL",e.MGF="MGF",e.MVQ="MVQ",e.MLF="MLF",e.MTL="MTL",e.MTP="MTP",e.MRO="MRO",e.MXP="MXP",e.MZE="MZE",e.MZM="MZM",e.NLG="NLG",e.NIC="NIC",e.PEH="PEH",e.PEI="PEI",e.PES="PES",e.PLZ="PLZ",e.PTE="PTE",e.ROK="ROK",e.ROL="ROL",e.STD="STD",e.CSD="CSD",e.SKK="SKK",e.SIT="SIT",e.RHD="RHD",e.ESA="ESA",e.ESB="ESB",e.SDD="SDD",e.SDP="SDP",e.SRG="SRG",e.CHC="CHC",e.TJR="TJR",e.TPE="TPE",e.TRL="TRL",e.TMM="TMM",e.UGS="UGS",e.UGW="UGW",e.UAK="UAK",e.SUR="SUR",e.USS="USS",e.UYN="UYN",e.UYP="UYP",e.VEB="VEB",e.VEF="VEF",e.VNC="VNC",e.YDD="YDD",e.YUD="YUD",e.YUM="YUM",e.YUN="YUN",e.ZRN="ZRN",e.ZRZ="ZRZ",e.ZMK="ZMK",e.ZWC="ZWC",e.ZWD="ZWD",e.ZWN="ZWN",e.ZWR="ZWR",e.XFO="XFO",e.XRE="XRE",e.XFU="XFU",e))(ae||{}),ne=(n=>(n.AU="AU",n.ID="ID",n.IN="IN",n.JP="JP",n.SG="SG",n.KR="KR",n.DE="DE",n.CH="CH",n.GB="GB",n.BR="BR",n.BH="BH",n.ZA="ZA",n.AE="AE",n.CA="CA",n))(ne||{}),pe=(g=>(g.ALCOHOL="ALCOHOL",g.APPAREL="APPAREL",g.AUTO="AUTO",g.BEAUTY="BEAUTY",g.EDU="EDU",g.ENTERTAIN="ENTERTAIN",g.EVENT_PLAN="EVENT_PLAN",g.FINANCE="FINANCE",g.GOVT="GOVT",g.GROCERY="GROCERY",g.HEALTH="HEALTH",g.HOTEL="HOTEL",g.NONPROFIT="NONPROFIT",g.ONLINE_GAMBLING="ONLINE_GAMBLING",g.OTC_DRUGS="OTC_DRUGS",g.OTHER="OTHER",g.PHYSICAL_GAMBLING="PHYSICAL_GAMBLING",g.PROF_SERVICES="PROF_SERVICES",g.RESTAURANT="RESTAURANT",g.RETAIL="RETAIL",g.TRAVEL="TRAVEL",g))(pe||{});var P=class{name;debug;constructor(t,s=!1){this.name=t,this.debug=s}log(...t){if(this.debug){let s=`[ ${Date.now()} ]`;this.name&&(s+=` - ${this.name}`),console.log.apply(console,[s,": ",...t])}}error(...t){let s=`[ ${Date.now()} ] - ERROR`;this.name&&(s+=` - ${this.name}`),console.error.apply(console,[s,": ",...t])}warn(...t){let s=`[ ${Date.now()} ] - WARN`;this.name&&(s+=` - ${this.name}`),console.warn.apply(console,[s,": ",...t])}info(...t){let s=`[ ${Date.now()} ] - INFO`;this.name&&(s+=` - ${this.name}`),console.info.apply(console,[s,": ",...t])}};var Ae="BaseAPI",Se=!1,Te=new P(Ae,process.env.DEBUG==="true"||Se),p=class{config;client;constructor(t,s){this.config=t,this.client=s,Te.log("Initialized with HTTPSClient")}};var A=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[i,o]of Object.entries(a))o!==void 0&&t.append(i,String(o));let s=t.toString();return s?`?${s}`:""};var S=class extends p{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?A({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let o=A({file_length:t,file_type:s,file_name:i});return this.client.sendRequest("POST",`app/uploads/${o}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends p{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let s=new FormData;return s.append("business_public_key",t),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var me="FlowAPI",qe=!1,be=new P(me,process.env.DEBUG==="true"||qe),m=class extends p{constructor(t,s){super(t,s),be.log("FlowAPI initialized")}async listFlows(t){return this.client.sendRequest("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.clone_flow_id&&i.append("clone_flow_id",s.clone_flow_id),s.flow_json&&i.append("flow_json",s.flow_json),s.publish!==void 0&&i.append("publish",String(s.publish)),this.client.sendRequest("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let o=new URLSearchParams;s&&o.append("fields",s),i&&o.append("date_format",i);let c=o.toString()?`?${o.toString()}`:"";return this.client.sendRequest("GET",`/${t}${c}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.application_id&&i.append("application_id",s.application_id),this.client.sendRequest("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.client.sendRequest("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.client.sendRequest("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData;return i.append("asset_type",s.asset_type),i.append("file",s.file),i.append("name",s.name),this.client.sendRequest("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.client.sendRequest("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.client.sendRequest("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i=new FormData;return i.append("source_waba_id",s.source_waba_id),s.source_flow_names&&i.append("source_flow_names",JSON.stringify(s.source_flow_names)),this.client.sendRequest("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var q=class extends p{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s="whatsapp"){let i=new FormData;return i.append("file",t),i.append("messaging_product",s),i.append("type",t.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.client.sendRequest("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.client.sendRequest("GET",t,this.config.REQUEST_TIMEOUT,null)}};var b=class extends p{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,o){let c={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return o&&(c.context={message_id:o}),c}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",s,i,o)))}async contacts(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",s,i,o)))}async document(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("document",s,i,o)))}async image(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("image",s,i,o)))}async interactive(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async location(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("location",s,i,o)))}async sticker(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",s,i,o)))}async template(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("template",s,i,o)))}async text(t){let{body:s,previewUrl:i,to:o,replyMessageId:c}=t,d;return typeof s=="string"?d={body:s,preview_url:i}:d=s,this.send(JSON.stringify(this.bodyBuilder("text",d,o,c)))}async video(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("video",s,i,o)))}async status(t){let{status:s,messageId:i,typingIndicator:o}=t,c={messaging_product:"whatsapp",status:s,message_id:i,...o&&{typing_indicator:o}};return this.send(JSON.stringify(c))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveCtaUrl(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveLocationRequest(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveAddressMessage(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveReplyButtons(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveFlow(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async reaction(t){let{messageId:s,emoji:i,to:o}=t,c={messaging_product:"whatsapp",recipient_type:"individual",to:o,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(c))}};var N=class extends p{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?A({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var M=class extends p{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var _=class extends p{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends p{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends p{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var B=class extends p{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};var Re=require("https");var Ne="HttpsClient",Me=!1,_e=new P(Ne,process.env.DEBUG==="true"||Me),U=class{agent;constructor(){this.agent=new Re.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,o,c,d){let f=`https://${t}/${s}`,R=new AbortController,fe=setTimeout(()=>R.abort(),c);try{let F=await fetch(f,{method:i,headers:o,body:d,signal:R.signal});return _e.log(`${i} : ${f} - ${JSON.stringify(F)}`),clearTimeout(fe),new H(F)}catch(F){throw F}}},H=class{res;respStatusCode;respHeaders;constructor(t){this.res=t,this.respStatusCode=t.status,this.respHeaders=Object.fromEntries(t.headers.entries())}statusCode(){return this.respStatusCode}headers(){return this.respHeaders}rawResponse(){return this.res}async json(){try{return await this.res.json()}catch(t){throw new Error("Failed to parse response body to JSON: "+t.message)}}};function v(a){return a!=null&&typeof a=="object"&&"error"in a&&typeof a.error=="object"&&a.error!=null&&"message"in a.error&&typeof a.error.message=="string"&&"type"in a.error&&typeof a.error.type=="string"&&"code"in a.error&&typeof a.error.code=="number"&&"fbtrace_id"in a.error&&typeof a.error.fbtrace_id=="string"&&(!("error_data"in a.error)||typeof a.error.error_data=="object"&&a.error.error_data!=null&&"messaging_product"in a.error.error_data&&a.error.error_data.messaging_product==="whatsapp"&&"details"in a.error.error_data&&typeof a.error.error_data.details=="string")&&(!("error_subcode"in a.error)||typeof a.error.error_subcode=="number")}var Oe="REQUESTER",De=!1,Be=new P(Oe,process.env.DEBUG==="true"||De),w=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,o,c,d){this.client=new U,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=o,this.businessAcctId=c,this.userAgent=d}buildHeader(t){return{"Content-Type":t,Authorization:`Bearer ${this.accessToken}`,"User-Agent":this.userAgent}}buildCAPIPath(t){return`v${this.apiVersion}.0/${t}`}async sendRequest(t,s,i,o){let c="application/json",d=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Be.log(`${t} : ${d}`);try{let f=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(c),i,t==="POST"||t==="PUT"?o:void 0);if(!f.rawResponse().ok){let R=await f.json();throw v(R)?R:{name:"MetaError",message:"Unknown error occurred",error:{message:R.message||"Unknown error occurred",type:"UnknownError",code:f.statusCode(),fbtrace_id:""}}}return f}catch(f){throw v(f)?f:{name:"MetaError",message:f instanceof Error?f.message:"Network error occurred",error:{message:f instanceof Error?f.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}};var Ue="UTILS",we=!1,le=new P(Ue,process.env.DEBUG==="true"||we),Ge="graph.facebook.com",Fe=3e3,Le=30,We=2e4,Ke=a=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!a?.accessToken)throw le.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},ce=a=>{Ke(a);let t={WA_BASE_URL:process.env.WA_BASE_URL||Ge,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:a?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:a?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:a?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||Fe,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||Le,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||We,DEBUG:process.env.DEBUG==="true"};return le.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var xe="WHATSAPP",He=!1,G=new P(xe,process.env.DEBUG==="true"||He),ve="WA_SDK",L=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=x;constructor(t){this.config=ce(t),this.requester=new w(this.config.WA_BASE_URL,this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.userAgent()),this.messages=new b(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new N(this.config,this.requester),this.qrCode=new M(this.config,this.requester),this.encryption=new T(this.config,this.requester),this.twoStepVerification=new D(this.config,this.requester),this.registration=new _(this.config,this.requester),this.media=new q(this.config,this.requester),this.waba=new B(this.config,this.requester),this.flow=new m(this.config,this.requester),this.businessProfile=new S(this.config,this.requester),G.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${ve}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,G.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,G.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,G.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,G.log(`Updated business account id to ${t}`),!0}};
|
|
1
|
+
"use strict";var W=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var $=(a,t)=>{for(var s in t)W(a,s,{get:t[s],enumerable:!0})},Ie=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of he(t))!Pe.call(a,o)&&o!==s&&W(a,o,{get:()=>t[o],enumerable:!(i=ge(t,o))||i.enumerable});return a};var de=a=>Ie(W({},"__esModule",{value:!0}),a);var $e={};$($e,{default:()=>L});module.exports=de($e);var x={};$(x,{AudioMediaTypesEnum:()=>ee,BusinessVerticalEnum:()=>ne,ButtonPositionEnum:()=>V,ButtonTypesEnum:()=>k,CategoryEnum:()=>J,ComponentTypesEnum:()=>Z,ConversationTypesEnum:()=>y,CurrencyCodesEnum:()=>ae,DataLocalizationRegionEnum:()=>pe,DocumentMediaTypesEnum:()=>C,HttpMethodsEnum:()=>I,ImageMediaTypesEnum:()=>E,InteractiveTypesEnum:()=>j,LanguagesEnum:()=>re,MessageTypesEnum:()=>K,ParametersTypesEnum:()=>Y,ReferralSourceTypesEnum:()=>ie,RequestCodeMethodsEnum:()=>oe,StatusEnum:()=>Q,StickerMediaTypesEnum:()=>u,SystemChangeTypesEnum:()=>se,TemplateStatusEnum:()=>X,VideoMediaTypesEnum:()=>z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>te});var J=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(J||{}),X=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(X||{}),I=(o=>(o.Get="GET",o.Post="POST",o.Put="PUT",o.Delete="DELETE",o))(I||{}),K=(l=>(l.Audio="audio",l.Contacts="contacts",l.Document="document",l.Image="image",l.Interactive="interactive",l.Location="location",l.Reaction="sticker",l.Sticker="sticker",l.Template="template",l.Text="text",l.Video="video",l))(K||{}),Y=(c=>(c.Currency="currency",c.DateTime="date_time",c.Document="document",c.Image="image",c.Text="text",c.Video="video",c.Payload="payload",c))(Y||{}),j=(R=>(R.Button="button",R.List="list",R.Product="product",R.ProductList="product_list",R.CtaUrl="cta_url",R.LocationRequest="location_request_message",R.AddressMessage="address_message",R.Flow="flow",R))(j||{}),k=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(k||{}),V=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(V||{}),Z=(o=>(o.Header="HEADER",o.Body="BODY",o.Button="BUTTON",o.Footer="FOOTER",o))(Z||{}),h=(p=>(p.BaseURL="WA_BASE_URL",p.AppId="M4D_APP_ID",p.Port="WA_PORT",p.AppSecret="M4D_APP_SECRET",p.PhoneNumberId="WA_PHONE_NUMBER_ID",p.BusinessAcctId="WA_BUSINESS_ACCOUNT_ID",p.APIVersion="CLOUD_API_VERSION",p.AccessToken="CLOUD_API_ACCESS_TOKEN",p.WebhookEndpoint="WEBHOOK_ENDPOINT",p.WebhookVerificationToken="WEBHOOK_VERIFICATION_TOKEN",p.ListenerPort="LISTENER_PORT",p.MaxRetriesAfterWait="MAX_RETRIES_AFTER_WAIT",p.RequestTimeout="REQUEST_TIMEOUT",p.Debug="DEBUG",p))(h||{}),y=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(y||{}),Q=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(Q||{}),z=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(z||{}),u=(t=>(t.Webp="image/webp",t))(u||{}),E=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(E||{}),C=(R=>(R.Text="text/plain",R.Pdf="application/pdf",R.Ppt="application/vnd.ms-powerpoint",R.Word="application/msword",R.Excel="application/vnd.ms-excel",R.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",R.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",R.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",R))(C||{}),ee=(f=>(f.Aac="audio/aac",f.Mp4="audio/mp4",f.Mpeg="audio/mpeg",f.Amr="audio/amr",f.Ogg="audio/ogg",f))(ee||{}),te=(l=>(l.Audio="audio",l.Button="button",l.Document="document",l.Text="text",l.Image="image",l.Interactive="interactive",l.Order="order",l.Sticker="sticker",l.System="system",l.Unknown="unknown",l.Video="video",l))(te||{}),se=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(se||{}),ie=(s=>(s.Ad="ad",s.Post="post",s))(ie||{}),oe=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(oe||{}),re=(r=>(r.Afrikaans="af",r.Albanian="sq",r.Arabic="ar",r.Azerbaijani="az",r.Bengali="bn",r.Bulgarian="bg",r.Catalan="ca",r.Chinese_CHN="zh_CN",r.Chinese_HKG="zh_HK",r.Chinese_TAI="zh_TW",r.Croatian="hr",r.Czech="cs",r.Danish="da",r.Dutch="nl",r.English="en",r.English_UK="en_GB",r.English_US="en_US",r.Estonian="et",r.Filipino="fil",r.Finnish="fi",r.French="fr",r.Georgian="ka",r.German="de",r.Greek="el",r.Gujarati="gu",r.Hausa="ha",r.Hebrew="he",r.Hindi="hi",r.Hungarian="hu",r.Indonesian="id",r.Irish="ga",r.Italian="it",r.Japanese="ja",r.Kannada="kn",r.Kazakh="kk",r.Kinyarwanda="rw_RW",r.Korean="ko",r.Kyrgyz_Kyrgyzstan="ky_KG",r.Lao="lo",r.Latvian="lv",r.Lithuanian="lt",r.Macedonian="mk",r.Malay="ms",r.Malayalam="ml",r.Marathi="mr",r.Norwegian="nb",r.Persian="fa",r.Polish="pl",r.Portuguese_BR="pt_BR",r.Portuguese_POR="pt_PT",r.Punjabi="pa",r.Romanian="ro",r.Russian="ru",r.Serbian="sr",r.Slovak="sk",r.Slovenian="sl",r.Spanish="es",r.Spanish_ARG="es_AR",r.Spanish_SPA="es_ES",r.Spanish_MEX="es_MX",r.Swahili="sw",r.Swedish="sv",r.Tamil="ta",r.Telugu="te",r.Thai="th",r.Turkish="tr",r.Ukrainian="uk",r.Urdu="ur",r.Uzbek="uz",r.Vietnamese="vi",r.Zulu="zu",r))(re||{}),ae=(e=>(e.AFN="AFN",e.EUR="EUR",e.ALL="ALL",e.DZD="DZD",e.USD="USD",e.AOA="AOA",e.XCD="XCD",e.ARS="ARS",e.AMD="AMD",e.AWG="AWG",e.AUD="AUD",e.AZN="AZN",e.BSD="BSD",e.BHD="BHD",e.BDT="BDT",e.BBD="BBD",e.BYN="BYN",e.BZD="BZD",e.XOF="XOF",e.BMD="BMD",e.INR="INR",e.BTN="BTN",e.BOB="BOB",e.BOV="BOV",e.BAM="BAM",e.BWP="BWP",e.NOK="NOK",e.BRL="BRL",e.BND="BND",e.BGN="BGN",e.BIF="BIF",e.CVE="CVE",e.KHR="KHR",e.XAF="XAF",e.CAD="CAD",e.KYD="KYD",e.CLP="CLP",e.CLF="CLF",e.CNY="CNY",e.COP="COP",e.COU="COU",e.KMF="KMF",e.CDF="CDF",e.NZD="NZD",e.CRC="CRC",e.HRK="HRK",e.CUP="CUP",e.CUC="CUC",e.ANG="ANG",e.CZK="CZK",e.DKK="DKK",e.DJF="DJF",e.DOP="DOP",e.EGP="EGP",e.SVC="SVC",e.ERN="ERN",e.SZL="SZL",e.ETB="ETB",e.FKP="FKP",e.FJD="FJD",e.XPF="XPF",e.GMD="GMD",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GTQ="GTQ",e.GBP="GBP",e.GNF="GNF",e.GYD="GYD",e.HTG="HTG",e.HNL="HNL",e.HKD="HKD",e.HUF="HUF",e.ISK="ISK",e.IDR="IDR",e.XDR="XDR",e.IRR="IRR",e.IQD="IQD",e.ILS="ILS",e.JMD="JMD",e.JPY="JPY",e.JOD="JOD",e.KZT="KZT",e.KES="KES",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KGS="KGS",e.LAK="LAK",e.LBP="LBP",e.LSL="LSL",e.ZAR="ZAR",e.LRD="LRD",e.LYD="LYD",e.CHF="CHF",e.MOP="MOP",e.MKD="MKD",e.MGA="MGA",e.MWK="MWK",e.MYR="MYR",e.MVR="MVR",e.MRU="MRU",e.MUR="MUR",e.XUA="XUA",e.MXN="MXN",e.MXV="MXV",e.MDL="MDL",e.MNT="MNT",e.MAD="MAD",e.MZN="MZN",e.MMK="MMK",e.NAD="NAD",e.NPR="NPR",e.NIO="NIO",e.NGN="NGN",e.OMR="OMR",e.PKR="PKR",e.PAB="PAB",e.PGK="PGK",e.PYG="PYG",e.PEN="PEN",e.PHP="PHP",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RUB="RUB",e.RWF="RWF",e.SHP="SHP",e.WST="WST",e.STN="STN",e.SAR="SAR",e.RSD="RSD",e.SCR="SCR",e.SLL="SLL",e.SGD="SGD",e.XSU="XSU",e.SBD="SBD",e.SOS="SOS",e.SSP="SSP",e.LKR="LKR",e.SDG="SDG",e.SRD="SRD",e.SEK="SEK",e.CHE="CHE",e.CHW="CHW",e.SYP="SYP",e.TWD="TWD",e.TJS="TJS",e.TZS="TZS",e.THB="THB",e.TOP="TOP",e.TTD="TTD",e.TND="TND",e.TRY="TRY",e.TMT="TMT",e.UGX="UGX",e.UAH="UAH",e.AED="AED",e.USN="USN",e.UYU="UYU",e.UYI="UYI",e.UYW="UYW",e.UZS="UZS",e.VUV="VUV",e.VES="VES",e.VND="VND",e.YER="YER",e.ZMW="ZMW",e.ZWL="ZWL",e.XBA="XBA",e.XBB="XBB",e.XBC="XBC",e.XBD="XBD",e.XTS="XTS",e.XXX="XXX",e.XAU="XAU",e.XPD="XPD",e.XPT="XPT",e.XAG="XAG",e.AFA="AFA",e.FIM="FIM",e.ALK="ALK",e.ADP="ADP",e.ESP="ESP",e.FRF="FRF",e.AOK="AOK",e.AON="AON",e.AOR="AOR",e.ARA="ARA",e.ARP="ARP",e.ARY="ARY",e.RUR="RUR",e.ATS="ATS",e.AYM="AYM",e.AZM="AZM",e.BYB="BYB",e.BYR="BYR",e.BEC="BEC",e.BEF="BEF",e.BEL="BEL",e.BOP="BOP",e.BAD="BAD",e.BRB="BRB",e.BRC="BRC",e.BRE="BRE",e.BRN="BRN",e.BRR="BRR",e.BGJ="BGJ",e.BGK="BGK",e.BGL="BGL",e.BUK="BUK",e.HRD="HRD",e.CYP="CYP",e.CSJ="CSJ",e.CSK="CSK",e.ECS="ECS",e.ECV="ECV",e.GQE="GQE",e.EEK="EEK",e.XEU="XEU",e.GEK="GEK",e.DDM="DDM",e.DEM="DEM",e.GHC="GHC",e.GHP="GHP",e.GRD="GRD",e.GNE="GNE",e.GNS="GNS",e.GWE="GWE",e.GWP="GWP",e.ITL="ITL",e.ISJ="ISJ",e.IEP="IEP",e.ILP="ILP",e.ILR="ILR",e.LAJ="LAJ",e.LVL="LVL",e.LVR="LVR",e.LSM="LSM",e.ZAL="ZAL",e.LTL="LTL",e.LTT="LTT",e.LUC="LUC",e.LUF="LUF",e.LUL="LUL",e.MGF="MGF",e.MVQ="MVQ",e.MLF="MLF",e.MTL="MTL",e.MTP="MTP",e.MRO="MRO",e.MXP="MXP",e.MZE="MZE",e.MZM="MZM",e.NLG="NLG",e.NIC="NIC",e.PEH="PEH",e.PEI="PEI",e.PES="PES",e.PLZ="PLZ",e.PTE="PTE",e.ROK="ROK",e.ROL="ROL",e.STD="STD",e.CSD="CSD",e.SKK="SKK",e.SIT="SIT",e.RHD="RHD",e.ESA="ESA",e.ESB="ESB",e.SDD="SDD",e.SDP="SDP",e.SRG="SRG",e.CHC="CHC",e.TJR="TJR",e.TPE="TPE",e.TRL="TRL",e.TMM="TMM",e.UGS="UGS",e.UGW="UGW",e.UAK="UAK",e.SUR="SUR",e.USS="USS",e.UYN="UYN",e.UYP="UYP",e.VEB="VEB",e.VEF="VEF",e.VNC="VNC",e.YDD="YDD",e.YUD="YUD",e.YUM="YUM",e.YUN="YUN",e.ZRN="ZRN",e.ZRZ="ZRZ",e.ZMK="ZMK",e.ZWC="ZWC",e.ZWD="ZWD",e.ZWN="ZWN",e.ZWR="ZWR",e.XFO="XFO",e.XRE="XRE",e.XFU="XFU",e))(ae||{}),pe=(p=>(p.AU="AU",p.ID="ID",p.IN="IN",p.JP="JP",p.SG="SG",p.KR="KR",p.DE="DE",p.CH="CH",p.GB="GB",p.BR="BR",p.BH="BH",p.ZA="ZA",p.AE="AE",p.CA="CA",p))(pe||{}),ne=(g=>(g.ALCOHOL="ALCOHOL",g.APPAREL="APPAREL",g.AUTO="AUTO",g.BEAUTY="BEAUTY",g.EDU="EDU",g.ENTERTAIN="ENTERTAIN",g.EVENT_PLAN="EVENT_PLAN",g.FINANCE="FINANCE",g.GOVT="GOVT",g.GROCERY="GROCERY",g.HEALTH="HEALTH",g.HOTEL="HOTEL",g.NONPROFIT="NONPROFIT",g.ONLINE_GAMBLING="ONLINE_GAMBLING",g.OTC_DRUGS="OTC_DRUGS",g.OTHER="OTHER",g.PHYSICAL_GAMBLING="PHYSICAL_GAMBLING",g.PROF_SERVICES="PROF_SERVICES",g.RESTAURANT="RESTAURANT",g.RETAIL="RETAIL",g.TRAVEL="TRAVEL",g))(ne||{});var P=class{name;debug;constructor(t,s=!1){this.name=t,this.debug=s}log(...t){if(this.debug){let s=`[ ${Date.now()} ]`;this.name&&(s+=` - ${this.name}`),console.log.apply(console,[s,": ",...t])}}error(...t){let s=`[ ${Date.now()} ] - ERROR`;this.name&&(s+=` - ${this.name}`),console.error.apply(console,[s,": ",...t])}warn(...t){let s=`[ ${Date.now()} ] - WARN`;this.name&&(s+=` - ${this.name}`),console.warn.apply(console,[s,": ",...t])}info(...t){let s=`[ ${Date.now()} ] - INFO`;this.name&&(s+=` - ${this.name}`),console.info.apply(console,[s,": ",...t])}};var Ae="BaseAPI",Se=!1,Te=new P(Ae,process.env.DEBUG==="true"||Se),n=class{config;client;constructor(t,s){this.config=t,this.client=s,Te.log("Initialized with HTTPSClient")}};var A=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[i,o]of Object.entries(a))o!==void 0&&t.append(i,String(o));let s=t.toString();return s?`?${s}`:""};var S=class extends n{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?A({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let o=A({file_length:t,file_type:s,file_name:i});return this.client.sendRequest("POST",`app/uploads/${o}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends n{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let s=new FormData;return s.append("business_public_key",t),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var me="FlowAPI",be=!1,qe=new P(me,process.env.DEBUG==="true"||be),m=class extends n{constructor(t,s){super(t,s),qe.log("FlowAPI initialized")}async listFlows(t){return this.client.sendRequest("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.clone_flow_id&&i.append("clone_flow_id",s.clone_flow_id),s.flow_json&&i.append("flow_json",s.flow_json),s.publish!==void 0&&i.append("publish",String(s.publish)),this.client.sendRequest("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let o=new URLSearchParams;s&&o.append("fields",s),i&&o.append("date_format",i);let f=o.toString()?`?${o.toString()}`:"";return this.client.sendRequest("GET",`/${t}${f}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.application_id&&i.append("application_id",s.application_id),this.client.sendRequest("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.client.sendRequest("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.client.sendRequest("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData;return i.append("asset_type",s.asset_type),i.append("file",s.file),i.append("name",s.name),this.client.sendRequest("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.client.sendRequest("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.client.sendRequest("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i=new FormData;return i.append("source_waba_id",s.source_waba_id),s.source_flow_names&&i.append("source_flow_names",JSON.stringify(s.source_flow_names)),this.client.sendRequest("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var b=class extends n{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s="whatsapp"){let i=new FormData;return i.append("file",t),i.append("messaging_product",s),i.append("type",t.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.client.sendRequest("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.client.sendRequest("GET",t,this.config.REQUEST_TIMEOUT,null)}};var q=class extends n{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,o){let f={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return o&&(f.context={message_id:o}),f}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",s,i,o)))}async contacts(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",s,i,o)))}async document(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("document",s,i,o)))}async image(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("image",s,i,o)))}async interactive(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async location(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("location",s,i,o)))}async sticker(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",s,i,o)))}async template(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("template",s,i,o)))}async text(t){let{body:s,previewUrl:i,to:o,replyMessageId:f}=t,d;return typeof s=="string"?d={body:s,preview_url:i}:d=s,this.send(JSON.stringify(this.bodyBuilder("text",d,o,f)))}async video(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("video",s,i,o)))}async status(t){let{status:s,messageId:i,typingIndicator:o}=t,f={messaging_product:"whatsapp",status:s,message_id:i,...o&&{typing_indicator:o}};return this.send(JSON.stringify(f))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveCtaUrl(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveLocationRequest(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveAddressMessage(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveReplyButtons(t){let{body:s,to:i,replyMessageId:o}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async interactiveFlow(t){let{body:s,to:i,replyMessageId:o}=t;return s.action.parameters.flow_message_version===void 0&&(s.action.parameters.flow_message_version="3"),s.action.parameters.mode===void 0&&(s.action.parameters.mode="published"),s.action.parameters.flow_action===void 0&&(s.action.parameters.flow_action="navigate"),s.action.parameters.flow_action_payload?.screen===void 0&&(s.action.parameters.flow_action_payload={...s.action.parameters.flow_action_payload,screen:"FIRST_ENTRY_SCREEN"}),this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async reaction(t){let{messageId:s,emoji:i,to:o}=t,f={messaging_product:"whatsapp",recipient_type:"individual",to:o,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(f))}};var _=class extends n{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?A({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var N=class extends n{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var M=class extends n{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends n{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends n{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var B=class extends n{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};var Re=require("https");var _e="HttpsClient",Ne=!1,Me=new P(_e,process.env.DEBUG==="true"||Ne),U=class{agent;constructor(){this.agent=new Re.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,o,f,d){let c=`https://${t}/${s}`,R=new AbortController,ce=setTimeout(()=>R.abort(),f);try{let F=await fetch(c,{method:i,headers:o,body:d,signal:R.signal});return Me.log(`${i} : ${c} - ${JSON.stringify(F)}`),clearTimeout(ce),new H(F)}catch(F){throw F}}},H=class{res;respStatusCode;respHeaders;constructor(t){this.res=t,this.respStatusCode=t.status,this.respHeaders=Object.fromEntries(t.headers.entries())}statusCode(){return this.respStatusCode}headers(){return this.respHeaders}rawResponse(){return this.res}async json(){try{return await this.res.json()}catch(t){throw new Error("Failed to parse response body to JSON: "+t.message)}}};function v(a){return a!=null&&typeof a=="object"&&"error"in a&&typeof a.error=="object"&&a.error!=null&&"message"in a.error&&typeof a.error.message=="string"&&"type"in a.error&&typeof a.error.type=="string"&&"code"in a.error&&typeof a.error.code=="number"&&"fbtrace_id"in a.error&&typeof a.error.fbtrace_id=="string"&&(!("error_data"in a.error)||typeof a.error.error_data=="object"&&a.error.error_data!=null&&"messaging_product"in a.error.error_data&&a.error.error_data.messaging_product==="whatsapp"&&"details"in a.error.error_data&&typeof a.error.error_data.details=="string")&&(!("error_subcode"in a.error)||typeof a.error.error_subcode=="number")}var Oe="REQUESTER",De=!1,Be=new P(Oe,process.env.DEBUG==="true"||De),w=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,o,f,d){this.client=new U,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=o,this.businessAcctId=f,this.userAgent=d}buildHeader(t){return{"Content-Type":t,Authorization:`Bearer ${this.accessToken}`,"User-Agent":this.userAgent}}buildCAPIPath(t){return`v${this.apiVersion}.0/${t}`}async sendRequest(t,s,i,o){let f="application/json",d=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Be.log(`${t} : ${d}`);try{let c=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(f),i,t==="POST"||t==="PUT"?o:void 0);if(!c.rawResponse().ok){let R=await c.json();throw v(R)?R:{name:"MetaError",message:"Unknown error occurred",error:{message:R.message||"Unknown error occurred",type:"UnknownError",code:c.statusCode(),fbtrace_id:""}}}return c}catch(c){throw v(c)?c:{name:"MetaError",message:c instanceof Error?c.message:"Network error occurred",error:{message:c instanceof Error?c.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}};var Ue="UTILS",we=!1,le=new P(Ue,process.env.DEBUG==="true"||we),Ge="graph.facebook.com",Fe=3e3,Le=30,We=2e4,Ke=a=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!a?.accessToken)throw le.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},fe=a=>{Ke(a);let t={WA_BASE_URL:process.env.WA_BASE_URL||Ge,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:a?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:a?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:a?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||Fe,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||Le,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||We,DEBUG:process.env.DEBUG==="true"};return le.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var xe="WHATSAPP",He=!1,G=new P(xe,process.env.DEBUG==="true"||He),ve="WA_SDK",L=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=x;constructor(t){this.config=fe(t),this.requester=new w(this.config.WA_BASE_URL,this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.userAgent()),this.messages=new q(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new _(this.config,this.requester),this.qrCode=new N(this.config,this.requester),this.encryption=new T(this.config,this.requester),this.twoStepVerification=new D(this.config,this.requester),this.registration=new M(this.config,this.requester),this.media=new b(this.config,this.requester),this.waba=new B(this.config,this.requester),this.flow=new m(this.config,this.requester),this.businessProfile=new S(this.config,this.requester),G.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${ve}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,G.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,G.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,G.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,G.log(`Updated business account id to ${t}`),!0}};
|
|
2
2
|
//# sourceMappingURL=whatsapp.js.map
|