@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.
Files changed (42) hide show
  1. package/README.md +44 -4
  2. package/dist/function-context-D8eyZuw_.d.cts +720 -0
  3. package/dist/function-context-D8eyZuw_.d.cts.map +1 -0
  4. package/dist/function-context-D8eyZuw_.d.mts +720 -0
  5. package/dist/function-context-D8eyZuw_.d.mts.map +1 -0
  6. package/dist/index.cjs +156 -11
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +338 -595
  9. package/dist/index.d.cts.map +1 -1
  10. package/dist/index.d.mts +338 -595
  11. package/dist/index.d.mts.map +1 -1
  12. package/dist/index.mjs +155 -12
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/ops.cjs +85 -0
  15. package/dist/ops.cjs.map +1 -0
  16. package/dist/ops.d.cts +61 -0
  17. package/dist/ops.d.cts.map +1 -0
  18. package/dist/ops.d.mts +61 -0
  19. package/dist/ops.d.mts.map +1 -0
  20. package/dist/ops.mjs +79 -0
  21. package/dist/ops.mjs.map +1 -0
  22. package/dist/{react-B7zt-0RH.mjs → react-BXGyzgz0.mjs} +19 -6
  23. package/dist/react-BXGyzgz0.mjs.map +1 -0
  24. package/dist/{react-BGUzRMxq.d.mts → react-DW7Z96sD.d.cts} +52 -1
  25. package/dist/react-DW7Z96sD.d.cts.map +1 -0
  26. package/dist/{react-BGUzRMxq.d.cts → react-DW7Z96sD.d.mts} +52 -1
  27. package/dist/react-DW7Z96sD.d.mts.map +1 -0
  28. package/dist/{react-Cas_DVKe.cjs → react-DcT-mUPj.cjs} +19 -6
  29. package/dist/react-DcT-mUPj.cjs.map +1 -0
  30. package/dist/shell.cjs +34 -4
  31. package/dist/shell.cjs.map +1 -1
  32. package/dist/shell.d.cts +39 -7
  33. package/dist/shell.d.cts.map +1 -1
  34. package/dist/shell.d.mts +39 -7
  35. package/dist/shell.d.mts.map +1 -1
  36. package/dist/shell.mjs +34 -5
  37. package/dist/shell.mjs.map +1 -1
  38. package/package.json +12 -1
  39. package/dist/react-B7zt-0RH.mjs.map +0 -1
  40. package/dist/react-BGUzRMxq.d.cts.map +0 -1
  41. package/dist/react-BGUzRMxq.d.mts.map +0 -1
  42. package/dist/react-Cas_DVKe.cjs.map +0 -1
package/README.md CHANGED
@@ -36,10 +36,10 @@ read data with hooks:
36
36
  import { OxyAppProvider, useQuery, OxyChat } from "@oxy-hq/sdk";
37
37
 
38
38
  function Dashboard() {
39
- const { rows, isLoading, error } = useQuery({
39
+ const { rows, loading, error } = useQuery({
40
40
  sql: "SELECT Store, SUM(Weekly_Sales) AS sales FROM oxymart GROUP BY 1 ORDER BY 2 DESC LIMIT 5"
41
41
  });
42
- if (isLoading) return <p>Loading…</p>;
42
+ if (loading) return <p>Loading…</p>;
43
43
  if (error) return <p>{error.message}</p>;
44
44
  return (
45
45
  <>
@@ -97,11 +97,14 @@ exploration itself. Each fetches when enabled and its input is present; pass
97
97
 
98
98
  | Export | What it does |
99
99
  | --- | --- |
100
- | `useWorldModel()` | The entity/measure graph — entities, their measures, and how measures promote across the hierarchy (edges). |
100
+ | `useWorldModel()` | The World Model **node interface** — `world.metric(id)` returns a handle speaking `expand` / `drivers` / `explain` / `size` / `drill`. |
101
+ | `useWorldModelGraph()` | The raw entity/measure graph — entities, their measures, and how measures promote across the hierarchy (edges). |
101
102
  | `useWorldModelInstances(entityId, { search?, limit? })` | Searchable listing of an entity's instances (primary key + display label). |
102
103
  | `useMetricTree({ root? })` | The metric tree (measures + component/driver edges), or the subtree at `root`. |
103
104
  | `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
+ | `usePredict(changes, { values?, coefficients? })` | **What-if**: propagate hypothetical `(measure, delta)` changes upward (pure tree walk, no warehouse). Feed it `useBaseline`'s `values` / `fitted` or undeclared driver edges propagate nothing. |
106
+ | `useBaseline(request)` | **Scenario levels**: current values for the levers and everything downstream, plus coefficients fitted for driver edges that declare none. |
107
+ | `useProjection(request)` | **Scenario forecasting**: bucketed history + forward curve (with prediction band) for the levers and everything downstream. |
105
108
  | `useExplain(request)` | **RCA**: period-over-period root-cause decomposition. |
106
109
  | `useOpportunity(request)` | Segment **opportunity sizing** — addressable upside vs a benchmark peer. |
107
110
  | `useDistribution(request)` | Single-period distribution against an auto-derived prior baseline. |
@@ -134,6 +137,43 @@ function Upside() {
134
137
  }
135
138
  ```
136
139
 
140
+ Scenario forecasting is three hooks, split by what each one costs.
141
+ `useBaseline` and `useProjection` each fire one warehouse query, so they belong
142
+ on a *window* change; `usePredict` touches no database and re-runs per
143
+ keystroke as the analyst drags a lever. `useProjection` returns the **baseline**
144
+ curve only — the scenario's second curve is arithmetic over it and the
145
+ `usePredict` result, composed client-side so a lever edit costs no query.
146
+
147
+ ```tsx
148
+ import { useBaseline, useProjection, usePredict } from "@oxy-hq/sdk";
149
+
150
+ function Scenario({ lever, delta }: { lever: string; delta: number }) {
151
+ const period: [string, string] = ["2025-08-01", "2025-08-31"];
152
+ const baseline = useBaseline({
153
+ roots: [lever],
154
+ time_dimension: "orders.order_date",
155
+ period
156
+ });
157
+ // Fitted coefficients go in verbatim, refusals included — filtering them here
158
+ // would just be a second place for client and server to disagree.
159
+ const predicted = usePredict([{ measure: lever, delta }], {
160
+ values: baseline.data?.values,
161
+ coefficients: baseline.data?.fitted
162
+ });
163
+ const projection = useProjection({
164
+ roots: [lever],
165
+ time_dimension: "orders.order_date",
166
+ // Its own, much longer window: the forecaster refuses under eight seasonal
167
+ // cycles, so reusing the baseline's month would refuse every curve.
168
+ period: ["2024-09-01", "2025-08-31"],
169
+ granularity: "day",
170
+ horizon: 30
171
+ });
172
+
173
+ return <p>{projection.data?.series.length} curves, {predicted.data?.impacts.length} impacts</p>;
174
+ }
175
+ ```
176
+
137
177
  A fuller worked example (graph + opportunity + RCA + streaming driver tree) is
138
178
  in [examples/world-model-analysis.tsx](examples/world-model-analysis.tsx).
139
179