@nest-yalc-2/utils 1.0.0 → 2.1.0
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/package.json +1 -1
- package/src/__tests__/object-mapper.helper.spec.ts +1 -1
- package/src/__tests__/object-mapper.interceptor.spec.ts +1 -1
- package/src/index.d.ts +19 -19
- package/src/index.js +22 -35
- package/src/index.js.map +1 -1
- package/src/index.ts +21 -21
- package/src/object-mapper.interceptor.d.ts +1 -1
- package/src/object-mapper.interceptor.js +5 -10
- package/src/object-mapper.interceptor.js.map +1 -1
- package/src/object-mapper.interceptor.ts +1 -1
- package/src/simple-mapper.interceptor.js +2 -7
- package/src/simple-mapper.interceptor.js.map +1 -1
- package/src/__mocks__/enum.mock.ts +0 -9
- package/src/__tests__/class.helper.spec.ts +0 -32
- package/src/__tests__/command.helper.spec.ts +0 -35
- package/src/__tests__/config-manager.helper.spec.ts +0 -93
- package/src/__tests__/custom-validator.spec.ts +0 -34
- package/src/__tests__/data-structure.helper.spec.ts +0 -30
- package/src/__tests__/date.helper.spec.ts +0 -78
- package/src/__tests__/encryption.helper.spec.ts +0 -45
- package/src/__tests__/enum.helper.spec.ts +0 -53
- package/src/__tests__/env.helper.spec.ts +0 -68
- package/src/__tests__/error.helper.spec.ts +0 -20
- package/src/__tests__/faker-helper.spec.ts +0 -187
- package/src/__tests__/files.helper.spec.ts +0 -22
- package/src/__tests__/http.helper.spec.ts +0 -15
- package/src/__tests__/interval.helper.spec.ts +0 -29
- package/src/__tests__/math.helper.spec.ts +0 -24
- package/src/__tests__/object.helper.spec.ts +0 -181
- package/src/__tests__/plugin.helper.spec.ts +0 -85
- package/src/__tests__/promise.helper.spec.ts +0 -76
- package/src/__tests__/returnValue.spec.ts +0 -49
- package/src/__tests__/rxjs.helper.spec.ts +0 -79
- package/src/__tests__/tsconfig.json +0 -3
- package/src/__tests__/validator-helper.spec.ts +0 -34
- package/src/__tests__/zlib.helper.spec.ts +0 -20
- package/src/class.helper.d.ts +0 -4
- package/src/class.helper.js +0 -19
- package/src/class.helper.js.map +0 -1
- package/src/class.helper.ts +0 -33
- package/src/command.helper.d.ts +0 -1
- package/src/command.helper.js +0 -16
- package/src/command.helper.js.map +0 -1
- package/src/command.helper.ts +0 -19
- package/src/config-manager.helper.d.ts +0 -12
- package/src/config-manager.helper.js +0 -60
- package/src/config-manager.helper.js.map +0 -1
- package/src/config-manager.helper.ts +0 -122
- package/src/custom-validator.d.ts +0 -3
- package/src/custom-validator.js +0 -13
- package/src/custom-validator.js.map +0 -1
- package/src/custom-validator.ts +0 -13
- package/src/data-structure.helper.d.ts +0 -1
- package/src/data-structure.helper.js +0 -13
- package/src/data-structure.helper.js.map +0 -1
- package/src/data-structure.helper.ts +0 -14
- package/src/date.helper.d.ts +0 -12
- package/src/date.helper.js +0 -47
- package/src/date.helper.js.map +0 -1
- package/src/date.helper.ts +0 -65
- package/src/encryption.helper.d.ts +0 -2
- package/src/encryption.helper.js +0 -58
- package/src/encryption.helper.js.map +0 -1
- package/src/encryption.helper.ts +0 -29
- package/src/enum.helper.d.ts +0 -8
- package/src/enum.helper.js +0 -21
- package/src/enum.helper.js.map +0 -1
- package/src/enum.helper.ts +0 -34
- package/src/env.helper.d.ts +0 -3
- package/src/env.helper.js +0 -23
- package/src/env.helper.js.map +0 -1
- package/src/env.helper.ts +0 -35
- package/src/error.helper.d.ts +0 -1
- package/src/error.helper.js +0 -12
- package/src/error.helper.js.map +0 -1
- package/src/error.helper.ts +0 -12
- package/src/faker-helper.d.ts +0 -16
- package/src/faker-helper.js +0 -73
- package/src/faker-helper.js.map +0 -1
- package/src/faker-helper.ts +0 -98
- package/src/files.helper.d.ts +0 -2
- package/src/files.helper.js +0 -13
- package/src/files.helper.js.map +0 -1
- package/src/files.helper.ts +0 -20
- package/src/http.helper.d.ts +0 -26
- package/src/http.helper.js +0 -84
- package/src/http.helper.js.map +0 -1
- package/src/http.helper.ts +0 -152
- package/src/interval.helper.d.ts +0 -5
- package/src/interval.helper.js +0 -16
- package/src/interval.helper.js.map +0 -1
- package/src/interval.helper.ts +0 -13
- package/src/math.helper.d.ts +0 -1
- package/src/math.helper.js +0 -8
- package/src/math.helper.js.map +0 -1
- package/src/math.helper.ts +0 -4
- package/src/nest.decorator.d.ts +0 -3
- package/src/nest.decorator.js +0 -10
- package/src/nest.decorator.js.map +0 -1
- package/src/nest.decorator.ts +0 -10
- package/src/object-mapper.helper.d.ts +0 -16
- package/src/object-mapper.helper.js +0 -47
- package/src/object-mapper.helper.js.map +0 -1
- package/src/object-mapper.helper.ts +0 -148
- package/src/object.helper.d.ts +0 -18
- package/src/object.helper.js +0 -91
- package/src/object.helper.js.map +0 -1
- package/src/object.helper.ts +0 -173
- package/src/plugin.helper.d.ts +0 -22
- package/src/plugin.helper.js +0 -26
- package/src/plugin.helper.js.map +0 -1
- package/src/plugin.helper.ts +0 -42
- package/src/promise.helper.d.ts +0 -13
- package/src/promise.helper.js +0 -71
- package/src/promise.helper.js.map +0 -1
- package/src/promise.helper.ts +0 -65
- package/src/returnValue.d.ts +0 -14
- package/src/returnValue.js +0 -17
- package/src/returnValue.js.map +0 -1
- package/src/returnValue.ts +0 -26
- package/src/rxjs.helper.d.ts +0 -7
- package/src/rxjs.helper.js +0 -33
- package/src/rxjs.helper.js.map +0 -1
- package/src/rxjs.helper.ts +0 -71
- package/src/validator-helper.d.ts +0 -2
- package/src/validator-helper.js +0 -22
- package/src/validator-helper.js.map +0 -1
- package/src/validator-helper.ts +0 -26
- package/src/zlib.helper.d.ts +0 -3
- package/src/zlib.helper.js +0 -25
- package/src/zlib.helper.js.map +0 -1
- package/src/zlib.helper.ts +0 -19
package/src/date.helper.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateHelper = void 0;
|
|
4
|
-
class DateHelper {
|
|
5
|
-
static getWeekEdgeDates() {
|
|
6
|
-
const currentDate = Date.now();
|
|
7
|
-
const weekInMs = 1000 * 60 * 60 * 24 * 7;
|
|
8
|
-
const startDate = new Date(new Date(currentDate).getTime() - weekInMs);
|
|
9
|
-
const endDate = new Date(currentDate);
|
|
10
|
-
const startDateMonth = DateHelper.formatMonth(startDate.getMonth());
|
|
11
|
-
const startDateDay = DateHelper.formatDay(startDate.getDate());
|
|
12
|
-
const endDateMonth = DateHelper.formatMonth(endDate.getMonth());
|
|
13
|
-
const endDateDay = DateHelper.formatDay(endDate.getDate());
|
|
14
|
-
const queryStartDate = `${startDate.getFullYear()}-${startDateMonth}-${startDateDay}`;
|
|
15
|
-
const queryEndDate = `${endDate.getFullYear()}-${endDateMonth}-${endDateDay}`;
|
|
16
|
-
return { startDate: queryStartDate, endDate: queryEndDate };
|
|
17
|
-
}
|
|
18
|
-
static formatMonth(month) {
|
|
19
|
-
const fixedMonth = month + 1;
|
|
20
|
-
return fixedMonth < 10 ? `0${fixedMonth}` : `${fixedMonth}`;
|
|
21
|
-
}
|
|
22
|
-
static formatDay(day) {
|
|
23
|
-
return day < 10 ? `0${day}` : `${day}`;
|
|
24
|
-
}
|
|
25
|
-
static subsMinutes(date, minutes) {
|
|
26
|
-
const result = new Date(date.getTime());
|
|
27
|
-
result.setMinutes(result.getMinutes() - minutes);
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
static addMinutes(date, minutes) {
|
|
31
|
-
const result = new Date(date.getTime());
|
|
32
|
-
result.setMinutes(result.getMinutes() + minutes);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
static dateToSQLDateTime(date) {
|
|
36
|
-
return date.toISOString().slice(0, 19).replace('T', ' ');
|
|
37
|
-
}
|
|
38
|
-
static dateToPlainISO(date) {
|
|
39
|
-
return date
|
|
40
|
-
.toISOString()
|
|
41
|
-
.replace(/:/g, '')
|
|
42
|
-
.replace(/-/g, '')
|
|
43
|
-
.replace(/\./g, '');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.DateHelper = DateHelper;
|
|
47
|
-
//# sourceMappingURL=date.helper.js.map
|
package/src/date.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date.helper.js","sourceRoot":"","sources":["date.helper.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAKrB,MAAM,CAAC,gBAAgB;QACrB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;QAEtC,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpE,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;QAE/D,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhE,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAE3D,MAAM,cAAc,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,cAAc,IAAI,YAAY,EAAE,CAAC;QAEtF,MAAM,YAAY,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;QAE9E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAC9D,CAAC;IAOD,MAAM,CAAC,WAAW,CAAC,KAAa;QAC9B,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,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
|
-
export class DateHelper {
|
|
2
|
-
/**
|
|
3
|
-
* Function that returns interface of startDate being current date and endDate being 1 week earlier
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
static getWeekEdgeDates(): { startDate: string; endDate: string } {
|
|
7
|
-
const currentDate = Date.now();
|
|
8
|
-
const weekInMs = 1000 * 60 * 60 * 24 * 7;
|
|
9
|
-
|
|
10
|
-
const startDate = new Date(new Date(currentDate).getTime() - weekInMs);
|
|
11
|
-
const endDate = new Date(currentDate);
|
|
12
|
-
|
|
13
|
-
const startDateMonth = DateHelper.formatMonth(startDate.getMonth());
|
|
14
|
-
|
|
15
|
-
const startDateDay = DateHelper.formatDay(startDate.getDate());
|
|
16
|
-
|
|
17
|
-
const endDateMonth = DateHelper.formatMonth(endDate.getMonth());
|
|
18
|
-
|
|
19
|
-
const endDateDay = DateHelper.formatDay(endDate.getDate());
|
|
20
|
-
|
|
21
|
-
const queryStartDate = `${startDate.getFullYear()}-${startDateMonth}-${startDateDay}`;
|
|
22
|
-
|
|
23
|
-
const queryEndDate = `${endDate.getFullYear()}-${endDateMonth}-${endDateDay}`;
|
|
24
|
-
|
|
25
|
-
return { startDate: queryStartDate, endDate: queryEndDate };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param num number of day or month
|
|
31
|
-
* @returns formatted number, like 3rd month (number 3 passed) returns string '03'
|
|
32
|
-
*/
|
|
33
|
-
static formatMonth(month: number): string {
|
|
34
|
-
const fixedMonth = month + 1;
|
|
35
|
-
return fixedMonth < 10 ? `0${fixedMonth}` : `${fixedMonth}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static formatDay(day: number): string {
|
|
39
|
-
return day < 10 ? `0${day}` : `${day}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static subsMinutes(date: Date, minutes: number): Date {
|
|
43
|
-
const result = new Date(date.getTime());
|
|
44
|
-
result.setMinutes(result.getMinutes() - minutes);
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static addMinutes(date: Date, minutes: number): Date {
|
|
49
|
-
const result = new Date(date.getTime());
|
|
50
|
-
result.setMinutes(result.getMinutes() + minutes);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static dateToSQLDateTime(date: Date) {
|
|
55
|
-
return date.toISOString().slice(0, 19).replace('T', ' ');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static dateToPlainISO(date: Date) {
|
|
59
|
-
return date
|
|
60
|
-
.toISOString()
|
|
61
|
-
.replace(/:/g, '')
|
|
62
|
-
.replace(/-/g, '')
|
|
63
|
-
.replace(/\./g, '');
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/encryption.helper.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.decryptAes = exports.encryptAes = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const encryptAes = (toEncrypt, key) => {
|
|
39
|
-
const iv = crypto.randomBytes(16);
|
|
40
|
-
const cipher = crypto.createCipheriv('aes-256-ctr', Buffer.from(key, 'hex'), iv);
|
|
41
|
-
let encrypted = cipher.update(toEncrypt, 'utf8', 'hex');
|
|
42
|
-
encrypted += cipher.final('hex');
|
|
43
|
-
return iv.toString('hex') + ':' + encrypted;
|
|
44
|
-
};
|
|
45
|
-
exports.encryptAes = encryptAes;
|
|
46
|
-
const decryptAes = (toDecrypt, key) => {
|
|
47
|
-
if (toDecrypt === '') {
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
const split = toDecrypt.split(':');
|
|
51
|
-
const iv = split[0];
|
|
52
|
-
const decipher = crypto.createDecipheriv('aes-256-ctr', Buffer.from(key, 'hex'), Buffer.from(iv, 'hex'));
|
|
53
|
-
let decrypted = decipher.update(split[1], 'hex', 'utf8');
|
|
54
|
-
decrypted += decipher.final('utf8');
|
|
55
|
-
return decrypted;
|
|
56
|
-
};
|
|
57
|
-
exports.decryptAes = decryptAes;
|
|
58
|
-
//# sourceMappingURL=encryption.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAdW,QAAA,UAAU,cAcrB"}
|
package/src/encryption.helper.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
export const encryptAes = (toEncrypt: string, key: string) => {
|
|
4
|
-
const iv = crypto.randomBytes(16);
|
|
5
|
-
const cipher = crypto.createCipheriv(
|
|
6
|
-
'aes-256-ctr',
|
|
7
|
-
Buffer.from(key, 'hex'),
|
|
8
|
-
iv,
|
|
9
|
-
);
|
|
10
|
-
let encrypted = cipher.update(toEncrypt, 'utf8', 'hex');
|
|
11
|
-
encrypted += cipher.final('hex');
|
|
12
|
-
return iv.toString('hex') + ':' + encrypted;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const decryptAes = (toDecrypt: string, key: string) => {
|
|
16
|
-
if (toDecrypt === '') {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
const split = toDecrypt.split(':');
|
|
20
|
-
const iv = split[0];
|
|
21
|
-
const decipher = crypto.createDecipheriv(
|
|
22
|
-
'aes-256-ctr',
|
|
23
|
-
Buffer.from(key, 'hex'),
|
|
24
|
-
Buffer.from(iv, 'hex'),
|
|
25
|
-
);
|
|
26
|
-
let decrypted = decipher.update(split[1], 'hex', 'utf8');
|
|
27
|
-
decrypted += decipher.final('utf8');
|
|
28
|
-
return decrypted;
|
|
29
|
-
};
|
package/src/enum.helper.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Spread } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
export declare const belongsToEnum: <T extends Record<string, string | number>>(enumObj: T, value: string | number) => boolean;
|
|
3
|
-
type Merge<T extends readonly any[]> = T extends readonly [infer H, ...infer R] ? Spread<H, Merge<R>> : {};
|
|
4
|
-
export declare const mergeEnums: <T extends any[]>(...enums: T) => Merge<T>;
|
|
5
|
-
export declare const getEnumValueByEnumKey: <T extends {
|
|
6
|
-
[index: string]: string;
|
|
7
|
-
}>(myEnum: T, enumKey: string | undefined) => any | null;
|
|
8
|
-
export {};
|
package/src/enum.helper.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEnumValueByEnumKey = exports.mergeEnums = exports.belongsToEnum = void 0;
|
|
4
|
-
const belongsToEnum = (enumObj, value) => {
|
|
5
|
-
return Object.values(enumObj).includes(value);
|
|
6
|
-
};
|
|
7
|
-
exports.belongsToEnum = belongsToEnum;
|
|
8
|
-
const mergeEnums = (...enums) => {
|
|
9
|
-
let merged = {};
|
|
10
|
-
enums.forEach((e) => (merged = { ...merged, ...e }));
|
|
11
|
-
return merged;
|
|
12
|
-
};
|
|
13
|
-
exports.mergeEnums = mergeEnums;
|
|
14
|
-
const getEnumValueByEnumKey = (myEnum, enumKey) => {
|
|
15
|
-
if (!enumKey)
|
|
16
|
-
return undefined;
|
|
17
|
-
const idx = Object.keys(myEnum).find((x) => x === enumKey);
|
|
18
|
-
return idx ? myEnum[idx] : undefined;
|
|
19
|
-
};
|
|
20
|
-
exports.getEnumValueByEnumKey = getEnumValueByEnumKey;
|
|
21
|
-
//# sourceMappingURL=enum.helper.js.map
|
package/src/enum.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enum.helper.js","sourceRoot":"","sources":["enum.helper.ts"],"names":[],"mappings":";;;AAQO,MAAM,aAAa,GAAG,CAC3B,OAAU,EACV,KAAsB,EACb,EAAE;IACX,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB;AAOK,MAAM,UAAU,GAAG,CAAkB,GAAG,KAAQ,EAAE,EAAE;IACzD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,OAAO,MAAyB,CAAC;AACnC,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEK,MAAM,qBAAqB,GAAG,CACnC,MAAS,EACT,OAA2B,EACf,EAAE;IACd,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvC,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
package/src/enum.helper.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Spread } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Used to check if a value is contained in a enum object
|
|
5
|
-
* @param enumObj
|
|
6
|
-
* @param value
|
|
7
|
-
* @returns `boolean`
|
|
8
|
-
*/
|
|
9
|
-
export const belongsToEnum = <T extends Record<string, string | number>>(
|
|
10
|
-
enumObj: T,
|
|
11
|
-
value: string | number,
|
|
12
|
-
): boolean => {
|
|
13
|
-
return Object.values(enumObj).includes(value);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type Merge<T extends readonly any[]> = T extends readonly [infer H, ...infer R]
|
|
17
|
-
? Spread<H, Merge<R>>
|
|
18
|
-
: // eslint-disable-next-line @typescript-eslint/ban-types
|
|
19
|
-
{};
|
|
20
|
-
|
|
21
|
-
export const mergeEnums = <T extends any[]>(...enums: T) => {
|
|
22
|
-
let merged = {};
|
|
23
|
-
enums.forEach((e) => (merged = { ...merged, ...e }));
|
|
24
|
-
return merged as any as Merge<T>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const getEnumValueByEnumKey = <T extends { [index: string]: string }>(
|
|
28
|
-
myEnum: T,
|
|
29
|
-
enumKey: string | undefined,
|
|
30
|
-
): any | null => {
|
|
31
|
-
if (!enumKey) return undefined;
|
|
32
|
-
const idx = Object.keys(myEnum).find((x) => x === enumKey);
|
|
33
|
-
return idx ? myEnum[idx] : undefined;
|
|
34
|
-
};
|
package/src/env.helper.d.ts
DELETED
package/src/env.helper.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.envToArray = void 0;
|
|
4
|
-
exports.envIsTrue = envIsTrue;
|
|
5
|
-
exports.isProduction = isProduction;
|
|
6
|
-
const envToArray = (key) => {
|
|
7
|
-
if (process.env[key] === '')
|
|
8
|
-
return [];
|
|
9
|
-
return (process.env[key]?.split(',').map((v) => v.trim()) ?? []);
|
|
10
|
-
};
|
|
11
|
-
exports.envToArray = envToArray;
|
|
12
|
-
function envIsTrue(value) {
|
|
13
|
-
if (!value)
|
|
14
|
-
return false;
|
|
15
|
-
const val = value.toLowerCase();
|
|
16
|
-
return val === 'true' || val === '1' || val === 'on';
|
|
17
|
-
}
|
|
18
|
-
function isProduction(implicitCheck = true) {
|
|
19
|
-
return (process.env.NODE_ENV === 'production' ||
|
|
20
|
-
(implicitCheck &&
|
|
21
|
-
['test', 'pipeline', 'development'].every((v) => process.env.NODE_ENV !== v)));
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=env.helper.js.map
|
package/src/env.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.helper.js","sourceRoot":"","sources":["env.helper.ts"],"names":[],"mappings":";;;AAaA,8BAKC;AAQD,oCAQC;AA9BM,MAAM,UAAU,GAAG,CAAI,GAAW,EAAO,EAAE;IAEhD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAEvC,OAAO,CACU,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAE,IAAI,EAAE,CACxE,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,UAAU,cAOrB;AAEF,SAAgB,SAAS,CAAC,KAAc;IACtC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC;AACvD,CAAC;AAQD,SAAgB,YAAY,CAAC,aAAa,GAAG,IAAI;IAC/C,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACrC,CAAC,aAAa;YACZ,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,KAAK,CACvC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,CAClC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
package/src/env.helper.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This method can be used to convert a comma separated list of elements from process.env to an array
|
|
3
|
-
* @param key
|
|
4
|
-
*/
|
|
5
|
-
export const envToArray = <T>(key: string): T[] => {
|
|
6
|
-
// for testing purpose we need to specify only the case of empty string here
|
|
7
|
-
if (process.env[key] === '') return [];
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<T[]>(<unknown>process.env[key]?.split(',').map((v) => v.trim())) ?? []
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function envIsTrue(value?: string) {
|
|
15
|
-
if (!value) return false;
|
|
16
|
-
|
|
17
|
-
const val = value.toLowerCase();
|
|
18
|
-
return val === 'true' || val === '1' || val === 'on';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Check that the current env is in production by
|
|
23
|
-
* checking the explicit case first, and the implicit case after (if requested)
|
|
24
|
-
* @param implicitCheck enable implicit check by default
|
|
25
|
-
* @returns boolean
|
|
26
|
-
*/
|
|
27
|
-
export function isProduction(implicitCheck = true) {
|
|
28
|
-
return (
|
|
29
|
-
process.env.NODE_ENV === 'production' ||
|
|
30
|
-
(implicitCheck &&
|
|
31
|
-
['test', 'pipeline', 'development'].every(
|
|
32
|
-
(v) => process.env.NODE_ENV !== v,
|
|
33
|
-
))
|
|
34
|
-
);
|
|
35
|
-
}
|
package/src/error.helper.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function throwWrap(error: any): never;
|
package/src/error.helper.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwWrap = throwWrap;
|
|
4
|
-
function throwWrap(error) {
|
|
5
|
-
if (error instanceof Error) {
|
|
6
|
-
throw error;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
throw new Error(error);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=error.helper.js.map
|
package/src/error.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.helper.js","sourceRoot":"","sources":["error.helper.ts"],"names":[],"mappings":";;AAKA,8BAMC;AAND,SAAgB,SAAS,CAAC,KAAU;IAClC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC;IACd,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,KAAe,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/src/error.helper.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If the argument of the function is an instance of Error the function throw it,
|
|
3
|
-
* else it throw a new error instance
|
|
4
|
-
* @throws a wrapped error, avoiding a double wrap of the error
|
|
5
|
-
*/
|
|
6
|
-
export function throwWrap(error: any): never {
|
|
7
|
-
if (error instanceof Error) {
|
|
8
|
-
throw error;
|
|
9
|
-
} else {
|
|
10
|
-
throw new Error(error as string);
|
|
11
|
-
}
|
|
12
|
-
}
|
package/src/faker-helper.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const DEF_FAKER_MAX_RETRIES = 1500;
|
|
2
|
-
export declare const DEF_FAKER_MAX_TIME = 250;
|
|
3
|
-
export declare class FakerHelper {
|
|
4
|
-
private readonly generatedEmails;
|
|
5
|
-
createPerson(): {
|
|
6
|
-
gender: string;
|
|
7
|
-
firstName: string;
|
|
8
|
-
lastName: string;
|
|
9
|
-
email: string;
|
|
10
|
-
};
|
|
11
|
-
generateNewEmail(firstName: string, lastName: string, provider?: string): string;
|
|
12
|
-
randomFromEnum<T extends Record<string, string | number>>(inputEnum: T): T[keyof T];
|
|
13
|
-
randomDecimal: (min: number, max: number, precision: number) => string;
|
|
14
|
-
randomBirthDate: (start?: number, end?: number) => string;
|
|
15
|
-
randomLockDate: () => Date | undefined;
|
|
16
|
-
}
|
package/src/faker-helper.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FakerHelper = exports.DEF_FAKER_MAX_TIME = exports.DEF_FAKER_MAX_RETRIES = void 0;
|
|
4
|
-
const faker_1 = require("@faker-js/faker");
|
|
5
|
-
exports.DEF_FAKER_MAX_RETRIES = 1500;
|
|
6
|
-
exports.DEF_FAKER_MAX_TIME = 250;
|
|
7
|
-
class FakerHelper {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.generatedEmails = new Set();
|
|
10
|
-
this.randomDecimal = (min, max, precision) => {
|
|
11
|
-
return faker_1.faker.number
|
|
12
|
-
.float({ multipleOf: precision, min: min, max: max })
|
|
13
|
-
.toString();
|
|
14
|
-
};
|
|
15
|
-
this.randomBirthDate = (start = 18, end = 100) => {
|
|
16
|
-
const birthDate = faker_1.faker.date.past({ years: end - start });
|
|
17
|
-
birthDate.setUTCFullYear(birthDate.getUTCFullYear() - start);
|
|
18
|
-
const yyyy = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(birthDate);
|
|
19
|
-
const mm = new Intl.DateTimeFormat('en', { month: 'numeric' }).format(birthDate);
|
|
20
|
-
const dd = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(birthDate);
|
|
21
|
-
return `${yyyy}-${mm}-${dd}`;
|
|
22
|
-
};
|
|
23
|
-
this.randomLockDate = () => {
|
|
24
|
-
const random = faker_1.faker.number.int(2);
|
|
25
|
-
if (random === 0) {
|
|
26
|
-
return faker_1.faker.date.past({ years: 3 });
|
|
27
|
-
}
|
|
28
|
-
else if (random === 1) {
|
|
29
|
-
return faker_1.faker.date.future({ years: 1 });
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
createPerson() {
|
|
37
|
-
const gender = faker_1.faker.number.int(1) === 0 ? 'male' : 'female';
|
|
38
|
-
const firstName = faker_1.faker.person.firstName(gender);
|
|
39
|
-
const lastName = faker_1.faker.person.lastName(gender);
|
|
40
|
-
return {
|
|
41
|
-
gender,
|
|
42
|
-
firstName,
|
|
43
|
-
lastName,
|
|
44
|
-
email: this.generateNewEmail(firstName, lastName, 'gmail.test'),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
generateNewEmail(firstName, lastName, provider) {
|
|
48
|
-
const startTime = Date.now();
|
|
49
|
-
for (let attempt = 0; attempt < exports.DEF_FAKER_MAX_RETRIES; attempt++) {
|
|
50
|
-
const email = faker_1.faker.internet.email({ firstName, lastName, provider });
|
|
51
|
-
if (!this.generatedEmails.has(email)) {
|
|
52
|
-
this.generatedEmails.add(email);
|
|
53
|
-
return email;
|
|
54
|
-
}
|
|
55
|
-
if (Date.now() - startTime > exports.DEF_FAKER_MAX_TIME) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const fallbackEmail = faker_1.faker.internet.email({
|
|
60
|
-
firstName,
|
|
61
|
-
lastName,
|
|
62
|
-
provider,
|
|
63
|
-
});
|
|
64
|
-
this.generatedEmails.add(fallbackEmail);
|
|
65
|
-
return fallbackEmail;
|
|
66
|
-
}
|
|
67
|
-
randomFromEnum(inputEnum) {
|
|
68
|
-
const randInt = faker_1.faker.number.int(Object.keys(inputEnum).length - 1);
|
|
69
|
-
return inputEnum[Object.keys(inputEnum)[randInt]];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.FakerHelper = FakerHelper;
|
|
73
|
-
//# sourceMappingURL=faker-helper.js.map
|
package/src/faker-helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"faker-helper.js","sourceRoot":"","sources":["faker-helper.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAK3B,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC7B,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEtC,MAAa,WAAW;IAAxB;QACmB,oBAAe,GAAG,IAAI,GAAG,EAAU,CAAC;QAiDrD,kBAAa,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,SAAiB,EAAU,EAAE;YACtE,OAAO,aAAK,CAAC,MAAM;iBAChB,KAAK,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;iBACpD,QAAQ,EAAE,CAAC;QAChB,CAAC,CAAC;QAIF,oBAAe,G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AC;QACxC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,cAAc,CACZ,SAAY;QAEZ,MAAM,OAAO,GAAG,aAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpE,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAA2B,CAAC,CAAC;IAC9E,CAAC;CAyCF;AAzFD,kCAyFC"}
|
package/src/faker-helper.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { faker } from '@faker-js/faker';
|
|
2
|
-
|
|
3
|
-
// TODO: Probably we can use the internal faker of typeorm-seeding to create uniqueness, like we do here
|
|
4
|
-
// (mentioned in https://github.com/w3tecch/typeorm-seeding/issues/98#issuecomment-849585576)
|
|
5
|
-
|
|
6
|
-
export const DEF_FAKER_MAX_RETRIES = 1500;
|
|
7
|
-
export const DEF_FAKER_MAX_TIME = 250;
|
|
8
|
-
|
|
9
|
-
export class FakerHelper {
|
|
10
|
-
private readonly generatedEmails = new Set<string>();
|
|
11
|
-
|
|
12
|
-
// We could also create a new email from the same person,
|
|
13
|
-
// however we assume when this function is called we actually want a different person.
|
|
14
|
-
createPerson() {
|
|
15
|
-
const gender = faker.number.int(1) === 0 ? 'male' : 'female';
|
|
16
|
-
const firstName = faker.person.firstName(gender);
|
|
17
|
-
const lastName = faker.person.lastName(gender);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
gender,
|
|
21
|
-
firstName,
|
|
22
|
-
lastName,
|
|
23
|
-
email: this.generateNewEmail(firstName, lastName, 'gmail.test'),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
generateNewEmail(firstName: string, lastName: string, provider?: string) {
|
|
28
|
-
const startTime = Date.now();
|
|
29
|
-
|
|
30
|
-
for (let attempt = 0; attempt < DEF_FAKER_MAX_RETRIES; attempt++) {
|
|
31
|
-
const email = faker.internet.email({ firstName, lastName, provider });
|
|
32
|
-
|
|
33
|
-
if (!this.generatedEmails.has(email)) {
|
|
34
|
-
this.generatedEmails.add(email);
|
|
35
|
-
return email;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (Date.now() - startTime > DEF_FAKER_MAX_TIME) {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const fallbackEmail = faker.internet.email({
|
|
44
|
-
firstName,
|
|
45
|
-
lastName,
|
|
46
|
-
provider,
|
|
47
|
-
});
|
|
48
|
-
this.generatedEmails.add(fallbackEmail);
|
|
49
|
-
return fallbackEmail;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
randomFromEnum<T extends Record<string, string | number>>(
|
|
53
|
-
inputEnum: T,
|
|
54
|
-
): T[keyof T] {
|
|
55
|
-
const randInt = faker.number.int(Object.keys(inputEnum).length - 1);
|
|
56
|
-
return inputEnum[Object.keys(inputEnum)[randInt] as keyof typeof inputEnum];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
randomDecimal = (min: number, max: number, precision: number): string => {
|
|
60
|
-
return faker.number
|
|
61
|
-
.float({ multipleOf: precision, min: min, max: max })
|
|
62
|
-
.toString();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Creates a random birthdate for people between 18-82 years of age.
|
|
66
|
-
// Date is returned in format YYYY-MM-DD
|
|
67
|
-
randomBirthDate = (start = 18, end = 100) => {
|
|
68
|
-
const birthDate = faker.date.past({ years: end - start });
|
|
69
|
-
birthDate.setUTCFullYear(birthDate.getUTCFullYear() - start);
|
|
70
|
-
// const [mm, dd, yyyy] = birthDate.format('yyyy-MM-dd').toLocaleString().split(',')[0].split('/');
|
|
71
|
-
const yyyy = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(
|
|
72
|
-
birthDate,
|
|
73
|
-
);
|
|
74
|
-
const mm = new Intl.DateTimeFormat('en', { month: 'numeric' }).format(
|
|
75
|
-
birthDate,
|
|
76
|
-
);
|
|
77
|
-
const dd = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(
|
|
78
|
-
birthDate,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return `${yyyy}-${mm}-${dd}`;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Returns one of three values:
|
|
85
|
-
// * a date in the past (expired lock)
|
|
86
|
-
// * a date in the future (locked till then)
|
|
87
|
-
// * null (db)/undefined (in code) (no locks)
|
|
88
|
-
randomLockDate = () => {
|
|
89
|
-
const random = faker.number.int(2);
|
|
90
|
-
if (random === 0) {
|
|
91
|
-
return faker.date.past({ years: 3 });
|
|
92
|
-
} else if (random === 1) {
|
|
93
|
-
return faker.date.future({ years: 1 });
|
|
94
|
-
} else {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
package/src/files.helper.d.ts
DELETED
package/src/files.helper.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__filename = __filename;
|
|
4
|
-
exports.___dirname = ___dirname;
|
|
5
|
-
const node_url_1 = require("node:url");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
function __filename(path) {
|
|
8
|
-
return (0, node_url_1.fileURLToPath)(path);
|
|
9
|
-
}
|
|
10
|
-
function ___dirname(path) {
|
|
11
|
-
return (0, node_path_1.dirname)(__filename(path));
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=files.helper.js.map
|
package/src/files.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.helper.js","sourceRoot":"","sources":["files.helper.ts"],"names":[],"mappings":";;AAQA,gCAEC;AAOD,gCAEC;AAnBD,uCAAyC;AACzC,yCAAoC;AAOpC,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAOD,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAA,mBAAO,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
package/src/files.helper.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Util function to replace the commonjs __filename
|
|
6
|
-
* @param path
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export function __filename(path: string) {
|
|
10
|
-
return fileURLToPath(path);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Util function to replace the commonjs __dirname
|
|
15
|
-
* @param path
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export function ___dirname(path: string) {
|
|
19
|
-
return dirname(__filename(path));
|
|
20
|
-
}
|
package/src/http.helper.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, GoneException, HttpException, HttpStatus, InternalServerErrorException, MethodNotAllowedException, MisdirectedException, NotAcceptableException, NotFoundException, NotImplementedException, PayloadTooLargeException, PreconditionFailedException, RequestTimeoutException, ServiceUnavailableException, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException } from '@nestjs/common';
|
|
2
|
-
export declare const HttpStatusCodes: Record<string, any>;
|
|
3
|
-
export type HttpStatusCodes = (typeof HttpStatusCodes)[keyof typeof HttpStatusCodes];
|
|
4
|
-
export declare const getHttpStatusDescription: (status: HttpStatusCodes, fallbackDescription?: string) => string;
|
|
5
|
-
export declare const httpExceptionStatusCodes: {
|
|
6
|
-
[BadRequestException.name]: HttpStatus;
|
|
7
|
-
[UnauthorizedException.name]: HttpStatus;
|
|
8
|
-
[ForbiddenException.name]: HttpStatus;
|
|
9
|
-
[NotFoundException.name]: HttpStatus;
|
|
10
|
-
[MethodNotAllowedException.name]: HttpStatus;
|
|
11
|
-
[NotAcceptableException.name]: HttpStatus;
|
|
12
|
-
[RequestTimeoutException.name]: HttpStatus;
|
|
13
|
-
[ConflictException.name]: HttpStatus;
|
|
14
|
-
[GoneException.name]: HttpStatus;
|
|
15
|
-
[PreconditionFailedException.name]: HttpStatus;
|
|
16
|
-
[PayloadTooLargeException.name]: HttpStatus;
|
|
17
|
-
[UnsupportedMediaTypeException.name]: HttpStatus;
|
|
18
|
-
[UnprocessableEntityException.name]: HttpStatus;
|
|
19
|
-
[InternalServerErrorException.name]: HttpStatus;
|
|
20
|
-
[NotImplementedException.name]: HttpStatus;
|
|
21
|
-
[BadGatewayException.name]: HttpStatus;
|
|
22
|
-
[ServiceUnavailableException.name]: HttpStatus;
|
|
23
|
-
[GatewayTimeoutException.name]: HttpStatus;
|
|
24
|
-
[HttpException.name]: HttpStatus;
|
|
25
|
-
[MisdirectedException.name]: HttpStatus;
|
|
26
|
-
};
|