@darksheep/json-schema 0.1.1 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.2](https://github.com/DarkSheepSoftware/node-packages/compare/json-schema-v0.1.1...json-schema-v0.1.2) (2026-04-17)
4
+
5
+
6
+ ### 📦 Dependencies
7
+
8
+ * **pkg:** update dependency ajv to v8.18.0 [security] ([#816](https://github.com/DarkSheepSoftware/node-packages/issues/816)) ([bbced20](https://github.com/DarkSheepSoftware/node-packages/commit/bbced20577c99909507d0195dcd464703d92b801))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @darksheep/errors bumped to 1.2.1
16
+
3
17
  ## [0.1.1](https://github.com/DarkSheepSoftware/node-packages/compare/json-schema-v0.1.0...json-schema-v0.1.1) (2025-10-09)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/json-schema",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "JSON schema validation (with types)",
5
5
  "license": "UNLICENCED",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@darksheep/errors": "",
25
- "ajv": "8.17.1",
25
+ "ajv": "8.18.0",
26
26
  "ajv-formats": "3.0.1",
27
27
  "json-schema-to-ts": "3.1.1"
28
28
  },
package/src/errors.js CHANGED
@@ -1,11 +1,18 @@
1
1
  /**
2
- * @import { DefinedError } from 'ajv'
3
- * @import { ErrorOptions } from '@darksheep/errors'
2
+ * @import { DefinedError } from 'ajv';
3
+ * @import { ErrorOptions } from '@darksheep/errors';
4
4
  */
5
5
 
6
- import { ValidationError } from 'ajv';
6
+ import { ValidationError as AjvError } from 'ajv';
7
7
  import { BadRequest, InternalServerError } from '@darksheep/errors';
8
8
 
9
+ /**
10
+ * @typedef {(
11
+ * & Omit<AjvError, 'errors'>
12
+ * & { errors: DefinedError[] }
13
+ * )} ValidationError
14
+ */
15
+
9
16
  /**
10
17
  * @typedef {(
11
18
  * & ErrorOptions
@@ -108,11 +115,11 @@ export function isDefinedError(input) {
108
115
 
109
116
  /**
110
117
  * @param {unknown} input - The value to check.
111
- * @returns {input is import('./types.js').ValidationError}
118
+ * @returns {input is ValidationError}
112
119
  */
113
120
  export function isSchemaError(input) {
114
121
  return (
115
- input instanceof ValidationError &&
122
+ input instanceof AjvError &&
116
123
  input.errors.every(isDefinedError)
117
124
  );
118
125
  }
package/src/index.js CHANGED
@@ -1,7 +1,14 @@
1
+ /**
2
+ * @import { JSONSchema } from './types.js';
3
+ */
1
4
  export * from './types.js';
2
5
 
3
6
  /**
4
- * @template {import('./types.js').JSONSchema} const Schema - The raw schema type.
7
+ * @typedef {import('./errors.js').ValidationError} ValidationError
8
+ */
9
+
10
+ /**
11
+ * @template {JSONSchema} const Schema - The raw schema type.
5
12
  * @param {Schema} schema - The raw JSON schema.
6
13
  * @returns {Schema}
7
14
  */
package/src/types.js CHANGED
@@ -1,14 +1,8 @@
1
1
  /**
2
2
  * @import { DefinedError } from 'ajv'
3
3
  */
4
- export {};
5
4
 
6
- /**
7
- * @typedef {(
8
- * & Omit<import('ajv').ValidationError, 'errors'>
9
- * & { errors: DefinedError[] }
10
- * )} ValidationError
11
- */
5
+ export {};
12
6
 
13
7
  /**
14
8
  * @typedef {new (options: { cause?: Error, errors: DefinedError[] }) => Error} TargetError
package/types/errors.d.ts CHANGED
@@ -5,9 +5,15 @@
5
5
  export function isDefinedError(input: unknown): input is DefinedError;
6
6
  /**
7
7
  * @param {unknown} input - The value to check.
8
- * @returns {input is import('./types.js').ValidationError}
8
+ * @returns {input is ValidationError}
9
+ */
10
+ export function isSchemaError(input: unknown): input is ValidationError;
11
+ /**
12
+ * @typedef {(
13
+ * & Omit<AjvError, 'errors'>
14
+ * & { errors: DefinedError[] }
15
+ * )} ValidationError
9
16
  */
10
- export function isSchemaError(input: unknown): input is import("./types.js").ValidationError;
11
17
  /**
12
18
  * @typedef {(
13
19
  * & ErrorOptions
@@ -36,10 +42,14 @@ export class ResponseSchemaError extends InternalServerError {
36
42
  /** @type {DefinedError[]} */
37
43
  errors: DefinedError[];
38
44
  }
45
+ export type ValidationError = (Omit<AjvError, "errors"> & {
46
+ errors: DefinedError[];
47
+ });
39
48
  export type SchemaErrorOptions = (ErrorOptions & {
40
49
  errors: DefinedError[];
41
50
  });
42
51
  import type { DefinedError } from 'ajv';
43
52
  import { BadRequest } from '@darksheep/errors';
44
53
  import { InternalServerError } from '@darksheep/errors';
54
+ import { ValidationError as AjvError } from 'ajv';
45
55
  import type { ErrorOptions } from '@darksheep/errors';
package/types/index.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  /**
2
- * @template {import('./types.js').JSONSchema} const Schema - The raw schema type.
2
+ * @typedef {import('./errors.js').ValidationError} ValidationError
3
+ */
4
+ /**
5
+ * @template {JSONSchema} const Schema - The raw schema type.
3
6
  * @param {Schema} schema - The raw JSON schema.
4
7
  * @returns {Schema}
5
8
  */
6
- export function defineSchema<const Schema extends import("./types.js").JSONSchema>(schema: Schema): Schema;
9
+ export function defineSchema<const Schema extends JSONSchema>(schema: Schema): Schema;
7
10
  export * from "./types.js";
11
+ export type ValidationError = import("./errors.js").ValidationError;
12
+ import type { JSONSchema } from './types.js';
8
13
  export { isDefinedError, isSchemaError, RequestSchemaError, ResponseSchemaError } from "./errors.js";
9
14
  export { createValidator, validate } from "./async.js";
10
15
  export { createAssertSchema, assertSchema } from "./sync.js";
package/types/types.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export type ValidationError = (Omit<import("ajv").ValidationError, "errors"> & {
2
- errors: DefinedError[];
3
- });
4
1
  export type TargetError = new (options: {
5
2
  cause?: Error;
6
3
  errors: DefinedError[];