@getsupervisor/agents-studio-sdk 1.41.2-patch.11 → 1.41.2-patch.13
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 +49 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1799,14 +1799,17 @@ function createToolsApi(cfg) {
|
|
|
1799
1799
|
}
|
|
1800
1800
|
|
|
1801
1801
|
// src/api/usage.ts
|
|
1802
|
+
var import_api_query_builder = require("@getsupervisor/api-query-builder");
|
|
1802
1803
|
function createUsageApi(cfg) {
|
|
1803
1804
|
const { base, doFetch } = createHttp(cfg);
|
|
1804
1805
|
const fetchUsageAgentsPage = async (options = {}) => {
|
|
1805
|
-
const { resource, from, to, ...listOptions } = options
|
|
1806
|
-
const query = serializeListOptions(
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
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
|
+
)
|
|
1810
1813
|
});
|
|
1811
1814
|
const res = await doFetch(`${base}/usage/agents`, {
|
|
1812
1815
|
method: "GET",
|
|
@@ -1817,13 +1820,51 @@ function createUsageApi(cfg) {
|
|
|
1817
1820
|
return {
|
|
1818
1821
|
async agents(options = {}) {
|
|
1819
1822
|
const normalizedOptions = {
|
|
1820
|
-
...options
|
|
1823
|
+
...options
|
|
1821
1824
|
};
|
|
1822
1825
|
const response = await fetchUsageAgentsPage(normalizedOptions);
|
|
1823
1826
|
return attachPaginator(response, fetchUsageAgentsPage, normalizedOptions);
|
|
1824
1827
|
}
|
|
1825
1828
|
};
|
|
1826
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
|
+
var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
1844
|
+
function toISOString(value) {
|
|
1845
|
+
const input = DATE_ONLY.test(value) ? `${value}T00:00:00` : value;
|
|
1846
|
+
const date = new Date(input);
|
|
1847
|
+
if (Number.isNaN(date.getTime())) {
|
|
1848
|
+
return value;
|
|
1849
|
+
}
|
|
1850
|
+
return date.toISOString();
|
|
1851
|
+
}
|
|
1852
|
+
function buildUsageFilter(resource, from, to) {
|
|
1853
|
+
let query;
|
|
1854
|
+
if (resource) {
|
|
1855
|
+
query = appendCondition(query, (qb) => qb.eq("resource", resource));
|
|
1856
|
+
}
|
|
1857
|
+
if (from) {
|
|
1858
|
+
query = appendCondition(
|
|
1859
|
+
query,
|
|
1860
|
+
(qb) => qb.mte("createdAt", toISOString(from))
|
|
1861
|
+
);
|
|
1862
|
+
}
|
|
1863
|
+
if (to) {
|
|
1864
|
+
query = appendCondition(query, (qb) => qb.lt("createdAt", toISOString(to)));
|
|
1865
|
+
}
|
|
1866
|
+
return query;
|
|
1867
|
+
}
|
|
1827
1868
|
|
|
1828
1869
|
// src/utils/catalog-voices.ts
|
|
1829
1870
|
var FALLBACK_LOCALE = "und";
|
|
@@ -1883,9 +1924,9 @@ function pickGender(value) {
|
|
|
1883
1924
|
}
|
|
1884
1925
|
|
|
1885
1926
|
// src/utils/catalog-filter.ts
|
|
1886
|
-
var
|
|
1927
|
+
var import_api_query_builder2 = require("@getsupervisor/api-query-builder");
|
|
1887
1928
|
function createCatalogTypeQuery(type) {
|
|
1888
|
-
return new
|
|
1929
|
+
return new import_api_query_builder2.Query((qb) => qb.eq("type", type));
|
|
1889
1930
|
}
|
|
1890
1931
|
function ensureCatalogTypeFilter(filter, type) {
|
|
1891
1932
|
const requiredQuery = createCatalogTypeQuery(type);
|