@w6w/embed 0.2.11 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
- package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
- package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
- package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
- package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
- package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
- package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
- package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
- package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
- package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
- package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
- package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
- package/dist/apps-ItBvnWX3.js +92 -0
- package/dist/apps-ItBvnWX3.js.map +1 -0
- package/dist/chrome/DangerZone.d.ts +4 -3
- package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
- package/dist/chrome/JsonToggle.d.ts +29 -20
- package/dist/chrome/Modal.d.ts +3 -1
- package/dist/chrome/RightRail.d.ts +6 -1
- package/dist/chrome/VersionHistoryModal.d.ts +2 -0
- package/dist/chrome/index.d.ts +1 -0
- package/dist/chrome/workspace.d.ts +32 -1
- package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
- package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
- package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
- package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
- package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
- package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
- package/dist/data-stores-UeQvwVCa.js +170 -0
- package/dist/data-stores-UeQvwVCa.js.map +1 -0
- package/dist/document-sources-DNmBojx6.js +169 -0
- package/dist/document-sources-DNmBojx6.js.map +1 -0
- package/dist/draft/use-workflow-draft.d.ts +2 -0
- package/dist/draft.mjs +2 -2
- package/dist/editor/PublishTooltip.d.ts +7 -0
- package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
- package/dist/editor/StartingStateModal.d.ts +14 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
- package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
- package/dist/editor/definition.d.ts +4 -0
- package/dist/editor/json-apply.d.ts +29 -0
- package/dist/editor/step-problems-feed.d.ts +5 -0
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor-apps-DkkC7wOQ.js +152 -0
- package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
- package/dist/editor-tools-BR27RGto.js +1683 -0
- package/dist/editor-tools-BR27RGto.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +536 -478
- package/dist/editors.mjs.map +1 -1
- package/dist/forms.mjs +3 -3
- package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
- package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
- package/dist/index.mjs +138 -108
- package/dist/index.mjs.map +1 -1
- package/dist/lib/binding-problems.d.ts +5 -1
- package/dist/lib/history-query.d.ts +45 -0
- package/dist/lib/import-bindings.d.ts +89 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/rail-settings.d.ts +1 -1
- package/dist/lib/setup-incomplete.d.ts +22 -0
- package/dist/lib/starting-data.d.ts +31 -0
- package/dist/lib/state-panel.d.ts +29 -0
- package/dist/lib/target-fields.d.ts +3 -15
- package/dist/lib/workflow-live-run.d.ts +84 -6
- package/dist/lib/workflow-validity.d.ts +64 -16
- package/dist/lib/workflow-variables.d.ts +1 -1
- package/dist/lib/workflow-version.d.ts +2 -0
- package/dist/lib.mjs +87 -72
- package/dist/lists/DataStoreList.d.ts +17 -0
- package/dist/lists/DataStoreView.d.ts +19 -0
- package/dist/lists/Logs.d.ts +19 -0
- package/dist/lists.d.ts +6 -0
- package/dist/lists.mjs +1255 -816
- package/dist/lists.mjs.map +1 -1
- package/dist/rail/ConnectionsTool.d.ts +2 -0
- package/dist/rail/HistoryTool.d.ts +2 -0
- package/dist/rail/StartingStateTool.d.ts +2 -0
- package/dist/rail/settings-sections.d.ts +4 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/constants.d.ts +12 -0
- package/dist/repos/data-stores.d.ts +84 -0
- package/dist/repos/history.d.ts +9 -0
- package/dist/repos/index.d.ts +2 -0
- package/dist/repos/spec-export.d.ts +3 -3
- package/dist/repos/spec-import.d.ts +30 -1
- package/dist/repos/step-tests.d.ts +2 -0
- package/dist/repos/webhook-listen.d.ts +35 -0
- package/dist/repos/workflows.d.ts +105 -2
- package/dist/repos.mjs +370 -328
- package/dist/repos.mjs.map +1 -1
- package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
- package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
- package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
- package/dist/spec-export-DGy5ijps.js.map +1 -0
- package/dist/spec-import-SWOonsNr.js +116 -0
- package/dist/spec-import-SWOonsNr.js.map +1 -0
- package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
- package/dist/step-tests-B4E4W3ly.js.map +1 -0
- package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
- package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
- package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
- package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
- package/dist/workflows-BZN4Hyz1.js +623 -0
- package/dist/workflows-BZN4Hyz1.js.map +1 -0
- package/package.json +3 -2
- package/src/styles.css +153 -1
- package/dist/ConfirmModal-BE-SdX-O.js +0 -185
- package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
- package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
- package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
- package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
- package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
- package/dist/apps-CboASBKr.js +0 -77
- package/dist/apps-CboASBKr.js.map +0 -1
- package/dist/coerce-input-DttlcSdO.js.map +0 -1
- package/dist/document-sources-UCwe8x77.js +0 -91
- package/dist/document-sources-UCwe8x77.js.map +0 -1
- package/dist/editor-apps-BUZWld-m.js +0 -95
- package/dist/editor-apps-BUZWld-m.js.map +0 -1
- package/dist/editor-tools-B_Lfx3kw.js +0 -1279
- package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
- package/dist/rail-settings-XYGToh00.js.map +0 -1
- package/dist/spec-export-CBbloO_n.js.map +0 -1
- package/dist/spec-import-CW6R_Wk1.js +0 -469
- package/dist/spec-import-CW6R_Wk1.js.map +0 -1
- package/dist/step-tests-CivICmTq.js.map +0 -1
- package/dist/trigger-preview-DKxfjzUY.js +0 -145
- package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
- package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
- package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal-BE-SdX-O.js","sources":["../src/chrome/Modal.tsx","../src/chrome/CallFromCodeButton.tsx","../src/chrome/ConfirmModal.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\ninterface ModalProps {\n title: string;\n onClose: () => void;\n children: React.ReactNode;\n /** Widen the dialog (e.g. for a JSON editor that needs room). */\n wide?: boolean;\n /** Widen further still (e.g. for the plan comparison grid). */\n xl?: boolean;\n /** Trailing control on the title row (e.g. a close `IconButton`). Given,\n * the title and this node share one `.modal-head` row; absent, the title\n * renders as a direct child exactly as before. */\n headerRight?: React.ReactNode;\n}\n\n/**\n * Small dialog modal. Built on the native <dialog> element so it gets focus\n * trapping, Esc-dismiss, and accessibility semantics for free. A button\n * positioned over the backdrop catches outside-clicks to close.\n */\nexport function Modal({\n title,\n onClose,\n children,\n wide = false,\n xl = false,\n headerRight,\n}: ModalProps) {\n const ref = useRef<HTMLDialogElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n if (!el.open) el.showModal();\n const onCancel = (e: Event) => {\n e.preventDefault();\n onClose();\n };\n // A `showModal()` dialog + its ::backdrop sit in the top layer, above any\n // sibling overlay — so catch outside clicks on the dialog itself: backdrop\n // clicks target the dialog, and land outside its box.\n const onClick = (e: MouseEvent) => {\n if (e.target !== el) return;\n const r = el.getBoundingClientRect();\n const outside =\n e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n if (outside) onClose();\n };\n el.addEventListener(\"cancel\", onCancel);\n el.addEventListener(\"click\", onClick);\n return () => {\n el.removeEventListener(\"cancel\", onCancel);\n el.removeEventListener(\"click\", onClick);\n };\n }, [onClose]);\n\n return (\n <div className=\"modal-backdrop\">\n <dialog\n ref={ref}\n className={`modal${wide ? \" modal-wide\" : \"\"}${xl ? \" modal-xl\" : \"\"}`}\n aria-label={title}\n >\n {headerRight ? (\n <div className=\"modal-head\">\n <h3>{title}</h3>\n {headerRight}\n </div>\n ) : (\n <h3>{title}</h3>\n )}\n {children}\n </dialog>\n </div>\n );\n}\n","import {\n type SnippetCallable,\n type TriggerPreview,\n buildSnippet,\n unavailableReason,\n} from \"@w6w/embed/lib\";\nimport { CodeBlock, type CodeLanguage, IconButton, type IconName, Modal } from \"@w6w/ui\";\nimport { useState } from \"react\";\n\n/**\n * \"Call from code\" — the button that shows how to reach the thing you are\n * looking at from the Node SDK (`@w6w/sdk`), the CLI (`w6w`), or the Python\n * SDK (`w6w`, PyPI).\n *\n * Mounted on the pages whose resource the wrapper contract actually covers.\n * Everything shown comes from `../lib/sdk-snippets.ts`, which builds against\n * `packages/wrappers/endpoints.json` — this component owns presentation only\n * and never composes an API call of its own.\n *\n * A modal rather than an inline block: the snippet is reference material a\n * reader wants once and then dismisses, and inlining it would push the page's\n * real content (a function's inputs, a workflow's steps) below the fold for\n * everyone who is not currently writing a client.\n */\n\n/**\n * Tabs, in the order the contract lists the wrappers — then `curl`, which is\n * not a wrapper at all and therefore comes last.\n *\n * The strip renders only the tabs the BUILT snippet actually carries\n * (`Snippet.curl` is optional): a Function, Endpoint or Workflow shows all\n * four tabs, while a Connection, Var or Document — which have no fixed\n * single-resource route to curl against — still show exactly the three\n * Node/CLI/Python tabs they show today.\n */\nconst TABS = [\n { id: \"node\", label: \"Node\", language: \"TypeScript\", grammar: \"typescript\", icon: \"lang-node\" },\n { id: \"cli\", label: \"CLI\", language: \"Shell\", grammar: \"bash\", icon: \"terminal\" },\n { id: \"python\", label: \"Python\", language: \"Python\", grammar: \"python\", icon: \"lang-python\" },\n { id: \"curl\", label: \"curl\", language: \"Shell\", grammar: \"bash\", icon: \"lang-curl\" },\n] as const satisfies readonly {\n id: string;\n label: string;\n language: string;\n grammar: CodeLanguage;\n /** The tab's glyph, by name from `@w6w/ui`'s icon set (`icons.tsx`). Every\n * language mark this file used to draw — its own `NodeGlyph`/`CliGlyph`/\n * `PythonGlyph`/`CurlGlyph` — is one of those entries, copied verbatim, so\n * the tab strip and the rail's language picker draw the same four shapes\n * from one place. */\n icon: IconName;\n}[];\n\n/**\n * The tab table, exported so a caller can render its OWN affordance per\n * language without re-deriving the set. `CodeTool`'s rail panel uses it to draw\n * one icon per language and open this component's modal on that language.\n *\n * Exported as the table rather than as a list of ids on purpose: label, grammar\n * and glyph belong to the same row, and a second place that decided \"which\n * languages exist\" would be a second place to forget `curl`.\n */\nexport const SNIPPET_TABS = TABS;\n\ntype TabId = (typeof TABS)[number][\"id\"];\nexport type SnippetTabId = TabId;\n\n/**\n * Which language tabs a resource actually has — the same filter the strip\n * below applies, hoisted so a caller can ask BEFORE rendering.\n *\n * `curl` is emitted only where a public URL exists and was handed in (today: a\n * Function, a Workflow, or an Endpoint that knows its own server-rendered URL),\n * so a var, document or connection yields exactly Node/CLI/Python. Trigger\n * fields are deliberately not a parameter: they change what the snippet SAYS,\n * never which languages it is available in.\n *\n * Empty when the resource has no snippet at all — the caller should then show\n * {@link unavailableReason} rather than an empty row of icons.\n */\nexport function snippetTabsFor(resource: SnippetCallable): readonly (typeof TABS)[number][] {\n const snippet = buildSnippet(resource);\n return snippet ? TABS.filter((t) => typeof snippet[t.id] === \"string\") : [];\n}\n\n/**\n * The headless body — everything that renders the snippet itself: the\n * trigger-tab strip, the language-tab strip, the `CodeBlock`, and the per-tab\n * install-hint paragraph. No button, no `Modal`. Split out (T2.1.2) so\n * `CodeTool.Panel` (`../ui/rail/CodeTool.tsx`) can render this INSIDE the\n * right rail's own already-open panel, without a second trigger button or a\n * Modal-on-top-of-a-panel double-wrap — the rail's strip + panel disclosure\n * IS the trigger; this component only needs to draw what's inside it.\n * `CallFromCodeButton` below is unchanged in outward shape: the same button +\n * `Modal`, now rendering this body inside.\n */\nexport function CallFromCodeBody({\n resource,\n triggers,\n wrap = false,\n maxHeight = \"420px\",\n initialTab,\n}: {\n resource: SnippetCallable;\n /**\n * The workflow's declared manual (`@w6w/trigger`) triggers, one entry per\n * step, in declared order — optional so every other `CallFromCodeBody`\n * caller (function, endpoint, connection, var, document) is unaffected.\n * Both call sites derive this from a workflow definition already in scope\n * (T2.2.1, HITL-2/HITL-4 pinned); nothing here fetches it. The selected\n * trigger's declared fields are passed straight into `buildSnippet` and\n * rendered INSIDE the generated code — required fields as active code with\n * a type-derived placeholder, optional fields commented out (D-3/D-4) — so\n * there is nothing left to duplicate in a panel above it.\n */\n triggers?: TriggerPreview[];\n /**\n * Soft-wrap the code box instead of scrolling it horizontally. Default OFF\n * — see the `CodeBlock` call below for why off is right wherever there is\n * room, and why the right rail is the place where it is not.\n */\n wrap?: boolean;\n /** The code box's max height. Default `\"420px\"`, the modal's size. */\n maxHeight?: string;\n /**\n * Which language to open on. Seeds the selection ONCE, at mount — this is a\n * starting point, not a controlled value, so the strip stays clickable\n * afterwards.\n *\n * That \"once\" is load-bearing for the rail: `CodeTool` mounts this inside a\n * modal that is conditionally rendered, so picking Python, closing, and\n * picking Node re-mounts and re-seeds. A tab this resource does not carry\n * falls back to the first one it does, via `activeTab` below.\n */\n initialTab?: TabId;\n}) {\n const [tab, setTab] = useState<TabId>(initialTab ?? \"node\");\n const [triggerIndex, setTriggerIndex] = useState(0);\n const hasTriggers = !!triggers && triggers.length > 0;\n const selectedTrigger = hasTriggers\n ? (triggers[Math.min(triggerIndex, triggers.length - 1)] ?? triggers[0])\n : null;\n const snippet = buildSnippet(resource, selectedTrigger?.fields);\n // Only the tabs this snippet carries. `curl` is emitted for a Function,\n // Workflow, or an Endpoint that knows its own server-rendered URL — a var,\n // document or connection still renders exactly Node/CLI/Python.\n const tabs = snippet ? TABS.filter((t) => typeof snippet[t.id] === \"string\") : [];\n // Never leave the selection pointing at a tab that is not on the strip — the\n // component is mounted once per page and `tab` outlives a resource change.\n const activeTab: TabId = tabs.some((t) => t.id === tab) ? tab : (tabs[0]?.id ?? \"node\");\n const code = snippet?.[activeTab] ?? \"\";\n\n if (snippet === null) return <p className=\"muted\">{unavailableReason(resource)}</p>;\n\n return (\n <>\n {hasTriggers && selectedTrigger && (\n <div className=\"subpanel\" style={{ marginTop: 0, paddingTop: 0, borderTop: \"none\" }}>\n {/* Reuses `.code-tabs`/`.code-tab` — the modal's own existing\n Node/CLI/Python strip pattern (HITL-2: \"mirroring the\n modal's existing Node/CLI/Python strip\"). Nested INSIDE\n the trigger panel so the language tab-strip assertion\n below (which filters out anything under\n `[data-testid='trigger-panel']`) still sees exactly\n Node/CLI/Python. The selected trigger's fields are no\n longer listed HERE — they are rendered inside the code\n below (required active, optional commented; D-3/D-4),\n so a list here would only duplicate it. */}\n <div data-testid=\"trigger-panel\">\n <div className=\"code-tabs\">\n {triggers.map((t, i) => (\n <button\n key={t.id}\n type=\"button\"\n className={`code-tab${i === triggerIndex ? \" active\" : \"\"}`}\n data-testid=\"trigger-tab\"\n onClick={() => setTriggerIndex(i)}\n >\n {t.label}\n </button>\n ))}\n </div>\n {selectedTrigger.fields.length === 0 && (\n <p className=\"muted small\">This trigger declares no fields.</p>\n )}\n </div>\n {triggers.length > 1 && (\n <p className=\"muted small\" data-testid=\"trigger-multi-note\">\n This workflow has {triggers.length} manual triggers — the same input reaches every one\n of them identically; there is no per-trigger routing.\n </p>\n )}\n </div>\n )}\n\n <div className=\"code-tabs\">\n {tabs.map((t) => (\n <button\n key={t.id}\n type=\"button\"\n className={`code-tab${activeTab === t.id ? \" active\" : \"\"}`}\n onClick={() => setTab(t.id)}\n >\n {t.label}\n </button>\n ))}\n </div>\n\n {/* `wrap` is a CALLER decision, defaulting OFF. Off is right wherever\n there is room: the CLI snippet's `\\`-continued lines are chosen line\n breaks, and soft-wrapping blurs them into the accidental ones, so a\n long Node line scrolls instead.\n It is wrong in the right RAIL, whose panel is ~395px wide — there\n every snippet scrolls horizontally, every time, and a snippet you\n have to drag sideways to read is not a snippet you can read. The\n rail passes `wrap`; the modal (which has the room) does not. The\n copy affordance lives inside the code box itself (`copyable`) — no\n local `CopyButton`, no `.code-tabs-spacer`. */}\n <CodeBlock\n code={code}\n language={TABS.find((t) => t.id === activeTab)?.grammar ?? \"plaintext\"}\n maxHeight={maxHeight}\n wrap={wrap}\n aria-label={`${TABS.find((t) => t.id === activeTab)?.label ?? activeTab} snippet`}\n copyable\n />\n\n {/* One arm per tab, and `python` is now EXPLICIT: it used to be\n the trailing `else`, so a fourth tab would silently have\n inherited \"pip install w6w\". The `curl` arm names no\n `operation` — raw HTTP maps to no wrapper-contract operation,\n and claiming one would be a promise the contract does not\n make. */}\n <p className=\"muted small\" style={{ marginBottom: 0 }}>\n {activeTab === \"node\" ? (\n <>\n <code>npm i @w6w/sdk</code> · set <code>W6W_BASE_URL</code> and <code>W6W_TOKEN</code> ·\n operation <code>{snippet.operation}</code>\n </>\n ) : activeTab === \"cli\" ? (\n <>\n <code>npm i -g @w6w/cli</code> · set <code>W6W_BASE_URL</code> and{\" \"}\n <code>W6W_TOKEN</code> (or pass <code>--base-url</code> / <code>--token</code>) ·\n operation <code>{snippet.operation}</code>\n </>\n ) : activeTab === \"python\" ? (\n <>\n <code>pip install w6w</code> · set <code>W6W_BASE_URL</code> and <code>W6W_TOKEN</code>{\" \"}\n · operation <code>{snippet.operation}</code>\n </>\n ) : (\n <>\n No client library — any HTTP client will do. Set <code>W6W_BASE_URL</code> to your w6w\n base URL (for an Endpoint, the URL above is the one this page is showing); substitute a\n w6w token for <code>$W6W_TOKEN</code> and send the declared input as the JSON body.\n </>\n )}\n </p>\n </>\n );\n}\n\nexport function CallFromCodeButton({\n resource,\n label = \"Call from code\",\n triggers,\n initialTab,\n}: {\n resource: SnippetCallable;\n label?: string;\n /** See {@link CallFromCodeBody}'s own doc — passed straight through. */\n triggers?: TriggerPreview[];\n /** See {@link CallFromCodeBody}'s own doc — passed straight through. */\n initialTab?: TabId;\n}) {\n const [open, setOpen] = useState(false);\n\n return (\n <>\n <IconButton icon=\"code\" label={label} onClick={() => setOpen(true)} />\n\n {open && (\n <Modal title=\"Call from code\" size=\"wide\" onClose={() => setOpen(false)}>\n <CallFromCodeBody resource={resource} triggers={triggers} initialTab={initialTab} />\n </Modal>\n )}\n </>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { Modal } from \"./Modal.tsx\";\n\ninterface ConfirmModalProps {\n title: string;\n message: string;\n /** Optional content rendered under the message (e.g. a list of impacted items). */\n children?: ReactNode;\n /** Fired when the user confirms. The caller clears its pending state via onClose. */\n onConfirm: () => void;\n /** Fired on Cancel, Esc, or outside-click — dismisses without confirming. */\n onClose: () => void;\n confirmLabel?: string;\n cancelLabel?: string;\n /** Style the confirm button as destructive (default true — this dialog gates dangerous actions). */\n destructive?: boolean;\n}\n\n/**\n * A reusable confirmation dialog built on our <dialog>-based Modal, so it inherits\n * focus-trap, Esc-dismiss, and outside-click close. Replaces the browser's native\n * confirmation prompt for destructive actions: Confirm fires `onConfirm`;\n * Cancel/Esc/outside-click fires `onClose` only (no confirmation).\n */\nexport function ConfirmModal({\n title,\n message,\n children,\n onConfirm,\n onClose,\n confirmLabel = \"Confirm\",\n cancelLabel = \"Cancel\",\n destructive = true,\n}: ConfirmModalProps) {\n return (\n <Modal title={title} onClose={onClose}>\n <div className=\"modal-body\">\n <p className=\"muted small\">{message}</p>\n {children}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={onClose}>\n {cancelLabel}\n </button>\n <button type=\"button\" className={destructive ? \"btn danger\" : \"btn\"} onClick={onConfirm}>\n {confirmLabel}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["Modal","title","onClose","children","wide","xl","headerRight","ref","useRef","useEffect","el","onCancel","e","onClick","r","jsx","jsxs","TABS","snippetTabsFor","resource","snippet","buildSnippet","t","CallFromCodeBody","triggers","wrap","maxHeight","initialTab","tab","setTab","useState","triggerIndex","setTriggerIndex","hasTriggers","selectedTrigger","tabs","activeTab","_a","code","unavailableReason","Fragment","i","CodeBlock","_b","_c","CallFromCodeButton","label","open","setOpen","IconButton","ConfirmModal","message","onConfirm","confirmLabel","cancelLabel","destructive"],"mappings":";;;;AAqBO,SAASA,EAAM;AAAA,EACpB,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,IAAAC,IAAK;AAAA,EACL,aAAAC;AACF,GAAe;AACb,QAAMC,IAAMC,EAA0B,IAAI;AAE1C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAKH,EAAI;AACf,QAAI,CAACG,E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AAAA,MAAA,gBAAAD,EAAC,KAAA,EAAE,WAAU,eAAe,UAAAoC,GAAQ;AAAA,MACnChD;AAAA,IAAA,GACH;AAAA,IACA,gBAAAa,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA;AAAA,MAAA,gBAAAD,EAAC,YAAO,MAAK,UAAS,WAAU,aAAY,SAASb,GAClD,UAAAoD,EAAA,CACH;AAAA,MACA,gBAAAvC,EAAC,UAAA,EAAO,MAAK,UAAS,WAAWwC,IAAc,eAAe,OAAO,SAASH,GAC3E,UAAAC,EAAA,CACH;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsxs as o, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { p as k } from "./rail-settings-XYGToh00.js";
|
|
3
|
-
import { ApiError as I } from "@w6w/sdk";
|
|
4
|
-
import { JsonEditor as C } from "@w6w/ui";
|
|
5
|
-
import { useState as p } from "react";
|
|
6
|
-
import { b as j } from "./spec-import-CW6R_Wk1.js";
|
|
7
|
-
import { M as y } from "./ConfirmModal-BE-SdX-O.js";
|
|
8
|
-
const S = {
|
|
9
|
-
function: "functions",
|
|
10
|
-
endpoint: "endpoints",
|
|
11
|
-
workflow: "workflows"
|
|
12
|
-
}, x = {
|
|
13
|
-
function: {
|
|
14
|
-
json: "functions-import-json",
|
|
15
|
-
submit: "functions-import-submit",
|
|
16
|
-
unresolved: "functions-import-unresolved",
|
|
17
|
-
goto: "functions-import-goto"
|
|
18
|
-
},
|
|
19
|
-
endpoint: {
|
|
20
|
-
json: "endpoints-import-json",
|
|
21
|
-
submit: "endpoints-import-submit",
|
|
22
|
-
unresolved: "endpoints-import-unresolved",
|
|
23
|
-
goto: "endpoints-import-goto"
|
|
24
|
-
},
|
|
25
|
-
workflow: {
|
|
26
|
-
json: "workflows-import-json",
|
|
27
|
-
submit: "workflows-import-submit",
|
|
28
|
-
unresolved: "workflows-import-unresolved",
|
|
29
|
-
goto: "workflows-import-goto"
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
function L(s) {
|
|
33
|
-
const { kind: t } = s, v = S[t], l = x[t], [c, g] = p(""), [f, a] = p(null), [r, m] = p(null), i = j(s.project, s.listKeys), { parsed: h, blockedReason: d } = k(c, t), w = d !== null || i.isPending;
|
|
34
|
-
function b(e) {
|
|
35
|
-
s.onClose(), s.onOpenImported(t, e);
|
|
36
|
-
}
|
|
37
|
-
function N() {
|
|
38
|
-
d !== null || h === null || i.isPending || (a(null), m(null), i.mutate(h, {
|
|
39
|
-
onSuccess: (e) => {
|
|
40
|
-
if (e.references.every((u) => u.resolved)) {
|
|
41
|
-
b(e.callable.id);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
m({
|
|
45
|
-
callableId: e.callable.id,
|
|
46
|
-
references: e.references.filter((u) => !u.resolved)
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
onError: (e) => a(e instanceof I ? e.message : String(e))
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
return /* @__PURE__ */ o(y, { title: `Import ${t}`, onClose: s.onClose, wide: !0, children: [
|
|
53
|
-
/* @__PURE__ */ o("div", { className: "modal-body", children: [
|
|
54
|
-
/* @__PURE__ */ o("p", { className: "muted small", children: [
|
|
55
|
-
"Paste a portable ",
|
|
56
|
-
t,
|
|
57
|
-
" spec document (exported via",
|
|
58
|
-
" ",
|
|
59
|
-
/* @__PURE__ */ o("code", { children: [
|
|
60
|
-
"GET /",
|
|
61
|
-
v,
|
|
62
|
-
"/:id/spec"
|
|
63
|
-
] }),
|
|
64
|
-
"). A fresh id is minted here; connection references are re-bound to whatever this account already has connected, and anything that couldn't be re-bound is reported below."
|
|
65
|
-
] }),
|
|
66
|
-
/* @__PURE__ */ n("div", { "data-testid": l.json, children: /* @__PURE__ */ n(
|
|
67
|
-
C,
|
|
68
|
-
{
|
|
69
|
-
value: c,
|
|
70
|
-
onChange: (e) => {
|
|
71
|
-
g(e), m(null), a(null);
|
|
72
|
-
},
|
|
73
|
-
minHeight: "320px",
|
|
74
|
-
"aria-label": `${t} spec document JSON`
|
|
75
|
-
}
|
|
76
|
-
) }),
|
|
77
|
-
d && c !== "" && /* @__PURE__ */ n("p", { className: "muted small", children: d }),
|
|
78
|
-
f && /* @__PURE__ */ n("div", { className: "result error", children: f }),
|
|
79
|
-
r && /* @__PURE__ */ o("div", { className: "result", "data-testid": l.unresolved, children: [
|
|
80
|
-
/* @__PURE__ */ o("p", { children: [
|
|
81
|
-
"The ",
|
|
82
|
-
t,
|
|
83
|
-
" was created, but ",
|
|
84
|
-
r.references.length,
|
|
85
|
-
" reference",
|
|
86
|
-
r.references.length === 1 ? "" : "s",
|
|
87
|
-
" could not be resolved:"
|
|
88
|
-
] }),
|
|
89
|
-
/* @__PURE__ */ n("ul", { className: "list", children: r.references.map((e) => /* @__PURE__ */ o("li", { children: [
|
|
90
|
-
/* @__PURE__ */ n("code", { children: e.path }),
|
|
91
|
-
" ",
|
|
92
|
-
/* @__PURE__ */ o("span", { className: "muted", children: [
|
|
93
|
-
"(",
|
|
94
|
-
e.kind,
|
|
95
|
-
")"
|
|
96
|
-
] }),
|
|
97
|
-
e.reason && /* @__PURE__ */ o("span", { className: "muted", children: [
|
|
98
|
-
" — ",
|
|
99
|
-
e.reason
|
|
100
|
-
] })
|
|
101
|
-
] }, e.path)) }),
|
|
102
|
-
/* @__PURE__ */ o(
|
|
103
|
-
"button",
|
|
104
|
-
{
|
|
105
|
-
type: "button",
|
|
106
|
-
className: "btn",
|
|
107
|
-
"data-testid": l.goto,
|
|
108
|
-
onClick: () => b(r.callableId),
|
|
109
|
-
children: [
|
|
110
|
-
"Open the created ",
|
|
111
|
-
t
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
] })
|
|
116
|
-
] }),
|
|
117
|
-
/* @__PURE__ */ o("div", { className: "modal-actions", children: [
|
|
118
|
-
/* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: s.onClose, children: "Cancel" }),
|
|
119
|
-
/* @__PURE__ */ n(
|
|
120
|
-
"button",
|
|
121
|
-
{
|
|
122
|
-
type: "button",
|
|
123
|
-
className: "btn",
|
|
124
|
-
"data-testid": l.submit,
|
|
125
|
-
disabled: w,
|
|
126
|
-
onClick: N,
|
|
127
|
-
children: i.isPending ? "Importing…" : "Import"
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
] })
|
|
131
|
-
] });
|
|
132
|
-
}
|
|
133
|
-
export {
|
|
134
|
-
L as I
|
|
135
|
-
};
|
|
136
|
-
//# sourceMappingURL=ImportSpecModal-B7qd1Km2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImportSpecModal-B7qd1Km2.js","sources":["../src/chrome/ImportSpecModal.tsx"],"sourcesContent":["import { type SpecImportKind, type SpecImportListKeys, parseImportPaste } from \"@w6w/embed/lib\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { JsonEditor } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { type SpecImportReferenceReport, useImportSpecMutation } from \"../repos/spec-import.ts\";\nimport { Modal } from \"./Modal.tsx\";\n\n/** The list route segment for each kind — `goto()`'s `<collection>/<id>` nav target. */\nconst COLLECTION: Record<SpecImportKind, \"functions\" | \"endpoints\" | \"workflows\"> = {\n function: \"functions\",\n endpoint: \"endpoints\",\n workflow: \"workflows\",\n};\n\n/**\n * P2's `<collection>-import-*` testid scheme, spelled out literally per kind rather than built by\n * string interpolation — so the Functions arm's four testids stay the exact byte strings\n * `functions-page-guards.test.cjs` (IM1–IM3) already asserts against, verifiable by a plain\n * substring search over this file rather than only by running the browser suite.\n */\nconst TESTIDS: Record<\n SpecImportKind,\n { json: string; submit: string; unresolved: string; goto: string }\n> = {\n function: {\n json: \"functions-import-json\",\n submit: \"functions-import-submit\",\n unresolved: \"functions-import-unresolved\",\n goto: \"functions-import-goto\",\n },\n endpoint: {\n json: \"endpoints-import-json\",\n submit: \"endpoints-import-submit\",\n unresolved: \"endpoints-import-unresolved\",\n goto: \"endpoints-import-goto\",\n },\n workflow: {\n json: \"workflows-import-json\",\n submit: \"workflows-import-submit\",\n unresolved: \"workflows-import-unresolved\",\n goto: \"workflows-import-goto\",\n },\n};\n\n/**\n * Import modal for the Functions, Endpoints and Workflows lists (T1.2.1, generalizing T3.2.1's\n * Functions-only `ImportFunctionModal`): paste a portable spec document (rfcs/function.md), POST\n * it to `/spec/import` and either land in the created resource's editor (every reference resolved)\n * or stay open with the unresolved-reference report (A5).\n *\n * **P1 — one parameterized component, not three.** The Function-specific surface was four strings,\n * one nav target and a testid prefix — forking it into three siblings would duplicate the state\n * machine below for no gain. The `kind` prop drives all of it: `parseImportPaste`'s expected kind,\n * the title/copy, the `goto()` navigation target (`<collection>/<id>`), and every testid (P2 — the\n * four `functions-import-*` ones this file used to hardcode keep matching byte-for-byte; see\n * `TESTIDS` above for why they are spelled out literally per kind rather than interpolated).\n *\n * Mirrors `FunctionIdentityModal.tsx` (note 3 — same studio-local `Modal`,\n * same `ApiError.message` handling, same \"the row was created, hand the\n * operator the id\" shape as `onCreated`) but is a structurally PARALLEL,\n * distinct trigger — not a second \"create a resource and land in its editor\"\n * flow built on top of it. It owns its own navigation (unlike the identity\n * modal, which reports back to the list) because A5's \"created but\n * partially resolved\" outcome has nowhere else to render the report: the\n * modal has to stay mounted to show it, so it is also the one place that can\n * decide whether and when to leave the list route.\n *\n * **A `201` whose `references` carry any `resolved: false` entry is NOT\n * \"done\" (A5)** — the near-miss this exists to kill is \"201 ⇒ close and\n * navigate\", which would hide exactly the unresolved-reference report the\n * intake asks for.\n */\nexport interface ImportSpecModalProps {\n kind: SpecImportKind;\n /** The host's current project (only the workflow list key reads it). */\n project: string | undefined;\n /** The three list query keys, injected by the host. */\n listKeys: SpecImportListKeys;\n /** Navigate to the imported row; the modal closes itself first. */\n onOpenImported: (kind: SpecImportKind, id: string) => void;\n onClose: () => void;\n}\n\nexport function ImportSpecModal(props: ImportSpecModalProps) {\n const { kind } = props;\n const collection = COLLECTION[kind];\n const testids = TESTIDS[kind];\n const [text, setText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const [unresolved, setUnresolved] = useState<{\n callableId: string;\n references: SpecImportReferenceReport[];\n } | null>(null);\n const importMut = useImportSpecMutation(props.project, props.listKeys);\n\n const { parsed, blockedReason } = parseImportPaste(text, kind);\n const disabled = blockedReason !== null || importMut.isPending;\n\n function goto(id: string) {\n props.onClose();\n props.onOpenImported(kind, id);\n }\n\n function submit() {\n // Defensive, not decorative: a forced click (e.g. `dispatchEvent`) on a\n // disabled button must still issue zero requests (A3, IM1(a)/(b)).\n if (blockedReason !== null || parsed === null || importMut.isPending) return;\n setError(null);\n setUnresolved(null);\n // The parsed paste, forwarded VERBATIM — note 1's mechanism pin (A4).\n importMut.mutate(parsed, {\n onSuccess: (result) => {\n const allResolved = result.references.every((r) => r.resolved);\n if (allResolved) {\n goto(result.callable.id);\n return;\n }\n // Kept open (A5): the resource WAS created, but at least one\n // reference did not bind — report every unresolved entry, and give\n // the operator an explicit way to still reach the row.\n setUnresolved({\n callableId: result.callable.id,\n references: result.references.filter((r) => !r.resolved),\n });\n },\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n });\n }\n\n return (\n <Modal title={`Import ${kind}`} onClose={props.onClose} wide>\n <div className=\"modal-body\">\n <p className=\"muted small\">\n Paste a portable {kind} spec document (exported via{\" \"}\n <code>GET /{collection}/:id/spec</code>\n ). A fresh id is minted here; connection references are re-bound to whatever this account\n already has connected, and anything that couldn't be re-bound is reported below.\n </p>\n\n <div data-testid={testids.json}>\n <JsonEditor\n value={text}\n onChange={(v) => {\n setText(v);\n setUnresolved(null);\n setError(null);\n }}\n minHeight=\"320px\"\n aria-label={`${kind} spec document JSON`}\n />\n </div>\n\n {blockedReason && text !== \"\" && <p className=\"muted small\">{blockedReason}</p>}\n {error && <div className=\"result error\">{error}</div>}\n\n {unresolved && (\n <div className=\"result\" data-testid={testids.unresolved}>\n <p>\n The {kind} was created, but {unresolved.references.length} reference\n {unresolved.references.length === 1 ? \"\" : \"s\"} could not be resolved:\n </p>\n <ul className=\"list\">\n {unresolved.references.map((r) => (\n <li key={r.path}>\n <code>{r.path}</code> <span className=\"muted\">({r.kind})</span>\n {r.reason && <span className=\"muted\"> — {r.reason}</span>}\n </li>\n ))}\n </ul>\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.goto}\n onClick={() => goto(unresolved.callableId)}\n >\n Open the created {kind}\n </button>\n </div>\n )}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.submit}\n disabled={disabled}\n onClick={submit}\n >\n {importMut.isPending ? \"Importing…\" : \"Import\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["COLLECTION","TESTIDS","ImportSpecModal","props","kind","collection","testids","text","setText","useState","error","setError","unresolved","setUnresolved","importMut","useImportSpecMutation","parsed","blockedReason","parseImportPaste","disabled","goto","id","submit","result","r","ApiError","jsxs","Modal","jsx","JsonEditor","v"],"mappings":";;;;;;;AAQA,MAAMA,IAA8E;AAAA,EAClF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAQMC,IAGF;AAAA,EACF,UAAU;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,MAAM;AAAA,EAAA;AAEV;AAyCO,SAASC,EAAgBC,GAA6B;AAC3D,QAAM,EAAE,MAAAC,MAASD,GACXE,IAAaL,EAAWI,CAAI,GAC5BE,IAAUL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