@punks/backend-entity-manager 0.0.270 → 0.0.272
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 +24 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/extensions/jobs/abstractions/repository.d.ts +8 -8
- package/dist/cjs/types/platforms/nest/module.d.ts +4 -1
- package/dist/esm/index.js +24 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/extensions/jobs/abstractions/repository.d.ts +8 -8
- package/dist/esm/types/platforms/nest/module.d.ts +4 -1
- package/dist/index.d.ts +11 -8
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -23628,6 +23628,7 @@ const getIoCContext = () => {
|
|
|
23628
23628
|
return _context;
|
|
23629
23629
|
};
|
|
23630
23630
|
|
|
23631
|
+
var EntityManagerModule_1;
|
|
23631
23632
|
const ModuleData$9 = {
|
|
23632
23633
|
imports: [exports.CustomDiscoveryModule, eventEmitter.EventEmitterModule],
|
|
23633
23634
|
providers: [
|
|
@@ -23639,7 +23640,7 @@ const ModuleData$9 = {
|
|
|
23639
23640
|
],
|
|
23640
23641
|
exports: [exports.EntityManagerRegistry, ...Services$1],
|
|
23641
23642
|
};
|
|
23642
|
-
exports.EntityManagerModule = class EntityManagerModule {
|
|
23643
|
+
exports.EntityManagerModule = EntityManagerModule_1 = class EntityManagerModule {
|
|
23643
23644
|
constructor(registry) {
|
|
23644
23645
|
this.registry = registry;
|
|
23645
23646
|
}
|
|
@@ -23648,8 +23649,21 @@ exports.EntityManagerModule = class EntityManagerModule {
|
|
|
23648
23649
|
registry: this.registry,
|
|
23649
23650
|
});
|
|
23650
23651
|
}
|
|
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
|
+
}
|
|
23651
23665
|
};
|
|
23652
|
-
exports.EntityManagerModule = __decorate([
|
|
23666
|
+
exports.EntityManagerModule = EntityManagerModule_1 = __decorate([
|
|
23653
23667
|
common.Module({
|
|
23654
23668
|
imports: ModuleData$9.imports,
|
|
23655
23669
|
providers: ModuleData$9.providers,
|
|
@@ -33687,7 +33701,7 @@ let JobsSchedulerTask = JobsSchedulerTask_1 = class JobsSchedulerTask {
|
|
|
33687
33701
|
}
|
|
33688
33702
|
async run() {
|
|
33689
33703
|
this.logger.info(`JobsSchedulerTask -> run start`);
|
|
33690
|
-
const jobs = await this.jobDefinitions.
|
|
33704
|
+
const jobs = await this.jobDefinitions.getAllDefinitions();
|
|
33691
33705
|
for (const job of jobs) {
|
|
33692
33706
|
await this.evaluateJob(job);
|
|
33693
33707
|
}
|
|
@@ -33762,7 +33776,7 @@ let JobsMonitorTask = JobsMonitorTask_1 = class JobsMonitorTask {
|
|
|
33762
33776
|
async monitorInstance(instance) {
|
|
33763
33777
|
try {
|
|
33764
33778
|
this.logger.info(`JobsMonitorTask -> evaluating job ${instance.id}`);
|
|
33765
|
-
const job = await this.jobDefinitions.
|
|
33779
|
+
const job = await this.jobDefinitions.getDefinitionByUid(instance.jobUid);
|
|
33766
33780
|
if (!job) {
|
|
33767
33781
|
throw new Error(`Job definition not found -> ${instance.jobUid}`);
|
|
33768
33782
|
}
|
|
@@ -33904,7 +33918,7 @@ let JobDispatchHandler = JobDispatchHandler_1 = class JobDispatchHandler {
|
|
|
33904
33918
|
const instanceId = backendCore.newUuid();
|
|
33905
33919
|
try {
|
|
33906
33920
|
this.logger.info(`JOB DISPATCH -> dispatching started job ${job.uid} -> ${instanceId}`);
|
|
33907
|
-
await this.instances.
|
|
33921
|
+
await this.instances.appendInstance(job, {
|
|
33908
33922
|
id: instanceId,
|
|
33909
33923
|
runType,
|
|
33910
33924
|
scheduleUid: schedule.uid,
|
|
@@ -33915,13 +33929,13 @@ let JobDispatchHandler = JobDispatchHandler_1 = class JobDispatchHandler {
|
|
|
33915
33929
|
schedule,
|
|
33916
33930
|
instanceId,
|
|
33917
33931
|
});
|
|
33918
|
-
await this.instances.
|
|
33932
|
+
await this.instances.updateInstance(instanceId, {
|
|
33919
33933
|
status: exports.JobStatus.Ready,
|
|
33920
33934
|
});
|
|
33921
33935
|
this.logger.info(`JOB DISPATCH -> dispatching completed job ${job.uid} -> ${instanceId}`);
|
|
33922
33936
|
}
|
|
33923
33937
|
catch (e) {
|
|
33924
|
-
await this.instances.
|
|
33938
|
+
await this.instances.updateInstance(instanceId, {
|
|
33925
33939
|
status: exports.JobStatus.InitializationError,
|
|
33926
33940
|
error: `${e.message} -> \n\n ${e.stack}`,
|
|
33927
33941
|
});
|
|
@@ -33967,7 +33981,7 @@ let JobStatusMonitorHandler = JobStatusMonitorHandler_1 = class JobStatusMonitor
|
|
|
33967
33981
|
const { input: { job, instanceId }, } = command;
|
|
33968
33982
|
try {
|
|
33969
33983
|
this.logger.info(`JOB STATUS UPDATE -> dispatching started job ${job.uid} -> ${instanceId}`);
|
|
33970
|
-
const current = await this.instances.
|
|
33984
|
+
const current = await this.instances.getById(instanceId);
|
|
33971
33985
|
if (!current) {
|
|
33972
33986
|
throw new Error(`Job instance ${instanceId} not found`);
|
|
33973
33987
|
}
|
|
@@ -33983,7 +33997,7 @@ let JobStatusMonitorHandler = JobStatusMonitorHandler_1 = class JobStatusMonitor
|
|
|
33983
33997
|
this.logger.info(`JOB STATUS UPDATE -> status unchanged ${job.uid} -> ${instanceId}`);
|
|
33984
33998
|
return;
|
|
33985
33999
|
}
|
|
33986
|
-
await this.instances.
|
|
34000
|
+
await this.instances.updateInstance(instanceId, {
|
|
33987
34001
|
status: newStatus,
|
|
33988
34002
|
endTime: !current.endTime && isJobEnded(newStatus) ? new Date() : undefined,
|
|
33989
34003
|
startTime: !current.startTime && isJobStarted(newStatus)
|
|
@@ -34031,7 +34045,7 @@ let JobDefinitionUpdateHandler = JobDefinitionUpdateHandler_1 = class JobDefinit
|
|
|
34031
34045
|
await this.executor.upsertJobDefinition({
|
|
34032
34046
|
definition: job,
|
|
34033
34047
|
});
|
|
34034
|
-
await this.definitions.
|
|
34048
|
+
await this.definitions.ensureDefinition(job);
|
|
34035
34049
|
this.logger.info(`JOB DEFINITION UPDATE -> status update completed job ${job.uid}`);
|
|
34036
34050
|
}
|
|
34037
34051
|
};
|