@equinor/fusion-framework-module-services 2.0.7 → 2.2.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 (227) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/bookmarks/client.js +10 -0
  3. package/dist/esm/bookmarks/client.js.map +1 -1
  4. package/dist/esm/bookmarks/delete/client.js +1 -1
  5. package/dist/esm/bookmarks/delete/client.js.map +1 -1
  6. package/dist/esm/bookmarks/getAll/client.js +4 -0
  7. package/dist/esm/bookmarks/getAll/client.js.map +1 -0
  8. package/dist/esm/bookmarks/getAll/generate-endpoint.js +11 -0
  9. package/dist/esm/bookmarks/getAll/generate-endpoint.js.map +1 -0
  10. package/dist/esm/bookmarks/getAll/generate-parameters.js +6 -0
  11. package/dist/esm/bookmarks/getAll/generate-parameters.js.map +1 -0
  12. package/dist/esm/bookmarks/getAll/index.js +5 -0
  13. package/dist/esm/bookmarks/getAll/index.js.map +1 -0
  14. package/dist/esm/bookmarks/getAll/types.js +2 -0
  15. package/dist/esm/bookmarks/getAll/types.js.map +1 -0
  16. package/dist/esm/bookmarks/patch/client.js +4 -0
  17. package/dist/esm/bookmarks/patch/client.js.map +1 -0
  18. package/dist/esm/bookmarks/patch/generate-endpoint.js +11 -0
  19. package/dist/esm/bookmarks/patch/generate-endpoint.js.map +1 -0
  20. package/dist/esm/bookmarks/patch/generate-parameters.js +9 -0
  21. package/dist/esm/bookmarks/patch/generate-parameters.js.map +1 -0
  22. package/dist/esm/bookmarks/patch/index.js +5 -0
  23. package/dist/esm/bookmarks/patch/index.js.map +1 -0
  24. package/dist/esm/bookmarks/patch/types.js +2 -0
  25. package/dist/esm/bookmarks/patch/types.js.map +1 -0
  26. package/dist/esm/bookmarks/post/generate-endpoint.js +1 -5
  27. package/dist/esm/bookmarks/post/generate-endpoint.js.map +1 -1
  28. package/dist/esm/bookmarks/post/generate-parameters.js.map +1 -1
  29. package/dist/esm/notification/api-models.js +2 -0
  30. package/dist/esm/notification/api-models.js.map +1 -0
  31. package/dist/esm/notification/client.js +43 -0
  32. package/dist/esm/notification/client.js.map +1 -0
  33. package/dist/esm/notification/index.js +5 -0
  34. package/dist/esm/notification/index.js.map +1 -0
  35. package/dist/esm/notification/notification/delete/client.js +4 -0
  36. package/dist/esm/notification/notification/delete/client.js.map +1 -0
  37. package/dist/esm/notification/notification/delete/generate-endpoint.js +18 -0
  38. package/dist/esm/notification/notification/delete/generate-endpoint.js.map +1 -0
  39. package/dist/esm/notification/notification/delete/generate-parameters.js +10 -0
  40. package/dist/esm/notification/notification/delete/generate-parameters.js.map +1 -0
  41. package/dist/esm/notification/notification/delete/index.js +6 -0
  42. package/dist/esm/notification/notification/delete/index.js.map +1 -0
  43. package/dist/esm/notification/notification/delete/types.js +2 -0
  44. package/dist/esm/notification/notification/delete/types.js.map +1 -0
  45. package/dist/esm/notification/notification/get/client.js +4 -0
  46. package/dist/esm/notification/notification/get/client.js.map +1 -0
  47. package/dist/esm/notification/notification/get/generate-endpoint.js +18 -0
  48. package/dist/esm/notification/notification/get/generate-endpoint.js.map +1 -0
  49. package/dist/esm/notification/notification/get/generate-parameters.js +7 -0
  50. package/dist/esm/notification/notification/get/generate-parameters.js.map +1 -0
  51. package/dist/esm/notification/notification/get/index.js +6 -0
  52. package/dist/esm/notification/notification/get/index.js.map +1 -0
  53. package/dist/esm/notification/notification/get/types.js +2 -0
  54. package/dist/esm/notification/notification/get/types.js.map +1 -0
  55. package/dist/esm/notification/notification/getAll/client.js +4 -0
  56. package/dist/esm/notification/notification/getAll/client.js.map +1 -0
  57. package/dist/esm/notification/notification/getAll/generate-endpoint.js +18 -0
  58. package/dist/esm/notification/notification/getAll/generate-endpoint.js.map +1 -0
  59. package/dist/esm/notification/notification/getAll/generate-parameters.js +7 -0
  60. package/dist/esm/notification/notification/getAll/generate-parameters.js.map +1 -0
  61. package/dist/esm/notification/notification/getAll/index.js +6 -0
  62. package/dist/esm/notification/notification/getAll/index.js.map +1 -0
  63. package/dist/esm/notification/notification/getAll/types.js +2 -0
  64. package/dist/esm/notification/notification/getAll/types.js.map +1 -0
  65. package/dist/esm/notification/notification/index.js +6 -0
  66. package/dist/esm/notification/notification/index.js.map +1 -0
  67. package/dist/esm/notification/notification/patch/client.js +4 -0
  68. package/dist/esm/notification/notification/patch/client.js.map +1 -0
  69. package/dist/esm/notification/notification/patch/generate-endpoint.js +18 -0
  70. package/dist/esm/notification/notification/patch/generate-endpoint.js.map +1 -0
  71. package/dist/esm/notification/notification/patch/generate-parameters.js +10 -0
  72. package/dist/esm/notification/notification/patch/generate-parameters.js.map +1 -0
  73. package/dist/esm/notification/notification/patch/index.js +6 -0
  74. package/dist/esm/notification/notification/patch/index.js.map +1 -0
  75. package/dist/esm/notification/notification/patch/types.js +2 -0
  76. package/dist/esm/notification/notification/patch/types.js.map +1 -0
  77. package/dist/esm/notification/notification/post/client.js +4 -0
  78. package/dist/esm/notification/notification/post/client.js.map +1 -0
  79. package/dist/esm/notification/notification/post/generate-endpoint.js +18 -0
  80. package/dist/esm/notification/notification/post/generate-endpoint.js.map +1 -0
  81. package/dist/esm/notification/notification/post/generate-parameters.js +10 -0
  82. package/dist/esm/notification/notification/post/generate-parameters.js.map +1 -0
  83. package/dist/esm/notification/notification/post/index.js +6 -0
  84. package/dist/esm/notification/notification/post/index.js.map +1 -0
  85. package/dist/esm/notification/notification/post/types.js +2 -0
  86. package/dist/esm/notification/notification/post/types.js.map +1 -0
  87. package/dist/esm/notification/settings/get/client.js +4 -0
  88. package/dist/esm/notification/settings/get/client.js.map +1 -0
  89. package/dist/esm/notification/settings/get/generate-endpoint.js +18 -0
  90. package/dist/esm/notification/settings/get/generate-endpoint.js.map +1 -0
  91. package/dist/esm/notification/settings/get/generate-parameters.js +7 -0
  92. package/dist/esm/notification/settings/get/generate-parameters.js.map +1 -0
  93. package/dist/esm/notification/settings/get/index.js +6 -0
  94. package/dist/esm/notification/settings/get/index.js.map +1 -0
  95. package/dist/esm/notification/settings/get/types.js +2 -0
  96. package/dist/esm/notification/settings/get/types.js.map +1 -0
  97. package/dist/esm/notification/settings/put/client.js +4 -0
  98. package/dist/esm/notification/settings/put/client.js.map +1 -0
  99. package/dist/esm/notification/settings/put/generate-endpoint.js +18 -0
  100. package/dist/esm/notification/settings/put/generate-endpoint.js.map +1 -0
  101. package/dist/esm/notification/settings/put/generate-parameters.js +10 -0
  102. package/dist/esm/notification/settings/put/generate-parameters.js.map +1 -0
  103. package/dist/esm/notification/settings/put/index.js +6 -0
  104. package/dist/esm/notification/settings/put/index.js.map +1 -0
  105. package/dist/esm/notification/settings/put/types.js +2 -0
  106. package/dist/esm/notification/settings/put/types.js.map +1 -0
  107. package/dist/esm/notification/static.js +6 -0
  108. package/dist/esm/notification/static.js.map +1 -0
  109. package/dist/esm/notification/types.js +2 -0
  110. package/dist/esm/notification/types.js.map +1 -0
  111. package/dist/esm/provider.js +7 -0
  112. package/dist/esm/provider.js.map +1 -1
  113. package/dist/tsconfig.tsbuildinfo +1 -1
  114. package/dist/types/bookmarks/api-models.d.ts +2 -2
  115. package/dist/types/bookmarks/client.d.ts +4 -0
  116. package/dist/types/bookmarks/getAll/client.d.ts +5 -0
  117. package/dist/types/bookmarks/getAll/generate-endpoint.d.ts +1 -0
  118. package/dist/types/bookmarks/getAll/generate-parameters.d.ts +3 -0
  119. package/dist/types/bookmarks/getAll/index.d.ts +4 -0
  120. package/dist/types/bookmarks/getAll/types.d.ts +10 -0
  121. package/dist/types/bookmarks/patch/client.d.ts +5 -0
  122. package/dist/types/bookmarks/patch/generate-endpoint.d.ts +2 -0
  123. package/dist/types/bookmarks/patch/generate-parameters.d.ts +4 -0
  124. package/dist/types/bookmarks/patch/index.d.ts +4 -0
  125. package/dist/types/bookmarks/patch/types.d.ts +19 -0
  126. package/dist/types/bookmarks/post/types.d.ts +2 -3
  127. package/dist/types/notification/api-models.d.ts +54 -0
  128. package/dist/types/notification/client.d.ts +24 -0
  129. package/dist/types/notification/index.d.ts +4 -0
  130. package/dist/types/notification/notification/delete/client.d.ts +5 -0
  131. package/dist/types/notification/notification/delete/generate-endpoint.d.ts +2 -0
  132. package/dist/types/notification/notification/delete/generate-parameters.d.ts +5 -0
  133. package/dist/types/notification/notification/delete/index.d.ts +5 -0
  134. package/dist/types/notification/notification/delete/types.d.ts +21 -0
  135. package/dist/types/notification/notification/get/client.d.ts +5 -0
  136. package/dist/types/notification/notification/get/generate-endpoint.d.ts +2 -0
  137. package/dist/types/notification/notification/get/generate-parameters.d.ts +5 -0
  138. package/dist/types/notification/notification/get/index.d.ts +5 -0
  139. package/dist/types/notification/notification/get/types.d.ts +21 -0
  140. package/dist/types/notification/notification/getAll/client.d.ts +5 -0
  141. package/dist/types/notification/notification/getAll/generate-endpoint.d.ts +2 -0
  142. package/dist/types/notification/notification/getAll/generate-parameters.d.ts +5 -0
  143. package/dist/types/notification/notification/getAll/index.d.ts +5 -0
  144. package/dist/types/notification/notification/getAll/types.d.ts +21 -0
  145. package/dist/types/notification/notification/index.d.ts +5 -0
  146. package/dist/types/notification/notification/patch/client.d.ts +5 -0
  147. package/dist/types/notification/notification/patch/generate-endpoint.d.ts +2 -0
  148. package/dist/types/notification/notification/patch/generate-parameters.d.ts +5 -0
  149. package/dist/types/notification/notification/patch/index.d.ts +5 -0
  150. package/dist/types/notification/notification/patch/types.d.ts +22 -0
  151. package/dist/types/notification/notification/post/client.d.ts +5 -0
  152. package/dist/types/notification/notification/post/generate-endpoint.d.ts +2 -0
  153. package/dist/types/notification/notification/post/generate-parameters.d.ts +5 -0
  154. package/dist/types/notification/notification/post/index.d.ts +5 -0
  155. package/dist/types/notification/notification/post/types.d.ts +33 -0
  156. package/dist/types/notification/settings/get/client.d.ts +5 -0
  157. package/dist/types/notification/settings/get/generate-endpoint.d.ts +2 -0
  158. package/dist/types/notification/settings/get/generate-parameters.d.ts +5 -0
  159. package/dist/types/notification/settings/get/index.d.ts +5 -0
  160. package/dist/types/notification/settings/get/types.d.ts +21 -0
  161. package/dist/types/notification/settings/put/client.d.ts +5 -0
  162. package/dist/types/notification/settings/put/generate-endpoint.d.ts +2 -0
  163. package/dist/types/notification/settings/put/generate-parameters.d.ts +5 -0
  164. package/dist/types/notification/settings/put/index.d.ts +5 -0
  165. package/dist/types/notification/settings/put/types.d.ts +17 -0
  166. package/dist/types/notification/static.d.ts +4 -0
  167. package/dist/types/notification/types.d.ts +1 -0
  168. package/dist/types/provider.d.ts +2 -0
  169. package/package.json +12 -4
  170. package/src/bookmarks/api-models.ts +2 -2
  171. package/src/bookmarks/client.ts +30 -2
  172. package/src/bookmarks/delete/client.ts +1 -1
  173. package/src/bookmarks/getAll/client.ts +30 -0
  174. package/src/bookmarks/getAll/generate-endpoint.ts +15 -0
  175. package/src/bookmarks/getAll/generate-parameters.ts +18 -0
  176. package/src/bookmarks/getAll/index.ts +6 -0
  177. package/src/bookmarks/getAll/types.ts +21 -0
  178. package/src/bookmarks/patch/client.ts +30 -0
  179. package/src/bookmarks/patch/generate-endpoint.ts +18 -0
  180. package/src/bookmarks/patch/generate-parameters.ts +28 -0
  181. package/src/bookmarks/patch/index.ts +6 -0
  182. package/src/bookmarks/patch/types.ts +45 -0
  183. package/src/bookmarks/post/generate-endpoint.ts +1 -5
  184. package/src/bookmarks/post/generate-parameters.ts +0 -2
  185. package/src/bookmarks/post/types.ts +2 -2
  186. package/src/notification/api-models.ts +70 -0
  187. package/src/notification/client.ts +167 -0
  188. package/src/notification/index.ts +6 -0
  189. package/src/notification/notification/delete/client.ts +37 -0
  190. package/src/notification/notification/delete/generate-endpoint.ts +24 -0
  191. package/src/notification/notification/delete/generate-parameters.ts +32 -0
  192. package/src/notification/notification/delete/index.ts +8 -0
  193. package/src/notification/notification/delete/types.ts +44 -0
  194. package/src/notification/notification/get/client.ts +33 -0
  195. package/src/notification/notification/get/generate-endpoint.ts +25 -0
  196. package/src/notification/notification/get/generate-parameters.ts +22 -0
  197. package/src/notification/notification/get/index.ts +8 -0
  198. package/src/notification/notification/get/types.ts +44 -0
  199. package/src/notification/notification/getAll/client.ts +37 -0
  200. package/src/notification/notification/getAll/generate-endpoint.ts +25 -0
  201. package/src/notification/notification/getAll/generate-parameters.ts +22 -0
  202. package/src/notification/notification/getAll/index.ts +8 -0
  203. package/src/notification/notification/getAll/types.ts +44 -0
  204. package/src/notification/notification/index.ts +5 -0
  205. package/src/notification/notification/patch/client.ts +37 -0
  206. package/src/notification/notification/patch/generate-endpoint.ts +24 -0
  207. package/src/notification/notification/patch/generate-parameters.ts +32 -0
  208. package/src/notification/notification/patch/index.ts +8 -0
  209. package/src/notification/notification/patch/types.ts +45 -0
  210. package/src/notification/notification/post/client.ts +37 -0
  211. package/src/notification/notification/post/generate-endpoint.ts +25 -0
  212. package/src/notification/notification/post/generate-parameters.ts +32 -0
  213. package/src/notification/notification/post/index.ts +8 -0
  214. package/src/notification/notification/post/types.ts +57 -0
  215. package/src/notification/settings/get/client.ts +37 -0
  216. package/src/notification/settings/get/generate-endpoint.ts +25 -0
  217. package/src/notification/settings/get/generate-parameters.ts +22 -0
  218. package/src/notification/settings/get/index.ts +8 -0
  219. package/src/notification/settings/get/types.ts +44 -0
  220. package/src/notification/settings/put/client.ts +37 -0
  221. package/src/notification/settings/put/generate-endpoint.ts +25 -0
  222. package/src/notification/settings/put/generate-parameters.ts +34 -0
  223. package/src/notification/settings/put/index.ts +8 -0
  224. package/src/notification/settings/put/types.ts +38 -0
  225. package/src/notification/static.ts +6 -0
  226. package/src/notification/types.ts +5 -0
  227. package/src/provider.ts +8 -0
