framework-do-dede 1.0.22 → 1.0.24
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function Storage(): (target: any, propertyKey: string) => void;
|
|
1
|
+
export declare function Storage(gatewayName: string): (target: any, propertyKey: string) => void;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { Registry } from "../di/registry";
|
|
2
2
|
import { StorageGateway } from "../protocols/StorageGateway";
|
|
3
|
-
|
|
3
|
+
import { Log } from "../utils/Log";
|
|
4
|
+
import { Testing } from "../utils/Testing";
|
|
5
|
+
export function Storage(gatewayName) {
|
|
4
6
|
return function (target, propertyKey) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
if (Testing.isEnabled()) {
|
|
8
|
+
Log.info(`@Storage ${gatewayName} is ignored in testing mode`);
|
|
9
|
+
return;
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
// Verifica se a classe está registrada
|
|
10
12
|
if (!Registry.has(gatewayName)) {
|
|
11
13
|
throw new Error(`StorageGateway ${gatewayName} not registered`);
|
|
12
14
|
}
|
|
15
|
+
const GatewayClass = Registry.resolve(gatewayName);
|
|
16
|
+
// Valida se a classe registrada é uma subclasse de StorageGateway
|
|
17
|
+
if (!(GatewayClass instanceof StorageGateway)) {
|
|
18
|
+
throw new Error(`${gatewayName} is not a valid StorageGateway`);
|
|
19
|
+
}
|
|
13
20
|
const instanceSymbol = Symbol();
|
|
14
21
|
Object.defineProperty(target, propertyKey, {
|
|
15
22
|
get: function () {
|
|
16
23
|
if (!this[instanceSymbol]) {
|
|
17
|
-
const GatewayClass = Registry.resolve(gatewayName);
|
|
18
24
|
this[instanceSymbol] = GatewayClass;
|
|
19
25
|
}
|
|
20
26
|
return this[instanceSymbol];
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Conte
|
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
4
|
import { Validation, HttpMiddleware, UseCase, CreateRepository, ExistsById, DeleteRepository, UpdateRepository, RestoreRepository, RestoreManyRepository, RequestMetricsHandler, RequestData, RequestMetrics, HttpServerError, StorageGateway } from './protocols';
|
|
5
5
|
import { Entity } from './domain/Entity';
|
|
6
|
+
import { Testing } from './utils/Testing';
|
|
6
7
|
declare class UseCaseHandler {
|
|
7
8
|
static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
|
|
8
9
|
}
|
|
9
|
-
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, HttpServerError, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, ExistsById, RestoreManyRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, VirtualProperty, Metrics, OffConsoleLog, StorageGateway, Storage };
|
|
10
|
+
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, HttpServerError, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, ExistsById, RestoreManyRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, VirtualProperty, Metrics, OffConsoleLog, StorageGateway, Storage, Testing };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Conte
|
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
4
|
import { Registry } from './di/registry';
|
|
5
5
|
import { Entity } from './domain/Entity';
|
|
6
|
+
import { Testing } from './utils/Testing';
|
|
6
7
|
class UseCaseHandler {
|
|
7
8
|
static load(useCaseClass, request) {
|
|
8
9
|
const instance = Registry.classLoader(useCaseClass);
|
|
@@ -16,4 +17,4 @@ class UseCaseHandler {
|
|
|
16
17
|
return instance;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
export { Dede, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, VirtualProperty, Metrics, OffConsoleLog, Storage };
|
|
20
|
+
export { Dede, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, VirtualProperty, Metrics, OffConsoleLog, Storage, Testing };
|