mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
Adding supported files for new provider
This commit is contained in:
parent
f98cea2c1d
commit
62e03f518c
1
framework/elasticpath/api/endpoints/cart/index.ts
Normal file
1
framework/elasticpath/api/endpoints/cart/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/catalog/index.ts
Normal file
1
framework/elasticpath/api/endpoints/catalog/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/catalog/products.ts
Normal file
1
framework/elasticpath/api/endpoints/catalog/products.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/checkout/index.ts
Normal file
1
framework/elasticpath/api/endpoints/checkout/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/customer/index.ts
Normal file
1
framework/elasticpath/api/endpoints/customer/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/logout/index.ts
Normal file
1
framework/elasticpath/api/endpoints/logout/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/signup/index.ts
Normal file
1
framework/elasticpath/api/endpoints/signup/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/elasticpath/api/endpoints/wishlist/index.tsx
Normal file
1
framework/elasticpath/api/endpoints/wishlist/index.tsx
Normal file
@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
@ -7,7 +7,15 @@ import {
|
||||
import createFetcher from './utils/fetch-local'
|
||||
|
||||
import type { LoginAPI } from './endpoints/login'
|
||||
|
||||
import login from './operations/login'
|
||||
import getAllPages from './operations/get-all-pages'
|
||||
import getPage from './operations/get-page'
|
||||
import getSiteInfo from './operations/get-site-info'
|
||||
import getCustomerWishlist from './operations/get-customer-wishlist'
|
||||
import getAllProductPaths from './operations/get-all-product-paths'
|
||||
import getAllProducts from './operations/get-all-products'
|
||||
import getProduct from './operations/get-product'
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_ELASTICPATH_BASE
|
||||
const STOREID = process.env.NEXT_PUBLIC_ELASTICPATH_STOREID
|
||||
@ -36,7 +44,15 @@ const config: any = {
|
||||
}
|
||||
|
||||
const operations = {
|
||||
login
|
||||
login,
|
||||
|
||||
getAllPages,
|
||||
getPage,
|
||||
getSiteInfo,
|
||||
getCustomerWishlist,
|
||||
getAllProductPaths,
|
||||
getAllProducts,
|
||||
getProduct
|
||||
}
|
||||
|
||||
export interface ElasticpathConfig extends CommerceAPIConfig {
|
||||
@ -50,10 +66,10 @@ export type Provider = typeof provider
|
||||
export type APIs =
|
||||
| LoginAPI
|
||||
|
||||
export type ElasticpathAPI<P extends Provider = Provider> = CommerceAPI<P>
|
||||
export type ElasticpathAPI<P extends Provider = Provider> = CommerceAPI<P | any>
|
||||
|
||||
export function getCommerceApi<P extends Provider>(
|
||||
customProvider: P = provider as any
|
||||
): ElasticpathAPI<P> {
|
||||
return commerceApi(customProvider)
|
||||
return commerceApi(customProvider as any)
|
||||
}
|
||||
|
19
framework/elasticpath/api/operations/get-all-pages.ts
Normal file
19
framework/elasticpath/api/operations/get-all-pages.ts
Normal file
@ -0,0 +1,19 @@
|
||||
export type Page = { url: string }
|
||||
export type GetAllPagesResult = { pages: Page[] }
|
||||
import type { ElasticpathConfig } from '../index'
|
||||
|
||||
export default function getAllPagesOperation() {
|
||||
function getAllPages({
|
||||
config,
|
||||
preview,
|
||||
}: {
|
||||
url?: string
|
||||
config?: Partial<ElasticpathConfig>
|
||||
preview?: boolean
|
||||
}): Promise<GetAllPagesResult> {
|
||||
return Promise.resolve({
|
||||
pages: [],
|
||||
})
|
||||
}
|
||||
return getAllPages
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import data from '../../data.json'
|
||||
|
||||
export type GetAllProductPathsResult = {
|
||||
products: Array<{ path: string }>
|
||||
}
|
||||
|
||||
export default function getAllProductPathsOperation() {
|
||||
function getAllProductPaths(): Promise<GetAllProductPathsResult> {
|
||||
return Promise.resolve({
|
||||
products: data.products.map(({ path }) => ({ path })),
|
||||
})
|
||||
}
|
||||
|
||||
return getAllProductPaths
|
||||
}
|
25
framework/elasticpath/api/operations/get-all-products.ts
Normal file
25
framework/elasticpath/api/operations/get-all-products.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Product } from '@commerce/types/product'
|
||||
import { GetAllProductsOperation } from '@commerce/types/product'
|
||||
import type { OperationContext } from '@commerce/api/operations'
|
||||
import type { ElasticpathConfig, Provider } from '../index'
|
||||
import data from '../../data.json'
|
||||
|
||||
export default function getAllProductsOperation({
|
||||
commerce,
|
||||
}: OperationContext<any>) {
|
||||
async function getAllProducts<T extends GetAllProductsOperation>({
|
||||
query = '',
|
||||
variables,
|
||||
config,
|
||||
}: {
|
||||
query?: string
|
||||
variables?: T['variables']
|
||||
config?: Partial<ElasticpathConfig>
|
||||
preview?: boolean
|
||||
} = {}): Promise<{ products: Product[] | any[] }> {
|
||||
return {
|
||||
products: data.products,
|
||||
}
|
||||
}
|
||||
return getAllProducts
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
export default function getCustomerWishlistOperation() {
|
||||
function getCustomerWishlist(): any {
|
||||
return { wishlist: {} }
|
||||
}
|
||||
return getCustomerWishlist
|
||||
}
|
13
framework/elasticpath/api/operations/get-page.ts
Normal file
13
framework/elasticpath/api/operations/get-page.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export type Page = any
|
||||
export type GetPageResult = { page?: Page }
|
||||
|
||||
export type PageVariables = {
|
||||
id: number
|
||||
}
|
||||
|
||||
export default function getPageOperation() {
|
||||
function getPage(): Promise<GetPageResult> {
|
||||
return Promise.resolve({})
|
||||
}
|
||||
return getPage
|
||||
}
|
26
framework/elasticpath/api/operations/get-product.ts
Normal file
26
framework/elasticpath/api/operations/get-product.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import type { ElasticpathConfig } from '../index'
|
||||
import { Product } from '@commerce/types/product'
|
||||
import { GetProductOperation } from '@commerce/types/product'
|
||||
import data from '../../data.json'
|
||||
import type { OperationContext } from '@commerce/api/operations'
|
||||
|
||||
export default function getProductOperation({
|
||||
commerce,
|
||||
}: OperationContext<any>) {
|
||||
async function getProduct<T extends GetProductOperation>({
|
||||
query = '',
|
||||
variables,
|
||||
config,
|
||||
}: {
|
||||
query?: string
|
||||
variables?: T['variables']
|
||||
config?: Partial<ElasticpathConfig>
|
||||
preview?: boolean
|
||||
} = {}): Promise<Product | {} | any> {
|
||||
return {
|
||||
product: data.products.find(({ slug }) => slug === variables!.slug),
|
||||
}
|
||||
}
|
||||
|
||||
return getProduct
|
||||
}
|
43
framework/elasticpath/api/operations/get-site-info.ts
Normal file
43
framework/elasticpath/api/operations/get-site-info.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { OperationContext } from '@commerce/api/operations'
|
||||
import { Category } from '@commerce/types/site'
|
||||
import { ElasticpathConfig } from '../index'
|
||||
|
||||
export type GetSiteInfoResult<
|
||||
T extends { categories: any[]; brands: any[] } = {
|
||||
categories: Category[]
|
||||
brands: any[]
|
||||
}
|
||||
> = T
|
||||
|
||||
export default function getSiteInfoOperation({}: OperationContext<any>) {
|
||||
function getSiteInfo({
|
||||
query,
|
||||
variables,
|
||||
config: cfg,
|
||||
}: {
|
||||
query?: string
|
||||
variables?: any
|
||||
config?: Partial<ElasticpathConfig>
|
||||
preview?: boolean
|
||||
} = {}): Promise<GetSiteInfoResult> {
|
||||
return Promise.resolve({
|
||||
categories: [
|
||||
{
|
||||
id: 'new-arrivals',
|
||||
name: 'New Arrivals',
|
||||
slug: 'new-arrivals',
|
||||
path: '/new-arrivals',
|
||||
},
|
||||
{
|
||||
id: 'featured',
|
||||
name: 'Featured',
|
||||
slug: 'featured',
|
||||
path: '/featured',
|
||||
},
|
||||
],
|
||||
brands: [],
|
||||
})
|
||||
}
|
||||
|
||||
return getSiteInfo
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
const commerce = require('./commerce.config.json')
|
||||
|
||||
module.exports = {
|
||||
commerce,
|
||||
images: {
|
||||
domains: ['localhost'],
|
||||
},
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user