@equinor/fusion-framework-module-services 5.0.0 → 5.0.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.
@@ -1 +1 @@
1
- export declare const version = "5.0.0";
1
+ export declare const version = "5.0.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-services",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",
@@ -117,9 +117,9 @@
117
117
  },
118
118
  "devDependencies": {
119
119
  "typescript": "^5.5.4",
120
- "@equinor/fusion-framework-module": "^4.3.5",
121
120
  "@equinor/fusion-framework-module-http": "^6.2.0",
122
- "@equinor/fusion-framework-module-service-discovery": "^8.0.2"
121
+ "@equinor/fusion-framework-module": "^4.3.5",
122
+ "@equinor/fusion-framework-module-service-discovery": "^8.0.3"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "odata-query": "^7.0.4",
@@ -57,9 +57,8 @@ const generateRequestParameters = <TResult, TVersion extends AvailableVersions>(
57
57
  switch (version) {
58
58
  case ApiVersion.v1: {
59
59
  const baseInit: FetchRequestInit<ApiResponse<ApiVersion.v1>, JsonRequest> = {
60
- method: 'POST',
60
+ method: 'HEAD',
61
61
  selector: headSelector,
62
- body: args,
63
62
  };
64
63
  return Object.assign({}, baseInit, init);
65
64
  }
@@ -1,4 +1,4 @@
1
- import { HttpJsonResponseError } from '@equinor/fusion-framework-module-http';
1
+ import { HttpJsonResponseError, HttpResponseError } from '@equinor/fusion-framework-module-http';
2
2
  import { type ResponseSelector } from '@equinor/fusion-framework-module-http/selectors';
3
3
 
4
4
  /**
@@ -35,15 +35,12 @@ export const statusSelector: ResponseSelector<boolean> = async (res) => {
35
35
  * @returns `true` if the response is successful, `false` if the response has a 404 status code, otherwise throws an `HttpJsonResponseError`.
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
- export const headSelector: ResponseSelector<boolean> = (res) => {
39
- try {
40
- return statusSelector(res);
41
- } catch (error) {
42
- if (error instanceof HttpJsonResponseError) {
43
- if (error.response.status === 404) {
44
- return Promise.resolve(false);
45
- }
46
- }
47
- throw error;
38
+ export const headSelector: ResponseSelector<boolean> = async (res) => {
39
+ if (res.ok) {
40
+ return true;
41
+ }
42
+ if (res.status === 404) {
43
+ return false;
48
44
  }
45
+ throw new HttpResponseError(`Failed to execute request. Status code: ${res.status}`, res);
49
46
  };
package/src/provider.ts CHANGED
@@ -96,7 +96,9 @@ export class ApiProvider<TClient extends IHttpClient = IHttpClient>
96
96
  method: TMethod,
97
97
  ): Promise<BookmarksApiClient<TMethod, TClient>> {
98
98
  const httpClient = await this._createClientFn('bookmarks');
99
- httpClient.responseHandler.add('validate_api_request', validateResponse);
99
+ // TODO: update when new ResponseOperator is available
100
+ // will fail because 'HEAD' will return 404 when no bookmarks are found
101
+ // httpClient.responseHandler.add('validate_api_request', validateResponse);
100
102
  return new BookmarksApiClient(httpClient, method);
101
103
  }
102
104
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '5.0.0';
2
+ export const version = '5.0.1';