@republicroad/seal-editor 1.13.0 → 1.16.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.
@@ -22,17 +22,28 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
22
22
  if (e === n.length - 1) return a;
23
23
  i = a;
24
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) => {
25
+ }, ee = (e, t) => {
26
+ let i = o(t);
27
+ if (i.length === 0) return;
28
+ let a = (e, t) => {
29
+ let o = i[t];
30
+ if (!n(e, o)) return Object.keys(e).length === 0;
31
+ if (t === i.length - 1) return delete e[o], Object.keys(e).length === 0;
32
+ let s = e[o];
33
+ return r(s) ? (a(s, t + 1) && delete e[o], Object.keys(e).length === 0) : (delete e[o], Object.keys(e).length === 0);
34
+ };
35
+ a(e, 0);
36
+ }, te = /[\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g, l = (e) => e.replace(te, "").trim(), u = (e) => Array.isArray(e) ? e.map(u) : r(e) ? Object.entries(e).reduce((e, [t, n]) => (e[l(t)] = u(n), e), {}) : e, ne = (e) => {
26
37
  if (e) return Array.isArray(e.type) ? e.type.find((e) => e !== "null") ?? e.type[0] : e.type;
27
- }, te = (e) => typeof e == "string" && [
38
+ }, re = (e) => typeof e == "string" && [
28
39
  "date-time",
29
40
  "datetime",
30
41
  "utc-millisec"
31
- ].includes(e), f = (e) => {
42
+ ].includes(e), d = (e) => {
32
43
  if (!e) return "string";
33
44
  if (r(e.properties)) return "object";
34
- let t = ee(e);
35
- if (t === "string" && te(e.format)) return "datetime";
45
+ let t = ne(e);
46
+ if (t === "string" && re(e.format)) return "datetime";
36
47
  switch (t) {
37
48
  case "number":
38
49
  case "integer": return "number";
@@ -41,18 +52,18 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
41
52
  case "object": return "object";
42
53
  default: return "string";
43
54
  }
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) => {
55
+ }, f = "+08:00", p = /^(\d{4}-\d{2}-\d{2})(?:[T\s](\d{2}:\d{2}:\d{2})(\.\d+)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/, ie = (e) => e ? e === "Z" ? "Z" : /^[+-]\d{2}:\d{2}$/.test(e) ? e : /^[+-]\d{4}$/.test(e) ? `${e.slice(0, 3)}:${e.slice(3)}` : f : f, m = (e) => {
45
56
  if (typeof e != "string") return e;
46
57
  let t = e.trim();
47
58
  if (!t) return t;
48
- let n = t.match(m);
59
+ let n = t.match(p);
49
60
  if (!n) return t;
50
61
  let [, r, i = "00:00:00", a = "", o] = n;
51
- return `${r}T${i}${a}${ne(o)}`;
52
- }, g = (e) => {
62
+ return `${r}T${i}${a}${ie(o)}`;
63
+ }, h = (e) => {
53
64
  let t = {};
54
65
  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) => {
66
+ }, ae = (e, t, n) => {
56
67
  let i = t.split(".").map((e) => e.trim()).filter(Boolean);
57
68
  if (i.length === 0) return;
58
69
  let a = e;
@@ -61,7 +72,7 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
61
72
  if (o) {
62
73
  let t = {
63
74
  ...s,
64
- ...g(n)
75
+ ...h(n)
65
76
  };
66
77
  n.type === "object" && (t.properties = s.properties && r(s.properties) ? s.properties : {}), n.type === "array" && (t.items = s.items ?? {}), a[e] = t;
67
78
  return;
@@ -72,7 +83,7 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
72
83
  properties: s.properties && r(s.properties) ? s.properties : {}
73
84
  }, a = a[e].properties;
74
85
  });
75
- }, ie = (e) => {
86
+ }, oe = (e) => {
76
87
  switch (e) {
77
88
  case "bool":
78
89
  case "boolean": return {
@@ -105,7 +116,7 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
105
116
  format: ""
106
117
  };
107
118
  }
108
- }, _ = (e) => {
119
+ }, g = (e) => {
109
120
  switch (e.type) {
110
121
  case "bool":
111
122
  case "boolean": return typeof e.value == "string" ? e.value === "true" : !!e.value;
@@ -132,35 +143,35 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
132
143
  return {};
133
144
  }
134
145
  return {};
135
- case "datetime": return h(e.value ?? "");
146
+ case "datetime": return m(e.value ?? "");
136
147
  default: return e.value ?? "";
137
148
  }
