@jpmorganchase/mosaic-core 0.1.0-beta.10
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/PluginError.d.ts +2 -0
- package/dist/PluginError.js +3 -0
- package/dist/PluginError.js.map +1 -0
- package/dist/PullDocs.d.ts +19 -0
- package/dist/PullDocs.js +92 -0
- package/dist/PullDocs.js.map +1 -0
- package/dist/Source.d.ts +28 -0
- package/dist/Source.js +157 -0
- package/dist/Source.js.map +1 -0
- package/dist/SourceManager.d.ts +11 -0
- package/dist/SourceManager.js +137 -0
- package/dist/SourceManager.js.map +1 -0
- package/dist/WorkerSubscription.d.ts +16 -0
- package/dist/WorkerSubscription.js +69 -0
- package/dist/WorkerSubscription.js.map +1 -0
- package/dist/filesystems/FileAccess.d.ts +31 -0
- package/dist/filesystems/FileAccess.js +217 -0
- package/dist/filesystems/FileAccess.js.map +1 -0
- package/dist/filesystems/ImmutableVolume.d.ts +15 -0
- package/dist/filesystems/ImmutableVolume.js +26 -0
- package/dist/filesystems/ImmutableVolume.js.map +1 -0
- package/dist/filesystems/MutableVolume.d.ts +26 -0
- package/dist/filesystems/MutableVolume.js +43 -0
- package/dist/filesystems/MutableVolume.js.map +1 -0
- package/dist/filesystems/RestrictedVolume.d.ts +24 -0
- package/dist/filesystems/RestrictedVolume.js +38 -0
- package/dist/filesystems/RestrictedVolume.js.map +1 -0
- package/dist/filesystems/UnionFileAccess.d.ts +23 -0
- package/dist/filesystems/UnionFileAccess.js +55 -0
- package/dist/filesystems/UnionFileAccess.js.map +1 -0
- package/dist/filesystems/UnionVolume.d.ts +8 -0
- package/dist/filesystems/UnionVolume.js +21 -0
- package/dist/filesystems/UnionVolume.js.map +1 -0
- package/dist/helpers/createConfig.d.ts +2 -0
- package/dist/helpers/createConfig.js +54 -0
- package/dist/helpers/createConfig.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/operators/ObservableWorker.d.ts +3 -0
- package/dist/operators/ObservableWorker.js +25 -0
- package/dist/operators/ObservableWorker.js.map +1 -0
- package/dist/plugin/createPluginAPI.d.ts +2 -0
- package/dist/plugin/createPluginAPI.js +76 -0
- package/dist/plugin/createPluginAPI.js.map +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +82 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/loadDefinitionModules.d.ts +2 -0
- package/dist/plugin/loadDefinitionModules.js +42 -0
- package/dist/plugin/loadDefinitionModules.js.map +1 -0
- package/dist/plugin/pluginRunner.d.ts +5 -0
- package/dist/plugin/pluginRunner.js +43 -0
- package/dist/plugin/pluginRunner.js.map +1 -0
- package/dist/plugin/serialiserRunner.d.ts +5 -0
- package/dist/plugin/serialiserRunner.js +31 -0
- package/dist/plugin/serialiserRunner.js.map +1 -0
- package/dist/worker/Source.worker.d.ts +1 -0
- package/dist/worker/Source.worker.js +103 -0
- package/dist/worker/Source.worker.js.map +1 -0
- package/dist/worker/helpers/createSourceObservable.d.ts +3 -0
- package/dist/worker/helpers/createSourceObservable.js +49 -0
- package/dist/worker/helpers/createSourceObservable.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableWorker.js","sourceRoot":"","sources":["../../src/operators/ObservableWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,IAAI,CAAI,UAAsB;IACpD,OAAO,IAAI,UAAU,CAAI,QAAQ,CAAC,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE;YACpE,UAAU;SACX,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,EAAE;gBACd,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC,CAAC;aAC3E;iBAAM;gBACL,QAAQ,CAAC,QAAQ,EAAE,CAAC;aACrB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import loadDefinitionModules from './loadDefinitionModules.js';
|
|
2
|
+
import pluginRunner from './pluginRunner.js';
|
|
3
|
+
import serialiserRunner from './serialiserRunner.js';
|
|
4
|
+
function createProxyBaseSerialiserAPI() {
|
|
5
|
+
return {
|
|
6
|
+
serialise() {
|
|
7
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
8
|
+
},
|
|
9
|
+
deserialise() {
|
|
10
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createProxyBaseAPI() {
|
|
15
|
+
return {
|
|
16
|
+
$afterSource() {
|
|
17
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
18
|
+
},
|
|
19
|
+
shouldClearCache() {
|
|
20
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
21
|
+
},
|
|
22
|
+
afterUpdate() {
|
|
23
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
24
|
+
},
|
|
25
|
+
$beforeSend() {
|
|
26
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
27
|
+
},
|
|
28
|
+
saveContent() {
|
|
29
|
+
throw new Error('This is just for the interface on the Proxy and should never be invoked.');
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export default async function createPluginAPI(plugins) {
|
|
34
|
+
const loadedPlugins = await loadDefinitionModules(plugins);
|
|
35
|
+
const baseObj = createProxyBaseAPI();
|
|
36
|
+
const baseSerialiserObj = createProxyBaseSerialiserAPI();
|
|
37
|
+
return new Proxy(baseObj, {
|
|
38
|
+
get(obj, propOrLifecycleName) {
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(baseSerialiserObj, propOrLifecycleName)) {
|
|
40
|
+
return async (pagePath, ...args) => {
|
|
41
|
+
let result;
|
|
42
|
+
try {
|
|
43
|
+
result = await serialiserRunner({
|
|
44
|
+
serialiserMethod: String(propOrLifecycleName),
|
|
45
|
+
loadedPlugins: loadedPlugins
|
|
46
|
+
}, pagePath, ...args);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new Error(e);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(baseObj, propOrLifecycleName)) {
|
|
55
|
+
return async (...args) => {
|
|
56
|
+
let result;
|
|
57
|
+
try {
|
|
58
|
+
result = await pluginRunner({
|
|
59
|
+
loadedPlugins: loadedPlugins,
|
|
60
|
+
lifecycleName: String(propOrLifecycleName)
|
|
61
|
+
}, ...args);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
throw new Error(e);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (typeof obj[propOrLifecycleName] !== 'undefined') {
|
|
70
|
+
return obj[propOrLifecycleName];
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=createPluginAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPluginAPI.js","sourceRoot":"","sources":["../../src/plugin/createPluginAPI.ts"],"names":[],"mappings":"AASA,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD,SAAS,4BAA4B;IACnC,OAAO;QACL,SAAS;YACP,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;QACD,WAAW;YACT,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO;QACL,YAAY;YACV,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;QACD,gBAAgB;YACd,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;QACD,WAAW;YACT,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;QACD,WAAW;YACT,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;QACD,WAAW;YACT,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;QAC9F,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,eAAe,CAC3C,OAAiC;IAEjC,MAAM,aAAa,GAAwC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAChG,MAAM,OAAO,GAAG,kB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AAC;QACnB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import loadPlugins from './createPluginAPI.js';
|
|
2
|
+
export async function bindSerialiser(serialisers) {
|
|
3
|
+
const pluginApi = (await loadPlugins(serialisers));
|
|
4
|
+
return {
|
|
5
|
+
async serialise(fullPath, page) {
|
|
6
|
+
let result;
|
|
7
|
+
try {
|
|
8
|
+
result = await pluginApi.serialise(fullPath, page);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
throw new Error(e);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
},
|
|
15
|
+
async deserialise(fullPath, data) {
|
|
16
|
+
let result;
|
|
17
|
+
try {
|
|
18
|
+
result = await pluginApi.deserialise(fullPath, data);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new Error(e);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export async function bindPluginMethods(plugins) {
|
|
28
|
+
const pluginApi = await loadPlugins(plugins);
|
|
29
|
+
return {
|
|
30
|
+
async $afterSource(pages, args) {
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
result = await pluginApi.$afterSource(pages, args);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new Error(e);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
async shouldClearCache(lastAfterUpdateReturn, args) {
|
|
41
|
+
let result;
|
|
42
|
+
try {
|
|
43
|
+
result = await pluginApi.shouldClearCache(lastAfterUpdateReturn, args);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
throw new Error(e);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
},
|
|
50
|
+
async afterUpdate(mutableFilesystem, args) {
|
|
51
|
+
let result;
|
|
52
|
+
try {
|
|
53
|
+
result = await pluginApi.afterUpdate(mutableFilesystem, args);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
throw new Error(e);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
},
|
|
60
|
+
async $beforeSend(mutableFilesystem, args) {
|
|
61
|
+
let result;
|
|
62
|
+
try {
|
|
63
|
+
result = await pluginApi.$beforeSend(mutableFilesystem, args);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
throw new Error(e);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
},
|
|
70
|
+
async saveContent(filePath, data, sourceOptions, args) {
|
|
71
|
+
let result;
|
|
72
|
+
try {
|
|
73
|
+
result = await pluginApi.saveContent(filePath, data, sourceOptions, args);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
throw new Error(e);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAUA,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,WAAW;IAC9C,MAAM,SAAS,GAAG,CAAC,MAAM,WAAW,CAAO,WAAW,CAAC,CAAe,CAAC;IAEvE,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI;YAC5B,IAAI,MAAM,CAAC;YACX,IAAI;gBACF,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;aACpD;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;aACpB;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,QAAQ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,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,iBAAiB,EAAE,IAAI;YACvC,IAAI,MAAM,CAAC;YACX,IAAI;gBACF,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;aAC/D;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;aACpB;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,WAAW,CACf,QAAgB,EAChB,IAAa,EACb,aAAsC,EACtC,IAAI;YAEJ,IAAI,MAAM,CAAC;YACX,IAAI;gBACF,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;aAC3E;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;aACpB;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { LoadedPlugin, LoadedSerialiser, PluginModuleDefinition, SerialiserModuleDefinition } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
export default function loadDefinitionModules(plugins: (PluginModuleDefinition | SerialiserModuleDefinition)[]): Promise<LoadedPlugin[] | LoadedSerialiser[]>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const loadedPluginsAndSerialisers = {};
|
|
2
|
+
function createInvoker(plugin, api) {
|
|
3
|
+
return new Proxy(plugin, {
|
|
4
|
+
get(obj, prop) {
|
|
5
|
+
if (typeof obj[prop] !== 'undefined') {
|
|
6
|
+
return obj[prop];
|
|
7
|
+
}
|
|
8
|
+
if (typeof api === 'function') {
|
|
9
|
+
return api;
|
|
10
|
+
}
|
|
11
|
+
if (prop in api) {
|
|
12
|
+
return api[prop];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export default async function loadDefinitionModules(plugins) {
|
|
19
|
+
const results = [];
|
|
20
|
+
try {
|
|
21
|
+
for (const plugin of plugins) {
|
|
22
|
+
const { modulePath } = plugin;
|
|
23
|
+
if (!loadedPluginsAndSerialisers[modulePath]) {
|
|
24
|
+
const { default: definitionExports } = await import(modulePath);
|
|
25
|
+
const pluginApi = '__esModule' in definitionExports && 'default' in definitionExports
|
|
26
|
+
? definitionExports.default
|
|
27
|
+
: definitionExports;
|
|
28
|
+
if (!pluginApi) {
|
|
29
|
+
throw new Error(`Plugin or serialiser '${modulePath}' did not have a default export.`);
|
|
30
|
+
}
|
|
31
|
+
loadedPluginsAndSerialisers[modulePath] = createInvoker(plugin, pluginApi);
|
|
32
|
+
}
|
|
33
|
+
results.push(loadedPluginsAndSerialisers[modulePath]);
|
|
34
|
+
}
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
throw new Error(`Could not load plugin/serialiser modules due to error.
|
|
39
|
+
${e}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=loadDefinitionModules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadDefinitionModules.js","sourceRoot":"","sources":["../../src/plugin/loadDefinitionModules.ts"],"names":[],"mappings":"AASA,MAAM,2BAA2B,GAAuD,EAAE,CAAC;AAE3F,SAAS,aAAa,CAAC,MAAM,EAAE,GAAG;IAChC,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,GAAG,EAAE,IAAI;YACX,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;gBACpC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;aAClB;YAED,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;gBAC7B,OAAO,GAAG,CAAC;aACZ;YAED,IAAI,IAAI,IAAI,GAAG,EAAE;gBACf,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;aAClB;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CACjD,OAAgE;IAEhE,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,IAAI;QACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,MAAM,EAAE,UAAU,EAAE,GAA2B,MAAM,CAAC;YACtD,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,EAAE;gBAC5C,MAAM,EACJ,OAAO,EAAE,iBAAiB,EAC3B,GAKG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC7B,MAAM,SAAS,GACb,YAAY,IAAI,iBAAiB,IAAI,SAAS,IAAI,iBAAiB;oBACjE,CAAC,CAAC,iBAAiB,CAAC,OAAO;oBAC3B,CAAC,CAAC,iBAAiB,CAAC;gBACxB,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,UAAU,kCAAkC,CAAC,CAAC;iBACxF;gBAED,2BAA2B,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;aAC5E;YACD,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC;SACvD;QACD,OAAO,OAAO,CAAC;KAChB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC;EAClB,CAAC,EAAE,CAAC,CAAC;KACJ;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import PluginError from '../PluginError.js';
|
|
2
|
+
export default async function pluginRunner({ loadedPlugins, lifecycleName }, input, ...args) {
|
|
3
|
+
let transformedInput = input;
|
|
4
|
+
for (const plugin of loadedPlugins) {
|
|
5
|
+
try {
|
|
6
|
+
if (typeof input === 'undefined') {
|
|
7
|
+
throw new Error('Input was undefined.');
|
|
8
|
+
}
|
|
9
|
+
if (typeof plugin[lifecycleName] !== 'function') {
|
|
10
|
+
// eslint-disable-next-line no-continue
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
// console.debug(
|
|
14
|
+
// `[Mosaic] Applying plugin method \`${lifecycleName}\`${lifecycleName.startsWith('$') ? ' (in a child worker)' : ''} for '${plugin.modulePath}'.`
|
|
15
|
+
// );
|
|
16
|
+
// eslint-disable-next-line no-await-in-loop
|
|
17
|
+
const result = await plugin[lifecycleName](lifecycleName === '$afterSource' ? transformedInput : input, ...args, plugin.options);
|
|
18
|
+
if (result &&
|
|
19
|
+
lifecycleName !== '$afterSource' &&
|
|
20
|
+
lifecycleName !== 'shouldClearCache' &&
|
|
21
|
+
lifecycleName !== 'saveContent') {
|
|
22
|
+
console.warn(`[Mosaic] \`${lifecycleName}\` plugin should not return a value - this lifecycle phase expects mutation to occur directly on the filesystem instance. This will be ignored.`);
|
|
23
|
+
}
|
|
24
|
+
if (lifecycleName === 'saveContent' && !result) {
|
|
25
|
+
console.warn(`[Mosaic] \`${lifecycleName}\` plugin returned a falsy value - this result has been discarded.`);
|
|
26
|
+
// eslint-disable-next-line no-continue
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
transformedInput = result;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
// This check will stop nested errors from ending up with multiple 'Plugin X threw an exception' headers from
|
|
33
|
+
// being prefixed to the messages
|
|
34
|
+
if (e instanceof PluginError) {
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
throw new PluginError(`Plugin '${plugin.modulePath}' threw an exception running \`${lifecycleName}\`. See below:
|
|
38
|
+
${e.stack}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return transformedInput;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=pluginRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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AM,IAAI,WAAW,CACnB,WAAW,MAAM,CAAC,UAAU,kCAAkC,aAAa;IAC/E,CAAC,CAAC,KAAK,EAAE,CACN,CAAC;SACH;KACF;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import PluginError from '../PluginError.js';
|
|
2
|
+
export default async function serialiserRunner({ loadedPlugins, serialiserMethod }, fullPath, ...args) {
|
|
3
|
+
if (typeof fullPath !== 'string' || !/\/[^/]+\.\w{1,4}$/.test(fullPath)) {
|
|
4
|
+
throw new Error(`Invalid serialiser input. '${fullPath}' provided but a path string (with a valid file extension) was expected.`);
|
|
5
|
+
}
|
|
6
|
+
for (const serialiser of loadedPlugins) {
|
|
7
|
+
try {
|
|
8
|
+
if (!serialiser.filter.test(String(fullPath))) {
|
|
9
|
+
// Serialiser failed the path filter test
|
|
10
|
+
// eslint-disable-next-line no-continue
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line no-await-in-loop
|
|
14
|
+
const result = await serialiser[serialiserMethod](fullPath, ...args, serialiser.options);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
// This check will stop nested errors from ending up with multiple 'Plugin X threw an exception' headers from
|
|
19
|
+
// being prefixed to the messages
|
|
20
|
+
if (e instanceof PluginError) {
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
throw new PluginError(`Serialiser '${serialiser.modulePath}' threw an exception calling \`serialiser.${serialiserMethod}\` on '${fullPath}'.
|
|
24
|
+
|
|
25
|
+
Is this the correct serialiser to use for this file type? See error below:
|
|
26
|
+
${e.stack}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Could not find a suitable serialiser for file '${fullPath}'.`);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=serialiserRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialiserRunner.js","sourceRoot":"","sources":["../../src/plugin/serialiserRunner.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,EACE,aAAa,EACb,gBAAgB,EACgD,EAClE,QAAgB,EAChB,GAAG,IAAI;IAEP,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CACb,8BAA8B,QAAQ,0EAA0E,CACjH,CAAC;KACH;IACD,KAAK,MAAM,UAAU,IAAI,aAAa,EAAE;QACtC,IAAI;YACF,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE;gBAC7C,yCAAyC;gBACzC,uCAAuC;gBACvC,SAAS;aACV;YACD,4CAA4C;YAC5C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;YACzF,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,CAAC,EAAE;YACV,6GAA6G;YAC7G,iCAAiC;YACjC,IAAI,CAAC,YAAY,WAAW,EAAE;gBAC5B,MAAM,CAAC,CAAC;aACT;YACD,MAAM,IAAI,WAAW,CACnB,eAAe,UAAU,CAAC,UAAU,6CAA6C,gBAAgB,UAAU,QAAQ;;;IAGvH,CAAC,CAAC,KAAK,EAAE,CACN,CAAC;SACH;KACF;IACD,MAAM,IAAI,KAAK,CAAC,kDAAkD,QAAQ,IAAI,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { isMainThread, parentPort, workerData as unTypedWorkerData } from 'worker_threads';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { Volume } from 'memfs';
|
|
5
|
+
import { switchMap, tap } from 'rxjs';
|
|
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 createSourceObservable from './helpers/createSourceObservable.js';
|
|
11
|
+
const workerData = unTypedWorkerData;
|
|
12
|
+
if (isMainThread) {
|
|
13
|
+
throw new Error('This module can only be called from a child process.');
|
|
14
|
+
}
|
|
15
|
+
(async () => {
|
|
16
|
+
let config;
|
|
17
|
+
let filesystem;
|
|
18
|
+
const serialiser = await bindSerialiser(workerData.serialisers);
|
|
19
|
+
const pluginApi = await bindPluginMethods(workerData.plugins);
|
|
20
|
+
const cachePath = path.join(process.cwd(), '.tmp', '.cache', `${workerData.name}.json`);
|
|
21
|
+
if (workerData.options.cache !== false) {
|
|
22
|
+
await fs.promises.mkdir(path.dirname(cachePath), { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
(await createSourceObservable(workerData, serialiser))
|
|
25
|
+
.pipe(tap(() => {
|
|
26
|
+
config = createConfig();
|
|
27
|
+
}), switchMap((pages) => pluginApi.$afterSource(pages, {
|
|
28
|
+
config,
|
|
29
|
+
serialiser,
|
|
30
|
+
ignorePages: workerData.ignorePages,
|
|
31
|
+
pageExtensions: workerData.pageExtensions
|
|
32
|
+
})), switchMap((pages) => pages.reduce(async (mergedPagesPromise, page) => {
|
|
33
|
+
const mergedPages = await mergedPagesPromise;
|
|
34
|
+
mergedPages[page.fullPath] = String(await serialiser.serialise(page.fullPath, page));
|
|
35
|
+
return mergedPages;
|
|
36
|
+
}, Promise.resolve({}))), switchMap(async (mergedPages) => {
|
|
37
|
+
filesystem = new MutableVolume(new FileAccess(Volume.fromJSON(mergedPages)), workerData.namespace);
|
|
38
|
+
await pluginApi.$beforeSend(filesystem.asRestricted(), {
|
|
39
|
+
config,
|
|
40
|
+
ignorePages: workerData.ignorePages,
|
|
41
|
+
pageExtensions: workerData.pageExtensions,
|
|
42
|
+
serialiser
|
|
43
|
+
});
|
|
44
|
+
// In the main thread we would freeze the filesystem here, but since we throw it away after sending it to the parent process,
|
|
45
|
+
// we don't bother freezing
|
|
46
|
+
// Turn data into buffer
|
|
47
|
+
return Buffer.from(JSON.stringify({
|
|
48
|
+
pages: filesystem.toJSON(),
|
|
49
|
+
data: config.data,
|
|
50
|
+
symlinks: filesystem.symlinksToJSON()
|
|
51
|
+
}));
|
|
52
|
+
}), tap(() => {
|
|
53
|
+
// Reset filesystem and config memory
|
|
54
|
+
config = null;
|
|
55
|
+
filesystem.reset();
|
|
56
|
+
filesystem = null;
|
|
57
|
+
}))
|
|
58
|
+
.subscribe(async (pagesAndSymlinks) => {
|
|
59
|
+
if (workerData.options.cache !== false) {
|
|
60
|
+
console.info(`[Mosaic] Saving cached filesystem of ${workerData.name}`);
|
|
61
|
+
await fs.promises.writeFile(cachePath, pagesAndSymlinks);
|
|
62
|
+
}
|
|
63
|
+
parentPort.postMessage({
|
|
64
|
+
type: 'message',
|
|
65
|
+
data: pagesAndSymlinks
|
|
66
|
+
},
|
|
67
|
+
/* transferList */ [pagesAndSymlinks.buffer]);
|
|
68
|
+
});
|
|
69
|
+
if (workerData.options.cache !== false) {
|
|
70
|
+
try {
|
|
71
|
+
if (await fs.promises.stat(cachePath)) {
|
|
72
|
+
const data = await fs.promises.readFile(cachePath);
|
|
73
|
+
console.info(`[Mosaic] Restoring cached filesystem for ${workerData.name}`);
|
|
74
|
+
parentPort.postMessage({
|
|
75
|
+
type: 'init',
|
|
76
|
+
data
|
|
77
|
+
},
|
|
78
|
+
/* transferList */ [data.buffer]);
|
|
79
|
+
}
|
|
80
|
+
// Important: Return to avoid sending another init signal on L107
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
// Does not exist
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
parentPort.postMessage({ type: 'init' });
|
|
88
|
+
})();
|
|
89
|
+
// Catch any unhandled errors and re-throw them
|
|
90
|
+
process.once('uncaughtException', e => {
|
|
91
|
+
throw e;
|
|
92
|
+
});
|
|
93
|
+
// async function getPagesWithoutContent(pages: DirectoryJSON, serialiser: Serialiser): Promise<DirectoryJSON> {
|
|
94
|
+
// const pagesWithoutContent = {};
|
|
95
|
+
// for (const fullPath in pages) {
|
|
96
|
+
// const serialisedPage = pages[fullPath];
|
|
97
|
+
// const page = await serialiser.deserialise(fullPath, serialisedPage);
|
|
98
|
+
// page.content = '';
|
|
99
|
+
// pagesWithoutContent[fullPath] = String(await serialiser.serialise(fullPath, page));
|
|
100
|
+
// }
|
|
101
|
+
// return pagesWithoutContent;
|
|
102
|
+
// }
|
|
103
|
+
//# sourceMappingURL=Source.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Source.worker.js","sourceRoot":"","sources":["../../src/worker/Source.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAiB,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAItC,OAAO,UAAU,MAAM,8BAA8B,CAAC;AACtD,OAAO,aAAa,MAAM,iCAAiC,CAAC;AAC5D,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,sBAAsB,MAAM,qCAAqC,CAAC;AAEzE,MAAM,UAAU,GAAmC,iBAAiB,CAAC;AAErE,IAAI,YAAY,EAAE;IA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E,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,gBAAgB;SACvB;QACD,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAC7C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE;QACtC,IAAI;YACF,IAAI,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBACrC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACnD,OAAO,CAAC,IAAI,CAAC,4CAA4C,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC5E,UAAU,CAAC,WAAW,CACpB;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI;iBACL;gBACD,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CACjC,CAAC;aACH;YACD,iEAAiE;YACjE,OAAO;SACR;QAAC,OAAO,CAAC,EAAE;YACV,iBAAiB;SAClB;KACF;IACD,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,EAAE,CAAC;AAEL,+CAA+C;AAC/C,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE;IACpC,MAAM,CAAC,CAAC;AACV,CAAC,CAAC,CAAC;AAEH,gHAAgH;AAChH,oCAAoC;AACpC,oCAAoC;AACpC,8CAA8C;AAC9C,2EAA2E;AAC3E,yBAAyB;AACzB,0FAA0F;AAC1F,MAAM;AACN,gCAAgC;AAChC,IAAI"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isObservable, map } from 'rxjs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { escapeRegExp } from 'lodash-es';
|
|
4
|
+
async function getSourceDefinitionExports(modulePath) {
|
|
5
|
+
const { default: defaultProp } = await import(modulePath);
|
|
6
|
+
const api = 'default' in defaultProp && defaultProp.__esModule
|
|
7
|
+
? defaultProp.default
|
|
8
|
+
: defaultProp;
|
|
9
|
+
if (!api) {
|
|
10
|
+
throw new Error(`Could not resolve source '${modulePath}'.`);
|
|
11
|
+
}
|
|
12
|
+
if (typeof api.create !== 'function') {
|
|
13
|
+
throw new Error(`Source '${modulePath}' does not have a valid \`create\` function.`);
|
|
14
|
+
}
|
|
15
|
+
return api;
|
|
16
|
+
}
|
|
17
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
18
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
19
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
20
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
21
|
+
}
|
|
22
|
+
export default async function createSourceObservable({ modulePath, options, pageExtensions, ignorePages }, serialiser) {
|
|
23
|
+
const api = await getSourceDefinitionExports(modulePath);
|
|
24
|
+
const source$ = api.create(options, { serialiser, pageExtensions });
|
|
25
|
+
if (!isObservable(source$)) {
|
|
26
|
+
throw new Error(`Source at '${modulePath}' did not return an Observable.`);
|
|
27
|
+
}
|
|
28
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
29
|
+
// TODO: Move this formatter
|
|
30
|
+
return source$.pipe(map((pages) => pages.reduce((pagesResult, page) => {
|
|
31
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
32
|
+
console.warn(`File '${page.fullPath}' does not have a matching page file extension, it will be removed from the output.
|
|
33
|
+
|
|
34
|
+
NOTE: Only ${pageExtensions.join(', ')} extensions are supported (as per the value defined in Mosaic Core config \`pageExtensions\`). To add non-page files to the filesystem, start their names with a dot to indicate they are hidden files.`);
|
|
35
|
+
return pagesResult;
|
|
36
|
+
}
|
|
37
|
+
if (!page.fullPath) {
|
|
38
|
+
console.warn(`Page '${page.fullPath}' is missing the \`fullPath\` property. It will be removed from the output.`);
|
|
39
|
+
return pagesResult;
|
|
40
|
+
}
|
|
41
|
+
return pagesResult.concat({
|
|
42
|
+
...page,
|
|
43
|
+
title: page.title || page.fullPath,
|
|
44
|
+
fullPath: page.fullPath.toLowerCase(),
|
|
45
|
+
route: page.route ? page.route.toLowerCase() : page.fullPath.toLowerCase()
|
|
46
|
+
});
|
|
47
|
+
}, [])));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=createSourceObservable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSourceObservable.js","sourceRoot":"","sources":["../../../src/worker/helpers/createSourceObservable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,KAAK,UAAU,0BAA0B,CAAC,UAAU;IAClD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAC5B,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAE3B,MAAM,GAAG,GACP,SAAS,IAAI,WAAW,IAAI,WAAW,CAAC,UAAU;QAChD,CAAC,CAAC,WAAW,CAAC,OAAO;QACrB,CAAC,CAAE,WAAsB,CAAC;IAE9B,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,IAAI,CAAC,CAAC;KAC9D;IAED,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,8CAA8C,CAAC,CAAC;KACtF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,cAAc,CAAC,WAAW,EAAE,cAAc;IACjD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GA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Q,EAAE;YAClB,OAAO,CAAC,IAAI,CACV,SAAS,IAAI,CAAC,QAAQ,6EAA6E,CACpG,CAAC;YACF,OAAO,WAAW,CAAC;SACpB;QAED,OAAO,WAAW,CAAC,MAAM,CAAC;YACxB,GAAG,IAAI;YACP,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ;YAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;SAC3E,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CACP,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jpmorganchase/mosaic-core",
|
|
3
|
+
"version": "0.1.0-beta.10",
|
|
4
|
+
"author": "",
|
|
5
|
+
"description": "Mosaic core file system",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"node": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 16.0.0"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"clean": "rm -fr dist",
|
|
25
|
+
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
|
|
26
|
+
"start": "node --trace-warnings ./dist/example",
|
|
27
|
+
"start:debug": "node --inspect-brk ./dist/example"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git@github.com:jpmorganchase/mosaic.git"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"express": "^4.17.1",
|
|
35
|
+
"cors": "^2.8.5",
|
|
36
|
+
"@types/express": "^4.17.13"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"gray-matter": "^4.0.3",
|
|
40
|
+
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.10",
|
|
41
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.10",
|
|
42
|
+
"md5": "*",
|
|
43
|
+
"unionfs": "^4.4.0",
|
|
44
|
+
"lodash-es": "^4.17.21",
|
|
45
|
+
"fast-glob": "*",
|
|
46
|
+
"memfs": "^3.4.12",
|
|
47
|
+
"rxjs": "^7.5.5"
|
|
48
|
+
}
|
|
49
|
+
}
|