@signalwire/sdk 2.0.0 → 2.0.1

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.
Files changed (75) hide show
  1. package/package.json +1 -1
  2. package/src/AgentBase.ts +113 -4
  3. package/src/AgentServer.ts +31 -4
  4. package/src/ContextBuilder.ts +33 -2
  5. package/src/DataMap.ts +30 -2
  6. package/src/FunctionResult.ts +40 -3
  7. package/src/PomBuilder.ts +29 -1
  8. package/src/SWMLService.ts +38 -6
  9. package/src/ServerlessAdapter.ts +20 -1
  10. package/src/SwmlBuilder.ts +26 -1
  11. package/src/TypeInference.ts +27 -9
  12. package/src/WebService.ts +27 -5
  13. package/src/index.ts +73 -7
  14. package/src/livewire/index.ts +343 -41
  15. package/src/prefabs/ConciergeAgent.ts +22 -0
  16. package/src/prefabs/FAQBotAgent.ts +32 -1
  17. package/src/prefabs/InfoGathererAgent.ts +41 -1
  18. package/src/prefabs/ReceptionistAgent.ts +30 -1
  19. package/src/prefabs/SurveyAgent.ts +26 -1
  20. package/src/relay/Action.ts +174 -6
  21. package/src/relay/Call.ts +459 -43
  22. package/src/relay/Deferred.ts +27 -4
  23. package/src/relay/Message.ts +54 -3
  24. package/src/relay/RelayClient.ts +167 -18
  25. package/src/relay/RelayError.ts +7 -1
  26. package/src/relay/RelayEvent.ts +52 -0
  27. package/src/rest/HttpClient.ts +61 -0
  28. package/src/rest/RestError.ts +14 -0
  29. package/src/rest/base/BaseResource.ts +16 -3
  30. package/src/rest/base/CrudResource.ts +52 -5
  31. package/src/rest/base/CrudWithAddresses.ts +12 -1
  32. package/src/rest/index.ts +30 -0
  33. package/src/rest/namespaces/addresses.ts +33 -1
  34. package/src/rest/namespaces/calling.ts +348 -1
  35. package/src/rest/namespaces/chat.ts +13 -2
  36. package/src/rest/namespaces/compat.ts +469 -9
  37. package/src/rest/namespaces/datasphere.ts +48 -5
  38. package/src/rest/namespaces/fabric.ts +197 -2
  39. package/src/rest/namespaces/imported-numbers.ts +13 -2
  40. package/src/rest/namespaces/logs.ts +68 -1
  41. package/src/rest/namespaces/lookup.ts +19 -2
  42. package/src/rest/namespaces/mfa.ts +35 -4
  43. package/src/rest/namespaces/number-groups.ts +35 -5
  44. package/src/rest/namespaces/phone-numbers.ts +35 -3
  45. package/src/rest/namespaces/project.ts +30 -1
  46. package/src/rest/namespaces/pubsub.ts +13 -2
  47. package/src/rest/namespaces/queues.ts +29 -4
  48. package/src/rest/namespaces/recordings.ts +26 -1
  49. package/src/rest/namespaces/registry.ts +100 -1
  50. package/src/rest/namespaces/short-codes.ts +27 -1
  51. package/src/rest/namespaces/sip-profile.ts +18 -3
  52. package/src/rest/namespaces/verified-callers.ts +22 -3
  53. package/src/rest/namespaces/video.ts +168 -1
  54. package/src/rest/pagination.ts +22 -8
  55. package/src/skills/SkillBase.ts +37 -2
  56. package/src/skills/SkillManager.ts +8 -4
  57. package/src/skills/builtin/api_ninjas_trivia.ts +5 -0
  58. package/src/skills/builtin/ask_claude.ts +5 -0
  59. package/src/skills/builtin/claude_skills.ts +5 -0
  60. package/src/skills/builtin/custom_skills.ts +15 -0
  61. package/src/skills/builtin/datasphere.ts +9 -0
  62. package/src/skills/builtin/datasphere_serverless.ts +8 -0
  63. package/src/skills/builtin/datetime.ts +7 -0
  64. package/src/skills/builtin/google_maps.ts +5 -0
  65. package/src/skills/builtin/info_gatherer.ts +10 -0
  66. package/src/skills/builtin/joke.ts +5 -0
  67. package/src/skills/builtin/math.ts +7 -0
  68. package/src/skills/builtin/mcp_gateway.ts +8 -0
  69. package/src/skills/builtin/native_vector_search.ts +9 -0
  70. package/src/skills/builtin/play_background_file.ts +9 -0
  71. package/src/skills/builtin/spider.ts +5 -0
  72. package/src/skills/builtin/swml_transfer.ts +10 -0
  73. package/src/skills/builtin/weather_api.ts +7 -0
  74. package/src/skills/builtin/web_search.ts +9 -0
  75. package/src/skills/builtin/wikipedia_search.ts +5 -0
