@equinor/fusion-framework-module-bookmark 1.2.13 → 2.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 +37 -0
- package/README.md +242 -9
- package/dist/esm/BookmarkClient.interface.js +2 -0
- package/dist/esm/BookmarkClient.interface.js.map +1 -0
- package/dist/esm/BookmarkClient.js +174 -0
- package/dist/esm/BookmarkClient.js.map +1 -0
- package/dist/esm/BookmarkConfigurator.js +348 -0
- package/dist/esm/BookmarkConfigurator.js.map +1 -0
- package/dist/esm/BookmarkProvider.actions.js +60 -0
- package/dist/esm/BookmarkProvider.actions.js.map +1 -0
- package/dist/esm/BookmarkProvider.error.js +14 -0
- package/dist/esm/BookmarkProvider.error.js.map +1 -0
- package/dist/esm/BookmarkProvider.events.js +2 -0
- package/dist/esm/BookmarkProvider.events.js.map +1 -0
- package/dist/esm/BookmarkProvider.flows.js +219 -0
- package/dist/esm/BookmarkProvider.flows.js.map +1 -0
- package/dist/esm/BookmarkProvider.js +937 -0
- package/dist/esm/BookmarkProvider.js.map +1 -0
- package/dist/esm/BookmarkProvider.reducer.js +125 -0
- package/dist/esm/BookmarkProvider.reducer.js.map +1 -0
- package/dist/esm/BookmarkProvider.selectors.js +43 -0
- package/dist/esm/BookmarkProvider.selectors.js.map +1 -0
- package/dist/esm/BookmarkProvider.store.js +19 -0
- package/dist/esm/BookmarkProvider.store.js.map +1 -0
- package/dist/esm/bookmark-config.schema.js +30 -0
- package/dist/esm/bookmark-config.schema.js.map +1 -0
- package/dist/esm/bookmark-module.js +53 -0
- package/dist/esm/bookmark-module.js.map +1 -0
- package/dist/esm/bookmark.schemas.js +38 -0
- package/dist/esm/bookmark.schemas.js.map +1 -0
- package/dist/esm/enable-bookmark.js +20 -7
- package/dist/esm/enable-bookmark.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/BookmarkClient.d.ts +42 -0
- package/dist/types/BookmarkClient.interface.d.ts +139 -0
- package/dist/types/BookmarkConfigurator.d.ts +100 -0
- package/dist/types/BookmarkProvider.actions.d.ts +525 -0
- package/dist/types/BookmarkProvider.d.ts +462 -0
- package/dist/types/BookmarkProvider.error.d.ts +9 -0
- package/dist/types/BookmarkProvider.events.d.ts +78 -0
- package/dist/types/BookmarkProvider.flows.d.ts +79 -0
- package/dist/types/BookmarkProvider.reducer.d.ts +302 -0
- package/dist/types/BookmarkProvider.selectors.d.ts +34 -0
- package/dist/types/BookmarkProvider.store.d.ts +30 -0
- package/dist/types/bookmark-config.schema.d.ts +118 -0
- package/dist/types/{module.d.ts → bookmark-module.d.ts} +3 -3
- package/dist/types/bookmark.schemas.d.ts +760 -0
- package/dist/types/enable-bookmark.d.ts +7 -6
- package/dist/types/index.d.ts +4 -3
- package/dist/types/types.d.ts +29 -65
- package/dist/types/version.d.ts +1 -1
- package/package.json +11 -5
- package/src/BookmarkClient.interface.ts +157 -0
- package/src/BookmarkClient.ts +226 -0
- package/src/BookmarkConfigurator.ts +374 -0
- package/src/BookmarkProvider.actions.ts +131 -0
- package/src/BookmarkProvider.error.ts +21 -0
- package/src/BookmarkProvider.events.ts +89 -0
- package/src/BookmarkProvider.flows.ts +426 -0
- package/src/BookmarkProvider.reducer.ts +141 -0
- package/src/BookmarkProvider.selectors.ts +55 -0
- package/src/BookmarkProvider.store.ts +52 -0
- package/src/BookmarkProvider.ts +1308 -0
- package/src/bookmark-config.schema.ts +41 -0
- package/src/bookmark-module.ts +70 -0
- package/src/bookmark.schemas.ts +50 -0
- package/src/enable-bookmark.ts +13 -20
- package/src/index.ts +15 -7
- package/src/types.ts +46 -73
- package/src/version.ts +1 -1
- package/dist/esm/bookmark-config-builder.js +0 -131
- package/dist/esm/bookmark-config-builder.js.map +0 -1
- package/dist/esm/bookmark-provider.js +0 -155
- package/dist/esm/bookmark-provider.js.map +0 -1
- package/dist/esm/client/bookmarkActions.js +0 -10
- package/dist/esm/client/bookmarkActions.js.map +0 -1
- package/dist/esm/client/bookmarkClient.js +0 -259
- package/dist/esm/client/bookmarkClient.js.map +0 -1
- package/dist/esm/client/bookmarkFlows.js +0 -31
- package/dist/esm/client/bookmarkFlows.js.map +0 -1
- package/dist/esm/client/bookmarkReducer.js +0 -29
- package/dist/esm/client/bookmarkReducer.js.map +0 -1
- package/dist/esm/configurator.js +0 -155
- package/dist/esm/configurator.js.map +0 -1
- package/dist/esm/module.js +0 -27
- package/dist/esm/module.js.map +0 -1
- package/dist/esm/utils/handle-url.js +0 -11
- package/dist/esm/utils/handle-url.js.map +0 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/types/bookmark-config-builder.d.ts +0 -85
- package/dist/types/bookmark-provider.d.ts +0 -169
- package/dist/types/client/bookmarkActions.d.ts +0 -27
- package/dist/types/client/bookmarkClient.d.ts +0 -53
- package/dist/types/client/bookmarkFlows.d.ts +0 -22
- package/dist/types/client/bookmarkReducer.d.ts +0 -5
- package/dist/types/configurator.d.ts +0 -75
- package/dist/types/utils/handle-url.d.ts +0 -2
- package/dist/types/utils/index.d.ts +0 -1
- package/src/bookmark-config-builder.ts +0 -177
- package/src/bookmark-provider.ts +0 -344
- package/src/client/bookmarkActions.ts +0 -44
- package/src/client/bookmarkClient.ts +0 -327
- package/src/client/bookmarkFlows.ts +0 -67
- package/src/client/bookmarkReducer.ts +0 -35
- package/src/configurator.ts +0 -235
- package/src/module.ts +0 -40
- package/src/utils/handle-url.ts +0 -13
- package/src/utils/index.ts +0 -1
package/src/bookmark-provider.ts
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { ModuleType } from '@equinor/fusion-framework-module';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
EventModule,
|
|
5
|
-
FrameworkEvent,
|
|
6
|
-
FrameworkEventInit,
|
|
7
|
-
} from '@equinor/fusion-framework-module-event';
|
|
8
|
-
|
|
9
|
-
import { BookmarkClient } from './client/bookmarkClient';
|
|
10
|
-
|
|
11
|
-
import { BookmarkModuleConfig } from './configurator';
|
|
12
|
-
import { Observable, Subscription } from 'rxjs';
|
|
13
|
-
import { Bookmark, CreateBookmark, PatchBookmark, UpdateBookmarkOptions } from './types';
|
|
14
|
-
|
|
15
|
-
export interface IBookmarkModuleProvider {
|
|
16
|
-
/**
|
|
17
|
-
* @type {BookmarkModuleConfig} Readonly configuration for the Bookmark Module used as a backdoor enabling bookmark configuration in a sub application.
|
|
18
|
-
*/
|
|
19
|
-
readonly config: BookmarkModuleConfig;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Observable Bookmark providing current resolved bookmark.
|
|
23
|
-
* @type {(Observable<Bookmark<any> | undefined>)}
|
|
24
|
-
*/
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
readonly currentBookmark$: Observable<Bookmark<any> | undefined>;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* Observable list of bookmarks in the current configured system,
|
|
30
|
-
* filtered by the confirmed SourceSystem identifier. This is done by the portal development team;
|
|
31
|
-
* @type {Observable<Array<Bookmark<unknown>>>}
|
|
32
|
-
*/
|
|
33
|
-
readonly bookmarks$: Observable<Array<Bookmark<unknown>>>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The current bookmark available
|
|
37
|
-
* @type {Bookmark<unknown>}
|
|
38
|
-
*/
|
|
39
|
-
currentBookmark?: Bookmark<unknown>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Function fo setting the current applications state creator, is used to collect the state stored in a bookmark.
|
|
43
|
-
* This will enable the bookmark functionality for the application.
|
|
44
|
-
*
|
|
45
|
-
* @template T - Payload Type
|
|
46
|
-
* @param {CreateBookmarkFn<T>} cb - For creating the bookmark payload, this should ne wrapped in a useCallback, payload return can be a partial.
|
|
47
|
-
* @param {keyof T} [key] - User to that property to add partial payload to ,
|
|
48
|
-
* @return {*} {VoidFunction} - Return a cleanup function for removing the stateCreator.
|
|
49
|
-
*/
|
|
50
|
-
addStateCreator<T>(cb: CreateBookmarkFn<T>, key?: keyof T): VoidFunction;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Function for resolving a bookmark form api client
|
|
54
|
-
* @template T - Bookmark Payload type.
|
|
55
|
-
* @param {string} bookmarkId - bookmark indemnificator.
|
|
56
|
-
* @returns {Promise<Bookmark<T>>}
|
|
57
|
-
*/
|
|
58
|
-
getBookmarkById<T>(bookmarkId: string): Promise<Bookmark<T>>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Function for resolving all bookmarks for the current sub system.
|
|
62
|
-
* @return {Observable<Bookmark<T>>} - An observable of the all Bookmarks.
|
|
63
|
-
*/
|
|
64
|
-
getAllBookmarks(): Observable<Array<Bookmark>>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Function for resolving all bookmarks forthe current sub system.
|
|
68
|
-
* @return {Promise<Array<Bookmark<T><>} - Promise of all Bookmarks
|
|
69
|
-
*/
|
|
70
|
-
getAllBookmarksAsync(): Promise<Array<Bookmark>>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Function for updating bookmark a bookmark when successful this will update the bookmark list.
|
|
74
|
-
* @template T - Payload Type
|
|
75
|
-
* @param {string} bookmarkId
|
|
76
|
-
* @param {Bookmark<T>} bookmark
|
|
77
|
-
* @return {Observable<Bookmark<T>>} - An observable of the updated Bookmark.
|
|
78
|
-
*/
|
|
79
|
-
updateBookmark<T>(bookmark: Bookmark<T>): Observable<Bookmark<T>>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Function for updating bookmark a bookmark when successful this will update the bookmark list.
|
|
83
|
-
* @template T - Payload Type
|
|
84
|
-
* @param {string} bookmarkId
|
|
85
|
-
* @param {Bookmark<T>} bookmark
|
|
86
|
-
* @param {UpdateBookmarkOptions} options - optional options that allow for configuration of bookmark payload update.
|
|
87
|
-
* @return {Promise<Bookmark<T>>} - Promise of a Bookmark
|
|
88
|
-
*/
|
|
89
|
-
updateBookmarkAsync<T>(
|
|
90
|
-
bookmark: PatchBookmark<T>,
|
|
91
|
-
options?: UpdateBookmarkOptions,
|
|
92
|
-
): Promise<Bookmark<T> | undefined>;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Function for deleting a bookmark, when successful this will update the bookmark list.
|
|
96
|
-
* @param {string} bookmarkId
|
|
97
|
-
* @return {Observable<string>} Observable of the deletes BookmarkId
|
|
98
|
-
*/
|
|
99
|
-
deleteBookmarkById(bookmarkId: string): Observable<string>;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Function for deleting a bookmark, when successful this will update the bookmark list.
|
|
103
|
-
* @param {string} bookmarkId
|
|
104
|
-
* @return {Promise<string>} - Promise of the deleted bookmarkId
|
|
105
|
-
*/
|
|
106
|
-
deleteBookmarkByIdAsync(bookmarkId: string): Promise<string>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Function for adding external bookmark to user's bookmarks.
|
|
110
|
-
* @param {string} bookmarkId
|
|
111
|
-
* @return {Promise<string>} void
|
|
112
|
-
*/
|
|
113
|
-
addBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Function for removing external bookmark to user's bookmarks.
|
|
117
|
-
* @param {string} bookmarkId
|
|
118
|
-
* @return {Promise<void>} - void
|
|
119
|
-
*/
|
|
120
|
-
removeBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Function for verifying that a bookmark belongs to the current user.
|
|
124
|
-
* @param {string} bookmarkId
|
|
125
|
-
* @return {Promise<string>} - void
|
|
126
|
-
*/
|
|
127
|
-
verifyBookmarkFavoriteAsync(bookmarkId: string): Promise<boolean>;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Function for setting the current bookmark, when successful this will update the bookmark list.
|
|
131
|
-
* @template TData - Bookmark payload type.
|
|
132
|
-
* @param {(string | Bookmark<TData> | undefined)} idOrItem - can be full bookmark object or bookmarkId.
|
|
133
|
-
* If not provided the current bookmark state will be set to undefined.
|
|
134
|
-
*/
|
|
135
|
-
setCurrentBookmark<TData>(idOrItem?: string | Bookmark<TData>): void;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Creates a new bookmark with the given arguments, and utilizes teh provided stateCreator to create the bookmark payload.
|
|
139
|
-
* @param {{ name: string; description: string; isShared: boolean }} args - Name, Description and isSheared
|
|
140
|
-
*/
|
|
141
|
-
createBookmark<T>(args: {
|
|
142
|
-
name: string;
|
|
143
|
-
description: string;
|
|
144
|
-
isShared: boolean;
|
|
145
|
-
}): Promise<Bookmark<T>>;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* A parent provider if configuration if application is needed. A backdoor enabling bookmark configuration in a sub application.
|
|
149
|
-
* This is not recommence and may result in unwanted behaviors if not used correctly.
|
|
150
|
-
* @type {IBookmarkModuleProvider}
|
|
151
|
-
*/
|
|
152
|
-
parentBookmarkProvider?: IBookmarkModuleProvider;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Record of state creator, is used to collect the state stored in a bookmark.
|
|
156
|
-
* @type {Record<string, CreateBookmarkFn<unknown>>}
|
|
157
|
-
*/
|
|
158
|
-
bookmarkCreators: Record<string, CreateBookmarkFn<unknown>>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export type CreateBookmarkFn<T> = () => Promise<Partial<T>> | Partial<T>;
|
|
162
|
-
|
|
163
|
-
export class BookmarkModuleProvider implements IBookmarkModuleProvider {
|
|
164
|
-
protected _bookmarkClient: BookmarkClient;
|
|
165
|
-
|
|
166
|
-
#event?: ModuleType<EventModule>;
|
|
167
|
-
|
|
168
|
-
config: BookmarkModuleConfig;
|
|
169
|
-
#subscriptions = new Subscription();
|
|
170
|
-
|
|
171
|
-
bookmarkCreators: Record<string | number | symbol, CreateBookmarkFn<unknown>> = {};
|
|
172
|
-
currentBookmark?: Bookmark<unknown>;
|
|
173
|
-
parentBookmarkProvider?: IBookmarkModuleProvider;
|
|
174
|
-
|
|
175
|
-
public get currentBookmark$() {
|
|
176
|
-
return this._bookmarkClient.currentBookmark$;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
public get bookmarks$() {
|
|
180
|
-
return this._bookmarkClient.bookmarks$;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
constructor(config: BookmarkModuleConfig, ref?: IBookmarkModuleProvider) {
|
|
184
|
-
this.config = config;
|
|
185
|
-
this.#event = config.event;
|
|
186
|
-
this._bookmarkClient = ref
|
|
187
|
-
? (ref as unknown as BookmarkModuleProvider)._bookmarkClient
|
|
188
|
-
: new BookmarkClient(config.clientConfiguration, config.sourceSystem, config.event);
|
|
189
|
-
|
|
190
|
-
const initialBookmarkId = config.resolveBookmarkId && config.resolveBookmarkId();
|
|
191
|
-
|
|
192
|
-
if (initialBookmarkId) {
|
|
193
|
-
this._bookmarkClient.setCurrentBookmark(initialBookmarkId);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (this.#event) {
|
|
197
|
-
this.#subscriptions.add(
|
|
198
|
-
this.#event.addEventListener('onCurrentAppChanged', this.#clearStateCreators),
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public async getBookmarkById<T>(bookmarkId: string): Promise<Bookmark<T>> {
|
|
204
|
-
return await this._bookmarkClient.getBookmarkById<T>(bookmarkId);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public async setCurrentBookmark<TData>(idOrItem?: string | Bookmark<TData>): Promise<void> {
|
|
208
|
-
this._bookmarkClient.setCurrentBookmark(idOrItem);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public getAllBookmarks(): Observable<Bookmark<unknown>[]> {
|
|
212
|
-
return this._bookmarkClient.getAllBookmarks();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
public async getAllBookmarksAsync(): Promise<Bookmark<unknown>[]> {
|
|
216
|
-
return this._bookmarkClient.getAllBookmarksAsync();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public updateBookmark<T>(bookmark: PatchBookmark<T>): Observable<Bookmark<T>> {
|
|
220
|
-
return this._bookmarkClient.updateBookmark<T>(bookmark);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public async updateBookmarkAsync<T>(
|
|
224
|
-
bookmark: PatchBookmark<T>,
|
|
225
|
-
options?: UpdateBookmarkOptions,
|
|
226
|
-
): Promise<Bookmark<T> | undefined> {
|
|
227
|
-
if (this.#getAppKey() !== bookmark.appKey) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (options?.updatePayload) {
|
|
232
|
-
const payload = (await this.#createPayload()) as T;
|
|
233
|
-
bookmark = {
|
|
234
|
-
...bookmark,
|
|
235
|
-
payload,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
return this._bookmarkClient.updateBookmarkAsync<T>(bookmark);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
public deleteBookmarkById(bookmarkId: string): Observable<string> {
|
|
242
|
-
return this._bookmarkClient.deleteBookmarkById(bookmarkId);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public deleteBookmarkByIdAsync(bookmarkId: string): Promise<string> {
|
|
246
|
-
return this._bookmarkClient.deleteBookmarkByIdAsync(bookmarkId);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
public async addBookmarkFavoriteAsync(bookmarkId: string): Promise<void> {
|
|
250
|
-
await this._bookmarkClient.addBookmarkFavoriteAsync(bookmarkId);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
public async removeBookmarkFavoriteAsync(bookmarkId: string): Promise<void> {
|
|
254
|
-
await this._bookmarkClient.removeBookmarkFavoriteAsync(bookmarkId);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public async verifyBookmarkFavoriteAsync(bookmarkId: string): Promise<boolean> {
|
|
258
|
-
return await this._bookmarkClient.verifyBookmarkFavoriteAsync(bookmarkId);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
public addStateCreator<T>(cb: CreateBookmarkFn<T>, key?: keyof T): VoidFunction {
|
|
262
|
-
const bookmarkCreatorKey = key ? key : '#creator';
|
|
263
|
-
|
|
264
|
-
if (this.#event) {
|
|
265
|
-
this.#event?.dispatchEvent('onAddCreator', {
|
|
266
|
-
source: this,
|
|
267
|
-
canBubble: true,
|
|
268
|
-
detail: { key, cb },
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
this.bookmarkCreators[bookmarkCreatorKey] = cb;
|
|
273
|
-
return () => {
|
|
274
|
-
delete this.bookmarkCreators[bookmarkCreatorKey];
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
public async createBookmark<T>(args: {
|
|
279
|
-
name: string;
|
|
280
|
-
description: string;
|
|
281
|
-
isShared: boolean;
|
|
282
|
-
}): Promise<Bookmark<T>> {
|
|
283
|
-
const payload = await this.#createPayload();
|
|
284
|
-
|
|
285
|
-
const contextId = this.config.getContextId && this.config.getContextId();
|
|
286
|
-
const appKey = this.#getAppKey();
|
|
287
|
-
const bookmark: CreateBookmark<unknown> = {
|
|
288
|
-
...args,
|
|
289
|
-
appKey,
|
|
290
|
-
contextId,
|
|
291
|
-
sourceSystem: this.config.sourceSystem,
|
|
292
|
-
payload,
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
return this._bookmarkClient.createBookmarkAsync(bookmark) as Promise<Bookmark<T>>;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
#clearStateCreators = () => {
|
|
299
|
-
this.bookmarkCreators = {};
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
async #createPayload() {
|
|
303
|
-
const creator = this.bookmarkCreators;
|
|
304
|
-
if (!creator || Object.keys(creator).length === 0) {
|
|
305
|
-
throw Error('No creator registered on this BookmarkProvider');
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (typeof creator['#creator'] === 'function') {
|
|
309
|
-
return creator['#creator']();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return await Object.entries(creator).reduce(async (cur, [key, fn]) => {
|
|
313
|
-
return Object.assign(await cur, { [key]: await fn() });
|
|
314
|
-
}, Promise.resolve({}));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
#getAppKey() {
|
|
318
|
-
const appKey =
|
|
319
|
-
this.config.getCurrentAppIdentification && this.config.getCurrentAppIdentification();
|
|
320
|
-
|
|
321
|
-
if (!appKey)
|
|
322
|
-
throw new Error(`There is noe current application selected, can't create bookmark.`);
|
|
323
|
-
|
|
324
|
-
return appKey;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
public dispose() {
|
|
328
|
-
this.#subscriptions.unsubscribe();
|
|
329
|
-
this._bookmarkClient.dispose();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
declare module '@equinor/fusion-framework-module-event' {
|
|
334
|
-
interface FrameworkEventMap {
|
|
335
|
-
/** dispatch before context changes */
|
|
336
|
-
onNavigateToApp: FrameworkEvent<FrameworkEventInit<URL, IBookmarkModuleProvider>>;
|
|
337
|
-
onAddCreator: FrameworkEvent<
|
|
338
|
-
FrameworkEventInit<
|
|
339
|
-
{ cb: CreateBookmarkFn<unknown>; key?: keyof unknown },
|
|
340
|
-
BookmarkModuleProvider
|
|
341
|
-
>
|
|
342
|
-
>;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createAsyncAction, ActionInstanceMap, ActionTypes } from '@equinor/fusion-observable';
|
|
2
|
-
|
|
3
|
-
import { Bookmark, CreateBookmark, PatchBookmark } from '../types';
|
|
4
|
-
|
|
5
|
-
export const actions = {
|
|
6
|
-
getAll: createAsyncAction(
|
|
7
|
-
'getAll',
|
|
8
|
-
(isValid: boolean) => ({ payload: isValid }),
|
|
9
|
-
(bookmarks: Bookmark[]) => ({ payload: bookmarks }),
|
|
10
|
-
(err: unknown) => ({ payload: err }),
|
|
11
|
-
),
|
|
12
|
-
delete: createAsyncAction(
|
|
13
|
-
'delete',
|
|
14
|
-
(id: string) => ({ payload: id }),
|
|
15
|
-
(id: string) => ({ payload: id }),
|
|
16
|
-
),
|
|
17
|
-
addFavorite: createAsyncAction(
|
|
18
|
-
'addFavorite',
|
|
19
|
-
(bookmark: Bookmark) => ({ payload: bookmark }),
|
|
20
|
-
(bookmark: Bookmark) => ({ payload: bookmark }),
|
|
21
|
-
),
|
|
22
|
-
removeFavorite: createAsyncAction(
|
|
23
|
-
'removeFavorite',
|
|
24
|
-
(id: string) => ({ payload: id }),
|
|
25
|
-
(id: string) => ({ payload: id }),
|
|
26
|
-
),
|
|
27
|
-
update: createAsyncAction(
|
|
28
|
-
'update',
|
|
29
|
-
(bookmark: PatchBookmark) => ({ payload: bookmark }),
|
|
30
|
-
(bookmark: Bookmark) => ({ payload: bookmark }),
|
|
31
|
-
),
|
|
32
|
-
create: createAsyncAction(
|
|
33
|
-
'create',
|
|
34
|
-
(bookmark: CreateBookmark) => ({ payload: bookmark }),
|
|
35
|
-
(bookmark: Bookmark) => ({ payload: bookmark }),
|
|
36
|
-
(err: unknown) => ({ payload: err }),
|
|
37
|
-
),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type ActionBuilder = typeof actions;
|
|
41
|
-
|
|
42
|
-
export type ActionMap = ActionInstanceMap<ActionBuilder>;
|
|
43
|
-
|
|
44
|
-
export type Actions = ActionTypes<typeof actions>;
|