framework-do-dede 3.0.28 → 3.0.30
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,6 +1,3 @@
|
|
|
1
|
-
export interface EntityIdentifier<T> {
|
|
2
|
-
getValue(): T;
|
|
3
|
-
}
|
|
4
1
|
export declare abstract class Entity {
|
|
5
2
|
[x: string]: any;
|
|
6
3
|
toEntity(): Record<string, any>;
|
|
@@ -12,10 +9,8 @@ export declare abstract class Entity {
|
|
|
12
9
|
serialize?: boolean;
|
|
13
10
|
}): Promise<Record<string, any>>;
|
|
14
11
|
protected generateGetters(): void;
|
|
15
|
-
constructor();
|
|
16
12
|
}
|
|
17
13
|
export declare function Restrict(): (target: any, propertyKey: string) => void;
|
|
18
14
|
export declare function VirtualProperty(propertyName: string): (target: any, methodName: string) => void;
|
|
19
15
|
export declare function Serialize(callback: (value: any) => any): PropertyDecorator;
|
|
20
16
|
export declare function GetterPrefix(prefix: string): (target: any, propertyKey: string) => void;
|
|
21
|
-
export declare function Id(): (target: any, propertyKey: string) => void;
|
|
@@ -8,10 +8,6 @@ export class Entity {
|
|
|
8
8
|
if (typeof value === 'function')
|
|
9
9
|
continue;
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
if (this.constructor.strategyId === propName) {
|
|
12
|
-
result[propName] = this[propName].getValue() || this[propName];
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
11
|
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
16
12
|
value = propertiesConfigs[propName].serialize(value);
|
|
17
13
|
}
|
|
@@ -30,10 +26,6 @@ export class Entity {
|
|
|
30
26
|
if (typeof value === 'function')
|
|
31
27
|
continue;
|
|
32
28
|
// @ts-ignore
|
|
33
|
-
if (this.constructor.strategyId === propName) {
|
|
34
|
-
result[propName] = this[propName].getValue();
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
29
|
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
38
30
|
value = await propertiesConfigs[propName].serialize(value);
|
|
39
31
|
}
|
|
@@ -55,10 +47,6 @@ export class Entity {
|
|
|
55
47
|
if (typeof this[propName] === 'function')
|
|
56
48
|
continue;
|
|
57
49
|
// @ts-ignore
|
|
58
|
-
if (this.constructor.strategyId === propName) {
|
|
59
|
-
result[propName] = this[propName].getValue();
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
50
|
let value = this[propName];
|
|
63
51
|
if (serialize && propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
64
52
|
value = propertiesConfigs[propName].serialize(value);
|
|
@@ -86,10 +74,6 @@ export class Entity {
|
|
|
86
74
|
if (propertiesConfigs && propertiesConfigs[propName]?.restrict)
|
|
87
75
|
continue;
|
|
88
76
|
// @ts-ignore
|
|
89
|
-
if (this.constructor.strategyId === propName) {
|
|
90
|
-
result[propName] = this[propName].getValue();
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
77
|
let value = this[propName];
|
|
94
78
|
if (serialize && propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
95
79
|
value = await propertiesConfigs[propName].serialize(value);
|
|
@@ -106,20 +90,9 @@ export class Entity {
|
|
|
106
90
|
return result;
|
|
107
91
|
}
|
|
108
92
|
generateGetters() {
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
if (this.constructor.strategyId) {
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
if (!this[`get${this.constructor.strategyId[0].toUpperCase()}${this.constructor.strategyId.slice(1)}`]) {
|
|
113
|
-
// @ts-ignore
|
|
114
|
-
this[`get${this.constructor.strategyId[0].toUpperCase()}${this.constructor.strategyId.slice(1)}`] = () => this[this.constructor.strategyId].getValue();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
93
|
for (const property of Object.keys(this)) {
|
|
118
94
|
if (typeof this[property] === 'function')
|
|
119
95
|
continue;
|
|
120
|
-
// @ts-ignore
|
|
121
|
-
if (this.constructor.strategyId === property)
|
|
122
|
-
continue;
|
|
123
96
|
let prefixName = null;
|
|
124
97
|
// @ts-ignore
|
|
125
98
|
if (this.constructor.propertiesConfigs && this.constructor.propertiesConfigs[property] && this.constructor.propertiesConfigs[property].prefix) {
|
|
@@ -139,12 +112,6 @@ export class Entity {
|
|
|
139
112
|
}
|
|
140
113
|
}
|
|
141
114
|
}
|
|
142
|
-
constructor() {
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
if (!this.constructor?.strategyId) {
|
|
145
|
-
throw new Error('StrategyId must to be implement.');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
115
|
}
|
|
149
116
|
export function Restrict() {
|
|
150
117
|
return function (target, propertyKey) {
|
|
@@ -171,11 +138,6 @@ export function GetterPrefix(prefix) {
|
|
|
171
138
|
target.constructor.propertiesConfigs[propertyKey].prefix = prefix;
|
|
172
139
|
};
|
|
173
140
|
}
|
|
174
|
-
export function Id() {
|
|
175
|
-
return function (target, propertyKey) {
|
|
176
|
-
target.constructor.strategyId = propertyKey;
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
141
|
const loadPropertiesConfig = (target, propertyKey) => {
|
|
180
142
|
if (!target.constructor.propertiesConfigs) {
|
|
181
143
|
target.constructor.propertiesConfigs = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, type Middleware, type Input, type Tracer, type TracerData } from './controller';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Entity, Restrict, VirtualProperty, Serialize, GetterPrefix } from './entity';
|
|
3
3
|
import { DecorateUseCase, UseCase } from './usecase';
|
|
4
4
|
import { Storage, type StorageGateway } from './services';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, DecorateUseCase, UseCase, Storage, Entity, Restrict, VirtualProperty, Serialize, GetterPrefix,
|
|
6
|
-
export type { Middleware, Input, StorageGateway, Tracer, TracerData
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, DecorateUseCase, UseCase, Storage, Entity, Restrict, VirtualProperty, Serialize, GetterPrefix, };
|
|
6
|
+
export type { Middleware, Input, StorageGateway, Tracer, TracerData };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing } from './controller';
|
|
2
|
-
import {
|
|
2
|
+
import { Restrict, VirtualProperty, Serialize, GetterPrefix } from './entity';
|
|
3
3
|
import { DecorateUseCase, UseCase } from './usecase';
|
|
4
4
|
import { Storage } from './services';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, DecorateUseCase, UseCase, Storage,
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, DecorateUseCase, UseCase, Storage, Restrict, VirtualProperty, Serialize, GetterPrefix, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Post, Get, Put, Delete, Patch, Controller, Input, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData,
|
|
1
|
+
import { Post, Get, Put, Delete, Patch, Controller, Input, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Serialize, UseCase, DecorateUseCase, Storage, StorageGateway } from "./application";
|
|
2
2
|
import { Inject } from './infra/di/registry';
|
|
3
3
|
import { Dede, type Options, Register } from './dede';
|
|
4
4
|
import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError } from './http/errors/server';
|
|
5
5
|
import type { RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryExistsBy, RepositoryRestore, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination } from './protocols/repository';
|
|
6
|
-
export { Controller, Post, Get, Put, Delete, Patch, Input, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData,
|
|
6
|
+
export { Controller, Post, Get, Put, Delete, Patch, Input, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Serialize, UseCase, DecorateUseCase, Storage, StorageGateway, Inject, Dede, Options, Register, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
// controller
|
|
3
|
-
Post, Get, Put, Delete, Patch, Controller, UseMiddleware, UseMiddlewares, Tracing,
|
|
3
|
+
Post, Get, Put, Delete, Patch, Controller, UseMiddleware, UseMiddlewares, Tracing, Restrict, VirtualProperty, GetterPrefix, Serialize,
|
|
4
4
|
// entity
|
|
5
5
|
// usecase
|
|
6
6
|
UseCase, DecorateUseCase,
|
|
@@ -10,4 +10,4 @@ Storage } from "./application";
|
|
|
10
10
|
import { Inject } from './infra/di/registry';
|
|
11
11
|
import { Dede } from './dede';
|
|
12
12
|
import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError } from './http/errors/server';
|
|
13
|
-
export { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing,
|
|
13
|
+
export { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Restrict, VirtualProperty, GetterPrefix, Serialize, UseCase, DecorateUseCase, Storage, Inject, Dede, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError };
|