@odata2ts/http-client-axios 0.11.0 → 0.11.2

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 CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.11.2](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-axios@0.11.1...@odata2ts/http-client-axios@0.11.2) (2024-08-22)
7
+
8
+ **Note:** Version bump only for package @odata2ts/http-client-axios
9
+
10
+ ## [0.11.1](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-axios@0.11.0...@odata2ts/http-client-axios@0.11.1) (2024-08-14)
11
+
12
+ ### Bug Fixes
13
+
14
+ * add ".js" suffix for all relative imports ([#20](https://github.com/odata2ts/http-client/issues/20)) ([961c910](https://github.com/odata2ts/http-client/commit/961c91002c8b1e9a7a6256cccd6b6d0ec9c142cd))
15
+
6
16
  # [0.11.0](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-axios@0.10.2...@odata2ts/http-client-axios@0.11.0) (2024-08-13)
7
17
 
8
18
  ### Code Refactoring
@@ -1,27 +1,30 @@
1
- import { __awaiter } from "tslib";
2
- import { BaseHttpClient, } from "@odata2ts/http-client-base";
3
- import axios from "axios";
4
- import { AxiosClientError } from "./AxiosClientError";
5
- import { mergeConfig } from "./AxiosRequestConfig";
6
- export const DEFAULT_ERROR_MESSAGE = "No error message!";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxiosClient = exports.DEFAULT_ERROR_MESSAGE = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const http_client_base_1 = require("@odata2ts/http-client-base");
6
+ const axios_1 = tslib_1.__importDefault(require("axios"));
7
+ const AxiosClientError_1 = require("./AxiosClientError");
8
+ const AxiosRequestConfig_1 = require("./AxiosRequestConfig");
9
+ exports.DEFAULT_ERROR_MESSAGE = "No error message!";
7
10
  const FAILURE_NO_RESPONSE = "No response from server! Failure: ";
8
11
  const FAILURE_NO_REQUEST = "No request was sent! Failure: ";
9
12
  const FAILURE_RESPONSE_MESSAGE = "OData server responded with error: ";
10
13
  const FAILURE_AXIOS = "Fatal Axios failure: ";
11
14
  function buildErrorMessage(prefix, error) {
12
15
  const msg = typeof error === "string" ? error : error === null || error === void 0 ? void 0 : error.message;
13
- return prefix + (msg || DEFAULT_ERROR_MESSAGE);
16
+ return prefix + (msg || exports.DEFAULT_ERROR_MESSAGE);
14
17
  }
15
- export class AxiosClient extends BaseHttpClient {
18
+ class AxiosClient extends http_client_base_1.BaseHttpClient {
16
19
  constructor(config, clientOptions) {
17
20
  super(clientOptions);
18
- this.client = axios.create(config);
21
+ this.client = axios_1.default.create(config);
19
22
  }
20
23
  executeRequest(method, url, data, requestConfig = {}, internalConfig = {}) {
21
- return __awaiter(this, void 0, void 0, function* () {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
25
  // add URL, HTTP method and additional headers to the request config
23
26
  const { headers } = internalConfig;
24
- const config = mergeConfig({ headers }, requestConfig, { url, method });
27
+ const config = (0, AxiosRequestConfig_1.mergeConfig)({ headers }, requestConfig, { url, method });
25
28
  if (typeof data !== "undefined") {
26
29
  config.data = data;
27
30
  }
@@ -38,15 +41,15 @@ export class AxiosClient extends BaseHttpClient {
38
41
  if (axiosError.response) {
39
42
  const errMsg = this.retrieveErrorMessage(axiosError.response.data);
40
43
  const msg = buildErrorMessage(FAILURE_RESPONSE_MESSAGE, errMsg);
41
- throw new AxiosClientError(msg, axiosError.response.status, this.mapHeaders(axiosError.response.headers), new Error(errMsg || DEFAULT_ERROR_MESSAGE), axiosError);
44
+ throw new AxiosClientError_1.AxiosClientError(msg, axiosError.response.status, this.mapHeaders(axiosError.response.headers), new Error(errMsg || exports.DEFAULT_ERROR_MESSAGE), axiosError);
42
45
  }
43
46
  // fatal failure without response
44
47
  else {
45
- throw new AxiosClientError(buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError), undefined, undefined, error, axiosError);
48
+ throw new AxiosClientError_1.AxiosClientError(buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError), undefined, undefined, error, axiosError);
46
49
  }
47
50
  }
48
51
  // not an Axios error
49
- throw new AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, undefined, error);
52
+ throw new AxiosClientError_1.AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, undefined, error);
50
53
  }
51
54
  });
