@jpmorganchase/mosaic-types 0.1.0-beta.6 → 0.1.0-beta.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @jpmorganchase/mosaic-types
2
2
 
3
+ ## 0.1.0-beta.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 46adaec: Initial release of theme and client side search
8
+
9
+ We are iterating towards deploying our site code.
10
+
11
+ This release includes
12
+
13
+ - initial work for client-side search support
14
+ - Mosaic theme.
15
+
3
16
  ## 0.1.0-beta.6
4
17
 
5
18
  ### Patch Changes
package/dist/Page.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `Page` is a type, which at a minimum has a `fullPath`, but can also contain metadata and `content`
3
3
  */
4
- export declare type Page<AdditionalProps = {}> = {
4
+ export declare type Page = {
5
5
  fullPath: string;
6
6
  title?: string;
7
7
  /**
@@ -17,4 +17,4 @@ export declare type Page<AdditionalProps = {}> = {
17
17
  lastModified?: Date;
18
18
  type?: string;
19
19
  content?: string;
20
- } & Record<string, unknown> & AdditionalProps;
20
+ };
package/dist/Plugin.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import type { Page } from './Page';
2
- import type { MutableData } from './MutableData';
3
- import type { PluginModuleDefinition } from './PluginModuleDefinition';
4
- import type { ImmutableData } from './MutableData';
2
+ import type { MutableData, ImmutableData } from './MutableData';
3
+ import type { PluginModuleDefinition } from './index';
5
4
  import type { IUnionVolume, IVolumeImmutable, IVolumeMutable, IVolumePartiallyMutable } from './Volume';
6
5
  import type { Serialiser } from './Serialiser';
7
- export declare type LoadedPlugin = Partial<Plugin> & PluginModuleDefinition;
6
+ export declare type LoadedPlugin = Partial<Plugin<Page>> & PluginModuleDefinition;
7
+ export declare type LifecycleMethod = keyof Plugin<Page>;
8
8
  /**
9
9
  * Plugins are lifecycle-based hooks that are called on every source at different stages.
10
10
  * Consumers will never need to invoke a lifecycle method; but for technical clarity - when a lifecycle method is called,
11
11
  * it will trigger `pluginRunner` which executes it on every source automatically.
12
12
  */
13
- export declare type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData = ConfigData> = {
13
+ export declare type Plugin<TPage extends Page = Page, TOptions = Record<string, unknown>, ConfigData = Record<string, unknown>, GlobalConfigData = ConfigData> = {
14
14
  /**
15
15
  * Plugin lifecycle method that triggers inside child processes.
16
16
  * 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
@@ -21,12 +21,12 @@ export declare type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData
21
21
  * @param options The options passed in when declaring the plugin
22
22
  * @returns {Promise<Page[]>} Must re-return an array of `Page` objects, modified or not
23
23
  */
24
- $afterSource?(pages: Page[], {}: {
25
- serialiser: Serialiser;
24
+ $afterSource?: (pages: TPage[], helpers: {
25
+ serialiser: Serialiser<TPage>;
26
26
  config: MutableData<ConfigData>;
27
27
  pageExtensions: string[];
28
28
  ignorePages: string[];
29
- }, options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions): Promise<Page[]>;
29
+ }, options?: TOptions) => Promise<Array<TPage>>;
30
30
  /**
31
31
  * Plugin lifecycle method that triggers inside child processes.
32
32
  * Calls after a filesystem has been built up from the source pages.
@@ -36,12 +36,12 @@ export declare type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData
36
36
  * @param options The options passed in when declaring the plugin
37
37
  * @returns {void} No return expected
38
38
  */
39
- $beforeSend?(mutableFilesystem: IVolumePartiallyMutable, {}: {
40
- serialiser: Serialiser;
39
+ $beforeSend?: (mutableFilesystem: IVolumePartiallyMutable, helpers: {
40
+ serialiser: Serialiser<TPage>;
41
41
  pageExtensions: string[];
42
42
  ignorePages: string[];
43
43
  config: MutableData<ConfigData>;
44
- }, options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions): Promise<void>;
44
+ }, options?: TOptions) => Promise<void>;
45
45
  /**
46
46
  * Plugin lifecycle method that triggers inside the main process.
47
47
  * Calls after the filesystem and symlinks have been reconstructed due to a change to the current source. This happens in the main thread.
@@ -59,15 +59,15 @@ export declare type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData
59
59
  * @param options The options passed in when declaring the plugin
60
60
  * @returns {void} No return expected
61
61
  */
62
- afterUpdate?(mutableFilesystem: IVolumePartiallyMutable, {}: {
63
- serialiser: Serialiser;
62
+ afterUpdate?: (mutableFilesystem: IVolumePartiallyMutable, helpers: {
63
+ serialiser: Serialiser<TPage>;
64
64
  config: ImmutableData<ConfigData>;
65
65
  globalFilesystem: IUnionVolume;
66
66
  sharedFilesystem: IVolumeMutable;
67
67
  globalConfig: ImmutableData<GlobalConfigData>;
68
68
  pageExtensions: string[];
69
69
  ignorePages: string[];
70
- }, options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions): Promise<void>;
70
+ }, options?: TOptions) => Promise<void>;
71
71
  /**
72
72
  * Plugin lifecycle method that triggers inside the main process everytime ANY source emits new pages.
73
73
  * This method should return a boolean that will indicate if this source should clear page caches.
@@ -80,12 +80,34 @@ export declare type Plugin<ConfigData = {}, PluginOptions = {}, GlobalConfigData
80
80
  * @param options The options passed in when declaring the plugin
81
81
  * @returns {Promise<boolean>} A boolean indicating whether to clear the cache for this source
82
82
  */
83
- shouldClearCache?(updatedSourceFilesystem: IVolumeImmutable, {}: {
84
- serialiser: Serialiser;
83
+ shouldClearCache?: (updatedSourceFilesystem: IVolumeImmutable, helpers: {
84
+ serialiser: Serialiser<TPage>;
85
85
  config: ImmutableData<ConfigData>;
86
86
  globalFilesystem: IUnionVolume;
87
87
  pageExtensions: string[];
88
88
  ignorePages: string[];
89
- }, options?: Pick<PluginModuleDefinition, 'options'> & PluginOptions): Promise<boolean>;
89
+ }, options?: TOptions) => Promise<boolean>;
90
+ /**
91
+ * Plugin lifecycle method that triggers inside the main process whenever a request to save content is made.
92
+ * This method should return the result of the save
93
+ * Returning `undefined`, false or no value, will result in the plugin runner discarding the result.
94
+ * @param path the route of the content being edited.
95
+ * @param data the data from the the request
96
+ * @param sourceOptions options used to create the source that is running the plugin
97
+ * @param mutableFilesystem Mutable filesystem instance with all of this source's pages inside (and symlinks re-applied)
98
+ * @param param.serialiser A matching `Serialiser` for serialising/deserialising pages when reading/writing to the filesystem
99
+ * @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.
100
+ * @param param.sharedFilesystem Mutable filesystem instance independent of any sources. Useful for global pages, like sitemaps
101
+ * @param param.namespace The namespace of the source running the plugin
102
+ * @param options The options passed in when declaring the plugin
103
+ * @returns {Promise<unknown>} The result of the save
104
+ */
105
+ saveContent?(path: string, data: unknown, sourceOptions: unknown, helpers: {
106
+ serialiser: Serialiser<TPage>;
107
+ config: ImmutableData<ConfigData>;
108
+ sharedFilesystem: IVolumeMutable;
109
+ pageExtensions: string[];
110
+ ignorePages: string[];
111
+ namespace: string;
112
+ }, options?: TOptions): Promise<unknown>;
90
113
  };
91
- export declare type LifecycleMethod = keyof Plugin;
@@ -1,26 +1,26 @@
1
1
  import type { TDataOut } from 'memfs/lib/encoding';
2
+ import type { SerialiserModuleDefinition } from './index';
2
3
  import type { Page } from './Page';
3
- import type { SerialiserModuleDefinition } from './SerialiserModuleDefinition';
4
4
  /**
5
- * Serialisers are a form of plugin that tells PullDocs how to turn a file from/to a storable form for the filesystem
5
+ * Serialisers are a form of plugin that tells Mosaic how to turn a file from/to a storable form for the filesystem
6
6
  * or a `Page` object.
7
7
  * For technical clarity - when a parser method is called, it will trigger `parserRunner` which checks the `fullPath` against
8
- * the `test` option that was passed in the PullDocs config file, to find a suitable parser.
8
+ * the `test` option that was passed in the Mosaic config file, to find a suitable parser.
9
9
  */
10
- export declare type Serialiser = {
10
+ export declare type Serialiser<TPage extends Page = Page> = {
11
11
  /**
12
12
  * Method to turn a raw page (e.g. an MDX file) into a `Page` object
13
13
  * @param fullPath Route on virtual disk (should be full fullPath, not an alias)
14
14
  * @param page Page in string or buffer form (i.e. an MDX page with frontmatter or a JSON file as a string)
15
15
  * @returns Page object in the `Page` format
16
16
  */
17
- deserialise: (fullPath: string, page: TDataOut) => Promise<Page>;
17
+ deserialise: (fullPath: string, page: TDataOut) => Promise<TPage>;
18
18
  /**
19
19
  * Method to load a raw page from disk (e.g. an MDX file) and return into a `Page` object
20
20
  * @param fullPath Route on virtual disk (should be full fullPath, not an alias)
21
21
  * @param page Page in `Page` form
22
22
  * @returns Page content
23
23
  */
24
- serialise: (fullPath: string, page: Page) => Promise<TDataOut>;
24
+ serialise: (fullPath: string, page: TPage) => Promise<TDataOut>;
25
25
  };
26
26
  export declare type LoadedSerialiser = Serialiser & SerialiserModuleDefinition;
@@ -0,0 +1,6 @@
1
+ export declare type SourceWorkflowAction<TSourceOptions, TOptions> = (sourceOptions: TSourceOptions, workflowOptions: TOptions, ...args: any[]) => Promise<unknown>;
2
+ export declare type SourceWorkflow<TSourceOptions = unknown, TOptions = unknown> = {
3
+ name: string;
4
+ options?: TOptions;
5
+ action: SourceWorkflowAction<TSourceOptions, TOptions>;
6
+ };
@@ -1,6 +1,4 @@
1
- import type { SerialiserModuleDefinition } from './SerialiserModuleDefinition';
2
- import type { PluginModuleDefinition } from './PluginModuleDefinition';
3
- import type { SourceModuleDefinition } from './SourceModuleDefinition';
1
+ import type { SerialiserModuleDefinition, PluginModuleDefinition, SourceModuleDefinition } from './index';
4
2
  export declare type WorkerData<Options = {}> = {
5
3
  options: Options & Pick<PluginModuleDefinition, 'options'> & Pick<SourceModuleDefinition, 'options'> & {
6
4
  pageExtensions: string[];
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
+ import type { SerialiserModuleDefinition, MosaicConfig, PluginModuleDefinition, SourceModuleDefinition, SourceWorkflow } from '@jpmorganchase/mosaic-schemas';
1
2
  export * from './IFileAccess';
2
3
  export * from './Meta';
3
4
  export * from './MutableData';
4
5
  export * from './Page';
5
6
  export * from './Plugin';
6
- export * from './PluginModuleDefinition';
7
- export * from './PullDocsConfig';
8
7
  export * from './Serialiser';
9
- export * from './SerialiserModuleDefinition';
10
8
  export * from './Source';
11
- export * from './SourceModuleDefinition';
12
9
  export * from './Volume';
13
10
  export * from './WorkerData';
11
+ export { SerialiserModuleDefinition, MosaicConfig, PluginModuleDefinition, SourceModuleDefinition, SourceWorkflow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpmorganchase/mosaic-types",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.7",
4
4
  "author": "",
5
5
  "description": "Mosaic BitBucket source for core file system",
6
6
  "license": "Apache-2.0",
@@ -20,6 +20,8 @@
20
20
  "clean": "rm -fr dist"
21
21
  },
22
22
  "devDependencies": {
23
- "rxjs": "^7.5.5"
23
+ "@jpmorganchase/mosaic-schemas": "^0.1.0-beta.7",
24
+ "rxjs": "^7.5.5",
25
+ "zod": "^3.19.1"
24
26
  }
25
27
  }
@@ -1,19 +0,0 @@
1
- export 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
- }
@@ -1,10 +0,0 @@
1
- import type { PluginModuleDefinition } from './PluginModuleDefinition';
2
- import type { SerialiserModuleDefinition } from './SerialiserModuleDefinition';
3
- import type { SourceModuleDefinition } from './SourceModuleDefinition';
4
- export interface PullDocsConfig {
5
- pageExtensions: Array<string>;
6
- ignorePages?: Array<string>;
7
- serialisers: Array<SerialiserModuleDefinition>;
8
- plugins: Array<PluginModuleDefinition>;
9
- sources: Array<SourceModuleDefinition>;
10
- }
@@ -1,4 +0,0 @@
1
- import type { PluginModuleDefinition } from './PluginModuleDefinition';
2
- export declare type SerialiserModuleDefinition = PluginModuleDefinition & {
3
- filter: RegExp;
4
- };
@@ -1,5 +0,0 @@
1
- import type { PluginModuleDefinition } from './PluginModuleDefinition';
2
- export declare type SourceModuleDefinition = PluginModuleDefinition & {
3
- namespace: string;
4
- cache?: boolean;
5
- };