@etohq/framework 1.3.0 → 1.5.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/LICENSE +21 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +11 -4
- package/dist/config/config.js.map +1 -1
- package/dist/config/loader.d.ts +2 -5
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +14 -13
- package/dist/config/loader.js.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +6 -3
- package/dist/context/index.js.map +1 -1
- package/dist/database/pg-connection-loader.d.ts +1 -1
- package/dist/database/pg-connection-loader.d.ts.map +1 -1
- package/dist/database/pg-connection-loader.js +25 -3
- package/dist/database/pg-connection-loader.js.map +1 -1
- package/dist/eto-app-loader.d.ts +6 -7
- package/dist/eto-app-loader.d.ts.map +1 -1
- package/dist/eto-app-loader.js +54 -4
- package/dist/eto-app-loader.js.map +1 -1
- package/dist/eto.d.ts +7 -7
- package/dist/eto.d.ts.map +1 -1
- package/dist/eto.js +4 -13
- package/dist/eto.js.map +1 -1
- package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-default-filters.js.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.js.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.d.ts +3 -1
- package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.js +19 -10
- package/dist/http/middlewares/authenticate-middleware.js.map +1 -1
- package/dist/http/middlewares/bodyparser.d.ts +2 -0
- package/dist/http/middlewares/bodyparser.d.ts.map +1 -0
- package/dist/http/middlewares/bodyparser.js +99 -0
- package/dist/http/middlewares/bodyparser.js.map +1 -0
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.js +2 -2
- package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -1
- package/dist/http/middlewares/error-handler.d.ts.map +1 -1
- package/dist/http/middlewares/error-handler.js +7 -6
- package/dist/http/middlewares/error-handler.js.map +1 -1
- package/dist/http/types.d.ts +49 -19
- package/dist/http/types.d.ts.map +1 -1
- package/dist/http/utils/get-query-config.d.ts +5 -6
- package/dist/http/utils/get-query-config.d.ts.map +1 -1
- package/dist/http/utils/get-query-config.js +7 -5
- package/dist/http/utils/get-query-config.js.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.js +12 -14
- package/dist/http/utils/maybe-apply-link-filter.js.map +1 -1
- package/dist/http/utils/refetch-entities.d.ts +1 -1
- package/dist/http/utils/refetch-entities.d.ts.map +1 -1
- package/dist/http/utils/refetch-entities.js +2 -2
- package/dist/http/utils/refetch-entities.js.map +1 -1
- package/dist/http/utils/validate-query.d.ts.map +1 -1
- package/dist/http/utils/validate-query.js +2 -1
- package/dist/http/utils/validate-query.js.map +1 -1
- package/dist/http/utils/wrap-handler.d.ts +2 -0
- package/dist/http/utils/wrap-handler.d.ts.map +1 -0
- package/dist/http/utils/wrap-handler.js +40 -0
- package/dist/http/utils/wrap-handler.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs/job-loader.d.ts +13 -16
- package/dist/jobs/job-loader.d.ts.map +1 -1
- package/dist/jobs/job-loader.js +18 -88
- package/dist/jobs/job-loader.js.map +1 -1
- package/dist/links/link-loader.js +1 -1
- package/dist/links/link-loader.js.map +1 -1
- package/dist/loader.d.ts +8 -12
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +40 -35
- package/dist/loader.js.map +1 -1
- package/dist/logger/index.d.ts +28 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +249 -3
- package/dist/logger/index.js.map +1 -1
- package/dist/migrations/index.d.ts +3 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +19 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrator.d.ts +38 -0
- package/dist/migrations/migrator.d.ts.map +1 -0
- package/dist/migrations/migrator.js +130 -0
- package/dist/migrations/migrator.js.map +1 -0
- package/dist/migrations/run-migration-scripts.d.ts +17 -0
- package/dist/migrations/run-migration-scripts.d.ts.map +1 -0
- package/dist/migrations/run-migration-scripts.js +95 -0
- package/dist/migrations/run-migration-scripts.js.map +1 -0
- package/dist/mikro-orm-cli/bin.js +3 -3
- package/dist/mikro-orm-cli/bin.js.map +1 -1
- package/dist/subscribers/subscriber-loader.d.ts +5 -18
- package/dist/subscribers/subscriber-loader.d.ts.map +1 -1
- package/dist/subscribers/subscriber-loader.js +19 -95
- package/dist/subscribers/subscriber-loader.js.map +1 -1
- package/dist/types/container.d.ts +3 -2
- package/dist/types/container.d.ts.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 +64 -57
- package/dist/telemetry/index.d.ts +0 -50
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -81
- package/dist/telemetry/index.js.map +0 -1
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
* small, we should be okay with managing this wrapper.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
const core_1 = require("@mikro-orm/core");
|
|
17
15
|
const cli_1 = require("@mikro-orm/cli");
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const path_1 = require("path");
|
|
18
18
|
/**
|
|
19
19
|
* Monkey patching the TSNode registration of Mikro ORM to not use
|
|
20
20
|
* hardcoded module system with TypeScript.
|
|
21
21
|
*/
|
|
22
|
-
core_1.ConfigurationLoader.registerTsNode =
|
|
22
|
+
core_1.ConfigurationLoader.registerTsNode = function (configPath = "tsconfig.json") {
|
|
23
23
|
const tsConfigPath = (0, path_1.isAbsolute)(configPath)
|
|
24
24
|
? configPath
|
|
25
25
|
: (0, path_1.join)(process.cwd(), configPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/mikro-orm-cli/bin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/mikro-orm-cli/bin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,wCAA2D;AAC3D,0CAAqD;AACrD,+BAAuC;AAEvC;;;GAGG;AACH,0BAAmB,CAAC,cAAc,GAAG,UAAU,UAAU,GAAG,eAAe;IACzE,MAAM,YAAY,GAAG,IAAA,iBAAU,EAAC,UAAU,CAAC;QACzC,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;IAEnC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,OAAO,EAAE,YAAY;QACrB,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC,MAAM,CAAA;IAET,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC;YACjC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG;YAC/B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,OAAO,CAAC,mBAAmB,CAAC;KACzB,KAAK,CAAC,MAAM,CAAC;KACb,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC;KAC3B,SAAS,CAAC,OAAO,CAAC;KAClB,WAAW,CAAC,KAAK,CAAC,CACpB;AAAA,CAAC,KAAK,IAAI,EAAE;IACX,MAAM,IAAI,GAAG,MAAM,qBAAe,CAAC,SAAS,EAAE,CAAA;IAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,eAAS,CAAC,QAAQ,EAAE,CAAA;IACtB,CAAC;AACH,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type LoaderInput = {
|
|
4
|
-
sourceDir?: string | string[];
|
|
5
|
-
subscribers?: Array<{
|
|
6
|
-
path: string;
|
|
7
|
-
module: {
|
|
8
|
-
config: SubscriberConfig;
|
|
9
|
-
default: SubscriberHandler<any>;
|
|
10
|
-
};
|
|
11
|
-
}>;
|
|
12
|
-
options?: Record<string, unknown>;
|
|
13
|
-
};
|
|
14
|
-
export declare class SubscriberLoader {
|
|
1
|
+
import { ResourceLoader } from "../utils/resource-loader";
|
|
2
|
+
export declare class SubscriberLoader extends ResourceLoader {
|
|
15
3
|
#private;
|
|
16
|
-
|
|
4
|
+
protected resourceName: string;
|
|
5
|
+
constructor(sourceDir: string | string[], options?: Record<string, unknown>);
|
|
6
|
+
protected onFileLoaded(path: string, fileExports: Record<string, unknown>): Promise<void>;
|
|
17
7
|
private validateSubscriber;
|
|
18
|
-
private createDescriptor;
|
|
19
|
-
private createMap;
|
|
20
8
|
private inferIdentifier;
|
|
21
9
|
private createSubscriber;
|
|
22
10
|
load(): Promise<string[]>;
|
|
23
11
|
}
|
|
24
|
-
export {};
|
|
25
12
|
//# sourceMappingURL=subscriber-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriber-loader.d.ts","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscriber-loader.d.ts","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AASzD,qBAAa,gBAAiB,SAAQ,cAAc;;IAClD,SAAS,CAAC,YAAY,SAAe;gBAenC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;cAMvB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBtC,OAAO,CAAC,kBAAkB;IA4D1B,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,gBAAgB;IAmClB,IAAI;CAsBX"}
|
|
@@ -10,56 +10,42 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
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
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _SubscriberLoader_pluginOptions,
|
|
13
|
+
var _SubscriberLoader_pluginOptions, _SubscriberLoader_subscriberDescriptors;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SubscriberLoader = void 0;
|
|
16
16
|
const utils_1 = require("@etohq/utils");
|
|
17
|
-
const promises_1 = require("fs/promises");
|
|
18
17
|
const path_1 = require("path");
|
|
19
18
|
const config_1 = require("../config");
|
|
20
19
|
const container_1 = require("../container");
|
|
21
20
|
const logger_1 = require("../logger");
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const resource_loader_1 = require("../utils/resource-loader");
|
|
22
|
+
class SubscriberLoader extends resource_loader_1.ResourceLoader {
|
|
23
|
+
constructor(sourceDir, options = {}) {
|
|
24
|
+
super(sourceDir);
|
|
25
|
+
this.resourceName = "subscriber";
|
|
24
26
|
/**
|
|
25
27
|
* The options of the plugin from which the subscribers are being loaded
|
|
26
28
|
* @private
|
|
27
29
|
*/
|
|
28
30
|
_SubscriberLoader_pluginOptions.set(this, void 0);
|
|
29
|
-
/**
|
|
30
|
-
* The base directory from which to scan for the subscribers
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
_SubscriberLoader_sourceDir.set(this, void 0);
|
|
34
|
-
_SubscriberLoader_preLoadedSubscribers.set(this, void 0);
|
|
35
|
-
/**
|
|
36
|
-
* The list of file names to exclude from the subscriber scan
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
_SubscriberLoader_excludes.set(this, [
|
|
40
|
-
/index\.js/,
|
|
41
|
-
/index\.ts/,
|
|
42
|
-
/\.DS_Store/,
|
|
43
|
-
/(\.ts\.map|\.js\.map|\.d\.ts|\.md)/,
|
|
44
|
-
/^_[^/\\]*(\.[^/\\]+)?$/,
|
|
45
|
-
]
|
|
46
|
-
/**
|
|
47
|
-
* Map of subscribers descriptors to consume in the loader
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
);
|
|
51
31
|
/**
|
|
52
32
|
* Map of subscribers descriptors to consume in the loader
|
|
53
33
|
* @private
|
|
54
34
|
*/
|
|
55
35
|
_SubscriberLoader_subscriberDescriptors.set(this, new Map());
|
|
56
|
-
if (!sourceDir && !subscribers) {
|
|
57
|
-
throw new Error("Either sourceDir or subscribers must be provided");
|
|
58
|
-
}
|
|
59
|
-
__classPrivateFieldSet(this, _SubscriberLoader_sourceDir, sourceDir, "f");
|
|
60
|
-
__classPrivateFieldSet(this, _SubscriberLoader_preLoadedSubscribers, subscribers, "f");
|
|
61
36
|
__classPrivateFieldSet(this, _SubscriberLoader_pluginOptions, options, "f");
|
|
62
37
|
}
|
|
38
|
+
async onFileLoaded(path, fileExports) {
|
|
39
|
+
const isValid = this.validateSubscriber(fileExports, path);
|
|
40
|
+
logger_1.logger.debug(`Registering subscribers from ${path}.`);
|
|
41
|
+
if (!isValid) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
__classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").set(path, {
|
|
45
|
+
config: fileExports.config,
|
|
46
|
+
handler: fileExports.default,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
63
49
|
validateSubscriber(subscriber, path) {
|
|
64
50
|
const handler = subscriber.default;
|
|
65
51
|
if (!handler || typeof handler !== "function") {
|
|
@@ -100,45 +86,6 @@ class SubscriberLoader {
|
|
|
100
86
|
}
|
|
101
87
|
return true;
|
|
102
88
|
}
|
|
103
|
-
async createDescriptor(absolutePath, module_) {
|
|
104
|
-
if (module_) {
|
|
105
|
-
module_ = (0, utils_1.resolveExports)(module_);
|
|
106
|
-
const isValid = this.validateSubscriber(module_, absolutePath);
|
|
107
|
-
if (!isValid) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
__classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").set(absolutePath, {
|
|
111
|
-
config: module_.config,
|
|
112
|
-
handler: module_.default,
|
|
113
|
-
});
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
return await (0, utils_1.dynamicImport)(absolutePath).then((module_) => {
|
|
117
|
-
module_ = (0, utils_1.resolveExports)(module_);
|
|
118
|
-
const isValid = this.validateSubscriber(module_, absolutePath);
|
|
119
|
-
if (!isValid) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
__classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").set(absolutePath, {
|
|
123
|
-
config: module_.config,
|
|
124
|
-
handler: module_.default,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
async createMap(dirPath) {
|
|
129
|
-
const promises = await (0, utils_1.readDirRecursive)(dirPath).then(async (entries) => {
|
|
130
|
-
const fileEntries = entries.filter((entry) => {
|
|
131
|
-
return (!entry.isDirectory() &&
|
|
132
|
-
!__classPrivateFieldGet(this, _SubscriberLoader_excludes, "f").some((exclude) => exclude.test(entry.name)));
|
|
133
|
-
});
|
|
134
|
-
logger_1.logger.debug(`Registering subscribers from ${dirPath}.`);
|
|
135
|
-
return fileEntries.flatMap(async (entry) => {
|
|
136
|
-
const fullPath = (0, path_1.join)(entry.path, entry.name);
|
|
137
|
-
return await this.createDescriptor(fullPath);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
await (0, utils_1.promiseAll)(promises);
|
|
141
|
-
}
|
|
142
89
|
inferIdentifier(fileName, { context }, handler) {
|
|
143
90
|
/**
|
|
144
91
|
* If subscriberId is provided, use that
|
|
@@ -179,30 +126,7 @@ class SubscriberLoader {
|
|
|
179
126
|
}
|
|
180
127
|
}
|
|
181
128
|
async load() {
|
|
182
|
-
|
|
183
|
-
if (__classPrivateFieldGet(this, _SubscriberLoader_preLoadedSubscribers, "f")) {
|
|
184
|
-
for (const { path, module } of __classPrivateFieldGet(this, _SubscriberLoader_preLoadedSubscribers, "f")) {
|
|
185
|
-
await this.createDescriptor(path, module);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// Handle source directory scanning
|
|
189
|
-
if (__classPrivateFieldGet(this, _SubscriberLoader_sourceDir, "f")) {
|
|
190
|
-
const normalizeSourcePaths = Array.isArray(__classPrivateFieldGet(this, _SubscriberLoader_sourceDir, "f"))
|
|
191
|
-
? __classPrivateFieldGet(this, _SubscriberLoader_sourceDir, "f")
|
|
192
|
-
: [__classPrivateFieldGet(this, _SubscriberLoader_sourceDir, "f")];
|
|
193
|
-
const promises = normalizeSourcePaths.map(async (sourcePath) => {
|
|
194
|
-
try {
|
|
195
|
-
await (0, promises_1.access)(sourcePath);
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
logger_1.logger.info(`No subscribers to load from ${sourcePath}. skipped.`);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
return await this.createMap(sourcePath);
|
|
202
|
-
});
|
|
203
|
-
await (0, utils_1.promiseAll)(promises);
|
|
204
|
-
}
|
|
205
|
-
// Register all subscribers
|
|
129
|
+
await super.discoverResources();
|
|
206
130
|
for (const [fileName, { config, handler },] of __classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").entries()) {
|
|
207
131
|
this.createSubscriber({
|
|
208
132
|
fileName,
|
|
@@ -219,5 +143,5 @@ class SubscriberLoader {
|
|
|
219
143
|
}
|
|
220
144
|
}
|
|
221
145
|
exports.SubscriberLoader = SubscriberLoader;
|
|
222
|
-
_SubscriberLoader_pluginOptions = new WeakMap(),
|
|
146
|
+
_SubscriberLoader_pluginOptions = new WeakMap(), _SubscriberLoader_subscriberDescriptors = new WeakMap();
|
|
223
147
|
//# sourceMappingURL=subscriber-loader.js.map
|
|
@@ -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,wCAAiD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WAGG;QACH,OAAO,CAAC,GAAG,uBAAA,IAAI,+CAAuB,CAAC,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;CACF;AA1LD,4CA0LC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Link } from "@etohq/modules-sdk";
|
|
2
|
-
import { ConfigModule, IApiKeyModuleService, IAuthModuleService, ICacheService, IEventBusModuleService, IFileModuleService, ILockingModule, INotificationModuleService, IPaymentModuleService, IUserModuleService, IWorkflowEngineService, Logger, ModuleImplementations, RemoteQueryFunction } from "@etohq/types";
|
|
2
|
+
import { ConfigModule, IAnalyticsModuleService, IApiKeyModuleService, IAuthModuleService, ICacheService, IEventBusModuleService, IFileModuleService, ILockingModule, INotificationModuleService, IPaymentModuleService, IUserModuleService, IWorkflowEngineService, Logger, ModuleImplementations, RemoteQueryFunction } from "@etohq/types";
|
|
3
3
|
import { ContainerRegistrationKeys, Modules } from "@etohq/utils";
|
|
4
4
|
import { Knex } from "@mikro-orm/knex";
|
|
5
5
|
import { AwilixContainer, ResolveOptions } from "awilix";
|
|
@@ -11,12 +11,13 @@ declare module "@etohq/types" {
|
|
|
11
11
|
[ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction;
|
|
12
12
|
[ContainerRegistrationKeys.QUERY]: Omit<RemoteQueryFunction, symbol>;
|
|
13
13
|
[ContainerRegistrationKeys.LOGGER]: Logger;
|
|
14
|
-
[Modules.
|
|
14
|
+
[Modules.ANALYTICS]: IAnalyticsModuleService;
|
|
15
15
|
[Modules.AUTH]: IAuthModuleService;
|
|
16
16
|
[Modules.CACHE]: ICacheService;
|
|
17
17
|
[Modules.EVENT_BUS]: IEventBusModuleService;
|
|
18
18
|
[Modules.USER]: IUserModuleService;
|
|
19
19
|
[Modules.WORKFLOW_ENGINE]: IWorkflowEngineService;
|
|
20
|
+
[Modules.PAYMENT]: IPaymentModuleService;
|
|
20
21
|
[Modules.API_KEY]: IApiKeyModuleService;
|
|
21
22
|
[Modules.FILE]: IFileModuleService;
|
|
22
23
|
[Modules.NOTIFICATION]: INotificationModuleService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAiB,qBAAqB;QACpC,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;QACtC,CAAC,yBAAyB,CAAC,aAAa,CAAC,EAAE,YAAY,CAAA;QACvD,CAAC,yBAAyB,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;QACpD,CAAC,yBAAyB,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAA;QAC7D,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;QACpE,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;QAC1C,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EACL,YAAY,EACZ,u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xC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;QACvC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;QAClC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAA;QAClD,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;KAClC;CACF;AAED,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,qBAAqB,IACpE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG;IACjC,OAAO,CAAC,CAAC,SAAS,MAAM,MAAM,EAC5B,GAAG,EAAE,CAAC,EACN,cAAc,CAAC,EAAE,cAAc,GAC9B,MAAM,CAAC,CAAC,CAAC,CAAA;IACZ,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,CAAC,CAAA;IAE3D;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,KAAK,YAAY,CAAA;IAC/D;;OAEG;IACH,WAAW,EAAE,MAAM,YAAY,CAAA;CAChC,CAAA;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CACrC,CAAA"}
|
|
@@ -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("@etohq/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)(sourcePath, 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,wCAA0E;AAE1E,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,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AAM,IAAA,kBAAU,EAAC,QAAQ,CAAC,CAAA;QAC5C,OAAO,SAAS,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;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("@etohq/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"}
|