mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
* TEC-252: Base integration with commercetools using fetchers for REST and GraphQL endpoints * TEC-252: WIP commenting some components that are failing while we don't have all the hooks defined * add sdk integration * TEC-256: Implementing product search * TEC-256: removing unnecessary env variables * TEC-256: review comments * TEC-256: other remaining review fixes Co-authored-by: nicossosa93 <nicolas.sosa@devgurus.io>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { CommercetoolsConfig, Provider } from '@framework/api'
|
|
import { OperationContext } from '@commerce/api/operations'
|
|
|
|
export type Page = any
|
|
|
|
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
|
|
|
|
export type PageVariables = {
|
|
id: number
|
|
}
|
|
|
|
export default function getPageOperation({
|
|
commerce,
|
|
}: OperationContext<Provider>) {
|
|
async function getPage(opts: {
|
|
url?: string
|
|
variables: PageVariables
|
|
config?: Partial<CommercetoolsConfig>
|
|
preview?: boolean
|
|
}): Promise<GetPageResult>
|
|
|
|
async function getPage<T extends { page?: any }, V = any>(opts: {
|
|
url: string
|
|
variables: V
|
|
config?: Partial<CommercetoolsConfig>
|
|
preview?: boolean
|
|
}): Promise<GetPageResult<T>>
|
|
|
|
async function getPage({
|
|
url,
|
|
variables,
|
|
config: cfg,
|
|
preview,
|
|
}: {
|
|
url?: string
|
|
variables: PageVariables
|
|
config?: Partial<CommercetoolsConfig>
|
|
preview?: boolean
|
|
}): Promise<GetPageResult> {
|
|
const config = commerce.getConfig(cfg)
|
|
return {}
|
|
}
|
|
|
|
return getPage
|
|
}
|