@equinor/fusion-framework-module-services 7.2.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +24 -16
  2. package/README.md +125 -0
  3. package/dist/esm/bookmarks/api-version.js +3 -0
  4. package/dist/esm/bookmarks/api-version.js.map +1 -1
  5. package/dist/esm/bookmarks/index.js +13 -0
  6. package/dist/esm/bookmarks/index.js.map +1 -1
  7. package/dist/esm/bookmarks/schemas.js +10 -0
  8. package/dist/esm/bookmarks/schemas.js.map +1 -1
  9. package/dist/esm/bookmarks/types.js +5 -0
  10. package/dist/esm/bookmarks/types.js.map +1 -1
  11. package/dist/esm/configurator.js +7 -0
  12. package/dist/esm/configurator.js.map +1 -1
  13. package/dist/esm/context/client.js +32 -6
  14. package/dist/esm/context/client.js.map +1 -1
  15. package/dist/esm/context/get/client.js +9 -4
  16. package/dist/esm/context/get/client.js.map +1 -1
  17. package/dist/esm/context/index.js +13 -0
  18. package/dist/esm/context/index.js.map +1 -1
  19. package/dist/esm/context/query/client.js +9 -1
  20. package/dist/esm/context/query/client.js.map +1 -1
  21. package/dist/esm/context/related/client.js +9 -1
  22. package/dist/esm/context/related/client.js.map +1 -1
  23. package/dist/esm/context/static.js +3 -2
  24. package/dist/esm/context/static.js.map +1 -1
  25. package/dist/esm/errors.js +14 -0
  26. package/dist/esm/errors.js.map +1 -1
  27. package/dist/esm/index.js +14 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/module.js +39 -7
  30. package/dist/esm/module.js.map +1 -1
  31. package/dist/esm/notification/client.js +56 -14
  32. package/dist/esm/notification/client.js.map +1 -1
  33. package/dist/esm/notification/index.js +14 -0
  34. package/dist/esm/notification/index.js.map +1 -1
  35. package/dist/esm/notification/static.js +3 -2
  36. package/dist/esm/notification/static.js.map +1 -1
  37. package/dist/esm/people/client.js +58 -5
  38. package/dist/esm/people/client.js.map +1 -1
  39. package/dist/esm/people/index.js +13 -0
  40. package/dist/esm/people/index.js.map +1 -1
  41. package/dist/esm/people/person-details/client.js +10 -4
  42. package/dist/esm/people/person-details/client.js.map +1 -1
  43. package/dist/esm/people/person-photo/client.js +10 -4
  44. package/dist/esm/people/person-photo/client.js.map +1 -1
  45. package/dist/esm/people/query/client.js +10 -4
  46. package/dist/esm/people/query/client.js.map +1 -1
  47. package/dist/esm/people/static.js +3 -0
  48. package/dist/esm/people/static.js.map +1 -1
  49. package/dist/esm/people/utils.js +19 -0
  50. package/dist/esm/people/utils.js.map +1 -1
  51. package/dist/esm/provider.js +37 -2
  52. package/dist/esm/provider.js.map +1 -1
  53. package/dist/esm/utils.js +2 -11
  54. package/dist/esm/utils.js.map +1 -1
  55. package/dist/esm/version.js +1 -1
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/dist/types/bookmarks/api-version.d.ts +3 -0
  58. package/dist/types/bookmarks/index.d.ts +13 -0
  59. package/dist/types/bookmarks/schemas.d.ts +10 -0
  60. package/dist/types/bookmarks/types.d.ts +17 -0
  61. package/dist/types/configurator.d.ts +15 -1
  62. package/dist/types/context/api-models.d.ts +16 -0
  63. package/dist/types/context/client.d.ts +32 -6
  64. package/dist/types/context/get/client.d.ts +9 -4
  65. package/dist/types/context/get/types.d.ts +27 -0
  66. package/dist/types/context/index.d.ts +13 -0
  67. package/dist/types/context/query/client.d.ts +9 -1
  68. package/dist/types/context/query/types.d.ts +35 -0
  69. package/dist/types/context/related/client.d.ts +9 -1
  70. package/dist/types/context/related/types.d.ts +36 -0
  71. package/dist/types/context/static.d.ts +3 -2
  72. package/dist/types/errors.d.ts +14 -0
  73. package/dist/types/index.d.ts +14 -0
  74. package/dist/types/module.d.ts +41 -6
  75. package/dist/types/notification/api-models.d.ts +20 -1
  76. package/dist/types/notification/client.d.ts +56 -14
  77. package/dist/types/notification/index.d.ts +14 -0
  78. package/dist/types/notification/static.d.ts +3 -2
  79. package/dist/types/people/api-models.d.ts +26 -0
  80. package/dist/types/people/api-models.v2.d.ts +1 -0
  81. package/dist/types/people/api-models.v4.d.ts +24 -0
  82. package/dist/types/people/client.d.ts +58 -5
  83. package/dist/types/people/index.d.ts +13 -0
  84. package/dist/types/people/person-details/client.d.ts +10 -4
  85. package/dist/types/people/person-details/types.d.ts +21 -0
  86. package/dist/types/people/person-photo/client.d.ts +10 -4
  87. package/dist/types/people/person-photo/types.d.ts +17 -0
  88. package/dist/types/people/query/client.d.ts +10 -4
  89. package/dist/types/people/query/types.d.ts +19 -0
  90. package/dist/types/people/resolve/types.d.ts +7 -0
  91. package/dist/types/people/static.d.ts +3 -0
  92. package/dist/types/people/suggest/types.d.ts +7 -0
  93. package/dist/types/people/utils.d.ts +19 -0
  94. package/dist/types/provider.d.ts +69 -4
  95. package/dist/types/types.d.ts +40 -15
  96. package/dist/types/utils.d.ts +2 -11
  97. package/dist/types/version.d.ts +1 -1
  98. package/package.json +9 -9
  99. package/src/bookmarks/api-version.ts +3 -0
  100. package/src/bookmarks/index.ts +14 -0
  101. package/src/bookmarks/schemas.ts +10 -0
  102. package/src/bookmarks/types.ts +18 -0
  103. package/src/configurator.ts +15 -1
  104. package/src/context/api-models.ts +16 -0
  105. package/src/context/client.ts +32 -6
  106. package/src/context/get/client.ts +9 -4
  107. package/src/context/get/types.ts +27 -0
  108. package/src/context/index.ts +14 -0
  109. package/src/context/query/client.ts +9 -1
  110. package/src/context/query/types.ts +35 -0
  111. package/src/context/related/client.ts +9 -1
  112. package/src/context/related/types.ts +36 -0
  113. package/src/context/static.ts +3 -2
  114. package/src/errors.ts +14 -0
  115. package/src/index.ts +15 -0
  116. package/src/module.ts +47 -7
  117. package/src/notification/api-models.ts +20 -1
  118. package/src/notification/client.ts +56 -14
  119. package/src/notification/index.ts +15 -0
  120. package/src/notification/static.ts +3 -2
  121. package/src/people/api-models.ts +26 -1
  122. package/src/people/api-models.v2.ts +1 -0
  123. package/src/people/api-models.v4.ts +24 -0
  124. package/src/people/client.ts +58 -5
  125. package/src/people/index.ts +14 -0
  126. package/src/people/person-details/client.ts +10 -4
  127. package/src/people/person-details/types.ts +21 -0
  128. package/src/people/person-photo/client.ts +10 -4
  129. package/src/people/person-photo/types.ts +17 -0
  130. package/src/people/query/client.ts +10 -4
  131. package/src/people/query/types.ts +19 -0
  132. package/src/people/resolve/types.ts +7 -0
  133. package/src/people/static.ts +3 -0
  134. package/src/people/suggest/types.ts +7 -0
  135. package/src/people/utils.ts +19 -0
  136. package/src/provider.ts +79 -8
  137. package/src/types.ts +40 -15
  138. package/src/utils.ts +2 -11
  139. package/src/version.ts +1 -1
