@ventlio/tanstack-query 0.5.4 → 0.5.6

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.
Files changed (76) hide show
  1. package/dist/config/bootstrapQueryRequest.d.ts +4 -4
  2. package/dist/config/bootstrapQueryRequest.js +15 -15
  3. package/dist/config/config.interface.d.ts +4 -4
  4. package/dist/config/index.d.ts +6 -6
  5. package/dist/config/useEnvironmentVariables.d.ts +2 -2
  6. package/dist/config/useEnvironmentVariables.js +8 -8
  7. package/dist/config/useQueryConfig.d.ts +2 -2
  8. package/dist/config/useQueryConfig.js +5 -5
  9. package/dist/config/useQueryHeaders.d.ts +2 -2
  10. package/dist/config/useQueryHeaders.js +9 -9
  11. package/dist/config/useReactNativeEnv.d.ts +5 -5
  12. package/dist/config/useReactNativeEnv.js +6 -6
  13. package/dist/helpers/index.d.ts +2 -2
  14. package/dist/helpers/scrollToTop.d.ts +1 -1
  15. package/dist/helpers/scrollToTop.js +5 -5
  16. package/dist/helpers/timeFuncs.d.ts +1 -1
  17. package/dist/helpers/timeFuncs.js +7 -7
  18. package/dist/hooks/index.d.ts +1 -1
  19. package/dist/hooks/useUploadProgress.d.ts +5 -5
  20. package/dist/hooks/useUploadProgress.js +8 -8
  21. package/dist/index.d.ts +8 -8
  22. package/dist/index.mjs +827 -830
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/model/index.d.ts +4 -4
  25. package/dist/model/model.interface.d.ts +11 -11
  26. package/dist/model/useKeyTrackerModel.d.ts +4 -4
  27. package/dist/model/useKeyTrackerModel.js +14 -14
  28. package/dist/model/useQueryModel.d.ts +2 -2
  29. package/dist/model/useQueryModel.js +115 -115
  30. package/dist/model/useRefetchQuery.d.ts +3 -3
  31. package/dist/model/useRefetchQuery.js +10 -10
  32. package/dist/queries/index.d.ts +6 -6
  33. package/dist/queries/queries.interface.d.ts +17 -17
  34. package/dist/queries/useDeleteRequest.d.ts +60 -60
  35. package/dist/queries/useDeleteRequest.js +72 -71
  36. package/dist/queries/useDeleteRequest.js.map +1 -1
  37. package/dist/queries/useGetInfiniteRequest.d.ts +108 -110
  38. package/dist/queries/useGetInfiniteRequest.js +103 -102
  39. package/dist/queries/useGetInfiniteRequest.js.map +1 -1
  40. package/dist/queries/useGetRequest.d.ts +73 -74
  41. package/dist/queries/useGetRequest.js +129 -133
  42. package/dist/queries/useGetRequest.js.map +1 -1
  43. package/dist/queries/usePatchRequest.d.ts +86 -86
  44. package/dist/queries/usePatchRequest.js +70 -70
  45. package/dist/queries/usePostRequest.d.ts +149 -157
  46. package/dist/queries/usePostRequest.js +77 -78
  47. package/dist/queries/usePostRequest.js.map +1 -1
  48. package/dist/queries/usePutRequest.d.ts +86 -86
  49. package/dist/request/axios-instance.d.ts +3 -3
  50. package/dist/request/axios-instance.js +6 -6
  51. package/dist/request/buildFormData.d.ts +1 -1
  52. package/dist/request/buildFormData.js +40 -40
  53. package/dist/request/index.d.ts +6 -6
  54. package/dist/request/make-request.d.ts +2 -2
  55. package/dist/request/make-request.js +80 -80
  56. package/dist/request/request.enum.d.ts +11 -11
  57. package/dist/request/request.enum.js +12 -12
  58. package/dist/request/request.interface.d.ts +48 -48
  59. package/dist/request/transformer.d.ts +7 -7
  60. package/dist/request/transformer.js +18 -18
  61. package/dist/stores/index.d.ts +2 -2
  62. package/dist/stores/useHeaderStore.d.ts +7 -7
  63. package/dist/stores/useHeaderStore.js +5 -5
  64. package/dist/stores/usePauseFutureRequests.d.ts +7 -7
  65. package/dist/stores/usePauseFutureRequests.js +13 -13
  66. package/dist/types/index.d.ts +27 -29
  67. package/package.json +2 -2
  68. package/src/queries/useDeleteRequest.ts +13 -14
  69. package/src/queries/useGetInfiniteRequest.ts +17 -19
  70. package/src/queries/useGetRequest.ts +29 -36
  71. package/src/queries/usePatchRequest.ts +24 -22
  72. package/src/queries/usePostRequest.ts +20 -23
  73. package/src/queries/usePutRequest.ts +19 -22
  74. package/src/request/make-request.ts +2 -2
  75. package/src/request/transformer.ts +1 -1
  76. package/src/types/index.ts +5 -4
