@nest-omni/core 1.0.56-1 → 1.0.56-2
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/common/utils.js +4 -3
- package/decorators/api-page-ok-response.decorator.js +2 -1
- package/decorators/auth-user.decorator.js +2 -1
- package/decorators/controller.decorator.js +2 -1
- package/decorators/field.decorators.js +38 -37
- package/decorators/http.decorators.js +2 -1
- package/decorators/property.decorators.js +7 -6
- package/decorators/swagger.schema.js +2 -1
- package/decorators/timestamp-column.decorator.js +2 -1
- package/decorators/transform.decorators.js +9 -8
- package/decorators/translate.decorator.js +3 -3
- package/decorators/use-dto.decorator.js +2 -1
- package/decorators/user-check.decorator.js +2 -2
- package/decorators/user.decorator.js +2 -2
- package/decorators/user_auth.decorator.js +2 -1
- package/decorators/validator.decorators.js +8 -7
- package/helpers/common.helper.js +3 -3
- package/helpers/date.helper.js +7 -6
- package/interceptors/language-interceptor.service.js +2 -2
- package/interfaces/IFile.d.ts +1 -0
- package/package.json +4 -2
- package/setup/bootstrap.setup.d.ts +3 -0
- package/setup/bootstrap.setup.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/validator-json/decorators.js +3 -2
- package/validator-json/default.js +3 -3
- package/validators/is-exists.validator.js +2 -2
- package/validators/is-unique.validator.js +2 -2
- package/validators/phone-country-code.validator.js +2 -1
- package/validators/same-as.validator.js +2 -1
- package/validators/skip-empty.validator.js +2 -1
package/common/utils.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateHash =
|
|
4
|
-
exports.validateHash = validateHash;
|
|
5
|
-
exports.getVariableName = getVariableName;
|
|
3
|
+
exports.getVariableName = exports.validateHash = exports.generateHash = void 0;
|
|
6
4
|
const bcrypt_1 = require("bcrypt");
|
|
7
5
|
function generateHash(password) {
|
|
8
6
|
return bcrypt_1.default.hashSync(password, 10);
|
|
9
7
|
}
|
|
8
|
+
exports.generateHash = generateHash;
|
|
10
9
|
function validateHash(password, hash) {
|
|
11
10
|
if (!password || !hash) {
|
|
12
11
|
return Promise.resolve(false);
|
|
13
12
|
}
|
|
14
13
|
return bcrypt_1.default.compare(password, hash);
|
|
15
14
|
}
|
|
15
|
+
exports.validateHash = validateHash;
|
|
16
16
|
function getVariableName(getVar) {
|
|
17
17
|
const m = /\(\)=>(.*)/.exec(getVar.toString().replace(/(\r\n|\n|\r|\s)/gm, ''));
|
|
18
18
|
if (!m) {
|
|
@@ -22,3 +22,4 @@ function getVariableName(getVar) {
|
|
|
22
22
|
const memberParts = fullMemberName.split('.');
|
|
23
23
|
return memberParts[memberParts.length - 1];
|
|
24
24
|
}
|
|
25
|
+
exports.getVariableName = getVariableName;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiPageResponse =
|
|
3
|
+
exports.ApiPageResponse = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
6
|
const page_dto_1 = require("../common/dto/page.dto");
|
|
@@ -22,3 +22,4 @@ function ApiPageResponse(options) {
|
|
|
22
22
|
},
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
25
|
+
exports.ApiPageResponse = ApiPageResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthUser =
|
|
3
|
+
exports.AuthUser = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
function AuthUser() {
|
|
6
6
|
return (0, common_1.createParamDecorator)((_data, context) => {
|
|
@@ -12,3 +12,4 @@ function AuthUser() {
|
|
|
12
12
|
return user;
|
|
13
13
|
})();
|
|
14
14
|
}
|
|
15
|
+
exports.AuthUser = AuthUser;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controller =
|
|
3
|
+
exports.Controller = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const crud_1 = require("@dataui/crud");
|
|
6
6
|
const _ = require("lodash");
|
|
@@ -8,3 +8,4 @@ function Controller(field) {
|
|
|
8
8
|
const featureName = _.upperFirst(field);
|
|
9
9
|
return (0, common_1.applyDecorators)((0, common_1.Controller)(field), (0, crud_1.Feature)(featureName));
|
|
10
10
|
}
|
|
11
|
+
exports.Controller = Controller;
|
|
@@ -1,42 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberField =
|
|
4
|
-
exports.NumberFieldOptional = NumberFieldOptional;
|
|
5
|
-
exports.StringField = StringField;
|
|
6
|
-
exports.StringFieldOptional = StringFieldOptional;
|
|
7
|
-
exports.PasswordField = PasswordField;
|
|
8
|
-
exports.PasswordFieldOptional = PasswordFieldOptional;
|
|
9
|
-
exports.BooleanField = BooleanField;
|
|
10
|
-
exports.BooleanFieldOptional = BooleanFieldOptional;
|
|
11
|
-
exports.TranslationsField = TranslationsField;
|
|
12
|
-
exports.TranslationsFieldOptional = TranslationsFieldOptional;
|
|
13
|
-
exports.TmpKeyField = TmpKeyField;
|
|
14
|
-
exports.TmpKeyFieldOptional = TmpKeyFieldOptional;
|
|
15
|
-
exports.getEnumDescription = getEnumDescription;
|
|
16
|
-
exports.EnumField = EnumField;
|
|
17
|
-
exports.ClassField = ClassField;
|
|
18
|
-
exports.EnumFieldOptional = EnumFieldOptional;
|
|
19
|
-
exports.ClassFieldOptional = ClassFieldOptional;
|
|
20
|
-
exports.EmailField = EmailField;
|
|
21
|
-
exports.EmailFieldOptional = EmailFieldOptional;
|
|
22
|
-
exports.PhoneField = PhoneField;
|
|
23
|
-
exports.PhoneFieldOptional = PhoneFieldOptional;
|
|
24
|
-
exports.UUIDField = UUIDField;
|
|
25
|
-
exports.UUIDFieldOptional = UUIDFieldOptional;
|
|
26
|
-
exports.URLField = URLField;
|
|
27
|
-
exports.URLFieldOptional = URLFieldOptional;
|
|
28
|
-
exports.FQDNField = FQDNField;
|
|
29
|
-
exports.FQDNFieldOptional = FQDNFieldOptional;
|
|
30
|
-
exports.DateField = DateField;
|
|
31
|
-
exports.DateFieldOptional = DateFieldOptional;
|
|
32
|
-
exports.IpFieldOptional = IpFieldOptional;
|
|
33
|
-
exports.IpField = IpField;
|
|
34
|
-
exports.ObjectField = ObjectField;
|
|
35
|
-
exports.ObjectFieldOptional = ObjectFieldOptional;
|
|
36
|
-
exports.TimeZoneField = TimeZoneField;
|
|
37
|
-
exports.TimeZoneFieldOptional = TimeZoneFieldOptional;
|
|
38
|
-
exports.LocaleField = LocaleField;
|
|
39
|
-
exports.LocaleFieldOptional = LocaleFieldOptional;
|
|
3
|
+
exports.LocaleFieldOptional = exports.LocaleField = exports.TimeZoneFieldOptional = exports.TimeZoneField = exports.ObjectFieldOptional = exports.ObjectField = exports.IpField = exports.IpFieldOptional = exports.DateFieldOptional = exports.DateField = exports.FQDNFieldOptional = exports.FQDNField = exports.URLFieldOptional = exports.URLField = exports.UUIDFieldOptional = exports.UUIDField = exports.PhoneFieldOptional = exports.PhoneField = exports.EmailFieldOptional = exports.EmailField = exports.ClassFieldOptional = exports.EnumFieldOptional = exports.ClassField = exports.EnumField = exports.getEnumDescription = exports.TmpKeyFieldOptional = exports.TmpKeyField = exports.TranslationsFieldOptional = exports.TranslationsField = exports.BooleanFieldOptional = exports.BooleanField = exports.PasswordFieldOptional = exports.PasswordField = exports.StringFieldOptional = exports.StringField = exports.NumberFieldOptional = exports.NumberField = void 0;
|
|
40
4
|
const common_1 = require("@nestjs/common");
|
|
41
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
42
6
|
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
@@ -97,9 +61,11 @@ function NumberField(options = {}) {
|
|
|
97
61
|
}
|
|
98
62
|
return (0, common_1.applyDecorators)(...decorators);
|
|
99
63
|
}
|
|
64
|
+
exports.NumberField = NumberField;
|
|
100
65
|
function NumberFieldOptional(options = {}) {
|
|
101
66
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), NumberField(Object.assign({ required: false }, options)));
|
|
102
67
|
}
|
|
68
|
+
exports.NumberFieldOptional = NumberFieldOptional;
|
|
103
69
|
function StringField(options = {}) {
|
|
104
70
|
var _a;
|
|
105
71
|
const decorators = [
|
|
@@ -140,9 +106,11 @@ function StringField(options = {}) {
|
|
|
140
106
|
}
|
|
141
107
|
return (0, common_1.applyDecorators)(...decorators);
|
|
142
108
|
}
|
|
109
|
+
exports.StringField = StringField;
|
|
143
110
|
function StringFieldOptional(options = {}) {
|
|
144
111
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), StringField(Object.assign({ required: false }, options)));
|
|
145
112
|
}
|
|
113
|
+
exports.StringFieldOptional = StringFieldOptional;
|
|
146
114
|
function PasswordField(options = {}) {
|
|
147
115
|
const decorators = [
|
|
148
116
|
StringField(Object.assign(Object.assign({}, options), { minLength: 6 })),
|
|
@@ -155,9 +123,11 @@ function PasswordField(options = {}) {
|
|
|
155
123
|
}
|
|
156
124
|
return (0, common_1.applyDecorators)(...decorators);
|
|
157
125
|
}
|
|
126
|
+
exports.PasswordField = PasswordField;
|
|
158
127
|
function PasswordFieldOptional(options = {}) {
|
|
159
128
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), PasswordField(Object.assign({ required: false }, options)));
|
|
160
129
|
}
|
|
130
|
+
exports.PasswordFieldOptional = PasswordFieldOptional;
|
|
161
131
|
function BooleanField(options = {}) {
|
|
162
132
|
const decorators = [
|
|
163
133
|
(0, transform_decorators_1.ToBoolean)(),
|
|
@@ -174,9 +144,11 @@ function BooleanField(options = {}) {
|
|
|
174
144
|
}
|
|
175
145
|
return (0, common_1.applyDecorators)(...decorators);
|
|
176
146
|
}
|
|
147
|
+
exports.BooleanField = BooleanField;
|
|
177
148
|
function BooleanFieldOptional(options = {}) {
|
|
178
149
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), BooleanField(Object.assign({ required: false }, options)));
|
|
179
150
|
}
|
|
151
|
+
exports.BooleanFieldOptional = BooleanFieldOptional;
|
|
180
152
|
function TranslationsField(options) {
|
|
181
153
|
const decorators = [
|
|
182
154
|
(0, class_validator_1.ArrayMinSize)(constants_1.supportedLanguageCount),
|
|
@@ -197,9 +169,11 @@ function TranslationsField(options) {
|
|
|
197
169
|
}
|
|
198
170
|
return (0, common_1.applyDecorators)(...decorators);
|
|
199
171
|
}
|
|
172
|
+
exports.TranslationsField = TranslationsField;
|
|
200
173
|
function TranslationsFieldOptional(options) {
|
|
201
174
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), TranslationsField(Object.assign({ required: false }, options)));
|
|
202
175
|
}
|
|
176
|
+
exports.TranslationsFieldOptional = TranslationsFieldOptional;
|
|
203
177
|
function TmpKeyField(options = {}) {
|
|
204
178
|
const decorators = [
|
|
205
179
|
StringField(options),
|
|
@@ -216,13 +190,16 @@ function TmpKeyField(options = {}) {
|
|
|
216
190
|
}
|
|
217
191
|
return (0, common_1.applyDecorators)(...decorators);
|
|
218
192
|
}
|
|
193
|
+
exports.TmpKeyField = TmpKeyField;
|
|
219
194
|
function TmpKeyFieldOptional(options = {}) {
|
|
220
195
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), TmpKeyField(Object.assign({ required: false }, options)));
|
|
221
196
|
}
|
|
197
|
+
exports.TmpKeyFieldOptional = TmpKeyFieldOptional;
|
|
222
198
|
function getEnumDescription(enumType) {
|
|
223
199
|
const keys = Object.keys(enumType).filter((k) => typeof enumType[k] === 'number');
|
|
224
200
|
return keys.map((k) => `${enumType[k]}: ${k}`).join(', ');
|
|
225
201
|
}
|
|
202
|
+
exports.getEnumDescription = getEnumDescription;
|
|
226
203
|
function EnumField(getEnum, options = {}) {
|
|
227
204
|
const enumValue = getEnum();
|
|
228
205
|
const decorators = [
|
|
@@ -245,6 +222,7 @@ function EnumField(getEnum, options = {}) {
|
|
|
245
222
|
}
|
|
246
223
|
return (0, common_1.applyDecorators)(...decorators);
|
|
247
224
|
}
|
|
225
|
+
exports.EnumField = EnumField;
|
|
248
226
|
function ClassField(getClass, options = {}) {
|
|
249
227
|
const classValue = getClass();
|
|
250
228
|
if (!classValue) {
|
|
@@ -271,12 +249,15 @@ function ClassField(getClass, options = {}) {
|
|
|
271
249
|
}
|
|
272
250
|
return (0, common_1.applyDecorators)(...decorators);
|
|
273
251
|
}
|
|
252
|
+
exports.ClassField = ClassField;
|
|
274
253
|
function EnumFieldOptional(getEnum, options = {}) {
|
|
275
254
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), EnumField(getEnum, Object.assign({ required: false }, options)));
|
|
276
255
|
}
|
|
256
|
+
exports.EnumFieldOptional = EnumFieldOptional;
|
|
277
257
|
function ClassFieldOptional(getClass, options = {}) {
|
|
278
258
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), ClassField(getClass, Object.assign({ required: false }, options)));
|
|
279
259
|
}
|
|
260
|
+
exports.ClassFieldOptional = ClassFieldOptional;
|
|
280
261
|
function EmailField(options = {}) {
|
|
281
262
|
var _a;
|
|
282
263
|
const decorators = [
|
|
@@ -294,9 +275,11 @@ function EmailField(options = {}) {
|
|
|
294
275
|
}
|
|
295
276
|
return (0, common_1.applyDecorators)(...decorators);
|
|
296
277
|
}
|
|
278
|
+
exports.EmailField = EmailField;
|
|
297
279
|
function EmailFieldOptional(options = {}) {
|
|
298
280
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), EmailField(Object.assign({ required: false }, options)));
|
|
299
281
|
}
|
|
282
|
+
exports.EmailFieldOptional = EmailFieldOptional;
|
|
300
283
|
function PhoneField(options = {}) {
|
|
301
284
|
const decorators = [(0, validator_decorators_1.IsPhoneNumber)(), (0, transform_decorators_1.PhoneNumberSerializer)()];
|
|
302
285
|
if (options.nullable) {
|
|
@@ -310,9 +293,11 @@ function PhoneField(options = {}) {
|
|
|
310
293
|
}
|
|
311
294
|
return (0, common_1.applyDecorators)(...decorators);
|
|
312
295
|
}
|
|
296
|
+
exports.PhoneField = PhoneField;
|
|
313
297
|
function PhoneFieldOptional(options = {}) {
|
|
314
298
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), PhoneField(Object.assign({ required: false }, options)));
|
|
315
299
|
}
|
|
300
|
+
exports.PhoneFieldOptional = PhoneFieldOptional;
|
|
316
301
|
function UUIDField(options = {}) {
|
|
317
302
|
const decorators = [
|
|
318
303
|
(0, class_transformer_1.Type)(() => String),
|
|
@@ -335,9 +320,11 @@ function UUIDField(options = {}) {
|
|
|
335
320
|
}
|
|
336
321
|
return (0, common_1.applyDecorators)(...decorators);
|
|
337
322
|
}
|
|
323
|
+
exports.UUIDField = UUIDField;
|
|
338
324
|
function UUIDFieldOptional(options = {}) {
|
|
339
325
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), UUIDField(Object.assign({ required: false }, options)));
|
|
340
326
|
}
|
|
327
|
+
exports.UUIDFieldOptional = UUIDFieldOptional;
|
|
341
328
|
function URLField(options = {}) {
|
|
342
329
|
const decorators = [StringField(Object.assign({}, options))];
|
|
343
330
|
if (options.simpleUrl) {
|
|
@@ -360,9 +347,11 @@ function URLField(options = {}) {
|
|
|
360
347
|
}
|
|
361
348
|
return (0, common_1.applyDecorators)(...decorators);
|
|
362
349
|
}
|
|
350
|
+
exports.URLField = URLField;
|
|
363
351
|
function URLFieldOptional(options = {}) {
|
|
364
352
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), URLField(Object.assign({ required: false }, options)));
|
|
365
353
|
}
|
|
354
|
+
exports.URLFieldOptional = URLFieldOptional;
|
|
366
355
|
function FQDNField(options = {}) {
|
|
367
356
|
const decorators = [
|
|
368
357
|
(0, class_validator_1.IsFQDN)(options, {
|
|
@@ -379,9 +368,11 @@ function FQDNField(options = {}) {
|
|
|
379
368
|
}
|
|
380
369
|
return (0, common_1.applyDecorators)(...decorators);
|
|
381
370
|
}
|
|
371
|
+
exports.FQDNField = FQDNField;
|
|
382
372
|
function FQDNFieldOptional(options = {}) {
|
|
383
373
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), FQDNField(Object.assign({ required: false }, options)));
|
|
384
374
|
}
|
|
375
|
+
exports.FQDNFieldOptional = FQDNFieldOptional;
|
|
385
376
|
function DateField(options = {}) {
|
|
386
377
|
const decorators = [
|
|
387
378
|
(0, class_transformer_1.Type)(() => Date),
|
|
@@ -410,12 +401,15 @@ function DateField(options = {}) {
|
|
|
410
401
|
}
|
|
411
402
|
return (0, common_1.applyDecorators)(...decorators);
|
|
412
403
|
}
|
|
404
|
+
exports.DateField = DateField;
|
|
413
405
|
function DateFieldOptional(options = {}) {
|
|
414
406
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), DateField(Object.assign(Object.assign({}, options), { required: false })));
|
|
415
407
|
}
|
|
408
|
+
exports.DateFieldOptional = DateFieldOptional;
|
|
416
409
|
function IpFieldOptional(options = {}) {
|
|
417
410
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), IpField(Object.assign({ required: false }, options)));
|
|
418
411
|
}
|
|
412
|
+
exports.IpFieldOptional = IpFieldOptional;
|
|
419
413
|
function IpField(options) {
|
|
420
414
|
const decorators = [
|
|
421
415
|
(0, class_validator_1.IsIP)(options.version || 4, {
|
|
@@ -432,6 +426,7 @@ function IpField(options) {
|
|
|
432
426
|
}
|
|
433
427
|
return (0, common_1.applyDecorators)(...decorators);
|
|
434
428
|
}
|
|
429
|
+
exports.IpField = IpField;
|
|
435
430
|
function ObjectField(options = {}) {
|
|
436
431
|
const decorators = [
|
|
437
432
|
(0, class_transformer_1.Type)(() => Object),
|
|
@@ -451,9 +446,11 @@ function ObjectField(options = {}) {
|
|
|
451
446
|
}
|
|
452
447
|
return (0, common_1.applyDecorators)(...decorators);
|
|
453
448
|
}
|
|
449
|
+
exports.ObjectField = ObjectField;
|
|
454
450
|
function ObjectFieldOptional(options = {}) {
|
|
455
451
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), ObjectField(Object.assign({ required: false }, options)));
|
|
456
452
|
}
|
|
453
|
+
exports.ObjectFieldOptional = ObjectFieldOptional;
|
|
457
454
|
function TimeZoneField(options = {}) {
|
|
458
455
|
const decorators = [
|
|
459
456
|
StringField(Object.assign({}, options)),
|
|
@@ -470,9 +467,11 @@ function TimeZoneField(options = {}) {
|
|
|
470
467
|
}
|
|
471
468
|
return (0, common_1.applyDecorators)(...decorators);
|
|
472
469
|
}
|
|
470
|
+
exports.TimeZoneField = TimeZoneField;
|
|
473
471
|
function TimeZoneFieldOptional(options = {}) {
|
|
474
472
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), TimeZoneField(Object.assign({ required: false }, options)));
|
|
475
473
|
}
|
|
474
|
+
exports.TimeZoneFieldOptional = TimeZoneFieldOptional;
|
|
476
475
|
function LocaleField(options = {}) {
|
|
477
476
|
const decorators = [
|
|
478
477
|
StringField(Object.assign({}, options)),
|
|
@@ -492,6 +491,8 @@ function LocaleField(options = {}) {
|
|
|
492
491
|
}
|
|
493
492
|
return (0, common_1.applyDecorators)(...decorators);
|
|
494
493
|
}
|
|
494
|
+
exports.LocaleField = LocaleField;
|
|
495
495
|
function LocaleFieldOptional(options = {}) {
|
|
496
496
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), LocaleField(Object.assign({ required: false }, options)));
|
|
497
497
|
}
|
|
498
|
+
exports.LocaleFieldOptional = LocaleFieldOptional;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UUIDParam =
|
|
3
|
+
exports.UUIDParam = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
function UUIDParam(property, ...pipes) {
|
|
6
6
|
return (0, common_1.Param)(property, new common_1.ParseUUIDPipe({ version: '4' }), ...pipes);
|
|
7
7
|
}
|
|
8
|
+
exports.UUIDParam = UUIDParam;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiBooleanProperty =
|
|
4
|
-
exports.ApiBooleanPropertyOptional = ApiBooleanPropertyOptional;
|
|
5
|
-
exports.ApiUUIDProperty = ApiUUIDProperty;
|
|
6
|
-
exports.ApiUUIDPropertyOptional = ApiUUIDPropertyOptional;
|
|
7
|
-
exports.ApiEnumProperty = ApiEnumProperty;
|
|
8
|
-
exports.ApiEnumPropertyOptional = ApiEnumPropertyOptional;
|
|
3
|
+
exports.ApiEnumPropertyOptional = exports.ApiEnumProperty = exports.ApiUUIDPropertyOptional = exports.ApiUUIDProperty = exports.ApiBooleanPropertyOptional = exports.ApiBooleanProperty = void 0;
|
|
9
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
10
5
|
const utils_1 = require("../common/utils");
|
|
11
6
|
const field_decorators_1 = require("../decorators/field.decorators");
|
|
12
7
|
function ApiBooleanProperty(options = {}) {
|
|
13
8
|
return (0, swagger_1.ApiProperty)(Object.assign({ type: Boolean }, options));
|
|
14
9
|
}
|
|
10
|
+
exports.ApiBooleanProperty = ApiBooleanProperty;
|
|
15
11
|
function ApiBooleanPropertyOptional(options = {}) {
|
|
16
12
|
return ApiBooleanProperty(Object.assign({ required: false }, options));
|
|
17
13
|
}
|
|
14
|
+
exports.ApiBooleanPropertyOptional = ApiBooleanPropertyOptional;
|
|
18
15
|
function ApiUUIDProperty(options = {}) {
|
|
19
16
|
return (0, swagger_1.ApiProperty)(Object.assign({ type: options.each ? [String] : String, format: 'uuid', isArray: options.each }, options));
|
|
20
17
|
}
|
|
18
|
+
exports.ApiUUIDProperty = ApiUUIDProperty;
|
|
21
19
|
function ApiUUIDPropertyOptional(options = {}) {
|
|
22
20
|
return ApiUUIDProperty(Object.assign({ required: false }, options));
|
|
23
21
|
}
|
|
22
|
+
exports.ApiUUIDPropertyOptional = ApiUUIDPropertyOptional;
|
|
24
23
|
function ApiEnumProperty(getEnum, options = {}) {
|
|
25
24
|
const enumValue = getEnum();
|
|
26
25
|
options.description = (0, field_decorators_1.getEnumDescription)(enumValue);
|
|
27
26
|
return (0, swagger_1.ApiProperty)(Object.assign({ type: 'enum', enum: enumValue, enumName: (0, utils_1.getVariableName)(getEnum) }, options));
|
|
28
27
|
}
|
|
28
|
+
exports.ApiEnumProperty = ApiEnumProperty;
|
|
29
29
|
function ApiEnumPropertyOptional(getEnum, options = {}) {
|
|
30
30
|
return ApiEnumProperty(getEnum, Object.assign({ required: false }, options));
|
|
31
31
|
}
|
|
32
|
+
exports.ApiEnumPropertyOptional = ApiEnumPropertyOptional;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiFile =
|
|
3
|
+
exports.ApiFile = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const constants_1 = require("@nestjs/common/constants");
|
|
6
6
|
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
|
|
@@ -76,3 +76,4 @@ function ApiFile(files, options = {}) {
|
|
|
76
76
|
: (0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)(file.name)));
|
|
77
77
|
return (0, common_1.applyDecorators)(RegisterModels(), (0, swagger_1.ApiConsumes)('multipart/form-data'), ApiFileDecorator(filesArray, options), ...apiFileInterceptors);
|
|
78
78
|
}
|
|
79
|
+
exports.ApiFile = ApiFile;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimestampColumn =
|
|
3
|
+
exports.TimestampColumn = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
@@ -25,3 +25,4 @@ function TimestampColumn(name, description) {
|
|
|
25
25
|
},
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
+
exports.TimestampColumn = TimestampColumn;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Trim =
|
|
4
|
-
exports.ToBoolean = ToBoolean;
|
|
5
|
-
exports.ToInt = ToInt;
|
|
6
|
-
exports.ToArray = ToArray;
|
|
7
|
-
exports.ToLowerCase = ToLowerCase;
|
|
8
|
-
exports.ToUpperCase = ToUpperCase;
|
|
9
|
-
exports.S3UrlParser = S3UrlParser;
|
|
10
|
-
exports.PhoneNumberSerializer = PhoneNumberSerializer;
|
|
3
|
+
exports.PhoneNumberSerializer = exports.S3UrlParser = exports.ToUpperCase = exports.ToLowerCase = exports.ToArray = exports.ToInt = exports.ToBoolean = exports.Trim = void 0;
|
|
11
4
|
const class_transformer_1 = require("class-transformer");
|
|
12
5
|
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
13
6
|
const lodash_1 = require("lodash");
|
|
@@ -21,6 +14,7 @@ function Trim() {
|
|
|
21
14
|
return (0, lodash_1.trim)(value).replaceAll(/\s\s+/g, ' ');
|
|
22
15
|
});
|
|
23
16
|
}
|
|
17
|
+
exports.Trim = Trim;
|
|
24
18
|
function ToBoolean() {
|
|
25
19
|
return (0, class_transformer_1.Transform)((params) => {
|
|
26
20
|
switch (params.value) {
|
|
@@ -36,12 +30,14 @@ function ToBoolean() {
|
|
|
36
30
|
}
|
|
37
31
|
}, { toClassOnly: true });
|
|
38
32
|
}
|
|
33
|
+
exports.ToBoolean = ToBoolean;
|
|
39
34
|
function ToInt() {
|
|
40
35
|
return (0, class_transformer_1.Transform)((params) => {
|
|
41
36
|
const value = params.value;
|
|
42
37
|
return Number.parseInt(value, 10);
|
|
43
38
|
}, { toClassOnly: true });
|
|
44
39
|
}
|
|
40
|
+
exports.ToInt = ToInt;
|
|
45
41
|
function ToArray() {
|
|
46
42
|
return (0, class_transformer_1.Transform)((params) => {
|
|
47
43
|
const value = params.value;
|
|
@@ -51,6 +47,7 @@ function ToArray() {
|
|
|
51
47
|
return (0, lodash_1.castArray)(value);
|
|
52
48
|
}, { toClassOnly: true });
|
|
53
49
|
}
|
|
50
|
+
exports.ToArray = ToArray;
|
|
54
51
|
function ToLowerCase() {
|
|
55
52
|
return (0, class_transformer_1.Transform)((params) => {
|
|
56
53
|
const value = params.value;
|
|
@@ -65,6 +62,7 @@ function ToLowerCase() {
|
|
|
65
62
|
toClassOnly: true,
|
|
66
63
|
});
|
|
67
64
|
}
|
|
65
|
+
exports.ToLowerCase = ToLowerCase;
|
|
68
66
|
function ToUpperCase() {
|
|
69
67
|
return (0, class_transformer_1.Transform)((params) => {
|
|
70
68
|
const value = params.value;
|
|
@@ -79,6 +77,7 @@ function ToUpperCase() {
|
|
|
79
77
|
toClassOnly: true,
|
|
80
78
|
});
|
|
81
79
|
}
|
|
80
|
+
exports.ToUpperCase = ToUpperCase;
|
|
82
81
|
function S3UrlParser() {
|
|
83
82
|
return (0, class_transformer_1.Transform)((params) => {
|
|
84
83
|
const key = params.value;
|
|
@@ -95,6 +94,8 @@ function S3UrlParser() {
|
|
|
95
94
|
}
|
|
96
95
|
});
|
|
97
96
|
}
|
|
97
|
+
exports.S3UrlParser = S3UrlParser;
|
|
98
98
|
function PhoneNumberSerializer() {
|
|
99
99
|
return (0, class_transformer_1.Transform)((params) => (0, libphonenumber_js_1.parsePhoneNumber)(params.value).number);
|
|
100
100
|
}
|
|
101
|
+
exports.PhoneNumberSerializer = PhoneNumberSerializer;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DYNAMIC_TRANSLATION_DECORATOR_KEY = exports.STATIC_TRANSLATION_DECORATOR_KEY = void 0;
|
|
4
|
-
exports.StaticTranslate = StaticTranslate;
|
|
5
|
-
exports.DynamicTranslate = DynamicTranslate;
|
|
3
|
+
exports.DynamicTranslate = exports.StaticTranslate = exports.DYNAMIC_TRANSLATION_DECORATOR_KEY = exports.STATIC_TRANSLATION_DECORATOR_KEY = void 0;
|
|
6
4
|
exports.STATIC_TRANSLATION_DECORATOR_KEY = 'custom:static-translate';
|
|
7
5
|
exports.DYNAMIC_TRANSLATION_DECORATOR_KEY = 'custom:dynamic-translate';
|
|
8
6
|
function StaticTranslate(data = {}) {
|
|
@@ -10,8 +8,10 @@ function StaticTranslate(data = {}) {
|
|
|
10
8
|
Reflect.defineMetadata(exports.STATIC_TRANSLATION_DECORATOR_KEY, data, target, key);
|
|
11
9
|
};
|
|
12
10
|
}
|
|
11
|
+
exports.StaticTranslate = StaticTranslate;
|
|
13
12
|
function DynamicTranslate() {
|
|
14
13
|
return (target, key) => {
|
|
15
14
|
Reflect.defineMetadata(exports.DYNAMIC_TRANSLATION_DECORATOR_KEY, {}, target, key);
|
|
16
15
|
};
|
|
17
16
|
}
|
|
17
|
+
exports.DynamicTranslate = DynamicTranslate;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = void 0;
|
|
4
|
-
exports.getUserData = getUserData;
|
|
3
|
+
exports.getUserData = exports.User = void 0;
|
|
5
4
|
const common_1 = require("@nestjs/common");
|
|
6
5
|
const lodash = require("lodash");
|
|
7
6
|
exports.User = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
@@ -19,3 +18,4 @@ function getUserData(req, data) {
|
|
|
19
18
|
};
|
|
20
19
|
return data ? user[data] : user;
|
|
21
20
|
}
|
|
21
|
+
exports.getUserData = getUserData;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = void 0;
|
|
4
|
-
exports.getOmniAuthData = getOmniAuthData;
|
|
3
|
+
exports.getOmniAuthData = exports.User = void 0;
|
|
5
4
|
const common_1 = require("@nestjs/common");
|
|
6
5
|
const lodash_1 = require("lodash");
|
|
7
6
|
const config_1 = require("@nestjs/config");
|
|
@@ -42,3 +41,4 @@ function getOmniAuthData(request, key) {
|
|
|
42
41
|
}
|
|
43
42
|
return key ? user[key] : user;
|
|
44
43
|
}
|
|
44
|
+
exports.getOmniAuthData = getOmniAuthData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserFilter =
|
|
3
|
+
exports.UserFilter = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const crud_1 = require("@dataui/crud");
|
|
6
6
|
const user_decorator_1 = require("./user.decorator");
|
|
@@ -13,3 +13,4 @@ function UserFilter(field) {
|
|
|
13
13
|
},
|
|
14
14
|
}));
|
|
15
15
|
}
|
|
16
|
+
exports.UserFilter = UserFilter;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsPassword =
|
|
4
|
-
exports.IsPhoneNumber = IsPhoneNumber;
|
|
5
|
-
exports.IsTmpKey = IsTmpKey;
|
|
6
|
-
exports.IsUndefinable = IsUndefinable;
|
|
7
|
-
exports.IsEmptyable = IsEmptyable;
|
|
8
|
-
exports.IsNullable = IsNullable;
|
|
9
|
-
exports.IsHttpUrl = IsHttpUrl;
|
|
3
|
+
exports.IsHttpUrl = exports.IsNullable = exports.IsEmptyable = exports.IsUndefinable = exports.IsTmpKey = exports.IsPhoneNumber = exports.IsPassword = void 0;
|
|
10
4
|
const class_validator_1 = require("class-validator");
|
|
11
5
|
const lodash_1 = require("lodash");
|
|
12
6
|
function IsPassword(validationOptions) {
|
|
@@ -25,9 +19,11 @@ function IsPassword(validationOptions) {
|
|
|
25
19
|
});
|
|
26
20
|
};
|
|
27
21
|
}
|
|
22
|
+
exports.IsPassword = IsPassword;
|
|
28
23
|
function IsPhoneNumber(validationOptions) {
|
|
29
24
|
return (0, class_validator_1.IsPhoneNumber)(validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.region, Object.assign({ message: 'error.phoneNumber' }, validationOptions));
|
|
30
25
|
}
|
|
26
|
+
exports.IsPhoneNumber = IsPhoneNumber;
|
|
31
27
|
function IsTmpKey(validationOptions) {
|
|
32
28
|
return (object, propertyName) => {
|
|
33
29
|
(0, class_validator_1.registerDecorator)({
|
|
@@ -46,17 +42,21 @@ function IsTmpKey(validationOptions) {
|
|
|
46
42
|
});
|
|
47
43
|
};
|
|
48
44
|
}
|
|
45
|
+
exports.IsTmpKey = IsTmpKey;
|
|
49
46
|
function IsUndefinable(options) {
|
|
50
47
|
return (0, class_validator_1.ValidateIf)((obj, value) => value !== undefined, options);
|
|
51
48
|
}
|
|
49
|
+
exports.IsUndefinable = IsUndefinable;
|
|
52
50
|
function IsEmptyable(options) {
|
|
53
51
|
return (0, class_validator_1.ValidateIf)((obj, value) => !(value === null ||
|
|
54
52
|
value === undefined ||
|
|
55
53
|
((0, lodash_1.isString)(value) && value.trim() === '')), options);
|
|
56
54
|
}
|
|
55
|
+
exports.IsEmptyable = IsEmptyable;
|
|
57
56
|
function IsNullable(options) {
|
|
58
57
|
return (0, class_validator_1.ValidateIf)((obj, value) => value !== null, options);
|
|
59
58
|
}
|
|
59
|
+
exports.IsNullable = IsNullable;
|
|
60
60
|
function IsHttpUrl(validationOptions) {
|
|
61
61
|
return function (object, propertyName) {
|
|
62
62
|
(0, class_validator_1.registerDecorator)({
|
|
@@ -76,3 +76,4 @@ function IsHttpUrl(validationOptions) {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
exports.IsHttpUrl = IsHttpUrl;
|
package/helpers/common.helper.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomString = void 0;
|
|
4
|
-
exports.enumToArray = enumToArray;
|
|
5
|
-
exports.getIPAdress = getIPAdress;
|
|
3
|
+
exports.getIPAdress = exports.randomString = exports.enumToArray = void 0;
|
|
6
4
|
const os_1 = require("os");
|
|
7
5
|
function enumToArray(Enum) {
|
|
8
6
|
return Object.keys(Enum)
|
|
9
7
|
.filter((key) => typeof Enum[key] === 'number')
|
|
10
8
|
.map((key) => Enum[key]);
|
|
11
9
|
}
|
|
10
|
+
exports.enumToArray = enumToArray;
|
|
12
11
|
const randomString = (length = 8, charSet) => {
|
|
13
12
|
charSet =
|
|
14
13
|
charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
@@ -34,3 +33,4 @@ function getIPAdress() {
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
}
|
|
36
|
+
exports.getIPAdress = getIPAdress;
|
package/helpers/date.helper.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.timestamp =
|
|
4
|
-
exports.strToTimeStamp = strToTimeStamp;
|
|
5
|
-
exports.getTodayTimeStamp = getTodayTimeStamp;
|
|
6
|
-
exports.unixtimestampToDate = unixtimestampToDate;
|
|
7
|
-
exports.formatDateTime = formatDateTime;
|
|
8
|
-
exports.timestampColumn = timestampColumn;
|
|
3
|
+
exports.timestampColumn = exports.formatDateTime = exports.unixtimestampToDate = exports.getTodayTimeStamp = exports.strToTimeStamp = exports.timestamp = void 0;
|
|
9
4
|
const moment = require("moment");
|
|
10
5
|
const _ = require("lodash");
|
|
11
6
|
function timestamp(value) {
|
|
@@ -14,12 +9,14 @@ function timestamp(value) {
|
|
|
14
9
|
}
|
|
15
10
|
return Math.round(value / 1000);
|
|
16
11
|
}
|
|
12
|
+
exports.timestamp = timestamp;
|
|
17
13
|
function strToTimeStamp(str) {
|
|
18
14
|
if (_.isEmpty(str)) {
|
|
19
15
|
return 0;
|
|
20
16
|
}
|
|
21
17
|
return moment(str).unix();
|
|
22
18
|
}
|
|
19
|
+
exports.strToTimeStamp = strToTimeStamp;
|
|
23
20
|
function getTodayTimeStamp() {
|
|
24
21
|
const startTime = strToTimeStamp(moment().format('YYYY-MM-DD 00:00:00'));
|
|
25
22
|
const endTime = strToTimeStamp(moment().format('YYYY-MM-DD 23:59:59'));
|
|
@@ -28,9 +25,11 @@ function getTodayTimeStamp() {
|
|
|
28
25
|
endTime,
|
|
29
26
|
};
|
|
30
27
|
}
|
|
28
|
+
exports.getTodayTimeStamp = getTodayTimeStamp;
|
|
31
29
|
function unixtimestampToDate(value) {
|
|
32
30
|
return moment(value * 1000).toDate();
|
|
33
31
|
}
|
|
32
|
+
exports.unixtimestampToDate = unixtimestampToDate;
|
|
34
33
|
function formatDateTime(value, format = 'YYYY-MM-DD HH:mm:ss', holder = '') {
|
|
35
34
|
if (value === 'now') {
|
|
36
35
|
return moment().format(format);
|
|
@@ -43,6 +42,7 @@ function formatDateTime(value, format = 'YYYY-MM-DD HH:mm:ss', holder = '') {
|
|
|
43
42
|
}
|
|
44
43
|
return holder;
|
|
45
44
|
}
|
|
45
|
+
exports.formatDateTime = formatDateTime;
|
|
46
46
|
function timestampColumn(name) {
|
|
47
47
|
return {
|
|
48
48
|
type: 'int',
|
|
@@ -55,3 +55,4 @@ function timestampColumn(name) {
|
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
exports.timestampColumn = timestampColumn;
|