@dbml/core 6.5.0 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/lib/index.cjs +73 -65
- package/lib/index.mjs +875 -133
- 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 -0
- package/types/model_structure/check.d.ts +0 -0
- package/types/model_structure/database.d.ts +0 -0
- package/types/model_structure/dbState.d.ts +0 -0
- 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 +0 -0
- package/types/model_structure/enumValue.d.ts +0 -0
- 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 +0 -0
- package/types/model_structure/indexes.d.ts +0 -0
- package/types/model_structure/ref.d.ts +0 -0
- 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 +0 -0
- package/types/model_structure/tableGroup.d.ts +0 -0
- package/types/model_structure/tablePartial.d.ts +0 -0
- 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 = _;
|
|
@@ -2447,6 +2450,18 @@ var NodeSymbolIdGenerator = class {
|
|
|
2447
2450
|
constructor({ declaration: _ }, HY) {
|
|
2448
2451
|
this.references = [], this.id = HY, this.declaration = _;
|
|
2449
2452
|
}
|
|
2453
|
+
}, DiagramViewSymbol = class {
|
|
2454
|
+
constructor({ symbolTable: _, declaration: HY }, P) {
|
|
2455
|
+
this.references = [], this.id = P, this.symbolTable = _, this.declaration = HY;
|
|
2456
|
+
}
|
|
2457
|
+
}, DiagramViewFieldSymbol = class {
|
|
2458
|
+
constructor({ declaration: _ }, HY) {
|
|
2459
|
+
this.references = [], this.id = HY, this.declaration = _;
|
|
2460
|
+
}
|
|
2461
|
+
}, StickyNoteSymbol = class {
|
|
2462
|
+
constructor({ declaration: _ }, HY) {
|
|
2463
|
+
this.references = [], this.id = HY, this.declaration = _;
|
|
2464
|
+
}
|
|
2450
2465
|
}, TablePartialSymbol = class {
|
|
2451
2466
|
constructor({ symbolTable: _, declaration: HY }, P) {
|
|
2452
2467
|
this.references = [], this.id = P, this.symbolTable = _, this.declaration = HY;
|
|
@@ -2460,7 +2475,7 @@ var NodeSymbolIdGenerator = class {
|
|
|
2460
2475
|
this.references = [], this.id = P, this.declaration = _, this.tablePartialSymbol = HY;
|
|
2461
2476
|
}
|
|
2462
2477
|
}, CompileErrorCode = /* @__PURE__ */ function(_) {
|
|
2463
|
-
return _[_.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", _[_.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", _[_.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", _[_.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", _[_.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", _[_.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", _[_.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", _[_.MISSING_SPACES = 1007] = "MISSING_SPACES", _[_.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", _[_.INVALID_OPERAND = 1009] = "INVALID_OPERAND", _[_.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", _[_.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", _[_.INVALID_NAME = 3e3] = "INVALID_NAME", _[_.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", _[_.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", _[_.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", _[_.INVALID_ALIAS = 3004] = "INVALID_ALIAS", _[_.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", _[_.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", _[_.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", _[_.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", _[_.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", _[_.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", _[_.UNKNOWN_TABLE_SETTING = 3011] = "UNKNOWN_TABLE_SETTING", _[_.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", _[_.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", _[_.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", _[_.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", _[_.EMPTY_TABLE = 3018] = "EMPTY_TABLE", _[_.INVALID_COLUMN = 3019] = "INVALID_COLUMN", _[_.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", _[_.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", _[_.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", _[_.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", _[_.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", _[_.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", _[_.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", _[_.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", _[_.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", _[_.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", _[_.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", _[_.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", _[_.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", _[_.EMPTY_ENUM = 3033] = "EMPTY_ENUM", _[_.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", _[_.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", _[_.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", _[_.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", _[_.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", _[_.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", _[_.EMPTY_REF = 3040] = "EMPTY_REF", _[_.REF_REDEFINED = 3041] = "REF_REDEFINED", _[_.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", _[_.INVALID_NOTE = 3043] = "INVALID_NOTE", _[_.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", _[_.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", _[_.EMPTY_NOTE = 3046] = "EMPTY_NOTE", _[_.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", _[_.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", _[_.INVALID_INDEX = 3049] = "INVALID_INDEX", _[_.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", _[_.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", _[_.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", _[_.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", _[_.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", _[_.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", _[_.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", _[_.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", _[_.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", _[_.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", _[_.INVALID_TABLE_PARTIAL_CONTEXT = 3060] = "INVALID_TABLE_PARTIAL_CONTEXT", _[_.INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3061] = "INVALID_TABLE_PARTIAL_ELEMENT_NAME", _[_.INVALID_TABLE_PARTIAL_SETTING_VALUE = 3062] = "INVALID_TABLE_PARTIAL_SETTING_VALUE", _[_.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3063] = "DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME", _[_.DUPLICATE_TABLE_PARTIAL_SETTING = 3064] = "DUPLICATE_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_PARTIAL_INJECTION = 3065] = "INVALID_TABLE_PARTIAL_INJECTION", _[_.INVALID_TABLE_PARTIAL_INJECTION_OP = 3066] = "INVALID_TABLE_PARTIAL_INJECTION_OP", _[_.INVALID_TABLE_PARTIAL_INJECTION_NAME = 3067] = "INVALID_TABLE_PARTIAL_INJECTION_NAME", _[_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3068] = "DUPLICATE_TABLE_PARTIAL_INJECTION_NAME", _[_.UNKNOWN_TABLE_PARTIAL_SETTING = 3069] = "UNKNOWN_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_SETTING_VALUE = 3070] = "INVALID_TABLE_SETTING_VALUE", _[_.INVALID_CHECKS_CONTEXT = 3071] = "INVALID_CHECKS_CONTEXT", _[_.INVALID_CHECKS_FIELD = 3072] = "INVALID_CHECKS_FIELD", _[_.INVALID_CHECK = 3073] = "INVALID_CHECK", _[_.UNKNOWN_CHECK_SETTING = 3074] = "UNKNOWN_CHECK_SETTING", _[_.DUPLICATE_CHECK_SETTING = 3075] = "DUPLICATE_CHECK_SETTING", _[_.INVALID_CHECK_SETTING_VALUE = 3076] = "INVALID_CHECK_SETTING_VALUE", _[_.INVALID_RECORDS_CONTEXT = 3077] = "INVALID_RECORDS_CONTEXT", _[_.INVALID_RECORDS_NAME = 3078] = "INVALID_RECORDS_NAME", _[_.INVALID_RECORDS_FIELD = 3079] = "INVALID_RECORDS_FIELD", _[_.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3080] = "DUPLICATE_COLUMN_REFERENCES_IN_RECORDS", _[_.DUPLICATE_RECORDS_FOR_TABLE = 3081] = "DUPLICATE_RECORDS_FOR_TABLE", _[_.BINDING_ERROR = 4e3] = "BINDING_ERROR", _[_.UNSUPPORTED = 5e3] = "UNSUPPORTED", _[_.CIRCULAR_REF = 5001] = "CIRCULAR_REF", _[_.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", _[_.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", _[_.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", _[_.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", _;
|
|
2478
|
+
return _[_.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", _[_.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", _[_.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", _[_.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", _[_.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", _[_.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", _[_.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", _[_.MISSING_SPACES = 1007] = "MISSING_SPACES", _[_.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", _[_.INVALID_OPERAND = 1009] = "INVALID_OPERAND", _[_.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", _[_.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", _[_.INVALID_NAME = 3e3] = "INVALID_NAME", _[_.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", _[_.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", _[_.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", _[_.INVALID_ALIAS = 3004] = "INVALID_ALIAS", _[_.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", _[_.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", _[_.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", _[_.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", _[_.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", _[_.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", _[_.UNKNOWN_TABLE_SETTING = 3011] = "UNKNOWN_TABLE_SETTING", _[_.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", _[_.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", _[_.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", _[_.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", _[_.EMPTY_TABLE = 3018] = "EMPTY_TABLE", _[_.INVALID_COLUMN = 3019] = "INVALID_COLUMN", _[_.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", _[_.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", _[_.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", _[_.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", _[_.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", _[_.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", _[_.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", _[_.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", _[_.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", _[_.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", _[_.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", _[_.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", _[_.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", _[_.EMPTY_ENUM = 3033] = "EMPTY_ENUM", _[_.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", _[_.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", _[_.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", _[_.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", _[_.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", _[_.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", _[_.EMPTY_REF = 3040] = "EMPTY_REF", _[_.REF_REDEFINED = 3041] = "REF_REDEFINED", _[_.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", _[_.INVALID_NOTE = 3043] = "INVALID_NOTE", _[_.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", _[_.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", _[_.EMPTY_NOTE = 3046] = "EMPTY_NOTE", _[_.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", _[_.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", _[_.INVALID_INDEX = 3049] = "INVALID_INDEX", _[_.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", _[_.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", _[_.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", _[_.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", _[_.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", _[_.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", _[_.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", _[_.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", _[_.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", _[_.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", _[_.INVALID_TABLE_PARTIAL_CONTEXT = 3060] = "INVALID_TABLE_PARTIAL_CONTEXT", _[_.INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3061] = "INVALID_TABLE_PARTIAL_ELEMENT_NAME", _[_.INVALID_TABLE_PARTIAL_SETTING_VALUE = 3062] = "INVALID_TABLE_PARTIAL_SETTING_VALUE", _[_.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3063] = "DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME", _[_.DUPLICATE_TABLE_PARTIAL_SETTING = 3064] = "DUPLICATE_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_PARTIAL_INJECTION = 3065] = "INVALID_TABLE_PARTIAL_INJECTION", _[_.INVALID_TABLE_PARTIAL_INJECTION_OP = 3066] = "INVALID_TABLE_PARTIAL_INJECTION_OP", _[_.INVALID_TABLE_PARTIAL_INJECTION_NAME = 3067] = "INVALID_TABLE_PARTIAL_INJECTION_NAME", _[_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3068] = "DUPLICATE_TABLE_PARTIAL_INJECTION_NAME", _[_.UNKNOWN_TABLE_PARTIAL_SETTING = 3069] = "UNKNOWN_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_SETTING_VALUE = 3070] = "INVALID_TABLE_SETTING_VALUE", _[_.INVALID_CHECKS_CONTEXT = 3071] = "INVALID_CHECKS_CONTEXT", _[_.INVALID_CHECKS_FIELD = 3072] = "INVALID_CHECKS_FIELD", _[_.INVALID_CHECK = 3073] = "INVALID_CHECK", _[_.UNKNOWN_CHECK_SETTING = 3074] = "UNKNOWN_CHECK_SETTING", _[_.DUPLICATE_CHECK_SETTING = 3075] = "DUPLICATE_CHECK_SETTING", _[_.INVALID_CHECK_SETTING_VALUE = 3076] = "INVALID_CHECK_SETTING_VALUE", _[_.INVALID_RECORDS_CONTEXT = 3077] = "INVALID_RECORDS_CONTEXT", _[_.INVALID_RECORDS_NAME = 3078] = "INVALID_RECORDS_NAME", _[_.INVALID_RECORDS_FIELD = 3079] = "INVALID_RECORDS_FIELD", _[_.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3080] = "DUPLICATE_COLUMN_REFERENCES_IN_RECORDS", _[_.DUPLICATE_RECORDS_FOR_TABLE = 3081] = "DUPLICATE_RECORDS_FOR_TABLE", _[_.INVALID_DIAGRAMVIEW_CONTEXT = 3082] = "INVALID_DIAGRAMVIEW_CONTEXT", _[_.DUPLICATE_DIAGRAMVIEW_NAME = 3083] = "DUPLICATE_DIAGRAMVIEW_NAME", _[_.INVALID_DIAGRAMVIEW_FIELD = 3084] = "INVALID_DIAGRAMVIEW_FIELD", _[_.DUPLICATE_DIAGRAMVIEW_FIELD = 3085] = "DUPLICATE_DIAGRAMVIEW_FIELD", _[_.BINDING_ERROR = 4e3] = "BINDING_ERROR", _[_.UNSUPPORTED = 5e3] = "UNSUPPORTED", _[_.CIRCULAR_REF = 5001] = "CIRCULAR_REF", _[_.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", _[_.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", _[_.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", _[_.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", _;
|
|
2464
2479
|
}({}), CompileError = class _ extends Error {
|
|
2465
2480
|
constructor(HY, P, UY) {
|
|
2466
2481
|
super(P), this.code = HY, this.diagnostic = P, this.nodeOrToken = UY, this.start = UY.start, this.end = UY.end, this.name = this.constructor.name, Object.setPrototypeOf(this, _.prototype);
|
|
@@ -2565,7 +2580,7 @@ var Some = class _ {
|
|
|
2565
2580
|
"true",
|
|
2566
2581
|
"false"
|
|
2567
2582
|
], NUMERIC_LITERAL_PREFIX = ["-", "+"], DEFAULT_SCHEMA_NAME$1 = "public", ElementKind = /* @__PURE__ */ function(_) {
|
|
2568
|
-
return _.Table = "table", _.Enum = "enum", _.Ref = "ref", _.Note = "note", _.Project = "project", _.Indexes = "indexes", _.TableGroup = "tablegroup", _.TablePartial = "tablepartial", _.Check = "checks", _.Records = "records", _;
|
|
2583
|
+
return _.Table = "table", _.Enum = "enum", _.Ref = "ref", _.Note = "note", _.Project = "project", _.Indexes = "indexes", _.TableGroup = "tablegroup", _.TablePartial = "tablepartial", _.Check = "checks", _.Records = "records", _.DiagramView = "diagramview", _;
|
|
2569
2584
|
}({}), SettingName = /* @__PURE__ */ function(_) {
|
|
2570
2585
|
return _.Color = "color", _.HeaderColor = "headercolor", _.Note = "note", _.PK = "pk", _.PrimaryKey = "primary key", _.Unique = "unique", _.Ref = "ref", _.NotNull = "not null", _.Null = "null", _.Increment = "increment", _.Default = "default", _.Name = "name", _.Type = "type", _.Check = "check", _.Update = "update", _.Delete = "delete", _;
|
|
2571
2586
|
}({}), CustomValidator = class {
|
|
@@ -2573,19 +2588,22 @@ var Some = class _ {
|
|
|
2573
2588
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2574
2589
|
}
|
|
2575
2590
|
validate() {
|
|
2576
|
-
return
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
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
|
+
};
|
|
2583
2601
|
}
|
|
2584
2602
|
validateContext() {
|
|
2585
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)] : [];
|
|
2586
2604
|
}
|
|
2587
2605
|
validateName(_) {
|
|
2588
|
-
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", _)] : [];
|
|
2589
2607
|
}
|
|
2590
2608
|
validateAlias(_) {
|
|
2591
2609
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", _)] : [];
|
|
@@ -2600,7 +2618,7 @@ var Some = class _ {
|
|
|
2600
2618
|
return isExpressionAQuotedString(_.callee) || HY.push(new CompileError(CompileErrorCode.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", _)), _.args.length > 0 && HY.push(..._.args.map((_) => new CompileError(CompileErrorCode.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", _))), HY;
|
|
2601
2619
|
}
|
|
2602
2620
|
}, SymbolKind = /* @__PURE__ */ function(_) {
|
|
2603
|
-
return _.Schema = "Schema", _.Table = "Table", _.Column = "Column", _.TableGroup = "TableGroup", _.TableGroupField = "TableGroup field", _.Enum = "Enum", _.EnumField = "Enum field", _.Note = "Note", _.TablePartial = "TablePartial", _.PartialInjection = "PartialInjection", _;
|
|
2621
|
+
return _.Schema = "Schema", _.Table = "Table", _.Column = "Column", _.TableGroup = "TableGroup", _.TableGroupField = "TableGroup field", _.Enum = "Enum", _.EnumField = "Enum field", _.Note = "Note", _.TablePartial = "TablePartial", _.PartialInjection = "PartialInjection", _.DiagramView = "DiagramView", _.DiagramViewField = "DiagramView field", _;
|
|
2604
2622
|
}({});
|
|
2605
2623
|
function createSchemaSymbolIndex(_) {
|
|
2606
2624
|
return `${SymbolKind.Schema}:${_}`;
|
|
@@ -2632,6 +2650,12 @@ function createTablePartialSymbolIndex(_) {
|
|
|
2632
2650
|
function createPartialInjectionSymbolIndex(_) {
|
|
2633
2651
|
return `${SymbolKind.PartialInjection}:${_}`;
|
|
2634
2652
|
}
|
|
2653
|
+
function createDiagramViewSymbolIndex(_) {
|
|
2654
|
+
return `${SymbolKind.DiagramView}:${_}`;
|
|
2655
|
+
}
|
|
2656
|
+
function createDiagramViewFieldSymbolIndex(_) {
|
|
2657
|
+
return `${SymbolKind.DiagramViewField}:${_}`;
|
|
2658
|
+
}
|
|
2635
2659
|
function createNodeSymbolIndex(_, HY) {
|
|
2636
2660
|
switch (HY) {
|
|
2637
2661
|
case SymbolKind.Column: return createColumnSymbolIndex(_);
|
|
@@ -2641,8 +2665,11 @@ function createNodeSymbolIndex(_, HY) {
|
|
|
2641
2665
|
case SymbolKind.Table: return createTableSymbolIndex(_);
|
|
2642
2666
|
case SymbolKind.TableGroup: return createTableGroupSymbolIndex(_);
|
|
2643
2667
|
case SymbolKind.TableGroupField: return createTableGroupFieldSymbolIndex(_);
|
|
2668
|
+
case SymbolKind.Note: return createStickyNoteSymbolIndex(_);
|
|
2644
2669
|
case SymbolKind.TablePartial: return createTablePartialSymbolIndex(_);
|
|
2645
2670
|
case SymbolKind.PartialInjection: return createPartialInjectionSymbolIndex(_);
|
|
2671
|
+
case SymbolKind.DiagramView: return createDiagramViewSymbolIndex(_);
|
|
2672
|
+
case SymbolKind.DiagramViewField: return createDiagramViewFieldSymbolIndex(_);
|
|
2646
2673
|
default: throw Error("Unreachable");
|
|
2647
2674
|
}
|
|
2648
2675
|
}
|
|
@@ -2677,20 +2704,23 @@ var SymbolTable = class {
|
|
|
2677
2704
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2678
2705
|
}
|
|
2679
2706
|
validate() {
|
|
2680
|
-
return
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
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
|
+
};
|
|
2688
2718
|
}
|
|
2689
2719
|
validateContext() {
|
|
2690
2720
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
2691
2721
|
}
|
|
2692
2722
|
validateName(_) {
|
|
2693
|
-
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)];
|
|
2694
2724
|
}
|
|
2695
2725
|
validateAlias(_) {
|
|
2696
2726
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "An Enum shouldn't have an alias", _)] : [];
|
|
@@ -2741,7 +2771,7 @@ var SymbolTable = class {
|
|
|
2741
2771
|
return P;
|
|
2742
2772
|
}
|
|
2743
2773
|
validateSubElements(_) {
|
|
2744
|
-
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 : []));
|
|
2745
2775
|
}
|
|
2746
2776
|
registerField(_) {
|
|
2747
2777
|
if (_.callee && isExpressionAVariableNode(_.callee)) {
|
|
@@ -2761,13 +2791,16 @@ var SymbolTable = class {
|
|
|
2761
2791
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2762
2792
|
}
|
|
2763
2793
|
validate() {
|
|
2764
|
-
return
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
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
|
+
};
|
|
2771
2804
|
}
|
|
2772
2805
|
validateContext() {
|
|
2773
2806
|
let _ = new CompileError(CompileErrorCode.INVALID_INDEXES_CONTEXT, "An Indexes can only appear inside a Table or a TablePartial", this.declarationNode);
|
|
@@ -2776,7 +2809,7 @@ var SymbolTable = class {
|
|
|
2776
2809
|
return HY && [ElementKind.Table, ElementKind.TablePartial].includes(HY) ? [] : [_];
|
|
2777
2810
|
}
|
|
2778
2811
|
validateName(_) {
|
|
2779
|
-
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", _)] : [];
|
|
2780
2813
|
}
|
|
2781
2814
|
validateAlias(_) {
|
|
2782
2815
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", _)] : [];
|
|
@@ -2828,20 +2861,23 @@ var SymbolTable = class {
|
|
|
2828
2861
|
return P;
|
|
2829
2862
|
}
|
|
2830
2863
|
validateSubElements(_) {
|
|
2831
|
-
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 : []));
|
|
2832
2865
|
}
|
|
2833
2866
|
}, NoteValidator = class {
|
|
2834
2867
|
constructor(_, HY, P) {
|
|
2835
2868
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2836
2869
|
}
|
|
2837
2870
|
validate() {
|
|
2838
|
-
return
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
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
|
+
};
|
|
2845
2881
|
}
|
|
2846
2882
|
validateContext() {
|
|
2847
2883
|
return !(this.declarationNode.parent instanceof ProgramNode) && ![
|
|
@@ -2854,10 +2890,11 @@ var SymbolTable = class {
|
|
|
2854
2890
|
validateName(_) {
|
|
2855
2891
|
if (!(this.declarationNode.parent instanceof ProgramNode)) return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_NAME, "A Note shouldn't have a name", _)] : [];
|
|
2856
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", _)];
|
|
2857
2894
|
let HY = destructureComplexVariable(_);
|
|
2858
2895
|
if (!HY.isOk()) return [new CompileError(CompileErrorCode.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2859
2896
|
let P = HY.unwrap().join("."), UY = createStickyNoteSymbolIndex(P);
|
|
2860
|
-
return this.publicSymbolTable.has(UY) ? [new CompileError(CompileErrorCode.DUPLICATE_NAME, `Sticky note "${P}" has already been defined`, _)] : (this.publicSymbolTable.set(UY, this.declarationNode.symbol), []);
|
|
2897
|
+
return this.publicSymbolTable.has(UY) ? [new CompileError(CompileErrorCode.DUPLICATE_NAME, `Sticky note "${P}" has already been defined`, _)] : (this.declarationNode.symbol = this.symbolFactory.create(StickyNoteSymbol, { declaration: this.declarationNode }), this.publicSymbolTable.set(UY, this.declarationNode.symbol), []);
|
|
2861
2898
|
}
|
|
2862
2899
|
validateAlias(_) {
|
|
2863
2900
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", _)] : [];
|
|
@@ -2876,26 +2913,29 @@ var SymbolTable = class {
|
|
|
2876
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);
|
|
2877
2914
|
}
|
|
2878
2915
|
validateSubElements(_) {
|
|
2879
|
-
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 : []));
|
|
2880
2917
|
}
|
|
2881
2918
|
}, ProjectValidator = class {
|
|
2882
2919
|
constructor(_, HY, P) {
|
|
2883
2920
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2884
2921
|
}
|
|
2885
2922
|
validate() {
|
|
2886
|
-
return
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
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
|
+
};
|
|
2893
2933
|
}
|
|
2894
2934
|
validateContext() {
|
|
2895
2935
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2896
2936
|
}
|
|
2897
2937
|
validateName(_) {
|
|
2898
|
-
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", _)] : [];
|
|
2899
2939
|
}
|
|
2900
2940
|
validateAlias(_) {
|
|
2901
2941
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", _)] : [];
|
|
@@ -2910,26 +2950,29 @@ var SymbolTable = class {
|
|
|
2910
2950
|
return [...HY.map((_) => new CompileError(CompileErrorCode.INVALID_PROJECT_FIELD, "A Project can not have inline fields", _)), ...this.validateSubElements(P)];
|
|
2911
2951
|
}
|
|
2912
2952
|
validateSubElements(_) {
|
|
2913
|
-
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 : []));
|
|
2914
2954
|
}
|
|
2915
2955
|
}, RefValidator = class {
|
|
2916
2956
|
constructor(_, HY, P) {
|
|
2917
2957
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
2918
2958
|
}
|
|
2919
2959
|
validate() {
|
|
2920
|
-
return
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
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
|
+
};
|
|
2927
2970
|
}
|
|
2928
2971
|
validateContext() {
|
|
2929
2972
|
return this.declarationNode.parent instanceof ProgramNode ? [] : [new CompileError(CompileErrorCode.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2930
2973
|
}
|
|
2931
2974
|
validateName(_) {
|
|
2932
|
-
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", _)] : [];
|
|
2933
2976
|
}
|
|
2934
2977
|
validateAlias(_) {
|
|
2935
2978
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", _)] : [];
|
|
@@ -2988,7 +3031,7 @@ var SymbolTable = class {
|
|
|
2988
3031
|
return P;
|
|
2989
3032
|
}
|
|
2990
3033
|
validateSubElements(_) {
|
|
2991
|
-
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 : []));
|
|
2992
3035
|
}
|
|
2993
3036
|
};
|
|
2994
3037
|
function isValidPolicy(_) {
|
|
@@ -3009,20 +3052,23 @@ var TableValidator = class {
|
|
|
3009
3052
|
this.declarationNode = _, this.symbolFactory = P, this.publicSymbolTable = HY;
|
|
3010
3053
|
}
|
|
3011
3054
|
validate() {
|
|
3012
|
-
return
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
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
|
+
};
|
|
3020
3066
|
}
|
|
3021
3067
|
validateContext() {
|
|
3022
3068
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
3023
3069
|
}
|
|
3024
3070
|
validateName(_) {
|
|
3025
|
-
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)];
|
|
3026
3072
|
}
|
|
3027
3073
|
validateAlias(_) {
|
|
3028
3074
|
return _ ? isValidAlias(_) ? [] : [new CompileError(CompileErrorCode.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", _)] : [];
|
|
@@ -3182,7 +3228,7 @@ var TableValidator = class {
|
|
|
3182
3228
|
}), UY;
|
|
3183
3229
|
}
|
|
3184
3230
|
validateSubElements(_) {
|
|
3185
|
-
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");
|
|
3186
3232
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3187
3233
|
}
|
|
3188
3234
|
};
|
|
@@ -3194,20 +3240,23 @@ var TableGroupValidator = class {
|
|
|
3194
3240
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3195
3241
|
}
|
|
3196
3242
|
validate() {
|
|
3197
|
-
return
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
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
|
+
};
|
|
3205
3254
|
}
|
|
3206
3255
|
validateContext() {
|
|
3207
3256
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
3208
3257
|
}
|
|
3209
3258
|
validateName(_) {
|
|
3210
|
-
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)];
|
|
3211
3260
|
}
|
|
3212
3261
|
validateAlias(_) {
|
|
3213
3262
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", _)] : [];
|
|
@@ -3259,7 +3308,7 @@ var TableGroupValidator = class {
|
|
|
3259
3308
|
});
|
|
3260
3309
|
}
|
|
3261
3310
|
validateSubElements(_) {
|
|
3262
|
-
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");
|
|
3263
3312
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3264
3313
|
}
|
|
3265
3314
|
registerField(_) {
|
|
@@ -3280,20 +3329,23 @@ var TableGroupValidator = class {
|
|
|
3280
3329
|
this.declarationNode = _, this.symbolFactory = P, this.publicSymbolTable = HY;
|
|
3281
3330
|
}
|
|
3282
3331
|
validate() {
|
|
3283
|
-
return
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
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
|
+
};
|
|
3291
3343
|
}
|
|
3292
3344
|
validateContext() {
|
|
3293
3345
|
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_TABLE_PARTIAL_CONTEXT, "TablePartial must appear top-level", this.declarationNode)] : [];
|
|
3294
3346
|
}
|
|
3295
3347
|
validateName(_) {
|
|
3296
|
-
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)];
|
|
3297
3349
|
}
|
|
3298
3350
|
validateAlias(_) {
|
|
3299
3351
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A TablePartial shouldn't have an alias", _)] : [];
|
|
@@ -3429,7 +3481,7 @@ var TableGroupValidator = class {
|
|
|
3429
3481
|
}), WY;
|
|
3430
3482
|
}
|
|
3431
3483
|
validateSubElements(_) {
|
|
3432
|
-
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);
|
|
3433
3485
|
return P.length > 1 && HY.push(...P.map((_) => new CompileError(CompileErrorCode.NOTE_REDEFINED, "Duplicate notes are defined", _))), HY;
|
|
3434
3486
|
}
|
|
3435
3487
|
}, ChecksValidator = class {
|
|
@@ -3437,13 +3489,16 @@ var TableGroupValidator = class {
|
|
|
3437
3489
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3438
3490
|
}
|
|
3439
3491
|
validate() {
|
|
3440
|
-
return
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
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
|
+
};
|
|
3447
3502
|
}
|
|
3448
3503
|
validateContext() {
|
|
3449
3504
|
let _ = new CompileError(CompileErrorCode.INVALID_CHECKS_CONTEXT, "A Checks can only appear inside a Table or a TablePartial", this.declarationNode);
|
|
@@ -3452,7 +3507,7 @@ var TableGroupValidator = class {
|
|
|
3452
3507
|
return HY && [ElementKind.Table, ElementKind.TablePartial].includes(HY) ? [] : [_];
|
|
3453
3508
|
}
|
|
3454
3509
|
validateName(_) {
|
|
3455
|
-
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", _)] : [];
|
|
3456
3511
|
}
|
|
3457
3512
|
validateAlias(_) {
|
|
3458
3513
|
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A Checks shouldn't have an alias", _)] : [];
|
|
@@ -3489,27 +3544,30 @@ var TableGroupValidator = class {
|
|
|
3489
3544
|
return P;
|
|
3490
3545
|
}
|
|
3491
3546
|
validateSubElements(_) {
|
|
3492
|
-
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 : []));
|
|
3493
3548
|
}
|
|
3494
3549
|
}, RecordsValidator = class {
|
|
3495
3550
|
constructor(_, HY, P) {
|
|
3496
3551
|
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3497
3552
|
}
|
|
3498
3553
|
validate() {
|
|
3499
|
-
return
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
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
|
+
};
|
|
3506
3564
|
}
|
|
3507
3565
|
validateContext() {
|
|
3508
3566
|
let _ = this.declarationNode.parent;
|
|
3509
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)];
|
|
3510
3568
|
}
|
|
3511
3569
|
validateName(_) {
|
|
3512
|
-
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(_);
|
|
3513
3571
|
}
|
|
3514
3572
|
validateTopLevelName(_) {
|
|
3515
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)];
|
|
@@ -3554,7 +3612,127 @@ var TableGroupValidator = class {
|
|
|
3554
3612
|
return !1;
|
|
3555
3613
|
}
|
|
3556
3614
|
validateSubElements(_) {
|
|
3557
|
-
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 : []));
|
|
3616
|
+
}
|
|
3617
|
+
}, DiagramViewValidator = class {
|
|
3618
|
+
constructor(_, HY, P) {
|
|
3619
|
+
this.declarationNode = _, this.publicSymbolTable = HY, this.symbolFactory = P;
|
|
3620
|
+
}
|
|
3621
|
+
validate() {
|
|
3622
|
+
let _ = [
|
|
3623
|
+
...this.validateContext(),
|
|
3624
|
+
...this.validateName(this.declarationNode.name),
|
|
3625
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
3626
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
3627
|
+
...this.registerElement()
|
|
3628
|
+
], HY = this.validateBody(this.declarationNode.body);
|
|
3629
|
+
return _.push(...HY.errors), {
|
|
3630
|
+
errors: _,
|
|
3631
|
+
warnings: HY.warnings
|
|
3632
|
+
};
|
|
3633
|
+
}
|
|
3634
|
+
validateContext() {
|
|
3635
|
+
return this.declarationNode.parent instanceof ElementDeclarationNode ? [new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_CONTEXT, "DiagramView must appear top-level", this.declarationNode)] : [];
|
|
3636
|
+
}
|
|
3637
|
+
validateName(_) {
|
|
3638
|
+
return _ ? isSimpleName(_) ? [] : [new CompileError(CompileErrorCode.INVALID_NAME, "A DiagramView name must be a single identifier", _)] : [new CompileError(CompileErrorCode.NAME_NOT_FOUND, "A DiagramView must have a name", this.declarationNode)];
|
|
3639
|
+
}
|
|
3640
|
+
validateAlias(_) {
|
|
3641
|
+
return _ ? [new CompileError(CompileErrorCode.UNEXPECTED_ALIAS, "A DiagramView shouldn't have an alias", _)] : [];
|
|
3642
|
+
}
|
|
3643
|
+
registerElement() {
|
|
3644
|
+
let { name: _ } = this.declarationNode;
|
|
3645
|
+
this.declarationNode.symbol = this.symbolFactory.create(DiagramViewSymbol, {
|
|
3646
|
+
declaration: this.declarationNode,
|
|
3647
|
+
symbolTable: new SymbolTable()
|
|
3648
|
+
});
|
|
3649
|
+
let HY = destructureComplexVariable(_);
|
|
3650
|
+
if (HY.isOk()) {
|
|
3651
|
+
let P = HY.unwrap(), UY = P.pop(), WY = registerSchemaStack(P, this.publicSymbolTable, this.symbolFactory), GY = createDiagramViewSymbolIndex(UY);
|
|
3652
|
+
if (WY.has(GY)) return [new CompileError(CompileErrorCode.DUPLICATE_DIAGRAMVIEW_NAME, `DiagramView name '${UY}' already exists`, _)];
|
|
3653
|
+
WY.set(GY, this.declarationNode.symbol);
|
|
3654
|
+
}
|
|
3655
|
+
return [];
|
|
3656
|
+
}
|
|
3657
|
+
validateSettingList(_) {
|
|
3658
|
+
let HY = aggregateSettingList(_), P = HY.getErrors(), UY = HY.getValue();
|
|
3659
|
+
for (let _ of Object.keys(UY)) P.push(...UY[_].map((HY) => new CompileError(CompileErrorCode.UNEXPECTED_SETTINGS, `Unknown '${_}' setting for DiagramView`, HY)));
|
|
3660
|
+
return P;
|
|
3661
|
+
}
|
|
3662
|
+
validateBody(_) {
|
|
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
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
validateFields(_) {
|
|
3678
|
+
return _.flatMap((_) => {
|
|
3679
|
+
if (isWildcardExpression(_.callee)) return _.args.length > 0 ? _.args.map((_) => new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, "DiagramView field should only have a single name", _)) : [];
|
|
3680
|
+
let HY = [];
|
|
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;
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3684
|
+
validateSubElements(_) {
|
|
3685
|
+
let HY = [], P = [], UY = [
|
|
3686
|
+
"tables",
|
|
3687
|
+
"notes",
|
|
3688
|
+
"tablegroups",
|
|
3689
|
+
"schemas"
|
|
3690
|
+
];
|
|
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));
|
|
3696
|
+
continue;
|
|
3697
|
+
}
|
|
3698
|
+
let GY = this.validateSubBlock(WY);
|
|
3699
|
+
HY.push(...GY.errors), P.push(...GY.warnings);
|
|
3700
|
+
}
|
|
3701
|
+
return {
|
|
3702
|
+
errors: HY,
|
|
3703
|
+
warnings: P
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
3706
|
+
validateSubBlock(_) {
|
|
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
|
+
};
|
|
3717
|
+
}
|
|
3718
|
+
registerSubBlockFields(_) {
|
|
3719
|
+
let HY = [];
|
|
3720
|
+
if (!_.body || !(_.body instanceof BlockExpressionNode)) return HY;
|
|
3721
|
+
let P = _.body.body.filter((_) => _ instanceof FunctionApplicationNode);
|
|
3722
|
+
for (let _ of P) {
|
|
3723
|
+
if (_.callee && isExpressionAVariableNode(_.callee)) {
|
|
3724
|
+
if (isWildcardExpression(_.callee)) continue;
|
|
3725
|
+
let P = extractVarNameFromPrimaryVariable(_.callee).unwrap(), UY = createDiagramViewFieldSymbolIndex(P), WY = this.symbolFactory.create(DiagramViewFieldSymbol, { declaration: _ });
|
|
3726
|
+
_.symbol = WY;
|
|
3727
|
+
let GY = this.declarationNode.symbol.symbolTable;
|
|
3728
|
+
if (GY.has(UY)) {
|
|
3729
|
+
let WY = GY.get(UY);
|
|
3730
|
+
HY.push(new CompileError(CompileErrorCode.DUPLICATE_DIAGRAMVIEW_FIELD, `${P} already exists in DiagramView`, _), new CompileError(CompileErrorCode.DUPLICATE_DIAGRAMVIEW_FIELD, `${P} already exists in DiagramView`, WY.declaration));
|
|
3731
|
+
} else GY.set(UY, WY);
|
|
3732
|
+
}
|
|
3733
|
+
_.args.length > 0 && HY.push(..._.args.map((_) => new CompileError(CompileErrorCode.INVALID_DIAGRAMVIEW_FIELD, "DiagramView field should only have a single name", _)));
|
|
3734
|
+
}
|
|
3735
|
+
return HY;
|
|
3558
3736
|
}
|
|
3559
3737
|
};
|
|
3560
3738
|
function pickValidator(_) {
|
|
@@ -3569,6 +3747,7 @@ function pickValidator(_) {
|
|
|
3569
3747
|
case ElementKind.TablePartial: return TablePartialValidator;
|
|
3570
3748
|
case ElementKind.Check: return ChecksValidator;
|
|
3571
3749
|
case ElementKind.Records: return RecordsValidator;
|
|
3750
|
+
case ElementKind.DiagramView: return DiagramViewValidator;
|
|
3572
3751
|
default: return CustomValidator;
|
|
3573
3752
|
}
|
|
3574
3753
|
}
|
|
@@ -3670,7 +3849,8 @@ function getElementKind(_) {
|
|
|
3670
3849
|
case ElementKind.TableGroup:
|
|
3671
3850
|
case ElementKind.TablePartial:
|
|
3672
3851
|
case ElementKind.Check:
|
|
3673
|
-
case ElementKind.Records:
|
|
3852
|
+
case ElementKind.Records:
|
|
3853
|
+
case ElementKind.DiagramView: return new Some(HY);
|
|
3674
3854
|
default: return new None();
|
|
3675
3855
|
}
|
|
3676
3856
|
}
|
|
@@ -3842,6 +4022,7 @@ function getMemberChain(_) {
|
|
|
3842
4022
|
if (_ instanceof CallExpressionNode) return filterUndefined(_.callee, _.argumentList);
|
|
3843
4023
|
if (_ instanceof PrimaryExpressionNode) return filterUndefined(_.expression);
|
|
3844
4024
|
if (_ instanceof ArrayNode) return filterUndefined(_.array, _.indexer);
|
|
4025
|
+
if (_ instanceof WildcardNode) return filterUndefined(_.token);
|
|
3845
4026
|
throw _ instanceof GroupExpressionNode ? Error("This case is already handled by TupleExpressionNode") : Error("Unreachable - no other possible cases");
|
|
3846
4027
|
}
|
|
3847
4028
|
function extractVariableNode(_) {
|
|
@@ -3853,6 +4034,9 @@ function isExpressionAQuotedString(_) {
|
|
|
3853
4034
|
function isExpressionAVariableNode(_) {
|
|
3854
4035
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode && _.expression.variable instanceof SyntaxToken;
|
|
3855
4036
|
}
|
|
4037
|
+
function isWildcardExpression(_) {
|
|
4038
|
+
return _ ? _ instanceof WildcardNode : !1;
|
|
4039
|
+
}
|
|
3856
4040
|
function isExpressionAnIdentifierNode(_) {
|
|
3857
4041
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode && _.expression.variable?.kind === SyntaxTokenKind.IDENTIFIER;
|
|
3858
4042
|
}
|
|
@@ -3964,6 +4148,9 @@ var Lexer = class {
|
|
|
3964
4148
|
case "/":
|
|
3965
4149
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator(_);
|
|
3966
4150
|
break;
|
|
4151
|
+
case "*":
|
|
4152
|
+
this.addToken(SyntaxTokenKind.WILDCARD);
|
|
4153
|
+
break;
|
|
3967
4154
|
default:
|
|
3968
4155
|
if (isOp(_)) {
|
|
3969
4156
|
this.operator(_);
|
|
@@ -4626,7 +4813,7 @@ var Lexer = class {
|
|
|
4626
4813
|
return _;
|
|
4627
4814
|
}
|
|
4628
4815
|
extractOperand() {
|
|
4629
|
-
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() }));
|
|
4630
4817
|
}
|
|
4631
4818
|
functionExpression() {
|
|
4632
4819
|
let _ = {};
|
|
@@ -4687,10 +4874,6 @@ var Lexer = class {
|
|
|
4687
4874
|
left: 9,
|
|
4688
4875
|
right: 10
|
|
4689
4876
|
},
|
|
4690
|
-
"*": {
|
|
4691
|
-
left: 11,
|
|
4692
|
-
right: 12
|
|
4693
|
-
},
|
|
4694
4877
|
"-": {
|
|
4695
4878
|
left: 9,
|
|
4696
4879
|
right: 10
|
|
@@ -4797,14 +4980,14 @@ var Validator = class {
|
|
|
4797
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;
|
|
4798
4981
|
}
|
|
4799
4982
|
validate() {
|
|
4800
|
-
let _ = [];
|
|
4801
|
-
this.ast.body.forEach((
|
|
4802
|
-
if (
|
|
4803
|
-
let
|
|
4804
|
-
_.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);
|
|
4805
4988
|
});
|
|
4806
|
-
let
|
|
4807
|
-
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);
|
|
4808
4991
|
}
|
|
4809
4992
|
}, ChecksBinder = class {
|
|
4810
4993
|
constructor(_, HY, P) {
|
|
@@ -4828,6 +5011,88 @@ var Validator = class {
|
|
|
4828
5011
|
bindSubElements(_) {
|
|
4829
5012
|
return _.flatMap((_) => _.type ? new (pickBinder(_))(_, this.ast, this.symbolFactory).bind() : []);
|
|
4830
5013
|
}
|
|
5014
|
+
}, DiagramViewBinder = class {
|
|
5015
|
+
constructor(_, HY, P) {
|
|
5016
|
+
this.declarationNode = _, this.ast = HY, this.symbolFactory = P;
|
|
5017
|
+
}
|
|
5018
|
+
bind() {
|
|
5019
|
+
return this.declarationNode.body instanceof BlockExpressionNode ? this.bindBody(this.declarationNode.body) : [];
|
|
5020
|
+
}
|
|
5021
|
+
bindBody(_) {
|
|
5022
|
+
let [, HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5023
|
+
return this.bindSubElements(HY);
|
|
5024
|
+
}
|
|
5025
|
+
bindSubElements(_) {
|
|
5026
|
+
return _.flatMap((_) => {
|
|
5027
|
+
if (!_.type) return [];
|
|
5028
|
+
let HY = _.type.value.toLowerCase();
|
|
5029
|
+
if (!(_.body instanceof BlockExpressionNode)) return [];
|
|
5030
|
+
let P = [];
|
|
5031
|
+
switch (HY) {
|
|
5032
|
+
case "tables":
|
|
5033
|
+
P.push(...this.bindTableReferences(_.body));
|
|
5034
|
+
break;
|
|
5035
|
+
case "notes":
|
|
5036
|
+
P.push(...this.bindNoteReferences(_.body));
|
|
5037
|
+
break;
|
|
5038
|
+
case "tablegroups":
|
|
5039
|
+
P.push(...this.bindTableGroupReferences(_.body));
|
|
5040
|
+
break;
|
|
5041
|
+
case "schemas":
|
|
5042
|
+
P.push(...this.bindSchemaReferences(_.body));
|
|
5043
|
+
break;
|
|
5044
|
+
default: break;
|
|
5045
|
+
}
|
|
5046
|
+
return P;
|
|
5047
|
+
});
|
|
5048
|
+
}
|
|
5049
|
+
bindTableReferences(_) {
|
|
5050
|
+
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5051
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : [_.callee, ..._.args].flatMap(scanNonListNodeForBinding).flatMap((_) => {
|
|
5052
|
+
let HY = _.variables.pop();
|
|
5053
|
+
if (!HY) return [];
|
|
5054
|
+
let P = _.variables;
|
|
5055
|
+
return lookupAndBindInScope(this.ast, [...P.map((_) => ({
|
|
5056
|
+
node: _,
|
|
5057
|
+
kind: SymbolKind.Schema
|
|
5058
|
+
})), {
|
|
5059
|
+
node: HY,
|
|
5060
|
+
kind: SymbolKind.Table
|
|
5061
|
+
}]);
|
|
5062
|
+
}));
|
|
5063
|
+
}
|
|
5064
|
+
bindNoteReferences(_) {
|
|
5065
|
+
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5066
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => {
|
|
5067
|
+
let HY = _.variables.pop();
|
|
5068
|
+
return HY ? lookupAndBindInScope(this.ast, [{
|
|
5069
|
+
node: HY,
|
|
5070
|
+
kind: SymbolKind.Note
|
|
5071
|
+
}]) : [];
|
|
5072
|
+
}));
|
|
5073
|
+
}
|
|
5074
|
+
bindTableGroupReferences(_) {
|
|
5075
|
+
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5076
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => {
|
|
5077
|
+
let HY = _.variables.pop();
|
|
5078
|
+
if (!HY) return [];
|
|
5079
|
+
let P = _.variables;
|
|
5080
|
+
return lookupAndBindInScope(this.ast, [...P.map((_) => ({
|
|
5081
|
+
node: _,
|
|
5082
|
+
kind: SymbolKind.Schema
|
|
5083
|
+
})), {
|
|
5084
|
+
node: HY,
|
|
5085
|
+
kind: SymbolKind.TableGroup
|
|
5086
|
+
}]);
|
|
5087
|
+
}));
|
|
5088
|
+
}
|
|
5089
|
+
bindSchemaReferences(_) {
|
|
5090
|
+
let [HY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
5091
|
+
return HY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : scanNonListNodeForBinding(_.callee).flatMap((_) => lookupAndBindInScope(this.ast, _.variables.map((_) => ({
|
|
5092
|
+
node: _,
|
|
5093
|
+
kind: SymbolKind.Schema
|
|
5094
|
+
})))));
|
|
5095
|
+
}
|
|
4831
5096
|
}, EnumBinder = class {
|
|
4832
5097
|
constructor(_, HY, P) {
|
|
4833
5098
|
this.declarationNode = _, this.ast = HY, this.symbolFactory = P;
|
|
@@ -5157,7 +5422,9 @@ function generatePossibleIndexes(_) {
|
|
|
5157
5422
|
createEnumFieldSymbolIndex,
|
|
5158
5423
|
createTableGroupFieldSymbolIndex,
|
|
5159
5424
|
createTablePartialSymbolIndex,
|
|
5160
|
-
createPartialInjectionSymbolIndex
|
|
5425
|
+
createPartialInjectionSymbolIndex,
|
|
5426
|
+
createDiagramViewSymbolIndex,
|
|
5427
|
+
createDiagramViewFieldSymbolIndex
|
|
5161
5428
|
].map((HY) => HY(_));
|
|
5162
5429
|
}
|
|
5163
5430
|
function getSymbolKind(_) {
|
|
@@ -5171,6 +5438,9 @@ function getSymbolKind(_) {
|
|
|
5171
5438
|
if (_ instanceof TablePartialSymbol) return SymbolKind.TablePartial;
|
|
5172
5439
|
if (_ instanceof TablePartialInjectedColumnSymbol) return SymbolKind.Column;
|
|
5173
5440
|
if (_ instanceof PartialInjectionSymbol) return SymbolKind.PartialInjection;
|
|
5441
|
+
if (_ instanceof StickyNoteSymbol) return SymbolKind.Note;
|
|
5442
|
+
if (_ instanceof DiagramViewSymbol) return SymbolKind.DiagramView;
|
|
5443
|
+
if (_ instanceof DiagramViewFieldSymbol) return SymbolKind.DiagramViewField;
|
|
5174
5444
|
throw Error("No other possible symbol kind in getSymbolKind");
|
|
5175
5445
|
}
|
|
5176
5446
|
var RecordsBinder = class {
|
|
@@ -5274,6 +5544,7 @@ function pickBinder(_) {
|
|
|
5274
5544
|
case ElementKind.TablePartial: return TablePartialBinder;
|
|
5275
5545
|
case ElementKind.Check: return ChecksBinder;
|
|
5276
5546
|
case ElementKind.Records: return RecordsBinder;
|
|
5547
|
+
case ElementKind.DiagramView: return DiagramViewBinder;
|
|
5277
5548
|
default: return CustomBinder;
|
|
5278
5549
|
}
|
|
5279
5550
|
}
|
|
@@ -6114,6 +6385,112 @@ var TableInterpreter = class {
|
|
|
6114
6385
|
}
|
|
6115
6386
|
});
|
|
6116
6387
|
}
|
|
6388
|
+
}, DiagramViewInterpreter = class {
|
|
6389
|
+
constructor(_, HY) {
|
|
6390
|
+
this.declarationNode = _, this.env = HY, this.diagramView = { visibleEntities: {
|
|
6391
|
+
tables: null,
|
|
6392
|
+
stickyNotes: null,
|
|
6393
|
+
tableGroups: null,
|
|
6394
|
+
schemas: null
|
|
6395
|
+
} };
|
|
6396
|
+
}
|
|
6397
|
+
interpret() {
|
|
6398
|
+
let _ = [];
|
|
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)), _;
|
|
6400
|
+
}
|
|
6401
|
+
interpretName(_) {
|
|
6402
|
+
let HY = destructureComplexVariable(_).unwrap_or([]);
|
|
6403
|
+
return HY.length > 0 && (this.diagramView.name = HY[HY.length - 1], HY.length > 1 && (this.diagramView.schemaName = HY.slice(0, -1).join("."))), [];
|
|
6404
|
+
}
|
|
6405
|
+
interpretBody(_) {
|
|
6406
|
+
if (_.body.length === 1) {
|
|
6407
|
+
let HY = _.body[0];
|
|
6408
|
+
if (HY instanceof FunctionApplicationNode && isWildcardExpression(HY.callee)) return this.diagramView.visibleEntities = {
|
|
6409
|
+
tables: [],
|
|
6410
|
+
stickyNotes: [],
|
|
6411
|
+
tableGroups: [],
|
|
6412
|
+
schemas: []
|
|
6413
|
+
}, this.env.diagramViewWildcards.set(this.diagramView, new Set([
|
|
6414
|
+
"tables",
|
|
6415
|
+
"stickyNotes",
|
|
6416
|
+
"tableGroups",
|
|
6417
|
+
"schemas"
|
|
6418
|
+
])), this.env.diagramViewExplicitlySet.set(this.diagramView, new Set([
|
|
6419
|
+
"tables",
|
|
6420
|
+
"stickyNotes",
|
|
6421
|
+
"tableGroups",
|
|
6422
|
+
"schemas"
|
|
6423
|
+
])), [];
|
|
6424
|
+
}
|
|
6425
|
+
let [HY] = partition_default(_.body, (_) => _ instanceof ElementDeclarationNode), P = /* @__PURE__ */ new Set();
|
|
6426
|
+
for (let _ of HY) {
|
|
6427
|
+
let HY = _.type?.value.toLowerCase();
|
|
6428
|
+
HY && P.add(HY), _.body instanceof BlockExpressionNode && this.interpretSubBlock(_.body, HY);
|
|
6429
|
+
}
|
|
6430
|
+
let UY = this.diagramView.visibleEntities;
|
|
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"), [];
|
|
6434
|
+
}
|
|
6435
|
+
interpretSubBlock(_, HY) {
|
|
6436
|
+
if (!HY) return;
|
|
6437
|
+
if (_.body.some((_) => _ instanceof FunctionApplicationNode && isWildcardExpression(_.callee))) {
|
|
6438
|
+
let _ = this.env.diagramViewWildcards.get(this.diagramView);
|
|
6439
|
+
switch (HY) {
|
|
6440
|
+
case "tables":
|
|
6441
|
+
this.diagramView.visibleEntities.tables = [], _.add("tables");
|
|
6442
|
+
break;
|
|
6443
|
+
case "notes":
|
|
6444
|
+
this.diagramView.visibleEntities.stickyNotes = [], _.add("stickyNotes");
|
|
6445
|
+
break;
|
|
6446
|
+
case "tablegroups":
|
|
6447
|
+
this.diagramView.visibleEntities.tableGroups = [], _.add("tableGroups");
|
|
6448
|
+
break;
|
|
6449
|
+
case "schemas":
|
|
6450
|
+
this.diagramView.visibleEntities.schemas = [], _.add("schemas");
|
|
6451
|
+
break;
|
|
6452
|
+
}
|
|
6453
|
+
return;
|
|
6454
|
+
}
|
|
6455
|
+
if (_.body.length === 0) return;
|
|
6456
|
+
let P = [];
|
|
6457
|
+
for (let HY of _.body) {
|
|
6458
|
+
if (!(HY instanceof FunctionApplicationNode)) continue;
|
|
6459
|
+
let _ = extractReferee(HY.callee);
|
|
6460
|
+
if (_?.declaration instanceof ElementDeclarationNode) {
|
|
6461
|
+
let HY = destructureComplexVariable(_.declaration.name).unwrap_or([]);
|
|
6462
|
+
if (HY.length > 0) {
|
|
6463
|
+
let _ = HY[HY.length - 1], UY = HY.length > 1 ? HY.slice(0, -1).join(".") : DEFAULT_SCHEMA_NAME$1;
|
|
6464
|
+
P.push({
|
|
6465
|
+
name: _,
|
|
6466
|
+
schemaName: UY
|
|
6467
|
+
});
|
|
6468
|
+
continue;
|
|
6469
|
+
}
|
|
6470
|
+
}
|
|
6471
|
+
let UY = destructureComplexVariable(HY.callee).unwrap_or([]);
|
|
6472
|
+
if (UY.length === 0) continue;
|
|
6473
|
+
let WY = UY[UY.length - 1], GY = UY.length > 1 ? UY[0] : DEFAULT_SCHEMA_NAME$1;
|
|
6474
|
+
P.push({
|
|
6475
|
+
name: WY,
|
|
6476
|
+
schemaName: GY
|
|
6477
|
+
});
|
|
6478
|
+
}
|
|
6479
|
+
switch (HY) {
|
|
6480
|
+
case "tables":
|
|
6481
|
+
this.diagramView.visibleEntities.tables = P.length > 0 ? P : null;
|
|
6482
|
+
break;
|
|
6483
|
+
case "notes":
|
|
6484
|
+
this.diagramView.visibleEntities.stickyNotes = P.length > 0 ? P.map((_) => ({ name: _.name })) : null;
|
|
6485
|
+
break;
|
|
6486
|
+
case "tablegroups":
|
|
6487
|
+
this.diagramView.visibleEntities.tableGroups = P.length > 0 ? P.map((_) => ({ name: _.name })) : null;
|
|
6488
|
+
break;
|
|
6489
|
+
case "schemas":
|
|
6490
|
+
this.diagramView.visibleEntities.schemas = P.length > 0 ? P.map((_) => ({ name: _.name })) : null;
|
|
6491
|
+
break;
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6117
6494
|
}, DIALECT_INTEGER_TYPES = {
|
|
6118
6495
|
mysql: new Set([
|
|
6119
6496
|
"int",
|
|
@@ -10196,6 +10573,12 @@ function processColumnInDb(_) {
|
|
|
10196
10573
|
}))
|
|
10197
10574
|
};
|
|
10198
10575
|
}
|
|
10576
|
+
function expandDiagramViewWildcards(_) {
|
|
10577
|
+
for (let HY of _.diagramViews.values()) {
|
|
10578
|
+
let P = HY.visibleEntities, UY = _.diagramViewWildcards.get(HY), WY = _.diagramViewExplicitlySet.get(HY);
|
|
10579
|
+
!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 }))));
|
|
10580
|
+
}
|
|
10581
|
+
}
|
|
10199
10582
|
function convertEnvToDb(_) {
|
|
10200
10583
|
let HY = [];
|
|
10201
10584
|
for (let [P, UY] of _.records) {
|
|
@@ -10227,7 +10610,8 @@ function convertEnvToDb(_) {
|
|
|
10227
10610
|
aliases: _.aliases,
|
|
10228
10611
|
project: Array.from(_.project.values())[0] || {},
|
|
10229
10612
|
tablePartials: Array.from(_.tablePartials.values()).map(processColumnInDb),
|
|
10230
|
-
records: HY
|
|
10613
|
+
records: HY,
|
|
10614
|
+
diagramViews: Array.from(_.diagramViews.values())
|
|
10231
10615
|
};
|
|
10232
10616
|
}
|
|
10233
10617
|
var Interpreter = class {
|
|
@@ -10247,7 +10631,10 @@ var Interpreter = class {
|
|
|
10247
10631
|
records: /* @__PURE__ */ new Map(),
|
|
10248
10632
|
recordsElements: [],
|
|
10249
10633
|
cachedMergedTables: /* @__PURE__ */ new Map(),
|
|
10250
|
-
source: _.source
|
|
10634
|
+
source: _.source,
|
|
10635
|
+
diagramViews: /* @__PURE__ */ new Map(),
|
|
10636
|
+
diagramViewWildcards: /* @__PURE__ */ new Map(),
|
|
10637
|
+
diagramViewExplicitlySet: /* @__PURE__ */ new Map()
|
|
10251
10638
|
};
|
|
10252
10639
|
}
|
|
10253
10640
|
interpret() {
|
|
@@ -10260,6 +10647,7 @@ var Interpreter = class {
|
|
|
10260
10647
|
case ElementKind.TablePartial: return new TablePartialInterpreter(_, this.env).interpret();
|
|
10261
10648
|
case ElementKind.Enum: return new EnumInterpreter(_, this.env).interpret();
|
|
10262
10649
|
case ElementKind.Project: return new ProjectInterpreter(_, this.env).interpret();
|
|
10650
|
+
case ElementKind.DiagramView: return new DiagramViewInterpreter(_, this.env).interpret();
|
|
10263
10651
|
case ElementKind.Records: return this.env.recordsElements.push(_), [];
|
|
10264
10652
|
default: return [];
|
|
10265
10653
|
}
|
|
@@ -10268,7 +10656,7 @@ var Interpreter = class {
|
|
|
10268
10656
|
let P = new RecordsInterpreter(this.env).interpret(this.env.recordsElements);
|
|
10269
10657
|
_.push(...P.getErrors()), HY.push(...P.getWarnings());
|
|
10270
10658
|
}
|
|
10271
|
-
return new Report(convertEnvToDb(this.env), _, HY);
|
|
10659
|
+
return expandDiagramViewWildcards(this.env), new Report(convertEnvToDb(this.env), _, HY);
|
|
10272
10660
|
}
|
|
10273
10661
|
}, CompletionItemKind = /* @__PURE__ */ function(_) {
|
|
10274
10662
|
return _[_.Function = 1] = "Function", _[_.Constructor = 2] = "Constructor", _[_.Field = 3] = "Field", _[_.Variable = 4] = "Variable", _[_.Class = 5] = "Class", _[_.Struct = 6] = "Struct", _[_.Interface = 7] = "Interface", _[_.Module = 8] = "Module", _[_.Property = 9] = "Property", _[_.Event = 10] = "Event", _[_.Operator = 11] = "Operator", _[_.Unit = 12] = "Unit", _[_.Value = 13] = "Value", _[_.Constant = 14] = "Constant", _[_.Enum = 15] = "Enum", _[_.EnumMember = 16] = "EnumMember", _[_.Keyword = 17] = "Keyword", _[_.Text = 18] = "Text", _[_.Color = 19] = "Color", _[_.File = 20] = "File", _[_.Reference = 21] = "Reference", _[_.Customcolor = 22] = "Customcolor", _[_.Folder = 23] = "Folder", _[_.TypeParameter = 24] = "TypeParameter", _[_.User = 25] = "User", _[_.Issue = 26] = "Issue", _[_.Snippet = 27] = "Snippet", _;
|
|
@@ -10787,6 +11175,11 @@ function suggestInSubField(_, HY, P) {
|
|
|
10787
11175
|
return _.container.token(HY).token?.kind === SyntaxTokenKind.COLON && shouldPrependSpace(_.container.token(HY).token, HY) ? prependSpace(P) : P;
|
|
10788
11176
|
}
|
|
10789
11177
|
case ScopeKind.TABLEGROUP: return suggestInTableGroupField(_);
|
|
11178
|
+
case ScopeKind.DIAGRAMVIEW: return suggestInDiagramViewField();
|
|
11179
|
+
case ScopeKind.CUSTOM: {
|
|
11180
|
+
let P = _.container.element(HY);
|
|
11181
|
+
return P instanceof ElementDeclarationNode && P.parent instanceof ElementDeclarationNode && getElementKind(P.parent).unwrap_or(void 0) === ElementKind.DiagramView ? suggestInDiagramViewSubBlock(_, HY) : noSuggestions();
|
|
11182
|
+
}
|
|
10790
11183
|
default: return noSuggestions();
|
|
10791
11184
|
}
|
|
10792
11185
|
}
|
|
@@ -10798,7 +11191,8 @@ function suggestTopLevelElementType() {
|
|
|
10798
11191
|
"Project",
|
|
10799
11192
|
"Ref",
|
|
10800
11193
|
"TablePartial",
|
|
10801
|
-
"Records"
|
|
11194
|
+
"Records",
|
|
11195
|
+
"DiagramView"
|
|
10802
11196
|
].map((_) => ({
|
|
10803
11197
|
label: _,
|
|
10804
11198
|
insertText: _,
|
|
@@ -10905,6 +11299,54 @@ function suggestInTableGroupField(_) {
|
|
|
10905
11299
|
range: void 0
|
|
10906
11300
|
}))] };
|
|
10907
11301
|
}
|
|
11302
|
+
function suggestInDiagramViewField() {
|
|
11303
|
+
return { suggestions: [...[
|
|
11304
|
+
"Tables",
|
|
11305
|
+
"TableGroups",
|
|
11306
|
+
"Notes",
|
|
11307
|
+
"Schemas"
|
|
11308
|
+
].map((_) => ({
|
|
11309
|
+
label: _,
|
|
11310
|
+
insertText: _,
|
|
11311
|
+
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11312
|
+
kind: CompletionItemKind.Keyword,
|
|
11313
|
+
range: void 0
|
|
11314
|
+
})), {
|
|
11315
|
+
label: "*",
|
|
11316
|
+
insertText: "*",
|
|
11317
|
+
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11318
|
+
kind: CompletionItemKind.Keyword,
|
|
11319
|
+
range: void 0
|
|
11320
|
+
}] };
|
|
11321
|
+
}
|
|
11322
|
+
function suggestInDiagramViewSubBlock(_, HY) {
|
|
11323
|
+
let P = _.container.element(HY);
|
|
11324
|
+
if (!(P instanceof ElementDeclarationNode)) return noSuggestions();
|
|
11325
|
+
let UY = P.type?.value.toLowerCase(), WY = {
|
|
11326
|
+
label: "*",
|
|
11327
|
+
insertText: "*",
|
|
11328
|
+
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11329
|
+
kind: CompletionItemKind.Keyword,
|
|
11330
|
+
range: void 0
|
|
11331
|
+
};
|
|
11332
|
+
switch (UY) {
|
|
11333
|
+
case "tables": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Table, SymbolKind.Schema]).suggestions] };
|
|
11334
|
+
case "tablegroups": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.TableGroup]).suggestions] };
|
|
11335
|
+
case "schemas": return { suggestions: [
|
|
11336
|
+
WY,
|
|
11337
|
+
{
|
|
11338
|
+
label: DEFAULT_SCHEMA_NAME$1,
|
|
11339
|
+
insertText: DEFAULT_SCHEMA_NAME$1,
|
|
11340
|
+
insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
|
|
11341
|
+
kind: CompletionItemKind.Module,
|
|
11342
|
+
range: void 0
|
|
11343
|
+
},
|
|
11344
|
+
...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Schema]).suggestions
|
|
11345
|
+
] };
|
|
11346
|
+
case "notes": return { suggestions: [WY, ...suggestNamesInScope(_, HY, _.parse.ast(), [SymbolKind.Note]).suggestions] };
|
|
11347
|
+
default: return noSuggestions();
|
|
11348
|
+
}
|
|
11349
|
+
}
|
|
10908
11350
|
function suggestInIndex(_, HY) {
|
|
10909
11351
|
return suggestColumnNameInIndexes(_, HY);
|
|
10910
11352
|
}
|
|
@@ -11035,6 +11477,200 @@ var DBMLDefinitionProvider = class {
|
|
|
11035
11477
|
getSeverityValue(_) {
|
|
11036
11478
|
return _ === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning;
|
|
11037
11479
|
}
|
|
11480
|
+
}, dbmlMonarchTokensProvider = {
|
|
11481
|
+
tokenPostfix: ".dbml",
|
|
11482
|
+
brackets: [
|
|
11483
|
+
{
|
|
11484
|
+
open: "[",
|
|
11485
|
+
close: "]",
|
|
11486
|
+
token: "delimiter.square"
|
|
11487
|
+
},
|
|
11488
|
+
{
|
|
11489
|
+
open: "(",
|
|
11490
|
+
close: ")",
|
|
11491
|
+
token: "delimiter.parenthesis"
|
|
11492
|
+
},
|
|
11493
|
+
{
|
|
11494
|
+
open: "{",
|
|
11495
|
+
close: "}",
|
|
11496
|
+
token: "delimiter.curly"
|
|
11497
|
+
}
|
|
11498
|
+
],
|
|
11499
|
+
decls: [
|
|
11500
|
+
"project",
|
|
11501
|
+
"tablegroup",
|
|
11502
|
+
"table",
|
|
11503
|
+
"enum",
|
|
11504
|
+
"ref",
|
|
11505
|
+
"note",
|
|
11506
|
+
"tablepartial",
|
|
11507
|
+
"records",
|
|
11508
|
+
"checks",
|
|
11509
|
+
"diagramview"
|
|
11510
|
+
],
|
|
11511
|
+
dataTypes: /* @__PURE__ */ "TINYINT.SMALLINT.MEDIUMINT.INT.INTEGER.BIGINT.FLOAT.DOUBLE.DECIMAL.DEC.BIT.BOOL.REAL.MONEY.BINARY_FLOAT.BINARY_DOUBLE.smallmoney.ENUM.CHAR.BINARY.VARCHAR.VARBINARY.TINYBLOB.TINYTEXT.BLOB.TEXT.MEDIUMBLOB.MEDIUMTEXT.LONGBLOB.LONGTEXT.SET.INET6.UUID.NVARCHAR.NCHAR.NTEXT.IMAGE.VARCHAR2.NVARCHAR2.DATE.TIME.DATETIME.DATETIME2.TIMESTAMP.YEAR.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW".split("."),
|
|
11512
|
+
settings: [
|
|
11513
|
+
"indexes",
|
|
11514
|
+
"ref",
|
|
11515
|
+
"note",
|
|
11516
|
+
"headercolor",
|
|
11517
|
+
"pk",
|
|
11518
|
+
"null",
|
|
11519
|
+
"increment",
|
|
11520
|
+
"unique",
|
|
11521
|
+
"default",
|
|
11522
|
+
"note",
|
|
11523
|
+
"primary",
|
|
11524
|
+
"key",
|
|
11525
|
+
"name",
|
|
11526
|
+
"as",
|
|
11527
|
+
"color",
|
|
11528
|
+
"check",
|
|
11529
|
+
"tables",
|
|
11530
|
+
"tablegroups",
|
|
11531
|
+
"notes",
|
|
11532
|
+
"schemas"
|
|
11533
|
+
],
|
|
11534
|
+
symbols: /[=><!~?:&|+\-\/\^%]+/,
|
|
11535
|
+
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
11536
|
+
newline: /[\r\n]/,
|
|
11537
|
+
digits: /\d+(_+\d+)*/,
|
|
11538
|
+
idtf: /[\p{L}0-9_]+/u,
|
|
11539
|
+
ignoreCase: !0,
|
|
11540
|
+
unicode: !0,
|
|
11541
|
+
tokenizer: {
|
|
11542
|
+
root: [
|
|
11543
|
+
[/[{}\[\]\(\)]/, "@bracket"],
|
|
11544
|
+
[/[,.:]/, "delimiter"],
|
|
11545
|
+
{ include: "@numbers" },
|
|
11546
|
+
{ include: "common" }
|
|
11547
|
+
],
|
|
11548
|
+
common: [
|
|
11549
|
+
{ include: "@whitespace" },
|
|
11550
|
+
[/[<>-]/, "operators"],
|
|
11551
|
+
[/\*/, "keyword.wildcard"],
|
|
11552
|
+
[/("[^"\\]*(?:\\.[^"\\]*)*")(\s+)(@idtf(?:\.@idtf*)*)/, [
|
|
11553
|
+
"string",
|
|
11554
|
+
"",
|
|
11555
|
+
"keyword"
|
|
11556
|
+
]],
|
|
11557
|
+
[/"([^"\\]|\\.)*$/, ""],
|
|
11558
|
+
[/'([^'\\]|\\.)*$/, ""],
|
|
11559
|
+
[
|
|
11560
|
+
/"/,
|
|
11561
|
+
"string",
|
|
11562
|
+
"@string_double"
|
|
11563
|
+
],
|
|
11564
|
+
[
|
|
11565
|
+
/'/,
|
|
11566
|
+
"string",
|
|
11567
|
+
"@string_single"
|
|
11568
|
+
],
|
|
11569
|
+
[
|
|
11570
|
+
/`/,
|
|
11571
|
+
"string",
|
|
11572
|
+
"@string_backtick"
|
|
11573
|
+
],
|
|
11574
|
+
[/(@idtf)(\s+)(@idtf(?:\.@idtf)*)/, { cases: {
|
|
11575
|
+
"$1@decls": [
|
|
11576
|
+
"keyword",
|
|
11577
|
+
"",
|
|
11578
|
+
"identifier"
|
|
11579
|
+
],
|
|
11580
|
+
"$1==not": { cases: {
|
|
11581
|
+
"$3==null": [
|
|
11582
|
+
"keyword",
|
|
11583
|
+
"",
|
|
11584
|
+
"keyword"
|
|
11585
|
+
],
|
|
11586
|
+
"@default": [
|
|
11587
|
+
"identifier",
|
|
11588
|
+
"",
|
|
11589
|
+
"identifier"
|
|
11590
|
+
]
|
|
11591
|
+
} },
|
|
11592
|
+
"@default": [
|
|
11593
|
+
"identifier",
|
|
11594
|
+
"",
|
|
11595
|
+
"keyword"
|
|
11596
|
+
]
|
|
11597
|
+
} }],
|
|
11598
|
+
[/@idtf/, { cases: {
|
|
11599
|
+
"@dataTypes": "keyword",
|
|
11600
|
+
"@decls": "keyword",
|
|
11601
|
+
"@settings": "keyword",
|
|
11602
|
+
"@default": "identifier"
|
|
11603
|
+
} }]
|
|
11604
|
+
],
|
|
11605
|
+
numbers: [
|
|
11606
|
+
[/0[xX][0-9a-fA-F]*/, "number"],
|
|
11607
|
+
[/[$][+-]*\d*(\.\d*)?/, "number"],
|
|
11608
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, "number"],
|
|
11609
|
+
[/#([0-9A-F]{3}){1,2}/, "number.hex"]
|
|
11610
|
+
],
|
|
11611
|
+
string_double: [
|
|
11612
|
+
[/[^\\"]+/, "string"],
|
|
11613
|
+
[/@escapes/, "string.escape"],
|
|
11614
|
+
[/\\./, "string.escape.invalid"],
|
|
11615
|
+
[
|
|
11616
|
+
/"/,
|
|
11617
|
+
"string",
|
|
11618
|
+
"@pop"
|
|
11619
|
+
]
|
|
11620
|
+
],
|
|
11621
|
+
string_single: [
|
|
11622
|
+
[/[^\\']+/, "string"],
|
|
11623
|
+
[/@escapes/, "string.escape"],
|
|
11624
|
+
[/\\./, "string.escape.invalid"],
|
|
11625
|
+
[
|
|
11626
|
+
/'/,
|
|
11627
|
+
"string",
|
|
11628
|
+
"@pop"
|
|
11629
|
+
]
|
|
11630
|
+
],
|
|
11631
|
+
string_backtick: [
|
|
11632
|
+
[/[^\\`$]+/, "string"],
|
|
11633
|
+
[/@escapes/, "string.escape"],
|
|
11634
|
+
[
|
|
11635
|
+
/`/,
|
|
11636
|
+
"string",
|
|
11637
|
+
"@pop"
|
|
11638
|
+
]
|
|
11639
|
+
],
|
|
11640
|
+
endTripleQuotesString: [
|
|
11641
|
+
[/\\'/, "string"],
|
|
11642
|
+
[
|
|
11643
|
+
/(.*[^\\])?(\\\\)*'''/,
|
|
11644
|
+
"string",
|
|
11645
|
+
"@popall"
|
|
11646
|
+
],
|
|
11647
|
+
[/.*$/, "string"]
|
|
11648
|
+
],
|
|
11649
|
+
whitespace: [
|
|
11650
|
+
[/[ \t\r\n]+/, ""],
|
|
11651
|
+
[
|
|
11652
|
+
/\/\*/,
|
|
11653
|
+
"comment",
|
|
11654
|
+
"@comment"
|
|
11655
|
+
],
|
|
11656
|
+
[/\/\/.*$/, "comment"],
|
|
11657
|
+
[/'''(.*[^\\])?(\\\\)*'''/, "string"],
|
|
11658
|
+
[
|
|
11659
|
+
/'''.*$/,
|
|
11660
|
+
"string",
|
|
11661
|
+
"@endTripleQuotesString"
|
|
11662
|
+
]
|
|
11663
|
+
],
|
|
11664
|
+
comment: [
|
|
11665
|
+
[/[^\/*]+/, "comment"],
|
|
11666
|
+
[
|
|
11667
|
+
/\*\//,
|
|
11668
|
+
"comment",
|
|
11669
|
+
"@pop"
|
|
11670
|
+
],
|
|
11671
|
+
[/[\/*]/, "comment"]
|
|
11672
|
+
]
|
|
11673
|
+
}
|
|
11038
11674
|
};
|
|
11039
11675
|
function ast() {
|
|
11040
11676
|
return this.parse._().getValue().ast;
|
|
@@ -11133,7 +11769,7 @@ function containerScope(_) {
|
|
|
11133
11769
|
return this.container.element(_)?.symbol?.symbolTable;
|
|
11134
11770
|
}
|
|
11135
11771
|
var ScopeKind = /* @__PURE__ */ function(_) {
|
|
11136
|
-
return _[_.TABLE = 0] = "TABLE", _[_.ENUM = 1] = "ENUM", _[_.TABLEGROUP = 2] = "TABLEGROUP", _[_.INDEXES = 3] = "INDEXES", _[_.NOTE = 4] = "NOTE", _[_.REF = 5] = "REF", _[_.PROJECT = 6] = "PROJECT", _[_.CUSTOM = 7] = "CUSTOM", _[_.TOPLEVEL = 8] = "TOPLEVEL", _[_.TABLEPARTIAL = 9] = "TABLEPARTIAL", _[_.CHECKS = 10] = "CHECKS", _[_.RECORDS = 11] = "RECORDS", _;
|
|
11772
|
+
return _[_.TABLE = 0] = "TABLE", _[_.ENUM = 1] = "ENUM", _[_.TABLEGROUP = 2] = "TABLEGROUP", _[_.INDEXES = 3] = "INDEXES", _[_.NOTE = 4] = "NOTE", _[_.REF = 5] = "REF", _[_.PROJECT = 6] = "PROJECT", _[_.CUSTOM = 7] = "CUSTOM", _[_.TOPLEVEL = 8] = "TOPLEVEL", _[_.TABLEPARTIAL = 9] = "TABLEPARTIAL", _[_.CHECKS = 10] = "CHECKS", _[_.RECORDS = 11] = "RECORDS", _[_.DIAGRAMVIEW = 12] = "DIAGRAMVIEW", _;
|
|
11137
11773
|
}({});
|
|
11138
11774
|
function containerScopeKind(_) {
|
|
11139
11775
|
let HY = this.container.element(_);
|
|
@@ -11149,13 +11785,14 @@ function containerScopeKind(_) {
|
|
|
11149
11785
|
case "tablepartial": return ScopeKind.TABLEPARTIAL;
|
|
11150
11786
|
case "checks": return ScopeKind.CHECKS;
|
|
11151
11787
|
case "records": return ScopeKind.RECORDS;
|
|
11788
|
+
case "diagramview": return ScopeKind.DIAGRAMVIEW;
|
|
11152
11789
|
default: return ScopeKind.CUSTOM;
|
|
11153
11790
|
}
|
|
11154
11791
|
}
|
|
11155
|
-
function applyTextEdits(_, HY) {
|
|
11156
|
-
let
|
|
11157
|
-
for (let { start: _, end: HY, newText:
|
|
11158
|
-
return
|
|
11792
|
+
function applyTextEdits(_, HY, P = !1) {
|
|
11793
|
+
let UY = P ? HY : [...HY].sort((_, HY) => HY.start - _.start), WY = _;
|
|
11794
|
+
for (let { start: _, end: HY, newText: P } of UY) WY = WY.substring(0, _) + P + WY.substring(HY);
|
|
11795
|
+
return WY;
|
|
11159
11796
|
}
|
|
11160
11797
|
function normalizeTableName(_) {
|
|
11161
11798
|
if (typeof _ != "string") return {
|
|
@@ -11275,6 +11912,97 @@ function renameTable$1(_, HY) {
|
|
|
11275
11912
|
for (let _ of XY.references) P.substring(_.start, _.end).replace(/"/g, "") === qY && QY.push(_);
|
|
11276
11913
|
return applyTextEdits(P, findReplacements(QY, KY, ZY, P));
|
|
11277
11914
|
}
|
|
11915
|
+
function findDiagramViewBlocks$1(_) {
|
|
11916
|
+
let HY = [], P = new Lexer(_).lex();
|
|
11917
|
+
if (P.getErrors().length > 0) return HY;
|
|
11918
|
+
let UY = new Parser$1(_, P.getValue(), new SyntaxNodeIdGenerator()).parse();
|
|
11919
|
+
if (UY.getErrors().length > 0) return HY;
|
|
11920
|
+
let WY = UY.getValue().ast;
|
|
11921
|
+
for (let _ of WY.body) if (_.type?.value === "DiagramView") {
|
|
11922
|
+
let P = _.name ? destructureComplexVariable(_.name).unwrap_or([]) : [], UY = P.length > 0 ? P[P.length - 1] : "";
|
|
11923
|
+
HY.push({
|
|
11924
|
+
name: UY,
|
|
11925
|
+
startIndex: _.start,
|
|
11926
|
+
endIndex: _.end
|
|
11927
|
+
});
|
|
11928
|
+
}
|
|
11929
|
+
return HY;
|
|
11930
|
+
}
|
|
11931
|
+
function needsQuoting(_) {
|
|
11932
|
+
return !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_);
|
|
11933
|
+
}
|
|
11934
|
+
function quoteName(_) {
|
|
11935
|
+
return needsQuoting(_) ? `"${_.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"` : _;
|
|
11936
|
+
}
|
|
11937
|
+
function generateDiagramViewBlock(_, HY) {
|
|
11938
|
+
let P = [`DiagramView ${quoteName(_)} {`];
|
|
11939
|
+
if (HY?.tables !== void 0 && HY.tables !== null) if (HY.tables.length === 0) P.push(" Tables { * }");
|
|
11940
|
+
else {
|
|
11941
|
+
let _ = HY.tables.map((_) => _.schemaName === "public" ? _.name : `${_.schemaName}.${_.name}`);
|
|
11942
|
+
P.push(" Tables {"), _.forEach((_) => P.push(` ${_}`)), P.push(" }");
|
|
11943
|
+
}
|
|
11944
|
+
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");
|
|
11945
|
+
}
|
|
11946
|
+
function syncDiagramView$1(_, HY, P) {
|
|
11947
|
+
let UY = P ?? findDiagramViewBlocks$1(_), WY = [];
|
|
11948
|
+
for (let P of HY) {
|
|
11949
|
+
let HY = applyOperation(_, P, UY);
|
|
11950
|
+
WY.push(...HY);
|
|
11951
|
+
}
|
|
11952
|
+
return WY.sort((_, HY) => HY.start - _.start), {
|
|
11953
|
+
newDbml: applyTextEdits(_, WY, !0),
|
|
11954
|
+
edits: WY
|
|
11955
|
+
};
|
|
11956
|
+
}
|
|
11957
|
+
function applyOperation(_, HY, P) {
|
|
11958
|
+
switch (HY.operation) {
|
|
11959
|
+
case "create": return computeCreateEdit(_, HY, P);
|
|
11960
|
+
case "update": return computeUpdateEdit(_, HY, P);
|
|
11961
|
+
case "delete": return computeDeleteEdit(_, HY, P);
|
|
11962
|
+
default: return [];
|
|
11963
|
+
}
|
|
11964
|
+
}
|
|
11965
|
+
function computeCreateEdit(_, HY, P) {
|
|
11966
|
+
if (P.find((_) => _.name === HY.name)) return computeUpdateEdit(_, HY, P);
|
|
11967
|
+
let UY = "\n\n" + generateDiagramViewBlock(HY.name, HY.visibleEntities) + "\n";
|
|
11968
|
+
return [{
|
|
11969
|
+
start: _.length,
|
|
11970
|
+
end: _.length,
|
|
11971
|
+
newText: UY
|
|
11972
|
+
}];
|
|
11973
|
+
}
|
|
11974
|
+
function computeUpdateEdit(_, HY, P) {
|
|
11975
|
+
let UY = P.find((_) => _.name === HY.name);
|
|
11976
|
+
if (!UY) return [];
|
|
11977
|
+
let WY = [];
|
|
11978
|
+
if (HY.newName || HY.visibleEntities) {
|
|
11979
|
+
let _ = generateDiagramViewBlock(HY.newName || HY.name, HY.visibleEntities);
|
|
11980
|
+
WY.push({
|
|
11981
|
+
start: UY.startIndex,
|
|
11982
|
+
end: UY.endIndex,
|
|
11983
|
+
newText: _
|
|
11984
|
+
});
|
|
11985
|
+
}
|
|
11986
|
+
return WY;
|
|
11987
|
+
}
|
|
11988
|
+
function computeDeleteEdit(_, HY, P) {
|
|
11989
|
+
let UY = P.find((_) => _.name === HY.name);
|
|
11990
|
+
if (!UY) return [];
|
|
11991
|
+
let WY = UY.startIndex, GY = UY.endIndex;
|
|
11992
|
+
for (; WY > 0 && _[WY - 1] === "\n";) {
|
|
11993
|
+
WY--, WY > 0 && _[WY - 1] === "\r" && WY--;
|
|
11994
|
+
let HY = _.lastIndexOf("\n", WY - 1) + 1;
|
|
11995
|
+
if (_.substring(HY, WY).trim() !== "") {
|
|
11996
|
+
WY = UY.startIndex, WY > 0 && _[WY - 1] === "\n" && (WY--, WY > 0 && _[WY - 1] === "\r" && WY--);
|
|
11997
|
+
break;
|
|
11998
|
+
}
|
|
11999
|
+
}
|
|
12000
|
+
return GY < _.length && _[GY] === "\r" && GY++, GY < _.length && _[GY] === "\n" && GY++, [{
|
|
12001
|
+
start: WY,
|
|
12002
|
+
end: GY,
|
|
12003
|
+
newText: ""
|
|
12004
|
+
}];
|
|
12005
|
+
}
|
|
11278
12006
|
var Compiler = class {
|
|
11279
12007
|
constructor() {
|
|
11280
12008
|
this.source = "", this.cache = /* @__PURE__ */ new Map(), this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.token = {
|
|
@@ -11331,6 +12059,12 @@ var Compiler = class {
|
|
|
11331
12059
|
renameTable(_, HY) {
|
|
11332
12060
|
return renameTable$1.call(this, _, HY);
|
|
11333
12061
|
}
|
|
12062
|
+
syncDiagramView(_, HY) {
|
|
12063
|
+
return syncDiagramView$1(this.parse.source(), _, HY);
|
|
12064
|
+
}
|
|
12065
|
+
findDiagramViewBlocks() {
|
|
12066
|
+
return findDiagramViewBlocks$1(this.parse.source());
|
|
12067
|
+
}
|
|
11334
12068
|
applyTextEdits(_) {
|
|
11335
12069
|
return applyTextEdits(this.parse.source(), _);
|
|
11336
12070
|
}
|
|
@@ -1821067,5 +1821801,13 @@ function renameTable(_, HY, P) {
|
|
|
1821067
1821801
|
let UY = new Compiler();
|
|
1821068
1821802
|
return UY.setSource(P), UY.renameTable(_, HY);
|
|
1821069
1821803
|
}
|
|
1821070
|
-
|
|
1821071
|
-
|
|
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-alpha.1";
|
|
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 };
|