framework-do-dede 5.5.3 → 5.5.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/application/controller.d.ts +1 -0
- package/dist/application/controller.js +11 -0
- package/dist/application/index.d.ts +2 -2
- package/dist/application/index.js +2 -2
- package/dist/http/controller.handler.js +8 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ type BodyFilter = "restrict" | "none";
|
|
|
30
30
|
export declare function Controller(basePath?: string): (target: any) => void;
|
|
31
31
|
export declare function Tracing<R>(tracer: Tracer<R>): (target: any, propertyKey?: string) => void;
|
|
32
32
|
export declare function Version(version: number): (target: any, propertyKey?: string) => void;
|
|
33
|
+
export declare function PresetIgnore(ignorePrefix?: boolean, ignoreVersion?: boolean): (target: any, propertyKey?: string) => void;
|
|
33
34
|
export declare function UseMiddleware(middlewareClass: MiddlewareDefinition): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
34
35
|
export declare function UseMiddlewares(middlewareClasses: MiddlewareDefinition[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
35
36
|
export declare function Post(config?: {
|
|
@@ -30,6 +30,17 @@ export function Version(version) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
export function PresetIgnore(ignorePrefix = true, ignoreVersion = true) {
|
|
34
|
+
return function (target, propertyKey) {
|
|
35
|
+
const ignoreConfig = { prefix: ignorePrefix, version: ignoreVersion };
|
|
36
|
+
if (!propertyKey) {
|
|
37
|
+
Reflect.defineMetadata('presetIgnore', ignoreConfig, target);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
Reflect.defineMetadata('presetIgnore', ignoreConfig, target, propertyKey);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
33
44
|
function isClass(fn) {
|
|
34
45
|
return /^\s*class\s/.test(Function.prototype.toString.call(fn));
|
|
35
46
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version, type Middleware, type Input, type Tracer, type TracerData } from './controller';
|
|
1
|
+
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version, PresetIgnore, type Middleware, type Input, type Tracer, type TracerData } from './controller';
|
|
2
2
|
import { Entity, Restrict, VirtualProperty, GetterPrefix, Transform } from '../infra/serialization/entity';
|
|
3
3
|
import { Model, model, column } from '../infra/model/model';
|
|
4
4
|
import { DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter } from './usecase';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, };
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, };
|
|
6
6
|
export { Storage, CacheGateway, EventDispatcher } from './services';
|
|
7
7
|
export type { Middleware, Input, Tracer, TracerData };
|
|
8
8
|
export type { StorageGateway } from './services';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version } from './controller';
|
|
1
|
+
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version, PresetIgnore } from './controller';
|
|
2
2
|
import { Entity, Restrict, VirtualProperty, GetterPrefix, Transform } from '../infra/serialization/entity';
|
|
3
3
|
import { Model, model, column } from '../infra/model/model';
|
|
4
4
|
import { DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, } from './usecase';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, };
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, };
|
|
6
6
|
export { Storage, CacheGateway, EventDispatcher } from './services';
|
|
@@ -97,6 +97,7 @@ export default class ControllerHandler {
|
|
|
97
97
|
const methodNames = Object.getOwnPropertyNames(controller.prototype).filter(method => method !== 'constructor');
|
|
98
98
|
let tracer = Reflect.getMetadata('tracer', controller) || null;
|
|
99
99
|
const controllerVersion = Reflect.getMetadata('version', controller);
|
|
100
|
+
const controllerPresetIgnore = Reflect.getMetadata('presetIgnore', controller);
|
|
100
101
|
const instance = new controller();
|
|
101
102
|
for (const methodName of methodNames) {
|
|
102
103
|
const routeConfig = Reflect.getMetadata('route', controller.prototype, methodName);
|
|
@@ -104,8 +105,13 @@ export default class ControllerHandler {
|
|
|
104
105
|
const responseType = Reflect.getMetadata('responseType', controller.prototype, methodName) || 'json';
|
|
105
106
|
tracer = Reflect.getMetadata('tracer', controller.prototype, methodName) || tracer;
|
|
106
107
|
const methodVersion = Reflect.getMetadata('version', controller.prototype, methodName);
|
|
107
|
-
const
|
|
108
|
-
const
|
|
108
|
+
const methodPresetIgnore = Reflect.getMetadata('presetIgnore', controller.prototype, methodName);
|
|
109
|
+
const presetIgnore = methodPresetIgnore ?? controllerPresetIgnore;
|
|
110
|
+
const ignoreGlobalVersion = presetIgnore?.version === true;
|
|
111
|
+
const ignoreGlobalPrefix = presetIgnore?.prefix === true;
|
|
112
|
+
const resolvedVersion = methodVersion ?? controllerVersion ?? (ignoreGlobalVersion ? undefined : this.version);
|
|
113
|
+
const resolvedPrefix = ignoreGlobalPrefix ? undefined : this.prefix;
|
|
114
|
+
const route = this.buildRoute(basePath + routeConfig.path, resolvedVersion, resolvedPrefix);
|
|
109
115
|
controllers.push({
|
|
110
116
|
method: routeConfig.method,
|
|
111
117
|
route,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher } from "./application";
|
|
1
|
+
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher } from "./application";
|
|
2
2
|
import { Container, DefaultContainer, Inject, setDefaultContainer } from './infra/di/registry';
|
|
3
3
|
import { Dede, type Options, Register } from './dede';
|
|
4
4
|
import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError } from './http/errors/server';
|
|
@@ -6,5 +6,5 @@ import { AppError } from './domain/errors/app-error';
|
|
|
6
6
|
import type { ValidatorDefinition } from './interface/validation/validator';
|
|
7
7
|
import type { StorageGateway, Event, EventPayload } from './application';
|
|
8
8
|
import type { RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryExistsBy, RepositoryRestore, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination } from './protocols/repository';
|
|
9
|
-
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, Options, Register, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
|
9
|
+
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, Options, Register, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
|
10
10
|
export type { ValidatorDefinition, StorageGateway, Event, EventPayload };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
// controller
|
|
3
|
-
Post, Get, Put, Delete, Patch, Controller, Version, UseMiddleware, UseMiddlewares, Tracing,
|
|
3
|
+
Post, Get, Put, Delete, Patch, Controller, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing,
|
|
4
4
|
// controller
|
|
5
5
|
// entity
|
|
6
6
|
Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column,
|
|
@@ -16,4 +16,4 @@ import { Container, DefaultContainer, Inject, setDefaultContainer } from './infr
|
|
|
16
16
|
import { Dede } from './dede';
|
|
17
17
|
import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError } from './http/errors/server';
|
|
18
18
|
import { AppError } from './domain/errors/app-error';
|
|
19
|
-
export { Controller, Post, Get, Put, Delete, Patch, Version, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError };
|
|
19
|
+
export { Controller, Post, Get, Put, Delete, Patch, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError };
|