@dbml/core 8.0.0-alpha.0 → 8.0.0-alpha.10

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.
Files changed (3) hide show
  1. package/lib/index.cjs +106 -110
  2. package/lib/index.mjs +494 -349
  3. package/package.json +3 -3
package/lib/index.mjs CHANGED
@@ -2229,6 +2229,10 @@ function baseUniq(_, VY, P) {
2229
2229
  return KY;
2230
2230
  }
2231
2231
  var _baseUniq_default = baseUniq;
2232
+ function uniq(_) {
2233
+ return _ && _.length ? _baseUniq_default(_) : [];
2234
+ }
2235
+ var uniq_default = uniq;
2232
2236
  function uniqBy(_, VY) {
2233
2237
  return _ && _.length ? _baseUniq_default(_, _baseIteratee_default(VY, 2)) : [];
2234
2238
  }
@@ -2475,13 +2479,13 @@ var isAbsolute = function(_) {
2475
2479
  function resolveImportFilepath(_, VY) {
2476
2480
  if (!Filepath.isRelative(VY)) return;
2477
2481
  let P = Filepath.resolve(_.dirname, VY);
2478
- return P.absolute.endsWith(".dbml") ? P : Filepath.from(P.absolute + DBML_EXT);
2482
+ return P.absolute.endsWith(".dbml") ? P : Filepath.from(P.absolute + ".dbml");
2479
2483
  }
2480
2484
  var KEYWORDS_OF_DEFAULT_SETTING = [
2481
2485
  "null",
2482
2486
  "true",
2483
2487
  "false"
2484
- ], DBML_EXT = ".dbml", NUMERIC_LITERAL_PREFIX = ["-", "+"], DEFAULT_SCHEMA_NAME$1 = "public", DEFAULT_ENTRY = Filepath.from("/main.dbml"), CompileErrorCode = /* @__PURE__ */ function(_) {
2488
+ ], NUMERIC_LITERAL_PREFIX = ["-", "+"], DEFAULT_SCHEMA_NAME$1 = "public", DEFAULT_ENTRY = Filepath.from("/main.dbml"), CompileErrorCode = /* @__PURE__ */ function(_) {
2485
2489
  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_USE_CONTEXT = 3082] = "INVALID_USE_CONTEXT", _[_.INVALID_USE_SPECIFIER_KIND = 3083] = "INVALID_USE_SPECIFIER_KIND", _[_.INVALID_USE_SPECIFIER_NAME = 3084] = "INVALID_USE_SPECIFIER_NAME", _[_.INVALID_DIAGRAMVIEW_CONTEXT = 3085] = "INVALID_DIAGRAMVIEW_CONTEXT", _[_.DUPLICATE_DIAGRAMVIEW_NAME = 3086] = "DUPLICATE_DIAGRAMVIEW_NAME", _[_.INVALID_DIAGRAMVIEW_FIELD = 3087] = "INVALID_DIAGRAMVIEW_FIELD", _[_.DUPLICATE_DIAGRAMVIEW_FIELD = 3088] = "DUPLICATE_DIAGRAMVIEW_FIELD", _[_.BINDING_ERROR = 4e3] = "BINDING_ERROR", _[_.NONEXISTENT_MODULE = 4001] = "NONEXISTENT_MODULE", _[_.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", _;
2486
2490
  }({}), CompileError = class _ extends Error {
2487
2491
  constructor(VY, P, HY) {
@@ -2526,6 +2530,9 @@ function isValidAlias(_) {
2526
2530
  function isSimpleName(_) {
2527
2531
  return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode;
2528
2532
  }
2533
+ function hasSimpleBody(_) {
2534
+ return !!_.bodyColon;
2535
+ }
2529
2536
  function isValidPartialInjection(_) {
2530
2537
  return _ instanceof PrefixExpressionNode && _.op?.value === "~" && isExpressionAVariableNode(_.expression);
2531
2538
  }
@@ -2720,7 +2727,7 @@ function destructureIndexNode(_) {
2720
2727
  };
2721
2728
  }
2722
2729
  function extractQuotedStringToken(_) {
2723
- if (isExpressionAQuotedString(_)) return _?.expression instanceof VariableNode ? _?.expression?.variable?.value : _.expression.literal.value;
2730
+ if (isExpressionAQuotedString(_)) return _.expression instanceof VariableNode ? _?.expression?.variable?.value : _.expression.literal.value;
2724
2731
  }
2725
2732
  function extractNumericLiteral(_) {
2726
2733
  return _ instanceof PrimaryExpressionNode && _.expression instanceof LiteralNode && _.expression.literal?.kind === SyntaxTokenKind.NUMERIC_LITERAL ? Number(_.expression.literal.value) : null;
@@ -4007,7 +4014,9 @@ var DiagramViewBinder = class {
4007
4014
  let [VY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
4008
4015
  return VY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : [_.callee, ..._.args].flatMap(scanNonListNodeForBinding).flatMap((_) => {
4009
4016
  let VY = _.variables.pop();
4010
- return VY ? this.compiler.nodeReferee(VY).getErrors() : [];
4017
+ if (!VY) return [];
4018
+ let P = _.variables.pop();
4019
+ return [...P ? this.compiler.nodeReferee(P).getErrors() : [], ...this.compiler.nodeReferee(VY).getErrors()];
4011
4020
  }));
4012
4021
  }
4013
4022
  bindNoteReferences(_) {
@@ -4452,7 +4461,7 @@ var EnumBinder = class {
4452
4461
  let WY = isExpressionAVariableNode(VY) ? VY.expression.variable?.value ?? "" : "", GY = _.lookupMembers(UY, SymbolKind.Column, WY);
4453
4462
  if (GY) return Report.create(GY);
4454
4463
  let KY = isElementNode(HY, ElementKind.TablePartial) ? "TablePartial" : "Table";
4455
- return new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Column '${WY}' does not exist in ${KY} 'public.${UY.name}'`, VY)]);
4464
+ return new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${WY}' does not exist in ${KY} 'public.${UY.name}'`, VY)]);
4456
4465
  },
4457
4466
  bindNode(_, VY) {
4458
4467
  return isElementNode(VY, ElementKind.Indexes) ? Report.create(void 0, new IndexesBinder(_, VY).bind()) : Report.create(PASS_THROUGH);
@@ -8553,11 +8562,15 @@ var ProgramInterpreter = class {
8553
8562
  let HY = P.getValue();
8554
8563
  HY && this.pushElement(VY, HY);
8555
8564
  }
8556
- let _ = this.compiler.symbolMembers(this.programSymbol).getFiltered(UNHANDLED) ?? [];
8557
- for (let VY of _) {
8558
- if (!(VY instanceof SchemaSymbol)) continue;
8559
- let _ = this.compiler.symbolMembers(VY).getFiltered(UNHANDLED) ?? [];
8560
- for (let VY of _) VY instanceof UseSymbol && this.interpretUseSymbol(VY);
8565
+ let _ = /* @__PURE__ */ new Set(), VY = this.compiler.symbolMembers(this.programSymbol).getFiltered(UNHANDLED) ?? [];
8566
+ for (let P of VY) {
8567
+ if (!(P instanceof SchemaSymbol)) continue;
8568
+ let VY = this.compiler.symbolMembers(P).getFiltered(UNHANDLED) ?? [];
8569
+ for (let P of VY) {
8570
+ if (!(P instanceof UseSymbol)) continue;
8571
+ let VY = P.originalSymbol.intern();
8572
+ _.has(VY) || (_.add(VY), this.interpretUseSymbol(P));
8573
+ }
8561
8574
  }
8562
8575
  }
8563
8576
  interpretUseSymbol(_) {
@@ -8760,24 +8773,16 @@ var ProgramInterpreter = class {
8760
8773
  },
8761
8774
  symbolMembers(_, VY) {
8762
8775
  if (!VY.isKind(SymbolKind.Program)) return Report.create(PASS_THROUGH);
8763
- let P = VY.declaration;
8764
- if (!(P instanceof ProgramNode)) return Report.create([]);
8765
- let HY = new Map([[DEFAULT_SCHEMA_NAME$1, _.symbolFactory.create(SchemaSymbol, { name: DEFAULT_SCHEMA_NAME$1 }, VY.filepath)]]);
8766
- for (let UY of P.declarations) {
8767
- let P = _.nodeFullname(UY).getFiltered(UNHANDLED) || [], WY = P.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : P[0];
8768
- HY.has(WY) || HY.set(WY, _.symbolFactory.create(SchemaSymbol, { name: WY }, VY.filepath));
8769
- }
8770
- for (let P of _.reachableFiles(VY.filepath)) {
8771
- let { schemaMembers: UY } = _.usableMembers(P).getValue();
8772
- for (let P of UY) {
8773
- let { name: UY } = P;
8774
- HY.has(UY) || HY.set(UY, _.symbolFactory.create(SchemaSymbol, { name: UY }, VY.filepath));
8775
- }
8776
- }
8777
- let UY = HY.get(DEFAULT_SCHEMA_NAME$1);
8778
- if (!UY) return Report.create([...HY.values()]);
8779
- let WY = _.symbolMembers(UY).getFiltered(UNHANDLED)?.filter((_) => !_.isKind(SymbolKind.Schema));
8780
- return WY ? Report.create([...HY.values(), ...WY]) : Report.create([...HY.values()]);
8776
+ if (!(VY.declaration instanceof ProgramNode)) return Report.create([]);
8777
+ let P = /* @__PURE__ */ new Map();
8778
+ for (let HY of _.reachableFiles(VY.filepath)) {
8779
+ let { schemaMembers: VY } = _.usableMembers(HY).getValue();
8780
+ for (let _ of VY) P.has(_.name) || P.set(_.name, _);
8781
+ }
8782
+ let HY = P.get(DEFAULT_SCHEMA_NAME$1);
8783
+ if (!HY) return Report.create([...P.values()]);
8784
+ let UY = _.symbolMembers(HY).getFiltered(UNHANDLED)?.filter((_) => !_.isKind(SymbolKind.Schema));
8785
+ return UY ? Report.create([...P.values(), ...UY]) : Report.create([...P.values()]);
8781
8786
  },
8782
8787
  bindNode(_, VY) {
8783
8788
  return isProgramNode(VY) ? new Binder(VY, _).resolve() : Report.create(PASS_THROUGH);
@@ -9194,23 +9199,23 @@ function nodeRefereeOfRecordsName(_, VY, P) {
9194
9199
  let HY = extractVarNameFromPrimaryVariable(P) ?? "";
9195
9200
  if (!isAccessExpression(P.parentNode)) {
9196
9201
  let UY = _.lookupMembers(VY, [SymbolKind.Table, SymbolKind.Schema], HY);
9197
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Table '${HY}' does not exist in Schema 'public'`, P)]);
9202
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table '${HY}' does not exist in Schema 'public'`, P)]);
9198
9203
  }
9199
9204
  let UY = nodeRefereeOfLeftExpression(_, P);
9200
9205
  if (!UY) {
9201
9206
  let UY = _.lookupMembers(VY, [SymbolKind.Table, SymbolKind.Schema], HY);
9202
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Table or schema '${HY}' does not exist`, P)]);
9207
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
9203
9208
  }
9204
9209
  if (UY.isKind(SymbolKind.Schema)) {
9205
9210
  let VY = _.lookupMembers(UY, [SymbolKind.Table, SymbolKind.Schema], HY);
9206
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Table or schema '${HY}' does not exist`, P)]);
9211
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
9207
9212
  }
9208
9213
  return new Report(void 0);
9209
9214
  }
9210
9215
  function nodeRefereeOfRecordsColumn(_, VY, P) {
9211
9216
  if (!isExpressionAVariableNode(P)) return new Report(void 0);
9212
9217
  let HY = extractVarNameFromPrimaryVariable(P) ?? "", UY = _.lookupMembers(VY, SymbolKind.Column, HY);
9213
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Column '${HY}' does not exist in Table 'public.${VY.name}'`, P)]);
9218
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in Table 'public.${VY.name}'`, P)]);
9214
9219
  }
