@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
@@ -4,11 +4,21 @@ import { ApiVersion, type ApiContextEntity, type ClientMethod } from '..';
4
4
 
5
5
  export { ApiClientArguments, ClientMethod } from '..';
6
6
 
7
+ /**
8
+ * OData filter parameters for context queries.
9
+ *
10
+ * Used to narrow results by context type or external identifier.
11
+ */
7
12
  export type QueryContextOdataFilter = {
8
13
  type?: string[];
9
14
  externalId?: string;
10
15
  };
11
16
 
17
+ /**
18
+ * Structured OData query parameters for context search.
19
+ *
20
+ * Allows combining free-text search with type or external-ID filters.
21
+ */
12
22
  export type QueryContextOdataParameters = {
13
23
  search?: string;
14
24
  filter?: QueryContextOdataFilter;
@@ -26,6 +36,11 @@ type SearchContextArgTypes = {
26
36
  [ApiVersion.v2]: QueryContextArgs_v2;
27
37
  };
28
38
 
39
+ /**
40
+ * Version-aware argument type for the context query endpoint.
41
+ *
42
+ * @template T - API version key.
43
+ */
29
44
  export type QueryContextArgs<T> = T extends keyof typeof ApiVersion
30
45
  ? SearchContextArgTypes[(typeof ApiVersion)[T]]
31
46
  : { query: { search: string } };
@@ -35,10 +50,23 @@ type QueryContextResponseTypes = {
35
50
  [ApiVersion.v2]: Array<ApiContextEntity<ApiVersion.v2>>;
36
51
  };
37
52
 
53
+ /**
54
+ * Version-aware response type for the context query endpoint.
55
+ *
56
+ * @template T - API version key.
57
+ */
38
58
  export type QueryContextResponse<T> = T extends keyof typeof ApiVersion
39
59
  ? QueryContextResponseTypes[(typeof ApiVersion)[T]]
40
60
  : unknown;
41
61
 
62
+ /**
63
+ * Function signature for the context query endpoint.
64
+ *
65
+ * @template TVersion - API version key.
66
+ * @template TMethod - Client execution method.
67
+ * @template TClient - HTTP client type.
68
+ * @template TResult - Expected response type.
69
+ */
42
70
  export type QueryContextFn<
43
71
  TVersion extends string = keyof typeof ApiVersion,
44
72
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -49,6 +77,13 @@ export type QueryContextFn<
49
77
  init?: ClientRequestInit<TClient, TResult>,
50
78
  ) => QueryContextResult<TVersion, TMethod, TResult>;
51
79
 
80
+ /**
81
+ * Result type for the context query endpoint.
82
+ *
83
+ * @template TVersion - API version key.
84
+ * @template TMethod - Client execution method.
85
+ * @template TResult - Expected response type.
86
+ */
52
87
  export type QueryContextResult<
53
88
  TVersion extends string = keyof typeof ApiVersion,
54
89
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -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 fetches contexts related to a given context.
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 relation args and returns related contexts.
16
24
  */
17
25
  export const relatedContexts =
18
26
  <
@@ -4,15 +4,26 @@ import { ApiVersion, type ApiContextEntity, type ClientMethod } from '..';
4
4
 
5
5
  export { ApiClientArguments, ClientMethod } from '..';
6
6
 
7
+ /**
8
+ * Extended context entity that includes relationship metadata.
9
+ *
10
+ * @template T - An {@link ApiVersion} member.
11
+ */
7
12
  export type ApiRelatedContextEntity<T extends ApiVersion> = ApiContextEntity<T> & {
8
13
  relationSource: string; // "ProjectMaster|OrgChart",
9
14
  relationType: unknown;
10
15
  };
11
16
 
17
+ /**
18
+ * OData filter for narrowing related-context results by type.
19
+ */
12
20
  export type RelatedContextOdataFilter = {
13
21
  type?: string[];
14
22
  };
15
23
 
