@w6w/embed 0.2.11 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
- package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
- package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
- package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
- package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
- package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
- package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
- package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
- package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
- package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
- package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
- package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
- package/dist/apps-ItBvnWX3.js +92 -0
- package/dist/apps-ItBvnWX3.js.map +1 -0
- package/dist/chrome/DangerZone.d.ts +4 -3
- package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
- package/dist/chrome/JsonToggle.d.ts +29 -20
- package/dist/chrome/Modal.d.ts +3 -1
- package/dist/chrome/RightRail.d.ts +6 -1
- package/dist/chrome/VersionHistoryModal.d.ts +2 -0
- package/dist/chrome/index.d.ts +1 -0
- package/dist/chrome/workspace.d.ts +32 -1
- package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
- package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
- package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
- package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
- package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
- package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
- package/dist/data-stores-UeQvwVCa.js +170 -0
- package/dist/data-stores-UeQvwVCa.js.map +1 -0
- package/dist/document-sources-DNmBojx6.js +169 -0
- package/dist/document-sources-DNmBojx6.js.map +1 -0
- package/dist/draft/use-workflow-draft.d.ts +2 -0
- package/dist/draft.mjs +2 -2
- package/dist/editor/PublishTooltip.d.ts +7 -0
- package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
- package/dist/editor/StartingStateModal.d.ts +14 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
- package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
- package/dist/editor/definition.d.ts +4 -0
- package/dist/editor/json-apply.d.ts +29 -0
- package/dist/editor/step-problems-feed.d.ts +5 -0
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor-apps-DkkC7wOQ.js +152 -0
- package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
- package/dist/editor-tools-BR27RGto.js +1683 -0
- package/dist/editor-tools-BR27RGto.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +536 -478
- package/dist/editors.mjs.map +1 -1
- package/dist/forms.mjs +3 -3
- package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
- package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
- package/dist/index.mjs +138 -108
- package/dist/index.mjs.map +1 -1
- package/dist/lib/binding-problems.d.ts +5 -1
- package/dist/lib/history-query.d.ts +45 -0
- package/dist/lib/import-bindings.d.ts +89 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/rail-settings.d.ts +1 -1
- package/dist/lib/setup-incomplete.d.ts +22 -0
- package/dist/lib/starting-data.d.ts +31 -0
- package/dist/lib/state-panel.d.ts +29 -0
- package/dist/lib/target-fields.d.ts +3 -15
- package/dist/lib/workflow-live-run.d.ts +84 -6
- package/dist/lib/workflow-validity.d.ts +64 -16
- package/dist/lib/workflow-variables.d.ts +1 -1
- package/dist/lib/workflow-version.d.ts +2 -0
- package/dist/lib.mjs +87 -72
- package/dist/lists/DataStoreList.d.ts +17 -0
- package/dist/lists/DataStoreView.d.ts +19 -0
- package/dist/lists/Logs.d.ts +19 -0
- package/dist/lists.d.ts +6 -0
- package/dist/lists.mjs +1255 -816
- package/dist/lists.mjs.map +1 -1
- package/dist/rail/ConnectionsTool.d.ts +2 -0
- package/dist/rail/HistoryTool.d.ts +2 -0
- package/dist/rail/StartingStateTool.d.ts +2 -0
- package/dist/rail/settings-sections.d.ts +4 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/constants.d.ts +12 -0
- package/dist/repos/data-stores.d.ts +84 -0
- package/dist/repos/history.d.ts +9 -0
- package/dist/repos/index.d.ts +2 -0
- package/dist/repos/spec-export.d.ts +3 -3
- package/dist/repos/spec-import.d.ts +30 -1
- package/dist/repos/step-tests.d.ts +2 -0
- package/dist/repos/webhook-listen.d.ts +35 -0
- package/dist/repos/workflows.d.ts +105 -2
- package/dist/repos.mjs +370 -328
- package/dist/repos.mjs.map +1 -1
- package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
- package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
- package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
- package/dist/spec-export-DGy5ijps.js.map +1 -0
- package/dist/spec-import-SWOonsNr.js +116 -0
- package/dist/spec-import-SWOonsNr.js.map +1 -0
- package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
- package/dist/step-tests-B4E4W3ly.js.map +1 -0
- package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
- package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
- package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
- package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
- package/dist/workflows-BZN4Hyz1.js +623 -0
- package/dist/workflows-BZN4Hyz1.js.map +1 -0
- package/package.json +3 -2
- package/src/styles.css +153 -1
- package/dist/ConfirmModal-BE-SdX-O.js +0 -185
- package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
- package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
- package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
- package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
- package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
- package/dist/apps-CboASBKr.js +0 -77
- package/dist/apps-CboASBKr.js.map +0 -1
- package/dist/coerce-input-DttlcSdO.js.map +0 -1
- package/dist/document-sources-UCwe8x77.js +0 -91
- package/dist/document-sources-UCwe8x77.js.map +0 -1
- package/dist/editor-apps-BUZWld-m.js +0 -95
- package/dist/editor-apps-BUZWld-m.js.map +0 -1
- package/dist/editor-tools-B_Lfx3kw.js +0 -1279
- package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
- package/dist/rail-settings-XYGToh00.js.map +0 -1
- package/dist/spec-export-CBbloO_n.js.map +0 -1
- package/dist/spec-import-CW6R_Wk1.js +0 -469
- package/dist/spec-import-CW6R_Wk1.js.map +0 -1
- package/dist/step-tests-CivICmTq.js.map +0 -1
- package/dist/trigger-preview-DKxfjzUY.js +0 -145
- package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
- package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
- package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
package/dist/forms.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { C as He, a as Ye } from "./CreateFunctionModal-
|
|
2
|
+
import { C as He, a as Ye } from "./CreateFunctionModal-DScxp_LN.js";
|
|
3
3
|
import { jsxs as a, jsx as e, Fragment as ne } from "react/jsx-runtime";
|
|
4
4
|
import { ApiError as L } from "@w6w/sdk";
|
|
5
5
|
import { EmptyState as U, DataTable as T, Copyable as se, EditButton as A, DeleteButton as O, useEnterSubmit as V, BudgetMeter as re } from "@w6w/ui";
|
|
6
6
|
import { useState as m } from "react";
|
|
7
|
-
import { C as W, a as oe, M as R } from "./ConfirmModal-
|
|
7
|
+
import { C as W, a as oe, M as R } from "./ConfirmModal-Pv2-A_3U.js";
|
|
8
8
|
import { u as ae } from "./project-context-Tvp-La7A.js";
|
|
9
9
|
import { i as de, d as ce, b as ue, h as me, f as he, c as ge, u as ve, g as be } from "./vault-BSEWhMYC.js";
|
|
10
|
-
import { M as Ge } from "./ModelRoutesManager-
|
|
10
|
+
import { M as Ge } from "./ModelRoutesManager-1Ac5wcas.js";
|
|
11
11
|
import { F as pe, D as fe, C as ye, I as Ne, E as Ce } from "./models-bAayQPJ_.js";
|
|
12
12
|
const Se = ["string", "number", "boolean", "json"];
|
|
13
13
|
function q(t) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(e, n) {
|
|
2
2
|
let t;
|
|
3
3
|
try {
|
|
4
4
|
t = JSON.parse(e);
|
|
@@ -17,7 +17,7 @@ function s(e, n) {
|
|
|
17
17
|
}
|
|
18
18
|
return { parsed: o, blockedReason: null };
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function p(e) {
|
|
21
21
|
switch (e) {
|
|
22
22
|
case "function":
|
|
23
23
|
case "endpoint":
|
|
@@ -28,10 +28,10 @@ function i(e) {
|
|
|
28
28
|
return ["id"];
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function k(e) {
|
|
32
32
|
return e === "function" || e === "endpoint";
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function m(e) {
|
|
35
35
|
switch (e) {
|
|
36
36
|
case "function":
|
|
37
37
|
case "workflow":
|
|
@@ -41,7 +41,7 @@ function l(e) {
|
|
|
41
41
|
return !1;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function y(e) {
|
|
45
45
|
switch (e) {
|
|
46
46
|
case "function":
|
|
47
47
|
case "workflow":
|
|
@@ -51,18 +51,19 @@ function u(e) {
|
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function b(e) {
|
|
55
55
|
switch (e) {
|
|
56
56
|
case "function":
|
|
57
57
|
return "functions";
|
|
58
58
|
case "endpoint":
|
|
59
59
|
return "endpoints";
|
|
60
60
|
case "workflow":
|
|
61
|
+
return "workflows";
|
|
61
62
|
case "connection":
|
|
62
63
|
return null;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function h(e, n) {
|
|
66
67
|
let t;
|
|
67
68
|
try {
|
|
68
69
|
t = JSON.parse(e);
|
|
@@ -74,13 +75,13 @@ function f(e, n) {
|
|
|
74
75
|
const o = t;
|
|
75
76
|
return o.id !== n.id ? { parsed: o, blockedReason: "id cannot be changed here." } : o.key !== n.key ? { parsed: o, blockedReason: "key cannot be changed here." } : { parsed: o, blockedReason: null };
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
+
function v(e, n) {
|
|
78
79
|
return e === void 0 ? { allowed: !1, reason: "Workflow not loaded yet." } : (n === void 0 ? null : n) !== e ? {
|
|
79
80
|
allowed: !1,
|
|
80
81
|
reason: "key cannot be changed here — use the Settings panel's Key field."
|
|
81
82
|
} : { allowed: !0, reason: null };
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function g(e) {
|
|
84
85
|
if (!e) return { activeTool: null };
|
|
85
86
|
try {
|
|
86
87
|
const n = JSON.parse(e);
|
|
@@ -89,23 +90,88 @@ function k(e) {
|
|
|
89
90
|
return { activeTool: null };
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function u(e) {
|
|
93
94
|
return e.status === "archived" || e.archivedAt != null;
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
-
return n ? e.slice() : e.filter((t) => !
|
|
96
|
+
function w(e, n) {
|
|
97
|
+
return n ? e.slice() : e.filter((t) => !u(t));
|
|
98
|
+
}
|
|
99
|
+
function l(e) {
|
|
100
|
+
return e.kind === "store" ? e.dynamic ? ["unconfigured"] : e.canCreate ? ["bind", "create", "unconfigured"] : ["bind", "unconfigured"] : ["bind", "unconfigured"];
|
|
101
|
+
}
|
|
102
|
+
function c(e, n) {
|
|
103
|
+
return l(e).includes(n.mode);
|
|
104
|
+
}
|
|
105
|
+
function R(e) {
|
|
106
|
+
return e.map((n) => ({
|
|
107
|
+
key: n.key,
|
|
108
|
+
dep: n,
|
|
109
|
+
options: [...n.options],
|
|
110
|
+
selection: n.suggested,
|
|
111
|
+
createName: n.suggested.mode === "create" ? n.suggested.name : n.name
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
function s(e, n, t) {
|
|
115
|
+
return e.map((o) => o.key === n ? t(o) : o);
|
|
116
|
+
}
|
|
117
|
+
function N(e, n, t) {
|
|
118
|
+
return s(e, n, (o) => {
|
|
119
|
+
const r = o.options.find((a) => a.id === t);
|
|
120
|
+
if (!r || r.compatible === !1) return o;
|
|
121
|
+
const i = { mode: "bind", target: t };
|
|
122
|
+
return c(o.dep, i) ? { ...o, selection: i } : o;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function A(e, n, t) {
|
|
126
|
+
return s(e, n, (o) => {
|
|
127
|
+
const r = { mode: "create", name: t };
|
|
128
|
+
return c(o.dep, r) ? { ...o, selection: r, createName: t } : o;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function S(e, n) {
|
|
132
|
+
return s(e, n, (t) => ({ ...t, selection: { mode: "unconfigured" } }));
|
|
133
|
+
}
|
|
134
|
+
function J(e, n, t, o) {
|
|
135
|
+
return s(e, n, (r) => {
|
|
136
|
+
if (r.dep.kind !== "connection") return r;
|
|
137
|
+
const i = r.options.some((a) => a.id === t) ? r.options : [...r.options, { id: t, label: o, source: "connection" }];
|
|
138
|
+
return { ...r, options: i, selection: { mode: "bind", target: t } };
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function d(e) {
|
|
142
|
+
return e.selection.mode !== "create" || e.selection.name.trim() !== "";
|
|
143
|
+
}
|
|
144
|
+
function O(e) {
|
|
145
|
+
return e.every(d);
|
|
146
|
+
}
|
|
147
|
+
function T(e) {
|
|
148
|
+
const n = {};
|
|
149
|
+
for (const t of e) {
|
|
150
|
+
const o = t.selection;
|
|
151
|
+
n[t.key] = o.mode === "create" ? { mode: "create", name: o.name.trim() } : o;
|
|
152
|
+
}
|
|
153
|
+
return n;
|
|
97
154
|
}
|
|
98
155
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
k as
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
156
|
+
l as a,
|
|
157
|
+
R as b,
|
|
158
|
+
y as c,
|
|
159
|
+
m as d,
|
|
160
|
+
h as e,
|
|
161
|
+
d as f,
|
|
162
|
+
O as g,
|
|
163
|
+
k as h,
|
|
164
|
+
u as i,
|
|
165
|
+
A as j,
|
|
166
|
+
S as k,
|
|
167
|
+
b as l,
|
|
168
|
+
p as m,
|
|
169
|
+
v as n,
|
|
170
|
+
f as p,
|
|
171
|
+
g as r,
|
|
172
|
+
N as s,
|
|
173
|
+
T as t,
|
|
174
|
+
w as v,
|
|
175
|
+
J as w
|
|
110
176
|
};
|
|
111
|
-
//# sourceMappingURL=
|
|
177
|
+
//# sourceMappingURL=import-bindings-EUtxZ9Ti.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-bindings-EUtxZ9Ti.js","sources":["../src/lib/import-paste.ts","../src/lib/rail-settings.ts","../src/lib/import-bindings.ts"],"sourcesContent":["/**\n * Pure decision behind `ImportSpecModal`'s Submit gate (T1.2.1, generalizing T3.2.1's A3 over all\n * three spec kinds).\n *\n * `/spec/import` accepts all three spec kinds at one route (T2.1.2 §B), and this affordance is now\n * mounted on the Functions, Endpoints and Workflows lists alike — each instance passing its own\n * `expectedKind`. Pasting a document of the WRONG kind onto a given list would still create a row\n * server-side and then send the operator to e.g. `functions/<ep_…>`, which 404s in the target\n * page's editor. So this module refuses, client-side, before any request is ever sent: (1) text\n * that isn't JSON, (2) a parse result that isn't a plain object, (3) a parsed `kind` that doesn't\n * match `expectedKind`.\n *\n * Nothing beyond that is checked here — `specVersion`, `callable`'s shape,\n * connection/reference resolvability, all of it is the SERVER's job\n * (T2.1.2 §B); duplicating any of it here would drift from what the route\n * actually enforces.\n *\n * `node --test` throws `ERR_UNKNOWN_FILE_EXTENSION` on anything reaching the\n * `@w6w/ui` import graph (`src/lib/alias-rail.ts`'s docblock), so this module\n * takes no value import at all — it has no dependency to avoid in the first\n * place.\n */\n\n/** The parsed paste, once it is confirmed to be a plain JSON object. */\nexport type ParsedSpecDocument = Record<string, unknown>;\n\n/** The one kind a given mount of the Import affordance expects — see `ImportSpecModal`'s `kind` prop. */\nexport type ExpectedSpecKind = \"function\" | \"endpoint\" | \"workflow\";\n\nexport interface ImportPasteResult {\n /**\n * The parsed JSON when it is a plain object — populated even when\n * `blockedReason` names a wrong `kind`, so a caller could still inspect\n * what was found. `null` when the text didn't even parse to an object.\n */\n parsed: ParsedSpecDocument | null;\n /** `null` exactly when the paste is a plausible spec document of `expectedKind`. */\n blockedReason: string | null;\n}\n\n/**\n * Total: never throws, always returns. `JSON.parse` is the only thing here\n * that can throw, and it is caught.\n */\nexport function parseImportPaste(text: string, expectedKind: ExpectedSpecKind): ImportPasteResult {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { parsed: null, blockedReason: \"Not valid JSON.\" };\n }\n\n if (value === null || Array.isArray(value) || typeof value !== \"object\") {\n return { parsed: null, blockedReason: \"Expected a JSON object, not a bare value or a list.\" };\n }\n\n const parsed = value as ParsedSpecDocument;\n\n if (parsed.kind !== expectedKind) {\n const found = typeof parsed.kind === \"string\" ? parsed.kind : \"unknown\";\n return {\n parsed,\n blockedReason: `This document's kind is \"${found}\", not \"${expectedKind}\" — paste a \"${expectedKind}\" spec document here.`,\n };\n }\n\n return { parsed, blockedReason: null };\n}\n","/**\n * Pure decisions behind the right rail's Settings tool (`src/ui/rail/SettingsTool.tsx`,\n * `id: \"aliases\"`, `title: \"Settings\"` since T3.1.2 — the tool widened past aliases alone\n * into a resource Settings panel: a metadata block and, for Functions and Endpoints, an\n * Export / Edit JSON action row (T3.3.1 — the definition itself no longer renders in the\n * panel, only the two buttons that open it in a modal), alongside the alias list\n * `../lib/alias-rail.ts` already decides). Split out so `node --test` can gate them\n * directly — same reasoning as\n * `alias-rail.ts`'s own header: `node --test` throws `ERR_UNKNOWN_FILE_EXTENSION` on\n * anything reaching the `@w6w/ui` / `Layout.tsx` import graph, and `src/ui/workspace.tsx`\n * sits one hop from that barrel through `Layout.tsx`'s import graph. So this module\n * declares its own structural mirror of the kinds it cares about instead of importing\n * `WorkspaceKind`, and takes only `import type` throughout.\n *\n * T4.1.1 widens this file's scope past the Settings tool itself: `restoreRailState`\n * (A2, `RightRail.tsx`'s persisted-state read path) and `isRowArchived`/`visibleRows`\n * (A6, the three listing pages' \"Show archived\" toggle) are pure decisions with the\n * exact same `node --test`-reachability constraint, so they land here rather than in\n * a new sibling module the contract's `inputs.touch` list didn't ask for.\n */\n\n/** Structural mirror of `WorkspaceCallable[\"kind\"]` (`src/ui/workspace.tsx`) — every kind\n * the rail can have open, not only the two this tool's action-row/metadata sections\n * apply to. */\nexport type RailSettingsKind = \"workflow\" | \"function\" | \"endpoint\" | \"connection\";\n\n/**\n * A4/T3.1.1: which metadata rows the Settings panel shows for this kind. `id` always\n * (every kind the tool is available on carries one). `key` for `function`/`endpoint`\n * (unchanged) AND, since T3.1.1, `workflow` too — `GET /workflows` now carries `key`\n * on every row (`string | null`, D-1: nullable, no backfill), and the panel renders it\n * as an editable control for `function`/`workflow` and the existing read-only `<code>`\n * for `endpoint` (`SettingsTool.tsx` gates that render choice on `ctx.kind` directly,\n * never on this array — an Endpoint's `key` entry here must not be read as \"editable\").\n * `updatedAt` stays `function`/`endpoint`-only: nothing asks for a Workflow Updated row,\n * and adding one would be a second, unrelated rail row. Deliberately never `createdAt`\n * (note 6): neither `GET /functions/:id` nor `GET /endpoints/:id` returns it, so\n * surfacing it would take a server change for one cosmetic field — this function's own\n * absence of a `createdAt` arm is half of that gate, the other half is the negative\n * assertion in the caller's markup.\n */\nexport function metadataFieldsForKind(\n kind: RailSettingsKind,\n): ReadonlyArray<\"id\" | \"key\" | \"updatedAt\"> {\n switch (kind) {\n case \"function\":\n case \"endpoint\":\n return [\"id\", \"key\", \"updatedAt\"];\n case \"workflow\":\n return [\"id\", \"key\"];\n case \"connection\":\n return [\"id\"];\n }\n}\n\n/**\n * A2/A5: the Export / Edit JSON action row exists for `function`/`endpoint` only. A\n * Workflow already has its own read-only Definition card\n * (`pages/WorkflowDetailPage.tsx:371-388`); a Connection has no stored definition shaped\n * like these two to show at all. (T3.3.1: renamed from the panel's earlier JSON-section\n * name — there is no JSON section left in the panel to describe, only the two buttons\n * that open one in a modal.)\n */\nexport function hasDefinitionActions(kind: RailSettingsKind): boolean {\n return kind === \"function\" || kind === \"endpoint\";\n}\n\n/**\n * A1/T3.1.1: does this kind have a version-history browser (the read-only browse list plus\n * Publish and Enable/Disable) in the Settings panel? `true` for `function`/`workflow`/`endpoint`,\n * `false` for `connection` — written as a `switch` naming every one of the four `RailSettingsKind`\n * arms explicitly, with no `default:`, matching {@link specCollectionForKind}'s shape and the\n * reason its own docblock gives (`:69` below — \"every one of the four `RailSettingsKind` arms is\n * named explicitly below\" so a kind can never silently fall through). Deliberately NOT derived\n * from {@link hasDefinitionActions}, which is `function`/`endpoint`-only: History covers Workflow\n * too, so deriving one from the other would silently drop it.\n */\nexport function hasVersionHistory(kind: RailSettingsKind): boolean {\n switch (kind) {\n case \"function\":\n case \"workflow\":\n case \"endpoint\":\n return true;\n case \"connection\":\n return false;\n }\n}\n\n/**\n * A1/T1.3.1: does this kind get a Delete (or, for `workflow`, Archive-then-Delete) affordance at\n * the bottom of the Settings panel? `true` for `function`/`workflow`/`endpoint`, `false` for\n * `connection` — written as a named `switch` naming every one of the four `RailSettingsKind` arms\n * explicitly, with no `default:`, matching {@link hasVersionHistory}'s exact shape (`:72-81` above)\n * for the same reason its own doc comment gives: a kind can never silently fall through. Deliberately\n * NOT derived from {@link hasVersionHistory} even though the two currently agree on every arm — a\n * future kind that gets history but not deletion (or vice versa) must not silently inherit the\n * wrong answer from a sibling predicate.\n */\nexport function hasDelete(kind: RailSettingsKind): boolean {\n switch (kind) {\n case \"function\":\n case \"workflow\":\n case \"endpoint\":\n return true;\n case \"connection\":\n return false;\n }\n}\n\n/**\n * A4: which `/<collection>/:id/spec` route the Export button's `useSpecQuery`\n * (`../repos/spec-export.ts`) must call for this kind — `null` for the two kinds A2's\n * action row never renders on. Kept in lockstep with {@link hasDefinitionActions}\n * (both are `function`/`endpoint`-only) but expressed as its own total function rather\n * than derived from it, so a Function can never be exported through\n * `/endpoints/:id/spec` by a wrong `if`/`else` fallthrough — every one of the four\n * `RailSettingsKind` arms is named explicitly below.\n */\nexport function specCollectionForKind(\n kind: RailSettingsKind,\n): \"functions\" | \"endpoints\" | \"workflows\" | null {\n switch (kind) {\n case \"function\":\n return \"functions\";\n case \"endpoint\":\n return \"endpoints\";\n case \"workflow\":\n return \"workflows\";\n case \"connection\":\n return null;\n }\n}\n\n/** What A8's `evaluateEdit` needs to know about the row already on screen — deliberately\n * narrower than a whole `FunctionDef`/`EndpointDef`: the two fields a hand-edit must not\n * be allowed to change out from under the row it opened on. */\nexport interface EditStored {\n id: string;\n key: string;\n}\n\n/** A8's total function's result: the parsed body (when parseable and a plain object, even\n * if it goes on to fail arm 2 or 3 — the modal still has something to inspect for the\n * render, just never something Save may submit) plus the one reason Save is refused, or\n * `null` when the edit is allowed through. */\nexport interface EditEvaluation {\n parsed: Record<string, unknown> | null;\n blockedReason: string | null;\n}\n\n/**\n * A8: is this edited text a Save the rail may submit? A total function over the modal's\n * OWN text state — never `JsonEditor`'s `onValidityChange` (note 10: the only browser\n * harness this repo has stubs `JsonEditor` with a callback that is wired but never\n * invoked, so a Save gated on it would look gated and be inert; parsing `text` here is\n * behaviourally identical and fully observable by a page guard).\n *\n * Three refusals, evaluated in order, each named for the near-miss it kills:\n * 1. the text does not parse as JSON, or parses to something that is not a plain object\n * (`null` and an array both fail here, not a dedicated fourth arm — a\n * `FunctionDef`/`EndpointDef` is never legitimately either);\n * 2. `parsed.id !== stored.id` (note 9 — `FunctionsRepo.upsert` selects the row by\n * `definition.id`, so an edited id does not edit this row, it creates or hijacks a\n * different one);\n * 3. `parsed.key !== stored.key` (note 8 — `POST /endpoints` 409s on a changed key while\n * `POST /functions` silently accepts one; locking it here keeps both kinds behaving\n * the same from this one modal).\n */\nexport function evaluateEdit(text: string, stored: EditStored): EditEvaluation {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { parsed: null, blockedReason: \"Not valid JSON.\" };\n }\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return { parsed: null, blockedReason: \"Not valid JSON.\" };\n }\n const parsed = value as Record<string, unknown>;\n if (parsed.id !== stored.id) {\n return { parsed, blockedReason: \"id cannot be changed here.\" };\n }\n if (parsed.key !== stored.key) {\n return { parsed, blockedReason: \"key cannot be changed here.\" };\n }\n return { parsed, blockedReason: null };\n}\n\n/** A7/D-3's total function's result: may the save proceed, and if not, why —\n * rendered verbatim in `WorkflowsPage.tsx`'s existing error/banner idiom. */\nexport interface KeyEditEvaluation {\n allowed: boolean;\n reason: string | null;\n}\n\n/**\n * D-3: is a Workflow save carrying this `key` one `WorkflowsPage.tsx`'s raw-JSON\n * editor may submit? The right rail's Key control (`SettingsTool.tsx`) is the ONLY\n * path allowed to assign or change a workflow's key (see this project's Requirement);\n * this total function is what keeps a hand-edit of the JSON — via the Save button OR\n * auto-save, both of which must fold this in (see `WorkflowsPage.tsx`'s `canSave`) —\n * from doing it silently instead.\n *\n * `loadedKey` is the key `WorkflowsPage.tsx` most recently loaded FROM THE SERVER\n * (its own `loadedKeyRef`, captured at both of its load sites — the initial `editId`\n * effect and `reloadFromServer`). `undefined` means nothing has loaded yet, which\n * refuses unconditionally: there is nothing yet to compare the parsed text against,\n * so allowing the save through would let an unloaded/stale comparison pass by\n * accident. Once loaded, `loadedKey` is `string | null` (P5's unset state, D-1).\n *\n * `parsedKey` is whatever the parsed JSON text's own `key` field currently holds.\n * `undefined` (the field is absent from the text) is treated exactly like an\n * explicit `null` — both mean \"no key\" on the wire, and a definition that dropped\n * the field entirely must be refused exactly like one that changed it, never waved\n * through as \"nothing to compare\".\n */\nexport function workflowKeyEditAllowed(\n loadedKey: string | null | undefined,\n parsedKey: unknown,\n): KeyEditEvaluation {\n if (loadedKey === undefined) {\n return { allowed: false, reason: \"Workflow not loaded yet.\" };\n }\n const normalizedParsed = parsedKey === undefined ? null : parsedKey;\n if (normalizedParsed !== loadedKey) {\n return {\n allowed: false,\n reason: \"key cannot be changed here — use the Settings panel's Key field.\",\n };\n }\n return { allowed: true, reason: null };\n}\n\n/**\n * T4.1.1/A2: the shape actually written to `localStorage` for the right\n * rail's persisted state (`RightRail.tsx`'s `PersistedRail`) — `activeTool`\n * ONLY. `open` is deliberately absent from this interface, not merely\n * unwritten: {@link restoreRailState} below has nothing to read it FROM, so\n * a pre-existing `{\"open\":true,…}` value written before this task cannot\n * reopen the rail even by accident.\n */\nexport interface StoredRailState {\n activeTool: string | null;\n}\n\n/**\n * A2: parses `localStorage`'s raw rail entry into {@link StoredRailState}.\n * Missing/unparsable input, or a non-string `activeTool`, all fall back to\n * `{ activeTool: null }` — the same defensive shape `RightRail.tsx`'s own\n * `readStoredState` used before this task, minus the `open` field entirely.\n * `RightRail.tsx` is the one caller; it combines this result with a hardcoded\n * `open: false` on every read (D-I0-2) — that combination happens there, not\n * here, because `open`'s absence from THIS function's return type is the\n * proof a page guard can pin: there is no `open` member left to misread.\n */\nexport function restoreRailState(raw: string | null): StoredRailState {\n if (!raw) return { activeTool: null };\n try {\n const parsed = JSON.parse(raw) as Partial<Record<string, unknown>>;\n return { activeTool: typeof parsed.activeTool === \"string\" ? parsed.activeTool : null };\n } catch {\n return { activeTool: null };\n }\n}\n\n/**\n * A6: a listing row either Workflow, Function or Endpoint's list carries —\n * whichever archived signal the row's own kind uses. Workflow rows signal\n * archived via the existing `status === \"archived\"` (`WorkflowSummary`);\n * Function/Endpoint rows via the new `archivedAt` column T1.1.1 ships\n * (`string | null`). Both fields optional so one predicate below covers all\n * three wire shapes without a per-kind branch at each listing page's call\n * site.\n */\nexport interface ArchivableRow {\n status?: string;\n archivedAt?: string | null;\n}\n\n/**\n * A6: is this row archived? Archived when the row's `status` is `\"archived\"` OR it carries a\n * non-null `archivedAt` (Endpoint rows carry both fields; Workflow rows carry a `status` that is\n * `\"archived\"` exactly when `archivedAt` is set).\n */\nexport function isRowArchived(row: ArchivableRow): boolean {\n return row.status === \"archived\" || row.archivedAt != null;\n}\n\n/**\n * A6: which rows a listing page's \"Show archived\" toggle should render.\n * `showArchived` false (the default) drops every archived row; `true`\n * reveals them ALONGSIDE the live ones — an include, never a toggle that\n * hides the rest (the contract's mutation M6: a toggle that hides LIVE rows\n * once ON must fail the \"both a live and an archived row survive together\"\n * case below; M7: defaulting to showing archived rows must fail the\n * toggle-OFF case). One pure function shared by `WorkflowsPage.tsx`,\n * `FunctionsPage.tsx` and `EndpointsPage.tsx` rather than three inline\n * `.filter`s.\n */\nexport function visibleRows<T extends ArchivableRow>(\n rows: readonly T[],\n showArchived: boolean,\n): T[] {\n return showArchived ? rows.slice() : rows.filter((row) => !isRowArchived(row));\n}\n","/**\n * Pure row logic behind `ImportSpecModal`'s configure step (T2.1.1, IF-1 / D-B8 / D-B9).\n *\n * Turns the server's `POST /spec/preview` dependencies into editable rows and back into the\n * `selections` map the import body carries. The client NEVER ranks: a row's initial selection is\n * exactly the server's `suggested`. Every dependency yields exactly one selection on the way out —\n * `{mode:\"unconfigured\"}` included, never omitted and never upgraded to a suggestion the user\n * cleared.\n *\n * `node --test` throws `ERR_UNKNOWN_FILE_EXTENSION` on anything reaching the `@w6w/ui` import graph\n * (see `lib/import-paste.ts`), so this module takes no value import at all.\n */\n\nexport type DependencyKind = \"connection\" | \"var\" | \"secret\" | \"const\" | \"store\";\n\nexport type Selection =\n | { mode: \"bind\"; target: string }\n | { mode: \"create\"; name: string }\n | { mode: \"unconfigured\" };\n\nexport type SelectionMode = Selection[\"mode\"];\n\nexport interface DependencyOption {\n id: string;\n label: string;\n source: \"connection\" | \"built-in\" | \"var\" | \"secret\" | \"const\" | \"store\";\n authKey?: string;\n compatible?: boolean;\n reason?: string;\n}\n\nexport interface SpecDependency {\n key: string;\n kind: DependencyKind;\n name: string;\n app?: string;\n authHint?: { method: \"built-in\" } | { method: \"authKey\"; authKey: string };\n usages: { nodeId: string | null; path: string; access?: \"read\" | \"write\" | \"delete\" }[];\n store?: {\n kind: \"kv\" | \"doc\" | \"table\" | null;\n schema: unknown | null;\n access: { read: boolean; write: boolean; delete: boolean };\n };\n dynamic?: true;\n}\n\nexport interface PreviewDependency extends SpecDependency {\n options: DependencyOption[];\n suggested: Selection;\n canCreate: boolean;\n}\n\nexport interface ImportRow {\n key: string;\n dep: PreviewDependency;\n /** Options offered to the row (the server's, plus any connection created in-modal). */\n options: DependencyOption[];\n selection: Selection;\n /** Remembered name for `create`, so toggling modes does not lose an edit. */\n createName: string;\n}\n\n/** IF-1 \"Allowed modes\". */\nexport function allowedModes(dep: PreviewDependency): SelectionMode[] {\n if (dep.kind === \"store\") {\n if (dep.dynamic) return [\"unconfigured\"];\n return dep.canCreate ? [\"bind\", \"create\", \"unconfigured\"] : [\"bind\", \"unconfigured\"];\n }\n return [\"bind\", \"unconfigured\"];\n}\n\nfunction selectionAllowed(dep: PreviewDependency, s: Selection): boolean {\n return allowedModes(dep).includes(s.mode);\n}\n\n/** One row per dependency; the initial selection is `suggested` verbatim (D-B9). */\nexport function buildRows(deps: readonly PreviewDependency[]): ImportRow[] {\n return deps.map((dep) => ({\n key: dep.key,\n dep,\n options: [...dep.options],\n selection: dep.suggested,\n createName: dep.suggested.mode === \"create\" ? dep.suggested.name : dep.name,\n }));\n}\n\nfunction update(\n rows: readonly ImportRow[],\n key: string,\n fn: (row: ImportRow) => ImportRow,\n): ImportRow[] {\n return rows.map((r) => (r.key === key ? fn(r) : r));\n}\n\n/** Bind a row to an option. Refused (row unchanged) for an unknown / incompatible option or a disallowed mode. */\nexport function setBind(rows: readonly ImportRow[], key: string, target: string): ImportRow[] {\n return update(rows, key, (row) => {\n const opt = row.options.find((o) => o.id === target);\n if (!opt || opt.compatible === false) return row;\n const next: Selection = { mode: \"bind\", target };\n return selectionAllowed(row.dep, next) ? { ...row, selection: next } : row;\n });\n}\n\n/** Switch a store row to `create` / edit its name. Refused unless `create` is allowed. */\nexport function setCreateName(rows: readonly ImportRow[], key: string, name: string): ImportRow[] {\n return update(rows, key, (row) => {\n const next: Selection = { mode: \"create\", name };\n return selectionAllowed(row.dep, next) ? { ...row, selection: next, createName: name } : row;\n });\n}\n\n/** Leave the dependency unconfigured (always allowed). */\nexport function setUnconfigured(rows: readonly ImportRow[], key: string): ImportRow[] {\n return update(rows, key, (row) => ({ ...row, selection: { mode: \"unconfigured\" } }));\n}\n\n/** A connection was just created via \"Add connection\": offer it and bind the row to it. */\nexport function withCreatedConnection(\n rows: readonly ImportRow[],\n key: string,\n id: string,\n label: string,\n): ImportRow[] {\n return update(rows, key, (row) => {\n if (row.dep.kind !== \"connection\") return row;\n const options = row.options.some((o) => o.id === id)\n ? row.options\n : [...row.options, { id, label, source: \"connection\" as const }];\n return { ...row, options, selection: { mode: \"bind\", target: id } };\n });\n}\n\n/** Whether a row can be submitted: a `create` needs a non-blank name. */\nexport function rowReady(row: ImportRow): boolean {\n return row.selection.mode !== \"create\" || row.selection.name.trim() !== \"\";\n}\n\nexport function rowsReady(rows: readonly ImportRow[]): boolean {\n return rows.every(rowReady);\n}\n\n/** The import body's `selections`: ONE entry per dependency key, `unconfigured` included. */\nexport function toSelections(rows: readonly ImportRow[]): Record<string, Selection> {\n const out: Record<string, Selection> = {};\n for (const row of rows) {\n const s = row.selection;\n out[row.key] = s.mode === \"create\" ? { mode: \"create\", name: s.name.trim() } : s;\n }\n return out;\n}\n"],"names":["parseImportPaste","text","expectedKind","value","parsed","found","metadataFieldsForKind","kind","hasDefinitionActions","hasVersionHistory","hasDelete","specCollectionForKind","evaluateEdit","stored","workflowKeyEditAllowed","loadedKey","parsedKey","restoreRailState","raw","isRowArchived","row","visibleRows","rows","showArchived","allowedModes","dep","selectionAllowed","s","buildRows","deps","update","key","fn","r","setBind","target","opt","o","next","setCreateName","name","setUnconfigured","withCreatedConnection","id","label","options","rowReady","rowsReady","toSelections","out"],"mappings":"AA4CO,SAASA,EAAiBC,GAAcC,GAAmD;AAChG,MAAIC;AACJ,MAAI;AACF,IAAAA,IAAQ,KAAK,MAAMF,CAAI;AAAA,EACzB,QAAQ;AACN,WAAO,EAAE,QAAQ,MAAM,eAAe,kBAAA;AAAA,EACxC;AAEA,MAAIE,MAAU,QAAQ,MAAM,QAAQA,CAAK,KAAK,OAAOA,KAAU;AAC7D,WAAO,EAAE,QAAQ,MAAM,eAAe,sDAAA;AAGxC,QAAMC,IAASD;AAEf,MAAIC,EAAO,SAASF,GAAc;AAChC,UAAMG,IAAQ,OAAOD,EAAO,QAAS,WAAWA,EAAO,OAAO;AAC9D,WAAO;AAAA,MACL,QAAAA;AAAA,MACA,eAAe,4BAA4BC,CAAK,WAAWH,CAAY,gBAAgBA,CAAY;AAAA,IAAA;AAAA,EAEvG;AAEA,SAAO,EAAE,QAAAE,GAAQ,eAAe,KAAA;AAClC;AC1BO,SAASE,EACdC,GAC2C;AAC3C,UAAQA,GAAA;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AACH,aAAO,CAAC,MAAM,OA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AAAA,EAClE,CAAC;AACH;AAGO,SAASG,EAAS1B,GAAyB;AAChD,SAAOA,EAAI,UAAU,SAAS,YAAYA,EAAI,UAAU,KAAK,WAAW;AAC1E;AAEO,SAAS2B,EAAUzB,GAAqC;AAC7D,SAAOA,EAAK,MAAMwB,CAAQ;AAC5B;AAGO,SAASE,EAAa1B,GAAuD;AAClF,QAAM2B,IAAiC,CAAA;AACvC,aAAW7B,KAAOE,GAAM;AACtB,UAAMK,IAAIP,EAAI;AACd,IAAA6B,EAAI7B,EAAI,GAAG,IAAIO,EAAE,SAAS,WAAW,EAAE,MAAM,UAAU,MAAMA,EAAE,KAAK,KAAA,MAAWA;AAAA,EACjF;AACA,SAAOsB;AACT;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { QueryClientProvider as
|
|
4
|
-
import { W6WProvider as
|
|
2
|
+
import { jsx as c, jsxs as N } from "react/jsx-runtime";
|
|
3
|
+
import { QueryClientProvider as O, QueryClient as G, useQuery as z } from "@tanstack/react-query";
|
|
4
|
+
import { W6WProvider as J, useW6WClient as P, useW6WSession as H, createW6WUiAdapter as V } from "@w6w/react";
|
|
5
5
|
import { W6WUIProvider as X } from "@w6w/ui";
|
|
6
|
-
import { useState as
|
|
6
|
+
import { useState as j, useRef as T, useEffect as w, useCallback as R, useMemo as v, useContext as Y, createContext as Z } from "react";
|
|
7
7
|
import { E as _ } from "./client-context-CX61Bgw-.js";
|
|
8
|
-
import { c as
|
|
9
|
-
import { E as
|
|
10
|
-
import { b as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
8
|
+
import { c as ee, D as te } from "./draft-registry-YF0tqNN0.js";
|
|
9
|
+
import { E as re, a as oe } from "./project-context-Tvp-La7A.js";
|
|
10
|
+
import { b as Ne } from "./project-context-Tvp-La7A.js";
|
|
11
|
+
import { j as ne } from "./connections-CzsCyIxY.js";
|
|
12
|
+
import { x as se } from "./credentials-Cn92LGhJ.js";
|
|
13
|
+
import { e as ie, c as ue } from "./data-stores-UeQvwVCa.js";
|
|
14
|
+
import { r as ae } from "./fields-DvS8XZFc.js";
|
|
15
|
+
import { l as ce } from "./models-bAayQPJ_.js";
|
|
16
|
+
import { path as q } from "@w6w/sdk";
|
|
17
|
+
import { s as le, t as de, J as fe } from "./workflows-BZN4Hyz1.js";
|
|
18
|
+
import { E as pe } from "./theme-context-E2ZhlXDX.js";
|
|
19
|
+
class me extends Error {
|
|
17
20
|
constructor(s) {
|
|
18
21
|
super("The w6w API rejected the embed session token (401).", { cause: s }), this.name = "EmbedAuthError";
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
function
|
|
24
|
+
function ye(n, s, e) {
|
|
22
25
|
if (e) return { status: "error", error: e };
|
|
23
|
-
switch (
|
|
26
|
+
switch (n) {
|
|
24
27
|
case "ready":
|
|
25
28
|
case "renewing":
|
|
26
29
|
return { status: "ready", error: null };
|
|
@@ -31,137 +34,164 @@ function le(t, s, e) {
|
|
|
31
34
|
return { status: "connecting", error: null };
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
37
|
+
async function he(n, s) {
|
|
38
|
+
return (await n.request({
|
|
39
|
+
method: "POST",
|
|
40
|
+
path: q`/subscriptions/${s}/listen`,
|
|
41
|
+
body: {}
|
|
42
|
+
})).body;
|
|
43
|
+
}
|
|
44
|
+
async function be(n, s, e, i) {
|
|
45
|
+
return (await n.request({
|
|
46
|
+
method: "GET",
|
|
47
|
+
path: q`/subscriptions/${s}/listen/${e}`,
|
|
48
|
+
query: { wait: String((i == null ? void 0 : i.waitSeconds) ?? 0) },
|
|
49
|
+
signal: i == null ? void 0 : i.signal
|
|
50
|
+
})).body.session;
|
|
51
|
+
}
|
|
52
|
+
async function je(n, s, e) {
|
|
53
|
+
await n.request({
|
|
54
|
+
method: "DELETE",
|
|
55
|
+
path: q`/subscriptions/${s}/listen/${e}`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function I() {
|
|
59
|
+
return new G({
|
|
36
60
|
defaultOptions: { queries: { retry: !1, refetchOnWindowFocus: !1 } }
|
|
37
61
|
});
|
|
38
62
|
}
|
|
39
|
-
function
|
|
40
|
-
return /* @__PURE__ */
|
|
63
|
+
function we({ children: n }) {
|
|
64
|
+
return /* @__PURE__ */ c(_, { client: P(), children: n });
|
|
41
65
|
}
|
|
42
|
-
function
|
|
43
|
-
const e =
|
|
44
|
-
const
|
|
45
|
-
return typeof
|
|
46
|
-
const o =
|
|
47
|
-
return o ? (await
|
|
48
|
-
}), typeof
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
function ve({ theme: n, children: s }) {
|
|
67
|
+
const e = P(), i = oe(), a = v(() => {
|
|
68
|
+
const t = V(e);
|
|
69
|
+
return typeof t.updateConnection != "function" && (t.updateConnection = (r, o) => ne(e, r, o)), se(t, e), typeof t.listModelRoutes != "function" && (t.listModelRoutes = async (r) => {
|
|
70
|
+
const o = r || i;
|
|
71
|
+
return o ? (await ce(e, o)).map((f) => ({ name: f.name, model: f.modelId, status: f.status })) : [];
|
|
72
|
+
}), typeof t.listDataStores != "function" && (t.listDataStores = async (r) => {
|
|
73
|
+
const o = r || i;
|
|
74
|
+
return o ? ie(e, o) : [];
|
|
75
|
+
}), typeof t.listDataStoreEntries != "function" && (t.listDataStoreEntries = async (r, o) => {
|
|
76
|
+
const u = o.project || i;
|
|
77
|
+
return u ? ue(e, u, r, o) : { items: [] };
|
|
78
|
+
}), typeof t.loadNodeSamples != "function" && (t.loadNodeSamples = (r) => le(e, r)), typeof t.loadTestInputs != "function" && (t.loadTestInputs = (r) => de(e, r)), typeof t.saveTestInput != "function" && (t.saveTestInput = (r, o, u) => fe(e, r, o, u)), typeof t.resolveActionFields != "function" && (t.resolveActionFields = (r, o, u, f) => ae(e, r, o, u, f)), typeof t.startWebhookListen != "function" && (t.startWebhookListen = (r) => he(e, r), t.pollWebhookListen = (r, o, u) => be(e, r, o, u), t.stopWebhookListen = (r, o) => je(e, r, o)), t;
|
|
79
|
+
}, [e, i]);
|
|
80
|
+
return /* @__PURE__ */ c(X, { api: a, theme: n, children: /* @__PURE__ */ c(pe.Provider, { value: n, children: s }) });
|
|
51
81
|
}
|
|
52
|
-
const
|
|
53
|
-
function
|
|
54
|
-
return Y(
|
|
82
|
+
const F = Z({ status: "connecting", error: null });
|
|
83
|
+
function $e() {
|
|
84
|
+
return Y(F);
|
|
55
85
|
}
|
|
56
|
-
function
|
|
57
|
-
eager:
|
|
86
|
+
function Ee({
|
|
87
|
+
eager: n,
|
|
58
88
|
authError: s,
|
|
59
89
|
onAcquire: e,
|
|
60
|
-
children:
|
|
90
|
+
children: i
|
|
61
91
|
}) {
|
|
62
|
-
const { status:
|
|
92
|
+
const { status: a, error: t, refresh: r } = H();
|
|
63
93
|
w(() => {
|
|
64
|
-
|
|
65
|
-
}, [
|
|
66
|
-
(
|
|
67
|
-
}, [
|
|
68
|
-
const o =
|
|
69
|
-
() =>
|
|
70
|
-
[
|
|
94
|
+
n && r();
|
|
95
|
+
}, [n, r]), w(() => {
|
|
96
|
+
(a === "loading" || a === "renewing") && e();
|
|
97
|
+
}, [a, e]);
|
|
98
|
+
const o = v(
|
|
99
|
+
() => ye(a, t, s),
|
|
100
|
+
[a, t, s]
|
|
71
101
|
);
|
|
72
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ c(F.Provider, { value: o, children: i });
|
|
73
103
|
}
|
|
74
|
-
function
|
|
75
|
-
identityKey:
|
|
104
|
+
function Ce({
|
|
105
|
+
identityKey: n,
|
|
76
106
|
enabled: s,
|
|
77
107
|
onState: e
|
|
78
108
|
}) {
|
|
79
|
-
const
|
|
109
|
+
const i = P(), a = z({
|
|
80
110
|
queryKey: ["w6w-embed", "default-project"],
|
|
81
111
|
enabled: s,
|
|
82
112
|
queryFn: async () => {
|
|
83
|
-
const y = (await
|
|
113
|
+
const y = (await i.projects.list()).find((l) => l.isDefault === !0);
|
|
84
114
|
if (!y) throw new Error("The account has no default project.");
|
|
85
115
|
return y.id;
|
|
86
116
|
}
|
|
87
|
-
}), { isError:
|
|
88
|
-
() =>
|
|
89
|
-
[
|
|
117
|
+
}), { isError: t, error: r, data: o } = a, u = v(
|
|
118
|
+
() => t ? { project: null, status: "error", error: r } : o !== void 0 ? { project: o, status: "ready" } : { project: null, status: "resolving" },
|
|
119
|
+
[t, r, o]
|
|
90
120
|
);
|
|
91
121
|
return w(() => {
|
|
92
|
-
e(
|
|
93
|
-
}, [
|
|
122
|
+
e(n, u);
|
|
123
|
+
}, [n, u, e]), null;
|
|
94
124
|
}
|
|
95
|
-
function
|
|
96
|
-
apiOrigin:
|
|
125
|
+
function Ke({
|
|
126
|
+
apiOrigin: n,
|
|
97
127
|
getSession: s,
|
|
98
128
|
identityKey: e,
|
|
99
|
-
fallback:
|
|
100
|
-
eager:
|
|
101
|
-
theme:
|
|
102
|
-
ready:
|
|
129
|
+
fallback: i = null,
|
|
130
|
+
eager: a = !1,
|
|
131
|
+
theme: t,
|
|
132
|
+
ready: r,
|
|
103
133
|
project: o,
|
|
104
|
-
fetch:
|
|
105
|
-
children:
|
|
134
|
+
fetch: u,
|
|
135
|
+
children: f
|
|
106
136
|
}) {
|
|
107
|
-
const [y] =
|
|
137
|
+
const [y] = j(ee), [l, L] = j(() => ({
|
|
108
138
|
identityKey: e,
|
|
109
|
-
queryClient:
|
|
110
|
-
})),
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const [
|
|
139
|
+
queryClient: I()
|
|
140
|
+
})), M = e !== l.identityKey, k = T({ apiOrigin: n, project: o, getSession: s });
|
|
141
|
+
M || (k.current = { apiOrigin: n, project: o, getSession: s });
|
|
142
|
+
const E = k.current, A = T(E.getSession);
|
|
143
|
+
A.current = E.getSession;
|
|
144
|
+
const [U] = j(() => () => A.current());
|
|
115
145
|
w(() => {
|
|
116
|
-
if (e ===
|
|
117
|
-
let
|
|
118
|
-
const
|
|
119
|
-
|
|
146
|
+
if (e === l.identityKey) return;
|
|
147
|
+
let p = !1;
|
|
148
|
+
const d = () => {
|
|
149
|
+
p || L({ identityKey: e, queryClient: I() });
|
|
120
150
|
};
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
}) : (y.flushAll().then(
|
|
124
|
-
|
|
151
|
+
return l.identityKey === null ? (d(), () => {
|
|
152
|
+
p = !0;
|
|
153
|
+
}) : (y.flushAll().then(d, d), () => {
|
|
154
|
+
p = !0;
|
|
125
155
|
});
|
|
126
|
-
}, [e,
|
|
127
|
-
const
|
|
128
|
-
w(() => () =>
|
|
129
|
-
const [
|
|
130
|
-
|
|
131
|
-
(
|
|
156
|
+
}, [e, l.identityKey, y]);
|
|
157
|
+
const C = l.queryClient;
|
|
158
|
+
w(() => () => C.clear(), [C]);
|
|
159
|
+
const [S, $] = j(null), K = R((p, d) => {
|
|
160
|
+
$(
|
|
161
|
+
(b) => b && b.key === p && b.state.project === d.project && b.state.status === d.status && b.state.error === d.error ? b : { key: p, state: d }
|
|
132
162
|
);
|
|
133
|
-
}, []), [
|
|
134
|
-
const
|
|
135
|
-
return (
|
|
136
|
-
|
|
163
|
+
}, []), [g, D] = j(null), Q = v(() => {
|
|
164
|
+
const p = l.queryClient;
|
|
165
|
+
return (d) => {
|
|
166
|
+
D({ key: p, error: new me(d) });
|
|
137
167
|
};
|
|
138
|
-
}, [
|
|
139
|
-
return h === null ?
|
|
140
|
-
|
|
168
|
+
}, [l.queryClient]), B = R(() => D(null), []), h = l.identityKey, m = E.project, W = typeof m == "object" && m !== null && !Array.isArray(m) && m.use === "default", x = v(() => typeof m == "string" ? { project: m, status: "ready" } : W ? S && S.key === h ? S.state : { project: null, status: "resolving" } : { project: null, status: "ready" }, [m, W, S, h]);
|
|
169
|
+
return h === null ? i : /* @__PURE__ */ c(te, { registry: y, children: /* @__PURE__ */ c(O, { client: C, children: /* @__PURE__ */ N(
|
|
170
|
+
J,
|
|
141
171
|
{
|
|
142
|
-
baseUrl:
|
|
143
|
-
getSession:
|
|
172
|
+
baseUrl: E.apiOrigin,
|
|
173
|
+
getSession: U,
|
|
144
174
|
identityKey: h,
|
|
145
|
-
ready:
|
|
146
|
-
project:
|
|
147
|
-
fetch:
|
|
148
|
-
onUnauthorized:
|
|
175
|
+
ready: r,
|
|
176
|
+
project: x.project ?? void 0,
|
|
177
|
+
fetch: u,
|
|
178
|
+
onUnauthorized: Q,
|
|
149
179
|
children: [
|
|
150
|
-
|
|
151
|
-
|
|
180
|
+
W ? /* @__PURE__ */ c(
|
|
181
|
+
Ce,
|
|
152
182
|
{
|
|
153
183
|
identityKey: h,
|
|
154
|
-
enabled:
|
|
155
|
-
onState:
|
|
184
|
+
enabled: r !== !1,
|
|
185
|
+
onState: K
|
|
156
186
|
}
|
|
157
187
|
) : null,
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
188
|
+
/* @__PURE__ */ c(re.Provider, { value: x, children: /* @__PURE__ */ c(
|
|
189
|
+
Ee,
|
|
160
190
|
{
|
|
161
|
-
eager:
|
|
162
|
-
authError:
|
|
163
|
-
onAcquire:
|
|
164
|
-
children: /* @__PURE__ */
|
|
191
|
+
eager: a,
|
|
192
|
+
authError: g && g.key === C ? g.error : null,
|
|
193
|
+
onAcquire: B,
|
|
194
|
+
children: /* @__PURE__ */ c(we, { children: /* @__PURE__ */ c(ve, { theme: t, children: f }) })
|
|
165
195
|
}
|
|
166
196
|
) })
|
|
167
197
|
]
|
|
@@ -169,9 +199,9 @@ function Re({
|
|
|
169
199
|
) }, h) });
|
|
170
200
|
}
|
|
171
201
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
me as EmbedAuthError,
|
|
203
|
+
Ke as W6WEmbedProvider,
|
|
204
|
+
Ne as useEmbedProject,
|
|
205
|
+
$e as useEmbedStatus
|
|
176
206
|
};
|
|
177
207
|
//# sourceMappingURL=index.mjs.map
|