meta-cloud-api 1.0.3 → 1.1.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.
- package/dist/{BusinessProfileApi-WXscSgo-.d.ts → BusinessProfileApi-CW0emncx.d.ts} +1 -1
- package/dist/{EncryptionApi-D7pt-OXT.d.ts → EncryptionApi-Dyea0SR3.d.ts} +1 -1
- package/dist/{FlowApi-B2ffO-HD.d.ts → FlowApi-DvoT7ivY.d.ts} +1 -1
- package/dist/{MessageApi-BgsSpDno.d.ts → MessageApi-D-9SuL4w.d.ts} +1 -1
- package/dist/{TemplateApi-xGgIZt89.d.ts → TemplateApi-D4_6LvhN.d.ts} +1 -1
- package/dist/{WabaApi-DqQi_68m.d.ts → WabaApi-BvY1JVRH.d.ts} +1 -1
- package/dist/{WebhookProcessor-BXYunz4N.d.ts → WebhookProcessor-CE4xBPe0.d.ts} +2 -2
- package/dist/{WhatsApp-pTZPQm81.d.ts → WhatsApp-iAly_4pr.d.ts} +6 -6
- package/dist/api/encryption/index.d.ts +2 -2
- package/dist/api/flow/index.d.ts +3 -2
- package/dist/api/flow/index.js +1 -1
- package/dist/api/index.d.ts +9 -8
- package/dist/api/index.js +1 -1
- package/dist/api/messages/builders/index.d.ts +1 -1
- package/dist/api/messages/index.d.ts +2 -2
- package/dist/api/profile/index.d.ts +2 -2
- package/dist/api/template/index.d.ts +6 -200
- package/dist/api/waba/index.d.ts +2 -2
- package/dist/chunk-5577QQ7V.js +2 -0
- package/dist/chunk-5577QQ7V.js.map +1 -0
- package/dist/{chunk-WGGN32O2.js → chunk-6DFC5L3X.js} +2 -2
- package/dist/chunk-6DFC5L3X.js.map +1 -0
- package/dist/chunk-GM63NGNV.js +2 -0
- package/dist/chunk-GM63NGNV.js.map +1 -0
- package/dist/chunk-J2JPTKU6.js +2 -0
- package/dist/chunk-J2JPTKU6.js.map +1 -0
- package/dist/{chunk-JPGXONBQ.js → chunk-U5FBZ6UB.js} +3 -3
- package/dist/{chunk-JPGXONBQ.js.map → chunk-U5FBZ6UB.js.map} +1 -1
- package/dist/chunk-ZMNXRMWK.js +2 -0
- package/dist/chunk-ZMNXRMWK.js.map +1 -0
- package/dist/{common-BiRA_uz3.d.ts → common-CzzMWFoO.d.ts} +1 -1
- package/dist/{common-lV0NsO7t.d.ts → common-nVoO5ROn.d.ts} +28 -1
- package/dist/core/webhook/frameworks/express.d.ts +20 -16
- package/dist/core/webhook/frameworks/express.js +1 -1
- package/dist/core/webhook/frameworks/nextjs-app.d.ts +48 -0
- package/dist/core/webhook/frameworks/nextjs-app.js +2 -0
- package/dist/core/webhook/frameworks/nextjs-app.js.map +1 -0
- package/dist/core/webhook/frameworks/nextjs.d.ts +18 -14
- package/dist/core/webhook/frameworks/nextjs.js +1 -1
- package/dist/core/webhook/index.d.ts +12 -10
- package/dist/core/webhook/index.js +1 -1
- package/dist/core/whatsapp/index.d.ts +10 -9
- package/dist/core/whatsapp/index.js +1 -1
- package/dist/factory-D2eO5etK.d.ts +200 -0
- package/dist/handler-DbySwF0E.d.ts +20 -0
- package/dist/index.d.ts +20 -17
- package/dist/index.js +1 -1
- package/dist/{isMetaError-CXWJwW58.d.ts → isMetaError-CLqzdSws.d.ts} +1 -1
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +1 -1
- package/package.json +59 -76
- package/dist/chunk-NLF2JGYY.js +0 -2
- package/dist/chunk-NLF2JGYY.js.map +0 -1
- package/dist/chunk-NOJFGTRT.js +0 -2
- package/dist/chunk-NOJFGTRT.js.map +0 -1
- package/dist/chunk-WGGN32O2.js.map +0 -1
- package/dist/chunk-YXZ4L2OK.js +0 -2
- package/dist/chunk-YXZ4L2OK.js.map +0 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { L as LanguagesEnum, i as CurrencyCodesEnum, a as CategoryEnum } from './enums-BZd9T2ul.js';
|
|
2
|
+
import { j as TemplateFormat } from './TemplateApi-D4_6LvhN.js';
|
|
3
|
+
|
|
4
|
+
interface TextParameter {
|
|
5
|
+
type: 'text';
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
interface CurrencyParameter {
|
|
9
|
+
type: 'currency';
|
|
10
|
+
amount_1000: number;
|
|
11
|
+
code: CurrencyCodesEnum;
|
|
12
|
+
fallback_value: string;
|
|
13
|
+
}
|
|
14
|
+
interface DateTimeParameter {
|
|
15
|
+
type: 'date_time';
|
|
16
|
+
fallback_value: string;
|
|
17
|
+
}
|
|
18
|
+
interface MediaParameter {
|
|
19
|
+
type: 'image' | 'video' | 'document';
|
|
20
|
+
handle?: string;
|
|
21
|
+
link?: string;
|
|
22
|
+
}
|
|
23
|
+
interface LocationParameter {
|
|
24
|
+
type: 'location';
|
|
25
|
+
latitude?: number;
|
|
26
|
+
longitude?: number;
|
|
27
|
+
name?: string;
|
|
28
|
+
address?: string;
|
|
29
|
+
}
|
|
30
|
+
interface ProductParameter {
|
|
31
|
+
type: 'product';
|
|
32
|
+
product_retailer_id: string;
|
|
33
|
+
}
|
|
34
|
+
type TemplateParameter = TextParameter | CurrencyParameter | DateTimeParameter | MediaParameter | LocationParameter | ProductParameter;
|
|
35
|
+
interface HeaderOptions {
|
|
36
|
+
format: TemplateFormat;
|
|
37
|
+
text?: string;
|
|
38
|
+
parameters?: TemplateParameter[];
|
|
39
|
+
example?: {
|
|
40
|
+
header_text?: string[];
|
|
41
|
+
header_text_named_params?: Array<{
|
|
42
|
+
param_name: string;
|
|
43
|
+
example: string;
|
|
44
|
+
}>;
|
|
45
|
+
header_handle?: string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface BodyOptions {
|
|
49
|
+
text: string;
|
|
50
|
+
parameters?: TemplateParameter[];
|
|
51
|
+
example?: {
|
|
52
|
+
body_text?: string[][];
|
|
53
|
+
body_text_named_params?: Array<{
|
|
54
|
+
param_name: string;
|
|
55
|
+
example: string;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
interface FooterOptions {
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
interface ButtonOptions {
|
|
63
|
+
phone_number?: {
|
|
64
|
+
text: string;
|
|
65
|
+
phone_number: string;
|
|
66
|
+
};
|
|
67
|
+
url?: {
|
|
68
|
+
text: string;
|
|
69
|
+
url: string;
|
|
70
|
+
example?: string;
|
|
71
|
+
};
|
|
72
|
+
quick_reply?: {
|
|
73
|
+
text: string;
|
|
74
|
+
}[];
|
|
75
|
+
copy_code?: {
|
|
76
|
+
example: string;
|
|
77
|
+
};
|
|
78
|
+
flow?: {
|
|
79
|
+
text: string;
|
|
80
|
+
flow_id?: string;
|
|
81
|
+
flow_name?: string;
|
|
82
|
+
flow_json?: string;
|
|
83
|
+
flow_action?: 'navigate' | 'data_exchange';
|
|
84
|
+
navigate_screen?: string;
|
|
85
|
+
};
|
|
86
|
+
mpm?: boolean;
|
|
87
|
+
otp?: boolean;
|
|
88
|
+
spm?: boolean;
|
|
89
|
+
}
|
|
90
|
+
interface CarouselCard {
|
|
91
|
+
image?: string;
|
|
92
|
+
video?: string;
|
|
93
|
+
product?: string;
|
|
94
|
+
body?: string;
|
|
95
|
+
bodyParameters?: TemplateParameter[];
|
|
96
|
+
buttons?: ButtonOptions;
|
|
97
|
+
}
|
|
98
|
+
interface CarouselOptions {
|
|
99
|
+
cards: CarouselCard[];
|
|
100
|
+
}
|
|
101
|
+
interface LimitedTimeOfferOptions {
|
|
102
|
+
expiration_time_ms: number;
|
|
103
|
+
}
|
|
104
|
+
interface ProductSection {
|
|
105
|
+
title?: string;
|
|
106
|
+
product_items: Array<{
|
|
107
|
+
product_retailer_id: string;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
interface TemplateOptions {
|
|
111
|
+
name: string;
|
|
112
|
+
language: LanguagesEnum;
|
|
113
|
+
category: CategoryEnum;
|
|
114
|
+
header?: HeaderOptions;
|
|
115
|
+
body?: BodyOptions;
|
|
116
|
+
footer?: FooterOptions;
|
|
117
|
+
buttons?: ButtonOptions;
|
|
118
|
+
carousel?: CarouselOptions;
|
|
119
|
+
limitedTimeOffer?: LimitedTimeOfferOptions;
|
|
120
|
+
}
|
|
121
|
+
interface OTPTemplateOptions {
|
|
122
|
+
name: string;
|
|
123
|
+
language: LanguagesEnum;
|
|
124
|
+
code_expiration_minutes?: number;
|
|
125
|
+
add_security_recommendation?: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface AuthenticationTemplateOptions {
|
|
128
|
+
name: string;
|
|
129
|
+
language: LanguagesEnum;
|
|
130
|
+
code_expiration_minutes?: number;
|
|
131
|
+
add_security_recommendation?: boolean;
|
|
132
|
+
copy_code_button?: boolean;
|
|
133
|
+
}
|
|
134
|
+
interface CatalogTemplateOptions {
|
|
135
|
+
name: string;
|
|
136
|
+
language: LanguagesEnum;
|
|
137
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
138
|
+
body: BodyOptions;
|
|
139
|
+
footer?: FooterOptions;
|
|
140
|
+
thumbnail_product_retailer_id: string;
|
|
141
|
+
}
|
|
142
|
+
interface CouponTemplateOptions {
|
|
143
|
+
name: string;
|
|
144
|
+
language: LanguagesEnum;
|
|
145
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
146
|
+
body: BodyOptions;
|
|
147
|
+
footer?: FooterOptions;
|
|
148
|
+
coupon_code: string;
|
|
149
|
+
}
|
|
150
|
+
interface LimitedTimeOfferTemplateOptions {
|
|
151
|
+
name: string;
|
|
152
|
+
language: LanguagesEnum;
|
|
153
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
154
|
+
body: BodyOptions;
|
|
155
|
+
footer?: FooterOptions;
|
|
156
|
+
expiration_time_ms: number;
|
|
157
|
+
}
|
|
158
|
+
interface MediaCardCarouselTemplateOptions {
|
|
159
|
+
name: string;
|
|
160
|
+
language: LanguagesEnum;
|
|
161
|
+
cards: Array<{
|
|
162
|
+
header: {
|
|
163
|
+
format: 'IMAGE' | 'VIDEO';
|
|
164
|
+
example: {
|
|
165
|
+
header_handle: string[];
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
body: BodyOptions;
|
|
169
|
+
buttons?: ButtonOptions;
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
interface MPMTemplateOptions {
|
|
173
|
+
name: string;
|
|
174
|
+
language: LanguagesEnum;
|
|
175
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
176
|
+
body: BodyOptions;
|
|
177
|
+
footer?: FooterOptions;
|
|
178
|
+
thumbnail_product_retailer_id: string;
|
|
179
|
+
sections: ProductSection[];
|
|
180
|
+
}
|
|
181
|
+
interface ProductCardCarouselTemplateOptions {
|
|
182
|
+
name: string;
|
|
183
|
+
language: LanguagesEnum;
|
|
184
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
185
|
+
body: BodyOptions;
|
|
186
|
+
footer?: FooterOptions;
|
|
187
|
+
cards: Array<{
|
|
188
|
+
product_retailer_id: string;
|
|
189
|
+
}>;
|
|
190
|
+
}
|
|
191
|
+
interface SPMTemplateOptions {
|
|
192
|
+
name: string;
|
|
193
|
+
language: LanguagesEnum;
|
|
194
|
+
header?: Omit<HeaderOptions, 'format'>;
|
|
195
|
+
body: BodyOptions;
|
|
196
|
+
footer?: FooterOptions;
|
|
197
|
+
product_retailer_id: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type { AuthenticationTemplateOptions as A, BodyOptions as B, CarouselCard as C, DateTimeParameter as D, FooterOptions as F, HeaderOptions as H, LimitedTimeOfferOptions as L, MediaCardCarouselTemplateOptions as M, OTPTemplateOptions as O, ProductCardCarouselTemplateOptions as P, SPMTemplateOptions as S, TemplateOptions as T, ButtonOptions as a, CarouselOptions as b, CatalogTemplateOptions as c, CouponTemplateOptions as d, CurrencyParameter as e, LimitedTimeOfferTemplateOptions as f, LocationParameter as g, MediaParameter as h, MPMTemplateOptions as i, ProductParameter as j, ProductSection as k, TemplateParameter as l, TextParameter as m };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WhatsAppConfig } from './types/config.js';
|
|
2
|
+
|
|
3
|
+
interface BaseRequest {
|
|
4
|
+
method?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
headers: Record<string, string | string[] | undefined>;
|
|
7
|
+
body?: any;
|
|
8
|
+
query?: Record<string, any> | URLSearchParams;
|
|
9
|
+
rawBody?: any;
|
|
10
|
+
}
|
|
11
|
+
interface BaseResponse<T = any> {
|
|
12
|
+
status(code: number): T;
|
|
13
|
+
json?(data: any): T | void;
|
|
14
|
+
send?(data?: any): T | void;
|
|
15
|
+
setHeader?(name: string, value: string): void;
|
|
16
|
+
}
|
|
17
|
+
interface BaseWebhookConfig extends WhatsAppConfig {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type { BaseWebhookConfig as B, BaseRequest as a, BaseResponse as b };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
export { W as WhatsApp, W as WhatsAppLegacy } from './WhatsApp-
|
|
2
|
-
export {
|
|
1
|
+
export { W as WhatsApp, W as WhatsAppLegacy } from './WhatsApp-iAly_4pr.js';
|
|
2
|
+
export { E as EncryptionApi, a as EncryptionPublicKeyResponse } from './EncryptionApi-Dyea0SR3.js';
|
|
3
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-
|
|
5
|
-
export { a as
|
|
6
|
-
export { M as MediaApi } from './MediaApi-BrEKpqi_.js';
|
|
7
|
-
export { M as MessagesApi } from './MessageApi-
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { M as
|
|
4
|
+
export { F as FlowApi } from './FlowApi-DvoT7ivY.js';
|
|
5
|
+
export { d as Flow, a as FlowActionEnum, e as FlowAsset, f as FlowAssetsResponse, b as FlowCategoryEnum, g as FlowClass, h as FlowDataExchangeRequest, i as FlowDataExchangeResponse, j as FlowDecryptedRequestResponse, k as FlowEncryptedRequestPayload, l as FlowEndpointRequest, m as FlowEndpointResponse, n as FlowErrorNotificationRequest, o as FlowErrorNotificationResponse, p as FlowHealthCheckRequest, q as FlowHealthCheckResponse, r as FlowHttpRequest, s as FlowMigrationFailure, u as FlowMigrationResponse, t as FlowMigrationResult, v as FlowPreview, w as FlowPreviewResponse, c as FlowStatusEnum, y as FlowSuccessScreenResponse, z as FlowType, F as FlowTypeEnum, A as FlowValidationError, B as FlowValidationErrorPointer, x as FlowsListResponse, P as Pagination, C as PaginationCursors, U as UpdateFlowResponse, V as ValidateFlowJsonResponse } from './common-nVoO5ROn.js';
|
|
6
|
+
export { M as MediaApi, a as MediaClass, b as MediaResponse, c as MediasResponse, U as UploadMediaResponse } from './MediaApi-BrEKpqi_.js';
|
|
7
|
+
export { M as MessagesApi } from './MessageApi-D-9SuL4w.js';
|
|
8
|
+
export { A as AudioMediaObject, C as ContactObject, D as DocumentMediaObject, G as GeneralMessageBody, I as ImageMediaObject, f as InteractiveObject, L as LocationObject, M as MessageRequestBody, a as MessageRequestParams, g as MessageTemplateObject, b as MessagesClass, c as MessagesResponse, R as ReactionParams, S as StatusParams, e as StickerMediaObject, T as TextMessageParams, d as TextObject, V as VideoMediaObject } from './common-CzzMWFoO.js';
|
|
9
|
+
export { A as AccountMode, C as CodeVerificationStatus, a as Cursors, H as HealthStatus, b as HealthStatusEntity, M as MessagingLimitTier, P as PhoneNumberApi, c as PhoneNumberClass, d as PhoneNumberResponse, e as PhoneNumbersResponse, f as PlatformType, Q as QualityRating, g as QualityScore, R as RequestVerificationCodeRequest, T as Throughput, h as ThroughputLevel, i as TwoStepVerificationParams, V as VerifyCodeRequest } from './PhoneNumberApi-DKlu9PHl.js';
|
|
10
|
+
export { B as BusinessProfileApi, e as BusinessProfileClass, a as BusinessProfileData, c as BusinessProfileField, d as BusinessProfileFieldsParam, b as BusinessProfileResponse, U as UpdateBusinessProfileRequest } from './BusinessProfileApi-CW0emncx.js';
|
|
11
|
+
export { C as CreateQrCodeRequest, Q as QrCodeApi, a as QrCodeClass, b as QrCodeResponse, c as QrCodesResponse, U as UpdateQrCodeRequest } from './QrCodeApi-7vDwIBHR.js';
|
|
12
|
+
export { R as RegistrationApi, a as RegistrationClass, b as RegistrationRequest } from './RegistrationApi-qO_qoti9.js';
|
|
13
|
+
export { C as CatalogButton, a as ComponentTypes, b as CopyCodeButton, F as FlowButton, M as MPMButton, O as OTPButton, P as PhoneNumberButton, Q as QuickReplyButton, S as SPMButton, T as TemplateApi, c as TemplateBody, d as TemplateButton, e as TemplateButtons, f as TemplateCarousel, g as TemplateClass, h as TemplateDeleteParams, i as TemplateFooter, j as TemplateFormat, k as TemplateGetParams, l as TemplateHeader, m as TemplateHeaderExample, n as TemplateLimitedTimeOffer, o as TemplateRequestBody, p as TemplateResponse, U as URLButton } from './TemplateApi-D4_6LvhN.js';
|
|
14
|
+
export { A as AuthenticationTemplateOptions, B as BodyOptions, a as ButtonOptions, C as CarouselCard, b as CarouselOptions, c as CatalogTemplateOptions, d as CouponTemplateOptions, e as CurrencyParameter, D as DateTimeParameter, F as FooterOptions, H as HeaderOptions, L as LimitedTimeOfferOptions, f as LimitedTimeOfferTemplateOptions, g as LocationParameter, i as MPMTemplateOptions, M as MediaCardCarouselTemplateOptions, h as MediaParameter, O as OTPTemplateOptions, P as ProductCardCarouselTemplateOptions, j as ProductParameter, k as ProductSection, S as SPMTemplateOptions, T as TemplateOptions, l as TemplateParameter, m as TextParameter } from './factory-D2eO5etK.js';
|
|
15
|
+
export { T as TwoStepVerificationApi, a as TwoStepVerificationClass, b as TwoStepVerificationRequest } from './TwoStepVerificationApi-DfNPIz-C.js';
|
|
16
|
+
export { U as UpdateWabaSubscription, b as WABAClass, a as WabaAccount, W as WabaApi, c as WabaSubscription, d as WabaSubscriptions } from './WabaApi-BvY1JVRH.js';
|
|
17
|
+
export { W as WebhookContact, a as WebhookEvent, b as WebhookMessage } from './WebhookProcessor-CE4xBPe0.js';
|
|
18
|
+
export { WabaConfigType, WhatsAppConfig } from './types/config.js';
|
|
19
|
+
export { M as MetaError, i as isFlowDataExchangeRequest, a as isFlowErrorRequest, b as isFlowPingRequest, c as isMetaError } from './isMetaError-CLqzdSws.js';
|
|
14
20
|
export { webhookHandler as ExpressWebhook } from './core/webhook/frameworks/express.js';
|
|
15
21
|
export { webhookHandler as NextJsWebhook } from './core/webhook/frameworks/nextjs.js';
|
|
16
22
|
import './request-vYMaEfk5.js';
|
|
17
23
|
import './httpsClient-v4gmltzS.js';
|
|
18
24
|
import 'https';
|
|
19
|
-
import './EncryptionApi-D7pt-OXT.js';
|
|
20
25
|
import './base-CdGDdVEl.js';
|
|
21
|
-
import '
|
|
22
|
-
import './
|
|
23
|
-
import './WabaApi-DqQi_68m.js';
|
|
24
|
-
import './common-BiRA_uz3.js';
|
|
26
|
+
import 'http';
|
|
27
|
+
import './handler-DbySwF0E.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./chunk-RWCVPWRC.js';export{a as ExpressWebhook}from'./chunk-
|
|
1
|
+
import'./chunk-RWCVPWRC.js';export{a as ExpressWebhook}from'./chunk-ZMNXRMWK.js';export{a as NextJsWebhook}from'./chunk-GM63NGNV.js';import'./chunk-5577QQ7V.js';import'./chunk-U5FBZ6UB.js';export{a as isFlowDataExchangeRequest,b as isFlowErrorRequest,c as isFlowPingRequest}from'./chunk-6DFC5L3X.js';export{b as WhatsApp,b as WhatsAppLegacy}from'./chunk-BAOZ4U74.js';export{c as isMetaError}from'./chunk-FKXSL2JK.js';import'./chunk-AMHQGG6Z.js';export{a as TemplateApi}from'./chunk-VHAODWCN.js';export{b as QrCodeApi}from'./chunk-JPAV644F.js';export{b as RegistrationApi}from'./chunk-PHPQ5HP3.js';export{b as EncryptionApi}from'./chunk-IYSR44P6.js';export{b as TwoStepVerificationApi}from'./chunk-SNNRWNGZ.js';export{b as WabaApi}from'./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';export{c as FlowActionEnum,b as FlowCategoryEnum,a as FlowStatusEnum,d as FlowTypeEnum}from'./chunk-J2JPTKU6.js';export{b as PhoneNumberApi}from'./chunk-FSKBLPGE.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
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as FlowEndpointRequest, h as FlowDataExchangeRequest, a as FlowActionEnum, n as FlowErrorNotificationRequest, p as FlowHealthCheckRequest } from './common-nVoO5ROn.js';
|
|
2
2
|
|
|
3
3
|
declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
|
|
4
4
|
declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { WabaConfigType } from '../types/config.js';
|
|
2
|
-
export { M as MetaError, i as isFlowDataExchangeRequest, a as isFlowErrorRequest, b as isFlowPingRequest, c as isMetaError } from '../isMetaError-
|
|
2
|
+
export { M as MetaError, i as isFlowDataExchangeRequest, a as isFlowErrorRequest, b as isFlowPingRequest, c as isMetaError } from '../isMetaError-CLqzdSws.js';
|
|
3
3
|
import { L as LoggerInterface } from '../logger-BdE0Vyim.js';
|
|
4
4
|
import '../enums-BZd9T2ul.js';
|
|
5
|
-
import '../common-
|
|
5
|
+
import '../common-nVoO5ROn.js';
|
|
6
6
|
import '../request-vYMaEfk5.js';
|
|
7
|
+
import 'http';
|
|
7
8
|
|
|
8
9
|
declare function buildFieldsQueryString(fields?: string[] | string): string;
|
|
9
10
|
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as isFlowDataExchangeRequest,b as isFlowErrorRequest,c as isFlowPingRequest}from'../chunk-
|
|
1
|
+
export{a as isFlowDataExchangeRequest,b as isFlowErrorRequest,c as isFlowPingRequest}from'../chunk-6DFC5L3X.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-J2JPTKU6.js';export{a as objectToQueryString}from'../chunk-MJEG3K4V.js';import'../chunk-KMAH6636.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meta-cloud-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "TypeScript wrapper for Meta's Cloud API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
|
+
"scripts": {
|
|
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
|
+
"changeset": "changeset",
|
|
22
|
+
"changeset:version": "changeset version",
|
|
23
|
+
"changeset:publish": "changeset publish",
|
|
24
|
+
"release": "pnpm build && changeset publish"
|
|
25
|
+
},
|
|
9
26
|
"publishConfig": {
|
|
10
27
|
"access": "public"
|
|
11
28
|
},
|
|
@@ -15,95 +32,70 @@
|
|
|
15
32
|
"import": "./dist/index.js",
|
|
16
33
|
"default": "./dist/index.js"
|
|
17
34
|
},
|
|
18
|
-
"./
|
|
35
|
+
"./api": {
|
|
36
|
+
"types": "./dist/api/index.d.ts",
|
|
37
|
+
"import": "./dist/api/index.js",
|
|
38
|
+
"default": "./dist/api/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./api/messages": {
|
|
19
41
|
"types": "./dist/api/messages/index.d.ts",
|
|
20
42
|
"import": "./dist/api/messages/index.js",
|
|
21
43
|
"default": "./dist/api/messages/index.js"
|
|
22
44
|
},
|
|
23
|
-
"./
|
|
45
|
+
"./api/messages/builders": {
|
|
46
|
+
"types": "./dist/api/messages/builders/index.d.ts",
|
|
47
|
+
"import": "./dist/api/messages/builders/index.js",
|
|
48
|
+
"default": "./dist/api/messages/builders/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./api/media": {
|
|
24
51
|
"types": "./dist/api/media/index.d.ts",
|
|
25
52
|
"import": "./dist/api/media/index.js",
|
|
26
53
|
"default": "./dist/api/media/index.js"
|
|
27
54
|
},
|
|
28
|
-
"./
|
|
29
|
-
"types": "./dist/api/profile/index.d.ts",
|
|
30
|
-
"import": "./dist/api/profile/index.js",
|
|
31
|
-
"default": "./dist/api/profile/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./flow": {
|
|
55
|
+
"./api/flow": {
|
|
34
56
|
"types": "./dist/api/flow/index.d.ts",
|
|
35
57
|
"import": "./dist/api/flow/index.js",
|
|
36
58
|
"default": "./dist/api/flow/index.js"
|
|
37
59
|
},
|
|
38
|
-
"./phone": {
|
|
60
|
+
"./api/phone": {
|
|
39
61
|
"types": "./dist/api/phone/index.d.ts",
|
|
40
62
|
"import": "./dist/api/phone/index.js",
|
|
41
63
|
"default": "./dist/api/phone/index.js"
|
|
42
64
|
},
|
|
43
|
-
"./
|
|
65
|
+
"./api/profile": {
|
|
66
|
+
"types": "./dist/api/profile/index.d.ts",
|
|
67
|
+
"import": "./dist/api/profile/index.js",
|
|
68
|
+
"default": "./dist/api/profile/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./api/template": {
|
|
44
71
|
"types": "./dist/api/template/index.d.ts",
|
|
45
72
|
"import": "./dist/api/template/index.js",
|
|
46
73
|
"default": "./dist/api/template/index.js"
|
|
47
74
|
},
|
|
48
|
-
"./
|
|
49
|
-
"types": "./dist/api/waba/index.d.ts",
|
|
50
|
-
"import": "./dist/api/waba/index.js",
|
|
51
|
-
"default": "./dist/api/waba/index.js"
|
|
52
|
-
},
|
|
53
|
-
"./qrCode": {
|
|
75
|
+
"./api/qrCode": {
|
|
54
76
|
"types": "./dist/api/qrCode/index.d.ts",
|
|
55
77
|
"import": "./dist/api/qrCode/index.js",
|
|
56
78
|
"default": "./dist/api/qrCode/index.js"
|
|
57
79
|
},
|
|
58
|
-
"./
|
|
59
|
-
"types": "./dist/api/twoStepVerification/index.d.ts",
|
|
60
|
-
"import": "./dist/api/twoStepVerification/index.js",
|
|
61
|
-
"default": "./dist/api/twoStepVerification/index.js"
|
|
62
|
-
},
|
|
63
|
-
"./encryption": {
|
|
64
|
-
"types": "./dist/api/encryption/index.d.ts",
|
|
65
|
-
"import": "./dist/api/encryption/index.js",
|
|
66
|
-
"default": "./dist/api/encryption/index.js"
|
|
67
|
-
},
|
|
68
|
-
"./registration": {
|
|
80
|
+
"./api/registration": {
|
|
69
81
|
"types": "./dist/api/registration/index.d.ts",
|
|
70
82
|
"import": "./dist/api/registration/index.js",
|
|
71
83
|
"default": "./dist/api/registration/index.js"
|
|
72
84
|
},
|
|
73
|
-
"./
|
|
74
|
-
"types": "./dist/
|
|
75
|
-
"import": "./dist/
|
|
76
|
-
"default": "./dist/
|
|
77
|
-
},
|
|
78
|
-
"./shared/utils": {
|
|
79
|
-
"types": "./dist/shared/utils/index.d.ts",
|
|
80
|
-
"import": "./dist/shared/utils/index.js",
|
|
81
|
-
"default": "./dist/shared/utils/index.js"
|
|
82
|
-
},
|
|
83
|
-
"./api": {
|
|
84
|
-
"types": "./dist/api/index.d.ts",
|
|
85
|
-
"import": "./dist/api/index.js",
|
|
86
|
-
"default": "./dist/api/index.js"
|
|
87
|
-
},
|
|
88
|
-
"./api/messages": {
|
|
89
|
-
"types": "./dist/api/messages.d.ts",
|
|
90
|
-
"import": "./dist/api/messages.js",
|
|
91
|
-
"default": "./dist/api/messages.js"
|
|
92
|
-
},
|
|
93
|
-
"./api/messages/builders": {
|
|
94
|
-
"types": "./dist/api/messages/builders/index.d.ts",
|
|
95
|
-
"import": "./dist/api/messages/builders/index.js",
|
|
96
|
-
"default": "./dist/api/messages/builders/index.js"
|
|
85
|
+
"./api/encryption": {
|
|
86
|
+
"types": "./dist/api/encryption/index.d.ts",
|
|
87
|
+
"import": "./dist/api/encryption/index.js",
|
|
88
|
+
"default": "./dist/api/encryption/index.js"
|
|
97
89
|
},
|
|
98
|
-
"./api/
|
|
99
|
-
"types": "./dist/api/
|
|
100
|
-
"import": "./dist/api/
|
|
101
|
-
"default": "./dist/api/
|
|
90
|
+
"./api/twoStepVerification": {
|
|
91
|
+
"types": "./dist/api/twoStepVerification/index.d.ts",
|
|
92
|
+
"import": "./dist/api/twoStepVerification/index.js",
|
|
93
|
+
"default": "./dist/api/twoStepVerification/index.js"
|
|
102
94
|
},
|
|
103
|
-
"./api/
|
|
104
|
-
"types": "./dist/api/
|
|
105
|
-
"import": "./dist/api/
|
|
106
|
-
"default": "./dist/api/
|
|
95
|
+
"./api/waba": {
|
|
96
|
+
"types": "./dist/api/waba/index.d.ts",
|
|
97
|
+
"import": "./dist/api/waba/index.js",
|
|
98
|
+
"default": "./dist/api/waba/index.js"
|
|
107
99
|
},
|
|
108
100
|
"./utils": {
|
|
109
101
|
"types": "./dist/utils/index.d.ts",
|
|
@@ -125,6 +117,11 @@
|
|
|
125
117
|
"import": "./dist/core/webhook/frameworks/nextjs.js",
|
|
126
118
|
"default": "./dist/core/webhook/frameworks/nextjs.js"
|
|
127
119
|
},
|
|
120
|
+
"./webhook/nextjs-app": {
|
|
121
|
+
"types": "./dist/core/webhook/frameworks/nextjs-app.d.ts",
|
|
122
|
+
"import": "./dist/core/webhook/frameworks/nextjs-app.js",
|
|
123
|
+
"default": "./dist/core/webhook/frameworks/nextjs-app.js"
|
|
124
|
+
},
|
|
128
125
|
"./types": {
|
|
129
126
|
"types": "./dist/types/index.d.ts",
|
|
130
127
|
"import": "./dist/types/index.js",
|
|
@@ -177,6 +174,7 @@
|
|
|
177
174
|
],
|
|
178
175
|
"author": "froggy1014",
|
|
179
176
|
"license": "MIT",
|
|
177
|
+
"packageManager": "pnpm@10.11.0",
|
|
180
178
|
"homepage": "https://github.com/froggy1014/meta-cloud-api#readme",
|
|
181
179
|
"repository": {
|
|
182
180
|
"type": "git",
|
|
@@ -232,20 +230,5 @@
|
|
|
232
230
|
"commitizen": {
|
|
233
231
|
"path": "@commitlint/cz-commitlint"
|
|
234
232
|
}
|
|
235
|
-
},
|
|
236
|
-
"scripts": {
|
|
237
|
-
"cz": "cz",
|
|
238
|
-
"dev": "tsup --watch",
|
|
239
|
-
"build": "tsup --clean",
|
|
240
|
-
"format": "prettier .",
|
|
241
|
-
"lint": "eslint .",
|
|
242
|
-
"clean": "rm -rf dist node_modules",
|
|
243
|
-
"typecheck": "tsc --noEmit",
|
|
244
|
-
"test": "vitest run",
|
|
245
|
-
"test:watch": "vitest --watch",
|
|
246
|
-
"changeset": "changeset",
|
|
247
|
-
"changeset:version": "changeset version",
|
|
248
|
-
"changeset:publish": "changeset publish",
|
|
249
|
-
"release": "pnpm build && changeset publish"
|
|
250
233
|
}
|
|
251
|
-
}
|
|
234
|
+
}
|
package/dist/chunk-NLF2JGYY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/flow/types/common.ts"],"names":["FlowTypeEnum"],"mappings":"AAsCO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GAERA,CAAAA,CAAA,IAAA,CAAO,MAAA,CAEPA,CAAAA,CAAA,MAAA,CAAS,eAAA,CAETA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAERA,CAAAA,CAAA,GAAA,CAAM,IAREA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA","file":"chunk-NLF2JGYY.js","sourcesContent":["import { ResponseSuccess } from '../../../types';\nimport { IncomingHttpHeaders, IncomingMessage } from 'http';\n\n/**\n * Enum for Flow Status\n */\nexport enum FlowStatusEnum {\n Draft = 'DRAFT',\n Published = 'PUBLISHED',\n Throttled = 'THROTTLED',\n Blocked = 'BLOCKED',\n Deprecated = 'DEPRECATED',\n}\n\n/**\n * Enum for Flow Categories\n */\nexport enum FlowCategoryEnum {\n SignUp = 'SIGN_UP',\n SignIn = 'SIGN_IN',\n AppointmentBooking = 'APPOINTMENT_BOOKING',\n LeadGeneration = 'LEAD_GENERATION',\n ContactUs = 'CONTACT_US',\n CustomerSupport = 'CUSTOMER_SUPPORT',\n Survey = 'SURVEY',\n Other = 'OTHER',\n}\n\nexport enum FlowActionEnum {\n INIT = 'INIT',\n BACK = 'BACK',\n DATA_EXCHANGE = 'data_exchange',\n}\n\n/**\n * Enum for Flow Types in webhook handlers\n * Used to register handlers for specific flow events\n */\nexport enum FlowTypeEnum {\n /** Health check/ping requests */\n Ping = 'ping',\n /** Data exchange requests */\n Change = 'data_exchange',\n /** Error notification requests */\n Error = 'error',\n /** Match all flow action types */\n All = '*',\n}\n\nexport type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];\n\n/**\n * Flow Validation Error Pointer\n */\nexport interface FlowValidationErrorPointer {\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n path: string;\n}\n\n/**\n * Flow Validation Error\n */\nexport interface FlowValidationError {\n error: string;\n error_type: string;\n message: string;\n line_start: number;\n line_end: number;\n column_start: number;\n column_end: number;\n pointers: FlowValidationErrorPointer[];\n}\n\n/**\n * Flow Item\n */\nexport interface Flow {\n id: string;\n name: string;\n status: FlowStatusEnum;\n categories: FlowCategoryEnum[];\n validation_errors: FlowValidationError[];\n}\n\n/**\n * Pagination Cursors\n */\nexport interface PaginationCursors {\n before: string;\n after: string;\n}\n\n/**\n * Pagination Object\n */\nexport interface Pagination {\n cursors: PaginationCursors;\n}\n\n/**\n * Flows List Response\n */\nexport interface FlowsListResponse {\n data: Flow[];\n paging: Pagination;\n}\n\n/**\n * Flow Asset\n */\nexport interface FlowAsset {\n name: string;\n asset_type: string;\n download_url: string;\n}\n\n/**\n * Flow Assets Response\n */\nexport interface FlowAssetsResponse {\n data: FlowAsset[];\n paging: Pagination;\n}\n\n/**\n * Flow Preview\n */\nexport interface FlowPreview {\n preview_url: string;\n expires_at: string;\n}\n\n/**\n * Flow Preview Response\n */\nexport interface FlowPreviewResponse {\n preview: FlowPreview;\n id: string;\n}\n\n/**\n * Flow Migration Result\n */\nexport interface FlowMigrationResult {\n source_name: string;\n source_id: string;\n migrated_id: string;\n}\n\n/**\n * Flow Migration Failure\n */\nexport interface FlowMigrationFailure {\n source_name: string;\n error_code: string;\n error_message: string;\n}\n\n/**\n * Create Flow Response\n */\nexport interface CreateFlowResponse {\n id: string;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Update Flow Response\n */\nexport interface UpdateFlowResponse {\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * Flow Migration Response\n */\nexport interface FlowMigrationResponse {\n migrated_flows: FlowMigrationResult[];\n failed_flows: FlowMigrationFailure[];\n}\n\n/**\n * Validate Flow JSON Response\n */\nexport interface ValidateFlowJsonResponse {\n valid: boolean;\n success: boolean;\n validation_errors?: FlowValidationError[];\n}\n\n/**\n * WhatsApp Flow Endpoint - Encrypted Request Payload\n * Represents the raw encrypted data received from WhatsApp\n */\nexport interface FlowEncryptedRequestPayload {\n encrypted_aes_key: string;\n encrypted_flow_data: string;\n initial_vector: string;\n}\n\n/**\n * WhatsApp Flow Endpoint - Decrypted Request Response\n * Represents the successfully decrypted data and encryption keys\n */\nexport interface FlowDecryptedRequestResponse {\n decryptedBody: any;\n aesKeyBuffer: Buffer;\n initialVectorBuffer: Buffer;\n}\n\n/**\n * WhatsApp Flow Endpoint - HTTP Request with Body\n * Represents an HTTP request with the encrypted payload\n */\nexport interface FlowHttpRequest extends IncomingMessage {\n body: FlowEncryptedRequestPayload;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Request\n * Represents the structure of a health check request\n */\nexport interface FlowHealthCheckRequest {\n action: 'ping';\n version: '3.0';\n}\n\n/**\n * WhatsApp Flow Endpoint - Health Check Response\n * The expected response structure for health check requests\n */\nexport interface FlowHealthCheckResponse {\n data: {\n status: 'active';\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Request\n * Represents the structure of a data exchange request\n */\nexport interface FlowDataExchangeRequest {\n version: '3.0';\n action: FlowActionEnum;\n screen: string;\n flow_token: string;\n data?: Record<string, any> & { error_message?: string };\n}\n\n/**\n * WhatsApp Flow Endpoint - Data Exchange Response\n * The expected response structure for data exchange requests\n */\nexport interface FlowDataExchangeResponse {\n screen?: string;\n data?: Record<string, any | { error_message?: string }>;\n}\n\n/**\n * WhatsApp Flow Endpoint - Success Screen Response\n * The expected response structure for success screen requests\n */\nexport interface FlowSuccessScreenResponse {\n screen: 'SUCCESS';\n data: {\n extension_message_response?: {\n params?: {\n flow_token: string;\n [key: string]: string;\n };\n };\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Request\n * Represents the structure of an error notification request\n */\nexport interface FlowErrorNotificationRequest {\n version: '3.0';\n action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Error Notification Response\n * The expected response structure for error notification requests\n */\nexport interface FlowErrorNotificationResponse {\n acknowledged: boolean;\n}\n\n/**\n * WhatsApp Flow Endpoint - Comprehensive Request Object\n * A combined type that includes all possible fields from different request types\n * with all fields being optional for flexibility\n */\nexport interface FlowEndpointRequest {\n // Common fields\n version?: '3.0';\n action?: 'ping' | FlowActionEnum;\n\n screen?: string;\n flow_token?: string;\n\n data?: Record<string, any> & {\n error_key?: string;\n error_message?: string;\n };\n}\n\n/**\n * WhatsApp Flow Endpoint - Response\n * Union type for all possible response types from a Flow endpoint\n */\nexport type FlowEndpointResponse =\n | FlowHealthCheckResponse\n | FlowDataExchangeResponse\n | FlowErrorNotificationResponse\n | FlowSuccessScreenResponse;\n\nexport interface FlowClass {\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n listFlows(wabaId: string): Promise<FlowsListResponse>;\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<CreateFlowResponse>;\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<ResponseSuccess>;\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deleteFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n listAssets(flowId: string): Promise<FlowAssetsResponse>;\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n updateFlowJson(\n flowId: string,\n data: {\n file: Blob | Buffer | object;\n name?: string;\n },\n ): Promise<UpdateFlowResponse>;\n\n /**\n * Validate Flow JSON by attempting an update without publishing.\n * This is a convenience method; the API doesn't have a dedicated validation endpoint.\n *\n * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).\n * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.\n * @returns Promise indicating if the JSON is valid and includes validation errors if any.\n */\n validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n publishFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n deprecateFlow(flowId: string): Promise<ResponseSuccess>;\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<FlowMigrationResponse>;\n}\n"]}
|
package/dist/chunk-NOJFGTRT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {d,c}from'./chunk-JPGXONBQ.js';function b(h){let d$1=new d(h);return {webhook:async(e,r,i)=>{try{if(e.method==="GET"){let{"hub.mode":s,"hub.verify_token":n,"hub.challenge":t}=e.query,o=await d$1.processVerification(s||null,n||null,t||null);return Object.entries(o.headers).forEach(([a,l])=>{r.setHeader(a,l);}),r.status(o.status).send(o.body)}if(e.method==="POST"){let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),t=await d$1.processWebhook(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}return r.status(405).json({error:"Method Not Allowed"})}catch(s){i(s);return}},flow:async(e,r,i)=>{try{let s=c(e.headers,e.url),n=new globalThis.Request(s,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),t=await d$1.processFlow(n);return Object.entries(t.headers).forEach(([o,a])=>{r.setHeader(o,a);}),r.status(t.status).send(t.body)}catch(s){i(s);return}},processor:d$1}}export{b as a};//# sourceMappingURL=chunk-NOJFGTRT.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-NOJFGTRT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/webhook/frameworks/express.ts"],"names":["webhookHandler","config","processor","WebhookProcessor","req","res","next","mode","token","challenge","result","key","value","fullUrl","constructFullUrl","webRequest","error"],"mappings":"sCA6BO,SAASA,CAAAA,CAAeC,CAAAA,CAA8B,CACzD,IAAMC,GAAAA,CAAY,IAAIC,CAAAA,CAAiBF,CAAM,CAAA,CAE7C,OAAO,CAEH,OAAA,CAAS,MAAOG,CAAAA,CAAqBC,CAAAA,CAAsBC,CAAAA,GAAuB,CAC9E,GAAI,CACA,GAAIF,CAAAA,CAAI,MAAA,GAAW,KAAA,CAAO,CACtB,GAAM,CAAE,UAAA,CAAYG,CAAAA,CAAM,kBAAA,CAAoBC,CAAAA,CAAO,eAAA,CAAiBC,CAAU,CAAA,CAAIL,CAAAA,CAAI,KAAA,CAElFM,CAAAA,CAAS,MAAMR,GAAAA,CAAU,mBAAA,CAC1BK,CAAAA,EAAmB,IAAA,CACnBC,CAAAA,EAAoB,IAAA,CACpBC,CAAAA,EAAwB,IAC7B,CAAA,CAEA,OAAA,MAAA,CAAO,OAAA,CAAQC,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDP,CAAAA,CAAI,SAAA,CAAUM,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMP,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAEA,GAAIN,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAQ,CAEvB,IAAMS,CAAAA,CAAUC,CAAAA,CAAiBV,CAAAA,CAAI,OAAA,CAASA,CAAAA,CAAI,GAAG,CAAA,CAC/CW,CAAAA,CAAa,IAAI,UAAA,CAAW,OAAA,CAAQF,CAAAA,CAAS,CAC/C,MAAA,CAAQT,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,CAAAA,CAAI,OAAA,CACb,IAAA,CAAM,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CACjC,CAAC,CAAA,CAEKM,CAAAA,CAAS,MAAMR,GAAAA,CAAU,cAAA,CAAea,CAAU,CAAA,CAExD,OAAA,MAAA,CAAO,OAAA,CAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,IAAM,CACrDP,CAAAA,CAAI,SAAA,CAAUM,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMP,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAEA,OAAOL,CAAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,CAAE,KAAA,CAAO,oBAAqB,CAAC,CAC/D,CAAA,MAASW,CAAAA,CAAO,CACZV,CAAAA,CAAKU,CAAK,CAAA,CACV,MACJ,CACJ,CAAA,CAGA,IAAA,CAAM,MAAOZ,CAAAA,CAAqBC,CAAAA,CAAsBC,CAAAA,GAAuB,CAC3E,GAAI,CAEA,IAAMO,CAAAA,CAAUC,CAAAA,CAAiBV,CAAAA,CAAI,OAAA,CAASA,CAAAA,CAAI,GAAG,CAAA,CAC/CW,CAAAA,CAAa,IAAI,UAAA,CAAW,OAAA,CAAQF,CAAAA,CAAS,CAC/C,MAAA,CAAQT,CAAAA,CAAI,OACZ,OAAA,CAASA,CAAAA,CAAI,OAAA,CACb,IAAA,CAAMA,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAS,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CAAA,CAAI,KAAA,CAC7D,CAAC,CAAA,CAEKM,CAAAA,CAAS,MAAMR,GAAAA,CAAU,WAAA,CAAYa,CAAU,CAAA,CAErD,OAAA,MAAA,CAAO,OAAA,CAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDP,CAAAA,CAAI,SAAA,CAAUM,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMP,CAAAA,CAAI,MAAA,CAAOK,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAAA,MAASM,CAAAA,CAAO,CACZV,CAAAA,CAAKU,CAAK,CAAA,CACV,MACJ,CACJ,CAAA,CAGA,SAAA,CAAAd,GACJ,CACJ","file":"chunk-NOJFGTRT.js","sourcesContent":["import { WhatsAppConfig } from '../../../types/config';\nimport { WebhookProcessor } from '../WebhookProcessor';\nimport { constructFullUrl } from '../utils/webhookUtils';\n\n// Express-like interfaces to avoid direct Express dependency\nexport interface ExpressRequest {\n method: string;\n url: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Record<string, any>;\n rawBody?: any;\n}\n\nexport interface ExpressResponse {\n status(code: number): ExpressResponse;\n json(data: any): ExpressResponse;\n send(data?: any): ExpressResponse;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextFunction {\n (error?: any): void;\n}\n\nexport interface ExpressWebhookConfig extends WhatsAppConfig {\n path?: string;\n}\n\nexport function webhookHandler(config: ExpressWebhookConfig) {\n const processor = new WebhookProcessor(config);\n\n return {\n // Main webhook handler\n webhook: async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {\n try {\n if (req.method === 'GET') {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await processor.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n if (req.method === 'POST') {\n // Create Web Standard Request from Express request with proper full URL\n const fullUrl = constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await processor.processWebhook(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n return res.status(405).json({ error: 'Method Not Allowed' });\n } catch (error) {\n next(error);\n return;\n }\n },\n\n // Flow handler\n flow: async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {\n try {\n // Create Web Standard Request from Express request with proper full URL\n const fullUrl = constructFullUrl(req.headers, req.url);\n const webRequest = new globalThis.Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await processor.processFlow(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n } catch (error) {\n next(error);\n return;\n }\n },\n\n // Expose processor for handler registration\n processor,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/flowTypeGuards.ts"],"names":["isObject","value","isString","DATA_EXCHANGE_ACTIONS","ERROR_ACTIONS","isFlowDataExchangeRequest","request","action","version","screen","data","hasValidVersion","hasValidAction","hasValidScreen","hasValidData","isFlowErrorRequest","isFlowPingRequest"],"mappings":"AAaA,SAASA,CAAAA,CAASC,CAAAA,CAAkD,CAChE,OAAO,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,GAAU,IAClD,CAOA,SAASC,CAAAA,CAASD,CAAAA,CAAiC,CAC/C,OAAO,OAAOA,CAAAA,EAAU,QAC5B,CAGA,IAAME,CAAAA,CAAwB,CAAA,eAAA,CAAA,MAAA,CAAA,MAAuE,CAAA,CAG/FC,EAAgB,CAAA,eAAA,CAAA,MAAkD,CAAA,CASjE,SAASC,CAAAA,CAA0BC,EAKxC,CAEE,GAAI,EAAE,YAAA,GAAgBA,GAAWJ,CAAAA,CAASI,CAAAA,CAAQ,UAAU,CAAA,EAAK,QAAA,GAAYA,CAAAA,CAAAA,CACzE,OAAO,MAAA,CAGX,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAQ,OAAA,CAAAC,EAAS,MAAA,CAAAC,CAAAA,CAAQ,IAAA,CAAAC,CAAK,EAAIJ,CAAAA,CAGpCK,CAAAA,CAAkBH,CAAAA,GAAY,KAAA,CAG9BI,CAAAA,CAAiBT,CAAAA,CAAsB,QAAA,CAASI,CAAa,EAG7DM,CAAAA,CAAiB,OAAOJ,CAAAA,CAAW,GAAA,EAAgBP,EAASO,CAAM,CAAA,EAAKA,CAAAA,GAAW,SAAA,CAGlFK,EAAeP,CAAAA,GAAW,eAAA,EAAgCP,CAAAA,CAASU,CAAI,CAAA,CAG7E,OAAOC,CAAAA,EAAmBC,CAAAA,EAAkBC,GAAkBC,CAClE,CASO,SAASC,CAAAA,CAAmBT,EAQjC,CAEE,GAAI,EAAE,YAAA,GAAgBA,GAAWJ,CAAAA,CAASI,CAAAA,CAAQ,UAAU,CAAA,EAAK,QAAA,GAAYA,CAAAA,CAAAA,CACzE,OAAO,MAAA,CAGX,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAQ,MAAA,CAAAE,EAAQ,IAAA,CAAAC,CAAK,CAAA,CAAIJ,CAAAA,CAG3BM,EAAiBR,CAAAA,CAAc,QAAA,CAASG,CAAa,CAAA,CAGrDM,CAAAA,CAAiBX,CAAAA,CAASO,CAAM,CAAA,CAGhCK,EACFd,CAAAA,CAASU,CAAI,CAAA,EACb,WAAA,GAAeA,GACfR,CAAAA,CAASQ,CAAAA,CAAK,KAAK,CAAA,EACnB,kBAAmBA,CAAAA,EACnBR,CAAAA,CAASQ,CAAAA,CAAK,aAAa,CAAA,CAG/B,OAAOE,CAAAA,EAAkBC,CAAAA,EAAkBC,CAC/C,CASO,SAASE,CAAAA,CAAkBV,CAAAA,CAAiE,CAE/F,OAAO,QAAA,GAAYA,CAAAA,EAAWA,CAAAA,CAAQ,SAAW,MACrD","file":"chunk-WGGN32O2.js","sourcesContent":["import {\n FlowActionEnum,\n FlowDataExchangeRequest,\n FlowEndpointRequest,\n FlowErrorNotificationRequest,\n FlowHealthCheckRequest,\n} from '@api/flow/types';\n\n/**\n * Helper function to check if a value is an object\n * @param value The value to check\n * @returns True if the value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Helper function to check if a value is a string\n * @param value The value to check\n * @returns True if the value is a string\n */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n// Array of allowed action types for data exchange requests\nconst DATA_EXCHANGE_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK] as const;\n\n// Array of allowed action types for error notification requests\nconst ERROR_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT] as const;\n\n/**\n * Type guard to check if a request is a Data Exchange request\n * Validates the request structure according to the Flow API specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Data Exchange request, false otherwise\n */\nexport function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {\n action: (typeof DATA_EXCHANGE_ACTIONS)[number];\n screen?: string;\n flow_token: string;\n data?: Record<string, any>;\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, version, screen, data } = request;\n\n // Validate API version\n const hasValidVersion = version === '3.0';\n\n // Check if the action is one of the allowed actions for data exchange\n const hasValidAction = DATA_EXCHANGE_ACTIONS.includes(action as any);\n\n // Screen is optional, but when present must be a string and not 'SUCCESS'\n const hasValidScreen = typeof screen === 'undefined' || (isString(screen) && screen !== 'SUCCESS');\n\n // Data is required except for DATA_EXCHANGE action\n const hasValidData = action === FlowActionEnum.DATA_EXCHANGE || isObject(data);\n\n // All conditions must be met for a valid data exchange request\n return hasValidVersion && hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is an Error Notification request\n * Validates the request structure according to the Flow API error specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Error Notification request, false otherwise\n */\nexport function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {\n action: (typeof ERROR_ACTIONS)[number];\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, screen, data } = request;\n\n // Check if the action is one of the allowed actions for error notifications\n const hasValidAction = ERROR_ACTIONS.includes(action as any);\n\n // Screen is required for error notifications\n const hasValidScreen = isString(screen);\n\n // Validate error data structure\n const hasValidData =\n isObject(data) &&\n 'error_key' in data &&\n isString(data.error) &&\n 'error_message' in data &&\n isString(data.error_message);\n\n // All conditions must be met for a valid error notification request\n return hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is a Ping (health check) request\n * Simple validation for health check endpoints in the Flow API\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a Ping request, false otherwise\n */\nexport function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest {\n // A ping request only requires the 'action' field with value 'ping'\n return 'action' in request && request.action === 'ping';\n}\n"]}
|
package/dist/chunk-YXZ4L2OK.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {d,c}from'./chunk-JPGXONBQ.js';function y(c$1){let d$1=new d(c$1);return {webhook:async(e,t)=>{try{if(e.method==="GET"){let{"hub.mode":s,"hub.verify_token":n,"hub.challenge":r}=e.query,o=await d$1.processVerification(s||null,n||null,r||null);return Object.entries(o.headers).forEach(([a,h])=>{t.setHeader(a,h);}),t.status(o.status).send(o.body)}if(e.method==="POST"){let s=c(e.headers,e.url),n=new Request(s,{method:e.method,headers:e.headers,body:JSON.stringify(e.body)}),r=await d$1.processWebhook(n);return Object.entries(r.headers).forEach(([o,a])=>{t.setHeader(o,a);}),t.status(r.status).send(r.body)}return t.status(405).json({error:"Method Not Allowed"})}catch(s){return console.error("Webhook error:",s),t.status(500).json({error:"Internal Server Error"})}},flow:async(e,t)=>{try{let s=c(e.headers,e.url),n=new Request(s,{method:e.method,headers:e.headers,body:e.method==="POST"?JSON.stringify(e.body):void 0}),r=await d$1.processFlow(n);return Object.entries(r.headers).forEach(([o,a])=>{t.setHeader(o,a);}),t.status(r.status).send(r.body)}catch(s){return console.error("Flow error:",s),t.status(500).json({error:"Internal Server Error"})}},processor:d$1}}export{y as a};//# sourceMappingURL=chunk-YXZ4L2OK.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-YXZ4L2OK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/webhook/frameworks/nextjs.ts"],"names":["webhookHandler","config","processor","WebhookProcessor","req","res","mode","token","challenge","result","key","value","fullUrl","constructFullUrl","webRequest","error"],"mappings":"sCA0BO,SAASA,CAAAA,CACZC,GAAAA,CACF,CACE,IAAMC,GAAAA,CAAY,IAAIC,CAAAA,CAAiBF,GAAM,CAAA,CAE7C,OAAO,CAEH,OAAA,CAAS,MAAOG,CAAAA,CAAeC,CAAAA,GAAmB,CAC9C,GAAI,CACA,GAAID,CAAAA,CAAI,MAAA,GAAW,KAAA,CAAO,CACtB,GAAM,CAAE,UAAA,CAAYE,CAAAA,CAAM,kBAAA,CAAoBC,EAAO,eAAA,CAAiBC,CAAU,CAAA,CAAIJ,CAAAA,CAAI,KAAA,CAElFK,CAAAA,CAAS,MAAMP,GAAAA,CAAU,mBAAA,CAC1BI,CAAAA,EAAmB,IAAA,CACnBC,CAAAA,EAAoB,IAAA,CACpBC,CAAAA,EAAwB,IAC7B,CAAA,CAEA,cAAO,OAAA,CAAQC,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDN,CAAAA,CAAI,SAAA,CAAUK,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMN,CAAAA,CAAI,MAAA,CAAOI,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAEA,GAAIL,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAQ,CAEvB,IAAMQ,CAAAA,CAAUC,CAAAA,CAAiBT,CAAAA,CAAI,OAAA,CAASA,CAAAA,CAAI,GAAG,CAAA,CAE/CU,CAAAA,CAAa,IAAI,OAAA,CAAQF,CAAAA,CAAS,CACpC,MAAA,CAAQR,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,EAAI,OAAA,CACb,IAAA,CAAM,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CACjC,CAAC,CAAA,CAEKK,CAAAA,CAAS,MAAMP,GAAAA,CAAU,cAAA,CAAeY,CAAU,CAAA,CAExD,OAAA,MAAA,CAAO,QAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDN,CAAAA,CAAI,SAAA,CAAUK,CAAAA,CAAKC,CAAK,EAC5B,CAAC,EAEMN,CAAAA,CAAI,MAAA,CAAOI,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAEA,OAAOJ,CAAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,CAAE,KAAA,CAAO,oBAAqB,CAAC,CAC/D,CAAA,MAASU,CAAAA,CAAO,CACZ,OAAA,OAAA,CAAQ,KAAA,CAAM,gBAAA,CAAkBA,CAAK,CAAA,CAC9BV,CAAAA,CAAI,MAAA,CAAO,GAAG,EAAE,IAAA,CAAK,CAAE,KAAA,CAAO,uBAAwB,CAAC,CAClE,CACJ,CAAA,CAGA,IAAA,CAAM,MAAOD,CAAAA,CAAeC,CAAAA,GAAmB,CAC3C,GAAI,CACA,IAAMO,EAAUC,CAAAA,CAAiBT,CAAAA,CAAI,OAAA,CAASA,CAAAA,CAAI,GAAG,CAAA,CAE/CU,CAAAA,CAAa,IAAI,OAAA,CAAQF,CAAAA,CAAS,CACpC,MAAA,CAAQR,CAAAA,CAAI,MAAA,CACZ,OAAA,CAASA,CAAAA,CAAI,QACb,IAAA,CAAMA,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAS,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAI,IAAI,CAAA,CAAI,KAAA,CAC7D,CAAC,CAAA,CAEKK,CAAAA,CAAS,MAAMP,GAAAA,CAAU,WAAA,CAAYY,CAAU,CAAA,CAErD,OAAA,MAAA,CAAO,OAAA,CAAQL,CAAAA,CAAO,OAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CACrDN,CAAAA,CAAI,SAAA,CAAUK,CAAAA,CAAKC,CAAK,EAC5B,CAAC,CAAA,CAEMN,CAAAA,CAAI,MAAA,CAAOI,CAAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAKA,CAAAA,CAAO,IAAI,CACrD,CAAA,MAASM,CAAAA,CAAO,CACZ,OAAA,OAAA,CAAQ,MAAM,aAAA,CAAeA,CAAK,CAAA,CAC3BV,CAAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,CAAE,KAAA,CAAO,uBAAwB,CAAC,CAClE,CACJ,CAAA,CAGA,SAAA,CAAAH,GACJ,CACJ","file":"chunk-YXZ4L2OK.js","sourcesContent":["import { WhatsAppConfig } from '../../../types/config';\nimport { WebhookProcessor } from '../WebhookProcessor';\nimport { constructFullUrl } from '../utils/webhookUtils';\n\n// Generic interfaces for better type compatibility\nexport interface BaseApiRequest {\n method?: string;\n url?: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Partial<Record<string, string | string[]>>;\n rawBody?: any;\n}\n\nexport interface BaseApiResponse {\n status(code: number): any;\n json(data: any): void | any;\n send(data?: any): void | any;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextJsWebhookConfig extends WhatsAppConfig {\n // Next.js specific config can be added here\n}\n\n// Generic webhook handler that accepts any compatible request/response types\nexport function webhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(\n config: NextJsWebhookConfig,\n) {\n const processor = new WebhookProcessor(config);\n\n return {\n // Main webhook handler\n webhook: async (req: TRequest, res: TResponse) => {\n try {\n if (req.method === 'GET') {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await processor.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n if (req.method === 'POST') {\n // Create Web Standard Request from Next.js request\n const fullUrl = constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await processor.processWebhook(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n }\n\n return res.status(405).json({ error: 'Method Not Allowed' });\n } catch (error) {\n console.error('Webhook error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n },\n\n // Flow handler\n flow: async (req: TRequest, res: TResponse) => {\n try {\n const fullUrl = constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await processor.processFlow(webRequest);\n\n Object.entries(result.headers).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Flow error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n },\n\n // Expose processor for handler registration\n processor,\n };\n}\n"]}
|