meta-cloud-api 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -0
  3. package/dist/BusinessProfileApi-WXscSgo-.d.ts +353 -0
  4. package/dist/EncryptionApi-D7pt-OXT.d.ts +22 -0
  5. package/dist/FlowApi-UAvzhJfV.d.ts +136 -0
  6. package/dist/MediaApi-BrEKpqi_.d.ts +90 -0
  7. package/dist/MessageApi-Circorzz.d.ts +587 -0
  8. package/dist/PhoneNumberApi-DKlu9PHl.d.ts +142 -0
  9. package/dist/QrCodeApi-7vDwIBHR.d.ts +98 -0
  10. package/dist/RegistrationApi-qO_qoti9.d.ts +47 -0
  11. package/dist/TemplateApi-xGgIZt89.d.ts +161 -0
  12. package/dist/TwoStepVerificationApi-DfNPIz-C.d.ts +33 -0
  13. package/dist/WabaApi-DqQi_68m.d.ts +175 -0
  14. package/dist/WebhookProcessor-ByAe7Kf_.d.ts +707 -0
  15. package/dist/WhatsApp-BIBtT-y9.d.ts +82 -0
  16. package/dist/api/encryption/index.d.ts +10 -0
  17. package/dist/api/encryption/index.js +2 -0
  18. package/dist/api/encryption/index.js.map +1 -0
  19. package/dist/api/flow/index.d.ts +10 -0
  20. package/dist/api/flow/index.js +2 -0
  21. package/dist/api/flow/index.js.map +1 -0
  22. package/dist/api/index.d.ts +16 -0
  23. package/dist/api/index.js +2 -0
  24. package/dist/api/index.js.map +1 -0
  25. package/dist/api/media/index.d.ts +10 -0
  26. package/dist/api/media/index.js +2 -0
  27. package/dist/api/media/index.js.map +1 -0
  28. package/dist/api/messages/index.d.ts +10 -0
  29. package/dist/api/messages/index.js +2 -0
  30. package/dist/api/messages/index.js.map +1 -0
  31. package/dist/api/phone/index.d.ts +10 -0
  32. package/dist/api/phone/index.js +2 -0
  33. package/dist/api/phone/index.js.map +1 -0
  34. package/dist/api/profile/index.d.ts +10 -0
  35. package/dist/api/profile/index.js +2 -0
  36. package/dist/api/profile/index.js.map +1 -0
  37. package/dist/api/qrCode/index.d.ts +10 -0
  38. package/dist/api/qrCode/index.js +2 -0
  39. package/dist/api/qrCode/index.js.map +1 -0
  40. package/dist/api/registration/index.d.ts +10 -0
  41. package/dist/api/registration/index.js +2 -0
  42. package/dist/api/registration/index.js.map +1 -0
  43. package/dist/api/template/index.d.ts +215 -0
  44. package/dist/api/template/index.js +2 -0
  45. package/dist/api/template/index.js.map +1 -0
  46. package/dist/api/twoStepVerification/index.d.ts +10 -0
  47. package/dist/api/twoStepVerification/index.js +2 -0
  48. package/dist/api/twoStepVerification/index.js.map +1 -0
  49. package/dist/api/waba/index.d.ts +10 -0
  50. package/dist/api/waba/index.js +2 -0
  51. package/dist/api/waba/index.js.map +1 -0
  52. package/dist/base-CdGDdVEl.d.ts +18 -0
  53. package/dist/chunk-7QBIZCJ4.js +2 -0
  54. package/dist/chunk-7QBIZCJ4.js.map +1 -0
  55. package/dist/chunk-AMHQGG6Z.js +2 -0
  56. package/dist/chunk-AMHQGG6Z.js.map +1 -0
  57. package/dist/chunk-B7DCL6I7.js +10 -0
  58. package/dist/chunk-B7DCL6I7.js.map +1 -0
  59. package/dist/chunk-CRZ7EUYR.js +2 -0
  60. package/dist/chunk-CRZ7EUYR.js.map +1 -0
  61. package/dist/chunk-FKXSL2JK.js +3 -0
  62. package/dist/chunk-FKXSL2JK.js.map +1 -0
  63. package/dist/chunk-FSKBLPGE.js +2 -0
  64. package/dist/chunk-FSKBLPGE.js.map +1 -0
  65. package/dist/chunk-HJGN3PO4.js +3 -0
  66. package/dist/chunk-HJGN3PO4.js.map +1 -0
  67. package/dist/chunk-IYSR44P6.js +2 -0
  68. package/dist/chunk-IYSR44P6.js.map +1 -0
  69. package/dist/chunk-JC6YMVID.js +2 -0
  70. package/dist/chunk-JC6YMVID.js.map +1 -0
  71. package/dist/chunk-JPAV644F.js +2 -0
  72. package/dist/chunk-JPAV644F.js.map +1 -0
  73. package/dist/chunk-JXCLRKQ7.js +2 -0
  74. package/dist/chunk-JXCLRKQ7.js.map +1 -0
  75. package/dist/chunk-KMAH6636.js +2 -0
  76. package/dist/chunk-KMAH6636.js.map +1 -0
  77. package/dist/chunk-L4ESAO2S.js +2 -0
  78. package/dist/chunk-L4ESAO2S.js.map +1 -0
  79. package/dist/chunk-LV3TULSI.js +2 -0
  80. package/dist/chunk-LV3TULSI.js.map +1 -0
  81. package/dist/chunk-MJEG3K4V.js +2 -0
  82. package/dist/chunk-MJEG3K4V.js.map +1 -0
  83. package/dist/chunk-NLF2JGYY.js +2 -0
  84. package/dist/chunk-NLF2JGYY.js.map +1 -0
  85. package/dist/chunk-OA2SW4AF.js +2 -0
  86. package/dist/chunk-OA2SW4AF.js.map +1 -0
  87. package/dist/chunk-PHPQ5HP3.js +2 -0
  88. package/dist/chunk-PHPQ5HP3.js.map +1 -0
  89. package/dist/chunk-RIL6QABY.js +2 -0
  90. package/dist/chunk-RIL6QABY.js.map +1 -0
  91. package/dist/chunk-RWCVPWRC.js +2 -0
  92. package/dist/chunk-RWCVPWRC.js.map +1 -0
  93. package/dist/chunk-SNNRWNGZ.js +2 -0
  94. package/dist/chunk-SNNRWNGZ.js.map +1 -0
  95. package/dist/chunk-UCBYECNQ.js +2 -0
  96. package/dist/chunk-UCBYECNQ.js.map +1 -0
  97. package/dist/chunk-VHAODWCN.js +2 -0
  98. package/dist/chunk-VHAODWCN.js.map +1 -0
  99. package/dist/chunk-WGGN32O2.js +2 -0
  100. package/dist/chunk-WGGN32O2.js.map +1 -0
  101. package/dist/common-DDXsNyLF.d.ts +376 -0
  102. package/dist/core/webhook/frameworks/express.d.ts +48 -0
  103. package/dist/core/webhook/frameworks/express.js +2 -0
  104. package/dist/core/webhook/frameworks/express.js.map +1 -0
  105. package/dist/core/webhook/frameworks/nextjs.d.ts +44 -0
  106. package/dist/core/webhook/frameworks/nextjs.js +2 -0
  107. package/dist/core/webhook/frameworks/nextjs.js.map +1 -0
  108. package/dist/core/webhook/index.d.ts +26 -0
  109. package/dist/core/webhook/index.js +2 -0
  110. package/dist/core/webhook/index.js.map +1 -0
  111. package/dist/core/whatsapp/index.d.ts +40 -0
  112. package/dist/core/whatsapp/index.js +2 -0
  113. package/dist/core/whatsapp/index.js.map +1 -0
  114. package/dist/enums-BZd9T2ul.d.ts +707 -0
  115. package/dist/httpsClient-v4gmltzS.d.ts +19 -0
  116. package/dist/index.d.ts +22 -0
  117. package/dist/index.js +2 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/logger-BdE0Vyim.d.ts +9 -0
  120. package/dist/request-vYMaEfk5.d.ts +50 -0
  121. package/dist/types/config.d.ts +78 -0
  122. package/dist/types/config.js +2 -0
  123. package/dist/types/config.js.map +1 -0
  124. package/dist/types/enums.d.ts +1 -0
  125. package/dist/types/enums.js +2 -0
  126. package/dist/types/enums.js.map +1 -0
  127. package/dist/types/index.d.ts +6 -0
  128. package/dist/types/index.js +2 -0
  129. package/dist/types/index.js.map +1 -0
  130. package/dist/utils/index.d.ts +98 -0
  131. package/dist/utils/index.js +2 -0
  132. package/dist/utils/index.js.map +1 -0
  133. package/package.json +240 -8
