@oxy-hq/sdk 2.6.0 → 2.8.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 +54 -4
- package/dist/index.cjs +670 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +505 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +505 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +654 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{react-BAiiXftp.cjs → react-BFFCK4VM.cjs} +6 -1
- package/dist/react-BFFCK4VM.cjs.map +1 -0
- package/dist/{react-DnBdQ8dG.d.cts → react-kHG5gkd-.d.cts} +7 -2
- package/dist/react-kHG5gkd-.d.cts.map +1 -0
- package/dist/{react-DnBdQ8dG.d.mts → react-kHG5gkd-.d.mts} +7 -2
- package/dist/react-kHG5gkd-.d.mts.map +1 -0
- package/dist/{react-5HGW_0oy.mjs → react-sT7E4CbA.mjs} +6 -1
- package/dist/react-sT7E4CbA.mjs.map +1 -0
- package/dist/shell.cjs +4 -3
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.css +28 -6
- package/dist/shell.d.cts +1 -1
- package/dist/shell.d.cts.map +1 -1
- package/dist/shell.d.mts +1 -1
- package/dist/shell.d.mts.map +1 -1
- package/dist/shell.mjs +4 -3
- package/dist/shell.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/react-5HGW_0oy.mjs.map +0 -1
- package/dist/react-BAiiXftp.cjs.map +0 -1
- package/dist/react-DnBdQ8dG.d.cts.map +0 -1
- package/dist/react-DnBdQ8dG.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -88,11 +88,61 @@ couldn't already read.
|
|
|
88
88
|
| `<OxyAnswer … />` | Renders markdown + SQL artifacts + thread link. URL schemes are allowlisted (rejects `javascript:` etc.). |
|
|
89
89
|
| `OxyApiError` | Structured `{ message, code? }` server-error envelope. |
|
|
90
90
|
|
|
91
|
-
###
|
|
91
|
+
### World Model & analysis hooks
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
The same airlayer analyses the IDE's **World Model** and **Metric Tree** run,
|
|
94
|
+
exposed as hooks so a bundle can do RCA, opportunity sizing, and driver
|
|
95
|
+
exploration itself. Each fetches when enabled and its input is present; pass
|
|
96
|
+
`null` for a request/id to keep a hook idle until the user makes a selection.
|
|
97
|
+
|
|
98
|
+
| Export | What it does |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `useWorldModel()` | The entity/measure graph — entities, their measures, and how measures promote across the hierarchy (edges). |
|
|
101
|
+
| `useWorldModelInstances(entityId, { search?, limit? })` | Searchable listing of an entity's instances (primary key + display label). |
|
|
102
|
+
| `useMetricTree({ root? })` | The metric tree (measures + component/driver edges), or the subtree at `root`. |
|
|
103
|
+
| `useSensitivity(measureId)` | Ranked **drivers** of a measure — "what moves this?" |
|
|
104
|
+
| `usePredict(changes)` | **What-if**: propagate hypothetical `(measure, delta)` changes upward (pure tree walk, no warehouse). |
|
|
105
|
+
| `useExplain(request)` | **RCA**: period-over-period root-cause decomposition. |
|
|
106
|
+
| `useOpportunity(request)` | Segment **opportunity sizing** — addressable upside vs a benchmark peer. |
|
|
107
|
+
| `useDistribution(request)` | Single-period distribution against an auto-derived prior baseline. |
|
|
108
|
+
| `useTimeDimensions()` | Valid time dimensions per view — the period axis for the ops above. |
|
|
109
|
+
| `useMeasureBreakdown(entityId, key, measure)` | Per-instance **driver tree** (SSE) — node values fill in as they resolve. |
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { OxyAppProvider, useExplain, useOpportunity } from "@oxy-hq/sdk";
|
|
113
|
+
|
|
114
|
+
function RootCause() {
|
|
115
|
+
// Pass `null` instead of the request object to defer until the user picks a period.
|
|
116
|
+
const { data, loading, error } = useExplain({
|
|
117
|
+
target: "financials.operating_profit",
|
|
118
|
+
time_dimension: "financials.month",
|
|
119
|
+
current_period: ["2025-09-01", "2025-09-30"],
|
|
120
|
+
previous_period: ["2025-08-01", "2025-08-31"]
|
|
121
|
+
});
|
|
122
|
+
if (loading) return <p>Explaining…</p>;
|
|
123
|
+
if (error) return <p>{error.message}</p>;
|
|
124
|
+
return <p>Δ {data?.target_delta} — {((data?.coverage ?? 0) * 100).toFixed(0)}% explained</p>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function Upside() {
|
|
128
|
+
const { data } = useOpportunity({
|
|
129
|
+
target: "orders.net_revenue",
|
|
130
|
+
time_dimension: "orders.order_date",
|
|
131
|
+
period: ["2025-04-01", "2025-06-30"]
|
|
132
|
+
});
|
|
133
|
+
return <>{data?.dimensions.map((d) => <p key={d.dimension}>{d.dimension}: +{d.total_upside}</p>)}</>;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
A fuller worked example (graph + opportunity + RCA + streaming driver tree) is
|
|
138
|
+
in [examples/world-model-analysis.tsx](examples/world-model-analysis.tsx).
|
|
139
|
+
|
|
140
|
+
### Metric Tree (client-class)
|
|
141
|
+
|
|
142
|
+
For non-React / API-key callers, the programmatic `MetricTreeClient` and
|
|
143
|
+
`AnomaliesClient` (and all related types) are available from the package root
|
|
144
|
+
— see [metricTree.ts](src/metricTree.ts), [anomalies.ts](src/anomalies.ts), and
|
|
145
|
+
[examples/metric-tree.ts](examples/metric-tree.ts).
|
|
96
146
|
|
|
97
147
|
Hooks fail loudly if called outside `<OxyAppProvider>`. The default fetcher
|
|
98
148
|
sends `credentials: "include"` so same-origin (served-by-oxy) calls carry the
|