@@ -11,24 +11,53 @@ import type { QueryParams } from '../types.js';
11
11
  import { BaseResource } from '../base/BaseResource.js';
12
12
  import { CrudResource } from '../base/CrudResource.js';
13
13
 
14
- /** Compat account/subproject management. */
14
+ /** Compat account / subproject management (Twilio-compatible LAML). */
15
15
  export class CompatAccounts extends BaseResource {
16
16
  constructor(http: HttpClient) {
17
17
  super(http, '/api/laml/2010-04-01/Accounts');
18
18
  }
19
19
 
20
+ /**
21
+ * List accounts visible to the authenticated project.
22
+ *
23
+ * @param params - Optional filter / pagination query parameters.
24
+ * @returns A LAML-shaped paginated account list.
25
+ * @throws {RestError} On any non-2xx HTTP response.
26
+ */
20
27
  async list(params?: QueryParams): Promise<any> {
21
28
  return this._http.get(this._basePath, params);
22
29
  }
23
30
 
31
+ /**
32
+ * Create a new sub-account under the authenticated parent account.
33
+ *
34
+ * @param body - Account payload (`FriendlyName`, etc.) — LAML form keys.
35
+ * @returns The newly-created account record.
36
+ * @throws {RestError} On any non-2xx HTTP response.
37
+ */
24
38
  async create(body: any): Promise<any> {
25
39
  return this._http.post(this._basePath, body);
26
40
  }
27
41
 
42
+ /**
43
+ * Fetch an account by SID.
44
+ *
45
+ * @param sid - Account SID (e.g. `"AC..."`).
46
+ * @returns The account record.
47
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
48
+ */
28
49
  async get(sid: string): Promise<any> {
29
50
  return this._http.get(this._path(sid));
30
51
  }
31
52
 
53
+ /**
54
+ * Update an account's attributes. LAML uses `POST` (not PATCH/PUT).
55
+ *
56
+ * @param sid - Account SID.
57
+ * @param body - Partial update payload. Defaults to `{}`.
58
+ * @returns The updated account record.
59
+ * @throws {RestError} On any non-2xx HTTP response.
60
+ */
32
61
  async update(sid: string, body: any = {}): Promise<any> {
33
62
  return this._http.post(this._path(sid), body);
34
63
  }
@@ -40,22 +69,65 @@ export class CompatCalls extends CrudResource {
40
69
  super(http, basePath);
41
70
  }
42
71
 
72
+ /**
73
+ * Update an in-progress or past call. LAML uses `POST` (not PATCH/PUT).
74
+ *
75
+ * @param sid - Call SID (e.g. `"CA..."`).
76
+ * @param body - LAML-form update payload (`Status`, `Url`, etc.). Defaults to `{}`.
77
+ * @returns The updated call record.
78
+ * @throws {RestError} On any non-2xx HTTP response.
79
+ */
43
80
  override async update(sid: string, body: any = {}): Promise<any> {
44
81
  return this._http.post(this._path(sid), body);
45
82
  }
46
83
 
84
+ /**
85
+ * Start recording an active call.
86
+ *
87
+ * @param callSid - Call SID.
88
+ * @param body - Recording parameters (channels, trim, status callback, etc.).
89
+ * Defaults to `{}`.
90
+ * @returns The newly-started recording record.
91
+ * @throws {RestError} On any non-2xx HTTP response.
92
+ */
47
93
  async startRecording(callSid: string, body: any = {}): Promise<any> {
48
94
  return this._http.post(this._path(callSid, 'Recordings'), body);
49
95
  }
50
96
 
97
+ /**
98
+ * Update an active recording (e.g. `Status=paused` / `Status=stopped`).
99
+ *
100
+ * @param callSid - Call SID.
101
+ * @param recordingSid - Recording SID returned by {@link startRecording}.
102
+ * @param body - Update payload. Defaults to `{}`.
103
+ * @returns The updated recording record.
104
+ * @throws {RestError} On any non-2xx HTTP response.
105
+ */
51
106
  async updateRecording(callSid: string, recordingSid: string, body: any = {}): Promise<any> {
52
107
  return this._http.post(this._path(callSid, 'Recordings', recordingSid), body);
53
108
  }
54
109
 
110
+ /**
111
+ * Start a media stream on an active call (WebSocket media forwarding).
112
+ *
113
+ * @param callSid - Call SID.
114
+ * @param body - Stream parameters (URL, track, etc.). Defaults to `{}`.
115
+ * @returns The newly-started stream record.
116
+ * @throws {RestError} On any non-2xx HTTP response.
117
+ */
55
118
  async startStream(callSid: string, body: any = {}): Promise<any> {
56
119
  return this._http.post(this._path(callSid, 'Streams'), body);
57
120
  }
58
121
 
122
+ /**
123
+ * Stop an active media stream on a call.
124
+ *
125
+ * @param callSid - Call SID.
126
+ * @param streamSid - Stream SID returned by {@link startStream}.
127
+ * @param body - Update payload. Defaults to `{}`.
128
+ * @returns The stopped stream record.
129
+ * @throws {RestError} On any non-2xx HTTP response.
130
+ */
59
131
  async stopStream(callSid: string, streamSid: string, body: any = {}): Promise<any> {
60
132
  return this._http.post(this._path(callSid, 'Streams', streamSid), body);
61
133
  }
@@ -67,18 +139,50 @@ export class CompatMessages extends CrudResource {
67
139
  super(http, basePath);
68
140
  }
69
141
 
142
+ /**
143
+ * Update a message. LAML uses `POST` (not PATCH/PUT).
144
+ *
145
+ * @param sid - Message SID (e.g. `"SM..."` / `"MM..."`).
146
+ * @param body - LAML-form update payload. Defaults to `{}`.
147
+ * @returns The updated message record.
148
+ * @throws {RestError} On any non-2xx HTTP response.
149
+ */
70
150
  override async update(sid: string, body: any = {}): Promise<any> {
71
151
  return this._http.post(this._path(sid), body);
72
152
  }
73
153
 
154
+ /**
155
+ * List media attachments for a message (MMS).
156
+ *
157
+ * @param messageSid - Message SID.
158
+ * @param params - Optional filter / pagination query parameters.
159
+ * @returns A paginated list of media records.
160
+ * @throws {RestError} On any non-2xx HTTP response.
161
+ */
74
162
  async listMedia(messageSid: string, params?: QueryParams): Promise<any> {
75
163
  return this._http.get(this._path(messageSid, 'Media'), params);
76
164
  }
77
165
 
166
+ /**
167
+ * Fetch a specific media attachment on a message.
168
+ *
169
+ * @param messageSid - Message SID.
170
+ * @param mediaSid - Media SID.
171
+ * @returns The media record (metadata + URL).
172
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
173
+ */
78
174
  async getMedia(messageSid: string, mediaSid: string): Promise<any> {
79
175
  return this._http.get(this._path(messageSid, 'Media', mediaSid));
80
176
  }
81
177
 
178
+ /**
179
+ * Delete a media attachment from a message.
180
+ *
181
+ * @param messageSid - Message SID.
182
+ * @param mediaSid - Media SID.
183
+ * @returns The platform's delete response.
184
+ * @throws {RestError} On any non-2xx HTTP response.
185
+ */
82
186
  async deleteMedia(messageSid: string, mediaSid: string): Promise<any> {
83
187
  return this._http.delete(this._path(messageSid, 'Media', mediaSid));
84
188
  }
@@ -90,18 +194,50 @@ export class CompatFaxes extends CrudResource {
90
194
  super(http, basePath);
91
195
  }
92
196
 
197
+ /**
198
+ * Update a fax. LAML uses `POST` (not PATCH/PUT).
199
+ *
200
+ * @param sid - Fax SID (e.g. `"FX..."`).
201
+ * @param body - LAML-form update payload. Defaults to `{}`.
202
+ * @returns The updated fax record.
203
+ * @throws {RestError} On any non-2xx HTTP response.
204
+ */
93
205
  override async update(sid: string, body: any = {}): Promise<any> {
94
206
  return this._http.post(this._path(sid), body);
95
207
  }
96
208
 
209
+ /**
210
+ * List media attachments for a fax.
211
+ *
212
+ * @param faxSid - Fax SID.
213
+ * @param params - Optional filter / pagination query parameters.
214
+ * @returns A paginated list of media records.
215
+ * @throws {RestError} On any non-2xx HTTP response.
216
+ */
97
217
  async listMedia(faxSid: string, params?: QueryParams): Promise<any> {
98
218
  return this._http.get(this._path(faxSid, 'Media'), params);
99
219
  }
100
220
 
221
+ /**
222
+ * Fetch a specific media attachment on a fax.
223
+ *
224
+ * @param faxSid - Fax SID.
225
+ * @param mediaSid - Media SID.
226
+ * @returns The media record.
227
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
228
+ */
101
229
  async getMedia(faxSid: string, mediaSid: string): Promise<any> {
102
230
  return this._http.get(this._path(faxSid, 'Media', mediaSid));
103
231
  }
104
232
 
233
+ /**
234
+ * Delete a media attachment from a fax.
235
+ *
236
+ * @param faxSid - Fax SID.
237
+ * @param mediaSid - Media SID.
238
+ * @returns The platform's delete response.
239
+ * @throws {RestError} On any non-2xx HTTP response.
240
+ */
105
241
  async deleteMedia(faxSid: string, mediaSid: string): Promise<any> {
106
242
  return this._http.delete(this._path(faxSid, 'Media', mediaSid));
107
243
  }
@@ -113,63 +249,173 @@ export class CompatConferences extends BaseResource {
113
249
  super(http, basePath);
114
250
  }
115
251
 
252
+ /**
253
+ * List conferences in the account.
254
+ *
255
+ * @param params - Optional filter / pagination query parameters.
256
+ * @returns A paginated list of conferences.
257
+ * @throws {RestError} On any non-2xx HTTP response.
258
+ */
116
259
  async list(params?: QueryParams): Promise<any> {
117
260
  return this._http.get(this._basePath, params);
118
261
  }
119
262
 
263
+ /**
264
+ * Fetch a conference by SID.
265
+ *
266
+ * @param sid - Conference SID (e.g. `"CF..."`).
267
+ * @returns The conference record.
268
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
269
+ */
120
270
  async get(sid: string): Promise<any> {
121
271
  return this._http.get(this._path(sid));
122
272
  }
123
273
 
274
+ /**
275
+ * Update a conference (e.g. `Status=completed` to terminate).
276
+ * LAML uses `POST` (not PATCH/PUT).
277
+ *
278
+ * @param sid - Conference SID.
279
+ * @param body - LAML-form update payload. Defaults to `{}`.
280
+ * @returns The updated conference record.
281
+ * @throws {RestError} On any non-2xx HTTP response.
282
+ */
124
283
  async update(sid: string, body: any = {}): Promise<any> {
125
284
  return this._http.post(this._path(sid), body);
126
285
  }
127
286
 
128
287
  // Participants
288
+
289
+ /**
290
+ * List participants in a conference.
291
+ *
292
+ * @param conferenceSid - Conference SID.
293
+ * @param params - Optional filter / pagination query parameters.
294
+ * @returns A paginated list of participants.
295
+ * @throws {RestError} On any non-2xx HTTP response.
296
+ */
129
297
  async listParticipants(conferenceSid: string, params?: QueryParams): Promise<any> {
130
298
  return this._http.get(this._path(conferenceSid, 'Participants'), params);
131
299
  }
132
300
 
301
+ /**
302
+ * Fetch a specific participant (by its call SID) in a conference.
303
+ *
304
+ * @param conferenceSid - Conference SID.
305
+ * @param callSid - Participant's call SID.
306
+ * @returns The participant record.
307
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
308
+ */
133
309
  async getParticipant(conferenceSid: string, callSid: string): Promise<any> {
134
310
  return this._http.get(this._path(conferenceSid, 'Participants', callSid));
135
311
  }
136
312
 
313
+ /**
314
+ * Update a participant (mute, hold, announce, etc.). LAML uses `POST`.
315
+ *
316
+ * @param conferenceSid - Conference SID.
317
+ * @param callSid - Participant's call SID.
318
+ * @param body - LAML-form update payload (e.g. `{ Muted: 'true' }`).
319
+ * Defaults to `{}`.
320
+ * @returns The updated participant record.
321
+ * @throws {RestError} On any non-2xx HTTP response.
322
+ */
137
323
  async updateParticipant(conferenceSid: string, callSid: string, body: any = {}): Promise<any> {
138
324
  return this._http.post(this._path(conferenceSid, 'Participants', callSid), body);
139
325
  }
140
326
 
327
+ /**
328
+ * Remove a participant from a conference (kick).
329
+ *
330
+ * @param conferenceSid - Conference SID.
331
+ * @param callSid - Participant's call SID.
332
+ * @returns The platform's delete response.
333
+ * @throws {RestError} On any non-2xx HTTP response.
334
+ */
141
335
  async removeParticipant(conferenceSid: string, callSid: string): Promise<any> {
142
336
  return this._http.delete(this._path(conferenceSid, 'Participants', callSid));
143
337
  }
144
338
 
145
339
  // Conference recordings
340
+
341
+ /**
342
+ * List recordings taken of a conference.
343
+ *
344
+ * @param conferenceSid - Conference SID.
345
+ * @param params - Optional filter / pagination query parameters.
346
+ * @returns A paginated list of recordings.
347
+ * @throws {RestError} On any non-2xx HTTP response.
348
+ */
146
349
  async listRecordings(conferenceSid: string, params?: QueryParams): Promise<any> {
147
350
  return this._http.get(this._path(conferenceSid, 'Recordings'), params);
148
351
  }
149
352
 
353
+ /**
354
+ * Fetch a specific conference recording.
355
+ *
356
+ * @param conferenceSid - Conference SID.
357
+ * @param recordingSid - Recording SID.
358
+ * @returns The recording record.
359
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
360
+ */
150
361
  async getRecording(conferenceSid: string, recordingSid: string): Promise<any> {
151
362
  return this._http.get(this._path(conferenceSid, 'Recordings', recordingSid));
152
363
  }
153
364
 
365
+ /**
366
+ * Update an active conference recording (pause, resume, stop). LAML uses `POST`.
367
+ *
368
+ * @param conferenceSid - Conference SID.
369
+ * @param recordingSid - Recording SID.
370
+ * @param body - LAML-form update payload. Defaults to `{}`.
371
+ * @returns The updated recording record.
372
+ * @throws {RestError} On any non-2xx HTTP response.
373
+ */
154
374
  async updateRecording(conferenceSid: string, recordingSid: string, body: any = {}): Promise<any> {
155
375
  return this._http.post(this._path(conferenceSid, 'Recordings', recordingSid), body);
156
376
  }
157
377
 
378
+ /**
379
+ * Delete a conference recording.
380
+ *
381
+ * @param conferenceSid - Conference SID.
382
+ * @param recordingSid - Recording SID.
383
+ * @returns The platform's delete response.
384
+ * @throws {RestError} On any non-2xx HTTP response.
385
+ */
158
386
  async deleteRecording(conferenceSid: string, recordingSid: string): Promise<any> {
159
387
  return this._http.delete(this._path(conferenceSid, 'Recordings', recordingSid));
160
388
  }
161
389
 
162
390
  // Conference streams
391
+
392
+ /**
393
+ * Start a media stream on a conference.
394
+ *
395
+ * @param conferenceSid - Conference SID.
396
+ * @param body - Stream parameters (URL, track, etc.). Defaults to `{}`.
397
+ * @returns The newly-started stream record.
398
+ * @throws {RestError} On any non-2xx HTTP response.
399
+ */
163
400
  async startStream(conferenceSid: string, body: any = {}): Promise<any> {
164
401
  return this._http.post(this._path(conferenceSid, 'Streams'), body);
165
402
  }
166
403
 
404
+ /**
405
+ * Stop an active conference media stream.
406
+ *
407
+ * @param conferenceSid - Conference SID.
408
+ * @param streamSid - Stream SID returned by {@link startStream}.
409
+ * @param body - Update payload. Defaults to `{}`.
410
+ * @returns The stopped stream record.
411
+ * @throws {RestError} On any non-2xx HTTP response.
412
+ */
167
413
  async stopStream(conferenceSid: string, streamSid: string, body: any = {}): Promise<any> {
168
414
  return this._http.post(this._path(conferenceSid, 'Streams', streamSid), body);
169
415
  }
170
416
  }
