@getsupervisor/agents-studio-sdk 1.41.2-patch.11 → 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 +37 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -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,39 @@ 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
|
+
function buildUsageFilter(resource, from, to) {
|
|
1782
|
+
let query;
|
|
1783
|
+
if (resource) {
|
|
1784
|
+
query = appendCondition(query, (qb) => qb.eq("resource", resource));
|
|
1785
|
+
}
|
|
1786
|
+
if (from) {
|
|
1787
|
+
query = appendCondition(query, (qb) => qb.mte("createdAt", from));
|
|
1788
|
+
}
|
|
1789
|
+
if (to) {
|
|
1790
|
+
query = appendCondition(query, (qb) => qb.lt("createdAt", to));
|
|
1791
|
+
}
|
|
1792
|
+
return query;
|
|
1793
|
+
}
|
|
1765
1794
|
|
|
1766
1795
|
// src/utils/catalog-voices.ts
|
|
1767
1796
|
var FALLBACK_LOCALE = "und";
|
|
@@ -1821,9 +1850,9 @@ function pickGender(value) {
|
|
|
1821
1850
|
}
|
|
1822
1851
|
|
|
1823
1852
|
// src/utils/catalog-filter.ts
|
|
1824
|
-
import { Query } from "@getsupervisor/api-query-builder";
|
|
1853
|
+
import { Query as Query2 } from "@getsupervisor/api-query-builder";
|
|
1825
1854
|
function createCatalogTypeQuery(type) {
|
|
1826
|
-
return new
|
|
1855
|
+
return new Query2((qb) => qb.eq("type", type));
|
|
1827
1856
|
}
|
|
1828
1857
|
function ensureCatalogTypeFilter(filter, type) {
|
|
1829
1858
|
const requiredQuery = createCatalogTypeQuery(type);
|