@equinor/fusion-framework-module-services 5.1.1-msal-6cf764b628c2afdd64dfd06e42abc953d78556d2 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/CHANGELOG.md +103 -98
  2. package/dist/esm/bookmarks/api-version.js.map +1 -1
  3. package/dist/esm/bookmarks/client.js.map +1 -1
  4. package/dist/esm/bookmarks/endpoints/bookmark-apply.get.js.map +1 -1
  5. package/dist/esm/bookmarks/endpoints/bookmark.delete.js.map +1 -1
  6. package/dist/esm/bookmarks/endpoints/bookmark.get.js.map +1 -1
  7. package/dist/esm/bookmarks/endpoints/bookmark.patch.js.map +1 -1
  8. package/dist/esm/bookmarks/endpoints/bookmark.post.js.map +1 -1
  9. package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.delete.js.map +1 -1
  10. package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.head.js.map +1 -1
  11. package/dist/esm/bookmarks/endpoints/user-bookmark-favourite.post.js.map +1 -1
  12. package/dist/esm/bookmarks/endpoints/user-bookmarks.get.js.map +1 -1
  13. package/dist/esm/bookmarks/schemas.js +1 -3
  14. package/dist/esm/bookmarks/schemas.js.map +1 -1
  15. package/dist/esm/bookmarks/selectors.js.map +1 -1
  16. package/dist/esm/context/client.js +2 -2
  17. package/dist/esm/context/client.js.map +1 -1
  18. package/dist/esm/context/get/client.js.map +1 -1
  19. package/dist/esm/context/get/generate-endpoint.js +0 -1
  20. package/dist/esm/context/get/generate-endpoint.js.map +1 -1
  21. package/dist/esm/context/get/generate-parameters.js.map +1 -1
  22. package/dist/esm/context/get/types.js.map +1 -1
  23. package/dist/esm/context/query/client.js.map +1 -1
  24. package/dist/esm/context/query/generate-endpoint.js +0 -1
  25. package/dist/esm/context/query/generate-endpoint.js.map +1 -1
  26. package/dist/esm/context/query/generate-parameters.js.map +1 -1
  27. package/dist/esm/context/query/types.js.map +1 -1
  28. package/dist/esm/context/related/client.js.map +1 -1
  29. package/dist/esm/context/related/generate-endpoint.js +0 -1
  30. package/dist/esm/context/related/generate-endpoint.js.map +1 -1
  31. package/dist/esm/context/related/generate-parameters.js.map +1 -1
  32. package/dist/esm/context/related/types.js.map +1 -1
  33. package/dist/esm/context/static.js.map +1 -1
  34. package/dist/esm/errors.js.map +1 -1
  35. package/dist/esm/module.js.map +1 -1
  36. package/dist/esm/notification/client.js.map +1 -1
  37. package/dist/esm/notification/notification/delete/client.js.map +1 -1
  38. package/dist/esm/notification/notification/delete/generate-endpoint.js +0 -1
  39. package/dist/esm/notification/notification/delete/generate-endpoint.js.map +1 -1
  40. package/dist/esm/notification/notification/delete/generate-parameters.js.map +1 -1
  41. package/dist/esm/notification/notification/get/client.js.map +1 -1
  42. package/dist/esm/notification/notification/get/generate-endpoint.js +0 -1
  43. package/dist/esm/notification/notification/get/generate-endpoint.js.map +1 -1
  44. package/dist/esm/notification/notification/get/generate-parameters.js.map +1 -1
  45. package/dist/esm/notification/notification/getAll/client.js.map +1 -1
  46. package/dist/esm/notification/notification/getAll/generate-endpoint.js +0 -1
  47. package/dist/esm/notification/notification/getAll/generate-endpoint.js.map +1 -1
  48. package/dist/esm/notification/notification/getAll/generate-parameters.js.map +1 -1
  49. package/dist/esm/notification/notification/patch/client.js.map +1 -1
  50. package/dist/esm/notification/notification/patch/generate-endpoint.js +0 -1
  51. package/dist/esm/notification/notification/patch/generate-endpoint.js.map +1 -1
  52. package/dist/esm/notification/notification/patch/generate-parameters.js.map +1 -1
  53. package/dist/esm/notification/notification/post/client.js.map +1 -1
  54. package/dist/esm/notification/notification/post/generate-endpoint.js +0 -1
  55. package/dist/esm/notification/notification/post/generate-endpoint.js.map +1 -1
  56. package/dist/esm/notification/notification/post/generate-parameters.js.map +1 -1
  57. package/dist/esm/notification/settings/get/client.js.map +1 -1
  58. package/dist/esm/notification/settings/get/generate-endpoint.js +0 -1
  59. package/dist/esm/notification/settings/get/generate-endpoint.js.map +1 -1
  60. package/dist/esm/notification/settings/get/generate-parameters.js.map +1 -1
  61. package/dist/esm/notification/settings/put/client.js.map +1 -1
  62. package/dist/esm/notification/settings/put/generate-endpoint.js +0 -1
  63. package/dist/esm/notification/settings/put/generate-endpoint.js.map +1 -1
  64. package/dist/esm/notification/settings/put/generate-parameters.js.map +1 -1
  65. package/dist/esm/notification/static.js.map +1 -1
  66. package/dist/esm/people/client.js.map +1 -1
  67. package/dist/esm/people/person-details/client.js.map +1 -1
  68. package/dist/esm/people/person-details/generate-endpoint.js.map +1 -1
  69. package/dist/esm/people/person-details/generate-parameters.js.map +1 -1
  70. package/dist/esm/people/person-photo/client.js.map +1 -1
  71. package/dist/esm/people/person-photo/generate-endpoint.js.map +1 -1
  72. package/dist/esm/people/person-photo/generate-parameters.js.map +1 -1
  73. package/dist/esm/people/query/client.js.map +1 -1
  74. package/dist/esm/people/query/generate-endpoint.js.map +1 -1
  75. package/dist/esm/people/query/generate-parameters.js.map +1 -1
  76. package/dist/esm/people/static.js.map +1 -1
  77. package/dist/esm/people/utils.js.map +1 -1
  78. package/dist/esm/provider.js.map +1 -1
  79. package/dist/esm/utils.js.map +1 -1
  80. package/dist/esm/version.js +1 -1
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/dist/types/bookmarks/api-version.d.ts +2 -2
  83. package/dist/types/bookmarks/client.d.ts +8 -8
  84. package/dist/types/bookmarks/endpoints/bookmark-apply.get.d.ts +1 -1
  85. package/dist/types/bookmarks/endpoints/bookmark.delete.d.ts +1 -1
  86. package/dist/types/bookmarks/endpoints/bookmark.get.d.ts +1 -1
  87. package/dist/types/bookmarks/endpoints/bookmark.patch.d.ts +1 -1
  88. package/dist/types/bookmarks/endpoints/bookmark.post.d.ts +1 -1
  89. package/dist/types/bookmarks/endpoints/user-bookmark-favourite.delete.d.ts +1 -1
  90. package/dist/types/bookmarks/endpoints/user-bookmark-favourite.head.d.ts +1 -1
  91. package/dist/types/bookmarks/endpoints/user-bookmark-favourite.post.d.ts +1 -1
  92. package/dist/types/bookmarks/endpoints/user-bookmarks.get.d.ts +1 -1
  93. package/dist/types/bookmarks/selectors.d.ts +1 -1
  94. package/dist/types/bookmarks/types.d.ts +1 -1
  95. package/dist/types/configurator.d.ts +1 -1
  96. package/dist/types/context/client.d.ts +4 -4
  97. package/dist/types/context/get/client.d.ts +1 -1
  98. package/dist/types/context/get/types.d.ts +2 -2
  99. package/dist/types/context/query/client.d.ts +1 -1
  100. package/dist/types/context/query/generate-parameters.d.ts +1 -1
  101. package/dist/types/context/query/types.d.ts +2 -2
  102. package/dist/types/context/related/client.d.ts +1 -1
  103. package/dist/types/context/related/generate-parameters.d.ts +1 -1
  104. package/dist/types/context/related/types.d.ts +2 -2
  105. package/dist/types/context/static.d.ts +2 -2
  106. package/dist/types/module.d.ts +2 -2
  107. package/dist/types/notification/client.d.ts +9 -9
  108. package/dist/types/notification/notification/delete/client.d.ts +2 -2
  109. package/dist/types/notification/notification/delete/generate-parameters.d.ts +2 -2
  110. package/dist/types/notification/notification/delete/types.d.ts +3 -3
  111. package/dist/types/notification/notification/get/client.d.ts +2 -2
  112. package/dist/types/notification/notification/get/generate-parameters.d.ts +2 -2
  113. package/dist/types/notification/notification/get/types.d.ts +3 -3
  114. package/dist/types/notification/notification/getAll/client.d.ts +2 -2
  115. package/dist/types/notification/notification/getAll/generate-parameters.d.ts +2 -2
  116. package/dist/types/notification/notification/getAll/types.d.ts +3 -3
  117. package/dist/types/notification/notification/patch/client.d.ts +2 -2
  118. package/dist/types/notification/notification/patch/generate-parameters.d.ts +2 -2
  119. package/dist/types/notification/notification/patch/types.d.ts +3 -3
  120. package/dist/types/notification/notification/post/client.d.ts +2 -2
  121. package/dist/types/notification/notification/post/generate-parameters.d.ts +2 -2
  122. package/dist/types/notification/notification/post/types.d.ts +3 -3
  123. package/dist/types/notification/settings/get/client.d.ts +2 -2
  124. package/dist/types/notification/settings/get/generate-parameters.d.ts +2 -2
  125. package/dist/types/notification/settings/get/types.d.ts +3 -3
  126. package/dist/types/notification/settings/put/client.d.ts +2 -2
  127. package/dist/types/notification/settings/put/generate-parameters.d.ts +2 -2
  128. package/dist/types/notification/settings/put/types.d.ts +3 -3
  129. package/dist/types/notification/static.d.ts +2 -2
  130. package/dist/types/people/api-models.d.ts +2 -2
  131. package/dist/types/people/api-models.v2.d.ts +1 -1
  132. package/dist/types/people/api-models.v4.d.ts +1 -1
  133. package/dist/types/people/client.d.ts +4 -4
  134. package/dist/types/people/person-details/client.d.ts +1 -1
  135. package/dist/types/people/person-details/types.d.ts +1 -1
  136. package/dist/types/people/person-photo/client.d.ts +1 -1
  137. package/dist/types/people/person-photo/types.d.ts +2 -2
  138. package/dist/types/people/query/client.d.ts +1 -1
  139. package/dist/types/people/query/types.d.ts +2 -2
  140. package/dist/types/people/static.d.ts +2 -2
  141. package/dist/types/people/utils.d.ts +1 -1
  142. package/dist/types/provider.d.ts +3 -3
  143. package/dist/types/types.d.ts +1 -1
  144. package/dist/types/utils.d.ts +1 -1
  145. package/dist/types/version.d.ts +1 -1
  146. package/package.json +5 -5
  147. package/src/bookmarks/api-version.ts +2 -2
  148. package/src/bookmarks/client.ts +228 -231
  149. package/src/bookmarks/endpoints/bookmark-apply.get.ts +58 -58
  150. package/src/bookmarks/endpoints/bookmark.delete.ts +57 -57
  151. package/src/bookmarks/endpoints/bookmark.get.ts +62 -62
  152. package/src/bookmarks/endpoints/bookmark.patch.ts +78 -78
  153. package/src/bookmarks/endpoints/bookmark.post.ts +68 -68
  154. package/src/bookmarks/endpoints/user-bookmark-favourite.delete.ts +57 -57
  155. package/src/bookmarks/endpoints/user-bookmark-favourite.head.ts +57 -57
  156. package/src/bookmarks/endpoints/user-bookmark-favourite.post.ts +58 -58
  157. package/src/bookmarks/endpoints/user-bookmarks.get.ts +98 -98
  158. package/src/bookmarks/schemas.ts +54 -56
  159. package/src/bookmarks/selectors.ts +24 -24
  160. package/src/bookmarks/types.ts +6 -6
  161. package/src/configurator.ts +3 -3
  162. package/src/context/api-models.ts +19 -19
  163. package/src/context/client.ts +68 -58
  164. package/src/context/get/client.ts +18 -18
  165. package/src/context/get/generate-endpoint.ts +13 -14
  166. package/src/context/get/generate-parameters.ts +9 -9
  167. package/src/context/get/types.ts +20 -20
  168. package/src/context/query/client.ts +22 -22
  169. package/src/context/query/generate-endpoint.ts +43 -44
  170. package/src/context/query/generate-parameters.ts +10 -10
  171. package/src/context/query/types.ts +25 -25
  172. package/src/context/related/client.ts +22 -22
  173. package/src/context/related/generate-endpoint.ts +40 -41
  174. package/src/context/related/generate-parameters.ts +10 -10
  175. package/src/context/related/types.ts +27 -27
  176. package/src/context/static.ts +3 -3
  177. package/src/errors.ts +6 -6
  178. package/src/module.ts +50 -52
  179. package/src/notification/api-models.ts +36 -36
  180. package/src/notification/client.ts +131 -151
  181. package/src/notification/notification/delete/client.ts +22 -22
  182. package/src/notification/notification/delete/generate-endpoint.ts +13 -14
  183. package/src/notification/notification/delete/generate-parameters.ts +18 -18
  184. package/src/notification/notification/delete/types.ts +21 -21
  185. package/src/notification/notification/get/client.ts +19 -19
  186. package/src/notification/notification/get/generate-endpoint.ts +13 -14
  187. package/src/notification/notification/get/generate-parameters.ts +11 -11
  188. package/src/notification/notification/get/types.ts +21 -21
  189. package/src/notification/notification/getAll/client.ts +22 -22
  190. package/src/notification/notification/getAll/generate-endpoint.ts +13 -14
  191. package/src/notification/notification/getAll/generate-parameters.ts +11 -11
  192. package/src/notification/notification/getAll/types.ts +21 -21
  193. package/src/notification/notification/patch/client.ts +22 -22
  194. package/src/notification/notification/patch/generate-endpoint.ts +13 -14
  195. package/src/notification/notification/patch/generate-parameters.ts +18 -18
  196. package/src/notification/notification/patch/types.ts +22 -22
  197. package/src/notification/notification/post/client.ts +22 -22
  198. package/src/notification/notification/post/generate-endpoint.ts +13 -14
  199. package/src/notification/notification/post/generate-parameters.ts +18 -18
  200. package/src/notification/notification/post/types.ts +31 -31
  201. package/src/notification/settings/get/client.ts +22 -22
  202. package/src/notification/settings/get/generate-endpoint.ts +13 -14
  203. package/src/notification/settings/get/generate-parameters.ts +11 -11
  204. package/src/notification/settings/get/types.ts +21 -21
  205. package/src/notification/settings/put/client.ts +22 -22
  206. package/src/notification/settings/put/generate-endpoint.ts +13 -14
  207. package/src/notification/settings/put/generate-parameters.ts +20 -20
  208. package/src/notification/settings/put/types.ts +20 -20
  209. package/src/notification/static.ts +3 -3
  210. package/src/people/api-models.ts +30 -30
  211. package/src/people/api-models.v2.ts +27 -27
  212. package/src/people/api-models.v4.ts +79 -79
  213. package/src/people/client.ts +73 -77
  214. package/src/people/person-details/client.ts +21 -18
  215. package/src/people/person-details/generate-endpoint.ts +16 -16
  216. package/src/people/person-details/generate-parameters.ts +8 -8
  217. package/src/people/person-details/types.ts +13 -13
  218. package/src/people/person-photo/client.ts +19 -22
  219. package/src/people/person-photo/generate-endpoint.ts +13 -13
  220. package/src/people/person-photo/generate-parameters.ts +8 -8
  221. package/src/people/person-photo/types.ts +8 -8
  222. package/src/people/query/client.ts +20 -18
  223. package/src/people/query/generate-endpoint.ts +14 -14
  224. package/src/people/query/generate-parameters.ts +8 -8
  225. package/src/people/query/types.ts +10 -10
  226. package/src/people/static.ts +2 -2
  227. package/src/people/utils.ts +20 -20
  228. package/src/provider.ts +85 -85
  229. package/src/types.ts +34 -34
  230. package/src/utils.ts +22 -26
  231. package/src/version.ts +1 -1
