framework-do-dede 6.0.0 → 6.0.1
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/README.md +3 -6
- package/dist/application/index.d.ts +2 -2
- package/dist/application/index.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/infra/model/model.d.ts +2 -3
- package/dist/infra/model/model.js +0 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -346,12 +346,9 @@ class CreatePhotoUseCase extends UseCase<void, void> {
|
|
|
346
346
|
Entities sao dominio puro. `Model` vive na borda e faz o mapeamento banco <-> model, alem de converter `Entity` <-> `Model`. Repositorios trabalham com `Model`, nao com `Entity`.
|
|
347
347
|
|
|
348
348
|
```ts
|
|
349
|
-
import { Entity, Model,
|
|
349
|
+
import { Entity, Model, column } from './src';
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
@model<UserTable>('users')
|
|
354
|
-
class UserModel extends Model<UserTable, User> {
|
|
351
|
+
class UserModel extends Model<User> {
|
|
355
352
|
@column('id')
|
|
356
353
|
id!: string;
|
|
357
354
|
|
|
@@ -398,7 +395,7 @@ return Optional.ofNullable(model);
|
|
|
398
395
|
|
|
399
396
|
Regras principais:
|
|
400
397
|
|
|
401
|
-
- `Model` guarda metadados de coluna (via `@column`)
|
|
398
|
+
- `Model` guarda metadados de coluna (via `@column`)
|
|
402
399
|
- `fromModel` aplica o mapeamento coluna -> propriedade e ignora `null/undefined` (retorna o proprio model)
|
|
403
400
|
- `fromEntity` / `toEntity` fazem a conversao entity <-> model
|
|
404
401
|
- `Entity` recebe o `Model` no construtor (acoplamento forte na borda)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
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
|
-
import { Model,
|
|
3
|
+
import { 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, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
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, 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
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
|
-
import { Model,
|
|
3
|
+
import { 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, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
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, column, };
|
|
6
6
|
export { Storage, CacheGateway, EventDispatcher } from './services';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
1
|
+
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, 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';
|
|
@@ -8,5 +8,5 @@ import type { ValidatorDefinition } from './interface/validation/validator';
|
|
|
8
8
|
import type { StorageGateway, Event, EventPayload } from './application';
|
|
9
9
|
import { RepositoryModel } from './protocols/model';
|
|
10
10
|
import type { RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryExistsBy, RepositoryRestore, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination } from './protocols/repository';
|
|
11
|
-
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
11
|
+
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, 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, Optional, RepositoryModel, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
|
12
12
|
export type { ValidatorDefinition, StorageGateway, Event, EventPayload };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Post, Get, Put, Delete, Patch, Controller, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing,
|
|
4
4
|
// controller
|
|
5
5
|
// entity
|
|
6
|
-
Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
6
|
+
Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column,
|
|
7
7
|
// entity
|
|
8
8
|
// usecase
|
|
9
9
|
UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter,
|
|
@@ -18,4 +18,4 @@ import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, Unprocessable
|
|
|
18
18
|
import { AppError } from './domain/errors/app-error';
|
|
19
19
|
import { Optional } from './domain/optional';
|
|
20
20
|
import { RepositoryModel } from './protocols/model';
|
|
21
|
-
export { Controller, Post, Get, Put, Delete, Patch, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model,
|
|
21
|
+
export { Controller, Post, Get, Put, Delete, Patch, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, 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, Optional, RepositoryModel };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Entity } from "../../infra/serialization/entity";
|
|
1
2
|
import { RepositoryModel } from "../../protocols/model";
|
|
2
3
|
export type ColumnDefinition = {
|
|
3
4
|
column: string;
|
|
4
5
|
property: string;
|
|
5
6
|
};
|
|
6
|
-
export declare abstract class Model<
|
|
7
|
-
table: TTable;
|
|
7
|
+
export declare abstract class Model<TEntity extends Entity = Entity> extends RepositoryModel<TEntity> {
|
|
8
8
|
columns: ColumnDefinition[];
|
|
9
9
|
[property: string]: any;
|
|
10
10
|
fromModel(input: Record<string, any> | null | undefined): this;
|
|
@@ -12,5 +12,4 @@ export declare abstract class Model<TTable = string, TEntity = any> extends Repo
|
|
|
12
12
|
toModel(): Record<string, any>;
|
|
13
13
|
abstract toEntity(): TEntity;
|
|
14
14
|
}
|
|
15
|
-
export declare function model<TTable>(table: TTable): (target: any) => void;
|
|
16
15
|
export declare function column(columnName: string): (target: any, propertyKey: string) => void;
|
|
@@ -32,11 +32,6 @@ export class Model extends RepositoryModel {
|
|
|
32
32
|
return record;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export function model(table) {
|
|
36
|
-
return function (target) {
|
|
37
|
-
target.prototype.table = table;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
35
|
export function column(columnName) {
|
|
41
36
|
return function (target, propertyKey) {
|
|
42
37
|
target.columns = target.columns || [];
|