@getsupervisor/agents-studio-sdk 1.41.2-patch.10 → 1.41.2-patch.12
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/dist/index.cjs +77 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -49
- package/dist/index.d.ts +165 -49
- package/dist/index.js +75 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __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,
|
|
@@ -50,6 +51,7 @@ __export(index_exports, {
|
|
|
50
51
|
createClient: () => createClient,
|
|
51
52
|
createHttp: () => createHttp,
|
|
52
53
|
createToolsApi: () => createToolsApi,
|
|
54
|
+
createUsageApi: () => createUsageApi,
|
|
53
55
|
createVoicesApi: () => createVoicesApi,
|
|
54
56
|
createWebhooksApi: () => createWebhooksApi,
|
|
55
57
|
createWorkspacesApi: () => createWorkspacesApi,
|
|
@@ -1379,6 +1381,19 @@ function createApiKeysApi(cfg) {
|
|
|
1379
1381
|
};
|
|
1380
1382
|
}
|
|
1381
1383
|
|
|
1384
|
+
// src/api/billing.ts
|
|
1385
|
+
function createBillingApi(cfg) {
|
|
1386
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1387
|
+
return {
|
|
1388
|
+
async getBalance() {
|
|
1389
|
+
const res = await doFetch(`${base}/billing/balance`, {
|
|
1390
|
+
method: "GET"
|
|
1391
|
+
});
|
|
1392
|
+
return res.json();
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1382
1397
|
// src/api/calls.ts
|
|
1383
1398
|
function createCallsApi(cfg) {
|
|
1384
1399
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -1783,6 +1798,62 @@ function createToolsApi(cfg) {
|
|
|
1783
1798
|
};
|
|
1784
1799
|
}
|
|
1785
1800
|
|
|
1801
|
+
// src/api/usage.ts
|
|
1802
|
+
var import_api_query_builder = require("@getsupervisor/api-query-builder");
|
|
1803
|
+
function createUsageApi(cfg) {
|
|
1804
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1805
|
+
const fetchUsageAgentsPage = async (options = {}) => {
|
|
1806
|
+
const { resource, from, to, ...listOptions } = options;
|
|
1807
|
+
const query = serializeListOptions({
|
|
1808
|
+
...listOptions,
|
|
1809
|
+
filter: resolveFilter(
|
|
1810
|
+
buildUsageFilter(resource, from, to),
|
|
1811
|
+
listOptions.filter
|
|
1812
|
+
)
|
|
1813
|
+
});
|
|
1814
|
+
const res = await doFetch(`${base}/usage/agents`, {
|
|
1815
|
+
method: "GET",
|
|
1816
|
+
query
|
|
1817
|
+
});
|
|
1818
|
+
return res.json();
|
|
1819
|
+
};
|
|
1820
|
+
return {
|
|
1821
|
+
async agents(options = {}) {
|
|
1822
|
+
const normalizedOptions = {
|
|
1823
|
+
...options
|
|
1824
|
+
};
|
|
1825
|
+
const response = await fetchUsageAgentsPage(normalizedOptions);
|
|
1826
|
+
return attachPaginator(response, fetchUsageAgentsPage, normalizedOptions);
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
function resolveFilter(usageFilter, fallback) {
|
|
1831
|
+
if (usageFilter) {
|
|
1832
|
+
return usageFilter;
|
|
1833
|
+
}
|
|
1834
|
+
return fallback;
|
|
1835
|
+
}
|
|
1836
|
+
function appendCondition(query, factory) {
|
|
1837
|
+
if (query) {
|
|
1838
|
+
query.and(factory);
|
|
1839
|
+
return query;
|
|
1840
|
+
}
|
|
1841
|
+
return new import_api_query_builder.Query(factory);
|
|
1842
|
+
}
|
|
1843
|
+
function buildUsageFilter(resource, from, to) {
|
|
1844
|
+
let query;
|
|
1845
|
+
if (resource) {
|
|
1846
|
+
query = appendCondition(query, (qb) => qb.eq("resource", resource));
|
|
1847
|
+
}
|
|
1848
|
+
if (from) {
|
|
1849
|
+
query = appendCondition(query, (qb) => qb.mte("createdAt", from));
|
|
1850
|
+
}
|
|
1851
|
+
if (to) {
|
|
1852
|
+
query = appendCondition(query, (qb) => qb.lt("createdAt", to));
|
|
1853
|
+
}
|
|
1854
|
+
return query;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1786
1857
|
// src/utils/catalog-voices.ts
|
|
1787
1858
|
var FALLBACK_LOCALE = "und";
|
|
1788
1859
|
var FALLBACK_PROVIDER = "catalog";
|
|
@@ -1841,9 +1912,9 @@ function pickGender(value) {
|
|
|
1841
1912
|
}
|
|
1842
1913
|
|
|
1843
1914
|
// src/utils/catalog-filter.ts
|
|
1844
|
-
var
|
|
1915
|
+
var import_api_query_builder2 = require("@getsupervisor/api-query-builder");
|
|
1845
1916
|
function createCatalogTypeQuery(type) {
|
|
1846
|
-
return new
|
|
1917
|
+
return new import_api_query_builder2.Query((qb) => qb.eq("type", type));
|
|
1847
1918
|
}
|
|
1848
1919
|
function ensureCatalogTypeFilter(filter, type) {
|
|
1849
1920
|
const requiredQuery = createCatalogTypeQuery(type);
|
|
@@ -2290,7 +2361,9 @@ function createClient(initialCfg) {
|
|
|
2290
2361
|
campaigns: createCampaignsApi(runtimeCfg),
|
|
2291
2362
|
voices: voicesApi,
|
|
2292
2363
|
apiKeys: apiKeysApi,
|
|
2364
|
+
billing: createBillingApi(runtimeCfg),
|
|
2293
2365
|
calls: callsApi,
|
|
2366
|
+
usage: createUsageApi(runtimeCfg),
|
|
2294
2367
|
webhooks: webhooksApi
|
|
2295
2368
|
};
|
|
2296
2369
|
return {
|
|
@@ -2374,6 +2447,7 @@ function createClient(initialCfg) {
|
|
|
2374
2447
|
createAgentVersionsApi,
|
|
2375
2448
|
createAgentsApi,
|
|
2376
2449
|
createApiKeysApi,
|
|
2450
|
+
createBillingApi,
|
|
2377
2451
|
createCallsApi,
|
|
2378
2452
|
createCampaignsApi,
|
|
2379
2453
|
createCatalogTemplatesApi,
|
|
@@ -2381,6 +2455,7 @@ function createClient(initialCfg) {
|
|
|
2381
2455
|
createClient,
|
|
2382
2456
|
createHttp,
|
|
2383
2457
|
createToolsApi,
|
|
2458
|
+
createUsageApi,
|
|
2384
2459
|
createVoicesApi,
|
|
2385
2460
|
createWebhooksApi,
|
|
2386
2461
|
createWorkspacesApi,
|