@my-devkit/core 1.0.122 → 1.0.124
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/.eslintrc.js +3 -3
- package/dist/date-helper.js +6 -12
- package/dist/date-helper.js.map +1 -1
- package/dist/decorators/cacheable.decorator.js +2 -2
- package/dist/decorators/cacheable.decorator.js.map +1 -1
- package/dist/enum-helper.js +1 -1
- package/dist/enum-helper.js.map +1 -1
- package/dist/event.js +1 -2
- package/dist/event.js.map +1 -1
- package/dist/json-helper.js.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/promise-helper.js +3 -3
- package/dist/promise-helper.js.map +1 -1
- package/dist/serialize/index.js.map +1 -1
- package/dist/serialize/serializable.js.map +1 -1
- package/dist/serialize/serialize-helper.js +3 -3
- package/dist/serialize/serialize-helper.js.map +1 -1
- package/dist/serialize/type-helper.js +11 -25
- package/dist/serialize/type-helper.js.map +1 -1
- package/dist/sleep.js +1 -1
- package/dist/sleep.js.map +1 -1
- package/dist/validators/custom-validators/camel-case.js +2 -2
- package/dist/validators/custom-validators/equals-to.js +2 -2
- package/dist/validators/custom-validators/greater-or-equal-than.js +2 -2
- package/dist/validators/custom-validators/greater-than-date.js +2 -2
- package/dist/validators/custom-validators/greater-than-date.js.map +1 -1
- package/dist/validators/custom-validators/is-empty-if.js +4 -7
- package/dist/validators/custom-validators/is-empty-if.js.map +1 -1
- package/dist/validators/custom-validators/is-not-empty-if.js +2 -2
- package/dist/validators/custom-validators/is-not-empty-if.js.map +1 -1
- package/dist/validators/custom-validators/is-not-in-relative-to.js +4 -6
- package/dist/validators/custom-validators/is-not-in-relative-to.js.map +1 -1
- 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/index.d.ts +1 -1
- package/dist/validators/validate.js +5 -9
- package/dist/validators/validate.js.map +1 -1
- package/dist/vendors/lodash.d.ts +1 -1
- package/package.json +2 -2
- package/src/date-helper.ts +17 -29
- package/src/decorators/cacheable.decorator.ts +8 -23
- package/src/enum-helper.ts +2 -2
- package/src/event.ts +1 -2
- package/src/json-helper.ts +1 -3
- package/src/logger.ts +3 -7
- package/src/model.ts +1 -1
- package/src/promise-helper.ts +3 -3
- package/src/retry.ts +1 -1
- package/src/serialize/index.ts +1 -7
- package/src/serialize/serializable.ts +1 -3
- package/src/serialize/serialize-helper.ts +6 -11
- package/src/serialize/type-helper.ts +13 -39
- package/src/sleep.ts +1 -1
- package/src/validators/custom-validators/camel-case.ts +2 -2
- package/src/validators/custom-validators/equals-to.ts +2 -2
- package/src/validators/custom-validators/greater-or-equal-than.ts +2 -2
- package/src/validators/custom-validators/greater-than-date.ts +3 -7
- package/src/validators/custom-validators/is-empty-if.ts +5 -13
- package/src/validators/custom-validators/is-not-empty-if.ts +3 -6
- package/src/validators/custom-validators/is-not-in-relative-to.ts +6 -16
- package/src/validators/custom-validators/is-optional-if.ts +1 -4
- package/src/validators/custom-validators/pascal-case.ts +2 -2
- package/src/validators/index.ts +1 -1
- package/src/validators/validate.ts +9 -24
- package/src/validators/validation-error.ts +1 -1
- package/src/vendors/lodash.ts +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ArrayContains, ArrayMaxSize, ArrayMinSize, ArrayNotContains, ArrayNotEmpty, ArrayUnique, Contains, Equals, IsAlpha, IsAlphanumeric, IsArray, IsAscii, IsBase64, IsBoolean, IsBooleanString, IsByteLength, IsCreditCard, IsCurrency, IsDate, IsDefined, IsDivisibleBy, IsEmail, IsEmpty, IsEnum, IsFQDN, IsFullWidth, IsHalfWidth, IsHexColor, IsHexadecimal, IsIP, IsISBN, IsISIN, IsISO8601, IsIn, IsInt, IsJSON, IsLowercase, IsMilitaryTime, IsMobilePhone, IsMongoId, IsMultibyte, IsNegative, IsNotEmpty, IsNotIn, IsNumber, IsNumberString, IsOptional, IsPositive, IsString, IsSurrogatePair, IsUUID, IsUppercase, IsUrl, IsVariableWidth, Length, Matches, Max, MaxDate, MaxLength, Min, MinDate, MinLength, NotContains, NotEquals, ValidateNested } from 'class-validator';
|
|
1
|
+
export { ArrayContains, ArrayMaxSize, ArrayMinSize, ArrayNotContains, ArrayNotEmpty, ArrayUnique, Contains, Equals, IsAlpha, IsAlphanumeric, IsArray, IsAscii, IsBase64, IsBoolean, IsBooleanString, IsByteLength, IsCreditCard, IsCurrency, IsDate, IsDefined, IsDivisibleBy, IsEmail, IsEmpty, IsEnum, IsFQDN, IsFullWidth, IsHalfWidth, IsHexColor, IsHexadecimal, IsIP, IsISBN, IsISIN, IsISO8601, IsIn, IsInt, IsJSON, IsLowercase, IsMilitaryTime, IsMobilePhone, IsMongoId, IsMultibyte, IsNegative, IsNotEmpty, IsNotIn, IsNumber, IsNumberString, IsOptional, IsPositive, IsString, IsSurrogatePair, IsUUID, IsUppercase, IsUrl, IsVariableWidth, Length, Matches, Max, MaxDate, MaxLength, Min, MinDate, MinLength, NotContains, NotEquals, ValidateNested, } from 'class-validator';
|
|
2
2
|
export * from './custom-validators';
|
|
3
3
|
export { validate } from './validate';
|
|
@@ -85,7 +85,7 @@ const validationPriorities = [
|
|
|
85
85
|
'greaterThanDate',
|
|
86
86
|
'isNotInRelativeTo',
|
|
87
87
|
'isOptionalIf',
|
|
88
|
-
'pascalCase'
|
|
88
|
+
'pascalCase',
|
|
89
89
|
];
|
|
90
90
|
function recursiveGetErrors(validationErrors, errors = [], propertyName = '', previousValueWasArray = false) {
|
|
91
91
|
for (const validationError of validationErrors) {
|
|
@@ -93,14 +93,13 @@ function recursiveGetErrors(validationErrors, errors = [], propertyName = '', pr
|
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
95
|
if (validationError.constraints) {
|
|
96
|
-
const containsNestedValidation = Object.keys(validationError.constraints).some(v => v === 'nestedValidation') &&
|
|
97
|
-
validationError.children.length > 0;
|
|
96
|
+
const containsNestedValidation = Object.keys(validationError.constraints).some((v) => v === 'nestedValidation') && validationError.children.length > 0;
|
|
98
97
|
const validations = Object.keys(validationError.constraints);
|
|
99
|
-
const constraintName = validationPriorities.find(cm => validations.some(cs => cs.split('-')[0] === cm));
|
|
98
|
+
const constraintName = validationPriorities.find((cm) => validations.some((cs) => cs.split('-')[0] === cm));
|
|
100
99
|
let domainErrorCode;
|
|
101
100
|
let i = 0;
|
|
102
101
|
while (!domainErrorCode) {
|
|
103
|
-
domainErrorCode = validations.find(vp => vp.split('-')[0] === validationPriorities[i]);
|
|
102
|
+
domainErrorCode = validations.find((vp) => vp.split('-')[0] === validationPriorities[i]);
|
|
104
103
|
i++;
|
|
105
104
|
}
|
|
106
105
|
if (validationError.contexts &&
|
|
@@ -122,10 +121,7 @@ function recursiveGetErrors(validationErrors, errors = [], propertyName = '', pr
|
|
|
122
121
|
? `${propertyName}[${validationError.property}]`
|
|
123
122
|
: `${propertyName}.${validationError.property}`;
|
|
124
123
|
}
|
|
125
|
-
errors = recursiveGetErrors(validationError.children.filter(ve => ve.constraints
|
|
126
|
-
? !Object.keys(ve.constraints).includes('nestedValidation') ||
|
|
127
|
-
ve.children.length === 0
|
|
128
|
-
: true), errors, childName, Array.isArray(validationError.value));
|
|
124
|
+
errors = recursiveGetErrors(validationError.children.filter((ve) => ve.constraints ? !Object.keys(ve.constraints).includes('nestedValidation') || ve.children.length === 0 : true), errors, childName, Array.isArray(validationError.value));
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validators/validate.ts"],"names":[],"mappings":";;AAKA,4BAGC;AARD,qDAAiG;AAGjG,yDAAqD;AAErD,SAAgB,QAAQ,CAAC,IAAa;IAClC,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,IAAI,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,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C;YAC9B,MAAM,wBAAwB,GAC1B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validators/validate.ts"],"names":[],"mappings":";;AAKA,4BAGC;AARD,qDAAiG;AAGjG,yDAAqD;AAErD,SAAgB,QAAQ,CAAC,IAAa;IAClC,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,IAAI,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,oBAAoB,GAAG;IACzB,4BAA4B;IAC5B,WAAW;IACX,QAAQ;IACR,WAAW;IACX,SAAS;IACT,YAAY;IACZ,MAAM;IACN,SAAS;IACT,0BAA0B;IAC1B,SAAS;IACT,WAAW;IACX,QAAQ;IACR,UAAU;IACV,UAAU;IACV,OAAO;IACP,QAAQ;IACR,4BAA4B;IAC5B,eAAe;IACf,YAAY;IACZ,YAAY;IACZ,KAAK;IACL,KAAK;IACL,0BAA0B;IAC1B,SAAS;IACT,SAAS;IACT,iCAAiC;IACjC,iBAAiB;IACjB,gBAAgB;IAChB,4BAA4B;IAC5B,UAAU;IACV,aAAa;IACb,SAAS;IACT,gBAAgB;IAChB,SAAS;IACT,UAAU;IACV,cAAc;IACd,cAAc;IACd,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,YAAY;IACZ,eAAe;IACf,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,aAAa;IACb,eAAe;IACf,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,OAAO;IACP,QAAQ;IACR,aAAa;IACb,QAAQ;IACR,WAAW;IACX,WAAW;IACX,SAAS;IACT,gBAAgB;IA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CAChH,EACD,MAAM,EACN,SAAS,EACT,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CACvC,CAAC;QACN,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/vendors/lodash.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { chunk as _chunk, cloneDeep as _cloneDeep, compact as _compact, deburr as _deburr, findLastIndex as _findLastIndex, first as _first, flatten as _flatten, flattenDeep as _flattenDeep, get as _get, groupBy as _groupBy, isArray as _isArray, isBoolean as _isBoolean, isDate as _isDate, isEqual as _isEqual, isNil as _isNil, isObjectLike as _isObjectLike, isString as _isString, kebabCase as _kebabCase, keys as _keys, last as _last, lowerFirst as _lowerFirst, max as _max, maxBy as _maxBy, minBy as _minBy, orderBy as _orderBy, padStart as _padStart, random as _random, round as _round, set as _set, shuffle as _shuffle, sortBy as _sortBy, sum as _sum, sumBy as _sumBy, trim as _trim, trimEnd as _trimEnd, trimStart as _trimStart, uniq as _uniq, uniqBy as _uniqBy, upperFirst as _upperFirst, values as _values, words as _words } from 'lodash';
|
|
1
|
+
export { chunk as _chunk, cloneDeep as _cloneDeep, compact as _compact, deburr as _deburr, findLastIndex as _findLastIndex, first as _first, flatten as _flatten, flattenDeep as _flattenDeep, get as _get, groupBy as _groupBy, isArray as _isArray, isBoolean as _isBoolean, isDate as _isDate, isEqual as _isEqual, isNil as _isNil, isObjectLike as _isObjectLike, isString as _isString, kebabCase as _kebabCase, keys as _keys, last as _last, lowerFirst as _lowerFirst, max as _max, maxBy as _maxBy, minBy as _minBy, orderBy as _orderBy, padStart as _padStart, random as _random, round as _round, set as _set, shuffle as _shuffle, sortBy as _sortBy, sum as _sum, sumBy as _sumBy, trim as _trim, trimEnd as _trimEnd, trimStart as _trimStart, uniq as _uniq, uniqBy as _uniqBy, upperFirst as _upperFirst, values as _values, words as _words, } from 'lodash';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@my-devkit/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.124",
|
|
4
4
|
"description": "My Devkit: common tools",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"uuid": "13.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@my-devkit/cli": "2.1.
|
|
26
|
+
"@my-devkit/cli": "2.1.9",
|
|
27
27
|
"@types/lodash": "4.17.20",
|
|
28
28
|
"@types/node": "22.18.6",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "8.46.2",
|
package/src/date-helper.ts
CHANGED
|
@@ -10,7 +10,7 @@ export class DateHelper {
|
|
|
10
10
|
now.getUTCHours(),
|
|
11
11
|
now.getUTCMinutes(),
|
|
12
12
|
now.getUTCSeconds(),
|
|
13
|
-
now.getUTCMilliseconds()
|
|
13
|
+
now.getUTCMilliseconds(),
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -22,11 +22,7 @@ export class DateHelper {
|
|
|
22
22
|
return this.getElapsedTime(startDate, endDate) / 1000 / 60 / 60 / 24;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
public static getReadableElapsedTime(
|
|
26
|
-
startDate: Date,
|
|
27
|
-
endDate = new Date(),
|
|
28
|
-
short = false
|
|
29
|
-
): string {
|
|
25
|
+
public static getReadableElapsedTime(startDate: Date, endDate = new Date(), short = false): string {
|
|
30
26
|
const elapsedTime = this.getElapsedTime(startDate, endDate);
|
|
31
27
|
return this.getReadableDuration(elapsedTime, short);
|
|
32
28
|
}
|
|
@@ -44,15 +40,11 @@ export class DateHelper {
|
|
|
44
40
|
const daysUnit = days > 1 ? 'days' : 'day';
|
|
45
41
|
|
|
46
42
|
if (days) {
|
|
47
|
-
return short
|
|
48
|
-
? `${days} ${daysUnit}`
|
|
49
|
-
: `${days} ${daysUnit} ${hours} h ${minutes} min ${seconds} sec ${miliseconds} ms`;
|
|
43
|
+
return short ? `${days} ${daysUnit}` : `${days} ${daysUnit} ${hours} h ${minutes} min ${seconds} sec ${miliseconds} ms`;
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
if (hours) {
|
|
53
|
-
return short
|
|
54
|
-
? `${hours} h`
|
|
55
|
-
: `${hours} h ${minutes} min ${seconds} sec ${miliseconds} ms`;
|
|
47
|
+
return short ? `${hours} h` : `${hours} h ${minutes} min ${seconds} sec ${miliseconds} ms`;
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
if (minutes) {
|
|
@@ -100,7 +92,7 @@ export class DateHelper {
|
|
|
100
92
|
public static getAverage(...dates: Date[]): Date {
|
|
101
93
|
if (dates.length === 0) return null;
|
|
102
94
|
|
|
103
|
-
const averageTime = _sumBy(dates, d => d.getTime()) / dates.length;
|
|
95
|
+
const averageTime = _sumBy(dates, (d) => d.getTime()) / dates.length;
|
|
104
96
|
|
|
105
97
|
return new Date(averageTime);
|
|
106
98
|
}
|
|
@@ -114,8 +106,8 @@ export class DateHelper {
|
|
|
114
106
|
startDate.getUTCHours(),
|
|
115
107
|
startDate.getUTCMinutes(),
|
|
116
108
|
startDate.getUTCSeconds(),
|
|
117
|
-
startDate.getUTCMilliseconds()
|
|
118
|
-
)
|
|
109
|
+
startDate.getUTCMilliseconds(),
|
|
110
|
+
),
|
|
119
111
|
);
|
|
120
112
|
}
|
|
121
113
|
|
|
@@ -128,8 +120,8 @@ export class DateHelper {
|
|
|
128
120
|
startDate.getUTCHours(),
|
|
129
121
|
startDate.getUTCMinutes(),
|
|
130
122
|
startDate.getUTCSeconds(),
|
|
131
|
-
startDate.getUTCMilliseconds()
|
|
132
|
-
)
|
|
123
|
+
startDate.getUTCMilliseconds(),
|
|
124
|
+
),
|
|
133
125
|
);
|
|
134
126
|
}
|
|
135
127
|
|
|
@@ -142,8 +134,8 @@ export class DateHelper {
|
|
|
142
134
|
startDate.getUTCHours(),
|
|
143
135
|
startDate.getUTCMinutes(),
|
|
144
136
|
startDate.getUTCSeconds(),
|
|
145
|
-
startDate.getUTCMilliseconds()
|
|
146
|
-
)
|
|
137
|
+
startDate.getUTCMilliseconds(),
|
|
138
|
+
),
|
|
147
139
|
);
|
|
148
140
|
}
|
|
149
141
|
|
|
@@ -168,8 +160,8 @@ export class DateHelper {
|
|
|
168
160
|
startDate.getUTCHours(),
|
|
169
161
|
startDate.getUTCMinutes(),
|
|
170
162
|
startDate.getUTCSeconds(),
|
|
171
|
-
startDate.getUTCMilliseconds() + numberOfMiliseconds
|
|
172
|
-
)
|
|
163
|
+
startDate.getUTCMilliseconds() + numberOfMiliseconds,
|
|
164
|
+
),
|
|
173
165
|
);
|
|
174
166
|
}
|
|
175
167
|
|
|
@@ -198,9 +190,7 @@ export class DateHelper {
|
|
|
198
190
|
const oneHourMs = 60 * oneMinMs;
|
|
199
191
|
const oneDayMs = 24 * oneHourMs;
|
|
200
192
|
|
|
201
|
-
const diffDays = Math.floor(
|
|
202
|
-
(startOfDay(reference).getTime() - startOfDay(date).getTime()) / oneDayMs
|
|
203
|
-
);
|
|
193
|
+
const diffDays = Math.floor((startOfDay(reference).getTime() - startOfDay(date).getTime()) / oneDayMs);
|
|
204
194
|
|
|
205
195
|
const diffMs = reference.getTime() - date.getTime();
|
|
206
196
|
|
|
@@ -213,9 +203,7 @@ export class DateHelper {
|
|
|
213
203
|
const relativeTime = _compact([
|
|
214
204
|
hours > 0 ? `${hours} hour${hours > 1 ? 's' : ''}` : null,
|
|
215
205
|
minutes > 0 ? `${minutes} min${minutes > 1 ? 's' : ''}` : null,
|
|
216
|
-
seconds > 0 && hours === 0 && minutes === 0
|
|
217
|
-
? `${seconds} sec${seconds > 1 ? 's' : ''}`
|
|
218
|
-
: null
|
|
206
|
+
seconds > 0 && hours === 0 && minutes === 0 ? `${seconds} sec${seconds > 1 ? 's' : ''}` : null,
|
|
219
207
|
])
|
|
220
208
|
.slice(0, 2)
|
|
221
209
|
.join(', ');
|
|
@@ -223,7 +211,7 @@ export class DateHelper {
|
|
|
223
211
|
const timeFormatter = new Intl.DateTimeFormat('en-GB', {
|
|
224
212
|
hour: 'numeric',
|
|
225
213
|
minute: '2-digit',
|
|
226
|
-
hour12: false
|
|
214
|
+
hour12: false,
|
|
227
215
|
});
|
|
228
216
|
|
|
229
217
|
const fullDateFormatter = new Intl.DateTimeFormat('en-GB', {
|
|
@@ -232,7 +220,7 @@ export class DateHelper {
|
|
|
232
220
|
day: 'numeric',
|
|
233
221
|
hour: 'numeric',
|
|
234
222
|
minute: '2-digit',
|
|
235
|
-
hour12: false
|
|
223
|
+
hour12: false,
|
|
236
224
|
});
|
|
237
225
|
const weekday = new Intl.DateTimeFormat('en-GB', { weekday: 'long' }).format(date);
|
|
238
226
|
|
|
@@ -11,10 +11,7 @@ export function Cacheable(): MethodDecorator {
|
|
|
11
11
|
if (!Cacheable.hasCache(instance, propertyKey, args)) {
|
|
12
12
|
Cacheable.setCache(instance, propertyKey, args, callback());
|
|
13
13
|
} else {
|
|
14
|
-
Logger.info(
|
|
15
|
-
`Cacheable: ${target.constructor.name}.${propertyKey.toString()} result retrieved from cache`,
|
|
16
|
-
...args
|
|
17
|
-
);
|
|
14
|
+
Logger.info(`Cacheable: ${target.constructor.name}.${propertyKey.toString()} result retrieved from cache`, ...args);
|
|
18
15
|
}
|
|
19
16
|
return Cacheable.getCache(instance, propertyKey, args);
|
|
20
17
|
},
|
|
@@ -22,24 +19,17 @@ export function Cacheable(): MethodDecorator {
|
|
|
22
19
|
if (!Cacheable.hasCache(instance, propertyKey, args)) {
|
|
23
20
|
Cacheable.setCache(instance, propertyKey, args, await callback());
|
|
24
21
|
} else {
|
|
25
|
-
Logger.info(
|
|
26
|
-
`Cacheable: ${target.constructor.name}.${propertyKey.toString()} result retrieved from cache`,
|
|
27
|
-
...args
|
|
28
|
-
);
|
|
22
|
+
Logger.info(`Cacheable: ${target.constructor.name}.${propertyKey.toString()} result retrieved from cache`, ...args);
|
|
29
23
|
}
|
|
30
|
-
return PromiseHelper.fromFaster(
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
}
|
|
24
|
+
return PromiseHelper.fromFaster(Cacheable.getCache(instance, propertyKey, args));
|
|
25
|
+
},
|
|
34
26
|
};
|
|
35
27
|
};
|
|
36
28
|
|
|
37
29
|
if (typeof originalMethod === 'function') {
|
|
38
30
|
if (originalMethod.constructor.name === 'AsyncFunction') {
|
|
39
31
|
(descriptor as any).value = async function (...args) {
|
|
40
|
-
return getCache(this, args).getAsync(
|
|
41
|
-
async () => await originalMethod.apply(this, args)
|
|
42
|
-
);
|
|
32
|
+
return getCache(this, args).getAsync(async () => await originalMethod.apply(this, args));
|
|
43
33
|
};
|
|
44
34
|
} else {
|
|
45
35
|
(descriptor as any).value = function (...args) {
|
|
@@ -59,21 +49,16 @@ export namespace Cacheable {
|
|
|
59
49
|
|
|
60
50
|
export function getArgsCacheKey(args: any[]): string {
|
|
61
51
|
return JSON.stringify(
|
|
62
|
-
Array.from(args).map(arg => {
|
|
52
|
+
Array.from(args).map((arg) => {
|
|
63
53
|
if (typeof arg === 'function') {
|
|
64
54
|
return `function => class ${arg.name}`;
|
|
65
55
|
}
|
|
66
56
|
return arg;
|
|
67
|
-
})
|
|
57
|
+
}),
|
|
68
58
|
);
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
export function setCache<T, R>(
|
|
72
|
-
instance: T,
|
|
73
|
-
propertyKey: keyof T,
|
|
74
|
-
args: any[],
|
|
75
|
-
result: R
|
|
76
|
-
): void {
|
|
61
|
+
export function setCache<T, R>(instance: T, propertyKey: keyof T, args: any[], result: R): void {
|
|
77
62
|
const cachePropertyName = getMethodCacheKey(instance, propertyKey);
|
|
78
63
|
if (!instance.hasOwnProperty(cachePropertyName)) {
|
|
79
64
|
instance[cachePropertyName] = new Map<string, any>();
|
package/src/enum-helper.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class EnumHelper<T> {
|
|
2
2
|
constructor(
|
|
3
3
|
private _name: string,
|
|
4
|
-
private _members: T[]
|
|
4
|
+
private _members: T[],
|
|
5
5
|
) {}
|
|
6
6
|
|
|
7
7
|
public get name(): string {
|
|
@@ -13,7 +13,7 @@ export class EnumHelper<T> {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public membersNotIn(excludedMembers: T[]): T[] {
|
|
16
|
-
const notExcludedMembers = this._members.filter(m => !excludedMembers.includes(m));
|
|
16
|
+
const notExcludedMembers = this._members.filter((m) => !excludedMembers.includes(m));
|
|
17
17
|
return [...notExcludedMembers];
|
|
18
18
|
}
|
|
19
19
|
}
|
package/src/event.ts
CHANGED
|
@@ -30,7 +30,6 @@ export abstract class Event implements Document {
|
|
|
30
30
|
|
|
31
31
|
public set publishedAt(date: Date) {
|
|
32
32
|
Event.counter++;
|
|
33
|
-
this._publishedAt =
|
|
34
|
-
date.toISOString().replace('Z', '.' + ('0'.repeat(9) + Event.counter).slice(-9)) + 'Z';
|
|
33
|
+
this._publishedAt = date.toISOString().replace('Z', '.' + ('0'.repeat(9) + Event.counter).slice(-9)) + 'Z';
|
|
35
34
|
}
|
|
36
35
|
}
|
package/src/json-helper.ts
CHANGED
|
@@ -28,8 +28,6 @@ export class JsonHelper {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
private static isISODateString(date: string): boolean {
|
|
31
|
-
return /^(?:\d{4})-(?:\d{2})-(?:\d{2})T(?:\d{2}):(?:\d{2}):(?:\d{2}(?:\.\d*)?)(?:(?:-(?:\d{2}):(?:\d{2})|Z)?)$/.test(
|
|
32
|
-
date
|
|
33
|
-
);
|
|
31
|
+
return /^(?:\d{4})-(?:\d{2})-(?:\d{2})T(?:\d{2}):(?:\d{2}):(?:\d{2}(?:\.\d*)?)(?:(?:-(?:\d{2}):(?:\d{2})|Z)?)$/.test(date);
|
|
34
32
|
}
|
|
35
33
|
}
|
package/src/logger.ts
CHANGED
|
@@ -19,17 +19,13 @@ export class Logger {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
public static infoWithElapesedTime(
|
|
23
|
-
message: string,
|
|
24
|
-
startDate: Date,
|
|
25
|
-
meta?: Logger.LogMetaData
|
|
26
|
-
): void {
|
|
22
|
+
public static infoWithElapesedTime(message: string, startDate: Date, meta?: Logger.LogMetaData): void {
|
|
27
23
|
this.info(message, {
|
|
28
24
|
...meta,
|
|
29
25
|
elpasedTime: {
|
|
30
26
|
ms: DateHelper.getElapsedTime(startDate),
|
|
31
|
-
readable: DateHelper.getReadableElapsedTime(startDate)
|
|
32
|
-
}
|
|
27
|
+
readable: DateHelper.getReadableElapsedTime(startDate),
|
|
28
|
+
},
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
|
package/src/model.ts
CHANGED
package/src/promise-helper.ts
CHANGED
|
@@ -4,7 +4,7 @@ export class PromiseHelper {
|
|
|
4
4
|
// Used to avoid syncronous Promise resolution
|
|
5
5
|
// That way other callbacks in the application can have an opportunity to get executed
|
|
6
6
|
public static async from<T>(value: T): Promise<T> {
|
|
7
|
-
return new Promise<T>(resolve => {
|
|
7
|
+
return new Promise<T>((resolve) => {
|
|
8
8
|
setTimeout(() => resolve(value), 0);
|
|
9
9
|
});
|
|
10
10
|
}
|
|
@@ -15,7 +15,7 @@ export class PromiseHelper {
|
|
|
15
15
|
this.counter++;
|
|
16
16
|
if (this.counter % 100 === 0) {
|
|
17
17
|
this.counter = 0;
|
|
18
|
-
return new Promise<T>(resolve => {
|
|
18
|
+
return new Promise<T>((resolve) => {
|
|
19
19
|
setTimeout(() => resolve(value), 0);
|
|
20
20
|
});
|
|
21
21
|
} else {
|
|
@@ -24,6 +24,6 @@ export class PromiseHelper {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
public static async wait(seconds: number): Promise<void> {
|
|
27
|
-
await new Promise<void>(resolve => setTimeout(() => resolve(), seconds * 1000));
|
|
27
|
+
await new Promise<void>((resolve) => setTimeout(() => resolve(), seconds * 1000));
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/retry.ts
CHANGED
package/src/serialize/index.ts
CHANGED
|
@@ -4,10 +4,4 @@ export * from './serialize';
|
|
|
4
4
|
export * from './serialize-helper';
|
|
5
5
|
export * from './type-helper';
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
autoserialize,
|
|
9
|
-
autoserializeAs,
|
|
10
|
-
deserializeAs,
|
|
11
|
-
inheritSerialization,
|
|
12
|
-
serializeAs
|
|
13
|
-
} from 'cerialize';
|
|
7
|
+
export { autoserialize, autoserializeAs, deserializeAs, inheritSerialization, serializeAs } from 'cerialize';
|
|
@@ -14,9 +14,7 @@ export namespace serializable {
|
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
if (!object._type) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`SerializeHelper: property _type is missing in ${JSON.stringify(object)}`
|
|
19
|
-
);
|
|
17
|
+
throw new Error(`SerializeHelper: property _type is missing in ${JSON.stringify(object)}`);
|
|
20
18
|
}
|
|
21
19
|
const type = types.get(object._type);
|
|
22
20
|
if (!type) {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { words as _words, compact, deburr, uniq } from 'lodash';
|
|
2
2
|
|
|
3
3
|
export class SerializeHelper {
|
|
4
|
-
public static getSearchKeyWords(
|
|
5
|
-
criterias: (string | number)[],
|
|
6
|
-
smartSearchCriterias: string[] = []
|
|
7
|
-
): string[] {
|
|
4
|
+
public static getSearchKeyWords(criterias: (string | number)[], smartSearchCriterias: string[] = []): string[] {
|
|
8
5
|
const smartSearchWords = this.getSmartSearchKeyWords(smartSearchCriterias);
|
|
9
6
|
return compact(uniq(this.getWords([...criterias, ...smartSearchWords]))).sort();
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
private static getSmartSearchKeyWords(criterias: string[]): string[] {
|
|
13
|
-
return this.getWords(criterias).flatMap(word => {
|
|
10
|
+
return this.getWords(criterias).flatMap((word) => {
|
|
14
11
|
const result: string[] = [word];
|
|
15
|
-
for (let length = 2; length < word.length; length++)
|
|
16
|
-
result.push(word.substring(0, length));
|
|
12
|
+
for (let length = 2; length < word.length; length++) result.push(word.substring(0, length));
|
|
17
13
|
|
|
18
14
|
return result;
|
|
19
15
|
});
|
|
@@ -45,14 +41,13 @@ export class SerializeHelper {
|
|
|
45
41
|
'/',
|
|
46
42
|
'|',
|
|
47
43
|
'_',
|
|
48
|
-
'#'
|
|
44
|
+
'#',
|
|
49
45
|
];
|
|
50
46
|
|
|
51
47
|
let phrase = deburr(_words(criterias.join(' ')).join(' ')).toLowerCase();
|
|
52
|
-
for (const excapedCharacter of excapedCharacters)
|
|
53
|
-
phrase = phrase.replaceAll(excapedCharacter, ' ');
|
|
48
|
+
for (const excapedCharacter of excapedCharacters) phrase = phrase.replaceAll(excapedCharacter, ' ');
|
|
54
49
|
|
|
55
|
-
const phraseWords = _words(phrase).flatMap(word => {
|
|
50
|
+
const phraseWords = _words(phrase).flatMap((word) => {
|
|
56
51
|
const result = [word];
|
|
57
52
|
|
|
58
53
|
// Remove leading zeros 00012345 => 12345
|
|
@@ -16,24 +16,22 @@ export class TypeHelper {
|
|
|
16
16
|
const metaData = this.getMetaData(type);
|
|
17
17
|
const result: TypeHelper.Property[] = [];
|
|
18
18
|
|
|
19
|
-
const remaining = metaData.map(m => ({ parent: null, m }));
|
|
19
|
+
const remaining = metaData.map((m) => ({ parent: null, m }));
|
|
20
20
|
while (remaining.length > 0) {
|
|
21
21
|
const property = remaining.shift();
|
|
22
|
-
const path = property.parent
|
|
23
|
-
? `${property.parent}.${property.m.name}`
|
|
24
|
-
: property.m.name;
|
|
22
|
+
const path = property.parent ? `${property.parent}.${property.m.name}` : property.m.name;
|
|
25
23
|
result.push({
|
|
26
24
|
parent: property.parent ? _trimEnd(property.parent, '[]') : null,
|
|
27
25
|
path,
|
|
28
26
|
name: property.m.name,
|
|
29
27
|
isArray: property.m.isArray,
|
|
30
28
|
type: property.m.type,
|
|
31
|
-
enumName: property.m.enumName
|
|
29
|
+
enumName: property.m.enumName,
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
if (property.m.type === TypeHelper.Type.Object) {
|
|
35
33
|
const parent = property.m.isArray ? `${path}[]` : path;
|
|
36
|
-
remaining.push(...property.m.objectMetadata.map(m => ({ parent, m })));
|
|
34
|
+
remaining.push(...property.m.objectMetadata.map((m) => ({ parent, m })));
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
return result;
|
|
@@ -45,28 +43,19 @@ export class TypeHelper {
|
|
|
45
43
|
return [];
|
|
46
44
|
}
|
|
47
45
|
const instance = Deserialize({}, type);
|
|
48
|
-
return metaDataList.map(m => {
|
|
46
|
+
return metaDataList.map((m) => {
|
|
49
47
|
const metaDataType = TypeHelper.getMetaDataType(m.deserializedType);
|
|
50
48
|
const metadata: TypeHelper.MetaData = {
|
|
51
49
|
name: m.keyName,
|
|
52
50
|
serializedKey: m.serializedKey ? m.serializedKey : m.keyName,
|
|
53
51
|
deserializedKey: m.deserializedKey ? m.deserializedKey : m.keyName,
|
|
54
52
|
type: metaDataType,
|
|
55
|
-
enumName:
|
|
56
|
-
metaDataType === TypeHelper.Type.Enum
|
|
57
|
-
? this.getEnumName(m.deserializedType)
|
|
58
|
-
: null,
|
|
53
|
+
enumName: metaDataType === TypeHelper.Type.Enum ? this.getEnumName(m.deserializedType) : null,
|
|
59
54
|
isArray: Array.isArray(instance[m.keyName]),
|
|
60
55
|
arrayLength: Array.isArray(instance[m.keyName]) ? instance[m.keyName].length : null,
|
|
61
56
|
objectName: metaDataType === TypeHelper.Type.Object ? m.deserializedType.name : [],
|
|
62
|
-
objectMetadata:
|
|
63
|
-
|
|
64
|
-
? this.getMetaData(m.deserializedType)
|
|
65
|
-
: [],
|
|
66
|
-
enumValues:
|
|
67
|
-
metaDataType === TypeHelper.Type.Enum
|
|
68
|
-
? this.getEnumValues(m.deserializedType)
|
|
69
|
-
: []
|
|
57
|
+
objectMetadata: metaDataType === TypeHelper.Type.Object ? this.getMetaData(m.deserializedType) : [],
|
|
58
|
+
enumValues: metaDataType === TypeHelper.Type.Enum ? this.getEnumValues(m.deserializedType) : [],
|
|
70
59
|
};
|
|
71
60
|
return metadata;
|
|
72
61
|
});
|
|
@@ -141,33 +130,21 @@ export class TypeHelper {
|
|
|
141
130
|
}
|
|
142
131
|
|
|
143
132
|
private static isString(propType: any) {
|
|
144
|
-
if (
|
|
145
|
-
propType &&
|
|
146
|
-
propType.Deserialize &&
|
|
147
|
-
propType.Deserialize.name.replace('deserialize', '') === 'String'
|
|
148
|
-
) {
|
|
133
|
+
if (propType && propType.Deserialize && propType.Deserialize.name.replace('deserialize', '') === 'String') {
|
|
149
134
|
return true;
|
|
150
135
|
}
|
|
151
136
|
return false;
|
|
152
137
|
}
|
|
153
138
|
|
|
154
139
|
private static isBoolean(propType: any) {
|
|
155
|
-
if (
|
|
156
|
-
propType &&
|
|
157
|
-
propType.Deserialize &&
|
|
158
|
-
propType.Deserialize.name.replace('deserialize', '') === 'Boolean'
|
|
159
|
-
) {
|
|
140
|
+
if (propType && propType.Deserialize && propType.Deserialize.name.replace('deserialize', '') === 'Boolean') {
|
|
160
141
|
return true;
|
|
161
142
|
}
|
|
162
143
|
return false;
|
|
163
144
|
}
|
|
164
145
|
|
|
165
146
|
private static isNumber(propType: any) {
|
|
166
|
-
if (
|
|
167
|
-
propType &&
|
|
168
|
-
propType.Deserialize &&
|
|
169
|
-
propType.Deserialize.name.replace('deserialize', '') === 'Number'
|
|
170
|
-
) {
|
|
147
|
+
if (propType && propType.Deserialize && propType.Deserialize.name.replace('deserialize', '') === 'Number') {
|
|
171
148
|
return true;
|
|
172
149
|
}
|
|
173
150
|
return false;
|
|
@@ -211,15 +188,12 @@ export namespace TypeHelper {
|
|
|
211
188
|
Boolean = <any>'Boolean',
|
|
212
189
|
Enum = <any>'Enum',
|
|
213
190
|
Object = <any>'Object',
|
|
214
|
-
Any = <any>'Any'
|
|
191
|
+
Any = <any>'Any',
|
|
215
192
|
}
|
|
216
193
|
|
|
217
194
|
type NonFunctionPropertyNames<T> = {
|
|
218
195
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
|
|
219
196
|
}[keyof T];
|
|
220
197
|
|
|
221
|
-
export type ClassProperties<T> = Omit<
|
|
222
|
-
Pick<T, NonFunctionPropertyNames<T>>,
|
|
223
|
-
'_path' | 'publishedAt' | 'publishedAt'
|
|
224
|
-
>;
|
|
198
|
+
export type ClassProperties<T> = Omit<Pick<T, NonFunctionPropertyNames<T>>, '_path' | 'publishedAt' | 'publishedAt'>;
|
|
225
199
|
}
|
package/src/sleep.ts
CHANGED
|
@@ -6,5 +6,5 @@ import { Logger } from './logger';
|
|
|
6
6
|
*/
|
|
7
7
|
export const sleep = async (miliseconds: number): Promise<void> => {
|
|
8
8
|
Logger.info(`Sleeping ${miliseconds} ms`);
|
|
9
|
-
return new Promise<void>(resolve => setTimeout(() => resolve(), miliseconds));
|
|
9
|
+
return new Promise<void>((resolve) => setTimeout(() => resolve(), miliseconds));
|
|
10
10
|
};
|
|
@@ -13,8 +13,8 @@ export function EqualsTo(property: string, validationOptions?: ValidationOptions
|
|
|
13
13
|
const relatedPropertyName = args.constraints[0].property;
|
|
14
14
|
const relatedValue = (args.object as any)[relatedPropertyName];
|
|
15
15
|
return value === relatedValue;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { registerDecorator, ValidationArguments, ValidationOptions } from 'class-validator';
|
|
2
2
|
|
|
3
|
-
export function GreaterThanDate(
|
|
4
|
-
property: string,
|
|
5
|
-
milliSecondsOffset?: number,
|
|
6
|
-
validationOptions?: ValidationOptions
|
|
7
|
-
) {
|
|
3
|
+
export function GreaterThanDate(property: string, milliSecondsOffset?: number, validationOptions?: ValidationOptions) {
|
|
8
4
|
return function (object: Record<string, any>, propertyName: string): void {
|
|
9
5
|
registerDecorator({
|
|
10
6
|
name: 'greaterThanDate',
|
|
@@ -25,8 +21,8 @@ export function GreaterThanDate(
|
|
|
25
21
|
return value > relatedValue;
|
|
26
22
|
}
|
|
27
23
|
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
30
26
|
});
|
|
31
27
|
};
|
|
32
28
|
}
|