@nest-boot/bullmq-mikro-orm 7.0.0-beta.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.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bullmq-mikro-orm-module-options.interface.d.ts +10 -0
  3. package/dist/bullmq-mikro-orm-module-options.interface.js +3 -0
  4. package/dist/bullmq-mikro-orm-module-options.interface.js.map +1 -0
  5. package/dist/bullmq-mikro-orm.module-definition.d.ts +2 -0
  6. package/dist/bullmq-mikro-orm.module-definition.js +9 -0
  7. package/dist/bullmq-mikro-orm.module-definition.js.map +1 -0
  8. package/dist/bullmq-mikro-orm.module.d.ts +8 -0
  9. package/dist/bullmq-mikro-orm.module.js +30 -0
  10. package/dist/bullmq-mikro-orm.module.js.map +1 -0
  11. package/dist/bullmq-mikro-orm.service.d.ts +19 -0
  12. package/dist/bullmq-mikro-orm.service.js +107 -0
  13. package/dist/bullmq-mikro-orm.service.js.map +1 -0
  14. package/dist/entities/job.entity.d.ts +17 -0
  15. package/dist/entities/job.entity.js +81 -0
  16. package/dist/entities/job.entity.js.map +1 -0
  17. package/dist/enums/job-status.enum.d.ts +10 -0
  18. package/dist/enums/job-status.enum.js +15 -0
  19. package/dist/enums/job-status.enum.js.map +1 -0
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +21 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/tsconfig.build.tsbuildinfo +1 -0
  24. package/dist/utils/convert-bullmq-job-state-to-job-status.util.d.ts +8 -0
  25. package/dist/utils/convert-bullmq-job-state-to-job-status.util.js +30 -0
  26. package/dist/utils/convert-bullmq-job-state-to-job-status.util.js.map +1 -0
  27. package/dist/utils/should-include-queue.util.d.ts +14 -0
  28. package/dist/utils/should-include-queue.util.js +29 -0
  29. package/dist/utils/should-include-queue.util.js.map +1 -0
  30. package/dist/utils/should-include-queue.util.spec.d.ts +1 -0
  31. package/dist/utils/should-include-queue.util.spec.js +62 -0
  32. package/dist/utils/should-include-queue.util.spec.js.map +1 -0
  33. package/package.json +74 -0