@@ -1,86 +1,86 @@
1
- import type { MutateOptions } from '@tanstack/react-query';
2
- import type { IRequestError, IRequestSuccess } from '../request/request.interface';
3
- import type { DefaultRequestOptions } from './queries.interface';
4
- export declare const usePutRequest: <TResponse>({ path, baseUrl, headers }: {
5
- path: string;
6
- } & DefaultRequestOptions) => {
7
- isLoading: boolean;
8
- data: undefined;
9
- variables: undefined;
10
- error: null;
11
- isError: false;
12
- isIdle: true;
13
- isPending: false;
14
- isSuccess: false;
15
- status: "idle";
16
- mutate: import("@tanstack/react-query/build/legacy/types").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
17
- reset: () => void;
18
- context: unknown;
19
- failureCount: number;
20
- failureReason: IRequestError | null;
21
- isPaused: boolean;
22
- submittedAt: number;
23
- mutateAsync: import("@tanstack/react-query/build/legacy/types").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
24
- put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
25
- uploadProgressPercent: number;
26
- } | {
27
- isLoading: boolean;
28
- data: undefined;
29
- variables: void;
30
- error: null;
31
- isError: false;
32
- isIdle: false;
33
- isPending: true;
34
- isSuccess: false;
35
- status: "pending";
36
- mutate: import("@tanstack/react-query/build/legacy/types").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
37
- reset: () => void;
38
- context: unknown;
39
- failureCount: number;
40
- failureReason: IRequestError | null;
41
- isPaused: boolean;
42
- submittedAt: number;
43
- mutateAsync: import("@tanstack/react-query/build/legacy/types").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
44
- put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
45
- uploadProgressPercent: number;
46
- } | {
47
- isLoading: boolean;
48
- data: undefined;
49
- error: IRequestError;
50
- variables: void;
51
- isError: true;
52
- isIdle: false;
53
- isPending: false;
54
- isSuccess: false;
55
- status: "error";
56
- mutate: import("@tanstack/react-query/build/legacy/types").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
57
- reset: () => void;
58
- context: unknown;
59
- failureCount: number;
60
- failureReason: IRequestError | null;
61
- isPaused: boolean;
62
- submittedAt: number;
63
- mutateAsync: import("@tanstack/react-query/build/legacy/types").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
64
- put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
65
- uploadProgressPercent: number;
66
- } | {
67
- isLoading: boolean;
68
- data: IRequestSuccess<TResponse>;
69
- error: null;
70
- variables: void;
71
- isError: false;
72
- isIdle: false;
73
- isPending: false;
74
- isSuccess: true;
75
- status: "success";
76
- mutate: import("@tanstack/react-query/build/legacy/types").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
77
- reset: () => void;
78
- context: unknown;
79
- failureCount: number;
80
- failureReason: IRequestError | null;
81
- isPaused: boolean;
82
- submittedAt: number;
83
- mutateAsync: import("@tanstack/react-query/build/legacy/types").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
84
- put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
85
- uploadProgressPercent: number;
86
- };
1
+ import type { MutateOptions } from '@tanstack/react-query';
2
+ import type { IRequestError, IRequestSuccess } from '../request/request.interface';
3
+ import type { DefaultRequestOptions } from './queries.interface';
4
+ export declare const usePutRequest: <TResponse>({ path, baseUrl, headers }: {
5
+ path: string;
6
+ } & DefaultRequestOptions) => {
7
+ isLoading: boolean;
8
+ data: undefined;
9
+ variables: undefined;
10
+ error: null;
11
+ isError: false;
12
+ isIdle: true;
13
+ isPending: false;
14
+ isSuccess: false;
15
+ status: "idle";
16
+ mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
17
+ reset: () => void;
18
+ context: unknown;
19
+ failureCount: number;
20
+ failureReason: IRequestError | null;
21
+ isPaused: boolean;
22
+ submittedAt: number;
23
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
24
+ put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
25
+ uploadProgressPercent: number;
26
+ } | {
27
+ isLoading: boolean;
28
+ data: undefined;
29
+ variables: void;
30
+ error: null;
31
+ isError: false;
32
+ isIdle: false;
33
+ isPending: true;
34
+ isSuccess: false;
35
+ status: "pending";
36
+ mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
37
+ reset: () => void;
38
+ context: unknown;
39
+ failureCount: number;
40
+ failureReason: IRequestError | null;
41
+ isPaused: boolean;
42
+ submittedAt: number;
43
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
44
+ put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
45
+ uploadProgressPercent: number;
46
+ } | {
47
+ isLoading: boolean;
48
+ data: undefined;
49
+ error: IRequestError;
50
+ variables: void;
51
+ isError: true;
52
+ isIdle: false;
53
+ isPending: false;
54
+ isSuccess: false;
55
+ status: "error";
56
+ mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
57
+ reset: () => void;
58
+ context: unknown;
59
+ failureCount: number;
60
+ failureReason: IRequestError | null;
61
+ isPaused: boolean;
62
+ submittedAt: number;
63
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
64
+ put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
65
+ uploadProgressPercent: number;
66
+ } | {
67
+ isLoading: boolean;
68
+ data: IRequestSuccess<TResponse>;
69
+ error: null;
70
+ variables: void;
71
+ isError: false;
72
+ isIdle: false;
73
+ isPending: false;
74
+ isSuccess: true;
75
+ status: "success";
76
+ mutate: import("@tanstack/react-query").UseMutateFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
77
+ reset: () => void;
78
+ context: unknown;
79
+ failureCount: number;
80
+ failureReason: IRequestError | null;
81
+ isPaused: boolean;
82
+ submittedAt: number;
83
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<IRequestSuccess<TResponse>, IRequestError, void, unknown>;
84
+ put: (data: any, options?: MutateOptions<IRequestSuccess<TResponse>, IRequestError, void, unknown> | undefined) => Promise<IRequestSuccess<TResponse> | undefined>;
85
+ uploadProgressPercent: number;
86
+ };
@@ -1,3 +1,3 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { IMakeRequest } from './request.interface';
3
- export declare const axiosInstance: ({ baseURL, timeout, headers }: Partial<IMakeRequest>) => AxiosInstance;
1
+ import type { AxiosInstance } from 'axios';
2
+ import type { IMakeRequest } from './request.interface';
3
+ export declare const axiosInstance: ({ baseURL, timeout, headers }: Partial<IMakeRequest>) => AxiosInstance;
@@ -1,11 +1,11 @@
1
1
  import axios from 'axios';
