@equinor/fusion-framework-module-bookmark 4.0.2 → 4.0.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/esm/BookmarkClient.js +18 -3
  3. package/dist/esm/BookmarkClient.js.map +1 -1
  4. package/dist/esm/{BookmarkProvider.error.js → BookmarkFlowError.js} +9 -7
  5. package/dist/esm/BookmarkFlowError.js.map +1 -0
  6. package/dist/esm/{BookmarkConfigurator.js → BookmarkModuleConfigurator.js} +36 -5
  7. package/dist/esm/BookmarkModuleConfigurator.js.map +1 -0
  8. package/dist/esm/BookmarkProvider.js +112 -23
  9. package/dist/esm/BookmarkProvider.js.map +1 -1
  10. package/dist/esm/BookmarkProvider.selectors.js +8 -0
  11. package/dist/esm/BookmarkProvider.selectors.js.map +1 -1
  12. package/dist/esm/BookmarkProviderError.js +20 -0
  13. package/dist/esm/BookmarkProviderError.js.map +1 -0
  14. package/dist/esm/{BookmarkProvider.actions.js → bookmark-actions.js} +1 -1
  15. package/dist/esm/bookmark-actions.js.map +1 -0
  16. package/dist/esm/bookmark-config.schema.js +2 -0
  17. package/dist/esm/bookmark-config.schema.js.map +1 -1
  18. package/dist/esm/bookmark-flows/bookmark-api-flows.js +28 -0
  19. package/dist/esm/bookmark-flows/bookmark-api-flows.js.map +1 -0
  20. package/dist/esm/bookmark-flows/handle-add-bookmark-as-favorite.js +27 -0
  21. package/dist/esm/bookmark-flows/handle-add-bookmark-as-favorite.js.map +1 -0
  22. package/dist/esm/bookmark-flows/handle-create-bookmark.js +27 -0
  23. package/dist/esm/bookmark-flows/handle-create-bookmark.js.map +1 -0
  24. package/dist/esm/bookmark-flows/handle-delete-bookmark.js +26 -0
  25. package/dist/esm/bookmark-flows/handle-delete-bookmark.js.map +1 -0
  26. package/dist/esm/bookmark-flows/handle-fetch-all-bookmark.js +29 -0
  27. package/dist/esm/bookmark-flows/handle-fetch-all-bookmark.js.map +1 -0
  28. package/dist/esm/bookmark-flows/handle-fetch-bookmark-data.js +26 -0
  29. package/dist/esm/bookmark-flows/handle-fetch-bookmark-data.js.map +1 -0
  30. package/dist/esm/bookmark-flows/handle-fetch-bookmark.js +30 -0
  31. package/dist/esm/bookmark-flows/handle-fetch-bookmark.js.map +1 -0
  32. package/dist/esm/bookmark-flows/handle-remove-bookmark-from-favorites.js +28 -0
  33. package/dist/esm/bookmark-flows/handle-remove-bookmark-from-favorites.js.map +1 -0
  34. package/dist/esm/bookmark-flows/handle-remove-bookmark.js +49 -0
  35. package/dist/esm/bookmark-flows/handle-remove-bookmark.js.map +1 -0
  36. package/dist/esm/bookmark-flows/handle-update-bookmark.js +28 -0
  37. package/dist/esm/bookmark-flows/handle-update-bookmark.js.map +1 -0
  38. package/dist/esm/bookmark-flows/index.js +11 -0
  39. package/dist/esm/bookmark-flows/index.js.map +1 -0
  40. package/dist/esm/bookmark-module.js +2 -2
  41. package/dist/esm/bookmark-module.js.map +1 -1
  42. package/dist/esm/bookmark.schemas.js +9 -3
  43. package/dist/esm/bookmark.schemas.js.map +1 -1
  44. package/dist/esm/create-bookmark-reducer.js +122 -0
  45. package/dist/esm/create-bookmark-reducer.js.map +1 -0
  46. package/dist/esm/{BookmarkProvider.store.js → create-bookmark-store.js} +3 -3
  47. package/dist/esm/create-bookmark-store.js.map +1 -0
  48. package/dist/esm/enable-bookmark.js +2 -1
  49. package/dist/esm/enable-bookmark.js.map +1 -1
  50. package/dist/esm/index.js +12 -1
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/version.js +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/types/BookmarkClient.d.ts +1 -0
  55. package/dist/types/{BookmarkProvider.error.d.ts → BookmarkFlowError.d.ts} +9 -4
  56. package/dist/types/{BookmarkConfigurator.d.ts → BookmarkModuleConfigurator.d.ts} +9 -4
  57. package/dist/types/BookmarkProvider.d.ts +81 -18
  58. package/dist/types/BookmarkProvider.interface.d.ts +1 -1
  59. package/dist/types/BookmarkProvider.selectors.d.ts +3 -3
  60. package/dist/types/BookmarkProviderError.d.ts +16 -0
  61. package/dist/types/{BookmarkProvider.actions.d.ts → bookmark-actions.d.ts} +3 -3
  62. package/dist/types/bookmark-flows/bookmark-api-flows.d.ts +11 -0
  63. package/dist/types/bookmark-flows/handle-add-bookmark-as-favorite.d.ts +10 -0
  64. package/dist/types/bookmark-flows/handle-create-bookmark.d.ts +10 -0
  65. package/dist/types/bookmark-flows/handle-delete-bookmark.d.ts +10 -0
  66. package/dist/types/bookmark-flows/handle-fetch-all-bookmark.d.ts +10 -0
  67. package/dist/types/bookmark-flows/handle-fetch-bookmark-data.d.ts +10 -0
  68. package/dist/types/bookmark-flows/handle-fetch-bookmark.d.ts +10 -0
  69. package/dist/types/bookmark-flows/handle-remove-bookmark-from-favorites.d.ts +10 -0
  70. package/dist/types/bookmark-flows/handle-remove-bookmark.d.ts +14 -0
  71. package/dist/types/bookmark-flows/handle-update-bookmark.d.ts +10 -0
  72. package/dist/types/bookmark-flows/index.d.ts +10 -0
  73. package/dist/types/bookmark-module.d.ts +1 -1
  74. package/dist/types/{BookmarkProvider.reducer.d.ts → create-bookmark-reducer.d.ts} +39 -39
  75. package/dist/types/{BookmarkProvider.store.d.ts → create-bookmark-store.d.ts} +2 -2
  76. package/dist/types/enable-bookmark.d.ts +1 -1
  77. package/dist/types/index.d.ts +12 -1
  78. package/dist/types/version.d.ts +1 -1
  79. package/package.json +11 -11
  80. package/src/BookmarkClient.ts +21 -3
  81. package/src/{BookmarkProvider.error.ts → BookmarkFlowError.ts} +9 -7
  82. package/src/{BookmarkConfigurator.ts → BookmarkModuleConfigurator.ts} +40 -11
  83. package/src/BookmarkProvider.interface.ts +3 -2
  84. package/src/BookmarkProvider.selectors.ts +10 -2
  85. package/src/BookmarkProvider.ts +112 -23
  86. package/src/BookmarkProviderError.ts +19 -0
  87. package/src/{BookmarkProvider.actions.ts → bookmark-actions.ts} +1 -1
  88. package/src/bookmark-config.schema.ts +2 -0
  89. package/src/bookmark-flows/bookmark-api-flows.ts +45 -0
  90. package/src/bookmark-flows/handle-add-bookmark-as-favorite.ts +49 -0
  91. package/src/bookmark-flows/handle-create-bookmark.ts +47 -0
  92. package/src/bookmark-flows/handle-delete-bookmark.ts +47 -0
  93. package/src/bookmark-flows/handle-fetch-all-bookmark.ts +53 -0
  94. package/src/bookmark-flows/handle-fetch-bookmark-data.ts +58 -0
  95. package/src/bookmark-flows/handle-fetch-bookmark.ts +64 -0
  96. package/src/bookmark-flows/handle-remove-bookmark-from-favorites.ts +49 -0
  97. package/src/bookmark-flows/handle-remove-bookmark.ts +76 -0
  98. package/src/bookmark-flows/handle-update-bookmark.ts +48 -0
  99. package/src/bookmark-flows/index.ts +10 -0
  100. package/src/bookmark-module.ts +2 -2
  101. package/src/bookmark.schemas.ts +10 -4
  102. package/src/create-bookmark-reducer.ts +149 -0
  103. package/src/{BookmarkProvider.store.ts → create-bookmark-store.ts} +4 -4
  104. package/src/enable-bookmark.ts +3 -2
  105. package/src/index.ts +12 -1
  106. package/src/version.ts +1 -1
  107. package/dist/esm/BookmarkConfigurator.js.map +0 -1
  108. package/dist/esm/BookmarkProvider.actions.js.map +0 -1
  109. package/dist/esm/BookmarkProvider.error.js.map +0 -1
  110. package/dist/esm/BookmarkProvider.flows.js +0 -217
  111. package/dist/esm/BookmarkProvider.flows.js.map +0 -1
  112. package/dist/esm/BookmarkProvider.reducer.js +0 -113
  113. package/dist/esm/BookmarkProvider.reducer.js.map +0 -1
  114. package/dist/esm/BookmarkProvider.store.js.map +0 -1
  115. package/dist/types/BookmarkProvider.flows.d.ts +0 -79
  116. package/src/BookmarkProvider.flows.ts +0 -421
  117. package/src/BookmarkProvider.reducer.ts +0 -144
