@comasoft/nestjs 0.0.8 → 0.0.91
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/timestamps.decorator.js +0 -3
- package/dist/dto/auth-user-sso.dto.d.ts +3 -0
- package/dist/dto/auth-user-sso.dto.js +21 -0
- package/dist/dto/index.d.ts +6 -6
- package/dist/dto/index.js +1 -1
- package/dist/dto/response-uid.dto.d.ts +6 -0
- package/dist/dto/response-uid.dto.js +27 -0
- package/dist/passport/jwt.strategy.js +1 -1
- package/dist/utils/common.utils.d.ts +1 -0
- package/dist/utils/common.utils.js +5 -1
- package/dist/utils/pagination-qb.utils.d.ts +1 -0
- package/dist/utils/pagination-qb.utils.js +110 -11
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthUserSsoDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class AuthUserSsoDto {
|
|
15
|
+
}
|
|
16
|
+
exports.AuthUserSsoDto = AuthUserSsoDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], AuthUserSsoDto.prototype, "access_token", void 0);
|
package/dist/dto/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from './auth-user-local.dto';
|
|
2
|
+
export * from './pagination.dto';
|
|
3
|
+
export * from './response-id.dto';
|
|
4
|
+
export * from './response-uid.dto';
|
|
5
|
+
export * from './response-access-token.dto';
|
|
6
|
+
export * from './custom-params.dto';
|
package/dist/dto/index.js
CHANGED
|
@@ -17,6 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./auth-user-local.dto"), exports);
|
|
18
18
|
__exportStar(require("./pagination.dto"), exports);
|
|
19
19
|
__exportStar(require("./response-id.dto"), exports);
|
|
20
|
+
__exportStar(require("./response-uid.dto"), exports);
|
|
20
21
|
__exportStar(require("./response-access-token.dto"), exports);
|
|
21
22
|
__exportStar(require("./custom-params.dto"), exports);
|
|
22
|
-
__exportStar(require("./jwt-user.dto"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ResponseUidsDto = exports.ResponseUidDto = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
class ResponseUidDto {
|
|
15
|
+
}
|
|
16
|
+
exports.ResponseUidDto = ResponseUidDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_transformer_1.Expose)(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], ResponseUidDto.prototype, "uid", void 0);
|
|
21
|
+
class ResponseUidsDto {
|
|
22
|
+
}
|
|
23
|
+
exports.ResponseUidsDto = ResponseUidsDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, class_transformer_1.Expose)(),
|
|
26
|
+
__metadata("design:type", Array)
|
|
27
|
+
], ResponseUidsDto.prototype, "uids", void 0);
|
|
@@ -44,7 +44,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
|
|
|
44
44
|
validate(payload) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const { sub } = payload, rest = __rest(payload, ["sub"]);
|
|
47
|
-
return Object.assign({
|
|
47
|
+
return Object.assign({ sub }, rest);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertExpirationToSeconds = exports.generateOrderId = void 0;
|
|
3
|
+
exports._randomRange = exports.convertExpirationToSeconds = exports.generateOrderId = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
const generateOrderId = () => {
|
|
6
6
|
const date_part = (0, date_fns_1.format)(new Date(), 'yyMMdd');
|
|
@@ -26,3 +26,7 @@ const convertExpirationToSeconds = (expiration) => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
exports.convertExpirationToSeconds = convertExpirationToSeconds;
|
|
29
|
+
const _randomRange = (min, max) => {
|
|
30
|
+
return Math.floor(min + Math.random() * (max - min + 1));
|
|
31
|
+
};
|
|
32
|
+
exports._randomRange = _randomRange;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applyFiltersAndSorting = applyFiltersAndSorting;
|
|
4
4
|
function applyFiltersAndSorting(queryBuilder, options) {
|
|
5
|
-
const { _keyword, _group, _sort, aliasName = 'a', keywordFields = ['name'], } = options;
|
|
5
|
+
const { _keyword, _group, _sort, aliasName = 'a', keywordFields = ['name'], groupFields = [], } = options;
|
|
6
6
|
applyKeywordFilter(queryBuilder, _keyword, aliasName, keywordFields);
|
|
7
|
-
applyGroupFilter(queryBuilder, _group, aliasName);
|
|
7
|
+
applyGroupFilter(queryBuilder, _group, aliasName, groupFields);
|
|
8
8
|
applySorting(queryBuilder, _sort, aliasName);
|
|
9
9
|
return queryBuilder;
|
|
10
10
|
}
|
|
@@ -16,17 +16,116 @@ function applyKeywordFilter(queryBuilder, keyword, aliasName, keywordFields) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
|
|
19
|
+
function validateAndParseDate(dateStr) {
|
|
20
|
+
if (!/^\d{8}T\d{6}Z$/.test(dateStr)) {
|
|
21
|
+
throw new Error('Invalid date format. Use YYYYMMDDTHHMMSSZ (e.g., 20250122T150000Z)');
|
|
22
|
+
}
|
|
23
|
+
const year = dateStr.substring(0, 4);
|
|
24
|
+
const month = dateStr.substring(4, 6);
|
|
25
|
+
const day = dateStr.substring(6, 8);
|
|
26
|
+
const hour = dateStr.substring(9, 11);
|
|
27
|
+
const minute = dateStr.substring(11, 13);
|
|
28
|
+
const second = dateStr.substring(13, 15);
|
|
29
|
+
const isoString = `${year}-${month}-${day}T${hour}:${minute}:${second}Z`;
|
|
30
|
+
const date = new Date(isoString);
|
|
31
|
+
if (isNaN(date.getTime())) {
|
|
32
|
+
throw new Error('Invalid date');
|
|
33
|
+
}
|
|
34
|
+
return date;
|
|
35
|
+
}
|
|
36
|
+
const filterHandlers = {
|
|
37
|
+
handleEquals(field, value, index) {
|
|
38
|
+
return {
|
|
39
|
+
condition: `${field} = :${field}${index}`,
|
|
40
|
+
parameters: { [`${field}${index}`]: value },
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
handleNumberRange(field, value, index) {
|
|
44
|
+
const [minValue, maxValue] = value
|
|
45
|
+
.split('__')
|
|
46
|
+
.map((v) => (v === '' ? null : Number(v)));
|
|
22
47
|
const conditions = [];
|
|
23
48
|
const parameters = {};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
parameters[`${field}${index}`] =
|
|
28
|
-
}
|
|
29
|
-
|
|
49
|
+
if (minValue !== null && maxValue !== null) {
|
|
50
|
+
conditions.push(`${field} BETWEEN :${field}Min${index} AND :${field}Max${index}`);
|
|
51
|
+
parameters[`${field}Min${index}`] = minValue;
|
|
52
|
+
parameters[`${field}Max${index}`] = maxValue;
|
|
53
|
+
}
|
|
54
|
+
else if (minValue !== null) {
|
|
55
|
+
conditions.push(`${field} >= :${field}Min${index}`);
|
|
56
|
+
parameters[`${field}Min${index}`] = minValue;
|
|
57
|
+
}
|
|
58
|
+
else if (maxValue !== null) {
|
|
59
|
+
conditions.push(`${field} <= :${field}Max${index}`);
|
|
60
|
+
parameters[`${field}Max${index}`] = maxValue;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
condition: conditions.join(' AND '),
|
|
64
|
+
parameters,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
handleDateRange(field, value, index) {
|
|
68
|
+
const [minValue, maxValue] = value
|
|
69
|
+
.split('__')
|
|
70
|
+
.map((v) => (v === '' ? null : v));
|
|
71
|
+
const conditions = [];
|
|
72
|
+
const parameters = {};
|
|
73
|
+
if (minValue !== null && maxValue !== null) {
|
|
74
|
+
conditions.push(`${field} BETWEEN :${field}Min${index} AND :${field}Max${index}`);
|
|
75
|
+
parameters[`${field}Min${index}`] = validateAndParseDate(minValue);
|
|
76
|
+
parameters[`${field}Max${index}`] = validateAndParseDate(maxValue);
|
|
77
|
+
}
|
|
78
|
+
else if (minValue !== null) {
|
|
79
|
+
conditions.push(`${field} >= :${field}Min${index}`);
|
|
80
|
+
parameters[`${field}Min${index}`] = validateAndParseDate(minValue);
|
|
81
|
+
}
|
|
82
|
+
else if (maxValue !== null) {
|
|
83
|
+
conditions.push(`${field} <= :${field}Max${index}`);
|
|
84
|
+
parameters[`${field}Max${index}`] = validateAndParseDate(maxValue);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
condition: conditions.join(' AND '),
|
|
88
|
+
parameters,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
function applyGroupFilter(queryBuilder, group, aliasName, groupFields) {
|
|
93
|
+
if (!group)
|
|
94
|
+
return;
|
|
95
|
+
if (groupFields.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
const groups = group.split('|');
|
|
98
|
+
const hasInvalidField = groups.some((g) => {
|
|
99
|
+
const [field] = g.split('-');
|
|
100
|
+
return !groupFields.includes(field);
|
|
101
|
+
});
|
|
102
|
+
if (hasInvalidField) {
|
|
103
|
+
throw new Error('Invalid field detected in group filter');
|
|
104
|
+
}
|
|
105
|
+
const allConditions = [];
|
|
106
|
+
const allParameters = {};
|
|
107
|
+
groups.forEach((g, index) => {
|
|
108
|
+
const [field, value] = g.split(/-(.+)/);
|
|
109
|
+
const fullField = `${aliasName}.${field}`;
|
|
110
|
+
let handler;
|
|
111
|
+
if (value.includes('__')) {
|
|
112
|
+
if (field.includes('_at') || field.includes('_date')) {
|
|
113
|
+
handler = filterHandlers.handleDateRange(fullField, value, index);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
handler = filterHandlers.handleNumberRange(fullField, value, index);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
handler = filterHandlers.handleEquals(fullField, value, index);
|
|
121
|
+
}
|
|
122
|
+
if (handler.condition) {
|
|
123
|
+
allConditions.push(handler.condition);
|
|
124
|
+
Object.assign(allParameters, handler.parameters);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (allConditions.length > 0) {
|
|
128
|
+
queryBuilder.andWhere(`(${allConditions.join(' AND ')})`, allParameters);
|
|
30
129
|
}
|
|
31
130
|
}
|
|
32
131
|
function applySorting(queryBuilder, sort, aliasName) {
|