abbot-http-client 0.0.33 → 0.0.35

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/dist/index.cjs CHANGED
@@ -30,10 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- AbbotHttp: () => AbbotHttp,
34
33
  AppError: () => AppError,
35
34
  RestError: () => RestError,
36
- catchError: () => catchError
35
+ catchError: () => catchError,
36
+ create: () => create
37
37
  });
38
38
  module.exports = __toCommonJS(index_exports);
39
39
 
@@ -202,18 +202,18 @@ function axiosConf(cfg) {
202
202
  var AbbotHttp = class {
203
203
  config = defaultConfig;
204
204
  constructor(config) {
205
- this.config = this.deepMerge(this.config, config);
206
- }
207
- deepMerge(target, source) {
208
- for (const key in source) {
209
- const srcVal = source[key];
210
- if (srcVal && typeof srcVal === "object" && !Array.isArray(srcVal)) {
211
- target[key] = deepMerge(target[key], srcVal);
212
- } else if (srcVal !== void 0) {
213
- target[key] = srcVal;
205
+ function deepMerge(target, source) {
206
+ for (const key in source) {
207
+ const srcVal = source[key];
208
+ if (srcVal && typeof srcVal === "object" && !Array.isArray(srcVal)) {
209
+ target[key] = deepMerge(target[key], srcVal);
210
+ } else if (srcVal !== void 0) {
211
+ target[key] = srcVal;
212
+ }
214
213
  }
214
+ return target;
215
215
  }
216
- return target;
216
+ this.config = deepMerge(this.config, config);
217
217
  }
218
218
  createAxiosInstance(option) {
219
219
  const axios2 = axiosConf(this.config);
@@ -445,10 +445,16 @@ var AbbotHttp = class {
445
445
  return this.config;
446
446
  }
447
447
  };
448
+
449
+ // src/config/core.ts
450
+ function create(config) {
451
+ const http = new AbbotHttp(config);
452
+ return http;
453
+ }
448
454
  // Annotate the CommonJS export names for ESM import in node:
449
455
  0 && (module.exports = {
450
- AbbotHttp,
451
456
  AppError,
452
457
  RestError,
453
- catchError
458
+ catchError,
459
+ create
454
460
  });
package/dist/index.d.cts CHANGED
@@ -55,7 +55,6 @@ interface AbbotResponse$1<T> {
55
55
  declare class AbbotHttp {
56
56
  protected config: AbbotConfig;
57
57
  constructor(config: DeepPartial<AbbotConfig>);
58
- protected deepMerge<T>(target: T, source: DeepPartial<T>): T;
59
58
  protected createAxiosInstance(option?: Partial<MethodOption>): AxiosInstance;
60
59
  protected prepareRequestConfig(option?: Partial<MethodOption>): {
61
60
  cryp: Cryp;
@@ -82,6 +81,8 @@ declare class RestError<T extends AxiosError> extends Error {
82
81
  constructor(rs: T);
83
82
  }
84
83
 
84
+ declare function create(config: DeepPartial<AbbotConfig>): AbbotHttp;
85
+
85
86
  type AbbotResponse<T> = AbbotResponse$1<T>;
86
87
 
87
- export { type AbbotConfig, AbbotHttp, type AbbotResponse, AppError, RestError, catchError };
88
+ export { type AbbotConfig, type AbbotResponse, AppError, RestError, catchError, create };
package/dist/index.d.ts CHANGED
@@ -55,7 +55,6 @@ interface AbbotResponse$1<T> {
55
55
  declare class AbbotHttp {
56
56
  protected config: AbbotConfig;
57
57
  constructor(config: DeepPartial<AbbotConfig>);
58
- protected deepMerge<T>(target: T, source: DeepPartial<T>): T;
59
58
  protected createAxiosInstance(option?: Partial<MethodOption>): AxiosInstance;
60
59
  protected prepareRequestConfig(option?: Partial<MethodOption>): {
61
60
  cryp: Cryp;
@@ -82,6 +81,8 @@ declare class RestError<T extends AxiosError> extends Error {
82
81
  constructor(rs: T);
83
82
  }
84
83
 
84
+ declare function create(config: DeepPartial<AbbotConfig>): AbbotHttp;
85
+
85
86
  type AbbotResponse<T> = AbbotResponse$1<T>;
86
87
 
87
- export { type AbbotConfig, AbbotHttp, type AbbotResponse, AppError, RestError, catchError };
88
+ export { type AbbotConfig, type AbbotResponse, AppError, RestError, catchError, create };
package/dist/index.js CHANGED
@@ -165,18 +165,18 @@ function axiosConf(cfg) {
165
165
  var AbbotHttp = class {
166
166
  config = defaultConfig;
167
167
  constructor(config) {
168
- this.config = this.deepMerge(this.config, config);
169
- }
170
- deepMerge(target, source) {
171
- for (const key in source) {
172
- const srcVal = source[key];
173
- if (srcVal && typeof srcVal === "object" && !Array.isArray(srcVal)) {
174
- target[key] = deepMerge(target[key], srcVal);
175
- } else if (srcVal !== void 0) {
176
- target[key] = srcVal;
168
+ function deepMerge(target, source) {
169
+ for (const key in source) {
170
+ const srcVal = source[key];
171
+ if (srcVal && typeof srcVal === "object" && !Array.isArray(srcVal)) {
172
+ target[key] = deepMerge(target[key], srcVal);
173
+ } else if (srcVal !== void 0) {
174
+ target[key] = srcVal;
175
+ }
177
176
  }
177
+ return target;
178
178
  }
179
- return target;
179
+ this.config = deepMerge(this.config, config);
180
180
  }
181
181
  createAxiosInstance(option) {
182
182
  const axios2 = axiosConf(this.config);
@@ -408,9 +408,15 @@ var AbbotHttp = class {
408
408
  return this.config;
409
409
  }
410
410
  };
411
+
412
+ // src/config/core.ts
413
+ function create(config) {
414
+ const http = new AbbotHttp(config);
415
+ return http;
416
+ }
411
417
  export {
412
- AbbotHttp,
413
418
  AppError,
414
419
  RestError,
415
- catchError
420
+ catchError,
421
+ create
416
422
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abbot-http-client",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "This package helps Abbot team to handle all the axios requests.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",