mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
fix cloudflare adapter warm mode and type improvements
Adds warm mode support to cloudflare adapter to enable app instance caching. Improves BkndConfig type handling and makes hybrid mode reader optional. Fixes entity hook types to properly handle Generated ID types from kysely.
This commit is contained in:
@@ -8,7 +8,7 @@ import type {
|
||||
ModuleApi,
|
||||
} from "bknd";
|
||||
import { objectTransform, encodeSearch } from "bknd/utils";
|
||||
import type { Insertable, Selectable, Updateable } from "kysely";
|
||||
import type { Insertable, Selectable, Updateable, Generated } from "kysely";
|
||||
import useSWR, { type SWRConfiguration, type SWRResponse, mutate } from "swr";
|
||||
import { type Api, useApi } from "ui/client";
|
||||
|
||||
@@ -33,6 +33,7 @@ interface UseEntityReturn<
|
||||
Entity extends keyof DB | string,
|
||||
Id extends PrimaryFieldType | undefined,
|
||||
Data = Entity extends keyof DB ? DB[Entity] : EntityData,
|
||||
ActualId = Data extends { id: infer I } ? (I extends Generated<infer T> ? T : I) : never,
|
||||
Response = ResponseObject<RepositoryResult<Selectable<Data>>>,
|
||||
> {
|
||||
create: (input: Insertable<Data>) => Promise<Response>;
|
||||
@@ -42,9 +43,11 @@ interface UseEntityReturn<
|
||||
ResponseObject<RepositoryResult<Id extends undefined ? Selectable<Data>[] : Selectable<Data>>>
|
||||
>;
|
||||
update: Id extends undefined
|
||||
? (input: Updateable<Data>, id: Id) => Promise<Response>
|
||||
? (input: Updateable<Data>, id: ActualId) => Promise<Response>
|
||||
: (input: Updateable<Data>) => Promise<Response>;
|
||||
_delete: Id extends undefined ? (id: Id) => Promise<Response> : () => Promise<Response>;
|
||||
_delete: Id extends undefined
|
||||
? (id: PrimaryFieldType) => Promise<Response>
|
||||
: () => Promise<Response>;
|
||||
}
|
||||
|
||||
export const useEntity = <
|
||||
|
||||
Reference in New Issue
Block a user