pg-boss 8.0.0 → 8.1.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-boss",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "Queueing jobs in Node.js using PostgreSQL like a boss",
5
5
  "main": "./src/index.js",
6
6
  "engines": {
@@ -13,7 +13,7 @@
13
13
  "p-map": "^5.3.0",
14
14
  "pg": "^8.5.1",
15
15
  "serialize-error": "^11.0.0",
16
- "uuid": "^8.3.2"
16
+ "uuid": "^9.0.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^18.0.0",
package/src/attorney.js CHANGED
@@ -377,7 +377,7 @@ function applyMonitoringConfig (config) {
377
377
 
378
378
  function applyUuidConfig (config) {
379
379
  assert(!('uuid' in config) || config.uuid === 'v1' || config.uuid === 'v4', 'configuration assert: uuid option only supports v1 or v4')
380
- config.uuid = config.uuid || 'v1'
380
+ config.uuid = config.uuid || 'v4'
381
381
  }
382
382
 
383
383
  function warnClockSkew (message) {
package/src/manager.js CHANGED
@@ -535,27 +535,31 @@ class Manager extends EventEmitter {
535
535
  }
536
536
  }
537
537
 
538
- async complete (id, data) {
538
+ async complete (id, data, options = {}) {
539
+ const db = options.db || this.db
539
540
  const ids = this.mapCompletionIdArg(id, 'complete')
540
- const result = await this.db.executeSql(this.completeJobsCommand, [ids, this.mapCompletionDataArg(data)])
541
+ const result = await db.executeSql(this.completeJobsCommand, [ids, this.mapCompletionDataArg(data)])
541
542
  return this.mapCompletionResponse(ids, result)
542
543
  }
543
544
 
544
- async fail (id, data) {
545
+ async fail (id, data, options = {}) {
546
+ const db = options.db || this.db
545
547
  const ids = this.mapCompletionIdArg(id, 'fail')
546
- const result = await this.db.executeSql(this.failJobsCommand, [ids, this.mapCompletionDataArg(data)])
548
+ const result = await db.executeSql(this.failJobsCommand, [ids, this.mapCompletionDataArg(data)])
547
549
  return this.mapCompletionResponse(ids, result)
548
550
  }
549
551
 
550
- async cancel (id) {
552
+ async cancel (id, options = {}) {
553
+ const db = options.db || this.db
551
554
  const ids = this.mapCompletionIdArg(id, 'cancel')
552
- const result = await this.db.executeSql(this.cancelJobsCommand, [ids])
555
+ const result = await db.executeSql(this.cancelJobsCommand, [ids])
553
556
  return this.mapCompletionResponse(ids, result)
554
557
  }
555
558
 
556
- async resume (id) {
559
+ async resume (id, options = {}) {
560
+ const db = options.db || this.db
557
561
  const ids = this.mapCompletionIdArg(id, 'resume')
558
- const result = await this.db.executeSql(this.resumeJobsCommand, [ids])
562
+ const result = await db.executeSql(this.resumeJobsCommand, [ids])
559
563
  return this.mapCompletionResponse(ids, result)
560
564
  }
561
565
 
@@ -587,14 +591,15 @@ class Manager extends EventEmitter {
587
591
  return result ? parseFloat(result.rows[0].count) : null
588
592
  }
589
593
 
590
- async getJobById (id) {
591
- const result1 = await this.db.executeSql(this.getJobByIdCommand, [id])
594
+ async getJobById (id, options = {}) {
595
+ const db = options.db || this.db
596
+ const result1 = await db.executeSql(this.getJobByIdCommand, [id])
592
597
 
593
598
  if (result1 && result1.rows && result1.rows.length === 1) {
594
599
  return result1.rows[0]
595
600
  }
596
601
 
597
- const result2 = await this.db.executeSql(this.getArchivedJobByIdCommand, [id])
602
+ const result2 = await db.executeSql(this.getArchivedJobByIdCommand, [id])
598
603
 
599
604
  if (result2 && result2.rows && result2.rows.length === 1) {
600
605
  return result2.rows[0]
package/types.d.ts CHANGED
@@ -341,22 +341,22 @@ declare class PgBoss extends EventEmitter {
341
341
  fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[] | null>;
342
342
  fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[] | null>;
343
343
 
344
- cancel(id: string): Promise<void>;
345
- cancel(ids: string[]): Promise<void>;
344
+ cancel(id: string, options: PgBoss.ConnectionOptions): Promise<void>;
345
+ cancel(ids: string[], options: PgBoss.ConnectionOptions): Promise<void>;
346
346
 
347
- resume(id: string): Promise<void>;
348
- resume(ids: string[]): Promise<void>;
347
+ resume(id: string, options: PgBoss.ConnectionOptions): Promise<void>;
348
+ resume(ids: string[], options: PgBoss.ConnectionOptions): Promise<void>;
349
349
 
350
- complete(id: string): Promise<void>;
351
- complete(id: string, data: object): Promise<void>;
352
- complete(ids: string[]): Promise<void>;
350
+ complete(id: string, options: PgBoss.ConnectionOptions): Promise<void>;
351
+ complete(id: string, data: object, options: PgBoss.ConnectionOptions): Promise<void>;
352
+ complete(ids: string[], options: PgBoss.ConnectionOptions): Promise<void>;
353
353
 
354
- fail(id: string): Promise<void>;
355
- fail(id: string, data: object): Promise<void>;
356
- fail(ids: string[]): Promise<void>;
354
+ fail(id: string, options: PgBoss.ConnectionOptions): Promise<void>;
355
+ fail(id: string, data: object, options: PgBoss.ConnectionOptions): Promise<void>;
356
+ fail(ids: string[], options: PgBoss.ConnectionOptions): Promise<void>;
357
357
 
358
358
  getQueueSize(name: string, options?: object): Promise<number>;
359
- getJobById(id: string): Promise<PgBoss.JobWithMetadata | null>;
359
+ getJobById(id: string, options: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata | null>;
360
360
 
361
361
  deleteQueue(name: string): Promise<void>;
362
362
  deleteAllQueues(): Promise<void>;