171
417
 
172
- /** Compat phone number management. */
418
+ /** Compat phone number management with searching, purchasing, and import. */
173
419
  export class CompatPhoneNumbers extends BaseResource {
174
420
  private readonly _availableBase: string;
175
421
 
@@ -178,159 +424,373 @@ export class CompatPhoneNumbers extends BaseResource {
178
424
  this._availableBase = basePath.replace('/IncomingPhoneNumbers', '/AvailablePhoneNumbers');
179
425
  }
180
426
 
427
+ /**
428
+ * List owned incoming phone numbers in the account.
429
+ *
430
+ * @param params - Optional filter / pagination query parameters.
431
+ * @returns A paginated list of owned numbers.
432
+ * @throws {RestError} On any non-2xx HTTP response.
433
+ */
181
434
  async list(params?: QueryParams): Promise<any> {
182
435
  return this._http.get(this._basePath, params);
183
436
  }
184
437
 
438
+ /**
439
+ * Purchase a phone number (LAML `POST /IncomingPhoneNumbers`).
440
+ *
441
+ * @param body - Purchase payload, typically including `PhoneNumber` or
442
+ * `AreaCode` plus webhook URLs.
443
+ * @returns The newly-purchased phone-number record.
444
+ * @throws {RestError} On any non-2xx HTTP response.
445
+ */
185
446
  async purchase(body: any): Promise<any> {
186
447
  return this._http.post(this._basePath, body);
187
448
  }
188
449
 
450
+ /**
451
+ * Fetch an owned phone number by SID.
452
+ *
453
+ * @param sid - Phone number SID (e.g. `"PN..."`).
454
+ * @returns The phone-number record.
455
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
456
+ */
189
457
  async get(sid: string): Promise<any> {
190
458
  return this._http.get(this._path(sid));
191
459
  }
192
460
 
461
+ /**
462
+ * Update an owned phone number (webhook URLs, friendly name, etc.).
463
+ * LAML uses `POST`.
464
+ *
465
+ * @param sid - Phone number SID.
466
+ * @param body - LAML-form update payload. Defaults to `{}`.
467
+ * @returns The updated phone-number record.
468
+ * @throws {RestError} On any non-2xx HTTP response.
469
+ */
193
470
  async update(sid: string, body: any = {}): Promise<any> {
194
471
  return this._http.post(this._path(sid), body);
195
472
  }
196
473
 
474
+ /**
475
+ * Release an owned phone number (delete).
476
+ *
477
+ * @param sid - Phone number SID.
478
+ * @returns The platform's delete response.
479
+ * @throws {RestError} On any non-2xx HTTP response.
480
+ */
197
481
  async delete(sid: string): Promise<any> {
198
482
  return this._http.delete(this._path(sid));
199
483
  }
200
484
 
485
+ /**
486
+ * Import an externally-hosted phone number into the account
487
+ * (LAML `/ImportedPhoneNumbers`).
488
+ *
489
+ * @param body - Import payload (number, carrier details, etc.).
490
+ * @returns The newly-imported number record.
491
+ * @throws {RestError} On any non-2xx HTTP response.
492
+ */
201
493
  async importNumber(body: any): Promise<any> {
202
494
  const path = this._basePath.replace('/IncomingPhoneNumbers', '/ImportedPhoneNumbers');
203
495
  return this._http.post(path, body);
204
496
  }
205
497
 
498
+ /**
499
+ * List countries in which numbers are available for purchase.
500
+ *
501
+ * @param params - Optional filter / pagination query parameters.
502
+ * @returns A paginated list of country records with capabilities.
503
+ * @throws {RestError} On any non-2xx HTTP response.
504
+ */
206
505
  async listAvailableCountries(params?: QueryParams): Promise<any> {
207
506
  return this._http.get(this._availableBase, params);
208
507
  }
209
508
 
509
+ /**
510
+ * Search for available local phone numbers in a country.
511
+ *
512
+ * @param country - ISO-3166 country code (e.g. `"US"`, `"CA"`).
513
+ * @param params - Search filters (`AreaCode`, `Contains`, `NearNumber`, etc.).
514
+ * @returns A paginated list of available local numbers.
515
+ * @throws {RestError} On any non-2xx HTTP response.
516
+ */
210
517
  async searchLocal(country: string, params?: QueryParams): Promise<any> {
211
518
  return this._http.get(`${this._availableBase}/${country}/Local`, params);
212
519
  }
213
520
 
521
+ /**
522
+ * Search for available toll-free phone numbers in a country.
523
+ *
524
+ * @param country - ISO-3166 country code.
525
+ * @param params - Search filters (`Contains`, `NearNumber`, etc.).
526
+ * @returns A paginated list of available toll-free numbers.
527
+ * @throws {RestError} On any non-2xx HTTP response.
528
+ */
214
529
  async searchTollFree(country: string, params?: QueryParams): Promise<any> {
215
530
  return this._http.get(`${this._availableBase}/${country}/TollFree`, params);
216
531
  }
217
532
  }
