@equinor/fusion-framework-module-bookmark 0.1.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 (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +11 -0
  4. package/dist/esm/bookmark-config-builder.js +70 -0
  5. package/dist/esm/bookmark-config-builder.js.map +1 -0
  6. package/dist/esm/bookmark-provider.js +130 -0
  7. package/dist/esm/bookmark-provider.js.map +1 -0
  8. package/dist/esm/client/bookmarkActions.js +8 -0
  9. package/dist/esm/client/bookmarkActions.js.map +1 -0
  10. package/dist/esm/client/bookmarkClient.js +212 -0
  11. package/dist/esm/client/bookmarkClient.js.map +1 -0
  12. package/dist/esm/client/bookmarkFlows.js +30 -0
  13. package/dist/esm/client/bookmarkFlows.js.map +1 -0
  14. package/dist/esm/client/bookmarkReducer.js +23 -0
  15. package/dist/esm/client/bookmarkReducer.js.map +1 -0
  16. package/dist/esm/configurator.js +172 -0
  17. package/dist/esm/configurator.js.map +1 -0
  18. package/dist/esm/enable-bookmark.js +10 -0
  19. package/dist/esm/enable-bookmark.js.map +1 -0
  20. package/dist/esm/index.js +6 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/module.js +27 -0
  23. package/dist/esm/module.js.map +1 -0
  24. package/dist/esm/types.js +2 -0
  25. package/dist/esm/types.js.map +1 -0
  26. package/dist/esm/utils/handle-url.js +11 -0
  27. package/dist/esm/utils/handle-url.js.map +1 -0
  28. package/dist/esm/utils/index.js +2 -0
  29. package/dist/esm/utils/index.js.map +1 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -0
  31. package/dist/types/bookmark-config-builder.d.ts +25 -0
  32. package/dist/types/bookmark-provider.d.ts +63 -0
  33. package/dist/types/client/bookmarkActions.d.ts +21 -0
  34. package/dist/types/client/bookmarkClient.d.ts +48 -0
  35. package/dist/types/client/bookmarkFlows.d.ts +22 -0
  36. package/dist/types/client/bookmarkReducer.d.ts +5 -0
  37. package/dist/types/configurator.d.ts +47 -0
  38. package/dist/types/enable-bookmark.d.ts +4 -0
  39. package/dist/types/index.d.ts +5 -0
  40. package/dist/types/module.d.ts +22 -0
  41. package/dist/types/types.d.ts +54 -0
  42. package/dist/types/utils/handle-url.d.ts +2 -0
  43. package/dist/types/utils/index.d.ts +1 -0
  44. package/package.json +48 -0
  45. package/src/bookmark-config-builder.ts +171 -0
  46. package/src/bookmark-provider.ts +288 -0
  47. package/src/client/bookmarkActions.ts +34 -0
  48. package/src/client/bookmarkClient.ts +290 -0
  49. package/src/client/bookmarkFlows.ts +66 -0
  50. package/src/client/bookmarkReducer.ts +29 -0
  51. package/src/configurator.ts +260 -0
  52. package/src/enable-bookmark.ts +32 -0
  53. package/src/index.ts +18 -0
  54. package/src/module.ts +40 -0
  55. package/src/types.ts +65 -0
  56. package/src/utils/handle-url.ts +13 -0
  57. package/src/utils/index.ts +1 -0
  58. package/tsconfig.json +36 -0
package/src/module.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { Module, ModulesInstance } from '@equinor/fusion-framework-module';
2
+ import { EventModule } from '@equinor/fusion-framework-module-event';
3
+ import { ServicesModule } from '@equinor/fusion-framework-module-services';
4
+ import { AppModule } from '@equinor/fusion-framework-module-app';
5
+ import { ContextModule } from '@equinor/fusion-framework-module-context';
6
+ import { BookmarkModuleProvider, IBookmarkModuleProvider } from './bookmark-provider';
7
+ import { BookmarkModuleConfigurator, IBookmarkModuleConfigurator } from './configurator';
8
+
9
+ export type BookmarkModuleKey = 'bookmark';
10
+
11
+ export const moduleKey: BookmarkModuleKey = 'bookmark';
12
+
13
+ export type BookmarkModule = Module<
14
+ BookmarkModuleKey,
15
+ IBookmarkModuleProvider,
16
+ IBookmarkModuleConfigurator,
17
+ [EventModule, ServicesModule, AppModule, ContextModule]
18
+ >;
19
+
20
+ export const module: BookmarkModule = {
21
+ name: moduleKey,
22
+ configure: () => new BookmarkModuleConfigurator(),
23
+ initialize: async (args) => {
24
+ const ref = (args.ref as ModulesInstance<[BookmarkModule]>)?.bookmark;
25
+ const config = await (args.config as BookmarkModuleConfigurator).createConfig(args, ref);
26
+
27
+ return new BookmarkModuleProvider(config, ref);
28
+ },
29
+ dispose: (args) => {
30
+ (args.instance as BookmarkModuleProvider).dispose();
31
+ },
32
+ };
33
+
34
+ declare module '@equinor/fusion-framework-module' {
35
+ interface Modules {
36
+ bookmark: BookmarkModule;
37
+ }
38
+ }
39
+
40
+ export default module;
package/src/types.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { QueryFn, QueryCtorOptions } from '@equinor/fusion-query';
2
+
3
+ export interface Bookmark<TData = unknown> {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ isShared: boolean;
8
+ payload: TData;
9
+ appKey: string;
10
+ context?: Context;
11
+ createdBy: CreatedBy;
12
+ updatedBy: CreatedBy;
13
+ created: string;
14
+ updated: string;
15
+ sourceSystem: SourceSystem;
16
+ }
17
+
18
+ export type CreateBookmark<TData = unknown> = {
19
+ /** Display name of the bookmark */
20
+ name: string;
21
+ description?: string;
22
+ /** Is the bookmark shared with others */
23
+ isShared: boolean;
24
+ /** Name of the app it belongs too, should correspond to a fusion appkey */
25
+ appKey: string;
26
+ contextId?: string;
27
+ /** Any JSON object to store as the bookmark payload */
28
+ payload: TData;
29
+ sourceSystem?: Partial<SourceSystem>;
30
+ };
31
+
32
+ export interface SourceSystem {
33
+ identifier: string;
34
+ name: string;
35
+ subSystem: string;
36
+ }
37
+
38
+ interface CreatedBy {
39
+ azureUniqueId: string;
40
+ mail: string;
41
+ name: string;
42
+ phoneNumber: string;
43
+ jobTitle: string;
44
+ accountType: number;
45
+ accountClassification: number;
46
+ }
47
+
48
+ interface Context {
49
+ id: string;
50
+ name: string;
51
+ type: string;
52
+ }
53
+
54
+ export type GetBookmarkParameters = { id: string };
55
+
56
+ export type GetAllBookmarksParameters = { isValid: boolean };
57
+
58
+ export interface BookmarkQueryClient {
59
+ getAllBookmarks:
60
+ | QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters>
61
+ | QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
62
+ getBookmarkById:
63
+ | QueryFn<Bookmark<unknown>, GetBookmarkParameters>
64
+ | QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
65
+ }
@@ -0,0 +1,13 @@
1
+ const BOOKMARK_SEARCH_PARAM = 'bookmarkId';
2
+
3
+ export function removeBookmarkIdFromURL(): void {
4
+ const params = new URLSearchParams(document.location.search);
5
+ params.delete(BOOKMARK_SEARCH_PARAM);
6
+
7
+ document.location.search = params.toString();
8
+ }
9
+
10
+ export const getBookmarkIdFormURL = (): string | null => {
11
+ const params = new URLSearchParams(document.location.search);
12
+ return params.get(BOOKMARK_SEARCH_PARAM);
13
+ };
@@ -0,0 +1 @@
1
+ export { getBookmarkIdFormURL, removeBookmarkIdFromURL } from './handle-url';
package/tsconfig.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist/esm",
5
+ "rootDir": "src",
6
+ "declarationDir": "./dist/types",
7
+ "baseUrl": "src",
8
+ },
9
+ "references": [
10
+ {
11
+ "path": "../../utils/query"
12
+ },
13
+ {
14
+ "path": "../module"
15
+ },
16
+ {
17
+ "path": "../services"
18
+ },
19
+ {
20
+ "path": "../event"
21
+ },
22
+ {
23
+ "path": "../context"
24
+ },
25
+ {
26
+ "path": "../app"
27
+ },
28
+ ],
29
+ "include": [
30
+ "src/**/*",
31
+ ],
32
+ "exclude": [
33
+ "node_modules",
34
+ "dist"
35
+ ]
36
+ }