52
55
  }
@@ -54,4 +57,5 @@ export class AxiosClient extends BaseHttpClient {
54
57
  return headers;
55
58
  }
56
59
  }
60
+ exports.AxiosClient = AxiosClient;
57
61
  //# sourceMappingURL=AxiosClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosClient.js","sourceRoot":"","sources":["../src/AxiosClient.ts"],"names":[],"mappings":";AACA,OAAO,EACL,cAAc,GAIf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAsB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AACjE,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAC5D,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AACvE,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,SAAS,iBAAiB,CAAC,MAAc,EAAE,KAAU;IACnD,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,KAAe,aAAf,KAAK,uBAAL,KAAK,CAAY,OAAO,CAAC;IAC1E,OAAO,MAAM,GAAG,CAAC,GAAG,IAAI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AC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAC5C,IAAI,KAAK,CAAC,MAAM,IAAI,qBAAqB,CAAC,EAC1C,UAAU,CACX,CAAC;qBACH;oBACD,iCAAiC;yBAC5B;wBACH,MAAM,IAAI,gBAAgB,CACxB,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAC5F,SAAS,EACT,SAAS,EACT,KAAK,EACL,UAAU,CACX,CAAC;qBACH;iBACF;gBACD,qBAAqB;gBACrB,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;aAClG;QACH,CAAC;KAAA;IAES,UAAU,CAAC,OAAuD;QAC1E,OAAO,OAAiC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { HttpResponseModel, ODataHttpClient, ODataResponse } from \"@odata2ts/http-client-api\";\nimport {\n BaseHttpClient,\n BaseHttpClientOptions,\n HttpMethods,\n InternalHttpClientConfig,\n} from \"@odata2ts/http-client-base\";\nimport axios, {\n AxiosError,\n AxiosInstance,\n AxiosResponseHeaders,\n AxiosRequestConfig as OriginalRequestConfig,\n RawAxiosResponseHeaders,\n} from \"axios\";\nimport { AxiosClientError } from \"./AxiosClientError\";\nimport { AxiosRequestConfig, mergeConfig } from \"./AxiosRequestConfig\";\n\nexport interface ClientOptions extends BaseHttpClientOptions {}\n\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\nconst FAILURE_NO_RESPONSE = \"No response from server! Failure: \";\nconst FAILURE_NO_REQUEST = \"No request was sent! Failure: \";\nconst FAILURE_RESPONSE_MESSAGE = \"OData server responded with error: \";\nconst FAILURE_AXIOS = \"Fatal Axios failure: \";\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\nexport class AxiosClient extends BaseHttpClient<AxiosRequestConfig> implements ODataHttpClient<AxiosRequestConfig> {\n protected readonly client: AxiosInstance;\n\n constructor(config?: AxiosRequestConfig, clientOptions?: ClientOptions) {\n super(clientOptions);\n this.client = axios.create(config);\n }\n\n protected async executeRequest<ResponseModel>(\n method: HttpMethods,\n url: string,\n data: any,\n requestConfig: AxiosRequestConfig | undefined = {},\n internalConfig: InternalHttpClientConfig = {},\n ): Promise<HttpResponseModel<ResponseModel>> {\n // add URL, HTTP method and additional headers to the request config\n const { headers } = internalConfig;\n const config: OriginalRequestConfig = mergeConfig({ headers }, requestConfig, { url, method });\n if (typeof data !== \"undefined\") {\n config.data = data;\n }\n\n if (internalConfig.dataType && internalConfig.dataType !== \"json\") {\n config.responseType = internalConfig.dataType;\n }\n\n try {\n return await this.client.request(config);\n } catch (error: any) {\n if ((error as AxiosError).isAxiosError) {\n const axiosError = error as AxiosError;\n\n // regular failure handling\n if (axiosError.response) {\n const errMsg = this.retrieveErrorMessage(axiosError.response.data);\n const msg = buildErrorMessage(FAILURE_RESPONSE_MESSAGE, errMsg);\n throw new AxiosClientError(\n msg,\n axiosError.response.status,\n this.mapHeaders(axiosError.response.headers),\n new Error(errMsg || DEFAULT_ERROR_MESSAGE),\n axiosError,\n );\n }\n // fatal failure without response\n else {\n throw new AxiosClientError(\n buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError),\n undefined,\n undefined,\n error,\n axiosError,\n );\n }\n }\n // not an Axios error\n throw new AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, undefined, error);\n }\n }\n\n protected mapHeaders(headers: AxiosResponseHeaders | RawAxiosResponseHeaders): Record<string, string> {\n return headers as Record<string, string>;\n }\n}\n"]}
