@jpmorganchase/mosaic-types 0.1.0-beta.3

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.
@@ -0,0 +1,2 @@
1
+ @jpmorganchase/mosaic-types:build: cache hit, replaying output 9084cbc397462f27
2
+ @jpmorganchase/mosaic-types:build: $ tsc
@@ -0,0 +1,2 @@
1
+ @jpmorganchase/mosaic-types:clean: cache hit, replaying output cf8c2b7775336107
2
+ @jpmorganchase/mosaic-types:clean: $ rm -fr dist
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # @jpmorganchase/mosaic-types
2
+
3
+ ## 0.1.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 457df5e: switch to public package
8
+
9
+ ## 0.1.0-beta.2
10
+
11
+ ### Patch Changes
12
+
13
+ - e1bbbe7: Initial release of Mosaic Core file-system.
14
+
15
+ Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
16
+
17
+ - 4b2bc51: pipped to 0.1.0-beta.1 for publishing to NPM
18
+
19
+ ## 0.1.0
20
+
21
+ ### Patch Changes
22
+
23
+ - e1bbbe7: Initial release of Mosaic Core file-system.
24
+
25
+ Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@jpmorganchase/mosaic-types",
3
+ "version": "0.1.0-beta.3",
4
+ "author": "",
5
+ "description": "",
6
+ "license": "Apache-2.0",
7
+ "types": "./dist/**",
8
+ "engines": {
9
+ "node": ">= 12.0.0"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git@github.com:jpmorganchase/mosaic.git"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "clean": "rm -fr dist"
18
+ },
19
+ "devDependencies": {
20
+ "rxjs": "^7.5.5"
21
+ }
22
+ }
@@ -0,0 +1,42 @@
1
+ import type {
2
+ DirectoryJSON,
3
+ IRealpathOptions,
4
+ IMkdirOptions,
5
+ IReaddirOptions,
6
+ TData,
7
+ TMode
8
+ } from 'memfs/lib/volume';
9
+ import type { TDataOut } from 'memfs/lib/encoding';
10
+ import type Dirent from 'memfs/lib/Dirent';
11
+ import type Stats from 'memfs/lib/Stats';
12
+ import type { TStatNumber } from 'memfs/lib/Stats';
13
+ import type { IStatOptions } from 'memfs/lib/volume';
14
+ import type { PathLike, symlink } from 'fs';
15
+ import type Page from './Page';
16
+ import type { Options, Pattern, Entry } from 'fast-glob';
17
+
18
+ /**
19
+ * This is the core underlying filesystem, which directly interfaces with a memfs Volume to mutate the filesystem
20
+ */
21
+ export default interface IFileAccess {
22
+ glob(pattern: Pattern, options?: Omit<Options, 'absolute' | 'fs'>): Promise<string[] | Entry[]>;
23
+ mkdir(dir: PathLike, options?: TMode | IMkdirOptions): Promise<void>;
24
+ readdir(dir: PathLike, options?: string | IReaddirOptions): Promise<TDataOut[] | Dirent[]>;
25
+ readFile(file: PathLike): Promise<TDataOut>;
26
+ realpath(target: string, options?: string | IRealpathOptions): Promise<TDataOut>;
27
+ stat(file: PathLike, options?: IStatOptions): Promise<Stats<TStatNumber>>;
28
+ unlink(target: PathLike): Promise<void>;
29
+ symlink(target: PathLike, alias: PathLike, type?: symlink.Type): Promise<void>;
30
+ writeFile(file: PathLike, data: TData): Promise<void>;
31
+ toJSON(): DirectoryJSON;
32
+ fromJSON(json: DirectoryJSON): void;
33
+ exists(file: PathLike): Promise<boolean>;
34
+ $$reset(): void;
35
+ $$freeze(): void;
36
+ get $$frozen(): boolean;
37
+ $$unfreeze(): void;
38
+ $$clearCache(): void;
39
+ $$symlinksFromJSON(page: { [key: string]: { target: string; type: string }[] }): Promise<void>;
40
+ symlinksToJSON(): { [key: string]: { target: string; type: string }[] };
41
+ $$addReadFileHook(hook: (result: Page, filepath: PathLike) => Promise<Page>): void;
42
+ }
package/src/Meta.ts ADDED
@@ -0,0 +1,9 @@
1
+ type Meta<AdditionalProps> = {
2
+ title?: string;
3
+ // `route` is a fullPath that points to the page, similar to how `page`.`fullPath` does - but this may be an alias instead,
4
+ // so it can be used for presenting more aesthetic URLs etc when used as a site href
5
+ route: string;
6
+ lastModified: Date;
7
+ } & Record<string, unknown> &
8
+ AdditionalProps;
9
+ export default Meta;
@@ -0,0 +1,55 @@
1
+ type MutableData<T = {}> = ImmutableData<T> & {
2
+ /**
3
+ * Set arbitrary data onto the config object. This value will persist across plugins and
4
+ * also be sent to the parent process when it executes plugins there as well.
5
+ * Values can be retrieved from `data`.
6
+ * This data is one-way, it can only be set/mutated in the child process lifecycle stages
7
+ * This will be reset everytime the relevant source receives new pages
8
+ * @param data Data to MERGE into the existing blob
9
+ */
10
+ setData(data: Partial<T>, overwrite?: boolean): void;
11
+ /**
12
+ * Helper function for declaring new aliases that will be applied by the AliasPlugin.
13
+ * Values can be retrieved from `data.aliases`
14
+ * This will be reset everytime the relevant source receives new pages
15
+ * @param fullPath The file/fullPath the alias will point to
16
+ * @param aliases Array of aliases to use when pointing to this page
17
+ */
18
+ setAliases(targetPath: string, aliases: string[]): void;
19
+ /**
20
+ * Helper function for declaring new tags (which are basically aliases to /.tags) that will be applied by the AliasPlugin.
21
+ * Values can be retrieved from `data.aliases`
22
+ * This will be reset everytime the relevant source receives new pages
23
+ * @param fullPath The file/fullPath the alias will point to
24
+ * @param tags Array of tag names to use when pointing to this page
25
+ */
26
+ setTags(targetPath: string, tags: string[]): void;
27
+ /**
28
+ * Helper function for declaring new refs that will be applied by the RefPlugin
29
+ * This will be reset everytime the relevant source receives new pages
30
+ * Values can be retrieved from `data.refs`
31
+ * @param targetPath The file/fullPath to write the ref to
32
+ * @param targetPropPath The path to the property where the ref will be applied
33
+ * @param refValue The value of the ref (can be a wildcard)
34
+ */
35
+ setRef(targetFilepath: string, targetPropPath: string | string[], refValue: string): void;
36
+ /**
37
+ * Same as `setRef`, but do not pre-resolve this ref - wait until the file is read and use the global filesystem for it
38
+ * @param targetPath The file/fullPath to write the ref to
39
+ * @param targetPropPath The path to the property where the ref will be applied
40
+ * @param refValue The value of the ref (can be a wildcard)
41
+ */
42
+ setGlobalRef(targetFilepath: string, targetPropPath: string | string[], refValue: string): void;
43
+ /**
44
+ * This object, but without the mutation methods like `setAliases`, `setData` etc
45
+ */
46
+ asReadOnly(): ImmutableData<T>;
47
+ };
48
+
49
+ export type ImmutableData<T = {}> = {
50
+ readonly data: Readonly<
51
+ T & { readonly refs: string[]; readonly aliases: Set<{ $$path: string[]; $$value: string }> }
52
+ >;
53
+ };
54
+
55
+ export default MutableData;
package/src/Page.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `Page` is a type, which at a minimum has a `fullPath`, but can also contain metadata and `content`
3
+ */
4
+ type Page<AdditionalProps = {}> = {
5
+ fullPath: string;
6
+ title?: string;
7
+ /**
8
+ * Friendly fullPaths are the shortest possible paths that will point to a page.
9
+ * They are useful for creating more user-friendly links on pages, rather than using a full filesystem path.
10
+ * They originally start as the same as `fullPath`, but can be modified by plugins whenever they make a change to how a page resolves.
11
+ * e.g. The `PagesWithoutFileExtPlugin` modifies the friendly fullPath after it creates aliases for every page (to allow
12
+ * them to be referenced without a file extension). Another example would be a plugin that allows `/index` to be
13
+ * automatically added if a fullPath points to a directory -- the `route` could then be modified by that
14
+ * plugin to remove `/index`
15
+ */
16
+ route?: string;
17
+ lastModified?: Date;
18
+ type?: string;
19
+ content?: string;
20
+ } & Record<string, unknown> &
21
+ AdditionalProps;
22
+
23
+ export default Page;
package/src/Plugin.ts ADDED
@@ -0,0 +1,112 @@
1
+ import type Page from './Page';
2
+ import type MutableData from './MutableData';
3
+ import type PluginModuleDefinition from './PluginModuleDefinition';
4
+ import type { ImmutableData } from './MutableData';
5
+ import type { IUnionVolume, IVolumeImmutable, IVolumeMutable, IVolumePartiallyMutable } from './Volume';
6
+ import type Serialiser from './Serialiser';
7
+
8
+ export type LoadedPlugin = Partial<Plugin> & PluginModuleDefinition;
9
+
10
+ /**
11
+ * Plugins are lifecycle-based hooks that are called on every source at different stages.
12
+ * Consumers will never need to invoke a lifecycle method; but for technical clarity - when a lifecycle method is called,
13
+ * it will trigger `pluginRunner` which executes it on every source automatically.
14
+ */
15
+ type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData = ConfigData> = {
16
+ /**
17
+ * Plugin lifecycle method that triggers inside child processes.
18
+ * The first lifecycle hook to trigger after receiving pages from a source. The pages can safely be mutated and will be reflected in the final
19
+ * filesystem that gets generated.
20
+ * @param pages Array of pages from the source
21
+ * @param param.serialiser A matching `Serialiser` for serialising/deserialising pages when reading/writing to the filesystem
22
+ * @param param.config A mutable object for sharing data with other lifecycle phases of all plugins for this source (including in the main thread) in this plugin
23
+ * @param options The options passed in when declaring the plugin
24
+ * @returns {Promise<Page[]>} Must re-return an array of `Page` objects, modified or not
25
+ */
26
+ $afterSource?(
27
+ pages: Page[],
28
+ {}: {
29
+ serialiser: Serialiser;
30
+ config: MutableData<ConfigData>;
31
+ pageExtensions: string[];
32
+ ignorePages: string[];
33
+ },
34
+ options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions
35
+ ): Promise<Page[]>;
36
+ /**
37
+ * Plugin lifecycle method that triggers inside child processes.
38
+ * Calls after a filesystem has been built up from the source pages.
39
+ * @param mutableFilesystem Mutable virtual filesystem instance with all of this source's pages inside (and symlinks applied)
40
+ * @param param.serialiser A matching `Serialiser` for serialising/deserialising pages when reading/writing to the filesystem
41
+ * @param param.config A mutable object for sharing data with other lifecycle phases of all plugins for this source (including in the main thread) in this plugin
42
+ * @param options The options passed in when declaring the plugin
43
+ * @returns {void} No return expected
44
+ */
45
+ $beforeSend?(
46
+ mutableFilesystem: IVolumePartiallyMutable,
47
+ {}: {
48
+ serialiser: Serialiser;
49
+ pageExtensions: string[];
50
+ ignorePages: string[];
51
+ config: MutableData<ConfigData>;
52
+ },
53
+ options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions
54
+ ): Promise<void>;
55
+ /**
56
+ * Plugin lifecycle method that triggers inside the main process.
57
+ * Calls after the filesystem and symlinks have been reconstructed due to a change to the current source. This happens in the main thread.
58
+ * Pages will NOT be cached when read at this stage, to allow for reading content and writing a new copy of it without the cached version taking effect.
59
+ * This method is safe to use with lazy loading, as the filesystem should return the full page when read.
60
+ * NOTE: Plugin methods that trigger inside the parent process should be async and highly optimised to avoid holding up the main thread.
61
+ * You should also be mindful of race conditions when reading / writing to the global filesystem from this method - as other plugins may
62
+ * also have a read copy of the same file and it could end up out of sync.
63
+ * @param mutableFilesystem Mutable filesystem instance with all of this source's pages inside (and symlinks re-applied)
64
+ * @param param.serialiser A matching `Serialiser` for serialising/deserialising pages when reading/writing to the filesystem
65
+ * @param param.config An immutable object for reading data from other lifecycle phases of all plugins for this source in the child process for this plugin. Shared only with this source.
66
+ * @param param.globalConfig An immutable object for reading data from other lifecycle phases of all plugins. Shared across all sources.
67
+ * @param param.sharedFilesystem Mutable filesystem instance independent of any sources. Useful for global pages, like sitemaps
68
+ * @param param.globalFilesystem Immutable union filesystem instance with all source's pages (and symlinks applied)
69
+ * @param options The options passed in when declaring the plugin
70
+ * @returns {void} No return expected
71
+ */
72
+ afterUpdate?(
73
+ mutableFilesystem: IVolumePartiallyMutable,
74
+ {}: {
75
+ serialiser: Serialiser;
76
+ config: ImmutableData<ConfigData>;
77
+ globalFilesystem: IUnionVolume;
78
+ sharedFilesystem: IVolumeMutable;
79
+ globalConfig: ImmutableData<GlobalConfigData>;
80
+ pageExtensions: string[];
81
+ ignorePages: string[];
82
+ },
83
+ options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions
84
+ ): Promise<void>;
85
+ /**
86
+ * Plugin lifecycle method that triggers inside the main process everytime ANY source emits new pages.
87
+ * This method should return a boolean that will indicate if this source should clear page caches.
88
+ * This method calls whenever another source (not this one) has changed.
89
+ * Returning `undefined`, false or no value, will result in the cache to be retained
90
+ * @param updatedSourceFilesystem Immutable filesystem for the source that changed
91
+ * @param param.config An immutable object for reading data from other lifecycle phases of all plugins for this source in the child process for this plugin
92
+ * @param param.serialiser A matching `Serialiser` for serialising/deserialising pages when reading/writing to the filesystem
93
+ * @param param.globalFilesystem Immutable union filesystem instance with all source's pages (and symlinks applied)
94
+ * @param options The options passed in when declaring the plugin
95
+ * @returns {Promise<boolean>} A boolean indicating whether to clear the cache for this source
96
+ */
97
+ shouldClearCache?(
98
+ updatedSourceFilesystem: IVolumeImmutable,
99
+ {}: {
100
+ serialiser: Serialiser;
101
+ config: ImmutableData<ConfigData>;
102
+ globalFilesystem: IUnionVolume;
103
+ pageExtensions: string[];
104
+ ignorePages: string[];
105
+ },
106
+ options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions
107
+ ): Promise<boolean>;
108
+ };
109
+
110
+ export type LifecycleMethod = keyof Plugin;
111
+
112
+ export default Plugin;
@@ -0,0 +1,19 @@
1
+ export default interface PluginModuleDefinition {
2
+ /**
3
+ * Options to pass to the plugin lifecycle methods.
4
+ */
5
+ options: Record<string, unknown>;
6
+ /**
7
+ * The importance of this plugin. This highest number plugin will be run first
8
+ */
9
+ priority?: number;
10
+ /**
11
+ * Exclude this plugin when running `mosaic build`
12
+ */
13
+ runTimeOnly?: boolean;
14
+ /**
15
+ * Path to the JS file for this plugin (can either export a `default` module with lifecycle methods,
16
+ * or export the methods individually)
17
+ */
18
+ modulePath: string;
19
+ }
@@ -0,0 +1,11 @@
1
+ import PluginModuleDefinition from './PluginModuleDefinition';
2
+ import SerialiserModuleDefinition from './SerialiserModuleDefinition';
3
+ import SourceModuleDefinition from './SourceModuleDefinition';
4
+
5
+ export interface PullDocsConfig {
6
+ pageExtensions: Array<string>;
7
+ ignorePages?: Array<string>;
8
+ serialisers: Array<SerialiserModuleDefinition>;
9
+ plugins: Array<PluginModuleDefinition>;
10
+ sources: Array<SourceModuleDefinition>;
11
+ }
@@ -0,0 +1,31 @@
1
+ import type { TDataOut } from 'memfs/lib/encoding';
2
+
3
+ import type Page from './Page';
4
+ import type SerialiserModuleDefinition from './SerialiserModuleDefinition';
5
+
6
+ /**
7
+ * Serialisers are a form of plugin that tells PullDocs how to turn a file from/to a storable form for the filesystem
8
+ * or a `Page` object.
9
+ * For technical clarity - when a parser method is called, it will trigger `parserRunner` which checks the `fullPath` against
10
+ * the `test` option that was passed in the PullDocs config file, to find a suitable parser.
11
+ */
12
+ export type Serialiser = {
13
+ /**
14
+ * Method to turn a raw page (e.g. an MDX file) into a `Page` object
15
+ * @param fullPath Route on virtual disk (should be full fullPath, not an alias)
16
+ * @param page Page in string or buffer form (i.e. an MDX page with frontmatter or a JSON file as a string)
17
+ * @returns Page object in the `Page` format
18
+ */
19
+ deserialise: (fullPath: string, page: TDataOut) => Promise<Page>;
20
+ /**
21
+ * Method to load a raw page from disk (e.g. an MDX file) and return into a `Page` object
22
+ * @param fullPath Route on virtual disk (should be full fullPath, not an alias)
23
+ * @param page Page in `Page` form
24
+ * @returns Page content
25
+ */
26
+ serialise: (fullPath: string, page: Page) => Promise<TDataOut>;
27
+ };
28
+
29
+ export type LoadedSerialiser = Serialiser & SerialiserModuleDefinition;
30
+
31
+ export default Serialiser;
@@ -0,0 +1,7 @@
1
+ import PluginModuleDefinition from './PluginModuleDefinition';
2
+
3
+ type SerialiserModuleDefinition = PluginModuleDefinition & {
4
+ filter: RegExp;
5
+ };
6
+
7
+ export default SerialiserModuleDefinition;
package/src/Source.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { Observable } from 'rxjs';
2
+
3
+ import type Serialiser from './Serialiser';
4
+ import type Page from './Page';
5
+
6
+ type Source<Options = {}> = {
7
+ create(
8
+ options: Options,
9
+ { serialiser, pageExtensions }: { pageExtensions: string[]; serialiser: Serialiser }
10
+ ): Observable<Page[]>;
11
+ };
12
+
13
+ export default Source;
@@ -0,0 +1,8 @@
1
+ import type PluginModuleDefinition from './PluginModuleDefinition';
2
+
3
+ type SourceModuleDefinition = PluginModuleDefinition & {
4
+ namespace: string;
5
+ cache?: boolean;
6
+ };
7
+
8
+ export default SourceModuleDefinition;
package/src/Volume.ts ADDED
@@ -0,0 +1,136 @@
1
+ import type {
2
+ DirectoryJSON,
3
+ IRealpathOptions,
4
+ IMkdirOptions,
5
+ IReaddirOptions,
6
+ TData,
7
+ TMode
8
+ } from 'memfs/lib/volume';
9
+ import type { TDataOut } from 'memfs/lib/encoding';
10
+ import type Dirent from 'memfs/lib/Dirent';
11
+ import type Stats from 'memfs/lib/Stats';
12
+ import type { TStatNumber } from 'memfs/lib/Stats';
13
+ import type { IStatOptions } from 'memfs/lib/volume';
14
+ import type { PathLike, symlink } from 'fs';
15
+ import type { Options, Pattern, Entry } from 'fast-glob';
16
+
17
+ /**
18
+ * Volumes are lightweight decorators which wrap `FileAccess` and limit access to the underlying API for different use-cases
19
+ * Examples include disallowing mutation or allowing underlying functions like resetting
20
+ */
21
+ interface IVolume {
22
+ namespace: string;
23
+ reset?(): void;
24
+ toJSON(): DirectoryJSON;
25
+ symlinksToJSON(): { [key: string]: { target: string; type: string }[] };
26
+ fromJSON?(json: DirectoryJSON): void;
27
+ promises: {
28
+ exists(file: PathLike): Promise<boolean>;
29
+ glob(pattern: Pattern, options?: Options): Promise<string[] | Entry[]>;
30
+ mkdir(dir: PathLike, options?: TMode | IMkdirOptions): Promise<void>;
31
+ readdir(dir: PathLike, options?: string | IReaddirOptions): Promise<TDataOut[] | Dirent[]>;
32
+ readFile(file: PathLike): Promise<TDataOut>;
33
+ realpath(target: string, options?: string | IRealpathOptions): Promise<TDataOut>;
34
+ stat(file: PathLike, options?: IStatOptions): Promise<Stats<TStatNumber>>;
35
+ symlink(target: PathLike, alias: PathLike, type?: symlink.Type): Promise<void>;
36
+ unlink(target: PathLike): Promise<void>;
37
+ writeFile(file: PathLike, data: TData): Promise<void>;
38
+ };
39
+ }
40
+ export interface IVolumePartiallyMutable extends Omit<IVolume, 'reset' | 'fromJSON'> {
41
+ /**
42
+ * Functions that will be called after a page is read from the filesystem for the first time (since last cache clear).
43
+ * The value returned from this hook will *replace* the contents of the read file.
44
+ * @param hook Any function that invokes an `afterRead` plugin
45
+ * @returns Promise<Page>
46
+ */
47
+ __internal_do_not_use_addReadFileHook(
48
+ hook: (filepath: PathLike, fileData: TDataOut) => Promise<TDataOut>
49
+ ): void;
50
+ }
51
+
52
+ export interface IUnionVolume extends Omit<IVolumeImmutable, 'promises'> {
53
+ promises: Pick<IVolumeImmutable, 'promises'> & {
54
+ /**
55
+ * Reads a file
56
+ * @param file Path
57
+ * @returns Promise<TDataOut>
58
+ */
59
+ readFile(file: PathLike): Promise<TDataOut>;
60
+ readFile(file: PathLike, options?: { includeConflicts?: false }): Promise<TDataOut>;
61
+ /**
62
+ * Reads 1 or more files (if multiple files exist at the same location within the union filesystem)
63
+ * @param file Path
64
+ * @param options.includeConflicts If multiple files exist at the same location in the filesystem, return them all as an array
65
+ * @returns Promise<TDataOut[]>
66
+ */
67
+ readFile(file: PathLike, options: { includeConflicts: true }): Promise<TDataOut[]>;
68
+ };
69
+ /**
70
+ * Scopes a filesystem to specific namespaces
71
+ * @param {string[]} namespaces Array of namespaces to limit this filesystem to
72
+ * @returns A new immutable union filesystem
73
+ */
74
+ scope(namespaces: string[]): IUnionVolume;
75
+ }
76
+
77
+ export interface IVolumeMutable extends IVolume {
78
+ /**
79
+ * Functions that will be called after a page is read from the filesystem for the first time (since last cache clear).
80
+ * The value returned from this hook will *replace* the contents of the read file.
81
+ * @param hook Any function that invokes an `afterRead` plugin
82
+ * @returns Promise<Page>
83
+ */
84
+ __internal_do_not_use_addReadFileHook(
85
+ hook: (filepath: PathLike, fileData: TDataOut) => Promise<TDataOut>
86
+ ): void;
87
+ /**
88
+ * Restricted filesystems can be written to, but cannot be frozen, updated or reset
89
+ */
90
+ asRestricted(): IVolumePartiallyMutable;
91
+ /**
92
+ * ReadOnly filesystems cannot be mutated in any way, including freezing, updating or reseting
93
+ */
94
+ asReadOnly(): IVolumeImmutable;
95
+ /**
96
+ * Clears the filesystem's internal page cache - used when the cache may be outdated due to a source emiting new data or a dependency changing.
97
+ */
98
+ clearCache(): void;
99
+ /**
100
+ * Re-enables mutations on the underlying `FileAccess`.
101
+ */
102
+ unfreeze(): void;
103
+ /**
104
+ * Freezes an object, preventing all mutations on the underlying `FileAccess` object
105
+ * Freezing a filesystem indicates that the mutation period has ended and the file system can no longer be modified.
106
+ * When a filesystem is unfrozen, it is considered to be in flux, so may change as more plugins are called.
107
+ * When a filesystem is frozen, it is considered to be stable and ready to begin serving finalised versions of files.
108
+ */
109
+ freeze(): void;
110
+ /**
111
+ * Is this filesystem frozen/mutable?
112
+ * @returns {boolean}
113
+ */
114
+ get frozen(): boolean;
115
+ /**
116
+ * Appends content to the filesystem
117
+ * @param json A JSON blob in the form of {[fullPath]: "{fullPath: '', content: ''}"}
118
+ */
119
+ fromJSON(json: DirectoryJSON): void;
120
+ symlinksFromJSON(json: { [key: string]: { target: string; type: string }[] }): Promise<void>;
121
+ /**
122
+ * Completely resets the filesystem.
123
+ * This includes clearing page cache, erasing filesystem data, clearing symlinks etc
124
+ */
125
+ reset(): void;
126
+ }
127
+ export interface IVolumeImmutable
128
+ extends Omit<
129
+ IVolumePartiallyMutable,
130
+ 'fromJSON' | 'reset' | 'promises' | '__internal_do_not_use_addReadFileHook'
131
+ > {
132
+ promises: Omit<
133
+ IVolume['promises'],
134
+ 'writeFile' | 'symlink' | 'mkdir' | 'unlink' | 'rmdir' | 'rm' | 'rename'
135
+ >;
136
+ }
@@ -0,0 +1,18 @@
1
+ import type SerialiserModuleDefinition from './SerialiserModuleDefinition';
2
+ import type PluginModuleDefinition from './PluginModuleDefinition';
3
+ import type SourceModuleDefinition from './SourceModuleDefinition';
4
+
5
+ type WorkerData<Options = {}> = {
6
+ options: Options & Pick<PluginModuleDefinition, 'options'> & Pick<SourceModuleDefinition, 'options'> & {
7
+ pageExtensions: string[]
8
+ };
9
+ name: string;
10
+ namespace: string;
11
+ pageExtensions: string[];
12
+ ignorePages: string[];
13
+ plugins: PluginModuleDefinition[];
14
+ serialisers: SerialiserModuleDefinition[];
15
+ modulePath: string;
16
+ };
17
+
18
+ export default WorkerData;
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig",
3
+ "compilerOptions": {
4
+ "emitDeclarationOnly": true,
5
+ "rootDir": "./src",
6
+ "outDir": "./dist"
7
+ },
8
+ "include": ["src"],
9
+ "exclude": ["src/**/__tests__/**/*", "src/__tests__/**/*"]
10
+ }