@punks/backend-entity-manager 0.0.26 → 0.0.28

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.
@@ -3,6 +3,7 @@ export interface IAuthorizationResult {
3
3
  isAuthorized: boolean;
4
4
  }
5
5
  export interface IEntityAuthorizationMiddleware<TEntity, TAuthenticationContext extends IAuthenticationContext<TUserContext>, TUserContext> {
6
+ canSearch(context: TAuthenticationContext): Promise<IAuthorizationResult>;
6
7
  canRead(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
7
8
  canCreate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
8
9
  canUpdate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
@@ -5,13 +5,17 @@ export declare enum EntityOperationType {
5
5
  Create = 0,
6
6
  Update = 1,
7
7
  Delete = 2,
8
- Read = 3
8
+ Read = 3,
9
+ Search = 4
9
10
  }
10
- export declare class EntityOperationUnauthorizedException<TEntity> extends EntityManagerException {
11
- private readonly entity;
11
+ export declare abstract class EntityManagerUnauthorizedException extends EntityManagerException {
12
+ constructor(message: string);
13
+ }
14
+ export declare class EntityOperationUnauthorizedException<TEntity> extends EntityManagerUnauthorizedException {
12
15
  private readonly operation;
13
- constructor(operationType: EntityOperationType, entity: Partial<TEntity>, entityName: string);
14
- get getEntity(): Partial<TEntity>;
16
+ private readonly entity?;
17
+ constructor(operationType: EntityOperationType, entityName: string, entity?: Partial<TEntity>);
18
+ get getEntity(): Partial<TEntity> | undefined;
15
19
  get getOperation(): EntityOperationType;
16
20
  }
17
21
  export declare class EntityNotFoundException<TEntityId> extends EntityManagerException {
@@ -3,6 +3,7 @@ import { NestEntityAuthorizationMiddleware } from "../../../../authentication";
3
3
  import { AppAuthContext, AppUserContext } from "../../authentication";
4
4
  import { FooEntity } from "./entity";
5
5
  export declare class FooAuthMiddleware extends NestEntityAuthorizationMiddleware<FooEntity, AppAuthContext, AppUserContext> {
6
+ canSearch(context: AppAuthContext): Promise<IAuthorizationResult>;
6
7
  canRead(entity: Partial<FooEntity>, context: AppAuthContext): Promise<IAuthorizationResult>;
7
8
  canCreate(entity: Partial<FooEntity>, context: AppAuthContext): Promise<IAuthorizationResult>;
8
9
  canUpdate(entity: Partial<FooEntity>, context: AppAuthContext): Promise<IAuthorizationResult>;
@@ -1,5 +1,6 @@
1
1
  import { IAuthenticationContext, IAuthorizationResult, IEntityAuthorizationMiddleware } from "../../../abstractions";
2
2
  export declare abstract class NestEntityAuthorizationMiddleware<TEntity, TAuthenticationContext extends IAuthenticationContext<TUserContext>, TUserContext> implements IEntityAuthorizationMiddleware<TEntity, TAuthenticationContext, TUserContext> {
3
+ abstract canSearch(context: TAuthenticationContext): Promise<IAuthorizationResult>;
3
4
  abstract canRead(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
4
5
  abstract canCreate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
5
6
  abstract canUpdate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
@@ -9,4 +9,5 @@ export declare class EntitiesSearchQuery<TEntity, TEntityId, TEntitySearchParame
9
9
  execute(request: TEntitySearchParameters): Promise<IEntitiesSearchResults<TEntitySearchParameters, TEntity, TSorting, TCursor, TFacets>>;
10
10
  private getContext;
11
11
  private filterAllowedEntities;
12
+ private authorizeSearch;
12
13
  }
package/dist/index.d.ts CHANGED
@@ -118,6 +118,7 @@ interface IAuthorizationResult {
118
118
  isAuthorized: boolean;
119
119
  }
120
120
  interface IEntityAuthorizationMiddleware<TEntity, TAuthenticationContext extends IAuthenticationContext<TUserContext>, TUserContext> {
121
+ canSearch(context: TAuthenticationContext): Promise<IAuthorizationResult>;
121
122
  canRead(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
122
123
  canCreate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
123
124
  canUpdate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
@@ -420,13 +421,17 @@ declare enum EntityOperationType {
420
421
  Create = 0,
421
422
  Update = 1,
422
423
  Delete = 2,
423
- Read = 3
424
+ Read = 3,
425
+ Search = 4
424
426
  }
425
- declare class EntityOperationUnauthorizedException<TEntity> extends EntityManagerException {
426
- private readonly entity;
427
+ declare abstract class EntityManagerUnauthorizedException extends EntityManagerException {
428
+ constructor(message: string);
429
+ }
430
+ declare class EntityOperationUnauthorizedException<TEntity> extends EntityManagerUnauthorizedException {
427
431
  private readonly operation;
428
- constructor(operationType: EntityOperationType, entity: Partial<TEntity>, entityName: string);
429
- get getEntity(): Partial<TEntity>;
432
+ private readonly entity?;
433
+ constructor(operationType: EntityOperationType, entityName: string, entity?: Partial<TEntity>);
434
+ get getEntity(): Partial<TEntity> | undefined;
430
435
  get getOperation(): EntityOperationType;
431
436
  }
432
437
  declare class EntityNotFoundException<TEntityId> extends EntityManagerException {
@@ -456,6 +461,7 @@ interface ISearchResultsPaging<TCursor> {
456
461
  }
457
462
 
458
463
  declare abstract class NestEntityAuthorizationMiddleware<TEntity, TAuthenticationContext extends IAuthenticationContext<TUserContext>, TUserContext> implements IEntityAuthorizationMiddleware<TEntity, TAuthenticationContext, TUserContext> {
464
+ abstract canSearch(context: TAuthenticationContext): Promise<IAuthorizationResult>;
459
465
  abstract canRead(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
460
466
  abstract canCreate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
461
467
  abstract canUpdate(entity: Partial<TEntity>, context: TAuthenticationContext): Promise<IAuthorizationResult>;
@@ -755,4 +761,4 @@ declare class EntityManagerModule {
755
761
 
756
762
  declare const newUuid: () => string;
757
763
 
758
- export { AppExceptionsFilterBase, AppSessionMiddleware, AppSessionService, AuthenticationModule, EntityActionsProps, EntityAdapterProps, EntityAuthMiddlewareProps, EntityConnectorProps, EntityConverterProps, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerProps, EntityManagerRegistry, EntityManagerSymbols, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntityProps, EntityQueryBuilderProps, EntityRepositoryProps, FilterExpression, IAuthenticationContext, IAuthenticationContextProvider, IAuthorizationResult, IEntitiesQueryBuilder, IEntitiesSearchAction, IEntitiesSearchQuery, IEntitiesSearchResults, IEntitiesSearchResultsPaging, IEntityActions, IEntityAdapter, IEntityAuthorizationMiddleware, IEntityConverter, IEntityCreateAction, IEntityCreateCommand, IEntityDeleteAction, IEntityDeleteCommand, IEntityEventsManager, IEntityGetAction, IEntityGetQuery, IEntityManager, IEntityManagerServiceCollection, IEntityManagerServiceRoot, IEntityMapper, IEntityReplicaDeleteManager, IEntityReplicaSyncManager, IEntityRepository, IEntitySearchParameters, IEntitySearchResults, IEntityUpdateAction, IEntityUpdateCommand, IEntityUpsertAction, IEntityUpsertCommand, IReplicasConfiguration, ISearchFilters, ISearchOptions, ISearchRequestPaging, ISearchResultsPaging, ISearchSorting, ISearchSortingField, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestTypeOrmQueryBuilder, NestTypeOrmRepository, QueryBuilderBase, ReplicaConfiguration, ReplicaOptions, ReplicationMode, RuntimeErrorInformation, SortDirection, SortingType, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, newUuid };
764
+ export { AppExceptionsFilterBase, AppSessionMiddleware, AppSessionService, AuthenticationModule, EntityActionsProps, EntityAdapterProps, EntityAuthMiddlewareProps, EntityConnectorProps, EntityConverterProps, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerProps, EntityManagerRegistry, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntityProps, EntityQueryBuilderProps, EntityRepositoryProps, FilterExpression, IAuthenticationContext, IAuthenticationContextProvider, IAuthorizationResult, IEntitiesQueryBuilder, IEntitiesSearchAction, IEntitiesSearchQuery, IEntitiesSearchResults, IEntitiesSearchResultsPaging, IEntityActions, IEntityAdapter, IEntityAuthorizationMiddleware, IEntityConverter, IEntityCreateAction, IEntityCreateCommand, IEntityDeleteAction, IEntityDeleteCommand, IEntityEventsManager, IEntityGetAction, IEntityGetQuery, IEntityManager, IEntityManagerServiceCollection, IEntityManagerServiceRoot, IEntityMapper, IEntityReplicaDeleteManager, IEntityReplicaSyncManager, IEntityRepository, IEntitySearchParameters, IEntitySearchResults, IEntityUpdateAction, IEntityUpdateCommand, IEntityUpsertAction, IEntityUpsertCommand, IReplicasConfiguration, ISearchFilters, ISearchOptions, ISearchRequestPaging, ISearchResultsPaging, ISearchSorting, ISearchSortingField, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestTypeOrmQueryBuilder, NestTypeOrmRepository, QueryBuilderBase, ReplicaConfiguration, ReplicaOptions, ReplicationMode, RuntimeErrorInformation, SortDirection, SortingType, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, newUuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punks/backend-entity-manager",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -62,7 +62,15 @@
62
62
  "typescript": "^5.1.6"
63
63
  },
64
64
  "peerDependencies": {
65
- "@punks/backend-core": "0.0.12"
65
+ "@nestjs/common": "^10.1.0",
66
+ "@nestjs/core": "^10.1.0",
67
+ "@nestjs/event-emitter": "^2.0.0",
68
+ "@nestjs/platform-express": "^10.1.0",
69
+ "@nestjs/swagger": "^7.1.2",
70
+ "@nestjs/testing": "^10.1.0",
71
+ "@nestjs/typeorm": "^10.0.0",
72
+ "@punks/backend-core": "0.0.12",
73
+ "typeorm": "^0.3.17"
66
74
  },
67
75
  "dependencies": {},
68
76
  "jest": {