framework-do-dede 1.0.18 → 1.0.19
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,2 +1,3 @@
|
|
|
1
1
|
export declare function Restrict(): (target: any, propertyKey: string) => void;
|
|
2
|
+
export declare function VirtualProperty(propertyName: string): (target: any, methodName: string, descriptor: PropertyDescriptor) => void;
|
|
2
3
|
export declare function DbColumn(mapping: string | Record<string, string>): (target: Object, propertyKey: string) => void;
|
|
@@ -6,6 +6,15 @@ export function Restrict() {
|
|
|
6
6
|
target.constructor._restrictedProperties.add(propertyKey);
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
export function VirtualProperty(propertyName) {
|
|
10
|
+
return function (target, methodName, descriptor) {
|
|
11
|
+
const ctor = target.constructor;
|
|
12
|
+
if (!ctor._exposedProperties) {
|
|
13
|
+
ctor._exposedProperties = new Map();
|
|
14
|
+
}
|
|
15
|
+
ctor._exposedProperties.set(propertyName, methodName);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
9
18
|
export function DbColumn(mapping) {
|
|
10
19
|
return function (target, propertyKey) {
|
|
11
20
|
const ctor = target.constructor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metrics, OffConsoleLog } from './controller';
|
|
2
2
|
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
|
-
import { Restrict, DbColumn } from './entity';
|
|
5
|
-
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn };
|
|
4
|
+
import { Restrict, DbColumn, VirtualProperty } from './entity';
|
|
5
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn, VirtualProperty };
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metrics, OffConsoleLog } from './controller';
|
|
2
2
|
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
|
-
import { Restrict, DbColumn } from './entity';
|
|
5
|
-
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn };
|
|
4
|
+
import { Restrict, DbColumn, VirtualProperty } from './entity';
|
|
5
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn, VirtualProperty };
|
package/dist/domain/Entity.js
CHANGED
|
@@ -2,7 +2,21 @@ export class Entity {
|
|
|
2
2
|
attributes() {
|
|
3
3
|
const ctor = this.constructor;
|
|
4
4
|
const restrictedProps = ctor._restrictedProperties || new Set();
|
|
5
|
-
|
|
5
|
+
const exposedProps = ctor._exposedProperties || new Map();
|
|
6
|
+
const attributes = {};
|
|
7
|
+
for (const [key, value] of Object.entries(this)) {
|
|
8
|
+
if (!restrictedProps.has(key)) {
|
|
9
|
+
attributes[key] = value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
for (const [propName, methodName] of exposedProps) {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
if (!restrictedProps.has(propName) && typeof this[methodName] === "function") {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
attributes[propName] = this[methodName]();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return attributes;
|
|
6
20
|
}
|
|
7
21
|
toSave() {
|
|
8
22
|
this.beforeSave();
|
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, OffConsoleLog } from './decorators';
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog } from './decorators';
|
|
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 } 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, 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 };
|
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, OffConsoleLog } from './decorators';
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, VirtualProperty, OffConsoleLog } 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, 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 };
|