@punks/backend-entity-manager 0.0.272 → 0.0.273

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.
@@ -17,7 +17,7 @@ export type LockReleaseInput = {
17
17
  export declare class LockNotFoundError extends Error {
18
18
  }
19
19
  export interface ILockRepository {
20
- acquire(input: LockAcquireInput): Promise<LockAcquireResult>;
21
- release(input: LockReleaseInput): Promise<void>;
22
- get(lockUid: string): Promise<LockItem | undefined>;
20
+ acquireLock(input: LockAcquireInput): Promise<LockAcquireResult>;
21
+ releaseLock(input: LockReleaseInput): Promise<void>;
22
+ getLock(lockUid: string): Promise<LockItem | undefined>;
23
23
  }
@@ -9,8 +9,8 @@ export declare class TypeormOperationLockRepository<TLockEntry extends LockItemC
9
9
  private readonly repo;
10
10
  private readonly entityClass;
11
11
  constructor(repo: Repository<TLockEntry>, entityClass: EntityTarget<TLockEntry>);
12
- get: (lockUid: string) => Promise<TLockEntry | undefined>;
13
- acquire: (input: LockAcquireInput) => Promise<LockAcquireResult>;
14
- release: (input: LockReleaseInput) => Promise<void>;
12
+ getLock: (lockUid: string) => Promise<TLockEntry | undefined>;
13
+ acquireLock: (input: LockAcquireInput) => Promise<LockAcquireResult>;
14
+ releaseLock: (input: LockReleaseInput) => Promise<void>;
15
15
  }
16
16
  export {};
package/dist/esm/index.js CHANGED
@@ -21926,14 +21926,14 @@ let OperationLockService = OperationLockService_1 = class OperationLockService {
21926
21926
  this.operations = operations;
21927
21927
  this.logger = Log.getLogger(OperationLockService_1.name);
21928
21928
  this.executeExclusive = async (input) => {
21929
- const lock = await this.operations.acquire({
21929
+ const lock = await this.operations.acquireLock({
21930
21930
  lockUid: input.lockUid,
21931
21931
  requestedBy: input.requestedBy,
21932
21932
  });
21933
21933
  if (!lock.available &&
21934
21934
  input.lockTimeout &&
21935
21935
  this.isLockExpired(lock.lockItem, new Date(), input.lockTimeout)) {
21936
- await this.operations.release({
21936
+ await this.operations.releaseLock({
21937
21937
  lockUid: input.lockUid,
21938
21938
  });
21939
21939
  return await this.executeExclusive(input);
@@ -21951,7 +21951,7 @@ let OperationLockService = OperationLockService_1 = class OperationLockService {
21951
21951
  };
21952
21952
  }
21953
21953
  finally {
21954
- await this.operations.release({
21954
+ await this.operations.releaseLock({
21955
21955
  lockUid: input.lockUid,
21956
21956
  });
21957
21957
  }
@@ -21975,12 +21975,12 @@ let TypeormOperationLockRepository = class TypeormOperationLockRepository {
21975
21975
  this.repo = repo;
21976
21976
  this.entityClass = entityClass;
21977
21977
  // todo: fix typing (and remove as any)
21978
- this.get = async (lockUid) => (await this.repo.findOne({
21978
+ this.getLock = async (lockUid) => (await this.repo.findOne({
21979
21979
  where: {
21980
21980
  uid: lockUid,
21981
21981
  },
21982
21982
  })) ?? undefined;
21983
- this.acquire = async (input) => {
21983
+ this.acquireLock = async (input) => {
21984
21984
  return await this.repo.manager.transaction(async (manager) => {
21985
21985
  const currentLock = await manager.findOne(this.entityClass, {
21986
21986
  where: [
@@ -22007,7 +22007,7 @@ let TypeormOperationLockRepository = class TypeormOperationLockRepository {
22007
22007
  };
22008
22008
  });
22009
22009
  };
22010
- this.release = async (input) => {
22010
+ this.releaseLock = async (input) => {
22011
22011
  const result = await this.repo.delete({
22012
22012
  uid: input.lockUid,
22013
22013
  });