@@ -0,0 +1,4 @@
1
+ export declare enum ApiVersion {
2
+ 'v1' = "1.0",
3
+ 'v2' = "2.0"
4
+ }
@@ -0,0 +1 @@
1
+ export { ClientMethodType, ClientMethod, ApiClientArguments, } from '@equinor/fusion-framework-module-services';
@@ -3,6 +3,7 @@ import { ClientMethod } from './types';
3
3
  import { ApiClientFactory } from './types';
4
4
  import { ContextApiClient } from './context';
5
5
  import BookmarksApiClient from './bookmarks/client';
6
+ import { NotificationApiClient } from './notification';
6
7
  export interface IApiProvider<TClient extends IHttpClient = IHttpClient> {
7
8
  createBookmarksClient<TMethod extends keyof ClientMethod, TPayload = unknown>(method: TMethod): Promise<BookmarksApiClient<TMethod, TClient, TPayload>>;
8
9
  createContextClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<ContextApiClient<TMethod, TClient>>;
@@ -13,6 +14,7 @@ type ApiProviderCtorArgs<TClient extends IHttpClient = IHttpClient> = {
13
14
  export declare class ApiProvider<TClient extends IHttpClient = IHttpClient> implements IApiProvider<TClient> {
14
15
  protected _createClientFn: ApiClientFactory<TClient>;
15
16
  constructor({ createClient }: ApiProviderCtorArgs<TClient>);
17
+ createNotificationClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<NotificationApiClient<TMethod, TClient>>;
16
18
  createBookmarksClient<TMethod extends keyof ClientMethod, TPayload = unknown>(method: TMethod): Promise<BookmarksApiClient<TMethod, TClient, TPayload>>;
17
19
  createContextClient<TMethod extends keyof ClientMethod>(method: TMethod): Promise<ContextApiClient<TMethod, TClient>>;
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-services",
3
- "version": "2.0.7",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",
@@ -10,6 +10,9 @@
10
10
  "*": [
11
11
  "dist/types/*"
12
12
  ],
13
+ "notification": [
14
+ "dist/types/notification/index"
15
+ ],
13
16
  "context": [
14
17
  "dist/types/context/index"
15
18
  ],
@@ -18,12 +21,17 @@
18
21
  ],
19
22
  "context/query": [
20
23
  "dist/types/context/query/index"
24
+ ],
25
+ "bookmarks": [
26
+ "dist/types/bookmarks/index"
21
27
  ]
22
28
  }
23
29
  },