218
533
 
219
- /** Compat application management. */
534
+ /** Compat application management (LAML-style `Applications`). */
220
535
  export class CompatApplications extends CrudResource {
221
536
  constructor(http: HttpClient, basePath: string) {
222
537
  super(http, basePath);
223
538
  }
224
539
 
540
+ /**
541
+ * Update an application. LAML uses `POST` (not PATCH/PUT).
542
+ *
543
+ * @param sid - Application SID (e.g. `"AP..."`).
544
+ * @param body - LAML-form update payload. Defaults to `{}`.
545
+ * @returns The updated application record.
546
+ * @throws {RestError} On any non-2xx HTTP response.
547
+ */
225
548
  override async update(sid: string, body: any = {}): Promise<any> {
226
549
  return this._http.post(this._path(sid), body);
227
550
  }
228
551
  }
229
552
 
230
- /** Compat cXML/LaML script management. */
553
+ /** Compat cXML / LaML Bin management. */
231
554
  export class CompatLamlBins extends CrudResource {
232
555
  constructor(http: HttpClient, basePath: string) {
233
556
  super(http, basePath);
234
557
  }
235
558
 
559
+ /**
560
+ * Update a LaML Bin's stored script. LAML uses `POST` (not PATCH/PUT).
561
+ *
562
+ * @param sid - LaML Bin SID (e.g. `"LA..."`).
563
+ * @param body - Payload containing the new `VoiceMethod`, `Url`, etc.
564
+ * Defaults to `{}`.
565
+ * @returns The updated LaML Bin record.
566
+ * @throws {RestError} On any non-2xx HTTP response.
567
+ */
236
568
  override async update(sid: string, body: any = {}): Promise<any> {
237
569
  return this._http.post(this._path(sid), body);
238
570
  }
239
571
  }
