@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
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BathJobDefinition, GetBatchJobStatusInput, SubmitBatchJobInput } from "./types";
|
|
2
|
-
import { AwsBatchSettings } from "../settings";
|
|
3
2
|
export declare class AwsBatchService {
|
|
4
|
-
private readonly awsSettings;
|
|
5
3
|
private readonly logger;
|
|
6
|
-
constructor(awsSettings: AwsBatchSettings);
|
|
7
4
|
cancelJobInput(): Promise<void>;
|
|
8
5
|
getJobInstance(input: GetBatchJobStatusInput): Promise<import("@aws-sdk/client-batch").JobSummary | undefined>;
|
|
9
6
|
submitJob(input: SubmitBatchJobInput): Promise<void>;
|
|
@@ -16,4 +13,5 @@ export declare class AwsBatchService {
|
|
|
16
13
|
private createQueue;
|
|
17
14
|
private getQueue;
|
|
18
15
|
private client;
|
|
16
|
+
private get awsSettings();
|
|
19
17
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AppInMemorySettings } from "../../../../../../settings";
|
|
1
2
|
export type AwsBatchSettings = {
|
|
2
3
|
awsAccessKeyId?: string;
|
|
3
4
|
awsSecretAccessKey?: string;
|
|
@@ -6,3 +7,4 @@ export type AwsBatchSettings = {
|
|
|
6
7
|
batchComputeEnvironment: string;
|
|
7
8
|
batchExecutionRole: string;
|
|
8
9
|
};
|
|
10
|
+
export declare const awsBatchSettings: AppInMemorySettings<AwsBatchSettings>;
|
package/dist/esm/index.js
CHANGED
|
@@ -39955,14 +39955,15 @@ InMemoryEmailProvider = __decorate([
|
|
|
39955
39955
|
WpEmailProvider("in-memory")
|
|
39956
39956
|
], InMemoryEmailProvider);
|
|
39957
39957
|
|
|
39958
|
+
const awsBatchSettings = new AppInMemorySettings();
|
|
39959
|
+
|
|
39958
39960
|
const JobProvider = (provider) => SetMetadata(JOB_PROVIDER, provider);
|
|
39959
39961
|
|
|
39960
39962
|
var AwsBatchService_1;
|
|
39961
39963
|
const jobDefinitionName = (jobUid) => `job-${jobUid}`;
|
|
39962
39964
|
const jobInstanceName = (jobUid, instanceId) => `job-${jobUid}-${instanceId}`;
|
|
39963
39965
|
let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
39964
|
-
constructor(
|
|
39965
|
-
this.awsSettings = awsSettings;
|
|
39966
|
+
constructor() {
|
|
39966
39967
|
this.logger = Log.getLogger(AwsBatchService_1.name);
|
|
39967
39968
|
this.client = () => new BatchClient({
|
|
39968
39969
|
...(this.awsSettings.awsSecretAccessKey &&
|
|
@@ -40003,7 +40004,7 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40003
40004
|
const jobDefName = jobDefinitionName(input.jobUid);
|
|
40004
40005
|
const jobDefinition = await this.getLatestJobDefinition(jobDefName);
|
|
40005
40006
|
const jobName = jobInstanceName(input.jobUid, input.instanceId);
|
|
40006
|
-
|
|
40007
|
+
const submitJobRequest = {
|
|
40007
40008
|
jobQueue: queue.jobQueueArn,
|
|
40008
40009
|
jobDefinition: jobDefinition.jobDefinitionArn,
|
|
40009
40010
|
jobName,
|
|
@@ -40011,8 +40012,14 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40011
40012
|
command: input.overrides?.command ??
|
|
40012
40013
|
jobDefinition.containerProperties.command,
|
|
40013
40014
|
},
|
|
40014
|
-
}
|
|
40015
|
-
this.logger.info(`AWS JOB -> job
|
|
40015
|
+
};
|
|
40016
|
+
this.logger.info(`AWS JOB -> submitting job ${jobName} ${queue.jobQueueArn}`, {
|
|
40017
|
+
request: submitJobRequest,
|
|
40018
|
+
});
|
|
40019
|
+
const result = await this.client().send(new SubmitJobCommand(submitJobRequest));
|
|
40020
|
+
this.logger.info(`AWS JOB -> job submitted ${jobName} ${queue.jobQueueArn}`, {
|
|
40021
|
+
result,
|
|
40022
|
+
});
|
|
40016
40023
|
}
|
|
40017
40024
|
async ensureJobDefinition(definition) {
|
|
40018
40025
|
const jobName = jobDefinitionName(definition.jobUid);
|
|
@@ -40055,6 +40062,10 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40055
40062
|
}
|
|
40056
40063
|
async getLatestJobDefinition(jobName) {
|
|
40057
40064
|
const jobs = await this.getActiveJobDefinitions(jobName);
|
|
40065
|
+
this.logger.debug(`AWS JOB -> latest job definition`, {
|
|
40066
|
+
jobName,
|
|
40067
|
+
jobs,
|
|
40068
|
+
});
|
|
40058
40069
|
return lodash.exports.orderBy(jobs, (x) => x.revision, "desc")[0];
|
|
40059
40070
|
}
|
|
40060
40071
|
async getActiveJobDefinitions(jobName) {
|
|
@@ -40065,11 +40076,18 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40065
40076
|
return result.jobDefinitions ?? [];
|
|
40066
40077
|
}
|
|
40067
40078
|
async ensureQueue(queueName) {
|
|
40079
|
+
if (!queueName) {
|
|
40080
|
+
throw new Error(`Queue name not provided`);
|
|
40081
|
+
}
|
|
40082
|
+
this.logger.debug(`AWS JOB -> ensuring queue ${queueName}`);
|
|
40068
40083
|
const queue = await this.getQueue(queueName);
|
|
40069
40084
|
if (queue) {
|
|
40085
|
+
this.logger.debug(`AWS JOB -> queue exists ${queueName}`);
|
|
40070
40086
|
return queue;
|
|
40071
40087
|
}
|
|
40088
|
+
this.logger.debug(`AWS JOB -> creating queue ${queueName}`);
|
|
40072
40089
|
await this.createQueue(queueName);
|
|
40090
|
+
this.logger.debug(`AWS JOB -> queue created ${queueName}`);
|
|
40073
40091
|
const currentQueue = await this.getQueue(queueName);
|
|
40074
40092
|
if (!currentQueue) {
|
|
40075
40093
|
throw new Error(`Queue not created -> ${queueName}`);
|
|
@@ -40077,6 +40095,9 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40077
40095
|
return currentQueue;
|
|
40078
40096
|
}
|
|
40079
40097
|
async createQueue(queueName) {
|
|
40098
|
+
if (!this.awsSettings.batchComputeEnvironment) {
|
|
40099
|
+
throw new Error(`No compute environment defined`);
|
|
40100
|
+
}
|
|
40080
40101
|
await this.client().send(new CreateJobQueueCommand({
|
|
40081
40102
|
jobQueueName: queueName,
|
|
40082
40103
|
priority: 0,
|
|
@@ -40094,11 +40115,12 @@ let AwsBatchService = AwsBatchService_1 = class AwsBatchService {
|
|
|
40094
40115
|
}));
|
|
40095
40116
|
return result.jobQueues?.[0];
|
|
40096
40117
|
}
|
|
40118
|
+
get awsSettings() {
|
|
40119
|
+
return awsBatchSettings.value;
|
|
40120
|
+
}
|
|
40097
40121
|
};
|
|
40098
40122
|
AwsBatchService = AwsBatchService_1 = __decorate([
|
|
40099
|
-
Injectable()
|
|
40100
|
-
__param(0, Inject("WP.AWS_BATCH_SETTINGS")),
|
|
40101
|
-
__metadata("design:paramtypes", [Object])
|
|
40123
|
+
Injectable()
|
|
40102
40124
|
], AwsBatchService);
|
|
40103
40125
|
|
|
40104
40126
|
const mapJobStatus = (awsJobStatus) => {
|
|
@@ -40173,17 +40195,10 @@ const ModuleData$3 = {
|
|
|
40173
40195
|
};
|
|
40174
40196
|
let AwsJobsModule = AwsJobsModule_1 = class AwsJobsModule {
|
|
40175
40197
|
static forRoot(input) {
|
|
40198
|
+
awsBatchSettings.initialize(input);
|
|
40176
40199
|
return {
|
|
40177
40200
|
module: AwsJobsModule_1,
|
|
40178
40201
|
...ModuleData$3,
|
|
40179
|
-
providers: [
|
|
40180
|
-
...ModuleData$3.providers,
|
|
40181
|
-
{
|
|
40182
|
-
provide: "WP.AWS_BATCH_SETTINGS",
|
|
40183
|
-
useValue: input,
|
|
40184
|
-
},
|
|
40185
|
-
],
|
|
40186
|
-
exports: [...ModuleData$3.exports],
|
|
40187
40202
|
};
|
|
40188
40203
|
}
|
|
40189
40204
|
};
|
|
@@ -43514,5 +43529,5 @@ AwsSecretsModule = AwsSecretsModule_1 = __decorate([
|
|
|
43514
43529
|
})
|
|
43515
43530
|
], AwsSecretsModule);
|
|
43516
43531
|
|
|
43517
|
-
export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryMediaProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, toEntitiesImportInput };
|
|
43532
|
+
export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryMediaProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, toEntitiesImportInput };
|
|
43518
43533
|
//# sourceMappingURL=index.js.map
|