9215
9220
  function nodeRefereeOfEnumValue(_, VY, P) {
9216
9221
  if (!isExpressionAVariableNode(P)) return new Report(void 0);
@@ -9220,7 +9225,7 @@ function nodeRefereeOfEnumValue(_, VY, P) {
9220
9225
  if (UY) {
9221
9226
  if (UY.isKind(SymbolKind.Schema)) {
9222
9227
  let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
9223
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum or schema '${HY}' does not exist`, P)]);
9228
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
9224
9229
  }
9225
9230
  if (UY.isKind(SymbolKind.Enum)) {
9226
9231
  let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
@@ -9232,7 +9237,7 @@ function nodeRefereeOfEnumValue(_, VY, P) {
9232
9237
  if (WY.leftExpression === P) {
9233
9238
  if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
9234
9239
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
9235
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9240
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9236
9241
  }
9237
9242
  let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
9238
9243
  return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
@@ -9403,7 +9408,7 @@ function nodeRefereeOfRefEndpoint(_, VY, P) {
9403
9408
  }
9404
9409
  var useUtils = { visibleName(_, VY) {
9405
9410
  let P = VY instanceof SyntaxNode ? VY : VY.useSpecifierDeclaration instanceof UseSpecifierNode ? VY.useSpecifierDeclaration : VY.declaration;
9406
- if (P) return _.nodeAlias(P).mapFiltered((_) => [_], UNHANDLED, void 0).getFiltered(UNHANDLED) || _.nodeFullname(P).getFiltered(UNHANDLED);
9411
+ if (P instanceof UseSpecifierNode && VY instanceof NodeSymbol && P.getSymbolKind() !== VY.kind && (P = VY.declaration), P) return _.nodeAlias(P).mapFiltered((_) => [_], UNHANDLED, void 0).getFiltered(UNHANDLED) || _.nodeFullname(P).getFiltered(UNHANDLED);
9407
9412
  } }, useModule$1 = {
9408
9413
  nodeSymbol(_, VY) {
9409
9414
  if (!isUseSpecifier(VY) || !VY.name) return Report.create(PASS_THROUGH);
@@ -9416,7 +9421,7 @@ var useUtils = { visibleName(_, VY) {
9416
9421
  usedSymbol: HY,
9417
9422
  kind: P,
9418
9423
  name: useUtils.visibleName(_, VY)?.at(-1)
9419
- }, VY.filepath), HY === void 0 ? [new CompileError(CompileErrorCode.BINDING_ERROR, `Failed to resolve the import of ${P} '${(_.nodeFullname(VY).getFiltered(UNHANDLED) || []).map(addDoubleQuoteIfNeeded).join(".")}'`, VY)] : []);
9424
+ }, VY.filepath), HY === void 0 ? [new CompileError(CompileErrorCode.BINDING_ERROR, `Failed to resolve the import of ${P} '${(destructureComplexVariable(VY.name) || []).map(addDoubleQuoteIfNeeded).join(".")}'`, VY)] : []);
9420
9425
  },
9421
9426
  symbolMembers(_, VY) {
9422
9427
  if (!(VY instanceof UseSymbol)) return Report.create(PASS_THROUGH);
@@ -9434,14 +9439,14 @@ var useUtils = { visibleName(_, VY) {
9434
9439
  let GY = VY.parentOfKind(UseDeclarationNode);
9435
9440
  if (GY?.importPath?.value === void 0) return Report.create(void 0);
9436
9441
  let KY = resolveImportFilepath(VY.filepath, GY.importPath.value);
9437
- if (!KY) return Report.create(void 0);
9442
+ if (!KY) return Report.create(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Import path must be relative, got '${GY.importPath.value}'`, VY)]);
9438
9443
  if (!_.layout.exists(KY)) return Report.create(void 0, [new CompileError(CompileErrorCode.NONEXISTENT_MODULE, `${HY} '${UY?.join(".") ?? WY}' does not exist in file ${KY.toString()}. Does the file exist?`, VY)]);
9439
9444
  let qY = VY.parentOfKind(InfixExpressionNode)?.leftExpression;
9440
9445
  if (qY && qY !== VY) {
9441
9446
  let P = _.nodeReferee(qY).getFiltered(UNHANDLED);
9442
9447
  if (!P) return Report.create(void 0);
9443
9448
  let UY = _.lookupMembers(P, HY, WY);
9444
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Could not find ${HY} '${WY}'`, VY)]);
9449
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Could not find ${HY} '${WY}'`, VY)]);
9445
9450
  }
9446
9451
  let JY = lookupMemberInFilepath(_, KY, WY, HY);
9447
9452
  return JY ? Report.create(JY) : Report.create(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `${HY} '${WY}' does not exist in file ${KY.toString()}`, VY)]);
@@ -9451,7 +9456,7 @@ var useUtils = { visibleName(_, VY) {
9451
9456
  let P = [];
9452
9457
  if (VY.importPath?.value) {
9453
9458
  let HY = resolveImportFilepath(VY.filepath, VY.importPath.value);
9454
- HY && !_.layout.exists(HY) && P.push(new CompileError(CompileErrorCode.NONEXISTENT_MODULE, `Failed to resolve the non-existent file '${VY.importPath.value}'`, VY.importPath));
9459
+ HY ? _.layout.exists(HY) || P.push(new CompileError(CompileErrorCode.NONEXISTENT_MODULE, `Failed to resolve the non-existent file '${VY.importPath.value}'`, VY.importPath)) : P.push(new CompileError(CompileErrorCode.BINDING_ERROR, `Import path must be relative, got '${VY.importPath.value}'`, VY.importPath));
9455
9460
  }
9456
9461
  if (VY.specifiers) {
9457
9462
  let HY = _.bindNode(VY.specifiers);
@@ -9497,64 +9502,23 @@ function lookupMemberInFilepath(_, VY, P, HY, UY = /* @__PURE__ */ new Set()) {
9497
9502
  }
9498
9503
  }
9499
9504
  function usableMembers(_) {
9500
- let VY = [], P = /* @__PURE__ */ new Map(), HY = [], UY = [], WY = [], GY = [], KY = _ instanceof Filepath ? _ : _.filepath, qY = this.parseFile(KY), { ast: JY } = qY.getValue();
9501
- for (let _ of JY.body) {
9502
- if (!(_ instanceof UseDeclarationNode) || !_.specifiers || !_.importPath) continue;
9503
- let VY = resolveImportFilepath(KY, _.importPath.value);
9504
- VY && (_.isReuse ? _.specifiers instanceof WildcardNode ? HY.push({
9505
- importPath: VY,
9506
- node: _.specifiers
9507
- }) : UY.push(..._.specifiers.specifiers) : _.specifiers instanceof WildcardNode ? WY.push({
9508
- importPath: VY,
9509
- node: _.specifiers
9510
- }) : GY.push(..._.specifiers.specifiers));
9511
- }
9512
- let YY = [];
9513
9505
  if (_ instanceof Filepath) {
9514
- let P = new Map([[DEFAULT_SCHEMA_NAME$1, this.symbolFactory.create(SchemaSymbol, { name: DEFAULT_SCHEMA_NAME$1 }, _)]]);
9515
- for (let VY of JY.declarations) {
9516
- let HY = this.nodeFullname(VY).getFiltered(UNHANDLED) || [], UY = HY.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : HY[0];
9517
- P.has(UY) || P.set(UY, this.symbolFactory.create(SchemaSymbol, { name: UY }, _));
9518
- }
9519
- YY.push(...P.values());
9520
- let HY = YY.find((_) => _.isPublicSchema());
9521
- if (HY) {
9522
- let _ = this.usableMembers(HY).getFiltered(UNHANDLED);
9523
- _ && VY.push(..._.nonSchemaMembers);
9524
- }
9525
- } else {
9526
- let HY = _;
9527
- for (let _ of JY.body) {
9528
- if (!(_ instanceof ElementDeclarationNode)) continue;
9529
- let UY = schemaMembership(this, HY, _), WY = this.nodeAlias(_).getFiltered(UNHANDLED), GY = this.nodeSymbol(_).getFiltered(UNHANDLED);
9530
- if (WY !== void 0 && HY.isPublicSchema() && GY && VY.push(this.symbolFactory.create(AliasSymbol, {
9531
- kind: GY.kind,
9532
- declaration: _,
9533
- aliasedSymbol: GY,
9534
- name: WY
9535
- }, HY.filepath)), UY.kind !== "none") if (UY.kind === "direct") {
9536
- let P = this.nodeSymbol(_).getFiltered(UNHANDLED);
9537
- if (!P) continue;
9538
- VY.push(P);
9539
- } else P.has(UY.schemaName) || P.set(UY.schemaName, this.symbolFactory.create(SchemaSymbol, {
9540
- name: UY.schemaName,
9541
- parent: HY
9542
- }, HY.filepath));
9543
- }
9544
- YY.push(...P.values());
9506
+ let { ast: VY } = this.parseFile(_).getValue(), P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
9507
+ return this.usableMembers(P);
9545
9508
  }
9509
+ let VY = _.filepath, P = collectImports(this, VY), { nonSchemaMembers: HY, schemaMembers: UY } = _ instanceof ProgramSymbol ? usableMembersForProgram(this, _, P) : usableMembersForSchema(this, _, P);
9546
9510
  return new Report({
9547
- nonSchemaMembers: VY,
9548
- schemaMembers: YY,
9511
+ nonSchemaMembers: HY,
9512
+ schemaMembers: UY,
9549
9513
  reuses: {
9550
- selective: UY,
9551
- wildcard: HY
9514
+ selective: P.selectiveReuses,
9515
+ wildcard: P.wildcardReuses
9552
9516
  },
9553
9517
  uses: {
9554
- selective: GY,
9555
- wildcard: WY
9518
+ selective: P.selectiveUses,
9519
+ wildcard: P.wildcardUses
9556
9520
  }
9557
- }, qY.getErrors(), qY.getWarnings());
9521
+ }, P.parseResult.getErrors(), P.parseResult.getWarnings());
9558
9522
  }
9559
9523
  function schemaMembership(_, VY, P) {
9560
9524
  let HY = VY.qualifiedName, UY;
@@ -9565,6 +9529,124 @@ function schemaMembership(_, VY, P) {
9565
9529
  schemaName: WY[HY.length]
9566
9530
  };
9567
9531
  }