240
572
 
241
- /** Compat queue management with members. */
573
+ /** Compat queue management with member operations. */
242
574
  export class CompatQueues extends CrudResource {
243
575
  constructor(http: HttpClient, basePath: string) {
244
576
  super(http, basePath);
245
577
  }
246
578
 
579
+ /**
580
+ * Update a queue. LAML uses `POST` (not PATCH/PUT).
581
+ *
582
+ * @param sid - Queue SID (e.g. `"QU..."`).
583
+ * @param body - LAML-form update payload. Defaults to `{}`.
584
+ * @returns The updated queue record.
585
+ * @throws {RestError} On any non-2xx HTTP response.
586
+ */
247
587
  override async update(sid: string, body: any = {}): Promise<any> {
248
588
  return this._http.post(this._path(sid), body);
249
589
  }
250
590
 
591
+ /**
592
+ * List members (calls) currently waiting in a queue.
593
+ *
594
+ * @param queueSid - Queue SID.
595
+ * @param params - Optional filter / pagination query parameters.
596
+ * @returns A paginated list of queue members.
597
+ * @throws {RestError} On any non-2xx HTTP response.
598
+ */
251
599
  async listMembers(queueSid: string, params?: QueryParams): Promise<any> {
252
600
  return this._http.get(this._path(queueSid, 'Members'), params);
253
601
  }
254
602
 
603
+ /**
604
+ * Fetch a specific member (by call SID) currently waiting in a queue.
605
+ *
606
+ * @param queueSid - Queue SID.
607
+ * @param callSid - Call SID of the queued member.
608
+ * @returns The queue-member record.
609
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
610
+ */
255
611
  async getMember(queueSid: string, callSid: string): Promise<any> {
256
612
  return this._http.get(this._path(queueSid, 'Members', callSid));
257
613
  }
258
614
 
615
+ /**
616
+ * Dequeue a member — LAML's `POST` on a queued call redirects it to the
617
+ * given `Url` (typically to connect the caller to a queue consumer).
618
+ *
619
+ * @param queueSid - Queue SID.
620
+ * @param callSid - Call SID of the queued member.
621
+ * @param body - LAML-form payload (commonly `{ Url, Method }`).
622
+ * Defaults to `{}`.
623
+ * @returns The updated queue-member record.
624
+ * @throws {RestError} On any non-2xx HTTP response.
625
+ */
259
626
  async dequeueMember(queueSid: string, callSid: string, body: any = {}): Promise<any> {
260
627
  return this._http.post(this._path(queueSid, 'Members', callSid), body);
261
628
  }
262
629
  }