@@ -3,38 +3,36 @@ import { ApiVersion } from './api-version';
3
3
  import { z } from 'zod';
4
4
 
5
5
  export const ApiDateSchema = z
6
- .string()
7
- .datetime({ offset: true })
8
- .transform((x) => new Date(x));
6
+ .string()
7
+ .datetime({ offset: true })
8
+ .transform((x) => new Date(x));
9
9
 
10
10
  export const ApiPersonSchema = {
11
- [ApiVersion.v1]: z.object({
12
- azureUniqueId: z.string(),
13
- name: z.string(),
14
- mail: z.string().optional(),
15
- phoneNumber: z.string().optional(),
16
- jobTitle: z.string().optional(),
17
- accountType: z
18
- .enum(['Employee', 'Consultant', 'External', 'Application', 'Local'])
19
- .optional(),
20
- accountClassification: z.enum(['Unclassified', 'Internal', 'External']).nullish(),
21
- }),
11
+ [ApiVersion.v1]: z.object({
12
+ azureUniqueId: z.string(),
13
+ name: z.string(),
14
+ mail: z.string().optional(),
15
+ phoneNumber: z.string().optional(),
16
+ jobTitle: z.string().optional(),
17
+ accountType: z.enum(['Employee', 'Consultant', 'External', 'Application', 'Local']).optional(),
18
+ accountClassification: z.enum(['Unclassified', 'Internal', 'External']).nullish(),
19
+ }),
22
20
  };
