mirror of
https://github.com/vercel/commerce.git
synced 2025-04-24 20:07:50 +00:00
37 lines
904 B
TypeScript
37 lines
904 B
TypeScript
import type { RequestInit, Response } from '@vercel/fetch'
|
|
|
|
export interface CommerceAPIConfig {
|
|
locale?: string
|
|
commerceUrl: string
|
|
apiToken: string
|
|
cartCookie: string
|
|
cartCookieMaxAge: number
|
|
customerCookie: string
|
|
fetch<Data = any, Variables = any>(
|
|
query: string,
|
|
queryData?: CommerceAPIFetchOptions<Variables>,
|
|
fetchOptions?: RequestInit
|
|
): Promise<GraphQLFetcherResult<Data>>
|
|
}
|
|
|
|
export type GraphQLFetcher<
|
|
Data extends GraphQLFetcherResult = GraphQLFetcherResult,
|
|
Variables = any
|
|
> = (
|
|
query: string,
|
|
queryData?: CommerceAPIFetchOptions<Variables>,
|
|
fetchOptions?: RequestInit
|
|
) => Promise<Data>
|
|
|
|
export interface GraphQLFetcherResult<Data = any> {
|
|
data: Data
|
|
res: Response
|
|
}
|
|
|
|
export interface CommerceAPIFetchOptions<Variables> {
|
|
variables?: Variables
|
|
preview?: boolean
|
|
}
|
|
|
|
// TODO: define interfaces for all the available operations and API endpoints
|