@open-norantec/utilities 1.0.1-alpha.9 → 2.0.0-alpha.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/dist/ecdh-util.class.d.ts +11 -0
- package/dist/ecdh-util.class.js +32 -0
- package/dist/enum-util.class.d.ts +2 -0
- package/dist/enum-util.class.js +4 -0
- package/dist/enums.d.ts +56 -0
- package/dist/enums.js +55 -0
- package/dist/error-util.class.d.ts +16 -0
- package/dist/error-util.class.js +59 -0
- package/dist/eslint-util.class.d.ts +29 -0
- package/dist/eslint-util.class.js +56 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/log-util.class.d.ts +4 -4
- package/dist/log-util.class.js +2 -2
- package/dist/schemas.d.ts +498 -0
- package/dist/schemas.js +113 -0
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +17 -0
- package/package.json +10 -9
- package/dist/schema-util.class.d.ts +0 -838
- package/dist/schema-util.class.js +0 -165
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import * as crypto from 'node:crypto';
|
|
4
|
+
export declare class ECDHUtil {
|
|
5
|
+
private readonly curveName;
|
|
6
|
+
readonly ecdh: crypto.ECDH;
|
|
7
|
+
protected readonly ALGORITHM: crypto.CipherGCMTypes;
|
|
8
|
+
constructor(curveName?: string);
|
|
9
|
+
encrypt(data: string, otherPublicKey: Buffer): string;
|
|
10
|
+
decrypt(encryptedData: string, otherPublicKey: Buffer): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ECDHUtil = void 0;
|
|
4
|
+
const crypto = require("node:crypto");
|
|
5
|
+
class ECDHUtil {
|
|
6
|
+
constructor(curveName = 'prime256v1') {
|
|
7
|
+
this.curveName = curveName;
|
|
8
|
+
this.ecdh = crypto.createECDH(this.curveName);
|
|
9
|
+
this.ALGORITHM = 'aes-256-gcm';
|
|
10
|
+
}
|
|
11
|
+
encrypt(data, otherPublicKey) {
|
|
12
|
+
const sharedKey = this.ecdh.computeSecret(new Uint8Array(otherPublicKey));
|
|
13
|
+
const iv = crypto.randomBytes(16);
|
|
14
|
+
const cipher = crypto.createCipheriv(this.ALGORITHM, new Uint8Array(sharedKey), new Uint8Array(iv));
|
|
15
|
+
const encrypted = Buffer.concat([new Uint8Array(cipher.update(data, 'utf-8')), new Uint8Array(cipher.final())]);
|
|
16
|
+
return Buffer.concat([new Uint8Array(iv), new Uint8Array(encrypted), new Uint8Array(cipher.getAuthTag())]).toString('base64');
|
|
17
|
+
}
|
|
18
|
+
decrypt(encryptedData, otherPublicKey) {
|
|
19
|
+
const sharedKey = this.ecdh.computeSecret(new Uint8Array(otherPublicKey));
|
|
20
|
+
const data = Buffer.from(encryptedData, 'base64');
|
|
21
|
+
const iv = data.subarray(0, 16);
|
|
22
|
+
const authTag = data.subarray(data.length - 16);
|
|
23
|
+
const encrypted = data.subarray(16, data.length - 16);
|
|
24
|
+
const decipher = crypto.createDecipheriv(this.ALGORITHM, new Uint8Array(sharedKey), new Uint8Array(iv));
|
|
25
|
+
decipher.setAuthTag(new Uint8Array(authTag));
|
|
26
|
+
return Buffer.concat([
|
|
27
|
+
new Uint8Array(decipher.update(new Uint8Array(encrypted))),
|
|
28
|
+
new Uint8Array(decipher.final()),
|
|
29
|
+
]).toString('utf-8');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ECDHUtil = ECDHUtil;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from './zod';
|
|
1
2
|
export interface IEnum {
|
|
2
3
|
[x: string]: any;
|
|
3
4
|
}
|
|
@@ -5,4 +6,5 @@ export declare class EnumUtil {
|
|
|
5
6
|
static getEntries(inputEnum: IEnum): Array<[string, any]>;
|
|
6
7
|
static isValidValue(inputEnum: IEnum, inputValue: any): boolean;
|
|
7
8
|
static isEqual(enum1: IEnum, enum2: IEnum): boolean;
|
|
9
|
+
static createEnumSchema<const T extends Record<string, string>>(object: T, params?: Parameters<typeof z.enum>[1]): z.ZodEnum<{ [k_1 in T[keyof T]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: { [k_1 in T[keyof T]]: k_1; }[k]; } : never>;
|
|
8
10
|
}
|
package/dist/enum-util.class.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumUtil = void 0;
|
|
4
|
+
const zod_1 = require("./zod");
|
|
4
5
|
class EnumUtil {
|
|
5
6
|
static getEntries(inputEnum) {
|
|
6
7
|
try {
|
|
@@ -34,5 +35,8 @@ class EnumUtil {
|
|
|
34
35
|
}
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
38
|
+
static createEnumSchema(object, params) {
|
|
39
|
+
return zod_1.z.enum(Object.values(object), params);
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
exports.EnumUtil = EnumUtil;
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare namespace Enums {
|
|
2
|
+
const OrderOrientation: {
|
|
3
|
+
readonly ASC: "ASC";
|
|
4
|
+
readonly DESC: "DESC";
|
|
5
|
+
};
|
|
6
|
+
const WhereClauseOp: {
|
|
7
|
+
readonly ADJACENT: "adjacent";
|
|
8
|
+
readonly ANY: "any";
|
|
9
|
+
readonly BETWEEN: "between";
|
|
10
|
+
readonly COL: "col";
|
|
11
|
+
readonly CONTAINED: "contained";
|
|
12
|
+
readonly CONTAINS: "contains";
|
|
13
|
+
readonly ENDS_WITH: "endsWith";
|
|
14
|
+
readonly EQ: "eq";
|
|
15
|
+
readonly GT: "gt";
|
|
16
|
+
readonly GTE: "gte";
|
|
17
|
+
readonly I_LIKE: "iLike";
|
|
18
|
+
readonly IN: "in";
|
|
19
|
+
readonly I_REGEXP: "iRegexp";
|
|
20
|
+
readonly IS: "is";
|
|
21
|
+
readonly LIKE: "like";
|
|
22
|
+
readonly LT: "lt";
|
|
23
|
+
readonly LTE: "lte";
|
|
24
|
+
readonly MATCH: "match";
|
|
25
|
+
readonly NE: "ne";
|
|
26
|
+
readonly NO_EXTEND_LEFT: "noExtendLeft";
|
|
27
|
+
readonly NO_EXTEND_RIGHT: "noExtendRight";
|
|
28
|
+
readonly NOT: "not";
|
|
29
|
+
readonly NOT_BETWEEN: "notBetween";
|
|
30
|
+
readonly NOT_I_LIKE: "notILike";
|
|
31
|
+
readonly NOT_IN: "notIn";
|
|
32
|
+
readonly NOT_I_REGEXP: "notIRegexp";
|
|
33
|
+
readonly NOT_LIKE: "notLike";
|
|
34
|
+
readonly NOT_REGEXP: "notRegexp";
|
|
35
|
+
readonly OVERLAP: "overlap";
|
|
36
|
+
readonly PLACEHOLDER: "placeholder";
|
|
37
|
+
readonly REGEXP: "regexp";
|
|
38
|
+
readonly STARTS_WITH: "startsWith";
|
|
39
|
+
readonly STRICT_LEFT: "strictLeft";
|
|
40
|
+
readonly STRICT_RIGHT: "strictRight";
|
|
41
|
+
readonly SUBSTRING: "substring";
|
|
42
|
+
readonly VALUES: "values";
|
|
43
|
+
};
|
|
44
|
+
const LogLevel: {
|
|
45
|
+
readonly ERROR: "error";
|
|
46
|
+
readonly WARN: "warn";
|
|
47
|
+
readonly INFO: "info";
|
|
48
|
+
readonly VERBOSE: "verbose";
|
|
49
|
+
readonly DEBUG: "debug";
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export declare namespace EnumTypes {
|
|
53
|
+
type OrderOrientation = (typeof Enums.OrderOrientation)[keyof typeof Enums.OrderOrientation];
|
|
54
|
+
type WhereClauseOp = (typeof Enums.WhereClauseOp)[keyof typeof Enums.WhereClauseOp];
|
|
55
|
+
type LogLevel = (typeof Enums.LogLevel)[keyof typeof Enums.LogLevel];
|
|
56
|
+
}
|
package/dist/enums.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Enums = void 0;
|
|
4
|
+
var Enums;
|
|
5
|
+
(function (Enums) {
|
|
6
|
+
Enums.OrderOrientation = {
|
|
7
|
+
ASC: 'ASC',
|
|
8
|
+
DESC: 'DESC',
|
|
9
|
+
};
|
|
10
|
+
Enums.WhereClauseOp = {
|
|
11
|
+
ADJACENT: 'adjacent',
|
|
12
|
+
ANY: 'any',
|
|
13
|
+
BETWEEN: 'between',
|
|
14
|
+
COL: 'col',
|
|
15
|
+
CONTAINED: 'contained',
|
|
16
|
+
CONTAINS: 'contains',
|
|
17
|
+
ENDS_WITH: 'endsWith',
|
|
18
|
+
EQ: 'eq',
|
|
19
|
+
GT: 'gt',
|
|
20
|
+
GTE: 'gte',
|
|
21
|
+
I_LIKE: 'iLike',
|
|
22
|
+
IN: 'in',
|
|
23
|
+
I_REGEXP: 'iRegexp',
|
|
24
|
+
IS: 'is',
|
|
25
|
+
LIKE: 'like',
|
|
26
|
+
LT: 'lt',
|
|
27
|
+
LTE: 'lte',
|
|
28
|
+
MATCH: 'match',
|
|
29
|
+
NE: 'ne',
|
|
30
|
+
NO_EXTEND_LEFT: 'noExtendLeft',
|
|
31
|
+
NO_EXTEND_RIGHT: 'noExtendRight',
|
|
32
|
+
NOT: 'not',
|
|
33
|
+
NOT_BETWEEN: 'notBetween',
|
|
34
|
+
NOT_I_LIKE: 'notILike',
|
|
35
|
+
NOT_IN: 'notIn',
|
|
36
|
+
NOT_I_REGEXP: 'notIRegexp',
|
|
37
|
+
NOT_LIKE: 'notLike',
|
|
38
|
+
NOT_REGEXP: 'notRegexp',
|
|
39
|
+
OVERLAP: 'overlap',
|
|
40
|
+
PLACEHOLDER: 'placeholder',
|
|
41
|
+
REGEXP: 'regexp',
|
|
42
|
+
STARTS_WITH: 'startsWith',
|
|
43
|
+
STRICT_LEFT: 'strictLeft',
|
|
44
|
+
STRICT_RIGHT: 'strictRight',
|
|
45
|
+
SUBSTRING: 'substring',
|
|
46
|
+
VALUES: 'values',
|
|
47
|
+
};
|
|
48
|
+
Enums.LogLevel = {
|
|
49
|
+
ERROR: 'error',
|
|
50
|
+
WARN: 'warn',
|
|
51
|
+
INFO: 'info',
|
|
52
|
+
VERBOSE: 'verbose',
|
|
53
|
+
DEBUG: 'debug',
|
|
54
|
+
};
|
|
55
|
+
})(Enums || (exports.Enums = Enums = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare class ResponseError extends Error {
|
|
2
|
+
readonly statusCode: number;
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: number;
|
|
5
|
+
constructor(message?: string | undefined, statusCode?: number, status?: number, code?: number);
|
|
6
|
+
}
|
|
7
|
+
export declare class ErrorUtil {
|
|
8
|
+
static createResponseError(error: Error, statusCode?: number): ResponseError;
|
|
9
|
+
static formatError(error: Error): {
|
|
10
|
+
id: string;
|
|
11
|
+
message: string;
|
|
12
|
+
logs: string[];
|
|
13
|
+
response: Response;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorUtil = void 0;
|
|
4
|
+
const uuid_util_class_1 = require("./uuid-util.class");
|
|
5
|
+
function isZodError(error) {
|
|
6
|
+
return typeof error === 'object' && error !== null && 'issues' in error && Array.isArray(error.issues);
|
|
7
|
+
}
|
|
8
|
+
class ResponseError extends Error {
|
|
9
|
+
constructor(message, statusCode = 500, status = 500, code = 500) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.statusCode = statusCode;
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class ErrorUtil {
|
|
17
|
+
static createResponseError(error, statusCode = 500) {
|
|
18
|
+
return new ResponseError(error.message, statusCode, statusCode, statusCode);
|
|
19
|
+
}
|
|
20
|
+
static formatError(error) {
|
|
21
|
+
const id = uuid_util_class_1.UUIDUtil.generateV4();
|
|
22
|
+
let message;
|
|
23
|
+
let errorLogs = [];
|
|
24
|
+
if (isZodError(error)) {
|
|
25
|
+
message = JSON.stringify({
|
|
26
|
+
message: 'Failed to validate your input data ({{context.trace}})',
|
|
27
|
+
context: {
|
|
28
|
+
trace: id,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
errorLogs.push(JSON.stringify(error.issues));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
message = JSON.stringify({
|
|
35
|
+
message: `${error.message || 'An unknown error occurred'} ({{context.trace}})`,
|
|
36
|
+
context: {
|
|
37
|
+
trace: id,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
errorLogs.push((error === null || error === void 0 ? void 0 : error.stack) || 'No stack trace available');
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
message,
|
|
45
|
+
logs: errorLogs.map((log) => `[AUTO_ERROR] [${id}] [${new Date().toISOString()}] ${log}`),
|
|
46
|
+
response: new Response(message, {
|
|
47
|
+
status: (() => {
|
|
48
|
+
if (isZodError(error))
|
|
49
|
+
return 400;
|
|
50
|
+
if (error instanceof ResponseError)
|
|
51
|
+
return error.statusCode;
|
|
52
|
+
return 500;
|
|
53
|
+
})(),
|
|
54
|
+
headers: { 'Content-Type': 'application/json' },
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ErrorUtil = ErrorUtil;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import * as stylistic from '@stylistic/eslint-plugin';
|
|
3
|
+
export declare class ESLintUtil {
|
|
4
|
+
static create({ ignores, project }: {
|
|
5
|
+
ignores?: string[];
|
|
6
|
+
project?: string;
|
|
7
|
+
}): {
|
|
8
|
+
files: string[];
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parser: typeof tsParser;
|
|
11
|
+
parserOptions: {
|
|
12
|
+
project: string;
|
|
13
|
+
tsconfigRootDir: string;
|
|
14
|
+
sourceType: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
ignores: string[];
|
|
18
|
+
plugins: {
|
|
19
|
+
'@typescript-eslint': {
|
|
20
|
+
configs: Record<string, ClassicConfig.Config>;
|
|
21
|
+
meta: FlatConfig.PluginMeta;
|
|
22
|
+
rules: import("@typescript-eslint/eslint-plugin/rules").TypeScriptESLintRules;
|
|
23
|
+
};
|
|
24
|
+
'@stylistic': typeof stylistic;
|
|
25
|
+
prettier: import("@eslint/core").Plugin;
|
|
26
|
+
};
|
|
27
|
+
rules: any;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ESLintUtil = void 0;
|
|
4
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
5
|
+
const tsPlugin = require("@typescript-eslint/eslint-plugin");
|
|
6
|
+
const stylistic = require("@stylistic/eslint-plugin");
|
|
7
|
+
const prettier = require("eslint-plugin-prettier");
|
|
8
|
+
class ESLintUtil {
|
|
9
|
+
static create({ ignores = [], project = './tsconfig.json' }) {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.mts', '**/*.cts', '**/*.mjs', '**/*.cjs'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: tsParser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
project,
|
|
18
|
+
tsconfigRootDir: process.cwd(),
|
|
19
|
+
sourceType: 'module',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
ignores,
|
|
23
|
+
plugins: {
|
|
24
|
+
'@typescript-eslint': tsPlugin,
|
|
25
|
+
'@stylistic': stylistic,
|
|
26
|
+
prettier,
|
|
27
|
+
},
|
|
28
|
+
rules: Object.assign(Object.assign(Object.assign({}, (_b = (_a = tsPlugin === null || tsPlugin === void 0 ? void 0 : tsPlugin.configs) === null || _a === void 0 ? void 0 : _a.recommended) === null || _b === void 0 ? void 0 : _b.rules), (_d = (_c = prettier === null || prettier === void 0 ? void 0 : prettier.configs) === null || _c === void 0 ? void 0 : _c.recommended) === null || _d === void 0 ? void 0 : _d.rules), { 'prettier/prettier': [
|
|
29
|
+
'error',
|
|
30
|
+
{
|
|
31
|
+
singleQuote: true,
|
|
32
|
+
trailingComma: 'all',
|
|
33
|
+
tabWidth: 2,
|
|
34
|
+
printWidth: 120,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
usePrettierrc: false,
|
|
38
|
+
},
|
|
39
|
+
], '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-require-imports': 'off', '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', '@typescript-eslint/no-namespace': 'off', '@stylistic/member-delimiter-style': [
|
|
40
|
+
'error',
|
|
41
|
+
{
|
|
42
|
+
multiline: {
|
|
43
|
+
delimiter: 'semi',
|
|
44
|
+
requireLast: true,
|
|
45
|
+
},
|
|
46
|
+
singleline: {
|
|
47
|
+
delimiter: 'semi',
|
|
48
|
+
requireLast: false,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
], 'multiline-ternary': ['error', 'always-multiline'], 'object-curly-newline': ['error', { multiline: true, consistent: true }] }),
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ESLintUtil = ESLintUtil;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,11 @@ export * from './json-util.class';
|
|
|
5
5
|
export * from './string-util.class';
|
|
6
6
|
export * from './user-agent-util.class';
|
|
7
7
|
export * from './enum-util.class';
|
|
8
|
-
export * from './schema-util.class';
|
|
9
8
|
export * from './log-util.class';
|
|
10
9
|
export * from './crypto-util.class';
|
|
11
10
|
export * from './date-util.class';
|
|
12
11
|
export * from './url-util.class';
|
|
12
|
+
export * from './error-util.class';
|
|
13
|
+
export * from './zod';
|
|
14
|
+
export * from './schemas';
|
|
15
|
+
export * from './enums';
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,11 @@ __exportStar(require("./json-util.class"), exports);
|
|
|
21
21
|
__exportStar(require("./string-util.class"), exports);
|
|
22
22
|
__exportStar(require("./user-agent-util.class"), exports);
|
|
23
23
|
__exportStar(require("./enum-util.class"), exports);
|
|
24
|
-
__exportStar(require("./schema-util.class"), exports);
|
|
25
24
|
__exportStar(require("./log-util.class"), exports);
|
|
26
25
|
__exportStar(require("./crypto-util.class"), exports);
|
|
27
26
|
__exportStar(require("./date-util.class"), exports);
|
|
28
27
|
__exportStar(require("./url-util.class"), exports);
|
|
28
|
+
__exportStar(require("./error-util.class"), exports);
|
|
29
|
+
__exportStar(require("./zod"), exports);
|
|
30
|
+
__exportStar(require("./schemas"), exports);
|
|
31
|
+
__exportStar(require("./enums"), exports);
|
package/dist/log-util.class.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumTypes } from './enums';
|
|
2
2
|
export declare class LogUtil {
|
|
3
3
|
private readonly defaultLogLevel;
|
|
4
|
-
constructor(defaultLogLevel?:
|
|
5
|
-
match(bottomLogLevel:
|
|
6
|
-
log(level:
|
|
4
|
+
constructor(defaultLogLevel?: EnumTypes.LogLevel);
|
|
5
|
+
match(bottomLogLevel: EnumTypes.LogLevel | boolean, logLevel: EnumTypes.LogLevel): boolean;
|
|
6
|
+
log(level: EnumTypes.LogLevel, message: string | Error): void;
|
|
7
7
|
}
|
package/dist/log-util.class.js
CHANGED
|
@@ -36,9 +36,9 @@ class LogUtil {
|
|
|
36
36
|
if (this.match(this.defaultLogLevel, level) === false)
|
|
37
37
|
return;
|
|
38
38
|
const finalExtraMessage = level === 'debug' || (this.defaultLogLevel === 'debug' && level === 'error')
|
|
39
|
-
? (_d = (_c = (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split) === null || _b === void 0 ? void 0 : _b.call(_a, '\n')) === null || _c === void 0 ? void 0 : _c.slice(1)) === null || _d === void 0 ? void 0 : _d.join('\n')
|
|
39
|
+
? (_d = (_c = (_b = (_a = (message instanceof Error ? message : new Error()).stack) === null || _a === void 0 ? void 0 : _a.split) === null || _b === void 0 ? void 0 : _b.call(_a, '\n')) === null || _c === void 0 ? void 0 : _c.slice(1)) === null || _d === void 0 ? void 0 : _d.join('\n')
|
|
40
40
|
: '';
|
|
41
|
-
console.log(colorizer(`[${new Date().toLocaleString()}] [${level.toUpperCase()}] ${message
|
|
41
|
+
console.log(colorizer(`[${new Date().toLocaleString()}] [${level.toUpperCase()}] ${message instanceof Error ? message.message : message}${string_util_class_1.StringUtil.isFalsyString(finalExtraMessage) ? '' : `\n${finalExtraMessage}`}`));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.LogUtil = LogUtil;
|