@dbml/core 7.0.0-alpha.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/lib/index.cjs +71 -69
- package/lib/index.mjs +400 -338
- package/package.json +3 -3
- package/types/export/DbmlExporter.d.ts +0 -0
- package/types/export/JsonExporter.d.ts +0 -0
- package/types/export/ModelExporter.d.ts +0 -0
- package/types/export/index.d.ts +0 -0
- package/types/import/index.d.ts +0 -0
- package/types/index.d.ts +5 -2
- package/types/model_structure/check.d.ts +1 -1
- package/types/model_structure/database.d.ts +2 -0
- package/types/model_structure/dbState.d.ts +1 -1
- package/types/model_structure/element.d.ts +0 -0
- package/types/model_structure/endpoint.d.ts +0 -0
- package/types/model_structure/enum.d.ts +1 -1
- package/types/model_structure/enumValue.d.ts +1 -1
- package/types/model_structure/field.d.ts +0 -0
- package/types/model_structure/index.d.ts +0 -0
- package/types/model_structure/indexColumn.d.ts +9 -1
- package/types/model_structure/indexes.d.ts +1 -1
- package/types/model_structure/ref.d.ts +1 -1
- package/types/model_structure/schema.d.ts +0 -0
- package/types/model_structure/stickyNote.d.ts +0 -0
- package/types/model_structure/table.d.ts +5 -2
- package/types/model_structure/tableGroup.d.ts +1 -1
- package/types/model_structure/tablePartial.d.ts +1 -1
- package/types/parse/Parser.d.ts +0 -0
- package/types/parse/error.d.ts +0 -0
- package/types/transform/index.d.ts +12 -0
package/lib/index.mjs
CHANGED
|
@@ -2199,7 +2199,7 @@ function unzip(_) {
|
|
|
2199
2199
|
});
|
|
2200
2200
|
}
|
|
2201
2201
|
var zip_default = _baseRest_default(unzip), SyntaxTokenKind = /* @__PURE__ */ function(_) {
|
|
2202
|
-
return _.SPACE = "<space>", _.TAB = "<tab>", _.NEWLINE = "<newline>", _.COMMA = "<comma>", _.LPAREN = "<lparen>", _.RPAREN = "<rparen>", _.LBRACE = "<lbrace>", _.RBRACE = "<rbrace>", _.LBRACKET = "<lbracket>", _.RBRACKET = "<rbracket>", _.LANGLE = "<langle>", _.RANGLE = "<rangle>", _.OP = "<op>", _.EOF = "<eof>", _.NUMERIC_LITERAL = "<number>", _.STRING_LITERAL = "<string>", _.COLOR_LITERAL = "<color>", _.FUNCTION_EXPRESSION = "<function-expression>", _.QUOTED_STRING = "<variable>", _.IDENTIFIER = "<identifier>", _.SEMICOLON = "<semicolon>", _.COLON = "<colon>", _.SINGLE_LINE_COMMENT = "<single-line-comment>", _.MULTILINE_COMMENT = "<multiline-comment>", _;
|
|
2202
|
+
return _.SPACE = "<space>", _.TAB = "<tab>", _.NEWLINE = "<newline>", _.COMMA = "<comma>", _.LPAREN = "<lparen>", _.RPAREN = "<rparen>", _.LBRACE = "<lbrace>", _.RBRACE = "<rbrace>", _.LBRACKET = "<lbracket>", _.RBRACKET = "<rbracket>", _.LANGLE = "<langle>", _.RANGLE = "<rangle>", _.OP = "<op>", _.EOF = "<eof>", _.NUMERIC_LITERAL = "<number>", _.STRING_LITERAL = "<string>", _.COLOR_LITERAL = "<color>", _.FUNCTION_EXPRESSION = "<function-expression>", _.QUOTED_STRING = "<variable>", _.IDENTIFIER = "<identifier>", _.SEMICOLON = "<semicolon>", _.COLON = "<colon>", _.SINGLE_LINE_COMMENT = "<single-line-comment>", _.MULTILINE_COMMENT = "<multiline-comment>", _.WILDCARD = "<wildcard>", _;
|
|
2203
2203
|
}({});
|
|
2204
2204
|
function isTriviaToken(_) {
|
|
2205
2205
|
switch (_.kind) {
|
|
@@ -2216,7 +2216,6 @@ function isOp(_) {
|
|
|
2216
2216
|
switch (_) {
|
|
2217
2217
|
case "+":
|
|
2218
2218
|
case "-":
|
|
2219
|
-
case "*":
|
|
2220
2219
|
case "/":
|
|
2221
2220
|
case "%":
|
|
2222
2221
|
case "<":
|
|
@@ -2286,7 +2285,7 @@ var SyntaxNodeIdGenerator = class {
|
|
|
2286
2285
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
2287
2286
|
}
|
|
2288
2287
|
}, SyntaxNodeKind = /* @__PURE__ */ function(_) {
|
|
2289
|
-
return _.PROGRAM = "<program>", _.ELEMENT_DECLARATION = "<element-declaration>", _.ATTRIBUTE = "<attribute>", _.IDENTIFIER_STREAM = "<identifer-stream>", _.LITERAL = "<literal>", _.VARIABLE = "<variable>", _.PREFIX_EXPRESSION = "<prefix-expression>", _.INFIX_EXPRESSION = "<infix-expression>", _.POSTFIX_EXPRESSION = "<postfix-expression>", _.FUNCTION_EXPRESSION = "<function-expression>", _.FUNCTION_APPLICATION = "<function-application>", _.BLOCK_EXPRESSION = "<block-expression>", _.LIST_EXPRESSION = "<list-expression>", _.TUPLE_EXPRESSION = "<tuple-expression>", _.CALL_EXPRESSION = "<call-expression>", _.PRIMARY_EXPRESSION = "<primary-expression>", _.GROUP_EXPRESSION = "<group-expression>", _.COMMA_EXPRESSION = "<comma-expression>", _.EMPTY = "<dummy>", _.ARRAY = "<array>", _;
|
|
2288
|
+
return _.PROGRAM = "<program>", _.ELEMENT_DECLARATION = "<element-declaration>", _.ATTRIBUTE = "<attribute>", _.IDENTIFIER_STREAM = "<identifer-stream>", _.LITERAL = "<literal>", _.VARIABLE = "<variable>", _.PREFIX_EXPRESSION = "<prefix-expression>", _.INFIX_EXPRESSION = "<infix-expression>", _.POSTFIX_EXPRESSION = "<postfix-expression>", _.FUNCTION_EXPRESSION = "<function-expression>", _.FUNCTION_APPLICATION = "<function-application>", _.BLOCK_EXPRESSION = "<block-expression>", _.LIST_EXPRESSION = "<list-expression>", _.TUPLE_EXPRESSION = "<tuple-expression>", _.CALL_EXPRESSION = "<call-expression>", _.PRIMARY_EXPRESSION = "<primary-expression>", _.GROUP_EXPRESSION = "<group-expression>", _.COMMA_EXPRESSION = "<comma-expression>", _.WILDCARD = "<wildcard>", _.EMPTY = "<dummy>", _.ARRAY = "<array>", _;
|
|
2290
2289
|
}({}), ProgramNode = class extends SyntaxNode {
|
|
2291
2290
|
constructor({ body: _ = [], eof: HY, source: P }, UY) {
|
|
2292
2291
|
super(UY, SyntaxNodeKind.PROGRAM, [..._, HY]), this.source = P, this.body = _, this.eof = HY;
|
|
@@ -2385,6 +2384,10 @@ var SyntaxNodeIdGenerator = class {
|
|
|
2385
2384
|
constructor({ literal: _ }, HY) {
|
|
2386
2385
|
super(HY, SyntaxNodeKind.LITERAL, [_]), this.literal = _;
|
|
2387
2386
|
}
|
|
2387
|
+
}, WildcardNode = class extends SyntaxNode {
|
|
2388
|
+
constructor({ token: _ }, HY) {
|
|
2389
|
+
super(HY, SyntaxNodeKind.WILDCARD, [_]), this.token = _;
|
|
2390
|
+
}
|
|
2388
2391
|
}, VariableNode = class extends SyntaxNode {
|
|
2389
2392
|
constructor({ variable: _ }, HY) {
|
|
2390
2393
|
super(HY, SyntaxNodeKind.VARIABLE, [_]), this.variable = _;
|
|
@@ -2585,19 +2588,22 @@ var Some = class _ {
|
|
|
2585
2588
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2586
2589
|
}
|
|
2587
2590
|
validate() {
|
|
2588
|
-
return
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2591
|
+
return {
|
|
2592
|
+
errors: [
|
|
2593
|
+
...this.validateContext(),
|
|
2594
|
+
...this.validateName(this.declarationNode.name),
|
|
2595
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2596
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2597
|
+
...this.validateBody(this.declarationNode.body)
|
|
2598
|
+
],
|
|
2599
|
+
warnings: []
|
|
2600
|
+
};
|
|
2595
2601
|
}
|
|
2596
2602
|
validateContext() {
|
|
2597
2603
|
return this.declarationNode.parent instanceof ProgramNode || getElementKind(this.declarationNode.parent).unwrap_or(void 0) !== ElementKind.Project ? [new CompileError(CompileErrorCode.INVALID_CUSTOM_CONTEXT, "A Custom element can only appear in a Project", this.declarationNode)] : [];
|
|
2598
2604
|
}
|
|
2599
2605
|
validateName(_) {
|
|
2600
|
-
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Custom element shouldn't have a name", _)] : [];
|
|
2606
|
+
return _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Custom element name", _)] : _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Custom element shouldn't have a name", _)] : [];
|
|
2601
2607
|
}
|
|
2602
2608
|
validateAlias(_) {
|
|
2603
2609
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", _)] : [];
|
|
@@ -2698,20 +2704,23 @@ var SymbolTable = class {
|
|
|
2698
2704
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2699
2705
|
}
|
|
2700
2706
|
validate() {
|
|
2701
|
-
return
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2707
|
+
return {
|
|
2708
|
+
errors: [
|
|
2709
|
+
...this.validateContext(),
|
|
2710
|
+
...this.validateName(this.declarationNode.name),
|
|
2711
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2712
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2713
|
+
...this.registerElement(),
|
|
2714
|
+
...this.validateBody(this.declarationNode.body)
|
|
2715
|
+
],
|
|
2716
|
+
warnings: []
|
|
2717
|
+
};
|
|
2709
2718
|
}
|
|
2710
2719
|
validateContext() {
|
|
2711
2720
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
2712
2721
|
}
|
|
2713
2722
|
validateName(_) {
|
|
2714
|
-
return _ ? isValidName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
2723
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as an Enum name", _)] : isValidName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
2715
2724
|
}
|
|
2716
2725
|
validateAlias(_) {
|
|
2717
2726
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "An Enum shouldn't have an alias", _)] : [];
|
|
@@ -2762,7 +2771,7 @@ var SymbolTable = class {
|
|
|
2762
2771
|
return P;
|
|
2763
2772
|
}
|
|
2764
2773
|
validateSubElements(_) {
|
|
2765
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
2774
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
2766
2775
|
}
|
|
2767
2776
|
registerField(_) {
|
|
2768
2777
|
if (_.callee && isExpressionAVariableNode(_.callee)) {
|
|
@@ -2782,13 +2791,16 @@ var SymbolTable = class {
|
|
|
2782
2791
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2783
2792
|
}
|
|
2784
2793
|
validate() {
|
|
2785
|
-
return
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2794
|
+
return {
|
|
2795
|
+
errors: [
|
|
2796
|
+
...this.validateContext(),
|
|
2797
|
+
...this.validateName(this.declarationNode.name),
|
|
2798
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2799
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2800
|
+
...this.validateBody(this.declarationNode.body)
|
|
2801
|
+
],
|
|
2802
|
+
warnings: []
|
|
2803
|
+
};
|
|
2792
2804
|
}
|
|
2793
2805
|
validateContext() {
|
|
2794
2806
|
let _ = new CompileError(CompileErrorCode.INVALID_INDEXES_CONTEXT, "An Indexes can only appear inside a Table or a TablePartial", this.declarationNode);
|
|
@@ -2797,7 +2809,7 @@ var SymbolTable = class {
|
|
|
2797
2809
|
return HY && [ElementKind.Table, ElementKind.TablePartial].includes(HY) ? [] : [_];
|
|
2798
2810
|
}
|
|
2799
2811
|
validateName(_) {
|
|
2800
|
-
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "An Indexes shouldn't have a name", _)] : [];
|
|
2812
|
+
return _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as an Indexes name", _)] : _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "An Indexes shouldn't have a name", _)] : [];
|
|
2801
2813
|
}
|
|
2802
2814
|
validateAlias(_) {
|
|
2803
2815
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", _)] : [];
|
|
@@ -2849,20 +2861,23 @@ var SymbolTable = class {
|
|
|
2849
2861
|
return P;
|
|
2850
2862
|
}
|
|
2851
2863
|
validateSubElements(_) {
|
|
2852
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
2864
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
2853
2865
|
}
|
|
2854
2866
|
}, NoteValidator = class {
|
|
2855
2867
|
constructor(_, HY, P) {
|
|
2856
2868
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2857
2869
|
}
|
|
2858
2870
|
validate() {
|
|
2859
|
-
return
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2871
|
+
return {
|
|
2872
|
+
errors: [
|
|
2873
|
+
...this.validateContext(),
|
|
2874
|
+
...this.validateName(this.declarationNode.name),
|
|
2875
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2876
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2877
|
+
...this.validateBody(this.declarationNode.body)
|
|
2878
|
+
],
|
|
2879
|
+
warnings: []
|
|
2880
|
+
};
|
|
2866
2881
|
}
|
|
2867
2882
|
validateContext() {
|
|
2868
2883
|
return !(this.declarationNode.parent instanceof ProgramNode) && ![
|
|
@@ -2875,6 +2890,7 @@ var SymbolTable = class {
|
|
|
2875
2890
|
validateName(_) {
|
|
2876
2891
|
if (!(this.declarationNode.parent instanceof ProgramNode)) return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Note shouldn't have a name", _)] : [];
|
|
2877
2892
|
if (!_) return [new CompileError(CompileErrorCode.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2893
|
+
if (_ instanceof WildcardNode) return [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Note name", _)];
|
|
2878
2894
|
let HY = destructureComplexVariable(_);
|
|
2879
2895
|
if (!HY.isOk()) return [new CompileError(CompileErrorCode.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2880
2896
|
let P = HY.unwrap().join("."), UY = createStickyNoteSymbolIndex(P);
|
|
@@ -2897,26 +2913,29 @@ var SymbolTable = class {
|
|
|
2897
2913
|
return _.length === 0 ? [new CompileError(CompileErrorCode.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (_.length > 1 && _.slice(1).forEach((_) => HY.push(new CompileError(CompileErrorCode.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", _))), isExpressionAQuotedString(_[0].callee) || HY.push(new CompileError(CompileErrorCode.INVALID_NOTE, "A Note content must be a quoted string", _[0])), _[0].args.length > 0 && HY.push(..._[0].args.map((_) => new CompileError(CompileErrorCode.INVALID_NOTE, "A Note can only contain one quoted string", _))), HY);
|
|
2898
2914
|
}
|
|
2899
2915
|
validateSubElements(_) {
|
|
2900
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
2916
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
2901
2917
|
}
|
|
2902
2918
|
}, ProjectValidator = class {
|
|
2903
2919
|
constructor(_, HY, P) {
|
|
2904
2920
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2905
2921
|
}
|
|
2906
2922
|
validate() {
|
|
2907
|
-
return
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2923
|
+
return {
|
|
2924
|
+
errors: [
|
|
2925
|
+
...this.validateContext(),
|
|
2926
|
+
...this.validateName(this.declarationNode.name),
|
|
2927
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2928
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2929
|
+
...this.validateBody(this.declarationNode.body)
|
|
2930
|
+
],
|
|
2931
|
+
warnings: []
|
|
2932
|
+
};
|
|
2914
2933
|
}
|
|
2915
2934
|
validateContext() {
|
|
2916
2935
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2917
2936
|
}
|
|
2918
2937
|
validateName(_) {
|
|
2919
|
-
return _ ? isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", _)] : [];
|
|
2938
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Project name", _)] : isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", _)] : [];
|
|
2920
2939
|
}
|
|
2921
2940
|
validateAlias(_) {
|
|
2922
2941
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", _)] : [];
|
|
@@ -2931,26 +2950,29 @@ var SymbolTable = class {
|
|
|
2931
2950
|
return [...HY.map((_) => new CompileError(CompileErrorCode.INVALID_PROJECT_FIELD, "A Project can not have inline fields", _)), ...this.validateSubElements(P)];
|
|
2932
2951
|
}
|
|
2933
2952
|
validateSubElements(_) {
|
|
2934
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
2953
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
2935
2954
|
}
|
|
2936
2955
|
}, RefValidator = class {
|
|
2937
2956
|
constructor(_, HY, P) {
|
|
2938
2957
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2939
2958
|
}
|
|
2940
2959
|
validate() {
|
|
2941
|
-
return
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2960
|
+
return {
|
|
2961
|
+
errors: [
|
|
2962
|
+
...this.validateContext(),
|
|
2963
|
+
...this.validateName(this.declarationNode.name),
|
|
2964
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2965
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2966
|
+
...this.validateBody(this.declarationNode.body)
|
|
2967
|
+
],
|
|
2968
|
+
warnings: []
|
|
2969
|
+
};
|
|
2948
2970
|
}
|
|
2949
2971
|
validateContext() {
|
|
2950
2972
|
return this.declarationNode.parent instanceof ProgramNode ? [] : [new CompileError(CompileErrorCode.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2951
2973
|
}
|
|
2952
2974
|
validateName(_) {
|
|
2953
|
-
return _ ? isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", _)] : [];
|
|
2975
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Ref name", _)] : isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", _)] : [];
|
|
2954
2976
|
}
|
|
2955
2977
|
validateAlias(_) {
|
|
2956
2978
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", _)] : [];
|
|
@@ -3009,7 +3031,7 @@ var SymbolTable = class {
|
|
|
3009
3031
|
return P;
|
|
3010
3032
|
}
|
|
3011
3033
|
validateSubElements(_) {
|
|
3012
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
3034
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
3013
3035
|
}
|
|
3014
3036
|
};
|
|
3015
3037
|
function isValidPolicy(_) {
|
|
@@ -3030,20 +3052,23 @@ var TableValidator = class {
|
|
|
3030
3052
|
this.declarationNode = _, this.symbolFactory = P, this.publicSymbolTable = HY;
|
|
3031
3053
|
}
|
|
3032
3054
|
validate() {
|
|
3033
|
-
return
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3055
|
+
return {
|
|
3056
|
+
errors: [
|
|
3057
|
+
...this.validateContext(),
|
|
3058
|
+
...this.validateName(this.declarationNode.name),
|
|
3059
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3060
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3061
|
+
...this.registerElement(),
|
|
3062
|
+
...this.validateBody(this.declarationNode.body)
|
|
3063
|
+
],
|
|
3064
|
+
warnings: []
|
|
3065
|
+
};
|
|
3041
3066
|
}
|
|
3042
3067
|
validateContext() {
|
|
3043
3068
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
3044
3069
|
}
|
|
3045
3070
|
validateName(_) {
|
|
3046
|
-
return _ ? _ instanceof ArrayNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", _)] : isValidName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
3071
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Table name", _)] : _ instanceof ArrayNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", _)] : isValidName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
3047
3072
|
}
|
|
3048
3073
|
validateAlias(_) {
|
|
3049
3074
|
return _ ? isValidAlias(_) ? [] : [new CompileError(CompileErrorCode.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", _)] : [];
|
|
@@ -3203,7 +3228,7 @@ var TableValidator = class {
|
|
|
3203
3228
|
}), UY;
|
|
3204
3229
|
}
|
|
3205
3230
|
validateSubElements(_) {
|
|
3206
|
-
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : [])), P = _.filter((_) => _.type?.value.toLowerCase() === "note");
|
|
3231
|
+
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : [])), P = _.filter((_) => _.type?.value.toLowerCase() === "note");
|
|
3207
3232
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3208
3233
|
}
|
|
3209
3234
|
};
|
|
@@ -3215,20 +3240,23 @@ var TableGroupValidator = class {
|
|
|
3215
3240
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3216
3241
|
}
|
|
3217
3242
|
validate() {
|
|
3218
|
-
return
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3243
|
+
return {
|
|
3244
|
+
errors: [
|
|
3245
|
+
...this.validateContext(),
|
|
3246
|
+
...this.validateName(this.declarationNode.name),
|
|
3247
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3248
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3249
|
+
...this.registerElement(),
|
|
3250
|
+
...this.validateBody(this.declarationNode.body)
|
|
3251
|
+
],
|
|
3252
|
+
warnings: []
|
|
3253
|
+
};
|
|
3226
3254
|
}
|
|
3227
3255
|
validateContext() {
|
|
3228
3256
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
3229
3257
|
}
|
|
3230
3258
|
validateName(_) {
|
|
3231
|
-
return _ ? isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A TableGroup name must be a single identifier", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
3259
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a TableGroup name", _)] : isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A TableGroup name must be a single identifier", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
3232
3260
|
}
|
|
3233
3261
|
validateAlias(_) {
|
|
3234
3262
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", _)] : [];
|
|
@@ -3280,7 +3308,7 @@ var TableGroupValidator = class {
|
|
|
3280
3308
|
});
|
|
3281
3309
|
}
|
|
3282
3310
|
validateSubElements(_) {
|
|
3283
|
-
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : [])), P = _.filter((_) => _.type?.value.toLowerCase() === "note");
|
|
3311
|
+
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : [])), P = _.filter((_) => _.type?.value.toLowerCase() === "note");
|
|
3284
3312
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3285
3313
|
}
|
|
3286
3314
|
registerField(_) {
|
|
@@ -3301,20 +3329,23 @@ var TableGroupValidator = class {
|
|
|
3301
3329
|
this.declarationNode = _, this.symbolFactory = P, this.publicSymbolTable = HY;
|
|
3302
3330
|
}
|
|
3303
3331
|
validate() {
|
|
3304
|
-
return
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3332
|
+
return {
|
|
3333
|
+
errors: [
|
|
3334
|
+
...this.validateContext(),
|
|
3335
|
+
...this.validateName(this.declarationNode.name),
|
|
3336
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3337
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3338
|
+
...this.registerElement(),
|
|
3339
|
+
...this.validateBody(this.declarationNode.body)
|
|
3340
|
+
],
|
|
3341
|
+
warnings: []
|
|
3342
|
+
};
|
|
3312
3343
|
}
|
|
3313
3344
|
validateContext() {
|
|
3314
3345
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLE_PARTIAL_CONTEXT, "TablePartial must appear top-level", this.declarationNode)] : [];
|
|
3315
3346
|
}
|
|
3316
3347
|
validateName(_) {
|
|
3317
|
-
return _ ? isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A TablePartial name must be an identifier or a quoted identifer", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A TablePartial must have a name", this.declarationNode)];
|
|
3348
|
+
return _ ? _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a TablePartial name", _)] : isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A TablePartial name must be an identifier or a quoted identifer", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A TablePartial must have a name", this.declarationNode)];
|
|
3318
3349
|
}
|
|
3319
3350
|
validateAlias(_) {
|
|
3320
3351
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A TablePartial shouldn't have an alias", _)] : [];
|
|
@@ -3450,7 +3481,7 @@ var TableGroupValidator = class {
|
|
|
3450
3481
|
}), WY;
|
|
3451
3482
|
}
|
|
3452
3483
|
validateSubElements(_) {
|
|
3453
|
-
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : [])), P = _.filter((_) => _.type?.value.toLowerCase() === ElementKind.Note);
|
|
3484
|
+
let HY = _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : [])), P = _.filter((_) => _.type?.value.toLowerCase() === ElementKind.Note);
|
|
3454
3485
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3455
3486
|
}
|
|
3456
3487
|
}, ChecksValidator = class {
|
|
@@ -3458,13 +3489,16 @@ var TableGroupValidator = class {
|
|
|
3458
3489
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3459
3490
|
}
|
|
3460
3491
|
validate() {
|
|
3461
|
-
return
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3492
|
+
return {
|
|
3493
|
+
errors: [
|
|
3494
|
+
...this.validateContext(),
|
|
3495
|
+
...this.validateName(this.declarationNode.name),
|
|
3496
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3497
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3498
|
+
...this.validateBody(this.declarationNode.body)
|
|
3499
|
+
],
|
|
3500
|
+
warnings: []
|
|
3501
|
+
};
|
|
3468
3502
|
}
|
|
3469
3503
|
validateContext() {
|
|
3470
3504
|
let _ = new CompileError(CompileErrorCode.INVALID_CHECKS_CONTEXT, "A Checks can only appear inside a Table or a TablePartial", this.declarationNode);
|
|
@@ -3473,7 +3507,7 @@ var TableGroupValidator = class {
|
|
|
3473
3507
|
return HY && [ElementKind.Table, ElementKind.TablePartial].includes(HY) ? [] : [_];
|
|
3474
3508
|
}
|
|
3475
3509
|
validateName(_) {
|
|
3476
|
-
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Checks shouldn't have a name", _)] : [];
|
|
3510
|
+
return _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Checks name", _)] : _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Checks shouldn't have a name", _)] : [];
|
|
3477
3511
|
}
|
|
3478
3512
|
validateAlias(_) {
|
|
3479
3513
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Checks shouldn't have an alias", _)] : [];
|
|
@@ -3510,27 +3544,30 @@ var TableGroupValidator = class {
|
|
|
3510
3544
|
return P;
|
|
3511
3545
|
}
|
|
3512
3546
|
validateSubElements(_) {
|
|
3513
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
3547
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
3514
3548
|
}
|
|
3515
3549
|
}, RecordsValidator = class {
|
|
3516
3550
|
constructor(_, HY, P) {
|
|
3517
3551
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3518
3552
|
}
|
|
3519
3553
|
validate() {
|
|
3520
|
-
return
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3554
|
+
return {
|
|
3555
|
+
errors: [
|
|
3556
|
+
...this.validateContext(),
|
|
3557
|
+
...this.validateName(this.declarationNode.name),
|
|
3558
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3559
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3560
|
+
...this.validateBody(this.declarationNode.body)
|
|
3561
|
+
],
|
|
3562
|
+
warnings: []
|
|
3563
|
+
};
|
|
3527
3564
|
}
|
|
3528
3565
|
validateContext() {
|
|
3529
3566
|
let _ = this.declarationNode.parent;
|
|
3530
3567
|
return _ instanceof ProgramNode || _ instanceof ElementDeclarationNode && getElementKind(_).unwrap_or(void 0) === ElementKind.Table ? [] : [new CompileError(CompileErrorCode.INVALID_RECORDS_CONTEXT, "Records can only appear at top-level or inside a Table", this.declarationNode)];
|
|
3531
3568
|
}
|
|
3532
3569
|
validateName(_) {
|
|
3533
|
-
return this.declarationNode.parent instanceof ProgramNode ? this.validateTopLevelName(_) : this.validateInsideTableName(_);
|
|
3570
|
+
return _ instanceof WildcardNode ? [new CompileError(CompileErrorCode.INVALID_NAME, "Wildcard (*) is not allowed as a Records name", _)] : this.declarationNode.parent instanceof ProgramNode ? this.validateTopLevelName(_) : this.validateInsideTableName(_);
|
|
3534
3571
|
}
|
|
3535
3572
|
validateTopLevelName(_) {
|
|
3536
3573
|
if (!(_ instanceof CallExpressionNode)) return [new CompileError(CompileErrorCode.INVALID_RECORDS_NAME, "Records at top-level must have a name in the form of table(col1, col2, ...) or schema.table(col1, col2, ...)", _ || this.declarationNode.type)];
|
|
@@ -3575,25 +3612,24 @@ var TableGroupValidator = class {
|
|
|
3575
3612
|
return !1;
|
|
3576
3613
|
}
|
|
3577
3614
|
validateSubElements(_) {
|
|
3578
|
-
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate() : []));
|
|
3615
|
+
return _.flatMap((_) => (_.parent = this.declarationNode, _.type ? new (pickValidator(_))(_, this.publicSymbolTable, this.symbolFactory).validate().errors : []));
|
|
3579
3616
|
}
|
|
3580
|
-
}
|
|
3581
|
-
function isWildcardExpression$2(_) {
|
|
3582
|
-
return _ && _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode ? _.expression.variable?.value === "*" : !1;
|
|
3583
|
-
}
|
|
3584
|
-
var DiagramViewValidator = class {
|
|
3617
|
+
}, DiagramViewValidator = class {
|
|
3585
3618
|
constructor(_, HY, P) {
|
|
3586
3619
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3587
3620
|
}
|
|
3588
3621
|
validate() {
|
|
3589
|
-
|
|
3622
|
+
let _ = [
|
|
3590
3623
|
...this.validateContext(),
|
|
3591
3624
|
...this.validateName(this.declarationNode.name),
|
|
3592
3625
|
...this.validateAlias(this.declarationNode.alias),
|
|
3593
3626
|
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3594
|
-
...this.registerElement()
|
|
3595
|
-
|
|
3596
|
-
|
|
3627
|
+
...this.registerElement()
|
|
3628
|
+
], HY = this.validateBody(this.declarationNode.body);
|
|
3629
|
+
return _.push(...HY.errors), {
|
|
3630
|
+
errors: _,
|
|
3631
|
+
warnings: HY.warnings
|
|
3632
|
+
};
|
|
3597
3633
|
}
|
|
3598
3634
|
validateContext() {
|
|
3599
3635
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_CONTEXT, "DiagramView must appear top-level", this.declarationNode)] : [];
|
|
@@ -3624,41 +3660,60 @@ var DiagramViewValidator = class {
|
|
|
3624
3660
|
return P;
|
|
3625
3661
|
}
|
|
3626
3662
|
validateBody(_) {
|
|
3627
|
-
if (!_) return
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3663
|
+
if (!_) return {
|
|
3664
|
+
errors: [],
|
|
3665
|
+
warnings: []
|
|
3666
|
+
};
|
|
3667
|
+
if (_ instanceof FunctionApplicationNode) return {
|
|
3668
|
+
errors: [new CompileError(CompileErrorCode.UNEXPECTED_SIMPLE_BODY, "A DiagramView's body must be a block", _)],
|
|
3669
|
+
warnings: []
|
|
3670
|
+
};
|
|
3671
|
+
let [HY, P] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode), UY = this.validateSubElements(P);
|
|
3672
|
+
return {
|
|
3673
|
+
errors: [...this.validateFields(HY), ...UY.errors],
|
|
3674
|
+
warnings: UY.warnings
|
|
3675
|
+
};
|
|
3631
3676
|
}
|
|
3632
3677
|
validateFields(_) {
|
|
3633
3678
|
return _.flatMap((_) => {
|
|
3634
|
-
if (isWildcardExpression
|
|
3679
|
+
if (isWildcardExpression(_.callee)) return _.args.length > 0 ? _.args.map((_) => new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, "DiagramView field should only have a single name", _)) : [];
|
|
3635
3680
|
let HY = [];
|
|
3636
3681
|
return HY.push(new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, "Fields are not allowed at DiagramView level. Use Tables, Notes, TableGroups, or Schemas blocks instead.", _)), HY;
|
|
3637
3682
|
});
|
|
3638
3683
|
}
|
|
3639
3684
|
validateSubElements(_) {
|
|
3640
|
-
let HY = [], P = [
|
|
3685
|
+
let HY = [], P = [], UY = [
|
|
3641
3686
|
"tables",
|
|
3642
3687
|
"notes",
|
|
3643
3688
|
"tablegroups",
|
|
3644
3689
|
"schemas"
|
|
3645
3690
|
];
|
|
3646
|
-
for (let
|
|
3647
|
-
if (
|
|
3648
|
-
let _ =
|
|
3649
|
-
if (!
|
|
3650
|
-
HY.push(new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, `Unknown block type "${
|
|
3691
|
+
for (let WY of _) {
|
|
3692
|
+
if (WY.parent = this.declarationNode, !WY.type) continue;
|
|
3693
|
+
let _ = WY.type.value.toLowerCase();
|
|
3694
|
+
if (!UY.includes(_)) {
|
|
3695
|
+
HY.push(new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, `Unknown block type "${WY.type.value}" in DiagramView. Allowed: Tables, Notes, TableGroups, Schemas`, WY));
|
|
3651
3696
|
continue;
|
|
3652
3697
|
}
|
|
3653
|
-
|
|
3698
|
+
let GY = this.validateSubBlock(WY);
|
|
3699
|
+
HY.push(...GY.errors), P.push(...GY.warnings);
|
|
3654
3700
|
}
|
|
3655
|
-
return
|
|
3701
|
+
return {
|
|
3702
|
+
errors: HY,
|
|
3703
|
+
warnings: P
|
|
3704
|
+
};
|
|
3656
3705
|
}
|
|
3657
3706
|
validateSubBlock(_) {
|
|
3658
|
-
let HY = [];
|
|
3659
|
-
if (!_.body || !(_.body instanceof BlockExpressionNode)) return
|
|
3660
|
-
|
|
3661
|
-
|
|
3707
|
+
let HY = [], P = [];
|
|
3708
|
+
if (!_.body || !(_.body instanceof BlockExpressionNode)) return {
|
|
3709
|
+
errors: HY,
|
|
3710
|
+
warnings: P
|
|
3711
|
+
};
|
|
3712
|
+
let UY = _.body, WY = UY.body.some((_) => _ instanceof FunctionApplicationNode && isWildcardExpression(_.callee)), GY = UY.body.some((_) => _ instanceof FunctionApplicationNode && !isWildcardExpression(_.callee));
|
|
3713
|
+
return WY && GY && P.push(new CompileWarning(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, `Wildcard (*) combined with specific items in ${_.type?.value} block. Specific items will be ignored.`, _)), HY.push(...this.registerSubBlockFields(_)), {
|
|
3714
|
+
errors: HY,
|
|
3715
|
+
warnings: P
|
|
3716
|
+
};
|
|
3662
3717
|
}
|
|
3663
3718
|
registerSubBlockFields(_) {
|
|
3664
3719
|
let HY = [];
|
|
@@ -3666,7 +3721,7 @@ var DiagramViewValidator = class {
|
|
|
3666
3721
|
let P = _.body.body.filter((_) => _ instanceof FunctionApplicationNode);
|
|
3667
3722
|
for (let _ of P) {
|
|
3668
3723
|
if (_.callee && isExpressionAVariableNode(_.callee)) {
|
|
3669
|
-
if (isWildcardExpression
|
|
3724
|
+
if (isWildcardExpression(_.callee)) continue;
|
|
3670
3725
|
let P = extractVarNameFromPrimaryVariable(_.callee).unwrap(), UY = createDiagramViewFieldSymbolIndex(P), WY = this.symbolFactory.create(DiagramViewFieldSymbol, { declaration: _ });
|
|
3671
3726
|
_.symbol = WY;
|
|
3672
3727
|
let GY = this.declarationNode.symbol.symbolTable;
|
|
@@ -3967,6 +4022,7 @@ function getMemberChain(_) {
|
|
|
3967
4022
|
if (_ instanceof CallExpressionNode) return filterUndefined(_.callee, _.argumentList);
|
|
3968
4023
|
if (_ instanceof PrimaryExpressionNode) return filterUndefined(_.expression);
|
|
3969
4024
|
if (_ instanceof ArrayNode) return filterUndefined(_.array, _.indexer);
|
|
4025
|
+
if (_ instanceof WildcardNode) return filterUndefined(_.token);
|
|
3970
4026
|
throw _ instanceof GroupExpressionNode ? Error("This case is already handled by TupleExpressionNode") : Error("Unreachable - no other possible cases");
|
|
3971
4027
|
}
|
|
3972
4028
|
function extractVariableNode(_) {
|
|
@@ -3978,6 +4034,9 @@ function isExpressionAQuotedString(_) {
|
|
|
3978
4034
|
function isExpressionAVariableNode(_) {
|
|
3979
4035
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode && _.expression.variable instanceof SyntaxToken;
|
|
3980
4036
|
}
|
|
4037
|
+
function isWildcardExpression(_) {
|
|
4038
|
+
return _ ? _ instanceof WildcardNode : !1;
|
|
4039
|
+
}
|
|
3981
4040
|
function isExpressionAnIdentifierNode(_) {
|
|
3982
4041
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode && _.expression.variable?.kind === SyntaxTokenKind.IDENTIFIER;
|
|
3983
4042
|
}
|
|
@@ -4089,6 +4148,9 @@ var Lexer = class {
|
|
|
4089
4148
|
case "/":
|
|
4090
4149
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator(_);
|
|
4091
4150
|
break;
|
|
4151
|
+
case "*":
|
|
4152
|
+
this.addToken(SyntaxTokenKind.WILDCARD);
|
|
4153
|
+
break;
|
|
4092
4154
|
default:
|
|
4093
4155
|
if (isOp(_)) {
|
|
4094
4156
|
this.operator(_);
|
|
@@ -4735,8 +4797,7 @@ var Lexer = class {
|
|
|
4735
4797
|
}
|
|
4736
4798
|
leftExpression_bp() {
|
|
4737
4799
|
let _;
|
|
4738
|
-
if (
|
|
4739
|
-
else if (isOpToken(this.peek())) {
|
|
4800
|
+
if (isOpToken(this.peek())) {
|
|
4740
4801
|
let HY = {};
|
|
4741
4802
|
HY.op = this.peek();
|
|
4742
4803
|
let P = prefixBindingPower(HY.op);
|
|
@@ -4752,7 +4813,7 @@ var Lexer = class {
|
|
|
4752
4813
|
return _;
|
|
4753
4814
|
}
|
|
4754
4815
|
extractOperand() {
|
|
4755
|
-
return this.check(SyntaxTokenKind.NUMERIC_LITERAL, SyntaxTokenKind.STRING_LITERAL, SyntaxTokenKind.COLOR_LITERAL, SyntaxTokenKind.QUOTED_STRING, SyntaxTokenKind.IDENTIFIER) ? this.primaryExpression() : this.check(SyntaxTokenKind.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(SyntaxTokenKind.LBRACKET) ? this.listExpression() : this.check(SyntaxTokenKind.LBRACE) ? this.blockExpression() : this.check(SyntaxTokenKind.LPAREN) ? this.tupleExpression() : (this.peek().kind === SyntaxTokenKind.EOF ? this.logError(this.peek(), CompileErrorCode.UNEXPECTED_EOF, "Unexpected EOF") : this.logError(this.peek(), CompileErrorCode.INVALID_OPERAND, `Invalid start of operand "${this.peek().value}"`), this.nodeFactory.create(EmptyNode, { prevToken: this.previous() }));
|
|
4816
|
+
return this.check(SyntaxTokenKind.WILDCARD) ? (this.advance(), this.nodeFactory.create(WildcardNode, { token: this.previous() })) : this.check(SyntaxTokenKind.NUMERIC_LITERAL, SyntaxTokenKind.STRING_LITERAL, SyntaxTokenKind.COLOR_LITERAL, SyntaxTokenKind.QUOTED_STRING, SyntaxTokenKind.IDENTIFIER) ? this.primaryExpression() : this.check(SyntaxTokenKind.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(SyntaxTokenKind.LBRACKET) ? this.listExpression() : this.check(SyntaxTokenKind.LBRACE) ? this.blockExpression() : this.check(SyntaxTokenKind.LPAREN) ? this.tupleExpression() : (this.peek().kind === SyntaxTokenKind.EOF ? this.logError(this.peek(), CompileErrorCode.UNEXPECTED_EOF, "Unexpected EOF") : this.logError(this.peek(), CompileErrorCode.INVALID_OPERAND, `Invalid start of operand "${this.peek().value}"`), this.nodeFactory.create(EmptyNode, { prevToken: this.previous() }));
|
|
4756
4817
|
}
|
|
4757
4818
|
functionExpression() {
|
|
4758
4819
|
let _ = {};
|
|
@@ -4813,10 +4874,6 @@ var Lexer = class {
|
|
|
4813
4874
|
left: 9,
|
|
4814
4875
|
right: 10
|
|
4815
4876
|
},
|
|
4816
|
-
"*": {
|
|
4817
|
-
left: 11,
|
|
4818
|
-
right: 12
|
|
4819
|
-
},
|
|
4820
4877
|
"-": {
|
|
4821
4878
|
left: 9,
|
|
4822
4879
|
right: 10
|
|
@@ -4923,14 +4980,14 @@ var Validator = class {
|
|
|
4923
4980
|
this.ast = _, this.symbolFactory = HY, this.publicSchemaSymbol = this.symbolFactory.create(SchemaSymbol, { symbolTable: new SymbolTable() }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
4924
4981
|
}
|
|
4925
4982
|
validate() {
|
|
4926
|
-
let _ = [];
|
|
4927
|
-
this.ast.body.forEach((
|
|
4928
|
-
if (
|
|
4929
|
-
let
|
|
4930
|
-
_.push(...
|
|
4983
|
+
let _ = [], HY = [];
|
|
4984
|
+
this.ast.body.forEach((P) => {
|
|
4985
|
+
if (P.parent = this.ast, P.type === void 0) return;
|
|
4986
|
+
let UY = new (pickValidator(P))(P, this.publicSchemaSymbol.symbolTable, this.symbolFactory).validate();
|
|
4987
|
+
_.push(...UY.errors), HY.push(...UY.warnings);
|
|
4931
4988
|
});
|
|
4932
|
-
let
|
|
4933
|
-
return
|
|
4989
|
+
let P = this.ast.body.filter((_) => getElementKind(_).unwrap_or(void 0) === ElementKind.Project);
|
|
4990
|
+
return P.length > 1 && P.forEach((HY) => _.push(new CompileError(CompileErrorCode.PROJECT_REDEFINED, "Only one project can exist", HY))), new Report(this.ast, _, HY);
|
|
4934
4991
|
}
|
|
4935
4992
|
}, ChecksBinder = class {
|
|
4936
4993
|
constructor(_, HY, P) {
|
|
@@ -4954,11 +5011,7 @@ var Validator = class {
|
|
|
4954
5011
|
bindSubElements(_) {
|
|
4955
5012
|
return _.flatMap((_) => _.type ? new (pickBinder(_))(_, this.ast, this.symbolFactory).bind() : []);
|
|
4956
5013
|
}
|
|
4957
|
-
}
|
|
4958
|
-
function isWildcardExpression$1(_) {
|
|
4959
|
-
return _ && _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode ? _.expression.variable?.value === "*" : !1;
|
|
4960
|
-
}
|
|
4961
|
-
var DiagramViewBinder = class {
|
|
5014
|
+
}, DiagramViewBinder = class {
|
|
4962
5015
|
constructor(_, HY, P) {
|
|
4963
5016
|
this.declarationNode = _, this.ast = HY, this.symbolFactory = P;
|
|
4964
5017
|
}
|
|
@@ -4995,7 +5048,7 @@ var DiagramViewBinder = class {
|
|
|
4995
5048
|
}
|
|
4996
5049
|
bindTableReferences(_) {
|
|
4997
5050
|
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
4998
|
-
return HY.flatMap((_) => !_.callee || isWildcardExpression
|
|
5051
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : [_.callee, ..._.args].flatMap(scanNonListNodeForBinding).flatMap((_) => {
|
|
4999
5052
|
let HY = _.variables.pop();
|
|
5000
5053
|
if (!HY) return [];
|
|
5001
5054
|
let P = _.variables;
|
|
@@ -5010,7 +5063,7 @@ var DiagramViewBinder = class {
|
|
|
5010
5063
|
}
|
|
5011
5064
|
bindNoteReferences(_) {
|
|
5012
5065
|
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5013
|
-
return HY.flatMap((_) => !_.callee || isWildcardExpression
|
|
5066
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => {
|
|
5014
5067
|
let HY = _.variables.pop();
|
|
5015
5068
|
return HY ? lookupAndBindInScope(this.ast, [{
|
|
5016
5069
|
node: HY,
|
|
@@ -5020,7 +5073,7 @@ var DiagramViewBinder = class {
|
|
|
5020
5073
|
}
|
|
5021
5074
|
bindTableGroupReferences(_) {
|
|
5022
5075
|
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5023
|
-
return HY.flatMap((_) => !_.callee || isWildcardExpression
|
|
5076
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => {
|
|
5024
5077
|
let HY = _.variables.pop();
|
|
5025
5078
|
if (!HY) return [];
|
|
5026
5079
|
let P = _.variables;
|
|
@@ -5035,13 +5088,10 @@ var DiagramViewBinder = class {
|
|
|
5035
5088
|
}
|
|
5036
5089
|
bindSchemaReferences(_) {
|
|
5037
5090
|
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5038
|
-
return HY.flatMap((_) => !_.callee || isWildcardExpression
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
kind: SymbolKind.Schema
|
|
5043
|
-
}]) : [];
|
|
5044
|
-
}));
|
|
5091
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => lookupAndBindInScope(this.ast, _.variables.map((_) => ({
|
|
5092
|
+
node: _,
|
|
5093
|
+
kind: SymbolKind.Schema
|
|
5094
|
+
})))));
|
|
5045
5095
|
}
|
|
5046
5096
|
}, EnumBinder = class {
|
|
5047
5097
|
constructor(_, HY, P) {
|
|
@@ -5372,7 +5422,9 @@ function generatePossibleIndexes(_) {
|
|
|
5372
5422
|
createEnumFieldSymbolIndex,
|
|
5373
5423
|
createTableGroupFieldSymbolIndex,
|
|
5374
5424
|
createTablePartialSymbolIndex,
|
|
5375
|
-
createPartialInjectionSymbolIndex
|
|
5425
|
+
createPartialInjectionSymbolIndex,
|
|
5426
|
+
createDiagramViewSymbolIndex,
|
|
5427
|
+
createDiagramViewFieldSymbolIndex
|
|
5376
5428
|
].map((HY) => HY(_));
|
|
5377
5429
|
}
|
|
5378
5430
|
function getSymbolKind(_) {
|
|
@@ -5387,6 +5439,8 @@ function getSymbolKind(_) {
|
|
|
5387
5439
|
if (_ instanceof TablePartialInjectedColumnSymbol) return SymbolKind.Column;
|
|
5388
5440
|
if (_ instanceof PartialInjectionSymbol) return SymbolKind.PartialInjection;
|
|
5389
5441
|
if (_ instanceof StickyNoteSymbol) return SymbolKind.Note;
|
|
5442
|
+
if (_ instanceof DiagramViewSymbol) return SymbolKind.DiagramView;
|
|
5443
|
+
if (_ instanceof DiagramViewFieldSymbol) return SymbolKind.DiagramViewField;
|
|
5390
5444
|
throw Error("No other possible symbol kind in getSymbolKind");
|
|
5391
5445
|
}
|
|
5392
5446
|
var RecordsBinder = class {
|
|
@@ -6331,26 +6385,18 @@ var TableInterpreter = class {
|
|
|
6331
6385
|
}
|
|
6332
6386
|
});
|
|
6333
6387
|
}
|
|
6334
|
-
}
|
|
6335
|
-
function isWildcardExpression(_) {
|
|
6336
|
-
return _ && _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode ? _.expression.variable?.value === "*" : !1;
|
|
6337
|
-
}
|
|
6338
|
-
var DiagramViewInterpreter = class {
|
|
6388
|
+
}, DiagramViewInterpreter = class {
|
|
6339
6389
|
constructor(_, HY) {
|
|
6340
|
-
this.declarationNode = _, this.env = HY, this.diagramView = {
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
},
|
|
6347
|
-
_explicitWildcards: /* @__PURE__ */ new Set(),
|
|
6348
|
-
_explicitlySet: /* @__PURE__ */ new Set()
|
|
6349
|
-
};
|
|
6390
|
+
this.declarationNode = _, this.env = HY, this.diagramView = { visibleEntities: {
|
|
6391
|
+
tables: null,
|
|
6392
|
+
stickyNotes: null,
|
|
6393
|
+
tableGroups: null,
|
|
6394
|
+
schemas: null
|
|
6395
|
+
} };
|
|
6350
6396
|
}
|
|
6351
6397
|
interpret() {
|
|
6352
6398
|
let _ = [];
|
|
6353
|
-
return this.diagramView.token = getTokenPosition(this.declarationNode), this.env.diagramViews
|
|
6399
|
+
return this.diagramView.token = getTokenPosition(this.declarationNode), this.env.diagramViews.set(this.declarationNode, this.diagramView), this.env.diagramViewWildcards.set(this.diagramView, /* @__PURE__ */ new Set()), this.env.diagramViewExplicitlySet.set(this.diagramView, /* @__PURE__ */ new Set()), this.declarationNode.name && _.push(...this.interpretName(this.declarationNode.name)), this.declarationNode.body instanceof BlockExpressionNode && _.push(...this.interpretBody(this.declarationNode.body)), _;
|
|
6354
6400
|
}
|
|
6355
6401
|
interpretName(_) {
|
|
6356
6402
|
let HY = destructureComplexVariable(_).unwrap_or([]);
|
|
@@ -6364,17 +6410,17 @@ var DiagramViewInterpreter = class {
|
|
|
6364
6410
|
stickyNotes: [],
|
|
6365
6411
|
tableGroups: [],
|
|
6366
6412
|
schemas: []
|
|
6367
|
-
}, this.diagramView
|
|
6413
|
+
}, this.env.diagramViewWildcards.set(this.diagramView, new Set([
|
|
6368
6414
|
"tables",
|
|
6369
6415
|
"stickyNotes",
|
|
6370
6416
|
"tableGroups",
|
|
6371
6417
|
"schemas"
|
|
6372
|
-
]), this.diagramView
|
|
6418
|
+
])), this.env.diagramViewExplicitlySet.set(this.diagramView, new Set([
|
|
6373
6419
|
"tables",
|
|
6374
6420
|
"stickyNotes",
|
|
6375
6421
|
"tableGroups",
|
|
6376
6422
|
"schemas"
|
|
6377
|
-
]), [];
|
|
6423
|
+
])), [];
|
|
6378
6424
|
}
|
|
6379
6425
|
let [HY] = partition_default(_.body, (_) => _ instanceof ElementDeclarationNode), P = /* @__PURE__ */ new Set();
|
|
6380
6426
|
for (let _ of HY) {
|
|
@@ -6382,23 +6428,26 @@ var DiagramViewInterpreter = class {
|
|
|
6382
6428
|
HY && P.add(HY), _.body instanceof BlockExpressionNode && this.interpretSubBlock(_.body, HY);
|
|
6383
6429
|
}
|
|
6384
6430
|
let UY = this.diagramView.visibleEntities;
|
|
6385
|
-
|
|
6431
|
+
(P.has("tables") && UY.tables !== null || P.has("tablegroups") && UY.tableGroups !== null || P.has("schemas") && UY.schemas !== null) && (P.has("tables") || (UY.tables = []), P.has("tablegroups") || (UY.tableGroups = []), P.has("schemas") || (UY.schemas = []));
|
|
6432
|
+
let WY = this.env.diagramViewExplicitlySet.get(this.diagramView);
|
|
6433
|
+
return P.has("tables") && WY.add("tables"), P.has("tablegroups") && WY.add("tableGroups"), P.has("schemas") && WY.add("schemas"), P.has("notes") && WY.add("stickyNotes"), [];
|
|
6386
6434
|
}
|
|
6387
6435
|
interpretSubBlock(_, HY) {
|
|
6388
6436
|
if (!HY) return;
|
|
6389
6437
|
if (_.body.some((_) => _ instanceof FunctionApplicationNode && isWildcardExpression(_.callee))) {
|
|
6438
|
+
let _ = this.env.diagramViewWildcards.get(this.diagramView);
|
|
6390
6439
|
switch (HY) {
|
|
6391
6440
|
case "tables":
|
|
6392
|
-
this.diagramView.visibleEntities.tables = [],
|
|
6441
|
+
this.diagramView.visibleEntities.tables = [], _.add("tables");
|
|
6393
6442
|
break;
|
|
6394
6443
|
case "notes":
|
|
6395
|
-
this.diagramView.visibleEntities.stickyNotes = [],
|
|
6444
|
+
this.diagramView.visibleEntities.stickyNotes = [], _.add("stickyNotes");
|
|
6396
6445
|
break;
|
|
6397
6446
|
case "tablegroups":
|
|
6398
|
-
this.diagramView.visibleEntities.tableGroups = [],
|
|
6447
|
+
this.diagramView.visibleEntities.tableGroups = [], _.add("tableGroups");
|
|
6399
6448
|
break;
|
|
6400
6449
|
case "schemas":
|
|
6401
|
-
this.diagramView.visibleEntities.schemas = [],
|
|
6450
|
+
this.diagramView.visibleEntities.schemas = [], _.add("schemas");
|
|
6402
6451
|
break;
|
|
6403
6452
|
}
|
|
6404
6453
|
return;
|
|
@@ -10240,7 +10289,7 @@ function createConstraintErrors(_, HY, P) {
|
|
|
10240
10289
|
}
|
|
10241
10290
|
var getConstraintType$1 = (_) => _ > 1 ? "Composite PK" : "PK";
|
|
10242
10291
|
function validatePrimaryKey(_) {
|
|
10243
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
10292
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
10244
10293
|
if (isEmpty_default$1(P)) return [];
|
|
10245
10294
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
10246
10295
|
let UY = _.cachedMergedTables.get(HY), WY = collectPkConstraints(UY), GY = collectAvailableColumns(P), KY = keyBy_default(UY.fields, "name");
|
|
@@ -10283,7 +10332,7 @@ function checkMissingPkColumns(_, HY, P, UY, WY) {
|
|
|
10283
10332
|
}
|
|
10284
10333
|
var getConstraintType = (_) => _ > 1 ? "Composite UNIQUE" : "UNIQUE";
|
|
10285
10334
|
function validateUnique(_) {
|
|
10286
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
10335
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
10287
10336
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
10288
10337
|
let UY = _.cachedMergedTables.get(HY);
|
|
10289
10338
|
if (isEmpty_default$1(P)) return [];
|
|
@@ -10307,7 +10356,7 @@ function validateForeignKeys(_) {
|
|
|
10307
10356
|
function buildTableInfoMap(_) {
|
|
10308
10357
|
let HY = /* @__PURE__ */ new Map();
|
|
10309
10358
|
for (let P of _.tables.values()) {
|
|
10310
|
-
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P) || [];
|
|
10359
|
+
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P)?.rows || [];
|
|
10311
10360
|
_.cachedMergedTables.has(P) || _.cachedMergedTables.set(P, mergeTableAndPartials(P, _));
|
|
10312
10361
|
let GY = _.cachedMergedTables.get(P);
|
|
10313
10362
|
HY.set(UY, {
|
|
@@ -10352,16 +10401,20 @@ var RecordsInterpreter = class {
|
|
|
10352
10401
|
HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, GY)), HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, UY));
|
|
10353
10402
|
continue;
|
|
10354
10403
|
}
|
|
10355
|
-
this.tableToRecordMap.set(_, UY)
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10404
|
+
this.tableToRecordMap.set(_, UY), this.env.records.has(_) || this.env.records.set(_, {
|
|
10405
|
+
element: UY,
|
|
10406
|
+
rows: []
|
|
10407
|
+
});
|
|
10408
|
+
let KY = this.env.records.get(_);
|
|
10409
|
+
for (let _ of UY.body.body) {
|
|
10410
|
+
let UY = _, GY = extractDataFromRow(UY, WY, this.env);
|
|
10411
|
+
HY.push(...GY.getErrors()), P.push(...GY.getWarnings());
|
|
10412
|
+
let qY = GY.getValue();
|
|
10413
|
+
qY.row && KY.rows.push({
|
|
10361
10414
|
values: qY.row,
|
|
10362
10415
|
node: UY,
|
|
10363
10416
|
columnNodes: qY.columnNodes
|
|
10364
|
-
})
|
|
10417
|
+
});
|
|
10365
10418
|
}
|
|
10366
10419
|
}
|
|
10367
10420
|
let UY = this.validateConstraints();
|
|
@@ -10524,26 +10577,23 @@ function processColumnInDb(_) {
|
|
|
10524
10577
|
}))
|
|
10525
10578
|
};
|
|
10526
10579
|
}
|
|
10527
|
-
var WILDCARD_EXPAND_ENTITIES = new Set(["tableGroups"]);
|
|
10528
10580
|
function expandDiagramViewWildcards(_) {
|
|
10529
|
-
|
|
10530
|
-
let P = HY.visibleEntities, UY = HY
|
|
10531
|
-
!UY || !WY ||
|
|
10532
|
-
name: _.name,
|
|
10533
|
-
schemaName: _.schemaName || "public"
|
|
10534
|
-
})))), WILDCARD_EXPAND_ENTITIES.has("tableGroups") && UY.has("tableGroups") && P.tableGroups && P.tableGroups.length === 0 && (WY.has("tables") || WY.has("schemas") || (P.tableGroups = Array.from(_.tableGroups.values()).map((_) => ({ name: _.name })))), WILDCARD_EXPAND_ENTITIES.has("stickyNotes") && UY.has("stickyNotes") && P.stickyNotes && P.stickyNotes.length === 0 && (P.stickyNotes = Array.from(_.notes.values()).map((_) => ({ name: _.name }))), WILDCARD_EXPAND_ENTITIES.has("schemas") && UY.has("schemas") && P.schemas && P.schemas.length === 0 && (WY.has("tables") || WY.has("tableGroups") || (P.schemas = [...new Set(Array.from(_.tables.values()).map((_) => _.schemaName || "public"))].map((_) => ({ name: _ })))), delete HY._explicitWildcards, delete HY._explicitlySet);
|
|
10581
|
+
for (let HY of _.diagramViews.values()) {
|
|
10582
|
+
let P = HY.visibleEntities, UY = _.diagramViewWildcards.get(HY), WY = _.diagramViewExplicitlySet.get(HY);
|
|
10583
|
+
!UY || !WY || UY.has("tableGroups") && P.tableGroups && P.tableGroups.length === 0 && (WY.has("tables") || WY.has("schemas") || (P.tableGroups = Array.from(_.tableGroups.values()).map((_) => ({ name: _.name }))));
|
|
10535
10584
|
}
|
|
10536
10585
|
}
|
|
10537
10586
|
function convertEnvToDb(_) {
|
|
10538
10587
|
let HY = [];
|
|
10539
|
-
for (let [P, UY] of _.records) {
|
|
10540
|
-
if (!
|
|
10541
|
-
let _ = Object.keys(
|
|
10588
|
+
for (let [P, { element: UY, rows: WY }] of _.records) {
|
|
10589
|
+
if (!WY.length) continue;
|
|
10590
|
+
let _ = Object.keys(WY[0].columnNodes);
|
|
10542
10591
|
HY.push({
|
|
10543
10592
|
schemaName: P.schemaName || void 0,
|
|
10544
10593
|
tableName: P.name,
|
|
10545
10594
|
columns: _,
|
|
10546
|
-
|
|
10595
|
+
token: getTokenPosition(UY),
|
|
10596
|
+
values: WY.map((HY) => _.map((_) => {
|
|
10547
10597
|
let P = HY.values[_];
|
|
10548
10598
|
return P ? {
|
|
10549
10599
|
value: P.value,
|
|
@@ -10566,7 +10616,7 @@ function convertEnvToDb(_) {
|
|
|
10566
10616
|
project: Array.from(_.project.values())[0] || {},
|
|
10567
10617
|
tablePartials: Array.from(_.tablePartials.values()).map(processColumnInDb),
|
|
10568
10618
|
records: HY,
|
|
10569
|
-
diagramViews:
|
|
10619
|
+
diagramViews: Array.from(_.diagramViews.values())
|
|
10570
10620
|
};
|
|
10571
10621
|
}
|
|
10572
10622
|
var Interpreter = class {
|
|
@@ -10587,7 +10637,9 @@ var Interpreter = class {
|
|
|
10587
10637
|
recordsElements: [],
|
|
10588
10638
|
cachedMergedTables: /* @__PURE__ */ new Map(),
|
|
10589
10639
|
source: _.source,
|
|
10590
|
-
diagramViews: /* @__PURE__ */ new Map()
|
|
10640
|
+
diagramViews: /* @__PURE__ */ new Map(),
|
|
10641
|
+
diagramViewWildcards: /* @__PURE__ */ new Map(),
|
|
10642
|
+
diagramViewExplicitlySet: /* @__PURE__ */ new Map()
|
|
10591
10643
|
};
|
|
10592
10644
|
}
|
|
10593
10645
|
interpret() {
|
|
@@ -11131,7 +11183,7 @@ function suggestInSubField(_, HY, P) {
|
|
|
11131
11183
|
case ScopeKind.DIAGRAMVIEW: return suggestInDiagramViewField();
|
|
11132
11184
|
case ScopeKind.CUSTOM: {
|
|
11133
11185
|
let P = _.container.element(HY);
|
|
11134
|
-
return P instanceof ElementDeclarationNode && P.parent instanceof ElementDeclarationNode && P.parent.
|
|
11186
|
+
return P instanceof ElementDeclarationNode && P.parent instanceof ElementDeclarationNode && getElementKind(P.parent).unwrap_or(void 0) === ElementKind.DiagramView ? suggestInDiagramViewSubBlock(_, HY) : noSuggestions();
|
|
11135
11187
|
}
|
|
11136
11188
|
default: return noSuggestions();
|
|
11137
11189
|
}
|
|
@@ -11283,48 +11335,20 @@ function suggestInDiagramViewSubBlock(_, HY) {
|
|
|
11283
11335
|
range: void 0
|
|
11284
11336
|
};
|
|
11285
11337
|
switch (UY) {
|
|
11286
|
-
case "tables": return { suggestions: [WY, ...
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
label:
|
|
11292
|
-
insertText:
|
|
11293
|
-
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11294
|
-
kind: pickCompletionItemKind(P),
|
|
11295
|
-
range: void 0
|
|
11296
|
-
};
|
|
11297
|
-
}) }).suggestions] };
|
|
11298
|
-
case "tablegroups": return { suggestions: [WY, ...addQuoteToSuggestionIfNeeded({ suggestions: [..._.parse.publicSymbolTable().entries()].flatMap(([_]) => {
|
|
11299
|
-
let HY = destructureIndex(_).unwrap_or(void 0);
|
|
11300
|
-
if (HY === void 0) return [];
|
|
11301
|
-
let { kind: P, name: UY } = HY;
|
|
11302
|
-
return P === SymbolKind.TableGroup ? {
|
|
11303
|
-
label: UY,
|
|
11304
|
-
insertText: UY,
|
|
11305
|
-
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11306
|
-
kind: pickCompletionItemKind(P),
|
|
11307
|
-
range: void 0
|
|
11308
|
-
} : [];
|
|
11309
|
-
}) }).suggestions] };
|
|
11310
|
-
case "schemas": {
|
|
11311
|
-
let HY = /* @__PURE__ */ new Set(), P = _.parse.ast();
|
|
11312
|
-
for (let _ of P?.body || []) if (_ instanceof ElementDeclarationNode && _.name instanceof InfixExpressionNode && _.name.op?.value === ".") {
|
|
11313
|
-
let P = destructureMemberAccessExpression(_.name).unwrap_or([]);
|
|
11314
|
-
if (P.length >= 2) {
|
|
11315
|
-
let _ = extractVariableFromExpression(P[0]).unwrap_or("");
|
|
11316
|
-
_ && HY.add(_);
|
|
11317
|
-
}
|
|
11318
|
-
}
|
|
11319
|
-
return { suggestions: [WY, ...[...HY].map((_) => ({
|
|
11320
|
-
label: _,
|
|
11321
|
-
insertText: _,
|
|
11338
|
+
case "tables": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Table, SymbolKind.Schema]).suggestions] };
|
|
11339
|
+
case "tablegroups": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.TableGroup]).suggestions] };
|
|
11340
|
+
case "schemas": return { suggestions: [
|
|
11341
|
+
WY,
|
|
11342
|
+
{
|
|
11343
|
+
label: DEFAULT_SCHEMA_NAME$1,
|
|
11344
|
+
insertText: DEFAULT_SCHEMA_NAME$1,
|
|
11322
11345
|
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11323
11346
|
kind: CompletionItemKind.Module,
|
|
11324
11347
|
range: void 0
|
|
11325
|
-
}
|
|
11326
|
-
|
|
11327
|
-
|
|
11348
|
+
},
|
|
11349
|
+
...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Schema]).suggestions
|
|
11350
|
+
] };
|
|
11351
|
+
case "notes": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Note]).suggestions] };
|
|
11328
11352
|
default: return noSuggestions();
|
|
11329
11353
|
}
|
|
11330
11354
|
}
|
|
@@ -11512,7 +11536,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11512
11536
|
"notes",
|
|
11513
11537
|
"schemas"
|
|
11514
11538
|
],
|
|
11515
|
-
symbols: /[
|
|
11539
|
+
symbols: /[=><!~?:&|+\-/^%]+/,
|
|
11516
11540
|
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
11517
11541
|
newline: /[\r\n]/,
|
|
11518
11542
|
digits: /\d+(_+\d+)*/,
|
|
@@ -11521,7 +11545,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11521
11545
|
unicode: !0,
|
|
11522
11546
|
tokenizer: {
|
|
11523
11547
|
root: [
|
|
11524
|
-
[/[{}
|
|
11548
|
+
[/[{}[\]()]/, "@bracket"],
|
|
11525
11549
|
[/[,.:]/, "delimiter"],
|
|
11526
11550
|
{ include: "@numbers" },
|
|
11527
11551
|
{ include: "common" }
|
|
@@ -11586,7 +11610,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11586
11610
|
numbers: [
|
|
11587
11611
|
[/0[xX][0-9a-fA-F]*/, "number"],
|
|
11588
11612
|
[/[$][+-]*\d*(\.\d*)?/, "number"],
|
|
11589
|
-
[/((\d+(\.\d*)?)|(\.\d+))([eE][
|
|
11613
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][-+]?\d+)?/, "number"],
|
|
11590
11614
|
[/#([0-9A-F]{3}){1,2}/, "number.hex"]
|
|
11591
11615
|
],
|
|
11592
11616
|
string_double: [
|
|
@@ -11643,13 +11667,13 @@ var DBMLDefinitionProvider = class {
|
|
|
11643
11667
|
]
|
|
11644
11668
|
],
|
|
11645
11669
|
comment: [
|
|
11646
|
-
[/[
|
|
11670
|
+
[/[^/*]+/, "comment"],
|
|
11647
11671
|
[
|
|
11648
11672
|
/\*\//,
|
|
11649
11673
|
"comment",
|
|
11650
11674
|
"@pop"
|
|
11651
11675
|
],
|
|
11652
|
-
[/[
|
|
11676
|
+
[/[/*]/, "comment"]
|
|
11653
11677
|
]
|
|
11654
11678
|
}
|
|
11655
11679
|
};
|
|
@@ -11770,10 +11794,10 @@ function containerScopeKind(_) {
|
|
|
11770
11794
|
default: return ScopeKind.CUSTOM;
|
|
11771
11795
|
}
|
|
11772
11796
|
}
|
|
11773
|
-
function applyTextEdits(_, HY) {
|
|
11774
|
-
let
|
|
11775
|
-
for (let { start: _, end: HY, newText:
|
|
11776
|
-
return
|
|
11797
|
+
function applyTextEdits(_, HY, P = !1) {
|
|
11798
|
+
let UY = P ? HY : [...HY].sort((_, HY) => HY.start - _.start), WY = _;
|
|
11799
|
+
for (let { start: _, end: HY, newText: P } of UY) WY = WY.substring(0, _) + P + WY.substring(HY);
|
|
11800
|
+
return WY;
|
|
11777
11801
|
}
|
|
11778
11802
|
function normalizeTableName(_) {
|
|
11779
11803
|
if (typeof _ != "string") return {
|
|
@@ -11893,6 +11917,91 @@ function renameTable$1(_, HY) {
|
|
|
11893
11917
|
for (let _ of XY.references) P.substring(_.start, _.end).replace(/"/g, "") === qY && QY.push(_);
|
|
11894
11918
|
return applyTextEdits(P, findReplacements(QY, KY, ZY, P));
|
|
11895
11919
|
}
|
|
11920
|
+
function findDiagramViewBlocks$1(_) {
|
|
11921
|
+
let HY = [], P = new Lexer(_).lex();
|
|
11922
|
+
if (P.getErrors().length > 0) return HY;
|
|
11923
|
+
let UY = new Parser$1(_, P.getValue(), new SyntaxNodeIdGenerator()).parse();
|
|
11924
|
+
if (UY.getErrors().length > 0) return HY;
|
|
11925
|
+
let WY = UY.getValue().ast;
|
|
11926
|
+
for (let _ of WY.body) if (_.type?.value.toLowerCase() === ElementKind.DiagramView) {
|
|
11927
|
+
let P = _.name ? destructureComplexVariable(_.name).unwrap_or([]) : [], UY = P.length > 0 ? P[P.length - 1] : "";
|
|
11928
|
+
HY.push({
|
|
11929
|
+
name: UY,
|
|
11930
|
+
startIndex: _.start,
|
|
11931
|
+
endIndex: _.end
|
|
11932
|
+
});
|
|
11933
|
+
}
|
|
11934
|
+
return HY;
|
|
11935
|
+
}
|
|
11936
|
+
function generateDiagramViewBlock(_, HY) {
|
|
11937
|
+
let P = [`DiagramView ${addDoubleQuoteIfNeeded(_)} {`];
|
|
11938
|
+
if (HY?.tables !== void 0 && HY.tables !== null) if (HY.tables.length === 0) P.push(" Tables { * }");
|
|
11939
|
+
else {
|
|
11940
|
+
let _ = HY.tables.map((_) => _.schemaName === "public" ? _.name : `${_.schemaName}.${_.name}`);
|
|
11941
|
+
P.push(" Tables {"), _.forEach((_) => P.push(` ${_}`)), P.push(" }");
|
|
11942
|
+
}
|
|
11943
|
+
return HY?.stickyNotes !== void 0 && (HY.stickyNotes === null || (HY.stickyNotes.length === 0 ? P.push(" Notes { * }") : (P.push(" Notes {"), HY.stickyNotes.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), HY?.tableGroups !== void 0 && (HY.tableGroups === null || (HY.tableGroups.length === 0 ? P.push(" TableGroups { * }") : (P.push(" TableGroups {"), HY.tableGroups.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), HY?.schemas !== void 0 && (HY.schemas === null || (HY.schemas.length === 0 ? P.push(" Schemas { * }") : (P.push(" Schemas {"), HY.schemas.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), P.push("}"), P.join("\n");
|
|
11944
|
+
}
|
|
11945
|
+
function syncDiagramView$1(_, HY, P) {
|
|
11946
|
+
let UY = P ?? findDiagramViewBlocks$1(_), WY = [];
|
|
11947
|
+
for (let P of HY) {
|
|
11948
|
+
let HY = applyOperation(_, P, UY);
|
|
11949
|
+
WY.push(...HY);
|
|
11950
|
+
}
|
|
11951
|
+
return WY.sort((_, HY) => HY.start - _.start), {
|
|
11952
|
+
newDbml: applyTextEdits(_, WY, !0),
|
|
11953
|
+
edits: WY
|
|
11954
|
+
};
|
|
11955
|
+
}
|
|
11956
|
+
function applyOperation(_, HY, P) {
|
|
11957
|
+
switch (HY.operation) {
|
|
11958
|
+
case "create": return computeCreateEdit(_, HY, P);
|
|
11959
|
+
case "update": return computeUpdateEdit(_, HY, P);
|
|
11960
|
+
case "delete": return computeDeleteEdit(_, HY, P);
|
|
11961
|
+
default: return [];
|
|
11962
|
+
}
|
|
11963
|
+
}
|
|
11964
|
+
function computeCreateEdit(_, HY, P) {
|
|
11965
|
+
if (P.find((_) => _.name === HY.name)) return computeUpdateEdit(_, HY, P);
|
|
11966
|
+
let UY = "\n\n" + generateDiagramViewBlock(HY.name, HY.visibleEntities) + "\n";
|
|
11967
|
+
return [{
|
|
11968
|
+
start: _.length,
|
|
11969
|
+
end: _.length,
|
|
11970
|
+
newText: UY
|
|
11971
|
+
}];
|
|
11972
|
+
}
|
|
11973
|
+
function computeUpdateEdit(_, HY, P) {
|
|
11974
|
+
let UY = P.find((_) => _.name === HY.name);
|
|
11975
|
+
if (!UY) return [];
|
|
11976
|
+
let WY = [];
|
|
11977
|
+
if (HY.newName || HY.visibleEntities) {
|
|
11978
|
+
let _ = generateDiagramViewBlock(HY.newName || HY.name, HY.visibleEntities);
|
|
11979
|
+
WY.push({
|
|
11980
|
+
start: UY.startIndex,
|
|
11981
|
+
end: UY.endIndex,
|
|
11982
|
+
newText: _
|
|
11983
|
+
});
|
|
11984
|
+
}
|
|
11985
|
+
return WY;
|
|
11986
|
+
}
|
|
11987
|
+
function computeDeleteEdit(_, HY, P) {
|
|
11988
|
+
let UY = P.find((_) => _.name === HY.name);
|
|
11989
|
+
if (!UY) return [];
|
|
11990
|
+
let WY = UY.startIndex, GY = UY.endIndex;
|
|
11991
|
+
for (; WY > 0 && _[WY - 1] === "\n";) {
|
|
11992
|
+
WY--, WY > 0 && _[WY - 1] === "\r" && WY--;
|
|
11993
|
+
let HY = _.lastIndexOf("\n", WY - 1) + 1;
|
|
11994
|
+
if (_.substring(HY, WY).trim() !== "") {
|
|
11995
|
+
WY = UY.startIndex, WY > 0 && _[WY - 1] === "\n" && (WY--, WY > 0 && _[WY - 1] === "\r" && WY--);
|
|
11996
|
+
break;
|
|
11997
|
+
}
|
|
11998
|
+
}
|
|
11999
|
+
return GY < _.length && _[GY] === "\r" && GY++, GY < _.length && _[GY] === "\n" && GY++, [{
|
|
12000
|
+
start: WY,
|
|
12001
|
+
end: GY,
|
|
12002
|
+
newText: ""
|
|
12003
|
+
}];
|
|
12004
|
+
}
|
|
11896
12005
|
var Compiler = class {
|
|
11897
12006
|
constructor() {
|
|
11898
12007
|
this.source = "", this.cache = /* @__PURE__ */ new Map(), this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.token = {
|
|
@@ -11949,6 +12058,12 @@ var Compiler = class {
|
|
|
11949
12058
|
renameTable(_, HY) {
|
|
11950
12059
|
return renameTable$1.call(this, _, HY);
|
|
11951
12060
|
}
|
|
12061
|
+
syncDiagramView(_, HY) {
|
|
12062
|
+
return syncDiagramView$1(this.parse.source(), _, HY);
|
|
12063
|
+
}
|
|
12064
|
+
findDiagramViewBlocks() {
|
|
12065
|
+
return findDiagramViewBlocks$1(this.parse.source());
|
|
12066
|
+
}
|
|
11952
12067
|
applyTextEdits(_) {
|
|
11953
12068
|
return applyTextEdits(this.parse.source(), _);
|
|
11954
12069
|
}
|
|
@@ -11961,80 +12076,6 @@ var Compiler = class {
|
|
|
11961
12076
|
};
|
|
11962
12077
|
}
|
|
11963
12078
|
};
|
|
11964
|
-
function findDiagramViewBlocks(_) {
|
|
11965
|
-
let HY = [], P = new Lexer(_).lex();
|
|
11966
|
-
if (P.getErrors().length > 0) return HY;
|
|
11967
|
-
let UY = new Parser$1(_, P.getValue(), new SyntaxNodeIdGenerator()).parse();
|
|
11968
|
-
if (UY.getErrors().length > 0) return HY;
|
|
11969
|
-
let WY = UY.getValue().ast;
|
|
11970
|
-
for (let _ of WY.body) if (_.type?.value === "DiagramView") {
|
|
11971
|
-
let P = _.name ? destructureComplexVariable(_.name).unwrap_or([]) : [], UY = P.length > 0 ? P[P.length - 1] : "";
|
|
11972
|
-
HY.push({
|
|
11973
|
-
name: UY,
|
|
11974
|
-
startIndex: _.start,
|
|
11975
|
-
endIndex: _.end
|
|
11976
|
-
});
|
|
11977
|
-
}
|
|
11978
|
-
return HY;
|
|
11979
|
-
}
|
|
11980
|
-
function needsQuoting(_) {
|
|
11981
|
-
return !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_);
|
|
11982
|
-
}
|
|
11983
|
-
function quoteName(_) {
|
|
11984
|
-
return needsQuoting(_) ? `"${_.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"` : _;
|
|
11985
|
-
}
|
|
11986
|
-
function generateDiagramViewBlock(_, HY) {
|
|
11987
|
-
let P = [`DiagramView ${quoteName(_)} {`];
|
|
11988
|
-
if (HY?.tables !== void 0 && HY.tables !== null) if (HY.tables.length === 0) P.push(" Tables { * }");
|
|
11989
|
-
else {
|
|
11990
|
-
let _ = HY.tables.map((_) => _.schemaName === "public" ? _.name : `${_.schemaName}.${_.name}`);
|
|
11991
|
-
P.push(" Tables {"), _.forEach((_) => P.push(` ${_}`)), P.push(" }");
|
|
11992
|
-
}
|
|
11993
|
-
return HY?.stickyNotes !== void 0 && (HY.stickyNotes === null || (HY.stickyNotes.length === 0 ? P.push(" Notes { * }") : (P.push(" Notes {"), HY.stickyNotes.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), HY?.tableGroups !== void 0 && (HY.tableGroups === null || (HY.tableGroups.length === 0 ? P.push(" TableGroups { * }") : (P.push(" TableGroups {"), HY.tableGroups.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), HY?.schemas !== void 0 && (HY.schemas === null || (HY.schemas.length === 0 ? P.push(" Schemas { * }") : (P.push(" Schemas {"), HY.schemas.forEach((_) => P.push(` ${_.name}`)), P.push(" }")))), P.push("}"), P.join("\n");
|
|
11994
|
-
}
|
|
11995
|
-
function syncDiagramView(_, HY) {
|
|
11996
|
-
let P = _;
|
|
11997
|
-
for (let _ of HY) P = applyOperation(P, _);
|
|
11998
|
-
return { newDbml: P };
|
|
11999
|
-
}
|
|
12000
|
-
function applyOperation(_, HY) {
|
|
12001
|
-
switch (HY.operation) {
|
|
12002
|
-
case "create": return applyCreate(_, HY);
|
|
12003
|
-
case "update": return applyUpdate(_, HY, findDiagramViewBlocks(_));
|
|
12004
|
-
case "delete": return applyDelete(_, HY, findDiagramViewBlocks(_));
|
|
12005
|
-
default: return _;
|
|
12006
|
-
}
|
|
12007
|
-
}
|
|
12008
|
-
function applyCreate(_, HY) {
|
|
12009
|
-
let P = findDiagramViewBlocks(_);
|
|
12010
|
-
if (P.find((_) => _.name === HY.name)) return applyUpdate(_, HY, P);
|
|
12011
|
-
let UY = generateDiagramViewBlock(HY.name, HY.visibleEntities);
|
|
12012
|
-
return _.trimEnd() + "\n\n" + UY + "\n";
|
|
12013
|
-
}
|
|
12014
|
-
function applyUpdate(_, HY, P) {
|
|
12015
|
-
let UY = P.find((_) => _.name === HY.name);
|
|
12016
|
-
if (!UY) return _;
|
|
12017
|
-
let WY = [];
|
|
12018
|
-
if (HY.newName || HY.visibleEntities) {
|
|
12019
|
-
let _ = generateDiagramViewBlock(HY.newName || HY.name, HY.visibleEntities);
|
|
12020
|
-
WY.push({
|
|
12021
|
-
start: UY.startIndex,
|
|
12022
|
-
end: UY.endIndex,
|
|
12023
|
-
newText: _
|
|
12024
|
-
});
|
|
12025
|
-
}
|
|
12026
|
-
return applyTextEdits(_, WY);
|
|
12027
|
-
}
|
|
12028
|
-
function applyDelete(_, HY, P) {
|
|
12029
|
-
let UY = P.find((_) => _.name === HY.name);
|
|
12030
|
-
if (!UY) return _;
|
|
12031
|
-
let WY = _.split("\n"), GY = 0, KY = WY.length - 1, qY = 0;
|
|
12032
|
-
for (let _ = 0; _ < WY.length; _++) {
|
|
12033
|
-
let HY = qY, P = qY + WY[_].length;
|
|
12034
|
-
HY <= UY.startIndex && UY.startIndex <= P && (GY = _), HY <= UY.endIndex && UY.endIndex <= P && (KY = _), qY = P + 1;
|
|
12035
|
-
}
|
|
12036
|
-
return [...WY.slice(0, GY), ...WY.slice(KY + 1)].join("\n");
|
|
12037
|
-
}
|
|
12038
12079
|
const DEFAULT_SCHEMA_NAME = "public", TABLE = "table", ENUM = "enum", TABLE_GROUP = "table_group";
|
|
12039
12080
|
var LuxonError = class extends Error {}, InvalidDateTimeError = class extends LuxonError {
|
|
12040
12081
|
constructor(_) {
|
|
@@ -16179,7 +16220,7 @@ var field_default = class extends element_default {
|
|
|
16179
16220
|
init_lodash();
|
|
16180
16221
|
var table_default = class extends element_default {
|
|
16181
16222
|
constructor({ name: _, alias: HY, note: P, fields: UY = [], indexes: WY = [], checks: GY = [], schema: KY = {}, token: qY, headerColor: JY, noteToken: YY = null, partials: XY = [] } = {}) {
|
|
16182
|
-
super(qY), this.name = _, this.alias = HY, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", YY) : null, this.headerColor = JY, this.fields = [], this.indexes = [], this.checks = [], this.schema = KY, this.partials = XY, this.dbState = this.schema.dbState, this.generateId(), this.processFields(UY), this.processPartials(), this.checkFieldCount(), this.processIndexes(WY), this.processChecks(GY);
|
|
16223
|
+
super(qY), this.name = _, this.alias = HY, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", YY) : null, this.headerColor = JY, this.fields = [], this.indexes = [], this.checks = [], this.schema = KY, this.partials = XY, this.records = [], this.dbState = this.schema.dbState, this.generateId(), this.processFields(UY), this.processPartials(), this.checkFieldCount(), this.processIndexes(WY), this.processChecks(GY);
|
|
16183
16224
|
}
|
|
16184
16225
|
generateId() {
|
|
16185
16226
|
this.id = this.dbState.generateId("tableId");
|
|
@@ -16319,7 +16360,8 @@ var table_default = class extends element_default {
|
|
|
16319
16360
|
alias: this.alias,
|
|
16320
16361
|
note: this.note,
|
|
16321
16362
|
headerColor: this.headerColor,
|
|
16322
|
-
partials: this.partials
|
|
16363
|
+
partials: this.partials,
|
|
16364
|
+
recordIds: this.records.map((_) => _.id)
|
|
16323
16365
|
};
|
|
16324
16366
|
}
|
|
16325
16367
|
normalize(_) {
|
|
@@ -16756,7 +16798,7 @@ var tablePartial_default = class extends element_default {
|
|
|
16756
16798
|
init_lodash();
|
|
16757
16799
|
var database_default = class extends element_default {
|
|
16758
16800
|
constructor({ schemas: _ = [], tables: HY = [], notes: P = [], enums: UY = [], refs: WY = [], tableGroups: GY = [], project: KY = {}, aliases: qY = [], records: JY = [], tablePartials: YY = [] }) {
|
|
16759
|
-
super(), this.dbState = new DbState(), this.generateId(), this.hasDefaultSchema = !1, this.schemas = [], this.notes = [], this.note = KY.note ? get_default(KY, "note.value", KY.note) : null, this.noteToken = KY.note ? get_default(KY, "note.token", KY.noteToken) : null, this.databaseType = KY.database_type, this.name = KY.name, this.token = KY.token, this.aliases = qY, this.records = [], this.tablePartials = [], this.injectedRawRefs = [], this.processNotes(P), this.processRecords(JY), this.processTablePartials(YY), this.processSchemas(_), this.processSchemaElements(UY, ENUM), this.processSchemaElements(HY, TABLE), this.processSchemaElements(P, "note"), this.processSchemaElements(WY, "ref"), this.processSchemaElements(GY, TABLE_GROUP), this.injectedRawRefs.forEach((_) => {
|
|
16801
|
+
super(), this.dbState = new DbState(), this.generateId(), this.hasDefaultSchema = !1, this.schemas = [], this.notes = [], this.note = KY.note ? get_default(KY, "note.value", KY.note) : null, this.noteToken = KY.note ? get_default(KY, "note.token", KY.noteToken) : null, this.databaseType = KY.database_type, this.name = KY.name, this.token = KY.token, this.aliases = qY, this.records = [], this.tablePartials = [], this.injectedRawRefs = [], this.processNotes(P), this.processRecords(JY), this.processTablePartials(YY), this.processSchemas(_), this.processSchemaElements(UY, ENUM), this.processSchemaElements(HY, TABLE), this.linkRecordsToTables(), this.processSchemaElements(P, "note"), this.processSchemaElements(WY, "ref"), this.processSchemaElements(GY, TABLE_GROUP), this.injectedRawRefs.forEach((_) => {
|
|
16760
16802
|
let HY = this.findOrCreateSchema(DEFAULT_SCHEMA_NAME), P = new ref_default({
|
|
16761
16803
|
..._,
|
|
16762
16804
|
schema: HY
|
|
@@ -16776,13 +16818,14 @@ var database_default = class extends element_default {
|
|
|
16776
16818
|
});
|
|
16777
16819
|
}
|
|
16778
16820
|
processRecords(_) {
|
|
16779
|
-
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY }) => {
|
|
16821
|
+
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY, token: WY }) => {
|
|
16780
16822
|
this.records.push({
|
|
16781
16823
|
id: this.dbState.generateId("recordId"),
|
|
16782
16824
|
schemaName: _,
|
|
16783
16825
|
tableName: HY,
|
|
16784
16826
|
columns: P,
|
|
16785
|
-
values: UY
|
|
16827
|
+
values: UY,
|
|
16828
|
+
token: WY
|
|
16786
16829
|
});
|
|
16787
16830
|
});
|
|
16788
16831
|
}
|
|
@@ -16846,6 +16889,17 @@ var database_default = class extends element_default {
|
|
|
16846
16889
|
}
|
|
16847
16890
|
});
|
|
16848
16891
|
}
|
|
16892
|
+
linkRecordsToTables() {
|
|
16893
|
+
let _ = {};
|
|
16894
|
+
this.schemas.forEach((HY) => {
|
|
16895
|
+
_[HY.name] = {}, HY.tables.forEach((P) => {
|
|
16896
|
+
_[HY.name][P.name] = P;
|
|
16897
|
+
});
|
|
16898
|
+
}), this.records.forEach((HY) => {
|
|
16899
|
+
let P = _[HY.schemaName ?? "public"]?.[HY.tableName];
|
|
16900
|
+
P && (HY.tableId = P.id, P.records.push(HY));
|
|
16901
|
+
});
|
|
16902
|
+
}
|
|
16849
16903
|
findOrCreateSchema(_) {
|
|
16850
16904
|
let HY = this.schemas.find((HY) => HY.name === _ || HY.alias === _);
|
|
16851
16905
|
return HY || (HY = new schema_default({
|
|
@@ -1821747,5 +1821801,13 @@ function renameTable(_, HY, P) {
|
|
|
1821747
1821801
|
let UY = new Compiler();
|
|
1821748
1821802
|
return UY.setSource(P), UY.renameTable(_, HY);
|
|
1821749
1821803
|
}
|
|
1821750
|
-
|
|
1821751
|
-
|
|
1821804
|
+
function syncDiagramView(_, HY, P) {
|
|
1821805
|
+
let UY = new Compiler();
|
|
1821806
|
+
return UY.setSource(_), UY.syncDiagramView(HY, P);
|
|
1821807
|
+
}
|
|
1821808
|
+
function findDiagramViewBlocks(_) {
|
|
1821809
|
+
let HY = new Compiler();
|
|
1821810
|
+
return HY.setSource(_), HY.findDiagramViewBlocks();
|
|
1821811
|
+
}
|
|
1821812
|
+
const VERSION = "7.0.0";
|
|
1821813
|
+
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, dbmlMonarchTokensProvider, export_default as exporter, findDiagramViewBlocks, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, syncDiagramView, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString };
|