@dbml/core 3.1.5 → 3.1.6
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/export/DbmlExporter.js +15 -4
- package/package.json +3 -3
|
@@ -36,7 +36,18 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
36
36
|
}, {
|
|
37
37
|
key: "escapeNote",
|
|
38
38
|
value: function escapeNote(str) {
|
|
39
|
-
|
|
39
|
+
if (str === null) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
var newStr = str.replaceAll('\\', '\\\\');
|
|
43
|
+
if (!newStr.match(/[\n\r']/)) {
|
|
44
|
+
// Only safe chars, no simple quotes nor CR/LF
|
|
45
|
+
return "'".concat(newStr, "'");
|
|
46
|
+
}
|
|
47
|
+
// see https://dbml.dbdiagram.io/docs/#multi-line-string
|
|
48
|
+
newStr = newStr.replaceAll("'''", "\\'''");
|
|
49
|
+
newStr = newStr.replaceAll('\r\n', '\n'); // turn all CRLF to LF
|
|
50
|
+
return "'''".concat(newStr, "'''");
|
|
40
51
|
}
|
|
41
52
|
}, {
|
|
42
53
|
key: "exportEnums",
|
|
@@ -45,7 +56,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
45
56
|
var _enum = model.enums[enumId];
|
|
46
57
|
var schema = model.schemas[_enum.schemaId];
|
|
47
58
|
return "Enum ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(_enum.name, "\" {\n").concat(_enum.valueIds.map(function (valueId) {
|
|
48
|
-
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note:
|
|
59
|
+
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note: ".concat(DbmlExporter.escapeNote(model.enumValues[valueId].note), "]") : '');
|
|
49
60
|
}).join('\n'), "\n}\n");
|
|
50
61
|
});
|
|
51
62
|
return enumStrs.length ? enumStrs.join('\n') : '';
|
|
@@ -93,7 +104,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
93
104
|
constraints.push(value);
|
|
94
105
|
}
|
|
95
106
|
if (field.note) {
|
|
96
|
-
constraints.push("note:
|
|
107
|
+
constraints.push("note: ".concat(DbmlExporter.escapeNote(field.note)));
|
|
97
108
|
}
|
|
98
109
|
if (constraints.length > 0) {
|
|
99
110
|
line += " [".concat(constraints.join(', '), "]");
|
|
@@ -185,7 +196,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
185
196
|
return " ".concat(indexLine);
|
|
186
197
|
}).join('\n'), "\n}");
|
|
187
198
|
}
|
|
188
|
-
var tableNote = table.note ? " Note:
|
|
199
|
+
var tableNote = table.note ? " Note: ".concat(DbmlExporter.escapeNote(table.note), "\n") : '';
|
|
189
200
|
var tableStr = "Table ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\"").concat(tableSettingStr, " {\n").concat(tableContent.fieldContents.map(function (line) {
|
|
190
201
|
return " ".concat(line);
|
|
191
202
|
}).join('\n'), "\n").concat(indexStr ? "".concat(indexStr, "\n") : '').concat(tableNote, "}\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Holistics <dev@holistics.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepublish": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dbml/parse": "^3.1.
|
|
35
|
+
"@dbml/parse": "^3.1.6",
|
|
36
36
|
"antlr4": "^4.13.1",
|
|
37
37
|
"lodash": "^4.17.15",
|
|
38
38
|
"parsimmon": "^1.13.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"\\.(?!json$)[^.]*$": "@glen/jest-raw-loader"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "f82965d9636209e22f31794111f37e05c5da79ce"
|
|
63
63
|
}
|