9532
+ function collectImports(_, VY) {
9533
+ let P = _.parseFile(VY), { ast: HY } = P.getValue(), UY = [], WY = [], GY = [], KY = [];
9534
+ for (let _ of HY.body) {
9535
+ if (!(_ instanceof UseDeclarationNode) || !_.specifiers || !_.importPath) continue;
9536
+ let P = resolveImportFilepath(VY, _.importPath.value);
9537
+ P && (_.isReuse ? _.specifiers instanceof WildcardNode ? UY.push({
9538
+ importPath: P,
9539
+ node: _.specifiers
9540
+ }) : WY.push(..._.specifiers.specifiers) : _.specifiers instanceof WildcardNode ? GY.push({
9541
+ importPath: P,
9542
+ node: _.specifiers
9543
+ }) : KY.push(..._.specifiers.specifiers));
9544
+ }
9545
+ return {
9546
+ ast: HY,
9547
+ parseResult: P,
9548
+ selectiveReuses: WY,
9549
+ wildcardReuses: UY,
9550
+ selectiveUses: KY,
9551
+ wildcardUses: GY
9552
+ };
9553
+ }
9554
+ function usableMembersForProgram(_, VY, P) {
9555
+ let { ast: HY, selectiveUses: UY, selectiveReuses: WY } = P, GY = VY.filepath, KY = new Map([[DEFAULT_SCHEMA_NAME$1, _.symbolFactory.create(SchemaSymbol, { name: DEFAULT_SCHEMA_NAME$1 }, GY)]]);
9556
+ for (let VY of HY.declarations) {
9557
+ let P = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], HY = P.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : P[0];
9558
+ KY.has(HY) || KY.set(HY, _.symbolFactory.create(SchemaSymbol, { name: HY }, GY));
9559
+ }
9560
+ registerProgramSchemas(_, [...UY, ...WY], KY, GY);
9561
+ for (let VY of _.reachableFiles(GY)) for (let P of collectTopLevelSchemaNames(_, VY)) KY.has(P) || KY.set(P, _.symbolFactory.create(SchemaSymbol, { name: P }, GY));
9562
+ let qY = [...KY.values()], JY = [], YY = qY.find((_) => _.isPublicSchema());
9563
+ if (YY) {
9564
+ let VY = _.usableMembers(YY).getFiltered(UNHANDLED);
9565
+ VY && JY.push(...VY.nonSchemaMembers);
9566
+ }
9567
+ return {
9568
+ nonSchemaMembers: JY,
9569
+ schemaMembers: qY
9570
+ };
9571
+ }
9572
+ function usableMembersForSchema(_, VY, P) {
9573
+ let { ast: HY, selectiveUses: UY, selectiveReuses: WY } = P, GY = [], KY = /* @__PURE__ */ new Map();
9574
+ for (let P of HY.body) {
9575
+ if (!(P instanceof ElementDeclarationNode)) continue;
9576
+ let HY = schemaMembership(_, VY, P), UY = _.nodeAlias(P).getFiltered(UNHANDLED), WY = _.nodeSymbol(P).getFiltered(UNHANDLED);
9577
+ if (UY !== void 0 && VY.isPublicSchema() && WY && GY.push(_.symbolFactory.create(AliasSymbol, {
9578
+ kind: WY.kind,
9579
+ declaration: P,
9580
+ aliasedSymbol: WY,
9581
+ name: UY
9582
+ }, VY.filepath)), HY.kind !== "none") if (HY.kind === "direct") {
9583
+ let VY = _.nodeSymbol(P).getFiltered(UNHANDLED);
9584
+ if (!VY) continue;
9585
+ GY.push(VY);
9586
+ } else KY.has(HY.schemaName) || KY.set(HY.schemaName, _.symbolFactory.create(SchemaSymbol, {
9587
+ name: HY.schemaName,
9588
+ parent: VY
9589
+ }, VY.filepath));
9590
+ }
9591
+ registerSchemaChildren(_, [...UY, ...WY], VY, KY);
9592
+ let qY = VY.qualifiedName;
9593
+ for (let P of _.reachableFiles(VY.filepath)) for (let HY of collectChildSchemaNames(_, P, qY)) KY.has(HY) || KY.set(HY, _.symbolFactory.create(SchemaSymbol, {
9594
+ name: HY,
9595
+ parent: VY
9596
+ }, VY.filepath));
9597
+ return {
9598
+ nonSchemaMembers: GY,
9599
+ schemaMembers: [...KY.values()]
9600
+ };
9601
+ }
9602
+ function registerProgramSchemas(_, VY, P, HY) {
9603
+ for (let UY of VY) {
9604
+ if (UY.getSymbolKind() !== SymbolKind.Schema) continue;
9605
+ let VY = useUtils.visibleName(_, UY)?.at(0);
9606
+ VY !== void 0 && !P.has(VY) && P.set(VY, _.symbolFactory.create(SchemaSymbol, { name: VY }, HY));
9607
+ }
9608
+ }
9609
+ function registerSchemaChildren(_, VY, P, HY) {
9610
+ let UY = P.qualifiedName;
9611
+ for (let WY of VY) {
9612
+ if (WY.getSymbolKind() !== SymbolKind.Schema) continue;
9613
+ let VY = useUtils.visibleName(_, WY);
9614
+ if (!VY || VY.length <= UY.length || !UY.every((_, P) => _ === VY[P])) continue;
9615
+ let GY = VY[UY.length];
9616
+ GY && !HY.has(GY) && HY.set(GY, _.symbolFactory.create(SchemaSymbol, {
9617
+ name: GY,
9618
+ parent: P
9619
+ }, P.filepath));
9620
+ }
9621
+ }
9622
+ function collectTopLevelSchemaNames(_, VY) {
9623
+ let { ast: P } = _.parseFile(VY).getValue(), HY = [];
9624
+ for (let VY of P.declarations) {
9625
+ let P = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], UY = P.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : P[0];
9626
+ HY.push(UY);
9627
+ }
9628
+ let UY = collectImports(_, VY);
9629
+ for (let VY of [...UY.selectiveUses, ...UY.selectiveReuses]) {
9630
+ if (VY.getSymbolKind() !== SymbolKind.Schema) continue;
9631
+ let P = useUtils.visibleName(_, VY)?.at(0);
9632
+ P !== void 0 && HY.push(P);
9633
+ }
9634
+ return HY;
9635
+ }
9636
+ function collectChildSchemaNames(_, VY, P) {
9637
+ let { ast: HY } = _.parseFile(VY).getValue(), UY = [];
9638
+ for (let VY of HY.declarations) {
9639
+ let HY = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], WY = HY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : HY.slice(0, -1);
9640
+ WY.length > P.length && P.every((_, VY) => _ === WY[VY]) && UY.push(WY[P.length]);
9641
+ }
9642
+ let WY = collectImports(_, VY);
9643
+ for (let VY of [...WY.selectiveUses, ...WY.selectiveReuses]) {
9644
+ if (VY.getSymbolKind() !== SymbolKind.Schema) continue;
9645
+ let HY = useUtils.visibleName(_, VY);
9646
+ !HY || HY.length <= P.length || P.every((_, VY) => _ === HY[VY]) && UY.push(HY[P.length]);
9647
+ }
9648
+ return UY;
9649
+ }
9568
9650
  var TableBinder = class {
9569
9651
  constructor(_, VY) {
9570
9652
  this.compiler = _, this.declarationNode = VY;
@@ -9883,7 +9965,7 @@ function nodeRefereeOfPartialInjection(_, VY, P) {
9883
9965
  }
9884
9966
  }
9885
9967
  let WY = _.lookupMembers(VY, SymbolKind.TablePartial, HY);
9886
- return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `TablePartial '${HY}' does not exist in Schema 'public'`, P)]);
9968
+ return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `TablePartial '${HY}' does not exist in Schema 'public'`, P)]);
9887
9969
  }
9888
9970
  function nodeRefereeOfEnumType$1(_, VY, P) {
9889
9971
  if (!isExpressionAVariableNode(P)) return new Report(void 0);
@@ -9893,13 +9975,13 @@ function nodeRefereeOfEnumType$1(_, VY, P) {
9893
9975
  if (UY) {
9894
9976
  if (UY.isKind(SymbolKind.Schema)) {
9895
9977
  let VY = isTerminalAccessFragment(P), WY = _.lookupMembers(UY, VY ? SymbolKind.Enum : SymbolKind.Schema, HY);
9896
- return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, VY ? `Enum '${HY}' does not exist in Schema 'public'` : `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9978
+ return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, VY ? `Enum '${HY}' does not exist in Schema 'public'` : `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9897
9979
  }
9898
9980
  return new Report(void 0);
9899
9981
  }
9900
9982
  if (P.parentNode.leftExpression === P) {
9901
9983
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
9902
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9984
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9903
9985
  }
9904
9986
  return new Report(void 0);
9905
9987
  }
@@ -9946,11 +10028,11 @@ function nodeRefereeOfEnumDefault$1(_, VY, P) {
9946
10028
  if (UY) {
9947
10029
  if (UY.isKind(SymbolKind.Schema)) {
9948
10030
  let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
9949
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum or schema '${HY}' does not exist`, P)]);
10031
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
9950
10032
  }
9951
10033
  if (UY.isKind(SymbolKind.Enum)) {
9952
10034
  let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
9953
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
10035
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
9954
10036
  }
9955
10037
  return new Report(void 0);
9956
10038
  }
@@ -9958,10 +10040,10 @@ function nodeRefereeOfEnumDefault$1(_, VY, P) {
9958
10040
  if (WY.leftExpression === P) {
9959
10041
  if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
9960
10042
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
9961
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10043
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
9962
10044
  }
9963
10045
  let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
9964
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
10046
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
9965
10047
  }
9966
10048
  return new Report(void 0);
9967
10049
  }
@@ -10225,16 +10307,11 @@ function nodeRefereeOfTableGroupField(_, VY, P) {
10225
10307
  let HY = extractVarNameFromPrimaryVariable(P) ?? "";
10226
10308
  if (!isAccessExpression(P.parentNode)) {
10227
10309
  let UY = _.symbolMembers(VY).getFiltered(UNHANDLED);
10228
- if (UY) for (let VY of UY) {
10229
- if (!(VY instanceof SchemaSymbol)) continue;
10230
- let P = _.lookupMembers(VY, SymbolKind.Table, HY);
10231
- if (P) return Report.create(P);
10232
- if (!VY.isPublicSchema()) {
10233
- let P = _.symbolMembers(VY).getFiltered(UNHANDLED);
10234
- if (P) {
10235
- let VY = P.find((VY) => !VY.isKind(SymbolKind.Table) || !VY.declaration ? !1 : _.nodeAlias(VY.declaration).getFiltered(UNHANDLED) === HY);
10236
- if (VY) return new Report(VY);
10237
- }
10310
+ if (UY) {
10311
+ let VY = UY.find((_) => _ instanceof SchemaSymbol && _.isPublicSchema());
10312
+ if (VY) {
10313
+ let P = _.lookupMembers(VY, SymbolKind.Table, HY);
10314
+ if (P) return Report.create(P);
10238
10315
  }
10239
10316
  }
10240
10317
  let WY = _.lookupMembers(VY, SymbolKind.Table, HY);
@@ -10343,7 +10420,7 @@ var TablePartialBinder = class {
10343
10420
  this.tablePartial.headerColor = P ? extractColor(P.value) : void 0;
10344
10421
  let [HY] = VY[SettingName.Note] || [];
10345
10422
  return this.tablePartial.note = HY && {
10346
- value: extractQuotedStringToken(HY?.value) ? normalizeNote(extractQuotedStringToken(HY?.value)) : "",
10423
+ value: normalizeNote(extractQuotedStringToken(HY?.value)),
10347
10424
  token: getTokenPosition(HY)
10348
10425
  }, [];
10349
10426
  }
@@ -10470,13 +10547,13 @@ function nodeRefereeOfEnumType(_, VY, P) {
10470
10547
  if (UY) {
10471
10548
  if (UY.isKind(SymbolKind.Schema)) {
10472
10549
  let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
10473
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum or schema '${HY}' does not exist`, P)]);
10550
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
10474
10551
  }
10475
10552
  return new Report(void 0);
10476
10553
  }
10477
10554
  if (P.parentNode.leftExpression === P) {
10478
10555
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
10479
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10556
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10480
10557
  }
10481
10558
  return new Report(void 0);
10482
10559
  }
@@ -10489,21 +10566,21 @@ function nodeRefereeOfInlineRef(_, VY, P) {
10489
10566
  let VY = _.nodeSymbol(UY).getFiltered(UNHANDLED);
10490
10567
  if (VY) {
10491
10568
  let UY = _.lookupMembers(VY, SymbolKind.Column, HY);
10492
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Column '${HY}' does not exist in TablePartial '${VY.name}'`, P)]);
10569
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in TablePartial '${VY.name}'`, P)]);
10493
10570
  }
10494
10571
  }
10495
10572
  let WY = _.lookupMembers(VY, SymbolKind.Column, HY);
10496
- return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Column '${HY}' does not exist`, P)]);
10573
+ return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist`, P)]);
10497
10574
  }
10498
10575
  let UY = nodeRefereeOfLeftExpression(_, P);
10499
10576
  if (UY) {
10500
10577
  if (UY.isKind(SymbolKind.Schema)) {
10501
10578
  let VY = _.lookupMembers(UY, [SymbolKind.Table, SymbolKind.Schema], HY);
10502
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Table or schema '${HY}' does not exist`, P)]);
10579
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
10503
10580
  }
10504
10581
  if (UY.isKind(SymbolKind.Table)) {
10505
10582
  let VY = _.lookupMembers(UY, SymbolKind.Column, HY);
10506
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Column '${HY}' does not exist in Table 'public.${UY.name}'`, P)]);
10583
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in Table 'public.${UY.name}'`, P)]);
10507
10584
  }
10508
10585
  return new Report(void 0);
10509
10586
  }
@@ -10511,10 +10588,10 @@ function nodeRefereeOfInlineRef(_, VY, P) {
10511
10588
  if (WY.leftExpression === P) {
10512
10589
  if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
10513
10590
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
10514
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10591
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10515
10592
  }
10516
10593
  let UY = _.lookupMembers(VY, SymbolKind.Table, HY);
10517
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Table '${HY}' does not exist in Schema 'public'`, P)]);
10594
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table '${HY}' does not exist in Schema 'public'`, P)]);
10518
10595
  }
10519
10596
  return new Report(void 0);
10520
10597
  }
@@ -10526,11 +10603,11 @@ function nodeRefereeOfEnumDefault(_, VY, P) {
10526
10603
  if (UY) {
10527
10604
  if (UY.isKind(SymbolKind.Schema)) {
10528
10605
  let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
10529
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum or schema '${HY}' does not exist`, P)]);
10606
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
10530
10607
  }
10531
10608
  if (UY.isKind(SymbolKind.Enum)) {
10532
10609
  let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
10533
- return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
10610
+ return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
10534
10611
  }
