@flowgram.ai/variable-core 0.1.30 → 0.2.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/esm/index.js +210 -77
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +81 -13
- package/dist/index.d.ts +81 -13
- package/dist/index.js +237 -104
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -43,7 +43,6 @@ __export(src_exports, {
|
|
|
43
43
|
CustomType: () => CustomType,
|
|
44
44
|
DataNode: () => DataNode,
|
|
45
45
|
EnumerateExpression: () => EnumerateExpression,
|
|
46
|
-
ExpressionList: () => ExpressionList,
|
|
47
46
|
IntegerType: () => IntegerType,
|
|
48
47
|
KeyPathExpression: () => KeyPathExpression,
|
|
49
48
|
KeyPathExpressionV2: () => KeyPathExpressionV2,
|
|
@@ -64,6 +63,7 @@ __export(src_exports, {
|
|
|
64
63
|
VariableEngine: () => VariableEngine,
|
|
65
64
|
VariableEngineProvider: () => VariableEngineProvider,
|
|
66
65
|
VariableFieldKeyRenameService: () => VariableFieldKeyRenameService,
|
|
66
|
+
WrapArrayExpression: () => WrapArrayExpression,
|
|
67
67
|
injectToAST: () => injectToAST,
|
|
68
68
|
isMatchAST: () => isMatchAST,
|
|
69
69
|
postConstructAST: () => postConstructAST,
|
|
@@ -75,11 +75,11 @@ __export(src_exports, {
|
|
|
75
75
|
module.exports = __toCommonJS(src_exports);
|
|
76
76
|
|
|
77
77
|
// src/variable-container-module.ts
|
|
78
|
-
var
|
|
78
|
+
var import_inversify8 = require("inversify");
|
|
79
79
|
|
|
80
80
|
// src/variable-engine.ts
|
|
81
81
|
var import_rxjs6 = require("rxjs");
|
|
82
|
-
var
|
|
82
|
+
var import_inversify6 = require("inversify");
|
|
83
83
|
var import_utils8 = require("@flowgram.ai/utils");
|
|
84
84
|
var import_utils9 = require("@flowgram.ai/utils");
|
|
85
85
|
|
|
@@ -281,7 +281,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
|
281
281
|
ASTKind2["VariableDeclarationList"] = "VariableDeclarationList";
|
|
282
282
|
ASTKind2["KeyPathExpression"] = "KeyPathExpression";
|
|
283
283
|
ASTKind2["EnumerateExpression"] = "EnumerateExpression";
|
|
284
|
-
ASTKind2["
|
|
284
|
+
ASTKind2["WrapArrayExpression"] = "WrapArrayExpression";
|
|
285
285
|
ASTKind2["ListNode"] = "ListNode";
|
|
286
286
|
ASTKind2["DataNode"] = "DataNode";
|
|
287
287
|
ASTKind2["MapNode"] = "MapNode";
|
|
@@ -289,8 +289,8 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
|
289
289
|
})(ASTKind || {});
|
|
290
290
|
|
|
291
291
|
// src/ast/ast-registers.ts
|
|
292
|
-
var
|
|
293
|
-
var
|
|
292
|
+
var import_lodash4 = require("lodash");
|
|
293
|
+
var import_inversify3 = require("inversify");
|
|
294
294
|
|
|
295
295
|
// src/ast/utils/inversify.ts
|
|
296
296
|
var injectToAST = (serviceIdentifier) => function(target, propertyKey) {
|
|
@@ -608,6 +608,106 @@ var ASTNode = class _ASTNode {
|
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
+
// src/ast/factory.ts
|
|
612
|
+
var import_lodash = require("lodash");
|
|
613
|
+
var ASTFactory;
|
|
614
|
+
((ASTFactory2) => {
|
|
615
|
+
ASTFactory2.createString = () => ({ kind: "String" /* String */ });
|
|
616
|
+
ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
|
|
617
|
+
ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
|
|
618
|
+
ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
|
|
619
|
+
ASTFactory2.createObject = (json) => ({
|
|
620
|
+
kind: "Object" /* Object */,
|
|
621
|
+
...json
|
|
622
|
+
});
|
|
623
|
+
ASTFactory2.createArray = (json) => ({
|
|
624
|
+
kind: "Array" /* Array */,
|
|
625
|
+
...json
|
|
626
|
+
});
|
|
627
|
+
ASTFactory2.createMap = (json) => ({
|
|
628
|
+
kind: "Map" /* Map */,
|
|
629
|
+
...json
|
|
630
|
+
});
|
|
631
|
+
ASTFactory2.createUnion = (json) => ({
|
|
632
|
+
kind: "Union" /* Union */,
|
|
633
|
+
...json
|
|
634
|
+
});
|
|
635
|
+
ASTFactory2.createCustomType = (json) => ({
|
|
636
|
+
kind: "CustomType" /* CustomType */,
|
|
637
|
+
...json
|
|
638
|
+
});
|
|
639
|
+
ASTFactory2.createVariableDeclaration = (json) => ({
|
|
640
|
+
kind: "VariableDeclaration" /* VariableDeclaration */,
|
|
641
|
+
...json
|
|
642
|
+
});
|
|
643
|
+
ASTFactory2.createProperty = (json) => ({
|
|
644
|
+
kind: "Property" /* Property */,
|
|
645
|
+
...json
|
|
646
|
+
});
|
|
647
|
+
ASTFactory2.createVariableDeclarationList = (json) => ({
|
|
648
|
+
kind: "VariableDeclarationList" /* VariableDeclarationList */,
|
|
649
|
+
...json
|
|
650
|
+
});
|
|
651
|
+
ASTFactory2.createEnumerateExpression = (json) => ({
|
|
652
|
+
kind: "EnumerateExpression" /* EnumerateExpression */,
|
|
653
|
+
...json
|
|
654
|
+
});
|
|
655
|
+
ASTFactory2.createKeyPathExpression = (json) => ({
|
|
656
|
+
kind: "KeyPathExpression" /* KeyPathExpression */,
|
|
657
|
+
...json
|
|
658
|
+
});
|
|
659
|
+
ASTFactory2.createWrapArrayExpression = (json) => ({
|
|
660
|
+
kind: "WrapArrayExpression" /* WrapArrayExpression */,
|
|
661
|
+
...json
|
|
662
|
+
});
|
|
663
|
+
function createTypeASTFromSchema(jsonSchema) {
|
|
664
|
+
const { type, extra } = jsonSchema || {};
|
|
665
|
+
const { weak = false } = extra || {};
|
|
666
|
+
if (!type) {
|
|
667
|
+
return void 0;
|
|
668
|
+
}
|
|
669
|
+
switch (type) {
|
|
670
|
+
case "object":
|
|
671
|
+
if (weak) {
|
|
672
|
+
return { kind: "Object" /* Object */, weak: true };
|
|
673
|
+
}
|
|
674
|
+
return ASTFactory2.createObject({
|
|
675
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
676
|
+
key,
|
|
677
|
+
type: createTypeASTFromSchema(_property),
|
|
678
|
+
meta: { description: _property.description }
|
|
679
|
+
}))
|
|
680
|
+
});
|
|
681
|
+
case "array":
|
|
682
|
+
if (weak) {
|
|
683
|
+
return { kind: "Array" /* Array */, weak: true };
|
|
684
|
+
}
|
|
685
|
+
return ASTFactory2.createArray({
|
|
686
|
+
items: createTypeASTFromSchema(jsonSchema.items)
|
|
687
|
+
});
|
|
688
|
+
case "map":
|
|
689
|
+
if (weak) {
|
|
690
|
+
return { kind: "Map" /* Map */, weak: true };
|
|
691
|
+
}
|
|
692
|
+
return ASTFactory2.createMap({
|
|
693
|
+
valueType: createTypeASTFromSchema(jsonSchema.additionalProperties)
|
|
694
|
+
});
|
|
695
|
+
case "string":
|
|
696
|
+
return ASTFactory2.createString();
|
|
697
|
+
case "number":
|
|
698
|
+
return ASTFactory2.createNumber();
|
|
699
|
+
case "boolean":
|
|
700
|
+
return ASTFactory2.createBoolean();
|
|
701
|
+
case "integer":
|
|
702
|
+
return ASTFactory2.createInteger();
|
|
703
|
+
default:
|
|
704
|
+
return ASTFactory2.createCustomType({ typeName: type });
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
ASTFactory2.createTypeASTFromSchema = createTypeASTFromSchema;
|
|
708
|
+
ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
|
|
709
|
+
})(ASTFactory || (ASTFactory = {}));
|
|
710
|
+
|
|
611
711
|
// src/ast/type/base-type.ts
|
|
612
712
|
var BaseType = class extends ASTNode {
|
|
613
713
|
constructor() {
|
|
@@ -615,7 +715,7 @@ var BaseType = class extends ASTNode {
|
|
|
615
715
|
this.flags = 8 /* BasicType */;
|
|
616
716
|
}
|
|
617
717
|
/**
|
|
618
|
-
*
|
|
718
|
+
* 类型是否一致
|
|
619
719
|
* @param targetTypeJSON
|
|
620
720
|
*/
|
|
621
721
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
@@ -634,11 +734,37 @@ var BaseType = class extends ASTNode {
|
|
|
634
734
|
getByKeyPath(keyPath = []) {
|
|
635
735
|
throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);
|
|
636
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Get AST JSON for current base type
|
|
739
|
+
* @returns
|
|
740
|
+
*/
|
|
637
741
|
toJSON() {
|
|
638
742
|
return {
|
|
639
743
|
kind: this.kind
|
|
640
744
|
};
|
|
641
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Get Standard JSON Schema for current base type
|
|
748
|
+
* @returns
|
|
749
|
+
*/
|
|
750
|
+
toJSONSchema() {
|
|
751
|
+
return {
|
|
752
|
+
type: this.kind.toLowerCase()
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Check if the type is equal with json schema
|
|
757
|
+
*/
|
|
758
|
+
isEqualWithJSONSchema(schema) {
|
|
759
|
+
if (Array.isArray(schema)) {
|
|
760
|
+
return this.isTypeEqual(
|
|
761
|
+
ASTFactory.createUnion({
|
|
762
|
+
types: schema.map((_schema) => ASTFactory.createTypeASTFromSchema(_schema)).filter(Boolean)
|
|
763
|
+
})
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
return this.isTypeEqual(ASTFactory.createTypeASTFromSchema(schema));
|
|
767
|
+
}
|
|
642
768
|
};
|
|
643
769
|
|
|
644
770
|
// src/ast/type/array.ts
|
|
@@ -698,6 +824,11 @@ var StringType = class extends BaseType {
|
|
|
698
824
|
}
|
|
699
825
|
fromJSON() {
|
|
700
826
|
}
|
|
827
|
+
toJSONSchema() {
|
|
828
|
+
return {
|
|
829
|
+
type: "string"
|
|
830
|
+
};
|
|
831
|
+
}
|
|
701
832
|
};
|
|
702
833
|
StringType.kind = "String" /* String */;
|
|
703
834
|
|
|
@@ -709,6 +840,11 @@ var IntegerType = class extends BaseType {
|
|
|
709
840
|
}
|
|
710
841
|
fromJSON() {
|
|
711
842
|
}
|
|
843
|
+
toJSONSchema() {
|
|
844
|
+
return {
|
|
845
|
+
type: "integer"
|
|
846
|
+
};
|
|
847
|
+
}
|
|
712
848
|
};
|
|
713
849
|
IntegerType.kind = "Integer" /* Integer */;
|
|
714
850
|
|
|
@@ -716,6 +852,11 @@ IntegerType.kind = "Integer" /* Integer */;
|
|
|
716
852
|
var BooleanType = class extends BaseType {
|
|
717
853
|
fromJSON() {
|
|
718
854
|
}
|
|
855
|
+
toJSONSchema() {
|
|
856
|
+
return {
|
|
857
|
+
type: "boolean"
|
|
858
|
+
};
|
|
859
|
+
}
|
|
719
860
|
};
|
|
720
861
|
BooleanType.kind = "Boolean" /* Boolean */;
|
|
721
862
|
|
|
@@ -723,6 +864,11 @@ BooleanType.kind = "Boolean" /* Boolean */;
|
|
|
723
864
|
var NumberType = class extends BaseType {
|
|
724
865
|
fromJSON() {
|
|
725
866
|
}
|
|
867
|
+
toJSONSchema() {
|
|
868
|
+
return {
|
|
869
|
+
type: "number"
|
|
870
|
+
};
|
|
871
|
+
}
|
|
726
872
|
};
|
|
727
873
|
NumberType.kind = "Number" /* Number */;
|
|
728
874
|
|
|
@@ -769,12 +915,18 @@ var MapType = class extends BaseType {
|
|
|
769
915
|
valueType: this.valueType?.toJSON()
|
|
770
916
|
};
|
|
771
917
|
}
|
|
918
|
+
toJSONSchema() {
|
|
919
|
+
return {
|
|
920
|
+
type: "map",
|
|
921
|
+
additionalProperties: this.valueType?.toJSONSchema()
|
|
922
|
+
};
|
|
923
|
+
}
|
|
772
924
|
};
|
|
773
925
|
// public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType | ASTNodeFlags.EnumerateType;
|
|
774
926
|
MapType.kind = "Map" /* Map */;
|
|
775
927
|
|
|
776
928
|
// src/ast/type/object.ts
|
|
777
|
-
var
|
|
929
|
+
var import_lodash2 = require("lodash");
|
|
778
930
|
var ObjectType = class extends BaseType {
|
|
779
931
|
constructor() {
|
|
780
932
|
super(...arguments);
|
|
@@ -854,12 +1006,21 @@ var ObjectType = class extends BaseType {
|
|
|
854
1006
|
const targetProperties = targetTypeJSON.properties || [];
|
|
855
1007
|
const sourcePropertyKeys = Array.from(this.propertyTable.keys());
|
|
856
1008
|
const targetPropertyKeys = targetProperties.map((_target) => _target.key);
|
|
857
|
-
const isKeyStrongEqual = !(0,
|
|
1009
|
+
const isKeyStrongEqual = !(0, import_lodash2.xor)(sourcePropertyKeys, targetPropertyKeys).length;
|
|
858
1010
|
return isKeyStrongEqual && targetProperties.every((targetProperty) => {
|
|
859
1011
|
const sourceProperty = this.propertyTable.get(targetProperty.key);
|
|
860
1012
|
return sourceProperty && sourceProperty.key === targetProperty.key && sourceProperty.type?.isTypeEqual(targetProperty?.type);
|
|
861
1013
|
});
|
|
862
1014
|
}
|
|
1015
|
+
toJSONSchema() {
|
|
1016
|
+
return {
|
|
1017
|
+
type: "object",
|
|
1018
|
+
properties: this.properties.reduce((acc, _property) => {
|
|
1019
|
+
acc[_property.key] = _property.type?.toJSONSchema();
|
|
1020
|
+
return acc;
|
|
1021
|
+
}, {})
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
863
1024
|
};
|
|
864
1025
|
ObjectType.kind = "Object" /* Object */;
|
|
865
1026
|
|
|
@@ -883,6 +1044,11 @@ var CustomType = class extends BaseType {
|
|
|
883
1044
|
}
|
|
884
1045
|
return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;
|
|
885
1046
|
}
|
|
1047
|
+
toJSONSchema() {
|
|
1048
|
+
return {
|
|
1049
|
+
type: this._typeName
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
886
1052
|
};
|
|
887
1053
|
CustomType.kind = "CustomType" /* CustomType */;
|
|
888
1054
|
|
|
@@ -961,29 +1127,6 @@ var BaseExpression = class extends ASTNode {
|
|
|
961
1127
|
}
|
|
962
1128
|
};
|
|
963
1129
|
|
|
964
|
-
// src/ast/expression/expression-list.ts
|
|
965
|
-
var ExpressionList = class extends ASTNode {
|
|
966
|
-
fromJSON({ expressions }) {
|
|
967
|
-
this.expressions = expressions.map((_expression, idx) => {
|
|
968
|
-
const prevExpression = this.expressions[idx];
|
|
969
|
-
if (prevExpression.kind !== _expression.kind) {
|
|
970
|
-
prevExpression.dispose();
|
|
971
|
-
this.fireChange();
|
|
972
|
-
return this.createChildNode(_expression);
|
|
973
|
-
}
|
|
974
|
-
prevExpression.fromJSON(_expression);
|
|
975
|
-
return prevExpression;
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
toJSON() {
|
|
979
|
-
return {
|
|
980
|
-
kind: "ExpressionList" /* ExpressionList */,
|
|
981
|
-
properties: this.expressions.map((_expression) => _expression.toJSON())
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
ExpressionList.kind = "ExpressionList" /* ExpressionList */;
|
|
986
|
-
|
|
987
1130
|
// src/ast/expression/keypath-expression.ts
|
|
988
1131
|
var import_fast_equals3 = require("fast-equals");
|
|
989
1132
|
var KeyPathExpression = class extends BaseExpression {
|
|
@@ -1073,12 +1216,12 @@ EnumerateExpression.kind = "EnumerateExpression" /* EnumerateExpression */;
|
|
|
1073
1216
|
var import_fast_equals4 = require("fast-equals");
|
|
1074
1217
|
|
|
1075
1218
|
// src/ast/utils/expression.ts
|
|
1076
|
-
var
|
|
1219
|
+
var import_lodash3 = require("lodash");
|
|
1077
1220
|
function getAllRefs(ast) {
|
|
1078
1221
|
return getAllChildren(ast).filter((_child) => _child.flags & 4 /* Expression */).map((_child) => _child.refs).flat().filter(Boolean);
|
|
1079
1222
|
}
|
|
1080
1223
|
function checkRefCycle(curr, refNodes) {
|
|
1081
|
-
if ((0,
|
|
1224
|
+
if ((0, import_lodash3.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean)).length === 0) {
|
|
1082
1225
|
return false;
|
|
1083
1226
|
}
|
|
1084
1227
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1090,7 +1233,7 @@ function checkRefCycle(curr, refNodes) {
|
|
|
1090
1233
|
queue.push(ref);
|
|
1091
1234
|
}
|
|
1092
1235
|
}
|
|
1093
|
-
return (0,
|
|
1236
|
+
return (0, import_lodash3.intersection)(Array.from(visited), getParentFields(curr)).length > 0;
|
|
1094
1237
|
}
|
|
1095
1238
|
|
|
1096
1239
|
// src/ast/expression/keypath-expression-v2.ts
|
|
@@ -1165,6 +1308,46 @@ var KeyPathExpressionV2 = class extends BaseExpression {
|
|
|
1165
1308
|
};
|
|
1166
1309
|
KeyPathExpressionV2.kind = "KeyPathExpression" /* KeyPathExpression */;
|
|
1167
1310
|
|
|
1311
|
+
// src/ast/expression/wrap-array-expression.ts
|
|
1312
|
+
var WrapArrayExpression = class extends BaseExpression {
|
|
1313
|
+
get wrapFor() {
|
|
1314
|
+
return this._wrapFor;
|
|
1315
|
+
}
|
|
1316
|
+
get returnType() {
|
|
1317
|
+
return this._returnType;
|
|
1318
|
+
}
|
|
1319
|
+
refreshReturnType() {
|
|
1320
|
+
const childReturnTypeJSON = this.wrapFor?.returnType?.toJSON();
|
|
1321
|
+
this.updateChildNodeByKey("_returnType", {
|
|
1322
|
+
kind: "Array" /* Array */,
|
|
1323
|
+
items: childReturnTypeJSON
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
getRefFields() {
|
|
1327
|
+
return [];
|
|
1328
|
+
}
|
|
1329
|
+
fromJSON({ wrapFor: expression }) {
|
|
1330
|
+
this.updateChildNodeByKey("_wrapFor", expression);
|
|
1331
|
+
}
|
|
1332
|
+
toJSON() {
|
|
1333
|
+
return {
|
|
1334
|
+
kind: "WrapArrayExpression" /* WrapArrayExpression */,
|
|
1335
|
+
wrapFor: this.wrapFor?.toJSON()
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
init() {
|
|
1339
|
+
this.toDispose.push(
|
|
1340
|
+
this.subscribe(this.refreshReturnType, {
|
|
1341
|
+
selector: (curr) => curr.wrapFor?.returnType
|
|
1342
|
+
})
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
WrapArrayExpression.kind = "WrapArrayExpression" /* WrapArrayExpression */;
|
|
1347
|
+
__decorateClass([
|
|
1348
|
+
postConstructAST()
|
|
1349
|
+
], WrapArrayExpression.prototype, "init", 1);
|
|
1350
|
+
|
|
1168
1351
|
// src/ast/declaration/base-variable-field.ts
|
|
1169
1352
|
var import_fast_equals5 = require("fast-equals");
|
|
1170
1353
|
var BaseVariableField = class extends ASTNode {
|
|
@@ -1471,7 +1654,7 @@ var ASTRegisters = class {
|
|
|
1471
1654
|
this.registerAST(VariableDeclarationList);
|
|
1472
1655
|
this.registerAST(KeyPathExpression);
|
|
1473
1656
|
this.registerAST(EnumerateExpression);
|
|
1474
|
-
this.registerAST(
|
|
1657
|
+
this.registerAST(WrapArrayExpression);
|
|
1475
1658
|
this.registerAST(MapNode);
|
|
1476
1659
|
this.registerAST(DataNode);
|
|
1477
1660
|
}
|
|
@@ -1495,7 +1678,7 @@ var ASTRegisters = class {
|
|
|
1495
1678
|
injector?.() || {}
|
|
1496
1679
|
);
|
|
1497
1680
|
node.changeLocked = true;
|
|
1498
|
-
node.fromJSON((0,
|
|
1681
|
+
node.fromJSON((0, import_lodash4.omit)(json, ["key", "kind"]));
|
|
1499
1682
|
node.changeLocked = false;
|
|
1500
1683
|
if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
|
|
1501
1684
|
const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
|
|
@@ -1524,59 +1707,9 @@ var ASTRegisters = class {
|
|
|
1524
1707
|
}
|
|
1525
1708
|
};
|
|
1526
1709
|
ASTRegisters = __decorateClass([
|
|
1527
|
-
(0,
|
|
1710
|
+
(0, import_inversify3.injectable)()
|
|
1528
1711
|
], ASTRegisters);
|
|
1529
1712
|
|
|
1530
|
-
// src/ast/factory.ts
|
|
1531
|
-
var ASTFactory;
|
|
1532
|
-
((ASTFactory2) => {
|
|
1533
|
-
ASTFactory2.createString = () => ({ kind: "String" /* String */ });
|
|
1534
|
-
ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
|
|
1535
|
-
ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
|
|
1536
|
-
ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
|
|
1537
|
-
ASTFactory2.createObject = (json) => ({
|
|
1538
|
-
kind: "Object" /* Object */,
|
|
1539
|
-
...json
|
|
1540
|
-
});
|
|
1541
|
-
ASTFactory2.createArray = (json) => ({
|
|
1542
|
-
kind: "Array" /* Array */,
|
|
1543
|
-
...json
|
|
1544
|
-
});
|
|
1545
|
-
ASTFactory2.createMap = (json) => ({
|
|
1546
|
-
kind: "Map" /* Map */,
|
|
1547
|
-
...json
|
|
1548
|
-
});
|
|
1549
|
-
ASTFactory2.createUnion = (json) => ({
|
|
1550
|
-
kind: "Union" /* Union */,
|
|
1551
|
-
...json
|
|
1552
|
-
});
|
|
1553
|
-
ASTFactory2.createCustomType = (json) => ({
|
|
1554
|
-
kind: "CustomType" /* CustomType */,
|
|
1555
|
-
...json
|
|
1556
|
-
});
|
|
1557
|
-
ASTFactory2.createVariableDeclaration = (json) => ({
|
|
1558
|
-
kind: "VariableDeclaration" /* VariableDeclaration */,
|
|
1559
|
-
...json
|
|
1560
|
-
});
|
|
1561
|
-
ASTFactory2.createProperty = (json) => ({
|
|
1562
|
-
kind: "Property" /* Property */,
|
|
1563
|
-
...json
|
|
1564
|
-
});
|
|
1565
|
-
ASTFactory2.createVariableDeclarationList = (json) => ({
|
|
1566
|
-
kind: "VariableDeclarationList" /* VariableDeclarationList */,
|
|
1567
|
-
...json
|
|
1568
|
-
});
|
|
1569
|
-
ASTFactory2.createEnumerateExpression = (json) => ({
|
|
1570
|
-
kind: "EnumerateExpression" /* EnumerateExpression */,
|
|
1571
|
-
...json
|
|
1572
|
-
});
|
|
1573
|
-
ASTFactory2.createKeyPathExpression = (json) => ({
|
|
1574
|
-
kind: "KeyPathExpression" /* KeyPathExpression */,
|
|
1575
|
-
...json
|
|
1576
|
-
});
|
|
1577
|
-
ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
|
|
1578
|
-
})(ASTFactory || (ASTFactory = {}));
|
|
1579
|
-
|
|
1580
1713
|
// src/scope/datas/scope-output-data.ts
|
|
1581
1714
|
var ScopeOutputData = class {
|
|
1582
1715
|
constructor(scope) {
|
|
@@ -1661,7 +1794,7 @@ var ScopeOutputData = class {
|
|
|
1661
1794
|
|
|
1662
1795
|
// src/scope/datas/scope-available-data.ts
|
|
1663
1796
|
var import_rxjs4 = require("rxjs");
|
|
1664
|
-
var
|
|
1797
|
+
var import_lodash5 = require("lodash");
|
|
1665
1798
|
var import_fast_equals7 = require("fast-equals");
|
|
1666
1799
|
var import_utils5 = require("@flowgram.ai/utils");
|
|
1667
1800
|
var import_utils6 = require("@flowgram.ai/utils");
|
|
@@ -1676,7 +1809,7 @@ var ScopeAvailableData = class {
|
|
|
1676
1809
|
*/
|
|
1677
1810
|
this.variables$ = this.refresh$.pipe(
|
|
1678
1811
|
// 输出变量是否 version 发生变化
|
|
1679
|
-
(0, import_rxjs4.map)(() => (0,
|
|
1812
|
+
(0, import_rxjs4.map)(() => (0, import_lodash5.flatten)(this.depScopes.map((scope) => scope.output.variables || []))),
|
|
1680
1813
|
// 变量列表浅比较
|
|
1681
1814
|
(0, import_rxjs4.distinctUntilChanged)(import_fast_equals7.shallowEqual),
|
|
1682
1815
|
(0, import_rxjs4.share)()
|
|
@@ -1946,20 +2079,20 @@ var VariableEngine = class {
|
|
|
1946
2079
|
}
|
|
1947
2080
|
};
|
|
1948
2081
|
__decorateClass([
|
|
1949
|
-
(0,
|
|
2082
|
+
(0, import_inversify6.inject)(ContainerProvider)
|
|
1950
2083
|
], VariableEngine.prototype, "containerProvider", 2);
|
|
1951
2084
|
__decorateClass([
|
|
1952
|
-
(0,
|
|
2085
|
+
(0, import_inversify6.preDestroy)()
|
|
1953
2086
|
], VariableEngine.prototype, "dispose", 1);
|
|
1954
2087
|
VariableEngine = __decorateClass([
|
|
1955
|
-
(0,
|
|
1956
|
-
__decorateParam(0, (0,
|
|
1957
|
-
__decorateParam(1, (0,
|
|
2088
|
+
(0, import_inversify6.injectable)(),
|
|
2089
|
+
__decorateParam(0, (0, import_inversify6.inject)(ScopeChain)),
|
|
2090
|
+
__decorateParam(1, (0, import_inversify6.inject)(ASTRegisters))
|
|
1958
2091
|
], VariableEngine);
|
|
1959
2092
|
|
|
1960
2093
|
// src/services/variable-field-key-rename-service.ts
|
|
1961
|
-
var
|
|
1962
|
-
var
|
|
2094
|
+
var import_lodash6 = require("lodash");
|
|
2095
|
+
var import_inversify7 = require("inversify");
|
|
1963
2096
|
var import_utils10 = require("@flowgram.ai/utils");
|
|
1964
2097
|
var VariableFieldKeyRenameService = class {
|
|
1965
2098
|
constructor() {
|
|
@@ -2001,7 +2134,7 @@ var VariableFieldKeyRenameService = class {
|
|
|
2001
2134
|
this.renameEmitter.fire(renameNodeInfo);
|
|
2002
2135
|
}
|
|
2003
2136
|
notifyFieldsDispose(prev, next) {
|
|
2004
|
-
const removedFields = (0,
|
|
2137
|
+
const removedFields = (0, import_lodash6.difference)(prev || [], next || []);
|
|
2005
2138
|
removedFields.forEach((_field) => this.disposeInListEmitter.fire(_field));
|
|
2006
2139
|
}
|
|
2007
2140
|
init() {
|
|
@@ -2025,20 +2158,20 @@ var VariableFieldKeyRenameService = class {
|
|
|
2025
2158
|
}
|
|
2026
2159
|
};
|
|
2027
2160
|
__decorateClass([
|
|
2028
|
-
(0,
|
|
2161
|
+
(0, import_inversify7.inject)(VariableEngine)
|
|
2029
2162
|
], VariableFieldKeyRenameService.prototype, "variableEngine", 2);
|
|
2030
2163
|
__decorateClass([
|
|
2031
|
-
(0,
|
|
2164
|
+
(0, import_inversify7.postConstruct)()
|
|
2032
2165
|
], VariableFieldKeyRenameService.prototype, "init", 1);
|
|
2033
2166
|
__decorateClass([
|
|
2034
|
-
(0,
|
|
2167
|
+
(0, import_inversify7.preDestroy)()
|
|
2035
2168
|
], VariableFieldKeyRenameService.prototype, "dispose", 1);
|
|
2036
2169
|
VariableFieldKeyRenameService = __decorateClass([
|
|
2037
|
-
(0,
|
|
2170
|
+
(0, import_inversify7.injectable)()
|
|
2038
2171
|
], VariableFieldKeyRenameService);
|
|
2039
2172
|
|
|
2040
2173
|
// src/variable-container-module.ts
|
|
2041
|
-
var VariableContainerModule = new
|
|
2174
|
+
var VariableContainerModule = new import_inversify8.ContainerModule((bind) => {
|
|
2042
2175
|
bind(VariableEngine).toSelf().inSingletonScope();
|
|
2043
2176
|
bind(ASTRegisters).toSelf().inSingletonScope();
|
|
2044
2177
|
bind(VariableFieldKeyRenameService).toSelf().inSingletonScope();
|
|
@@ -2105,7 +2238,6 @@ function useAvailableVariables() {
|
|
|
2105
2238
|
CustomType,
|
|
2106
2239
|
DataNode,
|
|
2107
2240
|
EnumerateExpression,
|
|
2108
|
-
ExpressionList,
|
|
2109
2241
|
IntegerType,
|
|
2110
2242
|
KeyPathExpression,
|
|
2111
2243
|
KeyPathExpressionV2,
|
|
@@ -2126,6 +2258,7 @@ function useAvailableVariables() {
|
|
|
2126
2258
|
VariableEngine,
|
|
2127
2259
|
VariableEngineProvider,
|
|
2128
2260
|
VariableFieldKeyRenameService,
|
|
2261
|
+
WrapArrayExpression,
|
|
2129
2262
|
injectToAST,
|
|
2130
2263
|
isMatchAST,
|
|
2131
2264
|
postConstructAST,
|