@rvoh/psychic-workers 2.0.0 → 2.0.2

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.
@@ -525,10 +525,22 @@ export class Background {
525
525
  }
526
526
  if (!queueInstance)
527
527
  throw new Error(`missing queue: ${jobConfig?.queue?.toString() || 'N/A'}`);
528
+ const jobOptions = {};
529
+ if (jobId)
530
+ jobOptions.jobId = jobId;
531
+ if (delay)
532
+ jobOptions.delay = delay;
533
+ if (delay && jobId) {
534
+ jobOptions.deduplication = {
535
+ id: jobId,
536
+ ttl: delay,
537
+ extend: true,
538
+ replace: true,
539
+ };
540
+ }
528
541
  if (groupId && priority) {
529
542
  await queueInstance.add(jobType, jobData, {
530
- delay,
531
- jobId,
543
+ ...jobOptions,
532
544
  group: {
533
545
  ...this.groupIdToGroupConfig(groupId),
534
546
  priority: this.mapPriorityWordToPriorityNumber(priority),
@@ -539,8 +551,7 @@ export class Background {
539
551
  }
540
552
  else {
541
553
  await queueInstance.add(jobType, jobData, {
542
- delay,
543
- jobId,
554
+ ...jobOptions,
544
555
  group: this.groupIdToGroupConfig(groupId),
545
556
  priority: this.mapPriorityWordToPriorityNumber(priority),
546
557
  // explicitly typing as JobsOptions because Psychic can't be aware of BullMQ Pro options
@@ -1,5 +1,5 @@
1
- import background, { Background } from '../background/index.js';
2
1
  import parallelTestSafeQueueName from '../background/helpers/parallelTestSafeQueueName.js';
2
+ import background, { Background } from '../background/index.js';
3
3
  const LOCK_TOKEN = 'psychic-test-worker';
4
4
  export default class WorkerTestUtils {
5
5
  /*
@@ -46,7 +46,7 @@ export default class WorkerTestUtils {
46
46
  if (opts.queue && !queues.length)
47
47
  throw new Error(`Expected to find queue with name: ${opts.queue}, but none were found by that name. The queue names available are: ${background.queues.map(queue => queue.name).join(', ')}`);
48
48
  for (const queue of queues) {
49
- const jobs = (await queue.getDelayed());
49
+ const jobs = await queue.getDelayed();
50
50
  for (const job of jobs) {
51
51
  const data = job.data;
52
52
  if (opts.for) {
@@ -525,10 +525,22 @@ export class Background {
525
525
  }
526
526
  if (!queueInstance)
527
527
  throw new Error(`missing queue: ${jobConfig?.queue?.toString() || 'N/A'}`);
528
+ const jobOptions = {};
529
+ if (jobId)
530
+ jobOptions.jobId = jobId;
531
+ if (delay)
532
+ jobOptions.delay = delay;
533
+ if (delay && jobId) {
534
+ jobOptions.deduplication = {
535
+ id: jobId,
536
+ ttl: delay,
537
+ extend: true,
538
+ replace: true,
539
+ };
540
+ }
528
541
  if (groupId && priority) {
529
542
  await queueInstance.add(jobType, jobData, {
530
- delay,
531
- jobId,
543
+ ...jobOptions,
532
544
  group: {
533
545
  ...this.groupIdToGroupConfig(groupId),
534
546
  priority: this.mapPriorityWordToPriorityNumber(priority),
@@ -539,8 +551,7 @@ export class Background {
539
551
  }
540
552
  else {
541
553
  await queueInstance.add(jobType, jobData, {
542
- delay,
543
- jobId,
554
+ ...jobOptions,
544
555
  group: this.groupIdToGroupConfig(groupId),
545
556
  priority: this.mapPriorityWordToPriorityNumber(priority),
546
557
  // explicitly typing as JobsOptions because Psychic can't be aware of BullMQ Pro options
@@ -1,5 +1,5 @@
1
- import background, { Background } from '../background/index.js';
2
1
  import parallelTestSafeQueueName from '../background/helpers/parallelTestSafeQueueName.js';
2
+ import background, { Background } from '../background/index.js';
3
3
  const LOCK_TOKEN = 'psychic-test-worker';
4
4
  export default class WorkerTestUtils {
5
5
  /*
@@ -46,7 +46,7 @@ export default class WorkerTestUtils {
46
46
  if (opts.queue && !queues.length)
47
47
  throw new Error(`Expected to find queue with name: ${opts.queue}, but none were found by that name. The queue names available are: ${background.queues.map(queue => queue.name).join(', ')}`);
48
48
  for (const queue of queues) {
49
- const jobs = (await queue.getDelayed());
49
+ const jobs = await queue.getDelayed();
50
50
  for (const job of jobs) {
51
51
  const data = job.data;
52
52
  if (opts.for) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic-workers",
4
4
  "description": "Background job system for Psychic applications",
5
- "version": "2.0.0",
5
+ "version": "2.0.2",
6
6
  "author": "RVO Health",
7
7
  "repository": {
8
8
  "type": "git",
@@ -54,14 +54,14 @@
54
54
  "peerDependencies": {
55
55
  "@rvoh/dream": "^2.0.0",
56
56
  "@rvoh/psychic": "^2.0.0",
57
- "bullmq": "*",
58
- "ioredis": "*"
57
+ "bullmq": "^5.64.0",
58
+ "ioredis": "^5.8.2"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@eslint/js": "=9.0.0",
62
- "@rvoh/dream": "^2.0.0",
63
- "@rvoh/dream-spec-helpers": "^1.2.1",
64
- "@rvoh/psychic": "^2.0.0",
62
+ "@rvoh/dream": "^2.0.1",
63
+ "@rvoh/dream-spec-helpers": "^2.0.0",
64
+ "@rvoh/psychic": "^2.0.1",
65
65
  "@rvoh/psychic-spec-helpers": "^1.1.3",
66
66
  "@socket.io/redis-adapter": "^8.3.0",
67
67
  "@socket.io/redis-emitter": "^5.1.0",
@@ -69,10 +69,10 @@
69
69
  "@types/node": "^22.5.1",
70
70
  "@types/pg": "^8",
71
71
  "@types/supertest": "^6.0.3",
72
- "bullmq": "^5.52.0",
72
+ "bullmq": "^5.64.0",
73
73
  "eslint": "^9.9.1",
74
74
  "express": "^4.21.2",
75
- "ioredis": "^5.4.1",
75
+ "ioredis": "^5.8.2",
76
76
  "kysely": "^0.28.7",
77
77
  "kysely-codegen": "^0.17.0",
78
78
  "luxon-jest-matchers": "^0.1.14",
@@ -83,11 +83,11 @@
83
83
  "socket.io-adapter": "^2.5.5",
84
84
  "supertest": "^7.1.4",
85
85
  "tslib": "^2.7.0",
86
- "tsx": "^4.19.3",
86
+ "tsx": "^4.20.6",
87
87
  "typedoc": "^0.26.6",
88
88
  "typescript": "^5.8.2",
89
89
  "typescript-eslint": "=7.18.0",
90
- "vitest": "^3.2.4"
90
+ "vitest": "^4.0.10"
91
91
  },
92
92
  "packageManager": "yarn@4.7.0"
93
93
  }