@odata2ts/http-client-fetch 0.9.0 → 0.9.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.
- package/CHANGELOG.md +14 -0
- package/lib/FetchClient.d.ts +6 -8
- package/lib/FetchClient.js +6 -3
- package/lib/FetchClient.js.map +1 -1
- package/lib/FetchRequestConfig.d.ts +4 -11
- package/lib/FetchRequestConfig.js +11 -11
- package/lib/FetchRequestConfig.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,20 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
9
9
|
|
|
10
10
|
* **fetch:** FetchClientError with full responseData object ([#22](https://github.com/odata2ts/http-client/issues/22)) ([e66fa95](https://github.com/odata2ts/http-client/commit/e66fa952909383d55555eed23d1a8e55fe0081f2))
|
|
11
11
|
|
|
12
|
+
## [0.9.1](https://github.com/odata2ts/http-client/compare/@odata2ts/fetch-v0.9.0...@odata2ts/fetch-v0.9.1) (2026-06-10)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* create blob request ([#28](https://github.com/odata2ts/http-client/issues/28)) ([4cc238d](https://github.com/odata2ts/http-client/commit/4cc238d3fbe07c09d56732b4b12d0b1b875a3ef5))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Dependencies
|
|
21
|
+
|
|
22
|
+
* The following workspace dependencies were updated
|
|
23
|
+
* dependencies
|
|
24
|
+
* @odata2ts/http-client-base bumped from ^0.5.4 to ^0.5.5
|
|
25
|
+
|
|
12
26
|
## [0.9.0](https://github.com/odata2ts/http-client/compare/@odata2ts/fetch-v0.8.0...@odata2ts/fetch-v0.9.0) (2025-03-26)
|
|
13
27
|
|
|
14
28
|
|
package/lib/FetchClient.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { HttpResponseModel, ODataHttpClient } from "@odata2ts/http-client-api";
|
|
2
|
-
import { BaseHttpClient,
|
|
1
|
+
import { HttpResponseModel, ODataHttpClient, ODataHttpClientOptions, ODataHttpMethods } from "@odata2ts/http-client-api";
|
|
2
|
+
import { BaseHttpClient, BaseRequestConfig } from "@odata2ts/http-client-base";
|
|
3
3
|
import { FetchRequestConfig } from "./FetchRequestConfig";
|
|
4
|
-
export interface ClientOptions extends BaseHttpClientOptions {
|
|
5
|
-
}
|
|
6
4
|
export declare const DEFAULT_ERROR_MESSAGE = "No error message!";
|
|
7
5
|
export declare class FetchClient extends BaseHttpClient<FetchRequestConfig> implements ODataHttpClient<FetchRequestConfig> {
|
|
8
|
-
protected readonly config:
|
|
9
|
-
constructor(config?: FetchRequestConfig, clientOptions?:
|
|
10
|
-
protected executeRequest<ResponseModel>(method:
|
|
11
|
-
protected getResponseBody(response: Response, options:
|
|
6
|
+
protected readonly config: FetchRequestConfig;
|
|
7
|
+
constructor(config?: FetchRequestConfig, clientOptions?: ODataHttpClientOptions);
|
|
8
|
+
protected executeRequest<ResponseModel>(method: ODataHttpMethods, url: string, data: any, requestConfig?: FetchRequestConfig | undefined, internalConfig?: BaseRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
9
|
+
protected getResponseBody(response: Response, options: BaseRequestConfig): Promise<any>;
|
|
12
10
|
protected mapHeaders(headers: Headers): Record<string, string>;
|
|
13
11
|
}
|
package/lib/FetchClient.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FetchClient = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const ODataHttpDataTypes_1 = require("@odata2ts/http-client-api/lib/ODataHttpDataTypes");
|
|
5
6
|
const http_client_base_1 = require("@odata2ts/http-client-base");
|
|
6
7
|
const FetchClientError_1 = require("./FetchClientError");
|
|
7
8
|
const FetchRequestConfig_1 = require("./FetchRequestConfig");
|
|
@@ -23,10 +24,12 @@ class FetchClient extends http_client_base_1.BaseHttpClient {
|
|
|
23
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
25
|
const { headers, noBodyEvaluation } = internalConfig;
|
|
25
26
|
const _a = (0, FetchRequestConfig_1.mergeFetchConfig)(this.config, { headers }, requestConfig), { params } = _a, config = tslib_1.__rest(_a, ["params"]);
|
|
26
|
-
|
|
27
|
+
// set core inputs for request
|
|
28
|
+
const resultConfig = Object.assign(Object.assign({}, config), { method });
|
|
27
29
|
if (typeof data !== "undefined") {
|
|
28
|
-
|
|
30
|
+
resultConfig.body = internalConfig.dataType === ODataHttpDataTypes_1.ODataHttpDataTypes.JSON ? JSON.stringify(data) : data;
|
|
29
31
|
}
|
|
32
|
+
// apply additional query params to the URL
|
|
30
33
|
let finalUrl = url;
|
|
31
34
|
if (params && Object.values(params).length) {
|
|
32
35
|
finalUrl +=
|
|
@@ -37,7 +40,7 @@ class FetchClient extends http_client_base_1.BaseHttpClient {
|
|
|
37
40
|
// the actual request
|
|
38
41
|
let response;
|
|
39
42
|
try {
|
|
40
|
-
response = yield fetch(finalUrl,
|
|
43
|
+
response = yield fetch(finalUrl, resultConfig);
|
|
41
44
|
}
|
|
42
45
|
catch (fetchError) {
|
|
43
46
|
throw new FetchClientError_1.FetchClientError(buildErrorMessage(FETCH_FAILURE_MESSAGE, fetchError), undefined, undefined, fetchError);
|
package/lib/FetchClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchClient.js","sourceRoot":"","sources":["../src/FetchClient.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"FetchClient.js","sourceRoot":"","sources":["../src/FetchClient.ts"],"names":[],"mappings":";;;;AAMA,yFAAsF;AACtF,iEAA+E;AAC/E,yDAAsD;AACtD,6DAA8F;AAEjF,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAChE,MAAM,8BAA8B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pClientOptions,\n ODataHttpMethods,\n} from \"@odata2ts/http-client-api\";\nimport { ODataHttpDataTypes } from \"@odata2ts/http-client-api/lib/ODataHttpDataTypes\";\nimport { BaseHttpClient, BaseRequestConfig } from \"@odata2ts/http-client-base\";\nimport { FetchClientError } from \"./FetchClientError\";\nimport { FetchRequestConfig, getDefaultConfig, mergeFetchConfig } from \"./FetchRequestConfig\";\n\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\nconst FETCH_FAILURE_MESSAGE = \"OData request failed entirely: \";\nconst JSON_RETRIEVAL_FAILURE_MESSAGE = \"Retrieving JSON body from OData response failed: \";\nconst BLOB_RETRIEVAL_FAILURE_MESSAGE = \"Retrieving blob from OData response failed: \";\nconst RESPONSE_FAILURE_MESSAGE = \"OData server responded with error: \";\n\nfunction buildErrorMessage(prefix: string, error: any) {\n const msg = typeof error === \"string\" ? error : (error as Error)?.message;\n return prefix + (msg || DEFAULT_ERROR_MESSAGE);\n}\n\ninterface InternalFetchConfig extends FetchRequestConfig, Pick<RequestInit, \"method\" | \"body\"> {}\n\nexport class FetchClient extends BaseHttpClient<FetchRequestConfig> implements ODataHttpClient<FetchRequestConfig> {\n protected readonly config: FetchRequestConfig;\n\n constructor(config?: FetchRequestConfig, clientOptions?: ODataHttpClientOptions) {\n super(clientOptions);\n this.config = getDefaultConfig(config);\n }\n\n protected async executeRequest<ResponseModel>(\n method: ODataHttpMethods,\n url: string,\n data: any,\n requestConfig: FetchRequestConfig | undefined = {},\n internalConfig: BaseRequestConfig = {},\n ): Promise<HttpResponseModel<ResponseModel>> {\n const { headers, noBodyEvaluation } = internalConfig;\n const { params, ...config } = mergeFetchConfig(this.config, { headers }, requestConfig);\n\n // set core inputs for request\n const resultConfig: InternalFetchConfig = {\n ...config,\n method,\n };\n if (typeof data !== \"undefined\") {\n resultConfig.body = internalConfig.dataType === ODataHttpDataTypes.JSON ? JSON.stringify(data) : data;\n }\n\n // apply additional query params to the URL\n let finalUrl = url;\n if (params && Object.values(params).length) {\n finalUrl +=\n (url.match(/\\?/) ? \"&\" : \"?\") +\n // @ts-ignore\n new URLSearchParams(params).toString();\n }\n\n // the actual request\n let response: Response;\n try {\n response = await fetch(finalUrl, resultConfig);\n } catch (fetchError) {\n throw new FetchClientError(\n buildErrorMessage(FETCH_FAILURE_MESSAGE, fetchError),\n undefined,\n undefined,\n fetchError as Error,\n );\n }\n\n // error response\n if (!response.ok) {\n let responseData;\n try {\n responseData = await this.getResponseBody(response, internalConfig);\n } catch (e) {\n responseData = undefined;\n }\n const errMsg = this.retrieveErrorMessage(responseData);\n\n throw new FetchClientError(\n buildErrorMessage(RESPONSE_FAILURE_MESSAGE, errMsg),\n response.status,\n this.mapHeaders(response.headers),\n new Error(errMsg || DEFAULT_ERROR_MESSAGE),\n responseData,\n );\n }\n\n let responseData;\n try {\n responseData = noBodyEvaluation ? undefined : await this.getResponseBody(response, internalConfig);\n } catch (error) {\n const msg = internalConfig.dataType === \"blob\" ? BLOB_RETRIEVAL_FAILURE_MESSAGE : JSON_RETRIEVAL_FAILURE_MESSAGE;\n throw new FetchClientError(\n buildErrorMessage(msg, error),\n response.status,\n this.mapHeaders(response.headers),\n error as Error,\n );\n }\n\n return {\n status: response.status,\n statusText: response.statusText,\n headers: this.mapHeaders(response.headers),\n data: responseData,\n };\n }\n\n protected async getResponseBody(response: Response, options: BaseRequestConfig) {\n if (response.status === 204) {\n return undefined;\n }\n switch (options.dataType) {\n case \"json\":\n return response.json();\n case \"blob\":\n return response.blob();\n case \"stream\":\n return response.body;\n }\n\n return undefined;\n }\n\n protected mapHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n headers.forEach((value, key) => (result[key] = value));\n\n return result;\n }\n}\n"]}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
+
import { ODataRequestConfig } from "@odata2ts/http-client-api";
|
|
1
2
|
/**
|
|
2
3
|
* Available config options for end user when making a given request.
|
|
3
4
|
*/
|
|
4
|
-
export interface FetchRequestConfig extends Partial<Pick<RequestInit, "credentials" | "cache" | "mode" | "redirect" | "referrerPolicy" | "signal">> {
|
|
5
|
-
headers?: Record<string, string> | Headers;
|
|
6
|
-
/**
|
|
7
|
-
* Add query params.
|
|
8
|
-
*/
|
|
9
|
-
params?: Record<string, string | number | boolean | Array<string | number | boolean>>;
|
|
5
|
+
export interface FetchRequestConfig extends ODataRequestConfig, Partial<Pick<RequestInit, "credentials" | "cache" | "mode" | "redirect" | "referrerPolicy" | "signal">> {
|
|
10
6
|
}
|
|
11
|
-
export
|
|
12
|
-
headers: Headers;
|
|
13
|
-
}
|
|
14
|
-
export declare function getDefaultConfig(config?: FetchRequestConfig): RequestInit;
|
|
7
|
+
export declare function getDefaultConfig(config?: FetchRequestConfig): FetchRequestConfig;
|
|
15
8
|
export declare function mergeFetchConfig(): undefined;
|
|
16
|
-
export declare function mergeFetchConfig(...configs: Array<
|
|
9
|
+
export declare function mergeFetchConfig(...configs: Array<FetchRequestConfig | undefined>): FetchRequestConfig;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mergeFetchConfig = exports.getDefaultConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const DEFAULT_CONFIG = {
|
|
6
|
-
// headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
7
6
|
cache: "no-store",
|
|
8
7
|
};
|
|
9
8
|
function getDefaultConfig(config) {
|
|
@@ -17,19 +16,20 @@ function mergeFetchConfig(...configs) {
|
|
|
17
16
|
return configs
|
|
18
17
|
.filter((c) => !!c)
|
|
19
18
|
.reduce((collector, current) => {
|
|
19
|
+
const { headers: prevHeaders } = collector, prevPassThrough = tslib_1.__rest(collector, ["headers"]);
|
|
20
20
|
const { headers } = current, passThrough = tslib_1.__rest(current, ["headers"]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (headers && headers instanceof Headers) {
|
|
24
|
-
// @ts-ignore: fails on CI test
|
|
25
|
-
headers.forEach((val, key) => collectedHeaders.set(key, val));
|
|
26
|
-
}
|
|
27
|
-
// headers as plain Record<string,string>
|
|
28
|
-
else if (headers) {
|
|
29
|
-
Object.entries(headers).forEach(([key, val]) => collectedHeaders.set(key, val));
|
|
21
|
+
if (headers) {
|
|
22
|
+
Object.entries(cleanHeaders(headers)).forEach(([key, val]) => (collector.headers[key] = val));
|
|
30
23
|
}
|
|
31
24
|
return Object.assign(Object.assign({}, collector), passThrough);
|
|
32
|
-
}, { headers:
|
|
25
|
+
}, { headers: {} });
|
|
33
26
|
}
|
|
34
27
|
exports.mergeFetchConfig = mergeFetchConfig;
|
|
28
|
+
function cleanHeaders(headers) {
|
|
29
|
+
const result = {};
|
|
30
|
+
const temp = new Headers();
|
|
31
|
+
Object.entries(headers).forEach(([key, val]) => temp.set(key, val));
|
|
32
|
+
temp.forEach((val, key) => (result[key] = val));
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
35
|
//# sourceMappingURL=FetchRequestConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchRequestConfig.js","sourceRoot":"","sources":["../src/FetchRequestConfig.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"FetchRequestConfig.js","sourceRoot":"","sources":["../src/FetchRequestConfig.ts"],"names":[],"mappings":";;;;AAEA,MAAM,cAAc,GAAuB;IACzC,KAAK,EAAE,UAAU;CAClB,CAAC;AASF,SAAgB,gBAAgB,CAAC,MAA2B;IAC1D,OAAO,gBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAFD,4CAEC;AAID,SAAgB,gBAAgB,CAAC,GAAG,OAA8C;IAChF,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAA2B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C,MAAM,CACL,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;QACrB,MAAM,EAAE,OAAO,EAAE,WAAW,KAAyB,SAAS,EAA7B,eAAe,kBAAK,SAAS,EAAxD,WAA4C,CAAY,CAAC;QAC/D,MAAM,EAAE,OAAO,KAAqB,OAAO,EAAvB,WAAW,kBAAK,OAAO,EAArC,WAA2B,CAAU,CAAC;QAE5C,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,OAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAChG;QAED,uCAAY,SAAS,GAAK,WAAW,EAAG;IAC1C,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,CAChB,CAAC;AACN,CAAC;AAnBD,4CAmBC;AAED,SAAS,YAAY,CAAC,OAA+B;IACnD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IAC3B,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAEhD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { ODataRequestConfig } from \"@odata2ts/http-client-api\";\n\nconst DEFAULT_CONFIG: FetchRequestConfig = {\n cache: \"no-store\",\n};\n\n/**\n * Available config options for end user when making a given request.\n */\nexport interface FetchRequestConfig\n extends ODataRequestConfig,\n Partial<Pick<RequestInit, \"credentials\" | \"cache\" | \"mode\" | \"redirect\" | \"referrerPolicy\" | \"signal\">> {}\n\nexport function getDefaultConfig(config?: FetchRequestConfig): FetchRequestConfig {\n return mergeFetchConfig(DEFAULT_CONFIG, config);\n}\n\nexport function mergeFetchConfig(): undefined;\nexport function mergeFetchConfig(...configs: Array<FetchRequestConfig | undefined>): FetchRequestConfig;\nexport function mergeFetchConfig(...configs: Array<FetchRequestConfig | undefined>) {\n if (!configs.length) {\n return undefined;\n }\n return configs\n .filter((c): c is FetchRequestConfig => !!c)\n .reduce<FetchRequestConfig>(\n (collector, current) => {\n const { headers: prevHeaders, ...prevPassThrough } = collector;\n const { headers, ...passThrough } = current;\n\n if (headers) {\n Object.entries(cleanHeaders(headers)).forEach(([key, val]) => (collector.headers![key] = val));\n }\n\n return { ...collector, ...passThrough };\n },\n { headers: {} },\n );\n}\n\nfunction cleanHeaders(headers: Record<string, string>): Record<string, string> {\n const result: Record<string, string> = {};\n const temp = new Headers();\n Object.entries(headers).forEach(([key, val]) => temp.set(key, val));\n temp.forEach((val, key) => (result[key] = val));\n\n return result;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/http-client-fetch",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "HTTP client based on fetch and consumable by odata2ts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"http client",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "vitest run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@odata2ts/http-client-base": "^0.5.
|
|
33
|
+
"@odata2ts/http-client-base": "^0.5.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@odata2ts/odata-core": "^0.3.7",
|