@tsed/ajv 8.34.0 → 8.35.0

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.
@@ -1,6 +1,6 @@
1
- import { inject } from "@tsed/di";
2
- import { JsonSchema } from "@tsed/schema";
3
1
  import { AjvService } from "../services/AjvService.js";
2
+ import { JsonSchema } from "@tsed/schema";
3
+ import { inject } from "@tsed/di";
4
4
  /**
5
5
  * Validate a value against a JSON schema or a type using the configured `AjvService`.
6
6
  *
@@ -1,8 +1,8 @@
1
- import { cleanObject } from "@tsed/core";
2
- import { constant, inject, injectable, injector, ProviderScope } from "@tsed/di";
3
1
  import { Ajv } from "ajv";
2
+ import { ProviderScope, constant, inject, injectable, injector } from "@tsed/di";
4
3
  import AjvErrors from "ajv-errors";
5
4
  import AjvFormats from "ajv-formats";
5
+ import { cleanObject } from "@tsed/core";
6
6
  function getHandler(key, service) {
7
7
  if (service[key]) {
8
8
  return service[key].bind(service);
@@ -1,8 +1,8 @@
1
1
  import "./Ajv.js";
2
+ import { Ajv } from "ajv";
3
+ import { JsonSchema, compile } from "@tsed/schema";
2
4
  import { deepClone } from "@tsed/core";
3
5
  import { constant, inject, injectable } from "@tsed/di";
4
- import { compile, JsonSchema } from "@tsed/schema";
5
- import { Ajv } from "ajv";
6
6
  import { defaultErrorFormatter } from "../utils/defaultErrorFormatter.js";
7
7
  import { mapErrors } from "../utils/mapErrors.js";
8
8
  export class AjvService {
@@ -1,5 +1,5 @@
1
1
  import { getValue, prototypeOf, setValue } from "@tsed/core";
2
- import { JsonEntityStore } from "@tsed/schema";
2
+ import { s } from "@tsed/schema";
3
3
  /**
4
4
  * Rewrite class-related AJV messages using Ts.ED metadata.
5
5
  *
@@ -13,7 +13,7 @@ import { JsonEntityStore } from "@tsed/schema";
13
13
  export function mapClassError(error, targetType) {
14
14
  const propertyKey = getValue(error, "params.missingProperty");
15
15
  if (propertyKey) {
16
- const store = JsonEntityStore.from(prototypeOf(targetType), propertyKey);
16
+ const store = s.store.get(prototypeOf(targetType), propertyKey);
17
17
  if (store) {
18
18
  setValue(error, "params.missingProperty", store.name || propertyKey);
19
19
  return error.message?.replace(`'${propertyKey}'`, `'${store.name || propertyKey}'`);
@@ -1,5 +1,5 @@
1
- import { type TokenProvider } from "@tsed/di";
2
1
  import { AsyncFormatDefinition, FormatDefinition } from "ajv";
2
+ import { type TokenProvider } from "@tsed/di";
3
3
  export type FormatsOptions = Omit<FormatDefinition<any>, "validate" | "compare"> | Omit<AsyncFormatDefinition<any>, "validate" | "compare">;
4
4
  /**
5
5
  * Create a new custom formats validator
@@ -1,6 +1,6 @@
1
+ import type { AnySchemaObject, KeywordDefinition } from "ajv";
1
2
  import { type TokenProvider } from "@tsed/di";
2
3
  import { JsonSchema } from "@tsed/schema";
3
- import type { AnySchemaObject, KeywordDefinition } from "ajv";
4
4
  export type KeywordOptions = Partial<Omit<KeywordDefinition, "metaSchema">> & {
5
5
  metaSchema?: AnySchemaObject | JsonSchema;
6
6
  };
@@ -1,5 +1,5 @@
1
- import { JsonSchema } from "@tsed/schema";
2
1
  import { type AjvValidateOptions } from "../services/AjvService.js";
2
+ import { JsonSchema } from "@tsed/schema";
3
3
  /**
4
4
  * Validate a value against a JSON schema or a type using the configured `AjvService`.
5
5
  *
@@ -1,8 +1,8 @@
1
1
  import "./Ajv.js";
2
- import { Type } from "@tsed/core";
3
- import { JsonSchema, JsonSchemaObject } from "@tsed/schema";
4
2
  import { Ajv, ValidateFunction } from "ajv";
5
3
  import { ErrorFormatter } from "../interfaces/AjvSettings.js";
4
+ import { JsonSchema, JsonSchemaObject } from "@tsed/schema";
5
+ import { Type } from "@tsed/core";
6
6
  export interface AjvValidateOptions extends Record<string, any> {
7
7
  schema?: JsonSchema | Partial<JsonSchemaObject>;
8
8
  type?: Type<any> | any;
@@ -1,7 +1,7 @@
1
+ import { ErrorFormatter } from "../interfaces/AjvSettings.js";
1
2
  import { Type } from "@tsed/core";
2
- import { ErrorObject } from "ajv";
3
3
  import { AjvValidationError } from "../errors/AjvValidationError.js";
4
- import { ErrorFormatter } from "../interfaces/AjvSettings.js";
4
+ import { ErrorObject } from "ajv";
5
5
  export interface MapErrorsOptions {
6
6
  collectionType?: Type<any> | any;
7
7
  errorFormatter: ErrorFormatter;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tsed/ajv",
3
+ "version": "8.35.0",
3
4
  "description": "AJV package for Ts.ED framework",
4
- "type": "module",
5
- "version": "8.34.0",
6
5
  "source": "./src/index.ts",
6
+ "type": "module",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
@@ -29,14 +29,13 @@
29
29
  "tslib": ">=2.7.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@tsed/barrels": "8.34.0",
33
- "@tsed/core": "8.34.0",
34
- "@tsed/di": "8.34.0",
35
- "@tsed/exceptions": "8.34.0",
36
- "@tsed/schema": "8.34.0",
37
- "@tsed/typescript": "8.34.0",
32
+ "@tsed/barrels": "8.35.0",
33
+ "@tsed/core": "8.35.0",
34
+ "@tsed/di": "8.35.0",
35
+ "@tsed/exceptions": "8.35.0",
36
+ "@tsed/schema": "8.35.0",
37
+ "@tsed/typescript": "8.35.0",
38
38
  "ajv": "^8.17.1",
39
- "eslint": "9.12.0",
40
39
  "typescript": "6.0.2",
41
40
  "vite": "7.3.2",
42
41
  "vitest": "4.1.4"