@republicroad/seal-editor 1.0.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 +13 -0
- package/README.md +127 -0
- package/dist/index.d.ts +2515 -0
- package/dist/index.js +15779 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-BmbNWz7t.js +596 -0
- package/dist/schema-BmbNWz7t.js.map +1 -0
- package/dist/schema.d.ts +868 -0
- package/dist/schema.js +2 -0
- package/dist/style.css +3 -0
- package/package.json +144 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
import t from "json5";
|
|
3
|
+
//#region src/helpers/request-schema/utils.ts
|
|
4
|
+
var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = (e) => Array.isArray(e) ? e.map((e) => i(e)) : r(e) ? Object.entries(e).reduce((e, [t, n]) => (e[t] = i(n), e), {}) : e, a = (e, t) => e ? `${e}.${t}` : t, o = (e) => e.split(".").map((e) => e.trim()).filter(Boolean), s = (e, t, n) => {
|
|
5
|
+
let i = o(t);
|
|
6
|
+
if (i.length === 0) return;
|
|
7
|
+
let a = e;
|
|
8
|
+
i.forEach((e, t) => {
|
|
9
|
+
if (t === i.length - 1) {
|
|
10
|
+
a[e] = n;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
r(a[e]) || (a[e] = {}), a = a[e];
|
|
14
|
+
});
|
|
15
|
+
}, c = (e, t) => {
|
|
16
|
+
let n = o(t);
|
|
17
|
+
if (n.length === 0) return;
|
|
18
|
+
let i = e;
|
|
19
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
20
|
+
if (!r(i)) return;
|
|
21
|
+
let t = n[e], a = i[t];
|
|
22
|
+
if (e === n.length - 1) return a;
|
|
23
|
+
i = a;
|
|
24
|
+
}
|
|
25
|
+
}, l = /[\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g, u = (e) => e.replace(l, "").trim(), d = (e) => Array.isArray(e) ? e.map(d) : r(e) ? Object.entries(e).reduce((e, [t, n]) => (e[u(t)] = d(n), e), {}) : e, ee = (e) => {
|
|
26
|
+
if (e) return Array.isArray(e.type) ? e.type.find((e) => e !== "null") ?? e.type[0] : e.type;
|
|
27
|
+
}, te = (e) => typeof e == "string" && [
|
|
28
|
+
"date-time",
|
|
29
|
+
"datetime",
|
|
30
|
+
"utc-millisec"
|
|
31
|
+
].includes(e), f = (e) => {
|
|
32
|
+
if (!e) return "string";
|
|
33
|
+
if (r(e.properties)) return "object";
|
|
34
|
+
let t = ee(e);
|
|
35
|
+
if (t === "string" && te(e.format)) return "datetime";
|
|
36
|
+
switch (t) {
|
|
37
|
+
case "number":
|
|
38
|
+
case "integer": return "number";
|
|
39
|
+
case "boolean": return "boolean";
|
|
40
|
+
case "array": return "array";
|
|
41
|
+
case "object": return "object";
|
|
42
|
+
default: return "string";
|
|
43
|
+
}
|
|
44
|
+
}, p = "+08:00", m = /^(\d{4}-\d{2}-\d{2})(?:[T\s](\d{2}:\d{2}:\d{2})(\.\d+)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/, ne = (e) => e ? e === "Z" ? "Z" : /^[+-]\d{2}:\d{2}$/.test(e) ? e : /^[+-]\d{4}$/.test(e) ? `${e.slice(0, 3)}:${e.slice(3)}` : p : p, h = (e) => {
|
|
45
|
+
if (typeof e != "string") return e;
|
|
46
|
+
let t = e.trim();
|
|
47
|
+
if (!t) return t;
|
|
48
|
+
let n = t.match(m);
|
|
49
|
+
if (!n) return t;
|
|
50
|
+
let [, r, i = "00:00:00", a = "", o] = n;
|
|
51
|
+
return `${r}T${i}${a}${ne(o)}`;
|
|
52
|
+
}, g = (e) => {
|
|
53
|
+
let t = {};
|
|
54
|
+
return e.type === "datetime" ? (t.type = "string", t.format = e.format.trim() || "date-time") : t.type = e.type, e.description.trim() && (t.description = e.description.trim()), e.type === "string" && e.format.trim() && (t.format = e.format.trim()), e.type === "object" && (t.properties = t.properties ?? {}), e.type === "array" && !t.items && (t.items = { type: "string" }), e.defaultValue !== void 0 && e.defaultValue.trim() !== "" && (t.default = e.defaultValue), t["x-order"] = e.order, t;
|
|
55
|
+
}, re = (e, t, n) => {
|
|
56
|
+
let i = t.split(".").map((e) => e.trim()).filter(Boolean);
|
|
57
|
+
if (i.length === 0) return;
|
|
58
|
+
let a = e;
|
|
59
|
+
i.forEach((e, t) => {
|
|
60
|
+
let o = t === i.length - 1, s = r(a[e]) ? a[e] : {};
|
|
61
|
+
if (o) {
|
|
62
|
+
let t = {
|
|
63
|
+
...s,
|
|
64
|
+
...g(n)
|
|
65
|
+
};
|
|
66
|
+
n.type === "object" && (t.properties = s.properties && r(s.properties) ? s.properties : {}), n.type === "array" && (t.items = s.items ?? {}), a[e] = t;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
a[e] = {
|
|
70
|
+
...s,
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: s.properties && r(s.properties) ? s.properties : {}
|
|
73
|
+
}, a = a[e].properties;
|
|
74
|
+
});
|
|
75
|
+
}, ie = (e) => {
|
|
76
|
+
switch (e) {
|
|
77
|
+
case "bool":
|
|
78
|
+
case "boolean": return {
|
|
79
|
+
type: "boolean",
|
|
80
|
+
format: ""
|
|
81
|
+
};
|
|
82
|
+
case "number":
|
|
83
|
+
case "integer": return {
|
|
84
|
+
type: "number",
|
|
85
|
+
format: ""
|
|
86
|
+
};
|
|
87
|
+
case "array": return {
|
|
88
|
+
type: "array",
|
|
89
|
+
format: ""
|
|
90
|
+
};
|
|
91
|
+
case "object": return {
|
|
92
|
+
type: "object",
|
|
93
|
+
format: ""
|
|
94
|
+
};
|
|
95
|
+
case "datetime": return {
|
|
96
|
+
type: "datetime",
|
|
97
|
+
format: "date-time"
|
|
98
|
+
};
|
|
99
|
+
case "string": return {
|
|
100
|
+
type: "string",
|
|
101
|
+
format: ""
|
|
102
|
+
};
|
|
103
|
+
default: return {
|
|
104
|
+
type: "string",
|
|
105
|
+
format: ""
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}, _ = (e) => {
|
|
109
|
+
switch (e.type) {
|
|
110
|
+
case "bool":
|
|
111
|
+
case "boolean": return typeof e.value == "string" ? e.value === "true" : !!e.value;
|
|
112
|
+
case "number":
|
|
113
|
+
case "integer": {
|
|
114
|
+
let t = Number(e.value);
|
|
115
|
+
return Number.isFinite(t) ? t : e.value;
|
|
116
|
+
}
|
|
117
|
+
case "array":
|
|
118
|
+
if (Array.isArray(e.value)) return e.value;
|
|
119
|
+
if (typeof e.value == "string" && e.value.trim()) try {
|
|
120
|
+
let n = t.parse(e.value);
|
|
121
|
+
return Array.isArray(n) ? n : [];
|
|
122
|
+
} catch {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
return [];
|
|
126
|
+
case "object":
|
|
127
|
+
if (r(e.value)) return e.value;
|
|
128
|
+
if (typeof e.value == "string" && e.value.trim()) try {
|
|
129
|
+
let n = t.parse(e.value);
|
|
130
|
+
return r(n) ? n : {};
|
|
131
|
+
} catch {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
return {};
|
|
135
|
+
case "datetime": return h(e.value ?? "");
|
|
136
|
+
default: return e.value ?? "";
|
|
137
|
+
}
|
|
138
|
+
}, v = (e) => {
|
|
139
|
+
if (Array.isArray(e)) {
|
|
140
|
+
let t = e.find((e) => e != null);
|
|
141
|
+
return {
|
|
142
|
+
type: "array",
|
|
143
|
+
items: t === void 0 ? { type: "string" } : v(t)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (r(e)) return {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: Object.entries(e).reduce((e, [t, n]) => (e[t] = v(n), e), {})
|
|
149
|
+
};
|
|
150
|
+
switch (typeof e) {
|
|
151
|
+
case "number": return { type: "number" };
|
|
152
|
+
case "boolean": return { type: "boolean" };
|
|
153
|
+
default: return { type: "string" };
|
|
154
|
+
}
|
|
155
|
+
}, ae = (e) => {
|
|
156
|
+
let t = ie(e.type), n = v(_(e)), i = typeof e.type == "string" && e.type.trim().length > 0 ? t.type : f(n), a = g({
|
|
157
|
+
type: i,
|
|
158
|
+
description: String(e.description ?? e.desc ?? ""),
|
|
159
|
+
format: i === "datetime" ? t.format : "",
|
|
160
|
+
order: 0
|
|
161
|
+
});
|
|
162
|
+
return i === "object" && (a.properties = r(n.properties) ? n.properties : a.properties ?? {}), i === "array" && (a.items = n.items ?? a.items ?? { type: "string" }), a;
|
|
163
|
+
}, oe = (e, t, n) => {
|
|
164
|
+
let i = t.split(".").map((e) => e.trim()).filter(Boolean);
|
|
165
|
+
if (i.length === 0) return;
|
|
166
|
+
let a = e;
|
|
167
|
+
i.forEach((e, t) => {
|
|
168
|
+
let o = t === i.length - 1, s = r(a[e]) ? a[e] : {};
|
|
169
|
+
if (o) {
|
|
170
|
+
let t = {
|
|
171
|
+
...s,
|
|
172
|
+
...n
|
|
173
|
+
};
|
|
174
|
+
(r(s.properties) || r(n.properties)) && (t.properties = {
|
|
175
|
+
...r(s.properties) ? s.properties : {},
|
|
176
|
+
...r(n.properties) ? n.properties : {}
|
|
177
|
+
}), (n.items !== void 0 || s.items !== void 0) && (t.items = n.items ?? s.items), a[e] = t;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
a[e] = {
|
|
181
|
+
...s,
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: s.properties && r(s.properties) ? s.properties : {}
|
|
184
|
+
}, a = a[e].properties;
|
|
185
|
+
});
|
|
186
|
+
}, y = (e) => {
|
|
187
|
+
let t = {};
|
|
188
|
+
return (e ?? []).forEach((e) => {
|
|
189
|
+
let n = String(e.key ?? "").trim();
|
|
190
|
+
n && oe(t, n, ae(e));
|
|
191
|
+
}), t;
|
|
192
|
+
}, b = (e) => {
|
|
193
|
+
let t = {};
|
|
194
|
+
return (e ?? []).forEach((e) => {
|
|
195
|
+
let n = String(e.key ?? "").trim();
|
|
196
|
+
n && s(t, n, _(e));
|
|
197
|
+
}), t;
|
|
198
|
+
}, se = (e, t) => {
|
|
199
|
+
let n = y(e);
|
|
200
|
+
if (Object.keys(n).length === 0) return null;
|
|
201
|
+
let r = {
|
|
202
|
+
type: "object",
|
|
203
|
+
properties: n
|
|
204
|
+
};
|
|
205
|
+
return t?.includeExamples && (r.examples = [b(e)]), r;
|
|
206
|
+
}, x = (e) => e ? typeof e == "string" ? e : r(e) ? JSON.stringify(e, null, 2) : "" : "", S = (e) => {
|
|
207
|
+
if (!e) return null;
|
|
208
|
+
if (typeof e == "string") {
|
|
209
|
+
let n = e.trim();
|
|
210
|
+
if (!n) return null;
|
|
211
|
+
try {
|
|
212
|
+
let e = t.parse(n);
|
|
213
|
+
return r(e) ? e : null;
|
|
214
|
+
} catch {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return r(e) ? e : null;
|
|
219
|
+
}, C = (e) => e?.schemaUI !== void 0 || (e?.inputs ?? []).length > 0, ce = (e) => C(e) ? "schemaUI" : "schema", w = (e) => {
|
|
220
|
+
if (e) {
|
|
221
|
+
if (e.schemaUI !== void 0) return e.schemaUI;
|
|
222
|
+
if (!((e.inputs ?? []).length > 0)) return e.schema;
|
|
223
|
+
}
|
|
224
|
+
}, le = (e, t) => {
|
|
225
|
+
let n = ce(e);
|
|
226
|
+
e[n] = t, n === "schemaUI" ? delete e.schema : delete e.schemaUI, delete e.inputs;
|
|
227
|
+
}, ue = (e, t) => {
|
|
228
|
+
let n = S(w(e)), i = !!(n && r(n.properties)), a = e?.schemaUI !== void 0;
|
|
229
|
+
return n && (i || a || (e?.inputs ?? []).length === 0) ? n : se(e?.inputs, t) ?? n;
|
|
230
|
+
}, de = (e, t) => {
|
|
231
|
+
let n = e?.["x-order"];
|
|
232
|
+
return typeof n == "number" && Number.isFinite(n) ? n : t;
|
|
233
|
+
}, fe = (e) => Object.entries(e).map(([e, t], n) => ({
|
|
234
|
+
key: e,
|
|
235
|
+
propertySchema: t,
|
|
236
|
+
index: n,
|
|
237
|
+
order: de(t, n)
|
|
238
|
+
})).sort((e, t) => e.order - t.order || e.index - t.index), T = (e, t = "", n = 0) => {
|
|
239
|
+
let i = [];
|
|
240
|
+
return fe(e).forEach(({ key: e, propertySchema: o, order: s }) => {
|
|
241
|
+
let c = a(t, e);
|
|
242
|
+
i.push({
|
|
243
|
+
id: `schema-property-${c}`,
|
|
244
|
+
path: c,
|
|
245
|
+
name: e,
|
|
246
|
+
type: f(o),
|
|
247
|
+
description: String(o?.description ?? ""),
|
|
248
|
+
format: String(o?.format ?? ""),
|
|
249
|
+
order: s,
|
|
250
|
+
depth: n,
|
|
251
|
+
parentPath: t || null,
|
|
252
|
+
source: "schema.properties",
|
|
253
|
+
defaultValue: o?.default === void 0 ? void 0 : String(o.default)
|
|
254
|
+
}), r(o?.properties) && i.push(...T(o.properties, c, n + 1));
|
|
255
|
+
}), i;
|
|
256
|
+
}, E = (e) => {
|
|
257
|
+
let t = /* @__PURE__ */ new Map();
|
|
258
|
+
return e.map((e) => {
|
|
259
|
+
let n = e.parentPath ?? "__root__", r = t.get(n) ?? 0;
|
|
260
|
+
return t.set(n, r + 1), {
|
|
261
|
+
...e,
|
|
262
|
+
order: r
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
}, pe = (e) => {
|
|
266
|
+
let t = S(w(e));
|
|
267
|
+
if (t && n(t, "properties") && r(t.properties)) return E(T(t.properties));
|
|
268
|
+
let i = y(e?.inputs);
|
|
269
|
+
return Object.keys(i).length === 0 ? [] : E(T(i).map((e) => ({
|
|
270
|
+
...e,
|
|
271
|
+
source: "content.inputs"
|
|
272
|
+
})));
|
|
273
|
+
}, me = (e, t) => {
|
|
274
|
+
let n = S(e) ?? {}, r = {};
|
|
275
|
+
return E(t).forEach((e) => {
|
|
276
|
+
if (!u(e.name)) return;
|
|
277
|
+
let t = e.path.split(".").map(u).filter(Boolean).join(".");
|
|
278
|
+
t && re(r, t, e);
|
|
279
|
+
}), x({
|
|
280
|
+
...n,
|
|
281
|
+
type: "object",
|
|
282
|
+
properties: r
|
|
283
|
+
});
|
|
284
|
+
}, D = (e, t = "Data") => `${t} ${e + 1}`, he = (e) => e === void 0 ? "" : typeof e == "string" ? e : JSON.stringify(e, null, 2), O = (e, t = "", n = []) => (r(e) && Object.entries(e).forEach(([e, i]) => {
|
|
285
|
+
let a = t ? `${t}.${e}` : e;
|
|
286
|
+
r(i) ? O(i, a, n) : n.push(a);
|
|
287
|
+
}), n), k = (e, t) => {
|
|
288
|
+
if (e === void 0 || !e.trim()) return;
|
|
289
|
+
let n = e.trim();
|
|
290
|
+
switch (t) {
|
|
291
|
+
case "number": {
|
|
292
|
+
let e = Number(n);
|
|
293
|
+
return Number.isFinite(e) ? e : n;
|
|
294
|
+
}
|
|
295
|
+
case "boolean": return n.toLowerCase() === "true";
|
|
296
|
+
case "array":
|
|
297
|
+
case "object": try {
|
|
298
|
+
return JSON.parse(n);
|
|
299
|
+
} catch {
|
|
300
|
+
return n;
|
|
301
|
+
}
|
|
302
|
+
default: return n;
|
|
303
|
+
}
|
|
304
|
+
}, ge = (e) => {
|
|
305
|
+
let t = (e) => String(e).padStart(2, "0"), n = () => {
|
|
306
|
+
let e = /* @__PURE__ */ new Date(), n = e.getFullYear(), r = t(e.getMonth() + 1), i = t(e.getDate()), a = -e.getTimezoneOffset(), o = a >= 0 ? "+" : "-", s = Math.abs(a);
|
|
307
|
+
return `${n}-${r}-${i}T00:00:00${o}${t(Math.floor(s / 60))}:${t(s % 60)}`;
|
|
308
|
+
};
|
|
309
|
+
switch (e) {
|
|
310
|
+
case "number": return 0;
|
|
311
|
+
case "boolean": return !1;
|
|
312
|
+
case "array": return [];
|
|
313
|
+
case "object": return {};
|
|
314
|
+
case "datetime": return n();
|
|
315
|
+
default: return "";
|
|
316
|
+
}
|
|
317
|
+
}, _e = (e) => {
|
|
318
|
+
let t = {};
|
|
319
|
+
return [...e].filter((e) => e.name.trim() && e.path.trim()).sort((e, t) => e.path.split(".").length - t.path.split(".").length).forEach((e) => {
|
|
320
|
+
let n = k(e.defaultValue, e.type);
|
|
321
|
+
s(t, e.path, n === void 0 ? ge(e.type) : n);
|
|
322
|
+
}), t;
|
|
323
|
+
}, A = (e, t) => {
|
|
324
|
+
let n = i(e);
|
|
325
|
+
return t.forEach((e) => {
|
|
326
|
+
if (e.type !== "datetime") return;
|
|
327
|
+
let t = e.path.trim();
|
|
328
|
+
if (!t) return;
|
|
329
|
+
let r = c(n, t);
|
|
330
|
+
r !== void 0 && s(n, t, h(r));
|
|
331
|
+
}), n;
|
|
332
|
+
}, j = (e) => {
|
|
333
|
+
if (e === "" || e === 0 || e === !1) return !0;
|
|
334
|
+
if (Array.isArray(e)) return e.length === 0;
|
|
335
|
+
if (r(e)) {
|
|
336
|
+
let t = Object.values(e);
|
|
337
|
+
return t.length === 0 || t.every((e) => j(e));
|
|
338
|
+
}
|
|
339
|
+
return !1;
|
|
340
|
+
}, M = (e, t) => {
|
|
341
|
+
switch (t.type) {
|
|
342
|
+
case "number": return typeof e == "number" && Number.isFinite(e);
|
|
343
|
+
case "boolean": return typeof e == "boolean";
|
|
344
|
+
case "array": return Array.isArray(e);
|
|
345
|
+
case "object": return r(e);
|
|
346
|
+
case "datetime": return typeof e == "string" && m.test(e.trim());
|
|
347
|
+
default: return typeof e == "string";
|
|
348
|
+
}
|
|
349
|
+
}, N = (e, t) => t.filter((e) => e.name.trim() && e.path.trim()).flatMap((t) => {
|
|
350
|
+
let n = c(e, t.path.trim());
|
|
351
|
+
return n === void 0 || M(n, t) ? [] : [{
|
|
352
|
+
path: t.path,
|
|
353
|
+
nextType: t.type,
|
|
354
|
+
value: i(n)
|
|
355
|
+
}];
|
|
356
|
+
}), P = (e, t) => {
|
|
357
|
+
let n = i(e);
|
|
358
|
+
return t.filter((e) => e.name.trim() && e.path.trim()).forEach((e) => {
|
|
359
|
+
let t = k(e.defaultValue, e.type);
|
|
360
|
+
if (t === void 0) return;
|
|
361
|
+
let r = e.path.trim(), a = c(n, r);
|
|
362
|
+
(a === void 0 || j(a)) && s(n, r, i(t));
|
|
363
|
+
}), n;
|
|
364
|
+
}, F = (e, t) => {
|
|
365
|
+
let n = S(w(e)), i = t?.dataLabel ?? "Data", a = Array.isArray(n?.examples) ? n.examples : [], o = Array.isArray(n?.["x-examples-meta"]) ? n["x-examples-meta"] : [];
|
|
366
|
+
return a.length > 0 ? a.map((e, t) => {
|
|
367
|
+
let n = o[t];
|
|
368
|
+
return {
|
|
369
|
+
id: `schema-example-${t}`,
|
|
370
|
+
name: n?.name?.trim() || D(t, i),
|
|
371
|
+
description: n?.description?.trim(),
|
|
372
|
+
data: r(e) ? { ...e } : { value: e },
|
|
373
|
+
source: "schema.examples"
|
|
374
|
+
};
|
|
375
|
+
}) : (e?.inputs ?? []).length > 0 ? [{
|
|
376
|
+
id: "schema-example-0",
|
|
377
|
+
name: D(0, i),
|
|
378
|
+
data: b(e?.inputs),
|
|
379
|
+
source: "schema.examples"
|
|
380
|
+
}] : [];
|
|
381
|
+
}, ve = (e, t, n) => {
|
|
382
|
+
let r = {
|
|
383
|
+
...S(e) ?? {},
|
|
384
|
+
type: "object",
|
|
385
|
+
examples: t.map((e) => ({ ...e }))
|
|
386
|
+
};
|
|
387
|
+
return n && n.length > 0 && n.some((e) => e?.name?.trim() || e?.description?.trim()) && (r["x-examples-meta"] = n.map((e) => ({
|
|
388
|
+
name: e?.name?.trim(),
|
|
389
|
+
description: e?.description?.trim()
|
|
390
|
+
}))), x(r);
|
|
391
|
+
}, ye = "application/vnd.gorules.decision", I = e.string().default(() => crypto.randomUUID()), be = e.object({
|
|
392
|
+
label: e.string(),
|
|
393
|
+
value: e.string()
|
|
394
|
+
}), L = e.discriminatedUnion("type", [e.object({
|
|
395
|
+
type: e.literal("inline"),
|
|
396
|
+
values: e.array(be),
|
|
397
|
+
loose: e.boolean().optional()
|
|
398
|
+
}), e.object({
|
|
399
|
+
type: e.literal("ref"),
|
|
400
|
+
ref: e.string(),
|
|
401
|
+
loose: e.boolean().optional()
|
|
402
|
+
})]), R = e.discriminatedUnion("type", [
|
|
403
|
+
e.object({ type: e.literal("any") }),
|
|
404
|
+
e.object({
|
|
405
|
+
type: e.literal("string"),
|
|
406
|
+
enum: L.optional()
|
|
407
|
+
}),
|
|
408
|
+
e.object({ type: e.literal("number") }),
|
|
409
|
+
e.object({ type: e.literal("boolean") }),
|
|
410
|
+
e.object({ type: e.literal("date") })
|
|
411
|
+
]), xe = [
|
|
412
|
+
{
|
|
413
|
+
value: "any",
|
|
414
|
+
label: "Any"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
value: "string",
|
|
418
|
+
label: "String"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
value: "number",
|
|
422
|
+
label: "Number"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
value: "boolean",
|
|
426
|
+
label: "Boolean"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
value: "date",
|
|
430
|
+
label: "Date"
|
|
431
|
+
}
|
|
432
|
+
], z = e.discriminatedUnion("type", [
|
|
433
|
+
e.object({ type: e.literal("auto") }),
|
|
434
|
+
e.object({
|
|
435
|
+
type: e.literal("string"),
|
|
436
|
+
enum: L.optional()
|
|
437
|
+
}),
|
|
438
|
+
e.object({
|
|
439
|
+
type: e.literal("string-array"),
|
|
440
|
+
enum: L.optional()
|
|
441
|
+
}),
|
|
442
|
+
e.object({ type: e.literal("number") }),
|
|
443
|
+
e.object({ type: e.literal("boolean") }),
|
|
444
|
+
e.object({ type: e.literal("date") })
|
|
445
|
+
]), Se = [
|
|
446
|
+
{
|
|
447
|
+
value: "auto",
|
|
448
|
+
label: "Auto"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
value: "string",
|
|
452
|
+
label: "Text"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
value: "string-array",
|
|
456
|
+
label: "Text[]"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
value: "number",
|
|
460
|
+
label: "Number"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
value: "boolean",
|
|
464
|
+
label: "Boolean"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
value: "date",
|
|
468
|
+
label: "Date"
|
|
469
|
+
}
|
|
470
|
+
], B = /* @__PURE__ */ function(e) {
|
|
471
|
+
return e.Input = "inputNode", e.Output = "outputNode", e.DecisionTable = "decisionTableNode", e.Function = "functionNode", e.Expression = "expressionNode", e.Switch = "switchNode", e.Decision = "decisionNode", e;
|
|
472
|
+
}({}), V = "customNode", H = e.object({
|
|
473
|
+
id: I,
|
|
474
|
+
name: e.string(),
|
|
475
|
+
position: e.object({
|
|
476
|
+
x: e.number(),
|
|
477
|
+
y: e.number()
|
|
478
|
+
}).default({
|
|
479
|
+
x: 0,
|
|
480
|
+
y: 0
|
|
481
|
+
})
|
|
482
|
+
}), U = e.object({
|
|
483
|
+
type: e.literal("inputNode"),
|
|
484
|
+
content: e.object({
|
|
485
|
+
schema: e.union([e.string(), e.record(e.string(), e.any())]).nullish().transform((e) => x(e)),
|
|
486
|
+
expressions: e.array(e.object({
|
|
487
|
+
id: I,
|
|
488
|
+
key: e.string().default(""),
|
|
489
|
+
value: e.any().default(""),
|
|
490
|
+
type: e.string().optional()
|
|
491
|
+
})).default([]),
|
|
492
|
+
inputField: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
493
|
+
outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null)
|
|
494
|
+
}).default({
|
|
495
|
+
schema: "",
|
|
496
|
+
expressions: [],
|
|
497
|
+
inputField: null,
|
|
498
|
+
outputPath: null
|
|
499
|
+
})
|
|
500
|
+
}).merge(H), W = e.object({
|
|
501
|
+
type: e.literal("outputNode"),
|
|
502
|
+
content: e.object({ schema: e.string().nullish().transform((e) => e ?? "") }).default({ schema: "" })
|
|
503
|
+
}).merge(H), G = e.object({
|
|
504
|
+
type: e.literal("decisionTableNode"),
|
|
505
|
+
content: e.object({
|
|
506
|
+
hitPolicy: e.enum(["first", "collect"]).nullish().transform((e) => e ?? "first"),
|
|
507
|
+
rules: e.array(e.record(e.string(), e.string().nullish().transform((e) => e ?? ""))).default([]),
|
|
508
|
+
inputs: e.array(e.object({
|
|
509
|
+
id: I,
|
|
510
|
+
name: e.string().nullish(),
|
|
511
|
+
field: e.string().nullish(),
|
|
512
|
+
defaultValue: e.string().nullish(),
|
|
513
|
+
fieldType: R.nullish()
|
|
514
|
+
})),
|
|
515
|
+
outputs: e.array(e.object({
|
|
516
|
+
id: I,
|
|
517
|
+
name: e.string(),
|
|
518
|
+
field: e.string(),
|
|
519
|
+
defaultValue: e.string().nullish(),
|
|
520
|
+
outputFieldType: z.nullish()
|
|
521
|
+
})),
|
|
522
|
+
passThrough: e.boolean().nullish().transform((e) => e ?? !1),
|
|
523
|
+
inputField: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
524
|
+
outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
525
|
+
executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
|
|
526
|
+
})
|
|
527
|
+
}).merge(H), K = e.object({
|
|
528
|
+
type: e.literal("functionNode"),
|
|
529
|
+
content: e.string().or(e.object({ source: e.string().default("") })).nullish()
|
|
530
|
+
}).merge(H), q = e.object({
|
|
531
|
+
type: e.literal("expressionNode"),
|
|
532
|
+
content: e.object({
|
|
533
|
+
expressions: e.array(e.object({
|
|
534
|
+
id: I,
|
|
535
|
+
key: e.string().default(""),
|
|
536
|
+
value: e.string().default("")
|
|
537
|
+
})),
|
|
538
|
+
passThrough: e.boolean().nullish().transform((e) => e ?? !1),
|
|
539
|
+
inputField: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
540
|
+
outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
541
|
+
executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
|
|
542
|
+
})
|
|
543
|
+
}).merge(H), J = e.object({
|
|
544
|
+
type: e.literal("decisionNode"),
|
|
545
|
+
content: e.object({
|
|
546
|
+
key: e.string(),
|
|
547
|
+
passThrough: e.boolean().nullish().transform((e) => e ?? !1),
|
|
548
|
+
inputField: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
549
|
+
outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
|
|
550
|
+
executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
|
|
551
|
+
})
|
|
552
|
+
}).merge(H), Y = e.object({
|
|
553
|
+
type: e.literal("switchNode"),
|
|
554
|
+
content: e.object({
|
|
555
|
+
hitPolicy: e.enum(["first", "collect"]).nullish().transform((e) => e ?? "first"),
|
|
556
|
+
statements: e.array(e.object({
|
|
557
|
+
id: I,
|
|
558
|
+
condition: e.string().nullish().transform((e) => e ?? ""),
|
|
559
|
+
isDefault: e.boolean().nullish().transform((e) => e ?? !1)
|
|
560
|
+
}))
|
|
561
|
+
})
|
|
562
|
+
}).merge(H), X = e.object({
|
|
563
|
+
type: e.literal(V),
|
|
564
|
+
content: e.object({
|
|
565
|
+
kind: e.string(),
|
|
566
|
+
config: e.any()
|
|
567
|
+
})
|
|
568
|
+
}).merge(H), Z = e.object({
|
|
569
|
+
type: e.string().refine((e) => !Object.values(B).includes(e), { message: "Invalid type" }),
|
|
570
|
+
content: e.any().nullish()
|
|
571
|
+
}).merge(H), Q = e.discriminatedUnion("type", [
|
|
572
|
+
J,
|
|
573
|
+
q,
|
|
574
|
+
K,
|
|
575
|
+
G,
|
|
576
|
+
Y,
|
|
577
|
+
X,
|
|
578
|
+
U,
|
|
579
|
+
W
|
|
580
|
+
]).or(Z), $ = e.object({
|
|
581
|
+
id: e.string(),
|
|
582
|
+
sourceId: e.string(),
|
|
583
|
+
targetId: e.string(),
|
|
584
|
+
sourceHandle: e.string().nullish(),
|
|
585
|
+
type: e.enum(["edge"])
|
|
586
|
+
}), Ce = e.object({
|
|
587
|
+
inputSchema: e.any().nullish().default(null),
|
|
588
|
+
outputSchema: e.any().nullish().default(null)
|
|
589
|
+
}), we = e.object({
|
|
590
|
+
nodes: e.array(Q).default([]),
|
|
591
|
+
edges: e.array($).default([])
|
|
592
|
+
});
|
|
593
|
+
//#endregion
|
|
594
|
+
export { ve as A, d as B, O as C, F as D, N as E, S as F, n as H, ue as I, le as L, pe as M, E as N, P as O, w as P, x as R, _e as S, D as T, r as U, c as V, Q as _, Se as a, Y as b, R as c, J as d, G as f, U as g, K as h, B as i, me as j, A as k, X as l, q as m, V as n, Z as o, $ as p, ye as r, L as s, xe as t, we as u, z as v, he as w, Ce as x, W as y, u as z };
|
|
595
|
+
|
|
596
|
+
//# sourceMappingURL=schema-BmbNWz7t.js.map
|