@equinor/fusion-framework-module-bookmark 1.2.7 → 1.2.8

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.
@@ -12,12 +12,72 @@ export declare class BookmarkConfigBuilder<TModules extends Array<AnyModule> = [
12
12
  constructor(init: TInit, config?: Partial<BookmarkModuleConfig>);
13
13
  requireInstance<TKey extends string = Extract<keyof Modules, string>>(module: TKey): Promise<ModuleType<Modules[TKey]>>;
14
14
  requireInstance<T>(module: string): Promise<T>;
15
+ /**
16
+ *
17
+ * This will sett the SourceSystem used when creating a new bookmark,
18
+ * used as the identifier for the current client. Only used in app shell / portal configuration.
19
+ *
20
+ * @param {SourceSystem} sourceSystem
21
+ * ```ts
22
+ * interface SourceSystem {
23
+ * identifier: string;
24
+ * name: string;
25
+ * subSystem: string;
26
+ * }
27
+ * ```
28
+ * @memberof BookmarkConfigBuilder
29
+ */
15
30
  setSourceSystem(sourceSystem: SourceSystem): void;
31
+ /**
32
+ * Used to over write the default Url id resolving.
33
+ *
34
+ * @param {(() => string | null)} fn - Resolver for bookmarkId
35
+ * @memberof BookmarkConfigBuilder
36
+ */
16
37
  setBookmarkIdResolver(fn: () => string | null): void;
38
+ /**
39
+ * This allow for custom BookmarkApiClient to be added.
40
+ *
41
+ * @param {BookmarksApiClient<'fetch', IHttpClient, Bookmark<unknown>>} client - Custom Api client
42
+ * @memberof BookmarkConfigBuilder
43
+ */
17
44
  serCustomBookmarkApiClient(client: BookmarksApiClient<'fetch', IHttpClient, Bookmark<unknown>>): void;
45
+ /**
46
+ * Used to over with the default context id resolver.
47
+ *
48
+ * @param {(() => string | undefined)} fn - Function for providing current contextId
49
+ * @memberof BookmarkConfigBuilder
50
+ */
18
51
  setContextIdResolver(fn: () => string | undefined): void;
52
+ /**
53
+ * Used to over withe the default function for getting the current applications
54
+ * key identifier.
55
+ *
56
+ * @param {(() => string | undefined)} - A function for getting the current application key
57
+ * @memberof BookmarkConfigBuilder
58
+ */
19
59
  setCurrentAppIdResolver(fn: () => string | undefined): void;
60
+ /**
61
+ * Enable the over write default Event provider if needed.
62
+ * Should not be used if all event providers are changes in the current environment
63
+ *
64
+ * @param {IEventModuleProvider} provider - Custom Event provider
65
+ * @memberof BookmarkConfigBuilder
66
+ */
20
67
  setEventProvider(provider: IEventModuleProvider): void;
68
+ /**
69
+ * Use for override the bookmark query client
70
+ *
71
+ * @param {({
72
+ * getAllBookmarks:
73
+ * | QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters>
74
+ * | QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
75
+ * getBookmarkById:
76
+ * | QueryFn<Bookmark<unknown>, GetBookmarkParameters>
77
+ * | QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
78
+ * })} client - Custom client definition.
79
+ * @memberof BookmarkConfigBuilder
80
+ */
21
81
  setBookmarkQueryClient(client: {
22
82
  getAllBookmarks: QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters> | QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
23
83
  getBookmarkById: QueryFn<Bookmark<unknown>, GetBookmarkParameters> | QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
@@ -4,28 +4,127 @@ import { BookmarkModuleConfig } from './configurator';
4
4
  import { Observable } from 'rxjs';
5
5
  import { Bookmark, PatchBookmark, UpdateBookmarkOptions } from './types';
6
6
  export interface IBookmarkModuleProvider {
7
+ /**
8
+ * @type {BookmarkModuleConfig} Readonly configuration for the Bookmark Module used as a backdoor enabling bookmark configuration in a sub application.
9
+ */
7
10
  readonly config: BookmarkModuleConfig;
11
+ /**
12
+ * Observable Bookmark providing current resolved bookmark.
13
+ * @type {(Observable<Bookmark<any> | undefined>)}
14
+ */
8
15
  readonly currentBookmark$: Observable<Bookmark<any> | undefined>;
16
+ /**
17
+ *
18
+ * Observable list of bookmarks in the current configured system,
19
+ * filtered by the confirmed SourceSystem identifier. This is done by the portal development team;
20
+ * @type {Observable<Array<Bookmark<unknown>>>}
21
+ */
9
22
  readonly bookmarks$: Observable<Array<Bookmark<unknown>>>;
23
+ /**
24
+ * The current bookmark available
25
+ * @type {Bookmark<unknown>}
26
+ */
10
27
  currentBookmark?: Bookmark<unknown>;
28
+ /**
29
+ * Function fo setting the current applications state creator, is used to collect the state stored in a bookmark.
30
+ * This will enable the bookmark functionality for the application.
31
+ *
32
+ * @template T - Payload Type
33
+ * @param {CreateBookmarkFn<T>} cb - For creating the bookmark payload, this should ne wrapped in a useCallback, payload return can be a partial.
34
+ * @param {keyof T} [key] - User to that property to add partial payload to ,
35
+ * @return {*} {VoidFunction} - Return a cleanup function for removing the stateCreator.
36
+ */
11
37
  addStateCreator<T>(cb: CreateBookmarkFn<T>, key?: keyof T): VoidFunction;
38
+ /**
39
+ * Function for resolving a bookmark form api client
40
+ * @template T - Bookmark Payload type.
41
+ * @param {string} bookmarkId - bookmark indemnificator.
42
+ * @returns {Promise<Bookmark<T>>}
43
+ */
12
44
  getBookmarkById<T>(bookmarkId: string): Promise<Bookmark<T>>;
45
+ /**
46
+ * Function for resolving all bookmarks for the current sub system.
47
+ * @return {Observable<Bookmark<T>>} - An observable of the all Bookmarks.
48
+ */
13
49
  getAllBookmarks(): Observable<Array<Bookmark>>;
50
+ /**
51
+ * Function for resolving all bookmarks forthe current sub system.
52
+ * @return {Promise<Array<Bookmark<T><>} - Promise of all Bookmarks
53
+ */
14
54
  getAllBookmarksAsync(): Promise<Array<Bookmark>>;
55
+ /**
56
+ * Function for updating bookmark a bookmark when successful this will update the bookmark list.
57
+ * @template T - Payload Type
58
+ * @param {string} bookmarkId
59
+ * @param {Bookmark<T>} bookmark
60
+ * @return {Observable<Bookmark<T>>} - An observable of the updated Bookmark.
61
+ */
15
62
  updateBookmark<T>(bookmark: Bookmark<T>): Observable<Bookmark<T>>;
63
+ /**
64
+ * Function for updating bookmark a bookmark when successful this will update the bookmark list.
65
+ * @template T - Payload Type
66
+ * @param {string} bookmarkId
67
+ * @param {Bookmark<T>} bookmark
68
+ * @param {UpdateBookmarkOptions} options - optional options that allow for configuration of bookmark payload update.
69
+ * @return {Promise<Bookmark<T>>} - Promise of a Bookmark
70
+ */
16
71
  updateBookmarkAsync<T>(bookmark: PatchBookmark<T>, options?: UpdateBookmarkOptions): Promise<Bookmark<T> | undefined>;
72
+ /**
73
+ * Function for deleting a bookmark, when successful this will update the bookmark list.
74
+ * @param {string} bookmarkId
75
+ * @return {Observable<string>} Observable of the deletes BookmarkId
76
+ */
17
77
  deleteBookmarkById(bookmarkId: string): Observable<string>;
78
+ /**
79
+ * Function for deleting a bookmark, when successful this will update the bookmark list.
80
+ * @param {string} bookmarkId
81
+ * @return {Promise<string>} - Promise of the deleted bookmarkId
82
+ */
18
83
  deleteBookmarkByIdAsync(bookmarkId: string): Promise<string>;
84
+ /**
85
+ * Function for adding external bookmark to user's bookmarks.
86
+ * @param {string} bookmarkId
87
+ * @return {Promise<string>} void
88
+ */
19
89
  addBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
90
+ /**
91
+ * Function for removing external bookmark to user's bookmarks.
92
+ * @param {string} bookmarkId
93
+ * @return {Promise<void>} - void
94
+ */
20
95
  removeBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
96
+ /**
97
+ * Function for verifying that a bookmark belongs to the current user.
98
+ * @param {string} bookmarkId
99
+ * @return {Promise<string>} - void
100
+ */
21
101
  verifyBookmarkFavoriteAsync(bookmarkId: string): Promise<boolean>;
102
+ /**
103
+ * Function for setting the current bookmark, when successful this will update the bookmark list.
104
+ * @template TData - Bookmark payload type.
105
+ * @param {(string | Bookmark<TData> | undefined)} idOrItem - can be full bookmark object or bookmarkId.
106
+ * If not provided the current bookmark state will be set to undefined.
107
+ */
22
108
  setCurrentBookmark<TData>(idOrItem?: string | Bookmark<TData>): void;
109
+ /**
110
+ * Creates a new bookmark with the given arguments, and utilizes teh provided stateCreator to create the bookmark payload.
111
+ * @param {{ name: string; description: string; isShared: boolean }} args - Name, Description and isSheared
112
+ */
23
113
  createBookmark<T>(args: {
24
114
  name: string;
25
115
  description: string;
26
116
  isShared: boolean;
27
117
  }): Promise<Bookmark<T>>;
118
+ /**
119
+ * A parent provider if configuration if application is needed. A backdoor enabling bookmark configuration in a sub application.
120
+ * This is not recommence and may result in unwanted behaviors if not used correctly.
121
+ * @type {IBookmarkModuleProvider}
122
+ */
28
123
  parentBookmarkProvider?: IBookmarkModuleProvider;
124
+ /**
125
+ * Record of state creator, is used to collect the state stored in a bookmark.
126
+ * @type {Record<string, CreateBookmarkFn<unknown>>}
127
+ */
29
128
  bookmarkCreators: Record<string, CreateBookmarkFn<unknown>>;
30
129
  }
31
130
  export type CreateBookmarkFn<T> = () => Promise<Partial<T>> | Partial<T>;
@@ -60,6 +159,7 @@ export declare class BookmarkModuleProvider implements IBookmarkModuleProvider {
60
159
  }
61
160
  declare module '@equinor/fusion-framework-module-event' {
62
161
  interface FrameworkEventMap {
162
+ /** dispatch before context changes */
63
163
  onNavigateToApp: FrameworkEvent<FrameworkEventInit<URL, IBookmarkModuleProvider>>;
64
164
  onAddCreator: FrameworkEvent<FrameworkEventInit<{
65
165
  cb: CreateBookmarkFn<unknown>;
@@ -41,7 +41,9 @@ export declare class BookmarkClient {
41
41
  }
42
42
  declare module '@equinor/fusion-framework-module-event' {
43
43
  interface FrameworkEventMap {
44
+ /** dispatch before bookmark changes */
44
45
  onBookmarkChanged: FrameworkEvent<FrameworkEventInit<Bookmark<unknown>, BookmarkClient>>;
46
+ /** dispatch before bookmarks changes */
45
47
  onBookmarksChanged: FrameworkEvent<FrameworkEventInit<Array<Bookmark<unknown>>, BookmarkClient>>;
46
48
  onBookmarkCreated: FrameworkEvent<FrameworkEventInit<Bookmark<unknown>, BookmarkClient>>;
47
49
  onBookmarkUpdated: FrameworkEvent<FrameworkEventInit<Bookmark<unknown>, BookmarkClient>>;
@@ -8,15 +8,15 @@ export declare const handleBookmarkGetAll: (queryAllBookmarks: Query<Array<Bookm
8
8
  payload: Bookmark<unknown>[];
9
9
  type: "getAll::success";
10
10
  }>;
11
- export declare const handleCreateBookmark: (apiClient: BookmarksApiClient<'fetch', IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
11
+ export declare const handleCreateBookmark: (apiClient: BookmarksApiClient<"fetch", IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
12
12
  payload: Bookmark<unknown>;
13
13
  type: "create::success";
14
14
  }>;
15
- export declare const handleUpdateBookmark: (apiClient: BookmarksApiClient<'fetch', IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
15
+ export declare const handleUpdateBookmark: (apiClient: BookmarksApiClient<"fetch", IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
16
16
  payload: Bookmark<unknown>;
17
17
  type: "update::success";
18
18
  }>;
19
- export declare const handleDeleteBookmark: (apiClient: BookmarksApiClient<'fetch', IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
19
+ export declare const handleDeleteBookmark: (apiClient: BookmarksApiClient<"fetch", IHttpClient, unknown>) => (action$: Observable<Actions>) => Observable<{
20
20
  payload: string;
21
21
  type: "delete::success";
22
22
  }>;
@@ -8,15 +8,45 @@ import type { EventModule, IEventModuleProvider } from '@equinor/fusion-framewor
8
8
  import type { IBookmarkModuleProvider } from './bookmark-provider';
9
9
  import type { BookmarkClientConfig } from './client/bookmarkClient';
10
10
  export interface BookmarkModuleConfig {
11
+ /**
12
+ * SourceSystem used when creating a new bookmark,
13
+ * used as the identifier for the current client. Only used in app shell / portal configuration.
14
+ */
11
15
  sourceSystem?: SourceSystem;
16
+ /**
17
+ * The clintConfiguration consist of both Api client configuration and query client configuration
18
+ */
12
19
  clientConfiguration: BookmarkClientConfig;
20
+ /**
21
+ * It is possible to associate a Fusion context with a bookmark and this function is used to resolve the current context id applied.
22
+ * @returns - should return a fusion context id.
23
+ */
13
24
  getContextId: () => string | undefined;
25
+ /**
26
+ * A bookmark kan be connected to a application this is used to resolve the current applications appKey.
27
+ */
14
28
  getCurrentAppIdentification?(): string | undefined;
29
+ /**
30
+ * The resolves bookmarkId at startup, default configured to resolve id form URL with query parm
31
+ * ?bookmarkId=GUID but this can be resolved for any where if needed.
32
+ */
15
33
  resolveBookmarkId?(): string | null;
34
+ /**
35
+ * default set to Fusion Events Module.
36
+ */
16
37
  event?: IEventModuleProvider;
17
38
  }
18
39
  export type IBookmarkModuleConfigurator = {
40
+ /**
41
+ * @param init BookmarkConfigBuilderCallback for configuring the bookmark module.
42
+ * Configuration is only needed for application shell / portals.
43
+ */
19
44
  addConfigBuilder(init: BookmarkConfigBuilderCallback): void;
45
+ /**
46
+ * Bookmark Config Factory Providing default configuration if no configuration is provided.
47
+ * @param init ModuleInitializerArgs<IBookmarkModuleConfigurator, [ServicesModule, AppModule, ContextModule]>
48
+ * @param parentProvider Parent IBookmarkModuleProvider
49
+ */
20
50
  createConfig(init: ModuleInitializerArgs<IBookmarkModuleConfigurator, [
21
51
  ServicesModule,
22
52
  AppModule,
@@ -1,4 +1,8 @@
1
1
  import type { AnyModule, IModulesConfigurator, ModuleInitializerArgs } from '@equinor/fusion-framework-module';
2
2
  import { BookmarkConfigBuilder } from './bookmark-config-builder';
3
3
  import { IBookmarkModuleConfigurator } from './configurator';
4
- export declare const enableBookmark: (configurator: IModulesConfigurator<any, any>, builder?: (<TDeps extends AnyModule[] = []>(builder: BookmarkConfigBuilder<TDeps, ModuleInitializerArgs<IBookmarkModuleConfigurator, TDeps>>) => void | Promise<void>) | undefined) => void;
4
+ /**
5
+ * Method for enabling Bookmark module
6
+ * @param configurator - configuration object
7
+ */
8
+ export declare const enableBookmark: (configurator: IModulesConfigurator<any, any>, builder?: <TDeps extends Array<AnyModule> = []>(builder: BookmarkConfigBuilder<TDeps, ModuleInitializerArgs<IBookmarkModuleConfigurator, TDeps>>) => void | Promise<void>) => void;
@@ -18,11 +18,15 @@ export interface Bookmark<TData = unknown> {
18
18
  sourceSystem?: SourceSystem;
19
19
  }
20
20
  export type CreateBookmark<TData = unknown> = {
21
+ /** Display name of the bookmark */
21
22
  name: string;
22
23
  description?: string;
24
+ /** Is the bookmark shared with others */
23
25
  isShared: boolean;
26
+ /** Name of the app it belongs too, should correspond to a fusion appkey */
24
27
  appKey: string;
25
28
  contextId?: string;
29
+ /** Any JSON object to store as the bookmark payload */
26
30
  payload: TData;
27
31
  sourceSystem?: Partial<SourceSystem>;
28
32
  };
@@ -1 +1 @@
1
- export declare const version = "1.2.7";
1
+ export declare const version = "1.2.8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-bookmark",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "main": "./dist/esm/index.js",
6
6
  "exports": {
@@ -35,17 +35,17 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "rxjs": "^7.8.1",
38
- "@equinor/fusion-framework-module": "^4.3.1",
39
- "@equinor/fusion-query": "^5.0.5",
40
- "@equinor/fusion-observable": "^8.3.2"
38
+ "@equinor/fusion-framework-module": "^4.3.2",
39
+ "@equinor/fusion-observable": "^8.3.3",
40
+ "@equinor/fusion-query": "^5.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "typescript": "^5.4.2",
44
- "@equinor/fusion-framework-module-app": "^5.3.7",
45
- "@equinor/fusion-framework-module-context": "^5.0.7",
46
- "@equinor/fusion-framework-module-event": "^4.1.2",
47
- "@equinor/fusion-framework-module-http": "^6.0.0",
48
- "@equinor/fusion-framework-module-services": "^4.1.0"
43
+ "typescript": "^5.5.3",
44
+ "@equinor/fusion-framework-module-app": "^5.3.8",
45
+ "@equinor/fusion-framework-module-event": "^4.2.0",
46
+ "@equinor/fusion-framework-module-http": "^6.0.1",
47
+ "@equinor/fusion-framework-module-context": "^5.0.8",
48
+ "@equinor/fusion-framework-module-services": "^4.1.1"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsc -b"
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '1.2.7';
2
+ export const version = '1.2.8';