@bedrockio/model 0.10.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.10.1
2
+
3
+ - Fix to not expose details on unique constraint errors.
4
+
1
5
  ## 0.10.0
2
6
 
3
7
  - Unique constraints now run sequentially and will not run on nested validations
@@ -25,5 +25,11 @@ class UniqueConstraintError extends Error {
25
25
  super(message);
26
26
  this.details = details;
27
27
  }
28
+ toJSON() {
29
+ return {
30
+ type: 'unique',
31
+ message: this.message
32
+ };
33
+ }
28
34
  }
29
35
  exports.UniqueConstraintError = UniqueConstraintError;
@@ -34,8 +34,9 @@ async function assertUnique(options) {
34
34
  if (exists) {
35
35
  const message = getUniqueErrorMessage(model, field);
36
36
  throw new _errors.UniqueConstraintError(message, {
37
- ...options,
38
- field
37
+ model,
38
+ field,
39
+ value
39
40
  });
40
41
  }
41
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/errors.js CHANGED
@@ -19,4 +19,11 @@ export class UniqueConstraintError extends Error {
19
19
  super(message);
20
20
  this.details = details;
21
21
  }
22
+
23
+ toJSON() {
24
+ return {
25
+ type: 'unique',
26
+ message: this.message,
27
+ };
28
+ }
22
29
  }
@@ -27,8 +27,9 @@ export async function assertUnique(options) {
27
27
  if (exists) {
28
28
  const message = getUniqueErrorMessage(model, field);
29
29
  throw new UniqueConstraintError(message, {
30
- ...options,
30
+ model,
31
31
  field,
32
+ value,
32
33
  });
33
34
  }
34
35
  }
package/types/errors.d.ts CHANGED
@@ -11,5 +11,9 @@ export class ReferenceError extends Error {
11
11
  export class UniqueConstraintError extends Error {
12
12
  constructor(message: any, details: any);
13
13
  details: any;
14
+ toJSON(): {
15
+ type: string;
16
+ message: string;
17
+ };
14
18
  }
15
19
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAAA;CAA8C;AAE9C;IACE,uBAGC;IADC,UAAgB;CAEnB;AAED;IACE,wCAGC;IADC,aAAsB;CAEzB;AAED;IACE,wCAGC;IADC,aAAsB;CAEzB"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAAA;CAA8C;AAE9C;IACE,uBAGC;IADC,UAAgB;CAEnB;AAED;IACE,wCAGC;IADC,aAAsB;CAEzB;AAED;IACE,wCAGC;IADC,aAAsB;IAGxB;;;MAKC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"AAKA,mDAIC;AAED,0DAsBC"}
1
+ {"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"AAKA,mDAIC;AAED,0DAuBC"}