@@ -0,0 +1,149 @@
1
+ import {
2
+ createReducer,
3
+ getBaseType,
4
+ isCompleteAction,
5
+ isFailureAction,
6
+ isRequestAction,
7
+ isSuccessAction,
8
+ type ActionBaseType,
9
+ } from '@equinor/fusion-observable';
10
+
11
+ import { bookmarkActions, type BookmarkActions } from './bookmark-actions';
12
+ import type { BookmarkState } from './create-bookmark-store';
13
+ import type { BookmarkFlowError } from './BookmarkFlowError';
14
+ import type { BookmarkWithoutData } from './types';
15
+ import { enableMapSet } from 'immer';
16
+
17
+ enableMapSet();
18
+
19
+ /**
20
+ * Utility function that extracts the base action type from a given action object.
21
+ */
22
+ const getBookmarkBaseAction = <T extends BookmarkActions>(action: T): ActionBaseType<T> => {
23
+ return getBaseType(action.type) as ActionBaseType<T>;
24
+ };
25
+
26
+ /**
27
+ * The default initial state for the BookmarkProvider reducer.
28
+ */
29
+ const defaultInitialState: BookmarkState = {
30
+ status: new Set<ActionBaseType<BookmarkActions>>(),
31
+ errors: {} as Record<ActionBaseType<BookmarkActions>, BookmarkFlowError>,
32
+ bookmarks: {},
33
+ };
34
+
35
+ /**
36
+ * Creates a reducer for managing the state of bookmarks.
37
+ *
38
+ * @todo TODO(#5135) - add fast-deep-equal to compare bookmarks
39
+ *
40
+ * @param initialState - The initial state of the bookmarks.
41
+ * @returns A reducer function for managing the bookmarks state.
42
+ */
43
+ export const createBookmarkReducer = (initialState?: Partial<BookmarkState>) => {
44
+ // Layer any provided overrides on top of the module's defaults for the initial state.
45
+ const initial = { ...defaultInitialState, ...initialState };
46
+ return createReducer<BookmarkState, BookmarkActions>(initial, (builder) => {
47
+ builder
48
+ .addCase(bookmarkActions.fetchBookmark.success, (state, action) => {
49
+ // only update the bookmark if it already exists in the store
50
+ if (action.payload.id in state.bookmarks) {
51
+ state.bookmarks[action.payload.id] = action.payload;
52
+ }
53
+ })
54
+ .addCase(bookmarkActions.fetchBookmarkData.success, (state, action) => {
55
+ const { bookmarkId, data } = action.payload;
56
+ // only apply the fetched data if it belongs to the current bookmark
57
+ if (state.currentBookmark?.id === bookmarkId) {
58
+ state.currentBookmark.payload = data;
59
+ }
60
+ })
61
+ .addCase(bookmarkActions.fetchBookmarks.success, (state, action) => {
62
+ // normalize the bookmarks array into a record
63
+ // build a lookup record keyed by bookmark id
64
+ state.bookmarks = action.payload.reduce(
65
+ (acc, bookmark) => {
66
+ acc[bookmark.id] = bookmark;
67
+ return acc;
68
+ },
69
+ {} as Record<string, BookmarkWithoutData>,
70
+ );
71
+ })
72
+ .addCase(bookmarkActions.setBookmark, (state, action) => {
73
+ const bookmarkId = action.payload.id;
74
+ // only update the bookmark if it already exists in the store
75
+ if (bookmarkId in state.bookmarks) {
76
+ state.bookmarks[bookmarkId] = action.payload;
77
+ }
78
+ // keep the current bookmark in sync if it's the one being set
79
+ if (state.currentBookmark?.id === bookmarkId) {
80
+ state.currentBookmark = action.payload;
81
+ }
82
+ })
83
+ .addCase(bookmarkActions.setCurrentBookmark, (state, action) => {
84
+ state.currentBookmark = action.payload;
85
+ })
86
+ .addCase(bookmarkActions.createBookmark.success, (state, action) => {
87
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
88
+ const { payload, ...bookmark } = action.payload;
89
+ state.bookmarks[bookmark.id] = bookmark;
90
+ })
91
+ .addCase(bookmarkActions.updateBookmark.success, (state, action) => {
92
+ const bookmarkId = action.payload.id;
93
+ const hasBookmark = bookmarkId in state.bookmarks;
94
+ const isCurrent = state.currentBookmark?.id === bookmarkId;
95
+
96
+ // get the current bookmark
97
+ const current = hasBookmark
98
+ ? state.bookmarks[bookmarkId]
99
+ : isCurrent
100
+ ? state.currentBookmark
101
+ : null;
102
+
103
+ // merge the current bookmark with the new data
104
+ const next = { ...current, ...action.payload };
105
+
106
+ // if the bookmark is in the current state, update it
107
+ if (hasBookmark) {
108
+ state.bookmarks[bookmarkId] = next;
109
+ }
110
+
111
+ // if the bookmark is the selected bookmark, update it
112
+ if (isCurrent) {
113
+ state.currentBookmark = next;
114
+ }
115
+ })
116
+
117
+ /** removal of bookmarks */
118
+ .addCase(bookmarkActions.deleteBookmark.success, (state, action) => {
119
+ delete state.bookmarks[action.payload];
120
+ })
121
+ .addCase(bookmarkActions.removeBookmarkAsFavourite.success, (state, action) => {
122
+ delete state.bookmarks[action.payload];
123
+ })
124
+
125
+ /** when a request is made, add the action type to the status object */
126
+ .addMatcher(isRequestAction, (state, action) => {
127
+ const actionName = getBookmarkBaseAction(action);
128
+ state.status.add(actionName);
129
+ })
130
+
131
+ /** when a request succeeds, remove the error from the errors object */
132
+ .addMatcher(isSuccessAction, (state, action) => {
133
+ const actionName = getBookmarkBaseAction(action);
134
+ delete state.errors[actionName];
135
+ })
136
+
137
+ /** when a request fails, add the error to the errors object */
138
+ .addMatcher(isFailureAction, (state, action) => {
139
+ const actionName = getBookmarkBaseAction(action);
140
+ state.errors[actionName] = action.payload;
141
+ })
142
+
143
+ /** when a request is complete, remove the status from the status set */
144
+ .addMatcher(isCompleteAction, (state, action) => {
145
+ const actionName = getBookmarkBaseAction(action);
146
+ state.status.delete(actionName);
147
+ });
148
+ });
149
+ };
@@ -1,9 +1,9 @@
1
1
  import { FlowSubject, type ActionBaseType } from '@equinor/fusion-observable';
