medusa-test-utils 1.1.45-snapshot-20240607093839 → 1.1.45-snapshot-20240703074611
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database.js +56 -142
- package/dist/database.js.map +1 -1
- package/dist/events.js +7 -54
- package/dist/events.js.map +1 -1
- package/dist/id-map.js +8 -13
- package/dist/id-map.js.map +1 -1
- package/dist/init-modules.js +37 -98
- package/dist/init-modules.js.map +1 -1
- package/dist/jest.js +14 -62
- package/dist/jest.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.js +48 -141
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/use-db.js +26 -99
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner.d.ts +7 -0
- package/dist/medusa-test-runner.js +130 -290
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/mock-event-bus-service.d.ts +4 -4
- package/dist/mock-event-bus-service.js +13 -53
- package/dist/mock-event-bus-service.js.map +1 -1
- package/dist/module-test-runner.js +57 -128
- package/dist/module-test-runner.js.map +1 -1
- package/package.json +6 -6
@@ -1,167 +1,60 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
40
|
-
if (m) return m.call(o);
|
41
|
-
if (o && typeof o.length === "number") return {
|
42
|
-
next: function () {
|
43
|
-
if (o && i >= o.length) o = void 0;
|
44
|
-
return { value: o && o[i++], done: !o };
|
45
|
-
}
|
46
|
-
};
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
48
|
-
};
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
50
3
|
exports.medusaIntegrationTestRunner = void 0;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
const pg_god_1 = require("pg-god");
|
6
|
+
const database_1 = require("./database");
|
7
|
+
const bootstrap_app_1 = require("./medusa-test-runner-utils/bootstrap-app");
|
8
|
+
const use_db_1 = require("./medusa-test-runner-utils/use-db");
|
9
|
+
const axios = require("axios").default;
|
10
|
+
const DB_HOST = process.env.DB_HOST;
|
11
|
+
const DB_USERNAME = process.env.DB_USERNAME;
|
12
|
+
const DB_PASSWORD = process.env.DB_PASSWORD;
|
13
|
+
const pgGodCredentials = {
|
61
14
|
user: DB_USERNAME,
|
62
15
|
password: DB_PASSWORD,
|
63
16
|
host: DB_HOST,
|
64
17
|
};
|
65
|
-
|
18
|
+
const dbTestUtilFactory = () => ({
|
66
19
|
pgConnection_: null,
|
67
|
-
create: function (dbName) {
|
68
|
-
|
69
|
-
return __generator(this, function (_a) {
|
70
|
-
switch (_a.label) {
|
71
|
-
case 0: return [4 /*yield*/, (0, pg_god_1.createDatabase)({ databaseName: dbName }, pgGodCredentials)];
|
72
|
-
case 1:
|
73
|
-
_a.sent();
|
74
|
-
return [2 /*return*/];
|
75
|
-
}
|
76
|
-
});
|
77
|
-
});
|
20
|
+
create: async function (dbName) {
|
21
|
+
await (0, pg_god_1.createDatabase)({ databaseName: dbName }, pgGodCredentials);
|
78
22
|
},
|
79
|
-
teardown: function () {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
_d.sent();
|
95
|
-
return [4 /*yield*/, runRawQuery("SELECT table_name\n FROM information_schema.tables\n WHERE table_schema = '".concat(schema, "';"))];
|
96
|
-
case 2:
|
97
|
-
tableNames = (_d.sent()).rows;
|
98
|
-
_d.label = 3;
|
99
|
-
case 3:
|
100
|
-
_d.trys.push([3, 8, 9, 10]);
|
101
|
-
tableNames_1 = __values(tableNames), tableNames_1_1 = tableNames_1.next();
|
102
|
-
_d.label = 4;
|
103
|
-
case 4:
|
104
|
-
if (!!tableNames_1_1.done) return [3 /*break*/, 7];
|
105
|
-
table_name = tableNames_1_1.value.table_name;
|
106
|
-
return [4 /*yield*/, runRawQuery("DELETE\n FROM ".concat(schema, ".\"").concat(table_name, "\";"))];
|
107
|
-
case 5:
|
108
|
-
_d.sent();
|
109
|
-
_d.label = 6;
|
110
|
-
case 6:
|
111
|
-
tableNames_1_1 = tableNames_1.next();
|
112
|
-
return [3 /*break*/, 4];
|
113
|
-
case 7: return [3 /*break*/, 10];
|
114
|
-
case 8:
|
115
|
-
e_1_1 = _d.sent();
|
116
|
-
e_1 = { error: e_1_1 };
|
117
|
-
return [3 /*break*/, 10];
|
118
|
-
case 9:
|
119
|
-
try {
|
120
|
-
if (tableNames_1_1 && !tableNames_1_1.done && (_b = tableNames_1.return)) _b.call(tableNames_1);
|
121
|
-
}
|
122
|
-
finally { if (e_1) throw e_1.error; }
|
123
|
-
return [7 /*endfinally*/];
|
124
|
-
case 10: return [4 /*yield*/, runRawQuery("SET session_replication_role = 'origin';")];
|
125
|
-
case 11:
|
126
|
-
_d.sent();
|
127
|
-
return [2 /*return*/];
|
128
|
-
}
|
129
|
-
});
|
130
|
-
});
|
23
|
+
teardown: async function ({ schema } = {}) {
|
24
|
+
if (!this.pgConnection_) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
const runRawQuery = this.pgConnection_.raw.bind(this.pgConnection_);
|
28
|
+
schema ??= "public";
|
29
|
+
await runRawQuery(`SET session_replication_role = 'replica';`);
|
30
|
+
const { rows: tableNames } = await runRawQuery(`SELECT table_name
|
31
|
+
FROM information_schema.tables
|
32
|
+
WHERE table_schema = '${schema}';`);
|
33
|
+
for (const { table_name } of tableNames) {
|
34
|
+
await runRawQuery(`DELETE
|
35
|
+
FROM ${schema}."${table_name}";`);
|
36
|
+
}
|
37
|
+
await runRawQuery(`SET session_replication_role = 'origin';`);
|
131
38
|
},
|
132
|
-
shutdown: function (dbName) {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
switch (_d.label) {
|
137
|
-
case 0: return [4 /*yield*/, ((_b = (_a = this.pgConnection_) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.destroy())];
|
138
|
-
case 1:
|
139
|
-
_d.sent();
|
140
|
-
return [4 /*yield*/, ((_c = this.pgConnection_) === null || _c === void 0 ? void 0 : _c.destroy())];
|
141
|
-
case 2:
|
142
|
-
_d.sent();
|
143
|
-
return [4 /*yield*/, (0, pg_god_1.dropDatabase)({ databaseName: dbName, errorIfNonExist: false }, pgGodCredentials)];
|
144
|
-
case 3: return [2 /*return*/, _d.sent()];
|
145
|
-
}
|
146
|
-
});
|
147
|
-
});
|
39
|
+
shutdown: async function (dbName) {
|
40
|
+
await this.pgConnection_?.context?.destroy();
|
41
|
+
await this.pgConnection_?.destroy();
|
42
|
+
return await (0, pg_god_1.dropDatabase)({ databaseName: dbName, errorIfNonExist: false }, pgGodCredentials);
|
148
43
|
},
|
149
|
-
});
|
150
|
-
function medusaIntegrationTestRunner(
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
var dbConfig = {
|
157
|
-
dbName: dbName,
|
44
|
+
});
|
45
|
+
function medusaIntegrationTestRunner({ moduleName, dbName, schema = "public", env = {}, debug = false, testSuite, }) {
|
46
|
+
const tempName = parseInt(process.env.JEST_WORKER_ID || "1");
|
47
|
+
moduleName = moduleName ?? Math.random().toString(36).substring(7);
|
48
|
+
dbName ??= `medusa-${moduleName.toLowerCase()}-integration-${tempName}`;
|
49
|
+
let dbConfig = {
|
50
|
+
dbName,
|
158
51
|
clientUrl: (0, database_1.getDatabaseURL)(dbName),
|
159
|
-
schema
|
160
|
-
debug
|
52
|
+
schema,
|
53
|
+
debug,
|
161
54
|
};
|
162
|
-
|
163
|
-
require("@medusajs/medusa/dist/loaders/config").default =
|
164
|
-
|
55
|
+
const originalConfigLoader = require("@medusajs/medusa/dist/loaders/config").default;
|
56
|
+
require("@medusajs/medusa/dist/loaders/config").default = (rootDirectory) => {
|
57
|
+
const config = originalConfigLoader(rootDirectory);
|
165
58
|
config.projectConfig.databaseUrl = dbConfig.clientUrl;
|
166
59
|
config.projectConfig.databaseLogging = !!dbConfig.debug;
|
167
60
|
config.projectConfig.databaseDriverOptions = dbConfig.clientUrl.includes("localhost")
|
@@ -174,161 +67,108 @@ function medusaIntegrationTestRunner(_a) {
|
|
174
67
|
};
|
175
68
|
return config;
|
176
69
|
};
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
var apiUtils;
|
184
|
-
var options = {
|
70
|
+
const cwd = process.cwd();
|
71
|
+
let shutdown = async () => void 0;
|
72
|
+
const dbUtils = dbTestUtilFactory();
|
73
|
+
let container;
|
74
|
+
let apiUtils;
|
75
|
+
let options = {
|
185
76
|
api: new Proxy({}, {
|
186
|
-
get:
|
77
|
+
get: (target, prop) => {
|
187
78
|
return apiUtils[prop];
|
188
79
|
},
|
189
80
|
}),
|
190
81
|
dbConnection: new Proxy({}, {
|
191
|
-
get:
|
82
|
+
get: (target, prop) => {
|
192
83
|
return dbUtils.pgConnection_[prop];
|
193
84
|
},
|
194
85
|
}),
|
195
|
-
getContainer:
|
86
|
+
getContainer: () => container,
|
196
87
|
dbConfig: {
|
197
|
-
dbName
|
198
|
-
schema
|
88
|
+
dbName,
|
89
|
+
schema,
|
199
90
|
clientUrl: dbConfig.clientUrl,
|
200
91
|
},
|
92
|
+
dbUtils,
|
201
93
|
};
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
error_2 = _d.sent();
|
242
|
-
console.error("Error starting the app", error_2 === null || error_2 === void 0 ? void 0 : error_2.message);
|
243
|
-
throw error_2;
|
244
|
-
case 8:
|
245
|
-
cancelTokenSource = axios.CancelToken.source();
|
246
|
-
container = containerRes;
|
247
|
-
shutdown = function () { return __awaiter(_this, void 0, void 0, function () {
|
248
|
-
return __generator(this, function (_a) {
|
249
|
-
switch (_a.label) {
|
250
|
-
case 0: return [4 /*yield*/, serverShutdownRes()];
|
251
|
-
case 1:
|
252
|
-
_a.sent();
|
253
|
-
cancelTokenSource.cancel("Request canceled by shutdown");
|
254
|
-
return [2 /*return*/];
|
255
|
-
}
|
256
|
-
});
|
257
|
-
}); };
|
258
|
-
apiUtils = axios.create({
|
259
|
-
baseURL: "http://localhost:".concat(portRes),
|
260
|
-
cancelToken: cancelTokenSource.token,
|
261
|
-
});
|
262
|
-
return [2 /*return*/];
|
263
|
-
}
|
264
|
-
});
|
265
|
-
}); };
|
266
|
-
var beforeEach_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
267
|
-
var container, copiedContainer, medusaAppLoaderRunner, error_3;
|
268
|
-
return __generator(this, function (_a) {
|
269
|
-
switch (_a.label) {
|
270
|
-
case 0:
|
271
|
-
// The beforeAll already run everything, so lets not re run the loaders for the first iteration
|
272
|
-
if (isFirstTime) {
|
273
|
-
isFirstTime = false;
|
274
|
-
return [2 /*return*/];
|
275
|
-
}
|
276
|
-
container = options.getContainer();
|
277
|
-
copiedContainer = (0, utils_1.createMedusaContainer)({}, container);
|
278
|
-
_a.label = 1;
|
279
|
-
case 1:
|
280
|
-
_a.trys.push([1, 3, , 4]);
|
281
|
-
medusaAppLoaderRunner = require("@medusajs/medusa/dist/loaders/medusa-app").runModulesLoader;
|
282
|
-
return [4 /*yield*/, medusaAppLoaderRunner({
|
283
|
-
container: copiedContainer,
|
284
|
-
configModule: container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE),
|
285
|
-
})];
|
286
|
-
case 2:
|
287
|
-
_a.sent();
|
288
|
-
return [3 /*break*/, 4];
|
289
|
-
case 3:
|
290
|
-
error_3 = _a.sent();
|
291
|
-
console.error("Error runner modules loaders", error_3 === null || error_3 === void 0 ? void 0 : error_3.message);
|
292
|
-
throw error_3;
|
293
|
-
case 4: return [2 /*return*/];
|
294
|
-
}
|
295
|
-
});
|
296
|
-
}); };
|
297
|
-
var afterEach_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
298
|
-
var error_4;
|
299
|
-
return __generator(this, function (_a) {
|
300
|
-
switch (_a.label) {
|
301
|
-
case 0:
|
302
|
-
_a.trys.push([0, 2, , 3]);
|
303
|
-
return [4 /*yield*/, dbUtils.teardown({ schema: schema })];
|
304
|
-
case 1:
|
305
|
-
_a.sent();
|
306
|
-
return [3 /*break*/, 3];
|
307
|
-
case 2:
|
308
|
-
error_4 = _a.sent();
|
309
|
-
console.error("Error tearing down database:", error_4 === null || error_4 === void 0 ? void 0 : error_4.message);
|
310
|
-
throw error_4;
|
311
|
-
case 3: return [2 /*return*/];
|
312
|
-
}
|
94
|
+
let isFirstTime = true;
|
95
|
+
const beforeAll_ = async () => {
|
96
|
+
console.log(`Creating database ${dbName}`);
|
97
|
+
await dbUtils.create(dbName);
|
98
|
+
try {
|
99
|
+
dbUtils.pgConnection_ = await (0, use_db_1.initDb)({
|
100
|
+
cwd,
|
101
|
+
env,
|
102
|
+
});
|
103
|
+
}
|
104
|
+
catch (error) {
|
105
|
+
console.error("Error initializing database", error?.message);
|
106
|
+
throw error;
|
107
|
+
}
|
108
|
+
let containerRes;
|
109
|
+
let serverShutdownRes;
|
110
|
+
let portRes;
|
111
|
+
try {
|
112
|
+
const { shutdown = () => void 0, container, port, } = await (0, bootstrap_app_1.startApp)({
|
113
|
+
cwd,
|
114
|
+
env,
|
115
|
+
});
|
116
|
+
containerRes = container;
|
117
|
+
serverShutdownRes = shutdown;
|
118
|
+
portRes = port;
|
119
|
+
}
|
120
|
+
catch (error) {
|
121
|
+
console.error("Error starting the app", error?.message);
|
122
|
+
throw error;
|
123
|
+
}
|
124
|
+
const cancelTokenSource = axios.CancelToken.source();
|
125
|
+
container = containerRes;
|
126
|
+
shutdown = async () => {
|
127
|
+
await serverShutdownRes();
|
128
|
+
cancelTokenSource.cancel("Request canceled by shutdown");
|
129
|
+
};
|
130
|
+
apiUtils = axios.create({
|
131
|
+
baseURL: `http://localhost:${portRes}`,
|
132
|
+
cancelToken: cancelTokenSource.token,
|
313
133
|
});
|
314
|
-
}
|
315
|
-
|
134
|
+
};
|
135
|
+
const beforeEach_ = async () => {
|
136
|
+
// The beforeAll already run everything, so lets not re run the loaders for the first iteration
|
137
|
+
if (isFirstTime) {
|
138
|
+
isFirstTime = false;
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
const container = options.getContainer();
|
142
|
+
const copiedContainer = (0, utils_1.createMedusaContainer)({}, container);
|
143
|
+
try {
|
144
|
+
const medusaAppLoaderRunner = require("@medusajs/medusa/dist/loaders/medusa-app").runModulesLoader;
|
145
|
+
await medusaAppLoaderRunner({
|
146
|
+
container: copiedContainer,
|
147
|
+
configModule: container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE),
|
148
|
+
});
|
149
|
+
}
|
150
|
+
catch (error) {
|
151
|
+
console.error("Error runner modules loaders", error?.message);
|
152
|
+
throw error;
|
153
|
+
}
|
154
|
+
};
|
155
|
+
const afterEach_ = async () => {
|
156
|
+
try {
|
157
|
+
await dbUtils.teardown({ schema });
|
158
|
+
}
|
159
|
+
catch (error) {
|
160
|
+
console.error("Error tearing down database:", error?.message);
|
161
|
+
throw error;
|
162
|
+
}
|
163
|
+
};
|
164
|
+
return describe("", () => {
|
316
165
|
beforeAll(beforeAll_);
|
317
166
|
beforeEach(beforeEach_);
|
318
167
|
afterEach(afterEach_);
|
319
|
-
afterAll(
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
case 1:
|
324
|
-
_a.sent();
|
325
|
-
return [4 /*yield*/, shutdown()];
|
326
|
-
case 2:
|
327
|
-
_a.sent();
|
328
|
-
return [2 /*return*/];
|
329
|
-
}
|
330
|
-
});
|
331
|
-
}); });
|
168
|
+
afterAll(async () => {
|
169
|
+
await dbUtils.shutdown(dbName);
|
170
|
+
await shutdown();
|
171
|
+
});
|
332
172
|
testSuite(options);
|
333
173
|
});
|
334
174
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":";;;AACA,2CAGwB;AACxB,mCAAqD;AACrD,yCAA2C;AAC3C,4EAAmE;AACnE,8DAA0D;AAE1D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAA;AAEtC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAA;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAE3C,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,WAAW;IACr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C,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YAC7D,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YAC7D,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA;IAED,OAAO,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,UAAU,CAAC,WAAW,CAAC,CAAA;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC9B,MAAM,QAAQ,EAAE,CAAA;QAClB,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,OAAQ,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;AACJ,CAAC;AAjLD,kEAiLC"}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { EventBusTypes, IEventBusModuleService, Message, Subscriber } from "@medusajs/types";
|
2
2
|
export default class EventBusService implements IEventBusModuleService {
|
3
|
-
emit<T>(
|
4
|
-
emit<T>(data: EmitData<T>[]): Promise<void>;
|
5
|
-
emit<T>(data: Message<T>[]): Promise<void>;
|
3
|
+
emit<T>(data: Message<T> | Message<T>[], options: Record<string, unknown>): Promise<void>;
|
6
4
|
subscribe(event: string | symbol, subscriber: Subscriber): this;
|
7
5
|
unsubscribe(event: string | symbol, subscriber: Subscriber, context?: EventBusTypes.SubscriberContext): this;
|
6
|
+
releaseGroupedEvents(eventGroupId: string): Promise<void>;
|
7
|
+
clearGroupedEvents(eventGroupId: string): Promise<void>;
|
8
8
|
}
|
@@ -1,59 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
EventBusService.prototype.emit = function (eventOrData_1, data_1) {
|
43
|
-
return __awaiter(this, arguments, void 0, function (eventOrData, data, options) {
|
44
|
-
if (options === void 0) { options = {}; }
|
45
|
-
return __generator(this, function (_a) {
|
46
|
-
return [2 /*return*/];
|
47
|
-
});
|
48
|
-
});
|
49
|
-
};
|
50
|
-
EventBusService.prototype.subscribe = function (event, subscriber) {
|
3
|
+
class EventBusService {
|
4
|
+
async emit(data, options) { }
|
5
|
+
subscribe(event, subscriber) {
|
51
6
|
return this;
|
52
|
-
}
|
53
|
-
|
7
|
+
}
|
8
|
+
unsubscribe(event, subscriber, context) {
|
54
9
|
return this;
|
55
|
-
}
|
56
|
-
|
57
|
-
|
10
|
+
}
|
11
|
+
releaseGroupedEvents(eventGroupId) {
|
12
|
+
return Promise.resolve();
|
13
|
+
}
|
14
|
+
clearGroupedEvents(eventGroupId) {
|
15
|
+
return Promise.resolve();
|
16
|
+
}
|
17
|
+
}
|
58
18
|
exports.default = EventBusService;
|
59
19
|
//# sourceMappingURL=mock-event-bus-service.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mock-event-bus-service.js","sourceRoot":"","sources":["../src/mock-event-bus-service.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"mock-event-bus-service.js","sourceRoot":"","sources":["../src/mock-event-bus-service.ts"],"names":[],"mappings":";;AAOA,MAAqB,eAAe;IAClC,KAAK,CAAC,IAAI,CACR,IAA+B,EAC/B,OAAgC,IAChB,CAAC;IAEnB,SAAS,CAAC,KAAsB,EAAE,UAAsB;QACtD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CACT,KAAsB,EACtB,UAAsB,EACtB,OAAyC;QAEzC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,oBAAoB,CAAC,YAAoB;QACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,kBAAkB,CAAC,YAAoB;QACrC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;CACF;AAzBD,kCAyBC"}
|