@punks/backend-entity-manager 0.0.399 → 0.0.401

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.
@@ -18,6 +18,7 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
18
18
  all(): Promise<TEntity[]>;
19
19
  count(condition: FindManyOptions<TEntity>): Promise<number>;
20
20
  find(condition: FindManyOptions<TEntity>): Promise<TEntity[]>;
21
+ findOne(condition: FindManyOptions<TEntity>): Promise<TEntity>;
21
22
  findById(id: TEntityId[]): Promise<TEntity[]>;
22
23
  delete(id: TEntityId): Promise<void>;
23
24
  deleteBy(condition: DeleteCriteria<TEntity>): Promise<IEntitiesDeleteResult>;
@@ -1,5 +1,4 @@
1
1
  export type PipelineTemplateProps = {
2
2
  name: string;
3
- description?: string;
4
3
  };
5
4
  export declare const WpPipeline: (name: string, props?: Omit<PipelineTemplateProps, "name">) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
package/dist/esm/index.js CHANGED
@@ -1070,7 +1070,7 @@ class EntityUpdateCommand {
1070
1070
  }
1071
1071
  const authorizationResult = await authorization.canUpdate(currentEntity, context);
1072
1072
  if (!authorizationResult.isAuthorized)
1073
- throw new EntityOperationUnauthorizedException(EntityOperationType.Create, this.services.getEntityName(), currentEntity);
1073
+ throw new EntityOperationUnauthorizedException(EntityOperationType.Update, this.services.getEntityName(), currentEntity);
1074
1074
  }
1075
1075
  async getContext() {
1076
1076
  const authorization = this.services.resolveAuthorizationMiddleware();
@@ -4035,6 +4035,11 @@ class TypeOrmRepository {
4035
4035
  this.logger.debug("Finding entities by condition", { condition });
4036
4036
  return await this.innerRepository.find(condition);
4037
4037
  }
4038
+ async findOne(condition) {
4039
+ this.logger.debug("Finding entity by condition", { condition });
4040
+ const items = await this.innerRepository.find(condition);
4041
+ return items[0];
4042
+ }
4038
4043
  async findById(id) {
4039
4044
  this.logger.debug("Finding entities by id", { id });
4040
4045
  return await this.innerRepository.findBy({