2
2
 
3
- import type { BookmarkActions } from './BookmarkProvider.actions';
4
- import type { BookmarkFlowError } from './BookmarkProvider.error';
5
- import { createBookmarkReducer } from './BookmarkProvider.reducer';
6
- import { bookmarkApiFlows } from './BookmarkProvider.flows';
3
+ import type { BookmarkActions } from './bookmark-actions';
4
+ import type { BookmarkFlowError } from './BookmarkFlowError';
5
+ import { createBookmarkReducer } from './create-bookmark-reducer';
6
+ import { bookmarkApiFlows } from './bookmark-flows';
7
7
  import type { IBookmarkClient } from './BookmarkClient.interface';
8
8
  import type { Bookmark, BookmarkWithoutData } from './types';
9
9
 
@@ -1,7 +1,7 @@
1
1
  import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
2
2
 
3
3
  import { module } from './bookmark-module';
4
- import type { BookmarkModuleConfigurator } from './BookmarkConfigurator';
4
+ import type { BookmarkModuleConfigurator } from './BookmarkModuleConfigurator';
5
5
 
6
6
  /**
7
7
  * Enables the bookmark module on a Fusion Framework module configurator.
@@ -28,13 +28,14 @@ import type { BookmarkModuleConfigurator } from './BookmarkConfigurator';
28
28
  * ```
29
29
  */
