@creopse/vue 0.0.47 → 0.0.48
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 +9 -9
- package/dist/index.js +9 -9
- package/dist/index.mjs +1104 -1098
- package/package.json +1 -1
- package/types/composables/api.d.ts +18 -16
- package/types/composables/config.d.ts +0 -4
- package/types/core/api.d.ts +2 -0
- package/types/types/api.d.ts +12 -5
- package/types/types/plugin.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Payload, Response } from '@/types/api';
|
|
2
|
+
import type { AxiosError } from 'axios';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* A composable that provides a way to make API requests.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
* @returns {Object} An object containing the following methods:
|
|
6
|
+
* The composable provides the following methods:
|
|
7
7
|
* - `request`: Makes an API request with the given payload.
|
|
8
|
-
* - `
|
|
9
|
-
* - `
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
12
|
-
* - `
|
|
8
|
+
* - `getItemRequest`: Makes a GET request to the specified API endpoint with the given payload.
|
|
9
|
+
* - `postItemRequest`: Makes a POST request to the specified API endpoint with the given payload.
|
|
10
|
+
* - `putItemRequest`: Makes a PUT request to the specified API endpoint with the given payload.
|
|
11
|
+
* - `deleteItemRequest`: Makes a DELETE request to the specified API endpoint with the given payload.
|
|
12
|
+
* - `getAllItemsRequest`: Makes a GET request to the specified API endpoint with the given payload.
|
|
13
13
|
* - `handleError`: Handles an error from the API.
|
|
14
|
+
*
|
|
15
|
+
* @returns {Object} An object containing the methods listed above.
|
|
14
16
|
*/
|
|
15
17
|
export declare const useApi: () => {
|
|
16
|
-
request: (payload: Payload,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
handleError: (error:
|
|
18
|
+
request: <T = any>(payload: Payload, accessForbiddenCallback?: () => void) => Promise<Response<T>>;
|
|
19
|
+
getItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
20
|
+
postItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
21
|
+
putItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
22
|
+
deleteItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
23
|
+
getAllItemsRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
24
|
+
handleError: (error: AxiosError) => void;
|
|
23
25
|
};
|
|
@@ -10,12 +10,8 @@
|
|
|
10
10
|
export declare const useConfig: () => {
|
|
11
11
|
apiBaseUrl: string;
|
|
12
12
|
apiUrl: string;
|
|
13
|
-
apiRequestHeaders: {
|
|
14
|
-
'X-API-Key': string;
|
|
15
|
-
};
|
|
16
13
|
debug: boolean;
|
|
17
14
|
appUrl: string;
|
|
18
|
-
xApiKey: string;
|
|
19
15
|
locale: string;
|
|
20
16
|
fallbackLocale: string;
|
|
21
17
|
encryptionKey: string;
|
package/types/types/api.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import type { ResponseType } from 'axios';
|
|
1
2
|
export type Method = 'get' | 'post' | 'put' | 'delete';
|
|
2
3
|
export interface Payload {
|
|
3
4
|
method?: Method;
|
|
4
5
|
routeBase?: string;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
responseType?: ResponseType;
|
|
7
|
+
params?: Record<string, any>;
|
|
8
|
+
data?: Record<string, any>;
|
|
7
9
|
url?: string;
|
|
8
10
|
id?: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
useApiBaseUrl?: boolean;
|
|
9
13
|
}
|
|
10
|
-
export interface
|
|
14
|
+
export interface Response<T> {
|
|
11
15
|
success: boolean;
|
|
12
16
|
failure: boolean;
|
|
13
|
-
result:
|
|
14
|
-
|
|
17
|
+
result: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
data?: T;
|
|
20
|
+
};
|
|
21
|
+
error?: any;
|
|
15
22
|
}
|