@dbml/parse 9.0.0-alpha.14 → 9.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +1 -1
- package/dist/dbml-parse.mjs +17 -9
- package/dist/src/core/global_modules/dep/interpret.d.ts +0 -16
- package/dist/src/core/global_modules/program/utils/{validateDep.d.ts → dep.d.ts} +1 -1
- package/dist/src/core/global_modules/program/utils/index.d.ts +2 -2
- package/package.json +2 -2
- /package/dist/src/core/global_modules/program/utils/{validateRecords.d.ts → records.d.ts} +0 -0
package/dist/dbml-parse.mjs
CHANGED
|
@@ -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/
|
|
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/
|
|
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
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
let n =
|
|
8192
|
-
|
|
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
|
|
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
|
|
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);
|
|
@@ -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,
|
|
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 './
|
|
3
|
-
export { validateDepBlocks } from './
|
|
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.
|
|
4
|
+
"version": "9.0.0-alpha.15",
|
|
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": "
|
|
53
|
+
"gitHead": "6b55b7c469c1f577c3e27fa699d107ecbd4c47d2"
|
|
54
54
|
}
|
|
File without changes
|