@w6w/embed 0.2.20 → 0.2.22

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 (29) hide show
  1. package/dist/{ModelRoutesManager-1Ac5wcas.js → ModelRoutesManager-BUw_sm-M.js} +2 -2
  2. package/dist/ModelRoutesManager-BUw_sm-M.js.map +1 -0
  3. package/dist/{WorkflowEditor-CmhXHRxi.js → WorkflowEditor-LesBKjb2.js} +194 -186
  4. package/dist/{WorkflowEditor-CmhXHRxi.js.map → WorkflowEditor-LesBKjb2.js.map} +1 -1
  5. package/dist/{apps-ItBvnWX3.js → apps-CYUgEfGf.js} +2 -2
  6. package/dist/{apps-ItBvnWX3.js.map → apps-CYUgEfGf.js.map} +1 -1
  7. package/dist/editor/types.d.ts +2 -0
  8. package/dist/{editor-apps-DkkC7wOQ.js → editor-apps-LZmDWMqf.js} +3 -3
  9. package/dist/{editor-apps-DkkC7wOQ.js.map → editor-apps-LZmDWMqf.js.map} +1 -1
  10. package/dist/{editor-tools-BR27RGto.js → editor-tools-DHyWiG21.js} +49 -40
  11. package/dist/{editor-tools-BR27RGto.js.map → editor-tools-DHyWiG21.js.map} +1 -1
  12. package/dist/editor.mjs +1 -1
  13. package/dist/editors.mjs +67 -60
  14. package/dist/editors.mjs.map +1 -1
  15. package/dist/forms.mjs +272 -269
  16. package/dist/forms.mjs.map +1 -1
  17. package/dist/index.mjs +1 -1
  18. package/dist/lists.mjs +7 -7
  19. package/dist/lists.mjs.map +1 -1
  20. package/dist/rail.mjs +1 -1
  21. package/dist/repos/workflows.d.ts +1 -1
  22. package/dist/repos.mjs +3 -3
  23. package/dist/{spec-export-DGy5ijps.js → spec-export-DGigBUsP.js} +2 -2
  24. package/dist/{spec-export-DGy5ijps.js.map → spec-export-DGigBUsP.js.map} +1 -1
  25. package/dist/{workflows-BZN4Hyz1.js → workflows-BK6IM4if.js} +3 -3
  26. package/dist/{workflows-BZN4Hyz1.js.map → workflows-BK6IM4if.js.map} +1 -1
  27. package/package.json +3 -3
  28. package/src/styles.css +30 -4
  29. package/dist/ModelRoutesManager-1Ac5wcas.js.map +0 -1
package/dist/rail.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as r } from "react/jsx-runtime";
3
3
  import { useMemo as u } from "react";
4
- import { W as d, R as p, P as m, u as f, a as v, e as b, b as h } from "./editor-tools-BR27RGto.js";
4
+ import { W as d, R as p, P as m, u as f, a as v, e as b, b as h } from "./editor-tools-DHyWiG21.js";
5
5
  import { r as P, a as j } from "./project-context-Tvp-La7A.js";
6
6
  const R = () => {
7
7
  };
@@ -79,7 +79,7 @@ export declare function useRunWorkflowMutation(): UseMutationResult<RunState, Er
79
79
  * result distinguish "finished in time" (`200`) from "still going when the
80
80
  * server's own wait timed out" (`202`, a legitimate outcome, not an error).
81
81
  */
