@my-devkit/core 1.0.98 → 1.0.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate.d.ts +1 -1
- package/dist/aggregate.js +19 -24
- package/dist/aggregate.js.map +1 -1
- package/dist/command.d.ts +1 -1
- package/dist/command.js +8 -9
- package/dist/command.js.map +1 -1
- package/dist/date-helper.js +27 -33
- package/dist/date-helper.js.map +1 -1
- package/dist/decorators/cacheable.decorator.js +32 -95
- package/dist/decorators/cacheable.decorator.js.map +1 -1
- package/dist/decorators/index.js +5 -1
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/retryable.decorator.js +6 -45
- package/dist/decorators/retryable.decorator.js.map +1 -1
- package/dist/enum-helper.js +13 -31
- package/dist/enum-helper.js.map +1 -1
- package/dist/errors/bad-request-error.js +6 -24
- package/dist/errors/bad-request-error.js.map +1 -1
- package/dist/errors/domain-error.js +6 -24
- package/dist/errors/domain-error.js.map +1 -1
- package/dist/errors/forbidden-error.js +6 -24
- package/dist/errors/forbidden-error.js.map +1 -1
- package/dist/errors/index.js +5 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/not-found-error.js +6 -24
- package/dist/errors/not-found-error.js.map +1 -1
- package/dist/errors/not-implemented-error.js +6 -24
- package/dist/errors/not-implemented-error.js.map +1 -1
- package/dist/errors/unauthorized-error.js +6 -24
- package/dist/errors/unauthorized-error.js.map +1 -1
- package/dist/event.d.ts +7 -7
- package/dist/event.js +44 -53
- package/dist/event.js.map +1 -1
- package/dist/guid/index.js +1 -1
- package/dist/guid/index.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/json-helper.d.ts +1 -0
- package/dist/json-helper.js +18 -12
- package/dist/json-helper.js.map +1 -1
- package/dist/logger.js +35 -57
- package/dist/logger.js.map +1 -1
- package/dist/maintenance-model.js +16 -34
- package/dist/maintenance-model.js.map +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/model.js +11 -16
- package/dist/model.js.map +1 -1
- package/dist/passwords.js +1 -1
- package/dist/passwords.js.map +1 -1
- package/dist/promise-helper.js +25 -67
- package/dist/promise-helper.js.map +1 -1
- package/dist/release-model.js +16 -34
- package/dist/release-model.js.map +1 -1
- package/dist/retry.js +24 -76
- package/dist/retry.js.map +1 -1
- package/dist/sanity-check-warm-up-dto.js +11 -12
- package/dist/sanity-check-warm-up-dto.js.map +1 -1
- package/dist/serialize/deserialize.js +2 -2
- package/dist/serialize/deserialize.js.map +1 -1
- package/dist/serialize/index.d.ts +2 -1
- package/dist/serialize/index.js +7 -2
- package/dist/serialize/index.js.map +1 -1
- package/dist/serialize/serializable.d.ts +1 -1
- package/dist/serialize/serializable.js +5 -5
- package/dist/serialize/serializable.js.map +1 -1
- package/dist/serialize/serialize-helper.d.ts +5 -0
- package/dist/serialize/serialize-helper.js +38 -0
- package/dist/serialize/serialize-helper.js.map +1 -0
- package/dist/serialize/serialize.js +1 -1
- package/dist/serialize/serialize.js.map +1 -1
- package/dist/serialize/type-helper.js +62 -73
- package/dist/serialize/type-helper.js.map +1 -1
- package/dist/sleep.js +5 -34
- package/dist/sleep.js.map +1 -1
- package/dist/validators/custom-validators/camel-case.js +2 -2
- package/dist/validators/custom-validators/camel-case.js.map +1 -1
- package/dist/validators/custom-validators/equals-to.js +5 -5
- package/dist/validators/custom-validators/equals-to.js.map +1 -1
- package/dist/validators/custom-validators/greater-or-equal-than.js +5 -5
- package/dist/validators/custom-validators/greater-or-equal-than.js.map +1 -1
- package/dist/validators/custom-validators/greater-than-date.js +6 -6
- package/dist/validators/custom-validators/greater-than-date.js.map +1 -1
- package/dist/validators/custom-validators/index.js +5 -1
- package/dist/validators/custom-validators/index.js.map +1 -1
- package/dist/validators/custom-validators/is-empty-if.js +6 -6
- package/dist/validators/custom-validators/is-empty-if.js.map +1 -1
- package/dist/validators/custom-validators/is-not-empty-if.js +5 -5
- package/dist/validators/custom-validators/is-not-empty-if.js.map +1 -1
- package/dist/validators/custom-validators/is-not-in-relative-to.js +5 -6
- package/dist/validators/custom-validators/is-not-in-relative-to.js.map +1 -1
- package/dist/validators/custom-validators/is-optional-if.d.ts +4 -1
- package/dist/validators/custom-validators/is-optional-if.js +9 -17
- package/dist/validators/custom-validators/is-optional-if.js.map +1 -1
- package/dist/validators/custom-validators/pascal-case.js +2 -2
- package/dist/validators/custom-validators/pascal-case.js.map +1 -1
- package/dist/validators/index.js +5 -1
- package/dist/validators/index.js.map +1 -1
- package/dist/validators/validate.d.ts +2 -1
- package/dist/validators/validate.js +28 -41
- package/dist/validators/validate.js.map +1 -1
- package/dist/validators/validation-error.js +5 -6
- package/dist/validators/validation-error.js.map +1 -1
- package/dist/vendors/index.js +5 -1
- package/dist/vendors/index.js.map +1 -1
- package/dist/vendors/lodash.d.ts +1 -1
- package/dist/vendors/lodash.js +2 -1
- package/dist/vendors/lodash.js.map +1 -1
- package/package.json +11 -11
- package/src/aggregate.ts +1 -1
- package/src/command.ts +1 -1
- package/src/event.ts +8 -8
- package/src/json-helper.ts +9 -0
- package/src/model.ts +1 -1
- package/src/serialize/index.ts +2 -1
- package/src/serialize/serializable.ts +1 -1
- package/src/serialize/serialize-helper.ts +43 -0
- package/src/validators/custom-validators/is-not-in-relative-to.ts +3 -5
- package/src/validators/custom-validators/is-optional-if.ts +9 -18
- package/src/validators/validate.ts +38 -35
- package/src/vendors/lodash.ts +1 -0
- package/tsconfig.json +7 -10
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ValidationError as ClassValidatorValidationError,
|
|
2
|
-
import { ValidationMetadata } from 'class-validator/metadata/ValidationMetadata';
|
|
1
|
+
import { ValidationError as ClassValidatorValidationError, validateSync } from 'class-validator';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { Command } from '../command';
|
|
5
4
|
import { ValidationError } from './validation-error';
|
|
6
5
|
|
|
7
|
-
export function validate(data:
|
|
6
|
+
export function validate(data: Command): ValidationError[] {
|
|
8
7
|
const errors = validateSync(data);
|
|
9
8
|
return recursiveGetErrors(errors);
|
|
10
9
|
}
|
|
@@ -90,45 +89,49 @@ const validationPriorities = [
|
|
|
90
89
|
'pascalCase'
|
|
91
90
|
];
|
|
92
91
|
|
|
93
|
-
function getMetadatas(validationError: ClassValidatorValidationError, constraintName: string): ValidationMetadata {
|
|
94
|
-
const metadatas = getFromContainer(MetadataStorage);
|
|
95
|
-
const validationMetadatas: ValidationMetadata[] = (metadatas as any).validationMetadatas;
|
|
96
|
-
const filteredMetadatas = validationMetadatas
|
|
97
|
-
.filter(vmd => vmd.target === validationError.target.constructor
|
|
98
|
-
&& vmd.propertyName === validationError.property
|
|
99
|
-
&& (vmd.type === constraintName || (vmd.type === 'customValidation' && vmd.constraints[0] && vmd.constraints[0].name === constraintName)));
|
|
100
|
-
return filteredMetadatas[0];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
92
|
function recursiveGetErrors(validationErrors: ClassValidatorValidationError[], errors: ValidationError[] = [],
|
|
104
93
|
propertyName = '', previousValueWasArray = false): ValidationError[] {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
94
|
+
for (const validationError of validationErrors) {
|
|
95
|
+
if (!validationError) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (validationError.constraints) {
|
|
100
|
+
const containsNestedValidation = Object.keys(validationError.constraints).some(v => v === 'nestedValidation') && validationError.children.length > 0;
|
|
101
|
+
const validations = Object.keys(validationError.constraints);
|
|
102
|
+
|
|
103
|
+
const constraintName = validationPriorities.find(cm => validations.some(cs => cs.split('-')[0] === cm));
|
|
104
|
+
|
|
105
|
+
let domainErrorCode: string;
|
|
106
|
+
let i = 0;
|
|
107
|
+
while (!domainErrorCode) {
|
|
108
|
+
domainErrorCode = validations.find(vp => vp.split('-')[0] === validationPriorities[i]);
|
|
109
|
+
i++;
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
if (validationError.contexts && validationError.contexts[domainErrorCode] && validationError.contexts[domainErrorCode].domainErrorCodes) {
|
|
113
|
+
domainErrorCode = validationError.contexts[domainErrorCode].domainErrorCodes;
|
|
114
|
+
}
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
} else {
|
|
121
|
-
actualPropertyName = actualPropertyName ? `${actualPropertyName}.${validationError.property}` : validationError.property;
|
|
116
|
+
const domainErrorProperty = propertyName ? (containsNestedValidation ? propertyName : `${propertyName}.${validationError.property}`) : validationError.property;
|
|
122
117
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
errors.push(new ValidationError(domainErrorProperty, validationError.value, constraintName, null));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (validationError.children && validationError.children.length) {
|
|
122
|
+
let childName = validationError.property;
|
|
123
|
+
if (propertyName) {
|
|
124
|
+
childName = previousValueWasArray ? `${propertyName}[${validationError.property}]` : `${propertyName}.${validationError.property}`;
|
|
129
125
|
}
|
|
130
126
|
|
|
127
|
+
errors = recursiveGetErrors(
|
|
128
|
+
validationError.children.filter(ve => ve.constraints ? !Object.keys(ve.constraints).includes('nestedValidation') || ve.children.length === 0 : true),
|
|
129
|
+
errors,
|
|
130
|
+
childName,
|
|
131
|
+
Array.isArray(validationError.value)
|
|
132
|
+
);
|
|
131
133
|
}
|
|
132
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
133
136
|
return errors;
|
|
134
137
|
}
|
package/src/vendors/lodash.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"compileOnSave": false,
|
|
3
2
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
],
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"moduleResolution": "node",
|
|
5
|
+
"target": "es6",
|
|
6
|
+
"esModuleInterop": true,
|
|
9
7
|
"outDir": "./dist",
|
|
10
|
-
"
|
|
8
|
+
"rootDir": "./src",
|
|
11
9
|
"sourceMap": true,
|
|
12
10
|
"declaration": true,
|
|
13
|
-
"moduleResolution": "node",
|
|
14
11
|
"emitDecoratorMetadata": true,
|
|
15
12
|
"experimentalDecorators": true,
|
|
16
|
-
"
|
|
17
|
-
|
|
13
|
+
"lib": [
|
|
14
|
+
"ES2021"
|
|
18
15
|
]
|
|
19
16
|
}
|
|
20
17
|
}
|