@equinor/fusion-framework-module-bookmark 3.0.6 → 4.0.0
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 +30 -18
- package/README.md +156 -255
- package/dist/esm/BookmarkClient.js +10 -0
- package/dist/esm/BookmarkClient.js.map +1 -1
- package/dist/esm/BookmarkConfigurator.js +8 -1
- package/dist/esm/BookmarkConfigurator.js.map +1 -1
- package/dist/esm/BookmarkProvider.error.js +17 -1
- package/dist/esm/BookmarkProvider.error.js.map +1 -1
- package/dist/esm/BookmarkProvider.selectors.js +14 -7
- package/dist/esm/BookmarkProvider.selectors.js.map +1 -1
- package/dist/esm/BookmarkProvider.store.js +6 -5
- package/dist/esm/BookmarkProvider.store.js.map +1 -1
- package/dist/esm/bookmark-config.schema.js +13 -0
- package/dist/esm/bookmark-config.schema.js.map +1 -1
- package/dist/esm/bookmark-module.js +16 -0
- package/dist/esm/bookmark-module.js.map +1 -1
- package/dist/esm/bookmark.schemas.js +22 -0
- package/dist/esm/bookmark.schemas.js.map +1 -1
- package/dist/esm/enable-bookmark.js +21 -3
- package/dist/esm/enable-bookmark.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/BookmarkClient.d.ts +10 -0
- package/dist/types/BookmarkConfigurator.d.ts +8 -1
- package/dist/types/BookmarkProvider.actions.d.ts +1 -0
- package/dist/types/BookmarkProvider.error.d.ts +18 -1
- package/dist/types/BookmarkProvider.interface.d.ts +37 -0
- package/dist/types/BookmarkProvider.selectors.d.ts +14 -7
- package/dist/types/BookmarkProvider.store.d.ts +16 -7
- package/dist/types/bookmark-config.schema.d.ts +13 -0
- package/dist/types/bookmark-module.d.ts +23 -0
- package/dist/types/bookmark.schemas.d.ts +22 -0
- package/dist/types/enable-bookmark.d.ts +21 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -13
- package/src/BookmarkClient.ts +10 -0
- package/src/BookmarkConfigurator.ts +8 -1
- package/src/BookmarkProvider.actions.ts +1 -0
- package/src/BookmarkProvider.error.ts +15 -0
- package/src/BookmarkProvider.interface.ts +37 -0
- package/src/BookmarkProvider.selectors.ts +14 -7
- package/src/BookmarkProvider.store.ts +16 -7
- package/src/bookmark-config.schema.ts +13 -0
- package/src/bookmark-module.ts +23 -0
- package/src/bookmark.schemas.ts +22 -0
- package/src/enable-bookmark.ts +21 -3
- package/src/version.ts +1 -1
|
@@ -8,7 +8,12 @@ import type { IBookmarkClient } from './BookmarkClient.interface';
|
|
|
8
8
|
import type { Bookmark, BookmarkWithoutData } from './types';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Internal state shape managed by the bookmark store.
|
|
12
|
+
*
|
|
13
|
+
* @property status - Set of base action types currently in-flight (used for loading indicators).
|
|
14
|
+
* @property errors - Map from base action type to the most recent error for that action.
|
|
15
|
+
* @property currentBookmark - The active bookmark, `null` when explicitly cleared, `undefined` before first set.
|
|
16
|
+
* @property bookmarks - Normalised record of bookmarks keyed by ID.
|
|
12
17
|
*/
|
|
13
18
|
export type BookmarkState = {
|
|
14
19
|
// current actions performed on the store
|
|
@@ -24,17 +29,21 @@ export type BookmarkState = {
|
|
|
24
29
|
// export type BookmarkStoreFunctions = ActionCalls<typeof bookmarkActions>;
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
*
|
|
32
|
+
* A {@link FlowSubject} specialised for bookmark state and actions.
|
|
33
|
+
*
|
|
34
|
+
* Combines a Redux-style reducer with RxJS side-effect flows to manage
|
|
35
|
+
* bookmark CRUD operations, favourites, and current-bookmark selection.
|
|
28
36
|
*/
|
|
29
37
|
export type BookmarkStore = FlowSubject<BookmarkState, BookmarkActions>;
|
|
30
38
|
|
|
31
39
|
/**
|
|
32
|
-
* Creates a new BookmarkStore
|
|
40
|
+
* Creates and returns a new {@link BookmarkStore} wired with the bookmark
|
|
41
|
+
* reducer and all API side-effect flows.
|
|
33
42
|
*
|
|
34
|
-
* @param args -
|
|
35
|
-
* @param args.initial -
|
|
36
|
-
* @param args.client - The IBookmarkClient
|
|
37
|
-
* @returns A
|
|
43
|
+
* @param args - Initialisation options.
|
|
44
|
+
* @param args.initial - Optional partial state merged over the reducer defaults.
|
|
45
|
+
* @param args.client - The {@link IBookmarkClient} used by store flows for API calls.
|
|
46
|
+
* @returns A fully configured bookmark store.
|
|
38
47
|
*/
|
|
39
48
|
export const createBookmarkStore = (args: {
|
|
40
49
|
initial?: Partial<BookmarkState>;
|
|
@@ -10,6 +10,12 @@ import type { IBookmarkClient } from './BookmarkClient.interface';
|
|
|
10
10
|
import { bookmarkSourceSystemSchema } from './bookmark.schemas';
|
|
11
11
|
import type { BookmarkModuleConfig } from './types';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Zod schema that validates the full {@link BookmarkModuleConfig} object.
|
|
15
|
+
*
|
|
16
|
+
* Used internally by {@link BookmarkModuleConfigurator} to verify the resolved
|
|
17
|
+
* configuration before the bookmark module is initialised.
|
|
18
|
+
*/
|
|
13
19
|
export const bookmarkConfigSchema = z.object({
|
|
14
20
|
log: z.custom<ILogger>().optional(),
|
|
15
21
|
logLevel: z.nativeEnum(LogLevel).optional(),
|
|
@@ -35,6 +41,13 @@ export const bookmarkConfigSchema = z.object({
|
|
|
35
41
|
.default({ context: false, application: false }),
|
|
36
42
|
});
|
|
37
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Parses an unknown configuration object against {@link bookmarkConfigSchema}.
|
|
46
|
+
*
|
|
47
|
+
* @param config - The raw config value to validate.
|
|
48
|
+
* @returns A validated {@link BookmarkModuleConfig}.
|
|
49
|
+
* @throws {ZodError} When validation fails.
|
|
50
|
+
*/
|
|
38
51
|
export const parseBookmarkConfig = (config: unknown): BookmarkModuleConfig => {
|
|
39
52
|
return bookmarkConfigSchema.parse(config) as BookmarkModuleConfig;
|
|
40
53
|
};
|
package/src/bookmark-module.ts
CHANGED
|
@@ -14,10 +14,18 @@ import { lastValueFrom } from 'rxjs';
|
|
|
14
14
|
import { version } from './version';
|
|
15
15
|
import type { IBookmarkProvider } from './BookmarkProvider.interface';
|
|
16
16
|
|
|
17
|
+
/** String literal key used to register the bookmark module in the framework. */
|
|
17
18
|
export type BookmarkModuleKey = 'bookmark';
|
|
18
19
|
|
|
20
|
+
/** The module key constant used to identify the bookmark module at runtime. */
|
|
19
21
|
export const moduleKey: BookmarkModuleKey = 'bookmark';
|
|
20
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Type definition for the bookmark framework module.
|
|
25
|
+
*
|
|
26
|
+
* Declares the module key, provider interface, configurator class,
|
|
27
|
+
* and optional peer dependencies (event, services, app, context modules).
|
|
28
|
+
*/
|
|
21
29
|
export type BookmarkModule = Module<
|
|
22
30
|
BookmarkModuleKey,
|
|
23
31
|
IBookmarkProvider,
|
|
@@ -28,6 +36,21 @@ export type BookmarkModule = Module<
|
|
|
28
36
|
// TODO - remove when all framework uses log
|
|
29
37
|
const fallbackLogger: ILogger = new ConsoleLogger('BookmarkModule');
|
|
30
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Bookmark module definition for the Fusion Framework.
|
|
41
|
+
*
|
|
42
|
+
* Handles configuration, initialization (creating a {@link BookmarkProvider}),
|
|
43
|
+
* and disposal of the bookmark module lifecycle.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { enableBookmark } from '@equinor/fusion-framework-module-bookmark';
|
|
48
|
+
*
|
|
49
|
+
* const configure = (configurator) => {
|
|
50
|
+
* enableBookmark(configurator);
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
31
54
|
export const module: BookmarkModule = {
|
|
32
55
|
name: moduleKey,
|
|
33
56
|
version: new SemanticVersion(version),
|
package/src/bookmark.schemas.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { Bookmark, BookmarkData } from './types';
|
|
3
3
|
|
|
4
|
+
/** Zod schema for validating {@link BookmarkUser} objects. */
|
|
4
5
|
export const bookmarkUserSchema = z.object({
|
|
5
6
|
id: z.string(),
|
|
6
7
|
name: z.string(),
|
|
7
8
|
mail: z.string().optional(),
|
|
8
9
|
});
|
|
9
10
|
|
|
11
|
+
/** Zod schema for validating {@link SourceSystem} objects on a bookmark. */
|
|
10
12
|
export const bookmarkSourceSystemSchema = z.object(
|
|
11
13
|
{
|
|
12
14
|
identifier: z.string(),
|
|
@@ -16,12 +18,14 @@ export const bookmarkSourceSystemSchema = z.object(
|
|
|
16
18
|
{ message: 'invalid source system' },
|
|
17
19
|
);
|
|
18
20
|
|
|
21
|
+
/** Zod schema for validating {@link BookmarkContext} objects. */
|
|
19
22
|
export const bookmarkContextSchema = z.object({
|
|
20
23
|
id: z.string(),
|
|
21
24
|
name: z.string().optional(),
|
|
22
25
|
type: z.string().optional(),
|
|
23
26
|
});
|
|
24
27
|
|
|
28
|
+
/** Zod schema for validating a {@link BookmarkWithoutData} (no payload). */
|
|
25
29
|
export const bookmarkSchema = z.object({
|
|
26
30
|
id: z.string(),
|
|
27
31
|
name: z.string(),
|
|
@@ -36,8 +40,18 @@ export const bookmarkSchema = z.object({
|
|
|
36
40
|
sourceSystem: bookmarkSourceSystemSchema.nullish(),
|
|
37
41
|
});
|
|
38
42
|
|
|
43
|
+
/** Zod schema for validating an array of bookmarks. */
|
|
39
44
|
export const bookmarksSchema = z.array(bookmarkSchema);
|
|
40
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Zod schema for a {@link Bookmark} that includes a typed payload field.
|
|
48
|
+
*
|
|
49
|
+
* @template T - The bookmark payload data shape.
|
|
50
|
+
* @template S - Zod schema type for the payload.
|
|
51
|
+
* @param schema - Optional Zod schema to validate the payload. Defaults to
|
|
52
|
+
* `z.record(z.string(), z.unknown()).or(z.string()).optional()`.
|
|
53
|
+
* @returns A Zod object schema extending {@link bookmarkSchema} with a `payload` property.
|
|
54
|
+
*/
|
|
41
55
|
export const bookmarkWithDataSchema = <
|
|
42
56
|
T extends BookmarkData = BookmarkData,
|
|
43
57
|
S extends z.ZodSchema<T> = z.ZodSchema<T>,
|
|
@@ -48,6 +62,14 @@ export const bookmarkWithDataSchema = <
|
|
|
48
62
|
payload: schema,
|
|
49
63
|
});
|
|
50
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Parses an unknown value into a typed {@link Bookmark} using {@link bookmarkWithDataSchema}.
|
|
67
|
+
*
|
|
68
|
+
* @template T - The bookmark payload data shape.
|
|
69
|
+
* @param value - The raw value to parse.
|
|
70
|
+
* @returns The parsed bookmark object.
|
|
71
|
+
* @throws {ZodError} When validation fails.
|
|
72
|
+
*/
|
|
51
73
|
export const parseBookmark = <T extends BookmarkData>(value: unknown): Bookmark<T> => {
|
|
52
74
|
return bookmarkWithDataSchema().parse(value) as Bookmark<T>;
|
|
53
75
|
};
|
package/src/enable-bookmark.ts
CHANGED
|
@@ -4,10 +4,28 @@ import { module } from './bookmark-module';
|
|
|
4
4
|
import type { BookmarkModuleConfigurator } from './BookmarkConfigurator';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Enables the
|
|
7
|
+
* Enables the bookmark module on a Fusion Framework module configurator.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* This is the primary entry point for adding bookmark support to an application.
|
|
10
|
+
* Call it during the application’s configure phase to register the module.
|
|
11
|
+
* An optional callback allows further customisation of the bookmark configurator
|
|
12
|
+
* (source system, filters, custom client, etc.).
|
|
13
|
+
*
|
|
14
|
+
* @param configurator - The application’s module configurator instance.
|
|
15
|
+
* @param callback - Optional callback that receives the {@link BookmarkModuleConfigurator}
|
|
16
|
+
* for additional setup such as setting source system, filters, or a custom client.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { enableBookmark } from '@equinor/fusion-framework-module-bookmark';
|
|
21
|
+
*
|
|
22
|
+
* const configure = (configurator) => {
|
|
23
|
+
* enableBookmark(configurator, (builder) => {
|
|
24
|
+
* builder.setSourceSystem({ identifier: 'my-app', name: 'My App' });
|
|
25
|
+
* builder.setFilter('application', true);
|
|
26
|
+
* });
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
11
29
|
*/
|
|
12
30
|
export const enableBookmark = (
|
|
13
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '4.0.0';
|