23
21
 
24
22
  export const ApiSourceSystem = {
25
- [ApiVersion.v1]: z.object({
26
- identifier: z.string(),
27
- name: z.string().nullish(),
28
- subSystem: z.string().nullish(),
29
- }),
23
+ [ApiVersion.v1]: z.object({
24
+ identifier: z.string(),
25
+ name: z.string().nullish(),
26
+ subSystem: z.string().nullish(),
27
+ }),
30
28
  };
31
29
 
32
30
  export const ApiFusionContext = {
33
- [ApiVersion.v1]: z.object({
34
- id: z.string(),
35
- name: z.string().nullish(),
36
- type: z.string().nullish(),
37
- }),
31
+ [ApiVersion.v1]: z.object({
32
+ id: z.string(),
33
+ name: z.string().nullish(),
34
+ type: z.string().nullish(),
35
+ }),
38
36
  };
39
37
 
40
38
  /**
@@ -43,39 +41,39 @@ export const ApiFusionContext = {
43
41
  * This schema is defined for the v1 API version, and the properties are validated using the Zod library.
44
42
  */
45
43
  export const ApiBookmarkSchema = {
46
- get [ApiVersion.v1]() {
47
- return z.object({
48
- id: z.string(),
49
- name: z.string(),
50
- appKey: z.string(),
51
- description: z.string().optional(),
52
- isShared: z.boolean().optional(),
53
- context: ApiFusionContext[ApiVersion.v1].optional(),
54
- createdBy: ApiPersonSchema[ApiVersion.v1],
55
- updatedBy: ApiPersonSchema[ApiVersion.v1].optional(),
56
- created: ApiDateSchema,
57
- updated: ApiDateSchema.optional(),
58
- sourceSystem: ApiSourceSystem[ApiVersion.v1].nullish(),
59
- });
60
- },
61
- get [ApiVersion.v2]() {
62
- return this[ApiVersion.v1];
63
- },
44
+ get [ApiVersion.v1]() {
45
+ return z.object({
46
+ id: z.string(),
47
+ name: z.string(),
48
+ appKey: z.string(),
49
+ description: z.string().optional(),
50
+ isShared: z.boolean().optional(),
51
+ context: ApiFusionContext[ApiVersion.v1].optional(),
52
+ createdBy: ApiPersonSchema[ApiVersion.v1],
53
+ updatedBy: ApiPersonSchema[ApiVersion.v1].optional(),
54
+ created: ApiDateSchema,
55
+ updated: ApiDateSchema.optional(),
56
+ sourceSystem: ApiSourceSystem[ApiVersion.v1].nullish(),
57
+ });
58
+ },
59
+ get [ApiVersion.v2]() {
60
+ return this[ApiVersion.v1];
61
+ },
64
62
  };
