@punks/backend-entity-manager 0.0.272 → 0.0.274
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 +9 -31
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/operations.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/extensions/jobs/module.d.ts +2 -5
- package/dist/cjs/types/platforms/nest/module.d.ts +1 -4
- package/dist/cjs/types/platforms/nest/services/operations/operation-lock.repository.d.ts +3 -3
- package/dist/esm/index.js +9 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/operations.d.ts +3 -3
- package/dist/esm/types/platforms/nest/extensions/jobs/module.d.ts +2 -5
- package/dist/esm/types/platforms/nest/module.d.ts +1 -4
- package/dist/esm/types/platforms/nest/services/operations/operation-lock.repository.d.ts +3 -3
- package/dist/index.d.ts +7 -13
- 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
|
});
|
|
@@ -23628,7 +23628,6 @@ const getIoCContext = () => {
|
|
|
23628
23628
|
return _context;
|
|
23629
23629
|
};
|
|
23630
23630
|
|
|
23631
|
-
var EntityManagerModule_1;
|
|
23632
23631
|
const ModuleData$9 = {
|
|
23633
23632
|
imports: [exports.CustomDiscoveryModule, eventEmitter.EventEmitterModule],
|
|
23634
23633
|
providers: [
|
|
@@ -23640,7 +23639,7 @@ const ModuleData$9 = {
|
|
|
23640
23639
|
],
|
|
23641
23640
|
exports: [exports.EntityManagerRegistry, ...Services$1],
|
|
23642
23641
|
};
|
|
23643
|
-
exports.EntityManagerModule =
|
|
23642
|
+
exports.EntityManagerModule = class EntityManagerModule {
|
|
23644
23643
|
constructor(registry) {
|
|
23645
23644
|
this.registry = registry;
|
|
23646
23645
|
}
|
|
@@ -23649,21 +23648,8 @@ exports.EntityManagerModule = EntityManagerModule_1 = class EntityManagerModule
|
|
|
23649
23648
|
registry: this.registry,
|
|
23650
23649
|
});
|
|
23651
23650
|
}
|
|
23652
|
-
static forRoot(providers) {
|
|
23653
|
-
return {
|
|
23654
|
-
module: EntityManagerModule_1,
|
|
23655
|
-
...ModuleData$9,
|
|
23656
|
-
providers: [
|
|
23657
|
-
...ModuleData$9.providers,
|
|
23658
|
-
{
|
|
23659
|
-
provide: getEntityManagerProviderToken("OperationsLockRepository"),
|
|
23660
|
-
useClass: providers.operationsLockRepository,
|
|
23661
|
-
},
|
|
23662
|
-
],
|
|
23663
|
-
};
|
|
23664
|
-
}
|
|
23665
23651
|
};
|
|
23666
|
-
exports.EntityManagerModule =
|
|
23652
|
+
exports.EntityManagerModule = __decorate([
|
|
23667
23653
|
common.Module({
|
|
23668
23654
|
imports: ModuleData$9.imports,
|
|
23669
23655
|
providers: ModuleData$9.providers,
|
|
@@ -34088,7 +34074,7 @@ exports.JobsModule = JobsModule_1 = class JobsModule {
|
|
|
34088
34074
|
this.jobsScheduler.register();
|
|
34089
34075
|
await this.jobsProviderFactory.initialize();
|
|
34090
34076
|
}
|
|
34091
|
-
static forRoot(input
|
|
34077
|
+
static forRoot(input) {
|
|
34092
34078
|
return {
|
|
34093
34079
|
module: JobsModule_1,
|
|
34094
34080
|
...ModuleData$7,
|
|
@@ -34098,14 +34084,6 @@ exports.JobsModule = JobsModule_1 = class JobsModule {
|
|
|
34098
34084
|
provide: getEntityManagerProviderToken("JobsModuleSettings"),
|
|
34099
34085
|
useValue: input,
|
|
34100
34086
|
},
|
|
34101
|
-
{
|
|
34102
|
-
provide: getEntityManagerProviderToken("JobInstancesRepository"),
|
|
34103
|
-
useClass: providers.jobInstancesRepository,
|
|
34104
|
-
},
|
|
34105
|
-
{
|
|
34106
|
-
provide: getEntityManagerProviderToken("JobDefinitionsRepository"),
|
|
34107
|
-
useClass: providers.jobDefinitionsRepository,
|
|
34108
|
-
},
|
|
34109
34087
|
],
|
|
34110
34088
|
};
|
|
34111
34089
|
}
|