tsondb 0.13.1 → 0.13.2

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.
@@ -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 { getErrorMessageForDisplay, wrapErrorsIfAny } from "./utils/error.js";
12
+ import { countError, countErrors, 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");
@@ -40,7 +40,8 @@ const _validate = (dataRootPath, entities, databaseInMemory, options = {}) => {
40
40
  .flatMap(entity => parallelizeErrors(getInstancesOfEntityFromDatabaseInMemory(databaseInMemory, entity.name).map(instance => wrapErrorsIfAny(`in file ${styleText("white", `"${dataRootPath}${sep}${styleText("bold", join(entity.name, getFileNameForId(instance.id)))}"`)}`, validateEntityDecl(validationContext, [], entity, instance.content)))))
41
41
  .toSorted((a, b) => a.message.localeCompare(b.message));
42
42
  if (errors.length > 0) {
43
- debug(`${errors.length.toString()} structural integrity violation${errors.length === 1 ? "" : "s"} found`);
43
+ const errorCount = countErrors(errors);
44
+ debug(`${errorCount.toString()} structural integrity violation${errorCount === 1 ? "" : "s"} found`);
44
45
  }
45
46
  else {
46
47
  debug("No structural integrity violations found");
@@ -49,7 +50,8 @@ const _validate = (dataRootPath, entities, databaseInMemory, options = {}) => {
49
50
  debug("Checking unique constraints ...");
50
51
  const constraintResult = checkUniqueConstraintsForAllEntities(databaseInMemory, entities);
51
52
  if (isError(constraintResult)) {
52
- debug(`${constraintResult.error.errors.length.toString()} unique constraint violation${constraintResult.error.errors.length === 1 ? "" : "s"} found`);
53
+ const errorCount = countError(constraintResult.error);
54
+ debug(`${errorCount.toString()} unique constraint violation${errorCount === 1 ? "" : "s"} found`);
53
55
  errors.push(constraintResult.error);
54
56
  }
55
57
  else {
@@ -64,7 +66,8 @@ const _validate = (dataRootPath, entities, databaseInMemory, options = {}) => {
64
66
  return true;
65
67
  }
66
68
  else {
67
- console.error(`${errors.length.toString()} validation error${errors.length === 1 ? "" : "s"} found\n\n${errors.map(err => getErrorMessageForDisplay(err)).join("\n\n")}`);
69
+ const errorCount = countErrors(errors);
70
+ console.error(`${errorCount.toString()} validation error${errorCount === 1 ? "" : "s"} found\n\n${errors.map(err => getErrorMessageForDisplay(err)).join("\n\n")}`);
68
71
  process.exitCode = 1;
69
72
  return false;
70
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsondb",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Lukas Obermann",