@punks/backend-entity-manager 0.0.470 → 0.0.472
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 +76 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/pipelines.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/decorators/pipelines.d.ts +9 -0
- package/dist/cjs/types/platforms/nest/pipelines/template/template.d.ts +6 -1
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/manager/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/manager/types.d.ts +4 -0
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/models/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/plugins/jobs/aws-batch/settings/index.d.ts +2 -1
- package/dist/esm/index.js +77 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/pipelines.d.ts +1 -0
- package/dist/esm/types/platforms/nest/decorators/pipelines.d.ts +9 -0
- package/dist/esm/types/platforms/nest/pipelines/template/template.d.ts +6 -1
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/manager/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/manager/types.d.ts +4 -0
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/models/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/plugins/jobs/aws-batch/settings/index.d.ts +2 -1
- package/dist/index.d.ts +17 -2
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -35596,7 +35596,7 @@ class NestPipelineTemplate {
|
|
|
35596
35596
|
return result.output;
|
|
35597
35597
|
}
|
|
35598
35598
|
async execute(data) {
|
|
35599
|
-
if (this.
|
|
35599
|
+
if (this.concurrency === "sequential") {
|
|
35600
35600
|
return await this.operationsLockService.executeSequential({
|
|
35601
35601
|
lockUid: this.getConcurrencyKey(data.input),
|
|
35602
35602
|
operation: async () => {
|
|
@@ -35604,7 +35604,7 @@ class NestPipelineTemplate {
|
|
|
35604
35604
|
},
|
|
35605
35605
|
});
|
|
35606
35606
|
}
|
|
35607
|
-
if (this.
|
|
35607
|
+
if (this.concurrency === "exclusive") {
|
|
35608
35608
|
const result = await this.operationsLockService.executeExclusive({
|
|
35609
35609
|
lockUid: this.getConcurrencyKey(data.input),
|
|
35610
35610
|
operation: async () => {
|
|
@@ -35622,9 +35622,9 @@ class NestPipelineTemplate {
|
|
|
35622
35622
|
context: data.context,
|
|
35623
35623
|
instanceId,
|
|
35624
35624
|
};
|
|
35625
|
-
this.logger.debug(`[START] | ${this.metadata.name}`, logMetadata);
|
|
35625
|
+
this.logger.debug(`[START] | ${this.metadata.name}`, this.processLogMetadata(logMetadata));
|
|
35626
35626
|
if (!this.isAuthorized(data.context)) {
|
|
35627
|
-
this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, logMetadata);
|
|
35627
|
+
this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, this.processLogMetadata(logMetadata));
|
|
35628
35628
|
return {
|
|
35629
35629
|
type: "error",
|
|
35630
35630
|
errorType: exports.PipelineErrorType.Unauthorized,
|
|
@@ -35637,19 +35637,25 @@ class NestPipelineTemplate {
|
|
|
35637
35637
|
if (result.type === "error") {
|
|
35638
35638
|
this.logger.error(`[ERROR] | ${this.metadata.name} -> ${result.exception
|
|
35639
35639
|
? `exception: ${result.exception.name}\n${result.exception.stack}`
|
|
35640
|
-
: ""}`, {
|
|
35640
|
+
: ""}`, this.processLogMetadata({
|
|
35641
35641
|
...logMetadata,
|
|
35642
35642
|
result,
|
|
35643
|
-
});
|
|
35643
|
+
}));
|
|
35644
35644
|
}
|
|
35645
35645
|
else {
|
|
35646
|
-
this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, {
|
|
35646
|
+
this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, this.processLogMetadata({
|
|
35647
35647
|
...logMetadata,
|
|
35648
35648
|
result,
|
|
35649
|
-
});
|
|
35649
|
+
}));
|
|
35650
35650
|
}
|
|
35651
35651
|
return result;
|
|
35652
35652
|
}
|
|
35653
|
+
processLogMetadata(meta) {
|
|
35654
|
+
if (this.metadata.options?.logging?.ignoreMeta) {
|
|
35655
|
+
return undefined;
|
|
35656
|
+
}
|
|
35657
|
+
return meta;
|
|
35658
|
+
}
|
|
35653
35659
|
getDefinition() {
|
|
35654
35660
|
if (!this.cachedDefinition) {
|
|
35655
35661
|
this.cachedDefinition = this.buildDefinition();
|
|
@@ -35666,6 +35672,9 @@ class NestPipelineTemplate {
|
|
|
35666
35672
|
.resolveAuthenticationContextProvider();
|
|
35667
35673
|
return (await contextService?.getContext());
|
|
35668
35674
|
}
|
|
35675
|
+
get concurrency() {
|
|
35676
|
+
return this.options?.concurrency ?? this.metadata.concurrency;
|
|
35677
|
+
}
|
|
35669
35678
|
get operationsLockService() {
|
|
35670
35679
|
return this.registry
|
|
35671
35680
|
.getContainer()
|
|
@@ -41554,9 +41563,25 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
41554
41563
|
this.logger.info(`AWS JOB -> submitting job triggered`, {
|
|
41555
41564
|
input,
|
|
41556
41565
|
});
|
|
41557
|
-
const queue = await this.ensureQueue(jobQueueName(input.jobUid));
|
|
41558
41566
|
const jobDefName = jobDefinitionName(input.jobUid);
|
|
41559
41567
|
const jobDefinition = await this.getLatestJobDefinition(jobDefName);
|
|
41568
|
+
if (!jobDefinition) {
|
|
41569
|
+
throw new Error(`Job definition not found -> ${jobDefName}`);
|
|
41570
|
+
}
|
|
41571
|
+
const platformType = jobDefinition.platformCapabilities?.[0];
|
|
41572
|
+
if (!platformType) {
|
|
41573
|
+
throw new Error(`Platform type not found -> ${jobDefName}`);
|
|
41574
|
+
}
|
|
41575
|
+
const defaultComputeEnvironment = platformType === clientBatch.PlatformCapability.FARGATE
|
|
41576
|
+
? this.awsSettings.defaultFargateBatchComputeEnvironment
|
|
41577
|
+
: this.awsSettings.defaultEc2BatchComputeEnvironment;
|
|
41578
|
+
const batchComputeEnvironment = input.overrides?.batchComputeEnvironment ?? defaultComputeEnvironment;
|
|
41579
|
+
if (!batchComputeEnvironment) {
|
|
41580
|
+
throw new Error(`Compute environment not found -> ${jobDefName}`);
|
|
41581
|
+
}
|
|
41582
|
+
const queue = await this.ensureQueue(jobQueueName(input.jobUid), {
|
|
41583
|
+
batchComputeEnvironment,
|
|
41584
|
+
});
|
|
41560
41585
|
const jobName = jobInstanceName(input.jobUid, input.instanceId);
|
|
41561
41586
|
const submitJobRequest = {
|
|
41562
41587
|
jobQueue: queue.jobQueueArn,
|
|
@@ -41683,18 +41708,32 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
41683
41708
|
}));
|
|
41684
41709
|
return result.jobDefinitions ?? [];
|
|
41685
41710
|
}
|
|
41686
|
-
async ensureQueue(queueName) {
|
|
41711
|
+
async ensureQueue(queueName, options) {
|
|
41687
41712
|
if (!queueName) {
|
|
41688
41713
|
throw new Error(`Queue name not provided`);
|
|
41689
41714
|
}
|
|
41690
41715
|
this.logger.debug(`AWS JOB -> ensuring queue ${queueName}`);
|
|
41691
41716
|
const queue = await this.getQueue(queueName);
|
|
41692
41717
|
if (queue) {
|
|
41693
|
-
|
|
41694
|
-
|
|
41718
|
+
if (queue.computeEnvironmentOrder?.[0].computeEnvironment ===
|
|
41719
|
+
options.batchComputeEnvironment) {
|
|
41720
|
+
this.logger.debug(`AWS JOB -> queue exists ${queueName}`);
|
|
41721
|
+
return queue;
|
|
41722
|
+
}
|
|
41723
|
+
this.logger.debug(`AWS JOB -> queue exists with different compute environment ${queueName}`, {
|
|
41724
|
+
queue,
|
|
41725
|
+
options,
|
|
41726
|
+
});
|
|
41727
|
+
await this.updateQueue(queueName, options);
|
|
41728
|
+
this.logger.debug(`AWS JOB -> queue updated ${queueName}`);
|
|
41729
|
+
const updatedQueue = await this.getQueue(queueName);
|
|
41730
|
+
if (!updatedQueue) {
|
|
41731
|
+
throw new Error(`Queue not updated -> ${queueName}`);
|
|
41732
|
+
}
|
|
41733
|
+
return updatedQueue;
|
|
41695
41734
|
}
|
|
41696
41735
|
this.logger.debug(`AWS JOB -> creating queue ${queueName}`);
|
|
41697
|
-
await this.createQueue(queueName);
|
|
41736
|
+
await this.createQueue(queueName, options);
|
|
41698
41737
|
this.logger.debug(`AWS JOB -> queue created ${queueName}`);
|
|
41699
41738
|
// Wait for the queue to be active
|
|
41700
41739
|
await backendCore.sleep(10000);
|
|
@@ -41704,8 +41743,9 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
41704
41743
|
}
|
|
41705
41744
|
return currentQueue;
|
|
41706
41745
|
}
|
|
41707
|
-
async createQueue(queueName) {
|
|
41708
|
-
if (!this.awsSettings.
|
|
41746
|
+
async createQueue(queueName, options) {
|
|
41747
|
+
if (!this.awsSettings.defaultFargateBatchComputeEnvironment &&
|
|
41748
|
+
!options?.batchComputeEnvironment) {
|
|
41709
41749
|
throw new Error(`No compute environment defined`);
|
|
41710
41750
|
}
|
|
41711
41751
|
await this.client().send(new clientBatch.CreateJobQueueCommand({
|
|
@@ -41713,7 +41753,25 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
41713
41753
|
priority: 0,
|
|
41714
41754
|
computeEnvironmentOrder: [
|
|
41715
41755
|
{
|
|
41716
|
-
computeEnvironment:
|
|
41756
|
+
computeEnvironment: options?.batchComputeEnvironment ||
|
|
41757
|
+
this.awsSettings.defaultFargateBatchComputeEnvironment,
|
|
41758
|
+
order: 0,
|
|
41759
|
+
},
|
|
41760
|
+
],
|
|
41761
|
+
}));
|
|
41762
|
+
}
|
|
41763
|
+
async updateQueue(queueName, options) {
|
|
41764
|
+
if (!this.awsSettings.defaultFargateBatchComputeEnvironment &&
|
|
41765
|
+
!options?.batchComputeEnvironment) {
|
|
41766
|
+
throw new Error(`No compute environment defined`);
|
|
41767
|
+
}
|
|
41768
|
+
await this.client().send(new clientBatch.UpdateJobQueueCommand({
|
|
41769
|
+
jobQueue: queueName,
|
|
41770
|
+
priority: 0,
|
|
41771
|
+
computeEnvironmentOrder: [
|
|
41772
|
+
{
|
|
41773
|
+
computeEnvironment: options?.batchComputeEnvironment ||
|
|
41774
|
+
this.awsSettings.defaultFargateBatchComputeEnvironment,
|
|
41717
41775
|
order: 0,
|
|
41718
41776
|
},
|
|
41719
41777
|
],
|
|
@@ -41758,11 +41816,13 @@ let AwsJobsProvider = class AwsJobsProvider {
|
|
|
41758
41816
|
const { definition, schedule, instanceId, payload, commandPlaceholders } = input;
|
|
41759
41817
|
const awsInvocationParams = schedule?.invocationOverrides ??
|
|
41760
41818
|
definition.invocationParams;
|
|
41819
|
+
const awsInfrastructureParams = definition.infrastructureParams;
|
|
41761
41820
|
await this.awsBatchService.submitJob({
|
|
41762
41821
|
instanceId,
|
|
41763
41822
|
jobUid: definition.uid,
|
|
41764
41823
|
overrides: {
|
|
41765
41824
|
command: awsInvocationParams.startCommand?.map((x) => replacePlaceholders(replacePayload(x, payload), commandPlaceholders)),
|
|
41825
|
+
batchComputeEnvironment: awsInfrastructureParams.batchComputeEnvironment,
|
|
41766
41826
|
},
|
|
41767
41827
|
});
|
|
41768
41828
|
}
|