@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,217 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import glob from 'fast-glob';
|
|
3
|
+
import { createFsFromVolume } from 'memfs';
|
|
4
|
+
export default class FileAccess {
|
|
5
|
+
#adapter;
|
|
6
|
+
#hooks = [];
|
|
7
|
+
#rawReadonlyFs;
|
|
8
|
+
#symlinks = {};
|
|
9
|
+
#frozen = false;
|
|
10
|
+
#cachedPages = new Map();
|
|
11
|
+
constructor(filesystemAdapter) {
|
|
12
|
+
this.#adapter = filesystemAdapter;
|
|
13
|
+
}
|
|
14
|
+
async readFile(file) {
|
|
15
|
+
const resolvedPath = await this.#resolvePath(file);
|
|
16
|
+
let result;
|
|
17
|
+
try {
|
|
18
|
+
result = await this.#getFileFromCache(resolvedPath);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new Error(e);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
// return this.#adapter.promises.readFile(resolvedPath);
|
|
25
|
+
}
|
|
26
|
+
async glob(pattern, options) {
|
|
27
|
+
// We need a created filesystem, not a Volume, for glob
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
this.#rawReadonlyFs = this.#rawReadonlyFs || createFsFromVolume(this.#adapter);
|
|
30
|
+
const paths = Array.from(new Set(await Promise.all((await glob(pattern, {
|
|
31
|
+
...options,
|
|
32
|
+
absolute: true,
|
|
33
|
+
fs: this.#rawReadonlyFs
|
|
34
|
+
})).map(filepath => this.#resolvePath(filepath)))));
|
|
35
|
+
return paths;
|
|
36
|
+
}
|
|
37
|
+
$$addReadFileHook(hook) {
|
|
38
|
+
// if (this.#frozen) {
|
|
39
|
+
// throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
40
|
+
// }
|
|
41
|
+
this.#hooks.push(hook);
|
|
42
|
+
}
|
|
43
|
+
readdir(dir, options) {
|
|
44
|
+
return this.#adapter.promises.readdir(dir, options);
|
|
45
|
+
}
|
|
46
|
+
async stat(file, options) {
|
|
47
|
+
return this.#adapter.promises.stat(file, options);
|
|
48
|
+
}
|
|
49
|
+
get $$frozen() {
|
|
50
|
+
return this.#frozen;
|
|
51
|
+
}
|
|
52
|
+
realpath(target, options) {
|
|
53
|
+
return this.#adapter.promises.realpath(target, options);
|
|
54
|
+
}
|
|
55
|
+
async $$symlinksFromJSON(symlinks) {
|
|
56
|
+
this.#symlinks = symlinks;
|
|
57
|
+
if (this.#frozen) {
|
|
58
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
59
|
+
}
|
|
60
|
+
Object.keys(symlinks).forEach(async (alias) => {
|
|
61
|
+
for (const { target, type = 'file' } of symlinks[alias]) {
|
|
62
|
+
// eslint-disable-next-line no-await-in-loop
|
|
63
|
+
if (!(await this.exists(alias))) {
|
|
64
|
+
// eslint-disable-next-line no-await-in-loop
|
|
65
|
+
if (!(await this.exists(path.dirname(alias)))) {
|
|
66
|
+
// TODO: This works... But why are the subdirs not being passed from the child process as `null`s?
|
|
67
|
+
// eslint-disable-next-line no-await-in-loop
|
|
68
|
+
await this.#adapter.promises.mkdir(path.dirname(alias), { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line no-await-in-loop
|
|
71
|
+
await this.#adapter.promises.symlink(target, alias, type);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async unlink(target) {
|
|
77
|
+
if (this.#frozen) {
|
|
78
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
79
|
+
}
|
|
80
|
+
await this.#adapter.promises.unlink(target);
|
|
81
|
+
// If path refers to a symbolic link, then the link is removed without affecting the file or directory to which that link refers.
|
|
82
|
+
this.#cachedPages.delete(target);
|
|
83
|
+
}
|
|
84
|
+
symlink(target, alias, type) {
|
|
85
|
+
if (this.#frozen) {
|
|
86
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
87
|
+
}
|
|
88
|
+
this.#symlinks[alias] = this.#symlinks[alias] || [];
|
|
89
|
+
this.#symlinks[alias].push({ target, type });
|
|
90
|
+
// console.debug('[Mosaic]', target, 'aliased to', alias);
|
|
91
|
+
return this.#adapter.promises.symlink(target, alias, type);
|
|
92
|
+
}
|
|
93
|
+
async writeFile(file, data) {
|
|
94
|
+
if (this.#frozen) {
|
|
95
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
96
|
+
}
|
|
97
|
+
await this.#adapter.promises.writeFile(file, data);
|
|
98
|
+
this.#cachedPages.delete(file);
|
|
99
|
+
// TODO: Do we need?
|
|
100
|
+
this.#cachedPages.delete(await this.#resolvePath(file));
|
|
101
|
+
}
|
|
102
|
+
async mkdir(dir, options) {
|
|
103
|
+
if (this.#frozen) {
|
|
104
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
105
|
+
}
|
|
106
|
+
return this.#adapter.promises.mkdir(dir, options);
|
|
107
|
+
}
|
|
108
|
+
async exists(file) {
|
|
109
|
+
try {
|
|
110
|
+
return !!(await this.#adapter.promises.realpath(file));
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
if (e.code !== 'ENOENT') {
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
toJSON() {
|
|
120
|
+
return this.#adapter.toJSON();
|
|
121
|
+
}
|
|
122
|
+
symlinksToJSON() {
|
|
123
|
+
return this.#symlinks;
|
|
124
|
+
}
|
|
125
|
+
async #resolvePath(file) {
|
|
126
|
+
const realPath = await this.#adapter.promises.realpath(file);
|
|
127
|
+
if (realPath !== file &&
|
|
128
|
+
!(await this.#adapter.promises.stat(realPath, { throwIfNoEntry: true }))) {
|
|
129
|
+
throw new Error(`ENOENT: no such file or directory, stat '${file}'`);
|
|
130
|
+
}
|
|
131
|
+
const stat = await this.#adapter.promises.stat(realPath, { throwIfNoEntry: true });
|
|
132
|
+
// Enable this for /index directories ... but should a filesystem really rewrite URLs like that?
|
|
133
|
+
// The downside is that relative links can break when /index is missing from the end of a URL
|
|
134
|
+
// e.g. if /home/dir is actually /home/dir/index any relative links will be from ./home not ./home/dir
|
|
135
|
+
// if (stat.isDirectory()) {
|
|
136
|
+
// try {
|
|
137
|
+
// const resolved = await this.#resolvePath(path.join(String(realPath), 'index'));
|
|
138
|
+
// return resolved;
|
|
139
|
+
// } catch {}
|
|
140
|
+
// }
|
|
141
|
+
if (!stat.isFile()) {
|
|
142
|
+
return file;
|
|
143
|
+
// throw new Error(`EISDIR: illegal operation on a directory, open '${file}'`);
|
|
144
|
+
}
|
|
145
|
+
return realPath;
|
|
146
|
+
}
|
|
147
|
+
async #getFileFromCache(file) {
|
|
148
|
+
const stat = await this.#adapter.promises.stat(file, { throwIfNoEntry: true });
|
|
149
|
+
if (!stat.isFile()) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
if (await this.#isNonHiddenPageCached(file)) {
|
|
153
|
+
const cachedItem = this.#cachedPages.get(file);
|
|
154
|
+
return cachedItem;
|
|
155
|
+
}
|
|
156
|
+
// Bit of parallel programming needed here, to avoid 2+ requests triggering a file load at the same time and making a race condition
|
|
157
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
158
|
+
const loadPagePromise = new Promise(async (resolve) => {
|
|
159
|
+
const rawFile = await this.#adapter.promises.readFile(file);
|
|
160
|
+
// if (!this.#pageTest(file)) {
|
|
161
|
+
// return resolve(rawFile);
|
|
162
|
+
// }
|
|
163
|
+
let fileData = rawFile;
|
|
164
|
+
for (const hook of this.#hooks) {
|
|
165
|
+
// eslint-disable-next-line no-await-in-loop
|
|
166
|
+
fileData = await hook(file, fileData);
|
|
167
|
+
}
|
|
168
|
+
resolve(fileData);
|
|
169
|
+
});
|
|
170
|
+
this.#cachedPages.set(file, loadPagePromise);
|
|
171
|
+
const result = await loadPagePromise;
|
|
172
|
+
if (this.#frozen) {
|
|
173
|
+
this.#cachedPages.set(file, result);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Clear the `currentlyResolving` entry
|
|
177
|
+
this.#cachedPages.delete(file);
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
// this.#cachedPages.add(file);
|
|
181
|
+
// return this.#adapter.promises.writeFile(file, JSON.stringify(currentPage));
|
|
182
|
+
}
|
|
183
|
+
async #isNonHiddenPageCached(fileArg) {
|
|
184
|
+
const file = await this.#adapter.promises.realpath(fileArg);
|
|
185
|
+
return this.#cachedPages.has(file);
|
|
186
|
+
}
|
|
187
|
+
$$freeze() {
|
|
188
|
+
if (this.#frozen) {
|
|
189
|
+
throw new Error('This file system has already been frozen.');
|
|
190
|
+
}
|
|
191
|
+
this.#frozen = true;
|
|
192
|
+
}
|
|
193
|
+
$$unfreeze() {
|
|
194
|
+
if (!this.#frozen) {
|
|
195
|
+
throw new Error('This file system is not frozen.');
|
|
196
|
+
}
|
|
197
|
+
this.#frozen = false;
|
|
198
|
+
}
|
|
199
|
+
$$clearCache() {
|
|
200
|
+
this.#cachedPages.clear();
|
|
201
|
+
}
|
|
202
|
+
async $$reset() {
|
|
203
|
+
this.#rawReadonlyFs = null;
|
|
204
|
+
this.#frozen = false;
|
|
205
|
+
this.#symlinks = {};
|
|
206
|
+
this.#hooks = [];
|
|
207
|
+
this.#adapter.reset();
|
|
208
|
+
this.#cachedPages.clear();
|
|
209
|
+
}
|
|
210
|
+
fromJSON(json) {
|
|
211
|
+
if (this.#frozen) {
|
|
212
|
+
throw new Error('This file system has been frozen. Mutations are not allowed.');
|
|
213
|
+
}
|
|
214
|
+
this.#adapter.fromJSON(json);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=FileAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileAccess.js","sourceRoot":"","sources":["../../src/filesystems/FileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAsD,MAAM,OAAO,CAAC;AAI/F,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,QAAQ,CAAU;IAClB,MAAM,GAAsE,EAAE,CAAC;IAC/E,cAAc,CAAC;IACf,SAAS,GAA0D,EAAE,CAAC;IACtE,OAAO,GAAG,KAAK,CAAC;IAChB,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;IAEzB,YAAY,iBAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAI;QACjB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnD,IAA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|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IVolumeImmutable } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
export default class ImmutableVolume implements IVolumeImmutable {
|
|
3
|
+
#private;
|
|
4
|
+
namespace: string;
|
|
5
|
+
constructor(vfs: any, namespace: any);
|
|
6
|
+
promises: IVolumeImmutable['promises'];
|
|
7
|
+
get frozen(): boolean;
|
|
8
|
+
symlinksToJSON(): {
|
|
9
|
+
[key: string]: {
|
|
10
|
+
target: string;
|
|
11
|
+
type: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
toJSON(): import("memfs").DirectoryJSON;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class ImmutableVolume {
|
|
2
|
+
#vfs;
|
|
3
|
+
namespace;
|
|
4
|
+
constructor(vfs, namespace) {
|
|
5
|
+
this.#vfs = vfs;
|
|
6
|
+
this.namespace = namespace;
|
|
7
|
+
}
|
|
8
|
+
promises = {
|
|
9
|
+
readFile: file => this.#vfs.readFile(file),
|
|
10
|
+
readdir: (dir, options) => this.#vfs.readdir(dir, options),
|
|
11
|
+
stat: (file, options) => this.#vfs.stat(file, options),
|
|
12
|
+
realpath: (target, options) => this.#vfs.realpath(target, options),
|
|
13
|
+
exists: file => this.#vfs.exists(file),
|
|
14
|
+
glob: (pattern, options) => this.#vfs.glob(pattern, options)
|
|
15
|
+
};
|
|
16
|
+
get frozen() {
|
|
17
|
+
return this.#vfs.$$frozen;
|
|
18
|
+
}
|
|
19
|
+
symlinksToJSON() {
|
|
20
|
+
return this.#vfs.symlinksToJSON();
|
|
21
|
+
}
|
|
22
|
+
toJSON() {
|
|
23
|
+
return this.#vfs.toJSON();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ImmutableVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImmutableVolume.js","sourceRoot":"","sources":["../../src/filesystems/ImmutableVolume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|
+
import type { IVolumeMutable } from '@jpmorganchase/mosaic-types';
|
|
3
|
+
import FileSystemRestricted from './RestrictedVolume.js';
|
|
4
|
+
export default class MutableVolume extends FileSystemRestricted implements IVolumeMutable {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(vfs: any, namespace: any);
|
|
7
|
+
asRestricted(): FileSystemRestricted;
|
|
8
|
+
freeze(): void;
|
|
9
|
+
clearCache(): void;
|
|
10
|
+
unfreeze(): void;
|
|
11
|
+
__internal_do_not_use_addReadFileHook(hook: any): void;
|
|
12
|
+
symlinksToJSON(): {
|
|
13
|
+
[key: string]: {
|
|
14
|
+
target: string;
|
|
15
|
+
type: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
symlinksFromJSON(json: {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
target: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
}): Promise<any>;
|
|
24
|
+
fromJSON(json: DirectoryJSON): void;
|
|
25
|
+
reset(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import FileSystemRestricted from './RestrictedVolume.js';
|
|
2
|
+
export default class MutableVolume extends FileSystemRestricted {
|
|
3
|
+
#vfs;
|
|
4
|
+
constructor(vfs, namespace) {
|
|
5
|
+
super(vfs, namespace);
|
|
6
|
+
this.#vfs = vfs;
|
|
7
|
+
}
|
|
8
|
+
asRestricted() {
|
|
9
|
+
return new FileSystemRestricted(this.#vfs, super.namespace);
|
|
10
|
+
}
|
|
11
|
+
freeze() {
|
|
12
|
+
this.#vfs.$$freeze();
|
|
13
|
+
}
|
|
14
|
+
clearCache() {
|
|
15
|
+
this.#vfs.$$clearCache();
|
|
16
|
+
}
|
|
17
|
+
unfreeze() {
|
|
18
|
+
this.#vfs.$$unfreeze();
|
|
19
|
+
}
|
|
20
|
+
__internal_do_not_use_addReadFileHook(hook) {
|
|
21
|
+
this.#vfs.$$addReadFileHook(hook);
|
|
22
|
+
}
|
|
23
|
+
symlinksToJSON() {
|
|
24
|
+
return this.#vfs.symlinksToJSON();
|
|
25
|
+
}
|
|
26
|
+
async symlinksFromJSON(json) {
|
|
27
|
+
let result;
|
|
28
|
+
try {
|
|
29
|
+
result = await this.#vfs.$$symlinksFromJSON(json);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
throw new Error(e);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
fromJSON(json) {
|
|
37
|
+
return this.#vfs.fromJSON(json);
|
|
38
|
+
}
|
|
39
|
+
reset() {
|
|
40
|
+
this.#vfs.$$reset();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=MutableVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MutableVolume.js","sourceRoot":"","sources":["../../src/filesystems/MutableVolume.ts"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,oBAAoB;IAC7D,IAAI,CAAc;IAElB,YAAY,GAAG,EAAE,SAAS;QACxB,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC;IAED,qCAAqC,CAAC,IAAI;QACxC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAA2D;QAChF,IAAI,MAAM,CAAC;QACX,IAAI;YACF,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACnD;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,IAAmB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IVolumePartiallyMutable } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
import ImmutableFileSystem from './ImmutableVolume.js';
|
|
3
|
+
/**
|
|
4
|
+
* Restricted filesystems can be written to, but cannot be frozen, updated or reset
|
|
5
|
+
*/
|
|
6
|
+
declare class RestrictedVolume extends ImmutableFileSystem implements IVolumePartiallyMutable {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(vfs: any, namespace: any);
|
|
9
|
+
promises: any;
|
|
10
|
+
/**
|
|
11
|
+
* Do not use this method on restricted volumes, as it may disrupt the read/cache flow of files.
|
|
12
|
+
*/
|
|
13
|
+
__internal_do_not_use_addReadFileHook(readFileHook: any): void;
|
|
14
|
+
symlinksToJSON(): {
|
|
15
|
+
[key: string]: {
|
|
16
|
+
target: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
toJSON(): import("memfs").DirectoryJSON;
|
|
21
|
+
get frozen(): boolean;
|
|
22
|
+
asReadOnly(): ImmutableFileSystem;
|
|
23
|
+
}
|
|
24
|
+
export default RestrictedVolume;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { create } from 'lodash-es';
|
|
2
|
+
import ImmutableFileSystem from './ImmutableVolume.js';
|
|
3
|
+
/**
|
|
4
|
+
* Restricted filesystems can be written to, but cannot be frozen, updated or reset
|
|
5
|
+
*/
|
|
6
|
+
class RestrictedVolume extends ImmutableFileSystem {
|
|
7
|
+
#vfs;
|
|
8
|
+
constructor(vfs, namespace) {
|
|
9
|
+
super(vfs, namespace);
|
|
10
|
+
this.#vfs = vfs;
|
|
11
|
+
}
|
|
12
|
+
promises = create(this.promises, {
|
|
13
|
+
unlink: target => this.#vfs.unlink(target),
|
|
14
|
+
symlink: (target, alias, type) => this.#vfs.symlink(target, alias, type),
|
|
15
|
+
writeFile: (file, data) => this.#vfs.writeFile(file, data),
|
|
16
|
+
mkdir: (dir, options) => this.#vfs.mkdir(dir, options)
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Do not use this method on restricted volumes, as it may disrupt the read/cache flow of files.
|
|
20
|
+
*/
|
|
21
|
+
__internal_do_not_use_addReadFileHook(readFileHook) {
|
|
22
|
+
return this.#vfs.$$addReadFileHook(readFileHook);
|
|
23
|
+
}
|
|
24
|
+
symlinksToJSON() {
|
|
25
|
+
return this.#vfs.symlinksToJSON();
|
|
26
|
+
}
|
|
27
|
+
toJSON() {
|
|
28
|
+
return this.#vfs.toJSON();
|
|
29
|
+
}
|
|
30
|
+
get frozen() {
|
|
31
|
+
return this.#vfs.$$frozen;
|
|
32
|
+
}
|
|
33
|
+
asReadOnly() {
|
|
34
|
+
return new ImmutableFileSystem(this.#vfs, super.namespace);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default RestrictedVolume;
|
|
38
|
+
//# sourceMappingURL=RestrictedVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestrictedVolume.js","sourceRoot":"","sources":["../../src/filesystems/RestrictedVolume.ts"],"names":[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BAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import FileAccess from './FileAccess.js';
|
|
2
|
+
export default class UnionFileAccess extends FileAccess {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(ufs: any);
|
|
5
|
+
glob(pattern: any, options: any): Promise<any[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Scopes a filesystem to specific namespaces
|
|
8
|
+
* @param {string[]} namespaces Array of namespaces to limit this filesystem to
|
|
9
|
+
* @returns A new immutable union filesystem
|
|
10
|
+
*/
|
|
11
|
+
scope(namespaces: string[]): UnionFileAccess;
|
|
12
|
+
/**
|
|
13
|
+
* Reads 1 or more files (if multiple files exist at the same location within the union filesystem)
|
|
14
|
+
* @param file Path
|
|
15
|
+
* @param options.includeConflicts If multiple files exist at the same location in the filesystem, return them all as an array
|
|
16
|
+
* @returns Promise<TDataOut[]>
|
|
17
|
+
*/
|
|
18
|
+
readFile(file: any, options?: {
|
|
19
|
+
includeConflicts?: boolean;
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
symlinksToJSON(): {};
|
|
22
|
+
toJSON(): {};
|
|
23
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Union } from 'unionfs';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import FileAccess from './FileAccess.js';
|
|
4
|
+
export default class UnionFileAccess extends FileAccess {
|
|
5
|
+
#ufs;
|
|
6
|
+
constructor(ufs) {
|
|
7
|
+
super(ufs);
|
|
8
|
+
this.#ufs = ufs;
|
|
9
|
+
}
|
|
10
|
+
// We have to override this here, so we can hand-hold the glob and make sure it fires on all filesystems
|
|
11
|
+
async glob(pattern, options) {
|
|
12
|
+
return this.#ufs.fss.reduce(async (globResults, childFs) => [
|
|
13
|
+
...(await globResults),
|
|
14
|
+
...(await childFs.promises.glob(pattern, options))
|
|
15
|
+
], Promise.resolve([]));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Scopes a filesystem to specific namespaces
|
|
19
|
+
* @param {string[]} namespaces Array of namespaces to limit this filesystem to
|
|
20
|
+
* @returns A new immutable union filesystem
|
|
21
|
+
*/
|
|
22
|
+
scope(namespaces) {
|
|
23
|
+
const scopedUnion = new Union();
|
|
24
|
+
const matchingNamespaceFSs = this.#ufs.fss.filter(fss => namespaces.includes(fss.namespace));
|
|
25
|
+
if (!matchingNamespaceFSs.length) {
|
|
26
|
+
throw new Error(`Scoping failed. No matching filesystems for ${namespaces
|
|
27
|
+
.map(namespace => `"${namespace}"`)
|
|
28
|
+
.join(', ')}.`);
|
|
29
|
+
}
|
|
30
|
+
matchingNamespaceFSs.forEach(fss => scopedUnion.use(fss));
|
|
31
|
+
return new UnionFileAccess(scopedUnion);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reads 1 or more files (if multiple files exist at the same location within the union filesystem)
|
|
35
|
+
* @param file Path
|
|
36
|
+
* @param options.includeConflicts If multiple files exist at the same location in the filesystem, return them all as an array
|
|
37
|
+
* @returns Promise<TDataOut[]>
|
|
38
|
+
*/
|
|
39
|
+
readFile(file, options) {
|
|
40
|
+
if (!options?.includeConflicts) {
|
|
41
|
+
return super.readFile(file);
|
|
42
|
+
}
|
|
43
|
+
return this.#ufs.fss.reduce(async (fileResults, childFs) => [
|
|
44
|
+
...(await fileResults),
|
|
45
|
+
...((await childFs.promises.exists(file)) ? [await childFs.promises.readFile(file)] : [])
|
|
46
|
+
], Promise.resolve([]));
|
|
47
|
+
}
|
|
48
|
+
symlinksToJSON() {
|
|
49
|
+
return this.#ufs.fss.reduce((merged, filesystem) => merge(merged, filesystem.symlinksToJSON()), {});
|
|
50
|
+
}
|
|
51
|
+
toJSON() {
|
|
52
|
+
return this.#ufs.fss.reduce((merged, filesystem) => ({ ...merged, ...filesystem.toJSON() }), {});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=UnionFileAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnionFileAccess.js","sourceRoot":"","sources":["../../src/filesystems/UnionFileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IACrD,IAAI,CAAuC;IAE3C,YAAY,GAAG;QACb,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IACD,wGAAwG;IACxG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CACzB,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;YAC9B,GAAG,CAAC,MAAM,WAAW,CAAC;YACtB,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACnD,EACD,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CACpB,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,UAAoB;QACxB,MAAM,WAAW,GAAyC,IAAI,KAAK,EAElE,CAAC;QACF,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAE7F,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,+CAA+C,UAAU;iBACtD,GAAG,CAAC,SAAS,CAAC,EAAE,C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H,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IUnionVolume } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
import MutableVolume from './MutableVolume.js';
|
|
3
|
+
export default class UnionVolume extends MutableVolume implements IUnionVolume {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(vfs: any, namespace: any);
|
|
6
|
+
promises: any;
|
|
7
|
+
scope(namespaces: string[]): UnionVolume;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { create } from 'lodash-es';
|
|
2
|
+
import MutableVolume from './MutableVolume.js';
|
|
3
|
+
export default class UnionVolume extends MutableVolume {
|
|
4
|
+
#vfs;
|
|
5
|
+
constructor(vfs, namespace) {
|
|
6
|
+
super(vfs, namespace);
|
|
7
|
+
this.#vfs = vfs;
|
|
8
|
+
}
|
|
9
|
+
promises = create(this.promises, {
|
|
10
|
+
readFile: (file, options) => {
|
|
11
|
+
if (options?.includeConflicts) {
|
|
12
|
+
return this.#vfs.readFile(file, options);
|
|
13
|
+
}
|
|
14
|
+
return this.#vfs.readFile(file);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
scope(namespaces) {
|
|
18
|
+
return new UnionVolume(this.#vfs.scope(namespaces), super.namespace);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=UnionVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnionVolume.js","sourceRoot":"","sources":["../../src/filesystems/UnionVolume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKnC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,aAAa;IACpD,IAAI,CAAkB;IAEtB,YAAY,GAAG,EAAE,SAAS;QACxB,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;QAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YAC1B,IAAI,OAAO,EAAE,gBAAgB,EAAE;gBAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAwB,CAAC;aACjE;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAsB,CAAC;QACvD,CAAC;KACF,CAAC,CAAC;IAEH,KAAK,CAAC,UAAoB;QACxB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { merge } from 'lodash-es';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export default function createConfig(initialData) {
|
|
4
|
+
let data = {
|
|
5
|
+
refs: {},
|
|
6
|
+
globalRefs: {},
|
|
7
|
+
aliases: {},
|
|
8
|
+
...initialData
|
|
9
|
+
};
|
|
10
|
+
const configReadOnly = {
|
|
11
|
+
get data() {
|
|
12
|
+
return Object.freeze({ ...data });
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
asReadOnly() {
|
|
17
|
+
return configReadOnly;
|
|
18
|
+
},
|
|
19
|
+
setTags(fullPath, tags) {
|
|
20
|
+
data.aliases[fullPath] = new Set(data.aliases[fullPath] || []);
|
|
21
|
+
tags.forEach(tag => data.aliases[fullPath].add(path.join('/.tags', tag, fullPath)));
|
|
22
|
+
},
|
|
23
|
+
setGlobalRef(targetPath, targetPropPath, refValue) {
|
|
24
|
+
data.globalRefs[targetPath] = data.globalRefs[targetPath] || [];
|
|
25
|
+
data.globalRefs[targetPath].push({
|
|
26
|
+
$$path: targetPropPath,
|
|
27
|
+
$$value: refValue
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
setRef(targetPath, targetPropPath, refValue) {
|
|
31
|
+
data.refs[targetPath] = data.refs[targetPath] || [];
|
|
32
|
+
data.refs[targetPath].push({
|
|
33
|
+
$$path: targetPropPath,
|
|
34
|
+
$$value: refValue
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
setAliases(fullPath, aliases) {
|
|
38
|
+
data.aliases[fullPath] = new Set(data.aliases[fullPath] || []);
|
|
39
|
+
aliases.forEach(alias => data.aliases[fullPath].add(alias));
|
|
40
|
+
},
|
|
41
|
+
setData(value, overwrite = false) {
|
|
42
|
+
if (overwrite) {
|
|
43
|
+
data = value;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
merge(data, value);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
get data() {
|
|
50
|
+
return configReadOnly.data;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=createConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createConfig.js","sourceRoot":"","sources":["../../src/helpers/createConfig.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,YAAY,CAAe,WAAwB;IACzE,IAAI,IAAI,GAIJ;QACF,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,EAAE;QACX,GAAG,WAAW;KACf,CAAC;IAEF,MAAM,cAAc,GAAG;QACrB,IAAI,IAAI;YACN,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;KACkB,CAAC;IAEtB,OAAO;QACL,UAAU;YACR,OAAO,cAAc,CAAC;QACxB,CAAC;QACD,OAAO,CAAC,QA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;QAC9D,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK;YAC9B,IAAI,SAAS,EAAE;gBACb,IAAI,GAAG,KAAK,CAAC;aACd;iBAAM;gBACL,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACpB;QACH,CAAC;QACD,IAAI,IAAI;YACN,OAAO,cAAc,CAAC,IAAI,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { Worker } from 'node:worker_threads';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
export default function from(workerData) {
|
|
6
|
+
return new Observable(observer => {
|
|
7
|
+
const worker = new Worker(require.resolve('../worker/Source.worker'), {
|
|
8
|
+
workerData
|
|
9
|
+
});
|
|
10
|
+
worker.on('message', message => observer.next(message));
|
|
11
|
+
worker.once('error', error => observer.error(error));
|
|
12
|
+
worker.once('exit', code => {
|
|
13
|
+
if (code !== 0) {
|
|
14
|
+
observer.error(new Error(`mosaic source stopped with exit code ${code}`));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
observer.complete();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return () => {
|
|
21
|
+
worker.terminate();
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ObservableWorker.js.map
|