@w6w/embed 0.2.30 → 0.2.32
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-CCYi9deY.js → CreateFunctionModal-glk2zg1r.js} +28 -27
- package/dist/{CreateFunctionModal-CCYi9deY.js.map → CreateFunctionModal-glk2zg1r.js.map} +1 -1
- package/dist/{DocumentFormModal-B3VudaLb.js → DocumentFormModal-Cw85R4wk.js} +2 -2
- package/dist/{DocumentFormModal-B3VudaLb.js.map → DocumentFormModal-Cw85R4wk.js.map} +1 -1
- package/dist/{ImportSpecModal-C-B8Jwxk.js → ImportSpecModal-fU5RsVTa.js} +2 -2
- package/dist/{ImportSpecModal-C-B8Jwxk.js.map → ImportSpecModal-fU5RsVTa.js.map} +1 -1
- package/dist/WorkflowEditor-C7oudiIb.js +1169 -0
- package/dist/WorkflowEditor-C7oudiIb.js.map +1 -0
- package/dist/callable-record-Bhxim8C1.js +14 -0
- package/dist/callable-record-Bhxim8C1.js.map +1 -0
- package/dist/callables-B49tS2vv.js +297 -0
- package/dist/callables-B49tS2vv.js.map +1 -0
- package/dist/{document-sources-DNmBojx6.js → document-sources-Khcw2zB5.js} +16 -16
- package/dist/document-sources-Khcw2zB5.js.map +1 -0
- package/dist/draft.mjs +1 -1
- package/dist/editor/WorkflowEditor.d.ts +2 -1
- package/dist/editor/WorkflowInputsModal.d.ts +12 -0
- package/dist/editor/WorkflowVariablesEditor.d.ts +1 -1
- package/dist/{editor-tools-BIAW-wzt.js → editor-tools-Dn7TgCP4.js} +566 -486
- package/dist/editor-tools-Dn7TgCP4.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +81 -80
- package/dist/editors.mjs.map +1 -1
- package/dist/endpoints-zOuwci2U.js +136 -0
- package/dist/endpoints-zOuwci2U.js.map +1 -0
- package/dist/fields-CXHRR5eK.js +28 -0
- package/dist/fields-CXHRR5eK.js.map +1 -0
- package/dist/forms.mjs +1 -1
- package/dist/index.mjs +91 -91
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-duplicate.d.ts +26 -0
- package/dist/lib/settings-rail.d.ts +12 -0
- package/dist/lib/variable-preview.d.ts +6 -0
- package/dist/lib.mjs +41 -40
- package/dist/lib.mjs.map +1 -1
- package/dist/lists/CallableKindList.d.ts +4 -1
- package/dist/lists/CallableRowParts.d.ts +5 -0
- package/dist/lists/CredentialDetail.d.ts +2 -0
- package/dist/lists/CredentialFields.d.ts +1 -1
- package/dist/lists/EndpointList.d.ts +2 -1
- package/dist/lists/WorkflowList.d.ts +2 -1
- package/dist/lists.mjs +1509 -1421
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/callables.d.ts +23 -0
- package/dist/repos/fields.d.ts +4 -1
- package/dist/repos.mjs +242 -239
- package/dist/settings-rail-gUU2ZbSw.js +36 -0
- package/dist/settings-rail-gUU2ZbSw.js.map +1 -0
- package/dist/{spec-import-FygyV8sy.js → spec-import-CGPqUUjN.js} +2 -2
- package/dist/{spec-import-FygyV8sy.js.map → spec-import-CGPqUUjN.js.map} +1 -1
- package/dist/{use-callable-draft-DCauHt5o.js → use-callable-draft-w4tDTYcb.js} +8 -7
- package/dist/{use-callable-draft-DCauHt5o.js.map → use-callable-draft-w4tDTYcb.js.map} +1 -1
- package/package.json +3 -3
- package/src/styles.css +174 -40
- package/dist/WorkflowEditor-8NAcpjO_.js +0 -1140
- package/dist/WorkflowEditor-8NAcpjO_.js.map +0 -1
- package/dist/callables-tOlflvbl.js +0 -151
- package/dist/callables-tOlflvbl.js.map +0 -1
- package/dist/document-sources-DNmBojx6.js.map +0 -1
- package/dist/editor-tools-BIAW-wzt.js.map +0 -1
- package/dist/endpoints-DArAqoLT.js +0 -233
- package/dist/endpoints-DArAqoLT.js.map +0 -1
- package/dist/fields-DvS8XZFc.js +0 -21
- package/dist/fields-DvS8XZFc.js.map +0 -1
- package/dist/settings-rail--GdRMusb.js +0 -33
- package/dist/settings-rail--GdRMusb.js.map +0 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsx as n, jsxs as i } from "react/jsx-runtime";
|
|
2
2
|
import { ApiError as I } from "@w6w/sdk";
|
|
3
3
|
import { useEnterSubmit as K } from "@w6w/ui";
|
|
4
|
-
import { useState as
|
|
4
|
+
import { useState as c } from "react";
|
|
5
5
|
import { M } from "./ConfirmModal-WqBfWftD.js";
|
|
6
|
-
import { n as F
|
|
6
|
+
import { n as F } from "./callables-B49tS2vv.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-zOuwci2U.js";
|
|
8
9
|
function R(e) {
|
|
9
10
|
var C, v, k;
|
|
10
|
-
const a = !!e.initial, [l,
|
|
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;
|
|
11
12
|
function w() {
|
|
12
13
|
if (s) return;
|
|
13
14
|
const t = A(l);
|
|
14
15
|
t && h(t);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function b() {
|
|
17
18
|
var t;
|
|
18
19
|
if (N(null), a) {
|
|
19
20
|
(t = e.onSaved) == null || t.call(e, { displayName: l.trim(), description: r }), e.onClose();
|
|
@@ -31,15 +32,15 @@ function R(e) {
|
|
|
31
32
|
// finishes it in the editor that opens next.
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
|
-
onSuccess: (
|
|
35
|
+
onSuccess: (o) => {
|
|
35
36
|
var g;
|
|
36
|
-
return (g = e.onCreated) == null ? void 0 : g.call(e,
|
|
37
|
+
return (g = e.onCreated) == null ? void 0 : g.call(e, o.endpoint.id);
|
|
37
38
|
},
|
|
38
|
-
onError: (
|
|
39
|
+
onError: (o) => N(o instanceof I ? o.message : String(o))
|
|
39
40
|
}
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
|
-
const m = K(
|
|
43
|
+
const m = K(b, { enabled: f });
|
|
43
44
|
return /* @__PURE__ */ i(M, { title: a ? "Edit identity" : "New endpoint", onClose: e.onClose, children: [
|
|
44
45
|
/* @__PURE__ */ i("div", { className: "modal-body", children: [
|
|
45
46
|
/* @__PURE__ */ i("div", { className: "row field-row", children: [
|
|
@@ -50,7 +51,7 @@ function R(e) {
|
|
|
50
51
|
{
|
|
51
52
|
type: "text",
|
|
52
53
|
value: l,
|
|
53
|
-
onChange: (t) =>
|
|
54
|
+
onChange: (t) => d(t.target.value),
|
|
54
55
|
onBlur: w,
|
|
55
56
|
placeholder: "Notify Customer",
|
|
56
57
|
autoFocus: !0,
|
|
@@ -92,17 +93,17 @@ function R(e) {
|
|
|
92
93
|
] }),
|
|
93
94
|
/* @__PURE__ */ i("div", { className: "modal-actions", children: [
|
|
94
95
|
/* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Cancel" }),
|
|
95
|
-
/* @__PURE__ */ n("button", { type: "button", className: "btn", disabled: !
|
|
96
|
+
/* @__PURE__ */ n("button", { type: "button", className: "btn", disabled: !f, onClick: b, children: u.isPending ? "Creating…" : a ? "Save" : "Create" })
|
|
96
97
|
] })
|
|
97
98
|
] });
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
-
const [a] =
|
|
100
|
+
function J(e) {
|
|
101
|
+
const [a] = c(() => F("endpoint")), l = D(e.takenKeys === void 0);
|
|
101
102
|
return /* @__PURE__ */ n("div", { className: "w6w-embed-root", children: /* @__PURE__ */ n(
|
|
102
103
|
R,
|
|
103
104
|
{
|
|
104
105
|
newId: a,
|
|
105
|
-
takenKeys: e.takenKeys ?? (l.data ?? []).map((
|
|
106
|
+
takenKeys: e.takenKeys ?? (l.data ?? []).map((d) => d.key),
|
|
106
107
|
onClose: e.onClose,
|
|
107
108
|
onCreated: e.onCreated
|
|
108
109
|
}
|
|
@@ -110,13 +111,13 @@ function H(e) {
|
|
|
110
111
|
}
|
|
111
112
|
function V(e) {
|
|
112
113
|
var C, v, k;
|
|
113
|
-
const a = !!e.initial, [l,
|
|
114
|
+
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 = B(), S = !a && s !== "" && (e.takenKeys ?? []).includes(s), f = x(s) && !u.isPending;
|
|
114
115
|
function w() {
|
|
115
116
|
if (s) return;
|
|
116
117
|
const t = A(l);
|
|
117
118
|
t && h(t);
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
+
function b() {
|
|
120
121
|
var t;
|
|
121
122
|
if (N(null), a) {
|
|
122
123
|
(t = e.onSaved) == null || t.call(e, { displayName: l.trim(), description: r }), e.onClose();
|
|
@@ -135,15 +136,15 @@ function V(e) {
|
|
|
135
136
|
// finishes it in the editor that opens next.
|
|
136
137
|
},
|
|
137
138
|
{
|
|
138
|
-
onSuccess: (
|
|
139
|
+
onSuccess: (o) => {
|
|
139
140
|
var g;
|
|
140
|
-
return (g = e.onCreated) == null ? void 0 : g.call(e,
|
|
141
|
+
return (g = e.onCreated) == null ? void 0 : g.call(e, o.id);
|
|
141
142
|
},
|
|
142
|
-
onError: (
|
|
143
|
+
onError: (o) => N(o instanceof I ? o.message : String(o))
|
|
143
144
|
}
|
|
144
145
|
);
|
|
145
146
|
}
|
|
146
|
-
const m = K(
|
|
147
|
+
const m = K(b, { enabled: f });
|
|
147
148
|
return /* @__PURE__ */ i(M, { title: a ? "Edit identity" : "New function", onClose: e.onClose, children: [
|
|
148
149
|
/* @__PURE__ */ i("div", { className: "modal-body", children: [
|
|
149
150
|
/* @__PURE__ */ i("div", { className: "row field-row", children: [
|
|
@@ -154,7 +155,7 @@ function V(e) {
|
|
|
154
155
|
{
|
|
155
156
|
type: "text",
|
|
156
157
|
value: l,
|
|
157
|
-
onChange: (t) =>
|
|
158
|
+
onChange: (t) => d(t.target.value),
|
|
158
159
|
onBlur: w,
|
|
159
160
|
placeholder: "Send Email",
|
|
160
161
|
autoFocus: !0,
|
|
@@ -196,26 +197,26 @@ function V(e) {
|
|
|
196
197
|
] }),
|
|
197
198
|
/* @__PURE__ */ i("div", { className: "modal-actions", children: [
|
|
198
199
|
/* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Cancel" }),
|
|
199
|
-
/* @__PURE__ */ n("button", { type: "button", className: "btn", disabled: !
|
|
200
|
+
/* @__PURE__ */ n("button", { type: "button", className: "btn", disabled: !f, onClick: b, children: u.isPending ? "Creating…" : a ? "Save" : "Create" })
|
|
200
201
|
] })
|
|
201
202
|
] });
|
|
202
203
|
}
|
|
203
|
-
function
|
|
204
|
-
const [a] =
|
|
204
|
+
function W(e) {
|
|
205
|
+
const [a] = c(() => F("function")), l = P(e.takenKeys === void 0);
|
|
205
206
|
return /* @__PURE__ */ n("div", { className: "w6w-embed-root", children: /* @__PURE__ */ n(
|
|
206
207
|
V,
|
|
207
208
|
{
|
|
208
209
|
newId: a,
|
|
209
|
-
takenKeys: e.takenKeys ?? (l.data ?? []).map((
|
|
210
|
+
takenKeys: e.takenKeys ?? (l.data ?? []).map((d) => d.key),
|
|
210
211
|
onClose: e.onClose,
|
|
211
212
|
onCreated: e.onCreated
|
|
212
213
|
}
|
|
213
214
|
) });
|
|
214
215
|
}
|
|
215
216
|
export {
|
|
216
|
-
|
|
217
|
+
J as C,
|
|
217
218
|
R as E,
|
|
218
219
|
V as F,
|
|
219
|
-
|
|
220
|
+
W as a
|
|
220
221
|
};
|
|
221
|
-
//# sourceMappingURL=CreateFunctionModal-
|
|
222
|
+
//# sourceMappingURL=CreateFunctionModal-glk2zg1r.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateFunctionModal-CCYi9deY.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","CreateFunct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C;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,OAAOtB;AAAA,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-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,GAYnC;;AACD,QAAMC,IAAS,CAAC,CAACD,EAAM,SACjB,CAACE,GAAaC,CAAc,IAAIC,IAASC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,gBAAe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,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;"}
|
|
@@ -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 { b as K, c as V } from "./spec-import-
|
|
6
|
+
import { b as K, c as V } from "./spec-import-CGPqUUjN.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-Cw85R4wk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentFormModal-B3VudaLb.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,EA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+B,EAACK,GAAA,EAAW,OAAO9C,GAAS,UAAUU,GAAY,cAAW,UAAA,CAAU;AAAA,UAAA,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-Cw85R4wk.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,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AAA,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;"}
|
|
@@ -3,7 +3,7 @@ import { p as R, g as F, j as x, w as L, k as D, s as J, b as U, t as B } from "
|
|
|
3
3
|
import { ApiError as I } from "@w6w/sdk";
|
|
4
4
|
import { JsonEditor as G, AddConnectionModal as H } from "@w6w/ui";
|
|
5
5
|
import { useState as p } from "react";
|
|
6
|
-
import { u as K, a as V } from "./spec-import-
|
|
6
|
+
import { u as K, a as V } from "./spec-import-CGPqUUjN.js";
|
|
7
7
|
import { M as q } from "./ConfirmModal-WqBfWftD.js";
|
|
8
8
|
const z = {
|
|
9
9
|
function: "functions",
|
|
@@ -249,4 +249,4 @@ function te(l) {
|
|
|
249
249
|
export {
|
|
250
250
|
te as I
|
|
251
251
|
};
|
|
252
|
-
//# sourceMappingURL=ImportSpecModal-
|
|
252
|
+
//# sourceMappingURL=ImportSpecModal-fU5RsVTa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportSpecModal-C-B8Jwxk.js","sources":["../src/chrome/ImportSpecModal.tsx"],"sourcesContent":["import {\n type ImportRow,\n type SpecImportKind,\n type SpecImportListKeys,\n buildRows,\n parseImportPaste,\n rowsReady,\n setBind,\n setCreateName,\n setUnconfigured,\n toSelections,\n withCreatedConnection,\n} from \"@w6w/embed/lib\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { AddConnectionModal, JsonEditor } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport {\n type SpecImportReferenceReport,\n useImportSpecMutation,\n useSpecPreviewMutation,\n} 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 /** Optional: where the connect form's Use existing empty state sends the user. */\n onCreateSharedCredential?: () => 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 // Two steps: \"paste\" (parse → explicit Next → ONE preview request) then \"configure\" (rows).\n const [rows, setRows] = useState<ImportRow[] | null>(null);\n const [addingFor, setAddingFor] = useState<ImportRow | null>(null);\n const importMut = useImportSpecMutation(props.project, props.listKeys);\n const previewMut = useSpecPreviewMutation(props.project);\n\n const { parsed, blockedReason } = parseImportPaste(text, kind);\n const configuring = rows !== null;\n // Create is enabled ONLY after a successful preview (never a verbatim post).\n const disabled =\n !configuring || !rowsReady(rows) || blockedReason !== null || importMut.isPending;\n\n function edit(next: string) {\n setText(next);\n setUnresolved(null);\n setError(null);\n setRows(null);\n }\n\n function next() {\n if (blockedReason !== null || parsed === null || previewMut.isPending) return;\n setError(null);\n previewMut.mutate(parsed as Record<string, unknown>, {\n onSuccess: (res) => setRows(buildRows(res.dependencies)),\n onError: (e) => {\n setRows(null);\n setError(e instanceof ApiError ? e.message : String(e));\n },\n });\n }\n\n function onFile(file: File | undefined) {\n if (!file) return;\n file.text().then(edit, (e) => setError(String(e)));\n }\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 (rows === null || blockedReason !== null || parsed === null || importMut.isPending) return;\n setError(null);\n setUnresolved(null);\n // The parsed paste plus EVERY row's selection (`unconfigured` included).\n importMut.mutate(\n { document: parsed as Record<string, unknown>, selections: toSelections(rows) },\n {\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\n function selectValue(row: ImportRow): string {\n const s = row.selection;\n return s.mode === \"bind\" ? `bind:${s.target}` : s.mode;\n }\n\n function onPick(row: ImportRow, value: string) {\n setRows((cur) => {\n if (!cur) return cur;\n if (value === \"unconfigured\") return setUnconfigured(cur, row.key);\n if (value === \"create\") return setCreateName(cur, row.key, row.createName);\n return setBind(cur, row.key, value.slice(\"bind:\".length));\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={edit}\n minHeight=\"320px\"\n aria-label={`${kind} spec document JSON`}\n />\n </div>\n\n <label className=\"muted small\">\n Or choose a <code>.json</code> file:{\" \"}\n <input\n type=\"file\"\n accept=\".json,application/json\"\n data-testid={`${collection}-import-file`}\n onChange={(e) => onFile(e.target.files?.[0])}\n />\n </label>\n\n {blockedReason && text !== \"\" && <p className=\"muted small\">{blockedReason}</p>}\n {error && <div className=\"result error\">{error}</div>}\n\n {rows && rows.length === 0 && (\n <p className=\"muted small\" data-testid={`${collection}-import-nodeps`}>\n This {kind} has no dependencies.\n </p>\n )}\n {rows && rows.length > 0 && (\n <ul className=\"list\" data-testid={`${collection}-import-rows`}>\n {rows.map((row) => (\n <li key={row.key} data-testid={`${collection}-import-row-${row.key}`}>\n <code>{row.dep.name}</code> <span className=\"muted\">({row.dep.kind})</span>{\" \"}\n {row.dep.dynamic ? (\n <span className=\"muted small\">\n Dynamic store name — configure it manually after import.\n </span>\n ) : null}\n <select\n value={selectValue(row)}\n onChange={(e) => onPick(row, e.target.value)}\n aria-label={`Configure ${row.dep.name}`}\n >\n <option value=\"unconfigured\">Leave unconfigured</option>\n {!row.dep.dynamic &&\n row.options.map((o) => (\n <option\n key={o.id}\n value={`bind:${o.id}`}\n disabled={o.compatible === false}\n title={o.reason}\n >\n {o.label}\n {o.compatible === false && o.reason ? ` — ${o.reason}` : \"\"}\n </option>\n ))}\n {row.dep.kind === \"store\" && row.dep.canCreate && !row.dep.dynamic && (\n <option value=\"create\">Create new</option>\n )}\n </select>\n {row.selection.mode === \"create\" && (\n <input\n type=\"text\"\n value={row.selection.name}\n aria-label={`New name for ${row.dep.name}`}\n onChange={(e) =>\n setRows((cur) => (cur ? setCreateName(cur, row.key, e.target.value) : cur))\n }\n />\n )}\n {row.dep.kind === \"connection\" && row.dep.app && (\n <button type=\"button\" className=\"btn ghost\" onClick={() => setAddingFor(row)}>\n Add connection\n </button>\n )}\n </li>\n ))}\n </ul>\n )}\n {addingFor && (\n <AddConnectionModal\n onCreateSharedCredential={props.onCreateSharedCredential}\n initialAppId={addingFor.dep.app}\n onClose={() => setAddingFor(null)}\n onCreated={({ connectionId }) => {\n // Append the new connection as an option and bind the row to it (no re-preview).\n const key = addingFor.key;\n setRows((cur) =>\n cur ? withCreatedConnection(cur, key, connectionId, connectionId) : cur,\n );\n setAddingFor(null);\n }}\n />\n )}\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 {!configuring && (\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={`${collection}-import-next`}\n disabled={blockedReason !== null || previewMut.isPending}\n onClick={next}\n >\n {previewMut.isPending ? \"Checking…\" : \"Next\"}\n </button>\n )}\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.submit}\n disabled={disabled}\n onClick={submit}\n >\n {importMut.isPending ? \"Importing…\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["COLLECTION","TESTIDS","ImportSpecModal","props","kind","collection","testids","text","setText","useState","error","setError","unresolved","setUnresolved","rows","setRows","addingFor","setAddingFor","importMut","useImportSpecMutation","previewMut","useSpecPreviewMutation","parsed","blockedReason","parseImportPaste","configuring","disabled","rowsReady","edit","next","res","buildRows","ApiError","onFile","file","e","goto","id","submit","toSelections","result","r","selectValue","row","s","onPick","value","cur","setUnconfigured","setCreateName","setBind","jsxs","Modal","jsx","JsonEditor","_a","o","AddConnect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A,EAAO,MAAK,UAAS,WAAU,aAAY,SAASlD,EAAM,SAAS,UAAA,SAAA,CAEpE;AAAA,MACC,CAACsB,KACA,gBAAA4B;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,eAAa,GAAGhD,CAAU;AAAA,UAC1B,UAAUkB,MAAkB,QAAQH,EAAW;AAAA,UAC/C,SAASS;AAAA,UAER,UAAAT,EAAW,YAAY,cAAc;AAAA,QAAA;AAAA,MAAA;AAAA,MAG1C,gBAAAiC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,eAAa/C,EAAQ;AAAA,UACrB,UAAAoB;AAAA,UACA,SAASY;AAAA,UAER,UAAApB,EAAU,YAAY,eAAe;AAAA,QAAA;AAAA,MAAA;AAAA,IACxC,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ImportSpecModal-fU5RsVTa.js","sources":["../src/chrome/ImportSpecModal.tsx"],"sourcesContent":["import {\n type ImportRow,\n type SpecImportKind,\n type SpecImportListKeys,\n buildRows,\n parseImportPaste,\n rowsReady,\n setBind,\n setCreateName,\n setUnconfigured,\n toSelections,\n withCreatedConnection,\n} from \"@w6w/embed/lib\";\nimport { ApiError } from \"@w6w/sdk\";\nimport { AddConnectionModal, JsonEditor } from \"@w6w/ui\";\nimport { useState } from \"react\";\nimport {\n type SpecImportReferenceReport,\n useImportSpecMutation,\n useSpecPreviewMutation,\n} 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 /** Optional: where the connect form's Use existing empty state sends the user. */\n onCreateSharedCredential?: () => 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 // Two steps: \"paste\" (parse → explicit Next → ONE preview request) then \"configure\" (rows).\n const [rows, setRows] = useState<ImportRow[] | null>(null);\n const [addingFor, setAddingFor] = useState<ImportRow | null>(null);\n const importMut = useImportSpecMutation(props.project, props.listKeys);\n const previewMut = useSpecPreviewMutation(props.project);\n\n const { parsed, blockedReason } = parseImportPaste(text, kind);\n const configuring = rows !== null;\n // Create is enabled ONLY after a successful preview (never a verbatim post).\n const disabled =\n !configuring || !rowsReady(rows) || blockedReason !== null || importMut.isPending;\n\n function edit(next: string) {\n setText(next);\n setUnresolved(null);\n setError(null);\n setRows(null);\n }\n\n function next() {\n if (blockedReason !== null || parsed === null || previewMut.isPending) return;\n setError(null);\n previewMut.mutate(parsed as Record<string, unknown>, {\n onSuccess: (res) => setRows(buildRows(res.dependencies)),\n onError: (e) => {\n setRows(null);\n setError(e instanceof ApiError ? e.message : String(e));\n },\n });\n }\n\n function onFile(file: File | undefined) {\n if (!file) return;\n file.text().then(edit, (e) => setError(String(e)));\n }\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 (rows === null || blockedReason !== null || parsed === null || importMut.isPending) return;\n setError(null);\n setUnresolved(null);\n // The parsed paste plus EVERY row's selection (`unconfigured` included).\n importMut.mutate(\n { document: parsed as Record<string, unknown>, selections: toSelections(rows) },\n {\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\n function selectValue(row: ImportRow): string {\n const s = row.selection;\n return s.mode === \"bind\" ? `bind:${s.target}` : s.mode;\n }\n\n function onPick(row: ImportRow, value: string) {\n setRows((cur) => {\n if (!cur) return cur;\n if (value === \"unconfigured\") return setUnconfigured(cur, row.key);\n if (value === \"create\") return setCreateName(cur, row.key, row.createName);\n return setBind(cur, row.key, value.slice(\"bind:\".length));\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={edit}\n minHeight=\"320px\"\n aria-label={`${kind} spec document JSON`}\n />\n </div>\n\n <label className=\"muted small\">\n Or choose a <code>.json</code> file:{\" \"}\n <input\n type=\"file\"\n accept=\".json,application/json\"\n data-testid={`${collection}-import-file`}\n onChange={(e) => onFile(e.target.files?.[0])}\n />\n </label>\n\n {blockedReason && text !== \"\" && <p className=\"muted small\">{blockedReason}</p>}\n {error && <div className=\"result error\">{error}</div>}\n\n {rows && rows.length === 0 && (\n <p className=\"muted small\" data-testid={`${collection}-import-nodeps`}>\n This {kind} has no dependencies.\n </p>\n )}\n {rows && rows.length > 0 && (\n <ul className=\"list\" data-testid={`${collection}-import-rows`}>\n {rows.map((row) => (\n <li key={row.key} data-testid={`${collection}-import-row-${row.key}`}>\n <code>{row.dep.name}</code> <span className=\"muted\">({row.dep.kind})</span>{\" \"}\n {row.dep.dynamic ? (\n <span className=\"muted small\">\n Dynamic store name — configure it manually after import.\n </span>\n ) : null}\n <select\n value={selectValue(row)}\n onChange={(e) => onPick(row, e.target.value)}\n aria-label={`Configure ${row.dep.name}`}\n >\n <option value=\"unconfigured\">Leave unconfigured</option>\n {!row.dep.dynamic &&\n row.options.map((o) => (\n <option\n key={o.id}\n value={`bind:${o.id}`}\n disabled={o.compatible === false}\n title={o.reason}\n >\n {o.label}\n {o.compatible === false && o.reason ? ` — ${o.reason}` : \"\"}\n </option>\n ))}\n {row.dep.kind === \"store\" && row.dep.canCreate && !row.dep.dynamic && (\n <option value=\"create\">Create new</option>\n )}\n </select>\n {row.selection.mode === \"create\" && (\n <input\n type=\"text\"\n value={row.selection.name}\n aria-label={`New name for ${row.dep.name}`}\n onChange={(e) =>\n setRows((cur) => (cur ? setCreateName(cur, row.key, e.target.value) : cur))\n }\n />\n )}\n {row.dep.kind === \"connection\" && row.dep.app && (\n <button type=\"button\" className=\"btn ghost\" onClick={() => setAddingFor(row)}>\n Add connection\n </button>\n )}\n </li>\n ))}\n </ul>\n )}\n {addingFor && (\n <AddConnectionModal\n onCreateSharedCredential={props.onCreateSharedCredential}\n initialAppId={addingFor.dep.app}\n onClose={() => setAddingFor(null)}\n onCreated={({ connectionId }) => {\n // Append the new connection as an option and bind the row to it (no re-preview).\n const key = addingFor.key;\n setRows((cur) =>\n cur ? withCreatedConnection(cur, key, connectionId, connectionId) : cur,\n );\n setAddingFor(null);\n }}\n />\n )}\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 {!configuring && (\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={`${collection}-import-next`}\n disabled={blockedReason !== null || previewMut.isPending}\n onClick={next}\n >\n {previewMut.isPending ? \"Checking…\" : \"Next\"}\n </button>\n )}\n <button\n type=\"button\"\n className=\"btn\"\n data-testid={testids.submit}\n disabled={disabled}\n onClick={submit}\n >\n {importMut.isPending ? \"Importing…\" : \"Create\"}\n </button>\n </div>\n </Modal>\n );\n}\n"],"names":["COLLECTION","TESTIDS","ImportSpecModal","props","kind","collection","testids","text","setText","useState","error","setError","unresolved","setUnresolved","rows","setRows","addingFor","setAddingFor","importMut","useImportSpecMutation","previewMut","useSpecPreviewMutation","parsed","blockedReason","parseImportPaste","configuring","disabled","rowsReady","edit","next","res","buildRows","ApiError","onFile","file","e","goto","id","submit","toSelections","result","r","selectValue","row","s","onPick","value","cur","setUnconfigured","setCreateName","setBind","jsxs","Modal","jsx","JsonEditor","_a","o","AddConnectionModal","connectionId","key","withCreatedConnection"],"mappings":";;;;;;;AAwBA,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;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