From b5fa6a3208a8f2a39777dc30c2db2f498addb907 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Mon, 9 Dec 2024 22:39:04 -0600 Subject: [PATCH] fix(job-scheduler): omit deduplication and debounce options from template options (#2960) --- src/classes/job-scheduler.ts | 8 ++++++-- src/classes/queue.ts | 9 +++++++-- src/interfaces/job-scheduler-json.ts | 4 ++-- src/types/index.ts | 1 + src/types/job-scheduler-template-options.ts | 6 ++++++ 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/types/job-scheduler-template-options.ts diff --git a/src/classes/job-scheduler.ts b/src/classes/job-scheduler.ts index bd47466ce5..c728f50834 100644 --- a/src/classes/job-scheduler.ts +++ b/src/classes/job-scheduler.ts @@ -6,7 +6,11 @@ import { RepeatBaseOptions, RepeatOptions, } from '../interfaces'; -import { JobsOptions, RepeatStrategy } from '../types'; +import { + JobSchedulerTemplateOptions, + JobsOptions, + RepeatStrategy, +} from '../types'; import { Job } from './job'; import { QueueBase } from './queue-base'; import { RedisConnection } from './redis-connection'; @@ -32,7 +36,7 @@ export class JobScheduler extends QueueBase { repeatOpts: Omit, jobName: N, jobData: T, - opts: Omit, + opts: JobSchedulerTemplateOptions, { override }: { override: boolean }, ): Promise | undefined> { const { every, pattern } = repeatOpts; diff --git a/src/classes/queue.ts b/src/classes/queue.ts index 1525d13254..34cb1a4bd8 100644 --- a/src/classes/queue.ts +++ b/src/classes/queue.ts @@ -8,7 +8,12 @@ import { RepeatableJob, RepeatOptions, } from '../interfaces'; -import { FinishedStatus, JobsOptions, MinimalQueue } from '../types'; +import { + FinishedStatus, + JobsOptions, + JobSchedulerTemplateOptions, + MinimalQueue, +} from '../types'; import { Job } from './job'; import { QueueGetters } from './queue-getters'; import { Repeat } from './repeat'; @@ -433,7 +438,7 @@ export class Queue< jobTemplate?: { name?: NameType; data?: DataType; - opts?: Omit; + opts?: JobSchedulerTemplateOptions; }, ) { if (repeatOpts.endDate) { diff --git a/src/interfaces/job-scheduler-json.ts b/src/interfaces/job-scheduler-json.ts index 90796f5dd5..150d08873e 100644 --- a/src/interfaces/job-scheduler-json.ts +++ b/src/interfaces/job-scheduler-json.ts @@ -1,8 +1,8 @@ -import { JobsOptions } from '../types'; +import { JobSchedulerTemplateOptions } from '../types'; export interface JobSchedulerTemplateJson { data?: D; - opts?: Omit; + opts?: JobSchedulerTemplateOptions; } export interface JobSchedulerJson { diff --git a/src/types/index.ts b/src/types/index.ts index 7d30742ac9..c2ec6b49e8 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -3,5 +3,6 @@ export * from './finished-status'; export * from './minimal-queue'; export * from './job-json-sandbox'; export * from './job-options'; +export * from './job-scheduler-template-options'; export * from './job-type'; export * from './repeat-strategy'; diff --git a/src/types/job-scheduler-template-options.ts b/src/types/job-scheduler-template-options.ts new file mode 100644 index 0000000000..57bbfd6b31 --- /dev/null +++ b/src/types/job-scheduler-template-options.ts @@ -0,0 +1,6 @@ +import { JobsOptions } from './job-options'; + +export type JobSchedulerTemplateOptions = Omit< + JobsOptions, + 'jobId' | 'repeat' | 'delay' | 'deduplication' | 'debounce' +>;