@equinor/fusion-framework-module-services 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/esm/context/index.js.map +1 -1
  3. package/dist/esm/context/query/generate-endpoint.js +58 -12
  4. package/dist/esm/context/query/generate-endpoint.js.map +1 -1
  5. package/dist/esm/context/related/generate-endpoint.js +56 -12
  6. package/dist/esm/context/related/generate-endpoint.js.map +1 -1
  7. package/dist/esm/version.js +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/dist/types/context/get/client.d.ts +2 -1
  10. package/dist/types/context/get/generate-endpoint.d.ts +2 -1
  11. package/dist/types/context/get/generate-parameters.d.ts +2 -1
  12. package/dist/types/context/index.d.ts +1 -0
  13. package/dist/types/context/query/client.d.ts +2 -1
  14. package/dist/types/context/query/generate-endpoint.d.ts +11 -1
  15. package/dist/types/context/query/generate-parameters.d.ts +2 -1
  16. package/dist/types/context/related/client.d.ts +2 -1
  17. package/dist/types/context/related/generate-endpoint.d.ts +11 -1
  18. package/dist/types/context/related/generate-parameters.d.ts +2 -1
  19. package/dist/types/notification/notification/delete/client.d.ts +2 -1
  20. package/dist/types/notification/notification/delete/generate-endpoint.d.ts +2 -1
  21. package/dist/types/notification/notification/delete/generate-parameters.d.ts +2 -1
  22. package/dist/types/notification/notification/get/client.d.ts +2 -1
  23. package/dist/types/notification/notification/get/generate-endpoint.d.ts +2 -1
  24. package/dist/types/notification/notification/get/generate-parameters.d.ts +2 -1
  25. package/dist/types/notification/notification/getAll/client.d.ts +2 -1
  26. package/dist/types/notification/notification/getAll/generate-endpoint.d.ts +2 -1
  27. package/dist/types/notification/notification/getAll/generate-parameters.d.ts +2 -1
  28. package/dist/types/notification/notification/patch/client.d.ts +2 -1
  29. package/dist/types/notification/notification/patch/generate-endpoint.d.ts +2 -1
  30. package/dist/types/notification/notification/patch/generate-parameters.d.ts +2 -1
  31. package/dist/types/notification/notification/post/client.d.ts +2 -1
  32. package/dist/types/notification/notification/post/generate-endpoint.d.ts +2 -1
  33. package/dist/types/notification/notification/post/generate-parameters.d.ts +2 -1
  34. package/dist/types/notification/settings/get/client.d.ts +2 -1
  35. package/dist/types/notification/settings/get/generate-endpoint.d.ts +2 -1
  36. package/dist/types/notification/settings/get/generate-parameters.d.ts +2 -1
  37. package/dist/types/notification/settings/put/client.d.ts +2 -1
  38. package/dist/types/notification/settings/put/generate-endpoint.d.ts +2 -1
  39. package/dist/types/notification/settings/put/generate-parameters.d.ts +2 -1
  40. package/dist/types/people/person-details/client.d.ts +1 -1
  41. package/dist/types/people/person-details/generate-parameters.d.ts +1 -1
  42. package/dist/types/people/person-photo/client.d.ts +1 -1
  43. package/dist/types/people/person-photo/generate-parameters.d.ts +1 -1
  44. package/dist/types/people/query/client.d.ts +1 -1
  45. package/dist/types/people/query/generate-parameters.d.ts +1 -1
  46. package/dist/types/version.d.ts +1 -1
  47. package/package.json +11 -7
  48. package/src/context/index.ts +2 -0
  49. package/src/context/query/generate-endpoint.ts +76 -27
  50. package/src/context/related/generate-endpoint.ts +74 -26
  51. package/src/version.ts +1 -1
  52. package/tests/context.test.ts +109 -0
  53. package/tests/mocks/get-context-item.ts +60 -0
  54. package/tests/mocks/index.ts +1 -0
  55. package/tests/setup.ts +73 -0
  56. package/tsconfig.json +4 -3
  57. package/vitest.config.ts +11 -0
