mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
Generalize TypeScript and add typings to getPage
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import type { OperationOptions } from '@commerce/api/operations'
|
||||
import type { GetPageOperation } from '@commerce/types/page'
|
||||
import type { SpreeApiConfig } from '..'
|
||||
|
||||
export type Page = any
|
||||
export type GetPageResult = { page?: Page }
|
||||
|
||||
@@ -6,8 +10,33 @@ export type PageVariables = {
|
||||
}
|
||||
|
||||
export default function getPageOperation() {
|
||||
function getPage(): Promise<GetPageResult> {
|
||||
async function getPage<T extends GetPageOperation>(opts: {
|
||||
variables: T['variables']
|
||||
config?: Partial<SpreeApiConfig>
|
||||
preview?: boolean
|
||||
}): Promise<T['data']>
|
||||
|
||||
async function getPage<T extends GetPageOperation>(
|
||||
opts: {
|
||||
variables: T['variables']
|
||||
config?: Partial<SpreeApiConfig>
|
||||
preview?: boolean
|
||||
} & OperationOptions
|
||||
): Promise<T['data']>
|
||||
|
||||
async function getPage<T extends GetPageOperation>({
|
||||
url,
|
||||
variables,
|
||||
config,
|
||||
preview,
|
||||
}: {
|
||||
url?: string
|
||||
variables: T['variables']
|
||||
config?: Partial<SpreeApiConfig>
|
||||
preview?: boolean
|
||||
}): Promise<T['data']> {
|
||||
return Promise.resolve({})
|
||||
}
|
||||
|
||||
return getPage
|
||||
}
|
||||
|
Reference in New Issue
Block a user