@getsupervisor/agents-studio-sdk 1.41.2-patch.9 → 1.42.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.
- package/CHANGELOG.md +52 -0
- package/README.md +39 -0
- package/dist/index.cjs +205 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +327 -56
- package/dist/index.d.ts +327 -56
- package/dist/index.js +202 -7
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,58 @@
|
|
|
4
4
|
|
|
5
5
|
- SDK endpoints no longer include the `/v1` prefix. Backends now serve routes without that versioned segment, so existing consumers must drop `/v1` from any custom base URLs or proxy rewrites. The `/v1` paths are no longer supported, making this a hard breaking change that requires all clients to update their configuration before upgrading the SDK.
|
|
6
6
|
|
|
7
|
+
## [1.42.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.41.0...v1.42.0) (2026-06-03)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add agent call statistics including total calls, operational da… ([f2ceddb](https://github.com/julio-supervisor/agents-studio-be/commit/f2ceddbc914f0a69975e90bd42c22511115553be))
|
|
13
|
+
* add agent call statistics including total calls, operational days, and goal achievement percentage ([3841bb3](https://github.com/julio-supervisor/agents-studio-be/commit/3841bb3bd1deb83fbc247d73acf093dea70b5342))
|
|
14
|
+
* add catalog metadata structure to tools ([cd482f7](https://github.com/julio-supervisor/agents-studio-be/commit/cd482f756c9404d815df16bdc7fcf2abfcbc87fc))
|
|
15
|
+
* add CloneAgentRequest schema and cloning endpoint ([36d3ff9](https://github.com/julio-supervisor/agents-studio-be/commit/36d3ff955472df6b801ceaee99affa535020f4e5))
|
|
16
|
+
* add CloneAgentRequest schema and cloning endpoint ([5b97daf](https://github.com/julio-supervisor/agents-studio-be/commit/5b97daf5bde28c653cd7898fb6c0313370080849))
|
|
17
|
+
* add descriptionUsage and usageExample fields to tool connection schemas ([7f1cc63](https://github.com/julio-supervisor/agents-studio-be/commit/7f1cc6335c5a588275aeec91684cb49f42a31beb))
|
|
18
|
+
* add optional description field to agent DTOs and schemas ([e3e336e](https://github.com/julio-supervisor/agents-studio-be/commit/e3e336e0b6613b54b7df4f6d3f7a2693e025a5dc))
|
|
19
|
+
* add output variables support to agent blueprints ([093fa95](https://github.com/julio-supervisor/agents-studio-be/commit/093fa9533c459f54fe162ae082d57ce5555f8a37))
|
|
20
|
+
* add output variables support to agent blueprints ([7345f47](https://github.com/julio-supervisor/agents-studio-be/commit/7345f470ab6cebbd9ed2a4d9c0614c5f313b9e0f))
|
|
21
|
+
* add output variables support to agent blueprints and update related documentation ([19e67ea](https://github.com/julio-supervisor/agents-studio-be/commit/19e67eae361ea982188bb6cdc34d0bd16563ef03))
|
|
22
|
+
* add SIP trunks CRUD to public-api with direct Kamailio DB access ([a9e80dd](https://github.com/julio-supervisor/agents-studio-be/commit/a9e80dd49c3290d5ac1144b93172f276da56d256))
|
|
23
|
+
* add tool connections API endpoints and listing service ([6736347](https://github.com/julio-supervisor/agents-studio-be/commit/67363479fc929dcd93018e1e6a62e01787e25ea2))
|
|
24
|
+
* add visibility flag to tools and update related components ([e00e201](https://github.com/julio-supervisor/agents-studio-be/commit/e00e201888f856002bbbf79f529f33dd9dc6450a))
|
|
25
|
+
* **api:** enhance workspace resolution to support API key authentication ([2f151cd](https://github.com/julio-supervisor/agents-studio-be/commit/2f151cd223a74f4a7a2a68cf5e680393097e2869))
|
|
26
|
+
* Billing & Usage module ([9300bcc](https://github.com/julio-supervisor/agents-studio-be/commit/9300bccc302c4ae7f3aad05caef331f0d4866460))
|
|
27
|
+
* **calls:** add durationBucket and goalStatus parameters to calls API and SDK, update related documentation ([981ed9d](https://github.com/julio-supervisor/agents-studio-be/commit/981ed9d6a8335614e5a1acd4da808f01417bc28d))
|
|
28
|
+
* **calls:** add durationBucket, goalStatus, and query parameters to calls API and SDK documentation ([9423b7f](https://github.com/julio-supervisor/agents-studio-be/commit/9423b7f4b990887dd6593e97203b4e15f580dc27))
|
|
29
|
+
* **calls:** implement TypeORM repository and specifications for call management ([30c9b71](https://github.com/julio-supervisor/agents-studio-be/commit/30c9b71c56fbcea3688585e66b12229a8db62215))
|
|
30
|
+
* **calls:** implement TypeORM repository and specifications for call… ([47803ce](https://github.com/julio-supervisor/agents-studio-be/commit/47803cea9d3751b953a3d9f7147869bb94a32798))
|
|
31
|
+
* **campaigns:** export CSV de executions + persistencia de outcome por intento ([17366c6](https://github.com/julio-supervisor/agents-studio-be/commit/17366c6c7cabd751ede8ad8fdb57166ed1e4645c))
|
|
32
|
+
* **campaigns:** lifecycle completo con retries, pause/resume/cancel y paralelismo ([3954e48](https://github.com/julio-supervisor/agents-studio-be/commit/3954e483adc0890b04eb7e830af395e6fdb4086a))
|
|
33
|
+
* **campaigns:** outcome classification, lifecycle quiescence y filtros E2E ([0afe803](https://github.com/julio-supervisor/agents-studio-be/commit/0afe8033919c2420551ce9c4073f3ced3bd29024))
|
|
34
|
+
* enforce title as a required field in blueprint stages and related DTOs ([e90a84e](https://github.com/julio-supervisor/agents-studio-be/commit/e90a84eeb4c1c3f82e8027da30991673d2fbabac))
|
|
35
|
+
* enhance Tool and Connection Models with Connection Key ([8471499](https://github.com/julio-supervisor/agents-studio-be/commit/847149931138a5786e2c9f7314a346fbcf27e67e))
|
|
36
|
+
* enhance Tool and Connection Models with Connection Key ([6379fdf](https://github.com/julio-supervisor/agents-studio-be/commit/6379fdf34ffe67fc841db58d8778012d20696396))
|
|
37
|
+
* **errors:** enhance error handling and type safety for API errors in SDK ([7848c61](https://github.com/julio-supervisor/agents-studio-be/commit/7848c615c20951a66fdeb4b8d9c465d8cc542721))
|
|
38
|
+
* **errors:** enhance ErrorResponse structure with detailed descriptions and subcode ([044d022](https://github.com/julio-supervisor/agents-studio-be/commit/044d0227331c650fff7b4294344420a1302ae9cb))
|
|
39
|
+
* implement Retell tool execution signature service and update re… ([a783e91](https://github.com/julio-supervisor/agents-studio-be/commit/a783e9123104b8398841223bcdb1ecede5c8ded2))
|
|
40
|
+
* refactor workspace enabling API to use API key and update related documentation ([38505ab](https://github.com/julio-supervisor/agents-studio-be/commit/38505ab4bbb9ac3d22bf4c7335c51ed0fe3700e2))
|
|
41
|
+
* **sdk:** add billing and usage API modules ([97e7e44](https://github.com/julio-supervisor/agents-studio-be/commit/97e7e4455e00fd99420fa04f7e0a2dc6b591c938))
|
|
42
|
+
* SIP load balancer with Kamailio Dispatcher and autoscaling ([20a918c](https://github.com/julio-supervisor/agents-studio-be/commit/20a918cb2e3d6092cc5f30ec6a7a58043357838e))
|
|
43
|
+
* SIP trunks CRUD in public-api with direct Kamailio DB ([25af230](https://github.com/julio-supervisor/agents-studio-be/commit/25af230afea0e4c2326dd22d5df30930dc2897a9))
|
|
44
|
+
* update agent stages tools to support partial payloads and enhance functionality ([99346db](https://github.com/julio-supervisor/agents-studio-be/commit/99346db032b985ebed4fdf6ca17271f68d527b33))
|
|
45
|
+
* **usage:** add aggregations to usage agents meta with totalUsage and planLimit ([0f2e6c8](https://github.com/julio-supervisor/agents-studio-be/commit/0f2e6c8eed21cce74babad77e4450b1b9d8f1aad))
|
|
46
|
+
* **webhooks:** add method field to OpenAPI spec and implement SDKs ([2cd6908](https://github.com/julio-supervisor/agents-studio-be/commit/2cd6908175b9935ab1e960e1b72e6c9cc5fb23bc))
|
|
47
|
+
* **webhooks:** add webhook deliveries functionality ([c552636](https://github.com/julio-supervisor/agents-studio-be/commit/c5526369b9a6e7467f0ed7fdd4185e8c508bdd73))
|
|
48
|
+
* **workspaces:** add WorkspacesEnableTool and related command for enabling workspaces ([215b36b](https://github.com/julio-supervisor/agents-studio-be/commit/215b36bb44beb3d433564cdcf72a4571a5e0145b))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* add missing commas in various TypeScript files for consistency and syntax correctness ([66b912b](https://github.com/julio-supervisor/agents-studio-be/commit/66b912bb43aecdb368c08f357325ce8ea20af528))
|
|
54
|
+
* **sdk:** agregar eslint flat config y corregir lint del paquete ([5956d7e](https://github.com/julio-supervisor/agents-studio-be/commit/5956d7e1f2ae3371331136c6eb132f8318b3ef15))
|
|
55
|
+
* **sdk:** listExecutions debe propagar filter y sort ([f351896](https://github.com/julio-supervisor/agents-studio-be/commit/f351896e3e76aa36093a5875d5265bb186c38d13))
|
|
56
|
+
* **sdk:** update yarn.lock after pinning openapi-typescript to 6.7.6 ([c0ca89a](https://github.com/julio-supervisor/agents-studio-be/commit/c0ca89a9113805df9f9d779315405ddfeaca751f))
|
|
57
|
+
* serialize date filters as ISO 8601 with local timezone support ([c0c2b37](https://github.com/julio-supervisor/agents-studio-be/commit/c0c2b37062955c630906b35cd81de723007a5c6a))
|
|
58
|
+
|
|
7
59
|
## v1.41.0
|
|
8
60
|
|
|
9
61
|
## [1.41.0](https://github.com/julio-supervisor/agents-studio-be/compare/v1.40.0...v1.41.0) (2025-12-07)
|
package/README.md
CHANGED
|
@@ -397,6 +397,45 @@ npx tsx examples/custom-tool-connection.ts
|
|
|
397
397
|
|
|
398
398
|
El script envía la metadata de conexión (URL, método, headers) y, sobre todo, almacena un `configSchema` específico del workspace dentro de `tool_agent_connections.metadata`. Ese esquema describe los campos que el agente debe solicitar (en el ejemplo `agentId` y `customerName`) y coincide con la acción `triggerWorkflow` que expone el seed `custom.http.workflow`. Después de conectar la tool ejecuta `client.tools.execute('custom.http.workflow', { action: 'triggerWorkflow', args: { ... } })` respetando el schema definido en tu metadata.
|
|
399
399
|
|
|
400
|
+
## SIP Trunks
|
|
401
|
+
|
|
402
|
+
Namespace: `client.sip`
|
|
403
|
+
|
|
404
|
+
Gestiona trunks SIP para conectar agentes de voz a carriers PSTN (Twilio, ccc2.uno, etc.).
|
|
405
|
+
|
|
406
|
+
Operaciones disponibles:
|
|
407
|
+
|
|
408
|
+
- `sip.list()` — lista todos los SIP trunks del workspace.
|
|
409
|
+
- `sip.get(trunkId)` — obtiene un trunk por ID.
|
|
410
|
+
- `sip.create(payload)` — crea un trunk (devuelve `password` solo en la creación).
|
|
411
|
+
- `sip.update(trunkId, payload)` — actualiza un trunk (campos parciales).
|
|
412
|
+
- `sip.delete(trunkId)` — elimina un trunk y su subscriber asociado.
|
|
413
|
+
|
|
414
|
+
Ejemplo:
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
// crear un trunk SIP
|
|
418
|
+
const trunk = await client.sip.create({
|
|
419
|
+
name: 'Twilio Production',
|
|
420
|
+
carrierAddress: 'my-trunk.pstn.twilio.com',
|
|
421
|
+
// opcionales: carrierPort (default 5060), carrierTransport (default 'udp'), phoneNumbers
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
console.log(trunk.username); // auto-generado para SIP digest auth
|
|
425
|
+
console.log(trunk.password); // solo visible en la creación
|
|
426
|
+
|
|
427
|
+
// listar trunks del workspace
|
|
428
|
+
const trunks = await client.sip.list();
|
|
429
|
+
|
|
430
|
+
// actualizar
|
|
431
|
+
await client.sip.update(trunk.id, { name: 'Twilio Staging' });
|
|
432
|
+
|
|
433
|
+
// eliminar
|
|
434
|
+
await client.sip.delete(trunk.id);
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Scopes requeridos: `sip:read` para lectura, `sip:write` para escritura.
|
|
438
|
+
|
|
400
439
|
## Configuración
|
|
401
440
|
|
|
402
441
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -43,13 +43,16 @@ __export(index_exports, {
|
|
|
43
43
|
createAgentVersionsApi: () => createAgentVersionsApi,
|
|
44
44
|
createAgentsApi: () => createAgentsApi,
|
|
45
45
|
createApiKeysApi: () => createApiKeysApi,
|
|
46
|
+
createBillingApi: () => createBillingApi,
|
|
46
47
|
createCallsApi: () => createCallsApi,
|
|
47
48
|
createCampaignsApi: () => createCampaignsApi,
|
|
48
49
|
createCatalogTemplatesApi: () => createCatalogTemplatesApi,
|
|
49
50
|
createCatalogsApi: () => createCatalogsApi,
|
|
50
51
|
createClient: () => createClient,
|
|
51
52
|
createHttp: () => createHttp,
|
|
53
|
+
createSipTrunksApi: () => createSipTrunksApi,
|
|
52
54
|
createToolsApi: () => createToolsApi,
|
|
55
|
+
createUsageApi: () => createUsageApi,
|
|
53
56
|
createVoicesApi: () => createVoicesApi,
|
|
54
57
|
createWebhooksApi: () => createWebhooksApi,
|
|
55
58
|
createWorkspacesApi: () => createWorkspacesApi,
|
|
@@ -239,7 +242,8 @@ function createHttp(cfg) {
|
|
|
239
242
|
}
|
|
240
243
|
return res;
|
|
241
244
|
} catch (e) {
|
|
242
|
-
if (e
|
|
245
|
+
if (e?.name === "AbortError")
|
|
246
|
+
throw new TimeoutError(timeout, targetUrl);
|
|
243
247
|
if (e instanceof HttpError) throw e;
|
|
244
248
|
throw new NetworkError(e, targetUrl);
|
|
245
249
|
}
|
|
@@ -1379,6 +1383,19 @@ function createApiKeysApi(cfg) {
|
|
|
1379
1383
|
};
|
|
1380
1384
|
}
|
|
1381
1385
|
|
|
1386
|
+
// src/api/billing.ts
|
|
1387
|
+
function createBillingApi(cfg) {
|
|
1388
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1389
|
+
return {
|
|
1390
|
+
async getBalance() {
|
|
1391
|
+
const res = await doFetch(`${base}/billing/balance`, {
|
|
1392
|
+
method: "GET"
|
|
1393
|
+
});
|
|
1394
|
+
return res.json();
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1382
1399
|
// src/api/calls.ts
|
|
1383
1400
|
function createCallsApi(cfg) {
|
|
1384
1401
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -1457,10 +1474,7 @@ function createCampaignsApi(cfg) {
|
|
|
1457
1474
|
return res.json();
|
|
1458
1475
|
};
|
|
1459
1476
|
const fetchExecutionsPage = async (campaignId, options = {}) => {
|
|
1460
|
-
const query = serializeListOptions({
|
|
1461
|
-
page: options.page,
|
|
1462
|
-
limit: options.limit
|
|
1463
|
-
});
|
|
1477
|
+
const query = serializeListOptions(options ?? {});
|
|
1464
1478
|
const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
|
|
1465
1479
|
method: "GET",
|
|
1466
1480
|
query
|
|
@@ -1514,6 +1528,51 @@ function createCampaignsApi(cfg) {
|
|
|
1514
1528
|
const response = await fetchExecutionsPage(campaignId, normalizedOptions);
|
|
1515
1529
|
const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
|
|
1516
1530
|
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
1531
|
+
},
|
|
1532
|
+
/**
|
|
1533
|
+
* Pausa una campaña en curso. Los reintentos ya programados se
|
|
1534
|
+
* reagendan al ejecutarse (sin consumir intentos) hasta `resume()`.
|
|
1535
|
+
*/
|
|
1536
|
+
async pause(campaignId) {
|
|
1537
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/pause`, {
|
|
1538
|
+
method: "POST"
|
|
1539
|
+
});
|
|
1540
|
+
return res.json();
|
|
1541
|
+
},
|
|
1542
|
+
/**
|
|
1543
|
+
* Reanuda una campaña pausada. Re-encola los reintentos pendientes
|
|
1544
|
+
* según su `nextRetryAt`.
|
|
1545
|
+
*/
|
|
1546
|
+
async resume(campaignId) {
|
|
1547
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/resume`, {
|
|
1548
|
+
method: "POST"
|
|
1549
|
+
});
|
|
1550
|
+
return res.json();
|
|
1551
|
+
},
|
|
1552
|
+
/**
|
|
1553
|
+
* Cancela definitivamente una campaña no terminal. Los reintentos
|
|
1554
|
+
* pendientes se descartan — operación destructiva.
|
|
1555
|
+
*/
|
|
1556
|
+
async cancel(campaignId) {
|
|
1557
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/cancel`, {
|
|
1558
|
+
method: "POST"
|
|
1559
|
+
});
|
|
1560
|
+
return res.json();
|
|
1561
|
+
},
|
|
1562
|
+
/**
|
|
1563
|
+
* Descarga el CSV con todas las ejecuciones de la campaña. Devuelve un
|
|
1564
|
+
* `Blob` con `text/csv; charset=utf-8` (BOM UTF-8 incluido). Para
|
|
1565
|
+
* campañas > 20,000 filas la API responde 413.
|
|
1566
|
+
*/
|
|
1567
|
+
async exportExecutions(campaignId) {
|
|
1568
|
+
const res = await doFetch(
|
|
1569
|
+
`${base}/campaigns/${campaignId}/executions/export`,
|
|
1570
|
+
{
|
|
1571
|
+
method: "GET",
|
|
1572
|
+
headers: { Accept: "text/csv" }
|
|
1573
|
+
}
|
|
1574
|
+
);
|
|
1575
|
+
return res.blob();
|
|
1517
1576
|
}
|
|
1518
1577
|
};
|
|
1519
1578
|
}
|
|
@@ -1594,6 +1653,42 @@ function createCatalogsApi(cfg) {
|
|
|
1594
1653
|
};
|
|
1595
1654
|
}
|
|
1596
1655
|
|
|
1656
|
+
// src/api/sip-trunks.ts
|
|
1657
|
+
function createSipTrunksApi(cfg) {
|
|
1658
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1659
|
+
return {
|
|
1660
|
+
async list() {
|
|
1661
|
+
const res = await doFetch(`${base}/sip/trunks`, { method: "GET" });
|
|
1662
|
+
return res.json();
|
|
1663
|
+
},
|
|
1664
|
+
async get(trunkId) {
|
|
1665
|
+
const res = await doFetch(`${base}/sip/trunks/${trunkId}`, {
|
|
1666
|
+
method: "GET"
|
|
1667
|
+
});
|
|
1668
|
+
return res.json();
|
|
1669
|
+
},
|
|
1670
|
+
async create(body) {
|
|
1671
|
+
const res = await doFetch(`${base}/sip/trunks`, {
|
|
1672
|
+
method: "POST",
|
|
1673
|
+
headers: { "Content-Type": "application/json" },
|
|
1674
|
+
body: JSON.stringify(body)
|
|
1675
|
+
});
|
|
1676
|
+
return res.json();
|
|
1677
|
+
},
|
|
1678
|
+
async update(trunkId, body) {
|
|
1679
|
+
const res = await doFetch(`${base}/sip/trunks/${trunkId}`, {
|
|
1680
|
+
method: "PATCH",
|
|
1681
|
+
headers: { "Content-Type": "application/json" },
|
|
1682
|
+
body: JSON.stringify(body)
|
|
1683
|
+
});
|
|
1684
|
+
return res.json();
|
|
1685
|
+
},
|
|
1686
|
+
async delete(trunkId) {
|
|
1687
|
+
await doFetch(`${base}/sip/trunks/${trunkId}`, { method: "DELETE" });
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1597
1692
|
// src/api/tools.ts
|
|
1598
1693
|
var IDEMPOTENCY_HEADER = "Idempotency-Key";
|
|
1599
1694
|
var generateIdempotencyKey = (explicit) => {
|
|
@@ -1783,6 +1878,74 @@ function createToolsApi(cfg) {
|
|
|
1783
1878
|
};
|
|
1784
1879
|
}
|
|
1785
1880
|
|
|
1881
|
+
// src/api/usage.ts
|
|
1882
|
+
var import_api_query_builder = require("@getsupervisor/api-query-builder");
|
|
1883
|
+
function createUsageApi(cfg) {
|
|
1884
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1885
|
+
const fetchUsageAgentsPage = async (options = {}) => {
|
|
1886
|
+
const { resource, from, to, ...listOptions } = options;
|
|
1887
|
+
const query = serializeListOptions({
|
|
1888
|
+
...listOptions,
|
|
1889
|
+
filter: resolveFilter(
|
|
1890
|
+
buildUsageFilter(resource, from, to),
|
|
1891
|
+
listOptions.filter
|
|
1892
|
+
)
|
|
1893
|
+
});
|
|
1894
|
+
const res = await doFetch(`${base}/usage/agents`, {
|
|
1895
|
+
method: "GET",
|
|
1896
|
+
query
|
|
1897
|
+
});
|
|
1898
|
+
return res.json();
|
|
1899
|
+
};
|
|
1900
|
+
return {
|
|
1901
|
+
async agents(options = {}) {
|
|
1902
|
+
const normalizedOptions = {
|
|
1903
|
+
...options
|
|
1904
|
+
};
|
|
1905
|
+
const response = await fetchUsageAgentsPage(normalizedOptions);
|
|
1906
|
+
return attachPaginator(response, fetchUsageAgentsPage, normalizedOptions);
|
|
1907
|
+
}
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
function resolveFilter(usageFilter, fallback) {
|
|
1911
|
+
if (usageFilter) {
|
|
1912
|
+
return usageFilter;
|
|
1913
|
+
}
|
|
1914
|
+
return fallback;
|
|
1915
|
+
}
|
|
1916
|
+
function appendCondition(query, factory) {
|
|
1917
|
+
if (query) {
|
|
1918
|
+
query.and(factory);
|
|
1919
|
+
return query;
|
|
1920
|
+
}
|
|
1921
|
+
return new import_api_query_builder.Query(factory);
|
|
1922
|
+
}
|
|
1923
|
+
var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
1924
|
+
function toISOString(value) {
|
|
1925
|
+
const input = DATE_ONLY.test(value) ? `${value}T00:00:00` : value;
|
|
1926
|
+
const date = new Date(input);
|
|
1927
|
+
if (Number.isNaN(date.getTime())) {
|
|
1928
|
+
return value;
|
|
1929
|
+
}
|
|
1930
|
+
return date.toISOString();
|
|
1931
|
+
}
|
|
1932
|
+
function buildUsageFilter(resource, from, to) {
|
|
1933
|
+
let query;
|
|
1934
|
+
if (resource) {
|
|
1935
|
+
query = appendCondition(query, (qb) => qb.eq("resource", resource));
|
|
1936
|
+
}
|
|
1937
|
+
if (from) {
|
|
1938
|
+
query = appendCondition(
|
|
1939
|
+
query,
|
|
1940
|
+
(qb) => qb.mte("createdAt", toISOString(from))
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
if (to) {
|
|
1944
|
+
query = appendCondition(query, (qb) => qb.lt("createdAt", toISOString(to)));
|
|
1945
|
+
}
|
|
1946
|
+
return query;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1786
1949
|
// src/utils/catalog-voices.ts
|
|
1787
1950
|
var FALLBACK_LOCALE = "und";
|
|
1788
1951
|
var FALLBACK_PROVIDER = "catalog";
|
|
@@ -1841,9 +2004,9 @@ function pickGender(value) {
|
|
|
1841
2004
|
}
|
|
1842
2005
|
|
|
1843
2006
|
// src/utils/catalog-filter.ts
|
|
1844
|
-
var
|
|
2007
|
+
var import_api_query_builder2 = require("@getsupervisor/api-query-builder");
|
|
1845
2008
|
function createCatalogTypeQuery(type) {
|
|
1846
|
-
return new
|
|
2009
|
+
return new import_api_query_builder2.Query((qb) => qb.eq("type", type));
|
|
1847
2010
|
}
|
|
1848
2011
|
function ensureCatalogTypeFilter(filter, type) {
|
|
1849
2012
|
const requiredQuery = createCatalogTypeQuery(type);
|
|
@@ -2079,6 +2242,35 @@ function createWebhooksApi(cfg) {
|
|
|
2079
2242
|
`${base}/webhooks/${webhookId}/subscriptions/${subscriptionId}`,
|
|
2080
2243
|
{ method: "DELETE" }
|
|
2081
2244
|
);
|
|
2245
|
+
},
|
|
2246
|
+
// Deliveries
|
|
2247
|
+
async listDeliveries(webhookId, options = {}) {
|
|
2248
|
+
const fetchPage = async (opts) => {
|
|
2249
|
+
const query = serializeListOptions({
|
|
2250
|
+
page: opts.page,
|
|
2251
|
+
limit: opts.limit,
|
|
2252
|
+
sort: opts.sort,
|
|
2253
|
+
fields: opts.fields,
|
|
2254
|
+
include: opts.include,
|
|
2255
|
+
search: opts.search,
|
|
2256
|
+
filter: opts.filter
|
|
2257
|
+
});
|
|
2258
|
+
const res = await doFetch(`${base}/webhooks/${webhookId}/deliveries`, {
|
|
2259
|
+
method: "GET",
|
|
2260
|
+
query
|
|
2261
|
+
});
|
|
2262
|
+
return res.json();
|
|
2263
|
+
};
|
|
2264
|
+
const normalized = { ...options ?? {} };
|
|
2265
|
+
const response = await fetchPage(normalized);
|
|
2266
|
+
return attachPaginator(response, fetchPage, normalized);
|
|
2267
|
+
},
|
|
2268
|
+
async getDelivery(webhookId, deliveryId) {
|
|
2269
|
+
const res = await doFetch(
|
|
2270
|
+
`${base}/webhooks/${webhookId}/deliveries/${deliveryId}`,
|
|
2271
|
+
{ method: "GET" }
|
|
2272
|
+
);
|
|
2273
|
+
return res.json();
|
|
2082
2274
|
}
|
|
2083
2275
|
};
|
|
2084
2276
|
}
|
|
@@ -2261,7 +2453,10 @@ function createClient(initialCfg) {
|
|
|
2261
2453
|
campaigns: createCampaignsApi(runtimeCfg),
|
|
2262
2454
|
voices: voicesApi,
|
|
2263
2455
|
apiKeys: apiKeysApi,
|
|
2456
|
+
billing: createBillingApi(runtimeCfg),
|
|
2264
2457
|
calls: callsApi,
|
|
2458
|
+
usage: createUsageApi(runtimeCfg),
|
|
2459
|
+
sip: createSipTrunksApi(runtimeCfg),
|
|
2265
2460
|
webhooks: webhooksApi
|
|
2266
2461
|
};
|
|
2267
2462
|
return {
|
|
@@ -2345,13 +2540,16 @@ function createClient(initialCfg) {
|
|
|
2345
2540
|
createAgentVersionsApi,
|
|
2346
2541
|
createAgentsApi,
|
|
2347
2542
|
createApiKeysApi,
|
|
2543
|
+
createBillingApi,
|
|
2348
2544
|
createCallsApi,
|
|
2349
2545
|
createCampaignsApi,
|
|
2350
2546
|
createCatalogTemplatesApi,
|
|
2351
2547
|
createCatalogsApi,
|
|
2352
2548
|
createClient,
|
|
2353
2549
|
createHttp,
|
|
2550
|
+
createSipTrunksApi,
|
|
2354
2551
|
createToolsApi,
|
|
2552
|
+
createUsageApi,
|
|
2355
2553
|
createVoicesApi,
|
|
2356
2554
|
createWebhooksApi,
|
|
2357
2555
|
createWorkspacesApi,
|