@flowgram.ai/variable-core 0.2.0 → 0.2.1

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/esm/index.js CHANGED
@@ -552,106 +552,6 @@ var ASTNode = class _ASTNode {
552
552
  }
553
553
  };
554
554
 
555
- // src/ast/factory.ts
556
- import { get } from "lodash";
557
- var ASTFactory;
558
- ((ASTFactory2) => {
559
- ASTFactory2.createString = () => ({ kind: "String" /* String */ });
560
- ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
561
- ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
562
- ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
563
- ASTFactory2.createObject = (json) => ({
564
- kind: "Object" /* Object */,
565
- ...json
566
- });
567
- ASTFactory2.createArray = (json) => ({
568
- kind: "Array" /* Array */,
569
- ...json
570
- });
571
- ASTFactory2.createMap = (json) => ({
572
- kind: "Map" /* Map */,
573
- ...json
574
- });
575
- ASTFactory2.createUnion = (json) => ({
576
- kind: "Union" /* Union */,
577
- ...json
578
- });
579
- ASTFactory2.createCustomType = (json) => ({
580
- kind: "CustomType" /* CustomType */,
581
- ...json
582
- });
583
- ASTFactory2.createVariableDeclaration = (json) => ({
584
- kind: "VariableDeclaration" /* VariableDeclaration */,
585
- ...json
586
- });
587
- ASTFactory2.createProperty = (json) => ({
588
- kind: "Property" /* Property */,
589
- ...json
590
- });
591
- ASTFactory2.createVariableDeclarationList = (json) => ({
592
- kind: "VariableDeclarationList" /* VariableDeclarationList */,
593
- ...json
594
- });
595
- ASTFactory2.createEnumerateExpression = (json) => ({
596
- kind: "EnumerateExpression" /* EnumerateExpression */,
597
- ...json
598
- });
599
- ASTFactory2.createKeyPathExpression = (json) => ({
600
- kind: "KeyPathExpression" /* KeyPathExpression */,
601
- ...json
602
- });
603
- ASTFactory2.createWrapArrayExpression = (json) => ({
604
- kind: "WrapArrayExpression" /* WrapArrayExpression */,
605
- ...json
606
- });
607
- function createTypeASTFromSchema(jsonSchema) {
608
- const { type, extra } = jsonSchema || {};
609
- const { weak = false } = extra || {};
610
- if (!type) {
611
- return void 0;
612
- }
613
- switch (type) {
614
- case "object":
615
- if (weak) {
616
- return { kind: "Object" /* Object */, weak: true };
617
- }
618
- return ASTFactory2.createObject({
619
- properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
620
- key,
621
- type: createTypeASTFromSchema(_property),
622
- meta: { description: _property.description }
623
- }))
624
- });
625
- case "array":
626
- if (weak) {
627
- return { kind: "Array" /* Array */, weak: true };
628
- }
629
- return ASTFactory2.createArray({
630
- items: createTypeASTFromSchema(jsonSchema.items)
631
- });
632
- case "map":
633
- if (weak) {
634
- return { kind: "Map" /* Map */, weak: true };
635
- }
636
- return ASTFactory2.createMap({
637
- valueType: createTypeASTFromSchema(jsonSchema.additionalProperties)
638
- });
639
- case "string":
640
- return ASTFactory2.createString();
641
- case "number":
642
- return ASTFactory2.createNumber();
643
- case "boolean":
644
- return ASTFactory2.createBoolean();
645
- case "integer":
646
- return ASTFactory2.createInteger();
647
- default:
648
- return ASTFactory2.createCustomType({ typeName: type });
649
- }
650
- }
651
- ASTFactory2.createTypeASTFromSchema = createTypeASTFromSchema;
652
- ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
653
- })(ASTFactory || (ASTFactory = {}));
654
-
655
555
  // src/ast/type/base-type.ts
656
556
  var BaseType = class extends ASTNode {
657
557
  constructor() {
@@ -687,28 +587,6 @@ var BaseType = class extends ASTNode {
687
587
  kind: this.kind
688
588
  };
689
589
  }
690
- /**
691
- * Get Standard JSON Schema for current base type
692
- * @returns
693
- */
694
- toJSONSchema() {
695
- return {
696
- type: this.kind.toLowerCase()
697
- };
698
- }
699
- /**
700
- * Check if the type is equal with json schema
701
- */
702
- isEqualWithJSONSchema(schema) {
703
- if (Array.isArray(schema)) {
704
- return this.isTypeEqual(
705
- ASTFactory.createUnion({
706
- types: schema.map((_schema) => ASTFactory.createTypeASTFromSchema(_schema)).filter(Boolean)
707
- })
708
- );
709
- }
710
- return this.isTypeEqual(ASTFactory.createTypeASTFromSchema(schema));
711
- }
712
590
  };
713
591
 
714
592
  // src/ast/type/array.ts
@@ -768,11 +646,6 @@ var StringType = class extends BaseType {
768
646
  }
769
647
  fromJSON() {
770
648
  }
771
- toJSONSchema() {
772
- return {
773
- type: "string"
774
- };
775
- }
776
649
  };
777
650
  StringType.kind = "String" /* String */;
