@sippulse/niva-sdk 0.1.0 → 0.2.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.
@@ -0,0 +1,4350 @@
1
+ import {
2
+ NivaError2,
3
+ NivaApiError2,
4
+ NivaConnectionError2,
5
+ NivaConfigurationError2,
6
+ NivaIncompatibleServerError2,
7
+ NivaUnavailableError2,
8
+ NivaWebhookError2
9
+ } from "./chunk-50ad2r7x.js";
10
+
11
+ // src/sse.ts
12
+ function parseFrame(block) {
13
+ let event;
14
+ const dataLines = [];
15
+ for (const line of block.split(`
16
+ `)) {
17
+ if (line === "")
18
+ continue;
19
+ if (line.startsWith(":"))
20
+ continue;
21
+ const colon = line.indexOf(":");
22
+ if (colon === -1)
23
+ continue;
24
+ const field = line.slice(0, colon);
25
+ const value = line.slice(colon + 1).startsWith(" ") ? line.slice(colon + 2) : line.slice(colon + 1);
26
+ if (field === "event")
27
+ event = value;
28
+ else if (field === "data")
29
+ dataLines.push(value);
30
+ }
31
+ if (event === undefined)
32
+ return;
33
+ return { event, dataLines };
34
+ }
35
+ function frameData(frame) {
36
+ const text = frame.dataLines.join(`
37
+ `);
38
+ if (text === "")
39
+ return;
40
+ const parsed = JSON.parse(text);
41
+ return parsed;
42
+ }
43
+ function isRecord(value) {
44
+ return value !== null && typeof value === "object" && !Array.isArray(value);
45
+ }
46
+ function errorFromFrame(frame, data, operation) {
47
+ if (isRecord(data) && data["defined"] === true && typeof data["code"] === "string") {
48
+ return new NivaApiError2({
49
+ status: typeof data["status"] === "number" ? data["status"] : 500,
50
+ code: data["code"],
51
+ message: typeof data["message"] === "string" ? data["message"] : "stream error",
52
+ data: data["data"],
53
+ operation
54
+ });
55
+ }
56
+ return new NivaApiError2({
57
+ status: 500,
58
+ code: "UNEXPECTED_RESPONSE",
59
+ message: `unexpected stream event ${frame.event}`,
60
+ operation
61
+ });
62
+ }
63
+ function messageValue(frame) {
64
+ return frameData(frame);
65
+ }
66
+ async function* emptyGenerator() {}
67
+ async function* readFrames(reader, decoder, isClosed) {
68
+ let buffer = "";
69
+ const carry = { current: "" };
70
+ for (;; ) {
71
+ if (isClosed())
72
+ return;
73
+ const chunk = await reader.read();
74
+ buffer += normalizeChunk(decoder, chunk.done ? undefined : chunk.value, carry);
75
+ const holder = { text: buffer };
76
+ for (const frame of takeFrames(holder)) {
77
+ yield frame;
78
+ if (isClosed())
79
+ return;
80
+ }
81
+ buffer = holder.text;
82
+ if (chunk.done)
83
+ return;
84
+ }
85
+ }
86
+ function normalizeChunk(decoder, raw, carry) {
87
+ if (raw === undefined) {
88
+ const flushed = carry.current === "\r" ? `
89
+ ` : carry.current;
90
+ carry.current = "";
91
+ return flushed;
92
+ }
93
+ let text = carry.current + decoder.decode(raw, { stream: true });
94
+ carry.current = "";
95
+ if (text.endsWith("\r")) {
96
+ carry.current = "\r";
97
+ text = text.slice(0, -1);
98
+ }
99
+ return text.replaceAll(`\r
100
+ `, `
101
+ `).replaceAll("\r", `
102
+ `);
103
+ }
104
+ function takeFrames(buffer) {
105
+ const frames = [];
106
+ let boundary = buffer.text.indexOf(`
107
+
108
+ `);
109
+ while (boundary !== -1) {
110
+ const block = buffer.text.slice(0, boundary);
111
+ buffer.text = buffer.text.slice(boundary + 2);
112
+ const frame = parseFrame(block);
113
+ if (frame !== undefined)
114
+ frames.push(frame);
115
+ boundary = buffer.text.indexOf(`
116
+
117
+ `);
118
+ }
119
+ return frames;
120
+ }
121
+ function createSseStream(response, options) {
122
+ const operation = options?.operation ?? "unknown";
123
+ const callerSignal = options?.signal;
124
+ const reader = response.body?.getReader();
125
+ const decoder = new TextDecoder;
126
+ let closed = false;
127
+ async function cancelBody() {
128
+ closed = true;
129
+ try {
130
+ await reader?.cancel();
131
+ } catch {}
132
+ }
133
+ if (callerSignal !== undefined) {
134
+ if (callerSignal.aborted)
135
+ cancelBody();
136
+ else
137
+ callerSignal.addEventListener("abort", () => void cancelBody(), { once: true });
138
+ }
139
+ async function* iterate() {
140
+ if (reader === undefined)
141
+ return;
142
+ try {
143
+ for await (const frame of readFrames(reader, decoder, () => closed)) {
144
+ if (frame.event === "message") {
145
+ yield messageValue(frame);
146
+ } else if (frame.event === "done") {
147
+ await cancelBody();
148
+ return;
149
+ } else if (frame.event === "error") {
150
+ throw errorFromFrame(frame, frameData(frame), operation);
151
+ } else {
152
+ throw new NivaApiError2({
153
+ status: 500,
154
+ code: "UNEXPECTED_RESPONSE",
155
+ message: `unexpected stream event ${frame.event}`,
156
+ operation
157
+ });
158
+ }
159
+ }
160
+ } finally {
161
+ if (!closed)
162
+ await cancelBody();
163
+ }
164
+ }
165
+ const iterator = iterate();
166
+ return {
167
+ [Symbol.asyncIterator]() {
168
+ return iterator;
169
+ },
170
+ close: async () => {
171
+ await cancelBody();
172
+ }
173
+ };
174
+ }
175
+ async function cancelQuietly(response) {
176
+ try {
177
+ await response.body?.cancel();
178
+ } catch {}
179
+ }
180
+ function streamFromResponse(responsePromise, options) {
181
+ let inner;
182
+ let closed = false;
183
+ let arrived;
184
+ responsePromise.then((response) => {
185
+ arrived = response;
186
+ if (closed)
187
+ cancelQuietly(response);
188
+ }, () => {
189
+ return;
190
+ });
191
+ const empty = {
192
+ [Symbol.asyncIterator]() {
193
+ return emptyGenerator();
194
+ },
195
+ close: async () => {}
196
+ };
197
+ async function* iterate() {
198
+ const response = await responsePromise;
199
+ if (closed) {
200
+ await cancelQuietly(response);
201
+ yield* empty;
202
+ return;
203
+ }
204
+ inner = createSseStream(response, options);
205
+ yield* inner;
206
+ }
207
+ return {
208
+ [Symbol.asyncIterator]() {
209
+ return iterate();
210
+ },
211
+ close: async () => {
212
+ closed = true;
213
+ try {
214
+ await arrived?.body?.cancel();
215
+ } catch {}
216
+ await inner?.close();
217
+ }
218
+ };
219
+ }
220
+
221
+ // src/generated/client-impl.ts
222
+ function buildNivaClient(call) {
223
+ return {
224
+ ai: {
225
+ getBudget: (options) => call("ai.getBudget", undefined, options),
226
+ getBudgetOverview: (options) => call("ai.getBudgetOverview", undefined, options),
227
+ getCallAnalyses: (input, options) => call("ai.getCallAnalyses", input, options),
228
+ getTranscription: (input, options) => call("ai.getTranscription", input, options),
229
+ getUsage: (options) => call("ai.getUsage", undefined, options),
230
+ listAgents: (options) => call("ai.listAgents", undefined, options),
231
+ listStructuredAnalyses: (input, options) => call("ai.listStructuredAnalyses", input, options),
232
+ runAnalysis: (input, options) => call("ai.runAnalysis", input, options),
233
+ runConfiguredAnalyses: (input, options) => call("ai.runConfiguredAnalyses", input, options),
234
+ runSpeechAnalytics: (input, options) => call("ai.runSpeechAnalytics", input, options),
235
+ searchTranscriptions: (input, options) => call("ai.searchTranscriptions", input, options),
236
+ transcribeNow: (input, options) => call("ai.transcribeNow", input, options)
237
+ },
238
+ apiKeys: {
239
+ create: (input, options) => call("apiKeys.create", input, options),
240
+ finishRotation: (input, options) => call("apiKeys.finishRotation", input, options),
241
+ get: (input, options) => call("apiKeys.get", input, options),
242
+ list: (input, options) => call("apiKeys.list", input, options),
243
+ revoke: (input, options) => call("apiKeys.revoke", input, options),
244
+ rotate: (input, options) => call("apiKeys.rotate", input, options),
245
+ update: (input, options) => call("apiKeys.update", input, options),
246
+ usage: (input, options) => call("apiKeys.usage", input, options)
247
+ },
248
+ archive: {
249
+ listDeleted: (input, options) => call("archive.listDeleted", input, options),
250
+ purge: (input, options) => call("archive.purge", input, options),
251
+ restore: (input, options) => call("archive.restore", input, options),
252
+ summary: (options) => call("archive.summary", undefined, options)
253
+ },
254
+ attendants: {
255
+ create: (input, options) => call("attendants.create", input, options),
256
+ delete: (input, options) => call("attendants.delete", input, options),
257
+ getById: (input, options) => call("attendants.getById", input, options),
258
+ list: (input, options) => call("attendants.list", input, options),
259
+ rotateSipCredential: (input, options) => call("attendants.rotateSipCredential", input, options),
260
+ setStatus: (input, options) => call("attendants.setStatus", input, options),
261
+ statusLog: (input, options) => call("attendants.statusLog", input, options),
262
+ update: (input, options) => call("attendants.update", input, options)
263
+ },
264
+ audioFiles: {
265
+ content: (input, options) => call("audioFiles.content", input, options),
266
+ delete: (input, options) => call("audioFiles.delete", input, options),
267
+ generateTts: (input, options) => call("audioFiles.generateTts", input, options),
268
+ getById: (input, options) => call("audioFiles.getById", input, options),
269
+ list: (input, options) => call("audioFiles.list", input, options),
270
+ previewUrl: (input, options) => call("audioFiles.previewUrl", input, options),
271
+ regenerateTts: (input, options) => call("audioFiles.regenerateTts", input, options),
272
+ update: (input, options) => call("audioFiles.update", input, options),
273
+ upload: (input, options) => call("audioFiles.upload", input, options)
274
+ },
275
+ audit: {
276
+ count: (input, options) => call("audit.count", input, options),
277
+ exportCsv: (input, options) => streamFromResponse(call("audit.exportCsv", input, options), {
278
+ signal: options?.signal,
279
+ operation: "audit.exportCsv"
280
+ }),
281
+ exportJobCancel: (input, options) => call("audit.exportJobCancel", input, options),
282
+ exportJobCreate: (input, options) => call("audit.exportJobCreate", input, options),
283
+ exportJobDownload: (input, options) => call("audit.exportJobDownload", input, options),
284
+ exportJobGet: (input, options) => call("audit.exportJobGet", input, options),
285
+ exportJobList: (options) => call("audit.exportJobList", undefined, options),
286
+ exportJobProgress: (input, options) => streamFromResponse(call("audit.exportJobProgress", input, options), {
287
+ signal: options?.signal,
288
+ operation: "audit.exportJobProgress"
289
+ }),
290
+ list: (input, options) => call("audit.list", input, options)
291
+ },
292
+ bugReports: {
293
+ create: (input, options) => call("bugReports.create", input, options)
294
+ },
295
+ callRecords: {
296
+ chatMediaContent: (input, options) => call("callRecords.chatMediaContent", input, options),
297
+ count: (input, options) => call("callRecords.count", input, options),
298
+ exportCsv: (input, options) => streamFromResponse(call("callRecords.exportCsv", input, options), {
299
+ signal: options?.signal,
300
+ operation: "callRecords.exportCsv"
301
+ }),
302
+ exportJobCancel: (input, options) => call("callRecords.exportJobCancel", input, options),
303
+ exportJobCreate: (input, options) => call("callRecords.exportJobCreate", input, options),
304
+ exportJobDownload: (input, options) => call("callRecords.exportJobDownload", input, options),
305
+ exportJobGet: (input, options) => call("callRecords.exportJobGet", input, options),
306
+ exportJobList: (options) => call("callRecords.exportJobList", undefined, options),
307
+ exportJobProgress: (input, options) => streamFromResponse(call("callRecords.exportJobProgress", input, options), { signal: options?.signal, operation: "callRecords.exportJobProgress" }),
308
+ getById: (input, options) => call("callRecords.getById", input, options),
309
+ getEvents: (input, options) => call("callRecords.getEvents", input, options),
310
+ getRecordingUrl: (input, options) => call("callRecords.getRecordingUrl", input, options),
311
+ list: (input, options) => call("callRecords.list", input, options),
312
+ purgeVoiceContent: (input, options) => call("callRecords.purgeVoiceContent", input, options),
313
+ recordingContent: (input, options) => call("callRecords.recordingContent", input, options),
314
+ retryRecording: (input, options) => call("callRecords.retryRecording", input, options)
315
+ },
316
+ calls: {
317
+ hangupCall: (input, options) => call("calls.hangupCall", input, options),
318
+ originate: (input, options) => call("calls.originate", input, options)
319
+ },
320
+ capabilities: {
321
+ get: (options) => call("capabilities.get", undefined, options)
322
+ },
323
+ channels: {
324
+ create: (input, options) => call("channels.create", input, options),
325
+ delete: (input, options) => call("channels.delete", input, options),
326
+ getById: (input, options) => call("channels.getById", input, options),
327
+ list: (input, options) => call("channels.list", input, options),
328
+ rotateWebchatKey: (input, options) => call("channels.rotateWebchatKey", input, options),
329
+ rotateWebchatSecret: (input, options) => call("channels.rotateWebchatSecret", input, options),
330
+ testConnection: (input, options) => call("channels.testConnection", input, options),
331
+ toggle: (input, options) => call("channels.toggle", input, options),
332
+ update: (input, options) => call("channels.update", input, options)
333
+ },
334
+ chat: {
335
+ createMedia: (input, options) => call("chat.createMedia", input, options),
336
+ createSession: (input, options) => call("chat.createSession", input, options),
337
+ endSession: (input, options) => call("chat.endSession", input, options),
338
+ getMedia: (input, options) => call("chat.getMedia", input, options)
339
+ },
340
+ contacts: {
341
+ getById: (input, options) => call("contacts.getById", input, options),
342
+ list: (input, options) => call("contacts.list", input, options),
343
+ update: (input, options) => call("contacts.update", input, options)
344
+ },
345
+ conversations: {
346
+ count: (input, options) => call("conversations.count", input, options),
347
+ getById: (input, options) => call("conversations.getById", input, options),
348
+ list: (input, options) => call("conversations.list", input, options),
349
+ mediaContent: (input, options) => call("conversations.mediaContent", input, options)
350
+ },
351
+ dashboard: {
352
+ capacityStatus: (options) => call("dashboard.capacityStatus", undefined, options),
353
+ watchDashboardMetrics: (options) => streamFromResponse(call("dashboard.watchDashboardMetrics", undefined, options), { signal: options?.signal, operation: "dashboard.watchDashboardMetrics" })
354
+ },
355
+ desk: {
356
+ transferQueues: (options) => call("desk.transferQueues", undefined, options),
357
+ copilot: {
358
+ stats: (input, options) => call("desk.copilot.stats", input, options)
359
+ }
360
+ },
361
+ deskSettings: {
362
+ copilotAgents: (options) => call("deskSettings.copilotAgents", undefined, options),
363
+ createDefaults: (options) => call("deskSettings.createDefaults", undefined, options),
364
+ createDisposition: (input, options) => call("deskSettings.createDisposition", input, options),
365
+ createPauseReason: (input, options) => call("deskSettings.createPauseReason", input, options),
366
+ deleteDisposition: (input, options) => call("deskSettings.deleteDisposition", input, options),
367
+ deletePauseReason: (input, options) => call("deskSettings.deletePauseReason", input, options),
368
+ get: (options) => call("deskSettings.get", undefined, options),
369
+ listDispositions: (input, options) => call("deskSettings.listDispositions", input, options),
370
+ listPauseReasons: (input, options) => call("deskSettings.listPauseReasons", input, options),
371
+ reorderDispositions: (input, options) => call("deskSettings.reorderDispositions", input, options),
372
+ reorderPauseReasons: (input, options) => call("deskSettings.reorderPauseReasons", input, options),
373
+ update: (input, options) => call("deskSettings.update", input, options),
374
+ updateDisposition: (input, options) => call("deskSettings.updateDisposition", input, options),
375
+ updatePauseReason: (input, options) => call("deskSettings.updatePauseReason", input, options)
376
+ },
377
+ destinations: {
378
+ create: (input, options) => call("destinations.create", input, options),
379
+ delete: (input, options) => call("destinations.delete", input, options),
380
+ getById: (input, options) => call("destinations.getById", input, options),
381
+ list: (input, options) => call("destinations.list", input, options),
382
+ update: (input, options) => call("destinations.update", input, options)
383
+ },
384
+ dialerAttempts: {
385
+ list: (input, options) => call("dialerAttempts.list", input, options)
386
+ },
387
+ dialerCampaigns: {
388
+ control: (input, options) => call("dialerCampaigns.control", input, options),
389
+ create: (input, options) => call("dialerCampaigns.create", input, options),
390
+ delete: (input, options) => call("dialerCampaigns.delete", input, options),
391
+ get: (input, options) => call("dialerCampaigns.get", input, options),
392
+ list: (input, options) => call("dialerCampaigns.list", input, options),
393
+ liveStats: (input, options) => streamFromResponse(call("dialerCampaigns.liveStats", input, options), { signal: options?.signal, operation: "dialerCampaigns.liveStats" }),
394
+ orgLiveStats: (options) => streamFromResponse(call("dialerCampaigns.orgLiveStats", undefined, options), { signal: options?.signal, operation: "dialerCampaigns.orgLiveStats" }),
395
+ stats: (input, options) => call("dialerCampaigns.stats", input, options),
396
+ summary: (options) => call("dialerCampaigns.summary", undefined, options),
397
+ update: (input, options) => call("dialerCampaigns.update", input, options)
398
+ },
399
+ dialerContacts: {
400
+ add: (input, options) => call("dialerContacts.add", input, options),
401
+ bulkCancel: (input, options) => call("dialerContacts.bulkCancel", input, options),
402
+ bulkRequeue: (input, options) => call("dialerContacts.bulkRequeue", input, options),
403
+ cancel: (input, options) => call("dialerContacts.cancel", input, options),
404
+ exportCsv: (input, options) => streamFromResponse(call("dialerContacts.exportCsv", input, options), { signal: options?.signal, operation: "dialerContacts.exportCsv" }),
405
+ get: (input, options) => call("dialerContacts.get", input, options),
406
+ list: (input, options) => call("dialerContacts.list", input, options),
407
+ remove: (input, options) => call("dialerContacts.remove", input, options),
408
+ requeue: (input, options) => call("dialerContacts.requeue", input, options),
409
+ requeueAll: (input, options) => call("dialerContacts.requeueAll", input, options),
410
+ update: (input, options) => call("dialerContacts.update", input, options)
411
+ },
412
+ dialerDnc: {
413
+ add: (input, options) => call("dialerDnc.add", input, options),
414
+ bulkImport: (input, options) => call("dialerDnc.bulkImport", input, options),
415
+ bulkRemove: (input, options) => call("dialerDnc.bulkRemove", input, options),
416
+ list: (input, options) => call("dialerDnc.list", input, options),
417
+ remove: (input, options) => call("dialerDnc.remove", input, options)
418
+ },
419
+ dialerImports: {
420
+ create: (input, options) => call("dialerImports.create", input, options),
421
+ get: (input, options) => call("dialerImports.get", input, options),
422
+ invalidRows: (input, options) => call("dialerImports.invalidRows", input, options),
423
+ progress: (input, options) => streamFromResponse(call("dialerImports.progress", input, options), {
424
+ signal: options?.signal,
425
+ operation: "dialerImports.progress"
426
+ })
427
+ },
428
+ holidayCalendars: {
429
+ create: (input, options) => call("holidayCalendars.create", input, options),
430
+ delete: (input, options) => call("holidayCalendars.delete", input, options),
431
+ getById: (input, options) => call("holidayCalendars.getById", input, options),
432
+ importIcs: (input, options) => call("holidayCalendars.importIcs", input, options),
433
+ list: (input, options) => call("holidayCalendars.list", input, options),
434
+ previewRule: (input, options) => call("holidayCalendars.previewRule", input, options),
435
+ update: (input, options) => call("holidayCalendars.update", input, options),
436
+ entries: {
437
+ create: (input, options) => call("holidayCalendars.entries.create", input, options),
438
+ delete: (input, options) => call("holidayCalendars.entries.delete", input, options),
439
+ getById: (input, options) => call("holidayCalendars.entries.getById", input, options),
440
+ list: (input, options) => call("holidayCalendars.entries.list", input, options),
441
+ update: (input, options) => call("holidayCalendars.entries.update", input, options)
442
+ }
443
+ },
444
+ holidayCatalog: {
445
+ countries: (options) => call("holidayCatalog.countries", undefined, options),
446
+ holidays: (input, options) => call("holidayCatalog.holidays", input, options),
447
+ regions: (input, options) => call("holidayCatalog.regions", input, options)
448
+ },
449
+ insights: {
450
+ aggregate: (input, options) => call("insights.aggregate", input, options)
451
+ },
452
+ license: {
453
+ activate: (input, options) => call("license.activate", input, options),
454
+ activation: (options) => call("license.activation", undefined, options),
455
+ modules: (options) => call("license.modules", undefined, options),
456
+ orgUsage: (options) => call("license.orgUsage", undefined, options),
457
+ refresh: (options) => call("license.refresh", undefined, options),
458
+ status: (options) => call("license.status", undefined, options),
459
+ usage: (options) => call("license.usage", undefined, options)
460
+ },
461
+ nodes: {
462
+ list: (options) => call("nodes.list", undefined, options),
463
+ schema: (input, options) => call("nodes.schema", input, options)
464
+ },
465
+ oauthGrants: {
466
+ get: (input, options) => call("oauthGrants.get", input, options),
467
+ list: (input, options) => call("oauthGrants.list", input, options),
468
+ revoke: (input, options) => call("oauthGrants.revoke", input, options),
469
+ usage: (input, options) => call("oauthGrants.usage", input, options)
470
+ },
471
+ orgSettings: {
472
+ getDialer: (options) => call("orgSettings.getDialer", undefined, options),
473
+ upsertDialer: (input, options) => call("orgSettings.upsertDialer", input, options)
474
+ },
475
+ queues: {
476
+ addMembers: (input, options) => call("queues.addMembers", input, options),
477
+ create: (input, options) => call("queues.create", input, options),
478
+ delete: (input, options) => call("queues.delete", input, options),
479
+ getById: (input, options) => call("queues.getById", input, options),
480
+ list: (input, options) => call("queues.list", input, options),
481
+ listMembers: (input, options) => call("queues.listMembers", input, options),
482
+ removeMember: (input, options) => call("queues.removeMember", input, options),
483
+ replaceMembers: (input, options) => call("queues.replaceMembers", input, options),
484
+ stats: (input, options) => call("queues.stats", input, options),
485
+ update: (input, options) => call("queues.update", input, options),
486
+ updateMember: (input, options) => call("queues.updateMember", input, options)
487
+ },
488
+ savedReplies: {
489
+ create: (input, options) => call("savedReplies.create", input, options),
490
+ delete: (input, options) => call("savedReplies.delete", input, options),
491
+ get: (input, options) => call("savedReplies.get", input, options),
492
+ list: (input, options) => call("savedReplies.list", input, options),
493
+ update: (input, options) => call("savedReplies.update", input, options)
494
+ },
495
+ scheduleExceptions: {
496
+ create: (input, options) => call("scheduleExceptions.create", input, options),
497
+ delete: (input, options) => call("scheduleExceptions.delete", input, options),
498
+ getById: (input, options) => call("scheduleExceptions.getById", input, options),
499
+ list: (input, options) => call("scheduleExceptions.list", input, options),
500
+ update: (input, options) => call("scheduleExceptions.update", input, options)
501
+ },
502
+ schedules: {
503
+ calendar: (input, options) => call("schedules.calendar", input, options),
504
+ clearEmergency: (input, options) => call("schedules.clearEmergency", input, options),
505
+ create: (input, options) => call("schedules.create", input, options),
506
+ delete: (input, options) => call("schedules.delete", input, options),
507
+ getById: (input, options) => call("schedules.getById", input, options),
508
+ holidays: (input, options) => call("schedules.holidays", input, options),
509
+ list: (input, options) => call("schedules.list", input, options),
510
+ previewHolidays: (input, options) => call("schedules.previewHolidays", input, options),
511
+ setEmergency: (input, options) => call("schedules.setEmergency", input, options),
512
+ simulate: (input, options) => call("schedules.simulate", input, options),
513
+ upcoming: (input, options) => call("schedules.upcoming", input, options),
514
+ update: (input, options) => call("schedules.update", input, options),
515
+ usage: (input, options) => call("schedules.usage", input, options)
516
+ },
517
+ secrets: {
518
+ list: (input, options) => call("secrets.list", input, options),
519
+ listNames: (options) => call("secrets.listNames", undefined, options)
520
+ },
521
+ signals: {
522
+ callSignals: (input, options) => call("signals.callSignals", input, options),
523
+ create: (input, options) => call("signals.create", input, options),
524
+ delete: (input, options) => call("signals.delete", input, options),
525
+ get: (input, options) => call("signals.get", input, options),
526
+ list: (input, options) => call("signals.list", input, options),
527
+ overview: (options) => call("signals.overview", undefined, options),
528
+ presets: (input, options) => call("signals.presets", input, options),
529
+ test: (input, options) => call("signals.test", input, options),
530
+ update: (input, options) => call("signals.update", input, options),
531
+ upsertBySlug: (input, options) => call("signals.upsertBySlug", input, options)
532
+ },
533
+ tts: {
534
+ listModels: (options) => call("tts.listModels", undefined, options),
535
+ listVoices: (input, options) => call("tts.listVoices", input, options),
536
+ preview: (input, options) => call("tts.preview", input, options)
537
+ },
538
+ users: {
539
+ activateMember: (input, options) => call("users.activateMember", input, options),
540
+ createMember: (input, options) => call("users.createMember", input, options),
541
+ listMembers: (input, options) => call("users.listMembers", input, options),
542
+ me: (options) => call("users.me", undefined, options),
543
+ removeMember: (input, options) => call("users.removeMember", input, options),
544
+ resetSecondFactor: (input, options) => call("users.resetSecondFactor", input, options),
545
+ revokeMemberSessions: (input, options) => call("users.revokeMemberSessions", input, options),
546
+ suspendMember: (input, options) => call("users.suspendMember", input, options),
547
+ unlockMember: (input, options) => call("users.unlockMember", input, options),
548
+ updateMyDeskAlerts: (input, options) => call("users.updateMyDeskAlerts", input, options),
549
+ updateMyNotificationEmail: (input, options) => call("users.updateMyNotificationEmail", input, options),
550
+ updateMyNotificationToast: (input, options) => call("users.updateMyNotificationToast", input, options),
551
+ updateRole: (input, options) => call("users.updateRole", input, options)
552
+ },
553
+ visualPlans: {
554
+ clone: (input, options) => call("visualPlans.clone", input, options),
555
+ create: (input, options) => call("visualPlans.create", input, options),
556
+ delete: (input, options) => call("visualPlans.delete", input, options),
557
+ getById: (input, options) => call("visualPlans.getById", input, options),
558
+ importDraft: (input, options) => call("visualPlans.importDraft", input, options),
559
+ list: (input, options) => call("visualPlans.list", input, options),
560
+ listVersions: (input, options) => call("visualPlans.listVersions", input, options),
561
+ publish: (input, options) => call("visualPlans.publish", input, options),
562
+ update: (input, options) => call("visualPlans.update", input, options),
563
+ validate: (input, options) => call("visualPlans.validate", input, options)
564
+ },
565
+ webhooks: {
566
+ deliveries: {
567
+ count: (input, options) => call("webhooks.deliveries.count", input, options),
568
+ getById: (input, options) => call("webhooks.deliveries.getById", input, options),
569
+ list: (input, options) => call("webhooks.deliveries.list", input, options),
570
+ retention: (options) => call("webhooks.deliveries.retention", undefined, options),
571
+ retry: (input, options) => call("webhooks.deliveries.retry", input, options),
572
+ aggregates: {
573
+ get: (input, options) => call("webhooks.deliveries.aggregates.get", input, options),
574
+ list: (input, options) => call("webhooks.deliveries.aggregates.list", input, options)
575
+ }
576
+ },
577
+ endpoints: {
578
+ create: (input, options) => call("webhooks.endpoints.create", input, options),
579
+ delete: (input, options) => call("webhooks.endpoints.delete", input, options),
580
+ getById: (input, options) => call("webhooks.endpoints.getById", input, options),
581
+ list: (input, options) => call("webhooks.endpoints.list", input, options),
582
+ rotateSecret: (input, options) => call("webhooks.endpoints.rotateSecret", input, options),
583
+ test: (input, options) => call("webhooks.endpoints.test", input, options),
584
+ update: (input, options) => call("webhooks.endpoints.update", input, options)
585
+ },
586
+ events: {
587
+ list: (options) => call("webhooks.events.list", undefined, options)
588
+ }
589
+ }
590
+ };
591
+ }
592
+
593
+ // src/generated/meta.ts
594
+ var SDK_VERSION = "0.2.1";
595
+ var SUPPORTED_NIVA = { min: "2.0.0", max: null };
596
+ var PROTOCOL_VERSION = 1;
597
+ var COMPAT_TABLE = [
598
+ { nivaMin: "2.0.0", nivaMax: null, distTag: "niva-2.0" }
599
+ ];
600
+
601
+ // src/generated/operations.ts
602
+ var ERROR_CODES2 = [
603
+ "ACCOUNT_TARGET_FORBIDDEN",
604
+ "ACTIVE_CALL_NOT_FOUND",
605
+ "AI_ENCRYPTION_KEY_MISSING",
606
+ "AI_INVALID_API_KEY",
607
+ "AI_NOT_CONFIGURED",
608
+ "AI_UNREACHABLE",
609
+ "ALREADY_MEMBER",
610
+ "API_KEY_EXPIRED",
611
+ "API_KEY_NOT_FOUND",
612
+ "ARCHIVE_ITEM_IN_USE",
613
+ "ARCHIVE_ITEM_NOT_FOUND",
614
+ "ARCHIVE_RESTORE_CONFLICT",
615
+ "ATTENDANT_ALREADY_EXISTS",
616
+ "ATTENDANT_BUSY",
617
+ "ATTENDANT_LIMIT_REACHED",
618
+ "ATTENDANT_NOT_FOUND",
619
+ "ATTENDANT_NOT_SIP_EXTENSION",
620
+ "AUDIO_FILE_CONTENT_MISSING",
621
+ "AUDIO_FILE_INVALID_FORMAT",
622
+ "AUDIO_FILE_IN_USE",
623
+ "AUDIO_FILE_NOT_FOUND",
624
+ "AUDIO_FILE_NOT_TTS",
625
+ "AUDIO_FILE_TOO_LARGE",
626
+ "AUDIO_URL_BLOCKED",
627
+ "AUDIO_URL_DECODE_FAILED",
628
+ "AUDIO_URL_HTTP_ERROR",
629
+ "AUDIO_URL_INVALID",
630
+ "AUDIO_URL_TIMEOUT",
631
+ "AUDIO_URL_TOO_LARGE",
632
+ "AUDIO_URL_UNREACHABLE",
633
+ "AUDIO_URL_UNSUPPORTED_FORMAT",
634
+ "AUDIT_CURSOR_INVALID",
635
+ "BUG_REPORTING_DISABLED",
636
+ "BUG_REPORT_DELIVERY_FAILED",
637
+ "CALL_HAS_NO_TRANSCRIPTION_WINDOW",
638
+ "CALL_NOT_FOUND",
639
+ "CALL_RECORD_CURSOR_INVALID",
640
+ "CANNOT_MANAGE_OWN_ACCOUNT",
641
+ "CANNOT_REMOVE_SELF",
642
+ "CANNOT_SUSPEND_SELF",
643
+ "CHANNEL_ALREADY_ASSIGNED",
644
+ "CHANNEL_CONNECTOR_NOT_ALLOWED",
645
+ "CHANNEL_CONNECTOR_REQUIRED",
646
+ "CHANNEL_CONNECTOR_UNAVAILABLE",
647
+ "CHANNEL_INVALID_CREDENTIALS",
648
+ "CHANNEL_NOT_FOUND",
649
+ "CHANNEL_VOICE_NOT_SUPPORTED",
650
+ "CHANNEL_WEBCHAT_IDENTITY_SECRET_REQUIRED",
651
+ "CHANNEL_WHATSAPP_NUMBER_NOT_IN_CONNECTOR",
652
+ "CHAT_MEDIA_NOT_FOUND",
653
+ "CHAT_MEDIA_TOO_LARGE",
654
+ "CHAT_MEDIA_UNSUPPORTED",
655
+ "CHAT_SESSION_NOT_FOUND",
656
+ "CONTACT_NOT_FOUND",
657
+ "CONVERSATION_CURSOR_INVALID",
658
+ "CONVERSATION_NOT_FOUND",
659
+ "DECISIONS_UNAVAILABLE",
660
+ "DESK_PUBLIC_URL_MISSING",
661
+ "DESTINATION_NOT_FOUND",
662
+ "DIALER_CAMPAIGN_INVALID_TRANSITION",
663
+ "DIALER_CAMPAIGN_NOT_FOUND",
664
+ "DIALER_CAMPAIGN_NO_CONTACTS",
665
+ "DIALER_CAMPAIGN_PLAN_NOT_PUBLISHED",
666
+ "DIALER_CONTACT_DUPLICATE",
667
+ "DIALER_CONTACT_NOT_EDITABLE",
668
+ "DIALER_CONTACT_NOT_REQUEUEABLE",
669
+ "DIALER_DNC_DUPLICATE",
670
+ "DIALER_IMPORT_INVALID",
671
+ "DIALER_IMPORT_JOB_NOT_FOUND",
672
+ "DIALER_MODULE_DISABLED",
673
+ "DIALER_PLAN_IN_USE",
674
+ "DISPOSITION_DUPLICATE",
675
+ "DISPOSITION_NOT_FOUND",
676
+ "DRAFT_STALE",
677
+ "DUPLICATE_CHANNEL",
678
+ "DUPLICATE_EMAIL",
679
+ "DUPLICATE_SIGNAL_SLUG",
680
+ "ESL_CONNECTION_ERROR",
681
+ "EXPORT_JOB_EXPIRED",
682
+ "EXPORT_JOB_LIMIT_REACHED",
683
+ "EXPORT_JOB_NOT_CANCELLABLE",
684
+ "EXPORT_JOB_NOT_FOUND",
685
+ "EXPORT_JOB_NOT_OWNER",
686
+ "EXPORT_JOB_NOT_READY",
687
+ "EXTENSION_IN_USE",
688
+ "EXTENSION_REQUIRED",
689
+ "FEATURE_DISABLED",
690
+ "FORBIDDEN",
691
+ "HANGUP_FAILED",
692
+ "HOLIDAY_CALENDAR_ENTRY_NOT_FOUND",
693
+ "HOLIDAY_CALENDAR_IN_USE",
694
+ "HOLIDAY_CALENDAR_NOT_FOUND",
695
+ "INSIGHT_PERIOD_TOO_LONG",
696
+ "INSUFFICIENT_PERMISSIONS",
697
+ "INSUFFICIENT_SCOPE",
698
+ "INVALID_CATALOG_CODE",
699
+ "INVALID_EXPORT_COLUMNS",
700
+ "INVALID_HOLIDAY_WINDOW",
701
+ "INVALID_SCHEDULE_INPUT",
702
+ "LAST_ADMINISTRATOR",
703
+ "LENGTH_REQUIRED",
704
+ "LICENSE_SUITE_BAD_REQUEST",
705
+ "LICENSE_SUITE_CONFLICT",
706
+ "LICENSE_SUITE_FORBIDDEN",
707
+ "LICENSE_SUITE_RATE_LIMITED",
708
+ "LICENSE_SUITE_UNAVAILABLE",
709
+ "LICENSE_SUITE_UNREACHABLE",
710
+ "LICENSE_V3_NOT_CONFIGURED",
711
+ "MAX_CUSTOM_ROLES_REACHED",
712
+ "MEMBER_NOT_FOUND",
713
+ "MEMBER_SUSPENDED",
714
+ "MFA_SETUP_REQUIRED",
715
+ "MODULE_DISABLED",
716
+ "NEW_USER_REQUIRES_PASSWORD",
717
+ "NODE_NOT_IN_TRACE",
718
+ "NODE_RANGE_INVALID",
719
+ "OAUTH_GRANT_FORBIDDEN",
720
+ "OAUTH_GRANT_NOT_FOUND",
721
+ "ORIGINATE_CAPACITY_EXCEEDED",
722
+ "ORIGINATE_DESTINATION_NOT_ROUTABLE",
723
+ "ORIGINATE_FAILED",
724
+ "ORIGINATE_PLAN_NOT_PUBLISHED",
725
+ "PAUSE_REASON_DUPLICATE",
726
+ "PAUSE_REASON_NOT_FOUND",
727
+ "PAUSE_REASON_REQUIRED",
728
+ "PERMISSION_CEILING_EXCEEDED",
729
+ "PLAN_NOT_FOUND",
730
+ "PLAN_NOT_PUBLISHED",
731
+ "PLAN_VALIDATION_FAILED",
732
+ "QUEUE_IN_USE",
733
+ "QUEUE_NAME_TAKEN",
734
+ "QUEUE_NOT_FOUND",
735
+ "RANGE_HAS_NO_AUDIO",
736
+ "RANGE_NOT_APPLICABLE",
737
+ "RANGE_NOT_SATISFIABLE",
738
+ "RECORDING_CONTENT_MISSING",
739
+ "RECORDING_NOT_FOUND",
740
+ "ROLE_NOT_FOUND",
741
+ "ROLE_SCOPE_MISMATCH",
742
+ "SAVED_REPLY_NOT_FOUND",
743
+ "SAVED_REPLY_SHORTCUT_TAKEN",
744
+ "SCHEDULE_EXCEPTION_NOT_FOUND",
745
+ "SCHEDULE_NOT_FOUND",
746
+ "SELF_ROTATION_FORBIDDEN",
747
+ "SIGNAL_ALERT_OPTION_REMOVED",
748
+ "SIGNAL_ARCHIVED",
749
+ "SIGNAL_DEFINITION_INVALID",
750
+ "SIGNAL_KIND_IMMUTABLE",
751
+ "SIGNAL_NOT_FOUND",
752
+ "SIGNAL_TEST_NO_TRANSCRIPTION",
753
+ "SIGNAL_TEST_SOURCE_INVALID",
754
+ "SIGNAL_VERSION_CONFLICT",
755
+ "SSO_REQUIRED",
756
+ "TRANSCRIPTION_CAPACITY_EXCEEDED",
757
+ "TRANSCRIPTION_NOT_FOUND",
758
+ "TTS_VOICE_UNAVAILABLE",
759
+ "UNAUTHORIZED",
760
+ "WEBCHAT_ORIGIN_DENIED",
761
+ "WEBCHAT_SESSION_INVALID",
762
+ "WEBHOOK_DELIVERY_AGGREGATE_NOT_FOUND",
763
+ "WEBHOOK_DELIVERY_CURSOR_INVALID",
764
+ "WEBHOOK_DELIVERY_NOT_RETRYABLE",
765
+ "WEBHOOK_DELIVERY_RETENTION_EXPIRED",
766
+ "WEBHOOK_ENDPOINT_NOT_FOUND",
767
+ "WINDOW_TOO_LONG",
768
+ "WRAP_UP_PENDING"
769
+ ];
770
+ var COMMON_ERROR_CODES2 = [];
771
+ var ERROR_CODE_SETS2 = [
772
+ [49, 157, 158],
773
+ [52, 157, 158],
774
+ [87, 110, 111, 156],
775
+ [50, 51, 100, 157, 158],
776
+ [32, 33, 87, 110, 111, 156],
777
+ [87, 93, 94, 110, 111, 156],
778
+ [35, 87, 93, 94, 110, 111, 156],
779
+ [36, 87, 93, 94, 110, 111, 156],
780
+ [58, 87, 93, 94, 110, 111, 156],
781
+ [8, 87, 93, 94, 110, 111, 156],
782
+ [81, 87, 93, 94, 110, 111, 156],
783
+ [87, 91, 93, 94, 110, 111, 156],
784
+ [87, 93, 94, 110, 111, 112, 156],
785
+ [87, 93, 94, 110, 111, 141, 156],
786
+ [87, 93, 94, 110, 111, 142, 156],
787
+ [87, 93, 94, 110, 111, 156, 159],
788
+ [87, 93, 94, 110, 111, 156, 160],
789
+ [87, 93, 94, 95, 110, 111, 156],
790
+ [87, 93, 94, 96, 110, 111, 156],
791
+ [87, 93, 94, 97, 110, 111, 156],
792
+ [15, 87, 93, 94, 110, 111, 112, 156],
793
+ [17, 20, 87, 93, 94, 110, 111, 156],
794
+ [18, 22, 87, 93, 94, 110, 111, 156],
795
+ [31, 87, 93, 94, 110, 111, 112, 156],
796
+ [35, 49, 87, 93, 94, 110, 111, 156],
797
+ [53, 87, 93, 94, 110, 111, 112, 156],
798
+ [54, 87, 93, 94, 110, 111, 112, 156],
799
+ [55, 87, 93, 94, 110, 111, 112, 156],
800
+ [79, 87, 93, 94, 110, 111, 112, 156],
801
+ [79, 87, 93, 94, 96, 110, 111, 156],
802
+ [81, 87, 93, 94, 110, 111, 112, 156],
803
+ [87, 89, 91, 93, 94, 110, 111, 156],
804
+ [87, 90, 91, 93, 94, 110, 111, 156],
805
+ [87, 91, 93, 94, 97, 110, 111, 156],
806
+ [87, 92, 93, 94, 110, 111, 112, 156],
807
+ [87, 93, 94, 109, 110, 111, 125, 156],
808
+ [87, 93, 94, 110, 111, 112, 131, 156],
809
+ [87, 93, 94, 110, 111, 112, 156, 163],
810
+ [87, 93, 94, 110, 111, 112, 156, 164],
811
+ [87, 93, 94, 110, 111, 116, 117, 156],
812
+ [87, 93, 94, 110, 111, 156, 161, 162],
813
+ [87, 93, 94, 98, 110, 111, 142, 156],
814
+ [1, 77, 87, 88, 93, 94, 110, 111, 156],
815
+ [13, 15, 87, 93, 94, 110, 111, 112, 156],
816
+ [15, 87, 93, 94, 110, 111, 112, 131, 156],
817
+ [3, 4, 5, 87, 93, 94, 110, 111, 156],
818
+ [49, 55, 87, 93, 94, 110, 111, 112, 156],
819
+ [53, 65, 87, 93, 94, 110, 111, 112, 156],
820
+ [66, 67, 87, 93, 94, 110, 111, 112, 156],
821
+ [7, 8, 87, 93, 94, 110, 111, 143, 156],
822
+ [78, 81, 83, 87, 93, 94, 110, 111, 156],
823
+ [80, 81, 82, 87, 93, 94, 110, 111, 156],
824
+ [86, 87, 93, 94, 110, 111, 112, 154, 156],
825
+ [87, 89, 91, 93, 94, 97, 110, 111, 156],
826
+ [87, 91, 93, 94, 95, 98, 110, 111, 156],
827
+ [87, 93, 94, 110, 111, 112, 122, 123, 156],
828
+ [87, 93, 94, 110, 111, 112, 126, 127, 156],
829
+ [87, 93, 94, 110, 111, 112, 126, 148, 156],
830
+ [87, 93, 94, 110, 111, 112, 129, 131, 156],
831
+ [87, 93, 94, 110, 111, 112, 139, 140, 156],
832
+ [87, 93, 94, 98, 110, 111, 141, 142, 156],
833
+ [0, 37, 87, 93, 94, 109, 110, 111, 125, 156],
834
+ [20, 87, 93, 94, 110, 111, 112, 130, 131, 156],
835
+ [3, 4, 5, 87, 93, 94, 110, 111, 112, 156],
836
+ [3, 4, 5, 87, 93, 94, 110, 111, 155, 156],
837
+ [35, 87, 93, 94, 110, 111, 134, 135, 136, 156],
838
+ [38, 87, 93, 94, 99, 109, 110, 111, 125, 156],
839
+ [39, 87, 93, 94, 99, 109, 110, 111, 125, 156],
840
+ [53, 60, 67, 87, 93, 94, 110, 111, 112, 156],
841
+ [60, 67, 68, 87, 93, 94, 110, 111, 112, 156],
842
+ [70, 87, 93, 94, 110, 111, 112, 126, 148, 156],
843
+ [71, 72, 87, 93, 94, 110, 111, 112, 131, 156],
844
+ [78, 81, 83, 87, 93, 94, 110, 111, 112, 156],
845
+ [80, 81, 82, 87, 93, 94, 110, 111, 112, 156],
846
+ [87, 91, 93, 94, 95, 98, 110, 111, 142, 156],
847
+ [15, 87, 93, 94, 110, 111, 112, 123, 124, 156, 165],
848
+ [2, 15, 16, 57, 87, 93, 94, 110, 111, 112, 156],
849
+ [53, 63, 64, 67, 87, 93, 94, 110, 111, 112, 156],
850
+ [73, 87, 93, 94, 110, 111, 112, 126, 128, 148, 156],
851
+ [59, 60, 61, 62, 69, 87, 93, 94, 110, 111, 112, 156],
852
+ [2, 12, 15, 57, 84, 85, 87, 93, 94, 110, 111, 112, 156],
853
+ [3, 4, 5, 19, 20, 21, 87, 93, 94, 110, 111, 155, 156],
854
+ [37, 38, 87, 93, 94, 99, 109, 110, 111, 125, 137, 138, 156],
855
+ [59, 60, 61, 62, 69, 87, 93, 94, 110, 111, 112, 126, 156],
856
+ [6, 75, 87, 93, 94, 110, 111, 113, 125, 137, 138, 152, 156],
857
+ [87, 93, 94, 101, 102, 103, 104, 105, 106, 107, 110, 111, 156],
858
+ [23, 24, 25, 26, 27, 28, 29, 30, 87, 93, 94, 110, 111, 156],
859
+ [77, 86, 87, 93, 94, 110, 111, 112, 118, 119, 120, 121, 126, 156],
860
+ [9, 10, 11, 14, 48, 87, 93, 94, 108, 110, 111, 112, 125, 156],
861
+ [4, 34, 87, 93, 94, 110, 111, 112, 114, 115, 132, 133, 136, 153, 156],
862
+ [2, 40, 41, 42, 43, 44, 45, 46, 47, 48, 74, 87, 93, 94, 110, 111, 112, 156],
863
+ [35, 56, 76, 87, 93, 94, 110, 111, 112, 126, 144, 145, 146, 147, 148, 149, 150, 151, 156],
864
+ [2, 6, 12, 14, 15, 57, 84, 85, 87, 93, 94, 109, 110, 111, 112, 125, 137, 138, 152, 156]
865
+ ];
866
+ var OPERATIONS2 = {
867
+ "ai.getBudget": {
868
+ method: "GET",
869
+ path: "/ai/budget",
870
+ pathParams: [],
871
+ queryParams: [],
872
+ bodyKind: "none",
873
+ responseKind: "json",
874
+ codes: 12
875
+ },
876
+ "ai.getBudgetOverview": {
877
+ method: "GET",
878
+ path: "/ai/budget/overview",
879
+ pathParams: [],
880
+ queryParams: [],
881
+ bodyKind: "none",
882
+ responseKind: "json",
883
+ codes: 12
884
+ },
885
+ "ai.getCallAnalyses": {
886
+ method: "GET",
887
+ path: "/call-records/{call_record_id}/analyses",
888
+ pathParams: ["call_record_id"],
889
+ queryParams: [],
890
+ bodyKind: "none",
891
+ responseKind: "json",
892
+ codes: 5
893
+ },
894
+ "ai.getTranscription": {
895
+ method: "GET",
896
+ path: "/call-records/{call_record_id}/transcription",
897
+ pathParams: ["call_record_id"],
898
+ queryParams: [],
899
+ bodyKind: "none",
900
+ responseKind: "json",
901
+ codes: 5
902
+ },
903
+ "ai.getUsage": {
904
+ method: "GET",
905
+ path: "/ai/usage",
906
+ pathParams: [],
907
+ queryParams: [],
908
+ bodyKind: "none",
909
+ responseKind: "json",
910
+ codes: 12
911
+ },
912
+ "ai.listAgents": {
913
+ method: "GET",
914
+ path: "/ai/agents",
915
+ pathParams: [],
916
+ queryParams: [],
917
+ bodyKind: "none",
918
+ responseKind: "json",
919
+ codes: 63
920
+ },
921
+ "ai.listStructuredAnalyses": {
922
+ method: "GET",
923
+ path: "/ai/structured-analyses",
924
+ pathParams: [],
925
+ queryParams: ["refresh"],
926
+ bodyKind: "none",
927
+ responseKind: "json",
928
+ codes: 12
929
+ },
930
+ "ai.runAnalysis": {
931
+ method: "POST",
932
+ path: "/call-records/{call_record_id}/analyses",
933
+ pathParams: ["call_record_id"],
934
+ queryParams: [],
935
+ bodyKind: "json",
936
+ responseKind: "json",
937
+ codes: 52
938
+ },
939
+ "ai.runConfiguredAnalyses": {
940
+ method: "POST",
941
+ path: "/call-records/{call_record_id}/configured-analyses",
942
+ pathParams: ["call_record_id"],
943
+ queryParams: [],
944
+ bodyKind: "json",
945
+ responseKind: "json",
946
+ codes: 52
947
+ },
948
+ "ai.runSpeechAnalytics": {
949
+ method: "POST",
950
+ path: "/call-records/{call_record_id}/speech-analytics",
951
+ pathParams: ["call_record_id"],
952
+ queryParams: [],
953
+ bodyKind: "json",
954
+ responseKind: "json",
955
+ codes: 12
956
+ },
957
+ "ai.searchTranscriptions": {
958
+ method: "GET",
959
+ path: "/transcriptions/search",
960
+ pathParams: [],
961
+ queryParams: ["query", "limit", "threshold", "date_from", "date_to", "visual_plan_id"],
962
+ bodyKind: "none",
963
+ responseKind: "json",
964
+ codes: 12
965
+ },
966
+ "ai.transcribeNow": {
967
+ method: "POST",
968
+ path: "/call-records/{call_record_id}/transcription",
969
+ pathParams: ["call_record_id"],
970
+ queryParams: [],
971
+ bodyKind: "json",
972
+ responseKind: "json",
973
+ codes: 89
974
+ },
975
+ "apiKeys.create": {
976
+ method: "POST",
977
+ path: "/api-keys",
978
+ pathParams: [],
979
+ queryParams: [],
980
+ bodyKind: "json",
981
+ responseKind: "json",
982
+ codes: 5
983
+ },
984
+ "apiKeys.finishRotation": {
985
+ method: "POST",
986
+ path: "/api-keys/{api_key_id}/finish-rotation",
987
+ pathParams: ["api_key_id"],
988
+ queryParams: [],
989
+ bodyKind: "none",
990
+ responseKind: "json",
991
+ codes: 9
992
+ },
993
+ "apiKeys.get": {
994
+ method: "GET",
995
+ path: "/api-keys/{api_key_id}",
996
+ pathParams: ["api_key_id"],
997
+ queryParams: [],
998
+ bodyKind: "none",
999
+ responseKind: "json",
1000
+ codes: 9
1001
+ },
1002
+ "apiKeys.list": {
1003
+ method: "GET",
1004
+ path: "/api-keys",
1005
+ pathParams: [],
1006
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
1007
+ bodyKind: "none",
1008
+ responseKind: "json",
1009
+ codes: 5
1010
+ },
1011
+ "apiKeys.revoke": {
1012
+ method: "DELETE",
1013
+ path: "/api-keys/{api_key_id}",
1014
+ pathParams: ["api_key_id"],
1015
+ queryParams: [],
1016
+ bodyKind: "none",
1017
+ responseKind: "json",
1018
+ codes: 9
1019
+ },
1020
+ "apiKeys.rotate": {
1021
+ method: "POST",
1022
+ path: "/api-keys/{api_key_id}/rotate",
1023
+ pathParams: ["api_key_id"],
1024
+ queryParams: [],
1025
+ bodyKind: "json",
1026
+ responseKind: "json",
1027
+ codes: 49
1028
+ },
1029
+ "apiKeys.update": {
1030
+ method: "PATCH",
1031
+ path: "/api-keys/{api_key_id}",
1032
+ pathParams: ["api_key_id"],
1033
+ queryParams: [],
1034
+ bodyKind: "json",
1035
+ responseKind: "json",
1036
+ codes: 9
1037
+ },
1038
+ "apiKeys.usage": {
1039
+ method: "GET",
1040
+ path: "/api-keys/{api_key_id}/usage",
1041
+ pathParams: ["api_key_id"],
1042
+ queryParams: ["days"],
1043
+ bodyKind: "none",
1044
+ responseKind: "json",
1045
+ codes: 9
1046
+ },
1047
+ "archive.listDeleted": {
1048
+ method: "GET",
1049
+ path: "/archive",
1050
+ pathParams: [],
1051
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "entity_type"],
1052
+ bodyKind: "none",
1053
+ responseKind: "json",
1054
+ codes: 88
1055
+ },
1056
+ "archive.purge": {
1057
+ method: "DELETE",
1058
+ path: "/archive/{entity_type}/{id}",
1059
+ pathParams: ["entity_type", "id"],
1060
+ queryParams: [],
1061
+ bodyKind: "none",
1062
+ responseKind: "json",
1063
+ codes: 88
1064
+ },
1065
+ "archive.restore": {
1066
+ method: "POST",
1067
+ path: "/archive/{entity_type}/{id}/restore",
1068
+ pathParams: ["entity_type", "id"],
1069
+ queryParams: [],
1070
+ bodyKind: "none",
1071
+ responseKind: "json",
1072
+ codes: 88
1073
+ },
1074
+ "archive.summary": {
1075
+ method: "GET",
1076
+ path: "/archive/summary",
1077
+ pathParams: [],
1078
+ queryParams: [],
1079
+ bodyKind: "none",
1080
+ responseKind: "json",
1081
+ codes: 88
1082
+ },
1083
+ "attendants.create": {
1084
+ method: "POST",
1085
+ path: "/desk/attendants",
1086
+ pathParams: [],
1087
+ queryParams: [],
1088
+ bodyKind: "json",
1089
+ responseKind: "json",
1090
+ codes: 92
1091
+ },
1092
+ "attendants.delete": {
1093
+ method: "DELETE",
1094
+ path: "/desk/attendants/{attendant_id}",
1095
+ pathParams: ["attendant_id"],
1096
+ queryParams: [],
1097
+ bodyKind: "none",
1098
+ responseKind: "json",
1099
+ codes: 43
1100
+ },
1101
+ "attendants.getById": {
1102
+ method: "GET",
1103
+ path: "/desk/attendants/{attendant_id}",
1104
+ pathParams: ["attendant_id"],
1105
+ queryParams: [],
1106
+ bodyKind: "none",
1107
+ responseKind: "json",
1108
+ codes: 20
1109
+ },
1110
+ "attendants.list": {
1111
+ method: "GET",
1112
+ path: "/desk/attendants",
1113
+ pathParams: [],
1114
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "status", "endpoint"],
1115
+ bodyKind: "none",
1116
+ responseKind: "json",
1117
+ codes: 12
1118
+ },
1119
+ "attendants.rotateSipCredential": {
1120
+ method: "POST",
1121
+ path: "/desk/attendants/{attendant_id}/sip-credential",
1122
+ pathParams: ["attendant_id"],
1123
+ queryParams: [],
1124
+ bodyKind: "none",
1125
+ responseKind: "json",
1126
+ codes: 76
1127
+ },
1128
+ "attendants.setStatus": {
1129
+ method: "POST",
1130
+ path: "/desk/attendants/{attendant_id}/status",
1131
+ pathParams: ["attendant_id"],
1132
+ queryParams: [],
1133
+ bodyKind: "json",
1134
+ responseKind: "json",
1135
+ codes: 75
1136
+ },
1137
+ "attendants.statusLog": {
1138
+ method: "GET",
1139
+ path: "/desk/attendants/{attendant_id}/status-log",
1140
+ pathParams: ["attendant_id"],
1141
+ queryParams: ["date_from", "date_to"],
1142
+ bodyKind: "none",
1143
+ responseKind: "json",
1144
+ codes: 20
1145
+ },
1146
+ "attendants.update": {
1147
+ method: "PATCH",
1148
+ path: "/desk/attendants/{attendant_id}",
1149
+ pathParams: ["attendant_id"],
1150
+ queryParams: [],
1151
+ bodyKind: "json",
1152
+ responseKind: "json",
1153
+ codes: 80
1154
+ },
1155
+ "audioFiles.content": {
1156
+ method: "GET",
1157
+ path: "/audio-files/{audio_file_id}/content",
1158
+ pathParams: ["audio_file_id"],
1159
+ queryParams: [],
1160
+ bodyKind: "none",
1161
+ responseKind: "binary",
1162
+ codes: 21
1163
+ },
1164
+ "audioFiles.delete": {
1165
+ method: "DELETE",
1166
+ path: "/audio-files/{audio_file_id}",
1167
+ pathParams: ["audio_file_id"],
1168
+ queryParams: [],
1169
+ bodyKind: "none",
1170
+ responseKind: "json",
1171
+ codes: 81
1172
+ },
1173
+ "audioFiles.generateTts": {
1174
+ method: "POST",
1175
+ path: "/audio-files/generate-tts",
1176
+ pathParams: [],
1177
+ queryParams: [],
1178
+ bodyKind: "json",
1179
+ responseKind: "json",
1180
+ codes: 81
1181
+ },
1182
+ "audioFiles.getById": {
1183
+ method: "GET",
1184
+ path: "/audio-files/{audio_file_id}",
1185
+ pathParams: ["audio_file_id"],
1186
+ queryParams: [],
1187
+ bodyKind: "none",
1188
+ responseKind: "json",
1189
+ codes: 81
1190
+ },
1191
+ "audioFiles.list": {
1192
+ method: "GET",
1193
+ path: "/audio-files",
1194
+ pathParams: [],
1195
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
1196
+ bodyKind: "none",
1197
+ responseKind: "json",
1198
+ codes: 5
1199
+ },
1200
+ "audioFiles.previewUrl": {
1201
+ method: "POST",
1202
+ path: "/audio-files/preview-url",
1203
+ pathParams: [],
1204
+ queryParams: [],
1205
+ bodyKind: "json",
1206
+ responseKind: "binary",
1207
+ codes: 86
1208
+ },
1209
+ "audioFiles.regenerateTts": {
1210
+ method: "POST",
1211
+ path: "/audio-files/{audio_file_id}/regenerate-tts",
1212
+ pathParams: ["audio_file_id"],
1213
+ queryParams: [],
1214
+ bodyKind: "json",
1215
+ responseKind: "json",
1216
+ codes: 81
1217
+ },
1218
+ "audioFiles.update": {
1219
+ method: "PATCH",
1220
+ path: "/audio-files/{audio_file_id}",
1221
+ pathParams: ["audio_file_id"],
1222
+ queryParams: [],
1223
+ bodyKind: "json",
1224
+ responseKind: "json",
1225
+ codes: 81
1226
+ },
1227
+ "audioFiles.upload": {
1228
+ method: "POST",
1229
+ path: "/audio-files/upload",
1230
+ pathParams: [],
1231
+ queryParams: [],
1232
+ bodyKind: "multipart",
1233
+ responseKind: "json",
1234
+ codes: 22
1235
+ },
1236
+ "audit.count": {
1237
+ method: "GET",
1238
+ path: "/audit-logs/count",
1239
+ pathParams: [],
1240
+ queryParams: [
1241
+ "search",
1242
+ "action",
1243
+ "actions",
1244
+ "resource_type",
1245
+ "resource_types",
1246
+ "auth_kind",
1247
+ "credential_id",
1248
+ "retention_class",
1249
+ "date_from",
1250
+ "date_to"
1251
+ ],
1252
+ bodyKind: "none",
1253
+ responseKind: "json",
1254
+ codes: 12
1255
+ },
1256
+ "audit.exportCsv": {
1257
+ method: "GET",
1258
+ path: "/audit-logs/export",
1259
+ pathParams: [],
1260
+ queryParams: [
1261
+ "search",
1262
+ "action",
1263
+ "actions",
1264
+ "resource_type",
1265
+ "resource_types",
1266
+ "auth_kind",
1267
+ "credential_id",
1268
+ "retention_class",
1269
+ "date_from",
1270
+ "date_to"
1271
+ ],
1272
+ bodyKind: "none",
1273
+ responseKind: "sse",
1274
+ codes: 12
1275
+ },
1276
+ "audit.exportJobCancel": {
1277
+ method: "POST",
1278
+ path: "/audit-logs/exports/{export_job_id}/cancel",
1279
+ pathParams: ["export_job_id"],
1280
+ queryParams: [],
1281
+ bodyKind: "none",
1282
+ responseKind: "json",
1283
+ codes: 73
1284
+ },
1285
+ "audit.exportJobCreate": {
1286
+ method: "POST",
1287
+ path: "/audit-logs/exports",
1288
+ pathParams: [],
1289
+ queryParams: [],
1290
+ bodyKind: "json",
1291
+ responseKind: "json",
1292
+ codes: 28
1293
+ },
1294
+ "audit.exportJobDownload": {
1295
+ method: "GET",
1296
+ path: "/audit-logs/exports/{export_job_id}/download",
1297
+ pathParams: ["export_job_id"],
1298
+ queryParams: [],
1299
+ bodyKind: "none",
1300
+ responseKind: "binary",
1301
+ codes: 72
1302
+ },
1303
+ "audit.exportJobGet": {
1304
+ method: "GET",
1305
+ path: "/audit-logs/exports/{export_job_id}",
1306
+ pathParams: ["export_job_id"],
1307
+ queryParams: [],
1308
+ bodyKind: "none",
1309
+ responseKind: "json",
1310
+ codes: 30
1311
+ },
1312
+ "audit.exportJobList": {
1313
+ method: "GET",
1314
+ path: "/audit-logs/exports",
1315
+ pathParams: [],
1316
+ queryParams: [],
1317
+ bodyKind: "none",
1318
+ responseKind: "json",
1319
+ codes: 12
1320
+ },
1321
+ "audit.exportJobProgress": {
1322
+ method: "GET",
1323
+ path: "/audit-logs/exports/{export_job_id}/progress",
1324
+ pathParams: ["export_job_id"],
1325
+ queryParams: [],
1326
+ bodyKind: "none",
1327
+ responseKind: "sse",
1328
+ codes: 30
1329
+ },
1330
+ "audit.list": {
1331
+ method: "GET",
1332
+ path: "/audit-logs",
1333
+ pathParams: [],
1334
+ queryParams: [
1335
+ "search",
1336
+ "page",
1337
+ "limit",
1338
+ "sort_by",
1339
+ "sort_order",
1340
+ "action",
1341
+ "actions",
1342
+ "resource_type",
1343
+ "resource_types",
1344
+ "auth_kind",
1345
+ "credential_id",
1346
+ "retention_class",
1347
+ "date_from",
1348
+ "date_to",
1349
+ "cursor"
1350
+ ],
1351
+ bodyKind: "none",
1352
+ responseKind: "json",
1353
+ codes: 23
1354
+ },
1355
+ "bugReports.create": {
1356
+ method: "POST",
1357
+ path: "/bug-reports",
1358
+ pathParams: [],
1359
+ queryParams: [],
1360
+ bodyKind: "json",
1361
+ responseKind: "json",
1362
+ codes: 4
1363
+ },
1364
+ "callRecords.chatMediaContent": {
1365
+ method: "GET",
1366
+ path: "/call-records/{call_record_id}/media/{media_id}",
1367
+ pathParams: ["call_record_id", "media_id"],
1368
+ queryParams: [],
1369
+ bodyKind: "none",
1370
+ responseKind: "binary",
1371
+ codes: 24
1372
+ },
1373
+ "callRecords.count": {
1374
+ method: "GET",
1375
+ path: "/call-records/count",
1376
+ pathParams: [],
1377
+ queryParams: [
1378
+ "search",
1379
+ "call_record_id",
1380
+ "uuid",
1381
+ "sip_call_id",
1382
+ "date_from",
1383
+ "date_to",
1384
+ "visual_plan_id",
1385
+ "channel_id",
1386
+ "status",
1387
+ "caller_search",
1388
+ "min_duration",
1389
+ "max_duration",
1390
+ "has_recording",
1391
+ "has_transcription",
1392
+ "recording_states",
1393
+ "transcription_states",
1394
+ "analysis_states",
1395
+ "has_error",
1396
+ "has_structured_analysis",
1397
+ "has_structured_analysis_error",
1398
+ "channel_type",
1399
+ "origin",
1400
+ "signal_id",
1401
+ "signal_triggered",
1402
+ "signal_value",
1403
+ "metadata"
1404
+ ],
1405
+ bodyKind: "none",
1406
+ responseKind: "json",
1407
+ codes: 5
1408
+ },
1409
+ "callRecords.exportCsv": {
1410
+ method: "GET",
1411
+ path: "/call-records/export",
1412
+ pathParams: [],
1413
+ queryParams: [
1414
+ "date_from",
1415
+ "date_to",
1416
+ "visual_plan_id",
1417
+ "channel_id",
1418
+ "status",
1419
+ "search",
1420
+ "min_duration",
1421
+ "max_duration",
1422
+ "channel_type",
1423
+ "origin",
1424
+ "signal_id",
1425
+ "signal_triggered",
1426
+ "signal_value",
1427
+ "has_recording",
1428
+ "has_transcription",
1429
+ "recording_states",
1430
+ "transcription_states",
1431
+ "analysis_states",
1432
+ "has_error",
1433
+ "has_structured_analysis",
1434
+ "has_structured_analysis_error",
1435
+ "metadata",
1436
+ "apply_table_filters",
1437
+ "separator",
1438
+ "columns",
1439
+ "include_events"
1440
+ ],
1441
+ bodyKind: "none",
1442
+ responseKind: "sse",
1443
+ codes: 18
1444
+ },
1445
+ "callRecords.exportJobCancel": {
1446
+ method: "POST",
1447
+ path: "/call-records/exports/{export_job_id}/cancel",
1448
+ pathParams: ["export_job_id"],
1449
+ queryParams: [],
1450
+ bodyKind: "none",
1451
+ responseKind: "json",
1452
+ codes: 51
1453
+ },
1454
+ "callRecords.exportJobCreate": {
1455
+ method: "POST",
1456
+ path: "/call-records/exports",
1457
+ pathParams: [],
1458
+ queryParams: [],
1459
+ bodyKind: "json",
1460
+ responseKind: "json",
1461
+ codes: 29
1462
+ },
1463
+ "callRecords.exportJobDownload": {
1464
+ method: "GET",
1465
+ path: "/call-records/exports/{export_job_id}/download",
1466
+ pathParams: ["export_job_id"],
1467
+ queryParams: [],
1468
+ bodyKind: "none",
1469
+ responseKind: "binary",
1470
+ codes: 50
1471
+ },
1472
+ "callRecords.exportJobGet": {
1473
+ method: "GET",
1474
+ path: "/call-records/exports/{export_job_id}",
1475
+ pathParams: ["export_job_id"],
1476
+ queryParams: [],
1477
+ bodyKind: "none",
1478
+ responseKind: "json",
1479
+ codes: 10
1480
+ },
1481
+ "callRecords.exportJobList": {
1482
+ method: "GET",
1483
+ path: "/call-records/exports",
1484
+ pathParams: [],
1485
+ queryParams: [],
1486
+ bodyKind: "none",
1487
+ responseKind: "json",
1488
+ codes: 5
1489
+ },
1490
+ "callRecords.exportJobProgress": {
1491
+ method: "GET",
1492
+ path: "/call-records/exports/{export_job_id}/progress",
1493
+ pathParams: ["export_job_id"],
1494
+ queryParams: [],
1495
+ bodyKind: "none",
1496
+ responseKind: "sse",
1497
+ codes: 10
1498
+ },
1499
+ "callRecords.getById": {
1500
+ method: "GET",
1501
+ path: "/call-records/{call_record_id}",
1502
+ pathParams: ["call_record_id"],
1503
+ queryParams: [],
1504
+ bodyKind: "none",
1505
+ responseKind: "json",
1506
+ codes: 5
1507
+ },
1508
+ "callRecords.getEvents": {
1509
+ method: "GET",
1510
+ path: "/call-records/{call_record_id}/events",
1511
+ pathParams: ["call_record_id"],
1512
+ queryParams: [],
1513
+ bodyKind: "none",
1514
+ responseKind: "json",
1515
+ codes: 5
1516
+ },
1517
+ "callRecords.getRecordingUrl": {
1518
+ method: "GET",
1519
+ path: "/call-records/{call_record_id}/recording-url",
1520
+ pathParams: ["call_record_id"],
1521
+ queryParams: ["ttl_seconds"],
1522
+ bodyKind: "none",
1523
+ responseKind: "json",
1524
+ codes: 5
1525
+ },
1526
+ "callRecords.list": {
1527
+ method: "GET",
1528
+ path: "/call-records",
1529
+ pathParams: [],
1530
+ queryParams: [
1531
+ "search",
1532
+ "page",
1533
+ "limit",
1534
+ "sort_by",
1535
+ "sort_order",
1536
+ "call_record_id",
1537
+ "uuid",
1538
+ "sip_call_id",
1539
+ "date_from",
1540
+ "date_to",
1541
+ "visual_plan_id",
1542
+ "channel_id",
1543
+ "status",
1544
+ "caller_search",
1545
+ "min_duration",
1546
+ "max_duration",
1547
+ "has_recording",
1548
+ "has_transcription",
1549
+ "recording_states",
1550
+ "transcription_states",
1551
+ "analysis_states",
1552
+ "has_error",
1553
+ "has_structured_analysis",
1554
+ "has_structured_analysis_error",
1555
+ "channel_type",
1556
+ "origin",
1557
+ "signal_id",
1558
+ "signal_triggered",
1559
+ "signal_value",
1560
+ "include_signals",
1561
+ "metadata",
1562
+ "cursor"
1563
+ ],
1564
+ bodyKind: "none",
1565
+ responseKind: "json",
1566
+ codes: 7
1567
+ },
1568
+ "callRecords.purgeVoiceContent": {
1569
+ method: "POST",
1570
+ path: "/call-records/{call_record_id}/purge-voice",
1571
+ pathParams: ["call_record_id"],
1572
+ queryParams: [],
1573
+ bodyKind: "none",
1574
+ responseKind: "json",
1575
+ codes: 6
1576
+ },
1577
+ "callRecords.recordingContent": {
1578
+ method: "GET",
1579
+ path: "/call-records/{call_record_id}/recording",
1580
+ pathParams: ["call_record_id"],
1581
+ queryParams: [],
1582
+ bodyKind: "none",
1583
+ responseKind: "binary",
1584
+ codes: 65
1585
+ },
1586
+ "callRecords.retryRecording": {
1587
+ method: "POST",
1588
+ path: "/call-records/{call_record_id}/recording/retry",
1589
+ pathParams: ["call_record_id"],
1590
+ queryParams: [],
1591
+ bodyKind: "none",
1592
+ responseKind: "json",
1593
+ codes: 5
1594
+ },
1595
+ "calls.hangupCall": {
1596
+ method: "POST",
1597
+ path: "/calls/{call_id}/hangup",
1598
+ pathParams: ["call_id"],
1599
+ queryParams: [],
1600
+ bodyKind: "none",
1601
+ responseKind: "json",
1602
+ codes: 42
1603
+ },
1604
+ "calls.originate": {
1605
+ method: "POST",
1606
+ path: "/calls",
1607
+ pathParams: [],
1608
+ queryParams: [],
1609
+ bodyKind: "json",
1610
+ responseKind: "json",
1611
+ codes: 87
1612
+ },
1613
+ "capabilities.get": {
1614
+ method: "GET",
1615
+ path: "/capabilities",
1616
+ pathParams: [],
1617
+ queryParams: [],
1618
+ bodyKind: "none",
1619
+ responseKind: "json",
1620
+ codes: 2
1621
+ },
1622
+ "channels.create": {
1623
+ method: "POST",
1624
+ path: "/channels",
1625
+ pathParams: [],
1626
+ queryParams: [],
1627
+ bodyKind: "json",
1628
+ responseKind: "json",
1629
+ codes: 90
1630
+ },
1631
+ "channels.delete": {
1632
+ method: "DELETE",
1633
+ path: "/channels/{channel_id}",
1634
+ pathParams: ["channel_id"],
1635
+ queryParams: [],
1636
+ bodyKind: "none",
1637
+ responseKind: "json",
1638
+ codes: 90
1639
+ },
1640
+ "channels.getById": {
1641
+ method: "GET",
1642
+ path: "/channels/{channel_id}",
1643
+ pathParams: ["channel_id"],
1644
+ queryParams: [],
1645
+ bodyKind: "none",
1646
+ responseKind: "json",
1647
+ codes: 90
1648
+ },
1649
+ "channels.list": {
1650
+ method: "GET",
1651
+ path: "/channels",
1652
+ pathParams: [],
1653
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "channel_type", "is_active", "alert"],
1654
+ bodyKind: "none",
1655
+ responseKind: "json",
1656
+ codes: 90
1657
+ },
1658
+ "channels.rotateWebchatKey": {
1659
+ method: "POST",
1660
+ path: "/channels/{channel_id}/rotate-webchat-key",
1661
+ pathParams: ["channel_id"],
1662
+ queryParams: [],
1663
+ bodyKind: "none",
1664
+ responseKind: "json",
1665
+ codes: 90
1666
+ },
1667
+ "channels.rotateWebchatSecret": {
1668
+ method: "POST",
1669
+ path: "/channels/{channel_id}/rotate-webchat-secret",
1670
+ pathParams: ["channel_id"],
1671
+ queryParams: [],
1672
+ bodyKind: "none",
1673
+ responseKind: "json",
1674
+ codes: 90
1675
+ },
1676
+ "channels.testConnection": {
1677
+ method: "POST",
1678
+ path: "/channels/test-connection",
1679
+ pathParams: [],
1680
+ queryParams: [],
1681
+ bodyKind: "json",
1682
+ responseKind: "json",
1683
+ codes: 90
1684
+ },
1685
+ "channels.toggle": {
1686
+ method: "POST",
1687
+ path: "/channels/{channel_id}/toggle-active",
1688
+ pathParams: ["channel_id"],
1689
+ queryParams: [],
1690
+ bodyKind: "json",
1691
+ responseKind: "json",
1692
+ codes: 90
1693
+ },
1694
+ "channels.update": {
1695
+ method: "PATCH",
1696
+ path: "/channels/{channel_id}",
1697
+ pathParams: ["channel_id"],
1698
+ queryParams: [],
1699
+ bodyKind: "json",
1700
+ responseKind: "json",
1701
+ codes: 90
1702
+ },
1703
+ "chat.createMedia": {
1704
+ method: "POST",
1705
+ path: "/chat/media",
1706
+ pathParams: [],
1707
+ queryParams: [],
1708
+ bodyKind: "multipart",
1709
+ responseKind: "json",
1710
+ codes: 3
1711
+ },
1712
+ "chat.createSession": {
1713
+ method: "POST",
1714
+ path: "/chat/sessions",
1715
+ pathParams: [],
1716
+ queryParams: [],
1717
+ bodyKind: "json",
1718
+ responseKind: "json",
1719
+ codes: 56
1720
+ },
1721
+ "chat.endSession": {
1722
+ method: "DELETE",
1723
+ path: "/chat/sessions/{session_id}",
1724
+ pathParams: ["session_id"],
1725
+ queryParams: [],
1726
+ bodyKind: "none",
1727
+ responseKind: "empty",
1728
+ codes: 1
1729
+ },
1730
+ "chat.getMedia": {
1731
+ method: "GET",
1732
+ path: "/chat/media/{media_id}",
1733
+ pathParams: ["media_id"],
1734
+ queryParams: [],
1735
+ bodyKind: "none",
1736
+ responseKind: "binary",
1737
+ codes: 0
1738
+ },
1739
+ "contacts.getById": {
1740
+ method: "GET",
1741
+ path: "/contacts/{contact_id}",
1742
+ pathParams: ["contact_id"],
1743
+ queryParams: [],
1744
+ bodyKind: "none",
1745
+ responseKind: "json",
1746
+ codes: 25
1747
+ },
1748
+ "contacts.list": {
1749
+ method: "GET",
1750
+ path: "/contacts",
1751
+ pathParams: [],
1752
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
1753
+ bodyKind: "none",
1754
+ responseKind: "json",
1755
+ codes: 12
1756
+ },
1757
+ "contacts.update": {
1758
+ method: "PATCH",
1759
+ path: "/contacts/{contact_id}",
1760
+ pathParams: ["contact_id"],
1761
+ queryParams: [],
1762
+ bodyKind: "json",
1763
+ responseKind: "json",
1764
+ codes: 25
1765
+ },
1766
+ "conversations.count": {
1767
+ method: "GET",
1768
+ path: "/desk/conversations/count",
1769
+ pathParams: [],
1770
+ queryParams: [
1771
+ "search",
1772
+ "date_from",
1773
+ "date_to",
1774
+ "attendant_id",
1775
+ "channel",
1776
+ "status",
1777
+ "outcome",
1778
+ "call_record_id",
1779
+ "queue_id",
1780
+ "disposition_id"
1781
+ ],
1782
+ bodyKind: "none",
1783
+ responseKind: "json",
1784
+ codes: 12
1785
+ },
1786
+ "conversations.getById": {
1787
+ method: "GET",
1788
+ path: "/desk/conversations/{conversation_id}",
1789
+ pathParams: ["conversation_id"],
1790
+ queryParams: [],
1791
+ bodyKind: "none",
1792
+ responseKind: "json",
1793
+ codes: 27
1794
+ },
1795
+ "conversations.list": {
1796
+ method: "GET",
1797
+ path: "/desk/conversations",
1798
+ pathParams: [],
1799
+ queryParams: [
1800
+ "search",
1801
+ "page",
1802
+ "limit",
1803
+ "sort_by",
1804
+ "sort_order",
1805
+ "date_from",
1806
+ "date_to",
1807
+ "attendant_id",
1808
+ "channel",
1809
+ "status",
1810
+ "outcome",
1811
+ "call_record_id",
1812
+ "queue_id",
1813
+ "disposition_id",
1814
+ "cursor"
1815
+ ],
1816
+ bodyKind: "none",
1817
+ responseKind: "json",
1818
+ codes: 26
1819
+ },
1820
+ "conversations.mediaContent": {
1821
+ method: "GET",
1822
+ path: "/desk/conversations/{conversation_id}/media/{media_id}",
1823
+ pathParams: ["conversation_id", "media_id"],
1824
+ queryParams: [],
1825
+ bodyKind: "none",
1826
+ responseKind: "binary",
1827
+ codes: 46
1828
+ },
1829
+ "dashboard.capacityStatus": {
1830
+ method: "GET",
1831
+ path: "/capacity",
1832
+ pathParams: [],
1833
+ queryParams: [],
1834
+ bodyKind: "none",
1835
+ responseKind: "json",
1836
+ codes: 5
1837
+ },
1838
+ "dashboard.watchDashboardMetrics": {
1839
+ method: "GET",
1840
+ path: "/capacity/stream",
1841
+ pathParams: [],
1842
+ queryParams: [],
1843
+ bodyKind: "none",
1844
+ responseKind: "sse",
1845
+ codes: 5
1846
+ },
1847
+ "desk.copilot.stats": {
1848
+ method: "GET",
1849
+ path: "/desk/copilot/stats",
1850
+ pathParams: [],
1851
+ queryParams: ["from", "to", "queue_id"],
1852
+ bodyKind: "none",
1853
+ responseKind: "json",
1854
+ codes: 38
1855
+ },
1856
+ "desk.transferQueues": {
1857
+ method: "GET",
1858
+ path: "/desk/transfer-queues",
1859
+ pathParams: [],
1860
+ queryParams: [],
1861
+ bodyKind: "none",
1862
+ responseKind: "json",
1863
+ codes: 12
1864
+ },
1865
+ "deskSettings.copilotAgents": {
1866
+ method: "POST",
1867
+ path: "/deskSettings/copilotAgents",
1868
+ pathParams: [],
1869
+ queryParams: [],
1870
+ bodyKind: "none",
1871
+ responseKind: "json",
1872
+ codes: 12
1873
+ },
1874
+ "deskSettings.createDefaults": {
1875
+ method: "POST",
1876
+ path: "/desk/defaults",
1877
+ pathParams: [],
1878
+ queryParams: [],
1879
+ bodyKind: "none",
1880
+ responseKind: "json",
1881
+ codes: 12
1882
+ },
1883
+ "deskSettings.createDisposition": {
1884
+ method: "POST",
1885
+ path: "/desk/dispositions",
1886
+ pathParams: [],
1887
+ queryParams: [],
1888
+ bodyKind: "json",
1889
+ responseKind: "json",
1890
+ codes: 71
1891
+ },
1892
+ "deskSettings.createPauseReason": {
1893
+ method: "POST",
1894
+ path: "/desk/pause-reasons",
1895
+ pathParams: [],
1896
+ queryParams: [],
1897
+ bodyKind: "json",
1898
+ responseKind: "json",
1899
+ codes: 55
1900
+ },
1901
+ "deskSettings.deleteDisposition": {
1902
+ method: "DELETE",
1903
+ path: "/desk/dispositions/{disposition_id}",
1904
+ pathParams: ["disposition_id"],
1905
+ queryParams: [],
1906
+ bodyKind: "none",
1907
+ responseKind: "json",
1908
+ codes: 71
1909
+ },
1910
+ "deskSettings.deletePauseReason": {
1911
+ method: "DELETE",
1912
+ path: "/desk/pause-reasons/{pause_reason_id}",
1913
+ pathParams: ["pause_reason_id"],
1914
+ queryParams: [],
1915
+ bodyKind: "none",
1916
+ responseKind: "json",
1917
+ codes: 55
1918
+ },
1919
+ "deskSettings.get": {
1920
+ method: "GET",
1921
+ path: "/desk/settings",
1922
+ pathParams: [],
1923
+ queryParams: [],
1924
+ bodyKind: "none",
1925
+ responseKind: "json",
1926
+ codes: 12
1927
+ },
1928
+ "deskSettings.listDispositions": {
1929
+ method: "GET",
1930
+ path: "/desk/dispositions",
1931
+ pathParams: [],
1932
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "queue_id"],
1933
+ bodyKind: "none",
1934
+ responseKind: "json",
1935
+ codes: 12
1936
+ },
1937
+ "deskSettings.listPauseReasons": {
1938
+ method: "GET",
1939
+ path: "/desk/pause-reasons",
1940
+ pathParams: [],
1941
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
1942
+ bodyKind: "none",
1943
+ responseKind: "json",
1944
+ codes: 12
1945
+ },
1946
+ "deskSettings.reorderDispositions": {
1947
+ method: "POST",
1948
+ path: "/desk/dispositions/reorder",
1949
+ pathParams: [],
1950
+ queryParams: [],
1951
+ bodyKind: "json",
1952
+ responseKind: "json",
1953
+ codes: 71
1954
+ },
1955
+ "deskSettings.reorderPauseReasons": {
1956
+ method: "POST",
1957
+ path: "/desk/pause-reasons/reorder",
1958
+ pathParams: [],
1959
+ queryParams: [],
1960
+ bodyKind: "json",
1961
+ responseKind: "json",
1962
+ codes: 55
1963
+ },
1964
+ "deskSettings.update": {
1965
+ method: "PATCH",
1966
+ path: "/desk/settings",
1967
+ pathParams: [],
1968
+ queryParams: [],
1969
+ bodyKind: "json",
1970
+ responseKind: "json",
1971
+ codes: 12
1972
+ },
1973
+ "deskSettings.updateDisposition": {
1974
+ method: "PATCH",
1975
+ path: "/desk/dispositions/{disposition_id}",
1976
+ pathParams: ["disposition_id"],
1977
+ queryParams: [],
1978
+ bodyKind: "json",
1979
+ responseKind: "json",
1980
+ codes: 71
1981
+ },
1982
+ "deskSettings.updatePauseReason": {
1983
+ method: "PATCH",
1984
+ path: "/desk/pause-reasons/{pause_reason_id}",
1985
+ pathParams: ["pause_reason_id"],
1986
+ queryParams: [],
1987
+ bodyKind: "json",
1988
+ responseKind: "json",
1989
+ codes: 55
1990
+ },
1991
+ "destinations.create": {
1992
+ method: "POST",
1993
+ path: "/destinations",
1994
+ pathParams: [],
1995
+ queryParams: [],
1996
+ bodyKind: "json",
1997
+ responseKind: "json",
1998
+ codes: 5
1999
+ },
2000
+ "destinations.delete": {
2001
+ method: "DELETE",
2002
+ path: "/destinations/{destination_id}",
2003
+ pathParams: ["destination_id"],
2004
+ queryParams: [],
2005
+ bodyKind: "none",
2006
+ responseKind: "json",
2007
+ codes: 8
2008
+ },
2009
+ "destinations.getById": {
2010
+ method: "GET",
2011
+ path: "/destinations/{destination_id}",
2012
+ pathParams: ["destination_id"],
2013
+ queryParams: [],
2014
+ bodyKind: "none",
2015
+ responseKind: "json",
2016
+ codes: 8
2017
+ },
2018
+ "destinations.list": {
2019
+ method: "GET",
2020
+ path: "/destinations",
2021
+ pathParams: [],
2022
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2023
+ bodyKind: "none",
2024
+ responseKind: "json",
2025
+ codes: 5
2026
+ },
2027
+ "destinations.update": {
2028
+ method: "PATCH",
2029
+ path: "/destinations/{destination_id}",
2030
+ pathParams: ["destination_id"],
2031
+ queryParams: [],
2032
+ bodyKind: "json",
2033
+ responseKind: "json",
2034
+ codes: 8
2035
+ },
2036
+ "dialerAttempts.list": {
2037
+ method: "GET",
2038
+ path: "/dialer/campaigns/{campaign_id}/attempts",
2039
+ pathParams: ["campaign_id"],
2040
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "date_from", "date_to", "status", "contact_id"],
2041
+ bodyKind: "none",
2042
+ responseKind: "json",
2043
+ codes: 12
2044
+ },
2045
+ "dialerCampaigns.control": {
2046
+ method: "POST",
2047
+ path: "/dialer/campaigns/{campaign_id}/control",
2048
+ pathParams: ["campaign_id"],
2049
+ queryParams: [],
2050
+ bodyKind: "json",
2051
+ responseKind: "json",
2052
+ codes: 79
2053
+ },
2054
+ "dialerCampaigns.create": {
2055
+ method: "POST",
2056
+ path: "/dialer/campaigns",
2057
+ pathParams: [],
2058
+ queryParams: [],
2059
+ bodyKind: "json",
2060
+ responseKind: "json",
2061
+ codes: 83
2062
+ },
2063
+ "dialerCampaigns.delete": {
2064
+ method: "DELETE",
2065
+ path: "/dialer/campaigns/{campaign_id}",
2066
+ pathParams: ["campaign_id"],
2067
+ queryParams: [],
2068
+ bodyKind: "none",
2069
+ responseKind: "json",
2070
+ codes: 79
2071
+ },
2072
+ "dialerCampaigns.get": {
2073
+ method: "GET",
2074
+ path: "/dialer/campaigns/{campaign_id}",
2075
+ pathParams: ["campaign_id"],
2076
+ queryParams: [],
2077
+ bodyKind: "none",
2078
+ responseKind: "json",
2079
+ codes: 79
2080
+ },
2081
+ "dialerCampaigns.list": {
2082
+ method: "GET",
2083
+ path: "/dialer/campaigns",
2084
+ pathParams: [],
2085
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "status"],
2086
+ bodyKind: "none",
2087
+ responseKind: "json",
2088
+ codes: 12
2089
+ },
2090
+ "dialerCampaigns.liveStats": {
2091
+ method: "GET",
2092
+ path: "/dialer/campaigns/{campaign_id}/stats/stream",
2093
+ pathParams: ["campaign_id"],
2094
+ queryParams: [],
2095
+ bodyKind: "none",
2096
+ responseKind: "sse",
2097
+ codes: 79
2098
+ },
2099
+ "dialerCampaigns.orgLiveStats": {
2100
+ method: "GET",
2101
+ path: "/dialer/campaigns/stats/stream",
2102
+ pathParams: [],
2103
+ queryParams: [],
2104
+ bodyKind: "none",
2105
+ responseKind: "sse",
2106
+ codes: 12
2107
+ },
2108
+ "dialerCampaigns.stats": {
2109
+ method: "GET",
2110
+ path: "/dialer/campaigns/{campaign_id}/stats",
2111
+ pathParams: ["campaign_id"],
2112
+ queryParams: [],
2113
+ bodyKind: "none",
2114
+ responseKind: "json",
2115
+ codes: 79
2116
+ },
2117
+ "dialerCampaigns.summary": {
2118
+ method: "GET",
2119
+ path: "/dialer/campaigns/summary",
2120
+ pathParams: [],
2121
+ queryParams: [],
2122
+ bodyKind: "none",
2123
+ responseKind: "json",
2124
+ codes: 12
2125
+ },
2126
+ "dialerCampaigns.update": {
2127
+ method: "PATCH",
2128
+ path: "/dialer/campaigns/{campaign_id}",
2129
+ pathParams: ["campaign_id"],
2130
+ queryParams: [],
2131
+ bodyKind: "json",
2132
+ responseKind: "json",
2133
+ codes: 79
2134
+ },
2135
+ "dialerContacts.add": {
2136
+ method: "POST",
2137
+ path: "/dialer/campaigns/{campaign_id}/contacts",
2138
+ pathParams: ["campaign_id"],
2139
+ queryParams: [],
2140
+ bodyKind: "json",
2141
+ responseKind: "json",
2142
+ codes: 68
2143
+ },
2144
+ "dialerContacts.bulkCancel": {
2145
+ method: "POST",
2146
+ path: "/dialer/campaigns/{campaign_id}/contacts/bulk-cancel",
2147
+ pathParams: ["campaign_id"],
2148
+ queryParams: [],
2149
+ bodyKind: "json",
2150
+ responseKind: "json",
2151
+ codes: 12
2152
+ },
2153
+ "dialerContacts.bulkRequeue": {
2154
+ method: "POST",
2155
+ path: "/dialer/campaigns/{campaign_id}/contacts/bulk-requeue",
2156
+ pathParams: ["campaign_id"],
2157
+ queryParams: [],
2158
+ bodyKind: "json",
2159
+ responseKind: "json",
2160
+ codes: 12
2161
+ },
2162
+ "dialerContacts.cancel": {
2163
+ method: "POST",
2164
+ path: "/dialer/campaigns/{campaign_id}/contacts/{contact_id}/cancel",
2165
+ pathParams: ["campaign_id", "contact_id"],
2166
+ queryParams: [],
2167
+ bodyKind: "none",
2168
+ responseKind: "json",
2169
+ codes: 68
2170
+ },
2171
+ "dialerContacts.exportCsv": {
2172
+ method: "GET",
2173
+ path: "/dialer/campaigns/{campaign_id}/contacts/export",
2174
+ pathParams: ["campaign_id"],
2175
+ queryParams: ["date_from", "date_to", "status", "search"],
2176
+ bodyKind: "none",
2177
+ responseKind: "sse",
2178
+ codes: 12
2179
+ },
2180
+ "dialerContacts.get": {
2181
+ method: "GET",
2182
+ path: "/dialer/campaigns/{campaign_id}/contacts/{contact_id}",
2183
+ pathParams: ["campaign_id", "contact_id"],
2184
+ queryParams: [],
2185
+ bodyKind: "none",
2186
+ responseKind: "json",
2187
+ codes: 25
2188
+ },
2189
+ "dialerContacts.list": {
2190
+ method: "GET",
2191
+ path: "/dialer/campaigns/{campaign_id}/contacts",
2192
+ pathParams: ["campaign_id"],
2193
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "date_from", "date_to", "status"],
2194
+ bodyKind: "none",
2195
+ responseKind: "json",
2196
+ codes: 12
2197
+ },
2198
+ "dialerContacts.remove": {
2199
+ method: "POST",
2200
+ path: "/dialer/campaigns/{campaign_id}/contacts/bulk-remove",
2201
+ pathParams: ["campaign_id"],
2202
+ queryParams: [],
2203
+ bodyKind: "json",
2204
+ responseKind: "json",
2205
+ codes: 12
2206
+ },
2207
+ "dialerContacts.requeue": {
2208
+ method: "POST",
2209
+ path: "/dialer/campaigns/{campaign_id}/contacts/{contact_id}/requeue",
2210
+ pathParams: ["campaign_id", "contact_id"],
2211
+ queryParams: [],
2212
+ bodyKind: "none",
2213
+ responseKind: "json",
2214
+ codes: 47
2215
+ },
2216
+ "dialerContacts.requeueAll": {
2217
+ method: "POST",
2218
+ path: "/dialer/campaigns/{campaign_id}/contacts/requeue-all",
2219
+ pathParams: ["campaign_id"],
2220
+ queryParams: [],
2221
+ bodyKind: "json",
2222
+ responseKind: "json",
2223
+ codes: 12
2224
+ },
2225
+ "dialerContacts.update": {
2226
+ method: "PATCH",
2227
+ path: "/dialer/campaigns/{campaign_id}/contacts/{contact_id}",
2228
+ pathParams: ["campaign_id", "contact_id"],
2229
+ queryParams: [],
2230
+ bodyKind: "json",
2231
+ responseKind: "json",
2232
+ codes: 77
2233
+ },
2234
+ "dialerDnc.add": {
2235
+ method: "POST",
2236
+ path: "/dialer/dnc",
2237
+ pathParams: [],
2238
+ queryParams: [],
2239
+ bodyKind: "json",
2240
+ responseKind: "json",
2241
+ codes: 48
2242
+ },
2243
+ "dialerDnc.bulkImport": {
2244
+ method: "POST",
2245
+ path: "/dialer/dnc/bulk-import",
2246
+ pathParams: [],
2247
+ queryParams: [],
2248
+ bodyKind: "json",
2249
+ responseKind: "json",
2250
+ codes: 12
2251
+ },
2252
+ "dialerDnc.bulkRemove": {
2253
+ method: "POST",
2254
+ path: "/dialer/dnc/bulk-remove",
2255
+ pathParams: [],
2256
+ queryParams: [],
2257
+ bodyKind: "json",
2258
+ responseKind: "json",
2259
+ codes: 12
2260
+ },
2261
+ "dialerDnc.list": {
2262
+ method: "GET",
2263
+ path: "/dialer/dnc",
2264
+ pathParams: [],
2265
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2266
+ bodyKind: "none",
2267
+ responseKind: "json",
2268
+ codes: 12
2269
+ },
2270
+ "dialerDnc.remove": {
2271
+ method: "DELETE",
2272
+ path: "/dialer/dnc/{dnc_id}",
2273
+ pathParams: ["dnc_id"],
2274
+ queryParams: [],
2275
+ bodyKind: "none",
2276
+ responseKind: "json",
2277
+ codes: 12
2278
+ },
2279
+ "dialerImports.create": {
2280
+ method: "POST",
2281
+ path: "/dialer/campaigns/{campaign_id}/imports",
2282
+ pathParams: ["campaign_id"],
2283
+ queryParams: [],
2284
+ bodyKind: "json",
2285
+ responseKind: "json",
2286
+ codes: 69
2287
+ },
2288
+ "dialerImports.get": {
2289
+ method: "GET",
2290
+ path: "/dialer/imports/{import_job_id}",
2291
+ pathParams: ["import_job_id"],
2292
+ queryParams: [],
2293
+ bodyKind: "none",
2294
+ responseKind: "json",
2295
+ codes: 69
2296
+ },
2297
+ "dialerImports.invalidRows": {
2298
+ method: "GET",
2299
+ path: "/dialer/imports/{import_job_id}/invalid-rows",
2300
+ pathParams: ["import_job_id"],
2301
+ queryParams: [],
2302
+ bodyKind: "none",
2303
+ responseKind: "json",
2304
+ codes: 69
2305
+ },
2306
+ "dialerImports.progress": {
2307
+ method: "GET",
2308
+ path: "/dialer/imports/{import_job_id}/progress",
2309
+ pathParams: ["import_job_id"],
2310
+ queryParams: [],
2311
+ bodyKind: "none",
2312
+ responseKind: "sse",
2313
+ codes: 69
2314
+ },
2315
+ "holidayCalendars.create": {
2316
+ method: "POST",
2317
+ path: "/holiday-calendars",
2318
+ pathParams: [],
2319
+ queryParams: [],
2320
+ bodyKind: "json",
2321
+ responseKind: "json",
2322
+ codes: 5
2323
+ },
2324
+ "holidayCalendars.delete": {
2325
+ method: "DELETE",
2326
+ path: "/holiday-calendars/{holiday_calendar_id}",
2327
+ pathParams: ["holiday_calendar_id"],
2328
+ queryParams: [],
2329
+ bodyKind: "none",
2330
+ responseKind: "json",
2331
+ codes: 32
2332
+ },
2333
+ "holidayCalendars.entries.create": {
2334
+ method: "POST",
2335
+ path: "/holiday-calendars/{holiday_calendar_id}/entries",
2336
+ pathParams: ["holiday_calendar_id"],
2337
+ queryParams: [],
2338
+ bodyKind: "json",
2339
+ responseKind: "json",
2340
+ codes: 33
2341
+ },
2342
+ "holidayCalendars.entries.delete": {
2343
+ method: "DELETE",
2344
+ path: "/holiday-calendars/{holiday_calendar_id}/entries/{holiday_calendar_entry_id}",
2345
+ pathParams: ["holiday_calendar_id", "holiday_calendar_entry_id"],
2346
+ queryParams: [],
2347
+ bodyKind: "none",
2348
+ responseKind: "json",
2349
+ codes: 31
2350
+ },
2351
+ "holidayCalendars.entries.getById": {
2352
+ method: "GET",
2353
+ path: "/holiday-calendars/{holiday_calendar_id}/entries/{holiday_calendar_entry_id}",
2354
+ pathParams: ["holiday_calendar_id", "holiday_calendar_entry_id"],
2355
+ queryParams: [],
2356
+ bodyKind: "none",
2357
+ responseKind: "json",
2358
+ codes: 31
2359
+ },
2360
+ "holidayCalendars.entries.list": {
2361
+ method: "GET",
2362
+ path: "/holiday-calendars/{holiday_calendar_id}/entries",
2363
+ pathParams: ["holiday_calendar_id"],
2364
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "year"],
2365
+ bodyKind: "none",
2366
+ responseKind: "json",
2367
+ codes: 11
2368
+ },
2369
+ "holidayCalendars.entries.update": {
2370
+ method: "PATCH",
2371
+ path: "/holiday-calendars/{holiday_calendar_id}/entries/{holiday_calendar_entry_id}",
2372
+ pathParams: ["holiday_calendar_id", "holiday_calendar_entry_id"],
2373
+ queryParams: [],
2374
+ bodyKind: "json",
2375
+ responseKind: "json",
2376
+ codes: 53
2377
+ },
2378
+ "holidayCalendars.getById": {
2379
+ method: "GET",
2380
+ path: "/holiday-calendars/{holiday_calendar_id}",
2381
+ pathParams: ["holiday_calendar_id"],
2382
+ queryParams: [],
2383
+ bodyKind: "none",
2384
+ responseKind: "json",
2385
+ codes: 11
2386
+ },
2387
+ "holidayCalendars.importIcs": {
2388
+ method: "POST",
2389
+ path: "/holiday-calendars/{holiday_calendar_id}/import-ics",
2390
+ pathParams: ["holiday_calendar_id"],
2391
+ queryParams: [],
2392
+ bodyKind: "json",
2393
+ responseKind: "json",
2394
+ codes: 11
2395
+ },
2396
+ "holidayCalendars.list": {
2397
+ method: "GET",
2398
+ path: "/holiday-calendars",
2399
+ pathParams: [],
2400
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2401
+ bodyKind: "none",
2402
+ responseKind: "json",
2403
+ codes: 5
2404
+ },
2405
+ "holidayCalendars.previewRule": {
2406
+ method: "POST",
2407
+ path: "/holiday-calendars/preview-rule",
2408
+ pathParams: [],
2409
+ queryParams: [],
2410
+ bodyKind: "json",
2411
+ responseKind: "json",
2412
+ codes: 19
2413
+ },
2414
+ "holidayCalendars.update": {
2415
+ method: "PATCH",
2416
+ path: "/holiday-calendars/{holiday_calendar_id}",
2417
+ pathParams: ["holiday_calendar_id"],
2418
+ queryParams: [],
2419
+ bodyKind: "json",
2420
+ responseKind: "json",
2421
+ codes: 11
2422
+ },
2423
+ "holidayCatalog.countries": {
2424
+ method: "GET",
2425
+ path: "/holiday-catalog/countries",
2426
+ pathParams: [],
2427
+ queryParams: [],
2428
+ bodyKind: "none",
2429
+ responseKind: "json",
2430
+ codes: 5
2431
+ },
2432
+ "holidayCatalog.holidays": {
2433
+ method: "GET",
2434
+ path: "/holiday-catalog/{code}/holidays",
2435
+ pathParams: ["code"],
2436
+ queryParams: ["year"],
2437
+ bodyKind: "none",
2438
+ responseKind: "json",
2439
+ codes: 17
2440
+ },
2441
+ "holidayCatalog.regions": {
2442
+ method: "GET",
2443
+ path: "/holiday-catalog/countries/{country_code}/regions",
2444
+ pathParams: ["country_code"],
2445
+ queryParams: [],
2446
+ bodyKind: "none",
2447
+ responseKind: "json",
2448
+ codes: 17
2449
+ },
2450
+ "insights.aggregate": {
2451
+ method: "POST",
2452
+ path: "/insights/aggregate",
2453
+ pathParams: [],
2454
+ queryParams: [],
2455
+ bodyKind: "json",
2456
+ responseKind: "json",
2457
+ codes: 34
2458
+ },
2459
+ "license.activate": {
2460
+ method: "POST",
2461
+ path: "/license/activate",
2462
+ pathParams: [],
2463
+ queryParams: [],
2464
+ bodyKind: "json",
2465
+ responseKind: "json",
2466
+ codes: 85
2467
+ },
2468
+ "license.activation": {
2469
+ method: "GET",
2470
+ path: "/license/activation",
2471
+ pathParams: [],
2472
+ queryParams: [],
2473
+ bodyKind: "none",
2474
+ responseKind: "json",
2475
+ codes: 5
2476
+ },
2477
+ "license.modules": {
2478
+ method: "GET",
2479
+ path: "/license/modules",
2480
+ pathParams: [],
2481
+ queryParams: [],
2482
+ bodyKind: "none",
2483
+ responseKind: "json",
2484
+ codes: 2
2485
+ },
2486
+ "license.orgUsage": {
2487
+ method: "GET",
2488
+ path: "/license/org-usage",
2489
+ pathParams: [],
2490
+ queryParams: [],
2491
+ bodyKind: "none",
2492
+ responseKind: "json",
2493
+ codes: 2
2494
+ },
2495
+ "license.refresh": {
2496
+ method: "POST",
2497
+ path: "/license/refresh",
2498
+ pathParams: [],
2499
+ queryParams: [],
2500
+ bodyKind: "none",
2501
+ responseKind: "json",
2502
+ codes: 85
2503
+ },
2504
+ "license.status": {
2505
+ method: "GET",
2506
+ path: "/license/status",
2507
+ pathParams: [],
2508
+ queryParams: [],
2509
+ bodyKind: "none",
2510
+ responseKind: "json",
2511
+ codes: 5
2512
+ },
2513
+ "license.usage": {
2514
+ method: "GET",
2515
+ path: "/license/usage",
2516
+ pathParams: [],
2517
+ queryParams: [],
2518
+ bodyKind: "none",
2519
+ responseKind: "json",
2520
+ codes: 5
2521
+ },
2522
+ "nodes.list": {
2523
+ method: "GET",
2524
+ path: "/nodes",
2525
+ pathParams: [],
2526
+ queryParams: [],
2527
+ bodyKind: "none",
2528
+ responseKind: "json",
2529
+ codes: 2
2530
+ },
2531
+ "nodes.schema": {
2532
+ method: "GET",
2533
+ path: "/nodes/{node_type}/schema",
2534
+ pathParams: ["node_type"],
2535
+ queryParams: [],
2536
+ bodyKind: "none",
2537
+ responseKind: "json",
2538
+ codes: 2
2539
+ },
2540
+ "oauthGrants.get": {
2541
+ method: "GET",
2542
+ path: "/oauth-grants/{oauth_grant_id}",
2543
+ pathParams: ["oauth_grant_id"],
2544
+ queryParams: [],
2545
+ bodyKind: "none",
2546
+ responseKind: "json",
2547
+ codes: 39
2548
+ },
2549
+ "oauthGrants.list": {
2550
+ method: "GET",
2551
+ path: "/oauth-grants",
2552
+ pathParams: [],
2553
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2554
+ bodyKind: "none",
2555
+ responseKind: "json",
2556
+ codes: 5
2557
+ },
2558
+ "oauthGrants.revoke": {
2559
+ method: "DELETE",
2560
+ path: "/oauth-grants/{oauth_grant_id}",
2561
+ pathParams: ["oauth_grant_id"],
2562
+ queryParams: [],
2563
+ bodyKind: "none",
2564
+ responseKind: "json",
2565
+ codes: 39
2566
+ },
2567
+ "oauthGrants.usage": {
2568
+ method: "GET",
2569
+ path: "/oauth-grants/{oauth_grant_id}/usage",
2570
+ pathParams: ["oauth_grant_id"],
2571
+ queryParams: ["days"],
2572
+ bodyKind: "none",
2573
+ responseKind: "json",
2574
+ codes: 39
2575
+ },
2576
+ "orgSettings.getDialer": {
2577
+ method: "GET",
2578
+ path: "/organization/dialer-settings",
2579
+ pathParams: [],
2580
+ queryParams: [],
2581
+ bodyKind: "none",
2582
+ responseKind: "json",
2583
+ codes: 5
2584
+ },
2585
+ "orgSettings.upsertDialer": {
2586
+ method: "PATCH",
2587
+ path: "/organization/dialer-settings",
2588
+ pathParams: [],
2589
+ queryParams: [],
2590
+ bodyKind: "json",
2591
+ responseKind: "json",
2592
+ codes: 12
2593
+ },
2594
+ "queues.addMembers": {
2595
+ method: "POST",
2596
+ path: "/queues/{queue_id}/members/batch",
2597
+ pathParams: ["queue_id"],
2598
+ queryParams: [],
2599
+ bodyKind: "json",
2600
+ responseKind: "json",
2601
+ codes: 44
2602
+ },
2603
+ "queues.create": {
2604
+ method: "POST",
2605
+ path: "/queues",
2606
+ pathParams: [],
2607
+ queryParams: [],
2608
+ bodyKind: "json",
2609
+ responseKind: "json",
2610
+ codes: 62
2611
+ },
2612
+ "queues.delete": {
2613
+ method: "DELETE",
2614
+ path: "/queues/{queue_id}",
2615
+ pathParams: ["queue_id"],
2616
+ queryParams: [],
2617
+ bodyKind: "none",
2618
+ responseKind: "json",
2619
+ codes: 58
2620
+ },
2621
+ "queues.getById": {
2622
+ method: "GET",
2623
+ path: "/queues/{queue_id}",
2624
+ pathParams: ["queue_id"],
2625
+ queryParams: [],
2626
+ bodyKind: "none",
2627
+ responseKind: "json",
2628
+ codes: 36
2629
+ },
2630
+ "queues.list": {
2631
+ method: "GET",
2632
+ path: "/queues",
2633
+ pathParams: [],
2634
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2635
+ bodyKind: "none",
2636
+ responseKind: "json",
2637
+ codes: 12
2638
+ },
2639
+ "queues.listMembers": {
2640
+ method: "GET",
2641
+ path: "/queues/{queue_id}/members",
2642
+ pathParams: ["queue_id"],
2643
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2644
+ bodyKind: "none",
2645
+ responseKind: "json",
2646
+ codes: 36
2647
+ },
2648
+ "queues.removeMember": {
2649
+ method: "DELETE",
2650
+ path: "/queues/{queue_id}/members/{attendant_id}",
2651
+ pathParams: ["queue_id", "attendant_id"],
2652
+ queryParams: [],
2653
+ bodyKind: "none",
2654
+ responseKind: "json",
2655
+ codes: 44
2656
+ },
2657
+ "queues.replaceMembers": {
2658
+ method: "PUT",
2659
+ path: "/queues/{queue_id}/members",
2660
+ pathParams: ["queue_id"],
2661
+ queryParams: [],
2662
+ bodyKind: "json",
2663
+ responseKind: "json",
2664
+ codes: 44
2665
+ },
2666
+ "queues.stats": {
2667
+ method: "GET",
2668
+ path: "/queues/{queue_id}/stats",
2669
+ pathParams: ["queue_id"],
2670
+ queryParams: [],
2671
+ bodyKind: "none",
2672
+ responseKind: "json",
2673
+ codes: 36
2674
+ },
2675
+ "queues.update": {
2676
+ method: "PATCH",
2677
+ path: "/queues/{queue_id}",
2678
+ pathParams: ["queue_id"],
2679
+ queryParams: [],
2680
+ bodyKind: "json",
2681
+ responseKind: "json",
2682
+ codes: 62
2683
+ },
2684
+ "queues.updateMember": {
2685
+ method: "PATCH",
2686
+ path: "/queues/{queue_id}/members/{attendant_id}",
2687
+ pathParams: ["queue_id", "attendant_id"],
2688
+ queryParams: [],
2689
+ bodyKind: "json",
2690
+ responseKind: "json",
2691
+ codes: 44
2692
+ },
2693
+ "savedReplies.create": {
2694
+ method: "POST",
2695
+ path: "/desk/saved-replies",
2696
+ pathParams: [],
2697
+ queryParams: [],
2698
+ bodyKind: "json",
2699
+ responseKind: "json",
2700
+ codes: 59
2701
+ },
2702
+ "savedReplies.delete": {
2703
+ method: "DELETE",
2704
+ path: "/desk/saved-replies/{saved_reply_id}",
2705
+ pathParams: ["saved_reply_id"],
2706
+ queryParams: [],
2707
+ bodyKind: "none",
2708
+ responseKind: "json",
2709
+ codes: 59
2710
+ },
2711
+ "savedReplies.get": {
2712
+ method: "GET",
2713
+ path: "/desk/saved-replies/{saved_reply_id}",
2714
+ pathParams: ["saved_reply_id"],
2715
+ queryParams: [],
2716
+ bodyKind: "none",
2717
+ responseKind: "json",
2718
+ codes: 59
2719
+ },
2720
+ "savedReplies.list": {
2721
+ method: "GET",
2722
+ path: "/desk/saved-replies",
2723
+ pathParams: [],
2724
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "channel", "q"],
2725
+ bodyKind: "none",
2726
+ responseKind: "json",
2727
+ codes: 12
2728
+ },
2729
+ "savedReplies.update": {
2730
+ method: "PATCH",
2731
+ path: "/desk/saved-replies/{saved_reply_id}",
2732
+ pathParams: ["saved_reply_id"],
2733
+ queryParams: [],
2734
+ bodyKind: "json",
2735
+ responseKind: "json",
2736
+ codes: 59
2737
+ },
2738
+ "scheduleExceptions.create": {
2739
+ method: "POST",
2740
+ path: "/schedule-exceptions",
2741
+ pathParams: [],
2742
+ queryParams: [],
2743
+ bodyKind: "json",
2744
+ responseKind: "json",
2745
+ codes: 41
2746
+ },
2747
+ "scheduleExceptions.delete": {
2748
+ method: "DELETE",
2749
+ path: "/schedule-exceptions/{schedule_exception_id}",
2750
+ pathParams: ["schedule_exception_id"],
2751
+ queryParams: [],
2752
+ bodyKind: "none",
2753
+ responseKind: "json",
2754
+ codes: 13
2755
+ },
2756
+ "scheduleExceptions.getById": {
2757
+ method: "GET",
2758
+ path: "/schedule-exceptions/{schedule_exception_id}",
2759
+ pathParams: ["schedule_exception_id"],
2760
+ queryParams: [],
2761
+ bodyKind: "none",
2762
+ responseKind: "json",
2763
+ codes: 13
2764
+ },
2765
+ "scheduleExceptions.list": {
2766
+ method: "GET",
2767
+ path: "/schedule-exceptions",
2768
+ pathParams: [],
2769
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "schedule_id"],
2770
+ bodyKind: "none",
2771
+ responseKind: "json",
2772
+ codes: 5
2773
+ },
2774
+ "scheduleExceptions.update": {
2775
+ method: "PATCH",
2776
+ path: "/schedule-exceptions/{schedule_exception_id}",
2777
+ pathParams: ["schedule_exception_id"],
2778
+ queryParams: [],
2779
+ bodyKind: "json",
2780
+ responseKind: "json",
2781
+ codes: 60
2782
+ },
2783
+ "schedules.calendar": {
2784
+ method: "GET",
2785
+ path: "/schedules/{schedule_id}/calendar",
2786
+ pathParams: ["schedule_id"],
2787
+ queryParams: ["month"],
2788
+ bodyKind: "none",
2789
+ responseKind: "json",
2790
+ codes: 41
2791
+ },
2792
+ "schedules.clearEmergency": {
2793
+ method: "DELETE",
2794
+ path: "/schedules/{schedule_id}/emergency",
2795
+ pathParams: ["schedule_id"],
2796
+ queryParams: [],
2797
+ bodyKind: "none",
2798
+ responseKind: "json",
2799
+ codes: 14
2800
+ },
2801
+ "schedules.create": {
2802
+ method: "POST",
2803
+ path: "/schedules",
2804
+ pathParams: [],
2805
+ queryParams: [],
2806
+ bodyKind: "json",
2807
+ responseKind: "json",
2808
+ codes: 54
2809
+ },
2810
+ "schedules.delete": {
2811
+ method: "DELETE",
2812
+ path: "/schedules/{schedule_id}",
2813
+ pathParams: ["schedule_id"],
2814
+ queryParams: [],
2815
+ bodyKind: "none",
2816
+ responseKind: "json",
2817
+ codes: 14
2818
+ },
2819
+ "schedules.getById": {
2820
+ method: "GET",
2821
+ path: "/schedules/{schedule_id}",
2822
+ pathParams: ["schedule_id"],
2823
+ queryParams: [],
2824
+ bodyKind: "none",
2825
+ responseKind: "json",
2826
+ codes: 14
2827
+ },
2828
+ "schedules.holidays": {
2829
+ method: "GET",
2830
+ path: "/schedules/{schedule_id}/holidays",
2831
+ pathParams: ["schedule_id"],
2832
+ queryParams: ["from", "to"],
2833
+ bodyKind: "none",
2834
+ responseKind: "json",
2835
+ codes: 41
2836
+ },
2837
+ "schedules.list": {
2838
+ method: "GET",
2839
+ path: "/schedules",
2840
+ pathParams: [],
2841
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2842
+ bodyKind: "none",
2843
+ responseKind: "json",
2844
+ codes: 5
2845
+ },
2846
+ "schedules.previewHolidays": {
2847
+ method: "POST",
2848
+ path: "/schedules/holidays/preview",
2849
+ pathParams: [],
2850
+ queryParams: [],
2851
+ bodyKind: "json",
2852
+ responseKind: "json",
2853
+ codes: 54
2854
+ },
2855
+ "schedules.setEmergency": {
2856
+ method: "POST",
2857
+ path: "/schedules/{schedule_id}/emergency",
2858
+ pathParams: ["schedule_id"],
2859
+ queryParams: [],
2860
+ bodyKind: "json",
2861
+ responseKind: "json",
2862
+ codes: 41
2863
+ },
2864
+ "schedules.simulate": {
2865
+ method: "POST",
2866
+ path: "/schedules/{schedule_id}/simulate",
2867
+ pathParams: ["schedule_id"],
2868
+ queryParams: [],
2869
+ bodyKind: "json",
2870
+ responseKind: "json",
2871
+ codes: 41
2872
+ },
2873
+ "schedules.upcoming": {
2874
+ method: "GET",
2875
+ path: "/schedules/upcoming",
2876
+ pathParams: [],
2877
+ queryParams: ["days"],
2878
+ bodyKind: "none",
2879
+ responseKind: "json",
2880
+ codes: 5
2881
+ },
2882
+ "schedules.update": {
2883
+ method: "PATCH",
2884
+ path: "/schedules/{schedule_id}",
2885
+ pathParams: ["schedule_id"],
2886
+ queryParams: [],
2887
+ bodyKind: "json",
2888
+ responseKind: "json",
2889
+ codes: 74
2890
+ },
2891
+ "schedules.usage": {
2892
+ method: "GET",
2893
+ path: "/schedules/{schedule_id}/usage",
2894
+ pathParams: ["schedule_id"],
2895
+ queryParams: [],
2896
+ bodyKind: "none",
2897
+ responseKind: "json",
2898
+ codes: 14
2899
+ },
2900
+ "secrets.list": {
2901
+ method: "GET",
2902
+ path: "/secrets",
2903
+ pathParams: [],
2904
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
2905
+ bodyKind: "none",
2906
+ responseKind: "json",
2907
+ codes: 5
2908
+ },
2909
+ "secrets.listNames": {
2910
+ method: "GET",
2911
+ path: "/secrets/names",
2912
+ pathParams: [],
2913
+ queryParams: [],
2914
+ bodyKind: "none",
2915
+ responseKind: "json",
2916
+ codes: 5
2917
+ },
2918
+ "signals.callSignals": {
2919
+ method: "GET",
2920
+ path: "/call-records/{call_id}/signals",
2921
+ pathParams: ["call_id"],
2922
+ queryParams: ["locale"],
2923
+ bodyKind: "none",
2924
+ responseKind: "json",
2925
+ codes: 91
2926
+ },
2927
+ "signals.create": {
2928
+ method: "POST",
2929
+ path: "/signals",
2930
+ pathParams: [],
2931
+ queryParams: [],
2932
+ bodyKind: "json",
2933
+ responseKind: "json",
2934
+ codes: 91
2935
+ },
2936
+ "signals.delete": {
2937
+ method: "DELETE",
2938
+ path: "/signals/{signal_id}",
2939
+ pathParams: ["signal_id"],
2940
+ queryParams: [],
2941
+ bodyKind: "none",
2942
+ responseKind: "json",
2943
+ codes: 91
2944
+ },
2945
+ "signals.get": {
2946
+ method: "GET",
2947
+ path: "/signals/{signal_id}",
2948
+ pathParams: ["signal_id"],
2949
+ queryParams: [],
2950
+ bodyKind: "none",
2951
+ responseKind: "json",
2952
+ codes: 91
2953
+ },
2954
+ "signals.list": {
2955
+ method: "GET",
2956
+ path: "/signals",
2957
+ pathParams: [],
2958
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "include_archived"],
2959
+ bodyKind: "none",
2960
+ responseKind: "json",
2961
+ codes: 12
2962
+ },
2963
+ "signals.overview": {
2964
+ method: "GET",
2965
+ path: "/signals/overview",
2966
+ pathParams: [],
2967
+ queryParams: [],
2968
+ bodyKind: "none",
2969
+ responseKind: "json",
2970
+ codes: 12
2971
+ },
2972
+ "signals.presets": {
2973
+ method: "GET",
2974
+ path: "/signals/presets",
2975
+ pathParams: [],
2976
+ queryParams: ["locale"],
2977
+ bodyKind: "none",
2978
+ responseKind: "json",
2979
+ codes: 12
2980
+ },
2981
+ "signals.test": {
2982
+ method: "POST",
2983
+ path: "/signals/test",
2984
+ pathParams: [],
2985
+ queryParams: [],
2986
+ bodyKind: "json",
2987
+ responseKind: "json",
2988
+ codes: 91
2989
+ },
2990
+ "signals.update": {
2991
+ method: "PATCH",
2992
+ path: "/signals/{signal_id}",
2993
+ pathParams: ["signal_id"],
2994
+ queryParams: [],
2995
+ bodyKind: "json",
2996
+ responseKind: "json",
2997
+ codes: 91
2998
+ },
2999
+ "signals.upsertBySlug": {
3000
+ method: "PUT",
3001
+ path: "/signals/by-slug/{slug}",
3002
+ pathParams: ["slug"],
3003
+ queryParams: [],
3004
+ bodyKind: "json",
3005
+ responseKind: "json",
3006
+ codes: 91
3007
+ },
3008
+ "tts.listModels": {
3009
+ method: "GET",
3010
+ path: "/tts/models",
3011
+ pathParams: [],
3012
+ queryParams: [],
3013
+ bodyKind: "none",
3014
+ responseKind: "json",
3015
+ codes: 45
3016
+ },
3017
+ "tts.listVoices": {
3018
+ method: "GET",
3019
+ path: "/tts/voices",
3020
+ pathParams: [],
3021
+ queryParams: ["language", "model"],
3022
+ bodyKind: "none",
3023
+ responseKind: "json",
3024
+ codes: 45
3025
+ },
3026
+ "tts.preview": {
3027
+ method: "POST",
3028
+ path: "/tts/preview",
3029
+ pathParams: [],
3030
+ queryParams: [],
3031
+ bodyKind: "json",
3032
+ responseKind: "binary",
3033
+ codes: 64
3034
+ },
3035
+ "users.activateMember": {
3036
+ method: "POST",
3037
+ path: "/members/{user_id}/activate",
3038
+ pathParams: ["user_id"],
3039
+ queryParams: [],
3040
+ bodyKind: "none",
3041
+ responseKind: "json",
3042
+ codes: 35
3043
+ },
3044
+ "users.createMember": {
3045
+ method: "POST",
3046
+ path: "/members",
3047
+ pathParams: [],
3048
+ queryParams: [],
3049
+ bodyKind: "json",
3050
+ responseKind: "json",
3051
+ codes: 84
3052
+ },
3053
+ "users.listMembers": {
3054
+ method: "GET",
3055
+ path: "/members",
3056
+ pathParams: [],
3057
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "status", "role_id"],
3058
+ bodyKind: "none",
3059
+ responseKind: "json",
3060
+ codes: 5
3061
+ },
3062
+ "users.me": {
3063
+ method: "GET",
3064
+ path: "/users/me",
3065
+ pathParams: [],
3066
+ queryParams: [],
3067
+ bodyKind: "none",
3068
+ responseKind: "json",
3069
+ codes: 2
3070
+ },
3071
+ "users.removeMember": {
3072
+ method: "DELETE",
3073
+ path: "/members/{user_id}",
3074
+ pathParams: ["user_id"],
3075
+ queryParams: [],
3076
+ bodyKind: "none",
3077
+ responseKind: "json",
3078
+ codes: 66
3079
+ },
3080
+ "users.resetSecondFactor": {
3081
+ method: "POST",
3082
+ path: "/members/{user_id}/reset-second-factor",
3083
+ pathParams: ["user_id"],
3084
+ queryParams: [],
3085
+ bodyKind: "none",
3086
+ responseKind: "json",
3087
+ codes: 61
3088
+ },
3089
+ "users.revokeMemberSessions": {
3090
+ method: "POST",
3091
+ path: "/members/{user_id}/revoke-sessions",
3092
+ pathParams: ["user_id"],
3093
+ queryParams: [],
3094
+ bodyKind: "none",
3095
+ responseKind: "json",
3096
+ codes: 61
3097
+ },
3098
+ "users.suspendMember": {
3099
+ method: "POST",
3100
+ path: "/members/{user_id}/suspend",
3101
+ pathParams: ["user_id"],
3102
+ queryParams: [],
3103
+ bodyKind: "none",
3104
+ responseKind: "json",
3105
+ codes: 67
3106
+ },
3107
+ "users.unlockMember": {
3108
+ method: "POST",
3109
+ path: "/members/{user_id}/unlock",
3110
+ pathParams: ["user_id"],
3111
+ queryParams: [],
3112
+ bodyKind: "none",
3113
+ responseKind: "json",
3114
+ codes: 61
3115
+ },
3116
+ "users.updateMyDeskAlerts": {
3117
+ method: "PUT",
3118
+ path: "/users/me/desk-alerts",
3119
+ pathParams: [],
3120
+ queryParams: [],
3121
+ bodyKind: "json",
3122
+ responseKind: "json",
3123
+ codes: 2
3124
+ },
3125
+ "users.updateMyNotificationEmail": {
3126
+ method: "PUT",
3127
+ path: "/users/me/notification-email",
3128
+ pathParams: [],
3129
+ queryParams: [],
3130
+ bodyKind: "json",
3131
+ responseKind: "json",
3132
+ codes: 2
3133
+ },
3134
+ "users.updateMyNotificationToast": {
3135
+ method: "PUT",
3136
+ path: "/users/me/notification-toast",
3137
+ pathParams: [],
3138
+ queryParams: [],
3139
+ bodyKind: "json",
3140
+ responseKind: "json",
3141
+ codes: 2
3142
+ },
3143
+ "users.updateRole": {
3144
+ method: "PATCH",
3145
+ path: "/members/{user_id}/role",
3146
+ pathParams: ["user_id"],
3147
+ queryParams: [],
3148
+ bodyKind: "json",
3149
+ responseKind: "json",
3150
+ codes: 82
3151
+ },
3152
+ "visualPlans.clone": {
3153
+ method: "POST",
3154
+ path: "/visual-plans/{plan_id}/clone",
3155
+ pathParams: ["plan_id"],
3156
+ queryParams: [],
3157
+ bodyKind: "json",
3158
+ responseKind: "json",
3159
+ codes: 57
3160
+ },
3161
+ "visualPlans.create": {
3162
+ method: "POST",
3163
+ path: "/visual-plans",
3164
+ pathParams: [],
3165
+ queryParams: [],
3166
+ bodyKind: "json",
3167
+ responseKind: "json",
3168
+ codes: 57
3169
+ },
3170
+ "visualPlans.delete": {
3171
+ method: "DELETE",
3172
+ path: "/visual-plans/{plan_id}",
3173
+ pathParams: ["plan_id"],
3174
+ queryParams: [],
3175
+ bodyKind: "none",
3176
+ responseKind: "json",
3177
+ codes: 70
3178
+ },
3179
+ "visualPlans.getById": {
3180
+ method: "GET",
3181
+ path: "/visual-plans/{plan_id}",
3182
+ pathParams: ["plan_id"],
3183
+ queryParams: [],
3184
+ bodyKind: "none",
3185
+ responseKind: "json",
3186
+ codes: 57
3187
+ },
3188
+ "visualPlans.importDraft": {
3189
+ method: "POST",
3190
+ path: "/visual-plans/{plan_id}/import",
3191
+ pathParams: ["plan_id"],
3192
+ queryParams: [],
3193
+ bodyKind: "json",
3194
+ responseKind: "json",
3195
+ codes: 57
3196
+ },
3197
+ "visualPlans.list": {
3198
+ method: "GET",
3199
+ path: "/visual-plans",
3200
+ pathParams: [],
3201
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order", "status"],
3202
+ bodyKind: "none",
3203
+ responseKind: "json",
3204
+ codes: 5
3205
+ },
3206
+ "visualPlans.listVersions": {
3207
+ method: "GET",
3208
+ path: "/visual-plans/{plan_id}/versions",
3209
+ pathParams: ["plan_id"],
3210
+ queryParams: [],
3211
+ bodyKind: "none",
3212
+ responseKind: "json",
3213
+ codes: 57
3214
+ },
3215
+ "visualPlans.publish": {
3216
+ method: "POST",
3217
+ path: "/visual-plans/{plan_id}/publish",
3218
+ pathParams: ["plan_id"],
3219
+ queryParams: [],
3220
+ bodyKind: "json",
3221
+ responseKind: "json",
3222
+ codes: 78
3223
+ },
3224
+ "visualPlans.update": {
3225
+ method: "PATCH",
3226
+ path: "/visual-plans/{plan_id}",
3227
+ pathParams: ["plan_id"],
3228
+ queryParams: [],
3229
+ bodyKind: "json",
3230
+ responseKind: "json",
3231
+ codes: 57
3232
+ },
3233
+ "visualPlans.validate": {
3234
+ method: "POST",
3235
+ path: "/visual-plans/validate",
3236
+ pathParams: [],
3237
+ queryParams: [],
3238
+ bodyKind: "json",
3239
+ responseKind: "json",
3240
+ codes: 57
3241
+ },
3242
+ "webhooks.deliveries.aggregates.get": {
3243
+ method: "GET",
3244
+ path: "/webhooks/deliveries/aggregates/{day}",
3245
+ pathParams: ["day"],
3246
+ queryParams: ["webhook_endpoint_id"],
3247
+ bodyKind: "none",
3248
+ responseKind: "json",
3249
+ codes: 15
3250
+ },
3251
+ "webhooks.deliveries.aggregates.list": {
3252
+ method: "GET",
3253
+ path: "/webhooks/deliveries/aggregates",
3254
+ pathParams: [],
3255
+ queryParams: [
3256
+ "limit",
3257
+ "cursor",
3258
+ "sort_order",
3259
+ "webhook_endpoint_id",
3260
+ "event_type",
3261
+ "outcome",
3262
+ "http_class",
3263
+ "date_from",
3264
+ "date_to"
3265
+ ],
3266
+ bodyKind: "none",
3267
+ responseKind: "json",
3268
+ codes: 16
3269
+ },
3270
+ "webhooks.deliveries.count": {
3271
+ method: "GET",
3272
+ path: "/webhooks/deliveries/count",
3273
+ pathParams: [],
3274
+ queryParams: ["webhook_endpoint_id", "event_type", "status", "date_from", "date_to"],
3275
+ bodyKind: "none",
3276
+ responseKind: "json",
3277
+ codes: 5
3278
+ },
3279
+ "webhooks.deliveries.getById": {
3280
+ method: "GET",
3281
+ path: "/webhooks/deliveries/{delivery_log_id}",
3282
+ pathParams: ["delivery_log_id"],
3283
+ queryParams: [],
3284
+ bodyKind: "none",
3285
+ responseKind: "json",
3286
+ codes: 5
3287
+ },
3288
+ "webhooks.deliveries.list": {
3289
+ method: "GET",
3290
+ path: "/webhooks/deliveries",
3291
+ pathParams: [],
3292
+ queryParams: [
3293
+ "limit",
3294
+ "cursor",
3295
+ "sort_order",
3296
+ "webhook_endpoint_id",
3297
+ "event_type",
3298
+ "status",
3299
+ "date_from",
3300
+ "date_to"
3301
+ ],
3302
+ bodyKind: "none",
3303
+ responseKind: "json",
3304
+ codes: 16
3305
+ },
3306
+ "webhooks.deliveries.retention": {
3307
+ method: "GET",
3308
+ path: "/webhooks/deliveries/retention",
3309
+ pathParams: [],
3310
+ queryParams: [],
3311
+ bodyKind: "none",
3312
+ responseKind: "json",
3313
+ codes: 5
3314
+ },
3315
+ "webhooks.deliveries.retry": {
3316
+ method: "POST",
3317
+ path: "/webhooks/deliveries/{delivery_log_id}/retry",
3318
+ pathParams: ["delivery_log_id"],
3319
+ queryParams: [],
3320
+ bodyKind: "none",
3321
+ responseKind: "json",
3322
+ codes: 40
3323
+ },
3324
+ "webhooks.endpoints.create": {
3325
+ method: "POST",
3326
+ path: "/webhooks",
3327
+ pathParams: [],
3328
+ queryParams: [],
3329
+ bodyKind: "json",
3330
+ responseKind: "json",
3331
+ codes: 37
3332
+ },
3333
+ "webhooks.endpoints.delete": {
3334
+ method: "DELETE",
3335
+ path: "/webhooks/{webhook_endpoint_id}",
3336
+ pathParams: ["webhook_endpoint_id"],
3337
+ queryParams: [],
3338
+ bodyKind: "none",
3339
+ responseKind: "json",
3340
+ codes: 37
3341
+ },
3342
+ "webhooks.endpoints.getById": {
3343
+ method: "GET",
3344
+ path: "/webhooks/{webhook_endpoint_id}",
3345
+ pathParams: ["webhook_endpoint_id"],
3346
+ queryParams: [],
3347
+ bodyKind: "none",
3348
+ responseKind: "json",
3349
+ codes: 37
3350
+ },
3351
+ "webhooks.endpoints.list": {
3352
+ method: "GET",
3353
+ path: "/webhooks",
3354
+ pathParams: [],
3355
+ queryParams: ["search", "page", "limit", "sort_by", "sort_order"],
3356
+ bodyKind: "none",
3357
+ responseKind: "json",
3358
+ codes: 5
3359
+ },
3360
+ "webhooks.endpoints.rotateSecret": {
3361
+ method: "POST",
3362
+ path: "/webhooks/{webhook_endpoint_id}/rotate-secret",
3363
+ pathParams: ["webhook_endpoint_id"],
3364
+ queryParams: [],
3365
+ bodyKind: "none",
3366
+ responseKind: "json",
3367
+ codes: 37
3368
+ },
3369
+ "webhooks.endpoints.test": {
3370
+ method: "POST",
3371
+ path: "/webhooks/{webhook_endpoint_id}/test",
3372
+ pathParams: ["webhook_endpoint_id"],
3373
+ queryParams: [],
3374
+ bodyKind: "none",
3375
+ responseKind: "json",
3376
+ codes: 37
3377
+ },
3378
+ "webhooks.endpoints.update": {
3379
+ method: "PATCH",
3380
+ path: "/webhooks/{webhook_endpoint_id}",
3381
+ pathParams: ["webhook_endpoint_id"],
3382
+ queryParams: [],
3383
+ bodyKind: "json",
3384
+ responseKind: "json",
3385
+ codes: 37
3386
+ },
3387
+ "webhooks.events.list": {
3388
+ method: "GET",
3389
+ path: "/webhooks/events",
3390
+ pathParams: [],
3391
+ queryParams: [],
3392
+ bodyKind: "none",
3393
+ responseKind: "json",
3394
+ codes: 5
3395
+ }
3396
+ };
3397
+
3398
+ // src/transport.ts
3399
+ function splitOperationInput(op, input) {
3400
+ const record = isPlainObject(input) ? input : {};
3401
+ const path = {};
3402
+ const query = {};
3403
+ const body = {};
3404
+ const pathSet = new Set(op.pathParams);
3405
+ const querySet = new Set(op.queryParams);
3406
+ for (const [key, value] of Object.entries(record)) {
3407
+ if (pathSet.has(key)) {
3408
+ path[key] = encodeURIComponent(String(value));
3409
+ } else if (querySet.has(key)) {
3410
+ query[key] = value;
3411
+ } else if (op.bodyKind !== "none") {
3412
+ body[key] = value;
3413
+ }
3414
+ }
3415
+ return { path, query, body };
3416
+ }
3417
+ function isRecord2(value) {
3418
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3419
+ }
3420
+ function isPlainObject(value) {
3421
+ if (!isRecord2(value))
3422
+ return false;
3423
+ const proto = Object.getPrototypeOf(value);
3424
+ return proto === Object.prototype || proto === null;
3425
+ }
3426
+ var SAFE_ERROR_NAMES = new Set([
3427
+ "TypeError",
3428
+ "AbortError",
3429
+ "TimeoutError",
3430
+ "DOMException",
3431
+ "Error",
3432
+ "SyntaxError"
3433
+ ]);
3434
+ var SAFE_ERROR_CODES = new Set([
3435
+ "ECONNREFUSED",
3436
+ "ECONNRESET",
3437
+ "ENOTFOUND",
3438
+ "EAI_AGAIN",
3439
+ "ETIMEDOUT",
3440
+ "EHOSTUNREACH",
3441
+ "ENETUNREACH",
3442
+ "EPIPE",
3443
+ "CERT_HAS_EXPIRED",
3444
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
3445
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
3446
+ "UND_ERR_CONNECT_TIMEOUT",
3447
+ "UND_ERR_HEADERS_TIMEOUT",
3448
+ "UND_ERR_BODY_TIMEOUT",
3449
+ "UND_ERR_SOCKET",
3450
+ "UND_ERR_ABORT",
3451
+ "UND_ERR_INFO",
3452
+ "UND_ERR_CLOSED",
3453
+ "UND_ERR_DESTROYED",
3454
+ "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH",
3455
+ "UND_ERR_RES_CONTENT_LENGTH_MISMATCH",
3456
+ "UND_ERR_CONTINUE_100",
3457
+ "UND_ERR_HEADERS_OVERFLOW",
3458
+ "UND_ERR_BODY_TOO_LARGE",
3459
+ "UND_ERR_RESPONSE_STATUS_CODE",
3460
+ "UND_ERR_INVALID_ARG",
3461
+ "UND_ERR_NOT_SUPPORTED"
3462
+ ]);
3463
+ function sanitizeCause(error) {
3464
+ if (!(error instanceof Error))
3465
+ return;
3466
+ const cause = {
3467
+ name: SAFE_ERROR_NAMES.has(error.name) ? error.name : "Error"
3468
+ };
3469
+ if (isRecord2(error)) {
3470
+ const code = error["code"];
3471
+ if (typeof code === "string" && SAFE_ERROR_CODES.has(code))
3472
+ cause.code = code;
3473
+ }
3474
+ return cause;
3475
+ }
3476
+ function jsonScalar(value) {
3477
+ if (value instanceof Date)
3478
+ return Number.isNaN(value.getTime()) ? null : value.toISOString();
3479
+ if (typeof value === "bigint" || value instanceof RegExp || value instanceof URL)
3480
+ return value.toString();
3481
+ if (typeof value === "number" && Number.isNaN(value))
3482
+ return null;
3483
+ return value;
3484
+ }
3485
+ function escapeSegment(segment) {
3486
+ const bs = String.fromCharCode(92);
3487
+ return segment.split(bs).join(bs + bs).split("[").join(bs + "[").split("]").join(bs + "]");
3488
+ }
3489
+ function bracketPath(segments) {
3490
+ return segments.map((segment) => typeof segment === "number" ? String(segment) : escapeSegment(segment)).reduce((head, segment, index) => index === 0 ? head + segment : `${head}[${segment}]`, "");
3491
+ }
3492
+ function flattenBracket(value, segments, out) {
3493
+ if (Array.isArray(value)) {
3494
+ value.forEach((item, index) => flattenBracket(item, [...segments, index], out));
3495
+ } else if (isPlainObject(value)) {
3496
+ for (const [key, entry] of Object.entries(value))
3497
+ flattenBracket(entry, [...segments, key], out);
3498
+ } else {
3499
+ out.push([bracketPath(segments), value]);
3500
+ }
3501
+ }
3502
+ function appendQueryValue(params, path, value) {
3503
+ const scalar = jsonScalar(value);
3504
+ if (typeof scalar === "string" || typeof scalar === "number" || typeof scalar === "boolean") {
3505
+ params.append(path, String(scalar));
3506
+ }
3507
+ }
3508
+ function encodeQueryParams(query) {
3509
+ const params = new URLSearchParams;
3510
+ const flat = [];
3511
+ flattenBracket(query, [], flat);
3512
+ for (const [path, value] of flat)
3513
+ appendQueryValue(params, path, value);
3514
+ return params.toString();
3515
+ }
3516
+ function encodeMultipartForm(body) {
3517
+ const form = new FormData;
3518
+ const flat = [];
3519
+ flattenBracket(body, [], flat);
3520
+ for (const [path, value] of flat) {
3521
+ const scalar = jsonScalar(value);
3522
+ if (typeof scalar === "string" || typeof scalar === "number" || typeof scalar === "boolean") {
3523
+ form.append(path, String(scalar));
3524
+ } else if (scalar instanceof Blob) {
3525
+ form.append(path, scalar);
3526
+ }
3527
+ }
3528
+ return form;
3529
+ }
3530
+ function encodeBody(bodyKind, body) {
3531
+ if (bodyKind === "multipart")
3532
+ return { contentType: undefined, body: encodeMultipartForm(body) };
3533
+ return { contentType: "application/json", body: JSON.stringify(body) };
3534
+ }
3535
+ function mergeRequestHeaders(base, extra) {
3536
+ const merged = new Headers(base);
3537
+ if (extra !== undefined)
3538
+ new Headers(extra).forEach((value, key) => merged.set(key, value));
3539
+ return merged;
3540
+ }
3541
+ function abortError(signal, timeoutMs) {
3542
+ if (signal?.aborted === true) {
3543
+ return new NivaConnectionError2("request aborted by the caller", { reason: "aborted" });
3544
+ }
3545
+ return new NivaConnectionError2(`request timed out after ${timeoutMs}ms`, { reason: "timeout" });
3546
+ }
3547
+ async function fetchWithTimeout(fetchImpl, url, init, timeoutMs) {
3548
+ const callerSignal = init.signal instanceof AbortSignal ? init.signal : undefined;
3549
+ if (callerSignal?.aborted === true)
3550
+ throw abortError(callerSignal, timeoutMs);
3551
+ const controller = new AbortController;
3552
+ const onCallerAbort = () => controller.abort();
3553
+ callerSignal?.addEventListener("abort", onCallerAbort, { once: true });
3554
+ const timer = setTimeout(() => {
3555
+ callerSignal?.removeEventListener("abort", onCallerAbort);
3556
+ controller.abort();
3557
+ }, timeoutMs);
3558
+ try {
3559
+ return await fetchImpl(url, { ...init, signal: controller.signal });
3560
+ } catch (error) {
3561
+ if (error instanceof Error && error.name === "AbortError")
3562
+ throw abortError(callerSignal, timeoutMs);
3563
+ throw new NivaConnectionError2("request failed", { reason: "network", cause: sanitizeCause(error) });
3564
+ } finally {
3565
+ clearTimeout(timer);
3566
+ }
3567
+ }
3568
+ function isDefinedErrorBody(body) {
3569
+ if (!isPlainObject(body))
3570
+ return false;
3571
+ return body["defined"] === true && typeof body["code"] === "string" && typeof body["status"] === "number" && typeof body["message"] === "string";
3572
+ }
3573
+ async function parseApiError(response, operation) {
3574
+ const requestId = response.headers.get("x-request-id") ?? undefined;
3575
+ let body;
3576
+ try {
3577
+ body = await response.json();
3578
+ } catch {
3579
+ body = undefined;
3580
+ }
3581
+ if (isDefinedErrorBody(body)) {
3582
+ return new NivaApiError2({
3583
+ status: body.status,
3584
+ code: body.code,
3585
+ message: body.message,
3586
+ data: body.data,
3587
+ requestId,
3588
+ operation
3589
+ });
3590
+ }
3591
+ return new NivaApiError2({
3592
+ status: response.status,
3593
+ code: "UNEXPECTED_RESPONSE",
3594
+ message: `request failed with status ${response.status}`,
3595
+ requestId,
3596
+ operation
3597
+ });
3598
+ }
3599
+ async function readJsonResponse(response, operation = "unknown") {
3600
+ if (response.status === 204)
3601
+ return;
3602
+ try {
3603
+ return await response.json();
3604
+ } catch {
3605
+ throw new NivaApiError2({
3606
+ status: response.status,
3607
+ code: "UNEXPECTED_RESPONSE",
3608
+ message: `request succeeded with a malformed JSON body (status ${response.status})`,
3609
+ operation
3610
+ });
3611
+ }
3612
+ }
3613
+
3614
+ // src/handshake.ts
3615
+ var PUBLISHED_PACKAGE = "@sippulse/niva-sdk";
3616
+ function isRecord3(value) {
3617
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3618
+ }
3619
+ function parseVersion(value) {
3620
+ if (typeof value !== "string")
3621
+ return;
3622
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?$/.exec(value);
3623
+ if (match === null)
3624
+ return;
3625
+ const [, major, minor, patch, pre] = match;
3626
+ return { major: Number(major), minor: Number(minor), patch: Number(patch), pre };
3627
+ }
3628
+ function isBelowFloor(version, floor) {
3629
+ if (version.major !== floor.major)
3630
+ return version.major < floor.major;
3631
+ if (version.minor !== floor.minor)
3632
+ return version.minor < floor.minor;
3633
+ if (version.patch !== floor.patch)
3634
+ return version.patch < floor.patch;
3635
+ if (version.pre === floor.pre)
3636
+ return false;
3637
+ if (version.pre === undefined)
3638
+ return false;
3639
+ return true;
3640
+ }
3641
+ function rowForServer(serverVersion) {
3642
+ for (const row of COMPAT_TABLE) {
3643
+ const min = parseVersion(row.nivaMin);
3644
+ if (min === undefined)
3645
+ continue;
3646
+ if (isBelowFloor(serverVersion, min))
3647
+ continue;
3648
+ if (row.nivaMax !== null) {
3649
+ const max = parseVersion(row.nivaMax);
3650
+ if (max === undefined || isBelowFloor(max, serverVersion))
3651
+ continue;
3652
+ }
3653
+ return { distTag: row.distTag };
3654
+ }
3655
+ return;
3656
+ }
3657
+ function incompatibleError(baseUrl, serverVersion, serverProtocol) {
3658
+ const range = SUPPORTED_NIVA.max === null ? `>= ${SUPPORTED_NIVA.min}` : `>= ${SUPPORTED_NIVA.min} <${SUPPORTED_NIVA.max}`;
3659
+ const lines = [
3660
+ `${PUBLISHED_PACKAGE}@${SDK_VERSION} requires NIVA ${range} (protocol ${PROTOCOL_VERSION}).`,
3661
+ `The server ${baseUrl} reports NIVA ${serverVersion} (protocol ${String(serverProtocol)}).`
3662
+ ];
3663
+ let installCommand;
3664
+ const parsed = parseVersion(serverVersion);
3665
+ const row = parsed === undefined ? undefined : rowForServer(parsed);
3666
+ if (row !== undefined) {
3667
+ installCommand = `npm i ${PUBLISHED_PACKAGE}@${row.distTag}`;
3668
+ lines.push(`Install the matching version: ${installCommand}`);
3669
+ }
3670
+ return new NivaIncompatibleServerError2(lines.join(`
3671
+ `), {
3672
+ serverVersion,
3673
+ supported: range,
3674
+ installCommand
3675
+ });
3676
+ }
3677
+ async function resolveHandshakeHeaders(input) {
3678
+ const base = typeof input.headers === "function" ? await input.headers() : input.headers;
3679
+ const headers = new Headers(base);
3680
+ if (!headers.has("accept"))
3681
+ headers.set("accept", "application/json");
3682
+ return headers;
3683
+ }
3684
+ async function readJson(response) {
3685
+ try {
3686
+ const parsed = await response.json();
3687
+ return parsed;
3688
+ } catch {
3689
+ return;
3690
+ }
3691
+ }
3692
+ async function fetchVersion(input) {
3693
+ const timeout = input.timeout ?? 30000;
3694
+ let response;
3695
+ try {
3696
+ response = await fetchWithTimeout(input.fetchImpl, `${input.baseUrl}/api/version`, { headers: { accept: "application/json" } }, timeout);
3697
+ } catch (error) {
3698
+ if (error instanceof NivaConnectionError2)
3699
+ throw error;
3700
+ throw new NivaConnectionError2("version check failed", {
3701
+ reason: "network",
3702
+ cause: error instanceof Error ? error : undefined
3703
+ });
3704
+ }
3705
+ const body = await readJson(response);
3706
+ if (!isRecord3(body)) {
3707
+ throw new NivaConnectionError2("unexpected version response: not JSON", { reason: "network" });
3708
+ }
3709
+ const record = body;
3710
+ const nivaVersion = record["niva_version"];
3711
+ if (typeof nivaVersion !== "string" || parseVersion(nivaVersion) === undefined) {
3712
+ throw new NivaConnectionError2("unexpected version response: bad niva_version", { reason: "network" });
3713
+ }
3714
+ return { nivaVersion, protocol: record["protocol_version"] };
3715
+ }
3716
+ var EMPTY_SNAPSHOT = { operations: undefined, modules: {}, requiredModules: {} };
3717
+ async function fetchCapabilities(input) {
3718
+ const timeout = input.timeout ?? 30000;
3719
+ const response = await fetchWithTimeout(input.fetchImpl, `${input.baseUrl}/api/v1/capabilities`, { headers: await resolveHandshakeHeaders(input) }, timeout);
3720
+ if (response.status === 404 || response.status === 403)
3721
+ return { ...EMPTY_SNAPSHOT };
3722
+ if (response.status < 200 || response.status >= 300)
3723
+ throw await parseApiError(response, "capabilities.get");
3724
+ const raw = await readJson(response);
3725
+ if (!isRecord3(raw))
3726
+ return { ...EMPTY_SNAPSHOT };
3727
+ return parseSnapshot(raw);
3728
+ }
3729
+ function parseSnapshot(body) {
3730
+ const modules = {};
3731
+ const modulesValue = body["modules"];
3732
+ if (isRecord3(modulesValue)) {
3733
+ for (const [key, value] of Object.entries(modulesValue)) {
3734
+ if (typeof value === "boolean")
3735
+ modules[key] = value;
3736
+ }
3737
+ }
3738
+ const requiredModules = {};
3739
+ const requiredValue = body["required_modules"];
3740
+ if (isRecord3(requiredValue)) {
3741
+ for (const [key, value] of Object.entries(requiredValue)) {
3742
+ if (Array.isArray(value)) {
3743
+ requiredModules[key] = value.filter((entry) => typeof entry === "string");
3744
+ }
3745
+ }
3746
+ }
3747
+ const operations = body["operations"];
3748
+ return {
3749
+ operations: Array.isArray(operations) ? operations.filter((op) => typeof op === "string") : [],
3750
+ modules,
3751
+ requiredModules
3752
+ };
3753
+ }
3754
+ function createHandshake(input) {
3755
+ let memo;
3756
+ return {
3757
+ async ensure() {
3758
+ memo ??= run().catch((error) => {
3759
+ if (error instanceof NivaConnectionError2)
3760
+ memo = undefined;
3761
+ throw error;
3762
+ });
3763
+ return memo;
3764
+ }
3765
+ };
3766
+ async function run() {
3767
+ const { nivaVersion, protocol } = await fetchVersion(input);
3768
+ const floor = parseVersion(SUPPORTED_NIVA.min);
3769
+ const parsed = parseVersion(nivaVersion);
3770
+ if (floor === undefined || parsed === undefined || isBelowFloor(parsed, floor) || protocol !== PROTOCOL_VERSION) {
3771
+ throw incompatibleError(input.baseUrl, nivaVersion, protocol);
3772
+ }
3773
+ return fetchCapabilities(input);
3774
+ }
3775
+ }
3776
+ function assertOperationAvailable(snapshot, opId) {
3777
+ if (snapshot.operations === undefined)
3778
+ return;
3779
+ if (!snapshot.operations.includes(opId))
3780
+ throw new NivaUnavailableError2(opId, { reason: "operation" });
3781
+ const required = snapshot.requiredModules[opId];
3782
+ if (required === undefined)
3783
+ return;
3784
+ const disabled = required.find((module) => snapshot.modules[module] !== true);
3785
+ if (disabled !== undefined)
3786
+ throw new NivaUnavailableError2(opId, { reason: "module", module: disabled });
3787
+ }
3788
+
3789
+ // src/safe.ts
3790
+ var DECLARED_CODES = new WeakMap;
3791
+ var ERROR_CODE_INDEX = new Map(ERROR_CODES2.map((code, index) => [code, index]));
3792
+ var COMMON_CODES = new Set(COMMON_ERROR_CODES2);
3793
+ function attachDeclaredCodes(error, setIndex) {
3794
+ DECLARED_CODES.set(error, setIndex);
3795
+ }
3796
+ function isDeclared(error) {
3797
+ if (!(error instanceof NivaApiError2))
3798
+ return false;
3799
+ const apiError = error;
3800
+ const setIndex = DECLARED_CODES.get(apiError);
3801
+ if (setIndex === undefined)
3802
+ return false;
3803
+ const index = ERROR_CODE_INDEX.get(apiError.code);
3804
+ if (index === undefined)
3805
+ return false;
3806
+ const set = ERROR_CODE_SETS2[setIndex];
3807
+ return COMMON_CODES.has(index) || (set?.includes(index) ?? false);
3808
+ }
3809
+ function classify(thrown) {
3810
+ try {
3811
+ if (thrown instanceof NivaError2) {
3812
+ return { error: thrown, defined: isDeclared(thrown) };
3813
+ }
3814
+ } catch {}
3815
+ return { error: new NivaConfigurationError2("client call failed"), defined: false };
3816
+ }
3817
+ function makeResult(error, data, isDefined, isSuccess) {
3818
+ const tuple = [error, data, isDefined, isSuccess];
3819
+ return Object.assign(tuple, { error, data, isDefined, isSuccess });
3820
+ }
3821
+ async function safe2(call) {
3822
+ try {
3823
+ return makeResult(null, await call, false, true);
3824
+ } catch (error) {
3825
+ const { error: caught, defined } = classify(error);
3826
+ if (defined) {
3827
+ const declaredError = caught;
3828
+ return makeResult(declaredError, undefined, true, false);
3829
+ }
3830
+ return makeResult(caught, undefined, false, false);
3831
+ }
3832
+ }
3833
+
3834
+ // src/client.ts
3835
+ var DEFAULT_TIMEOUT_MS = 30000;
3836
+ function normalizeBaseUrl(baseUrl) {
3837
+ let url;
3838
+ try {
3839
+ url = new URL(baseUrl);
3840
+ } catch {
3841
+ throw new NivaConfigurationError2(`baseUrl is not a URL: ${baseUrl}`);
3842
+ }
3843
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
3844
+ throw new NivaConfigurationError2(`baseUrl must be http(s): ${baseUrl}`);
3845
+ }
3846
+ return url.toString().replace(/\/$/, "");
3847
+ }
3848
+ async function resolveHeaders(headers) {
3849
+ if (headers === undefined)
3850
+ return;
3851
+ try {
3852
+ return typeof headers === "function" ? await headers() : headers;
3853
+ } catch {
3854
+ throw new NivaConfigurationError2("headers provider failed");
3855
+ }
3856
+ }
3857
+ function lookupOperation(opId) {
3858
+ for (const [id, entry] of Object.entries(OPERATIONS2)) {
3859
+ if (id === opId)
3860
+ return entry;
3861
+ }
3862
+ throw new NivaUnavailableError2(opId, { reason: "operation" });
3863
+ }
3864
+ async function resolveApiKey(apiKey) {
3865
+ let key;
3866
+ try {
3867
+ key = typeof apiKey === "function" ? await apiKey() : apiKey;
3868
+ } catch {
3869
+ throw new NivaConfigurationError2("apiKey provider failed");
3870
+ }
3871
+ if (typeof key !== "string" || key.length === 0) {
3872
+ throw new NivaConfigurationError2("apiKey provider resolved an empty key");
3873
+ }
3874
+ return key;
3875
+ }
3876
+ function buildUrl(baseUrl, entry, input) {
3877
+ const split = splitOperationInput(entry, input);
3878
+ let url = `${baseUrl}/api/v1${entry.path}`;
3879
+ for (const [name, encoded] of Object.entries(split.path)) {
3880
+ url = url.replace(`{${name}}`, encoded);
3881
+ }
3882
+ const query = encodeQueryParams(split.query);
3883
+ if (query.length > 0)
3884
+ url += `?${query}`;
3885
+ return url;
3886
+ }
3887
+ async function buildHeaders(deps, apiKey, callOptions, entry) {
3888
+ const headers = mergeRequestHeaders(await resolveHeaders(deps.clientHeaders), callOptions.headers);
3889
+ headers.set("x-api-key", apiKey);
3890
+ headers.set("x-niva-sdk-version", SDK_VERSION);
3891
+ if (!headers.has("accept"))
3892
+ headers.set("accept", "application/json");
3893
+ if (callOptions.range !== undefined && entry.responseKind === "binary")
3894
+ headers.set("range", callOptions.range);
3895
+ return headers;
3896
+ }
3897
+ function buildBody(entry, input) {
3898
+ const split = splitOperationInput(entry, input);
3899
+ if (entry.bodyKind === "none" || Object.keys(split.body).length === 0) {
3900
+ return { contentType: undefined, body: undefined };
3901
+ }
3902
+ const encoded = encodeBody(entry.bodyKind, split.body);
3903
+ return { contentType: encoded.contentType, body: encoded.body ?? undefined };
3904
+ }
3905
+ async function performRequest(deps, opId, entry, input, callOptions, apiKey) {
3906
+ const url = buildUrl(deps.baseUrl, entry, input);
3907
+ const headers = await buildHeaders(deps, apiKey, callOptions, entry);
3908
+ const { contentType, body } = buildBody(entry, input);
3909
+ if (contentType !== undefined)
3910
+ headers.set("content-type", contentType);
3911
+ const init = { method: entry.method, headers };
3912
+ if (body !== undefined)
3913
+ init.body = body;
3914
+ if (callOptions.signal !== undefined)
3915
+ init.signal = callOptions.signal;
3916
+ const timeout = callOptions.timeout ?? deps.defaultTimeout;
3917
+ const response = await fetchWithTimeout(deps.fetchImpl, url, init, timeout);
3918
+ if (response.status < 200 || response.status >= 300)
3919
+ throw await parseApiError(response, opId);
3920
+ if (entry.responseKind === "binary" || entry.responseKind === "sse")
3921
+ return response;
3922
+ if (entry.responseKind === "empty")
3923
+ return;
3924
+ return readJsonResponse(response, opId);
3925
+ }
3926
+ function withAbsoluteWsUrl(opId, output, baseUrl) {
3927
+ if (opId !== "chat.createSession" || typeof output !== "object" || output === null)
3928
+ return output;
3929
+ const wsUrl = Reflect.get(output, "ws_url");
3930
+ if (typeof wsUrl !== "string" || !wsUrl.startsWith("/"))
3931
+ return output;
3932
+ return { ...output, ws_url: `${baseUrl.replace(/^http/, "ws")}${wsUrl}` };
3933
+ }
3934
+ function asNivaError(error) {
3935
+ try {
3936
+ if (error instanceof NivaError2)
3937
+ return error;
3938
+ } catch {}
3939
+ return new NivaConfigurationError2("client call failed before a NIVA error could be produced");
3940
+ }
3941
+ function createNivaClient2(options) {
3942
+ const baseUrl = normalizeBaseUrl(options.baseUrl);
3943
+ if (typeof options.apiKey === "string" && options.apiKey.length === 0) {
3944
+ throw new NivaConfigurationError2("apiKey must not be empty");
3945
+ }
3946
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3947
+ if (typeof fetchImpl !== "function")
3948
+ throw new NivaConfigurationError2("no fetch implementation available");
3949
+ const defaultTimeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
3950
+ const deps = {
3951
+ fetchImpl,
3952
+ baseUrl,
3953
+ defaultTimeout,
3954
+ handshake: createHandshake({
3955
+ fetchImpl,
3956
+ baseUrl,
3957
+ headers: async () => {
3958
+ const apiKey = await resolveApiKey(options.apiKey);
3959
+ const headers = mergeRequestHeaders(await resolveHeaders(options.headers));
3960
+ if (apiKey.length > 0)
3961
+ headers.set("x-api-key", apiKey);
3962
+ headers.set("x-niva-sdk-version", SDK_VERSION);
3963
+ return headers;
3964
+ },
3965
+ timeout: defaultTimeout
3966
+ }),
3967
+ apiKey: options.apiKey,
3968
+ clientHeaders: options.headers
3969
+ };
3970
+ function call(opId, input, callOptions) {
3971
+ const pending = (async () => {
3972
+ const entry = lookupOperation(opId);
3973
+ try {
3974
+ const snapshot = await deps.handshake.ensure();
3975
+ assertOperationAvailable(snapshot, opId);
3976
+ const apiKey = await resolveApiKey(deps.apiKey);
3977
+ const output = await performRequest(deps, opId, entry, input, callOptions ?? {}, apiKey);
3978
+ return withAbsoluteWsUrl(opId, output, deps.baseUrl);
3979
+ } catch (error) {
3980
+ if (error instanceof NivaApiError2) {
3981
+ const apiError = error;
3982
+ attachDeclaredCodes(apiError, entry.codes);
3983
+ }
3984
+ throw asNivaError(error);
3985
+ }
3986
+ })();
3987
+ return pending;
3988
+ }
3989
+ return buildNivaClient(call);
3990
+ }
3991
+ // src/generated/webhooks.ts
3992
+ var NIVA_WEBHOOK_EVENT_TYPES2 = [
3993
+ "alert.fired",
3994
+ "alert.resolved",
3995
+ "attendant.status_changed",
3996
+ "call.amd_completed",
3997
+ "call.analysis_completed",
3998
+ "call.answered",
3999
+ "call.hangup",
4000
+ "call.intent_matched",
4001
+ "call.node_entered",
4002
+ "call.node_error",
4003
+ "call.node_warning",
4004
+ "call.recording_available",
4005
+ "call.rejected",
4006
+ "call.signal_triggered",
4007
+ "call.started",
4008
+ "call.transcribed",
4009
+ "call.transcription_failed",
4010
+ "call.transferred",
4011
+ "conversation.abandoned",
4012
+ "conversation.answered",
4013
+ "conversation.offered",
4014
+ "conversation.queued",
4015
+ "conversation.wrapped",
4016
+ "dialer.attempt.finished",
4017
+ "message.sent",
4018
+ "plan.published",
4019
+ "service.down",
4020
+ "service.up",
4021
+ "webhook.test"
4022
+ ];
4023
+ // src/webhook/verify.ts
4024
+ var SIGNATURE_RE = /^sha256=([0-9a-f]{64})$/;
4025
+ var TIMESTAMP_RE = /^(0|[1-9]\d{0,15})$/;
4026
+ var ISO_DATETIME_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;
4027
+ var DEFAULT_TOLERANCE_SECONDS2 = 300;
4028
+ function readHeader(headers, name) {
4029
+ if (headers instanceof Headers) {
4030
+ const value = headers.get(name);
4031
+ return value !== null && value.length > 0 ? value : undefined;
4032
+ }
4033
+ const matches = Object.entries(headers).filter(([key]) => key.toLowerCase() === name);
4034
+ if (matches.length > 1)
4035
+ throw verification("duplicate_header", `duplicate ${name}`);
4036
+ const value = matches[0]?.[1];
4037
+ return typeof value === "string" && value.length > 0 ? value : undefined;
4038
+ }
4039
+ var verification = (code, message) => new NivaWebhookError2("verification", code, message);
4040
+ var payload = (code, message) => new NivaWebhookError2("payload", code, message);
4041
+ function isJsonObject(value) {
4042
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4043
+ }
4044
+ function hasControlChars(value) {
4045
+ for (let i = 0;i < value.length; i++) {
4046
+ const code = value.charCodeAt(i);
4047
+ if (code <= 31 || code === 127)
4048
+ return true;
4049
+ }
4050
+ return false;
4051
+ }
4052
+ function readDeliveryHeaders(headers) {
4053
+ const id = readHeader(headers, "x-webhook-id");
4054
+ const timestampText = readHeader(headers, "x-webhook-timestamp");
4055
+ const signature = readHeader(headers, "x-webhook-signature");
4056
+ if (id === undefined)
4057
+ throw verification("missing_header", "missing x-webhook-id");
4058
+ if (timestampText === undefined)
4059
+ throw verification("missing_header", "missing x-webhook-timestamp");
4060
+ if (signature === undefined)
4061
+ throw verification("missing_header", "missing x-webhook-signature");
4062
+ return { id, timestampText, signature };
4063
+ }
4064
+ function checkTimestamp(timestampText, toleranceSeconds, nowSeconds) {
4065
+ if (!TIMESTAMP_RE.test(timestampText))
4066
+ throw verification("bad_timestamp", "malformed x-webhook-timestamp");
4067
+ const timestamp = Number(timestampText);
4068
+ if (!Number.isSafeInteger(timestamp) || Math.abs(nowSeconds - timestamp) > toleranceSeconds) {
4069
+ throw verification("timestamp_out_of_tolerance", "webhook timestamp outside the allowed window");
4070
+ }
4071
+ }
4072
+ function freshBytes(length) {
4073
+ return new Uint8Array(new ArrayBuffer(length));
4074
+ }
4075
+ function hexToBytes(hex) {
4076
+ const out = freshBytes(hex.length / 2);
4077
+ for (let i = 0;i < out.length; i++)
4078
+ out[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
4079
+ return out;
4080
+ }
4081
+ function bodyBytes(body) {
4082
+ if (typeof body === "string")
4083
+ return new TextEncoder().encode(body);
4084
+ if (body instanceof Uint8Array)
4085
+ return body;
4086
+ return new Uint8Array(body);
4087
+ }
4088
+ async function verifySignature(secret, id, timestampText, raw, signature) {
4089
+ const signatureMatch = SIGNATURE_RE.exec(signature);
4090
+ if (signatureMatch === null)
4091
+ throw verification("bad_signature", "malformed x-webhook-signature");
4092
+ const encoder = new TextEncoder;
4093
+ const secretBytes = encoder.encode(secret);
4094
+ const keyMaterial = freshBytes(secretBytes.length);
4095
+ keyMaterial.set(secretBytes);
4096
+ const key = await crypto.subtle.importKey("raw", keyMaterial, { name: "HMAC", hash: "SHA-256" }, false, ["verify"]);
4097
+ const prefix = encoder.encode(`${id}.${timestampText}.`);
4098
+ const signed = freshBytes(prefix.length + raw.length);
4099
+ signed.set(prefix, 0);
4100
+ signed.set(raw, prefix.length);
4101
+ let valid = false;
4102
+ try {
4103
+ valid = await crypto.subtle.verify("HMAC", key, hexToBytes(signatureMatch[1]), signed);
4104
+ } catch {
4105
+ valid = false;
4106
+ }
4107
+ if (!valid)
4108
+ throw verification("bad_signature", "webhook signature mismatch");
4109
+ }
4110
+ function parseEnvelope(raw, headerId) {
4111
+ let parsed;
4112
+ try {
4113
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(raw));
4114
+ } catch {
4115
+ throw payload("invalid_json", "webhook body is not valid JSON");
4116
+ }
4117
+ if (!isJsonObject(parsed)) {
4118
+ throw payload("invalid_envelope", "webhook body is not an envelope object");
4119
+ }
4120
+ const body = parsed;
4121
+ if ("org_id" in body)
4122
+ throw payload("invalid_envelope", "webhook envelope carries org_id");
4123
+ if (typeof body["event"] !== "string")
4124
+ throw payload("invalid_envelope", "webhook envelope has no event");
4125
+ const event = NIVA_WEBHOOK_EVENT_TYPES2.find((candidate) => candidate === body["event"]);
4126
+ if (event === undefined)
4127
+ throw payload("unknown_event", "unknown webhook event");
4128
+ if (typeof body["event_id"] !== "string" || body["event_id"].length === 0) {
4129
+ throw payload("invalid_envelope", "webhook envelope has no event_id");
4130
+ }
4131
+ if (typeof body["timestamp"] !== "string" || !isDispatcherTimestamp(body["timestamp"])) {
4132
+ throw payload("invalid_envelope", "webhook envelope timestamp is not an ISO 8601 date-time");
4133
+ }
4134
+ if (typeof body["data"] !== "object" || body["data"] === null || Array.isArray(body["data"])) {
4135
+ throw payload("invalid_envelope", "webhook envelope has no data object");
4136
+ }
4137
+ if (body["event_id"] !== headerId)
4138
+ throw payload("invalid_envelope", "webhook id does not match the envelope");
4139
+ return { event, event_id: body["event_id"], timestamp: body["timestamp"], data: body["data"] };
4140
+ }
4141
+ async function verifyNivaWebhook2(options) {
4142
+ const { secret, toleranceSeconds = DEFAULT_TOLERANCE_SECONDS2 } = options;
4143
+ if (secret.length === 0)
4144
+ throw verification("bad_signature", "a non-empty webhook secret is required");
4145
+ const { id, timestampText, signature } = readDeliveryHeaders(options.headers);
4146
+ if (id.length > 256 || hasControlChars(id))
4147
+ throw verification("bad_signature", "malformed x-webhook-id");
4148
+ checkTimestamp(timestampText, toleranceSeconds, options.now ?? Math.floor(Date.now() / 1000));
4149
+ const raw = bodyBytes(options.body);
4150
+ await verifySignature(secret, id, timestampText, raw, signature);
4151
+ return envelopeToEvent(parseEnvelope(raw, id));
4152
+ }
4153
+ function isDispatcherTimestamp(value) {
4154
+ return ISO_DATETIME_RE.test(value) && Number.isFinite(Date.parse(value));
4155
+ }
4156
+ function envelopeToEvent(envelope) {
4157
+ return envelope;
4158
+ }
4159
+ // src/webhook/handler.ts
4160
+ var DEFAULT_MAX_BODY_BYTES2 = 1024 * 1024;
4161
+ var DRAIN_CAP_BYTES = 1024 * 1024;
4162
+ var DRAIN_TIMEOUT_MS = 1000;
4163
+ function concatChunks(chunks, total) {
4164
+ const out = new Uint8Array(total);
4165
+ let offset = 0;
4166
+ for (const chunk of chunks) {
4167
+ out.set(chunk, offset);
4168
+ offset += chunk.byteLength;
4169
+ }
4170
+ return out;
4171
+ }
4172
+ async function drainOverLimit(reader) {
4173
+ const deadline = Date.now() + DRAIN_TIMEOUT_MS;
4174
+ let discarded = 0;
4175
+ for (;; ) {
4176
+ const remaining = deadline - Date.now();
4177
+ if (remaining <= 0)
4178
+ return;
4179
+ let timer;
4180
+ try {
4181
+ const next = await Promise.race([
4182
+ reader.read(),
4183
+ new Promise((resolve) => {
4184
+ timer = setTimeout(() => resolve(undefined), remaining);
4185
+ })
4186
+ ]);
4187
+ if (next === undefined || next.done)
4188
+ return;
4189
+ discarded += next.value.byteLength;
4190
+ if (discarded > DRAIN_CAP_BYTES)
4191
+ return;
4192
+ } finally {
4193
+ if (timer !== undefined)
4194
+ clearTimeout(timer);
4195
+ }
4196
+ }
4197
+ }
4198
+
4199
+ class BodyTooLargeError extends Error {
4200
+ constructor() {
4201
+ super("webhook body exceeds maxBodyBytes");
4202
+ this.name = "BodyTooLargeError";
4203
+ }
4204
+ }
4205
+ async function readBodyWithLimit(request, maxBodyBytes) {
4206
+ if (request.body === null)
4207
+ return new Uint8Array(0);
4208
+ const reader = request.body.getReader();
4209
+ const chunks = [];
4210
+ let total = 0;
4211
+ try {
4212
+ for (;; ) {
4213
+ const { done, value } = await reader.read();
4214
+ if (done)
4215
+ return concatChunks(chunks, total);
4216
+ total += value.byteLength;
4217
+ if (total <= maxBodyBytes) {
4218
+ chunks.push(value);
4219
+ continue;
4220
+ }
4221
+ chunks.length = 0;
4222
+ await drainOverLimit(reader);
4223
+ try {
4224
+ await reader.cancel();
4225
+ } catch {}
4226
+ throw new BodyTooLargeError;
4227
+ }
4228
+ } finally {
4229
+ reader.releaseLock();
4230
+ }
4231
+ }
4232
+ var empty = (status, headers) => new Response(null, headers === undefined ? { status } : { status, headers });
4233
+ function createNivaWebhookHandler2(options) {
4234
+ const path = options.path ?? "/";
4235
+ const maxBodyBytes = options.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES2;
4236
+ const handlers = new Map;
4237
+ return {
4238
+ on(event, handler) {
4239
+ if (handlers.has(event))
4240
+ throw new Error(`a handler is already registered for event ${JSON.stringify(event)}`);
4241
+ handlers.set(event, async (incoming, context) => {
4242
+ if (incoming.event !== event)
4243
+ throw new Error("webhook dispatcher delivered the wrong event");
4244
+ await handler(incoming, context);
4245
+ });
4246
+ },
4247
+ off(event) {
4248
+ handlers.delete(event);
4249
+ },
4250
+ async fetch(request) {
4251
+ let pathname;
4252
+ try {
4253
+ pathname = new URL(request.url).pathname;
4254
+ } catch {
4255
+ return empty(400);
4256
+ }
4257
+ if (pathname !== path)
4258
+ return empty(404);
4259
+ if (request.method !== "POST")
4260
+ return empty(405);
4261
+ let raw;
4262
+ try {
4263
+ raw = await readBodyWithLimit(request, maxBodyBytes);
4264
+ } catch (error) {
4265
+ if (error instanceof BodyTooLargeError)
4266
+ return empty(413, { Connection: "close" });
4267
+ return empty(500);
4268
+ }
4269
+ let event;
4270
+ try {
4271
+ event = await verifyNivaWebhook2({
4272
+ secret: options.secret,
4273
+ headers: request.headers,
4274
+ body: raw,
4275
+ ...options.toleranceSeconds === undefined ? {} : { toleranceSeconds: options.toleranceSeconds }
4276
+ });
4277
+ } catch (error) {
4278
+ if (error instanceof NivaWebhookError2)
4279
+ return empty(error.kind === "verification" ? 401 : 400);
4280
+ return empty(500);
4281
+ }
4282
+ const handler = handlers.get(event.event);
4283
+ if (handler === undefined)
4284
+ return empty(422);
4285
+ try {
4286
+ await handler(event, { signal: request.signal });
4287
+ } catch {
4288
+ return empty(500);
4289
+ }
4290
+ return empty(204);
4291
+ }
4292
+ };
4293
+ }
4294
+ // src/webhook/server.ts
4295
+ var SHUTDOWN_GRACE_MS = 5000;
4296
+ var SHUTDOWN_SETTLE_MS = 200;
4297
+ async function delayMs(ms) {
4298
+ await new Promise((resolve) => setTimeout(resolve, ms));
4299
+ }
4300
+ function createShutdownTracker() {
4301
+ let shuttingDown = false;
4302
+ const active = new Set;
4303
+ return {
4304
+ get shuttingDown() {
4305
+ return shuttingDown;
4306
+ },
4307
+ get inFlight() {
4308
+ return active.size;
4309
+ },
4310
+ beginShutdown() {
4311
+ shuttingDown = true;
4312
+ },
4313
+ admit() {
4314
+ if (shuttingDown)
4315
+ return;
4316
+ const controller = new AbortController;
4317
+ active.add(controller);
4318
+ return controller;
4319
+ },
4320
+ release(controller) {
4321
+ active.delete(controller);
4322
+ },
4323
+ abortInFlight() {
4324
+ for (const controller of active)
4325
+ controller.abort();
4326
+ active.clear();
4327
+ }
4328
+ };
4329
+ }
4330
+ function withShutdownSignal(request, signal) {
4331
+ return new Request(request, { signal: AbortSignal.any([request.signal, signal]) });
4332
+ }
4333
+ function defineNivaWebhookServer(options, adapter) {
4334
+ const handler = createNivaWebhookHandler2(options);
4335
+ return {
4336
+ on: (event, fn) => handler.on(event, fn),
4337
+ off: (event) => handler.off(event),
4338
+ fetch: async (request) => handler.fetch(request),
4339
+ async serve(serveOptions = {}) {
4340
+ const shutdownGraceMs = serveOptions.shutdownGraceMs !== undefined && Number.isFinite(serveOptions.shutdownGraceMs) && serveOptions.shutdownGraceMs >= 0 ? serveOptions.shutdownGraceMs : SHUTDOWN_GRACE_MS;
4341
+ return adapter(async (request) => handler.fetch(request), {
4342
+ port: serveOptions.port ?? 0,
4343
+ hostname: serveOptions.hostname ?? "127.0.0.1",
4344
+ shutdownGraceMs
4345
+ });
4346
+ }
4347
+ };
4348
+ }
4349
+
4350
+ export { ERROR_CODES2, COMMON_ERROR_CODES2, ERROR_CODE_SETS2, OPERATIONS2, safe2, createNivaClient2, NIVA_WEBHOOK_EVENT_TYPES2, DEFAULT_TOLERANCE_SECONDS2, verifyNivaWebhook2, DEFAULT_MAX_BODY_BYTES2, createNivaWebhookHandler2, SHUTDOWN_SETTLE_MS, delayMs, createShutdownTracker, withShutdownSignal, defineNivaWebhookServer };