@zenofolio/hyper-decor 1.0.75 → 1.0.81
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/README.md +42 -0
- package/dist/__internals/helpers/prepare.helper.js +15 -6
- package/dist/common/testing.d.ts +56 -0
- package/dist/common/testing.js +193 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/server/decorators/HyperService.d.ts +2 -1
- package/dist/lib/server/decorators/types.d.ts +1 -1
- package/package.json +5 -1
- package/dist/__internals/creators/request.creator.d.ts +0 -2
- package/dist/__internals/creators/request.creator.js +0 -173
- package/dist/__internals/creators/routes.creator.d.ts +0 -9
- package/dist/__internals/creators/routes.creator.js +0 -39
- package/dist/__internals/decorator-base.d.ts +0 -30
- package/dist/__internals/decorator-base.js +0 -122
- package/dist/__internals/helpers/imports.helper.d.ts +0 -8
- package/dist/__internals/helpers/imports.helper.js +0 -92
- package/dist/__internals/helpers/tree.helper.d.ts +0 -36
- package/dist/__internals/helpers/tree.helper.js +0 -81
- package/dist/__internals/stores/metadata.store.d.ts +0 -15
- package/dist/__internals/stores/metadata.store.js +0 -37
- package/dist/__internals/stores/service.store.d.ts +0 -1
- package/dist/__internals/stores/service.store.js +0 -4
- package/dist/decorators/File.d.ts +0 -37
- package/dist/decorators/File.js +0 -167
- package/dist/decorators/Http.d.ts +0 -22
- package/dist/decorators/Http.js +0 -45
- package/dist/decorators/HyperApp.d.ts +0 -3
- package/dist/decorators/HyperApp.js +0 -96
- package/dist/decorators/HyperController.d.ts +0 -2
- package/dist/decorators/HyperController.js +0 -20
- package/dist/decorators/HyperModule.d.ts +0 -5
- package/dist/decorators/HyperModule.js +0 -14
- package/dist/decorators/HyperService.d.ts +0 -15
- package/dist/decorators/HyperService.js +0 -29
- package/dist/decorators/Messaging.d.ts +0 -10
- package/dist/decorators/Messaging.js +0 -22
- package/dist/decorators/Middleware.d.ts +0 -25
- package/dist/decorators/Middleware.js +0 -65
- package/dist/decorators/Output.d.ts +0 -9
- package/dist/decorators/Output.js +0 -18
- package/dist/decorators/Pass.d.ts +0 -15
- package/dist/decorators/Pass.js +0 -32
- package/dist/decorators/Role.d.ts +0 -6
- package/dist/decorators/Role.js +0 -34
- package/dist/decorators/Routes.d.ts +0 -15
- package/dist/decorators/Routes.js +0 -21
- package/dist/decorators/Scope.d.ts +0 -6
- package/dist/decorators/Scope.js +0 -25
- package/dist/decorators/Transform.d.ts +0 -14
- package/dist/decorators/Transform.js +0 -18
- package/dist/decorators/index.d.ts +0 -14
- package/dist/decorators/index.js +0 -30
- package/dist/decorators/types.d.ts +0 -124
- package/dist/decorators/types.js +0 -6
- package/dist/exeptions/DuplicateControllerPathException.d.ts +0 -14
- package/dist/exeptions/DuplicateControllerPathException.js +0 -12
- package/dist/exeptions/DuplicatedException.d.ts +0 -8
- package/dist/exeptions/DuplicatedException.js +0 -12
- package/dist/exeptions/DuplicatedHandlerException.d.ts +0 -4
- package/dist/exeptions/DuplicatedHandlerException.js +0 -12
- package/dist/exeptions/HyperException.d.ts +0 -8
- package/dist/exeptions/HyperException.js +0 -14
- package/dist/exeptions/HyperFileException.d.ts +0 -4
- package/dist/exeptions/HyperFileException.js +0 -12
- package/dist/exeptions/MethodNotFountException.d.ts +0 -4
- package/dist/exeptions/MethodNotFountException.js +0 -12
- package/dist/exeptions/NotPropertyException.d.ts +0 -6
- package/dist/exeptions/NotPropertyException.js +0 -16
- package/dist/exeptions/NotRoleException.d.ts +0 -6
- package/dist/exeptions/NotRoleException.js +0 -17
- package/dist/exeptions/NotScopeException.d.ts +0 -7
- package/dist/exeptions/NotScopeException.js +0 -18
- package/dist/exeptions/WrongPlaceException.d.ts +0 -8
- package/dist/exeptions/WrongPlaceException.js +0 -21
- package/dist/exeptions/index.d.ts +0 -8
- package/dist/exeptions/index.js +0 -18
- package/dist/exeptions/types.d.ts +0 -1
- package/dist/exeptions/types.js +0 -2
- package/dist/lib/openapi/collectors/param.collector.d.ts +0 -2
- package/dist/lib/openapi/collectors/param.collector.js +0 -64
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.d.ts +0 -2
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-method.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-method.decorator.js +0 -11
- package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-parameter.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-request-body.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-response.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-response.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-security.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-security.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-tag.decorator.js +0 -13
- package/dist/lib/openapi/decorators/index.d.ts +0 -7
- package/dist/lib/openapi/decorators/index.js +0 -23
- package/dist/lib/openapi/helpers/index.d.ts +0 -7
- package/dist/lib/openapi/helpers/index.js +0 -23
- package/dist/lib/openapi/helpers/method.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/method.helper.js +0 -20
- package/dist/lib/openapi/helpers/openapi.helper.d.ts +0 -7
- package/dist/lib/openapi/helpers/openapi.helper.js +0 -51
- package/dist/lib/openapi/helpers/parameter.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/parameter.helper.js +0 -16
- package/dist/lib/openapi/helpers/request-body.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/request-body.helper.js +0 -9
- package/dist/lib/openapi/helpers/response.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/response.helper.js +0 -18
- package/dist/lib/openapi/helpers/security.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/security.helper.js +0 -17
- package/dist/lib/openapi/helpers/tag.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/tag.helper.js +0 -10
- package/dist/stores/index.d.ts +0 -1
- package/dist/stores/index.js +0 -17
- package/dist/stores/scope.store.d.ts +0 -14
- package/dist/stores/scope.store.js +0 -29
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { MiddlewareHandler, MiddlewareNext, Request, Response, ServerConstructorOptions } from "hyper-express";
|
|
2
|
-
import { InjectionToken, RegistrationOptions } from "tsyringe";
|
|
3
|
-
import { IMessageTransport } from "../common/transport";
|
|
4
|
-
export interface OnInit {
|
|
5
|
-
onInit(): Promise<any>;
|
|
6
|
-
}
|
|
7
|
-
export interface IsSingleton {
|
|
8
|
-
isSingleton(): boolean;
|
|
9
|
-
}
|
|
10
|
-
export type Constructor<R extends any = any> = new (...args: any[]) => R;
|
|
11
|
-
export type ImportObject = {
|
|
12
|
-
token: InjectionToken;
|
|
13
|
-
useClass?: Constructor;
|
|
14
|
-
useValue?: any;
|
|
15
|
-
useFactory?: (...args: any[]) => any;
|
|
16
|
-
useToken?: InjectionToken;
|
|
17
|
-
options?: RegistrationOptions;
|
|
18
|
-
};
|
|
19
|
-
export type ImportType = Constructor<Partial<OnInit> & Partial<IsSingleton>> | InjectionToken | ImportObject;
|
|
20
|
-
export type ConstructorDecorator = (target: Constructor, kay?: any, descriptor?: PropertyDescriptor) => Constructor;
|
|
21
|
-
export type HyperClassDecorator<T> = (options?: T) => ConstructorDecorator;
|
|
22
|
-
export type HyperMethodDecorator<T> = (options?: T) => (target: any, key?: any, descriptor?: PropertyDescriptor) => void;
|
|
23
|
-
export interface LogSpaces {
|
|
24
|
-
modules: boolean;
|
|
25
|
-
controllers: boolean;
|
|
26
|
-
middleware: boolean;
|
|
27
|
-
routes: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface IHyperHooks {
|
|
30
|
-
onBeforeInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
31
|
-
onAfterInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
export interface HyperAppMetadata {
|
|
34
|
-
name?: string;
|
|
35
|
-
version?: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
author?: string;
|
|
38
|
-
license?: string;
|
|
39
|
-
prefix?: string;
|
|
40
|
-
logger?: (...args: any[]) => void;
|
|
41
|
-
logs?: Partial<LogSpaces>;
|
|
42
|
-
modules: Constructor[];
|
|
43
|
-
imports?: ImportType[];
|
|
44
|
-
options?: ServerConstructorOptions;
|
|
45
|
-
transports?: IMessageTransport[];
|
|
46
|
-
hooks?: IHyperHooks | Constructor<IHyperHooks>;
|
|
47
|
-
}
|
|
48
|
-
export interface HyperAppDecorator {
|
|
49
|
-
(options?: HyperAppMetadata): (target: Constructor) => Constructor;
|
|
50
|
-
}
|
|
51
|
-
export type HyperModuleMetadata = {
|
|
52
|
-
path?: string;
|
|
53
|
-
name?: string;
|
|
54
|
-
roles?: string[];
|
|
55
|
-
scopes?: string[];
|
|
56
|
-
modules?: Constructor[];
|
|
57
|
-
controllers?: Constructor[];
|
|
58
|
-
imports?: ImportType[];
|
|
59
|
-
};
|
|
60
|
-
export type HyperModuleDecorator = HyperClassDecorator<HyperModuleMetadata>;
|
|
61
|
-
export type HyperControllerMetadata = {
|
|
62
|
-
path?: string;
|
|
63
|
-
roles?: string[];
|
|
64
|
-
scopes?: string[];
|
|
65
|
-
imports?: ImportType[];
|
|
66
|
-
};
|
|
67
|
-
export type HyperControllerDecorator = HyperClassDecorator<HyperControllerMetadata | string>;
|
|
68
|
-
export type ParameterResolver = (req: Request, res: Response) => any | Promise<any>;
|
|
69
|
-
export type HyperParameterMetadata = {
|
|
70
|
-
params: Record<string, {
|
|
71
|
-
index: number;
|
|
72
|
-
type: any;
|
|
73
|
-
key: string;
|
|
74
|
-
name: string;
|
|
75
|
-
method: string;
|
|
76
|
-
resolver: ParameterResolver;
|
|
77
|
-
schema?: any;
|
|
78
|
-
isWholeSource?: boolean;
|
|
79
|
-
}[]>;
|
|
80
|
-
};
|
|
81
|
-
export type HyperParamDecorator = (key: string) => (target: any, key: string, index: number) => void;
|
|
82
|
-
export type RoleMap<T> = {
|
|
83
|
-
role: T;
|
|
84
|
-
description: string;
|
|
85
|
-
message?: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Type definition for Role decorator.
|
|
89
|
-
* It can accept a single role, an array of roles, or a function that evaluates roles dynamically.
|
|
90
|
-
*/
|
|
91
|
-
export type RoleType<T extends string = string> = T | T[] | RoleMap<T> | RoleMap<T>[];
|
|
92
|
-
export type ScopeMap<T extends string = string> = {
|
|
93
|
-
scope: T;
|
|
94
|
-
description: string;
|
|
95
|
-
message?: string;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Type definition for Scope decorator.
|
|
99
|
-
* It can accept a single scope or multiple scopes as an array of strings.
|
|
100
|
-
*/
|
|
101
|
-
export type ScopeType<T extends string = string> = T | T[] | ScopeMap<T> | ScopeMap<T>[];
|
|
102
|
-
/**
|
|
103
|
-
* Type definition for Route metadata.
|
|
104
|
-
* Contains method, path, and handler function name.
|
|
105
|
-
*/
|
|
106
|
-
export interface RouteMetadata {
|
|
107
|
-
className: string;
|
|
108
|
-
method: string;
|
|
109
|
-
path: string;
|
|
110
|
-
propertyKey: string;
|
|
111
|
-
options?: any;
|
|
112
|
-
handler: (...args: any[]) => any;
|
|
113
|
-
}
|
|
114
|
-
export declare abstract class MiddlewareClass {
|
|
115
|
-
abstract handle(req: Request, res: Response, next: MiddlewareNext): void;
|
|
116
|
-
}
|
|
117
|
-
export interface MiddlewareClassConstructor {
|
|
118
|
-
new (...args: any[]): MiddlewareClass;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Type definition for Middleware.
|
|
122
|
-
* Middleware can be a single handler or an array of handlers.
|
|
123
|
-
*/
|
|
124
|
-
export type MiddlewareType = MiddlewareHandler | MiddlewareClassConstructor;
|
package/dist/decorators/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import HyperException from "./HyperException";
|
|
2
|
-
export default class DuplicateControllerPathException extends HyperException {
|
|
3
|
-
constructor(data: {
|
|
4
|
-
path: string;
|
|
5
|
-
current: {
|
|
6
|
-
module: string;
|
|
7
|
-
controller: string;
|
|
8
|
-
};
|
|
9
|
-
duplicate: {
|
|
10
|
-
module: string;
|
|
11
|
-
controller: string;
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class DuplicateControllerPathException extends HyperException_1.default {
|
|
8
|
-
constructor(data) {
|
|
9
|
-
super(`Duplicate controller path: '${data.path}' in ${data.current.module}/${data.current.controller} and ${data.duplicate.module} controller: ${data.duplicate.controller}`, "DuplicateControllerPathException", data);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = DuplicateControllerPathException;
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class DuplicatedException extends HyperException_1.default {
|
|
8
|
-
constructor(data) {
|
|
9
|
-
super(`Duplicate at path: '${data.path}' in ${data.currentNameSpace} and ${data.duplicateNameSpace}`, "DuplicatedException", data);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = DuplicatedException;
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class DuplicatedHandlerException extends HyperException_1.default {
|
|
8
|
-
constructor(message) {
|
|
9
|
-
super(message, "DuplicateHandlerException");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = DuplicatedHandlerException;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExceptionType } from "./types";
|
|
2
|
-
export default class HyperException extends Error {
|
|
3
|
-
code: ExceptionType;
|
|
4
|
-
additionalInfo: any;
|
|
5
|
-
status: number;
|
|
6
|
-
constructor(message: string, code?: ExceptionType, additionalInfo?: any, status?: number);
|
|
7
|
-
static throw(message: string, code?: ExceptionType, additionalInfo?: {}): void;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class HyperException extends Error {
|
|
4
|
-
constructor(message, code = "HyperException", additionalInfo = {}, status = 500) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.code = code;
|
|
7
|
-
this.additionalInfo = additionalInfo;
|
|
8
|
-
this.status = status;
|
|
9
|
-
}
|
|
10
|
-
static throw(message, code, additionalInfo = {}) {
|
|
11
|
-
throw new this(message, code, additionalInfo);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = HyperException;
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class HyperFileException extends HyperException_1.default {
|
|
8
|
-
constructor(message, additional) {
|
|
9
|
-
super(message, "HyperFileException", additional, 400);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = HyperFileException;
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class MethodNotFountException extends HyperException_1.default {
|
|
8
|
-
constructor(className, method, path) {
|
|
9
|
-
super(`Method ${method} not exists in ${className} for path ${path}`, "MethodNotFountException");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = MethodNotFountException;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class NotPropertyException extends HyperException_1.default {
|
|
8
|
-
constructor(namespace, target) {
|
|
9
|
-
super(`This decorator cannot be used as a property decorator in ${namespace}`, "NotPropertyException", {
|
|
10
|
-
target,
|
|
11
|
-
});
|
|
12
|
-
this.namespace = namespace;
|
|
13
|
-
this.target = target;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.default = NotPropertyException;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class NotRoleException extends HyperException_1.default {
|
|
8
|
-
constructor(message = `Has not Permission to access this resource`, roles = [], requiredRoles = []) {
|
|
9
|
-
super(message, "NotRoleException", {
|
|
10
|
-
roles,
|
|
11
|
-
requiredRoles,
|
|
12
|
-
});
|
|
13
|
-
this.roles = roles;
|
|
14
|
-
this.requiredRoles = requiredRoles;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.default = NotRoleException;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import HyperException from "./HyperException";
|
|
2
|
-
export default class NotScopeException extends HyperException {
|
|
3
|
-
message: string;
|
|
4
|
-
requestScopes: string[];
|
|
5
|
-
requiredScopes: string[];
|
|
6
|
-
constructor(message: string, requestScopes?: string[], requiredScopes?: string[]);
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class NotScopeException extends HyperException_1.default {
|
|
8
|
-
constructor(message, requestScopes = [], requiredScopes = []) {
|
|
9
|
-
super(message || `You don't have the required scopes to access this resource`, "NotScopeException", {
|
|
10
|
-
requestScopes,
|
|
11
|
-
requiredScopes,
|
|
12
|
-
});
|
|
13
|
-
this.message = message;
|
|
14
|
-
this.requestScopes = requestScopes;
|
|
15
|
-
this.requiredScopes = requiredScopes;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = NotScopeException;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import HyperException from "./HyperException";
|
|
2
|
-
export default class WrongPlaceException extends HyperException {
|
|
3
|
-
decorator: string;
|
|
4
|
-
as: string;
|
|
5
|
-
namespace: string;
|
|
6
|
-
target: any;
|
|
7
|
-
constructor(decorator: string, as: string, namespace: string, target: any);
|
|
8
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
-
class WrongPlaceException extends HyperException_1.default {
|
|
8
|
-
constructor(decorator, as, namespace, target) {
|
|
9
|
-
super(`The decorator @${decorator} only can be used as a ${as} decorator. Error => ${namespace}`, "WrongPlaceException", {
|
|
10
|
-
decorator,
|
|
11
|
-
target,
|
|
12
|
-
namespace,
|
|
13
|
-
as,
|
|
14
|
-
});
|
|
15
|
-
this.decorator = decorator;
|
|
16
|
-
this.as = as;
|
|
17
|
-
this.namespace = namespace;
|
|
18
|
-
this.target = target;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = WrongPlaceException;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import DuplicatedHandlerException from "./DuplicatedHandlerException";
|
|
2
|
-
import DuplicateControllerPathException from "./DuplicateControllerPathException";
|
|
3
|
-
import HyperException from "./HyperException";
|
|
4
|
-
import MethodNotFountException from "./MethodNotFountException";
|
|
5
|
-
import NotRoleException from "./NotRoleException";
|
|
6
|
-
import NotScopeException from "./NotScopeException";
|
|
7
|
-
export type * from "./types";
|
|
8
|
-
export { DuplicatedHandlerException, DuplicateControllerPathException as DuplicatedRouterException, HyperException, NotRoleException, NotScopeException, MethodNotFountException as MethodNotExists, };
|
package/dist/exeptions/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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.MethodNotExists = exports.NotScopeException = exports.NotRoleException = exports.HyperException = exports.DuplicatedRouterException = exports.DuplicatedHandlerException = void 0;
|
|
7
|
-
const DuplicatedHandlerException_1 = __importDefault(require("./DuplicatedHandlerException"));
|
|
8
|
-
exports.DuplicatedHandlerException = DuplicatedHandlerException_1.default;
|
|
9
|
-
const DuplicateControllerPathException_1 = __importDefault(require("./DuplicateControllerPathException"));
|
|
10
|
-
exports.DuplicatedRouterException = DuplicateControllerPathException_1.default;
|
|
11
|
-
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
12
|
-
exports.HyperException = HyperException_1.default;
|
|
13
|
-
const MethodNotFountException_1 = __importDefault(require("./MethodNotFountException"));
|
|
14
|
-
exports.MethodNotExists = MethodNotFountException_1.default;
|
|
15
|
-
const NotRoleException_1 = __importDefault(require("./NotRoleException"));
|
|
16
|
-
exports.NotRoleException = NotRoleException_1.default;
|
|
17
|
-
const NotScopeException_1 = __importDefault(require("./NotScopeException"));
|
|
18
|
-
exports.NotScopeException = NotScopeException_1.default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ExceptionType = "DuplicateControllerException" | "DuplicateHandlerException" | "DuplicateRouterException" | "HyperException" | "NotRoleException" | "NotScopeException" | "MethodNotFountException" | "DuplicateControllerPathException" | "DuplicateHandlerException" | "DuplicatedException" | "NotPropertyException" | "WrongPlaceException" | "HyperFileException" | "DpublicateModuleException";
|
package/dist/exeptions/types.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectParameterMetadata = collectParameterMetadata;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const constants_2 = require("../../../__internals/constants");
|
|
6
|
-
const transform_registry_1 = require("../../../__internals/transform/transform.registry");
|
|
7
|
-
const function_util_1 = require("../../../__internals/utils/function.util");
|
|
8
|
-
function collectParameterMetadata(target, methodName) {
|
|
9
|
-
const parameters = Reflect.getMetadata(constants_1.PARAMETERS, target, methodName) || [];
|
|
10
|
-
const hyperParams = Reflect.getMetadata(constants_2.KEY_PARAMS_PARAM, target[methodName]);
|
|
11
|
-
if (hyperParams && hyperParams.params[methodName]) {
|
|
12
|
-
hyperParams.params[methodName].forEach((p) => {
|
|
13
|
-
// Ignore body, req, res as they are not standard "parameters" in OpenAPI terms (body is separate)
|
|
14
|
-
if (['req', 'res', 'body', 'BODY'].includes(p.key))
|
|
15
|
-
return;
|
|
16
|
-
const locationMap = {
|
|
17
|
-
'query': 'query',
|
|
18
|
-
'params': 'path',
|
|
19
|
-
'headers': 'header',
|
|
20
|
-
'cookie': 'cookie'
|
|
21
|
-
};
|
|
22
|
-
const location = locationMap[p.key] || 'query';
|
|
23
|
-
if (p.isWholeSource && p.schema) {
|
|
24
|
-
const schema = transform_registry_1.transformRegistry.getOpenApiSchema(p.schema);
|
|
25
|
-
if (schema && schema.properties) {
|
|
26
|
-
Object.keys(schema.properties).forEach((propKey) => {
|
|
27
|
-
parameters.push({
|
|
28
|
-
name: propKey,
|
|
29
|
-
in: location,
|
|
30
|
-
required: (schema.required || []).includes(propKey),
|
|
31
|
-
schema: schema.properties[propKey]
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
parameters.push({
|
|
38
|
-
name: p.name,
|
|
39
|
-
in: location,
|
|
40
|
-
required: true, // TODO: detect optionality from design:paramtypes or metadata
|
|
41
|
-
schema: p.schema ? transform_registry_1.transformRegistry.getOpenApiSchema(p.schema) : { type: 'string' }
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Fallback to design:paramtypes if no hyper-decor metadata found
|
|
47
|
-
if (parameters.length === 0) {
|
|
48
|
-
const methodParams = Reflect.getMetadata("design:paramtypes", target, methodName) || [];
|
|
49
|
-
const paramNames = (0, function_util_1.extractArgsNames)(target[methodName]);
|
|
50
|
-
methodParams.forEach((paramType, index) => {
|
|
51
|
-
var _a;
|
|
52
|
-
const name = paramNames && paramNames[index] ? paramNames[index] : `param${index}`;
|
|
53
|
-
parameters.push({
|
|
54
|
-
name,
|
|
55
|
-
in: "query",
|
|
56
|
-
required: true,
|
|
57
|
-
schema: {
|
|
58
|
-
type: ((_a = paramType === null || paramType === void 0 ? void 0 : paramType.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'number' ? 'number' : 'string',
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return parameters;
|
|
64
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiBearerAuth = ApiBearerAuth;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const security_helper_1 = require("../helpers/security.helper");
|
|
6
|
-
function ApiBearerAuth(name = 'bearerAuth') {
|
|
7
|
-
return (target, propertyKey, descriptor) => {
|
|
8
|
-
(0, security_helper_1.apiSecurity)(target, { [name]: [] }, propertyKey);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiMethod = ApiMethod;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const method_helper_1 = require("../helpers/method.helper");
|
|
6
|
-
function ApiMethod(options) {
|
|
7
|
-
return (target, propertyKey, descriptor) => {
|
|
8
|
-
(0, method_helper_1.apimethod)(target, propertyKey, options);
|
|
9
|
-
return descriptor;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiParameter = ApiParameter;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const parameter_helper_1 = require("../helpers/parameter.helper");
|
|
6
|
-
function ApiParameter(options) {
|
|
7
|
-
return (target, propertyKey) => {
|
|
8
|
-
(0, parameter_helper_1.apiParameter)(target, propertyKey, options);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiRequestBody = ApiRequestBody;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const request_body_helper_1 = require("../helpers/request-body.helper");
|
|
6
|
-
function ApiRequestBody(options) {
|
|
7
|
-
return (target, propertyKey) => {
|
|
8
|
-
(0, request_body_helper_1.apiRequestBody)(target, propertyKey, options);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiResponse = ApiResponse;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const response_helper_1 = require("../helpers/response.helper");
|
|
6
|
-
function ApiResponse(options) {
|
|
7
|
-
return (target, propertyKey, descriptor) => {
|
|
8
|
-
(0, response_helper_1.apiResponse)(target, propertyKey, options);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiSecurity = ApiSecurity;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const security_helper_1 = require("../helpers/security.helper");
|
|
6
|
-
function ApiSecurity(options) {
|
|
7
|
-
return (target, propertyKey, descriptor) => {
|
|
8
|
-
(0, security_helper_1.apiSecurity)(target, options, propertyKey);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiTag = ApiTag;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const tag_helper_1 = require("../helpers/tag.helper");
|
|
6
|
-
function ApiTag(options) {
|
|
7
|
-
return (target) => {
|
|
8
|
-
if (typeof options === 'string') {
|
|
9
|
-
options = { name: options };
|
|
10
|
-
}
|
|
11
|
-
(0, tag_helper_1.apiTag)(target, options);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./api-method.decorator";
|
|
2
|
-
export * from "./api-parameter.decorator";
|
|
3
|
-
export * from "./api-request-body.decorator";
|
|
4
|
-
export * from "./api-response.decorator";
|
|
5
|
-
export * from "./api-security.decorator";
|
|
6
|
-
export * from "./api-bearer-auth.decorator";
|
|
7
|
-
export * from "./api-tag.decorator";
|
|
@@ -1,23 +0,0 @@
|
|
|
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("./api-method.decorator"), exports);
|
|
18
|
-
__exportStar(require("./api-parameter.decorator"), exports);
|
|
19
|
-
__exportStar(require("./api-request-body.decorator"), exports);
|
|
20
|
-
__exportStar(require("./api-response.decorator"), exports);
|
|
21
|
-
__exportStar(require("./api-security.decorator"), exports);
|
|
22
|
-
__exportStar(require("./api-bearer-auth.decorator"), exports);
|
|
23
|
-
__exportStar(require("./api-tag.decorator"), exports);
|