@pilot-status/sdk 0.9.0 → 0.11.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 CHANGED
@@ -2,6 +2,91 @@
2
2
 
3
3
  All notable changes to `@pilot-status/sdk`.
4
4
 
5
+ ## 0.11.0 - 2026-10-03
6
+
7
+ ### Added
8
+
9
+ - **Phone lines: `client.phoneLines`.** Tenant-scoped API key only.
10
+ - `phoneLines.verification.get()` — `GET /v1/phone-lines/verification`.
11
+ - `phoneLines.verification.start(params, { idempotencyKey })` — `POST
12
+ /v1/phone-lines/verification`. `idempotencyKey` is required and sent as
13
+ `Idempotency-Key`; reuse the same key when retrying. Resolves to
14
+ `{ state: VerificationState, replayed: boolean }` (`replayed` is `true` only when the
15
+ server answered `Idempotent-Replayed: true`; `state` is the response body untouched),
16
+ the same shape as the Python SDK.
17
+ - `phoneLines.verification.sendContactCode(channel)` and
18
+ `phoneLines.verification.confirmContact(channel, code)` — `channel` is `"whatsapp"` |
19
+ `"email"`.
20
+ - `phoneLines.verification.submitDocument(document)` — a `data:` URI.
21
+ - `phoneLines.getActivationAudio(activationId)` — `GET
22
+ /v1/phone-lines/activations/{id}/audio`, resolving to `{ data: ArrayBuffer, contentType,
23
+ contentLength, fileName }`. The recording speaks the activation code: do not log it.
24
+ - The verification routes need an OWNER's key (`phone_lines:purchase`); the audio needs
25
+ `phone_lines:read`.
26
+ - Types `VerificationState` (and its parts), `StartVerificationParams`,
27
+ `StartVerificationOptions`, `StartVerificationResult`, `ActivationAudio`.
28
+ - Phone-line webhook types: `PhoneLineWebhookEvent` (discriminated by `event`) and one type
29
+ per event (`PhoneLinePurchasedEvent` … `PhoneLineVerificationUpdatedEvent`). They are
30
+ separate from `CustomerWebhookEvent` and are **not** accepted by `parseCustomerWebhook`,
31
+ because they come from a separate webhook registry.
32
+ - Helpers `toDataUri(bytes, mimeType)` and `parseContentDispositionFileName(header)`.
33
+
34
+ ### Changed
35
+
36
+ - Internal: the HTTP client accepts per-request headers and reads binary bodies over the
37
+ same retry/timeout/error path. Requests made by existing methods send exactly the headers
38
+ they sent before.
39
+
40
+ ## 0.10.0 - 2026-09-21
41
+
42
+ Four changes: the `MessageDetails` fix below, plus three already merged since `0.9.0` and
43
+ never published. Those three describe behavior the API already has in production.
44
+
45
+ ### Fixed
46
+
47
+ - **`MessageDetails` (`messages.get()`) now matches what `GET /v1/messages/{id}` returns.**
48
+ The type was missing four fields:
49
+ - `errorCode` — the same closed set of failure codes as `GET /v1/messages` and the Logs
50
+ screen ([Log Error Codes](https://docs.pilotstatus.com.br/api/messages/log-error-codes)),
51
+ `null` when the message has no error. Branch on it instead of parsing `errorMessage`.
52
+ The set grows, so treat a code you do not know as "needs review".
53
+ Requires server release `20260921c` (in production since 2026-09-21). An older server omits the key, and at runtime
54
+ you get `undefined`, not `null`.
55
+ - `externalMessageId` — the provider's message id (Meta `wamid…`), `null` until the
56
+ provider has accepted the send.
57
+ - `origin` — which rail the send left by (`"API"`, `"MCP"`, `"CHATWOOT"`, `"CHAT"`,
58
+ `"DASHBOARD"`, `"SYSTEM"`), the same tag as `MessageLogEntry.origin`. `null` does not mean
59
+ inbound.
60
+ - `metaPricing` — what Meta billed for the message, in Meta's own words, as the new exported
61
+ type `MessageMetaPricing`. `null` until Meta reports it, and always on non-Meta numbers.
62
+
63
+ ⚠️ **`template` is now optional (`template?: string`).** It was declared as a required
64
+ `string`, but the key is absent whenever the send was not a template. Code that assigned it
65
+ straight to a `string` now fails to compile. The runtime value is the same as before; only
66
+ the type now admits that it can be missing.
67
+
68
+ ### Added
69
+
70
+ - **`flowToken` on `SendMessageAccepted`.** The 202 of `messages.send()` returns the Flow
71
+ token it minted, present ONLY when the message carries a Flow (a `flow` block, or a template
72
+ with a FLOW button) and absent otherwise. It is the same string as on the
73
+ `flow.response_received` webhook and `flows.listResponses()`, and the only key that joins
74
+ an answer back to the send that caused it.
75
+ - **`coexistence` on numbers, typed as `NumberCoexistence`.** `NumberDetail.coexistence` is
76
+ `null` on non-Meta numbers. `WhatsAppNumberListItem.coexistence` is present on Meta numbers
77
+ only. It gives a `status` (`CONFIRMED` | `LIKELY` | `NO` | `UNKNOWN`) and the `evidence` it
78
+ was decided from. Do not read `meta.phone.platformType` for this: a coexistence number
79
+ reports `CLOUD_API` there. `UNKNOWN` does not mean `NO`. `NumberCoexistence` is also exported
80
+ from the package root now (the type existed but could not be imported by name).
81
+
82
+ ### Changed
83
+
84
+ - **`historyImportEnabled` defaults to `true` for new numbers.** A number created without
85
+ `settings.historyImportEnabled` now imports the device history when it connects. Pass
86
+ `settings: { historyImportEnabled: false }` on `numbers.create()` to opt out. The history is
87
+ sent once, right after the connection, and cannot be requested later. Only the docs changed
88
+ in the SDK; the default itself lives on the server and is already in effect.
89
+
5
90
  ## 0.9.0 - 2026-09-10
6
91
 
7
92
  ### Blocos interativos: `list`, `carousel` e `flow`
@@ -20,15 +105,22 @@ a mensagem em silencio, entao o Pilot Status recusa com `FLOW_WINDOW_CLOSED` em
20
105
  a deixar desaparecer. Nao ha campo para `flowToken`: ele e gerado por mensagem, e um
21
106
  escolhido por quem chama deixaria uma conta reclamar as respostas de outra.
22
107
 
23
- ## Unreleased
108
+ ### Also in 0.9.0: Flow `submitted` answers and Flow attachments
24
109
 
25
- ⚠️ **Heading deliberately not a number.** `0.8.0` is on npm and `package.json` still declares
26
- `0.8.0`, so writing a version here would either backdate these fields into a release that
27
- does not contain them or announce a bump nothing has made — which is the exact mistake the
28
- `0.8.0` entry below is about. Whoever cuts the release renames this heading and bumps
29
- `package.json` in the same commit.
110
+ ⚠️ **Everything under this heading shipped in `0.9.0`.** It used to sit under an
111
+ `## Unreleased` heading that the `0.9.0` release commit did not rename, so the `0.9.0`
112
+ CHANGELOG on npm still calls it unreleased. The `0.9.0` tarball contains all of it
113
+ (`FlowSubmittedExchange`, `submitted`, `flowMedia`, `FlowResponseMedia`,
114
+ `FlowResponseMediaAttachment`) and the `0.8.0` tarball contains none of it. The note that
115
+ heading carried, kept as it was:
30
116
 
31
- ### Added
117
+ > ⚠️ **Heading deliberately not a number.** `0.8.0` is on npm and `package.json` still declares
118
+ > `0.8.0`, so writing a version here would either backdate these fields into a release that
119
+ > does not contain them or announce a bump nothing has made — which is the exact mistake the
120
+ > `0.8.0` entry below is about. Whoever cuts the release renames this heading and bumps
121
+ > `package.json` in the same commit.
122
+
123
+ #### Added
32
124
 
33
125
  - **What the person TYPED, on a `data_exchange` Flow.** `data.submitted` on the
34
126
  `flow.response_received` webhook, and `submitted` on every entry of
package/README.md CHANGED
@@ -325,6 +325,109 @@ await client.calls.play(call.id, "https://cdn.example.com/ivr-greeting.mp3");
325
325
  const session = await client.calls.realtimeSession(call.id, "talk");
326
326
  ```
327
327
 
328
+ ## Phone lines (`client.phoneLines`)
329
+
330
+ Every `/v1/phone-lines/*` route requires a **tenant-scoped** API key — a number-scoped key
331
+ is refused. The verification routes also require `phone_lines:purchase`, which only an
332
+ **OWNER**'s key has; the activation audio requires `phone_lines:read` (ADMIN and up).
333
+ These routes do not use `whatsappNumberId`.
334
+
335
+ ### Workspace verification (unlocks buying lines)
336
+
337
+ ```ts
338
+ import { randomUUID } from "node:crypto";
339
+ import { readFile } from "node:fs/promises";
340
+ import { toDataUri } from "@pilot-status/sdk";
341
+
342
+ const current = await client.phoneLines.verification.get();
343
+ // { status: "NONE" | "PENDING_CONTACT" | "NEEDS_DOCUMENT" | "IN_REVIEW" | "APPROVED" | "REJECTED",
344
+ // canPurchase, verification: null | { ...masked details } }
345
+
346
+ // Generate the key ONCE per submission and keep it: a retry must reuse it.
347
+ const idempotencyKey = randomUUID();
348
+ const started = await client.phoneLines.verification.start(
349
+ {
350
+ documentType: "CNPJ",
351
+ documentNumber: "12345678000199",
352
+ contactEmail: "ana@acme.com.br",
353
+ contactWhatsapp: "+55 11 99999-8888",
354
+ document: toDataUri(await readFile("contrato-social.pdf"), "application/pdf"),
355
+ },
356
+ { idempotencyKey },
357
+ );
358
+ console.log(started.state.status, started.replayed); // "PENDING_CONTACT", false
359
+
360
+ // Codes go to every channel in verification.contact.requiredChannels.
361
+ await client.phoneLines.verification.confirmContact("email", "123456");
362
+ await client.phoneLines.verification.confirmContact("whatsapp", "654321");
363
+
364
+ // Resend a code (60 s cooldown; codes expire in 10 min):
365
+ await client.phoneLines.verification.sendContactCode("whatsapp");
366
+
367
+ // When document.status is UNREADABLE/UNCLEAR, or status is NEEDS_DOCUMENT:
368
+ await client.phoneLines.verification.submitDocument(
369
+ toDataUri(await readFile("cartao-cnpj.png"), "image/png"),
370
+ );
371
+ ```
372
+
373
+ - **`Idempotency-Key` is required on `start()`** (the `idempotencyKey` option, ≤255 chars).
374
+ If the call times out or fails on the network, retry with the **same key**: the server
375
+ answers the current state (HTTP 200, `Idempotent-Replayed: true` → `replayed: true`;
376
+ `start()` resolves to `{ state, replayed }`)
377
+ instead of starting again and re-sending codes. The same key with a different body is
378
+ `409 IDEMPOTENCY_KEY_REUSED`; while the first request is still running, `409
379
+ IDEMPOTENCY_KEY_IN_USE`. The SDK never retries a POST on its own.
380
+ - The path argument of `sendContactCode()` / `confirmContact()` is lower-case (`"whatsapp"`
381
+ | `"email"`), while the channels inside the state are UPPERCASE (`"WHATSAPP"` | `"EMAIL"`).
382
+ - `document` is a `data:<mime>;base64,...` URI (PDF, JPG, PNG or WEBP, up to 10 MB).
383
+ `toDataUri(bytes, mime)` builds it from a `Buffer`/`Uint8Array`.
384
+ - Starts and document submissions share a limit of 10 per hour per workspace
385
+ (`429 RATE_LIMITED`, `retryAfterSeconds` in the body). Errors carry `body.code`.
386
+
387
+ ### Activation audio
388
+
389
+ ```ts
390
+ import { writeFile } from "node:fs/promises";
391
+
392
+ const audio = await client.phoneLines.getActivationAudio(activationId);
393
+ // { data: ArrayBuffer, contentType: "audio/mpeg", contentLength: 48213, fileName: "activation-<id>.mp3" }
394
+ await writeFile(audio.fileName ?? "activation.mp3", new Uint8Array(audio.data));
395
+ ```
396
+
397
+ ⛔ **The recording speaks the activation code, which is a credential.** Do not log the
398
+ bytes, do not put them in a public bucket or an inline player on a shared page. An unknown
399
+ id, another workspace's id, a request without a recording and a line already returned or
400
+ canceled are all `404 ACTIVATION_NOT_FOUND` (`NotFoundError`). This is the URL the
401
+ `audioUrl` field of the phone-line webhooks points to.
402
+
403
+ ### Phone-line webhooks
404
+
405
+ Phone-line events come from a **separate webhook registry** and are **not** handled by
406
+ `parseCustomerWebhook`. They are signed the same way (`x-pilot-status-signature`,
407
+ HMAC-SHA256 hex over the raw body), keyed with the phone-line webhook secret (`plwh_...`),
408
+ so `verifyWebhookSignature` works with that secret. The body is
409
+ `{ id, event, createdAt, data }`, typed as the discriminated union `PhoneLineWebhookEvent`:
410
+
411
+ ```ts
412
+ import type { PhoneLineWebhookEvent } from "@pilot-status/sdk";
413
+
414
+ const event = JSON.parse(raw) as PhoneLineWebhookEvent; // after verifying the signature
415
+ switch (event.event) {
416
+ case "phone_line.code_received":
417
+ console.log(event.data.code, event.data.audioUrl); // audioUrl: string | null
418
+ break;
419
+ case "phone_line.returned":
420
+ console.log(event.data.reason); // "unpaid" | "canceled_by_customer" | "verification_rejected"
421
+ break;
422
+ }
423
+ ```
424
+
425
+ Events: `phone_line.purchased`, `phone_line.audio_received`, `phone_line.code_received`,
426
+ `phone_line.code_failed`, `phone_line.renewed`, `phone_line.payment_failed`,
427
+ `phone_line.suspended`, `phone_line.returned`, `phone_line.canceled`,
428
+ `phone_line.verification_updated`. `name` is the line's display name (the formatted
429
+ number when the line has none).
430
+
328
431
  ## Receiving webhooks (verify, then parse)
329
432
 
330
433
  `parseCustomerWebhook` proves the **shape** of an event, nothing else — anyone on
package/dist/client.d.ts CHANGED
@@ -10,6 +10,7 @@ import { MessagesResource } from "./resources/messages.js";
10
10
  import { MetaResource } from "./resources/meta.js";
11
11
  import { ApiKeysResource } from "./resources/api-keys.js";
12
12
  import { NumbersResource } from "./resources/numbers.js";
13
+ import { PhoneLinesResource } from "./resources/phone-lines.js";
13
14
  import { ServiceWindowResource } from "./resources/service-window.js";
14
15
  import { SubscriptionResource } from "./resources/subscription.js";
15
16
  import { TemplatesResource } from "./resources/templates.js";
@@ -67,6 +68,8 @@ export declare class PilotStatusClient {
67
68
  readonly subscription: SubscriptionResource;
68
69
  readonly chatwoot: ChatwootResource;
69
70
  readonly workspace: WorkspaceResource;
71
+ /** Phone lines (`/v1/phone-lines/*`) — tenant-scoped key only. */
72
+ readonly phoneLines: PhoneLinesResource;
70
73
  constructor(options: PilotStatusClientOptions);
71
74
  /**
72
75
  * A sibling client pointed at ANOTHER number — this is the per-call override of
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,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e,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;gBAI5B,OAAO,EAAE,wBAAwB;IA8C7C;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,iBAAiB;CAGxD"}
package/dist/client.js CHANGED
@@ -10,6 +10,7 @@ import { MessagesResource } from "./resources/messages.js";
10
10
  import { MetaResource } from "./resources/meta.js";
11
11
  import { ApiKeysResource } from "./resources/api-keys.js";
12
12
  import { NumbersResource } from "./resources/numbers.js";
13
+ import { PhoneLinesResource } from "./resources/phone-lines.js";
13
14
  import { ServiceWindowResource } from "./resources/service-window.js";
14
15
  import { SubscriptionResource } from "./resources/subscription.js";
15
16
  import { TemplatesResource } from "./resources/templates.js";
@@ -44,6 +45,8 @@ export class PilotStatusClient {
44
45
  subscription;
45
46
  chatwoot;
46
47
  workspace;
48
+ /** Phone lines (`/v1/phone-lines/*`) — tenant-scoped key only. */
49
+ phoneLines;
47
50
  #options;
48
51
  constructor(options) {
49
52
  this.#options = options;
@@ -81,6 +84,7 @@ export class PilotStatusClient {
81
84
  this.subscription = new SubscriptionResource(http);
82
85
  this.chatwoot = new ChatwootResource(http);
83
86
  this.workspace = new WorkspaceResource(http);
87
+ this.phoneLines = new PhoneLinesResource(http);
84
88
  }
85
89
  /**
86
90
  * A sibling client pointed at ANOTHER number — this is the per-call override of
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,E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,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,gBAAwB;QACjC,OAAO,IAAI,iBAAiB,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACvE,CAAC;CACF"}
package/dist/http.d.ts CHANGED
@@ -18,9 +18,30 @@ export type HttpRequest = {
18
18
  path: string;
19
19
  query?: Record<string, string | number | boolean | undefined | null>;
20
20
  body?: unknown;
21
+ /**
22
+ * Extra headers for THIS request only (e.g. `Idempotency-Key`). Applied after
23
+ * the client defaults. Absent on every pre-existing call site, which therefore
24
+ * sends exactly the headers it always did.
25
+ */
26
+ headers?: Record<string, string>;
27
+ };
28
+ /** A JSON body together with the response headers that came with it. */
29
+ export type JsonResponse<T> = {
30
+ body: T;
31
+ headers: Headers;
32
+ };
33
+ /**
34
+ * A 2xx body read as raw bytes. The bytes are never logged nor parsed here — the
35
+ * caller decides what they are.
36
+ */
37
+ export type BinaryResponse = {
38
+ data: ArrayBuffer;
39
+ headers: Headers;
21
40
  };
22
41
  export declare function createHttpClient(options: HttpClientOptions): {
23
42
  requestJson: <T>(req: HttpRequest) => Promise<T>;
43
+ requestJsonWithHeaders: <T>(req: HttpRequest) => Promise<JsonResponse<T>>;
44
+ requestBinary: (req: HttpRequest, accept: string) => Promise<BinaryResponse>;
24
45
  };
25
46
  export type HttpClient = ReturnType<typeof createHttpClient>;
26
47
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACrE,IA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AC;CACpB,CAAC;AA+CF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB;kBAyG5B,CAAC,OAAO,WAAW,KAAG,OAAO,CAAC,CAAC,CAAC;6BAPrB,CAAC,OAAO,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;yBAelD,WAAW,UAAU,MAAM,KAAG,OAAO,CAAC,cAAc,CAAC;EAQ1F;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
package/dist/http.js CHANGED
@@ -46,13 +46,19 @@ function shouldRetryRequest(method, status) {
46
46
  }
47
47
  export function createHttpClient(options) {
48
48
  const baseUrl = normalizeBaseUrl(options.baseUrl);
49
- async function requestJson(req) {
49
+ /**
50
+ * The single transport path: url, headers, timeout, retry and the typed error
51
+ * on non-2xx. Only what happens to a 2xx body differs between callers, and
52
+ * that is `readOk`. A non-2xx is ALWAYS read as text and parsed as JSON, so a
53
+ * binary route's JSON error raises the same typed error as any JSON route.
54
+ */
55
+ async function send(req, accept, readOk) {
50
56
  const url = buildUrl(baseUrl, req.path, req.query);
51
57
  const controller = new AbortController();
52
58
  const timeout = setTimeout(() => controller.abort(), options.timeoutMs);
53
59
  const headers = {
54
60
  "x-api-key": options.apiKey,
55
- Accept: "application/json",
61
+ Accept: accept,
56
62
  };
57
63
  if (options.userAgent) {
58
64
  headers["user-agent"] = options.userAgent;
@@ -65,6 +71,9 @@ export function createHttpClient(options) {
65
71
  headers["content-type"] = "application/json";
66
72
  body = JSON.stringify(req.body);
67
73
  }
74
+ if (req.headers) {
75
+ Object.assign(headers, req.headers);
76
+ }
68
77
  const doFetch = async () => {
69
78
  const res = await options.fetch(url, {
70
79
  method: req.method,
@@ -80,9 +89,9 @@ export function createHttpClient(options) {
80
89
  while (true) {
81
90
  try {
82
91
  const res = await doFetch();
83
- const raw = await res.text();
84
- const parsed = parseJsonIfPossible(raw);
85
92
  if (!res.ok) {
93
+ const raw = await res.text();
94
+ const parsed = parseJsonIfPossible(raw);
86
95
  const message = typeof parsed?.error === "string"
87
96
  ? String(parsed.error)
88
97
  : `HTTP ${res.status}`;
@@ -96,7 +105,7 @@ export function createHttpClient(options) {
96
105
  headers: headersToRecord(res.headers),
97
106
  });
98
107
  }
99
- return parsed;
108
+ return await readOk(res);
100
109
  }
101
110
  catch (err) {
102
111
  if (attempt >= maxRetries ||
@@ -114,6 +123,25 @@ export function createHttpClient(options) {
114
123
  clearTimeout(timeout);
115
124
  }
116
125
  }
117
- return { requestJson };
126
+ async function requestJsonWithHeaders(req) {
127
+ return send(req, "application/json", async (res) => ({
128
+ body: parseJsonIfPossible(await res.text()),
129
+ headers: res.headers,
130
+ }));
131
+ }
132
+ async function requestJson(req) {
133
+ return (await requestJsonWithHeaders(req)).body;
134
+ }
135
+ /**
136
+ * A route that answers raw bytes on 2xx (and a JSON error otherwise). Same
137
+ * retry, timeout and typed errors as {@link requestJson}.
138
+ */
139
+ async function requestBinary(req, accept) {
140
+ return send(req, accept, async (res) => ({
141
+ data: await res.arrayBuffer(),
142
+ headers: res.headers,
143
+ }));
144
+ }
145
+ return { requestJson, requestJsonWithHeaders, requestBinary };
118
146
  }
119
147
  //# sourceMappingURL=http.js.map
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA0B9C,SAAS,gBAAgB,CAAC,OAAe;IACrC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,IAAY;IAC1C,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,UAAU,IAAI,IAAI,EAAE,CAAC;IAC1D,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AC,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YACjD,IAAI,EAAE,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM;YAChD,OAAO,EAAE,GAAG,CAAC,OAAO;SACvB,CAAC,CAAC,CAAC;IACR,CAAC;IAED,KAAK,UAAU,WAAW,CAAI,GAAgB;QAC1C,OAAO,CAAC,MAAM,sBAAsB,CAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,KAAK,UAAU,aAAa,CAAC,GAAgB,EAAE,MAAc;QACzD,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YACrC,IAAI,EAAE,MAAM,GAAG,CAAC,WAAW,EAAE;YAC7B,OAAO,EAAE,GAAG,CAAC,OAAO;SACvB,CAAC,CAAC,CAAC;IACR,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAClE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,8 +8,10 @@ export { NUMBER_STATUS_FAILURE_CODES } from "./types.js";
8
8
  * ONLY place that list is reachable — see its own docblock.
9
9
  */
10
10
  export { flowJsonValidationErrors } from "./resources/flows.js";
11
- export type { MessageStatus, Button, ButtonType, MarketingOptions, SendMessageInput, SendMessageHeader, SendMessageAccepted, MessageDetails, MessageLogDirection, MessageLogEntry, MessageListParams, MessageListResult, GroupMessagesParams, GroupMessagesResult, UnreadMessagesParams, UnreadMessagesResult, MarkReadResult, TypingState, TypingInput, TypingResult, DashboardStats, ApiKeyCreated, ApiKeyListItem, ApiKeyListResult, NumberApiKeyReveal, RegeneratedNumberKey, WhatsAppNumberInstance, WhatsAppNumberListItem, NumberListItemApiKeyRef, CreateNumberInput, CreateNumberResult, CreateMetaNumberInput, CheckNumbersInput, CheckNumbersResult, NumberConnectResult, NumberStatusResult, NumberStatusFailureCode, NumberDetail, NumberSettings, NumberSettingsInput, NumberSettingsSync, NumberPiiInput, NumberLogoutResult, NumberRestoreResult, NumberPurgeResult, UpdateNumberInput, UpdateNumberResult, ChatHistoryMedia, ChatHistoryMessage, MessageHistoryParams, MessageHistoryResult, NumberLinkBundle, RemotePairingInput, RemotePairingResult, RemotePairingInfo, RemotePairingStatus, RemotePairingConnectResult, CancelMessagesResult, DeleteNumberResult, TemplateCategory, TemplateExamples, TemplateListItem, TemplateDetail, CreateTemplateInput, UpdateTemplateInput, TemplateDeleteResult, FlowCategory, Flow, FlowListParams, FlowListResult, CreateFlowInput, FlowCreated, UpdateFlowInput, FlowUpdateResult, FlowDeleteResult, FlowJsonUploadResult, FlowJsonValidationFailure, FlowPublishInput, FlowPublishResult, FlowDeprecateInput, FlowDeprecateResult, FlowResponse, FlowResponseMedia, FlowSubmittedExchange, FlowResponseListParams, FlowResponseListResult, FlowEndpointKeyMetaStatus, FlowEndpointKeyStatus, FlowEndpointKeyRotateInput, FlowEndpointKeyRotateResult, GroupListItem, GroupDetail, GroupParticipant, CreateGroupInput, GroupActionResult, GroupInviteResult, GroupPinAction, NewsletterListItem, MediaDownloadResult, ConversationListParams, ConversationListResult, ConversationSummary, ServiceWindowType, ServiceWindowResult, MetaPricingParams, MetaPricingResult, Webhook, CreateWebhookInput, UpdateWebhookInput, WebhookDeleteResult, WebhookLogsParams, WebhookLogEntry, BrandingInput, BrandingResult, EmbedSurface, EmbedSessionInput, EmbedSessionResult, CheckoutPurpose, CheckoutInput, CheckoutResult, ExtraNumbersPreview, ExtraNumbersPurchaseResult, ExtraNumbersScheduleResult, ChatwootChannelMode, ChatwootStatus, ChatwootConnectInput, ChatwootUpdateInput, ChatwootTestInput, ChatwootTestResult, ChatwootHistoryReplayInput, ChatwootHistoryReplayState, WorkspaceRole, WorkspaceMemberStatus, WorkspaceDetail, WorkspaceMember, WorkspaceMemberList, CallDirection, CallStatus, CallDetails, CallInitiateInput, CallInitiateAccepted, CallActionResult, CallListResult, CallingSettingsResult, CallSettingsUpdateInput, CallSettingsUpdateResult, CallPermissionResult, CallPermissionRequestInput, CallPermissionRequestResult, CallRealtimeSessionMode, CallRealtimeSessionResult, } from "./types.js";
12
- export type { CustomerWebhookEvent, WhatsAppMessageType, MessageSentEvent, MessageDeliveredEvent, MessageReadEvent, MessageFailedEvent, MessageReplyEvent, MessageReceivedEvent, MessageGroupEvent, MessageNewsletterEvent, NumberCreatedEvent, NumberConnectedEvent, NumberDisconnectedEvent, NumberRemovedEvent, CallRingingEvent, CallConnectedEvent, CallEndedEvent, CallMissedEvent, CallPermissionUpdatedEvent, EvolutionGoCallEventData, EvolutionGoCallOfferEvent, EvolutionGoCallAcceptEvent, EvolutionGoCallTerminateEvent, EvolutionGoCallEvent, FlowResponseReceivedEvent, FlowResponseReceivedEventData, FlowResponseMediaAttachment, } from "./webhooks/types.js";
11
+ /** Phone lines: the resource classes, the `data:` URI helper and the `Content-Disposition` parser. */
12
+ export { PhoneLinesResource, PhoneLineVerificationResource, toDataUri, parseContentDispositionFileName, } from "./resources/phone-lines.js";
13
+ export type { MessageStatus, Button, ButtonType, MarketingOptions, SendMessageInput, SendMessageHeader, SendMessageAccepted, MessageDetails, MessageMetaPricing, MessageLogDirection, MessageLogEntry, MessageListParams, MessageListResult, GroupMessagesParams, GroupMessagesResult, UnreadMessagesParams, UnreadMessagesResult, MarkReadResult, TypingState, TypingInput, TypingResult, DashboardStats, ApiKeyCreated, ApiKeyListItem, ApiKeyListResult, NumberApiKeyReveal, RegeneratedNumberKey, WhatsAppNumberInstance, WhatsAppNumberListItem, NumberListItemApiKeyRef, NumberCoexistence, CreateNumberInput, CreateNumberResult, CreateMetaNumberInput, CheckNumbersInput, CheckNumbersResult, NumberConnectResult, NumberStatusResult, NumberStatusFailureCode, NumberDetail, NumberSettings, NumberSettingsInput, NumberSettingsSync, NumberPiiInput, NumberLogoutResult, NumberRestoreResult, NumberPurgeResult, UpdateNumberInput, UpdateNumberResult, ChatHistoryMedia, ChatHistoryMessage, MessageHistoryParams, MessageHistoryResult, NumberLinkBundle, RemotePairingInput, RemotePairingResult, RemotePairingInfo, RemotePairingStatus, RemotePairingConnectResult, CancelMessagesResult, DeleteNumberResult, TemplateCategory, TemplateExamples, TemplateListItem, TemplateDetail, CreateTemplateInput, UpdateTemplateInput, TemplateDeleteResult, FlowCategory, Flow, FlowListParams, FlowListResult, CreateFlowInput, FlowCreated, UpdateFlowInput, FlowUpdateResult, FlowDeleteResult, FlowJsonUploadResult, FlowJsonValidationFailure, FlowPublishInput, FlowPublishResult, FlowDeprecateInput, FlowDeprecateResult, FlowResponse, FlowResponseMedia, FlowSubmittedExchange, FlowResponseListParams, FlowResponseListResult, FlowEndpointKeyMetaStatus, FlowEndpointKeyStatus, FlowEndpointKeyRotateInput, FlowEndpointKeyRotateResult, GroupListItem, GroupDetail, GroupParticipant, CreateGroupInput, GroupActionResult, GroupInviteResult, GroupPinAction, NewsletterListItem, MediaDownloadResult, ConversationListParams, ConversationListResult, ConversationSummary, ServiceWindowType, ServiceWindowResult, MetaPricingParams, MetaPricingResult, Webhook, CreateWebhookInput, UpdateWebhookInput, WebhookDeleteResult, WebhookLogsParams, WebhookLogEntry, BrandingInput, BrandingResult, EmbedSurface, EmbedSessionInput, EmbedSessionResult, CheckoutPurpose, CheckoutInput, CheckoutResult, ExtraNumbersPreview, ExtraNumbersPurchaseResult, ExtraNumbersScheduleResult, ChatwootChannelMode, ChatwootStatus, ChatwootConnectInput, ChatwootUpdateInput, ChatwootTestInput, ChatwootTestResult, ChatwootHistoryReplayInput, ChatwootHistoryReplayState, WorkspaceRole, WorkspaceMemberStatus, WorkspaceDetail, WorkspaceMember, WorkspaceMemberList, CallDirection, CallStatus, CallDetails, CallInitiateInput, CallInitiateAccepted, CallActionResult, CallListResult, CallingSettingsResult, CallSettingsUpdateInput, CallSettingsUpdateResult, CallPermissionResult, CallPermissionRequestInput, CallPermissionRequestResult, CallRealtimeSessionMode, CallRealtimeSessionResult, VerificationStatus, VerificationDocumentType, VerificationContactChannel, VerificationContactChannelPath, VerificationDocumentStatus, VerificationReviewReason, VerificationDetails, VerificationState, StartVerificationParams, StartVerificationOptions, StartVerificationResult, ActivationAudio, } from "./types.js";
14
+ export type { CustomerWebhookEvent, WhatsAppMessageType, MessageSentEvent, MessageDeliveredEvent, MessageReadEvent, MessageFailedEvent, MessageReplyEvent, MessageReceivedEvent, MessageGroupEvent, MessageNewsletterEvent, NumberCreatedEvent, NumberConnectedEvent, NumberDisconnectedEvent, NumberRemovedEvent, CallRingingEvent, CallConnectedEvent, CallEndedEvent, CallMissedEvent, CallPermissionUpdatedEvent, EvolutionGoCallEventData, EvolutionGoCallOfferEvent, EvolutionGoCallAcceptEvent, EvolutionGoCallTerminateEvent, EvolutionGoCallEvent, FlowResponseReceivedEvent, FlowResponseReceivedEventData, FlowResponseMediaAttachment, PhoneLineWebhookEvent, PhoneLineWebhookEventName, PhoneLineReturnedReason, PhoneLinePurchasedEvent, PhoneLineAudioReceivedEvent, PhoneLineCodeReceivedEvent, PhoneLineCodeFailedEvent, PhoneLineRenewedEvent, PhoneLinePaymentFailedEvent, PhoneLineSuspendedEvent, PhoneLineReturnedEvent, PhoneLineCanceledEvent, PhoneLineVerificationUpdatedEvent, } from "./webhooks/types.js";
13
15
  export { parseCustomerWebhook, isCustomerWebhookEvent, CUSTOMER_WEBHOOK_EVENTS, } from "./webhooks/parse.js";
14
16
  export { verifyWebhookSignature, WEBHOOK_SIGNATURE_HEADER, } from "./webhooks/signature.js";
15
17
  export type { VerifyWebhookSignatureInput } from "./webhooks/signature.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,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eAAe,EACf,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // mutation-exempt-file: PURE RE-EXPORT BARREL — every non-blank line is `export … from`, ⚠️ (this used to say "209 lines" and the file had 219: a count in a justification rots the moment an export is added, and a reader who counts and finds a mismatch distrusts the whole exemption — or "verifies" it away. The claim is now the one that stays checkable no matter how the file grows.) with no statement, no expression and no branch to mutate. EVERY value it re-exports is ASSERTED in the test of the module it comes from — the list below is the claim, and it is checkable name by name (⚠️ this used to say "7"; measured 2026-09-06 there are SIX blocks carrying nineteen names, because `CUSTOMER_WEBHOOK_EVENTS` ships in the same block as `parseCustomerWebhook` even though a different test asserts it. A count that disagrees with the enumeration beside it makes a reader doubt both), so nothing here is unmeasured: `PilotStatusClient`/`DEFAULT_BASE_URL` in `client.test.ts`; the 10 error classes (`UnprocessableEntityError` included, 16 references, structural assertions on the prototype chain) in `errors.test.ts`; `NUMBER_STATUS_FAILURE_CODES` in `resources/resources.test.ts`, list asserted whole; `flowJsonValidationErrors` in `resources/flows.test.ts`; `parseCustomerWebhook`/`isCustomerWebhookEvent` in `webhooks/parse.test.ts`; `CUSTOMER_WEBHOOK_EVENTS` in `webhooks/readme-events.test.ts`, compared name-by-name against `README.md`; `verifyWebhookSignature`/`WEBHOOK_SIGNATURE_HEADER` in `webhooks/signature.test.ts`. Everything else it forwards is `export type`, erased before a mutant could exist. This is the declared escape hatch for the gate's OWN documented limit — `mutate-diff.mjs` does not follow barrels, so a barrel resolves to `index` and lands in `semTeste`; the same reason already excludes this exact file from `vitest.coverage.config.ts` ("pure re-export barrel"). A dropped export is caught by `tsc`, in this package and in every consumer, not by mutation.
1
+ // mutation-exempt-file: PURE RE-EXPORT BARREL — every non-blank line is `export … from`, ⚠️ (this used to say "209 lines" and the file had 219: a count in a justification rots the moment an export is added, and a reader who counts and finds a mismatch distrusts the whole exemption — or "verifies" it away. The claim is now the one that stays checkable no matter how the file grows.) with no statement, no expression and no branch to mutate. EVERY value it re-exports is ASSERTED in the test of the module it comes from — the list below is the claim, and it is checkable name by name (⚠️ this used to say "7"; measured 2026-09-06 there are SIX blocks carrying nineteen names, because `CUSTOMER_WEBHOOK_EVENTS` ships in the same block as `parseCustomerWebhook` even though a different test asserts it. A count that disagrees with the enumeration beside it makes a reader doubt both), so nothing here is unmeasured: `PilotStatusClient`/`DEFAULT_BASE_URL` in `client.test.ts`; the 10 error classes (`UnprocessableEntityError` included, 16 references, structural assertions on the prototype chain) in `errors.test.ts`; `NUMBER_STATUS_FAILURE_CODES` in `resources/resources.test.ts`, list asserted whole; `flowJsonValidationErrors` in `resources/flows.test.ts`; `parseCustomerWebhook`/`isCustomerWebhookEvent` in `webhooks/parse.test.ts`; `CUSTOMER_WEBHOOK_EVENTS` in `webhooks/readme-events.test.ts`, compared name-by-name against `README.md`; `verifyWebhookSignature`/`WEBHOOK_SIGNATURE_HEADER` in `webhooks/signature.test.ts`; `PhoneLinesResource`/`PhoneLineVerificationResource`/`toDataUri`/`parseContentDispositionFileName` in `resources/phone-lines.test.ts`. Everything else it forwards is `export type`, erased before a mutant could exist. This is the declared escape hatch for the gate's OWN documented limit — `mutate-diff.mjs` does not follow barrels, so a barrel resolves to `index` and lands in `semTeste`; the same reason already excludes this exact file from `vitest.coverage.config.ts` ("pure re-export barrel"). A dropped export is caught by `tsc`, in this package and in every consumer, not by mutation.
2
2
  export { PilotStatusClient, DEFAULT_BASE_URL } from "./client.js";
3
3
  export { PilotStatusError, PilotStatusHttpError, AuthenticationError, ValidationError, ForbiddenError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, ServerError, } from "./errors.js";
4
4
  export { NUMBER_STATUS_FAILURE_CODES } from "./types.js";
@@ -7,6 +7,8 @@ export { NUMBER_STATUS_FAILURE_CODES } from "./types.js";
7
7
  * ONLY place that list is reachable — see its own docblock.
8
8
  */
9
9
  export { flowJsonValidationErrors } from "./resources/flows.js";
10
+ /** Phone lines: the resource classes, the `data:` URI helper and the `Content-Disposition` parser. */
11
+ export { PhoneLinesResource, PhoneLineVerificationResource, toDataUri, parseContentDispositionFileName, } from "./resources/phone-lines.js";
10
12
  export { parseCustomerWebhook, isCustomerWebhookEvent, CUSTOMER_WEBHOOK_EVENTS, } from "./webhooks/parse.js";
11
13
  export { verifyWebhookSignature, WEBHOOK_SIGNATURE_HEADER, } from "./webhooks/signature.js";
12
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,67DAA67D;AAE77D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAEzD;;;GAGG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAyLhE,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,okEAAokE;AAEpkE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAEzD;;;GAGG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,sGAAsG;AACtG,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,SAAS,EACT,+BAA+B,GAChC,MAAM,4BAA4B,CAAC;AAoNpC,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { ActivationAudio, StartVerificationOptions, StartVerificationParams, StartVerificationResult, VerificationContactChannelPath, VerificationState } from "../types.js";
3
+ /**
4
+ * `filename` out of a `Content-Disposition` header — quoted (what the server sends,
5
+ * `attachment; filename="activation-<id>.mp3"`) or a bare token. `null` when the
6
+ * header or the parameter is absent.
7
+ */
8
+ export declare function parseContentDispositionFileName(header: string | null): string | null;
9
+ /**
10
+ * Workspace verification — the step that unlocks buying phone lines.
11
+ *
12
+ * Requires a TENANT-scoped key (a number-scoped key is refused) with the
13
+ * `phone_lines:purchase` permission, i.e. an OWNER's key.
14
+ */
15
+ export declare class PhoneLineVerificationResource {
16
+ #private;
17
+ constructor(http: HttpClient);
18
+ /** `GET /v1/phone-lines/verification` — the current state (`status: "NONE"` before any start). */
19
+ get(): Promise<VerificationState>;
20
+ /**
21
+ * `POST /v1/phone-lines/verification` — submits the registry document and the
22
+ * contacts, and sends a confirmation code to every required channel.
23
+ *
24
+ * `idempotencyKey` is REQUIRED and goes out as the `Idempotency-Key` header.
25
+ * Generate it once per logical submission and REUSE THE SAME KEY on retry (after
26
+ * a timeout, a network error or a 5xx): the server then answers the current state
27
+ * instead of starting again and re-sending the codes. That replay comes back as
28
+ * HTTP 200 with `Idempotent-Replayed: true`, surfaced here as `replayed: true`; a
29
+ * fresh start is HTTP 201 and `replayed: false`. Resolves to `{ state, replayed }`,
30
+ * where `state` is the response body untouched.
31
+ *
32
+ * The same key with a DIFFERENT body is refused (409 `IDEMPOTENCY_KEY_REUSED`);
33
+ * while the first request is still running a retry gets 409
34
+ * `IDEMPOTENCY_KEY_IN_USE`. While `PENDING_CONTACT`, a new start (with a new key)
35
+ * REPLACES the current one and the old codes stop working. This POST is never
36
+ * retried automatically by the SDK.
37
+ */
38
+ start(params: StartVerificationParams, options: StartVerificationOptions): Promise<StartVerificationResult>;
39
+ /**
40
+ * `POST /v1/phone-lines/verification/contact/{channel}/send` — (re)sends the
41
+ * code to one channel. 60 s cooldown (429 `CONTACT_CODE_COOLDOWN`); codes expire
42
+ * in 10 minutes.
43
+ */
44
+ sendContactCode(channel: VerificationContactChannelPath): Promise<VerificationState>;
45
+ /**
46
+ * `POST /v1/phone-lines/verification/contact/{channel}/confirm` with `{ code }`.
47
+ * Confirming the last required channel (with the document in) may move the
48
+ * verification to `APPROVED` or `IN_REVIEW`.
49
+ */
50
+ confirmContact(channel: VerificationContactChannelPath, code: string): Promise<VerificationState>;
51
+ /**
52
+ * `POST /v1/phone-lines/verification/document` with `{ document }` — a
53
+ * `data:<mime>;base64,...` URI (PDF/JPG/PNG/WEBP, ≤10 MB). Accepted while the
54
+ * document is `UNREADABLE`/`UNCLEAR` (status `PENDING_CONTACT`) or when the status
55
+ * is `NEEDS_DOCUMENT`; 409 `VERIFICATION_WRONG_STATE` otherwise.
56
+ */
57
+ submitDocument(document: string): Promise<VerificationState>;
58
+ }
59
+ /** Phone lines (`/v1/phone-lines/*`). Tenant-scoped keys only. */
60
+ export declare class PhoneLinesResource {
61
+ #private;
62
+ readonly verification: PhoneLineVerificationResource;
63
+ constructor(http: HttpClient);
64
+ /**
65
+ * `GET /v1/phone-lines/activations/{activationId}/audio` — the recording of one
66
+ * activation call (the URL the `audioUrl` of the phone-line webhooks points to).
67
+ * Needs `phone_lines:read`.
68
+ *
69
+ * ⛔ The recording SPEAKS the activation code, a credential: never log the bytes
70
+ * nor expose them publicly. 404 `ACTIVATION_NOT_FOUND` (a `NotFoundError`) covers
71
+ * an unknown id, another workspace's id, no recording, and a line already
72
+ * returned or canceled.
73
+ */
74
+ getActivationAudio(activationId: string): Promise<ActivationAudio>;
75
+ }
76
+ /**
77
+ * Builds the `data:<mime>;base64,<...>` URI that `start()` / `submitDocument()`
78
+ * expect, from raw bytes (a Node `Buffer` is a `Uint8Array`). Uses the global
79
+ * `btoa`, available in Node >= 16 and every browser.
80
+ */
81
+ export declare function toDataUri(bytes: Uint8Array, mimeType: string): string;
82
+ //# sourceMappingURL=phone-lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone-lines.d.ts","sourceRoot":"","sources":["../../src/resources/phone-lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACR,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,8BAA8B,EAC9B,iBAAiB,EACpB,MAAM,aAAa,CAAC;AAIrB;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAA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