24
+ /**
25
+ * Structured OData query parameters for related-context lookups.
26
+ */
16
27
  export type RelatedContextOdataParameters = {
17
28
  search?: string;
18
29
  filter?: RelatedContextOdataFilter;
@@ -31,6 +42,11 @@ type RelatedContextArgTypes = {
31
42
  [ApiVersion.v2]: RelatedContextArgs_v2;
32
43
  };
33
44
 
45
+ /**
46
+ * Version-aware argument type for the related-contexts endpoint.
47
+ *
48
+ * @template T - API version key.
49
+ */
34
50
  export type RelatedContextArgs<T> = T extends keyof typeof ApiVersion
35
51
  ? RelatedContextArgTypes[(typeof ApiVersion)[T]]
36
52
  : { id: string };
@@ -40,10 +56,23 @@ type RelatedContextResponseTypes = {
40
56
  [ApiVersion.v2]: Array<ApiRelatedContextEntity<ApiVersion.v2>>;
41
57
  };
42
58
 
59
+ /**
60
+ * Version-aware response type for the related-contexts endpoint.
61
+ *
62
+ * @template T - API version key.
63
+ */
43
64
  export type RelatedContextResponse<T> = T extends keyof typeof ApiVersion
44
65
  ? RelatedContextResponseTypes[(typeof ApiVersion)[T]]
45
66
  : unknown;
46
67
 
68
+ /**
69
+ * Function signature for the related-contexts endpoint.
70
+ *
71
+ * @template TVersion - API version key.
72
+ * @template TMethod - Client execution method.
73
+ * @template TClient - HTTP client type.
74
+ * @template TResult - Expected response type.
75
+ */
47
76
  export type RelatedContextFn<
48
77
  TVersion extends string = keyof typeof ApiVersion,
49
78
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -54,6 +83,13 @@ export type RelatedContextFn<
54
83
  init?: ClientRequestInit<TClient, TResult>,
55
84
  ) => RelatedContextResult<TVersion, TMethod, TResult>;
56
85
 
86
+ /**
87
+ * Result type for the related-contexts endpoint.
88
+ *
89
+ * @template TVersion - API version key.
90
+ * @template TMethod - Client execution method.
91
+ * @template TResult - Expected response type.
92
+ */
57
93
  export type RelatedContextResult<
58
94
  TVersion extends string = keyof typeof ApiVersion,
59
95
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -1,6 +1,7 @@
1
- /** index of api versions of context service */
1
+ /** Supported API versions for the context service. */
2
2
  export enum ApiVersion {
3
+ /** Context API version 1.0. */
3
4
  v1 = '1.0',
4
- /** not in use atm */
5
+ /** Context API version 2.0 (not currently in use). */
5
6
  v2 = '2.0',
6
7
  }