65
63
 
66
64
  export const ApiBookmarkPayload = {
67
- get [ApiVersion.v1]() {
68
- return z
69
- .record(z.unknown())
70
- .or(z.string())
71
- .optional()
72
- .default('')
73
- .transform((x) => {
74
- try {
75
- return typeof x === 'string' ? JSON.parse(x) : x;
76
- } catch {
77
- return x;
78
- }
79
- });
80
- },
65
+ get [ApiVersion.v1]() {
66
+ return z
67
+ .record(z.unknown())
68
+ .or(z.string())
69
+ .optional()
70
+ .default('')
71
+ .transform((x) => {
72
+ try {
73
+ return typeof x === 'string' ? JSON.parse(x) : x;
74
+ } catch {
75
+ return x;
76
+ }
77
+ });
78
+ },
81
79
  };
@@ -1,5 +1,5 @@
1
1
  import { HttpJsonResponseError, HttpResponseError } from '@equinor/fusion-framework-module-http';
2
- import { type ResponseSelector } from '@equinor/fusion-framework-module-http/selectors';
2
+ import type { ResponseSelector } from '@equinor/fusion-framework-module-http/selectors';
3
3
 
4
4
  /**
5
5
  * A response selector that checks the status of an HTTP response and throws an error if the response is not successful.
@@ -9,23 +9,23 @@ import { type ResponseSelector } from '@equinor/fusion-framework-module-http/sel
9
9
  * @throws {HttpJsonResponseError} If the response is not successful, with the error message, response, and any additional data or cause.
10
10
  */
