meta-cloud-api 0.1.5 → 0.1.7
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/businessProfile.d.mts +6 -6
- package/dist/api/businessProfile.d.ts +6 -6
- package/dist/api/businessProfile.js +1 -1
- package/dist/api/businessProfile.js.map +1 -1
- package/dist/api/businessProfile.mjs +1 -1
- package/dist/api/businessProfile.mjs.map +1 -1
- package/dist/api/encryption.d.mts +3 -3
- package/dist/api/encryption.d.ts +3 -3
- package/dist/api/encryption.js.map +1 -1
- package/dist/api/encryption.mjs.map +1 -1
- package/dist/api/flow.d.mts +14 -25
- package/dist/api/flow.d.ts +14 -25
- package/dist/api/flow.js +1 -1
- package/dist/api/flow.js.map +1 -1
- package/dist/api/flow.mjs +1 -1
- package/dist/api/flow.mjs.map +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 +5 -5
- package/dist/api/media.d.ts +5 -5
- package/dist/api/media.js.map +1 -1
- package/dist/api/media.mjs.map +1 -1
- package/dist/api/messages.d.mts +21 -21
- package/dist/api/messages.d.ts +21 -21
- 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 +5 -5
- package/dist/api/phoneNumber.d.ts +5 -5
- package/dist/api/phoneNumber.js +1 -1
- package/dist/api/phoneNumber.js.map +1 -1
- package/dist/api/phoneNumber.mjs.map +1 -1
- package/dist/api/qrCode.d.mts +6 -6
- package/dist/api/qrCode.d.ts +6 -6
- package/dist/api/qrCode.js +1 -1
- package/dist/api/qrCode.js.map +1 -1
- package/dist/api/qrCode.mjs.map +1 -1
- package/dist/api/registration.d.mts +3 -3
- package/dist/api/registration.d.ts +3 -3
- package/dist/api/registration.js +1 -1
- package/dist/api/registration.js.map +1 -1
- package/dist/api/registration.mjs.map +1 -1
- package/dist/api/template.d.mts +6 -6
- package/dist/api/template.d.ts +6 -6
- package/dist/api/template.js +1 -1
- package/dist/api/template.js.map +1 -1
- package/dist/api/template.mjs +1 -1
- package/dist/api/template.mjs.map +1 -1
- package/dist/api/twoStepVerification.d.mts +3 -3
- package/dist/api/twoStepVerification.d.ts +3 -3
- package/dist/api/twoStepVerification.js +1 -1
- package/dist/api/twoStepVerification.js.map +1 -1
- package/dist/api/twoStepVerification.mjs.map +1 -1
- package/dist/api/waba.d.mts +5 -5
- package/dist/api/waba.d.ts +5 -5
- package/dist/api/waba.js.map +1 -1
- package/dist/api/waba.mjs.map +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/types/businessProfile.d.mts +6 -6
- package/dist/types/businessProfile.d.ts +6 -6
- package/dist/types/businessProfile.js +1 -1
- package/dist/types/businessProfile.js.map +1 -1
- package/dist/types/encryption.d.mts +3 -3
- package/dist/types/encryption.d.ts +3 -3
- package/dist/types/encryption.js +1 -1
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/flow.d.mts +12 -12
- package/dist/types/flow.d.ts +12 -12
- package/dist/types/flow.js +1 -1
- package/dist/types/flow.js.map +1 -1
- package/dist/types/flow.mjs +1 -1
- package/dist/types/flow.mjs.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/media.d.mts +5 -5
- package/dist/types/media.d.ts +5 -5
- package/dist/types/media.js +1 -1
- package/dist/types/media.js.map +1 -1
- package/dist/types/messages.d.mts +21 -21
- package/dist/types/messages.d.ts +21 -21
- package/dist/types/messages.js.map +1 -1
- package/dist/types/phoneNumber.d.mts +5 -5
- package/dist/types/phoneNumber.d.ts +5 -5
- package/dist/types/phoneNumber.js +1 -1
- package/dist/types/phoneNumber.js.map +1 -1
- package/dist/types/qrCode.d.mts +6 -6
- package/dist/types/qrCode.d.ts +6 -6
- package/dist/types/qrCode.js +1 -1
- package/dist/types/qrCode.js.map +1 -1
- package/dist/types/registration.d.mts +3 -3
- package/dist/types/registration.d.ts +3 -3
- package/dist/types/registration.js +1 -1
- package/dist/types/registration.js.map +1 -1
- package/dist/types/template.d.mts +6 -6
- package/dist/types/template.d.ts +6 -6
- package/dist/types/template.js +1 -1
- package/dist/types/template.js.map +1 -1
- package/dist/types/twoStepVerification.d.mts +2 -2
- package/dist/types/twoStepVerification.d.ts +2 -2
- package/dist/types/twoStepVerification.js +1 -1
- package/dist/types/twoStepVerification.js.map +1 -1
- package/dist/types/waba.d.mts +5 -5
- package/dist/types/waba.d.ts +5 -5
- package/dist/types/waba.js +1 -1
- package/dist/types/waba.js.map +1 -1
- package/dist/types/waba.mjs +1 -1
- package/dist/types/waba.mjs.map +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,5 +1,5 @@
|
|
|
1
1
|
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D7paGoTY.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.mjs';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
|
5
5
|
type PhoneNumberButton = {
|
|
@@ -96,11 +96,11 @@ type TemplateDeleteParams = {
|
|
|
96
96
|
name: string;
|
|
97
97
|
};
|
|
98
98
|
declare class TemplateClass {
|
|
99
|
-
getTemplate(templateId: string): Promise<
|
|
100
|
-
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<
|
|
101
|
-
getTemplates(params: TemplateGetParams): Promise<
|
|
102
|
-
createTemplate(template: TemplateRequestBody): Promise<
|
|
103
|
-
deleteTemplate(params: TemplateDeleteParams): Promise<
|
|
99
|
+
getTemplate(templateId: string): Promise<TemplateResponse>;
|
|
100
|
+
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
|
|
101
|
+
getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
|
|
102
|
+
createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
|
|
103
|
+
deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export { type ComponentTypes, type CopyCodeButton, type FlowButton, type MPMButton, type OTPButton, type PhoneNumberButton, type QuickReplyButton, type SPMButton, type TemplateBody, type TemplateButton, TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateRequestBody, type TemplateResponse, type URLButton };
|
package/dist/types/template.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-D7paGoTY.js';
|
|
2
|
-
import {
|
|
2
|
+
import { GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.js';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
|
5
5
|
type PhoneNumberButton = {
|
|
@@ -96,11 +96,11 @@ type TemplateDeleteParams = {
|
|
|
96
96
|
name: string;
|
|
97
97
|
};
|
|
98
98
|
declare class TemplateClass {
|
|
99
|
-
getTemplate(templateId: string): Promise<
|
|
100
|
-
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<
|
|
101
|
-
getTemplates(params: TemplateGetParams): Promise<
|
|
102
|
-
createTemplate(template: TemplateRequestBody): Promise<
|
|
103
|
-
deleteTemplate(params: TemplateDeleteParams): Promise<
|
|
99
|
+
getTemplate(templateId: string): Promise<TemplateResponse>;
|
|
100
|
+
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
|
|
101
|
+
getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
|
|
102
|
+
createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
|
|
103
|
+
deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export { type ComponentTypes, type CopyCodeButton, type FlowButton, type MPMButton, type OTPButton, type PhoneNumberButton, type QuickReplyButton, type SPMButton, type TemplateBody, type TemplateButton, TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateRequestBody, type TemplateResponse, type URLButton };
|
package/dist/types/template.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var l=(t,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of s(e))!m.call(t,a)&&a!==r&&n(t,a,{get:()=>e[a],enumerable:!(p=o(e,a))||p.enumerable});return t};var g=t=>l(n({},"__esModule",{value:!0}),t);var y={};module.exports=g(y);
|
|
2
2
|
//# sourceMappingURL=template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/template.ts"],"sourcesContent":["import { CategoryEnum, LanguagesEnum, TemplateStatusEnum } from './enums';\nimport { GeneralRequestBody,
|
|
1
|
+
{"version":3,"sources":["../../src/types/template.ts"],"sourcesContent":["import { CategoryEnum, LanguagesEnum, TemplateStatusEnum } from './enums';\nimport { GeneralRequestBody, ResponsePagination, ResponseSuccess } from './request';\n\nexport type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';\n\nexport type PhoneNumberButton = {\n type: 'PHONE_NUMBER';\n text: string; // max 25 chars\n phone_number: string; // max 20 chars\n};\n\nexport type URLButton = {\n type: 'URL';\n text: string; // max 25 chars\n url: string; // max 2000 chars\n example?: string[]; // Required if url contains variable\n};\n\nexport type QuickReplyButton = {\n type: 'QUICK_REPLY';\n text: string; // max 25 chars\n};\n\nexport type CopyCodeButton = {\n type: 'COPY_CODE';\n example: string; // max 15 chars\n};\n\nexport type FlowButton = {\n type: 'FLOW';\n text: string; // max 25 chars\n flow_id?: string;\n flow_name?: string;\n flow_json?: string;\n flow_action?: 'navigate' | 'data_exchange';\n navigate_screen?: string;\n};\n\nexport type MPMButton = {\n type: 'MPM';\n};\n\nexport type OTPButton = {\n type: 'OTP';\n};\n\nexport type SPMButton = {\n type: 'SPM';\n};\n\nexport type TemplateButton =\n | PhoneNumberButton\n | URLButton\n | QuickReplyButton\n | CopyCodeButton\n | FlowButton\n | MPMButton\n | OTPButton\n | SPMButton;\n\nexport type TemplateHeaderExample = {\n header_text?: string[];\n header_text_named_params?: Array<{\n param_name: string;\n example: string;\n }>;\n header_handle?: string[];\n};\n\nexport type TemplateHeader = {\n type: 'HEADER';\n format: TemplateFormat;\n text?: string; // max 60 chars\n example?: TemplateHeaderExample;\n};\n\nexport type TemplateBody = {\n type: 'BODY';\n text: string; // max 1024 chars\n example?: {\n body_text?: Array<Array<string>>; // For positional parameters\n body_text_named_params?: Array<{\n param_name: string; // lowercase letters and underscores only\n example: string;\n }>; // For named parameters\n };\n};\n\nexport type TemplateFooter = {\n type: 'FOOTER';\n text: string; // max 60 chars\n};\n\nexport type ComponentTypes = TemplateHeader | TemplateBody | TemplateFooter | TemplateButton;\n\nexport type TemplateRequestBody = GeneralRequestBody & {\n name: string;\n language: LanguagesEnum;\n category?: CategoryEnum;\n components?: ComponentTypes[];\n};\n\nexport type TemplateResponse = {\n id: string;\n status: string;\n language: LanguagesEnum;\n category: CategoryEnum;\n name: string;\n components: ComponentTypes[];\n};\n\nexport type TemplateGetParams = {\n limit?: number;\n name?: string;\n language?: LanguagesEnum;\n category?: CategoryEnum;\n status?: TemplateStatusEnum;\n};\n\nexport type TemplateDeleteParams = {\n hsm_id: string;\n name: string;\n};\n\nexport declare class TemplateClass {\n getTemplate(templateId: string): Promise<TemplateResponse>;\n updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;\n getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;\n createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;\n deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["template_exports","__toCommonJS"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseSuccess } from './request.mjs';
|
|
2
2
|
import '../enums-D7paGoTY.mjs';
|
|
3
3
|
|
|
4
4
|
type TwoStepVerificationRequest = {
|
|
5
5
|
pin: string;
|
|
6
6
|
};
|
|
7
7
|
interface TwoStepVerificationClass {
|
|
8
|
-
setTwoStepVerificationCode(pin: string): Promise<
|
|
8
|
+
setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type { TwoStepVerificationClass, TwoStepVerificationRequest };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseSuccess } from './request.js';
|
|
2
2
|
import '../enums-D7paGoTY.js';
|
|
3
3
|
|
|
4
4
|
type TwoStepVerificationRequest = {
|
|
5
5
|
pin: string;
|
|
6
6
|
};
|
|
7
7
|
interface TwoStepVerificationClass {
|
|
8
|
-
setTwoStepVerificationCode(pin: string): Promise<
|
|
8
|
+
setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type { TwoStepVerificationClass, TwoStepVerificationRequest };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var a=(i,e,p,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of n(e))!c.call(i,s)&&s!==p&&o(i,s,{get:()=>e[s],enumerable:!(t=r(e,s))||t.enumerable});return i};var f=i=>a(o({},"__esModule",{value:!0}),i);var S={};module.exports=f(S);
|
|
2
2
|
//# sourceMappingURL=twoStepVerification.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/twoStepVerification.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/types/twoStepVerification.ts"],"sourcesContent":["import { ResponseSuccess } from './request';\n\nexport type TwoStepVerificationRequest = {\n pin: string;\n};\n\nexport interface TwoStepVerificationClass {\n setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["twoStepVerification_exports","__toCommonJS"]}
|
package/dist/types/waba.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseSuccess } from './request.mjs';
|
|
2
2
|
import '../enums-D7paGoTY.mjs';
|
|
3
3
|
|
|
4
4
|
type WabaSubscription = {
|
|
@@ -18,10 +18,10 @@ interface WabaSubscriptions {
|
|
|
18
18
|
data: Array<WabaSubscription>;
|
|
19
19
|
}
|
|
20
20
|
interface WABAClass {
|
|
21
|
-
getWabaAccount(fields?: WabaAccountFieldsParam): Promise<
|
|
22
|
-
getAllWabaSubscriptions(): Promise<
|
|
23
|
-
updateWabaSubscription(params: UpdateWabaSubscription): Promise<
|
|
24
|
-
unsubscribeFromWaba(): Promise<
|
|
21
|
+
getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
|
|
22
|
+
getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
|
|
23
|
+
updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
|
|
24
|
+
unsubscribeFromWaba(): Promise<ResponseSuccess>;
|
|
25
25
|
}
|
|
26
26
|
declare enum WabaAccountReviewStatus {
|
|
27
27
|
Approved = "APPROVED",
|
package/dist/types/waba.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseSuccess } from './request.js';
|
|
2
2
|
import '../enums-D7paGoTY.js';
|
|
3
3
|
|
|
4
4
|
type WabaSubscription = {
|
|
@@ -18,10 +18,10 @@ interface WabaSubscriptions {
|
|
|
18
18
|
data: Array<WabaSubscription>;
|
|
19
19
|
}
|
|
20
20
|
interface WABAClass {
|
|
21
|
-
getWabaAccount(fields?: WabaAccountFieldsParam): Promise<
|
|
22
|
-
getAllWabaSubscriptions(): Promise<
|
|
23
|
-
updateWabaSubscription(params: UpdateWabaSubscription): Promise<
|
|
24
|
-
unsubscribeFromWaba(): Promise<
|
|
21
|
+
getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
|
|
22
|
+
getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
|
|
23
|
+
updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
|
|
24
|
+
unsubscribeFromWaba(): Promise<ResponseSuccess>;
|
|
25
25
|
}
|
|
26
26
|
declare enum WabaAccountReviewStatus {
|
|
27
27
|
Approved = "APPROVED",
|
package/dist/types/waba.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var d=(r,t)=>{for(var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var d=(r,t)=>{for(var s in t)a(r,s,{get:t[s],enumerable:!0})},l=(r,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of _(t))!b.call(r,e)&&e!==s&&a(r,e,{get:()=>t[e],enumerable:!(i=u(t,e))||i.enumerable});return r};var m=r=>l(a({},"__esModule",{value:!0}),r);var g={};d(g,{WabaAccountReviewStatus:()=>n,WabaAccountStatus:()=>p,WabaBusinessVerificationStatus:()=>c,WabaHealthStatusCanSendMessage:()=>o});module.exports=m(g);var n=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(n||{}),o=(i=>(i.Blocked="BLOCKED",i.Limited="LIMITED",i.Available="AVAILABLE",i))(o||{}),p=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(p||{}),c=(e=>(e.Verified="verified",e.PendingSubmission="pending_submission",e.Unverified="unverified",e.Rejected="rejected",e))(c||{});0&&(module.exports={WabaAccountReviewStatus,WabaAccountStatus,WabaBusinessVerificationStatus,WabaHealthStatusCanSendMessage});
|
|
2
2
|
//# sourceMappingURL=waba.js.map
|
package/dist/types/waba.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/waba.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/types/waba.ts"],"sourcesContent":["import type { ResponseSuccess } from './request';\n\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n}\n\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n currency?: string;\n}\n\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace';\n\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,sBAAAC,EAAA,mCAAAC,EAAA,mCAAAC,IAAA,eAAAC,EAAAN,GA4BO,IAAKE,OACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WAJHA,OAAA,IAOAG,OACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,UAAY,YAHJA,OAAA,IAMAF,OACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WAJHA,OAAA,IAOAC,OACRA,EAAA,SAAW,WACXA,EAAA,kBAAoB,qBACpBA,EAAA,WAAa,aACbA,EAAA,SAAW,WAJHA,OAAA","names":["waba_exports","__export","WabaAccountReviewStatus","WabaAccountStatus","WabaBusinessVerificationStatus","WabaHealthStatusCanSendMessage","__toCommonJS"]}
|
package/dist/types/waba.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(r||{}),
|
|
1
|
+
var r=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(r||{}),i=(t=>(t.Blocked="BLOCKED",t.Limited="LIMITED",t.Available="AVAILABLE",t))(i||{}),s=(e=>(e.Approved="APPROVED",e.Active="ACTIVE",e.Inactive="INACTIVE",e.Disabled="DISABLED",e))(s||{}),a=(e=>(e.Verified="verified",e.PendingSubmission="pending_submission",e.Unverified="unverified",e.Rejected="rejected",e))(a||{});export{r as WabaAccountReviewStatus,s as WabaAccountStatus,a as WabaBusinessVerificationStatus,i as WabaHealthStatusCanSendMessage};
|
|
2
2
|
//# sourceMappingURL=waba.mjs.map
|
package/dist/types/waba.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/waba.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/types/waba.ts"],"sourcesContent":["import type { ResponseSuccess } from './request';\n\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n}\n\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n currency?: string;\n}\n\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace';\n\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n"],"mappings":"AA4BO,IAAKA,OACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WAJHA,OAAA,IAOAC,OACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,UAAY,YAHJA,OAAA,IAMAC,OACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WAJHA,OAAA,IAOAC,OACRA,EAAA,SAAW,WACXA,EAAA,kBAAoB,qBACpBA,EAAA,WAAa,aACbA,EAAA,SAAW,WAJHA,OAAA","names":["WabaAccountReviewStatus","WabaHealthStatusCanSendMessage","WabaAccountStatus","WabaBusinessVerificationStatus"]}
|
package/dist/whatsapp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var W=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var H=(a,t)=>{for(var s in t)W(a,s,{get:t[s],enumerable:!0})},Ae=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of de(t))!Ie.call(a,o)&&o!==s&&W(a,o,{get:()=>t[o],enumerable:!(i=Pe(t,o))||i.enumerable});return a};var Se=a=>Ae(W({},"__esModule",{value:!0}),a);var $e={};H($e,{default:()=>J});module.exports=Se($e);var v={};H(v,{AudioMediaTypesEnum:()=>ee,BusinessVerticalEnum:()=>pe,ButtonPositionEnum:()=>Y,ButtonTypesEnum:()=>k,CategoryEnum:()=>$,ComponentTypesEnum:()=>V,ConversationTypesEnum:()=>Z,CurrencyCodesEnum:()=>ae,DataLocalizationRegionEnum:()=>ne,DocumentMediaTypesEnum:()=>C,HttpMethodsEnum:()=>d,ImageMediaTypesEnum:()=>E,InteractiveTypesEnum:()=>X,LanguagesEnum:()=>re,MessageTypesEnum:()=>L,ParametersTypesEnum:()=>j,ReferralSourceTypesEnum:()=>ie,RequestCodeMethodsEnum:()=>oe,StatusEnum:()=>Q,StickerMediaTypesEnum:()=>u,SystemChangeTypesEnum:()=>se,TemplateStatusEnum:()=>y,VideoMediaTypesEnum:()=>z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>te});var $=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))($||{}),y=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(y||{}),d=(o=>(o.Get="GET",o.Post="POST",o.Put="PUT",o.Delete="DELETE",o))(d||{}),L=(f=>(f.Audio="audio",f.Contacts="contacts",f.Document="document",f.Image="image",f.Interactive="interactive",f.Location="location",f.Reaction="sticker",f.Sticker="sticker",f.Template="template",f.Text="text",f.Video="video",f))(L||{}),j=(c=>(c.Currency="currency",c.DateTime="date_time",c.Document="document",c.Image="image",c.Text="text",c.Video="video",c.Payload="payload",c))(j||{}),X=(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))(X||{}),k=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(k||{}),Y=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(Y||{}),V=(o=>(o.Header="HEADER",o.Body="BODY",o.Button="BUTTON",o.Footer="FOOTER",o))(V||{}),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||{}),Z=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(Z||{}),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=(p=>(p.Aac="audio/aac",p.Mp4="audio/mp4",p.Mpeg="audio/mpeg",p.Amr="audio/amr",p.Ogg="audio/ogg",p))(ee||{}),te=(f=>(f.Audio="audio",f.Button="button",f.Document="document",f.Text="text",f.Image="image",f.Interactive="interactive",f.Order="order",f.Sticker="sticker",f.System="system",f.Unknown="unknown",f.Video="video",f))(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 be="BaseAPI",Te=!1,me=new P(be,process.env.DEBUG==="true"||Te),l=class{config;client;constructor(t,s){this.config=t,this.client=s,me.log("Initialized with HTTPSClient")}sendJson(t,s,i,o){return this.client.getJson(t,s,i,o)}};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 l{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let o=A({file_length:t,file_type:s,file_name:i});return this.sendJson("POST",`app/uploads/${o}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends l{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var _e="FlowAPI",Ne=!1,le=new P(_e,process.env.DEBUG==="true"||Ne),T=class extends l{constructor(t,s){super(t,s),le.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i={name:s.name,categories:s.categories,...s.endpoint_uri&&{endpoint_uri:s.endpoint_uri},...s.clone_flow_id&&{clone_flow_id:s.clone_flow_id},...s.flow_json&&{flow_json:s.flow_json},...s.publish!==void 0&&{publish:s.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async getFlow(t,s,i){let o=new URLSearchParams;s&&o.append("fields",s),i&&o.append("date_format",i);let p=o.toString()?`?${o.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,s=!1){let i=`preview.invalidate(${s})`;return this.getFlow(t,i)}async updateFlowMetadata(t,s){let i={...s.name&&{name:s.name},...s.categories&&{categories:s.categories},...s.endpoint_uri&&{endpoint_uri:s.endpoint_uri},...s.application_id&&{application_id:s.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData,o;if(s.file instanceof Buffer)o=new globalThis.Blob([s.file]),i.append("file",o);else if(typeof s.file=="object"&&!(s.file instanceof Blob))try{o=new globalThis.Blob([JSON.stringify(s.file,null,2)],{type:"application/json"}),i.append("file",o)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(s.file instanceof Blob)o=s.file,i.append("file",o);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return i.append("asset_type","FLOW_JSON"),i.append("name",s.name||"flow.json"),this.sendJson("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async validateFlowJson(t,s){try{let o=await(await this.updateFlowJson(t,{file:s})).json(),p=!o.validation_errors||o.validation_errors.length===0,I={...o,valid:p};return{json:async()=>I}}catch(i){throw le.error("Error during Flow JSON validation attempt:",i),i}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i={source_waba_id:s.source_waba_id,...s.source_flow_names&&{source_flow_names:s.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};var m=class extends l{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var _=class extends l{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,o){let p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return o&&(p.context={message_id:o}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body: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:p}=t,I;return typeof s=="string"?I={body:s,preview_url:i}:I=s,this.send(JSON.stringify(this.bodyBuilder("text",I,o,p)))}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,p={messaging_product:"whatsapp",status:s,message_id:i,...o&&{typing_indicator:o}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body: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==="navigate"?s.action.parameters.flow_action_payload?.screen===void 0&&(s.action.parameters.flow_action_payload={...s.action.parameters.flow_action_payload,screen:"INIT"}):s.action.parameters.flow_action==="data_exchange"&&delete s.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async reaction(t){let{messageId:s,emoji:i,to:o}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:o,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(p))}};var N=class extends l{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var q=class extends l{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var M=class extends l{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends l{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}};var B=class extends l{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};function Re(a){if(!a)return"";let t="";return Array.isArray(a)?t=a.join(","):t=Object.entries(a).filter(([s,i])=>i).map(([s])=>s).join(","),t?`?fields=${t}`:""}var D=class extends l{constructor(t,s){super(t,s)}async getWabaAccount(t){let s=Re(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};var fe=require("https");var qe="HttpsClient",Me=!1,Oe=new P(qe,process.env.DEBUG==="true"||Me),w=class{agent;constructor(){this.agent=new fe.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,o,p,I){let c=`https://${t}/${s}`,R=new AbortController,he=setTimeout(()=>R.abort(),p);try{let F=await fetch(c,{method:i,headers:o,body:I,signal:R.signal});return Oe.log(`${i} : ${c} - ${JSON.stringify(F)}`),clearTimeout(he),new K(F)}catch(F){throw F}}},K=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 x(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 Be="REQUESTER",De=!1,we=new P(Be,process.env.DEBUG==="true"||De),U=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,o,p,I){this.client=new w,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=o,this.businessAcctId=p,this.userAgent=I}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 p="application/json",I=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;we.log(`${t} : ${I}`);try{let c=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(p),i,t==="POST"||t==="PUT"?o:void 0);if(!c.rawResponse().ok){let R=await c.json();throw x(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 x(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:""}}}}async getJson(t,s,i,o){return await(await this.sendRequest(t,s,i,o)).json()}};var Ue="UTILS",Ge=!1,ce=new P(Ue,process.env.DEBUG==="true"||Ge),Fe="graph.facebook.com",Je=3e3,We=30,Le=2e4,ve=a=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!a?.accessToken)throw ce.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},ge=a=>{ve(a);let t={WA_BASE_URL:process.env.WA_BASE_URL||Fe,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:a?.phoneNumberId||Number(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||"")||Je,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||We,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Le,DEBUG:process.env.DEBUG==="true"};return ce.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var Ke="WHATSAPP",xe=!1,G=new P(Ke,process.env.DEBUG==="true"||xe),He="WA_SDK",J=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=v;constructor(t){this.config=ge(t),this.requester=new U(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 _(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new N(this.config,this.requester),this.qrCode=new q(this.config,this.requester),this.encryption=new b(this.config,this.requester),this.twoStepVerification=new B(this.config,this.requester),this.registration=new M(this.config,this.requester),this.media=new m(this.config,this.requester),this.waba=new D(this.config,this.requester),this.flow=new T(this.config,this.requester),this.businessProfile=new S(this.config,this.requester),G.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${He}/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 Pe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var v=(r,t)=>{for(var s in t)W(r,s,{get:t[s],enumerable:!0})},Se=(r,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of de(t))!Ae.call(r,o)&&o!==s&&W(r,o,{get:()=>t[o],enumerable:!(i=Pe(t,o))||i.enumerable});return r};var Te=r=>Se(W({},"__esModule",{value:!0}),r);var $e={};v($e,{default:()=>J});module.exports=Te($e);var K={};v(K,{AudioMediaTypesEnum:()=>ee,BusinessVerticalEnum:()=>pe,ButtonPositionEnum:()=>Y,ButtonTypesEnum:()=>k,CategoryEnum:()=>$,ComponentTypesEnum:()=>V,ConversationTypesEnum:()=>Z,CurrencyCodesEnum:()=>re,DataLocalizationRegionEnum:()=>ne,DocumentMediaTypesEnum:()=>C,HttpMethodsEnum:()=>d,ImageMediaTypesEnum:()=>E,InteractiveTypesEnum:()=>X,LanguagesEnum:()=>ae,MessageTypesEnum:()=>L,ParametersTypesEnum:()=>j,ReferralSourceTypesEnum:()=>ie,RequestCodeMethodsEnum:()=>oe,StatusEnum:()=>Q,StickerMediaTypesEnum:()=>u,SystemChangeTypesEnum:()=>se,TemplateStatusEnum:()=>y,VideoMediaTypesEnum:()=>z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>te});var $=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))($||{}),y=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(y||{}),d=(o=>(o.Get="GET",o.Post="POST",o.Put="PUT",o.Delete="DELETE",o))(d||{}),L=(c=>(c.Audio="audio",c.Contacts="contacts",c.Document="document",c.Image="image",c.Interactive="interactive",c.Location="location",c.Reaction="sticker",c.Sticker="sticker",c.Template="template",c.Text="text",c.Video="video",c))(L||{}),j=(R=>(R.Currency="currency",R.DateTime="date_time",R.Document="document",R.Image="image",R.Text="text",R.Video="video",R.Payload="payload",R))(j||{}),X=(f=>(f.Button="button",f.List="list",f.Product="product",f.ProductList="product_list",f.CtaUrl="cta_url",f.LocationRequest="location_request_message",f.AddressMessage="address_message",f.Flow="flow",f))(X||{}),k=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(k||{}),Y=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(Y||{}),V=(o=>(o.Header="HEADER",o.Body="BODY",o.Button="BUTTON",o.Footer="FOOTER",o))(V||{}),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||{}),Z=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(Z||{}),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=(f=>(f.Text="text/plain",f.Pdf="application/pdf",f.Ppt="application/vnd.ms-powerpoint",f.Word="application/msword",f.Excel="application/vnd.ms-excel",f.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",f.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",f.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",f))(C||{}),ee=(l=>(l.Aac="audio/aac",l.Mp4="audio/mp4",l.Mpeg="audio/mpeg",l.Amr="audio/amr",l.Ogg="audio/ogg",l))(ee||{}),te=(c=>(c.Audio="audio",c.Button="button",c.Document="document",c.Text="text",c.Image="image",c.Interactive="interactive",c.Order="order",c.Sticker="sticker",c.System="system",c.Unknown="unknown",c.Video="video",c))(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||{}),ae=(a=>(a.Afrikaans="af",a.Albanian="sq",a.Arabic="ar",a.Azerbaijani="az",a.Bengali="bn",a.Bulgarian="bg",a.Catalan="ca",a.Chinese_CHN="zh_CN",a.Chinese_HKG="zh_HK",a.Chinese_TAI="zh_TW",a.Croatian="hr",a.Czech="cs",a.Danish="da",a.Dutch="nl",a.English="en",a.English_UK="en_GB",a.English_US="en_US",a.Estonian="et",a.Filipino="fil",a.Finnish="fi",a.French="fr",a.Georgian="ka",a.German="de",a.Greek="el",a.Gujarati="gu",a.Hausa="ha",a.Hebrew="he",a.Hindi="hi",a.Hungarian="hu",a.Indonesian="id",a.Irish="ga",a.Italian="it",a.Japanese="ja",a.Kannada="kn",a.Kazakh="kk",a.Kinyarwanda="rw_RW",a.Korean="ko",a.Kyrgyz_Kyrgyzstan="ky_KG",a.Lao="lo",a.Latvian="lv",a.Lithuanian="lt",a.Macedonian="mk",a.Malay="ms",a.Malayalam="ml",a.Marathi="mr",a.Norwegian="nb",a.Persian="fa",a.Polish="pl",a.Portuguese_BR="pt_BR",a.Portuguese_POR="pt_PT",a.Punjabi="pa",a.Romanian="ro",a.Russian="ru",a.Serbian="sr",a.Slovak="sk",a.Slovenian="sl",a.Spanish="es",a.Spanish_ARG="es_AR",a.Spanish_SPA="es_ES",a.Spanish_MEX="es_MX",a.Swahili="sw",a.Swedish="sv",a.Tamil="ta",a.Telugu="te",a.Thai="th",a.Turkish="tr",a.Ukrainian="uk",a.Urdu="ur",a.Uzbek="uz",a.Vietnamese="vi",a.Zulu="zu",a))(ae||{}),re=(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))(re||{}),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 me="BaseAPI",be=!1,Ie=new P(me,process.env.DEBUG==="true"||be),p=class{config;client;constructor(t,s){this.config=t,this.client=s,Ie.log("Initialized with HTTPSClient")}sendJson(t,s,i,o){return this.client.getJson(t,s,i,o)}};var S=r=>{if(!r||Object.keys(r).length===0)return"";let t=new URLSearchParams;for(let[i,o]of Object.entries(r))o!==void 0&&t.append(i,String(o));let s=t.toString();return s?`?${s}`:""};var T=class extends p{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?S({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let o=S({file_length:t,file_type:s,file_name:i});return this.sendJson("POST",`app/uploads/${o}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var m=class extends p{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var Ne="FlowAPI",_e=!1,le=new P(Ne,process.env.DEBUG==="true"||_e),b=class extends p{constructor(t,s){super(t,s),le.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i={name:s.name,categories:s.categories,...s.endpoint_uri&&{endpoint_uri:s.endpoint_uri},...s.clone_flow_id&&{clone_flow_id:s.clone_flow_id},...s.flow_json&&{flow_json:s.flow_json},...s.publish!==void 0&&{publish:s.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async getFlow(t,s,i){let o=new URLSearchParams;s&&o.append("fields",s),i&&o.append("date_format",i);let l=o.toString()?`?${o.toString()}`:"";return this.sendJson("GET",`/${t}${l}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,s=!1){let i=`preview.invalidate(${s})`;return this.getFlow(t,i)}async updateFlowMetadata(t,s){let i={...s.name&&{name:s.name},...s.categories&&{categories:s.categories},...s.endpoint_uri&&{endpoint_uri:s.endpoint_uri},...s.application_id&&{application_id:s.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData,o;if(s.file instanceof Buffer)o=new globalThis.Blob([s.file]),i.append("file",o);else if(typeof s.file=="object"&&!(s.file instanceof Blob))try{o=new globalThis.Blob([JSON.stringify(s.file,null,2)],{type:"application/json"}),i.append("file",o)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(s.file instanceof Blob)o=s.file,i.append("file",o);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return i.append("asset_type","FLOW_JSON"),i.append("name",s.name||"flow.json"),this.sendJson("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async validateFlowJson(t,s){try{let i=await this.updateFlowJson(t,{file:s}),o=!i.validation_errors||i.validation_errors.length===0;return{...i,valid:o}}catch(i){throw le.error("Error during Flow JSON validation attempt:",i),i}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i={source_waba_id:s.source_waba_id,...s.source_flow_names&&{source_flow_names:s.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};var I=class extends p{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var N=class extends p{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,o){let l={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return o&&(l.context={message_id:o}),l}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body: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:l}=t,A;return typeof s=="string"?A={body:s,preview_url:i}:A=s,this.send(JSON.stringify(this.bodyBuilder("text",A,o,l)))}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,l={messaging_product:"whatsapp",status:s,message_id:i,...o&&{typing_indicator:o}};return this.send(JSON.stringify(l))}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==="navigate"?s.action.parameters.flow_action_payload?.screen===void 0&&(s.action.parameters.flow_action_payload={...s.action.parameters.flow_action_payload,screen:"INIT"}):s.action.parameters.flow_action==="data_exchange"&&delete s.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,o)))}async reaction(t){let{messageId:s,emoji:i,to:o}=t,l={messaging_product:"whatsapp",recipient_type:"individual",to:o,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(l))}};var _=class extends p{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?S({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var M=class extends p{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var O=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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var B=class extends p{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${S(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${S(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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};function fe(r){if(!r)return"";let t="";return Array.isArray(r)?t=r.join(","):t=Object.entries(r).filter(([s,i])=>i).map(([s])=>s).join(","),t?`?fields=${t}`:""}var w=class extends p{constructor(t,s){super(t,s)}async getWabaAccount(t){let s=fe(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};var ce=require("https");var Me="HttpsClient",Oe=!1,Be=new P(Me,process.env.DEBUG==="true"||Oe),U=class{agent;constructor(){this.agent=new ce.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,o,l,A){let R=`https://${t}/${s}`,f=new AbortController,he=setTimeout(()=>f.abort(),l);try{let F=await fetch(R,{method:i,headers:o,body:A,signal:f.signal});return Be.log(`${i} : ${R} - ${JSON.stringify(F)}`),clearTimeout(he),new x(F)}catch(F){throw F}}},x=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 H(r){return r!=null&&typeof r=="object"&&"error"in r&&typeof r.error=="object"&&r.error!=null&&"message"in r.error&&typeof r.error.message=="string"&&"type"in r.error&&typeof r.error.type=="string"&&"code"in r.error&&typeof r.error.code=="number"&&"fbtrace_id"in r.error&&typeof r.error.fbtrace_id=="string"&&(!("error_data"in r.error)||typeof r.error.error_data=="object"&&r.error.error_data!=null&&"messaging_product"in r.error.error_data&&r.error.error_data.messaging_product==="whatsapp"&&"details"in r.error.error_data&&typeof r.error.error_data.details=="string")&&(!("error_subcode"in r.error)||typeof r.error.error_subcode=="number")}var De="REQUESTER",we=!1,Ue=new P(De,process.env.DEBUG==="true"||we),q=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,o,l,A){this.client=new U,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=o,this.businessAcctId=l,this.userAgent=A}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 l="application/json",A=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Ue.log(`${t} : ${A}`);try{let R=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(l),i,t==="POST"||t==="PUT"?o:void 0);if(!R.rawResponse().ok){let f=await R.json();throw H(f)?f:{name:"MetaError",message:"Unknown error occurred",error:{message:f.message||"Unknown error occurred",type:"UnknownError",code:R.statusCode(),fbtrace_id:""}}}return R}catch(R){throw H(R)?R:{name:"MetaError",message:R instanceof Error?R.message:"Network error occurred",error:{message:R instanceof Error?R.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}async getJson(t,s,i,o){return await(await this.sendRequest(t,s,i,o)).json()}};var qe="UTILS",Ge=!1,Re=new P(qe,process.env.DEBUG==="true"||Ge),Fe="graph.facebook.com",Je=3e3,We=30,Le=2e4,Ke=r=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!r?.accessToken)throw Re.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},ge=r=>{Ke(r);let t={WA_BASE_URL:process.env.WA_BASE_URL||Fe,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:r?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),WA_BUSINESS_ACCOUNT_ID:r?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:r?.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||"")||Je,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||We,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Le,DEBUG:process.env.DEBUG==="true"};return Re.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",J=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=K;constructor(t){this.config=ge(t),this.requester=new q(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 N(this.config,this.requester),this.templates=new B(this.config,this.requester),this.phoneNumber=new _(this.config,this.requester),this.qrCode=new M(this.config,this.requester),this.encryption=new m(this.config,this.requester),this.twoStepVerification=new D(this.config,this.requester),this.registration=new O(this.config,this.requester),this.media=new I(this.config,this.requester),this.waba=new w(this.config,this.requester),this.flow=new b(this.config,this.requester),this.businessProfile=new T(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
|