@equinor/fusion-framework-module-bookmark 0.2.0 → 0.2.3
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 +12 -0
- package/dist/esm/bookmark-provider.js +14 -5
- package/dist/esm/bookmark-provider.js.map +1 -1
- package/dist/esm/client/bookmarkActions.js.map +1 -1
- package/dist/esm/client/bookmarkClient.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bookmark-provider.d.ts +4 -4
- package/dist/types/client/bookmarkActions.d.ts +2 -2
- package/dist/types/client/bookmarkClient.d.ts +3 -3
- package/dist/types/types.d.ts +7 -0
- package/package.json +3 -3
- package/src/bookmark-provider.ts +29 -10
- package/src/client/bookmarkActions.ts +2 -2
- package/src/client/bookmarkClient.ts +3 -2
- package/src/types.ts +8 -0
|
@@ -2,7 +2,7 @@ import { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-mo
|
|
|
2
2
|
import { BookmarkClient } from './client/bookmarkClient';
|
|
3
3
|
import { BookmarkModuleConfig } from './configurator';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
-
import { Bookmark } from './types';
|
|
5
|
+
import { Bookmark, PatchBookmark, UpdateBookmarkOptions } from './types';
|
|
6
6
|
export interface IBookmarkModuleProvider {
|
|
7
7
|
readonly config: BookmarkModuleConfig;
|
|
8
8
|
readonly currentBookmark$: Observable<Bookmark<any> | undefined>;
|
|
@@ -13,7 +13,7 @@ export interface IBookmarkModuleProvider {
|
|
|
13
13
|
getAllBookmarks(): Observable<Array<Bookmark>>;
|
|
14
14
|
getAllBookmarksAsync(): Promise<Array<Bookmark>>;
|
|
15
15
|
updateBookmark<T>(bookmark: Bookmark<T>): Observable<Bookmark<T>>;
|
|
16
|
-
updateBookmarkAsync<T>(bookmark:
|
|
16
|
+
updateBookmarkAsync<T>(bookmark: PatchBookmark<T>, options?: UpdateBookmarkOptions): Promise<Bookmark<T> | undefined>;
|
|
17
17
|
deleteBookmarkById(bookmarkId: string): Observable<string>;
|
|
18
18
|
deleteBookmarkByIdAsync(bookmarkId: string): Promise<string>;
|
|
19
19
|
addBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
|
|
@@ -43,8 +43,8 @@ export declare class BookmarkModuleProvider implements IBookmarkModuleProvider {
|
|
|
43
43
|
setCurrentBookmark<TData>(idOrItem?: string | Bookmark<TData>): Promise<void>;
|
|
44
44
|
getAllBookmarks(): Observable<Bookmark<unknown>[]>;
|
|
45
45
|
getAllBookmarksAsync(): Promise<Bookmark<unknown>[]>;
|
|
46
|
-
updateBookmark<T>(bookmark:
|
|
47
|
-
updateBookmarkAsync<T>(bookmark:
|
|
46
|
+
updateBookmark<T>(bookmark: PatchBookmark<T>): Observable<Bookmark<T>>;
|
|
47
|
+
updateBookmarkAsync<T>(bookmark: PatchBookmark<T>, options?: UpdateBookmarkOptions): Promise<Bookmark<T> | undefined>;
|
|
48
48
|
deleteBookmarkById(bookmarkId: string): Observable<string>;
|
|
49
49
|
deleteBookmarkByIdAsync(bookmarkId: string): Promise<string>;
|
|
50
50
|
addBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionInstanceMap, ActionTypes } from '@equinor/fusion-observable';
|
|
2
|
-
import { Bookmark, CreateBookmark } from '../types';
|
|
2
|
+
import { Bookmark, CreateBookmark, PatchBookmark } from '../types';
|
|
3
3
|
export declare const actions: {
|
|
4
4
|
getAll: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[isValid: boolean], boolean, "getAll::request", never, never> & {
|
|
5
5
|
success: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[bookmarks: Bookmark<unknown>[]], Bookmark<unknown>[], "getAll::success", never, never>;
|
|
@@ -8,7 +8,7 @@ export declare const actions: {
|
|
|
8
8
|
delete: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[id: string], string, "delete::request", never, never> & {
|
|
9
9
|
success: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[id: string], string, "delete::success", never, never>;
|
|
10
10
|
};
|
|
11
|
-
update: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[bookmark:
|
|
11
|
+
update: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[bookmark: PatchBookmark<unknown>], PatchBookmark<unknown>, "update::request", never, never> & {
|
|
12
12
|
success: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[bookmark: Bookmark<unknown>], Bookmark<unknown>, "update::success", never, never>;
|
|
13
13
|
};
|
|
14
14
|
create: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[bookmark: CreateBookmark<unknown>], CreateBookmark<unknown>, "create::request", never, never> & {
|
|
@@ -3,7 +3,7 @@ import { IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
|
3
3
|
import { BookmarksApiClient } from '@equinor/fusion-framework-module-services/bookmarks';
|
|
4
4
|
import { type QueryCtorOptions } from '@equinor/fusion-query';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
|
-
import { Bookmark, CreateBookmark, GetAllBookmarksParameters, GetBookmarkParameters, SourceSystem } from '../types';
|
|
6
|
+
import { Bookmark, CreateBookmark, GetAllBookmarksParameters, GetBookmarkParameters, PatchBookmark, SourceSystem } from '../types';
|
|
7
7
|
export type BookmarkClientConfig = {
|
|
8
8
|
client: BookmarksApiClient<'fetch', IHttpClient, Bookmark<unknown>>;
|
|
9
9
|
queryClientConfig: {
|
|
@@ -30,8 +30,8 @@ export declare class BookmarkClient {
|
|
|
30
30
|
getBookmarkById<T>(bookmarkId: string): Promise<Bookmark<T>>;
|
|
31
31
|
createBookmark(bookmark: CreateBookmark<unknown>): Observable<Bookmark<unknown>>;
|
|
32
32
|
createBookmarkAsync(bookmark: CreateBookmark<unknown>): Promise<Bookmark<unknown>>;
|
|
33
|
-
updateBookmark<T>(bookmark:
|
|
34
|
-
updateBookmarkAsync<T>(bookmark:
|
|
33
|
+
updateBookmark<T>(bookmark: PatchBookmark<T>): Observable<Bookmark<T>>;
|
|
34
|
+
updateBookmarkAsync<T>(bookmark: PatchBookmark<T>): Promise<Bookmark<T>>;
|
|
35
35
|
deleteBookmarkById(bookmarkId: string): Observable<string>;
|
|
36
36
|
deleteBookmarkByIdAsync(bookmarkId: string): Promise<string>;
|
|
37
37
|
addBookmarkFavoriteAsync(bookmarkId: string): Promise<void>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { QueryFn, QueryCtorOptions } from '@equinor/fusion-query';
|
|
2
|
+
export interface PatchBookmark<TData = unknown> extends Partial<Bookmark<TData>> {
|
|
3
|
+
id: string;
|
|
4
|
+
appKey: string;
|
|
5
|
+
}
|
|
2
6
|
export interface Bookmark<TData = unknown> {
|
|
3
7
|
id: string;
|
|
4
8
|
name: string;
|
|
@@ -51,4 +55,7 @@ export interface BookmarkQueryClient {
|
|
|
51
55
|
getAllBookmarks: QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters> | QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
|
|
52
56
|
getBookmarkById: QueryFn<Bookmark<unknown>, GetBookmarkParameters> | QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
|
|
53
57
|
}
|
|
58
|
+
export type UpdateBookmarkOptions = {
|
|
59
|
+
updatePayload: boolean;
|
|
60
|
+
};
|
|
54
61
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-bookmark",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@equinor/fusion-framework-module": "^2.0.0",
|
|
39
39
|
"@equinor/fusion-framework-module-event": "^2.0.0",
|
|
40
|
-
"@equinor/fusion-framework-module-services": "^2.
|
|
40
|
+
"@equinor/fusion-framework-module-services": "^2.5.0",
|
|
41
41
|
"rxjs": "^7.5.7"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@equinor/fusion-framework-module": ">=1.2.5",
|
|
45
45
|
"rxjs": "^7.5.7"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "dd4ed92c8f1d020f3b537172b4fe7788aeae99e7"
|
|
48
48
|
}
|
package/src/bookmark-provider.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { BookmarkClient } from './client/bookmarkClient';
|
|
|
10
10
|
|
|
11
11
|
import { BookmarkModuleConfig } from './configurator';
|
|
12
12
|
import { Observable, Subscription } from 'rxjs';
|
|
13
|
-
import { Bookmark, CreateBookmark } from './types';
|
|
13
|
+
import { Bookmark, CreateBookmark, PatchBookmark, UpdateBookmarkOptions } from './types';
|
|
14
14
|
|
|
15
15
|
export interface IBookmarkModuleProvider {
|
|
16
16
|
/**
|
|
@@ -83,9 +83,13 @@ export interface IBookmarkModuleProvider {
|
|
|
83
83
|
* @template T - Payload Type
|
|
84
84
|
* @param {string} bookmarkId
|
|
85
85
|
* @param {Bookmark<T>} bookmark
|
|
86
|
+
* @param {UpdateBookmarkOptions} options - optional options that allow for configuration of bookmark payload update.
|
|
86
87
|
* @return {Promise<Bookmark<T>>} - Promise of a Bookmark
|
|
87
88
|
*/
|
|
88
|
-
updateBookmarkAsync<T>(
|
|
89
|
+
updateBookmarkAsync<T>(
|
|
90
|
+
bookmark: PatchBookmark<T>,
|
|
91
|
+
options?: UpdateBookmarkOptions
|
|
92
|
+
): Promise<Bookmark<T> | undefined>;
|
|
89
93
|
|
|
90
94
|
/**
|
|
91
95
|
* Function for deleting a bookmark, when successful this will update the bookmark list.
|
|
@@ -212,11 +216,21 @@ export class BookmarkModuleProvider implements IBookmarkModuleProvider {
|
|
|
212
216
|
return this._bookmarkClient.getAllBookmarksAsync();
|
|
213
217
|
}
|
|
214
218
|
|
|
215
|
-
public updateBookmark<T>(bookmark:
|
|
219
|
+
public updateBookmark<T>(bookmark: PatchBookmark<T>): Observable<Bookmark<T>> {
|
|
216
220
|
return this._bookmarkClient.updateBookmark<T>(bookmark);
|
|
217
221
|
}
|
|
218
222
|
|
|
219
|
-
public async updateBookmarkAsync<T>(
|
|
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
|
+
bookmark.payload = (await this.#createPayload()) as T;
|
|
233
|
+
}
|
|
220
234
|
return this._bookmarkClient.updateBookmarkAsync<T>(bookmark);
|
|
221
235
|
}
|
|
222
236
|
|
|
@@ -265,12 +279,7 @@ export class BookmarkModuleProvider implements IBookmarkModuleProvider {
|
|
|
265
279
|
const payload = await this.#createPayload();
|
|
266
280
|
|
|
267
281
|
const contextId = this.config.getContextId && this.config.getContextId();
|
|
268
|
-
const appKey =
|
|
269
|
-
this.config.getCurrentAppIdentification && this.config.getCurrentAppIdentification();
|
|
270
|
-
|
|
271
|
-
if (!appKey)
|
|
272
|
-
throw new Error(`There is noe current application selected, can't create bookmark.`);
|
|
273
|
-
|
|
282
|
+
const appKey = this.#getAppKey();
|
|
274
283
|
const bookmark: CreateBookmark<unknown> = {
|
|
275
284
|
...args,
|
|
276
285
|
appKey,
|
|
@@ -301,6 +310,16 @@ export class BookmarkModuleProvider implements IBookmarkModuleProvider {
|
|
|
301
310
|
}, Promise.resolve({}));
|
|
302
311
|
}
|
|
303
312
|
|
|
313
|
+
#getAppKey() {
|
|
314
|
+
const appKey =
|
|
315
|
+
this.config.getCurrentAppIdentification && this.config.getCurrentAppIdentification();
|
|
316
|
+
|
|
317
|
+
if (!appKey)
|
|
318
|
+
throw new Error(`There is noe current application selected, can't create bookmark.`);
|
|
319
|
+
|
|
320
|
+
return appKey;
|
|
321
|
+
}
|
|
322
|
+
|
|
304
323
|
public dispose() {
|
|
305
324
|
this.#subscriptions.unsubscribe();
|
|
306
325
|
this._bookmarkClient.dispose();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAsyncAction, ActionInstanceMap, ActionTypes } from '@equinor/fusion-observable';
|
|
2
2
|
|
|
3
|
-
import { Bookmark, CreateBookmark } from '../types';
|
|
3
|
+
import { Bookmark, CreateBookmark, PatchBookmark } from '../types';
|
|
4
4
|
|
|
5
5
|
export const actions = {
|
|
6
6
|
getAll: createAsyncAction(
|
|
@@ -16,7 +16,7 @@ export const actions = {
|
|
|
16
16
|
),
|
|
17
17
|
update: createAsyncAction(
|
|
18
18
|
'update',
|
|
19
|
-
(bookmark:
|
|
19
|
+
(bookmark: PatchBookmark) => ({ payload: bookmark }),
|
|
20
20
|
(bookmark: Bookmark) => ({ payload: bookmark })
|
|
21
21
|
),
|
|
22
22
|
create: createAsyncAction(
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
CreateBookmark,
|
|
18
18
|
GetAllBookmarksParameters,
|
|
19
19
|
GetBookmarkParameters,
|
|
20
|
+
PatchBookmark,
|
|
20
21
|
SourceSystem,
|
|
21
22
|
} from '../types';
|
|
22
23
|
import { ActionBuilder, actions } from './bookmarkActions';
|
|
@@ -192,7 +193,7 @@ export class BookmarkClient {
|
|
|
192
193
|
return lastValueFrom(this.createBookmark(bookmark));
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
public updateBookmark<T>(bookmark:
|
|
196
|
+
public updateBookmark<T>(bookmark: PatchBookmark<T>): Observable<Bookmark<T>> {
|
|
196
197
|
return new Observable((subscriber) => {
|
|
197
198
|
this.#state.dispatch.update(bookmark);
|
|
198
199
|
subscriber.add(
|
|
@@ -205,7 +206,7 @@ export class BookmarkClient {
|
|
|
205
206
|
});
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
public async updateBookmarkAsync<T>(bookmark:
|
|
209
|
+
public async updateBookmarkAsync<T>(bookmark: PatchBookmark<T>): Promise<Bookmark<T>> {
|
|
209
210
|
return lastValueFrom(this.updateBookmark(bookmark));
|
|
210
211
|
}
|
|
211
212
|
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { QueryFn, QueryCtorOptions } from '@equinor/fusion-query';
|
|
2
2
|
|
|
3
|
+
export interface PatchBookmark<TData = unknown> extends Partial<Bookmark<TData>> {
|
|
4
|
+
id: string;
|
|
5
|
+
appKey: string;
|
|
6
|
+
}
|
|
3
7
|
export interface Bookmark<TData = unknown> {
|
|
4
8
|
id: string;
|
|
5
9
|
name: string;
|
|
@@ -63,3 +67,7 @@ export interface BookmarkQueryClient {
|
|
|
63
67
|
| QueryFn<Bookmark<unknown>, GetBookmarkParameters>
|
|
64
68
|
| QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
|
|
65
69
|
}
|
|
70
|
+
|
|
71
|
+
export type UpdateBookmarkOptions = {
|
|
72
|
+
updatePayload: boolean;
|
|
73
|
+
};
|