2
2
 
3
- const axiosInstance = ({ baseURL, timeout, headers }) => {
4
- return axios.create({
5
- baseURL,
6
- timeout,
7
- headers,
8
- });
3
+ const axiosInstance = ({ baseURL, timeout, headers }) => {
4
+ return axios.create({
5
+ baseURL,
6
+ timeout,
7
+ headers,
8
+ });
9
9
  };
10
10
 
11
11
  export { axiosInstance };
@@ -1 +1 @@
1
- export declare const buildFormData: (body: Record<string, any>) => FormData;
1
+ export declare const buildFormData: (body: Record<string, any>) => FormData;
@@ -1,43 +1,43 @@
1
- const buildFormData = (body) => {
2
- const formData = new FormData();
3
- const handleArrayValue = (key, value) => {
4
- for (const item of value) {
5
- if (item instanceof File) {
6
- formData.append(key, item);
7
- }
8
- else if (item instanceof Object) {
9
- formData.append(key, JSON.stringify(item));
10
- }
11
- else {
12
- formData.append(key, item);
13
- }
14
- }
15
- };
16
- const handleObjectValue = (key, value) => {
17
- if (value instanceof File) {
18
- formData.append(key, value);
19
- }
20
- else {
21
- formData.append(key, JSON.stringify(value));
22
- }
23
- };
24
- const handlePrimitiveValue = (key, value) => {
25
- formData.append(key, value);
26
- };
27
- const bodyKeys = Object.keys(body);
28
- bodyKeys.forEach((key) => {
29
- const inputValue = body[key];
30
- if (Array.isArray(inputValue) && inputValue.length > 0) {
31
- handleArrayValue(key, inputValue);
32
- }
33
- else if (inputValue instanceof Object) {
34
- handleObjectValue(key, inputValue);
35
- }
36
- else {
37
- handlePrimitiveValue(key, inputValue);
38
- }
39
- });
40
- return formData;
1
+ const buildFormData = (body) => {
2
+ const formData = new FormData();
3
+ const handleArrayValue = (key, value) => {
4
+ for (const item of value) {
5
+ if (item instanceof File) {
6
+ formData.append(key, item);
7
+ }
8
+ else if (item instanceof Object) {
9
+ formData.append(key, JSON.stringify(item));
10
+ }
11
+ else {
12
+ formData.append(key, item);
13
+ }
14
+ }
15
+ };
16
+ const handleObjectValue = (key, value) => {
17
+ if (value instanceof File) {
18
+ formData.append(key, value);
19
+ }
20
+ else {
21
+ formData.append(key, JSON.stringify(value));
22
+ }
23
+ };
24
+ const handlePrimitiveValue = (key, value) => {
25
+ formData.append(key, value);
26
+ };
27
+ const bodyKeys = Object.keys(body);
28
+ bodyKeys.forEach((key) => {
29
+ const inputValue = body[key];
30
+ if (Array.isArray(inputValue) && inputValue.length > 0) {
31
+ handleArrayValue(key, inputValue);
32
+ }
33
+ else if (inputValue instanceof Object) {
34
+ handleObjectValue(key, inputValue);
35
+ }
36
+ else {
37
+ handlePrimitiveValue(key, inputValue);
38
+ }
39
+ });
40
+ return formData;
41
41
  };
42
42
 
43
43
  export { buildFormData };
@@ -1,6 +1,6 @@
1
- export * from './axios-instance';
2
- export * from './buildFormData';
3
- export * from './make-request';
4
- export * from './request.enum';
5
- export * from './request.interface';
6
- export * from './transformer';
1
+ export * from './axios-instance';
2
+ export * from './buildFormData';
3
+ export * from './make-request';
4
+ export * from './request.enum';
5
+ export * from './request.interface';
6
+ export * from './transformer';
@@ -1,2 +1,2 @@
1
- import type { IMakeRequest } from './request.interface';
2
- export declare function makeRequest<TResponse>({ body, method, path, isFormData, headers, baseURL, timeout, appFileConfig, onUploadProgress, }: IMakeRequest): Promise<import("./request.interface").IRequestError>;
1
+ import type { IMakeRequest, IRequestError, IRequestSuccess } from './request.interface';
2
+ export declare function makeRequest<TResponse>({ body, method, path, isFormData, headers, baseURL, timeout, appFileConfig, onUploadProgress, }: IMakeRequest): Promise<IRequestSuccess<TResponse> | IRequestError>;
@@ -3,86 +3,86 @@ import { axiosInstance } from './axios-instance.js';
3
3
  import { HttpMethod, ContentType } from './request.enum.js';
4
4
  import { errorTransformer, successTransformer } from './transformer.js';
5
5
 
6
- async function makeRequest({ body = {}, method = HttpMethod.GET, path, isFormData, headers = {}, baseURL, timeout, appFileConfig, onUploadProgress, }) {
7
- // check if file is included in mobile app environment and extract all file input to avoid
8
- // it being formatted to object using axios formData builder
9
- const isApp = appFileConfig?.isApp;
10
- const appFiles = isApp ? getAppFiles(body, appFileConfig.fileSelectors) : {};
11
- // configure body
12
- body = (isFormData ? axios.toFormData(body) : body);
13
- // configure request header1
14
- configureRequestHeader(isFormData, headers, isApp, appFiles, body);
15
- try {
16
- const axiosRequest = axiosInstance({ baseURL, headers, timeout });
17
- const axiosRequestConfig = {
18
- url: path,
19
- method,
20
- onUploadProgress,
21
- };
22
- if (Object.keys(body).length > 0 || (isFormData && !isApp && [...body.keys()].length > 0)) {
23
- axiosRequestConfig.data = body;
24
- }
25
- // send request
26
- const resp = await axiosRequest(axiosRequestConfig);
27
- // get response json
28
- const jsonResp = await resp.data;
29
- // get response code
30
- const responseCode = resp.status;
31
- if (responseCode > 299) {
32
- // server returned an error
33
- return errorTransformer({ ...jsonResp, statusCode: responseCode });
34
- }
35
- return successTransformer({
36
- statusCode: responseCode,
37
- ...jsonResp,
38
- status: resp.status,
39
- });
40
- }
41
- catch (error) {
42
- const errorData = error?.response?.data;
43
- return errorTransformer({
44
- statusCode: error.status,
45
- message: error.message,
46
- code: error.status || error.statusCode,
47
- ...errorData,
48
- });
49
- }
50
- }
51
- const configureRequestHeader = (isFormData, headers, isApp, appFiles, body) => {
52
- if (!isFormData) {
53
- headers['Content-Type'] = ContentType.APPLICATION_JSON;
54
- }
55
- else if (isApp) {
56
- headers['Content-Type'] = ContentType.MULTIPART_FORM_DATA;
57
- // add the app files
58
- for (const fileKey in appFiles) {
59
- const currentFile = appFiles[fileKey];
60
- if (Array.isArray(currentFile)) {
61
- for (const innerFile of currentFile) {
62
- body.append(fileKey, innerFile);
63
- }
64
- }
65
- else {
66
- body.append(fileKey, currentFile);
67
- }
68
- }
69
- }
70
- else {
71
- delete headers['Content-Type'];
72
- }
73
- };
74
- function getAppFiles(body, fileSelectors = []) {
75
- const files = {};
76
- if (body) {
77
- if (fileSelectors.length > 0) {
78
- //
79
- for (const fileKey of fileSelectors) {
80
- files[fileKey] = body[fileKey];
81
- delete body[fileKey];
82
- }
83
- }
84
- }
85
- return files;
6
+ async function makeRequest({ body = {}, method = HttpMethod.GET, path, isFormData, headers = {}, baseURL, timeout, appFileConfig, onUploadProgress, }) {
7
+ // check if file is included in mobile app environment and extract all file input to avoid
8
+ // it being formatted to object using axios formData builder
9
+ const isApp = appFileConfig?.isApp;
10
+ const appFiles = isApp ? getAppFiles(body, appFileConfig.fileSelectors) : {};
11
+ // configure body
12
+ body = (isFormData ? axios.toFormData(body) : body);
13
+ // configure request header1
14
+ configureRequestHeader(isFormData, headers, isApp, appFiles, body);
15
+ try {
16
+ const axiosRequest = axiosInstance({ baseURL, headers, timeout });
17
+ const axiosRequestConfig = {
18
+ url: path,
19
+ method,
20
+ onUploadProgress,
21
+ };
22
+ if (Object.keys(body).length > 0 || (isFormData && !isApp && [...body.keys()].length > 0)) {
23
+ axiosRequestConfig.data = body;
24
+ }
25
+ // send request
26
+ const resp = await axiosRequest(axiosRequestConfig);
27
+ // get response json
28
+ const jsonResp = await resp.data;
29
+ // get response code
30
+ const responseCode = resp.status;
31
+ if (responseCode > 299) {
32
+ // server returned an error
33
+ return errorTransformer({ ...jsonResp, statusCode: responseCode });
34
+ }
35
+ return successTransformer({
36
+ statusCode: responseCode,
37
+ ...jsonResp,
38
+ status: resp.status,
39
+ });
40
+ }
41
+ catch (error) {
42
+ const errorData = error?.response?.data;
43
+ return errorTransformer({
44
+ statusCode: error.status,
45
+ message: error.message,
46
+ code: error.status || error.statusCode,
47
+ ...errorData,
48
+ });
49
+ }
50
+ }
51
+ const configureRequestHeader = (isFormData, headers, isApp, appFiles, body) => {
52
+ if (!isFormData) {
53
+ headers['Content-Type'] = ContentType.APPLICATION_JSON;
54
+ }
55
+ else if (isApp) {
56
+ headers['Content-Type'] = ContentType.MULTIPART_FORM_DATA;
57
+ // add the app files
58
+ for (const fileKey in appFiles) {
59
+ const currentFile = appFiles[fileKey];
60
+ if (Array.isArray(currentFile)) {
61
+ for (const innerFile of currentFile) {
62
+ body.append(fileKey, innerFile);
63
+ }
64
+ }
65
+ else {
66
+ body.append(fileKey, currentFile);
67
+ }
68
+ }
69
+ }
70
+ else {
71
+ delete headers['Content-Type'];
72
+ }
73
+ };
74
+ function getAppFiles(body, fileSelectors = []) {
75
+ const files = {};
76
+ if (body) {
77
+ if (fileSelectors.length > 0) {
78
+ //
79
+ for (const fileKey of fileSelectors) {
80
+ files[fileKey] = body[fileKey];
81
+ delete body[fileKey];
82
+ }
83
+ }
84
+ }
85
+ return files;
86
86
  }
87
87
 
88
88
  export { makeRequest };
@@ -1,11 +1,11 @@
1
- export declare enum HttpMethod {
2
- GET = "GET",
3
- POST = "POST",
4
- PUT = "PUT",
5
- PATCH = "PATCH",
6
- DELETE = "DELETE"
7
- }
8
- export declare enum ContentType {
9
- APPLICATION_JSON = "application/json",
10
- MULTIPART_FORM_DATA = "multipart/form-data"
11
- }
1
+ export declare enum HttpMethod {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ PUT = "PUT",
5
+ PATCH = "PATCH",
6
+ DELETE = "DELETE"
7
+ }
8
+ export declare enum ContentType {
9
+ APPLICATION_JSON = "application/json",
10
+ MULTIPART_FORM_DATA = "multipart/form-data"
11
+ }
@@ -1,15 +1,15 @@
1
- var HttpMethod;
2
- (function (HttpMethod) {
3
- HttpMethod["GET"] = "GET";
4
- HttpMethod["POST"] = "POST";
5
- HttpMethod["PUT"] = "PUT";
6
- HttpMethod["PATCH"] = "PATCH";
7
- HttpMethod["DELETE"] = "DELETE";
8
- })(HttpMethod || (HttpMethod = {}));
9
- var ContentType;
10
- (function (ContentType) {
11
- ContentType["APPLICATION_JSON"] = "application/json";
12
- ContentType["MULTIPART_FORM_DATA"] = "multipart/form-data";
1
+ var HttpMethod;
2
+ (function (HttpMethod) {
3
+ HttpMethod["GET"] = "GET";
4
+ HttpMethod["POST"] = "POST";
5
+ HttpMethod["PUT"] = "PUT";
6
+ HttpMethod["PATCH"] = "PATCH";
7
+ HttpMethod["DELETE"] = "DELETE";
8
+ })(HttpMethod || (HttpMethod = {}));
9
+ var ContentType;
10
+ (function (ContentType) {
11
+ ContentType["APPLICATION_JSON"] = "application/json";
12
+ ContentType["MULTIPART_FORM_DATA"] = "multipart/form-data";
13
13
  })(ContentType || (ContentType = {}));
14
14
 
15
15
  export { ContentType, HttpMethod };
@@ -1,48 +1,48 @@
1
- import type { AxiosProgressEvent, RawAxiosRequestHeaders } from 'axios';
2
- import type { HttpMethod } from './request.enum';
3
- export interface IMakeRequest {
4
- baseURL: string;
5
- timeout?: number;
6
- path: string;
7
- body?: Record<string, any> | null;
8
- method?: HttpMethod;
9
- isFormData?: boolean;
10
- headers: RawAxiosRequestHeaders;
11
- appFileConfig?: AppFileConfig;
12
- onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
13
- }
14
- export interface AppFileConfig {
15
- fileSelectors?: string[];
16
- isApp: boolean;
17
- }
18
- export interface AxiosInstanceOption {
19
- bearerToken?: string;
20
- contentType?: string;
21
- }
22
- export interface IRequestError {
23
- statusCode: number;
24
- message: string;
25
- timeStamp: Date;
26
- status: boolean;
27
- data?: any;
28
- }
29
- export interface IRequestSuccess<T> {
30
- statusCode: number;
31
- message: string;
32
- timeStamp: Date;
33
- status: boolean;
34
- data: T;
35
- }
36
- export interface IServerRequestSuccess {
37
- status?: boolean;
38
- data: any;
39
- message?: string;
40
- }
41
- export interface IServerRequestError {
42
- status?: boolean;
43
- code?: number;
44
- success?: boolean;
45
- message: string;
46
- error?: Record<string, any>;
47
- data?: Record<string, any>;
48
- }
1
+ import type { AxiosProgressEvent, RawAxiosRequestHeaders } from 'axios';
2
+ import type { HttpMethod } from './request.enum';
3
+ export interface IMakeRequest {
4
+ baseURL: string;
5
+ timeout?: number;
6
+ path: string;
7
+ body?: Record<string, any> | null;
8
+ method?: HttpMethod;
9
+ isFormData?: boolean;
10
+ headers: RawAxiosRequestHeaders;
11
+ appFileConfig?: AppFileConfig;
12
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
13
+ }
14
+ export interface AppFileConfig {
15
+ fileSelectors?: string[];
16
+ isApp: boolean;
17
+ }
18
+ export interface AxiosInstanceOption {
19
+ bearerToken?: string;
20
+ contentType?: string;
21
+ }
22
+ export interface IRequestError {
23
+ statusCode: number;
24
+ message: string;
25
+ timeStamp: Date;
26
+ status: boolean;
27
+ data?: any;
28
+ }
29
+ export interface IRequestSuccess<T> {
30
+ statusCode: number;
31
+ message: string;
32
+ timeStamp: Date;
33
+ status: boolean;
34
+ data: T;
35
+ }
36
+ export interface IServerRequestSuccess {
37
+ status?: boolean;
38
+ data: any;
39
+ message?: string;
40
+ }
41
+ export interface IServerRequestError {
42
+ status?: boolean;
43
+ code?: number;
44
+ success?: boolean;
45
+ message: string;
46
+ error?: Record<string, any>;
47
+ data?: Record<string, any>;
48
+ }
@@ -1,7 +1,7 @@
1
- import type { IRequestError, IRequestSuccess, IServerRequestError, IServerRequestSuccess } from './request.interface';
2
- export declare const errorTransformer: (data: IServerRequestError & {
3
- statusCode: number;
4
- }) => IRequestError;
5
- export declare const successTransformer: <T>(data: IServerRequestSuccess & {
6
- statusCode: number;
7
- }) => IRequestSuccess<T>;
1
+ import type { IRequestError, IRequestSuccess, IServerRequestError, IServerRequestSuccess } from './request.interface';
2
+ export declare const errorTransformer: (data: IServerRequestError & {
3
+ statusCode: number;
4
+ }) => IRequestError;
5
+ export declare const successTransformer: <T>(data: IServerRequestSuccess & {
6
+ statusCode: number;
7
+ }) => IRequestSuccess<T>;