@punks/backend-entity-manager 0.0.292 → 0.0.293

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.
@@ -22,8 +22,13 @@ export declare class EntityOperationUnauthorizedException<TEntity> extends Entit
22
22
  }
23
23
  export declare class EntityNotFoundException<TEntityId> extends EntityManagerException {
24
24
  private readonly entityId;
25
- constructor(id?: TEntityId);
25
+ private readonly entityType;
26
+ constructor(entityData: {
27
+ id: TEntityId;
28
+ type: string;
29
+ });
26
30
  getEntityId(): TEntityId | undefined;
31
+ getEntityType(): string | undefined;
27
32
  }
28
33
  export declare class MultipleEntitiesFoundException extends EntityManagerException {
29
34
  constructor();
package/dist/esm/index.js CHANGED
@@ -90,13 +90,19 @@ class EntityOperationUnauthorizedException extends EntityManagerUnauthorizedExce
90
90
  }
91
91
  }
92
92
  class EntityNotFoundException extends EntityManagerException {
93
- constructor(id) {
94
- super(id ? `Entity with id ${id} not found` : "Entity not found");
95
- this.entityId = id;
93
+ constructor(entityData) {
94
+ super(entityData
95
+ ? `Entity ${entityData.type} with id ${entityData.id} not found`
96
+ : "Entity not found");
97
+ this.entityId = entityData.id;
98
+ this.entityType = entityData.type;
96
99
  }
97
100
  getEntityId() {
98
101
  return this.entityId;
99
102
  }
103
+ getEntityType() {
104
+ return this.entityType;
105
+ }
100
106
  }
101
107
  class MultipleEntitiesFoundException extends EntityManagerException {
102
108
  constructor() {
@@ -672,7 +678,10 @@ class EntityDeleteCommand {
672
678
  }
673
679
  const entity = await this.services.resolveRepository().get(id);
674
680
  if (entity == null) {
675
- throw new EntityNotFoundException(id);
681
+ throw new EntityNotFoundException({
682
+ id,
683
+ type: this.services.getEntityName(),
684
+ });
676
685
  }
677
686
  const contextService = this.services.resolveAuthenticationContextProvider();
678
687
  const context = await contextService?.getContext();
@@ -897,7 +906,10 @@ class EntityUpdateCommand {
897
906
  }
898
907
  const currentEntity = await this.services.resolveRepository().get(id);
899
908
  if (currentEntity == null) {
900
- throw new EntityNotFoundException();
909
+ throw new EntityNotFoundException({
910
+ id,
911
+ type: this.services.getEntityName(),
912
+ });
901
913
  }
902
914
  const context = await this.getContext();
903
915
  if (!context) {