@tsed/bullmq 7.79.4 → 7.80.1

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.
@@ -0,0 +1,23 @@
1
+ import { BeforeInit, OnDestroy } from "@tsed/common";
2
+ import { InjectorService } from "@tsed/di";
3
+ import { BullMQConfig } from "./config/config.js";
4
+ import { JobDispatcher } from "./dispatchers/index.js";
5
+ export declare class BullMQModule implements BeforeInit, OnDestroy {
6
+ private readonly injector;
7
+ private readonly dispatcher;
8
+ constructor(injector: InjectorService, dispatcher: JobDispatcher);
9
+ get config(): BullMQConfig;
10
+ $beforeInit(): void;
11
+ $onDestroy(): Promise<void>;
12
+ isEnabled(): boolean;
13
+ isWorkerEnabled(): boolean | undefined;
14
+ private buildQueues;
15
+ private buildWorkers;
16
+ /**
17
+ * Auto discover queue names from provider and merge it with queue names from global configuration.
18
+ * @private
19
+ */
20
+ private getUniqQueueNames;
21
+ private getJob;
22
+ private onProcess;
23
+ }
@@ -0,0 +1,54 @@
1
+ import type { ConnectionOptions, DefaultJobOptions, QueueOptions, WorkerOptions } from "bullmq";
2
+ export type BullMQConfig = {
3
+ /**
4
+ * Specify queue name's to create
5
+ */
6
+ queues?: string[];
7
+ /**
8
+ * Default connection to use for queue's and worker's
9
+ */
10
+ connection: ConnectionOptions;
11
+ /**
12
+ * @deprecated Use defaultQueueOptions instead. Will be removed in the next major release
13
+ */
14
+ defaultJobOptions?: DefaultJobOptions;
15
+ /**
16
+ * Default queue options which are applied to every queue
17
+ *
18
+ * Can be extended/overridden by `queueOptions`
19
+ */
20
+ defaultQueueOptions?: Partial<QueueOptions>;
21
+ /**
22
+ * Specify additional queue options by queue name
23
+ */
24
+ queueOptions?: Record<string, Partial<QueueOptions>>;
25
+ /**
26
+ * Disable the creation of any worker.
27
+ *
28
+ * All other worker configuration will be ignored
29
+ */
30
+ disableWorker?: boolean;
31
+ /**
32
+ * Specify for which queues to start a worker for.
33
+ *
34
+ * Defaultly for every queue added in the `queues` parameter
35
+ */
36
+ workerQueues?: string[];
37
+ /**
38
+ * Default worker options which are applied to every worker
39
+ *
40
+ * Can be extended/overridden by `workerOptions`
41
+ */
42
+ defaultWorkerOptions?: Partial<WorkerOptions>;
43
+ /**
44
+ * Specify additional worker options by queue name
45
+ */
46
+ workerOptions?: Record<string, Partial<WorkerOptions>>;
47
+ };
48
+ declare global {
49
+ namespace TsED {
50
+ interface Configuration {
51
+ bullmq?: BullMQConfig;
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum BullMQTypes {
2
+ CRON = "bullmq:cron",
3
+ QUEUE = "bullmq:queue",
4
+ JOB = "bullmq:job",
5
+ WORKER = "bullmq:worker",
6
+ FALLBACK_JOB = "bullmq:fallback-job"
7
+ }
@@ -0,0 +1 @@
1
+ export declare const BULLMQ = "bullmq";
@@ -0,0 +1,5 @@
1
+ import { Job } from "bullmq";
2
+ export interface JobMethods<DataType = unknown, ReturnType = unknown> {
3
+ handle(payload: DataType, job: Job<DataType, ReturnType>): ReturnType | Promise<ReturnType>;
4
+ jobId?(payload: DataType): string | Promise<string>;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { JobsOptions } from "bullmq";
2
+ export interface JobStore {
3
+ name: string;
4
+ queue: string;
5
+ opts: JobsOptions;
6
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./JobMethods.js";
5
+ export * from "./JobStore.js";
@@ -0,0 +1 @@
1
+ export declare function InjectQueue(name: string): Function;
@@ -0,0 +1 @@
1
+ export declare function InjectWorker(name: string): Function;
@@ -0,0 +1,3 @@
1
+ import { JobsOptions } from "bullmq";
2
+ export declare function JobController(name: string, queue?: string, opts?: JobsOptions): any;
3
+ export declare function FallbackJobController(queue?: string): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./InjectQueue.js";
5
+ export * from "./InjectWorker.js";
6
+ export * from "./JobController.js";
@@ -0,0 +1,14 @@
1
+ import { Type } from "@tsed/core";
2
+ import { InjectorService } from "@tsed/di";
3
+ import { Job as BullMQJob, JobsOptions } from "bullmq";
4
+ import { JobMethods } from "../contracts/index.js";
5
+ import type { JobDispatcherOptions } from "./JobDispatcherOptions.js";
6
+ export declare class JobDispatcher {
7
+ private readonly injector;
8
+ constructor(injector: InjectorService);
9
+ dispatch<T extends JobMethods>(job: Type<T>, payload?: Parameters<T["handle"]>[0], options?: JobsOptions): Promise<BullMQJob>;
10
+ dispatch<P = unknown>(job: JobDispatcherOptions, payload?: P, options?: JobsOptions): Promise<BullMQJob>;
11
+ dispatch<P = unknown>(job: string, payload?: P, options?: JobsOptions): Promise<BullMQJob>;
12
+ private resolveDispatchArgs;
13
+ private retrieveJobOptionsFromClassBasedJob;
14
+ }
@@ -0,0 +1,4 @@
1
+ export interface JobDispatcherOptions {
2
+ queue: string;
3
+ name: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./JobDispatcher.js";
5
+ export * from "./JobDispatcherOptions.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./BullMQModule.js";
5
+ export * from "./config/config.js";
6
+ export * from "./constants/BullMQTypes.js";
7
+ export * from "./constants/constants.js";
8
+ export * from "./contracts/index.js";
9
+ export * from "./contracts/JobMethods.js";
10
+ export * from "./contracts/JobStore.js";
11
+ export * from "./decorators/index.js";
12
+ export * from "./decorators/InjectQueue.js";
13
+ export * from "./decorators/InjectWorker.js";
14
+ export * from "./decorators/JobController.js";
15
+ export * from "./dispatchers/index.js";
16
+ export * from "./dispatchers/JobDispatcher.js";
17
+ export * from "./dispatchers/JobDispatcherOptions.js";
18
+ export * from "./utils/createQueueProvider.js";
19
+ export * from "./utils/createWorkerProvider.js";
20
+ export * from "./utils/getJobToken.js";
21
+ export * from "./utils/getQueueToken.js";
22
+ export * from "./utils/getWorkerToken.js";
23
+ export * from "./utils/mapQueueOptions.js";
24
+ export * from "./utils/mapWorkerOptions.js";
@@ -0,0 +1,3 @@
1
+ import { InjectorService } from "@tsed/di";
2
+ import { Queue, QueueOptions } from "bullmq";
3
+ export declare function createQueueProvider(injector: InjectorService, queue: string, opts: QueueOptions): Queue<any, any, string>;
@@ -0,0 +1,3 @@
1
+ import { InjectorService } from "@tsed/di";
2
+ import { Job, Worker, WorkerOptions } from "bullmq";
3
+ export declare function createWorkerProvider(injector: InjectorService, worker: string, process: (job: Job) => any, opts: WorkerOptions): Worker<any, any, string>;
@@ -0,0 +1,2 @@
1
+ export declare function getJobToken(queue: string, name: string): string;
2
+ export declare function getFallbackJobToken(queue?: string): string;
@@ -0,0 +1 @@
1
+ export declare function getQueueToken(queue: string): string;
@@ -0,0 +1 @@
1
+ export declare function getWorkerToken(worker: string): string;
@@ -0,0 +1,3 @@
1
+ import type { QueueOptions } from "bullmq";
2
+ import { BullMQConfig } from "../config/config.js";
3
+ export declare function mapQueueOptions(queue: string, bullMQConfig: BullMQConfig): QueueOptions;
@@ -0,0 +1,3 @@
1
+ import type { WorkerOptions } from "bullmq";
2
+ import { BullMQConfig } from "../config/config.js";
3
+ export declare function mapWorkerOptions(queue: string, bullMQConfig: BullMQConfig): WorkerOptions;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@tsed/bullmq",
3
- "version": "7.79.4",
4
3
  "description": "BullMQ integration for Ts.ED",
4
+ "type": "commonjs",
5
+ "version": "7.80.1",
5
6
  "keywords": [
6
7
  "Ts.ED",
7
8
  "BullMQ"
@@ -11,32 +12,34 @@
11
12
  "module": "./lib/esm/index.js",
12
13
  "typings": "./lib/types/index.d.ts",
13
14
  "exports": {
14
- "types": "./lib/types/index.d.ts",
15
- "import": "./lib/esm/index.js",
16
- "require": "./lib/cjs/index.js",
17
- "default": "./lib/esm/index.js"
15
+ ".": {
16
+ "types": "./lib/types/index.d.ts",
17
+ "import": "./lib/esm/index.js",
18
+ "default": "./lib/cjs/index.js"
19
+ }
18
20
  },
19
21
  "scripts": {
20
22
  "build": "yarn barrels && yarn build:ts",
21
23
  "barrels": "barrels",
22
- "test": "jest --runInBand && jest-coverage-thresholds-bumper",
23
- "build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json"
24
+ "test": "vitest run",
25
+ "build:ts": "tsc --build tsconfig.json",
26
+ "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
24
27
  },
25
28
  "dependencies": {
26
29
  "tslib": "2.6.1"
27
30
  },
28
31
  "devDependencies": {
29
- "@tsed/barrels": "7.79.4",
30
- "@tsed/common": "7.79.4",
31
- "@tsed/core": "7.79.4",
32
- "@tsed/di": "7.79.4",
33
- "@tsed/schema": "7.79.4",
34
- "@tsed/typescript": "7.79.4",
32
+ "@tsed/barrels": "7.80.1",
33
+ "@tsed/common": "7.80.1",
34
+ "@tsed/core": "7.80.1",
35
+ "@tsed/di": "7.80.1",
36
+ "@tsed/schema": "7.80.1",
37
+ "@tsed/typescript": "7.80.1",
35
38
  "bullmq": "^4.12.3 || ^5.1.1",
36
39
  "eslint": "^8.57.0",
37
- "jest": "^29.7.0",
38
40
  "ts-mockito": "^2.6.1",
39
- "typescript": "4.9.5"
41
+ "typescript": "4.9.5",
42
+ "vitest": "2.0.4"
40
43
  },
41
44
  "peerDependencies": {
42
45
  "bullmq": "^4.12.3 || ^5.1.1"
@@ -0,0 +1,21 @@
1
+ // @ts-ignore
2
+ import {presets} from "@tsed/vitest/presets";
3
+ import {defineConfig} from "vitest/config";
4
+
5
+ export default defineConfig(
6
+ {
7
+ ...presets,
8
+ test: {
9
+ ...presets.test,
10
+ coverage: {
11
+ ...presets.test.coverage,
12
+ thresholds: {
13
+ statements: 0,
14
+ branches: 0,
15
+ functions: 0,
16
+ lines: 0
17
+ }
18
+ }
19
+ }
20
+ }
21
+ );
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }