@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
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  import type {
4
- ClientRequestInit,
5
- FetchRequestInit,
6
- IHttpClient,
7
- JsonRequest,
4
+ ClientRequestInit,
5
+ FetchRequestInit,
6
+ IHttpClient,
7
+ JsonRequest,
8
8
  } from '@equinor/fusion-framework-module-http/client';
9
9
 
10
10
  import type { ClientMethod, ExtractApiVersion, FilterAllowedApiVersions } from '../types';
@@ -21,115 +21,115 @@ type AllowedVersions = FilterAllowedApiVersions<AvailableVersions>;
21
21
 
22
22
  /** Schema for the input arguments to this operation. */
23
23
  const ArgSchema = {
24
- [ApiVersion.v1]: z.object({
25
- bookmarkId: z.string(),
26
- updates: z.object({
27
- name: z.string().nullish(),
28
- description: z.string().nullish(),
29
- isShared: z.boolean().nullish(),
30
- payload: z
31
- .record(z.unknown())
32
- .or(z.string())
33
- .nullish()
34
- .transform((x) => (typeof x === 'object' ? JSON.stringify(x) : x)),
35
- sourceSystem: z
36
- .object({
37
- identifier: z.string().nullish(),
38
- name: z.string().nullish(),
39
- subSystem: z.string().nullish(),
40
- })
41
- .nullish(),
42
- }),
24
+ [ApiVersion.v1]: z.object({
25
+ bookmarkId: z.string(),
26
+ updates: z.object({
27
+ name: z.string().nullish(),
28
+ description: z.string().nullish(),
29
+ isShared: z.boolean().nullish(),
30
+ payload: z
31
+ .record(z.unknown())
32
+ .or(z.string())
33
+ .nullish()
34
+ .transform((x) => (typeof x === 'object' ? JSON.stringify(x) : x)),
35
+ sourceSystem: z
36
+ .object({
37
+ identifier: z.string().nullish(),
38
+ name: z.string().nullish(),
39
+ subSystem: z.string().nullish(),
40
+ })
41
+ .nullish(),
43
42
  }),
43
+ }),
44
44
  };
45
45
 
46
46
  /** Schema for the response from the API. */
47
47
  const ApiResponseSchema = {
48
- [ApiVersion.v1]: ApiBookmarkSchema[ApiVersion.v1].and(
49
- z.object({
50
- payload: ApiBookmarkPayload[ApiVersion.v1].optional(),
51
- }),
52
- ),
48
+ [ApiVersion.v1]: ApiBookmarkSchema[ApiVersion.v1].and(
49
+ z.object({
50
+ payload: ApiBookmarkPayload[ApiVersion.v1].optional(),
51
+ }),
52
+ ),
53
53
  };
54
54
 
55
55
  /** Defines the expected output from the api. */
56
56
  type ApiResponse<TVersion extends AllowedVersions> = z.infer<
57
- (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
57
+ (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
58
58
  >;
59
59
 
60
60
  /** Defines the input arguments to this operation. */
61
61
  type MethodArg<TVersion extends AllowedVersions> = z.input<
62
- (typeof ArgSchema)[ExtractApiVersion<TVersion>]
62
+ (typeof ArgSchema)[ExtractApiVersion<TVersion>]
63
63
  >;
64
64
 
65
65
  /** Defines the expected output of this operation. */
66
66
  type MethodResult<
67
- TVersion extends AllowedVersions,
68
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
69
- TResult = ApiResponse<TVersion>,
67
+ TVersion extends AllowedVersions,
68
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
69
+ TResult = ApiResponse<TVersion>,
70
70
  > = ClientMethod<TResult>[TMethod];
71
71
 
72
72
  /** utility function for generating http request initialization parameters */
73
73
  const generateRequestParameters = <TResult, TVersion extends AvailableVersions>(
74
- version: TVersion,
75
- args: z.infer<(typeof ArgSchema)[TVersion]>,
76
- init?: ClientRequestInit<IHttpClient, TResult>,
74
+ version: TVersion,
75
+ args: z.infer<(typeof ArgSchema)[TVersion]>,
76
+ init?: ClientRequestInit<IHttpClient, TResult>,
77
77
  ): ClientRequestInit<IHttpClient, TResult> => {
78
- switch (version) {
79
- case ApiVersion.v1: {
80
- const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
81
- method: 'PATCH',
82
- selector: schemaSelector(ApiResponseSchema[version]),
83
- body: args.updates,
84
- };
85
- return Object.assign({}, baseInit, init);
86
- }
78
+ switch (version) {
79
+ case ApiVersion.v1: {
80
+ const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
81
+ method: 'PATCH',
82
+ selector: schemaSelector(ApiResponseSchema[version]),
83
+ body: args.updates,
84
+ };
85
+ return Object.assign({}, baseInit, init);
87
86
  }
88
- throw Error(`Unknown API version: ${version}`);
87
+ }
88
+ throw Error(`Unknown API version: ${version}`);
89
89
  };
90
90
 
91
91
  /** utility function for generating the api path */
92
92
  const generateApiPath = <TVersion extends AvailableVersions>(
93
- version: TVersion,
94
- args: z.infer<(typeof ArgSchema)[TVersion]>,
93
+ version: TVersion,
94
+ args: z.infer<(typeof ArgSchema)[TVersion]>,
95
95
  ): string => {
96
- switch (version) {
97
- case ApiVersion.v1: {
98
- const params = new URLSearchParams();
99
- params.append('api-version', version);
100
- return `/bookmarks/${args.bookmarkId}?${String(params)}`;
101
- }
96
+ switch (version) {
97
+ case ApiVersion.v1: {
98
+ const params = new URLSearchParams();
99
+ params.append('api-version', version);
100
+ return `/bookmarks/${args.bookmarkId}?${String(params)}`;
102
101
  }
103
- throw Error(`Unknown API version: ${version}`);
102
+ }
103
+ throw Error(`Unknown API version: ${version}`);
104
104
  };
105
105
 
106
106
  /** executes the api call */
107
107
  const executeApiCall = <TVersion extends AllowedVersions, TMethod extends keyof ClientMethod>(
108
- version: TVersion,
109
- client: IHttpClient,
110
- method: TMethod = 'json' as TMethod,
108
+ version: TVersion,
109
+ client: IHttpClient,
110
+ method: TMethod = 'json' as TMethod,
111
111
  ) => {
112
- type MethodVersion = ExtractApiVersion<TVersion>;
113
- const apiVersion = extractVersion(ApiVersion, version);
114
- return <
115
- TResponse = ApiResponse<MethodVersion>,
116
- TResult = MethodResult<MethodVersion, TMethod, TResponse>,
117
- >(
118
- input: MethodArg<MethodVersion>,
119
- init?: ClientRequestInit<IHttpClient, TResponse>,
120
- ): TResult => {
121
- const args = ArgSchema[apiVersion].parse(input);
122
- return client[method](
123
- generateApiPath(apiVersion, args),
124
- generateRequestParameters(apiVersion, args, init),
125
- ) as TResult;
126
- };
112
+ type MethodVersion = ExtractApiVersion<TVersion>;
113
+ const apiVersion = extractVersion(ApiVersion, version);
114
+ return <
115
+ TResponse = ApiResponse<MethodVersion>,
116
+ TResult = MethodResult<MethodVersion, TMethod, TResponse>,
117
+ >(
118
+ input: MethodArg<MethodVersion>,
119
+ init?: ClientRequestInit<IHttpClient, TResponse>,
120
+ ): TResult => {
121
+ const args = ArgSchema[apiVersion].parse(input);
122
+ return client[method](
123
+ generateApiPath(apiVersion, args),
124
+ generateRequestParameters(apiVersion, args, init),
125
+ ) as TResult;
126
+ };
127
127
  };
128
128
 
129
129
  export {
130
- AllowedVersions as PatchBookmarkVersion,
131
- MethodArg as PatchBookmarkArg,
132
- ApiResponse as PatchBookmarkResponse,
133
- MethodResult as PatchBookmarksResult,
134
- executeApiCall as patchBookmark,
130
+ type AllowedVersions as PatchBookmarkVersion,
131
+ type MethodArg as PatchBookmarkArg,
132
+ type ApiResponse as PatchBookmarkResponse,
133
+ type MethodResult as PatchBookmarksResult,
134
+ executeApiCall as patchBookmark,
135
135
  };
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  import type {
4
- ClientRequestInit,
5
- FetchRequestInit,
6
- IHttpClient,
7
- JsonRequest,
4
+ ClientRequestInit,
5
+ FetchRequestInit,
6
+ IHttpClient,
7
+ JsonRequest,
8
8
  } from '@equinor/fusion-framework-module-http/client';
9
9
 
10
10
  import type { ClientMethod, ExtractApiVersion, FilterAllowedApiVersions } from '../types';
@@ -21,104 +21,104 @@ type AllowedVersions = FilterAllowedApiVersions<AvailableVersions>;
21
21
 
22
22
  /** Schema for the input arguments to this operation. */
23
23
  const ArgSchema = {
24
- [ApiVersion.v1]: z.object({
25
- name: z.string(),
26
- appKey: z.string(),
27
- payload: z.record(z.unknown()).or(z.string()).optional(),
28
- description: z.string().nullish(),
29
- isShared: z.boolean().nullish(),
30
- contextId: z.string().nullish(),
31
- sourceSystem: ApiSourceSystem[ApiVersion.v1].nullish(),
32
- }),
24
+ [ApiVersion.v1]: z.object({
25
+ name: z.string(),
26
+ appKey: z.string(),
27
+ payload: z.record(z.unknown()).or(z.string()).optional(),
28
+ description: z.string().nullish(),
29
+ isShared: z.boolean().nullish(),
30
+ contextId: z.string().nullish(),
31
+ sourceSystem: ApiSourceSystem[ApiVersion.v1].nullish(),
32
+ }),
33
33
  };
34
34
 
35
35
  /** Schema for the response from the API. */
36
36
  const ApiResponseSchema = {
37
- [ApiVersion.v1]: ApiBookmarkSchema[ApiVersion.v1].and(
38
- z.object({
39
- payload: ApiBookmarkPayload[ApiVersion.v1].optional(),
40
- }),
41
- ),
37
+ [ApiVersion.v1]: ApiBookmarkSchema[ApiVersion.v1].and(
38
+ z.object({
39
+ payload: ApiBookmarkPayload[ApiVersion.v1].optional(),
40
+ }),
41
+ ),
42
42
  };
43
43
 
44
44
  /** Defines the expected output from the api. */
45
45
  type ApiResponse<TVersion extends AllowedVersions> = z.infer<
46
- (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
46
+ (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
47
47
  >;
48
48
 
49
49
  /** Defines the input arguments to this operation. */
50
50
  type MethodArg<TVersion extends AllowedVersions> = z.input<
51
- (typeof ArgSchema)[ExtractApiVersion<TVersion>]
51
+ (typeof ArgSchema)[ExtractApiVersion<TVersion>]
52
52
  >;
53
53
 
54
54
  /** Defines the expected output of this operation. */
55
55
  type MethodResult<
56
- TVersion extends AllowedVersions,
57
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
58
- TResult = ApiResponse<TVersion>,
56
+ TVersion extends AllowedVersions,
57
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
58
+ TResult = ApiResponse<TVersion>,
59
59
  > = ClientMethod<TResult>[TMethod];
60
60
 
61
61
  /** utility function for generating http request initialization parameters */
62
62
  const generateRequestParameters = <TResult, TVersion extends AvailableVersions>(
63
- version: TVersion,
64
- args: z.infer<(typeof ArgSchema)[TVersion]>,
65
- init?: ClientRequestInit<IHttpClient, TResult>,
63
+ version: TVersion,
64
+ args: z.infer<(typeof ArgSchema)[TVersion]>,
65
+ init?: ClientRequestInit<IHttpClient, TResult>,
66
66
  ): ClientRequestInit<IHttpClient, TResult> => {
67
- switch (version) {
68
- case ApiVersion.v1: {
69
- const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
70
- method: 'POST',
71
- selector: schemaSelector(ApiResponseSchema[version]),
72
- body: args,
73
- };
74
- return Object.assign({}, baseInit, init);
75
- }
67
+ switch (version) {
68
+ case ApiVersion.v1: {
69
+ const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
70
+ method: 'POST',
71
+ selector: schemaSelector(ApiResponseSchema[version]),
72
+ body: args,
73
+ };
74
+ return Object.assign({}, baseInit, init);
76
75
  }
77
- throw Error(`Unknown API version: ${version}`);
76
+ }
77
+ throw Error(`Unknown API version: ${version}`);
78
78
  };
79
79
 
80
80
  /** utility function for generating the api path */
81
81
  const generateApiPath = <TVersion extends AvailableVersions>(
82
- version: TVersion,
83
- _args: z.infer<(typeof ArgSchema)[TVersion]>,
82
+ version: TVersion,
83
+ _args: z.infer<(typeof ArgSchema)[TVersion]>,
84
84
  ): string => {
85
- switch (version) {
86
- case ApiVersion.v1: {
87
- const params = new URLSearchParams();
88
- params.append('api-version', version);
89
- return `/bookmarks?${String(params)}`;
90
- }
85
+ switch (version) {
86
+ case ApiVersion.v1: {
87
+ const params = new URLSearchParams();
88
+ params.append('api-version', version);
89
+ return `/bookmarks?${String(params)}`;
91
90
  }
92
- throw Error(`Unknown API version: ${version}`);
91
+ }
92
+ throw Error(`Unknown API version: ${version}`);
93
93
  };
94
94
 
95
95
  /** executes the api call */
96
96
  const executeApiCall = <TVersion extends AllowedVersions, TMethod extends keyof ClientMethod>(
97
- version: TVersion,
98
- client: IHttpClient,
99
- method: TMethod = 'json' as TMethod,
97
+ version: TVersion,
98
+ client: IHttpClient,
99
+ method: TMethod = 'json' as TMethod,
100
100
  ) => {
101
- type MethodVersion = ExtractApiVersion<TVersion>;
102
- const apiVersion = extractVersion(ApiVersion, version);
103
- return <
104
- TResponse = ApiResponse<MethodVersion>,
105
- TResult = MethodResult<MethodVersion, TMethod, TResponse>,
106
- >(
107
- input: MethodArg<MethodVersion>,
108
- init?: ClientRequestInit<IHttpClient, TResponse>,
109
- ): TResult => {
110
- const args = ArgSchema[apiVersion].parse(input);
111
- return client[method](
112
- generateApiPath(apiVersion, args),
113
- generateRequestParameters(apiVersion, args, init),
114
- ) as TResult;
115
- };
101
+ type MethodVersion = ExtractApiVersion<TVersion>;
102
+ const apiVersion = extractVersion(ApiVersion, version);
103
+ return <
104
+ TResponse = ApiResponse<MethodVersion>,
105
+ TResult = MethodResult<MethodVersion, TMethod, TResponse>,
106
+ >(
107
+ input: MethodArg<MethodVersion>,
108
+ init?: ClientRequestInit<IHttpClient, TResponse>,
109
+ ): TResult => {
110
+ const args = ArgSchema[apiVersion].parse(input);
111
+ return client[method](
112
+ generateApiPath(apiVersion, args),
113
+ generateRequestParameters(apiVersion, args, init),
114
+ ) as TResult;
115
+ };
116
116
  };
117
117
 
118
118
  export {
119
- AllowedVersions as CreateBookmarkVersion,
120
- MethodArg as CreateBookmarkArg,
121
- ApiResponse as CreateBookmarkResponse,
122
- MethodResult as CreateBookmarksResult,
123
- executeApiCall as createBookmark,
119
+ type AllowedVersions as CreateBookmarkVersion,
120
+ type MethodArg as CreateBookmarkArg,
121
+ type ApiResponse as CreateBookmarkResponse,
122
+ type MethodResult as CreateBookmarksResult,
123
+ executeApiCall as createBookmark,
124
124
  };
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  import type {
4
- ClientRequestInit,
5
- FetchRequestInit,
6
- IHttpClient,
7
- JsonRequest,
4
+ ClientRequestInit,
5
+ FetchRequestInit,
6
+ IHttpClient,
7
+ JsonRequest,
8
8
  } from '@equinor/fusion-framework-module-http/client';
9
9
 
10
10
  import type { ClientMethod, ExtractApiVersion, FilterAllowedApiVersions } from '../types';
@@ -21,93 +21,93 @@ type AllowedVersions = FilterAllowedApiVersions<AvailableVersions>;
21
21
 
22
22
  /** Schema for the input arguments to this operation. */
23
23
  const ArgSchema = {
24
- [ApiVersion.v1]: z.object({
25
- bookmarkId: z.string(),
26
- }),
24
+ [ApiVersion.v1]: z.object({
25
+ bookmarkId: z.string(),
26
+ }),
27
27
  };
28
28
 
29
29
  /** Schema for the response from the API. */
30
30
  const ApiResponseSchema = {
31
- [ApiVersion.v1]: z.boolean(),
31
+ [ApiVersion.v1]: z.boolean(),
32
32
  };
33
33
 
34
34
  /** Defines the expected output from the api. */
35
35
  type ApiResponse<TVersion extends AllowedVersions> = z.infer<
36
- (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
36
+ (typeof ApiResponseSchema)[ExtractApiVersion<TVersion>]
37
37
  >;
38
38
 
39
39
  /** Defines the input arguments to this operation. */
40
40
  type MethodArg<TVersion extends AllowedVersions> = z.input<
41
- (typeof ArgSchema)[ExtractApiVersion<TVersion>]
41
+ (typeof ArgSchema)[ExtractApiVersion<TVersion>]
42
42
  >;
43
43
 
44
44
  /** Defines the expected output of this operation. */
45
45
  type MethodResult<
46
- TVersion extends AllowedVersions,
47
- TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
48
- TResult = ApiResponse<TVersion>,
46
+ TVersion extends AllowedVersions,
47
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
48
+ TResult = ApiResponse<TVersion>,
49
49
  > = ClientMethod<TResult>[TMethod];
50
50
 
51
51
  /** utility function for generating http request initialization parameters */
52
52
  const generateRequestParameters = <TResult, TVersion extends AvailableVersions>(
53
- version: TVersion,
54
- args: z.infer<(typeof ArgSchema)[TVersion]>,
55
- init?: ClientRequestInit<IHttpClient, TResult>,
53
+ version: TVersion,
54
+ args: z.infer<(typeof ArgSchema)[TVersion]>,
55
+ init?: ClientRequestInit<IHttpClient, TResult>,
56
56
  ): ClientRequestInit<IHttpClient, TResult> => {
57
- switch (version) {
58
- case ApiVersion.v1: {
59
- const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
60
- method: 'DELETE',
61
- selector: statusSelector,
62
- };
63
- return Object.assign({}, baseInit, init);
64
- }
57
+ switch (version) {
58
+ case ApiVersion.v1: {
59
+ const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
60
+ method: 'DELETE',
61
+ selector: statusSelector,
62
+ };
63
+ return Object.assign({}, baseInit, init);
65
64
  }
66
- throw Error(`Unknown API version: ${version}`);
65
+ }
66
+ throw Error(`Unknown API version: ${version}`);
67
67
  };
68
68
 
69
69
  /** utility function for generating the api path */
70
70
  const generateApiPath = <TVersion extends AvailableVersions>(
71
- version: TVersion,
72
- args: z.infer<(typeof ArgSchema)[TVersion]>,
71
+ version: TVersion,
72
+ args: z.infer<(typeof ArgSchema)[TVersion]>,
73
73
  ): string => {
74
- switch (version) {
75
- case ApiVersion.v1: {
76
- const params = new URLSearchParams();
77
- params.append('api-version', version);
78
- return `/persons/me/bookmarks/favourites/${args.bookmarkId}?${String(params)}`;
79
- }
74
+ switch (version) {
75
+ case ApiVersion.v1: {
76
+ const params = new URLSearchParams();
77
+ params.append('api-version', version);
78
+ return `/persons/me/bookmarks/favourites/${args.bookmarkId}?${String(params)}`;
80
79
  }
81
- throw Error(`Unknown API version: ${version}`);
80
+ }
81
+ throw Error(`Unknown API version: ${version}`);
82
82
  };
83
83
 
84
84
  /** executes the api call */
85
85
  const executeApiCall = <TVersion extends AllowedVersions, TMethod extends keyof ClientMethod>(
86
- version: TVersion,
87
- client: IHttpClient,
88
- method: TMethod = 'json' as TMethod,
86
+ version: TVersion,
87
+ client: IHttpClient,
88
+ method: TMethod = 'json' as TMethod,
89
89
  ) => {
90
- type MethodVersion = ExtractApiVersion<TVersion>;
91
- const apiVersion = extractVersion(ApiVersion, version);
92
- return <
93
- TResponse = ApiResponse<MethodVersion>,
94
- TResult = MethodResult<MethodVersion, TMethod, TResponse>,
95
- >(
96
- input: MethodArg<MethodVersion>,
97
- init?: ClientRequestInit<IHttpClient, TResponse>,
98
- ): TResult => {
99
- const args = ArgSchema[apiVersion].parse(input);
100
- return client[method](
101
- generateApiPath(apiVersion, args),
102
- generateRequestParameters(apiVersion, args, init),
103
- ) as TResult;
104
- };
90
+ type MethodVersion = ExtractApiVersion<TVersion>;
91
+ const apiVersion = extractVersion(ApiVersion, version);
92
+ return <
93
+ TResponse = ApiResponse<MethodVersion>,
94
+ TResult = MethodResult<MethodVersion, TMethod, TResponse>,
95
+ >(
96
+ input: MethodArg<MethodVersion>,
97
+ init?: ClientRequestInit<IHttpClient, TResponse>,
98
+ ): TResult => {
99
+ const args = ArgSchema[apiVersion].parse(input);
100
+ return client[method](
101
+ generateApiPath(apiVersion, args),
102
+ generateRequestParameters(apiVersion, args, init),
103
+ ) as TResult;
104
+ };
105
105
  };
106
106
 
107
107
  export {
108
- AllowedVersions as RemoveBookmarkFavouriteVersion,
109
- MethodArg as RemoveBookmarkFavouriteArgs,
110
- ApiResponse as RemoveBookmarkFavouriteResponse,
111
- MethodResult as RemoveBookmarkFavouriteResult,
112
- executeApiCall as removeFavoriteBookmark,
108
+ type AllowedVersions as RemoveBookmarkFavouriteVersion,
109
+ type MethodArg as RemoveBookmarkFavouriteArgs,
110
+ type ApiResponse as RemoveBookmarkFavouriteResponse,
111
+ type MethodResult as RemoveBookmarkFavouriteResult,
112
+ executeApiCall as removeFavoriteBookmark,
113
113
  };