24
30
  "exports": {
25
31
  ".": "./dist/esm/index.js",
26
32
  "./context": "./dist/esm/context/index.js",
33
+ "./bookmark": "./dist/esm/bookmarks/index.js",
34
+ "./notification": "./dist/esm/notification/index.js",
27
35
  "./context/get": "./dist/esm/context/get-context/index.js",
28
36
  "./errors": "./dist/esm/errors.js",
29
37
  "./package.json": "./package.json"
@@ -48,12 +56,12 @@
48
56
  },
49
57
  "devDependencies": {
50
58
  "@equinor/fusion-framework-module": "^2.0.1",
51
- "@equinor/fusion-framework-module-http": "^4.0.1",
52
- "@equinor/fusion-framework-module-service-discovery": "^6.0.7"
59
+ "@equinor/fusion-framework-module-http": "^4.0.2",
60
+ "@equinor/fusion-framework-module-service-discovery": "^6.0.8"
53
61
  },
54
62
  "peerDependencies": {
55
63
  "@equinor/fusion-framework-module": ">=1.2.2",
56
64
  "odata-query": "^7.0.3"
57
65
  },
58
- "gitHead": "a59959b7f25df08c9f93b05f1ea46980ff9e1303"
66
+ "gitHead": "8271bcdf843d09c67cb60a563cf32dbd9767e621"
59
67
  }
