@jpmorganchase/mosaic-core 0.1.0-beta.7 → 0.1.0-beta.71
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/PullDocs.d.ts +27 -0
- package/dist/PullDocs.js +64 -79
- package/dist/PullDocs.js.map +1 -1
- package/dist/Source.d.ts +32 -0
- package/dist/Source.js +165 -184
- package/dist/Source.js.map +1 -1
- package/dist/SourceManager.d.ts +41 -0
- package/dist/SourceManager.js +122 -95
- package/dist/SourceManager.js.map +1 -1
- package/dist/WorkerSubscription.d.ts +17 -0
- package/dist/WorkerSubscription.js +50 -64
- package/dist/WorkerSubscription.js.map +1 -1
- package/dist/filesystems/FileAccess.d.ts +31 -0
- package/dist/filesystems/FileAccess.js +161 -189
- package/dist/filesystems/FileAccess.js.map +1 -1
- package/dist/filesystems/ImmutableVolume.d.ts +15 -0
- package/dist/filesystems/ImmutableVolume.js +15 -30
- package/dist/filesystems/ImmutableVolume.js.map +1 -1
- package/dist/filesystems/MutableVolume.d.ts +26 -0
- package/dist/filesystems/MutableVolume.js +22 -52
- package/dist/filesystems/MutableVolume.js.map +1 -1
- package/dist/filesystems/RestrictedVolume.d.ts +24 -0
- package/dist/filesystems/RestrictedVolume.js +17 -35
- package/dist/filesystems/RestrictedVolume.js.map +1 -1
- package/dist/filesystems/UnionFileAccess.d.ts +23 -0
- package/dist/filesystems/UnionFileAccess.js +20 -54
- package/dist/filesystems/UnionFileAccess.js.map +1 -1
- package/dist/filesystems/UnionVolume.d.ts +8 -0
- package/dist/filesystems/UnionVolume.js +14 -33
- package/dist/filesystems/UnionVolume.js.map +1 -1
- package/dist/helpers/createConfig.d.ts +2 -0
- package/dist/helpers/createConfig.js +12 -13
- package/dist/helpers/createConfig.js.map +1 -1
- package/dist/helpers/parsePluginModuleDefinitions.d.ts +13 -0
- package/dist/helpers/parsePluginModuleDefinitions.js +28 -0
- package/dist/helpers/parsePluginModuleDefinitions.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/dist/operators/ObservableWorker.d.ts +3 -0
- package/dist/operators/ObservableWorker.js +9 -8
- package/dist/operators/ObservableWorker.js.map +1 -1
- package/dist/plugin/createPluginAPI.d.ts +2 -0
- package/dist/plugin/createPluginAPI.js +54 -59
- package/dist/plugin/createPluginAPI.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +52 -113
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/loadDefinitionModules.d.ts +2 -0
- package/dist/plugin/loadDefinitionModules.js +21 -35
- package/dist/plugin/loadDefinitionModules.js.map +1 -1
- package/dist/plugin/pluginRunner.d.ts +8 -0
- package/dist/plugin/pluginRunner.js +50 -55
- package/dist/plugin/pluginRunner.js.map +1 -1
- package/dist/plugin/serialiserRunner.d.ts +5 -0
- package/dist/plugin/serialiserRunner.js +31 -42
- package/dist/plugin/serialiserRunner.js.map +1 -1
- package/dist/worker/Source.worker.d.ts +1 -0
- package/dist/worker/Source.worker.js +48 -53
- package/dist/worker/Source.worker.js.map +1 -1
- package/dist/worker/helpers/createSourceObservable.d.ts +3 -0
- package/dist/worker/helpers/createSourceObservable.js +46 -56
- package/dist/worker/helpers/createSourceObservable.js.map +1 -1
- package/dist/worker/helpers/exponentialBackOffRetryStrategy.d.ts +9 -0
- package/dist/worker/helpers/exponentialBackOffRetryStrategy.js +19 -0
- package/dist/worker/helpers/exponentialBackOffRetryStrategy.js.map +1 -0
- package/package.json +21 -10
- package/CHANGELOG.md +0 -77
- package/dist/PluginError.js +0 -6
- package/dist/PluginError.js.map +0 -1
package/dist/Source.js
CHANGED
|
@@ -1,216 +1,197 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
41
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
42
|
-
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");
|
|
43
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
44
|
-
};
|
|
45
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
-
};
|
|
48
|
-
var _Source_instances, _Source_emitter, _Source_modulePath, _Source_plugins, _Source_serialisers, _Source_worker, _Source_globalFilesystem, _Source_pluginApi, _Source_mergedOptions, _Source_pageExtensions, _Source_ignorePages, _Source_workflows, _Source_createWorker;
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
const events_1 = __importDefault(require("events"));
|
|
51
|
-
const md5_1 = __importDefault(require("md5"));
|
|
52
|
-
const memfs_1 = require("memfs");
|
|
53
|
-
const path_1 = __importDefault(require("path"));
|
|
54
|
-
const util_1 = __importDefault(require("util"));
|
|
55
|
-
const FileAccess_1 = __importDefault(require("./filesystems/FileAccess"));
|
|
56
|
-
const MutableVolume_1 = __importDefault(require("./filesystems/MutableVolume"));
|
|
57
|
-
const createConfig_1 = __importDefault(require("./helpers/createConfig"));
|
|
58
|
-
const plugin_1 = require("./plugin");
|
|
59
|
-
const WorkerSubscription_1 = __importStar(require("./WorkerSubscription"));
|
|
60
|
-
class Source {
|
|
61
|
-
constructor({ modulePath, namespace }, mergedOptions, pageExtensions, ignorePages, globalFilesystem, workflows) {
|
|
62
|
-
_Source_instances.add(this);
|
|
63
|
-
_Source_emitter.set(this, new events_1.default());
|
|
64
|
-
_Source_modulePath.set(this, void 0);
|
|
65
|
-
_Source_plugins.set(this, []);
|
|
66
|
-
_Source_serialisers.set(this, []);
|
|
67
|
-
_Source_worker.set(this, void 0);
|
|
68
|
-
_Source_globalFilesystem.set(this, void 0);
|
|
69
|
-
_Source_pluginApi.set(this, void 0);
|
|
70
|
-
_Source_mergedOptions.set(this, void 0);
|
|
71
|
-
_Source_pageExtensions.set(this, void 0);
|
|
72
|
-
_Source_ignorePages.set(this, void 0);
|
|
73
|
-
_Source_workflows.set(this, []);
|
|
74
|
-
__classPrivateFieldSet(this, _Source_modulePath, modulePath, "f");
|
|
75
|
-
__classPrivateFieldSet(this, _Source_mergedOptions, mergedOptions, "f");
|
|
76
|
-
__classPrivateFieldSet(this, _Source_globalFilesystem, globalFilesystem, "f");
|
|
77
|
-
__classPrivateFieldSet(this, _Source_ignorePages, ignorePages, "f");
|
|
78
|
-
__classPrivateFieldSet(this, _Source_workflows, workflows, "f");
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import md5 from 'md5';
|
|
3
|
+
import { Volume } from 'memfs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import util from 'util';
|
|
6
|
+
import FileAccess from './filesystems/FileAccess.js';
|
|
7
|
+
import MutableVolume from './filesystems/MutableVolume.js';
|
|
8
|
+
import createConfig from './helpers/createConfig.js';
|
|
9
|
+
import { bindPluginMethods, bindSerialiser } from './plugin/index.js';
|
|
10
|
+
import WorkerSubscription, { EVENT } from './WorkerSubscription.js';
|
|
11
|
+
export default class Source {
|
|
12
|
+
#emitter = new EventEmitter();
|
|
13
|
+
#modulePath;
|
|
14
|
+
#plugins = [];
|
|
15
|
+
#serialisers = [];
|
|
16
|
+
#worker;
|
|
17
|
+
#globalFilesystem;
|
|
18
|
+
#pluginApi;
|
|
19
|
+
#mergedOptions;
|
|
20
|
+
#pageExtensions;
|
|
21
|
+
#ignorePages;
|
|
22
|
+
#workflows = [];
|
|
23
|
+
#schedule;
|
|
24
|
+
pluginErrors = {};
|
|
25
|
+
config;
|
|
26
|
+
serialiser;
|
|
27
|
+
namespace;
|
|
28
|
+
id;
|
|
29
|
+
filesystem;
|
|
30
|
+
moduleDefinition;
|
|
31
|
+
constructor(moduleDefinition, mergedOptions, pageExtensions, ignorePages, globalFilesystem, workflows = []) {
|
|
32
|
+
const { modulePath, namespace, schedule } = moduleDefinition;
|
|
33
|
+
this.moduleDefinition = moduleDefinition;
|
|
34
|
+
this.#modulePath = modulePath;
|
|
35
|
+
this.#mergedOptions = mergedOptions;
|
|
36
|
+
this.#globalFilesystem = globalFilesystem;
|
|
37
|
+
this.#ignorePages = ignorePages;
|
|
38
|
+
this.#workflows = workflows;
|
|
39
|
+
this.#schedule = schedule;
|
|
79
40
|
this.namespace = namespace;
|
|
80
|
-
this.id = Symbol(`${
|
|
81
|
-
this.filesystem = new
|
|
82
|
-
|
|
41
|
+
this.id = Symbol(`${path.basename(path.dirname(path.resolve(modulePath, '../')))}#${md5(util.inspect(this.#mergedOptions, { sorted: true })).substring(0, 8)}`);
|
|
42
|
+
this.filesystem = new MutableVolume(new FileAccess(new Volume()), this.namespace);
|
|
43
|
+
this.#pageExtensions = pageExtensions;
|
|
83
44
|
}
|
|
84
45
|
onUpdate(callback) {
|
|
85
|
-
|
|
86
|
-
return () =>
|
|
46
|
+
this.#emitter.on(EVENT.UPDATE, callback);
|
|
47
|
+
return () => this.#emitter.off(EVENT.UPDATE, callback);
|
|
87
48
|
}
|
|
88
49
|
onError(callback) {
|
|
89
|
-
|
|
90
|
-
return () =>
|
|
50
|
+
this.#emitter.once(EVENT.ERROR, callback);
|
|
51
|
+
return () => this.#emitter.off(EVENT.ERROR, callback);
|
|
91
52
|
}
|
|
92
53
|
onStart(callback) {
|
|
93
|
-
|
|
94
|
-
return () =>
|
|
54
|
+
this.#emitter.once(EVENT.START, callback);
|
|
55
|
+
return () => this.#emitter.off(EVENT.START, callback);
|
|
95
56
|
}
|
|
96
57
|
onExit(callback) {
|
|
97
|
-
|
|
98
|
-
return () =>
|
|
58
|
+
this.#emitter.once(EVENT.EXIT, callback);
|
|
59
|
+
return () => this.#emitter.off(EVENT.EXIT, callback);
|
|
99
60
|
}
|
|
100
61
|
stop() {
|
|
101
|
-
if (
|
|
62
|
+
if (this.#worker && this.#worker.closed) {
|
|
102
63
|
throw new Error('Cannot stop source that has not started');
|
|
103
64
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
65
|
+
if (this.#worker) {
|
|
66
|
+
this.#worker.stop();
|
|
106
67
|
}
|
|
107
68
|
}
|
|
108
69
|
/**
|
|
109
70
|
* Called when another source (not this one) has changed.
|
|
110
71
|
* This source can then ask its plugins if they also want to clear their cache in response to the other source's change.
|
|
111
72
|
*/
|
|
112
|
-
requestCacheClear(updatedSourceFilesystem) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
const timeTaken = new Date().getTime() - initTime;
|
|
123
|
-
if (timeTaken > 400) {
|
|
124
|
-
console.warn(`Lifecycle phase 'shouldClearCache' for source '${this.id.description}' took ${timeTaken}ms to complete. The method is async, so this may not be an accurate measurement of execution time, but consider optimising this method if it is performing intensive operations.`);
|
|
125
|
-
}
|
|
126
|
-
if (shouldInvokeAfterUpdate === true) {
|
|
127
|
-
this.filesystem.clearCache();
|
|
128
|
-
}
|
|
73
|
+
async requestCacheClear(updatedSourceFilesystem) {
|
|
74
|
+
const initTime = new Date().getTime();
|
|
75
|
+
const shouldInvokeAfterUpdate = await this.#pluginApi.shouldClearCache(updatedSourceFilesystem, {
|
|
76
|
+
globalFilesystem: this.#globalFilesystem,
|
|
77
|
+
pageExtensions: this.#pageExtensions,
|
|
78
|
+
ignorePages: this.#ignorePages,
|
|
79
|
+
serialiser: this.serialiser,
|
|
80
|
+
config: this.config.asReadOnly(),
|
|
81
|
+
namespace: this.namespace
|
|
129
82
|
});
|
|
83
|
+
const timeTaken = new Date().getTime() - initTime;
|
|
84
|
+
if (timeTaken > 400) {
|
|
85
|
+
console.warn(`Lifecycle phase 'shouldClearCache' for source '${this.id.description}' took ${timeTaken}ms to complete. The method is async, so this may not be an accurate measurement of execution time, but consider optimising this method if it is performing intensive operations.`);
|
|
86
|
+
}
|
|
87
|
+
if (shouldInvokeAfterUpdate === true) {
|
|
88
|
+
this.filesystem.clearCache();
|
|
89
|
+
}
|
|
130
90
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
91
|
+
async requestNamespaceSourceUpdate(namespaceSourceDesc, updatedSourceFilesystem, sharedFilesystem, globalConfig) {
|
|
92
|
+
const initTime = new Date().getTime();
|
|
93
|
+
const shouldInvokeAfterUpdate = await this.#pluginApi.shouldUpdateNamespaceSources(updatedSourceFilesystem, {
|
|
94
|
+
globalFilesystem: this.#globalFilesystem,
|
|
95
|
+
pageExtensions: this.#pageExtensions,
|
|
96
|
+
ignorePages: this.#ignorePages,
|
|
97
|
+
serialiser: this.serialiser,
|
|
98
|
+
config: this.config.asReadOnly(),
|
|
99
|
+
namespace: this.namespace
|
|
135
100
|
});
|
|
101
|
+
const timeTaken = new Date().getTime() - initTime;
|
|
102
|
+
if (timeTaken > 400) {
|
|
103
|
+
console.warn(`Lifecycle phase 'shouldUpdateNamespaceSources' for source '${this.id.description}' took ${timeTaken}ms to complete. The method is async, so this may not be an accurate measurement of execution time, but consider optimising this method if it is performing intensive operations.`);
|
|
104
|
+
}
|
|
105
|
+
if (shouldInvokeAfterUpdate === true) {
|
|
106
|
+
console.log(`[Mosaic][Source] namespace source ${namespaceSourceDesc} updated. Triggering 'afterNamespaceSourceUpdate for ${this.id.description}`);
|
|
107
|
+
this.filesystem.unfreeze();
|
|
108
|
+
await this.invokeAfterUpdate(sharedFilesystem, globalConfig, 'afterNamespaceSourceUpdate');
|
|
109
|
+
this.filesystem.freeze();
|
|
110
|
+
this.filesystem.clearCache();
|
|
111
|
+
}
|
|
136
112
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
serialiser: this.serialiser,
|
|
147
|
-
config: this.config.asReadOnly()
|
|
148
|
-
});
|
|
149
|
-
const timeTaken = new Date().getTime() - initTime;
|
|
150
|
-
if (timeTaken > 800) {
|
|
151
|
-
console.warn(`Lifecycle phase 'afterUpdate' for source '${this.id.description}' took ${timeTaken / 1000}s to complete. The method is async, so this may not be an accurate measurement of execution time, but consider optimising this method if it is performing intensive operations.`);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
113
|
+
async use(plugins = [], serialisers = []) {
|
|
114
|
+
if (this.namespace.startsWith('preview-')) {
|
|
115
|
+
console.log('[Mosaic] Preview source detected, filtering plugins to use.');
|
|
116
|
+
this.#plugins.push(...plugins.filter(plugin => !plugin.previewDisabled));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.#plugins.push(...plugins);
|
|
120
|
+
}
|
|
121
|
+
this.#serialisers.push(...serialisers);
|
|
154
122
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
123
|
+
async invokeAfterUpdate(sharedFilesystem, globalConfig, lifecycleMethod = 'afterUpdate') {
|
|
124
|
+
const initTime = new Date().getTime();
|
|
125
|
+
await this.#pluginApi[lifecycleMethod](this.filesystem.asRestricted(), {
|
|
126
|
+
globalFilesystem: this.#globalFilesystem,
|
|
127
|
+
sharedFilesystem,
|
|
128
|
+
globalConfig,
|
|
129
|
+
pageExtensions: this.#pageExtensions,
|
|
130
|
+
ignorePages: this.#ignorePages,
|
|
131
|
+
serialiser: this.serialiser,
|
|
132
|
+
config: this.config.asReadOnly(),
|
|
133
|
+
namespace: this.namespace
|
|
164
134
|
});
|
|
135
|
+
const timeTaken = new Date().getTime() - initTime;
|
|
136
|
+
if (timeTaken > 800) {
|
|
137
|
+
console.warn(`Lifecycle phase '${lifecycleMethod}' for source '${this.id.description}' took ${timeTaken / 1000}s to complete. The method is async, so this may not be an accurate measurement of execution time, but consider optimising this method if it is performing intensive operations.`);
|
|
138
|
+
}
|
|
165
139
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
#createWorker() {
|
|
141
|
+
const worker = new WorkerSubscription({
|
|
142
|
+
modulePath: this.#modulePath,
|
|
143
|
+
name: this.id.description,
|
|
144
|
+
options: this.#mergedOptions,
|
|
145
|
+
namespace: this.namespace,
|
|
146
|
+
pageExtensions: this.#pageExtensions,
|
|
147
|
+
ignorePages: this.#ignorePages,
|
|
148
|
+
plugins: this.#plugins,
|
|
149
|
+
serialisers: this.#serialisers,
|
|
150
|
+
schedule: this.#schedule
|
|
170
151
|
});
|
|
152
|
+
worker.once(EVENT.ERROR, error => this.#emitter.emit(EVENT.ERROR, error));
|
|
153
|
+
worker.once(EVENT.EXIT, () => {
|
|
154
|
+
this.#emitter.emit(EVENT.EXIT);
|
|
155
|
+
this.#emitter.removeAllListeners();
|
|
156
|
+
// this.filesystem.reset();
|
|
157
|
+
this.filesystem = null;
|
|
158
|
+
});
|
|
159
|
+
worker.once(EVENT.START, () => this.#emitter.emit(EVENT.START));
|
|
160
|
+
return worker;
|
|
171
161
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
error: `[Mosaic] Multiple workflows with ${name} found for ${this.id.description.toString()}`
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
const triggeredWorkflow = foundWorkflows[0];
|
|
187
|
-
if (triggeredWorkflow) {
|
|
188
|
-
return triggeredWorkflow.action(__classPrivateFieldGet(this, _Source_mergedOptions, "f"), triggeredWorkflow.options, filePath, data);
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
162
|
+
async start() {
|
|
163
|
+
this.serialiser = await bindSerialiser(this.#serialisers);
|
|
164
|
+
this.#pluginApi = await bindPluginMethods(this.#plugins, this.trackPluginErrors.bind(this));
|
|
165
|
+
this.#worker = this.#createWorker();
|
|
166
|
+
this.#worker.on(EVENT.UPDATE, async ({ data: { pages, symlinks, data } }) => {
|
|
167
|
+
this.config = createConfig(data);
|
|
168
|
+
this.#emitter.emit(EVENT.UPDATE, { pages, symlinks, data });
|
|
169
|
+
});
|
|
170
|
+
this.#worker.on(EVENT.TRACK, async ({ data: { errors, lifecycleMethod } }) => {
|
|
171
|
+
this.pluginErrors[`${lifecycleMethod}`] = errors;
|
|
191
172
|
});
|
|
192
173
|
}
|
|
174
|
+
async isOwner(filePath) {
|
|
175
|
+
const isFileInSource = await this.filesystem.promises.exists(filePath);
|
|
176
|
+
return isFileInSource;
|
|
177
|
+
}
|
|
178
|
+
triggerWorkflow(sendWorkflowProgressMessage, name, filePath, data) {
|
|
179
|
+
const foundWorkflows = this.#workflows.filter(workflow => workflow.name === name);
|
|
180
|
+
if (foundWorkflows.length === 0) {
|
|
181
|
+
sendWorkflowProgressMessage(`[Mosaic][Source] workflow ${name} not found for ${this.id.description.toString()}`, 'ERROR');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (foundWorkflows.length > 1) {
|
|
185
|
+
sendWorkflowProgressMessage(`[Mosaic][Source] multiple workflows with "${name}" found for ${this.id.description.toString()}`, 'ERROR');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const triggeredWorkflow = foundWorkflows[0];
|
|
189
|
+
if (triggeredWorkflow) {
|
|
190
|
+
triggeredWorkflow.action(sendWorkflowProgressMessage, this.#mergedOptions, triggeredWorkflow.options, filePath, data);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
trackPluginErrors(errors, lifecycleMethod) {
|
|
194
|
+
this.pluginErrors[`${lifecycleMethod}`] = errors;
|
|
195
|
+
}
|
|
193
196
|
}
|
|
194
|
-
exports.default = Source;
|
|
195
|
-
_Source_emitter = new WeakMap(), _Source_modulePath = new WeakMap(), _Source_plugins = new WeakMap(), _Source_serialisers = new WeakMap(), _Source_worker = new WeakMap(), _Source_globalFilesystem = new WeakMap(), _Source_pluginApi = new WeakMap(), _Source_mergedOptions = new WeakMap(), _Source_pageExtensions = new WeakMap(), _Source_ignorePages = new WeakMap(), _Source_workflows = new WeakMap(), _Source_instances = new WeakSet(), _Source_createWorker = function _Source_createWorker() {
|
|
196
|
-
const worker = new WorkerSubscription_1.default({
|
|
197
|
-
modulePath: __classPrivateFieldGet(this, _Source_modulePath, "f"),
|
|
198
|
-
name: this.id.description,
|
|
199
|
-
options: __classPrivateFieldGet(this, _Source_mergedOptions, "f"),
|
|
200
|
-
namespace: this.namespace,
|
|
201
|
-
pageExtensions: __classPrivateFieldGet(this, _Source_pageExtensions, "f"),
|
|
202
|
-
ignorePages: __classPrivateFieldGet(this, _Source_ignorePages, "f"),
|
|
203
|
-
plugins: __classPrivateFieldGet(this, _Source_plugins, "f"),
|
|
204
|
-
serialisers: __classPrivateFieldGet(this, _Source_serialisers, "f")
|
|
205
|
-
});
|
|
206
|
-
worker.once(WorkerSubscription_1.EVENT.ERROR, error => __classPrivateFieldGet(this, _Source_emitter, "f").emit(WorkerSubscription_1.EVENT.ERROR, error));
|
|
207
|
-
worker.once(WorkerSubscription_1.EVENT.EXIT, () => {
|
|
208
|
-
__classPrivateFieldGet(this, _Source_emitter, "f").emit(WorkerSubscription_1.EVENT.EXIT);
|
|
209
|
-
__classPrivateFieldGet(this, _Source_emitter, "f").removeAllListeners();
|
|
210
|
-
// this.filesystem.reset();
|
|
211
|
-
this.filesystem = null;
|
|
212
|
-
});
|
|
213
|
-
worker.once(WorkerSubscription_1.EVENT.START, () => __classPrivateFieldGet(this, _Source_emitter, "f").emit(WorkerSubscription_1.EVENT.START));
|
|
214
|
-
return worker;
|
|
215
|
-
};
|
|
216
197
|
//# sourceMappingURL=Source.js.map
|
package/dist/Source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Source.js","sourceRoot":"","sources":["../src/Source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Source.js","sourceRoot":"","sources":["../src/Source.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AAiBxB,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,QAAQ,GAAiB,IAAI,YAAY,EAAE,CAAC;IAC5C,WAAW,CAAS;IACpB,QAAQ,GAA6B,EAAE,CAAC;IACxC,YAAY,GAAiC,EAAE,CAAC;IAChD,OAAO,CAAqB;IAC5B,iBAAiB,CAAe;IAChC,UAAU,CAAS;IACnB,cAAc,CAA0B;IACxC,eAAe,CAAW;IAC1B,YAAY,CAAW;IACvB,UAAU,GAAqB,EAAE,CAAC;IAClC,SAAS,CAAiB;IAC1B,YAAY,GAA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/mosaic-types';
|
|
2
|
+
import Source from './Source.js';
|
|
3
|
+
export default class SourceManager {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(globalFilesystem: any, sharedFilesystem: any, plugins: any[], serialisers: any[], pageExtensions: any[], ignorePages: any[], schedule: any);
|
|
6
|
+
onSourceUpdate(callback: any): () => boolean;
|
|
7
|
+
triggerWorkflow(sendWorkflowProgressMessage: SendSourceWorkflowMessage, name: string, filePath: string, data: unknown): Promise<void>;
|
|
8
|
+
getSource(name: string): Source;
|
|
9
|
+
destroyAll(): void;
|
|
10
|
+
destroySource(name: string): void;
|
|
11
|
+
addSource(sourceDefinition: SourceModuleDefinition, options: Record<string, unknown>): Promise<Source>;
|
|
12
|
+
listSources(): {
|
|
13
|
+
name: string;
|
|
14
|
+
pluginErrors: any;
|
|
15
|
+
index: number;
|
|
16
|
+
}[];
|
|
17
|
+
getSourceDefinition(name: string): {
|
|
18
|
+
modulePath: string;
|
|
19
|
+
namespace: string;
|
|
20
|
+
options?: unknown;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
runTimeOnly?: boolean;
|
|
23
|
+
priority?: number;
|
|
24
|
+
previewDisabled?: boolean;
|
|
25
|
+
allowMultiple?: boolean;
|
|
26
|
+
cache?: boolean;
|
|
27
|
+
workflows?: {
|
|
28
|
+
name: string;
|
|
29
|
+
options?: unknown;
|
|
30
|
+
action?: any;
|
|
31
|
+
}[];
|
|
32
|
+
schedule?: {
|
|
33
|
+
checkIntervalMins: number;
|
|
34
|
+
initialDelayMs: number;
|
|
35
|
+
retryEnabled: boolean;
|
|
36
|
+
retryDelayMins: number;
|
|
37
|
+
maxRetries: number;
|
|
38
|
+
resetOnSuccess: boolean;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|