@tsed/bullmq 7.79.4 → 7.80.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/lib/types-esm/BullMQModule.d.ts +23 -0
- package/lib/types-esm/config/config.d.ts +54 -0
- package/lib/types-esm/constants/BullMQTypes.d.ts +7 -0
- package/lib/types-esm/constants/constants.d.ts +1 -0
- package/lib/types-esm/contracts/JobMethods.d.ts +5 -0
- package/lib/types-esm/contracts/JobStore.d.ts +6 -0
- package/lib/types-esm/contracts/index.d.ts +5 -0
- package/lib/types-esm/decorators/InjectQueue.d.ts +1 -0
- package/lib/types-esm/decorators/InjectWorker.d.ts +1 -0
- package/lib/types-esm/decorators/JobController.d.ts +3 -0
- package/lib/types-esm/decorators/index.d.ts +6 -0
- package/lib/types-esm/dispatchers/JobDispatcher.d.ts +14 -0
- package/lib/types-esm/dispatchers/JobDispatcherOptions.d.ts +4 -0
- package/lib/types-esm/dispatchers/index.d.ts +5 -0
- package/lib/types-esm/index.d.ts +24 -0
- package/lib/types-esm/utils/createQueueProvider.d.ts +3 -0
- package/lib/types-esm/utils/createWorkerProvider.d.ts +3 -0
- package/lib/types-esm/utils/getJobToken.d.ts +2 -0
- package/lib/types-esm/utils/getQueueToken.d.ts +1 -0
- package/lib/types-esm/utils/getWorkerToken.d.ts +1 -0
- package/lib/types-esm/utils/mapQueueOptions.d.ts +3 -0
- package/lib/types-esm/utils/mapWorkerOptions.d.ts +3 -0
- package/package.json +18 -15
- package/vitest.config.mts +21 -0
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
|
@@ -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 @@
|
|
|
1
|
+
export declare const BULLMQ = "bullmq";
|
|
@@ -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,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,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 @@
|
|
|
1
|
+
export declare function getQueueToken(queue: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWorkerToken(worker: string): string;
|
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.0",
|
|
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
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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": "
|
|
23
|
-
"build:ts": "tsc --build tsconfig.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.
|
|
30
|
-
"@tsed/common": "7.
|
|
31
|
-
"@tsed/core": "7.
|
|
32
|
-
"@tsed/di": "7.
|
|
33
|
-
"@tsed/schema": "7.
|
|
34
|
-
"@tsed/typescript": "7.
|
|
32
|
+
"@tsed/barrels": "7.80.0",
|
|
33
|
+
"@tsed/common": "7.80.0",
|
|
34
|
+
"@tsed/core": "7.80.0",
|
|
35
|
+
"@tsed/di": "7.80.0",
|
|
36
|
+
"@tsed/schema": "7.80.0",
|
|
37
|
+
"@tsed/typescript": "7.80.0",
|
|
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
|
+
);
|
package/lib/cjs/package.json
DELETED
package/lib/esm/package.json
DELETED