@dbml/core 8.0.0-alpha.4 → 8.0.0-alpha.5

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 +107 -107
  2. package/lib/index.mjs +46 -38
  3. package/package.json +3 -3
package/lib/index.mjs CHANGED
@@ -9395,7 +9395,7 @@ function nodeRefereeOfRefEndpoint(_, VY, P) {
9395
9395
  }
9396
9396
  var useUtils = { visibleName(_, VY) {
9397
9397
  let P = VY instanceof SyntaxNode ? VY : VY.useSpecifierDeclaration instanceof UseSpecifierNode ? VY.useSpecifierDeclaration : VY.declaration;
9398
- if (P) return _.nodeAlias(P).mapFiltered((_) => [_], UNHANDLED, void 0).getFiltered(UNHANDLED) || _.nodeFullname(P).getFiltered(UNHANDLED);
9398
+ 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);
9399
9399
  } }, useModule$1 = {
9400
9400
  nodeSymbol(_, VY) {
9401
9401
  if (!isUseSpecifier(VY) || !VY.name) return Report.create(PASS_THROUGH);
@@ -10294,16 +10294,11 @@ function nodeRefereeOfTableGroupField(_, VY, P) {
10294
10294
  let HY = extractVarNameFromPrimaryVariable(P) ?? "";
10295
10295
  if (!isAccessExpression(P.parentNode)) {
10296
10296
  let UY = _.symbolMembers(VY).getFiltered(UNHANDLED);
10297
- if (UY) for (let VY of UY) {
10298
- if (!(VY instanceof SchemaSymbol)) continue;
10299
- let P = _.lookupMembers(VY, SymbolKind.Table, HY);
10300
- if (P) return Report.create(P);
10301
- if (!VY.isPublicSchema()) {
10302
- let P = _.symbolMembers(VY).getFiltered(UNHANDLED);
10303
- if (P) {
10304
- let VY = P.find((VY) => !VY.isKind(SymbolKind.Table) || !VY.declaration ? !1 : _.nodeAlias(VY.declaration).getFiltered(UNHANDLED) === HY);
10305
- if (VY) return new Report(VY);
10306
- }
10297
+ if (UY) {
10298
+ let VY = UY.find((_) => _ instanceof SchemaSymbol && _.isPublicSchema());
10299
+ if (VY) {
10300
+ let P = _.lookupMembers(VY, SymbolKind.Table, HY);
10301
+ if (P) return Report.create(P);
10307
10302
  }
10308
10303
  }
10309
10304
  let WY = _.lookupMembers(VY, SymbolKind.Table, HY);
@@ -10635,7 +10630,17 @@ var schemaModule = { symbolMembers(_, VY) {
10635
10630
  for (let { importPath: P, node: GY } of HY.uses.wildcard) UY.push(...handleMemberWildcardUses(_, VY, P, GY, WY));
10636
10631
  UY.push(...WY.values());
10637
10632
  let KY = [...UY];
10638
- for (let VY of UY) VY.isKind(SymbolKind.TableGroup) && KY.push(...expandTableGroup(_, VY));
10633
+ {
10634
+ let P = UY.filter((_) => _.isKind(SymbolKind.TableGroup));
10635
+ if (!VY.isPublicSchema()) {
10636
+ let HY = _.usableMembers(VY.filepath).getFiltered(UNHANDLED)?.schemaMembers.find((_) => _.isPublicSchema());
10637
+ if (HY) {
10638
+ let VY = _.symbolMembers(HY).getFiltered(UNHANDLED);
10639
+ VY && P.push(...VY.filter((_) => _.isKind(SymbolKind.TableGroup)));
10640
+ }
10641
+ }
10642
+ for (let HY of P) KY.push(...expandTableGroup(_, VY, HY));
10643
+ }
10639
10644
  let qY = /* @__PURE__ */ new Set(), JY = KY.filter((_) => {
10640
10645
  let VY = `${_.originalSymbol.intern()}:${_.name ?? ""}`;
10641
10646
  return qY.has(VY) ? !1 : (qY.add(VY), !0);
@@ -10680,13 +10685,14 @@ function mergeImportedSchema(_, VY, P, HY = /* @__PURE__ */ new Set()) {
10680
10685
  HY.add(WY);
10681
10686
  let GY = _.usableMembers(UY).getFiltered(UNHANDLED);
10682
10687
  if (!GY) return [];
10683
- let KY = GY.nonSchemaMembers.filter((_) => _.canBeImported).map((P) => _.symbolFactory.create(UseSymbol, {
10684
- kind: P.kind,
10685
- declaration: P.originalSymbol.declaration,
10686
- usedSymbol: P.originalSymbol,
10687
- useSpecifierDeclaration: void 0,
10688
- name: P.name
10688
+ let KY = GY.nonSchemaMembers.filter((_) => _.canBeImported).map((HY) => _.symbolFactory.create(UseSymbol, {
10689
+ kind: HY.kind,
10690
+ declaration: HY.originalSymbol.declaration,
10691
+ usedSymbol: HY.originalSymbol,
10692
+ useSpecifierDeclaration: P,
10693
+ name: HY.name
10689
10694
  }, VY.filepath));
10695
+ for (let P of [...KY]) P.isKind(SymbolKind.TableGroup) && KY.push(...expandTableGroup(_, VY, P));
10690
10696
  for (let P of GY.reuses.selective) KY.push(...mergeImportedSchema(_, VY, P, HY));
10691
10697
  return KY;
10692
10698
  }
@@ -10708,7 +10714,7 @@ function handleMemberWildcardUses(_, VY, P, HY, UY, WY = /* @__PURE__ */ new Set
10708
10714
  let { reuses: { selective: JY, wildcard: YY } } = KY;
10709
10715
  for (let P of JY) {
10710
10716
  let HY = handleMemberSelectiveUses(_, VY, P, UY).getFiltered(UNHANDLED);
10711
- HY && qY.push(HY);
10717
+ HY && qY.push(HY), qY.push(...mergeImportedSchema(_, VY, P));
10712
10718
  }
10713
10719
  for (let { importPath: P } of YY) qY.push(...handleMemberWildcardUses(_, VY, P, HY, UY, WY));
10714
10720
  return qY;
@@ -10726,34 +10732,36 @@ function findSchemaSymbolInFilepath(_, VY, P) {
10726
10732
  }
10727
10733
  return WY;
10728
10734
  }
10729
- function expandTableGroup(_, VY) {
10730
- if (!VY.isKind(SymbolKind.TableGroup)) return [];
10731
- let P = VY.originalSymbol, HY = _.symbolMembers(P).getFiltered(UNHANDLED);
10732
- if (!HY) return [];
10733
- let UY = [];
10734
- for (let P of HY) {
10735
- if (!P.isKind(SymbolKind.TableGroupField) || !P.declaration) continue;
10736
- let HY = P.declaration.callee;
10735
+ function expandTableGroup(_, VY, P) {
10736
+ if (!P.isKind(SymbolKind.TableGroup) || !(P instanceof UseSymbol)) return [];
10737
+ let HY = P.originalSymbol, UY = _.symbolMembers(HY).getFiltered(UNHANDLED);
10738
+ if (!UY) return [];
10739
+ let WY = VY.qualifiedName, GY = [];
10740
+ for (let VY of UY) {
10741
+ if (!VY.isKind(SymbolKind.TableGroupField) || !VY.declaration) continue;
10742
+ let HY = VY.declaration.callee;
10737
10743
  if (!HY) continue;
10738
- let WY = destructureComplexVariable(HY);
10739
- if (!WY || WY.length === 0) continue;
10740
- let GY = P.declaration.filepath, KY = lookupTableInFile(_, GY, WY);
10741
- KY && VY instanceof UseSymbol && UY.push(_.symbolFactory.create(UseSymbol, {
10744
+ let UY = destructureComplexVariable(HY);
10745
+ if (!UY || UY.length === 0) continue;
10746
+ let KY = UY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : UY.slice(0, -1);
10747
+ if (KY.length !== WY.length || !WY.every((_, VY) => _ === KY[VY])) continue;
10748
+ let qY = VY.declaration.filepath, JY = lookupTableInFile(_, qY, UY);
10749
+ JY && GY.push(_.symbolFactory.create(UseSymbol, {
10742
10750
  kind: SymbolKind.Table,
10743
- declaration: KY.declaration,
10744
- usedSymbol: KY,
10751
+ declaration: JY.declaration,
10752
+ usedSymbol: JY,
10745
10753
  useSpecifierDeclaration: void 0,
10746
- name: KY.name
10747
- }, VY.filepath));
10754
+ name: JY.name
10755
+ }, P.filepath));
10748
10756
  }
10749
- return UY;
10757
+ return GY;
10750
10758
  }
10751
10759
  function lookupTableInFile(_, VY, P) {
10752
10760
  if (P.length === 1) {
10753
10761
  let HY = _.usableMembers(VY).getFiltered(UNHANDLED);
10754
10762
  return HY ? HY.nonSchemaMembers.find((_) => _.isKind(SymbolKind.Table) && _.name === P[0]) : void 0;
10755
10763
  }
10756
- let [HY, UY] = [P[0], P[P.length - 1]], WY = _.usableMembers(VY).getFiltered(UNHANDLED);
10764
+ let HY = P[0], UY = P[P.length - 1], WY = _.usableMembers(VY).getFiltered(UNHANDLED);
10757
10765
  if (!WY) return;
10758
10766
  let GY = WY.schemaMembers.find((_) => _.name === HY);
10759
10767
  if (!GY) return;
@@ -1825734,5 +1825742,5 @@ function findDiagramViewBlocks(_) {
1825734
1825742
  let VY = new Compiler();
1825735
1825743
  return VY.setSource(DEFAULT_ENTRY, _), VY.findDiagramViewBlocks(DEFAULT_ENTRY);
1825736
1825744
  }
1825737
- const VERSION = "8.0.0-alpha.4";
1825745
+ const VERSION = "8.0.0-alpha.5";
1825738
1825746
  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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/core",
4
- "version": "8.0.0-alpha.4",
4
+ "version": "8.0.0-alpha.5",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -46,7 +46,7 @@
46
46
  "lint:fix": "eslint --fix ."
47
47
  },
48
48
  "dependencies": {
49
- "@dbml/parse": "^8.0.0-alpha.4",
49
+ "@dbml/parse": "^8.0.0-alpha.5",
50
50
  "antlr4": "^4.13.1",
51
51
  "lodash": "^4.18.1",
52
52
  "lodash-es": "^4.18.1",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "bluebird": "^3.5.5"
59
59
  },
60
- "gitHead": "17d4675433b702912a20dcc65a63c03c73c56db5",
60
+ "gitHead": "2e6795b120c2ca4f16bb542295b2152f091d6ed9",
61
61
  "engines": {
62
62
  "node": ">=16"
63
63
  }