@code0-tech/triangulum 0.33.0 → 0.35.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/dist/index.cjs +4 -4
- package/dist/index.js +160 -100
- package/dist/server.cjs +2 -2
- package/dist/server.js +2 -2
- package/dist/util/schema.util.d.ts +54 -8
- package/dist/{utils-DHs93w48.js → utils-CAOAm6k-.js} +269 -154
- package/dist/utils-oMAOCPrM.cjs +45 -0
- package/package.json +2 -2
- package/dist/utils-9-y-1aUm.cjs +0 -45
|
@@ -278,16 +278,16 @@ var _ = (t) => {
|
|
|
278
278
|
value: !1,
|
|
279
279
|
__typename: "LiteralValue"
|
|
280
280
|
}] : [];
|
|
281
|
-
},
|
|
281
|
+
}, ee = (e, t, n, r) => r.flatMap((r) => {
|
|
282
282
|
let i = r.getName();
|
|
283
|
-
if (!
|
|
283
|
+
if (!y(i)) return [];
|
|
284
284
|
let a = r.getDeclarations()?.[0];
|
|
285
285
|
if (!a || a.getEnd() >= t.getEnd()) return [];
|
|
286
286
|
let o = e.getTypeOfSymbolAtLocation(r, t);
|
|
287
|
-
return i.startsWith("node_") ?
|
|
288
|
-
}),
|
|
287
|
+
return i.startsWith("node_") ? b(i, o, e, n) : i.startsWith("p_") ? x(i, o, e, n) : i.startsWith("flow_") ? S(o, e, n) : [];
|
|
288
|
+
}), y = (e) => e.startsWith("node_") || e.startsWith("p_") || e.startsWith("flow_"), b = (t, n, r, i) => {
|
|
289
289
|
if ((n.flags & e.TypeFlags.Void) !== 0) return [];
|
|
290
|
-
let a =
|
|
290
|
+
let a = C(t.replace("node_", ""));
|
|
291
291
|
return D(n, r, i).flatMap(({ path: e }) => {
|
|
292
292
|
let t = {
|
|
293
293
|
__typename: "ReferenceValue",
|
|
@@ -295,8 +295,8 @@ var _ = (t) => {
|
|
|
295
295
|
};
|
|
296
296
|
return e.length > 0 && (t.referencePath = e), t;
|
|
297
297
|
});
|
|
298
|
-
},
|
|
299
|
-
let { nodeFunctionId: i, paramIndexFromName: a } =
|
|
298
|
+
}, x = (e, t, n, r) => {
|
|
299
|
+
let { nodeFunctionId: i, paramIndexFromName: a } = te(e);
|
|
300
300
|
if (!n.isTupleType(t)) return [];
|
|
301
301
|
let o = t;
|
|
302
302
|
return n.getTypeArguments(o).flatMap((e, t) => D(e, n, r).flatMap(({ path: e }) => {
|
|
@@ -309,19 +309,19 @@ var _ = (t) => {
|
|
|
309
309
|
};
|
|
310
310
|
return e.length > 0 && (n.referencePath = e), n;
|
|
311
311
|
}));
|
|
312
|
-
},
|
|
312
|
+
}, S = (e, t, n) => D(e, t, n).flatMap(({ path: e }) => {
|
|
313
313
|
let t = {
|
|
314
314
|
__typename: "ReferenceValue",
|
|
315
315
|
nodeFunctionId: null
|
|
316
316
|
};
|
|
317
317
|
return e.length > 0 && (t.referencePath = e), t;
|
|
318
|
-
}),
|
|
318
|
+
}), C = (e) => e.replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/"), te = (e) => {
|
|
319
319
|
let t = e.replace("p_", ""), n = t.lastIndexOf("_"), r = t.substring(0, n), i = parseInt(t.substring(n + 1), 10);
|
|
320
320
|
return {
|
|
321
|
-
nodeFunctionId:
|
|
321
|
+
nodeFunctionId: C(r),
|
|
322
322
|
paramIndexFromName: i
|
|
323
323
|
};
|
|
324
|
-
},
|
|
324
|
+
}, ne = 7, w = (e, t, n) => {
|
|
325
325
|
let r = n.get(e);
|
|
326
326
|
if (r !== void 0) return r;
|
|
327
327
|
let i = /* @__PURE__ */ new Set(), a = (n) => {
|
|
@@ -335,13 +335,13 @@ var _ = (t) => {
|
|
|
335
335
|
return !1;
|
|
336
336
|
}, o = a(e);
|
|
337
337
|
return n.set(e, o), o;
|
|
338
|
-
},
|
|
338
|
+
}, T = (t, n, r) => t.isUnion() ? t.types.some((e) => T(n.getNonNullableType(e), n, r)) : (t.flags & e.TypeFlags.Never) === 0 && n.isTypeAssignableTo(t, r), E = (e, t) => e.isUnion() ? e.types.map((e) => t.getNonNullableType(e)).filter(O) : O(e) ? [e] : [], D = (e, t, n, r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map()) => {
|
|
339
339
|
let o = [], s = t.getNonNullableType(e);
|
|
340
|
-
return
|
|
340
|
+
return T(s, t, n) && o.push({
|
|
341
341
|
path: r,
|
|
342
342
|
type: e
|
|
343
|
-
}),
|
|
344
|
-
if (i.has(e) || r.length >=
|
|
343
|
+
}), E(s, t).forEach((e) => {
|
|
344
|
+
if (i.has(e) || r.length >= ne && w(e, t, a)) return;
|
|
345
345
|
let s = e.getProperties();
|
|
346
346
|
s && s.length > 0 && (i.add(e), s.forEach((e) => {
|
|
347
347
|
let s = t.getTypeOfSymbolAtLocation(e, e.valueDeclaration), c = e.getName(), l = [...r, { path: c }];
|
|
@@ -351,11 +351,10 @@ var _ = (t) => {
|
|
|
351
351
|
}, O = (t) => {
|
|
352
352
|
let n = e.TypeFlags.String | e.TypeFlags.Number | e.TypeFlags.Boolean | e.TypeFlags.Undefined | e.TypeFlags.Null | e.TypeFlags.BigInt | e.TypeFlags.ESSymbol;
|
|
353
353
|
return (t.flags & n) === 0;
|
|
354
|
-
}, re = (e, t, n, r) =>
|
|
354
|
+
}, re = (e, t, n, r) => q(r) ? [] : t.flatMap((t) => {
|
|
355
355
|
let i = ie(e, t, n, r);
|
|
356
356
|
return i ? [i] : [];
|
|
357
357
|
}), ie = (t, n, r, i) => {
|
|
358
|
-
if (n.parameters.length > 0) return null;
|
|
359
358
|
let a = t.getSignatureFromDeclaration(n), o = ae(t, t.getReturnTypeOfSignature(a)), s = t.getNonNullableType(o);
|
|
360
359
|
if ((s.flags & e.TypeFlags.Never) !== 0 || !t.isTypeAssignableTo(s, i)) return null;
|
|
361
360
|
let c = oe(n.name?.getText());
|
|
@@ -388,15 +387,15 @@ var _ = (t) => {
|
|
|
388
387
|
__typename: "LiteralValue",
|
|
389
388
|
value: e.defaultValue.value
|
|
390
389
|
} : null
|
|
391
|
-
}), ue = (e, t, n, r) =>
|
|
390
|
+
}), ue = (e, t, n, r) => q(r) ? t.flatMap((t) => {
|
|
392
391
|
let i = de(e, t, n, r);
|
|
393
392
|
return i ? [i] : [];
|
|
394
393
|
}) : [], de = (e, t, n, r) => {
|
|
395
394
|
let i = e.getTypeAtLocation(t);
|
|
396
395
|
if (!e.isTypeAssignableTo(i, r)) return null;
|
|
397
|
-
let a =
|
|
398
|
-
return o ?
|
|
399
|
-
},
|
|
396
|
+
let a = fe(t.name?.getText()), o = n.find((e) => e.identifier === a);
|
|
397
|
+
return o ? pe(o) : null;
|
|
398
|
+
}, fe = (e) => e ? e.replace("fn_", "").replace("_", "::").replace("_", "::") : "", pe = (e) => ({
|
|
400
399
|
__typename: "SubFlowValue",
|
|
401
400
|
functionDefinition: e,
|
|
402
401
|
signature: e.signature,
|
|
@@ -407,181 +406,253 @@ var _ = (t) => {
|
|
|
407
406
|
hidden: e?.hidden ?? !1,
|
|
408
407
|
optional: e?.optional ?? !1
|
|
409
408
|
}))
|
|
410
|
-
}),
|
|
409
|
+
}), k = {
|
|
410
|
+
DATE: "date",
|
|
411
|
+
TYPE: "type"
|
|
412
|
+
}, A = (e) => e != null && e in k, me = new Set(Object.values(k)), j = (e) => e != null && me.has(e), M = 7, N = (t, n, r, i, a, o = !0, s, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), u) => {
|
|
411
413
|
if ((r.flags & e.TypeFlags.TypeParameter) !== 0) {
|
|
412
414
|
let u = r.symbol?.declarations?.[0];
|
|
413
|
-
if (u && e.isTypeParameterDeclaration(u) && u.constraint) return
|
|
415
|
+
if (u && e.isTypeParameterDeclaration(u) && u.constraint) return N(t, n, t.getTypeFromTypeNode(u.constraint), i, a, o, s, c, l);
|
|
414
416
|
}
|
|
415
|
-
let
|
|
417
|
+
let d = A(r.aliasSymbol?.getName()), f = d && r.isIntersection() ? t.typeToString(r.types.find((t) => (t.flags & e.TypeFlags.Object) === 0) ?? r) : d ? "object" : t.typeToString({
|
|
416
418
|
...r,
|
|
417
419
|
aliasSymbol: void 0
|
|
418
|
-
}),
|
|
419
|
-
...v(
|
|
420
|
-
...n ?
|
|
421
|
-
...re(t, i, a,
|
|
422
|
-
...ue(t, i, a,
|
|
420
|
+
}), p = s ?? r, m = o ? { suggestions: [
|
|
421
|
+
...v(p, t),
|
|
422
|
+
...n ? ee(t, n, p, t.getSymbolsInScope(n, e.SymbolFlags.Variable)) : [],
|
|
423
|
+
...re(t, i, a, p),
|
|
424
|
+
...ue(t, i, a, p)
|
|
423
425
|
] } : {};
|
|
426
|
+
if (u) {
|
|
427
|
+
let e = ve(t, u);
|
|
428
|
+
if (e) return {
|
|
429
|
+
input: e,
|
|
430
|
+
type: f,
|
|
431
|
+
...m
|
|
432
|
+
};
|
|
433
|
+
}
|
|
424
434
|
if (r.isUnion()) {
|
|
425
|
-
let
|
|
426
|
-
if (
|
|
427
|
-
...
|
|
428
|
-
type:
|
|
429
|
-
...
|
|
435
|
+
let s = r.types.filter((t) => (t.flags & (e.TypeFlags.Undefined | e.TypeFlags.Null)) === 0);
|
|
436
|
+
if (s.length === 1) return {
|
|
437
|
+
...N(t, n, s[0], i, a, o, void 0, c, l),
|
|
438
|
+
type: f,
|
|
439
|
+
...m
|
|
430
440
|
};
|
|
431
441
|
}
|
|
432
|
-
let
|
|
433
|
-
if (
|
|
434
|
-
input:
|
|
435
|
-
type:
|
|
436
|
-
...
|
|
442
|
+
let h = B(r);
|
|
443
|
+
if (h) return {
|
|
444
|
+
input: h,
|
|
445
|
+
type: f,
|
|
446
|
+
...m
|
|
437
447
|
};
|
|
438
|
-
if (
|
|
448
|
+
if (V(t, r)) return {
|
|
439
449
|
input: "file",
|
|
440
|
-
type:
|
|
441
|
-
mimetype:
|
|
442
|
-
...
|
|
450
|
+
type: f,
|
|
451
|
+
mimetype: H(t, r),
|
|
452
|
+
...m
|
|
443
453
|
};
|
|
444
|
-
if (
|
|
454
|
+
if (be(t, r)) return {
|
|
445
455
|
input: "color",
|
|
446
|
-
type:
|
|
447
|
-
...
|
|
456
|
+
type: f,
|
|
457
|
+
...m
|
|
448
458
|
};
|
|
449
|
-
if (
|
|
459
|
+
if (U(r)) return {
|
|
450
460
|
input: "boolean",
|
|
451
|
-
type:
|
|
452
|
-
...
|
|
461
|
+
type: f,
|
|
462
|
+
...m
|
|
453
463
|
};
|
|
454
|
-
if (
|
|
464
|
+
if (K(r)) return {
|
|
455
465
|
input: "select",
|
|
456
|
-
type:
|
|
457
|
-
...
|
|
466
|
+
type: f,
|
|
467
|
+
...m
|
|
458
468
|
};
|
|
459
|
-
if (
|
|
469
|
+
if (W(r)) return {
|
|
460
470
|
input: "number",
|
|
461
|
-
type:
|
|
462
|
-
...
|
|
471
|
+
type: f,
|
|
472
|
+
...m
|
|
463
473
|
};
|
|
464
|
-
if (
|
|
474
|
+
if (G(r)) return {
|
|
465
475
|
input: "text",
|
|
466
|
-
type:
|
|
467
|
-
...
|
|
476
|
+
type: f,
|
|
477
|
+
...m
|
|
468
478
|
};
|
|
469
|
-
if (
|
|
479
|
+
if (q(r)) return {
|
|
470
480
|
input: "sub-flow",
|
|
471
|
-
type:
|
|
472
|
-
...
|
|
481
|
+
type: f,
|
|
482
|
+
...m
|
|
473
483
|
};
|
|
474
|
-
if (
|
|
484
|
+
if (we(t, r)) {
|
|
475
485
|
let e = t.getTypeArguments(r);
|
|
476
|
-
if (e.length === 1 &&
|
|
486
|
+
if (e.length === 1 && V(t, e[0])) return {
|
|
477
487
|
input: "list-file",
|
|
478
|
-
type:
|
|
479
|
-
mimetype:
|
|
480
|
-
...
|
|
488
|
+
type: f,
|
|
489
|
+
mimetype: H(t, e[0]),
|
|
490
|
+
...m
|
|
481
491
|
};
|
|
482
|
-
let s = e.flatMap((e) => (e.isUnion() ? e.types : [e]).map((e) =>
|
|
483
|
-
if (e.length === 1 &&
|
|
492
|
+
let s = e.flatMap((e) => (e.isUnion() ? e.types : [e]).map((e) => N(t, n, e, i, a, o, void 0, c, l)));
|
|
493
|
+
if (e.length === 1 && K(e[0])) return {
|
|
484
494
|
input: "list-select",
|
|
485
|
-
type:
|
|
495
|
+
type: f,
|
|
486
496
|
items: s,
|
|
487
|
-
...
|
|
497
|
+
...m
|
|
488
498
|
};
|
|
489
499
|
if (e.length === 1) {
|
|
490
500
|
let t = e[0];
|
|
491
|
-
if (
|
|
501
|
+
if (U(t)) return {
|
|
492
502
|
input: "list-boolean",
|
|
493
|
-
type:
|
|
503
|
+
type: f,
|
|
494
504
|
items: s,
|
|
495
|
-
...
|
|
505
|
+
...m
|
|
496
506
|
};
|
|
497
|
-
if (
|
|
507
|
+
if (W(t)) return {
|
|
498
508
|
input: "list-number",
|
|
499
|
-
type:
|
|
509
|
+
type: f,
|
|
500
510
|
items: s,
|
|
501
|
-
...
|
|
511
|
+
...m
|
|
502
512
|
};
|
|
503
|
-
if (
|
|
513
|
+
if (G(t)) return {
|
|
504
514
|
input: "list-text",
|
|
505
|
-
type:
|
|
515
|
+
type: f,
|
|
506
516
|
items: s,
|
|
507
|
-
...
|
|
517
|
+
...m
|
|
508
518
|
};
|
|
509
|
-
if (
|
|
519
|
+
if (q(t)) return {
|
|
510
520
|
input: "list-sub-flow",
|
|
511
|
-
type:
|
|
521
|
+
type: f,
|
|
512
522
|
items: s,
|
|
513
|
-
...
|
|
523
|
+
...m
|
|
514
524
|
};
|
|
515
525
|
}
|
|
516
526
|
return {
|
|
517
527
|
input: "list",
|
|
518
|
-
type:
|
|
528
|
+
type: f,
|
|
519
529
|
items: s,
|
|
520
|
-
...
|
|
530
|
+
...m
|
|
521
531
|
};
|
|
522
532
|
}
|
|
523
533
|
if ((r.flags & e.TypeFlags.Object) !== 0) {
|
|
524
|
-
if (c.has(r) || c.size >=
|
|
534
|
+
if (c.has(r) || c.size >= M && w(r, t, l)) return {
|
|
525
535
|
input: "data",
|
|
526
|
-
type:
|
|
527
|
-
...
|
|
536
|
+
type: f,
|
|
537
|
+
...m
|
|
528
538
|
};
|
|
529
539
|
c.add(r);
|
|
530
540
|
let s = {}, d = [];
|
|
531
|
-
for (let
|
|
532
|
-
let r =
|
|
541
|
+
for (let f of t.getPropertiesOfType(r)) {
|
|
542
|
+
let r = f.valueDeclaration ?? f.declarations?.[0];
|
|
533
543
|
if (!r) continue;
|
|
534
|
-
let
|
|
535
|
-
s[
|
|
544
|
+
let p = t.getTypeOfSymbolAtLocation(f, r), m = (f.flags & e.SymbolFlags.Optional) !== 0 || p.isUnion() && p.types.some((t) => (t.flags & (e.TypeFlags.Undefined | e.TypeFlags.Null)) !== 0), h = p.isUnion() ? p.types.filter((t) => (t.flags & (e.TypeFlags.Undefined | e.TypeFlags.Null)) === 0) : [p], g = u ? ye(t, u, f.name) : void 0, _ = h.map((e) => N(t, n, e, i, a, o, void 0, c, l, g));
|
|
545
|
+
s[f.name] = _.length === 1 ? _[0] : _, m || d.push(f.name);
|
|
536
546
|
}
|
|
537
547
|
return c.delete(r), {
|
|
538
548
|
input: "data",
|
|
539
|
-
type:
|
|
549
|
+
type: f,
|
|
540
550
|
properties: s,
|
|
541
551
|
required: d,
|
|
542
|
-
...
|
|
552
|
+
...m
|
|
543
553
|
};
|
|
544
554
|
}
|
|
545
555
|
return {
|
|
546
556
|
input: "generic",
|
|
547
|
-
type:
|
|
548
|
-
...
|
|
557
|
+
type: f,
|
|
558
|
+
...m
|
|
549
559
|
};
|
|
550
|
-
},
|
|
560
|
+
}, P = /* @__PURE__ */ new Set([
|
|
551
561
|
"list",
|
|
552
562
|
"list-select",
|
|
553
563
|
"list-boolean",
|
|
554
564
|
"list-number",
|
|
555
565
|
"list-text",
|
|
556
566
|
"list-sub-flow"
|
|
557
|
-
]),
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
567
|
+
]), F = /* @__PURE__ */ new Set([
|
|
568
|
+
"list-select",
|
|
569
|
+
"list-boolean",
|
|
570
|
+
"list-number",
|
|
571
|
+
"list-text",
|
|
572
|
+
"list-sub-flow",
|
|
573
|
+
"list-file"
|
|
574
|
+
]), I = (e) => {
|
|
575
|
+
let t = e, n = e.items;
|
|
576
|
+
n && (t = {
|
|
577
|
+
...t,
|
|
578
|
+
items: n.map(I)
|
|
579
|
+
});
|
|
580
|
+
let r = e.properties;
|
|
581
|
+
if (r) {
|
|
582
|
+
let e = {};
|
|
583
|
+
for (let [t, n] of Object.entries(r)) e[t] = Array.isArray(n) ? n.map(I) : I(n);
|
|
584
|
+
t = {
|
|
585
|
+
...t,
|
|
586
|
+
properties: e
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
if (F.has(t.input)) {
|
|
590
|
+
let { mimetype: e, ...n } = t;
|
|
591
|
+
t = {
|
|
592
|
+
...n,
|
|
593
|
+
input: "list"
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (t.suggestions && t.suggestions.length === 0) {
|
|
597
|
+
let { suggestions: e, ...n } = t;
|
|
598
|
+
t = n;
|
|
599
|
+
}
|
|
600
|
+
return t;
|
|
601
|
+
}, L = (e, t = void 0, n = !0) => {
|
|
602
|
+
let r = _e(e), i = r.items;
|
|
603
|
+
i && (r = {
|
|
604
|
+
...r,
|
|
605
|
+
items: i.map((e) => L(e, t))
|
|
606
|
+
});
|
|
607
|
+
let a = r.properties;
|
|
608
|
+
if (a) {
|
|
609
|
+
let e = {};
|
|
610
|
+
for (let [n, r] of Object.entries(a)) e[n] = Array.isArray(r) ? r.map((e) => L(e, t)) : L(r, t);
|
|
611
|
+
r = {
|
|
612
|
+
...r,
|
|
613
|
+
properties: e
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
if (n) {
|
|
617
|
+
if (t && t.length > 0) r = {
|
|
618
|
+
...r,
|
|
619
|
+
suggestions: t
|
|
620
|
+
};
|
|
621
|
+
else if (r.suggestions) {
|
|
622
|
+
let { suggestions: e, ...t } = r;
|
|
623
|
+
r = t;
|
|
565
624
|
}
|
|
625
|
+
}
|
|
626
|
+
return r;
|
|
627
|
+
}, R = (e, t, n = !1, r = void 0, i = !0) => {
|
|
628
|
+
if (!e || e.input === "generic") return ge(L(t, r, !i), n);
|
|
629
|
+
let a = he(e.suggestions, t.suggestions);
|
|
630
|
+
if (e.input === "data") {
|
|
631
|
+
let n = e.properties ?? {}, i = t.input === "data" ? t.properties ?? {} : {}, o = {}, s = /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(i)]);
|
|
632
|
+
for (let e of s) o[e] = z(n[e], i[e], r);
|
|
566
633
|
return {
|
|
567
634
|
...e,
|
|
568
|
-
properties:
|
|
569
|
-
...
|
|
635
|
+
properties: o,
|
|
636
|
+
...a ? { suggestions: a } : {}
|
|
570
637
|
};
|
|
571
638
|
}
|
|
572
|
-
if (
|
|
573
|
-
let n = e.items ?? [], i = t.input
|
|
639
|
+
if (P.has(e.input)) {
|
|
640
|
+
let n = e.items ?? [], i = P.has(t.input) ? t.items ?? [] : [], o = n.length > 0 && n.every((e) => e.input === "generic") && i.length > 0 ? i.map((e) => L(e, r)) : n.length === i.length && n.length > 0 ? n.map((e, t) => R(e, i[t], !1, r, !1)) : n;
|
|
574
641
|
return {
|
|
575
642
|
...e,
|
|
576
|
-
items:
|
|
577
|
-
...
|
|
643
|
+
items: o,
|
|
644
|
+
...a ? { suggestions: a } : {}
|
|
578
645
|
};
|
|
579
646
|
}
|
|
580
|
-
return {
|
|
647
|
+
return j(e.input) ? {
|
|
581
648
|
...e,
|
|
582
|
-
...
|
|
649
|
+
...t.type === void 0 ? {} : { type: t.type },
|
|
650
|
+
...a ? { suggestions: a } : {}
|
|
651
|
+
} : {
|
|
652
|
+
...e,
|
|
653
|
+
...a ? { suggestions: a } : {}
|
|
583
654
|
};
|
|
584
|
-
},
|
|
655
|
+
}, z = (e, t, n = void 0) => e && !Array.isArray(e) && t && !Array.isArray(t) ? R(e, t, !1, n, !1) : e === void 0 && t !== void 0 ? Array.isArray(t) ? t.map((e) => L(e, n)) : L(t, n) : e ?? t, he = (e, t) => {
|
|
585
656
|
let n = [...e ?? [], ...t ?? []];
|
|
586
657
|
if (n.length === 0) return;
|
|
587
658
|
let r = /* @__PURE__ */ new Set(), i = [];
|
|
@@ -590,13 +661,13 @@ var _ = (t) => {
|
|
|
590
661
|
r.has(t) || (r.add(t), i.push(e));
|
|
591
662
|
}
|
|
592
663
|
return i;
|
|
593
|
-
},
|
|
664
|
+
}, ge = (e, t) => !t || e.input !== "generic" ? e : {
|
|
594
665
|
input: "data",
|
|
595
666
|
...e.type ? { type: e.type } : {},
|
|
596
667
|
properties: {},
|
|
597
668
|
required: [],
|
|
598
669
|
...e.suggestions ? { suggestions: e.suggestions } : {}
|
|
599
|
-
},
|
|
670
|
+
}, _e = (e) => {
|
|
600
671
|
if (e.input !== "select") return e;
|
|
601
672
|
let t = e.suggestions ?? [], n = /* @__PURE__ */ new Set();
|
|
602
673
|
for (let e of t) {
|
|
@@ -613,11 +684,20 @@ var _ = (t) => {
|
|
|
613
684
|
...t.length > 0 ? { suggestions: t } : {}
|
|
614
685
|
};
|
|
615
686
|
};
|
|
616
|
-
function
|
|
687
|
+
function B(e) {
|
|
617
688
|
let t = e.aliasSymbol?.getName();
|
|
618
|
-
return
|
|
689
|
+
return A(t) ? k[t] : void 0;
|
|
690
|
+
}
|
|
691
|
+
function ve(t, n) {
|
|
692
|
+
if ((n.flags & e.TypeFlags.TypeParameter) === 0) return;
|
|
693
|
+
let r = n.symbol?.declarations?.[0];
|
|
694
|
+
if (r && e.isTypeParameterDeclaration(r) && r.constraint) return B(t.getTypeFromTypeNode(r.constraint));
|
|
695
|
+
}
|
|
696
|
+
function ye(e, t, n) {
|
|
697
|
+
let r = e.getPropertyOfType(t, n), i = r?.valueDeclaration ?? r?.declarations?.[0];
|
|
698
|
+
return i ? e.getTypeOfSymbolAtLocation(r, i) : void 0;
|
|
619
699
|
}
|
|
620
|
-
function
|
|
700
|
+
function V(t, n) {
|
|
621
701
|
if (n.aliasSymbol?.getName() !== "FILE" || (n.flags & e.TypeFlags.Object) === 0) return !1;
|
|
622
702
|
let r = t.getPropertiesOfType(n);
|
|
623
703
|
if (r.length !== 4) return !1;
|
|
@@ -628,7 +708,7 @@ function H(t, n) {
|
|
|
628
708
|
let s = t.getTypeOfSymbolAtLocation(a, o);
|
|
629
709
|
return s.isStringLiteral() && s.value === "base64";
|
|
630
710
|
}
|
|
631
|
-
function
|
|
711
|
+
function be(t, n) {
|
|
632
712
|
if (n.aliasSymbol?.getName() !== "COLOR" || (n.flags & e.TypeFlags.Object) === 0) return !1;
|
|
633
713
|
let r = new Map(t.getPropertiesOfType(n).map((e) => [e.name, e]));
|
|
634
714
|
return [
|
|
@@ -639,10 +719,10 @@ function fe(t, n) {
|
|
|
639
719
|
let n = r.get(e);
|
|
640
720
|
if (!n) return !1;
|
|
641
721
|
let i = n.valueDeclaration ?? n.declarations?.[0];
|
|
642
|
-
return i ?
|
|
722
|
+
return i ? W(t.getTypeOfSymbolAtLocation(n, i)) : !1;
|
|
643
723
|
});
|
|
644
724
|
}
|
|
645
|
-
function
|
|
725
|
+
function H(e, t) {
|
|
646
726
|
let n = /^(\*|[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*)\/(\*|[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*)$/, r = e.getPropertiesOfType(t).find((e) => e.name === "contentType");
|
|
647
727
|
if (!r) return "*/*";
|
|
648
728
|
let i = r.valueDeclaration ?? r.declarations?.[0];
|
|
@@ -650,7 +730,7 @@ function U(e, t) {
|
|
|
650
730
|
let a = e.getTypeOfSymbolAtLocation(r, i);
|
|
651
731
|
return a.isStringLiteral() && n.test(a.value) ? a.value : "*/*";
|
|
652
732
|
}
|
|
653
|
-
function
|
|
733
|
+
function U(t) {
|
|
654
734
|
if ((t.flags & e.TypeFlags.Boolean) !== 0 || (t.flags & e.TypeFlags.BooleanLiteral) !== 0) return !0;
|
|
655
735
|
if (t.isUnion()) {
|
|
656
736
|
let n = t.types.filter((t) => (t.flags & (e.TypeFlags.Undefined | e.TypeFlags.Null)) === 0);
|
|
@@ -658,46 +738,46 @@ function W(t) {
|
|
|
658
738
|
}
|
|
659
739
|
return !1;
|
|
660
740
|
}
|
|
661
|
-
function
|
|
741
|
+
function W(t) {
|
|
662
742
|
return (t.flags & e.TypeFlags.Number) !== 0 || (t.flags & e.TypeFlags.NumberLiteral) !== 0;
|
|
663
743
|
}
|
|
664
|
-
function
|
|
744
|
+
function G(t) {
|
|
665
745
|
return (t.flags & e.TypeFlags.String) !== 0 || (t.flags & e.TypeFlags.StringLiteral) !== 0;
|
|
666
746
|
}
|
|
667
|
-
function
|
|
668
|
-
return
|
|
747
|
+
function xe(e) {
|
|
748
|
+
return G(e) || W(e) || U(e);
|
|
669
749
|
}
|
|
670
|
-
function
|
|
750
|
+
function Se(t) {
|
|
671
751
|
return (t.flags & e.TypeFlags.StringLiteral) !== 0 || (t.flags & e.TypeFlags.NumberLiteral) !== 0;
|
|
672
752
|
}
|
|
673
|
-
function
|
|
674
|
-
return
|
|
753
|
+
function K(e) {
|
|
754
|
+
return U(e) ? !1 : Ce(e) || Se(e);
|
|
675
755
|
}
|
|
676
|
-
function
|
|
756
|
+
function Ce(t) {
|
|
677
757
|
if (!t.isUnion()) return !1;
|
|
678
758
|
let n = t.types.filter((t) => (t.flags & (e.TypeFlags.Undefined | e.TypeFlags.Null)) === 0);
|
|
679
|
-
return n.length > 0 && n.every(
|
|
759
|
+
return n.length > 0 && n.every(xe);
|
|
680
760
|
}
|
|
681
|
-
function
|
|
761
|
+
function we(e, t) {
|
|
682
762
|
return e.isArrayType(t) || e.isTupleType(t);
|
|
683
763
|
}
|
|
684
|
-
function
|
|
764
|
+
function q(e) {
|
|
685
765
|
return e.getCallSignatures().length > 0;
|
|
686
766
|
}
|
|
687
767
|
//#endregion
|
|
688
768
|
//#region src/utils.ts
|
|
689
|
-
var
|
|
690
|
-
function
|
|
769
|
+
var Te = "\n interface Array<T> { \n [n: number]: T; \n length: number; \n }\n interface String { readonly length: number; }\n interface Number { }\n interface Boolean { }\n interface Object { }\n interface Function { }\n interface CallableFunction extends Function {}\n interface NewableFunction extends Function {}\n interface IArguments { }\n interface RegExp { }\n \n declare namespace Utils {\n type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;\n }\n\n import ReturnType = Utils.ReturnType;\n";
|
|
770
|
+
function J(t, n) {
|
|
691
771
|
let r = /* @__PURE__ */ new Map();
|
|
692
|
-
return r.set(t, n), r.set("lib.codezero.d.ts",
|
|
772
|
+
return r.set(t, n), r.set("lib.codezero.d.ts", Te), a(u(r), [t, "lib.codezero.d.ts"], e, Ee);
|
|
693
773
|
}
|
|
694
|
-
var
|
|
774
|
+
var Ee = {
|
|
695
775
|
target: e.ScriptTarget.Latest,
|
|
696
776
|
lib: ["lib.codezero.d.ts"],
|
|
697
777
|
noEmit: !0,
|
|
698
778
|
strictNullChecks: !0
|
|
699
779
|
};
|
|
700
|
-
function
|
|
780
|
+
function De(e) {
|
|
701
781
|
let t = [], n = 0, r = null, i = "";
|
|
702
782
|
for (let a of e) {
|
|
703
783
|
if (r) a === r && (r = null);
|
|
@@ -712,14 +792,40 @@ function ye(e) {
|
|
|
712
792
|
}
|
|
713
793
|
return t.push(i), t.map((e) => (e.trim().split(/\s+/).find((e) => e !== "const" && e !== "in" && e !== "out") ?? "").match(/^[A-Za-z_$][A-Za-z0-9_$]*/)?.[0] ?? "").filter((e) => e.length > 0);
|
|
714
794
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
795
|
+
var Oe = /* @__PURE__ */ new Set([
|
|
796
|
+
"number",
|
|
797
|
+
"string",
|
|
798
|
+
"boolean"
|
|
799
|
+
]);
|
|
800
|
+
function Y(e, t = "any", n = !0) {
|
|
801
|
+
let r = Array.from(new Set(e?.flatMap((e) => e.genericKeys || []).flatMap(De))).map((e) => `type ${e} = ${t};`).join("\n"), i = e?.map((e) => {
|
|
802
|
+
let t = A(e.identifier), n = (e.genericKeys?.length ?? 0) > 0 ? t ? `<${e.genericKeys.map((e) => e.includes("=") ? e : `${e} = any`).join(", ")}>` : `<${e.genericKeys?.join(",")}>` : "", r = e.type?.trim() ?? "", i = t ? Oe.has(r) ? `${e.type} & {}` : "{}" : e.type;
|
|
803
|
+
return `type ${e.identifier}${n} = ${i};`;
|
|
719
804
|
}).join("\n"), a = e?.filter((e) => (e.genericKeys?.length ?? 0) > 0).map((e) => `declare const __widen_${e.identifier}: ${e.identifier}<${e.genericKeys.map(() => "any").join(", ")}>;`).join("\n") ?? "";
|
|
720
805
|
return `${n ? r : ""}\n${i}\n${a}`;
|
|
721
806
|
}
|
|
722
|
-
var
|
|
807
|
+
var ke = /^[A-Za-z0-9_$<>\[\]{}(),.:?|&+\-'"\s]+$/, Ae = (e) => {
|
|
808
|
+
if (!ke.test(e)) return !1;
|
|
809
|
+
let t = {
|
|
810
|
+
"<": ">",
|
|
811
|
+
"[": "]",
|
|
812
|
+
"{": "}",
|
|
813
|
+
"(": ")"
|
|
814
|
+
}, n = [], r = null;
|
|
815
|
+
for (let i of e) {
|
|
816
|
+
if (r) {
|
|
817
|
+
i === r && (r = null);
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
if (i === "'" || i === "\"") r = i;
|
|
821
|
+
else if (t[i]) n.push(t[i]);
|
|
822
|
+
else if ((i === ">" || i === "]" || i === "}" || i === ")") && n.pop() !== i) return !1;
|
|
823
|
+
}
|
|
824
|
+
return r === null && n.length === 0;
|
|
825
|
+
}, X = (e, t) => {
|
|
826
|
+
let n = t?.trim();
|
|
827
|
+
return !n || !Ae(n) ? e : `(${e}) as unknown as ${n}`;
|
|
828
|
+
}, Z = (e) => e?.replace(/[^a-zA-Z0-9]/g, "_"), Q = (e) => e.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), je = (e, t) => {
|
|
723
829
|
let n = e.match(/^\$\{([^}]+)\}$/);
|
|
724
830
|
if (n && t.has(n[1])) return t.get(n[1]);
|
|
725
831
|
let r = /\$\{([^}]+)\}/g, i = !1;
|
|
@@ -734,8 +840,8 @@ var Z = (e) => e?.replace(/[^a-zA-Z0-9]/g, "_"), Q = (e) => e.replace(/\\/g, "\\
|
|
|
734
840
|
a += Q(e.slice(o, s)), a += t.has(i) ? "${" + t.get(i) + "}" : Q(r), o = s + r.length;
|
|
735
841
|
}
|
|
736
842
|
return a += Q(e.slice(o)), "`" + a + "`";
|
|
737
|
-
}, $ = (e, t) => typeof e == "string" ?
|
|
738
|
-
function
|
|
843
|
+
}, $ = (e, t) => typeof e == "string" ? je(e, t) : Array.isArray(e) ? `[${e.map((e) => $(e, t)).join(", ")}]` : typeof e == "object" && e ? `{${Object.entries(e).map(([e, n]) => `${h(e)}: ${$(n, t)}`).join(", ")}}` : h(e) ?? "undefined";
|
|
844
|
+
function Me(e, t, n, r = !1, i = !0) {
|
|
739
845
|
let a = e?.nodes?.nodes || [], o = new Map(t?.map((e) => [e.identifier, e])), s = /* @__PURE__ */ new Set(), c = (t) => {
|
|
740
846
|
let n = typeof t.inputIndex == "number" ? `p_${Z(t.nodeFunctionId ?? "undefined")}_${t.parameterIndex}[${t.inputIndex}]` : t.nodeFunctionId ? `node_${Z(t.nodeFunctionId)}` : `flow_${Z(e?.id ?? "undefined")}`;
|
|
741
847
|
return t.referencePath?.forEach((e) => {
|
|
@@ -759,12 +865,18 @@ function xe(e, t, n, r = !1, i = !0) {
|
|
|
759
865
|
if (!n || !n.functionDefinition) return "";
|
|
760
866
|
if (e?.includes("NodeFunction") && s.add(e), !o.get(n.functionDefinition.identifier)) return `${t}// Error: Function ${n.functionDefinition.identifier} not found\n`;
|
|
761
867
|
let i = (n.parameters?.nodes || []).map((n, i) => {
|
|
762
|
-
let a = n.value
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
868
|
+
let a = n.value, o = r ? `/* @pos ${e} ${i} */ ${X("{}", n.cast)}` : `/* @pos ${e} ${i} */ undefined`;
|
|
869
|
+
if (!a) return o;
|
|
870
|
+
if (a.__typename === "ReferenceValue") return `/* @pos ${e} ${i} */ ${X(c(a), n.cast)}`;
|
|
871
|
+
if (a.__typename === "LiteralValue") {
|
|
872
|
+
let r = u(a.value, a.references, {
|
|
873
|
+
id: e,
|
|
874
|
+
index: i,
|
|
875
|
+
indent: t
|
|
876
|
+
});
|
|
877
|
+
return r === void 0 ? `/* @pos ${e} ${i} */ undefined` : `/* @pos ${e} ${i} */ ${X(r, n.cast)}`;
|
|
878
|
+
}
|
|
879
|
+
return a.__typename === "SubFlowValue" ? `/* @pos ${e} ${i} */ ${l(a, e, i, t)}` : o;
|
|
768
880
|
}), f = `node_${Z(n.id)}`, p = `fn_${n?.functionDefinition?.identifier?.replace(/::/g, "_")}`;
|
|
769
881
|
i.includes("undefined");
|
|
770
882
|
let m = `${t}`;
|
|
@@ -775,7 +887,7 @@ function xe(e, t, n, r = !1, i = !0) {
|
|
|
775
887
|
} else {
|
|
776
888
|
${d(n.parameters?.nodes?.[2]?.value?.startingNodeId || (n.parameters?.nodes?.[2]?.value)?.functionDefinition?.identifier, t + " ")}
|
|
777
889
|
}`) : m += `const ${f} = /* @pos ${e} null */ ${p}(${i.join(", ")}) ;\n`, n.nextNodeId && (m += d(n.nextNodeId, t)), m;
|
|
778
|
-
}, f =
|
|
890
|
+
}, f = Y(n), p = `declare function flow${e?.signature ?? "(): void"}`, m = t?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join("\n"), g = new Set(a.map((e) => e?.nextNodeId).filter((e) => !!e)), _ = /* @__PURE__ */ new Set();
|
|
779
891
|
return a.forEach((e) => e?.parameters?.nodes?.forEach((e) => {
|
|
780
892
|
e?.value?.__typename === "SubFlowValue" && (e.value.startingNodeId || e.value.functionDefinition?.id) && _.add(e.value.startingNodeId || e.value.functionDefinition?.id);
|
|
781
893
|
})), `
|
|
@@ -783,10 +895,13 @@ function xe(e, t, n, r = !1, i = !0) {
|
|
|
783
895
|
${p}\n
|
|
784
896
|
${m}\n
|
|
785
897
|
(() =>
|
|
786
|
-
${e ? `const flow_${Z(e.id ?? "")} = /* @pos null null */ flow(${e.settings?.nodes?.map((e, t) =>
|
|
898
|
+
${e ? `const flow_${Z(e.id ?? "")} = /* @pos null null */ flow(${e.settings?.nodes?.map((e, t) => {
|
|
899
|
+
let n = e?.value !== null && e?.value !== void 0 ? h(e.value) : void 0;
|
|
900
|
+
return `/* @pos null ${t} */ ${n === void 0 ? "undefined" : X(n, e?.cast)}`;
|
|
901
|
+
}).join(", ") ?? ""});` : ""}
|
|
787
902
|
${a.filter((e) => e?.id && !g.has(e.id) && !_.has(e.id)).map((e) => d(e.id)).join("\n")}
|
|
788
903
|
)();
|
|
789
904
|
`;
|
|
790
905
|
}
|
|
791
906
|
//#endregion
|
|
792
|
-
export {
|
|
907
|
+
export { k as a, A as c, R as d, I as f, Z as i, j as l, Me as n, L as o, h as p, Y as r, N as s, J as t, q as u };
|