@@ -0,0 +1,8 @@
1
+ import { JobState } from "bullmq";
2
+ import { JobStatus } from "../enums/job-status.enum";
3
+ /**
4
+ * 将 BullMQ 的任务状态转换为内部 JobStatus 枚举
5
+ * @param state BullMQ 任务状态或 "unknown"
6
+ * @returns 对应的 JobStatus 枚举值
7
+ */
8
+ export declare function convertBullmqJobStateToJobStatus(state: JobState | "unknown"): JobStatus;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertBullmqJobStateToJobStatus = convertBullmqJobStateToJobStatus;
4
+ const job_status_enum_1 = require("../enums/job-status.enum");
5
+ /**
6
+ * 将 BullMQ 的任务状态转换为内部 JobStatus 枚举
7
+ * @param state BullMQ 任务状态或 "unknown"
8
+ * @returns 对应的 JobStatus 枚举值
9
+ */
10
+ function convertBullmqJobStateToJobStatus(state) {
11
+ switch (state) {
12
+ case "active":
13
+ return job_status_enum_1.JobStatus.ACTIVE;
14
+ case "completed":
15
+ return job_status_enum_1.JobStatus.COMPLETED;
16
+ case "delayed":
17
+ return job_status_enum_1.JobStatus.DELAYED;
18
+ case "failed":
19
+ return job_status_enum_1.JobStatus.FAILED;
20
+ case "prioritized":
21
+ return job_status_enum_1.JobStatus.PRIORITIZED;
22
+ case "waiting":
23
+ return job_status_enum_1.JobStatus.WAITING;
24
+ case "waiting-children":
25
+ return job_status_enum_1.JobStatus.WAITING_CHILDREN;
26
+ default:
27
+ return job_status_enum_1.JobStatus.UNKNOWN;
28
+ }
29
+ }
30
+ //# sourceMappingURL=convert-bullmq-job-state-to-job-status.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-bullmq-job-state-to-job-status.util.js","sourceRoot":"","sources":["../../src/utils/convert-bullmq-job-state-to-job-status.util.ts"],"names":[],"mappings":";;AASA,4EA4BC;AAnCD,8DAAqD;AAErD;;;;GAIG;AACH,SAAgB,gCAAgC,CAC9C,KAA2B;IAE3B,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,2BAAS,CAAC,MAAM,CAAC;QAE1B,KAAK,WAAW;YACd,OAAO,2BAAS,CAAC,SAAS,CAAC;QAE7B,KAAK,SAAS;YACZ,OAAO,2BAAS,CAAC,OAAO,CAAC;QAE3B,KAAK,QAAQ;YACX,OAAO,2BAAS,CAAC,MAAM,CAAC;QAE1B,KAAK,aAAa;YAChB,OAAO,2BAAS,CAAC,WAAW,CAAC;QAE/B,KAAK,SAAS;YACZ,OAAO,2BAAS,CAAC,OAAO,CAAC;QAE3B,KAAK,kBAAkB;YACrB,OAAO,2BAAS,CAAC,gBAAgB,CAAC;QAEpC;YACE,OAAO,2BAAS,CAAC,OAAO,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 判断队列是否应该被包含
3
+ * @param queueName 队列名称
4
+ * @param includeQueues 包含的队列列表(为空表示包含所有)
5
+ * @param excludeQueues 排除的队列列表
6
+ * @returns 如果队列应该被包含则返回 true
7
+ *
8
+ * 规则:
9
+ * 1. 如果在 excludeQueues 中,返回 false
10
+ * 2. 如果 includeQueues 为空,返回 true(包含所有未排除的队列)
11
+ * 3. 如果在 includeQueues 中,返回 true
12
+ * 4. 否则返回 false
13
+ */
14
+ export declare function shouldIncludeQueue(queueName: string, includeQueues: string[], excludeQueues: string[]): boolean;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldIncludeQueue = shouldIncludeQueue;
4
+ /**
5
+ * 判断队列是否应该被包含
6
+ * @param queueName 队列名称
7
+ * @param includeQueues 包含的队列列表(为空表示包含所有)
8
+ * @param excludeQueues 排除的队列列表
9
+ * @returns 如果队列应该被包含则返回 true
10
+ *
11
+ * 规则:
12
+ * 1. 如果在 excludeQueues 中,返回 false
13
+ * 2. 如果 includeQueues 为空,返回 true(包含所有未排除的队列)
14
+ * 3. 如果在 includeQueues 中,返回 true
15
+ * 4. 否则返回 false
16
+ */
17
+ function shouldIncludeQueue(queueName, includeQueues, excludeQueues) {
18
+ // 优先检查排除列表
19
+ if (excludeQueues.includes(queueName)) {
20
+ return false;
21
+ }
22
+ // 如果没有指定包含列表,则包含所有未排除的队列
23
+ if (includeQueues.length === 0) {
24
+ return true;
25
+ }
26
+ // 检查是否在包含列表中
27
+ return includeQueues.includes(queueName);
28
+ }
29
+ //# sourceMappingURL=should-include-queue.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"should-include-queue.util.js","sourceRoot":"","sources":["../../src/utils/should-include-queue.util.ts"],"names":[],"mappings":";;AAaA,gDAiBC;AA9BD;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAChC,SAAiB,EACjB,aAAuB,EACvB,aAAuB;IAEvB,WAAW;IACX,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yBAAyB;IACzB,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa;IACb,OAAO,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const should_include_queue_util_1 = require("./should-include-queue.util");
4
+ describe("shouldIncludeQueue", () => {
5
+ describe("当没有设置任何过滤器", () => {
6
+ it("应该包含所有队列", () => {
7
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("any-queue", [], [])).toBe(true);
8
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("test-queue", [], [])).toBe(true);
9
+ });
10
+ });
11
+ describe("当只设置了 excludeQueues", () => {
12
+ const excludeQueues = ["debug-queue", "test-queue"];
13
+ it("应该排除在列表中的队列", () => {
14
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("debug-queue", [], excludeQueues)).toBe(false);
15
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("test-queue", [], excludeQueues)).toBe(false);
16
+ });
17
+ it("应该包含不在列表中的队列", () => {
18
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("production-queue", [], excludeQueues)).toBe(true);
19
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("email-queue", [], excludeQueues)).toBe(true);
20
+ });
21
+ });
22
+ describe("当只设置了 includeQueues", () => {
23
+ const includeQueues = ["email-queue", "notification-queue"];
24
+ it("应该包含在列表中的队列", () => {
25
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("email-queue", includeQueues, [])).toBe(true);
26
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("notification-queue", includeQueues, [])).toBe(true);
27
+ });
28
+ it("应该排除不在列表中的队列", () => {
29
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("debug-queue", includeQueues, [])).toBe(false);
30
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("other-queue", includeQueues, [])).toBe(false);
31
+ });
32
+ });
33
+ describe("当同时设置了 includeQueues 和 excludeQueues", () => {
34
+ const includeQueues = ["email-queue", "notification-queue", "debug-queue"];
35
+ const excludeQueues = ["debug-queue"];
36
+ it("excludeQueues 应该优先于 includeQueues", () => {
37
+ // debug-queue 在 includeQueues 中,但也在 excludeQueues 中
38
+ // 应该被排除
39
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("debug-queue", includeQueues, excludeQueues)).toBe(false);
40
+ });
41
+ it("应该包含在 includeQueues 中且不在 excludeQueues 中的队列", () => {
42
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("email-queue", includeQueues, excludeQueues)).toBe(true);
43
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("notification-queue", includeQueues, excludeQueues)).toBe(true);
44
+ });
45
+ it("应该排除不在 includeQueues 中的队列", () => {
46
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("other-queue", includeQueues, excludeQueues)).toBe(false);
47
+ });
48
+ });
49
+ describe("边界情况", () => {
50
+ it("应该处理空字符串队列名", () => {
51
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("", [], [])).toBe(true);
52
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("", [""], [])).toBe(true);
53
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("", [], [""])).toBe(false);
54
+ });
55
+ it("应该区分大小写", () => {
56
+ const includeQueues = ["Email-Queue"];
57
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("email-queue", includeQueues, [])).toBe(false);
58
+ expect((0, should_include_queue_util_1.shouldIncludeQueue)("Email-Queue", includeQueues, [])).toBe(true);
59
+ });
60
+ });
61
+ });
62
+ //# sourceMappingURL=should-include-queue.util.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"should-include-queue.util.spec.js","sourceRoot":"","sources":["../../src/utils/should-include-queue.util.spec.ts"],"names":[],"mappings":";;AAAA,2EAAiE;AAEjE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAClB,MAAM,CAAC,IAAA,8CAAkB,EAAC,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3D,MAAM,CAAC,IAAA,8CAAkB,EAAC,YAAY,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,MAAM,aAAa,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAEpD,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;YACrB,MAAM,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AAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpD,MAAM,CAAC,IAAA,8CAAkB,EAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACjB,MAAM,aAAa,GAAG,CAAC,aAAa,CAAC,CAAC;YACtC,MAAM,CAAC,IAAA,8CAAkB,EAAC,aAAa,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzE,MAAM,CAAC,IAAA,8CAAkB,EAAC,aAAa,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@nest-boot/bullmq-mikro-orm",
3
+ "version": "7.0.0-beta.2",
4
+ "description": "",
5
+ "author": "d4rkcr0w <me@d4rkcr0w.com>",
6
+ "homepage": "",
7
+ "license": "MIT",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "directories": {
11
+ "lib": "dist"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "templates"
16
+ ],
17
+ "devDependencies": {
18
+ "@mikro-orm/core": "^6.5.8",
19
+ "@nest-boot/bullmq": "^7.0.0-beta.9",
20
+ "@nest-boot/eslint-config": "^7.0.0-beta.3",
21
+ "@nest-boot/eslint-plugin": "^7.0.0-beta.3",
22
+ "@nest-boot/request-context": "^7.0.0-beta.4",
23
+ "@nest-boot/schedule": "^7.0.0-beta.15",
24
+ "@nest-boot/tsconfig": "^7.0.0-beta.1",
25
+ "@nestjs/bullmq": "^11.0.4",
26
+ "@nestjs/common": "^11.1.6",
27
+ "@nestjs/core": "^11.1.6",
28
+ "@nestjs/testing": "^11.1.6",
29
+ "@types/jest": "^29.5.14",
30
+ "@types/node": "^22.18.6",
31
+ "bullmq": "^5.61.0",
32
+ "dotenv": "^17.2.3",
33
+ "eslint": "^9.36.0",
34
+ "jest": "^29.7.0",
35
+ "reflect-metadata": "^0.2.2",
36
+ "rxjs": "^7.8.2",
37
+ "ts-jest": "^29.4.4",
38
+ "typescript": "^5.9.3"
39
+ },
40
+ "peerDependencies": {
41
+ "@mikro-orm/core": "^6.0.0",
42
+ "@nest-boot/bullmq": "^7.0.0-beta.9",
43
+ "@nest-boot/request-context": "^7.0.0-beta.4",
44
+ "@nest-boot/schedule": "^7.0.0-beta.15",
45
+ "@nestjs/bullmq": "^11.0.0",
46
+ "@nestjs/common": "^11.0.0",
47
+ "@nestjs/core": "^11.0.0",
48
+ "bullmq": "^5.0.0",
49
+ "reflect-metadata": "^0.2.2",
50
+ "rxjs": "^7.0.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "lint-staged": {
56
+ "*.ts": [
57
+ "prettier --write",
58
+ "eslint --fix"
59
+ ]
60
+ },
61
+ "volta": {
62
+ "extends": "../../package.json"
63
+ },
64
+ "scripts": {
65
+ "build": "tsc -p tsconfig.build.json",
66
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
67
+ "dev": "tsc -w -p tsconfig.build.json",
68
+ "lint": "eslint \"{src,test}/**/*.ts\" --fix",
69
+ "test": "jest",
70
+ "test:cov": "jest --coverage",
71
+ "test:watch": "jest --watch",
72
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
73
+ }
74
+ }