263
630
 
264
- /** Compat recording management. */
631
+ /** Compat recording management (list / get / delete). */
265
632
  export class CompatRecordings extends BaseResource {
266
633
  constructor(http: HttpClient, basePath: string) {
267
634
  super(http, basePath);
268
635
  }
269
636
 
637
+ /**
638
+ * List recordings in the account.
639
+ *
640
+ * @param params - Optional filter / pagination query parameters
641
+ * (date range, call SID, conference SID, etc.).
642
+ * @returns A paginated list of recordings.
643
+ * @throws {RestError} On any non-2xx HTTP response.
644
+ */
270
645
  async list(params?: QueryParams): Promise<any> {
271
646
  return this._http.get(this._basePath, params);
272
647
  }
273
648
 
649
+ /**
650
+ * Fetch a recording by SID.
651
+ *
652
+ * @param sid - Recording SID (e.g. `"RE..."`).
653
+ * @returns The recording record.
654
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
655
+ */
274
656
  async get(sid: string): Promise<any> {
275
657
  return this._http.get(this._path(sid));
276
658
  }
277
659
 
660
+ /**
661
+ * Delete a recording.
662
+ *
663
+ * @param sid - Recording SID.
664
+ * @returns The platform's delete response.
665
+ * @throws {RestError} On any non-2xx HTTP response.
666
+ */
278
667
  async delete(sid: string): Promise<any> {
279
668
  return this._http.delete(this._path(sid));
280
669
  }
281
670
  }