@@ -8,8 +8,8 @@ export interface ApiBookmarkEntityV1<TPayload> {
8
8
  context: Context;
9
9
  createdBy: CreatedBy;
10
10
  updatedBy: UpdatedBy;
11
- created: Date;
12
- updated: Date;
11
+ created: string;
12
+ updated: string;
13
13
  sourceSystem: SourceSystem;
14
14
  }
15
15
 
@@ -7,6 +7,12 @@ import getBookmark from './get/client';
7
7
  import { ApiVersions, GetBookmarkResult, GetBookmarksFn, GetBookmarksResult } from './get/types';
8
8
  import { PostBookmarkResult, PostBookmarkFn, PostBookmarksResult } from './post/types';
9
9
  import postBookmark from './post/client';
10
+ import patchBookmark, {
11
+ PutBookmarkFn as PatchBookmarkFn,
12
+ PutBookmarkResult as PatchBookmarkResult,
13
+ PutBookmarksResult as PatchBookmarksResult,
14
+ } from './patch';
15
+ import getAllBookmarks, { GetAllBookmarkResult, GetAllBookmarksResult } from './getAll';
10
16
 
11
17
  export class BookmarksApiClient<
12
18
  TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
@@ -23,9 +29,19 @@ export class BookmarksApiClient<
23
29
  version: TVersion,
24
30
  ...args: Parameters<GetBookmarksFn<TVersion, TMethod, TClient, TPayload, TResult>>
25
31
  ): GetBookmarksResult<TVersion, TMethod, TPayload, TResult> {
26
- const fn = getBookmark<TVersion, TMethod, TClient>(this._client, version, this._method);
32
+ const fn = getBookmark(this._client, version, this._method);
27
33
  return fn<TResult>(...args);
28
34
  }
