add core creareApi index.d.ts

This commit is contained in:
Mohamadzadeh 2026-06-21 14:25:33 +03:30
parent 9fb89cb527
commit af068a945e
3 changed files with 59 additions and 2 deletions

25
dist/core.d.ts vendored Normal file
View 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;
};

View File

@ -16,7 +16,10 @@
}, },
"./pagination": "./dist/pagination.js", "./pagination": "./dist/pagination.js",
"./layout": "./dist/layout.js", "./layout": "./dist/layout.js",
"./core": "./dist/core.js", "./core": {
"types": "./dist/core.d.ts",
"import": "./dist/core.js"
},
"./table": "./dist/table.js", "./table": "./dist/table.js",
"./form": "./dist/form.js", "./form": "./dist/form.js",
"./icons": "./dist/icons.js" "./icons": "./dist/icons.js"
@ -26,7 +29,11 @@
"dist" "dist"
], ],
"scripts": { "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": { "peerDependencies": {
"@chakra-ui/react": "^2.0.0", "@chakra-ui/react": "^2.0.0",

25
src/core/index.d.ts vendored Normal file
View 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;
};