@w6w/embed 0.2.34 → 0.2.35
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/dist/{CreateFunctionModal-glk2zg1r.js → CreateFunctionModal-CYNHJUGJ.js} +3 -3
- package/dist/{CreateFunctionModal-glk2zg1r.js.map → CreateFunctionModal-CYNHJUGJ.js.map} +1 -1
- package/dist/{DocumentFormModal-B3OkvI5v.js → DocumentFormModal-CLmdGx34.js} +2 -2
- package/dist/{DocumentFormModal-B3OkvI5v.js.map → DocumentFormModal-CLmdGx34.js.map} +1 -1
- package/dist/ImportSpecModal-BzEyiNWD.js +378 -0
- package/dist/ImportSpecModal-BzEyiNWD.js.map +1 -0
- package/dist/WorkflowEditor-CxTuK8_d.js +1272 -0
- package/dist/WorkflowEditor-CxTuK8_d.js.map +1 -0
- package/dist/{apps-CFWdgGst.js → apps-CyEszfIu.js} +33 -33
- package/dist/{apps-CFWdgGst.js.map → apps-CyEszfIu.js.map} +1 -1
- package/dist/callable-row-actions-BPBPflMn.js +56 -0
- package/dist/callable-row-actions-BPBPflMn.js.map +1 -0
- package/dist/callables-dLF2IcwA.js +317 -0
- package/dist/callables-dLF2IcwA.js.map +1 -0
- package/dist/chrome/TagEditor.d.ts +6 -1
- package/dist/chrome/workspace.d.ts +16 -0
- package/dist/documents-hgltn0xe.js +1017 -0
- package/dist/documents-hgltn0xe.js.map +1 -0
- package/dist/draft.mjs +1 -1
- package/dist/editor/WaitingForm.d.ts +19 -0
- package/dist/{editor-apps-ShwCmvLY.js → editor-apps-DsGrGKfe.js} +3 -3
- package/dist/{editor-apps-ShwCmvLY.js.map → editor-apps-DsGrGKfe.js.map} +1 -1
- package/dist/{editor-tools-rY9nddqr.js → editor-tools-Ct7YPPj8.js} +682 -784
- package/dist/editor-tools-Ct7YPPj8.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +18 -18
- package/dist/{endpoints-zOuwci2U.js → endpoints-DJxXRh-I.js} +12 -12
- package/dist/{endpoints-zOuwci2U.js.map → endpoints-DJxXRh-I.js.map} +1 -1
- package/dist/forms.mjs +1 -1
- package/dist/index.mjs +140 -115
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-row-actions.d.ts +17 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/run-event-stream.d.ts +122 -0
- package/dist/lib/tag-editor.d.ts +6 -0
- package/dist/lib/workflow-live-run.d.ts +7 -0
- package/dist/lib/workflow-validity.d.ts +7 -1
- package/dist/lib.mjs +52 -47
- package/dist/lists/CallableKindList.d.ts +12 -0
- package/dist/lists/CallableRowParts.d.ts +8 -1
- package/dist/lists/EndpointList.d.ts +3 -0
- package/dist/lists/FunctionList.d.ts +3 -0
- package/dist/lists/WorkflowList.d.ts +3 -0
- package/dist/lists.d.ts +1 -0
- package/dist/lists.mjs +1589 -1513
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/callables.d.ts +25 -0
- package/dist/repos/documents.d.ts +9 -1
- package/dist/repos/saved-file-names.d.ts +10 -0
- package/dist/repos/workflows.d.ts +19 -13
- package/dist/repos.mjs +333 -328
- package/dist/{setup-incomplete-BHs3Lpfy.js → setup-incomplete-6PAbN0EW.js} +50 -49
- package/dist/setup-incomplete-6PAbN0EW.js.map +1 -0
- package/dist/spec-import-BKyfhTYG.js +200 -0
- package/dist/spec-import-BKyfhTYG.js.map +1 -0
- package/dist/{use-callable-draft-w4tDTYcb.js → use-callable-draft-7HwfTuYQ.js} +3 -3
- package/dist/{use-callable-draft-w4tDTYcb.js.map → use-callable-draft-7HwfTuYQ.js.map} +1 -1
- package/package.json +3 -3
- package/src/styles.css +43 -0
- package/dist/ImportSpecModal-SQvTwtcX.js +0 -252
- package/dist/ImportSpecModal-SQvTwtcX.js.map +0 -1
- package/dist/WorkflowEditor-D2EfEP-U.js +0 -1201
- package/dist/WorkflowEditor-D2EfEP-U.js.map +0 -1
- package/dist/callable-record-Bhxim8C1.js +0 -14
- package/dist/callable-record-Bhxim8C1.js.map +0 -1
- package/dist/callables-B49tS2vv.js +0 -297
- package/dist/callables-B49tS2vv.js.map +0 -1
- package/dist/editor-tools-rY9nddqr.js.map +0 -1
- package/dist/setup-incomplete-BHs3Lpfy.js.map +0 -1
- package/dist/spec-import-CPbDnnuv.js +0 -272
- package/dist/spec-import-CPbDnnuv.js.map +0 -1
- package/dist/workflows-RhR8kwt7.js +0 -667
- package/dist/workflows-RhR8kwt7.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-incomplete-BHs3Lpfy.js","sources":["../src/lib/binding-problems.ts","../src/lib/workflow-nodes.ts","../src/lib/workflow-validity.ts","../src/lib/workflow-settings.ts","../src/lib/trigger-preview.ts","../src/lib/setup-incomplete.ts"],"sourcesContent":["// Pure detection of dangling connection bindings (R5). No React, no I/O: call sites gather the\n// inputs (per-app connection lists, the callable's enabled flag, draft dirtiness) and render.\n\nexport type AppConnections =\n | { state: \"loading\" }\n | { state: \"error\" }\n | { state: \"ready\"; ids: ReadonlySet<string> };\n\nexport interface BindingSite {\n id: string;\n uses?: { app?: string; connection?: string | null; connectionRef?: string };\n}\n\nexport interface BindingProblem {\n siteId: string;\n app: string;\n connection: string;\n code: \"unknown_connection\";\n}\n\n/** A problem iff app + connection are non-empty and the app's list is `ready` without the id.\n * `loading`, `error` and `undefined` (internal app / not fetched) never report — no false red. */\nexport function findBindingProblems(\n sites: readonly BindingSite[],\n byApp: (app: string) => AppConnections | undefined,\n connections?: Record<string, { app: string; connection: string | null }>,\n): BindingProblem[] {\n const out: BindingProblem[] = [];\n for (const site of sites) {\n const app = site.uses?.app;\n const ref = site.uses?.connectionRef;\n const binding =\n ref && connections && Object.hasOwn(connections, ref) ? connections[ref] : undefined;\n const connection =\n ref === undefined\n ? site.uses?.connection\n : binding && binding.app === app\n ? binding.connection\n : undefined;\n if (typeof app !== \"string\" || app === \"\") continue;\n if (typeof connection !== \"string\" || connection === \"\") continue;\n const conns = byApp(app);\n if (conns?.state !== \"ready\") continue;\n if (conns.ids.has(connection)) continue;\n out.push({ siteId: site.id, app, connection, code: \"unknown_connection\" });\n }\n return out;\n}\n\nexport interface DisabledBannerInput {\n enabled: boolean | undefined;\n problemCount: number;\n dirty: boolean;\n hadProblems: boolean;\n}\n\nexport interface DisabledBannerState {\n show: boolean;\n canEnable: boolean;\n problemCount: number;\n}\n\n/** Show iff disabled AND (problems now OR problems seen this mount). Enable only once every\n * binding is fixed AND saved. `enabled` undefined (versions not loaded) never shows. */\nexport function disabledBannerState(input: DisabledBannerInput): DisabledBannerState {\n const show = input.enabled === false && (input.problemCount > 0 || input.hadProblems);\n return {\n show,\n canEnable: show && input.problemCount === 0 && !input.dirty,\n problemCount: input.problemCount,\n };\n}\n","/** The vertex array of a workflow definition, in either shape — `nodes` wins, `steps` is the legacy name. */\nexport function workflowNodes<T = unknown>(\n def: { nodes?: T[]; steps?: T[] } | null | undefined,\n): T[] {\n return def?.nodes ?? def?.steps ?? [];\n}\n","import { workflowNodes } from \"./workflow-nodes.ts\";\n\n/**\n * The publish-time validity gate (`logs/decisions.jsonl` row 9, verbatim):\n *\n * > a step is valid iff (app+action set, or function id set) and all its\n * > required params are filled (reuse `requiredParamsFilled`,\n * > `StepBuilderModal.tsx:577-590`) and, where `testRequired` is set for the\n * > app, its saved test has passed. The workflow is valid iff a trigger exists\n * > and every step is valid. Graph well-formedness (orphaned/unreachable\n * > nodes, dangling edges) is explicitly OUT of scope for this project.\n *\n * **Amended 2026-10-29: no trigger NODE is required.** A workflow without one is\n * a manual workflow (`rfcs/workflow.md:114`): it already runs from the editor's\n * Run button and from code, and the server publishes it, so gating Publish on a\n * trigger node only blocked a workflow that works. The workflow is now valid iff\n * it has at least one step and every step is valid.\n *\n * **Amended 2026-11-01: an app trigger node is never test-gated.** A node with\n * `uses.trigger: true` runs when its app reports the event; its Test tab has\n * nothing to run by hand (\"Publish the workflow to start listening\",\n * `AppTriggerTestNote` in `@w6w/ui`), so it can never hold a saved passing\n * test. Gating it on one made every app-triggered workflow unpublishable.\n *\n * **Amended 2026-11-02: tests never gate publishing.** Successful runs and saved\n * test records can disagree, and users may publish without testing. Only the\n * target and required configuration are checked; test history is advisory.\n *\n * Pure and testable by design: `WorkflowsPage.tsx` is JSX, which Node 24's\n * type-stripping cannot parse, so nothing in it can be loaded by `node --test`\n * (same shape as `src/lib/workflow-save.ts` + its `.test.ts`). This module\n * cannot import `@w6w/ui`/`@w6w/ui/flow` either way: `@w6w/ui`'s\n * `package.json` `exports[\".\"]` resolves to raw `./src/index.ts`, which\n * re-exports `StepBuilderModal.tsx` — a `.tsx` file — so `node --test` throws\n * `ERR_UNKNOWN_FILE_EXTENSION` the moment anything here imports it. Instead,\n * the two functions the pinned predicate reuses\n * (`requiredParamsFilled`/`isTestRequired`) are **caller-injected** on\n * `ValidityContext` — `WorkflowsPage.tsx` (unaffected by the JSX constraint)\n * imports the real ones from `@w6w/ui` and passes them in.\n *\n * `ActionParamLike`/`WorkflowStepLike`/`WorkflowLike` below are this file's\n * own minimal local types (see `rfcs/workflow.md` §\"Step\" for the real shape,\n * `rfcs/function.md` for the `uses.function` arm).\n */\n\n/** A declared action/internal-node param, just enough of it for this gate. */\nexport interface ActionParamLike {\n key: string;\n type: string;\n required?: boolean;\n default?: unknown;\n children?: ActionParamLike[];\n}\n\n/** A workflow graph step, just enough of it for this gate. */\nexport interface WorkflowStepLike {\n id: string;\n uses?: {\n app?: string;\n action?: string;\n connection?: string | null;\n connectionRef?: string;\n /** The \"or a function id\" arm (`rfcs/function.md:49,260`) — `Step.uses.function`. */\n function?: string;\n /** An app trigger node (`uses.trigger: true`): never gated on a saved test. */\n trigger?: boolean;\n };\n with?: Record<string, unknown>;\n}\n\n/** A workflow definition, just enough of it for this gate. */\nexport interface WorkflowLike {\n nodes?: WorkflowStepLike[];\n steps?: WorkflowStepLike[];\n /**\n * Present on real definitions, never read here — graph well-formedness\n * (orphaned/unreachable nodes, dangling edges) is explicitly out of scope\n * for the publish gate (`logs/decisions.jsonl` row 9).\n */\n edges?: unknown;\n}\n\n/**\n * Everything `stepValid`/`workflowValid`/`invalidReason` need that this pure\n * module cannot compute or import itself — see the module docstring for why\n * each field is caller-built rather than derived in here.\n */\nexport interface ValidityContext {\n /** Declared params for a step's target, keyed `` `${app}::${action}` ``. */\n actionParamsByKey: Record<string, ActionParamLike[]>;\n /** @deprecated Kept for caller compatibility; app test policy does not gate publishing. */\n appsById: Record<string, unknown>;\n /** @deprecated Kept for caller compatibility; test results do not gate publishing. */\n testStatus: Record<string, boolean>;\n /** `@w6w/ui`'s `requiredParamsFilled`, injected (see module docstring). */\n requiredParamsFilled: (params: ActionParamLike[], values: Record<string, unknown>) => boolean;\n /** @deprecated Kept for caller compatibility; never consulted for publishing. */\n isTestRequired: (app: unknown) => boolean;\n}\n\n/** Which of the pinned predicate's checks a step fails, or `null` when it's valid. */\ntype StepFailure = \"target missing\" | \"required params\";\n\n/**\n * The single place the pinned predicate's branching lives — `stepValid` and\n * `invalidReason` both read this rather than re-deriving the same checks.\n */\nfunction stepFailure(step: WorkflowStepLike, ctx: ValidityContext): StepFailure | null {\n const uses = step.uses;\n // A function-targeted step is valid on presence alone (T5.1.1 owns a\n // Function's own runnability separately — not duplicated here).\n if (uses?.function) return null;\n if (!uses?.app || !uses?.action) return \"target missing\";\n const params = ctx.actionParamsByKey[`${uses.app}::${uses.action}`] ?? [];\n const values = step.with ?? {};\n if (!ctx.requiredParamsFilled(params, values)) return \"required params\";\n return null;\n}\n\n/** Is this one step valid, per the pinned predicate? */\nexport function stepValid(step: WorkflowStepLike, ctx: ValidityContext): boolean {\n return stepFailure(step, ctx) === null;\n}\n\n/**\n * Is the whole workflow valid? It must have at least one step and every step\n * must be individually valid — a trigger node is not required, and nothing\n * about graph well-formedness is checked (this never reads `workflow.edges`).\n */\nexport function workflowValid(workflow: WorkflowLike, ctx: ValidityContext): boolean {\n const steps = workflowNodes(workflow);\n return steps.length > 0 && steps.every((step) => stepValid(step, ctx));\n}\n\n/**\n * `null` when the workflow is valid; otherwise names the cause — `\"no steps\"`,\n * or the id of the first invalid step in declared order plus which check it\n * fails.\n */\nexport function invalidReason(workflow: WorkflowLike, ctx: ValidityContext): string | null {\n const steps = workflowNodes(workflow);\n if (steps.length === 0) return \"no steps\";\n for (const step of steps) {\n const failure = stepFailure(step, ctx);\n if (failure) return `${step.id}: ${failure}`;\n }\n return null;\n}\n\n/** One reason the workflow cannot be published: the node it is about and how to fix it. */\nexport interface PublishProblem {\n /** The node's id, or `null` for a workflow-wide problem (`\"no steps\"`). */\n stepId: string | null;\n check: StepFailure | \"no steps\";\n /** Names the node and says how to fix it — shown verbatim in the tooltip and the list. */\n message: string;\n}\n\nconst FIX_TEXT: Record<StepFailure, string> = {\n \"target missing\": \"has no action or function chosen. Open it and pick what it runs.\",\n \"required params\": \"has required fields left empty. Open it and fill them in.\",\n};\n\n/**\n * Every publish problem, in declared node order — the full list `invalidReason`\n * stops at the first of. Empty iff `workflowValid`.\n */\nexport function publishProblems(workflow: WorkflowLike, ctx: ValidityContext): PublishProblem[] {\n const steps = workflowNodes(workflow);\n if (steps.length === 0) {\n return [\n {\n stepId: null,\n check: \"no steps\",\n message: \"The workflow has no nodes. Add a trigger or a step.\",\n },\n ];\n }\n const out: PublishProblem[] = [];\n for (const step of steps) {\n const failure = stepFailure(step, ctx);\n if (failure) {\n out.push({ stepId: step.id, check: failure, message: `${step.id} ${FIX_TEXT[failure]}` });\n }\n }\n return out;\n}\n\n/** What the header Publish button's `disabled` reads, each cause kept apart for its reason. */\nexport interface PublishGate {\n /** No project to publish into. */\n projectMissing: boolean;\n /** The draft has not loaded, is saving, or is switching context. */\n loading: boolean;\n /** The draft refuses to save (and so to publish): its reason, verbatim. */\n saveBlockedReason: string | null;\n /** The node catalog the validity gate needs has not arrived yet. */\n catalogLoading: boolean;\n problems: readonly PublishProblem[];\n publishing: boolean;\n}\n\n/**\n * Why Publish is disabled, or `null` when it is enabled. Every disabled state\n * has a reason, so the button never greys out silently.\n */\nexport function publishDisabledReason(g: PublishGate): string | null {\n if (g.publishing) return \"Publishing…\";\n if (g.projectMissing) return \"Can't publish: no project is selected.\";\n if (g.saveBlockedReason) return `Can't publish: ${g.saveBlockedReason}`;\n if (g.loading) return \"Can't publish yet: the workflow is still loading or saving.\";\n if (g.catalogLoading) return \"Can't publish yet: the node catalog is still loading.\";\n if (g.problems.length === 0) return null;\n const head =\n g.problems.length === 1\n ? \"Can't publish — fix this first:\"\n : `Can't publish — fix these ${g.problems.length} problems first:`;\n return [head, ...g.problems.map((p) => `• ${p.message}`)].join(\"\\n\");\n}\n","/**\n * The two pure decisions behind a workflow's authoring settings\n * (`rfcs/workflow.md` — \"Amendment — 2026-07-29: authoring presentation\").\n *\n * `settings` rides inside the workflow **definition** — the same JSON document\n * that already carries `steps` — so there is no column, no migration and no\n * server change behind it. What needs pinning is not the storage but the two\n * readings that can silently corrupt a definition, and both live here rather\n * than in `WorkflowsPage.tsx` so they are executable: that file is JSX, which\n * Node 24's type-stripping cannot parse, so nothing in it can be loaded by\n * `node --test`. Same shape as `src/lib/workflow-save.ts` + its `.test.ts`.\n */\nimport type { WorkflowStatus } from \"@w6w/sdk\";\n\n/**\n * Read a workflow definition's `status` field as the real three-state value.\n *\n * `WorkflowsPage.tsx` used to coerce this with `status === \"active\" ? \"active\" :\n * \"draft\"` — a two-way ternary that silently collapsed a freshly-archived\n * workflow back down to `\"draft\"`, which would have reproduced the same bug one\n * layer up in the archive/delete button-swap (an archived workflow would render\n * Archive again instead of Delete). `unknown` because the source is parsed JSON,\n * not a validated value — anything that isn't exactly `\"active\"` or `\"archived\"`\n * reads as `\"draft\"`, same fallback the old coercion used for a missing/garbage\n * status.\n */\nexport function readWorkflowStatus(status: unknown): WorkflowStatus {\n if (status === \"active\" || status === \"archived\") return status;\n return \"draft\";\n}\n\n/** Authoring presentation for one workflow. Declarative only — the engine ignores it. */\nexport type WorkflowSettings = {\n /** Persist edits without an explicit save. Omitted ⇒ **true**. */\n autoSave?: boolean;\n /** Persist step coordinates and `viewport` on save. Omitted ⇒ **true**. */\n savePosition?: boolean;\n /** The canvas camera, written by the editor — never by the settings modal. */\n viewport?: { x: number; y: number; zoom: number };\n};\n\n/** Both flags resolved against their defaults. */\nexport type EffectiveWorkflowSettings = {\n autoSave: boolean;\n savePosition: boolean;\n};\n\n/**\n * The effective flags for a workflow, applying the **true-by-default** rule.\n *\n * ⚠️ Both flags are `true` when omitted. That is deliberately *unlike* the house\n * convention `ports` and `onError` follow, where an absent field reproduces\n * prior behaviour: here the product requires both features on by default, so an\n * absent `settings` object means auto-save **on** and positions **persisted**.\n * The RFC states it three ways and names `?? false` as a contradiction. Only an\n * explicit `false` turns a feature off — hence `!== false`, which also refuses\n * to read `null`, `0` or `\"false\"` out of a hand-edited definition as \"off\".\n *\n * Takes `unknown` because the caller's source is parsed JSON, not a validated\n * value; every non-object reads as \"no flags set\", i.e. both on.\n */\nexport function readSettings(settings: unknown): EffectiveWorkflowSettings {\n const s = settings as WorkflowSettings | undefined;\n return {\n autoSave: s?.autoSave !== false,\n savePosition: s?.savePosition !== false,\n };\n}\n\n/**\n * Set one flag, returning the `settings` object to store.\n *\n * Two rules, both about *not* writing more than was asked:\n *\n * 1. **The default is written as absent.** `true` deletes the key instead of\n * storing `autoSave: true` (the same idiom as an omitted `onError: \"fail\"`).\n * Otherwise merely opening this modal on a legacy workflow and toggling\n * something back would rewrite the definition of every workflow ever\n * authored — and with auto-save on, that write happens by itself.\n * 2. **Everything else survives verbatim**, `viewport` above all: it is the\n * author's saved camera, written by the editor, and a whole-object replace\n * here would silently discard it on the next toggle.\n *\n * Returns `undefined` when nothing is left to store, so the caller drops the\n * key entirely rather than persisting an empty object.\n *\n * The input is `unknown` for the same reason `readSettings`' is — it comes straight\n * out of `JSON.parse`, and the `</>` editor in the very same header lets an author\n * write `\"settings\": \"hello\"`. Spreading that would persist `{\"0\":\"h\",\"1\":\"e\",…}`,\n * and with auto-save on the rewrite would repeat on a debounce, without anyone\n * clicking anything. So anything that is not a plain object reads as \"no flags\n * set\", exactly as it does in `readSettings`.\n */\nexport function writeSetting(\n settings: unknown,\n key: \"autoSave\" | \"savePosition\",\n value: boolean,\n): WorkflowSettings | undefined {\n const prev: WorkflowSettings | undefined =\n typeof settings === \"object\" && settings !== null && !Array.isArray(settings)\n ? (settings as WorkflowSettings)\n : undefined;\n // The copy is load-bearing: a debounced saver keeps payloads across ticks, so a\n // function that mutated `prev` in place would leave a \"has this actually changed?\"\n // comparison looking at one object twice. Never simplify this to `prev ?? {}`.\n const next: WorkflowSettings = { ...prev };\n if (value) delete next[key];\n else next[key] = false;\n return Object.keys(next).length === 0 ? undefined : next;\n}\n","import { workflowNodes } from \"./workflow-nodes.ts\";\n\n/**\n * \"Call from code\" trigger preview (T2.2.1, HITL-2/HITL-4 pinned):\n *\n * > one tab per MANUAL (`@w6w/trigger`) trigger step, in declared order,\n * > labelled `step.displayName ?? step.id`. Webhook/scheduler steps are\n * > excluded — they declare named params, never a generic `fields` array.\n *\n * Pure and testable by design, same shape as `workflow-validity.ts`:\n * `WorkflowDetailPage.tsx`/`WorkflowsPage.tsx` are JSX, which Node 24's\n * type-stripping cannot parse, so nothing in it can be loaded by\n * `node --test`. This module cannot import `@w6w/ui`/`@w6w/ui/flow` either\n * way (`ERR_UNKNOWN_FILE_EXTENSION` — see `workflow-validity.ts`'s docstring).\n * Instead, \"is this step a MANUAL trigger\" and \"read a trigger's declared\n * `fields`\" are **caller-injected** on `TriggerPreviewContext` —\n * `WorkflowsPage.tsx`/`WorkflowDetailPage.tsx` import the real\n * `TRIGGER_APP`/`asFieldDefs` from `@w6w/ui/flow` and pass them in. This file\n * contains no `@w6w/*` app-id string literal.\n *\n * Deliberately narrower than `@w6w/ui/flow`'s own `isTriggerApp`, which also\n * matches `@w6w/webhook`/`@w6w/scheduler` (all three are \"entry nodes\" for the\n * canvas). Those two kinds declare named params, not a generic `fields`\n * array, so they cannot be previewed the same way — the injected predicate a\n * caller supplies here is expected to be the MANUAL-only check\n * (`app === TRIGGER_APP`), not the broader `isTriggerApp`.\n */\n\n/** One field a trigger declares — just enough of `@w6w/ui/flow`'s\n * `TriggerFieldDef` for this preview (structurally compatible, not imported). */\nexport interface TriggerPreviewFieldDef {\n key?: string;\n type?: string;\n required?: boolean;\n default?: unknown;\n}\n\n/** A workflow graph step, just enough of it for this preview. */\nexport interface WorkflowStepLike {\n id: string;\n /** Human-facing step name, when the author set one. Falls back to `id`. */\n displayName?: string;\n uses?: { app?: string; action?: string };\n with?: Record<string, unknown>;\n}\n\n/** A workflow definition, just enough of it for this preview. */\nexport interface WorkflowLike {\n nodes?: WorkflowStepLike[];\n steps?: WorkflowStepLike[];\n}\n\n/**\n * Everything `triggerPreviews` needs that this pure module cannot compute or\n * import itself — see the module docstring for why each field is\n * caller-injected rather than derived in here.\n */\nexport interface TriggerPreviewContext {\n /** Is this step's `uses.app` a MANUAL trigger (`@w6w/trigger`)? Webhook and\n * scheduler steps must answer `false` here even though they are also\n * \"entry nodes\" — they have no generic `fields` array to preview. */\n isManualTrigger: (app: string) => boolean;\n /** `@w6w/ui/flow`'s `asFieldDefs`, injected — reads a step's `with.fields`\n * param value as an array of field definitions. */\n asFieldDefs: (fields: unknown) => TriggerPreviewFieldDef[];\n}\n\n/** One manual trigger's declared fields, ready for the modal's picker. */\nexport interface TriggerPreview {\n id: string;\n /** `step.displayName ?? step.id`. */\n label: string;\n fields: TriggerPreviewFieldDef[];\n}\n\n/**\n * One `TriggerPreview` per manual trigger step in `workflow.steps`, in\n * declared order. Non-manual steps (including webhook/scheduler entry nodes)\n * are excluded. A field with a missing/blank `key` is dropped — mirrors\n * `@w6w/ui/flow`'s `fieldsToParams`, which does the same before turning\n * `TriggerFieldDef[]` into a fillable form.\n */\nexport function triggerPreviews(\n workflow: WorkflowLike,\n ctx: TriggerPreviewContext,\n): TriggerPreview[] {\n const steps = workflowNodes(workflow);\n const previews: TriggerPreview[] = [];\n for (const step of steps) {\n const app = step.uses?.app;\n if (!app || !ctx.isManualTrigger(app)) continue;\n const fields = ctx\n .asFieldDefs(step.with?.fields)\n .filter((f) => typeof f.key === \"string\" && f.key.trim() !== \"\");\n previews.push({ id: step.id, label: step.displayName ?? step.id, fields });\n }\n return previews;\n}\n\n/**\n * A start-payload skeleton for one manual trigger — every declared field at its\n * declared default, so the Run panel opens with the shape the workflow actually\n * expects instead of an empty object the author has to reconstruct by hand.\n *\n * Mirrors `@w6w/ui/flow`'s `seedValues` (which this module cannot import — see\n * the header): an explicit `default` wins; otherwise the empty value for the\n * declared type. Unknown types fall to `\"\"`, matching that function.\n *\n * `undefined` in → `{}`, so a caller can pass a still-loading preview.\n */\nexport function triggerInputSeed(preview: TriggerPreview | undefined): Record<string, unknown> {\n const seed: Record<string, unknown> = {};\n for (const f of preview?.fields ?? []) {\n if (typeof f.key !== \"string\" || f.key.trim() === \"\") continue;\n if (f.default !== undefined) {\n seed[f.key] = f.default;\n continue;\n }\n seed[f.key] = f.type === \"number\" ? 0 : f.type === \"boolean\" ? false : \"\";\n }\n return seed;\n}\n","import { parseTemplate } from \"@w6w/expr\";\n\n// Pure detector for a saved workflow's incomplete setup (plan IF-1 unconfigured shape).\n// No React, no I/O, no @w6w/ui value imports. S2/S3 implement the body; the contract is here.\n\n/** A name list for one category; `ready:false` (loading/errored) means that category is never flagged. */\nexport interface SetupNameList {\n names: string[];\n ready: boolean;\n}\n\nexport interface SetupIncompleteInput {\n /** The parsed saved workflow (nodes, connections, variables, …). */\n workflow: unknown;\n lists: {\n vars: SetupNameList;\n secrets: SetupNameList;\n constants: SetupNameList;\n stores: SetupNameList;\n };\n}\n\n/** Node id -> human labels of what is missing at that node (e.g. `connection \"gmail\"`, `var.x`). */\nexport type SetupIncompleteResult = Record<string, string[]>;\n\nconst VAR_PREFIXES = [\"var.\", \"vars.\"];\nconst CONST_PREFIXES = [\"const.\", \"constants.\"];\nconst STORE_APP = \"@w6w/store\";\n\ntype Category = \"var\" | \"const\" | \"secret\";\ninterface Ref {\n category: Category;\n name: string;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction nameOf(path: string, prefixes: string[]): string | undefined {\n for (const p of prefixes) {\n if (path.startsWith(p)) {\n const name = path.slice(p.length).split(\".\")[0].trim();\n return name === \"\" ? undefined : name;\n }\n }\n return undefined;\n}\n\nfunction pathRef(path: string): Ref | undefined {\n const t = path.trim();\n const v = nameOf(t, VAR_PREFIXES);\n if (v) return { category: \"var\", name: v };\n const c = nameOf(t, CONST_PREFIXES);\n if (c) return { category: \"const\", name: c };\n return undefined;\n}\n\n/** `{ var: \"<path>\" }` operands inside a parsed expr (chains and `{{= … }}` JSONLogic). */\nfunction exprRefs(expr: unknown, out: Ref[]): void {\n if (Array.isArray(expr)) {\n for (const e of expr) exprRefs(e, out);\n } else if (isRecord(expr)) {\n for (const [k, v] of Object.entries(expr)) {\n if (k === \"var\" && typeof v === \"string\") {\n const r = pathRef(v);\n if (r) out.push(r);\n } else exprRefs(v, out);\n }\n }\n}\n\n/** Refs in one string, via the template parser (text outside `{{ }}` never yields a part). */\nfunction stringRefs(s: string, out: Ref[]): void {\n if (!s.includes(\"{{\")) return;\n for (const part of parseTemplate(s)) {\n if (part.kind === \"var\" && typeof part.ref === \"string\") {\n const r = pathRef(part.ref);\n if (r) out.push(r);\n } else if (part.kind === \"secret\" && typeof part.ref === \"string\") {\n const name = part.ref.trim().split(\".\")[0];\n if (name) out.push({ category: \"secret\", name });\n } else if (part.kind === \"expr\") exprRefs(part.expr, out);\n }\n}\n\nfunction walk(v: unknown, out: Ref[]): void {\n if (typeof v === \"string\") stringRefs(v, out);\n else if (Array.isArray(v)) for (const e of v) walk(e, out);\n else if (isRecord(v)) for (const e of Object.values(v)) walk(e, out);\n}\n\n/**\n * Derive what is unconfigured in a saved workflow (plan IF-1 shape), keyed by node id.\n * A category whose list is not `ready` is never flagged.\n */\nexport function findSetupIncomplete(input: SetupIncompleteInput): SetupIncompleteResult {\n const wf = isRecord(input.workflow) ? input.workflow : {};\n const nodes = Array.isArray(wf.nodes) ? wf.nodes : Array.isArray(wf.steps) ? wf.steps : [];\n const conns = isRecord(wf.connections) ? wf.connections : {};\n const local = new Set<string>();\n if (Array.isArray(wf.variables)) {\n for (const v of wf.variables) {\n if (isRecord(v) && typeof v.key === \"string\") local.add(v.key);\n }\n }\n const known = {\n var: input.lists.vars,\n const: input.lists.constants,\n secret: input.lists.secrets,\n };\n const label = { var: \"var\", const: \"const\", secret: \"secret\" } as const;\n const result: SetupIncompleteResult = {};\n for (const node of nodes) {\n if (!isRecord(node) || typeof node.id !== \"string\") continue;\n const items: string[] = [];\n const add = (s: string) => {\n if (!items.includes(s)) items.push(s);\n };\n const uses = isRecord(node.uses) ? node.uses : {};\n const ref = uses.connectionRef;\n if (typeof ref === \"string\" && ref !== \"\" && Object.hasOwn(conns, ref)) {\n const c = conns[ref];\n if (isRecord(c) && (c.connection === null || c.connection === \"\")) {\n add(`connection \"${ref}\"`);\n }\n }\n const withObj = isRecord(node.with) ? node.with : {};\n if (uses.app === STORE_APP && withObj.store === \"\") add(\"store\");\n const refs: Ref[] = [];\n walk(withObj, refs);\n for (const r of refs) {\n const list = known[r.category];\n if (!list.ready) continue;\n if (r.category === \"var\" && local.has(r.name)) continue;\n if (r.category === \"const\" && r.name === \"account_id\") continue;\n if (!list.names.includes(r.name)) add(`${label[r.category]}.${r.name}`);\n }\n if (items.length > 0) result[node.id] = items;\n }\n return result;\n}\n"],"names":["findBindingProblems","sites","byApp","connections","out","site","app","_a","ref","_b","binding","connection","_c","conns","disabledBannerState","input","show","workflowNodes","def","stepFailure","step","ctx","uses","params","values","stepValid","workflowValid","workflow","steps","invalidReason","failure","FIX_TEXT","publishProblems","publishDisabledReason","g","p","readWorkflowStatus","status","readSettings","settings","s","writeSetting","key","value","next","triggerPreviews","previews","fields","f","triggerInputSeed","preview","seed","VAR_PREFIXES","CONST_PREFIXES","STORE_APP","isRecord","v","nameOf","path","prefixes","name","pathRef","c","exprRefs","expr","k","r","stringRefs","part","parseTemplate","walk","findSetupIncomplete","wf","nodes","local","known","label","result","node","items","add","withObj","refs","list"],"mappings":";AAsBO,SAASA,EACdC,GACAC,GACAC,GACkB;;AAClB,QAAMC,IAAwB,CAAA;AAC9B,aAAWC,KAAQJ,GAAO;AACxB,UAAMK,KAAMC,IAAAF,EAAK,SAAL,gBAAAE,EAAW,KACjBC,KAAMC,IAAAJ,EAAK,SAAL,gBAAAI,EAAW,eACjBC,IACJF,KAAOL,KAAe,OAAO,OAAOA,GAAaK,CAAG,IAAIL,EAAYK,CAAG,IAAI,QACvEG,IACJH,MAAQ,UACJI,IAAAP,EAAK,SAAL,gBAAAO,EAAW,aACXF,KAAWA,EAAQ,QAAQJ,IACzBI,EAAQ,aACR;AAER,QADI,OAAOJ,KAAQ,YAAYA,MAAQ,MACnC,OAAOK,KAAe,YAAYA,MAAe,GAAI;AACzD,UAAME,IAAQX,EAAMI,CAAG;AACvB,KAAIO,KAAA,gBAAAA,EAAO,WAAU,YACjBA,EAAM,IAAI,IAAIF,CAAU,KAC5BP,EAAI,KAAK,EAAE,QAAQC,EAAK,IAAI,KAAAC,GAAK,YAAAK,GAAY,MAAM,sBAAsB;AAAA,EAC3E;AACA,SAAOP;AACT;AAiBO,SAASU,EAAoBC,GAAiD;AACnF,QAAMC,IAAOD,EAAM,YAAY,OAAUA,EAAM,eAAe,KAAKA,EAAM;AACzE,SAAO;AAAA,IACL,MAAAC;AAAA,IACA,WAAWA,KAAQD,EAAM,iBAAiB,KAAK,CAACA,EAAM;AAAA,IACtD,cAAcA,EAAM;AAAA,EAAA;AAExB;ACtEO,SAASE,EACdC,GACK;AACL,UAAOA,KAAA,gBAAAA,EAAK,WAASA,KAAA,gBAAAA,EAAK,UAAS,CAAA;AACrC;ACsGA,SAASC,EAAYC,GAAwBC,GAA0C;AACrF,QAAMC,IAAOF,EAAK;AAGlB,MAAIE,KAAA,QAAAA,EAAM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AAG,GAAG;AAAA,IAE7B;AACA,UAAMyE,IAAU1B,EAASuB,EAAK,IAAI,IAAIA,EAAK,OAAO,CAAA;AAClD,IAAIxD,EAAK,QAAQgC,KAAa2B,EAAQ,UAAU,QAAQ,OAAO;AAC/D,UAAMC,IAAc,CAAA;AACpB,IAAAZ,EAAKW,GAASC,CAAI;AAClB,eAAWhB,KAAKgB,GAAM;AACpB,YAAMC,IAAOR,EAAMT,EAAE,QAAQ;AAC7B,MAAKiB,EAAK,UACNjB,EAAE,aAAa,SAASQ,EAAM,IAAIR,EAAE,IAAI,KACxCA,EAAE,aAAa,WAAWA,EAAE,SAAS,gBACpCiB,EAAK,MAAM,SAASjB,EAAE,IAAI,KAAGc,EAAI,GAAGJ,EAAMV,EAAE,QAAQ,CAAC,IAAIA,EAAE,IAAI,EAAE;AAAA,IACxE;AACA,IAAIa,EAAM,SAAS,MAAGF,EAAOC,EAAK,EAAE,IAAIC;AAAA,EAC1C;AACA,SAAOF;AACT;"}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { useQueryClient as a, useMutation as u, useQuery as d } from "@tanstack/react-query";
|
|
2
|
-
import { path as c } from "@w6w/sdk";
|
|
3
|
-
import { u as i } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
import { i as w, a as y } from "./callables-B49tS2vv.js";
|
|
5
|
-
import { o as m, a4 as b } from "./workflows-RhR8kwt7.js";
|
|
6
|
-
import { i as q } from "./spec-import-invalidation-D3retX4Q.js";
|
|
7
|
-
const h = (e) => y("endpoint", e), S = (e) => y("function", e), l = {
|
|
8
|
-
function: "functions",
|
|
9
|
-
workflow: "workflows",
|
|
10
|
-
endpoint: "endpoints"
|
|
11
|
-
}, K = {
|
|
12
|
-
function: "invoke",
|
|
13
|
-
endpoint: "invoke",
|
|
14
|
-
workflow: "run"
|
|
15
|
-
};
|
|
16
|
-
function p(e, t) {
|
|
17
|
-
return ["versions", e, t];
|
|
18
|
-
}
|
|
19
|
-
function C(e, t, o) {
|
|
20
|
-
return ["version", e, t, o];
|
|
21
|
-
}
|
|
22
|
-
function g(e, t, o) {
|
|
23
|
-
const n = i();
|
|
24
|
-
return d({
|
|
25
|
-
queryKey: p(e, t),
|
|
26
|
-
queryFn: async () => {
|
|
27
|
-
switch (e) {
|
|
28
|
-
case "workflow":
|
|
29
|
-
return await n.workflows.listVersions(t);
|
|
30
|
-
case "function":
|
|
31
|
-
return await n.functions.listVersions(t);
|
|
32
|
-
case "endpoint":
|
|
33
|
-
return (await n.request({
|
|
34
|
-
method: "GET",
|
|
35
|
-
path: c`/${l.endpoint}/${t}/versions`
|
|
36
|
-
})).body;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
enabled: o && e !== null && t !== ""
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function j(e, t, o, n) {
|
|
43
|
-
const s = i();
|
|
44
|
-
return d({
|
|
45
|
-
queryKey: C(e, t, o),
|
|
46
|
-
queryFn: async () => {
|
|
47
|
-
const r = o;
|
|
48
|
-
switch (e) {
|
|
49
|
-
case "workflow":
|
|
50
|
-
return await s.workflows.getVersion(t, r);
|
|
51
|
-
case "function":
|
|
52
|
-
return await s.functions.getVersion(t, r);
|
|
53
|
-
case "endpoint":
|
|
54
|
-
return (await s.request({
|
|
55
|
-
method: "GET",
|
|
56
|
-
path: c`/${l.endpoint}/${t}/versions/${String(r)}`
|
|
57
|
-
})).body.version;
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
enabled: n && e !== null && t !== "" && o !== null
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function E(e) {
|
|
64
|
-
const t = i(), o = a();
|
|
65
|
-
return u({
|
|
66
|
-
mutationFn: async (n) => {
|
|
67
|
-
switch (e) {
|
|
68
|
-
case "workflow":
|
|
69
|
-
return await t.workflows.publish(n);
|
|
70
|
-
case "function":
|
|
71
|
-
return await t.functions.publish(n);
|
|
72
|
-
case "endpoint":
|
|
73
|
-
return (await t.request({
|
|
74
|
-
method: "POST",
|
|
75
|
-
path: c`/${l.endpoint}/${n}/publish`
|
|
76
|
-
})).body;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
onSuccess: (n, s) => o.invalidateQueries({ queryKey: p(e, s) })
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function D(e) {
|
|
83
|
-
const t = i(), o = a();
|
|
84
|
-
return u({
|
|
85
|
-
mutationFn: async (n) => {
|
|
86
|
-
switch (e) {
|
|
87
|
-
case "workflow":
|
|
88
|
-
return n.enabled ? await t.workflows.enable(n.id) : await t.workflows.disable(n.id), { enabled: n.enabled };
|
|
89
|
-
case "function":
|
|
90
|
-
return n.enabled ? await t.functions.enable(n.id) : await t.functions.disable(n.id), { enabled: n.enabled };
|
|
91
|
-
case "endpoint":
|
|
92
|
-
return (await t.request({
|
|
93
|
-
method: "POST",
|
|
94
|
-
path: c`/${l.endpoint}/${n.id}/${n.enabled ? "enable" : "disable"}`
|
|
95
|
-
})).body;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
onSuccess: (n, s) => {
|
|
99
|
-
o.invalidateQueries({ queryKey: p(e, s.id) });
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function I(e) {
|
|
104
|
-
const t = i(), o = a();
|
|
105
|
-
return u({
|
|
106
|
-
mutationFn: async (n) => {
|
|
107
|
-
switch (e) {
|
|
108
|
-
case "workflow":
|
|
109
|
-
return { reverted: await t.workflows.revert(n.id, n.versionNumber) };
|
|
110
|
-
case "function":
|
|
111
|
-
return { reverted: await t.functions.revert(n.id, n.versionNumber) };
|
|
112
|
-
case "endpoint":
|
|
113
|
-
return (await t.request({
|
|
114
|
-
method: "POST",
|
|
115
|
-
path: c`/${l.endpoint}/${n.id}/versions/${String(n.versionNumber)}/revert`
|
|
116
|
-
})).body;
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
onSuccess: (n, s) => {
|
|
120
|
-
let r;
|
|
121
|
-
switch (e) {
|
|
122
|
-
case "function":
|
|
123
|
-
r = S(s.id);
|
|
124
|
-
break;
|
|
125
|
-
case "workflow":
|
|
126
|
-
r = b(s.id);
|
|
127
|
-
break;
|
|
128
|
-
case "endpoint":
|
|
129
|
-
r = h(s.id);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
w(o, p(e, s.id), r);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function N(e) {
|
|
137
|
-
const t = i(), o = a();
|
|
138
|
-
return u({
|
|
139
|
-
mutationFn: async (n) => {
|
|
140
|
-
if (e === "workflow") {
|
|
141
|
-
const r = await t.workflows.runVersion(n.id, n.versionNumber, {});
|
|
142
|
-
return { runId: r.runId, status: r.status };
|
|
143
|
-
}
|
|
144
|
-
return (await t.request({
|
|
145
|
-
method: "POST",
|
|
146
|
-
path: c`/${l[e]}/${n.id}/versions/${String(n.versionNumber)}/${K[e]}`,
|
|
147
|
-
body: {}
|
|
148
|
-
})).body;
|
|
149
|
-
},
|
|
150
|
-
onSettled: () => o.invalidateQueries({ queryKey: m.root })
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function _(e) {
|
|
154
|
-
return e.shared ? e.sourceRepo == null ? "pending" : "synced" : "private";
|
|
155
|
-
}
|
|
156
|
-
function $(e) {
|
|
157
|
-
return ["documents", e];
|
|
158
|
-
}
|
|
159
|
-
function k(e, t) {
|
|
160
|
-
return ["documents", "detail", e, t];
|
|
161
|
-
}
|
|
162
|
-
function R(e, t, o = !0) {
|
|
163
|
-
const n = i();
|
|
164
|
-
return d({
|
|
165
|
-
queryKey: k(e, t),
|
|
166
|
-
queryFn: async () => await n.documents.get(e, { project: t }),
|
|
167
|
-
enabled: o
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function B(e, t = !0) {
|
|
171
|
-
const o = i();
|
|
172
|
-
return d({
|
|
173
|
-
queryKey: $(e),
|
|
174
|
-
// Cast to DocWithProvenance[], same as useDocumentQuery above: the wire
|
|
175
|
-
// response already carries `shared`/`source*`/`syncedAt` (repo.list()
|
|
176
|
-
// serializes every document the same way repo.get() does), but the SDK's
|
|
177
|
-
// own `Doc` type doesn't declare them yet (D-5). Without this cast,
|
|
178
|
-
// DocumentsPage.tsx's list rows have no type-visible way to branch on
|
|
179
|
-
// `d.shared` the way DocumentDetailPage.tsx already does.
|
|
180
|
-
queryFn: async () => await o.documents.list({ project: e }),
|
|
181
|
-
enabled: t
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function G() {
|
|
185
|
-
const e = i(), t = a();
|
|
186
|
-
return u({
|
|
187
|
-
mutationFn: (o) => e.documents.create(o.input, { project: o.project }),
|
|
188
|
-
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
function L() {
|
|
192
|
-
const e = i(), t = a();
|
|
193
|
-
return u({
|
|
194
|
-
mutationFn: (o) => e.documents.update(o.id, o.patch, { project: o.project }),
|
|
195
|
-
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
function x() {
|
|
199
|
-
const e = i(), t = a();
|
|
200
|
-
return u({
|
|
201
|
-
mutationFn: (o) => e.documents.delete(o.id, { project: o.project }),
|
|
202
|
-
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
function A() {
|
|
206
|
-
const e = i(), t = a();
|
|
207
|
-
return u({
|
|
208
|
-
mutationFn: (o) => e.request({
|
|
209
|
-
method: "POST",
|
|
210
|
-
path: c`/documents/${o.id}/sync`,
|
|
211
|
-
query: { project: o.project }
|
|
212
|
-
}),
|
|
213
|
-
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
function f(e, t) {
|
|
217
|
-
return { ...e, project: t };
|
|
218
|
-
}
|
|
219
|
-
function F(e, t, o) {
|
|
220
|
-
return { ...f(e, t), selections: o };
|
|
221
|
-
}
|
|
222
|
-
function H(e) {
|
|
223
|
-
const t = i();
|
|
224
|
-
return u({
|
|
225
|
-
mutationFn: async (o) => (await t.request({
|
|
226
|
-
method: "POST",
|
|
227
|
-
path: "/spec/preview",
|
|
228
|
-
body: f(o, e)
|
|
229
|
-
})).body
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
function U(e, t) {
|
|
233
|
-
const o = i(), n = a();
|
|
234
|
-
return u({
|
|
235
|
-
mutationFn: async (s) => (await o.request({
|
|
236
|
-
method: "POST",
|
|
237
|
-
path: "/spec/import",
|
|
238
|
-
body: F(s.document, e, s.selections)
|
|
239
|
-
})).body,
|
|
240
|
-
// A row exists in every `201` outcome (T2.1.2 §E creates it even when
|
|
241
|
-
// some references stayed unresolved), so the list is stale either way —
|
|
242
|
-
// but ONLY the list the imported kind actually belongs to (AC-3): the
|
|
243
|
-
// unconditional `functionsKey` this used to invalidate left an imported
|
|
244
|
-
// Endpoint or Workflow's own list stale while pointlessly invalidating
|
|
245
|
-
// Functions.
|
|
246
|
-
onSuccess: (s) => q(n, s.kind, t, e)
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
export {
|
|
250
|
-
H as a,
|
|
251
|
-
G as b,
|
|
252
|
-
L as c,
|
|
253
|
-
F as d,
|
|
254
|
-
f as e,
|
|
255
|
-
k as f,
|
|
256
|
-
_ as g,
|
|
257
|
-
$ as h,
|
|
258
|
-
x as i,
|
|
259
|
-
R as j,
|
|
260
|
-
B as k,
|
|
261
|
-
N as l,
|
|
262
|
-
E as m,
|
|
263
|
-
I as n,
|
|
264
|
-
D as o,
|
|
265
|
-
A as p,
|
|
266
|
-
j as q,
|
|
267
|
-
g as r,
|
|
268
|
-
p as s,
|
|
269
|
-
U as u,
|
|
270
|
-
C as v
|
|
271
|
-
};
|
|
272
|
-
//# sourceMappingURL=spec-import-CPbDnnuv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-import-CPbDnnuv.js","sources":["../src/repos/versions.ts","../src/repos/documents.ts","../src/repos/spec-import.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 `documents` domain repo — wraps `@w6w/sdk`'s `client.documents.*` in\n * react-query (HITL-6). `QueryClientProvider` (`main.tsx`) stays the actual\n * cache; this module only centralizes the query-key factory and the\n * `queryFn`/`mutationFn` pairs so every page reads documents the same way.\n *\n * Documents are project-scoped (`documents.ts`'s `DocumentOptions.project`);\n * every mutation here invalidates the unscoped `[\"documents\"]` key, which\n * prefix-matches every project-scoped query key produced by\n * {@linkcode documentsKey} — the same invalidation shape `DocumentsPage.tsx`\n * used before this migration.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type Doc, type DocumentCreateInput, type DocumentPatch } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/**\n * T1.1.1's wire shape for one document, pinned here ahead of that node\n * merging (this node is dispatched speculatively against it — see this\n * task's contract). `shared` and the six `source*`/`syncedAt` fields are all\n * additive over the SDK's own `Doc`, so a locally-created document simply\n * carries them as `null` (or `false` for `shared`) rather than omitting\n * them. Do not rename a field — the server produces these names verbatim.\n */\nexport interface DocWithProvenance extends Doc {\n shared: boolean;\n /** \"owner/name\" of the bound repository this document was pulled from. */\n sourceRepo: string | null;\n /** Repo-relative file path the document was pulled from. */\n sourcePath: string | null;\n /** The pulled file's content hash — NOT a commit SHA. */\n sourceSha: string | null;\n /** The repository's HEAD commit SHA at pull time — NOT a content hash. */\n sourceRefSha: string | null;\n /** Web link to the file; may be absent even when the rest of provenance is set. */\n sourceUrl: string | null;\n /** ISO-8601. Stamped at the document's last actual change, not at every sync. */\n syncedAt: string | null;\n}\n\n/**\n * Which provenance state `DocumentDetailPage.tsx`'s \"Source\" card should\n * render for `doc`. `shared` (not `sourceRepo`) is the gate: a shared\n * document whose provenance columns haven't been stamped yet (any document\n * synced before this feature shipped, until its next real-content sync —\n * tier-1 \"unchanged\" syncs never restamp provenance) is still shared, and\n * must say so, distinct from a genuinely private document.\n *\n * - `\"private\"` — `doc.shared` is false. No card.\n * - `\"pending\"` — shared, but `sourceRepo` hasn't been stamped yet.\n * - `\"synced\"` — shared, with full provenance available.\n */\nexport function documentProvenanceState(doc: DocWithProvenance): \"private\" | \"pending\" | \"synced\" {\n if (!doc.shared) return \"private\";\n return doc.sourceRepo == null ? \"pending\" : \"synced\";\n}\n\n/** Query key for a documents list, optionally scoped to a project. */\nexport function documentsKey(projectId?: string) {\n return [\"documents\", projectId] as const;\n}\n\n/**\n * Query key for a single document, scoped to a project (mirrors\n * {@linkcode useDocumentsQuery}'s fix at :72-79/:80-87 below — `projectId`\n * belongs in the key itself, not just the `queryFn`, so a render where the\n * key was cached under `projectId === undefined` genuinely changes key once\n * `ProjectContext` resolves the real one, instead of reusing the same cache\n * entry — and its `retry: false` wrong-project 404 — forever). Still sits\n * under the bare `[\"documents\"]` prefix every mutation below invalidates, so\n * an edit/delete refreshes this page too — `\"detail\"` keeps it from\n * colliding with {@linkcode documentsKey}'s own `[\"documents\", projectId]`\n * shape.\n */\nexport function documentKey(id: string, projectId?: string) {\n return [\"documents\", \"detail\", id, projectId] as const;\n}\n\n/**\n * A single document by id, cast to {@link DocWithProvenance} (D-5): the SDK's\n * `Doc` doesn't model T1.1.1's provenance fields yet, and this repo is not\n * the place to fork or extend `@w6w/sdk` (D-4). The `project` option is\n * passed exactly as {@linkcode useDocumentsQuery} passes it — a document in a\n * non-default project 404s without it. `enabled` defaults `true` to preserve\n * that unscoped fallback for a caller that genuinely wants it — same as\n * {@linkcode useDocumentsQuery}'s own `enabled` doc comment below — a\n * project-scoped page should instead pass `enabled: projectId != null` so it\n * never queries (and never renders) against the wrong project while\n * `ProjectContext`'s own project list is still resolving.\n */\nexport function useDocumentQuery(id: string, projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentKey(id, projectId),\n queryFn: async () =>\n (await apiClient.documents.get(id, { project: projectId })) as DocWithProvenance,\n enabled,\n });\n}\n\n/**\n * The current project's documents (or the tenant default when unscoped).\n * `enabled` defaults `true` to preserve that unscoped fallback for a caller\n * that genuinely wants it — a project-scoped page should instead pass\n * `enabled: projectId != null` so it never queries (and never renders)\n * against the wrong project while `ProjectContext`'s own project list is\n * still resolving.\n */\nexport function useDocumentsQuery(projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentsKey(projectId),\n // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire\n // response already carries `shared`/`source*`/`syncedAt` (repo.list()\n // serializes every document the same way repo.get() does), but the SDK's\n // own `Doc` type doesn't declare them yet (D-5). Without this cast,\n // DocumentsPage.tsx's list rows have no type-visible way to branch on\n // `d.shared` the way DocumentDetailPage.tsx already does.\n queryFn: async () =>\n (await apiClient.documents.list({ project: projectId })) as DocWithProvenance[],\n enabled,\n });\n}\n\nexport function useCreateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DocumentCreateInput; project?: string }) =>\n apiClient.documents.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useUpdateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; patch: DocumentPatch; project?: string }) =>\n apiClient.documents.update(vars.id, vars.patch, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useDeleteDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.documents.delete(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\n/**\n * Re-pulls a shared document from its bound repository (\"Sync\" button, T2.1.4)\n * — `POST /documents/:id/sync` (T3.1.1). No SDK method exists for this route\n * yet (D-4/D-5), so this goes through `apiClient.request()` directly, same\n * escape hatch `repo-sync.ts`'s `useSyncRepoNowMutation` uses. The document\n * routes are project-scoped by QUERY param, not a path segment (unlike\n * `repo-binding`'s `/projects/:id/...` shape), so `project` travels in\n * `query`, mirroring {@linkcode useDocumentQuery}'s own `{ project: … }` use.\n */\nexport function useSyncDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.request<{ document: DocWithProvenance }>({\n method: \"POST\",\n path: path`/documents/${vars.id}/sync`,\n query: { project: vars.project },\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n","/**\n * The `/spec/import` repo (T3.2.1). A NEW file, deliberately kept out of\n * `repos/functions.ts` / `repos/endpoints.ts` (T3.1.1 owns both) so the two\n * nodes never collide on the same file.\n *\n * **Every operation here goes through `W6WClient.request<T>()`, never\n * `apiClient.console.*`.** `T2.1.2`'s `inputs.touch` has no\n * `packages/wrappers` entry — there is no SDK method for this route — so\n * `request()` is the client's public escape hatch, exactly as\n * `repos/vars.ts`'s own docblock explains for the same reason.\n *\n * The posted `document` is forwarded to the server as-is (spread, never edited):\n * this module adds only `project` (and, on import, `selections`) beside it, validates nothing, and — this is the mechanism pin note 1\n * of the contract states from the side a wrong implementation must break —\n * never falls back to the sibling whole-definition save mutation\n * `FunctionIdentityModal.tsx` uses, on any response. `/spec/import` is where\n * the server-side sealed-secret walker lives (T2.1.2 §B runs\n * `assertNoSecretEnvelopes` over the WHOLE supplied body before any write);\n * a \"helpful\" fallback to that other write path would route a pasted\n * document straight around that check.\n *\n * T1.2.1 generalizes this over all three kinds: `onSuccess` invalidates the\n * ONE list key the imported document's own kind reads (`result.kind`, which\n * the server always echoes), never an unconditional `functionsKey`. The\n * decision of which key that is lives in `../lib/spec-import-invalidation.ts`\n * (a pure, `node --test`-loadable module). The three list keys are INJECTED by the host\n * (`listKeys`): Studio's `functionsKey`/`endpointsKey` live in its own `repos/callables`.\n */\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport type { PreviewDependency, Selection, SpecDependency } from \"../lib/import-bindings.ts\";\nimport {\n type SpecImportListKeys,\n invalidateImportedCallable,\n} from \"../lib/spec-import-invalidation.ts\";\n\n/**\n * Mirrors `T2.1.1`'s `SpecDocument` (`T2.1.1.contract.md:134-141`): the\n * portable document a `GET /<kind>/:id/spec` export produces and this\n * route consumes. Not a bare `FunctionDef` — connection/var references ride\n * as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecImportDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/** One reference site's outcome (T2.1.2 §E's `SpecImportReferenceReport`). */\nexport interface SpecImportReferenceReport {\n path: string;\n kind: string;\n resolved: boolean;\n /** Present only when `resolved` is `true`. */\n boundTo?: string;\n /** Present only when `resolved` is `false`. */\n reason?: string;\n}\n\n/** The `201` body `POST /spec/import` returns (T2.1.2 §E). */\nexport interface SpecImportResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: { id: string; key?: string; name?: string };\n references: SpecImportReferenceReport[];\n dependencies?: ImportDependencyStatus[];\n}\n\n/** IF-1 `POST /spec/preview` result: one entry per dependency, with server options + suggestion. */\nexport interface PreviewResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n dependencies: PreviewDependency[];\n references?: SpecImportReferenceReport[];\n}\n\n/** One dependency's outcome in the import result (IF-1 `dependencies` status[]). */\nexport interface ImportDependencyStatus {\n key: string;\n kind?: SpecDependency[\"kind\"];\n name?: string;\n status: \"bound\" | \"created\" | \"unconfigured\" | string;\n boundTo?: string;\n reason?: string;\n}\n\n/** The preview request body: the document plus the host project, sent explicitly. */\nexport function buildPreviewBody(\n document: Record<string, unknown>,\n project: string | undefined,\n): Record<string, unknown> {\n return { ...document, project };\n}\n\n/** The import request body: the preview body plus the FULL selections map (`unconfigured` included). */\nexport function buildImportBody(\n document: Record<string, unknown>,\n project: string | undefined,\n selections: Record<string, Selection>,\n): Record<string, unknown> {\n return { ...buildPreviewBody(document, project), selections };\n}\n\n/**\n * `POST /spec/preview` (IF-1). Read-only on the server; a failure rejects the mutation and the\n * caller blocks Create — there is NO fallback to posting the document verbatim to `/spec/import`.\n */\nexport function useSpecPreviewMutation(project: string | undefined) {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: async (document: Record<string, unknown>) => {\n const res = await apiClient.request<PreviewResult>({\n method: \"POST\",\n path: \"/spec/preview\",\n body: buildPreviewBody(document, project),\n });\n return res.body;\n },\n });\n}\n\n/**\n * `POST /spec/import`. Success is always `201` — including a partially\n * resolved import (T2.1.2 §E: \"report, never fail silently\"). This mutation\n * resolves on ANY `201`; branching on `references.every(r => r.resolved)` is\n * the caller's job (A5), never this repo's.\n *\n * `project` is the caller's current project — only the workflow arm reads it\n * (`listKeys.workflowsKey(project)`), but every caller passes it uniformly rather than branching on kind itself; see\n * `../lib/spec-import-invalidation.ts` for why the key differs by kind.\n */\nexport function useImportSpecMutation(project: string | undefined, listKeys: SpecImportListKeys) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: {\n document: Record<string, unknown>;\n selections: Record<string, Selection>;\n }) => {\n const res = await apiClient.request<SpecImportResult>({\n method: \"POST\",\n path: \"/spec/import\",\n body: buildImportBody(input.document, project, input.selections),\n });\n return res.body;\n },\n // A row exists in every `201` outcome (T2.1.2 §E creates it even when\n // some references stayed unresolved), so the list is stale either way —\n // but ONLY the list the imported kind actually belongs to (AC-3): the\n // unconditional `functionsKey` this used to invalidate left an imported\n // Endpoint or Workflow's own list stale while pointlessly invalidating\n // Functions.\n onSuccess: (result) => invalidateImportedCallable(qc, result.kind, listKeys, project),\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","documentProvenanceState","doc","documentsKey","projectId","documentKey","useDocumentQuery","useDocumentsQuery","useCreateDocumentMutation","useUpdateDocumentMutation","useDeleteDocumentMutation","useSyncDocumentMutation","buildPreviewBody","document","project","buildImportBody","selections","useSpecPreviewMutation","useImportSpecMutation","listKeys","input","result","invalidateImportedCallable"],"mappings":";;;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,MAAeC,EAAY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