@oxy-hq/sdk 2.0.1 → 2.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @oxy-hq/sdk
2
2
 
3
- React SDK for building **customer-app bundles** on the [Oxy](https://oxy.tech)
3
+ React SDK for building **customer-app bundles** on the [Oxy](https://oxygen-hq.com)
4
4
  platform. A bundle is a normal Vite + React app that reads from its linked oxy
5
5
  project — raw SQL, the semantic layer, agents, and procedures — through a
6
6
  small set of hooks, plus a couple of drop-in components.
@@ -83,10 +83,17 @@ couldn't already read.
83
83
  | `useSemanticQuery({ topic, dimensions, measures, … })` | Semantic-layer query compiled by airlayer. |
84
84
  | `useAgentRun({ agentId })` | `.ask(question)` starts an analytics agent run; streams events over SSE; `.cancel()`. |
85
85
  | `useProcedureRun({ procedureId })` | Start a long-running procedure, poll, cancel (beta). |
86
+ | `useFunction(name)` | `.invoke(body?)` runs a server-side **Oxy Function** (`functions/<name>.ts`) on oxy's isolate runtime; returns its JSON `Response`. For work the browser shouldn't do — warehouse writes, ELT, external APIs. |
86
87
  | `<OxyChat agentId="…" />` | Drop-in chat UI over `useAgentRun`. |
87
88
  | `<OxyAnswer … />` | Renders markdown + SQL artifacts + thread link. URL schemes are allowlisted (rejects `javascript:` etc.). |
88
89
  | `OxyApiError` | Structured `{ message, code? }` server-error envelope. |
89
90
 
91
+ ### Metric Tree
92
+
93
+ Additional exports for programmatic metric-tree analyses (`AnomaliesClient`,
94
+ `MetricTreeClient` and all related types) are available from the package root
95
+ — see [metricTree.ts](src/metricTree.ts) and [anomalies.ts](src/anomalies.ts).
96
+
90
97
  Hooks fail loudly if called outside `<OxyAppProvider>`. The default fetcher
91
98
  sends `credentials: "include"` so same-origin (served-by-oxy) calls carry the
92
99
  session cookie automatically.
@@ -98,6 +105,7 @@ session cookie automatically.
98
105
  - SDK flow reference: `docs/sdk-flow.md` in that repo.
99
106
  - Platform internals: `internal-docs/customer-apps.md` in oxygen-internal.
100
107
 
108
+
101
109
  ## License
102
110
 
103
111
  MIT
package/dist/email.cjs ADDED
@@ -0,0 +1,14 @@
1
+ // @oxy/sdk - TypeScript SDK for Oxy data platform
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ let preact = require("preact");
4
+ let preact_render_to_string = require("preact-render-to-string");
5
+
6
+ //#region src/email.ts
7
+ /** Render an email template component to an HTML string. */
8
+ function render(Component, props) {
9
+ return (0, preact_render_to_string.render)((0, preact.h)(Component, props));
10
+ }
11
+
12
+ //#endregion
13
+ exports.render = render;
14
+ //# sourceMappingURL=email.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.cjs","names":[],"sources":["../src/email.ts"],"sourcesContent":["// `@oxy-hq/sdk/email` — render an email template to an HTML string for use in\n// an Oxy Function's `ctx.email.send`.\n//\n// You write email templates as plain JSX components (point JSX at preact with\n// `jsxImportSource: \"preact\"` in the template's tsconfig — see the examples),\n// then:\n//\n// ```ts\n// import { render } from \"@oxy-hq/sdk/email\";\n// import { Welcome } from \"../emails/Welcome\";\n// await ctx.email.send({ to, subject, html: render(Welcome, { name }) });\n// ```\n//\n// Rendering uses preact-render-to-string — pure JS, no react-dom/server, no node\n// builtins, no Web Streams — so it bundles under esbuild `--platform=neutral`\n// and runs inside the Oxy Functions isolate (React Email / react-dom cannot).\n// Kept in a separate subpath entry so it never bloats the main SDK bundle.\n\nimport { type ComponentType, h } from \"preact\";\nimport { render as prerender } from \"preact-render-to-string\";\n\n/** Render an email template component to an HTML string. */\nexport function render<P extends Record<string, unknown>>(\n Component: ComponentType<P>,\n props: P\n): string {\n return prerender(h(Component, props));\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,OACd,WACA,OACQ;CACR,yDAAmB,WAAW,KAAK,CAAC;AACtC"}
@@ -0,0 +1,8 @@
1
+
2
+ import { ComponentType } from "preact";
3
+ //#region src/email.d.ts
4
+ /** Render an email template component to an HTML string. */
5
+ declare function render<P extends Record<string, unknown>>(Component: ComponentType<P>, props: P): string;
6
+ //#endregion
7
+ export { render };
8
+ //# sourceMappingURL=email.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"mappings":";;;;iBAsBgB,OAAO,UAAU,yBAC/B,WAAW,cAAc,IACzB,OAAO"}
@@ -0,0 +1,8 @@
1
+
2
+ import { ComponentType } from "preact";
3
+ //#region src/email.d.ts
4
+ /** Render an email template component to an HTML string. */
5
+ declare function render<P extends Record<string, unknown>>(Component: ComponentType<P>, props: P): string;
6
+ //#endregion
7
+ export { render };
8
+ //# sourceMappingURL=email.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"mappings":";;;;iBAsBgB,OAAO,UAAU,yBAC/B,WAAW,cAAc,IACzB,OAAO"}
package/dist/email.mjs ADDED
@@ -0,0 +1,13 @@
1
+ // @oxy/sdk - TypeScript SDK for Oxy data platform
2
+ import { h } from "preact";
3
+ import { render as render$1 } from "preact-render-to-string";
4
+
5
+ //#region src/email.ts
6
+ /** Render an email template component to an HTML string. */
7
+ function render(Component, props) {
8
+ return render$1(h(Component, props));
9
+ }
10
+
11
+ //#endregion
12
+ export { render };
13
+ //# sourceMappingURL=email.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.mjs","names":["prerender"],"sources":["../src/email.ts"],"sourcesContent":["// `@oxy-hq/sdk/email` — render an email template to an HTML string for use in\n// an Oxy Function's `ctx.email.send`.\n//\n// You write email templates as plain JSX components (point JSX at preact with\n// `jsxImportSource: \"preact\"` in the template's tsconfig — see the examples),\n// then:\n//\n// ```ts\n// import { render } from \"@oxy-hq/sdk/email\";\n// import { Welcome } from \"../emails/Welcome\";\n// await ctx.email.send({ to, subject, html: render(Welcome, { name }) });\n// ```\n//\n// Rendering uses preact-render-to-string — pure JS, no react-dom/server, no node\n// builtins, no Web Streams — so it bundles under esbuild `--platform=neutral`\n// and runs inside the Oxy Functions isolate (React Email / react-dom cannot).\n// Kept in a separate subpath entry so it never bloats the main SDK bundle.\n\nimport { type ComponentType, h } from \"preact\";\nimport { render as prerender } from \"preact-render-to-string\";\n\n/** Render an email template component to an HTML string. */\nexport function render<P extends Record<string, unknown>>(\n Component: ComponentType<P>,\n props: P\n): string {\n return prerender(h(Component, props));\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,OACd,WACA,OACQ;CACR,OAAOA,SAAU,EAAE,WAAW,KAAK,CAAC;AACtC"}