11
11
  export const statusSelector: ResponseSelector<boolean> = async (res) => {
12
- if (res.ok) {
13
- return true;
12
+ if (res.ok) {
13
+ return true;
14
+ }
15
+ const message = `Failed to execute request. Status code: ${res.status}`;
16
+ let cause: unknown;
17
+ let data: unknown;
18
+ switch (res.status) {
19
+ case 403:
20
+ case 404: {
21
+ try {
22
+ data = await res.json();
23
+ } catch (error) {
24
+ cause = error;
25
+ }
14
26
  }
15
- const message = `Failed to execute request. Status code: ${res.status}`;
16
- let cause: unknown;
17
- let data: unknown;
18
- switch (res.status) {
19
- case 403:
20
- case 404: {
21
- try {
22
- data = await res.json();
23
- } catch (error) {
24
- cause = error;
25
- }
26
- }
27
- }
28
- throw new HttpJsonResponseError(message, res, { cause, data });
27
+ }
28
+ throw new HttpJsonResponseError(message, res, { cause, data });
29
29
  };
30
30
 
31
31
  /**
@@ -36,11 +36,11 @@ export const statusSelector: ResponseSelector<boolean> = async (res) => {
36
36
  * @throws {HttpJsonResponseError} If the response is not successful and does not have a 404 status code, with the error message, response, and any additional data or cause.
37
37
  */
38
38
  export const headSelector: ResponseSelector<boolean> = async (res) => {
39
- if (res.ok) {
40
- return true;
41
- }
42
- if (res.status === 404) {
43
- return false;
44
- }
45
- throw new HttpResponseError(`Failed to execute request. Status code: ${res.status}`, res);
39
+ if (res.ok) {
40
+ return true;
41
+ }
42
+ if (res.status === 404) {
43
+ return false;
44
+ }
45
+ throw new HttpResponseError(`Failed to execute request. Status code: ${res.status}`, res);
46
46
  };
@@ -1,16 +1,16 @@
1
1
  import type {
2
- FilterAllowedApiVersions as FilterAllowApiVersionsBase,
3
- ExtractApiVersion as ExtractApiVersionBase,
2
+ FilterAllowedApiVersions as FilterAllowApiVersionsBase,
3
+ ExtractApiVersion as ExtractApiVersionBase,
4
4
  } from '../types';
5
5
 
6
- import { ApiVersion } from './api-version';
6
+ import type { ApiVersion } from './api-version';
7
7
 
8
8
  export { ClientMethodType, ClientMethod, ApiClientArguments } from '../types';
9
9
 
10
10
  export type FilterAllowedApiVersions<TAllowed extends string = keyof typeof ApiVersion> =
11
- FilterAllowApiVersionsBase<typeof ApiVersion, TAllowed>;
11
+ FilterAllowApiVersionsBase<typeof ApiVersion, TAllowed>;
12
12
 
13
13
  export type ExtractApiVersion<
14
- TVersion extends string,
15
- TAllowed extends string = FilterAllowedApiVersions,
14
+ TVersion extends string,
15
+ TAllowed extends string = FilterAllowedApiVersions,
16
16
  > = ExtractApiVersionBase<typeof ApiVersion, TVersion, TAllowed>;
@@ -1,8 +1,8 @@
1
- import { ApiClientFactory } from './types';
1
+ import type { ApiClientFactory } from './types';
2
2
 
3
3
  export interface IApiConfigurator {
4
- /** Method for creating IHttpClients */
5
- createClient?: ApiClientFactory;
4
+ /** Method for creating IHttpClients */
5
+ createClient?: ApiClientFactory;
6
6
  }
7
7
 
8
8
  export class ApiConfigurator implements IApiConfigurator {}
@@ -1,42 +1,42 @@
1
1
  import { ApiVersion } from './static';
2
2
 
3
3
  type ApiContextEntity_v1 = {
4
- id: string;
5
- externalId: string | null;
6
- source: string | null;
7
- type: ApiContextType_v1;
8
- value: Record<string, unknown> | null;
9
- title: string | null;
10
- isActive: boolean;
11
- isDeleted: boolean;
12
- created: string;
13
- updated: string | null;
4
+ id: string;
5
+ externalId: string | null;
6
+ source: string | null;
7
+ type: ApiContextType_v1;
8
+ value: Record<string, unknown> | null;
9
+ title: string | null;
10
+ isActive: boolean;
11
+ isDeleted: boolean;
12
+ created: string;
13
+ updated: string | null;
14
14
  };
15
15
 
16
16
  type ApiContextEntity_v2 = unknown;
17
17
 
18
18
  type ApiContextEntityTypes = {
19
- [ApiVersion.v1]: ApiContextEntity_v1;
20
- [ApiVersion.v2]: ApiContextEntity_v2;
19
+ [ApiVersion.v1]: ApiContextEntity_v1;
20
+ [ApiVersion.v2]: ApiContextEntity_v2;
21
21
  };
22
22
 
23
23
  export type ApiContextEntity<T extends string = ApiVersion> = T extends ApiVersion
24
- ? ApiContextEntityTypes[T]
25
- : unknown;
24
+ ? ApiContextEntityTypes[T]
25
+ : unknown;
26
26
 
27
27
  /** === types === */
28
28
 
29
29
  type ApiContextType_v1 = {
30
- id: string;
31
- isChildType: boolean;
32
- parentTypeIds: string[] | null;
30
+ id: string;
31
+ isChildType: boolean;
32
+ parentTypeIds: string[] | null;
33
33
  };
34
34
 
35
35
  type ApiContextType_v2 = unknown;
36
36
 
37
37
  type ApiContextTypeTypes = {
38
- [ApiVersion.v1]: ApiContextType_v1;
39
- [ApiVersion.v2]: ApiContextType_v2;
38
+ [ApiVersion.v1]: ApiContextType_v1;
39
+ [ApiVersion.v2]: ApiContextType_v2;
40
40
  };
41
41
 
42
42
  export type ApiContextType<T extends ApiVersion> = ApiContextTypeTypes[T];
@@ -1,76 +1,86 @@
1
- import { IHttpClient } from '@equinor/fusion-framework-module-http';
1
+ import type { IHttpClient } from '@equinor/fusion-framework-module-http';
2
2
 
3
3
  import type { ClientMethod } from './types';
4
4
  import { ApiVersion } from './static';
5
5
 
6
- import { getContext, GetContextFn, GetContextResponse, GetContextResult } from './get';
6
+ import {
7
+ getContext,
8
+ type GetContextFn,
9
+ type GetContextResponse,
10
+ type GetContextResult,
11
+ } from './get';
7
12
 
8
- import { queryContext, QueryContextFn, QueryContextResponse, QueryContextResult } from './query';
13
+ import {
14
+ queryContext,
15
+ type QueryContextFn,
16
+ type QueryContextResponse,
17
+ type QueryContextResult,
18
+ } from './query';
9
19
 
10
20
  import {
11
- RelatedContextFn,
12
- RelatedContextResponse,
13
- RelatedContextResult,
14
- relatedContexts,
21
+ type RelatedContextFn,
22
+ type RelatedContextResponse,
23
+ type RelatedContextResult,
24
+ relatedContexts,
15
25
  } from './related';
16
26
 
17
27
  export class ContextApiClient<
18
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
19
- TClient extends IHttpClient = IHttpClient,
28
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
29
+ TClient extends IHttpClient = IHttpClient,
20
30
  > {
21
- get Version(): typeof ApiVersion {
22
- return ApiVersion;
23
- }
31
+ get Version(): typeof ApiVersion {
32
+ return ApiVersion;
33
+ }
24
34
 
25
- constructor(
26
- protected _client: TClient,
27
- protected _method: TMethod,
28
- ) {}
35
+ constructor(
36
+ protected _client: TClient,
37
+ protected _method: TMethod,
38
+ ) {}
29
39
 
30
- /**
31
- * Fetch context by id
32
- * @see {@link get/client}
33
- */
34
- public get<
35
- TVersion extends string = keyof typeof ApiVersion,
36
- TResult = GetContextResponse<TVersion>,
37
- >(
38
- version: TVersion,
39
- ...args: Parameters<GetContextFn<TVersion, TMethod, TClient, TResult>>
40
- ): GetContextResult<TVersion, TMethod, TResult> {
41
- const fn = getContext<TVersion, TMethod, TClient>(this._client, version, this._method);
42
- return fn<TResult>(...args);
43
- }
40
+ /**
41
+ * Fetch context by id
42
+ * @see {@link get/client}
43
+ */
44
+ public get<
45
+ TVersion extends string = keyof typeof ApiVersion,
46
+ TResult = GetContextResponse<TVersion>,
47
+ >(
48
+ version: TVersion,
49
+ ...args: Parameters<GetContextFn<TVersion, TMethod, TClient, TResult>>
50
+ ): GetContextResult<TVersion, TMethod, TResult> {
51
+ const fn = getContext<TVersion, TMethod, TClient>(this._client, version, this._method);
52
+ return fn<TResult>(...args);
53
+ }
44
54
 
45
- /**
46
- * Query context service
47
- * @see {@link query/client}
48
- */
49
- public query<
50
- TVersion extends string = keyof typeof ApiVersion,
51
- TResult = QueryContextResponse<TVersion>,
52
- >(
53
- version: TVersion,
54
- ...args: Parameters<QueryContextFn<TVersion, TMethod, TClient, TResult>>
55
- ): QueryContextResult<TVersion, TMethod, TResult> {
56
- const fn = queryContext<TVersion, TMethod, TClient>(this._client, version, this._method);
57
- return fn<TResult>(...args);
58
- }
55
+ /**
56
+ * Query context service
57
+ * @see {@link query/client}
58
+ */
59
+ public query<
60
+ TVersion extends string = keyof typeof ApiVersion,
61
+ TResult = QueryContextResponse<TVersion>,
62
+ >(
63
+ version: TVersion,
64
+ ...args: Parameters<QueryContextFn<TVersion, TMethod, TClient, TResult>>
65
+ ): QueryContextResult<TVersion, TMethod, TResult> {
66
+ const fn = queryContext<TVersion, TMethod, TClient>(this._client, version, this._method);
67
+ return fn<TResult>(...args);
68
+ }
59
69
 
60
- /**
61
- * Query context service
62
- * @see {@link query/client}
63
- */
64
- public related<
65
- TVersion extends string = keyof typeof ApiVersion,
66
- TResult = RelatedContextResponse<TVersion>,
67
- >(
68
- version: TVersion,
69
- ...args: Parameters<RelatedContextFn<TVersion, TMethod, TClient, TResult>>
70
- ): RelatedContextResult<TVersion, TMethod, TResult> {
71
- const fn = relatedContexts<TVersion, TMethod, TClient>(this._client, version, this._method);
72
- return fn<TResult>(...args);
73
- }
70
+ /**
71
+ * Query context service
72
+ * @see {@link query/client}
73
+ */
74
+ public related<
75
+ TVersion extends string = keyof typeof ApiVersion,
76
+ TResult = RelatedContextResponse<TVersion>,
77
+ >(
78
+ version: TVersion,
79
+ ...args: Parameters<RelatedContextFn<TVersion, TMethod, TClient, TResult>>
80
+ ): RelatedContextResult<TVersion, TMethod, TResult> {
81
+ const fn = relatedContexts<TVersion, TMethod, TClient>(this._client, version, this._method);
82
+ return fn<TResult>(...args);
83
+ }
74
84
  }
75
85
 
76
86
  export default ContextApiClient;
@@ -1,6 +1,6 @@
1
- import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
1
+ import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
 
3
- import { ApiVersion } from '..';
3
+ import type { ApiVersion } from '..';
4
4
 
5
5
  import { generateParameters } from './generate-parameters';
6
6
 
@@ -13,21 +13,21 @@ import type { ClientMethod, GetContextArgs, GetContextResponse, GetContextResult
13
13
  * @param method - client method to call
14
14
  */
15
15
  export const getContext =
16
- <
17
- TVersion extends string = keyof typeof ApiVersion,
18
- TMethod extends keyof ClientMethod = keyof ClientMethod,
19
- TClient extends IHttpClient = IHttpClient,
20
- >(
21
- client: TClient,
22
- version: TVersion,
23
- method: TMethod = 'json' as TMethod,
24
- ) =>
25
- <T = GetContextResponse<TVersion>>(
26
- args: GetContextArgs<TVersion>,
27
- init?: ClientRequestInit<TClient, T>,
28
- ): GetContextResult<TVersion, TMethod, T> =>
29
- client[method](
30
- ...generateParameters<T, TVersion, TClient>(version, args, init),
31
- ) as GetContextResult<TVersion, TMethod, T>;
16
+ <
17
+ TVersion extends string = keyof typeof ApiVersion,
18
+ TMethod extends keyof ClientMethod = keyof ClientMethod,
19
+ TClient extends IHttpClient = IHttpClient,
20
+ >(
21
+ client: TClient,
22
+ version: TVersion,
23
+ method: TMethod = 'json' as TMethod,
24
+ ) =>
25
+ <T = GetContextResponse<TVersion>>(
26
+ args: GetContextArgs<TVersion>,
27
+ init?: ClientRequestInit<TClient, T>,
28
+ ): GetContextResult<TVersion, TMethod, T> =>
29
+ client[method](
30
+ ...generateParameters<T, TVersion, TClient>(version, args, init),
31
+ ) as GetContextResult<TVersion, TMethod, T>;
32
32
 
33
33
  export default getContext;
@@ -7,19 +7,18 @@ import type { GetContextArgs } from './types';
7
7
  * Method for generating endpoint for getting context by id
8
8
  */
9
9
  export const generateEndpoint = <TVersion extends string = keyof typeof ApiVersion>(
10
- version: TVersion,
11
- args: GetContextArgs<TVersion>,
12
- ) => {
13
- const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
14
- switch (apiVersion) {
15
- case ApiVersion.v2:
16
- throw new UnsupportedApiVersion(version);
17
- case ApiVersion.v1:
18
- default: {
19
- const { id } = args as { id: string };
20
- const params = new URLSearchParams();
21
- params.append('api-version', apiVersion);
22
- return `/contexts/${id}/?${String(params)}`;
23
- }
10
+ version: TVersion,
11
+ args: GetContextArgs<TVersion>,
12
+ ): string => {
13
+ const apiVersion = ApiVersion[version as keyof typeof ApiVersion] ?? version;
14
+ switch (apiVersion) {
15
+ case ApiVersion.v2:
16
+ throw new UnsupportedApiVersion(version);
17
+ default: {
18
+ const { id } = args as { id: string };
19
+ const params = new URLSearchParams();
20
+ params.append('api-version', apiVersion);
21
+ return `/contexts/${id}/?${String(params)}`;
24
22
  }
23
+ }
25
24
  };
@@ -1,6 +1,6 @@
1
1
  import type { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
2
 
3
- import { ApiVersion } from '..';
3
+ import type { ApiVersion } from '..';
4
4
 
5
5
  import { generateEndpoint } from './generate-endpoint';
6
6
 
@@ -8,16 +8,16 @@ import type { ApiClientArguments, GetContextArgs } from './types';
8
8
 
9
9
  /** function for creating http client arguments */
10
10
  export const generateParameters = <
11
- TResult,
12
- TVersion extends string = keyof typeof ApiVersion,
13
- TClient extends IHttpClient = IHttpClient,
11
+ TResult,
12
+ TVersion extends string = keyof typeof ApiVersion,
13
+ TClient extends IHttpClient = IHttpClient,
14
14
  >(
15
- version: TVersion,
16
- args: GetContextArgs<TVersion>,
17
- init?: ClientRequestInit<TClient, TResult>,
15
+ version: TVersion,
16
+ args: GetContextArgs<TVersion>,
17
+ init?: ClientRequestInit<TClient, TResult>,
18
18
  ): ApiClientArguments<TClient, TResult> => {
19
- const path = generateEndpoint(version, args);
20
- return [path, init];
19
+ const path = generateEndpoint(version, args);
20
+ return [path, init];
21
21
  };
22
22
 
23
23
  export default generateParameters;
@@ -1,45 +1,45 @@
1
- import { IHttpClient, ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
1
+ import type { IHttpClient, ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
2
2
 
3
- import { ApiVersion, ApiContextEntity, ClientMethod } from '..';
3
+ import { ApiVersion, type ApiContextEntity, type ClientMethod } from '..';
4
4
 
5
5
  export { ApiClientArguments, ClientMethod } from '..';
6
6
 
7
7
  type GetContextArgs_v1 = {
8
- id: string;
8
+ id: string;
9
9
  };
10
10
 
11
11
  type GetContextArgs_v2 = GetContextArgs_v1;
12
12
 
13
13
  type GetContextArgsTypes = {
14
- [ApiVersion.v1]: GetContextArgs_v1;
15
- [ApiVersion.v2]: GetContextArgs_v2;
14
+ [ApiVersion.v1]: GetContextArgs_v1;
15
+ [ApiVersion.v2]: GetContextArgs_v2;
16
16
  };
17
17
 
18
18
  export type GetContextArgs<T extends string> = T extends keyof typeof ApiVersion
19
- ? GetContextArgsTypes[(typeof ApiVersion)[T]]
20
- : unknown;
19
+ ? GetContextArgsTypes[(typeof ApiVersion)[T]]
20
+ : unknown;
21
21
 
22
22
  type GetContextResponseTypes = {
23
- [ApiVersion.v1]: ApiContextEntity<ApiVersion.v1>;
24
- [ApiVersion.v2]: ApiContextEntity<ApiVersion.v2>;
23
+ [ApiVersion.v1]: ApiContextEntity<ApiVersion.v1>;
24
+ [ApiVersion.v2]: ApiContextEntity<ApiVersion.v2>;
25
25
  };
26
26
 
27
27
  export type GetContextResponse<T> = T extends keyof typeof ApiVersion
28
- ? GetContextResponseTypes[(typeof ApiVersion)[T]]
29
- : unknown;
28
+ ? GetContextResponseTypes[(typeof ApiVersion)[T]]
29
+ : unknown;
30
30
 
31
31
  export type GetContextFn<
32
- TVersion extends string = keyof typeof ApiVersion,
33
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
34
- TClient extends IHttpClient = IHttpClient,
35
- TResult = GetContextResponse<TVersion>,
32
+ TVersion extends string = keyof typeof ApiVersion,
33
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
34
+ TClient extends IHttpClient = IHttpClient,
35
+ TResult = GetContextResponse<TVersion>,
36
36
  > = (
37
- args: GetContextArgs<TVersion>,
38
- init?: ClientRequestInit<TClient, TResult>,
37
+ args: GetContextArgs<TVersion>,
38
+ init?: ClientRequestInit<TClient, TResult>,
39
39
  ) => GetContextResult<TVersion, TMethod, TResult>;
40
40
 
41
41
  export type GetContextResult<
42
- TVersion extends string = keyof typeof ApiVersion,
43
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
44
- TResult = GetContextResponse<TVersion>,
42
+ TVersion extends string = keyof typeof ApiVersion,
43
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
44
+ TResult = GetContextResponse<TVersion>,
45
45
  > = ClientMethod<TResult>[TMethod];