@unboundcx/sdk 4.8.9 → 4.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base.js +71 -29
- package/index.js +6 -3
- package/package.json +1 -4
- package/services/ai/playbooks.js +22 -21
- package/services/ai/settings.js +4 -2
- package/services/ai/translate.js +3 -1
- package/services/ai/vocabulary.js +4 -3
- package/services/ai.js +21 -20
- package/services/chat.js +124 -48
- package/services/developerApis.js +174 -0
- package/services/directory.js +109 -12
- package/services/documents.js +11 -10
- package/services/engagementMetrics.js +2 -1
- package/services/enroll.js +16 -15
- package/services/externalOAuth.js +12 -11
- package/services/fax.js +4 -3
- package/services/generateId.js +3 -2
- package/services/googleCalendar.js +7 -6
- package/services/inbox.js +59 -11
- package/services/knowledgeBase.js +9 -8
- package/services/layouts.js +15 -14
- package/services/login.js +8 -7
- package/services/lookup.js +4 -3
- package/services/messaging/EmailAddressesService.js +5 -4
- package/services/messaging/EmailAnalyticsService.js +5 -4
- package/services/messaging/EmailDomainsService.js +8 -7
- package/services/messaging/EmailMailboxesService.js +59 -9
- package/services/messaging/EmailQueueService.js +2 -1
- package/services/messaging/EmailService.js +12 -11
- package/services/messaging/EmailSuppressionService.js +5 -4
- package/services/messaging/EmailTemplatesService.js +6 -5
- package/services/messaging/SmsService.js +3 -2
- package/services/messaging/SmsTemplatesService.js +6 -5
- package/services/messaging/TenDlcBrandsService.js +11 -10
- package/services/messaging/TenDlcCampaignManagementService.js +14 -13
- package/services/messaging/TenDlcCampaignsService.js +2 -1
- package/services/messaging/TollFreeCampaignsService.js +13 -12
- package/services/notes.js +7 -6
- package/services/objects.js +97 -36
- package/services/permissions.js +34 -33
- package/services/phoneNumbers.js +28 -27
- package/services/portals.js +8 -7
- package/services/recordTypes.js +12 -11
- package/services/search.js +2 -1
- package/services/sipEndpoints.js +8 -7
- package/services/storage.js +16 -15
- package/services/subscriptions.js +4 -3
- package/services/taskRouter/CCService.js +303 -0
- package/services/taskRouter/MetricsService.js +56 -1
- package/services/taskRouter/TaskRouterService.js +2 -0
- package/services/taskRouter/TaskService.js +13 -12
- package/services/taskRouter/WorkerService.js +9 -8
- package/services/triggers.js +9 -8
- package/services/verification.js +5 -4
- package/services/video.js +230 -45
- package/services/voice.js +40 -11
- package/services/workflows.js +22 -21
package/base.js
CHANGED
|
@@ -13,6 +13,31 @@
|
|
|
13
13
|
* npm install mime-types
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
const requestBySdk = new WeakMap();
|
|
17
|
+
const SDK_REQUEST = Symbol.for('unbound.sdk.request');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Service-internal request. Not part of the public SDK surface.
|
|
21
|
+
* Named SDK methods call this; app code must not. Optional transports
|
|
22
|
+
* (e.g. Socket.IO) are used when available unless httpOnly/forceFetch.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} sdk
|
|
25
|
+
* @param {string} endpoint
|
|
26
|
+
* @param {string} method
|
|
27
|
+
* @param {object} [params]
|
|
28
|
+
* @param {boolean} [forceFetch] Skip optional transports (HTTP only).
|
|
29
|
+
* Use for file upload/download.
|
|
30
|
+
*/
|
|
31
|
+
export function internalRequest(sdk, endpoint, method, params = {}, forceFetch) {
|
|
32
|
+
const run =
|
|
33
|
+
requestBySdk.get(sdk) || sdk?.[SDK_REQUEST];
|
|
34
|
+
if (typeof run !== 'function') {
|
|
35
|
+
throw new Error('SDK request is not initialized');
|
|
36
|
+
}
|
|
37
|
+
const httpOnly = forceFetch === true || params?.httpOnly === true;
|
|
38
|
+
return run(endpoint, method, params, httpOnly);
|
|
39
|
+
}
|
|
40
|
+
|
|
16
41
|
export class BaseSDK {
|
|
17
42
|
constructor(options = {}) {
|
|
18
43
|
// Support both object and legacy positional parameters for backwards compatibility
|
|
@@ -35,6 +60,15 @@ export class BaseSDK {
|
|
|
35
60
|
this.transports = new Map();
|
|
36
61
|
this.debugMode = false;
|
|
37
62
|
this._initializeEnvironment();
|
|
63
|
+
const run = (endpoint, method, params, forceFetch) =>
|
|
64
|
+
this.#request(endpoint, method, params, forceFetch);
|
|
65
|
+
requestBySdk.set(this, run);
|
|
66
|
+
Object.defineProperty(this, SDK_REQUEST, {
|
|
67
|
+
value: run,
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: false,
|
|
70
|
+
writable: false,
|
|
71
|
+
});
|
|
38
72
|
}
|
|
39
73
|
|
|
40
74
|
_initializeEnvironment() {
|
|
@@ -177,7 +211,13 @@ export class BaseSDK {
|
|
|
177
211
|
}
|
|
178
212
|
}
|
|
179
213
|
|
|
180
|
-
|
|
214
|
+
_fetch() {
|
|
215
|
+
throw new Error(
|
|
216
|
+
'sdk._fetch is private. Use a service method (sdk.chat, sdk.objects, ...).',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async #request(endpoint, method, params = {}, forceFetch = false) {
|
|
181
221
|
const startTime = Date.now();
|
|
182
222
|
const { body, query, headers = {}, returnRawResponse = false } = params;
|
|
183
223
|
|
|
@@ -410,37 +450,36 @@ export class BaseSDK {
|
|
|
410
450
|
'application/json';
|
|
411
451
|
|
|
412
452
|
if (!response.ok) {
|
|
453
|
+
// A fetch Response's `.body` is a ReadableStream, not the parsed
|
|
454
|
+
// payload — it must go through json()/text() or the API's
|
|
455
|
+
// `{ message }` envelope is lost and every error surfaces as the
|
|
456
|
+
// generic "API Error". Only NATS-transport responses carry a
|
|
457
|
+
// pre-parsed `.body`.
|
|
413
458
|
let errorBody;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
) {
|
|
422
|
-
|
|
423
|
-
errorBody = await response.json();
|
|
424
|
-
} else if (contentType.includes('text/')) {
|
|
425
|
-
errorBody = await response.text();
|
|
426
|
-
}
|
|
427
|
-
} else {
|
|
428
|
-
if (contentType.includes('application/json')) {
|
|
429
|
-
errorBody = this._getJsonSafely(
|
|
430
|
-
response?.body,
|
|
431
|
-
response?.body || {},
|
|
432
|
-
);
|
|
433
|
-
} else if (contentType.includes('text/')) {
|
|
434
|
-
errorBody = response?.body || '';
|
|
435
|
-
}
|
|
459
|
+
try {
|
|
460
|
+
if (
|
|
461
|
+
typeof response?.json === 'function' ||
|
|
462
|
+
typeof response?.text === 'function'
|
|
463
|
+
) {
|
|
464
|
+
if (contentType.includes('application/json')) {
|
|
465
|
+
errorBody = await response.json();
|
|
466
|
+
} else if (contentType.includes('text/')) {
|
|
467
|
+
errorBody = await response.text();
|
|
436
468
|
}
|
|
437
|
-
|
|
438
|
-
|
|
469
|
+
} else if (response?.body) {
|
|
470
|
+
if (contentType.includes('application/json')) {
|
|
471
|
+
errorBody = this._getJsonSafely(
|
|
472
|
+
response?.body,
|
|
473
|
+
response?.body || {},
|
|
474
|
+
);
|
|
475
|
+
} else {
|
|
476
|
+
errorBody = response.body;
|
|
439
477
|
}
|
|
440
|
-
} catch (parseError) {
|
|
441
|
-
errorBody = `HTTP ${response.status} ${response.statusText}`;
|
|
442
478
|
}
|
|
443
|
-
}
|
|
479
|
+
} catch (parseError) {
|
|
480
|
+
// fall through to the status-line fallback below
|
|
481
|
+
}
|
|
482
|
+
if (!errorBody) {
|
|
444
483
|
errorBody = `HTTP ${response.status} ${response.statusText}`;
|
|
445
484
|
}
|
|
446
485
|
|
|
@@ -455,7 +494,10 @@ export class BaseSDK {
|
|
|
455
494
|
httpError.method = method;
|
|
456
495
|
httpError.endpoint = endpoint;
|
|
457
496
|
httpError.body = errorBody;
|
|
458
|
-
httpError.message =
|
|
497
|
+
httpError.message =
|
|
498
|
+
errorBody?.error ||
|
|
499
|
+
errorBody?.message ||
|
|
500
|
+
(typeof errorBody === 'string' ? errorBody : 'API Error');
|
|
459
501
|
|
|
460
502
|
// Debug logging for successful HTTP requests
|
|
461
503
|
if (this.debugMode) {
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
2
|
/* eslint-disable prettier/prettier */
|
|
3
3
|
|
|
4
|
-
import { BaseSDK } from './base.js';
|
|
4
|
+
import { BaseSDK, internalRequest } from './base.js';
|
|
5
5
|
import { LoginService } from './services/login.js';
|
|
6
6
|
import { ObjectsService } from './services/objects.js';
|
|
7
7
|
import { MessagingService } from './services/messaging/MessagingService.js';
|
|
@@ -34,6 +34,7 @@ import { InboxService } from './services/inbox.js';
|
|
|
34
34
|
import { SearchService } from './services/search.js';
|
|
35
35
|
import { DirectoryService } from './services/directory.js';
|
|
36
36
|
import { ChatService } from './services/chat.js';
|
|
37
|
+
import { DeveloperApisService } from './services/developerApis.js';
|
|
37
38
|
|
|
38
39
|
class UnboundSDK extends BaseSDK {
|
|
39
40
|
constructor(options = {}) {
|
|
@@ -109,6 +110,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
109
110
|
this.search = new SearchService(this);
|
|
110
111
|
this.directory = new DirectoryService(this);
|
|
111
112
|
this.chat = new ChatService(this);
|
|
113
|
+
this.developerApis = new DeveloperApisService(this);
|
|
112
114
|
|
|
113
115
|
// Add additional services that might be missing
|
|
114
116
|
this._initializeAdditionalServices();
|
|
@@ -188,7 +190,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
188
190
|
*/
|
|
189
191
|
async status() {
|
|
190
192
|
try {
|
|
191
|
-
const response = await this
|
|
193
|
+
const response = await internalRequest(this, '/health', 'GET', {
|
|
192
194
|
returnRawResponse: true,
|
|
193
195
|
});
|
|
194
196
|
|
|
@@ -242,7 +244,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
242
244
|
*/
|
|
243
245
|
async getIp() {
|
|
244
246
|
// Force fetch transport (pass true as forceFetch parameter)
|
|
245
|
-
return await this
|
|
247
|
+
return await internalRequest(this, '/get-ip', 'GET', {}, true);
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
|
|
@@ -293,4 +295,5 @@ export { InboxService } from './services/inbox.js';
|
|
|
293
295
|
export { SearchService } from './services/search.js';
|
|
294
296
|
export { DirectoryService } from './services/directory.js';
|
|
295
297
|
export { ChatService } from './services/chat.js';
|
|
298
|
+
export { DeveloperApisService } from './services/developerApis.js';
|
|
296
299
|
export { BaseSDK } from './base.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.11",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,6 @@
|
|
|
52
52
|
"import": "./index.js",
|
|
53
53
|
"require": "./index.cjs"
|
|
54
54
|
},
|
|
55
|
-
"./base": {
|
|
56
|
-
"import": "./base.js"
|
|
57
|
-
},
|
|
58
55
|
"./services/*": {
|
|
59
56
|
"import": "./services/*.js"
|
|
60
57
|
},
|
package/services/ai/playbooks.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
1
2
|
/**
|
|
2
3
|
* Playbooks Service - Manage AI-driven playbook sessions for guided workflows
|
|
3
4
|
*/
|
|
@@ -36,7 +37,7 @@ export class PlaybooksService {
|
|
|
36
37
|
body: { name, recordTypeId },
|
|
37
38
|
};
|
|
38
39
|
|
|
39
|
-
const result = await this.sdk
|
|
40
|
+
const result = await internalRequest(this.sdk, '/ai/playbooks', 'POST', params);
|
|
40
41
|
return result;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -60,7 +61,7 @@ export class PlaybooksService {
|
|
|
60
61
|
},
|
|
61
62
|
);
|
|
62
63
|
|
|
63
|
-
const result = await this.sdk
|
|
64
|
+
const result = await internalRequest(this.sdk, `/ai/playbooks/${playbookId}`, 'GET');
|
|
64
65
|
return result;
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -92,7 +93,7 @@ export class PlaybooksService {
|
|
|
92
93
|
query: { limit, orderBy, orderDirection, isPublished, recordTypeId },
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
const result = await this.sdk
|
|
96
|
+
const result = await internalRequest(this.sdk, '/ai/playbooks', 'GET', params);
|
|
96
97
|
return result;
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -128,7 +129,7 @@ export class PlaybooksService {
|
|
|
128
129
|
body: { name, isPublished, recordTypeId },
|
|
129
130
|
};
|
|
130
131
|
|
|
131
|
-
const result = await this.sdk
|
|
132
|
+
const result = await internalRequest(this.sdk,
|
|
132
133
|
`/ai/playbooks/${playbookId}`,
|
|
133
134
|
'PUT',
|
|
134
135
|
params,
|
|
@@ -156,7 +157,7 @@ export class PlaybooksService {
|
|
|
156
157
|
},
|
|
157
158
|
);
|
|
158
159
|
|
|
159
|
-
const result = await this.sdk
|
|
160
|
+
const result = await internalRequest(this.sdk,
|
|
160
161
|
`/ai/playbooks/${playbookId}`,
|
|
161
162
|
'DELETE',
|
|
162
163
|
);
|
|
@@ -247,7 +248,7 @@ export class PlaybooksService {
|
|
|
247
248
|
},
|
|
248
249
|
};
|
|
249
250
|
|
|
250
|
-
const result = await this.sdk
|
|
251
|
+
const result = await internalRequest(this.sdk,
|
|
251
252
|
`/ai/playbooks/${playbookId}/goals`,
|
|
252
253
|
'POST',
|
|
253
254
|
params,
|
|
@@ -278,7 +279,7 @@ export class PlaybooksService {
|
|
|
278
279
|
},
|
|
279
280
|
);
|
|
280
281
|
|
|
281
|
-
const result = await this.sdk
|
|
282
|
+
const result = await internalRequest(this.sdk,
|
|
282
283
|
`/ai/playbooks/${playbookId}/goals/${goalId}`,
|
|
283
284
|
'GET',
|
|
284
285
|
);
|
|
@@ -305,7 +306,7 @@ export class PlaybooksService {
|
|
|
305
306
|
},
|
|
306
307
|
);
|
|
307
308
|
|
|
308
|
-
const result = await this.sdk
|
|
309
|
+
const result = await internalRequest(this.sdk,
|
|
309
310
|
`/ai/playbooks/${playbookId}/goals`,
|
|
310
311
|
'GET',
|
|
311
312
|
);
|
|
@@ -390,7 +391,7 @@ export class PlaybooksService {
|
|
|
390
391
|
},
|
|
391
392
|
};
|
|
392
393
|
|
|
393
|
-
const result = await this.sdk
|
|
394
|
+
const result = await internalRequest(this.sdk,
|
|
394
395
|
`/ai/playbooks/goals/${goalId}`,
|
|
395
396
|
'PUT',
|
|
396
397
|
params,
|
|
@@ -418,7 +419,7 @@ export class PlaybooksService {
|
|
|
418
419
|
},
|
|
419
420
|
);
|
|
420
421
|
|
|
421
|
-
const result = await this.sdk
|
|
422
|
+
const result = await internalRequest(this.sdk,
|
|
422
423
|
`/ai/playbooks/goals/${goalId}`,
|
|
423
424
|
'DELETE',
|
|
424
425
|
);
|
|
@@ -454,7 +455,7 @@ export class PlaybooksService {
|
|
|
454
455
|
},
|
|
455
456
|
};
|
|
456
457
|
|
|
457
|
-
const result = await this.sdk
|
|
458
|
+
const result = await internalRequest(this.sdk,
|
|
458
459
|
`/ai/playbooks/${playbookId}/goals/reorder`,
|
|
459
460
|
'PUT',
|
|
460
461
|
params,
|
|
@@ -511,7 +512,7 @@ export class PlaybooksService {
|
|
|
511
512
|
body: { name, description, keywords, recommendedPhase, role, signal, recordTypeId },
|
|
512
513
|
};
|
|
513
514
|
|
|
514
|
-
const result = await this.sdk
|
|
515
|
+
const result = await internalRequest(this.sdk,
|
|
515
516
|
'/ai/playbooks/goalTypes',
|
|
516
517
|
'POST',
|
|
517
518
|
params,
|
|
@@ -539,7 +540,7 @@ export class PlaybooksService {
|
|
|
539
540
|
},
|
|
540
541
|
);
|
|
541
542
|
|
|
542
|
-
const result = await this.sdk
|
|
543
|
+
const result = await internalRequest(this.sdk,
|
|
543
544
|
`/ai/playbooks/goalTypes/${goalTypeId}`,
|
|
544
545
|
'GET',
|
|
545
546
|
);
|
|
@@ -574,7 +575,7 @@ export class PlaybooksService {
|
|
|
574
575
|
query: { limit, orderBy, orderDirection, recommendedPhase, recordTypeId },
|
|
575
576
|
};
|
|
576
577
|
|
|
577
|
-
const result = await this.sdk
|
|
578
|
+
const result = await internalRequest(this.sdk,
|
|
578
579
|
'/ai/playbooks/goalTypes',
|
|
579
580
|
'GET',
|
|
580
581
|
params,
|
|
@@ -629,7 +630,7 @@ export class PlaybooksService {
|
|
|
629
630
|
body: { name, description, keywords, recommendedPhase, role, signal, recordTypeId },
|
|
630
631
|
};
|
|
631
632
|
|
|
632
|
-
const result = await this.sdk
|
|
633
|
+
const result = await internalRequest(this.sdk,
|
|
633
634
|
`/ai/playbooks/goalTypes/${goalTypeId}`,
|
|
634
635
|
'PUT',
|
|
635
636
|
params,
|
|
@@ -657,7 +658,7 @@ export class PlaybooksService {
|
|
|
657
658
|
},
|
|
658
659
|
);
|
|
659
660
|
|
|
660
|
-
const result = await this.sdk
|
|
661
|
+
const result = await internalRequest(this.sdk,
|
|
661
662
|
`/ai/playbooks/goalTypes/${goalTypeId}`,
|
|
662
663
|
'DELETE',
|
|
663
664
|
);
|
|
@@ -736,7 +737,7 @@ export class PlaybooksService {
|
|
|
736
737
|
},
|
|
737
738
|
};
|
|
738
739
|
|
|
739
|
-
const result = await this.sdk
|
|
740
|
+
const result = await internalRequest(this.sdk,
|
|
740
741
|
`/ai/playbooks/sessions/${playbookId}`,
|
|
741
742
|
'POST',
|
|
742
743
|
params,
|
|
@@ -792,7 +793,7 @@ export class PlaybooksService {
|
|
|
792
793
|
);
|
|
793
794
|
|
|
794
795
|
if (sessionId) {
|
|
795
|
-
const result = await this.sdk
|
|
796
|
+
const result = await internalRequest(this.sdk,
|
|
796
797
|
`/ai/playbooks/sessions/${sessionId}`,
|
|
797
798
|
'GET',
|
|
798
799
|
);
|
|
@@ -804,7 +805,7 @@ export class PlaybooksService {
|
|
|
804
805
|
if (workerId) query.workerId = workerId;
|
|
805
806
|
if (userId) query.userId = userId;
|
|
806
807
|
|
|
807
|
-
const result = await this.sdk
|
|
808
|
+
const result = await internalRequest(this.sdk,
|
|
808
809
|
`/ai/playbooks/sessions`,
|
|
809
810
|
'GET',
|
|
810
811
|
{ query },
|
|
@@ -882,7 +883,7 @@ export class PlaybooksService {
|
|
|
882
883
|
},
|
|
883
884
|
};
|
|
884
885
|
|
|
885
|
-
const result = await this.sdk
|
|
886
|
+
const result = await internalRequest(this.sdk,
|
|
886
887
|
`/ai/playbooks/sessions/${sessionId}/complete`,
|
|
887
888
|
'PUT',
|
|
888
889
|
params,
|
|
@@ -984,7 +985,7 @@ export class PlaybooksService {
|
|
|
984
985
|
},
|
|
985
986
|
};
|
|
986
987
|
|
|
987
|
-
const result = await this.sdk
|
|
988
|
+
const result = await internalRequest(this.sdk,
|
|
988
989
|
`/ai/playbooks/sessions/${sessionId}/goal`,
|
|
989
990
|
'POST',
|
|
990
991
|
params,
|
package/services/ai/settings.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* AI Settings helpers - Manage account-level AI feature settings
|
|
3
5
|
* Exposed directly on AIService as getSettings()/updateSettings()
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
* @returns {Promise<Object>} { settings: { shareOcrEnabled } }
|
|
10
12
|
*/
|
|
11
13
|
export async function getSettings(sdk) {
|
|
12
|
-
const result = await sdk
|
|
14
|
+
const result = await internalRequest(sdk, '/ai/settings', 'GET');
|
|
13
15
|
return result;
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -32,6 +34,6 @@ export async function updateSettings(sdk, { shareOcrEnabled }) {
|
|
|
32
34
|
body: { shareOcrEnabled },
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
const result = await sdk
|
|
37
|
+
const result = await internalRequest(sdk, '/ai/settings', 'PUT', params);
|
|
36
38
|
return result;
|
|
37
39
|
}
|
package/services/ai/translate.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* AI Translate helper - Batch-translate arbitrary text items
|
|
3
5
|
* Exposed directly on AIService as translate()
|
|
@@ -33,6 +35,6 @@ export async function translate(
|
|
|
33
35
|
body: { items, targetLanguage, sourceLanguage, domain, context },
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const result = await sdk
|
|
38
|
+
const result = await internalRequest(sdk, '/ai/translate', 'POST', params);
|
|
37
39
|
return result;
|
|
38
40
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
1
2
|
/**
|
|
2
3
|
* Vocabulary Service - Manage account-level custom transcription vocabulary
|
|
3
4
|
*/
|
|
@@ -11,7 +12,7 @@ export class VocabularyService {
|
|
|
11
12
|
* @returns {Promise<Object>} { terms: [{id, term, createdBy, createdAt}] }
|
|
12
13
|
*/
|
|
13
14
|
async list() {
|
|
14
|
-
const result = await this.sdk
|
|
15
|
+
const result = await internalRequest(this.sdk, '/ai/vocabulary', 'GET');
|
|
15
16
|
return result;
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -32,7 +33,7 @@ export class VocabularyService {
|
|
|
32
33
|
body: { term },
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const result = await this.sdk
|
|
36
|
+
const result = await internalRequest(this.sdk, '/ai/vocabulary', 'POST', params);
|
|
36
37
|
return result;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -49,7 +50,7 @@ export class VocabularyService {
|
|
|
49
50
|
},
|
|
50
51
|
);
|
|
51
52
|
|
|
52
|
-
const result = await this.sdk
|
|
53
|
+
const result = await internalRequest(this.sdk, `/ai/vocabulary/${id}`, 'DELETE');
|
|
53
54
|
return result;
|
|
54
55
|
}
|
|
55
56
|
}
|
package/services/ai.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { internalRequest } from '../base.js';
|
|
1
2
|
import { PlaybooksService } from './ai/playbooks.js';
|
|
2
3
|
import { VocabularyService } from './ai/vocabulary.js';
|
|
3
4
|
import { translate as translateItems } from './ai/translate.js';
|
|
@@ -175,7 +176,7 @@ export class GenerativeService {
|
|
|
175
176
|
),
|
|
176
177
|
);
|
|
177
178
|
const forceFetch = stream === true || hasLargeContent;
|
|
178
|
-
const result = await this.sdk
|
|
179
|
+
const result = await internalRequest(this.sdk,
|
|
179
180
|
'/ai/generative/chat',
|
|
180
181
|
'POST',
|
|
181
182
|
params,
|
|
@@ -249,7 +250,7 @@ export class GenerativeService {
|
|
|
249
250
|
},
|
|
250
251
|
};
|
|
251
252
|
|
|
252
|
-
const result = await this.sdk
|
|
253
|
+
const result = await internalRequest(this.sdk,
|
|
253
254
|
'/ai/generative/chat/clone',
|
|
254
255
|
'POST',
|
|
255
256
|
params,
|
|
@@ -274,7 +275,7 @@ export class GenerativeService {
|
|
|
274
275
|
body: payload,
|
|
275
276
|
};
|
|
276
277
|
|
|
277
|
-
const result = await this.sdk
|
|
278
|
+
const result = await internalRequest(this.sdk, '/ai/summarize', 'POST', params);
|
|
278
279
|
return result;
|
|
279
280
|
}
|
|
280
281
|
|
|
@@ -283,7 +284,7 @@ export class GenerativeService {
|
|
|
283
284
|
* @returns {Promise<Object>} { tools: Array<{ name, label, description, configRequirements }>, count: number }
|
|
284
285
|
*/
|
|
285
286
|
async listTools() {
|
|
286
|
-
return await this.sdk
|
|
287
|
+
return await internalRequest(this.sdk, '/ai/generative/tools', 'GET');
|
|
287
288
|
}
|
|
288
289
|
|
|
289
290
|
/**
|
|
@@ -307,7 +308,7 @@ export class GenerativeService {
|
|
|
307
308
|
);
|
|
308
309
|
|
|
309
310
|
const params = { query: { relatedId, scope, limit, offset } };
|
|
310
|
-
const result = await this.sdk
|
|
311
|
+
const result = await internalRequest(this.sdk,
|
|
311
312
|
'/ai/generative/sessions',
|
|
312
313
|
'GET',
|
|
313
314
|
params,
|
|
@@ -327,7 +328,7 @@ export class GenerativeService {
|
|
|
327
328
|
{ sessionId: { type: 'string', required: true } },
|
|
328
329
|
);
|
|
329
330
|
|
|
330
|
-
const result = await this.sdk
|
|
331
|
+
const result = await internalRequest(this.sdk,
|
|
331
332
|
`/ai/generative/sessions/${sessionId}`,
|
|
332
333
|
'GET',
|
|
333
334
|
);
|
|
@@ -352,7 +353,7 @@ export class GenerativeService {
|
|
|
352
353
|
},
|
|
353
354
|
);
|
|
354
355
|
|
|
355
|
-
const result = await this.sdk
|
|
356
|
+
const result = await internalRequest(this.sdk,
|
|
356
357
|
`/ai/generative/sessions/${sessionId}`,
|
|
357
358
|
'PUT',
|
|
358
359
|
{ body: { name, scope } },
|
|
@@ -372,7 +373,7 @@ export class GenerativeService {
|
|
|
372
373
|
{ sessionId: { type: 'string', required: true } },
|
|
373
374
|
);
|
|
374
375
|
|
|
375
|
-
const result = await this.sdk
|
|
376
|
+
const result = await internalRequest(this.sdk,
|
|
376
377
|
`/ai/generative/sessions/${sessionId}`,
|
|
377
378
|
'DELETE',
|
|
378
379
|
);
|
|
@@ -419,7 +420,7 @@ export class GenerativeService {
|
|
|
419
420
|
},
|
|
420
421
|
};
|
|
421
422
|
|
|
422
|
-
const result = await this.sdk
|
|
423
|
+
const result = await internalRequest(this.sdk,
|
|
423
424
|
'/ai/generative/playbook',
|
|
424
425
|
'POST',
|
|
425
426
|
params,
|
|
@@ -468,7 +469,7 @@ export class GenerativeService {
|
|
|
468
469
|
|
|
469
470
|
// // Force HTTP transport when streaming is enabled since NATS doesn't support streaming responses
|
|
470
471
|
// const forceFetch = stream === true;
|
|
471
|
-
// const result = await this.sdk
|
|
472
|
+
// const result = await internalRequest(this.sdk,
|
|
472
473
|
// '/ai/generative/ollama',
|
|
473
474
|
// 'POST',
|
|
474
475
|
// params,
|
|
@@ -537,7 +538,7 @@ export class TextToSpeechService {
|
|
|
537
538
|
body: ttsData,
|
|
538
539
|
};
|
|
539
540
|
|
|
540
|
-
const result = await this.sdk
|
|
541
|
+
const result = await internalRequest(this.sdk, '/ai/tts', 'POST', params);
|
|
541
542
|
return result;
|
|
542
543
|
}
|
|
543
544
|
|
|
@@ -546,7 +547,7 @@ export class TextToSpeechService {
|
|
|
546
547
|
* @returns {Promise<Object>} { voices: Array, count: number, supportedEncodings: Array, supportedLanguages: Array }
|
|
547
548
|
*/
|
|
548
549
|
async list() {
|
|
549
|
-
const result = await this.sdk
|
|
550
|
+
const result = await internalRequest(this.sdk, '/ai/tts', 'GET');
|
|
550
551
|
return result;
|
|
551
552
|
}
|
|
552
553
|
}
|
|
@@ -638,7 +639,7 @@ export class SpeechToTextService {
|
|
|
638
639
|
},
|
|
639
640
|
};
|
|
640
641
|
|
|
641
|
-
const result = await this.sdk
|
|
642
|
+
const result = await internalRequest(this.sdk, '/ai/stt', 'POST', params);
|
|
642
643
|
return result;
|
|
643
644
|
}
|
|
644
645
|
|
|
@@ -665,7 +666,7 @@ export class SpeechToTextService {
|
|
|
665
666
|
const body = { storageId };
|
|
666
667
|
if (language !== undefined) body.language = language;
|
|
667
668
|
if (encoding !== undefined) body.encoding = encoding;
|
|
668
|
-
return await this.sdk
|
|
669
|
+
return await internalRequest(this.sdk, '/ai/stt/file', 'POST', { body });
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
/**
|
|
@@ -858,7 +859,7 @@ export class SpeechToTextService {
|
|
|
858
859
|
},
|
|
859
860
|
};
|
|
860
861
|
|
|
861
|
-
const session = await this.sdk
|
|
862
|
+
const session = await internalRequest(this.sdk,
|
|
862
863
|
'/ai/stt/stream',
|
|
863
864
|
'POST',
|
|
864
865
|
sessionParams,
|
|
@@ -908,7 +909,7 @@ export class SpeechToTextService {
|
|
|
908
909
|
query: { includeMessages: includeMessages.toString() },
|
|
909
910
|
};
|
|
910
911
|
|
|
911
|
-
const result = await this.sdk
|
|
912
|
+
const result = await internalRequest(this.sdk, `/ai/stt/${id}`, 'GET', params);
|
|
912
913
|
return result;
|
|
913
914
|
}
|
|
914
915
|
|
|
@@ -945,7 +946,7 @@ export class SpeechToTextService {
|
|
|
945
946
|
query: filters,
|
|
946
947
|
};
|
|
947
948
|
|
|
948
|
-
const result = await this.sdk
|
|
949
|
+
const result = await internalRequest(this.sdk, '/ai/stt', 'GET', params);
|
|
949
950
|
return result;
|
|
950
951
|
}
|
|
951
952
|
|
|
@@ -1039,7 +1040,7 @@ export class SpeechToTextService {
|
|
|
1039
1040
|
},
|
|
1040
1041
|
};
|
|
1041
1042
|
|
|
1042
|
-
const result = await this.sdk
|
|
1043
|
+
const result = await internalRequest(this.sdk,
|
|
1043
1044
|
`/ai/stt/stream/${sessionId}/messages`,
|
|
1044
1045
|
'POST',
|
|
1045
1046
|
params,
|
|
@@ -1069,7 +1070,7 @@ export class SpeechToTextService {
|
|
|
1069
1070
|
body: { status, error },
|
|
1070
1071
|
};
|
|
1071
1072
|
|
|
1072
|
-
const result = await this.sdk
|
|
1073
|
+
const result = await internalRequest(this.sdk,
|
|
1073
1074
|
`/ai/stt/stream/${sessionId}/complete`,
|
|
1074
1075
|
'PUT',
|
|
1075
1076
|
params,
|
|
@@ -1281,7 +1282,7 @@ export class ExtractService {
|
|
|
1281
1282
|
},
|
|
1282
1283
|
};
|
|
1283
1284
|
|
|
1284
|
-
const result = await this.sdk
|
|
1285
|
+
const result = await internalRequest(this.sdk, '/ai/extract', 'POST', requestParams);
|
|
1285
1286
|
return result;
|
|
1286
1287
|
}
|
|
1287
1288
|
}
|