@techsio/storefront-data
Version:
Medusa-first storefront data layer built on TanStack Query.
35 lines • 2.35 kB
TypeScript
import { type CacheConfig, type CacheStrategy } from "./cache-config";
import type { QueryFactoryOptions, ReadQueryOptions } from "./hook-types";
import type { QueryKey } from "./query-keys";
type EnabledInput = {
enabled?: boolean;
};
type DetailInputBase = EnabledInput & {
id?: string;
};
type SimpleQueryKeys<TListParams, TDetailParams> = {
list: (params: TListParams) => QueryKey;
detail: (params: TDetailParams) => QueryKey;
};
type SimpleReadOptions<TData> = {
queryOptions?: ReadQueryOptions<TData>;
cacheStrategy?: CacheStrategy;
};
export type SimpleListDetailQueryOptionsFactory<TListResponse, TDetailResult, TListInput extends EnabledInput, TDetailInput extends DetailInputBase> = {
getListQueryOptions: (input: TListInput, options?: SimpleReadOptions<TListResponse>) => QueryFactoryOptions<TListResponse>;
getDetailQueryOptions: (input: TDetailInput, options?: SimpleReadOptions<TDetailResult>) => QueryFactoryOptions<TDetailResult>;
};
export type CreateSimpleListDetailQueryOptionsFactoryConfig<TListResponse, TDetailResult, TListInput extends EnabledInput, TListParams, TDetailInput extends DetailInputBase, TDetailParams> = {
getList: (params: TListParams, signal?: AbortSignal) => Promise<TListResponse>;
getDetail: (params: TDetailParams, signal?: AbortSignal) => Promise<TDetailResult>;
buildListParams?: (input: TListInput) => TListParams;
buildDetailParams?: (input: TDetailInput) => TDetailParams;
queryKeys: SimpleQueryKeys<TListParams, TDetailParams>;
cacheConfig?: CacheConfig;
defaultCacheStrategy?: CacheStrategy;
isDetailInputReady?: (input: TDetailInput) => boolean;
missingDetailErrorMessage: string;
};
export declare function createSimpleListDetailQueryOptionsFactory<TListResponse, TDetailResult, TListInput extends EnabledInput, TListParams, TDetailInput extends DetailInputBase, TDetailParams>({ getList, getDetail, buildListParams, buildDetailParams, queryKeys, cacheConfig, defaultCacheStrategy, isDetailInputReady, missingDetailErrorMessage, }: CreateSimpleListDetailQueryOptionsFactoryConfig<TListResponse, TDetailResult, TListInput, TListParams, TDetailInput, TDetailParams>): SimpleListDetailQueryOptionsFactory<TListResponse, TDetailResult, TListInput, TDetailInput>;
export {};
//# sourceMappingURL=simple-list-detail-query-options.d.ts.map