@wats/graph 0.3.26 → 0.3.27
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/README.md +1 -1
- package/dist/endpoints/businessManagement.d.ts +372 -1
- package/dist/endpoints/businessManagement.js +775 -5
- package/dist/endpoints/calling.d.ts +41 -1
- package/dist/endpoints/calling.js +100 -2
- package/dist/endpoints/flows/dataChannel.d.ts +139 -0
- package/dist/endpoints/flows/dataChannel.js +252 -0
- package/dist/endpoints/flows/flowDsl.d.ts +306 -0
- package/dist/endpoints/flows/flowDsl.js +610 -0
- package/dist/endpoints/flows/flowMediaUpload.d.ts +102 -0
- package/dist/endpoints/flows/flowMediaUpload.js +188 -0
- package/dist/endpoints/flows/index.d.ts +9 -1
- package/dist/endpoints/flows/index.js +70 -0
- package/dist/endpoints/flows/metricsMigration.d.ts +36 -0
- package/dist/endpoints/flows/metricsMigration.js +207 -0
- package/dist/endpoints/flows/types.d.ts +145 -0
- package/dist/endpoints/flows/types.js +14 -0
- package/dist/endpoints/flows.d.ts +2 -2
- package/dist/endpoints/flows.js +49 -1
- package/dist/endpoints/messages/builders-interactive.d.ts +9 -1
- package/dist/endpoints/messages/builders-interactive.js +49 -0
- package/dist/endpoints/messages/builders-template.d.ts +2 -1
- package/dist/endpoints/messages/builders-template.js +53 -2
- package/dist/endpoints/messages/deepLinks.d.ts +12 -0
- package/dist/endpoints/messages/deepLinks.js +38 -0
- package/dist/endpoints/messages/index.d.ts +4 -3
- package/dist/endpoints/messages/index.js +13 -2
- package/dist/endpoints/messages/types.d.ts +26 -3
- package/dist/endpoints/messages/validation.d.ts +7 -0
- package/dist/endpoints/messages/validation.js +12 -0
- package/dist/endpoints/oauth.d.ts +57 -0
- package/dist/endpoints/oauth.js +116 -0
- package/dist/endpoints/templates/advanced.d.ts +280 -0
- package/dist/endpoints/templates/advanced.js +519 -0
- package/dist/endpoints/templates/builders.js +21 -1
- package/dist/endpoints/templates/index.d.ts +2 -0
- package/dist/endpoints/templates/index.js +15 -0
- package/dist/endpoints/templates/shared.js +7 -1
- package/dist/endpoints/templates/types.d.ts +17 -2
- package/dist/endpoints/templates.d.ts +2 -1
- package/dist/endpoints/templates.js +14 -1
- package/dist/endpoints/wabaEndpoints.d.ts +4 -4
- package/dist/endpoints/wabaEndpoints.js +56 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/nodeMedia.d.ts +57 -0
- package/dist/nodeMedia.js +178 -0
- package/dist/subclients/phoneNumberClient.d.ts +92 -2
- package/dist/subclients/phoneNumberClient.js +133 -1
- package/dist/subclients/wabaClient.d.ts +82 -2
- package/dist/subclients/wabaClient.js +102 -2
- package/package.json +9 -11
|
@@ -74,6 +74,110 @@ export interface GetFlowAssetsInput {
|
|
|
74
74
|
readonly limit?: string;
|
|
75
75
|
readonly after?: string;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Canonical Flow metric names mirrored from pywa's `FlowMetricName` enum.
|
|
79
|
+
* Unknown values are preserved as raw strings (see {@link FlowMetric.name}).
|
|
80
|
+
*
|
|
81
|
+
* Reference: REFERENCE-154.md §1. The Metrics API is documented as
|
|
82
|
+
* deprecated 2026-04-30; whether a replacement exists is UNVERIFIED.
|
|
83
|
+
*/
|
|
84
|
+
export declare const KNOWN_FLOW_METRIC_NAMES: readonly ["ENDPOINT_REQUEST_COUNT", "ENDPOINT_REQUEST_ERROR", "ENDPOINT_REQUEST_ERROR_RATE", "ENDPOINT_REQUEST_LATENCY_SECONDS_CEIL", "ENDPOINT_AVAILABILITY"];
|
|
85
|
+
export type FlowMetricName = (typeof KNOWN_FLOW_METRIC_NAMES)[number];
|
|
86
|
+
/**
|
|
87
|
+
* Canonical Flow metric granularity values mirrored from pywa's
|
|
88
|
+
* `FlowMetricGranularity` enum. Meta's docs example uses lowercase
|
|
89
|
+
* `day`, but pywa enum values are uppercase; case acceptance is
|
|
90
|
+
* UNVERIFIED. WATS sends the uppercase form.
|
|
91
|
+
*/
|
|
92
|
+
export declare const KNOWN_FLOW_METRIC_GRANULARITIES: readonly ["DAY", "HOUR", "LIFETIME"];
|
|
93
|
+
export type FlowMetricGranularity = (typeof KNOWN_FLOW_METRIC_GRANULARITIES)[number];
|
|
94
|
+
/**
|
|
95
|
+
* One `{ timestamp, data:[{key,value}] }` entry inside a Flow metric
|
|
96
|
+
* `data_points` array. Kept loose because the `data` payload shape is
|
|
97
|
+
* metric-specific (count vs. error buckets vs. latency buckets); see
|
|
98
|
+
* REFERENCE-154.md §1.
|
|
99
|
+
*/
|
|
100
|
+
export interface FlowMetricDataPoint {
|
|
101
|
+
readonly timestamp?: string;
|
|
102
|
+
readonly data?: readonly {
|
|
103
|
+
readonly key?: string;
|
|
104
|
+
readonly value?: unknown;
|
|
105
|
+
}[];
|
|
106
|
+
readonly [key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Normalized result of `GET /{flowId}?fields=metric.name(...).granularity(...)...`.
|
|
110
|
+
* Mirrors pywa's `FlowMetric`:
|
|
111
|
+
* - `dataPoints` is the camelCase form of Meta's `data_points`.
|
|
112
|
+
* - Unknown response fields are preserved via the index signature.
|
|
113
|
+
*/
|
|
114
|
+
export interface FlowMetric {
|
|
115
|
+
readonly name?: string;
|
|
116
|
+
readonly granularity?: string;
|
|
117
|
+
readonly dataPoints?: readonly FlowMetricDataPoint[];
|
|
118
|
+
readonly [key: string]: unknown;
|
|
119
|
+
}
|
|
120
|
+
/** Raw Graph response shape for `GET /{flowId}?fields=metric...`. */
|
|
121
|
+
export interface FlowMetricResponse {
|
|
122
|
+
readonly id?: string;
|
|
123
|
+
readonly metric?: {
|
|
124
|
+
readonly name?: string;
|
|
125
|
+
readonly granularity?: string;
|
|
126
|
+
readonly data_points?: readonly unknown[];
|
|
127
|
+
readonly [key: string]: unknown;
|
|
128
|
+
};
|
|
129
|
+
readonly [key: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
export interface GetFlowMetricsInput {
|
|
132
|
+
readonly flowId: string;
|
|
133
|
+
readonly name: FlowMetricName | string;
|
|
134
|
+
readonly granularity: FlowMetricGranularity | string;
|
|
135
|
+
/** Optional YYYY-MM-DD inclusive lower bound. */
|
|
136
|
+
readonly since?: string;
|
|
137
|
+
/** Optional YYYY-MM-DD inclusive upper bound. */
|
|
138
|
+
readonly until?: string;
|
|
139
|
+
}
|
|
140
|
+
/** Cap on the number of source flow names per migration request. */
|
|
141
|
+
export declare const MIGRATE_FLOWS_MAX_NAMES = 100;
|
|
142
|
+
/** Per-name length cap for migration `sourceFlowNames` entries. */
|
|
143
|
+
export declare const MIGRATE_FLOWS_NAME_MAX_LENGTH = 256;
|
|
144
|
+
/**
|
|
145
|
+
* A successfully migrated Flow entry inside {@link MigrateFlowsResponse.migratedFlows}.
|
|
146
|
+
* Mirrors pywa's `MigratedFlow`.
|
|
147
|
+
*/
|
|
148
|
+
export interface MigratedFlow {
|
|
149
|
+
readonly sourceName?: string;
|
|
150
|
+
readonly sourceId?: string;
|
|
151
|
+
readonly migratedId?: string;
|
|
152
|
+
readonly [key: string]: unknown;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A failed migration entry inside {@link MigrateFlowsResponse.failedFlows}.
|
|
156
|
+
* Mirrors pywa's `MigratedFlowError`.
|
|
157
|
+
*/
|
|
158
|
+
export interface MigratedFlowError {
|
|
159
|
+
readonly sourceName?: string;
|
|
160
|
+
readonly errorCode?: number | string;
|
|
161
|
+
readonly errorMessage?: string;
|
|
162
|
+
readonly [key: string]: unknown;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Normalized result of `POST /{destinationWabaId}/migrate_flows`.
|
|
166
|
+
* Mirrors pywa's `MigrateFlowsResponse`:
|
|
167
|
+
* - `migratedFlows` is the camelCase form of Meta's `migrated_flows`.
|
|
168
|
+
* - `failedFlows` is the camelCase form of Meta's `failed_flows`.
|
|
169
|
+
* - Unknown response fields are preserved via the index signature.
|
|
170
|
+
*/
|
|
171
|
+
export interface MigrateFlowsResponse {
|
|
172
|
+
readonly migratedFlows?: readonly MigratedFlow[];
|
|
173
|
+
readonly failedFlows?: readonly MigratedFlowError[];
|
|
174
|
+
readonly [key: string]: unknown;
|
|
175
|
+
}
|
|
176
|
+
export interface MigrateFlowsInput {
|
|
177
|
+
readonly destinationWabaId: string;
|
|
178
|
+
readonly sourceWabaId: string;
|
|
179
|
+
readonly sourceFlowNames: readonly string[];
|
|
180
|
+
}
|
|
77
181
|
export interface FlowScreenResponseInput {
|
|
78
182
|
readonly screen: string;
|
|
79
183
|
readonly data?: unknown;
|
|
@@ -103,3 +207,44 @@ export interface FlowErrorResponse {
|
|
|
103
207
|
readonly error_message?: string;
|
|
104
208
|
readonly flow_token?: string;
|
|
105
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Decrypted Flow request action verbs. Meta sends INIT/BACK uppercase and
|
|
212
|
+
* data_exchange/navigate/ping lowercase (see REFERENCE-76 §B.4).
|
|
213
|
+
*/
|
|
214
|
+
export type FlowRequestAction = "INIT" | "BACK" | "data_exchange" | "navigate" | "ping";
|
|
215
|
+
/**
|
|
216
|
+
* The encrypted request envelope as it arrives from Meta. The wire payload
|
|
217
|
+
* uses snake_case keys (`encrypted_flow_data` / `encrypted_aes_key` /
|
|
218
|
+
* `initial_vector`); we also accept the camelCase form so callers that have
|
|
219
|
+
* already normalised the body can pass it straight through. All three values
|
|
220
|
+
* are base64-encoded strings.
|
|
221
|
+
*/
|
|
222
|
+
export interface EncryptedFlowRequest {
|
|
223
|
+
readonly encryptedFlowData: string;
|
|
224
|
+
readonly encryptedAesKey: string;
|
|
225
|
+
readonly initialVector: string;
|
|
226
|
+
}
|
|
227
|
+
export interface EncryptedFlowRequestWire {
|
|
228
|
+
readonly encrypted_flow_data: string;
|
|
229
|
+
readonly encrypted_aes_key: string;
|
|
230
|
+
readonly initial_vector: string;
|
|
231
|
+
}
|
|
232
|
+
export type EncryptedFlowRequestInput = EncryptedFlowRequest | EncryptedFlowRequestWire;
|
|
233
|
+
/**
|
|
234
|
+
* A decrypted Flow data-channel request, normalised to camelCase. `screen`
|
|
235
|
+
* is omitted when Meta sends `""`; `data` is omitted when Meta sends `{}`.
|
|
236
|
+
*/
|
|
237
|
+
export interface FlowRequest {
|
|
238
|
+
readonly version: string;
|
|
239
|
+
readonly action: FlowRequestAction;
|
|
240
|
+
readonly flowToken?: string;
|
|
241
|
+
readonly screen?: string;
|
|
242
|
+
readonly data?: Record<string, unknown>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The plaintext object that gets encrypted into the HTTP response body. This
|
|
246
|
+
* is the JSON-serialisable shape produced by the response builders in
|
|
247
|
+
* dataExchange.ts (screen / close / error) plus the ping and error-ack
|
|
248
|
+
* wrappers. Kept loose because the runtime only stringifies it.
|
|
249
|
+
*/
|
|
250
|
+
export type FlowResponsePayload = Record<string, unknown>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const KNOWN_FLOW_METRIC_NAMES = [
|
|
2
|
+
"ENDPOINT_REQUEST_COUNT",
|
|
3
|
+
"ENDPOINT_REQUEST_ERROR",
|
|
4
|
+
"ENDPOINT_REQUEST_ERROR_RATE",
|
|
5
|
+
"ENDPOINT_REQUEST_LATENCY_SECONDS_CEIL",
|
|
6
|
+
"ENDPOINT_AVAILABILITY"
|
|
7
|
+
];
|
|
8
|
+
export const KNOWN_FLOW_METRIC_GRANULARITIES = [
|
|
9
|
+
"DAY",
|
|
10
|
+
"HOUR",
|
|
11
|
+
"LIFETIME"
|
|
12
|
+
];
|
|
13
|
+
export const MIGRATE_FLOWS_MAX_NAMES = 100;
|
|
14
|
+
export const MIGRATE_FLOWS_NAME_MAX_LENGTH = 256;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @experimental Flow DSL and data-channel helpers may change in 0.x minors while WATS expands Flow parity.
|
|
3
3
|
*/
|
|
4
|
-
export { FLOW_JSON_MAX_ARRAY_LENGTH, FLOW_JSON_MAX_BYTES, FLOW_JSON_MAX_COMPONENTS, FLOW_JSON_MAX_DEPTH, FLOW_JSON_MAX_SCREENS, FLOW_JSON_MAX_STRING_LENGTH, FLOW_MAX_CATEGORIES, buildFlowCloseResponse, buildFlowErrorResponse, buildFlowJson, buildFlowScreenResponse, createFlow, deleteFlow, deprecateFlow, getFlow, getFlowAssets, listFlows, publishFlow, updateFlowJson, updateFlowMetadata, validateFlowJson } from "./flows/index.js";
|
|
5
|
-
export type { CreateFlowBody, FlowAssetDetails, FlowAssetsResponse, FlowCategory, FlowCloseResponse, FlowCloseResponseInput, FlowDetails, FlowErrorResponse, FlowErrorResponseInput, FlowJson, FlowListResponse, FlowMutationResponse, FlowScreenResponse, FlowScreenResponseInput, FlowStatus, GetFlowAssetsInput, GetFlowInput, GraphPaging, ListFlowsInput, UpdateFlowJsonBody, UpdateFlowMetadataBody } from "./flows/index.js";
|
|
4
|
+
export { FLOW_DSL_MAX_CONTROL_DEPTH, FLOW_JSON_MAX_ARRAY_LENGTH, FLOW_JSON_MAX_BYTES, FLOW_JSON_MAX_COMPONENTS, FLOW_JSON_MAX_DEPTH, FLOW_JSON_MAX_SCREENS, FLOW_JSON_MAX_STRING_LENGTH, FLOW_MAX_CATEGORIES, buildFlowCloseResponse, buildFlowErrorResponse, buildFlowJson, buildFlowScreenResponse, calendarPicker, checkboxGroup, chipsSelector, completeAction, createFlow, dataExchangeAction, dataSource, datePicker, deleteFlow, deprecateFlow, documentPicker, dropdown, embeddedLink, flowJson, footer, form, getFlow, getFlowAssets, getFlowMetrics, buildFlowMetricField, migrateFlows, ifComponent, image, imageCarousel, imageCarouselItem, listFlows, navigateAction, navigationItem, navigationList, openUrlAction, optIn, photoPicker, publishFlow, radioButtonsGroup, richText, screen, singleColumnLayout, switchComponent, textArea, textBody, textCaption, textHeading, textInput, textSubheading, updateDataAction, updateFlowJson, updateFlowMetadata, validateFlowJson, FLOW_MEDIA_MAX_BYTES, FlowMediaCryptoUnavailableError, FlowMediaDecryptionError, decryptFlowMedia, decryptFlowMediaFile, KNOWN_FLOW_METRIC_NAMES, KNOWN_FLOW_METRIC_GRANULARITIES, MIGRATE_FLOWS_MAX_NAMES, MIGRATE_FLOWS_NAME_MAX_LENGTH } from "./flows/index.js";
|
|
5
|
+
export type { CreateFlowBody, FlowAssetDetails, FlowAssetsResponse, FlowCategory, FlowCloseResponse, FlowCloseResponseInput, FlowDetails, FlowMetric, FlowMetricDataPoint, FlowMetricGranularity, FlowMetricName, FlowErrorResponse, FlowErrorResponseInput, FlowJson, FlowJsonProps, FlowListResponse, FlowMutationResponse, FlowScreenResponse, FlowScreenResponseInput, FlowStatus, FormProps, GetFlowAssetsInput, GetFlowInput, GetFlowMetricsInput, GraphPaging, IfProps, ImageCarouselItemProps, ListFlowsInput, MigratedFlow, MigratedFlowError, MigrateFlowsInput, MigrateFlowsResponse, NavigateActionProps, NavigationItemProps, ScreenProps, SwitchProps, UpdateFlowJsonBody, UpdateFlowMetadataBody, DecryptedFlowMedia, FlowMediaEncryptedFile, FlowMediaEncryptionMetadata } from "./flows/index.js";
|
package/dist/endpoints/flows.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {
|
|
2
|
+
FLOW_DSL_MAX_CONTROL_DEPTH,
|
|
2
3
|
FLOW_JSON_MAX_ARRAY_LENGTH,
|
|
3
4
|
FLOW_JSON_MAX_BYTES,
|
|
4
5
|
FLOW_JSON_MAX_COMPONENTS,
|
|
@@ -10,14 +11,61 @@ export {
|
|
|
10
11
|
buildFlowErrorResponse,
|
|
11
12
|
buildFlowJson,
|
|
12
13
|
buildFlowScreenResponse,
|
|
14
|
+
calendarPicker,
|
|
15
|
+
checkboxGroup,
|
|
16
|
+
chipsSelector,
|
|
17
|
+
completeAction,
|
|
13
18
|
createFlow,
|
|
19
|
+
dataExchangeAction,
|
|
20
|
+
dataSource,
|
|
21
|
+
datePicker,
|
|
14
22
|
deleteFlow,
|
|
15
23
|
deprecateFlow,
|
|
24
|
+
documentPicker,
|
|
25
|
+
dropdown,
|
|
26
|
+
embeddedLink,
|
|
27
|
+
flowJson,
|
|
28
|
+
footer,
|
|
29
|
+
form,
|
|
16
30
|
getFlow,
|
|
17
31
|
getFlowAssets,
|
|
32
|
+
getFlowMetrics,
|
|
33
|
+
buildFlowMetricField,
|
|
34
|
+
migrateFlows,
|
|
35
|
+
ifComponent,
|
|
36
|
+
image,
|
|
37
|
+
imageCarousel,
|
|
38
|
+
imageCarouselItem,
|
|
18
39
|
listFlows,
|
|
40
|
+
navigateAction,
|
|
41
|
+
navigationItem,
|
|
42
|
+
navigationList,
|
|
43
|
+
openUrlAction,
|
|
44
|
+
optIn,
|
|
45
|
+
photoPicker,
|
|
19
46
|
publishFlow,
|
|
47
|
+
radioButtonsGroup,
|
|
48
|
+
richText,
|
|
49
|
+
screen,
|
|
50
|
+
singleColumnLayout,
|
|
51
|
+
switchComponent,
|
|
52
|
+
textArea,
|
|
53
|
+
textBody,
|
|
54
|
+
textCaption,
|
|
55
|
+
textHeading,
|
|
56
|
+
textInput,
|
|
57
|
+
textSubheading,
|
|
58
|
+
updateDataAction,
|
|
20
59
|
updateFlowJson,
|
|
21
60
|
updateFlowMetadata,
|
|
22
|
-
validateFlowJson
|
|
61
|
+
validateFlowJson,
|
|
62
|
+
FLOW_MEDIA_MAX_BYTES,
|
|
63
|
+
FlowMediaCryptoUnavailableError,
|
|
64
|
+
FlowMediaDecryptionError,
|
|
65
|
+
decryptFlowMedia,
|
|
66
|
+
decryptFlowMediaFile,
|
|
67
|
+
KNOWN_FLOW_METRIC_NAMES,
|
|
68
|
+
KNOWN_FLOW_METRIC_GRANULARITIES,
|
|
69
|
+
MIGRATE_FLOWS_MAX_NAMES,
|
|
70
|
+
MIGRATE_FLOWS_NAME_MAX_LENGTH
|
|
23
71
|
} from "./flows/index.js";
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import type { GraphMessagesInteractivePayload, GraphMessagesMarkMessageAsReadInput, GraphMessagesRequestLocationInput, GraphMessagesSendButtonsInput, GraphMessagesSendCallPermissionRequestInput, GraphMessagesSendCatalogInput, GraphMessagesSendCtaUrlInput, GraphMessagesSendListInput, GraphMessagesSendProductInput, GraphMessagesSendProductsInput, GraphMessagesStatusPayload, GraphMessagesTypingIndicatorInput } from "./types.js";
|
|
1
|
+
import type { GraphMessagesInteractivePayload, GraphMessagesMarkMessageAsReadInput, GraphMessagesRequestLocationInput, GraphMessagesSendButtonsInput, GraphMessagesSendCallPermissionRequestInput, GraphMessagesSendCatalogInput, GraphMessagesSendCtaUrlInput, GraphMessagesSendListInput, GraphMessagesSendProductInput, GraphMessagesSendProductsInput, GraphMessagesSendVoiceCallInput, GraphMessagesStatusPayload, GraphMessagesTypingIndicatorInput } from "./types.js";
|
|
2
2
|
export declare function buildSendButtonsPayload(input: GraphMessagesSendButtonsInput): GraphMessagesInteractivePayload;
|
|
3
3
|
export declare function buildSendListPayload(input: GraphMessagesSendListInput): GraphMessagesInteractivePayload;
|
|
4
4
|
export declare function buildSendCtaUrlPayload(input: GraphMessagesSendCtaUrlInput): GraphMessagesInteractivePayload;
|
|
5
5
|
export declare function buildSendCallPermissionRequestPayload(input: GraphMessagesSendCallPermissionRequestInput): GraphMessagesInteractivePayload;
|
|
6
|
+
/**
|
|
7
|
+
* Meta Calling interactive voice-call button message.
|
|
8
|
+
*
|
|
9
|
+
* Source: Meta Developers, "Send WhatsApp Call Button Messages and Deep Links",
|
|
10
|
+
* updated 2026-05-21. `payload` is opaque and later appears as
|
|
11
|
+
* `cta_payload` on connect/terminate call webhooks.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildSendVoiceCallPayload(input: GraphMessagesSendVoiceCallInput): GraphMessagesInteractivePayload;
|
|
6
14
|
export declare function buildSendProductPayload(input: GraphMessagesSendProductInput): GraphMessagesInteractivePayload;
|
|
7
15
|
export declare function buildSendProductsPayload(input: GraphMessagesSendProductsInput): GraphMessagesInteractivePayload;
|
|
8
16
|
export declare function buildSendCatalogPayload(input: GraphMessagesSendCatalogInput): GraphMessagesInteractivePayload;
|
|
@@ -13,12 +13,19 @@ import {
|
|
|
13
13
|
GRAPH_MESSAGES_ROW_TITLE_MAX_LENGTH,
|
|
14
14
|
GRAPH_MESSAGES_SECTION_TITLE_MAX_LENGTH,
|
|
15
15
|
GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH,
|
|
16
|
+
GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH,
|
|
17
|
+
GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH,
|
|
18
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX,
|
|
19
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN,
|
|
16
20
|
applyRecipientType,
|
|
17
21
|
assertBoundedArray,
|
|
18
22
|
assertMessageRecipient,
|
|
19
23
|
assertNonEmptyControlFreeString,
|
|
20
24
|
assertOnlyKnownKeys,
|
|
25
|
+
assertRecipientType,
|
|
26
|
+
assertValidIntegerInRange,
|
|
21
27
|
assertValidMediaLink,
|
|
28
|
+
assertValidRecipient,
|
|
22
29
|
asRecordInput,
|
|
23
30
|
rejectGroupRecipient,
|
|
24
31
|
isPlainOptionsObject,
|
|
@@ -32,6 +39,18 @@ function interactiveBase(input, helperName, interactive) {
|
|
|
32
39
|
const { to, recipientType } = assertMessageRecipient(record, helperName);
|
|
33
40
|
return withReplyContext(applyRecipientType({ messaging_product: "whatsapp", to, type: "interactive", interactive }, recipientType), record);
|
|
34
41
|
}
|
|
42
|
+
function assertVoiceCallRecipient(record) {
|
|
43
|
+
const recipientType = assertRecipientType(record.recipientType, "sendVoiceCall");
|
|
44
|
+
if (recipientType === "group") {
|
|
45
|
+
throw new GraphRequestValidationError("Invalid sendVoiceCall input: voice_call interactive messages are not supported for group recipients.");
|
|
46
|
+
}
|
|
47
|
+
const to = record.to === undefined ? undefined : assertValidRecipient(record.to, "sendVoiceCall");
|
|
48
|
+
const recipient = record.recipient === undefined ? undefined : assertNonEmptyControlFreeString(record.recipient, "recipient", GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, "sendVoiceCall");
|
|
49
|
+
if (to === undefined && recipient === undefined) {
|
|
50
|
+
throw new GraphRequestValidationError("Invalid sendVoiceCall input: at least one of to or recipient is required.");
|
|
51
|
+
}
|
|
52
|
+
return { ...to !== undefined ? { to } : {}, ...recipient !== undefined ? { recipient } : {}, recipientType: "individual" };
|
|
53
|
+
}
|
|
35
54
|
function addHeaderFooter(target, record, helperName) {
|
|
36
55
|
const headerText = maybeText(record.headerText, "headerText", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, helperName);
|
|
37
56
|
const footerText = maybeText(record.footerText, "footerText", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, helperName);
|
|
@@ -101,6 +120,36 @@ export function buildSendCallPermissionRequestPayload(input) {
|
|
|
101
120
|
interactive.footer = { text: footerText };
|
|
102
121
|
return interactiveBase(input, "sendCallPermissionRequest", interactive);
|
|
103
122
|
}
|
|
123
|
+
export function buildSendVoiceCallPayload(input) {
|
|
124
|
+
const record = asRecordInput(input, "sendVoiceCall");
|
|
125
|
+
assertOnlyKnownKeys(record, ["to", "recipient", "recipientType", "bodyText", "displayText", "ttlMinutes", "payload", "replyToMessageId"], "sendVoiceCall");
|
|
126
|
+
const target = assertVoiceCallRecipient(record);
|
|
127
|
+
const parameters = {};
|
|
128
|
+
const displayText = maybeText(record.displayText, "displayText", GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH, "sendVoiceCall");
|
|
129
|
+
if (displayText !== undefined)
|
|
130
|
+
parameters.display_text = displayText;
|
|
131
|
+
if (record.ttlMinutes !== undefined) {
|
|
132
|
+
parameters.ttl_minutes = assertValidIntegerInRange(record.ttlMinutes, "ttlMinutes", GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN, GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX, "sendVoiceCall");
|
|
133
|
+
}
|
|
134
|
+
const payload = maybeText(record.payload, "payload", GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH, "sendVoiceCall");
|
|
135
|
+
if (payload !== undefined)
|
|
136
|
+
parameters.payload = payload;
|
|
137
|
+
const action = { name: "voice_call" };
|
|
138
|
+
if (Object.keys(parameters).length > 0)
|
|
139
|
+
action.parameters = parameters;
|
|
140
|
+
return withReplyContext({
|
|
141
|
+
messaging_product: "whatsapp",
|
|
142
|
+
recipient_type: "individual",
|
|
143
|
+
...target.to !== undefined ? { to: target.to } : {},
|
|
144
|
+
...target.recipient !== undefined ? { recipient: target.recipient } : {},
|
|
145
|
+
type: "interactive",
|
|
146
|
+
interactive: {
|
|
147
|
+
type: "voice_call",
|
|
148
|
+
body: { text: assertNonEmptyControlFreeString(record.bodyText, "bodyText", GRAPH_MESSAGES_GENERAL_TEXT_MAX_LENGTH, "sendVoiceCall") },
|
|
149
|
+
action
|
|
150
|
+
}
|
|
151
|
+
}, record);
|
|
152
|
+
}
|
|
104
153
|
export function buildSendProductPayload(input) {
|
|
105
154
|
const record = asRecordInput(input, "sendProduct");
|
|
106
155
|
const interactive = { type: "product", action: { catalog_id: assertNonEmptyControlFreeString(record.catalogId, "catalogId", GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, "sendProduct"), product_retailer_id: assertNonEmptyControlFreeString(record.productRetailerId, "productRetailerId", GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, "sendProduct") } };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { GraphMessagesMarketingTemplatePayload, GraphMessagesSendMarketingTemplateInput, GraphMessagesSendTemplateInput, GraphMessagesTemplatePayload } from "./types.js";
|
|
1
|
+
import type { GraphMessagesMarketingTemplatePayload, GraphMessagesSendMarketingTemplateInput, GraphMessagesSendTemplateInput, GraphMessagesTemplatePayload, GraphMessagesVoiceCallTemplateButtonInput } from "./types.js";
|
|
2
|
+
export declare function buildVoiceCallTemplateButtonComponent(input: GraphMessagesVoiceCallTemplateButtonInput): Record<string, unknown>;
|
|
2
3
|
export declare function buildSendTemplatePayload(input: GraphMessagesSendTemplateInput): GraphMessagesTemplatePayload;
|
|
3
4
|
export declare function buildSendMarketingTemplatePayload(input: GraphMessagesSendMarketingTemplateInput): GraphMessagesMarketingTemplatePayload;
|
|
@@ -2,12 +2,16 @@ import { GraphRequestValidationError } from "../../errors.js";
|
|
|
2
2
|
import {
|
|
3
3
|
GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH,
|
|
4
4
|
GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH,
|
|
5
|
+
GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH,
|
|
6
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX,
|
|
7
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN,
|
|
5
8
|
applyRecipientType,
|
|
6
9
|
assertBoundedArray,
|
|
7
10
|
assertMessageRecipient,
|
|
8
11
|
assertNonEmptyControlFreeString,
|
|
9
12
|
assertOnlyKnownKeys,
|
|
10
13
|
assertRecipientType,
|
|
14
|
+
assertValidIntegerInRange,
|
|
11
15
|
assertValidRecipient,
|
|
12
16
|
asRecordInput,
|
|
13
17
|
rejectGroupRecipient,
|
|
@@ -28,6 +32,44 @@ function assertGroupTemplateCategory(value) {
|
|
|
28
32
|
throw new GraphRequestValidationError("Invalid sendTemplate input: templateCategory must be UTILITY or MARKETING for group recipients.");
|
|
29
33
|
}
|
|
30
34
|
}
|
|
35
|
+
function assertTemplateRecipient(record) {
|
|
36
|
+
const recipientType = assertRecipientType(record.recipientType, "sendTemplate");
|
|
37
|
+
if (recipientType === "group")
|
|
38
|
+
return assertMessageRecipient(record, "sendTemplate");
|
|
39
|
+
const to = record.to === undefined ? undefined : assertValidRecipient(record.to, "sendTemplate");
|
|
40
|
+
const recipient = record.recipient === undefined ? undefined : assertNonEmptyControlFreeString(record.recipient, "recipient", GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, "sendTemplate");
|
|
41
|
+
if (to === undefined && recipient === undefined) {
|
|
42
|
+
throw new GraphRequestValidationError("Invalid sendTemplate input: at least one of to or recipient is required.");
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...to !== undefined ? { to } : {},
|
|
46
|
+
...recipient !== undefined ? { recipient } : {},
|
|
47
|
+
...recipientType !== undefined ? { recipientType } : recipient !== undefined ? { recipientType: "individual" } : {}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function buildVoiceCallTemplateButtonComponent(input) {
|
|
51
|
+
const record = asRecordInput(input, "buildVoiceCallTemplateButtonComponent");
|
|
52
|
+
assertOnlyKnownKeys(record, ["ttlMinutes", "payload", "index"], "buildVoiceCallTemplateButtonComponent");
|
|
53
|
+
const parameters = [];
|
|
54
|
+
if (record.ttlMinutes !== undefined) {
|
|
55
|
+
parameters.push({
|
|
56
|
+
type: "ttl_minutes",
|
|
57
|
+
ttl_minutes: assertValidIntegerInRange(record.ttlMinutes, "ttlMinutes", GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN, GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX, "buildVoiceCallTemplateButtonComponent")
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (record.payload !== undefined) {
|
|
61
|
+
parameters.push({
|
|
62
|
+
type: "payload",
|
|
63
|
+
payload: assertNonEmptyControlFreeString(record.payload, "payload", GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH, "buildVoiceCallTemplateButtonComponent")
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const out = { type: "button", sub_type: "voice_call" };
|
|
67
|
+
if (record.index !== undefined)
|
|
68
|
+
out.index = assertNonEmptyControlFreeString(record.index, "index", 8, "buildVoiceCallTemplateButtonComponent");
|
|
69
|
+
if (parameters.length > 0)
|
|
70
|
+
out.parameters = parameters;
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
31
73
|
function normalizeTemplateComponent(value, helperName) {
|
|
32
74
|
const cloned = sanitizeTemplateParameter(value, helperName, "component", new WeakSet);
|
|
33
75
|
if (!isPlainOptionsObject(cloned))
|
|
@@ -36,6 +78,8 @@ function normalizeTemplateComponent(value, helperName) {
|
|
|
36
78
|
const out = { type: assertNonEmptyControlFreeString(component.type, "component.type", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, helperName) };
|
|
37
79
|
if (component.subType !== undefined)
|
|
38
80
|
out.sub_type = assertNonEmptyControlFreeString(component.subType, "component.subType", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, helperName);
|
|
81
|
+
else if (component.sub_type !== undefined)
|
|
82
|
+
out.sub_type = assertNonEmptyControlFreeString(component.sub_type, "component.sub_type", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, helperName);
|
|
39
83
|
if (component.index !== undefined)
|
|
40
84
|
out.index = assertNonEmptyControlFreeString(component.index, "component.index", 8, helperName);
|
|
41
85
|
if (component.parameters !== undefined) {
|
|
@@ -50,14 +94,21 @@ function normalizeTemplateComponent(value, helperName) {
|
|
|
50
94
|
}
|
|
51
95
|
export function buildSendTemplatePayload(input) {
|
|
52
96
|
const record = asRecordInput(input, "sendTemplate");
|
|
53
|
-
|
|
97
|
+
assertOnlyKnownKeys(record, ["to", "recipient", "recipientType", "name", "languageCode", "templateCategory", "components", "replyToMessageId"], "sendTemplate");
|
|
98
|
+
const recipient = assertTemplateRecipient(record);
|
|
54
99
|
if (recipient.recipientType === "group") {
|
|
55
100
|
assertGroupTemplateCategory(record.templateCategory);
|
|
56
101
|
}
|
|
57
102
|
const template = { name: assertNonEmptyControlFreeString(record.name, "name", GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, "sendTemplate"), language: { code: assertNonEmptyControlFreeString(record.languageCode, "languageCode", GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, "sendTemplate") } };
|
|
58
103
|
if (record.components !== undefined)
|
|
59
104
|
template.components = mapValidatedArray(assertBoundedArray(record.components, "components", 0, 100, "sendTemplate"), (c) => normalizeTemplateComponent(c, "sendTemplate"));
|
|
60
|
-
return withReplyContext(applyRecipientType({
|
|
105
|
+
return withReplyContext(applyRecipientType({
|
|
106
|
+
messaging_product: "whatsapp",
|
|
107
|
+
...recipient.to !== undefined ? { to: recipient.to } : {},
|
|
108
|
+
...recipient.recipient !== undefined ? { recipient: recipient.recipient } : {},
|
|
109
|
+
type: "template",
|
|
110
|
+
template
|
|
111
|
+
}, recipient.recipientType), record);
|
|
61
112
|
}
|
|
62
113
|
function assertMarketingRecipient(value) {
|
|
63
114
|
if (value === undefined)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WhatsAppCallDeepLinkInput {
|
|
2
|
+
readonly phoneNumber: string;
|
|
3
|
+
readonly bizPayload?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Build a WhatsApp Calling deep link: `https://wa.me/call/<BUSINESS_PHONE_NUMBER>`.
|
|
7
|
+
*
|
|
8
|
+
* Source: Meta Developers, "Send WhatsApp Call Button Messages and Deep Links",
|
|
9
|
+
* updated 2026-05-21. `bizPayload` is opaque and appears as `deeplink_payload`
|
|
10
|
+
* on connect/terminate call webhooks when supported by the user's client.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildWhatsAppCallDeepLink(input: WhatsAppCallDeepLinkInput): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GraphRequestValidationError } from "../../errors.js";
|
|
2
|
+
import {
|
|
3
|
+
GRAPH_MESSAGES_RECIPIENT_MAX_DIGITS,
|
|
4
|
+
GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH,
|
|
5
|
+
assertNonEmptyControlFreeString,
|
|
6
|
+
hasControlChar
|
|
7
|
+
} from "./validation.js";
|
|
8
|
+
function assertBusinessPhoneNumber(value) {
|
|
9
|
+
if (typeof value !== "string") {
|
|
10
|
+
throw new GraphRequestValidationError("Invalid buildWhatsAppCallDeepLink input: phoneNumber must be a string.");
|
|
11
|
+
}
|
|
12
|
+
const digits = value.startsWith("+") ? value.slice(1) : value;
|
|
13
|
+
if (digits.length === 0 || digits.trim().length === 0) {
|
|
14
|
+
throw new GraphRequestValidationError("Invalid buildWhatsAppCallDeepLink input: phoneNumber must be non-empty.");
|
|
15
|
+
}
|
|
16
|
+
if (hasControlChar(digits) || !/^\d+$/.test(digits) || digits.length > GRAPH_MESSAGES_RECIPIENT_MAX_DIGITS) {
|
|
17
|
+
throw new GraphRequestValidationError(`Invalid buildWhatsAppCallDeepLink input: phoneNumber must be digits with optional leading + and at most ${GRAPH_MESSAGES_RECIPIENT_MAX_DIGITS} digits.`);
|
|
18
|
+
}
|
|
19
|
+
return digits;
|
|
20
|
+
}
|
|
21
|
+
export function buildWhatsAppCallDeepLink(input) {
|
|
22
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
23
|
+
throw new GraphRequestValidationError("Invalid buildWhatsAppCallDeepLink input: expected an options object.");
|
|
24
|
+
}
|
|
25
|
+
const record = input;
|
|
26
|
+
for (const key of Object.keys(record)) {
|
|
27
|
+
if (key !== "phoneNumber" && key !== "bizPayload") {
|
|
28
|
+
throw new GraphRequestValidationError(`Invalid buildWhatsAppCallDeepLink input: unknown field ${key}.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const phone = assertBusinessPhoneNumber(record.phoneNumber);
|
|
32
|
+
const url = new URL(`https://wa.me/call/${phone}`);
|
|
33
|
+
if (record.bizPayload !== undefined) {
|
|
34
|
+
const payload = assertNonEmptyControlFreeString(record.bizPayload, "bizPayload", GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH, "buildWhatsAppCallDeepLink");
|
|
35
|
+
url.searchParams.set("biz_payload", payload);
|
|
36
|
+
}
|
|
37
|
+
return url.toString();
|
|
38
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
|
-
export { GRAPH_MESSAGES_TEXT_BODY_MAX_LENGTH, GRAPH_MESSAGES_RECIPIENT_MAX_DIGITS, GRAPH_MESSAGES_REPLY_TO_MESSAGE_ID_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_LINK_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_CAPTION_MAX_LENGTH, GRAPH_MESSAGES_DOCUMENT_FILENAME_MAX_LENGTH, GRAPH_MESSAGES_GENERAL_TEXT_MAX_LENGTH, GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, GRAPH_MESSAGES_BUTTON_TITLE_MAX_LENGTH, GRAPH_MESSAGES_BUTTON_ID_MAX_LENGTH, GRAPH_MESSAGES_SECTION_TITLE_MAX_LENGTH, GRAPH_MESSAGES_ROW_TITLE_MAX_LENGTH, GRAPH_MESSAGES_ROW_DESCRIPTION_MAX_LENGTH, GRAPH_MESSAGES_MAX_REPLY_BUTTONS, GRAPH_MESSAGES_MAX_LIST_SECTIONS, GRAPH_MESSAGES_MAX_LIST_ROWS, GRAPH_MESSAGES_MAX_CONTACTS, GRAPH_MESSAGES_MAX_PRODUCT_ITEMS } from "./validation.js";
|
|
2
|
+
export { GRAPH_MESSAGES_TEXT_BODY_MAX_LENGTH, GRAPH_MESSAGES_RECIPIENT_MAX_DIGITS, GRAPH_MESSAGES_REPLY_TO_MESSAGE_ID_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_ID_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_LINK_MAX_LENGTH, GRAPH_MESSAGES_MEDIA_CAPTION_MAX_LENGTH, GRAPH_MESSAGES_DOCUMENT_FILENAME_MAX_LENGTH, GRAPH_MESSAGES_GENERAL_TEXT_MAX_LENGTH, GRAPH_MESSAGES_SHORT_LABEL_MAX_LENGTH, GRAPH_MESSAGES_BUTTON_TITLE_MAX_LENGTH, GRAPH_MESSAGES_BUTTON_ID_MAX_LENGTH, GRAPH_MESSAGES_SECTION_TITLE_MAX_LENGTH, GRAPH_MESSAGES_ROW_TITLE_MAX_LENGTH, GRAPH_MESSAGES_ROW_DESCRIPTION_MAX_LENGTH, GRAPH_MESSAGES_MAX_REPLY_BUTTONS, GRAPH_MESSAGES_MAX_LIST_SECTIONS, GRAPH_MESSAGES_MAX_LIST_ROWS, GRAPH_MESSAGES_MAX_CONTACTS, GRAPH_MESSAGES_MAX_PRODUCT_ITEMS, GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH, GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN, GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX, GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_DEFAULT, GRAPH_MESSAGES_VOICE_CALL_TEMPLATE_TTL_MINUTES_MIN, GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH } from "./validation.js";
|
|
3
3
|
export { buildSendTextPayload, buildSendImagePayload, buildSendVideoPayload, buildSendAudioPayload, buildSendDocumentPayload, buildSendStickerPayload, buildSendLocationPayload, buildSendContactsPayload, buildSendReactionPayload, buildRemoveReactionPayload, buildSendPinPayload } from "./builders-basic.js";
|
|
4
|
-
export { buildSendButtonsPayload, buildSendListPayload, buildSendCtaUrlPayload, buildSendCallPermissionRequestPayload, buildSendProductPayload, buildSendProductsPayload, buildSendCatalogPayload, buildRequestLocationPayload, buildMarkMessageAsReadPayload, buildTypingIndicatorPayload } from "./builders-interactive.js";
|
|
5
|
-
export { buildSendTemplatePayload, buildSendMarketingTemplatePayload } from "./builders-template.js";
|
|
4
|
+
export { buildSendButtonsPayload, buildSendListPayload, buildSendCtaUrlPayload, buildSendCallPermissionRequestPayload, buildSendVoiceCallPayload, buildSendProductPayload, buildSendProductsPayload, buildSendCatalogPayload, buildRequestLocationPayload, buildMarkMessageAsReadPayload, buildTypingIndicatorPayload } from "./builders-interactive.js";
|
|
5
|
+
export { buildSendTemplatePayload, buildSendMarketingTemplatePayload, buildVoiceCallTemplateButtonComponent } from "./builders-template.js";
|
|
6
|
+
export { buildWhatsAppCallDeepLink, type WhatsAppCallDeepLinkInput } from "./deepLinks.js";
|
|
6
7
|
export { buildSendMessagePayload, sendMarketingTemplate, sendMessage, GraphMessagesEndpoint } from "./callables.js";
|
|
@@ -18,7 +18,13 @@ export {
|
|
|
18
18
|
GRAPH_MESSAGES_MAX_LIST_SECTIONS,
|
|
19
19
|
GRAPH_MESSAGES_MAX_LIST_ROWS,
|
|
20
20
|
GRAPH_MESSAGES_MAX_CONTACTS,
|
|
21
|
-
GRAPH_MESSAGES_MAX_PRODUCT_ITEMS
|
|
21
|
+
GRAPH_MESSAGES_MAX_PRODUCT_ITEMS,
|
|
22
|
+
GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH,
|
|
23
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN,
|
|
24
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX,
|
|
25
|
+
GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_DEFAULT,
|
|
26
|
+
GRAPH_MESSAGES_VOICE_CALL_TEMPLATE_TTL_MINUTES_MIN,
|
|
27
|
+
GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH
|
|
22
28
|
} from "./validation.js";
|
|
23
29
|
export {
|
|
24
30
|
buildSendTextPayload,
|
|
@@ -38,6 +44,7 @@ export {
|
|
|
38
44
|
buildSendListPayload,
|
|
39
45
|
buildSendCtaUrlPayload,
|
|
40
46
|
buildSendCallPermissionRequestPayload,
|
|
47
|
+
buildSendVoiceCallPayload,
|
|
41
48
|
buildSendProductPayload,
|
|
42
49
|
buildSendProductsPayload,
|
|
43
50
|
buildSendCatalogPayload,
|
|
@@ -47,8 +54,12 @@ export {
|
|
|
47
54
|
} from "./builders-interactive.js";
|
|
48
55
|
export {
|
|
49
56
|
buildSendTemplatePayload,
|
|
50
|
-
buildSendMarketingTemplatePayload
|
|
57
|
+
buildSendMarketingTemplatePayload,
|
|
58
|
+
buildVoiceCallTemplateButtonComponent
|
|
51
59
|
} from "./builders-template.js";
|
|
60
|
+
export {
|
|
61
|
+
buildWhatsAppCallDeepLink
|
|
62
|
+
} from "./deepLinks.js";
|
|
52
63
|
export {
|
|
53
64
|
buildSendMessagePayload,
|
|
54
65
|
sendMarketingTemplate,
|
|
@@ -131,6 +131,18 @@ export interface GraphMessagesSendCallPermissionRequestInput extends GraphMessag
|
|
|
131
131
|
readonly footerText?: string;
|
|
132
132
|
readonly replyToMessageId?: string;
|
|
133
133
|
}
|
|
134
|
+
export interface GraphMessagesSendVoiceCallInput {
|
|
135
|
+
/** Phone-number / wa_id recipient. If `recipient` is also supplied, Meta routes by `to`. */
|
|
136
|
+
readonly to?: string;
|
|
137
|
+
/** Business-scoped user id / parent BSUID recipient. */
|
|
138
|
+
readonly recipient?: string;
|
|
139
|
+
readonly recipientType?: "individual";
|
|
140
|
+
readonly bodyText: string;
|
|
141
|
+
readonly displayText?: string;
|
|
142
|
+
readonly ttlMinutes?: number;
|
|
143
|
+
readonly payload?: string;
|
|
144
|
+
readonly replyToMessageId?: string;
|
|
145
|
+
}
|
|
134
146
|
export interface GraphMessagesSendProductInput extends GraphMessagesRecipientInput {
|
|
135
147
|
readonly catalogId: string;
|
|
136
148
|
readonly productRetailerId: string;
|
|
@@ -177,7 +189,16 @@ export interface GraphMessagesTemplateComponentInput {
|
|
|
177
189
|
readonly index?: string;
|
|
178
190
|
}
|
|
179
191
|
export type GraphMessagesTemplateCategory = "MARKETING" | "UTILITY" | "AUTHENTICATION";
|
|
180
|
-
export interface
|
|
192
|
+
export interface GraphMessagesVoiceCallTemplateButtonInput {
|
|
193
|
+
readonly ttlMinutes?: number;
|
|
194
|
+
readonly payload?: string;
|
|
195
|
+
readonly index?: string;
|
|
196
|
+
}
|
|
197
|
+
export interface GraphMessagesSendTemplateInput {
|
|
198
|
+
readonly to?: string;
|
|
199
|
+
/** Business-scoped user id / parent BSUID recipient for templates that support it. */
|
|
200
|
+
readonly recipient?: string;
|
|
201
|
+
readonly recipientType?: GraphMessagesRecipientType;
|
|
181
202
|
readonly name: string;
|
|
182
203
|
readonly languageCode: string;
|
|
183
204
|
readonly templateCategory?: GraphMessagesTemplateCategory;
|
|
@@ -342,7 +363,8 @@ export type GraphMessagesReactionPayload = {
|
|
|
342
363
|
export type GraphMessagesInteractivePayload = {
|
|
343
364
|
messaging_product: "whatsapp";
|
|
344
365
|
recipient_type?: GraphMessagesRecipientType;
|
|
345
|
-
to
|
|
366
|
+
to?: string;
|
|
367
|
+
recipient?: string;
|
|
346
368
|
type: "interactive";
|
|
347
369
|
interactive: Record<string, unknown>;
|
|
348
370
|
context?: {
|
|
@@ -352,7 +374,8 @@ export type GraphMessagesInteractivePayload = {
|
|
|
352
374
|
export type GraphMessagesTemplatePayload = {
|
|
353
375
|
messaging_product: "whatsapp";
|
|
354
376
|
recipient_type?: GraphMessagesRecipientType;
|
|
355
|
-
to
|
|
377
|
+
to?: string;
|
|
378
|
+
recipient?: string;
|
|
356
379
|
type: "template";
|
|
357
380
|
template: Record<string, unknown>;
|
|
358
381
|
context?: {
|
|
@@ -18,6 +18,12 @@ export declare const GRAPH_MESSAGES_MAX_LIST_ROWS = 10;
|
|
|
18
18
|
export declare const GRAPH_MESSAGES_MAX_CONTACTS = 257;
|
|
19
19
|
export declare const GRAPH_MESSAGES_MAX_PRODUCT_ITEMS = 30;
|
|
20
20
|
export declare const GRAPH_MESSAGES_GROUP_ID_MAX_LENGTH = 256;
|
|
21
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH = 20;
|
|
22
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN = 1;
|
|
23
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX = 43200;
|
|
24
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_DEFAULT = 10080;
|
|
25
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_TEMPLATE_TTL_MINUTES_MIN = 1440;
|
|
26
|
+
export declare const GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH = 512;
|
|
21
27
|
export declare function isPlainOptionsObject(value: unknown): value is Record<string, unknown>;
|
|
22
28
|
export declare function hasControlChar(value: string): boolean;
|
|
23
29
|
export declare function assertValidGroupId(to: unknown, helperName?: string): string;
|
|
@@ -40,6 +46,7 @@ export declare function assertNoUnsupportedMediaFields(input: Record<string, unk
|
|
|
40
46
|
}): void;
|
|
41
47
|
export declare function assertValidMediaLink(value: unknown, helperName: string): string;
|
|
42
48
|
export declare function assertValidNumberInRange(value: unknown, fieldName: string, min: number, max: number, helperName: string): number;
|
|
49
|
+
export declare function assertValidIntegerInRange(value: unknown, fieldName: string, min: number, max: number, helperName: string): number;
|
|
43
50
|
export declare function maybeText(value: unknown, fieldName: string, maxLength: number, helperName: string): string | undefined;
|
|
44
51
|
export declare function withReplyContext<T extends object>(payload: T, input: Record<string, unknown>): T & {
|
|
45
52
|
context?: {
|
|
@@ -19,6 +19,12 @@ export const GRAPH_MESSAGES_MAX_LIST_ROWS = 10;
|
|
|
19
19
|
export const GRAPH_MESSAGES_MAX_CONTACTS = 257;
|
|
20
20
|
export const GRAPH_MESSAGES_MAX_PRODUCT_ITEMS = 30;
|
|
21
21
|
export const GRAPH_MESSAGES_GROUP_ID_MAX_LENGTH = 256;
|
|
22
|
+
export const GRAPH_MESSAGES_VOICE_CALL_DISPLAY_TEXT_MAX_LENGTH = 20;
|
|
23
|
+
export const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MIN = 1;
|
|
24
|
+
export const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_MAX = 43200;
|
|
25
|
+
export const GRAPH_MESSAGES_VOICE_CALL_TTL_MINUTES_DEFAULT = 10080;
|
|
26
|
+
export const GRAPH_MESSAGES_VOICE_CALL_TEMPLATE_TTL_MINUTES_MIN = 1440;
|
|
27
|
+
export const GRAPH_MESSAGES_VOICE_CALL_PAYLOAD_MAX_LENGTH = 512;
|
|
22
28
|
export function isPlainOptionsObject(value) {
|
|
23
29
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
30
|
}
|
|
@@ -167,6 +173,12 @@ export function assertValidNumberInRange(value, fieldName, min, max, helperName)
|
|
|
167
173
|
}
|
|
168
174
|
return value;
|
|
169
175
|
}
|
|
176
|
+
export function assertValidIntegerInRange(value, fieldName, min, max, helperName) {
|
|
177
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value < min || value > max) {
|
|
178
|
+
throw new GraphRequestValidationError(`Invalid ${helperName} input: ${fieldName} must be an integer between ${min} and ${max}.`);
|
|
179
|
+
}
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
170
182
|
export function maybeText(value, fieldName, maxLength, helperName) {
|
|
171
183
|
if (value === undefined)
|
|
172
184
|
return;
|