@zerooneit/expressive-tea 1.3.0-beta.1 → 1.3.0-beta.3
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/classes/Boot.d.ts +1 -1
- package/classes/Boot.js +3 -2
- package/classes/Settings.d.ts +1 -1
- package/classes/Settings.js +11 -11
- package/decorators/annotations.d.ts +1 -1
- package/decorators/annotations.js +4 -4
- package/decorators/module.d.ts +1 -1
- package/decorators/proxy.d.ts +13 -0
- package/decorators/proxy.js +70 -0
- package/decorators/router.d.ts +4 -3
- package/decorators/router.js +10 -10
- package/decorators/server.d.ts +3 -2
- package/decorators/server.js +29 -19
- package/engines/http/index.d.ts +3 -1
- package/engines/http/index.js +16 -6
- package/engines/teacup/index.js +26 -25
- package/engines/teapot/index.js +30 -30
- package/engines/websocket/index.js +6 -5
- package/helpers/boot-helper.d.ts +2 -1
- package/helpers/boot-helper.js +13 -8
- package/helpers/decorators.js +4 -4
- package/helpers/server.d.ts +3 -3
- package/helpers/server.js +9 -9
- package/helpers/teapot-helper.d.ts +1 -0
- package/helpers/websocket-helper.d.ts +1 -0
- package/libs/classNames.d.ts +1 -0
- package/libs/classNames.js +4 -0
- package/package.json +29 -30
- package/services/WebsocketService.d.ts +1 -0
- package/classes/MetaData.d.ts +0 -17
- package/classes/MetaData.js +0 -68
- package/helpers/object-helper.d.ts +0 -166
- package/helpers/object-helper.js +0 -288
- package/libs/constants.d.ts +0 -69
- package/libs/constants.js +0 -101
- package/libs/interfaces.d.ts +0 -127
- package/libs/interfaces.js +0 -2
- package/libs/types.d.ts +0 -12
- package/libs/types.js +0 -2
- package/yarn-error.log +0 -5906
package/engines/teapot/index.js
CHANGED
|
@@ -5,32 +5,10 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const inversify_1 = require("inversify");
|
|
7
7
|
const ProxyRoute_1 = require("../../classes/ProxyRoute");
|
|
8
|
-
const
|
|
9
|
-
const constants_1 = require("
|
|
8
|
+
const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
|
|
9
|
+
const constants_1 = require("@expressive-tea/commons/constants");
|
|
10
10
|
const teapot_helper_1 = require("../../helpers/teapot-helper");
|
|
11
11
|
let TeapotEngine = TeapotEngine_1 = class TeapotEngine {
|
|
12
|
-
constructor(ctx, server, serverSecure, settings) {
|
|
13
|
-
this.clients = new Map();
|
|
14
|
-
this.registeredRoute = new Map();
|
|
15
|
-
this.settings = settings;
|
|
16
|
-
this.context = ctx;
|
|
17
|
-
this.server = server;
|
|
18
|
-
this.serverSecure = serverSecure;
|
|
19
|
-
this.isActive = MetaData_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, this.context, 'isTeapotActive');
|
|
20
|
-
this.teapotSettings = MetaData_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, this.context);
|
|
21
|
-
if (!this.isActive) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const { publicKey, privateKey } = teapot_helper_1.default.generateKeys(this.teapotSettings.serverKey);
|
|
25
|
-
this.publicKey = publicKey;
|
|
26
|
-
this.privateKey = privateKey;
|
|
27
|
-
this.serverSignature = teapot_helper_1.default.sign(this.teapotSettings.clientKey, privateKey, this.teapotSettings.serverKey);
|
|
28
|
-
this.socketServer = require('socket.io')({
|
|
29
|
-
path: '/teapot',
|
|
30
|
-
wsEngine: require('eiows').Server,
|
|
31
|
-
cookie: false
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
12
|
static header(teapotSettings) {
|
|
35
13
|
console.log(chalk.white.bold('Teapot Engine is initializing...'));
|
|
36
14
|
console.log(chalk `
|
|
@@ -136,6 +114,27 @@ All Communication are encrypted to ensure intruder can not connected, however, p
|
|
|
136
114
|
console.log(chalk `{cyan.bold [TEAPOT]} - {red.bold TEACUP} {magenta.bold ${self.id}}: Failed wiht next message: ${e.message}`);
|
|
137
115
|
}
|
|
138
116
|
}
|
|
117
|
+
constructor(ctx, server, serverSecure, settings) {
|
|
118
|
+
this.clients = new Map();
|
|
119
|
+
this.registeredRoute = new Map();
|
|
120
|
+
this.settings = settings;
|
|
121
|
+
this.context = ctx;
|
|
122
|
+
this.server = server;
|
|
123
|
+
this.serverSecure = serverSecure;
|
|
124
|
+
this.isActive = Metadata_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, this.context, 'isTeapotActive');
|
|
125
|
+
this.teapotSettings = Metadata_1.default.get(constants_1.ASSIGN_TEAPOT_KEY, this.context);
|
|
126
|
+
if (!this.isActive) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { publicKey, privateKey } = teapot_helper_1.default.generateKeys(this.teapotSettings.serverKey);
|
|
130
|
+
this.publicKey = publicKey;
|
|
131
|
+
this.privateKey = privateKey;
|
|
132
|
+
this.serverSignature = teapot_helper_1.default.sign(this.teapotSettings.clientKey, privateKey, this.teapotSettings.serverKey);
|
|
133
|
+
this.socketServer = require('socket.io')({
|
|
134
|
+
path: '/teapot',
|
|
135
|
+
cookie: false
|
|
136
|
+
});
|
|
137
|
+
}
|
|
139
138
|
async start() {
|
|
140
139
|
if (!this.isActive) {
|
|
141
140
|
return;
|
|
@@ -145,12 +144,13 @@ All Communication are encrypted to ensure intruder can not connected, however, p
|
|
|
145
144
|
this.socketServer.listen(this.server);
|
|
146
145
|
}
|
|
147
146
|
};
|
|
148
|
-
TeapotEngine = TeapotEngine_1 =
|
|
147
|
+
TeapotEngine = TeapotEngine_1 = tslib_1.__decorate([
|
|
149
148
|
(0, inversify_1.injectable)(),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(0,
|
|
149
|
+
tslib_1.__param(0, (0, inversify_1.inject)('context')),
|
|
150
|
+
tslib_1.__param(1, (0, inversify_1.inject)('server')),
|
|
151
|
+
tslib_1.__param(2, (0, inversify_1.inject)('secureServer')),
|
|
152
|
+
tslib_1.__param(2, (0, inversify_1.optional)()),
|
|
153
|
+
tslib_1.__param(3, (0, inversify_1.inject)('settings')),
|
|
154
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
155
155
|
], TeapotEngine);
|
|
156
156
|
exports.default = TeapotEngine;
|
|
@@ -26,11 +26,12 @@ let WebsocketEngine = class WebsocketEngine {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
WebsocketEngine =
|
|
29
|
+
WebsocketEngine = tslib_1.__decorate([
|
|
30
30
|
(0, inversify_1.injectable)(),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0,
|
|
31
|
+
tslib_1.__param(0, (0, inversify_1.inject)('server')),
|
|
32
|
+
tslib_1.__param(1, (0, inversify_1.inject)('secureServer')),
|
|
33
|
+
tslib_1.__param(1, (0, inversify_1.optional)()),
|
|
34
|
+
tslib_1.__param(2, (0, inversify_1.inject)('settings')),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object])
|
|
35
36
|
], WebsocketEngine);
|
|
36
37
|
exports.default = WebsocketEngine;
|
package/helpers/boot-helper.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { BOOT_STAGES } from '
|
|
1
|
+
import { BOOT_STAGES } from '@expressive-tea/commons/constants';
|
|
2
2
|
import { Express } from 'express';
|
|
3
3
|
import Boot from '../classes/Boot';
|
|
4
4
|
export declare function resolveStage(stage: BOOT_STAGES, ctx: Boot, server: Express, ...extraArgs: unknown[]): Promise<void>;
|
|
5
5
|
export declare function resolveDirectives(instance: typeof Boot | Boot, server: Express): Promise<void>;
|
|
6
6
|
export declare function resolveStatic(instance: typeof Boot | Boot, server: Express): Promise<void>;
|
|
7
|
+
export declare function resolveProxy(ProxyContainer: any, server: Express): Promise<void>;
|
package/helpers/boot-helper.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// tslint:disable:no-duplicate-imports
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.resolveStatic = exports.resolveDirectives = exports.resolveStage = void 0;
|
|
5
|
-
const constants_1 = require("
|
|
4
|
+
exports.resolveProxy = exports.resolveStatic = exports.resolveDirectives = exports.resolveStage = void 0;
|
|
5
|
+
const constants_1 = require("@expressive-tea/commons/constants");
|
|
6
6
|
const express = require("express");
|
|
7
|
-
const
|
|
8
|
-
const object_helper_1 = require("
|
|
7
|
+
const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
|
|
8
|
+
const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper");
|
|
9
9
|
const BootLoaderExceptions_1 = require("../exceptions/BootLoaderExceptions");
|
|
10
10
|
async function resolveStage(stage, ctx, server, ...extraArgs) {
|
|
11
11
|
try {
|
|
@@ -22,14 +22,14 @@ async function resolveStage(stage, ctx, server, ...extraArgs) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.resolveStage = resolveStage;
|
|
24
24
|
async function resolveDirectives(instance, server) {
|
|
25
|
-
const registeredDirectives =
|
|
25
|
+
const registeredDirectives = Metadata_1.default.get(constants_1.REGISTERED_DIRECTIVES_KEY, (0, object_helper_1.getClass)(instance)) || [];
|
|
26
26
|
registeredDirectives.forEach((options) => {
|
|
27
27
|
server.set.call(server, options.name, ...options.settings);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
exports.resolveDirectives = resolveDirectives;
|
|
31
31
|
async function resolveStatic(instance, server) {
|
|
32
|
-
const registeredStatic =
|
|
32
|
+
const registeredStatic = Metadata_1.default.get(constants_1.REGISTERED_STATIC_KEY, (0, object_helper_1.getClass)(instance)) || [];
|
|
33
33
|
registeredStatic.forEach((staticOptions) => {
|
|
34
34
|
if (staticOptions.virtual) {
|
|
35
35
|
server.use(staticOptions.virtual, express.static(staticOptions.root, staticOptions.options));
|
|
@@ -40,15 +40,20 @@ async function resolveStatic(instance, server) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
exports.resolveStatic = resolveStatic;
|
|
43
|
+
async function resolveProxy(ProxyContainer, server) {
|
|
44
|
+
const proxyContainer = new ProxyContainer();
|
|
45
|
+
proxyContainer.__register(server);
|
|
46
|
+
}
|
|
47
|
+
exports.resolveProxy = resolveProxy;
|
|
43
48
|
async function resolveModules(instance, server) {
|
|
44
|
-
const registeredModules =
|
|
49
|
+
const registeredModules = Metadata_1.default.get(constants_1.REGISTERED_MODULE_KEY, instance, 'start') || [];
|
|
45
50
|
registeredModules.forEach(Module => {
|
|
46
51
|
const moduleInstance = new Module();
|
|
47
52
|
moduleInstance.__register(server);
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
async function bootloaderResolve(STAGE, server, instance, ...args) {
|
|
51
|
-
const bootLoader =
|
|
56
|
+
const bootLoader = Metadata_1.default.get(constants_1.BOOT_STAGES_KEY, (0, object_helper_1.getClass)(instance)) || constants_1.STAGES_INIT;
|
|
52
57
|
for (const loader of bootLoader[STAGE] || []) {
|
|
53
58
|
try {
|
|
54
59
|
await selectLoaderType(loader, server, ...args);
|
package/helpers/decorators.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addAnnotation = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("
|
|
4
|
+
const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
|
|
5
|
+
const constants_1 = require("@expressive-tea/commons/constants");
|
|
6
6
|
function addAnnotation(type, target, propertyKey, ...args) {
|
|
7
|
-
const annotations =
|
|
7
|
+
const annotations = Metadata_1.default.get(constants_1.ROUTER_ANNOTATIONS_KEY, target, propertyKey) || [];
|
|
8
8
|
annotations.unshift({
|
|
9
9
|
arguments: args,
|
|
10
10
|
type
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
Metadata_1.default.set(constants_1.ROUTER_ANNOTATIONS_KEY, annotations, target, propertyKey);
|
|
13
13
|
}
|
|
14
14
|
exports.addAnnotation = addAnnotation;
|
package/helpers/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { ExpressiveTeaAnnotations, ExpressiveTeaArgumentOptions } from '
|
|
2
|
+
import { ExpressiveTeaAnnotations, ExpressiveTeaArgumentOptions } from '@expressive-tea/commons/interfaces';
|
|
3
3
|
export declare function autoResponse(request: Request, response: Response, annotations: ExpressiveTeaAnnotations[], responseResult?: any): void;
|
|
4
4
|
export declare function executeRequest(request: Request, response: Response, next: NextFunction): Promise<void>;
|
|
5
5
|
export declare function mapArguments(decoratedArguments: ExpressiveTeaArgumentOptions[], request: Request, response: Response, next: NextFunction, introspectedArgs?: string[]): unknown[];
|
|
6
6
|
export declare function extractParameters(target: unknown, args?: string | string[], propertyName?: string | symbol): any;
|
|
7
|
-
export declare function generateRoute(route: string, verb: string): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
8
|
-
export declare function router(verb: string, route: string, target: any, handler: (...args: any[]) => void | any | Promise<any>, propertyKey: string | symbol): void;
|
|
7
|
+
export declare function generateRoute(route: string, verb: string, ...settings: any): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
8
|
+
export declare function router(verb: string, route: string, target: any, handler: (...args: any[]) => void | any | Promise<any>, propertyKey: string | symbol, settings?: any): void;
|
|
9
9
|
export declare function fileSettings(): any;
|
package/helpers/server.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fileSettings = exports.router = exports.generateRoute = exports.extractParameters = exports.mapArguments = exports.executeRequest = exports.autoResponse = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const
|
|
6
|
-
const constants_1 = require("
|
|
5
|
+
const Metadata_1 = require("@expressive-tea/commons/classes/Metadata");
|
|
6
|
+
const constants_1 = require("@expressive-tea/commons/constants");
|
|
7
7
|
const RequestExceptions_1 = require("../exceptions/RequestExceptions");
|
|
8
|
-
const object_helper_1 = require("
|
|
8
|
+
const object_helper_1 = require("@expressive-tea/commons/helpers/object-helper");
|
|
9
9
|
const fs = require("fs");
|
|
10
10
|
function autoResponse(request, response, annotations, responseResult) {
|
|
11
11
|
const view = (0, lodash_1.find)(annotations, { type: 'view' });
|
|
@@ -77,14 +77,14 @@ function extractParameters(target, args, propertyName) {
|
|
|
77
77
|
return target;
|
|
78
78
|
}
|
|
79
79
|
exports.extractParameters = extractParameters;
|
|
80
|
-
function generateRoute(route, verb) {
|
|
81
|
-
return (target, propertyKey, descriptor) => router(verb, route, target, descriptor.value, propertyKey);
|
|
80
|
+
function generateRoute(route, verb, ...settings) {
|
|
81
|
+
return (target, propertyKey, descriptor) => router(verb, route, target, descriptor.value, propertyKey, settings);
|
|
82
82
|
}
|
|
83
83
|
exports.generateRoute = generateRoute;
|
|
84
|
-
function router(verb, route, target, handler, propertyKey) {
|
|
85
|
-
const existedRoutesHandlers =
|
|
86
|
-
existedRoutesHandlers.unshift({ verb, route, handler, target, propertyKey });
|
|
87
|
-
|
|
84
|
+
function router(verb, route, target, handler, propertyKey, settings) {
|
|
85
|
+
const existedRoutesHandlers = Metadata_1.default.get(constants_1.ROUTER_HANDLERS_KEY, target) || [];
|
|
86
|
+
existedRoutesHandlers.unshift({ verb, route, handler, target, propertyKey, settings });
|
|
87
|
+
Metadata_1.default.set(constants_1.ROUTER_HANDLERS_KEY, existedRoutesHandlers, target);
|
|
88
88
|
}
|
|
89
89
|
exports.router = router;
|
|
90
90
|
function fileSettings() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXPRESSIVE_TEA_PROXY_CLASS = "ExpressiveTeaProxy";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerooneit/expressive-tea",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.3",
|
|
4
4
|
"description": "A REST API over Express and Typescript",
|
|
5
5
|
"main": "classes/Boot.js",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"linter": "tslint -c tslint.json -p tsconfig.json",
|
|
13
13
|
"build:dev": "tsc --project tsconfig.json --watch",
|
|
14
14
|
"build": "tsc --project tsconfig.json",
|
|
15
|
-
"clean:build": "
|
|
15
|
+
"clean:build": "trash '**/*.js' '**/*.d.ts' '**/*.js.map' '**/*.d.ts.map' '!node_modules/**/*' '!docs/**/*' '!coverage/**/*' '!gulpfile.js' '!tasks/*.js' '!jest.config.js' '!tools/**/*'",
|
|
16
16
|
"publish:prepare": "npm run clean:build && npm run build",
|
|
17
17
|
"postpublish": "npm run clean:build",
|
|
18
18
|
"prepublishOnly": "npm test && npm run publish:prepare"
|
|
@@ -25,46 +25,45 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@expressive-tea/
|
|
29
|
-
"@
|
|
30
|
-
"@types/
|
|
28
|
+
"@expressive-tea/commons": "1.0.0",
|
|
29
|
+
"@expressive-tea/plugin": "1.0.2",
|
|
30
|
+
"@types/bluebird": "3.5.38",
|
|
31
|
+
"@types/express": "4.17.15",
|
|
31
32
|
"@types/express-http-proxy": "1.6.3",
|
|
32
|
-
"@types/express-serve-static-core": "4.17.
|
|
33
|
-
"@types/jest": "
|
|
34
|
-
"@types/lodash": "4.14.
|
|
35
|
-
"@types/node": "
|
|
33
|
+
"@types/express-serve-static-core": "4.17.32",
|
|
34
|
+
"@types/jest": "29.2.5",
|
|
35
|
+
"@types/lodash": "4.14.191",
|
|
36
|
+
"@types/node": "18.11.18",
|
|
36
37
|
"@types/reflect-metadata": "0.1.0",
|
|
37
38
|
"@types/socket.io": "3.0.2",
|
|
38
39
|
"@types/socket.io-client": "3.0.0",
|
|
39
|
-
"@types/ws": "8.
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"gulp-typescript": "6.0.0-alpha.1",
|
|
43
|
-
"http-terminator": "3.0.3",
|
|
44
|
-
"jest": "27.3.1",
|
|
40
|
+
"@types/ws": "8.5.4",
|
|
41
|
+
"http-terminator": "3.2.0",
|
|
42
|
+
"jest": "29.3.1",
|
|
45
43
|
"jest-express": "1.12.0",
|
|
46
|
-
"jest-junit": "
|
|
44
|
+
"jest-junit": "15.0.0",
|
|
47
45
|
"reflect-metadata": "0.1.13",
|
|
48
|
-
"rimraf": "
|
|
49
|
-
"supertest": "6.
|
|
46
|
+
"rimraf": "4.0.4",
|
|
47
|
+
"supertest": "6.3.3",
|
|
50
48
|
"toast-jsdoc": "1.0.2",
|
|
51
|
-
"
|
|
52
|
-
"ts-
|
|
49
|
+
"trash-cli": "5.0.0",
|
|
50
|
+
"ts-jest": "29.0.5",
|
|
51
|
+
"ts-node": "10.9.1",
|
|
53
52
|
"tslint": "6.1.3",
|
|
54
|
-
"typescript": "4.
|
|
53
|
+
"typescript": "4.9.4"
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
57
56
|
"bluebird": "3.7.2",
|
|
58
|
-
"eiows": "
|
|
59
|
-
"express": "4.
|
|
57
|
+
"eiows": "^4.1.2",
|
|
58
|
+
"express": "4.18.2",
|
|
60
59
|
"express-http-proxy": "1.6.3",
|
|
61
|
-
"inversify": "
|
|
60
|
+
"inversify": "6.0.1",
|
|
62
61
|
"inversify-inject-decorators": "3.1.0",
|
|
63
62
|
"lodash": "4.17.21",
|
|
64
|
-
"socket.io": "4.
|
|
65
|
-
"socket.io-client": "4.
|
|
63
|
+
"socket.io": "4.5.4",
|
|
64
|
+
"socket.io-client": "4.5.4",
|
|
66
65
|
"url-scheme": "1.0.5",
|
|
67
|
-
"ws": "8.
|
|
66
|
+
"ws": "8.12.0"
|
|
68
67
|
},
|
|
69
68
|
"repository": {
|
|
70
69
|
"type": "git",
|
|
@@ -107,11 +106,11 @@
|
|
|
107
106
|
},
|
|
108
107
|
"homepage": "https://github.com/Expressive-Tea/expresive-tea#readme",
|
|
109
108
|
"optionalDependencies": {
|
|
110
|
-
"bufferutil": "
|
|
111
|
-
"utf-8-validate": "^
|
|
109
|
+
"bufferutil": "4.0.7",
|
|
110
|
+
"utf-8-validate": "^6.0.0"
|
|
112
111
|
},
|
|
113
112
|
"resolutions": {
|
|
114
113
|
"set-value": "4.1.0",
|
|
115
|
-
"glob-parent": "
|
|
114
|
+
"glob-parent": "6.0.2"
|
|
116
115
|
}
|
|
117
116
|
}
|
package/classes/MetaData.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export default class Metadata {
|
|
3
|
-
static get(key: string, target: any, propertyKey?: string | symbol): any;
|
|
4
|
-
static getOwn(key: string, target: any, propertyKey?: string | symbol): any;
|
|
5
|
-
static getType(target: any, propertyKey?: string | symbol): any;
|
|
6
|
-
static getOwnType(target: any, propertyKey?: string | symbol): any;
|
|
7
|
-
static getReturnType(target: any, propertyKey?: string | symbol): any;
|
|
8
|
-
static getOwnReturnType(target: any, propertyKey?: string | symbol): any;
|
|
9
|
-
static has(key: string, target: any, propertyKey?: string | symbol): boolean;
|
|
10
|
-
static hasOwn(key: string, target: any, propertyKey?: string | symbol): boolean;
|
|
11
|
-
static setParamTypes(target: any, propertyKey: string | symbol, value: any): void;
|
|
12
|
-
static delete(key: string, target: any, propertyKey?: string | symbol): boolean;
|
|
13
|
-
static getTargetsFromPropertyKey: (metadataKey: string | symbol) => any[];
|
|
14
|
-
static set(key: string, value: any, target: any, propertyKey?: string | symbol): void;
|
|
15
|
-
static getParamTypes(targetPrototype: any, propertyKey?: string | symbol): any[];
|
|
16
|
-
static getOwnParamTypes(target: any, propertyKey?: string | symbol): any[];
|
|
17
|
-
}
|
package/classes/MetaData.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* istanbul ignore file */
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const object_helper_1 = require("../helpers/object-helper");
|
|
6
|
-
function get(key, target, propertyKey, own = false) {
|
|
7
|
-
return own ?
|
|
8
|
-
Reflect.getOwnMetadata(key, (0, object_helper_1.getClass)(target), propertyKey) :
|
|
9
|
-
Reflect.getMetadata(key, (0, object_helper_1.getClass)(target), propertyKey);
|
|
10
|
-
}
|
|
11
|
-
class Metadata {
|
|
12
|
-
static get(key, target, propertyKey) {
|
|
13
|
-
return get(key, (0, object_helper_1.getClass)(target), propertyKey);
|
|
14
|
-
}
|
|
15
|
-
static getOwn(key, target, propertyKey) {
|
|
16
|
-
return get(key, (0, object_helper_1.getClass)(target), propertyKey, true);
|
|
17
|
-
}
|
|
18
|
-
static getType(target, propertyKey) {
|
|
19
|
-
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
20
|
-
}
|
|
21
|
-
static getOwnType(target, propertyKey) {
|
|
22
|
-
return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey);
|
|
23
|
-
}
|
|
24
|
-
static getReturnType(target, propertyKey) {
|
|
25
|
-
return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
26
|
-
}
|
|
27
|
-
static getOwnReturnType(target, propertyKey) {
|
|
28
|
-
return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey);
|
|
29
|
-
}
|
|
30
|
-
static has(key, target, propertyKey) {
|
|
31
|
-
try {
|
|
32
|
-
return Reflect.hasMetadata(key, (0, object_helper_1.getClass)(target), propertyKey);
|
|
33
|
-
}
|
|
34
|
-
catch (er) {
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
static hasOwn(key, target, propertyKey) {
|
|
39
|
-
return Reflect.hasOwnMetadata(key, (0, object_helper_1.getClass)(target), propertyKey);
|
|
40
|
-
}
|
|
41
|
-
static setParamTypes(target, propertyKey, value) {
|
|
42
|
-
return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
|
|
43
|
-
}
|
|
44
|
-
static delete(key, target, propertyKey) {
|
|
45
|
-
return Reflect.deleteMetadata(key, (0, object_helper_1.getClass)(target), propertyKey);
|
|
46
|
-
}
|
|
47
|
-
static set(key, value, target, propertyKey) {
|
|
48
|
-
const targets = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];
|
|
49
|
-
const classConstructor = (0, object_helper_1.getClass)(target);
|
|
50
|
-
if (targets.indexOf(classConstructor) === -1) {
|
|
51
|
-
targets.push(classConstructor);
|
|
52
|
-
PROPERTIES.set(key, targets);
|
|
53
|
-
}
|
|
54
|
-
Reflect.defineMetadata(key, value, (0, object_helper_1.getClass)(target), propertyKey);
|
|
55
|
-
}
|
|
56
|
-
static getParamTypes(targetPrototype, propertyKey) {
|
|
57
|
-
return get(DESIGN_PARAM_TYPES, targetPrototype, propertyKey) || [];
|
|
58
|
-
}
|
|
59
|
-
static getOwnParamTypes(target, propertyKey) {
|
|
60
|
-
return get(DESIGN_PARAM_TYPES, target, propertyKey, true) || [];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.default = Metadata;
|
|
64
|
-
Metadata.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
|
|
65
|
-
const DESIGN_PARAM_TYPES = 'design:paramtypes';
|
|
66
|
-
const DESIGN_TYPE = 'design:type';
|
|
67
|
-
const DESIGN_RETURN_TYPE = 'design:returntype';
|
|
68
|
-
const PROPERTIES = new Map();
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the provide constructor.
|
|
3
|
-
* @param targetClass
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export declare const getConstructor: (targetClass: any) => any;
|
|
7
|
-
/**
|
|
8
|
-
* Get the provide constructor if target is an instance.
|
|
9
|
-
* @param target
|
|
10
|
-
* @returns {*}
|
|
11
|
-
* @ignore
|
|
12
|
-
*/
|
|
13
|
-
export declare function getClass(target: any): any;
|
|
14
|
-
/**
|
|
15
|
-
* Get the provide constructor if target is an instance.
|
|
16
|
-
* @param target
|
|
17
|
-
* @returns {*}
|
|
18
|
-
* @alias getClass
|
|
19
|
-
* @ignore
|
|
20
|
-
*/
|
|
21
|
-
export declare function classOf(target: any): any;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param target
|
|
25
|
-
* @returns {symbol}
|
|
26
|
-
* @ignore
|
|
27
|
-
*/
|
|
28
|
-
export declare function getClassOrSymbol(target: any): any;
|
|
29
|
-
/**
|
|
30
|
-
* Return true if the given obj is a primitive.
|
|
31
|
-
* @param target
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
* @ignore
|
|
34
|
-
*/
|
|
35
|
-
export declare function isPrimitiveOrPrimitiveClass(target: any): boolean;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param target
|
|
39
|
-
* @returns {"string" | "number" | "boolean" | "any"}
|
|
40
|
-
* @ignore
|
|
41
|
-
*/
|
|
42
|
-
export declare function primitiveOf(target: any): 'string' | 'number' | 'boolean' | 'any';
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param target
|
|
46
|
-
* @returns {boolean}
|
|
47
|
-
* @ignore
|
|
48
|
-
*/
|
|
49
|
-
export declare function isString(target: any): boolean;
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param target
|
|
53
|
-
* @returns {boolean}
|
|
54
|
-
* @ignore
|
|
55
|
-
*/
|
|
56
|
-
export declare function isNumber(target: any): boolean;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param target
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
* @ignore
|
|
62
|
-
*/
|
|
63
|
-
export declare function isBoolean(target: any): boolean;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* @param target
|
|
67
|
-
* @returns {Boolean}
|
|
68
|
-
* @ignore
|
|
69
|
-
*/
|
|
70
|
-
export declare function isArray(target: any): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Return true if the clazz is an array.
|
|
73
|
-
* @param target
|
|
74
|
-
* @returns {boolean}
|
|
75
|
-
* @ignore
|
|
76
|
-
*/
|
|
77
|
-
export declare function isArrayOrArrayClass(target: any): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Return true if the target.
|
|
80
|
-
* @param target
|
|
81
|
-
* @returns {boolean}
|
|
82
|
-
* @ignore
|
|
83
|
-
*/
|
|
84
|
-
export declare function isCollection(target: any): boolean;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @param target
|
|
88
|
-
* @returns {boolean}
|
|
89
|
-
* @ignore
|
|
90
|
-
*/
|
|
91
|
-
export declare function isDate(target: any): boolean;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param target
|
|
95
|
-
* @returns {boolean}
|
|
96
|
-
* @ignore
|
|
97
|
-
*/
|
|
98
|
-
export declare function isObject(target: any): boolean;
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
* @param target
|
|
102
|
-
* @returns {boolean}
|
|
103
|
-
* @ignore
|
|
104
|
-
*/
|
|
105
|
-
export declare function isClass(target: any): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Return true if the value is an empty string, null or undefined.
|
|
108
|
-
* @param value
|
|
109
|
-
* @returns {boolean}
|
|
110
|
-
* @ignore
|
|
111
|
-
*/
|
|
112
|
-
export declare function isEmpty(value: any): boolean;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
* @param target
|
|
116
|
-
* @returns {boolean}
|
|
117
|
-
* @ignore
|
|
118
|
-
*/
|
|
119
|
-
export declare function isPromise(target: any): boolean;
|
|
120
|
-
/**
|
|
121
|
-
*
|
|
122
|
-
* @param target
|
|
123
|
-
* @returns {any}
|
|
124
|
-
* @ignore
|
|
125
|
-
*/
|
|
126
|
-
export declare function getInheritedClass(target: any): any;
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @param target
|
|
130
|
-
* @returns {Array}
|
|
131
|
-
* @ignore
|
|
132
|
-
*/
|
|
133
|
-
export declare function ancestorsOf(target: any): any[];
|
|
134
|
-
/**
|
|
135
|
-
* Get object name
|
|
136
|
-
* @ignore
|
|
137
|
-
*/
|
|
138
|
-
export declare function nameOf(obj: any): string;
|
|
139
|
-
/**
|
|
140
|
-
* Get the provide name.
|
|
141
|
-
* @param targetClass
|
|
142
|
-
* @ignore
|
|
143
|
-
*/
|
|
144
|
-
export declare function nameOfClass(targetClass: any): string;
|
|
145
|
-
/**
|
|
146
|
-
* Get symbol name.
|
|
147
|
-
* @param sym
|
|
148
|
-
* @ignore
|
|
149
|
-
*/
|
|
150
|
-
export declare const nameOfSymbol: (sym: symbol) => string;
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* @param target
|
|
154
|
-
* @param {string} propertyKey
|
|
155
|
-
* @returns {PropertyDescriptor}
|
|
156
|
-
* @ignore
|
|
157
|
-
*/
|
|
158
|
-
export declare function descriptorOf(target: any, propertyKey: string): PropertyDescriptor;
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
* @param target
|
|
162
|
-
* @returns {any}
|
|
163
|
-
* @ignore
|
|
164
|
-
*/
|
|
165
|
-
export declare function prototypeOf(target: any): any;
|
|
166
|
-
export declare function getOwnArgumentNames(fn: Function): string[];
|