@eggjs/ajv-decorator 4.0.0-beta.34 → 4.0.0-beta.36
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/dist/enum/TransformEnum.d.ts +47 -44
- package/dist/enum/TransformEnum.js +17 -44
- package/dist/error/AjvInvalidParamError.d.ts +14 -10
- package/dist/error/AjvInvalidParamError.js +19 -15
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +3 -2
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -5
- package/dist/type/Ajv.d.ts +7 -3
- package/dist/type/index.d.ts +1 -1
- package/package.json +26 -30
- package/dist/enum/index.d.ts +0 -1
- package/dist/enum/index.js +0 -2
- package/dist/type/Ajv.js +0 -2
- package/dist/type/index.js +0 -2
|
@@ -1,46 +1,49 @@
|
|
|
1
|
+
//#region src/enum/TransformEnum.d.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 const TransformEnum: {
|
|
8
|
+
/** remove whitespace from start and end */
|
|
9
|
+
trim: string;
|
|
10
|
+
/** remove whitespace from start */
|
|
11
|
+
trimStart: string;
|
|
12
|
+
/**
|
|
13
|
+
* @alias trimStart
|
|
14
|
+
*/
|
|
15
|
+
trimLeft: string;
|
|
16
|
+
/** remove whitespace from end */
|
|
17
|
+
trimEnd: string;
|
|
18
|
+
/**
|
|
19
|
+
* @alias trimEnd
|
|
20
|
+
*/
|
|
21
|
+
trimRight: string;
|
|
22
|
+
/** convert to lower case */
|
|
23
|
+
toLowerCase: string;
|
|
24
|
+
/** convert to upper case */
|
|
25
|
+
toUpperCase: string;
|
|
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: string;
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
type TransformEnum = (typeof TransformEnum)[keyof typeof TransformEnum];
|
|
48
|
+
//#endregion
|
|
49
|
+
export { TransformEnum };
|
|
@@ -1,46 +1,19 @@
|
|
|
1
|
+
//#region src/enum/TransformEnum.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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',
|
|
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
|
+
const TransformEnum = {
|
|
8
|
+
trim: "trim",
|
|
9
|
+
trimStart: "trimStart",
|
|
10
|
+
trimLeft: "trimLeft",
|
|
11
|
+
trimEnd: "trimEnd",
|
|
12
|
+
trimRight: "trimRight",
|
|
13
|
+
toLowerCase: "toLowerCase",
|
|
14
|
+
toUpperCase: "toUpperCase",
|
|
15
|
+
toEnumCase: "toEnumCase"
|
|
45
16
|
};
|
|
46
|
-
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TransformEnum };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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[];
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
declare class AjvInvalidParamError extends Error {
|
|
10
|
+
errorData: unknown;
|
|
11
|
+
currentSchema: string;
|
|
12
|
+
errors: ErrorObject[];
|
|
13
|
+
constructor(message: string, options: AjvInvalidParamErrorOptions);
|
|
12
14
|
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { AjvInvalidParamError, AjvInvalidParamErrorOptions };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { AjvInvalidParamError };
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { AjvInvalidParamError, AjvInvalidParamErrorOptions } from "./AjvInvalidParamError.js";
|
package/dist/error/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { AjvInvalidParamError } from "./AjvInvalidParamError.js";
|
|
2
|
+
|
|
3
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { TransformEnum } from "./enum/TransformEnum.js";
|
|
2
|
+
import { AjvInvalidParamError, AjvInvalidParamErrorOptions } from "./error/AjvInvalidParamError.js";
|
|
3
|
+
import "./error/index.js";
|
|
4
|
+
import { Ajv } from "./type/Ajv.js";
|
|
5
|
+
import "./type/index.js";
|
|
6
|
+
export * from "typebox";
|
|
7
|
+
export { Ajv, AjvInvalidParamError, AjvInvalidParamErrorOptions, TransformEnum };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { TransformEnum } from "./enum/TransformEnum.js";
|
|
2
|
+
import { AjvInvalidParamError } from "./error/AjvInvalidParamError.js";
|
|
3
|
+
import "./error/index.js";
|
|
4
|
+
|
|
5
|
+
export * from "typebox"
|
|
6
|
+
|
|
7
|
+
export { AjvInvalidParamError, TransformEnum };
|
package/dist/type/Ajv.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
4
6
|
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Ajv };
|
package/dist/type/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ajv } from "./Ajv.js";
|
package/package.json
CHANGED
|
@@ -1,54 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/ajv-decorator",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
4
4
|
"description": "tegg ajv decorator",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"typescript",
|
|
6
|
+
"ajv",
|
|
8
7
|
"decorator",
|
|
8
|
+
"egg",
|
|
9
9
|
"tegg",
|
|
10
|
-
"
|
|
10
|
+
"typescript"
|
|
11
11
|
],
|
|
12
|
-
"type": "module",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": "./dist/index.js",
|
|
15
|
-
"./package.json": "./package.json"
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
12
|
"homepage": "https://github.com/eggjs/egg/tree/next/tegg/core/ajv-decorator",
|
|
22
13
|
"bugs": {
|
|
23
14
|
"url": "https://github.com/eggjs/egg/issues"
|
|
24
15
|
},
|
|
16
|
+
"license": "MIT",
|
|
25
17
|
"repository": {
|
|
26
18
|
"type": "git",
|
|
27
|
-
"url": "git
|
|
19
|
+
"url": "git+https://github.com/eggjs/egg.git",
|
|
28
20
|
"directory": "tegg/core/ajv-decorator"
|
|
29
21
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.js",
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
37
|
+
"ajv": "^8.8.2",
|
|
38
|
+
"typebox": "^1.0.65"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^24.
|
|
39
|
-
"typescript": "^5.9.3"
|
|
40
|
-
"tsdown": "0.15.11",
|
|
41
|
-
"unplugin-unused": "^0.5.4"
|
|
41
|
+
"@types/node": "^24.10.2",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
42
43
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.18.0"
|
|
45
46
|
},
|
|
46
|
-
"main": "./dist/index.js",
|
|
47
|
-
"module": "./dist/index.js",
|
|
48
|
-
"types": "./dist/index.d.ts",
|
|
49
47
|
"scripts": {
|
|
50
|
-
"
|
|
51
|
-
"build": "tsdown && npm run clean && tsc -p tsconfig.build.json",
|
|
52
|
-
"typecheck": "tsc --noEmit"
|
|
48
|
+
"typecheck": "tsgo --noEmit"
|
|
53
49
|
}
|
|
54
50
|
}
|
package/dist/enum/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TransformEnum.ts';
|
package/dist/enum/index.js
DELETED
package/dist/type/Ajv.js
DELETED
package/dist/type/index.js
DELETED