@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
@@ -64,6 +64,25 @@ interface OxyAppFunctionManifest {
64
64
  email?: {
65
65
  send?: boolean;
66
66
  };
67
+ /**
68
+ * Capability for `ctx.org.people()` — the org's people directory, READ-ONLY
69
+ * (fail-closed: omit → the call is rejected before any query).
70
+ *
71
+ * Declare it for a function that has to name a person: an assignee, a roster
72
+ * entry, who submitted something. It answers with a display name and a role.
73
+ *
74
+ * Three things it deliberately is not, so nobody plans around them:
75
+ * it returns **no email and no phone** — naming a colleague is a different
76
+ * need from contacting them off-platform; it returns **no location**, which
77
+ * the platform does not hold for a member; and it does **not include
78
+ * frontline workers**, who hold no org-membership row by design.
79
+ *
80
+ * One flag, not `read`/`write`: there is no write. Editing the directory
81
+ * would put tenant membership behind an app's manifest.
82
+ */
83
+ org?: {
84
+ read?: boolean;
85
+ };
67
86
  /**
68
87
  * Capability for `ctx.oltp` — read/write the app's OWN per-org OLTP schema on
69
88
  * the managed Postgres tenant (fail-closed: omit → every `ctx.oltp` call
@@ -139,6 +158,25 @@ interface OxyAppManifest {
139
158
  * static bundle (today's default). See the functions design doc.
140
159
  */
141
160
  functions?: Record<string, OxyAppFunctionManifest>;
161
+ /**
162
+ * Schema migrations that ship WITH this bundle and run on promote.
163
+ *
164
+ * `dir` is a directory inside the built bundle holding numbered `.sql` files.
165
+ * The platform runs them in lexical order, **once each, ever**, inside a
166
+ * transaction, as the app's own writer role, and records each one.
167
+ *
168
+ * What changes for the author: you no longer write defensive
169
+ * `IF NOT EXISTS` / idempotent upserts, because re-running is a no-op by
170
+ * construction rather than by your care. And you **may not edit, rename or
171
+ * copy a migration that has already run** — all three fail the promote by
172
+ * name, and the fix is always a new file.
173
+ *
174
+ * The `.sql` files are ordinary bundle files, fetchable over the app's own
175
+ * host: put no secrets in them.
176
+ */
177
+ migrations?: {
178
+ dir: string;
179
+ };
142
180
  /**
143
181
  * Optional Ask Oxygen binding (agent ref + composer chips). The
144
182
  * platform's registered copy is authoritative (surfaced by
@@ -420,6 +458,12 @@ declare function useResolvedManifest(): ResolvedCustomAppManifest;
420
458
  */
421
459
  declare function useOxyApp(): {
422
460
  projectId: string | undefined;
461
+ /**
462
+ * The `apps.id` this bundle was served as — from `window.__OXY_APP__`, so
463
+ * it is the platform's word and not the manifest's. Undefined under `pnpm
464
+ * dev` against a manifest with no injected identity.
465
+ */
466
+ appId: string | undefined;
423
467
  appSlug: string | undefined;
424
468
  orgSlug: string | undefined;
425
469
  fetcher: AppFetcher;
@@ -525,6 +569,13 @@ interface UseSemanticQueryInput {
525
569
  time_dimensions?: SemanticTimeDimension[];
526
570
  filters?: SemanticFilter[];
527
571
  limit?: number;
572
+ /**
573
+ * `"reach"` — pin the query server-side to the viewer's places: one `in`
574
+ * filter per view it names whose primary entity is bound to the org's
575
+ * locations registry. The bundle's own app is sent along so app-admin
576
+ * standing counts. A query naming no bound view is refused.
577
+ */
578
+ scope?: "reach";
528
579
  }
529
580
  interface UseSemanticQueryOpts {
530
581
  /** Set false to skip the request (e.g., waiting on user input). */
@@ -785,4 +836,4 @@ interface OxyChatProps {
785
836
  declare function OxyChat(props: OxyChatProps): React.JSX.Element;
786
837
  //#endregion
787
838
  export { loadCustomAppManifest as $, UseSemanticQueryOpts as A, FunctionError as B, UseProcedureRunInput as C, UseQueryOpts as D, UseQueryInput as E, useProcedureRun as F, apiErrorFromResponse as G, FunctionResult as H, useQuery as I, OxyAppFunctionManifest as J, interpretCustomAppError as K, useResolvedManifest as L, useAgentRun as M, useFunction as N, UseQueryResult as O, useOxyApp as P, _resetCustomAppManifestCacheForTest as Q, useSemanticQuery as R, UseFunctionResult as S, UseProcedureRunResult as T, CustomAppErrorReport as U, FunctionLog as V, OxyApiError as W, OxyAppPerformanceManifest as X, OxyAppManifest as Y, ResolvedCustomAppManifest as Z, SemanticFilter as _, AppFetcher as a, UseAgentRunInput as b, OxyAppProvider as c, OxyChatProps as d, ProcedureProgress as f, SemanticDateRangeOp as g, SemanticArrayOp as h, AgentSqlArtifact as i, UseSemanticQueryResult as j, UseSemanticQueryInput as k, OxyAppProviderProps as l, ProcedureRunState as m, AgentRunEvent as n, OxyAnswer as o, ProcedureResult as p, LoadManifestOptions as q, AgentRunState as r, OxyAnswerProps as s, AgentArtifact as t, OxyChat as u, SemanticScalarOp as v, UseProcedureRunOpts as w, UseAgentRunResult as x, SemanticTimeDimension as y, useTrackEvent as z };
788
- //# sourceMappingURL=react-BGUzRMxq.d.cts.map
839
+ //# sourceMappingURL=react-DW7Z96sD.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-DW7Z96sD.d.mts","names":[],"sources":["../src/custom-app/manifest.ts","../src/custom-app/errors.ts","../src/custom-app/function-sse.ts","../src/custom-app/react.tsx"],"mappings":";;;;;;;;;;;UA0BiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;IAAe;IAAkB;;;EAEjC;;;;;;;;;EASA;IAAU;;;;;;;;;;EASV;;;;;;;EAOA;IAAY;;;;;;;;;EAQZ;IAAU;;;;;;;;;;;;;;;;;;EAiBV;IAAQ;;;;;;;;;;;;;;;;;;EAiBR;IAAS;;;;;;;;;;EAST;IAAY;IAAsB;IAAuB;;;;;;;;EAOzD;;;UAIe;;EAEf;;;;;;EAMA;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,YAAY,eAAe;;;;;;;;;;;;;;;;;EAiB3B;IAAe;;;;;;;;EAOf;IAAQ;IAAgB;;;;;;;;EAOxB,UAAU;;;;;;;;;;EAUV,cAAc;;;;;;;;;;;;;;;EAed;;;UAIe;;;;;;;;;;;;EAYf;;;UAIe;;;;;EAKf;;;;;;;;;EASA;;;UAIe;;;;;;;;;;;;;;;;;;;;EAo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UAGe;EACf;EACA;EACA;EACA,kBAAkB;EAClB,UAAU;EACV;;;;;;;EAOA;;UAGe;;EAEf;;;;;;;EAOA;;UAGe,uBAAuB,MAAM;EAC5C,MAAM;EACN;;EAEA;;EAEA;EACA;EACA,OAAO;EACP;;;;;;;;;;;;iBAac,iBAAiB,MAAM,yBACrC,OAAO,uBACP,OAAM,uBACL,uBAAuB;KAqHd;UAEK;EACf;;UAGe;;;EAGf;EACA;;EAEA;;UAGe;EACf;EACA;;UAGe;EACf;EACA,SAAS;;UAGM;EACf,OAAO;EACP,MAAM,SAAS;;EAEf;EACA,UAAU;EACV,QAAQ;EACR,OAAO;;;;;;;;;;;;;;;;;;;;iBAyBO,gBACd,OAAO,sBACP,OAAM,sBACL;KAsLS;UAEK;EACf;EACA;;;;;;UAOe;EACf;;;EAGA;;;EAGA;EACA;;EAEA;IACE;IACA;IACA;;;;;EAKF;;KAGU,gBAAgB;UAEX;EACf;;UAGe;EACf,OAAO;;EAEP,MAAM,kBAAkB;IAAS;;;EAEjC;;EAEA,QAAQ;;;;EAIR,WAAW;;EAEX;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;EAmBA;EACA,OAAO;;iBAGO,YAAY,OAAO,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2hBtC,kBAAkB,cAAc,UAAU;UAmHzC;;EAEf;;EAEA,YAAY;;EAEZ,OAAO;;EAEP;;EAEA,QAAQ;;;;;;;;EAQR;;EAEA;;;EAGA;;EAEA;;;;;;;;;;;;;;;;;;;iBAoBc,UAAU,OAAO,iBAAiB,MAAM,IAAI;UAgE3C;;EAEf;;EAEA;;EAEA;;EAEA,aAAa,MAAM;;EAEnB;;EAEA;;;;;;;;;;;;;;iBAec,QAAQ,OAAO,eAAe,MAAM,IAAI"}
@@ -800,6 +800,7 @@ function useOxyApp() {
800
800
  if (!ctx) throw new Error("useOxyApp must be called inside <OxyAppProvider>");
801
801
  return {
802
802
  projectId: ctx.resolved?.projectId,
803
+ appId: ctx.resolved?.appId,
803
804
  appSlug: ctx.resolved?.appSlug,
804
805
  orgSlug: ctx.resolved?.orgSlug,
805
806
  fetcher: ctx.fetcher
@@ -974,7 +975,7 @@ function useFunction(name) {
974
975
  * inputs (e.g. a user-picked filter value) are available.
975
976
  */
976
977
  function useSemanticQuery(input, opts = {}) {
977
- const { projectId, fetcher } = useOxyApp();
978
+ const { projectId, appId, fetcher } = useOxyApp();
978
979
  const enabled = opts.enabled !== false;
979
980
  const debug = opts.debug === true;
980
981
  const inputKey = react.useMemo(() => JSON.stringify(input), [input]);
@@ -1009,7 +1010,11 @@ function useSemanticQuery(input, opts = {}) {
1009
1010
  measures: input.measures ?? [],
1010
1011
  time_dimensions: input.time_dimensions ?? [],
1011
1012
  filters: input.filters ?? [],
1012
- ...input.limit != null ? { limit: input.limit } : {}
1013
+ ...input.limit != null ? { limit: input.limit } : {},
1014
+ ...input.scope ? {
1015
+ scope: input.scope,
1016
+ ...appId ? { app: appId } : {}
1017
+ } : {}
1013
1018
  });
1014
1019
  const url = `/api/projects/${projectId}/semantic-query${debug ? "?debug=1" : ""}`;
1015
1020
  fetcher(url, {
@@ -1047,6 +1052,7 @@ function useSemanticQuery(input, opts = {}) {
1047
1052
  }, [
1048
1053
  enabled,
1049
1054
  projectId,
1055
+ appId,
1050
1056
  inputKey,
1051
1057
  debug,
1052
1058
  nonce,
@@ -1586,7 +1592,7 @@ function sleep(ms, signal) {
1586
1592
  * within-limit events are unaffected.
1587
1593
  */
1588
1594
  function useTrackEvent() {
1589
- const { projectId, fetcher } = useOxyApp();
1595
+ const { projectId, appId, fetcher } = useOxyApp();
1590
1596
  const queueRef = react.useRef([]);
1591
1597
  const flushTimerRef = react.useRef(null);
1592
1598
  const flush = react.useCallback(() => {
@@ -1597,7 +1603,10 @@ function useTrackEvent() {
1597
1603
  queueRef.current = [];
1598
1604
  for (const evt of batch) {
1599
1605
  const url = `/api/customer-apps/${projectId}/events`;
1600
- const body = JSON.stringify(evt);
1606
+ const body = JSON.stringify(appId ? {
1607
+ ...evt,
1608
+ app_id: appId
1609
+ } : evt);
1601
1610
  try {
1602
1611
  if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function" && document.visibilityState === "hidden") navigator.sendBeacon(url, new Blob([body], { type: "application/json" }));
1603
1612
  else fetcher(url, {
@@ -1611,7 +1620,11 @@ function useTrackEvent() {
1611
1620
  console.warn("[oxy] useTrackEvent enqueue failed:", e);
1612
1621
  }
1613
1622
  }
1614
- }, [projectId, fetcher]);
1623
+ }, [
1624
+ projectId,
1625
+ fetcher,
1626
+ appId
1627
+ ]);
1615
1628
  react.useEffect(() => {
1616
1629
  if (typeof window === "undefined") return;
1617
1630
  const onHide = () => flush();
@@ -2431,4 +2444,4 @@ Object.defineProperty(exports, 'useTrackEvent', {
2431
2444
  return useTrackEvent;
2432
2445
  }
2433
2446
  });
2434
- //# sourceMappingURL=react-Cas_DVKe.cjs.map
2447
+ //# sourceMappingURL=react-DcT-mUPj.cjs.map