282
671
 
283
- /** Compat transcription management. */
672
+ /** Compat transcription management (list / get / delete). */
284
673
  export class CompatTranscriptions extends BaseResource {
285
674
  constructor(http: HttpClient, basePath: string) {
286
675
  super(http, basePath);
287
676
  }
288
677
 
678
+ /**
679
+ * List transcriptions in the account.
680
+ *
681
+ * @param params - Optional filter / pagination query parameters.
682
+ * @returns A paginated list of transcriptions.
683
+ * @throws {RestError} On any non-2xx HTTP response.
684
+ */
289
685
  async list(params?: QueryParams): Promise<any> {
290
686
  return this._http.get(this._basePath, params);
291
687
  }
292
688
 
689
+ /**
690
+ * Fetch a transcription by SID.
691
+ *
692
+ * @param sid - Transcription SID (e.g. `"TR..."`).
693
+ * @returns The transcription record.
694
+ * @throws {RestError} On any non-2xx HTTP response (including `404`).
695
+ */
293
696
  async get(sid: string): Promise<any> {
294
697
  return this._http.get(this._path(sid));
295
698
  }
296
699
 
700
+ /**
701
+ * Delete a transcription.
702
+ *
703
+ * @param sid - Transcription SID.
704
+ * @returns The platform's delete response.
705
+ * @throws {RestError} On any non-2xx HTTP response.
706
+ */
297
707
  async delete(sid: string): Promise<any> {
298
708
  return this._http.delete(this._path(sid));
299
709
  }
300
710
  }
