1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-22 12:24:18 +00:00
Files
.vscode
assets
components
config
framework
bigcommerce
commerce
local
saleor
api
catalog
customers
endpoints
operations
utils
cart.ts
checkout.ts
index.ts
wishlist.ts
auth
cart
customer
product
types
utils
wishlist
.env.template
README.md
commerce.config.json
const.ts
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
types.ts
shopify
swell
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
swell-js.d.ts
tailwind.config.js
tsconfig.json
yarn.lock
commerce/framework/saleor/api/index.ts
Jakub Neander 3b2bf654fe Updated Saleor Provider ()
* Initial work, copied from the Shopify provider

* Added basis setup and type generation for the products queries

* refactor: adjust the types

* task: relax the Node.js constraint

* fix: page/product properties

* disable unknown fields

* mention Saleor in the README

* setup debugging for Next.js

* Check nextjs-commerce bug if no images are added for a product

* fix: client/server pecularities for env visibility

Must prefix with `NEXT_PUBLIC_` so that the API URL is
visible on the client

* re: make search work with Saleor API (WIP)

* task: update deps

* task: move to Webpack 5.x

* saleor: initial cart integration

* update deps

* saleor: shall the cart appear!

* task: remove deprecated packages

* saleor: adding/removing from the cart

* saleor: preliminary signup process

* saleor: fix the prices in the cart

* update deps

* update deps

* Added the options for a variant to the product page

* Mapped options to variants

* Mapped options to variants

* saleor: refine the auth process

* saleor: remove unused code

* saleor: handle customer find via refresh

temporary solution

* saleor: update deps

* saleor: fix the session handling

* saleor: fix the variants

* saleor: simplify the naming for GraphQL statements

* saleor: fix the type for collection

* saleor: arrange the error codes

* saleor: integrate collections

* saleor: fix product sorting

* saleor: set cookie location

* saleor: update the schema

* saleor: attach checkout to customer

* saleor: fix the checkout flow

* saleor: unify GraphQL naming approach

* task: update deps

* Add the env variables for saleor to the template

* task: prettier

* saleor: stub API for build/typescript compilation

thanks @cond0r

* task: temporarily disable for the `build`

* saleor: refactor GraphQL queries

* saleor: adjust the config

* task: update dependencies

* revert: Next.js to `10.0.9`

* saleor: fix the checkout fetch query

* task: update dependencies

* saleor: adapt for displaying featured products

* saleor: update the provider structure

* saleor: make the home page representable

* feature/cart: display the variant name (cond)

Co-authored-by: Patryk Zawadzki <patrys@room-303.com>
Co-authored-by: royderks <10717410+royderks@users.noreply.github.com>
2021-06-10 01:46:28 -05:00

50 lines
1.3 KiB
TypeScript

import type { CommerceAPIConfig } from '@commerce/api'
import * as Const from '../const'
if (!Const.API_URL) {
throw new Error(`The environment variable NEXT_SALEOR_API_URL is missing and it's required to access your store`)
}
if (!Const.API_CHANNEL) {
throw new Error(`The environment variable NEXT_SALEOR_CHANNEL is missing and it's required to access your store`)
}
import fetchGraphqlApi from './utils/fetch-graphql-api'
export interface SaleorConfig extends CommerceAPIConfig {
storeChannel: string
}
const config: SaleorConfig = {
locale: 'en-US',
commerceUrl: Const.API_URL,
apiToken: Const.SALEOR_TOKEN,
cartCookie: Const.CHECKOUT_ID_COOKIE,
cartCookieMaxAge: 60 * 60 * 24 * 30,
fetch: fetchGraphqlApi,
customerCookie: '',
storeChannel: Const.API_CHANNEL,
}
import {
CommerceAPI,
getCommerceApi as commerceApi,
} from '@commerce/api'
import * as operations from './operations'
export interface ShopifyConfig extends CommerceAPIConfig {}
export const provider = { config, operations }
export type Provider = typeof provider
export type SaleorAPI<P extends Provider = Provider> = CommerceAPI<P>
export function getCommerceApi<P extends Provider>(
customProvider: P = provider as any
): SaleorAPI<P> {
return commerceApi(customProvider)
}