@oxy-hq/sdk 2.12.0 → 2.16.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/README.md +67 -0
- package/dist/{function-context-D8eyZuw_.d.cts → function-context-BNpL5bFb.d.cts} +223 -20
- package/dist/function-context-BNpL5bFb.d.cts.map +1 -0
- package/dist/{function-context-D8eyZuw_.d.mts → function-context-BNpL5bFb.d.mts} +223 -20
- package/dist/function-context-BNpL5bFb.d.mts.map +1 -0
- package/dist/index.cjs +80 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +164 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +78 -16
- package/dist/index.mjs.map +1 -1
- package/dist/ops.d.cts +1 -1
- package/dist/ops.d.mts +1 -1
- package/dist/{react-DW7Z96sD.d.mts → react-CljeXJuw.d.cts} +142 -8
- package/dist/react-CljeXJuw.d.cts.map +1 -0
- package/dist/{react-DW7Z96sD.d.cts → react-CljeXJuw.d.mts} +142 -8
- package/dist/react-CljeXJuw.d.mts.map +1 -0
- package/dist/{react-DcT-mUPj.cjs → react-Dvkv2deI.cjs} +110 -59
- package/dist/react-Dvkv2deI.cjs.map +1 -0
- package/dist/{react-BXGyzgz0.mjs → react-OW1t_J0M.mjs} +103 -26
- package/dist/react-OW1t_J0M.mjs.map +1 -0
- package/dist/rolldown-runtime-KC0qvQup.cjs +34 -0
- package/dist/shell.cjs +38 -3
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +26 -3
- package/dist/shell.d.cts.map +1 -1
- package/dist/shell.d.mts +26 -3
- package/dist/shell.d.mts.map +1 -1
- package/dist/shell.mjs +34 -2
- package/dist/shell.mjs.map +1 -1
- package/dist/testing.cjs +4431 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +656 -0
- package/dist/testing.d.cts.map +1 -0
- package/dist/testing.d.mts +656 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +4395 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +22 -9
- package/dist/function-context-D8eyZuw_.d.cts.map +0 -1
- package/dist/function-context-D8eyZuw_.d.mts.map +0 -1
- package/dist/react-BXGyzgz0.mjs.map +0 -1
- package/dist/react-DW7Z96sD.d.cts.map +0 -1
- package/dist/react-DW7Z96sD.d.mts.map +0 -1
- package/dist/react-DcT-mUPj.cjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @oxy/sdk - TypeScript SDK for Oxy data platform
|
|
2
|
-
import { _ as
|
|
2
|
+
import { _ as asReportableError, a as useFunction, b as setOxyAppLogger, c as useQuery, d as useTrackEvent, f as _resetCustomAppManifestCacheForTest, g as apiErrorFromResponse, h as OxyApiError, i as useAgentRun, l as useResolvedManifest, m as readInjectedAppConfig, n as OxyAppProvider, o as useOxyApp, p as loadCustomAppManifest, r as OxyChat, s as useProcedureRun, t as OxyAnswer, u as useSemanticQuery, v as interpretCustomAppError, y as getOxyAppLogger } from "./react-OW1t_J0M.mjs";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/anomalies.ts
|
|
@@ -316,7 +316,7 @@ function useMetricTreeEndpoint(key, run, enabled) {
|
|
|
316
316
|
const [data, setData] = React.useState(null);
|
|
317
317
|
const [loading, setLoading] = React.useState(enabled && key !== null);
|
|
318
318
|
const [error, setError] = React.useState(null);
|
|
319
|
-
const [
|
|
319
|
+
const [nonce, setNonce] = React.useState(0);
|
|
320
320
|
const runRef = React.useRef(run);
|
|
321
321
|
runRef.current = run;
|
|
322
322
|
React.useEffect(() => {
|
|
@@ -334,15 +334,18 @@ function useMetricTreeEndpoint(key, run, enabled) {
|
|
|
334
334
|
setLoading(false);
|
|
335
335
|
}).catch((err) => {
|
|
336
336
|
if (cancelled) return;
|
|
337
|
-
|
|
338
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
337
|
+
setError(asReportableError(err));
|
|
339
338
|
setLoading(false);
|
|
340
339
|
});
|
|
341
340
|
return () => {
|
|
342
341
|
cancelled = true;
|
|
343
342
|
ctrl.abort();
|
|
344
343
|
};
|
|
345
|
-
}, [
|
|
344
|
+
}, [
|
|
345
|
+
key,
|
|
346
|
+
enabled,
|
|
347
|
+
nonce
|
|
348
|
+
]);
|
|
346
349
|
return {
|
|
347
350
|
data,
|
|
348
351
|
loading,
|
|
@@ -561,7 +564,7 @@ function useWorldModelGraph(opts = {}) {
|
|
|
561
564
|
const [data, setData] = React.useState(null);
|
|
562
565
|
const [loading, setLoading] = React.useState(enabled && !!projectId);
|
|
563
566
|
const [error, setError] = React.useState(null);
|
|
564
|
-
const [
|
|
567
|
+
const [nonce, setNonce] = React.useState(0);
|
|
565
568
|
React.useEffect(() => {
|
|
566
569
|
if (!enabled || !projectId) {
|
|
567
570
|
setLoading(false);
|
|
@@ -583,8 +586,7 @@ function useWorldModelGraph(opts = {}) {
|
|
|
583
586
|
setLoading(false);
|
|
584
587
|
}).catch((err) => {
|
|
585
588
|
if (cancelled) return;
|
|
586
|
-
|
|
587
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
589
|
+
setError(asReportableError(err));
|
|
588
590
|
setLoading(false);
|
|
589
591
|
});
|
|
590
592
|
return () => {
|
|
@@ -594,7 +596,8 @@ function useWorldModelGraph(opts = {}) {
|
|
|
594
596
|
}, [
|
|
595
597
|
enabled,
|
|
596
598
|
projectId,
|
|
597
|
-
fetcher
|
|
599
|
+
fetcher,
|
|
600
|
+
nonce
|
|
598
601
|
]);
|
|
599
602
|
return {
|
|
600
603
|
data,
|
|
@@ -615,7 +618,7 @@ function useWorldModelInstances(entityId, opts = {}) {
|
|
|
615
618
|
const [data, setData] = React.useState(null);
|
|
616
619
|
const [loading, setLoading] = React.useState(enabled && !!projectId && !!entityId);
|
|
617
620
|
const [error, setError] = React.useState(null);
|
|
618
|
-
const [
|
|
621
|
+
const [nonce, setNonce] = React.useState(0);
|
|
619
622
|
React.useEffect(() => {
|
|
620
623
|
if (!enabled || !projectId || !entityId) {
|
|
621
624
|
setLoading(false);
|
|
@@ -644,8 +647,7 @@ function useWorldModelInstances(entityId, opts = {}) {
|
|
|
644
647
|
setLoading(false);
|
|
645
648
|
}).catch((err) => {
|
|
646
649
|
if (cancelled) return;
|
|
647
|
-
|
|
648
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
650
|
+
setError(asReportableError(err));
|
|
649
651
|
setLoading(false);
|
|
650
652
|
});
|
|
651
653
|
return () => {
|
|
@@ -660,7 +662,8 @@ function useWorldModelInstances(entityId, opts = {}) {
|
|
|
660
662
|
limit,
|
|
661
663
|
fetcher,
|
|
662
664
|
scope,
|
|
663
|
-
appId
|
|
665
|
+
appId,
|
|
666
|
+
nonce
|
|
664
667
|
]);
|
|
665
668
|
return {
|
|
666
669
|
data,
|
|
@@ -738,8 +741,7 @@ function useMeasureBreakdown(entityId, keyValue, measure) {
|
|
|
738
741
|
if (!cancelled) setLoading(false);
|
|
739
742
|
}).catch((err) => {
|
|
740
743
|
if (cancelled) return;
|
|
741
|
-
|
|
742
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
744
|
+
setError(asReportableError(err));
|
|
743
745
|
setLoading(false);
|
|
744
746
|
});
|
|
745
747
|
return () => {
|
|
@@ -1085,5 +1087,65 @@ var MetricTreeClient = class {
|
|
|
1085
1087
|
};
|
|
1086
1088
|
|
|
1087
1089
|
//#endregion
|
|
1088
|
-
|
|
1090
|
+
//#region src/peerCohort.ts
|
|
1091
|
+
/**
|
|
1092
|
+
* Client for the `/semantic/cohort` endpoint. Surfaces airlayer's peer-cohort
|
|
1093
|
+
* benchmarking — comparing an entity's subjects against their declared peers
|
|
1094
|
+
* on a measure, with exclusions explained rather than silently dropped.
|
|
1095
|
+
*
|
|
1096
|
+
* Construction is internal to {@link OxyClient} — call `client.peerCohort`
|
|
1097
|
+
* to access an instance rather than building one yourself.
|
|
1098
|
+
*
|
|
1099
|
+
* @example
|
|
1100
|
+
* ```typescript
|
|
1101
|
+
* const client = await OxyClient.create({ projectId: "...", apiKey: "..." });
|
|
1102
|
+
* const result = await client.peerCohort.resolve({
|
|
1103
|
+
* entity: "restaurant_id",
|
|
1104
|
+
* measure: "orders.net_revenue",
|
|
1105
|
+
* time_dimension: "orders.order_date",
|
|
1106
|
+
* period: ["2025-09-01", "2025-09-30"],
|
|
1107
|
+
* });
|
|
1108
|
+
* for (const excluded of result.excluded) {
|
|
1109
|
+
* console.warn(excluded.key, excluded.reason);
|
|
1110
|
+
* }
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
var PeerCohortClient = class {
|
|
1114
|
+
constructor(config, request) {
|
|
1115
|
+
this.config = config;
|
|
1116
|
+
this.request = request;
|
|
1117
|
+
}
|
|
1118
|
+
path(suffix) {
|
|
1119
|
+
return `/${this.config.projectId}${suffix}`;
|
|
1120
|
+
}
|
|
1121
|
+
buildQuery(extra = {}) {
|
|
1122
|
+
const params = { ...extra };
|
|
1123
|
+
if (this.config.branch) params.branch = this.config.branch;
|
|
1124
|
+
const qs = new URLSearchParams(params).toString();
|
|
1125
|
+
return qs ? `?${qs}` : "";
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Resolve a subject's peer cohort and every peer's comparison against it.
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```typescript
|
|
1132
|
+
* const result = await client.peerCohort.resolve({
|
|
1133
|
+
* entity: "restaurant_id",
|
|
1134
|
+
* measure: "orders.net_revenue",
|
|
1135
|
+
* time_dimension: "orders.order_date",
|
|
1136
|
+
* period: ["2025-09-01", "2025-09-30"],
|
|
1137
|
+
* });
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
async resolve(request) {
|
|
1141
|
+
const query = this.buildQuery();
|
|
1142
|
+
return this.request(this.path(`/semantic/cohort${query}`), {
|
|
1143
|
+
method: "POST",
|
|
1144
|
+
body: JSON.stringify(request)
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
//#endregion
|
|
1150
|
+
export { AnomaliesClient, MetricTreeClient, OxyAnswer, OxyApiError, OxyAppProvider, OxyChat, PeerCohortClient, WorldModelScopeUnsupportedError, _resetCustomAppManifestCacheForTest, apiErrorFromResponse, base64ToBytes, bytesToBase64, createWorldModel, getCustomAppDebug, getOxyAppLogger, interpretCustomAppError, loadCustomAppManifest, readInjectedAppConfig, readJsonSseStream, setOxyAppLogger, useAgentRun, useBaseline, useDistribution, useExplain, useFunction, useMeasureBreakdown, useMetricTree, useOpportunity, useOxyApp, usePredict, useProcedureRun, useProjection, useQuery, useResolvedManifest, useSemanticQuery, useSensitivity, useTimeDimensions, useTrackEvent, useWorldModel, useWorldModelGraph, useWorldModelInstances };
|
|
1089
1151
|
//# sourceMappingURL=index.mjs.map
|