@equinor/fusion-framework-module-services 5.1.1-msal-0b0dadf270ee512f019a325c2f1586f91f9150a4 → 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
|
@@ -7,22 +7,22 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
* Method for generating endpoint for getting context by id
|
|
8
8
|
*/
|
|
9
9
|
export const generateEndpoint = <TVersion extends SupportedApiVersion>(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
version: TVersion,
|
|
11
|
+
args: ApiRequestArgs<TVersion>,
|
|
12
12
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
default: {
|
|
25
|
-
throw new UnsupportedApiVersion(version);
|
|
26
|
-
}
|
|
13
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
14
|
+
switch (apiVersion) {
|
|
15
|
+
case ApiVersion.v4: {
|
|
16
|
+
const { azureId, expand } = args;
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
params.append('api-version', apiVersion);
|
|
19
|
+
if (expand) {
|
|
20
|
+
params.append('$expand', expand.join(','));
|
|
21
|
+
}
|
|
22
|
+
return `/persons/${azureId}?${String(params)}`;
|
|
27
23
|
}
|
|
24
|
+
default: {
|
|
25
|
+
throw new UnsupportedApiVersion(version);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
28
|
};
|
|
@@ -7,16 +7,16 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
|
|
8
8
|
/** function for creating http client arguments */
|
|
9
9
|
export const generateParameters = <
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends SupportedApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient,
|
|
13
13
|
>(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: ApiRequestArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>,
|
|
17
17
|
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
return [path, init];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export default generateParameters;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { ApiVersion } from '../static';
|
|
2
2
|
import type { ApiPerson_v4, ApiPersonExpandProps_v4 } from '../api-models.v4';
|
|
3
|
-
import { ClientMethod } from '../../types';
|
|
3
|
+
import type { ClientMethod } from '../../types';
|
|
4
4
|
|
|
5
5
|
export type SupportedApiVersion = Extract<keyof typeof ApiVersion, 'v4'>;
|
|
6
6
|
|
|
7
7
|
type ApiRequestArgsMap = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
[ApiVersion.v4]: {
|
|
9
|
+
azureId: string;
|
|
10
|
+
expand?: Array<ApiPersonExpandProps_v4>;
|
|
11
|
+
};
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export type AllowedArgs = ApiRequestArgsMap[keyof ApiRequestArgsMap];
|
|
15
15
|
|
|
16
16
|
export type ApiRequestArgs<T extends SupportedApiVersion> =
|
|
17
|
-
|
|
17
|
+
ApiRequestArgsMap[(typeof ApiVersion)[T]];
|
|
18
18
|
|
|
19
19
|
type ApiResponseTypes<TArgs extends AllowedArgs> = {
|
|
20
|
-
|
|
20
|
+
[ApiVersion.v4]: ApiPerson_v4<TArgs['expand'] extends [] ? TArgs['expand'] : []>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type ApiResponse<
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
T extends SupportedApiVersion,
|
|
25
|
+
TArgs extends AllowedArgs,
|
|
26
26
|
> = ApiResponseTypes<TArgs>[(typeof ApiVersion)[T]];
|
|
27
27
|
|
|
28
28
|
export type ApiResult<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
TVersion extends SupportedApiVersion,
|
|
30
|
+
TArgs extends ApiRequestArgs<TVersion>,
|
|
31
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
32
|
+
TResult = ApiResponse<TVersion, TArgs>,
|
|
33
33
|
> = ClientMethod<TResult>[TMethod];
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ClientRequestInit,
|
|
3
|
-
type IHttpClient,
|
|
4
|
-
} from '@equinor/fusion-framework-module-http/client';
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
5
2
|
|
|
6
3
|
import { generateParameters } from './generate-parameters';
|
|
7
4
|
|
|
@@ -15,23 +12,23 @@ import type { ApiResponse, ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
15
12
|
* @param method - client method to call
|
|
16
13
|
*/
|
|
17
14
|
export const client =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
<
|
|
16
|
+
TVersion extends SupportedApiVersion,
|
|
17
|
+
TMethod extends keyof ClientDataMethod = keyof ClientDataMethod,
|
|
18
|
+
TClient extends IHttpClient = IHttpClient,
|
|
19
|
+
TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>,
|
|
20
|
+
>(
|
|
21
|
+
client: TClient,
|
|
22
|
+
version: TVersion,
|
|
23
|
+
method: TMethod = 'blob' as TMethod,
|
|
24
|
+
) =>
|
|
25
|
+
<T extends ApiResponse<TVersion> = ApiResponse<TVersion>>(
|
|
26
|
+
args: TArgs,
|
|
27
|
+
init?: ClientRequestInit<TClient, T>,
|
|
28
|
+
): ClientDataMethod<T>[TMethod] => {
|
|
29
|
+
return client[method](
|
|
30
|
+
...generateParameters<T, TVersion, TClient>(version, args, init),
|
|
31
|
+
) as ClientDataMethod<T>[TMethod];
|
|
32
|
+
};
|
|
36
33
|
|
|
37
34
|
export default client;
|
|
@@ -7,19 +7,19 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
* Method for generating endpoint for getting context by id
|
|
8
8
|
*/
|
|
9
9
|
export const generateEndpoint = <TVersion extends SupportedApiVersion>(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
version: TVersion,
|
|
11
|
+
args: ApiRequestArgs<TVersion>,
|
|
12
12
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
default: {
|
|
22
|
-
throw new UnsupportedApiVersion(version);
|
|
23
|
-
}
|
|
13
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
14
|
+
switch (apiVersion) {
|
|
15
|
+
case ApiVersion.v2: {
|
|
16
|
+
const { azureId } = args;
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
params.append('api-version', apiVersion);
|
|
19
|
+
return `/persons/${azureId}/photo?${String(params)}`;
|
|
24
20
|
}
|
|
21
|
+
default: {
|
|
22
|
+
throw new UnsupportedApiVersion(version);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
25
|
};
|
|
@@ -7,16 +7,16 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
|
|
8
8
|
/** function for creating http client arguments */
|
|
9
9
|
export const generateParameters = <
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends SupportedApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient,
|
|
13
13
|
>(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: ApiRequestArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>,
|
|
17
17
|
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
return [path, init];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export default generateParameters;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { BlobResult } from '@equinor/fusion-framework-module-http/client';
|
|
1
|
+
import type { BlobResult } from '@equinor/fusion-framework-module-http/client';
|
|
2
2
|
import { ApiVersion } from '../static';
|
|
3
|
-
import { ClientDataMethod } from '../../types';
|
|
3
|
+
import type { ClientDataMethod } from '../../types';
|
|
4
4
|
|
|
5
5
|
export type SupportedApiVersion = Extract<keyof typeof ApiVersion, 'v2'>;
|
|
6
6
|
|
|
7
7
|
type ApiRequestArgsMap = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
[ApiVersion.v2]: {
|
|
9
|
+
azureId: string;
|
|
10
|
+
};
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export type AllowedArgs = ApiRequestArgsMap[keyof ApiRequestArgsMap];
|
|
14
14
|
|
|
15
15
|
export type ApiRequestArgs<T extends SupportedApiVersion> =
|
|
16
|
-
|
|
16
|
+
ApiRequestArgsMap[(typeof ApiVersion)[T]];
|
|
17
17
|
|
|
18
18
|
type ApiResponseTypes = {
|
|
19
|
-
|
|
19
|
+
[ApiVersion.v2]: BlobResult;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type ApiResponse<T extends SupportedApiVersion> = ApiResponseTypes[(typeof ApiVersion)[T]];
|
|
23
23
|
|
|
24
24
|
export type ApiResult<TMethod extends keyof ClientDataMethod = keyof ClientDataMethod> =
|
|
25
|
-
|
|
25
|
+
ClientDataMethod[TMethod];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
1
|
+
import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
|
|
2
2
|
|
|
3
3
|
import { generateParameters } from './generate-parameters';
|
|
4
4
|
|
|
@@ -12,22 +12,24 @@ import type { ApiResponse, ApiResult, ApiRequestArgs, SupportedApiVersion } from
|
|
|
12
12
|
* @param method - client method to call
|
|
13
13
|
*/
|
|
14
14
|
export const client =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
<
|
|
16
|
+
TVersion extends SupportedApiVersion,
|
|
17
|
+
TMethod extends keyof ClientMethod = keyof ClientMethod,
|
|
18
|
+
TClient extends IHttpClient = IHttpClient,
|
|
19
|
+
TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>,
|
|
20
|
+
>(
|
|
21
|
+
client: TClient,
|
|
22
|
+
version: TVersion,
|
|
23
|
+
method: TMethod = 'json' as TMethod,
|
|
24
|
+
) =>
|
|
25
|
+
<T = ApiResponse<TVersion>>(
|
|
26
|
+
args: TArgs,
|
|
27
|
+
init?: ClientRequestInit<TClient, T>,
|
|
28
|
+
): ApiResult<TVersion, TMethod, T> =>
|
|
29
|
+
client[method](...generateParameters<T, TVersion, TClient>(version, args, init)) as ApiResult<
|
|
30
|
+
TVersion,
|
|
31
|
+
TMethod,
|
|
32
|
+
T
|
|
33
|
+
>;
|
|
32
34
|
|
|
33
35
|
export default client;
|
|
@@ -7,20 +7,20 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
* Method for generating endpoint for getting context by id
|
|
8
8
|
*/
|
|
9
9
|
export const generateEndpoint = <TVersion extends SupportedApiVersion>(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
version: TVersion,
|
|
11
|
+
args: ApiRequestArgs<TVersion>,
|
|
12
12
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
default: {
|
|
23
|
-
throw new UnsupportedApiVersion(version);
|
|
24
|
-
}
|
|
13
|
+
const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
|
|
14
|
+
switch (apiVersion) {
|
|
15
|
+
case ApiVersion.v2: {
|
|
16
|
+
const { search } = args;
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
params.append('api-version', apiVersion);
|
|
19
|
+
params.append('$search', search);
|
|
20
|
+
return `/persons?${String(params)}`;
|
|
25
21
|
}
|
|
22
|
+
default: {
|
|
23
|
+
throw new UnsupportedApiVersion(version);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
26
|
};
|
|
@@ -7,16 +7,16 @@ import type { ApiRequestArgs, SupportedApiVersion } from './types';
|
|
|
7
7
|
|
|
8
8
|
/** function for creating http client arguments */
|
|
9
9
|
export const generateParameters = <
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
TResult,
|
|
11
|
+
TVersion extends SupportedApiVersion,
|
|
12
|
+
TClient extends IHttpClient = IHttpClient,
|
|
13
13
|
>(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
version: TVersion,
|
|
15
|
+
args: ApiRequestArgs<TVersion>,
|
|
16
|
+
init?: ClientRequestInit<TClient, TResult>,
|
|
17
17
|
): ApiClientArguments<TClient, TResult> => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const path = generateEndpoint(version, args);
|
|
19
|
+
return [path, init];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export default generateParameters;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { ApiVersion } from '../static';
|
|
2
|
-
import { ApiPerson_v2 } from '../api-models.v2';
|
|
3
|
-
import { ClientMethod } from '../../types';
|
|
2
|
+
import type { ApiPerson_v2 } from '../api-models.v2';
|
|
3
|
+
import type { ClientMethod } from '../../types';
|
|
4
4
|
|
|
5
5
|
export type SupportedApiVersion = Extract<keyof typeof ApiVersion, 'v2'>;
|
|
6
6
|
|
|
7
7
|
type ApiRequestArgsMap = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
[ApiVersion.v2]: {
|
|
9
|
+
search: string;
|
|
10
|
+
};
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export type AllowedArgs = ApiRequestArgsMap[keyof ApiRequestArgsMap];
|
|
14
14
|
|
|
15
15
|
export type ApiRequestArgs<T extends SupportedApiVersion> =
|
|
16
|
-
|
|
16
|
+
ApiRequestArgsMap[(typeof ApiVersion)[T]];
|
|
17
17
|
|
|
18
18
|
type ApiResponseTypes = {
|
|
19
|
-
|
|
19
|
+
[ApiVersion.v2]: Array<ApiPerson_v2>;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type ApiResponse<T extends SupportedApiVersion> = ApiResponseTypes[(typeof ApiVersion)[T]];
|
|
23
23
|
|
|
24
24
|
export type ApiResult<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
TVersion extends SupportedApiVersion,
|
|
26
|
+
TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
|
|
27
|
+
TResult = ApiResponse<TVersion>,
|
|
28
28
|
> = ClientMethod<TResult>[TMethod];
|
package/src/people/static.ts
CHANGED
package/src/people/utils.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { ApiPerson } from './api-models';
|
|
1
|
+
import type { ApiPerson } from './api-models';
|
|
2
2
|
import { ApiVersion } from './static';
|
|
3
3
|
|
|
4
4
|
// type SupportedApiVersion = Extract<keyof typeof ApiVersion, 'v2' | 'v4'>;
|
|
5
5
|
|
|
6
6
|
const requiredApiPersonAttributes = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
[ApiVersion.v2]: [
|
|
8
|
+
'azureUniqueId',
|
|
9
|
+
/** TODO - has to be more required attributes to identify V2??? */
|
|
10
|
+
] satisfies Array<keyof ApiPerson<'v2'>>,
|
|
11
|
+
[ApiVersion.v4]: [
|
|
12
|
+
/** TODO - has to be more required attributes to identify V4??? */
|
|
13
|
+
'azureUniqueId',
|
|
14
|
+
] satisfies Array<keyof ApiPerson<'v4'>>,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const isApiPerson = <V extends keyof typeof ApiVersion>(version: V) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
/** todo add options for more strict check */
|
|
19
|
+
return <T>(value: T): value is T extends ApiPerson<V> ? T : never => {
|
|
20
|
+
/** early escape if value is not defined or not a object */
|
|
21
|
+
if (typeof value !== 'object') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const attr = Object.keys(value as object);
|
|
25
|
+
const requiredAttr = requiredApiPersonAttributes[ApiVersion[version]];
|
|
26
|
+
const result = requiredAttr.every((key) => attr.includes(key));
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
29
|
};
|