@pilot-status/sdk 0.5.0 → 0.8.0
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/CHANGELOG.md +51 -0
- package/README.md +165 -19
- package/dist/client.d.ts +53 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -4
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +65 -0
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +19 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +27 -0
- package/dist/internal.js.map +1 -0
- package/dist/resources/api-keys.d.ts +20 -7
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +18 -5
- package/dist/resources/api-keys.js.map +1 -1
- package/dist/resources/billing.d.ts +18 -0
- package/dist/resources/billing.d.ts.map +1 -0
- package/dist/resources/billing.js +30 -0
- package/dist/resources/billing.js.map +1 -0
- package/dist/resources/branding.d.ts +18 -0
- package/dist/resources/branding.d.ts.map +1 -0
- package/dist/resources/branding.js +29 -0
- package/dist/resources/branding.js.map +1 -0
- package/dist/resources/chatwoot.d.ts +57 -0
- package/dist/resources/chatwoot.d.ts.map +1 -0
- package/dist/resources/chatwoot.js +117 -0
- package/dist/resources/chatwoot.js.map +1 -0
- package/dist/resources/conversations.d.ts +16 -0
- package/dist/resources/conversations.d.ts.map +1 -0
- package/dist/resources/conversations.js +28 -0
- package/dist/resources/conversations.js.map +1 -0
- package/dist/resources/embed.d.ts +24 -0
- package/dist/resources/embed.d.ts.map +1 -0
- package/dist/resources/embed.js +37 -0
- package/dist/resources/embed.js.map +1 -0
- package/dist/resources/flows.d.ts +203 -0
- package/dist/resources/flows.d.ts.map +1 -0
- package/dist/resources/flows.js +289 -0
- package/dist/resources/flows.js.map +1 -0
- package/dist/resources/groups.d.ts +37 -1
- package/dist/resources/groups.d.ts.map +1 -1
- package/dist/resources/groups.js +91 -0
- package/dist/resources/groups.js.map +1 -1
- package/dist/resources/messages.d.ts +43 -1
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +105 -1
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/meta.d.ts +19 -0
- package/dist/resources/meta.d.ts.map +1 -0
- package/dist/resources/meta.js +31 -0
- package/dist/resources/meta.js.map +1 -0
- package/dist/resources/numbers.d.ts +63 -1
- package/dist/resources/numbers.d.ts.map +1 -1
- package/dist/resources/numbers.js +101 -0
- package/dist/resources/numbers.js.map +1 -1
- package/dist/resources/service-window.d.ts +20 -0
- package/dist/resources/service-window.d.ts.map +1 -0
- package/dist/resources/service-window.js +26 -0
- package/dist/resources/service-window.js.map +1 -0
- package/dist/resources/subscription.d.ts +43 -0
- package/dist/resources/subscription.d.ts.map +1 -0
- package/dist/resources/subscription.js +60 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/templates.d.ts +31 -1
- package/dist/resources/templates.d.ts.map +1 -1
- package/dist/resources/templates.js +56 -0
- package/dist/resources/templates.js.map +1 -1
- package/dist/resources/webhooks.d.ts +53 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +97 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/resources/workspace.d.ts +57 -0
- package/dist/resources/workspace.d.ts.map +1 -0
- package/dist/resources/workspace.js +73 -0
- package/dist/resources/workspace.js.map +1 -0
- package/dist/types.d.ts +801 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/webhooks/parse.d.ts +16 -0
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +49 -0
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/signature.d.ts +42 -0
- package/dist/webhooks/signature.d.ts.map +1 -0
- package/dist/webhooks/signature.js +40 -0
- package/dist/webhooks/signature.js.map +1 -0
- package/dist/webhooks/types.d.ts +59 -1
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +5 -3
- package/dist/messages.test.d.ts +0 -2
- package/dist/messages.test.d.ts.map +0 -1
- package/dist/messages.test.js +0 -107
- package/dist/messages.test.js.map +0 -1
- package/dist/numbers.test.d.ts +0 -2
- package/dist/numbers.test.d.ts.map +0 -1
- package/dist/numbers.test.js +0 -57
- package/dist/numbers.test.js.map +0 -1
- package/dist/resources/groups.test.d.ts +0 -2
- package/dist/resources/groups.test.d.ts.map +0 -1
- package/dist/resources/groups.test.js +0 -19
- package/dist/resources/groups.test.js.map +0 -1
- package/dist/resources/newsletters.test.d.ts +0 -2
- package/dist/resources/newsletters.test.d.ts.map +0 -1
- package/dist/resources/newsletters.test.js +0 -19
- package/dist/resources/newsletters.test.js.map +0 -1
- package/dist/resources/projects.d.ts +0 -9
- package/dist/resources/projects.d.ts.map +0 -1
- package/dist/resources/projects.js +0 -23
- package/dist/resources/projects.js.map +0 -1
- package/dist/resources/templates.test.d.ts +0 -2
- package/dist/resources/templates.test.d.ts.map +0 -1
- package/dist/resources/templates.test.js +0 -28
- package/dist/resources/templates.test.js.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
export type MessageStatus = "QUEUED" | "SENT" | "DELIVERED" | "FAILED" | "READ" | "CANCELED";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The API accepts BOTH spellings. The uppercase set is the current one (aligned with
|
|
4
|
+
* the Meta Cloud API); the lowercase set is kept for backward compatibility and is
|
|
5
|
+
* still what most of the server's own tests send — see `buttonSchema` in
|
|
6
|
+
* `packages/shared/src/validation.ts`, e.g. `z.enum(["QUICK_REPLY", "reply"])`.
|
|
7
|
+
* Declaring only half of it made valid calls fail to type-check.
|
|
8
|
+
*/
|
|
9
|
+
export type ButtonType = "QUICK_REPLY" | "URL" | "PHONE_NUMBER" | "COPY_CODE" | "reply" | "url" | "call" | "copy";
|
|
3
10
|
export type Button = {
|
|
4
11
|
type: ButtonType;
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The button's visible text. THIS is the field the platform reads.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ Do not use `label`. It was the only text field this type ever declared, and
|
|
16
|
+
* nothing on the server or in the providers reads it: the Meta adapter builds the
|
|
17
|
+
* button from `displayText` (`packages/whatsapp-provider/src/meta/message.ts`), and
|
|
18
|
+
* the request schema only passes `label` through untouched. A button sent with
|
|
19
|
+
* `label` alone therefore arrived with an EMPTY title. The SDK now copies `label`
|
|
20
|
+
* into `displayText` when you send one, so existing code keeps working, but new
|
|
21
|
+
* code should set `displayText`.
|
|
22
|
+
*/
|
|
23
|
+
displayText?: string;
|
|
24
|
+
/** Alias the request schema also accepts for {@link displayText}. */
|
|
25
|
+
text?: string;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Never read by the platform — see {@link displayText}. Still accepted
|
|
28
|
+
* and mapped for you, so old code does not break.
|
|
29
|
+
*/
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Payload id echoed back on the reply. Quick-reply buttons only. */
|
|
32
|
+
id?: string;
|
|
6
33
|
url?: string;
|
|
7
34
|
phone_number?: string;
|
|
35
|
+
phoneNumber?: string;
|
|
36
|
+
copyCode?: string;
|
|
8
37
|
example?: string[];
|
|
9
38
|
};
|
|
10
39
|
export type MarketingOptions = {
|
|
@@ -47,7 +76,7 @@ export type SendMessageInput = {
|
|
|
47
76
|
deliverUntil?: string;
|
|
48
77
|
marketingOptions?: MarketingOptions;
|
|
49
78
|
media?: string;
|
|
50
|
-
mediaType?: "image" | "video" | "document" | "audio" | "voice";
|
|
79
|
+
mediaType?: "image" | "video" | "document" | "audio" | "voice" | "sticker";
|
|
51
80
|
buttons?: Button[];
|
|
52
81
|
text?: string;
|
|
53
82
|
header?: SendMessageHeader;
|
|
@@ -91,17 +120,6 @@ export type DashboardStats = {
|
|
|
91
120
|
read: number;
|
|
92
121
|
};
|
|
93
122
|
};
|
|
94
|
-
export type Project = {
|
|
95
|
-
id: string;
|
|
96
|
-
name: string;
|
|
97
|
-
slug: string;
|
|
98
|
-
description: string;
|
|
99
|
-
createdAt: string;
|
|
100
|
-
};
|
|
101
|
-
export type CreateProjectInput = {
|
|
102
|
-
name: string;
|
|
103
|
-
description?: string;
|
|
104
|
-
};
|
|
105
123
|
export type ApiKeyCreated = {
|
|
106
124
|
id: string;
|
|
107
125
|
name: string;
|
|
@@ -150,6 +168,12 @@ export type NumberApiKeyReveal = {
|
|
|
150
168
|
key: string | null;
|
|
151
169
|
revealable: boolean;
|
|
152
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* What `GET /v1/api-keys` ACTUALLY returns — one shape or the other depending on
|
|
173
|
+
* the credential's scope, never both. Discriminate on `revealable`, which only
|
|
174
|
+
* exists on the tenant-scoped variant.
|
|
175
|
+
*/
|
|
176
|
+
export type ApiKeyListResult = ApiKeyListItem[] | NumberApiKeyReveal[];
|
|
153
177
|
/**
|
|
154
178
|
* The new usable key returned by `POST /v1/api-keys` (tenant-scoped) when
|
|
155
179
|
* regenerating the default key of one number. The raw `key` is shown only once.
|
|
@@ -198,13 +222,23 @@ export type CreateNumberInput = {
|
|
|
198
222
|
name: string;
|
|
199
223
|
number: string;
|
|
200
224
|
linkToApiKey?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Per-number settings the number is BORN with — same block as
|
|
227
|
+
* {@link NumberSettingsInput}.
|
|
228
|
+
*
|
|
229
|
+
* This is the only place `historyImportEnabled: true` can be asked for: the
|
|
230
|
+
* default is `false`, the provider dumps the device history in a burst right
|
|
231
|
+
* after the connection, and there is no way to request it later.
|
|
232
|
+
*/
|
|
233
|
+
settings?: NumberSettingsInput;
|
|
201
234
|
};
|
|
202
235
|
/**
|
|
203
236
|
* Per-number settings — `PATCH /v1/numbers/{id}` and the `settings` block of
|
|
204
237
|
* `GET /v1/numbers/{id}`. There is NO `POST /v1/numbers/{id}/settings`, and
|
|
205
238
|
* Evolution's `syncFullHistory` has no equivalent here: use `historyImportEnabled`.
|
|
206
239
|
*
|
|
207
|
-
*
|
|
240
|
+
* `historyImportEnabled`, `webhookHistoricalMessages` and `ignoreNewsletters`
|
|
241
|
+
* are platform-level and apply to every provider. The rest are the Evolution GO
|
|
208
242
|
* `advancedSettings`, in the GO dialect (`ignoreGroups` — NOT the v2
|
|
209
243
|
* `groupsIgnore`); they are stored on a Meta number but never applied, which is
|
|
210
244
|
* what `appliesTo.advanced === "none"` tells you.
|
|
@@ -212,7 +246,14 @@ export type CreateNumberInput = {
|
|
|
212
246
|
* `null` on a GO field means "reset to the provider default", not `false`.
|
|
213
247
|
*/
|
|
214
248
|
export type NumberSettingsInput = {
|
|
215
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* Import the provider's on-connect history dump into the chat. Default
|
|
251
|
+
* **false** — a number starts existing at the moment it connected.
|
|
252
|
+
*
|
|
253
|
+
* ⚠️ Set it on `numbers.create()`, not afterwards. The provider hands the
|
|
254
|
+
* history over in a burst right after the connection, and nothing can ask for
|
|
255
|
+
* it again: a `create` followed by an `updateSettings` races that burst.
|
|
256
|
+
*/
|
|
216
257
|
historyImportEnabled?: boolean;
|
|
217
258
|
/**
|
|
218
259
|
* Deliver historical (backfilled) messages to your webhooks. Default FALSE:
|
|
@@ -221,6 +262,19 @@ export type NumberSettingsInput = {
|
|
|
221
262
|
* `messages.history()` instead.
|
|
222
263
|
*/
|
|
223
264
|
webhookHistoricalMessages?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Drop WhatsApp CHANNEL (`@newsletter`) posts on ingestion: they become no
|
|
267
|
+
* conversation, no stored message and no webhook. Default FALSE — whoever
|
|
268
|
+
* already receives channels keeps receiving them.
|
|
269
|
+
*
|
|
270
|
+
* Asymmetric with `ignoreGroups` on purpose, and the asymmetry is the
|
|
271
|
+
* provider's, not ours: Evolution GO kills a group event inside its own
|
|
272
|
+
* handler, before it ever leaves the provider. There is no upstream gate for
|
|
273
|
+
* `@newsletter`, so a channel post always arrives and the only place it can be
|
|
274
|
+
* refused is on our side. Channels never reach a Meta number, where this field
|
|
275
|
+
* is accepted and stored but has nothing to drop.
|
|
276
|
+
*/
|
|
277
|
+
ignoreNewsletters?: boolean;
|
|
224
278
|
/** Keep the WhatsApp presence permanently online. Evolution GO only. */
|
|
225
279
|
alwaysOnline?: boolean | null;
|
|
226
280
|
/** Auto-reject incoming calls. Evolution GO only. */
|
|
@@ -275,7 +329,10 @@ export type NumberDetail = {
|
|
|
275
329
|
updatedAt: string;
|
|
276
330
|
health: {
|
|
277
331
|
qualityRating: string | null;
|
|
332
|
+
/** The number's OWN messaging limit tier. `null` when Meta reports none for it. */
|
|
278
333
|
messagingLimitTier: string | null;
|
|
334
|
+
/** The Business-Portfolio limit — a different thing, and usually higher. */
|
|
335
|
+
portfolioMessagingLimitTier: string | null;
|
|
279
336
|
metaStatus: string | null;
|
|
280
337
|
code: string | null;
|
|
281
338
|
reason: string | null;
|
|
@@ -412,32 +469,140 @@ export type RemotePairingResult = {
|
|
|
412
469
|
instance: WhatsAppNumberInstance;
|
|
413
470
|
linkedApiKeyId: string | null;
|
|
414
471
|
};
|
|
472
|
+
export type TemplateCategory = "OTP" | "UTILITY" | "MARKETING";
|
|
473
|
+
/**
|
|
474
|
+
* Only `sendable: true` can be passed to `messages.send()`. On a Meta number that
|
|
475
|
+
* means `source: "META"` + `metaStatus: "APPROVED"`.
|
|
476
|
+
*/
|
|
415
477
|
export type TemplateListItem = {
|
|
416
478
|
id: string;
|
|
417
479
|
name: string;
|
|
418
480
|
category: string;
|
|
481
|
+
source?: "META" | "PILOT_STATUS";
|
|
482
|
+
metaStatus?: string | null;
|
|
483
|
+
metaLanguage?: string | null;
|
|
484
|
+
sendable?: boolean;
|
|
419
485
|
latestVersion?: {
|
|
420
486
|
variables?: string[];
|
|
421
487
|
};
|
|
422
488
|
};
|
|
423
|
-
export type TemplateDetail =
|
|
424
|
-
|
|
489
|
+
export type TemplateDetail = TemplateListItem;
|
|
490
|
+
/**
|
|
491
|
+
* One NON-EMPTY example per `{{variable}}` in the body, keyed by the variable
|
|
492
|
+
* name. Without it the API rejects with `TEMPLATE_EXAMPLES_REQUIRED`.
|
|
493
|
+
*/
|
|
494
|
+
export type TemplateExamples = Record<string, string>;
|
|
495
|
+
export type CreateTemplateInput = {
|
|
425
496
|
name: string;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Plain text with `{{variables}}`, or the full template JSON (header
|
|
499
|
+
* TEXT/IMAGE/VIDEO/DOCUMENT, body, footer, up to 10 buttons — at most 2 URL and
|
|
500
|
+
* 1 PHONE_NUMBER).
|
|
501
|
+
*/
|
|
502
|
+
body: string;
|
|
503
|
+
examples: TemplateExamples;
|
|
504
|
+
/** Default `UTILITY`. */
|
|
505
|
+
category?: TemplateCategory;
|
|
506
|
+
/** Derived from the body when omitted. */
|
|
507
|
+
variables?: string[];
|
|
508
|
+
/** Meta language code, e.g. `pt_BR` (default `pt_BR`). */
|
|
509
|
+
language?: string;
|
|
510
|
+
};
|
|
511
|
+
export type UpdateTemplateInput = {
|
|
512
|
+
body: string;
|
|
513
|
+
examples: TemplateExamples;
|
|
514
|
+
};
|
|
515
|
+
export type TemplateDeleteResult = {
|
|
516
|
+
success: boolean;
|
|
430
517
|
};
|
|
431
518
|
export type GroupListItem = {
|
|
432
519
|
id: string;
|
|
433
520
|
subject: string;
|
|
434
521
|
};
|
|
522
|
+
export type GroupParticipant = {
|
|
523
|
+
id: string;
|
|
524
|
+
admin?: string | null;
|
|
525
|
+
name?: string | null;
|
|
526
|
+
};
|
|
527
|
+
export type GroupDetail = {
|
|
528
|
+
id: string;
|
|
529
|
+
subject: string;
|
|
530
|
+
owner?: string | null;
|
|
531
|
+
creation?: number | null;
|
|
532
|
+
participants?: GroupParticipant[];
|
|
533
|
+
};
|
|
534
|
+
export type CreateGroupInput = {
|
|
535
|
+
subject: string;
|
|
536
|
+
/** Phone numbers as E.164 digits — not JIDs. */
|
|
537
|
+
participants?: string[];
|
|
538
|
+
};
|
|
539
|
+
export type GroupActionResult = {
|
|
540
|
+
success: boolean;
|
|
541
|
+
};
|
|
542
|
+
export type GroupInviteResult = {
|
|
543
|
+
inviteCode?: string | null;
|
|
544
|
+
inviteUrl?: string | null;
|
|
545
|
+
};
|
|
546
|
+
export type GroupPinAction = "pin" | "unpin";
|
|
435
547
|
export type NewsletterListItem = {
|
|
436
548
|
id: string;
|
|
437
549
|
name: string;
|
|
438
550
|
};
|
|
551
|
+
/**
|
|
552
|
+
* ⚠️ `DELETE /v1/numbers/{id}` is a 30-day SOFT delete. `restorableUntil` is the
|
|
553
|
+
* end of the window in which `numbers.restore()` still works; it was not returned
|
|
554
|
+
* by the version where the delete was destructive, hence optional.
|
|
555
|
+
*/
|
|
439
556
|
export type DeleteNumberResult = {
|
|
440
|
-
|
|
557
|
+
ok?: boolean;
|
|
558
|
+
success?: boolean;
|
|
559
|
+
/** ISO 8601 — until when restoring is still possible. */
|
|
560
|
+
restorableUntil?: string;
|
|
561
|
+
};
|
|
562
|
+
/** `requiresReconnect` is always `true`: restoring gives back the line, not the session. */
|
|
563
|
+
export type NumberRestoreResult = {
|
|
564
|
+
ok: boolean;
|
|
565
|
+
requiresReconnect: boolean;
|
|
566
|
+
};
|
|
567
|
+
export type NumberPurgeResult = {
|
|
568
|
+
ok: boolean;
|
|
569
|
+
};
|
|
570
|
+
export type NumberLogoutResult = {
|
|
571
|
+
ok?: boolean;
|
|
572
|
+
success?: boolean;
|
|
573
|
+
results?: Array<{
|
|
574
|
+
instanceId: string;
|
|
575
|
+
ok: boolean;
|
|
576
|
+
error?: string;
|
|
577
|
+
}>;
|
|
578
|
+
};
|
|
579
|
+
/** Pass `numbers` (up to 20) OR `number`. */
|
|
580
|
+
export type CheckNumbersInput = {
|
|
581
|
+
numbers?: string[];
|
|
582
|
+
number?: string;
|
|
583
|
+
};
|
|
584
|
+
export type CheckNumbersResult = {
|
|
585
|
+
results: Array<{
|
|
586
|
+
/** What you sent. */
|
|
587
|
+
input: string;
|
|
588
|
+
exists: boolean;
|
|
589
|
+
/** The digits REGISTERED on WhatsApp — use this one when sending. `null` when it does not exist. */
|
|
590
|
+
number: string | null;
|
|
591
|
+
name?: string | null;
|
|
592
|
+
}>;
|
|
593
|
+
};
|
|
594
|
+
/** Your own Cloud API credentials — the server-side path of the official onboarding. */
|
|
595
|
+
export type CreateMetaNumberInput = {
|
|
596
|
+
name: string;
|
|
597
|
+
number: string;
|
|
598
|
+
metaPhoneId: string;
|
|
599
|
+
metaWabaId: string;
|
|
600
|
+
metaAccessToken: string;
|
|
601
|
+
metaAppSecret: string;
|
|
602
|
+
metaAppId: string;
|
|
603
|
+
linkToApiKey?: boolean;
|
|
604
|
+
/** Points the WABA's webhooks at Pilot Status (`POST /{waba}/subscribed_apps`). */
|
|
605
|
+
routeWebhooksToPilot?: boolean;
|
|
441
606
|
};
|
|
442
607
|
export type MediaDownloadResult = {
|
|
443
608
|
base64: string;
|
|
@@ -551,4 +716,617 @@ export type CallRealtimeSessionResult = {
|
|
|
551
716
|
token: string;
|
|
552
717
|
expiresInSeconds: number;
|
|
553
718
|
};
|
|
719
|
+
/** `"IN"` = received, `"OUT"` = sent. Distinct from the chat's `INBOUND`/`OUTBOUND`. */
|
|
720
|
+
export type MessageLogDirection = "IN" | "OUT";
|
|
721
|
+
/**
|
|
722
|
+
* One row of the message LOG (`GET /v1/messages`) — the operational trail, not
|
|
723
|
+
* the conversation text. Rows covered by the number's PII policy come back with
|
|
724
|
+
* `content`/`from`/`to` null and `redacted: true`.
|
|
725
|
+
*/
|
|
726
|
+
export type MessageLogEntry = {
|
|
727
|
+
id: string;
|
|
728
|
+
correlationId: string | null;
|
|
729
|
+
direction: MessageLogDirection;
|
|
730
|
+
from: string | null;
|
|
731
|
+
to: string | null;
|
|
732
|
+
content: string | null;
|
|
733
|
+
template: string | null;
|
|
734
|
+
status: string;
|
|
735
|
+
errorCode: string | null;
|
|
736
|
+
errorMessage: string | null;
|
|
737
|
+
/** Which surface it came in through (`"API"`, `"APP"`, …). `null` when not applicable. */
|
|
738
|
+
origin: string | null;
|
|
739
|
+
/** Whether the 24h window was open at send time. `null` on received messages. */
|
|
740
|
+
serviceWindowOpenAtSend: boolean | null;
|
|
741
|
+
createdAt: string | null;
|
|
742
|
+
sentAt: string | null;
|
|
743
|
+
deliveredAt: string | null;
|
|
744
|
+
readAt: string | null;
|
|
745
|
+
externalMessageId: string | null;
|
|
746
|
+
redacted?: true;
|
|
747
|
+
};
|
|
748
|
+
export type MessageListParams = {
|
|
749
|
+
page?: number;
|
|
750
|
+
/** Default 30, max 100. */
|
|
751
|
+
pageSize?: number;
|
|
752
|
+
/**
|
|
753
|
+
* Statuses comma-separated inside a single string — `"SENT,DELIVERED"`, not an
|
|
754
|
+
* array. That is the format the server reads.
|
|
755
|
+
*/
|
|
756
|
+
status?: string;
|
|
757
|
+
direction?: "in" | "out";
|
|
758
|
+
startDate?: string;
|
|
759
|
+
endDate?: string;
|
|
760
|
+
/** Phone number in any format, or a template name. */
|
|
761
|
+
search?: string;
|
|
762
|
+
/** Template id or name. */
|
|
763
|
+
templateId?: string;
|
|
764
|
+
/** State of the 24h window at send time. */
|
|
765
|
+
window?: "open" | "closed";
|
|
766
|
+
};
|
|
767
|
+
export type MessageListResult = {
|
|
768
|
+
data: MessageLogEntry[];
|
|
769
|
+
page: number;
|
|
770
|
+
pageSize: number;
|
|
771
|
+
total: number;
|
|
772
|
+
totalPages: number;
|
|
773
|
+
/** Only on a `RELAY_ONLY` number, explaining why every row came back redacted. */
|
|
774
|
+
notice?: string;
|
|
775
|
+
};
|
|
776
|
+
export type GroupMessagesParams = MessageHistoryParams;
|
|
777
|
+
export type GroupMessagesResult = MessageHistoryResult;
|
|
778
|
+
export type UnreadMessagesParams = {
|
|
779
|
+
page?: number;
|
|
780
|
+
pageSize?: number;
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* ⚠️ `total` is the REAL unread count (the same one the dashboard shows), not the
|
|
784
|
+
* size of `messages` — the list only carries the latest unread of each conversation.
|
|
785
|
+
*/
|
|
786
|
+
export type UnreadMessagesResult = {
|
|
787
|
+
messages: ChatHistoryMessage[];
|
|
788
|
+
total: number;
|
|
789
|
+
page: number;
|
|
790
|
+
pageSize: number;
|
|
791
|
+
totalPages: number;
|
|
792
|
+
notice?: string;
|
|
793
|
+
};
|
|
794
|
+
/** `acked: false` with HTTP 200 is the normal "there was nothing to acknowledge" case. */
|
|
795
|
+
export type MarkReadResult = {
|
|
796
|
+
ok: boolean;
|
|
797
|
+
acked: boolean;
|
|
798
|
+
/** `"NO_INBOUND_MESSAGE"` | `"PII_RELAY_ONLY"` when `acked` is false. */
|
|
799
|
+
reason?: string;
|
|
800
|
+
};
|
|
801
|
+
export type TypingState = "typing" | "recording" | "paused";
|
|
802
|
+
export type TypingInput = {
|
|
803
|
+
to: string;
|
|
804
|
+
/** Default `"typing"`. */
|
|
805
|
+
state?: TypingState;
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* `effectiveState` is what the provider ACTUALLY displayed: on a META number
|
|
809
|
+
* `"recording"` becomes `"typing"` and `"paused"` is a no-op. Branch on this, not
|
|
810
|
+
* on what you asked for.
|
|
811
|
+
*/
|
|
812
|
+
export type TypingResult = {
|
|
813
|
+
ok: boolean;
|
|
814
|
+
sent: boolean;
|
|
815
|
+
provider: string;
|
|
816
|
+
effectiveState: string;
|
|
817
|
+
note?: string;
|
|
818
|
+
};
|
|
819
|
+
export type ConversationListParams = {
|
|
820
|
+
/** These filter on the timestamp of the conversation's LAST message. */
|
|
821
|
+
startDate?: string;
|
|
822
|
+
endDate?: string;
|
|
823
|
+
page?: number;
|
|
824
|
+
pageSize?: number;
|
|
825
|
+
};
|
|
826
|
+
export type ConversationSummary = {
|
|
827
|
+
id: string;
|
|
828
|
+
peerPhone: string | null;
|
|
829
|
+
peerName: string | null;
|
|
830
|
+
lastMessageAt: string | null;
|
|
831
|
+
lastInboundAt: string | null;
|
|
832
|
+
unreadCount: number;
|
|
833
|
+
redacted?: true;
|
|
834
|
+
};
|
|
835
|
+
export type ConversationListResult = {
|
|
836
|
+
conversations: ConversationSummary[];
|
|
837
|
+
total: number;
|
|
838
|
+
page: number;
|
|
839
|
+
pageSize: number;
|
|
840
|
+
totalPages: number;
|
|
841
|
+
notice?: string;
|
|
842
|
+
};
|
|
843
|
+
/**
|
|
844
|
+
* `"META_24H"` = Meta's rule genuinely applies. `"NONE"` = web/unofficial number,
|
|
845
|
+
* where the restriction does not exist and `open` is always `true`.
|
|
846
|
+
*/
|
|
847
|
+
export type ServiceWindowType = "META_24H" | "NONE";
|
|
848
|
+
export type ServiceWindowResult = {
|
|
849
|
+
open: boolean;
|
|
850
|
+
windowType: ServiceWindowType;
|
|
851
|
+
/** ISO 8601, or `null` when there was never an inbound message. */
|
|
852
|
+
lastInboundAt: string | null;
|
|
853
|
+
/** `lastInboundAt` + 24h. */
|
|
854
|
+
expiresAt: string | null;
|
|
855
|
+
};
|
|
856
|
+
export type MetaPricingParams = {
|
|
857
|
+
/** ISO-3166 alpha-2 (BR, GB…), `NAM`, or a regional bucket (AFR, APAC, LATAM…). */
|
|
858
|
+
market?: string;
|
|
859
|
+
/** ISO 4217. */
|
|
860
|
+
currency?: string;
|
|
861
|
+
/** `marketing` | `utility` | `authentication` | `service` | `authentication_international`. */
|
|
862
|
+
category?: string;
|
|
863
|
+
/** Includes `volumeTiers` in the response. */
|
|
864
|
+
tiers?: boolean;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* Without the three parameters, this is the catalog (markets/currencies/categories).
|
|
868
|
+
* With them, the price. The body is a passthrough of the rate card Meta publishes,
|
|
869
|
+
* so it is deliberately left as an open record — it is not the account's invoice.
|
|
870
|
+
*/
|
|
871
|
+
export type MetaPricingResult = Record<string, unknown>;
|
|
872
|
+
/** The signing `secret` NEVER comes back here — only on creation, once, in the dashboard. */
|
|
873
|
+
export type Webhook = {
|
|
874
|
+
id: string;
|
|
875
|
+
name: string;
|
|
876
|
+
url: string;
|
|
877
|
+
/** `["*"]` = all of them. An EMPTY list = fires nothing. */
|
|
878
|
+
events: string[];
|
|
879
|
+
active: boolean;
|
|
880
|
+
lastTriggered: string | null;
|
|
881
|
+
whatsappNumberIds: string[];
|
|
882
|
+
whatsappInstanceIds: string[];
|
|
883
|
+
createdAt: string;
|
|
884
|
+
updatedAt: string;
|
|
885
|
+
};
|
|
886
|
+
export type CreateWebhookInput = {
|
|
887
|
+
url: string;
|
|
888
|
+
/** Default: the URL's hostname. */
|
|
889
|
+
name?: string;
|
|
890
|
+
/**
|
|
891
|
+
* Empty or omitted subscribes to NOTHING — there is no implicit subscribe-to-all.
|
|
892
|
+
* Use `["*"]` for all of them.
|
|
893
|
+
*/
|
|
894
|
+
events?: string[];
|
|
895
|
+
/** Required with a tenant-scoped key when the client has no `whatsappNumberId`. */
|
|
896
|
+
whatsappNumberId?: string;
|
|
897
|
+
};
|
|
898
|
+
/** `events` REPLACES the whole list; it is not a merge. */
|
|
899
|
+
export type UpdateWebhookInput = {
|
|
900
|
+
name?: string;
|
|
901
|
+
url?: string;
|
|
902
|
+
/** `false` pauses the deliveries without deleting it. */
|
|
903
|
+
active?: boolean;
|
|
904
|
+
events?: string[];
|
|
905
|
+
};
|
|
906
|
+
export type WebhookDeleteResult = {
|
|
907
|
+
success: boolean;
|
|
908
|
+
};
|
|
909
|
+
export type WebhookLogsParams = {
|
|
910
|
+
/** 1–50. */
|
|
911
|
+
limit?: number;
|
|
912
|
+
/** Filters by a single event type. */
|
|
913
|
+
event?: string;
|
|
914
|
+
};
|
|
915
|
+
export type WebhookLogEntry = {
|
|
916
|
+
id: string;
|
|
917
|
+
event: string;
|
|
918
|
+
status: "SUCCESS" | "FAILED";
|
|
919
|
+
statusCode: number | null;
|
|
920
|
+
payload: unknown;
|
|
921
|
+
response: string | null;
|
|
922
|
+
durationMs: number | null;
|
|
923
|
+
createdAt: string;
|
|
924
|
+
};
|
|
925
|
+
/** `null` on any field CLEARS the value; omitting it keeps the current one. */
|
|
926
|
+
export type BrandingInput = {
|
|
927
|
+
/** Must be https. */
|
|
928
|
+
logoUrl?: string | null;
|
|
929
|
+
/** `#RRGGBB`. */
|
|
930
|
+
primaryColor?: string | null;
|
|
931
|
+
backgroundColor?: string | null;
|
|
932
|
+
companyName?: string | null;
|
|
933
|
+
subtitle?: string | null;
|
|
934
|
+
supportUrl?: string | null;
|
|
935
|
+
defaultRedirectUrl?: string | null;
|
|
936
|
+
hidePilotStatusBranding?: boolean;
|
|
937
|
+
};
|
|
938
|
+
export type BrandingResult = {
|
|
939
|
+
branding: Record<string, unknown> | null;
|
|
940
|
+
};
|
|
941
|
+
export type EmbedSurface = "chat" | "connect";
|
|
942
|
+
export type EmbedSessionInput = {
|
|
943
|
+
surface: EmbedSurface;
|
|
944
|
+
/** EXACT origins (`https://app.customer.com`), 1–20, with no path and no trailing slash. */
|
|
945
|
+
allowedOrigins: string[];
|
|
946
|
+
/** Required on `chat` with a tenant-scoped credential; ignored on `connect`. */
|
|
947
|
+
whatsappNumberIds?: string[];
|
|
948
|
+
brandingOverride?: BrandingInput;
|
|
949
|
+
/** Max 3600. Default 900 (chat) / 1800 (connect). */
|
|
950
|
+
ttlSeconds?: number;
|
|
951
|
+
};
|
|
952
|
+
export type EmbedSessionResult = {
|
|
953
|
+
token: string;
|
|
954
|
+
surface: EmbedSurface;
|
|
955
|
+
whatsappNumberIds: string[] | null;
|
|
956
|
+
allowedOrigins: string[];
|
|
957
|
+
expiresAt: string;
|
|
958
|
+
};
|
|
959
|
+
export type CheckoutPurpose = "wallet_topup" | "add_card";
|
|
960
|
+
export type CheckoutInput = {
|
|
961
|
+
purpose: CheckoutPurpose;
|
|
962
|
+
/** Required on `wallet_topup`, in the account's currency. */
|
|
963
|
+
amount?: number;
|
|
964
|
+
successUrl?: string;
|
|
965
|
+
cancelUrl?: string;
|
|
966
|
+
};
|
|
967
|
+
/** Just a URL: nothing is charged until a human completes the payment on it. */
|
|
968
|
+
export type CheckoutResult = {
|
|
969
|
+
url: string;
|
|
970
|
+
};
|
|
971
|
+
export type ExtraNumbersPreview = {
|
|
972
|
+
quantity: number;
|
|
973
|
+
/** `true` when the purchase would convert a FREE plan into On Demand. */
|
|
974
|
+
requiresConversion?: boolean;
|
|
975
|
+
[key: string]: unknown;
|
|
976
|
+
};
|
|
977
|
+
/** With no card on file you get a `checkoutUrl` instead of a charge. */
|
|
978
|
+
export type ExtraNumbersPurchaseResult = {
|
|
979
|
+
success: boolean;
|
|
980
|
+
checkoutUrl?: string;
|
|
981
|
+
[key: string]: unknown;
|
|
982
|
+
};
|
|
983
|
+
export type ExtraNumbersScheduleResult = {
|
|
984
|
+
success: boolean;
|
|
985
|
+
[key: string]: unknown;
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* `auto` (default) sends an official number to the native `whatsapp_cloud` inbox
|
|
989
|
+
* and everything else to an API mirror inbox; `api`/`native` force one of the two.
|
|
990
|
+
*/
|
|
991
|
+
export type ChatwootChannelMode = "auto" | "api" | "native";
|
|
992
|
+
export type ChatwootStatus = {
|
|
993
|
+
connected: boolean;
|
|
994
|
+
status: "disconnected" | "pending" | "connected" | "error" | "disabled";
|
|
995
|
+
enabled: boolean;
|
|
996
|
+
inboxId: number | null;
|
|
997
|
+
instanceUrl: string | null;
|
|
998
|
+
accountId: string | null;
|
|
999
|
+
/** The Chatwoot token never comes back; this is all you can observe of it. */
|
|
1000
|
+
hasToken: boolean;
|
|
1001
|
+
channelMode: ChatwootChannelMode | null;
|
|
1002
|
+
lastError: string | null;
|
|
1003
|
+
lastErrorCode: string | null;
|
|
1004
|
+
lastSyncAt: string | null;
|
|
1005
|
+
};
|
|
1006
|
+
export type ChatwootConnectInput = {
|
|
1007
|
+
instanceUrl: string;
|
|
1008
|
+
accountId: string;
|
|
1009
|
+
/** `api_access_token` of a Chatwoot agent/admin. */
|
|
1010
|
+
userAccessToken: string;
|
|
1011
|
+
channelMode?: ChatwootChannelMode;
|
|
1012
|
+
};
|
|
1013
|
+
export type ChatwootUpdateInput = {
|
|
1014
|
+
/** `false` pauses the mirroring without disconnecting. */
|
|
1015
|
+
enabled?: boolean;
|
|
1016
|
+
instanceUrl?: string;
|
|
1017
|
+
accountId?: string;
|
|
1018
|
+
userAccessToken?: string;
|
|
1019
|
+
/** Rebuilds the inbox reusing the stored credential. */
|
|
1020
|
+
action?: "reconnect";
|
|
1021
|
+
channelMode?: ChatwootChannelMode;
|
|
1022
|
+
};
|
|
1023
|
+
export type ChatwootTestInput = {
|
|
1024
|
+
instanceUrl: string;
|
|
1025
|
+
accountId: string;
|
|
1026
|
+
/** Omit to reuse the stored token. */
|
|
1027
|
+
userAccessToken?: string;
|
|
1028
|
+
};
|
|
1029
|
+
export type ChatwootTestResult = {
|
|
1030
|
+
ok: boolean;
|
|
1031
|
+
checks: Array<{
|
|
1032
|
+
name: string;
|
|
1033
|
+
ok: boolean;
|
|
1034
|
+
status?: number;
|
|
1035
|
+
detail?: string;
|
|
1036
|
+
}>;
|
|
1037
|
+
};
|
|
1038
|
+
export type ChatwootHistoryReplayInput = {
|
|
1039
|
+
/** 30 (default) or 90. */
|
|
1040
|
+
windowDays?: 30 | 90;
|
|
1041
|
+
/** Resolves + marks read every conversation it touches, to contain the notification flood. Default true. */
|
|
1042
|
+
markRead?: boolean;
|
|
1043
|
+
};
|
|
1044
|
+
export type ChatwootHistoryReplayState = {
|
|
1045
|
+
status: string;
|
|
1046
|
+
total: number;
|
|
1047
|
+
done: number;
|
|
1048
|
+
failed: number;
|
|
1049
|
+
skippedMedia: number;
|
|
1050
|
+
[key: string]: unknown;
|
|
1051
|
+
};
|
|
1052
|
+
export type WorkspaceRole = "OWNER" | "ADMIN" | "AGENT" | "ANALYST";
|
|
1053
|
+
export type WorkspaceMemberStatus = "ACTIVE" | "PENDING";
|
|
1054
|
+
export type WorkspaceDetail = {
|
|
1055
|
+
id: string;
|
|
1056
|
+
/** `null` while the tenant has no name set — the route sends `tenant?.name ?? null`. */
|
|
1057
|
+
name: string | null;
|
|
1058
|
+
plan: string;
|
|
1059
|
+
/** Counts ACTIVE **and** PENDING: an invite already holds the seat. */
|
|
1060
|
+
seatsUsed: number;
|
|
1061
|
+
seatLimit: number;
|
|
1062
|
+
};
|
|
1063
|
+
/**
|
|
1064
|
+
* An active member or a pending invite — the same list, discriminated by `status`.
|
|
1065
|
+
* It never carries the invite token nor the `inviteUrl`: only the hash is stored.
|
|
1066
|
+
*
|
|
1067
|
+
* ⚠️ Mirrors, field for field, the `MemberView` that
|
|
1068
|
+
* `apps/backend/src/services/workspace-member.service.ts` builds. Every `Date`
|
|
1069
|
+
* there arrives here as an ISO-8601 string, because `NextResponse.json`
|
|
1070
|
+
* serializes it. Do not add a field that the service does not select: this type
|
|
1071
|
+
* crosses an HTTP boundary, so `tsc` cannot catch an invention — only a test
|
|
1072
|
+
* against the real body can.
|
|
1073
|
+
*/
|
|
1074
|
+
export type WorkspaceMember = {
|
|
1075
|
+
/** MEMBERSHIP id, not the user id. It is what the member routes take in the path. */
|
|
1076
|
+
id: string;
|
|
1077
|
+
email: string;
|
|
1078
|
+
/** `null` until the invitee has an account with a name on it. */
|
|
1079
|
+
name: string | null;
|
|
1080
|
+
role: WorkspaceRole;
|
|
1081
|
+
status: WorkspaceMemberStatus;
|
|
1082
|
+
/** Empty = every number in the account. */
|
|
1083
|
+
allowedNumberIds: string[];
|
|
1084
|
+
/** Always present, on ACTIVE rows too — it is when the invite was issued. */
|
|
1085
|
+
invitedAt: string;
|
|
1086
|
+
/** `null` while `status` is `PENDING`. */
|
|
1087
|
+
joinedAt: string | null;
|
|
1088
|
+
/** `null` once the invite has been accepted (the token is burned on acceptance). */
|
|
1089
|
+
inviteExpiresAt: string | null;
|
|
1090
|
+
/** `true` when the invite lapsed: the row survives but holds no seat any more. */
|
|
1091
|
+
inviteExpired: boolean;
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* The literal body of `GET /v1/workspace/members` — an ENVELOPE, not a bare
|
|
1095
|
+
* array. `seatsUsed`/`seatLimit` are the same counters `GET /v1/workspace`
|
|
1096
|
+
* reports, returned here so listing and capacity take one round trip instead of
|
|
1097
|
+
* two.
|
|
1098
|
+
*/
|
|
1099
|
+
export type WorkspaceMemberList = {
|
|
1100
|
+
members: WorkspaceMember[];
|
|
1101
|
+
seatsUsed: number;
|
|
1102
|
+
seatLimit: number;
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Meta's closed set. A value outside it only fails AFTER the trip to the Graph,
|
|
1106
|
+
* and Meta's message does not say WHICH category it refused — hence a union here
|
|
1107
|
+
* rather than `string`.
|
|
1108
|
+
*/
|
|
1109
|
+
export type FlowCategory = "SIGN_UP" | "SIGN_IN" | "APPOINTMENT_BOOKING" | "LEAD_GENERATION" | "CONTACT_US" | "CUSTOMER_SUPPORT" | "SURVEY" | "OTHER";
|
|
1110
|
+
/**
|
|
1111
|
+
* One Flow, as `GET /v1/flows` publishes it.
|
|
1112
|
+
*
|
|
1113
|
+
* ⚠️ `id` is the LOCAL cuid and it is the ONLY id any method of this SDK accepts
|
|
1114
|
+
* back. `metaFlowId` is READ-ONLY — Meta's identifier, useful for correlating with
|
|
1115
|
+
* Flow Manager and nothing else. See {@link CreateFlowInput.cloneFromFlowId}.
|
|
1116
|
+
*
|
|
1117
|
+
* `healthStatus` is the last channel that ever says a Flow was throttled or that
|
|
1118
|
+
* its endpoint public key died: Meta's Flows Metrics API was discontinued on
|
|
1119
|
+
* 2026-04-30 with no successor, so this column (filled by the `flows` webhook) is
|
|
1120
|
+
* where "the form stopped opening" becomes visible.
|
|
1121
|
+
*/
|
|
1122
|
+
export type Flow = {
|
|
1123
|
+
/** LOCAL cuid. The id every other method on this resource takes. */
|
|
1124
|
+
id: string;
|
|
1125
|
+
/** Meta's id. Read-only — never send it back to us. */
|
|
1126
|
+
metaFlowId: string | null;
|
|
1127
|
+
name: string;
|
|
1128
|
+
/** Meta's lifecycle: `DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED`, `THROTTLED`. */
|
|
1129
|
+
metaStatus: string | null;
|
|
1130
|
+
healthStatus: string | null;
|
|
1131
|
+
categories: string[];
|
|
1132
|
+
jsonVersion: string | null;
|
|
1133
|
+
/** LOCAL id of the Flow this one was cloned FROM. Points backwards in the chain. */
|
|
1134
|
+
clonedFromFlowId: string | null;
|
|
1135
|
+
/** LOCAL id of the Flow that replaced this one. Points forwards in the chain. */
|
|
1136
|
+
supersededByFlowId: string | null;
|
|
1137
|
+
createdAt: string;
|
|
1138
|
+
updatedAt: string;
|
|
1139
|
+
};
|
|
1140
|
+
/**
|
|
1141
|
+
* `page` ≥ 1 (default 1), `pageSize` in [1, 100] (default 30).
|
|
1142
|
+
*
|
|
1143
|
+
* ⚠️ `page * pageSize` above 100 000 is refused with 400 `FLOW_INVALID_PAGINATION`
|
|
1144
|
+
* — deep offsets scan and discard everything before them.
|
|
1145
|
+
*/
|
|
1146
|
+
export type FlowListParams = {
|
|
1147
|
+
page?: number;
|
|
1148
|
+
pageSize?: number;
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* ⚠️ An ENVELOPE, unlike `GET /v1/templates`, which answers a bare array. Flows is
|
|
1152
|
+
* a newer surface and starts at the paginated default on purpose.
|
|
1153
|
+
*/
|
|
1154
|
+
export type FlowListResult = {
|
|
1155
|
+
flows: Flow[];
|
|
1156
|
+
total: number;
|
|
1157
|
+
page: number;
|
|
1158
|
+
pageSize: number;
|
|
1159
|
+
totalPages: number;
|
|
1160
|
+
};
|
|
1161
|
+
export type CreateFlowInput = {
|
|
1162
|
+
name: string;
|
|
1163
|
+
/** Non-empty. Every value must be a {@link FlowCategory}. */
|
|
1164
|
+
categories: readonly FlowCategory[];
|
|
1165
|
+
/**
|
|
1166
|
+
* The LOCAL id (`Flow.id`) of the Flow to clone — ⛔ NEVER the `metaFlowId`.
|
|
1167
|
+
*
|
|
1168
|
+
* This is the mistake the API cannot catch for you: both are opaque strings, so
|
|
1169
|
+
* a `metaFlowId` here resolves to no row of ours and comes back as 404
|
|
1170
|
+
* `FLOW_NOT_FOUND` naming a Flow you can see in Flow Manager. Our resolver runs
|
|
1171
|
+
* `where: { id, tenantId }` and sends the resulting `metaFlowId` on to Meta, so
|
|
1172
|
+
* the local id is also what proves ownership.
|
|
1173
|
+
*
|
|
1174
|
+
* ⚠️ Cloning is the ONLY way to revise a published Flow: Meta never lets a
|
|
1175
|
+
* published Flow be edited again. `clonedFromFlowId` on the clone and
|
|
1176
|
+
* `supersededByFlowId` on the original are the two ends of that chain.
|
|
1177
|
+
*/
|
|
1178
|
+
cloneFromFlowId?: string;
|
|
1179
|
+
};
|
|
1180
|
+
/** 201 from `POST /v1/flows`. `id` is LOCAL; `metaFlowId` is Meta's. */
|
|
1181
|
+
export type FlowCreated = {
|
|
1182
|
+
id: string;
|
|
1183
|
+
metaFlowId: string;
|
|
1184
|
+
};
|
|
1185
|
+
/** At least one of the two is required — an empty patch is 400 `FLOW_PATCH_EMPTY`. */
|
|
1186
|
+
export type UpdateFlowInput = {
|
|
1187
|
+
name?: string;
|
|
1188
|
+
categories?: readonly FlowCategory[];
|
|
1189
|
+
};
|
|
1190
|
+
export type FlowUpdateResult = {
|
|
1191
|
+
ok: true;
|
|
1192
|
+
id: string;
|
|
1193
|
+
};
|
|
1194
|
+
export type FlowDeleteResult = {
|
|
1195
|
+
ok: true;
|
|
1196
|
+
id: string;
|
|
1197
|
+
deleted: true;
|
|
1198
|
+
};
|
|
1199
|
+
/**
|
|
1200
|
+
* 200 from `POST /v1/flows/{id}/json`.
|
|
1201
|
+
*
|
|
1202
|
+
* ⛔ `validationErrors` is ALWAYS `[]` here. A non-empty list never arrives as a
|
|
1203
|
+
* 200 on our API — it arrives as a THROWN 422; see
|
|
1204
|
+
* {@link FlowJsonValidationFailure} and `flowJsonValidationErrors`.
|
|
1205
|
+
*/
|
|
1206
|
+
export type FlowJsonUploadResult = {
|
|
1207
|
+
id: string;
|
|
1208
|
+
validationErrors: [];
|
|
1209
|
+
};
|
|
1210
|
+
/**
|
|
1211
|
+
* The body of the 422 `FLOW_JSON_INVALID` that a rejected Flow JSON throws.
|
|
1212
|
+
*
|
|
1213
|
+
* ⚠️ `validationErrors` is Meta's own list, VERBATIM and untyped: it names the
|
|
1214
|
+
* line and the refused component, its shape belongs to Meta, and they change it
|
|
1215
|
+
* without telling us. Read it, print it, do not branch on its internals.
|
|
1216
|
+
*/
|
|
1217
|
+
export type FlowJsonValidationFailure = {
|
|
1218
|
+
error: string;
|
|
1219
|
+
errorEN: string;
|
|
1220
|
+
code: "FLOW_JSON_INVALID";
|
|
1221
|
+
validationErrors: unknown[];
|
|
1222
|
+
};
|
|
1223
|
+
/**
|
|
1224
|
+
* ⛔ `confirm` is the literal `true` and it is REQUIRED. Publishing is
|
|
1225
|
+
* irreversible on Meta: a published Flow is never edited again, only cloned.
|
|
1226
|
+
*/
|
|
1227
|
+
export type FlowPublishInput = {
|
|
1228
|
+
confirm: true;
|
|
1229
|
+
};
|
|
1230
|
+
export type FlowPublishResult = {
|
|
1231
|
+
flowId: string;
|
|
1232
|
+
published: true;
|
|
1233
|
+
};
|
|
1234
|
+
export type FlowDeprecateInput = {
|
|
1235
|
+
/**
|
|
1236
|
+
* The LOCAL id (`Flow.id`) of the successor — ⛔ NEVER the `metaFlowId`.
|
|
1237
|
+
*
|
|
1238
|
+
* A `metaFlowId` here writes a pointer that resolves to no row of ours, so the
|
|
1239
|
+
* version chain ends silently at this Flow. It is the forward half of the pair
|
|
1240
|
+
* `clonedFromFlowId` opens.
|
|
1241
|
+
*
|
|
1242
|
+
* Optional on purpose: deprecating with no successor is legitimate (the Flow
|
|
1243
|
+
* left circulation and nothing replaces it). Omit the field — sending `""` or
|
|
1244
|
+
* `null` is refused with 400 rather than read as "no successor".
|
|
1245
|
+
*/
|
|
1246
|
+
supersededByFlowId?: string;
|
|
1247
|
+
};
|
|
1248
|
+
export type FlowDeprecateResult = {
|
|
1249
|
+
flowId: string;
|
|
1250
|
+
deprecated: true;
|
|
1251
|
+
/** Echoed always, `null` included, so "recorded" is distinguishable from "dropped". */
|
|
1252
|
+
supersededBy: string | null;
|
|
1253
|
+
};
|
|
1254
|
+
/** One submitted form. Every id here is LOCAL except `externalMessageId`. */
|
|
1255
|
+
export type FlowResponse = {
|
|
1256
|
+
id: string;
|
|
1257
|
+
/** LOCAL id of the Flow this was read through. */
|
|
1258
|
+
flowId: string;
|
|
1259
|
+
/**
|
|
1260
|
+
* `null` once the SESSION's own retention window closed (37 days from the send)
|
|
1261
|
+
* or its row was pruned — the answer outlives the phone by design.
|
|
1262
|
+
*/
|
|
1263
|
+
contactPhone: string | null;
|
|
1264
|
+
flowToken: string;
|
|
1265
|
+
/** Meta's `wamid` — a PROVIDER id, which is why it is not called `messageId`. */
|
|
1266
|
+
externalMessageId: string;
|
|
1267
|
+
/** The submitted form, already parsed. `null` when the stored payload was corrupt. */
|
|
1268
|
+
response: Record<string, unknown> | null;
|
|
1269
|
+
receivedAt: string;
|
|
1270
|
+
/** When this answer stops being readable (30 days from arrival). */
|
|
1271
|
+
expiresAt: string;
|
|
1272
|
+
};
|
|
1273
|
+
export type FlowResponseListParams = FlowListParams;
|
|
1274
|
+
export type FlowResponseListResult = {
|
|
1275
|
+
responses: FlowResponse[];
|
|
1276
|
+
total: number;
|
|
1277
|
+
page: number;
|
|
1278
|
+
pageSize: number;
|
|
1279
|
+
totalPages: number;
|
|
1280
|
+
/**
|
|
1281
|
+
* `"FLOW_RESPONSES_WINDOW_TRUNCATED"` when the Flow has minted more sends than
|
|
1282
|
+
* one request will correlate. ⚠️ The page is then SHORT — treat it as "there may
|
|
1283
|
+
* be more", never as "these are all the submissions".
|
|
1284
|
+
*/
|
|
1285
|
+
notice?: string;
|
|
1286
|
+
};
|
|
1287
|
+
/**
|
|
1288
|
+
* ⛔ FOUR values, and `UNKNOWN` is not `NOT_SET`. `NOT_SET` is Meta answering that
|
|
1289
|
+
* it holds no key; `UNKNOWN` is us failing to ask. Collapsing them makes an
|
|
1290
|
+
* operator rotate over a transient Graph 500 — and rotating breaks every
|
|
1291
|
+
* `data_exchange` Flow on the number.
|
|
1292
|
+
*/
|
|
1293
|
+
export type FlowEndpointKeyMetaStatus = "VALID" | "MISMATCH" | "NOT_SET" | "UNKNOWN";
|
|
1294
|
+
/**
|
|
1295
|
+
* The `data_exchange` endpoint keypair of ONE number.
|
|
1296
|
+
*
|
|
1297
|
+
* ⚠️ `endpointUrl` IS A CREDENTIAL. Meta signs nothing and sends no key, so the
|
|
1298
|
+
* endpoint authenticates callers by decrypting the body — and the other half of
|
|
1299
|
+
* that pair is published here and by Meta. Anyone holding this URL plus the public
|
|
1300
|
+
* key can forge a request we will decrypt and forward to your webhook carrying our
|
|
1301
|
+
* signature. That is why these two methods need `flows:manage` and not
|
|
1302
|
+
* `flows:read`, and why `endpointUrl` never appears in the Flow listing.
|
|
1303
|
+
*
|
|
1304
|
+
* The PRIVATE half is never in this payload, on either verb.
|
|
1305
|
+
*/
|
|
1306
|
+
export type FlowEndpointKeyStatus = {
|
|
1307
|
+
configured: boolean;
|
|
1308
|
+
/** PEM. Public by definition — this is the half Meta holds. */
|
|
1309
|
+
publicKey: string | null;
|
|
1310
|
+
/** ISO-8601, or `null` when we hold a pair Meta never accepted. */
|
|
1311
|
+
uploadedAt: string | null;
|
|
1312
|
+
endpointUrl: string | null;
|
|
1313
|
+
metaStatus: FlowEndpointKeyMetaStatus;
|
|
1314
|
+
};
|
|
1315
|
+
export type FlowEndpointKeyRotateInput = {
|
|
1316
|
+
/**
|
|
1317
|
+
* ⛔ REQUIRED exactly when a key of ours is already live at Meta, because the
|
|
1318
|
+
* call then DESTROYS it. See `FlowsResource.rotateEndpointKey`.
|
|
1319
|
+
*/
|
|
1320
|
+
confirm?: true;
|
|
1321
|
+
};
|
|
1322
|
+
export type FlowEndpointKeyRotateResult = FlowEndpointKeyStatus & {
|
|
1323
|
+
/** `uploadedAt` is never `null` on a successful rotate — it was just stamped. */
|
|
1324
|
+
uploadedAt: string;
|
|
1325
|
+
/**
|
|
1326
|
+
* ⛔ `true` means the key that was working IS GONE and every Flow whose
|
|
1327
|
+
* `endpoint_uri` answered with the old pair now answers with the new one. That
|
|
1328
|
+
* sentence is not derivable from the 200.
|
|
1329
|
+
*/
|
|
1330
|
+
replaced: boolean;
|
|
1331
|
+
};
|
|
554
1332
|
//# sourceMappingURL=types.d.ts.map
|