@bull-board/api
Advanced tools
Comparing version 5.8.4 to 5.9.0
@@ -5,2 +5,4 @@ export declare const STATUSES: { | ||
readonly waiting: "waiting"; | ||
readonly waitingChildren: "waiting-children"; | ||
readonly prioritized: "prioritized"; | ||
readonly completed: "completed"; | ||
@@ -7,0 +9,0 @@ readonly failed: "failed"; |
@@ -8,2 +8,4 @@ "use strict"; | ||
waiting: 'waiting', | ||
waitingChildren: 'waiting-children', | ||
prioritized: 'prioritized', | ||
completed: 'completed', | ||
@@ -10,0 +12,0 @@ failed: 'failed', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queuesHandler = exports.formatJob = void 0; | ||
const statuses_1 = require("../constants/statuses"); | ||
const formatJob = (job, queue) => { | ||
@@ -26,10 +25,2 @@ const jobProps = job.toJSON(); | ||
exports.formatJob = formatJob; | ||
const allStatuses = [ | ||
statuses_1.STATUSES.active, | ||
statuses_1.STATUSES.completed, | ||
statuses_1.STATUSES.delayed, | ||
statuses_1.STATUSES.failed, | ||
statuses_1.STATUSES.paused, | ||
statuses_1.STATUSES.waiting, | ||
]; | ||
function getPagination(statuses, counts, currentPage, jobsPerPage) { | ||
@@ -51,5 +42,6 @@ const isLatestStatus = statuses.length > 1; | ||
const jobsPerPage = +query.jobsPerPage || 10; | ||
const status = !isActiveQueue || query.status === 'latest' ? allStatuses : [query.status]; | ||
const jobStatuses = queue.getJobStatuses(); | ||
const status = !isActiveQueue || query.status === 'latest' ? jobStatuses : [query.status]; | ||
const currentPage = +query.page || 1; | ||
const counts = await queue.getJobCounts(...allStatuses); | ||
const counts = await queue.getJobCounts(...jobStatuses); | ||
const isPaused = await queue.isPaused(); | ||
@@ -60,6 +52,6 @@ const pagination = getPagination(status, counts, currentPage, jobsPerPage); | ||
: []; | ||
const description = queue.getDescription() || undefined; | ||
return { | ||
name: queueName, | ||
description, | ||
description: queue.getDescription() || undefined, | ||
statuses: queue.getStatuses(), | ||
counts: counts, | ||
@@ -66,0 +58,0 @@ jobs: jobs.filter(Boolean).map((job) => (0, exports.formatJob)(job, queue)), |
@@ -1,2 +0,2 @@ | ||
import { FormatterField, JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions, QueueJob } from '../../typings/app'; | ||
import { FormatterField, JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions, QueueJob, Status } from '../../typings/app'; | ||
export declare abstract class BaseAdapter { | ||
@@ -27,2 +27,4 @@ readonly readOnlyMode: boolean; | ||
abstract promoteAll(): Promise<void>; | ||
abstract getStatuses(): Status[]; | ||
abstract getJobStatuses(): JobStatus[]; | ||
} |
import { Job, Queue } from 'bull'; | ||
import { JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions } from '../../typings/app'; | ||
import { JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions, Status } from '../../typings/app'; | ||
import { BaseAdapter } from './base'; | ||
@@ -11,4 +11,4 @@ export declare class BullAdapter extends BaseAdapter { | ||
getJob(id: string): Promise<Job | undefined | null>; | ||
getJobs(jobStatuses: JobStatus[], start?: number, end?: number): Promise<Job[]>; | ||
getJobCounts(..._jobStatuses: JobStatus[]): Promise<JobCounts>; | ||
getJobs(jobStatuses: JobStatus<'bull'>[], start?: number, end?: number): Promise<Job[]>; | ||
getJobCounts(..._jobStatuses: JobStatus<'bull'>[]): Promise<JobCounts>; | ||
getJobLogs(id: string): Promise<string[]>; | ||
@@ -20,2 +20,4 @@ isPaused(): Promise<boolean>; | ||
promoteAll(): Promise<void>; | ||
getStatuses(): Status<'bull'>[]; | ||
getJobStatuses(): JobStatus<'bull'>[]; | ||
} |
@@ -59,4 +59,25 @@ "use strict"; | ||
} | ||
getStatuses() { | ||
return [ | ||
statuses_1.STATUSES.latest, | ||
statuses_1.STATUSES.active, | ||
statuses_1.STATUSES.waiting, | ||
statuses_1.STATUSES.completed, | ||
statuses_1.STATUSES.failed, | ||
statuses_1.STATUSES.delayed, | ||
statuses_1.STATUSES.paused, | ||
]; | ||
} | ||
getJobStatuses() { | ||
return [ | ||
statuses_1.STATUSES.active, | ||
statuses_1.STATUSES.waiting, | ||
statuses_1.STATUSES.completed, | ||
statuses_1.STATUSES.failed, | ||
statuses_1.STATUSES.delayed, | ||
statuses_1.STATUSES.paused, | ||
]; | ||
} | ||
} | ||
exports.BullAdapter = BullAdapter; | ||
//# sourceMappingURL=bull.js.map |
import { Job, Queue } from 'bullmq'; | ||
import { JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions } from '../../typings/app'; | ||
import { JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions, Status } from '../../typings/app'; | ||
import { BaseAdapter } from './base'; | ||
@@ -19,2 +19,4 @@ export declare class BullMQAdapter extends BaseAdapter { | ||
promoteAll(): Promise<void>; | ||
getStatuses(): Status[]; | ||
getJobStatuses(): JobStatus[]; | ||
} |
@@ -55,4 +55,29 @@ "use strict"; | ||
} | ||
getStatuses() { | ||
return [ | ||
statuses_1.STATUSES.latest, | ||
statuses_1.STATUSES.active, | ||
statuses_1.STATUSES.waiting, | ||
statuses_1.STATUSES.waitingChildren, | ||
statuses_1.STATUSES.prioritized, | ||
statuses_1.STATUSES.completed, | ||
statuses_1.STATUSES.failed, | ||
statuses_1.STATUSES.delayed, | ||
statuses_1.STATUSES.paused, | ||
]; | ||
} | ||
getJobStatuses() { | ||
return [ | ||
statuses_1.STATUSES.active, | ||
statuses_1.STATUSES.waiting, | ||
statuses_1.STATUSES.waitingChildren, | ||
statuses_1.STATUSES.prioritized, | ||
statuses_1.STATUSES.completed, | ||
statuses_1.STATUSES.failed, | ||
statuses_1.STATUSES.delayed, | ||
statuses_1.STATUSES.paused, | ||
]; | ||
} | ||
} | ||
exports.BullMQAdapter = BullMQAdapter; | ||
//# sourceMappingURL=bullMQ.js.map |
@@ -6,4 +6,8 @@ import { RedisInfo } from 'redis-info'; | ||
export type JobRetryStatus = 'completed' | 'failed'; | ||
export type Status = keyof typeof STATUSES; | ||
export type JobStatus = keyof Omit<typeof STATUSES, 'latest'>; | ||
type Library = 'bull' | 'bullmq'; | ||
type Values<T> = T[keyof T]; | ||
type BullMQStatuses = Values<typeof STATUSES>; | ||
type BullStatuses = Exclude<BullMQStatuses, 'prioritized' | 'waiting-children'>; | ||
export type Status<Lib extends Library = 'bullmq'> = Lib extends 'bullmq' ? BullMQStatuses : Lib extends 'bull' ? BullStatuses : never; | ||
export type JobStatus<Lib extends Library = 'bullmq'> = Lib extends 'bullmq' ? Exclude<BullMQStatuses, 'latest'> : Lib extends 'bull' ? Exclude<BullStatuses, 'latest'> : never; | ||
export type JobCounts = Record<Status, number>; | ||
@@ -81,2 +85,3 @@ export interface QueueAdapterOptions { | ||
jobs: AppJob[]; | ||
statuses: Status[]; | ||
pagination: Pagination; | ||
@@ -160,1 +165,2 @@ readOnlyMode: boolean; | ||
}; | ||
export {}; |
{ | ||
"name": "@bull-board/api", | ||
"version": "5.8.4", | ||
"version": "5.9.0", | ||
"description": "A Dashboard server API built on top of bull or bullmq.", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@bull-board/ui": "5.8.4" | ||
"@bull-board/ui": "5.9.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
62560
1008