@dbml/parse 9.0.0-alpha.0 → 9.0.0-alpha.1
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 +35 -18
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -8116,25 +8116,25 @@ var jh = class {
|
|
|
8116
8116
|
pl(this.db, e, o);
|
|
8117
8117
|
}
|
|
8118
8118
|
interpretAllMetadata() {
|
|
8119
|
-
let e = this.compiler.symbolMetadata(this.programSymbol) ?? [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
8119
|
+
let e = this.compiler.symbolMetadata(this.programSymbol) ?? [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
8120
8120
|
for (let t of e) {
|
|
8121
8121
|
if (!(t instanceof _c)) continue;
|
|
8122
8122
|
let e = t.table(this.compiler);
|
|
8123
8123
|
if (!e) continue;
|
|
8124
|
-
let n = e.originalSymbol.intern(),
|
|
8125
|
-
|
|
8124
|
+
let n = e.originalSymbol.intern(), r = i.get(n);
|
|
8125
|
+
r ? r.count++ : i.set(n, {
|
|
8126
8126
|
count: 1,
|
|
8127
8127
|
tableName: e.name ?? ""
|
|
8128
8128
|
});
|
|
8129
8129
|
}
|
|
8130
|
-
for (let
|
|
8131
|
-
let e = this.compiler.interpretMetadata(
|
|
8130
|
+
for (let a of e) {
|
|
8131
|
+
let e = this.compiler.interpretMetadata(a, this.filepath);
|
|
8132
8132
|
if (e.hasValue(t)) continue;
|
|
8133
8133
|
this.errors.push(...e.getErrors()), this.warnings.push(...e.getWarnings());
|
|
8134
|
-
let
|
|
8135
|
-
if (
|
|
8134
|
+
let o = e.getValue();
|
|
8135
|
+
if (o !== void 0) switch (a.kind) {
|
|
8136
8136
|
case uc.Ref: {
|
|
8137
|
-
let e =
|
|
8137
|
+
let e = o, [t, r] = e.endpoints ?? [];
|
|
8138
8138
|
if (t && r) {
|
|
8139
8139
|
let e = [
|
|
8140
8140
|
t.schemaName,
|
|
@@ -8143,7 +8143,7 @@ var jh = class {
|
|
|
8143
8143
|
r.schemaName,
|
|
8144
8144
|
r.tableName,
|
|
8145
8145
|
r.fieldNames.join(",")
|
|
8146
|
-
].join("|"),
|
|
8146
|
+
].join("|"), i = [
|
|
8147
8147
|
r.schemaName,
|
|
8148
8148
|
r.tableName,
|
|
8149
8149
|
r.fieldNames.join(","),
|
|
@@ -8151,8 +8151,8 @@ var jh = class {
|
|
|
8151
8151
|
t.tableName,
|
|
8152
8152
|
t.fieldNames.join(",")
|
|
8153
8153
|
].join("|");
|
|
8154
|
-
if (n.has(e) || n.has(
|
|
8155
|
-
this.errors.push(new x(b.SAME_ENDPOINT, "Ref with same endpoints already exists",
|
|
8154
|
+
if (n.has(e) || n.has(i)) {
|
|
8155
|
+
this.errors.push(new x(b.SAME_ENDPOINT, "Ref with same endpoints already exists", a.declaration));
|
|
8156
8156
|
break;
|
|
8157
8157
|
}
|
|
8158
8158
|
n.add(e);
|
|
@@ -8160,21 +8160,38 @@ var jh = class {
|
|
|
8160
8160
|
this.db.refs.push(e);
|
|
8161
8161
|
break;
|
|
8162
8162
|
}
|
|
8163
|
-
case uc.Dep:
|
|
8164
|
-
|
|
8163
|
+
case uc.Dep: {
|
|
8164
|
+
let e = o, t = a instanceof pc ? a.edgeExpressions() : [], n = -1;
|
|
8165
|
+
if ((e.edges ?? []).some((e, t) => {
|
|
8166
|
+
let { upstream: i, downstream: a } = e, o = [
|
|
8167
|
+
i.schemaName,
|
|
8168
|
+
i.tableName,
|
|
8169
|
+
i.fieldNames.join(","),
|
|
8170
|
+
a.schemaName,
|
|
8171
|
+
a.tableName,
|
|
8172
|
+
a.fieldNames.join(",")
|
|
8173
|
+
].join("|");
|
|
8174
|
+
return r.has(o) ? (n = t, !0) : (r.add(o), !1);
|
|
8175
|
+
}), n >= 0) {
|
|
8176
|
+
let e = t[n] ?? a.declaration;
|
|
8177
|
+
this.errors.push(new x(b.SAME_ENDPOINT, "Dep with same endpoints already exists", e));
|
|
8178
|
+
break;
|
|
8179
|
+
}
|
|
8180
|
+
this.db.deps.push(e);
|
|
8165
8181
|
break;
|
|
8182
|
+
}
|
|
8166
8183
|
case uc.Records:
|
|
8167
|
-
if (
|
|
8168
|
-
let e =
|
|
8184
|
+
if (a instanceof _c) {
|
|
8185
|
+
let e = a.table(this.compiler)?.originalSymbol.intern() ?? "", t = e ? i.get(e) : void 0;
|
|
8169
8186
|
if (t && t.count > 1) {
|
|
8170
|
-
this.errors.push(new x(b.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${t.tableName}' - A Table can only have one Records block`,
|
|
8187
|
+
this.errors.push(new x(b.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${t.tableName}' - A Table can only have one Records block`, a.declaration));
|
|
8171
8188
|
break;
|
|
8172
8189
|
}
|
|
8173
8190
|
}
|
|
8174
|
-
this.db.records.push(
|
|
8191
|
+
this.db.records.push(o);
|
|
8175
8192
|
break;
|
|
8176
8193
|
case uc.Project:
|
|
8177
|
-
this.db.project =
|
|
8194
|
+
this.db.project = o;
|
|
8178
8195
|
break;
|
|
8179
8196
|
default: break;
|
|
8180
8197
|
}
|
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.1",
|
|
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": "a5d691bdc91c0f35dd988e5a2537650466146c5e"
|
|
54
54
|
}
|