@steroidsjs/nest 3.0.3 → 3.2.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.
- package/infrastructure/adapters/QueryAdapterTypeORM.js +2 -2
- package/infrastructure/adapters/QueryAdapterTypeORM.js.map +1 -1
- package/infrastructure/applications/rest/RestApplication.js +1 -0
- package/infrastructure/applications/rest/RestApplication.js.map +1 -1
- package/infrastructure/base/ModelTableStorage.d.ts +4 -0
- package/infrastructure/base/ModelTableStorage.js +21 -0
- package/infrastructure/base/ModelTableStorage.js.map +1 -0
- package/infrastructure/commands/entity-generator/templates/TableTemplate.txt +2 -2
- package/infrastructure/decorators/fields/BaseField.d.ts +2 -2
- package/infrastructure/decorators/fields/BaseField.js +68 -80
- package/infrastructure/decorators/fields/BaseField.js.map +1 -1
- package/infrastructure/decorators/fields/BooleanField.js +1 -9
- package/infrastructure/decorators/fields/BooleanField.js.map +1 -1
- package/infrastructure/decorators/fields/ComputableField.js +1 -1
- package/infrastructure/decorators/fields/ComputableField.js.map +1 -1
- package/infrastructure/decorators/fields/CoordinateField.js +0 -8
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -1
- package/infrastructure/decorators/fields/CreateTimeField.js +1 -23
- package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DateField.js +0 -6
- package/infrastructure/decorators/fields/DateField.js.map +1 -1
- package/infrastructure/decorators/fields/DateTimeField.js +6 -16
- package/infrastructure/decorators/fields/DateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalField.js +0 -8
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalNumberField.js +3 -12
- package/infrastructure/decorators/fields/DecimalNumberField.js.map +1 -1
- package/infrastructure/decorators/fields/DeleteDateField.js +0 -5
- package/infrastructure/decorators/fields/DeleteDateField.js.map +1 -1
- package/infrastructure/decorators/fields/EmailField.js +0 -7
- package/infrastructure/decorators/fields/EmailField.js.map +1 -1
- package/infrastructure/decorators/fields/EnumField.js +2 -9
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/ExtendField.d.ts +1 -1
- package/infrastructure/decorators/fields/ExtendField.js +3 -2
- package/infrastructure/decorators/fields/ExtendField.js.map +1 -1
- package/infrastructure/decorators/fields/FileField.js +0 -6
- package/infrastructure/decorators/fields/FileField.js.map +1 -1
- package/infrastructure/decorators/fields/HtmlField.js +0 -5
- package/infrastructure/decorators/fields/HtmlField.js.map +1 -1
- package/infrastructure/decorators/fields/ImageField.js.map +1 -1
- package/infrastructure/decorators/fields/IntegerField.js +0 -7
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -1
- package/infrastructure/decorators/fields/JSONBField.d.ts +1 -2
- package/infrastructure/decorators/fields/JSONBField.js +0 -8
- package/infrastructure/decorators/fields/JSONBField.js.map +1 -1
- package/infrastructure/decorators/fields/PasswordField.js +0 -6
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
- package/infrastructure/decorators/fields/PhoneField.js +0 -8
- package/infrastructure/decorators/fields/PhoneField.js.map +1 -1
- package/infrastructure/decorators/fields/PrimaryKeyField.js +1 -2
- package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -1
- package/infrastructure/decorators/fields/RelationField.js +4 -51
- package/infrastructure/decorators/fields/RelationField.js.map +1 -1
- package/infrastructure/decorators/fields/RelationIdField.js +8 -16
- package/infrastructure/decorators/fields/RelationIdField.js.map +1 -1
- package/infrastructure/decorators/fields/StringField.js +0 -9
- package/infrastructure/decorators/fields/StringField.js.map +1 -1
- package/infrastructure/decorators/fields/TextField.js +0 -7
- package/infrastructure/decorators/fields/TextField.js.map +1 -1
- package/infrastructure/decorators/fields/TimeField.js +1 -8
- package/infrastructure/decorators/fields/TimeField.js.map +1 -1
- package/infrastructure/decorators/fields/UidField.d.ts +0 -1
- package/infrastructure/decorators/fields/UidField.js +2 -28
- package/infrastructure/decorators/fields/UidField.js.map +1 -1
- package/infrastructure/decorators/fields/UpdateTimeField.js +2 -26
- package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +57 -16
- package/infrastructure/decorators/fields/index.js +110 -54
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.d.ts +2 -0
- package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.js +65 -0
- package/infrastructure/decorators/typeorm/TypeOrmDecoratorFactory.js.map +1 -0
- package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.d.ts +6 -0
- package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.js +29 -0
- package/infrastructure/decorators/typeorm/TypeOrmTableFromModel.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.js +14 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmBooleanField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.js +13 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCoordinateField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.d.ts +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.js +22 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/TypeOrmCreateTimeBehaviour.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.js +17 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmCreateTimeField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.js +11 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDateTimeField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js +13 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js +13 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.d.ts +2 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.js +10 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmDeleteDateColumn/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEmailField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmEnumField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.js +11 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmFileField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.js +11 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmHtmlField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.js +11 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmImageField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmIntegerField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.js +13 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmJSONBField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPasswordField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.js +13 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPhoneField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.d.ts +2 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.js +7 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmPrimaryKeyField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.d.ts +4 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.js +30 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/TypeOrmRelationBehaviour.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.js +17 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.js +10 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmRelationIdField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.js +14 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmStringField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTextField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.js +12 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmTimeField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.d.ts +2 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.js +26 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/TypeOrmUidBehaviour.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.js +14 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUidField/index.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.d.ts +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.js +24 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.js.map +1 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.d.ts +3 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.js +17 -0
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/index.js.map +1 -0
- package/infrastructure/repositories/CrudRepository.d.ts +5 -0
- package/infrastructure/repositories/CrudRepository.js +13 -4
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/infrastructure/tests/app/tables/ArticleTable.js +2 -2
- package/infrastructure/tests/app/tables/ArticleTable.js.map +1 -1
- package/infrastructure/tests/app/tables/CommentTable.js +2 -2
- package/infrastructure/tests/app/tables/CommentTable.js.map +1 -1
- package/infrastructure/tests/app/tables/FileTable.js +2 -2
- package/infrastructure/tests/app/tables/FileTable.js.map +1 -1
- package/infrastructure/tests/app/tables/ImageTable.js +2 -2
- package/infrastructure/tests/app/tables/ImageTable.js.map +1 -1
- package/infrastructure/tests/app/tables/TagTable.js +2 -2
- package/infrastructure/tests/app/tables/TagTable.js.map +1 -1
- package/infrastructure/tests/app/tables/UserInfoTable.js +2 -2
- package/infrastructure/tests/app/tables/UserInfoTable.js.map +1 -1
- package/infrastructure/tests/app/tables/UserTable.js +2 -2
- package/infrastructure/tests/app/tables/UserTable.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/exceptions/ClassValidatorException.d.ts +5 -0
- package/usecases/exceptions/ClassValidatorException.js +10 -0
- package/usecases/exceptions/ClassValidatorException.js.map +1 -0
- package/usecases/helpers/DataMapper.js +2 -2
- package/usecases/helpers/DataMapper.js.map +1 -1
- package/usecases/helpers/ValidationHelper.d.ts +1 -0
- package/usecases/helpers/ValidationHelper.js +57 -6
- package/usecases/helpers/ValidationHelper.js.map +1 -1
- package/usecases/interfaces/ICrudRepository.d.ts +1 -0
- package/usecases/services/ReadService.d.ts +5 -0
- package/usecases/services/ReadService.js +7 -0
- package/usecases/services/ReadService.js.map +1 -1
- package/usecases/validators/Validator.d.ts +5 -5
- package/usecases/validators/Validator.js +16 -8
- package/usecases/validators/Validator.js.map +1 -1
- package/infrastructure/decorators/TableFromModel.d.ts +0 -9
- package/infrastructure/decorators/TableFromModel.js +0 -44
- package/infrastructure/decorators/TableFromModel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"DecimalField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAqF;AACrF,2CAAyD;AAU5C,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAE3C,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,SAAS,aAAa,CAClB,UAAkB,EAClB,gBAA6D,EAC7D,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACb;QACI,IAAI,EAAE,4BAAoB;QAC1B,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;SACpF;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC;AAED,SAAS,SAAS,CAAC,GAAY,EAAE,GAAW;IACxC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,GAA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AS,CAAC,OAAO,CAAC,GAAG,EAAE;YACtD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAtBD,oCAsBC"}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DecimalNumberField = exports.IsDecimalNumber = exports.isDecimalNumber = exports.IS_DECIMAL_NUMBER = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
|
-
const class_validator_2 = require("class-validator");
|
|
8
6
|
const BaseField_1 = require("./BaseField");
|
|
9
7
|
const Transform_1 = require("../Transform");
|
|
10
8
|
exports.IS_DECIMAL_NUMBER = 'isDecimalNumber';
|
|
@@ -13,18 +11,18 @@ function isDecimalNumber(value, options) {
|
|
|
13
11
|
if (typeof value !== 'number') {
|
|
14
12
|
return false;
|
|
15
13
|
}
|
|
16
|
-
return (0,
|
|
14
|
+
return (0, class_validator_1.isDecimal)(value.toString(), {
|
|
17
15
|
decimal_digits: '0,' + ((_a = options.scale) !== null && _a !== void 0 ? _a : ''),
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
18
|
exports.isDecimalNumber = isDecimalNumber;
|
|
21
19
|
function IsDecimalNumber(options, validationOptions) {
|
|
22
|
-
return (0,
|
|
20
|
+
return (0, class_validator_1.ValidateBy)({
|
|
23
21
|
name: exports.IS_DECIMAL_NUMBER,
|
|
24
22
|
constraints: [options],
|
|
25
23
|
validator: {
|
|
26
24
|
validate: (value, args) => isDecimalNumber(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
|
|
27
|
-
defaultMessage: (0,
|
|
25
|
+
defaultMessage: (0, class_validator_1.buildMessage)(eachPrefix => eachPrefix + '$property is not a valid decimal number.', validationOptions),
|
|
28
26
|
},
|
|
29
27
|
}, validationOptions);
|
|
30
28
|
}
|
|
@@ -36,13 +34,6 @@ function DecimalNumberField(options = {}) {
|
|
|
36
34
|
appType: 'decimal',
|
|
37
35
|
jsType: 'number',
|
|
38
36
|
}),
|
|
39
|
-
(0, typeorm_1.Column)({
|
|
40
|
-
type: 'decimal',
|
|
41
|
-
default: options.defaultValue,
|
|
42
|
-
nullable: options.nullable,
|
|
43
|
-
precision: options.precision || 10,
|
|
44
|
-
scale: options.scale || 2,
|
|
45
|
-
}),
|
|
46
37
|
(0, Transform_1.Transform)(({ value }) => value ? Number(value) : value, Transform_1.TRANSFORM_TYPE_FROM_DB),
|
|
47
38
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
48
39
|
IsDecimalNumber(options, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalNumberField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalNumberField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"DecimalNumberField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalNumberField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA6G;AAG7G,2CAAsC;AACtC,4CAA+D;AAElD,QAAA,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,SAAgB,eAAe,CAAC,KAAc,EAAE,OAA8B;;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAAE,OAAO,KAAK,CAAC;KAAE;IAEhD,OAAO,IAAA,2BAAS,EAAC,KAAK,CAAC,QAAQ,EAAE,EAAE;QAC/B,cAAc,EAAE,IAAI,GAAG,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAC;KAC/C,CAAC,CAAC;AACP,CAAC;AAND,0C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AAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;QACF,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAA,qBAAG,EAAC,OAAO,CAAC,GAAG,EAAE;YAChD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AArBD,gDAqBC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeleteDateField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const BaseField_1 = require("./BaseField");
|
|
7
6
|
const Transform_1 = require("../Transform");
|
|
8
7
|
const DateField_1 = require("./DateField");
|
|
@@ -13,10 +12,6 @@ function DeleteDateField(options = {}) {
|
|
|
13
12
|
appType: 'date',
|
|
14
13
|
jsType: 'string',
|
|
15
14
|
}),
|
|
16
|
-
(0, typeorm_1.DeleteDateColumn)({
|
|
17
|
-
type: 'date',
|
|
18
|
-
nullable: true,
|
|
19
|
-
}),
|
|
20
15
|
(0, Transform_1.Transform)(({ value }) => (0, DateField_1.normalizeDate)(value), Transform_1.TRANSFORM_TYPE_FROM_DB),
|
|
21
16
|
(0, Transform_1.Transform)(({ value }) => (0, DateField_1.normalizeDate)(value), Transform_1.TRANSFORM_TYPE_TO_DB),
|
|
22
17
|
].filter(Boolean));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteDateField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DeleteDateField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"DeleteDateField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DeleteDateField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAAyD;AACzD,4CAAqF;AACrF,2CAA0C;AAE1C,SAAgB,eAAe,CAAC,UAA6B,EAAE;IAC3D,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,iBAAiB;YAChC,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,IAAA,qBAAS,EAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,IAAA,yBAAa,EAAC,KAAK,CAAC,EAAE,kCAAsB,CAAC;QACpE,IAAA,qBAAS,EAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,IAAA,yBAAa,EAAC,KAAK,CAAC,EAAE,gCAAoB,CAAC;KACrE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAVD,0CAUC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmailField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const BaseField_1 = require("./BaseField");
|
|
8
7
|
function EmailField(options = {}) {
|
|
@@ -15,12 +14,6 @@ function EmailField(options = {}) {
|
|
|
15
14
|
appType: 'email',
|
|
16
15
|
jsType: 'string',
|
|
17
16
|
}),
|
|
18
|
-
(0, typeorm_1.Column)({
|
|
19
|
-
type: 'varchar',
|
|
20
|
-
default: options.defaultValue,
|
|
21
|
-
unique: options.unique,
|
|
22
|
-
nullable: options.nullable,
|
|
23
|
-
}),
|
|
24
17
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
25
18
|
(0, class_validator_1.IsEmail)({
|
|
26
19
|
allow_display_name: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EmailField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"EmailField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EmailField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAoD;AACpD,2CAAyD;AAMzD,SAAgB,UAAU,CAAC,UAA8B,EAAE;IACvD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC;KAC3B;IAED,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,YAAY;YAC3B,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;QACjG,IAAA,yBAAO,EAAC;YACJ,kBAAkB,EAAE,IAAI;SAC3B,EAAE;YACC,OAAO,EAAE,0BAA0B;SACtC,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAlBD,gCAkBC"}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
6
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
7
7
|
const BaseField_1 = require("./BaseField");
|
|
8
8
|
const BaseEnum_1 = require("../../../domain/base/BaseEnum");
|
|
9
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
10
9
|
function EnumField(options = {}) {
|
|
11
10
|
if (Array.isArray(options.enum)) {
|
|
12
11
|
options.enum = options.enum.reduce((obj, value) => {
|
|
@@ -28,19 +27,13 @@ function EnumField(options = {}) {
|
|
|
28
27
|
appType: 'enum',
|
|
29
28
|
jsType: 'string',
|
|
30
29
|
}),
|
|
31
|
-
(0, typeorm_1.Column)({
|
|
32
|
-
type: 'varchar',
|
|
33
|
-
default: options.defaultValue,
|
|
34
|
-
nullable: options.nullable,
|
|
35
|
-
array: options.isArray,
|
|
36
|
-
}),
|
|
37
30
|
(0, swagger_1.ApiProperty)({
|
|
38
31
|
enum: options.enum,
|
|
39
32
|
}),
|
|
40
33
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
41
34
|
(0, class_validator_1.IsEnum)(options.enum, {
|
|
42
35
|
each: options.isArray,
|
|
43
|
-
message: options.isEnumConstraintMessage || 'Выберите одно из значений'
|
|
36
|
+
message: options.isEnumConstraintMessage || 'Выберите одно из значений',
|
|
44
37
|
}),
|
|
45
38
|
].filter(Boolean));
|
|
46
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAmD;AACnD,6CAA4C;AAC5C,2CAAyD;AACzD,4DAAqD;AAOrD,SAAgB,SAAS,CAAC,UAA6B,EAAE;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC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ModelClass, modelFieldName);
|
|
19
19
|
const decorator = (0, BaseField_1.getFieldDecorator)(ModelClass, modelFieldName);
|
|
20
|
-
|
|
20
|
+
const decoratorOptions = Object.assign(Object.assign({}, extendOptions), options);
|
|
21
|
+
decorator(decoratorOptions)(object, propertyName);
|
|
21
22
|
if (options.extendValidators) {
|
|
22
23
|
// Extend validators
|
|
23
|
-
(0, Validator_1.
|
|
24
|
+
(0, Validator_1.getValidators)(ModelClass, modelFieldName).forEach(ValidatorClass => {
|
|
24
25
|
(0, Validator_1.Validator)(ValidatorClass)(object, propertyName);
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtendField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ExtendField.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAE/D,
|
|
1
|
+
{"version":3,"file":"ExtendField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ExtendField.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAE/D,sEAAgF;AAOhF,SAAgB,WAAW,CACvB,UAAU,EACV,UAAgD;IAC5C,gBAAgB,EAAE,IAAI;CACzB;IAED,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;QAC5B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC7B,OAAO,GAAG,EAAC,eAAe,EAAE,OAAO,EAAC,CAAC;SACxC;QAED,MAAM,cAAc,GAAG,OAAO,CAAC,eAAe,IAAI,YAAY,CAAC;QAC/D,IAAI,CAAC,cAAc,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,YAAY,GAAG,cAAc,GAAG,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;SAChG;QAED,oBAAoB;QACpB,MAAM,aAAa,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,IAAA,6BAAiB,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,gBAAgB,mCACf,aAAa,GACb,OAAO,CACb,CAAC;QAEF,SAAS,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAElD,IAAI,OAAO,CAAC,gBAAgB,EAAE;YAC1B,oBAAoB;YACpB,IAAA,yBAAa,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;gBAC/D,IAAA,qBAAS,EAAC,cAAc,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAC;AACN,CAAC;AAjCD,kCAiCC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileField = exports.getFileFieldDecorators = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const BaseField_1 = require("./BaseField");
|
|
8
7
|
function getFileFieldDecorators(options) {
|
|
@@ -12,11 +11,6 @@ function getFileFieldDecorators(options) {
|
|
|
12
11
|
appType: 'file',
|
|
13
12
|
jsType: 'number',
|
|
14
13
|
}),
|
|
15
|
-
(0, typeorm_1.Column)({
|
|
16
|
-
type: options.multiple ? 'simple-array' : 'integer',
|
|
17
|
-
default: options.defaultValue,
|
|
18
|
-
nullable: options.nullable,
|
|
19
|
-
}),
|
|
20
14
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value),
|
|
21
15
|
options.multiple
|
|
22
16
|
? (0, class_validator_1.IsArray)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/FileField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"FileField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/FileField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA2D;AAC3D,2CAAyD;AAOzD,SAAgB,sBAAsB,CAAC,OAAmB;IACtD,OAAO;QACH,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,WAAW;YAC1B,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;QACxD,OAAO,CAAC,QAAQ;YACZ,CAAC,CAAC,IAAA,yBAAO,EAAC;gBACN,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,4BAA4B;aAC/F,CAAC;YACF,CAAC,CAAC,IAAA,uBAAK,EAAC;gBACJ,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,2BAA2B;aAC9F,CAAC;KACT,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACtB,CAAC;AAhBD,wDAgBC;AAED,SAAgB,SAAS,CAAC,UAAsB,EAAE;IAC9C,OAAO,IAAA,wBAAe,EAClB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CACrC,CAAC;AACN,CAAC;AAJD,8BAIC"}
|
|
@@ -2,17 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HtmlField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const BaseField_1 = require("./BaseField");
|
|
7
6
|
function HtmlField(options = {}) {
|
|
8
7
|
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
9
8
|
decoratorName: 'HtmlField',
|
|
10
9
|
appType: 'html',
|
|
11
10
|
jsType: 'string',
|
|
12
|
-
}), (0, typeorm_1.Column)({
|
|
13
|
-
type: 'text',
|
|
14
|
-
default: options.defaultValue,
|
|
15
|
-
nullable: options.nullable,
|
|
16
11
|
}));
|
|
17
12
|
}
|
|
18
13
|
exports.HtmlField = HtmlField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/HtmlField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"HtmlField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/HtmlField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAAyD;AAEzD,SAAgB,SAAS,CAAC,UAA6B,EAAE;IACrD,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,WAAW;QAC1B,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,QAAQ;KACnB,CAAC,CACL,CAAC;AACN,CAAC;AARD,8BAQC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ImageField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,2CAAmD;AAOnD,SAAgB,UAAU,CAAC,UAAsB,EAAE;IAC/C,OAAO,IAAA,wBAAe,EAClB,GAAG,IAAA,kCAAsB,
|
|
1
|
+
{"version":3,"file":"ImageField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ImageField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,2CAAmD;AAOnD,SAAgB,UAAU,CAAC,UAAsB,EAAE;IAC/C,OAAO,IAAA,wBAAe,EAClB,GAAG,IAAA,kCAAsB,kCAClB,OAAO,KACV,OAAO,EAAE,IAAI,IACf,CACL,CAAC;AACN,CAAC;AAPD,gCAOC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IntegerField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
7
6
|
const class_validator_1 = require("class-validator");
|
|
8
7
|
const BaseField_1 = require("./BaseField");
|
|
9
8
|
const Transform_1 = require("../Transform");
|
|
@@ -16,12 +15,6 @@ function IntegerField(options = {}) {
|
|
|
16
15
|
appType: 'integer',
|
|
17
16
|
jsType: 'number',
|
|
18
17
|
}),
|
|
19
|
-
(0, typeorm_1.Column)({
|
|
20
|
-
type: 'integer',
|
|
21
|
-
default: options.defaultValue,
|
|
22
|
-
unique: options.unique,
|
|
23
|
-
nullable: options.nullable,
|
|
24
|
-
}),
|
|
25
18
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => options.isArray ? !isArrayEmpty(value) : !isEmpty(value)),
|
|
26
19
|
(0, Transform_1.Transform)(({ value }) => {
|
|
27
20
|
if (Array.isArray(value)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/IntegerField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"IntegerField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/IntegerField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAA+C;AAC/C,qDAA4D;AAC5D,2CAAyD;AACzD,4CAAuC;AASvC,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC;AAChE,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAA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AC,GAAG,EAAE,IAAI,OAAO,CAAC,uBAAuB;SACrF,CAAC;QACF,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAA,qBAAG,EAAC,OAAO,CAAC,GAAG,EAAE;YAChD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,yBAAyB,OAAO,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,uBAAuB;SACrF,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AA3BD,oCA2BC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
-
export
|
|
3
|
-
}
|
|
2
|
+
export type IJSONBFieldOptions = IBaseFieldOptions;
|
|
4
3
|
export declare function JSONBField(options?: IJSONBFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JSONBField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const BaseField_1 = require("./BaseField");
|
|
8
7
|
function JSONBField(options = {}) {
|
|
@@ -12,13 +11,6 @@ function JSONBField(options = {}) {
|
|
|
12
11
|
appType: 'object',
|
|
13
12
|
jsType: 'jsonb',
|
|
14
13
|
}),
|
|
15
|
-
(0, typeorm_1.Column)({
|
|
16
|
-
type: 'jsonb',
|
|
17
|
-
length: options.max,
|
|
18
|
-
default: options.defaultValue,
|
|
19
|
-
nullable: options.nullable,
|
|
20
|
-
array: options.isArray,
|
|
21
|
-
}),
|
|
22
14
|
!options.required && (0, class_validator_1.IsOptional)(),
|
|
23
15
|
].filter(Boolean));
|
|
24
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONBField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/JSONBField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"JSONBField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/JSONBField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA2C;AAC3C,2CAAyD;AAIzD,SAAgB,UAAU,CAAC,UAA8B,EAAE;IACvD,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,YAAY;YAC3B,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,OAAO;SAClB,CAAC;QACF,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,GAAE;KACpC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AATD,gCASC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PasswordField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const BaseField_1 = require("./BaseField");
|
|
7
6
|
function PasswordField(options = {}) {
|
|
8
7
|
if (!options.label) {
|
|
@@ -12,11 +11,6 @@ function PasswordField(options = {}) {
|
|
|
12
11
|
decoratorName: 'PasswordField',
|
|
13
12
|
appType: 'password',
|
|
14
13
|
jsType: 'string',
|
|
15
|
-
}), (0, typeorm_1.Column)({
|
|
16
|
-
type: 'text',
|
|
17
|
-
length: options.max,
|
|
18
|
-
default: options.defaultValue,
|
|
19
|
-
nullable: options.nullable,
|
|
20
14
|
}));
|
|
21
15
|
}
|
|
22
16
|
exports.PasswordField = PasswordField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PasswordField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"PasswordField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PasswordField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAAyD;AAEzD,SAAgB,aAAa,CAAC,UAA6B,EAAE;IACzD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;KAC5B;IAED,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,QAAQ;KACnB,CAAC,CACL,CAAC;AACN,CAAC;AAZD,sCAYC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PhoneField = exports.normalizePhone = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const BaseField_1 = require("./BaseField");
|
|
8
7
|
const Transform_1 = require("../Transform");
|
|
@@ -24,13 +23,6 @@ function PhoneField(options = {}) {
|
|
|
24
23
|
appType: 'phone',
|
|
25
24
|
jsType: 'string',
|
|
26
25
|
}),
|
|
27
|
-
(0, typeorm_1.Column)({
|
|
28
|
-
type: 'varchar',
|
|
29
|
-
length: options.max || 16,
|
|
30
|
-
default: options.defaultValue,
|
|
31
|
-
unique: options.unique,
|
|
32
|
-
nullable: options.nullable,
|
|
33
|
-
}),
|
|
34
26
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value),
|
|
35
27
|
(0, Transform_1.Transform)(({ value }) => (0, exports.normalizePhone)(value)),
|
|
36
28
|
(0, class_validator_1.IsPhoneNumber)(null, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PhoneField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"PhoneField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PhoneField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA0D;AAC1D,2CAAyD;AACzD,4CAAuC;AAOhC,MAAM,cAAc,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK;IACxC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SACV,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;SACnB,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;IACxB,CAAC,CAAC,KAAK,CAAC;AANC,QAAA,cAAc,kBAMf;AAEZ,SAAgB,UAAU,CAAC,UAA8B,EAAE;IACvD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;KAC7B;IAED,OAAO,IAAA,wBAAe,EAClB,GAAG;QACC,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,YAAY;YAC3B,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;QACxD,IAAA,qBAAS,EAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC;QAC7C,IAAA,+BAAa,EAAC,IAAI,EAAE;YAChB,OAAO,EAAE,OAAO,CAAC,iBAAiB,IAAI,6BAA6B;SACtE,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAnBD,gCAmBC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PrimaryKeyField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const BaseField_1 = require("./BaseField");
|
|
7
6
|
function PrimaryKeyField(options = {}) {
|
|
8
7
|
if (!options.label) {
|
|
@@ -12,7 +11,7 @@ function PrimaryKeyField(options = {}) {
|
|
|
12
11
|
decoratorName: 'PrimaryKeyField',
|
|
13
12
|
appType: 'primaryKey',
|
|
14
13
|
jsType: 'number',
|
|
15
|
-
})
|
|
14
|
+
}));
|
|
16
15
|
}
|
|
17
16
|
exports.PrimaryKeyField = PrimaryKeyField;
|
|
18
17
|
//# sourceMappingURL=PrimaryKeyField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimaryKeyField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PrimaryKeyField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"PrimaryKeyField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PrimaryKeyField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAAyD;AAEzD,SAAgB,eAAe,CAAC,UAA6B,EAAE;IAC3D,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;KACxB;IAED,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,iBAAiB;QAChC,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,QAAQ;KACnB,CAAC,CACL,CAAC;AACN,CAAC;AAZD,0CAYC"}
|
|
@@ -2,44 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RelationField = exports.relationTransform = exports.relationTransformToDb = exports.relationTransformFromDb = exports.getMetaRelationIdFieldKey = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
6
5
|
const class_validator_1 = require("class-validator");
|
|
7
6
|
const class_transformer_1 = require("class-transformer");
|
|
8
7
|
const BaseField_1 = require("./BaseField");
|
|
9
|
-
const TableFromModel_1 = require("../TableFromModel");
|
|
10
8
|
const Transform_1 = require("../Transform");
|
|
11
9
|
const DataMapper_1 = require("../../../usecases/helpers/DataMapper");
|
|
10
|
+
const ModelTableStorage_1 = require("../../base/ModelTableStorage");
|
|
12
11
|
const PROPERTY_TMP_ID_ENTITY = '__tmpIdEntity';
|
|
13
|
-
const getRelationDecorator = (relation) => {
|
|
14
|
-
switch (relation) {
|
|
15
|
-
case 'OneToOne':
|
|
16
|
-
return typeorm_1.OneToOne;
|
|
17
|
-
case 'ManyToMany':
|
|
18
|
-
return typeorm_1.ManyToMany;
|
|
19
|
-
case 'OneToMany':
|
|
20
|
-
return typeorm_1.OneToMany;
|
|
21
|
-
case 'ManyToOne':
|
|
22
|
-
return typeorm_1.ManyToOne;
|
|
23
|
-
default:
|
|
24
|
-
throw new Error('Wrong relation type: ' + relation);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
12
|
const getMetaRelationIdFieldKey = (relationClass, relationName) => {
|
|
28
|
-
return (0, BaseField_1.getMetaFields)(relationClass)
|
|
13
|
+
return (0, BaseField_1.getMetaFields)(relationClass)
|
|
14
|
+
.find(idName => {
|
|
29
15
|
const idOptions = (0, BaseField_1.getFieldOptions)(relationClass, idName);
|
|
30
16
|
return idOptions.appType === 'relationId' && idOptions.relationName === relationName;
|
|
31
17
|
});
|
|
32
18
|
};
|
|
33
19
|
exports.getMetaRelationIdFieldKey = getMetaRelationIdFieldKey;
|
|
34
|
-
const getOwningDecorator = (options) => {
|
|
35
|
-
if (options.type === 'ManyToMany' && options.isOwningSide) {
|
|
36
|
-
return typeorm_1.JoinTable;
|
|
37
|
-
}
|
|
38
|
-
if (options.type === 'OneToOne' && options.isOwningSide) {
|
|
39
|
-
return typeorm_1.JoinColumn;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
20
|
const transformInstances = (TargetClass, value, isArray, transformType) => {
|
|
44
21
|
if (isArray && Array.isArray(value)) {
|
|
45
22
|
return value.map(item => transformInstances(TargetClass, item, false, transformType));
|
|
@@ -63,26 +40,11 @@ const transformIds = (TableClass, value, isArray, transformType) => {
|
|
|
63
40
|
};
|
|
64
41
|
const relationTransformFromDb = ({ value, object, key, options, transformType }) => {
|
|
65
42
|
const ModelClass = options.relationClass();
|
|
66
|
-
// Удаляем объекты, необходимые только для сохранения id связей
|
|
67
|
-
if (value === null || value === void 0 ? void 0 : value[PROPERTY_TMP_ID_ENTITY]) {
|
|
68
|
-
delete object[key];
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
43
|
return transformInstances(ModelClass, value, options.isArray, transformType);
|
|
72
44
|
};
|
|
73
45
|
exports.relationTransformFromDb = relationTransformFromDb;
|
|
74
46
|
const relationTransformToDb = ({ value, item, key, options, transformType }) => {
|
|
75
|
-
const TableClass = (0,
|
|
76
|
-
const relationIdName = (0, BaseField_1.getMetaFields)(item.constructor).find(name => {
|
|
77
|
-
const relationOptions = (0, BaseField_1.getFieldOptions)(item.constructor, name);
|
|
78
|
-
return relationOptions.appType === 'relationId' && relationOptions.relationName === key;
|
|
79
|
-
});
|
|
80
|
-
if (relationIdName && item[relationIdName]) {
|
|
81
|
-
const result = transformIds(TableClass, item[relationIdName], options.isArray, transformType);
|
|
82
|
-
// Добавляем флаг к массиву или объекту, чтобы потом почистить такие временные объекты
|
|
83
|
-
result[PROPERTY_TMP_ID_ENTITY] = true;
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
47
|
+
const TableClass = (0, ModelTableStorage_1.getTableFromModel)(options.relationClass());
|
|
86
48
|
return transformInstances(TableClass, value, options.isArray, transformType);
|
|
87
49
|
};
|
|
88
50
|
exports.relationTransformToDb = relationTransformToDb;
|
|
@@ -92,16 +54,9 @@ const relationTransform = ({ value, options, transformType }) => {
|
|
|
92
54
|
};
|
|
93
55
|
exports.relationTransform = relationTransform;
|
|
94
56
|
function RelationField(options) {
|
|
95
|
-
const OwningDecorator = getOwningDecorator(options);
|
|
96
57
|
if (!options.transform) {
|
|
97
58
|
options.transform = exports.relationTransform;
|
|
98
59
|
}
|
|
99
|
-
let owningDecoratorOptions;
|
|
100
|
-
if ('tableName' in options) {
|
|
101
|
-
owningDecoratorOptions = {
|
|
102
|
-
name: options.tableName,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
60
|
return (0, common_1.applyDecorators)(...[
|
|
106
61
|
(0, BaseField_1.BaseField)(options, {
|
|
107
62
|
decoratorName: 'RelationField',
|
|
@@ -110,8 +65,6 @@ function RelationField(options) {
|
|
|
110
65
|
swaggerType: options.relationClass(),
|
|
111
66
|
isArray: ['ManyToMany', 'OneToMany'].includes(options.type),
|
|
112
67
|
}),
|
|
113
|
-
getRelationDecorator(options.type)(() => (0, TableFromModel_1.getTableFromModel)(options.relationClass()), options.inverseSide, { cascade: ['insert', 'update'], onUpdate: 'CASCADE' }),
|
|
114
|
-
OwningDecorator && OwningDecorator(owningDecoratorOptions),
|
|
115
68
|
//options.type === 'ManyToOne' && JoinColumn(),
|
|
116
69
|
(0, class_validator_1.ValidateIf)((object, value) => !!value),
|
|
117
70
|
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/RelationField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"RelationField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/RelationField.ts"],"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aAAa,CAAC,CAAC;AAC/E,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEF,SAAgB,aAAa,CAAC,OAA8B;IACxD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;QACpB,OAAO,CAAC,SAAS,GAAG,yBAAiB,CAAC;KACzC;IAED,OAAO,IAAA,wBAAe,EAClB,GAAG;QACC,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,eAAe;YAC9B,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,OAAO,CAAC,aAAa,EAAE;YACpC,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9D,CAAC;QACF,+CAA+C;QAC/C,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACtC,IAAA,gCAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;QAC5B,IAAA,wBAAI,EAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAA,qBAAS,EAAC,+BAAuB,EAAE,kCAAsB,CAAC;QAC1D,IAAA,qBAAS,EAAC,6BAAqB,EAAE,gCAAoB,CAAC;KACzD,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAtBD,sCAsBC"}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RelationIdField = exports.relationTransform = exports.relationTransformToDb = exports.relationTransformFromDb = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const BaseField_1 = require("./BaseField");
|
|
6
|
-
const TableFromModel_1 = require("../TableFromModel");
|
|
7
|
-
const Transform_1 = require("../Transform");
|
|
8
|
-
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
9
5
|
const class_validator_1 = require("class-validator");
|
|
10
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const BaseField_1 = require("./BaseField");
|
|
8
|
+
const Transform_1 = require("../Transform");
|
|
9
|
+
const ModelTableStorage_1 = require("../../base/ModelTableStorage");
|
|
11
10
|
// From db
|
|
12
11
|
const relationTransformFromDbInternal = (TableClass, value, isArray, transformType) => {
|
|
13
12
|
if (isArray && Array.isArray(value)) {
|
|
@@ -27,7 +26,7 @@ const relationTransformFromDb = ({ value, item, options, transformType }) => {
|
|
|
27
26
|
if (!relationOptions) {
|
|
28
27
|
return value;
|
|
29
28
|
}
|
|
30
|
-
const TableClass = (0,
|
|
29
|
+
const TableClass = (0, ModelTableStorage_1.getTableFromModel)(relationOptions.relationClass());
|
|
31
30
|
if (!TableClass) {
|
|
32
31
|
return value;
|
|
33
32
|
}
|
|
@@ -35,14 +34,11 @@ const relationTransformFromDb = ({ value, item, options, transformType }) => {
|
|
|
35
34
|
return relationTransformFromDbInternal(TableClass, relationValue, relationOptions.isArray, transformType);
|
|
36
35
|
};
|
|
37
36
|
exports.relationTransformFromDb = relationTransformFromDb;
|
|
38
|
-
const relationTransformToDb = ({ value }) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
37
|
+
const relationTransformToDb = ({ value }) =>
|
|
38
|
+
// Nothing do, see RelationField relationTransformToDb method for found *Ids logic
|
|
39
|
+
value;
|
|
42
40
|
exports.relationTransformToDb = relationTransformToDb;
|
|
43
|
-
const relationTransform = ({ value }) =>
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
41
|
+
const relationTransform = ({ value }) => value;
|
|
46
42
|
exports.relationTransform = relationTransform;
|
|
47
43
|
function RelationIdField(options = {}) {
|
|
48
44
|
if (!options.transform) {
|
|
@@ -58,10 +54,6 @@ function RelationIdField(options = {}) {
|
|
|
58
54
|
appType: 'relationId',
|
|
59
55
|
jsType: 'number',
|
|
60
56
|
}),
|
|
61
|
-
!options.isArray && (0, typeorm_1.Column)({
|
|
62
|
-
type: 'int',
|
|
63
|
-
nullable: options.nullable,
|
|
64
|
-
}),
|
|
65
57
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => !(0, lodash_1.isEmpty)(value)),
|
|
66
58
|
options.isArray && !options.nullable && (0, class_validator_1.ArrayNotEmpty)({ message: arrayNotEmptyMessage }),
|
|
67
59
|
(0, Transform_1.Transform)(exports.relationTransformFromDb, Transform_1.TRANSFORM_TYPE_FROM_DB),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationIdField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/RelationIdField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAA6F;AAC7F,
|
|
1
|
+
{"version":3,"file":"RelationIdField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/RelationIdField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA0D;AAC1D,mCAAoE;AACpE,2CAA6F;AAC7F,4CAAqF;AACrF,oEAA+D;AAO/D,UAAU;AACV,MAAM,+BAA+B,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE;IAClF,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACjC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,+BAA+B,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;KACrG;IACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,UAAU,GAAG,IAAA,6BAAiB,EAAC,UAAU,CAAC,CAAC;QACjD,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5B;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AACK,MAAM,uBAAuB,GAAG,CAAC,EAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAC,EAAE,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