778
651
 
@@ -784,11 +657,6 @@ var IntegerType = class extends BaseType {
784
657
  }
785
658
  fromJSON() {
786
659
  }
787
- toJSONSchema() {
788
- return {
789
- type: "integer"
790
- };
791
- }
792
660
  };
793
661
  IntegerType.kind = "Integer" /* Integer */;
794
662
 
@@ -796,11 +664,6 @@ IntegerType.kind = "Integer" /* Integer */;
796
664
  var BooleanType = class extends BaseType {
797
665
  fromJSON() {
798
666
  }
799
- toJSONSchema() {
800
- return {
801
- type: "boolean"
802
- };
803
- }
804
667
  };
805
668
  BooleanType.kind = "Boolean" /* Boolean */;
806
669
 
@@ -808,11 +671,6 @@ BooleanType.kind = "Boolean" /* Boolean */;
808
671
  var NumberType = class extends BaseType {
809
672
  fromJSON() {
810
673
  }
811
- toJSONSchema() {
812
- return {
813
- type: "number"
814
- };
815
- }
816
674
  };
817
675
  NumberType.kind = "Number" /* Number */;
818
676
 
@@ -859,12 +717,6 @@ var MapType = class extends BaseType {
859
717
  valueType: this.valueType?.toJSON()
860
718
  };
861
719
  }
862
- toJSONSchema() {
863
- return {
864
- type: "map",
865
- additionalProperties: this.valueType?.toJSONSchema()
866
- };
867
- }
868
720
  };
869
721
  // public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType | ASTNodeFlags.EnumerateType;
870
722
  MapType.kind = "Map" /* Map */;
@@ -956,15 +808,6 @@ var ObjectType = class extends BaseType {
956
808
  return sourceProperty && sourceProperty.key === targetProperty.key && sourceProperty.type?.isTypeEqual(targetProperty?.type);
957
809
  });
958
810
  }
959
- toJSONSchema() {
960
- return {
961
- type: "object",
962
- properties: this.properties.reduce((acc, _property) => {
963
- acc[_property.key] = _property.type?.toJSONSchema();
964
- return acc;
965
- }, {})
966
- };
967
- }
968
811
  };
969
812
  ObjectType.kind = "Object" /* Object */;
970
813
 
@@ -988,11 +831,6 @@ var CustomType = class extends BaseType {
988
831
  }
989
832
  return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;
990
833
  }
991
- toJSONSchema() {
992
- return {
993
- type: this._typeName
994
- };
995
- }
996
834
  };
997
835
  CustomType.kind = "CustomType" /* CustomType */;
998
836
 
@@ -1662,6 +1500,60 @@ ASTRegisters = __decorateClass([
1662
1500
  injectable2()
1663
1501
  ], ASTRegisters);
1664
1502
 
1503
+ // src/ast/factory.ts
1504
+ var ASTFactory;
1505
+ ((ASTFactory2) => {
1506
+ ASTFactory2.createString = () => ({ kind: "String" /* String */ });
1507
+ ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
1508
+ ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
1509
+ ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
1510
+ ASTFactory2.createObject = (json) => ({
1511
+ kind: "Object" /* Object */,
1512
+ ...json
1513
+ });
1514
+ ASTFactory2.createArray = (json) => ({
1515
+ kind: "Array" /* Array */,
1516
+ ...json
1517
+ });
1518
+ ASTFactory2.createMap = (json) => ({
1519
+ kind: "Map" /* Map */,
1520
+ ...json
1521
+ });
1522
+ ASTFactory2.createUnion = (json) => ({
1523
+ kind: "Union" /* Union */,
1524
+ ...json
1525
+ });
1526
+ ASTFactory2.createCustomType = (json) => ({
1527
+ kind: "CustomType" /* CustomType */,
1528
+ ...json
1529
+ });
1530
+ ASTFactory2.createVariableDeclaration = (json) => ({
1531
+ kind: "VariableDeclaration" /* VariableDeclaration */,
1532
+ ...json
1533
+ });
1534
+ ASTFactory2.createProperty = (json) => ({
1535
+ kind: "Property" /* Property */,
1536
+ ...json
1537
+ });
1538
+ ASTFactory2.createVariableDeclarationList = (json) => ({
1539
+ kind: "VariableDeclarationList" /* VariableDeclarationList */,
1540
+ ...json
1541
+ });
1542
+ ASTFactory2.createEnumerateExpression = (json) => ({
1543
+ kind: "EnumerateExpression" /* EnumerateExpression */,
1544
+ ...json
1545
+ });
1546
+ ASTFactory2.createKeyPathExpression = (json) => ({
1547
+ kind: "KeyPathExpression" /* KeyPathExpression */,
1548
+ ...json
1549
+ });
1550
+ ASTFactory2.createWrapArrayExpression = (json) => ({
1551
+ kind: "WrapArrayExpression" /* WrapArrayExpression */,
1552
+ ...json
1553
+ });
1554
+ ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
1555
+ })(ASTFactory || (ASTFactory = {}));
1556
+
1665
1557
  // src/scope/datas/scope-output-data.ts
1666
1558
  var ScopeOutputData = class {
1667
1559
  constructor(scope) {