@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.
- package/CHANGELOG.md +24 -16
- package/README.md +125 -0
- package/dist/esm/bookmarks/api-version.js +3 -0
- package/dist/esm/bookmarks/api-version.js.map +1 -1
- package/dist/esm/bookmarks/index.js +13 -0
- package/dist/esm/bookmarks/index.js.map +1 -1
- package/dist/esm/bookmarks/schemas.js +10 -0
- package/dist/esm/bookmarks/schemas.js.map +1 -1
- package/dist/esm/bookmarks/types.js +5 -0
- package/dist/esm/bookmarks/types.js.map +1 -1
- package/dist/esm/configurator.js +7 -0
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/context/client.js +32 -6
- package/dist/esm/context/client.js.map +1 -1
- package/dist/esm/context/get/client.js +9 -4
- package/dist/esm/context/get/client.js.map +1 -1
- package/dist/esm/context/index.js +13 -0
- package/dist/esm/context/index.js.map +1 -1
- package/dist/esm/context/query/client.js +9 -1
- package/dist/esm/context/query/client.js.map +1 -1
- package/dist/esm/context/related/client.js +9 -1
- package/dist/esm/context/related/client.js.map +1 -1
- package/dist/esm/context/static.js +3 -2
- package/dist/esm/context/static.js.map +1 -1
- package/dist/esm/errors.js +14 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/module.js +39 -7
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/notification/client.js +56 -14
- package/dist/esm/notification/client.js.map +1 -1
- package/dist/esm/notification/index.js +14 -0
- package/dist/esm/notification/index.js.map +1 -1
- package/dist/esm/notification/static.js +3 -2
- package/dist/esm/notification/static.js.map +1 -1
- package/dist/esm/people/client.js +58 -5
- package/dist/esm/people/client.js.map +1 -1
- package/dist/esm/people/index.js +13 -0
- package/dist/esm/people/index.js.map +1 -1
- package/dist/esm/people/person-details/client.js +10 -4
- package/dist/esm/people/person-details/client.js.map +1 -1
- package/dist/esm/people/person-photo/client.js +10 -4
- package/dist/esm/people/person-photo/client.js.map +1 -1
- package/dist/esm/people/query/client.js +10 -4
- package/dist/esm/people/query/client.js.map +1 -1
- package/dist/esm/people/static.js +3 -0
- package/dist/esm/people/static.js.map +1 -1
- package/dist/esm/people/utils.js +19 -0
- package/dist/esm/people/utils.js.map +1 -1
- package/dist/esm/provider.js +37 -2
- package/dist/esm/provider.js.map +1 -1
- package/dist/esm/utils.js +2 -11
- 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 +3 -0
- package/dist/types/bookmarks/index.d.ts +13 -0
- package/dist/types/bookmarks/schemas.d.ts +10 -0
- package/dist/types/bookmarks/types.d.ts +17 -0
- package/dist/types/configurator.d.ts +15 -1
- package/dist/types/context/api-models.d.ts +16 -0
- package/dist/types/context/client.d.ts +32 -6
- package/dist/types/context/get/client.d.ts +9 -4
- package/dist/types/context/get/types.d.ts +27 -0
- package/dist/types/context/index.d.ts +13 -0
- package/dist/types/context/query/client.d.ts +9 -1
- package/dist/types/context/query/types.d.ts +35 -0
- package/dist/types/context/related/client.d.ts +9 -1
- package/dist/types/context/related/types.d.ts +36 -0
- package/dist/types/context/static.d.ts +3 -2
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/module.d.ts +41 -6
- package/dist/types/notification/api-models.d.ts +20 -1
- package/dist/types/notification/client.d.ts +56 -14
- package/dist/types/notification/index.d.ts +14 -0
- package/dist/types/notification/static.d.ts +3 -2
- package/dist/types/people/api-models.d.ts +26 -0
- package/dist/types/people/api-models.v2.d.ts +1 -0
- package/dist/types/people/api-models.v4.d.ts +24 -0
- package/dist/types/people/client.d.ts +58 -5
- package/dist/types/people/index.d.ts +13 -0
- package/dist/types/people/person-details/client.d.ts +10 -4
- package/dist/types/people/person-details/types.d.ts +21 -0
- package/dist/types/people/person-photo/client.d.ts +10 -4
- package/dist/types/people/person-photo/types.d.ts +17 -0
- package/dist/types/people/query/client.d.ts +10 -4
- package/dist/types/people/query/types.d.ts +19 -0
- package/dist/types/people/resolve/types.d.ts +7 -0
- package/dist/types/people/static.d.ts +3 -0
- package/dist/types/people/suggest/types.d.ts +7 -0
- package/dist/types/people/utils.d.ts +19 -0
- package/dist/types/provider.d.ts +69 -4
- package/dist/types/types.d.ts +40 -15
- package/dist/types/utils.d.ts +2 -11
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
- package/src/bookmarks/api-version.ts +3 -0
- package/src/bookmarks/index.ts +14 -0
- package/src/bookmarks/schemas.ts +10 -0
- package/src/bookmarks/types.ts +18 -0
- package/src/configurator.ts +15 -1
- package/src/context/api-models.ts +16 -0
- package/src/context/client.ts +32 -6
- package/src/context/get/client.ts +9 -4
- package/src/context/get/types.ts +27 -0
- package/src/context/index.ts +14 -0
- package/src/context/query/client.ts +9 -1
- package/src/context/query/types.ts +35 -0
- package/src/context/related/client.ts +9 -1
- package/src/context/related/types.ts +36 -0
- package/src/context/static.ts +3 -2
- package/src/errors.ts +14 -0
- package/src/index.ts +15 -0
- package/src/module.ts +47 -7
- package/src/notification/api-models.ts +20 -1
- package/src/notification/client.ts +56 -14
- package/src/notification/index.ts +15 -0
- package/src/notification/static.ts +3 -2
- package/src/people/api-models.ts +26 -1
- package/src/people/api-models.v2.ts +1 -0
- package/src/people/api-models.v4.ts +24 -0
- package/src/people/client.ts +58 -5
- package/src/people/index.ts +14 -0
- package/src/people/person-details/client.ts +10 -4
- package/src/people/person-details/types.ts +21 -0
- package/src/people/person-photo/client.ts +10 -4
- package/src/people/person-photo/types.ts +17 -0
- package/src/people/query/client.ts +10 -4
- package/src/people/query/types.ts +19 -0
- package/src/people/resolve/types.ts +7 -0
- package/src/people/static.ts +3 -0
- package/src/people/suggest/types.ts +7 -0
- package/src/people/utils.ts +19 -0
- package/src/provider.ts +79 -8
- package/src/types.ts +40 -15
- package/src/utils.ts +2 -11
- package/src/version.ts +1 -1
package/src/types.ts
CHANGED
|
@@ -6,22 +6,29 @@ import type {
|
|
|
6
6
|
} from '@equinor/fusion-framework-module-http/client';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Factory function that creates a named HTTP client instance.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Used by {@link ApiProvider} to resolve service-specific HTTP clients
|
|
12
|
+
* (for example, `'bookmarks'`, `'context'`, `'notification'`, `'people'`).
|
|
13
|
+
* The factory first checks registered HTTP clients, then falls back to
|
|
14
|
+
* service discovery.
|
|
15
|
+
*
|
|
16
|
+
* @template TClient - The HTTP client type to create.
|
|
17
|
+
* @param name - Logical service name used to look up or create the HTTP client.
|
|
18
|
+
* @returns A Promise that resolves to a configured HTTP client instance.
|
|
13
19
|
*/
|
|
14
20
|
export type ApiClientFactory<TClient extends IHttpClient = IHttpClient> = (
|
|
15
21
|
name: string,
|
|
16
22
|
) => Promise<TClient>;
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
25
|
+
* Tuple type representing the positional arguments passed to an HTTP client method.
|
|
26
|
+
*
|
|
27
|
+
* Used internally by endpoint generators to build the `[path, init]` pair
|
|
28
|
+
* that the HTTP client's `json()` or `json$()` method expects.
|
|
20
29
|
*
|
|
21
|
-
* @template TClient - The
|
|
22
|
-
* @template TResult - The
|
|
23
|
-
* @param path - The path of the API endpoint.
|
|
24
|
-
* @param init - Optional initialization options for the API client request.
|
|
30
|
+
* @template TClient - The HTTP client type that will execute the request.
|
|
31
|
+
* @template TResult - The expected response body type.
|
|
25
32
|
*/
|
|
26
33
|
export type ApiClientArguments<TClient extends IHttpClient, TResult = unknown> = [
|
|
27
34
|
path: string,
|
|
@@ -29,24 +36,42 @@ export type ApiClientArguments<TClient extends IHttpClient, TResult = unknown> =
|
|
|
29
36
|
];
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Maps HTTP client execution methods to their return types.
|
|
40
|
+
*
|
|
41
|
+
* - `json` — returns a `Promise` that resolves with the parsed JSON body.
|
|
42
|
+
* - `json$` — returns an RxJS-style `StreamResponse` observable.
|
|
43
|
+
*
|
|
44
|
+
* All versioned API client methods are generic over `ClientMethod`,
|
|
45
|
+
* allowing callers to choose between promise-based and observable-based
|
|
46
|
+
* consumption.
|
|
47
|
+
*
|
|
48
|
+
* @template T - The expected deserialized response body type.
|
|
33
49
|
*/
|
|
34
50
|
export type ClientMethod<T = unknown> = {
|
|
35
|
-
/**
|
|
36
|
-
* Fetch JSON data from a service
|
|
37
|
-
*/
|
|
51
|
+
/** Fetch JSON data from a service as a promise. */
|
|
38
52
|
json: Promise<T>;
|
|
39
|
-
/**
|
|
40
|
-
* Fetch JSON data from a service as observable
|
|
41
|
-
*/
|
|
53
|
+
/** Fetch JSON data from a service as an observable stream. */
|
|
42
54
|
json$: StreamResponse<T>;
|
|
43
55
|
};
|
|
44
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Maps HTTP client binary-data execution methods to their return types.
|
|
59
|
+
*
|
|
60
|
+
* - `blob` — returns a `Promise` that resolves with the binary blob result.
|
|
61
|
+
* - `blob$` — returns an RxJS-style `StreamResponse` observable for the blob.
|
|
62
|
+
*
|
|
63
|
+
* Used by endpoints that return non-JSON data such as profile photos.
|
|
64
|
+
*
|
|
65
|
+
* @template T - The blob result type, defaults to `BlobResult`.
|
|
66
|
+
*/
|
|
45
67
|
export type ClientDataMethod<T extends BlobResult = BlobResult> = {
|
|
68
|
+
/** Fetch binary data from a service as a promise. */
|
|
46
69
|
blob: Promise<T>;
|
|
70
|
+
/** Fetch binary data from a service as an observable stream. */
|
|
47
71
|
blob$: StreamResponse<T>;
|
|
48
72
|
};
|
|
49
73
|
|
|
74
|
+
/** Union of available client method names (`'json' | 'json$'`). */
|
|
50
75
|
export type ClientMethodType = keyof ClientMethod;
|
|
51
76
|
|
|
52
77
|
/**
|
package/src/utils.ts
CHANGED
|
@@ -9,12 +9,7 @@ import {
|
|
|
9
9
|
import type { ExtractApiVersion } from './types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param apiVersions - An object mapping API version strings to their corresponding versions.
|
|
15
|
-
* @param version - The version string to extract.
|
|
16
|
-
* @returns The extracted API version, or throws an error if the version is not supported.
|
|
17
|
-
*/
|
|
12
|
+
* 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 */
|
|
18
13
|
export const extractVersion = <
|
|
19
14
|
TApiVersions extends Record<string, string>,
|
|
20
15
|
TAllowedApiVersion extends string,
|
|
@@ -34,11 +29,7 @@ export const extractVersion = <
|
|
|
34
29
|
};
|
|
35
30
|
|
|
36
31
|
/**
|
|
37
|
-
* Creates a response selector that parses the response body
|
|
38
|
-
*
|
|
39
|
-
* @param schema - The Zod schema to use for parsing the response body.
|
|
40
|
-
* @returns A response selector function that parses the response body using the provided schema.
|
|
41
|
-
*/
|
|
32
|
+
* 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 */
|
|
42
33
|
export const schemaSelector =
|
|
43
34
|
<Output>(schema: z.ZodSchema<Output>): ResponseSelector<Output> =>
|
|
44
35
|
async (response: FetchResponse<unknown>) =>
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '8.0.0';
|