@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
|
@@ -3,9 +3,9 @@ import { ApiError as I } from "@w6w/sdk";
|
|
|
3
3
|
import { useEnterSubmit as K } from "@w6w/ui";
|
|
4
4
|
import { useState as c } from "react";
|
|
5
5
|
import { M } from "./ConfirmModal-WqBfWftD.js";
|
|
6
|
-
import { n as F } from "./callables-
|
|
6
|
+
import { n as F } from "./callables-dLF2IcwA.js";
|
|
7
7
|
import { i as x, s as A } from "./slug-BVdgiP_L.js";
|
|
8
|
-
import { u as D, a as O, E as T, b as P, c as B, F as L } from "./endpoints-
|
|
8
|
+
import { u as D, a as O, E as T, b as P, c as B, F as L } from "./endpoints-DJxXRh-I.js";
|
|
9
9
|
function R(e) {
|
|
10
10
|
var C, v, k;
|
|
11
11
|
const a = !!e.initial, [l, d] = c(((C = e.initial) == null ? void 0 : C.displayName) ?? ""), [s, h] = c(((v = e.initial) == null ? void 0 : v.key) ?? ""), [r, E] = c(((k = e.initial) == null ? void 0 : k.description) ?? ""), [y, N] = c(null), u = O(), S = !a && s !== "" && (e.takenKeys ?? []).includes(s), f = x(s) && !u.isPending;
|
|
@@ -219,4 +219,4 @@ export {
|
|
|
219
219
|
V as F,
|
|
220
220
|
W as a
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=CreateFunctionModal-
|
|
222
|
+
//# sourceMappingURL=CreateFunctionModal-CYNHJUGJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateFunctionModal-glk2zg1r.js","sources":["../src/forms/CreateEndpointModal.tsx","../src/forms/CreateFunctionModal.tsx"],"sourcesContent":["import { ApiError } from \"@w6w/sdk\";\nimport { useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { newCallableId } from \"../lib/callable-descriptors.ts\";\nimport { isEndpointKey, slugify } from \"../lib/slug.ts\";\nimport {\n ENDPOINT_MANIFEST_VERSION,\n useEndpointsQuery,\n useSaveEndpointMutation,\n} from \"../repos/endpoints.ts\";\n\n/**\n * Identity modal shared by the Endpoints list (\"+ New endpoint\" — create\n * mode) and the editor's read-only info block (\"edit\" icon-button — edit\n * mode). `isEdit = !!props.initial`, mirroring `VarModal` and `FunctionIdentityModal`.\n *\n * **Create mode POSTs for real, right here — before any editor exists.**\n * That is this node's whole point: the row is created against the server\n * before the operator can put target/input work into a plain `useState` that\n * used to die on a missing var, a lost tab, or anything else short of a\n * completed Save. Submit is disabled unless the key clears\n * {@link isEndpointKey}; `takenKeys` (from the list's own `GET /endpoints`)\n * is an ADVISORY pre-check only — the account-scoped unique index is the\n * arbiter, and any refusal (409 `endpoint_key_conflict`, 409\n * `key_immutable`, 400 `invalid_endpoint`) renders `ApiError.message`\n * verbatim and leaves the modal open with what was typed intact.\n *\n * **Edit mode writes NOTHING.** `POST /endpoints` is a whole-definition\n * upsert, so an identity-only PATCH here would silently wipe the target and\n * input the editor already has saved — precisely the data loss this whole\n * node exists to stop. The patched fields go back through `onSaved`; the\n * editor's own `onSave()` stays the one path that ever persists them.\n */\nexport function EndpointIdentityModal(props: {\n /** Edit mode when present; create mode when absent. Mirrors VarModal's `isEdit = !!props.initial`. */\n initial?: { key: string; displayName: string; description: string };\n /** Create mode only: the caller-minted `ep_…` id the POST carries. */\n newId?: string;\n /** Create mode only: keys already taken in this account — advisory pre-check. */\n takenKeys?: readonly string[];\n onClose: () => void;\n /** Create mode: the id the SERVER returned (`saved.endpoint.id`). */\n onCreated?: (id: string) => void;\n /** Edit mode: the patched identity fields. The modal itself writes NOTHING. */\n onSaved?: (next: { displayName: string; description: string }) => void;\n}) {\n const isEdit = !!props.initial;\n const [displayName, setDisplayName] = useState(props.initial?.displayName ?? \"\");\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n\n const saveMut = useSaveEndpointMutation();\n\n const keyTaken = !isEdit && key !== \"\" && (props.takenKeys ?? []).includes(key);\n const canSubmit = isEndpointKey(key) && !saveMut.isPending;\n\n function onNameBlur() {\n // The intake's own gate: \"on `name` blur, if the key is still empty, use\n // the name to generate it.\" — `!key`, not SignupPage's richer\n // `slugManual` latch (that richer behavior was not asked for here).\n if (key) return;\n const candidate = slugify(displayName);\n if (!candidate) return;\n setKey(candidate);\n }\n\n function submit() {\n setError(null);\n if (isEdit) {\n props.onSaved?.({ displayName: displayName.trim(), description });\n props.onClose();\n return;\n }\n saveMut.mutate(\n {\n manifestVersion: ENDPOINT_MANIFEST_VERSION,\n id: props.newId,\n key,\n displayName: displayName.trim(),\n description,\n // Deliberately NO `target` — this is the draft state (HITL-8): the\n // row is created, holds its `(account, key)` slot, and the operator\n // finishes it in the editor that opens next.\n },\n {\n onSuccess: (saved) => props.onCreated?.(saved.endpoint.id),\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n },\n );\n }\n\n const enterSubmit = useEnterSubmit(submit, { enabled: canSubmit });\n\n return (\n <Modal title={isEdit ? \"Edit identity\" : \"New endpoint\"} onClose={props.onClose}>\n <div className=\"modal-body\">\n <div className=\"row field-row\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n onBlur={onNameBlur}\n placeholder=\"Notify Customer\"\n autoFocus\n {...enterSubmit}\n />\n </label>\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"notify-customer\"\n {...enterSubmit}\n />\n {!isEdit && (\n <span className=\"hint\">\n Lowercase, kebab-case, 3–39 characters. A public URL path segment — immutable after\n the first save.\n </span>\n )}\n {keyTaken && (\n <span className=\"hint\" data-testid=\"endpoint-key-taken\">\n Already in use in this account — the server has the final say.\n </span>\n )}\n </label>\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSubmit} onClick={submit}>\n {saveMut.isPending ? \"Creating…\" : isEdit ? \"Save\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n\n/**\n * Creates an Endpoint: the identity modal in create mode, in its own `.w6w-embed-root`. The id is\n * minted once per mount. Without `takenKeys` the modal reads the account's keys itself\n * (`GET /endpoints`) for the advisory \"already in use\" hint; the server stays the arbiter.\n */\nexport function CreateEndpointModal(props: {\n onClose: () => void;\n /** The id the SERVER returned for the new Endpoint. */\n onCreated: (id: string) => void;\n /** Keys already taken in this account. Omitted: read from the Endpoints list. */\n takenKeys?: readonly string[];\n}) {\n const [newId] = useState(() => newCallableId(\"endpoint\"));\n const keys = useEndpointsQuery(props.takenKeys === undefined);\n return (\n <div className=\"w6w-embed-root\">\n <EndpointIdentityModal\n newId={newId}\n takenKeys={props.takenKeys ?? (keys.data ?? []).map((row) => row.key)}\n onClose={props.onClose}\n onCreated={props.onCreated}\n />\n </div>\n );\n}\n","import { ApiError } from \"@w6w/sdk\";\nimport { useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { newCallableId } from \"../lib/callable-descriptors.ts\";\nimport { isEndpointKey, slugify } from \"../lib/slug.ts\";\nimport {\n FUNCTION_MANIFEST_VERSION,\n useFunctionsQuery,\n useSaveFunctionMutation,\n} from \"../repos/functions.ts\";\n\n/**\n * Identity modal shared by the Functions list (\"+ New function\" — create\n * mode) and the editor's read-only info block (\"edit\" icon-button — edit\n * mode). `isEdit = !!props.initial`, mirroring `VarModal` and\n * `EndpointIdentityModal`.\n *\n * **Create mode POSTs for real, right here — before any editor exists.**\n * That is this node's whole point: the row is created against the server\n * before the operator can put impl/input work into a plain `useState` that\n * used to die on a missing var, a lost tab, or anything else short of a\n * completed Save. Submit is disabled unless the key clears\n * {@link isEndpointKey} (reused — pin 2: the grammar is identical, so no\n * `isFunctionKey`); `takenKeys` (from the list's own `GET /functions`) is an\n * ADVISORY pre-check only — the account-scoped unique index is the arbiter,\n * and any refusal renders `ApiError.message` verbatim and leaves the modal\n * open with what was typed intact.\n *\n * **Edit mode writes NOTHING.** `POST /functions` is a whole-definition\n * upsert, so an identity-only PATCH here would silently wipe the impl and\n * inputs the editor already has saved — precisely the data loss this whole\n * node exists to stop. The patched fields go back through `onSaved`; the\n * editor's own `onSave()` stays the one path that ever persists them.\n */\nexport function FunctionIdentityModal(props: {\n /** Edit mode when present; create mode when absent. Mirrors VarModal's `isEdit = !!props.initial`. */\n initial?: { key: string; displayName: string; description: string };\n /** Create mode only: the caller-minted `fn_…` id the POST carries. */\n newId?: string;\n /** Create mode only: keys already taken in this account — advisory pre-check. */\n takenKeys?: readonly string[];\n onClose: () => void;\n /** Create mode: the id the SERVER returned (`saved.function.id`). */\n onCreated?: (id: string) => void;\n /** Edit mode: the patched identity fields. The modal itself writes NOTHING. */\n onSaved?: (next: { displayName: string; description: string }) => void;\n}) {\n const isEdit = !!props.initial;\n const [displayName, setDisplayName] = useState(props.initial?.displayName ?? \"\");\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n\n const saveMut = useSaveFunctionMutation();\n\n const keyTaken = !isEdit && key !== \"\" && (props.takenKeys ?? []).includes(key);\n // Pin 2: reuse `isEndpointKey` — the grammar is identical (kebab-case,\n // 3–39 chars, no `--` or trailing `-`), so a second `isFunctionKey` would\n // drift. Import it under its own name and note why right here.\n const canSubmit = isEndpointKey(key) && !saveMut.isPending;\n\n function onNameBlur() {\n // The intake's own gate: \"on `name` blur, if the key is still empty, use\n // the name to generate it.\" — `!key`, not SignupPage's richer\n // `slugManual` latch (that richer behavior was not asked for here).\n if (key) return;\n const candidate = slugify(displayName);\n if (!candidate) return;\n setKey(candidate);\n }\n\n function submit() {\n setError(null);\n if (isEdit) {\n props.onSaved?.({ displayName: displayName.trim(), description });\n props.onClose();\n return;\n }\n saveMut.mutate(\n {\n manifestVersion: FUNCTION_MANIFEST_VERSION,\n id: props.newId,\n key,\n displayName: displayName.trim(),\n description,\n inputs: [],\n // Deliberately NO `impl` — this is the draft state: the row is\n // created, holds its `(account, key)` slot, and the operator\n // finishes it in the editor that opens next.\n },\n {\n onSuccess: (saved: { id: string; key: string }) => props.onCreated?.(saved.id),\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n },\n );\n }\n\n const enterSubmit = useEnterSubmit(submit, { enabled: canSubmit });\n\n return (\n <Modal title={isEdit ? \"Edit identity\" : \"New function\"} onClose={props.onClose}>\n <div className=\"modal-body\">\n <div className=\"row field-row\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n onBlur={onNameBlur}\n placeholder=\"Send Email\"\n autoFocus\n {...enterSubmit}\n />\n </label>\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"send-email\"\n {...enterSubmit}\n />\n {!isEdit && (\n <span className=\"hint\">\n Lowercase, kebab-case, 3–39 characters. A public URL path segment — immutable after\n the first save.\n </span>\n )}\n {keyTaken && (\n <span className=\"hint\" data-testid=\"function-key-taken\">\n Already in use in this account — the server has the final say.\n </span>\n )}\n </label>\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSubmit} onClick={submit}>\n {saveMut.isPending ? \"Creating…\" : isEdit ? \"Save\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n\n/**\n * Creates a Function: the identity modal in create mode, in its own `.w6w-embed-root`. The id is\n * minted once per mount. Without `takenKeys` the modal reads the account's keys itself\n * (`GET /functions`) for the advisory \"already in use\" hint; the server stays the arbiter.\n */\nexport function CreateFunctionModal(props: {\n onClose: () => void;\n /** The id the SERVER returned for the new Function. */\n onCreated: (id: string) => void;\n /** Keys already taken in this account. Omitted: read from the Functions list. */\n takenKeys?: readonly string[];\n}) {\n const [newId] = useState(() => newCallableId(\"function\"));\n const keys = useFunctionsQuery(props.takenKeys === undefined);\n return (\n <div className=\"w6w-embed-root\">\n <FunctionIdentityModal\n newId={newId}\n takenKeys={props.takenKeys ?? (keys.data ?? []).map((row) => row.key)}\n onClose={props.onClose}\n onCreated={props.onCreated}\n />\n </div>\n );\n}\n"],"names":["EndpointIdentityModal","props","isEdit","displayName","setDisplayName","useState","_a","key","setKey","_b","description","setDescription","_c","error","setError","saveMut","useSaveEndpointMutation","keyTaken","canSubmit","isEndpointKey","onNameBlur","candidate","slugify","submit","ENDPOINT_MANIFEST_VERSION","saved","e","ApiError","enterSubmit","useEnterSubmit","jsxs","Modal","jsx","CreateEndpointModal","newId","newCallableId","keys","useEndpointsQuery","row","FunctionIdentityModal","useSaveFunctionMutation","FUNCTION_MANIFEST_VERSION","CreateFunctionModal","useFunctionsQuery"],"mappings":";;;;;;;;AAkCO,SAASA,EAAsBC,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A,YACP,UAAU,CAACgB,MAAMf,EAAee,EAAE,OAAO,KAAK;AAAA,YAC9C,aAAY;AAAA,YACX,GAAGE;AAAA,UAAA;AAAA,QAAA;AAAA,MACN,GACF;AAAA,MAECf,KAAS,gBAAAmB,EAAC,OAAA,EAAI,WAAU,gBAAgB,UAAAnB,EAAA,CAAM;AAAA,IAAA,GACjD;AAAA,IAEA,gBAAAiB,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA;AAAA,MAAA,gBAAAE,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,aAAY,SAAS/B,EAAM,SAAS,UAAA,SAAA,CAEpE;AAAA,wBACC,UAAA,EAAO,MAAK,UAAS,WAAU,OAAM,UAAU,CAACiB,GAAW,SAASK,GAClE,UAAAR,EAAQ,YAAY,cAAcb,IAAS,SAAS,SAAA,CACvD;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;AAOO,SAASwC,EAAoBzC,GAMjC;AACD,QAAM,CAACiC,CAAK,IAAI7B,EAAS,MAAM8B,EAAc,UAAU,CAAC,GAClDC,IAAOO,EAAkB1C,EAAM,cAAc,MAAS;AAC5D,SACE,gBAAA+B,EAAC,OAAA,EAAI,WAAU,kBACb,UAAA,gBAAAA;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,OAAAL;AAAA,MACA,WAAWjC,EAAM,cAAcmC,EAAK,QAAQ,CAAA,GAAI,IAAI,CAACE,MAAQA,EAAI,GAAG;AAAA,MACpE,SAASrC,EAAM;AAAA,MACf,WAAWA,EAAM;AAAA,IAAA;AAAA,EAAA,GAErB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CreateFunctionModal-CYNHJUGJ.js","sources":["../src/forms/CreateEndpointModal.tsx","../src/forms/CreateFunctionModal.tsx"],"sourcesContent":["import { ApiError } from \"@w6w/sdk\";\nimport { useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { newCallableId } from \"../lib/callable-descriptors.ts\";\nimport { isEndpointKey, slugify } from \"../lib/slug.ts\";\nimport {\n ENDPOINT_MANIFEST_VERSION,\n useEndpointsQuery,\n useSaveEndpointMutation,\n} from \"../repos/endpoints.ts\";\n\n/**\n * Identity modal shared by the Endpoints list (\"+ New endpoint\" — create\n * mode) and the editor's read-only info block (\"edit\" icon-button — edit\n * mode). `isEdit = !!props.initial`, mirroring `VarModal` and `FunctionIdentityModal`.\n *\n * **Create mode POSTs for real, right here — before any editor exists.**\n * That is this node's whole point: the row is created against the server\n * before the operator can put target/input work into a plain `useState` that\n * used to die on a missing var, a lost tab, or anything else short of a\n * completed Save. Submit is disabled unless the key clears\n * {@link isEndpointKey}; `takenKeys` (from the list's own `GET /endpoints`)\n * is an ADVISORY pre-check only — the account-scoped unique index is the\n * arbiter, and any refusal (409 `endpoint_key_conflict`, 409\n * `key_immutable`, 400 `invalid_endpoint`) renders `ApiError.message`\n * verbatim and leaves the modal open with what was typed intact.\n *\n * **Edit mode writes NOTHING.** `POST /endpoints` is a whole-definition\n * upsert, so an identity-only PATCH here would silently wipe the target and\n * input the editor already has saved — precisely the data loss this whole\n * node exists to stop. The patched fields go back through `onSaved`; the\n * editor's own `onSave()` stays the one path that ever persists them.\n */\nexport function EndpointIdentityModal(props: {\n /** Edit mode when present; create mode when absent. Mirrors VarModal's `isEdit = !!props.initial`. */\n initial?: { key: string; displayName: string; description: string };\n /** Create mode only: the caller-minted `ep_…` id the POST carries. */\n newId?: string;\n /** Create mode only: keys already taken in this account — advisory pre-check. */\n takenKeys?: readonly string[];\n onClose: () => void;\n /** Create mode: the id the SERVER returned (`saved.endpoint.id`). */\n onCreated?: (id: string) => void;\n /** Edit mode: the patched identity fields. The modal itself writes NOTHING. */\n onSaved?: (next: { displayName: string; description: string }) => void;\n}) {\n const isEdit = !!props.initial;\n const [displayName, setDisplayName] = useState(props.initial?.displayName ?? \"\");\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n\n const saveMut = useSaveEndpointMutation();\n\n const keyTaken = !isEdit && key !== \"\" && (props.takenKeys ?? []).includes(key);\n const canSubmit = isEndpointKey(key) && !saveMut.isPending;\n\n function onNameBlur() {\n // The intake's own gate: \"on `name` blur, if the key is still empty, use\n // the name to generate it.\" — `!key`, not SignupPage's richer\n // `slugManual` latch (that richer behavior was not asked for here).\n if (key) return;\n const candidate = slugify(displayName);\n if (!candidate) return;\n setKey(candidate);\n }\n\n function submit() {\n setError(null);\n if (isEdit) {\n props.onSaved?.({ displayName: displayName.trim(), description });\n props.onClose();\n return;\n }\n saveMut.mutate(\n {\n manifestVersion: ENDPOINT_MANIFEST_VERSION,\n id: props.newId,\n key,\n displayName: displayName.trim(),\n description,\n // Deliberately NO `target` — this is the draft state (HITL-8): the\n // row is created, holds its `(account, key)` slot, and the operator\n // finishes it in the editor that opens next.\n },\n {\n onSuccess: (saved) => props.onCreated?.(saved.endpoint.id),\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n },\n );\n }\n\n const enterSubmit = useEnterSubmit(submit, { enabled: canSubmit });\n\n return (\n <Modal title={isEdit ? \"Edit identity\" : \"New endpoint\"} onClose={props.onClose}>\n <div className=\"modal-body\">\n <div className=\"row field-row\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n onBlur={onNameBlur}\n placeholder=\"Notify Customer\"\n autoFocus\n {...enterSubmit}\n />\n </label>\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"notify-customer\"\n {...enterSubmit}\n />\n {!isEdit && (\n <span className=\"hint\">\n Lowercase, kebab-case, 3–39 characters. A public URL path segment — immutable after\n the first save.\n </span>\n )}\n {keyTaken && (\n <span className=\"hint\" data-testid=\"endpoint-key-taken\">\n Already in use in this account — the server has the final say.\n </span>\n )}\n </label>\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSubmit} onClick={submit}>\n {saveMut.isPending ? \"Creating…\" : isEdit ? \"Save\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n\n/**\n * Creates an Endpoint: the identity modal in create mode, in its own `.w6w-embed-root`. The id is\n * minted once per mount. Without `takenKeys` the modal reads the account's keys itself\n * (`GET /endpoints`) for the advisory \"already in use\" hint; the server stays the arbiter.\n */\nexport function CreateEndpointModal(props: {\n onClose: () => void;\n /** The id the SERVER returned for the new Endpoint. */\n onCreated: (id: string) => void;\n /** Keys already taken in this account. Omitted: read from the Endpoints list. */\n takenKeys?: readonly string[];\n}) {\n const [newId] = useState(() => newCallableId(\"endpoint\"));\n const keys = useEndpointsQuery(props.takenKeys === undefined);\n return (\n <div className=\"w6w-embed-root\">\n <EndpointIdentityModal\n newId={newId}\n takenKeys={props.takenKeys ?? (keys.data ?? []).map((row) => row.key)}\n onClose={props.onClose}\n onCreated={props.onCreated}\n />\n </div>\n );\n}\n","import { ApiError } from \"@w6w/sdk\";\nimport { useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { newCallableId } from \"../lib/callable-descriptors.ts\";\nimport { isEndpointKey, slugify } from \"../lib/slug.ts\";\nimport {\n FUNCTION_MANIFEST_VERSION,\n useFunctionsQuery,\n useSaveFunctionMutation,\n} from \"../repos/functions.ts\";\n\n/**\n * Identity modal shared by the Functions list (\"+ New function\" — create\n * mode) and the editor's read-only info block (\"edit\" icon-button — edit\n * mode). `isEdit = !!props.initial`, mirroring `VarModal` and\n * `EndpointIdentityModal`.\n *\n * **Create mode POSTs for real, right here — before any editor exists.**\n * That is this node's whole point: the row is created against the server\n * before the operator can put impl/input work into a plain `useState` that\n * used to die on a missing var, a lost tab, or anything else short of a\n * completed Save. Submit is disabled unless the key clears\n * {@link isEndpointKey} (reused — pin 2: the grammar is identical, so no\n * `isFunctionKey`); `takenKeys` (from the list's own `GET /functions`) is an\n * ADVISORY pre-check only — the account-scoped unique index is the arbiter,\n * and any refusal renders `ApiError.message` verbatim and leaves the modal\n * open with what was typed intact.\n *\n * **Edit mode writes NOTHING.** `POST /functions` is a whole-definition\n * upsert, so an identity-only PATCH here would silently wipe the impl and\n * inputs the editor already has saved — precisely the data loss this whole\n * node exists to stop. The patched fields go back through `onSaved`; the\n * editor's own `onSave()` stays the one path that ever persists them.\n */\nexport function FunctionIdentityModal(props: {\n /** Edit mode when present; create mode when absent. Mirrors VarModal's `isEdit = !!props.initial`. */\n initial?: { key: string; displayName: string; description: string };\n /** Create mode only: the caller-minted `fn_…` id the POST carries. */\n newId?: string;\n /** Create mode only: keys already taken in this account — advisory pre-check. */\n takenKeys?: readonly string[];\n onClose: () => void;\n /** Create mode: the id the SERVER returned (`saved.function.id`). */\n onCreated?: (id: string) => void;\n /** Edit mode: the patched identity fields. The modal itself writes NOTHING. */\n onSaved?: (next: { displayName: string; description: string }) => void;\n}) {\n const isEdit = !!props.initial;\n const [displayName, setDisplayName] = useState(props.initial?.displayName ?? \"\");\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n\n const saveMut = useSaveFunctionMutation();\n\n const keyTaken = !isEdit && key !== \"\" && (props.takenKeys ?? []).includes(key);\n // Pin 2: reuse `isEndpointKey` — the grammar is identical (kebab-case,\n // 3–39 chars, no `--` or trailing `-`), so a second `isFunctionKey` would\n // drift. Import it under its own name and note why right here.\n const canSubmit = isEndpointKey(key) && !saveMut.isPending;\n\n function onNameBlur() {\n // The intake's own gate: \"on `name` blur, if the key is still empty, use\n // the name to generate it.\" — `!key`, not SignupPage's richer\n // `slugManual` latch (that richer behavior was not asked for here).\n if (key) return;\n const candidate = slugify(displayName);\n if (!candidate) return;\n setKey(candidate);\n }\n\n function submit() {\n setError(null);\n if (isEdit) {\n props.onSaved?.({ displayName: displayName.trim(), description });\n props.onClose();\n return;\n }\n saveMut.mutate(\n {\n manifestVersion: FUNCTION_MANIFEST_VERSION,\n id: props.newId,\n key,\n displayName: displayName.trim(),\n description,\n inputs: [],\n // Deliberately NO `impl` — this is the draft state: the row is\n // created, holds its `(account, key)` slot, and the operator\n // finishes it in the editor that opens next.\n },\n {\n onSuccess: (saved: { id: string; key: string }) => props.onCreated?.(saved.id),\n onError: (e) => setError(e instanceof ApiError ? e.message : String(e)),\n },\n );\n }\n\n const enterSubmit = useEnterSubmit(submit, { enabled: canSubmit });\n\n return (\n <Modal title={isEdit ? \"Edit identity\" : \"New function\"} onClose={props.onClose}>\n <div className=\"modal-body\">\n <div className=\"row field-row\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n onBlur={onNameBlur}\n placeholder=\"Send Email\"\n autoFocus\n {...enterSubmit}\n />\n </label>\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"send-email\"\n {...enterSubmit}\n />\n {!isEdit && (\n <span className=\"hint\">\n Lowercase, kebab-case, 3–39 characters. A public URL path segment — immutable after\n the first save.\n </span>\n )}\n {keyTaken && (\n <span className=\"hint\" data-testid=\"function-key-taken\">\n Already in use in this account — the server has the final say.\n </span>\n )}\n </label>\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSubmit} onClick={submit}>\n {saveMut.isPending ? \"Creating…\" : isEdit ? \"Save\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n\n/**\n * Creates a Function: the identity modal in create mode, in its own `.w6w-embed-root`. The id is\n * minted once per mount. Without `takenKeys` the modal reads the account's keys itself\n * (`GET /functions`) for the advisory \"already in use\" hint; the server stays the arbiter.\n */\nexport function CreateFunctionModal(props: {\n onClose: () => void;\n /** The id the SERVER returned for the new Function. */\n onCreated: (id: string) => void;\n /** Keys already taken in this account. Omitted: read from the Functions list. */\n takenKeys?: readonly string[];\n}) {\n const [newId] = useState(() => newCallableId(\"function\"));\n const keys = useFunctionsQuery(props.takenKeys === undefined);\n return (\n <div className=\"w6w-embed-root\">\n <FunctionIdentityModal\n newId={newId}\n takenKeys={props.takenKeys ?? (keys.data ?? []).map((row) => row.key)}\n onClose={props.onClose}\n onCreated={props.onCreated}\n />\n </div>\n );\n}\n"],"names":["EndpointIdentityModal","props","isEdit","displayName","setDisplayName","useState","_a","key","setKey","_b","description","setDescription","_c","error","setError","saveMut","useSaveEndpointMutation","keyTaken","canSubmit","isEndpointKey","onNameBlur","candidate","slugify","submit","ENDPOINT_MANIFEST_VERSION","saved","e","ApiError","enterSubmit","useEnterSubmit","jsxs","Modal","jsx","CreateEndpointModal","newId","newCallableId","keys","useEndpointsQuery","row","FunctionIdentityModal","useSaveFunctionMutation","FUNCTION_MANIFEST_VERSION","CreateFunctionModal","useFunctionsQuery"],"mappings":";;;;;;;;AAkCO,SAASA,EAAsBC,GAYnC;;AACD,QAAMC,IAAS,CAAC,CAACD,EAAM,SACjB,CAACE,GAAaC,CAAc,IAAIC,IAASC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,gBAAe,EAAE,GACzE,CAACC,GAAKC,CAAM,IAAIH,IAASI,IAAAR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WAAU,gBAAgB,UAAAnB,EAAA,CAAM;AAAA,IAAA,GACjD;AAAA,IAEA,gBAAAiB,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA;AAAA,MAAA,gBAAAE,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,aAAY,SAAS/B,EAAM,SAAS,UAAA,SAAA,CAEpE;AAAA,wBACC,UAAA,EAAO,MAAK,UAAS,WAAU,OAAM,UAAU,CAACiB,GAAW,SAASK,GAClE,UAAAR,EAAQ,YAAY,cAAcb,IAAS,SAAS,SAAA,CACvD;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;AAOO,SAASwC,EAAoBzC,GAMjC;AACD,QAAM,CAACiC,CAAK,IAAI7B,EAAS,MAAM8B,EAAc,UAAU,CAAC,GAClDC,IAAOO,EAAkB1C,EAAM,cAAc,MAAS;AAC5D,SACE,gBAAA+B,EAAC,OAAA,EAAI,WAAU,kBACb,UAAA,gBAAAA;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,OAAAL;AAAA,MACA,WAAWjC,EAAM,cAAcmC,EAAK,QAAQ,CAAA,GAAI,IAAI,CAACE,MAAQA,EAAI,GAAG;AAAA,MACpE,SAASrC,EAAM;AAAA,MACf,WAAWA,EAAM;AAAA,IAAA;AAAA,EAAA,GAErB;AAEJ;"}
|
|
@@ -3,7 +3,7 @@ import { ApiError as Y } from "@w6w/sdk";
|
|
|
3
3
|
import { useEnterSubmit as J, JsonEditor as P, YamlEditor as R, CodeEditor as $ } from "@w6w/ui";
|
|
4
4
|
import { useState as l } from "react";
|
|
5
5
|
import { M as H } from "./ConfirmModal-WqBfWftD.js";
|
|
6
|
-
import {
|
|
6
|
+
import { u as K, a as V } from "./documents-hgltn0xe.js";
|
|
7
7
|
const _ = ".txt,.md,.markdown,.yaml,.yml,.html,.htm,.json,.csv,text/*,application/json,application/yaml";
|
|
8
8
|
async function q(t) {
|
|
9
9
|
var d;
|
|
@@ -172,4 +172,4 @@ function Z(t) {
|
|
|
172
172
|
export {
|
|
173
173
|
Z as D
|
|
174
174
|
};
|
|
175
|
-
//# sourceMappingURL=DocumentFormModal-
|
|
175
|
+
//# sourceMappingURL=DocumentFormModal-CLmdGx34.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentFormModal-B3OkvI5v.js","sources":["../src/lib/document-upload.ts","../src/forms/DocumentFormModal.tsx"],"sourcesContent":["import type { DocFormat } from \"@w6w/sdk\";\n\nexport const DOCUMENT_FILE_ACCEPT =\n \".txt,.md,.markdown,.yaml,.yml,.html,.htm,.json,.csv,text/*,application/json,application/yaml\";\n\n/** Read text without silently turning a binary or invalid UTF-8 file into document content. */\nexport async function readDocumentFile(file: Pick<File, \"name\" | \"arrayBuffer\">): Promise<{\n key: string;\n format: DocFormat;\n content: string;\n}> {\n const extension = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n const formats: Record<string, DocFormat> = {\n txt: \"text\",\n csv: \"text\",\n md: \"markdown\",\n markdown: \"markdown\",\n yaml: \"yaml\",\n yml: \"yaml\",\n html: \"html\",\n htm: \"html\",\n json: \"json\",\n };\n const format = formats[extension];\n if (!format)\n throw new Error(\n \"Choose a text, Markdown, YAML, HTML, JSON, or CSV file. Use Files for other file types.\",\n );\n let content: string;\n try {\n content = new TextDecoder(\"utf-8\", { fatal: true }).decode(await file.arrayBuffer());\n } catch {\n throw new Error(\"Could not read this file as UTF-8 text. Choose a UTF-8 text file.\");\n }\n if (content.includes(\"\\0\"))\n throw new Error(\"This file contains binary data. Upload it in Files instead.\");\n return {\n key:\n file.name\n .replace(/\\.[^.]+$/, \"\")\n .trim()\n .slice(0, 128) || \"document\",\n format,\n content,\n };\n}\n","/**\n * Create/edit modal for a document (internal: not exported from `@w6w/embed/forms`). Content is\n * stored verbatim in whatever format is selected, with no parsing or validation. The key is\n * immutable once set, so an edit never sends it.\n */\nimport { ApiError } from \"@w6w/sdk\";\nimport type { Doc, DocFormat } from \"@w6w/sdk\";\nimport { CodeEditor, JsonEditor, YamlEditor, useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { DOCUMENT_FILE_ACCEPT, readDocumentFile } from \"../lib/document-upload.ts\";\nimport { useCreateDocumentMutation, useUpdateDocumentMutation } from \"../repos/documents.ts\";\n\nconst FORMATS: readonly DocFormat[] = [\"text\", \"markdown\", \"yaml\", \"html\", \"json\"];\n\nexport function DocumentFormModal(props: {\n initial?: Doc;\n /** The resolved project, or `null` (none yet): a save is refused, never sent project-less. */\n project: string | null;\n onClose: () => void;\n onSaved: () => void;\n}) {\n const isEdit = !!props.initial;\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [format, setFormat] = useState<DocFormat>(props.initial?.format ?? \"text\");\n const [content, setContent] = useState(props.initial?.content ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n const [source, setSource] = useState<\"paste\" | \"upload\">(\"paste\");\n const [reading, setReading] = useState(false);\n const [uploadedName, setUploadedName] = useState<string | null>(null);\n\n const createMut = useCreateDocumentMutation();\n const updateMut = useUpdateDocumentMutation();\n const saving = createMut.isPending || updateMut.isPending;\n const canSave =\n !!key.trim() && !saving && !reading && (source !== \"upload\" || uploadedName !== null);\n\n async function loadFile(file: File) {\n setReading(true);\n setError(null);\n setUploadedName(null);\n try {\n const document = await readDocumentFile(file);\n setKey((current) => current || document.key);\n setFormat(document.format);\n setContent(document.content);\n setUploadedName(file.name);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not read this file.\");\n } finally {\n setReading(false);\n }\n }\n\n function save() {\n setError(null);\n if (props.project == null) {\n setError(\"No project selected: nothing was saved.\");\n return;\n }\n const onSettled = {\n onSuccess: () => props.onSaved(),\n onError: (e: unknown) => setError(e instanceof ApiError ? e.message : (e as Error).message),\n };\n if (props.initial) {\n updateMut.mutate(\n { id: props.initial.id, patch: { content, format, description }, project: props.project },\n onSettled,\n );\n return;\n }\n createMut.mutate(\n { input: { key: key.trim(), content, format, description }, project: props.project },\n onSettled,\n );\n }\n\n const enterSubmit = useEnterSubmit(save, { enabled: canSave });\n\n return (\n <Modal\n title={props.initial ? `Edit ${props.initial.key}` : \"Add document\"}\n onClose={props.onClose}\n >\n <div className=\"modal-body\">\n {!isEdit && (\n <>\n <div className=\"row\">\n <button\n type=\"button\"\n className={source === \"paste\" ? \"btn\" : \"btn ghost\"}\n disabled={saving || reading}\n aria-pressed={source === \"paste\"}\n onClick={() => setSource(\"paste\")}\n >\n Write or paste\n </button>\n <button\n type=\"button\"\n className={source === \"upload\" ? \"btn\" : \"btn ghost\"}\n disabled={saving || reading}\n aria-pressed={source === \"upload\"}\n onClick={() => setSource(\"upload\")}\n >\n Upload file\n </button>\n </div>\n {source === \"upload\" && (\n <label className=\"field\">\n <span>Document file</span>\n <input\n type=\"file\"\n accept={DOCUMENT_FILE_ACCEPT}\n disabled={saving || reading}\n onChange={(event) => {\n const file = event.currentTarget.files?.[0];\n event.currentTarget.value = \"\";\n if (file) void loadFile(file);\n }}\n />\n <span className=\"hint\">\n {reading\n ? \"Reading file…\"\n : uploadedName\n ? `${uploadedName} — review the content below before saving.`\n : \"Text, Markdown, YAML, HTML, JSON, or CSV. You can review and edit the content before saving.\"}\n </span>\n </label>\n )}\n </>\n )}\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"e.g. welcome-email\"\n {...enterSubmit}\n />\n {!isEdit && <span className=\"hint\">A unique name to reference this document by.</span>}\n </label>\n\n <label className=\"field\">\n <span>Format</span>\n <select value={format} onChange={(e) => setFormat(e.target.value as DocFormat)}>\n {FORMATS.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </label>\n\n {/* A `div`, not a `label`: none of JsonEditor/YamlEditor/CodeEditor render a native\n control for a label to name; each carries its own `aria-label` instead. */}\n <div className=\"field\">\n <span>Content</span>\n {format === \"json\" ? (\n <JsonEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : format === \"yaml\" ? (\n <YamlEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : (\n <CodeEditor value={content} onChange={setContent} aria-label=\"Content\" />\n )}\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSave} onClick={save}>\n {saving ? \"Saving…\" : isEdit ? \"Save changes\" : \"Save document\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["DOCUMENT_FILE_ACCEPT","readDocumentFile","file","extension","_a","format","content","FORMATS","DocumentFormModal","props","isEdit","key","setKey","useState","setFormat","_b","setContent","_c","description","setDescription","_d","error","setError","source","setSource","reading","setReading","uploadedName","setUploadedName","createMut","useCreateDocumentMutation","updateMut","useUpdateDocumentMutation","saving","canSave","loadFile","document","current","e","save","onSettled","ApiError","enterSubmit","useEnterSubmit","jsxs","Modal","Fragment","jsx","event","f","JsonEditor","YamlEditor","CodeEditor"],"mappings":";;;;;;AAEO,MAAMA,IACX;AAGF,eAAsBC,EAAiBC,GAIpC;;AACD,QAAMC,MAAYC,IAAAF,EAAK,KAAK,MAAM,GAAG,EAAE,IAAA,MAArB,gBAAAE,EAA4B,kBAAiB,IAYzDC,IAXqC;AAAA,IACzC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,EAAA,EAEeF,CAAS;AAChC,MAAI,CAACE;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;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AAA,GAE3E;AAAA,UAEA,gBAAA4B,EAAC,SAAA,EAAM,WAAU,SACf,UAAA;AAAA,YAAA,gBAAAG,EAAC,UAAK,UAAA,cAAA,CAAW;AAAA,YACjB,gBAAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,OAAO7B;AAAA,gBACP,UAAU,CAACoB,MAAMnB,EAAemB,EAAE,OAAO,KAAK;AAAA,gBAC9C,aAAY;AAAA,gBACX,GAAGI;AAAA,cAAA;AAAA,YAAA;AAAA,UACN,GACF;AAAA,UAECrB,KAAS,gBAAA0B,EAAC,OAAA,EAAI,WAAU,gBAAgB,UAAA1B,EAAA,CAAM;AAAA,QAAA,GACjD;AAAA,QACA,gBAAAuB,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA;AAAA,UAAA,gBAAAG,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,aAAY,SAAStC,EAAM,SAAS,UAAA,SAAA,CAEpE;AAAA,UACA,gBAAAsC,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,OAAM,UAAU,CAACb,GAAS,SAASK,GAChE,UAAAN,IAAS,YAAYvB,IAAS,iBAAiB,gBAAA,CAClD;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"DocumentFormModal-CLmdGx34.js","sources":["../src/lib/document-upload.ts","../src/forms/DocumentFormModal.tsx"],"sourcesContent":["import type { DocFormat } from \"@w6w/sdk\";\n\nexport const DOCUMENT_FILE_ACCEPT =\n \".txt,.md,.markdown,.yaml,.yml,.html,.htm,.json,.csv,text/*,application/json,application/yaml\";\n\n/** Read text without silently turning a binary or invalid UTF-8 file into document content. */\nexport async function readDocumentFile(file: Pick<File, \"name\" | \"arrayBuffer\">): Promise<{\n key: string;\n format: DocFormat;\n content: string;\n}> {\n const extension = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n const formats: Record<string, DocFormat> = {\n txt: \"text\",\n csv: \"text\",\n md: \"markdown\",\n markdown: \"markdown\",\n yaml: \"yaml\",\n yml: \"yaml\",\n html: \"html\",\n htm: \"html\",\n json: \"json\",\n };\n const format = formats[extension];\n if (!format)\n throw new Error(\n \"Choose a text, Markdown, YAML, HTML, JSON, or CSV file. Use Files for other file types.\",\n );\n let content: string;\n try {\n content = new TextDecoder(\"utf-8\", { fatal: true }).decode(await file.arrayBuffer());\n } catch {\n throw new Error(\"Could not read this file as UTF-8 text. Choose a UTF-8 text file.\");\n }\n if (content.includes(\"\\0\"))\n throw new Error(\"This file contains binary data. Upload it in Files instead.\");\n return {\n key:\n file.name\n .replace(/\\.[^.]+$/, \"\")\n .trim()\n .slice(0, 128) || \"document\",\n format,\n content,\n };\n}\n","/**\n * Create/edit modal for a document (internal: not exported from `@w6w/embed/forms`). Content is\n * stored verbatim in whatever format is selected, with no parsing or validation. The key is\n * immutable once set, so an edit never sends it.\n */\nimport { ApiError } from \"@w6w/sdk\";\nimport type { Doc, DocFormat } from \"@w6w/sdk\";\nimport { CodeEditor, JsonEditor, YamlEditor, useEnterSubmit } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { DOCUMENT_FILE_ACCEPT, readDocumentFile } from \"../lib/document-upload.ts\";\nimport { useCreateDocumentMutation, useUpdateDocumentMutation } from \"../repos/documents.ts\";\n\nconst FORMATS: readonly DocFormat[] = [\"text\", \"markdown\", \"yaml\", \"html\", \"json\"];\n\nexport function DocumentFormModal(props: {\n initial?: Doc;\n /** The resolved project, or `null` (none yet): a save is refused, never sent project-less. */\n project: string | null;\n onClose: () => void;\n onSaved: () => void;\n}) {\n const isEdit = !!props.initial;\n const [key, setKey] = useState(props.initial?.key ?? \"\");\n const [format, setFormat] = useState<DocFormat>(props.initial?.format ?? \"text\");\n const [content, setContent] = useState(props.initial?.content ?? \"\");\n const [description, setDescription] = useState(props.initial?.description ?? \"\");\n const [error, setError] = useState<string | null>(null);\n const [source, setSource] = useState<\"paste\" | \"upload\">(\"paste\");\n const [reading, setReading] = useState(false);\n const [uploadedName, setUploadedName] = useState<string | null>(null);\n\n const createMut = useCreateDocumentMutation();\n const updateMut = useUpdateDocumentMutation();\n const saving = createMut.isPending || updateMut.isPending;\n const canSave =\n !!key.trim() && !saving && !reading && (source !== \"upload\" || uploadedName !== null);\n\n async function loadFile(file: File) {\n setReading(true);\n setError(null);\n setUploadedName(null);\n try {\n const document = await readDocumentFile(file);\n setKey((current) => current || document.key);\n setFormat(document.format);\n setContent(document.content);\n setUploadedName(file.name);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not read this file.\");\n } finally {\n setReading(false);\n }\n }\n\n function save() {\n setError(null);\n if (props.project == null) {\n setError(\"No project selected: nothing was saved.\");\n return;\n }\n const onSettled = {\n onSuccess: () => props.onSaved(),\n onError: (e: unknown) => setError(e instanceof ApiError ? e.message : (e as Error).message),\n };\n if (props.initial) {\n updateMut.mutate(\n { id: props.initial.id, patch: { content, format, description }, project: props.project },\n onSettled,\n );\n return;\n }\n createMut.mutate(\n { input: { key: key.trim(), content, format, description }, project: props.project },\n onSettled,\n );\n }\n\n const enterSubmit = useEnterSubmit(save, { enabled: canSave });\n\n return (\n <Modal\n title={props.initial ? `Edit ${props.initial.key}` : \"Add document\"}\n onClose={props.onClose}\n >\n <div className=\"modal-body\">\n {!isEdit && (\n <>\n <div className=\"row\">\n <button\n type=\"button\"\n className={source === \"paste\" ? \"btn\" : \"btn ghost\"}\n disabled={saving || reading}\n aria-pressed={source === \"paste\"}\n onClick={() => setSource(\"paste\")}\n >\n Write or paste\n </button>\n <button\n type=\"button\"\n className={source === \"upload\" ? \"btn\" : \"btn ghost\"}\n disabled={saving || reading}\n aria-pressed={source === \"upload\"}\n onClick={() => setSource(\"upload\")}\n >\n Upload file\n </button>\n </div>\n {source === \"upload\" && (\n <label className=\"field\">\n <span>Document file</span>\n <input\n type=\"file\"\n accept={DOCUMENT_FILE_ACCEPT}\n disabled={saving || reading}\n onChange={(event) => {\n const file = event.currentTarget.files?.[0];\n event.currentTarget.value = \"\";\n if (file) void loadFile(file);\n }}\n />\n <span className=\"hint\">\n {reading\n ? \"Reading file…\"\n : uploadedName\n ? `${uploadedName} — review the content below before saving.`\n : \"Text, Markdown, YAML, HTML, JSON, or CSV. You can review and edit the content before saving.\"}\n </span>\n </label>\n )}\n </>\n )}\n <label className=\"field\">\n <span>Key</span>\n <input\n type=\"text\"\n value={key}\n disabled={isEdit}\n onChange={(e) => setKey(e.target.value)}\n placeholder=\"e.g. welcome-email\"\n {...enterSubmit}\n />\n {!isEdit && <span className=\"hint\">A unique name to reference this document by.</span>}\n </label>\n\n <label className=\"field\">\n <span>Format</span>\n <select value={format} onChange={(e) => setFormat(e.target.value as DocFormat)}>\n {FORMATS.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </label>\n\n {/* A `div`, not a `label`: none of JsonEditor/YamlEditor/CodeEditor render a native\n control for a label to name; each carries its own `aria-label` instead. */}\n <div className=\"field\">\n <span>Content</span>\n {format === \"json\" ? (\n <JsonEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : format === \"yaml\" ? (\n <YamlEditor value={content} onChange={setContent} aria-label=\"Content\" />\n ) : (\n <CodeEditor value={content} onChange={setContent} aria-label=\"Content\" />\n )}\n </div>\n\n <label className=\"field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder=\"Optional\"\n {...enterSubmit}\n />\n </label>\n\n {error && <div className=\"result error\">{error}</div>}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"btn\" disabled={!canSave} onClick={save}>\n {saving ? \"Saving…\" : isEdit ? \"Save changes\" : \"Save document\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["DOCUMENT_FILE_ACCEPT","readDocumentFile","file","extension","_a","format","content","FORMATS","DocumentFormModal","props","isEdit","key","setKey","useState","setFormat","_b","setContent","_c","description","setDescription","_d","error","setError","source","setSource","reading","setReading","uploadedName","setUploadedName","createMut","useCreateDocumentMutation","updateMut","useUpdateDocumentMutation","saving","canSave","loadFile","document","current","e","save","onSettled","ApiError","enterSubmit","useEnterSubmit","jsxs","Modal","Fragment","jsx","event","f","JsonEditor","YamlEditor","CodeEditor"],"mappings":";;;;;;AAEO,MAAMA,IACX;AAGF,eAAsBC,EAAiBC,GAIpC;;AACD,QAAMC,MAAYC,IAAAF,EAAK,KAAK,MAAM,GAAG,EAAE,IAAA,MAArB,gBAAAE,EAA4B,kBAAiB,IAYzDC,IAXqC;AAAA,IACzC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,EAAA,EAEeF,CAAS;AAChC,MAAI,CAACE;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAEJ,MAAIC;AACJ,MAAI;AACF,IAAAA,IAAU,IAAI,YAAY,SAAS,EAAE,OAAO,GAAA,CAAM,EAAE,OAAO,MAAMJ,EAAK,YAAA,CAAa;AAAA,EACrF,QAAQ;AACN,UAAM,IAAI,MAAM,mEAAmE;AAAA,EACrF;AACA,MAAII,EAAQ,SAAS,IAAI;AACvB,UAAM,IAAI,MAAM,6DAA6D;AAC/E,SAAO;AAAA,IACL,KACEJ,EAAK,KACF,QAAQ,YAAY,EAAE,EACtB,KAAA,EACA,MAAM,GAAG,GAAG,KAAK;AAAA,IACtB,QAAAG;AAAA,IACA,SAAAC;AAAA,EAAA;AAEJ;AChCA,MAAMC,IAAgC,CAAC,QAAQ,YAAY,QAAQ,QAAQ,MAAM;AAE1E,SAASC,EAAkBC,GAM/B;;AACD,QAAMC,IAAS,CAAC,CAACD,EAAM,SACjB,CAACE,GAAKC,CAAM,IAAIC,IAAST,IAAAK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AAA,SAAA,CAEpE;AAAA,UACA,gBAAAsC,EAAC,UAAA,EAAO,MAAK,UAAS,WAAU,OAAM,UAAU,CAACb,GAAS,SAASK,GAChE,UAAAN,IAAS,YAAYvB,IAAS,iBAAiB,gBAAA,CAClD;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { i as F, f as B } from "./slug-BVdgiP_L.js";
|
|
3
|
+
import { j as J } from "./callables-dLF2IcwA.js";
|
|
4
|
+
import { ApiError as M } from "@w6w/sdk";
|
|
5
|
+
import { IconButton as L, useEnterSubmit as G, JsonEditor as H, AddConnectionModal as U } from "@w6w/ui";
|
|
6
|
+
import { useState as u } from "react";
|
|
7
|
+
import { M as K } from "./ConfirmModal-WqBfWftD.js";
|
|
8
|
+
import { p as V, g as q, j as O, w as z, k as Q, s as W, b as X, t as Y } from "./import-bindings-EUtxZ9Ti.js";
|
|
9
|
+
import { u as Z, g as _ } from "./spec-import-BKyfhTYG.js";
|
|
10
|
+
function R(n, t) {
|
|
11
|
+
if (!t.includes(",")) return { tags: n, typed: t };
|
|
12
|
+
let o = n;
|
|
13
|
+
for (const d of t.split(",")) {
|
|
14
|
+
const m = d.trim();
|
|
15
|
+
m && !o.includes(m) && (o = [...o, m]);
|
|
16
|
+
}
|
|
17
|
+
return { tags: o, typed: "" };
|
|
18
|
+
}
|
|
19
|
+
function A(n, t) {
|
|
20
|
+
return R(n, `${t},`).tags;
|
|
21
|
+
}
|
|
22
|
+
function ee(n, t) {
|
|
23
|
+
return n.filter((o) => o !== t);
|
|
24
|
+
}
|
|
25
|
+
function ne({ tags: n, onChange: t, onPendingChange: o }) {
|
|
26
|
+
const [d, m] = u("");
|
|
27
|
+
function h(s) {
|
|
28
|
+
m(s), o == null || o(s);
|
|
29
|
+
}
|
|
30
|
+
function k(s) {
|
|
31
|
+
const f = R(n, s);
|
|
32
|
+
h(f.typed), f.tags !== n && t(f.tags);
|
|
33
|
+
}
|
|
34
|
+
function c() {
|
|
35
|
+
if (!d.trim()) return;
|
|
36
|
+
const s = A(n, d);
|
|
37
|
+
h(""), s.length !== n.length && t(s);
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ l("div", { className: "tag-list", "data-testid": "tag-editor", children: [
|
|
40
|
+
n.map((s) => /* @__PURE__ */ l("span", { className: "tag removable", children: [
|
|
41
|
+
s,
|
|
42
|
+
/* @__PURE__ */ a(
|
|
43
|
+
L,
|
|
44
|
+
{
|
|
45
|
+
danger: !0,
|
|
46
|
+
icon: "close",
|
|
47
|
+
label: `Remove tag ${s}`,
|
|
48
|
+
title: `Remove ${s}`,
|
|
49
|
+
onClick: () => t(ee(n, s))
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] }, s)),
|
|
53
|
+
/* @__PURE__ */ a(
|
|
54
|
+
"input",
|
|
55
|
+
{
|
|
56
|
+
type: "text",
|
|
57
|
+
value: d,
|
|
58
|
+
placeholder: "Add a tag…",
|
|
59
|
+
"aria-label": "New tag",
|
|
60
|
+
onChange: (s) => k(s.target.value),
|
|
61
|
+
onBlur: c,
|
|
62
|
+
onKeyDown: (s) => {
|
|
63
|
+
s.key === "Enter" && (s.preventDefault(), s.stopPropagation(), c());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function pe(n) {
|
|
70
|
+
const t = J(n.kind).settings, { initial: o } = n, [d, m] = u(o.displayName), [h, k] = u(o.key ?? ""), [c, s] = u(o.tags ?? []), [f, p] = u(""), g = A(c, f), [C, S] = u(!1), [v, N] = u(null), T = d !== o.displayName, b = h !== (o.key ?? ""), $ = t.hasTags && JSON.stringify(g) !== JSON.stringify(o.tags ?? []), I = T || b || $, x = t.canEditKey, P = h === "" || F(h), j = I && P && !C;
|
|
71
|
+
async function E() {
|
|
72
|
+
if (j) {
|
|
73
|
+
N(null), S(!0);
|
|
74
|
+
try {
|
|
75
|
+
await n.onSave({
|
|
76
|
+
displayName: d.trim(),
|
|
77
|
+
key: x && b ? h : o.key,
|
|
78
|
+
tags: t.hasTags ? g : void 0
|
|
79
|
+
}), n.onClose();
|
|
80
|
+
} catch (y) {
|
|
81
|
+
N(y instanceof M ? y.message : String(y));
|
|
82
|
+
} finally {
|
|
83
|
+
S(!1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const w = G(E, { enabled: j });
|
|
88
|
+
return /* @__PURE__ */ l(K, { title: "Edit settings", onClose: n.onClose, children: [
|
|
89
|
+
/* @__PURE__ */ l("div", { className: "modal-body", children: [
|
|
90
|
+
/* @__PURE__ */ l("label", { className: "field", children: [
|
|
91
|
+
/* @__PURE__ */ a("span", { children: "Name" }),
|
|
92
|
+
/* @__PURE__ */ a(
|
|
93
|
+
"input",
|
|
94
|
+
{
|
|
95
|
+
type: "text",
|
|
96
|
+
value: d,
|
|
97
|
+
onChange: (y) => m(y.target.value),
|
|
98
|
+
placeholder: t.namePlaceholder,
|
|
99
|
+
autoFocus: !0,
|
|
100
|
+
...w
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] }),
|
|
104
|
+
x && /* @__PURE__ */ l("label", { className: "field", children: [
|
|
105
|
+
/* @__PURE__ */ a("span", { children: "Key" }),
|
|
106
|
+
/* @__PURE__ */ a(
|
|
107
|
+
"input",
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
value: h,
|
|
111
|
+
onChange: (y) => k(B(y.target.value)),
|
|
112
|
+
placeholder: t.keyPlaceholder,
|
|
113
|
+
...w
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ l("span", { className: "muted small", children: [
|
|
117
|
+
"Lowercase, kebab-case, 3–39 characters.",
|
|
118
|
+
t.keyHintSuffix
|
|
119
|
+
] })
|
|
120
|
+
] }),
|
|
121
|
+
t.hasTags && /* @__PURE__ */ l("div", { children: [
|
|
122
|
+
/* @__PURE__ */ a("p", { className: "muted small", style: { marginBottom: "8px" }, children: "Tags" }),
|
|
123
|
+
/* @__PURE__ */ a(ne, { tags: c, onChange: s, onPendingChange: p })
|
|
124
|
+
] }),
|
|
125
|
+
v && /* @__PURE__ */ a("div", { className: "error", children: v })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ l("div", { className: "modal-actions", children: [
|
|
128
|
+
/* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: n.onClose, children: "Cancel" }),
|
|
129
|
+
/* @__PURE__ */ a("button", { type: "button", className: "btn", disabled: !j, onClick: E, children: C ? "Saving…" : "Save" })
|
|
130
|
+
] })
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
const te = {
|
|
134
|
+
function: "functions",
|
|
135
|
+
endpoint: "endpoints",
|
|
136
|
+
workflow: "workflows"
|
|
137
|
+
}, ae = {
|
|
138
|
+
function: {
|
|
139
|
+
json: "functions-import-json",
|
|
140
|
+
submit: "functions-import-submit",
|
|
141
|
+
unresolved: "functions-import-unresolved",
|
|
142
|
+
goto: "functions-import-goto"
|
|
143
|
+
},
|
|
144
|
+
endpoint: {
|
|
145
|
+
json: "endpoints-import-json",
|
|
146
|
+
submit: "endpoints-import-submit",
|
|
147
|
+
unresolved: "endpoints-import-unresolved",
|
|
148
|
+
goto: "endpoints-import-goto"
|
|
149
|
+
},
|
|
150
|
+
workflow: {
|
|
151
|
+
json: "workflows-import-json",
|
|
152
|
+
submit: "workflows-import-submit",
|
|
153
|
+
unresolved: "workflows-import-unresolved",
|
|
154
|
+
goto: "workflows-import-goto"
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
function he(n) {
|
|
158
|
+
const { kind: t } = n, o = te[t], d = ae[t], [m, h] = u(""), [k, c] = u(null), [s, f] = u(null), [p, g] = u(null), [C, S] = u(null), v = Z(n.project, n.listKeys), N = _(n.project), { parsed: T, blockedReason: b } = V(m, t), $ = p !== null, I = !$ || !q(p) || b !== null || v.isPending;
|
|
159
|
+
function x(e) {
|
|
160
|
+
h(e), f(null), c(null), g(null);
|
|
161
|
+
}
|
|
162
|
+
function P() {
|
|
163
|
+
b !== null || T === null || N.isPending || (c(null), N.mutate(T, {
|
|
164
|
+
onSuccess: (e) => g(X(e.dependencies)),
|
|
165
|
+
onError: (e) => {
|
|
166
|
+
g(null), c(e instanceof M ? e.message : String(e));
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
function j(e) {
|
|
171
|
+
e && e.text().then(x, (i) => c(String(i)));
|
|
172
|
+
}
|
|
173
|
+
function E(e) {
|
|
174
|
+
n.onClose(), n.onOpenImported(t, e);
|
|
175
|
+
}
|
|
176
|
+
function w() {
|
|
177
|
+
p === null || b !== null || T === null || v.isPending || (c(null), f(null), v.mutate(
|
|
178
|
+
{ document: T, selections: Y(p) },
|
|
179
|
+
{
|
|
180
|
+
onSuccess: (e) => {
|
|
181
|
+
if (e.references.every((r) => r.resolved)) {
|
|
182
|
+
E(e.callable.id);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
f({
|
|
186
|
+
callableId: e.callable.id,
|
|
187
|
+
references: e.references.filter((r) => !r.resolved)
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
onError: (e) => c(e instanceof M ? e.message : String(e))
|
|
191
|
+
}
|
|
192
|
+
));
|
|
193
|
+
}
|
|
194
|
+
function y(e) {
|
|
195
|
+
const i = e.selection;
|
|
196
|
+
return i.mode === "bind" ? `bind:${i.target}` : i.mode;
|
|
197
|
+
}
|
|
198
|
+
function D(e, i) {
|
|
199
|
+
g((r) => r && (i === "unconfigured" ? Q(r, e.key) : i === "create" ? O(r, e.key, e.createName) : W(r, e.key, i.slice(5))));
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ l(K, { title: `Import ${t}`, onClose: n.onClose, wide: !0, children: [
|
|
202
|
+
/* @__PURE__ */ l("div", { className: "modal-body", children: [
|
|
203
|
+
/* @__PURE__ */ l("p", { className: "muted small", children: [
|
|
204
|
+
"Paste a portable ",
|
|
205
|
+
t,
|
|
206
|
+
" spec document (exported via",
|
|
207
|
+
" ",
|
|
208
|
+
/* @__PURE__ */ l("code", { children: [
|
|
209
|
+
"GET /",
|
|
210
|
+
o,
|
|
211
|
+
"/:id/spec"
|
|
212
|
+
] }),
|
|
213
|
+
"). 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."
|
|
214
|
+
] }),
|
|
215
|
+
/* @__PURE__ */ a("div", { "data-testid": d.json, children: /* @__PURE__ */ a(
|
|
216
|
+
H,
|
|
217
|
+
{
|
|
218
|
+
value: m,
|
|
219
|
+
onChange: x,
|
|
220
|
+
minHeight: "320px",
|
|
221
|
+
"aria-label": `${t} spec document JSON`
|
|
222
|
+
}
|
|
223
|
+
) }),
|
|
224
|
+
/* @__PURE__ */ l("label", { className: "muted small", children: [
|
|
225
|
+
"Or choose a ",
|
|
226
|
+
/* @__PURE__ */ a("code", { children: ".json" }),
|
|
227
|
+
" file:",
|
|
228
|
+
" ",
|
|
229
|
+
/* @__PURE__ */ a(
|
|
230
|
+
"input",
|
|
231
|
+
{
|
|
232
|
+
type: "file",
|
|
233
|
+
accept: ".json,application/json",
|
|
234
|
+
"data-testid": `${o}-import-file`,
|
|
235
|
+
onChange: (e) => {
|
|
236
|
+
var i;
|
|
237
|
+
return j((i = e.target.files) == null ? void 0 : i[0]);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }),
|
|
242
|
+
b && m !== "" && /* @__PURE__ */ a("p", { className: "muted small", children: b }),
|
|
243
|
+
k && /* @__PURE__ */ a("div", { className: "result error", children: k }),
|
|
244
|
+
p && p.length === 0 && /* @__PURE__ */ l("p", { className: "muted small", "data-testid": `${o}-import-nodeps`, children: [
|
|
245
|
+
"This ",
|
|
246
|
+
t,
|
|
247
|
+
" has no dependencies."
|
|
248
|
+
] }),
|
|
249
|
+
p && p.length > 0 && /* @__PURE__ */ a("ul", { className: "list", "data-testid": `${o}-import-rows`, children: p.map((e) => /* @__PURE__ */ l("li", { "data-testid": `${o}-import-row-${e.key}`, children: [
|
|
250
|
+
/* @__PURE__ */ a("code", { children: e.dep.name }),
|
|
251
|
+
" ",
|
|
252
|
+
/* @__PURE__ */ l("span", { className: "muted", children: [
|
|
253
|
+
"(",
|
|
254
|
+
e.dep.kind,
|
|
255
|
+
")"
|
|
256
|
+
] }),
|
|
257
|
+
" ",
|
|
258
|
+
e.dep.dynamic ? /* @__PURE__ */ a("span", { className: "muted small", children: "Dynamic store name — configure it manually after import." }) : null,
|
|
259
|
+
/* @__PURE__ */ l(
|
|
260
|
+
"select",
|
|
261
|
+
{
|
|
262
|
+
value: y(e),
|
|
263
|
+
onChange: (i) => D(e, i.target.value),
|
|
264
|
+
"aria-label": `Configure ${e.dep.name}`,
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ a("option", { value: "unconfigured", children: "Leave unconfigured" }),
|
|
267
|
+
!e.dep.dynamic && e.options.map((i) => /* @__PURE__ */ l(
|
|
268
|
+
"option",
|
|
269
|
+
{
|
|
270
|
+
value: `bind:${i.id}`,
|
|
271
|
+
disabled: i.compatible === !1,
|
|
272
|
+
title: i.reason,
|
|
273
|
+
children: [
|
|
274
|
+
i.label,
|
|
275
|
+
i.compatible === !1 && i.reason ? ` — ${i.reason}` : ""
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
i.id
|
|
279
|
+
)),
|
|
280
|
+
e.dep.kind === "store" && e.dep.canCreate && !e.dep.dynamic && /* @__PURE__ */ a("option", { value: "create", children: "Create new" })
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
e.selection.mode === "create" && /* @__PURE__ */ a(
|
|
285
|
+
"input",
|
|
286
|
+
{
|
|
287
|
+
type: "text",
|
|
288
|
+
value: e.selection.name,
|
|
289
|
+
"aria-label": `New name for ${e.dep.name}`,
|
|
290
|
+
onChange: (i) => g((r) => r && O(r, e.key, i.target.value))
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
e.dep.kind === "connection" && e.dep.app && /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: () => S(e), children: "Add connection" })
|
|
294
|
+
] }, e.key)) }),
|
|
295
|
+
C && /* @__PURE__ */ a(
|
|
296
|
+
U,
|
|
297
|
+
{
|
|
298
|
+
onCreateSharedCredential: n.onCreateSharedCredential,
|
|
299
|
+
initialAppId: C.dep.app,
|
|
300
|
+
onClose: () => S(null),
|
|
301
|
+
onCreated: ({ connectionId: e }) => {
|
|
302
|
+
const i = C.key;
|
|
303
|
+
g(
|
|
304
|
+
(r) => r && z(r, i, e, e)
|
|
305
|
+
), S(null);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
s && /* @__PURE__ */ l("div", { className: "result", "data-testid": d.unresolved, children: [
|
|
310
|
+
/* @__PURE__ */ l("p", { children: [
|
|
311
|
+
"The ",
|
|
312
|
+
t,
|
|
313
|
+
" was created, but ",
|
|
314
|
+
s.references.length,
|
|
315
|
+
" reference",
|
|
316
|
+
s.references.length === 1 ? "" : "s",
|
|
317
|
+
" could not be resolved:"
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ a("ul", { className: "list", children: s.references.map((e) => /* @__PURE__ */ l("li", { children: [
|
|
320
|
+
/* @__PURE__ */ a("code", { children: e.path }),
|
|
321
|
+
" ",
|
|
322
|
+
/* @__PURE__ */ l("span", { className: "muted", children: [
|
|
323
|
+
"(",
|
|
324
|
+
e.kind,
|
|
325
|
+
")"
|
|
326
|
+
] }),
|
|
327
|
+
e.reason && /* @__PURE__ */ l("span", { className: "muted", children: [
|
|
328
|
+
" — ",
|
|
329
|
+
e.reason
|
|
330
|
+
] })
|
|
331
|
+
] }, e.path)) }),
|
|
332
|
+
/* @__PURE__ */ l(
|
|
333
|
+
"button",
|
|
334
|
+
{
|
|
335
|
+
type: "button",
|
|
336
|
+
className: "btn",
|
|
337
|
+
"data-testid": d.goto,
|
|
338
|
+
onClick: () => E(s.callableId),
|
|
339
|
+
children: [
|
|
340
|
+
"Open the created ",
|
|
341
|
+
t
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
] })
|
|
346
|
+
] }),
|
|
347
|
+
/* @__PURE__ */ l("div", { className: "modal-actions", children: [
|
|
348
|
+
/* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: n.onClose, children: "Cancel" }),
|
|
349
|
+
!$ && /* @__PURE__ */ a(
|
|
350
|
+
"button",
|
|
351
|
+
{
|
|
352
|
+
type: "button",
|
|
353
|
+
className: "btn",
|
|
354
|
+
"data-testid": `${o}-import-next`,
|
|
355
|
+
disabled: b !== null || N.isPending,
|
|
356
|
+
onClick: P,
|
|
357
|
+
children: N.isPending ? "Checking…" : "Next"
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
/* @__PURE__ */ a(
|
|
361
|
+
"button",
|
|
362
|
+
{
|
|
363
|
+
type: "button",
|
|
364
|
+
className: "btn",
|
|
365
|
+
"data-testid": d.submit,
|
|
366
|
+
disabled: I,
|
|
367
|
+
onClick: w,
|
|
368
|
+
children: v.isPending ? "Importing…" : "Create"
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
] })
|
|
372
|
+
] });
|
|
373
|
+
}
|
|
374
|
+
export {
|
|
375
|
+
pe as C,
|
|
376
|
+
he as I
|
|
377
|
+
};
|
|
378
|
+
//# sourceMappingURL=ImportSpecModal-BzEyiNWD.js.map
|