@medusajs/framework 3.0.0-preview-20250211091350 → 3.0.0-preview-20250406180144
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/build-tools/compiler.d.ts +2 -1
- package/dist/build-tools/compiler.d.ts.map +1 -1
- package/dist/build-tools/compiler.js +13 -7
- package/dist/build-tools/compiler.js.map +1 -1
- package/dist/config/types.d.ts +25 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/database/pg-connection-loader.d.ts.map +1 -1
- package/dist/database/pg-connection-loader.js +7 -1
- package/dist/database/pg-connection-loader.js.map +1 -1
- package/dist/http/express-loader.d.ts.map +1 -1
- package/dist/http/express-loader.js +42 -9
- package/dist/http/express-loader.js.map +1 -1
- package/dist/http/middleware-file-loader.d.ts +28 -0
- package/dist/http/middleware-file-loader.d.ts.map +1 -0
- package/dist/http/middleware-file-loader.js +140 -0
- package/dist/http/middleware-file-loader.js.map +1 -0
- package/dist/http/middlewares/apply-default-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-default-filters.js +1 -1
- package/dist/http/middlewares/apply-default-filters.js.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.js +1 -1
- package/dist/http/middlewares/apply-params-as-filters.js.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.d.ts +2 -0
- package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.js +3 -2
- package/dist/http/middlewares/authenticate-middleware.js.map +1 -1
- package/dist/http/middlewares/bodyparser.d.ts +13 -0
- package/dist/http/middlewares/bodyparser.d.ts.map +1 -0
- package/dist/http/middlewares/bodyparser.js +62 -0
- package/dist/http/middlewares/bodyparser.js.map +1 -0
- package/dist/http/middlewares/clear-filters-by-key.d.ts +2 -2
- package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -1
- package/dist/http/middlewares/clear-filters-by-key.js +1 -1
- package/dist/http/middlewares/clear-filters-by-key.js.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts +2 -2
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.js +3 -7
- package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -1
- package/dist/http/middlewares/error-handler.d.ts +2 -4
- package/dist/http/middlewares/error-handler.d.ts.map +1 -1
- package/dist/http/middlewares/error-handler.js +1 -1
- package/dist/http/middlewares/error-handler.js.map +1 -1
- package/dist/http/router.d.ts +4 -76
- package/dist/http/router.d.ts.map +1 -1
- package/dist/http/router.js +175 -717
- package/dist/http/router.js.map +1 -1
- package/dist/http/routes-finder.d.ts +22 -0
- package/dist/http/routes-finder.d.ts.map +1 -0
- package/dist/http/routes-finder.js +62 -0
- package/dist/http/routes-finder.js.map +1 -0
- package/dist/http/routes-loader.d.ts +30 -0
- package/dist/http/routes-loader.d.ts.map +1 -0
- package/dist/http/routes-loader.js +203 -0
- package/dist/http/routes-loader.js.map +1 -0
- package/dist/http/routes-sorter.d.ts +105 -0
- package/dist/http/routes-sorter.d.ts.map +1 -0
- package/dist/http/routes-sorter.js +146 -0
- package/dist/http/routes-sorter.js.map +1 -0
- package/dist/http/types.d.ts +33 -17
- package/dist/http/types.d.ts.map +1 -1
- package/dist/http/utils/define-middlewares.d.ts +4 -0
- package/dist/http/utils/define-middlewares.d.ts.map +1 -1
- package/dist/http/utils/define-middlewares.js +5 -1
- package/dist/http/utils/define-middlewares.js.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.d.ts +2 -2
- package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.js.map +1 -1
- package/dist/http/utils/wrap-handler.d.ts +3 -0
- package/dist/http/utils/wrap-handler.d.ts.map +1 -0
- package/dist/http/utils/wrap-handler.js +27 -0
- package/dist/http/utils/wrap-handler.js.map +1 -0
- package/dist/jobs/job-loader.d.ts +9 -4
- package/dist/jobs/job-loader.d.ts.map +1 -1
- package/dist/jobs/job-loader.js +15 -67
- package/dist/jobs/job-loader.js.map +1 -1
- package/dist/medusa-app-loader.d.ts.map +1 -1
- package/dist/medusa-app-loader.js +4 -0
- package/dist/medusa-app-loader.js.map +1 -1
- package/dist/subscribers/subscriber-loader.d.ts +4 -3
- package/dist/subscribers/subscriber-loader.d.ts.map +1 -1
- package/dist/subscribers/subscriber-loader.js +18 -67
- package/dist/subscribers/subscriber-loader.js.map +1 -1
- package/dist/utils/resource-loader.d.ts +26 -0
- package/dist/utils/resource-loader.d.ts.map +1 -0
- package/dist/utils/resource-loader.js +78 -0
- package/dist/utils/resource-loader.js.map +1 -0
- package/dist/workflows/workflow-loader.d.ts +4 -2
- package/dist/workflows/workflow-loader.d.ts.map +1 -1
- package/dist/workflows/workflow-loader.js +8 -58
- package/dist/workflows/workflow-loader.js.map +1 -1
- package/package.json +12 -11
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subscriber-loader.js","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,
|
1
|
+
{"version":3,"file":"subscriber-loader.js","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAAoD;AACpD,+BAA4B;AAE5B,sCAAyC;AACzC,4CAAwC;AACxC,sCAAkC;AAElC,8DAAyD;AASzD,MAAa,gBAAiB,SAAQ,gCAAc;IAelD,YACE,SAA4B,EAC5B,UAAmC,EAAE;QAErC,KAAK,CAAC,SAAS,CAAC,CAAA;QAlBR,iBAAY,GAAG,YAAY,CAAA;QAErC;;;WAGG;QACH,kDAAuC;QAEvC;;;WAGG;QACH,kDAA6D,IAAI,GAAG,EAAE,EAAA;QAOpE,uBAAA,IAAI,mCAAkB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AK,CAAC,CAAA;QAErD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAEpE,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,UAAU,GAAG,KAAK,EAAE,IAAO,EAAE,EAAE;gBACnC,OAAO,MAAM,OAAO,CAAC;oBACnB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAyB;oBAClD,SAAS,EAAT,qBAAS;oBACT,aAAa,EAAE,uBAAA,IAAI,uCAAe;iBACnC,CAAC,CAAA;YACJ,CAAC,CAAA;YAED,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,UAAwB,EAAE;gBACrD,GAAG,MAAM,CAAC,OAAO;gBACjB,YAAY;aACb,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAE/B,KAAK,MAAM,CACT,QAAQ,EACR,EAAE,MAAM,EAAE,OAAO,EAAE,EACpB,IAAI,uBAAA,IAAI,+CAAuB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC;gBACpB,QAAQ;gBACR,MAAM;gBACN,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;QAED,eAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAEvC;;;WAGG;QACH,OAAO,CAAC,GAAG,uBAAA,IAAI,+CAAuB,CAAC,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;CACF;AA1LD,4CA0LC"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Dirent } from "fs";
|
2
|
+
export declare abstract class ResourceLoader {
|
3
|
+
#private;
|
4
|
+
/**
|
5
|
+
* The name of the resource (e.g job, subscriber, workflow)
|
6
|
+
*/
|
7
|
+
protected abstract resourceName: string;
|
8
|
+
constructor(sourceDir: string | string[]);
|
9
|
+
/**
|
10
|
+
* Discover resources from the source directory
|
11
|
+
* @param exclude - custom exclusion regexes
|
12
|
+
* @param customFiltering - custom filtering function
|
13
|
+
* @returns The resources discovered
|
14
|
+
*/
|
15
|
+
protected discoverResources({ exclude, customFiltering, }?: {
|
16
|
+
exclude?: RegExp[];
|
17
|
+
customFiltering?: (entry: Dirent) => boolean;
|
18
|
+
}): Promise<Record<string, unknown>[]>;
|
19
|
+
/**
|
20
|
+
* Called when a file is imported
|
21
|
+
* @param path - The path of the file
|
22
|
+
* @param fileExports - The exports of the file
|
23
|
+
*/
|
24
|
+
protected abstract onFileLoaded(path: string, fileExports: Record<string, unknown>): Promise<void> | never;
|
25
|
+
}
|
26
|
+
//# sourceMappingURL=resource-loader.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resource-loader.d.ts","sourceRoot":"","sources":["../../src/utils/resource-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAK3B,8BAAsB,cAAc;;IAClC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;gBAc3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;;;;OAKG;cACa,iBAAiB,CAAC,EAChC,OAAO,EACP,eAAe,GAChB,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;KACxC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAmD3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK;CACzB"}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7
|
+
};
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12
|
+
};
|
13
|
+
var _ResourceLoader_sourceDir, _ResourceLoader_excludes;
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.ResourceLoader = void 0;
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
17
|
+
const promises_1 = require("fs/promises");
|
18
|
+
const path_1 = require("path");
|
19
|
+
const logger_1 = require("../logger");
|
20
|
+
class ResourceLoader {
|
21
|
+
constructor(sourceDir) {
|
22
|
+
/**
|
23
|
+
* The directory from which to load the jobs
|
24
|
+
* @private
|
25
|
+
*/
|
26
|
+
_ResourceLoader_sourceDir.set(this, void 0);
|
27
|
+
/**
|
28
|
+
* The list of file names to exclude from the subscriber scan
|
29
|
+
* @private
|
30
|
+
*/
|
31
|
+
_ResourceLoader_excludes.set(this, [/^_[^/\\]*(\.[^/\\]+)?$/]);
|
32
|
+
__classPrivateFieldSet(this, _ResourceLoader_sourceDir, sourceDir, "f");
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Discover resources from the source directory
|
36
|
+
* @param exclude - custom exclusion regexes
|
37
|
+
* @param customFiltering - custom filtering function
|
38
|
+
* @returns The resources discovered
|
39
|
+
*/
|
40
|
+
async discoverResources({ exclude, customFiltering, } = {}) {
|
41
|
+
exclude ??= [];
|
42
|
+
customFiltering ??= (entry) => {
|
43
|
+
const parsedName = (0, path_1.parse)(entry.name);
|
44
|
+
return (!entry.isDirectory() &&
|
45
|
+
parsedName.name !== "index" &&
|
46
|
+
!parsedName.base.endsWith(".d.ts") &&
|
47
|
+
[".js", ".ts"].includes(parsedName.ext) &&
|
48
|
+
!__classPrivateFieldGet(this, _ResourceLoader_excludes, "f").some((exclude) => exclude.test(parsedName.base)) &&
|
49
|
+
!exclude.some((exclude) => exclude.test(parsedName.base)));
|
50
|
+
};
|
51
|
+
const normalizedSourcePath = Array.isArray(__classPrivateFieldGet(this, _ResourceLoader_sourceDir, "f"))
|
52
|
+
? __classPrivateFieldGet(this, _ResourceLoader_sourceDir, "f")
|
53
|
+
: [__classPrivateFieldGet(this, _ResourceLoader_sourceDir, "f")];
|
54
|
+
const promises = normalizedSourcePath.map(async (sourcePath) => {
|
55
|
+
try {
|
56
|
+
await (0, promises_1.access)(sourcePath);
|
57
|
+
}
|
58
|
+
catch {
|
59
|
+
logger_1.logger.info(`No ${this.resourceName} to load from ${sourcePath}. skipped.`);
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
return await (0, utils_1.readDirRecursive)(sourcePath).then(async (entries) => {
|
63
|
+
const fileEntries = entries.filter((entry) => customFiltering(entry));
|
64
|
+
return await (0, utils_1.promiseAll)(fileEntries.map(async (entry) => {
|
65
|
+
const fullPath = (0, path_1.join)(entry.path, entry.name);
|
66
|
+
const module_ = await (0, utils_1.dynamicImport)(fullPath);
|
67
|
+
await this.onFileLoaded(fullPath, module_);
|
68
|
+
return module_;
|
69
|
+
}));
|
70
|
+
});
|
71
|
+
});
|
72
|
+
const resources = await (0, utils_1.promiseAll)(promises);
|
73
|
+
return resources.flat();
|
74
|
+
}
|
75
|
+
}
|
76
|
+
exports.ResourceLoader = ResourceLoader;
|
77
|
+
_ResourceLoader_sourceDir = new WeakMap(), _ResourceLoader_excludes = new WeakMap();
|
78
|
+
//# sourceMappingURL=resource-loader.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resource-loader.js","sourceRoot":"","sources":["../../src/utils/resource-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6E;AAE7E,0CAAoC;AACpC,+BAAkC;AAClC,sCAAkC;AAElC,MAAsB,cAAc;IAkBlC,YAAY,SAA4B;QAZxC;;;WAGG;QACH,4CAA6B;QAE7B;;;WAGG;QACH,mCAAsB,CAAC,wBAAwB,CAAC,EAAA;QAG9C,uBAAA,IAAI,6BAAc,SAAS,MAAA,CAAA;IAC7B,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,iBAAiB,CAAC,EAChC,OAAO,EACP,eAAe,MAIb,EAAE;QACJ,OAAO,KAAK,EAAE,CAAA;QACd,eAAe,KAAK,CAAC,KAAa,EAAE,EAAE;YACpC,MAAM,UAAU,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAEpC,OAAO,CACL,CAAC,KAAK,CAAC,WAAW,EAAE;gBACpB,UAAU,CAAC,IAAI,KAAK,OAAO;gBAC3B,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAClC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;gBACvC,CAAC,uBAAA,IAAI,gCAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAChE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAC1D,CAAA;QACH,CAAC,CAAA;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C;CAWF;AA9FD,wCA8FC"}
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { ResourceLoader } from "../utils/resource-loader";
|
2
|
+
export declare class WorkflowLoader extends ResourceLoader {
|
3
|
+
protected resourceName: string;
|
3
4
|
constructor(sourceDir: string | string[]);
|
5
|
+
protected onFileLoaded(path: string, fileExports: Record<string, unknown>): Promise<void>;
|
4
6
|
/**
|
5
7
|
* Load workflows from the source paths, workflows are registering themselves,
|
6
8
|
* therefore we only need to import them
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow-loader.d.ts","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"workflow-loader.d.ts","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,qBAAa,cAAe,SAAQ,cAAc;IAChD,SAAS,CAAC,YAAY,SAAa;gBAEvB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;cAIxB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKtC;;;OAGG;IACG,IAAI;CAKX"}
|
@@ -1,74 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7
|
-
};
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12
|
-
};
|
13
|
-
var _WorkflowLoader_sourceDir, _WorkflowLoader_excludes;
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
3
|
exports.WorkflowLoader = void 0;
|
16
|
-
const utils_1 = require("@medusajs/utils");
|
17
|
-
const promises_1 = require("fs/promises");
|
18
|
-
const path_1 = require("path");
|
19
4
|
const logger_1 = require("../logger");
|
20
|
-
|
5
|
+
const resource_loader_1 = require("../utils/resource-loader");
|
6
|
+
class WorkflowLoader extends resource_loader_1.ResourceLoader {
|
21
7
|
constructor(sourceDir) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
/**
|
28
|
-
* The list of file names to exclude from the subscriber scan
|
29
|
-
* @private
|
30
|
-
*/
|
31
|
-
_WorkflowLoader_excludes.set(this, [
|
32
|
-
/index\.js/,
|
33
|
-
/index\.ts/,
|
34
|
-
/\.DS_Store/,
|
35
|
-
/(\.ts\.map|\.js\.map|\.d\.ts|\.md)/,
|
36
|
-
/^_[^/\\]*(\.[^/\\]+)?$/,
|
37
|
-
]);
|
38
|
-
__classPrivateFieldSet(this, _WorkflowLoader_sourceDir, sourceDir, "f");
|
8
|
+
super(sourceDir);
|
9
|
+
this.resourceName = "workflow";
|
10
|
+
}
|
11
|
+
async onFileLoaded(path, fileExports) {
|
12
|
+
logger_1.logger.debug(`Registering workflows from ${path}.`);
|
39
13
|
}
|
40
14
|
/**
|
41
15
|
* Load workflows from the source paths, workflows are registering themselves,
|
42
16
|
* therefore we only need to import them
|
43
17
|
*/
|
44
18
|
async load() {
|
45
|
-
|
46
|
-
? __classPrivateFieldGet(this, _WorkflowLoader_sourceDir, "f")
|
47
|
-
: [__classPrivateFieldGet(this, _WorkflowLoader_sourceDir, "f")];
|
48
|
-
const promises = normalizedSourcePath.map(async (sourcePath) => {
|
49
|
-
try {
|
50
|
-
await (0, promises_1.access)(sourcePath);
|
51
|
-
}
|
52
|
-
catch {
|
53
|
-
logger_1.logger.info(`No workflow to load from ${sourcePath}. skipped.`);
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
return await (0, utils_1.readDirRecursive)(sourcePath).then(async (entries) => {
|
57
|
-
const fileEntries = entries.filter((entry) => {
|
58
|
-
return (!entry.isDirectory() &&
|
59
|
-
!__classPrivateFieldGet(this, _WorkflowLoader_excludes, "f").some((exclude) => exclude.test(entry.name)));
|
60
|
-
});
|
61
|
-
logger_1.logger.debug(`Registering workflows from ${sourcePath}.`);
|
62
|
-
return await (0, utils_1.promiseAll)(fileEntries.map(async (entry) => {
|
63
|
-
const fullPath = (0, path_1.join)(entry.path, entry.name);
|
64
|
-
return await (0, utils_1.dynamicImport)(fullPath);
|
65
|
-
}));
|
66
|
-
});
|
67
|
-
});
|
68
|
-
await (0, utils_1.promiseAll)(promises);
|
19
|
+
await super.discoverResources();
|
69
20
|
logger_1.logger.debug(`Workflows registered.`);
|
70
21
|
}
|
71
22
|
}
|
72
23
|
exports.WorkflowLoader = WorkflowLoader;
|
73
|
-
_WorkflowLoader_sourceDir = new WeakMap(), _WorkflowLoader_excludes = new WeakMap();
|
74
24
|
//# sourceMappingURL=workflow-loader.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow-loader.js","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"workflow-loader.js","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":";;;AAAA,sCAAkC;AAClC,8DAAyD;AAEzD,MAAa,cAAe,SAAQ,gCAAc;IAGhD,YAAY,SAA4B;QACtC,KAAK,CAAC,SAAS,CAAC,CAAA;QAHR,iBAAY,GAAG,UAAU,CAAA;IAInC,CAAC;IAES,KAAK,CAAC,YAAY,CAC1B,IAAY,EACZ,WAAoC;QAEpC,eAAM,CAAC,KAAK,CAAC,8BAA8B,IAAI,GAAG,CAAC,CAAA;IACrD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAE/B,eAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACvC,CAAC;CACF;AAvBD,wCAuBC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/framework",
|
3
|
-
"version": "3.0.0-preview-
|
3
|
+
"version": "3.0.0-preview-20250406180144",
|
4
4
|
"description": "Framework",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
|
-
"@medusajs/cli": "3.0.0-preview-
|
57
|
+
"@medusajs/cli": "3.0.0-preview-20250406180144",
|
58
58
|
"@mikro-orm/core": "6.4.3",
|
59
59
|
"@mikro-orm/knex": "6.4.3",
|
60
60
|
"@mikro-orm/migrations": "6.4.3",
|
@@ -70,16 +70,16 @@
|
|
70
70
|
"rimraf": "^3.0.2",
|
71
71
|
"supertest": "^4.0.2",
|
72
72
|
"typescript": "^5.6.2",
|
73
|
-
"vite": "^5.
|
73
|
+
"vite": "^5.4.14"
|
74
74
|
},
|
75
75
|
"dependencies": {
|
76
76
|
"@jercle/yargonaut": "^1.1.5",
|
77
|
-
"@medusajs/modules-sdk": "3.0.0-preview-
|
78
|
-
"@medusajs/orchestration": "3.0.0-preview-
|
79
|
-
"@medusajs/telemetry": "3.0.0-preview-
|
80
|
-
"@medusajs/types": "3.0.0-preview-
|
81
|
-
"@medusajs/utils": "3.0.0-preview-
|
82
|
-
"@medusajs/workflows-sdk": "3.0.0-preview-
|
77
|
+
"@medusajs/modules-sdk": "3.0.0-preview-20250406180144",
|
78
|
+
"@medusajs/orchestration": "3.0.0-preview-20250406180144",
|
79
|
+
"@medusajs/telemetry": "3.0.0-preview-20250406180144",
|
80
|
+
"@medusajs/types": "3.0.0-preview-20250406180144",
|
81
|
+
"@medusajs/utils": "3.0.0-preview-20250406180144",
|
82
|
+
"@medusajs/workflows-sdk": "3.0.0-preview-20250406180144",
|
83
83
|
"@opentelemetry/api": "^1.9.0",
|
84
84
|
"@types/express": "^4.17.17",
|
85
85
|
"chokidar": "^3.4.2",
|
@@ -93,11 +93,12 @@
|
|
93
93
|
"jsonwebtoken": "^9.0.2",
|
94
94
|
"lodash": "4.17.21",
|
95
95
|
"morgan": "^1.9.1",
|
96
|
+
"path-to-regexp": "^0.1.10",
|
96
97
|
"tsconfig-paths": "^4.2.0",
|
97
98
|
"zod": "3.22.4"
|
98
99
|
},
|
99
100
|
"peerDependencies": {
|
100
|
-
"@medusajs/cli": "3.0.0-preview-
|
101
|
+
"@medusajs/cli": "3.0.0-preview-20250406180144",
|
101
102
|
"@mikro-orm/cli": "6.4.3",
|
102
103
|
"@mikro-orm/core": "6.4.3",
|
103
104
|
"@mikro-orm/knex": "6.4.3",
|
@@ -106,7 +107,7 @@
|
|
106
107
|
"awilix": "^8.0.1",
|
107
108
|
"ioredis": "^5.4.1",
|
108
109
|
"pg": "^8.13.0",
|
109
|
-
"vite": "^5.
|
110
|
+
"vite": "^5.4.14"
|
110
111
|
},
|
111
112
|
"peerDependenciesMeta": {
|
112
113
|
"@mikro-orm/cli": {
|