framework-do-dede 0.0.24 → 0.0.26

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Dede, Register as DedeRegister, Options as DedeOptions } from './dede';
2
2
  import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Restrict } from './decorators';
3
3
  import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
4
- import { Validation, HttpMiddleware, UseCase } from './protocols';
4
+ import { Validation, HttpMiddleware, UseCase, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository } from './protocols';
5
5
  import { Entity } from './domain/Entity';
6
6
  declare class RequestData {
7
7
  headers: any;
@@ -12,4 +12,4 @@ declare class RequestData {
12
12
  declare class UseCaseHandler {
13
13
  static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
14
14
  }
15
- export { UseCase, HttpMiddleware, Validation, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Entity, Restrict };
15
+ export { UseCase, HttpMiddleware, Validation, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Entity, Restrict };
package/dist/index.js CHANGED
@@ -16,10 +16,10 @@ class RequestData {
16
16
  class UseCaseHandler {
17
17
  static load(useCaseClass, request) {
18
18
  const instance = Registry.classLoader(useCaseClass);
19
- const auth = Reflect.getMetadata("auth", useCaseClass);
19
+ const authProperty = Reflect.getMetadata("auth", useCaseClass.prototype.constructor);
20
20
  const context = request;
21
- if (auth && context?.middlewareData) {
22
- instance[auth] = context.middlewareData[auth];
21
+ if (authProperty && context?.middlewareData?.[authProperty]) {
22
+ instance[authProperty] = { ...context.middlewareData[authProperty] };
23
23
  }
24
24
  return instance;
25
25
  }
@@ -0,0 +1,4 @@
1
+ import { Entity } from "framework-do-dede";
2
+ export interface CreateRepository<T extends Entity> {
3
+ create(input: T): Promise<void>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Entity } from "framework-do-dede";
2
+ export interface DeleteRepository<T extends Entity> {
3
+ delete(input: T): Promise<void>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Entity } from "framework-do-dede";
2
+ export interface RestoreRepository<T extends Entity> {
3
+ restore(id: string | number): Promise<T | undefined>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Entity } from "framework-do-dede";
2
+ export interface UpdateRepository {
3
+ update(input: Entity): Promise<void>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,8 @@
1
1
  import type { HttpMiddleware } from './HttpMiddleware';
2
2
  import type { UseCase } from './UseCase';
3
3
  import type { Validation } from './Validation';
4
- export type { HttpMiddleware, UseCase, Validation };
4
+ import type { CreateRepository } from './CreateRepository';
5
+ import type { DeleteRepository } from './DeleteRepository';
6
+ import type { UpdateRepository } from './UpdateRepository';
7
+ import type { RestoreRepository } from './RestoreRepository';
8
+ export type { HttpMiddleware, UseCase, Validation, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework-do-dede",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",