/*! * @license * Copyright Squiz Australia Pty Ltd. All Rights Reserved. */ import { AttributeValue } from '@aws-sdk/client-dynamodb'; import { JobExecutionStatus } from '../../constants/JobExecutionStatus.constants'; import { ListParameters } from '../Base'; /** * JobExecution interface. * @export * @interface JobExecution */ export interface JobExecution { /** * The id of the job execution. * @type {string} * @memberof JobExecution */ id: string; /** * The name of the job. * @type {string} * @memberof JobExecution */ jobName: string; /** * The id of the context to run the job against. * @type {string} * @memberof JobExecution */ context: string; /** * The status of the job run. * @type {string} * @memberof JobExecution */ status: JobExecutionStatus; /** * The time the job execution was added to the queue. * @type {string} * @memberof JobExecution */ timeQueued: string; /** * The version of the job script to execute. * @type {(string)} * @memberof JobExecution */ version: string; /** * The ECS task ID of the job run. * @type {(string | null)} * @memberof JobExecution */ ecsTaskId: string | null; /** * The time the job run was started. * @type {(string | null)} * @memberof JobExecution */ timeStarted: string | null; /** * The time the job run was finished. * @type {(string | null)} * @memberof JobExecution */ timeFinished: string | null; /** * The input to the job. * @type {any} * @memberof JobExecution */ input: any; /** * The DynamoDB record type (dynamic, 'jobExecution-'). * @type {string} * @memberof JobExecution */ type: string; /** * The number of times the container start has been retried. * @type {number} * @memberof JobExecution */ retryCount: number; /** * The reason for the last container start failure (if any). * @type {(string | null)} * @memberof JobExecution */ lastFailureReason: string | null; /** * ISO timestamp indicating when the execution can be retried. * Used to implement exponential backoff - executions with retryAfter > now should be skipped. * @type {(string | null)} * @memberof JobExecution */ retryAfter: string | null; } /** * The JobExecution record attributes stored in DynamoDB. * @export * @interface JobExecutionRecord */ export interface JobExecutionRecord { /** * The partition key ('jobExecution~'). * @type {string} * @memberof JobExecutionRecord */ pk: string; /** * The sort key ('~'). * @type {string} * @memberof JobExecutionRecord */ sk: string; /** * Secondary sort key ('~'). * @type {string} * @memberof JobExecutionRecord */ lsi1sk: string; /** * Global secondary partition key ('jobExecution~'). * @type {string} * @memberof JobExecutionRecord */ gsi1pk: string; /** * The name of the job to execute. * @type {string} * @memberof JobExecutionRecord */ jobName: string; /** * The id of the job execution. * @type {string} * @memberof JobExecutionRecord */ id: string; /** * The time the job execution was added to the queue. * @type {string} * @memberof JobExecutionRecord */ timeQueued: string; /** * The id of the context to run the job against. * @type {string} * @memberof JobExecutionRecord */ context: string; /** * The status of the job run. * @type {JobExecutionStatus} * @memberof JobExecutionRecord */ status: JobExecutionStatus; /** * The version of the job script to execute. * @type @type {(string)} * @memberof JobExecutionRecord */ version: string; /** * The ECS task ID of the job run. * @type @type {(string | null)} * @memberof JobExecutionRecord */ ecsTaskId: string | null; /** * The time the job run was started. * @type @type {(string | null)} * @memberof JobExecutionRecord */ timeStarted: string | null; /** * The time the job run was finished. * @type {(string | null)} * @memberof JobExecutionRecord */ timeFinished: string | null; /** * The input to the job. * @type {any} * @memberof JobExecutionRecord */ input: any; /** * The number of times the container start has been retried. * @type {number} * @memberof JobExecutionRecord */ retryCount: number; /** * The reason for the last container start failure (if any). * @type {(string | null)} * @memberof JobExecutionRecord */ lastFailureReason: string | null; /** * ISO timestamp indicating when the execution can be retried. * Used to implement exponential backoff - executions with retryAfter > now should be skipped. * @type {(string | null)} * @memberof JobExecutionRecord */ retryAfter: string | null; } export type JobExecutionDto = Record; /** * The request body for adding an item to the job queue (POST /job/begin). * @export */ export type BeginJobExecutionRequest = Pick & Partial>; /** * The parameters for creating a job execution entity in the DB. * @export */ export type CreateJobExecutionRequest = Pick & Partial>; /** * The request body for terminating a job in the job queue (POST /job/terminate). * @export */ export interface TerminateJobExecutionRequest { jobName: string; executionId: string; reason: string; } /** * The parameters for listing job executions. * @export */ export type ListJobExecutionParameters = ListParameters>>; /** * The parameters for updating job executions. * @export */ export type UpdateJobExecutionParameters = Partial>; export type JobExecutionSk = Pick; /** * Array of job executions keys by tenant. */ export type JobExecutionsByTenant = Record>;