@punks/backend-entity-manager 0.0.285 → 0.0.287
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 +32 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/manager/index.d.ts +1 -3
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/settings/index.d.ts +2 -0
- package/dist/esm/index.js +32 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/manager/index.d.ts +1 -3
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/settings/index.d.ts +2 -0
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -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(
|
|
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 &&
|
|
@@ -40018,7 +40019,7 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40018
40019
|
const jobDefName = jobDefinitionName(input.jobUid);
|
|
40019
40020
|
const jobDefinition = await this.getLatestJobDefinition(jobDefName);
|
|
40020
40021
|
const jobName = jobInstanceName(input.jobUid, input.instanceId);
|
|
40021
|
-
|
|
40022
|
+
const submitJobRequest = {
|
|
40022
40023
|
jobQueue: queue.jobQueueArn,
|
|
40023
40024
|
jobDefinition: jobDefinition.jobDefinitionArn,
|
|
40024
40025
|
jobName,
|
|
@@ -40026,8 +40027,14 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40026
40027
|
command: input.overrides?.command ??
|
|
40027
40028
|
jobDefinition.containerProperties.command,
|
|
40028
40029
|
},
|
|
40029
|
-
}
|
|
40030
|
-
this.logger.info(`AWS JOB -> job
|
|
40030
|
+
};
|
|
40031
|
+
this.logger.info(`AWS JOB -> submitting job ${jobName} ${queue.jobQueueArn}`, {
|
|
40032
|
+
request: submitJobRequest,
|
|
40033
|
+
});
|
|
40034
|
+
const result = await this.client().send(new clientBatch.SubmitJobCommand(submitJobRequest));
|
|
40035
|
+
this.logger.info(`AWS JOB -> job submitted ${jobName} ${queue.jobQueueArn}`, {
|
|
40036
|
+
result,
|
|
40037
|
+
});
|
|
40031
40038
|
}
|
|
40032
40039
|
async ensureJobDefinition(definition) {
|
|
40033
40040
|
const jobName = jobDefinitionName(definition.jobUid);
|
|
@@ -40070,6 +40077,10 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40070
40077
|
}
|
|
40071
40078
|
async getLatestJobDefinition(jobName) {
|
|
40072
40079
|
const jobs = await this.getActiveJobDefinitions(jobName);
|
|
40080
|
+
this.logger.debug(`AWS JOB -> latest job definition`, {
|
|
40081
|
+
jobName,
|
|
40082
|
+
jobs,
|
|
40083
|
+
});
|
|
40073
40084
|
return lodash.exports.orderBy(jobs, (x) => x.revision, "desc")[0];
|
|
40074
40085
|
}
|
|
40075
40086
|
async getActiveJobDefinitions(jobName) {
|
|
@@ -40080,11 +40091,18 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40080
40091
|
return result.jobDefinitions ?? [];
|
|
40081
40092
|
}
|
|
40082
40093
|
async ensureQueue(queueName) {
|
|
40094
|
+
if (!queueName) {
|
|
40095
|
+
throw new Error(`Queue name not provided`);
|
|
40096
|
+
}
|
|
40097
|
+
this.logger.debug(`AWS JOB -> ensuring queue ${queueName}`);
|
|
40083
40098
|
const queue = await this.getQueue(queueName);
|
|
40084
40099
|
if (queue) {
|
|
40100
|
+
this.logger.debug(`AWS JOB -> queue exists ${queueName}`);
|
|
40085
40101
|
return queue;
|
|
40086
40102
|
}
|
|
40103
|
+
this.logger.debug(`AWS JOB -> creating queue ${queueName}`);
|
|
40087
40104
|
await this.createQueue(queueName);
|
|
40105
|
+
this.logger.debug(`AWS JOB -> queue created ${queueName}`);
|
|
40088
40106
|
const currentQueue = await this.getQueue(queueName);
|
|
40089
40107
|
if (!currentQueue) {
|
|
40090
40108
|
throw new Error(`Queue not created -> ${queueName}`);
|
|
@@ -40092,6 +40110,9 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40092
40110
|
return currentQueue;
|
|
40093
40111
|
}
|
|
40094
40112
|
async createQueue(queueName) {
|
|
40113
|
+
if (!this.awsSettings.batchComputeEnvironment) {
|
|
40114
|
+
throw new Error(`No compute environment defined`);
|
|
40115
|
+
}
|
|
40095
40116
|
await this.client().send(new clientBatch.CreateJobQueueCommand({
|
|
40096
40117
|
jobQueueName: queueName,
|
|
40097
40118
|
priority: 0,
|
|
@@ -40109,11 +40130,12 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40109
40130
|
}));
|
|
40110
40131
|
return result.jobQueues?.[0];
|
|
40111
40132
|
}
|
|
40133
|
+
get awsSettings() {
|
|
40134
|
+
return awsBatchSettings.value;
|
|
40135
|
+
}
|
|
40112
40136
|
};
|
|
40113
40137
|
AwsBatchService = AwsBatchService_1 = __decorate([
|
|
40114
|
-
common.Injectable()
|
|
40115
|
-
__param(0, common.Inject("WP.AWS_BATCH_SETTINGS")),
|
|
40116
|
-
__metadata("design:paramtypes", [Object])
|
|
40138
|
+
common.Injectable()
|
|
40117
40139
|
], AwsBatchService);
|
|
40118
40140
|
|
|
40119
40141
|
const mapJobStatus = (awsJobStatus) => {
|
|
@@ -40188,17 +40210,10 @@ const ModuleData$3 = {
|
|
|
40188
40210
|
};
|
|
40189
40211
|
exports.AwsJobsModule = AwsJobsModule_1 = class AwsJobsModule {
|
|
40190
40212
|
static forRoot(input) {
|
|
40213
|
+
awsBatchSettings.initialize(input);
|
|
40191
40214
|
return {
|
|
40192
40215
|
module: AwsJobsModule_1,
|
|
40193
40216
|
...ModuleData$3,
|
|
40194
|
-
providers: [
|
|
40195
|
-
...ModuleData$3.providers,
|
|
40196
|
-
{
|
|
40197
|
-
provide: "WP.AWS_BATCH_SETTINGS",
|
|
40198
|
-
useValue: input,
|
|
40199
|
-
},
|
|
40200
|
-
],
|
|
40201
|
-
exports: [...ModuleData$3.exports],
|
|
40202
40217
|
};
|
|
40203
40218
|
}
|
|
40204
40219
|
};
|
|
@@ -43617,6 +43632,7 @@ exports.WpRolesService = WpRolesService;
|
|
|
43617
43632
|
exports.WpSendgridEmailTemplate = WpSendgridEmailTemplate;
|
|
43618
43633
|
exports.WpUserRolesService = WpUserRolesService;
|
|
43619
43634
|
exports.WpUserService = WpUserService;
|
|
43635
|
+
exports.awsBatchSettings = awsBatchSettings;
|
|
43620
43636
|
exports.buildPermissionsGuard = buildPermissionsGuard;
|
|
43621
43637
|
exports.buildProviderToken = buildProviderToken;
|
|
43622
43638
|
exports.buildRolesGuard = buildRolesGuard;
|