@voiflow/sdk 0.0.0-stage → 0.1.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,573 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeneratedResources = exports.Limits = exports.Operations = exports.Usage = exports.Sessions = exports.Events = exports.WebhookEndpoints = exports.AiWork = exports.Conversations = exports.Calls = exports.Runs = exports.Campaigns = exports.Projects = exports.Files = exports.Knowledge = exports.Calendar = exports.Appointments = exports.Enquiries = exports.Contacts = exports.Lines = exports.ChannelAccounts = exports.Integrations = exports.Connections = exports.Journeys = exports.Agents = exports.Businesses = void 0;
4
+ const pagination_js_1 = require("./pagination.js");
5
+ const sse_js_1 = require("./sse.js");
6
+ class Businesses {
7
+ http;
8
+ constructor(http) {
9
+ this.http = http;
10
+ }
11
+ list(params = {}) {
12
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/businesses`, { query: { ...params.extraQuery, ...{}, cursor } }).then((r) => r.data));
13
+ }
14
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
15
+ create(body, options = {}) {
16
+ return this.http.request("POST", `/businesses`, { body, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
17
+ }
18
+ retrieve(businessId, params = {}) {
19
+ return this.http.request("GET", `/businesses/${encodeURIComponent(businessId)}`, { query: { ...params.extraQuery, ...{} } }).then((r) => r.data.data);
20
+ }
21
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
22
+ update(businessId, body) {
23
+ return this.http.request("PATCH", `/businesses/${encodeURIComponent(businessId)}`, { body }).then((r) => r.data.data);
24
+ }
25
+ readiness(businessId, params = {}) {
26
+ return this.http.request("GET", `/businesses/${encodeURIComponent(businessId)}/readiness`, { query: { ...params.extraQuery, ...{} } }).then((r) => r.data.data);
27
+ }
28
+ settings(businessId, params = {}) {
29
+ return this.http.request("GET", `/businesses/${encodeURIComponent(businessId)}/settings`, { query: { ...params.extraQuery, ...{} } }).then((r) => r.data.data);
30
+ }
31
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
32
+ updateSettings(businessId, body = {}, options = {}) {
33
+ return this.http.request("PATCH", `/businesses/${encodeURIComponent(businessId)}/settings`, { body, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
34
+ }
35
+ }
36
+ exports.Businesses = Businesses;
37
+ class Agents {
38
+ http;
39
+ constructor(http) {
40
+ this.http = http;
41
+ }
42
+ list(params = {}) {
43
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/agents`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
44
+ }
45
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
46
+ create(body = {}, options = {}) {
47
+ return this.http.request("POST", `/agents`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
48
+ }
49
+ retrieve(agentId, params = {}) {
50
+ return this.http.request("GET", `/agents/${encodeURIComponent(agentId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
51
+ }
52
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
53
+ update(agentId, body = {}, options = {}) {
54
+ return this.http.request("PUT", `/agents/${encodeURIComponent(agentId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
55
+ }
56
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
57
+ delete(agentId, options = {}) {
58
+ return this.http.request("DELETE", `/agents/${encodeURIComponent(agentId)}`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
59
+ }
60
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
61
+ publish(agentId, body = {}, options = {}) {
62
+ return this.http.request("POST", `/agents/${encodeURIComponent(agentId)}/publish`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
63
+ }
64
+ voiceOptions(agentId, params = {}) {
65
+ return this.http.request("GET", `/agents/${encodeURIComponent(agentId)}/voice-options`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
66
+ }
67
+ }
68
+ exports.Agents = Agents;
69
+ class Journeys {
70
+ http;
71
+ constructor(http) {
72
+ this.http = http;
73
+ }
74
+ list(params = {}) {
75
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/journeys`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
76
+ }
77
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
78
+ create(body = {}, options = {}) {
79
+ return this.http.request("POST", `/journeys`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
80
+ }
81
+ retrieve(journeyId, params = {}) {
82
+ return this.http.request("GET", `/journeys/${encodeURIComponent(journeyId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
83
+ }
84
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
85
+ update(journeyId, body = {}, options = {}) {
86
+ return this.http.request("PUT", `/journeys/${encodeURIComponent(journeyId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
87
+ }
88
+ draft(journeyId, params = {}) {
89
+ return this.http.request("GET", `/journeys/${encodeURIComponent(journeyId)}/draft`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
90
+ }
91
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
92
+ saveDraft(journeyId, body, options = {}) {
93
+ return this.http.request("POST", `/journeys/${encodeURIComponent(journeyId)}/draft`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
94
+ }
95
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
96
+ createVersion(journeyId, body, options = {}) {
97
+ return this.http.request("POST", `/journeys/${encodeURIComponent(journeyId)}/versions`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
98
+ }
99
+ retrieveVersion(journeyId, version, params = {}) {
100
+ return this.http.request("GET", `/journeys/${encodeURIComponent(journeyId)}/versions/${encodeURIComponent(version)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
101
+ }
102
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
103
+ publish(journeyId, body, options = {}) {
104
+ return this.http.request("POST", `/journeys/${encodeURIComponent(journeyId)}/publish`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
105
+ }
106
+ impact(journeyId, params = {}) {
107
+ return this.http.request("GET", `/journeys/${encodeURIComponent(journeyId)}/impact`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
108
+ }
109
+ }
110
+ exports.Journeys = Journeys;
111
+ class Connections {
112
+ http;
113
+ constructor(http) {
114
+ this.http = http;
115
+ }
116
+ list(params = {}) {
117
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/connections`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
118
+ }
119
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
120
+ create(body, options = {}) {
121
+ return this.http.request("POST", `/connections`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
122
+ }
123
+ retrieve(connectionId, params = {}) {
124
+ return this.http.request("GET", `/connections/${encodeURIComponent(connectionId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
125
+ }
126
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
127
+ update(connectionId, body = {}, options = {}) {
128
+ return this.http.request("PATCH", `/connections/${encodeURIComponent(connectionId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
129
+ }
130
+ readiness(connectionId, params = {}) {
131
+ return this.http.request("GET", `/connections/${encodeURIComponent(connectionId)}/readiness`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
132
+ }
133
+ }
134
+ exports.Connections = Connections;
135
+ class Integrations {
136
+ http;
137
+ constructor(http) {
138
+ this.http = http;
139
+ }
140
+ list(params = {}) {
141
+ return this.http.request("GET", `/integrations`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
142
+ }
143
+ }
144
+ exports.Integrations = Integrations;
145
+ class ChannelAccounts {
146
+ http;
147
+ constructor(http) {
148
+ this.http = http;
149
+ }
150
+ list(params = {}) {
151
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/channel-accounts`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
152
+ }
153
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
154
+ create(body, options = {}) {
155
+ return this.http.request("POST", `/channel-accounts`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
156
+ }
157
+ }
158
+ exports.ChannelAccounts = ChannelAccounts;
159
+ class Lines {
160
+ http;
161
+ constructor(http) {
162
+ this.http = http;
163
+ }
164
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
165
+ update(lineId, body = {}, options = {}) {
166
+ return this.http.request("PUT", `/lines/${encodeURIComponent(lineId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
167
+ }
168
+ list(params = {}) {
169
+ return this.http.request("GET", `/lines`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
170
+ }
171
+ }
172
+ exports.Lines = Lines;
173
+ class Contacts {
174
+ http;
175
+ constructor(http) {
176
+ this.http = http;
177
+ }
178
+ list(params = {}) {
179
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/contacts`, { query: { ...params.extraQuery, ...{ search: params.search, stage: params.stage, business_id: params.businessId }, cursor } }).then((r) => r.data));
180
+ }
181
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
182
+ create(body = {}, options = {}) {
183
+ return this.http.request("POST", `/contacts`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
184
+ }
185
+ retrieve(contactId, params = {}) {
186
+ return this.http.request("GET", `/contacts/${encodeURIComponent(contactId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
187
+ }
188
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
189
+ update(contactId, body = {}, options = {}) {
190
+ return this.http.request("PUT", `/contacts/${encodeURIComponent(contactId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
191
+ }
192
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
193
+ setDnc(contactId, body = {}, options = {}) {
194
+ return this.http.request("POST", `/contacts/${encodeURIComponent(contactId)}/dnc`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
195
+ }
196
+ }
197
+ exports.Contacts = Contacts;
198
+ class Enquiries {
199
+ http;
200
+ constructor(http) {
201
+ this.http = http;
202
+ }
203
+ list(params = {}) {
204
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/enquiries`, { query: { ...params.extraQuery, ...{ state: params.state, business_id: params.businessId }, cursor } }).then((r) => r.data));
205
+ }
206
+ retrieve(requestId, params = {}) {
207
+ return this.http.request("GET", `/enquiries/${encodeURIComponent(requestId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
208
+ }
209
+ }
210
+ exports.Enquiries = Enquiries;
211
+ class Appointments {
212
+ http;
213
+ constructor(http) {
214
+ this.http = http;
215
+ }
216
+ list(params = {}) {
217
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/calendar/appointments`, { query: { ...params.extraQuery, ...{ from_ms: params.fromMs, to_ms: params.toMs, business_id: params.businessId }, cursor } }).then((r) => r.data));
218
+ }
219
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
220
+ create(body, options = {}) {
221
+ return this.http.request("POST", `/calendar/appointments`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
222
+ }
223
+ }
224
+ exports.Appointments = Appointments;
225
+ class Calendar {
226
+ http;
227
+ constructor(http) {
228
+ this.http = http;
229
+ }
230
+ availability(params = {}) {
231
+ return this.http.request("GET", `/calendar/availability`, { query: { ...params.extraQuery, ...{ from_ms: params.fromMs, to_ms: params.toMs, resource_id: params.resourceId, service: params.service, business_id: params.businessId } } }).then((r) => r.data.data);
232
+ }
233
+ resources(params = {}) {
234
+ return this.http.request("GET", `/calendar/resources`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
235
+ }
236
+ }
237
+ exports.Calendar = Calendar;
238
+ class Knowledge {
239
+ http;
240
+ constructor(http) {
241
+ this.http = http;
242
+ }
243
+ list(params = {}) {
244
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/knowledge`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
245
+ }
246
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
247
+ create(body = {}, options = {}) {
248
+ return this.http.request("POST", `/knowledge`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
249
+ }
250
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
251
+ update(itemId, body = {}, options = {}) {
252
+ return this.http.request("PUT", `/knowledge/${encodeURIComponent(itemId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
253
+ }
254
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
255
+ publish(itemId, options = {}) {
256
+ return this.http.request("POST", `/knowledge/${encodeURIComponent(itemId)}/publish`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
257
+ }
258
+ }
259
+ exports.Knowledge = Knowledge;
260
+ class Files {
261
+ http;
262
+ constructor(http) {
263
+ this.http = http;
264
+ }
265
+ list(params = {}) {
266
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/files`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
267
+ }
268
+ /** Multipart upload: `file` is the document; `metadata` is optional JSON (title, description, ...). */
269
+ upload(file, options = {}) {
270
+ return this.http.uploadMultipart("POST", `/files`, file, options).then((r) => r.data.data);
271
+ }
272
+ retrieve(docId, params = {}) {
273
+ return this.http.request("GET", `/files/${encodeURIComponent(docId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
274
+ }
275
+ /** The stored original as raw bytes. */
276
+ download(docId, params = {}) {
277
+ return this.http.requestBinary("GET", `/files/${encodeURIComponent(docId)}/content`, { query: { business_id: params.businessId } });
278
+ }
279
+ }
280
+ exports.Files = Files;
281
+ class Projects {
282
+ http;
283
+ constructor(http) {
284
+ this.http = http;
285
+ }
286
+ list(params = {}) {
287
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/projects`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
288
+ }
289
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
290
+ create(body, options = {}) {
291
+ return this.http.request("POST", `/projects`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
292
+ }
293
+ }
294
+ exports.Projects = Projects;
295
+ class Campaigns {
296
+ http;
297
+ constructor(http) {
298
+ this.http = http;
299
+ }
300
+ list(params = {}) {
301
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/campaigns`, { query: { ...params.extraQuery, ...{ project_id: params.projectId, status: params.status, business_id: params.businessId }, cursor } }).then((r) => r.data));
302
+ }
303
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
304
+ create(body, options = {}) {
305
+ return this.http.request("POST", `/campaigns`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
306
+ }
307
+ retrieve(campaignId, params = {}) {
308
+ return this.http.request("GET", `/campaigns/${encodeURIComponent(campaignId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
309
+ }
310
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
311
+ update(campaignId, body = {}, options = {}) {
312
+ return this.http.request("PUT", `/campaigns/${encodeURIComponent(campaignId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
313
+ }
314
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
315
+ setStatus(campaignId, body, options = {}) {
316
+ return this.http.request("POST", `/campaigns/${encodeURIComponent(campaignId)}/status`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
317
+ }
318
+ stats(campaignId, params = {}) {
319
+ return this.http.request("GET", `/campaigns/${encodeURIComponent(campaignId)}/stats`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
320
+ }
321
+ }
322
+ exports.Campaigns = Campaigns;
323
+ class Runs {
324
+ http;
325
+ constructor(http) {
326
+ this.http = http;
327
+ }
328
+ retrieve(runId, params = {}) {
329
+ return this.http.request("GET", `/runs/${encodeURIComponent(runId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
330
+ }
331
+ stats(runId, params = {}) {
332
+ return this.http.request("GET", `/runs/${encodeURIComponent(runId)}/stats`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
333
+ }
334
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
335
+ create(body, options = {}) {
336
+ return this.http.request("POST", `/runs`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
337
+ }
338
+ }
339
+ exports.Runs = Runs;
340
+ class Calls {
341
+ http;
342
+ constructor(http) {
343
+ this.http = http;
344
+ }
345
+ list(params = {}) {
346
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/calls`, { query: { ...params.extraQuery, ...{ agent_id: params.agentId, direction: params.direction, days: params.days, business_id: params.businessId }, cursor } }).then((r) => r.data));
347
+ }
348
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
349
+ create(body, options = {}) {
350
+ return this.http.request("POST", `/calls`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
351
+ }
352
+ retrieve(callId, params = {}) {
353
+ return this.http.request("GET", `/calls/${encodeURIComponent(callId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
354
+ }
355
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
356
+ end(callId, options = {}) {
357
+ return this.http.request("POST", `/calls/${encodeURIComponent(callId)}/end`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
358
+ }
359
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
360
+ steer(callId, body, options = {}) {
361
+ return this.http.request("POST", `/calls/${encodeURIComponent(callId)}/steer`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
362
+ }
363
+ transcript(callId, params = {}) {
364
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/calls/${encodeURIComponent(callId)}/transcript`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
365
+ }
366
+ recording(callId, params = {}) {
367
+ return this.http.request("GET", `/calls/${encodeURIComponent(callId)}/recording`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
368
+ }
369
+ async *stream(params, options = {}) {
370
+ const body = await this.http.openStream(`/events/stream`, { call: params.call, business_id: params.businessId }, { signal: options.signal, lastEventId: options.lastEventId });
371
+ yield* (0, sse_js_1.parseEventStream)(body);
372
+ }
373
+ }
374
+ exports.Calls = Calls;
375
+ class Conversations {
376
+ http;
377
+ constructor(http) {
378
+ this.http = http;
379
+ }
380
+ list(params = {}) {
381
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/conversations`, { query: { ...params.extraQuery, ...{ channel: params.channel, contact_id: params.contactId, state: params.state, business_id: params.businessId }, cursor } }).then((r) => r.data));
382
+ }
383
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
384
+ create(body, options = {}) {
385
+ return this.http.request("POST", `/conversations`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
386
+ }
387
+ retrieve(cid, params = {}) {
388
+ return this.http.request("GET", `/conversations/${encodeURIComponent(cid)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
389
+ }
390
+ listMessages(cid, params = {}) {
391
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/conversations/${encodeURIComponent(cid)}/messages`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
392
+ }
393
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
394
+ sendMessage(cid, body = {}, options = {}) {
395
+ return this.http.request("POST", `/conversations/${encodeURIComponent(cid)}/messages`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
396
+ }
397
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
398
+ takeover(cid, options = {}) {
399
+ return this.http.request("POST", `/conversations/${encodeURIComponent(cid)}/takeover`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
400
+ }
401
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
402
+ resumeAi(cid, options = {}) {
403
+ return this.http.request("POST", `/conversations/${encodeURIComponent(cid)}/resume-ai`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
404
+ }
405
+ }
406
+ exports.Conversations = Conversations;
407
+ class AiWork {
408
+ http;
409
+ constructor(http) {
410
+ this.http = http;
411
+ }
412
+ list(params = {}) {
413
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/promises`, { query: { ...params.extraQuery, ...{ state: params.state, channel: params.channel, contact_id: params.contactId, origin_kind: params.originKind, origin_id: params.originId, from_ts: params.fromTs, to_ts: params.toTs, business_id: params.businessId }, cursor } }).then((r) => r.data));
414
+ }
415
+ retrieve(promiseId, params = {}) {
416
+ return this.http.request("GET", `/promises/${encodeURIComponent(promiseId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
417
+ }
418
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
419
+ cancel(promiseId, options = {}) {
420
+ return this.http.request("POST", `/promises/${encodeURIComponent(promiseId)}/cancel`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
421
+ }
422
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
423
+ requeue(promiseId, options = {}) {
424
+ return this.http.request("POST", `/promises/${encodeURIComponent(promiseId)}/requeue`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
425
+ }
426
+ }
427
+ exports.AiWork = AiWork;
428
+ class WebhookEndpoints {
429
+ http;
430
+ constructor(http) {
431
+ this.http = http;
432
+ }
433
+ list(params = {}) {
434
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/webhook-endpoints`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
435
+ }
436
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
437
+ create(body, options = {}) {
438
+ return this.http.request("POST", `/webhook-endpoints`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
439
+ }
440
+ retrieve(endpointId, params = {}) {
441
+ return this.http.request("GET", `/webhook-endpoints/${encodeURIComponent(endpointId)}`, { query: { ...params.extraQuery, ...{ business_id: params.businessId } } }).then((r) => r.data.data);
442
+ }
443
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
444
+ update(endpointId, body = {}, options = {}) {
445
+ return this.http.request("PATCH", `/webhook-endpoints/${encodeURIComponent(endpointId)}`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
446
+ }
447
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
448
+ delete(endpointId, options = {}) {
449
+ return this.http.request("DELETE", `/webhook-endpoints/${encodeURIComponent(endpointId)}`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
450
+ }
451
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
452
+ rotateSecret(endpointId, options = {}) {
453
+ return this.http.request("POST", `/webhook-endpoints/${encodeURIComponent(endpointId)}/rotate-secret`, { query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
454
+ }
455
+ listDeliveries(endpointId, params = {}) {
456
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/webhook-endpoints/${encodeURIComponent(endpointId)}/deliveries`, { query: { ...params.extraQuery, ...{ business_id: params.businessId }, cursor } }).then((r) => r.data));
457
+ }
458
+ }
459
+ exports.WebhookEndpoints = WebhookEndpoints;
460
+ class Events {
461
+ http;
462
+ constructor(http) {
463
+ this.http = http;
464
+ }
465
+ list(params = {}) {
466
+ return (0, pagination_js_1.paginate)((cursor) => this.http.request("GET", `/events`, { query: { ...params.extraQuery, ...{ event_type: params.eventType, business_id: params.businessId }, cursor } }).then((r) => r.data));
467
+ }
468
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
469
+ replay(eventId, options = {}) {
470
+ return this.http.request("POST", `/events/${encodeURIComponent(eventId)}/replay`, { query: { endpoint_id: options.endpointId, business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
471
+ }
472
+ }
473
+ exports.Events = Events;
474
+ class Sessions {
475
+ http;
476
+ constructor(http) {
477
+ this.http = http;
478
+ }
479
+ /** May throw VoiFlowOperationPending (HTTP 202): the outcome is not yet known — do not repeat under a new key. */
480
+ create(body, options = {}) {
481
+ return this.http.request("POST", `/sessions`, { body, query: { business_id: options.businessId }, idempotencyKey: options.idempotencyKey, idempotent: true }).then((r) => r.data.data);
482
+ }
483
+ }
484
+ exports.Sessions = Sessions;
485
+ class Usage {
486
+ http;
487
+ constructor(http) {
488
+ this.http = http;
489
+ }
490
+ get(params = {}) {
491
+ return this.http.request("GET", `/usage`, { query: { ...params.extraQuery, ...{ days: params.days, from_ms: params.fromMs, to_ms: params.toMs, business_id: params.businessId } } }).then((r) => r.data.data);
492
+ }
493
+ costs(params = {}) {
494
+ return this.http.request("GET", `/usage/costs`, { query: { ...params.extraQuery, ...{ days: params.days, business_id: params.businessId } } }).then((r) => r.data.data);
495
+ }
496
+ }
497
+ exports.Usage = Usage;
498
+ class Operations {
499
+ http;
500
+ constructor(http) {
501
+ this.http = http;
502
+ }
503
+ retrieve(operationId, params = {}) {
504
+ return this.http.request("GET", `/operations/${encodeURIComponent(operationId)}`, { query: { ...params.extraQuery, ...{} } }).then((r) => r.data.data);
505
+ }
506
+ }
507
+ exports.Operations = Operations;
508
+ class Limits {
509
+ http;
510
+ constructor(http) {
511
+ this.http = http;
512
+ }
513
+ get(params = {}) {
514
+ return this.http.request("GET", `/limits`, { query: { ...params.extraQuery, ...{} } }).then((r) => r.data.data);
515
+ }
516
+ }
517
+ exports.Limits = Limits;
518
+ /** One property per published resource group; VoiFlowClient extends this. */
519
+ class GeneratedResources {
520
+ businesses;
521
+ agents;
522
+ journeys;
523
+ connections;
524
+ integrations;
525
+ channelAccounts;
526
+ lines;
527
+ contacts;
528
+ enquiries;
529
+ appointments;
530
+ calendar;
531
+ knowledge;
532
+ files;
533
+ projects;
534
+ campaigns;
535
+ runs;
536
+ calls;
537
+ conversations;
538
+ aiWork;
539
+ webhookEndpoints;
540
+ events;
541
+ sessions;
542
+ usage;
543
+ operations;
544
+ limits;
545
+ constructor(http) {
546
+ this.businesses = new Businesses(http);
547
+ this.agents = new Agents(http);
548
+ this.journeys = new Journeys(http);
549
+ this.connections = new Connections(http);
550
+ this.integrations = new Integrations(http);
551
+ this.channelAccounts = new ChannelAccounts(http);
552
+ this.lines = new Lines(http);
553
+ this.contacts = new Contacts(http);
554
+ this.enquiries = new Enquiries(http);
555
+ this.appointments = new Appointments(http);
556
+ this.calendar = new Calendar(http);
557
+ this.knowledge = new Knowledge(http);
558
+ this.files = new Files(http);
559
+ this.projects = new Projects(http);
560
+ this.campaigns = new Campaigns(http);
561
+ this.runs = new Runs(http);
562
+ this.calls = new Calls(http);
563
+ this.conversations = new Conversations(http);
564
+ this.aiWork = new AiWork(http);
565
+ this.webhookEndpoints = new WebhookEndpoints(http);
566
+ this.events = new Events(http);
567
+ this.sessions = new Sessions(http);
568
+ this.usage = new Usage(http);
569
+ this.operations = new Operations(http);
570
+ this.limits = new Limits(http);
571
+ }
572
+ }
573
+ exports.GeneratedResources = GeneratedResources;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseEventStream = parseEventStream;
4
+ /** Parses a text/event-stream body into discrete events, one yield per blank-line-terminated block. */
5
+ async function* parseEventStream(stream) {
6
+ const reader = stream.getReader();
7
+ const decoder = new TextDecoder();
8
+ let buffer = "";
9
+ try {
10
+ while (true) {
11
+ const { value, done } = await reader.read();
12
+ if (done)
13
+ break;
14
+ buffer += decoder.decode(value, { stream: true });
15
+ let boundary;
16
+ while ((boundary = buffer.indexOf("\n\n")) !== -1) {
17
+ const block = buffer.slice(0, boundary);
18
+ buffer = buffer.slice(boundary + 2);
19
+ const event = parseBlock(block);
20
+ if (event)
21
+ yield event;
22
+ }
23
+ }
24
+ }
25
+ finally {
26
+ // Closes the underlying connection too, not just the local reader lock — important when the
27
+ // caller breaks out of a for-await loop early (SSE streams are otherwise long-lived).
28
+ await reader.cancel().catch(() => undefined);
29
+ }
30
+ }
31
+ function parseBlock(block) {
32
+ let id;
33
+ let eventName;
34
+ const dataLines = [];
35
+ for (const line of block.split("\n")) {
36
+ if (line.startsWith("id:"))
37
+ id = line.slice(3).trim();
38
+ else if (line.startsWith("event:"))
39
+ eventName = line.slice(6).trim();
40
+ else if (line.startsWith("data:"))
41
+ dataLines.push(line.slice(5).trim());
42
+ }
43
+ if (dataLines.length === 0)
44
+ return undefined;
45
+ return { id, event: eventName, data: dataLines.join("\n") };
46
+ }