@itzworking/decorated-class 0.0.151 → 0.0.157
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 +3 -3
- package/{src → dist}/decorated-class.d.ts +1 -0
- package/dist/decorated-class.d.ts.map +1 -0
- package/{src → dist}/decorated-class.js +11 -16
- package/{src → dist}/decorators/attribute/attribute.d.ts +1 -0
- package/dist/decorators/attribute/attribute.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/attribute.js +11 -16
- package/dist/decorators/attribute/index.d.ts +5 -0
- package/dist/decorators/attribute/index.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/is-attribute.d.ts +1 -0
- package/dist/decorators/attribute/is-attribute.d.ts.map +1 -0
- package/dist/decorators/attribute/is-attribute.js +4 -0
- package/{src → dist}/decorators/attribute/list-attributes.d.ts +1 -0
- package/dist/decorators/attribute/list-attributes.d.ts.map +1 -0
- package/dist/decorators/attribute/list-attributes.js +11 -0
- package/{src → dist}/decorators/attribute/symbol.d.ts +1 -0
- package/dist/decorators/attribute/symbol.d.ts.map +1 -0
- package/dist/decorators/attribute/symbol.js +1 -0
- package/{src → dist}/decorators/attribute/types/attribute-decorator.d.ts +1 -0
- package/dist/decorators/attribute/types/attribute-decorator.d.ts.map +1 -0
- package/dist/decorators/attribute/types/attribute-decorator.js +1 -0
- package/{src → dist}/decorators/attribute/types/attribute-definition.d.ts +1 -0
- package/dist/decorators/attribute/types/attribute-definition.d.ts.map +1 -0
- package/dist/decorators/attribute/types/attribute-definition.js +1 -0
- package/dist/decorators/attribute/types/attribute-type-alias.d.ts +3 -0
- package/dist/decorators/attribute/types/attribute-type-alias.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/types/attribute-type.d.ts +1 -0
- package/dist/decorators/attribute/types/attribute-type.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/types/attribute-type.js +3 -6
- package/dist/decorators/attribute/types/index.d.ts +6 -0
- package/dist/decorators/attribute/types/index.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/types/primitive-type.d.ts +1 -0
- package/dist/decorators/attribute/types/primitive-type.d.ts.map +1 -0
- package/dist/decorators/attribute/types/primitive-type.js +8 -0
- package/dist/decorators/attribute/utils/index.d.ts +2 -0
- package/dist/decorators/attribute/utils/index.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/utils/update-attributes.d.ts +1 -0
- package/dist/decorators/attribute/utils/update-attributes.d.ts.map +1 -0
- package/{src → dist}/decorators/attribute/utils/update-attributes.js +8 -13
- package/dist/decorators/index.d.ts +5 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/validation/index.d.ts +8 -0
- package/dist/decorators/validation/index.d.ts.map +1 -0
- package/{src → dist}/decorators/validation/max.d.ts +1 -0
- package/dist/decorators/validation/max.d.ts.map +1 -0
- package/dist/decorators/validation/max.js +17 -0
- package/{src → dist}/decorators/validation/min.d.ts +1 -0
- package/dist/decorators/validation/min.d.ts.map +1 -0
- package/dist/decorators/validation/min.js +17 -0
- package/{src → dist}/decorators/validation/not-blank.d.ts +1 -0
- package/dist/decorators/validation/not-blank.d.ts.map +1 -0
- package/dist/decorators/validation/not-blank.js +11 -0
- package/{src → dist}/decorators/validation/not-null.d.ts +1 -0
- package/dist/decorators/validation/not-null.d.ts.map +1 -0
- package/dist/decorators/validation/not-null.js +2 -0
- package/{src → dist}/decorators/validation/pattern.d.ts +1 -0
- package/dist/decorators/validation/pattern.d.ts.map +1 -0
- package/dist/decorators/validation/pattern.js +12 -0
- package/dist/decorators/validation/types/index.d.ts +3 -0
- package/dist/decorators/validation/types/index.d.ts.map +1 -0
- package/{src → dist}/decorators/validation/types/validation-definition.d.ts +1 -0
- package/dist/decorators/validation/types/validation-definition.d.ts.map +1 -0
- package/dist/decorators/validation/types/validation-definition.js +1 -0
- package/{src → dist}/decorators/validation/types/validation-type.d.ts +1 -0
- package/dist/decorators/validation/types/validation-type.d.ts.map +1 -0
- package/dist/decorators/validation/types/validation-type.js +1 -0
- package/dist/decorators/validation/utils/index.d.ts +2 -0
- package/dist/decorators/validation/utils/index.d.ts.map +1 -0
- package/{src → dist}/decorators/validation/utils/register-constraint.d.ts +1 -0
- package/dist/decorators/validation/utils/register-constraint.d.ts.map +1 -0
- package/{src → dist}/decorators/validation/utils/register-constraint.js +10 -16
- package/{src → dist}/errors/attributes-not-valid-error.d.ts +1 -0
- package/dist/errors/attributes-not-valid-error.d.ts.map +1 -0
- package/dist/errors/attributes-not-valid-error.js +9 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/{src → dist}/errors/invalid-target-error.d.ts +1 -0
- package/dist/errors/invalid-target-error.d.ts.map +1 -0
- package/dist/errors/invalid-target-error.js +6 -0
- package/{src → dist}/errors/unsupported-decorator-error.d.ts +1 -0
- package/dist/errors/unsupported-decorator-error.d.ts.map +1 -0
- package/{src → dist}/errors/unsupported-decorator-error.js +4 -6
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/{src → dist}/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/validator/index.d.ts +2 -0
- package/dist/validator/index.d.ts.map +1 -0
- package/{src → dist}/validator/list-validation-errors.d.ts +1 -0
- package/dist/validator/list-validation-errors.d.ts.map +1 -0
- package/{src → dist}/validator/list-validation-errors.js +8 -13
- package/{src → dist}/validator/validate.d.ts +1 -0
- package/dist/validator/validate.d.ts.map +1 -0
- package/dist/validator/validate.js +8 -0
- package/{src → dist}/validator/validator.d.ts +1 -0
- package/dist/validator/validator.d.ts.map +1 -0
- package/dist/validator/validator.js +6 -0
- package/package.json +36 -8
- package/src/decorated-class.js.map +0 -1
- package/src/decorators/attribute/attribute.js.map +0 -1
- package/src/decorators/attribute/index.js +0 -8
- package/src/decorators/attribute/index.js.map +0 -1
- package/src/decorators/attribute/is-attribute.js +0 -9
- package/src/decorators/attribute/is-attribute.js.map +0 -1
- package/src/decorators/attribute/list-attributes.js +0 -16
- package/src/decorators/attribute/list-attributes.js.map +0 -1
- package/src/decorators/attribute/symbol.js +0 -5
- package/src/decorators/attribute/symbol.js.map +0 -1
- package/src/decorators/attribute/types/attribute-decorator.js +0 -3
- package/src/decorators/attribute/types/attribute-decorator.js.map +0 -1
- package/src/decorators/attribute/types/attribute-definition.js +0 -3
- package/src/decorators/attribute/types/attribute-definition.js.map +0 -1
- package/src/decorators/attribute/types/attribute-type-alias.js +0 -6
- package/src/decorators/attribute/types/attribute-type-alias.js.map +0 -1
- package/src/decorators/attribute/types/attribute-type.js.map +0 -1
- package/src/decorators/attribute/types/index.js +0 -9
- package/src/decorators/attribute/types/index.js.map +0 -1
- package/src/decorators/attribute/types/primitive-type.js +0 -12
- package/src/decorators/attribute/types/primitive-type.js.map +0 -1
- package/src/decorators/attribute/utils/index.js +0 -5
- package/src/decorators/attribute/utils/index.js.map +0 -1
- package/src/decorators/attribute/utils/update-attributes.js.map +0 -1
- package/src/decorators/index.js +0 -8
- package/src/decorators/index.js.map +0 -1
- package/src/decorators/validation/index.js +0 -11
- package/src/decorators/validation/index.js.map +0 -1
- package/src/decorators/validation/max.js +0 -21
- package/src/decorators/validation/max.js.map +0 -1
- package/src/decorators/validation/min.js +0 -21
- package/src/decorators/validation/min.js.map +0 -1
- package/src/decorators/validation/not-blank.js +0 -15
- package/src/decorators/validation/not-blank.js.map +0 -1
- package/src/decorators/validation/not-null.js +0 -6
- package/src/decorators/validation/not-null.js.map +0 -1
- package/src/decorators/validation/pattern.js +0 -16
- package/src/decorators/validation/pattern.js.map +0 -1
- package/src/decorators/validation/types/index.js +0 -6
- package/src/decorators/validation/types/index.js.map +0 -1
- package/src/decorators/validation/types/validation-definition.js +0 -3
- package/src/decorators/validation/types/validation-definition.js.map +0 -1
- package/src/decorators/validation/types/validation-type.js +0 -3
- package/src/decorators/validation/types/validation-type.js.map +0 -1
- package/src/decorators/validation/utils/index.js +0 -5
- package/src/decorators/validation/utils/index.js.map +0 -1
- package/src/decorators/validation/utils/register-constraint.js.map +0 -1
- package/src/errors/attributes-not-valid-error.js +0 -13
- package/src/errors/attributes-not-valid-error.js.map +0 -1
- package/src/errors/index.js +0 -7
- package/src/errors/index.js.map +0 -1
- package/src/errors/invalid-target-error.js +0 -11
- package/src/errors/invalid-target-error.js.map +0 -1
- package/src/errors/unsupported-decorator-error.js.map +0 -1
- package/src/index.js +0 -9
- package/src/index.js.map +0 -1
- package/src/types.js +0 -4
- package/src/types.js.map +0 -1
- package/src/validator/index.js +0 -5
- package/src/validator/index.js.map +0 -1
- package/src/validator/list-validation-errors.js.map +0 -1
- package/src/validator/validate.js +0 -13
- package/src/validator/validate.js.map +0 -1
- package/src/validator/validator.js +0 -10
- package/src/validator/validator.js.map +0 -1
- /package/{src/decorators/attribute/index.d.ts → dist/decorators/attribute/index.js} +0 -0
- /package/{src/decorators/attribute/types/attribute-type-alias.d.ts → dist/decorators/attribute/types/attribute-type-alias.js} +0 -0
- /package/{src/decorators/attribute/types/index.d.ts → dist/decorators/attribute/types/index.js} +0 -0
- /package/{src/decorators/attribute/utils/index.d.ts → dist/decorators/attribute/utils/index.js} +0 -0
- /package/{src/decorators/index.d.ts → dist/decorators/index.js} +0 -0
- /package/{src/decorators/validation/index.d.ts → dist/decorators/validation/index.js} +0 -0
- /package/{src/decorators/validation/types/index.d.ts → dist/decorators/validation/types/index.js} +0 -0
- /package/{src/decorators/validation/utils/index.d.ts → dist/decorators/validation/utils/index.js} +0 -0
- /package/{src/errors/index.d.ts → dist/errors/index.js} +0 -0
- /package/{src/index.d.ts → dist/index.js} +0 -0
- /package/{src/validator/index.d.ts → dist/validator/index.js} +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ITz Working (AWS Serverless, TypeScript)
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **ITz Working because you built it!**
|
|
4
4
|
|
|
5
|
-
Framework for building AWS Serverless applications with
|
|
5
|
+
Framework for building AWS Serverless applications with TypeScript.
|
|
6
6
|
|
|
7
7
|
- [Intro](#intro)
|
|
8
8
|
- [Key features](#key-features)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-class.d.ts","sourceRoot":"","sources":["../src/decorated-class.ts"],"names":[],"mappings":"AAoEA,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAEjD,8BAAsB,cAAc;IAClC,SAAS,aAAa,KAAK,GAAE,8BAAmC;CAkBjE"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DecoratedClass = void 0;
|
|
4
|
-
const decorators_1 = require("./decorators");
|
|
1
|
+
import { AttributeType, listAttributes, PrimitiveType } from "./decorators";
|
|
5
2
|
const parseBoolean = (value) => {
|
|
6
3
|
switch (value) {
|
|
7
4
|
case true:
|
|
@@ -23,27 +20,27 @@ const parseBoolean = (value) => {
|
|
|
23
20
|
}
|
|
24
21
|
};
|
|
25
22
|
const isPrimitiveType = (type) => {
|
|
26
|
-
return Object.values(
|
|
23
|
+
return Object.values(PrimitiveType).includes(type);
|
|
27
24
|
};
|
|
28
25
|
const parseType = (value, type, nestedType) => {
|
|
29
|
-
if (type ===
|
|
26
|
+
if (type === AttributeType.Float) {
|
|
30
27
|
return parseFloat(value);
|
|
31
28
|
}
|
|
32
|
-
if (type ===
|
|
29
|
+
if (type === AttributeType.Integer) {
|
|
33
30
|
return parseInt(value);
|
|
34
31
|
}
|
|
35
|
-
if (type ===
|
|
32
|
+
if (type === AttributeType.Boolean) {
|
|
36
33
|
return parseBoolean(value);
|
|
37
34
|
}
|
|
38
|
-
if (type ===
|
|
35
|
+
if (type === AttributeType.Date) {
|
|
39
36
|
return new Date(value);
|
|
40
37
|
}
|
|
41
|
-
if (type ===
|
|
38
|
+
if (type === AttributeType.Object &&
|
|
42
39
|
nestedType &&
|
|
43
40
|
nestedType.prototype instanceof DecoratedClass) {
|
|
44
41
|
return new nestedType(value);
|
|
45
42
|
}
|
|
46
|
-
if (type ===
|
|
43
|
+
if (type === AttributeType.List) {
|
|
47
44
|
if (!value || !Array.isArray(value)) {
|
|
48
45
|
return undefined;
|
|
49
46
|
}
|
|
@@ -52,18 +49,18 @@ const parseType = (value, type, nestedType) => {
|
|
|
52
49
|
return value.map((item) => parseType(item, nestedType));
|
|
53
50
|
}
|
|
54
51
|
else if (nestedType.prototype instanceof DecoratedClass) {
|
|
55
|
-
return value.map((item) => parseType(item,
|
|
52
|
+
return value.map((item) => parseType(item, AttributeType.Object, nestedType));
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
return value;
|
|
60
57
|
};
|
|
61
|
-
class DecoratedClass {
|
|
58
|
+
export class DecoratedClass {
|
|
62
59
|
constructor(props = {}) {
|
|
63
60
|
if (!props) {
|
|
64
61
|
return;
|
|
65
62
|
}
|
|
66
|
-
const attributes =
|
|
63
|
+
const attributes = listAttributes(this);
|
|
67
64
|
const self = this;
|
|
68
65
|
for (const attribute of attributes) {
|
|
69
66
|
const { attributeName: key, attributeType, nestedType } = attribute;
|
|
@@ -78,5 +75,3 @@ class DecoratedClass {
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
|
-
exports.DecoratedClass = DecoratedClass;
|
|
82
|
-
//# sourceMappingURL=decorated-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/attribute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,eAAO,MAAM,SAAS,kBACL,aAAa,YACnB;IAAE,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,CAAA;CAAE,yCAiC/D,CAAC"}
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
const types_1 = require("./types");
|
|
6
|
-
const Attribute = (attributeType, options = {}) => {
|
|
1
|
+
import { updateAttributes } from "./utils";
|
|
2
|
+
import { AttributeType } from "./types";
|
|
3
|
+
export const Attribute = (attributeType, options = {}) => {
|
|
7
4
|
let isValidType = () => true;
|
|
8
|
-
if (attributeType ===
|
|
5
|
+
if (attributeType === AttributeType.String) {
|
|
9
6
|
isValidType = (value) => value === undefined || value === null || typeof value === "string";
|
|
10
7
|
}
|
|
11
|
-
else if (attributeType ===
|
|
8
|
+
else if (attributeType === AttributeType.Integer) {
|
|
12
9
|
isValidType = (value) => value === undefined ||
|
|
13
10
|
value === null ||
|
|
14
11
|
(Number(value) === value && value % 1 === 0);
|
|
15
12
|
}
|
|
16
|
-
else if (attributeType ===
|
|
13
|
+
else if (attributeType === AttributeType.Float) {
|
|
17
14
|
isValidType = (value) => value === undefined || value === null || Number(value) === value;
|
|
18
15
|
}
|
|
19
|
-
else if (attributeType ===
|
|
16
|
+
else if (attributeType === AttributeType.Boolean) {
|
|
20
17
|
isValidType = (value) => value === undefined || value === null || typeof value === "boolean";
|
|
21
18
|
}
|
|
22
|
-
else if (attributeType ===
|
|
19
|
+
else if (attributeType === AttributeType.Date) {
|
|
23
20
|
isValidType = (value) => value === undefined || value === null || value instanceof Date;
|
|
24
21
|
}
|
|
25
|
-
else if (attributeType ===
|
|
22
|
+
else if (attributeType === AttributeType.List) {
|
|
26
23
|
isValidType = (value) => value === undefined || value === null || Array.isArray(value);
|
|
27
24
|
}
|
|
28
|
-
else if (attributeType ===
|
|
25
|
+
else if (attributeType === AttributeType.Object) {
|
|
29
26
|
isValidType = (value) => value === undefined || value === null || typeof value === "object";
|
|
30
27
|
}
|
|
31
|
-
return
|
|
28
|
+
return updateAttributes(attributeType, isValidType, options);
|
|
32
29
|
};
|
|
33
|
-
exports.Attribute = Attribute;
|
|
34
30
|
// export const OldAttribute = {
|
|
35
31
|
// List: (type: PrimitiveType | any) =>
|
|
36
32
|
// updateAttributes(
|
|
@@ -47,4 +43,3 @@ exports.Attribute = Attribute;
|
|
|
47
43
|
// type
|
|
48
44
|
// ),
|
|
49
45
|
// };
|
|
50
|
-
//# sourceMappingURL=attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-attribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/is-attribute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,WAAY,GAAG,eAAe,MAAM,YAE3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-attributes.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/list-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,mBAAmB,EAS/D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { symbol } from "./symbol";
|
|
2
|
+
export const listAttributes = (target) => {
|
|
3
|
+
let attributes = [];
|
|
4
|
+
let targetToUse = Object.getPrototypeOf(target);
|
|
5
|
+
while (targetToUse && targetToUse !== Object.prototype) {
|
|
6
|
+
const parentAttributes = Reflect.getOwnMetadata(symbol, targetToUse) || [];
|
|
7
|
+
attributes = [...parentAttributes, ...attributes];
|
|
8
|
+
targetToUse = Object.getPrototypeOf(targetToUse);
|
|
9
|
+
}
|
|
10
|
+
return attributes;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../../../src/decorators/attribute/symbol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,eAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const symbol = Symbol("itw_attribute");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-decorator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,GAAG,EACX,OAAO,EACH,MAAM,GACN,CAAC,CAAC,2BAA2B,GAAG,0BAA0B,CAAC,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,KACH,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-definition.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,CAAC;IAClD,mBAAmB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;CAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-type-alias.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-type-alias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/attribute-type.ts"],"names":[],"mappings":"AAEA,oBAAY,aAAa;IACvB,MAAM,WAAuB;IAC7B,KAAK,UAAsB;IAC3B,OAAO,YAAwB;IAC/B,OAAO,YAAwB;IAC/B,IAAI,SAAqB;IACzB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AttributeType = void 0;
|
|
4
|
-
var AttributeType;
|
|
1
|
+
import { PrimitiveType } from "./primitive-type";
|
|
2
|
+
export var AttributeType;
|
|
5
3
|
(function (AttributeType) {
|
|
6
4
|
AttributeType["String"] = "String";
|
|
7
5
|
AttributeType["Float"] = "Float";
|
|
@@ -10,5 +8,4 @@ var AttributeType;
|
|
|
10
8
|
AttributeType["Date"] = "Date";
|
|
11
9
|
AttributeType["List"] = "List";
|
|
12
10
|
AttributeType["Object"] = "Object";
|
|
13
|
-
})(AttributeType || (
|
|
14
|
-
//# sourceMappingURL=attribute-type.js.map
|
|
11
|
+
})(AttributeType || (AttributeType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/types/primitive-type.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var PrimitiveType;
|
|
2
|
+
(function (PrimitiveType) {
|
|
3
|
+
PrimitiveType["String"] = "String";
|
|
4
|
+
PrimitiveType["Integer"] = "Integer";
|
|
5
|
+
PrimitiveType["Float"] = "Float";
|
|
6
|
+
PrimitiveType["Boolean"] = "Boolean";
|
|
7
|
+
PrimitiveType["Date"] = "Date";
|
|
8
|
+
})(PrimitiveType || (PrimitiveType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -2,3 +2,4 @@ import "reflect-metadata";
|
|
|
2
2
|
import { AttributeDecorator, AttributeType, PrimitiveType } from "../types";
|
|
3
3
|
import { DecoratedClass } from "../../../decorated-class";
|
|
4
4
|
export declare const updateAttributes: (attributeType: AttributeType, isValidType: (value: any, nestedType?: PrimitiveType | DecoratedClass | any) => boolean, options?: any) => AttributeDecorator;
|
|
5
|
+
//# sourceMappingURL=update-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-attributes.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attribute/utils/update-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,eAAO,MAAM,gBAAgB,kBAEV,aAAa,eACf,CACX,KAAK,EAAE,GAAG,EACV,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,GAAG,KAC9C,OAAO,YACH,GAAG,KACX,kBAqCF,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const symbol_1 = require("../symbol");
|
|
6
|
-
const updateAttributes = (attributeType, isValidType, options = {}) => (target, context) => {
|
|
7
|
-
const attributes = Reflect.getOwnMetadata(symbol_1.symbol, target) || [];
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { symbol } from "../symbol";
|
|
3
|
+
export const updateAttributes = (attributeType, isValidType, options = {}) => (target, context) => {
|
|
4
|
+
const attributes = Reflect.getOwnMetadata(symbol, target) || [];
|
|
8
5
|
const attributeName = typeof context === "string" ? context : context.name;
|
|
9
6
|
let currentAttribute = attributes.find((attribute) => attribute.attributeName === attributeName);
|
|
10
7
|
const isValidTypeInTarget = (target) => isValidType(typeof target[attributeName] === "function"
|
|
@@ -16,7 +13,7 @@ const updateAttributes = (attributeType, isValidType, options = {}) => (target,
|
|
|
16
13
|
attributeType,
|
|
17
14
|
constraints: [],
|
|
18
15
|
// isMethod: typeof target[attributeName] === "function",
|
|
19
|
-
nestedType: options
|
|
16
|
+
nestedType: options?.nestedType,
|
|
20
17
|
isValidTypeInTarget,
|
|
21
18
|
};
|
|
22
19
|
attributes.push(currentAttribute);
|
|
@@ -24,11 +21,9 @@ const updateAttributes = (attributeType, isValidType, options = {}) => (target,
|
|
|
24
21
|
else {
|
|
25
22
|
currentAttribute.attributeType = attributeType;
|
|
26
23
|
// currentAttribute.isMethod = typeof target[attributeName] === "function";
|
|
27
|
-
currentAttribute.nestedType = options
|
|
24
|
+
currentAttribute.nestedType = options?.nestedType;
|
|
28
25
|
currentAttribute.isValidTypeInTarget = isValidTypeInTarget;
|
|
29
26
|
}
|
|
30
|
-
Reflect.defineMetadata(
|
|
31
|
-
Reflect.defineMetadata(
|
|
27
|
+
Reflect.defineMetadata(symbol, attributes, target);
|
|
28
|
+
Reflect.defineMetadata(symbol, currentAttribute, target, attributeName);
|
|
32
29
|
};
|
|
33
|
-
exports.updateAttributes = updateAttributes;
|
|
34
|
-
//# sourceMappingURL=update-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kCAAkC,CAAC;AACjD,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/max.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,oDAiBf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { registerConstraintWithProps } from "./utils";
|
|
2
|
+
import { UnsupportedDecoratorError } from "../../errors";
|
|
3
|
+
export const Max = registerConstraintWithProps("Max", (max) => (value) => {
|
|
4
|
+
if (value === null || value === undefined) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return value.length <= max;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "number") {
|
|
11
|
+
return value <= max;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.length <= max;
|
|
15
|
+
}
|
|
16
|
+
throw new UnsupportedDecoratorError();
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/min.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,oDAiBf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { registerConstraintWithProps } from "./utils";
|
|
2
|
+
import { UnsupportedDecoratorError } from "../../errors";
|
|
3
|
+
export const Min = registerConstraintWithProps("Min", (min) => (value) => {
|
|
4
|
+
if (value === null || value === undefined) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return value.length >= min;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "number") {
|
|
11
|
+
return value >= min;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.length >= min;
|
|
15
|
+
}
|
|
16
|
+
throw new UnsupportedDecoratorError();
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-blank.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/not-blank.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,iCAWpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerConstraintWithoutProps } from "./utils";
|
|
2
|
+
import { UnsupportedDecoratorError } from "../../errors";
|
|
3
|
+
export const NotBlank = registerConstraintWithoutProps("NotBlank", (value) => {
|
|
4
|
+
if (value === null || value === undefined) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof value !== "string") {
|
|
8
|
+
throw new UnsupportedDecoratorError();
|
|
9
|
+
}
|
|
10
|
+
return value.trim().length > 0;
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-null.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/not-null.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,iCAGnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../../src/decorators/validation/pattern.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,6DAYnB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerConstraintWithProps } from "./utils";
|
|
2
|
+
import { UnsupportedDecoratorError } from "../../errors";
|
|
3
|
+
export const Pattern = registerConstraintWithProps("Pattern", (pattern) => (value) => {
|
|
4
|
+
if (value === null || value === undefined) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof value !== "string") {
|
|
8
|
+
throw new UnsupportedDecoratorError();
|
|
9
|
+
}
|
|
10
|
+
const r = value.match(pattern);
|
|
11
|
+
return !!r && r.length > 0;
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-definition.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/validation-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,qBAAqB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;IAChD,iBAAiB,CAAC,EAAE,GAAG,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-type.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/types/validation-type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,KAAK,GACL,KAAK,GACL,SAAS,GACT,UAAU,GACV,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -60,3 +60,4 @@ export declare const registerConstraintWithProps: <T = void>(constraintId: strin
|
|
|
60
60
|
*/
|
|
61
61
|
export declare const registerConstraintWithoutProps: (constraintId: string, constraintValidator: ConstraintWithoutProps) => AttributeDecorator;
|
|
62
62
|
export declare const registerConstraint: (constraintId: string, constraintValidator: ConstraintWithoutProps) => AttributeDecorator;
|
|
63
|
+
//# sourceMappingURL=register-constraint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-constraint.d.ts","sourceRoot":"","sources":["../../../../src/decorators/validation/utils/register-constraint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,eAAe,EAAE,CAAC,KACf,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;AAE7D,MAAM,MAAM,sBAAsB,GAAG,CACnC,KAAK,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI,EAC7B,MAAM,EAAE,GAAG,KACR,OAAO,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,GAAI,CAAC,uBAC7B,MAAM,uBACC,mBAAmB,CAAC,CAAC,CAAC,KAC1C,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,kBAAkB,CAiDnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,8BAA8B,iBAC3B,MAAM,uBACC,sBAAsB,KAC1C,kBAEF,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBANf,MAAM,uBACC,sBAAsB,KAC1C,kBAI6D,CAAC"}
|