abbot-http-client 0.0.26 → 0.0.28

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
@@ -196,7 +196,9 @@ var CoreHttp = class {
196
196
  payload.param = cryp.encrypt(JSON.stringify(config.data));
197
197
  const body = payload ? new URLSearchParams(payload).toString() : "";
198
198
  req.data = body;
199
- req.headers.setContentType("application/x-www-form-urlencoded");
199
+ req.headers.setContentType(
200
+ option?.contentType ?? this.config.axios.headers.post.contentType
201
+ );
200
202
  }
201
203
  }
202
204
  }
@@ -308,7 +310,10 @@ var CoreHttp = class {
308
310
  const fileKeys = param1;
309
311
  const param = param2;
310
312
  const opt = param3;
311
- const axios2 = this.createAxiosInstance(opt);
313
+ const axios2 = this.createAxiosInstance({
314
+ contentType: "multipart/form-data",
315
+ ...opt
316
+ });
312
317
  fileKeys.forEach((k, i) => {
313
318
  formData.append(k, file[i]);
314
319
  });
package/dist/index.d.cts CHANGED
@@ -1,28 +1,5 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
2
 
3
- declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
4
-
5
- interface AbbotResponse<T> {
6
- code: AxiosResponse["status"];
7
- detail: string | null;
8
- message: string;
9
- status: string;
10
- data: T;
11
- }
12
- interface MethodOption {
13
- isInit: boolean;
14
- }
15
- declare class CoreHttp {
16
- private config;
17
- constructor(config: AbbotConfig);
18
- private createAxiosInstance;
19
- post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
20
- get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
21
- uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
22
- uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
23
- getConfig(): AbbotConfig;
24
- }
25
-
26
3
  type DeepPartial<T> = T extends object ? {
27
4
  [P in keyof T]?: DeepPartial<T[P]>;
28
5
  } : T;
@@ -50,6 +27,30 @@ interface AbbotConfig {
50
27
  }
51
28
  declare function create(config: DeepPartial<AbbotConfig>): CoreHttp;
52
29
 
30
+ interface MethodOption {
31
+ isInit: boolean;
32
+ contentType: string;
33
+ }
34
+ interface AbbotResponse$1<T> {
35
+ code: AxiosResponse["status"];
36
+ detail: string | null;
37
+ message: string;
38
+ status: string;
39
+ data: T;
40
+ }
41
+ declare class CoreHttp {
42
+ private config;
43
+ constructor(config: AbbotConfig);
44
+ private createAxiosInstance;
45
+ post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
46
+ get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
47
+ uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
48
+ uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
49
+ getConfig(): AbbotConfig;
50
+ }
51
+
52
+ declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
53
+
53
54
  declare class AppError extends Error {
54
55
  name: string;
55
56
  }
@@ -59,4 +60,6 @@ declare class RestError<T extends AxiosError> extends Error {
59
60
  constructor(rs: T);
60
61
  }
61
62
 
62
- export { type AbbotConfig, AppError, RestError, catchError, create };
63
+ type AbbotResponse<T> = AbbotResponse$1<T>;
64
+
65
+ export { type AbbotConfig, type AbbotResponse, AppError, RestError, catchError, create };
package/dist/index.d.ts CHANGED
@@ -1,28 +1,5 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
2
 
3
- declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
4
-
5
- interface AbbotResponse<T> {
6
- code: AxiosResponse["status"];
7
- detail: string | null;
8
- message: string;
9
- status: string;
10
- data: T;
11
- }
12
- interface MethodOption {
13
- isInit: boolean;
14
- }
15
- declare class CoreHttp {
16
- private config;
17
- constructor(config: AbbotConfig);
18
- private createAxiosInstance;
19
- post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
20
- get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
21
- uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
22
- uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
23
- getConfig(): AbbotConfig;
24
- }
25
-
26
3
  type DeepPartial<T> = T extends object ? {
27
4
  [P in keyof T]?: DeepPartial<T[P]>;
28
5
  } : T;
@@ -50,6 +27,30 @@ interface AbbotConfig {
50
27
  }
51
28
  declare function create(config: DeepPartial<AbbotConfig>): CoreHttp;
52
29
 
30
+ interface MethodOption {
31
+ isInit: boolean;
32
+ contentType: string;
33
+ }
34
+ interface AbbotResponse$1<T> {
35
+ code: AxiosResponse["status"];
36
+ detail: string | null;
37
+ message: string;
38
+ status: string;
39
+ data: T;
40
+ }
41
+ declare class CoreHttp {
42
+ private config;
43
+ constructor(config: AbbotConfig);
44
+ private createAxiosInstance;
45
+ post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
46
+ get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
47
+ uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
48
+ uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse$1<T>>;
49
+ getConfig(): AbbotConfig;
50
+ }
51
+
52
+ declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
53
+
53
54
  declare class AppError extends Error {
54
55
  name: string;
55
56
  }
@@ -59,4 +60,6 @@ declare class RestError<T extends AxiosError> extends Error {
59
60
  constructor(rs: T);
60
61
  }
61
62
 
62
- export { type AbbotConfig, AppError, RestError, catchError, create };
63
+ type AbbotResponse<T> = AbbotResponse$1<T>;
64
+
65
+ export { type AbbotConfig, type AbbotResponse, AppError, RestError, catchError, create };
package/dist/index.js CHANGED
@@ -157,7 +157,9 @@ var CoreHttp = class {
157
157
  payload.param = cryp.encrypt(JSON.stringify(config.data));
158
158
  const body = payload ? new URLSearchParams(payload).toString() : "";
159
159
  req.data = body;
160
- req.headers.setContentType("application/x-www-form-urlencoded");
160
+ req.headers.setContentType(
161
+ option?.contentType ?? this.config.axios.headers.post.contentType
162
+ );
161
163
  }
162
164
  }
163
165
  }
@@ -269,7 +271,10 @@ var CoreHttp = class {
269
271
  const fileKeys = param1;
270
272
  const param = param2;
271
273
  const opt = param3;
272
- const axios2 = this.createAxiosInstance(opt);
274
+ const axios2 = this.createAxiosInstance({
275
+ contentType: "multipart/form-data",
276
+ ...opt
277
+ });
273
278
  fileKeys.forEach((k, i) => {
274
279
  formData.append(k, file[i]);
275
280
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abbot-http-client",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
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",