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