@eggjs/ajv-decorator 4.0.0-beta.4 → 4.0.0-beta.5

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/README.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # `@eggjs/ajv-decorator`
2
2
 
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![Known Vulnerabilities][snyk-image]][snyk-url]
5
+ [![npm download][download-image]][download-url]
6
+ [![Node.js Version](https://img.shields.io/node/v/@eggjs/ajv-decorator.svg?style=flat)](https://nodejs.org/en/download/)
7
+
8
+ [npm-image]: https://img.shields.io/npm/v/@eggjs/ajv-decorator.svg?style=flat-square
9
+ [npm-url]: https://npmjs.org/package/@eggjs/ajv-decorator
10
+ [snyk-image]: https://snyk.io/test/npm/@eggjs/ajv-decorator/badge.svg?style=flat-square
11
+ [snyk-url]: https://snyk.io/test/npm/@eggjs/ajv-decorator
12
+ [download-image]: https://img.shields.io/npm/dm/@eggjs/ajv-decorator.svg?style=flat-square
13
+ [download-url]: https://npmjs.org/package/@eggjs/ajv-decorator
14
+
3
15
  ## Usage
4
16
 
5
- Please read [@eggjs/tegg-ajv-plugin](../../plugin/ajv-plugin)
17
+ Please read [@eggjs/tegg-ajv-plugin](../../plugin/ajv/README.md)
@@ -0,0 +1,48 @@
1
+ //#region src/enum/TransformEnum.d.ts
2
+ /**
3
+ * This keyword allows a string to be modified during validation.
4
+ * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
5
+ * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
6
+ */
7
+ declare enum TransformEnum {
8
+ /** remove whitespace from start and end */
9
+ trim = "trim",
10
+ /** remove whitespace from start */
11
+ trimStart = "trimStart",
12
+ /**
13
+ * @alias trimStart
14
+ */
15
+ trimLeft = "trimLeft",
16
+ /** remove whitespace from end */
17
+ trimEnd = "trimEnd",
18
+ /**
19
+ * @alias trimEnd
20
+ */
21
+ trimRight = "trimRight",
22
+ /** convert to lower case */
23
+ toLowerCase = "toLowerCase",
24
+ /** convert to upper case */
25
+ toUpperCase = "toUpperCase",
26
+ /**
27
+ * change string case to be equal to one of `enum` values in the schema
28
+ *
29
+ * **NOTE**: requires that all allowed values are unique when case insensitive
30
+ * ```ts
31
+ * const schema = {
32
+ * type: "array",
33
+ * items: {
34
+ * type: "string",
35
+ * transform: ["trim", Transform.toEnumCase],
36
+ * enum: ["pH"],
37
+ * },
38
+ * };
39
+ *
40
+ * const data = ["ph", " Ph", "PH", "pH "];
41
+ * ajv.validate(schema, data);
42
+ * console.log(data) // ['pH','pH','pH','pH'];
43
+ * ```
44
+ */
45
+ toEnumCase = "toEnumCase",
46
+ }
47
+ //#endregion
48
+ export { TransformEnum };
@@ -0,0 +1,50 @@
1
+ //#region src/enum/TransformEnum.ts
2
+ /**
3
+ * This keyword allows a string to be modified during validation.
4
+ * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
5
+ * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
6
+ */
7
+ let TransformEnum = /* @__PURE__ */ function(TransformEnum$1) {
8
+ /** remove whitespace from start and end */
9
+ TransformEnum$1["trim"] = "trim";
10
+ /** remove whitespace from start */
11
+ TransformEnum$1["trimStart"] = "trimStart";
12
+ /**
13
+ * @alias trimStart
14
+ */
15
+ TransformEnum$1["trimLeft"] = "trimLeft";
16
+ /** remove whitespace from end */
17
+ TransformEnum$1["trimEnd"] = "trimEnd";
18
+ /**
19
+ * @alias trimEnd
20
+ */
21
+ TransformEnum$1["trimRight"] = "trimRight";
22
+ /** convert to lower case */
23
+ TransformEnum$1["toLowerCase"] = "toLowerCase";
24
+ /** convert to upper case */
25
+ TransformEnum$1["toUpperCase"] = "toUpperCase";
26
+ /**
27
+ * change string case to be equal to one of `enum` values in the schema
28
+ *
29
+ * **NOTE**: requires that all allowed values are unique when case insensitive
30
+ * ```ts
31
+ * const schema = {
32
+ * type: "array",
33
+ * items: {
34
+ * type: "string",
35
+ * transform: ["trim", Transform.toEnumCase],
36
+ * enum: ["pH"],
37
+ * },
38
+ * };
39
+ *
40
+ * const data = ["ph", " Ph", "PH", "pH "];
41
+ * ajv.validate(schema, data);
42
+ * console.log(data) // ['pH','pH','pH','pH'];
43
+ * ```
44
+ */
45
+ TransformEnum$1["toEnumCase"] = "toEnumCase";
46
+ return TransformEnum$1;
47
+ }({});
48
+
49
+ //#endregion
50
+ export { TransformEnum };
@@ -0,0 +1,16 @@
1
+ import { ErrorObject } from "ajv/dist/2019.js";
2
+
3
+ //#region src/error/AjvInvalidParamError.d.ts
4
+ interface AjvInvalidParamErrorOptions {
5
+ errorData: unknown;
6
+ currentSchema: string;
7
+ errors: ErrorObject[];
8
+ }
9
+ declare class AjvInvalidParamError extends Error {
10
+ errorData: unknown;
11
+ currentSchema: string;
12
+ errors: ErrorObject[];
13
+ constructor(message: string, options: AjvInvalidParamErrorOptions);
14
+ }
15
+ //#endregion
16
+ export { AjvInvalidParamError, AjvInvalidParamErrorOptions };
@@ -0,0 +1,18 @@
1
+ import "ajv/dist/2019.js";
2
+
3
+ //#region src/error/AjvInvalidParamError.ts
4
+ var AjvInvalidParamError = class extends Error {
5
+ errorData;
6
+ currentSchema;
7
+ errors;
8
+ constructor(message, options) {
9
+ super(message);
10
+ this.name = this.constructor.name;
11
+ this.errorData = options.errorData;
12
+ this.currentSchema = options.currentSchema;
13
+ this.errors = options.errors;
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ export { AjvInvalidParamError };
@@ -0,0 +1,3 @@
1
+ import { AjvInvalidParamError } from "./AjvInvalidParamError.js";
2
+
3
+ export { };
@@ -0,0 +1,5 @@
1
+ import { TransformEnum } from "./enum/TransformEnum.js";
2
+ import { AjvInvalidParamError, AjvInvalidParamErrorOptions } from "./error/AjvInvalidParamError.js";
3
+ import { Ajv } from "./type/Ajv.js";
4
+ export * from "@sinclair/typebox";
5
+ export { Ajv, AjvInvalidParamError, AjvInvalidParamErrorOptions, TransformEnum };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { TransformEnum } from "./enum/TransformEnum.js";
2
+ import { AjvInvalidParamError } from "./error/AjvInvalidParamError.js";
3
+ import "./error/index.js";
4
+
5
+ export * from "@sinclair/typebox"
6
+
7
+ export { AjvInvalidParamError, TransformEnum };
@@ -0,0 +1,8 @@
1
+ import { Schema } from "ajv/dist/2019.js";
2
+
3
+ //#region src/type/Ajv.d.ts
4
+ interface Ajv {
5
+ validate(schema: Schema, data: unknown): void;
6
+ }
7
+ //#endregion
8
+ export { Ajv };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/ajv-decorator",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "tegg ajv decorator",
5
5
  "keywords": [
6
6
  "egg",
@@ -11,23 +11,14 @@
11
11
  ],
12
12
  "type": "module",
13
13
  "exports": {
14
- ".": {
15
- "types": "./src/index.d.ts",
16
- "default": "./src/index.js"
17
- }
14
+ ".": "./dist/index.js",
15
+ "./package.json": "./package.json"
18
16
  },
19
17
  "files": [
20
- "src/**/*.js",
21
- "src/**/*.d.ts"
18
+ "dist"
22
19
  ],
23
- "scripts": {
24
- "clean": "tsc -b --clean",
25
- "tsc": "npm run clean && tsc -p ./tsconfig.json",
26
- "tsc:pub": "npm run tsc",
27
- "prepublishOnly": "npm run tsc"
28
- },
29
20
  "license": "MIT",
30
- "homepage": "https://github.com/eggjs/tegg",
21
+ "homepage": "https://github.com/eggjs/tegg/tree/next/core/ajv-decorator",
31
22
  "bugs": {
32
23
  "url": "https://github.com/eggjs/tegg/issues"
33
24
  },
@@ -37,7 +28,7 @@
37
28
  "directory": "core/ajv-decorator"
38
29
  },
39
30
  "engines": {
40
- "node": ">=20.0.0"
31
+ "node": ">=22.18.0"
41
32
  },
42
33
  "dependencies": {
43
34
  "@sinclair/typebox": "^0.32.20",
@@ -47,9 +38,17 @@
47
38
  "access": "public"
48
39
  },
49
40
  "devDependencies": {
50
- "@types/node": "22",
51
- "ts-node": "10",
52
- "typescript": "5"
53
- },
54
- "gitHead": "9ba90bed3ab9f641ceaa6a7db560095817b7e52c"
55
- }
41
+ "@types/node": "^22.10.5",
42
+ "typescript": "^5.9.3",
43
+ "tsdown": "^0.15.6",
44
+ "unplugin-unused": "^0.5.3"
45
+ },
46
+ "main": "./dist/index.js",
47
+ "module": "./dist/index.js",
48
+ "types": "./dist/index.d.ts",
49
+ "scripts": {
50
+ "clean": "rimraf dist",
51
+ "build": "tsdown",
52
+ "typecheck": "tsc --noEmit"
53
+ }
54
+ }
@@ -1,45 +0,0 @@
1
- /**
2
- * This keyword allows a string to be modified during validation.
3
- * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
4
- * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
5
- */
6
- export declare enum TransformEnum {
7
- /** remove whitespace from start and end */
8
- trim = "trim",
9
- /** remove whitespace from start */
10
- trimStart = "trimStart",
11
- /**
12
- * @alias trimStart
13
- */
14
- trimLeft = "trimLeft",
15
- /** remove whitespace from end */
16
- trimEnd = "trimEnd",
17
- /**
18
- * @alias trimEnd
19
- */
20
- trimRight = "trimRight",
21
- /** convert to lower case */
22
- toLowerCase = "toLowerCase",
23
- /** convert to upper case */
24
- toUpperCase = "toUpperCase",
25
- /**
26
- * change string case to be equal to one of `enum` values in the schema
27
- *
28
- * **NOTE**: requires that all allowed values are unique when case insensitive
29
- * ```ts
30
- * const schema = {
31
- * type: "array",
32
- * items: {
33
- * type: "string",
34
- * transform: ["trim", Transform.toEnumCase],
35
- * enum: ["pH"],
36
- * },
37
- * };
38
- *
39
- * const data = ["ph", " Ph", "PH", "pH "];
40
- * ajv.validate(schema, data);
41
- * console.log(data) // ['pH','pH','pH','pH'];
42
- * ```
43
- */
44
- toEnumCase = "toEnumCase"
45
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * This keyword allows a string to be modified during validation.
3
- * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
4
- * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
5
- */
6
- export var TransformEnum;
7
- (function (TransformEnum) {
8
- /** remove whitespace from start and end */
9
- TransformEnum["trim"] = "trim";
10
- /** remove whitespace from start */
11
- TransformEnum["trimStart"] = "trimStart";
12
- /**
13
- * @alias trimStart
14
- */
15
- TransformEnum["trimLeft"] = "trimLeft";
16
- /** remove whitespace from end */
17
- TransformEnum["trimEnd"] = "trimEnd";
18
- /**
19
- * @alias trimEnd
20
- */
21
- TransformEnum["trimRight"] = "trimRight";
22
- /** convert to lower case */
23
- TransformEnum["toLowerCase"] = "toLowerCase";
24
- /** convert to upper case */
25
- TransformEnum["toUpperCase"] = "toUpperCase";
26
- /**
27
- * change string case to be equal to one of `enum` values in the schema
28
- *
29
- * **NOTE**: requires that all allowed values are unique when case insensitive
30
- * ```ts
31
- * const schema = {
32
- * type: "array",
33
- * items: {
34
- * type: "string",
35
- * transform: ["trim", Transform.toEnumCase],
36
- * enum: ["pH"],
37
- * },
38
- * };
39
- *
40
- * const data = ["ph", " Ph", "PH", "pH "];
41
- * ajv.validate(schema, data);
42
- * console.log(data) // ['pH','pH','pH','pH'];
43
- * ```
44
- */
45
- TransformEnum["toEnumCase"] = "toEnumCase";
46
- })(TransformEnum || (TransformEnum = {}));
47
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVHJhbnNmb3JtRW51bS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIlRyYW5zZm9ybUVudW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILE1BQU0sQ0FBTixJQUFZLGFBdUNYO0FBdkNELFdBQVksYUFBYTtJQUN2QiwyQ0FBMkM7SUFDM0MsOEJBQWEsQ0FBQTtJQUNiLG1DQUFtQztJQUNuQyx3Q0FBdUIsQ0FBQTtJQUN2Qjs7T0FFRztJQUNILHNDQUFxQixDQUFBO0lBQ3JCLGlDQUFpQztJQUNqQyxvQ0FBbUIsQ0FBQTtJQUNuQjs7T0FFRztJQUNILHdDQUF1QixDQUFBO0lBQ3ZCLDRCQUE0QjtJQUM1Qiw0Q0FBMkIsQ0FBQTtJQUMzQiw0QkFBNEI7SUFDNUIsNENBQTJCLENBQUE7SUFDM0I7Ozs7Ozs7Ozs7Ozs7Ozs7OztPQWtCRztJQUNILDBDQUF5QixDQUFBO0FBQzNCLENBQUMsRUF2Q1csYUFBYSxLQUFiLGFBQWEsUUF1Q3hCIn0=
@@ -1 +0,0 @@
1
- export * from './TransformEnum.js';
package/src/enum/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './TransformEnum.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG9CQUFvQixDQUFDIn0=
@@ -1,12 +0,0 @@
1
- import { type ErrorObject } from 'ajv/dist/2019.js';
2
- export interface AjvInvalidParamErrorOptions {
3
- errorData: unknown;
4
- currentSchema: string;
5
- errors: ErrorObject[];
6
- }
7
- export declare class AjvInvalidParamError extends Error {
8
- errorData: unknown;
9
- currentSchema: string;
10
- errors: ErrorObject[];
11
- constructor(message: string, options: AjvInvalidParamErrorOptions);
12
- }
@@ -1,13 +0,0 @@
1
- export class AjvInvalidParamError extends Error {
2
- errorData;
3
- currentSchema;
4
- errors;
5
- constructor(message, options) {
6
- super(message);
7
- this.name = this.constructor.name;
8
- this.errorData = options.errorData;
9
- this.currentSchema = options.currentSchema;
10
- this.errors = options.errors;
11
- }
12
- }
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWp2SW52YWxpZFBhcmFtRXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJBanZJbnZhbGlkUGFyYW1FcnJvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRQSxNQUFNLE9BQU8sb0JBQXFCLFNBQVEsS0FBSztJQUM3QyxTQUFTLENBQVU7SUFDbkIsYUFBYSxDQUFTO0lBQ3RCLE1BQU0sQ0FBZ0I7SUFFdEIsWUFBWSxPQUFlLEVBQUUsT0FBb0M7UUFDL0QsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ2YsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQztRQUNsQyxJQUFJLENBQUMsU0FBUyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUM7UUFDbkMsSUFBSSxDQUFDLGFBQWEsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDO1FBQzNDLElBQUksQ0FBQyxNQUFNLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQztJQUMvQixDQUFDO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- export * from './AjvInvalidParamError.js';
@@ -1,2 +0,0 @@
1
- export * from './AjvInvalidParamError.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDIn0=
package/src/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from '@sinclair/typebox';
2
- export * from './enum/index.js';
3
- export * from './error/index.js';
4
- export * from './type/index.js';
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- export * from '@sinclair/typebox';
2
- export * from './enum/index.js';
3
- export * from './error/index.js';
4
- export * from './type/index.js';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyxrQkFBa0IsQ0FBQztBQUNqQyxjQUFjLGlCQUFpQixDQUFDIn0=
package/src/type/Ajv.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Schema } from 'ajv/dist/2019.js';
2
- export interface Ajv {
3
- validate(schema: Schema, data: unknown): void;
4
- }
package/src/type/Ajv.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWp2LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiQWp2LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -1 +0,0 @@
1
- export * from './Ajv.js';
package/src/type/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './Ajv.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFVBQVUsQ0FBQyJ9