@@ -6,24 +6,51 @@ import { ContextApiClient } from './context';
6
6
  import BookmarksApiClient from './bookmarks/client';
7
7
  import { NotificationApiClient } from './notification';
8
8
  import { PeopleApiClient } from './people/client';
9
+ /**
10
+ * Public interface for the services module provider.
11
+ *
12
+ * Exposes factory methods for creating domain-specific API clients
13
+ * for bookmarks, context, notification, and people services.
14
+ * Each factory resolves a named HTTP client, attaches response
15
+ * validation, and returns a typed client instance.
16
+ *
17
+ * @template TClient - The underlying HTTP client type.
18
+ */
9
19
  export interface IApiProvider<TClient extends IHttpClient = IHttpClient> {
10
20
  /**
11
- * @param method - Version of the service to use
21
+ * Creates a typed client for the bookmarks API.
22
+ *
23
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
24
+ * @param method - The execution method to use for requests.
25
+ * @returns A configured {@link BookmarksApiClient} instance.
12
26
  */
13
27
  createBookmarksClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<BookmarksApiClient<TMethod, TClient>>;
14
28
  /**
15
- * @param method - Version of the service to use
29
+ * Creates a typed client for the context API.
30
+ *
31
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
32
+ * @param method - The execution method to use for requests.
33
+ * @returns A configured {@link ContextApiClient} instance.
16
34
  */
17
35
  createContextClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<ContextApiClient<TMethod, TClient>>;
18
36
  /**
19
- * @param method - Version of the service to use
37
+ * Creates a typed client for the notification API.
38
+ *
39
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
40
+ * @param method - The execution method to use for requests.
41
+ * @returns A configured {@link NotificationApiClient} instance.
20
42
  */
21
43
  createNotificationClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<NotificationApiClient<TMethod, TClient>>;
22
44
  /**
23
- * @param method - Version of the service to use
45
+ * Creates a typed client for the people API.
46
+ *
47
+ * @returns A configured {@link PeopleApiClient} instance.
24
48
  */
25
49
  createPeopleClient(): Promise<PeopleApiClient<TClient>>;
26
50
  }
