@dbml/parse 9.0.0-alpha.14 → 9.0.0-alpha.16

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.
@@ -8110,7 +8110,7 @@ function Mh(e, t, n, r, i, a) {
8110
8110
  return o === "1" && s === "1" || o === "*" && s === "*" ? [...Ah(e, t, n, r, i, a), ...Ah(e, n, t, i, r, a)] : o === "*" && s === "1" ? Ah(e, t, n, r, i, a) : o === "1" && s === "*" ? Ah(e, n, t, i, r, a) : [];
8111
8111
  }
8112
8112
  //#endregion
8113
- //#region src/core/global_modules/program/utils/validateRecords.ts
8113
+ //#region src/core/global_modules/program/utils/records.ts
8114
8114
  function Nh(e, n, r, i) {
8115
8115
  let a = [], o = /* @__PURE__ */ new Map(), s = e.symbolMembers(n).getFiltered(t) ?? [];
8116
8116
  for (let n of s) {
@@ -8179,19 +8179,27 @@ function Ph(e, t, n, r) {
8179
8179
  return a;
8180
8180
  }
8181
8181
  //#endregion
8182
- //#region src/core/global_modules/program/utils/validateDep.ts
8182
+ //#region src/core/global_modules/program/utils/dep.ts
8183
8183
  function Fh(e) {
8184
8184
  return e instanceof cm && e.declaration instanceof z && e.declaration.body instanceof W;
8185
8185
  }
8186
8186
  function Ih(e, t, n) {
8187
8187
  let r = e.edges ?? [];
8188
- if (r.length === 0 || !Fh(t)) return [];
8189
- let i = uh(r[0].downstream.schemaName, r[0].downstream.tableName);
8190
- for (let e = 1; e < r.length; e++) {
8191
- let n = uh(r[e].downstream.schemaName, r[e].downstream.tableName);
8192
- if (n !== i) return [new T(w.DEP_MIXED_DOWNSTREAM_TABLES, `All edges in a Dep block must target the same downstream table, but found '${i}' and '${n}'`, t.declaration)];
8188
+ if (r.length === 0) return [];
8189
+ if (Fh(t)) {
8190
+ let e = uh(r[0].downstream.schemaName, r[0].downstream.tableName);
8191
+ for (let n = 1; n < r.length; n++) {
8192
+ let i = uh(r[n].downstream.schemaName, r[n].downstream.tableName);
8193
+ if (i !== e) return [new T(w.DEP_MIXED_DOWNSTREAM_TABLES, `All edges in a Dep block must target the same downstream table, but found '${e}' and '${i}'`, t.declaration)];
8194
+ }
8195
+ if (n.has(e)) return [new T(w.DEP_DUPLICATE_DOWNSTREAM_TABLE, `Downstream table '${e}' is already targeted by another Dep block`, t.declaration)];
8196
+ n.set(e, !0);
8197
+ } else for (let e of r) {
8198
+ let r = uh(e.downstream.schemaName, e.downstream.tableName);
8199
+ if (n.get(r) === !0) return [new T(w.DEP_DUPLICATE_DOWNSTREAM_TABLE, `Downstream table '${r}' is already targeted by a Dep block`, t.declaration)];
8200
+ n.has(r) || n.set(r, !1);
8193
8201
  }
8194
- return n.has(i) ? [new T(w.DEP_DUPLICATE_DOWNSTREAM_TABLE, `Downstream table '${i}' is already targeted by another Dep block`, t.declaration)] : (n.add(i), []);
8202
+ return [];
8195
8203
  }
8196
8204
  //#endregion
8197
8205
  //#region src/core/global_modules/program/interpret.ts
@@ -8271,7 +8279,7 @@ var Lh = class {
8271
8279
  ch(this.db, e, o);
8272
8280
  }
8273
8281
  interpretAllMetadata() {
8274
- let e = this.compiler.symbolMetadata(this.programSymbol) ?? [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
8282
+ let e = this.compiler.symbolMetadata(this.programSymbol) ?? [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
8275
8283
  for (let t of e) {
8276
8284
  if (!(t instanceof fm)) continue;
8277
8285
  let e = t.table(this.compiler);
@@ -16029,7 +16037,7 @@ function Gx(e, t) {
16029
16037
  return r;
16030
16038
  }
16031
16039
  function Kx(e, t) {
16032
- return hx(e.upstream, t.upstream) && hx(e.downstream, t.downstream);
16040
+ return gx(e.upstream, t.upstream) && gx(e.downstream, t.downstream);
16033
16041
  }
16034
16042
  function qx(e, t) {
16035
16043
  return e.edges.some((e) => Kx(e, t));
@@ -12,22 +12,6 @@ export declare class DepInterpreter {
12
12
  interpret(): Report<Dep>;
13
13
  private interpretName;
14
14
  private interpretEdges;
15
- /**
16
- * Read settings into `dep.note` and `dep.metadata`.
17
- *
18
- * Settings come from THREE sources, in this order:
19
- * 1. The top-level attribute list on the Dep header
20
- * (e.g. `Dep my_block [color: 'blue'] { ... }`).
21
- * 2. Per-field setting lists inside the body
22
- * (e.g. `Dep { a -> b [note: 'x'] }`).
23
- * 3. Sub-element declarations inside the body
24
- * (e.g. `Dep { a -> b; note: 'x'; materialized: 'view' }`).
25
- *
26
- * All three sources write into the same `metadata` object (with `note`
27
- * routed to the typed slot instead). Precedence is last-write-wins by
28
- * virtue of plain object assignment — settings later in the source
29
- * file overwrite earlier ones with the same key.
30
- */
31
15
  private interpretSettings;
32
16
  private consumeSettings;
33
17
  private extractAttrValue;
@@ -1,4 +1,4 @@
1
1
  import { CompileError } from '../../../types/errors';
2
2
  import { Dep } from '../../../types/schemaJson';
3
3
  import { NodeMetadata } from '../../../types/symbol/metadata';
4
- export declare function validateDepBlocks(dep: Dep, meta: NodeMetadata, seenComplexDownstream: Set<string>): CompileError[];
4
+ export declare function validateDepBlocks(dep: Dep, meta: NodeMetadata, seenDownstream: Map<string, boolean>): CompileError[];
@@ -1,3 +1,3 @@
1
1
  export { pushExternal } from './external';
2
- export { validateRecords } from './validateRecords';
3
- export { validateDepBlocks } from './validateDep';
2
+ export { validateRecords } from './records';
3
+ export { validateDepBlocks } from './dep';
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": "9.0.0-alpha.14",
4
+ "version": "9.0.0-alpha.16",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=18"
52
52
  },
53
- "gitHead": "d78ea32614a1f5a459e7dcb86a51fe25eff6ff3f"
53
+ "gitHead": "d1ac5ed4e6693dac2141987c09b5a628bc99dd3d"
54
54
  }