@w6w/embed 0.0.0-stage → 0.1.0
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/LICENSE +105 -0
- package/README.md +166 -2
- package/dist/W6WEmbedProvider.d.ts +29 -0
- package/dist/chrome/CallFromCodeButton.d.ts +155 -0
- package/dist/chrome/CallableSettingsModal.d.ts +17 -0
- package/dist/chrome/ConfirmModal.d.ts +20 -0
- package/dist/chrome/DangerZone.d.ts +19 -0
- package/dist/chrome/ExecutionProfileHeader.d.ts +69 -0
- package/dist/chrome/HistoryButton.d.ts +8 -0
- package/dist/chrome/HistoryModal.d.ts +9 -0
- package/dist/chrome/HistoryView.d.ts +15 -0
- package/dist/chrome/ImportSpecModal.d.ts +40 -0
- package/dist/chrome/JsonToggle.d.ts +51 -0
- package/dist/chrome/Modal.d.ts +20 -0
- package/dist/chrome/RightRail.d.ts +24 -0
- package/dist/chrome/TagEditor.d.ts +23 -0
- package/dist/chrome/VersionHistoryModal.d.ts +38 -0
- package/dist/chrome/history-open-run.d.ts +7 -0
- package/dist/chrome/index.d.ts +36 -0
- package/dist/chrome/workspace.d.ts +67 -0
- package/dist/client-context-CX61Bgw-.js +16 -0
- package/dist/client-context-CX61Bgw-.js.map +1 -0
- package/dist/draft/autosave-flush.d.ts +63 -0
- package/dist/draft/autosave.d.ts +68 -0
- package/dist/draft/client-context.d.ts +8 -0
- package/dist/draft/draft-registry.d.ts +14 -0
- package/dist/draft/index.d.ts +15 -0
- package/dist/draft/use-workflow-draft.d.ts +67 -0
- package/dist/draft/workflow-save.d.ts +48 -0
- package/dist/draft-registry-YF0tqNN0.js +49 -0
- package/dist/draft-registry-YF0tqNN0.js.map +1 -0
- package/dist/draft.d.ts +2 -0
- package/dist/draft.mjs +18 -0
- package/dist/draft.mjs.map +1 -0
- package/dist/editor/WorkflowEditor.d.ts +12 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +17 -0
- package/dist/editor/definition.d.ts +31 -0
- package/dist/editor/editor-apps.d.ts +7 -0
- package/dist/editor/types.d.ts +34 -0
- package/dist/editor.d.ts +9 -0
- package/dist/editor.mjs +2170 -0
- package/dist/editor.mjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +67 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/callable-descriptors.d.ts +77 -0
- package/dist/lib/callable-kind.d.ts +13 -0
- package/dist/lib/code-rail.d.ts +45 -0
- package/dist/lib/document-sources.d.ts +26 -0
- package/dist/lib/error-handler-self.d.ts +25 -0
- package/dist/lib/history-query.d.ts +135 -0
- package/dist/lib/import-paste.d.ts +41 -0
- package/dist/lib/index.d.ts +17 -0
- package/dist/lib/new-id.d.ts +10 -0
- package/dist/lib/rail-settings.d.ts +196 -0
- package/dist/lib/save-invalidation.d.ts +24 -0
- package/dist/lib/sdk-snippets.d.ts +96 -0
- package/dist/lib/settings-rail.d.ts +68 -0
- package/dist/lib/slug.d.ts +69 -0
- package/dist/lib/spec-import-invalidation.d.ts +48 -0
- package/dist/lib/tag-editor.d.ts +36 -0
- package/dist/lib/trigger-preview.d.ts +89 -0
- package/dist/lib/workflow-live-run.d.ts +165 -0
- package/dist/lib/workflow-poll.d.ts +8 -0
- package/dist/lib/workflow-route.d.ts +26 -0
- package/dist/lib/workflow-settings.d.ts +72 -0
- package/dist/lib/workflow-validity.d.ts +92 -0
- package/dist/lib/workflow-variables.d.ts +106 -0
- package/dist/lib.d.ts +2 -0
- package/dist/lib.mjs +62 -0
- package/dist/lib.mjs.map +1 -0
- package/dist/project-context-Dbk0Gr1K.js +16 -0
- package/dist/project-context-Dbk0Gr1K.js.map +1 -0
- package/dist/project-context.d.ts +11 -0
- package/dist/rail/CodeTool.d.ts +2 -0
- package/dist/rail/ErrorHandlingTool.d.ts +22 -0
- package/dist/rail/ExpressionScope.d.ts +21 -0
- package/dist/rail/SettingsTool.d.ts +27 -0
- package/dist/rail/editor-tools.d.ts +2 -0
- package/dist/rail/rail-env.d.ts +18 -0
- package/dist/rail/settings-sections.d.ts +93 -0
- package/dist/repos/documents.d.ts +102 -0
- package/dist/repos/history.d.ts +24 -0
- package/dist/repos/index.d.ts +22 -0
- package/dist/repos/spec-import.d.ts +44 -0
- package/dist/repos/step-tests.d.ts +19 -0
- package/dist/repos/vars.d.ts +25 -0
- package/dist/repos/vault.d.ts +24 -0
- package/dist/repos/versions.d.ts +112 -0
- package/dist/repos.d.ts +2 -0
- package/dist/repos.mjs +94 -0
- package/dist/repos.mjs.map +1 -0
- package/dist/slug-ByKQgxrf.js +642 -0
- package/dist/slug-ByKQgxrf.js.map +1 -0
- package/dist/spec-import-HgO7ZkLZ.js +898 -0
- package/dist/spec-import-HgO7ZkLZ.js.map +1 -0
- package/dist/spec-import-invalidation-D3retX4Q.js +18 -0
- package/dist/spec-import-invalidation-D3retX4Q.js.map +1 -0
- package/dist/use-workflow-draft-oI02dsP-.js +314 -0
- package/dist/use-workflow-draft-oI02dsP-.js.map +1 -0
- package/package.json +71 -3
- package/src/styles.css +829 -0
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import { parse as O } from "yaml";
|
|
2
|
+
function b(n, e) {
|
|
3
|
+
const t = n.uses;
|
|
4
|
+
if (t != null && t.function) return null;
|
|
5
|
+
if (!(t != null && t.app) || !(t != null && t.action)) return "target missing";
|
|
6
|
+
const r = e.actionParamsByKey[`${t.app}::${t.action}`] ?? [], i = n.with ?? {};
|
|
7
|
+
return e.requiredParamsFilled(r, i) ? t.app in e.appsById && e.isTestRequired(e.appsById[t.app]) && !e.testStatus[n.id] ? "saved test" : null : "required params";
|
|
8
|
+
}
|
|
9
|
+
function E(n, e) {
|
|
10
|
+
return b(n, e) === null;
|
|
11
|
+
}
|
|
12
|
+
function K(n, e) {
|
|
13
|
+
return e.hasTrigger ? (n.steps ?? []).every((t) => E(t, e)) : !1;
|
|
14
|
+
}
|
|
15
|
+
function L(n, e) {
|
|
16
|
+
if (!e.hasTrigger) return "no trigger step";
|
|
17
|
+
for (const t of n.steps ?? []) {
|
|
18
|
+
const r = b(t, e);
|
|
19
|
+
if (r) return `${t.id}: ${r}`;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const A = /* @__PURE__ */ new Set(["string", "number", "boolean", "object", "array"]);
|
|
24
|
+
function z(n) {
|
|
25
|
+
if (!Array.isArray(n)) return [];
|
|
26
|
+
const e = [];
|
|
27
|
+
for (const t of n) {
|
|
28
|
+
if (typeof t != "object" || t === null || Array.isArray(t)) continue;
|
|
29
|
+
const r = t, i = { key: typeof r.key == "string" ? r.key : "" };
|
|
30
|
+
typeof r.type == "string" && A.has(r.type) && (i.type = r.type), typeof r.required == "boolean" && (i.required = r.required), r.default !== void 0 && (i.default = r.default), e.push(i);
|
|
31
|
+
}
|
|
32
|
+
return e;
|
|
33
|
+
}
|
|
34
|
+
function D(n) {
|
|
35
|
+
if (n.length !== 0)
|
|
36
|
+
return n.map((e) => {
|
|
37
|
+
const t = { key: e.key };
|
|
38
|
+
return e.type !== void 0 && (t.type = e.type), e.required && (t.required = !0), e.default !== void 0 && (t.default = e.default), t;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function V(n) {
|
|
42
|
+
const e = /* @__PURE__ */ new Set(), t = [];
|
|
43
|
+
return n.forEach((r, i) => {
|
|
44
|
+
e.has(r.key) ? t.push(i) : e.add(r.key);
|
|
45
|
+
}), t;
|
|
46
|
+
}
|
|
47
|
+
function H(n, e, t) {
|
|
48
|
+
const r = /* @__PURE__ */ new Set(), i = [];
|
|
49
|
+
for (const a of [...n.slice(0, e).map((o) => o.key), ...t])
|
|
50
|
+
a === "" || r.has(a) || (r.add(a), i.push(a));
|
|
51
|
+
return i;
|
|
52
|
+
}
|
|
53
|
+
function T(n) {
|
|
54
|
+
return typeof n == "object" && n !== null && !Array.isArray(n) && n.type === "expr" && Array.isArray(n.parts);
|
|
55
|
+
}
|
|
56
|
+
function G(n) {
|
|
57
|
+
const e = [], t = [];
|
|
58
|
+
for (const r of n)
|
|
59
|
+
if (r.key.trim() !== "") {
|
|
60
|
+
if (T(r.default)) {
|
|
61
|
+
e.push({ key: r.key, type: r.type, required: !1 }), t.push(r.key);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
e.push({ key: r.key, type: r.type, default: r.default, required: r.required });
|
|
65
|
+
}
|
|
66
|
+
return { fields: e, computed: t };
|
|
67
|
+
}
|
|
68
|
+
function M(n) {
|
|
69
|
+
return n === "active" || n === "archived" ? n : "draft";
|
|
70
|
+
}
|
|
71
|
+
function X(n) {
|
|
72
|
+
const e = n;
|
|
73
|
+
return {
|
|
74
|
+
autoSave: (e == null ? void 0 : e.autoSave) !== !1,
|
|
75
|
+
savePosition: (e == null ? void 0 : e.savePosition) !== !1
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function Q(n, e, t) {
|
|
79
|
+
const i = { ...typeof n == "object" && n !== null && !Array.isArray(n) ? n : void 0 };
|
|
80
|
+
return t ? delete i[e] : i[e] = !1, Object.keys(i).length === 0 ? void 0 : i;
|
|
81
|
+
}
|
|
82
|
+
function Y(n) {
|
|
83
|
+
if (!n) return !1;
|
|
84
|
+
switch (n.kind) {
|
|
85
|
+
case "function":
|
|
86
|
+
case "endpoint":
|
|
87
|
+
case "workflow":
|
|
88
|
+
return !0;
|
|
89
|
+
default:
|
|
90
|
+
return !1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function Z(n) {
|
|
94
|
+
if (!n) return null;
|
|
95
|
+
switch (n.kind) {
|
|
96
|
+
case "function":
|
|
97
|
+
return { kind: "function", id: n.id, key: n.key, inputs: n.inputs, alias: n.alias };
|
|
98
|
+
case "endpoint":
|
|
99
|
+
return {
|
|
100
|
+
kind: "endpoint",
|
|
101
|
+
id: n.id,
|
|
102
|
+
key: n.key,
|
|
103
|
+
invokeUrl: n.invokeUrl,
|
|
104
|
+
invokeUrlByKey: n.invokeUrlByKey,
|
|
105
|
+
urlForm: n.urlForm,
|
|
106
|
+
alias: n.alias,
|
|
107
|
+
inputs: n.inputs
|
|
108
|
+
};
|
|
109
|
+
case "workflow":
|
|
110
|
+
return { kind: "workflow", id: n.id, displayName: n.label, key: n.key };
|
|
111
|
+
default:
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function x(n, e) {
|
|
116
|
+
let t;
|
|
117
|
+
try {
|
|
118
|
+
t = JSON.parse(n);
|
|
119
|
+
} catch {
|
|
120
|
+
return { parsed: null, blockedReason: "Not valid JSON." };
|
|
121
|
+
}
|
|
122
|
+
if (t === null || Array.isArray(t) || typeof t != "object")
|
|
123
|
+
return { parsed: null, blockedReason: "Expected a JSON object, not a bare value or a list." };
|
|
124
|
+
const r = t;
|
|
125
|
+
if (r.kind !== e) {
|
|
126
|
+
const i = typeof r.kind == "string" ? r.kind : "unknown";
|
|
127
|
+
return {
|
|
128
|
+
parsed: r,
|
|
129
|
+
blockedReason: `This document's kind is "${i}", not "${e}" — paste a "${e}" spec document here.`
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return { parsed: r, blockedReason: null };
|
|
133
|
+
}
|
|
134
|
+
function nn({
|
|
135
|
+
resource: n,
|
|
136
|
+
target: e,
|
|
137
|
+
hasAdapter: t
|
|
138
|
+
}) {
|
|
139
|
+
return (e.kind === "function" || e.kind === "workflow") && e.kind === n.kind && e.id === n.id ? t ? "warn" : "block" : "allow";
|
|
140
|
+
}
|
|
141
|
+
function S(n) {
|
|
142
|
+
let e;
|
|
143
|
+
if (n.format === "json")
|
|
144
|
+
try {
|
|
145
|
+
e = JSON.parse(n.content);
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
else if (n.format === "yaml")
|
|
150
|
+
try {
|
|
151
|
+
e = O(n.content);
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
return null;
|
|
157
|
+
return typeof e != "object" || e === null || Array.isArray(e) ? null : e;
|
|
158
|
+
}
|
|
159
|
+
function en(n) {
|
|
160
|
+
return n.map((e) => {
|
|
161
|
+
const t = S(e);
|
|
162
|
+
if (!t) return { key: e.key };
|
|
163
|
+
const r = Object.keys(t);
|
|
164
|
+
return r.length > 0 ? { key: e.key, fields: r.map((i) => ({ key: i })) } : { key: e.key };
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function tn(n) {
|
|
168
|
+
const e = {};
|
|
169
|
+
for (const t of n) {
|
|
170
|
+
e[`documents.${t.key}`] = t.content;
|
|
171
|
+
const r = S(t);
|
|
172
|
+
if (r)
|
|
173
|
+
for (const [i, a] of Object.entries(r))
|
|
174
|
+
e[`documents.${t.key}.${i}`] = a;
|
|
175
|
+
}
|
|
176
|
+
return e;
|
|
177
|
+
}
|
|
178
|
+
function rn(n) {
|
|
179
|
+
switch (n) {
|
|
180
|
+
case "function":
|
|
181
|
+
case "endpoint":
|
|
182
|
+
return ["id", "key", "updatedAt"];
|
|
183
|
+
case "workflow":
|
|
184
|
+
return ["id", "key"];
|
|
185
|
+
case "connection":
|
|
186
|
+
return ["id"];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function on(n) {
|
|
190
|
+
return n === "function" || n === "endpoint";
|
|
191
|
+
}
|
|
192
|
+
function an(n) {
|
|
193
|
+
switch (n) {
|
|
194
|
+
case "function":
|
|
195
|
+
case "workflow":
|
|
196
|
+
case "endpoint":
|
|
197
|
+
return !0;
|
|
198
|
+
case "connection":
|
|
199
|
+
return !1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function sn(n) {
|
|
203
|
+
switch (n) {
|
|
204
|
+
case "function":
|
|
205
|
+
case "workflow":
|
|
206
|
+
case "endpoint":
|
|
207
|
+
return !0;
|
|
208
|
+
case "connection":
|
|
209
|
+
return !1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function un(n) {
|
|
213
|
+
switch (n) {
|
|
214
|
+
case "function":
|
|
215
|
+
return "functions";
|
|
216
|
+
case "endpoint":
|
|
217
|
+
return "endpoints";
|
|
218
|
+
case "workflow":
|
|
219
|
+
case "connection":
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function ln(n, e) {
|
|
224
|
+
let t;
|
|
225
|
+
try {
|
|
226
|
+
t = JSON.parse(n);
|
|
227
|
+
} catch {
|
|
228
|
+
return { parsed: null, blockedReason: "Not valid JSON." };
|
|
229
|
+
}
|
|
230
|
+
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
231
|
+
return { parsed: null, blockedReason: "Not valid JSON." };
|
|
232
|
+
const r = t;
|
|
233
|
+
return r.id !== e.id ? { parsed: r, blockedReason: "id cannot be changed here." } : r.key !== e.key ? { parsed: r, blockedReason: "key cannot be changed here." } : { parsed: r, blockedReason: null };
|
|
234
|
+
}
|
|
235
|
+
function cn(n, e) {
|
|
236
|
+
return n === void 0 ? { allowed: !1, reason: "Workflow not loaded yet." } : (e === void 0 ? null : e) !== n ? {
|
|
237
|
+
allowed: !1,
|
|
238
|
+
reason: "key cannot be changed here — use the Settings panel's Key field."
|
|
239
|
+
} : { allowed: !0, reason: null };
|
|
240
|
+
}
|
|
241
|
+
function fn(n) {
|
|
242
|
+
if (!n) return { activeTool: null };
|
|
243
|
+
try {
|
|
244
|
+
const e = JSON.parse(n);
|
|
245
|
+
return { activeTool: typeof e.activeTool == "string" ? e.activeTool : null };
|
|
246
|
+
} catch {
|
|
247
|
+
return { activeTool: null };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function R(n) {
|
|
251
|
+
return n.status !== void 0 ? n.status === "archived" : n.archivedAt != null;
|
|
252
|
+
}
|
|
253
|
+
function dn(n, e) {
|
|
254
|
+
return e ? n.slice() : n.filter((t) => !R(t));
|
|
255
|
+
}
|
|
256
|
+
function yn(n) {
|
|
257
|
+
return n ? n.kind === "function" || n.kind === "endpoint" ? !0 : n.kind === "workflow" && typeof n.onPolicyChange == "function" : !1;
|
|
258
|
+
}
|
|
259
|
+
function pn(n) {
|
|
260
|
+
const e = {};
|
|
261
|
+
return n.retry && (e.retry = n.retry), n.onError && n.onError !== "fail" && (e.onError = n.onError), n.reroute && (e.reroute = n.reroute), e;
|
|
262
|
+
}
|
|
263
|
+
function kn(n, e) {
|
|
264
|
+
const { retry: t, onError: r, reroute: i, ...a } = n;
|
|
265
|
+
return {
|
|
266
|
+
...a,
|
|
267
|
+
...e.retry ? { retry: e.retry } : {},
|
|
268
|
+
...e.onError && e.onError !== "fail" ? { onError: e.onError } : {},
|
|
269
|
+
...e.reroute ? { reroute: e.reroute } : {}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function mn(n, e) {
|
|
273
|
+
var i, a;
|
|
274
|
+
const t = n.steps ?? [], r = [];
|
|
275
|
+
for (const o of t) {
|
|
276
|
+
const s = (i = o.uses) == null ? void 0 : i.app;
|
|
277
|
+
if (!s || !e.isManualTrigger(s)) continue;
|
|
278
|
+
const k = e.asFieldDefs((a = o.with) == null ? void 0 : a.fields).filter((g) => typeof g.key == "string" && g.key.trim() !== "");
|
|
279
|
+
r.push({ id: o.id, label: o.displayName ?? o.id, fields: k });
|
|
280
|
+
}
|
|
281
|
+
return r;
|
|
282
|
+
}
|
|
283
|
+
function hn(n) {
|
|
284
|
+
const e = {};
|
|
285
|
+
for (const t of (n == null ? void 0 : n.fields) ?? [])
|
|
286
|
+
if (!(typeof t.key != "string" || t.key.trim() === "")) {
|
|
287
|
+
if (t.default !== void 0) {
|
|
288
|
+
e[t.key] = t.default;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
e[t.key] = t.type === "number" ? 0 : t.type === "boolean" ? !1 : "";
|
|
292
|
+
}
|
|
293
|
+
return e;
|
|
294
|
+
}
|
|
295
|
+
const _ = ["conn_", "fn_", "wf_", "ep_"];
|
|
296
|
+
function f(n) {
|
|
297
|
+
return _.some((e) => n.startsWith(e));
|
|
298
|
+
}
|
|
299
|
+
function m(n) {
|
|
300
|
+
var t;
|
|
301
|
+
const e = (t = n.key) == null ? void 0 : t.trim();
|
|
302
|
+
return e && e.length > 0 ? e : n.id;
|
|
303
|
+
}
|
|
304
|
+
function u(n) {
|
|
305
|
+
return `'${n.replaceAll("'", "'\\''")}'`;
|
|
306
|
+
}
|
|
307
|
+
const J = 72;
|
|
308
|
+
function d(n, ...e) {
|
|
309
|
+
const t = [n, ...e].filter((i) => i.length > 0), r = t.join(" ");
|
|
310
|
+
return e.length === 0 || r.length <= J ? r : t.join(` \\
|
|
311
|
+
`);
|
|
312
|
+
}
|
|
313
|
+
function w(n) {
|
|
314
|
+
return !n || n.length === 0 ? [] : n.map(
|
|
315
|
+
(e) => typeof e == "string" ? { key: e, required: !0 } : {
|
|
316
|
+
key: e.key,
|
|
317
|
+
// Only an explicit `true` is required — an undeclared flag means the
|
|
318
|
+
// Function did not mark it, which is exactly what optional means.
|
|
319
|
+
required: e.required === !0
|
|
320
|
+
}
|
|
321
|
+
).filter((e) => typeof e.key == "string" && e.key.trim() !== "");
|
|
322
|
+
}
|
|
323
|
+
function h(n, e = !1) {
|
|
324
|
+
const t = w(n), r = e ? t.filter((i) => i.required) : t;
|
|
325
|
+
return Object.fromEntries(r.map((i) => [i.key, `<${i.key}>`]));
|
|
326
|
+
}
|
|
327
|
+
function y(n, e) {
|
|
328
|
+
const t = w(n);
|
|
329
|
+
return t.length === 0 ? "{}" : e.compact && t.every((i) => i.required) ? JSON.stringify(Object.fromEntries(t.map((i) => [i.key, `<${i.key}>`]))) : `{
|
|
330
|
+
${t.map(({ key: i, required: a }) => {
|
|
331
|
+
const o = `${JSON.stringify(i)}: ${JSON.stringify(`<${i}>`)},`;
|
|
332
|
+
return a ? `${e.indent} ${o}` : `${e.indent} ${e.comment} ${o}`;
|
|
333
|
+
}).join(`
|
|
334
|
+
`)}
|
|
335
|
+
${e.indent}}`;
|
|
336
|
+
}
|
|
337
|
+
function v(n) {
|
|
338
|
+
return w(n).filter((e) => !e.required).map((e) => `
|
|
339
|
+
# optional: ${e.key}`).join("");
|
|
340
|
+
}
|
|
341
|
+
function q(n) {
|
|
342
|
+
return n ? n.filter((e) => typeof e.key == "string" && e.key.trim() !== "") : [];
|
|
343
|
+
}
|
|
344
|
+
function $(n, e) {
|
|
345
|
+
return n === "number" ? 0 : n === "boolean" ? !1 : n === "json" ? {} : `<${e}>`;
|
|
346
|
+
}
|
|
347
|
+
function N(n, e, t) {
|
|
348
|
+
const r = $(n, e);
|
|
349
|
+
return typeof r == "boolean" ? t ? "False" : "false" : JSON.stringify(r);
|
|
350
|
+
}
|
|
351
|
+
function W(n) {
|
|
352
|
+
return n.length === 0 ? "" : `
|
|
353
|
+
input: {
|
|
354
|
+
${n.map((t) => {
|
|
355
|
+
const r = `${JSON.stringify(t.key)}: ${N(t.type, t.key, !1)},`;
|
|
356
|
+
return t.required === !0 ? ` ${r}` : ` // ${r}`;
|
|
357
|
+
}).join(`
|
|
358
|
+
`)}
|
|
359
|
+
},`;
|
|
360
|
+
}
|
|
361
|
+
function j(n, e) {
|
|
362
|
+
const t = JSON.stringify(n);
|
|
363
|
+
if (e.length === 0) return `client.workflows.run(${t}, wait=True)`;
|
|
364
|
+
const r = e.map((i) => {
|
|
365
|
+
const a = `"${i.key}": ${N(i.type, i.key, !0)},`;
|
|
366
|
+
return i.required === !0 ? ` ${a}` : ` # ${a}`;
|
|
367
|
+
});
|
|
368
|
+
return `client.workflows.run(
|
|
369
|
+
${t},
|
|
370
|
+
wait=True,
|
|
371
|
+
input={
|
|
372
|
+
${r.join(`
|
|
373
|
+
`)}
|
|
374
|
+
},
|
|
375
|
+
)`;
|
|
376
|
+
}
|
|
377
|
+
function P(n, e) {
|
|
378
|
+
if (e.length === 0) return d(`w6w workflows run ${n}`, "--wait");
|
|
379
|
+
const t = e.filter((o) => o.required === !0), r = e.filter((o) => o.required !== !0), i = Object.fromEntries(
|
|
380
|
+
t.map((o) => [o.key, $(o.type, o.key)])
|
|
381
|
+
);
|
|
382
|
+
let a = d(
|
|
383
|
+
`w6w workflows run ${n}`,
|
|
384
|
+
"--wait",
|
|
385
|
+
`--input ${u(JSON.stringify(i))}`
|
|
386
|
+
);
|
|
387
|
+
for (const o of r)
|
|
388
|
+
a += `
|
|
389
|
+
# optional: ${o.key} (${o.type ?? "string"})`;
|
|
390
|
+
return a;
|
|
391
|
+
}
|
|
392
|
+
function l(...n) {
|
|
393
|
+
return `import { ${["W6WClient", ...n].join(", ")} } from "@w6w/sdk";
|
|
394
|
+
|
|
395
|
+
// Reads W6W_BASE_URL and W6W_TOKEN from the environment when omitted.
|
|
396
|
+
const client = new W6WClient();`;
|
|
397
|
+
}
|
|
398
|
+
function c(...n) {
|
|
399
|
+
return `from w6w import ${["Client", ...n].join(", ")}
|
|
400
|
+
|
|
401
|
+
# Reads W6W_BASE_URL and W6W_TOKEN from the environment when omitted.
|
|
402
|
+
client = Client()`;
|
|
403
|
+
}
|
|
404
|
+
function p(n, e) {
|
|
405
|
+
return `curl -X POST ${n} \\
|
|
406
|
+
-H "authorization: Bearer $W6W_TOKEN" \\
|
|
407
|
+
-H 'content-type: application/json' \\
|
|
408
|
+
-d ${u(JSON.stringify(e))}`;
|
|
409
|
+
}
|
|
410
|
+
function U(n, e) {
|
|
411
|
+
return p(u(n), e ?? {});
|
|
412
|
+
}
|
|
413
|
+
function C(n, e, t, r) {
|
|
414
|
+
const i = `"$W6W_BASE_URL/${n}/${encodeURIComponent(e)}/invoke"`;
|
|
415
|
+
return p(i, { [t]: r });
|
|
416
|
+
}
|
|
417
|
+
function B(n, e) {
|
|
418
|
+
const t = `"$W6W_BASE_URL/workflows/${n}/run?wait=true"`;
|
|
419
|
+
if (e.length === 0) return p(t, {});
|
|
420
|
+
const r = e.filter((s) => s.required === !0), i = e.filter((s) => s.required !== !0), a = Object.fromEntries(
|
|
421
|
+
r.map((s) => [s.key, $(s.type, s.key)])
|
|
422
|
+
);
|
|
423
|
+
let o = p(t, { input: a });
|
|
424
|
+
for (const s of i)
|
|
425
|
+
o += `
|
|
426
|
+
# optional: ${s.key} (${s.type ?? "string"})`;
|
|
427
|
+
return o;
|
|
428
|
+
}
|
|
429
|
+
function wn(n, e) {
|
|
430
|
+
switch (n.kind) {
|
|
431
|
+
case "workflow": {
|
|
432
|
+
if (!f(n.id)) return null;
|
|
433
|
+
const t = m(n), r = q(e);
|
|
434
|
+
return {
|
|
435
|
+
operation: "workflows.run — POST /workflows/{idOrKey}/run",
|
|
436
|
+
node: `${l()}
|
|
437
|
+
|
|
438
|
+
// \`wait: true\` blocks until the run reaches a terminal state.
|
|
439
|
+
// Omit it and you get \`{ runId, status: "queued" }\` back immediately.
|
|
440
|
+
const result = await client.workflows.run(${JSON.stringify(t)}, {
|
|
441
|
+
wait: true,${W(r)}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
console.log(result.status, result.runId);`,
|
|
445
|
+
cli: P(t, r),
|
|
446
|
+
python: `${c()}
|
|
447
|
+
|
|
448
|
+
# \`wait=True\` blocks until the run reaches a terminal state.
|
|
449
|
+
# Omit it and you get \`WorkflowRunResult(status="queued", ...)\` back immediately.
|
|
450
|
+
result = ${j(t, r)}
|
|
451
|
+
|
|
452
|
+
print(result.status, result.runId)`,
|
|
453
|
+
curl: B(t, r)
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
case "function": {
|
|
457
|
+
if (!f(n.id)) return null;
|
|
458
|
+
const t = m(n), r = h(n.inputs, !0), i = JSON.stringify(r), a = v(n.inputs), o = y(n.inputs, { indent: " ", comment: "//" }), s = y(n.inputs, {
|
|
459
|
+
indent: "",
|
|
460
|
+
comment: "#",
|
|
461
|
+
compact: !0
|
|
462
|
+
});
|
|
463
|
+
return {
|
|
464
|
+
operation: "functions.run — POST /functions/{idOrKey}/invoke",
|
|
465
|
+
node: `${l()}
|
|
466
|
+
|
|
467
|
+
// The name is the first argument, and it may be the Function's key or its
|
|
468
|
+
// \`fn_…\` id — one slot takes either. Returns the OUTPUT directly: the kind is
|
|
469
|
+
// settled by the method, so there is no envelope to narrow.
|
|
470
|
+
const output = await client.functions.run(${JSON.stringify(t)}, {
|
|
471
|
+
payload: ${o},
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
console.log(output);`,
|
|
475
|
+
cli: d(`w6w functions run ${t}`, `--payload ${u(i)}`) + a,
|
|
476
|
+
python: `${c()}
|
|
477
|
+
|
|
478
|
+
# The name is the first argument — the Function's key or its \`fn_…\` id.
|
|
479
|
+
output = client.functions.run(${JSON.stringify(t)}, payload=${s})
|
|
480
|
+
|
|
481
|
+
print(output)`,
|
|
482
|
+
curl: C("functions", t, "inputs", r) + a
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
case "endpoint": {
|
|
486
|
+
if (!f(n.id)) return null;
|
|
487
|
+
const t = n.urlForm === "key" && n.invokeUrlByKey ? n.invokeUrlByKey : n.invokeUrl, r = m(n), i = h(n.inputs, !0), a = JSON.stringify(i), o = v(n.inputs), s = y(n.inputs, { indent: " ", comment: "//" }), k = y(n.inputs, {
|
|
488
|
+
indent: "",
|
|
489
|
+
comment: "#",
|
|
490
|
+
compact: !0
|
|
491
|
+
});
|
|
492
|
+
return {
|
|
493
|
+
operation: "endpoints.run — POST /endpoints/{idOrKey}/invoke",
|
|
494
|
+
node: `${l()}
|
|
495
|
+
|
|
496
|
+
// The name is the first argument — the Endpoint's key or its \`ep_…\` id. Unlike
|
|
497
|
+
// \`functions.run\` this returns the ENVELOPE: an Endpoint dispatches to an app
|
|
498
|
+
// action, a Function or a Workflow, and only \`kind\` says which answered.
|
|
499
|
+
const envelope = await client.endpoints.run(${JSON.stringify(r)}, {
|
|
500
|
+
payload: ${s},
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
console.log(envelope.kind, envelope);`,
|
|
504
|
+
cli: d(`w6w endpoints run ${r}`, `--payload ${u(a)}`) + o,
|
|
505
|
+
python: `${c()}
|
|
506
|
+
|
|
507
|
+
# The name is the first argument — the Endpoint's key or its \`ep_…\` id.
|
|
508
|
+
envelope = client.endpoints.run(${JSON.stringify(r)}, payload=${k})
|
|
509
|
+
|
|
510
|
+
print(envelope["kind"], envelope)`,
|
|
511
|
+
...typeof t == "string" && t !== "" ? { curl: U(t, i) + o } : {}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
case "connection": {
|
|
515
|
+
if (!f(n.id)) return null;
|
|
516
|
+
const t = h(n.params);
|
|
517
|
+
return {
|
|
518
|
+
operation: "run — POST /run",
|
|
519
|
+
node: `${l("isActionRun")}
|
|
520
|
+
|
|
521
|
+
// An app action runs through the CONNECTION that authenticates it, so the URN
|
|
522
|
+
// is the connection id and \`action\` names the action on its app. This is the
|
|
523
|
+
// one arm where \`action\` is required — a workflow, function or endpoint URN
|
|
524
|
+
// has no action to name.
|
|
525
|
+
const envelope = await client.run({
|
|
526
|
+
urn: ${JSON.stringify(n.id)},
|
|
527
|
+
action: ${JSON.stringify(n.action)},
|
|
528
|
+
payload: ${JSON.stringify(t, null, 2).replaceAll(`
|
|
529
|
+
`, `
|
|
530
|
+
`)},
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
if (isActionRun(envelope)) console.log(envelope.value);`,
|
|
534
|
+
cli: d(
|
|
535
|
+
`w6w run ${n.id}`,
|
|
536
|
+
`--action ${n.action}`,
|
|
537
|
+
`--payload ${u(JSON.stringify(t))}`
|
|
538
|
+
),
|
|
539
|
+
python: `${c("is_action_run")}
|
|
540
|
+
|
|
541
|
+
# An app action runs through the CONNECTION that authenticates it, so the URN
|
|
542
|
+
# is the connection id and \`action\` names the action on its app. This is the
|
|
543
|
+
# one arm where \`action\` is required — a workflow, function or endpoint URN
|
|
544
|
+
# has no action to name.
|
|
545
|
+
envelope = client.run(
|
|
546
|
+
${JSON.stringify(n.id)},
|
|
547
|
+
action=${JSON.stringify(n.action)},
|
|
548
|
+
payload=${JSON.stringify(t)},
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
if is_action_run(envelope):
|
|
552
|
+
print(envelope["value"])`
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
case "var":
|
|
556
|
+
return {
|
|
557
|
+
operation: "vars.getByName — GET /vars/by-name/{name}",
|
|
558
|
+
node: `${l()}
|
|
559
|
+
|
|
560
|
+
const variable = await client.vars.getByName(${JSON.stringify(n.name)});
|
|
561
|
+
console.log(variable.value);`,
|
|
562
|
+
cli: `w6w vars get-by-name ${n.name}`,
|
|
563
|
+
python: `${c()}
|
|
564
|
+
|
|
565
|
+
variable = client.vars.get_by_name(${JSON.stringify(n.name)})
|
|
566
|
+
print(variable.value)`
|
|
567
|
+
};
|
|
568
|
+
case "document":
|
|
569
|
+
return {
|
|
570
|
+
operation: "documents.getByKey — GET /documents/by-key/{key}",
|
|
571
|
+
node: `${l()}
|
|
572
|
+
|
|
573
|
+
const doc = await client.documents.getByKey(${JSON.stringify(n.key)});
|
|
574
|
+
console.log(doc.content);`,
|
|
575
|
+
cli: `w6w documents get-by-key ${u(n.key)}`,
|
|
576
|
+
python: `${c()}
|
|
577
|
+
|
|
578
|
+
doc = client.documents.get_by_key(${JSON.stringify(n.key)})
|
|
579
|
+
print(doc.content)`
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function $n(n) {
|
|
584
|
+
return (n.kind === "function" || n.kind === "endpoint" || n.kind === "workflow") && !f(n.id) ? `This ${n.kind}'s id (${n.id}) has no \`${n.kind === "workflow" ? "wf_" : n.kind === "function" ? "fn_" : "ep_"}\` prefix, so it cannot be addressed by URN. The SDK and CLI reach ${n.kind}s through \`run\`, which resolves a URN by that prefix — re-create it with a host-issued id to call it from code.` : "The client libraries do not expose an operation for this yet.";
|
|
585
|
+
}
|
|
586
|
+
function gn(n) {
|
|
587
|
+
return n.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
588
|
+
}
|
|
589
|
+
const F = /^[a-z][a-z0-9-]{2,}$/;
|
|
590
|
+
function vn(n) {
|
|
591
|
+
return F.test(n);
|
|
592
|
+
}
|
|
593
|
+
function bn(n) {
|
|
594
|
+
return /^[a-z][a-z0-9-]{2,38}$/.test(n) && !n.includes("--") && !n.endsWith("-");
|
|
595
|
+
}
|
|
596
|
+
function Sn(n) {
|
|
597
|
+
return n.toLowerCase().replace(/[^a-z0-9-]/g, "").slice(0, 39);
|
|
598
|
+
}
|
|
599
|
+
export {
|
|
600
|
+
F as A,
|
|
601
|
+
G as B,
|
|
602
|
+
gn as C,
|
|
603
|
+
un as D,
|
|
604
|
+
E,
|
|
605
|
+
Z as F,
|
|
606
|
+
hn as G,
|
|
607
|
+
mn as H,
|
|
608
|
+
$n as I,
|
|
609
|
+
D as J,
|
|
610
|
+
H as K,
|
|
611
|
+
dn as L,
|
|
612
|
+
cn as M,
|
|
613
|
+
K as N,
|
|
614
|
+
Q as O,
|
|
615
|
+
tn as a,
|
|
616
|
+
wn as b,
|
|
617
|
+
V as c,
|
|
618
|
+
kn as d,
|
|
619
|
+
nn as e,
|
|
620
|
+
ln as f,
|
|
621
|
+
Sn as g,
|
|
622
|
+
on as h,
|
|
623
|
+
sn as i,
|
|
624
|
+
an as j,
|
|
625
|
+
L as k,
|
|
626
|
+
Y as l,
|
|
627
|
+
bn as m,
|
|
628
|
+
T as n,
|
|
629
|
+
R as o,
|
|
630
|
+
yn as p,
|
|
631
|
+
f as q,
|
|
632
|
+
vn as r,
|
|
633
|
+
rn as s,
|
|
634
|
+
x as t,
|
|
635
|
+
pn as u,
|
|
636
|
+
en as v,
|
|
637
|
+
X as w,
|
|
638
|
+
z as x,
|
|
639
|
+
M as y,
|
|
640
|
+
fn as z
|
|
641
|
+
};
|
|
642
|
+
//# sourceMappingURL=slug-ByKQgxrf.js.map
|