@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.
package/dist/cjs/index.js CHANGED
@@ -105,13 +105,19 @@ class EntityOperationUnauthorizedException extends EntityManagerUnauthorizedExce
105
105
  }
106
106
  }
107
107
  class EntityNotFoundException extends EntityManagerException {
108
- constructor(id) {
109
- super(id ? `Entity with id ${id} not found` : "Entity not found");
110
- this.entityId = id;
108
+ constructor(entityData) {
109
+ super(entityData
110
+ ? `Entity ${entityData.type} with id ${entityData.id} not found`
111
+ : "Entity not found");
112
+ this.entityId = entityData.id;
113
+ this.entityType = entityData.type;
111
114
  }
112
115
  getEntityId() {
113
116
  return this.entityId;
114
117
  }
118
+ getEntityType() {
119
+ return this.entityType;
120
+ }
115
121
  }
116
122
  class MultipleEntitiesFoundException extends EntityManagerException {
117
123
  constructor() {
@@ -687,7 +693,10 @@ class EntityDeleteCommand {
687
693
  }
688
694
  const entity = await this.services.resolveRepository().get(id);
689
695
  if (entity == null) {
690
- throw new EntityNotFoundException(id);
696
+ throw new EntityNotFoundException({
697
+ id,
698
+ type: this.services.getEntityName(),
699
+ });
691
700
  }
692
701
  const contextService = this.services.resolveAuthenticationContextProvider();
693
702
  const context = await contextService?.getContext();
@@ -912,7 +921,10 @@ class EntityUpdateCommand {
912
921
  }
913
922
  const currentEntity = await this.services.resolveRepository().get(id);
914
923
  if (currentEntity == null) {
915
- throw new EntityNotFoundException();
924
+ throw new EntityNotFoundException({
925
+ id,
926
+ type: this.services.getEntityName(),
927
+ });
916
928
  }
917
929
  const context = await this.getContext();
918
930
  if (!context) {