@wats/graph 0.3.25 → 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/media.js +15 -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
|
@@ -45,6 +45,16 @@ export class PhoneNumberClient {
|
|
|
45
45
|
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
46
46
|
return getBusinessProfileEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
47
47
|
}
|
|
48
|
+
async getBusinessPublicKey(params, opts) {
|
|
49
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.getBusinessPublicKey");
|
|
50
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
51
|
+
return getBusinessPublicKeyEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
52
|
+
}
|
|
53
|
+
async setBusinessPublicKey(params, opts) {
|
|
54
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.setBusinessPublicKey");
|
|
55
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
56
|
+
return setBusinessPublicKeyEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
57
|
+
}
|
|
48
58
|
async getCommerceSettings(params, opts) {
|
|
49
59
|
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.getCommerceSettings");
|
|
50
60
|
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
@@ -89,6 +99,55 @@ export class PhoneNumberClient {
|
|
|
89
99
|
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
90
100
|
return submitDisplayNameForReviewEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
91
101
|
}
|
|
102
|
+
async requestVerificationCode(params, opts) {
|
|
103
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.requestVerificationCode");
|
|
104
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
105
|
+
return requestVerificationCodeEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
106
|
+
}
|
|
107
|
+
async verifyPhoneNumber(params, opts) {
|
|
108
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.verifyPhoneNumber");
|
|
109
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
110
|
+
return verifyPhoneNumberEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
111
|
+
}
|
|
112
|
+
async registerPhoneNumber(params, opts) {
|
|
113
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.registerPhoneNumber");
|
|
114
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
115
|
+
return registerPhoneNumberEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
116
|
+
}
|
|
117
|
+
async deregisterPhoneNumber(params, opts) {
|
|
118
|
+
copyOptionalParamsObject(params, "PhoneNumberClient.deregisterPhoneNumber");
|
|
119
|
+
return deregisterPhoneNumberEndpoint(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, undefined, opts);
|
|
120
|
+
}
|
|
121
|
+
async setTwoStepVerificationPin(params, opts) {
|
|
122
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.setTwoStepVerificationPin");
|
|
123
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
124
|
+
return setTwoStepVerificationPinEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
125
|
+
}
|
|
126
|
+
async createQrCode(params, opts) {
|
|
127
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.createQrCode");
|
|
128
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
129
|
+
return createQrCodeEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
130
|
+
}
|
|
131
|
+
async listQrCodes(params, opts) {
|
|
132
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.listQrCodes");
|
|
133
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
134
|
+
return listQrCodesEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
135
|
+
}
|
|
136
|
+
async getQrCode(params, opts) {
|
|
137
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.getQrCode");
|
|
138
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
139
|
+
return getQrCodeEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
140
|
+
}
|
|
141
|
+
async updateQrCode(params, opts) {
|
|
142
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.updateQrCode");
|
|
143
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
144
|
+
return updateQrCodeEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
145
|
+
}
|
|
146
|
+
async deleteQrCode(params, opts) {
|
|
147
|
+
const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.deleteQrCode");
|
|
148
|
+
scopedParams.phoneNumberId = this.#phoneNumberId;
|
|
149
|
+
return deleteQrCodeEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
150
|
+
}
|
|
92
151
|
async sendMessage(body, opts) {
|
|
93
152
|
return sendMessageEndpoint(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, body, opts);
|
|
94
153
|
}
|
|
@@ -107,6 +166,9 @@ export class PhoneNumberClient {
|
|
|
107
166
|
async sendCallPermissionRequest(input, opts) {
|
|
108
167
|
return this.sendMessage(buildSendCallPermissionRequestPayload(input), opts);
|
|
109
168
|
}
|
|
169
|
+
async sendVoiceCall(input, opts) {
|
|
170
|
+
return this.sendMessage(buildSendVoiceCallPayload(input), opts);
|
|
171
|
+
}
|
|
110
172
|
async sendDocument(input, opts) {
|
|
111
173
|
return this.sendMessage(buildSendDocumentPayload(input), opts);
|
|
112
174
|
}
|
|
@@ -195,9 +257,66 @@ export class PhoneNumberClient {
|
|
|
195
257
|
async terminateCall(input, opts) {
|
|
196
258
|
return terminateCallEndpoint(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, input, opts);
|
|
197
259
|
}
|
|
260
|
+
async#uploadInMemoryMedia(file, mimeType, options) {
|
|
261
|
+
const body = {
|
|
262
|
+
file,
|
|
263
|
+
type: mimeType,
|
|
264
|
+
messagingProduct: "whatsapp"
|
|
265
|
+
};
|
|
266
|
+
const response = await uploadMedia(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, body, options);
|
|
267
|
+
return response.id;
|
|
268
|
+
}
|
|
269
|
+
async uploadAndSendImage(input, opts) {
|
|
270
|
+
const mediaId = await this.#uploadInMemoryMedia(input.file, input.mimeType, opts);
|
|
271
|
+
return this.sendImage({
|
|
272
|
+
to: input.to,
|
|
273
|
+
mediaId,
|
|
274
|
+
...input.caption !== undefined ? { caption: input.caption } : {},
|
|
275
|
+
...input.replyToMessageId !== undefined ? { replyToMessageId: input.replyToMessageId } : {}
|
|
276
|
+
}, opts);
|
|
277
|
+
}
|
|
278
|
+
async uploadAndSendVideo(input, opts) {
|
|
279
|
+
const mediaId = await this.#uploadInMemoryMedia(input.file, input.mimeType, opts);
|
|
280
|
+
return this.sendVideo({
|
|
281
|
+
to: input.to,
|
|
282
|
+
mediaId,
|
|
283
|
+
...input.caption !== undefined ? { caption: input.caption } : {},
|
|
284
|
+
...input.replyToMessageId !== undefined ? { replyToMessageId: input.replyToMessageId } : {}
|
|
285
|
+
}, opts);
|
|
286
|
+
}
|
|
287
|
+
async uploadAndSendAudio(input, opts) {
|
|
288
|
+
const mediaId = await this.#uploadInMemoryMedia(input.file, input.mimeType, opts);
|
|
289
|
+
return this.sendAudio({
|
|
290
|
+
to: input.to,
|
|
291
|
+
mediaId,
|
|
292
|
+
...input.voice !== undefined ? { voice: input.voice } : {},
|
|
293
|
+
...input.replyToMessageId !== undefined ? { replyToMessageId: input.replyToMessageId } : {}
|
|
294
|
+
}, opts);
|
|
295
|
+
}
|
|
296
|
+
async uploadAndSendDocument(input, opts) {
|
|
297
|
+
const mediaId = await this.#uploadInMemoryMedia(input.file, input.mimeType, opts);
|
|
298
|
+
return this.sendDocument({
|
|
299
|
+
to: input.to,
|
|
300
|
+
mediaId,
|
|
301
|
+
...input.caption !== undefined ? { caption: input.caption } : {},
|
|
302
|
+
...input.filename !== undefined ? { filename: input.filename } : {},
|
|
303
|
+
...input.replyToMessageId !== undefined ? { replyToMessageId: input.replyToMessageId } : {}
|
|
304
|
+
}, opts);
|
|
305
|
+
}
|
|
306
|
+
async uploadAndSendSticker(input, opts) {
|
|
307
|
+
const mediaId = await this.#uploadInMemoryMedia(input.file, input.mimeType, opts);
|
|
308
|
+
return this.sendSticker({
|
|
309
|
+
to: input.to,
|
|
310
|
+
mediaId,
|
|
311
|
+
...input.replyToMessageId !== undefined ? { replyToMessageId: input.replyToMessageId } : {}
|
|
312
|
+
}, opts);
|
|
313
|
+
}
|
|
198
314
|
}
|
|
199
315
|
import { assertSafePathParamValue } from "../endpoint.js";
|
|
200
316
|
import { GraphRequestValidationError } from "../errors.js";
|
|
317
|
+
import {
|
|
318
|
+
uploadMedia
|
|
319
|
+
} from "../endpoints/media.js";
|
|
201
320
|
import { copyOptionalParamsObject } from "../internal/validation/options.js";
|
|
202
321
|
import { GroupClient } from "./groupClient.js";
|
|
203
322
|
import {
|
|
@@ -205,6 +324,8 @@ import {
|
|
|
205
324
|
getCommerceSettings as getCommerceSettingsEndpoint,
|
|
206
325
|
updateBusinessProfile as updateBusinessProfileEndpoint,
|
|
207
326
|
updateCommerceSettings as updateCommerceSettingsEndpoint,
|
|
327
|
+
getBusinessPublicKey as getBusinessPublicKeyEndpoint,
|
|
328
|
+
setBusinessPublicKey as setBusinessPublicKeyEndpoint,
|
|
208
329
|
getPhoneNumberInfo as getPhoneNumberInfoEndpoint,
|
|
209
330
|
getPhoneNumberSettings as getPhoneNumberSettingsEndpoint,
|
|
210
331
|
updatePhoneNumberSettings as updatePhoneNumberSettingsEndpoint,
|
|
@@ -213,7 +334,17 @@ import {
|
|
|
213
334
|
unblockUsers as unblockUsersEndpoint,
|
|
214
335
|
getOfficialBusinessAccountStatus as getOfficialBusinessAccountStatusEndpoint,
|
|
215
336
|
requestOfficialBusinessAccountReview as requestOfficialBusinessAccountReviewEndpoint,
|
|
216
|
-
submitDisplayNameForReview as submitDisplayNameForReviewEndpoint
|
|
337
|
+
submitDisplayNameForReview as submitDisplayNameForReviewEndpoint,
|
|
338
|
+
requestVerificationCode as requestVerificationCodeEndpoint,
|
|
339
|
+
verifyPhoneNumber as verifyPhoneNumberEndpoint,
|
|
340
|
+
registerPhoneNumber as registerPhoneNumberEndpoint,
|
|
341
|
+
deregisterPhoneNumber as deregisterPhoneNumberEndpoint,
|
|
342
|
+
setTwoStepVerificationPin as setTwoStepVerificationPinEndpoint,
|
|
343
|
+
createQrCode as createQrCodeEndpoint,
|
|
344
|
+
listQrCodes as listQrCodesEndpoint,
|
|
345
|
+
getQrCode as getQrCodeEndpoint,
|
|
346
|
+
updateQrCode as updateQrCodeEndpoint,
|
|
347
|
+
deleteQrCode as deleteQrCodeEndpoint
|
|
217
348
|
} from "../endpoints/businessManagement.js";
|
|
218
349
|
import {
|
|
219
350
|
acceptCall as acceptCallEndpoint,
|
|
@@ -235,6 +366,7 @@ import {
|
|
|
235
366
|
buildSendAudioPayload,
|
|
236
367
|
buildSendButtonsPayload,
|
|
237
368
|
buildSendCallPermissionRequestPayload,
|
|
369
|
+
buildSendVoiceCallPayload,
|
|
238
370
|
buildSendCatalogPayload,
|
|
239
371
|
buildSendContactsPayload,
|
|
240
372
|
buildSendCtaUrlPayload,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { GraphClient } from "../client.js";
|
|
2
2
|
import type { EndpointInvokeOptions } from "../endpoint.js";
|
|
3
|
-
import { type GetWabaInfoInput, type SubscribedAppsResponse, type WabaInfo } from "../endpoints/businessManagement.js";
|
|
3
|
+
import { type CreatePhoneNumberInput, type CreatePhoneNumberResponse, type ClearWabaCallbackOverrideInput, type GetWabaInfoInput, type SetWabaCallbackOverrideInput, type SubscribedAppsResponse, type WabaCallbackOverrideResponse, type WabaInfo } from "../endpoints/businessManagement.js";
|
|
4
4
|
import { type ListPhoneNumbersInput, type PhoneNumberListResponse } from "../endpoints/waba/index.js";
|
|
5
|
-
import { type CreateFlowBody, type CreateMessageTemplateBody, type DeleteMessageTemplateInput, type FlowAssetsResponse, type FlowDetails, type FlowListResponse, type FlowMutationResponse, type GetFlowAssetsInput, type GetFlowInput, type GetMessageTemplateInput, type ListFlowsInput, type ListMessageTemplatesInput, type ListTemplateGroupsInput, type TemplateDetails, type TemplateGroupAnalyticsInput, type TemplateGroupAnalyticsResponse, type TemplateGroupDetails, type TemplateGroupListResponse, type TemplateGroupMutationResponse, type TemplateListResponse, type TemplateMutationResponse, type CreateTemplateGroupBody, type DeleteTemplateGroupInput, type GetTemplateGroupInput, type UpdateTemplateGroupBody, type UpdateFlowJsonBody, type UpdateFlowMetadataBody, type UpdateMessageTemplateBody } from "../endpoints/wabaEndpoints.js";
|
|
5
|
+
import { type CreateFlowBody, type CreateMessageTemplateBody, type DeleteMessageTemplateInput, type FlowAssetsResponse, type FlowDetails, type FlowListResponse, type FlowMetric, type FlowMutationResponse, type GetFlowAssetsInput, type GetFlowInput, type GetFlowMetricsInput, type GetMessageTemplateInput, type ListFlowsInput, type ListMessageTemplatesInput, type ListTemplateGroupsInput, type MigrateFlowsInput, type MigrateFlowsResponse, type TemplateDetails, type TemplateGroupAnalyticsInput, type TemplateGroupAnalyticsResponse, type TemplateGroupDetails, type TemplateGroupListResponse, type TemplateGroupMutationResponse, type TemplateListResponse, type TemplateMutationResponse, type CreateTemplateGroupBody, type CompareTemplatesInput, type DeleteTemplateGroupInput, type GetTemplateGroupInput, type MigrateTemplatesInput, type MigrateTemplatesResponse, type ArchiveTemplatesInput, type ArchiveTemplatesResponse, type UnarchiveTemplatesInput, type UnarchiveTemplatesResponse, type UpsertAuthenticationTemplateBody, type UpsertAuthenticationTemplateResponse, type TemplatesCompareResult, type TemplateUnpauseResult, type UnpauseTemplateInput, type UpdateTemplateGroupBody, type UpdateFlowJsonBody, type UpdateFlowMetadataBody, type UpdateMessageTemplateBody } from "../endpoints/wabaEndpoints.js";
|
|
6
6
|
export interface WABAClientConfig {
|
|
7
7
|
readonly graphClient: GraphClient;
|
|
8
8
|
readonly wabaId: string;
|
|
@@ -17,12 +17,25 @@ export declare class WABAClient {
|
|
|
17
17
|
getInfo(params?: Omit<GetWabaInfoInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<WabaInfo>;
|
|
18
18
|
/** Graph `GET /{wabaId}/subscribed_apps`. */
|
|
19
19
|
listSubscribedApps(params?: Record<string, never>, opts?: EndpointInvokeOptions): Promise<SubscribedAppsResponse>;
|
|
20
|
+
/** Graph `POST /{wabaId}/subscribed_apps` — sets a WABA alternate callback URL. */
|
|
21
|
+
setCallbackOverride(params: Omit<SetWabaCallbackOverrideInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<WabaCallbackOverrideResponse>;
|
|
22
|
+
/** Graph `POST /{wabaId}/subscribed_apps` with no body — clears the override. */
|
|
23
|
+
clearCallbackOverride(params?: Omit<ClearWabaCallbackOverrideInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<WabaCallbackOverrideResponse>;
|
|
20
24
|
/**
|
|
21
25
|
* Graph `GET /{wabaId}/phone_numbers` — returns the phone numbers
|
|
22
26
|
* attached to this WABA. Delegates to the F-6 `listPhoneNumbers`
|
|
23
27
|
* endpoint-registry callable with the bound wabaId injected.
|
|
24
28
|
*/
|
|
25
29
|
listPhoneNumbers(params?: Omit<ListPhoneNumbersInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<PhoneNumberListResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Graph `POST /{wabaId}/phone_numbers` (WATS-155) — registers a new
|
|
32
|
+
* phone number against the bound WABA. Mirrors pywa's
|
|
33
|
+
* `WhatsApp.create_phone_number`. The bound wabaId is injected into the
|
|
34
|
+
* params object and wins over any caller-supplied `wabaId`; body fields
|
|
35
|
+
* (countryCode / phoneNumber / verifiedName) are passed through to the
|
|
36
|
+
* endpoint callable's body builder.
|
|
37
|
+
*/
|
|
38
|
+
createPhoneNumber(body: Omit<CreatePhoneNumberInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<CreatePhoneNumberResponse>;
|
|
26
39
|
/** Graph `GET /{wabaId}/message_templates`. */
|
|
27
40
|
listMessageTemplates(params?: Omit<ListMessageTemplatesInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<TemplateListResponse>;
|
|
28
41
|
/** Graph `POST /{wabaId}/message_templates`. */
|
|
@@ -49,6 +62,59 @@ export declare class WABAClient {
|
|
|
49
62
|
deleteTemplateGroup(params: DeleteTemplateGroupInput, opts?: EndpointInvokeOptions): Promise<TemplateGroupMutationResponse>;
|
|
50
63
|
/** Graph `GET /{wabaId}/template_group_analytics`. */
|
|
51
64
|
getTemplateGroupAnalytics(params?: Omit<TemplateGroupAnalyticsInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<TemplateGroupAnalyticsResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Graph `GET /{templateId}/compare` (WATS-153). Template-id scoped edge
|
|
67
|
+
* that compares send/block metrics across templates. Delegates to the
|
|
68
|
+
* endpoint-registry callable; the bound wabaId is not used because the
|
|
69
|
+
* path is template-id scoped (mirrors getMessageTemplate).
|
|
70
|
+
*/
|
|
71
|
+
compareTemplates(params: CompareTemplatesInput, opts?: EndpointInvokeOptions): Promise<TemplatesCompareResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Graph `POST /{templateId}/unpause` (WATS-153). Template-id scoped edge
|
|
74
|
+
* that unpauses a paused template. Delegates to the endpoint-registry
|
|
75
|
+
* callable; the bound wabaId is not used (mirrors getMessageTemplate).
|
|
76
|
+
* The endpoint/response shape is UNVERIFIED — see REFERENCE-153.md.
|
|
77
|
+
*/
|
|
78
|
+
unpauseTemplate(params: UnpauseTemplateInput, opts?: EndpointInvokeOptions): Promise<TemplateUnpauseResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Graph `POST /{wabaId}/migrate_message_templates?source_waba_id=...`
|
|
81
|
+
* (WATS-160A). Copies (not moves) message templates from a source WABA
|
|
82
|
+
* into the bound destination WABA. Mirrors pywa's
|
|
83
|
+
* `WhatsApp.migrate_templates`. The bound wabaId is used as the
|
|
84
|
+
* destination and wins over any caller-supplied `destinationWabaId`
|
|
85
|
+
* (mirrors `migrateFlows`). See REFERENCE-160 / handoff.
|
|
86
|
+
*/
|
|
87
|
+
migrateTemplates(params: Omit<MigrateTemplatesInput, "destinationWabaId">, opts?: EndpointInvokeOptions): Promise<MigrateTemplatesResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* `POST https://api.facebook.com/{wabaId}/message_templates/archive`
|
|
90
|
+
* (WATS-160B). Bulk-archive up to 100 message templates on the bound WABA.
|
|
91
|
+
* Mirrors pywa's `WhatsApp.archive_templates`. Uses
|
|
92
|
+
* `GraphClient.requestRaw` (not `defineEndpoint`) because the endpoint
|
|
93
|
+
* lives on api.facebook.com, not graph.facebook.com. The bound wabaId is
|
|
94
|
+
* used in the path and wins over any caller-supplied `wabaId` (mirrors
|
|
95
|
+
* `migrateTemplates`). See REFERENCE-153.md §5.
|
|
96
|
+
*/
|
|
97
|
+
archiveTemplates(params: Omit<ArchiveTemplatesInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<ArchiveTemplatesResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* `POST https://api.facebook.com/{wabaId}/message_templates/unarchive`
|
|
100
|
+
* (WATS-160B). Bulk-unarchive up to 100 message templates on the bound
|
|
101
|
+
* WABA. Mirrors pywa's `WhatsApp.unarchive_templates`. Uses
|
|
102
|
+
* `GraphClient.requestRaw` (not `defineEndpoint`) because the endpoint
|
|
103
|
+
* lives on api.facebook.com, not graph.facebook.com. The bound wabaId is
|
|
104
|
+
* used in the path and wins over any caller-supplied `wabaId` (mirrors
|
|
105
|
+
* `migrateTemplates`). See REFERENCE-153.md §5.
|
|
106
|
+
*/
|
|
107
|
+
unarchiveTemplates(params: Omit<UnarchiveTemplatesInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<UnarchiveTemplatesResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* `POST /{wabaId}/upsert_message_templates` (WATS-160C). Upserts an
|
|
110
|
+
* authentication message template (one or more languages) on the bound
|
|
111
|
+
* WABA. Mirrors pywa's `WhatsApp.upsert_authentication_template`. The
|
|
112
|
+
* bound wabaId is used in the path and wins over any caller-supplied
|
|
113
|
+
* `wabaId`. Stricter than `createMessageTemplate`: the body is a fixed
|
|
114
|
+
* camelCase descriptor translated into the Graph AUTHENTICATION
|
|
115
|
+
* component layout. See advanced.ts / REFERENCE.
|
|
116
|
+
*/
|
|
117
|
+
upsertAuthenticationTemplate(body: UpsertAuthenticationTemplateBody, opts?: EndpointInvokeOptions): Promise<UpsertAuthenticationTemplateResponse>;
|
|
52
118
|
/** Graph `GET /{wabaId}/flows`. */
|
|
53
119
|
listFlows(params?: Omit<ListFlowsInput, "wabaId">, opts?: EndpointInvokeOptions): Promise<FlowListResponse>;
|
|
54
120
|
/** Graph `POST /{wabaId}/flows`. */
|
|
@@ -77,4 +143,18 @@ export declare class WABAClient {
|
|
|
77
143
|
}, opts?: EndpointInvokeOptions): Promise<FlowMutationResponse>;
|
|
78
144
|
/** Graph `GET /{flowId}/assets`. */
|
|
79
145
|
getFlowAssets(params: GetFlowAssetsInput, opts?: EndpointInvokeOptions): Promise<FlowAssetsResponse>;
|
|
146
|
+
/**
|
|
147
|
+
* Graph `GET /{flowId}?fields=metric.name(...).granularity(...)...`
|
|
148
|
+
* (WATS-154). Flow-id scoped edge that returns Flow metrics; the bound
|
|
149
|
+
* wabaId is not used because the path is flow-id scoped (mirrors
|
|
150
|
+
* getFlow / getFlowAssets). See REFERENCE-154.md §1.
|
|
151
|
+
*/
|
|
152
|
+
getFlowMetrics(params: GetFlowMetricsInput, opts?: EndpointInvokeOptions): Promise<FlowMetric>;
|
|
153
|
+
/**
|
|
154
|
+
* Graph `POST /{wabaId}/migrate_flows?source_waba_id=...&source_flow_names=...`
|
|
155
|
+
* (WATS-154). Copies (not moves) Flows from a source WABA into the bound
|
|
156
|
+
* destination WABA. Mirrors pywa's `WhatsApp.migrate_flows`. The bound
|
|
157
|
+
* wabaId is used as the destination; see REFERENCE-154.md §2.
|
|
158
|
+
*/
|
|
159
|
+
migrateFlows(params: Omit<MigrateFlowsInput, "destinationWabaId">, opts?: EndpointInvokeOptions): Promise<MigrateFlowsResponse>;
|
|
80
160
|
}
|
|
@@ -21,11 +21,27 @@ export class WABAClient {
|
|
|
21
21
|
copyOptionalParamsObject(params, "WABAClient.listSubscribedApps");
|
|
22
22
|
return listSubscribedAppsEndpoint(this.#graphClient, { wabaId: this.#wabaId }, undefined, opts);
|
|
23
23
|
}
|
|
24
|
+
async setCallbackOverride(params, opts) {
|
|
25
|
+
const scopedParams = copyOptionalParamsObject(params, "WABAClient.setCallbackOverride");
|
|
26
|
+
scopedParams.wabaId = this.#wabaId;
|
|
27
|
+
return setWabaCallbackOverrideEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
28
|
+
}
|
|
29
|
+
async clearCallbackOverride(params, opts) {
|
|
30
|
+
copyOptionalParamsObject(params, "WABAClient.clearCallbackOverride");
|
|
31
|
+
return clearWabaCallbackOverrideEndpoint(this.#graphClient, { wabaId: this.#wabaId }, undefined, opts);
|
|
32
|
+
}
|
|
24
33
|
async listPhoneNumbers(params, opts) {
|
|
25
34
|
const scopedParams = copyOptionalParamsObject(params, "WABAClient.listPhoneNumbers");
|
|
26
35
|
scopedParams.wabaId = this.#wabaId;
|
|
27
36
|
return listPhoneNumbersEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
28
37
|
}
|
|
38
|
+
async createPhoneNumber(body, opts) {
|
|
39
|
+
const input = {
|
|
40
|
+
...copyOptionalParamsObject(body, "WABAClient.createPhoneNumber"),
|
|
41
|
+
wabaId: this.#wabaId
|
|
42
|
+
};
|
|
43
|
+
return createPhoneNumberEndpoint(this.#graphClient, input, undefined, opts);
|
|
44
|
+
}
|
|
29
45
|
async listMessageTemplates(params, opts) {
|
|
30
46
|
const scopedParams = {
|
|
31
47
|
...copyOptionalParamsObject(params, "WABAClient.listMessageTemplates"),
|
|
@@ -94,6 +110,41 @@ export class WABAClient {
|
|
|
94
110
|
};
|
|
95
111
|
return getTemplateGroupAnalyticsEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
96
112
|
}
|
|
113
|
+
async compareTemplates(params, opts) {
|
|
114
|
+
return compareTemplatesEndpoint(this.#graphClient, params, undefined, opts);
|
|
115
|
+
}
|
|
116
|
+
async unpauseTemplate(params, opts) {
|
|
117
|
+
return unpauseTemplateEndpoint(this.#graphClient, params, undefined, opts);
|
|
118
|
+
}
|
|
119
|
+
async migrateTemplates(params, opts) {
|
|
120
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
121
|
+
throw new GraphRequestValidationError("Invalid WABAClient.migrateTemplates params: expected an options object.");
|
|
122
|
+
}
|
|
123
|
+
const descriptors = Object.getOwnPropertyDescriptors(params);
|
|
124
|
+
const scopedParams = {};
|
|
125
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
126
|
+
if (typeof descriptor.get === "function" || typeof descriptor.set === "function") {
|
|
127
|
+
throw new GraphRequestValidationError(`Invalid WABAClient.migrateTemplates params: ${key} must not use accessors.`);
|
|
128
|
+
}
|
|
129
|
+
if (descriptor.value !== undefined)
|
|
130
|
+
scopedParams[key] = descriptor.value;
|
|
131
|
+
}
|
|
132
|
+
scopedParams.destinationWabaId = this.#wabaId;
|
|
133
|
+
return migrateTemplatesEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
134
|
+
}
|
|
135
|
+
async archiveTemplates(params, opts) {
|
|
136
|
+
const scopedParams = scopedArchiveParams(params, "WABAClient.archiveTemplates");
|
|
137
|
+
scopedParams.wabaId = this.#wabaId;
|
|
138
|
+
return archiveTemplatesEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
139
|
+
}
|
|
140
|
+
async unarchiveTemplates(params, opts) {
|
|
141
|
+
const scopedParams = scopedArchiveParams(params, "WABAClient.unarchiveTemplates");
|
|
142
|
+
scopedParams.wabaId = this.#wabaId;
|
|
143
|
+
return unarchiveTemplatesEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
144
|
+
}
|
|
145
|
+
async upsertAuthenticationTemplate(body, opts) {
|
|
146
|
+
return upsertAuthenticationTemplateEndpoint(this.#graphClient, { wabaId: this.#wabaId }, body, opts);
|
|
147
|
+
}
|
|
97
148
|
async listFlows(params, opts) {
|
|
98
149
|
const scopedParams = {
|
|
99
150
|
...copyOptionalParamsObject(params, "WABAClient.listFlows"),
|
|
@@ -132,13 +183,36 @@ export class WABAClient {
|
|
|
132
183
|
const { flowId, rest } = splitFlowIdParams(params, "WABAClient.getFlowAssets");
|
|
133
184
|
return getFlowAssetsEndpoint(this.#graphClient, { flowId, ...rest }, undefined, opts);
|
|
134
185
|
}
|
|
186
|
+
async getFlowMetrics(params, opts) {
|
|
187
|
+
const { flowId, rest } = splitFlowIdParams(params, "WABAClient.getFlowMetrics");
|
|
188
|
+
return getFlowMetricsEndpoint(this.#graphClient, { flowId, ...rest }, undefined, opts);
|
|
189
|
+
}
|
|
190
|
+
async migrateFlows(params, opts) {
|
|
191
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
192
|
+
throw new GraphRequestValidationError("Invalid WABAClient.migrateFlows params: expected an options object.");
|
|
193
|
+
}
|
|
194
|
+
const descriptors = Object.getOwnPropertyDescriptors(params);
|
|
195
|
+
const scopedParams = {};
|
|
196
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
197
|
+
if (typeof descriptor.get === "function" || typeof descriptor.set === "function") {
|
|
198
|
+
throw new GraphRequestValidationError(`Invalid WABAClient.migrateFlows params: ${key} must not use accessors.`);
|
|
199
|
+
}
|
|
200
|
+
if (descriptor.value !== undefined)
|
|
201
|
+
scopedParams[key] = descriptor.value;
|
|
202
|
+
}
|
|
203
|
+
scopedParams.destinationWabaId = this.#wabaId;
|
|
204
|
+
return migrateFlowsEndpoint(this.#graphClient, scopedParams, undefined, opts);
|
|
205
|
+
}
|
|
135
206
|
}
|
|
136
207
|
import { assertSafePathParamValue } from "../endpoint.js";
|
|
137
208
|
import { GraphRequestValidationError } from "../errors.js";
|
|
138
209
|
import { copyOptionalParamsObject, splitRequiredStringDataProp } from "../internal/validation/options.js";
|
|
139
210
|
import {
|
|
140
211
|
getWabaInfo as getWabaInfoEndpoint,
|
|
141
|
-
listSubscribedApps as listSubscribedAppsEndpoint
|
|
212
|
+
listSubscribedApps as listSubscribedAppsEndpoint,
|
|
213
|
+
setWabaCallbackOverride as setWabaCallbackOverrideEndpoint,
|
|
214
|
+
clearWabaCallbackOverride as clearWabaCallbackOverrideEndpoint,
|
|
215
|
+
createPhoneNumber as createPhoneNumberEndpoint
|
|
142
216
|
} from "../endpoints/businessManagement.js";
|
|
143
217
|
import {
|
|
144
218
|
listPhoneNumbers as listPhoneNumbersEndpoint
|
|
@@ -155,15 +229,23 @@ import {
|
|
|
155
229
|
updateTemplateGroup as updateTemplateGroupEndpoint,
|
|
156
230
|
deleteTemplateGroup as deleteTemplateGroupEndpoint,
|
|
157
231
|
getTemplateGroupAnalytics as getTemplateGroupAnalyticsEndpoint,
|
|
232
|
+
compareTemplates as compareTemplatesEndpoint,
|
|
233
|
+
unpauseTemplate as unpauseTemplateEndpoint,
|
|
234
|
+
migrateTemplates as migrateTemplatesEndpoint,
|
|
235
|
+
archiveTemplates as archiveTemplatesEndpoint,
|
|
236
|
+
unarchiveTemplates as unarchiveTemplatesEndpoint,
|
|
237
|
+
upsertAuthenticationTemplate as upsertAuthenticationTemplateEndpoint,
|
|
158
238
|
listFlows as listFlowsEndpoint,
|
|
159
239
|
getFlow as getFlowEndpoint,
|
|
240
|
+
getFlowMetrics as getFlowMetricsEndpoint,
|
|
160
241
|
createFlow as createFlowEndpoint,
|
|
161
242
|
updateFlowMetadata as updateFlowMetadataEndpoint,
|
|
162
243
|
updateFlowJson as updateFlowJsonEndpoint,
|
|
163
244
|
publishFlow as publishFlowEndpoint,
|
|
164
245
|
deleteFlow as deleteFlowEndpoint,
|
|
165
246
|
deprecateFlow as deprecateFlowEndpoint,
|
|
166
|
-
getFlowAssets as getFlowAssetsEndpoint
|
|
247
|
+
getFlowAssets as getFlowAssetsEndpoint,
|
|
248
|
+
migrateFlows as migrateFlowsEndpoint
|
|
167
249
|
} from "../endpoints/wabaEndpoints.js";
|
|
168
250
|
function hasRequestMethod(candidate) {
|
|
169
251
|
if (candidate === null || typeof candidate !== "object") {
|
|
@@ -211,3 +293,21 @@ function splitFlowIdParams(params, helperName) {
|
|
|
211
293
|
const split = splitRequiredStringDataProp(params, "flowId", helperName);
|
|
212
294
|
return { flowId: split.value, rest: split.rest };
|
|
213
295
|
}
|
|
296
|
+
function scopedArchiveParams(params, helperName) {
|
|
297
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
298
|
+
throw new GraphRequestValidationError(`Invalid ${helperName} params: expected an options object.`);
|
|
299
|
+
}
|
|
300
|
+
const descriptors = Object.getOwnPropertyDescriptors(params);
|
|
301
|
+
const scopedParams = {};
|
|
302
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
303
|
+
if (typeof descriptor.get === "function" || typeof descriptor.set === "function") {
|
|
304
|
+
throw new GraphRequestValidationError(`Invalid ${helperName} params: ${key} must not use accessors.`);
|
|
305
|
+
}
|
|
306
|
+
if (key === "wabaId") {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (descriptor.value !== undefined)
|
|
310
|
+
scopedParams[key] = descriptor.value;
|
|
311
|
+
}
|
|
312
|
+
return scopedParams;
|
|
313
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wats/graph",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.27",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
"types": "./dist/transport.d.ts",
|
|
52
52
|
"import": "./dist/transport.js"
|
|
53
53
|
},
|
|
54
|
+
"./node-media": {
|
|
55
|
+
"types": "./dist/nodeMedia.d.ts",
|
|
56
|
+
"import": "./dist/nodeMedia.js"
|
|
57
|
+
},
|
|
54
58
|
"./testing": {
|
|
55
59
|
"types": "./dist/createMockTransport.d.ts",
|
|
56
60
|
"import": "./dist/createMockTransport.js"
|
|
@@ -64,20 +68,14 @@
|
|
|
64
68
|
"publishConfig": {
|
|
65
69
|
"access": "public"
|
|
66
70
|
},
|
|
67
|
-
"repository": {
|
|
68
|
-
"type": "git",
|
|
69
|
-
"url": "git+https://github.com/Switchbord/wats.git",
|
|
70
|
-
"directory": "packages/graph"
|
|
71
|
-
},
|
|
72
|
-
"homepage": "https://github.com/Switchbord/wats#readme",
|
|
73
|
-
"bugs": {
|
|
74
|
-
"url": "https://github.com/Switchbord/wats/issues"
|
|
75
|
-
},
|
|
76
71
|
"keywords": [
|
|
77
72
|
"whatsapp",
|
|
78
73
|
"whatsapp-cloud-api",
|
|
79
74
|
"bun",
|
|
80
75
|
"typescript",
|
|
81
76
|
"wats"
|
|
82
|
-
]
|
|
77
|
+
],
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@wats/crypto": "^0.3.27"
|
|
80
|
+
}
|
|
83
81
|
}
|