@oxy-hq/sdk 2.10.0 → 2.12.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 +44 -4
- package/dist/function-context-D8eyZuw_.d.cts +720 -0
- package/dist/function-context-D8eyZuw_.d.cts.map +1 -0
- package/dist/function-context-D8eyZuw_.d.mts +720 -0
- package/dist/function-context-D8eyZuw_.d.mts.map +1 -0
- package/dist/index.cjs +156 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +338 -595
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +338 -595
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +155 -12
- package/dist/index.mjs.map +1 -1
- package/dist/ops.cjs +85 -0
- package/dist/ops.cjs.map +1 -0
- package/dist/ops.d.cts +61 -0
- package/dist/ops.d.cts.map +1 -0
- package/dist/ops.d.mts +61 -0
- package/dist/ops.d.mts.map +1 -0
- package/dist/ops.mjs +79 -0
- package/dist/ops.mjs.map +1 -0
- package/dist/{react-B7zt-0RH.mjs → react-BXGyzgz0.mjs} +19 -6
- package/dist/react-BXGyzgz0.mjs.map +1 -0
- package/dist/{react-BGUzRMxq.d.mts → react-DW7Z96sD.d.cts} +52 -1
- package/dist/react-DW7Z96sD.d.cts.map +1 -0
- package/dist/{react-BGUzRMxq.d.cts → react-DW7Z96sD.d.mts} +52 -1
- package/dist/react-DW7Z96sD.d.mts.map +1 -0
- package/dist/{react-Cas_DVKe.cjs → react-DcT-mUPj.cjs} +19 -6
- package/dist/react-DcT-mUPj.cjs.map +1 -0
- package/dist/shell.cjs +34 -4
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +39 -7
- package/dist/shell.d.cts.map +1 -1
- package/dist/shell.d.mts +39 -7
- package/dist/shell.d.mts.map +1 -1
- package/dist/shell.mjs +34 -5
- package/dist/shell.mjs.map +1 -1
- package/package.json +12 -1
- package/dist/react-B7zt-0RH.mjs.map +0 -1
- package/dist/react-BGUzRMxq.d.cts.map +0 -1
- package/dist/react-BGUzRMxq.d.mts.map +0 -1
- package/dist/react-Cas_DVKe.cjs.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/metricTree.ts","../src/anomalies.ts","../src/custom-app/base64.ts","../src/custom-app/debug.ts","../src/custom-app/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/metricTree.ts","../src/anomalies.ts","../src/custom-app/base64.ts","../src/custom-app/debug.ts","../src/custom-app/inject.ts","../src/custom-app/logger.ts","../src/custom-app/metric-tree-hooks.tsx","../src/custom-app/sse.ts","../src/worldModel.ts","../src/custom-app/world-model-hooks.tsx","../src/custom-app/world-node.tsx"],"mappings":";;;;;;;UAGiB;;;;EAIf;;;;EAKA;;;;EAKA;;;;EAKA;;;;EAKA;;;;;;;EAQA;;;;;EAMA;;;;KCjCU;KACA;KACA;KACA;;;;;;;;;KASA;UAWK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;EAKA;EACA;;UAGe;EACf;EACA;EACA,MAAM;;EAEN;;;;;EAKA;EACA,WAAW;EACX,UAAU;EACV,YAAY;EACZ;EACA,MAAM;;EAEN;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP,OAAO;EACP;;;;EAIA;;UAKe;EACf;EACA;EACA;EACA;EACA,OAAO;EACP,WAAW;EACX,UAAU;EACV;EACA;;UAGe;EACf;EACA,SAAS;;UAKM;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,MAAM;EACN;;UAGe;EACf,QAAQ;EACR,SAAS;;;KAIC,gBAAgB;;;;;;;;UASX;EACf;EACA;EACA;;;;EAIA,OAAO;;;;;;;;;EASP;EACA;EACA;;;;EAIA;;;EAGA;EACA;;EAEA;;EAEA;;;;EAIA;;;;EAIA;IAAY;IAAY;IAAa;;;;EAGrC;;;;;EAKA;EACA;;;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KAAK,SAAS,cAAc,QAAQ;;EAEpC,OAAO,SAAS,cAAc,QAAQ;;EAEtC,QAAQ,SAAS,cAAc,QAAQ;;EAEvC,QAAQ,MAAM,aAAa,SAAS,cAAc,QAAQ;;EAE1D,KAAK,MAAM,UAAU,SAAS,cAAc,QAAQ;;EAEpD,MAAM,OAAO,yBAAyB;;;;;;;UAQvB;;WAEN;;EAET,KAAK,eAAe,SAAS,cAAc,QAAQ;;EAEnD,OAAO,aAAa;;;;;;;;cAST,wCAAwC;WAC1C;WACA,OAAO;EAChB,YAAY,cAAc,OAAO;;;;;;;iBAkBnB,iBAAiB,0BAA0B,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;iBAqGjE,iBAAiB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @oxy/sdk - TypeScript SDK for Oxy data platform
|
|
2
|
-
import { _ as interpretCustomAppError, a as useFunction, 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 getOxyAppLogger, y as setOxyAppLogger } from "./react-
|
|
2
|
+
import { _ as interpretCustomAppError, a as useFunction, 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 getOxyAppLogger, y as setOxyAppLogger } from "./react-BXGyzgz0.mjs";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/anomalies.ts
|
|
@@ -386,14 +386,69 @@ function useSensitivity(measureId, opts = {}) {
|
|
|
386
386
|
* Propagate hypothetical `(measure, delta)` changes upward through the
|
|
387
387
|
* tree and return the estimated impact on every downstream measure — a
|
|
388
388
|
* pure metric-tree walk, no warehouse query. Pass `null` to stay idle.
|
|
389
|
+
*
|
|
390
|
+
* Because it is database-free it can only use the coefficients it is GIVEN.
|
|
391
|
+
* Without `opts.coefficients` from {@link useBaseline}, every driver edge
|
|
392
|
+
* whose `.view.yml` declares no `coefficient:` contributes nothing and its
|
|
393
|
+
* downstream measures are simply absent from `impacts` — no error, no
|
|
394
|
+
* refusal. Without `opts.values`, multiplicative component edges come back
|
|
395
|
+
* `unquantifiable` rather than sized.
|
|
389
396
|
*/
|
|
390
397
|
function usePredict(changes, opts = {}) {
|
|
391
398
|
const { projectId, fetcher } = useOxyApp();
|
|
392
399
|
const enabled = opts.enabled !== false;
|
|
400
|
+
const { values, coefficients } = opts;
|
|
401
|
+
const body = {
|
|
402
|
+
changes,
|
|
403
|
+
...values ? { values } : {},
|
|
404
|
+
...coefficients?.length ? { coefficients } : {}
|
|
405
|
+
};
|
|
393
406
|
return useMetricTreeEndpoint(projectId && changes ? JSON.stringify({
|
|
394
407
|
projectId,
|
|
395
|
-
|
|
396
|
-
}) : null, (signal) => postJson(fetcher, `${metricTreePath(projectId)}/predict`,
|
|
408
|
+
body
|
|
409
|
+
}) : null, (signal) => postJson(fetcher, `${metricTreePath(projectId)}/predict`, body, signal), enabled);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Value a scenario's starting point, and measure the coefficients it needs.
|
|
413
|
+
*
|
|
414
|
+
* Two warehouse reads: the current value of every node reachable from
|
|
415
|
+
* `request.roots`, and — for driver edges declaring no `coefficient:` — a fit
|
|
416
|
+
* over the window. Both are expensive, which is why they live here and not in
|
|
417
|
+
* {@link usePredict}: predict is database-free by design so it can re-run per
|
|
418
|
+
* keystroke, and it CANNOT measure a coefficient itself.
|
|
419
|
+
*
|
|
420
|
+
* That is the whole reason to call this. Feed `data.values` and `data.fitted`
|
|
421
|
+
* into `usePredict`; omit them and an undeclared edge propagates nothing.
|
|
422
|
+
* Pass `null` to stay idle until levers and a period are chosen.
|
|
423
|
+
*/
|
|
424
|
+
function useBaseline(request, opts = {}) {
|
|
425
|
+
const { projectId, fetcher } = useOxyApp();
|
|
426
|
+
const enabled = opts.enabled !== false;
|
|
427
|
+
return useMetricTreeEndpoint(projectId && request ? JSON.stringify({
|
|
428
|
+
projectId,
|
|
429
|
+
request
|
|
430
|
+
}) : null, (signal) => postJson(fetcher, `${metricTreePath(projectId)}/baseline`, request, signal), enabled);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Bucketed history for the levers and everything downstream, plus the forward
|
|
434
|
+
* curve the forecaster expects next — the scenario's time axis.
|
|
435
|
+
*
|
|
436
|
+
* One warehouse query, so it belongs on a window change, not on a lever edit.
|
|
437
|
+
* It returns the BASELINE curve only: the scenario's second curve is
|
|
438
|
+
* arithmetic over this and a `usePredict` result — a proportional shift
|
|
439
|
+
* landing `lag` buckets in — composed client-side precisely so editing a lever
|
|
440
|
+
* costs no query.
|
|
441
|
+
*
|
|
442
|
+
* Treat a series with a `refusal` as a stated absence: it must not render as a
|
|
443
|
+
* flat forward line. Pass `null` to stay idle.
|
|
444
|
+
*/
|
|
445
|
+
function useProjection(request, opts = {}) {
|
|
446
|
+
const { projectId, fetcher } = useOxyApp();
|
|
447
|
+
const enabled = opts.enabled !== false;
|
|
448
|
+
return useMetricTreeEndpoint(projectId && request ? JSON.stringify({
|
|
449
|
+
projectId,
|
|
450
|
+
request
|
|
451
|
+
}) : null, (signal) => postJson(fetcher, `${metricTreePath(projectId)}/projection`, request, signal), enabled);
|
|
397
452
|
}
|
|
398
453
|
/**
|
|
399
454
|
* Period-over-period root-cause decomposition: recursively splits the
|
|
@@ -554,9 +609,9 @@ function useWorldModelGraph(opts = {}) {
|
|
|
554
609
|
* to stay idle until an entity is chosen.
|
|
555
610
|
*/
|
|
556
611
|
function useWorldModelInstances(entityId, opts = {}) {
|
|
557
|
-
const { projectId, fetcher } = useOxyApp();
|
|
612
|
+
const { projectId, appId, fetcher } = useOxyApp();
|
|
558
613
|
const enabled = opts.enabled !== false;
|
|
559
|
-
const { search, limit } = opts;
|
|
614
|
+
const { search, limit, scope } = opts;
|
|
560
615
|
const [data, setData] = React.useState(null);
|
|
561
616
|
const [loading, setLoading] = React.useState(enabled && !!projectId && !!entityId);
|
|
562
617
|
const [error, setError] = React.useState(null);
|
|
@@ -573,6 +628,10 @@ function useWorldModelInstances(entityId, opts = {}) {
|
|
|
573
628
|
const params = new URLSearchParams({ entity: entityId });
|
|
574
629
|
if (search) params.set("search", search);
|
|
575
630
|
if (limit != null) params.set("limit", String(limit));
|
|
631
|
+
if (scope) {
|
|
632
|
+
params.set("scope", scope);
|
|
633
|
+
if (appId) params.set("app", appId);
|
|
634
|
+
}
|
|
576
635
|
fetcher(`${worldModelPath(projectId)}/instances?${params}`, {
|
|
577
636
|
method: "GET",
|
|
578
637
|
signal: ctrl.signal
|
|
@@ -599,7 +658,9 @@ function useWorldModelInstances(entityId, opts = {}) {
|
|
|
599
658
|
entityId,
|
|
600
659
|
search,
|
|
601
660
|
limit,
|
|
602
|
-
fetcher
|
|
661
|
+
fetcher,
|
|
662
|
+
scope,
|
|
663
|
+
appId
|
|
603
664
|
]);
|
|
604
665
|
return {
|
|
605
666
|
data,
|
|
@@ -816,9 +877,10 @@ function useWorldModel() {
|
|
|
816
877
|
//#endregion
|
|
817
878
|
//#region src/metricTree.ts
|
|
818
879
|
/**
|
|
819
|
-
* Client for the `/semantic/metric-tree*` endpoints. Surfaces the
|
|
820
|
-
*
|
|
821
|
-
*
|
|
880
|
+
* Client for the `/semantic/metric-tree*` endpoints. Surfaces the airlayer
|
|
881
|
+
* metric-tree analyses — tree introspection, sensitivity, explain, opportunity
|
|
882
|
+
* — plus the three legs of scenario forecasting (`baseline` levels,
|
|
883
|
+
* `predict` propagation, `projection` curves) over typed methods.
|
|
822
884
|
*
|
|
823
885
|
* Construction is internal to {@link OxyClient} — call `client.metricTree`
|
|
824
886
|
* to access an instance rather than building one yourself.
|
|
@@ -878,9 +940,50 @@ var MetricTreeClient = class {
|
|
|
878
940
|
return this.request(this.path(`/${encodeURIComponent(measureId)}/sensitivity${query}`));
|
|
879
941
|
}
|
|
880
942
|
/**
|
|
943
|
+
* Value a change's starting point, and measure the coefficients it needs.
|
|
944
|
+
*
|
|
945
|
+
* Two warehouse reads: the current value of every node reachable from
|
|
946
|
+
* `roots`, and — for driver edges that declare no `coefficient:` — a fit
|
|
947
|
+
* over the window. Both are expensive, which is why they live here and not
|
|
948
|
+
* in `predict`: `predict` is database-free by design so it can re-run per
|
|
949
|
+
* keystroke, and it CANNOT measure a coefficient itself.
|
|
950
|
+
*
|
|
951
|
+
* That is the whole reason to call this. Pass `fitted` back into `predict`
|
|
952
|
+
* and an undeclared edge propagates; omit it and `predict` has nothing to
|
|
953
|
+
* multiply by, so the impact is simply absent — no error, no refusal, just a
|
|
954
|
+
* downstream measure that never appears.
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* const baseline = await client.metricTree.getBaseline({
|
|
959
|
+
* roots: ["marketing_spend.total_spend"],
|
|
960
|
+
* time_dimension: "orders.order_date",
|
|
961
|
+
* period: ["2025-09-01", "2025-09-30"],
|
|
962
|
+
* });
|
|
963
|
+
* const result = await client.metricTree.predict(
|
|
964
|
+
* [{ measure: "marketing_spend.total_spend", delta: 10000 }],
|
|
965
|
+
* { values: baseline.values, coefficients: baseline.fitted }
|
|
966
|
+
* );
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
async getBaseline(request) {
|
|
970
|
+
const query = this.buildQuery();
|
|
971
|
+
return this.request(this.path(`/baseline${query}`), {
|
|
972
|
+
method: "POST",
|
|
973
|
+
body: JSON.stringify(request)
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
881
977
|
* Propagate hypothetical `(measure, delta)` changes upward through the
|
|
882
978
|
* tree. Returns the estimated impact on every downstream measure.
|
|
883
979
|
*
|
|
980
|
+
* Database-free, so it re-runs cheaply — and so it can only use
|
|
981
|
+
* coefficients it is GIVEN. Without `options.coefficients` from
|
|
982
|
+
* {@link getBaseline}, every edge whose `.view.yml` declares no
|
|
983
|
+
* `coefficient:` contributes nothing and its downstream measures are
|
|
984
|
+
* silently missing from `impacts`. Without `options.values`, multiplicative
|
|
985
|
+
* component edges come back `unquantifiable` rather than sized.
|
|
986
|
+
*
|
|
884
987
|
* @example
|
|
885
988
|
* ```typescript
|
|
886
989
|
* const result = await client.metricTree.predict([
|
|
@@ -888,11 +991,51 @@ var MetricTreeClient = class {
|
|
|
888
991
|
* ]);
|
|
889
992
|
* ```
|
|
890
993
|
*/
|
|
891
|
-
async predict(changes) {
|
|
994
|
+
async predict(changes, options = {}) {
|
|
892
995
|
const query = this.buildQuery();
|
|
893
996
|
return this.request(this.path(`/predict${query}`), {
|
|
894
997
|
method: "POST",
|
|
895
|
-
body: JSON.stringify({
|
|
998
|
+
body: JSON.stringify({
|
|
999
|
+
changes,
|
|
1000
|
+
...options.values ? { values: options.values } : {},
|
|
1001
|
+
...options.coefficients?.length ? { coefficients: options.coefficients } : {}
|
|
1002
|
+
})
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Draw the scenario's time axis: bucketed history for the levers and
|
|
1007
|
+
* everything downstream, plus the forward curve the detector's own model
|
|
1008
|
+
* expects next.
|
|
1009
|
+
*
|
|
1010
|
+
* The third leg of scenario forecasting. {@link getBaseline} gives levels
|
|
1011
|
+
* and coefficients, {@link predict} propagates a change with no database at
|
|
1012
|
+
* all, and this gives time — one warehouse query, so treat it like the
|
|
1013
|
+
* baseline: fetch on a window change, not on a lever edit.
|
|
1014
|
+
*
|
|
1015
|
+
* **Returns the BASELINE curve only.** The scenario's second curve is
|
|
1016
|
+
* arithmetic over this and a `predict` result — a proportional shift landing
|
|
1017
|
+
* `lag` buckets in — and is composed client-side deliberately, so editing a
|
|
1018
|
+
* lever costs no query.
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```typescript
|
|
1022
|
+
* const projection = await client.metricTree.getProjection({
|
|
1023
|
+
* roots: ["marketing_spend.total_spend"],
|
|
1024
|
+
* time_dimension: "orders.order_date",
|
|
1025
|
+
* period: ["2024-09-01", "2025-08-31"],
|
|
1026
|
+
* granularity: "day",
|
|
1027
|
+
* horizon: 30,
|
|
1028
|
+
* });
|
|
1029
|
+
* for (const series of projection.series) {
|
|
1030
|
+
* if (series.refusal) console.warn(series.measure, series.refusal);
|
|
1031
|
+
* }
|
|
1032
|
+
* ```
|
|
1033
|
+
*/
|
|
1034
|
+
async getProjection(request) {
|
|
1035
|
+
const query = this.buildQuery();
|
|
1036
|
+
return this.request(this.path(`/projection${query}`), {
|
|
1037
|
+
method: "POST",
|
|
1038
|
+
body: JSON.stringify(request)
|
|
896
1039
|
});
|
|
897
1040
|
}
|
|
898
1041
|
/**
|
|
@@ -942,5 +1085,5 @@ var MetricTreeClient = class {
|
|
|
942
1085
|
};
|
|
943
1086
|
|
|
944
1087
|
//#endregion
|
|
945
|
-
export { AnomaliesClient, MetricTreeClient, OxyAnswer, OxyApiError, OxyAppProvider, OxyChat, WorldModelScopeUnsupportedError, _resetCustomAppManifestCacheForTest, apiErrorFromResponse, base64ToBytes, bytesToBase64, createWorldModel, getCustomAppDebug, getOxyAppLogger, interpretCustomAppError, loadCustomAppManifest, readInjectedAppConfig, readJsonSseStream, setOxyAppLogger, useAgentRun, useDistribution, useExplain, useFunction, useMeasureBreakdown, useMetricTree, useOpportunity, useOxyApp, usePredict, useProcedureRun, useQuery, useResolvedManifest, useSemanticQuery, useSensitivity, useTimeDimensions, useTrackEvent, useWorldModel, useWorldModelGraph, useWorldModelInstances };
|
|
1088
|
+
export { AnomaliesClient, MetricTreeClient, OxyAnswer, OxyApiError, OxyAppProvider, OxyChat, 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 };
|
|
946
1089
|
//# sourceMappingURL=index.mjs.map
|