supaapps-api-kit-client 0.6.0 → 0.7.0
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/ApiKitClient.d.ts +3 -3
- package/dist/ApiKitClient.js +6 -4
- package/package.json +1 -1
- package/src/ApiKitClient.ts +13 -5
package/dist/ApiKitClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
import { PaginatedResponse } from './types';
|
|
3
3
|
type UnAuthorizedCallback = () => void;
|
|
4
4
|
type AuthTokenCallback = () => Promise<string>;
|
|
@@ -21,7 +21,7 @@ export declare class ApiKitClient {
|
|
|
21
21
|
get<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<T>>;
|
|
22
22
|
getOne<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<T>>;
|
|
23
23
|
getPaginated<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<PaginatedResponse<T>>>;
|
|
24
|
-
post<T>(endpoint: string, data?: T): Promise<AxiosResponse<T>>;
|
|
24
|
+
post<T>(endpoint: string, data?: T, options?: Omit<AxiosRequestConfig, 'url' | 'method'>): Promise<AxiosResponse<T>>;
|
|
25
25
|
put<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>>;
|
|
26
26
|
patch<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>>;
|
|
27
27
|
delete<T>(endpoint: string): Promise<AxiosResponse<T>>;
|
|
@@ -29,7 +29,7 @@ export declare class ApiKitClient {
|
|
|
29
29
|
static get<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<T>>;
|
|
30
30
|
static getOne<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<T>>;
|
|
31
31
|
static getPaginated<T>(endpoint: string, params?: URLSearchParams): Promise<AxiosResponse<PaginatedResponse<T>>>;
|
|
32
|
-
static post<T>(endpoint: string, data?: T): Promise<AxiosResponse<T>>;
|
|
32
|
+
static post<T>(endpoint: string, data?: T, options?: Omit<AxiosRequestConfig, 'url' | 'method'>): Promise<AxiosResponse<T>>;
|
|
33
33
|
static put<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>>;
|
|
34
34
|
static patch<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>>;
|
|
35
35
|
static delete<T>(endpoint: string): Promise<AxiosResponse<T>>;
|
package/dist/ApiKitClient.js
CHANGED
|
@@ -79,11 +79,12 @@ class ApiKitClient {
|
|
|
79
79
|
return axiosInstance.get(endpoint, { params });
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
post(endpoint, data
|
|
82
|
+
post(endpoint, data, options // Exclude 'url' and 'method' since they are handled separately
|
|
83
|
+
) {
|
|
83
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
85
|
this.checkInitialization();
|
|
85
86
|
const axiosInstance = ApiKitClient.apiClients[this.apiClientKey].axiosInstance;
|
|
86
|
-
return axiosInstance.post(endpoint, data);
|
|
87
|
+
return axiosInstance.post(endpoint, data, options);
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
put(endpoint, data) {
|
|
@@ -126,9 +127,10 @@ class ApiKitClient {
|
|
|
126
127
|
return (new ApiKitClient('default')).getPaginated(endpoint, params);
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
|
-
static post(endpoint, data
|
|
130
|
+
static post(endpoint, data, options // Exclude 'url' and 'method' since they are handled separately
|
|
131
|
+
) {
|
|
130
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
return (new ApiKitClient('default')).post(endpoint, data);
|
|
133
|
+
return (new ApiKitClient('default')).post(endpoint, data, options);
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
136
|
static put(endpoint, data) {
|
package/package.json
CHANGED
package/src/ApiKitClient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
|
|
2
2
|
import { PaginatedResponse } from './types';
|
|
3
3
|
|
|
4
4
|
type UnAuthorizedCallback = () => void;
|
|
@@ -92,10 +92,14 @@ export class ApiKitClient {
|
|
|
92
92
|
return axiosInstance!.get<PaginatedResponse<T>>(endpoint, { params });
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
public async post<T>(
|
|
95
|
+
public async post<T>(
|
|
96
|
+
endpoint: string,
|
|
97
|
+
data?: T,
|
|
98
|
+
options?: Omit<AxiosRequestConfig, 'url' | 'method'> // Exclude 'url' and 'method' since they are handled separately
|
|
99
|
+
): Promise<AxiosResponse<T>> {
|
|
96
100
|
this.checkInitialization();
|
|
97
101
|
const axiosInstance = ApiKitClient.apiClients[this.apiClientKey].axiosInstance;
|
|
98
|
-
return axiosInstance!.post<T>(endpoint, data);
|
|
102
|
+
return axiosInstance!.post<T>(endpoint, data, options);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
public async put<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>> {
|
|
@@ -135,8 +139,12 @@ export class ApiKitClient {
|
|
|
135
139
|
return (new ApiKitClient('default')).getPaginated<T>(endpoint, params);
|
|
136
140
|
}
|
|
137
141
|
|
|
138
|
-
public static async post<T>(
|
|
139
|
-
|
|
142
|
+
public static async post<T>(
|
|
143
|
+
endpoint: string,
|
|
144
|
+
data?: T,
|
|
145
|
+
options?: Omit<AxiosRequestConfig, 'url' | 'method'> // Exclude 'url' and 'method' since they are handled separately
|
|
146
|
+
): Promise<AxiosResponse<T>> {
|
|
147
|
+
return (new ApiKitClient('default')).post<T>(endpoint, data, options);
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
public static async put<T>(endpoint: string, data: Partial<T>): Promise<AxiosResponse<T>> {
|