platform-types 1.10.761 → 1.10.763

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.
@@ -1,70 +0,0 @@
1
- "use strict";
2
- /**
3
- * Published WhatsApp surface — the tenant-facing connection config and the
4
- * tenant's own template send (`POST /whatsapp/send`).
5
- *
6
- * ⚠️ **Meta's inbound webhook payload is NOT here and must not come back.**
7
- * The twelve shapes Meta POSTs to `/whatsapp` — the entry/change/value
8
- * envelope, the contact, message, document, audio, image, status, error,
9
- * conversation and pricing leaves — live in
10
- * `./internal/whatsappWebhook.ts`, prefixed `WhatsAppWebhook*` and excluded
11
- * from the published build. They are inbound (the provider answering us), so
12
- * they fail `./internal/README.md`'s own test for what may be published, and
13
- * their bare names MERGED with globals in every consumer: a published
14
- * `interface Document` made `document.filename` compile and type as `string`
15
- * against `lib.dom`'s `Document`, returning `undefined` at runtime.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.WHATSAPP_SEND_ERROR_CODES = void 0;
19
- /**
20
- * `POST /whatsapp/send` refusals, beyond the cross-cutting `GATING_ERROR_CODES`
21
- * (notably `PLAN_LIMIT_EXCEEDED` for the `whatsappMessages` monthly cap).
22
- *
23
- * - `VALIDATION_FAILED` · 400 — including a body naming both or neither of
24
- * `to` / `customerId`.
25
- * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — no `Idempotency-Key` header. The
26
- * idempotency wrapper's own codes (`INVALID_IDEMPOTENCY_KEY`,
27
- * `IDEMPOTENCY_KEY_REUSE`, `IDEMPOTENCY_IN_PROGRESS`, `IDEMPOTENCY_KEY_FAILED`,
28
- * `IDEMPOTENCY_LOCK_CONTENTION`) apply too. `IDEMPOTENCY_KEY_FAILED` (409)
29
- * means an earlier attempt under this key may have reached Meta: check the
30
- * recipient's chat before sending again under a NEW key.
31
- * - `PLATFORM_INTEGRATION_DISABLED` · 503 — WhatsApp is switched off
32
- * platform-wide by SINFACTURA.
33
- * - `WHATSAPP_NOT_CONNECTED` · 409 — the calling store has no connected
34
- * WhatsApp, or a connection with no stored token after a disconnect. Disable
35
- * the send control. ⚠️ Never falls back to the platform number.
36
- * - `WHATSAPP_TOKEN_REJECTED` · 409 — connected, but Meta refused the stored
37
- * token. Reconnect.
38
- * - `CUSTOMER_NOT_FOUND` · 404 / `WHATSAPP_RECIPIENT_PHONE_MISSING` · 400 — a bad
39
- * id versus a real customer with no usable number.
40
- * - `WHATSAPP_RECIPIENT_NOT_ALLOWED` · 403 — non-production stages only: the
41
- * number is not on that stage's test allowlist. Nothing was sent.
42
- * - `WHATSAPP_TEMPLATE_NOT_APPROVED` · 422 — not approved, paused, disabled,
43
- * wrong language or wrong parameter count (Meta does not tell these apart).
44
- * - `WHATSAPP_RECIPIENT_OPTED_OUT` · 409 — the recipient cannot receive it.
45
- * - `WHATSAPP_RATE_LIMITED` · 429 — throughput cap; retry later.
46
- * - `WHATSAPP_ACCOUNT_SUSPENDED` · 403 — the WhatsApp Business account or the
47
- * number itself is restricted.
48
- * - `WHATSAPP_SEND_FAILED` · 502 — any other Meta 4xx refusal; carries `metaCode`.
49
- * - `WHATSAPP_SEND_UNCONFIRMED` · 502 — the request reached Meta and its outcome
50
- * is unknown: no answer came back, Meta answered 5xx, or Meta accepted it
51
- * without a message id.
52
- * The message may have been delivered, so the key is sealed:
53
- * a retry under it answers `IDEMPOTENCY_KEY_FAILED` rather than re-sending.
54
- */
55
- exports.WHATSAPP_SEND_ERROR_CODES = [
56
- 'VALIDATION_FAILED',
57
- 'IDEMPOTENCY_KEY_REQUIRED',
58
- 'PLATFORM_INTEGRATION_DISABLED',
59
- 'WHATSAPP_NOT_CONNECTED',
60
- 'WHATSAPP_TOKEN_REJECTED',
61
- 'CUSTOMER_NOT_FOUND',
62
- 'WHATSAPP_RECIPIENT_PHONE_MISSING',
63
- 'WHATSAPP_RECIPIENT_NOT_ALLOWED',
64
- 'WHATSAPP_TEMPLATE_NOT_APPROVED',
65
- 'WHATSAPP_RECIPIENT_OPTED_OUT',
66
- 'WHATSAPP_RATE_LIMITED',
67
- 'WHATSAPP_ACCOUNT_SUSPENDED',
68
- 'WHATSAPP_SEND_FAILED',
69
- 'WHATSAPP_SEND_UNCONFIRMED',
70
- ];
@@ -1,148 +0,0 @@
1
- /**
2
- * Published WhatsApp surface — the tenant-facing connection config and the
3
- * tenant's own template send (`POST /whatsapp/send`).
4
- *
5
- * ⚠️ **Meta's inbound webhook payload is NOT here and must not come back.**
6
- * The twelve shapes Meta POSTs to `/whatsapp` — the entry/change/value
7
- * envelope, the contact, message, document, audio, image, status, error,
8
- * conversation and pricing leaves — live in
9
- * `./internal/whatsappWebhook.ts`, prefixed `WhatsAppWebhook*` and excluded
10
- * from the published build. They are inbound (the provider answering us), so
11
- * they fail `./internal/README.md`'s own test for what may be published, and
12
- * their bare names MERGED with globals in every consumer: a published
13
- * `interface Document` made `document.filename` compile and type as `string`
14
- * against `lib.dom`'s `Document`, returning `undefined` at runtime.
15
- */
16
- declare global {
17
- /**
18
- * Per-tenant WhatsApp Business connection + plan tier.
19
- *
20
- * ⚠️ **Treat every member as potentially absent on a real row.** Rows
21
- * predate the connect flow that populates this block, and writes here are
22
- * forward-only — an older tenant keeps its original shape rather than being
23
- * backfilled. This is a property of the stored data, not a statement about
24
- * which release shipped the writer, so it does not go stale.
25
- *
26
- * ⚠️ The Meta access token is deliberately absent. It is written by the
27
- * per-tenant OAuth callback and stripped by `sanitizeStoreRow` at every
28
- * STORE-row wire boundary, so a consumer never receives it;
29
- * `WhatsAppConfigRow` (api-internal, unpublished) is what the api's own
30
- * senders read. Declaring it here described a field that never arrives.
31
- */
32
- interface WhatsAppConfig {
33
- wabaId: string;
34
- phoneNumberId: string;
35
- verifiedName: string;
36
- /**
37
- * Meta's quality signal for the number.
38
- *
39
- * ⚠️ `'UNKNOWN'` is a real Meta value, not a placeholder — it is what a
40
- * number with no traffic yet reports, so every freshly connected tenant
41
- * starts here. Render it as "no data", never fold it into `'GREEN'`:
42
- * coercing it makes a brand-new number indistinguishable from a
43
- * healthy one, and the coercion is invisible at the read site.
44
- */
45
- qualityRating: 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
46
- status: 'connected' | 'disconnected' | 'suspended';
47
- tier: 'free' | 'pro' | 'enterprise';
48
- /** ISO timestamp. */
49
- connectedAt: string;
50
- /** ISO timestamp. */
51
- disconnectedAt?: string;
52
- }
53
- /**
54
- * Request body for `POST /whatsapp/send` — the TENANT's own template send,
55
- * under `adminToken`, from the calling store's own connected number.
56
- *
57
- * ⚠️ The request must carry an `Idempotency-Key` header — without one it is
58
- * refused `400 IDEMPOTENCY_KEY_REQUIRED`. Meta is called before anything is
59
- * written, so a retried request with no key would send the message twice.
60
- *
61
- * ⚠️ There is no `storeId` member and there must never be one. The sending
62
- * store is the authorizer's; a body-supplied one is the shape that would let
63
- * a tenant address another tenant's number.
64
- *
65
- * ⚠️ Template only. Outside Meta's 24-hour customer-service window a free-form
66
- * message is refused, and every case this serves (invoice reminder, payment
67
- * link, order confirmation) is outside it — so there is no free-text member.
68
- *
69
- * Exactly one of `to` / `customerId` is required.
70
- */
71
- interface WhatsAppSendRequest {
72
- /** Meta-approved template NAME, as registered against the store's own WhatsApp Business account. */
73
- template: string;
74
- /**
75
- * Language code of the approved translation. Defaults to `'es'`.
76
- *
77
- * ⚠️ Meta matches a template by (name, language) PAIR — an approved template
78
- * requested in the wrong language is refused exactly like one that was never
79
- * approved (`WHATSAPP_TEMPLATE_NOT_APPROVED`).
80
- */
81
- languageCode?: string;
82
- /**
83
- * BODY placeholders, in `{{1}}`, `{{2}}`, … order.
84
- *
85
- * ⚠️ ORDER IS THE BINDING — Meta positions them, so an amount where a due
86
- * date belongs is accepted, delivered and wrong.
87
- */
88
- parameters?: string[];
89
- /** Recipient, digits with country code (`5491150123456`). Mutually exclusive with `customerId`. */
90
- to?: string;
91
- /** Recipient by id, resolved against the CALLING store's own customers. */
92
- customerId?: string;
93
- /** Display name for the message-log row only; never sent to Meta. */
94
- name?: string;
95
- }
96
- /**
97
- * `data` of a successful `POST /whatsapp/send`.
98
- *
99
- * (Named for the template send, not `WhatsAppSendResult`: that name belongs
100
- * to the api-internal send seam and has a different shape.)
101
- */
102
- interface WhatsAppTemplateSendResult {
103
- /** Meta's message id — the handle every later delivery-status webhook carries. */
104
- messageId: string;
105
- template: string;
106
- /** ms epoch of the accepted send. */
107
- sentAt: number;
108
- }
109
- }
110
- /**
111
- * `POST /whatsapp/send` refusals, beyond the cross-cutting `GATING_ERROR_CODES`
112
- * (notably `PLAN_LIMIT_EXCEEDED` for the `whatsappMessages` monthly cap).
113
- *
114
- * - `VALIDATION_FAILED` · 400 — including a body naming both or neither of
115
- * `to` / `customerId`.
116
- * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — no `Idempotency-Key` header. The
117
- * idempotency wrapper's own codes (`INVALID_IDEMPOTENCY_KEY`,
118
- * `IDEMPOTENCY_KEY_REUSE`, `IDEMPOTENCY_IN_PROGRESS`, `IDEMPOTENCY_KEY_FAILED`,
119
- * `IDEMPOTENCY_LOCK_CONTENTION`) apply too. `IDEMPOTENCY_KEY_FAILED` (409)
120
- * means an earlier attempt under this key may have reached Meta: check the
121
- * recipient's chat before sending again under a NEW key.
122
- * - `PLATFORM_INTEGRATION_DISABLED` · 503 — WhatsApp is switched off
123
- * platform-wide by SINFACTURA.
124
- * - `WHATSAPP_NOT_CONNECTED` · 409 — the calling store has no connected
125
- * WhatsApp, or a connection with no stored token after a disconnect. Disable
126
- * the send control. ⚠️ Never falls back to the platform number.
127
- * - `WHATSAPP_TOKEN_REJECTED` · 409 — connected, but Meta refused the stored
128
- * token. Reconnect.
129
- * - `CUSTOMER_NOT_FOUND` · 404 / `WHATSAPP_RECIPIENT_PHONE_MISSING` · 400 — a bad
130
- * id versus a real customer with no usable number.
131
- * - `WHATSAPP_RECIPIENT_NOT_ALLOWED` · 403 — non-production stages only: the
132
- * number is not on that stage's test allowlist. Nothing was sent.
133
- * - `WHATSAPP_TEMPLATE_NOT_APPROVED` · 422 — not approved, paused, disabled,
134
- * wrong language or wrong parameter count (Meta does not tell these apart).
135
- * - `WHATSAPP_RECIPIENT_OPTED_OUT` · 409 — the recipient cannot receive it.
136
- * - `WHATSAPP_RATE_LIMITED` · 429 — throughput cap; retry later.
137
- * - `WHATSAPP_ACCOUNT_SUSPENDED` · 403 — the WhatsApp Business account or the
138
- * number itself is restricted.
139
- * - `WHATSAPP_SEND_FAILED` · 502 — any other Meta 4xx refusal; carries `metaCode`.
140
- * - `WHATSAPP_SEND_UNCONFIRMED` · 502 — the request reached Meta and its outcome
141
- * is unknown: no answer came back, Meta answered 5xx, or Meta accepted it
142
- * without a message id.
143
- * The message may have been delivered, so the key is sealed:
144
- * a retry under it answers `IDEMPOTENCY_KEY_FAILED` rather than re-sending.
145
- */
146
- export declare const WHATSAPP_SEND_ERROR_CODES: readonly ["VALIDATION_FAILED", "IDEMPOTENCY_KEY_REQUIRED", "PLATFORM_INTEGRATION_DISABLED", "WHATSAPP_NOT_CONNECTED", "WHATSAPP_TOKEN_REJECTED", "CUSTOMER_NOT_FOUND", "WHATSAPP_RECIPIENT_PHONE_MISSING", "WHATSAPP_RECIPIENT_NOT_ALLOWED", "WHATSAPP_TEMPLATE_NOT_APPROVED", "WHATSAPP_RECIPIENT_OPTED_OUT", "WHATSAPP_RATE_LIMITED", "WHATSAPP_ACCOUNT_SUSPENDED", "WHATSAPP_SEND_FAILED", "WHATSAPP_SEND_UNCONFIRMED"];
147
- export type WhatsAppSendErrorCode = (typeof WHATSAPP_SEND_ERROR_CODES)[number];
148
- export {};
package/dist/whatsapp.js DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * Published WhatsApp surface — the tenant-facing connection config and the
3
- * tenant's own template send (`POST /whatsapp/send`).
4
- *
5
- * ⚠️ **Meta's inbound webhook payload is NOT here and must not come back.**
6
- * The twelve shapes Meta POSTs to `/whatsapp` — the entry/change/value
7
- * envelope, the contact, message, document, audio, image, status, error,
8
- * conversation and pricing leaves — live in
9
- * `./internal/whatsappWebhook.ts`, prefixed `WhatsAppWebhook*` and excluded
10
- * from the published build. They are inbound (the provider answering us), so
11
- * they fail `./internal/README.md`'s own test for what may be published, and
12
- * their bare names MERGED with globals in every consumer: a published
13
- * `interface Document` made `document.filename` compile and type as `string`
14
- * against `lib.dom`'s `Document`, returning `undefined` at runtime.
15
- */
16
- /**
17
- * `POST /whatsapp/send` refusals, beyond the cross-cutting `GATING_ERROR_CODES`
18
- * (notably `PLAN_LIMIT_EXCEEDED` for the `whatsappMessages` monthly cap).
19
- *
20
- * - `VALIDATION_FAILED` · 400 — including a body naming both or neither of
21
- * `to` / `customerId`.
22
- * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — no `Idempotency-Key` header. The
23
- * idempotency wrapper's own codes (`INVALID_IDEMPOTENCY_KEY`,
24
- * `IDEMPOTENCY_KEY_REUSE`, `IDEMPOTENCY_IN_PROGRESS`, `IDEMPOTENCY_KEY_FAILED`,
25
- * `IDEMPOTENCY_LOCK_CONTENTION`) apply too. `IDEMPOTENCY_KEY_FAILED` (409)
26
- * means an earlier attempt under this key may have reached Meta: check the
27
- * recipient's chat before sending again under a NEW key.
28
- * - `PLATFORM_INTEGRATION_DISABLED` · 503 — WhatsApp is switched off
29
- * platform-wide by SINFACTURA.
30
- * - `WHATSAPP_NOT_CONNECTED` · 409 — the calling store has no connected
31
- * WhatsApp, or a connection with no stored token after a disconnect. Disable
32
- * the send control. ⚠️ Never falls back to the platform number.
33
- * - `WHATSAPP_TOKEN_REJECTED` · 409 — connected, but Meta refused the stored
34
- * token. Reconnect.
35
- * - `CUSTOMER_NOT_FOUND` · 404 / `WHATSAPP_RECIPIENT_PHONE_MISSING` · 400 — a bad
36
- * id versus a real customer with no usable number.
37
- * - `WHATSAPP_RECIPIENT_NOT_ALLOWED` · 403 — non-production stages only: the
38
- * number is not on that stage's test allowlist. Nothing was sent.
39
- * - `WHATSAPP_TEMPLATE_NOT_APPROVED` · 422 — not approved, paused, disabled,
40
- * wrong language or wrong parameter count (Meta does not tell these apart).
41
- * - `WHATSAPP_RECIPIENT_OPTED_OUT` · 409 — the recipient cannot receive it.
42
- * - `WHATSAPP_RATE_LIMITED` · 429 — throughput cap; retry later.
43
- * - `WHATSAPP_ACCOUNT_SUSPENDED` · 403 — the WhatsApp Business account or the
44
- * number itself is restricted.
45
- * - `WHATSAPP_SEND_FAILED` · 502 — any other Meta 4xx refusal; carries `metaCode`.
46
- * - `WHATSAPP_SEND_UNCONFIRMED` · 502 — the request reached Meta and its outcome
47
- * is unknown: no answer came back, Meta answered 5xx, or Meta accepted it
48
- * without a message id.
49
- * The message may have been delivered, so the key is sealed:
50
- * a retry under it answers `IDEMPOTENCY_KEY_FAILED` rather than re-sending.
51
- */
52
- export const WHATSAPP_SEND_ERROR_CODES = [
53
- 'VALIDATION_FAILED',
54
- 'IDEMPOTENCY_KEY_REQUIRED',
55
- 'PLATFORM_INTEGRATION_DISABLED',
56
- 'WHATSAPP_NOT_CONNECTED',
57
- 'WHATSAPP_TOKEN_REJECTED',
58
- 'CUSTOMER_NOT_FOUND',
59
- 'WHATSAPP_RECIPIENT_PHONE_MISSING',
60
- 'WHATSAPP_RECIPIENT_NOT_ALLOWED',
61
- 'WHATSAPP_TEMPLATE_NOT_APPROVED',
62
- 'WHATSAPP_RECIPIENT_OPTED_OUT',
63
- 'WHATSAPP_RATE_LIMITED',
64
- 'WHATSAPP_ACCOUNT_SUSPENDED',
65
- 'WHATSAPP_SEND_FAILED',
66
- 'WHATSAPP_SEND_UNCONFIRMED',
67
- ];