package/src/errors.ts CHANGED
@@ -1,4 +1,18 @@
1
+ /**
2
+ * Error thrown when an API endpoint is called with a version string
3
+ * that does not match any supported API version.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * throw new UnsupportedApiVersion('3.0');
8
+ * // Error: unsupported version 3.0
9
+ * ```
10
+ */
1
11
  export class UnsupportedApiVersion extends Error {
12
+ /**
13
+ * @param version - The unsupported version value that was requested.
14
+ * @param cause - Optional underlying error or context.
15
+ */
2
16
  constructor(
3
17
  public readonly version: string | number,
4
18
  cause?: unknown,
package/src/index.ts CHANGED
@@ -1,3 +1,18 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Typed API service clients for the Fusion Framework.\
5
+ * Provides factory-based access to bookmarks, context, notification, and
6
+ * people APIs with versioned endpoints, response validation, and support
7
+ * for both promise (`json`) and observable (`json$`) consumption patterns.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { enableServices } from '@equinor/fusion-framework-module-services';
12
+ * configurator.addConfig(enableServices);
13
+ * ```
14
+ */
15
+
1
16
  export * from './types';
2
17
  export type { ServicesModule, ServicesModuleKey } from './module';
3
18
 
package/src/module.ts CHANGED
@@ -14,10 +14,19 @@ import { type IApiProvider, ApiProvider } from './provider';
14
14
 
15
15
  import type { ApiClientFactory } from './types';
16
16
 
17
+ /** String literal type for the services module registration key. */
17
18
  export type ServicesModuleKey = 'services';
18
19
 
20
+ /** Module registration key used to identify the services module. */
19
21
  export const moduleKey: ServicesModuleKey = 'services';
20
22
 
23
+ /**
24
+ * Module definition for the services module.
25
+ *
26
+ * Declares the module key, provider type ({@link IApiProvider}),
27
+ * configurator type ({@link IApiConfigurator}), and required
28
+ * dependency modules (HTTP and service-discovery).
29
+ */
21
30
  export type ServicesModule = Module<
22
31
  ServicesModuleKey,
23
32
  IApiProvider,
@@ -26,7 +35,12 @@ export type ServicesModule = Module<
26
35
  >;
27
36
 
28
37
  /**
29
- * Method to trying to resolve method for creating an IHttpClient
38
+ * Creates the default {@link ApiClientFactory} by attempting named HTTP clients
39
+ * first, then falling back to service-discovery.
40
+ *
41
+ * @param http - The HTTP client provider from the `http` module.
42
+ * @param serviceDiscovery - Optional service-discovery provider for automatic client resolution.
43
+ * @returns A factory function that creates named HTTP clients.
30
44
  */
31
45
  const createDefaultClient =
32
46
  (http: IHttpClientProvider, serviceDiscovery?: ServiceDiscoveryProvider): ApiClientFactory =>
@@ -41,7 +55,11 @@ const createDefaultClient =
41
55
  };
42
56
 
43
57
  /**
44
- * Configure http-client
58
+ * Services module definition.
59
+ *
60
+ * Registers the `'services'` module, wires up the {@link ApiConfigurator},
61
+ * and initializes the {@link ApiProvider} with an HTTP client factory
62
+ * resolved from the `http` and optional `serviceDiscovery` modules.
45
63
  */
46
64
  export const module: ServicesModule = {
47
65
  name: moduleKey,
@@ -66,8 +84,18 @@ export const module: ServicesModule = {
66
84
  };
67
85
 
68
86
  /**
69
- * Method for enabling the Service module
70
- * @param config - configuration object
87
+ * Registers the services module with the framework configurator.
88
+ *
89
+ * Call this during app configuration to make the services module
90
+ * available at runtime.
91
+ *
92
+ * @param config - The framework modules configurator.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { enableServices } from '@equinor/fusion-framework-module-services';
97
+ * configurator.addConfig(enableServices);
98
+ * ```
71
99
  */
72
100
  export const enableServices = (
73
101
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -77,12 +105,24 @@ export const enableServices = (
77
105
  };
78
106
 
79
107
  /**
108
+ * Creates a module configuration object for the services module
109
+ * with a custom configuration callback.
110
+ *
111
+ * Use this when you need to customise the services module (for example,
112
+ * supplying a custom `createClient` factory).
113
+ *
114
+ * @param configure - Callback that receives the {@link IApiConfigurator} for customisation.
115
+ * @returns A module configurator object that can be passed to `addConfig`.
116
+ *
80
117
  * @example
81
118
  * ```ts
82
- * config.addConfig(x => x.createClient(...));
119
+ * import { configureServices } from '@equinor/fusion-framework-module-services';
120
+ * configurator.addConfig(
121
+ * configureServices((cfg) => {
122
+ * cfg.createClient = myCustomClientFactory;
123
+ * }),
124
+ * );
83
125
  * ```
84
- * @param configure - Callback for configuring the module
85
- * @returns Configuration object
86
126
  */
87
127
  export const configureServices = (
88
128
  configure: (configurator: IApiConfigurator) => void,
@@ -1,5 +1,6 @@
1
1
  import { ApiVersion } from './static';
2
2
 
3
+ /** Notification entity returned by the v1 notification API. */
3
4
  type ApiNotificationEntity_v1 = {
4
5
  id: string;
5
6
  appKey: string;
@@ -16,17 +17,20 @@ type ApiNotificationEntity_v1 = {
16
17
  sourceSystem: SourceSystem_v1;
17
18
  };
18
19
 
20
+ /** Source system metadata for a notification. */
19
21
  type SourceSystem_v1 = {
20
22
  name: string;
21
23
  subSystem: string;
22
24
  identifier: string;
23
25
  };
24
26
 
27
+ /** Application that created the notification. */
25
28
  type CreatedByApplication_v1 = {
26
29
  id: string;
27
30
  title: string;
28
31
  };
29
32
 
33
+ /** Person who created the notification. */
30
34
  type CreatedBy_v1 = {
31
35
  id: string;
32
36
  name: string;
@@ -35,6 +39,7 @@ type CreatedBy_v1 = {
35
39
  accountType: string;
36
40
  };
37
41
 
42
+ /** Placeholder for the v2 notification entity (not yet defined). */
38
43
  type ApiNotificationEntity_v2 = unknown;
39
44
 
40
45
  type ApiNotificationEntityTypes = {
@@ -42,22 +47,31 @@ type ApiNotificationEntityTypes = {
42
47
  [ApiVersion.v2]: ApiNotificationEntity_v2;
43
48
  };
44
49
 
50
+ /**
51
+ * Version-aware notification entity type.
52
+ *
53
+ * Resolves to the concrete entity shape for a given {@link ApiVersion}.
54
+ *
55
+ * @template T - An `ApiVersion` member string.
56
+ */
45
57
  export type ApiNotificationEntity<T extends string = ApiVersion> = T extends ApiVersion
46
58
  ? ApiNotificationEntityTypes[T]
47
59
  : unknown;
48
60
 
49
- /**User notification Settings */
61
+ /** User notification settings entity for API v1. */
50
62
  type ApiNotificationSettingsEntity_v1 = {
51
63
  email: boolean;
52
64
  delayInMinutes: number;
53
65
  appConfig: AppConfig_v1[];
54
66
  };
55
67
 
68
+ /** Per-application notification toggle within user settings. */
56
69
  type AppConfig_v1 = {
57
70
  appKey: string;
58
71
  enabled: boolean;
59
72
  };
60
73
 
74
+ /** Placeholder for the v2 notification settings entity (not yet defined). */
61
75
  type ApiNotificationSettingsEntity_v2 = unknown;
62
76
 
63
77
  type ApiNotificationSettingEntityTypes = {
@@ -65,6 +79,11 @@ type ApiNotificationSettingEntityTypes = {
65
79
  [ApiVersion.v2]: ApiNotificationSettingsEntity_v2;
66
80
  };
67
81
 
82
+ /**
83
+ * Version-aware notification settings entity type.
84
+ *
85
+ * @template T - An `ApiVersion` member string.
86
+ */
68
87
  export type ApiNotificationSettingsEntity<T extends string = ApiVersion> = T extends ApiVersion
69
88
  ? ApiNotificationSettingEntityTypes[T]
70
89
  : unknown;
@@ -22,22 +22,40 @@ import getUserNotificationSettings, {
22
22
  type GetUserNotificationsSettingsResult,
23
23
  } from './settings/get';
24
24
 
25
+ /**
26
+ * Typed API client for the Fusion notification service.
27
+ *
28
+ * Provides methods for notification CRUD operations, marking notifications
29
+ * as seen, and managing user notification settings.
30
+ *
31
+ * @template TMethod - The client execution method (`'json'` or `'json$'`).
32
+ * @template TClient - The underlying HTTP client type.
33
+ */
25
34
  export class NotificationApiClient<
26
35
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
27
36
  TClient extends IHttpClient = IHttpClient,
28
37
  > {
38
+ /** Returns the {@link ApiVersion} enum for version-constant access. */
29
39
  get Version(): typeof ApiVersion {
30
40
  return ApiVersion;
31
41
  }
32
42
 
43
+ /**
44
+ * @param _client - The HTTP client used to execute requests.
45
+ * @param _method - The execution method (`'json'` or `'json$'`).
46
+ */
33
47
  constructor(
34
48
  protected _client: TClient,
35
49
  protected _method: TMethod,
36
50
  ) {}
37
51
 
38
52
  /**
39
- * Fetch all notifications
40
- * @see {@link getAll/client}
53
+ * Fetch all notifications for the current user.
54
+ *
55
+ * @template TVersion - The API version key.
56
+ * @template TResult - The expected response type.
57
+ * @param version - API version to use.
58
+ * @returns All notifications matching the query.
41
59
  */
42
60
  public getAll<
43
61
  TVersion extends string = keyof typeof ApiVersion,
@@ -51,8 +69,12 @@ export class NotificationApiClient<
51
69
  }
52
70
 
53
71
  /**
54
- * Fetch notification by id
55
- * @see {@link getById/client}
72
+ * Fetch a single notification by its identifier.
73
+ *
74
+ * @template TVersion - The API version key.
75
+ * @template TResult - The expected response type.
76
+ * @param version - API version to use.
77
+ * @returns The notification with the specified ID.
56
78
  */
57
79
  public getById<
58
80
  TVersion extends string = keyof typeof ApiVersion,
@@ -66,8 +88,12 @@ export class NotificationApiClient<
66
88
  }
67
89
 
68
90
  /**
69
- * Set notification seen by user
70
- * @see {@link setSeenByUser/client}
91
+ * Mark a notification as seen by the current user.
92
+ *
93
+ * @template TVersion - The API version key.
94
+ * @template TResult - The expected response type.
95
+ * @param version - API version to use.
96
+ * @returns The updated notification.
71
97
  */
72
98
  public setSeenByUser<
73
99
  TVersion extends string = keyof typeof ApiVersion,
@@ -81,8 +107,12 @@ export class NotificationApiClient<
81
107
  }
82
108
 
83
109
  /**
84
- * Create a notification
85
- * @see {@link create/client}
110
+ * Create a new notification.
111
+ *
112
+ * @template TVersion - The API version key.
113
+ * @template TResult - The expected response type.
114
+ * @param version - API version to use.
115
+ * @returns The created notification.
86
116
  */
87
117
  public create<
88
118
  TVersion extends string = keyof typeof ApiVersion,
@@ -96,8 +126,12 @@ export class NotificationApiClient<
96
126
  }
97
127
 
98
128
  /**
99
- * Delete a notification
100
- * @see {@link delete/client}
129
+ * Delete a notification by its identifier.
130
+ *
131
+ * @template TVersion - The API version key.
132
+ * @template TResult - The expected response type.
133
+ * @param version - API version to use.
134
+ * @returns The deletion result.
101
135
  */
102
136
  public delete<
103
137
  TVersion extends string = keyof typeof ApiVersion,
@@ -110,8 +144,12 @@ export class NotificationApiClient<
110
144
  return fn<TResult>(...args);
111
145
  }
112
146
  /**
113
- * Get users notification settings
114
- * @see {@link getSettings/client}
147
+ * Retrieve the current user's notification settings.
148
+ *
149
+ * @template TVersion - The API version key.
150
+ * @template TResult - The expected response type.
151
+ * @param version - API version to use.
152
+ * @returns The user's notification settings.
115
153
  */
116
154
  public getSettings<
117
155
  TVersion extends string = keyof typeof ApiVersion,
@@ -128,8 +166,12 @@ export class NotificationApiClient<
128
166
  return fn<TResult>(...args);
129
167
  }
130
168
  /**
131
- * Update user notification settings
132
- * @see {@link updateSettings/client}
169
+ * Update the current user's notification settings.
170
+ *
171
+ * @template TVersion - The API version key.
172
+ * @template TResult - The expected response type.
173
+ * @param version - API version to use.
174
+ * @returns The updated notification settings.
133
175
  */
134
176
  public updateSettings<
135
177
  TVersion extends string = keyof typeof ApiVersion,
@@ -1,3 +1,18 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Notification API client and types.
5
+ *
6
+ * Provides {@link NotificationApiClient} for creating, fetching, deleting
7
+ * notifications, marking them as seen, and managing user notification
8
+ * settings, with versioned endpoints (`v1`, `v2`).
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { NotificationApiClient } from '@equinor/fusion-framework-module-services/notification';
13
+ * ```
14
+ */
15
+
1
16
  export { NotificationApiClient, default } from './client';
2
17
 
3
18
  export { ApiVersion } from './static';
@@ -1,6 +1,7 @@
1
- /** index of api versions of context service */
1
+ /** Supported API versions for the notification service. */
2
2
  export enum ApiVersion {
3
+ /** Notification API version 1.0. */
3
4
  v1 = '1.0',
4
- /** not in use atm */
5
+ /** Notification API version 2.0 (not currently in use). */
5
6
  v2 = '2.0',
6
7
  }
@@ -2,11 +2,13 @@ import type { ApiPerson_v2 } from './api-models.v2';
2
2
  import type { ApiPerson_v4 } from './api-models.v4';
3
3
  import { ApiVersion } from './static';
4
4
 
5
+ /** Project master reference attached to a person's contract. */
5
6
  export type ApiProjectMaster = {
6
7
  id: string;
7
8
  name?: string;
8
9
  };
9
10
 
11
+ /** Manager information with contact details and classification. */
10
12
  export type ApiManager = {
11
13
  azureUniqueId: string;
12
14
  name?: string;
@@ -19,8 +21,10 @@ export type ApiManager = {
19
21
  accountClassification: ApiAccountClassification;
20
22
  };
21
23
 
24
+ /** Invitation status for a person's account. */
22
25
  export type ApiInvitationStatus = 'Accepted' | 'Pending' | 'NotSent';
23
26
 
27
+ /** Account type classification for a person profile. */
24
28
  export type ApiProfileAccountType =
25
29
  | 'Employee'
26
30
  | 'Consultant'
@@ -28,9 +32,10 @@ export type ApiProfileAccountType =
28
32
  | 'External'
29
33
  | 'External Hire';
30
34
 
31
- // TODO what are these?
35
+ /** Account classification tier for access control. */
32
36
  export type ApiAccountClassification = 'Unclassified' | 'Internal' | 'External';
33
37
 
38
+ /** Linked account reference for a person profile. */
34
39
  export type ApiProfileAccountLink = {
35
40
  azureUniqueId: string;
36
41
  mail?: string;
@@ -40,17 +45,32 @@ export type ApiProfileAccountLink = {
40
45
  upn?: string;
41
46
  };
42
47
 
48
+ /**
49
+ * Map from API version to the corresponding person entity type.
50
+ *
51
+ * @see {@link ApiPerson_v2}
52
+ * @see {@link ApiPerson_v4}
53
+ */
43
54
  export type ApiPersonMap = {
44
55
  [ApiVersion.v2]: ApiPerson_v2;
45
56
  [ApiVersion.v4]: ApiPerson_v4;
46
57
  };
47
58
 
59
+ /**
60
+ * Version-aware person entity type.
61
+ *
62
+ * Resolves to the concrete person shape for a given {@link ApiVersion}
63
+ * key or value.
64
+ *
65
+ * @template T - An `ApiVersion` key or value.
66
+ */
48
67
  export type ApiPerson<T extends keyof typeof ApiVersion | ApiVersion> = T extends ApiVersion
49
68
  ? ApiPersonMap[T]
50
69
  : T extends keyof typeof ApiVersion
51
70
  ? ApiPersonMap[(typeof ApiVersion)[T]]
52
71
  : unknown;
53
72
 
73
+ /** Person suggestion result with account type and department detail. */
54
74
  export type ApiSuggestionPerson = {
55
75
  accountType?:
56
76
  | 'Unknown'
@@ -73,12 +93,14 @@ export type ApiSuggestionPerson = {
73
93
  mobilePhone?: string;
74
94
  };
75
95
 
96
+ /** Application entity in a person suggestion result. */
76
97
  export type ApiSuggestionApplication = {
77
98
  applicationId: string;
78
99
  applicationName?: string;
79
100
  servicePrincipalType: 'Application' | 'ManagedIdentity' | 'ServicePrincipal';
80
101
  };
81
102
 
103
+ /** Single suggestion value representing a person or system account. */
82
104
  export type ApiSuggestionValue = {
83
105
  azureUniqueId: string;
84
106
  name?: string;
@@ -91,6 +113,7 @@ export type ApiSuggestionValue = {
91
113
  isExpired: boolean;
92
114
  };
93
115
 
116
+ /** Paginated suggestion response from the people suggest endpoint. */
94
117
  export type ApiSuggestions = {
95
118
  totalCount: number;
96
119
  count: number;
@@ -98,6 +121,7 @@ export type ApiSuggestions = {
98
121
  value: Array<ApiSuggestionValue>;
99
122
  };
100
123
 
124
+ /** Single resolved item from the people resolve endpoint. */
101
125
  export type ApiResolveItem = {
102
126
  success: boolean;
103
127
  statusCode: number;
@@ -106,4 +130,5 @@ export type ApiResolveItem = {
106
130
  account: ApiSuggestionValue | null;
107
131
  };
108
132
 
133
+ /** Array of resolved person lookup results. */
109
134
  export type ApiResolved = Array<ApiResolveItem>;
@@ -5,6 +5,7 @@ import type {
5
5
  ApiProfileAccountType,
6
6
  } from './api-models';
7
7
 
8
+ /** Person entity returned by the v2 people API. */
8
9
  export type ApiPerson_v2 = {
9
10
  fusionPersonId?: string;
10
11
  azureUniqueId: string;