@jpmorganchase/mosaic-store 0.1.0-beta.72 → 0.1.0-beta.73

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.
Files changed (44) hide show
  1. package/package.json +4 -1
  2. package/.turbo/turbo-build.log +0 -4
  3. package/CHANGELOG.md +0 -374
  4. package/src/__tests__/store.test.ts +0 -210
  5. package/src/__tests__/test-utils/utils.tsx +0 -26
  6. package/src/__tests__/useAppHeader.test.ts +0 -157
  7. package/src/__tests__/useBreadcrumbs.test.ts +0 -42
  8. package/src/__tests__/useColorMode.test.ts +0 -12
  9. package/src/__tests__/useFooter.test.ts +0 -64
  10. package/src/__tests__/useLayout.test.ts +0 -24
  11. package/src/__tests__/useMeta.test.ts +0 -35
  12. package/src/__tests__/useRoute.test.ts +0 -24
  13. package/src/__tests__/useSearchIndex.test.ts +0 -86
  14. package/src/__tests__/useStoreActions.test.ts +0 -35
  15. package/src/__tests__/useTableOfContents.test.ts +0 -32
  16. package/src/index.ts +0 -14
  17. package/src/store.ts +0 -140
  18. package/src/types/appHeader.ts +0 -80
  19. package/src/types/breadcrumbs.ts +0 -21
  20. package/src/types/colorMode.ts +0 -4
  21. package/src/types/footer.ts +0 -17
  22. package/src/types/helpLinks.ts +0 -13
  23. package/src/types/index.ts +0 -12
  24. package/src/types/layout.ts +0 -7
  25. package/src/types/meta.ts +0 -13
  26. package/src/types/navigation.ts +0 -23
  27. package/src/types/route.ts +0 -7
  28. package/src/types/searchIndex.ts +0 -21
  29. package/src/types/sharedConfig.ts +0 -15
  30. package/src/types/sidebar.ts +0 -24
  31. package/src/types/tableOfContents.ts +0 -19
  32. package/src/useAppHeader.ts +0 -46
  33. package/src/useBreadcrumbs.ts +0 -11
  34. package/src/useColorMode.ts +0 -8
  35. package/src/useFooter.ts +0 -10
  36. package/src/useLayout.ts +0 -9
  37. package/src/useMeta.ts +0 -17
  38. package/src/useNavigation.ts +0 -10
  39. package/src/useRoute.ts +0 -9
  40. package/src/useSearchIndex.ts +0 -17
  41. package/src/useSidebar.ts +0 -18
  42. package/src/useStoreActions.ts +0 -2
  43. package/src/useTableOfContents.ts +0 -8
  44. package/tsconfig.json +0 -8
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jpmorganchase/mosaic-store",
3
3
  "description": "Mosaic - Store for site configuration",
4
- "version": "0.1.0-beta.72",
4
+ "version": "0.1.0-beta.73",
5
5
  "license": "Apache-2.0",
6
6
  "author": "",
7
7
  "repository": {
@@ -20,6 +20,9 @@
20
20
  "default": "./dist/index.js"
21
21
  }
22
22
  },
