@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creopse/vue",
3
3
  "description": "Creopse Vue Toolkit",
4
- "version": "0.0.47",
4
+ "version": "0.0.48",
5
5
  "private": false,
6
6
  "author": "Noé Gnanih <noegnanih@gmail.com>",
7
7
  "license": "MIT",
@@ -1,23 +1,25 @@
1
- import type { ApiResponse, Payload } from '@/types/api';
1
+ import type { Payload, Response } from '@/types/api';
2
+ import type { AxiosError } from 'axios';
2
3
  /**
3
- * This composable is used to make API requests.
4
+ * A composable that provides a way to make API requests.
4
5
  *
5
- * @function useApi
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
- * - `addItem`: Adds an item to the API.
9
- * - `deleteItem`: Deletes an item from the API.
10
- * - `updateItem`: Updates an item in the API.
11
- * - `getAllItems`: Gets all items from the API.
12
- * - `getItem`: Gets an item from the API.
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, accessToken?: string, accessForbiddenCallback?: () => void) => Promise<any>;
17
- getItem: (payload: Payload) => Promise<ApiResponse>;
18
- addItem: (payload: Payload) => Promise<ApiResponse>;
19
- updateItem: (payload: Payload) => Promise<ApiResponse>;
20
- deleteItem: (payload: Payload) => Promise<ApiResponse>;
21
- getAllItems: (payload: Payload) => Promise<ApiResponse>;
22
- handleError: (error: any) => void;
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;
@@ -0,0 +1,2 @@
1
+ declare const api: import("axios").AxiosInstance;
2
+ export default api;
@@ -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
- params?: object;
6
- data?: object;
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 ApiResponse {
14
+ export interface Response<T> {
11
15
  success: boolean;
12
16
  failure: boolean;
13
- result: any;
14
- error: any;
17
+ result: {
18
+ [key: string]: any;
19
+ data?: T;
20
+ };
21
+ error?: any;
15
22
  }
@@ -7,7 +7,6 @@ export type Props = SharedProps & PageProps & {
7
7
  export interface PluginConfig {
8
8
  debug: boolean;
9
9
  appUrl: string;
10
- xApiKey: string;
11
10
  locale: string;
12
11
  fallbackLocale: string;
13
12
  encryptionKey: string;