30
30
  export const enableBookmark = (
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ // biome-ignore lint/suspicious/noExplicitAny: IModulesConfigurator<any> widens to accept a configurator for any concrete module set
32
32
  configurator: IModulesConfigurator<any>,
33
33
  callback?: (builder: BookmarkModuleConfigurator) => void | Promise<void>,
34
34
  ): void => {
35
35
  configurator.addConfig({
36
36
  module,
37
37
  configure: async (builder) => {
38
+ // run the caller-provided configuration callback, if any
38
39
  if (callback) {
39
40
  Promise.resolve(callback(builder));
40
41
  }
package/src/index.ts CHANGED
@@ -1,4 +1,15 @@
1
- export { BookmarkModuleConfigurator } from './BookmarkConfigurator';
1
+ /**
2
+ * Bookmark module for the Fusion Framework.
3
+ *
4
+ * Provides bookmark management (create, update, delete, favourite) with
5
+ * application-scoped payloads and event-driven state updates.
6
+ *
7
+ * @see {@link enableBookmark} to enable the module in a configurator.
8
+ * @see {@link BookmarkProvider} for the runtime provider API.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export { BookmarkModuleConfigurator } from './BookmarkModuleConfigurator';
2
13
 
3
14
  export type {
4
15
  IBookmarkClient,
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '4.0.2';
2
+ export const version = '4.0.3';
@@ -1 +0,0 @@
1
- {"version":3,"file":"BookmarkConfigurator.js","sourceRoot":"","sources":["../../src/BookmarkConfigurator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,GAIlB,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAIrF,MAAM,qBAAqB,GAAG,oBAAoB;KAC/C,IAAI,CAAC;IACJ,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,IAAI;IAClB,OAAO,EAA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AE,KAAK,EAAE,IAAI,EAAE,CAAC,CACnF;IACD,yBAAyB,EAAE,iBAAiB,CAC1C,2BAA2B,EAC3B,CAAC,UAAkB,EAAE,IAAyB,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE;KACnC,CAAC,EACF,CAAC,UAAkB,EAAE,IAAyB,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE;KACnC,CAAC,EACF,CAAC,KAAwB,EAAE,IAAwB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CACnF;CACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BookmarkProvider.error.js","sourceRoot":"","sources":["../../src/BookmarkProvider.error.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAIxB;IAHlB,YACE,OAAe;IACf,yDAAyD;IACzC,MAAoD,EACpE,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAHR,WAAM,GAAN,MAAM,CAA8C;QAIpE,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
@@ -1,217 +0,0 @@
1
- import { from, of, merge, concat } from 'rxjs';
2
- import { switchMap, map, catchError, filter, concatMap, mergeMap, groupBy, throttleTime, last, } from 'rxjs/operators';
3
- import { getBaseType } from '@equinor/fusion-observable';
4
- import { bookmarkActions as actions } from './BookmarkProvider.actions';
5
- import { BookmarkFlowError } from './BookmarkProvider.error';
6
- const defaultThrottleTime = 200;
7
- /**
8
- * Handles the fetch bookmark action by making an API request to get the bookmark by its ID.
9
- *
10
- * @param api - The bookmark client API.
11
- * @returns A flow that handles the fetch bookmark action.
12
- */
13
- export const handleFetchBookmark = (api) => (action$) => {
14
- /**
15
- * Observable that represents the flow of fetching bookmarks.
16
- * It listens for `fetchBookmark` actions, makes an API request to get the bookmark by ID,
17
- * and emits corresponding success or failure actions based on the API response.
18
- */
19
- const flow$ = action$.pipe(filter(actions.fetchBookmark.match), groupBy((action) => action.payload), mergeMap((group) => group.pipe(throttleTime(defaultThrottleTime))), switchMap((action) => from(api.getBookmarkById(action.payload)).pipe(last(), map((bookmark) => actions.fetchBookmark.success(bookmark, action.meta)), catchError((error) => of(actions.fetchBookmark.failure(new BookmarkFlowError('Failed to fetch bookmark', action, {
20
- cause: error,
21
- }), action.meta))))));
22
- return flow$;
23
- };
24
- /**
25
- * Creates a flow for handling fetching bookmark data.
26
- *
27
- * @param api - The bookmark client API.
28
- * @returns A flow of bookmark actions.
29
- */
30
- export const handleFetchBookmarkData = (api) => (action$) => {
31
- const flow$ = action$.pipe(filter(actions.fetchBookmarkData.match), groupBy((action) => JSON.stringify(action.payload)), mergeMap((group) => group.pipe(throttleTime(defaultThrottleTime))), switchMap((action) => {
32
- return from(api.getBookmarkData(action.payload)).pipe(last(), map((data) => actions.fetchBookmarkData.success(action.payload, data, action.meta)), catchError((error) => of(actions.fetchBookmarkData.failure(new BookmarkFlowError('Failed to fetch bookmark payload', action, {
33
- cause: error,
34
- }), action.meta))));
35
- }));
36
- return flow$;
37
- };
38
- /**
39
- * Creates a Flow for handling fetching users bookmarks.
40
- *
41
- * @param api - The bookmark API client to use for fetching bookmarks.
42
- * @param options - Optional configuration options, including a `throttle` value in milliseconds.
43
- * @returns An observable that emits the result of the bookmark fetch operation.
44
- */
45
- export const handleFetchAllBookmark = (api) => (action$) => {
46
- /**
47
- * This flow is triggered by the `fetchBookmarks` action and uses the `throttleTime` operator
48
- * to limit the number of requests made to the API. The `switchMap` operator is used to make
49
- * the API call and map the response to the appropriate action (success or failure).
50
- */
51
- const flow$ = action$.pipe(filter(actions.fetchBookmarks.match), groupBy((action) => JSON.stringify(action.payload)), switchMap((group) => group.pipe(throttleTime(defaultThrottleTime))), switchMap((action) => from(api.getAllBookmarks(action.payload)).pipe(last(), map((value) => actions.fetchBookmarks.success(value, action.meta)), catchError((error) => of(actions.fetchBookmarks.failure(new BookmarkFlowError('Failed to fetch all bookmarks', action, {
52
- cause: error,
53
- }), action.meta))))));
54
- return flow$;
55
- };
56
- /**
57
- * Creates a Flow for handling creating bookmarks.
58
- *
59
- * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for creating bookmarks.
60
- * @returns A flow that listens for `createBookmark` actions, creates a new bookmark using the provided API.
61
- */
62
- export const handleCreateBookmark = (api) => (action$) => {
63
- /**
64
- * This flow listens for the `createBookmark` action, and then uses the `api.createBookmark` function to create a new bookmark.
65
- * If the bookmark is created successfully, it dispatches the `createBookmark.success` action with the new bookmark.
66
- * If there is an error creating the bookmark, it dispatches the `fetchBookmark.failure` action with an error.
67
- *
68
- * The `concatMap` operator is used to prevent aborting the request if a new `createBookmark` action is dispatched while the previous request is in flight.
69
- */
70
- const flow$ = action$.pipe(filter(actions.createBookmark.match), concatMap((action) => {
71
- return from(api.createBookmark(action.payload)).pipe(last(), map((bookmark) => actions.createBookmark.success(bookmark, action.meta)), catchError((error) => of(actions.createBookmark.failure(new BookmarkFlowError('Failed to create new bookmark', action, {
72
- cause: error,
73
- }), action.meta))));
74
- }));
75
- return flow$;
76
- };
77
- /**
78
- * Creates a Flow for handling updating bookmarks.
79
- *
80
- * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for updating bookmarks.
81
- * @returns A flow that listens for `updateBookmark` actions, updates the bookmark using the provided API.
82
- */
83
- export const handleUpdateBookmark = (api) => (action$) => {
84
- /**
85
- * This flow listens for `updateBookmark` actions, then calls the `api.updateBookmark` function with the action payload.
86
- * If the update is successful, it dispatches a `updateBookmark.success` action with the updated bookmark.
87
- * If there is an error, it dispatches a `fetchBookmark.failure` action with the error.
88
- *
89
- * The `concatMap` operator is used to prevent aborting the request if a new `updateBookmark` action is dispatched while the previous request is in flight.
90
- */
91
- const flow$ = action$.pipe(filter(actions.updateBookmark.match), concatMap((action) => {
92
- const { bookmarkId, updates } = action.payload;
93
- return from(api.updateBookmark(bookmarkId, updates)).pipe(last(), map((bookmark) => actions.updateBookmark.success(bookmark, action.meta)), catchError((error) => of(actions.updateBookmark.failure(new BookmarkFlowError('Failed to update bookmark', action, {
94
- cause: error,
95
- }), action.meta))));
96
- }));
97
- return flow$;
98
- };
99
- /**
100
- * Creates a flow for handling deleting bookmarks.
101
- *
102
- * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for deleting bookmarks.
103
- * @returns A flow that listens for `deleteBookmark` actions, deletes the bookmark using the provided API.
104
- */
105
- export const handleDeleteBookmark = (api) => (action$) => {
106
- /**
107
- * - Listens for the `deleteBookmark` action.
108
- * - Calls the `api.deleteBookmark` function to delete the bookmark.
109
- * - Maps the successful response to the `deleteBookmark.success` action.
110
- * - Handles errors by dispatching the `fetchBookmark.failure` action with a `BookmarkFlowError`.
111
- * - Uses `concatMap` to prevent aborting the request if a new action is dispatched while the previous request is in flight.
112
- */
113
- const flow$ = action$.pipe(filter(actions.deleteBookmark.match), concatMap((action) => from(api.deleteBookmark(action.payload)).pipe(last(), map(() => actions.deleteBookmark.success(action.payload, action.meta)), catchError((error) => of(actions.deleteBookmark.failure(new BookmarkFlowError('Failed to delete bookmark', action, {
114
- cause: error,
115
- }), action.meta))))));
116
- return flow$;
117
- };
118
- /**
119
- * Creates a Flow for handling deleting bookmarks.
120
- *
121
- * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods for managing favorite bookmarks.
122
- * @returns A flow that listens for `removeBookmarkAsFavorite` actions, removes the bookmark from the user's favorites using the provided API.
123
- */
124
- export const handleRemoveBookmarkFromFavorites = (api) => (action$) => {
125
- /**
126
- * - Listens for the `removeBookmarkAsFavourite` action.
127
- * - Calls the `api.removeBookmarkFromFavorites` function to remove the bookmark from favorites.
128
- * - On success, dispatches the `removeBookmarkAsFavourite.success` action.
129
- * - On error, dispatches the `fetchBookmark.failure` action with a `BookmarkFlowError`.
130
- * - Uses `concatMap` to prevent aborting the request if a new action is dispatched while the previous request is in flight.
131
- */
132
- const flow$ = action$.pipe(filter(actions.removeBookmarkAsFavourite.match),
133
- // use concat to prevent aborting the request if a new action is dispatched while the previous request is in flight
134
- concatMap((action) => from(api.removeBookmarkFromFavorites(action.payload)).pipe(last(), map(() => actions.removeBookmarkAsFavourite.success(action.payload, action.meta)), catchError((error) => of(actions.removeBookmarkAsFavourite.failure(new BookmarkFlowError('Failed to remove bookmark as favorite', action, {
135
- cause: error,
136
- }), action.meta))))));
137
- return flow$;
138
- };
139
- /**
140
- * Handles the flow of adding a bookmark as a favorite.
141
- *
142
- * @param api - The `IBookmarkClient` API instance to use for interacting with bookmarks.
143
- * @returns An RxJS `Flow` that handles the `addBookmarkAsFavourite` action.
144
- */
145
- export const handleAddBookmarkAsFavorite = (api) => (action$) => {
146
- /**
147
- * Handles the flow for adding a bookmark as a favorite.
148
- *
149
- * This flow listens for the `addBookmarkAsFavourite` action, and then:
150
- * 1. Calls the `addBookmarkToFavorites` API to add the bookmark to the user's favorites.
151
- * 2. If the API call is successful, dispatches the `addBookmarkAsFavourite.success` action.
152
- * 3. If the API call fails, dispatches the `addBookmarkAsFavourite.failure` action with an error.
153
- */
154
- const flow$ = action$.pipe(filter(actions.addBookmarkAsFavourite.match), concatMap((action) => from(api.addBookmarkToFavorites(action.payload)).pipe(last(), map(() => actions.addBookmarkAsFavourite.success(action.payload, action.meta)), catchError((error) => of(actions.addBookmarkAsFavourite.failure(new BookmarkFlowError('Failed to add bookmark as favorite', action, {
155
- cause: error,
156
- }), action.meta))))));
157
- return flow$;
158
- };
159
- /**
160
- * Creates a flow for handling bookmark removal.
161
- *
162
- * This function observes actions related to deleting a bookmark or removing a bookmark as a favorite, and dispatches the appropriate actions for each case.
163
- * If the bookmark is currently a favorite, it will dispatch an action to remove it as a favorite.
164
- * If the bookmark is not a favorite, it will dispatch an action to delete it.
165
- *
166
- * @param api - An instance of the `IBookmarkClient` interface, which provides the necessary API methods checking if bookmarks are favorites.
167
- * @returns A flow that handles the removal of a bookmark.
168
- */
169
- export const handleRemoveBookmark = (api) => (action$) => {
170
- /**
171
- * Handles the removal of a bookmark from the application.
172
- *
173
- * This function is responsible for determining whether the bookmark being removed is a favorite or not,
174
- * and then dispatching the appropriate action to either remove the bookmark as a favorite or delete the bookmark entirely.
175
- *
176
- * Uses `concatMap` to prevent aborting the request if a new action is dispatched while the previous request is in flight.
177
- */
178
- const dispatch$ = action$.pipe(filter(actions.removeBookmark.match), concatMap(({ payload: bookmarkId }) => {
179
- return from(api.isBookmarkFavorite(bookmarkId)).pipe(map((isFavorite) => {
180
- const action = isFavorite ? actions.removeBookmarkAsFavourite : actions.deleteBookmark;
181
- return action(bookmarkId);
182
- }));
183
- }));
184
- /**
185
- * Handles failures for deleting a bookmark or removing a bookmark as a favorite.
186
- */
187
- const failure$ = merge(action$.pipe(filter(actions.deleteBookmark.failure.match)), action$.pipe(filter(actions.removeBookmarkAsFavourite.failure.match))).pipe(map((action) => actions.removeBookmark.failure(action.payload, action.meta)));
188
- /**
189
- * Handles the success of deleting a bookmark or removing a bookmark as a favorite.
190
- */
191
- const success$ = merge(action$.pipe(filter(actions.deleteBookmark.success.match)), action$.pipe(filter(actions.removeBookmarkAsFavourite.success.match))).pipe(map((action) => actions.removeBookmark.success({
192
- type: getBaseType(action.type),
193
- bookmarkId: action.payload,
194
- }, action.meta)));
195
- /**
196
- * First dispatch either deletions of bookmark or removals of bookmarks as favorites.
197
- * Then observer the results of those actions and dispatch the appropriate actions.
198
- */
199
- const flow$ = concat(dispatch$, merge(failure$, success$));
200
- return flow$;
201
- };
202
- /**
203
- * Defines a set of flows that handle various bookmark-related actions, such as fetching, creating, updating, and deleting bookmarks.
204
- *
205
- * @param api - An instance of `IBookmarkClient` that provides the necessary API methods for interacting with the bookmark service.
206
- * @returns A combined flow that handles all the bookmark-related actions.
207
- */
208
- export const bookmarkApiFlows = (api) => {
209
- // return handleFetchAllBookmark(api);
210
- /**
211
- * Combines multiple Bookmark-related observable flows into a single observable stream.
212
- * The resulting observable stream emits the combined effects of these flows,
213
- * which can be used to update the application state.
214
- */
215
- return (actions$, state$) => of(handleFetchBookmark, handleFetchBookmarkData, handleFetchAllBookmark, handleCreateBookmark, handleUpdateBookmark, handleDeleteBookmark, handleRemoveBookmark, handleRemoveBookmarkFromFavorites, handleAddBookmarkAsFavorite).pipe(mergeMap((flow) => flow(api)(actions$, state$)));
216
- };
217
- //# sourceMappingURL=BookmarkProvider.flows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BookmarkProvider.flows.js","sourceRoot":"","sources":["../../src/BookmarkProvider.flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,GAAG,EACH,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,IAAI,GACL,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAA8B,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAErF,OAAO,EAAE,eAAe,IAAI,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAG9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,CAAC,GAAoB,EAAyB,EAAE,CAChD,CAAC,OAAO,EAAE,EAAE;IACV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,GAAoB,EAAwC,EAAE;IAC7F,sCAAsC;IACtC;;;;OAIG;IACH,OAAO,CAAC,QAAqC,EAAE,MAAiC,EAAE,EAAE,CAClF,EAAE,CACA,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,EACjC,2BAA2B,CAC5B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC"}
@@ -1,113 +0,0 @@
1
- import { createReducer, getBaseType, isCompleteAction, isFailureAction, isRequestAction, isSuccessAction, } from '@equinor/fusion-observable';
2
- import { bookmarkActions } from './BookmarkProvider.actions';
3
- import { enableMapSet } from 'immer';
4
- enableMapSet();
5
- /**
6
- * Utility function that extracts the base action type from a given action object.
7
- */
8
- const getBookmarkBaseAction = (action) => {
9
- return getBaseType(action.type);
10
- };
11
- /**
12
- * The default initial state for the BookmarkProvider reducer.
13
- */
14
- const defaultInitialState = {
15
- status: new Set(),
16
- errors: {},
17
- bookmarks: {},
18
- };
19
- /**
20
- * Creates a reducer for managing the state of bookmarks.
21
- *
22
- * @todo add fast-deep-equal to compare bookmarks
23
- *
24
- * @param initialState - The initial state of the bookmarks.
25
- * @returns A reducer function for managing the bookmarks state.
26
- */
27
- export const createBookmarkReducer = (initialState) => createReducer({ ...defaultInitialState, ...initialState }, (builder) => {
28
- builder
29
- .addCase(bookmarkActions.fetchBookmark.success, (state, action) => {
30
- if (action.payload.id in state.bookmarks) {
31
- state.bookmarks[action.payload.id] = action.payload;
32
- }
33
- })
34
- .addCase(bookmarkActions.fetchBookmarkData.success, (state, action) => {
35
- const { bookmarkId, data } = action.payload;
36
- if (state.currentBookmark?.id === bookmarkId) {
37
- state.currentBookmark.payload = data;
38
- }
39
- })
40
- .addCase(bookmarkActions.fetchBookmarks.success, (state, action) => {
41
- // normalize the bookmarks array into a record
42
- state.bookmarks = action.payload.reduce((acc, bookmark) => {
43
- acc[bookmark.id] = bookmark;
44
- return acc;
45
- }, {});
46
- })
47
- .addCase(bookmarkActions.setBookmark, (state, action) => {
48
- const bookmarkId = action.payload.id;
49
- if (bookmarkId in state.bookmarks) {
50
- state.bookmarks[bookmarkId] = action.payload;
51
- }
52
- if (state.currentBookmark?.id === bookmarkId) {
53
- state.currentBookmark = action.payload;
54
- }
55
- })
56
- .addCase(bookmarkActions.setCurrentBookmark, (state, action) => {
57
- state.currentBookmark = action.payload;
58
- })
59
- .addCase(bookmarkActions.createBookmark.success, (state, action) => {
60
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
- const { payload, ...bookmark } = action.payload;
62
- state.bookmarks[bookmark.id] = bookmark;
63
- })
64
- .addCase(bookmarkActions.updateBookmark.success, (state, action) => {
65
- const bookmarkId = action.payload.id;
66
- const hasBookmark = bookmarkId in state.bookmarks;
67
- const isCurrent = state.currentBookmark?.id === bookmarkId;
68
- // get the current bookmark
69
- const current = hasBookmark
70
- ? state.bookmarks[bookmarkId]
71
- : isCurrent
72
- ? state.currentBookmark
73
- : null;
74
- // merge the current bookmark with the new data
75
- const next = { ...current, ...action.payload };
76
- // if the bookmark is in the current state, update it
77
- if (hasBookmark) {
78
- state.bookmarks[bookmarkId] = next;
79
- }
80
- // if the bookmark is the selected bookmark, update it
81
- if (isCurrent) {
82
- state.currentBookmark = next;
83
- }
84
- })
85
- /** removal of bookmarks */
86
- .addCase(bookmarkActions.deleteBookmark.success, (state, action) => {
87
- delete state.bookmarks[action.payload];
88
- })
89
- .addCase(bookmarkActions.removeBookmarkAsFavourite.success, (state, action) => {
90
- delete state.bookmarks[action.payload];
91
- })
92
- /** when a request is made, add the action type to the status object */
93
- .addMatcher(isRequestAction, (state, action) => {
94
- const actionName = getBookmarkBaseAction(action);
95
- state.status.add(actionName);
96
- })
97
- /** when a request succeeds, remove the error from the errors object */
98
- .addMatcher(isSuccessAction, (state, action) => {
99
- const actionName = getBookmarkBaseAction(action);
100
- delete state.errors[actionName];
101
- })
102
- /** when a request fails, add the error to the errors object */
103
- .addMatcher(isFailureAction, (state, action) => {
104
- const actionName = getBookmarkBaseAction(action);
105
- state.errors[actionName] = action.payload;
106
- })
107
- /** when a request is complete, remove the status from the status set */
108
- .addMatcher(isCompleteAction, (state, action) => {
109
- const actionName = getBookmarkBaseAction(action);
110
- state.status.delete(actionName);
111
- });
112
- });
113
- //# sourceMappingURL=BookmarkProvider.reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BookmarkProvider.reducer.js","sourceRoot":"","sources":["../../src/BookmarkProvider.reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,eAAe,GAEhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAwB,MAAM,4BAA4B,CAAC;AAInF,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,YAAY,EAAE,CAAC;AAEf;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAA4B,MAAS,EAAqB,EAAE;IACxF,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAsB,CAAC;AACvD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAkB;IACzC,MAAM,EAAE,IAAI,GAAG,EAAmC;IAClD,MAAM,EAAE,EAAgE;IACxE,SAAS,EAAE,EAAE;CACd,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,YAAqC,EAAE,EAAE,CAC7E,aAAa,CACX,EAAE,GAAG,mBAAmB,EAAE,GAAG,YAAY,EAAE,EAC3C,CAAC,OAAO,EAAE,EAAE;IACV,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAA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