pangea-lib 2.12.270 → 2.12.271
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.
|
@@ -5,34 +5,34 @@ import { ApiConfig, ApiEndpoints, ApiEndpointName, ApiEndpointParams, ApiEndpoin
|
|
|
5
5
|
export declare function createApiConnections<AE extends ApiEndpoints>(endpoints: AE): {
|
|
6
6
|
getOne<T extends ApiEndpointName<AE, "getOne">>(url: T, id?: Id, params?: ApiEndpointParams<AE, T, "getOne">, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T, "getOne">>): Promise<{
|
|
7
7
|
data: ApiEndpointResponse<AE, T, "getOne">;
|
|
8
|
-
totalCount?:
|
|
8
|
+
totalCount?: unknown;
|
|
9
9
|
}>;
|
|
10
|
-
getMany<T_1 extends ApiEndpointName<AE, "getMany">>(url: T_1, params?: ApiEndpointParams<AE, T_1, "getMany">, apiConfig?: ApiConfig<Arrayify<ApiEndpointResponse<AE, T_1, "getMany"
|
|
10
|
+
getMany<T_1 extends ApiEndpointName<AE, "getMany">>(url: T_1, params?: ApiEndpointParams<AE, T_1, "getMany">, apiConfig?: ApiConfig<Arrayify<ApiEndpointResponse<AE, T_1, "getMany">>, number>): Promise<{
|
|
11
11
|
data: Arrayify<ApiEndpointResponse<AE, T_1, "getMany">>;
|
|
12
|
-
totalCount?:
|
|
12
|
+
totalCount?: unknown;
|
|
13
13
|
}>;
|
|
14
14
|
postOne<T_2 extends ApiEndpointName<AE, "postOne">>(url: T_2, params?: ApiEndpointParams<AE, T_2, "postOne">, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_2, "postOne">>): Promise<{
|
|
15
15
|
data: ApiEndpointResponse<AE, T_2, "postOne">;
|
|
16
|
-
totalCount?:
|
|
16
|
+
totalCount?: unknown;
|
|
17
17
|
}>;
|
|
18
18
|
postMany<T_3 extends ApiEndpointName<AE, "postMany">>(url: T_3, params: ApiEndpointParams<AE, T_3, "postMany">[], apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_3, "postMany">>): Promise<{
|
|
19
19
|
data: ApiEndpointResponse<AE, T_3, "postMany">;
|
|
20
|
-
totalCount?:
|
|
20
|
+
totalCount?: unknown;
|
|
21
21
|
}>;
|
|
22
22
|
putOne<T_4 extends ApiEndpointName<AE, "putOne">>(url: T_4, id?: Id, params?: ApiEndpointParams<AE, T_4, "putOne">, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_4, "putOne">>): Promise<{
|
|
23
23
|
data: ApiEndpointResponse<AE, T_4, "putOne">;
|
|
24
|
-
totalCount?:
|
|
24
|
+
totalCount?: unknown;
|
|
25
25
|
}>;
|
|
26
26
|
putMany<T_5 extends ApiEndpointName<AE, "putMany">>(url: T_5, params: ApiEndpointParams<AE, T_5, "putMany">[], apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_5, "putMany">>): Promise<{
|
|
27
27
|
data: ApiEndpointResponse<AE, T_5, "putMany">;
|
|
28
|
-
totalCount?:
|
|
28
|
+
totalCount?: unknown;
|
|
29
29
|
}>;
|
|
30
30
|
deleteOne<T_6 extends ApiEndpointName<AE, "deleteOne">>(url: T_6, id?: Id, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_6, "deleteOne">>): Promise<{
|
|
31
31
|
data: ApiEndpointResponse<AE, T_6, "deleteOne">;
|
|
32
|
-
totalCount?:
|
|
32
|
+
totalCount?: unknown;
|
|
33
33
|
}>;
|
|
34
34
|
deleteMany<T_7 extends ApiEndpointName<AE, "deleteMany">>(url: T_7, ids: Id[], apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_7, "deleteMany">>): Promise<{
|
|
35
35
|
data: ApiEndpointResponse<AE, T_7, "deleteMany">;
|
|
36
|
-
totalCount?:
|
|
36
|
+
totalCount?: unknown;
|
|
37
37
|
}>;
|
|
38
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlainObject } from 'pangea-helpers';
|
|
2
2
|
import { ApiMethod, ApiConfig, EndpointSettings } from '../../types/api-connections.types';
|
|
3
3
|
|
|
4
|
-
export declare function connectToApi<T extends ApiMethod, SuccessRes>(method: T, url: string, endpointSettings: EndpointSettings, params: PlainObject | Array<any>, apiConfig?: ApiConfig<SuccessRes>): Promise<{
|
|
4
|
+
export declare function connectToApi<T extends ApiMethod, SuccessRes, TCount>(method: T, url: string, endpointSettings: EndpointSettings, params: PlainObject | Array<any>, apiConfig?: ApiConfig<SuccessRes>): Promise<{
|
|
5
5
|
data: SuccessRes;
|
|
6
|
-
totalCount?:
|
|
6
|
+
totalCount?: TCount;
|
|
7
7
|
}>;
|
|
@@ -6,10 +6,10 @@ import { BaseResponse } from '../models/base-response.models';
|
|
|
6
6
|
import { ExtractConstructor } from 'pangea-helpers';
|
|
7
7
|
import { ClassWithConstructor } from '.';
|
|
8
8
|
|
|
9
|
-
export type ApiMethod = '
|
|
9
|
+
export type ApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
10
10
|
export type ApiConnectionMethod = 'getOne' | 'getMany' | 'postOne' | 'postMany' | 'putOne' | 'putMany' | 'deleteOne' | 'deleteMany';
|
|
11
|
-
export type ApiConfig<SuccessRes> = {
|
|
12
|
-
success?: (data: SuccessRes, totalCount?:
|
|
11
|
+
export type ApiConfig<SuccessRes, TCount = undefined> = {
|
|
12
|
+
success?: (data: SuccessRes, totalCount?: TCount) => void;
|
|
13
13
|
error?: (err: AxiosError) => void;
|
|
14
14
|
finally?: () => void;
|
|
15
15
|
displaySuccess?: boolean;
|