@punks/backend-entity-manager 0.0.286 → 0.0.288

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 CHANGED
@@ -33867,7 +33867,7 @@ exports.JobsService = class JobsService {
33867
33867
  }));
33868
33868
  };
33869
33869
  this.updateJob = async (input) => {
33870
- this.commandBus.execute(new JobDefinitionUpdateCommand({
33870
+ await this.commandBus.execute(new JobDefinitionUpdateCommand({
33871
33871
  job: input,
33872
33872
  }));
33873
33873
  };
@@ -39970,14 +39970,15 @@ exports.InMemoryEmailProvider = __decorate([
39970
39970
  WpEmailProvider("in-memory")
39971
39971
  ], exports.InMemoryEmailProvider);
39972
39972
 
39973
+ const awsBatchSettings = new AppInMemorySettings();
39974
+
39973
39975
  const JobProvider = (provider) => common.SetMetadata(JOB_PROVIDER, provider);
39974
39976
 
39975
39977
  var AwsBatchService_1;
39976
39978
  const jobDefinitionName = (jobUid) => `job-${jobUid}`;
39977
39979
  const jobInstanceName = (jobUid, instanceId) => `job-${jobUid}-${instanceId}`;
39978
39980
  let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
39979
- constructor(awsSettings) {
39980
- this.awsSettings = awsSettings;
39981
+ constructor() {
39981
39982
  this.logger = backendCore.Log.getLogger(AwsBatchService_1.name);
39982
39983
  this.client = () => new clientBatch.BatchClient({
39983
39984
  ...(this.awsSettings.awsSecretAccessKey &&
@@ -40037,12 +40038,25 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
40037
40038
  }
40038
40039
  async ensureJobDefinition(definition) {
40039
40040
  const jobName = jobDefinitionName(definition.jobUid);
40041
+ this.logger.debug(`AWS JOB -> ensuring job definition ${jobName}`, {
40042
+ definition,
40043
+ });
40040
40044
  const jobs = await this.getActiveJobDefinitions(jobName);
40041
40045
  for (const job of jobs) {
40046
+ this.logger.debug(`AWS JOB -> unregistering job definition`, {
40047
+ job,
40048
+ });
40042
40049
  await this.unregisterJobDefinition(job.jobDefinitionArn);
40043
40050
  }
40051
+ this.logger.debug(`AWS JOB -> registering job definition`, {
40052
+ definition,
40053
+ });
40044
40054
  await this.registerJobDefinition(jobName, definition);
40045
- return await this.getLatestJobDefinition(jobName);
40055
+ const updatedDefinition = await this.getLatestJobDefinition(jobName);
40056
+ this.logger.debug(`AWS JOB -> job definition updated`, {
40057
+ updatedDefinition,
40058
+ });
40059
+ return updatedDefinition;
40046
40060
  }
40047
40061
  async unregisterJobDefinition(jobDefinitionArn) {
40048
40062
  await this.client().send(new clientBatch.DeregisterJobDefinitionCommand({
@@ -40090,6 +40104,9 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
40090
40104
  return result.jobDefinitions ?? [];
40091
40105
  }
40092
40106
  async ensureQueue(queueName) {
40107
+ if (!queueName) {
40108
+ throw new Error(`Queue name not provided`);
40109
+ }
40093
40110
  this.logger.debug(`AWS JOB -> ensuring queue ${queueName}`);
40094
40111
  const queue = await this.getQueue(queueName);
40095
40112
  if (queue) {
@@ -40106,6 +40123,9 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
40106
40123
  return currentQueue;
40107
40124
  }
40108
40125
  async createQueue(queueName) {
40126
+ if (!this.awsSettings.batchComputeEnvironment) {
40127
+ throw new Error(`No compute environment defined`);
40128
+ }
40109
40129
  await this.client().send(new clientBatch.CreateJobQueueCommand({
40110
40130
  jobQueueName: queueName,
40111
40131
  priority: 0,
@@ -40123,11 +40143,12 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
40123
40143
  }));
40124
40144
  return result.jobQueues?.[0];
40125
40145
  }
40146
+ get awsSettings() {
40147
+ return awsBatchSettings.value;
40148
+ }
40126
40149
  };
40127
40150
  AwsBatchService = AwsBatchService_1 = __decorate([
40128
- common.Injectable(),
40129
- __param(0, common.Inject("WP.AWS_BATCH_SETTINGS")),
40130
- __metadata("design:paramtypes", [Object])
40151
+ common.Injectable()
40131
40152
  ], AwsBatchService);
40132
40153
 
40133
40154
  const mapJobStatus = (awsJobStatus) => {
@@ -40202,17 +40223,10 @@ const ModuleData$3 = {
40202
40223
  };
40203
40224
  exports.AwsJobsModule = AwsJobsModule_1 = class AwsJobsModule {
40204
40225
  static forRoot(input) {
40226
+ awsBatchSettings.initialize(input);
40205
40227
  return {
40206
40228
  module: AwsJobsModule_1,
40207
40229
  ...ModuleData$3,
40208
- providers: [
40209
- ...ModuleData$3.providers,
40210
- {
40211
- provide: "WP.AWS_BATCH_SETTINGS",
40212
- useValue: input,
40213
- },
40214
- ],
40215
- exports: [...ModuleData$3.exports],
40216
40230
  };
40217
40231
  }
40218
40232
  };
@@ -43631,6 +43645,7 @@ exports.WpRolesService = WpRolesService;
43631
43645
  exports.WpSendgridEmailTemplate = WpSendgridEmailTemplate;
43632
43646
  exports.WpUserRolesService = WpUserRolesService;
43633
43647
  exports.WpUserService = WpUserService;
43648
+ exports.awsBatchSettings = awsBatchSettings;
43634
43649
  exports.buildPermissionsGuard = buildPermissionsGuard;
43635
43650
  exports.buildProviderToken = buildProviderToken;
43636
43651
  exports.buildRolesGuard = buildRolesGuard;