@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +242 -9
  3. package/dist/esm/BookmarkClient.interface.js +2 -0
  4. package/dist/esm/BookmarkClient.interface.js.map +1 -0
  5. package/dist/esm/BookmarkClient.js +174 -0
  6. package/dist/esm/BookmarkClient.js.map +1 -0
  7. package/dist/esm/BookmarkConfigurator.js +348 -0
  8. package/dist/esm/BookmarkConfigurator.js.map +1 -0
  9. package/dist/esm/BookmarkProvider.actions.js +60 -0
  10. package/dist/esm/BookmarkProvider.actions.js.map +1 -0
  11. package/dist/esm/BookmarkProvider.error.js +14 -0
  12. package/dist/esm/BookmarkProvider.error.js.map +1 -0
  13. package/dist/esm/BookmarkProvider.events.js +2 -0
  14. package/dist/esm/BookmarkProvider.events.js.map +1 -0
  15. package/dist/esm/BookmarkProvider.flows.js +219 -0
  16. package/dist/esm/BookmarkProvider.flows.js.map +1 -0
  17. package/dist/esm/BookmarkProvider.js +937 -0
  18. package/dist/esm/BookmarkProvider.js.map +1 -0
  19. package/dist/esm/BookmarkProvider.reducer.js +125 -0
  20. package/dist/esm/BookmarkProvider.reducer.js.map +1 -0
  21. package/dist/esm/BookmarkProvider.selectors.js +43 -0
  22. package/dist/esm/BookmarkProvider.selectors.js.map +1 -0
  23. package/dist/esm/BookmarkProvider.store.js +19 -0
  24. package/dist/esm/BookmarkProvider.store.js.map +1 -0
  25. package/dist/esm/bookmark-config.schema.js +30 -0
  26. package/dist/esm/bookmark-config.schema.js.map +1 -0
  27. package/dist/esm/bookmark-module.js +53 -0
  28. package/dist/esm/bookmark-module.js.map +1 -0
  29. package/dist/esm/bookmark.schemas.js +38 -0
  30. package/dist/esm/bookmark.schemas.js.map +1 -0
  31. package/dist/esm/enable-bookmark.js +20 -7
  32. package/dist/esm/enable-bookmark.js.map +1 -1
  33. package/dist/esm/index.js +3 -3
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/version.js +1 -1
  36. package/dist/esm/version.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/dist/types/BookmarkClient.d.ts +42 -0
  39. package/dist/types/BookmarkClient.interface.d.ts +139 -0
  40. package/dist/types/BookmarkConfigurator.d.ts +100 -0
  41. package/dist/types/BookmarkProvider.actions.d.ts +525 -0
  42. package/dist/types/BookmarkProvider.d.ts +462 -0
  43. package/dist/types/BookmarkProvider.error.d.ts +9 -0
  44. package/dist/types/BookmarkProvider.events.d.ts +78 -0
  45. package/dist/types/BookmarkProvider.flows.d.ts +79 -0
  46. package/dist/types/BookmarkProvider.reducer.d.ts +302 -0
  47. package/dist/types/BookmarkProvider.selectors.d.ts +34 -0
  48. package/dist/types/BookmarkProvider.store.d.ts +30 -0
  49. package/dist/types/bookmark-config.schema.d.ts +118 -0
  50. package/dist/types/{module.d.ts → bookmark-module.d.ts} +3 -3
  51. package/dist/types/bookmark.schemas.d.ts +760 -0
  52. package/dist/types/enable-bookmark.d.ts +7 -6
  53. package/dist/types/index.d.ts +4 -3
  54. package/dist/types/types.d.ts +29 -65
  55. package/dist/types/version.d.ts +1 -1
  56. package/package.json +11 -5
  57. package/src/BookmarkClient.interface.ts +157 -0
  58. package/src/BookmarkClient.ts +226 -0
  59. package/src/BookmarkConfigurator.ts +374 -0
  60. package/src/BookmarkProvider.actions.ts +131 -0
  61. package/src/BookmarkProvider.error.ts +21 -0
  62. package/src/BookmarkProvider.events.ts +89 -0
  63. package/src/BookmarkProvider.flows.ts +426 -0
  64. package/src/BookmarkProvider.reducer.ts +141 -0
  65. package/src/BookmarkProvider.selectors.ts +55 -0
  66. package/src/BookmarkProvider.store.ts +52 -0
  67. package/src/BookmarkProvider.ts +1308 -0
  68. package/src/bookmark-config.schema.ts +41 -0
  69. package/src/bookmark-module.ts +70 -0
  70. package/src/bookmark.schemas.ts +50 -0
  71. package/src/enable-bookmark.ts +13 -20
  72. package/src/index.ts +15 -7
  73. package/src/types.ts +46 -73
  74. package/src/version.ts +1 -1
  75. package/dist/esm/bookmark-config-builder.js +0 -131
  76. package/dist/esm/bookmark-config-builder.js.map +0 -1
  77. package/dist/esm/bookmark-provider.js +0 -155
  78. package/dist/esm/bookmark-provider.js.map +0 -1
  79. package/dist/esm/client/bookmarkActions.js +0 -10
  80. package/dist/esm/client/bookmarkActions.js.map +0 -1
  81. package/dist/esm/client/bookmarkClient.js +0 -259
  82. package/dist/esm/client/bookmarkClient.js.map +0 -1
  83. package/dist/esm/client/bookmarkFlows.js +0 -31
  84. package/dist/esm/client/bookmarkFlows.js.map +0 -1
  85. package/dist/esm/client/bookmarkReducer.js +0 -29
  86. package/dist/esm/client/bookmarkReducer.js.map +0 -1
  87. package/dist/esm/configurator.js +0 -155
  88. package/dist/esm/configurator.js.map +0 -1
  89. package/dist/esm/module.js +0 -27
  90. package/dist/esm/module.js.map +0 -1
  91. package/dist/esm/utils/handle-url.js +0 -11
  92. package/dist/esm/utils/handle-url.js.map +0 -1
  93. package/dist/esm/utils/index.js +0 -2
  94. package/dist/esm/utils/index.js.map +0 -1
  95. package/dist/types/bookmark-config-builder.d.ts +0 -85
  96. package/dist/types/bookmark-provider.d.ts +0 -169
  97. package/dist/types/client/bookmarkActions.d.ts +0 -27
  98. package/dist/types/client/bookmarkClient.d.ts +0 -53
  99. package/dist/types/client/bookmarkFlows.d.ts +0 -22
  100. package/dist/types/client/bookmarkReducer.d.ts +0 -5
  101. package/dist/types/configurator.d.ts +0 -75
  102. package/dist/types/utils/handle-url.d.ts +0 -2
  103. package/dist/types/utils/index.d.ts +0 -1
  104. package/src/bookmark-config-builder.ts +0 -177
  105. package/src/bookmark-provider.ts +0 -344
  106. package/src/client/bookmarkActions.ts +0 -44
  107. package/src/client/bookmarkClient.ts +0 -327
  108. package/src/client/bookmarkFlows.ts +0 -67
  109. package/src/client/bookmarkReducer.ts +0 -35
  110. package/src/configurator.ts +0 -235
  111. package/src/module.ts +0 -40
  112. package/src/utils/handle-url.ts +0 -13
  113. package/src/utils/index.ts +0 -1
