pg-boss 11.0.5 → 11.0.6
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.
- package/package.json +8 -17
- package/src/plans.js +2 -2
- package/src/timekeeper.js +3 -3
- package/types.d.ts +79 -79
package/package.json
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.6",
|
|
4
4
|
"description": "Queueing jobs in Postgres from Node.js like a boss",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
|
+
"type": "commonjs",
|
|
6
7
|
"engines": {
|
|
7
8
|
"node": ">=22"
|
|
8
9
|
},
|
|
9
10
|
"dependencies": {
|
|
10
|
-
"cron-parser": "^4.
|
|
11
|
+
"cron-parser": "^5.4.0",
|
|
11
12
|
"pg": "^8.16.3",
|
|
12
13
|
"serialize-error": "^8.1.0"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@types/node": "^22",
|
|
17
|
+
"eslint": "^9.36.0",
|
|
16
18
|
"luxon": "^3.7.2",
|
|
17
|
-
"mocha": "^
|
|
18
|
-
"
|
|
19
|
-
"
|
|
19
|
+
"mocha": "^11.7.4",
|
|
20
|
+
"neostandard": "^0.12.2",
|
|
21
|
+
"nyc": "^17.1.0"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
|
-
"test": "
|
|
24
|
+
"test": "eslint . && mocha",
|
|
23
25
|
"cover": "nyc npm test",
|
|
24
26
|
"tsc": "tsc --noEmit types.d.ts",
|
|
25
27
|
"readme": "node ./test/readme.js",
|
|
@@ -45,17 +47,6 @@
|
|
|
45
47
|
"text"
|
|
46
48
|
]
|
|
47
49
|
},
|
|
48
|
-
"standard": {
|
|
49
|
-
"globals": [
|
|
50
|
-
"describe",
|
|
51
|
-
"it",
|
|
52
|
-
"before",
|
|
53
|
-
"after",
|
|
54
|
-
"before",
|
|
55
|
-
"beforeEach",
|
|
56
|
-
"afterEach"
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
50
|
"repository": {
|
|
60
51
|
"type": "git",
|
|
61
52
|
"url": "git+https://github.com/timgit/pg-boss.git"
|
package/src/plans.js
CHANGED
|
@@ -702,7 +702,7 @@ function insertJobs (schema, { table, name, returnId = true }) {
|
|
|
702
702
|
END as singleton_on,
|
|
703
703
|
COALESCE("expireInSeconds", q.expire_seconds) as expire_seconds,
|
|
704
704
|
COALESCE("deleteAfterSeconds", q.deletion_seconds) as deletion_seconds,
|
|
705
|
-
COALESCE("
|
|
705
|
+
j.start_after + (COALESCE("retentionSeconds", q.retention_seconds) * interval '1s') as keep_until,
|
|
706
706
|
COALESCE("retryLimit", q.retry_limit) as retry_limit,
|
|
707
707
|
COALESCE("retryDelay", q.retry_delay) as retry_delay,
|
|
708
708
|
COALESCE("retryBackoff", q.retry_backoff, false) as retry_backoff,
|
|
@@ -730,7 +730,7 @@ function insertJobs (schema, { table, name, returnId = true }) {
|
|
|
730
730
|
"singletonOffset" integer,
|
|
731
731
|
"expireInSeconds" integer,
|
|
732
732
|
"deleteAfterSeconds" integer,
|
|
733
|
-
"
|
|
733
|
+
"retentionSeconds" integer
|
|
734
734
|
)
|
|
735
735
|
) j
|
|
736
736
|
JOIN ${schema}.queue q ON q.name = '${name}'
|
package/src/timekeeper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const EventEmitter = require('node:events')
|
|
2
2
|
const plans = require('./plans')
|
|
3
|
-
const
|
|
3
|
+
const { CronExpressionParser } = require('cron-parser')
|
|
4
4
|
const Attorney = require('./attorney')
|
|
5
5
|
|
|
6
6
|
const QUEUES = {
|
|
@@ -144,7 +144,7 @@ class Timekeeper extends EventEmitter {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
shouldSendIt (cron, tz) {
|
|
147
|
-
const interval =
|
|
147
|
+
const interval = CronExpressionParser.parse(cron, { tz, strict: false })
|
|
148
148
|
|
|
149
149
|
const prevTime = interval.prev()
|
|
150
150
|
|
|
@@ -176,7 +176,7 @@ class Timekeeper extends EventEmitter {
|
|
|
176
176
|
async schedule (name, cron, data, options = {}) {
|
|
177
177
|
const { tz = 'UTC', key = '', ...rest } = options
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
CronExpressionParser.parse(cron, { tz, strict: false })
|
|
180
180
|
|
|
181
181
|
Attorney.checkSendArgs([name, data, { ...rest }])
|
|
182
182
|
Attorney.assertKey(key)
|
package/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events'
|
|
|
3
3
|
declare namespace PgBoss {
|
|
4
4
|
|
|
5
5
|
type JobStates = {
|
|
6
|
-
created
|
|
6
|
+
created: 'created',
|
|
7
7
|
retry: 'retry',
|
|
8
8
|
active: 'active',
|
|
9
9
|
completed: 'completed',
|
|
@@ -79,9 +79,9 @@ declare namespace PgBoss {
|
|
|
79
79
|
db?: Db;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
type InsertOptions = ConnectionOptions
|
|
82
|
+
type InsertOptions = ConnectionOptions
|
|
83
83
|
|
|
84
|
-
type SendOptions = JobOptions & QueueOptions & ConnectionOptions
|
|
84
|
+
type SendOptions = JobOptions & QueueOptions & ConnectionOptions
|
|
85
85
|
|
|
86
86
|
type QueuePolicy = 'standard' | 'short' | 'singleton' | 'stately'
|
|
87
87
|
|
|
@@ -117,7 +117,7 @@ declare namespace PgBoss {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
type WorkOptions = JobFetchOptions & JobPollingOptions
|
|
120
|
-
type FetchOptions = JobFetchOptions & ConnectionOptions
|
|
120
|
+
type FetchOptions = JobFetchOptions & ConnectionOptions
|
|
121
121
|
|
|
122
122
|
interface WorkHandler<ReqData> {
|
|
123
123
|
(job: PgBoss.Job<ReqData>[]): Promise<any>;
|
|
@@ -184,8 +184,8 @@ declare namespace PgBoss {
|
|
|
184
184
|
singletonKey?: string;
|
|
185
185
|
singletonSeconds?: number;
|
|
186
186
|
expireInSeconds?: number;
|
|
187
|
-
deleteAfterSeconds
|
|
188
|
-
|
|
187
|
+
deleteAfterSeconds?: number;
|
|
188
|
+
retentionSeconds?: number;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
interface Worker {
|
|
@@ -217,107 +217,107 @@ declare namespace PgBoss {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
declare class PgBoss extends EventEmitter {
|
|
220
|
-
constructor(connectionString: string)
|
|
221
|
-
constructor(options: PgBoss.ConstructorOptions)
|
|
220
|
+
constructor (connectionString: string)
|
|
221
|
+
constructor (options: PgBoss.ConstructorOptions)
|
|
222
222
|
|
|
223
|
-
static getConstructionPlans(schema?: string): string
|
|
224
|
-
static getMigrationPlans(schema?: string, version?: string): string
|
|
225
|
-
static getRollbackPlans(schema?: string, version?: string): string
|
|
223
|
+
static getConstructionPlans (schema?: string): string
|
|
224
|
+
static getMigrationPlans (schema?: string, version?: string): string
|
|
225
|
+
static getRollbackPlans (schema?: string, version?: string): string
|
|
226
226
|
|
|
227
227
|
static states: PgBoss.JobStates
|
|
228
228
|
static policies: PgBoss.QueuePolicies
|
|
229
229
|
|
|
230
|
-
on(event:
|
|
231
|
-
off(event:
|
|
230
|
+
on (event: 'error', handler: (error: Error) => void): this
|
|
231
|
+
off (event: 'error', handler: (error: Error) => void): this
|
|
232
232
|
|
|
233
|
-
on(event:
|
|
234
|
-
off(event:
|
|
233
|
+
on (event: 'warning', handler: (warning: { message: string, data: object }) => void): this
|
|
234
|
+
off (event: 'warning', handler: (warning: { message: string, data: object }) => void): this
|
|
235
235
|
|
|
236
|
-
on(event:
|
|
237
|
-
off(event:
|
|
236
|
+
on (event: 'wip', handler: (data: PgBoss.Worker[]) => void): this
|
|
237
|
+
off (event: 'wip', handler: (data: PgBoss.Worker[]) => void): this
|
|
238
238
|
|
|
239
|
-
on(event:
|
|
240
|
-
off(event:
|
|
239
|
+
on (event: 'stopped', handler: () => void): this
|
|
240
|
+
off (event: 'stopped', handler: () => void): this
|
|
241
241
|
|
|
242
|
-
start(): Promise<PgBoss
|
|
243
|
-
stop(options?: PgBoss.StopOptions): Promise<void
|
|
242
|
+
start (): Promise<PgBoss>
|
|
243
|
+
stop (options?: PgBoss.StopOptions): Promise<void>
|
|
244
244
|
|
|
245
|
-
send(request: PgBoss.Request): Promise<string | null
|
|
246
|
-
send(name: string, data: object): Promise<string | null
|
|
247
|
-
send(name: string, data: object, options: PgBoss.SendOptions): Promise<string | null
|
|
245
|
+
send (request: PgBoss.Request): Promise<string | null>
|
|
246
|
+
send (name: string, data: object): Promise<string | null>
|
|
247
|
+
send (name: string, data: object, options: PgBoss.SendOptions): Promise<string | null>
|
|
248
248
|
|
|
249
|
-
sendAfter(name: string, data: object, options: PgBoss.SendOptions, date: Date): Promise<string | null
|
|
250
|
-
sendAfter(name: string, data: object, options: PgBoss.SendOptions, dateString: string): Promise<string | null
|
|
251
|
-
sendAfter(name: string, data: object, options: PgBoss.SendOptions, seconds: number): Promise<string | null
|
|
249
|
+
sendAfter (name: string, data: object, options: PgBoss.SendOptions, date: Date): Promise<string | null>
|
|
250
|
+
sendAfter (name: string, data: object, options: PgBoss.SendOptions, dateString: string): Promise<string | null>
|
|
251
|
+
sendAfter (name: string, data: object, options: PgBoss.SendOptions, seconds: number): Promise<string | null>
|
|
252
252
|
|
|
253
|
-
sendThrottled(name: string, data: object, options: PgBoss.SendOptions, seconds: number, key?: string): Promise<string | null
|
|
254
|
-
sendDebounced(name: string, data: object, options: PgBoss.SendOptions, seconds: number, key?: string): Promise<string | null
|
|
253
|
+
sendThrottled (name: string, data: object, options: PgBoss.SendOptions, seconds: number, key?: string): Promise<string | null>
|
|
254
|
+
sendDebounced (name: string, data: object, options: PgBoss.SendOptions, seconds: number, key?: string): Promise<string | null>
|
|
255
255
|
|
|
256
|
-
insert(name: string, jobs: PgBoss.JobInsert[]): Promise<void
|
|
257
|
-
insert(name: string, jobs: PgBoss.JobInsert[], options: PgBoss.InsertOptions): Promise<void
|
|
256
|
+
insert (name: string, jobs: PgBoss.JobInsert[]): Promise<void>
|
|
257
|
+
insert (name: string, jobs: PgBoss.JobInsert[], options: PgBoss.InsertOptions): Promise<void>
|
|
258
258
|
|
|
259
|
-
fetch<T>(name: string): Promise<PgBoss.Job<T>[]
|
|
260
|
-
fetch<T>(name: string, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[]
|
|
261
|
-
fetch<T>(name: string, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[]
|
|
259
|
+
fetch<T>(name: string): Promise<PgBoss.Job<T>[]>
|
|
260
|
+
fetch<T>(name: string, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[]>
|
|
261
|
+
fetch<T>(name: string, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[]>
|
|
262
262
|
|
|
263
|
-
work<ReqData>(name: string, handler: PgBoss.WorkHandler<ReqData>): Promise<string
|
|
264
|
-
work<ReqData>(name: string, options: PgBoss.WorkOptions & { includeMetadata: true }, handler: PgBoss.WorkWithMetadataHandler<ReqData>): Promise<string
|
|
265
|
-
work<ReqData>(name: string, options: PgBoss.WorkOptions, handler: PgBoss.WorkHandler<ReqData>): Promise<string
|
|
263
|
+
work<ReqData>(name: string, handler: PgBoss.WorkHandler<ReqData>): Promise<string>
|
|
264
|
+
work<ReqData>(name: string, options: PgBoss.WorkOptions & { includeMetadata: true }, handler: PgBoss.WorkWithMetadataHandler<ReqData>): Promise<string>
|
|
265
|
+
work<ReqData>(name: string, options: PgBoss.WorkOptions, handler: PgBoss.WorkHandler<ReqData>): Promise<string>
|
|
266
266
|
|
|
267
|
-
offWork(name: string): Promise<void
|
|
268
|
-
offWork(options: PgBoss.OffWorkOptions): Promise<void
|
|
267
|
+
offWork (name: string): Promise<void>
|
|
268
|
+
offWork (options: PgBoss.OffWorkOptions): Promise<void>
|
|
269
269
|
|
|
270
|
-
notifyWorker(workerId: string): void
|
|
270
|
+
notifyWorker (workerId: string): void
|
|
271
271
|
|
|
272
|
-
subscribe(event: string, name: string): Promise<void
|
|
273
|
-
unsubscribe(event: string, name: string): Promise<void
|
|
274
|
-
publish(event: string): Promise<void
|
|
275
|
-
publish(event: string, data: object): Promise<void
|
|
276
|
-
publish(event: string, data: object, options: PgBoss.SendOptions): Promise<void
|
|
272
|
+
subscribe (event: string, name: string): Promise<void>
|
|
273
|
+
unsubscribe (event: string, name: string): Promise<void>
|
|
274
|
+
publish (event: string): Promise<void>
|
|
275
|
+
publish (event: string, data: object): Promise<void>
|
|
276
|
+
publish (event: string, data: object, options: PgBoss.SendOptions): Promise<void>
|
|
277
277
|
|
|
278
|
-
cancel(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
279
|
-
cancel(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
278
|
+
cancel (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
279
|
+
cancel (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
280
280
|
|
|
281
|
-
resume(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
282
|
-
resume(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
281
|
+
resume (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
282
|
+
resume (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
283
283
|
|
|
284
|
-
retry(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
285
|
-
retry(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
284
|
+
retry (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
285
|
+
retry (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
286
286
|
|
|
287
|
-
deleteJob(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
288
|
-
deleteJob(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
289
|
-
deleteQueuedJobs(name: string): Promise<void
|
|
290
|
-
deleteStoredJobs(name: string): Promise<void
|
|
291
|
-
deleteAllJobs(name: string): Promise<void
|
|
287
|
+
deleteJob (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
288
|
+
deleteJob (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
289
|
+
deleteQueuedJobs (name: string): Promise<void>
|
|
290
|
+
deleteStoredJobs (name: string): Promise<void>
|
|
291
|
+
deleteAllJobs (name: string): Promise<void>
|
|
292
292
|
|
|
293
|
-
complete(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
294
|
-
complete(name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void
|
|
295
|
-
complete(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
293
|
+
complete (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
294
|
+
complete (name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
295
|
+
complete (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
296
296
|
|
|
297
|
-
fail(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void
|
|
298
|
-
fail(name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void
|
|
299
|
-
fail(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void
|
|
297
|
+
fail (name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
298
|
+
fail (name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>
|
|
299
|
+
fail (name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>
|
|
300
300
|
|
|
301
|
-
getJobById<T>(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata<T> | null
|
|
301
|
+
getJobById<T>(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata<T> | null>
|
|
302
302
|
|
|
303
|
-
createQueue(name: string, options?: Omit<PgBoss.Queue, 'name'>): Promise<void
|
|
304
|
-
createQueue(options: PgBoss.Queue): Promise<void
|
|
305
|
-
updateQueue(name: string, options?: Omit<PgBoss.Queue, 'name'>): Promise<void
|
|
306
|
-
updateQueue(options: PgBoss.Queue): Promise<void
|
|
307
|
-
deleteQueue(name: string): Promise<void
|
|
308
|
-
getQueues(): Promise<PgBoss.QueueResult[]
|
|
309
|
-
getQueue(name: string): Promise<PgBoss.QueueResult | null
|
|
310
|
-
getQueueStats(name: string): Promise<PgBoss.QueueResult
|
|
303
|
+
createQueue (name: string, options?: Omit<PgBoss.Queue, 'name'>): Promise<void>
|
|
304
|
+
createQueue (options: PgBoss.Queue): Promise<void>
|
|
305
|
+
updateQueue (name: string, options?: Omit<PgBoss.Queue, 'name'>): Promise<void>
|
|
306
|
+
updateQueue (options: PgBoss.Queue): Promise<void>
|
|
307
|
+
deleteQueue (name: string): Promise<void>
|
|
308
|
+
getQueues (): Promise<PgBoss.QueueResult[]>
|
|
309
|
+
getQueue (name: string): Promise<PgBoss.QueueResult | null>
|
|
310
|
+
getQueueStats (name: string): Promise<PgBoss.QueueResult>
|
|
311
311
|
|
|
312
|
-
supervise(name?: string): Promise<void
|
|
313
|
-
isInstalled(): Promise<boolean
|
|
314
|
-
schemaVersion(): Promise<number
|
|
312
|
+
supervise (name?: string): Promise<void>
|
|
313
|
+
isInstalled (): Promise<boolean>
|
|
314
|
+
schemaVersion (): Promise<number>
|
|
315
315
|
|
|
316
|
-
schedule(name: string, cron: string, data?: object, options?: PgBoss.ScheduleOptions): Promise<void
|
|
317
|
-
unschedule(name: string, key?: string): Promise<void
|
|
318
|
-
getSchedules(name?: string, key?: string): Promise<PgBoss.Schedule[]
|
|
316
|
+
schedule (name: string, cron: string, data?: object, options?: PgBoss.ScheduleOptions): Promise<void>
|
|
317
|
+
unschedule (name: string, key?: string): Promise<void>
|
|
318
|
+
getSchedules (name?: string, key?: string): Promise<PgBoss.Schedule[]>
|
|
319
319
|
|
|
320
|
-
getDb(): PgBoss.Db
|
|
320
|
+
getDb (): PgBoss.Db
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
export = PgBoss
|
|
323
|
+
export = PgBoss
|