@gennext/lb-infra 0.0.2 → 0.0.4
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/base/base.helper.d.ts +10 -0
- package/dist/base/base.helper.d.ts.map +1 -0
- package/dist/base/base.helper.js +12 -0
- package/dist/base/base.helper.js.map +1 -0
- package/dist/base/datasources/base.datasource.d.ts +14 -0
- package/dist/base/datasources/base.datasource.d.ts.map +1 -0
- package/dist/base/datasources/base.datasource.js +24 -0
- package/dist/base/datasources/base.datasource.js.map +1 -0
- package/dist/base/datasources/index.d.ts +3 -0
- package/dist/base/datasources/index.d.ts.map +1 -0
- package/dist/base/datasources/index.js +19 -0
- package/dist/base/datasources/index.js.map +1 -0
- package/dist/base/datasources/types.d.ts +5 -0
- package/dist/base/datasources/types.d.ts.map +1 -0
- package/dist/base/datasources/types.js +3 -0
- package/dist/base/datasources/types.js.map +1 -0
- package/dist/base/index.d.ts +4 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +20 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/models/base.model.d.ts +16 -0
- package/dist/base/models/base.model.d.ts.map +1 -0
- package/dist/base/models/base.model.js +44 -0
- package/dist/base/models/base.model.js.map +1 -0
- package/dist/base/models/index.d.ts +2 -0
- package/dist/base/models/index.d.ts.map +1 -0
- package/dist/base/models/index.js +18 -0
- package/dist/base/models/index.js.map +1 -0
- package/dist/common/constants.d.ts +35 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +52 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +20 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/result-codes.d.ts +30 -0
- package/dist/common/result-codes.d.ts.map +1 -0
- package/dist/common/result-codes.js +37 -0
- package/dist/common/result-codes.js.map +1 -0
- package/dist/common/types.d.ts +189 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -0
- package/dist/datasources/index.d.ts +3 -0
- package/dist/datasources/index.d.ts.map +1 -0
- package/dist/datasources/index.js +19 -0
- package/dist/datasources/index.js.map +1 -0
- package/dist/datasources/postgres/datasource.d.ts +8 -0
- package/dist/datasources/postgres/datasource.d.ts.map +1 -0
- package/dist/datasources/postgres/datasource.js +72 -0
- package/dist/datasources/postgres/datasource.js.map +1 -0
- package/dist/datasources/postgres/index.d.ts +3 -0
- package/dist/datasources/postgres/index.d.ts.map +1 -0
- package/dist/datasources/postgres/index.js +19 -0
- package/dist/datasources/postgres/index.js.map +1 -0
- package/dist/datasources/postgres/types.d.ts +10 -0
- package/dist/datasources/postgres/types.d.ts.map +1 -0
- package/dist/datasources/postgres/types.js +3 -0
- package/dist/datasources/postgres/types.js.map +1 -0
- package/dist/datasources/redis/connector.d.ts +37 -0
- package/dist/datasources/redis/connector.d.ts.map +1 -0
- package/dist/datasources/redis/connector.js +134 -0
- package/dist/datasources/redis/connector.js.map +1 -0
- package/dist/datasources/redis/datasource.d.ts +10 -0
- package/dist/datasources/redis/datasource.d.ts.map +1 -0
- package/dist/datasources/redis/datasource.js +48 -0
- package/dist/datasources/redis/datasource.js.map +1 -0
- package/dist/datasources/redis/index.d.ts +4 -0
- package/dist/datasources/redis/index.d.ts.map +1 -0
- package/dist/datasources/redis/index.js +20 -0
- package/dist/datasources/redis/index.js.map +1 -0
- package/dist/datasources/redis/types.d.ts +11 -0
- package/dist/datasources/redis/types.d.ts.map +1 -0
- package/dist/datasources/redis/types.js +3 -0
- package/dist/datasources/redis/types.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/logger/application-logger.d.ts +22 -0
- package/dist/helpers/logger/application-logger.d.ts.map +1 -0
- package/dist/helpers/logger/application-logger.js +95 -0
- package/dist/helpers/logger/application-logger.js.map +1 -0
- package/dist/helpers/logger/common/index.d.ts +2 -0
- package/dist/helpers/logger/common/index.d.ts.map +1 -0
- package/dist/helpers/logger/common/index.js +18 -0
- package/dist/helpers/logger/common/index.js.map +1 -0
- package/dist/helpers/logger/common/types.d.ts +16 -0
- package/dist/helpers/logger/common/types.d.ts.map +1 -0
- package/dist/helpers/logger/common/types.js +30 -0
- package/dist/helpers/logger/common/types.js.map +1 -0
- package/dist/helpers/logger/default-logger.d.ts +34 -0
- package/dist/helpers/logger/default-logger.d.ts.map +1 -0
- package/dist/helpers/logger/default-logger.js +122 -0
- package/dist/helpers/logger/default-logger.js.map +1 -0
- package/dist/helpers/logger/factory.d.ts +5 -0
- package/dist/helpers/logger/factory.d.ts.map +1 -0
- package/dist/helpers/logger/factory.js +13 -0
- package/dist/helpers/logger/factory.js.map +1 -0
- package/dist/helpers/logger/index.d.ts +5 -0
- package/dist/helpers/logger/index.d.ts.map +1 -0
- package/dist/helpers/logger/index.js +21 -0
- package/dist/helpers/logger/index.js.map +1 -0
- package/dist/helpers/logger/transports/dgram.transport.d.ts +29 -0
- package/dist/helpers/logger/transports/dgram.transport.d.ts.map +1 -0
- package/dist/helpers/logger/transports/dgram.transport.js +74 -0
- package/dist/helpers/logger/transports/dgram.transport.js.map +1 -0
- package/dist/helpers/logger/transports/index.d.ts +2 -0
- package/dist/helpers/logger/transports/index.d.ts.map +1 -0
- package/dist/helpers/logger/transports/index.js +18 -0
- package/dist/helpers/logger/transports/index.js.map +1 -0
- package/dist/helpers/redis/default.helper.d.ts +135 -0
- package/dist/helpers/redis/default.helper.d.ts.map +1 -0
- package/dist/helpers/redis/default.helper.js +307 -0
- package/dist/helpers/redis/default.helper.js.map +1 -0
- package/dist/helpers/redis/index.d.ts +5 -0
- package/dist/helpers/redis/index.d.ts.map +1 -0
- package/dist/helpers/redis/index.js +21 -0
- package/dist/helpers/redis/index.js.map +1 -0
- package/dist/helpers/redis/redis-cluster.helper.d.ts +8 -0
- package/dist/helpers/redis/redis-cluster.helper.d.ts.map +1 -0
- package/dist/helpers/redis/redis-cluster.helper.js +27 -0
- package/dist/helpers/redis/redis-cluster.helper.js.map +1 -0
- package/dist/helpers/redis/redis.helper.d.ts +8 -0
- package/dist/helpers/redis/redis.helper.d.ts.map +1 -0
- package/dist/helpers/redis/redis.helper.js +43 -0
- package/dist/helpers/redis/redis.helper.js.map +1 -0
- package/dist/helpers/redis/types.d.ts +43 -0
- package/dist/helpers/redis/types.d.ts.map +1 -0
- package/dist/helpers/redis/types.js +3 -0
- package/dist/helpers/redis/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/crypto.utility.d.ts +7 -0
- package/dist/utilities/crypto.utility.d.ts.map +1 -0
- package/dist/utilities/crypto.utility.js +26 -0
- package/dist/utilities/crypto.utility.js.map +1 -0
- package/dist/utilities/date.utility.d.ts +18 -0
- package/dist/utilities/date.utility.d.ts.map +1 -0
- package/dist/utilities/date.utility.js +75 -0
- package/dist/utilities/date.utility.js.map +1 -0
- package/dist/utilities/error.utility.d.ts +15 -0
- package/dist/utilities/error.utility.d.ts.map +1 -0
- package/dist/utilities/error.utility.js +18 -0
- package/dist/utilities/error.utility.js.map +1 -0
- package/dist/utilities/index.d.ts +12 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +28 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/model.utility.d.ts +9 -0
- package/dist/utilities/model.utility.d.ts.map +1 -0
- package/dist/utilities/model.utility.js +28 -0
- package/dist/utilities/model.utility.js.map +1 -0
- package/dist/utilities/module.utility.d.ts +5 -0
- package/dist/utilities/module.utility.d.ts.map +1 -0
- package/dist/utilities/module.utility.js +21 -0
- package/dist/utilities/module.utility.js.map +1 -0
- package/dist/utilities/parse.utility.d.ts +34 -0
- package/dist/utilities/parse.utility.d.ts.map +1 -0
- package/dist/utilities/parse.utility.js +215 -0
- package/dist/utilities/parse.utility.js.map +1 -0
- package/dist/utilities/performance.utility.d.ts +6 -0
- package/dist/utilities/performance.utility.d.ts.map +1 -0
- package/dist/utilities/performance.utility.js +14 -0
- package/dist/utilities/performance.utility.js.map +1 -0
- package/dist/utilities/promise.utility.d.ts +28 -0
- package/dist/utilities/promise.utility.d.ts.map +1 -0
- package/dist/utilities/promise.utility.js +41 -0
- package/dist/utilities/promise.utility.js.map +1 -0
- package/dist/utilities/query.utility.d.ts +31 -0
- package/dist/utilities/query.utility.d.ts.map +1 -0
- package/dist/utilities/query.utility.js +145 -0
- package/dist/utilities/query.utility.js.map +1 -0
- package/dist/utilities/request.utility.d.ts +21 -0
- package/dist/utilities/request.utility.d.ts.map +1 -0
- package/dist/utilities/request.utility.js +46 -0
- package/dist/utilities/request.utility.js.map +1 -0
- package/dist/utilities/url.utility.d.ts +3 -0
- package/dist/utilities/url.utility.d.ts.map +1 -0
- package/dist/utilities/url.utility.js +32 -0
- package/dist/utilities/url.utility.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Redis from "ioredis";
|
|
2
|
+
import { DefaultRedisHelper } from "./default.helper";
|
|
3
|
+
import { IRedisHelperOptions } from "./types";
|
|
4
|
+
export declare class RedisHelper extends DefaultRedisHelper {
|
|
5
|
+
constructor(opts: IRedisHelperOptions);
|
|
6
|
+
getClient(): Redis;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=redis.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/redis/redis.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,qBAAa,WAAY,SAAQ,kBAAkB;gBACrC,IAAI,EAAE,mBAAmB;IAyC5B,SAAS,IACM,KAAK;CAE9B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RedisHelper = void 0;
|
|
7
|
+
const parse_utility_1 = require("../../utilities/parse.utility");
|
|
8
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
9
|
+
const default_helper_1 = require("./default.helper");
|
|
10
|
+
class RedisHelper extends default_helper_1.DefaultRedisHelper {
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
const { name, host, port, password,
|
|
13
|
+
// Optional
|
|
14
|
+
database = 0, autoConnect = true, maxRetry = 0, } = opts;
|
|
15
|
+
super({
|
|
16
|
+
...opts,
|
|
17
|
+
scope: RedisHelper.name,
|
|
18
|
+
identifier: name,
|
|
19
|
+
client: new ioredis_1.default({
|
|
20
|
+
name,
|
|
21
|
+
host,
|
|
22
|
+
port: (0, parse_utility_1.int)(port),
|
|
23
|
+
password,
|
|
24
|
+
db: database,
|
|
25
|
+
lazyConnect: !autoConnect,
|
|
26
|
+
showFriendlyErrorStack: true,
|
|
27
|
+
retryStrategy: (attemptCounter) => {
|
|
28
|
+
if (maxRetry > -1 && attemptCounter > maxRetry) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const strategy = Math.max(Math.min(attemptCounter * 2000, 5000), 1000);
|
|
32
|
+
return strategy;
|
|
33
|
+
},
|
|
34
|
+
maxRetriesPerRequest: null,
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getClient() {
|
|
39
|
+
return this.client;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.RedisHelper = RedisHelper;
|
|
43
|
+
//# sourceMappingURL=redis.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.helper.js","sourceRoot":"","sources":["../../../src/helpers/redis/redis.helper.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAgD;AAChD,sDAA4B;AAC5B,qDAAsD;AAGtD,MAAa,WAAY,SAAQ,mCAAkB;IACjD,YAAY,IAAyB;QACnC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ;QAER,WAAW;QACX,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,CAAC,GACb,GAAG,IAAI,CAAC;QAET,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,WAAW,CAAC,IAAI;YACvB,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI,iBAAK,CAAC;gBAChB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,IAAA,mBAAG,EAAC,IAAI,CAAC;gBACf,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,sBAAsB,EAAE,IAAI;gBAC5B,aAAa,EAAE,CAAC,cAAsB,EAAE,EAAE;oBACxC,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,cAAc,GAAG,QAAQ,EAAE,CAAC;wBAC/C,OAAO,SAAS,CAAC;oBACnB,CAAC;oBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CACvB,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,EAAE,IAAI,CAAC,EACrC,IAAI,CACL,CAAC;oBACF,OAAO,QAAQ,CAAC;gBAClB,CAAC;gBACD,oBAAoB,EAAE,IAAI;aAC3B,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAe,CAAC;IAC9B,CAAC;CACF;AA7CD,kCA6CC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseHelper } from "../../base/base.helper";
|
|
2
|
+
import { ClusterOptions } from "ioredis";
|
|
3
|
+
export interface IRedisHelperProps {
|
|
4
|
+
name: string;
|
|
5
|
+
host: string;
|
|
6
|
+
port: string | number;
|
|
7
|
+
user?: string;
|
|
8
|
+
password: string;
|
|
9
|
+
database?: number;
|
|
10
|
+
autoConnect?: boolean;
|
|
11
|
+
maxRetry?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface IRedisClusterHelperProps {
|
|
14
|
+
name: string;
|
|
15
|
+
nodes: Array<Pick<IRedisHelperProps, "host" | "port"> & {
|
|
16
|
+
password?: string;
|
|
17
|
+
}>;
|
|
18
|
+
clusterOptions?: ClusterOptions;
|
|
19
|
+
}
|
|
20
|
+
export interface IRedisHelperCallbacks {
|
|
21
|
+
onInitialized?: (opts: {
|
|
22
|
+
name: string;
|
|
23
|
+
helper: BaseHelper;
|
|
24
|
+
}) => void;
|
|
25
|
+
onConnected?: (opts: {
|
|
26
|
+
name: string;
|
|
27
|
+
helper: BaseHelper;
|
|
28
|
+
}) => void;
|
|
29
|
+
onReady?: (opts: {
|
|
30
|
+
name: string;
|
|
31
|
+
helper: BaseHelper;
|
|
32
|
+
}) => void;
|
|
33
|
+
onError?: (opts: {
|
|
34
|
+
name: string;
|
|
35
|
+
helper: BaseHelper;
|
|
36
|
+
error: any;
|
|
37
|
+
}) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface IRedisHelperOptions extends IRedisHelperProps, IRedisHelperCallbacks {
|
|
40
|
+
}
|
|
41
|
+
export interface IRedisClusterHelperOptions extends IRedisClusterHelperProps, IRedisHelperCallbacks {
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/helpers/redis/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EA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wB,EAAE,qBAAqB;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/helpers/redis/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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("./base"), exports);
|
|
18
|
+
__exportStar(require("./common"), exports);
|
|
19
|
+
__exportStar(require("./datasources"), exports);
|
|
20
|
+
__exportStar(require("./helpers"), exports);
|
|
21
|
+
__exportStar(require("./utilities"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/crypto.utility.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,aAAa,CAAC;AAE5B,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,SAAS;IACP,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,CAAC,oBAAoB,CAAC;CACpC,KACA,MAkBF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.hash = void 0;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
+
const hash = (text, options) => {
|
|
9
|
+
const { algorithm, secret, outputType } = options;
|
|
10
|
+
switch (algorithm) {
|
|
11
|
+
case "SHA256": {
|
|
12
|
+
if (!secret) {
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
return node_crypto_1.default.createHmac(algorithm, secret).update(text).digest(outputType);
|
|
16
|
+
}
|
|
17
|
+
case "MD5": {
|
|
18
|
+
return node_crypto_1.default.createHash(algorithm).update(text).digest(outputType);
|
|
19
|
+
}
|
|
20
|
+
default: {
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.hash = hash;
|
|
26
|
+
//# sourceMappingURL=crypto.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.utility.js","sourceRoot":"","sources":["../../src/utilities/crypto.utility.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA4B;AAErB,MAAM,IAAI,GAAG,CAClB,IAAY,EACZ,OAIC,EACO,EAAE;IACV,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAElD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,qBAAC,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzE,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,OAAO,qBAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,IAAI,QAyBf"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
3
|
+
export declare const isWeekday: (date: string | dayjs.Dayjs) => boolean;
|
|
4
|
+
export declare const getPreviousWeekday: (opts?: {
|
|
5
|
+
date?: string | dayjs.Dayjs;
|
|
6
|
+
}) => dayjs.Dayjs;
|
|
7
|
+
export declare const getNextWeekday: (opts?: {
|
|
8
|
+
date?: string | dayjs.Dayjs;
|
|
9
|
+
}) => dayjs.Dayjs;
|
|
10
|
+
export declare const getDateTz: (opts: {
|
|
11
|
+
date: string;
|
|
12
|
+
timezone: string;
|
|
13
|
+
useClientTz?: boolean;
|
|
14
|
+
timeOffset?: number;
|
|
15
|
+
}) => dayjs.Dayjs;
|
|
16
|
+
export declare const hrTime: () => number;
|
|
17
|
+
export { dayjs };
|
|
18
|
+
//# sourceMappingURL=date.utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/date.utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAE/B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,YAGnD,CAAC;AAWF,eAAO,MAAM,kBAAkB,GAAI,OAAO;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAA;CAAE,gBASxE,CAAC;AAWF,eAAO,MAAM,cAAc,GAAI,OAAO;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAA;CAAE,gBASpE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,gBAGA,CAAC;AAEF,eAAO,MAAM,MAAM,cAGlB,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.dayjs = exports.hrTime = exports.getDateTz = exports.getNextWeekday = exports.getPreviousWeekday = exports.isWeekday = exports.sleep = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
exports.dayjs = dayjs_1.default;
|
|
9
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
10
|
+
const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
|
|
11
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
12
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
13
|
+
const weekday_1 = __importDefault(require("dayjs/plugin/weekday"));
|
|
14
|
+
const parse_utility_1 = require("./parse.utility");
|
|
15
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
16
|
+
dayjs_1.default.extend(utc_1.default);
|
|
17
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
18
|
+
dayjs_1.default.extend(weekday_1.default);
|
|
19
|
+
dayjs_1.default.extend(isoWeek_1.default);
|
|
20
|
+
const tz = process.env.APP_ENV_APPLICATION_TIMEZONE ?? "Asia/Ho_Chi_Minh";
|
|
21
|
+
dayjs_1.default.tz.setDefault(tz);
|
|
22
|
+
const sleep = (ms) => {
|
|
23
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
24
|
+
};
|
|
25
|
+
exports.sleep = sleep;
|
|
26
|
+
const isWeekday = (date) => {
|
|
27
|
+
const isoWeekday = (0, dayjs_1.default)(date)?.isoWeekday();
|
|
28
|
+
return isoWeekday > 0 && isoWeekday < 6;
|
|
29
|
+
};
|
|
30
|
+
exports.isWeekday = isWeekday;
|
|
31
|
+
/* export const getPreviousWeekday = () => {
|
|
32
|
+
let date = dayjs();
|
|
33
|
+
while (!isWeekday(date)) {
|
|
34
|
+
date = date.subtract(1, 'day');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return date;
|
|
38
|
+
}; */
|
|
39
|
+
const getPreviousWeekday = (opts) => {
|
|
40
|
+
const { date } = opts ?? { date: (0, dayjs_1.default)() };
|
|
41
|
+
let rs = (0, dayjs_1.default)(date).clone().subtract(1, "day");
|
|
42
|
+
while (!(0, exports.isWeekday)(rs.toISOString())) {
|
|
43
|
+
rs = rs.subtract(1, "day");
|
|
44
|
+
}
|
|
45
|
+
return rs;
|
|
46
|
+
};
|
|
47
|
+
exports.getPreviousWeekday = getPreviousWeekday;
|
|
48
|
+
/* export const getNextWeekday = () => {
|
|
49
|
+
let date = dayjs();
|
|
50
|
+
while (!isWeekday(date)) {
|
|
51
|
+
date = date.add(1, 'day');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return date;
|
|
55
|
+
}; */
|
|
56
|
+
const getNextWeekday = (opts) => {
|
|
57
|
+
const { date } = opts ?? { date: (0, dayjs_1.default)() };
|
|
58
|
+
let rs = (0, dayjs_1.default)(date).clone().add(1, "day");
|
|
59
|
+
while (!(0, exports.isWeekday)(rs.toISOString())) {
|
|
60
|
+
rs = rs.add(1, "day");
|
|
61
|
+
}
|
|
62
|
+
return rs;
|
|
63
|
+
};
|
|
64
|
+
exports.getNextWeekday = getNextWeekday;
|
|
65
|
+
const getDateTz = (opts) => {
|
|
66
|
+
const { date, timezone, useClientTz = false, timeOffset = 0 } = opts;
|
|
67
|
+
return (0, dayjs_1.default)(date).tz(timezone, useClientTz).add(timeOffset, "hour");
|
|
68
|
+
};
|
|
69
|
+
exports.getDateTz = getDateTz;
|
|
70
|
+
const hrTime = () => {
|
|
71
|
+
const curr = process.hrtime();
|
|
72
|
+
return (0, parse_utility_1.float)(curr[0] + curr[1] / 10 ** 9, 9);
|
|
73
|
+
};
|
|
74
|
+
exports.hrTime = hrTime;
|
|
75
|
+
//# sourceMappingURL=date.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.utility.js","sourceRoot":"","sources":["../../src/utilities/date.utility.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAkFjB,gBAlFF,eAAK,CAkFE;AAhFd,uFAAqE;AACrE,mEAAiD;AACjD,qEAAmD;AACnD,2DAAyC;AACzC,mE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AAHW,QAAA,MAAM,UAGjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class ApplicationError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
messageCode?: string;
|
|
4
|
+
constructor(opts: {
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
messageCode?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export declare const getError: (opts: {
|
|
11
|
+
statusCode?: number;
|
|
12
|
+
messageCode?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}) => ApplicationError;
|
|
15
|
+
//# sourceMappingURL=error.utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/error.utility.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB;CAOF;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,qBAGA,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getError = exports.ApplicationError = void 0;
|
|
4
|
+
class ApplicationError extends Error {
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
const { message, messageCode, statusCode = 400 } = opts;
|
|
7
|
+
super(message);
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
this.messageCode = messageCode;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ApplicationError = ApplicationError;
|
|
13
|
+
const getError = (opts) => {
|
|
14
|
+
const error = new ApplicationError(opts);
|
|
15
|
+
return error;
|
|
16
|
+
};
|
|
17
|
+
exports.getError = getError;
|
|
18
|
+
//# sourceMappingURL=error.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.utility.js","sourceRoot":"","sources":["../../src/utilities/error.utility.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IAIzC,YAAY,IAIX;QACC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AAfD,4CAeC;AAEM,MAAM,QAAQ,GAAG,CAAC,IAIxB,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAPW,QAAA,QAAQ,YAOnB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./crypto.utility";
|
|
2
|
+
export * from "./date.utility";
|
|
3
|
+
export * from "./error.utility";
|
|
4
|
+
export * from "./model.utility";
|
|
5
|
+
export * from "./module.utility";
|
|
6
|
+
export * from "./parse.utility";
|
|
7
|
+
export * from "./performance.utility";
|
|
8
|
+
export * from "./promise.utility";
|
|
9
|
+
export * from "./query.utility";
|
|
10
|
+
export * from "./request.utility";
|
|
11
|
+
export * from "./url.utility";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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("./crypto.utility"), exports);
|
|
18
|
+
__exportStar(require("./date.utility"), exports);
|
|
19
|
+
__exportStar(require("./error.utility"), exports);
|
|
20
|
+
__exportStar(require("./model.utility"), exports);
|
|
21
|
+
__exportStar(require("./module.utility"), exports);
|
|
22
|
+
__exportStar(require("./parse.utility"), exports);
|
|
23
|
+
__exportStar(require("./performance.utility"), exports);
|
|
24
|
+
__exportStar(require("./promise.utility"), exports);
|
|
25
|
+
__exportStar(require("./query.utility"), exports);
|
|
26
|
+
__exportStar(require("./request.utility"), exports);
|
|
27
|
+
__exportStar(require("./url.utility"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,iDAA+B;AAC/B,kDAAgC;AAChC,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SchemaObject } from "@loopback/rest";
|
|
2
|
+
import { BaseEntity, BaseIdEntity } from "../base/models/base.model";
|
|
3
|
+
export declare const getIdSchema: <E extends BaseEntity>(entity: typeof BaseEntity & {
|
|
4
|
+
prototype: E;
|
|
5
|
+
}) => SchemaObject;
|
|
6
|
+
export declare const getIdType: <E extends BaseEntity>(entity: typeof BaseIdEntity & {
|
|
7
|
+
prototype: E;
|
|
8
|
+
}) => "string" | "number";
|
|
9
|
+
//# sourceMappingURL=model.utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/model.utility.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGpE,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC9C,QAAQ,OAAO,UAAU,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,KAC3C,YAIF,CAAC;AAGF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC5C,QAAQ,OAAO,YAAY,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,KAC7C,QAAQ,GAAG,QAoBb,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIdType = exports.getIdSchema = void 0;
|
|
4
|
+
const metadata_1 = require("@loopback/metadata");
|
|
5
|
+
const rest_1 = require("@loopback/rest");
|
|
6
|
+
// --------------------------------------------------------------------------------------------------------------
|
|
7
|
+
const getIdSchema = (entity) => {
|
|
8
|
+
const idProp = entity.getIdProperties()[0];
|
|
9
|
+
const modelSchema = (0, rest_1.jsonToSchemaObject)((0, rest_1.getJsonSchema)(entity));
|
|
10
|
+
return modelSchema.properties?.[idProp];
|
|
11
|
+
};
|
|
12
|
+
exports.getIdSchema = getIdSchema;
|
|
13
|
+
// --------------------------------------------------------------------------------------------------------------
|
|
14
|
+
const getIdType = (entity) => {
|
|
15
|
+
let idType = "number";
|
|
16
|
+
try {
|
|
17
|
+
const idMetadata = metadata_1.MetadataInspector.getPropertyMetadata("loopback:model-properties", entity, "id");
|
|
18
|
+
idType = idMetadata?.type ?? "number";
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
console.error("[getIdType] Failed to inspect entity id type! Use 'number' by default | Error: ", e);
|
|
22
|
+
idType = "number";
|
|
23
|
+
return idType;
|
|
24
|
+
}
|
|
25
|
+
return idType;
|
|
26
|
+
};
|
|
27
|
+
exports.getIdType = getIdType;
|
|
28
|
+
//# sourceMappingURL=model.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.utility.js","sourceRoot":"","sources":["../../src/utilities/model.utility.ts"],"names":[],"mappings":";;;AAAA,iDAAuD;AACvD,yCAIwB;AAIxB,iHAAiH;AAC1G,MAAM,WAAW,GAAG,CACzB,MAA4C,EAC9B,EAAE;IAChB,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAA,yBAAkB,EAAC,IAAA,oBAAa,EAAC,MAAM,CAAC,CAAiB,CAAC;IAC9E,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC,MAAM,CAAiB,CAAC;AAC1D,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB;AAEF,iHAAiH;AAC1G,MAAM,SAAS,GAAG,CACvB,MAA8C,EACzB,EAAE;IACvB,IAAI,MAAM,GAAwB,QAAQ,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,4BAAiB,CAAC,mBAAmB,CAErD,2BAA2B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAE9C,MAAM,GAAG,UAAU,EAAE,IAAI,IAAI,QAAQ,CAAC;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACX,iFAAiF,EACjF,CAAC,CACF,CAAC;QAEF,MAAM,GAAG,QAAQ,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAtBW,QAAA,SAAS,aAsBpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/module.utility.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,GAAI,MAAM;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB,SAgBA,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateModule = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const error_utility_1 = require("./error.utility");
|
|
6
|
+
const validateModule = (opts) => {
|
|
7
|
+
const { scope = "", modules = [] } = opts;
|
|
8
|
+
for (const module of modules) {
|
|
9
|
+
try {
|
|
10
|
+
require.resolve(module);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
helpers_1.LoggerFactory.getLogger([scope]).error("[validateModule] Failed to import '%s' | Error: %s", module, error);
|
|
14
|
+
throw (0, error_utility_1.getError)({
|
|
15
|
+
message: `[validateModule] ${module} is required${scope ? ` for ${scope}` : ""}. Please install '${module}'`,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.validateModule = validateModule;
|
|
21
|
+
//# sourceMappingURL=module.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.utility.js","sourceRoot":"","sources":["../../src/utilities/module.utility.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,mDAA2C;AAEpC,MAAM,cAAc,GAAG,CAAC,IAG9B,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IAC1C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uBAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CACpC,oDAAoD,EACpD,MAAM,EACN,KAAK,CACN,CAAC;YACF,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EAAE,oBAAoB,MAAM,eAAe,KAAK,CAAC,CAAC,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,qBAAqB,MAAM,GAAG;aAC7G,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAnBW,QAAA,cAAc,kBAmBzB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const getUID: () => string;
|
|
2
|
+
export declare const toCamel: (s: string) => string;
|
|
3
|
+
export declare const keysToCamel: (object: object) => any;
|
|
4
|
+
export declare const isInt: (n: any) => boolean;
|
|
5
|
+
export declare const isFloat: (input: any) => boolean;
|
|
6
|
+
export declare const int: (input: any) => number;
|
|
7
|
+
export declare const float: (input: any, digit?: number) => number;
|
|
8
|
+
export declare const toBoolean: (input: any) => boolean;
|
|
9
|
+
export declare const toStringDecimal: (input: any, digit?: number, options?: {
|
|
10
|
+
useLocaleFormat: boolean;
|
|
11
|
+
}) => string | 0;
|
|
12
|
+
export declare const getNumberValue: (input: string, method?: "int" | "float") => number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns an object with the key as the value of the `keyMap` and the value as the object itself.
|
|
15
|
+
*
|
|
16
|
+
* @param arr - The input array
|
|
17
|
+
* @param keyMap - The property key to use as the key in the resulting object
|
|
18
|
+
*
|
|
19
|
+
* Note: In case of duplicate keys, the last element will be used.
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseArrayToRecordWithKey: <T extends Record<K, PropertyKey>, K extends keyof T>(opts: {
|
|
22
|
+
arr: T[];
|
|
23
|
+
keyMap: K;
|
|
24
|
+
}) => Record<T[K], T>;
|
|
25
|
+
/**
|
|
26
|
+
* Return a map with the key as the value of the `keyMap` and the value as the object itself.
|
|
27
|
+
*
|
|
28
|
+
* @param arr - The input array
|
|
29
|
+
* @param keyMap - The property key to use as the key in the resulting object
|
|
30
|
+
*
|
|
31
|
+
* Note: In case of duplicate keys, the last element will be used.
|
|
32
|
+
*/
|
|
33
|
+
export declare const parseArrayToMapWithKey: <T extends Record<K, PropertyKey>, K extends keyof T>(arr: T[], keyMap: K) => Map<T[K], T>;
|
|
34
|
+
//# sourceMappingURL=parse.utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/parse.utility.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,MAAM,cAA0D,CAAC;AAG9E,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,WAIhC,CAAC;AAGF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAA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