138
- }, v = (e) => {
149
+ }, _ = (e) => {
139
150
  if (Array.isArray(e)) {
140
151
  let t = e.find((e) => e != null);
141
152
  return {
142
153
  type: "array",
143
- items: t === void 0 ? { type: "string" } : v(t)
154
+ items: t === void 0 ? { type: "string" } : _(t)
144
155
  };
145
156
  }
146
157
  if (r(e)) return {
147
158
  type: "object",
148
- properties: Object.entries(e).reduce((e, [t, n]) => (e[t] = v(n), e), {})
159
+ properties: Object.entries(e).reduce((e, [t, n]) => (e[t] = _(n), e), {})
149
160
  };
150
161
  switch (typeof e) {
151
162
  case "number": return { type: "number" };
152
163
  case "boolean": return { type: "boolean" };
153
164
  default: return { type: "string" };
154
165
  }
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({
166
+ }, se = (e) => {
167
+ let t = oe(e.type), n = _(g(e)), i = typeof e.type == "string" && e.type.trim().length > 0 ? t.type : d(n), a = h({
157
168
  type: i,
158
169
  description: String(e.description ?? e.desc ?? ""),
159
170
  format: i === "datetime" ? t.format : "",
160
171
  order: 0
161
172
  });
162
173
  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) => {
174
+ }, ce = (e, t, n) => {
164
175
  let i = t.split(".").map((e) => e.trim()).filter(Boolean);
165
176
  if (i.length === 0) return;
166
177
  let a = e;
@@ -183,27 +194,27 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
183
194
  properties: s.properties && r(s.properties) ? s.properties : {}
184
195
  }, a = a[e].properties;
185
196
  });
186
- }, y = (e) => {
197
+ }, v = (e) => {
187
198
  let t = {};
188
199
  return (e ?? []).forEach((e) => {
189
200
  let n = String(e.key ?? "").trim();
190
- n && oe(t, n, ae(e));
201
+ n && ce(t, n, se(e));
191
202
  }), t;
192
- }, b = (e) => {
203
+ }, y = (e) => {
193
204
  let t = {};
194
205
  return (e ?? []).forEach((e) => {
195
206
  let n = String(e.key ?? "").trim();
196
- n && s(t, n, _(e));
207
+ n && s(t, n, g(e));
197
208
  }), t;
198
- }, se = (e, t) => {
199
- let n = y(e);
209
+ }, le = (e, t) => {
210
+ let n = v(e);
200
211
  if (Object.keys(n).length === 0) return null;
201
212
  let r = {
202
213
  type: "object",
203
214
  properties: n
204
215
  };
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) => {
216
+ return t?.includeExamples && (r.examples = [y(e)]), r;
217
+ }, b = (e) => e ? typeof e == "string" ? e : r(e) ? JSON.stringify(e, null, 2) : "" : "", x = (e) => {
207
218
  if (!e) return null;
208
219
  if (typeof e == "string") {
209
220
  let n = e.trim();
@@ -216,75 +227,21 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
216
227
  }
217
228
  }
218
229
  return r(e) ? e : null;
219
- }, C = (e) => e?.schemaUI !== void 0 || (e?.inputs ?? []).length > 0, ce = (e) => C(e) ? "schemaUI" : "schema", w = (e) => {
230
+ }, ue = (e) => e?.schemaUI !== void 0 || (e?.inputs ?? []).length > 0, de = (e) => ue(e) ? "schemaUI" : "schema", S = (e) => {
220
231
  if (e) {
221
232
  if (e.schemaUI !== void 0) return e.schemaUI;
222
233
  if (!((e.inputs ?? []).length > 0)) return e.schema;
223
234
  }
224
- }, le = (e, t) => {
225
- let n = ce(e);
235
+ }, fe = (e, t) => {
236
+ let n = de(e);
226
237
  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]) => {
238
+ }, C = (e, t) => {
239
+ let n = x(S(e)), i = !!(n && r(n.properties)), a = e?.schemaUI !== void 0;
240
+ return n && (i || a || (e?.inputs ?? []).length === 0) ? n : le(e?.inputs, t) ?? n;
241
+ }, w = (e, t = "Data") => `${t} ${e + 1}`, pe = (e) => e === void 0 ? "" : typeof e == "string" ? e : JSON.stringify(e, null, 2), T = (e, t = "", n = []) => (r(e) && Object.entries(e).forEach(([e, i]) => {
285
242
  let a = t ? `${t}.${e}` : e;
286
- r(i) ? O(i, a, n) : n.push(a);
287
- }), n), k = (e, t) => {
243
+ r(i) ? T(i, a, n) : n.push(a);
244
+ }), n), E = (e, t) => {
288
245
  if (e === void 0 || !e.trim()) return;
289
246
  let n = e.trim();
290
247
  switch (t) {
@@ -301,7 +258,7 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
301
258
  }
302
259
  default: return n;
303
260
  }
