@venturekit/notify 0.0.13 → 0.0.15
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 +59 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/whatsapp-meta.d.ts +232 -1
- package/dist/providers/whatsapp-meta.d.ts.map +1 -1
- package/dist/providers/whatsapp-meta.js +242 -30
- package/dist/providers/whatsapp-meta.js.map +1 -1
- package/package.json +25 -25
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ export default defineVenture({
|
|
|
39
39
|
hostedZoneId: 'Z123…', // optional: auto-publish DKIM CNAMEs in Route53
|
|
40
40
|
whatsapp: {
|
|
41
41
|
phoneNumberId: '105954992345678', // from Meta Business Suite
|
|
42
|
+
wabaId: '102290129340398', // optional: only for managing templates
|
|
42
43
|
},
|
|
43
44
|
},
|
|
44
45
|
],
|
|
@@ -69,6 +70,8 @@ export const notify = createNotifyClient({
|
|
|
69
70
|
}),
|
|
70
71
|
createMetaWhatsAppProvider({
|
|
71
72
|
phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
73
|
+
// Only needed for the template-management APIs below.
|
|
74
|
+
wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
72
75
|
tokenResolver: createSecretsTokenResolver({
|
|
73
76
|
secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
74
77
|
}),
|
|
@@ -225,6 +228,61 @@ notify.registerTemplate({
|
|
|
225
228
|
|
|
226
229
|
Phase 2 will introduce DB-backed templates with admin UI editing — see the project roadmap.
|
|
227
230
|
|
|
231
|
+
## Managing WhatsApp templates on Meta
|
|
232
|
+
|
|
233
|
+
The `metaTemplateName` above has to exist and be approved on Meta's side before you can send it. You can create it by hand in WhatsApp Manager, or from code — `createMetaWhatsAppProvider` returns a `MetaWhatsAppProvider` with four extra methods for the Business Management API.
|
|
234
|
+
|
|
235
|
+
These are **not** used by the dispatcher; call them from a migration, a CLI task, or an admin route. All four need a `wabaId` except `updateTemplate`, which addresses the template node directly.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import { createMetaWhatsAppProvider, createSecretsTokenResolver } from '@venturekit/notify';
|
|
239
|
+
|
|
240
|
+
const wa = createMetaWhatsAppProvider({
|
|
241
|
+
phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
242
|
+
wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
243
|
+
tokenResolver: createSecretsTokenResolver({
|
|
244
|
+
secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
245
|
+
}),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// 1. Submit for review. Names are lowercase + digits + underscores only.
|
|
249
|
+
const created = await wa.createTemplate({
|
|
250
|
+
name: 'application_received_v1',
|
|
251
|
+
language: 'fr',
|
|
252
|
+
category: 'UTILITY',
|
|
253
|
+
// Let Meta re-categorise rather than reject outright. Changes billing,
|
|
254
|
+
// so check `created.category` for what it actually assigned.
|
|
255
|
+
allowCategoryChange: true,
|
|
256
|
+
components: [
|
|
257
|
+
{ type: 'BODY', text: 'Bonjour {{1}}, votre dossier {{2}} est reçu.',
|
|
258
|
+
example: { body_text: [['Ana', 'Île-de-France #4']] } },
|
|
259
|
+
],
|
|
260
|
+
});
|
|
261
|
+
// -> { id, name, status: 'PENDING', category }
|
|
262
|
+
|
|
263
|
+
// 2. Poll until Meta finishes reviewing (also delivered as a
|
|
264
|
+
// `message_template_status_update` webhook).
|
|
265
|
+
const status = await wa.getTemplateStatus('application_received_v1', 'fr');
|
|
266
|
+
if (status.status === 'REJECTED') console.error(status.rejectedReason);
|
|
267
|
+
|
|
268
|
+
// 3. Edits re-open review, so the response only confirms acceptance —
|
|
269
|
+
// poll `getTemplateStatus` again for the outcome.
|
|
270
|
+
await wa.updateTemplate({
|
|
271
|
+
templateId: created.id,
|
|
272
|
+
components: [{ type: 'BODY', text: 'Bonjour {{1}}, dossier {{2}} confirmé.' }],
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// 4. Delete one language variant, or every language sharing the name.
|
|
276
|
+
await wa.deleteTemplate({ name: 'application_received_v1', templateId: created.id });
|
|
277
|
+
await wa.deleteTemplate({ name: 'application_received_v1' });
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
A few Meta quirks the provider papers over, worth knowing about:
|
|
281
|
+
|
|
282
|
+
- **`status` and `category` are open string unions.** Meta adds values without notice (`PAUSED`, `LIMIT_EXCEEDED`, legacy `TRANSACTIONAL`, …), so don't assume a `switch` over them is exhaustive.
|
|
283
|
+
- **Reads are paginated and field-gated.** `getTemplateStatus` asks for `rejected_reason` explicitly (it is absent from Meta's default field set) and follows `paging.next` up to 10 pages, because one name can exist once per language.
|
|
284
|
+
- **Failures split by retryability.** `ProviderSendError` means Meta was unreachable, rate-limited or broken — retrying the identical call may work. `ProviderHardError` means the request or the configuration is wrong.
|
|
285
|
+
|
|
228
286
|
## Admin / inbox helpers
|
|
229
287
|
|
|
230
288
|
`@venturekit/notify/admin` exposes route-helper functions consumers wire into their own handlers (no automatic mounting — pick your own auth/scope conventions):
|
|
@@ -277,6 +335,7 @@ The infra package injects these on every Lambda when a notify intent is declared
|
|
|
277
335
|
| `VENTURE_NOTIFY_CONFIG_SET` | First notify intent's SES configuration set name |
|
|
278
336
|
| `VENTURE_NOTIFY_EVENTS_TOPIC_ARN` | First notify intent's SES events SNS topic ARN |
|
|
279
337
|
| `VENTURE_NOTIFY_WHATSAPP_PHONE_ID` | First notify intent's `whatsapp.phoneNumberId` |
|
|
338
|
+
| `VENTURE_NOTIFY_WHATSAPP_WABA_ID` | First notify intent's `whatsapp.wabaId` (optional; needed by `createTemplate` / `getTemplateStatus` / `deleteTemplate`) |
|
|
280
339
|
| `VENTURE_NOTIFY_WHATSAPP_API_VERSION` | First notify intent's `whatsapp.apiVersion` |
|
|
281
340
|
| `VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET` | Secrets Manager ARN for the WhatsApp token |
|
|
282
341
|
| `NOTIFY_<ID>_FROM` / `NOTIFY_<ID>_CONFIG_SET` / `NOTIFY_<ID>_EVENTS_TOPIC_ARN` | Per-id overrides for projects with multiple intents |
|
package/dist/client.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ export interface NotifyClient {
|
|
|
110
110
|
* }),
|
|
111
111
|
* createMetaWhatsAppProvider({
|
|
112
112
|
* phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
113
|
+
* // Only needed for the template-management APIs.
|
|
114
|
+
* wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
113
115
|
* tokenResolver: createSecretsTokenResolver({
|
|
114
116
|
* secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
115
117
|
* }),
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAEf,MAAM,YAAY,CAAC;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E,GAAG,IAAI,CAAC;IAE1D,8CAA8C;IAC9C,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IAEjD,gEAAgE;IAChE,KAAK,EAAE,WAAW,CAAC;IACnB,4CAA4C;IAC5C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,uCAAuC;IACvC,SAAS,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IACtD,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,YAAY,CA8Nd"}
|
package/dist/client.js
CHANGED
|
@@ -41,6 +41,8 @@ import { createTemplateRegistry, } from './templates/registry.js';
|
|
|
41
41
|
* }),
|
|
42
42
|
* createMetaWhatsAppProvider({
|
|
43
43
|
* phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
44
|
+
* // Only needed for the template-management APIs.
|
|
45
|
+
* wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
44
46
|
* tokenResolver: createSecretsTokenResolver({
|
|
45
47
|
* secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
46
48
|
* }),
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AAyFjC
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,sBAAsB,GAEvB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OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAC,CAAC;YACH,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QACnE,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,mEAAmE;AACnE,uDAAuD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* createSesEmailProvider({ region: process.env.AWS_REGION! }),
|
|
18
18
|
* createMetaWhatsAppProvider({
|
|
19
19
|
* phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
20
|
+
* // Only needed for the template-management APIs.
|
|
21
|
+
* wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
20
22
|
* tokenResolver: createSecretsTokenResolver({
|
|
21
23
|
* secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
22
24
|
* }),
|
|
@@ -53,7 +55,7 @@ export type { NotifyChannel, NotificationStatus, NotifyAddress, NotificationRow,
|
|
|
53
55
|
export { createNotifyClient, type NotifyClient, type CreateNotifyClientOptions, type AddressResolver, } from './client.js';
|
|
54
56
|
export { createTemplateRegistry, TemplateNotFoundError, type TemplateRegistry, } from './templates/registry.js';
|
|
55
57
|
export { createPostgresNotifyStore, type CreatePostgresNotifyStoreOptions, type NotifyStore, type CreateNotificationInput, type UpdateNotificationStatusInput, type ListForUserOptions, type AdminListOptions, } from './store/index.js';
|
|
56
|
-
export { ProviderHardError, ProviderSendError, type NotifyProvider, type ProviderSendRequest, type ProviderSendResult, createSesEmailProvider, type SesEmailProviderConfig, __resetSesClientForTests, createMetaWhatsAppProvider, createSecretsTokenResolver, type MetaWhatsAppProviderConfig, createSmsNoopProvider, createPushNoopProvider, createEmailNoopProvider, type EmailNoopOptions, createMailHogProvider, type MailHogProviderConfig, } from './providers/index.js';
|
|
58
|
+
export { ProviderHardError, ProviderSendError, type NotifyProvider, type ProviderSendRequest, type ProviderSendResult, createSesEmailProvider, type SesEmailProviderConfig, __resetSesClientForTests, createMetaWhatsAppProvider, createSecretsTokenResolver, type MetaWhatsAppProvider, type MetaWhatsAppProviderConfig, type WhatsAppTemplateCategory, type WhatsAppTemplateCategoryReported, type WhatsAppTemplateStatus, type WhatsAppTemplateRejectedReason, type WhatsAppTemplateComponent, type WhatsAppTemplateInput, type WhatsAppTemplateCreateResult, type WhatsAppTemplateStatusResult, type WhatsAppTemplateUpdateInput, type WhatsAppTemplateUpdateResult, type WhatsAppTemplateDeleteInput, type WhatsAppTemplateDeleteResult, createSmsNoopProvider, createPushNoopProvider, createEmailNoopProvider, type EmailNoopOptions, createMailHogProvider, type MailHogProviderConfig, } from './providers/index.js';
|
|
57
59
|
export { dispatchOnce, makeDispatchHandler, type DispatchOutcome, type DispatchSummary, type DispatchOnceOptions, } from './dispatcher.js';
|
|
58
60
|
export { makeBounceHandler, type BounceHandlerOutcome, } from './bounce-handler.js';
|
|
59
61
|
export { adminListNotifications, adminGetNotification, adminSendNotification, adminRetryNotification, adminCancelNotification, adminClearSuppression, listUserPreferences, upsertUserPreference, listNotificationsForUser, type AdminListResult, type AdminSendInput, } from './admin/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.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AAqB,GAC3B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* createSesEmailProvider({ region: process.env.AWS_REGION! }),
|
|
18
18
|
* createMetaWhatsAppProvider({
|
|
19
19
|
* phoneNumberId: process.env.VENTURE_NOTIFY_WHATSAPP_PHONE_ID!,
|
|
20
|
+
* // Only needed for the template-management APIs.
|
|
21
|
+
* wabaId: process.env.VENTURE_NOTIFY_WHATSAPP_WABA_ID,
|
|
20
22
|
* tokenResolver: createSecretsTokenResolver({
|
|
21
23
|
* secretArn: process.env.VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET!,
|
|
22
24
|
* }),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAkBH,sEAAsE;AACtE,OAAO,EACL,kBAAkB,GAInB,MAAM,aAAa,CAAC;AAErB,sEAAsE;AACtE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,OAAO,EACL,yBAAyB,GAO1B,MAAM,kBAAkB,CAAC;AAE1B,sEAAsE;AACtE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAIjB,sBAAsB,EAEtB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAe1B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EAEvB,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAE9B,sEAAsE;AACtE,OAAO,EACL,YAAY,EACZ,mBAAmB,GAIpB,MAAM,iBAAiB,CAAC;AAEzB,sEAAsE;AACtE,OAAO,EACL,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAE7B,sEAAsE;AACtE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,GAGzB,MAAM,kBAAkB,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { ProviderHardError, ProviderSendError, type NotifyProvider, type ProviderSendRequest, type ProviderSendResult, } from './types.js';
|
|
15
15
|
export { createSesEmailProvider, type SesEmailProviderConfig, __resetSesClientForTests, } from './email-ses.js';
|
|
16
|
-
export { createMetaWhatsAppProvider, createSecretsTokenResolver, type MetaWhatsAppProviderConfig, } from './whatsapp-meta.js';
|
|
16
|
+
export { createMetaWhatsAppProvider, createSecretsTokenResolver, type MetaWhatsAppProvider, type MetaWhatsAppProviderConfig, type WhatsAppTemplateCategory, type WhatsAppTemplateCategoryReported, type WhatsAppTemplateStatus, type WhatsAppTemplateRejectedReason, type WhatsAppTemplateComponent, type WhatsAppTemplateInput, type WhatsAppTemplateCreateResult, type WhatsAppTemplateStatusResult, type WhatsAppTemplateUpdateInput, type WhatsAppTemplateUpdateResult, type WhatsAppTemplateDeleteInput, type WhatsAppTemplateDeleteResult, } from './whatsapp-meta.js';
|
|
17
17
|
export { createSmsNoopProvider } from './sms-noop.js';
|
|
18
18
|
export { createPushNoopProvider } from './push-noop.js';
|
|
19
19
|
export { createEmailNoopProvider, type EmailNoopOptions } from './email-noop.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,KAAK,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,GAClC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAIlB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EAEtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAIlB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EAEtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAe3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAyB,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAA8B,MAAM,oBAAoB,CAAC"}
|
|
@@ -15,6 +15,20 @@
|
|
|
15
15
|
* does not enforce session-window detection — the caller decides
|
|
16
16
|
* based on conversation context, the provider just forwards.
|
|
17
17
|
*
|
|
18
|
+
* Template management (`createTemplate`, `getTemplateStatus`,
|
|
19
|
+
* `updateTemplate`, `deleteTemplate`) talks to different nodes than
|
|
20
|
+
* sending does:
|
|
21
|
+
*
|
|
22
|
+
* - create / read / delete → `{wabaId}/message_templates`, so they need
|
|
23
|
+
* the WhatsApp Business Account ID (WABA ID), which is separate from
|
|
24
|
+
* the Phone Number ID used for sending.
|
|
25
|
+
* - update → `{templateId}` directly, so it needs no WABA ID.
|
|
26
|
+
*
|
|
27
|
+
* Meta's edit and delete endpoints answer `{ "success": true }` instead
|
|
28
|
+
* of echoing the template, and both re-trigger template review, so the
|
|
29
|
+
* resulting status has to be polled via `getTemplateStatus` rather than
|
|
30
|
+
* read from the write response.
|
|
31
|
+
*
|
|
18
32
|
* The Meta access token is stored in Secrets Manager. The dispatcher
|
|
19
33
|
* fetches it once per cold start and caches it across sends.
|
|
20
34
|
*/
|
|
@@ -23,6 +37,15 @@ import { type NotifyProvider } from './types.js';
|
|
|
23
37
|
export interface MetaWhatsAppProviderConfig {
|
|
24
38
|
/** Meta Phone Number ID (assigned in Meta Business Suite). */
|
|
25
39
|
phoneNumberId: string;
|
|
40
|
+
/**
|
|
41
|
+
* WhatsApp Business Account ID (WABA ID). Required by
|
|
42
|
+
* `createTemplate`, `getTemplateStatus` and `deleteTemplate` — they
|
|
43
|
+
* address the WABA's `message_templates` edge. Found in Meta Business
|
|
44
|
+
* Suite → Business Settings → WhatsApp Accounts. Optional: send-only
|
|
45
|
+
* setups never need it, and `updateTemplate` addresses the template
|
|
46
|
+
* node directly.
|
|
47
|
+
*/
|
|
48
|
+
wabaId?: string;
|
|
26
49
|
/** Graph API version, default `'v21.0'`. */
|
|
27
50
|
apiVersion?: string;
|
|
28
51
|
/**
|
|
@@ -39,10 +62,218 @@ export interface MetaWhatsAppProviderConfig {
|
|
|
39
62
|
*/
|
|
40
63
|
fetch?: typeof fetch;
|
|
41
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Template category accepted by Meta on create. Closed union — we
|
|
67
|
+
* control what we send, so anything outside it is a bug on our side.
|
|
68
|
+
*/
|
|
69
|
+
export type WhatsAppTemplateCategory = 'MARKETING' | 'UTILITY' | 'AUTHENTICATION';
|
|
70
|
+
/**
|
|
71
|
+
* Category as *reported* by Meta. Includes the legacy values still
|
|
72
|
+
* returned for templates created before the 2023 re-categorisation, and
|
|
73
|
+
* stays open because Meta ships new values without notice.
|
|
74
|
+
*
|
|
75
|
+
* The `(string & {})` idiom keeps autocompletion on the known literals
|
|
76
|
+
* while making it explicit that a `switch` over this type is never
|
|
77
|
+
* exhaustive — the previous closed union was cast into from `string`,
|
|
78
|
+
* which silently promised more type safety than Meta provides.
|
|
79
|
+
*/
|
|
80
|
+
export type WhatsAppTemplateCategoryReported = WhatsAppTemplateCategory | 'TRANSACTIONAL' | 'OTP' | (string & {});
|
|
81
|
+
/**
|
|
82
|
+
* Template approval status as reported by Meta. Every documented value
|
|
83
|
+
* is listed; the union stays open for the same reason as
|
|
84
|
+
* {@link WhatsAppTemplateCategoryReported}.
|
|
85
|
+
*/
|
|
86
|
+
export type WhatsAppTemplateStatus = 'APPROVED' | 'IN_APPEAL' | 'PENDING' | 'REJECTED' | 'PENDING_DELETION' | 'DELETED' | 'DISABLED' | 'PAUSED' | 'LIMIT_EXCEEDED' | (string & {});
|
|
87
|
+
/**
|
|
88
|
+
* Why Meta rejected a template. Only meaningful when `status` is
|
|
89
|
+
* `'REJECTED'` — Meta reports `'NONE'` otherwise. Open union, see
|
|
90
|
+
* {@link WhatsAppTemplateStatus}.
|
|
91
|
+
*/
|
|
92
|
+
export type WhatsAppTemplateRejectedReason = 'NONE' | 'ABUSIVE_CONTENT' | 'INVALID_FORMAT' | 'PROMOTIONAL' | 'SCAM' | 'TAG_CONTENT_MISMATCH' | (string & {});
|
|
93
|
+
/** A single component in a template (BODY, HEADER, FOOTER, BUTTONS). */
|
|
94
|
+
export interface WhatsAppTemplateComponent {
|
|
95
|
+
/** Component type: `BODY`, `HEADER`, `FOOTER`, `BUTTONS`. */
|
|
96
|
+
type: string;
|
|
97
|
+
/** Text content (required for BODY, FOOTER; used for HEADER when format is TEXT). */
|
|
98
|
+
text?: string;
|
|
99
|
+
/** Header format: `TEXT`, `IMAGE`, `VIDEO`, `DOCUMENT`. Only for HEADER. */
|
|
100
|
+
format?: string;
|
|
101
|
+
/** Button definitions. Only for BUTTONS. */
|
|
102
|
+
buttons?: Array<{
|
|
103
|
+
type: string;
|
|
104
|
+
text: string;
|
|
105
|
+
url?: string;
|
|
106
|
+
phone_number?: string;
|
|
107
|
+
}>;
|
|
108
|
+
/** Example values for variables in BODY/HEADER text. */
|
|
109
|
+
example?: {
|
|
110
|
+
body_text?: string[][];
|
|
111
|
+
header_text?: string[];
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Input for {@link MetaWhatsAppProvider.createTemplate}. */
|
|
115
|
+
export interface WhatsAppTemplateInput {
|
|
116
|
+
/**
|
|
117
|
+
* Template name — lowercase letters, digits and underscores only,
|
|
118
|
+
* max 512 characters. Validated before the request so a typo fails
|
|
119
|
+
* with a readable message instead of an opaque Graph 400.
|
|
120
|
+
*/
|
|
121
|
+
name: string;
|
|
122
|
+
/** Language code (e.g. `'en_US'`, `'fr'`, `'ar'`). */
|
|
123
|
+
language: string;
|
|
124
|
+
/** Template category. */
|
|
125
|
+
category: WhatsAppTemplateCategory;
|
|
126
|
+
/** Template components (BODY, HEADER, FOOTER, BUTTONS). */
|
|
127
|
+
components: WhatsAppTemplateComponent[];
|
|
128
|
+
/**
|
|
129
|
+
* Let Meta re-categorise the template instead of rejecting it when it
|
|
130
|
+
* disagrees with `category`. Usually preferable to a rejection, but it
|
|
131
|
+
* changes what you are billed per message, so it stays opt-in. Check
|
|
132
|
+
* `category` on the result to see what Meta actually assigned.
|
|
133
|
+
*/
|
|
134
|
+
allowCategoryChange?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Whether `{{1}}`-style positional or `{{name}}`-style named variables
|
|
137
|
+
* are used in the components. Meta defaults to `'POSITIONAL'`.
|
|
138
|
+
*/
|
|
139
|
+
parameterFormat?: 'POSITIONAL' | 'NAMED';
|
|
140
|
+
}
|
|
141
|
+
/** Result of {@link MetaWhatsAppProvider.createTemplate}. */
|
|
142
|
+
export interface WhatsAppTemplateCreateResult {
|
|
143
|
+
/** Meta template ID. */
|
|
144
|
+
id: string;
|
|
145
|
+
/** Template name. */
|
|
146
|
+
name: string;
|
|
147
|
+
/** Status immediately after creation (`'PENDING'` unless auto-approved). */
|
|
148
|
+
status: WhatsAppTemplateStatus;
|
|
149
|
+
/**
|
|
150
|
+
* Category Meta assigned. Differs from the requested category when
|
|
151
|
+
* `allowCategoryChange` was set and Meta disagreed.
|
|
152
|
+
*/
|
|
153
|
+
category: WhatsAppTemplateCategoryReported;
|
|
154
|
+
}
|
|
155
|
+
/** Result of {@link MetaWhatsAppProvider.getTemplateStatus}. */
|
|
156
|
+
export interface WhatsAppTemplateStatusResult {
|
|
157
|
+
/** Meta template ID. */
|
|
158
|
+
id: string;
|
|
159
|
+
/** Template name. */
|
|
160
|
+
name: string;
|
|
161
|
+
/** Language code. */
|
|
162
|
+
language: string;
|
|
163
|
+
/** Approval status. */
|
|
164
|
+
status: WhatsAppTemplateStatus;
|
|
165
|
+
/** Template category. */
|
|
166
|
+
category: WhatsAppTemplateCategoryReported;
|
|
167
|
+
/** Components as returned by Meta. */
|
|
168
|
+
components: WhatsAppTemplateComponent[];
|
|
169
|
+
/**
|
|
170
|
+
* Rejection reason. Meta reports `'NONE'` for templates it has not
|
|
171
|
+
* rejected, and omits the field entirely on API versions that don't
|
|
172
|
+
* expose it.
|
|
173
|
+
*/
|
|
174
|
+
rejectedReason?: WhatsAppTemplateRejectedReason;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Input for {@link MetaWhatsAppProvider.updateTemplate}. At least one of
|
|
178
|
+
* `components` / `category` must be set.
|
|
179
|
+
*/
|
|
180
|
+
export interface WhatsAppTemplateUpdateInput {
|
|
181
|
+
/** Meta template ID (returned by `createTemplate` or `getTemplateStatus`). */
|
|
182
|
+
templateId: string;
|
|
183
|
+
/** Updated template components (BODY, HEADER, FOOTER, BUTTONS). */
|
|
184
|
+
components?: WhatsAppTemplateComponent[];
|
|
185
|
+
/** Updated category. */
|
|
186
|
+
category?: WhatsAppTemplateCategory;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Result of {@link MetaWhatsAppProvider.updateTemplate}.
|
|
190
|
+
*
|
|
191
|
+
* Deliberately thin: Meta's edit endpoint returns `{ "success": true }`
|
|
192
|
+
* and nothing else, so there is no status or category to report. The
|
|
193
|
+
* edit re-opens review — poll `getTemplateStatus` for the outcome.
|
|
194
|
+
*/
|
|
195
|
+
export interface WhatsAppTemplateUpdateResult {
|
|
196
|
+
/** Meta template ID that was edited (echoed from the request). */
|
|
197
|
+
id: string;
|
|
198
|
+
/** Whether Meta accepted the edit. */
|
|
199
|
+
success: boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Input for {@link MetaWhatsAppProvider.deleteTemplate}. */
|
|
202
|
+
export interface WhatsAppTemplateDeleteInput {
|
|
203
|
+
/**
|
|
204
|
+
* Template name. Required by Meta in both delete modes — deletion is
|
|
205
|
+
* keyed by name, not by id.
|
|
206
|
+
*/
|
|
207
|
+
name: string;
|
|
208
|
+
/**
|
|
209
|
+
* Meta template ID. When set, only that language variant is deleted
|
|
210
|
+
* (`hsm_id` + `name`); when omitted, every language sharing `name` is
|
|
211
|
+
* deleted.
|
|
212
|
+
*/
|
|
213
|
+
templateId?: string;
|
|
214
|
+
}
|
|
215
|
+
/** Result of {@link MetaWhatsAppProvider.deleteTemplate}. */
|
|
216
|
+
export interface WhatsAppTemplateDeleteResult {
|
|
217
|
+
/** Template name that was deleted. */
|
|
218
|
+
name: string;
|
|
219
|
+
/** Template ID, when a single language variant was targeted. */
|
|
220
|
+
templateId?: string;
|
|
221
|
+
/** Whether Meta accepted the deletion. */
|
|
222
|
+
success: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Extended provider type returned by {@link createMetaWhatsAppProvider}:
|
|
226
|
+
* a plain {@link NotifyProvider} for the dispatcher, plus Meta's
|
|
227
|
+
* template-management surface.
|
|
228
|
+
*
|
|
229
|
+
* All four template methods are always present. The three that address
|
|
230
|
+
* the WABA edge throw {@link ProviderHardError} at call time when
|
|
231
|
+
* `wabaId` was omitted from the config.
|
|
232
|
+
*
|
|
233
|
+
* None of them run under the dispatcher, so their `ProviderSendError` /
|
|
234
|
+
* `ProviderHardError` split is a hint for the caller's own retry logic:
|
|
235
|
+
* `ProviderSendError` means Meta was unreachable, rate-limited or
|
|
236
|
+
* broken, and an identical retry may succeed.
|
|
237
|
+
*/
|
|
238
|
+
export type MetaWhatsAppProvider = NotifyProvider & {
|
|
239
|
+
/**
|
|
240
|
+
* Submit a new template for review. It enters `'PENDING'` and Meta
|
|
241
|
+
* reviews it asynchronously — poll {@link getTemplateStatus}.
|
|
242
|
+
*
|
|
243
|
+
* Requires `wabaId` in the provider config.
|
|
244
|
+
*/
|
|
245
|
+
createTemplate(input: WhatsAppTemplateInput): Promise<WhatsAppTemplateCreateResult>;
|
|
246
|
+
/**
|
|
247
|
+
* Look up a template by name, walking Meta's pagination. Meta allows
|
|
248
|
+
* one template per name *per language*, so pass `language` when the
|
|
249
|
+
* name is reused across languages; otherwise the first match wins.
|
|
250
|
+
* Throws {@link ProviderHardError} when nothing matches.
|
|
251
|
+
*
|
|
252
|
+
* Requires `wabaId` in the provider config.
|
|
253
|
+
*/
|
|
254
|
+
getTemplateStatus(templateName: string, language?: string): Promise<WhatsAppTemplateStatusResult>;
|
|
255
|
+
/**
|
|
256
|
+
* Edit an existing template's components and/or category. Meta
|
|
257
|
+
* re-reviews it, so the status returns to `'PENDING'`; the response
|
|
258
|
+
* only confirms acceptance, so poll {@link getTemplateStatus} for the
|
|
259
|
+
* outcome.
|
|
260
|
+
*
|
|
261
|
+
* Addresses the template node directly — needs no `wabaId`.
|
|
262
|
+
*/
|
|
263
|
+
updateTemplate(input: WhatsAppTemplateUpdateInput): Promise<WhatsAppTemplateUpdateResult>;
|
|
264
|
+
/**
|
|
265
|
+
* Delete a template by name (every language) or by name + id (one
|
|
266
|
+
* language). The template enters `'PENDING_DELETION'` before Meta
|
|
267
|
+
* removes it for good.
|
|
268
|
+
*
|
|
269
|
+
* Requires `wabaId` in the provider config.
|
|
270
|
+
*/
|
|
271
|
+
deleteTemplate(input: WhatsAppTemplateDeleteInput): Promise<WhatsAppTemplateDeleteResult>;
|
|
272
|
+
};
|
|
42
273
|
/**
|
|
43
274
|
* Create the Meta WhatsApp Cloud API provider.
|
|
44
275
|
*/
|
|
45
|
-
export declare function createMetaWhatsAppProvider(config: MetaWhatsAppProviderConfig):
|
|
276
|
+
export declare function createMetaWhatsAppProvider(config: MetaWhatsAppProviderConfig): MetaWhatsAppProvider;
|
|
46
277
|
/**
|
|
47
278
|
* Build a token resolver that reads from AWS Secrets Manager.
|
|
48
279
|
* Memoizes the secret value per cold start.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-meta.d.ts","sourceRoot":"","sources":["../../src/providers/whatsapp-meta.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"whatsapp-meta.d.ts","sourceRoot":"","sources":["../../src/providers/whatsapp-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAGL,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AAEpB,mEAAmE;AACnE,MAAM,WAAW,0BAA0B;IACzC,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAID;;;GAGG;AACH,MAA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;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,6DAA6D;AAC7D,MAAM,WAAW,4BAA4B;IAC3C,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD;;;;;OAKG;IACH,cAAc,CACZ,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,iBAAiB,CACf,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,cAAc,CACZ,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,cAAc,CACZ,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,4BAA4B,CAAC,CAAC;CAC1C,CAAC;AA0DF;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,0BAA0B,GACjC,oBAAoB,CAuVtB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CA2CxB"}
|
|
@@ -15,10 +15,48 @@
|
|
|
15
15
|
* does not enforce session-window detection — the caller decides
|
|
16
16
|
* based on conversation context, the provider just forwards.
|
|
17
17
|
*
|
|
18
|
+
* Template management (`createTemplate`, `getTemplateStatus`,
|
|
19
|
+
* `updateTemplate`, `deleteTemplate`) talks to different nodes than
|
|
20
|
+
* sending does:
|
|
21
|
+
*
|
|
22
|
+
* - create / read / delete → `{wabaId}/message_templates`, so they need
|
|
23
|
+
* the WhatsApp Business Account ID (WABA ID), which is separate from
|
|
24
|
+
* the Phone Number ID used for sending.
|
|
25
|
+
* - update → `{templateId}` directly, so it needs no WABA ID.
|
|
26
|
+
*
|
|
27
|
+
* Meta's edit and delete endpoints answer `{ "success": true }` instead
|
|
28
|
+
* of echoing the template, and both re-trigger template review, so the
|
|
29
|
+
* resulting status has to be polled via `getTemplateStatus` rather than
|
|
30
|
+
* read from the write response.
|
|
31
|
+
*
|
|
18
32
|
* The Meta access token is stored in Secrets Manager. The dispatcher
|
|
19
33
|
* fetches it once per cold start and caches it across sends.
|
|
20
34
|
*/
|
|
21
35
|
import { ProviderHardError, ProviderSendError, } from './types.js';
|
|
36
|
+
/** Meta's naming rule for templates, checked before spending a round-trip. */
|
|
37
|
+
const TEMPLATE_NAME_PATTERN = /^[a-z0-9_]{1,512}$/;
|
|
38
|
+
/**
|
|
39
|
+
* Fields requested when reading templates. `rejected_reason` is *not*
|
|
40
|
+
* part of Meta's default field set — without an explicit `fields` query
|
|
41
|
+
* it is silently absent from the response.
|
|
42
|
+
*/
|
|
43
|
+
const TEMPLATE_READ_FIELDS = 'id,name,language,status,category,components,rejected_reason';
|
|
44
|
+
/** Page size for template reads. Meta defaults to 25, which is too small. */
|
|
45
|
+
const TEMPLATE_PAGE_SIZE = 100;
|
|
46
|
+
/**
|
|
47
|
+
* Safety valve for the pagination loop. One name can exist in every
|
|
48
|
+
* language Meta supports, so a single page is not enough — but we also
|
|
49
|
+
* refuse to walk an unbounded cursor chain.
|
|
50
|
+
*/
|
|
51
|
+
const TEMPLATE_MAX_PAGES = 10;
|
|
52
|
+
/**
|
|
53
|
+
* Graph API failures worth retrying: request timeout, rate limit and
|
|
54
|
+
* server-side errors. Anything else means the request itself is wrong,
|
|
55
|
+
* so an identical retry would fail identically.
|
|
56
|
+
*/
|
|
57
|
+
function isTransientStatus(status) {
|
|
58
|
+
return status === 408 || status === 429 || status >= 500;
|
|
59
|
+
}
|
|
22
60
|
/**
|
|
23
61
|
* Create the Meta WhatsApp Cloud API provider.
|
|
24
62
|
*/
|
|
@@ -35,6 +73,62 @@ export function createMetaWhatsAppProvider(config) {
|
|
|
35
73
|
}
|
|
36
74
|
return cachedToken;
|
|
37
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Template endpoints on the WABA edge need the account id. Fail with a
|
|
78
|
+
* configuration error naming the missing setting instead of letting
|
|
79
|
+
* Meta answer with an opaque 404 on `undefined/message_templates`.
|
|
80
|
+
*/
|
|
81
|
+
function requireWabaId(op) {
|
|
82
|
+
if (!config.wabaId) {
|
|
83
|
+
throw new ProviderHardError(`Meta WhatsApp ${op}: wabaId is not configured. Set it in ` +
|
|
84
|
+
'MetaWhatsAppProviderConfig (VENTURE_NOTIFY_WHATSAPP_WABA_ID, from ' +
|
|
85
|
+
"the notify intent's `whatsapp.wabaId`) to use template " +
|
|
86
|
+
'management APIs.');
|
|
87
|
+
}
|
|
88
|
+
return config.wabaId;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* One Graph API round-trip: auth header, network-error handling, status
|
|
92
|
+
* classification, JSON parsing. Everything below goes through here so
|
|
93
|
+
* the five endpoints cannot drift apart in how they report failures.
|
|
94
|
+
*
|
|
95
|
+
* `isTransient` decides whether a failing status surfaces as
|
|
96
|
+
* {@link ProviderSendError} (worth retrying) or
|
|
97
|
+
* {@link ProviderHardError} (permanent). Network-level failures are
|
|
98
|
+
* always transient. `send` overrides it to keep the message-specific
|
|
99
|
+
* classification it has always used.
|
|
100
|
+
*/
|
|
101
|
+
async function graphRequest(opts) {
|
|
102
|
+
const { op, method, url, body, isTransient = isTransientStatus } = opts;
|
|
103
|
+
const hasBody = body !== undefined;
|
|
104
|
+
// Resolved outside the try on purpose: a failure here is a missing
|
|
105
|
+
// secret or a denied IAM policy, which the catch below would
|
|
106
|
+
// mislabel as a transient network error and retry forever.
|
|
107
|
+
const token = await getToken();
|
|
108
|
+
let response;
|
|
109
|
+
try {
|
|
110
|
+
response = await fetchImpl(url, {
|
|
111
|
+
method,
|
|
112
|
+
headers: {
|
|
113
|
+
Authorization: `Bearer ${token}`,
|
|
114
|
+
...(hasBody ? { 'Content-Type': 'application/json' } : {}),
|
|
115
|
+
},
|
|
116
|
+
...(hasBody ? { body: JSON.stringify(body) } : {}),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
// Network-level failure (DNS, connection reset, …) — transient.
|
|
121
|
+
throw new ProviderSendError(`Meta WhatsApp ${op} failed (network error)`, err);
|
|
122
|
+
}
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
const text = await response.text().catch(() => '');
|
|
125
|
+
const message = `Meta WhatsApp ${op} failed (${response.status}): ${text.slice(0, 500)}`;
|
|
126
|
+
throw isTransient(response.status)
|
|
127
|
+
? new ProviderSendError(message)
|
|
128
|
+
: new ProviderHardError(message);
|
|
129
|
+
}
|
|
130
|
+
return (await response.json().catch(() => ({})));
|
|
131
|
+
}
|
|
38
132
|
return {
|
|
39
133
|
channel: 'whatsapp',
|
|
40
134
|
name: 'meta-cloud',
|
|
@@ -66,24 +160,11 @@ export function createMetaWhatsAppProvider(config) {
|
|
|
66
160
|
text: { body: message.text, preview_url: false },
|
|
67
161
|
biz_opaque_callback_data: notificationId,
|
|
68
162
|
};
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
headers: {
|
|
75
|
-
Authorization: `Bearer ${await getToken()}`,
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify(body),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
// Network-level failure (DNS, connection reset, …) — transient.
|
|
83
|
-
throw new ProviderSendError(`Meta WhatsApp send failed (network error)`, err);
|
|
84
|
-
}
|
|
85
|
-
if (!response.ok) {
|
|
86
|
-
const text = await response.text().catch(() => '');
|
|
163
|
+
const json = await graphRequest({
|
|
164
|
+
op: 'send',
|
|
165
|
+
method: 'POST',
|
|
166
|
+
url: `https://graph.facebook.com/${apiVersion}/${config.phoneNumberId}/messages`,
|
|
167
|
+
body,
|
|
87
168
|
// Graph API returns structured errors:
|
|
88
169
|
// { error: { code, message, type, error_subcode } }
|
|
89
170
|
// Hard-fail on:
|
|
@@ -91,18 +172,9 @@ export function createMetaWhatsAppProvider(config) {
|
|
|
91
172
|
// not on WA, etc.)
|
|
92
173
|
// - 401 / 403 (auth / permission)
|
|
93
174
|
// - 404 (bad phone number id)
|
|
94
|
-
// Retry on 429 + 5xx.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
response.status === 403 ||
|
|
98
|
-
response.status === 404;
|
|
99
|
-
const message = `Meta WhatsApp send failed (${response.status}): ${text.slice(0, 500)}`;
|
|
100
|
-
if (hard) {
|
|
101
|
-
throw new ProviderHardError(message);
|
|
102
|
-
}
|
|
103
|
-
throw new ProviderSendError(message);
|
|
104
|
-
}
|
|
105
|
-
const json = (await response.json().catch(() => ({})));
|
|
175
|
+
// Retry on everything else (429 + 5xx in practice).
|
|
176
|
+
isTransient: (status) => status !== 400 && status !== 401 && status !== 403 && status !== 404,
|
|
177
|
+
});
|
|
106
178
|
const wamid = json.messages?.[0]?.id;
|
|
107
179
|
if (!wamid) {
|
|
108
180
|
// Treat missing wamid as transient — Meta has occasionally
|
|
@@ -117,6 +189,146 @@ export function createMetaWhatsAppProvider(config) {
|
|
|
117
189
|
channel: 'whatsapp',
|
|
118
190
|
};
|
|
119
191
|
},
|
|
192
|
+
async createTemplate(input) {
|
|
193
|
+
const wabaId = requireWabaId('createTemplate');
|
|
194
|
+
// Meta enforces this server-side with a generic 400; checking here
|
|
195
|
+
// turns the most common mistake into an actionable message.
|
|
196
|
+
if (!TEMPLATE_NAME_PATTERN.test(input.name)) {
|
|
197
|
+
throw new ProviderHardError(`Meta WhatsApp createTemplate: invalid template name '${input.name}'. ` +
|
|
198
|
+
'Meta accepts lowercase letters, digits and underscores only ' +
|
|
199
|
+
'(1-512 characters).');
|
|
200
|
+
}
|
|
201
|
+
const body = {
|
|
202
|
+
name: input.name,
|
|
203
|
+
language: input.language,
|
|
204
|
+
category: input.category,
|
|
205
|
+
components: input.components,
|
|
206
|
+
};
|
|
207
|
+
if (input.allowCategoryChange !== undefined) {
|
|
208
|
+
body.allow_category_change = input.allowCategoryChange;
|
|
209
|
+
}
|
|
210
|
+
if (input.parameterFormat) {
|
|
211
|
+
body.parameter_format = input.parameterFormat;
|
|
212
|
+
}
|
|
213
|
+
const json = await graphRequest({
|
|
214
|
+
op: 'createTemplate',
|
|
215
|
+
method: 'POST',
|
|
216
|
+
url: `https://graph.facebook.com/${apiVersion}/${wabaId}/message_templates`,
|
|
217
|
+
body,
|
|
218
|
+
});
|
|
219
|
+
if (!json.id) {
|
|
220
|
+
throw new ProviderHardError('Meta WhatsApp createTemplate: response missing template id');
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
id: json.id,
|
|
224
|
+
// Meta's create response omits `name` and may omit `status`.
|
|
225
|
+
// Falling back to the request echoes our own input rather than
|
|
226
|
+
// inventing provider state — unlike a read, we know what we sent,
|
|
227
|
+
// and Meta documents `PENDING` as the post-create status.
|
|
228
|
+
name: json.name ?? input.name,
|
|
229
|
+
status: json.status ?? 'PENDING',
|
|
230
|
+
category: json.category ?? input.category,
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
async getTemplateStatus(templateName, language) {
|
|
234
|
+
const wabaId = requireWabaId('getTemplateStatus');
|
|
235
|
+
// Meta's `?name=` filter is a partial match, so the exact name is
|
|
236
|
+
// re-checked here (querying "foo" also returns "foo1"), and the
|
|
237
|
+
// same name may exist once per language — hence the optional
|
|
238
|
+
// language narrowing.
|
|
239
|
+
const matches = (t) => t.name === templateName && (!language || t.language === language);
|
|
240
|
+
let nextUrl = `https://graph.facebook.com/${apiVersion}/${wabaId}/message_templates` +
|
|
241
|
+
`?name=${encodeURIComponent(templateName)}` +
|
|
242
|
+
`&fields=${TEMPLATE_READ_FIELDS}` +
|
|
243
|
+
`&limit=${TEMPLATE_PAGE_SIZE}`;
|
|
244
|
+
for (let page = 0; page < TEMPLATE_MAX_PAGES; page += 1) {
|
|
245
|
+
const url = nextUrl;
|
|
246
|
+
if (!url)
|
|
247
|
+
break;
|
|
248
|
+
const json = await graphRequest({
|
|
249
|
+
op: 'getTemplateStatus',
|
|
250
|
+
method: 'GET',
|
|
251
|
+
url,
|
|
252
|
+
});
|
|
253
|
+
const match = json.data?.find(matches);
|
|
254
|
+
if (match) {
|
|
255
|
+
// We asked for these fields explicitly, so a gap means Meta
|
|
256
|
+
// changed the contract. Surface that instead of defaulting to
|
|
257
|
+
// a plausible-looking status/category the caller would trust.
|
|
258
|
+
if (!match.id ||
|
|
259
|
+
!match.language ||
|
|
260
|
+
!match.status ||
|
|
261
|
+
!match.category) {
|
|
262
|
+
throw new ProviderHardError(`Meta WhatsApp getTemplateStatus: template '${templateName}' ` +
|
|
263
|
+
'is missing id/language/status/category in the Graph response');
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
id: match.id,
|
|
267
|
+
name: templateName,
|
|
268
|
+
language: match.language,
|
|
269
|
+
status: match.status,
|
|
270
|
+
category: match.category,
|
|
271
|
+
components: match.components ?? [],
|
|
272
|
+
rejectedReason: match.rejected_reason,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
nextUrl = json.paging?.next;
|
|
276
|
+
}
|
|
277
|
+
throw new ProviderHardError(`Meta WhatsApp getTemplateStatus: template '${templateName}'` +
|
|
278
|
+
(language ? ` (language: ${language})` : '') +
|
|
279
|
+
' not found' +
|
|
280
|
+
(nextUrl
|
|
281
|
+
? ` in the first ${TEMPLATE_MAX_PAGES * TEMPLATE_PAGE_SIZE} results`
|
|
282
|
+
: ''));
|
|
283
|
+
},
|
|
284
|
+
async updateTemplate(input) {
|
|
285
|
+
const body = {};
|
|
286
|
+
if (input.components)
|
|
287
|
+
body.components = input.components;
|
|
288
|
+
if (input.category)
|
|
289
|
+
body.category = input.category;
|
|
290
|
+
if (Object.keys(body).length === 0) {
|
|
291
|
+
throw new ProviderHardError('Meta WhatsApp updateTemplate: nothing to update — pass ' +
|
|
292
|
+
'`components`, `category`, or both.');
|
|
293
|
+
}
|
|
294
|
+
// Edits address the template node directly, so no WABA id is
|
|
295
|
+
// needed. The response is `{ "success": true }` — Meta does not
|
|
296
|
+
// echo the template, which is why there is no status to read back.
|
|
297
|
+
const json = await graphRequest({
|
|
298
|
+
op: 'updateTemplate',
|
|
299
|
+
method: 'POST',
|
|
300
|
+
url: `https://graph.facebook.com/${apiVersion}/${input.templateId}`,
|
|
301
|
+
body,
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
id: input.templateId,
|
|
305
|
+
// A non-2xx already threw, so getting here means Meta accepted the
|
|
306
|
+
// edit; the flag is echoed when present.
|
|
307
|
+
success: json.success ?? true,
|
|
308
|
+
};
|
|
309
|
+
},
|
|
310
|
+
async deleteTemplate(input) {
|
|
311
|
+
const wabaId = requireWabaId('deleteTemplate');
|
|
312
|
+
// Deletion lives on the WABA edge and is keyed by name. `hsm_id`
|
|
313
|
+
// narrows it to a single language variant, but Meta still requires
|
|
314
|
+
// `name` alongside it.
|
|
315
|
+
const url = `https://graph.facebook.com/${apiVersion}/${wabaId}/message_templates` +
|
|
316
|
+
`?name=${encodeURIComponent(input.name)}` +
|
|
317
|
+
(input.templateId
|
|
318
|
+
? `&hsm_id=${encodeURIComponent(input.templateId)}`
|
|
319
|
+
: '');
|
|
320
|
+
const json = await graphRequest({
|
|
321
|
+
op: 'deleteTemplate',
|
|
322
|
+
method: 'DELETE',
|
|
323
|
+
url,
|
|
324
|
+
});
|
|
325
|
+
return {
|
|
326
|
+
name: input.name,
|
|
327
|
+
templateId: input.templateId,
|
|
328
|
+
// As with updateTemplate: a non-2xx already threw.
|
|
329
|
+
success: json.success ?? true,
|
|
330
|
+
};
|
|
331
|
+
},
|
|
120
332
|
};
|
|
121
333
|
}
|
|
122
334
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-meta.js","sourceRoot":"","sources":["../../src/providers/whatsapp-meta.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"whatsapp-meta.js","sourceRoot":"","sources":["../../src/providers/whatsapp-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAIlB,MAAM,YAAY,CAAC;AAgSpB,8EAA8E;AAC9E,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,oBAAoB,GACxB,6DAA6D,CAAC;AAEhE,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AA4B9B;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,MAAc;IACvC,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAkC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC;IAChD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IACxC,IAAI,WAAW,GAAkB,IAAI,CAAC;IAEtC,KAAK,UAAU,QAAQ;QACrB,IAAI,WAAW;YAAE,OAAO,WAAW,CAAC;QACpC,WAAW,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;QAC3C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,iBAAiB,CACzB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,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/notify",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Transactional notifications for VentureKit — email (SES), WhatsApp (Meta Cloud), with a Postgres outbox + cron dispatcher.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,32 +29,32 @@
|
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./dispatcher": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"types": "./dist/dispatcher.d.ts",
|
|
37
|
+
"import": "./dist/dispatcher.js"
|
|
38
38
|
},
|
|
39
39
|
"./bounce-handler": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"types": "./dist/bounce-handler.d.ts",
|
|
41
|
+
"import": "./dist/bounce-handler.js"
|
|
42
42
|
},
|
|
43
43
|
"./admin": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
44
|
+
"types": "./dist/admin/index.d.ts",
|
|
45
|
+
"import": "./dist/admin/index.js"
|
|
46
46
|
},
|
|
47
47
|
"./providers/email-ses": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"types": "./dist/providers/email-ses.d.ts",
|
|
49
|
+
"import": "./dist/providers/email-ses.js"
|
|
50
50
|
},
|
|
51
51
|
"./providers/whatsapp-meta": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"types": "./dist/providers/whatsapp-meta.d.ts",
|
|
53
|
+
"import": "./dist/providers/whatsapp-meta.js"
|
|
54
54
|
},
|
|
55
55
|
"./store/postgres": {
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"types": "./dist/store/postgres.d.ts",
|
|
57
|
+
"import": "./dist/store/postgres.js"
|
|
58
58
|
},
|
|
59
59
|
"./migrations": {
|
|
60
60
|
"default": "./src/migrations"
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"outbox"
|
|
77
77
|
],
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@venturekit/core": "0.0.
|
|
79
|
+
"@venturekit/core": "0.0.15"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@venturekit/data": "0.0.
|
|
83
|
-
"@venturekit/runtime": "0.0.
|
|
84
|
-
"@aws-sdk/client-sesv2": "^3.
|
|
85
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
82
|
+
"@venturekit/data": "0.0.15",
|
|
83
|
+
"@venturekit/runtime": "0.0.15",
|
|
84
|
+
"@aws-sdk/client-sesv2": "^3.1091.0",
|
|
85
|
+
"@aws-sdk/client-secrets-manager": "^3.1091.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
88
88
|
"@venturekit/data": {
|
|
@@ -99,14 +99,14 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@venturekit/data": "0.0.
|
|
103
|
-
"@venturekit/runtime": "0.0.
|
|
104
|
-
"@aws-sdk/client-sesv2": "^3.
|
|
105
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
102
|
+
"@venturekit/data": "0.0.15",
|
|
103
|
+
"@venturekit/runtime": "0.0.15",
|
|
104
|
+
"@aws-sdk/client-sesv2": "^3.1091.0",
|
|
105
|
+
"@aws-sdk/client-secrets-manager": "^3.1091.0",
|
|
106
106
|
"@types/aws-lambda": "^8.10.131",
|
|
107
107
|
"@types/node": "^26.1.0",
|
|
108
108
|
"typescript": "^5.3.0",
|
|
109
|
-
"vitest": "^4.1.
|
|
109
|
+
"vitest": "^4.1.10"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "tsc && node -e \"require('fs').cpSync('src/migrations','dist/migrations',{recursive:true})\"",
|