pangea-lib 4.0.511 → 4.0.513
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/main.cjs.js +2 -2
- package/dist/main.es.js +14 -46
- package/dist/types/api/create-api.d.ts +38 -0
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/methods/call-axios.d.ts +4 -0
- package/dist/types/api/methods/connect-to-api.d.ts +7 -0
- package/dist/types/api/methods/convert-json-to-model.d.ts +3 -0
- package/dist/types/api/methods/get-finals.d.ts +6 -0
- package/dist/types/i18n/i18n.d.ts +127 -127
- package/dist/types/i18n/messages/index.d.ts +2 -2
- package/dist/types/main.d.ts +1 -1
- package/dist/types/types/api.types.d.ts +39 -0
- package/dist/types/types/app-config.types.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/api-connections/create-api-connections.d.ts +0 -38
- package/dist/types/api-connections/index.d.ts +0 -1
- package/dist/types/api-connections/methods/call-axios.d.ts +0 -4
- package/dist/types/api-connections/methods/connect-to-api.d.ts +0 -7
- package/dist/types/api-connections/methods/convert-json-to-model.d.ts +0 -3
- package/dist/types/api-connections/methods/get-finals.d.ts +0 -6
- package/dist/types/types/api-connections.types.d.ts +0 -39
- /package/dist/types/{api-connections/i18n/api-connections-error.i18n.d.ts → api/i18n/api-error.i18n.d.ts} +0 -0
- /package/dist/types/{api-connections/i18n/api-connections-success.i18n.d.ts → api/i18n/api-success.i18n.d.ts} +0 -0
- /package/dist/types/{api-connections → api}/methods/convert-params-into-form-data.d.ts +0 -0
- /package/dist/types/{api-connections → api}/methods/display-error.d.ts +0 -0
- /package/dist/types/{api-connections → api}/methods/display-success.d.ts +0 -0
- /package/dist/types/{api-connections → api}/methods/get-request-config.d.ts +0 -0
|
@@ -31,7 +31,7 @@ declare const _default: {
|
|
|
31
31
|
danger: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
apiError: {
|
|
35
35
|
es: {
|
|
36
36
|
INTERNAL_SERVER_ERROR: string;
|
|
37
37
|
DUPLICATE_KEY: string;
|
|
@@ -44,7 +44,7 @@ declare const _default: {
|
|
|
44
44
|
UNAUTHORIZED: string;
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
apiSuccess: {
|
|
48
48
|
es: {
|
|
49
49
|
_LOGIN: string;
|
|
50
50
|
};
|
package/dist/types/main.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default install;
|
|
|
13
13
|
export { App };
|
|
14
14
|
export * from './alert-danger';
|
|
15
15
|
export * from './alert-info';
|
|
16
|
-
export * from './api
|
|
16
|
+
export * from './api';
|
|
17
17
|
export * from './composables';
|
|
18
18
|
export * from './helpers';
|
|
19
19
|
export * from './i18n';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { AxiosError, AxiosBasicCredentials } from 'axios';
|
|
3
|
+
import { BaseModel } from '../models/base-model.model';
|
|
4
|
+
import { BaseParams } from '../models/base-params.models';
|
|
5
|
+
import { BaseResponse } from '../models/base-response.models';
|
|
6
|
+
import { ExtractConstructor } from 'pangea-helpers';
|
|
7
|
+
import { ClassWithConstructor } from '.';
|
|
8
|
+
|
|
9
|
+
export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
10
|
+
export type ApiMethod = 'getOne' | 'getMany' | 'postOne' | 'postMany' | 'putOne' | 'putMany' | 'deleteOne' | 'deleteMany';
|
|
11
|
+
export type CallConfig<SuccessRes, TCount = undefined> = {
|
|
12
|
+
success?: (data: SuccessRes, totalCount?: TCount) => void;
|
|
13
|
+
error?: (err: AxiosError) => void;
|
|
14
|
+
noDisplayError?: boolean;
|
|
15
|
+
noThrowError?: boolean;
|
|
16
|
+
isLoading?: Ref<boolean>;
|
|
17
|
+
basicAuth?: AxiosBasicCredentials;
|
|
18
|
+
};
|
|
19
|
+
export type Headers = Record<string, string>;
|
|
20
|
+
export type GetCustomHeaders = () => Headers;
|
|
21
|
+
export type ApiConfig = {
|
|
22
|
+
getCustomHeaders?: GetCustomHeaders;
|
|
23
|
+
};
|
|
24
|
+
export type EndpointParams = typeof BaseParams;
|
|
25
|
+
export type EndpointResponse = typeof BaseModel | typeof BaseResponse | ClassWithConstructor | undefined;
|
|
26
|
+
export type EndpointMeta = {
|
|
27
|
+
sendAsFormData?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type Endpoint = {
|
|
30
|
+
params?: EndpointParams;
|
|
31
|
+
response: EndpointResponse;
|
|
32
|
+
meta?: EndpointMeta;
|
|
33
|
+
};
|
|
34
|
+
export type Endpoints = Record<string, Partial<Record<ApiMethod, Endpoint>>>;
|
|
35
|
+
export type EndpointName<AE extends Endpoints, CM extends ApiMethod> = {
|
|
36
|
+
[K in keyof AE]: CM extends keyof AE[K] ? K : never;
|
|
37
|
+
}[keyof AE];
|
|
38
|
+
export type ParamsOf<AE extends Endpoints, EN extends EndpointName<AE, CM>, CM extends ApiMethod> = EN extends keyof AE ? CM extends keyof AE[EN] ? 'params' extends keyof AE[EN][CM] ? InstanceType<ExtractConstructor<AE[EN][CM]['params']>> : never : never : any;
|
|
39
|
+
export type ResponseOf<AE extends Endpoints, EN extends EndpointName<AE, CM>, CM extends ApiMethod> = EN extends keyof AE ? CM extends keyof AE[EN] ? 'response' extends keyof AE[EN][CM] ? InstanceType<ExtractConstructor<AE[EN][CM]['response']>> : never : never : any;
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Arrayify } from 'pangea-helpers';
|
|
2
|
-
import { Id } from '../types';
|
|
3
|
-
import { ApiConfig, ApiEndpoints, ApiEndpointName, ApiEndpointParams, ApiEndpointResponse, ApiConnectionsConfig } from '../types/api-connections.types';
|
|
4
|
-
|
|
5
|
-
export declare function createApiConnections<AE extends ApiEndpoints>(endpoints: AE, appVersion: string, apiConnectionsConfig?: ApiConnectionsConfig): {
|
|
6
|
-
getOne<T extends ApiEndpointName<AE, "getOne">>(url: T, id?: Id, params?: ApiEndpointParams<AE, T, "getOne">, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T, "getOne">>): Promise<{
|
|
7
|
-
data: ApiEndpointResponse<AE, T, "getOne">;
|
|
8
|
-
totalCount: undefined;
|
|
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">>, number>): Promise<{
|
|
11
|
-
data: Arrayify<ApiEndpointResponse<AE, T_1, "getMany">>;
|
|
12
|
-
totalCount: number;
|
|
13
|
-
}>;
|
|
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
|
-
data: ApiEndpointResponse<AE, T_2, "postOne">;
|
|
16
|
-
totalCount: undefined;
|
|
17
|
-
}>;
|
|
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
|
-
data: ApiEndpointResponse<AE, T_3, "postMany">;
|
|
20
|
-
totalCount: undefined;
|
|
21
|
-
}>;
|
|
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
|
-
data: ApiEndpointResponse<AE, T_4, "putOne">;
|
|
24
|
-
totalCount: undefined;
|
|
25
|
-
}>;
|
|
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
|
-
data: ApiEndpointResponse<AE, T_5, "putMany">;
|
|
28
|
-
totalCount: undefined;
|
|
29
|
-
}>;
|
|
30
|
-
deleteOne<T_6 extends ApiEndpointName<AE, "deleteOne">>(url: T_6, id?: Id, apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_6, "deleteOne">>): Promise<{
|
|
31
|
-
data: ApiEndpointResponse<AE, T_6, "deleteOne">;
|
|
32
|
-
totalCount: undefined;
|
|
33
|
-
}>;
|
|
34
|
-
deleteMany<T_7 extends ApiEndpointName<AE, "deleteMany">>(url: T_7, ids: Id[], apiConfig?: ApiConfig<ApiEndpointResponse<AE, T_7, "deleteMany">>): Promise<{
|
|
35
|
-
data: ApiEndpointResponse<AE, T_7, "deleteMany">;
|
|
36
|
-
totalCount: undefined;
|
|
37
|
-
}>;
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createApiConnections } from './create-api-connections';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { default as axios, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { ApiMethod } from '../../types/api-connections.types';
|
|
3
|
-
|
|
4
|
-
export declare function callAxios(method: ApiMethod, url: string, params?: object, config?: AxiosRequestConfig): Promise<axios.AxiosResponse<any, any>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PlainObject } from 'pangea-helpers';
|
|
2
|
-
import { ApiMethod, ApiConfig, EndpointSettings, ApiConnectionsConfig } from '../../types/api-connections.types';
|
|
3
|
-
|
|
4
|
-
export declare function connectToApi<T extends ApiMethod, SuccessRes, TCount>(method: T, url: string, endpointSettings: EndpointSettings, params: PlainObject | Array<any>, appVersion: string, apiConnectionsConfig: ApiConnectionsConfig | undefined, apiConfig?: ApiConfig<SuccessRes, TCount>): Promise<{
|
|
5
|
-
data: SuccessRes;
|
|
6
|
-
totalCount: TCount;
|
|
7
|
-
}>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PlainObject } from 'pangea-helpers';
|
|
2
|
-
import { Id } from '../../types';
|
|
3
|
-
import { EndpointSettingsParams } from '../../types/api-connections.types';
|
|
4
|
-
|
|
5
|
-
export declare function getFinalUrl(url: string, id?: Id): string;
|
|
6
|
-
export declare function getFinalParams(Model: EndpointSettingsParams, params: PlainObject | PlainObject[]): import('../../models').BaseParams;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import { AxiosError, AxiosBasicCredentials } from 'axios';
|
|
3
|
-
import { BaseModel } from '../models/base-model.model';
|
|
4
|
-
import { BaseParams } from '../models/base-params.models';
|
|
5
|
-
import { BaseResponse } from '../models/base-response.models';
|
|
6
|
-
import { ExtractConstructor } from 'pangea-helpers';
|
|
7
|
-
import { ClassWithConstructor } from '.';
|
|
8
|
-
|
|
9
|
-
export type ApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
10
|
-
export type ApiConnectionMethod = 'getOne' | 'getMany' | 'postOne' | 'postMany' | 'putOne' | 'putMany' | 'deleteOne' | 'deleteMany';
|
|
11
|
-
export type ApiConfig<SuccessRes, TCount = undefined> = {
|
|
12
|
-
success?: (data: SuccessRes, totalCount?: TCount) => void;
|
|
13
|
-
error?: (err: AxiosError) => void;
|
|
14
|
-
noDisplayError?: boolean;
|
|
15
|
-
noThrowError?: boolean;
|
|
16
|
-
isLoading?: Ref<boolean>;
|
|
17
|
-
basicAuth?: AxiosBasicCredentials;
|
|
18
|
-
};
|
|
19
|
-
export type Headers = Record<string, string>;
|
|
20
|
-
export type GetCustomHeaders = () => Headers;
|
|
21
|
-
export type ApiConnectionsConfig = {
|
|
22
|
-
getCustomHeaders?: GetCustomHeaders;
|
|
23
|
-
};
|
|
24
|
-
export type EndpointSettingsParams = typeof BaseParams;
|
|
25
|
-
export type EndpointSettingsResponse = typeof BaseModel | typeof BaseResponse | ClassWithConstructor | undefined;
|
|
26
|
-
export type EndpointSettingsMeta = {
|
|
27
|
-
sendAsFormData?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type EndpointSettings = {
|
|
30
|
-
params?: EndpointSettingsParams;
|
|
31
|
-
response: EndpointSettingsResponse;
|
|
32
|
-
meta?: EndpointSettingsMeta;
|
|
33
|
-
};
|
|
34
|
-
export type ApiEndpoints = Record<string, Partial<Record<ApiConnectionMethod, EndpointSettings>>>;
|
|
35
|
-
export type ApiEndpointName<AE extends ApiEndpoints, CM extends ApiConnectionMethod> = {
|
|
36
|
-
[K in keyof AE]: CM extends keyof AE[K] ? K : never;
|
|
37
|
-
}[keyof AE];
|
|
38
|
-
export type ApiEndpointParams<AE extends ApiEndpoints, EN extends ApiEndpointName<AE, CM>, CM extends ApiConnectionMethod> = EN extends keyof AE ? CM extends keyof AE[EN] ? 'params' extends keyof AE[EN][CM] ? InstanceType<ExtractConstructor<AE[EN][CM]['params']>> : never : never : any;
|
|
39
|
-
export type ApiEndpointResponse<AE extends ApiEndpoints, EN extends ApiEndpointName<AE, CM>, CM extends ApiConnectionMethod> = EN extends keyof AE ? CM extends keyof AE[EN] ? 'response' extends keyof AE[EN][CM] ? InstanceType<ExtractConstructor<AE[EN][CM]['response']>> : never : never : any;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|