@dbml/core 6.5.0 → 6.6.0
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/lib/index.cjs +3 -3
- package/lib/index.mjs +23 -17
- package/package.json +3 -3
- package/types/model_structure/database.d.ts +1 -0
package/lib/index.mjs
CHANGED
|
@@ -9912,7 +9912,7 @@ function createConstraintErrors(_, HY, P) {
|
|
|
9912
9912
|
}
|
|
9913
9913
|
var getConstraintType$1 = (_) => _ > 1 ? "Composite PK" : "PK";
|
|
9914
9914
|
function validatePrimaryKey(_) {
|
|
9915
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
9915
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
9916
9916
|
if (isEmpty_default$1(P)) return [];
|
|
9917
9917
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
9918
9918
|
let UY = _.cachedMergedTables.get(HY), WY = collectPkConstraints(UY), GY = collectAvailableColumns(P), KY = keyBy_default(UY.fields, "name");
|
|
@@ -9955,7 +9955,7 @@ function checkMissingPkColumns(_, HY, P, UY, WY) {
|
|
|
9955
9955
|
}
|
|
9956
9956
|
var getConstraintType = (_) => _ > 1 ? "Composite UNIQUE" : "UNIQUE";
|
|
9957
9957
|
function validateUnique(_) {
|
|
9958
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
9958
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
9959
9959
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
9960
9960
|
let UY = _.cachedMergedTables.get(HY);
|
|
9961
9961
|
if (isEmpty_default$1(P)) return [];
|
|
@@ -9979,7 +9979,7 @@ function validateForeignKeys(_) {
|
|
|
9979
9979
|
function buildTableInfoMap(_) {
|
|
9980
9980
|
let HY = /* @__PURE__ */ new Map();
|
|
9981
9981
|
for (let P of _.tables.values()) {
|
|
9982
|
-
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P) || [];
|
|
9982
|
+
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P)?.rows || [];
|
|
9983
9983
|
_.cachedMergedTables.has(P) || _.cachedMergedTables.set(P, mergeTableAndPartials(P, _));
|
|
9984
9984
|
let GY = _.cachedMergedTables.get(P);
|
|
9985
9985
|
HY.set(UY, {
|
|
@@ -10024,16 +10024,20 @@ var RecordsInterpreter = class {
|
|
|
10024
10024
|
HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, GY)), HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, UY));
|
|
10025
10025
|
continue;
|
|
10026
10026
|
}
|
|
10027
|
-
this.tableToRecordMap.set(_, UY)
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10027
|
+
this.tableToRecordMap.set(_, UY), this.env.records.has(_) || this.env.records.set(_, {
|
|
10028
|
+
element: UY,
|
|
10029
|
+
rows: []
|
|
10030
|
+
});
|
|
10031
|
+
let KY = this.env.records.get(_);
|
|
10032
|
+
for (let _ of UY.body.body) {
|
|
10033
|
+
let UY = _, GY = extractDataFromRow(UY, WY, this.env);
|
|
10034
|
+
HY.push(...GY.getErrors()), P.push(...GY.getWarnings());
|
|
10035
|
+
let qY = GY.getValue();
|
|
10036
|
+
qY.row && KY.rows.push({
|
|
10033
10037
|
values: qY.row,
|
|
10034
10038
|
node: UY,
|
|
10035
10039
|
columnNodes: qY.columnNodes
|
|
10036
|
-
})
|
|
10040
|
+
});
|
|
10037
10041
|
}
|
|
10038
10042
|
}
|
|
10039
10043
|
let UY = this.validateConstraints();
|
|
@@ -10198,14 +10202,15 @@ function processColumnInDb(_) {
|
|
|
10198
10202
|
}
|
|
10199
10203
|
function convertEnvToDb(_) {
|
|
10200
10204
|
let HY = [];
|
|
10201
|
-
for (let [P, UY] of _.records) {
|
|
10202
|
-
if (!
|
|
10203
|
-
let _ = Object.keys(
|
|
10205
|
+
for (let [P, { element: UY, rows: WY }] of _.records) {
|
|
10206
|
+
if (!WY.length) continue;
|
|
10207
|
+
let _ = Object.keys(WY[0].columnNodes);
|
|
10204
10208
|
HY.push({
|
|
10205
10209
|
schemaName: P.schemaName || void 0,
|
|
10206
10210
|
tableName: P.name,
|
|
10207
10211
|
columns: _,
|
|
10208
|
-
|
|
10212
|
+
token: getTokenPosition(UY),
|
|
10213
|
+
values: WY.map((HY) => _.map((_) => {
|
|
10209
10214
|
let P = HY.values[_];
|
|
10210
10215
|
return P ? {
|
|
10211
10216
|
value: P.value,
|
|
@@ -16085,13 +16090,14 @@ var database_default = class extends element_default {
|
|
|
16085
16090
|
});
|
|
16086
16091
|
}
|
|
16087
16092
|
processRecords(_) {
|
|
16088
|
-
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY }) => {
|
|
16093
|
+
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY, token: WY }) => {
|
|
16089
16094
|
this.records.push({
|
|
16090
16095
|
id: this.dbState.generateId("recordId"),
|
|
16091
16096
|
schemaName: _,
|
|
16092
16097
|
tableName: HY,
|
|
16093
16098
|
columns: P,
|
|
16094
|
-
values: UY
|
|
16099
|
+
values: UY,
|
|
16100
|
+
token: WY
|
|
16095
16101
|
});
|
|
16096
16102
|
});
|
|
16097
16103
|
}
|
|
@@ -1821067,5 +1821073,5 @@ function renameTable(_, HY, P) {
|
|
|
1821067
1821073
|
let UY = new Compiler();
|
|
1821068
1821074
|
return UY.setSource(P), UY.renameTable(_, HY);
|
|
1821069
1821075
|
}
|
|
1821070
|
-
const VERSION = "6.
|
|
1821076
|
+
const VERSION = "6.6.0";
|
|
1821071
1821077
|
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, export_default as exporter, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, 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": "6.
|
|
4
|
+
"version": "6.6.0",
|
|
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": "^6.
|
|
49
|
+
"@dbml/parse": "^6.6.0",
|
|
50
50
|
"antlr4": "^4.13.1",
|
|
51
51
|
"lodash": "^4.17.15",
|
|
52
52
|
"lodash-es": "^4.17.15",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"bluebird": "^3.5.5"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "d12a8904713b9d76a3aab7a51ea6e94ae8f00ee1",
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=16"
|
|
63
63
|
}
|