@pilot-status/sdk 0.3.0 → 0.5.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/README.md CHANGED
@@ -27,6 +27,15 @@ const accepted = await client.messages.send({
27
27
 
28
28
  const message = await client.messages.get(accepted.id);
29
29
  console.log(message.status);
30
+
31
+ // Conversation history (both directions, every provider), newest first.
32
+ // This is how you read old messages — the webhook does not replay history.
33
+ const history = await client.messages.history({
34
+ startDate: "2026-07-01T00:00:00Z",
35
+ endDate: "2026-07-31T23:59:59Z",
36
+ pageSize: 100,
37
+ });
38
+ console.log(history.total, history.messages[0]?.providerTimestamp);
30
39
  ```
31
40
 
32
41
  ## Management (projects, API keys, numbers)
@@ -47,12 +56,15 @@ const projects = await client.projects.list();
47
56
  ### API keys
48
57
 
49
58
  ```ts
50
- const key = await client.apiKeys.create({
51
- name: "Backend Key",
52
- retentionDays: 30,
53
- });
59
+ // Regenerate the default key of one number (tenant-scoped). The new usable key
60
+ // is returned once — there is no "create another key" concept.
61
+ const regenerated = await client.apiKeys.regenerateNumber("wn_1");
62
+ console.log(regenerated.key); // shown only once
54
63
 
55
64
  const keys = await client.apiKeys.list();
65
+ // With a number-scoped key this returns that number's masked keys (`ApiKeyListItem[]`).
66
+ // With a tenant-scoped key it returns a lean per-number list (`NumberApiKeyReveal[]`):
67
+ // { numberId, number, displayName, keyId, keyLast4, key, revealable } — `key` is the real usable value when `revealable` is true.
56
68
  ```
57
69
 
58
70
  ### Numbers (WhatsApp)
@@ -68,8 +80,39 @@ const refreshed = await client.numbers.connect(created.instance.id);
68
80
  // refreshed.qrcodeBase64, refreshed.pairingCode
69
81
 
70
82
  const status = await client.numbers.getStatus(created.instance.id);
83
+
84
+ const detail = await client.numbers.get(created.instance.id);
85
+ console.log(detail.settings.appliesTo.advanced); // "evolution-go" | "none"
86
+ ```
87
+
88
+ #### Per-number settings
89
+
90
+ `numbers.update()` is a PARTIAL patch of the number: retention policy and/or the
91
+ `settings` block. There is no `POST /v1/numbers/{id}/settings`, and Evolution's
92
+ `syncFullHistory` has no equivalent here.
93
+
94
+ ```ts
95
+ // stop replaying the device's old messages into the webhook on every reconnect
96
+ await client.numbers.updateSettings(id, { webhookHistoricalMessages: false });
97
+
98
+ await client.numbers.update(id, {
99
+ piiMode: "STORE_X_DAYS",
100
+ piiRetentionDays: 30,
101
+ settings: { rejectCall: true, msgRejectCall: "I don't take calls here" },
102
+ });
71
103
  ```
72
104
 
105
+ `historyImportEnabled` / `webhookHistoricalMessages` apply to every provider. The
106
+ other six are the Evolution GO `advancedSettings`, in the GO dialect
107
+ (`ignoreGroups`, not the v2 `groupsIgnore`); passing `null` resets one to the
108
+ provider default. On a Meta number they are stored but never applied — which is
109
+ what `settings.appliesTo.advanced === "none"` tells you.
110
+
111
+ They are also pushed to the number's connected instances; `settingsSync`
112
+ (`{applied, failed, skipped}`) reports that push. It is best-effort: a
113
+ disconnected instance still keeps the persisted value and picks it up on its next
114
+ provisioning.
115
+
73
116
  ## Analytics
74
117
 
75
118
  ```ts
@@ -77,6 +120,86 @@ const stats = await client.analytics.getDashboardStats({ tz: "America/Sao_Paulo"
77
120
  console.log(stats.totalSent, stats.failureRate);
78
121
  ```
79
122
 
123
+ ## Calls (WhatsApp Business Calling)
124
+
125
+ Voice calls over the `/v1/calls*` endpoints, on **two kinds of numbers**:
126
+
127
+ - **Meta Cloud API numbers** — signaling-only: `initiate`/`accept` carry the
128
+ SDP (RFC 8866) produced by your WebRTC client, and audio flows directly
129
+ between the browser and WhatsApp. Settings/permissions/`preAccept` are
130
+ Meta-only.
131
+ - **Web (Pilot Status / unofficial) numbers** — call media is handled
132
+ server-side, so there is **no SDP** (omit `sdp` on `initiate`/`accept`).
133
+ No call permission is required before `initiate` and there is **no Meta
134
+ per-minute billing**. Extra media controls: `play` (stream an audio file
135
+ into the call) and `realtimeSession` (full-duplex PCM16 WebSocket).
136
+
137
+ Numbers on any other provider get `400 FEATURE_NOT_SUPPORTED`. `callId`
138
+ arguments accept the Pilot Status id (`call_...`) **or** the provider call id
139
+ (Meta `wacid...` / Evolution GO CallID).
140
+
141
+ > Billing: on Meta numbers, business-initiated calls (BIC) are billed by
142
+ > **Meta directly on your WABA** — per minute, in 6-second pulses, only when
143
+ > answered; user-initiated calls (UIC) are free. Calls on web numbers have no
144
+ > Meta billing at all. Pilot Status does not charge for calls.
145
+ >
146
+ > Web numbers are unofficial (QR-paired) WhatsApp sessions — call quality and
147
+ > availability depend on the paired device/session, and heavy automated
148
+ > calling carries the usual unofficial-number ban risk.
149
+
150
+ ```ts
151
+ // 1. Permission first (required before calling a user)
152
+ const perm = await client.calls.getPermissions("+5511999999999");
153
+ if (perm.permission.status === "no_permission") {
154
+ await client.calls.requestPermission({
155
+ to: "+5511999999999",
156
+ text: "May we call you about your order?",
157
+ });
158
+ // the user's reply arrives as the call.permission_updated webhook
159
+ }
160
+
161
+ // 2. Start a business-initiated call (sdp = offer from your WebRTC client)
162
+ const call = await client.calls.initiate({
163
+ to: "+5511999999999",
164
+ sdp: offerSdp,
165
+ bizOpaqueCallbackData: "order-42",
166
+ });
167
+
168
+ // 3. Answer an inbound call (after the call.ringing webhook)
169
+ const inbound = await client.calls.get("wacid.ABGG...", { includeSdp: true });
170
+ // feed inbound.sdpOffer to your WebRTC client, produce the answer, then:
171
+ await client.calls.accept(inbound.id, answerSdp);
172
+
173
+ // Other controls
174
+ await client.calls.reject("wacid.ABGG...");
175
+ await client.calls.terminate("wacid.ABGG...");
176
+
177
+ // History + settings (settings are Meta-only)
178
+ const { calls } = await client.calls.list({ limit: 25 });
179
+ const settings = await client.calls.getSettings();
180
+ await client.calls.updateSettings({ status: "ENABLED" });
181
+ ```
182
+
183
+ On a **web (Pilot Status) number** the same flow needs no SDP and no
184
+ permission step, and you get server-side media controls:
185
+
186
+ ```ts
187
+ // Start a call (no sdp, no permission step)
188
+ const call = await client.calls.initiate({ to: "+5511999999999" });
189
+
190
+ // Answer an inbound call (after the call.ringing webhook) — no sdp
191
+ await client.calls.accept(call.id);
192
+
193
+ // Stream an audio file into the active call (.mp3/.wav/.opus by URL;
194
+ // queued and played on connect when the call is not active yet)
195
+ await client.calls.play(call.id, "https://cdn.example.com/ivr-greeting.mp3");
196
+
197
+ // Full-duplex realtime audio: returns { wsUrl, token, expiresInSeconds }.
198
+ // Connect a WebSocket to wsUrl and exchange RAW binary PCM16 LE frames
199
+ // (this is a plain WebSocket transport, NOT WebRTC; token is single-use, ~2 min)
200
+ const session = await client.calls.realtimeSession(call.id, "talk");
201
+ ```
202
+
80
203
  ## Webhooks (parse / validation)
81
204
 
82
205
  ```ts
@@ -100,7 +223,8 @@ Notes:
100
223
  - `message.received` includes `fromMe` (boolean).
101
224
  - `message.group` is delivered for inbound group messages (includes `groupName`).
102
225
  - `message.newsletter` is delivered for inbound WhatsApp channel / newsletter messages (`@newsletter`, includes `newsletterId`).
103
- - Supported events in the parser: `message.sent`, `message.delivered`, `message.read`, `message.failed`, `message.reply`, `message.received`, `message.group`, `message.newsletter`.
226
+ - Supported events in the parser: `message.sent`, `message.delivered`, `message.read`, `message.failed`, `message.reply`, `message.received`, `message.group`, `message.newsletter`, `number.created`, `number.connected`, `number.disconnected`, `number.removed`, `call.ringing`, `call.connected`, `call.ended`, `call.missed`, `call.permission_updated`.
227
+ - `call.*` payloads are **flat** (fields sit next to `event`, no `data` wrapper): `{ event, callId, externalCallId?, direction, status, from, to, timestamp, duration? }`. `duration` (seconds) appears on `call.ended` only when the call was answered; `call.permission_updated` has `callId`/`direction` `null` and `status` `NO_PERMISSION` | `TEMPORARY` | `PERMANENT`.
104
228
 
105
229
  ## Errors
106
230
 
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AnalyticsResource } from "./resources/analytics.js";
2
+ import { CallsResource } from "./resources/calls.js";
2
3
  import { MessagesResource } from "./resources/messages.js";
3
4
  import { ApiKeysResource } from "./resources/api-keys.js";
4
5
  import { NumbersResource } from "./resources/numbers.js";
@@ -27,6 +28,7 @@ export declare class PilotStatusClient {
27
28
  readonly newsletters: NewslettersResource;
28
29
  readonly remotePairing: RemotePairingResource;
29
30
  readonly media: MediaResource;
31
+ readonly calls: CallsResource;
30
32
  constructor(options: PilotStatusClientOptions);
31
33
  }
32
34
  //# sourceMappingURL=client.d.ts.map
@@ -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,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,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C,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,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;gBAElB,OAAO,EAAE,wBAAwB;CA+B9C"}
package/dist/client.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AnalyticsResource } from "./resources/analytics.js";
2
+ import { CallsResource } from "./resources/calls.js";
2
3
  import { MessagesResource } from "./resources/messages.js";
3
4
  import { ApiKeysResource } from "./resources/api-keys.js";
4
5
  import { NumbersResource } from "./resources/numbers.js";
@@ -20,13 +21,14 @@ export class PilotStatusClient {
20
21
  newsletters;
21
22
  remotePairing;
22
23
  media;
24
+ calls;
23
25
  constructor(options) {
24
26
  const fetchImpl = options.fetch ?? globalThis.fetch;
25
27
  if (!fetchImpl) {
26
28
  throw new Error("fetch is not available in this runtime; pass { fetch } to PilotStatusClient");
27
29
  }
28
30
  const http = createHttpClient({
29
- baseUrl: "https://pilotstatuss.com",
31
+ baseUrl: "https://pilotstatus.com.br",
30
32
  apiKey: options.apiKey,
31
33
  timeoutMs: options.timeoutMs ?? 30_000,
32
34
  userAgent: options.userAgent,
@@ -43,6 +45,7 @@ export class PilotStatusClient {
43
45
  this.newsletters = new NewslettersResource(http);
44
46
  this.remotePairing = new RemotePairingResource(http);
45
47
  this.media = new MediaResource(http);
48
+ this.calls = new CallsResource(http);
46
49
  }
47
50
  }
48
51
  //# sourceMappingURL=client.js.map
@@ -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,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAkB,MAAM,WAAW,CAAC;AAU7D,MAAM,OAAO,iBAAiB;IACnB,QAAQ,CAAmB;IAC3B,SAAS,CAAoB;IAC7B,OAAO,CAAkB;IACzB,OAAO,CAAkB;IACzB,QAAQ,CAAmB;IAC3B,SAAS,CAAoB;IAC7B,MAAM,CAAiB;IACvB,WAAW,CAAsB;IACjC,aAAa,CAAwB;IACrC,KAAK,CAAgB;IAE9B,YAAY,OAAiC;QAC3C,MAAM,SAAS,GACb,OAAO,CAAC,KAAK,IAAK,UAAkB,CAAC,KAAK,CAAC;QAE7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,gBAAgB,CAAC;YAC5B,OAAO,E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C,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
package/dist/http.d.ts CHANGED
@@ -8,7 +8,7 @@ export type HttpClientOptions = {
8
8
  getRetries: number;
9
9
  };
10
10
  export type HttpRequest = {
11
- method: "GET" | "POST" | "DELETE";
11
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
12
12
  path: string;
13
13
  query?: Record<string, string | number | boolean | undefined | null>;
14
14
  body?: unknown;
@@ -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;CACtB,CAAC;AAEF,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,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@ export { PilotStatusClient } from "./client.js";
2
2
  export type { PilotStatusClientOptions } from "./client.js";
3
3
  export { PilotStatusError, PilotStatusHttpError, AuthenticationError, ValidationError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, } from "./errors.js";
4
4
  export type { PilotStatusErrorBody } from "./errors.js";
5
- export type { MessageStatus, Button, ButtonType, MarketingOptions, SendMessageInput, SendMessageHeader, SendMessageAccepted, MessageDetails, DashboardStats, Project, CreateProjectInput, ApiKeyCreateInput, ApiKeyCreated, ApiKeyListItem, WhatsAppNumberInstance, WhatsAppNumberListItem, NumberListItemApiKeyRef, CreateNumberInput, CreateNumberResult, NumberConnectResult, NumberStatusResult, NumberLinkBundle, RemotePairingInput, RemotePairingResult, RemotePairingInfo, RemotePairingStatus, RemotePairingConnectResult, CancelMessagesResult, DeleteNumberResult, TemplateListItem, TemplateDetail, GroupListItem, NewsletterListItem, MediaDownloadResult, } from "./types.js";
6
- export type { CustomerWebhookEvent, WhatsAppMessageType, MessageSentEvent, MessageDeliveredEvent, MessageReadEvent, MessageFailedEvent, MessageReplyEvent, MessageReceivedEvent, MessageGroupEvent, MessageNewsletterEvent, NumberCreatedEvent, NumberConnectedEvent, NumberDisconnectedEvent, NumberRemovedEvent, } from "./webhooks/types.js";
5
+ export { NUMBER_STATUS_FAILURE_CODES } from "./types.js";
6
+ export type { MessageStatus, Button, ButtonType, MarketingOptions, SendMessageInput, SendMessageHeader, SendMessageAccepted, MessageDetails, DashboardStats, Project, CreateProjectInput, ApiKeyCreated, ApiKeyListItem, NumberApiKeyReveal, RegeneratedNumberKey, WhatsAppNumberInstance, WhatsAppNumberListItem, NumberListItemApiKeyRef, CreateNumberInput, CreateNumberResult, NumberConnectResult, NumberStatusResult, NumberStatusFailureCode, NumberDetail, NumberSettings, NumberSettingsInput, NumberSettingsSync, NumberPiiInput, UpdateNumberInput, UpdateNumberResult, ChatHistoryMedia, ChatHistoryMessage, MessageHistoryParams, MessageHistoryResult, NumberLinkBundle, RemotePairingInput, RemotePairingResult, RemotePairingInfo, RemotePairingStatus, RemotePairingConnectResult, CancelMessagesResult, DeleteNumberResult, TemplateListItem, TemplateDetail, GroupListItem, NewsletterListItem, MediaDownloadResult, CallDirection, CallStatus, CallDetails, CallInitiateInput, CallInitiateAccepted, CallActionResult, CallListResult, CallingSettingsResult, CallSettingsUpdateInput, CallSettingsUpdateResult, CallPermissionResult, CallPermissionRequestInput, CallPermissionRequestResult, CallRealtimeSessionMode, CallRealtimeSessionResult, } from "./types.js";
7
+ 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, } from "./webhooks/types.js";
7
8
  export { parseCustomerWebhook, isCustomerWebhookEvent } from "./webhooks/parse.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,YAAY,EACV,aAAa,EACb,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAEzD,YAAY,EACV,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,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { PilotStatusClient } from "./client.js";
2
2
  export { PilotStatusError, PilotStatusHttpError, AuthenticationError, ValidationError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, } from "./errors.js";
3
+ export { NUMBER_STATUS_FAILURE_CODES } from "./types.js";
3
4
  export { parseCustomerWebhook, isCustomerWebhookEvent } from "./webhooks/parse.js";
4
5
  //# 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,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AAwDrB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AA6FzD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,9 +1,26 @@
1
1
  import type { HttpClient } from "../http.js";
2
- import type { ApiKeyCreateInput, ApiKeyCreated, ApiKeyListItem } from "../types.js";
2
+ import type { ApiKeyListItem, RegeneratedNumberKey } from "../types.js";
3
3
  export declare class ApiKeysResource {
4
4
  #private;
5
5
  constructor(http: HttpClient);
6
+ /**
7
+ * List API keys (`GET /v1/api-keys`).
8
+ *
9
+ * With a NUMBER-scoped key this returns that number's masked keys
10
+ * (`ApiKeyListItem[]`).
11
+ *
12
+ * With a TENANT-scoped key the endpoint instead returns a lean per-number list
13
+ * (`NumberApiKeyReveal[]`) — one entry per number carrying the real usable
14
+ * `key` when `revealable` is true.
15
+ */
6
16
  list(): Promise<ApiKeyListItem[]>;
7
- create(input: ApiKeyCreateInput): Promise<ApiKeyCreated>;
17
+ /**
18
+ * Regenerate the default key of one WhatsApp number (`POST /v1/api-keys`).
19
+ *
20
+ * Tenant-scoped action — there is no "create another key" concept. It rotates
21
+ * the default key of the number identified by `whatsappNumberId`, revokes the
22
+ * previous key, and returns the new usable key (shown once).
23
+ */
24
+ regenerateNumber(whatsappNumberId: string): Promise<RegeneratedNumberKey>;
8
25
  }
9
26
  //# sourceMappingURL=api-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEpF,qBAAa,eAAe;;gBAGd,IAAI,EAAE,UAAU;IAItB,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAOjC,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;CAmB/D"}
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExE,qBAAa,eAAe;;gBAGd,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAOvC;;;;;;OAMG;IACG,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAOhF"}
@@ -3,29 +3,34 @@ export class ApiKeysResource {
3
3
  constructor(http) {
4
4
  this.#http = http;
5
5
  }
6
+ /**
7
+ * List API keys (`GET /v1/api-keys`).
8
+ *
9
+ * With a NUMBER-scoped key this returns that number's masked keys
10
+ * (`ApiKeyListItem[]`).
11
+ *
12
+ * With a TENANT-scoped key the endpoint instead returns a lean per-number list
13
+ * (`NumberApiKeyReveal[]`) — one entry per number carrying the real usable
14
+ * `key` when `revealable` is true.
15
+ */
6
16
  async list() {
7
17
  return this.#http.requestJson({
8
18
  method: "GET",
9
19
  path: "/v1/api-keys",
10
20
  });
11
21
  }
12
- async create(input) {
22
+ /**
23
+ * Regenerate the default key of one WhatsApp number (`POST /v1/api-keys`).
24
+ *
25
+ * Tenant-scoped action — there is no "create another key" concept. It rotates
26
+ * the default key of the number identified by `whatsappNumberId`, revokes the
27
+ * previous key, and returns the new usable key (shown once).
28
+ */
29
+ async regenerateNumber(whatsappNumberId) {
13
30
  return this.#http.requestJson({
14
31
  method: "POST",
15
32
  path: "/v1/api-keys",
16
- body: {
17
- name: input.name,
18
- ...(input.webhookId !== undefined ? { webhookId: input.webhookId } : {}),
19
- ...(input.whatsappInstanceId !== undefined
20
- ? { whatsappInstanceId: input.whatsappInstanceId }
21
- : {}),
22
- ...(input.whatsappNumberId !== undefined
23
- ? { whatsappNumberId: input.whatsappNumberId }
24
- : {}),
25
- ...(input.retentionDays !== undefined
26
- ? { retentionDays: input.retentionDays }
27
- : {}),
28
- },
33
+ body: { whatsappNumberId },
29
34
  });
30
35
  }
31
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACjB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAmB;YAC9C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAwB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAgB;YAC3C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE;gBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxE,GAAG,CAAC,KAAK,CAAC,kBAAkB,KAAK,SAAS;oBACxC,CAAC,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE;oBAClD,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS;oBACtC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE;oBAC9C,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS;oBACnC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;oBACxC,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACjB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAmB;YAC9C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CAAC,gBAAwB;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAuB;YAClD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,EAAE,gBAAgB,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,72 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { CallActionResult, CallDetails, CallInitiateAccepted, CallInitiateInput, CallListResult, CallPermissionRequestInput, CallPermissionRequestResult, CallPermissionResult, CallRealtimeSessionMode, CallRealtimeSessionResult, CallSettingsUpdateInput, CallSettingsUpdateResult, CallingSettingsResult } from "../types.js";
3
+ /**
4
+ * WhatsApp Business Calling (`/v1/calls*`) — Meta Cloud API AND web
5
+ * (Pilot Status) numbers; any other provider gets `400 FEATURE_NOT_SUPPORTED`.
6
+ *
7
+ * - **Meta**: signaling-only — `initiate`/`accept`/`preAccept` carry the SDP
8
+ * (RFC 8866) produced by YOUR WebRTC client; media flows browser↔WhatsApp
9
+ * directly. `preAccept`/settings/permissions are Meta-only.
10
+ * - **Web (Pilot Status) numbers**: call media is handled server-side — there
11
+ * is NO SDP ever (omit `sdp` on `initiate`/`accept`). Extra media controls:
12
+ * `play` (stream an audio file into the call) and `realtimeSession`
13
+ * (full-duplex PCM16 WebSocket). No call permission is needed before
14
+ * `initiate` and there is no Meta per-minute billing.
15
+ *
16
+ * `callId` arguments accept the Pilot Status id (`call_...`) OR the provider
17
+ * call id (Meta `wacid...` / Evolution GO CallID).
18
+ */
19
+ export declare class CallsResource {
20
+ #private;
21
+ constructor(http: HttpClient);
22
+ /**
23
+ * Start a business-initiated call (BIC). On Meta numbers `sdp` is required
24
+ * and a prior user call permission is needed; on web (Pilot Status) numbers
25
+ * omit `sdp` — no permission step and no Meta billing.
26
+ */
27
+ initiate(input: CallInitiateInput): Promise<CallInitiateAccepted>;
28
+ /** List the number's calls, newest first (`limit` 1–100, `before` ISO 8601 cursor). */
29
+ list(params?: {
30
+ limit?: number;
31
+ before?: string;
32
+ }): Promise<CallListResult>;
33
+ /** One call; `includeSdp: true` adds `sdpOffer`/`sdpAnswer` (needed to answer a UIC). */
34
+ get(callId: string, params?: {
35
+ includeSdp?: boolean;
36
+ }): Promise<CallDetails>;
37
+ /** OPTIONAL early SDP answer (reduces clipping); the call connects only on accept. Meta-only. */
38
+ preAccept(callId: string, sdp: string): Promise<CallActionResult>;
39
+ /**
40
+ * Answer an inbound (user-initiated) call. On Meta numbers pass the
41
+ * business-side SDP answer; on web (Pilot Status) numbers omit `sdp`.
42
+ */
43
+ accept(callId: string, sdp?: string): Promise<CallActionResult>;
44
+ /** Decline an incoming call (no body). */
45
+ reject(callId: string): Promise<CallActionResult>;
46
+ /** Hang up an active call (no body). */
47
+ terminate(callId: string): Promise<CallActionResult>;
48
+ /**
49
+ * Play an audio file into an active call — web (Pilot Status) numbers only
50
+ * (Meta numbers get `400 FEATURE_NOT_SUPPORTED`). `mediaUrl` must be a public
51
+ * http(s) URL of an `.mp3`/`.wav`/`.opus` file; when the call is not active
52
+ * yet the audio is queued and starts as soon as it connects.
53
+ */
54
+ play(callId: string, mediaUrl: string): Promise<CallActionResult>;
55
+ /**
56
+ * Open a short-lived full-duplex realtime media session on an active call —
57
+ * web (Pilot Status) numbers only. `mode: "talk"` sends mic audio AND
58
+ * receives peer audio; `"listen"` only receives. Returns `{ wsUrl, token,
59
+ * expiresInSeconds }`: connect a WebSocket to `wsUrl` and exchange raw
60
+ * binary PCM16 LE frames (NOT WebRTC; the token is single-use, ~2 min).
61
+ */
62
+ realtimeSession(callId: string, mode: CallRealtimeSessionMode): Promise<CallRealtimeSessionResult>;
63
+ /** Read the number's `calling` settings object. Meta-only. */
64
+ getSettings(): Promise<CallingSettingsResult>;
65
+ /** Partial update; a posted `call_hours` REPLACES the stored object entirely. Meta-only. */
66
+ updateSettings(input: CallSettingsUpdateInput): Promise<CallSettingsUpdateResult>;
67
+ /** Probe whether the business may call `to` (required before a Meta BIC). Meta-only. */
68
+ getPermissions(to: string): Promise<CallPermissionResult>;
69
+ /** Send the interactive call-permission request (inside the 24h service window). Meta-only. */
70
+ requestPermission(input: CallPermissionRequestInput): Promise<CallPermissionRequestResult>;
71
+ }
72
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../src/resources/calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAa;;gBAGZ,IAAI,EAAE,UAAU;IAI5B;;;;OAIG;IACG,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAcvE,uFAAuF;IACjF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAQjF,yFAAyF;IACnF,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAQlF,iGAAiG;IAC3F,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQvE;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQrE,0CAA0C;IACpC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAOvD,wCAAwC;IAClC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO1D;;;;;OAKG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQvE;;;;;;OAMG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,yBAAyB,CAAC;IAQrC,8DAA8D;IACxD,WAAW,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAOnD,4FAA4F;IACtF,cAAc,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQvF,wFAAwF;IAClF,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQ/D,+FAA+F;IACzF,iBAAiB,CACrB,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC;CAUxC"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * WhatsApp Business Calling (`/v1/calls*`) — Meta Cloud API AND web
3
+ * (Pilot Status) numbers; any other provider gets `400 FEATURE_NOT_SUPPORTED`.
4
+ *
5
+ * - **Meta**: signaling-only — `initiate`/`accept`/`preAccept` carry the SDP
6
+ * (RFC 8866) produced by YOUR WebRTC client; media flows browser↔WhatsApp
7
+ * directly. `preAccept`/settings/permissions are Meta-only.
8
+ * - **Web (Pilot Status) numbers**: call media is handled server-side — there
9
+ * is NO SDP ever (omit `sdp` on `initiate`/`accept`). Extra media controls:
10
+ * `play` (stream an audio file into the call) and `realtimeSession`
11
+ * (full-duplex PCM16 WebSocket). No call permission is needed before
12
+ * `initiate` and there is no Meta per-minute billing.
13
+ *
14
+ * `callId` arguments accept the Pilot Status id (`call_...`) OR the provider
15
+ * call id (Meta `wacid...` / Evolution GO CallID).
16
+ */
17
+ export class CallsResource {
18
+ #http;
19
+ constructor(http) {
20
+ this.#http = http;
21
+ }
22
+ /**
23
+ * Start a business-initiated call (BIC). On Meta numbers `sdp` is required
24
+ * and a prior user call permission is needed; on web (Pilot Status) numbers
25
+ * omit `sdp` — no permission step and no Meta billing.
26
+ */
27
+ async initiate(input) {
28
+ return this.#http.requestJson({
29
+ method: "POST",
30
+ path: "/v1/calls",
31
+ body: {
32
+ to: input.to,
33
+ ...(input.sdp ? { sdp: input.sdp } : {}),
34
+ ...(input.bizOpaqueCallbackData
35
+ ? { bizOpaqueCallbackData: input.bizOpaqueCallbackData }
36
+ : {}),
37
+ },
38
+ });
39
+ }
40
+ /** List the number's calls, newest first (`limit` 1–100, `before` ISO 8601 cursor). */
41
+ async list(params) {
42
+ return this.#http.requestJson({
43
+ method: "GET",
44
+ path: "/v1/calls",
45
+ query: { limit: params?.limit, before: params?.before },
46
+ });
47
+ }
48
+ /** One call; `includeSdp: true` adds `sdpOffer`/`sdpAnswer` (needed to answer a UIC). */
49
+ async get(callId, params) {
50
+ return this.#http.requestJson({
51
+ method: "GET",
52
+ path: `/v1/calls/${encodeURIComponent(callId)}`,
53
+ query: { includeSdp: params?.includeSdp ? "1" : undefined },
54
+ });
55
+ }
56
+ /** OPTIONAL early SDP answer (reduces clipping); the call connects only on accept. Meta-only. */
57
+ async preAccept(callId, sdp) {
58
+ return this.#http.requestJson({
59
+ method: "POST",
60
+ path: `/v1/calls/${encodeURIComponent(callId)}/pre-accept`,
61
+ body: { sdp },
62
+ });
63
+ }
64
+ /**
65
+ * Answer an inbound (user-initiated) call. On Meta numbers pass the
66
+ * business-side SDP answer; on web (Pilot Status) numbers omit `sdp`.
67
+ */
68
+ async accept(callId, sdp) {
69
+ return this.#http.requestJson({
70
+ method: "POST",
71
+ path: `/v1/calls/${encodeURIComponent(callId)}/accept`,
72
+ body: { ...(sdp ? { sdp } : {}) },
73
+ });
74
+ }
75
+ /** Decline an incoming call (no body). */
76
+ async reject(callId) {
77
+ return this.#http.requestJson({
78
+ method: "POST",
79
+ path: `/v1/calls/${encodeURIComponent(callId)}/reject`,
80
+ });
81
+ }
82
+ /** Hang up an active call (no body). */
83
+ async terminate(callId) {
84
+ return this.#http.requestJson({
85
+ method: "POST",
86
+ path: `/v1/calls/${encodeURIComponent(callId)}/terminate`,
87
+ });
88
+ }
89
+ /**
90
+ * Play an audio file into an active call — web (Pilot Status) numbers only
91
+ * (Meta numbers get `400 FEATURE_NOT_SUPPORTED`). `mediaUrl` must be a public
92
+ * http(s) URL of an `.mp3`/`.wav`/`.opus` file; when the call is not active
93
+ * yet the audio is queued and starts as soon as it connects.
94
+ */
95
+ async play(callId, mediaUrl) {
96
+ return this.#http.requestJson({
97
+ method: "POST",
98
+ path: `/v1/calls/${encodeURIComponent(callId)}/play`,
99
+ body: { mediaUrl },
100
+ });
101
+ }
102
+ /**
103
+ * Open a short-lived full-duplex realtime media session on an active call —
104
+ * web (Pilot Status) numbers only. `mode: "talk"` sends mic audio AND
105
+ * receives peer audio; `"listen"` only receives. Returns `{ wsUrl, token,
106
+ * expiresInSeconds }`: connect a WebSocket to `wsUrl` and exchange raw
107
+ * binary PCM16 LE frames (NOT WebRTC; the token is single-use, ~2 min).
108
+ */
109
+ async realtimeSession(callId, mode) {
110
+ return this.#http.requestJson({
111
+ method: "POST",
112
+ path: `/v1/calls/${encodeURIComponent(callId)}/realtime-session`,
113
+ body: { mode },
114
+ });
115
+ }
116
+ /** Read the number's `calling` settings object. Meta-only. */
117
+ async getSettings() {
118
+ return this.#http.requestJson({
119
+ method: "GET",
120
+ path: "/v1/calls/settings",
121
+ });
122
+ }
123
+ /** Partial update; a posted `call_hours` REPLACES the stored object entirely. Meta-only. */
124
+ async updateSettings(input) {
125
+ return this.#http.requestJson({
126
+ method: "PUT",
127
+ path: "/v1/calls/settings",
128
+ body: input,
129
+ });
130
+ }
131
+ /** Probe whether the business may call `to` (required before a Meta BIC). Meta-only. */
132
+ async getPermissions(to) {
133
+ return this.#http.requestJson({
134
+ method: "GET",
135
+ path: "/v1/calls/permissions",
136
+ query: { to },
137
+ });
138
+ }
139
+ /** Send the interactive call-permission request (inside the 24h service window). Meta-only. */
140
+ async requestPermission(input) {
141
+ return this.#http.requestJson({
142
+ method: "POST",
143
+ path: "/v1/calls/permissions/request",
144
+ body: {
145
+ to: input.to,
146
+ ...(input.text ? { text: input.text } : {}),
147
+ },
148
+ });
149
+ }
150
+ }
151
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["../../src/resources/calls.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,aAAa;IACf,KAAK,CAAa;IAE3B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,KAAwB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAuB;YAClD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxC,GAAG,CAAC,KAAK,CAAC,qBAAqB;oBAC7B,CAAC,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