@types/bull
Advanced tools
Comparing version 3.0.2 to 3.3.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for bull 3.0 | ||
// Type definitions for bull 3.3 | ||
// Project: https://github.com/OptimalBits/bull | ||
@@ -6,5 +6,8 @@ // Definitions by: Bruno Grieder <https://github.com/bgrieder> | ||
// Marshall Cottrell <https://github.com/marshall007> | ||
// Weeco <https://github.com/weeco> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 | ||
import * as Redis from "ioredis"; | ||
import * as Promise from "bluebird"; | ||
@@ -17,405 +20,589 @@ /** | ||
declare const Bull: { | ||
// tslint:disable:unified-signatures | ||
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue; | ||
(queueName: string, url?: string): Bull.Queue; | ||
new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; | ||
new (queueName: string, url?: string): Bull.Queue; | ||
// tslint:enable:unified-signatures | ||
// tslint:disable:unified-signatures | ||
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue; | ||
(queueName: string, url?: string): Bull.Queue; | ||
new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; | ||
new (queueName: string, url?: string): Bull.Queue; | ||
// tslint:enable:unified-signatures | ||
}; | ||
declare namespace Bull { | ||
interface QueueOptions { | ||
/** | ||
* Options passed directly to the `ioredis` constructor | ||
*/ | ||
redis?: Redis.RedisOptions; | ||
interface RateLimiter { | ||
/** Max numbers of jobs processed */ | ||
max: number; | ||
/** Per duration in milliseconds */ | ||
duration: number; | ||
} | ||
/** | ||
* When specified, the `Queue` will use this function to create new `ioredis` client connections. | ||
* This is useful if you want to re-use connections. | ||
*/ | ||
createClient?(type: 'client' | 'subscriber', redisOpts?: Redis.RedisOptions): Redis.Redis; | ||
interface QueueOptions { | ||
/** | ||
* Options passed directly to the `ioredis` constructor | ||
*/ | ||
redis?: Redis.RedisOptions; | ||
/** | ||
* Prefix to use for all redis keys | ||
*/ | ||
prefix?: string; | ||
/** | ||
* When specified, the `Queue` will use this function to create new `ioredis` client connections. | ||
* This is useful if you want to re-use connections. | ||
*/ | ||
createClient?(type: 'client' | 'subscriber', redisOpts?: Redis.RedisOptions): Redis.Redis; | ||
settings?: AdvancedSettings; | ||
} | ||
/** | ||
* Prefix to use for all redis keys | ||
*/ | ||
prefix?: string; | ||
interface AdvancedSettings { | ||
/** | ||
* Key expiration time for job locks | ||
*/ | ||
lockDuration?: number; | ||
settings?: AdvancedSettings; | ||
/** | ||
* How often check for stalled jobs (use 0 for never checking) | ||
*/ | ||
stalledInterval?: number; | ||
limiter?: RateLimiter; | ||
} | ||
/** | ||
* Max amount of times a stalled job will be re-processed | ||
*/ | ||
maxStalledCount?: number; | ||
interface AdvancedSettings { | ||
/** | ||
* Key expiration time for job locks | ||
*/ | ||
lockDuration?: number; | ||
/** | ||
* Poll interval for delayed jobs and added jobs | ||
*/ | ||
guardInterval?: number; | ||
/** | ||
* How often check for stalled jobs (use 0 for never checking) | ||
*/ | ||
stalledInterval?: number; | ||
/** | ||
* Delay before processing next job in case of internal error | ||
*/ | ||
retryProcessDelay?: number; | ||
} | ||
/** | ||
* Max amount of times a stalled job will be re-processed | ||
*/ | ||
maxStalledCount?: number; | ||
type DoneCallback = (error?: Error | null, value?: any) => void; | ||
/** | ||
* Poll interval for delayed jobs and added jobs | ||
*/ | ||
guardInterval?: number; | ||
type JobId = number | string; | ||
/** | ||
* Delay before processing next job in case of internal error | ||
*/ | ||
retryProcessDelay?: number; | ||
} | ||
interface Job { | ||
id: JobId; | ||
type DoneCallback = (error?: Error | null, value?: any) => void; | ||
/** | ||
* The custom data passed when the job was created | ||
*/ | ||
data: any; | ||
type JobId = number | string; | ||
/** | ||
* Report progress on a job | ||
*/ | ||
progress(value: any): Promise<void>; | ||
interface Job { | ||
id: JobId; | ||
/** | ||
* Removes a job from the queue and from any lists it may be included in. | ||
* @returns A promise that resolves when the job is removed. | ||
*/ | ||
remove(): Promise<void>; | ||
/** | ||
* The custom data passed when the job was created | ||
*/ | ||
data: any; | ||
/** | ||
* Re-run a job that has failed. | ||
* @returns A promise that resolves when the job is scheduled for retry. | ||
*/ | ||
retry(): Promise<void>; | ||
/** | ||
* Report progress on a job | ||
*/ | ||
progress(value: any): Promise<void>; | ||
/** | ||
* Returns a promise the resolves when the job has been finished. | ||
* TODO: Add a watchdog to check if the job has finished periodically. | ||
* since pubsub does not give any guarantees. | ||
*/ | ||
finished(): Promise<void>; | ||
/** | ||
* Returns a promise resolving to the current job's status. | ||
* Please take note that the implementation of this method is not very efficient, nor is | ||
* it atomic. If your queue does have a very large quantity of jobs, you may want to | ||
* avoid using this method. | ||
*/ | ||
getState(): Promise<JobStatus>; | ||
/** | ||
* Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible. | ||
*/ | ||
promote(): Promise<void>; | ||
} | ||
/** | ||
* Update a specific job's data. Promise resolves when the job has been updated. | ||
*/ | ||
update(data: any): Promise<void>; | ||
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed'; | ||
/** | ||
* Removes a job from the queue and from any lists it may be included in. | ||
* The returned promise resolves when the job has been removed. | ||
*/ | ||
remove(): Promise<void>; | ||
interface BackoffOptions { | ||
/** | ||
* Backoff type, which can be either `fixed` or `exponential` | ||
*/ | ||
type: 'fixed' | 'exponential'; | ||
/** | ||
* Re-run a job that has failed. The returned promise resolves when the job | ||
* has been scheduled for retry. | ||
*/ | ||
retry(): Promise<void>; | ||
/** | ||
* Backoff delay, in milliseconds | ||
*/ | ||
delay: number; | ||
} | ||
/** | ||
* Returns a promise that resolves to the returned data when the job has been finished. | ||
* TODO: Add a watchdog to check if the job has finished periodically. | ||
* since pubsub does not give any guarantees. | ||
*/ | ||
finished(): Promise<any>; | ||
interface RepeatOptions { | ||
/** | ||
* Cron pattern specifying when the job should execute | ||
*/ | ||
cron: string; | ||
/** | ||
* Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible. | ||
*/ | ||
promote(): Promise<void>; | ||
} | ||
/** | ||
* Timezone | ||
*/ | ||
tz?: string; | ||
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed'; | ||
/** | ||
* End date when the repeat job should stop repeating | ||
*/ | ||
endDate?: Date | string | number; | ||
} | ||
interface BackoffOptions { | ||
/** | ||
* Backoff type, which can be either `fixed` or `exponential` | ||
*/ | ||
type: 'fixed' | 'exponential'; | ||
interface JobOptions { | ||
/** | ||
* Optional priority value. ranges from 1 (highest priority) to MAX_INT (lowest priority). | ||
* Note that using priorities has a slight impact on performance, so do not use it if not required | ||
*/ | ||
priority?: number; | ||
/** | ||
* Backoff delay, in milliseconds | ||
*/ | ||
delay: number; | ||
} | ||
/** | ||
* An amount of miliseconds to wait until this job can be processed. | ||
* Note that for accurate delays, both server and clients should have their clocks synchronized. [optional] | ||
*/ | ||
delay?: number; | ||
interface RepeatOptions { | ||
/** | ||
* Cron pattern specifying when the job should execute | ||
*/ | ||
cron: string; | ||
/** | ||
* The total number of attempts to try the job until it completes | ||
*/ | ||
attempts?: number; | ||
/** | ||
* Timezone | ||
*/ | ||
tz?: string; | ||
/** | ||
* Repeat job according to a cron specification | ||
*/ | ||
repeat?: RepeatOptions; | ||
/** | ||
* End date when the repeat job should stop repeating | ||
*/ | ||
endDate?: Date | string | number; | ||
} | ||
/** | ||
* Backoff setting for automatic retries if the job fails | ||
*/ | ||
backoff?: number | BackoffOptions; | ||
interface JobOptions { | ||
/** | ||
* Optional priority value. ranges from 1 (highest priority) to MAX_INT (lowest priority). | ||
* Note that using priorities has a slight impact on performance, so do not use it if not required | ||
*/ | ||
priority?: number; | ||
/** | ||
* A boolean which, if true, adds the job to the right | ||
* of the queue instead of the left (default false) | ||
*/ | ||
lifo?: boolean; | ||
/** | ||
* An amount of miliseconds to wait until this job can be processed. | ||
* Note that for accurate delays, both server and clients should have their clocks synchronized. [optional] | ||
*/ | ||
delay?: number; | ||
/** | ||
* The number of milliseconds after which the job should be fail with a timeout error | ||
*/ | ||
timeout?: number; | ||
/** | ||
* The total number of attempts to try the job until it completes | ||
*/ | ||
attempts?: number; | ||
/** | ||
* Override the job ID - by default, the job ID is a unique | ||
* integer, but you can use this setting to override it. | ||
* If you use this option, it is up to you to ensure the | ||
* jobId is unique. If you attempt to add a job with an id that | ||
* already exists, it will not be added. | ||
*/ | ||
jobId?: JobId; | ||
/** | ||
* Repeat job according to a cron specification | ||
*/ | ||
repeat?: RepeatOptions; | ||
/** | ||
* A boolean which, if true, removes the job when it successfully completes. | ||
* Default behavior is to keep the job in the completed set. | ||
*/ | ||
removeOnComplete?: boolean; | ||
/** | ||
* Backoff setting for automatic retries if the job fails | ||
*/ | ||
backoff?: number | BackoffOptions; | ||
/** | ||
* A boolean which, if true, removes the job when it fails after all attempts | ||
* Default behavior is to keep the job in the completed set. | ||
*/ | ||
removeOnFail?: boolean; | ||
} | ||
/** | ||
* A boolean which, if true, adds the job to the right | ||
* of the queue instead of the left (default false) | ||
*/ | ||
lifo?: boolean; | ||
interface JobCounts { | ||
wait: number; | ||
active: number; | ||
completed: number; | ||
failed: number; | ||
delayed: number; | ||
} | ||
/** | ||
* The number of milliseconds after which the job should be fail with a timeout error | ||
*/ | ||
timeout?: number; | ||
interface Queue { | ||
/** | ||
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs. | ||
* This replaces the `ready` event emitted on Queue in previous verisons. | ||
*/ | ||
isReady(): Promise<this>; | ||
/** | ||
* Override the job ID - by default, the job ID is a unique | ||
* integer, but you can use this setting to override it. | ||
* If you use this option, it is up to you to ensure the | ||
* jobId is unique. If you attempt to add a job with an id that | ||
* already exists, it will not be added. | ||
*/ | ||
jobId?: JobId; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
* | ||
* concurrency: Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(concurrency: number, callback: (job: Job, done: DoneCallback) => void): void; | ||
/** | ||
* A boolean which, if true, removes the job when it successfully completes. | ||
* Default behavior is to keep the job in the completed set. | ||
*/ | ||
removeOnComplete?: boolean; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
*/ | ||
process(callback: (job: Job, done: DoneCallback) => void): void; | ||
/** | ||
* A boolean which, if true, removes the job when it fails after all attempts | ||
* Default behavior is to keep the job in the completed set. | ||
*/ | ||
removeOnFail?: boolean; | ||
} | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
* | ||
* concurrency: Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(concurrency: number, callback: (job: Job) => void): Promise<any>; | ||
interface JobCounts { | ||
wait: number; | ||
active: number; | ||
completed: number; | ||
failed: number; | ||
delayed: number; | ||
} | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
*/ | ||
process(callback: (job: Job) => void): Promise<any>; | ||
interface JobInformation { | ||
key: string; | ||
name: string; | ||
id?: string; | ||
endDate?: number; | ||
tz?: string; | ||
cron: string; | ||
next: number; | ||
} | ||
/** | ||
* Creates a new job and adds it to the queue. | ||
* If the queue is empty the job will be executed directly, | ||
* otherwise it will be placed in the queue and executed as soon as possible. | ||
*/ | ||
add(data: any, opts?: JobOptions): Promise<Job>; | ||
interface Queue { | ||
/** | ||
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs. | ||
* This replaces the `ready` event emitted on Queue in previous verisons. | ||
*/ | ||
isReady(): Promise<this>; | ||
/** | ||
* Returns a promise that resolves when the queue is paused. | ||
* The pause is global, meaning that all workers in all queue instances for a given queue will be paused. | ||
* A paused queue will not process new jobs until resumed, | ||
* but current jobs being processed will continue until they are finalized. | ||
* | ||
* Pausing a queue that is already paused does nothing. | ||
*/ | ||
pause(): Promise<void>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
*/ | ||
process(callback: (job: Job, done: DoneCallback) => void): void; | ||
/** | ||
* Returns a promise that resolves when the queue is resumed after being paused. | ||
* The resume is global, meaning that all workers in all queue instances for a given queue will be resumed. | ||
* | ||
* Resuming a queue that is not paused does nothing. | ||
*/ | ||
resume(): Promise<void>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
*/ | ||
process(callback: (job: Job) => void): Promise<any>; | ||
/** | ||
* Returns a promise that returns the number of jobs in the queue, waiting or paused. | ||
* Since there may be other processes adding or processing jobs, this value may be true only for a very small amount of time. | ||
*/ | ||
count(): Promise<number>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
* | ||
* @param concurrency Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(concurrency: number, callback: (job: Job) => void): Promise<any>; | ||
/** | ||
* Empties a queue deleting all the input lists and associated jobs. | ||
*/ | ||
empty(): Promise<void>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
* | ||
* @param concurrency Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(concurrency: number, callback: (job: Job, done: DoneCallback) => void): void; | ||
/** | ||
* Closes the underlying redis client. Use this to perform a graceful shutdown. | ||
* | ||
* `close` can be called from anywhere, with one caveat: | ||
* if called from within a job handler the queue won't close until after the job has been processed | ||
*/ | ||
close(): Promise<void>; | ||
/** | ||
* Defines a named processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
* | ||
* @param name Bull will only call the handler if the job name matches | ||
*/ | ||
// tslint:disable-next-line:unified-signatures | ||
process(name: string, callback: (job: Job) => void): Promise<any>; | ||
/** | ||
* Returns a promise that will return the job instance associated with the jobId parameter. | ||
* If the specified job cannot be located, the promise callback parameter will be set to null. | ||
*/ | ||
getJob(jobId: JobId): Promise<Job>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
* | ||
* @param name Bull will only call the handler if the job name matches | ||
*/ | ||
// tslint:disable-next-line:unified-signatures | ||
process(name: string, callback: (job: Job, done: DoneCallback) => void): void; | ||
/** | ||
* Returns a promise that resolves with the job counts for the given queue | ||
*/ | ||
getJobCounts(): Promise<JobCounts>; | ||
/** | ||
* Defines a named processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* A promise must be returned to signal job completion. | ||
* If the promise is rejected, the error will be passed as a second argument to the "failed" event. | ||
* If it is resolved, its value will be the "completed" event's second argument. | ||
* | ||
* @param name Bull will only call the handler if the job name matches | ||
* @param concurrency Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(name: string, concurrency: number, callback: (job: Job) => void): Promise<any>; | ||
/** | ||
* Tells the queue remove all jobs created outside of a grace period in milliseconds. | ||
* You can clean the jobs with the following states: completed, waiting, active, delayed, and failed. | ||
*/ | ||
clean(grace: number, status?: JobStatus, limit?: number): Promise<Job[]>; | ||
/** | ||
* Defines a processing function for the jobs placed into a given Queue. | ||
* | ||
* The callback is called everytime a job is placed in the queue. | ||
* It is passed an instance of the job as first argument. | ||
* | ||
* The done callback can be called with an Error instance, to signal that the job did not complete successfully, | ||
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful. | ||
* Errors will be passed as a second argument to the "failed" event; | ||
* results, as a second argument to the "completed" event. | ||
* | ||
* @param name Bull will only call the handler if the job name matches | ||
* @param concurrency Bull will then call you handler in parallel respecting this max number. | ||
*/ | ||
process(name: string, concurrency: number, callback: (job: Job, done: DoneCallback) => void): void; | ||
// tslint:disable:unified-signatures | ||
/** | ||
* Creates a new job and adds it to the queue. | ||
* If the queue is empty the job will be executed directly, | ||
* otherwise it will be placed in the queue and executed as soon as possible. | ||
*/ | ||
add(data: any, opts?: JobOptions): Promise<Job>; | ||
/** | ||
* Listens to queue events | ||
*/ | ||
on(event: string, callback: (...args: any[]) => void): this; | ||
/** | ||
* Creates a new named job and adds it to the queue. | ||
* If the queue is empty the job will be executed directly, | ||
* otherwise it will be placed in the queue and executed as soon as possible. | ||
*/ | ||
add(name: string, data: any, opts?: JobOptions): Promise<Job>; | ||
/** | ||
* An error occured | ||
*/ | ||
on(event: 'error', callback: ErrorEventCallback): this; | ||
/** | ||
* Returns a promise that resolves when the queue is paused. | ||
* The pause is global, meaning that all workers in all queue instances for a given queue will be paused. | ||
* A paused queue will not process new jobs until resumed, | ||
* but current jobs being processed will continue until they are finalized. | ||
* | ||
* Pausing a queue that is already paused does nothing. | ||
*/ | ||
pause(): Promise<void>; | ||
/** | ||
* A job has started. You can use `jobPromise.cancel()` to abort it | ||
*/ | ||
on(event: 'active', callback: ActiveEventCallback): this; | ||
/** | ||
* Returns a promise that resolves when the queue is resumed after being paused. | ||
* The resume is global, meaning that all workers in all queue instances for a given queue will be resumed. | ||
* | ||
* Resuming a queue that is not paused does nothing. | ||
*/ | ||
resume(): Promise<void>; | ||
/** | ||
* A job has been marked as stalled. | ||
* This is useful for debugging job workers that crash or pause the event loop. | ||
*/ | ||
on(event: 'stalled', callback: StalledEventCallback): this; | ||
/** | ||
* Returns a promise that returns the number of jobs in the queue, waiting or paused. | ||
* Since there may be other processes adding or processing jobs, this value may be true only for a very small amount of time. | ||
*/ | ||
count(): Promise<number>; | ||
/** | ||
* A job's progress was updated | ||
*/ | ||
on(event: 'progress', callback: ProgressEventCallback): this; | ||
/** | ||
* Empties a queue deleting all the input lists and associated jobs. | ||
*/ | ||
empty(): Promise<void>; | ||
/** | ||
* A job successfully completed with a `result` | ||
*/ | ||
on(event: 'completed', callback: CompletedEventCallback): this; | ||
/** | ||
* Closes the underlying redis client. Use this to perform a graceful shutdown. | ||
* | ||
* `close` can be called from anywhere, with one caveat: | ||
* if called from within a job handler the queue won't close until after the job has been processed | ||
*/ | ||
close(): Promise<void>; | ||
/** | ||
* A job failed with `err` as the reason | ||
*/ | ||
on(event: 'failed', callback: FailedEventCallback): this; | ||
/** | ||
* Returns a promise that will return the job instance associated with the jobId parameter. | ||
* If the specified job cannot be located, the promise callback parameter will be set to null. | ||
*/ | ||
getJob(jobId: JobId): Promise<Job>; | ||
/** | ||
* The queue has been paused | ||
*/ | ||
on(event: 'paused', callback: EventCallback): this; | ||
/** | ||
* Returns a promise that will return an array with the active jobs between start and end. | ||
*/ | ||
getActive(start?: number, end?: number): Promise<Job[]>; | ||
/** | ||
* The queue has been resumed | ||
*/ | ||
on(event: 'resumed', callback: EventCallback): this; | ||
/** | ||
* Returns a promise that will return an array with the delayed jobs between start and end. | ||
*/ | ||
getDelayed(start?: number, end?: number): Promise<Job[]>; | ||
/** | ||
* Old jobs have been cleaned from the queue. | ||
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs. | ||
* | ||
* @see Queue#clean() for details | ||
*/ | ||
on(event: 'cleaned', callback: CleanedEventCallback): this; | ||
/** | ||
* Returns a promise that will return an array with the completed jobs between start and end. | ||
*/ | ||
getCompleted(start?: number, end?: number): Promise<Job[]>; | ||
// tslint:enable:unified-signatures | ||
} | ||
/** | ||
* Returns a promise that will return an array with the failed jobs between start and end. | ||
*/ | ||
getFailed(start?: number, end?: number): Promise<Job[]>; | ||
type EventCallback = () => void; | ||
/** | ||
* Returns JobInformation of repeatable jobs (ordered descending). Provide a start and/or an end | ||
* index to limit the number of results. Start defaults to 0, end to -1 and asc to false. | ||
*/ | ||
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<JobInformation[]>; | ||
type ErrorEventCallback = (error: Error) => void; | ||
/** | ||
* ??? | ||
*/ | ||
nextRepeatableJob(name: string, data: any, opts: JobOptions): Promise<Job>; | ||
interface JobPromise { | ||
/** | ||
* Abort this job | ||
*/ | ||
cancel(): void; | ||
} | ||
/** | ||
* Removes a given repeatable job. The RepeatOpts needs to be the same as the ones used for | ||
* the job when it was added. | ||
*/ | ||
removeRepeatable(repeat: RepeatOptions): Promise<void>; | ||
type ActiveEventCallback = (job: Job, jobPromise?: JobPromise) => void; | ||
/** | ||
* Removes a given repeatable job. The RepeatOpts needs to be the same as the ones used for | ||
* the job when it was added. | ||
* | ||
* name: The name of the to be removed job | ||
*/ | ||
removeRepeatable(name: string, repeat: RepeatOptions): Promise<void>; | ||
type StalledEventCallback = (job: Job) => void; | ||
/** | ||
* Returns a promise that resolves with the job counts for the given queue. | ||
*/ | ||
getJobCounts(): Promise<JobCounts>; | ||
type ProgressEventCallback = (job: Job, progress: any) => void; | ||
/** | ||
* Returns a promise that resolves with the quantity of completed jobs. | ||
*/ | ||
getCompletedCount(): Promise<number>; | ||
type CompletedEventCallback = (job: Job, result: any) => void; | ||
/** | ||
* Returns a promise that resolves with the quantity of failed jobs. | ||
*/ | ||
getFailedCount(): Promise<number>; | ||
type FailedEventCallback = (job: Job, error: Error) => void; | ||
/** | ||
* Returns a promise that resolves with the quantity of delayed jobs. | ||
*/ | ||
getDelayedCount(): Promise<number>; | ||
type CleanedEventCallback = (jobs: Job[], status: JobStatus) => void; | ||
/** | ||
* Returns a promise that resolves with the quantity of waiting jobs. | ||
*/ | ||
getWaitingCount(): Promise<number>; | ||
/** | ||
* Returns a promise that resolves with the quantity of paused jobs. | ||
*/ | ||
getPausedCount(): Promise<number>; | ||
/** | ||
* Returns a promise that resolves with the quantity of active jobs. | ||
*/ | ||
getActiveCount(): Promise<number>; | ||
/** | ||
* Returns a promise that resolves to the quantity of repeatable jobs. | ||
*/ | ||
getRepeatableCount(): Promise<number>; | ||
/** | ||
* Tells the queue remove all jobs created outside of a grace period in milliseconds. | ||
* You can clean the jobs with the following states: completed, waiting, active, delayed, and failed. | ||
* @param grace Grace period in milliseconds. | ||
* @param status Status of the job to clean. Values are completed, wait, active, delayed, and failed. Defaults to completed. | ||
* @param limit Maximum amount of jobs to clean per call. If not provided will clean all matching jobs. | ||
*/ | ||
clean(grace: number, status?: JobStatus, limit?: number): Promise<Job[]>; | ||
// tslint:disable:unified-signatures | ||
/** | ||
* Listens to queue events | ||
*/ | ||
on(event: string, callback: (...args: any[]) => void): this; | ||
/** | ||
* An error occured | ||
*/ | ||
on(event: 'error', callback: ErrorEventCallback): this; | ||
/** | ||
* A job has started. You can use `jobPromise.cancel()` to abort it | ||
*/ | ||
on(event: 'active', callback: ActiveEventCallback): this; | ||
/** | ||
* A job has been marked as stalled. | ||
* This is useful for debugging job workers that crash or pause the event loop. | ||
*/ | ||
on(event: 'stalled', callback: StalledEventCallback): this; | ||
/** | ||
* A job's progress was updated | ||
*/ | ||
on(event: 'progress', callback: ProgressEventCallback): this; | ||
/** | ||
* A job successfully completed with a `result` | ||
*/ | ||
on(event: 'completed', callback: CompletedEventCallback): this; | ||
/** | ||
* A job failed with `err` as the reason | ||
*/ | ||
on(event: 'failed', callback: FailedEventCallback): this; | ||
/** | ||
* The queue has been paused | ||
*/ | ||
on(event: 'paused', callback: EventCallback): this; | ||
/** | ||
* The queue has been resumed | ||
*/ | ||
on(event: 'resumed', callback: EventCallback): this; | ||
/** | ||
* Old jobs have been cleaned from the queue. | ||
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs. | ||
* | ||
* @see Queue#clean() for details | ||
*/ | ||
on(event: 'cleaned', callback: CleanedEventCallback): this; | ||
// tslint:enable:unified-signatures | ||
} | ||
type EventCallback = () => void; | ||
type ErrorEventCallback = (error: Error) => void; | ||
interface JobPromise { | ||
/** | ||
* Abort this job | ||
*/ | ||
cancel(): void; | ||
} | ||
type ActiveEventCallback = (job: Job, jobPromise?: JobPromise) => void; | ||
type StalledEventCallback = (job: Job) => void; | ||
type ProgressEventCallback = (job: Job, progress: any) => void; | ||
type CompletedEventCallback = (job: Job, result: any) => void; | ||
type FailedEventCallback = (job: Job, error: Error) => void; | ||
type CleanedEventCallback = (jobs: Job[], status: JobStatus) => void; | ||
} | ||
export = Bull; |
{ | ||
"name": "@types/bull", | ||
"version": "3.0.2", | ||
"version": "3.3.0", | ||
"description": "TypeScript definitions for bull", | ||
@@ -21,2 +21,7 @@ "license": "MIT", | ||
"githubUsername": "marshall007" | ||
}, | ||
{ | ||
"name": "Weeco", | ||
"url": "https://github.com/weeco", | ||
"githubUsername": "weeco" | ||
} | ||
@@ -31,6 +36,7 @@ ], | ||
"dependencies": { | ||
"@types/ioredis": "*" | ||
"@types/ioredis": "*", | ||
"@types/bluebird": "*" | ||
}, | ||
"typesPublisherContentHash": "22c300cd9af23da94280da72758f4fc67f519a5a7b1911fb8493a5d2265effea", | ||
"typeScriptVersion": "2.0" | ||
"typesPublisherContentHash": "5419b44cabb4ff6be8443a9e386512cc5183e0e4d567555449e5efb27b369162", | ||
"typeScriptVersion": "2.3" | ||
} |
@@ -11,7 +11,7 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 25 Oct 2017 00:19:45 GMT | ||
* Dependencies: ioredis | ||
* Last updated: Tue, 14 Nov 2017 17:43:01 GMT | ||
* Dependencies: ioredis, bluebird | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Bruno Grieder <https://github.com/bgrieder>, Cameron Crothers <https://github.com/JProgrammer>, Marshall Cottrell <https://github.com/marshall007>. | ||
These definitions were written by Bruno Grieder <https://github.com/bgrieder>, Cameron Crothers <https://github.com/JProgrammer>, Marshall Cottrell <https://github.com/marshall007>, Weeco <https://github.com/weeco>. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23877
508
2
+ Added@types/bluebird@*
+ Added@types/bluebird@3.5.42(transitive)