@eggjs/ajv-decorator 4.0.0-beta.8 → 4.0.0-beta.9

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.
@@ -0,0 +1,45 @@
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
+ }
@@ -0,0 +1,47 @@
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVHJhbnNmb3JtRW51bS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9lbnVtL1RyYW5zZm9ybUVudW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILE1BQU0sQ0FBTixJQUFZLGFBdUNYO0FBdkNELFdBQVksYUFBYTtJQUN2QiwyQ0FBMkM7SUFDM0MsOEJBQWEsQ0FBQTtJQUNiLG1DQUFtQztJQUNuQyx3Q0FBdUIsQ0FBQTtJQUN2Qjs7T0FFRztJQUNILHNDQUFxQixDQUFBO0lBQ3JCLGlDQUFpQztJQUNqQyxvQ0FBbUIsQ0FBQTtJQUNuQjs7T0FFRztJQUNILHdDQUF1QixDQUFBO0lBQ3ZCLDRCQUE0QjtJQUM1Qiw0Q0FBMkIsQ0FBQTtJQUMzQiw0QkFBNEI7SUFDNUIsNENBQTJCLENBQUE7SUFDM0I7Ozs7Ozs7Ozs7Ozs7Ozs7OztPQWtCRztJQUNILDBDQUF5QixDQUFBO0FBQzNCLENBQUMsRUF2Q1csYUFBYSxLQUFiLGFBQWEsUUF1Q3hCIn0=
@@ -0,0 +1 @@
1
+ export * from './TransformEnum.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./TransformEnum.js";
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW51bS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG9CQUFvQixDQUFDIn0=
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,14 @@
1
+ import {} from 'ajv/dist/2019.js';
2
+ export class AjvInvalidParamError extends Error {
3
+ errorData;
4
+ currentSchema;
5
+ errors;
6
+ constructor(message, options) {
7
+ super(message);
8
+ this.name = this.constructor.name;
9
+ this.errorData = options.errorData;
10
+ this.currentSchema = options.currentSchema;
11
+ this.errors = options.errors;
12
+ }
13
+ }
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWp2SW52YWxpZFBhcmFtRXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXJyb3IvQWp2SW52YWxpZFBhcmFtRXJyb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFvQixNQUFNLGtCQUFrQixDQUFDO0FBUXBELE1BQU0sT0FBTyxvQkFBcUIsU0FBUSxLQUFLO0lBQzdDLFNBQVMsQ0FBVTtJQUNuQixhQUFhLENBQVM7SUFDdEIsTUFBTSxDQUFnQjtJQUV0QixZQUFZLE9BQWUsRUFBRSxPQUFvQztRQUMvRCxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDZixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDO1FBQ2xDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQztRQUNuQyxJQUFJLENBQUMsYUFBYSxHQUFHLE9BQU8sQ0FBQyxhQUFhLENBQUM7UUFDM0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDO0lBQy9CLENBQUM7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ export * from './AjvInvalidParamError.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./AjvInvalidParamError.js";
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXJyb3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywyQkFBMkIsQ0FBQyJ9
package/dist/index.d.ts CHANGED
@@ -1,69 +1,4 @@
1
- import { ErrorObject, Schema } from "ajv/dist/2019.js";
2
- export * from "@sinclair/typebox";
3
-
4
- //#region src/enum/TransformEnum.d.ts
5
- /**
6
- * This keyword allows a string to be modified during validation.
7
- * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
8
- * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
9
- */
10
- declare enum TransformEnum {
11
- /** remove whitespace from start and end */
12
- trim = "trim",
13
- /** remove whitespace from start */
14
- trimStart = "trimStart",
15
- /**
16
- * @alias trimStart
17
- */
18
- trimLeft = "trimLeft",
19
- /** remove whitespace from end */
20
- trimEnd = "trimEnd",
21
- /**
22
- * @alias trimEnd
23
- */
24
- trimRight = "trimRight",
25
- /** convert to lower case */
26
- toLowerCase = "toLowerCase",
27
- /** convert to upper case */
28
- toUpperCase = "toUpperCase",
29
- /**
30
- * change string case to be equal to one of `enum` values in the schema
31
- *
32
- * **NOTE**: requires that all allowed values are unique when case insensitive
33
- * ```ts
34
- * const schema = {
35
- * type: "array",
36
- * items: {
37
- * type: "string",
38
- * transform: ["trim", Transform.toEnumCase],
39
- * enum: ["pH"],
40
- * },
41
- * };
42
- *
43
- * const data = ["ph", " Ph", "PH", "pH "];
44
- * ajv.validate(schema, data);
45
- * console.log(data) // ['pH','pH','pH','pH'];
46
- * ```
47
- */
48
- toEnumCase = "toEnumCase",
49
- }
50
- //#endregion
51
- //#region src/error/AjvInvalidParamError.d.ts
52
- interface AjvInvalidParamErrorOptions {
53
- errorData: unknown;
54
- currentSchema: string;
55
- errors: ErrorObject[];
56
- }
57
- declare class AjvInvalidParamError extends Error {
58
- errorData: unknown;
59
- currentSchema: string;
60
- errors: ErrorObject[];
61
- constructor(message: string, options: AjvInvalidParamErrorOptions);
62
- }
63
- //#endregion
64
- //#region src/type/Ajv.d.ts
65
- interface Ajv {
66
- validate(schema: Schema, data: unknown): void;
67
- }
68
- //#endregion
69
- export { Ajv, AjvInvalidParamError, AjvInvalidParamErrorOptions, TransformEnum };
1
+ export * from '@sinclair/typebox';
2
+ export * from './enum/index.ts';
3
+ export * from './error/index.ts';
4
+ export * from './type/index.ts';
package/dist/index.js CHANGED
@@ -1,69 +1,5 @@
1
- import "ajv/dist/2019.js";
2
-
3
- export * from "@sinclair/typebox"
4
-
5
- //#region src/enum/TransformEnum.ts
6
- /**
7
- * This keyword allows a string to be modified during validation.
8
- * This keyword applies only to strings. If the data is not a string, the transform keyword is ignored.
9
- * @see https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#transform
10
- */
11
- let TransformEnum = /* @__PURE__ */ function(TransformEnum$1) {
12
- /** remove whitespace from start and end */
13
- TransformEnum$1["trim"] = "trim";
14
- /** remove whitespace from start */
15
- TransformEnum$1["trimStart"] = "trimStart";
16
- /**
17
- * @alias trimStart
18
- */
19
- TransformEnum$1["trimLeft"] = "trimLeft";
20
- /** remove whitespace from end */
21
- TransformEnum$1["trimEnd"] = "trimEnd";
22
- /**
23
- * @alias trimEnd
24
- */
25
- TransformEnum$1["trimRight"] = "trimRight";
26
- /** convert to lower case */
27
- TransformEnum$1["toLowerCase"] = "toLowerCase";
28
- /** convert to upper case */
29
- TransformEnum$1["toUpperCase"] = "toUpperCase";
30
- /**
31
- * change string case to be equal to one of `enum` values in the schema
32
- *
33
- * **NOTE**: requires that all allowed values are unique when case insensitive
34
- * ```ts
35
- * const schema = {
36
- * type: "array",
37
- * items: {
38
- * type: "string",
39
- * transform: ["trim", Transform.toEnumCase],
40
- * enum: ["pH"],
41
- * },
42
- * };
43
- *
44
- * const data = ["ph", " Ph", "PH", "pH "];
45
- * ajv.validate(schema, data);
46
- * console.log(data) // ['pH','pH','pH','pH'];
47
- * ```
48
- */
49
- TransformEnum$1["toEnumCase"] = "toEnumCase";
50
- return TransformEnum$1;
51
- }({});
52
-
53
- //#endregion
54
- //#region src/error/AjvInvalidParamError.ts
55
- var AjvInvalidParamError = class extends Error {
56
- errorData;
57
- currentSchema;
58
- errors;
59
- constructor(message, options) {
60
- super(message);
61
- this.name = this.constructor.name;
62
- this.errorData = options.errorData;
63
- this.currentSchema = options.currentSchema;
64
- this.errors = options.errors;
65
- }
66
- };
67
-
68
- //#endregion
69
- export { AjvInvalidParamError, TransformEnum };
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxpQkFBaUIsQ0FBQyJ9
@@ -0,0 +1,4 @@
1
+ import type { Schema } from 'ajv/dist/2019.js';
2
+ export interface Ajv {
3
+ validate(schema: Schema, data: unknown): void;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWp2LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGUvQWp2LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1 @@
1
+ export * from './Ajv.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./Ajv.js";
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFVBQVUsQ0FBQyJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/ajv-decorator",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0-beta.9",
4
4
  "description": "tegg ajv decorator",
5
5
  "keywords": [
6
6
  "egg",
@@ -48,7 +48,7 @@
48
48
  "types": "./dist/index.d.ts",
49
49
  "scripts": {
50
50
  "clean": "rimraf dist",
51
- "build": "tsdown",
51
+ "build": "tsdown && rimraf dist && tsc -b --clean && tsc",
52
52
  "typecheck": "tsc --noEmit"
53
53
  }
54
54
  }