@@ -1,4 +1,5 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { ClientMethod, GetContextArgs, GetContextResponse, GetContextResult } from './types';
3
4
  /**
4
5
  * Method for fetching context item from context service
@@ -6,5 +7,5 @@ import type { ClientMethod, GetContextArgs, GetContextResponse, GetContextResult
6
7
  * @param version - version of API to call
7
8
  * @param method - client method to call
8
9
  */
9
- export declare const getContext: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = GetContextResponse<TVersion>>(args: GetContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetContextResult<TVersion, TMethod, T>;
10
+ export declare const getContext: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = GetContextResponse<TVersion>>(args: GetContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetContextResult<TVersion, TMethod, T>;
10
11
  export default getContext;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '..';
1
2
  import type { GetContextArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting context by id
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: GetContextArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: GetContextArgs<TVersion>) => string;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { ApiClientArguments, GetContextArgs } from './types';
3
4
  /** function for creating http client arguments */
4
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: GetContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: GetContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
6
  export default generateParameters;
@@ -1,4 +1,5 @@
1
1
  export { ContextApiClient, default } from './client';
2
2
  export { ApiVersion } from './static';
3
+ export { ApiContextEntity } from './api-models';
3
4
  export * from './api-models';
4
5
  export * from './types';
@@ -1,7 +1,8 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { QueryContextArgs, QueryContextResponse, QueryContextResult, ClientMethod } from './types';
3
4
  /**
4
5
  * Function for querying the context service
5
6
  */
6
- export declare const queryContext: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = QueryContextResponse<TVersion>>(args: QueryContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => QueryContextResult<TVersion, TMethod, T>;
7
+ export declare const queryContext: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = QueryContextResponse<TVersion>>(args: QueryContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => QueryContextResult<TVersion, TMethod, T>;
7
8
  export default queryContext;
@@ -1,3 +1,13 @@
1
+ import { ApiVersion } from '..';
1
2
  import type { QueryContextArgs } from './types';
2
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: QueryContextArgs<TVersion>) => string;
3
+ /**
4
+ * Generates an endpoint URL based on the provided API version and query context arguments.
5
+ *
6
+ * @template TVersion - The type of the API version, defaults to the keys of `ApiVersion`.
7
+ * @param version - The API version to use for generating the endpoint.
8
+ * @param args - The query context arguments specific to the provided API version.
9
+ * @returns The generated endpoint URL as a string.
10
+ * @throws {UnsupportedApiVersion} If the provided API version is not supported.
11
+ */
12
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: QueryContextArgs<TVersion>) => string;
3
13
  export default generateEndpoint;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { QueryContextArgs, ApiClientArguments } from './types';
3
4
  /** Function for generating parameter for querying context service */
4
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: QueryContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: QueryContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
6
  export default generateParameters;
@@ -1,7 +1,8 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { RelatedContextArgs, RelatedContextResponse, RelatedContextResult, ClientMethod } from './types';
3
4
  /**
4
5
  * Function for querying the context service
5
6
  */
6
- export declare const relatedContexts: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = RelatedContextResponse<TVersion>>(args: RelatedContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => RelatedContextResult<TVersion, TMethod, T>;
7
+ export declare const relatedContexts: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = RelatedContextResponse<TVersion>>(args: RelatedContextArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => RelatedContextResult<TVersion, TMethod, T>;
7
8
  export default relatedContexts;
@@ -1,3 +1,13 @@
1
+ import { ApiVersion } from '..';
1
2
  import type { RelatedContextArgs } from './types';
2
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: RelatedContextArgs<TVersion>) => string;
3
+ /**
4
+ * Generates an endpoint URL based on the provided API version and arguments.
5
+ *
6
+ * @template TVersion - The type of the API version, defaults to the keys of `ApiVersion`.
7
+ * @param version - The API version to use for generating the endpoint.
8
+ * @param args - The arguments required to generate the endpoint, including `id` and `query`.
9
+ * @returns The generated endpoint URL as a string.
10
+ * @throws {UnsupportedApiVersion} If the provided API version is not supported.
11
+ */
12
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: RelatedContextArgs<TVersion>) => string;
3
13
  export default generateEndpoint;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '..';
2
3
  import type { RelatedContextArgs, ApiClientArguments } from './types';
3
4
  /** Function for generating parameter for querying context service */
4
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: RelatedContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: RelatedContextArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
6
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { DeleteNotificationArgs, DeleteNotificationResponse, DeleteNotificationResult } from './types';
4
5
  /**
5
6
  * Method for deleting notification item from notifications service
@@ -7,5 +8,5 @@ import type { DeleteNotificationArgs, DeleteNotificationResponse, DeleteNotifica
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const deleteNotification: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = DeleteNotificationResponse<TVersion>>(args: DeleteNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => DeleteNotificationResult<TVersion, TMethod, T>;
11
+ export declare const deleteNotification: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = DeleteNotificationResponse<TVersion>>(args: DeleteNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => DeleteNotificationResult<TVersion, TMethod, T>;
11
12
  export default deleteNotification;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { DeleteNotificationArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting notification by id
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: DeleteNotificationArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: DeleteNotificationArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { DeleteNotificationArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: DeleteNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: DeleteNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { GetNotificationArgs, GetNotificationResult, GetNotificationResponse } from './types';
4
5
  /**
5
6
  * Method for fetching a notification item from notifications service
@@ -7,5 +8,5 @@ import type { GetNotificationArgs, GetNotificationResult, GetNotificationRespons
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const getNotificationById: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = GetNotificationResponse<TVersion>>(args: GetNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetNotificationResult<TVersion, TMethod, T>;
11
+ export declare const getNotificationById: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = GetNotificationResponse<TVersion>>(args: GetNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetNotificationResult<TVersion, TMethod, T>;
11
12
  export default getNotificationById;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { GetNotificationArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting notification by id
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: GetNotificationArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: GetNotificationArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { GetNotificationArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: GetNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: GetNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { GetNotificationsArgs, GetNotificationsResult, GetNotificationsResponse } from './types';
4
5
  /**
5
6
  * Method for fetching all notifications item from notification service
@@ -7,5 +8,5 @@ import type { GetNotificationsArgs, GetNotificationsResult, GetNotificationsResp
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const getNotifications: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = GetNotificationsResponse<TVersion>>(args: GetNotificationsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetNotificationsResult<TVersion, TMethod, T>;
11
+ export declare const getNotifications: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = GetNotificationsResponse<TVersion>>(args: GetNotificationsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetNotificationsResult<TVersion, TMethod, T>;
11
12
  export default getNotifications;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { GetNotificationsArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting all notifications
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: GetNotificationsArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: GetNotificationsArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { GetNotificationsArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: GetNotificationsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: GetNotificationsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { PatchNotificationArgs, PatchNotificationResponse, PatchNotificationResult } from './types';
4
5
  /**
5
6
  * Method for updating a notification item
@@ -7,5 +8,5 @@ import type { PatchNotificationArgs, PatchNotificationResponse, PatchNotificatio
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const updateSeenByUser: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = PatchNotificationResponse<TVersion>>(args: PatchNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PatchNotificationResult<TVersion, TMethod, T>;
11
+ export declare const updateSeenByUser: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = PatchNotificationResponse<TVersion>>(args: PatchNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PatchNotificationResult<TVersion, TMethod, T>;
11
12
  export default updateSeenByUser;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { PatchNotificationArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting notification by id
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: PatchNotificationArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: PatchNotificationArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { PatchNotificationArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: PatchNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: PatchNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { PostNotificationArgs, PostNotificationResult, PostNotificationResponse } from './types';
4
5
  /**
5
6
  * Method for creating a notification item
@@ -7,5 +8,5 @@ import type { PostNotificationArgs, PostNotificationResult, PostNotificationResp
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const createNotification: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = PostNotificationResponse<TVersion>>(args: PostNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PostNotificationResult<TVersion, TMethod, T>;
11
+ export declare const createNotification: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = PostNotificationResponse<TVersion>>(args: PostNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PostNotificationResult<TVersion, TMethod, T>;
11
12
  export default createNotification;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { PostNotificationArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting all notifications
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: PostNotificationArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: PostNotificationArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { PostNotificationArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: PostNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: PostNotificationArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { GetUserNotificationSettingsArgs, GetUserNotificationsSettingsResult, GetUserNotificationSettingsResponse } from './types';
4
5
  /**
5
6
  * Method for fetching user notification settings from the notifications service
@@ -7,5 +8,5 @@ import type { GetUserNotificationSettingsArgs, GetUserNotificationsSettingsResul
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const getUserNotificationSettings: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = GetUserNotificationSettingsResponse<TVersion>>(args: GetUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetUserNotificationsSettingsResult<TVersion, TMethod, T>;
11
+ export declare const getUserNotificationSettings: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = GetUserNotificationSettingsResponse<TVersion>>(args: GetUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => GetUserNotificationsSettingsResult<TVersion, TMethod, T>;
11
12
  export default getUserNotificationSettings;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { GetUserNotificationSettingsArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting all notifications
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: GetUserNotificationSettingsArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: GetUserNotificationSettingsArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { GetUserNotificationSettingsArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: GetUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: GetUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -1,5 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
  import type { ClientMethod } from '../../../types';
3
+ import type { ApiVersion } from '../../static';
3
4
  import type { PutUserNotificationSettingsArgs, PutUserNotificationSettingsResult, PutUserNotificationSettingsResponse } from './types';
4
5
  /**
5
6
  * Method for fetching user notification settings from the notifications service
@@ -7,5 +8,5 @@ import type { PutUserNotificationSettingsArgs, PutUserNotificationSettingsResult
7
8
  * @param version - version of API to call
8
9
  * @param method - client method to call
9
10
  */
10
- export declare const updateUserNotificationSettings: <TVersion extends string = "v1" | "v2", TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(client: TClient, version: TVersion, method?: TMethod) => <T = PutUserNotificationSettingsResponse<TVersion>>(args: PutUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PutUserNotificationSettingsResult<TVersion, TMethod, T>;
11
+ export declare const updateUserNotificationSettings: <TVersion extends string = keyof typeof ApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient>(client: TClient, version: TVersion, method?: TMethod) => <T = PutUserNotificationSettingsResponse<TVersion>>(args: PutUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, T>) => PutUserNotificationSettingsResult<TVersion, TMethod, T>;
11
12
  export default updateUserNotificationSettings;
@@ -1,5 +1,6 @@
1
+ import { ApiVersion } from '../..';
1
2
  import type { PutUserNotificationSettingsArgs } from './types';
2
3
  /**
3
4
  * Method for generating endpoint for getting all notifications
4
5
  */
5
- export declare const generateEndpoint: <TVersion extends string = "v1" | "v2">(version: TVersion, args: PutUserNotificationSettingsArgs<TVersion>) => string;
6
+ export declare const generateEndpoint: <TVersion extends string = keyof typeof ApiVersion>(version: TVersion, args: PutUserNotificationSettingsArgs<TVersion>) => string;
@@ -1,6 +1,7 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import type { ApiVersion } from '../../static';
2
3
  import type { ApiClientArguments } from '../../types';
3
4
  import type { PutUserNotificationSettingsArgs } from './types';
4
5
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends string = "v1" | "v2", TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: PutUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
+ export declare const generateParameters: <TResult, TVersion extends string = keyof typeof ApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: PutUserNotificationSettingsArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
7
  export default generateParameters;
@@ -7,5 +7,5 @@ import type { ApiResponse, ApiResult, ApiRequestArgs, SupportedApiVersion } from
7
7
  * @param version - version of API to call
8
8
  * @param method - client method to call
9
9
  */
10
- export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T = ApiResponse<TVersion, TArgs>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ApiResult<TVersion, TArgs, TMethod, T>;
10
+ export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T = ApiResponse<TVersion, TArgs>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ApiResult<TVersion, TArgs, TMethod, T>;
11
11
  export default client;
@@ -2,5 +2,5 @@ import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-m
2
2
  import type { ApiClientArguments } from '../../types';
3
3
  import type { ApiRequestArgs, SupportedApiVersion } from './types';
4
4
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
6
  export default generateParameters;
@@ -7,5 +7,5 @@ import type { ApiResponse, ApiRequestArgs, SupportedApiVersion } from './types';
7
7
  * @param version - version of API to call
8
8
  * @param method - client method to call
9
9
  */
10
- export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientDataMethod = keyof ClientDataMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T extends ApiResponse<TVersion> = ApiResponse<TVersion>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ClientDataMethod<T>[TMethod];
10
+ export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientDataMethod = keyof ClientDataMethod, TClient extends IHttpClient = IHttpClient, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T extends ApiResponse<TVersion> = ApiResponse<TVersion>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ClientDataMethod<T>[TMethod];
11
11
  export default client;
@@ -2,5 +2,5 @@ import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-m
2
2
  import type { ApiClientArguments } from '../../types';
3
3
  import type { ApiRequestArgs, SupportedApiVersion } from './types';
4
4
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
6
  export default generateParameters;
@@ -7,5 +7,5 @@ import type { ApiResponse, ApiResult, ApiRequestArgs, SupportedApiVersion } from
7
7
  * @param version - version of API to call
8
8
  * @param method - client method to call
9
9
  */
10
- export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T = ApiResponse<TVersion>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ApiResult<TVersion, TMethod, T>;
10
+ export declare const client: <TVersion extends SupportedApiVersion, TMethod extends keyof ClientMethod = keyof ClientMethod, TClient extends IHttpClient = IHttpClient, TArgs extends ApiRequestArgs<TVersion> = ApiRequestArgs<TVersion>>(client: TClient, version: TVersion, method?: TMethod) => <T = ApiResponse<TVersion>>(args: TArgs, init?: ClientRequestInit<TClient, T>) => ApiResult<TVersion, TMethod, T>;
11
11
  export default client;
@@ -2,5 +2,5 @@ import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-m
2
2
  import type { ApiClientArguments } from '../../types';
3
3
  import type { ApiRequestArgs, SupportedApiVersion } from './types';
4
4
  /** function for creating http client arguments */
5
- export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient<import("@equinor/fusion-framework-module-http/client").FetchRequest, Response>>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
5
+ export declare const generateParameters: <TResult, TVersion extends SupportedApiVersion, TClient extends IHttpClient = IHttpClient>(version: TVersion, args: ApiRequestArgs<TVersion>, init?: ClientRequestInit<TClient, TResult>) => ApiClientArguments<TClient, TResult>;
6
6
  export default generateParameters;
@@ -1 +1 @@
1
- export declare const version = "5.1.1";
1
+ export declare const version = "5.1.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-services",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",
@@ -116,16 +116,20 @@
116
116
  "zod": "^3.23.8"
117
117
  },
118
118
  "devDependencies": {
119
- "typescript": "^5.5.4",
120
- "@equinor/fusion-framework-module": "^4.3.6",
121
- "@equinor/fusion-framework-module-http": "^6.2.2",
122
- "@equinor/fusion-framework-module-service-discovery": "^8.0.7"
119
+ "@faker-js/faker": "^9.5.1",
120
+ "msw": "^2.7.3",
121
+ "typescript": "^5.8.2",
122
+ "vitest": "^2.0.5",
123
+ "@equinor/fusion-framework-module": "^4.3.7",
124
+ "@equinor/fusion-framework-module-http": "^6.2.3",
125
+ "@equinor/fusion-framework-module-service-discovery": "^8.0.8"
123
126
  },
124
127
  "peerDependencies": {
125
128
  "odata-query": "^7.0.4",
126
- "@equinor/fusion-framework-module": "^4.3.6"
129
+ "@equinor/fusion-framework-module": "^4.3.7"
127
130
  },
128
131
  "scripts": {
129
- "build": "tsc -b"
132
+ "build": "tsc -b",
133
+ "test": "vitest"
130
134
  }
131
135
  }
@@ -2,5 +2,7 @@ export { ContextApiClient, default } from './client';
2
2
 
3
3
  export { ApiVersion } from './static';
4
4
 
5
+ export { ApiContextEntity } from './api-models';
6
+
5
7
  export * from './api-models';
6
8
  export * from './types';
@@ -10,39 +10,88 @@ import type {
10
10
  QueryContextOdataParameters,
11
11
  } from './types';
12
12
 
13
- const buildOdataFilter = (filterObj: QueryContextOdataFilter) => {
14
- return Object.keys(filterObj).reduce((acc, key) => {
15
- switch (key) {
16
- case 'type':
17
- return filterObj[key]?.length ? { ...acc, [key]: { in: filterObj[key] } } : acc;
18
- default:
19
- return { ...acc, [key]: filterObj[key as keyof typeof filterObj] };
20
- }
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- }, {} as any);
23
- };
24
-
25
- const buildOdataObject = (parameters: QueryContextOdataParameters) => {
26
- return Object.entries(parameters)
27
- .filter(([_, value]) => !!value)
28
- .reduce((acc, [key, value]) => {
13
+ /**
14
+ * Builds an OData filter object from the given filter object.
15
+ *
16
+ * This function takes a `QueryContextOdataFilter` object and transforms it into an OData filter object.
17
+ * It iterates over the keys of the input object and processes each key according to specific rules.
18
+ *
19
+ * @param filterObj - The filter object to be transformed into an OData filter.
20
+ * @returns A record representing the OData filter.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const filterObj = { type: ['exampleType'], otherKey: 'value' };
25
+ * const odataFilter = buildOdataFilter(filterObj);
26
+ * // odataFilter will be { $filter: { in: ['exampleType'] }, otherKey: 'value' }
27
+ * ```
28
+ */
29
+ function buildOdataFilter(filterObj: QueryContextOdataFilter) {
30
+ return Object.keys(filterObj).reduce(
31
+ (acc, key) => {
29
32
  switch (key) {
30
- case 'filter':
31
- return {
32
- ...acc,
33
- [key]: buildOdataFilter(value as QueryContextOdataFilter),
34
- };
33
+ case 'type':
34
+ if (filterObj[key]?.length) {
35
+ acc[key] = { in: filterObj[key] };
36
+ }
37
+ break;
35
38
  default:
36
- return { ...acc, [key]: parameters[key as keyof typeof parameters] };
39
+ acc[key] = filterObj[key as keyof typeof filterObj];
40
+ break;
37
41
  }
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- }, {} as any);
40
- };
42
+ return acc;
43
+ },
44
+ {} as Record<string, unknown>,
45
+ );
46
+ }
41
47
 
42
- const createSearchParameters = (args: string | QueryContextOdataParameters) => {
48
+ /**
49
+ * Builds an OData object from the given query context parameters.
50
+ *
51
+ * This function processes the provided parameters, filters out any entries with falsy values,
52
+ * and constructs an OData object. It handles specific keys, such as 'filter', with custom logic.
53
+ *
54
+ * @param parameters - The query context parameters to be converted into an OData object.
55
+ * @returns An OData object constructed from the provided parameters.
56
+ */
57
+ function buildOdataObject(parameters: QueryContextOdataParameters) {
58
+ return Object.entries(parameters)
59
+ .filter(([_, value]) => !!value)
60
+ .reduce(
61
+ (acc, [key, value]) => {
62
+ switch (key) {
63
+ case 'filter':
64
+ acc[key] = buildOdataFilter(value as QueryContextOdataFilter);
65
+ break;
66
+ default:
67
+ acc[key] = parameters[key as keyof typeof parameters];
68
+ break;
69
+ }
70
+ return acc;
71
+ },
72
+ {} as Record<string, unknown>,
73
+ );
74
+ }
75
+
76
+ /**
77
+ * Creates search parameters based on the provided arguments.
78
+ *
79
+ * @param args - A string or an object containing OData query parameters.
80
+ * @returns A string representing the search parameters.
81
+ */
82
+ function createSearchParameters(args: string | QueryContextOdataParameters) {
43
83
  return typeof args === 'string' ? args : buildOdataQuery(buildOdataObject(args));
44
- };
84
+ }
45
85
 
86
+ /**
87
+ * Generates an endpoint URL based on the provided API version and query context arguments.
88
+ *
89
+ * @template TVersion - The type of the API version, defaults to the keys of `ApiVersion`.
90
+ * @param version - The API version to use for generating the endpoint.
91
+ * @param args - The query context arguments specific to the provided API version.
92
+ * @returns The generated endpoint URL as a string.
93
+ * @throws {UnsupportedApiVersion} If the provided API version is not supported.
94
+ */
46
95
  export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
47
96
  version: TVersion,
48
97
  args: QueryContextArgs<TVersion>,