@@ -0,0 +1,462 @@
1
+ import { Observable } from 'rxjs';
2
+ import { Draft } from 'immer';
3
+ import { FrameworkEventInitType } from '@equinor/fusion-framework-module-event';
4
+ import { SemanticVersion } from '@equinor/fusion-framework-module';
5
+ import type { Bookmark, BookmarkData, BookmarkWithoutData, Bookmarks, BookmarkModuleConfig } from './types';
6
+ import { BookmarkNew, BookmarkUpdate, type IBookmarkClient } from './BookmarkClient.interface';
7
+ import { BookmarkActions } from './BookmarkProvider.actions';
8
+ import { BookmarkState } from './BookmarkProvider.store';
9
+ import { BookmarkFlowError } from './BookmarkProvider.error';
10
+ import { BookmarkProviderEventMap } from './BookmarkProvider.events';
11
+ export type BookmarkPayloadGenerator<TData extends BookmarkData = any> = (payload?: Draft<Partial<TData>> | null, initial?: Partial<TData> | null) => Promise<Partial<TData> | void> | Partial<TData> | void;
12
+ export type BookmarkUpdateOptions = {
13
+ excludePayloadGeneration?: boolean;
14
+ };
15
+ export type BookmarkCreateArgs<T extends BookmarkData> = Omit<BookmarkNew<T>, 'appKey' | 'contextId' | 'sourceSystem'> & Partial<Pick<BookmarkNew<T>, 'appKey'>>;
16
+ /**
17
+ * The `BookmarkProvider` class is responsible for managing bookmarks in the application.
18
+ * It provides methods for creating, updating, and removing bookmarks, as well as managing the current bookmark and the list of bookmarks.
19
+ *
20
+ * The `BookmarkProvider` uses a `BookmarkStore` to manage the state of the bookmarks, and an `IBookmarkClient` to interact with the backend API.
21
+ *
22
+ * The `BookmarkProvider` also supports event listeners for various bookmark-related events, such as when the current bookmark changes or when a bookmark is created, updated, or removed.
23
+ */
24
+ export declare class BookmarkProvider {
25
+ #private;
26
+ /**
27
+ * Gets the semantic version of the bookmark provider.
28
+ */
29
+ get version(): SemanticVersion;
30
+ get filters(): BookmarkModuleConfig['filters'];
31
+ /**
32
+ * Gets the `IBookmarkClient` instance used by this `BookmarkProvider`.
33
+ */
34
+ get client(): IBookmarkClient;
35
+ /**
36
+ * Gets the currently active bookmark (if any).
37
+ */
38
+ get currentBookmark$(): Observable<Bookmark | null>;
39
+ /**
40
+ * Gets an observable that emits the current list of bookmarks.
41
+ */
42
+ get bookmarks$(): Observable<Array<BookmarkWithoutData>>;
43
+ /**
44
+ * Gets the current list of bookmarks.
45
+ */
46
+ get bookmarks(): Array<BookmarkWithoutData>;
47
+ /**
48
+ * Gets the currently active bookmark.
49
+ */
50
+ get currentBookmark(): Bookmark | null | undefined;
51
+ /**
52
+ * Represents an observable stream of the bookmark status.
53
+ */
54
+ get status$(): Observable<BookmarkState['status']>;
55
+ /**
56
+ * Gets an observable that emits the current list of bookmark errors.
57
+ */
58
+ get errors$(): Observable<Array<BookmarkFlowError>>;
59
+ /**
60
+ * Determines whether there are any bookmark creators configured.
61
+ * `true` if there are any bookmark creators configured, `false` otherwise.
62
+ */
63
+ get hasBookmarkCreators(): boolean;
64
+ /**
65
+ * Gets the source system value from the configuration.
66
+ */
67
+ get sourceSystem(): BookmarkModuleConfig['sourceSystem'];
68
+ /**
69
+ * Gets the resolved application from the bookmark module configuration.
70
+ */
71
+ get resolvedApplication(): BookmarkModuleConfig['resolve']['application'];
72
+ /**
73
+ * Gets the resolved context from the bookmark module configuration.
74
+ */
75
+ get resolvedContext(): BookmarkModuleConfig['resolve']['context'];
76
+ protected get _apiClient(): IBookmarkClient;
77
+ /**
78
+ * configured logger instance.
79
+ */
80
+ protected get _log(): BookmarkModuleConfig['log'];
81
+ /**
82
+ * configured resolvers
83
+ */
84
+ protected get _resolve(): BookmarkModuleConfig['resolve'];
85
+ /**
86
+ * configured event provider.
87
+ */
88
+ protected get _event(): BookmarkModuleConfig['eventProvider'];
89
+ /**
90
+ * configured parent bookmark provider
91
+ */
92
+ protected get _parent(): BookmarkModuleConfig['parent'];
93
+ /**
94
+ * Constructs a new `BookmarkProvider` instance.
95
+ *
96
+ * @param config - The configuration for the bookmark module, including the client, initial state, and optional parent provider.
97
+ */
98
+ constructor(config: BookmarkModuleConfig);
99
+ /**
100
+ * Registers an event listener for the specified event on the BookmarkProvider.
101
+ *
102
+ * @param eventName - The name of the event to listen for. Must be a key of the `BookmarkProviderEventMap` type.
103
+ * @param callback - The callback function to be invoked when the event is triggered.
104
+ * The callback will receive the event object as its parameter, which will be of the type corresponding to the `eventName`.
105
+ * @returns A function that can be called to remove the event listener.
106
+ */
107
+ on<TType extends keyof BookmarkProviderEventMap>(eventName: TType, callback: (event: BookmarkProviderEventMap[TType]) => void): VoidFunction;
108
+ /**
109
+ * Adds a new payload generator function to the BookmarkProvider.
110
+ * The payload generator function will be used to generate the payload for a bookmark-related action.
111
+ *
112
+ * @param fn - The payload generator function to add. It should be of type `PayloadGenerator<T>`, where `T` is the type of the bookmark data.
113
+ * @returns A function that can be called to remove the added payload generator.
114
+ */
115
+ addPayloadGenerator<T extends BookmarkData>(fn: BookmarkPayloadGenerator<T>): VoidFunction;
116
+ /**
117
+ * Generates a payload by applying registered generator functions to an accumulator object.
118
+ *
119
+ * @param initial - The initial value of the accumulator object.
120
+ * @returns An observable that emits the generated payload.
121
+ * @template T - The type of the generated payload.
122
+ */
123
+ generatePayload<T extends BookmarkData>(initial?: Partial<T> | null): Observable<T | null | undefined>;
124
+ /**
125
+ * Retrieves a bookmark with the specified bookmarkId and returns an observable that emits the combined result of fetching the bookmark and bookmark data.
126
+ * @template T The type of the bookmark payload.
127
+ * @param bookmarkId The unique identifier of the bookmark.
128
+ * @param options An optional object that allows excluding the bookmark payload from the result.
129
+ * @returns An observable that emits the combined result of fetching the bookmark and bookmark data.
130
+ */
131
+ getBookmark<T extends BookmarkData>(bookmarkId: string, options?: {
132
+ excludePayload?: boolean;
133
+ }): Observable<import("zod").objectUtil.addQuestionMarks<import("zod").baseObjectOutputType<import("zod").objectUtil.extendShape<{
134
+ id: import("zod").ZodString;
135
+ name: import("zod").ZodString;
136
+ appKey: import("zod").ZodString;
137
+ description: import("zod").ZodOptional<import("zod").ZodString>;
138
+ isShared: import("zod").ZodOptional<import("zod").ZodBoolean>;
139
+ created: import("zod").ZodDate;
140
+ createdBy: import("zod").ZodObject<{
141
+ azureUniqueId: import("zod").ZodString;
142
+ name: import("zod").ZodString;
143
+ mail: import("zod").ZodOptional<import("zod").ZodString>;
144
+ phoneNumber: import("zod").ZodOptional<import("zod").ZodString>;
145
+ jobTitle: import("zod").ZodOptional<import("zod").ZodString>;
146
+ accountType: import("zod").ZodOptional<import("zod").ZodEnum<["Employee", "Consultant", "External", "Application", "Local"]>>;
147
+ accountClassification: import("zod").ZodOptional<import("zod").ZodEnum<["Unclassified", "Internal", "External"]>>;
148
+ }, "strip", import("zod").ZodTypeAny, {
149
+ azureUniqueId: string;
150
+ name: string;
151
+ mail?: string | undefined;
152
+ phoneNumber?: string | undefined;
153
+ jobTitle?: string | undefined;
154
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
155
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
156
+ }, {
157
+ azureUniqueId: string;
158
+ name: string;
159
+ mail?: string | undefined;
160
+ phoneNumber?: string | undefined;
161
+ jobTitle?: string | undefined;
162
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
163
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
164
+ }>;
165
+ updated: import("zod").ZodOptional<import("zod").ZodDate>;
166
+ updatedBy: import("zod").ZodOptional<import("zod").ZodObject<{
167
+ azureUniqueId: import("zod").ZodString;
168
+ name: import("zod").ZodString;
169
+ mail: import("zod").ZodOptional<import("zod").ZodString>;
170
+ phoneNumber: import("zod").ZodOptional<import("zod").ZodString>;
171
+ jobTitle: import("zod").ZodOptional<import("zod").ZodString>;
172
+ accountType: import("zod").ZodOptional<import("zod").ZodEnum<["Employee", "Consultant", "External", "Application", "Local"]>>;
173
+ accountClassification: import("zod").ZodOptional<import("zod").ZodEnum<["Unclassified", "Internal", "External"]>>;
174
+ }, "strip", import("zod").ZodTypeAny, {
175
+ azureUniqueId: string;
176
+ name: string;
177
+ mail?: string | undefined;
178
+ phoneNumber?: string | undefined;
179
+ jobTitle?: string | undefined;
180
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
181
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
182
+ }, {
183
+ azureUniqueId: string;
184
+ name: string;
185
+ mail?: string | undefined;
186
+ phoneNumber?: string | undefined;
187
+ jobTitle?: string | undefined;
188
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
189
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
190
+ }>>;
191
+ context: import("zod").ZodOptional<import("zod").ZodObject<{
192
+ id: import("zod").ZodString;
193
+ name: import("zod").ZodOptional<import("zod").ZodString>;
194
+ type: import("zod").ZodOptional<import("zod").ZodString>;
195
+ }, "strip", import("zod").ZodTypeAny, {
196
+ id: string;
197
+ name?: string | undefined;
198
+ type?: string | undefined;
199
+ }, {
200
+ id: string;
201
+ name?: string | undefined;
202
+ type?: string | undefined;
203
+ }>>;
204
+ sourceSystem: import("zod").ZodOptional<import("zod").ZodObject<{
205
+ identifier: import("zod").ZodString;
206
+ name: import("zod").ZodOptional<import("zod").ZodString>;
207
+ subSystem: import("zod").ZodOptional<import("zod").ZodString>;
208
+ }, "strip", import("zod").ZodTypeAny, {
209
+ identifier: string;
210
+ name?: string | undefined;
211
+ subSystem?: string | undefined;
212
+ }, {
213
+ identifier: string;
214
+ name?: string | undefined;
215
+ subSystem?: string | undefined;
216
+ }>>;
217
+ }, {
218
+ payload: import("zod").ZodType<T, import("zod").ZodTypeDef, T>;
219
+ }>>, any> extends infer T_1 ? { [k in keyof T_1]: import("zod").objectUtil.addQuestionMarks<import("zod").baseObjectOutputType<import("zod").objectUtil.extendShape<{
220
+ id: import("zod").ZodString;
221
+ name: import("zod").ZodString;
222
+ appKey: import("zod").ZodString;
223
+ description: import("zod").ZodOptional<import("zod").ZodString>;
224
+ isShared: import("zod").ZodOptional<import("zod").ZodBoolean>;
225
+ created: import("zod").ZodDate;
226
+ createdBy: import("zod").ZodObject<{
227
+ azureUniqueId: import("zod").ZodString;
228
+ name: import("zod").ZodString;
229
+ mail: import("zod").ZodOptional<import("zod").ZodString>;
230
+ phoneNumber: import("zod").ZodOptional<import("zod").ZodString>;
231
+ jobTitle: import("zod").ZodOptional<import("zod").ZodString>;
232
+ accountType: import("zod").ZodOptional<import("zod").ZodEnum<["Employee", "Consultant", "External", "Application", "Local"]>>;
233
+ accountClassification: import("zod").ZodOptional<import("zod").ZodEnum<["Unclassified", "Internal", "External"]>>;
234
+ }, "strip", import("zod").ZodTypeAny, {
235
+ azureUniqueId: string;
236
+ name: string;
237
+ mail?: string | undefined;
238
+ phoneNumber?: string | undefined;
239
+ jobTitle?: string | undefined;
240
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
241
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
242
+ }, {
243
+ azureUniqueId: string;
244
+ name: string;
245
+ mail?: string | undefined;
246
+ phoneNumber?: string | undefined;
247
+ jobTitle?: string | undefined;
248
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
249
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
250
+ }>;
251
+ updated: import("zod").ZodOptional<import("zod").ZodDate>;
252
+ updatedBy: import("zod").ZodOptional<import("zod").ZodObject<{
253
+ azureUniqueId: import("zod").ZodString;
254
+ name: import("zod").ZodString;
255
+ mail: import("zod").ZodOptional<import("zod").ZodString>;
256
+ phoneNumber: import("zod").ZodOptional<import("zod").ZodString>;
257
+ jobTitle: import("zod").ZodOptional<import("zod").ZodString>;
258
+ accountType: import("zod").ZodOptional<import("zod").ZodEnum<["Employee", "Consultant", "External", "Application", "Local"]>>;
259
+ accountClassification: import("zod").ZodOptional<import("zod").ZodEnum<["Unclassified", "Internal", "External"]>>;
260
+ }, "strip", import("zod").ZodTypeAny, {
261
+ azureUniqueId: string;
262
+ name: string;
263
+ mail?: string | undefined;
264
+ phoneNumber?: string | undefined;
265
+ jobTitle?: string | undefined;
266
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
267
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
268
+ }, {
269
+ azureUniqueId: string;
270
+ name: string;
271
+ mail?: string | undefined;
272
+ phoneNumber?: string | undefined;
273
+ jobTitle?: string | undefined;
274
+ accountType?: "Employee" | "Consultant" | "External" | "Application" | "Local" | undefined;
275
+ accountClassification?: "External" | "Unclassified" | "Internal" | undefined;
276
+ }>>;
277
+ context: import("zod").ZodOptional<import("zod").ZodObject<{
278
+ id: import("zod").ZodString;
279
+ name: import("zod").ZodOptional<import("zod").ZodString>;
280
+ type: import("zod").ZodOptional<import("zod").ZodString>;
281
+ }, "strip", import("zod").ZodTypeAny, {
282
+ id: string;
283
+ name?: string | undefined;
284
+ type?: string | undefined;
285
+ }, {
286
+ id: string;
287
+ name?: string | undefined;
288
+ type?: string | undefined;
289
+ }>>;
290
+ sourceSystem: import("zod").ZodOptional<import("zod").ZodObject<{
291
+ identifier: import("zod").ZodString;
292
+ name: import("zod").ZodOptional<import("zod").ZodString>;
293
+ subSystem: import("zod").ZodOptional<import("zod").ZodString>;
294
+ }, "strip", import("zod").ZodTypeAny, {
295
+ identifier: string;
296
+ name?: string | undefined;
297
+ subSystem?: string | undefined;
298
+ }, {
299
+ identifier: string;
300
+ name?: string | undefined;
301
+ subSystem?: string | undefined;
302
+ }>>;
303
+ }, {
304
+ payload: import("zod").ZodType<T, import("zod").ZodTypeDef, T>;
305
+ }>>, any>[k]; } : never>;
306
+ /**
307
+ * Retrieves a bookmark asynchronously.
308
+ *
309
+ * @param id - The ID of the bookmark to retrieve.
310
+ * @param options - Optional parameters for the retrieval.
311
+ * @param options.excludePayload - Specifies whether to exclude the payload from the bookmark.
312
+ * @returns A promise that resolves to the retrieved bookmark, or null if the bookmark is not found.
313
+ */
314
+ getBookmarkAsync<T extends BookmarkData>(id: string, options?: {
315
+ excludePayload?: boolean;
316
+ }): Promise<Bookmark<T> | null>;
317
+ /**
318
+ * Asynchronously retrieves all bookmarks from the store.
319
+ *
320
+ * @returns A Promise that resolves to the Bookmarks object containing all bookmarks.
321
+ */
322
+ getAllBookmarks(): Observable<Bookmarks>;
323
+ /**
324
+ * Asynchronously retrieves all bookmarks from the store.
325
+ *
326
+ * @returns A Promise that resolves to the Bookmarks object containing all bookmarks.
327
+ */
328
+ getAllBookmarksAsync(): Promise<Bookmarks>;
329
+ /**
330
+ * Sets the current bookmark to the specified bookmark or ID.
331
+ * If the bookmark is already the current bookmark, it returns the bookmark directly.
332
+ * Otherwise, it emits the next bookmark or null through an observable.
333
+ *
334
+ * By proving `null` as the bookmark_or_id, the current bookmark will be cleared.
335
+ *
336
+ * @param bookmark_or_id - The bookmark or ID to set as the current bookmark.
337
+ * @returns An observable that emits the next bookmark or null.
338
+ * @template T - The type of the bookmark data.
339
+ */
340
+ setCurrentBookmark<T extends BookmarkData = any>(bookmark_or_id: Bookmark<T> | string | null): Observable<Bookmark<T> | null>;
341
+ /**
342
+ * Sets the current bookmark.
343
+ * This method dispatches an event to notify listeners of a change in the current bookmark,
344
+ * and then dispatches a request to set the active bookmark in the application state.
345
+ *
346
+ * The request will be canceled if the subscription is unsubscribed before the request completes.
347
+ *
348
+ * @param bookmarkId - The ID of the bookmark to set as the current bookmark.
349
+ * @returns A subscription to the operation that sets the current bookmark.
350
+ */
351
+ setCurrentBookmarkAsync<T extends BookmarkData>(bookmark_or_id: Bookmark<T> | string | null): Promise<Bookmark<T> | null>;
352
+ /**
353
+ * Creates a new bookmark with the provided bookmark data.
354
+ * @template T - The type of bookmark data.
355
+ * @param {BookmarkCreateArgs<T>} newBookmarkData - The data for creating the bookmark.
356
+ * @returns {Observable<Bookmark<T>>} - An observable that emits the created bookmark.
357
+ */
358
+ createBookmark<T extends BookmarkData>(newBookmarkData: BookmarkCreateArgs<T>): Observable<Bookmark<T>>;
359
+ /**
360
+ * Asynchronously creates a new bookmark.
361
+ *
362
+ * @param bookmark - The new bookmark to create.
363
+ * @returns A promise that resolves to the created bookmark with its associated data.
364
+ */
365
+ createBookmarkAsync<T extends BookmarkData>(args: BookmarkCreateArgs<T>): Promise<Bookmark<T>>;
366
+ /**
367
+ * Updates a bookmark with the specified bookmarkId and bookmarkUpdates.
368
+ *
369
+ * @template T - The type of the bookmark data.
370
+ * @param {string} bookmarkId - The identifier of the bookmark to update.
371
+ * @param {BookmarkUpdate<T>} [bookmarkUpdates] - The updates to apply to the bookmark.
372
+ * @param {BookmarkUpdateOptions} [options] - The options for updating the bookmark.
373
+ * @returns {Promise<Bookmark<T>>} - A promise that resolves to the updated bookmark.
374
+ */
375
+ updateBookmark<T extends BookmarkData>(bookmarkId: string, bookmarkUpdates?: BookmarkUpdate<T>, options?: BookmarkUpdateOptions): Observable<Bookmark<T>>;
376
+ /**
377
+ * Updates a bookmark asynchronously.
378
+ *
379
+ * @param bookmark - The bookmark to update.
380
+ * @returns A promise that resolves to the updated bookmark with its associated data.
381
+ */
382
+ updateBookmarkAsync<T extends BookmarkData>(bookmarkId: string, bookmarkUpdates?: BookmarkUpdate<T>, options?: BookmarkUpdateOptions): Promise<Bookmark<T>>;
383
+ /**
384
+ * Deletes a bookmark with the specified bookmarkId.
385
+ *
386
+ * @param bookmarkId - The unique identifier of the bookmark to be deleted.
387
+ * @returns A Promise that resolves when the bookmark is successfully deleted.
388
+ * @throws {BookmarkProviderError} If there is an error deleting the bookmark.
389
+ */
390
+ deleteBookmark(bookmarkId: string): Observable<void>;
391
+ /**
392
+ * Deletes a bookmark asynchronously.
393
+ *
394
+ * @param bookmarkId - The ID of the bookmark to delete.
395
+ * @returns A Promise that resolves when the bookmark is deleted.
396
+ */
397
+ deleteBookmarkAsync(bookmarkId: string): Promise<void>;
398
+ /**
399
+ * Adds a bookmark to the favorites.
400
+ *
401
+ * @param bookmarkId - The ID of the bookmark to add.
402
+ * @returns A Promise that resolves to the added bookmark, or null if the bookmark was not added.
403
+ */
404
+ addBookmarkToFavorites(bookmarkId: string): Observable<BookmarkWithoutData | undefined>;
405
+ /**
406
+ * Asynchronously adds a bookmark to the user's favorites.
407
+ *
408
+ * @param bookmarkId - The ID of the bookmark to add to the user's favorites.
409
+ * @returns A Promise that resolves to the added Bookmark, or null if the operation failed.
410
+ */
411
+ addBookmarkToFavoritesAsync(bookmarkId: string): Promise<Bookmark | undefined>;
412
+ /**
413
+ * Removes a bookmark as a favorite.
414
+ *
415
+ * @param bookmarkId - The ID of the bookmark to remove as a favorite.
416
+ * @returns A Promise that resolves when the bookmark is successfully removed as a favorite.
417
+ * @throws {BookmarkProviderError} If the event is canceled or if there is a failure in removing the bookmark as a favorite.
418
+ */
419
+ removeBookmarkAsFavorite(bookmarkId: string): Observable<void>;
420
+ /**
421
+ * Removes a bookmark as a favorite asynchronously.
422
+ *
423
+ * @param bookmarkId - The ID of the bookmark to remove as a favorite.
424
+ * @returns A Promise that resolves when the bookmark is successfully removed as a favorite.
425
+ */
426
+ removeBookmarkAsFavoriteAsync(bookmarkId: string): Promise<void>;
427
+ /**
428
+ * Checks if a bookmark is in the favorites.
429
+ * @param bookmarkId - The ID of the bookmark to check.
430
+ * @returns A promise that resolves to a boolean indicating whether the bookmark is in the favorites.
431
+ */
432
+ isBookmarkInFavorites(bookmarkId: string): Observable<boolean>;
433
+ /**
434
+ * Checks if the specified bookmark is in the user's favorites.
435
+ *
436
+ * @param bookmarkId - The ID of the bookmark to check.
437
+ * @returns A Promise that resolves to a boolean indicating whether the bookmark is in the user's favorites.
438
+ */
439
+ isBookmarkInFavoritesAsync(bookmarkId: string): Promise<boolean>;
440
+ protected _getBookmarkInfo(bookmarkId: string, options?: {
441
+ timeout?: number;
442
+ }): Observable<BookmarkWithoutData>;
443
+ protected _getBookmarkData<T extends BookmarkData>(bookmarkId: string, options?: {
444
+ timeout?: number;
445
+ }): Observable<T | null>;
446
+ /**
447
+ * Dispatches an event of the specified type with the provided arguments.
448
+ *
449
+ * @param type - The type of the event to dispatch.
450
+ * @param args - The arguments to pass to the event.
451
+ * @returns A promise that resolves with the result of the event dispatch.
452
+ */
453
+ protected _dispatchEvent<TType extends keyof BookmarkProviderEventMap>(type: TType, args: FrameworkEventInitType<BookmarkProviderEventMap[NoInfer<TType>]>): Promise<BookmarkProviderEventMap[NoInfer<TType>]>;
454
+ protected _useScopedActions<TAction extends BookmarkActions>(ref?: string): {
455
+ ref: string;
456
+ action$: Observable<TAction>;
457
+ };
458
+ /**
459
+ * Disposes the BookmarkProvider.
460
+ */
461
+ dispose(): void;
462
+ }
@@ -0,0 +1,9 @@
1
+ import { type ActionWithSuffix } from '@equinor/fusion-observable';
2
+ import { BookmarkActions } from './BookmarkProvider.actions';
3
+ export declare class BookmarkFlowError extends Error {
4
+ readonly action: ActionWithSuffix<BookmarkActions, 'request'>;
5
+ constructor(message: string, action: ActionWithSuffix<BookmarkActions, 'request'>, options?: ErrorOptions);
6
+ }
7
+ export declare class BookmarkProviderError extends Error {
8
+ constructor(message: string, options?: ErrorOptions);
9
+ }
@@ -0,0 +1,78 @@
1
+ import type { FrameworkEventInit, IFrameworkEvent } from '@equinor/fusion-framework-module-event';
2
+ import type { Bookmark } from './types';
3
+ import type { BookmarkPayloadGenerator, BookmarkProvider } from './BookmarkProvider';
4
+ import { BookmarkNew, BookmarkUpdate } from './BookmarkClient.interface';
5
+ export interface BookmarkProviderEventMap {
6
+ /**
7
+ * An event that is emitted before current bookmark is changed.
8
+ */
9
+ onCurrentBookmarkChange: IFrameworkEvent<FrameworkEventInit<{
10
+ current?: Bookmark | null;
11
+ next: Bookmark | null;
12
+ }, BookmarkProvider>>;
13
+ /**
14
+ * An event that is emitted when the current bookmark has changed.
15
+ */
16
+ onCurrentBookmarkChanged: IFrameworkEvent<FrameworkEventInit<Bookmark | null, BookmarkProvider>>;
17
+ /**
18
+ * An event that is emitted before a bookmark is created.
19
+ */
20
+ onBookmarkCreate: IFrameworkEvent<FrameworkEventInit<BookmarkNew, BookmarkProvider>>;
21
+ /**
22
+ * An event that is emitted when a bookmark has been created.
23
+ */
24
+ onBookmarkCreated: IFrameworkEvent<FrameworkEventInit<Bookmark, BookmarkProvider>>;
25
+ /**
26
+ * An event that is emitted before a bookmark is updated.
27
+ */
28
+ onBookmarkUpdate: IFrameworkEvent<FrameworkEventInit<{
29
+ current?: Bookmark;
30
+ updates: BookmarkUpdate;
31
+ }, BookmarkProvider>>;
32
+ /**
33
+ * An event that is emitted before a bookmark is updated.
34
+ */
35
+ onBookmarkUpdated: IFrameworkEvent<FrameworkEventInit<Bookmark, BookmarkProvider>>;
36
+ /**
37
+ * An event that is emitted before a bookmark is removed.
38
+ */
39
+ onBookmarkDelete: IFrameworkEvent<FrameworkEventInit<{
40
+ id: string;
41
+ }, BookmarkProvider>>;
42
+ /**
43
+ * An event that is emitted before a bookmark is removed.
44
+ */
45
+ onBookmarkDeleted: IFrameworkEvent<FrameworkEventInit<{
46
+ id: string;
47
+ }, BookmarkProvider>>;
48
+ /**
49
+ * An event that is emitted before a bookmark is added to the user's favorites.
50
+ */
51
+ onBookmarkFavouriteRemove: IFrameworkEvent<FrameworkEventInit<{
52
+ id: string;
53
+ }, BookmarkProvider>>;
54
+ /**
55
+ * An event that is emitted when a bookmark is removed from the user's favorites.
56
+ */
57
+ onBookmarkFavouriteRemoved: IFrameworkEvent<FrameworkEventInit<{
58
+ id: string;
59
+ }, BookmarkProvider>>;
60
+ /**
61
+ * An event that is emitted before a bookmark is added to the user's favorites.
62
+ */
63
+ onBookmarkFavouriteAdd: IFrameworkEvent<FrameworkEventInit<{
64
+ id: string;
65
+ }, BookmarkProvider>>;
66
+ /**
67
+ * An event that is emitted when a bookmark is added to the user's favorites.
68
+ */
69
+ onBookmarkFavouriteAdded: IFrameworkEvent<FrameworkEventInit<Bookmark | undefined, BookmarkProvider>>;
70
+ /**
71
+ * An event that is emitted when a new bookmark payload generator is added.
72
+ */
73
+ onBookmarkPayloadCreatorAdded: IFrameworkEvent<FrameworkEventInit<BookmarkPayloadGenerator, BookmarkProvider>>;
74
+ }
75
+ declare module '@equinor/fusion-framework-module-event' {
76
+ interface FrameworkEventMap extends BookmarkProviderEventMap {
77
+ }
78
+ }
@@ -0,0 +1,79 @@
1
+ import { type Flow } from '@equinor/fusion-observable';
2
+ import { type BookmarkActions } from './BookmarkProvider.actions';
3
+ import type { IBookmarkClient } from './BookmarkClient.interface';
4
+ import type { BookmarkState } from './BookmarkProvider.store';
5
+ /**
6
+ * Handles the fetch bookmark action by making an API request to get the bookmark by its ID.
7
+ *
8
+ * @param api - The bookmark client API.
9
+ * @returns A flow that handles the fetch bookmark action.
10
+ */
11
+ export declare const handleFetchBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
12
+ /**
13
+ * Creates a flow for handling fetching bookmark data.
14
+ *
15
+ * @param api - The bookmark client API.
16
+ * @returns A flow of bookmark actions.
17
+ */
18
+ export declare const handleFetchBookmarkData: (api: IBookmarkClient) => Flow<BookmarkActions>;
19
+ /**
20
+ * Creates a Flow for handling fetching users bookmarks.
21
+ *
22
+ * @param api - The bookmark API client to use for fetching bookmarks.
23
+ * @param options - Optional configuration options, including a `throttle` value in milliseconds.
24
+ * @returns An observable that emits the result of the bookmark fetch operation.
25
+ */
26
+ export declare const handleFetchAllBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
27
+ /**
28
+ * Creates a Flow for handling creating bookmarks.
29
+ *
30
+ * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for creating bookmarks.
31
+ * @returns A flow that listens for `createBookmark` actions, creates a new bookmark using the provided API.
32
+ */
33
+ export declare const handleCreateBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
34
+ /**
35
+ * Creates a Flow for handling updating bookmarks.
36
+ *
37
+ * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for updating bookmarks.
38
+ * @returns A flow that listens for `updateBookmark` actions, updates the bookmark using the provided API.
39
+ */
40
+ export declare const handleUpdateBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
41
+ /**
42
+ * Creates a flow for handling deleting bookmarks.
43
+ *
44
+ * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for deleting bookmarks.
45
+ * @returns A flow that listens for `deleteBookmark` actions, deletes the bookmark using the provided API.
46
+ */
47
+ export declare const handleDeleteBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
48
+ /**
49
+ * Creates a Flow for handling deleting bookmarks.
50
+ *
51
+ * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for managing favorite bookmarks.
52
+ * @returns A flow that listens for `removeBookmarkAsFavorite` actions, removes the bookmark from the user's favorites using the provided API.
53
+ */
54
+ export declare const handleRemoveBookmarkFromFavorites: (api: IBookmarkClient) => Flow<BookmarkActions>;
55
+ /**
56
+ * Handles the flow of adding a bookmark as a favorite.
57
+ *
58
+ * @param api - The `IBookmarkClient` API instance to use for interacting with bookmarks.
59
+ * @returns An RxJS `Flow` that handles the `addBookmarkAsFavourite` action.
60
+ */
61
+ export declare const handleAddBookmarkAsFavorite: (api: IBookmarkClient) => Flow<BookmarkActions>;
62
+ /**
63
+ * Creates a flow for handling bookmark removal.
64
+ *
65
+ * This function observes actions related to deleting a bookmark or removing a bookmark as a favorite, and dispatches the appropriate actions for each case.
66
+ * If the bookmark is currently a favorite, it will dispatch an action to remove it as a favorite.
67
+ * If the bookmark is not a favorite, it will dispatch an action to delete it.
68
+ *
69
+ * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods checking if bookmarks are favorites.
70
+ * @returns A flow that handles the removal of a bookmark.
71
+ */
72
+ export declare const handleRemoveBookmark: (api: IBookmarkClient) => Flow<BookmarkActions>;
73
+ /**
74
+ * Defines a set of flows that handle various bookmark-related actions, such as fetching, creating, updating, and deleting bookmarks.
75
+ *
76
+ * @param api - An instance of `IBookmarkClient` that provides the necessary API methods for interacting with the bookmark service.
77
+ * @returns A combined flow that handles all the bookmark-related actions.
78
+ */
79
+ export declare const bookmarkApiFlows: (api: IBookmarkClient) => Flow<BookmarkActions, BookmarkState>;