meta-cloud-api 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +210 -140
- 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/businessProfile.js +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/flow.js +1 -1
- package/dist/api/flow.mjs +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.mjs +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/messages.d.mts +1 -1
- package/dist/api/messages.d.ts +1 -1
- package/dist/api/phoneNumber.d.mts +1 -1
- package/dist/api/phoneNumber.d.ts +1 -1
- package/dist/api/phoneNumber.js +1 -1
- package/dist/api/phoneNumber.mjs +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/template.d.mts +1 -1
- package/dist/api/template.d.ts +1 -1
- package/dist/api/template.js +1 -1
- package/dist/api/template.mjs +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-BYfW0iLO.d.mts → enums-Bcd3jLw2.d.mts} +0 -1
- package/dist/{enums-BYfW0iLO.d.ts → enums-Bcd3jLw2.d.ts} +0 -1
- package/dist/httpsClient.d.mts +1 -1
- package/dist/httpsClient.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- 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 +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -1
- package/dist/request.mjs +1 -1
- package/dist/request.mjs.map +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 -6
- package/dist/types/config.d.ts +1 -6
- package/dist/types/config.js.map +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 +2 -2
- package/dist/types/index.d.ts +2 -2
- 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 +1 -1
- package/dist/types/media.d.ts +1 -1
- package/dist/types/messages.d.mts +1 -1
- package/dist/types/messages.d.ts +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 +2 -2
- package/dist/types/request.d.ts +2 -2
- package/dist/types/request.js.map +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/webhook.d.mts +42 -2
- package/dist/types/webhook.d.ts +42 -2
- package/dist/types/webhook.js.map +1 -1
- package/dist/types/webhook.mjs.map +1 -1
- package/dist/types/whatsapp.d.mts +1 -2
- package/dist/types/whatsapp.d.ts +1 -2
- package/dist/types/whatsapp.js.map +1 -1
- package/dist/utils/filters.d.mts +1 -1
- package/dist/utils/filters.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.js.map +1 -1
- package/dist/utils/importConfig.mjs +1 -1
- package/dist/utils/importConfig.mjs.map +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.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/webhook.d.mts +1 -1
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +1 -1
- package/dist/webhook.js.map +1 -1
- package/dist/webhook.mjs +1 -1
- package/dist/webhook.mjs.map +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,5 +1,5 @@
|
|
|
1
1
|
import { BaseClass } from './base.mjs';
|
|
2
|
-
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-
|
|
2
|
+
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-Bcd3jLw2.mjs';
|
|
3
3
|
import { GeneralRequestBody } from './request.mjs';
|
|
4
4
|
import './config.mjs';
|
|
5
5
|
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClass } from './base.js';
|
|
2
|
-
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-
|
|
2
|
+
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-Bcd3jLw2.js';
|
|
3
3
|
import { GeneralRequestBody } from './request.js';
|
|
4
4
|
import './config.js';
|
|
5
5
|
|
package/dist/types/qrCode.d.mts
CHANGED
package/dist/types/qrCode.d.ts
CHANGED
package/dist/types/request.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HttpMethodsEnum } from '../enums-
|
|
1
|
+
import { H as HttpMethodsEnum } from '../enums-Bcd3jLw2.mjs';
|
|
2
2
|
|
|
3
3
|
type GeneralRequestBody = Record<string, unknown>;
|
|
4
4
|
interface GeneralHeaderInterface {
|
|
@@ -40,7 +40,7 @@ interface Paging {
|
|
|
40
40
|
next: string;
|
|
41
41
|
}
|
|
42
42
|
declare class RequesterClass {
|
|
43
|
-
constructor(
|
|
43
|
+
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
44
44
|
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
|
|
45
45
|
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
46
46
|
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HttpMethodsEnum } from '../enums-
|
|
1
|
+
import { H as HttpMethodsEnum } from '../enums-Bcd3jLw2.js';
|
|
2
2
|
|
|
3
3
|
type GeneralRequestBody = Record<string, unknown>;
|
|
4
4
|
interface GeneralHeaderInterface {
|
|
@@ -40,7 +40,7 @@ interface Paging {
|
|
|
40
40
|
next: string;
|
|
41
41
|
}
|
|
42
42
|
declare class RequesterClass {
|
|
43
|
-
constructor(
|
|
43
|
+
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
|
|
44
44
|
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
|
|
45
45
|
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
46
46
|
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/request.ts"],"sourcesContent":["import { HttpMethodsEnum } from './enums';\n\nexport type GeneralRequestBody = Record<string, unknown>;\n\nexport interface GeneralHeaderInterface {\n /**\n * Authorization token. This is required for all HTTP requests made to the graph API.\n * @default 'Bearer '\n */\n Authorization: string;\n\n /**\n * Content type of the message being sent. This is required for all HTTP requests made to the graph API.\n * @default 'application/json'\n */\n 'Content-Type': string;\n\n /**\n * User agent field sent in all requests. This is used to gather SDK usage metrics and help\n * better triage support requests.\n * @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`\n */\n 'User-Agent': string;\n}\n\nexport interface RequesterResponseInterface<T> {\n json: () => Promise<T>;\n}\n\nexport interface ResponseSuccess {\n success: boolean;\n}\n\nexport interface ResponseData<T> {\n data: T;\n}\n\nexport interface ResponsePagination<T> {\n data: T[];\n paging: Paging;\n}\n\nexport interface Paging {\n cursors: {\n before: string;\n after: string;\n };\n next: string;\n}\n\nexport declare class RequesterClass {\n constructor(\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/request.ts"],"sourcesContent":["import { HttpMethodsEnum } from './enums';\n\nexport type GeneralRequestBody = Record<string, unknown>;\n\nexport interface GeneralHeaderInterface {\n /**\n * Authorization token. This is required for all HTTP requests made to the graph API.\n * @default 'Bearer '\n */\n Authorization: string;\n\n /**\n * Content type of the message being sent. This is required for all HTTP requests made to the graph API.\n * @default 'application/json'\n */\n 'Content-Type': string;\n\n /**\n * User agent field sent in all requests. This is used to gather SDK usage metrics and help\n * better triage support requests.\n * @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`\n */\n 'User-Agent': string;\n}\n\nexport interface RequesterResponseInterface<T> {\n json: () => Promise<T>;\n}\n\nexport interface ResponseSuccess {\n success: boolean;\n}\n\nexport interface ResponseData<T> {\n data: T;\n}\n\nexport interface ResponsePagination<T> {\n data: T[];\n paging: Paging;\n}\n\nexport interface Paging {\n cursors: {\n before: string;\n after: string;\n };\n next: string;\n}\n\nexport declare class RequesterClass {\n constructor(\n apiVersion: string,\n phoneNumberId: number,\n accessToken: string,\n businessAcctId: string,\n userAgent: string,\n );\n\n sendRequest: (\n method: HttpMethodsEnum,\n path: string,\n timeout: number,\n body?: GeneralRequestBody,\n contentType?: string,\n additionalHeaders?: Record<string, string>,\n ) => Promise<RequesterResponseInterface<unknown>>;\n\n getJson<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: GeneralRequestBody,\n additionalHeaders?: Record<string, string>,\n ): Promise<T>;\n\n sendFormData<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n formData: FormData,\n additionalHeaders?: Record<string, string>,\n ): Promise<T>;\n\n sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n formData: Record<string, string>,\n additionalHeaders?: Record<string, string>,\n ): Promise<T>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["request_exports","__toCommonJS"]}
|
|
@@ -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-Bcd3jLw2.mjs';
|
|
2
2
|
import { 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-Bcd3jLw2.js';
|
|
2
2
|
import { 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
package/dist/types/webhook.d.mts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { M as MessageTypesEnum } from '../enums-
|
|
1
|
+
import { M as MessageTypesEnum } from '../enums-Bcd3jLw2.mjs';
|
|
2
2
|
|
|
3
|
+
interface WebhookContact {
|
|
4
|
+
/**
|
|
5
|
+
* WhatsApp ID of the contact. Business can respond to this contact using this ID.
|
|
6
|
+
*/
|
|
7
|
+
wa_id: string;
|
|
8
|
+
/**
|
|
9
|
+
* Additional unique, alphanumeric identifier for a WhatsApp user
|
|
10
|
+
*/
|
|
11
|
+
user_id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Profile of Whatsapp user
|
|
14
|
+
*/
|
|
15
|
+
profile: {
|
|
16
|
+
/**
|
|
17
|
+
* The display name of the contact
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
3
22
|
/**
|
|
4
23
|
* Represents a message received through the webhook
|
|
5
24
|
* Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
|
|
@@ -143,6 +162,19 @@ interface WebhookMessage {
|
|
|
143
162
|
*/
|
|
144
163
|
mime_type: string;
|
|
145
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* Reaction object for reaction messages
|
|
167
|
+
*/
|
|
168
|
+
reaction?: {
|
|
169
|
+
/**
|
|
170
|
+
* The ID of the message being reacted to
|
|
171
|
+
*/
|
|
172
|
+
message_id: string;
|
|
173
|
+
/**
|
|
174
|
+
* Emoji used for the reaction
|
|
175
|
+
*/
|
|
176
|
+
emoji: string;
|
|
177
|
+
};
|
|
146
178
|
/**
|
|
147
179
|
* Contacts object for contact messages
|
|
148
180
|
*/
|
|
@@ -332,6 +364,14 @@ interface WebhookMessage {
|
|
|
332
364
|
* Context object, included when a user replies or interacts
|
|
333
365
|
*/
|
|
334
366
|
context?: {
|
|
367
|
+
/**
|
|
368
|
+
* ID of the message
|
|
369
|
+
*/
|
|
370
|
+
id?: string;
|
|
371
|
+
/**
|
|
372
|
+
* ID of the sender
|
|
373
|
+
*/
|
|
374
|
+
from?: string;
|
|
335
375
|
/**
|
|
336
376
|
* ID of the message being replied to or interacted with
|
|
337
377
|
*/
|
|
@@ -443,4 +483,4 @@ declare enum EventField {
|
|
|
443
483
|
UNKNOWN = "unknown"
|
|
444
484
|
}
|
|
445
485
|
|
|
446
|
-
export { EventField, type EventHandler, type MessageHandler, MessageStatus, type WebhookEvent, type WebhookMessage };
|
|
486
|
+
export { EventField, type EventHandler, type MessageHandler, MessageStatus, type WebhookContact, type WebhookEvent, type WebhookMessage };
|
package/dist/types/webhook.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { M as MessageTypesEnum } from '../enums-
|
|
1
|
+
import { M as MessageTypesEnum } from '../enums-Bcd3jLw2.js';
|
|
2
2
|
|
|
3
|
+
interface WebhookContact {
|
|
4
|
+
/**
|
|
5
|
+
* WhatsApp ID of the contact. Business can respond to this contact using this ID.
|
|
6
|
+
*/
|
|
7
|
+
wa_id: string;
|
|
8
|
+
/**
|
|
9
|
+
* Additional unique, alphanumeric identifier for a WhatsApp user
|
|
10
|
+
*/
|
|
11
|
+
user_id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Profile of Whatsapp user
|
|
14
|
+
*/
|
|
15
|
+
profile: {
|
|
16
|
+
/**
|
|
17
|
+
* The display name of the contact
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
3
22
|
/**
|
|
4
23
|
* Represents a message received through the webhook
|
|
5
24
|
* Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
|
|
@@ -143,6 +162,19 @@ interface WebhookMessage {
|
|
|
143
162
|
*/
|
|
144
163
|
mime_type: string;
|
|
145
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* Reaction object for reaction messages
|
|
167
|
+
*/
|
|
168
|
+
reaction?: {
|
|
169
|
+
/**
|
|
170
|
+
* The ID of the message being reacted to
|
|
171
|
+
*/
|
|
172
|
+
message_id: string;
|
|
173
|
+
/**
|
|
174
|
+
* Emoji used for the reaction
|
|
175
|
+
*/
|
|
176
|
+
emoji: string;
|
|
177
|
+
};
|
|
146
178
|
/**
|
|
147
179
|
* Contacts object for contact messages
|
|
148
180
|
*/
|
|
@@ -332,6 +364,14 @@ interface WebhookMessage {
|
|
|
332
364
|
* Context object, included when a user replies or interacts
|
|
333
365
|
*/
|
|
334
366
|
context?: {
|
|
367
|
+
/**
|
|
368
|
+
* ID of the message
|
|
369
|
+
*/
|
|
370
|
+
id?: string;
|
|
371
|
+
/**
|
|
372
|
+
* ID of the sender
|
|
373
|
+
*/
|
|
374
|
+
from?: string;
|
|
335
375
|
/**
|
|
336
376
|
* ID of the message being replied to or interacted with
|
|
337
377
|
*/
|
|
@@ -443,4 +483,4 @@ declare enum EventField {
|
|
|
443
483
|
UNKNOWN = "unknown"
|
|
444
484
|
}
|
|
445
485
|
|
|
446
|
-
export { EventField, type EventHandler, type MessageHandler, MessageStatus, type WebhookEvent, type WebhookMessage };
|
|
486
|
+
export { EventField, type EventHandler, type MessageHandler, MessageStatus, type WebhookContact, type WebhookEvent, type WebhookMessage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/webhook.ts"],"sourcesContent":["import { MessageTypesEnum } from './enums';\n\n/**\n * Represents a message received through the webhook\n * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object\n */\nexport interface WebhookMessage {\n /**\n * The message ID\n */\n id: string;\n\n /**\n * The sender's phone number\n */\n from: string;\n\n /**\n * The timestamp of the message\n */\n timestamp: string;\n\n /**\n * The type of message (text, image, etc.)\n */\n type: MessageTypesEnum;\n\n /**\n * The phone number ID that received the message\n */\n phoneNumberId: string;\n\n /**\n * The display phone number that received the message\n */\n displayPhoneNumber: string;\n\n /**\n * The profile name of the sender\n */\n profileName: string;\n\n /**\n * Text object for text messages\n */\n text?: {\n /**\n * The text content of the message\n */\n body: string;\n };\n\n /**\n * Image object for image messages\n */\n image?: {\n /**\n * The image caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the image\n */\n sha256?: string;\n /**\n * The ID for the image\n */\n id: string;\n /**\n * The MIME type of the image\n */\n mime_type: string;\n };\n\n /**\n * Video object for video messages\n */\n video?: {\n /**\n * The video caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the video\n */\n sha256?: string;\n /**\n * The ID for the video\n */\n id: string;\n /**\n * The MIME type of the video\n */\n mime_type: string;\n };\n\n /**\n * Audio object for audio messages\n */\n audio?: {\n /**\n * The ID for the audio file\n */\n id: string;\n /**\n * The MIME type of the audio file\n */\n mime_type: string;\n /**\n * Whether the audio is a voice message\n */\n voice?: boolean;\n };\n\n /**\n * Document object for document messages\n */\n document?: {\n /**\n * The document caption (if provided)\n */\n caption?: string;\n /**\n * The document filename\n */\n filename: string;\n /**\n * The SHA256 hash of the document\n */\n sha256?: string;\n /**\n * The ID for the document\n */\n id: string;\n /**\n * The MIME type of the document\n */\n mime_type: string;\n };\n\n /**\n * Sticker object for sticker messages\n */\n sticker?: {\n /**\n * The ID for the sticker\n */\n id: string;\n /**\n * Whether this is an animated sticker\n */\n animated: boolean;\n /**\n * The MIME type of the sticker\n */\n mime_type: string;\n };\n\n /**\n * Contacts object for contact messages\n */\n contacts?: Array<{\n /**\n * The contact's name\n */\n name: {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n };\n /**\n * The contact's phone numbers\n */\n phones?: Array<{\n phone: string;\n type?: string;\n wa_id?: string;\n }>;\n /**\n * The contact's emails\n */\n emails?: Array<{\n email: string;\n type?: string;\n }>;\n /**\n * The contact's addresses\n */\n addresses?: Array<{\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: string;\n }>;\n /**\n * The contact's organizations\n */\n org?: {\n company?: string;\n department?: string;\n title?: string;\n };\n /**\n * The contact's URLs\n */\n urls?: Array<{\n url: string;\n type?: string;\n }>;\n /**\n * The contact's birthday (YYYY-MM-DD format)\n */\n birthday?: string;\n }>;\n\n /**\n * Location object for location messages\n */\n location?: {\n /**\n * Latitude of the location\n */\n latitude: number;\n /**\n * Longitude of the location\n */\n longitude: number;\n /**\n * Name of the location\n */\n name?: string;\n /**\n * Address of the location\n */\n address?: string;\n };\n\n /**\n * Interactive object for interactive messages\n */\n interactive?: {\n /**\n * Type of the interactive message\n * Can be: button_reply, list_reply, flow, nfm_reply, etc.\n */\n type: string;\n /**\n * ID for the button that was clicked\n */\n button_reply?: {\n id: string;\n title: string;\n };\n /**\n * ID for the list item that was selected\n */\n list_reply?: {\n id: string;\n title: string;\n description?: string;\n };\n\n /**\n * NFM (No-Code Flow Message) reply data\n */\n nfm_reply?: {\n /**\n * Response data in JSON format\n */\n response_json: string;\n /**\n * Body text of the reply\n */\n body: string;\n /**\n * Name of the flow\n */\n name: string;\n };\n };\n\n /**\n * System object for system messages (like user phone number changes)\n */\n system?: {\n /**\n * The type of system update\n */\n type: string;\n /**\n * User's identity if the update is a customer identity change\n */\n identity?: string;\n /**\n * Old and new phone numbers if the update is a phone number change\n */\n customer?: {\n /**\n * The previous phone number\n */\n previous_wa_id: string;\n /**\n * The new phone number\n */\n wa_id: string;\n };\n };\n\n /**\n * Order object for order messages\n */\n order?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product items in the order\n */\n product_items: Array<{\n /**\n * Product ID\n */\n product_retailer_id: string;\n /**\n * Quantity of the product\n */\n quantity: number;\n /**\n * Item price\n */\n item_price: number;\n /**\n * Currency code\n */\n currency: string;\n }>;\n /**\n * Text message included with the order\n */\n text?: string;\n };\n\n /**\n * Context object, included when a user replies or interacts\n */\n context?: {\n /**\n * ID of the message being replied to or interacted with\n */\n message_id: string;\n /**\n * ID of the forwarded message, if applicable\n */\n forwarded?: boolean;\n /**\n * Frequently forwarded status\n */\n frequently_forwarded?: boolean;\n /**\n * Original message information if the message was referred\n */\n referred_product?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product ID\n */\n product_retailer_id: string;\n };\n };\n\n /**\n * Errors array, if the message had errors\n */\n errors?: Array<{\n /**\n * Error code\n */\n code: number;\n /**\n * Error title\n */\n title: string;\n /**\n * Error message\n */\n message: string;\n /**\n * Error details object\n */\n error_data?: {\n /**\n * Describes the error details\n */\n details: string;\n };\n }>;\n\n /**\n * Button object for button messages\n */\n button?: {\n /**\n * The payload for the button\n */\n payload: string;\n /**\n * Button text\n */\n text: string;\n };\n\n /**\n * The original message data as received from the webhook\n */\n originalData: any;\n}\n\n/**\n * Represents a non-message event received through the webhook\n */\nexport interface WebhookEvent {\n /**\n * The field type of the event\n */\n field: string;\n\n /**\n * The event data\n */\n value: any;\n}\n\n/**\n * Handler function for processing messages\n */\nexport type MessageHandler = (message: WebhookMessage) => void | Promise<void>;\n\n/**\n * Handler function for processing events\n */\nexport type EventHandler = (event: WebhookEvent) => void | Promise<void>;\n\n/**\n * Statuses that can be received in status updates\n */\nexport enum MessageStatus {\n DELIVERED = 'delivered',\n READ = 'read',\n SENT = 'sent',\n}\n\n/**\n * Event fields that can be received through the webhook\n */\nexport enum EventField {\n MESSAGES = 'messages',\n STATUSES = 'statuses',\n MESSAGE_TEMPLATE_STATUS_UPDATE = 'message_template_status_update',\n PHONE_NUMBER_QUALITY_UPDATE = 'phone_number_quality_update',\n PHONE_NUMBER_NAME_UPDATE = 'phone_number_name_update',\n UNKNOWN = 'unknown',\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GAucO,IAAKG,OACRA,EAAA,UAAY,YACZA,EAAA,KAAO,OACPA,EAAA,KAAO,OAHCA,OAAA,IASAD,OACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,+BAAiC,iCACjCA,EAAA,4BAA8B,8BAC9BA,EAAA,yBAA2B,2BAC3BA,EAAA,QAAU,UANFA,OAAA","names":["webhook_exports","__export","EventField","MessageStatus","__toCommonJS"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/webhook.ts"],"sourcesContent":["import { MessageTypesEnum } from './enums';\n\nexport interface WebhookContact {\n /**\n * WhatsApp ID of the contact. Business can respond to this contact using this ID.\n */\n wa_id: string;\n /**\n * Additional unique, alphanumeric identifier for a WhatsApp user\n */\n user_id?: string;\n /**\n * Profile of Whatsapp user\n */\n profile: {\n /**\n * The display name of the contact\n */\n name: string;\n };\n}\n\n/**\n * Represents a message received through the webhook\n * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object\n */\nexport interface WebhookMessage {\n /**\n * The message ID\n */\n id: string;\n\n /**\n * The sender's phone number\n */\n from: string;\n\n /**\n * The timestamp of the message\n */\n timestamp: string;\n\n /**\n * The type of message (text, image, etc.)\n */\n type: MessageTypesEnum;\n\n /**\n * The phone number ID that received the message\n */\n phoneNumberId: string;\n\n /**\n * The display phone number that received the message\n */\n displayPhoneNumber: string;\n\n /**\n * The profile name of the sender\n */\n profileName: string;\n\n /**\n * Text object for text messages\n */\n text?: {\n /**\n * The text content of the message\n */\n body: string;\n };\n\n /**\n * Image object for image messages\n */\n image?: {\n /**\n * The image caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the image\n */\n sha256?: string;\n /**\n * The ID for the image\n */\n id: string;\n /**\n * The MIME type of the image\n */\n mime_type: string;\n };\n\n /**\n * Video object for video messages\n */\n video?: {\n /**\n * The video caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the video\n */\n sha256?: string;\n /**\n * The ID for the video\n */\n id: string;\n /**\n * The MIME type of the video\n */\n mime_type: string;\n };\n\n /**\n * Audio object for audio messages\n */\n audio?: {\n /**\n * The ID for the audio file\n */\n id: string;\n /**\n * The MIME type of the audio file\n */\n mime_type: string;\n /**\n * Whether the audio is a voice message\n */\n voice?: boolean;\n };\n\n /**\n * Document object for document messages\n */\n document?: {\n /**\n * The document caption (if provided)\n */\n caption?: string;\n /**\n * The document filename\n */\n filename: string;\n /**\n * The SHA256 hash of the document\n */\n sha256?: string;\n /**\n * The ID for the document\n */\n id: string;\n /**\n * The MIME type of the document\n */\n mime_type: string;\n };\n\n /**\n * Sticker object for sticker messages\n */\n sticker?: {\n /**\n * The ID for the sticker\n */\n id: string;\n /**\n * Whether this is an animated sticker\n */\n animated: boolean;\n /**\n * The MIME type of the sticker\n */\n mime_type: string;\n };\n\n /**\n * Reaction object for reaction messages\n */\n reaction?: {\n /**\n * The ID of the message being reacted to\n */\n message_id: string;\n /**\n * Emoji used for the reaction\n */\n emoji: string;\n };\n\n /**\n * Contacts object for contact messages\n */\n contacts?: Array<{\n /**\n * The contact's name\n */\n name: {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n };\n /**\n * The contact's phone numbers\n */\n phones?: Array<{\n phone: string;\n type?: string;\n wa_id?: string;\n }>;\n /**\n * The contact's emails\n */\n emails?: Array<{\n email: string;\n type?: string;\n }>;\n /**\n * The contact's addresses\n */\n addresses?: Array<{\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: string;\n }>;\n /**\n * The contact's organizations\n */\n org?: {\n company?: string;\n department?: string;\n title?: string;\n };\n /**\n * The contact's URLs\n */\n urls?: Array<{\n url: string;\n type?: string;\n }>;\n /**\n * The contact's birthday (YYYY-MM-DD format)\n */\n birthday?: string;\n }>;\n\n /**\n * Location object for location messages\n */\n location?: {\n /**\n * Latitude of the location\n */\n latitude: number;\n /**\n * Longitude of the location\n */\n longitude: number;\n /**\n * Name of the location\n */\n name?: string;\n /**\n * Address of the location\n */\n address?: string;\n };\n\n /**\n * Interactive object for interactive messages\n */\n interactive?: {\n /**\n * Type of the interactive message\n * Can be: button_reply, list_reply, flow, nfm_reply, etc.\n */\n type: string;\n /**\n * ID for the button that was clicked\n */\n button_reply?: {\n id: string;\n title: string;\n };\n /**\n * ID for the list item that was selected\n */\n list_reply?: {\n id: string;\n title: string;\n description?: string;\n };\n\n /**\n * NFM (No-Code Flow Message) reply data\n */\n nfm_reply?: {\n /**\n * Response data in JSON format\n */\n response_json: string;\n /**\n * Body text of the reply\n */\n body: string;\n /**\n * Name of the flow\n */\n name: string;\n };\n };\n\n /**\n * System object for system messages (like user phone number changes)\n */\n system?: {\n /**\n * The type of system update\n */\n type: string;\n /**\n * User's identity if the update is a customer identity change\n */\n identity?: string;\n /**\n * Old and new phone numbers if the update is a phone number change\n */\n customer?: {\n /**\n * The previous phone number\n */\n previous_wa_id: string;\n /**\n * The new phone number\n */\n wa_id: string;\n };\n };\n\n /**\n * Order object for order messages\n */\n order?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product items in the order\n */\n product_items: Array<{\n /**\n * Product ID\n */\n product_retailer_id: string;\n /**\n * Quantity of the product\n */\n quantity: number;\n /**\n * Item price\n */\n item_price: number;\n /**\n * Currency code\n */\n currency: string;\n }>;\n /**\n * Text message included with the order\n */\n text?: string;\n };\n\n /**\n * Context object, included when a user replies or interacts\n */\n context?: {\n /**\n * ID of the message\n */\n id?: string;\n /**\n * ID of the sender\n */\n from?: string;\n /**\n * ID of the message being replied to or interacted with\n */\n message_id: string;\n /**\n * ID of the forwarded message, if applicable\n */\n forwarded?: boolean;\n /**\n * Frequently forwarded status\n */\n frequently_forwarded?: boolean;\n /**\n * Original message information if the message was referred\n */\n referred_product?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product ID\n */\n product_retailer_id: string;\n };\n };\n\n /**\n * Errors array, if the message had errors\n */\n errors?: Array<{\n /**\n * Error code\n */\n code: number;\n /**\n * Error title\n */\n title: string;\n /**\n * Error message\n */\n message: string;\n /**\n * Error details object\n */\n error_data?: {\n /**\n * Describes the error details\n */\n details: string;\n };\n }>;\n\n /**\n * Button object for button messages\n */\n button?: {\n /**\n * The payload for the button\n */\n payload: string;\n /**\n * Button text\n */\n text: string;\n };\n\n /**\n * The original message data as received from the webhook\n */\n originalData: any;\n}\n\n/**\n * Represents a non-message event received through the webhook\n */\nexport interface WebhookEvent {\n /**\n * The field type of the event\n */\n field: string;\n\n /**\n * The event data\n */\n value: any;\n}\n\n/**\n * Handler function for processing messages\n */\nexport type MessageHandler = (message: WebhookMessage) => void | Promise<void>;\n\n/**\n * Handler function for processing events\n */\nexport type EventHandler = (event: WebhookEvent) => void | Promise<void>;\n\n/**\n * Statuses that can be received in status updates\n */\nexport enum MessageStatus {\n DELIVERED = 'delivered',\n READ = 'read',\n SENT = 'sent',\n}\n\n/**\n * Event fields that can be received through the webhook\n */\nexport enum EventField {\n MESSAGES = 'messages',\n STATUSES = 'statuses',\n MESSAGE_TEMPLATE_STATUS_UPDATE = 'message_template_status_update',\n PHONE_NUMBER_QUALITY_UPDATE = 'phone_number_quality_update',\n PHONE_NUMBER_NAME_UPDATE = 'phone_number_name_update',\n UNKNOWN = 'unknown',\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GAifO,IAAKG,OACRA,EAAA,UAAY,YACZA,EAAA,KAAO,OACPA,EAAA,KAAO,OAHCA,OAAA,IASAD,OACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,+BAAiC,iCACjCA,EAAA,4BAA8B,8BAC9BA,EAAA,yBAA2B,2BAC3BA,EAAA,QAAU,UANFA,OAAA","names":["webhook_exports","__export","EventField","MessageStatus","__toCommonJS"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/webhook.ts"],"sourcesContent":["import { MessageTypesEnum } from './enums';\n\n/**\n * Represents a message received through the webhook\n * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object\n */\nexport interface WebhookMessage {\n /**\n * The message ID\n */\n id: string;\n\n /**\n * The sender's phone number\n */\n from: string;\n\n /**\n * The timestamp of the message\n */\n timestamp: string;\n\n /**\n * The type of message (text, image, etc.)\n */\n type: MessageTypesEnum;\n\n /**\n * The phone number ID that received the message\n */\n phoneNumberId: string;\n\n /**\n * The display phone number that received the message\n */\n displayPhoneNumber: string;\n\n /**\n * The profile name of the sender\n */\n profileName: string;\n\n /**\n * Text object for text messages\n */\n text?: {\n /**\n * The text content of the message\n */\n body: string;\n };\n\n /**\n * Image object for image messages\n */\n image?: {\n /**\n * The image caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the image\n */\n sha256?: string;\n /**\n * The ID for the image\n */\n id: string;\n /**\n * The MIME type of the image\n */\n mime_type: string;\n };\n\n /**\n * Video object for video messages\n */\n video?: {\n /**\n * The video caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the video\n */\n sha256?: string;\n /**\n * The ID for the video\n */\n id: string;\n /**\n * The MIME type of the video\n */\n mime_type: string;\n };\n\n /**\n * Audio object for audio messages\n */\n audio?: {\n /**\n * The ID for the audio file\n */\n id: string;\n /**\n * The MIME type of the audio file\n */\n mime_type: string;\n /**\n * Whether the audio is a voice message\n */\n voice?: boolean;\n };\n\n /**\n * Document object for document messages\n */\n document?: {\n /**\n * The document caption (if provided)\n */\n caption?: string;\n /**\n * The document filename\n */\n filename: string;\n /**\n * The SHA256 hash of the document\n */\n sha256?: string;\n /**\n * The ID for the document\n */\n id: string;\n /**\n * The MIME type of the document\n */\n mime_type: string;\n };\n\n /**\n * Sticker object for sticker messages\n */\n sticker?: {\n /**\n * The ID for the sticker\n */\n id: string;\n /**\n * Whether this is an animated sticker\n */\n animated: boolean;\n /**\n * The MIME type of the sticker\n */\n mime_type: string;\n };\n\n /**\n * Contacts object for contact messages\n */\n contacts?: Array<{\n /**\n * The contact's name\n */\n name: {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n };\n /**\n * The contact's phone numbers\n */\n phones?: Array<{\n phone: string;\n type?: string;\n wa_id?: string;\n }>;\n /**\n * The contact's emails\n */\n emails?: Array<{\n email: string;\n type?: string;\n }>;\n /**\n * The contact's addresses\n */\n addresses?: Array<{\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: string;\n }>;\n /**\n * The contact's organizations\n */\n org?: {\n company?: string;\n department?: string;\n title?: string;\n };\n /**\n * The contact's URLs\n */\n urls?: Array<{\n url: string;\n type?: string;\n }>;\n /**\n * The contact's birthday (YYYY-MM-DD format)\n */\n birthday?: string;\n }>;\n\n /**\n * Location object for location messages\n */\n location?: {\n /**\n * Latitude of the location\n */\n latitude: number;\n /**\n * Longitude of the location\n */\n longitude: number;\n /**\n * Name of the location\n */\n name?: string;\n /**\n * Address of the location\n */\n address?: string;\n };\n\n /**\n * Interactive object for interactive messages\n */\n interactive?: {\n /**\n * Type of the interactive message\n * Can be: button_reply, list_reply, flow, nfm_reply, etc.\n */\n type: string;\n /**\n * ID for the button that was clicked\n */\n button_reply?: {\n id: string;\n title: string;\n };\n /**\n * ID for the list item that was selected\n */\n list_reply?: {\n id: string;\n title: string;\n description?: string;\n };\n\n /**\n * NFM (No-Code Flow Message) reply data\n */\n nfm_reply?: {\n /**\n * Response data in JSON format\n */\n response_json: string;\n /**\n * Body text of the reply\n */\n body: string;\n /**\n * Name of the flow\n */\n name: string;\n };\n };\n\n /**\n * System object for system messages (like user phone number changes)\n */\n system?: {\n /**\n * The type of system update\n */\n type: string;\n /**\n * User's identity if the update is a customer identity change\n */\n identity?: string;\n /**\n * Old and new phone numbers if the update is a phone number change\n */\n customer?: {\n /**\n * The previous phone number\n */\n previous_wa_id: string;\n /**\n * The new phone number\n */\n wa_id: string;\n };\n };\n\n /**\n * Order object for order messages\n */\n order?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product items in the order\n */\n product_items: Array<{\n /**\n * Product ID\n */\n product_retailer_id: string;\n /**\n * Quantity of the product\n */\n quantity: number;\n /**\n * Item price\n */\n item_price: number;\n /**\n * Currency code\n */\n currency: string;\n }>;\n /**\n * Text message included with the order\n */\n text?: string;\n };\n\n /**\n * Context object, included when a user replies or interacts\n */\n context?: {\n /**\n * ID of the message being replied to or interacted with\n */\n message_id: string;\n /**\n * ID of the forwarded message, if applicable\n */\n forwarded?: boolean;\n /**\n * Frequently forwarded status\n */\n frequently_forwarded?: boolean;\n /**\n * Original message information if the message was referred\n */\n referred_product?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product ID\n */\n product_retailer_id: string;\n };\n };\n\n /**\n * Errors array, if the message had errors\n */\n errors?: Array<{\n /**\n * Error code\n */\n code: number;\n /**\n * Error title\n */\n title: string;\n /**\n * Error message\n */\n message: string;\n /**\n * Error details object\n */\n error_data?: {\n /**\n * Describes the error details\n */\n details: string;\n };\n }>;\n\n /**\n * Button object for button messages\n */\n button?: {\n /**\n * The payload for the button\n */\n payload: string;\n /**\n * Button text\n */\n text: string;\n };\n\n /**\n * The original message data as received from the webhook\n */\n originalData: any;\n}\n\n/**\n * Represents a non-message event received through the webhook\n */\nexport interface WebhookEvent {\n /**\n * The field type of the event\n */\n field: string;\n\n /**\n * The event data\n */\n value: any;\n}\n\n/**\n * Handler function for processing messages\n */\nexport type MessageHandler = (message: WebhookMessage) => void | Promise<void>;\n\n/**\n * Handler function for processing events\n */\nexport type EventHandler = (event: WebhookEvent) => void | Promise<void>;\n\n/**\n * Statuses that can be received in status updates\n */\nexport enum MessageStatus {\n DELIVERED = 'delivered',\n READ = 'read',\n SENT = 'sent',\n}\n\n/**\n * Event fields that can be received through the webhook\n */\nexport enum EventField {\n MESSAGES = 'messages',\n STATUSES = 'statuses',\n MESSAGE_TEMPLATE_STATUS_UPDATE = 'message_template_status_update',\n PHONE_NUMBER_QUALITY_UPDATE = 'phone_number_quality_update',\n PHONE_NUMBER_NAME_UPDATE = 'phone_number_name_update',\n UNKNOWN = 'unknown',\n}\n"],"mappings":"AAucO,IAAKA,OACRA,EAAA,UAAY,YACZA,EAAA,KAAO,OACPA,EAAA,KAAO,OAHCA,OAAA,IASAC,OACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,+BAAiC,iCACjCA,EAAA,4BAA8B,8BAC9BA,EAAA,yBAA2B,2BAC3BA,EAAA,QAAU,UANFA,OAAA","names":["MessageStatus","EventField"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/webhook.ts"],"sourcesContent":["import { MessageTypesEnum } from './enums';\n\nexport interface WebhookContact {\n /**\n * WhatsApp ID of the contact. Business can respond to this contact using this ID.\n */\n wa_id: string;\n /**\n * Additional unique, alphanumeric identifier for a WhatsApp user\n */\n user_id?: string;\n /**\n * Profile of Whatsapp user\n */\n profile: {\n /**\n * The display name of the contact\n */\n name: string;\n };\n}\n\n/**\n * Represents a message received through the webhook\n * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object\n */\nexport interface WebhookMessage {\n /**\n * The message ID\n */\n id: string;\n\n /**\n * The sender's phone number\n */\n from: string;\n\n /**\n * The timestamp of the message\n */\n timestamp: string;\n\n /**\n * The type of message (text, image, etc.)\n */\n type: MessageTypesEnum;\n\n /**\n * The phone number ID that received the message\n */\n phoneNumberId: string;\n\n /**\n * The display phone number that received the message\n */\n displayPhoneNumber: string;\n\n /**\n * The profile name of the sender\n */\n profileName: string;\n\n /**\n * Text object for text messages\n */\n text?: {\n /**\n * The text content of the message\n */\n body: string;\n };\n\n /**\n * Image object for image messages\n */\n image?: {\n /**\n * The image caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the image\n */\n sha256?: string;\n /**\n * The ID for the image\n */\n id: string;\n /**\n * The MIME type of the image\n */\n mime_type: string;\n };\n\n /**\n * Video object for video messages\n */\n video?: {\n /**\n * The video caption (if provided)\n */\n caption?: string;\n /**\n * The SHA256 hash of the video\n */\n sha256?: string;\n /**\n * The ID for the video\n */\n id: string;\n /**\n * The MIME type of the video\n */\n mime_type: string;\n };\n\n /**\n * Audio object for audio messages\n */\n audio?: {\n /**\n * The ID for the audio file\n */\n id: string;\n /**\n * The MIME type of the audio file\n */\n mime_type: string;\n /**\n * Whether the audio is a voice message\n */\n voice?: boolean;\n };\n\n /**\n * Document object for document messages\n */\n document?: {\n /**\n * The document caption (if provided)\n */\n caption?: string;\n /**\n * The document filename\n */\n filename: string;\n /**\n * The SHA256 hash of the document\n */\n sha256?: string;\n /**\n * The ID for the document\n */\n id: string;\n /**\n * The MIME type of the document\n */\n mime_type: string;\n };\n\n /**\n * Sticker object for sticker messages\n */\n sticker?: {\n /**\n * The ID for the sticker\n */\n id: string;\n /**\n * Whether this is an animated sticker\n */\n animated: boolean;\n /**\n * The MIME type of the sticker\n */\n mime_type: string;\n };\n\n /**\n * Reaction object for reaction messages\n */\n reaction?: {\n /**\n * The ID of the message being reacted to\n */\n message_id: string;\n /**\n * Emoji used for the reaction\n */\n emoji: string;\n };\n\n /**\n * Contacts object for contact messages\n */\n contacts?: Array<{\n /**\n * The contact's name\n */\n name: {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n };\n /**\n * The contact's phone numbers\n */\n phones?: Array<{\n phone: string;\n type?: string;\n wa_id?: string;\n }>;\n /**\n * The contact's emails\n */\n emails?: Array<{\n email: string;\n type?: string;\n }>;\n /**\n * The contact's addresses\n */\n addresses?: Array<{\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: string;\n }>;\n /**\n * The contact's organizations\n */\n org?: {\n company?: string;\n department?: string;\n title?: string;\n };\n /**\n * The contact's URLs\n */\n urls?: Array<{\n url: string;\n type?: string;\n }>;\n /**\n * The contact's birthday (YYYY-MM-DD format)\n */\n birthday?: string;\n }>;\n\n /**\n * Location object for location messages\n */\n location?: {\n /**\n * Latitude of the location\n */\n latitude: number;\n /**\n * Longitude of the location\n */\n longitude: number;\n /**\n * Name of the location\n */\n name?: string;\n /**\n * Address of the location\n */\n address?: string;\n };\n\n /**\n * Interactive object for interactive messages\n */\n interactive?: {\n /**\n * Type of the interactive message\n * Can be: button_reply, list_reply, flow, nfm_reply, etc.\n */\n type: string;\n /**\n * ID for the button that was clicked\n */\n button_reply?: {\n id: string;\n title: string;\n };\n /**\n * ID for the list item that was selected\n */\n list_reply?: {\n id: string;\n title: string;\n description?: string;\n };\n\n /**\n * NFM (No-Code Flow Message) reply data\n */\n nfm_reply?: {\n /**\n * Response data in JSON format\n */\n response_json: string;\n /**\n * Body text of the reply\n */\n body: string;\n /**\n * Name of the flow\n */\n name: string;\n };\n };\n\n /**\n * System object for system messages (like user phone number changes)\n */\n system?: {\n /**\n * The type of system update\n */\n type: string;\n /**\n * User's identity if the update is a customer identity change\n */\n identity?: string;\n /**\n * Old and new phone numbers if the update is a phone number change\n */\n customer?: {\n /**\n * The previous phone number\n */\n previous_wa_id: string;\n /**\n * The new phone number\n */\n wa_id: string;\n };\n };\n\n /**\n * Order object for order messages\n */\n order?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product items in the order\n */\n product_items: Array<{\n /**\n * Product ID\n */\n product_retailer_id: string;\n /**\n * Quantity of the product\n */\n quantity: number;\n /**\n * Item price\n */\n item_price: number;\n /**\n * Currency code\n */\n currency: string;\n }>;\n /**\n * Text message included with the order\n */\n text?: string;\n };\n\n /**\n * Context object, included when a user replies or interacts\n */\n context?: {\n /**\n * ID of the message\n */\n id?: string;\n /**\n * ID of the sender\n */\n from?: string;\n /**\n * ID of the message being replied to or interacted with\n */\n message_id: string;\n /**\n * ID of the forwarded message, if applicable\n */\n forwarded?: boolean;\n /**\n * Frequently forwarded status\n */\n frequently_forwarded?: boolean;\n /**\n * Original message information if the message was referred\n */\n referred_product?: {\n /**\n * Catalog ID\n */\n catalog_id: string;\n /**\n * Product ID\n */\n product_retailer_id: string;\n };\n };\n\n /**\n * Errors array, if the message had errors\n */\n errors?: Array<{\n /**\n * Error code\n */\n code: number;\n /**\n * Error title\n */\n title: string;\n /**\n * Error message\n */\n message: string;\n /**\n * Error details object\n */\n error_data?: {\n /**\n * Describes the error details\n */\n details: string;\n };\n }>;\n\n /**\n * Button object for button messages\n */\n button?: {\n /**\n * The payload for the button\n */\n payload: string;\n /**\n * Button text\n */\n text: string;\n };\n\n /**\n * The original message data as received from the webhook\n */\n originalData: any;\n}\n\n/**\n * Represents a non-message event received through the webhook\n */\nexport interface WebhookEvent {\n /**\n * The field type of the event\n */\n field: string;\n\n /**\n * The event data\n */\n value: any;\n}\n\n/**\n * Handler function for processing messages\n */\nexport type MessageHandler = (message: WebhookMessage) => void | Promise<void>;\n\n/**\n * Handler function for processing events\n */\nexport type EventHandler = (event: WebhookEvent) => void | Promise<void>;\n\n/**\n * Statuses that can be received in status updates\n */\nexport enum MessageStatus {\n DELIVERED = 'delivered',\n READ = 'read',\n SENT = 'sent',\n}\n\n/**\n * Event fields that can be received through the webhook\n */\nexport enum EventField {\n MESSAGES = 'messages',\n STATUSES = 'statuses',\n MESSAGE_TEMPLATE_STATUS_UPDATE = 'message_template_status_update',\n PHONE_NUMBER_QUALITY_UPDATE = 'phone_number_quality_update',\n PHONE_NUMBER_NAME_UPDATE = 'phone_number_name_update',\n UNKNOWN = 'unknown',\n}\n"],"mappings":"AAifO,IAAKA,OACRA,EAAA,UAAY,YACZA,EAAA,KAAO,OACPA,EAAA,KAAO,OAHCA,OAAA,IASAC,OACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,+BAAiC,iCACjCA,EAAA,4BAA8B,8BAC9BA,EAAA,yBAA2B,2BAC3BA,EAAA,QAAU,UANFA,OAAA","names":["MessageStatus","EventField"]}
|
|
@@ -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-Bcd3jLw2.mjs';
|
|
13
13
|
import './request.mjs';
|
|
14
14
|
import './base.mjs';
|
|
15
15
|
import './config.mjs';
|
|
@@ -24,7 +24,6 @@ import './config.mjs';
|
|
|
24
24
|
|
|
25
25
|
type WhatsAppConfig = {
|
|
26
26
|
accessToken: string;
|
|
27
|
-
baseUrl?: string;
|
|
28
27
|
appId?: string;
|
|
29
28
|
appSecret?: string;
|
|
30
29
|
phoneNumberId?: number;
|
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-Bcd3jLw2.js';
|
|
13
13
|
import './request.js';
|
|
14
14
|
import './base.js';
|
|
15
15
|
import './config.js';
|
|
@@ -24,7 +24,6 @@ import './config.js';
|
|
|
24
24
|
|
|
25
25
|
type WhatsAppConfig = {
|
|
26
26
|
accessToken: string;
|
|
27
|
-
baseUrl?: string;
|
|
28
27
|
appId?: string;
|
|
29
28
|
appSecret?: string;
|
|
30
29
|
phoneNumberId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/whatsapp.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 { BusinessProfileClass } from './businessProfile';\nimport { EncryptionClass } from './encryption';\nimport { FlowClass } from './flow';\nimport { MediaClass } from './media';\nimport { MessagesClass } from './messages';\nimport { PhoneNumberClass } from './phoneNumber';\nimport { QrCodeClass } from './qrCode';\nimport { RegistrationClass } from './registration';\nimport { TemplateClass } from './template';\nimport { TwoStepVerificationClass } from './twoStepVerification';\nimport { WABAClass } from './waba';\n\nexport type WhatsAppConfig = {\n accessToken: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/whatsapp.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 { BusinessProfileClass } from './businessProfile';\nimport { EncryptionClass } from './encryption';\nimport { FlowClass } from './flow';\nimport { MediaClass } from './media';\nimport { MessagesClass } from './messages';\nimport { PhoneNumberClass } from './phoneNumber';\nimport { QrCodeClass } from './qrCode';\nimport { RegistrationClass } from './registration';\nimport { TemplateClass } from './template';\nimport { TwoStepVerificationClass } from './twoStepVerification';\nimport { WABAClass } from './waba';\n\nexport type WhatsAppConfig = {\n accessToken: string;\n appId?: string;\n appSecret?: string;\n phoneNumberId?: number;\n businessAcctId?: string;\n apiVersion?: string;\n webhookEndpoint?: string;\n webhookVerificationToken?: string;\n listenerPort?: number;\n debug?: boolean;\n maxRetriesAfterWait?: number;\n requestTimeout?: number;\n};\n\nexport declare class WhatsAppClass {\n constructor(config?: WhatsAppConfig);\n readonly messages: MessagesClass;\n readonly templates: TemplateClass;\n readonly phoneNumber: PhoneNumberClass;\n readonly qrCode: QrCodeClass;\n readonly encryption: EncryptionClass;\n readonly twoStepVerification: TwoStepVerificationClass;\n readonly registration: RegistrationClass;\n readonly media: MediaClass;\n readonly waba: WABAClass;\n readonly flow: FlowClass;\n readonly businessProfile: BusinessProfileClass;\n updateTimeout(ms: number): boolean;\n updatePhoneNumberId(phoneNumberId: number): boolean;\n updateAccessToken(accessToken: string): boolean;\n updateWabaId(wabaId: string): boolean;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["whatsapp_exports","__toCommonJS"]}
|
package/dist/utils/filters.d.mts
CHANGED
package/dist/utils/filters.d.ts
CHANGED
|
@@ -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-Bcd3jLw2.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-Bcd3jLw2.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 O=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var B=(A,R)=>{for(var S in R)N(A,S,{get:R[S],enumerable:!0})},T=(A,R,S,U)=>{if(R&&typeof R=="object"||typeof R=="function")for(let D of t(R))!G.call(A,D)&&D!==S&&N(A,D,{get:()=>R[D],enumerable:!(U=O(R,D))||U.enumerable});return A};var _=A=>T(N({},"__esModule",{value:!0}),A);var X={};B(X,{importConfig:()=>L});module.exports=_(X);var P=class{name;debug;constructor(R,S=!1){this.name=R,this.debug=S}log(...R){if(this.debug){let S=`[ ${Date.now()} ]`;this.name&&(S+=` - ${this.name}`),console.log.apply(console,[S,": ",...R])}}error(...R){let S=`[ ${Date.now()} ] - ERROR`;this.name&&(S+=` - ${this.name}`),console.error.apply(console,[S,": ",...R])}warn(...R){let S=`[ ${Date.now()} ] - WARN`;this.name&&(S+=` - ${this.name}`),console.warn.apply(console,[S,": ",...R])}info(...R){let S=`[ ${Date.now()} ] - INFO`;this.name&&(S+=` - ${this.name}`),console.info.apply(console,[S,": ",...R])}};var K="UTILS",M=!1,I=new P(K,process.env.DEBUG==="true"||M),F=3e3,i=30,H=2e4,p=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw I.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},L=A=>{p(A);let R={M4D_APP_ID:A?.appId||process.env.M4D_APP_ID||"",M4D_APP_SECRET:A?.appSecret||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:A?.apiVersion||process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:A?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:A?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:A?.listenerPort||parseInt(process.env.LISTENER_PORT||"")||F,MAX_RETRIES_AFTER_WAIT:A?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||i,REQUEST_TIMEOUT:A?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||"")||H,DEBUG:A?.debug||process.env.DEBUG==="true"};return I.log(`Configuration loaded for App Id ${R.M4D_APP_ID}`),R};0&&(module.exports={importConfig});
|
|
2
2
|
//# sourceMappingURL=importConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst
|
|
1
|
+
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,EDxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACA,GAAQ,YACrD,MAAAN,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaO,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,WAAuBD,GAAa,OAAS,QAAQ,IAAI,YAAc,GACvE,eAA2BA,GAAa,WAAa,QAAQ,IAAI,gBAAkB,GACnF,mBAA+BA,GAAa,eAAiB,OAAO,QAAQ,IAAI,kBAAkB,EAClG,uBAAgCA,GAAa,gBAAkB,QAAQ,IAAI,wBAA0B,GACrG,kBAA4BA,GAAa,YAAc,QAAQ,IAAI,mBAAqB,GACxF,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiCA,GAAa,iBAAmB,QAAQ,IAAI,kBAAoB,GACjG,2BACGA,GAAa,0BAA4B,QAAQ,IAAI,4BAA8B,GACtF,cACGA,GAAa,cAAgB,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC7E,uBACGM,GAAa,qBACb,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GACjDL,EACH,gBACGK,GAAa,gBAAkB,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKJ,EACjF,MAAuBI,GAAa,OAAS,QAAQ,IAAI,QAAU,MACxE,EAEA,OAAAR,EAAO,IAAI,mCAAmCS,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["importConfig_exports","__export","importConfig","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var D=class{name;debug;constructor(S,R=!1){this.name=S,this.debug=R}log(...S){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...S])}}error(...S){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...S])}warn(...S){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...S])}info(...S){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...S])}};var N="UTILS",U=!1,P=new D(N,process.env.DEBUG==="true"||U),I=
|
|
1
|
+
var D=class{name;debug;constructor(S,R=!1){this.name=S,this.debug=R}log(...S){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...S])}}error(...S){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...S])}warn(...S){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...S])}info(...S){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...S])}};var N="UTILS",U=!1,P=new D(N,process.env.DEBUG==="true"||U),I=3e3,O=30,t=2e4,G=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw P.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},F=A=>{G(A);let S={M4D_APP_ID:A?.appId||process.env.M4D_APP_ID||"",M4D_APP_SECRET:A?.appSecret||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:A?.apiVersion||process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:A?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:A?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:A?.listenerPort||parseInt(process.env.LISTENER_PORT||"")||I,MAX_RETRIES_AFTER_WAIT:A?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||O,REQUEST_TIMEOUT:A?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||"")||t,DEBUG:A?.debug||process.env.DEBUG==="true"};return P.log(`Configuration loaded for App Id ${S.M4D_APP_ID}`),S};export{F as importConfig};
|
|
2
2
|
//# sourceMappingURL=importConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACA,GAAQ,YACrD,MAAAN,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaO,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,WAAuBD,GAAa,OAAS,QAAQ,IAAI,YAAc,GACvE,eAA2BA,GAAa,WAAa,QAAQ,IAAI,gBAAkB,GACnF,mBAA+BA,GAAa,eAAiB,OAAO,QAAQ,IAAI,kBAAkB,EAClG,uBAAgCA,GAAa,gBAAkB,QAAQ,IAAI,wBAA0B,GACrG,kBAA4BA,GAAa,YAAc,QAAQ,IAAI,mBAAqB,GACxF,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiCA,GAAa,iBAAmB,QAAQ,IAAI,kBAAoB,GACjG,2BACGA,GAAa,0BAA4B,QAAQ,IAAI,4BAA8B,GACtF,cACGA,GAAa,cAAgB,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC7E,uBACGM,GAAa,qBACb,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GACjDL,EACH,gBACGK,GAAa,gBAAkB,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKJ,EACjF,MAAuBI,GAAa,OAAS,QAAQ,IAAI,QAAU,MACxE,EAEA,OAAAR,EAAO,IAAI,mCAAmCS,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|
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-Bcd3jLw2.mjs';
|
|
8
8
|
import '../types/request.mjs';
|
|
9
9
|
import '../types/encryption.mjs';
|
|
10
10
|
import '../types/flow.mjs';
|