@equinor/fusion-framework-module-bookmark 1.2.13 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +242 -9
- package/dist/esm/BookmarkClient.interface.js +2 -0
- package/dist/esm/BookmarkClient.interface.js.map +1 -0
- package/dist/esm/BookmarkClient.js +174 -0
- package/dist/esm/BookmarkClient.js.map +1 -0
- package/dist/esm/BookmarkConfigurator.js +348 -0
- package/dist/esm/BookmarkConfigurator.js.map +1 -0
- package/dist/esm/BookmarkProvider.actions.js +60 -0
- package/dist/esm/BookmarkProvider.actions.js.map +1 -0
- package/dist/esm/BookmarkProvider.error.js +14 -0
- package/dist/esm/BookmarkProvider.error.js.map +1 -0
- package/dist/esm/BookmarkProvider.events.js +2 -0
- package/dist/esm/BookmarkProvider.events.js.map +1 -0
- package/dist/esm/BookmarkProvider.flows.js +219 -0
- package/dist/esm/BookmarkProvider.flows.js.map +1 -0
- package/dist/esm/BookmarkProvider.js +937 -0
- package/dist/esm/BookmarkProvider.js.map +1 -0
- package/dist/esm/BookmarkProvider.reducer.js +125 -0
- package/dist/esm/BookmarkProvider.reducer.js.map +1 -0
- package/dist/esm/BookmarkProvider.selectors.js +43 -0
- package/dist/esm/BookmarkProvider.selectors.js.map +1 -0
- package/dist/esm/BookmarkProvider.store.js +19 -0
- package/dist/esm/BookmarkProvider.store.js.map +1 -0
- package/dist/esm/bookmark-config.schema.js +30 -0
- package/dist/esm/bookmark-config.schema.js.map +1 -0
- package/dist/esm/bookmark-module.js +53 -0
- package/dist/esm/bookmark-module.js.map +1 -0
- package/dist/esm/bookmark.schemas.js +38 -0
- package/dist/esm/bookmark.schemas.js.map +1 -0
- package/dist/esm/enable-bookmark.js +20 -7
- package/dist/esm/enable-bookmark.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/BookmarkClient.d.ts +42 -0
- package/dist/types/BookmarkClient.interface.d.ts +139 -0
- package/dist/types/BookmarkConfigurator.d.ts +100 -0
- package/dist/types/BookmarkProvider.actions.d.ts +525 -0
- package/dist/types/BookmarkProvider.d.ts +462 -0
- package/dist/types/BookmarkProvider.error.d.ts +9 -0
- package/dist/types/BookmarkProvider.events.d.ts +78 -0
- package/dist/types/BookmarkProvider.flows.d.ts +79 -0
- package/dist/types/BookmarkProvider.reducer.d.ts +302 -0
- package/dist/types/BookmarkProvider.selectors.d.ts +34 -0
- package/dist/types/BookmarkProvider.store.d.ts +30 -0
- package/dist/types/bookmark-config.schema.d.ts +118 -0
- package/dist/types/{module.d.ts → bookmark-module.d.ts} +3 -3
- package/dist/types/bookmark.schemas.d.ts +760 -0
- package/dist/types/enable-bookmark.d.ts +7 -6
- package/dist/types/index.d.ts +4 -3
- package/dist/types/types.d.ts +29 -65
- package/dist/types/version.d.ts +1 -1
- package/package.json +11 -5
- package/src/BookmarkClient.interface.ts +157 -0
- package/src/BookmarkClient.ts +226 -0
- package/src/BookmarkConfigurator.ts +374 -0
- package/src/BookmarkProvider.actions.ts +131 -0
- package/src/BookmarkProvider.error.ts +21 -0
- package/src/BookmarkProvider.events.ts +89 -0
- package/src/BookmarkProvider.flows.ts +426 -0
- package/src/BookmarkProvider.reducer.ts +141 -0
- package/src/BookmarkProvider.selectors.ts +55 -0
- package/src/BookmarkProvider.store.ts +52 -0
- package/src/BookmarkProvider.ts +1308 -0
- package/src/bookmark-config.schema.ts +41 -0
- package/src/bookmark-module.ts +70 -0
- package/src/bookmark.schemas.ts +50 -0
- package/src/enable-bookmark.ts +13 -20
- package/src/index.ts +15 -7
- package/src/types.ts +46 -73
- package/src/version.ts +1 -1
- package/dist/esm/bookmark-config-builder.js +0 -131
- package/dist/esm/bookmark-config-builder.js.map +0 -1
- package/dist/esm/bookmark-provider.js +0 -155
- package/dist/esm/bookmark-provider.js.map +0 -1
- package/dist/esm/client/bookmarkActions.js +0 -10
- package/dist/esm/client/bookmarkActions.js.map +0 -1
- package/dist/esm/client/bookmarkClient.js +0 -259
- package/dist/esm/client/bookmarkClient.js.map +0 -1
- package/dist/esm/client/bookmarkFlows.js +0 -31
- package/dist/esm/client/bookmarkFlows.js.map +0 -1
- package/dist/esm/client/bookmarkReducer.js +0 -29
- package/dist/esm/client/bookmarkReducer.js.map +0 -1
- package/dist/esm/configurator.js +0 -155
- package/dist/esm/configurator.js.map +0 -1
- package/dist/esm/module.js +0 -27
- package/dist/esm/module.js.map +0 -1
- package/dist/esm/utils/handle-url.js +0 -11
- package/dist/esm/utils/handle-url.js.map +0 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/types/bookmark-config-builder.d.ts +0 -85
- package/dist/types/bookmark-provider.d.ts +0 -169
- package/dist/types/client/bookmarkActions.d.ts +0 -27
- package/dist/types/client/bookmarkClient.d.ts +0 -53
- package/dist/types/client/bookmarkFlows.d.ts +0 -22
- package/dist/types/client/bookmarkReducer.d.ts +0 -5
- package/dist/types/configurator.d.ts +0 -75
- package/dist/types/utils/handle-url.d.ts +0 -2
- package/dist/types/utils/index.d.ts +0 -1
- package/src/bookmark-config-builder.ts +0 -177
- package/src/bookmark-provider.ts +0 -344
- package/src/client/bookmarkActions.ts +0 -44
- package/src/client/bookmarkClient.ts +0 -327
- package/src/client/bookmarkFlows.ts +0 -67
- package/src/client/bookmarkReducer.ts +0 -35
- package/src/configurator.ts +0 -235
- package/src/module.ts +0 -40
- package/src/utils/handle-url.ts +0 -13
- package/src/utils/index.ts +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { LogLevel, type ILogger } from '@equinor/fusion-log';
|
|
4
|
+
|
|
5
|
+
import type { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
|
|
6
|
+
|
|
7
|
+
import type { BookmarkProvider } from './BookmarkProvider';
|
|
8
|
+
import type { IBookmarkClient } from './BookmarkClient.interface';
|
|
9
|
+
|
|
10
|
+
import { bookmarkSourceSystemSchema } from './bookmark.schemas';
|
|
11
|
+
|
|
12
|
+
export const bookmarkConfigSchema = z.object({
|
|
13
|
+
log: z.custom<ILogger>().optional(),
|
|
14
|
+
logLevel: z.nativeEnum(LogLevel).optional(),
|
|
15
|
+
eventProvider: z.custom<IEventModuleProvider>().optional(),
|
|
16
|
+
sourceSystem: bookmarkSourceSystemSchema
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('The source system for the bookmarks'),
|
|
19
|
+
parent: z.custom<BookmarkProvider>().describe('Parent Bookmark provider').optional().nullable(),
|
|
20
|
+
client: z.custom<IBookmarkClient>().describe('API client for interacting with bookmarks'),
|
|
21
|
+
resolve: z
|
|
22
|
+
.object({
|
|
23
|
+
context: z.function().returns(z.promise(z.object({ id: z.string() }).optional())),
|
|
24
|
+
application: z
|
|
25
|
+
.function()
|
|
26
|
+
.returns(
|
|
27
|
+
z.promise(
|
|
28
|
+
z.object({ appKey: z.string(), name: z.string().optional() }).optional(),
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
})
|
|
32
|
+
.describe('Functions for resolving context and application'),
|
|
33
|
+
filters: z
|
|
34
|
+
.object({
|
|
35
|
+
context: z.boolean().optional().default(false),
|
|
36
|
+
application: z.boolean().optional().default(false),
|
|
37
|
+
})
|
|
38
|
+
.describe('Flags for enabling resolving when fetching bookmarks')
|
|
39
|
+
.optional()
|
|
40
|
+
.default({ context: false, application: false }),
|
|
41
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Module, ModulesInstance, SemanticVersion } 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 { BookmarkProvider } from './BookmarkProvider';
|
|
7
|
+
import { BookmarkModuleConfigurator } from './BookmarkConfigurator';
|
|
8
|
+
import { ConsoleLogger, ILogger } from '@equinor/fusion-log';
|
|
9
|
+
import { lastValueFrom } from 'rxjs';
|
|
10
|
+
import { version } from './version';
|
|
11
|
+
|
|
12
|
+
export type BookmarkModuleKey = 'bookmark';
|
|
13
|
+
|
|
14
|
+
export const moduleKey: BookmarkModuleKey = 'bookmark';
|
|
15
|
+
|
|
16
|
+
export type BookmarkModule = Module<
|
|
17
|
+
BookmarkModuleKey,
|
|
18
|
+
BookmarkProvider,
|
|
19
|
+
BookmarkModuleConfigurator,
|
|
20
|
+
[EventModule, ServicesModule, AppModule, ContextModule]
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
// TODO - remove when all framework uses log
|
|
24
|
+
const fallbackLogger: ILogger = new ConsoleLogger('BookmarkModule');
|
|
25
|
+
|
|
26
|
+
export const module: BookmarkModule = {
|
|
27
|
+
name: moduleKey,
|
|
28
|
+
version: new SemanticVersion(version),
|
|
29
|
+
configure: (args) => {
|
|
30
|
+
// use parent logger if available, else fallback to console logger
|
|
31
|
+
const log: ILogger =
|
|
32
|
+
(args?.log as ILogger)?.createSubLogger('BookmarkModule') || fallbackLogger;
|
|
33
|
+
|
|
34
|
+
// Set client from parent module if available
|
|
35
|
+
const ref = args?.ref as ModulesInstance<[BookmarkModule]>;
|
|
36
|
+
|
|
37
|
+
// create a configurator instance
|
|
38
|
+
const configurator = new BookmarkModuleConfigurator({ log, ref });
|
|
39
|
+
|
|
40
|
+
return configurator;
|
|
41
|
+
},
|
|
42
|
+
initialize: async (args) => {
|
|
43
|
+
const parent = args.ref?.bookmark as BookmarkProvider;
|
|
44
|
+
const config = await lastValueFrom(
|
|
45
|
+
args.config.createConfig(args, {
|
|
46
|
+
filters: parent?.filters,
|
|
47
|
+
sourceSystem: parent?.sourceSystem,
|
|
48
|
+
resolve: parent
|
|
49
|
+
? {
|
|
50
|
+
application: parent.resolvedApplication.bind(parent),
|
|
51
|
+
context: parent.resolvedContext.bind(parent),
|
|
52
|
+
}
|
|
53
|
+
: undefined,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
const provider = new BookmarkProvider(config);
|
|
57
|
+
return provider;
|
|
58
|
+
},
|
|
59
|
+
dispose: (args) => {
|
|
60
|
+
(args.instance as BookmarkProvider).dispose();
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare module '@equinor/fusion-framework-module' {
|
|
65
|
+
interface Modules {
|
|
66
|
+
bookmark: BookmarkModule;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default module;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { BookmarkData } from './types';
|
|
3
|
+
|
|
4
|
+
const bookmarkUserSchema = z.object({
|
|
5
|
+
azureUniqueId: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
mail: z.string().optional(),
|
|
8
|
+
phoneNumber: z.string().optional(),
|
|
9
|
+
jobTitle: z.string().optional(),
|
|
10
|
+
accountType: z.enum(['Employee', 'Consultant', 'External', 'Application', 'Local']).optional(),
|
|
11
|
+
accountClassification: z.enum(['Unclassified', 'Internal', 'External']).optional(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const bookmarkSourceSystemSchema = z.object({
|
|
15
|
+
identifier: z.string(),
|
|
16
|
+
name: z.string().optional(),
|
|
17
|
+
subSystem: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const bookmarkContextSchema = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
name: z.string().optional(),
|
|
23
|
+
type: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const bookmarkSchema = z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
name: z.string(),
|
|
29
|
+
appKey: z.string(),
|
|
30
|
+
description: z.string().optional(),
|
|
31
|
+
isShared: z.boolean().optional(),
|
|
32
|
+
created: z.date(),
|
|
33
|
+
createdBy: bookmarkUserSchema,
|
|
34
|
+
updated: z.date().optional(),
|
|
35
|
+
updatedBy: bookmarkUserSchema.optional(),
|
|
36
|
+
context: bookmarkContextSchema.optional(),
|
|
37
|
+
sourceSystem: bookmarkSourceSystemSchema.optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const bookmarksSchema = z.array(bookmarkSchema);
|
|
41
|
+
|
|
42
|
+
export const bookmarkWithDataSchema = <
|
|
43
|
+
T extends BookmarkData = BookmarkData,
|
|
44
|
+
S extends z.ZodSchema<T> = z.ZodSchema<T>,
|
|
45
|
+
>(
|
|
46
|
+
schema: S = z.record(z.unknown()).or(z.string()).optional() as unknown as S,
|
|
47
|
+
) =>
|
|
48
|
+
bookmarkSchema.extend({
|
|
49
|
+
payload: schema,
|
|
50
|
+
});
|
package/src/enable-bookmark.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyModule,
|
|
3
|
-
IModulesConfigurator,
|
|
4
|
-
ModuleInitializerArgs,
|
|
5
|
-
} from '@equinor/fusion-framework-module';
|
|
6
|
-
import { BookmarkConfigBuilder } from './bookmark-config-builder';
|
|
1
|
+
import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
7
2
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import { module } from './module';
|
|
3
|
+
import { module } from './bookmark-module';
|
|
4
|
+
import { BookmarkModuleConfigurator } from './BookmarkConfigurator';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
7
|
+
* Enables the Bookmark module
|
|
8
|
+
*
|
|
9
|
+
* @param configurator - The configuration object for the modules.
|
|
10
|
+
* @param callback - An optional callback function that receives the `BookmarkModuleConfigurator` instance, allowing for further configuration.
|
|
15
11
|
*/
|
|
16
12
|
export const enableBookmark = (
|
|
17
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
configurator: IModulesConfigurator<any
|
|
19
|
-
|
|
20
|
-
builder: BookmarkConfigBuilder<
|
|
21
|
-
TDeps,
|
|
22
|
-
ModuleInitializerArgs<IBookmarkModuleConfigurator, TDeps>
|
|
23
|
-
>,
|
|
24
|
-
) => void | Promise<void>,
|
|
14
|
+
configurator: IModulesConfigurator<any>,
|
|
15
|
+
callback?: (builder: BookmarkModuleConfigurator) => void | Promise<void>,
|
|
25
16
|
): void => {
|
|
26
17
|
configurator.addConfig({
|
|
27
18
|
module,
|
|
28
|
-
configure: (
|
|
29
|
-
|
|
19
|
+
configure: async (builder) => {
|
|
20
|
+
if (callback) {
|
|
21
|
+
Promise.resolve(callback(builder));
|
|
22
|
+
}
|
|
30
23
|
},
|
|
31
24
|
});
|
|
32
25
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { BookmarkModuleConfigurator } from './BookmarkConfigurator';
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
IBookmarkClient,
|
|
5
|
+
BookmarkNew,
|
|
6
|
+
BookmarkUpdate,
|
|
7
|
+
BookmarksFilter,
|
|
8
|
+
} from './BookmarkClient.interface';
|
|
6
9
|
|
|
7
10
|
export {
|
|
8
11
|
default,
|
|
9
12
|
BookmarkModule,
|
|
10
13
|
module as bookmarkModule,
|
|
11
14
|
moduleKey as bookmarkModuleKey,
|
|
12
|
-
} from './module';
|
|
15
|
+
} from './bookmark-module';
|
|
13
16
|
|
|
14
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
BookmarkProvider,
|
|
19
|
+
type BookmarkPayloadGenerator,
|
|
20
|
+
type BookmarkCreateArgs,
|
|
21
|
+
type BookmarkUpdateOptions,
|
|
22
|
+
} from './BookmarkProvider';
|
|
15
23
|
|
|
16
24
|
export { enableBookmark } from './enable-bookmark';
|
|
17
25
|
|
package/src/types.ts
CHANGED
|
@@ -1,73 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
jobTitle: string;
|
|
48
|
-
accountType: number;
|
|
49
|
-
accountClassification: number;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface Context {
|
|
53
|
-
id: string;
|
|
54
|
-
name: string;
|
|
55
|
-
type: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type GetBookmarkParameters = { id: string };
|
|
59
|
-
|
|
60
|
-
export type GetAllBookmarksParameters = { isValid: boolean };
|
|
61
|
-
|
|
62
|
-
export interface BookmarkQueryClient {
|
|
63
|
-
getAllBookmarks:
|
|
64
|
-
| QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters>
|
|
65
|
-
| QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
|
|
66
|
-
getBookmarkById:
|
|
67
|
-
| QueryFn<Bookmark<unknown>, GetBookmarkParameters>
|
|
68
|
-
| QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type UpdateBookmarkOptions = {
|
|
72
|
-
updatePayload: boolean;
|
|
73
|
-
};
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
bookmarkSchema,
|
|
5
|
+
bookmarkSourceSystemSchema,
|
|
6
|
+
bookmarksSchema,
|
|
7
|
+
bookmarkWithDataSchema,
|
|
8
|
+
} from './bookmark.schemas';
|
|
9
|
+
|
|
10
|
+
import { bookmarkConfigSchema } from './bookmark-config.schema';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents the source system for a bookmark.
|
|
14
|
+
*/
|
|
15
|
+
export type SourceSystem = z.infer<typeof bookmarkSourceSystemSchema>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the data associated with a bookmark.
|
|
19
|
+
* This is a generic type that can hold any arbitrary data as a key-value map.
|
|
20
|
+
*/
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
export type BookmarkData = Record<string, any> | string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a collection of bookmarks.
|
|
26
|
+
*/
|
|
27
|
+
export type Bookmarks = z.infer<typeof bookmarksSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents a bookmark without any associated data.
|
|
31
|
+
*/
|
|
32
|
+
export type BookmarkWithoutData = z.infer<typeof bookmarkSchema>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents a bookmark with associated data.
|
|
36
|
+
* @template T - The type of the bookmark data.
|
|
37
|
+
*/
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
export type Bookmark<T extends BookmarkData = any> = z.infer<
|
|
40
|
+
ReturnType<typeof bookmarkWithDataSchema<T>>
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Represents the configuration options for a bookmark module.
|
|
45
|
+
*/
|
|
46
|
+
export type BookmarkModuleConfig = z.infer<typeof bookmarkConfigSchema>;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '2.0.0';
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _BookmarkConfigBuilder_init;
|
|
13
|
-
export class BookmarkConfigBuilder {
|
|
14
|
-
constructor(init, config = {}) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
_BookmarkConfigBuilder_init.set(this, void 0);
|
|
17
|
-
__classPrivateFieldSet(this, _BookmarkConfigBuilder_init, init, "f");
|
|
18
|
-
}
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
requireInstance(module) {
|
|
21
|
-
return __classPrivateFieldGet(this, _BookmarkConfigBuilder_init, "f").requireInstance(module);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* This will sett the SourceSystem used when creating a new bookmark,
|
|
26
|
-
* used as the identifier for the current client. Only used in app shell / portal configuration.
|
|
27
|
-
*
|
|
28
|
-
* @param {SourceSystem} sourceSystem
|
|
29
|
-
* ```ts
|
|
30
|
-
* interface SourceSystem {
|
|
31
|
-
* identifier: string;
|
|
32
|
-
* name: string;
|
|
33
|
-
* subSystem: string;
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
* @memberof BookmarkConfigBuilder
|
|
37
|
-
*/
|
|
38
|
-
setSourceSystem(sourceSystem) {
|
|
39
|
-
this.config.sourceSystem = sourceSystem;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Used to over write the default Url id resolving.
|
|
43
|
-
*
|
|
44
|
-
* @param {(() => string | null)} fn - Resolver for bookmarkId
|
|
45
|
-
* @memberof BookmarkConfigBuilder
|
|
46
|
-
*/
|
|
47
|
-
setBookmarkIdResolver(fn) {
|
|
48
|
-
this.config.resolveBookmarkId = fn;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* This allow for custom BookmarkApiClient to be added.
|
|
52
|
-
*
|
|
53
|
-
* @param {BookmarksApiClient<'fetch', IHttpClient, Bookmark<unknown>>} client - Custom Api client
|
|
54
|
-
* @memberof BookmarkConfigBuilder
|
|
55
|
-
*/
|
|
56
|
-
serCustomBookmarkApiClient(client) {
|
|
57
|
-
if (this.config.clientConfiguration) {
|
|
58
|
-
this.config.clientConfiguration.client = client;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Used to over with the default context id resolver.
|
|
63
|
-
*
|
|
64
|
-
* @param {(() => string | undefined)} fn - Function for providing current contextId
|
|
65
|
-
* @memberof BookmarkConfigBuilder
|
|
66
|
-
*/
|
|
67
|
-
setContextIdResolver(fn) {
|
|
68
|
-
this.config.getContextId = fn;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Used to over withe the default function for getting the current applications
|
|
72
|
-
* key identifier.
|
|
73
|
-
*
|
|
74
|
-
* @param {(() => string | undefined)} - A function for getting the current application key
|
|
75
|
-
* @memberof BookmarkConfigBuilder
|
|
76
|
-
*/
|
|
77
|
-
setCurrentAppIdResolver(fn) {
|
|
78
|
-
this.config.getCurrentAppIdentification = fn;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Enable the over write default Event provider if needed.
|
|
82
|
-
* Should not be used if all event providers are changes in the current environment
|
|
83
|
-
*
|
|
84
|
-
* @param {IEventModuleProvider} provider - Custom Event provider
|
|
85
|
-
* @memberof BookmarkConfigBuilder
|
|
86
|
-
*/
|
|
87
|
-
setEventProvider(provider) {
|
|
88
|
-
this.config.event = provider;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Use for override the bookmark query client
|
|
92
|
-
*
|
|
93
|
-
* @param {({
|
|
94
|
-
* getAllBookmarks:
|
|
95
|
-
* | QueryFn<Array<Bookmark<unknown>>, GetAllBookmarksParameters>
|
|
96
|
-
* | QueryCtorOptions<Array<Bookmark<unknown>>, GetAllBookmarksParameters>;
|
|
97
|
-
* getBookmarkById:
|
|
98
|
-
* | QueryFn<Bookmark<unknown>, GetBookmarkParameters>
|
|
99
|
-
* | QueryCtorOptions<Bookmark<unknown>, GetBookmarkParameters>;
|
|
100
|
-
* })} client - Custom client definition.
|
|
101
|
-
* @memberof BookmarkConfigBuilder
|
|
102
|
-
*/
|
|
103
|
-
setBookmarkQueryClient(client) {
|
|
104
|
-
const expire = 1 * 60 * 1000;
|
|
105
|
-
if (this.config.clientConfiguration) {
|
|
106
|
-
this.config.clientConfiguration.queryClientConfig = {
|
|
107
|
-
getAllBookmarks: typeof client.getAllBookmarks === 'function'
|
|
108
|
-
? {
|
|
109
|
-
key: () => 'all-bookmarks',
|
|
110
|
-
client: {
|
|
111
|
-
fn: client.getAllBookmarks,
|
|
112
|
-
},
|
|
113
|
-
validate: ({ args }) => args.isValid,
|
|
114
|
-
}
|
|
115
|
-
: client.getAllBookmarks,
|
|
116
|
-
getBookmarkById: typeof client.getBookmarkById === 'function'
|
|
117
|
-
? {
|
|
118
|
-
key: ({ id }) => id,
|
|
119
|
-
client: {
|
|
120
|
-
fn: client.getBookmarkById,
|
|
121
|
-
},
|
|
122
|
-
expire,
|
|
123
|
-
validate: () => false,
|
|
124
|
-
}
|
|
125
|
-
: client.getBookmarkById,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
_BookmarkConfigBuilder_init = new WeakMap();
|
|
131
|
-
//# sourceMappingURL=bookmark-config-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bookmark-config-builder.js","sourceRoot":"","sources":["../../src/bookmark-config-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AA0BA,MAAM,OAAO,qBAAqB;IAS9B,YACI,IAAW,EACJ,SAAwC,EAAE;QAA1C,WAAM,GAAN,MAAM,CAAoC;QAHrD,8CAAa;QAKT,uBAAA,IAAI,+BAAS,IAAI,MAAA,CAAC;IACtB,CAAC;IAQD,8DAA8D;IAC9D,eAAe,CAAC,MAAc;QAC1B,OAAO,uBAAA,IAAI,mCAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,YAA0B;QACtC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,EAAuB;QACzC,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,EAAE,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,0BAA0B,CACtB,MAAmE;QAEnE,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC;QACpD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,EAA4B;QAC7C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CAAC,EAA4B;QAChD,IAAI,CAAC,MAAM,CAAC,2BAA2B,GAAG,EAAE,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,QAA8B;QAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,sBAAsB,CAAC,MAOtB;QACG,MAAM,MAAM,GAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,iBAAiB,GAAG;gBAChD,eAAe,EACX,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU;oBACxC,CAAC,CAAC;wBACI,GAAG,EAAE,GAAG,EAAE,CAAC,eAAe;wBAC1B,MAAM,EAAE;4BACJ,EAAE,EAAE,MAAM,CAAC,eAAe;yBAC7B;wBACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO;qBACvC;oBACH,CAAC,CAAC,MAAM,CAAC,eAAe;gBAChC,eAAe,EACX,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU;oBACxC,CAAC,CAAC;wBACI,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;wBACnB,MAAM,EAAE;4BACJ,EAAE,EAAE,MAAM,CAAC,eAAe;yBAC7B;wBACD,MAAM;wBACN,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;qBACxB;oBACH,CAAC,CAAC,MAAM,CAAC,eAAe;aACnC,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
-
};
|
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
-
};
|
|
21
|
-
var _BookmarkModuleProvider_instances, _BookmarkModuleProvider_event, _BookmarkModuleProvider_subscriptions, _BookmarkModuleProvider_clearStateCreators, _BookmarkModuleProvider_createPayload, _BookmarkModuleProvider_getAppKey;
|
|
22
|
-
import { BookmarkClient } from './client/bookmarkClient';
|
|
23
|
-
import { Subscription } from 'rxjs';
|
|
24
|
-
export class BookmarkModuleProvider {
|
|
25
|
-
get currentBookmark$() {
|
|
26
|
-
return this._bookmarkClient.currentBookmark$;
|
|
27
|
-
}
|
|
28
|
-
get bookmarks$() {
|
|
29
|
-
return this._bookmarkClient.bookmarks$;
|
|
30
|
-
}
|
|
31
|
-
constructor(config, ref) {
|
|
32
|
-
_BookmarkModuleProvider_instances.add(this);
|
|
33
|
-
_BookmarkModuleProvider_event.set(this, void 0);
|
|
34
|
-
_BookmarkModuleProvider_subscriptions.set(this, new Subscription());
|
|
35
|
-
this.bookmarkCreators = {};
|
|
36
|
-
_BookmarkModuleProvider_clearStateCreators.set(this, () => {
|
|
37
|
-
this.bookmarkCreators = {};
|
|
38
|
-
});
|
|
39
|
-
this.config = config;
|
|
40
|
-
__classPrivateFieldSet(this, _BookmarkModuleProvider_event, config.event, "f");
|
|
41
|
-
this._bookmarkClient = ref
|
|
42
|
-
? ref._bookmarkClient
|
|
43
|
-
: new BookmarkClient(config.clientConfiguration, config.sourceSystem, config.event);
|
|
44
|
-
const initialBookmarkId = config.resolveBookmarkId && config.resolveBookmarkId();
|
|
45
|
-
if (initialBookmarkId) {
|
|
46
|
-
this._bookmarkClient.setCurrentBookmark(initialBookmarkId);
|
|
47
|
-
}
|
|
48
|
-
if (__classPrivateFieldGet(this, _BookmarkModuleProvider_event, "f")) {
|
|
49
|
-
__classPrivateFieldGet(this, _BookmarkModuleProvider_subscriptions, "f").add(__classPrivateFieldGet(this, _BookmarkModuleProvider_event, "f").addEventListener('onCurrentAppChanged', __classPrivateFieldGet(this, _BookmarkModuleProvider_clearStateCreators, "f")));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
getBookmarkById(bookmarkId) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return yield this._bookmarkClient.getBookmarkById(bookmarkId);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
setCurrentBookmark(idOrItem) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
this._bookmarkClient.setCurrentBookmark(idOrItem);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
getAllBookmarks() {
|
|
63
|
-
return this._bookmarkClient.getAllBookmarks();
|
|
64
|
-
}
|
|
65
|
-
getAllBookmarksAsync() {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return this._bookmarkClient.getAllBookmarksAsync();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
updateBookmark(bookmark) {
|
|
71
|
-
return this._bookmarkClient.updateBookmark(bookmark);
|
|
72
|
-
}
|
|
73
|
-
updateBookmarkAsync(bookmark, options) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
if (__classPrivateFieldGet(this, _BookmarkModuleProvider_instances, "m", _BookmarkModuleProvider_getAppKey).call(this) !== bookmark.appKey) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (options === null || options === void 0 ? void 0 : options.updatePayload) {
|
|
79
|
-
const payload = (yield __classPrivateFieldGet(this, _BookmarkModuleProvider_instances, "m", _BookmarkModuleProvider_createPayload).call(this));
|
|
80
|
-
bookmark = Object.assign(Object.assign({}, bookmark), { payload });
|
|
81
|
-
}
|
|
82
|
-
return this._bookmarkClient.updateBookmarkAsync(bookmark);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
deleteBookmarkById(bookmarkId) {
|
|
86
|
-
return this._bookmarkClient.deleteBookmarkById(bookmarkId);
|
|
87
|
-
}
|
|
88
|
-
deleteBookmarkByIdAsync(bookmarkId) {
|
|
89
|
-
return this._bookmarkClient.deleteBookmarkByIdAsync(bookmarkId);
|
|
90
|
-
}
|
|
91
|
-
addBookmarkFavoriteAsync(bookmarkId) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
yield this._bookmarkClient.addBookmarkFavoriteAsync(bookmarkId);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
removeBookmarkFavoriteAsync(bookmarkId) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
yield this._bookmarkClient.removeBookmarkFavoriteAsync(bookmarkId);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
verifyBookmarkFavoriteAsync(bookmarkId) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return yield this._bookmarkClient.verifyBookmarkFavoriteAsync(bookmarkId);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
addStateCreator(cb, key) {
|
|
107
|
-
var _a;
|
|
108
|
-
const bookmarkCreatorKey = key ? key : '#creator';
|
|
109
|
-
if (__classPrivateFieldGet(this, _BookmarkModuleProvider_event, "f")) {
|
|
110
|
-
(_a = __classPrivateFieldGet(this, _BookmarkModuleProvider_event, "f")) === null || _a === void 0 ? void 0 : _a.dispatchEvent('onAddCreator', {
|
|
111
|
-
source: this,
|
|
112
|
-
canBubble: true,
|
|
113
|
-
detail: { key, cb },
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
this.bookmarkCreators[bookmarkCreatorKey] = cb;
|
|
117
|
-
return () => {
|
|
118
|
-
delete this.bookmarkCreators[bookmarkCreatorKey];
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
createBookmark(args) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const payload = yield __classPrivateFieldGet(this, _BookmarkModuleProvider_instances, "m", _BookmarkModuleProvider_createPayload).call(this);
|
|
124
|
-
const contextId = this.config.getContextId && this.config.getContextId();
|
|
125
|
-
const appKey = __classPrivateFieldGet(this, _BookmarkModuleProvider_instances, "m", _BookmarkModuleProvider_getAppKey).call(this);
|
|
126
|
-
const bookmark = Object.assign(Object.assign({}, args), { appKey,
|
|
127
|
-
contextId, sourceSystem: this.config.sourceSystem, payload });
|
|
128
|
-
return this._bookmarkClient.createBookmarkAsync(bookmark);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
dispose() {
|
|
132
|
-
__classPrivateFieldGet(this, _BookmarkModuleProvider_subscriptions, "f").unsubscribe();
|
|
133
|
-
this._bookmarkClient.dispose();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
_BookmarkModuleProvider_event = new WeakMap(), _BookmarkModuleProvider_subscriptions = new WeakMap(), _BookmarkModuleProvider_clearStateCreators = new WeakMap(), _BookmarkModuleProvider_instances = new WeakSet(), _BookmarkModuleProvider_createPayload = function _BookmarkModuleProvider_createPayload() {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
const creator = this.bookmarkCreators;
|
|
139
|
-
if (!creator || Object.keys(creator).length === 0) {
|
|
140
|
-
throw Error('No creator registered on this BookmarkProvider');
|
|
141
|
-
}
|
|
142
|
-
if (typeof creator['#creator'] === 'function') {
|
|
143
|
-
return creator['#creator']();
|
|
144
|
-
}
|
|
145
|
-
return yield Object.entries(creator).reduce((cur_1, _a) => __awaiter(this, [cur_1, _a], void 0, function* (cur, [key, fn]) {
|
|
146
|
-
return Object.assign(yield cur, { [key]: yield fn() });
|
|
147
|
-
}), Promise.resolve({}));
|
|
148
|
-
});
|
|
149
|
-
}, _BookmarkModuleProvider_getAppKey = function _BookmarkModuleProvider_getAppKey() {
|
|
150
|
-
const appKey = this.config.getCurrentAppIdentification && this.config.getCurrentAppIdentification();
|
|
151
|
-
if (!appKey)
|
|
152
|
-
throw new Error(`There is noe current application selected, can't create bookmark.`);
|
|
153
|
-
return appKey;
|
|
154
|
-
};
|
|
155
|
-
//# sourceMappingURL=bookmark-provider.js.map
|