@equinor/fusion-framework-module-services 2.1.0 → 2.2.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 +6 -0
- package/dist/esm/notification/api-models.js +2 -0
- package/dist/esm/notification/api-models.js.map +1 -0
- package/dist/esm/notification/client.js +43 -0
- package/dist/esm/notification/client.js.map +1 -0
- package/dist/esm/notification/index.js +5 -0
- package/dist/esm/notification/index.js.map +1 -0
- package/dist/esm/notification/notification/delete/client.js +4 -0
- package/dist/esm/notification/notification/delete/client.js.map +1 -0
- package/dist/esm/notification/notification/delete/generate-endpoint.js +18 -0
- package/dist/esm/notification/notification/delete/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/notification/delete/generate-parameters.js +10 -0
- package/dist/esm/notification/notification/delete/generate-parameters.js.map +1 -0
- package/dist/esm/notification/notification/delete/index.js +6 -0
- package/dist/esm/notification/notification/delete/index.js.map +1 -0
- package/dist/esm/notification/notification/delete/types.js +2 -0
- package/dist/esm/notification/notification/delete/types.js.map +1 -0
- package/dist/esm/notification/notification/get/client.js +4 -0
- package/dist/esm/notification/notification/get/client.js.map +1 -0
- package/dist/esm/notification/notification/get/generate-endpoint.js +18 -0
- package/dist/esm/notification/notification/get/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/notification/get/generate-parameters.js +7 -0
- package/dist/esm/notification/notification/get/generate-parameters.js.map +1 -0
- package/dist/esm/notification/notification/get/index.js +6 -0
- package/dist/esm/notification/notification/get/index.js.map +1 -0
- package/dist/esm/notification/notification/get/types.js +2 -0
- package/dist/esm/notification/notification/get/types.js.map +1 -0
- package/dist/esm/notification/notification/getAll/client.js +4 -0
- package/dist/esm/notification/notification/getAll/client.js.map +1 -0
- package/dist/esm/notification/notification/getAll/generate-endpoint.js +18 -0
- package/dist/esm/notification/notification/getAll/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/notification/getAll/generate-parameters.js +7 -0
- package/dist/esm/notification/notification/getAll/generate-parameters.js.map +1 -0
- package/dist/esm/notification/notification/getAll/index.js +6 -0
- package/dist/esm/notification/notification/getAll/index.js.map +1 -0
- package/dist/esm/notification/notification/getAll/types.js +2 -0
- package/dist/esm/notification/notification/getAll/types.js.map +1 -0
- package/dist/esm/notification/notification/index.js +6 -0
- package/dist/esm/notification/notification/index.js.map +1 -0
- package/dist/esm/notification/notification/patch/client.js +4 -0
- package/dist/esm/notification/notification/patch/client.js.map +1 -0
- package/dist/esm/notification/notification/patch/generate-endpoint.js +18 -0
- package/dist/esm/notification/notification/patch/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/notification/patch/generate-parameters.js +10 -0
- package/dist/esm/notification/notification/patch/generate-parameters.js.map +1 -0
- package/dist/esm/notification/notification/patch/index.js +6 -0
- package/dist/esm/notification/notification/patch/index.js.map +1 -0
- package/dist/esm/notification/notification/patch/types.js +2 -0
- package/dist/esm/notification/notification/patch/types.js.map +1 -0
- package/dist/esm/notification/notification/post/client.js +4 -0
- package/dist/esm/notification/notification/post/client.js.map +1 -0
- package/dist/esm/notification/notification/post/generate-endpoint.js +18 -0
- package/dist/esm/notification/notification/post/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/notification/post/generate-parameters.js +10 -0
- package/dist/esm/notification/notification/post/generate-parameters.js.map +1 -0
- package/dist/esm/notification/notification/post/index.js +6 -0
- package/dist/esm/notification/notification/post/index.js.map +1 -0
- package/dist/esm/notification/notification/post/types.js +2 -0
- package/dist/esm/notification/notification/post/types.js.map +1 -0
- package/dist/esm/notification/settings/get/client.js +4 -0
- package/dist/esm/notification/settings/get/client.js.map +1 -0
- package/dist/esm/notification/settings/get/generate-endpoint.js +18 -0
- package/dist/esm/notification/settings/get/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/settings/get/generate-parameters.js +7 -0
- package/dist/esm/notification/settings/get/generate-parameters.js.map +1 -0
- package/dist/esm/notification/settings/get/index.js +6 -0
- package/dist/esm/notification/settings/get/index.js.map +1 -0
- package/dist/esm/notification/settings/get/types.js +2 -0
- package/dist/esm/notification/settings/get/types.js.map +1 -0
- package/dist/esm/notification/settings/put/client.js +4 -0
- package/dist/esm/notification/settings/put/client.js.map +1 -0
- package/dist/esm/notification/settings/put/generate-endpoint.js +18 -0
- package/dist/esm/notification/settings/put/generate-endpoint.js.map +1 -0
- package/dist/esm/notification/settings/put/generate-parameters.js +10 -0
- package/dist/esm/notification/settings/put/generate-parameters.js.map +1 -0
- package/dist/esm/notification/settings/put/index.js +6 -0
- package/dist/esm/notification/settings/put/index.js.map +1 -0
- package/dist/esm/notification/settings/put/types.js +2 -0
- package/dist/esm/notification/settings/put/types.js.map +1 -0
- package/dist/esm/notification/static.js +6 -0
- package/dist/esm/notification/static.js.map +1 -0
- package/dist/esm/notification/types.js +2 -0
- package/dist/esm/notification/types.js.map +1 -0
- package/dist/esm/provider.js +7 -0
- package/dist/esm/provider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/notification/api-models.d.ts +54 -0
- package/dist/types/notification/client.d.ts +24 -0
- package/dist/types/notification/index.d.ts +4 -0
- package/dist/types/notification/notification/delete/client.d.ts +5 -0
- package/dist/types/notification/notification/delete/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/notification/delete/generate-parameters.d.ts +5 -0
- package/dist/types/notification/notification/delete/index.d.ts +5 -0
- package/dist/types/notification/notification/delete/types.d.ts +21 -0
- package/dist/types/notification/notification/get/client.d.ts +5 -0
- package/dist/types/notification/notification/get/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/notification/get/generate-parameters.d.ts +5 -0
- package/dist/types/notification/notification/get/index.d.ts +5 -0
- package/dist/types/notification/notification/get/types.d.ts +21 -0
- package/dist/types/notification/notification/getAll/client.d.ts +5 -0
- package/dist/types/notification/notification/getAll/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/notification/getAll/generate-parameters.d.ts +5 -0
- package/dist/types/notification/notification/getAll/index.d.ts +5 -0
- package/dist/types/notification/notification/getAll/types.d.ts +21 -0
- package/dist/types/notification/notification/index.d.ts +5 -0
- package/dist/types/notification/notification/patch/client.d.ts +5 -0
- package/dist/types/notification/notification/patch/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/notification/patch/generate-parameters.d.ts +5 -0
- package/dist/types/notification/notification/patch/index.d.ts +5 -0
- package/dist/types/notification/notification/patch/types.d.ts +22 -0
- package/dist/types/notification/notification/post/client.d.ts +5 -0
- package/dist/types/notification/notification/post/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/notification/post/generate-parameters.d.ts +5 -0
- package/dist/types/notification/notification/post/index.d.ts +5 -0
- package/dist/types/notification/notification/post/types.d.ts +33 -0
- package/dist/types/notification/settings/get/client.d.ts +5 -0
- package/dist/types/notification/settings/get/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/settings/get/generate-parameters.d.ts +5 -0
- package/dist/types/notification/settings/get/index.d.ts +5 -0
- package/dist/types/notification/settings/get/types.d.ts +21 -0
- package/dist/types/notification/settings/put/client.d.ts +5 -0
- package/dist/types/notification/settings/put/generate-endpoint.d.ts +2 -0
- package/dist/types/notification/settings/put/generate-parameters.d.ts +5 -0
- package/dist/types/notification/settings/put/index.d.ts +5 -0
- package/dist/types/notification/settings/put/types.d.ts +17 -0
- package/dist/types/notification/static.d.ts +4 -0
- package/dist/types/notification/types.d.ts +1 -0
- package/dist/types/provider.d.ts +2 -0
- package/package.json +6 -2
- package/src/notification/api-models.ts +70 -0
- package/src/notification/client.ts +167 -0
- package/src/notification/index.ts +6 -0
- package/src/notification/notification/delete/client.ts +37 -0
- package/src/notification/notification/delete/generate-endpoint.ts +24 -0
- package/src/notification/notification/delete/generate-parameters.ts +32 -0
- package/src/notification/notification/delete/index.ts +8 -0
- package/src/notification/notification/delete/types.ts +44 -0
- package/src/notification/notification/get/client.ts +33 -0
- package/src/notification/notification/get/generate-endpoint.ts +25 -0
- package/src/notification/notification/get/generate-parameters.ts +22 -0
- package/src/notification/notification/get/index.ts +8 -0
- package/src/notification/notification/get/types.ts +44 -0
- package/src/notification/notification/getAll/client.ts +37 -0
- package/src/notification/notification/getAll/generate-endpoint.ts +25 -0
- package/src/notification/notification/getAll/generate-parameters.ts +22 -0
- package/src/notification/notification/getAll/index.ts +8 -0
- package/src/notification/notification/getAll/types.ts +44 -0
- package/src/notification/notification/index.ts +5 -0
- package/src/notification/notification/patch/client.ts +37 -0
- package/src/notification/notification/patch/generate-endpoint.ts +24 -0
- package/src/notification/notification/patch/generate-parameters.ts +32 -0
- package/src/notification/notification/patch/index.ts +8 -0
- package/src/notification/notification/patch/types.ts +45 -0
- package/src/notification/notification/post/client.ts +37 -0
- package/src/notification/notification/post/generate-endpoint.ts +25 -0
- package/src/notification/notification/post/generate-parameters.ts +32 -0
- package/src/notification/notification/post/index.ts +8 -0
- package/src/notification/notification/post/types.ts +57 -0
- package/src/notification/settings/get/client.ts +37 -0
- package/src/notification/settings/get/generate-endpoint.ts +25 -0
- package/src/notification/settings/get/generate-parameters.ts +22 -0
- package/src/notification/settings/get/index.ts +8 -0
- package/src/notification/settings/get/types.ts +44 -0
- package/src/notification/settings/put/client.ts +37 -0
- package/src/notification/settings/put/generate-endpoint.ts +25 -0
- package/src/notification/settings/put/generate-parameters.ts +34 -0
- package/src/notification/settings/put/index.ts +8 -0
- package/src/notification/settings/put/types.ts +38 -0
- package/src/notification/static.ts +6 -0
- package/src/notification/types.ts +5 -0
- package/src/provider.ts +8 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
2
|
+
import { ClientMethod } from '../types';
|
|
3
|
+
import { GetNotificationFn, GetNotificationResult } from './notification/get';
|
|
4
|
+
import {
|
|
5
|
+
createNotification,
|
|
6
|
+
deleteNotification,
|
|
7
|
+
getNotificationById,
|
|
8
|
+
getNotifications,
|
|
9
|
+
updateSeenByUser,
|
|
10
|
+
} from './notification';
|
|
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';
|
|
16
|
+
import updateUserNotificationSettings, {
|
|
17
|
+
PutUserNotificationSettingsFn,
|
|
18
|
+
PutUserNotificationSettingsResult,
|
|
19
|
+
} from './settings/put';
|
|
20
|
+
import getUserNotificationSettings, {
|
|
21
|
+
GetUserNotificationSettingsFn,
|
|
22
|
+
GetUserNotificationsSettingsResult,
|
|
23
|
+
} from './settings/get';
|
|
24
|
+
|
|
25
|
+
export class NotificationApiClient<
|
|
26
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
27
|
+
TClient extends IHttpClient = IHttpClient
|
|
28
|
+
> {
|
|
29
|
+
get Version(): typeof ApiVersion {
|
|
30
|
+
return ApiVersion;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor(protected _client: TClient, protected _method: TMethod) {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Fetch all notifications
|
|
37
|
+
* @see {@link getAll/client}
|
|
38
|
+
*/
|
|
39
|
+
public getAll<
|
|
40
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
41
|
+
TResult = GetNotificationsResult<TVersion>
|
|
42
|
+
>(
|
|
43
|
+
version: TVersion,
|
|
44
|
+
...args: Parameters<GetNotificationsFn<TVersion, TMethod, TClient, TResult>>
|
|
45
|
+
): GetNotificationsResult<TVersion, TMethod, TResult> {
|
|
46
|
+
const fn = getNotifications<TVersion, TMethod, TClient>(
|
|
47
|
+
this._client,
|
|
48
|
+
version,
|
|
49
|
+
this._method
|
|
50
|
+
);
|
|
51
|
+
return fn<TResult>(...args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fetch notification by id
|
|
56
|
+
* @see {@link getById/client}
|
|
57
|
+
*/
|
|
58
|
+
public getById<
|
|
59
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
60
|
+
TResult = GetNotificationResult<TVersion>
|
|
61
|
+
>(
|
|
62
|
+
version: TVersion,
|
|
63
|
+
...args: Parameters<GetNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
64
|
+
): GetNotificationResult<TVersion, TMethod, TResult> {
|
|
65
|
+
const fn = getNotificationById<TVersion, TMethod, TClient>(
|
|
66
|
+
this._client,
|
|
67
|
+
version,
|
|
68
|
+
this._method
|
|
69
|
+
);
|
|
70
|
+
return fn<TResult>(...args);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Set notification seen by user
|
|
75
|
+
* @see {@link setSeenByUser/client}
|
|
76
|
+
*/
|
|
77
|
+
public setSeenByUser<
|
|
78
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
79
|
+
TResult = PatchNotificationResult<TVersion>
|
|
80
|
+
>(
|
|
81
|
+
version: TVersion,
|
|
82
|
+
...args: Parameters<PatchNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
83
|
+
): PatchNotificationResult<TVersion, TMethod, TResult> {
|
|
84
|
+
const fn = updateSeenByUser<TVersion, TMethod, TClient>(
|
|
85
|
+
this._client,
|
|
86
|
+
version,
|
|
87
|
+
this._method
|
|
88
|
+
);
|
|
89
|
+
return fn<TResult>(...args);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Create a notification
|
|
94
|
+
* @see {@link create/client}
|
|
95
|
+
*/
|
|
96
|
+
public create<
|
|
97
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
98
|
+
TResult = PostNotificationResult<TVersion>
|
|
99
|
+
>(
|
|
100
|
+
version: TVersion,
|
|
101
|
+
...args: Parameters<PostNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
102
|
+
): PostNotificationResult<TVersion, TMethod, TResult> {
|
|
103
|
+
const fn = createNotification<TVersion, TMethod, TClient>(
|
|
104
|
+
this._client,
|
|
105
|
+
version,
|
|
106
|
+
this._method
|
|
107
|
+
);
|
|
108
|
+
return fn<TResult>(...args);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Delete a notification
|
|
113
|
+
* @see {@link delete/client}
|
|
114
|
+
*/
|
|
115
|
+
public delete<
|
|
116
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
117
|
+
TResult = PostNotificationResult<TVersion>
|
|
118
|
+
>(
|
|
119
|
+
version: TVersion,
|
|
120
|
+
...args: Parameters<DeleteNotificationFn<TVersion, TMethod, TClient, TResult>>
|
|
121
|
+
): DeleteNotificationResult<TVersion, TMethod, TResult> {
|
|
122
|
+
const fn = deleteNotification<TVersion, TMethod, TClient>(
|
|
123
|
+
this._client,
|
|
124
|
+
version,
|
|
125
|
+
this._method
|
|
126
|
+
);
|
|
127
|
+
return fn<TResult>(...args);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get users notification settings
|
|
131
|
+
* @see {@link getSettings/client}
|
|
132
|
+
*/
|
|
133
|
+
public getSettings<
|
|
134
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
135
|
+
TResult = PostNotificationResult<TVersion>
|
|
136
|
+
>(
|
|
137
|
+
version: TVersion,
|
|
138
|
+
...args: Parameters<GetUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
|
|
139
|
+
): GetUserNotificationsSettingsResult<TVersion, TMethod, TResult> {
|
|
140
|
+
const fn = getUserNotificationSettings<TVersion, TMethod, TClient>(
|
|
141
|
+
this._client,
|
|
142
|
+
version,
|
|
143
|
+
this._method
|
|
144
|
+
);
|
|
145
|
+
return fn<TResult>(...args);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Update user notification settings
|
|
149
|
+
* @see {@link updateSettings/client}
|
|
150
|
+
*/
|
|
151
|
+
public updateSettings<
|
|
152
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
153
|
+
TResult = PostNotificationResult<TVersion>
|
|
154
|
+
>(
|
|
155
|
+
version: TVersion,
|
|
156
|
+
...args: Parameters<PutUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
|
|
157
|
+
): PutUserNotificationSettingsResult<TVersion, TMethod, TResult> {
|
|
158
|
+
const fn = updateUserNotificationSettings<TVersion, TMethod, TClient>(
|
|
159
|
+
this._client,
|
|
160
|
+
version,
|
|
161
|
+
this._method
|
|
162
|
+
);
|
|
163
|
+
return fn<TResult>(...args);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export default NotificationApiClient;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiVersion } from '../../static';
|
|
4
|
+
|
|
5
|
+
import { generateParameters } from './generate-parameters';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
DeleteNotificationArgs,
|
|
9
|
+
DeleteNotificationResponse,
|
|
10
|
+
DeleteNotificationResult,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Method for deleting notification item from notifications service
|
|
15
|
+
* @param client - client for execution of request
|
|
16
|
+
* @param version - version of API to call
|
|
17
|
+
* @param method - client method to call
|
|
18
|
+
*/
|
|
19
|
+
export const deleteNotification =
|
|
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
|
+
|
|
37
|
+
export default deleteNotification;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UnsupportedApiVersion } from '@equinor/fusion-framework-module-services/errors';
|
|
2
|
+
import { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
3
|
+
import type { DeleteNotificationArgs } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Method for generating endpoint for getting notification by id
|
|
7
|
+
*/
|
|
8
|
+
export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
|
|
9
|
+
version: TVersion,
|
|
10
|
+
args: DeleteNotificationArgs<TVersion>
|
|
11
|
+
) => {
|
|
12
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
13
|
+
switch (apiVersion) {
|
|
14
|
+
case ApiVersion.v2:
|
|
15
|
+
throw new UnsupportedApiVersion(version);
|
|
16
|
+
case ApiVersion.v1:
|
|
17
|
+
default: {
|
|
18
|
+
const { id } = args as { id: string };
|
|
19
|
+
const params = new URLSearchParams();
|
|
20
|
+
params.append('api-version', apiVersion);
|
|
21
|
+
return `/notification/${id}/?${String(params)}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ApiVersion } from '../../static';
|
|
3
|
+
import { ApiClientArguments } from '../../types';
|
|
4
|
+
|
|
5
|
+
import { generateEndpoint } from './generate-endpoint';
|
|
6
|
+
import { DeleteNotificationArgs } from './types';
|
|
7
|
+
|
|
8
|
+
/** function for creating http client arguments */
|
|
9
|
+
export const generateParameters = <
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient
|
|
13
|
+
>(
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: DeleteNotificationArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
17
|
+
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
|
|
20
|
+
const headers = new Headers();
|
|
21
|
+
headers.append('content-type', 'application/json');
|
|
22
|
+
|
|
23
|
+
const requestParams: ClientRequestInit<TClient, TResult> = Object.assign(
|
|
24
|
+
{},
|
|
25
|
+
{ method: 'delete', headers: headers },
|
|
26
|
+
init
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return [path, requestParams];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default generateParameters;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
2
|
+
|
|
3
|
+
export { generateEndpoint } from './generate-endpoint';
|
|
4
|
+
export { generateParameters } from './generate-parameters';
|
|
5
|
+
|
|
6
|
+
export * from './types';
|
|
7
|
+
|
|
8
|
+
export { deleteNotification as getNotificationById, default } from './client';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IHttpClient, ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiNotificationEntity } from '../../api-models';
|
|
4
|
+
import { ApiVersion } from '../../static';
|
|
5
|
+
|
|
6
|
+
type DeleteNotificationArgs_v1 = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type DeleteNotificationArgs_v2 = DeleteNotificationArgs_v1;
|
|
11
|
+
|
|
12
|
+
type DeleteNotificationArgsTypes = {
|
|
13
|
+
[ApiVersion.v1]: DeleteNotificationArgs_v1;
|
|
14
|
+
[ApiVersion.v2]: DeleteNotificationArgs_v2;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type DeleteNotificationArgs<T extends string> = T extends keyof typeof ApiVersion
|
|
18
|
+
? DeleteNotificationArgsTypes[(typeof ApiVersion)[T]]
|
|
19
|
+
: unknown;
|
|
20
|
+
|
|
21
|
+
type DeleteNotificationResponseTypes = {
|
|
22
|
+
[ApiVersion.v1]: ApiNotificationEntity<ApiVersion.v1>;
|
|
23
|
+
[ApiVersion.v2]: ApiNotificationEntity<ApiVersion.v2>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type DeleteNotificationResponse<T> = T extends keyof typeof ApiVersion
|
|
27
|
+
? DeleteNotificationResponseTypes[(typeof ApiVersion)[T]]
|
|
28
|
+
: unknown;
|
|
29
|
+
|
|
30
|
+
export type DeleteNotificationFn<
|
|
31
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
32
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
33
|
+
TClient extends IHttpClient = IHttpClient,
|
|
34
|
+
TResult = DeleteNotificationResponse<TVersion>
|
|
35
|
+
> = (
|
|
36
|
+
args: DeleteNotificationArgs<TVersion>,
|
|
37
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
38
|
+
) => DeleteNotificationResult<TVersion, TMethod, TResult>;
|
|
39
|
+
|
|
40
|
+
export type DeleteNotificationResult<
|
|
41
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
42
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
43
|
+
TResult = DeleteNotificationResponse<TVersion>
|
|
44
|
+
> = ClientMethod<TResult>[TMethod];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiVersion } from '../../static';
|
|
4
|
+
|
|
5
|
+
import { generateParameters } from './generate-parameters';
|
|
6
|
+
|
|
7
|
+
import type { GetNotificationArgs, GetNotificationResult, GetNotificationResponse } from './types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Method for fetching a notification item from notifications service
|
|
11
|
+
* @param client - client for execution of request
|
|
12
|
+
* @param version - version of API to call
|
|
13
|
+
* @param method - client method to call
|
|
14
|
+
*/
|
|
15
|
+
export const getNotificationById =
|
|
16
|
+
<
|
|
17
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
18
|
+
TMethod extends keyof ClientMethod = keyof ClientMethod,
|
|
19
|
+
TClient extends IHttpClient = IHttpClient
|
|
20
|
+
>(
|
|
21
|
+
client: TClient,
|
|
22
|
+
version: TVersion,
|
|
23
|
+
method: TMethod = 'json' as TMethod
|
|
24
|
+
) =>
|
|
25
|
+
<T = GetNotificationResponse<TVersion>>(
|
|
26
|
+
args: GetNotificationArgs<TVersion>,
|
|
27
|
+
init?: ClientRequestInit<TClient, T>
|
|
28
|
+
): GetNotificationResult<TVersion, TMethod, T> =>
|
|
29
|
+
client[method](
|
|
30
|
+
...generateParameters<T, TVersion, TClient>(version, args, init)
|
|
31
|
+
) as GetNotificationResult<TVersion, TMethod, T>;
|
|
32
|
+
|
|
33
|
+
export default getNotificationById;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UnsupportedApiVersion } from '@equinor/fusion-framework-module-services/errors';
|
|
2
|
+
import { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
3
|
+
|
|
4
|
+
import type { GetNotificationArgs } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Method for generating endpoint for getting notification by id
|
|
8
|
+
*/
|
|
9
|
+
export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
|
|
10
|
+
version: TVersion,
|
|
11
|
+
args: GetNotificationArgs<TVersion>
|
|
12
|
+
) => {
|
|
13
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
14
|
+
switch (apiVersion) {
|
|
15
|
+
case ApiVersion.v2:
|
|
16
|
+
throw new UnsupportedApiVersion(version);
|
|
17
|
+
case ApiVersion.v1:
|
|
18
|
+
default: {
|
|
19
|
+
const { id } = args as { id: string };
|
|
20
|
+
const params = new URLSearchParams();
|
|
21
|
+
params.append('api-version', apiVersion);
|
|
22
|
+
return `/notification/${id}/?${String(params)}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ApiVersion } from '../../static';
|
|
3
|
+
import { ApiClientArguments } from '../../types';
|
|
4
|
+
|
|
5
|
+
import { generateEndpoint } from './generate-endpoint';
|
|
6
|
+
import { GetNotificationArgs } from './types';
|
|
7
|
+
|
|
8
|
+
/** function for creating http client arguments */
|
|
9
|
+
export const generateParameters = <
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient
|
|
13
|
+
>(
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: GetNotificationArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
17
|
+
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
return [path, init];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default generateParameters;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
2
|
+
|
|
3
|
+
export { generateEndpoint } from './generate-endpoint';
|
|
4
|
+
export { generateParameters } from './generate-parameters';
|
|
5
|
+
|
|
6
|
+
export * from './types';
|
|
7
|
+
|
|
8
|
+
export { getNotificationById, default } from './client';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IHttpClient, ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiNotificationEntity } from '../../api-models';
|
|
4
|
+
import { ApiVersion } from '../../static';
|
|
5
|
+
|
|
6
|
+
type GetNotificationArgs_v1 = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type GetNotificationArgs_v2 = GetNotificationArgs_v1;
|
|
11
|
+
|
|
12
|
+
type GetNotificationArgsTypes = {
|
|
13
|
+
[ApiVersion.v1]: GetNotificationArgs_v1;
|
|
14
|
+
[ApiVersion.v2]: GetNotificationArgs_v2;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type GetNotificationArgs<T extends string> = T extends keyof typeof ApiVersion
|
|
18
|
+
? GetNotificationArgsTypes[(typeof ApiVersion)[T]]
|
|
19
|
+
: unknown;
|
|
20
|
+
|
|
21
|
+
type GetNotificationResponseTypes = {
|
|
22
|
+
[ApiVersion.v1]: ApiNotificationEntity<ApiVersion.v1>;
|
|
23
|
+
[ApiVersion.v2]: ApiNotificationEntity<ApiVersion.v2>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type GetNotificationResponse<T> = T extends keyof typeof ApiVersion
|
|
27
|
+
? GetNotificationResponseTypes[(typeof ApiVersion)[T]]
|
|
28
|
+
: unknown;
|
|
29
|
+
|
|
30
|
+
export type GetNotificationFn<
|
|
31
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
32
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
33
|
+
TClient extends IHttpClient = IHttpClient,
|
|
34
|
+
TResult = GetNotificationResponse<TVersion>
|
|
35
|
+
> = (
|
|
36
|
+
args: GetNotificationArgs<TVersion>,
|
|
37
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
38
|
+
) => GetNotificationResult<TVersion, TMethod, TResult>;
|
|
39
|
+
|
|
40
|
+
export type GetNotificationResult<
|
|
41
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
42
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
43
|
+
TResult = GetNotificationResponse<TVersion>
|
|
44
|
+
> = ClientMethod<TResult>[TMethod];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiVersion } from '../../static';
|
|
4
|
+
|
|
5
|
+
import { generateParameters } from './generate-parameters';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
GetNotificationsArgs,
|
|
9
|
+
GetNotificationsResult,
|
|
10
|
+
GetNotificationsResponse,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Method for fetching all notifications item from notification service
|
|
15
|
+
* @param client - client for execution of request
|
|
16
|
+
* @param version - version of API to call
|
|
17
|
+
* @param method - client method to call
|
|
18
|
+
*/
|
|
19
|
+
export const getNotifications =
|
|
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 = GetNotificationsResponse<TVersion>>(
|
|
30
|
+
args: GetNotificationsArgs<TVersion>,
|
|
31
|
+
init?: ClientRequestInit<TClient, T>
|
|
32
|
+
): GetNotificationsResult<TVersion, TMethod, T> =>
|
|
33
|
+
client[method](
|
|
34
|
+
...generateParameters<T, TVersion, TClient>(version, args, init)
|
|
35
|
+
) as GetNotificationsResult<TVersion, TMethod, T>;
|
|
36
|
+
|
|
37
|
+
export default getNotifications;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UnsupportedApiVersion } from '@equinor/fusion-framework-module-services/errors';
|
|
2
|
+
import { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
3
|
+
|
|
4
|
+
import type { GetNotificationsArgs } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Method for generating endpoint for getting all notifications
|
|
8
|
+
*/
|
|
9
|
+
export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
|
|
10
|
+
version: TVersion,
|
|
11
|
+
args: GetNotificationsArgs<TVersion>
|
|
12
|
+
) => {
|
|
13
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
14
|
+
switch (apiVersion) {
|
|
15
|
+
case ApiVersion.v2:
|
|
16
|
+
throw new UnsupportedApiVersion(version);
|
|
17
|
+
case ApiVersion.v1:
|
|
18
|
+
default: {
|
|
19
|
+
const { userId } = args as { userId: string };
|
|
20
|
+
const params = new URLSearchParams();
|
|
21
|
+
params.append('api-version', apiVersion);
|
|
22
|
+
return `/person/${userId}/notifications/?${String(params)}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ApiVersion } from '../../static';
|
|
3
|
+
import { ApiClientArguments } from '../../types';
|
|
4
|
+
|
|
5
|
+
import { generateEndpoint } from './generate-endpoint';
|
|
6
|
+
import { GetNotificationsArgs } from './types';
|
|
7
|
+
|
|
8
|
+
/** function for creating http client arguments */
|
|
9
|
+
export const generateParameters = <
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient
|
|
13
|
+
>(
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: GetNotificationsArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
17
|
+
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
return [path, init];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default generateParameters;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ApiVersion } from '@equinor/fusion-framework-module-services/notification';
|
|
2
|
+
|
|
3
|
+
export { generateEndpoint } from './generate-endpoint';
|
|
4
|
+
export { generateParameters } from './generate-parameters';
|
|
5
|
+
|
|
6
|
+
export * from './types';
|
|
7
|
+
|
|
8
|
+
export { getNotifications, default } from './client';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IHttpClient, ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiNotificationEntity } from '../../api-models';
|
|
4
|
+
import { ApiVersion } from '../../static';
|
|
5
|
+
|
|
6
|
+
type GetNotificationsArgs_v1 = {
|
|
7
|
+
userId: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type GetNotificationsArgs_v2 = GetNotificationsArgs_v1;
|
|
11
|
+
|
|
12
|
+
type GetNotificationsArgsTypes = {
|
|
13
|
+
[ApiVersion.v1]: GetNotificationsArgs_v1;
|
|
14
|
+
[ApiVersion.v2]: GetNotificationsArgs_v2;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type GetNotificationsArgs<T extends string> = T extends keyof typeof ApiVersion
|
|
18
|
+
? GetNotificationsArgsTypes[(typeof ApiVersion)[T]]
|
|
19
|
+
: unknown;
|
|
20
|
+
|
|
21
|
+
type GetNotificationResponseTypes = {
|
|
22
|
+
[ApiVersion.v1]: Array<ApiNotificationEntity<ApiVersion.v1>>;
|
|
23
|
+
[ApiVersion.v2]: Array<ApiNotificationEntity<ApiVersion.v2>>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type GetNotificationsResponse<T> = T extends keyof typeof ApiVersion
|
|
27
|
+
? GetNotificationResponseTypes[(typeof ApiVersion)[T]]
|
|
28
|
+
: unknown;
|
|
29
|
+
|
|
30
|
+
export type GetNotificationsFn<
|
|
31
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
32
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
33
|
+
TClient extends IHttpClient = IHttpClient,
|
|
34
|
+
TResult = GetNotificationsResponse<TVersion>
|
|
35
|
+
> = (
|
|
36
|
+
args: GetNotificationsArgs<TVersion>,
|
|
37
|
+
init?: ClientRequestInit<TClient, TResult>
|
|
38
|
+
) => GetNotificationsResult<TVersion, TMethod, TResult>;
|
|
39
|
+
|
|
40
|
+
export type GetNotificationsResult<
|
|
41
|
+
TVersion extends string = keyof typeof ApiVersion,
|
|
42
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
43
|
+
TResult = GetNotificationsResponse<TVersion>
|
|
44
|
+
> = ClientMethod<TResult>[TMethod];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
|
+
import { ClientMethod } from '../../../types';
|
|
3
|
+
import { ApiVersion } from '../../static';
|
|
4
|
+
|
|
5
|
+
import { generateParameters } from './generate-parameters';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
PatchNotificationArgs,
|
|
9
|
+
PatchNotificationResponse,
|
|
10
|
+
PatchNotificationResult,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Method for updating a notification item
|
|
15
|
+
* @param client - client for execution of request
|
|
16
|
+
* @param version - version of API to call
|
|
17
|
+
* @param method - client method to call
|
|
18
|
+
*/
|
|
19
|
+
export const updateSeenByUser =
|
|
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 = PatchNotificationResponse<TVersion>>(
|
|
30
|
+
args: PatchNotificationArgs<TVersion>,
|
|
31
|
+
init?: ClientRequestInit<TClient, T>
|
|
32
|
+
): PatchNotificationResult<TVersion, TMethod, T> =>
|
|
33
|
+
client[method](
|
|
34
|
+
...generateParameters<T, TVersion, TClient>(version, args, init)
|
|
35
|
+
) as PatchNotificationResult<TVersion, TMethod, T>;
|
|
36
|
+
|
|
37
|
+
export default updateSeenByUser;
|