10535
10612
  return new Report(void 0);
10536
10613
  }
@@ -10538,10 +10615,10 @@ function nodeRefereeOfEnumDefault(_, VY, P) {
10538
10615
  if (WY.leftExpression === P) {
10539
10616
  if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
10540
10617
  let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
10541
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10618
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
10542
10619
  }
10543
10620
  let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
10544
- return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.NAME_NOT_FOUND, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
10621
+ return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
10545
10622
  }
10546
10623
  return new Report(void 0);
10547
10624
  }
@@ -10554,26 +10631,38 @@ var schemaModule = { symbolMembers(_, VY) {
10554
10631
  let HY = handleMemberSelectiveUses(_, VY, P, WY);
10555
10632
  GY.push(...HY.getErrors());
10556
10633
  let KY = HY.getFiltered(UNHANDLED);
10557
- KY && UY.push(KY);
10634
+ KY && UY.push(KY), UY.push(...mergeImportedSchema(_, VY, P));
10558
10635
  }
10559
10636
  for (let { importPath: P, node: GY } of HY.reuses.wildcard) UY.push(...handleMemberWildcardUses(_, VY, P, GY, WY));
10560
10637
  for (let P of HY.uses.selective) {
10561
10638
  let HY = handleMemberSelectiveUses(_, VY, P, WY);
10562
10639
  GY.push(...HY.getErrors());
10563
10640
  let KY = HY.getFiltered(UNHANDLED);
10564
- KY && UY.push(KY);
10641
+ KY && UY.push(KY), UY.push(...mergeImportedSchema(_, VY, P));
10565
10642
  }
10566
10643
  for (let { importPath: P, node: GY } of HY.uses.wildcard) UY.push(...handleMemberWildcardUses(_, VY, P, GY, WY));
10567
10644
  UY.push(...WY.values());
10568
10645
  let KY = [...UY];
10569
- for (let VY of UY) VY.isKind(SymbolKind.TableGroup) && KY.push(...expandTableGroup(_, VY));
10646
+ {
10647
+ let P = UY.filter((_) => _.isKind(SymbolKind.TableGroup));
10648
+ if (!VY.isPublicSchema()) {
10649
+ let HY = _.usableMembers(VY.filepath).getFiltered(UNHANDLED)?.schemaMembers.find((_) => _.isPublicSchema());
10650
+ if (HY) {
10651
+ let VY = _.symbolMembers(HY).getFiltered(UNHANDLED);
10652
+ VY && P.push(...VY.filter((_) => _.isKind(SymbolKind.TableGroup)));
10653
+ }
10654
+ }
10655
+ for (let HY of P) KY.push(...expandTableGroup(_, VY, HY));
10656
+ }
10570
10657
  let qY = /* @__PURE__ */ new Set(), JY = KY.filter((_) => {
10658
+ if (_ instanceof UseSymbol && _.isKind(SymbolKind.Schema)) return !1;
10571
10659
  let VY = `${_.originalSymbol.intern()}:${_.name ?? ""}`;
10572
10660
  return qY.has(VY) ? !1 : (qY.add(VY), !0);
10573
10661
  }), YY = /* @__PURE__ */ new Map();
10574
10662
  for (let _ of JY) {
10575
10663
  let VY = `${_.kind}:${_.name}`;
10576
10664
  if (YY.get(VY)) {
10665
+ if (_.isKind(SymbolKind.Schema)) continue;
10577
10666
  let VY = _ instanceof UseSymbol ? _.useSpecifierDeclaration ?? _.declaration : _.declaration instanceof ElementDeclarationNode && _.declaration.name ? _.declaration.name : _.declaration;
10578
10667
  VY && _.name !== void 0 && GY.push(getDuplicateSchemaMemberError(_.kind, _.name, P.join("."), VY));
10579
10668
  } else YY.set(VY, _);
@@ -10602,6 +10691,26 @@ function handleMemberSelectiveUses(_, VY, P, HY) {
10602
10691
  parent: VY
10603
10692
  }, VY.filepath)), Report.create(void 0);
10604
10693
  }
