medusa-test-utils 1.1.45-snapshot-20240719080828 → 1.1.45-snapshot-20240723115023
Sign up to get free protection for your applications and to get access to all the features.
package/dist/events.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAIxD,eAAO,MAAM,wBAAwB,cACxB,MAAM,YACP,sBAAsB,mBAmCjC,CAAA"}
|
package/dist/events.js
CHANGED
@@ -4,20 +4,32 @@ exports.waitSubscribersExecution = void 0;
|
|
4
4
|
// Allows you to wait for all subscribers to execute for a given event. Only works with the local event bus.
|
5
5
|
const waitSubscribersExecution = (eventName, eventBus) => {
|
6
6
|
const subscriberPromises = [];
|
7
|
-
eventBus.eventEmitter_
|
8
|
-
|
9
|
-
|
7
|
+
const eventEmitter = eventBus.eventEmitter_;
|
8
|
+
// If there are no existing listeners, resolve once the event happens. Otherwise, wrap the existing subscribers in a promise and resolve once they are done.
|
9
|
+
if (!eventEmitter.listeners(eventName).length) {
|
10
10
|
let ok, nok;
|
11
11
|
const promise = new Promise((resolve, reject) => {
|
12
12
|
ok = resolve;
|
13
13
|
nok = reject;
|
14
14
|
});
|
15
15
|
subscriberPromises.push(promise);
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
eventEmitter.on(eventName, ok);
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
eventEmitter.listeners(eventName).forEach((listener) => {
|
20
|
+
eventEmitter.removeListener(eventName, listener);
|
21
|
+
let ok, nok;
|
22
|
+
const promise = new Promise((resolve, reject) => {
|
23
|
+
ok = resolve;
|
24
|
+
nok = reject;
|
25
|
+
});
|
26
|
+
subscriberPromises.push(promise);
|
27
|
+
const newListener = async (...args2) => {
|
28
|
+
return await listener.apply(eventBus, args2).then(ok).catch(nok);
|
29
|
+
};
|
30
|
+
eventEmitter.on(eventName, newListener);
|
31
|
+
});
|
32
|
+
}
|
21
33
|
return Promise.all(subscriberPromises);
|
22
34
|
};
|
23
35
|
exports.waitSubscribersExecution = waitSubscribersExecution;
|
package/dist/events.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAGA,4GAA4G;AACrG,MAAM,wBAAwB,GAAG,CACtC,SAAiB,EACjB,QAAgC,EAChC,EAAE;IACF,MAAM,kBAAkB,GAAmB,EAAE,CAAA;IAC7C,MAAM,YAAY,GAAkB,QAAgB,CAAC,aAAa,CAAA;IAElE,4JAA4J;IAC5J,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;QAC9C,IAAI,EAAE,EAAE,GAAG,CAAA;QACX,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,EAAE,GAAG,OAAO,CAAA;YACZ,GAAG,GAAG,MAAM,CAAA;QACd,CAAC,CAAC,CAAA;QAEF,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAChC,CAAC;SAAM,CAAC;QACN,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAa,EAAE,EAAE;YAC1D,YAAY,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;YAEhD,IAAI,EAAE,EAAE,GAAG,CAAA;YACX,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC9C,EAAE,GAAG,OAAO,CAAA;gBACZ,GAAG,GAAG,MAAM,CAAA;YACd,CAAC,CAAC,CAAA;YACF,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAEhC,MAAM,WAAW,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE;gBACrC,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClE,CAAC,CAAA;YAED,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AACxC,CAAC,CAAA;AArCY,QAAA,wBAAwB,4BAqCpC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-db.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":"AAOA,wBAAsB,MAAM,CAAC,EAC3B,GAAG,EACH,GAAQ,GACT,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACvB,
|
1
|
+
{"version":3,"file":"use-db.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":"AAOA,wBAAsB,MAAM,CAAC,EAC3B,GAAG,EACH,GAAQ,GACT,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACvB,gBAsDA"}
|
@@ -21,8 +21,22 @@ async function initDb({ cwd, env = {}, }) {
|
|
21
21
|
[utils_1.ContainerRegistrationKeys.FEATURE_FLAG_ROUTER]: (0, awilix_1.asValue)(featureFlagRouter),
|
22
22
|
});
|
23
23
|
try {
|
24
|
-
const { runMedusaAppMigrations, } = require("@medusajs/medusa/dist/loaders/medusa-app");
|
24
|
+
const { runMedusaAppMigrations, getLinksExecutionPlanner, } = require("@medusajs/medusa/dist/loaders/medusa-app");
|
25
25
|
await runMedusaAppMigrations({ configModule, container });
|
26
|
+
const planner = await getLinksExecutionPlanner({
|
27
|
+
configModule,
|
28
|
+
container,
|
29
|
+
});
|
30
|
+
const actionPlan = await planner.createPlan();
|
31
|
+
await planner.executePlan(actionPlan);
|
32
|
+
/**
|
33
|
+
* cleanup temporary created resources for the migrations
|
34
|
+
* @internal I didnt find a god place to put that, should we eventually add a close function
|
35
|
+
* to the planner to handle that part? so that you would do planner.close() and it will handle the cleanup
|
36
|
+
* automatically just like we usually do for the classic migrations actions
|
37
|
+
*/
|
38
|
+
const { MedusaModule } = require("@medusajs/modules-sdk");
|
39
|
+
MedusaModule.clearInstances();
|
26
40
|
}
|
27
41
|
catch (err) {
|
28
42
|
console.error("Something went wrong while running the migrations");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-db.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":";;;AAAA,2CAIwB;AACxB,mCAAgC;AAEzB,KAAK,UAAU,MAAM,CAAC,EAC3B,GAAG,EACH,GAAG,GAAG,EAAE,GAIT;IACC,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC;IAED,MAAM,SAAS,GAAG,IAAA,6BAAqB,GAAE,CAAA;IAEzC,MAAM,YAAY,GAChB,MAAM,OAAO,CAAC,sCAAsC,CAAC,CAAC,OA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C"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "medusa-test-utils",
|
3
|
-
"version": "1.1.45-snapshot-
|
3
|
+
"version": "1.1.45-snapshot-20240723115023",
|
4
4
|
"description": "Test utils for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -24,15 +24,15 @@
|
|
24
24
|
"author": "Sebastian Rindom",
|
25
25
|
"license": "MIT",
|
26
26
|
"devDependencies": {
|
27
|
-
"@medusajs/types": "1.12.0-snapshot-
|
27
|
+
"@medusajs/types": "1.12.0-snapshot-20240723115023",
|
28
28
|
"cross-env": "^5.2.1",
|
29
29
|
"jest": "^29.7.0",
|
30
30
|
"rimraf": "^3.0.2",
|
31
31
|
"typescript": "^5.1.6"
|
32
32
|
},
|
33
33
|
"peerDependencies": {
|
34
|
-
"@medusajs/medusa": "1.20.6-snapshot-
|
35
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
34
|
+
"@medusajs/medusa": "1.20.6-snapshot-20240723115023",
|
35
|
+
"@medusajs/modules-sdk": "1.13.0-snapshot-20240723115023",
|
36
36
|
"axios": "^0.28.0",
|
37
37
|
"express": "^4.18.3",
|
38
38
|
"get-port": "^5.1.0",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
}
|
57
57
|
},
|
58
58
|
"dependencies": {
|
59
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
59
|
+
"@medusajs/utils": "1.12.0-snapshot-20240723115023",
|
60
60
|
"@mikro-orm/migrations": "5.9.7",
|
61
61
|
"@mikro-orm/postgresql": "5.9.7",
|
62
62
|
"randomatic": "^3.1.1"
|