@samet-it/be-base-common 1.0.11 → 1.1.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/dist/config/base-common.config.d.ts +1 -1
- package/dist/config/base-common.config.js +9 -9
- package/dist/config/index.types.d.ts +2 -2
- package/dist/error/error.handler.d.ts +1 -1
- package/dist/error/error.handler.js +15 -220
- package/dist/error/index.d.ts +2 -7
- package/dist/error/index.js +2 -7
- package/dist/error/index.types.d.ts +3 -24
- package/dist/error/items/index.d.ts +5 -0
- package/dist/error/items/index.js +21 -0
- package/dist/error/items/page-not-found.error.d.ts +4 -0
- package/dist/error/items/page-not-found.error.js +11 -0
- package/dist/error/items/record-duplicated.error.d.ts +4 -0
- package/dist/error/items/record-duplicated.error.js +11 -0
- package/dist/error/items/record-not-found.error.d.ts +4 -0
- package/dist/error/items/record-not-found.error.js +11 -0
- package/dist/error/items/samet.error.d.ts +6 -0
- package/dist/error/items/samet.error.js +10 -0
- package/dist/error/items/validation.error.d.ts +4 -0
- package/dist/error/items/validation.error.js +11 -0
- package/dist/exit/exit-handler.impl.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +18 -0
- package/dist/logger/index.types.d.ts +68 -0
- package/dist/logger/logger.default.d.ts +41 -0
- package/dist/logger/logger.default.js +142 -0
- package/dist/model/index.types.d.ts +101 -0
- package/dist/model/index.types.js +2 -0
- package/package.json +4 -4
- package/dist/error/base.exception.d.ts +0 -7
- package/dist/error/base.exception.js +0 -11
- package/dist/error/initialization.exception.d.ts +0 -4
- package/dist/error/initialization.exception.js +0 -12
- package/dist/error/page-not-found.exception.d.ts +0 -4
- package/dist/error/page-not-found.exception.js +0 -11
- package/dist/error/record-duplicated.exception.d.ts +0 -4
- package/dist/error/record-duplicated.exception.js +0 -18
- package/dist/error/record-not-found.exception.d.ts +0 -4
- package/dist/error/record-not-found.exception.js +0 -13
- package/dist/error/validation.exception.d.ts +0 -4
- package/dist/error/validation.exception.js +0 -23
- package/dist/shared/index.types.d.ts +0 -11
- /package/dist/{shared → logger}/index.types.js +0 -0
- /package/dist/{shared → model}/index.d.ts +0 -0
- /package/dist/{shared → model}/index.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { BaseCommonConf } from "./index.types";
|
|
2
|
-
export declare const baseCommonConfig: import("@leyyo/env").EnvScopeRuntime<BaseCommonConf>;
|
|
2
|
+
export declare const baseCommonConfig: import("@leyyo/env").EnvScopeRuntime<BaseCommonConf, undefined, undefined>;
|
|
@@ -7,12 +7,12 @@ const common_1 = require("@leyyo/common");
|
|
|
7
7
|
// noinspection JSUnusedGlobalSymbols
|
|
8
8
|
exports.baseCommonConfig = env_1.envCore.configure
|
|
9
9
|
.scope('BaseCommon')
|
|
10
|
-
.
|
|
11
|
-
.field('NODE_ENV').
|
|
12
|
-
.field('LOG_LEVEL').literal(common_1.LogLevelItems).required().def('info').end
|
|
13
|
-
.field('npm_config_node_version').string().def((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node).end
|
|
14
|
-
.field('npm_package_name').string().end
|
|
15
|
-
.field('npm_package_version').string().end
|
|
16
|
-
.field('npm_config_npm_version').string().end
|
|
17
|
-
.field('PWD').string().end
|
|
18
|
-
.
|
|
10
|
+
.start()
|
|
11
|
+
.field('NODE_ENV').text().def('development').end()
|
|
12
|
+
.field('LOG_LEVEL').literal(common_1.LogLevelItems).required().def('info').end()
|
|
13
|
+
.field('npm_config_node_version').string().def((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node).end()
|
|
14
|
+
.field('npm_package_name').string().end()
|
|
15
|
+
.field('npm_package_version').string().end()
|
|
16
|
+
.field('npm_config_npm_version').string().end()
|
|
17
|
+
.field('PWD').string().end()
|
|
18
|
+
.finish();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnvBase } from "@leyyo/env";
|
|
2
|
-
import {
|
|
2
|
+
import type { LogLevel } from "@leyyo/common";
|
|
3
3
|
export declare namespace NodeJS {
|
|
4
4
|
interface ProcessEnv extends BaseCommonConf {
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ export interface BaseCommonConf extends EnvBase {
|
|
|
8
8
|
/**
|
|
9
9
|
* Environment
|
|
10
10
|
* */
|
|
11
|
-
readonly NODE_ENV:
|
|
11
|
+
readonly NODE_ENV: string;
|
|
12
12
|
/**
|
|
13
13
|
* Log Level, severity
|
|
14
14
|
* */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ErrorHandlerLike } from "./index.types";
|
|
1
|
+
import type { ErrorHandlerLike } from "./index.types";
|
|
2
2
|
export declare const errorHandler: ErrorHandlerLike;
|
|
@@ -1,105 +1,17 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.errorHandler = void 0;
|
|
37
|
-
const stackTraceParser = __importStar(require("stacktrace-parser"));
|
|
38
|
-
const base_exception_1 = require("./base.exception");
|
|
39
4
|
const common_1 = require("@leyyo/common");
|
|
40
|
-
const KNOWN_GROUPS = {
|
|
41
|
-
'@samet-digital': 's',
|
|
42
|
-
'@leyyo': 'l',
|
|
43
|
-
'@nestjs': 'n',
|
|
44
|
-
};
|
|
45
|
-
const IGNORED_KEYS = ['constructor', 'prototype', 'message', 'stack', 'name'];
|
|
46
5
|
class ErrorHandler {
|
|
47
6
|
constructor() {
|
|
48
7
|
this._CLEAR_STAT = 1000 * 60 * 60 * 24; // daily
|
|
49
8
|
this._stats = new Map();
|
|
9
|
+
this.common = common_1.$err;
|
|
50
10
|
this.started = new Date();
|
|
11
|
+
common_1.$err.addKnownPackage('@samet-it', 's');
|
|
12
|
+
common_1.$err.addKnownPackage('@nestjs', 'n');
|
|
51
13
|
this._clearStats();
|
|
52
14
|
}
|
|
53
|
-
_item(value, set) {
|
|
54
|
-
var _a;
|
|
55
|
-
if (value === null || value === undefined) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
switch (typeof value) {
|
|
59
|
-
case "string":
|
|
60
|
-
case "boolean":
|
|
61
|
-
case "number":
|
|
62
|
-
case "bigint":
|
|
63
|
-
return value;
|
|
64
|
-
case "object": {
|
|
65
|
-
if (set.has(value)) {
|
|
66
|
-
return `#ref: circular dependency: ${(_a = value === null || value === void 0 ? void 0 : value.constructor) === null || _a === void 0 ? void 0 : _a.name}`;
|
|
67
|
-
}
|
|
68
|
-
set.add(value);
|
|
69
|
-
if (Array.isArray(value)) {
|
|
70
|
-
return value
|
|
71
|
-
.map(item => this._item(item, set));
|
|
72
|
-
}
|
|
73
|
-
else if (value instanceof Set) {
|
|
74
|
-
return Array.from(value.values())
|
|
75
|
-
.map(item => this._item(item, set));
|
|
76
|
-
}
|
|
77
|
-
else if (value instanceof Map) {
|
|
78
|
-
const result = {};
|
|
79
|
-
for (const [k, v] of value.entries()) {
|
|
80
|
-
if (typeof k === 'symbol') {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
result[k] = this._item(v, set);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
const result = {};
|
|
88
|
-
for (const [k, v] of Object.entries(value)) {
|
|
89
|
-
if (typeof k === 'symbol') {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
result[k] = this._item(v, set);
|
|
93
|
-
}
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
case "function":
|
|
97
|
-
return `#ref: function: ${value === null || value === void 0 ? void 0 : value.name}`;
|
|
98
|
-
case "symbol":
|
|
99
|
-
return `#ref: symbol: ${value === null || value === void 0 ? void 0 : value.description}`;
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
15
|
/**
|
|
104
16
|
* Clear native errors
|
|
105
17
|
* */
|
|
@@ -107,141 +19,24 @@ class ErrorHandler {
|
|
|
107
19
|
this._stats.clear();
|
|
108
20
|
setTimeout(() => this._clearStats(), this._CLEAR_STAT);
|
|
109
21
|
}
|
|
110
|
-
checkParams(exception) {
|
|
111
|
-
const set = new WeakSet();
|
|
112
|
-
set.add(exception);
|
|
113
|
-
exception.params = this._item(exception.params, set);
|
|
114
|
-
}
|
|
115
|
-
export(exception) {
|
|
116
|
-
var _a;
|
|
117
|
-
const result = {};
|
|
118
|
-
this.checkParams(exception);
|
|
119
|
-
const all = Object.assign({}, exception);
|
|
120
|
-
if (all.params) {
|
|
121
|
-
if (typeof all.params['$name'] === 'string') {
|
|
122
|
-
result.name = all.params['$name'];
|
|
123
|
-
delete all.params['$name'];
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
result.name = all.name;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (all.name && result.name !== all.name && all.name !== 'BaseException') {
|
|
130
|
-
if (!all.params) {
|
|
131
|
-
all.params = {};
|
|
132
|
-
}
|
|
133
|
-
all.params['$name'] = all.name;
|
|
134
|
-
}
|
|
135
|
-
delete all.name;
|
|
136
|
-
result.message = (_a = all.message) !== null && _a !== void 0 ? _a : result.name;
|
|
137
|
-
delete all.message;
|
|
138
|
-
if (all.params !== undefined) {
|
|
139
|
-
if (Object.keys(all.params).length > 0) {
|
|
140
|
-
result.params = Object.assign({}, all.params);
|
|
141
|
-
}
|
|
142
|
-
delete all.params;
|
|
143
|
-
}
|
|
144
|
-
if (all.stackTrace !== undefined) {
|
|
145
|
-
result.stackTrace = [...all.stackTrace];
|
|
146
|
-
delete all.stackTrace;
|
|
147
|
-
delete all.stack;
|
|
148
|
-
}
|
|
149
|
-
if (all.stack !== undefined) {
|
|
150
|
-
delete all.stack;
|
|
151
|
-
}
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
cast(error, p1, p2) {
|
|
155
|
-
let fnc;
|
|
156
|
-
let status;
|
|
157
|
-
switch (typeof p1) {
|
|
158
|
-
case "function":
|
|
159
|
-
fnc = p1;
|
|
160
|
-
break;
|
|
161
|
-
case "number":
|
|
162
|
-
status = p1;
|
|
163
|
-
if (typeof p2 === 'function') {
|
|
164
|
-
fnc = p2;
|
|
165
|
-
}
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
if (!fnc) {
|
|
169
|
-
fnc = base_exception_1.BaseException;
|
|
170
|
-
}
|
|
171
|
-
const exc = new fnc(error.message, {}, status);
|
|
172
|
-
exc.params['$name'] = error.name;
|
|
173
|
-
let now = Date.now();
|
|
174
|
-
for (const [key, value] of Object.entries(error)) {
|
|
175
|
-
if (typeof key === 'symbol' || value === undefined || IGNORED_KEYS.includes(key)) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (exc.params[key] === undefined) {
|
|
179
|
-
exc.params[key] = value;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
now++;
|
|
183
|
-
exc.params[`$${key}__${now}`] = value;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return exc;
|
|
187
|
-
}
|
|
188
|
-
stack(source, causedBy) {
|
|
189
|
-
var _a;
|
|
190
|
-
source.stackTrace = [];
|
|
191
|
-
try {
|
|
192
|
-
const original = (_a = causedBy.stack) !== null && _a !== void 0 ? _a : source.stack;
|
|
193
|
-
if (original) {
|
|
194
|
-
const frames = stackTraceParser.parse(original);
|
|
195
|
-
if (Array.isArray(frames)) {
|
|
196
|
-
frames.forEach(frame => {
|
|
197
|
-
var _a, _b;
|
|
198
|
-
if (['<unknown>', 'Object.<anonymous>'].includes(frame.methodName)) {
|
|
199
|
-
frame.methodName = undefined;
|
|
200
|
-
}
|
|
201
|
-
if (frame.file) {
|
|
202
|
-
if (frame.file.startsWith('node:')) {
|
|
203
|
-
frame.file = `@` + frame.file.substring(5);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
for (const [pck, short] of Object.entries(KNOWN_GROUPS)) {
|
|
207
|
-
const index = frame.file.indexOf(pck);
|
|
208
|
-
if (index >= 0) {
|
|
209
|
-
frame.file = `#${short}` + frame.file.substring(index);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (frame.file.endsWith('.js') || frame.file.endsWith('.ts')) {
|
|
214
|
-
frame.file.substring(0, frame.file.length - 3);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
source.stackTrace.push({
|
|
218
|
-
file: frame.file,
|
|
219
|
-
method: frame.methodName,
|
|
220
|
-
pos: `${(_a = frame.lineNumber) !== null && _a !== void 0 ? _a : ''}:${(_b = frame.column) !== null && _b !== void 0 ? _b : ''}`
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
catch (e) {
|
|
227
|
-
// none
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
22
|
addStat(error) {
|
|
23
|
+
let num = -1;
|
|
231
24
|
try {
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this._stats.set(error, num
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
num = this._stats.get(error);
|
|
27
|
+
if (num === undefined) {
|
|
28
|
+
num = 1;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
num++;
|
|
32
|
+
}
|
|
33
|
+
this._stats.set(error, num);
|
|
241
34
|
}
|
|
242
35
|
}
|
|
243
36
|
catch (e) {
|
|
37
|
+
// nothing
|
|
244
38
|
}
|
|
39
|
+
return num;
|
|
245
40
|
}
|
|
246
41
|
listStats() {
|
|
247
42
|
var _a, _b;
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from './base.exception';
|
|
2
|
-
export * from './error.handler';
|
|
3
1
|
export * from './index.types';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './record-duplicated.exception';
|
|
7
|
-
export * from './record-not-found.exception';
|
|
8
|
-
export * from './validation.exception';
|
|
2
|
+
export * from './error.handler';
|
|
3
|
+
export * from './items';
|
package/dist/error/index.js
CHANGED
|
@@ -14,11 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base.exception"), exports);
|
|
18
|
-
__exportStar(require("./error.handler"), exports);
|
|
19
17
|
__exportStar(require("./index.types"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./record-duplicated.exception"), exports);
|
|
23
|
-
__exportStar(require("./record-not-found.exception"), exports);
|
|
24
|
-
__exportStar(require("./validation.exception"), exports);
|
|
18
|
+
__exportStar(require("./error.handler"), exports);
|
|
19
|
+
__exportStar(require("./items"), exports);
|
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Stack line
|
|
4
|
-
* */
|
|
5
|
-
export interface ErrorStackLine {
|
|
6
|
-
file: string;
|
|
7
|
-
method?: string;
|
|
8
|
-
pos?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Core exception
|
|
12
|
-
* */
|
|
13
|
-
export interface ExceptionLike extends Error {
|
|
14
|
-
status: number;
|
|
15
|
-
params: Record<string, unknown>;
|
|
16
|
-
stackTrace: Array<ErrorStackLine>;
|
|
17
|
-
}
|
|
1
|
+
import type { ErrorCommonLike, ErrorStackLine } from "@leyyo/common";
|
|
18
2
|
export interface ExceptionExported {
|
|
19
3
|
name: string;
|
|
20
4
|
message: string;
|
|
21
5
|
params?: Record<string, unknown>;
|
|
22
6
|
stackTrace?: Array<ErrorStackLine>;
|
|
23
7
|
}
|
|
24
|
-
export type ErrorItem<A, C = ExceptionLike> = A extends ClassLike<infer R> ? (R extends ExceptionLike ? C : never) : never;
|
|
25
8
|
export interface ErrorHandlerLike {
|
|
26
9
|
readonly started: Date;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cast<F extends ClassLike<ExceptionLike>>(error: Error, fnc?: F): ErrorItem<F>;
|
|
30
|
-
cast<F extends ClassLike<ExceptionLike>>(error: Error, status: number, fnc?: F): ErrorItem<F>;
|
|
31
|
-
stack(source: ExceptionLike, causedBy?: Error): void;
|
|
32
|
-
addStat(error: Error): void;
|
|
10
|
+
readonly common: ErrorCommonLike;
|
|
11
|
+
addStat(error: Error): number;
|
|
33
12
|
listStats(): Record<string, number>;
|
|
34
13
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./page-not-found.error"), exports);
|
|
18
|
+
__exportStar(require("./record-duplicated.error"), exports);
|
|
19
|
+
__exportStar(require("./record-not-found.error"), exports);
|
|
20
|
+
__exportStar(require("./samet.error"), exports);
|
|
21
|
+
__exportStar(require("./validation.error"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageNotFoundError = void 0;
|
|
4
|
+
const common_1 = require("@leyyo/common");
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
class PageNotFoundError extends common_1.NotFoundError {
|
|
7
|
+
constructor(path, opt) {
|
|
8
|
+
super(`Path: ${path} is not found`, Object.assign(Object.assign({}, opt), { path }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.PageNotFoundError = PageNotFoundError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordDuplicatedError = void 0;
|
|
4
|
+
const common_1 = require("@leyyo/common");
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
class RecordDuplicatedError extends common_1.ConflictError {
|
|
7
|
+
constructor(domain, query, opt) {
|
|
8
|
+
super(`${domain} record is duplicated`, Object.assign(Object.assign({}, opt), { domain, query }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.RecordDuplicatedError = RecordDuplicatedError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordNotFoundError = void 0;
|
|
4
|
+
const common_1 = require("@leyyo/common");
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
class RecordNotFoundError extends common_1.NotFoundError {
|
|
7
|
+
constructor(domain, query, opt) {
|
|
8
|
+
super(`${domain} record could not be found`, Object.assign(Object.assign({}, opt), { domain, query }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.RecordNotFoundError = RecordNotFoundError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SametError = void 0;
|
|
4
|
+
const common_1 = require("@leyyo/common");
|
|
5
|
+
/**
|
|
6
|
+
* Samet base error
|
|
7
|
+
* */
|
|
8
|
+
class SametError extends common_1.LeyyoError {
|
|
9
|
+
}
|
|
10
|
+
exports.SametError = SametError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
const common_1 = require("@leyyo/common");
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
class ValidationError extends common_1.ConflictError {
|
|
7
|
+
constructor(domain, key, value, opt) {
|
|
8
|
+
super(`${domain} -> ${key} is invalid`, Object.assign(Object.assign({}, opt), { domain, key, value }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ValidationError = ValidationError;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ExitHandler } from "./index.types";
|
|
1
|
+
import type { ExitHandler } from "./index.types";
|
|
2
2
|
export declare const exitHandler: ExitHandler;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./config"), exports);
|
|
|
18
18
|
__exportStar(require("./error"), exports);
|
|
19
19
|
__exportStar(require("./exit"), exports);
|
|
20
20
|
__exportStar(require("./generator"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./logger"), exports);
|
|
22
|
+
__exportStar(require("./model"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index.types"), exports);
|
|
18
|
+
__exportStar(require("./logger.default"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ClassLike, Obj } from "@leyyo/common";
|
|
2
|
+
/**
|
|
3
|
+
* Base logger to align console
|
|
4
|
+
* */
|
|
5
|
+
export interface LoggerLike {
|
|
6
|
+
/**
|
|
7
|
+
* Debug log
|
|
8
|
+
*
|
|
9
|
+
* @param {string} message - message
|
|
10
|
+
* @param {any} args - arguments
|
|
11
|
+
* */
|
|
12
|
+
debug?(message: string, args?: unknown): void;
|
|
13
|
+
/**
|
|
14
|
+
* Trace log
|
|
15
|
+
*
|
|
16
|
+
* @param {string} message - message
|
|
17
|
+
* @param {any} args - arguments
|
|
18
|
+
* */
|
|
19
|
+
trace?(message: string, args?: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Info log
|
|
22
|
+
*
|
|
23
|
+
* @param {string} message - message
|
|
24
|
+
* @param {any} args - arguments
|
|
25
|
+
* */
|
|
26
|
+
info?(message: string, args?: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Info log
|
|
29
|
+
* @alias info
|
|
30
|
+
*
|
|
31
|
+
* @param {string} message - message
|
|
32
|
+
* @param {any} args - arguments
|
|
33
|
+
* */
|
|
34
|
+
log?(message: string, args?: unknown): void;
|
|
35
|
+
/**
|
|
36
|
+
* Warning log
|
|
37
|
+
*
|
|
38
|
+
* @param {(string|Error)} message - error or message
|
|
39
|
+
* @param {any} args - arguments
|
|
40
|
+
* */
|
|
41
|
+
warn?(message: string | Error, args?: unknown): void;
|
|
42
|
+
/**
|
|
43
|
+
* Error log
|
|
44
|
+
*
|
|
45
|
+
* @param {(string|Error)} message - error or message
|
|
46
|
+
* @param {any} args - arguments
|
|
47
|
+
* */
|
|
48
|
+
error?(message: string | Error, args?: unknown): void;
|
|
49
|
+
/**
|
|
50
|
+
* Fatal log
|
|
51
|
+
*
|
|
52
|
+
* @param {(string|Error)} message - error or message
|
|
53
|
+
* @param {any} args - arguments
|
|
54
|
+
* */
|
|
55
|
+
fatal?(message: string | Error, args?: unknown): void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extended logger to support to fork new logger
|
|
59
|
+
* */
|
|
60
|
+
export interface LoggerDefaultLike extends LoggerLike {
|
|
61
|
+
/**
|
|
62
|
+
* Create/fork new logger
|
|
63
|
+
*
|
|
64
|
+
* @param {(string|ClassLike|Obj)} clazz - class, name or instance
|
|
65
|
+
* @return {LoggerLike} - new logger
|
|
66
|
+
* */
|
|
67
|
+
of(clazz: string | ClassLike | Obj): LoggerLike;
|
|
68
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ClassLike, Obj } from "@leyyo/common";
|
|
2
|
+
import type { LoggerDefaultLike, LoggerLike } from "./index.types";
|
|
3
|
+
/** @inheritDoc */
|
|
4
|
+
export declare class LoggerDefault implements LoggerDefaultLike {
|
|
5
|
+
private readonly _className;
|
|
6
|
+
/**
|
|
7
|
+
* Constructor
|
|
8
|
+
*
|
|
9
|
+
* @param {(string|ClassLike|Obj)} clazz - class, name or instance
|
|
10
|
+
* */
|
|
11
|
+
constructor(clazz?: string | ClassLike | Obj);
|
|
12
|
+
/**
|
|
13
|
+
* Builds the log message
|
|
14
|
+
*
|
|
15
|
+
* @param {any} message - message or error
|
|
16
|
+
* @return {string} - formatted message
|
|
17
|
+
* */
|
|
18
|
+
private _buildMessage;
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
of(clazz: string | ClassLike | Obj): LoggerLike;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
debug(message: string, args?: unknown): void;
|
|
23
|
+
/** @inheritDoc */
|
|
24
|
+
error(message: string | Error, args?: unknown): void;
|
|
25
|
+
/** @inheritDoc */
|
|
26
|
+
fatal(message: string | Error, args?: unknown): void;
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
info(message: string, args?: unknown): void;
|
|
29
|
+
/** @inheritDoc */
|
|
30
|
+
log(message: string, args?: unknown): void;
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
trace(message: string, args?: unknown): void;
|
|
33
|
+
/** @inheritDoc */
|
|
34
|
+
warn(message: string | Error, args?: unknown): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base logger instance
|
|
38
|
+
*
|
|
39
|
+
* @type {LoggerDefaultLike}
|
|
40
|
+
* */
|
|
41
|
+
export declare const logger: LoggerDefaultLike;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logger = exports.LoggerDefault = void 0;
|
|
4
|
+
/** @inheritDoc */
|
|
5
|
+
class LoggerDefault {
|
|
6
|
+
/**
|
|
7
|
+
* Constructor
|
|
8
|
+
*
|
|
9
|
+
* @param {(string|ClassLike|Obj)} clazz - class, name or instance
|
|
10
|
+
* */
|
|
11
|
+
constructor(clazz) {
|
|
12
|
+
var _a;
|
|
13
|
+
switch (typeof clazz) {
|
|
14
|
+
case "string":
|
|
15
|
+
this._className = clazz;
|
|
16
|
+
break;
|
|
17
|
+
case "function":
|
|
18
|
+
this._className = clazz.name;
|
|
19
|
+
break;
|
|
20
|
+
case "object":
|
|
21
|
+
if (clazz) {
|
|
22
|
+
this._className = (_a = clazz.constructor) === null || _a === void 0 ? void 0 : _a.name;
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (this._className) {
|
|
27
|
+
this._className = this._className ? `[${this._className}] ` : '';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds the log message
|
|
32
|
+
*
|
|
33
|
+
* @param {any} message - message or error
|
|
34
|
+
* @return {string} - formatted message
|
|
35
|
+
* */
|
|
36
|
+
_buildMessage(message) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
switch (typeof message) {
|
|
39
|
+
case "string":
|
|
40
|
+
return message.trim();
|
|
41
|
+
case "boolean":
|
|
42
|
+
return message ? 'true' : 'false';
|
|
43
|
+
case "bigint":
|
|
44
|
+
case "number":
|
|
45
|
+
return message.toString();
|
|
46
|
+
case "object":
|
|
47
|
+
if (message instanceof Error) {
|
|
48
|
+
const errorName = message.name ? `[${message.name}] => ` : '';
|
|
49
|
+
return `${errorName}${(_a = message.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`;
|
|
50
|
+
}
|
|
51
|
+
return JSON.stringify(message);
|
|
52
|
+
case "symbol":
|
|
53
|
+
return message.description;
|
|
54
|
+
case "undefined":
|
|
55
|
+
return '';
|
|
56
|
+
case "function":
|
|
57
|
+
return `${(_b = message.name) !== null && _b !== void 0 ? _b : '~fnc~'}(${message.length})`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** @inheritDoc */
|
|
61
|
+
of(clazz) {
|
|
62
|
+
return new LoggerDefault(clazz);
|
|
63
|
+
}
|
|
64
|
+
/** @inheritDoc */
|
|
65
|
+
debug(message, args) {
|
|
66
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
67
|
+
if (args === undefined) {
|
|
68
|
+
console.debug(line);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.debug(line, args);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** @inheritDoc */
|
|
75
|
+
error(message, args) {
|
|
76
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
77
|
+
if (args === undefined) {
|
|
78
|
+
console.error(line);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.error(line, args);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** @inheritDoc */
|
|
85
|
+
fatal(message, args) {
|
|
86
|
+
const line = `[${new Date().toISOString()}] ${this._className}[#fatal]${this._buildMessage(message)}`;
|
|
87
|
+
if (args === undefined) {
|
|
88
|
+
console.error(line);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.error(line, args);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** @inheritDoc */
|
|
95
|
+
info(message, args) {
|
|
96
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
97
|
+
if (args === undefined) {
|
|
98
|
+
console.info(line);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.info(line, args);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** @inheritDoc */
|
|
105
|
+
log(message, args) {
|
|
106
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
107
|
+
if (args === undefined) {
|
|
108
|
+
console.log(line);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.log(line, args);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** @inheritDoc */
|
|
115
|
+
trace(message, args) {
|
|
116
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
117
|
+
if (args === undefined) {
|
|
118
|
+
console.trace(line);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.trace(line, args);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** @inheritDoc */
|
|
125
|
+
warn(message, args) {
|
|
126
|
+
const line = `[${new Date().toISOString()}] ${this._className}${this._buildMessage(message)}`;
|
|
127
|
+
if (args === undefined) {
|
|
128
|
+
console.warn(line);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.warn(line, args);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.LoggerDefault = LoggerDefault;
|
|
136
|
+
// noinspection JSUnusedGlobalSymbols
|
|
137
|
+
/**
|
|
138
|
+
* Base logger instance
|
|
139
|
+
*
|
|
140
|
+
* @type {LoggerDefaultLike}
|
|
141
|
+
* */
|
|
142
|
+
exports.logger = new LoggerDefault();
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export type LangLike = string;
|
|
2
|
+
export type NameLike = string;
|
|
3
|
+
export type UuidLike = string;
|
|
4
|
+
export type IdLike = string | number | UuidLike;
|
|
5
|
+
export type KeywordLike = string;
|
|
6
|
+
export type FieldNameLike = string;
|
|
7
|
+
export type UrnLike = string;
|
|
8
|
+
export type UrlLike = string;
|
|
9
|
+
export type TtlLong = number;
|
|
10
|
+
export type TtlShort = number;
|
|
11
|
+
export type TimeLong = number;
|
|
12
|
+
export type TimeShort = number;
|
|
13
|
+
export type IsoDatetime = string;
|
|
14
|
+
export type IsoDate = string;
|
|
15
|
+
export type IsoTime = string;
|
|
16
|
+
export interface Entity<I extends IdLike = IdLike, N extends CanBeI18N<L> = NameLike, L extends LangLike = LangLike> extends IdDocLike<I> {
|
|
17
|
+
/**
|
|
18
|
+
* Name
|
|
19
|
+
* */
|
|
20
|
+
name?: N;
|
|
21
|
+
/**
|
|
22
|
+
* Created at
|
|
23
|
+
* */
|
|
24
|
+
createdAt?: IsoDatetime | TimeLong;
|
|
25
|
+
/**
|
|
26
|
+
* Created by
|
|
27
|
+
* */
|
|
28
|
+
createdBy?: UuidLike;
|
|
29
|
+
/**
|
|
30
|
+
* Updated at
|
|
31
|
+
* */
|
|
32
|
+
updatedAt?: IsoDatetime | TimeLong;
|
|
33
|
+
/**
|
|
34
|
+
* Updated by
|
|
35
|
+
* */
|
|
36
|
+
updatedBy?: UuidLike;
|
|
37
|
+
/**
|
|
38
|
+
* Urn
|
|
39
|
+
* */
|
|
40
|
+
_urn?: UrnLike;
|
|
41
|
+
/**
|
|
42
|
+
* Trash id if it's trashed
|
|
43
|
+
* */
|
|
44
|
+
_trashId?: UuidLike;
|
|
45
|
+
/**
|
|
46
|
+
* Revision, update count
|
|
47
|
+
* */
|
|
48
|
+
_rev?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Version
|
|
51
|
+
* */
|
|
52
|
+
_ver?: number;
|
|
53
|
+
/**
|
|
54
|
+
* search keywords
|
|
55
|
+
* */
|
|
56
|
+
_search?: SearchDoc<L>;
|
|
57
|
+
/**
|
|
58
|
+
* alpha keywords
|
|
59
|
+
* */
|
|
60
|
+
_alpha?: KeywordLike[];
|
|
61
|
+
/**
|
|
62
|
+
* Irregular fields
|
|
63
|
+
* */
|
|
64
|
+
_irregular?: FieldNameLike[];
|
|
65
|
+
}
|
|
66
|
+
export type EntityI18n<I extends IdLike = IdLike, L extends LangLike = LangLike> = Entity<I, I18nBase<L>, L>;
|
|
67
|
+
export interface Pair<I extends IdLike = IdLike> extends IdDocLike<I> {
|
|
68
|
+
/**
|
|
69
|
+
* Name
|
|
70
|
+
* */
|
|
71
|
+
name?: string;
|
|
72
|
+
}
|
|
73
|
+
export type UrnItem = string | number | Date | bigint;
|
|
74
|
+
export type UrnTuple = [UrnItem, ...UrnItem[]];
|
|
75
|
+
export type UrnDocLike = {
|
|
76
|
+
[key: FieldNameLike]: UrnItem;
|
|
77
|
+
};
|
|
78
|
+
export type UrnDef<I extends IdLike = IdLike> = IdDocLike<I> & UrnDocLike;
|
|
79
|
+
export interface IdDocLike<I extends IdLike = IdLike> {
|
|
80
|
+
/**
|
|
81
|
+
* Id
|
|
82
|
+
* */
|
|
83
|
+
id?: I;
|
|
84
|
+
}
|
|
85
|
+
export type View<I extends IdLike = IdLike> = IdDocLike<I>;
|
|
86
|
+
export type Portion<I extends IdLike = IdLike> = IdDocLike<I>;
|
|
87
|
+
export interface Portions<I extends IdLike = IdLike> {
|
|
88
|
+
ids: Array<I>;
|
|
89
|
+
}
|
|
90
|
+
export type DefDims = 'pair' | 'view' | 'portion';
|
|
91
|
+
export type I18nBase<L extends LangLike = LangLike, V = string> = {
|
|
92
|
+
[lang in L]: V;
|
|
93
|
+
};
|
|
94
|
+
export type CanBeI18N<L extends LangLike = LangLike, V = string> = string | I18nBase<L, V>;
|
|
95
|
+
export type SearchDoc<L extends LangLike = LangLike> = {
|
|
96
|
+
[lang in L]: SearchItem;
|
|
97
|
+
};
|
|
98
|
+
export type SearchItem<L extends string = DefSearchLevel> = {
|
|
99
|
+
[level in L]?: KeywordLike[];
|
|
100
|
+
};
|
|
101
|
+
export type DefSearchLevel = 'high' | 'mid' | 'low';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-base-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Backend Base Common",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@leyyo/common": "^1.
|
|
67
|
-
"@leyyo/env": "^1.
|
|
68
|
-
"
|
|
66
|
+
"@leyyo/common": "^1.2.2",
|
|
67
|
+
"@leyyo/env": "^1.2.1",
|
|
68
|
+
"@leyyo/asl": "^1.2.1"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ErrorStackLine, ExceptionLike } from "../error";
|
|
2
|
-
export declare class BaseException extends Error implements ExceptionLike {
|
|
3
|
-
status: number;
|
|
4
|
-
params: Record<string, unknown>;
|
|
5
|
-
stackTrace: Array<ErrorStackLine>;
|
|
6
|
-
constructor(message: string, params: Record<string, unknown>, status?: number);
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseException = void 0;
|
|
4
|
-
class BaseException extends Error {
|
|
5
|
-
constructor(message, params, status) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.params = params !== null && params !== void 0 ? params : {};
|
|
8
|
-
this.status = Number.isInteger(status) ? status : 499;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.BaseException = BaseException;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InitializationException = void 0;
|
|
4
|
-
// noinspection JSUnusedGlobalSymbols
|
|
5
|
-
const base_exception_1 = require("./base.exception");
|
|
6
|
-
// noinspection JSUnusedGlobalSymbols
|
|
7
|
-
class InitializationException extends base_exception_1.BaseException {
|
|
8
|
-
constructor(message) {
|
|
9
|
-
super(message, {}, 500);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.InitializationException = InitializationException;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageNotFoundException = void 0;
|
|
4
|
-
const base_exception_1 = require("./base.exception");
|
|
5
|
-
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class PageNotFoundException extends base_exception_1.BaseException {
|
|
7
|
-
constructor(path) {
|
|
8
|
-
super(`Path: ${path} is not found`, { path }, 404);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.PageNotFoundException = PageNotFoundException;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordDuplicatedException = void 0;
|
|
4
|
-
const base_exception_1 = require("./base.exception");
|
|
5
|
-
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordDuplicatedException extends base_exception_1.BaseException {
|
|
7
|
-
constructor(domain, value, id) {
|
|
8
|
-
let valueJson;
|
|
9
|
-
try {
|
|
10
|
-
valueJson = JSON.stringify(value);
|
|
11
|
-
}
|
|
12
|
-
catch (_e) {
|
|
13
|
-
//
|
|
14
|
-
}
|
|
15
|
-
super(`${domain} is duplicated with values: ${valueJson}, existing:${id}`, { domain, id, value }, 409);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.RecordDuplicatedException = RecordDuplicatedException;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordNotFoundException = void 0;
|
|
4
|
-
const base_exception_1 = require("./base.exception");
|
|
5
|
-
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordNotFoundException extends base_exception_1.BaseException {
|
|
7
|
-
constructor(domain, key, value) {
|
|
8
|
-
super(`Record could not be found`, {
|
|
9
|
-
domain, key, value
|
|
10
|
-
}, 404);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.RecordNotFoundException = RecordNotFoundException;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationException = void 0;
|
|
4
|
-
const base_exception_1 = require("./base.exception");
|
|
5
|
-
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class ValidationException extends base_exception_1.BaseException {
|
|
7
|
-
constructor(domain, key, value, params) {
|
|
8
|
-
try {
|
|
9
|
-
value = JSON.parse(JSON.stringify(value));
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
value = undefined;
|
|
13
|
-
}
|
|
14
|
-
if (!params) {
|
|
15
|
-
params = { domain, key, value };
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
params = Object.assign(Object.assign({}, params), { domain, key, value });
|
|
19
|
-
}
|
|
20
|
-
super(`${domain} -> ${key} is invalid`, params, 409);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.ValidationException = ValidationException;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface _Func {
|
|
2
|
-
readonly name?: string;
|
|
3
|
-
readonly length?: number;
|
|
4
|
-
bind(thisArg: any, ...args: Array<any>): any;
|
|
5
|
-
apply(thisArg: any, args: Array<any>): any;
|
|
6
|
-
call(thisArg: any, ...args: Array<any>): any;
|
|
7
|
-
}
|
|
8
|
-
export interface ClassLike<T = {}> extends _Func {
|
|
9
|
-
new (...args: Array<any>): T;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|