@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.
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/operations.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/services/operations/operation-lock.repository.d.ts +3 -3
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/operations.d.ts +3 -3
- package/dist/esm/types/platforms/nest/services/operations/operation-lock.repository.d.ts +3 -3
- package/dist/index.d.ts +6 -6
- package/package.json +1 -4
package/dist/cjs/index.js
CHANGED
|
@@ -21941,14 +21941,14 @@ exports.OperationLockService = OperationLockService_1 = class OperationLockServi
|
|
|
21941
21941
|
this.operations = operations;
|
|
21942
21942
|
this.logger = backendCore.Log.getLogger(OperationLockService_1.name);
|
|
21943
21943
|
this.executeExclusive = async (input) => {
|
|
21944
|
-
const lock = await this.operations.
|
|
21944
|
+
const lock = await this.operations.acquireLock({
|
|
21945
21945
|
lockUid: input.lockUid,
|
|
21946
21946
|
requestedBy: input.requestedBy,
|
|
21947
21947
|
});
|
|
21948
21948
|
if (!lock.available &&
|
|
21949
21949
|
input.lockTimeout &&
|
|
21950
21950
|
this.isLockExpired(lock.lockItem, new Date(), input.lockTimeout)) {
|
|
21951
|
-
await this.operations.
|
|
21951
|
+
await this.operations.releaseLock({
|
|
21952
21952
|
lockUid: input.lockUid,
|
|
21953
21953
|
});
|
|
21954
21954
|
return await this.executeExclusive(input);
|
|
@@ -21966,7 +21966,7 @@ exports.OperationLockService = OperationLockService_1 = class OperationLockServi
|
|
|
21966
21966
|
};
|
|
21967
21967
|
}
|
|
21968
21968
|
finally {
|
|
21969
|
-
await this.operations.
|
|
21969
|
+
await this.operations.releaseLock({
|
|
21970
21970
|
lockUid: input.lockUid,
|
|
21971
21971
|
});
|
|
21972
21972
|
}
|
|
@@ -21990,12 +21990,12 @@ exports.TypeormOperationLockRepository = class TypeormOperationLockRepository {
|
|
|
21990
21990
|
this.repo = repo;
|
|
21991
21991
|
this.entityClass = entityClass;
|
|
21992
21992
|
// todo: fix typing (and remove as any)
|
|
21993
|
-
this.
|
|
21993
|
+
this.getLock = async (lockUid) => (await this.repo.findOne({
|
|
21994
21994
|
where: {
|
|
21995
21995
|
uid: lockUid,
|
|
21996
21996
|
},
|
|
21997
21997
|
})) ?? undefined;
|
|
21998
|
-
this.
|
|
21998
|
+
this.acquireLock = async (input) => {
|
|
21999
21999
|
return await this.repo.manager.transaction(async (manager) => {
|
|
22000
22000
|
const currentLock = await manager.findOne(this.entityClass, {
|
|
22001
22001
|
where: [
|
|
@@ -22022,7 +22022,7 @@ exports.TypeormOperationLockRepository = class TypeormOperationLockRepository {
|
|
|
22022
22022
|
};
|
|
22023
22023
|
});
|
|
22024
22024
|
};
|
|
22025
|
-
this.
|
|
22025
|
+
this.releaseLock = async (input) => {
|
|
22026
22026
|
const result = await this.repo.delete({
|
|
22027
22027
|
uid: input.lockUid,
|
|
22028
22028
|
});
|