framework-do-dede 1.0.21 → 1.0.23
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/decorators/index.d.ts +2 -1
- package/dist/decorators/index.js +2 -1
- package/dist/decorators/services.d.ts +1 -0
- package/dist/decorators/services.js +29 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/protocols/StorageGateway.d.ts +5 -0
- package/dist/protocols/StorageGateway.js +11 -0
- package/dist/protocols/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -2,4 +2,5 @@ import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metri
|
|
|
2
2
|
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
4
|
import { Restrict, DbColumn, VirtualProperty } from './entity';
|
|
5
|
-
|
|
5
|
+
import { Storage } from './services';
|
|
6
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn, Storage, VirtualProperty };
|
package/dist/decorators/index.js
CHANGED
|
@@ -2,4 +2,5 @@ import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metri
|
|
|
2
2
|
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
4
|
import { Restrict, DbColumn, VirtualProperty } from './entity';
|
|
5
|
-
|
|
5
|
+
import { Storage } from './services';
|
|
6
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn, Storage, VirtualProperty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Storage(gatewayName: string): (target: any, propertyKey: string) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Registry } from "../di/registry";
|
|
2
|
+
import { StorageGateway } from "../protocols/StorageGateway";
|
|
3
|
+
export function Storage(gatewayName) {
|
|
4
|
+
return function (target, propertyKey) {
|
|
5
|
+
// Verifica se a classe está registrada
|
|
6
|
+
if (!Registry.has(gatewayName)) {
|
|
7
|
+
throw new Error(`StorageGateway ${gatewayName} not registered`);
|
|
8
|
+
}
|
|
9
|
+
const GatewayClass = Registry.resolve(gatewayName);
|
|
10
|
+
// Valida se a classe registrada é uma subclasse de StorageGateway
|
|
11
|
+
if (!(GatewayClass instanceof StorageGateway)) {
|
|
12
|
+
throw new Error(`${gatewayName} is not a valid StorageGateway`);
|
|
13
|
+
}
|
|
14
|
+
const instanceSymbol = Symbol();
|
|
15
|
+
Object.defineProperty(target, propertyKey, {
|
|
16
|
+
get: function () {
|
|
17
|
+
if (!this[instanceSymbol]) {
|
|
18
|
+
this[instanceSymbol] = GatewayClass;
|
|
19
|
+
}
|
|
20
|
+
return this[instanceSymbol];
|
|
21
|
+
},
|
|
22
|
+
set: () => {
|
|
23
|
+
throw new Error('Cannot assign new value to @Storage() property');
|
|
24
|
+
},
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dede, Register as DedeRegister, Options as DedeOptions } from './dede';
|
|
2
|
-
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog } from './decorators';
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog, Storage } from './decorators';
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
|
-
import { Validation, HttpMiddleware, UseCase, CreateRepository, ExistsById, DeleteRepository, UpdateRepository, RestoreRepository, RestoreManyRepository, RequestMetricsHandler, RequestData, RequestMetrics, HttpServerError } from './protocols';
|
|
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
6
|
declare class UseCaseHandler {
|
|
7
7
|
static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
|
|
8
8
|
}
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dede } from './dede';
|
|
2
|
-
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog } from './decorators';
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog, Storage } from './decorators';
|
|
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';
|
|
@@ -16,4 +16,4 @@ class UseCaseHandler {
|
|
|
16
16
|
return instance;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
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 };
|
|
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 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class StorageGateway {
|
|
2
|
+
save(file, path) {
|
|
3
|
+
throw new Error(this.constructor.name + ' save method not implemented');
|
|
4
|
+
}
|
|
5
|
+
get(key) {
|
|
6
|
+
throw new Error(this.constructor.name + ' get method not implemented');
|
|
7
|
+
}
|
|
8
|
+
delete(key) {
|
|
9
|
+
throw new Error(this.constructor.name + ' delete method not implemented');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -11,4 +11,5 @@ import type { RequestMetricsHandler } from './RequestMetricsHandler';
|
|
|
11
11
|
import type { RequestData } from './RequestData';
|
|
12
12
|
import type { RequestMetrics } from './RequestMetrics';
|
|
13
13
|
import type { HttpServerError } from './HttpServerError';
|
|
14
|
-
|
|
14
|
+
import type { StorageGateway } from './StorageGateway';
|
|
15
|
+
export type { RequestData, RequestMetrics, HttpMiddleware, UseCase, Validation, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RestoreManyRepository, RequestMetricsHandler, HttpServerError, StorageGateway, ExistsById };
|