@equinor/fusion-framework-module-services 5.1.1-msal-6cf764b628c2afdd64dfd06e42abc953d78556d2 → 5.1.1
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 +103 -98
- package/dist/esm/bookmarks/api-version.js.map +1 -1
- package/dist/esm/bookmarks/client.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/bookmark-apply.get.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/bookmark.delete.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/bookmark.get.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/bookmark.patch.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/bookmark.post.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.delete.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.head.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.post.js.map +1 -1
- package/dist/esm/bookmarks/endpoints/user-bookmarks.get.js.map +1 -1
- package/dist/esm/bookmarks/schemas.js +1 -3
- package/dist/esm/bookmarks/schemas.js.map +1 -1
- package/dist/esm/bookmarks/selectors.js.map +1 -1
- package/dist/esm/context/client.js +2 -2
- package/dist/esm/context/client.js.map +1 -1
- package/dist/esm/context/get/client.js.map +1 -1
- package/dist/esm/context/get/generate-endpoint.js +0 -1
- package/dist/esm/context/get/generate-endpoint.js.map +1 -1
- package/dist/esm/context/get/generate-parameters.js.map +1 -1
- package/dist/esm/context/get/types.js.map +1 -1
- package/dist/esm/context/query/client.js.map +1 -1
- package/dist/esm/context/query/generate-endpoint.js +0 -1
- package/dist/esm/context/query/generate-endpoint.js.map +1 -1
- package/dist/esm/context/query/generate-parameters.js.map +1 -1
- package/dist/esm/context/query/types.js.map +1 -1
- package/dist/esm/context/related/client.js.map +1 -1
- package/dist/esm/context/related/generate-endpoint.js +0 -1
- package/dist/esm/context/related/generate-endpoint.js.map +1 -1
- package/dist/esm/context/related/generate-parameters.js.map +1 -1
- package/dist/esm/context/related/types.js.map +1 -1
- package/dist/esm/context/static.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/notification/client.js.map +1 -1
- package/dist/esm/notification/notification/delete/client.js.map +1 -1
- package/dist/esm/notification/notification/delete/generate-endpoint.js +0 -1
- package/dist/esm/notification/notification/delete/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/notification/delete/generate-parameters.js.map +1 -1
- package/dist/esm/notification/notification/get/client.js.map +1 -1
- package/dist/esm/notification/notification/get/generate-endpoint.js +0 -1
- package/dist/esm/notification/notification/get/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/notification/get/generate-parameters.js.map +1 -1
- package/dist/esm/notification/notification/getAll/client.js.map +1 -1
- package/dist/esm/notification/notification/getAll/generate-endpoint.js +0 -1
- package/dist/esm/notification/notification/getAll/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/notification/getAll/generate-parameters.js.map +1 -1
- package/dist/esm/notification/notification/patch/client.js.map +1 -1
- package/dist/esm/notification/notification/patch/generate-endpoint.js +0 -1
- package/dist/esm/notification/notification/patch/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/notification/patch/generate-parameters.js.map +1 -1
- package/dist/esm/notification/notification/post/client.js.map +1 -1
- package/dist/esm/notification/notification/post/generate-endpoint.js +0 -1
- package/dist/esm/notification/notification/post/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/notification/post/generate-parameters.js.map +1 -1
- package/dist/esm/notification/settings/get/client.js.map +1 -1
- package/dist/esm/notification/settings/get/generate-endpoint.js +0 -1
- package/dist/esm/notification/settings/get/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/settings/get/generate-parameters.js.map +1 -1
- package/dist/esm/notification/settings/put/client.js.map +1 -1
- package/dist/esm/notification/settings/put/generate-endpoint.js +0 -1
- package/dist/esm/notification/settings/put/generate-endpoint.js.map +1 -1
- package/dist/esm/notification/settings/put/generate-parameters.js.map +1 -1
- package/dist/esm/notification/static.js.map +1 -1
- package/dist/esm/people/client.js.map +1 -1
- package/dist/esm/people/person-details/client.js.map +1 -1
- package/dist/esm/people/person-details/generate-endpoint.js.map +1 -1
- package/dist/esm/people/person-details/generate-parameters.js.map +1 -1
- package/dist/esm/people/person-photo/client.js.map +1 -1
- package/dist/esm/people/person-photo/generate-endpoint.js.map +1 -1
- package/dist/esm/people/person-photo/generate-parameters.js.map +1 -1
- package/dist/esm/people/query/client.js.map +1 -1
- package/dist/esm/people/query/generate-endpoint.js.map +1 -1
- package/dist/esm/people/query/generate-parameters.js.map +1 -1
- package/dist/esm/people/static.js.map +1 -1
- package/dist/esm/people/utils.js.map +1 -1
- package/dist/esm/provider.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bookmarks/api-version.d.ts +2 -2
- package/dist/types/bookmarks/client.d.ts +8 -8
- package/dist/types/bookmarks/endpoints/bookmark-apply.get.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/bookmark.delete.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/bookmark.get.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/bookmark.patch.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/bookmark.post.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/user-bookmark-favourite.delete.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/user-bookmark-favourite.head.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/user-bookmark-favourite.post.d.ts +1 -1
- package/dist/types/bookmarks/endpoints/user-bookmarks.get.d.ts +1 -1
- package/dist/types/bookmarks/selectors.d.ts +1 -1
- package/dist/types/bookmarks/types.d.ts +1 -1
- package/dist/types/configurator.d.ts +1 -1
- package/dist/types/context/client.d.ts +4 -4
- package/dist/types/context/get/client.d.ts +1 -1
- package/dist/types/context/get/types.d.ts +2 -2
- package/dist/types/context/query/client.d.ts +1 -1
- package/dist/types/context/query/generate-parameters.d.ts +1 -1
- package/dist/types/context/query/types.d.ts +2 -2
- package/dist/types/context/related/client.d.ts +1 -1
- package/dist/types/context/related/generate-parameters.d.ts +1 -1
- package/dist/types/context/related/types.d.ts +2 -2
- package/dist/types/context/static.d.ts +2 -2
- package/dist/types/module.d.ts +2 -2
- package/dist/types/notification/client.d.ts +9 -9
- package/dist/types/notification/notification/delete/client.d.ts +2 -2
- package/dist/types/notification/notification/delete/generate-parameters.d.ts +2 -2
- package/dist/types/notification/notification/delete/types.d.ts +3 -3
- package/dist/types/notification/notification/get/client.d.ts +2 -2
- package/dist/types/notification/notification/get/generate-parameters.d.ts +2 -2
- package/dist/types/notification/notification/get/types.d.ts +3 -3
- package/dist/types/notification/notification/getAll/client.d.ts +2 -2
- package/dist/types/notification/notification/getAll/generate-parameters.d.ts +2 -2
- package/dist/types/notification/notification/getAll/types.d.ts +3 -3
- package/dist/types/notification/notification/patch/client.d.ts +2 -2
- package/dist/types/notification/notification/patch/generate-parameters.d.ts +2 -2
- package/dist/types/notification/notification/patch/types.d.ts +3 -3
- package/dist/types/notification/notification/post/client.d.ts +2 -2
- package/dist/types/notification/notification/post/generate-parameters.d.ts +2 -2
- package/dist/types/notification/notification/post/types.d.ts +3 -3
- package/dist/types/notification/settings/get/client.d.ts +2 -2
- package/dist/types/notification/settings/get/generate-parameters.d.ts +2 -2
- package/dist/types/notification/settings/get/types.d.ts +3 -3
- package/dist/types/notification/settings/put/client.d.ts +2 -2
- package/dist/types/notification/settings/put/generate-parameters.d.ts +2 -2
- package/dist/types/notification/settings/put/types.d.ts +3 -3
- package/dist/types/notification/static.d.ts +2 -2
- package/dist/types/people/api-models.d.ts +2 -2
- package/dist/types/people/api-models.v2.d.ts +1 -1
- package/dist/types/people/api-models.v4.d.ts +1 -1
- package/dist/types/people/client.d.ts +4 -4
- package/dist/types/people/person-details/client.d.ts +1 -1
- package/dist/types/people/person-details/types.d.ts +1 -1
- package/dist/types/people/person-photo/client.d.ts +1 -1
- package/dist/types/people/person-photo/types.d.ts +2 -2
- package/dist/types/people/query/client.d.ts +1 -1
- package/dist/types/people/query/types.d.ts +2 -2
- package/dist/types/people/static.d.ts +2 -2
- package/dist/types/people/utils.d.ts +1 -1
- package/dist/types/provider.d.ts +3 -3
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/bookmarks/api-version.ts +2 -2
- package/src/bookmarks/client.ts +228 -231
- package/src/bookmarks/endpoints/bookmark-apply.get.ts +58 -58
- package/src/bookmarks/endpoints/bookmark.delete.ts +57 -57
- package/src/bookmarks/endpoints/bookmark.get.ts +62 -62
- package/src/bookmarks/endpoints/bookmark.patch.ts +78 -78
- package/src/bookmarks/endpoints/bookmark.post.ts +68 -68
- package/src/bookmarks/endpoints/user-bookmark-favourite.delete.ts +57 -57
- package/src/bookmarks/endpoints/user-bookmark-favourite.head.ts +57 -57
- package/src/bookmarks/endpoints/user-bookmark-favourite.post.ts +58 -58
- package/src/bookmarks/endpoints/user-bookmarks.get.ts +98 -98
- package/src/bookmarks/schemas.ts +54 -56
- package/src/bookmarks/selectors.ts +24 -24
- package/src/bookmarks/types.ts +6 -6
- package/src/configurator.ts +3 -3
- package/src/context/api-models.ts +19 -19
- package/src/context/client.ts +68 -58
- package/src/context/get/client.ts +18 -18
- package/src/context/get/generate-endpoint.ts +13 -14
- package/src/context/get/generate-parameters.ts +9 -9
- package/src/context/get/types.ts +20 -20
- package/src/context/query/client.ts +22 -22
- package/src/context/query/generate-endpoint.ts +43 -44
- package/src/context/query/generate-parameters.ts +10 -10
- package/src/context/query/types.ts +25 -25
- package/src/context/related/client.ts +22 -22
- package/src/context/related/generate-endpoint.ts +40 -41
- package/src/context/related/generate-parameters.ts +10 -10
- package/src/context/related/types.ts +27 -27
- package/src/context/static.ts +3 -3
- package/src/errors.ts +6 -6
- package/src/module.ts +50 -52
- package/src/notification/api-models.ts +36 -36
- package/src/notification/client.ts +131 -151
- package/src/notification/notification/delete/client.ts +22 -22
- package/src/notification/notification/delete/generate-endpoint.ts +13 -14
- package/src/notification/notification/delete/generate-parameters.ts +18 -18
- package/src/notification/notification/delete/types.ts +21 -21
- package/src/notification/notification/get/client.ts +19 -19
- package/src/notification/notification/get/generate-endpoint.ts +13 -14
- package/src/notification/notification/get/generate-parameters.ts +11 -11
- package/src/notification/notification/get/types.ts +21 -21
- package/src/notification/notification/getAll/client.ts +22 -22
- package/src/notification/notification/getAll/generate-endpoint.ts +13 -14
- package/src/notification/notification/getAll/generate-parameters.ts +11 -11
- package/src/notification/notification/getAll/types.ts +21 -21
- package/src/notification/notification/patch/client.ts +22 -22
- package/src/notification/notification/patch/generate-endpoint.ts +13 -14
- package/src/notification/notification/patch/generate-parameters.ts +18 -18
- package/src/notification/notification/patch/types.ts +22 -22
- package/src/notification/notification/post/client.ts +22 -22
- package/src/notification/notification/post/generate-endpoint.ts +13 -14
- package/src/notification/notification/post/generate-parameters.ts +18 -18
- package/src/notification/notification/post/types.ts +31 -31
- package/src/notification/settings/get/client.ts +22 -22
- package/src/notification/settings/get/generate-endpoint.ts +13 -14
- package/src/notification/settings/get/generate-parameters.ts +11 -11
- package/src/notification/settings/get/types.ts +21 -21
- package/src/notification/settings/put/client.ts +22 -22
- package/src/notification/settings/put/generate-endpoint.ts +13 -14
- package/src/notification/settings/put/generate-parameters.ts +20 -20
- package/src/notification/settings/put/types.ts +20 -20
- package/src/notification/static.ts +3 -3
- package/src/people/api-models.ts +30 -30
- package/src/people/api-models.v2.ts +27 -27
- package/src/people/api-models.v4.ts +79 -79
- package/src/people/client.ts +73 -77
- package/src/people/person-details/client.ts +21 -18
- package/src/people/person-details/generate-endpoint.ts +16 -16
- package/src/people/person-details/generate-parameters.ts +8 -8
- package/src/people/person-details/types.ts +13 -13
- package/src/people/person-photo/client.ts +19 -22
- package/src/people/person-photo/generate-endpoint.ts +13 -13
- package/src/people/person-photo/generate-parameters.ts +8 -8
- package/src/people/person-photo/types.ts +8 -8
- package/src/people/query/client.ts +20 -18
- package/src/people/query/generate-endpoint.ts +14 -14
- package/src/people/query/generate-parameters.ts +8 -8
- package/src/people/query/types.ts +10 -10
- package/src/people/static.ts +2 -2
- package/src/people/utils.ts +20 -20
- package/src/provider.ts +85 -85
- package/src/types.ts +34 -34
- package/src/utils.ts +22 -26
- package/src/version.ts +1 -1
package/src/module.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
IModuleConfigurator,
|
|
3
|
+
IModulesConfigurator,
|
|
4
|
+
Module,
|
|
5
5
|
} from '@equinor/fusion-framework-module';
|
|
6
6
|
import type { HttpModule, IHttpClientProvider } from '@equinor/fusion-framework-module-http';
|
|
7
7
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
ServiceDiscoveryModule,
|
|
9
|
+
ServiceDiscoveryProvider,
|
|
10
10
|
} from '@equinor/fusion-framework-module-service-discovery';
|
|
11
11
|
|
|
12
|
-
import { IApiConfigurator, ApiConfigurator } from './configurator';
|
|
13
|
-
import { IApiProvider, ApiProvider } from './provider';
|
|
12
|
+
import { type IApiConfigurator, ApiConfigurator } from './configurator';
|
|
13
|
+
import { type IApiProvider, ApiProvider } from './provider';
|
|
14
14
|
|
|
15
15
|
import type { ApiClientFactory } from './types';
|
|
16
16
|
|
|
@@ -19,52 +19,50 @@ export type ServicesModuleKey = 'services';
|
|
|
19
19
|
export const moduleKey: ServicesModuleKey = 'services';
|
|
20
20
|
|
|
21
21
|
export type ServicesModule = Module<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
ServicesModuleKey,
|
|
23
|
+
IApiProvider,
|
|
24
|
+
IApiConfigurator,
|
|
25
|
+
[HttpModule, ServiceDiscoveryModule]
|
|
26
26
|
>;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Method to trying to resolve method for creating an IHttpClient
|
|
30
30
|
*/
|
|
31
31
|
const createDefaultClient =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
(http: IHttpClientProvider, serviceDiscovery?: ServiceDiscoveryProvider): ApiClientFactory =>
|
|
33
|
+
async (name: string) => {
|
|
34
|
+
if (http.hasClient(name)) {
|
|
35
|
+
return http.createClient(name);
|
|
36
|
+
}
|
|
37
|
+
if (serviceDiscovery) {
|
|
38
|
+
return serviceDiscovery.createClient(name);
|
|
39
|
+
}
|
|
40
|
+
throw Error(`failed to create http client for service ${name}`);
|
|
41
|
+
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Configure http-client
|
|
45
45
|
*/
|
|
46
46
|
export const module: ServicesModule = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: /** try to load parent service discovery provider */
|
|
59
|
-
ref?.serviceDiscovery;
|
|
47
|
+
name: moduleKey,
|
|
48
|
+
configure: () => new ApiConfigurator(),
|
|
49
|
+
initialize: async ({ ref, config, requireInstance, hasModule }) => {
|
|
50
|
+
/** we can not create this callback within the configuration, since it might require other modules. */
|
|
51
|
+
if (!config.createClient) {
|
|
52
|
+
const http = await requireInstance('http');
|
|
53
|
+
const serviceDiscovery: ServiceDiscoveryProvider | undefined = hasModule('serviceDiscovery')
|
|
54
|
+
? /** if the module is within module, await creation */
|
|
55
|
+
await requireInstance('serviceDiscovery')
|
|
56
|
+
: /** try to load parent service discovery provider */
|
|
57
|
+
ref?.serviceDiscovery;
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
config.createClient = createDefaultClient(http, serviceDiscovery);
|
|
60
|
+
}
|
|
61
|
+
if (!config.createClient) {
|
|
62
|
+
throw Error('missing configuration for creating API client');
|
|
63
|
+
}
|
|
64
|
+
return new ApiProvider(config as Required<IApiConfigurator>);
|
|
65
|
+
},
|
|
68
66
|
};
|
|
69
67
|
|
|
70
68
|
/**
|
|
@@ -72,10 +70,10 @@ export const module: ServicesModule = {
|
|
|
72
70
|
* @param config - configuration object
|
|
73
71
|
*/
|
|
74
72
|
export const enableServices = (
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
config: IModulesConfigurator<any, any>,
|
|
77
75
|
): void => {
|
|
78
|
-
|
|
76
|
+
config.addConfig({ module });
|
|
79
77
|
};
|
|
80
78
|
|
|
81
79
|
/**
|
|
@@ -87,18 +85,18 @@ export const enableServices = (
|
|
|
87
85
|
* @returns Configuration object
|
|
88
86
|
*/
|
|
89
87
|
export const configureServices = (
|
|
90
|
-
|
|
88
|
+
configure: (configurator: IApiConfigurator) => void,
|
|
91
89
|
): IModuleConfigurator<ServicesModule> => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
return {
|
|
91
|
+
module,
|
|
92
|
+
configure,
|
|
93
|
+
};
|
|
96
94
|
};
|
|
97
95
|
|
|
98
96
|
declare module '@equinor/fusion-framework-module' {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
interface Modules {
|
|
98
|
+
services: ServicesModule;
|
|
99
|
+
}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
export default module;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import { ApiVersion } from './static';
|
|
2
2
|
|
|
3
3
|
type ApiNotificationEntity_v1 = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
id: string;
|
|
5
|
+
appKey: string;
|
|
6
|
+
emailPriority: number;
|
|
7
|
+
fallbackHtml: string;
|
|
8
|
+
targetAzureUniqueId: string;
|
|
9
|
+
title: string;
|
|
10
|
+
card: string;
|
|
11
|
+
created: string;
|
|
12
|
+
createdBy: CreatedBy_v1;
|
|
13
|
+
createdByApplication: CreatedByApplication_v1;
|
|
14
|
+
seenByUser: boolean;
|
|
15
|
+
seen: string;
|
|
16
|
+
sourceSystem: SourceSystem_v1;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
type SourceSystem_v1 = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
name: string;
|
|
21
|
+
subSystem: string;
|
|
22
|
+
identifier: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
type CreatedByApplication_v1 = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
type CreatedBy_v1 = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
jobTitle: string;
|
|
34
|
+
mail: string;
|
|
35
|
+
accountType: string;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
type ApiNotificationEntity_v2 = unknown;
|
|
39
39
|
|
|
40
40
|
type ApiNotificationEntityTypes = {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
[ApiVersion.v1]: ApiNotificationEntity_v1;
|
|
42
|
+
[ApiVersion.v2]: ApiNotificationEntity_v2;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export type ApiNotificationEntity<T extends string = ApiVersion> = T extends ApiVersion
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
? ApiNotificationEntityTypes[T]
|
|
47
|
+
: unknown;
|
|
48
48
|
|
|
49
49
|
/**User notification Settings */
|
|
50
50
|
type ApiNotificationSettingsEntity_v1 = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
email: boolean;
|
|
52
|
+
delayInMinutes: number;
|
|
53
|
+
appConfig: AppConfig_v1[];
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
type AppConfig_v1 = {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
appKey: string;
|
|
58
|
+
enabled: boolean;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
type ApiNotificationSettingsEntity_v2 = unknown;
|
|
62
62
|
|
|
63
63
|
type ApiNotificationSettingEntityTypes = {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
[ApiVersion.v1]: ApiNotificationSettingsEntity_v1;
|
|
65
|
+
[ApiVersion.v2]: ApiNotificationSettingsEntity_v2;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export type ApiNotificationSettingsEntity<T extends string = ApiVersion> = T extends ApiVersion
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
? ApiNotificationSettingEntityTypes[T]
|
|
70
|
+
: unknown;
|
|
@@ -1,170 +1,150 @@
|
|
|
1
|
-
import { IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
2
|
-
import { ClientMethod } from '../types';
|
|
3
|
-
import { GetNotificationFn, GetNotificationResult } from './notification/get';
|
|
1
|
+
import type { IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
2
|
+
import type { ClientMethod } from '../types';
|
|
3
|
+
import type { GetNotificationFn, GetNotificationResult } from './notification/get';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
createNotification,
|
|
6
|
+
deleteNotification,
|
|
7
|
+
getNotificationById,
|
|
8
|
+
getNotifications,
|
|
9
|
+
updateSeenByUser,
|
|
10
10
|
} from './notification';
|
|
11
11
|
import { ApiVersion } from './static';
|
|
12
|
-
import { PatchNotificationFn, PatchNotificationResult } from './notification/patch';
|
|
13
|
-
import { GetNotificationsFn, GetNotificationsResult } from './notification/getAll';
|
|
14
|
-
import { PostNotificationResult, PostNotificationFn } from './notification/post';
|
|
15
|
-
import { DeleteNotificationFn, DeleteNotificationResult } from './notification/delete';
|
|
12
|
+
import type { PatchNotificationFn, PatchNotificationResult } from './notification/patch';
|
|
13
|
+
import type { GetNotificationsFn, GetNotificationsResult } from './notification/getAll';
|
|
14
|
+
import type { PostNotificationResult, PostNotificationFn } from './notification/post';
|
|
15
|
+
import type { DeleteNotificationFn, DeleteNotificationResult } from './notification/delete';
|
|
16
16
|
import updateUserNotificationSettings, {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
type PutUserNotificationSettingsFn,
|
|
18
|
+
type PutUserNotificationSettingsResult,
|
|
19
19
|
} from './settings/put';
|
|
20
20
|
import getUserNotificationSettings, {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
type GetUserNotificationSettingsFn,
|
|
22
|
+
type GetUserNotificationsSettingsResult,
|
|
23
23
|
} from './settings/get';
|
|
24
24
|
|
|
25
25
|
export class NotificationApiClient<
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
27
|
+
TClient extends IHttpClient = IHttpClient,
|
|
28
28
|
> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
get Version(): typeof ApiVersion {
|
|
30
|
+
return ApiVersion;
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
constructor(
|
|
34
|
+
protected _client: TClient,
|
|
35
|
+
protected _method: TMethod,
|
|
36
|
+
) {}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this._method,
|
|
53
|
-
);
|
|
54
|
-
return fn<TResult>(...args);
|
|
55
|
-
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetch all notifications
|
|
40
|
+
* @see {@link getAll/client}
|
|
41
|
+
*/
|
|
42
|
+
public getAll<
|
|
43
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
44
|
+
TResult = GetNotificationsResult<TVersion>,
|
|
45
|
+
>(
|
|
46
|
+
version: TVersion,
|
|
47
|
+
...args: Parameters<GetNotificationsFn<TVersion, TMethod, TClient, TResult>>
|
|
48
|
+
): GetNotificationsResult<TVersion, TMethod, TResult> {
|
|
49
|
+
const fn = getNotifications<TVersion, TMethod, TClient>(this._client, version, this._method);
|
|
50
|
+
return fn<TResult>(...args);
|
|
51
|
+
}
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this._method,
|
|
72
|
-
);
|
|
73
|
-
return fn<TResult>(...args);
|
|
74
|
-
}
|
|
53
|
+
/**
|
|
54
|
+
* Fetch notification by id
|
|
55
|
+
* @see {@link getById/client}
|
|
56
|
+
*/
|
|
57
|
+
public getById<
|
|
58
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
59
|
+
TResult = GetNotificationResult<TVersion>,
|
|
60
|
+
>(
|
|
61
|
+
version: TVersion,
|
|
62
|
+
...args: Parameters<GetNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
63
|
+
): GetNotificationResult<TVersion, TMethod, TResult> {
|
|
64
|
+
const fn = getNotificationById<TVersion, TMethod, TClient>(this._client, version, this._method);
|
|
65
|
+
return fn<TResult>(...args);
|
|
66
|
+
}
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this._method,
|
|
91
|
-
);
|
|
92
|
-
return fn<TResult>(...args);
|
|
93
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* Set notification seen by user
|
|
70
|
+
* @see {@link setSeenByUser/client}
|
|
71
|
+
*/
|
|
72
|
+
public setSeenByUser<
|
|
73
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
74
|
+
TResult = PatchNotificationResult<TVersion>,
|
|
75
|
+
>(
|
|
76
|
+
version: TVersion,
|
|
77
|
+
...args: Parameters<PatchNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
78
|
+
): PatchNotificationResult<TVersion, TMethod, TResult> {
|
|
79
|
+
const fn = updateSeenByUser<TVersion, TMethod, TClient>(this._client, version, this._method);
|
|
80
|
+
return fn<TResult>(...args);
|
|
81
|
+
}
|
|
94
82
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this._method,
|
|
110
|
-
);
|
|
111
|
-
return fn<TResult>(...args);
|
|
112
|
-
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a notification
|
|
85
|
+
* @see {@link create/client}
|
|
86
|
+
*/
|
|
87
|
+
public create<
|
|
88
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
89
|
+
TResult = PostNotificationResult<TVersion>,
|
|
90
|
+
>(
|
|
91
|
+
version: TVersion,
|
|
92
|
+
...args: Parameters<PostNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
93
|
+
): PostNotificationResult<TVersion, TMethod, TResult> {
|
|
94
|
+
const fn = createNotification<TVersion, TMethod, TClient>(this._client, version, this._method);
|
|
95
|
+
return fn<TResult>(...args);
|
|
96
|
+
}
|
|
113
97
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
>(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
>(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this._method,
|
|
165
|
-
);
|
|
166
|
-
return fn<TResult>(...args);
|
|
167
|
-
}
|
|
98
|
+
/**
|
|
99
|
+
* Delete a notification
|
|
100
|
+
* @see {@link delete/client}
|
|
101
|
+
*/
|
|
102
|
+
public delete<
|
|
103
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
104
|
+
TResult = PostNotificationResult<TVersion>,
|
|
105
|
+
>(
|
|
106
|
+
version: TVersion,
|
|
107
|
+
...args: Parameters<DeleteNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
108
|
+
): DeleteNotificationResult<TVersion, TMethod, TResult> {
|
|
109
|
+
const fn = deleteNotification<TVersion, TMethod, TClient>(this._client, version, this._method);
|
|
110
|
+
return fn<TResult>(...args);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get users notification settings
|
|
114
|
+
* @see {@link getSettings/client}
|
|
115
|
+
*/
|
|
116
|
+
public getSettings<
|
|
117
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
118
|
+
TResult = PostNotificationResult<TVersion>,
|
|
119
|
+
>(
|
|
120
|
+
version: TVersion,
|
|
121
|
+
...args: Parameters<GetUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
|
|
122
|
+
): GetUserNotificationsSettingsResult<TVersion, TMethod, TResult> {
|
|
123
|
+
const fn = getUserNotificationSettings<TVersion, TMethod, TClient>(
|
|
124
|
+
this._client,
|
|
125
|
+
version,
|
|
126
|
+
this._method,
|
|
127
|
+
);
|
|
128
|
+
return fn<TResult>(...args);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Update user notification settings
|
|
132
|
+
* @see {@link updateSettings/client}
|
|
133
|
+
*/
|
|
134
|
+
public updateSettings<
|
|
135
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
136
|
+
TResult = PostNotificationResult<TVersion>,
|
|
137
|
+
>(
|
|
138
|
+
version: TVersion,
|
|
139
|
+
...args: Parameters<PutUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
|
|
140
|
+
): PutUserNotificationSettingsResult<TVersion, TMethod, TResult> {
|
|
141
|
+
const fn = updateUserNotificationSettings<TVersion, TMethod, TClient>(
|
|
142
|
+
this._client,
|
|
143
|
+
version,
|
|
144
|
+
this._method,
|
|
145
|
+
);
|
|
146
|
+
return fn<TResult>(...args);
|
|
147
|
+
}
|
|
168
148
|
}
|
|
169
149
|
|
|
170
150
|
export default NotificationApiClient;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
-
import { ClientMethod } from '../../../types';
|
|
3
|
-
import { ApiVersion } from '../../static';
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import type { ClientMethod } from '../../../types';
|
|
3
|
+
import type { ApiVersion } from '../../static';
|
|
4
4
|
|
|
5
5
|
import { generateParameters } from './generate-parameters';
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
DeleteNotificationArgs,
|
|
9
|
+
DeleteNotificationResponse,
|
|
10
|
+
DeleteNotificationResult,
|
|
11
11
|
} from './types';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -17,21 +17,21 @@ import type {
|
|
|
17
17
|
* @param method - client method to call
|
|
18
18
|
*/
|
|
19
19
|
export const deleteNotification =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
<
|
|
21
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
22
|
+
TMethod extends keyof ClientMethod = keyof ClientMethod,
|
|
23
|
+
TClient extends IHttpClient = IHttpClient,
|
|
24
|
+
>(
|
|
25
|
+
client: TClient,
|
|
26
|
+
version: TVersion,
|
|
27
|
+
method: TMethod = 'json' as TMethod,
|
|
28
|
+
) =>
|
|
29
|
+
<T = DeleteNotificationResponse<TVersion>>(
|
|
30
|
+
args: DeleteNotificationArgs<TVersion>,
|
|
31
|
+
init?: ClientRequestInit<TClient, T>,
|
|
32
|
+
): DeleteNotificationResult<TVersion, TMethod, T> =>
|
|
33
|
+
client[method](
|
|
34
|
+
...generateParameters<T, TVersion, TClient>(version, args, init),
|
|
35
|
+
) as DeleteNotificationResult<TVersion, TMethod, T>;
|
|
36
36
|
|
|
37
37
|
export default deleteNotification;
|
|
@@ -6,19 +6,18 @@ import type { DeleteNotificationArgs } from './types';
|
|
|
6
6
|
* Method for generating endpoint for getting notification by id
|
|
7
7
|
*/
|
|
8
8
|
export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `/notification/${id}/?${String(params)}`;
|
|
22
|
-
}
|
|
9
|
+
version: TVersion,
|
|
10
|
+
args: DeleteNotificationArgs<TVersion>,
|
|
11
|
+
): string => {
|
|
12
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
13
|
+
switch (apiVersion) {
|
|
14
|
+
case ApiVersion.v2:
|
|
15
|
+
throw new UnsupportedApiVersion(version);
|
|
16
|
+
default: {
|
|
17
|
+
const { id } = args as { id: string };
|
|
18
|
+
const params = new URLSearchParams();
|
|
19
|
+
params.append('api-version', apiVersion);
|
|
20
|
+
return `/notification/${id}/?${String(params)}`;
|
|
23
21
|
}
|
|
22
|
+
}
|
|
24
23
|
};
|