51
+ /**
52
+ * Shape of the structured error response attached to an {@link ApiProviderError}.
53
+ */
27
54
  type ApiProviderErrorResponse = {
28
55
  type: ResponseType;
29
56
  status: number;
@@ -32,13 +59,51 @@ type ApiProviderErrorResponse = {
32
59
  url: string;
33
60
  data: unknown;
34
61
  };
62
+ /**
63
+ * Error thrown when an API response indicates a non-OK HTTP status.
64
+ *
65
+ * Contains the full {@link ApiProviderErrorResponse} (status, headers, body)
66
+ * so callers can inspect the failure details.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * try {
71
+ * await provider.createNotificationClient('json');
72
+ * } catch (err) {
73
+ * if (err instanceof ApiProviderError) {
74
+ * console.error(err.response.status, err.response.data);
75
+ * }
76
+ * }
77
+ * ```
78
+ */
35
79
  export declare class ApiProviderError extends Error {
80
+ /** Structured HTTP response data associated with this error. */
36
81
  readonly response: ApiProviderErrorResponse;
82
+ /**
83
+ * @param msg - Human-readable error message.
84
+ * @param response - The parsed HTTP response details.
85
+ * @param options - Standard `ErrorOptions` (e.g. `cause`).
86
+ */
37
87
  constructor(msg: string, response: ApiProviderErrorResponse, options?: ErrorOptions);
38
88
  }
89
+ /**
90
+ * Internal configuration shape for {@link ApiProvider}.
91
+ *
92
+ * @template TClient - The underlying HTTP client type.
93
+ */
39
94
  type ApiProviderConfig<TClient extends IHttpClient = IHttpClient> = {
40
95
  createClient: ApiClientFactory<TClient>;
41
96
  };
97
+ /**
98
+ * Default implementation of {@link IApiProvider}.
99
+ *
100
+ * Manages the lifecycle of domain-specific API clients (bookmarks, context,
101
+ * notification, people) by resolving named HTTP clients through the
102
+ * configured {@link ApiClientFactory} and attaching response-validation
103
+ * middleware.
104
+ *
105
+ * @template TClient - The underlying HTTP client type.
106
+ */
42
107
  export declare class ApiProvider<TClient extends IHttpClient = IHttpClient> extends BaseModuleProvider<ApiProviderConfig<TClient>> implements IApiProvider<TClient> {
43
108
  protected _createClientFn: ApiClientFactory<TClient>;
44
109
  constructor(config: ApiProviderConfig<TClient>);
@@ -1,40 +1,65 @@
1
1
  import type { ClientRequestInit, IHttpClient, StreamResponse, BlobResult } from '@equinor/fusion-framework-module-http/client';
2
2
  /**
3
- * A factory function that creates an instance of an HTTP client.
3
+ * Factory function that creates a named HTTP client instance.
4
4
  *
5
- * @param name - The name of the HTTP client to create.
6
- * @returns A Promise that resolves to an instance of the HTTP client.
5
+ * Used by {@link ApiProvider} to resolve service-specific HTTP clients
6
+ * (for example, `'bookmarks'`, `'context'`, `'notification'`, `'people'`).
7
+ * The factory first checks registered HTTP clients, then falls back to
8
+ * service discovery.
9
+ *
10
+ * @template TClient - The HTTP client type to create.
11
+ * @param name - Logical service name used to look up or create the HTTP client.
12
+ * @returns A Promise that resolves to a configured HTTP client instance.
7
13
  */
8
14
  export type ApiClientFactory<TClient extends IHttpClient = IHttpClient> = (name: string) => Promise<TClient>;
9
15
  /**
10
- * Represents the arguments for an API client function.
16
+ * Tuple type representing the positional arguments passed to an HTTP client method.
17
+ *
18
+ * Used internally by endpoint generators to build the `[path, init]` pair
19
+ * that the HTTP client's `json()` or `json$()` method expects.
11
20
  *
12
- * @template TClient - The type of the HTTP client used by the API client.
13
- * @template TResult - The type of the result returned by the API client.
14
- * @param path - The path of the API endpoint.
15
- * @param init - Optional initialization options for the API client request.
21
+ * @template TClient - The HTTP client type that will execute the request.
22
+ * @template TResult - The expected response body type.
16
23
  */
17
24
  export type ApiClientArguments<TClient extends IHttpClient, TResult = unknown> = [
18
25
  path: string,
19
26
  init?: ClientRequestInit<TClient, TResult>
20
27
  ];
21
28
  /**
22
- * Execute methods on the IHttpClient
29
+ * Maps HTTP client execution methods to their return types.
30
+ *
31
+ * - `json` — returns a `Promise` that resolves with the parsed JSON body.
32
+ * - `json$` — returns an RxJS-style `StreamResponse` observable.
33
+ *
34
+ * All versioned API client methods are generic over `ClientMethod`,
35
+ * allowing callers to choose between promise-based and observable-based
36
+ * consumption.
37
+ *
38
+ * @template T - The expected deserialized response body type.
23
39
  */
24
40
  export type ClientMethod<T = unknown> = {
25
- /**
26
- * Fetch JSON data from a service
27
- */
41
+ /** Fetch JSON data from a service as a promise. */
28
42
  json: Promise<T>;
29
- /**
30
- * Fetch JSON data from a service as observable
31
- */
43
+ /** Fetch JSON data from a service as an observable stream. */
32
44
  json$: StreamResponse<T>;
33
45
  };
46
+ /**
47
+ * Maps HTTP client binary-data execution methods to their return types.
48
+ *
49
+ * - `blob` — returns a `Promise` that resolves with the binary blob result.
50
+ * - `blob$` — returns an RxJS-style `StreamResponse` observable for the blob.
51
+ *
52
+ * Used by endpoints that return non-JSON data such as profile photos.
53
+ *
54
+ * @template T - The blob result type, defaults to `BlobResult`.
55
+ */
34
56
  export type ClientDataMethod<T extends BlobResult = BlobResult> = {
57
+ /** Fetch binary data from a service as a promise. */
35
58
  blob: Promise<T>;
59
+ /** Fetch binary data from a service as an observable stream. */
36
60
  blob$: StreamResponse<T>;
37
61
  };
62
+ /** Union of available client method names (`'json' | 'json$'`). */
38
63
  export type ClientMethodType = keyof ClientMethod;
39
64
  /**
40
65
  * Utility type that filters the keys of an `AvailableTypes` object to only those
@@ -2,17 +2,8 @@ import type { z } from 'zod';
2
2
  import { type ResponseSelector } from '@equinor/fusion-framework-module-http/selectors';
3
3
  import type { ExtractApiVersion } from './types';
4
4
  /**
5
- * Extracts the correct API version from the provided `apiVersions` object based on the given `version` parameter.
6
- *
7
- * @param apiVersions - An object mapping API version strings to their corresponding versions.
8
- * @param version - The version string to extract.
9
- * @returns The extracted API version, or throws an error if the version is not supported.
10
- */
5
+ * Resolves an API version string from a named key or raw version value.\n *\n * Looks up `version` as a key in `apiVersions` first; if not found,\n * searches the object values for a direct match. Throws when neither\n * lookup succeeds.\n *\n * @template TApiVersions - Record mapping version names to version strings.\n * @template TAllowedApiVersion - Allowed version constraint.\n * @template TVersion - The version string provided by the caller.\n * @param apiVersions - Map of version names to version strings.\n * @param version - Version key or raw version string to resolve.\n * @returns The resolved API version string.\n * @throws {Error} When the version is not found in `apiVersions`.\n *\n * @example\n * ```ts\n * enum ApiVersions { v1 = '1.0', v2 = '2.0' }\n * extractVersion(ApiVersions, 'v1'); // '1.0'\n * extractVersion(ApiVersions, '1.0'); // '1.0'\n * ```\n */
11
6
  export declare const extractVersion: <TApiVersions extends Record<string, string>, TAllowedApiVersion extends string, TVersion extends string>(apiVersions: TApiVersions, version: TVersion) => ExtractApiVersion<TApiVersions, TVersion, TAllowedApiVersion>;
12
7
  /**
13
- * Creates a response selector that parses the response body using the provided Zod schema.
14
- *
15
- * @param schema - The Zod schema to use for parsing the response body.
16
- * @returns A response selector function that parses the response body using the provided schema.
17
- */
8
+ * Creates a response selector that parses the HTTP response body with a Zod schema.\n *\n * Combines the built-in `jsonSelector` with Zod validation, ensuring the\n * response body matches the expected shape at runtime.\n *\n * @template Output - The validated output type produced by the schema.\n * @param schema - The Zod schema used to parse and validate the response body.\n * @returns A `ResponseSelector` that extracts JSON and runs it through `schema.parse`.\n *\n * @example\n * ```ts\n * import { z } from 'zod';\n * const UserSchema = z.object({ id: z.string(), name: z.string() });\n * const selector = schemaSelector(UserSchema);\n * ```\n */
18
9
  export declare const schemaSelector: <Output>(schema: z.ZodSchema<Output>) => ResponseSelector<Output>;
@@ -1 +1 @@
1
- export declare const version = "7.2.1";
1
+ export declare const version = "8.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-services",
3
- "version": "7.2.1",
3
+ "version": "8.0.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",
@@ -137,20 +137,20 @@
137
137
  },
138
138
  "dependencies": {
139
139
  "odata-query": "^8.0.4",
140
- "zod": "^4.1.8"
140
+ "zod": "^4.3.6"
141
141
  },
142
142
  "devDependencies": {
143
143
  "@faker-js/faker": "^10.1.0",
144
144
  "msw": "^2.7.3",
145
- "typescript": "^5.8.2",
146
- "vitest": "^3.2.4",
147
- "@equinor/fusion-framework-module": "^5.0.6",
148
- "@equinor/fusion-framework-module-service-discovery": "^9.1.1",
149
- "@equinor/fusion-framework-module-http": "^7.0.8"
145
+ "typescript": "^5.9.3",
146
+ "vitest": "^4.1.0",
147
+ "@equinor/fusion-framework-module": "^6.0.0",
148
+ "@equinor/fusion-framework-module-http": "^8.0.0",
149
+ "@equinor/fusion-framework-module-service-discovery": "^10.0.0"
150
150
  },
151
151
  "peerDependencies": {
152
- "odata-query": "^8.0.4",
153
- "@equinor/fusion-framework-module": "^5.0.6"
152
+ "odata-query": "^8.0.0",
153
+ "@equinor/fusion-framework-module": "^6.0.0"
154
154
  },
155
155
  "scripts": {
156
156
  "build": "tsc -b",
@@ -1,4 +1,7 @@
1
+ /** Supported API versions for the bookmarks service. */
1
2
  export enum ApiVersion {
3
+ /** Bookmarks API version 1.0. */
2
4
  v1 = '1.0',
5
+ /** Bookmarks API version 2.0. */
3
6
  v2 = '2.0',
4
7
  }
@@ -1,3 +1,17 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Bookmarks API client and types.
5
+ *
6
+ * Provides {@link BookmarksApiClient} for CRUD operations on bookmarks
7
+ * and favourite management, with versioned endpoints (`v1`, `v2`).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { BookmarksApiClient } from '@equinor/fusion-framework-module-services/bookmarks';
12
+ * ```
13
+ */
14
+
1
15
  export { BookmarksApiClient, default } from './client';
2
16
  export { ApiVersion } from './api-version';
3
17
  export * from './schemas';
@@ -2,11 +2,13 @@ import { ApiVersion } from './api-version';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
5
+ /** Zod schema that parses an ISO-8601 datetime string into a `Date` object. */
5
6
  export const ApiDateSchema = z
6
7
  .string()
7
8
  .datetime({ offset: true })
8
9
  .transform((x) => new Date(x));
9
10
 
11
+ /** Zod schema for a person reference in a bookmark response. */
10
12
  export const ApiPersonSchema = {
11
13
  [ApiVersion.v1]: z.object({
12
14
  azureUniqueId: z.string(),
@@ -19,6 +21,7 @@ export const ApiPersonSchema = {
19
21
  }),
20
22
  };
21
23
 
24
+ /** Zod schema for the source system of a bookmark. */
22
25
  export const ApiSourceSystem = {
23
26
  [ApiVersion.v1]: z.object({
24
27
  identifier: z.string(),
@@ -27,6 +30,7 @@ export const ApiSourceSystem = {
27
30
  }),
28
31
  };
29
32
 
33
+ /** Zod schema for a Fusion context reference attached to a bookmark. */
30
34
  export const ApiFusionContext = {
31
35
  [ApiVersion.v1]: z.object({
32
36
  id: z.string(),
@@ -61,6 +65,12 @@ export const ApiBookmarkSchema = {
61
65
  },
62
66
  };
63
67
 
68
+ /**
69
+ * Zod schema for the bookmark payload.
70
+ *
71
+ * Accepts a record of key-value pairs, a JSON string, or `undefined`.
72
+ * JSON strings are automatically parsed into objects.
73
+ */
64
74
  export const ApiBookmarkPayload = {
65
75
  get [ApiVersion.v1]() {
66
76
  return z
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Re-exported shared types scoped for the bookmarks service.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  import type {
2
8
  FilterAllowedApiVersions as FilterAllowApiVersionsBase,
3
9
  ExtractApiVersion as ExtractApiVersionBase,
@@ -7,9 +13,21 @@ import type { ApiVersion } from './api-version';
7
13
 
8
14
  export { ClientMethodType, ClientMethod, ApiClientArguments } from '../types';
9
15
 
16
+ /**
17
+ * Union of allowed version keys and values for the bookmarks API.
18
+ *
19
+ * @template TAllowed - Subset of `ApiVersion` keys to include.
20
+ */
10
21
  export type FilterAllowedApiVersions<TAllowed extends string = keyof typeof ApiVersion> =
11
22
  FilterAllowApiVersionsBase<typeof ApiVersion, TAllowed>;
12
23
 
24
+ /**
25
+ * Extracts the concrete version string from a key-or-value version identifier
26
+ * for the bookmarks API.
27
+ *
28
+ * @template TVersion - The version string to resolve.
29
+ * @template TAllowed - Constraint on allowed versions.
30
+ */
13
31
  export type ExtractApiVersion<
14
32
  TVersion extends string,
15
33
  TAllowed extends string = FilterAllowedApiVersions,
@@ -1,8 +1,22 @@
1
1
  import type { ApiClientFactory } from './types';
2
2
 
3
+ /**
4
+ * Configuration interface for the services module.
5
+ *
6
+ * Consumers can set `createClient` to override how HTTP clients are resolved
7
+ * for each backend service. When left `undefined`, the module automatically
8
+ * resolves clients through the HTTP module and service-discovery module.
9
+ */
3
10
  export interface IApiConfigurator {
4
- /** Method for creating IHttpClients */
11
+ /** Optional factory for creating named HTTP clients. */
5
12
  createClient?: ApiClientFactory;
6
13
  }
7
14
 
15
+ /**
16
+ * Default configurator for the services module.
17
+ *
18
+ * Implements {@link IApiConfigurator} with an initially empty configuration.
19
+ * The module initialization step populates `createClient` if it was not
20
+ * provided during configuration.
21
+ */
8
22
  export class ApiConfigurator implements IApiConfigurator {}
@@ -1,5 +1,6 @@
1
1
  import { ApiVersion } from './static';
2
2
 
3
+ /** Context entity returned by the v1 context API. */
3
4
  type ApiContextEntity_v1 = {
4
5
  id: string;
5
6
  externalId: string | null;
@@ -13,6 +14,7 @@ type ApiContextEntity_v1 = {
13
14
  updated: string | null;
14
15
  };
15
16
 
17
+ /** Placeholder for the v2 context entity (not yet defined). */
16
18
  type ApiContextEntity_v2 = unknown;
17
19
 
18
20
  type ApiContextEntityTypes = {
@@ -20,18 +22,27 @@ type ApiContextEntityTypes = {
20
22
  [ApiVersion.v2]: ApiContextEntity_v2;
21
23
  };
22
24
 
25
+ /**
26
+ * Version-aware context entity type.
27
+ *
28
+ * Resolves to the concrete entity shape for a given {@link ApiVersion}.
29
+ *
30
+ * @template T - An `ApiVersion` member (e.g. `ApiVersion.v1`).
31
+ */
23
32
  export type ApiContextEntity<T extends string = ApiVersion> = T extends ApiVersion
24
33
  ? ApiContextEntityTypes[T]
25
34
  : unknown;
26
35
 
27
36
  /** === types === */
28
37
 
38
+ /** Context type metadata returned by the v1 context API. */
29
39
  type ApiContextType_v1 = {
30
40
  id: string;
31
41
  isChildType: boolean;
32
42
  parentTypeIds: string[] | null;
33
43
  };
34
44
 
45
+ /** Placeholder for the v2 context type (not yet defined). */
35
46
  type ApiContextType_v2 = unknown;
36
47
 
37
48
  type ApiContextTypeTypes = {
@@ -39,4 +50,9 @@ type ApiContextTypeTypes = {
39
50
  [ApiVersion.v2]: ApiContextType_v2;
40
51
  };
41
52
 
53
+ /**
54
+ * Version-aware context type metadata.
55
+ *
56
+ * @template T - An `ApiVersion` member.
57
+ */
42
58
  export type ApiContextType<T extends ApiVersion> = ApiContextTypeTypes[T];
@@ -24,22 +24,40 @@ import {
24
24
  relatedContexts,
25
25
  } from './related';
26
26
 
27
+ /**
28
+ * Typed API client for the Fusion context service.
29
+ *
30
+ * Delegates to versioned endpoint implementations for fetching a single context,
31
+ * querying contexts by search criteria, and listing related contexts.
32
+ *
33
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
34
+ * @template TClient - The underlying HTTP client type.
35
+ */
27
36
  export class ContextApiClient<
28
37
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
29
38
  TClient extends IHttpClient = IHttpClient,
30
39
  > {
40
+ /** Returns the {@link ApiVersion} enum for version-constant access. */
31
41
  get Version(): typeof ApiVersion {
32
42
  return ApiVersion;
33
43
  }
34
44
 
45
+ /**
46
+ * @param _client - The HTTP client used to execute requests.
47
+ * @param _method - The execution method (`'json'` or `'json$'`).
48
+ */
35
49
  constructor(
36
50
  protected _client: TClient,
37
51
  protected _method: TMethod,
38
52
  ) {}
39
53
 
40
54
  /**
41
- * Fetch context by id
42
- * @see {@link get/client}
55
+ * Fetch a single context entity by its identifier.
56
+ *
57
+ * @template TVersion - The API version key (e.g. `'v1'`).
58
+ * @template TResult - The expected response type.
59
+ * @param version - API version to use.
60
+ * @returns The context entity matching the provided arguments.
43
61
  */
44
62
  public get<
45
63
  TVersion extends string = keyof typeof ApiVersion,
@@ -53,8 +71,12 @@ export class ContextApiClient<
53
71
  }
54
72
 
55
73
  /**
56
- * Query context service
57
- * @see {@link query/client}
74
+ * Query the context service with search criteria.
75
+ *
76
+ * @template TVersion - The API version key (e.g. `'v1'`).
77
+ * @template TResult - The expected response type.
78
+ * @param version - API version to use.
79
+ * @returns An array of context entities matching the query.
58
80
  */
59
81
  public query<
60
82
  TVersion extends string = keyof typeof ApiVersion,
@@ -68,8 +90,12 @@ export class ContextApiClient<
68
90
  }
69
91
 
70
92
  /**
71
- * Query context service
72
- * @see {@link query/client}
93
+ * List contexts related to a specific context entity.
94
+ *
95
+ * @template TVersion - The API version key (e.g. `'v1'`).
96
+ * @template TResult - The expected response type.
97
+ * @param version - API version to use.
98
+ * @returns An array of related context entities.
73
99
  */
74
100
  public related<
75
101
  TVersion extends string = keyof typeof ApiVersion,
@@ -7,10 +7,15 @@ import { generateParameters } from './generate-parameters';
7
7
  import type { ClientMethod, GetContextArgs, GetContextResponse, GetContextResult } from './types';
8
8
 
9
9
  /**
10
- * Method for fetching context item from context service
11
- * @param client - client for execution of request
12
- * @param version - version of API to call
13
- * @param method - client method to call
10
+ * Creates a curried function that fetches a single context entity by ID.
11
+ *
12
+ * @template TVersion - The API version key (e.g. `'v1'`).
13
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
14
+ * @template TClient - The underlying HTTP client type.
15
+ * @param client - HTTP client used to execute the request.
16
+ * @param version - API version to call.
17
+ * @param method - Client method to use (defaults to `'json'`).
18
+ * @returns A function that accepts context args and returns the result.
14
19
  */
15
20
  export const getContext =
16
21
  <
@@ -4,7 +4,9 @@ import { ApiVersion, type ApiContextEntity, type ClientMethod } from '..';
4
4
 
5
5
  export { ApiClientArguments, ClientMethod } from '..';
6
6
 
7
+ /** Arguments for fetching a single context in API v1. */
7
8
  type GetContextArgs_v1 = {
9
+ /** The unique context identifier. */
8
10
  id: string;
9
11
  };
10
12
 
@@ -15,6 +17,11 @@ type GetContextArgsTypes = {
15
17
  [ApiVersion.v2]: GetContextArgs_v2;
16
18
  };
17
19
 
20
+ /**
21
+ * Version-aware argument type for the get-context endpoint.
22
+ *
23
+ * @template T - API version key.
24
+ */
18
25
  export type GetContextArgs<T extends string> = T extends keyof typeof ApiVersion
19
26
  ? GetContextArgsTypes[(typeof ApiVersion)[T]]
20
27
  : unknown;
@@ -24,10 +31,23 @@ type GetContextResponseTypes = {
24
31
  [ApiVersion.v2]: ApiContextEntity<ApiVersion.v2>;
25
32
  };
26
33
 
34
+ /**
35
+ * Version-aware response type for the get-context endpoint.
36
+ *
37
+ * @template T - API version key.
38
+ */
27
39
  export type GetContextResponse<T> = T extends keyof typeof ApiVersion
28
40
  ? GetContextResponseTypes[(typeof ApiVersion)[T]]
29
41
  : unknown;
30
42
 
43
+ /**
44
+ * Function signature for the get-context endpoint.
45
+ *
46
+ * @template TVersion - API version key.
47
+ * @template TMethod - Client execution method.
48
+ * @template TClient - HTTP client type.
49
+ * @template TResult - Expected response type.
50
+ */
31
51
  export type GetContextFn<
32
52
  TVersion extends string = keyof typeof ApiVersion,
33
53
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -38,6 +58,13 @@ export type GetContextFn<
38
58
  init?: ClientRequestInit<TClient, TResult>,
39
59
  ) => GetContextResult<TVersion, TMethod, TResult>;
40
60
 
61
+ /**
62
+ * Result type for the get-context endpoint, derived from `ClientMethod`.
63
+ *
64
+ * @template TVersion - API version key.
65
+ * @template TMethod - Client execution method.
66
+ * @template TResult - Expected response type.
67
+ */
41
68
  export type GetContextResult<
42
69
  TVersion extends string = keyof typeof ApiVersion,
43
70
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -1,3 +1,17 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Context API client and types.
5
+ *
6
+ * Provides {@link ContextApiClient} for fetching, querying, and listing
7
+ * related contexts, with versioned endpoints (`v1`, `v2`).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { ContextApiClient } from '@equinor/fusion-framework-module-services/context';
12
+ * ```
13
+ */
14
+
1
15
  export { ContextApiClient, default } from './client';
2
16
 
3
17
  export { ApiVersion } from './static';
@@ -12,7 +12,15 @@ import type {
12
12
  } from './types';
13
13
 
14
14
  /**
15
- * Function for querying the context service
15
+ * Creates a curried function that queries the context service.
16
+ *
17
+ * @template TVersion - The API version key.
18
+ * @template TMethod - The client execution method.
19
+ * @template TClient - The underlying HTTP client type.
20
+ * @param client - HTTP client used to execute the request.
21
+ * @param version - API version to call.
22
+ * @param method - Client method to use (defaults to `'json'`).
23
+ * @returns A function that accepts query args and returns context results.
16
24
  */
17
25
  export const queryContext =
18
26
  <