From af068a945eaa7f682d6cbb5379b8a9411c9ab839 Mon Sep 17 00:00:00 2001 From: Mohamadzadeh <7796733@gmail.com> Date: Sun, 21 Jun 2026 14:25:33 +0330 Subject: [PATCH] add core creareApi index.d.ts --- dist/core.d.ts | 25 +++++++++++++++++++++++++ package.json | 11 +++++++++-- src/core/index.d.ts | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 dist/core.d.ts create mode 100644 src/core/index.d.ts diff --git a/dist/core.d.ts b/dist/core.d.ts new file mode 100644 index 0000000..5cfcbfb --- /dev/null +++ b/dist/core.d.ts @@ -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; + axiosInstance?: any; + fetcher?: any; +}; + +export function createApi(config: CreateApiConfig): { + key: unknown[]; + listKey: unknown[]; + useGet: any; + useItem: any; + useAction: any; +}; diff --git a/package.json b/package.json index e08a3d7..de27664 100644 --- a/package.json +++ b/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", diff --git a/src/core/index.d.ts b/src/core/index.d.ts new file mode 100644 index 0000000..5cfcbfb --- /dev/null +++ b/src/core/index.d.ts @@ -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; + axiosInstance?: any; + fetcher?: any; +}; + +export function createApi(config: CreateApiConfig): { + key: unknown[]; + listKey: unknown[]; + useGet: any; + useItem: any; + useAction: any; +};