35
+ /**
36
+ * Fetch all bookmarks
37
+ * @see {@link get/client}
38
+ */
39
+ public getAll<TVersion extends ApiVersions, TResult = GetAllBookmarkResult<TVersion, TPayload>>(
40
+ version: TVersion
41
+ ): GetAllBookmarksResult<TVersion, TMethod, TPayload, TResult> {
42
+ const fn = getAllBookmarks(this._client, version, this._method);
43
+ return fn<TResult>();
44
+ }
29
45
 
30
46
  /**
31
47
  * Create a new bookmark
@@ -35,7 +51,19 @@ export class BookmarksApiClient<
35
51
  version: TVersion,
36
52
  ...args: Parameters<PostBookmarkFn<TVersion, TMethod, TClient, TPayload, TResult>>
37
53
  ): PostBookmarksResult<TVersion, TMethod, TPayload, TResult> {
38
- const fn = postBookmark<TVersion, TMethod, TClient>(this._client, version, this._method);
54
+ const fn = postBookmark(this._client, version, this._method);
55
+ return fn<TResult>(...args);
56
+ }
57
+
58
+ /**
59
+ * Update a bookmark
60
+ * @see {@link get/client}
61
+ */
62
+ public patch<TVersion extends ApiVersions, TResult = PatchBookmarkResult<TVersion, TPayload>>(
63
+ version: TVersion,
64
+ ...args: Parameters<PatchBookmarkFn<TVersion, TMethod, TClient, TPayload, TResult>>
65
+ ): PatchBookmarksResult<TVersion, TMethod, TPayload, TResult> {
66
+ const fn = patchBookmark(this._client, version, this._method);
39
67
  return fn<TResult>(...args);
40
68
  }
41
69
 
@@ -22,7 +22,7 @@ export const deleteBookmark =
22
22
  >(
23
23
  client: TClient,
24
24
  version: TVersion,
25
- method: TMethod = 'json' as TMethod
25
+ method: TMethod = 'fetch' as TMethod
26
26
  ) =>
