@squiz/job-runner-lib 2.1.0 → 2.2.0
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/CHANGELOG.md +6 -1
- package/lib/domains/job/S3Repository/S3RepositoryBase.d.ts +2 -2
- package/lib/domains/job/singletonProvider.d.ts +1 -1
- package/lib/domains/job/transientProvider.d.ts +1 -1
- package/lib/index.js +7 -7
- package/lib/index.js.map +3 -3
- package/package.json +8 -12
- package/src/domains/job/S3Repository/JobDetailsRepository.ts +4 -1
- package/src/domains/job/S3Repository/S3RepositoryBase.ts +6 -3
- package/src/domains/job/core/pagination/services/PaginationService.spec.ts +1 -1
- package/src/domains/job/errors/BadRequestError.ts +4 -1
- package/src/domains/job/errors/ErrorWithHttpStatusCode.ts +5 -1
- package/src/domains/job/errors/InternalServerError.ts +4 -1
- package/src/domains/job/errors/NotImplementedError.ts +4 -1
- package/src/domains/job/errors/UnprocessableContent.ts +4 -1
- package/src/domains/job/manifest/JobManifestV1.ts +4 -1
- package/src/domains/job/services/JobExecutionTaskService/JobExecutionTaskService.ts +2 -3
- package/tsconfig.json +1 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squiz/job-runner-lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -26,22 +26,18 @@
|
|
|
26
26
|
"aws-sdk-client-mock": "^2.2.0",
|
|
27
27
|
"aws-sdk-client-mock-jest": "^2.2.0",
|
|
28
28
|
"dotenv": "16.0.3",
|
|
29
|
-
"esbuild": "^0.25.
|
|
30
|
-
"jest": "29.4.1",
|
|
31
|
-
"rimraf": "4.1.2",
|
|
32
|
-
"ts-jest": "29.0.5",
|
|
33
|
-
"typescript": "4.9.4"
|
|
29
|
+
"esbuild": "^0.25.8"
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
36
|
-
"@aws-sdk/client-dynamodb": "3.
|
|
37
|
-
"@aws-sdk/client-ecs": "3.
|
|
38
|
-
"@aws-sdk/client-s3": "
|
|
39
|
-
"@aws-sdk/s3-request-presigner": "
|
|
32
|
+
"@aws-sdk/client-dynamodb": "3.848.0",
|
|
33
|
+
"@aws-sdk/client-ecs": "3.848.0",
|
|
34
|
+
"@aws-sdk/client-s3": "3.850.0",
|
|
35
|
+
"@aws-sdk/s3-request-presigner": "3.850.0",
|
|
40
36
|
"@squiz/dx-common-lib": "^1.66.1",
|
|
41
37
|
"@squiz/dx-json-schema-lib": "1.78.1",
|
|
42
38
|
"@squiz/dx-logger-lib": "^1.64.0",
|
|
43
|
-
"axios": "1.
|
|
44
|
-
"cli-color": "^2.0.
|
|
39
|
+
"axios": "1.11.0",
|
|
40
|
+
"cli-color": "^2.0.4",
|
|
45
41
|
"dotenv": "16.0.3",
|
|
46
42
|
"fs-extra": "11.1.0",
|
|
47
43
|
"inversify": "6.0.1",
|
|
@@ -8,7 +8,10 @@ import { JobExecution } from '../model/JobExecution';
|
|
|
8
8
|
|
|
9
9
|
@provideTransient(JobDetailsRepository)
|
|
10
10
|
export class JobDetailsRepository extends S3RepositoryBase {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
@inject(S3Client) protected s3Client: S3Client,
|
|
13
|
+
@inject('JobDetailsBucketName') bucketName: string,
|
|
14
|
+
) {
|
|
12
15
|
super(s3Client, bucketName);
|
|
13
16
|
}
|
|
14
17
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
HeadObjectCommand,
|
|
12
12
|
HeadObjectCommandOutput,
|
|
13
13
|
PutObjectCommand,
|
|
14
|
-
|
|
14
|
+
PutObjectCommandInput,
|
|
15
15
|
S3Client,
|
|
16
16
|
} from '@aws-sdk/client-s3';
|
|
17
17
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
@@ -26,7 +26,10 @@ import 'reflect-metadata';
|
|
|
26
26
|
@injectable()
|
|
27
27
|
export abstract class S3RepositoryBase {
|
|
28
28
|
protected bucketName: string;
|
|
29
|
-
public constructor(
|
|
29
|
+
public constructor(
|
|
30
|
+
@inject(S3Client) protected s3Client: S3Client,
|
|
31
|
+
bucketName: string,
|
|
32
|
+
) {
|
|
30
33
|
this.bucketName = bucketName;
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -37,7 +40,7 @@ export abstract class S3RepositoryBase {
|
|
|
37
40
|
* @return {Promise<void>}
|
|
38
41
|
* @memberof S3Repository
|
|
39
42
|
*/
|
|
40
|
-
async put(key: string, body:
|
|
43
|
+
async put(key: string, body: PutObjectCommandInput['Body']): Promise<void> {
|
|
41
44
|
await this.s3Client.send(
|
|
42
45
|
new PutObjectCommand({
|
|
43
46
|
Bucket: this.bucketName,
|
|
@@ -24,7 +24,7 @@ describe('PaginationService', (): void => {
|
|
|
24
24
|
let mockData;
|
|
25
25
|
let mockPaginationInfo: PaginationInfo;
|
|
26
26
|
let mockExclusiveStartKey: Record<string, AttributeValue>;
|
|
27
|
-
|
|
27
|
+
const mockLastEvaluatedKey: string | null = null;
|
|
28
28
|
|
|
29
29
|
beforeEach(() => {
|
|
30
30
|
jest.resetAllMocks();
|
|
@@ -13,7 +13,10 @@ import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
|
|
|
13
13
|
* @extends {ErrorWithHttpStatusCode}
|
|
14
14
|
*/
|
|
15
15
|
export class BadRequestError extends ErrorWithHttpStatusCode {
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
public details: string,
|
|
18
|
+
message = ERRORS.badRequest.name,
|
|
19
|
+
) {
|
|
17
20
|
super(ERRORS.badRequest.code, message, details);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* @extends {Error}
|
|
11
11
|
*/
|
|
12
12
|
export class ErrorWithHttpStatusCode extends Error {
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
public statusCode: number,
|
|
15
|
+
public message: string,
|
|
16
|
+
public details: string,
|
|
17
|
+
) {
|
|
14
18
|
super(message);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
@@ -13,7 +13,10 @@ import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
|
|
|
13
13
|
* @extends {ErrorWithHttpStatusCode}
|
|
14
14
|
*/
|
|
15
15
|
export class InternalServerError extends ErrorWithHttpStatusCode {
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
public details: string,
|
|
18
|
+
message = ERRORS.internalServerError.name,
|
|
19
|
+
) {
|
|
17
20
|
super(ERRORS.internalServerError.code, message, details);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -13,7 +13,10 @@ import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
|
|
|
13
13
|
* @extends {ErrorWithHttpStatusCode}
|
|
14
14
|
*/
|
|
15
15
|
export class NotImplementedError extends ErrorWithHttpStatusCode {
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
public details: string,
|
|
18
|
+
message = ERRORS.notImplemented.name,
|
|
19
|
+
) {
|
|
17
20
|
super(ERRORS.notImplemented.code, message, details);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -13,7 +13,10 @@ import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
|
|
|
13
13
|
* @extends {ErrorWithHttpStatusCode}
|
|
14
14
|
*/
|
|
15
15
|
export class UnprocessableContentError extends ErrorWithHttpStatusCode {
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
public details: string,
|
|
18
|
+
message = ERRORS.unprocessableContent.name,
|
|
19
|
+
) {
|
|
17
20
|
super(ERRORS.unprocessableContent.code, message, details);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -4,7 +4,10 @@ import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
6
|
export class JobManifestV1 {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(
|
|
8
|
+
protected manifest: JobManifestV1Model,
|
|
9
|
+
protected manifestPath: string,
|
|
10
|
+
) {}
|
|
8
11
|
|
|
9
12
|
public static getJobSchemaVersionRegex(): RegExp {
|
|
10
13
|
return /\/schemas\/(?<schema>JobV\d+)\.json#?$/;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ECSClient, LaunchType, ListTasksCommand, RunTaskCommand } from '@aws-sdk/client-ecs';
|
|
7
|
-
import { JOB_EXECUTION_STATUS } from '../../constants/JobExecutionStatus.constants';
|
|
6
|
+
import { DesiredStatus, ECSClient, LaunchType, ListTasksCommand, RunTaskCommand } from '@aws-sdk/client-ecs';
|
|
8
7
|
import { getAwsTags } from '../../utils';
|
|
9
8
|
import { ListRunningTasksParams, RunJobTaskParams } from './JobExecutionTaskService.defs';
|
|
10
9
|
import { JobDetailsRepository, S3Repository } from '../../S3Repository';
|
|
@@ -26,7 +25,7 @@ export class JobExecutionTaskService {
|
|
|
26
25
|
cluster: params.clusterArn,
|
|
27
26
|
family: params.runtimeTaskFamily,
|
|
28
27
|
maxResults: params.maxTenantConcurrentTasks + 1,
|
|
29
|
-
desiredStatus:
|
|
28
|
+
desiredStatus: DesiredStatus.RUNNING,
|
|
30
29
|
};
|
|
31
30
|
const command = new ListTasksCommand(input);
|
|
32
31
|
const response = await this.ecsClient.send(command);
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
|
-
|
|
4
3
|
"compilerOptions": {
|
|
5
4
|
"outDir": "lib/",
|
|
6
|
-
"resolveJsonModule": true,
|
|
7
|
-
"composite": true,
|
|
8
5
|
"rootDir": "./src",
|
|
9
|
-
"
|
|
10
|
-
"emitDeclarationOnly": true,
|
|
11
|
-
"declaration": true
|
|
6
|
+
"emitDeclarationOnly": true
|
|
12
7
|
},
|
|
13
|
-
|
|
14
8
|
"references": [],
|
|
15
|
-
|
|
16
9
|
"include": ["src/**/*.ts", "src/**/*.json"],
|
|
17
10
|
"exclude": ["jest.config.ts"]
|
|
18
11
|
}
|