mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Add get-all-pages operator
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
parent
8eda86ae82
commit
29b0e064a9
@ -10,10 +10,7 @@
|
|||||||
],
|
],
|
||||||
"generates": {
|
"generates": {
|
||||||
"./schema.d.ts": {
|
"./schema.d.ts": {
|
||||||
"plugins": ["typescript", "typescript-operations"],
|
"plugins": ["typescript", "typescript-operations"]
|
||||||
"config": {
|
|
||||||
"avoidOptionals": true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"./schema.graphql": {
|
"./schema.graphql": {
|
||||||
"plugins": ["schema-ast"]
|
"plugins": ["schema-ast"]
|
||||||
|
2791
packages/opencommerce/schema.d.ts
vendored
2791
packages/opencommerce/schema.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,44 @@
|
|||||||
|
import type {
|
||||||
|
OperationContext,
|
||||||
|
OperationOptions,
|
||||||
|
} from '@vercel/commerce/api/operations'
|
||||||
|
import { GetAllPagesOperation } from '../../types/page'
|
||||||
|
|
||||||
|
import type { OpenCommerceConfig, Provider } from '../index'
|
||||||
|
|
||||||
export type Page = { url: string }
|
export type Page = { url: string }
|
||||||
export type GetAllPagesResult = { pages: Page[] }
|
export type GetAllPagesResult = { pages: Page[] }
|
||||||
import type { OpenCommerceConfig } from '../index'
|
|
||||||
|
|
||||||
export default function getAllPagesOperation() {
|
export default function getAllPagesOperation({
|
||||||
function getAllPages({
|
commerce,
|
||||||
|
}: OperationContext<Provider>) {
|
||||||
|
async function getAllPages<T extends GetAllPagesOperation>(opts?: {
|
||||||
|
config?: Partial<OpenCommerceConfig>
|
||||||
|
preview?: boolean
|
||||||
|
}): Promise<T['data']>
|
||||||
|
|
||||||
|
async function getAllPages<T extends GetAllPagesOperation>(
|
||||||
|
opts: {
|
||||||
|
config?: Partial<OpenCommerceConfig>
|
||||||
|
preview?: boolean
|
||||||
|
} & OperationOptions
|
||||||
|
): Promise<T['data']>
|
||||||
|
|
||||||
|
async function getAllPages<T extends GetAllPagesOperation>(
|
||||||
|
opts: {
|
||||||
|
config?: Partial<OpenCommerceConfig>
|
||||||
|
preview?: boolean
|
||||||
|
} & OperationOptions
|
||||||
|
): Promise<T['data']>
|
||||||
|
|
||||||
|
async function getAllPages<T extends GetAllPagesOperation>({
|
||||||
config,
|
config,
|
||||||
preview,
|
preview,
|
||||||
}: {
|
}: {
|
||||||
url?: string
|
url?: string
|
||||||
config?: Partial<OpenCommerceConfig>
|
config?: Partial<OpenCommerceConfig>
|
||||||
preview?: boolean
|
preview?: boolean
|
||||||
}): Promise<GetAllPagesResult> {
|
} = {}): Promise<GetAllPagesResult> {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
pages: [],
|
pages: [],
|
||||||
})
|
})
|
||||||
|
11
packages/opencommerce/src/types/page.ts
Normal file
11
packages/opencommerce/src/types/page.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as Core from '@vercel/commerce/types/page'
|
||||||
|
export * from '@vercel/commerce/types/page'
|
||||||
|
|
||||||
|
export type Page = Core.Page
|
||||||
|
|
||||||
|
export type PageTypes = {
|
||||||
|
page: Page
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GetAllPagesOperation = Core.GetAllPagesOperation<PageTypes>
|
||||||
|
export type GetPageOperation = Core.GetPageOperation<PageTypes>
|
Loading…
x
Reference in New Issue
Block a user