304
- }, ge = (e) => {
261
+ }, me = (e) => {
305
262
  let t = (e) => String(e).padStart(2, "0"), n = () => {
306
263
  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
264
  return `${n}-${r}-${i}T00:00:00${o}${t(Math.floor(s / 60))}:${t(s % 60)}`;
@@ -314,101 +271,355 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
314
271
  case "datetime": return n();
315
272
  default: return "";
316
273
  }
317
- }, _e = (e) => {
274
+ }, D = (e) => {
318
275
  let t = {};
319
276
  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);
277
+ let n = E(e.defaultValue, e.type);
278
+ s(t, e.path, n === void 0 ? me(e.type) : n);
322
279
  }), t;
323
- }, A = (e, t) => {
280
+ }, O = (e, t) => {
281
+ if (r(e)) {
282
+ if (!r(t)) return i(t === void 0 ? e : t);
283
+ let n = {};
284
+ return Object.keys(e).forEach((r) => {
285
+ n[r] = O(e[r], t[r]);
286
+ }), Object.keys(t).forEach((e) => {
287
+ e in n || (n[e] = i(t[e]));
288
+ }), n;
289
+ }
290
+ return i(t === void 0 ? e : t);
291
+ }, he = (e, t) => O(e, r(t) ? t : {}), k = (e, t) => {
324
292
  let n = i(e);
325
293
  return t.forEach((e) => {
326
294
  if (e.type !== "datetime") return;
327
295
  let t = e.path.trim();
328
296
  if (!t) return;
329
297
  let r = c(n, t);
330
- r !== void 0 && s(n, t, h(r));
298
+ r !== void 0 && s(n, t, m(r));
331
299
  }), n;
332
- }, j = (e) => {
300
+ }, A = (e) => {
333
301
  if (e === "" || e === 0 || e === !1) return !0;
334
302
  if (Array.isArray(e)) return e.length === 0;
335
303
  if (r(e)) {
336
304
  let t = Object.values(e);
337
- return t.length === 0 || t.every((e) => j(e));
305
+ return t.length === 0 || t.every((e) => A(e));
338
306
  }
339
307
  return !1;
340
- }, M = (e, t) => {
308
+ }, ge = (e, t) => {
341
309
  switch (t.type) {
342
310
  case "number": return typeof e == "number" && Number.isFinite(e);
343
311
  case "boolean": return typeof e == "boolean";
344
312
  case "array": return Array.isArray(e);
345
313
  case "object": return r(e);
346
- case "datetime": return typeof e == "string" && m.test(e.trim());
314
+ case "datetime": return typeof e == "string" && p.test(e.trim());
347
315
  default: return typeof e == "string";
348
316
  }
349
- }, N = (e, t) => t.filter((e) => e.name.trim() && e.path.trim()).flatMap((t) => {
317
+ }, j = (e, t) => t.filter((e) => e.name.trim() && e.path.trim()).flatMap((t) => {
350
318
  let n = c(e, t.path.trim());
351
- return n === void 0 || M(n, t) ? [] : [{
319
+ return n === void 0 || ge(n, t) ? [] : [{
352
320
  path: t.path,
353
321
  nextType: t.type,
354
322
  value: i(n)
355
323
  }];
356
- }), P = (e, t) => {
324
+ }), _e = (e, t) => {
357
325
  let n = i(e);
358
326
  return t.filter((e) => e.name.trim() && e.path.trim()).forEach((e) => {
359
- let t = k(e.defaultValue, e.type);
327
+ let t = E(e.defaultValue, e.type);
360
328
  if (t === void 0) return;
361
329
  let r = e.path.trim(), a = c(n, r);
362
- (a === void 0 || j(a)) && s(n, r, i(t));
330
+ (a === void 0 || A(a)) && s(n, r, i(t));
363
331
  }), 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"] : [];
332
+ }, ve = (e, t) => {
333
+ let n = x(S(e)), i = t?.dataLabel ?? "Data", a = Array.isArray(n?.examples) ? n.examples : [], o = Array.isArray(n?.["x-examples-meta"]) ? n["x-examples-meta"] : [];
366
334
  return a.length > 0 ? a.map((e, t) => {
367
335
  let n = o[t];
368
336
  return {
369
337
  id: `schema-example-${t}`,
370
- name: n?.name?.trim() || D(t, i),
338
+ name: n?.name?.trim() || w(t, i),
371
339
  description: n?.description?.trim(),
372
340
  data: r(e) ? { ...e } : { value: e },
373
341
  source: "schema.examples"
374
342
  };
375
343
  }) : (e?.inputs ?? []).length > 0 ? [{
376
344
  id: "schema-example-0",
377
- name: D(0, i),
378
- data: b(e?.inputs),
345
+ name: w(0, i),
346
+ data: y(e?.inputs),
379
347
  source: "schema.examples"
380
348
  }] : [];
381
- }, ve = (e, t, n) => {
349
+ }, M = (e, t, n) => {
382
350
  let r = {
383
- ...S(e) ?? {},
351
+ ...x(e) ?? {},
384
352
  type: "object",
385
353
  examples: t.map((e) => ({ ...e }))
386
354
  };
387
355
  return n && n.length > 0 && n.some((e) => e?.name?.trim() || e?.description?.trim()) && (r["x-examples-meta"] = n.map((e) => ({
388
356
  name: e?.name?.trim(),
389
357
  description: e?.description?.trim()
390
- }))), x(r);
391
- }, ye = "application/vnd.gorules.decision", I = e.string().default(() => crypto.randomUUID()), be = e.object({
358
+ }))), b(r);
359
+ }, ye = 1, N = "examples", P = "x-examples-meta", F = (e) => {
360
+ let t = (e) => Array.isArray(e) ? e.map(t) : r(e) ? Object.keys(e).sort().reduce((n, r) => (n[r] = t(e[r]), n), {}) : e, n = JSON.stringify(t(e ?? {})), i = 2166136261, a = 522970236;
361
+ for (let e = 0; e < n.length; e += 1) {
362
+ let t = n.charCodeAt(e);
363
+ i = Math.imul(i ^ t, 16777619) >>> 0, a = Math.imul(a ^ t, 16777619) >>> 0;
364
+ }
365
+ return `${i.toString(16).padStart(8, "0")}${a.toString(16).padStart(8, "0")}`;
366
+ }, I = (e) => r(e) ? { ...e } : { value: e }, L = (e, t) => {
367
+ let n = r(e) ? e : {};
368
+ return {
369
+ id: typeof n.id == "string" && n.id ? n.id : `contract-example-${t}`,
370
+ name: typeof n.name == "string" && n.name.trim() ? n.name : w(t),
371
+ description: typeof n.description == "string" && n.description.trim() ? n.description : void 0,
372
+ data: I(n.data),
373
+ schemaFingerprint: typeof n.schemaFingerprint == "string" ? n.schemaFingerprint : void 0
374
+ };
375
+ }, be = (e) => {
376
+ let t = x(e.schema) ?? {}, n = Array.isArray(e.examples) ? e.examples : [];
377
+ return {
378
+ contractVersion: typeof e.contractVersion == "number" ? e.contractVersion : 1,
379
+ schema: t,
380
+ examples: n.map((e, t) => L(e, t))
381
+ };
382
+ }, xe = (e) => {
383
+ let t = C(e, { includeExamples: !0 }), n = Array.isArray(t?.[N]) ? t?.[N] : [], i = Array.isArray(t?.[P]) ? t?.[P] : [], a = {};
384
+ return t && r(t) && Object.entries(t).forEach(([e, t]) => {
385
+ e !== N && e !== P && (a[e] = t);
386
+ }), {
387
+ contractVersion: 1,
388
+ schema: a,
389
+ examples: n.map((e, t) => {
390
+ let n = i[t];
391
+ return {
392
+ id: `schema-example-${t}`,
393
+ name: n?.name?.trim() || w(t),
394
+ description: n?.description?.trim() || void 0,
395
+ data: I(e),
396
+ schemaFingerprint: void 0
397
+ };
398
+ })
399
+ };
400
+ }, Se = (e) => {
401
+ let t = r(e?.inputContract) ? e?.inputContract : null;
402
+ return t ? {
403
+ contract: be(t),
404
+ origin: "contract"
405
+ } : {
406
+ contract: xe(e),
407
+ origin: "legacy"
408
+ };
409
+ }, Ce = (e, t) => {
410
+ let n = {
411
+ contractVersion: t.contractVersion || 1,
412
+ schema: r(t.schema) ? t.schema : {},
413
+ examples: t.examples.map((e, t) => L(e, t))
414
+ };
415
+ return e.inputContract = {
416
+ contractVersion: n.contractVersion,
417
+ schema: n.schema,
418
+ examples: n.examples.map((e) => ({
419
+ id: e.id,
420
+ name: e.name,
421
+ ...e.description ? { description: e.description } : {},
422
+ data: i(e.data),
423
+ ...e.schemaFingerprint ? { schemaFingerprint: e.schemaFingerprint } : {}
424
+ }))
425
+ }, fe(e, M(n.schema, n.examples.map((e) => e.data), n.examples.map((e) => ({
426
+ name: e.name,
427
+ description: e.description
428
+ })))), n;
429
+ }, we = (e, t) => {
430
+ let n = x(t);
431
+ if (!n) return {
432
+ contractVersion: e.contractVersion,
433
+ schema: {},
434
+ examples: e.examples
435
+ };
436
+ let r = Array.isArray(n[N]) ? n[N] : [], i = Array.isArray(n[P]) ? n[P] : [], a = {};
437
+ if (Object.entries(n).forEach(([e, t]) => {
438
+ e !== N && e !== P && (a[e] = t);
439
+ }), r.length === 0) return {
440
+ contractVersion: e.contractVersion,
441
+ schema: a,
442
+ examples: e.examples
443
+ };
444
+ let o = r.map((t, n) => {
445
+ let r = i[n], a = e.examples[n];
446
+ return {
447
+ id: a?.id ?? `schema-example-${n}`,
448
+ name: r?.name?.trim() || a?.name || w(n),
449
+ description: r?.description?.trim() || a?.description,
450
+ data: I(t),
451
+ schemaFingerprint: void 0
452
+ };
453
+ });
454
+ return {
455
+ contractVersion: e.contractVersion,
456
+ schema: a,
457
+ examples: o
458
+ };
459
+ }, Te = (e, t) => e.examples.map((e, n) => ({
460
+ id: e.id,
461
+ name: e.name.trim() || w(n, t?.dataLabel),
462
+ description: e.description,
463
+ data: { ...e.data },
464
+ source: "schema.examples"
465
+ })), Ee = (e, t) => {
466
+ let n = t.filter((e) => e.name.trim() && e.path.trim()), r = j(e, n), i = n.filter((t) => c(e, t.path.trim()) === void 0), a = T(e), o = n.map((e) => e.path.trim());
467
+ return {
468
+ missing: i,
469
+ extra: a.filter((e) => !o.some((t) => e === t || e.startsWith(`${t}.`))),
470
+ conflicts: r
471
+ };
472
+ }, De = (e) => e.missing.length > 0 || e.extra.length > 0 || e.conflicts.length > 0, Oe = (e, t) => {
473
+ let n = t.filter((e) => e.name.trim() && e.path.trim());
474
+ if (n.length === 0) return {
475
+ data: i(e),
476
+ conflicts: []
477
+ };
478
+ let r = he(D(n), e);
479
+ T(r).forEach((e) => {
480
+ n.some((t) => {
481
+ let n = t.path.trim();
482
+ return e === n || e.startsWith(`${n}.`);
483
+ }) || ee(r, e);
484
+ });
485
+ let a = k(r, n);
486
+ return {
487
+ data: a,
488
+ conflicts: j(a, n)
489
+ };
490
+ }, ke = (e) => ({
491
+ contractVersion: e.contractVersion || 1,
492
+ schema: r(e.schema) ? e.schema : {},
493
+ examples: e.examples.map((e) => ({
494
+ id: e.id,
495
+ name: e.name,
496
+ ...e.description ? { description: e.description } : {},
497
+ data: i(e.data)
498
+ }))
499
+ }), Ae = (e) => {
500
+ let n;
501
+ try {
502
+ n = t.parse(e);
503
+ } catch {
504
+ return {
505
+ ok: !1,
506
+ error: "invalid-json"
507
+ };
508
+ }
509
+ if (!r(n) || !r(n.schema) || !Array.isArray(n.examples)) return {
510
+ ok: !1,
511
+ error: "invalid-shape"
512
+ };
513
+ let i = n.contractVersion;
514
+ if (typeof i != "number" || i > 1) return {
515
+ ok: !1,
516
+ error: "unsupported-version"
517
+ };
518
+ let a = /* @__PURE__ */ new Set(), o = n.examples.map((e, t) => {
519
+ let n = r(e) ? e : {}, i = typeof n.id == "string" ? n.id.trim() : "", o = i && !a.has(i) ? i : "";
520
+ return a.add(i), {
521
+ id: o,
522
+ name: typeof n.name == "string" && n.name.trim() ? n.name : w(t),
523
+ description: typeof n.description == "string" && n.description.trim() ? n.description : void 0,
524
+ data: I(n.data)
525
+ };
526
+ });
527
+ return {
528
+ ok: !0,
529
+ contract: {
530
+ contractVersion: i,
531
+ schema: n.schema,
532
+ examples: o
533
+ }
534
+ };
535
+ }, je = null, R = /* @__PURE__ */ new Map(), Me = () => (je ??= Promise.all([import("ajv/dist/2020"), import("ajv-formats")]).then(([e, t]) => {
536
+ let n = new e.default({ allErrors: !0 });
537
+ return t.default(n), n;
538
+ }), je), Ne = (e) => {
539
+ let t = F(e), n = R.get(t);
540
+ return n || (n = Me().then((t) => t.compile(e)), R.set(t, n)), n;
541
+ }, Pe = (e) => `${e.instancePath || "/"} ${e.message ?? ""}`.trim(), Fe = async (e, t) => {
542
+ try {
543
+ let n = await Ne(t);
544
+ return e.map((e) => n(e) ? [] : n.errors?.map(Pe) ?? []);
545
+ } catch {
546
+ return e.map(() => []);
547
+ }
548
+ }, Ie = (e, t) => {
549
+ let n = e?.["x-order"];
550
+ return typeof n == "number" && Number.isFinite(n) ? n : t;
551
+ }, Le = (e) => Object.entries(e).map(([e, t], n) => ({
552
+ key: e,
553
+ propertySchema: t,
554
+ index: n,
555
+ order: Ie(t, n)
556
+ })).sort((e, t) => e.order - t.order || e.index - t.index), z = (e, t = "", n = 0) => {
557
+ let i = [];
558
+ return Le(e).forEach(({ key: e, propertySchema: o, order: s }) => {
559
+ let c = a(t, e);
560
+ i.push({
561
+ id: `schema-property-${c}`,
562
+ path: c,
563
+ name: e,
564
+ type: d(o),
565
+ description: String(o?.description ?? ""),
566
+ format: String(o?.format ?? ""),
567
+ order: s,
568
+ depth: n,
569
+ parentPath: t || null,
570
+ source: "schema.properties",
571
+ defaultValue: o?.default === void 0 ? void 0 : String(o.default)
572
+ }), r(o?.properties) && i.push(...z(o.properties, c, n + 1));
573
+ }), i;
574
+ }, B = (e) => {
575
+ let t = /* @__PURE__ */ new Map();
576
+ return e.map((e) => {
577
+ let n = e.parentPath ?? "__root__", r = t.get(n) ?? 0;
578
+ return t.set(n, r + 1), {
579
+ ...e,
580
+ order: r
581
+ };
582
+ });
583
+ }, Re = (e) => {
584
+ let t = x(S(e));
585
+ if (t && n(t, "properties") && r(t.properties)) return B(z(t.properties));
586
+ let i = v(e?.inputs);
587
+ return Object.keys(i).length === 0 ? [] : B(z(i).map((e) => ({
588
+ ...e,
589
+ source: "content.inputs"
590
+ })));
591
+ }, ze = (e, t) => {
592
+ let n = x(e) ?? {}, r = {};
593
+ return B(t).forEach((e) => {
594
+ if (!l(e.name)) return;
595
+ let t = e.path.split(".").map(l).filter(Boolean).join(".");
596
+ t && ae(r, t, e);
597
+ }), b({
598
+ ...n,
599
+ type: "object",
600
+ properties: r
601
+ });
602
+ }, Be = "application/vnd.gorules.decision", V = e.string().default(() => crypto.randomUUID()), Ve = e.object({
392
603
  label: e.string(),
393
604
  value: e.string()
394
- }), L = e.discriminatedUnion("type", [e.object({
605
+ }), H = e.discriminatedUnion("type", [e.object({
395
606
  type: e.literal("inline"),
396
- values: e.array(be),
607
+ values: e.array(Ve),
397
608
  loose: e.boolean().optional()
398
609
  }), e.object({
399
610
  type: e.literal("ref"),
400
611
  ref: e.string(),
401
612
  loose: e.boolean().optional()
402
- })]), R = e.discriminatedUnion("type", [
613
+ })]), U = e.discriminatedUnion("type", [
403
614
  e.object({ type: e.literal("any") }),
404
615
  e.object({
405
616
  type: e.literal("string"),
406
- enum: L.optional()
617
+ enum: H.optional()
407
618
  }),
408
619
  e.object({ type: e.literal("number") }),
409
620
  e.object({ type: e.literal("boolean") }),
410
621
  e.object({ type: e.literal("date") })
411
- ]), xe = [
622
+ ]), He = [
412
623
  {
413
624
  value: "any",
414
625
  label: "Any"
@@ -429,20 +640,20 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
429
640
  value: "date",
430
641
  label: "Date"
431
642
  }
432
- ], z = e.discriminatedUnion("type", [
643
+ ], W = e.discriminatedUnion("type", [
433
644
  e.object({ type: e.literal("auto") }),
434
645
  e.object({
435
646
  type: e.literal("string"),
436
- enum: L.optional()
647
+ enum: H.optional()
437
648
  }),
438
649
  e.object({
439
650
  type: e.literal("string-array"),
440
- enum: L.optional()
651
+ enum: H.optional()
441
652
  }),
442
653
  e.object({ type: e.literal("number") }),
443
654
  e.object({ type: e.literal("boolean") }),
444
655
  e.object({ type: e.literal("date") })
445
- ]), Se = [
656
+ ]), Ue = [
446
657
  {
447
658
  value: "auto",
448
659
  label: "Auto"
@@ -467,10 +678,10 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
467
678
  value: "date",
468
679
  label: "Date"
469
680
  }
470
- ], B = /* @__PURE__ */ function(e) {
681
+ ], G = /* @__PURE__ */ function(e) {
471
682
  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,
683
+ }({}), K = "customNode", q = e.object({
684
+ id: V,
474
685
  name: e.string(),
475
686
  position: e.object({
476
687
  x: e.number(),
@@ -479,59 +690,70 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
479
690
  x: 0,
480
691
  y: 0
481
692
  })
482
- }), U = e.object({
693
+ }), J = e.object({
483
694
  type: e.literal("inputNode"),
484
695
  content: e.object({
485
- schema: e.union([e.string(), e.record(e.string(), e.any())]).nullish().transform((e) => x(e)),
696
+ schema: e.union([e.string(), e.record(e.string(), e.any())]).nullish().transform((e) => b(e)),
486
697
  expressions: e.array(e.object({
487
- id: I,
698
+ id: V,
488
699
  key: e.string().default(""),
489
700
  value: e.any().default(""),
490
701
  type: e.string().optional()
491
702
  })).default([]),
492
703
  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)
704
+ outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
705
+ inputContract: e.object({
706
+ contractVersion: e.number().default(1),
707
+ schema: e.union([e.string(), e.record(e.string(), e.any())]).nullish().transform((e) => r(e) ? e : x(e) ?? {}),
708
+ examples: e.array(e.object({
709
+ id: e.string(),
710
+ name: e.string().default(""),
711
+ description: e.string().nullish(),
712
+ data: e.record(e.string(), e.any()).default({}),
713
+ schemaFingerprint: e.string().nullish()
714
+ })).default([])
715
+ }).nullish()
494
716
  }).default({
495
717
  schema: "",
496
718
  expressions: [],
497
719
  inputField: null,
498
720
  outputPath: null
499
721
  })
500
- }).merge(H), W = e.object({
722
+ }).merge(q), Y = e.object({
501
723
  type: e.literal("outputNode"),
502
724
  content: e.object({ schema: e.string().nullish().transform((e) => e ?? "") }).default({ schema: "" })
503
- }).merge(H), G = e.object({
725
+ }).merge(q), X = e.object({
504
726
  type: e.literal("decisionTableNode"),
505
727
  content: e.object({
506
728
  hitPolicy: e.enum(["first", "collect"]).nullish().transform((e) => e ?? "first"),
507
729
  rules: e.array(e.record(e.string(), e.string().nullish().transform((e) => e ?? ""))).default([]),
508
730
  inputs: e.array(e.object({
509
- id: I,
731
+ id: V,
510
732
  name: e.string().nullish(),
511
733
  field: e.string().nullish(),
512
734
  defaultValue: e.string().nullish(),
513
- fieldType: R.nullish()
735
+ fieldType: U.nullish()
514
736
  })),
515
737
  outputs: e.array(e.object({
516
- id: I,
738
+ id: V,
517
739
  name: e.string(),
518
740
  field: e.string(),
519
741
  defaultValue: e.string().nullish(),
520
- outputFieldType: z.nullish()
742
+ outputFieldType: W.nullish()
521
743
  })),
522
744
  passThrough: e.boolean().nullish().transform((e) => e ?? !1),
523
745
  inputField: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
524
746
  outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
525
747
  executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
526
748
  })
527
- }).merge(H), K = e.object({
749
+ }).merge(q), Z = e.object({
528
750
  type: e.literal("functionNode"),
529
751
  content: e.string().or(e.object({ source: e.string().default("") })).nullish()
530
- }).merge(H), q = e.object({
752
+ }).merge(q), Q = e.object({
531
753
  type: e.literal("expressionNode"),
532
754
  content: e.object({
533
755
  expressions: e.array(e.object({
534
- id: I,
756
+ id: V,
535
757
  key: e.string().default(""),
536
758
  value: e.string().default("")
537
759
  })),
@@ -540,7 +762,7 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
540
762
  outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
541
763
  executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
542
764
  })
543
- }).merge(H), J = e.object({
765
+ }).merge(q), We = e.object({
544
766
  type: e.literal("decisionNode"),
545
767
  content: e.object({
546
768
  key: e.string(),
@@ -549,50 +771,50 @@ var n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), r = (e) => typeof
549
771
  outputPath: e.string().nullish().default(null).transform((e) => e && e.trim().length > 0 ? e : null),
550
772
  executionMode: e.enum(["single", "loop"]).nullish().transform((e) => e ?? "single")
551
773
  })
552
- }).merge(H), Y = e.object({
774
+ }).merge(q), $ = e.object({
553
775
  type: e.literal("switchNode"),
554
776
  content: e.object({
555
777
  hitPolicy: e.enum(["first", "collect"]).nullish().transform((e) => e ?? "first"),
556
778
  statements: e.array(e.object({
557
- id: I,
779
+ id: V,
558
780
  condition: e.string().nullish().transform((e) => e ?? ""),
559
781
  isDefault: e.boolean().nullish().transform((e) => e ?? !1),
560
782
  name: e.string().nullish().transform((e) => e && e.trim() !== "" ? e : void 0)
561
783
  }))
562
784
  })
563
- }).merge(H), X = e.object({
564
- type: e.literal(V),
785
+ }).merge(q), Ge = e.object({
786
+ type: e.literal(K),
565
787
  content: e.object({
566
788
  kind: e.string(),
567
789
  config: e.any()
568
790
  })
569
- }).merge(H), Z = e.object({
570
- type: e.string().refine((e) => !Object.values(B).includes(e), { message: "Invalid type" }),
791
+ }).merge(q), Ke = e.object({
792
+ type: e.string().refine((e) => !Object.values(G).includes(e), { message: "Invalid type" }),
571
793
  content: e.any().nullish()
572
- }).merge(H), Q = e.discriminatedUnion("type", [
573
- J,
574
- q,
575
- K,
576
- G,
577
- Y,
794
+ }).merge(q), qe = e.discriminatedUnion("type", [
795
+ We,
796
+ Q,
797
+ Z,
578
798
  X,
579
- U,
580
- W
581
- ]).or(Z), $ = e.object({
799
+ $,
800
+ Ge,
801
+ J,
802
+ Y
803
+ ]).or(Ke), Je = e.object({
582
804
  id: e.string(),
583
805
  sourceId: e.string(),
584
806
  targetId: e.string(),
585
807
  sourceHandle: e.string().nullish(),
586
808
  type: e.enum(["edge"]),
587
809
  name: e.string().nullish().transform((e) => e && e.trim() !== "" ? e : void 0)
588
- }), Ce = e.object({
810
+ }), Ye = e.object({
589
811
  inputSchema: e.any().nullish().default(null),
590
812
  outputSchema: e.any().nullish().default(null)
591
- }), we = e.object({
592
- nodes: e.array(Q).default([]),
593
- edges: e.array($).default([])
813
+ }), Xe = e.object({
814
+ nodes: e.array(qe).default([]),
815
+ edges: e.array(Je).default([])
594
816
  });
595
817
  //#endregion
596
- 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 };
818
+ export { n as $, ke as A, w as B, Re as C, we as D, ye as E, F, M as G, ve as H, Ce as I, C as J, S as K, D as L, Oe as M, Ae as N, Ee as O, Se as P, c as Q, T as R, ze as S, Fe as T, _e as U, j as V, k as W, l as X, b as Y, u as Z, qe as _, Ue as a, $ as b, U as c, We as d, r as et, X as f, J as g, Z as h, G as i, De as j, Te as k, Ge as l, Q as m, K as n, Ke as o, Je as p, x as q, Be as r, H as s, He as t, Xe as u, W as v, B as w, Ye as x, Y as y, pe as z };
597
819
 
598
- //# sourceMappingURL=schema-Csyt47SS.js.map
820
+ //# sourceMappingURL=schema-BDvVbmiV.js.map