1
+ {"version":3,"file":"AxiosClient.js","sourceRoot":"","sources":["../src/AxiosClient.ts"],"names":[],"mappings":";;;;AACA,iEAKoC;AACpC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CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC1C;YAAC,OAAO,KAAU,EAAE;gBACnB,IAAK,KAAoB,CAAC,YAAY,EAAE;oBACtC,MAAM,UAAU,GAAG,KAAmB,CAAC;oBAEvC,2BAA2B;oBAC3B,IAAI,UAAU,CAAC,QAAQ,EAAE;wBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBACnE,MAAM,GAAG,GAAG,iBAAiB,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;wBAChE,MAAM,IAAI,mCAAgB,CACxB,GAAG,EACH,UAAU,CAAC,QAAQ,CAAC,MAAM,EAC1B,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAC5C,IAAI,KAAK,CAAC,MAAM,IAAI,6BAAqB,CAAC,EAC1C,UAAU,CACX,CAAC;qBACH;oBACD,iCAAiC;yBAC5B;wBACH,MAAM,IAAI,mCAAgB,CACxB,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAC5F,SAAS,EACT,SAAS,EACT,KAAK,EACL,UAAU,CACX,CAAC;qBACH;iBACF;gBACD,qBAAqB;gBACrB,MAAM,IAAI,mCAAgB,CAAC,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;aAClG;QACH,CAAC;KAAA;IAES,UAAU,CAAC,OAAuD;QAC1E,OAAO,OAAiC,CAAC;IAC3C,CAAC;CACF;AA/DD,kCA+DC","sourcesContent":["import { HttpResponseModel, ODataHttpClient } from \"@odata2ts/http-client-api\";\r\nimport {\r\n BaseHttpClient,\r\n BaseHttpClientOptions,\r\n HttpMethods,\r\n InternalHttpClientConfig,\r\n} from \"@odata2ts/http-client-base\";\r\nimport axios, {\r\n AxiosError,\r\n AxiosInstance,\r\n AxiosResponseHeaders,\r\n AxiosRequestConfig as OriginalRequestConfig,\r\n RawAxiosResponseHeaders,\r\n} from \"axios\";\r\nimport { AxiosClientError } from \"./AxiosClientError\";\r\nimport { AxiosRequestConfig, mergeConfig } from \"./AxiosRequestConfig\";\r\n\r\nexport interface ClientOptions extends BaseHttpClientOptions {}\r\n\r\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\r\nconst FAILURE_NO_RESPONSE = \"No response from server! Failure: \";\r\nconst FAILURE_NO_REQUEST = \"No request was sent! Failure: \";\r\nconst FAILURE_RESPONSE_MESSAGE = \"OData server responded with error: \";\r\nconst FAILURE_AXIOS = \"Fatal Axios failure: \";\r\n\r\nfunction buildErrorMessage(prefix: string, error: any) {\r\n const msg = typeof error === \"string\" ? error : (error as Error)?.message;\r\n return prefix + (msg || DEFAULT_ERROR_MESSAGE);\r\n}\r\n\r\nexport class AxiosClient extends BaseHttpClient<AxiosRequestConfig> implements ODataHttpClient<AxiosRequestConfig> {\r\n protected readonly client: AxiosInstance;\r\n\r\n constructor(config?: AxiosRequestConfig, clientOptions?: ClientOptions) {\r\n super(clientOptions);\r\n this.client = axios.create(config);\r\n }\r\n\r\n protected async executeRequest<ResponseModel>(\r\n method: HttpMethods,\r\n url: string,\r\n data: any,\r\n requestConfig: AxiosRequestConfig | undefined = {},\r\n internalConfig: InternalHttpClientConfig = {},\r\n ): Promise<HttpResponseModel<ResponseModel>> {\r\n // add URL, HTTP method and additional headers to the request config\r\n const { headers } = internalConfig;\r\n const config: OriginalRequestConfig = mergeConfig({ headers }, requestConfig, { url, method });\r\n if (typeof data !== \"undefined\") {\r\n config.data = data;\r\n }\r\n\r\n if (internalConfig.dataType && internalConfig.dataType !== \"json\") {\r\n config.responseType = internalConfig.dataType;\r\n }\r\n\r\n try {\r\n return await this.client.request(config);\r\n } catch (error: any) {\r\n if ((error as AxiosError).isAxiosError) {\r\n const axiosError = error as AxiosError;\r\n\r\n // regular failure handling\r\n if (axiosError.response) {\r\n const errMsg = this.retrieveErrorMessage(axiosError.response.data);\r\n const msg = buildErrorMessage(FAILURE_RESPONSE_MESSAGE, errMsg);\r\n throw new AxiosClientError(\r\n msg,\r\n axiosError.response.status,\r\n this.mapHeaders(axiosError.response.headers),\r\n new Error(errMsg || DEFAULT_ERROR_MESSAGE),\r\n axiosError,\r\n );\r\n }\r\n // fatal failure without response\r\n else {\r\n throw new AxiosClientError(\r\n buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError),\r\n undefined,\r\n undefined,\r\n error,\r\n axiosError,\r\n );\r\n }\r\n }\r\n // not an Axios error\r\n throw new AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, undefined, error);\r\n }\r\n }\r\n\r\n protected mapHeaders(headers: AxiosResponseHeaders | RawAxiosResponseHeaders): Record<string, string> {\r\n return headers as Record<string, string>;\r\n }\r\n}\r\n"]}
@@ -1,4 +1,7 @@
1
- export class AxiosClientError extends Error {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxiosClientError = void 0;
4
+ class AxiosClientError extends Error {
2
5
  constructor(msg, status, headers, cause, axiosError) {
3
6
  // @ts-ignore: fetch requires lib "dom" or "webworker", but then the "cause" property becomes unknown to TS
4
7
  super(msg, { cause });
@@ -9,4 +12,5 @@ export class AxiosClientError extends Error {
9
12
  this.name = this.constructor.name;
10
13
  }
11
14
  }
15
+ exports.AxiosClientError = AxiosClientError;
12
16
  //# sourceMappingURL=AxiosClientError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosClientError.js","sourceRoot":"","sources":["../src/AxiosClientError.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YACE,GAAW,EACK,MAAe,EACf,OAAgC,EAChC,KAAa,EACb,UAAuB;QAEvC,2GAA2G;QAC3G,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QANN,WAAM,GAAN,MAAM,CAAS;QACf,YAAO,GAAP,OAAO,CAAyB;QAChC,UAAK,GAAL,KAAK,CAAQ;QACb,eAAU,GAAV,UAAU,CAAa;QAIvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF","sourcesContent":["import { ODataClientError } from \"@odata2ts/http-client-api\";\nimport type { AxiosError } from \"axios\";\n\nexport class AxiosClientError extends Error implements ODataClientError {\n constructor(\n msg: string,\n public readonly status?: number,\n public readonly headers?: Record<string, string>,\n public readonly cause?: Error,\n public readonly axiosError?: AxiosError,\n ) {\n // @ts-ignore: fetch requires lib \"dom\" or \"webworker\", but then the \"cause\" property becomes unknown to TS\n super(msg, { cause });\n this.name = this.constructor.name;\n }\n}\n"]}
1
+ {"version":3,"file":"AxiosClientError.js","sourceRoot":"","sources":["../src/AxiosClientError.ts"],"names":[],"mappings":";;;AAGA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YACE,GAAW,EACK,MAAe,EACf,OAAgC,EAChC,KAAa,EACb,UAAuB;QAEvC,2GAA2G;QAC3G,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QANN,WAAM,GAAN,MAAM,CAAS;QACf,YAAO,GAAP,OAAO,CAAyB;QAChC,UAAK,GAAL,KAAK,CAAQ;QACb,eAAU,GAAV,UAAU,CAAa;QAIvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAZD,4CAYC","sourcesContent":["import { ODataClientError } from \"@odata2ts/http-client-api\";\nimport type { AxiosError } from \"axios\";\n\nexport class AxiosClientError extends Error implements ODataClientError {\n constructor(\n msg: string,\n public readonly status?: number,\n public readonly headers?: Record<string, string>,\n public readonly cause?: Error,\n public readonly axiosError?: AxiosError,\n ) {\n // @ts-ignore: fetch requires lib \"dom\" or \"webworker\", but then the \"cause\" property becomes unknown to TS\n super(msg, { cause });\n this.name = this.constructor.name;\n }\n}\n"]}
@@ -1,16 +1,20 @@
1
- import { __rest } from "tslib";
2
- export function mergeConfig(...configs) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ function mergeConfig(...configs) {
3
6
  if (!configs.length) {
4
7
  return undefined;
5
8
  }
6
9
  return configs
7
10
  .filter((c) => !!c)
8
11
  .reduce((collector, current) => {
9
- const { headers } = current, passThrough = __rest(current, ["headers"]);
12
+ const { headers } = current, passThrough = tslib_1.__rest(current, ["headers"]);
10
13
  if (headers) {
11
14
  Object.entries(headers).forEach(([key, val]) => (collector.headers[key] = val));
12
15
  }
13
16
  return Object.assign(Object.assign({}, collector), passThrough);
14
17
  }, { headers: {} });
15
18
  }
19
+ exports.mergeConfig = mergeConfig;
16
20
  //# sourceMappingURL=AxiosRequestConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosRequestConfig.js","sourceRoot":"","sources":["../src/AxiosRequestConfig.ts"],"names":[],"mappings":";AAaA,MAAM,UAAU,WAAW,CAAC,GAAG,OAAiD;IAC9E,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM,CACL,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;QACrB,MAAM,EAAE,OAAO,KAAqB,OAAO,EAAvB,WAAW,UAAK,OAAO,EAArC,WAA2B,CAAU,CAAC;QAE5C,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,OAAO,CAAC,OAAO,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;SAClF;QACD,uCAAY,SAAS,GAAK,WAAW,EAAG;IAC1C,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,CAChB,CAAC;AACN,CAAC","sourcesContent":["import { CreateAxiosDefaults, AxiosRequestConfig as OriginalRequestConfig } from \"axios\";\n\nexport interface AxiosRequestConfig extends Omit<OriginalRequestConfig, \"method\" | \"url\" | \"headers\"> {\n headers?: Record<string, string>;\n}\n\nexport interface InternalRequestConfig extends Omit<OriginalRequestConfig, \"headers\"> {\n url?: string;\n headers?: Record<string, string>;\n}\n\nexport function mergeConfig(): undefined;\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>): InternalRequestConfig;\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>) {\n if (!configs.length) {\n return undefined;\n }\n\n return configs\n .filter((c): c is InternalRequestConfig => !!c)\n .reduce<InternalRequestConfig>(\n (collector, current) => {\n const { headers, ...passThrough } = current;\n\n if (headers) {\n Object.entries(headers).forEach(([key, val]) => (collector.headers![key] = val));\n }\n return { ...collector, ...passThrough };\n },\n { headers: {} },\n );\n}\n"]}
1
+ {"version":3,"file":"AxiosRequestConfig.js","sourceRoot":"","sources":["../src/AxiosRequestConfig.ts"],"names":[],"mappings":";;;;AAaA,SAAgB,WAAW,CAAC,GAAG,OAAiD;IAC9E,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM,CACL,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;QACrB,MAAM,EAAE,OAAO,KAAqB,OAAO,EAAvB,WAAW,kBAAK,OAAO,EAArC,WAA2B,CAAU,CAAC;QAE5C,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,OAAO,CAAC,OAAO,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;SAClF;QACD,uCAAY,SAAS,GAAK,WAAW,EAAG;IAC1C,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,CAChB,CAAC;AACN,CAAC;AAlBD,kCAkBC","sourcesContent":["import { AxiosRequestConfig as OriginalRequestConfig } from \"axios\";\r\n\r\nexport interface AxiosRequestConfig extends Omit<OriginalRequestConfig, \"method\" | \"url\" | \"headers\"> {\r\n headers?: Record<string, string>;\r\n}\r\n\r\nexport interface InternalRequestConfig extends Omit<OriginalRequestConfig, \"headers\"> {\r\n url?: string;\r\n headers?: Record<string, string>;\r\n}\r\n\r\nexport function mergeConfig(): undefined;\r\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>): InternalRequestConfig;\r\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>) {\r\n if (!configs.length) {\r\n return undefined;\r\n }\r\n\r\n return configs\r\n .filter((c): c is InternalRequestConfig => !!c)\r\n .reduce<InternalRequestConfig>(\r\n (collector, current) => {\r\n const { headers, ...passThrough } = current;\r\n\r\n if (headers) {\r\n Object.entries(headers).forEach(([key, val]) => (collector.headers![key] = val));\r\n }\r\n return { ...collector, ...passThrough };\r\n },\r\n { headers: {} },\r\n );\r\n}\r\n"]}
package/lib/index.js CHANGED
@@ -1,3 +1,8 @@
1
- export * from "./AxiosClient";
2
- export { AxiosClientError } from "./AxiosClientError";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxiosClientError = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./AxiosClient"), exports);
6
+ var AxiosClientError_1 = require("./AxiosClientError");
7
+ Object.defineProperty(exports, "AxiosClientError", { enumerable: true, get: function () { return AxiosClientError_1.AxiosClientError; } });
3
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export * from \"./AxiosClient\";\nexport { AxiosClientError } from \"./AxiosClientError\";\nexport { AxiosRequestConfig } from \"./AxiosRequestConfig\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAA8B;AAC9B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["export * from \"./AxiosClient\";\r\nexport { AxiosClientError } from \"./AxiosClientError\";\r\nexport { AxiosRequestConfig } from \"./AxiosRequestConfig\";\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/http-client-axios",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Axios based odata HTTP client consumable by odata2ts",
5
5
  "keywords": [
6
6
  "http client",
@@ -13,7 +13,7 @@
13
13
  "repository": "git@github.com:odata2ts/http-client.git",
14
14
  "license": "MIT",
15
15
  "author": "texttechne",
16
- "type": "module",
16
+ "type": "commonjs",
17
17
  "main": "./lib/index.js",
18
18
  "types": "./lib/index.d.ts",
19
19
  "files": [
@@ -31,7 +31,7 @@
31
31
  "test": "vitest run test/**"
32
32
  },
33
33
  "dependencies": {
34
- "@odata2ts/http-client-base": "^0.5.0"
34
+ "@odata2ts/http-client-base": "^0.5.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^17.0.23",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "6a0905bd7f201a5c91d83a9319c2a0325a017651"
48
+ "gitHead": "20d77b211d6c7a44e7f1d14e9b63be531bb30e87"
49
49
  }