@mondart/nestjs-common-module 2.3.5 → 2.4.1
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/decorators/swagger-api-response.decorator.d.ts +1 -0
- package/dist/decorators/swagger-api-response.decorator.js +5 -0
- package/dist/dto/response/index.d.ts +1 -0
- package/dist/dto/response/index.js +1 -0
- package/dist/dto/response/paginate-metadata-response.dto.d.ts +12 -0
- package/dist/dto/response/paginate-metadata-response.dto.js +43 -0
- package/dist/dto/response/success-response.dto.d.ts +5 -5
- package/dist/lib/bottleneck/bottleneck.module.d.ts +8 -0
- package/dist/lib/bottleneck/bottleneck.module.js +109 -0
- package/dist/lib/bottleneck/constants/bottleneck.const.d.ts +3 -0
- package/dist/lib/bottleneck/constants/bottleneck.const.js +6 -0
- package/dist/lib/bottleneck/cqrs-wrapper/queued-command-bus.d.ts +8 -0
- package/dist/lib/bottleneck/cqrs-wrapper/queued-command-bus.js +31 -0
- package/dist/lib/bottleneck/cqrs-wrapper/queued-query-bus.d.ts +8 -0
- package/dist/lib/bottleneck/cqrs-wrapper/queued-query-bus.js +31 -0
- package/dist/lib/bottleneck/decorators/config-bottleneck.decorator.d.ts +2 -0
- package/dist/lib/bottleneck/decorators/config-bottleneck.decorator.js +7 -0
- package/dist/lib/bottleneck/decorators/skip-bottleneck.decorator.d.ts +1 -0
- package/dist/lib/bottleneck/decorators/skip-bottleneck.decorator.js +7 -0
- package/dist/lib/bottleneck/decorators/use-bottleneck.decorator.d.ts +1 -0
- package/dist/lib/bottleneck/decorators/use-bottleneck.decorator.js +7 -0
- package/dist/lib/bottleneck/index.d.ts +10 -0
- package/dist/lib/bottleneck/index.js +26 -0
- package/dist/lib/bottleneck/interceptors/bottleneck.interceptor.d.ts +12 -0
- package/dist/lib/bottleneck/interceptors/bottleneck.interceptor.js +82 -0
- package/dist/lib/bottleneck/interfaces/bottleneck-options.interface.d.ts +39 -0
- package/dist/lib/bottleneck/interfaces/bottleneck-options.interface.js +4 -0
- package/dist/lib/bottleneck/services/bottleneck.service.d.ts +14 -0
- package/dist/lib/bottleneck/services/bottleneck.service.js +93 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/validators/is-date-range.validator.d.ts +1 -1
- package/dist/validators/is-date-range.validator.js +19 -12
- package/package.json +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ValidationOptions } from 'class-validator';
|
|
2
2
|
type DateComparisonOperator = '<' | '<=' | '>' | '>=';
|
|
3
|
-
export declare function IsDateRangeValid(relatedPropertyNameOrCurrent: string, operator: DateComparisonOperator, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
3
|
+
export declare function IsDateRangeValid(relatedPropertyNameOrCurrent: string, operator: DateComparisonOperator, timezone?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
4
4
|
export {};
|
|
@@ -8,32 +8,39 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.IsDateRangeValid = IsDateRangeValid;
|
|
10
10
|
const class_validator_1 = require("class-validator");
|
|
11
|
+
const moment = require("moment-timezone");
|
|
11
12
|
let IsDateRangeValidConstraint = class IsDateRangeValidConstraint {
|
|
12
13
|
validate(from, args) {
|
|
13
|
-
const [relatedPropertyNameOrCurrent, operator] = args.constraints;
|
|
14
|
+
const [relatedPropertyNameOrCurrent, operator, timezone] = args.constraints;
|
|
14
15
|
let compareTo;
|
|
15
16
|
if (relatedPropertyNameOrCurrent === 'current') {
|
|
16
|
-
compareTo =
|
|
17
|
-
|
|
17
|
+
compareTo = moment
|
|
18
|
+
.tz(timezone || moment.tz.guess())
|
|
19
|
+
.startOf('day')
|
|
20
|
+
.toDate();
|
|
21
|
+
console.log('Compare To Date:', compareTo);
|
|
18
22
|
}
|
|
19
23
|
else {
|
|
20
24
|
compareTo = args.object[relatedPropertyNameOrCurrent];
|
|
21
|
-
compareTo =
|
|
22
|
-
|
|
25
|
+
compareTo = moment(compareTo)
|
|
26
|
+
.tz(timezone || moment.tz.guess())
|
|
27
|
+
.startOf('day')
|
|
28
|
+
.toDate();
|
|
23
29
|
}
|
|
24
30
|
if (!from || !compareTo) {
|
|
25
31
|
return true;
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
const convertedFrom = moment(from).endOf('day').toDate();
|
|
34
|
+
console.log('From Date:', from);
|
|
28
35
|
switch (operator) {
|
|
29
36
|
case '<':
|
|
30
|
-
return
|
|
37
|
+
return convertedFrom.getTime() < compareTo.getTime();
|
|
31
38
|
case '<=':
|
|
32
|
-
return
|
|
39
|
+
return convertedFrom.getTime() <= compareTo.getTime();
|
|
33
40
|
case '>':
|
|
34
|
-
return
|
|
41
|
+
return convertedFrom.getTime() > compareTo.getTime();
|
|
35
42
|
case '>=':
|
|
36
|
-
return
|
|
43
|
+
return convertedFrom.getTime() >= compareTo.getTime();
|
|
37
44
|
default:
|
|
38
45
|
return false;
|
|
39
46
|
}
|
|
@@ -49,13 +56,13 @@ let IsDateRangeValidConstraint = class IsDateRangeValidConstraint {
|
|
|
49
56
|
IsDateRangeValidConstraint = __decorate([
|
|
50
57
|
(0, class_validator_1.ValidatorConstraint)({ async: false })
|
|
51
58
|
], IsDateRangeValidConstraint);
|
|
52
|
-
function IsDateRangeValid(relatedPropertyNameOrCurrent, operator, validationOptions) {
|
|
59
|
+
function IsDateRangeValid(relatedPropertyNameOrCurrent, operator, timezone, validationOptions) {
|
|
53
60
|
return (object, propertyName) => {
|
|
54
61
|
(0, class_validator_1.registerDecorator)({
|
|
55
62
|
target: object.constructor,
|
|
56
63
|
propertyName: propertyName,
|
|
57
64
|
options: validationOptions,
|
|
58
|
-
constraints: [relatedPropertyNameOrCurrent, operator],
|
|
65
|
+
constraints: [relatedPropertyNameOrCurrent, operator, timezone],
|
|
59
66
|
validator: IsDateRangeValidConstraint,
|
|
60
67
|
});
|
|
61
68
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondart/nestjs-common-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mondart"
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@sentry/profiling-node": "^8.32.0",
|
|
39
39
|
"@types/redis": "^4.0.11",
|
|
40
40
|
"axios": "^1.7.9",
|
|
41
|
+
"bottleneck": "^2.19.5",
|
|
41
42
|
"cache-manager": "^6.4.0",
|
|
42
43
|
"cache-manager-ioredis-yet": "^2.1.1",
|
|
43
44
|
"class-transformer": "^0.5.1",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"express-basic-auth": "^1.2.1",
|
|
46
47
|
"kafkajs": "^2.2.4",
|
|
47
48
|
"nestjs-paginate": "^11.1.0",
|
|
49
|
+
"moment-timezone": "^0.6.0",
|
|
48
50
|
"npm": "^10.8.1",
|
|
49
51
|
"reflect-metadata": "^0.2.0",
|
|
50
52
|
"rxjs": "^7.8.1",
|