@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.js
CHANGED
|
@@ -1737,14 +1737,17 @@ function createToolsApi(cfg) {
|
|
|
1737
1737
|
}
|
|
1738
1738
|
|
|
1739
1739
|
// src/api/usage.ts
|
|
1740
|
+
import { Query } from "@getsupervisor/api-query-builder";
|
|
1740
1741
|
function createUsageApi(cfg) {
|
|
1741
1742
|
const { base, doFetch } = createHttp(cfg);
|
|
1742
1743
|
const fetchUsageAgentsPage = async (options = {}) => {
|
|
1743
|
-
const { resource, from, to, ...listOptions } = options
|
|
1744
|
-
const query = serializeListOptions(
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1744
|
+
const { resource, from, to, ...listOptions } = options;
|
|
1745
|
+
const query = serializeListOptions({
|
|
1746
|
+
...listOptions,
|
|
1747
|
+
filter: resolveFilter(
|
|
1748
|
+
buildUsageFilter(resource, from, to),
|
|
1749
|
+
listOptions.filter
|
|
1750
|
+
)
|
|
1748
1751
|
});
|
|
1749
1752
|
const res = await doFetch(`${base}/usage/agents`, {
|
|
1750
1753
|
method: "GET",
|
|
@@ -1755,13 +1758,51 @@ function createUsageApi(cfg) {
|
|
|
1755
1758
|
return {
|
|
1756
1759
|
async agents(options = {}) {
|
|
1757
1760
|
const normalizedOptions = {
|
|
1758
|
-
...options
|
|
1761
|
+
...options
|
|
1759
1762
|
};
|
|
1760
1763
|
const response = await fetchUsageAgentsPage(normalizedOptions);
|
|
1761
1764
|
return attachPaginator(response, fetchUsageAgentsPage, normalizedOptions);
|
|
1762
1765
|
}
|
|
1763
1766
|
};
|
|
1764
1767
|
}
|
|
1768
|
+
function resolveFilter(usageFilter, fallback) {
|
|
1769
|
+
if (usageFilter) {
|
|
1770
|
+
return usageFilter;
|
|
1771
|
+
}
|
|
1772
|
+
return fallback;
|
|
1773
|
+
}
|
|
1774
|
+
function appendCondition(query, factory) {
|
|
1775
|
+
if (query) {
|
|
1776
|
+
query.and(factory);
|
|
1777
|
+
return query;
|
|
1778
|
+
}
|
|
1779
|
+
return new Query(factory);
|
|
1780
|
+
}
|
|
1781
|
+
var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
1782
|
+
function toISOString(value) {
|
|
1783
|
+
const input = DATE_ONLY.test(value) ? `${value}T00:00:00` : value;
|
|
1784
|
+
const date = new Date(input);
|
|
1785
|
+
if (Number.isNaN(date.getTime())) {
|
|
1786
|
+
return value;
|
|
1787
|
+
}
|
|
1788
|
+
return date.toISOString();
|
|
1789
|
+
}
|
|
1790
|
+
function buildUsageFilter(resource, from, to) {
|
|
1791
|
+
let query;
|
|
1792
|
+
if (resource) {
|
|
1793
|
+
query = appendCondition(query, (qb) => qb.eq("resource", resource));
|
|
1794
|
+
}
|
|
1795
|
+
if (from) {
|
|
1796
|
+
query = appendCondition(
|
|
1797
|
+
query,
|
|
1798
|
+
(qb) => qb.mte("createdAt", toISOString(from))
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
if (to) {
|
|
1802
|
+
query = appendCondition(query, (qb) => qb.lt("createdAt", toISOString(to)));
|
|
1803
|
+
}
|
|
1804
|
+
return query;
|
|
1805
|
+
}
|
|
1765
1806
|
|
|
1766
1807
|
// src/utils/catalog-voices.ts
|
|
1767
1808
|
var FALLBACK_LOCALE = "und";
|
|
@@ -1821,9 +1862,9 @@ function pickGender(value) {
|
|
|
1821
1862
|
}
|
|
1822
1863
|
|
|
1823
1864
|
// src/utils/catalog-filter.ts
|
|
1824
|
-
import { Query } from "@getsupervisor/api-query-builder";
|
|
1865
|
+
import { Query as Query2 } from "@getsupervisor/api-query-builder";
|
|
1825
1866
|
function createCatalogTypeQuery(type) {
|
|
1826
|
-
return new
|
|
1867
|
+
return new Query2((qb) => qb.eq("type", type));
|
|
1827
1868
|
}
|
|
1828
1869
|
function ensureCatalogTypeFilter(filter, type) {
|
|
1829
1870
|
const requiredQuery = createCatalogTypeQuery(type);
|