@@ -0,0 +1,19 @@
1
+ import { H as HttpMethodsEnum } from './enums-BZd9T2ul.js';
2
+
3
+ type ResponseHeaderValue = string | string[] | undefined;
4
+ type ResponseHeaders = Record<string, ResponseHeaderValue>;
5
+ type ResponseJSONBody = Record<string, unknown>;
6
+ declare class HttpsClientResponseClass {
7
+ constructor(resp: Response);
8
+ statusCode: () => number;
9
+ headers: () => ResponseHeaders;
10
+ rawResponse: () => Response;
11
+ json: () => Promise<ResponseJSONBody>;
12
+ }
13
+ declare class HttpsClientClass {
14
+ constructor();
15
+ clearSockets: () => boolean;
16
+ sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
17
+ }
18
+
19
+ export { HttpsClientClass as H, type ResponseHeaders as R, HttpsClientResponseClass as a, type ResponseHeaderValue as b, type ResponseJSONBody as c };
@@ -0,0 +1,22 @@
1
+ export { W as WhatsApp, W as WhatsAppLegacy } from './WhatsApp-BIBtT-y9.js';
2
+ export { WabaConfigType, WhatsAppConfig } from './types/config.js';
3
+ export { C as ComponentTypesEnum, I as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum } from './enums-BZd9T2ul.js';
4
+ export { F as FlowApi } from './FlowApi-UAvzhJfV.js';
5
+ export { M as MediaApi } from './MediaApi-BrEKpqi_.js';
6
+ export { M as MessagesApi } from './MessageApi-Circorzz.js';
7
+ export { P as PhoneNumberApi } from './PhoneNumberApi-DKlu9PHl.js';
8
+ export { B as BusinessProfileApi } from './BusinessProfileApi-WXscSgo-.js';
9
+ export { T as TemplateApi } from './TemplateApi-xGgIZt89.js';
10
+ export { T as TwoStepVerificationApi } from './TwoStepVerificationApi-DfNPIz-C.js';
11
+ export { W as WebhookContact, a as WebhookEvent, b as WebhookMessage } from './WebhookProcessor-ByAe7Kf_.js';
12
+ export { webhookHandler as ExpressWebhook } from './core/webhook/frameworks/express.js';
13
+ export { webhookHandler as NextJsWebhook } from './core/webhook/frameworks/nextjs.js';
14
+ import './request-vYMaEfk5.js';
15
+ import './httpsClient-v4gmltzS.js';
16
+ import 'https';
17
+ import './EncryptionApi-D7pt-OXT.js';
18
+ import './base-CdGDdVEl.js';
19
+ import './QrCodeApi-7vDwIBHR.js';
20
+ import './RegistrationApi-qO_qoti9.js';
21
+ import './WabaApi-DqQi_68m.js';
22
+ import './common-DDXsNyLF.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import'./chunk-RWCVPWRC.js';export{a as ExpressWebhook}from'./chunk-OA2SW4AF.js';export{a as NextJsWebhook}from'./chunk-UCBYECNQ.js';import'./chunk-HJGN3PO4.js';import'./chunk-WGGN32O2.js';export{b as WhatsApp,b as WhatsAppLegacy}from'./chunk-B7DCL6I7.js';import'./chunk-FKXSL2JK.js';import'./chunk-AMHQGG6Z.js';import'./chunk-JPAV644F.js';import'./chunk-PHPQ5HP3.js';import'./chunk-IYSR44P6.js';export{b as TwoStepVerificationApi}from'./chunk-SNNRWNGZ.js';import'./chunk-L4ESAO2S.js';export{b as MessagesApi}from'./chunk-7QBIZCJ4.js';export{b as MediaApi}from'./chunk-JXCLRKQ7.js';export{b as BusinessProfileApi}from'./chunk-LV3TULSI.js';import'./chunk-CRZ7EUYR.js';export{b as FlowApi}from'./chunk-JC6YMVID.js';import'./chunk-NLF2JGYY.js';export{b as PhoneNumberApi}from'./chunk-FSKBLPGE.js';export{a as TemplateApi}from'./chunk-VHAODWCN.js';import'./chunk-MJEG3K4V.js';import'./chunk-RIL6QABY.js';export{i as ComponentTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum}from'./chunk-KMAH6636.js';//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,9 @@
1
+ interface LoggerInterface {
2
+ log(...data: any[]): void;
3
+ error(...data: any[]): void;
4
+ warn(...data: any[]): void;
5
+ info(...data: any[]): void;
6
+ debug(...data: any[]): void;
7
+ }
8
+
9
+ export type { LoggerInterface as L };
@@ -0,0 +1,50 @@
1
+ import { H as HttpMethodsEnum } from './enums-BZd9T2ul.js';
2
+
3
+ type GeneralRequestBody = Record<string, unknown>;
4
+ interface GeneralHeaderInterface {
5
+ /**
6
+ * Authorization token. This is required for all HTTP requests made to the graph API.
7
+ * @default 'Bearer '
8
+ */
9
+ Authorization: string;
10
+ /**
11
+ * Content type of the message being sent. This is required for all HTTP requests made to the graph API.
12
+ * @default 'application/json'
13
+ */
14
+ 'Content-Type': string;
15
+ /**
16
+ * User agent field sent in all requests. This is used to gather SDK usage metrics and help
17
+ * better triage support requests.
18
+ * @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`
19
+ */
20
+ 'User-Agent': string;
21
+ }
22
+ interface RequesterResponseInterface<T> {
23
+ json: () => Promise<T>;
24
+ }
25
+ interface ResponseSuccess {
26
+ success: boolean;
27
+ }
28
+ interface ResponseData<T> {
29
+ data: T;
30
+ }
31
+ interface ResponsePagination<T> {
32
+ data: T[];
33
+ paging: Paging;
34
+ }
35
+ interface Paging {
36
+ cursors: {
37
+ before: string;
38
+ after: string;
39
+ };
40
+ next: string;
41
+ }
42
+ declare class RequesterClass {
43
+ constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
44
+ sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
45
+ getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
46
+ sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
47
+ sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
48
+ }
49
+
50
+ export { type GeneralHeaderInterface as G, type Paging as P, RequesterClass as R, type GeneralRequestBody as a, type RequesterResponseInterface as b, type ResponseData as c, type ResponsePagination as d, type ResponseSuccess as e };
@@ -0,0 +1,78 @@
1
+ import { W as WabaConfigEnum } from '../enums-BZd9T2ul.js';
2
+
3
+ type WhatsAppConfig = {
4
+ accessToken: string;
5
+ appId?: string;
6
+ appSecret?: string;
7
+ phoneNumberId?: number;
8
+ businessAcctId?: string;
9
+ apiVersion?: string;
10
+ webhookEndpoint?: string;
11
+ webhookVerificationToken?: string;
12
+ listenerPort?: number;
13
+ debug?: boolean;
14
+ maxRetriesAfterWait?: number;
15
+ requestTimeout?: number;
16
+ privatePem?: string;
17
+ passphrase?: string;
18
+ };
19
+ type WabaConfigType = {
20
+ /**
21
+ * The Meta for Developers business application Id for this registered application.
22
+ */
23
+ [WabaConfigEnum.AppId]: string;
24
+ /**
25
+ * The Meta for Developers business application secret for this registered application.
26
+ */
27
+ [WabaConfigEnum.AppSecret]: string;
28
+ /**
29
+ * The Meta for Developers phone number id used by the registered business.
30
+ */
31
+ [WabaConfigEnum.PhoneNumberId]: number;
32
+ /**
33
+ * The Meta for Developers business id for the registered business.
34
+ */
35
+ [WabaConfigEnum.BusinessAcctId]: string;
36
+ /**
37
+ * The version of the Cloud API being used. Starts with a "v" and follows the major number.
38
+ */
39
+ [WabaConfigEnum.APIVersion]: string;
40
+ /**
41
+ * The access token to make calls on behalf of the signed in Meta for Developers account or business.
42
+ */
43
+ [WabaConfigEnum.AccessToken]: string;
44
+ /**
45
+ * The endpoint path (e.g. if the value here is webhook, the webhook URL would look like http/https://{host}/webhook).
46
+ */
47
+ [WabaConfigEnum.WebhookEndpoint]: string;
48
+ /**
49
+ * The verification token that needs to match what is sent by the Cloud API webhook in order to subscribe.
50
+ */
51
+ [WabaConfigEnum.WebhookVerificationToken]: string;
52
+ /**
53
+ * The listener port for the webhook web server.
54
+ */
55
+ [WabaConfigEnum.ListenerPort]: number;
56
+ /**
57
+ * To turn on global debugging of the logger to print verbose output across the APIs.
58
+ */
59
+ [WabaConfigEnum.Debug]: boolean;
60
+ /**
61
+ * The total number of times a request should be retried after the wait period if it fails.
62
+ */
63
+ [WabaConfigEnum.MaxRetriesAfterWait]: number;
64
+ /**
65
+ * The timeout period for a request to quit and destroy the attempt in ms.
66
+ */
67
+ [WabaConfigEnum.RequestTimeout]: number;
68
+ /**
69
+ * The private key for the Meta for Developers business.
70
+ */
71
+ [WabaConfigEnum.PrivatePem]: string;
72
+ /**
73
+ * The passphrase for the Meta for Developers business.
74
+ */
75
+ [WabaConfigEnum.Passphrase]: string;
76
+ };
77
+
78
+ export type { WabaConfigType, WhatsAppConfig };
@@ -0,0 +1,2 @@
1
+ //# sourceMappingURL=config.js.map
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"config.js"}
@@ -0,0 +1 @@
1
+ export { A as AudioMediaTypesEnum, k as BusinessVerticalEnum, B as ButtonPositionEnum, a as CategoryEnum, C as ComponentTypesEnum, b as ConversationTypesEnum, i as CurrencyCodesEnum, j as DataLocalizationRegionEnum, D as DocumentMediaTypesEnum, H as HttpMethodsEnum, e as ImageMediaTypesEnum, I as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, R as ReferralSourceTypesEnum, h as RequestCodeMethodsEnum, c as StatusEnum, d as StickerMediaTypesEnum, S as SubTypeEnum, g as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, f as WebhookTypesEnum } from '../enums-BZd9T2ul.js';
@@ -0,0 +1,2 @@
1
+ export{q as AudioMediaTypesEnum,y as BusinessVerticalEnum,g as ButtonPositionEnum,a as CategoryEnum,i as ComponentTypesEnum,k as ConversationTypesEnum,w as CurrencyCodesEnum,x as DataLocalizationRegionEnum,p as DocumentMediaTypesEnum,c as HttpMethodsEnum,o as ImageMediaTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum,t as ReferralSourceTypesEnum,u as RequestCodeMethodsEnum,l as StatusEnum,n as StickerMediaTypesEnum,h as SubTypeEnum,s as SystemChangeTypesEnum,b as TemplateStatusEnum,m as VideoMediaTypesEnum,j as WabaConfigEnum,r as WebhookTypesEnum}from'../chunk-KMAH6636.js';//# sourceMappingURL=enums.js.map
2
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"enums.js"}
@@ -0,0 +1,6 @@
1
+ export { B as BaseAPI, a as BaseClass } from '../base-CdGDdVEl.js';
2
+ export { WabaConfigType, WhatsAppConfig } from './config.js';
3
+ export { L as LoggerInterface } from '../logger-BdE0Vyim.js';
4
+ export { H as HttpsClientClass, a as HttpsClientResponseClass, b as ResponseHeaderValue, R as ResponseHeaders, c as ResponseJSONBody } from '../httpsClient-v4gmltzS.js';
5
+ export { G as GeneralHeaderInterface, a as GeneralRequestBody, P as Paging, R as RequesterClass, b as RequesterResponseInterface, c as ResponseData, d as ResponsePagination, e as ResponseSuccess } from '../request-vYMaEfk5.js';
6
+ export { A as AudioMediaTypesEnum, k as BusinessVerticalEnum, B as ButtonPositionEnum, a as CategoryEnum, C as ComponentTypesEnum, b as ConversationTypesEnum, i as CurrencyCodesEnum, j as DataLocalizationRegionEnum, D as DocumentMediaTypesEnum, H as HttpMethodsEnum, e as ImageMediaTypesEnum, I as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, R as ReferralSourceTypesEnum, h as RequestCodeMethodsEnum, c as StatusEnum, d as StickerMediaTypesEnum, S as SubTypeEnum, g as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, f as WebhookTypesEnum } from '../enums-BZd9T2ul.js';
@@ -0,0 +1,2 @@
1
+ export{a as BaseAPI}from'../chunk-RIL6QABY.js';export{q as AudioMediaTypesEnum,y as BusinessVerticalEnum,g as ButtonPositionEnum,a as CategoryEnum,i as ComponentTypesEnum,k as ConversationTypesEnum,w as CurrencyCodesEnum,x as DataLocalizationRegionEnum,p as DocumentMediaTypesEnum,c as HttpMethodsEnum,o as ImageMediaTypesEnum,f as InteractiveTypesEnum,v as LanguagesEnum,d as MessageTypesEnum,e as ParametersTypesEnum,t as ReferralSourceTypesEnum,u as RequestCodeMethodsEnum,l as StatusEnum,n as StickerMediaTypesEnum,h as SubTypeEnum,s as SystemChangeTypesEnum,b as TemplateStatusEnum,m as VideoMediaTypesEnum,j as WabaConfigEnum,r as WebhookTypesEnum}from'../chunk-KMAH6636.js';//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,98 @@
1
+ import { WabaConfigType } from '../types/config.js';
2
+ import { L as LoggerInterface } from '../logger-BdE0Vyim.js';
3
+ import { f as FlowEndpointRequest, n as FlowDataExchangeRequest, b as FlowActionEnum, o as FlowErrorNotificationRequest, p as FlowHealthCheckRequest } from '../common-DDXsNyLF.js';
4
+ import '../enums-BZd9T2ul.js';
5
+ import '../request-vYMaEfk5.js';
6
+
7
+ declare function buildFieldsQueryString(fields?: string[] | string): string;
8
+
9
+ /**
10
+ * Formats configuration as a terminal table
11
+ * @param config - The WABA configuration object
12
+ * @param apiName - The name of the API being initialized
13
+ * @returns Formatted table string
14
+ */
15
+ declare function formatConfigTable(config: WabaConfigType): string;
16
+
17
+ interface MetaError extends Error {
18
+ error: {
19
+ message: string;
20
+ type: string;
21
+ code: number;
22
+ error_data?: {
23
+ messaging_product: 'whatsapp';
24
+ details: string;
25
+ };
26
+ error_subcode?: number;
27
+ fbtrace_id: string;
28
+ };
29
+ }
30
+ /**
31
+ * Determines if the error is a Meta API error response
32
+ * @param error Any error object to check
33
+ * @returns Type guard indicating if error is a Meta API error
34
+ */
35
+ declare function isMetaError(error: any): error is MetaError;
36
+
37
+ declare class Logger implements LoggerInterface {
38
+ private name;
39
+ private debug;
40
+ constructor(name: string, debug?: boolean);
41
+ log(...data: any[]): void;
42
+ error(...data: any[]): void;
43
+ warn(...data: any[]): void;
44
+ info(...data: any[]): void;
45
+ }
46
+
47
+ declare const objectToQueryString: (params: Record<string, any>) => string;
48
+
49
+ /**
50
+ * Get SDK version from package.json
51
+ */
52
+ declare function getVersion(): string;
53
+ /**
54
+ * Generate User-Agent string following official SDK pattern
55
+ */
56
+ declare function getUserAgent(): string;
57
+
58
+ declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
59
+ declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
60
+ /**
61
+ * Type guard to check if a request is a Data Exchange request
62
+ * Validates the request structure according to the Flow API specifications
63
+ *
64
+ * @param request The Flow endpoint request to check
65
+ * @returns True if the request is a valid Data Exchange request, false otherwise
66
+ */
67
+ declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
68
+ action: (typeof DATA_EXCHANGE_ACTIONS)[number];
69
+ screen?: string;
70
+ flow_token: string;
71
+ data?: Record<string, any>;
72
+ };
73
+ /**
74
+ * Type guard to check if a request is an Error Notification request
75
+ * Validates the request structure according to the Flow API error specifications
76
+ *
77
+ * @param request The Flow endpoint request to check
78
+ * @returns True if the request is a valid Error Notification request, false otherwise
79
+ */
80
+ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
81
+ action: (typeof ERROR_ACTIONS)[number];
82
+ screen: string;
83
+ flow_token: string;
84
+ data: {
85
+ error: string;
86
+ error_message: string;
87
+ };
88
+ };
89
+ /**
90
+ * Type guard to check if a request is a Ping (health check) request
91
+ * Simple validation for health check endpoints in the Flow API
92
+ *
93
+ * @param request The Flow endpoint request to check
94
+ * @returns True if the request is a Ping request, false otherwise
95
+ */
96
+ declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
97
+
98
+ export { Logger, type MetaError, buildFieldsQueryString, formatConfigTable, getUserAgent, getVersion, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError, objectToQueryString };
@@ -0,0 +1,2 @@
1
+ export{a as isFlowDataExchangeRequest,b as isFlowErrorRequest,c as isFlowPingRequest}from'../chunk-WGGN32O2.js';export{a as Logger,b as formatConfigTable,e as getUserAgent,d as getVersion,c as isMetaError}from'../chunk-FKXSL2JK.js';export{a as buildFieldsQueryString}from'../chunk-CRZ7EUYR.js';import'../chunk-NLF2JGYY.js';export{a as objectToQueryString}from'../chunk-MJEG3K4V.js';import'../chunk-KMAH6636.js';//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,12 +1,244 @@
1
1
  {
2
2
  "name": "meta-cloud-api",
3
- "version": "1.0.0",
4
- "description": "",
5
- "license": "ISC",
6
- "author": "",
7
- "type": "commonjs",
8
- "main": "index.js",
3
+ "version": "1.0.1",
4
+ "description": "TypeScript wrapper for Meta's Cloud API",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "sideEffects": false,
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- }
10
+ "prepublishOnly": "pnpm build",
11
+ "prepare": "husky",
12
+ "cz": "cz",
13
+ "dev": "tsup --watch",
14
+ "build": "tsup --clean",
15
+ "format": "prettier .",
16
+ "lint": "eslint .",
17
+ "clean": "rm -rf dist node_modules",
18
+ "typecheck": "tsc --noEmit",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest --watch"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./messages": {
32
+ "types": "./dist/api/messages/index.d.ts",
33
+ "import": "./dist/api/messages/index.js",
34
+ "default": "./dist/api/messages/index.js"
35
+ },
36
+ "./media": {
37
+ "types": "./dist/api/media/index.d.ts",
38
+ "import": "./dist/api/media/index.js",
39
+ "default": "./dist/api/media/index.js"
40
+ },
41
+ "./profile": {
42
+ "types": "./dist/api/profile/index.d.ts",
43
+ "import": "./dist/api/profile/index.js",
44
+ "default": "./dist/api/profile/index.js"
45
+ },
46
+ "./flow": {
47
+ "types": "./dist/api/flow/index.d.ts",
48
+ "import": "./dist/api/flow/index.js",
49
+ "default": "./dist/api/flow/index.js"
50
+ },
51
+ "./phone": {
52
+ "types": "./dist/api/phone/index.d.ts",
53
+ "import": "./dist/api/phone/index.js",
54
+ "default": "./dist/api/phone/index.js"
55
+ },
56
+ "./template": {
57
+ "types": "./dist/api/template/index.d.ts",
58
+ "import": "./dist/api/template/index.js",
59
+ "default": "./dist/api/template/index.js"
60
+ },
61
+ "./waba": {
62
+ "types": "./dist/api/waba/index.d.ts",
63
+ "import": "./dist/api/waba/index.js",
64
+ "default": "./dist/api/waba/index.js"
65
+ },
66
+ "./qrCode": {
67
+ "types": "./dist/api/qrCode/index.d.ts",
68
+ "import": "./dist/api/qrCode/index.js",
69
+ "default": "./dist/api/qrCode/index.js"
70
+ },
71
+ "./twoStepVerification": {
72
+ "types": "./dist/api/twoStepVerification/index.d.ts",
73
+ "import": "./dist/api/twoStepVerification/index.js",
74
+ "default": "./dist/api/twoStepVerification/index.js"
75
+ },
76
+ "./encryption": {
77
+ "types": "./dist/api/encryption/index.d.ts",
78
+ "import": "./dist/api/encryption/index.js",
79
+ "default": "./dist/api/encryption/index.js"
80
+ },
81
+ "./registration": {
82
+ "types": "./dist/api/registration/index.d.ts",
83
+ "import": "./dist/api/registration/index.js",
84
+ "default": "./dist/api/registration/index.js"
85
+ },
86
+ "./shared/types": {
87
+ "types": "./dist/shared/types/index.d.ts",
88
+ "import": "./dist/shared/types/index.js",
89
+ "default": "./dist/shared/types/index.js"
90
+ },
91
+ "./shared/utils": {
92
+ "types": "./dist/shared/utils/index.d.ts",
93
+ "import": "./dist/shared/utils/index.js",
94
+ "default": "./dist/shared/utils/index.js"
95
+ },
96
+ "./api": {
97
+ "types": "./dist/api/index.d.ts",
98
+ "import": "./dist/api/index.js",
99
+ "default": "./dist/api/index.js"
100
+ },
101
+ "./api/messages": {
102
+ "types": "./dist/api/messages.d.ts",
103
+ "import": "./dist/api/messages.js",
104
+ "default": "./dist/api/messages.js"
105
+ },
106
+ "./api/media": {
107
+ "types": "./dist/api/media.d.ts",
108
+ "import": "./dist/api/media.js",
109
+ "default": "./dist/api/media.js"
110
+ },
111
+ "./api/flows": {
112
+ "types": "./dist/api/flows.d.ts",
113
+ "import": "./dist/api/flows.js",
114
+ "default": "./dist/api/flows.js"
115
+ },
116
+ "./utils": {
117
+ "types": "./dist/utils/index.d.ts",
118
+ "import": "./dist/utils/index.js",
119
+ "default": "./dist/utils/index.js"
120
+ },
121
+ "./webhook": {
122
+ "types": "./dist/core/webhook/index.d.ts",
123
+ "import": "./dist/core/webhook/index.js",
124
+ "default": "./dist/core/webhook/index.js"
125
+ },
126
+ "./webhook/express": {
127
+ "types": "./dist/core/webhook/frameworks/express.d.ts",
128
+ "import": "./dist/core/webhook/frameworks/express.js",
129
+ "default": "./dist/core/webhook/frameworks/express.js"
130
+ },
131
+ "./webhook/nextjs": {
132
+ "types": "./dist/core/webhook/frameworks/nextjs.d.ts",
133
+ "import": "./dist/core/webhook/frameworks/nextjs.js",
134
+ "default": "./dist/core/webhook/frameworks/nextjs.js"
135
+ },
136
+ "./types": {
137
+ "types": "./dist/types/index.d.ts",
138
+ "import": "./dist/types/index.js",
139
+ "default": "./dist/types/index.js"
140
+ },
141
+ "./types/enums": {
142
+ "types": "./dist/types/enums.d.ts",
143
+ "import": "./dist/types/enums.js",
144
+ "default": "./dist/types/enums.js"
145
+ },
146
+ "./types/config": {
147
+ "types": "./dist/types/config.d.ts",
148
+ "import": "./dist/types/config.js",
149
+ "default": "./dist/types/config.js"
150
+ },
151
+ "./core/webhook": {
152
+ "types": "./dist/core/webhook/index.d.ts",
153
+ "import": "./dist/core/webhook/index.js",
154
+ "default": "./dist/core/webhook/index.js"
155
+ },
156
+ "./core/whatsapp": {
157
+ "types": "./dist/core/whatsapp/index.d.ts",
158
+ "import": "./dist/core/whatsapp/index.js",
159
+ "default": "./dist/core/whatsapp/index.js"
160
+ },
161
+ "./package.json": "./package.json"
162
+ },
163
+ "keywords": [
164
+ "whatsapp-api",
165
+ "cloud-api",
166
+ "meta-api",
167
+ "typescript-sdk",
168
+ "whatsapp-business",
169
+ "whatsapp-cloud-api",
170
+ "messaging-api",
171
+ "node-api-client",
172
+ "meta-cloud",
173
+ "whatsapp-messaging",
174
+ "api-wrapper",
175
+ "typescript",
176
+ "nodejs",
177
+ "meta",
178
+ "facebook-api",
179
+ "whatsapp-integration",
180
+ "whatsapp-templates",
181
+ "media-api",
182
+ "flow-api",
183
+ "waba",
184
+ "business-messaging"
185
+ ],
186
+ "author": "froggy1014",
187
+ "license": "MIT",
188
+ "homepage": "https://github.com/froggy1014/meta-cloud-api#readme",
189
+ "repository": {
190
+ "type": "git",
191
+ "url": "git+https://github.com/froggy1014/meta-cloud-api.git"
192
+ },
193
+ "bugs": {
194
+ "url": "https://github.com/froggy1014/meta-cloud-api/issues"
195
+ },
196
+ "files": [
197
+ "dist",
198
+ "README.md"
199
+ ],
200
+ "engines": {
201
+ "node": ">=18"
202
+ },
203
+ "devDependencies": {
204
+ "@changesets/cli": "^2.28.1",
205
+ "@commitlint/cli": "^19.6.1",
206
+ "@commitlint/config-conventional": "^19.6.0",
207
+ "@commitlint/cz-commitlint": "^19.6.1",
208
+ "@commitlint/types": "^19.5.0",
209
+ "@eslint/eslintrc": "^3.2.0",
210
+ "@eslint/js": "^9.17.0",
211
+ "@types/eslint-config-prettier": "^6.11.3",
212
+ "@types/eslint__eslintrc": "^2.1.2",
213
+ "@types/express": "^5.0.3",
214
+ "@types/node": "^22.15.29",
215
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
216
+ "@typescript-eslint/parser": "^8.15.0",
217
+ "commitizen": "^4.3.1",
218
+ "dotenv": "^16.4.7",
219
+ "eslint": "^9.20.1",
220
+ "eslint-config-prettier": "^9.1.0",
221
+ "eslint-plugin-only-warn": "^1.1.0",
222
+ "eslint-plugin-unused-imports": "^4.1.4",
223
+ "husky": "^9.1.7",
224
+ "lint-staged": "^15.3.0",
225
+ "next": "^15.3.5",
226
+ "prettier": "^3.5.0",
227
+ "tsup": "^8.3.6",
228
+ "typescript": "^5.7.3",
229
+ "typescript-eslint": "^8.23.0",
230
+ "vitest": "^2.1.8"
231
+ },
232
+ "lint-staged": {
233
+ "**/*.{ts,tsx}": [
234
+ "prettier --write --ignore-unknown",
235
+ "eslint --fix"
236
+ ]
237
+ },
238
+ "config": {
239
+ "commitizen": {
240
+ "path": "@commitlint/cz-commitlint"
241
+ }
242
+ },
243
+ "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
12
244
  }