import type { LoadEvent, RequestEvent } from '@sveltejs/kit' import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, HoudiniFetchContext, FetchParams, } from 'houdini/runtime' import type { Readable } from 'svelte/store' export type QueryInputs<_Data> = FetchQueryResult<_Data> & { variables: { [key: string]: any } } export type KitLoadResponse = { status?: number error?: Error redirect?: string props?: Record context?: Record maxage?: number } export type FragmentStoreInstance<_Data, _Input> = Readable<_Data> & { variables: _Input kind: typeof CompiledFragmentKind } type Reshape<_Data, _Input> = Omit, 'data'> & { data: _Data } export type CursorFragmentStoreInstance<_Data extends GraphQLObject, _Input> = { kind: typeof CompiledFragmentKind data: Readable<_Data> subscribe: Readable & { pageInfo: PageInfo }>['subscribe'] fetching: Readable } & CursorHandlers<_Data, _Input> export type OffsetFragmentStoreInstance<_Data extends GraphQLObject, _Input> = { kind: typeof CompiledFragmentKind data: Readable<_Data> subscribe: Readable>['subscribe'] fetching: Readable } & OffsetHandlers<_Data, _Input> type FetchGlobalParams<_Data extends GraphQLObject, _Input> = FetchParams<_Input> & { /** * Set to true if you want the promise to pause while it's resolving. * Only enable this if you know what you are doing. This will cause route * transitions to pause while loading data. */ blocking?: boolean /** * A function to call after the fetch happens (whether fake or not) */ then?: (val: _Data | null) => void | Promise } export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams< _Data, _Input > & { /** * Directly the `event` param coming from the `load` function */ event?: LoadEvent } export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams< _Data, _Input > & { /** * A RequestEvent should be provided when the store is being used in an endpoint. * When this happens, fetch also needs to be provided */ event?: RequestEvent /** * The fetch function to use when using this store in an endpoint. */ fetch?: LoadEvent['fetch'] } export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams< _Data, _Input > & { /** * An object containing all of the current info necessary for a * client-side fetch. Must be called in component initialization with * something like this: `const context = getHoudiniFetchContext()` */ context?: HoudiniFetchContext } export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = | QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input> export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = | LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>