27
27
  <TResult = DeleteBookmarkResult<TVersion>>(
28
28
  args: DeleteBookmarkArgs<TVersion>,
@@ -0,0 +1,30 @@
1
+ import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import { ClientMethod } from '../..';
3
+
4
+ import { generateParameters } from './generate-parameters';
5
+ import { ApiVersions, GetAllBookmarkResult, GetAllBookmarksResult } from './types';
6
+
7
+ /**
8
+ * Method for fetching all bookmarks for the current user from bookmark service
9
+ * @param client - client for execution of request
10
+ * @param version - version of API to call
11
+ * @param method - client method to call
12
+ */
13
+ export const getAllBookmarks =
14
+ <
15
+ TVersion extends ApiVersions = ApiVersions,
16
+ TMethod extends keyof ClientMethod = keyof ClientMethod,
17
+ TClient extends IHttpClient = IHttpClient
18
+ >(
19
+ client: TClient,
20
+ version: TVersion,
21
+ method: TMethod = 'json' as TMethod
22
+ ) =>
23
+ <TResult = GetAllBookmarkResult<TVersion, unknown>>(
24
+ init?: ClientRequestInit<TClient, TResult>
25
+ ): GetAllBookmarksResult<TVersion, TMethod, unknown, TResult> =>
26
+ client[method](
27
+ ...generateParameters<TResult, TVersion, TClient>(version, init)
28
+ ) as GetAllBookmarksResult<TVersion, TMethod, unknown, TResult>;
29
+
30
+ export default getAllBookmarks;
@@ -0,0 +1,15 @@
1
+ import { ApiVersions } from './types';
2
+
3
+ /**
4
+ * Method for generating endpoint for getting all bookmarks
5
+ */
6
+ export const generateEndpoint = <TVersion extends ApiVersions>(version: TVersion) => {
7
+ switch (version) {
8
+ case 'v1':
9
+ default: {
10
+ const params = new URLSearchParams();
11
+ params.append('api-version', version);
12
+ return `persons/me/bookmarks/?${String(params)}`;
13
+ }
14
+ }
15
+ };
@@ -0,0 +1,18 @@
1
+ import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import { ApiClientArguments } from '../types';
3
+
4
+ import { generateEndpoint } from './generate-endpoint';
5
+ import { ApiVersions } from './types';
6
+
7
+ /** function for creating http client arguments */
8
+ export const generateParameters = <
9
+ TResult,
10
+ TVersion extends ApiVersions,
11
+ TClient extends IHttpClient = IHttpClient
12
+ >(
13
+ version: TVersion,
14
+ init?: ClientRequestInit<TClient, TResult>
15
+ ): ApiClientArguments<TClient, TResult> => {
16
+ const path = generateEndpoint(version);
17
+ return [path, init];
18
+ };
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+
3
+ export { getAllBookmarks, default } from './client';
4
+
5
+ export { generateEndpoint } from './generate-endpoint';
6
+ export { generateParameters } from './generate-parameters';
@@ -0,0 +1,21 @@
1
+ import { ApiBookmarkEntityV1 } from '../api-models';
2
+ import { ClientMethod } from '../types';
3
+
4
+ /**Gets result type for GetAllBookmark call based on version and method */
5
+ export type GetAllBookmarksResult<
6
+ TVersion extends ApiVersions,
7
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
8
+ TPayload = unknown,
9
+ TResult = GetAllBookmarkResult<TVersion, TPayload>
10
+ > = ClientMethod<TResult>[TMethod];
11
+
12
+ export type GetAllBookmarkResult<
13
+ TVersion extends ApiVersions,
14
+ TPayload
15
+ > = GetAllBookmarksVersions<TPayload>[TVersion]['result'];
16
+
17
+ export type GetAllBookmarksVersions<TPayload = unknown> = {
18
+ ['v1']: { result: Array<ApiBookmarkEntityV1<TPayload>> };
19
+ };
20
+
21
+ export type ApiVersions = keyof GetAllBookmarksVersions<unknown>;
@@ -0,0 +1,30 @@
1
+ import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import { ClientMethod } from '../..';
3
+ import { generateParameters } from './generate-parameters';
4
+ import { ApiVersions, PutBookmarkArgs, PutBookmarkResult, PutBookmarksResult } from './types';
5
+
6
+ /**
7
+ * Method for updating bookmark
8
+ * @param client - client for execution of request
9
+ * @param version - version of API to call
10
+ * @param method - client method to call
11
+ */
12
+ export const putBookmark =
13
+ <
14
+ TClient extends IHttpClient = IHttpClient,
15
+ TVersion extends ApiVersions = ApiVersions,
16
+ TMethod extends keyof ClientMethod = keyof ClientMethod
17
+ >(
18
+ client: TClient,
19
+ version: TVersion,
20
+ method: TMethod = 'json' as TMethod
21
+ ) =>
22
+ <TResult = PutBookmarkResult<TVersion, unknown>>(
23
+ args: PutBookmarkArgs<TVersion>,
24
+ init?: ClientRequestInit<TClient, TResult>
25
+ ): PutBookmarksResult<TVersion, TMethod, unknown, TResult> =>
26
+ client[method](
27
+ ...generateParameters<TResult, TVersion, TClient>(version, args, init)
28
+ ) as PutBookmarksResult<TVersion, TMethod, unknown, TResult>;
29
+
30
+ export default putBookmark;
@@ -0,0 +1,18 @@
1
+ import { ApiVersions, PutBookmarkArgs } from './types';
2
+
3
+ /**
4
+ * Method for generating endpoint for getting bookmark by id
5
+ */
6
+ export const generateEndpoint = <TVersion extends ApiVersions>(
7
+ version: TVersion,
8
+ _args: PutBookmarkArgs<TVersion>
9
+ ) => {
10
+ switch (version) {
11
+ case 'v1':
12
+ default: {
13
+ const params = new URLSearchParams();
14
+ params.append('api-version', version);
15
+ return `/bookmarks/${_args.id}?${String(params)}`;
16
+ }
17
+ }
18
+ };
@@ -0,0 +1,28 @@
1
+ import { ClientRequestInit, IHttpClient } from '@equinor/fusion-framework-module-http/client';
2
+ import { ApiClientArguments } from '../..';
3
+ import { generateEndpoint } from './generate-endpoint';
4
+ import { ApiVersions, PutBookmarkArgs } from './types';
5
+
6
+ /** function for creating http client arguments */
7
+ export const generateParameters = <
8
+ TResult,
9
+ TVersion extends ApiVersions,
10
+ TClient extends IHttpClient = IHttpClient
11
+ >(
12
+ version: TVersion,
13
+ args: PutBookmarkArgs<TVersion>,
14
+ init?: ClientRequestInit<TClient, TResult>
15
+ ): ApiClientArguments<TClient, TResult> => {
16
+ const path = generateEndpoint(version, args);
17
+
18
+ const headers = new Headers();
19
+ headers.append('content-type', 'application/json');
20
+
21
+ const requestParams: ClientRequestInit<TClient, TResult> = Object.assign(
22
+ {},
23
+ { method: 'patch', body: JSON.stringify(args), headers: headers },
24
+ init
25
+ );
26
+
27
+ return [path, requestParams];
28
+ };
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+
3
+ export { putBookmark, default } from './client';
4
+
5
+ export { generateEndpoint as generatePutEndpoint } from './generate-endpoint';
6
+ export { generateParameters as generatePutParameters } from './generate-parameters';
@@ -0,0 +1,45 @@
1
+ import { IHttpClient } from '@equinor/fusion-framework-module-http';
2
+ import { ClientRequestInit } from '@equinor/fusion-framework-module-http/client';
3
+ import { ClientMethod } from '../..';
4
+ import { ApiBookmarkEntityV1 } from '../api-models';
5
+ import { PostBookmarksArgsV1 } from '../post';
6
+
7
+ export type PutBookmarkResult<
8
+ TVersion extends ApiVersions,
9
+ TPayload
10
+ > = PutBookmarksVersions<TPayload>[TVersion]['result'];
11
+
12
+ /** Returns args for PutBookmark based on version*/
13
+ export type PutBookmarkArgs<
14
+ TVersion extends ApiVersions,
15
+ TPayload = unknown
16
+ > = PutBookmarksVersions<TPayload>[TVersion]['args'];
17
+
18
+ /**Gets result type for PutBookmark call based on version and method */
19
+ export type PutBookmarksResult<
20
+ TVersion extends ApiVersions,
21
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
22
+ TPayload = unknown,
23
+ TResult = PutBookmarkResult<TVersion, TPayload>
24
+ > = ClientMethod<TResult>[TMethod];
25
+
26
+ export type PutBookmarkFn<
27
+ TVersion extends ApiVersions,
28
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
29
+ TClient extends IHttpClient = IHttpClient,
30
+ TPayload = unknown,
31
+ TResult = PutBookmarkResult<TVersion, TPayload>
32
+ > = (
33
+ args: PutBookmarkArgs<TVersion>,
34
+ init?: ClientRequestInit<TClient, TResult>
35
+ ) => PutBookmarksResult<TVersion, TMethod, TPayload, TResult>;
36
+
37
+ export interface PutBookmarksArgsV1<T = unknown> extends PostBookmarksArgsV1<T> {
38
+ id: string;
39
+ }
40
+
41
+ export type PutBookmarksVersions<TPayload = unknown> = {
42
+ ['v1']: { args: PutBookmarksArgsV1<TPayload>; result: ApiBookmarkEntityV1<TPayload> };
43
+ };
44
+
45
+ export type ApiVersions = keyof PutBookmarksVersions<unknown>;
@@ -8,11 +8,7 @@ export const generateEndpoint = <TVersion extends ApiVersions>(
8
8
  _args: PostBookmarkArgs<TVersion>
9
9
  ) => {
10
10
  switch (version) {
11
- case 'v1': {
12
- const params = new URLSearchParams();
13
- params.append('api-version', '1.0');
14
- return `/bookmarks?${String(params)}`;
15
- }
11
+ case 'v1':
16
12
  default: {
17
13
  const params = new URLSearchParams();
18
14
  params.append('api-version', version);
@@ -14,9 +14,7 @@ export const generateParameters = <
14
14
  init?: ClientRequestInit<TClient, TResult>
15
15
  ): ApiClientArguments<TClient, TResult> => {
16
16
  const path = generateEndpoint(version, args);
17
- //add versions switch case later
18
17
 
19
- //Not sure why this is needed, defaults to application/problem+json failing the request
20
18
  const headers = new Headers();
21
19
  headers.append('content-type', 'application/json');
22
20
 
@@ -33,7 +33,7 @@ export type PostBookmarkFn<
33
33
  init?: ClientRequestInit<TClient, TResult>
34
34
  ) => PostBookmarksResult<TVersion, TMethod, TPayload, TResult>;
35
35
 
36
- type PostBookmarksArgsV1<T = unknown> = {
36
+ export interface PostBookmarksArgsV1<T = unknown> {
37
37
  /** Display name of the bookmark */
38
38
  name: string;
39
39
  description?: string;
@@ -49,7 +49,7 @@ type PostBookmarksArgsV1<T = unknown> = {
49
49
  name?: string;
50
50
  subSystem?: string;
51
51
  };
52
- };
52
+ }
53
53
 
54
54
  export type PostBookmarksVersions<TPayload = unknown> = {
55
55
  ['v1']: { args: PostBookmarksArgsV1<TPayload>; result: ApiBookmarkEntityV1<TPayload> };
@@ -0,0 +1,70 @@
1
+ import { ApiVersion } from './static';
2
+
3
+ type ApiNotificationEntity_v1 = {
4
+ id: string;
5
+ appKey: string;
6
+ emailPriority: number;
7
+ fallbackHtml: string;
8
+ targetAzureUniqueId: string;
9
+ title: string;
10
+ card: string;
11
+ created: string;
12
+ createdBy: CreatedBy_v1;
13
+ createdByApplication: CreatedByApplication_v1;
14
+ seenByUser: boolean;
15
+ seen: string;
16
+ sourceSystem: SourceSystem_v1;
17
+ };
18
+
19
+ type SourceSystem_v1 = {
20
+ name: string;
21
+ subSystem: string;
22
+ identifier: string;
23
+ };
24
+
25
+ type CreatedByApplication_v1 = {
26
+ id: string;
27
+ title: string;
28
+ };
29
+
30
+ type CreatedBy_v1 = {
31
+ id: string;
32
+ name: string;
33
+ jobTitle: string;
34
+ mail: string;
35
+ accountType: string;
36
+ };
37
+
38
+ type ApiNotificationEntity_v2 = unknown;
39
+
40
+ type ApiNotificationEntityTypes = {
41
+ [ApiVersion.v1]: ApiNotificationEntity_v1;
42
+ [ApiVersion.v2]: ApiNotificationEntity_v2;
43
+ };
44
+
45
+ export type ApiNotificationEntity<T extends string = ApiVersion> = T extends ApiVersion
46
+ ? ApiNotificationEntityTypes[T]
47
+ : unknown;
48
+
49
+ /**User notification Settings */
50
+ type ApiNotificationSettingsEntity_v1 = {
51
+ email: boolean;
52
+ delayInMinutes: number;
53
+ appConfig: AppConfig_v1[];
54
+ };
55
+
56
+ type AppConfig_v1 = {
57
+ appKey: string;
58
+ enabled: boolean;
59
+ };
60
+
61
+ type ApiNotificationSettingsEntity_v2 = unknown;
62
+
63
+ type ApiNotificationSettingEntityTypes = {
64
+ [ApiVersion.v1]: ApiNotificationSettingsEntity_v1;
65
+ [ApiVersion.v2]: ApiNotificationSettingsEntity_v2;
66
+ };
67
+
68
+ export type ApiNotificationSettingsEntity<T extends string = ApiVersion> = T extends ApiVersion
69
+ ? ApiNotificationSettingEntityTypes[T]
70
+ : unknown;
@@ -0,0 +1,167 @@
1
+ import { IHttpClient } from '@equinor/fusion-framework-module-http';
2
+ import { ClientMethod } from '../types';
3
+ import { GetNotificationFn, GetNotificationResult } from './notification/get';
4
+ import {
5
+ createNotification,
6
+ deleteNotification,
7
+ getNotificationById,
8
+ getNotifications,
9
+ updateSeenByUser,
10
+ } from './notification';
11
+ import { ApiVersion } from './static';
12
+ import { PatchNotificationFn, PatchNotificationResult } from './notification/patch';
13
+ import { GetNotificationsFn, GetNotificationsResult } from './notification/getAll';
14
+ import { PostNotificationResult, PostNotificationFn } from './notification/post';
15
+ import { DeleteNotificationFn, DeleteNotificationResult } from './notification/delete';
16
+ import updateUserNotificationSettings, {
17
+ PutUserNotificationSettingsFn,
18
+ PutUserNotificationSettingsResult,
19
+ } from './settings/put';
20
+ import getUserNotificationSettings, {
21
+ GetUserNotificationSettingsFn,
22
+ GetUserNotificationsSettingsResult,
23
+ } from './settings/get';
24
+
25
+ export class NotificationApiClient<
26
+ TMethod extends keyof ClientMethod<unknown> = keyof ClientMethod<unknown>,
27
+ TClient extends IHttpClient = IHttpClient
28
+ > {
29
+ get Version(): typeof ApiVersion {
30
+ return ApiVersion;
31
+ }
32
+
33
+ constructor(protected _client: TClient, protected _method: TMethod) {}
34
+
35
+ /**
36
+ * Fetch all notifications
37
+ * @see {@link getAll/client}
38
+ */
39
+ public getAll<
40
+ TVersion extends string = keyof typeof ApiVersion,
41
+ TResult = GetNotificationsResult<TVersion>
42
+ >(
43
+ version: TVersion,
44
+ ...args: Parameters<GetNotificationsFn<TVersion, TMethod, TClient, TResult>>
45
+ ): GetNotificationsResult<TVersion, TMethod, TResult> {
46
+ const fn = getNotifications<TVersion, TMethod, TClient>(
47
+ this._client,
48
+ version,
49
+ this._method
50
+ );
51
+ return fn<TResult>(...args);
52
+ }
53
+
54
+ /**
55
+ * Fetch notification by id
56
+ * @see {@link getById/client}
57
+ */
58
+ public getById<
59
+ TVersion extends string = keyof typeof ApiVersion,
60
+ TResult = GetNotificationResult<TVersion>
61
+ >(
62
+ version: TVersion,
63
+ ...args: Parameters<GetNotificationFn<TVersion, TMethod, TClient, TResult>>
64
+ ): GetNotificationResult<TVersion, TMethod, TResult> {
65
+ const fn = getNotificationById<TVersion, TMethod, TClient>(
66
+ this._client,
67
+ version,
68
+ this._method
69
+ );
70
+ return fn<TResult>(...args);
71
+ }
72
+
73
+ /**
74
+ * Set notification seen by user
75
+ * @see {@link setSeenByUser/client}
76
+ */
77
+ public setSeenByUser<
78
+ TVersion extends string = keyof typeof ApiVersion,
79
+ TResult = PatchNotificationResult<TVersion>
80
+ >(
81
+ version: TVersion,
82
+ ...args: Parameters<PatchNotificationFn<TVersion, TMethod, TClient, TResult>>
83
+ ): PatchNotificationResult<TVersion, TMethod, TResult> {
84
+ const fn = updateSeenByUser<TVersion, TMethod, TClient>(
85
+ this._client,
86
+ version,
87
+ this._method
88
+ );
89
+ return fn<TResult>(...args);
90
+ }
91
+
92
+ /**
93
+ * Create a notification
94
+ * @see {@link create/client}
95
+ */
96
+ public create<
97
+ TVersion extends string = keyof typeof ApiVersion,
98
+ TResult = PostNotificationResult<TVersion>
99
+ >(
100
+ version: TVersion,
101
+ ...args: Parameters<PostNotificationFn<TVersion, TMethod, TClient, TResult>>
102
+ ): PostNotificationResult<TVersion, TMethod, TResult> {
103
+ const fn = createNotification<TVersion, TMethod, TClient>(
104
+ this._client,
105
+ version,
106
+ this._method
107
+ );
108
+ return fn<TResult>(...args);
109
+ }
110
+
111
+ /**
112
+ * Delete a notification
113
+ * @see {@link delete/client}
114
+ */
115
+ public delete<
116
+ TVersion extends string = keyof typeof ApiVersion,
117
+ TResult = PostNotificationResult<TVersion>
118
+ >(
119
+ version: TVersion,
120
+ ...args: Parameters<DeleteNotificationFn<TVersion, TMethod, TClient, TResult>>
121
+ ): DeleteNotificationResult<TVersion, TMethod, TResult> {
122
+ const fn = deleteNotification<TVersion, TMethod, TClient>(
123
+ this._client,
124
+ version,
125
+ this._method
126
+ );
127
+ return fn<TResult>(...args);
128
+ }
129
+ /**
130
+ * Get users notification settings
131
+ * @see {@link getSettings/client}
132
+ */
133
+ public getSettings<
134
+ TVersion extends string = keyof typeof ApiVersion,
135
+ TResult = PostNotificationResult<TVersion>
136
+ >(
137
+ version: TVersion,
138
+ ...args: Parameters<GetUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
139
+ ): GetUserNotificationsSettingsResult<TVersion, TMethod, TResult> {
140
+ const fn = getUserNotificationSettings<TVersion, TMethod, TClient>(
141
+ this._client,
142
+ version,
143
+ this._method
144
+ );
145
+ return fn<TResult>(...args);
146
+ }
147
+ /**
148
+ * Update user notification settings
149
+ * @see {@link updateSettings/client}
150
+ */
151
+ public updateSettings<
152
+ TVersion extends string = keyof typeof ApiVersion,
153
+ TResult = PostNotificationResult<TVersion>
154
+ >(
155
+ version: TVersion,
156
+ ...args: Parameters<PutUserNotificationSettingsFn<TVersion, TMethod, TClient, TResult>>
157
+ ): PutUserNotificationSettingsResult<TVersion, TMethod, TResult> {
158
+ const fn = updateUserNotificationSettings<TVersion, TMethod, TClient>(
159
+ this._client,
160
+ version,
161
+ this._method
162
+ );
163
+ return fn<TResult>(...args);
164
+ }
165
+ }
166
+
167
+ export default NotificationApiClient;