301
711
 
302
- /** Compat API token management. */
712
+ /** Compat API token management (non-LAML — uses `PATCH`). */
303
713
  export class CompatTokens extends BaseResource {
304
714
  constructor(http: HttpClient, basePath: string) {
305
715
  super(http, basePath);
306
716
  }
307
717
 
718
+ /**
719
+ * Create a new Compat API token.
720
+ *
721
+ * @param body - Token payload (friendly name, scopes, etc.).
722
+ * @returns The newly-created token record, including the secret value.
723
+ * @throws {RestError} On any non-2xx HTTP response.
724
+ */
308
725
  async create(body: any): Promise<any> {
309
726
  return this._http.post(this._basePath, body);
310
727
  }
311
728
 
729
+ /**
730
+ * Update a Compat API token.
731
+ *
732
+ * @param tokenId - Unique identifier of the token.
733
+ * @param body - Partial update payload. Defaults to `{}`.
734
+ * @returns The updated token record.
735
+ * @throws {RestError} On any non-2xx HTTP response.
736
+ */
312
737
  async update(tokenId: string, body: any = {}): Promise<any> {
313
738
  return this._http.patch(this._path(tokenId), body);
314
739
  }
315
740
 
741
+ /**
742
+ * Revoke and delete a Compat API token.
743
+ *
744
+ * @param tokenId - Unique identifier of the token.
745
+ * @returns The platform's delete response.
746
+ * @throws {RestError} On any non-2xx HTTP response.
747
+ */
316
748
  async delete(tokenId: string): Promise<any> {
317
749
  return this._http.delete(this._path(tokenId));
318
750
  }
319
751
  }
320
752
 
321
- /** Twilio-compatible LAML API namespace with AccountSid scoping. */
753
+ /**
754
+ * Twilio-compatible LAML API namespace with AccountSid scoping.
755
+ *
756
+ * Access via `client.compat.*`. This is the legacy LAML (cXML) surface for code
757
+ * migrated from Twilio — all updates use POST bodies instead of REST-idiomatic
758
+ * PATCH/PUT. Prefer the native SignalWire namespaces (`client.calling`, `client.fabric`,
759
+ * etc.) for greenfield projects.
760
+ *
761
+ * @example Send an SMS via the LAML Messages API
762
+ * ```ts
763
+ * await client.compat.messages.create({
764
+ * From: '+15551112222',
765
+ * To: '+15553334444',
766
+ * Body: 'Hello from SignalWire!',
767
+ * });
768
+ * ```
769
+ */
322
770
  export class CompatNamespace {
771
+ /** Main and sub-account CRUD. */
323
772
  readonly accounts: CompatAccounts;
773
+ /** Call CRUD plus recording / stream sub-resource management. */
324
774
  readonly calls: CompatCalls;
775
+ /** Message CRUD plus media sub-resource management. */
325
776
  readonly messages: CompatMessages;
777
+ /** Fax CRUD plus media sub-resource management. */
326
778
  readonly faxes: CompatFaxes;
779
+ /** Conference read / update with participants, recordings, and streams. */
327
780
  readonly conferences: CompatConferences;
781
+ /** Phone number CRUD plus search / purchase / import helpers. */
328
782
  readonly phoneNumbers: CompatPhoneNumbers;
783
+ /** LAML Application CRUD. */
329
784
  readonly applications: CompatApplications;
785
+ /** LaML Bin (hosted script) CRUD. */
330
786
  readonly lamlBins: CompatLamlBins;
787
+ /** Queue CRUD plus member list / fetch / dequeue. */
331
788
  readonly queues: CompatQueues;
789
+ /** Recording list / fetch / delete. */
332
790
  readonly recordings: CompatRecordings;
791
+ /** Transcription list / fetch / delete. */
333
792
  readonly transcriptions: CompatTranscriptions;
793
+ /** Compat API token create / update / delete. */
334
794
  readonly tokens: CompatTokens;
335
795
 
336
796
  constructor(http: HttpClient, accountSid: string) {