add core creareApi index.d.ts
This commit is contained in:
parent
9fb89cb527
commit
af068a945e
25
dist/core.d.ts
vendored
Normal file
25
dist/core.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// ----- createApi -----
|
||||
|
||||
export type ApiAction = {
|
||||
url?: string | ((id?: unknown, data?: any) => string);
|
||||
method?: "get" | "post" | "put" | "patch" | "delete";
|
||||
body?: (data: any) => any;
|
||||
sendRawPayload?: boolean;
|
||||
invalidateKeys?: any[] | ((responseData: any, variables: any) => any[]);
|
||||
};
|
||||
|
||||
export type CreateApiConfig = {
|
||||
key: string | unknown[];
|
||||
url: string;
|
||||
actions?: Record<string, ApiAction>;
|
||||
axiosInstance?: any;
|
||||
fetcher?: any;
|
||||
};
|
||||
|
||||
export function createApi(config: CreateApiConfig): {
|
||||
key: unknown[];
|
||||
listKey: unknown[];
|
||||
useGet: any;
|
||||
useItem: any;
|
||||
useAction: any;
|
||||
};
|
||||
11
package.json
11
package.json
@ -16,7 +16,10 @@
|
||||
},
|
||||
"./pagination": "./dist/pagination.js",
|
||||
"./layout": "./dist/layout.js",
|
||||
"./core": "./dist/core.js",
|
||||
"./core": {
|
||||
"types": "./dist/core.d.ts",
|
||||
"import": "./dist/core.js"
|
||||
},
|
||||
"./table": "./dist/table.js",
|
||||
"./form": "./dist/form.js",
|
||||
"./icons": "./dist/icons.js"
|
||||
@ -26,7 +29,11 @@
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "vite build && cp src/index.d.ts dist/index.d.ts && cp src/utils/index.d.ts dist/utils.d.ts"
|
||||
"build": "vite build && yarn copy-types",
|
||||
"copy-types": "yarn copy-index-types && yarn copy-utils-types && yarn copy-core-types",
|
||||
"copy-index-types": "cp src/index.d.ts dist/index.d.ts",
|
||||
"copy-utils-types": "cp src/utils/index.d.ts dist/utils.d.ts",
|
||||
"copy-core-types": "cp src/core/index.d.ts dist/core.d.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@chakra-ui/react": "^2.0.0",
|
||||
|
||||
25
src/core/index.d.ts
vendored
Normal file
25
src/core/index.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// ----- createApi -----
|
||||
|
||||
export type ApiAction = {
|
||||
url?: string | ((id?: unknown, data?: any) => string);
|
||||
method?: "get" | "post" | "put" | "patch" | "delete";
|
||||
body?: (data: any) => any;
|
||||
sendRawPayload?: boolean;
|
||||
invalidateKeys?: any[] | ((responseData: any, variables: any) => any[]);
|
||||
};
|
||||
|
||||
export type CreateApiConfig = {
|
||||
key: string | unknown[];
|
||||
url: string;
|
||||
actions?: Record<string, ApiAction>;
|
||||
axiosInstance?: any;
|
||||
fetcher?: any;
|
||||
};
|
||||
|
||||
export function createApi(config: CreateApiConfig): {
|
||||
key: unknown[];
|
||||
listKey: unknown[];
|
||||
useGet: any;
|
||||
useItem: any;
|
||||
useAction: any;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user