10694
+ function mergeImportedSchema(_, VY, P, HY = /* @__PURE__ */ new Set()) {
10695
+ if (P.getSymbolKind() !== SymbolKind.Schema || !P.name) return [];
10696
+ let UY = _.nodeReferee(P.name).getFiltered(UNHANDLED);
10697
+ if (!UY || !UY.isKind(SymbolKind.Schema) || (_.nodeAlias(P).getFiltered(UNHANDLED) ?? _.nodeFullname(P).getFiltered(UNHANDLED)?.at(0)) !== VY.name) return [];
10698
+ let WY = UY.intern();
10699
+ if (HY.has(WY)) return [];
10700
+ HY.add(WY);
10701
+ let GY = _.usableMembers(UY).getFiltered(UNHANDLED);
10702
+ if (!GY) return [];
10703
+ let KY = GY.nonSchemaMembers.filter((_) => _.canBeImported).map((HY) => _.symbolFactory.create(UseSymbol, {
10704
+ kind: HY.kind,
10705
+ declaration: HY.originalSymbol.declaration,
10706
+ usedSymbol: HY.originalSymbol,
10707
+ useSpecifierDeclaration: P,
10708
+ name: HY.name
10709
+ }, VY.filepath));
10710
+ for (let P of [...KY]) P.isKind(SymbolKind.TableGroup) && KY.push(...expandTableGroup(_, VY, P));
10711
+ for (let P of GY.reuses.selective) KY.push(...mergeImportedSchema(_, VY, P, HY));
10712
+ return KY;
10713
+ }
10605
10714
  function handleMemberWildcardUses(_, VY, P, HY, UY, WY = /* @__PURE__ */ new Set()) {
10606
10715
  if (WY.has(P)) return [];
10607
10716
  WY.add(P);
@@ -10620,7 +10729,7 @@ function handleMemberWildcardUses(_, VY, P, HY, UY, WY = /* @__PURE__ */ new Set
10620
10729
  let { reuses: { selective: JY, wildcard: YY } } = KY;
10621
10730
  for (let P of JY) {
10622
10731
  let HY = handleMemberSelectiveUses(_, VY, P, UY).getFiltered(UNHANDLED);
10623
- HY && qY.push(HY);
10732
+ HY && qY.push(HY), qY.push(...mergeImportedSchema(_, VY, P));
10624
10733
  }
10625
10734
  for (let { importPath: P } of YY) qY.push(...handleMemberWildcardUses(_, VY, P, HY, UY, WY));
10626
10735
  return qY;
@@ -10638,34 +10747,36 @@ function findSchemaSymbolInFilepath(_, VY, P) {
10638
10747
  }
10639
10748
  return WY;
10640
10749
  }
10641
- function expandTableGroup(_, VY) {
10642
- if (!VY.isKind(SymbolKind.TableGroup)) return [];
10643
- let P = VY.originalSymbol, HY = _.symbolMembers(P).getFiltered(UNHANDLED);
10644
- if (!HY) return [];
10645
- let UY = [];
10646
- for (let P of HY) {
10647
- if (!P.isKind(SymbolKind.TableGroupField) || !P.declaration) continue;
10648
- let HY = P.declaration.callee;
10750
+ function expandTableGroup(_, VY, P) {
10751
+ if (!P.isKind(SymbolKind.TableGroup) || !(P instanceof UseSymbol)) return [];
10752
+ let HY = P.originalSymbol, UY = _.symbolMembers(HY).getFiltered(UNHANDLED);
10753
+ if (!UY) return [];
10754
+ let WY = VY.qualifiedName, GY = [];
10755
+ for (let VY of UY) {
10756
+ if (!VY.isKind(SymbolKind.TableGroupField) || !VY.declaration) continue;
10757
+ let HY = VY.declaration.callee;
10649
10758
  if (!HY) continue;
10650
- let WY = destructureComplexVariable(HY);
10651
- if (!WY || WY.length === 0) continue;
10652
- let GY = P.declaration.filepath, KY = lookupTableInFile(_, GY, WY);
10653
- KY && VY instanceof UseSymbol && UY.push(_.symbolFactory.create(UseSymbol, {
10759
+ let UY = destructureComplexVariable(HY);
10760
+ if (!UY || UY.length === 0) continue;
10761
+ let KY = UY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : UY.slice(0, -1);
10762
+ if (KY.length !== WY.length || !WY.every((_, VY) => _ === KY[VY])) continue;
10763
+ let qY = VY.declaration.filepath, JY = lookupTableInFile(_, qY, UY);
10764
+ JY && GY.push(_.symbolFactory.create(UseSymbol, {
10654
10765
  kind: SymbolKind.Table,
10655
- declaration: KY.declaration,
10656
- usedSymbol: KY,
10766
+ declaration: JY.declaration,
10767
+ usedSymbol: JY,
10657
10768
  useSpecifierDeclaration: void 0,
10658
- name: KY.name
10659
- }, VY.filepath));
10769
+ name: JY.name
10770
+ }, P.filepath));
10660
10771
  }
10661
- return UY;
10772
+ return GY;
10662
10773
  }
10663
10774
  function lookupTableInFile(_, VY, P) {
10664
10775
  if (P.length === 1) {
10665
10776
  let HY = _.usableMembers(VY).getFiltered(UNHANDLED);
10666
10777
  return HY ? HY.nonSchemaMembers.find((_) => _.isKind(SymbolKind.Table) && _.name === P[0]) : void 0;
10667
10778
  }
10668
- let [HY, UY] = [P[0], P[P.length - 1]], WY = _.usableMembers(VY).getFiltered(UNHANDLED);
10779
+ let HY = P[0], UY = P[P.length - 1], WY = _.usableMembers(VY).getFiltered(UNHANDLED);
10669
10780
  if (!WY) return;
10670
10781
  let GY = WY.schemaMembers.find((_) => _.name === HY);
10671
10782
  if (!GY) return;
@@ -10981,6 +11092,10 @@ var customModule = {
10981
11092
  }
10982
11093
  validateSubBlock(_) {
10983
11094
  let VY = [], P = [];
11095
+ if (hasSimpleBody(_)) return VY.push(new CompileError(CompileErrorCode.UNEXPECTED_SIMPLE_BODY, `${_.type?.value} body must be a block`, _.bodyColon)), {
11096
+ errors: VY,
11097
+ warnings: P
11098
+ };
10984
11099
  if (!_.body || !(_.body instanceof BlockExpressionNode)) return {
10985
11100
  errors: VY,
10986
11101
  warnings: P
@@ -12196,7 +12311,7 @@ var tablePartialModule = {
12196
12311
  nodeFullname(_, VY) {
12197
12312
  if (!isUseSpecifier(VY)) return Report.create(PASS_THROUGH);
12198
12313
  let P = destructureComplexVariable(VY.name);
12199
- return !P || P.length === 0 ? Report.create(void 0, [new CompileError(CompileErrorCode.INVALID_NAME, "Use specifiers must have a valid name (simple name or schema-qualified name)", VY)]) : VY.isKind(ImportKind.TableGroup) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TableGroup name must be a simple name", VY)]) : VY.isKind(ImportKind.TablePartial) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TablePartial name must be a simple name", VY)]) : VY.isKind(ImportKind.Note) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A Sticky note name must be a simple name", VY)]) : (P.length === 1 && P.unshift(DEFAULT_SCHEMA_NAME$1), new Report(P));
12314
+ return !P || P.length === 0 ? Report.create(void 0, [new CompileError(CompileErrorCode.INVALID_NAME, "Use specifiers must have a valid name (simple name or schema-qualified name)", VY)]) : VY.isKind(ImportKind.TableGroup) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TableGroup name must be a simple name", VY)]) : VY.isKind(ImportKind.TablePartial) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TablePartial name must be a simple name", VY)]) : VY.isKind(ImportKind.Note) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A Sticky note name must be a simple name", VY)]) : (P.length === 1 && !VY.isKind(ImportKind.Schema) && P.unshift(DEFAULT_SCHEMA_NAME$1), new Report(P));
12200
12315
  },
12201
12316
  nodeAlias(_, VY) {
12202
12317
  return isUseSpecifier(VY) ? VY.alias ? isValidAlias(VY.alias) ? new Report(extractVariableFromExpression(VY.alias)) : new Report(void 0, [new CompileError(CompileErrorCode.INVALID_ALIAS, "Use aliases can only contain alphanumeric and underscore unless surrounded by double quotes", VY.alias)]) : new Report(void 0) : Report.create(PASS_THROUGH);
@@ -13070,77 +13185,47 @@ function isOffsetWithinElementHeader(_, VY) {
13070
13185
  let P = VY.bodyColon?.start ?? VY.body?.start;
13071
13186
  return P === void 0 ? _ >= VY.start && _ <= VY.end : _ >= VY.start && _ < P;
13072
13187
  }
13073
- function scanExistingUses(_, VY, P) {
13074
- let HY = [], UY = _.parseFile(VY).getValue()?.ast;
13075
- if (!UY) return HY;
13076
- for (let _ of UY.uses) {
13077
- let VY = _.importPath?.value ?? "";
13078
- if (!VY) {
13079
- let HY = _.useKeyword?.start ?? _.fullStart, UY = P.lastIndexOf("\n", HY - 1) + 1, WY = P.indexOf("\n", HY), GY = P.slice(UY, WY === -1 ? void 0 : WY).match(/from\s*(['"])(.*?)\1/);
13080
- GY && (VY = GY[2]);
13081
- }
13082
- let UY = [];
13083
- if (_.specifiers instanceof UseSpecifierListNode) {
13084
- let VY = new Set([
13085
- "table",
13086
- "enum",
13087
- "tablepartial",
13088
- "tablegroup",
13089
- "note",
13090
- "schema",
13091
- "from"
13092
- ]);
13093
- for (let HY of _.specifiers.specifiers) {
13094
- let _, WY;
13095
- if (HY.name) _ = HY.importKind?.value, WY = extractVariableFromExpression(HY.name), !WY && HY.name.start !== void 0 && HY.name.end !== void 0 && (WY = P.slice(HY.name.start, HY.name.end).trim());
13096
- else if (HY.importKind) {
13097
- let _ = HY.importKind.value ?? void 0;
13098
- _ && !VY.has(_.toLowerCase()) && (WY = _);
13099
- }
13100
- WY && WY.toLowerCase() !== "from" && UY.push({
13188
+ function scanExistingUses(_, VY) {
13189
+ let P = [], HY = _.parseFile(VY).getValue()?.ast;
13190
+ if (!HY) return P;
13191
+ for (let _ of HY.uses) {
13192
+ let VY = _.importPath?.value ?? "", HY = [];
13193
+ if (_.specifiers instanceof UseSpecifierListNode) for (let VY of _.specifiers.specifiers) {
13194
+ let _, P;
13195
+ if (VY.name ? (_ = VY.importKind?.value, P = extractVariableFromExpression(VY.name)) : VY.importKind && (P = VY.importKind.value ?? void 0), P) {
13196
+ let UY = VY.alias ? extractVariableFromExpression(VY.alias) : void 0;
13197
+ HY.push({
13101
13198
  kind: _,
13102
- name: WY
13199
+ name: P,
13200
+ alias: UY
13103
13201
  });
13104
13202
  }
13105
- } else _.specifiers instanceof WildcardNode && UY.push({ name: "*" });
13106
- if (UY.length === 0 && !(_.specifiers instanceof WildcardNode)) continue;
13107
- let WY = _.fullEnd;
13108
- if (!_.importPath) {
13109
- let VY = _.useKeyword?.start ?? _.fullStart, HY = P.indexOf("\n", VY);
13110
- WY = HY === -1 ? P.length : HY;
13111
13203
  }
13112
- HY.push({
13204
+ else _.specifiers instanceof WildcardNode && HY.push({ name: "*" });
13205
+ HY.length === 0 && !(_.specifiers instanceof WildcardNode) || P.push({
13113
13206
  startOffset: _.fullStart,
13114
- endOffset: WY,
13207
+ endOffset: _.fullEnd,
13115
13208
  sourceFile: VY,
13116
- specifiers: UY,
13209
+ specifiers: HY,
13117
13210
  node: _
13118
13211
  });
13119
13212
  }
13120
- return HY;
13213
+ return P;
13121
13214
  }
13122
13215
  function mergeSymbolIntoUses(_, VY, P, HY, UY, WY) {
13123
- let GY = scanExistingUses(_, UY, WY), KY = normalizeSourcePath(HY, UY), qY = GY.findIndex((_) => _.sourceFile === KY), JY = `${P} ${VY}`, YY = detectLineEnding(WY);
13216
+ let GY = scanExistingUses(_, UY), KY = HY.relativeTo(UY.dirname).replace(/\.dbml$/, ""), qY = GY.findIndex((_) => _.sourceFile === KY), JY = `${P} ${VY}`;
13124
13217
  if (qY !== -1) {
13125
13218
  let _ = GY[qY];
13126
13219
  return _.specifiers.some((_) => _.name === VY) ? { topInsert: "" } : {
13127
- topInsert: buildUseStatement(uniqueInOrder([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}`), JY]), KY, YY),
13220
+ topInsert: buildUseStatement(uniq_default([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}${_.alias ? ` as ${_.alias}` : ""}`), JY]), KY, "\n"),
13128
13221
  removeRange: expandToFullLines(WY, _.startOffset, _.endOffset)
13129
13222
  };
13130
13223
  }
13131
- return { topInsert: buildUseStatement([JY], KY, YY) };
13224
+ return { topInsert: buildUseStatement([JY], KY, "\n") };
13132
13225
  }
13133
13226
  function buildUseStatement(_, VY, P) {
13134
13227
  return `use {${P}${_.map((_) => ` ${_}`).join(P)}${P}} from '${VY}'${P}${P}`;
13135
13228
  }
13136
- function uniqueInOrder(_) {
13137
- let VY = /* @__PURE__ */ new Set(), P = [];
13138
- for (let HY of _) {
13139
- let _ = HY.trim();
13140
- VY.has(_) || (VY.add(_), P.push(HY));
13141
- }
13142
- return P;
13143
- }
13144
13229
  function expandToFullLines(_, VY, P) {
13145
13230
  let HY = _.lastIndexOf("\n", VY - 1) + 1, UY = P;
13146
13231
  for (; UY < _.length && (_[UY] === " " || _[UY] === " ");) UY++;
@@ -13149,12 +13234,6 @@ function expandToFullLines(_, VY, P) {
13149
13234
  endOffset: UY
13150
13235
  };
13151
13236
  }
13152
- function detectLineEnding(_) {
13153
- return _.includes("\r\n") ? "\r\n" : "\n";
13154
- }
13155
- function normalizeSourcePath(_, VY) {
13156
- return _.relativeTo(VY.dirname).replace(/\.dbml$/, "");
13157
- }
13158
13237
  function pickCompletionItemKind(_) {
13159
13238
  switch (_) {
13160
13239
  case SymbolKind.Schema: return CompletionItemKind.Module;
@@ -13214,7 +13293,7 @@ function addSuggestAllSuggestion(_, VY = ", ") {
13214
13293
  }
13215
13294
  function collectCrossFileSuggestions(_, VY, P) {
13216
13295
  let HY = [], UY = /* @__PURE__ */ new Set(), WY = _.layout.getSource(P) ?? "";
13217
- for (let GY of _.layout.getEntryPoints()) {
13296
+ for (let GY of _.layout.getEntrypoints()) {
13218
13297
  if (GY.equals(P)) continue;
13219
13298
  let KY = _.usableMembers(GY).getFiltered(UNHANDLED);
13220
13299
  if (KY) for (let qY of [...KY.nonSchemaMembers, ...KY.schemaMembers]) {
@@ -13334,6 +13413,7 @@ function suggestUseCompletion(_, VY, P, HY, UY) {
13334
13413
  }
13335
13414
  function suggestInUseDeclaration(_, VY, P, HY, UY, WY) {
13336
13415
  if (HY.importPath && isOffsetWithinSpan(P, HY.importPath)) return suggestUseFilepath(_, VY, HY.importPath, UY, HY);
13416
+ if (HY.importPath && P >= HY.importPath.end) return noSuggestions();
13337
13417
  if (HY.fromKeyword && P > HY.fromKeyword.end) return suggestUseFilepath(_, VY, void 0, UY, HY);
13338
13418
  if (HY.specifiers instanceof UseSpecifierListNode) {
13339
13419
  if (!HY.specifiers.openBrace) {
@@ -13403,14 +13483,14 @@ function suggestUseSpecifierStart() {
13403
13483
  return { suggestions: [{
13404
13484
  label: "* from",
13405
13485
  detail: "import all",
13406
- insertText: "* from '${1:path}'",
13486
+ insertText: "* from '${1:./path}'",
13407
13487
  insertTextRules: CompletionItemInsertTextRule.InsertAsSnippet,
13408
13488
  kind: CompletionItemKind.Snippet,
13409
13489
  range: void 0
13410
13490
  }, {
13411
13491
  label: "{ } from",
13412
13492
  detail: "import named",
13413
- insertText: "{ ${1:table} ${2:name} } from '${3:path}'",
13493
+ insertText: "{ ${1:kind} ${2:name} } from '${3:./path}'",
13414
13494
  insertTextRules: CompletionItemInsertTextRule.InsertAsSnippet,
13415
13495
  kind: CompletionItemKind.Snippet,
13416
13496
  range: void 0
@@ -13427,7 +13507,7 @@ function suggestUseFilepath(_, VY, P, HY, UY) {
13427
13507
  endColumn: _.endColumn - 1
13428
13508
  };
13429
13509
  }
13430
- let JY = /* @__PURE__ */ new Map(), YY = /* @__PURE__ */ new Map(), XY = uniqBy_default(_.layout.getEntryPoints().flatMap((VY) => [..._.reachableFiles(VY)]), (_) => _.intern());
13510
+ let JY = /* @__PURE__ */ new Map(), YY = /* @__PURE__ */ new Map(), XY = uniqBy_default(_.layout.getEntrypoints().flatMap((VY) => [..._.reachableFiles(VY)]), (_) => _.intern());
13431
13511
  for (let P of XY) {
13432
13512
  if (P.equals(VY)) continue;
13433
13513
  let HY = P.relativeTo(WY);
@@ -14216,7 +14296,7 @@ var dbmlMonarchTokensProvider = {
14216
14296
  }
14217
14297
  return [...HY].sort().map(Filepath.from);
14218
14298
  }
14219
- getEntryPoints() {
14299
+ getEntrypoints() {
14220
14300
  return [...this.files.keys()].map(Filepath.from).sort((_, VY) => _.absolute.localeCompare(VY.absolute));
14221
14301
  }
14222
14302
  clone() {
@@ -14236,7 +14316,7 @@ function containerStack(_, VY) {
14236
14316
  for (; qY.length > 0;) {
14237
14317
  let P = !1, HY = last_default$1(qY);
14238
14318
  if (HY instanceof FunctionApplicationNode) {
14239
- let UY = this.layout.getSource(_) || "";
14319
+ let UY = this.getSource(_) || "";
14240
14320
  for (let _ = HY.end; _ < VY; _ += 1) UY[_] === "\n" && (qY.pop(), P = !0);
14241
14321
  } else HY instanceof PrefixExpressionNode || HY instanceof InfixExpressionNode ? this.container.token(_, VY).token !== HY.op && (qY.pop(), P = !0) : HY instanceof ListExpressionNode ? HY.listCloseBracket && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof TupleExpressionNode ? HY.tupleCloseParen && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof CommaExpressionNode ? HY.end <= VY && (qY.pop(), P = !0) : HY instanceof BlockExpressionNode ? HY.blockCloseBrace && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof IdentifierStreamNode || HY.end < VY && (qY.pop(), P = !0);
14242
14322
  if (P) {
@@ -14293,32 +14373,40 @@ function containerScopeKind(_, VY) {
14293
14373
  }
14294
14374
  function canonicalName(_, VY) {
14295
14375
  let P = VY.originalSymbol;
14296
- if (P.filepath.intern() === _.intern()) return Report.create(fullnameToCanonical(this, P));
14297
- let HY = this.parseFile(_).getValue().ast, UY = this.nodeSymbol(HY).getFiltered(UNHANDLED);
14298
- if (!UY) return Report.create(fullnameToCanonical(this, P));
14299
- let WY = this.symbolMembers(UY).getFiltered(UNHANDLED) ?? [], GY = [...WY];
14300
- for (let _ of WY) if (_ instanceof SchemaSymbol && _.isKind(SymbolKind.Schema)) {
14301
- let VY = this.symbolMembers(_).getFiltered(UNHANDLED);
14302
- VY && GY.push(...VY);
14303
- }
14304
- for (let VY of GY) if (VY.filepath.intern() === _.intern() && VY.originalSymbol === P && (VY instanceof UseSymbol || VY instanceof AliasSymbol)) {
14305
- let _ = VY.name;
14306
- if (!_) continue;
14307
- if (_ !== P.name) return Report.create({
14376
+ if (P.filepath.equals(_)) return Report.create(fullnameToCanonical(this, P));
14377
+ let HY = [...this.symbolUses(P).getValue(), ...this.symbolAliases(P).getValue()].filter((VY) => VY.filepath.equals(_));
14378
+ for (let _ of HY) {
14379
+ let VY = _.name;
14380
+ if (!VY) continue;
14381
+ if (VY !== P.name) return Report.create({
14308
14382
  schema: "",
14309
- name: _
14383
+ name: VY
14384
+ });
14385
+ let HY = getSchemaChain(this, _);
14386
+ if (HY.length > 0) return Report.create({
14387
+ schema: HY.join("."),
14388
+ name: VY
14310
14389
  });
14311
- let HY = fullnameToCanonical(this, P);
14312
- return HY ? Report.create({
14313
- ...HY,
14314
- name: _
14390
+ let UY = fullnameToCanonical(this, P);
14391
+ return UY ? Report.create({
14392
+ ...UY,
14393
+ name: VY
14315
14394
  }) : Report.create({
14316
14395
  schema: DEFAULT_SCHEMA_NAME$1,
14317
- name: _
14396
+ name: VY
14318
14397
  });
14319
14398
  }
14320
14399
  return Report.create(fullnameToCanonical(this, P));
14321
14400
  }
14401
+ function getSchemaChain(_, VY) {
14402
+ let P = [], HY = VY;
14403
+ for (; HY;) {
14404
+ let VY = _.symbolParent(HY).find((_) => _ instanceof SchemaSymbol && _.isKind(SymbolKind.Schema));
14405
+ if (!VY || VY.isPublicSchema()) break;
14406
+ P.unshift(VY.name ?? ""), HY = VY;
14407
+ }
14408
+ return P;
14409
+ }
14322
14410
  function fullnameToCanonical(_, VY) {
14323
14411
  if (!VY.declaration) return VY.name ? {
14324
14412
  schema: DEFAULT_SCHEMA_NAME$1,
@@ -14344,16 +14432,19 @@ function fileDependencies(_) {
14344
14432
  }
14345
14433
  return P;
14346
14434
  }
14347
- function reachableFiles(_) {
14348
- let VY = /* @__PURE__ */ new Set(), P = [], HY = _ ? [_] : this.layout.getEntryPoints(), UY = 0;
14349
- for (; UY < HY.length;) {
14350
- let _ = HY[UY++], WY = _.intern();
14351
- if (!VY.has(WY)) {
14352
- VY.add(WY), P.push(_);
14353
- for (let VY of this.fileDependencies(_)) HY.push(VY);
14435
+ function walkDependencies(_, VY) {
14436
+ let P = /* @__PURE__ */ new Set(), HY = [], UY = [...VY], WY = 0;
14437
+ for (; WY < UY.length;) {
14438
+ let VY = UY[WY++], GY = VY.intern();
14439
+ if (!P.has(GY)) {
14440
+ P.add(GY), HY.push(VY);
14441
+ for (let P of _.fileDependencies(VY)) UY.push(P);
14354
14442
  }
14355
14443
  }
14356
- return P;
14444
+ return HY;
14445
+ }
14446
+ function reachableFiles(_) {
14447
+ return walkDependencies(this, _ ? [_] : this.layout.getEntrypoints());
14357
14448
  }
14358
14449
  function ast(_) {
14359
14450
  return this.bindFile(_), this.parseFile(_).getValue().ast;
@@ -14404,7 +14495,7 @@ function bindFile(_) {
14404
14495
  return new Report(void 0, [...VY.getErrors(), ...HY.getErrors()], [...VY.getWarnings(), ...HY.getWarnings()]);
14405
14496
  }
14406
14497
  function bindProject() {
14407
- let _ = collectTransitiveDependencies(this, this.layout.getEntryPoints()), VY = /* @__PURE__ */ new Map();
14498
+ let _ = collectTransitiveDependencies(this, this.layout.getEntrypoints()), VY = /* @__PURE__ */ new Map();
14408
14499
  for (let P of _) {
14409
14500
  let _ = this.bindFile(P);
14410
14501
  VY.set(P.absolute, _);
@@ -14419,7 +14510,7 @@ function interpretFile(_) {
14419
14510
  }
14420
14511
  function interpretProject() {
14421
14512
  let _ = [], VY = [], P = /* @__PURE__ */ new Set(), HY = [];
14422
- for (let _ of this.layout.getEntryPoints()) for (let VY of this.reachableFiles(_)) {
14513
+ for (let _ of this.layout.getEntrypoints()) for (let VY of this.reachableFiles(_)) {
14423
14514
  let _ = VY.intern();
14424
14515
  P.has(_) || (P.add(_), HY.push(VY));
14425
14516
  }
@@ -14427,8 +14518,10 @@ function interpretProject() {
14427
14518
  for (let P of HY) {
14428
14519
  let HY = this.parseFile(P);
14429
14520
  _.push(...HY.getErrors()), VY.push(...HY.getWarnings());
14430
- let WY = HY.getValue().ast, GY = this.nodeSymbol(WY).getFiltered(UNHANDLED), KY = GY ? this.interpretSymbol(GY, P) : Report.create(UNHANDLED), qY = KY.getFiltered(UNHANDLED);
14431
- qY && UY.set(P.absolute, qY), _.push(...KY.getErrors()), VY.push(...KY.getWarnings());
14521
+ let WY = this.bindFile(P);
14522
+ _.push(...WY.getErrors()), VY.push(...WY.getWarnings());
14523
+ let GY = HY.getValue().ast, KY = this.nodeSymbol(GY).getFiltered(UNHANDLED), qY = KY ? this.interpretSymbol(KY, P) : Report.create(UNHANDLED), JY = qY.getFiltered(UNHANDLED);
14524
+ JY && UY.set(P.absolute, JY), _.push(...qY.getErrors()), VY.push(...qY.getWarnings());
14432
14525
  }
14433
14526
  let WY = {};
14434
14527
  for (let [_, VY] of UY) WY[_] = VY;
@@ -14780,7 +14873,47 @@ var Lexer = class {
14780
14873
  }
14781
14874
  }, Parser$1 = class {
14782
14875
  constructor(_, VY, P, HY) {
14783
- this.current = 0, this.errors = [], this.contextStack = new ParsingContextStack(), this.synchronizeProgram = () => {
14876
+ this.current = 0, this.errors = [], this.contextStack = new ParsingContextStack(), this.useSpecifierList = this.contextStack.withContextDo(ParsingContext.BlockExpression, () => {
14877
+ let _ = { specifiers: [] }, VY = () => this.nodeFactory.create(UseSpecifierListNode, _);
14878
+ try {
14879
+ this.consume("Expect an opening brace '{'", SyntaxTokenKind.LBRACE), _.openBrace = this.previous();
14880
+ } catch (_) {
14881
+ if (!(_ instanceof PartialParsingError)) throw _;
14882
+ if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
14883
+ this.synchronizeUseSpecifierList();
14884
+ }
14885
+ for (; !this.isAtEnd() && !this.check(SyntaxTokenKind.RBRACE);) {
14886
+ try {
14887
+ _.specifiers.push(this.useSpecifier());
14888
+ } catch (P) {
14889
+ if (!(P instanceof PartialParsingError)) throw P;
14890
+ if (P.partialNode instanceof UseSpecifierNode && _.specifiers.push(P.partialNode), !this.canHandle(P)) throw new PartialParsingError(P.token, VY(), P.handlerContext);
14891
+ this.synchronizeUseSpecifierList();
14892
+ }
14893
+ if (this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(this.peek())) break;
14894
+ !hasTrailingNewLines(this.previous()) && !this.check(SyntaxTokenKind.RBRACE) && this.logError(this.peek(), CompileErrorCode.MISSING_SPACES, "Expect a newline between use specifiers");
14895
+ }
14896
+ try {
14897
+ this.consume("Expect a closing brace '}'", SyntaxTokenKind.RBRACE), _.closeBrace = this.previous();
14898
+ } catch (_) {
14899
+ if (!(_ instanceof PartialParsingError)) throw _;
14900
+ if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
14901
+ this.synchronizeUseSpecifierList();
14902
+ }
14903
+ return VY();
14904
+ }), this.synchronizeUseSpecifierList = () => {
14905
+ if (!this.check(SyntaxTokenKind.RBRACE)) for (markInvalid(this.advance()); !this.isAtEnd();) {
14906
+ let _ = this.peek();
14907
+ if (this.check(SyntaxTokenKind.RBRACE) || this.check(SyntaxTokenKind.STRING_LITERAL) || this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(_) || isAtStartOfLine(this.previous(), _)) break;
14908
+ markInvalid(_), this.advance();
14909
+ }
14910
+ }, this.synchronizeUseSpecifier = () => {
14911
+ for (; !this.isAtEnd();) {
14912
+ let _ = this.peek();
14913
+ if (this.check(SyntaxTokenKind.RBRACE) || isAtStartOfLine(this.previous(), _)) break;
14914
+ markInvalid(_), this.advance();
14915
+ }
14916
+ }, this.synchronizeProgram = () => {
14784
14917
  let _ = this.peek();
14785
14918
  _.kind === SyntaxTokenKind.EOF ? this.logError(_, CompileErrorCode.UNEXPECTED_EOF, "Unexpected EOF") : markInvalid(this.advance());
14786
14919
  }, this.synchronizeElementDeclarationName = () => {
@@ -15002,59 +15135,39 @@ var Lexer = class {
15002
15135
  if (this.advance(), _.useKeyword = this.previous(), this.peek().kind === SyntaxTokenKind.WILDCARD) this.advance(), _.specifiers = this.nodeFactory.create(WildcardNode, { token: this.previous() });
15003
15136
  else try {
15004
15137
  _.specifiers = this.useSpecifierList();
15005
- } catch (P) {
15006
- throw P instanceof PartialParsingError ? (_.specifiers = P.partialNode, new PartialParsingError(P.token, VY(), P.handlerContext)) : P;
15138
+ } catch (VY) {
15139
+ if (!(VY instanceof PartialParsingError)) throw VY;
15140
+ VY.partialNode instanceof UseSpecifierListNode && (_.specifiers = VY.partialNode);
15007
15141
  }
15008
15142
  let P = _.specifiers instanceof WildcardNode ? "'*'" : "specifier list";
15009
- if (isFromKeyword(this.peek())) _.fromKeyword = this.advance();
15010
- else throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, `Expect 'from' after ${P}`), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
15011
- if (this.match(SyntaxTokenKind.STRING_LITERAL)) _.importPath = this.previous();
15012
- else throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect a string literal path"), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
15013
- return VY();
15014
- }
15015
- useSpecifierList() {
15016
- let _ = { specifiers: [] }, VY = () => this.nodeFactory.create(UseSpecifierListNode, _);
15017
- try {
15018
- this.consume("Expect an opening brace '{'", SyntaxTokenKind.LBRACE), _.openBrace = this.previous();
15019
- } catch (_) {
15020
- throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
15021
- }
15022
- for (; !this.isAtEnd() && !this.check(SyntaxTokenKind.RBRACE);) {
15023
- try {
15024
- _.specifiers.push(this.useSpecifier());
15025
- } catch (P) {
15026
- throw P instanceof PartialParsingError ? (P.partialNode instanceof UseSpecifierNode && _.specifiers.push(P.partialNode), new PartialParsingError(P.token, VY(), P.handlerContext)) : P;
15027
- }
15028
- if (this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(this.peek())) break;
15029
- !hasTrailingNewLines(this.previous()) && !this.check(SyntaxTokenKind.RBRACE) && this.logError(this.peek(), CompileErrorCode.MISSING_SPACES, "Expect a newline between use specifiers");
15030
- }
15031
- try {
15032
- this.consume("Expect a closing brace '}'", SyntaxTokenKind.RBRACE), _.closeBrace = this.previous();
15033
- } catch (_) {
15034
- throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
15035
- }
15036
- return VY();
15143
+ return isFromKeyword(this.peek()) ? _.fromKeyword = this.advance() : this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, `Expect 'from' after ${P}`), this.match(SyntaxTokenKind.STRING_LITERAL) ? _.importPath = this.previous() : this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect a string literal path"), VY();
15037
15144
  }
15038
15145
  useSpecifier() {
15039
15146
  let _ = {}, VY = () => this.nodeFactory.create(UseSpecifierNode, _);
15040
15147
  try {
15041
15148
  this.consume("Expect an import kind specifier (e.g. table, enum)", SyntaxTokenKind.IDENTIFIER), _.importKind = this.previous();
15042
15149
  } catch (_) {
15043
- throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
15150
+ if (!(_ instanceof PartialParsingError)) throw _;
15151
+ if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
15152
+ this.synchronizeUseSpecifier();
15044
15153
  }
15045
15154
  if (this.check(SyntaxTokenKind.IDENTIFIER, SyntaxTokenKind.QUOTED_STRING)) try {
15046
15155
  _.name = this.normalExpression();
15047
- } catch (_) {
15048
- throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
15156
+ } catch (P) {
15157
+ if (!(P instanceof PartialParsingError)) throw P;
15158
+ if (P.partialNode instanceof SyntaxNode && (_.name = P.partialNode), !this.canHandle(P)) throw new PartialParsingError(P.token, VY(), P.handlerContext);
15159
+ this.synchronizeUseSpecifier();
15049
15160
  }
15050
- else this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an element name");
15161
+ else _.importKind && this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an element name");
15051
15162
  if (isAsKeyword(this.peek())) {
15052
15163
  _.asKeyword = this.advance();
15053
15164
  try {
15054
15165
  if (!this.check(SyntaxTokenKind.IDENTIFIER, SyntaxTokenKind.QUOTED_STRING)) throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an alias name after 'as'"), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
15055
15166
  _.alias = this.normalExpression();
15056
15167
  } catch (_) {
15057
- throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
15168
+ if (!(_ instanceof PartialParsingError)) throw _;
15169
+ if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
15170
+ this.synchronizeUseSpecifier();
15058
15171
  }
15059
15172
  }
15060
15173
  return VY();
@@ -15434,7 +15547,7 @@ function postfixBindingPower(_) {
15434
15547
  };
15435
15548
  }
15436
15549
  function parseFile(_) {
15437
- let VY = this.layout.getSource(_);
15550
+ let VY = this.getSource(_);
15438
15551
  return new Lexer(VY ?? "", _).lex().chain((P) => new Parser$1(VY ?? "", P, this.nodeIdGenerator, _).parse()).map(({ ast: VY, tokens: P }) => ({
15439
15552
  ast: VY,
15440
15553
  tokens: P,
@@ -15442,7 +15555,7 @@ function parseFile(_) {
15442
15555
  }));
15443
15556
  }
15444
15557
  function parseProject() {
15445
- let _ = collectTransitiveDependencies(this, this.layout.getEntryPoints()), VY = /* @__PURE__ */ new Map();
15558
+ let _ = collectTransitiveDependencies(this, this.layout.getEntrypoints()), VY = /* @__PURE__ */ new Map();
15446
15559
  for (let P of _) {
15447
15560
  let _ = this.parseFile(P);
15448
15561
  VY.set(P.absolute, _);
@@ -15513,11 +15626,30 @@ function resolutionIndex() {
15513
15626
  };
15514
15627
  P(VY);
15515
15628
  }
15629
+ let GY = /* @__PURE__ */ new Map(), KY = /* @__PURE__ */ new Set();
15630
+ function qY(_, VY) {
15631
+ let P = VY.intern();
15632
+ if (KY.has(P)) return;
15633
+ KY.add(P);
15634
+ let HY = _.symbolMembers(VY).getFiltered(UNHANDLED);
15635
+ if (HY) for (let P of HY) {
15636
+ let HY = P.intern(), UY = GY.get(HY);
15637
+ UY || (UY = [], GY.set(HY, UY)), UY.push(VY), P instanceof SchemaSymbol && P.isKind(SymbolKind.Schema) && qY(_, P);
15638
+ }
15639
+ }
15640
+ for (let _ of P.values()) {
15641
+ let VY = _.getValue().ast, P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
15642
+ P && qY(this, P);
15643
+ }
15516
15644
  return {
15517
15645
  references: _,
15518
- metadata: VY
15646
+ metadata: VY,
15647
+ parents: GY
15519
15648
  };
15520
15649
  }
15650
+ function symbolParent(_) {
15651
+ return this.resolutionIndex().parents.get(_.intern()) ?? [];
15652
+ }
15521
15653
  function symbolReferences(_) {
15522
15654
  return this.resolutionIndex().references.get(_.intern()) ?? [];
15523
15655
  }
@@ -15626,59 +15758,60 @@ function findReplacements(_, VY, P, HY, UY) {
15626
15758
  return WY;
15627
15759
  }
15628
15760
  function renameTable$1(_, VY, P) {
15629
- let HY = this.layout.clone(), UY = normalizeTableName(VY), WY = normalizeTableName(P), GY = UY.schema, KY = UY.table, qY = WY.schema, JY = WY.table, YY = lookupTableSymbol(this, _, GY, KY);
15630
- if (!YY || YY instanceof AliasSymbol || checkForNameCollision(this, _, GY, KY, qY, JY)) return HY;
15631
- if (YY instanceof UseSymbol && YY.useSpecifierDeclaration instanceof UseSpecifierNode && YY.useSpecifierDeclaration.alias) {
15632
- let VY = YY.useSpecifierDeclaration;
15633
- if (this.nodeAlias(VY).getFiltered(UNHANDLED) === KY) return renameAlias(this, HY, _, VY, YY, qY, JY);
15761
+ let HY = normalizeTableName(VY), UY = normalizeTableName(P), WY = HY.schema, GY = HY.table, KY = UY.schema, qY = UY.table, JY = lookupTableSymbol(this, _, WY, GY);
15762
+ if (!JY || JY instanceof AliasSymbol || checkForNameCollision(this, _, WY, GY, KY, qY)) return /* @__PURE__ */ new Map();
15763
+ if (JY instanceof UseSymbol && JY.useSpecifierDeclaration instanceof UseSpecifierNode && JY.useSpecifierDeclaration.alias) {
15764
+ let VY = JY.useSpecifierDeclaration;
15765
+ if (this.nodeAlias(VY).getFiltered(UNHANDLED) === GY) return renameAlias(this, _, VY, JY, KY, qY);
15634
15766
  }
15635
- return renameRealDeclaration(this, HY, YY, GY, KY, qY, JY);
15767
+ return renameRealDeclaration(this, JY, WY, GY, KY, qY);
15636
15768
  }
15637
- function renameAlias(_, VY, P, HY, UY, WY, GY) {
15638
- let KY = _.layout.getSource(P) ?? "";
15639
- if (!HY.alias) return VY;
15640
- let qY = formatTableName(WY, GY, KY.substring(HY.alias.start, HY.alias.end).includes("\"")), JY = [];
15641
- JY.push({
15642
- start: HY.alias.start,
15643
- end: HY.alias.end,
15644
- newText: qY.formattedTable
15769
+ function renameAlias(_, VY, P, HY, UY, WY) {
15770
+ let GY = _.getSource(VY) ?? "";
15771
+ if (!P.alias) return /* @__PURE__ */ new Map();
15772
+ let KY = formatTableName(UY, WY, GY.substring(P.alias.start, P.alias.end).includes("\"")), qY = [];
15773
+ qY.push({
15774
+ start: P.alias.start,
15775
+ end: P.alias.end,
15776
+ newText: KY.formattedTable
15645
15777
  });
15646
- let YY = _.symbolReferences(UY);
15647
- for (let _ of YY) _.filepath.absolute === P.absolute && _ !== HY.alias && JY.push({
15778
+ let JY = _.symbolReferences(HY);
15779
+ for (let _ of JY) _.filepath.absolute === VY.absolute && _ !== P.alias && qY.push({
15648
15780
  start: _.start,
15649
15781
  end: _.end,
15650
- newText: qY.formattedTable
15782
+ newText: KY.formattedTable
15651
15783
  });
15652
- return VY.setSource(P, applyTextEdits(KY, JY)), VY;
15784
+ return new Map([[VY.absolute, applyTextEdits(GY, qY)]]);
15653
15785
  }
15654
- function renameRealDeclaration(_, VY, P, HY, UY, WY, GY) {
15655
- let KY = P.originalSymbol, qY = KY.declaration;
15656
- if (!qY || !(qY instanceof ElementDeclarationNode)) return VY;
15657
- let JY = qY.filepath;
15658
- if (!JY) return VY;
15659
- let YY = formatTableName(WY, GY, checkIfDeclarationUsesQuotes(qY, _.layout.getSource(JY) ?? "")), XY = /* @__PURE__ */ new Map(), ZY = (_, VY) => {
15660
- let P = _.absolute, HY = XY.get(P);
15786
+ function renameRealDeclaration(_, VY, P, HY, UY, WY) {
15787
+ let GY = VY.originalSymbol, KY = GY.declaration;
15788
+ if (!KY || !(KY instanceof ElementDeclarationNode)) return /* @__PURE__ */ new Map();
15789
+ let qY = KY.filepath;
15790
+ if (!qY) return /* @__PURE__ */ new Map();
15791
+ let JY = formatTableName(UY, WY, checkIfDeclarationUsesQuotes(KY, _.getSource(qY) ?? "")), YY = /* @__PURE__ */ new Map(), XY = (_, VY) => {
15792
+ let P = _.absolute, HY = YY.get(P);
15661
15793
  HY || (HY = {
15662
15794
  fp: _,
15663
15795
  edits: []
15664
- }, XY.set(P, HY)), HY.edits.push(VY);
15665
- }, QY = qY.name;
15666
- QY && ZY(JY, {
15667
- start: QY.start,
15668
- end: QY.end,
15669
- newText: buildReplacementText(YY)
15796
+ }, YY.set(P, HY)), HY.edits.push(VY);
15797
+ }, ZY = KY.name;
15798
+ ZY && XY(qY, {
15799
+ start: ZY.start,
15800
+ end: ZY.end,
15801
+ newText: buildReplacementText(JY)
15670
15802
  });
15671
- let $Y = _.symbolReferences(KY);
15672
- for (let VY of $Y) {
15673
- if (VY === QY) continue;
15674
- let P = VY.filepath, WY = _.layout.getSource(P) ?? "";
15675
- for (let _ of findReplacements([VY], HY, UY, YY, WY)) ZY(P, _);
15676
- }
15677
- for (let { fp: P, edits: HY } of XY.values()) {
15678
- let UY = _.layout.getSource(P) ?? "";
15679
- VY.setSource(P, applyTextEdits(UY, HY));
15680
- }
15681
- return VY;
15803
+ let QY = _.symbolReferences(GY);
15804
+ for (let VY of QY) {
15805
+ if (VY === ZY) continue;
15806
+ let UY = VY.filepath, WY = _.getSource(UY) ?? "";
15807
+ for (let _ of findReplacements([VY], P, HY, JY, WY)) XY(UY, _);
15808
+ }
15809
+ let $Y = /* @__PURE__ */ new Map();
15810
+ for (let { fp: VY, edits: P } of YY.values()) {
15811
+ let HY = _.getSource(VY) ?? "";
15812
+ $Y.set(VY.absolute, applyTextEdits(HY, P));
15813
+ }
15814
+ return $Y;
15682
15815
  }
15683
15816
  function findDiagramViewBlocks$1(_) {
15684
15817
  let VY = [], P = new Lexer(_, DEFAULT_ENTRY).lex();
@@ -15741,7 +15874,7 @@ function generateDiagramViewBlock(_, VY) {
15741
15874
  return YY.length > 0 && emitTablesBlock(eX, YY), XY.length > 0 && emitTableGroupsBlock(eX, XY), ZY.length > 0 && emitSchemasBlock(eX, ZY), $Y && emitNotesBlock(eX, GY), eX.push("}"), eX.join("\n");
15742
15875
  }
15743
15876
  function syncDiagramView$1(_, VY, P) {
15744
- let HY = this.layout.getSource(_) ?? "", UY = P ?? findDiagramViewBlocks$1(HY), WY = [];
15877
+ let HY = this.getSource(_) ?? "", UY = P ?? findDiagramViewBlocks$1(HY), WY = [];
15745
15878
  for (let _ of VY) {
15746
15879
  let VY = applyOperation(HY, _, UY);
15747
15880
  WY.push(...VY);
@@ -15801,12 +15934,12 @@ function computeDeleteEdit(_, VY, P) {
15801
15934
  }];
15802
15935
  }
15803
15936
  var COMPUTING = Symbol("COMPUTING"), Compiler = class {
15804
- constructor() {
15805
- this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.layout = new MemoryProjectLayout(), this.globalCache = /* @__PURE__ */ new Map(), this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(parseFile), this.parseProject = this.globalQuery(parseProject), this.validateNode = this.localQuery(validateNode), this.validateFile = this.localQuery(validateFile), this.nodeFullname = this.localQuery(nodeFullname), this.nodeAlias = this.localQuery(nodeAlias), this.nodeSettings = this.localQuery(nodeSettings), this.canonicalName = this.globalQuery(canonicalName), this.bindNode = this.globalQuery(bindNode), this.bindFile = this.globalQuery(bindFile), this.bindProject = this.globalQuery(bindProject), this.interpretSymbol = this.globalQuery(interpretSymbol), this.interpretMetadata = interpretMetadata.bind(this), this.interpretFile = this.globalQuery(interpretFile), this.interpretProject = this.globalQuery(interpretProject), this.nodeSymbol = this.globalQuery(nodeSymbol), this.nodeMetadata = this.globalQuery(nodeMetadata), this.symbolMembers = this.globalQuery(symbolMembers), this.lookupMembers = this.globalQuery(lookupMembers), this.nodeReferee = this.globalQuery(nodeReferee), this.resolutionIndex = this.globalQuery(resolutionIndex), this.symbolReferences = this.globalQuery(symbolReferences), this.symbolMetadata = this.globalQuery(symbolMetadata), this.symbolAliases = this.globalQuery(symbolAliases), this.symbolUses = this.globalQuery(symbolUses), this.fileDependencies = this.localQuery(fileDependencies), this.reachableFiles = this.globalQuery(reachableFiles), this.usableMembers = this.globalQuery(usableMembers), this.nodeAtPosition = this.localQuery(nodeAtPosition), this.renameTable = renameTable$1.bind(this), this.syncDiagramView = syncDiagramView$1.bind(this), this.token = {
15937
+ constructor(_ = new MemoryProjectLayout()) {
15938
+ this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(parseFile), this.parseProject = this.globalQuery(parseProject), this.validateNode = this.localQuery(validateNode), this.validateFile = this.localQuery(validateFile), this.nodeFullname = this.localQuery(nodeFullname), this.nodeAlias = this.localQuery(nodeAlias), this.nodeSettings = this.localQuery(nodeSettings), this.canonicalName = this.globalQuery(canonicalName), this.bindNode = this.globalQuery(bindNode), this.bindFile = this.globalQuery(bindFile), this.bindProject = this.globalQuery(bindProject), this.interpretSymbol = this.globalQuery(interpretSymbol), this.interpretMetadata = interpretMetadata.bind(this), this.interpretFile = this.globalQuery(interpretFile), this.interpretProject = this.globalQuery(interpretProject), this.nodeSymbol = this.globalQuery(nodeSymbol), this.nodeMetadata = this.globalQuery(nodeMetadata), this.symbolMembers = this.globalQuery(symbolMembers), this.lookupMembers = this.globalQuery(lookupMembers), this.nodeReferee = this.globalQuery(nodeReferee), this.resolutionIndex = this.globalQuery(resolutionIndex), this.symbolReferences = this.globalQuery(symbolReferences), this.symbolParent = this.globalQuery(symbolParent), this.symbolMetadata = this.globalQuery(symbolMetadata), this.symbolAliases = this.globalQuery(symbolAliases), this.symbolUses = this.globalQuery(symbolUses), this.fileDependencies = this.localQuery(fileDependencies), this.reachableFiles = this.globalQuery(reachableFiles), this.usableMembers = this.globalQuery(usableMembers), this.nodeAtPosition = this.localQuery(nodeAtPosition), this.renameTable = renameTable$1.bind(this), this.syncDiagramView = syncDiagramView$1.bind(this), this.token = {
15806
15939
  invalidStream: this.localQuery(invalidStream),
15807
15940
  flatStream: this.localQuery(flatStream)
15808
15941
  }, this.parse = {
15809
- source: (_) => this.layout.getSource(_) || "",
15942
+ source: (_) => this.getSource(_) || "",
15810
15943
  ast: (_ = DEFAULT_ENTRY) => ast.call(this, _),
15811
15944
  errors: (_ = DEFAULT_ENTRY) => errors.call(this, _),
15812
15945
  warnings: (_ = DEFAULT_ENTRY) => warnings.call(this, _),
@@ -15819,21 +15952,25 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
15819
15952
  element: this.localQuery(containerElement),
15820
15953
  scope: this.localQuery(containerScope),
15821
15954
  scopeKind: this.localQuery(containerScopeKind)
15822
- };
15955
+ }, this.layout = _;
15823
15956
  }
15824
- setSource(_, VY) {
15825
- this.layout.setSource(_, VY), this.localCache.delete(_.intern()), this.globalCache.clear();
15957
+ getSource(_) {
15958
+ return this.layout.getSource(_);
15826
15959
  }
15827
- clearSource() {
15828
- this.layout = new MemoryProjectLayout(), this.localCache.clear(), this.globalCache.clear();
15960
+ cleanStaleLocalCache(_) {
15961
+ let VY = this.layout.getSource(_), P = _.absolute;
15962
+ this.sourceSnapshot.has(P) && this.sourceSnapshot.get(P) !== VY && (this.localCache.delete(_.intern()), this.globalCache.clear()), this.sourceSnapshot.set(P, VY);
15829
15963
  }
15830
- deleteSource(_) {
15831
- this.layout.deleteSource(_), this.localCache.delete(_.intern()), this.globalCache.clear();
15964
+ cleanStaleGlobalCache() {
15965
+ let _ = this.layout.getEntrypoints(), VY = !1;
15966
+ this.entrypointsSnapshot !== void 0 && (this.entrypointsSnapshot.length !== _.length || this.entrypointsSnapshot.some((VY, P) => VY.absolute !== _[P].absolute)) && (VY = !0), this.entrypointsSnapshot = _;
15967
+ for (let VY of walkDependencies(this, _)) this.cleanStaleLocalCache(VY);
15968
+ VY && this.globalCache.clear();
15832
15969
  }
15833
15970
  globalQuery(_) {
15834
15971
  let VY = Symbol();
15835
15972
  return ((...P) => {
15836
- this.globalCache.has(VY) || this.globalCache.set(VY, /* @__PURE__ */ new Map());
15973
+ this.cleanStaleGlobalCache(), this.globalCache.has(VY) || this.globalCache.set(VY, /* @__PURE__ */ new Map());
15837
15974
  let HY = P.map((_) => intern(_)).join("\0"), UY = this.globalCache.get(VY);
15838
15975
  if (UY.has(HY)) {
15839
15976
  let VY = UY.get(HY);
@@ -15852,25 +15989,27 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
15852
15989
  localQuery(_) {
15853
15990
  let VY = Symbol();
15854
15991
  return ((...P) => {
15855
- let [HY] = P, UY = (HY instanceof SyntaxNode ? HY.filepath : HY).intern(), WY = P.map((_) => intern(_)).join("\0"), GY = this.localCache.get(UY);
15856
- GY || (GY = /* @__PURE__ */ new Map(), this.localCache.set(UY, GY));
15857
- let KY = GY.get(VY);
15858
- if (KY || (KY = /* @__PURE__ */ new Map(), GY.set(VY, KY)), KY.has(WY)) {
15859
- let VY = KY.get(WY);
15860
- if (VY === COMPUTING) throw Error(`Cycle detected in query: ${_.name}(${UY}, ${WY})`);
15992
+ let [HY] = P, UY = HY instanceof SyntaxNode ? HY.filepath : HY;
15993
+ this.cleanStaleLocalCache(UY);
15994
+ let WY = UY.intern(), GY = P.map((_) => intern(_)).join("\0"), KY = this.localCache.get(WY);
15995
+ KY || (KY = /* @__PURE__ */ new Map(), this.localCache.set(WY, KY));
15996
+ let qY = KY.get(VY);
15997
+ if (qY || (qY = /* @__PURE__ */ new Map(), KY.set(VY, qY)), qY.has(GY)) {
15998
+ let VY = qY.get(GY);
15999
+ if (VY === COMPUTING) throw Error(`Cycle detected in query: ${_.name}(${WY}, ${GY})`);
15861
16000
  return VY;
15862
16001
  }
15863
- KY.set(WY, COMPUTING);
16002
+ qY.set(GY, COMPUTING);
15864
16003
  try {
15865
16004
  let VY = _.apply(this, P);
15866
- return KY.set(WY, VY), VY;
16005
+ return qY.set(GY, VY), VY;
15867
16006
  } catch (_) {
15868
- throw KY.delete(WY), _;
16007
+ throw qY.delete(GY), _;
15869
16008
  }
15870
16009
  });
15871
16010
  }
15872
16011
  findDiagramViewBlocks(_) {
15873
- return findDiagramViewBlocks$1(this.layout.getSource(_) ?? "");
16012
+ return findDiagramViewBlocks$1(this.getSource(_) ?? "");
15874
16013
  }
15875
16014
  initMonacoServices(_) {
15876
16015
  let VY = _?.autocompletion?.triggerCharacters ?? [
@@ -1825423,9 +1825562,9 @@ var init_actions = __esmMin((() => {
1825423
1825562
  return import_postgresParser.default.parse(_);
1825424
1825563
  }
1825425
1825564
  static parseDBMLToJSONv2(_, VY) {
1825426
- let P = VY || new Compiler();
1825427
- P.setSource(DEFAULT_ENTRY, _);
1825428
- let HY = P.parse.errors(DEFAULT_ENTRY).map((_) => ({
1825565
+ let P = VY || new Compiler(), HY = new MemoryProjectLayout();
1825566
+ HY.setSource(DEFAULT_ENTRY, _), P.layout = HY;
1825567
+ let UY = P.parse.errors(DEFAULT_ENTRY).map((_) => ({
1825429
1825568
  message: _.diagnostic,
1825430
1825569
  location: {
1825431
1825570
  start: {
@@ -1825439,7 +1825578,7 @@ var init_actions = __esmMin((() => {
1825439
1825578
  },
1825440
1825579
  code: _.code
1825441
1825580
  }));
1825442
- if (HY.length > 0) throw CompilerError.create(HY);
1825581
+ if (UY.length > 0) throw CompilerError.create(UY);
1825443
1825582
  return P.parse.rawDb(DEFAULT_ENTRY);
1825444
1825583
  }
1825445
1825584
  static parseDBMLToJSON(_) {
@@ -1825635,16 +1825774,22 @@ var import_default = {
1825635
1825774
  generateDbml
1825636
1825775
  };
1825637
1825776
  function renameTable(_, VY, P) {
1825638
- let HY = new Compiler();
1825639
- return HY.setSource(DEFAULT_ENTRY, P), HY.renameTable(DEFAULT_ENTRY, _, VY).getSource(DEFAULT_ENTRY) ?? P;
1825777
+ let HY = new MemoryProjectLayout();
1825778
+ HY.setSource(DEFAULT_ENTRY, P);
1825779
+ let UY = new Compiler();
1825780
+ return UY.layout = HY, UY.renameTable(DEFAULT_ENTRY, _, VY).get(DEFAULT_ENTRY.absolute) ?? P;
1825640
1825781
  }
1825641
1825782
  function syncDiagramView(_, VY, P) {
1825642
- let HY = new Compiler();
1825643
- return HY.setSource(DEFAULT_ENTRY, _), HY.syncDiagramView(DEFAULT_ENTRY, VY, P);
1825783
+ let HY = new MemoryProjectLayout();
1825784
+ HY.setSource(DEFAULT_ENTRY, _);
1825785
+ let UY = new Compiler();
1825786
+ return UY.layout = HY, UY.syncDiagramView(DEFAULT_ENTRY, VY, P);
1825644
1825787
  }
1825645
1825788
  function findDiagramViewBlocks(_) {
1825646
- let VY = new Compiler();
1825647
- return VY.setSource(DEFAULT_ENTRY, _), VY.findDiagramViewBlocks(DEFAULT_ENTRY);
1825789
+ let VY = new MemoryProjectLayout();
1825790
+ VY.setSource(DEFAULT_ENTRY, _);
1825791
+ let P = new Compiler();
1825792
+ return P.layout = VY, P.findDiagramViewBlocks(DEFAULT_ENTRY);
1825648
1825793
  }
1825649
- const VERSION = "8.0.0-alpha.0";
1825794
+ const VERSION = "8.0.0-alpha.10";
1825650
1825795
  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 };