@samet-it/be-base-common 1.1.5 → 1.3.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 +5 -9
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -18
- package/dist/config/index.types.d.ts +2 -2
- package/dist/config/index.types.js +1 -2
- package/dist/error/error.handler.d.ts +1 -1
- package/dist/error/error.handler.js +9 -12
- package/dist/error/index.d.ts +3 -3
- package/dist/error/index.js +3 -19
- package/dist/error/index.types.d.ts +1 -1
- package/dist/error/index.types.js +1 -2
- package/dist/error/items/index.d.ts +5 -5
- package/dist/error/items/index.js +5 -21
- package/dist/error/items/page-not-found.error.d.ts +4 -2
- package/dist/error/items/page-not-found.error.js +4 -7
- package/dist/error/items/record-duplicated.error.d.ts +4 -2
- package/dist/error/items/record-duplicated.error.js +4 -7
- package/dist/error/items/record-not-found.error.d.ts +4 -2
- package/dist/error/items/record-not-found.error.js +4 -7
- package/dist/error/items/samet.error.d.ts +1 -1
- package/dist/error/items/samet.error.js +2 -6
- package/dist/error/items/validation.error.d.ts +4 -2
- package/dist/error/items/validation.error.js +4 -7
- package/dist/exit/exit-handler.impl.d.ts +1 -1
- package/dist/exit/exit-handler.impl.js +8 -7
- package/dist/exit/index.d.ts +2 -2
- package/dist/exit/index.js +2 -18
- package/dist/exit/index.types.js +1 -2
- package/dist/generator/generator.d.ts +1 -1
- package/dist/generator/generator.js +10 -15
- package/dist/generator/index.d.ts +2 -2
- package/dist/generator/index.js +2 -18
- package/dist/generator/index.types.js +1 -2
- package/dist/index.d.ts +14 -6
- package/dist/index.js +14 -22
- package/dist/logger/index.d.ts +2 -2
- package/dist/logger/index.js +2 -18
- package/dist/logger/index.types.d.ts +4 -4
- package/dist/logger/index.types.js +1 -2
- package/dist/logger/logger.impl.d.ts +1 -1
- package/dist/logger/logger.impl.js +14 -9
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.js +1 -17
- package/dist/model/index.types.d.ts +1 -15
- package/dist/model/index.types.js +2 -2
- package/package.json +12 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseCommonConf } from "./index.types.js";
|
|
2
2
|
export declare const baseCommonConfig: import("@leyyo/env").EnvScopeRuntime<BaseCommonConf, undefined, undefined>;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.baseCommonConfig = void 0;
|
|
5
|
-
const env_1 = require("@leyyo/env");
|
|
6
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { envCore } from "@leyyo/env";
|
|
2
|
+
import { LogLevelItems } from "@leyyo/common";
|
|
7
3
|
// noinspection JSUnusedGlobalSymbols
|
|
8
|
-
|
|
4
|
+
export const baseCommonConfig = envCore.configure
|
|
9
5
|
.scope('BaseCommon')
|
|
10
6
|
.start()
|
|
11
7
|
.field('NODE_ENV').text().def('development').end()
|
|
12
|
-
.field('LOG_LEVEL').literal(
|
|
13
|
-
.field('npm_config_node_version').string().def(
|
|
8
|
+
.field('LOG_LEVEL').literal(LogLevelItems).required().def('info').end()
|
|
9
|
+
.field('npm_config_node_version').string().def(process?.versions?.node).end()
|
|
14
10
|
.field('npm_package_name').string().end()
|
|
15
11
|
.field('npm_package_version').string().end()
|
|
16
12
|
.field('npm_config_npm_version').string().end()
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './base-common.config';
|
|
2
|
-
export * from './index.types';
|
|
1
|
+
export * from './base-common.config.js';
|
|
2
|
+
export * from './index.types.js';
|
package/dist/config/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./base-common.config"), exports);
|
|
18
|
-
__exportStar(require("./index.types"), exports);
|
|
1
|
+
export * from './base-common.config.js';
|
|
2
|
+
export * from './index.types.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ErrorHandlerLike } from "./index.types.js";
|
|
2
2
|
export declare const errorHandler: ErrorHandlerLike;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorHandler = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { errorCommon } from "@leyyo/common";
|
|
5
2
|
class ErrorHandler {
|
|
3
|
+
_CLEAR_STAT = 1_000 * 60 * 60 * 24; // daily
|
|
4
|
+
_stats = new Map();
|
|
5
|
+
started;
|
|
6
|
+
common = errorCommon;
|
|
6
7
|
constructor() {
|
|
7
|
-
this._CLEAR_STAT = 1000 * 60 * 60 * 24; // daily
|
|
8
|
-
this._stats = new Map();
|
|
9
|
-
this.common = common_1.$err;
|
|
10
8
|
this.started = new Date();
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
errorCommon.addKnownPackage('@samet-it', 's');
|
|
10
|
+
errorCommon.addKnownPackage('@nestjs', 'n');
|
|
13
11
|
this._clearStats();
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
@@ -39,13 +37,12 @@ class ErrorHandler {
|
|
|
39
37
|
return num;
|
|
40
38
|
}
|
|
41
39
|
listStats() {
|
|
42
|
-
var _a, _b;
|
|
43
40
|
const map = {};
|
|
44
41
|
let id = 0;
|
|
45
42
|
for (const [error, num] of this._stats.entries()) {
|
|
46
43
|
let name;
|
|
47
44
|
try {
|
|
48
|
-
name =
|
|
45
|
+
name = error.name ?? error.constructor?.name;
|
|
49
46
|
}
|
|
50
47
|
catch (e) {
|
|
51
48
|
id++;
|
|
@@ -61,4 +58,4 @@ class ErrorHandler {
|
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
// noinspection JSUnusedGlobalSymbols
|
|
64
|
-
|
|
61
|
+
export const errorHandler = new ErrorHandler();
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './index.types';
|
|
2
|
-
export * from './error.handler';
|
|
3
|
-
export * from './items';
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './error.handler.js';
|
|
3
|
+
export * from './items/index.js';
|
package/dist/error/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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("./error.handler"), exports);
|
|
19
|
-
__exportStar(require("./items"), exports);
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './error.handler.js';
|
|
3
|
+
export * from './items/index.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './page-not-found.error';
|
|
2
|
-
export * from './record-duplicated.error';
|
|
3
|
-
export * from './record-not-found.error';
|
|
4
|
-
export * from './samet.error';
|
|
5
|
-
export * from './validation.error';
|
|
1
|
+
export * from './page-not-found.error.js';
|
|
2
|
+
export * from './record-duplicated.error.js';
|
|
3
|
+
export * from './record-not-found.error.js';
|
|
4
|
+
export * from './samet.error.js';
|
|
5
|
+
export * from './validation.error.js';
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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);
|
|
1
|
+
export * from './page-not-found.error.js';
|
|
2
|
+
export * from './record-duplicated.error.js';
|
|
3
|
+
export * from './record-not-found.error.js';
|
|
4
|
+
export * from './samet.error.js';
|
|
5
|
+
export * from './validation.error.js';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error.js";
|
|
3
|
+
export declare class PageNotFoundError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(path: string, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageNotFoundError = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { SametError } from "./samet.error.js";
|
|
5
2
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class PageNotFoundError extends
|
|
3
|
+
export class PageNotFoundError extends SametError {
|
|
4
|
+
status = 404;
|
|
7
5
|
constructor(path, opt) {
|
|
8
|
-
super(`Path: ${path} is not found`,
|
|
6
|
+
super(`Path: ${path} is not found`, { ...opt, path });
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
exports.PageNotFoundError = PageNotFoundError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error.js";
|
|
3
|
+
export declare class RecordDuplicatedError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, query: Record<string, unknown>, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordDuplicatedError = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { SametError } from "./samet.error.js";
|
|
5
2
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordDuplicatedError extends
|
|
3
|
+
export class RecordDuplicatedError extends SametError {
|
|
4
|
+
status = 409;
|
|
7
5
|
constructor(domain, query, opt) {
|
|
8
|
-
super(`${domain} record is duplicated`,
|
|
6
|
+
super(`${domain} record is duplicated`, { ...opt, domain, query });
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
exports.RecordDuplicatedError = RecordDuplicatedError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error.js";
|
|
3
|
+
export declare class RecordNotFoundError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, query: Record<string, unknown>, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordNotFoundError = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { SametError } from "./samet.error.js";
|
|
5
2
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordNotFoundError extends
|
|
3
|
+
export class RecordNotFoundError extends SametError {
|
|
4
|
+
status = 400;
|
|
7
5
|
constructor(domain, query, opt) {
|
|
8
|
-
super(`${domain} record could not be found`,
|
|
6
|
+
super(`${domain} record could not be found`, { ...opt, domain, query });
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
exports.RecordNotFoundError = RecordNotFoundError;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SametError = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { LeyyoError } from "@leyyo/common";
|
|
5
2
|
/**
|
|
6
3
|
* Samet base error
|
|
7
4
|
* */
|
|
8
|
-
class SametError extends
|
|
5
|
+
export class SametError extends LeyyoError {
|
|
9
6
|
}
|
|
10
|
-
exports.SametError = SametError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error.js";
|
|
3
|
+
export declare class ValidationError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, key: string, value?: unknown, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationError = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { SametError } from "./samet.error.js";
|
|
5
2
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class ValidationError extends
|
|
3
|
+
export class ValidationError extends SametError {
|
|
4
|
+
status = 400;
|
|
7
5
|
constructor(domain, key, value, opt) {
|
|
8
|
-
super(`${domain} -> ${key} is invalid`,
|
|
6
|
+
super(`${domain} -> ${key} is invalid`, { ...opt, domain, key, value });
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
exports.ValidationError = ValidationError;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExitHandler } from "./index.types";
|
|
1
|
+
import type { ExitHandler } from "./index.types.js";
|
|
2
2
|
export declare const exitHandler: ExitHandler;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exitHandler = void 0;
|
|
4
1
|
class ExitHandlerImpl {
|
|
5
2
|
register(fn) {
|
|
6
3
|
['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGKILL'].forEach(event => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
try {
|
|
5
|
+
process.on(event, () => {
|
|
6
|
+
fn(`${event} event received`);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
}
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
// noinspection JSUnusedGlobalSymbols
|
|
14
|
-
|
|
15
|
+
export const exitHandler = new ExitHandlerImpl();
|
package/dist/exit/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './exit-handler.impl';
|
|
2
|
-
export * from './index.types';
|
|
1
|
+
export * from './exit-handler.impl.js';
|
|
2
|
+
export * from './index.types.js';
|
package/dist/exit/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./exit-handler.impl"), exports);
|
|
18
|
-
__exportStar(require("./index.types"), exports);
|
|
1
|
+
export * from './exit-handler.impl.js';
|
|
2
|
+
export * from './index.types.js';
|
package/dist/exit/index.types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneratorLike } from "./index.types";
|
|
1
|
+
import { GeneratorLike } from "./index.types.js";
|
|
2
2
|
export declare const generator: GeneratorLike;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generator = void 0;
|
|
4
|
-
const node_crypto_1 = require("node:crypto");
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
5
2
|
const NUMERIC = '0123456789';
|
|
6
3
|
const UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
7
4
|
const LOWER = 'abcdefghijklmnopqrstuvwxyz';
|
|
8
5
|
const ALPHABET = NUMERIC + UPPER + LOWER;
|
|
9
|
-
const SECONDS =
|
|
6
|
+
const SECONDS = 1_000;
|
|
10
7
|
const MINUTES = SECONDS * 60;
|
|
11
8
|
const HOURS = MINUTES * 60;
|
|
12
9
|
const DAYS = HOURS * 24;
|
|
@@ -45,9 +42,7 @@ const LOREM = [
|
|
|
45
42
|
'elementum', 'tempor', 'risus', 'cras'
|
|
46
43
|
];
|
|
47
44
|
class Generator {
|
|
48
|
-
|
|
49
|
-
this._start = new Date().getTime();
|
|
50
|
-
}
|
|
45
|
+
_start = new Date().getTime();
|
|
51
46
|
/**
|
|
52
47
|
* Checks number value in a range
|
|
53
48
|
*
|
|
@@ -58,7 +53,7 @@ class Generator {
|
|
|
58
53
|
* */
|
|
59
54
|
_range(value, min, max, def) {
|
|
60
55
|
if (typeof value !== "number") {
|
|
61
|
-
return def
|
|
56
|
+
return def ?? min;
|
|
62
57
|
}
|
|
63
58
|
if (value < min) {
|
|
64
59
|
return min;
|
|
@@ -103,14 +98,14 @@ class Generator {
|
|
|
103
98
|
if (min === undefined) {
|
|
104
99
|
if (max === undefined) {
|
|
105
100
|
min = 0;
|
|
106
|
-
max =
|
|
101
|
+
max = 1_000;
|
|
107
102
|
}
|
|
108
103
|
else {
|
|
109
|
-
min = max -
|
|
104
|
+
min = max - 1_000;
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
else if (max === undefined) {
|
|
113
|
-
max = min +
|
|
108
|
+
max = min + 1_000;
|
|
114
109
|
}
|
|
115
110
|
if (min > max) {
|
|
116
111
|
const swap = min;
|
|
@@ -254,7 +249,7 @@ class Generator {
|
|
|
254
249
|
}
|
|
255
250
|
/** {@inheritDoc} */
|
|
256
251
|
uuid() {
|
|
257
|
-
return
|
|
252
|
+
return randomUUID();
|
|
258
253
|
}
|
|
259
254
|
/** {@inheritDoc} */
|
|
260
255
|
uuidArray(size) {
|
|
@@ -271,7 +266,7 @@ class Generator {
|
|
|
271
266
|
/** {@inheritDoc} */
|
|
272
267
|
timestamp(type, value, pastFuture) {
|
|
273
268
|
let diff;
|
|
274
|
-
value = this._range(value, 1,
|
|
269
|
+
value = this._range(value, 1, 1_000, 10);
|
|
275
270
|
switch (type) {
|
|
276
271
|
case "year":
|
|
277
272
|
case "y":
|
|
@@ -414,4 +409,4 @@ class Generator {
|
|
|
414
409
|
}
|
|
415
410
|
}
|
|
416
411
|
// noinspection JSUnusedGlobalSymbols
|
|
417
|
-
|
|
412
|
+
export const generator = new Generator();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './generator';
|
|
2
|
-
export * from './index.types';
|
|
1
|
+
export * from './generator.js';
|
|
2
|
+
export * from './index.types.js';
|
package/dist/generator/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./generator"), exports);
|
|
18
|
-
__exportStar(require("./index.types"), exports);
|
|
1
|
+
export * from './generator.js';
|
|
2
|
+
export * from './index.types.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
export * from './config';
|
|
2
|
-
export * from './error';
|
|
3
|
-
export * from './exit';
|
|
4
|
-
export * from './generator';
|
|
5
|
-
export * from './logger';
|
|
6
|
-
export * from './model';
|
|
1
|
+
export * from './config/index.js';
|
|
2
|
+
export * from './error/index.js';
|
|
3
|
+
export * from './exit/index.js';
|
|
4
|
+
export * from './generator/index.js';
|
|
5
|
+
export * from './logger/index.js';
|
|
6
|
+
export * from './model/index.js';
|
|
7
|
+
export * from '@leyyo/asl';
|
|
8
|
+
export * from '@leyyo/assert';
|
|
9
|
+
export * from '@leyyo/builder';
|
|
10
|
+
export * from '@leyyo/common';
|
|
11
|
+
export * from '@leyyo/either';
|
|
12
|
+
export * from '@leyyo/env';
|
|
13
|
+
export * from '@leyyo/enveloper';
|
|
14
|
+
export * from '@leyyo/type';
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./config"), exports);
|
|
18
|
-
__exportStar(require("./error"), exports);
|
|
19
|
-
__exportStar(require("./exit"), exports);
|
|
20
|
-
__exportStar(require("./generator"), exports);
|
|
21
|
-
__exportStar(require("./logger"), exports);
|
|
22
|
-
__exportStar(require("./model"), exports);
|
|
1
|
+
export * from './config/index.js';
|
|
2
|
+
export * from './error/index.js';
|
|
3
|
+
export * from './exit/index.js';
|
|
4
|
+
export * from './generator/index.js';
|
|
5
|
+
export * from './logger/index.js';
|
|
6
|
+
export * from './model/index.js';
|
|
7
|
+
export * from '@leyyo/asl';
|
|
8
|
+
export * from '@leyyo/assert';
|
|
9
|
+
export * from '@leyyo/builder';
|
|
10
|
+
export * from '@leyyo/common';
|
|
11
|
+
export * from '@leyyo/either';
|
|
12
|
+
export * from '@leyyo/env';
|
|
13
|
+
export * from '@leyyo/enveloper';
|
|
14
|
+
export * from '@leyyo/type';
|
package/dist/logger/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './index.types';
|
|
2
|
-
export * from './logger.impl';
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './logger.impl.js';
|
package/dist/logger/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.impl"), exports);
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './logger.impl.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ClassLike, Obj, Logger } from "@leyyo/common";
|
|
2
2
|
/**
|
|
3
3
|
* Logger pool interface
|
|
4
4
|
* */
|
|
@@ -9,21 +9,21 @@ export interface LoggerLike {
|
|
|
9
9
|
* @param {string} className - class name
|
|
10
10
|
* @return {Logger} - logger instance
|
|
11
11
|
* */
|
|
12
|
-
|
|
12
|
+
of(className: string): Logger;
|
|
13
13
|
/**
|
|
14
14
|
* Create logger by class
|
|
15
15
|
*
|
|
16
16
|
* @param {function} clazz - class
|
|
17
17
|
* @return {Logger} - logger instance
|
|
18
18
|
* */
|
|
19
|
-
|
|
19
|
+
of(clazz: ClassLike): Logger;
|
|
20
20
|
/**
|
|
21
21
|
* Create logger by instance
|
|
22
22
|
*
|
|
23
23
|
* @param {Obj} instance - instance, ie: `this`
|
|
24
24
|
* @return {Logger} - logger instance
|
|
25
25
|
* */
|
|
26
|
-
|
|
26
|
+
of(instance: Obj): Logger;
|
|
27
27
|
/**
|
|
28
28
|
* Get samet default logger
|
|
29
29
|
*
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logger = void 0;
|
|
4
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import { logCommon } from "@leyyo/common";
|
|
5
2
|
/**
|
|
6
3
|
* Logger pool class
|
|
7
4
|
* */
|
|
8
5
|
class LoggerImpl {
|
|
6
|
+
/**
|
|
7
|
+
* Samet default logger
|
|
8
|
+
* */
|
|
9
|
+
_sametLogger;
|
|
10
|
+
/**
|
|
11
|
+
* Developer default logger
|
|
12
|
+
* */
|
|
13
|
+
_developerLogger;
|
|
9
14
|
/**
|
|
10
15
|
* Create logger
|
|
11
16
|
*
|
|
12
17
|
* @param {(string|ClassLike|Obj)} ref - class name, class or instance
|
|
13
18
|
* @return {Logger} - logger instance
|
|
14
19
|
* */
|
|
15
|
-
|
|
16
|
-
return
|
|
20
|
+
of(ref) {
|
|
21
|
+
return logCommon.of(ref);
|
|
17
22
|
}
|
|
18
23
|
/** @inheritDoc */
|
|
19
24
|
get samet() {
|
|
20
25
|
if (!this._sametLogger) {
|
|
21
|
-
this._sametLogger =
|
|
26
|
+
this._sametLogger = logCommon.of('Samet');
|
|
22
27
|
}
|
|
23
28
|
return this._sametLogger;
|
|
24
29
|
}
|
|
25
30
|
/** @inheritDoc */
|
|
26
31
|
get developer() {
|
|
27
32
|
if (!this._developerLogger) {
|
|
28
|
-
this._developerLogger =
|
|
33
|
+
this._developerLogger = logCommon.of('Developer');
|
|
29
34
|
}
|
|
30
35
|
return this._developerLogger;
|
|
31
36
|
}
|
|
@@ -36,4 +41,4 @@ class LoggerImpl {
|
|
|
36
41
|
*
|
|
37
42
|
* @type {LoggerLike}
|
|
38
43
|
* */
|
|
39
|
-
|
|
44
|
+
export const logger = new LoggerImpl();
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './index.types';
|
|
1
|
+
export * from './index.types.js';
|
package/dist/model/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
export * from './index.types.js';
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
import { FieldNameLike, IdLike, IsoDatetime, KeywordLike, LangLike, NameLike, TimeLong, UrnLike, UuidLike } from "@leyyo/common";
|
|
16
2
|
export interface Entity<I extends IdLike = IdLike, N extends CanBeI18N<L> = NameLike, L extends LangLike = LangLike> extends IdDocLike<I> {
|
|
17
3
|
/**
|
|
18
4
|
* Name
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-base-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Backend Base Common",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"email": "mustafay@samet.com.tr"
|
|
17
17
|
},
|
|
18
18
|
"main": "dist/index.js",
|
|
19
|
-
"type": "
|
|
19
|
+
"type": "module",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"clear": "rimraf dist && rimraf coverage",
|
|
22
22
|
"clear:nm": "rimraf node_modules && npm run clear",
|
|
23
23
|
"lint": "eslint src/**/*.ts --quiet",
|
|
24
24
|
"lint:verbose": "eslint src/**/*.ts",
|
|
25
|
-
"asset": "node -r ts-node/register commands/assets.
|
|
25
|
+
"asset": "node -r ts-node/register commands/assets.js",
|
|
26
26
|
"build": "npm run clear && tsc && npm run asset",
|
|
27
27
|
"test": "jest --config=jest.json --detectOpenHandles",
|
|
28
28
|
"coverage": "rimraf coverage && jest --config=jest.json --coverage --coverageDirectory=coverage",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@babel/preset-env": "^7.28.0",
|
|
38
38
|
"@babel/preset-typescript": "^7.27.1",
|
|
39
39
|
"@eslint/js": "^9.33.0",
|
|
40
|
+
"@types/express": "^5.0.6",
|
|
40
41
|
"@types/jest": "^30.0.0",
|
|
41
42
|
"@types/node": "^24.2.1",
|
|
42
43
|
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
@@ -63,8 +64,13 @@
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@leyyo/
|
|
67
|
-
"@leyyo/
|
|
68
|
-
"@leyyo/
|
|
67
|
+
"@leyyo/asl": "^1.3.4",
|
|
68
|
+
"@leyyo/assert": "^1.3.1",
|
|
69
|
+
"@leyyo/builder": "^3.1.10",
|
|
70
|
+
"@leyyo/common": "^1.3.10",
|
|
71
|
+
"@leyyo/either": "^1.3.3",
|
|
72
|
+
"@leyyo/env": "^1.3.9",
|
|
73
|
+
"@leyyo/enveloper": "^1.3.4",
|
|
74
|
+
"@leyyo/type": "^1.3.4"
|
|
69
75
|
}
|
|
70
76
|
}
|