@dbml/parse 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.
@@ -8196,7 +8196,7 @@ function nodeRefereeOfRefEndpoint(r, N, P) {
8196
8196
  }
8197
8197
  const useUtils = { visibleName(r, M) {
8198
8198
  let N = M instanceof SyntaxNode ? M : M.useSpecifierDeclaration instanceof UseSpecifierNode ? M.useSpecifierDeclaration : M.declaration;
8199
- if (N) return r.nodeAlias(N).mapFiltered((r) => [r], UNHANDLED, void 0).getFiltered(UNHANDLED) || r.nodeFullname(N).getFiltered(UNHANDLED);
8199
+ if (N instanceof UseSpecifierNode && M instanceof NodeSymbol && N.getSymbolKind() !== M.kind && (N = M.declaration), N) return r.nodeAlias(N).mapFiltered((r) => [r], UNHANDLED, void 0).getFiltered(UNHANDLED) || r.nodeFullname(N).getFiltered(UNHANDLED);
8200
8200
  } }, useModule$1 = {
8201
8201
  nodeSymbol(N, P) {
8202
8202
  if (!isUseSpecifier(P) || !P.name) return Report.create(PASS_THROUGH);
@@ -9097,16 +9097,11 @@ function nodeRefereeOfTableGroupField(r, N, P) {
9097
9097
  let F = extractVarNameFromPrimaryVariable(P) ?? "";
9098
9098
  if (!isAccessExpression(P.parentNode)) {
9099
9099
  let I = r.symbolMembers(N).getFiltered(UNHANDLED);
9100
- if (I) for (let N of I) {
9101
- if (!(N instanceof SchemaSymbol)) continue;
9102
- let P = r.lookupMembers(N, SymbolKind.Table, F);
9103
- if (P) return Report.create(P);
9104
- if (!N.isPublicSchema()) {
9105
- let P = r.symbolMembers(N).getFiltered(UNHANDLED);
9106
- if (P) {
9107
- let N = P.find((M) => !M.isKind(SymbolKind.Table) || !M.declaration ? !1 : r.nodeAlias(M.declaration).getFiltered(UNHANDLED) === F);
9108
- if (N) return new Report(N);
9109
- }
9100
+ if (I) {
9101
+ let j = I.find((r) => r instanceof SchemaSymbol && r.isPublicSchema());
9102
+ if (j) {
9103
+ let N = r.lookupMembers(j, SymbolKind.Table, F);
9104
+ if (N) return Report.create(N);
9110
9105
  }
9111
9106
  }
9112
9107
  let L = r.lookupMembers(N, SymbolKind.Table, F);
@@ -9439,7 +9434,17 @@ const schemaModule = { symbolMembers(N, P) {
9439
9434
  for (let { importPath: r, node: j } of I.uses.wildcard) L.push(...handleMemberWildcardUses(N, P, r, j, R));
9440
9435
  L.push(...R.values());
9441
9436
  let B = [...L];
9442
- for (let r of L) r.isKind(SymbolKind.TableGroup) && B.push(...expandTableGroup(N, r));
9437
+ {
9438
+ let r = L.filter((r) => r.isKind(SymbolKind.TableGroup));
9439
+ if (!P.isPublicSchema()) {
9440
+ let M = N.usableMembers(P.filepath).getFiltered(UNHANDLED)?.schemaMembers.find((r) => r.isPublicSchema());
9441
+ if (M) {
9442
+ let P = N.symbolMembers(M).getFiltered(UNHANDLED);
9443
+ P && r.push(...P.filter((r) => r.isKind(SymbolKind.TableGroup)));
9444
+ }
9445
+ }
9446
+ for (let j of r) B.push(...expandTableGroup(N, P, j));
9447
+ }
9443
9448
  let V = /* @__PURE__ */ new Set(), H = B.filter((r) => {
9444
9449
  let j = `${r.originalSymbol.intern()}:${r.name ?? ""}`;
9445
9450
  return V.has(j) ? !1 : (V.add(j), !0);
@@ -9488,9 +9493,10 @@ function mergeImportedSchema(r, M, N, P = /* @__PURE__ */ new Set()) {
9488
9493
  kind: j.kind,
9489
9494
  declaration: j.originalSymbol.declaration,
9490
9495
  usedSymbol: j.originalSymbol,
9491
- useSpecifierDeclaration: void 0,
9496
+ useSpecifierDeclaration: N,
9492
9497
  name: j.name
9493
9498
  }, M.filepath));
9499
+ for (let j of [...R]) j.isKind(SymbolKind.TableGroup) && R.push(...expandTableGroup(r, M, j));
9494
9500
  for (let j of L.reuses.selective) R.push(...mergeImportedSchema(r, M, j, P));
9495
9501
  return R;
9496
9502
  }
@@ -9512,7 +9518,7 @@ function handleMemberWildcardUses(r, M, N, P, F, I = /* @__PURE__ */ new Set())
9512
9518
  let { reuses: { selective: B, wildcard: V } } = R;
9513
9519
  for (let N of B) {
9514
9520
  let P = handleMemberSelectiveUses(r, M, N, F).getFiltered(UNHANDLED);
9515
- P && z.push(P);
9521
+ P && z.push(P), z.push(...mergeImportedSchema(r, M, N));
9516
9522
  }
9517
9523
  for (let { importPath: j } of V) z.push(...handleMemberWildcardUses(r, M, j, P, F, I));
9518
9524
  return z;
@@ -9530,34 +9536,36 @@ function findSchemaSymbolInFilepath(r, M, N) {
9530
9536
  }
9531
9537
  return I;
9532
9538
  }
9533
- function expandTableGroup(r, M) {
9534
- if (!M.isKind(SymbolKind.TableGroup)) return [];
9535
- let N = M.originalSymbol, P = r.symbolMembers(N).getFiltered(UNHANDLED);
9536
- if (!P) return [];
9537
- let F = [];
9538
- for (let j of P) {
9539
+ function expandTableGroup(r, M, N) {
9540
+ if (!N.isKind(SymbolKind.TableGroup) || !(N instanceof UseSymbol)) return [];
9541
+ let P = N.originalSymbol, F = r.symbolMembers(P).getFiltered(UNHANDLED);
9542
+ if (!F) return [];
9543
+ let I = M.qualifiedName, L = [];
9544
+ for (let j of F) {
9539
9545
  if (!j.isKind(SymbolKind.TableGroupField) || !j.declaration) continue;
9540
- let N = j.declaration.callee;
9541
- if (!N) continue;
9542
- let P = destructureComplexVariable(N);
9546
+ let M = j.declaration.callee;
9547
+ if (!M) continue;
9548
+ let P = destructureComplexVariable(M);
9543
9549
  if (!P || P.length === 0) continue;
9544
- let I = j.declaration.filepath, L = lookupTableInFile(r, I, P);
9545
- L && M instanceof UseSymbol && F.push(r.symbolFactory.create(UseSymbol, {
9550
+ let F = P.length <= 1 ? [DEFAULT_SCHEMA_NAME] : P.slice(0, -1);
9551
+ if (F.length !== I.length || !I.every((r, j) => r === F[j])) continue;
9552
+ let R = j.declaration.filepath, z = lookupTableInFile(r, R, P);
9553
+ z && L.push(r.symbolFactory.create(UseSymbol, {
9546
9554
  kind: SymbolKind.Table,
9547
- declaration: L.declaration,
9548
- usedSymbol: L,
9555
+ declaration: z.declaration,
9556
+ usedSymbol: z,
9549
9557
  useSpecifierDeclaration: void 0,
9550
- name: L.name
9551
- }, M.filepath));
9558
+ name: z.name
9559
+ }, N.filepath));
9552
9560
  }
9553
- return F;
9561
+ return L;
9554
9562
  }
9555
9563
  function lookupTableInFile(r, M, N) {
9556
9564
  if (N.length === 1) {
9557
9565
  let P = r.usableMembers(M).getFiltered(UNHANDLED);
9558
9566
  return P ? P.nonSchemaMembers.find((r) => r.isKind(SymbolKind.Table) && r.name === N[0]) : void 0;
9559
9567
  }
9560
- let [P, F] = [N[0], N[N.length - 1]], I = r.usableMembers(M).getFiltered(UNHANDLED);
9568
+ let P = N[0], F = N[N.length - 1], I = r.usableMembers(M).getFiltered(UNHANDLED);
9561
9569
  if (!I) return;
9562
9570
  let L = I.schemaMembers.find((r) => r.name === P);
9563
9571
  if (!L) return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/parse",
4
- "version": "8.0.0-alpha.4",
4
+ "version": "8.0.0-alpha.5",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=18"
47
47
  },
48
- "gitHead": "17d4675433b702912a20dcc65a63c03c73c56db5"
48
+ "gitHead": "2e6795b120c2ca4f16bb542295b2152f091d6ed9"
49
49
  }