@sippulse/niva-sdk 0.1.0 → 0.2.0

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