@medusajs/event-bus-redis 1.8.0-rc.3 → 1.8.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/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +11 -0
- package/dist/initialize/index.js.map +1 -0
- package/dist/services/event-bus-redis.d.ts +2 -4
- package/dist/services/event-bus-redis.js +1 -2
- package/dist/services/event-bus-redis.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
18
|
};
|
|
@@ -12,4 +26,6 @@ const moduleDefinition = {
|
|
|
12
26
|
loaders,
|
|
13
27
|
};
|
|
14
28
|
exports.default = moduleDefinition;
|
|
29
|
+
__exportStar(require("./initialize"), exports);
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
15
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,wDAA8B;AAC9B,iFAA6D;AAE7D,MAAM,OAAO,GAAG,yBAAoB,CAAA;AACpC,MAAM,OAAO,GAAG,CAAC,iBAAM,CAAC,CAAA;AAExB,MAAM,gBAAgB,GAAkB;IACtC,OAAO;IACP,OAAO;CACR,CAAA;AAED,kBAAe,gBAAgB,CAAA;AAC/B,+CAA4B;AAC5B,0CAAuB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration } from "@medusajs/modules-sdk";
|
|
2
|
+
import { IEventBusService } from "@medusajs/types";
|
|
3
|
+
import { EventBusRedisModuleOptions } from "../types";
|
|
4
|
+
export declare const initialize: (options?: EventBusRedisModuleOptions | ExternalModuleDeclaration) => Promise<IEventBusService>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialize = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
const initialize = async (options) => {
|
|
6
|
+
const serviceKey = modules_sdk_1.Modules.EVENT_BUS;
|
|
7
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap(serviceKey, "@medusajs/event-bus-redis", options, undefined);
|
|
8
|
+
return loaded[serviceKey];
|
|
9
|
+
};
|
|
10
|
+
exports.initialize = initialize;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":";;;AAAA,uDAK8B;AAIvB,MAAM,UAAU,GAAG,KAAK,EAC7B,OAAgE,EACrC,EAAE;IAC7B,MAAM,UAAU,GAAG,qBAAO,CAAC,SAAS,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,0BAAY,CAAC,SAAS,CACzC,UAAU,EACV,2BAA2B,EAC3B,OAAgE,EAChE,SAAS,CACV,CAAA;IAED,OAAO,MAAM,CAAC,UAAU,CAAqB,CAAA;AAC/C,CAAC,CAAA;AAZY,QAAA,UAAU,cAYtB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { InternalModuleDeclaration, Logger } from "@medusajs/modules-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { EmitData } from "@medusajs/types";
|
|
3
3
|
import { AbstractEventBusModuleService } from "@medusajs/utils";
|
|
4
4
|
import { Queue } from "bullmq";
|
|
5
5
|
import { Redis } from "ioredis";
|
|
6
6
|
import { BullJob, EventBusRedisModuleOptions } from "../types";
|
|
7
7
|
declare type InjectedDependencies = {
|
|
8
8
|
logger: Logger;
|
|
9
|
-
configModule: ConfigModule;
|
|
10
9
|
eventBusRedisConnection: Redis;
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
@@ -14,12 +13,11 @@ declare type InjectedDependencies = {
|
|
|
14
13
|
* subscribers when events happen. Events will run asynchronously.
|
|
15
14
|
*/
|
|
16
15
|
export default class RedisEventBusService extends AbstractEventBusModuleService {
|
|
17
|
-
protected readonly config_: ConfigModule;
|
|
18
16
|
protected readonly logger_: Logger;
|
|
19
17
|
protected readonly moduleOptions_: EventBusRedisModuleOptions;
|
|
20
18
|
protected readonly moduleDeclaration_: InternalModuleDeclaration;
|
|
21
19
|
protected queue_: Queue;
|
|
22
|
-
constructor({
|
|
20
|
+
constructor({ logger, eventBusRedisConnection }: InjectedDependencies, moduleOptions: EventBusRedisModuleOptions | undefined, moduleDeclaration: InternalModuleDeclaration);
|
|
23
21
|
/**
|
|
24
22
|
* Emit a single event
|
|
25
23
|
* @param {string} eventName - the name of the event to be process.
|
|
@@ -8,7 +8,7 @@ const bullmq_1 = require("bullmq");
|
|
|
8
8
|
*/
|
|
9
9
|
// eslint-disable-next-line max-len
|
|
10
10
|
class RedisEventBusService extends utils_1.AbstractEventBusModuleService {
|
|
11
|
-
constructor({
|
|
11
|
+
constructor({ logger, eventBusRedisConnection }, moduleOptions = {}, moduleDeclaration) {
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
// eslint-disable-next-line prefer-rest-params
|
|
14
14
|
super(...arguments);
|
|
@@ -76,7 +76,6 @@ class RedisEventBusService extends utils_1.AbstractEventBusModuleService {
|
|
|
76
76
|
return Promise.resolve(subscribersResult);
|
|
77
77
|
};
|
|
78
78
|
this.moduleOptions_ = moduleOptions;
|
|
79
|
-
this.config_ = configModule;
|
|
80
79
|
this.logger_ = logger;
|
|
81
80
|
this.queue_ = new bullmq_1.Queue(moduleOptions.queueName ?? `events-queue`, {
|
|
82
81
|
prefix: `${this.constructor.name}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-redis.js","sourceRoot":"","sources":["../../src/services/event-bus-redis.ts"],"names":[],"mappings":";;AAEA,2CAA+D;AAC/D,mCAAmE;
|
|
1
|
+
{"version":3,"file":"event-bus-redis.js","sourceRoot":"","sources":["../../src/services/event-bus-redis.ts"],"names":[],"mappings":";;AAEA,2CAA+D;AAC/D,mCAAmE;AASnE;;;GAGG;AACH,mCAAmC;AACnC,MAAqB,oBAAqB,SAAQ,qCAA6B;IAQ7E,YACE,EAAE,MAAM,EAAE,uBAAuB,EAAwB,EACzD,gBAA4C,EAAE,EAC9C,iBAA4C;QAE5C,aAAa;QACb,8CAA8C;QAC9C,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QA+ErB;;;;WAIG;QACH,YAAO,GAAG,KAAK,EAAK,GAAe,EAAoB,EAAE;YACvD,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAA;YACpC,MAAM,gBAAgB,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IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;gBACtD,IAAI,EAAE;oBACJ,GAAG,IAAI;oBACP,gBAAgB;oBAChB,GAAG,KAAK,CAAC,OAAO;iBACjB;aACF,CAAC,CAAC;YACL,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,eAAyB;oBAC/B,IAAI,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE;oBAC1C,IAAI,EAAE;wBACJ,GAAG,IAAI;wBACP,gBAAgB;wBAChB,GAAG,OAAO;qBACX;iBACF;aACF,CAAA;QAEL,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,CAAC;CAmGF;AA/LD,uCA+LC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/event-bus-redis",
|
|
3
|
-
"version": "1.8.0
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Redis Event Bus Module for Medusa",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"author": "Medusa",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@medusajs/types": "
|
|
20
|
+
"@medusajs/types": "1.8.0",
|
|
21
21
|
"cross-env": "^5.2.1",
|
|
22
22
|
"jest": "^25.5.2",
|
|
23
|
-
"medusa-test-utils": "^1.1.40
|
|
23
|
+
"medusa-test-utils": "^1.1.40",
|
|
24
24
|
"ts-jest": "^25.5.1",
|
|
25
25
|
"typescript": "^4.4.4"
|
|
26
26
|
},
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"test:unit": "jest --passWithNoTests"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@medusajs/modules-sdk": "
|
|
36
|
-
"@medusajs/utils": "
|
|
35
|
+
"@medusajs/modules-sdk": "1.8.0",
|
|
36
|
+
"@medusajs/utils": "1.8.0",
|
|
37
37
|
"awilix": "^8.0.0",
|
|
38
38
|
"bullmq": "^3.5.6",
|
|
39
39
|
"ioredis": "^5.2.5"
|