@squiz/job-runner-lib 2.8.0 → 2.10.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/domains/job/constants/QueueBacklog.constants.d.ts +11 -0
  3. package/lib/domains/job/constants/RuntimeImage.constants.d.ts +3 -4
  4. package/lib/domains/job/constants/RuntimeImage.constants.spec.d.ts +5 -0
  5. package/lib/domains/job/index.d.ts +1 -0
  6. package/lib/domains/job/repository/JobExecutionRepository/JobExecutionRepository.d.ts +15 -0
  7. package/lib/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.d.ts +1 -1
  8. package/lib/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.spec.d.ts +5 -0
  9. package/lib/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.types.d.ts +1 -1
  10. package/lib/index.js +9 -9
  11. package/lib/index.js.map +4 -4
  12. package/package.json +1 -1
  13. package/src/domains/job/constants/QueueBacklog.constants.ts +12 -0
  14. package/src/domains/job/constants/RuntimeImage.constants.spec.ts +26 -0
  15. package/src/domains/job/constants/RuntimeImage.constants.ts +6 -9
  16. package/src/domains/job/index.ts +1 -0
  17. package/src/domains/job/manifest/mocks/JobManifest.mock.ts +2 -2
  18. package/src/domains/job/manifest/mocks/JobManifestDto.mock.ts +2 -2
  19. package/src/domains/job/manifest/mocks/JobManifestRecord.mock.ts +2 -2
  20. package/src/domains/job/manifest/mocks/JobManifestRequest.mock.ts +2 -2
  21. package/src/domains/job/repository/JobExecutionRepository/JobExecutionRepository.spec.ts +65 -0
  22. package/src/domains/job/repository/JobExecutionRepository/JobExecutionRepository.ts +53 -0
  23. package/src/domains/job/repository/JobManifestRepository/JobManifestRepository.spec.ts +24 -3
  24. package/src/domains/job/repository/JobRepository/JobRepository.spec.ts +24 -3
  25. package/src/domains/job/services/JobExecutionTaskService/JobExecutionTaskService.spec.ts +5 -6
  26. package/src/domains/job/services/JobExecutionTaskService/JobExecutionTaskService.ts +1 -1
  27. package/src/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.spec.ts +64 -0
  28. package/src/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.ts +2 -5
  29. package/src/domains/job/utils/ResolveRuntimeImageTaskDefinitionArn/ResolveRuntimeImageTaskDefinitionArn.types.ts +1 -1
  30. package/src/domains/manifest/utils/validateRuntimeImage.spec.ts +0 -8
  31. package/src/domains/manifest/utils/validateRuntimeImage.ts +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4c30a4d: Remove Node 20 runtime support
8
+
9
+ ## 2.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 89bb566: Mark node:20 runtime image as deprecated
14
+
3
15
  ## 2.8.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * @license
3
+ * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
+ */
5
+ /**
6
+ * Backlog guard defaults. A job's `begin` is rejected with 422 once it has more than
7
+ * DEFAULT_MAX_QUEUED_EXECUTIONS queued AND its oldest queued execution is older than
8
+ * DEFAULT_MAX_QUEUED_AGE_HOURS. Both conditions are required (large AND stale).
9
+ */
10
+ export declare const DEFAULT_MAX_QUEUED_EXECUTIONS = 500;
11
+ export declare const DEFAULT_MAX_QUEUED_AGE_HOURS = 2;
@@ -2,15 +2,14 @@
2
2
  * @license
3
3
  * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
4
  */
5
- export declare const SUPPORTED_RUNTIME_IMAGES: readonly ["node:20", "node:24"];
6
- export declare const LEGACY_RUNTIME_IMAGE = "node:20";
5
+ export declare const SUPPORTED_RUNTIME_IMAGES: readonly ["node:24"];
7
6
  export declare const RECOMMENDED_RUNTIME_IMAGE = "node:24";
8
7
  export declare const DEPRECATED_RUNTIME_IMAGES: readonly string[];
8
+ export declare const isDeprecatedRuntimeImage: (image: string) => boolean;
9
9
  export declare const getRuntimeImageOrDefault: (image: string | null | undefined) => string;
10
10
  export declare const isSupportedRuntimeImage: (image: string) => boolean;
11
- export declare const isDeprecatedRuntimeImage: (image: string) => boolean;
12
11
  export declare const getRuntimeImagesMetadata: () => {
13
- supportedRuntimeImages: ("node:20" | "node:24")[];
12
+ supportedRuntimeImages: "node:24"[];
14
13
  deprecatedRuntimeImages: string[];
15
14
  recommendedRuntimeImage: string;
16
15
  };
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * @license
3
+ * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
+ */
5
+ export {};
@@ -2,6 +2,7 @@ export * from './core/dynamoClient.mock';
2
2
  export * from './core/pagination';
3
3
  export * from './constants/InjectTokens';
4
4
  export * from './constants/JobExecutionStatus.constants';
5
+ export * from './constants/QueueBacklog.constants';
5
6
  export * from './constants/Repository.constants';
6
7
  export * from './constants/RetryConfig.constants';
7
8
  export * from './constants/RuntimeImage.constants';
@@ -16,6 +16,21 @@ export declare class JobExecutionRepository extends Repository<JobExecution, Job
16
16
  * @memberof JobExecutionRepository
17
17
  */
18
18
  list(parameters?: ListJobExecutionParameters): Promise<Array<JobExecution>>;
19
+ /**
20
+ * Returns the single oldest queued execution for a job, or null if there are none.
21
+ *
22
+ * Queries the `lsi1` index (`lsi1sk = "<status>~<jobName>"`). All queued executions of one
23
+ * job share the same `lsi1sk`, so DynamoDB breaks ties by the base-table `sk`
24
+ * (`"<jobName>~<id>"`); `id` is prefixed with the ISO `timeQueued`, which sorts
25
+ * lexicographically, so ascending order is chronological and the first item is the oldest.
26
+ */
27
+ getOldestQueuedExecution(jobName: string): Promise<JobExecution | null>;
28
+ /**
29
+ * Counts queued executions for a job, evaluating at most `limit` items (`Select: COUNT` so no
30
+ * item data is returned). Pass a `limit` just above the threshold you care about — queued
31
+ * items are small, so a single page covers the bounded count.
32
+ */
33
+ countQueuedExecutions(jobName: string, limit?: number): Promise<number>;
19
34
  /**
20
35
  * Get list of records from database.
21
36
  * @abstract
@@ -3,4 +3,4 @@
3
3
  * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
4
  */
5
5
  import { ResolveRuntimeImageTaskDefinitionArnParams } from './ResolveRuntimeImageTaskDefinitionArn.types';
6
- export declare const resolveRuntimeImageTaskDefinitionArn: ({ image, taskDefinitionArnsByRuntimeImage, legacyTaskDefinitionArn, }: ResolveRuntimeImageTaskDefinitionArnParams) => string;
6
+ export declare const resolveRuntimeImageTaskDefinitionArn: ({ image, taskDefinitionArnsByRuntimeImage, defaultTaskDefinitionArn, }: ResolveRuntimeImageTaskDefinitionArnParams) => string;
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * @license
3
+ * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
+ */
5
+ export {};
@@ -5,5 +5,5 @@
5
5
  export interface ResolveRuntimeImageTaskDefinitionArnParams {
6
6
  image: string | null | undefined;
7
7
  taskDefinitionArnsByRuntimeImage: Record<string, string>;
8
- legacyTaskDefinitionArn: string;
8
+ defaultTaskDefinitionArn: string;
9
9
  }