tsondb 0.13.0 → 0.13.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/src/node/index.js +13 -6
- package/package.json +1 -1
package/dist/src/node/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createValidationContext } from "./schema/Node.js";
|
|
|
9
9
|
import { getEntities } from "./schema/Schema.js";
|
|
10
10
|
import { createServer } from "./server/index.js";
|
|
11
11
|
import { asyncForEachInstanceInDatabaseInMemory, createDatabaseInMemory, getInstancesOfEntityFromDatabaseInMemory, } from "./utils/databaseInMemory.js";
|
|
12
|
-
import {
|
|
12
|
+
import { getErrorMessageForDisplay, wrapErrorsIfAny } from "./utils/error.js";
|
|
13
13
|
import { getFileNameForId, writeInstance } from "./utils/files.js";
|
|
14
14
|
import { checkUniqueConstraintsForAllEntities } from "./utils/unique.js";
|
|
15
15
|
const debug = Debug("tsondb:jsapi");
|
|
@@ -60,11 +60,13 @@ const _validate = (dataRootPath, entities, databaseInMemory, options = {}) => {
|
|
|
60
60
|
debug("Skipping unique constraint checks due to previous structural integrity errors");
|
|
61
61
|
}
|
|
62
62
|
if (errors.length === 0) {
|
|
63
|
-
|
|
63
|
+
console.log("All entities are valid");
|
|
64
|
+
return true;
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
|
-
console.error(
|
|
67
|
-
|
|
67
|
+
console.error(`${errors.length.toString()} validation error${errors.length === 1 ? "" : "s"} found\n\n${errors.map(err => getErrorMessageForDisplay(err)).join("\n\n")}`);
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return false;
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
export const validate = async (schema, dataRootPath, options) => {
|
|
@@ -96,8 +98,13 @@ export const generateValidateAndServe = async (schema, outputs, dataRootPath, de
|
|
|
96
98
|
const entities = getEntities(schema);
|
|
97
99
|
await prepareFolders(dataRootPath, entities);
|
|
98
100
|
const databaseInMemory = await createDatabaseInMemory(dataRootPath, entities);
|
|
99
|
-
_validate(dataRootPath, entities, databaseInMemory, validationOptions);
|
|
100
|
-
|
|
101
|
+
const isValid = _validate(dataRootPath, entities, databaseInMemory, validationOptions);
|
|
102
|
+
if (isValid) {
|
|
103
|
+
await createServer(schema, dataRootPath, databaseInMemory, defaultLocales, homeLayoutSections, serverOptions, validationOptions, customStylesheetPath);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.error("Not starting server due to invalid database");
|
|
107
|
+
}
|
|
101
108
|
};
|
|
102
109
|
export const format = async (schema, dataRootPath) => {
|
|
103
110
|
const entities = getEntities(schema);
|