@nu-art/ts-common 0.200.129 → 0.200.131
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/core/error-handling.d.ts +10 -5
- package/core/error-handling.js +3 -2
- package/core/exceptions.d.ts +1 -0
- package/core/exceptions.js +4 -0
- package/package.json +3 -2
- package/replacer-v2/ReplacerV2.d.ts +9 -0
- package/replacer-v2/ReplacerV2.js +20 -0
- package/testing/consts.d.ts +4 -0
- package/testing/consts.js +10 -3
package/core/error-handling.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Module } from
|
|
2
|
-
import { Dispatcher } from
|
|
1
|
+
import { Module } from './module';
|
|
2
|
+
import { Dispatcher } from './dispatcher';
|
|
3
|
+
import { CustomException } from './exceptions';
|
|
3
4
|
export declare enum ServerErrorSeverity {
|
|
4
5
|
Debug = "Debug",
|
|
5
6
|
Info = "Info",
|
|
@@ -12,7 +13,11 @@ export type ErrorMessage = {
|
|
|
12
13
|
message: string;
|
|
13
14
|
innerMessages?: string[];
|
|
14
15
|
};
|
|
15
|
-
export interface
|
|
16
|
-
|
|
16
|
+
export interface OnApplicationNotification {
|
|
17
|
+
__processApplicationNotification(errorLevel: ServerErrorSeverity, module: Module, message: ErrorMessage): Promise<void>;
|
|
17
18
|
}
|
|
18
|
-
export declare const
|
|
19
|
+
export declare const dispatch_onApplicationNotification: Dispatcher<OnApplicationNotification, "__processApplicationNotification", [errorLevel: ServerErrorSeverity, module: Module<any, any>, message: ErrorMessage], void>;
|
|
20
|
+
export interface OnApplicationException {
|
|
21
|
+
__processApplicationException(e: CustomException, module: Module, data: any): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare const dispatch_onApplicationException: Dispatcher<OnApplicationException, "__processApplicationException", [e: CustomException, module: Module<any, any>, data: any], void>;
|
package/core/error-handling.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.dispatch_onApplicationException = exports.dispatch_onApplicationNotification = exports.ServerErrorSeverity_Ordinal = exports.ServerErrorSeverity = void 0;
|
|
21
21
|
const dispatcher_1 = require("./dispatcher");
|
|
22
22
|
var ServerErrorSeverity;
|
|
23
23
|
(function (ServerErrorSeverity) {
|
|
@@ -34,4 +34,5 @@ exports.ServerErrorSeverity_Ordinal = [
|
|
|
34
34
|
ServerErrorSeverity.Error,
|
|
35
35
|
ServerErrorSeverity.Critical
|
|
36
36
|
];
|
|
37
|
-
exports.
|
|
37
|
+
exports.dispatch_onApplicationNotification = new dispatcher_1.Dispatcher('__processApplicationNotification');
|
|
38
|
+
exports.dispatch_onApplicationException = new dispatcher_1.Dispatcher('__processApplicationException');
|
package/core/exceptions.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare function isErrorOfType<T extends Error>(e: Error, _exceptionType:
|
|
|
41
41
|
export declare abstract class CustomException extends Error {
|
|
42
42
|
exceptionType: string;
|
|
43
43
|
isInstanceOf: (_exceptionType: Function) => boolean;
|
|
44
|
+
generateMrkDwnMessage: () => string;
|
|
44
45
|
cause?: Error;
|
|
45
46
|
protected constructor(exceptionType: Function, message: string, cause?: Error);
|
|
46
47
|
}
|
package/core/exceptions.js
CHANGED
|
@@ -73,6 +73,10 @@ class CustomException extends Error {
|
|
|
73
73
|
this.isInstanceOf = (_exceptionType) => {
|
|
74
74
|
return this.exceptionType === _exceptionType.name;
|
|
75
75
|
};
|
|
76
|
+
this.generateMrkDwnMessage = () => {
|
|
77
|
+
return `*Exception Type :* ${this.exceptionType}\n`
|
|
78
|
+
+ `*Message :* ${this.message}`;
|
|
79
|
+
};
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
exports.CustomException = CustomException;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/ts-common",
|
|
3
|
-
"version": "0.200.
|
|
3
|
+
"version": "0.200.131",
|
|
4
4
|
"description": "js and ts infra",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/minimatch": "^5.1.2",
|
|
43
|
-
"@types/node-forge": "^1.0.0"
|
|
43
|
+
"@types/node-forge": "^1.0.0",
|
|
44
|
+
"@types/qs": "latest"
|
|
44
45
|
},
|
|
45
46
|
"_moduleAliases": {
|
|
46
47
|
"@main": "dist/main/ts",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ReplacerV2_Input = {
|
|
2
|
+
[k: string]: string | ((...params: string[]) => string);
|
|
3
|
+
};
|
|
4
|
+
export declare class ReplacerV2 {
|
|
5
|
+
private static Regexp_paramGroup;
|
|
6
|
+
private static Regexp_param;
|
|
7
|
+
replace(text: string, input?: ReplacerV2_Input): string;
|
|
8
|
+
private resolveParams;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplacerV2 = void 0;
|
|
4
|
+
const array_tools_1 = require("../utils/array-tools");
|
|
5
|
+
class ReplacerV2 {
|
|
6
|
+
replace(text, input) {
|
|
7
|
+
const params = this.resolveParams(text);
|
|
8
|
+
return params[0];
|
|
9
|
+
return text;
|
|
10
|
+
}
|
|
11
|
+
resolveParams(text) {
|
|
12
|
+
const matches = text.match(ReplacerV2.Regexp_paramGroup);
|
|
13
|
+
if (!matches)
|
|
14
|
+
return [];
|
|
15
|
+
return (0, array_tools_1.filterInstances)(matches.map((param) => { var _a; return (_a = param.match(ReplacerV2.Regexp_param)) === null || _a === void 0 ? void 0 : _a[1]; }));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
ReplacerV2.Regexp_paramGroup = /\$\{(\{?.*?\}?)\}/g;
|
|
19
|
+
ReplacerV2.Regexp_param = /\$\{(\{?.*?\}?)\}/;
|
|
20
|
+
exports.ReplacerV2 = ReplacerV2;
|
package/testing/consts.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="chai" />
|
|
2
2
|
/// <reference types="chai-as-promised" />
|
|
3
3
|
import { TestSuite } from './types';
|
|
4
|
+
import { ModuleManager } from '../core/module-manager';
|
|
5
|
+
export declare class ModuleManagerTester extends ModuleManager {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
4
8
|
export declare const testSuiteTester: <Input, ExpectedResult>(testSuit: TestSuite<Input, ExpectedResult>) => void;
|
|
5
9
|
export declare const expectFailAsync: (action: () => Promise<void>) => Promise<Chai.Assertion>;
|
package/testing/consts.js
CHANGED
|
@@ -9,9 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.expectFailAsync = exports.testSuiteTester = void 0;
|
|
12
|
+
exports.expectFailAsync = exports.testSuiteTester = exports.ModuleManagerTester = void 0;
|
|
13
13
|
const chai_1 = require("chai");
|
|
14
|
-
const
|
|
14
|
+
const module_manager_1 = require("../core/module-manager");
|
|
15
|
+
const tools_1 = require("../utils/tools");
|
|
16
|
+
class ModuleManagerTester extends module_manager_1.ModuleManager {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ModuleManagerTester = ModuleManagerTester;
|
|
15
22
|
const testSuiteTester = (testSuit) => {
|
|
16
23
|
describe(testSuit.label, () => {
|
|
17
24
|
//Run pre-process
|
|
@@ -27,7 +34,7 @@ exports.testSuiteTester = testSuiteTester;
|
|
|
27
34
|
const expectFailAsync = (action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
35
|
try {
|
|
29
36
|
yield action();
|
|
30
|
-
return (0, chai_1.expect)(
|
|
37
|
+
return (0, chai_1.expect)(tools_1.voidFunction);
|
|
31
38
|
}
|
|
32
39
|
catch (e) {
|
|
33
40
|
return (0, chai_1.expect)(() => {
|