23
+ "files": [
24
+ "dist"
25
+ ],
23
26
  "scripts": {
24
27
  "build": "npm-run-all --parallel build:*",
25
28
  "build:bundle": "node ../../scripts/bundle.js",
@@ -1,4 +0,0 @@
1
- @jpmorganchase/mosaic-store:build: cache hit, replaying output dcc8c8b3c42a602c
2
- @jpmorganchase/mosaic-store:build: $ npm-run-all --parallel build:*
3
- @jpmorganchase/mosaic-store:build: $ tsc
4
- @jpmorganchase/mosaic-store:build: $ node ../../scripts/bundle.js
package/CHANGELOG.md DELETED
@@ -1,374 +0,0 @@
1
- # @jpmorganchase/mosaic-store
2
-
3
- ## 0.1.0-beta.72
4
-
5
- ## 0.1.0-beta.71
6
-
7
- ## 0.1.0-beta.70
8
-
9
- ## 0.1.0-beta.69
10
-
11
- ## 0.1.0-beta.68
12
-
13
- ## 0.1.0-beta.67
14
-
15
- ## 0.1.0-beta.66
16
-
17
- ## 0.1.0-beta.65
18
-
19
- ## 0.1.0-beta.64
20
-
21
- ## 0.1.0-beta.63
22
-
23
- ## 0.1.0-beta.62
24
-
25
- ## 0.1.0-beta.61
26
-
27
- ### Patch Changes
28
-
29
- - cec89401: add `pluginTimeout` (20 secs) to fastify to prevent loading timeout
30
-
31
- ## 0.1.0-beta.60
32
-
33
- ### Patch Changes
34
-
35
- - a3da0830: New Readme Source
36
-
37
- This source pulls a single Readme.md from a remote Source repo.
38
- Typically used for third-party repos which exist already or don't want to
39
- create a full document hierachy and use `@jpmorganchase/mosaic-source-git-repo`.
40
- By pulling a single page, we can add metadata to that page via the source's config.
41
- It's also more performant as we do not need to pull a whole source repo.
42
-
43
- ## 0.1.0-beta.59
44
-
45
- ## 0.1.0-beta.58
46
-
47
- ## 0.1.0-beta.57
48
-
49
- ### Patch Changes
50
-
51
- - d214d112: Add catch-all default exports for
52
-
53
- - `@jpmorganchase/mosaic-store`
54
- - `@jpmorganchase/mosaic-theme`
55
- - `@jpmorganchase/mosaic-workflows`
56
-
57
- This resolves an issue when running tests from an external repo which depends on these packages
58
-
59
- ## 0.1.0-beta.56
60
-
61
- ### Patch Changes
62
-
63
- - 6d30e29f: Add new Storybook source
64
-
65
- Storybook stories can be extracted from Storybook and embedded into Mosaic pages.
66
-
67
- The stories are extracted based on a configured filter or matching tags.
68
-
69
- With a page created for each Story, the author can create a dynamic index of matching stories.
70
-
71
- eg. An index of patterns which match a specific tag
72
-
73
- ## 0.1.0-beta.55
74
-
75
- ## 0.1.0-beta.54
76
-
77
- ## 0.1.0-beta.53
78
-
79
- ## 0.1.0-beta.52
80
-
81
- ## 0.1.0-beta.51
82
-
83
- ## 0.1.0-beta.50
84
-
85
- ## 0.1.0-beta.49
86
-
87
- ## 0.1.0-beta.48
88
-
89
- ## 0.1.0-beta.47
90
-
91
- ### Patch Changes
92
-
93
- - 19b4e49a: ### Fix
94
-
95
- Ensure that help links in the sidebar are visible when they are present in the page `sharedConfig`
96
-
97
- ## 0.1.0-beta.46
98
-
99
- ### Patch Changes
100
-
101
- - 32e86cfd: ## Fix
102
-
103
- When a page does not specify a property that is part of the store default props, we use what the default props specify and not what is currently in the store.
104
-
105
- ## 0.1.0-beta.45
106
-
107
- ## 0.1.0-beta.44
108
-
109
- ## 0.1.0-beta.43
110
-
111
- ## 0.1.0-beta.42
112
-
113
- ## 0.1.0-beta.41
114
-
115
- ## 0.1.0-beta.40
116
-
117
- ## 0.1.0-beta.39
118
-
119
- ## 0.1.0-beta.38
120
-
121
- ## 0.1.0-beta.37
122
-
123
- ## 0.1.0-beta.36
124
-
125
- ## 0.1.0-beta.35
126
-
127
- ## 0.1.0-beta.34
128
-
129
- ## 0.1.0-beta.33
130
-
131
- ## 0.1.0-beta.32
132
-
133
- ## 0.1.0-beta.31
134
-
135
- ### Patch Changes
136
-
137
- - b609fd0: Added support for containerization of the site and cli as well as providing config for kubernetes development (skaffold)
138
-
139
- ## @jpmorganchase/mosaic-cli
140
-
141
- The cli package has been updated to support containerization.
142
-
143
- ## 0.1.0-beta.30
144
-
145
- ### Patch Changes
146
-
147
- - 18ef436: The git repo source no longer generates a double slash between the repo host and repo path.
148
-
149
- ## 0.1.0-beta.29
150
-
151
- ### Minor Changes
152
-
153
- - c78deb4: Flatten Sidebar
154
- Search Optimisation
155
- Public Assets Plugin
156
- TOC Indentation
157
-
158
- ## 0.1.0-beta.28
159
-
160
- ### Patch Changes
161
-
162
- - 27ac914: 1. Layout improvements. 2. Fix: if a user hits a url that lands on a directory, the index file within that directory is resolved as the content. 3. Fix: improve Table of Contents component highlighting.
163
-
164
- ## 0.1.0-beta.27
165
-
166
- ### Patch Changes
167
-
168
- - b465413: Improvements to vercel deployments
169
-
170
- ## 0.1.0-beta.26
171
-
172
- ### Minor Changes
173
-
174
- - 531c87a: ## Mosaic Theme
175
-
176
- The theme variables are now globally scoped and prefixed with `mosaic`.
177
-
178
- ## BrokenLinksPlugin
179
-
180
- The `BrokenLinksPlugin` uses a running instance of mosaic to verify that all links in the source pages are alive.
181
-
182
- If mosaic is running behind a corporate proxy, the `proxyEndpoint` option is required to fetch external URLs.
183
-
184
- Configuration:
185
-
186
- ```json
187
- {
188
- modulePath: '@jpmorganchase/mosaic-plugins/BrokenLinksPlugin',
189
- priority: -1,
190
- // Exclude this plugin in builds
191
- runTimeOnly: true,
192
- options: {
193
- baseUrl: process.env.MOSAIC_ACTIVE_MODE_URL || 'http://localhost:8080',
194
- proxyEndpoint: 'http://some-proxy-url'
195
- }
196
- }
197
- ```
198
-
199
- ## Next/Prev button
200
-
201
- The next and prev buttons are visible again on pages that have a layout that uses these buttons.
202
-
203
- ## 0.1.0-beta.25
204
-
205
- ### Minor Changes
206
-
207
- - 93e9b07: The theme contract provided by the `@jpmorganchase/mosaic-theme` package now uses locally scoped variable names via a Vanilla Extract [Theme Contract](https://vanilla-extract.style/documentation/api/create-theme-contract/). Previously the theme variables were globally scoped resulting in conflicts with other design systems.
208
-
209
- ### Patch Changes
210
-
211
- - a36219c: - Next/Prev page buttons were not appearing at the bottom of a page sequence
212
- - Removed redundant snapshot page api
213
-
214
- ## 0.1.0-beta.24
215
-
216
- ### Patch Changes
217
-
218
- - 049d9af: 1. Pip Salt version 2. Issues 155, make 500 error more specific 3. button and sidebar styles 4. search opt-out
219
-
220
- ## 0.1.0-beta.23
221
-
222
- ### Patch Changes
223
-
224
- - 513d45f: Sidebar behavior and styling changes.
225
- Add Client-side search feature.
226
- Relax node engine requirements.
227
- Removal of patches from the site package.
228
- Update site generator templates.
229
-
230
- ## 0.1.0-beta.22
231
-
232
- ### Patch Changes
233
-
234
- - be89e4f: fix markdown tables and update generator's Salt patches
235
-
236
- - Salt patches in generator were out of sync with Mosaic repo
237
- - Markdown now support github flavoured markdown, such as Tables
238
-
239
- ## 0.1.0-beta.21
240
-
241
- ### Patch Changes
242
-
243
- - f75fd5e: fix sidebar which was generated after `beforeSend` had completed
244
-
245
- ## 0.1.0-beta.20
246
-
247
- ### Patch Changes
248
-
249
- - 9c7b8ff: pip to beta.20
250
-
251
- ## 0.1.0-beta.19
252
-
253
- ### Patch Changes
254
-
255
- - ad06d4c: ensure spinner is removed after page has loaded
256
-
257
- ## 0.1.0-beta.18
258
-
259
- ### Patch Changes
260
-
261
- - 066efed: Update docs with quick-start guide
262
-
263
- Sample docs now include a 'quick-start' guide to onboarding to AWS.
264
-
265
- Also
266
-
267
- - generator default directory is the current directory
268
- - after generating a site, it will run `yarn` in the created directory. This simplifies the generator call to just `yarn mosaic-create-site`
269
-
270
- ## 0.1.0-beta.17
271
-
272
- ### Patch Changes
273
-
274
- - b2f6d52: Fix `pre` block code block rendering
275
-
276
- ## 0.1.0-beta.16
277
-
278
- ### Patch Changes
279
-
280
- - 3a5c88a: add missing `@types/node` dependency for generator
281
-
282
- ## 0.1.0-beta.15
283
-
284
- ### Patch Changes
285
-
286
- - aaaf255: initial release of HTTP Source package.
287
-
288
- An HTTP source accepts a collection of endpoints and a path to a transformer module.
289
- The response from fetching is transformed and merged together into 1 single collection of pages.
290
- Should 1 of the endpoints request fail then it will have no impact on the other requests.
291
-
292
- ## 0.1.0-beta.14
293
-
294
- ### Patch Changes
295
-
296
- - dde3b5a: Feature release
297
-
298
- - Enhanced generators now have defaults.
299
- With one command (`yarn mosaic-create-site create`) it will generate a fully working site with both local and remote sources
300
- - Fix an issue where we could not clone from the master branch of git repos
301
- - Migrate to Next 13 image
302
-
303
- ## 0.1.0-beta.13
304
-
305
- ### Patch Changes
306
-
307
- - d4da1df: incremental improvements
308
-
309
- - move colormode into store
310
- - ensure breadcrumbs and sidebar data is only added to frontmatter for pages which use a layout that has breadcrumbs or a sidebar
311
- - improve changeset so it can work standalone without a monorepo
312
- - resolev json5 vulnerability
313
-
314
- ## 0.1.0-beta.12
315
-
316
- ### Patch Changes
317
-
318
- - 9ec358b: Upgrade React to version 18 and NextJs to version 13
319
- - 3eb35bf: initial work to enable generators to run outside of the repo
320
-
321
- ## 0.1.0-beta.11
322
-
323
- ### Patch Changes
324
-
325
- - fc5d7b5: Generators can now interactively add sources
326
-
327
- Previously we were making local edits to our own site or examples to implement new features.
328
- What we wanted was the ability to create a local rig, A local rig can be used for development purposes,
329
- without touching our site code.
330
-
331
- We have added Mosaic repo commands, to enable us to generates local rigs (`yarn gen:rig`) and deploy our own
332
- tech docs via snapshot (`yarn gen`)
333
-
334
- To generate a site+snapshot from sources defined in `mosaic-generators.js`, run `yarn gen`
335
- To generate a dynamic site from sources defined in `mosaic-generators.js`, run `yarn gen:site`
336
- To generate a rig `yarn gen:rig`
337
-
338
- Equally these changes can be used to generate sites in other repos via the `mosaic-create-site` command.
339
-
340
- `yarn mosaic-create-site init` will create a `mosaic.generators.js`.
341
-
342
- Configure the `mosaic.generators.js` with your generator and sources, then run.
343
-
344
- `yarn mosaic-create-site create -i -o path/to/my-site`
345
-
346
- When this command is run, it will present an interactive menu of generators and output the site to `path/to/my-site`.
347
-
348
- ## 0.1.0-beta.10
349
-
350
- ### Patch Changes
351
-
352
- - af2f579: Converted repo to ESM and Salt DS nomenclature
353
-
354
- - Switch UITK nomenclature to Salt DS
355
- Upgraded to first stable version of Salt DS version 1.0.0
356
- - CommonJS code switched to ESM and upgraded to Node 16
357
- - Removed example-nextjs-ssr package as un-required, can be replaced by documentation
358
- - Sites can now generate immutable snapshots of content that loads content like a SGS (statically generated site)
359
- Snapshots can be used as a serverless solution when deployed to Vercel.
360
- - New Middleware package `@jpmorganchase/mosaic-site-middleware`
361
-
362
- ## 0.1.0-beta.9
363
-
364
- ### Minor Changes
365
-
366
- - c3fee89: initial components package
367
-
368
- - added JSDOM testing
369
-
370
- ## 0.1.0-beta.8
371
-
372
- ### Minor Changes
373
-
374
- - 2dca0b1: initial release of Mosaic store package
@@ -1,210 +0,0 @@
1
- import { renderHook } from '@testing-library/react';
2
-
3
- import { createWrapper } from './test-utils/utils';
4
- import { initializeStore, SiteState, useCreateStore, useStore } from '../store';
5
-
6
- function getStateToVerify(currentState: SiteState) {
7
- let { actions, ...stateToVerify } = currentState;
8
- return stateToVerify;
9
- }
10
-
11
- describe('GIVEN the store initializer', () => {
12
- describe('WHEN no other state is provided', () => {
13
- test('THEN the store api provides the initial default state', () => {
14
- const storeApi = initializeStore();
15
- expect(getStateToVerify(storeApi.getState())).toEqual({
16
- breadcrumbs: [],
17
- navigation: {},
18
- sidebarData: [],
19
- tableOfContents: [],
20
- searchIndex: [],
21
- searchConfig: {},
22
- sharedConfig: {},
23
- description: undefined,
24
- layout: undefined,
25
- route: undefined,
26
- title: undefined,
27
- colorMode: 'light'
28
- });
29
- });
30
- });
31
-
32
- describe('WHEN additional state is preloaded', () => {
33
- test('THEN the store api provides the initial default state plus the preloaded state', () => {
34
- const state = {
35
- description: 'description',
36
- layout: 'layout',
37
- route: 'route',
38
- title: 'title'
39
- };
40
-
41
- const storeApi = initializeStore(state);
42
- expect(getStateToVerify(storeApi.getState())).toEqual({
43
- breadcrumbs: [],
44
- navigation: {},
45
- searchIndex: [],
46
- searchConfig: {},
47
- sidebarData: [],
48
- tableOfContents: [],
49
- sharedConfig: {},
50
- colorMode: 'light',
51
-
52
- ...state
53
- });
54
- });
55
- });
56
- });
57
-
58
- describe('GIVEN the `useCreateStore` hook', () => {
59
- describe('WHEN executed on the client', () => {
60
- test('THEN the store content is replaced', () => {
61
- const state = { layout: 'layout', description: 'des' };
62
- const { result, rerender } = renderHook(() => useCreateStore(state));
63
- let currentState = result.current().getState();
64
-
65
- expect(getStateToVerify(currentState)).toEqual({
66
- breadcrumbs: [],
67
- navigation: {},
68
- searchIndex: [],
69
- searchConfig: {},
70
- sidebarData: [],
71
- tableOfContents: [],
72
- sharedConfig: {},
73
- colorMode: 'light',
74
- ...state,
75
- route: undefined,
76
- title: undefined
77
- });
78
-
79
- // update the state and rerender
80
- state.layout = 'new';
81
- state.description = 'description';
82
- rerender();
83
-
84
- currentState = result.current().getState();
85
- expect(getStateToVerify(currentState)).toEqual({
86
- breadcrumbs: [],
87
- navigation: {},
88
- sidebarData: [],
89
- searchIndex: [],
90
- searchConfig: {},
91
- tableOfContents: [],
92
- sharedConfig: {},
93
- colorMode: 'light',
94
- description: 'description',
95
- layout: 'new',
96
- route: undefined,
97
- title: undefined
98
- });
99
- });
100
- test('THEN defaults applied when page props do not include default state', () => {
101
- const state: { layout?: string; description: string } = {
102
- layout: 'layout',
103
- description: 'des'
104
- };
105
- const { result, rerender } = renderHook(() => useCreateStore(state));
106
- let currentState = result.current().getState();
107
-
108
- expect(getStateToVerify(currentState)).toEqual({
109
- breadcrumbs: [],
110
- navigation: {},
111
- searchIndex: [],
112
- searchConfig: {},
113
- sidebarData: [],
114
- tableOfContents: [],
115
- sharedConfig: {},
116
- colorMode: 'light',
117
- ...state,
118
- route: undefined,
119
- title: undefined
120
- });
121
-
122
- /**
123
- * we use delete here because the idea is that the page does not indicate a layout IN ANY WAY
124
- * This is different from the page saying my layout is undefined
125
- */
126
- delete state.layout;
127
- state.description = 'description';
128
- rerender();
129
-
130
- currentState = result.current().getState();
131
- expect(getStateToVerify(currentState)).toEqual({
132
- breadcrumbs: [],
133
- navigation: {},
134
- sidebarData: [],
135
- searchIndex: [],
136
- searchConfig: {},
137
- tableOfContents: [],
138
- sharedConfig: {},
139
- colorMode: 'light',
140
- description: 'description',
141
- layout: undefined,
142
- route: undefined,
143
- title: undefined
144
- });
145
- });
146
- });
147
-
148
- describe('WHEN executed on the server', () => {
149
- test('THEN the store is always reinitialized', () => {
150
- const state = { layout: 'layout', description: 'des' };
151
- const { result, rerender } = renderHook(() => useCreateStore(state, true));
152
- let currentState = result.current().getState();
153
-
154
- expect(getStateToVerify(currentState)).toEqual({
155
- breadcrumbs: [],
156
- navigation: {},
157
- searchIndex: [],
158
- searchConfig: {},
159
- sidebarData: [],
160
- tableOfContents: [],
161
- sharedConfig: {},
162
- colorMode: 'light',
163
- ...state,
164
- route: undefined,
165
- title: undefined
166
- });
167
-
168
- // update the state and rerender
169
- state.layout = 'new';
170
- state.description = 'description';
171
- rerender();
172
-
173
- currentState = result.current().getState();
174
-
175
- expect(getStateToVerify(currentState)).toEqual({
176
- breadcrumbs: [],
177
- navigation: {},
178
- sidebarData: [],
179
- searchIndex: [],
180
- searchConfig: {},
181
- tableOfContents: [],
182
- sharedConfig: {},
183
- colorMode: 'light',
184
- description: 'description',
185
- layout: 'new',
186
- route: undefined,
187
- title: undefined
188
- });
189
- });
190
- });
191
- });
192
-
193
- describe('GIVEN the `useStore` hook', () => {
194
- describe('WHEN a selector is provided', () => {
195
- test('THEN the hook applies the selector and returns the selected state', () => {
196
- const { result } = renderHook(() => useStore(state => state.title), {
197
- wrapper: createWrapper({ title: 'title' })
198
- });
199
- expect(result.current).toEqual('title');
200
- });
201
- });
202
-
203
- describe('WHEN rendered outside of the StoreContext', () => {
204
- test('THEN the hook throws an error', () => {
205
- expect(() => renderHook(() => useStore(state => state.title))).toThrowError(
206
- 'Missing StoreProvider in the tree'
207
- );
208
- });
209
- });
210
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
-
4
- import { useCreateStore, StoreProvider } from '../../store';
5
- import type { SiteState } from '../../store';
6
-
7
- export function renderWithStore(ui: React.ReactElement) {
8
- const { rerender, ...result } = render(<Store>{ui}</Store>);
9
- return {
10
- ...result,
11
- rerender: (rerenderUi: React.ReactElement) => rerender(<Store>{rerenderUi}</Store>)
12
- };
13
- }
14
-
15
- export function createWrapper(state?: Partial<SiteState>) {
16
- return ({ children }: { children?: React.ReactNode }) => <Store state={state}>{children}</Store>;
17
- }
18
-
19
- /**
20
- *
21
- * @param state: initial state for the site store
22
- */
23
- const Store: React.FC<{ state?: Partial<SiteState> }> = ({ children, state = {} }) => {
24
- const createStore = useCreateStore(state);
25
- return <StoreProvider value={createStore()}>{children}</StoreProvider>;
26
- };