82
- export declare function runWorkflowSync(client: W6WClient, id: string, variables: Record<string, unknown>, input?: Record<string, unknown>): Promise<WorkflowRunResult>;
82
+ export declare function runWorkflowSync(client: W6WClient, id: string, variables: Record<string, unknown>, input?: Record<string, unknown>, entry?: string): Promise<WorkflowRunResult>;
83
83
  /**
84
84
  * T2.1.1 — the ENQUEUE half only: starts a run and returns its handle
85
85
  * immediately, without polling it to terminal. A genuine sibling of
package/dist/repos.mjs CHANGED
@@ -2,10 +2,10 @@
2
2
  var S = Object.defineProperty;
3
3
  var M = (e, t, s) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
4
4
  var l = (e, t, s) => M(e, typeof t != "symbol" ? t + "" : t, s);
5
- import { E as he, H as De, R as Te, S as we, a as Ie, c as _e, b as Pe, d as Ue, f as Be, e as Ne, g as We, h as Le, i as Ve, j as Oe, k as He, l as je, m as Ge, n as ze, o as Ye, p as Xe, q as Ze, r as Je, s as $e, t as et, u as tt, v as st, w as nt, x as at, y as ot, z as ut, A as rt, B as it, C as lt, D as ct, F as yt, G as dt, I as ft, J as gt, K as pt, L as St, M as Mt, N as Ct, O as Kt, P as mt, Q as Qt, T as Et, U as vt, V as At, W as xt, X as Ft, Y as qt, Z as Rt, _ as bt, $ as kt, a0 as ht, a1 as Dt, a2 as Tt, a3 as wt } from "./workflows-BZN4Hyz1.js";
6
- import { c as _t, u as Pt, a as Ut, b as Bt, d as Nt, e as Wt, f as Lt, g as Vt, h as Ot, v as Ht, i as jt } from "./spec-export-DGy5ijps.js";
5
+ import { E as he, H as De, R as Te, S as we, a as Ie, c as _e, b as Pe, d as Ue, f as Be, e as Ne, g as We, h as Le, i as Ve, j as Oe, k as He, l as je, m as Ge, n as ze, o as Ye, p as Xe, q as Ze, r as Je, s as $e, t as et, u as tt, v as st, w as nt, x as at, y as ot, z as ut, A as rt, B as it, C as lt, D as ct, F as yt, G as dt, I as ft, J as gt, K as pt, L as St, M as Mt, N as Ct, O as Kt, P as mt, Q as Qt, T as Et, U as vt, V as At, W as xt, X as Ft, Y as qt, Z as Rt, _ as bt, $ as kt, a0 as ht, a1 as Dt, a2 as Tt, a3 as wt } from "./workflows-BK6IM4if.js";
6
+ import { c as _t, u as Pt, a as Ut, b as Bt, d as Nt, e as Wt, f as Lt, g as Vt, h as Ot, v as Ht, i as jt } from "./spec-export-DGigBUsP.js";
7
7
  import { l as zt, r as Yt, s as Xt, a as Zt, w as Jt } from "./step-tests-B4E4W3ly.js";
8
- import { e as es, f as ts, g as ss, h as ns, i as as, j as os, b as us, d as rs, k as is, u as ls, a as cs, c as ys } from "./apps-ItBvnWX3.js";
8
+ import { e as es, f as ts, g as ss, h as ns, i as as, j as os, b as us, d as rs, k as is, u as ls, a as cs, c as ys } from "./apps-CYUgEfGf.js";
9
9
  import { l as fs, s as gs, a as ps, u as Ss, b as Ms, c as Cs, d as Ks, e as ms, f as Qs, g as Es, h as vs, i as As, v as xs } from "./vault-BSEWhMYC.js";
10
10
  import { d as qs, e as Rs, f as bs, g as ks, h as hs, u as Ds, i as Ts, j as ws, k as Is, b as _s, c as Ps, l as Us, a as Bs } from "./spec-import-SWOonsNr.js";
11
11
  import { D as Ws, d as Ls, a as Vs, b as Os, g as Hs, l as js, c as Gs, e as zs, u as Ys, f as Xs, h as Zs, i as Js, j as $s, k as en, m as tn, n as sn, o as nn, p as an } from "./data-stores-UeQvwVCa.js";
@@ -2,7 +2,7 @@ import { useQueryClient as c, useMutation as l, useQuery as w } from "@tanstack/
2
2
  import { path as u } from "@w6w/sdk";
3
3
  import { u as i } from "./client-context-CX61Bgw-.js";
4
4
  import { i as y, a as d } from "./callables-tOlflvbl.js";
5
- import { o as p, a2 as b } from "./workflows-BZN4Hyz1.js";
5
+ import { o as p, a2 as b } from "./workflows-BK6IM4if.js";
6
6
  const h = (t) => d("endpoint", t), m = (t) => d("function", t), a = {
7
7
  function: "functions",
8
8
  workflow: "workflows",
@@ -186,4 +186,4 @@ export {
186
186
  N as u,
187
187
  $ as v
188
188
  };
189
- //# sourceMappingURL=spec-export-DGy5ijps.js.map
189
+ //# sourceMappingURL=spec-export-DGigBUsP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spec-export-DGy5ijps.js","sources":["../src/repos/versions.ts","../src/repos/constants.ts","../src/repos/spec-export.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `constants` domain repo — account-level, read-only values set by an\n * administrator and referenced as `{{ const.<name> }}`. There is no write\n * route; the server derives the account from the token.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface Constant {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"json\";\n value: unknown;\n description: string;\n /** Computed by the server (e.g. `account_id`), not stored. */\n derived: boolean;\n}\n\n/** Query key for the constants list. */\nexport function constantsKey() {\n return [\"constants\"] as const;\n}\n\n/** The account's constants (read-only). */\nexport function useConstantsQuery() {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: constantsKey(),\n queryFn: async () => {\n const res = await apiClient.request<{ constants: Constant[] }>({\n method: \"GET\",\n path: \"/constants\",\n });\n return res.body.constants;\n },\n });\n}\n","/**\n * The `/<collection>/:id/spec` export repo (T3.3.1) — the Settings rail's Export\n * button. A NEW file, deliberately kept out of `repos/functions.ts` /\n * `repos/endpoints.ts` (T3.1.1 owns both), exactly as T3.2.1 put `/spec/import` in\n * its own `repos/spec-import.ts` for the same reason — the two nodes never\n * collide on the same file.\n *\n * **Goes through `W6WClient.request<T>()`, never `apiClient.console.*`.** There\n * is no SDK method for this route, exactly as `repos/spec-import.ts`'s own\n * docblock records for the sibling `/spec/import` route.\n *\n * `useSpecQuery` is gated on the caller's `enabled` flag (the export modal's own\n * open state) AND `collection !== null` — never on `ctx.kind` alone, and never\n * on mount: the contract pins that opening the Settings panel must issue ZERO\n * `/spec` requests, and exactly one fires per Export click.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The collections that carry a `/spec` export route — `specCollectionForKind`\n * (`../lib/rail-settings.ts`) is the sole producer of this type's values. */\nexport type SpecCollection = \"functions\" | \"endpoints\" | \"workflows\";\n\n/**\n * Mirrors T2.1.1's `SpecDocument`, also mirrored by `repos/spec-import.ts`'s\n * `SpecImportDocument` for the sibling import route: the portable document a\n * `GET /<kind>/:id/spec` export produces. Not a bare `FunctionDef`/`EndpointDef`\n * — `id` is deleted server-side (`admin/spec.ts:96-108`) and connection/var\n * references ride as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/**\n * `GET /<collection>/:id/spec`. `collection` is `null` for a kind the Export\n * button never renders on (`specCollectionForKind`'s `connection`\n * arm) — passing `null` disables the query regardless of `enabled`, so a\n * caller need not re-derive that guard itself.\n */\nexport function useSpecQuery(collection: SpecCollection | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: [\"spec\", collection, id],\n queryFn: async () => {\n const res = await apiClient.request<{ spec: SpecDocument }>({\n method: \"GET\",\n path: path`/${collection as SpecCollection}/${id}/spec`,\n });\n return res.body.spec;\n },\n enabled: enabled && collection !== null,\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys","constantsKey","useConstantsQuery","useSpecQuery","collection"],"mappings":";;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,M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Q;AAAA,MACR,MAAMG,KAAQoB,CAA4B,IAAIlC,CAAE;AAAA,IAAA,CACjD,GACU,KAAK;AAAA,IAElB,SAASU,KAAWwB,MAAe;AAAA,EAAA,CACpC;AACH;"}
1
+ {"version":3,"file":"spec-export-DGigBUsP.js","sources":["../src/repos/versions.ts","../src/repos/constants.ts","../src/repos/spec-export.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `constants` domain repo — account-level, read-only values set by an\n * administrator and referenced as `{{ const.<name> }}`. There is no write\n * route; the server derives the account from the token.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface Constant {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"json\";\n value: unknown;\n description: string;\n /** Computed by the server (e.g. `account_id`), not stored. */\n derived: boolean;\n}\n\n/** Query key for the constants list. */\nexport function constantsKey() {\n return [\"constants\"] as const;\n}\n\n/** The account's constants (read-only). */\nexport function useConstantsQuery() {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: constantsKey(),\n queryFn: async () => {\n const res = await apiClient.request<{ constants: Constant[] }>({\n method: \"GET\",\n path: \"/constants\",\n });\n return res.body.constants;\n },\n });\n}\n","/**\n * The `/<collection>/:id/spec` export repo (T3.3.1) — the Settings rail's Export\n * button. A NEW file, deliberately kept out of `repos/functions.ts` /\n * `repos/endpoints.ts` (T3.1.1 owns both), exactly as T3.2.1 put `/spec/import` in\n * its own `repos/spec-import.ts` for the same reason — the two nodes never\n * collide on the same file.\n *\n * **Goes through `W6WClient.request<T>()`, never `apiClient.console.*`.** There\n * is no SDK method for this route, exactly as `repos/spec-import.ts`'s own\n * docblock records for the sibling `/spec/import` route.\n *\n * `useSpecQuery` is gated on the caller's `enabled` flag (the export modal's own\n * open state) AND `collection !== null` — never on `ctx.kind` alone, and never\n * on mount: the contract pins that opening the Settings panel must issue ZERO\n * `/spec` requests, and exactly one fires per Export click.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The collections that carry a `/spec` export route — `specCollectionForKind`\n * (`../lib/rail-settings.ts`) is the sole producer of this type's values. */\nexport type SpecCollection = \"functions\" | \"endpoints\" | \"workflows\";\n\n/**\n * Mirrors T2.1.1's `SpecDocument`, also mirrored by `repos/spec-import.ts`'s\n * `SpecImportDocument` for the sibling import route: the portable document a\n * `GET /<kind>/:id/spec` export produces. Not a bare `FunctionDef`/`EndpointDef`\n * — `id` is deleted server-side (`admin/spec.ts:96-108`) and connection/var\n * references ride as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/**\n * `GET /<collection>/:id/spec`. `collection` is `null` for a kind the Export\n * button never renders on (`specCollectionForKind`'s `connection`\n * arm) — passing `null` disables the query regardless of `enabled`, so a\n * caller need not re-derive that guard itself.\n */\nexport function useSpecQuery(collection: SpecCollection | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: [\"spec\", collection, id],\n queryFn: async () => {\n const res = await apiClient.request<{ spec: SpecDocument }>({\n method: \"GET\",\n path: path`/${collection as SpecCollection}/${id}/spec`,\n });\n return res.body.spec;\n },\n enabled: enabled && collection !== null,\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys","constantsKey","useConstantsQuery","useSpecQuery","collection"],"mappings":";;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,MAAeC,EAAY,YAAYD,CAAE,GAUxDG,IAAiF;AAAA,EACrF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAqDMC,IAA8D;AAAA,EAClE,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,SAASC,EAAYC,GAA2BN,GAAY;AACjE,SAAO,CAAC,YAAYM,GAAMN,CAAE;AAC9B;AAEO,SAASO,EAAWD,GAA2BN,GAAYQ,GAA8B;AAC9F,SAAO,CAAC,WAAWF,GAAMN,GAAIQ,CAAa;AAC5C;AAOO,SAASC,EAAiBH,GAA2BN,GAAYU,GAAkB;AACxF,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUR,EAAYC,GAAMN,CAAE;AAAA,IAC9B,SAAS,Y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AA,QACR,MAAMG,KAAQX,EAAgBG,CAAI,CAAC,IAAIiB,EAAK,EAAE,aAAa,OAAOA,EAAK,aAAa,CAAC,IAAInB,EAAoBE,CAAI,CAAC;AAAA,QAClH,MAAM,CAAA;AAAA,MAAC,CACR,GACU;AAAA,IACb;AAAA,IACA,WAAW,MAAMY,EAAG,kBAAkB,EAAE,UAAUY,EAAY,MAAM;AAAA,EAAA,CACrE;AACH;AC/UO,SAASC,IAAe;AAC7B,SAAO,CAAC,WAAW;AACrB;AAGO,SAASC,IAAoB;AAClC,QAAMrB,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUkB,EAAA;AAAA,IACV,SAAS,aACK,MAAMpB,EAAU,QAAmC;AAAA,MAC7D,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,CACP,GACU,KAAK;AAAA,EAClB,CACD;AACH;ACSO,SAASsB,EAAaC,GAAmClC,GAAYU,GAAkB;AAC5F,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAU,CAAC,QAAQqB,GAAYlC,CAAE;AAAA,IACjC,SAAS,aACK,MAAMW,EAAU,QAAgC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMG,KAAQoB,CAA4B,IAAIlC,CAAE;AAAA,IAAA,CACjD,GACU,KAAK;AAAA,IAElB,SAASU,KAAWwB,MAAe;AAAA,EAAA,CACpC;AACH;"}
@@ -462,8 +462,8 @@ function Qt() {
462
462
  onSettled: () => e.invalidateQueries({ queryKey: E.root })
463
463
  });
464
464
  }
465
- function Ut(t, e, n, o) {
466
- return t.workflows.run(e, { variables: n, input: o, wait: !0 });
465
+ function Ut(t, e, n, o, r) {
466
+ return t.workflows.run(e, { variables: n, input: o, entry: r, wait: !0 });
467
467
  }
468
468
  function at(t, e, n, o) {
469
469
  return t.workflows.run(e, { variables: n, input: o, allowUnpublished: !0 }).then((r) => ({ runId: r.runId }));
@@ -620,4 +620,4 @@ export {
620
620
  bt as y,
621
621
  kt as z
622
622
  };
623
- //# sourceMappingURL=workflows-BZN4Hyz1.js.map
623
+ //# sourceMappingURL=workflows-BK6IM4if.js.map