mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 23:16:59 +00:00
Import core types only from commerce
This commit is contained in:
parent
6bdfe56e9f
commit
9136ae21a3
15
README.md
15
README.md
@ -23,8 +23,8 @@ Demo live at: [demo.vercel.store](https://demo.vercel.store/)
|
|||||||
> To run a minimal version of Next.js Commerce you can start with the default local provider `@vercel/commerce-local` that has disabled all features (cart, auth) and use static files for the backend
|
> To run a minimal version of Next.js Commerce you can start with the default local provider `@vercel/commerce-local` that has disabled all features (cart, auth) and use static files for the backend
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm install # run this command in root folder of the mono repo
|
pnpm install & pnpm build # run this commands in root folder of the mono repo
|
||||||
pnpm dev
|
pnpm dev # run this commands in the site folder
|
||||||
```
|
```
|
||||||
|
|
||||||
> If you encounter any problems while installing and running for the first time, please see the Troubleshoot section
|
> If you encounter any problems while installing and running for the first time, please see the Troubleshoot section
|
||||||
@ -111,10 +111,11 @@ Our commitment to Open Source can be found [here](https://vercel.com/oss).
|
|||||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
|
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
|
||||||
2. Create a new branch `git checkout -b MY_BRANCH_NAME`
|
2. Create a new branch `git checkout -b MY_BRANCH_NAME`
|
||||||
3. Install the dependencies: `pnpm install`
|
3. Install the dependencies: `pnpm install`
|
||||||
4. Duplicate `site/.env.template` and rename it to `site/.env.local`
|
4. Build the packages: `pnpm build`
|
||||||
5. Add proper store values to `site/.env.local`
|
5. Duplicate `site/.env.template` and rename it to `site/.env.local`
|
||||||
6. Run `pnpm dev` to build the packages and watch for code changes
|
6. Add proper store values to `site/.env.local`
|
||||||
7. Run `pnpm turbo run build` to check the build after your changes
|
7. Run `cd site` & `pnpm dev` to watch for code changes
|
||||||
|
8. Run `pnpm turbo run build` to check the build after your changes
|
||||||
|
|
||||||
## Work in progress
|
## Work in progress
|
||||||
|
|
||||||
@ -191,7 +192,7 @@ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this comm
|
|||||||
|
|
||||||
The error usually occurs when running `pnpm dev` inside of the `/site/` folder after installing a fresh repository.
|
The error usually occurs when running `pnpm dev` inside of the `/site/` folder after installing a fresh repository.
|
||||||
|
|
||||||
In order to fix this, run `pnpm dev` in the monorepo root folder first.
|
In order to fix this, run `pnpm build` in the monorepo root folder first.
|
||||||
|
|
||||||
> Using `pnpm dev` from the root is recommended for developing, which will run watch mode on all packages.
|
> Using `pnpm dev` from the root is recommended for developing, which will run watch mode on all packages.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { normalizeCart } from '../../../lib/normalize'
|
import { normalizeCart } from '../../../lib/normalize'
|
||||||
import { BigcommerceApiError } from '../../utils/errors'
|
import { BigcommerceApiError } from '../../utils/errors'
|
||||||
import getCartCookie from '../../utils/get-cart-cookie'
|
import getCartCookie from '../../utils/get-cart-cookie'
|
||||||
import type { BigcommerceCart } from '../../../types/cart'
|
import type { BigcommerceCart } from '../../../types'
|
||||||
import type { CartEndpoint } from '.'
|
import type { CartEndpoint } from '.'
|
||||||
|
|
||||||
// Return current cart info
|
// Return current cart info
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import cartEndpoint from '@vercel/commerce/api/endpoints/cart'
|
import cartEndpoint from '@vercel/commerce/api/endpoints/cart'
|
||||||
import type { CartSchema } from '../../../types/cart'
|
import type { CartSchema } from '@vercel/commerce/types/cart'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getCart from './get-cart'
|
import getCart from './get-cart'
|
||||||
import addItem from './add-item'
|
import addItem from './add-item'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import productsEndpoint from '@vercel/commerce/api/endpoints/catalog/products'
|
import productsEndpoint from '@vercel/commerce/api/endpoints/catalog/products'
|
||||||
import type { ProductsSchema } from '../../../../types/product'
|
import type { ProductsSchema } from '@vercel/commerce/types/product'
|
||||||
import type { BigcommerceAPI } from '../../..'
|
import type { BigcommerceAPI } from '../../..'
|
||||||
import getProducts from './get-products'
|
import getProducts from './get-products'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout'
|
import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout'
|
||||||
import type { CheckoutSchema } from '../../../types/checkout'
|
import type { CheckoutSchema } from '@vercel/commerce/types/checkout'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getCheckout from './get-checkout'
|
import getCheckout from './get-checkout'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import customerEndpoint from '@vercel/commerce/api/endpoints/customer'
|
import customerEndpoint from '@vercel/commerce/api/endpoints/customer'
|
||||||
import type { CustomerSchema } from '../../../types/customer'
|
import type { CustomerSchema } from '@vercel/commerce/types/customer'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getLoggedInCustomer from './get-logged-in-customer'
|
import getLoggedInCustomer from './get-logged-in-customer'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
||||||
import type { LoginSchema } from '../../../types/login'
|
import type { LoginSchema } from '@vercel/commerce/types/login'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import login from './login'
|
import login from './login'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import logoutEndpoint from '@vercel/commerce/api/endpoints/logout'
|
import logoutEndpoint from '@vercel/commerce/api/endpoints/logout'
|
||||||
import type { LogoutSchema } from '../../../types/logout'
|
import type { LogoutSchema } from '@vercel/commerce/types/logout'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import logout from './logout'
|
import logout from './logout'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import signupEndpoint from '@vercel/commerce/api/endpoints/signup'
|
import signupEndpoint from '@vercel/commerce/api/endpoints/signup'
|
||||||
import type { SignupSchema } from '../../../types/signup'
|
import type { SignupSchema } from '@vercel/commerce/types/signup'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import signup from './signup'
|
import signup from './signup'
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { Wishlist } from '../../../types/wishlist'
|
import type { Wishlist } from '@vercel/commerce/types/wishlist'
|
||||||
import type { WishlistEndpoint } from '.'
|
import type { WishlistEndpoint } from '.'
|
||||||
import getCustomerId from '../../utils/get-customer-id'
|
import getCustomerId from '../../utils/get-customer-id'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import wishlistEndpoint from '@vercel/commerce/api/endpoints/wishlist'
|
import wishlistEndpoint from '@vercel/commerce/api/endpoints/wishlist'
|
||||||
import type { WishlistSchema } from '../../../types/wishlist'
|
import type { WishlistSchema } from '@vercel/commerce/types/wishlist'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getWishlist from './get-wishlist'
|
import getWishlist from './get-wishlist'
|
||||||
import addItem from './add-item'
|
import addItem from './add-item'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import type { Wishlist } from '../../../types/wishlist'
|
import type { Wishlist } from '@vercel/commerce/types/wishlist'
|
||||||
import getCustomerWishlist from '../../operations/get-customer-wishlist'
|
|
||||||
import getCustomerId from '../../utils/get-customer-id'
|
import getCustomerId from '../../utils/get-customer-id'
|
||||||
import type { WishlistEndpoint } from '.'
|
import type { WishlistEndpoint } from '.'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import type {
|
|||||||
OperationContext,
|
OperationContext,
|
||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { GetAllPagesOperation } from '../../types/page'
|
import type { GetAllPagesOperation } from '@vercel/commerce/types/page'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||||
import { BigcommerceConfig, Provider } from '..'
|
import { BigcommerceConfig, Provider } from '..'
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import type {
|
|||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { GetAllProductPathsQuery } from '../../../schema'
|
import type { GetAllProductPathsQuery } from '../../../schema'
|
||||||
import type { GetAllProductPathsOperation } from '../../types/product'
|
import type { GetAllProductPathsOperation } from '@vercel/commerce/types/product'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||||
import filterEdges from '../utils/filter-edges'
|
import filterEdges from '../utils/filter-edges'
|
||||||
import { BigcommerceConfig, Provider } from '..'
|
import { BigcommerceConfig, Provider } from '..'
|
||||||
|
@ -6,7 +6,7 @@ import type {
|
|||||||
GetAllProductsQuery,
|
GetAllProductsQuery,
|
||||||
GetAllProductsQueryVariables,
|
GetAllProductsQueryVariables,
|
||||||
} from '../../../schema'
|
} from '../../../schema'
|
||||||
import type { GetAllProductsOperation } from '../../types/product'
|
import type { GetAllProductsOperation } from '@vercel/commerce/types/product'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||||
import filterEdges from '../utils/filter-edges'
|
import filterEdges from '../utils/filter-edges'
|
||||||
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
||||||
|
@ -5,7 +5,7 @@ import type {
|
|||||||
import type {
|
import type {
|
||||||
GetCustomerWishlistOperation,
|
GetCustomerWishlistOperation,
|
||||||
Wishlist,
|
Wishlist,
|
||||||
} from '../../types/wishlist'
|
} from '@vercel/commerce/types/wishlist'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||||
import { BigcommerceConfig, Provider } from '..'
|
import { BigcommerceConfig, Provider } from '..'
|
||||||
import getAllProducts, { ProductEdge } from './get-all-products'
|
import getAllProducts, { ProductEdge } from './get-all-products'
|
||||||
|
@ -2,7 +2,7 @@ import type {
|
|||||||
OperationContext,
|
OperationContext,
|
||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { GetPageOperation, Page } from '../../types/page'
|
import type { GetPageOperation, Page } from '@vercel/commerce/types/page'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||||
import type { BigcommerceConfig, Provider } from '..'
|
import type { BigcommerceConfig, Provider } from '..'
|
||||||
import { normalizePage } from '../../lib/normalize'
|
import { normalizePage } from '../../lib/normalize'
|
||||||
|
@ -2,7 +2,7 @@ import type {
|
|||||||
OperationContext,
|
OperationContext,
|
||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { GetProductOperation } from '../../types/product'
|
import type { GetProductOperation } from '@vercel/commerce/types/product'
|
||||||
import type { GetProductQuery, GetProductQueryVariables } from '../../../schema'
|
import type { GetProductQuery, GetProductQueryVariables } from '../../../schema'
|
||||||
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
||||||
import { productInfoFragment } from '../fragments/product'
|
import { productInfoFragment } from '../fragments/product'
|
||||||
|
@ -2,7 +2,7 @@ import type {
|
|||||||
OperationContext,
|
OperationContext,
|
||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { GetSiteInfoOperation } from '../../types/site'
|
import type { GetSiteInfoOperation } from '@vercel/commerce/types/site'
|
||||||
import type { GetSiteInfoQuery } from '../../../schema'
|
import type { GetSiteInfoQuery } from '../../../schema'
|
||||||
import filterEdges from '../utils/filter-edges'
|
import filterEdges from '../utils/filter-edges'
|
||||||
import type { BigcommerceConfig, Provider } from '..'
|
import type { BigcommerceConfig, Provider } from '..'
|
||||||
|
@ -3,7 +3,7 @@ import type {
|
|||||||
OperationContext,
|
OperationContext,
|
||||||
OperationOptions,
|
OperationOptions,
|
||||||
} from '@vercel/commerce/api/operations'
|
} from '@vercel/commerce/api/operations'
|
||||||
import type { LoginOperation } from '../../types/login'
|
import type { LoginOperation } from '@vercel/commerce/types/login'
|
||||||
import type { LoginMutation } from '../../../schema'
|
import type { LoginMutation } from '../../../schema'
|
||||||
import type { RecursivePartial } from '../utils/types'
|
import type { RecursivePartial } from '../utils/types'
|
||||||
import concatHeader from '../utils/concat-cookie'
|
import concatHeader from '../utils/concat-cookie'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { WishlistItemBody } from '../../types/wishlist'
|
import type { WishlistItemBody } from '@vercel/commerce/types/wishlist'
|
||||||
import type { CartItemBody, SelectedOption } from '../../types/cart'
|
import type { CartItemBody, SelectedOption } from '@vercel/commerce/types/cart'
|
||||||
|
|
||||||
type BCWishlistItemBody = {
|
type BCWishlistItemBody = {
|
||||||
product_id: number
|
product_id: number
|
||||||
|
@ -2,7 +2,7 @@ import { useCallback } from 'react'
|
|||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login'
|
import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login'
|
||||||
import type { LoginHook } from '../types/login'
|
import type { LoginHook } from '@vercel/commerce/types/login'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
|
|
||||||
export default useLogin as UseLogin<typeof handler>
|
export default useLogin as UseLogin<typeof handler>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout'
|
import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout'
|
||||||
import type { LogoutHook } from '../types/logout'
|
import type { LogoutHook } from '@vercel/commerce/types/logout'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
|
|
||||||
export default useLogout as UseLogout<typeof handler>
|
export default useLogout as UseLogout<typeof handler>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup'
|
import useSignup, { type UseSignup } from '@vercel/commerce/auth/use-signup'
|
||||||
import type { SignupHook } from '../types/signup'
|
import type { SignupHook } from '@vercel/commerce/types/signup'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
|
|
||||||
export default useSignup as UseSignup<typeof handler>
|
export default useSignup as UseSignup<typeof handler>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import type { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useCustomer, {
|
import useCustomer, {
|
||||||
UseCustomer,
|
type UseCustomer,
|
||||||
} from '@vercel/commerce/customer/use-customer'
|
} from '@vercel/commerce/customer/use-customer'
|
||||||
import type { CustomerHook } from '../types/customer'
|
import type { CustomerHook } from '@vercel/commerce/types/customer'
|
||||||
|
|
||||||
export default useCustomer as UseCustomer<typeof handler>
|
export default useCustomer as UseCustomer<typeof handler>
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import type { Product } from '../types/product'
|
import type { Page } from '@vercel/commerce/types/page'
|
||||||
import type { Cart, BigcommerceCart, LineItem } from '../types/cart'
|
import type { Product } from '@vercel/commerce/types/product'
|
||||||
import type { Page } from '../types/page'
|
import type { Cart, LineItem } from '@vercel/commerce/types/cart'
|
||||||
import type { BCCategory, BCBrand, Category, Brand } from '../types/site'
|
import type { Category, Brand } from '@vercel/commerce/types/site'
|
||||||
|
import type { BigcommerceCart, BCCategory, BCBrand } from '../types'
|
||||||
|
|
||||||
import { definitions } from '../api/definitions/store-content'
|
import { definitions } from '../api/definitions/store-content'
|
||||||
import update from './immutability'
|
import update from './immutability'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useSearch, { UseSearch } from '@vercel/commerce/product/use-search'
|
import useSearch, { UseSearch } from '@vercel/commerce/product/use-search'
|
||||||
import type { SearchProductsHook } from '../types/product'
|
import type { SearchProductsHook } from '@vercel/commerce/types/product'
|
||||||
|
|
||||||
export default useSearch as UseSearch<typeof handler>
|
export default useSearch as UseSearch<typeof handler>
|
||||||
|
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
export * from '@vercel/commerce/types/cart'
|
import type { GetSiteInfoQuery } from '../schema'
|
||||||
|
|
||||||
|
export type BCCategory = NonNullable<
|
||||||
|
GetSiteInfoQuery['site']['categoryTree']
|
||||||
|
>[0]
|
||||||
|
|
||||||
|
export type BCBrand = NonNullable<
|
||||||
|
NonNullable<GetSiteInfoQuery['site']['brands']['edges']>[0]
|
||||||
|
>
|
||||||
|
|
||||||
// TODO: this type should match:
|
// TODO: this type should match:
|
||||||
// https://developer.bigcommerce.com/api-reference/cart-checkout/server-server-cart-api/cart/getacart#responses
|
// https://developer.bigcommerce.com/api-reference/cart-checkout/server-server-cart-api/cart/getacart#responses
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/checkout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/common'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/customer'
|
|
@ -1,25 +0,0 @@
|
|||||||
import * as Cart from './cart'
|
|
||||||
import * as Checkout from './checkout'
|
|
||||||
import * as Common from './common'
|
|
||||||
import * as Customer from './customer'
|
|
||||||
import * as Login from './login'
|
|
||||||
import * as Logout from './logout'
|
|
||||||
import * as Page from './page'
|
|
||||||
import * as Product from './product'
|
|
||||||
import * as Signup from './signup'
|
|
||||||
import * as Site from './site'
|
|
||||||
import * as Wishlist from './wishlist'
|
|
||||||
|
|
||||||
export type {
|
|
||||||
Cart,
|
|
||||||
Checkout,
|
|
||||||
Common,
|
|
||||||
Customer,
|
|
||||||
Login,
|
|
||||||
Logout,
|
|
||||||
Page,
|
|
||||||
Product,
|
|
||||||
Signup,
|
|
||||||
Site,
|
|
||||||
Wishlist,
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/login'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/page'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/product'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/signup'
|
|
@ -1,11 +0,0 @@
|
|||||||
import type { GetSiteInfoQuery } from '../../schema'
|
|
||||||
|
|
||||||
export * from '@vercel/commerce/types/site'
|
|
||||||
|
|
||||||
export type BCCategory = NonNullable<
|
|
||||||
GetSiteInfoQuery['site']['categoryTree']
|
|
||||||
>[0]
|
|
||||||
|
|
||||||
export type BCBrand = NonNullable<
|
|
||||||
NonNullable<GetSiteInfoQuery['site']['brands']['edges']>[0]
|
|
||||||
>
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/wishlist'
|
|
@ -1,8 +1,10 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import useAddItem, { UseAddItem } from '@vercel/commerce/wishlist/use-add-item'
|
import useAddItem, {
|
||||||
import type { AddItemHook } from '../types/wishlist'
|
type UseAddItem,
|
||||||
|
} from '@vercel/commerce/wishlist/use-add-item'
|
||||||
|
import type { AddItemHook } from '@vercel/commerce/types/wishlist'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
import useWishlist from './use-wishlist'
|
import useWishlist from './use-wishlist'
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import { useCallback } from 'react'
|
|||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import useRemoveItem, {
|
import useRemoveItem, {
|
||||||
UseRemoveItem,
|
type UseRemoveItem,
|
||||||
} from '@vercel/commerce/wishlist/use-remove-item'
|
} from '@vercel/commerce/wishlist/use-remove-item'
|
||||||
import type { RemoveItemHook } from '../types/wishlist'
|
import type { RemoveItemHook } from '@vercel/commerce/types/wishlist'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
import useWishlist from './use-wishlist'
|
import useWishlist from './use-wishlist'
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useWishlist, {
|
import useWishlist, {
|
||||||
UseWishlist,
|
type UseWishlist,
|
||||||
} from '@vercel/commerce/wishlist/use-wishlist'
|
} from '@vercel/commerce/wishlist/use-wishlist'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
|
|
||||||
import type { GetWishlistHook } from '../types/wishlist'
|
import type { GetWishlistHook } from '@vercel/commerce/types/wishlist'
|
||||||
|
|
||||||
export default useWishlist as UseWishlist<typeof handler>
|
export default useWishlist as UseWishlist<typeof handler>
|
||||||
export const handler: SWRHook<GetWishlistHook> = {
|
export const handler: SWRHook<GetWishlistHook> = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CartSchema } from '../../types/cart'
|
import type { CartSchema } from '@vercel/commerce/types/cart'
|
||||||
import { CommerceAPIError } from '../utils/errors'
|
import { CommerceAPIError } from '../utils/errors'
|
||||||
import isAllowedOperation from '../utils/is-allowed-operation'
|
import isAllowedOperation from '../utils/is-allowed-operation'
|
||||||
import type { GetAPISchema } from '..'
|
import type { GetAPISchema } from '..'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useHook, useMutationHook } from '../utils/use-hook'
|
import { useHook, useMutationHook } from '../utils/use-hook'
|
||||||
import { mutationFetcher } from '../utils/default-fetcher'
|
import { mutationFetcher } from '../utils/default-fetcher'
|
||||||
import type { HookFetcherFn, MutationHook } from '../utils/types'
|
import type { HookFetcherFn, MutationHook } from '../utils/types'
|
||||||
import type { LogoutHook } from '../types/logout'
|
import type { LogoutHook } from '@vercel/commerce/types/logout'
|
||||||
import type { Provider } from '..'
|
import type { Provider } from '..'
|
||||||
|
|
||||||
export type UseLogout<
|
export type UseLogout<
|
||||||
|
@ -37,7 +37,7 @@ export type CheckoutBody = {
|
|||||||
cartId?: string
|
cartId?: string
|
||||||
/**
|
/**
|
||||||
* The Card information.
|
* The Card information.
|
||||||
* @see @vercel/commerce/types/customer/card/CardFields
|
* @see CardFields
|
||||||
*/
|
*/
|
||||||
card: CardFields
|
card: CardFields
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout'
|
import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout'
|
||||||
import type { CheckoutSchema } from '../../../types/checkout'
|
import type { CheckoutSchema } from '@vercel/commerce/types/checkout'
|
||||||
import type { CommercejsAPI } from '../..'
|
import type { CommercejsAPI } from '../..'
|
||||||
|
|
||||||
import submitCheckout from './submit-checkout'
|
import submitCheckout from './submit-checkout'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
||||||
import type { LoginSchema } from '../../../types/login'
|
import type { LoginSchema } from '@vercel/commerce/types/login'
|
||||||
import type { CommercejsAPI } from '../..'
|
import type { CommercejsAPI } from '../..'
|
||||||
import login from './login'
|
import login from './login'
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { CommercejsConfig } from '..'
|
import type { CommercejsConfig } from '..'
|
||||||
import { GetAllPagesOperation } from '../../types/page'
|
import { GetAllPagesOperation } from '@vercel/commerce/types/page'
|
||||||
|
|
||||||
export type Page = { url: string }
|
export type Page = { url: string }
|
||||||
export type GetAllPagesResult = { pages: Page[] }
|
export type GetAllPagesResult = { pages: Page[] }
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import type { OperationContext } from '@vercel/commerce/api/operations'
|
import type { OperationContext } from '@vercel/commerce/api/operations'
|
||||||
import type {
|
import type { GetAllProductPathsOperation } from '@vercel/commerce/types/product'
|
||||||
GetAllProductPathsOperation,
|
|
||||||
CommercejsProduct,
|
|
||||||
} from '../../types/product'
|
|
||||||
|
|
||||||
import type { CommercejsConfig, Provider } from '..'
|
import type { CommercejsConfig, Provider } from '..'
|
||||||
|
|
||||||
export type GetAllProductPathsResult = {
|
export type GetAllProductPathsResult = {
|
||||||
@ -22,7 +18,7 @@ export default function getAllProductPathsOperation({
|
|||||||
const { data } = await sdkFetch('products', 'list')
|
const { data } = await sdkFetch('products', 'list')
|
||||||
|
|
||||||
// Match a path for every product retrieved
|
// Match a path for every product retrieved
|
||||||
const productPaths = data.map(({ permalink }: CommercejsProduct) => ({
|
const productPaths = data.map(({ permalink }: { permalink: string }) => ({
|
||||||
path: `/${permalink}`,
|
path: `/${permalink}`,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { OperationContext } from '@vercel/commerce/api/operations'
|
import type { OperationContext } from '@vercel/commerce/api/operations'
|
||||||
import type { GetAllProductsOperation } from '../../types/product'
|
import type { GetAllProductsOperation } from '@vercel/commerce/types/product'
|
||||||
import type { CommercejsConfig, Provider } from '../index'
|
import type { CommercejsConfig, Provider } from '../index'
|
||||||
|
|
||||||
import { normalizeProduct } from '../../utils/normalize-product'
|
import { normalizeProduct } from '../../utils/normalize-product'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { GetPageOperation } from '../../types/page'
|
import { GetPageOperation } from '@vercel/commerce/types/page'
|
||||||
|
|
||||||
export type Page = any
|
export type Page = any
|
||||||
export type GetPageResult = { page?: Page }
|
export type GetPageResult = { page?: Page }
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { OperationContext } from '@vercel/commerce/api/operations'
|
import type { OperationContext } from '@vercel/commerce/api/operations'
|
||||||
import type { GetProductOperation } from '../../types/product'
|
import type { GetProductOperation } from '@vercel/commerce/types/product'
|
||||||
import type { CommercejsConfig, Provider } from '../index'
|
import type { CommercejsConfig, Provider } from '../index'
|
||||||
import { normalizeProduct } from '../../utils/normalize-product'
|
import { normalizeProduct } from '../../utils/normalize-product'
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import type { OperationContext } from '@vercel/commerce/api/operations'
|
import type { OperationContext } from '@vercel/commerce/api/operations'
|
||||||
import type { Category, GetSiteInfoOperation } from '../../types/site'
|
import type {
|
||||||
|
Category,
|
||||||
|
GetSiteInfoOperation,
|
||||||
|
} from '@vercel/commerce/types/site'
|
||||||
import { normalizeCategory } from '../../utils/normalize-category'
|
import { normalizeCategory } from '../../utils/normalize-category'
|
||||||
import type { CommercejsConfig, Provider } from '../index'
|
import type { CommercejsConfig, Provider } from '../index'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import type { AddItemHook } from '@vercel/commerce/types/cart'
|
|||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import useAddItem, { UseAddItem } from '@vercel/commerce/cart/use-add-item'
|
import useAddItem, { UseAddItem } from '@vercel/commerce/cart/use-add-item'
|
||||||
import type { CommercejsCart } from '../types/cart'
|
import type { CommercejsCart } from '../types'
|
||||||
import { normalizeCart } from '../utils/normalize-cart'
|
import { normalizeCart } from '../utils/normalize-cart'
|
||||||
import useCart from './use-cart'
|
import useCart from './use-cart'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { useMemo } from 'react'
|
|||||||
import type { GetCartHook } from '@vercel/commerce/types/cart'
|
import type { GetCartHook } from '@vercel/commerce/types/cart'
|
||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useCart, { UseCart } from '@vercel/commerce/cart/use-cart'
|
import useCart, { UseCart } from '@vercel/commerce/cart/use-cart'
|
||||||
import type { CommercejsCart } from '../types/cart'
|
import type { CommercejsCart } from '../types'
|
||||||
import { normalizeCart } from '../utils/normalize-cart'
|
import { normalizeCart } from '../utils/normalize-cart'
|
||||||
|
|
||||||
export default useCart as UseCart<typeof handler>
|
export default useCart as UseCart<typeof handler>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import type { RemoveItemHook } from '@vercel/commerce/types/cart'
|
import type { RemoveItemHook } from '@vercel/commerce/types/cart'
|
||||||
import useRemoveItem, { UseRemoveItem } from '@vercel/commerce/cart/use-remove-item'
|
import useRemoveItem, {
|
||||||
import type { CommercejsCart } from '../types/cart'
|
UseRemoveItem,
|
||||||
|
} from '@vercel/commerce/cart/use-remove-item'
|
||||||
|
import type { CommercejsCart } from '../types'
|
||||||
import { normalizeCart } from '../utils/normalize-cart'
|
import { normalizeCart } from '../utils/normalize-cart'
|
||||||
import useCart from './use-cart'
|
import useCart from './use-cart'
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
import type { UpdateItemHook, LineItem } from '@vercel/commerce/types/cart'
|
import type {
|
||||||
|
UpdateItemHook,
|
||||||
|
LineItem,
|
||||||
|
Cart,
|
||||||
|
} from '@vercel/commerce/types/cart'
|
||||||
import type {
|
import type {
|
||||||
HookFetcherContext,
|
HookFetcherContext,
|
||||||
MutationHookContext,
|
MutationHookContext,
|
||||||
@ -6,8 +10,10 @@ import type {
|
|||||||
import { ValidationError } from '@vercel/commerce/utils/errors'
|
import { ValidationError } from '@vercel/commerce/utils/errors'
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import useUpdateItem, { UseUpdateItem } from '@vercel/commerce/cart/use-update-item'
|
import useUpdateItem, {
|
||||||
import type { CommercejsCart } from '../types/cart'
|
UseUpdateItem,
|
||||||
|
} from '@vercel/commerce/cart/use-update-item'
|
||||||
|
import type { CommercejsCart } from '../types'
|
||||||
import { normalizeCart } from '../utils/normalize-cart'
|
import { normalizeCart } from '../utils/normalize-cart'
|
||||||
import useCart from './use-cart'
|
import useCart from './use-cart'
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import useCustomer, {
|
|||||||
UseCustomer,
|
UseCustomer,
|
||||||
} from '@vercel/commerce/customer/use-customer'
|
} from '@vercel/commerce/customer/use-customer'
|
||||||
import { CUSTOMER_COOKIE, API_URL } from '../constants'
|
import { CUSTOMER_COOKIE, API_URL } from '../constants'
|
||||||
import type { CustomerHook } from '../types/customer'
|
import type { CustomerHook } from '@vercel/commerce/types/customer'
|
||||||
|
|
||||||
export default useCustomer as UseCustomer<typeof handler>
|
export default useCustomer as UseCustomer<typeof handler>
|
||||||
export const handler: SWRHook<CustomerHook> = {
|
export const handler: SWRHook<CustomerHook> = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useSearch, { UseSearch } from '@vercel/commerce/product/use-search'
|
import useSearch, { UseSearch } from '@vercel/commerce/product/use-search'
|
||||||
import { SearchProductsHook } from '@vercel/commerce/types/product'
|
import { SearchProductsHook } from '@vercel/commerce/types/product'
|
||||||
import type { CommercejsProduct } from '../types/product'
|
import type { CommercejsProduct } from '../types'
|
||||||
import { getProductSearchVariables } from '../utils/product-search'
|
import { getProductSearchVariables } from '../utils/product-search'
|
||||||
import { normalizeProduct } from '../utils/normalize-product'
|
import { normalizeProduct } from '../utils/normalize-product'
|
||||||
|
|
||||||
|
6
packages/commercejs/src/types.ts
Normal file
6
packages/commercejs/src/types.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export type { Cart as CommercejsCart } from '@chec/commerce.js/types/cart'
|
||||||
|
export type { LineItem as CommercejsLineItem } from '@chec/commerce.js/types/line-item'
|
||||||
|
export type { CheckoutCapture as CommercejsCheckoutCapture } from '@chec/commerce.js/types/checkout-capture'
|
||||||
|
export type { Product as CommercejsProduct } from '@chec/commerce.js/types/product'
|
||||||
|
export type { Variant as CommercejsVariant } from '@chec/commerce.js/types/variant'
|
||||||
|
export type { Category as CommercejsCategory } from '@chec/commerce.js/types/category'
|
@ -1,4 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/cart'
|
|
||||||
|
|
||||||
export type { Cart as CommercejsCart } from '@chec/commerce.js/types/cart'
|
|
||||||
export type { LineItem as CommercejsLineItem } from '@chec/commerce.js/types/line-item'
|
|
@ -1,3 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/checkout'
|
|
||||||
|
|
||||||
export type { CheckoutCapture as CommercejsCheckoutCapture } from '@chec/commerce.js/types/checkout-capture'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/common'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/customer'
|
|
@ -1,25 +0,0 @@
|
|||||||
import * as Cart from './cart'
|
|
||||||
import * as Checkout from './checkout'
|
|
||||||
import * as Common from './common'
|
|
||||||
import * as Customer from './customer'
|
|
||||||
import * as Login from './login'
|
|
||||||
import * as Logout from './logout'
|
|
||||||
import * as Page from './page'
|
|
||||||
import * as Product from './product'
|
|
||||||
import * as Signup from './signup'
|
|
||||||
import * as Site from './site'
|
|
||||||
import * as Wishlist from './wishlist'
|
|
||||||
|
|
||||||
export type {
|
|
||||||
Cart,
|
|
||||||
Checkout,
|
|
||||||
Common,
|
|
||||||
Customer,
|
|
||||||
Login,
|
|
||||||
Logout,
|
|
||||||
Page,
|
|
||||||
Product,
|
|
||||||
Signup,
|
|
||||||
Site,
|
|
||||||
Wishlist,
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/login'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/page'
|
|
@ -1,4 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/product'
|
|
||||||
|
|
||||||
export type { Product as CommercejsProduct } from '@chec/commerce.js/types/product'
|
|
||||||
export type { Variant as CommercejsVariant } from '@chec/commerce.js/types/variant'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/signup'
|
|
@ -1,3 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/site'
|
|
||||||
|
|
||||||
export type { Category as CommercejsCategory } from '@chec/commerce.js/types/category'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/wishlist'
|
|
@ -1,9 +1,5 @@
|
|||||||
import type {
|
import type { Cart, LineItem } from '@vercel/commerce/types/cart'
|
||||||
Cart,
|
import type { CommercejsCart, CommercejsLineItem } from '../types'
|
||||||
LineItem,
|
|
||||||
CommercejsCart,
|
|
||||||
CommercejsLineItem,
|
|
||||||
} from '../types/cart'
|
|
||||||
|
|
||||||
type CommercejsLineItemType = CommercejsLineItem & { image: { url: string } }
|
type CommercejsLineItemType = CommercejsLineItem & { image: { url: string } }
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { CardFields } from '@vercel/commerce/types/customer/card'
|
import type { CardFields } from '@vercel/commerce/types/customer/card'
|
||||||
import type { AddressFields } from '@vercel/commerce/types/customer/address'
|
import type { AddressFields } from '@vercel/commerce/types/customer/address'
|
||||||
import type { CommercejsCheckoutCapture } from '../types/checkout'
|
import type { CommercejsCheckoutCapture } from '../types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a checkout payload suitable for test checkouts.
|
* Creates a checkout payload suitable for test checkouts.
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import type {
|
import type { Product } from '@vercel/commerce/types/product'
|
||||||
Product,
|
import type { CommercejsProduct, CommercejsVariant } from '../types'
|
||||||
CommercejsProduct,
|
|
||||||
CommercejsVariant,
|
|
||||||
} from '../types/product'
|
|
||||||
|
|
||||||
function getOptionsFromVariantGroups(
|
function getOptionsFromVariantGroups(
|
||||||
variantGroups: CommercejsProduct['variant_groups']
|
variantGroups: CommercejsProduct['variant_groups']
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import customerEndpoint from '@vercel/commerce/api/endpoints/customer'
|
import customerEndpoint from '@vercel/commerce/api/endpoints/customer'
|
||||||
import type { CustomerSchema } from '../../../types/customer'
|
import type { CustomerSchema } from '@vercel/commerce/types/customer'
|
||||||
import type { KiboCommerceAPI } from '../..'
|
import type { KiboCommerceAPI } from '../..'
|
||||||
import getLoggedInCustomer from './customer'
|
import getLoggedInCustomer from './customer'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
import loginEndpoint from '@vercel/commerce/api/endpoints/login'
|
||||||
import type { LoginSchema } from '../../../types/login'
|
import type { LoginSchema } from '@vercel/commerce/types/login'
|
||||||
import type { KiboCommerceAPI } from '../..'
|
import type { KiboCommerceAPI } from '../..'
|
||||||
import login from './login'
|
import login from './login'
|
||||||
|
|
||||||
@ -15,6 +15,4 @@ const loginApi = createEndpoint<LoginAPI>({
|
|||||||
handlers,
|
handlers,
|
||||||
})
|
})
|
||||||
|
|
||||||
export default loginApi;
|
export default loginApi
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import logoutEndpoint from '@vercel/commerce/api/endpoints/logout'
|
import logoutEndpoint from '@vercel/commerce/api/endpoints/logout'
|
||||||
import type { LogoutSchema } from '../../../types/logout'
|
import type { LogoutSchema } from '@vercel/commerce/types/logout'
|
||||||
import type { KiboCommerceAPI } from '../..'
|
import type { KiboCommerceAPI } from '../..'
|
||||||
import logout from './logout'
|
import logout from './logout'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import signupEndpoint from '@vercel/commerce/api/endpoints/signup'
|
import signupEndpoint from '@vercel/commerce/api/endpoints/signup'
|
||||||
import type { SignupSchema } from '../../../types/signup'
|
import type { SignupSchema } from '@vercel/commerce/types/signup'
|
||||||
import type { KiboCommerceAPI } from '../..'
|
import type { KiboCommerceAPI } from '../..'
|
||||||
import signup from './signup'
|
import signup from './signup'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import type { OperationContext } from '@vercel/commerce/api/operations'
|
|||||||
import type { KiboCommerceConfig, KiboCommerceProvider } from '..'
|
import type { KiboCommerceConfig, KiboCommerceProvider } from '..'
|
||||||
import { normalizePage } from '../../lib/normalize'
|
import { normalizePage } from '../../lib/normalize'
|
||||||
import { getPageQuery } from '../queries/get-page-query'
|
import { getPageQuery } from '../queries/get-page-query'
|
||||||
import type { Page, GetPageOperation } from '../../types/page'
|
import type { Page, GetPageOperation } from '@vercel/commerce/types/page'
|
||||||
import type { Document } from '../../../schema'
|
import type { Document } from '../../../schema'
|
||||||
|
|
||||||
export default function getPageOperation({ commerce }: OperationContext<any>) {
|
export default function getPageOperation({ commerce }: OperationContext<any>) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login'
|
import useLogin, { type UseLogin } from '@vercel/commerce/auth/use-login'
|
||||||
|
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import type { LoginHook } from '../types/login'
|
import type { LoginHook } from '@vercel/commerce/types/login'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
import useCart from '../cart/use-cart'
|
import useCart from '../cart/use-cart'
|
||||||
export default useLogin as UseLogin<typeof handler>
|
export default useLogin as UseLogin<typeof handler>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout'
|
import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout'
|
||||||
import type { LogoutHook } from '../types/logout'
|
import type { LogoutHook } from '@vercel/commerce/types/logout'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
import useCart from '../cart/use-cart'
|
import useCart from '../cart/use-cart'
|
||||||
|
|
||||||
@ -12,18 +12,20 @@ export const handler: MutationHook<LogoutHook> = {
|
|||||||
url: '/api/logout',
|
url: '/api/logout',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
useHook: ({ fetch }) => () => {
|
useHook:
|
||||||
const { mutate } = useCustomer()
|
({ fetch }) =>
|
||||||
const { mutate: mutateCart } = useCart()
|
() => {
|
||||||
|
const { mutate } = useCustomer()
|
||||||
|
const { mutate: mutateCart } = useCart()
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
async function logout() {
|
async function logout() {
|
||||||
const data = await fetch()
|
const data = await fetch()
|
||||||
await mutate(null, false)
|
await mutate(null, false)
|
||||||
await mutateCart(null, false)
|
await mutateCart(null, false)
|
||||||
return data
|
return data
|
||||||
},
|
},
|
||||||
[fetch, mutate, mutateCart]
|
[fetch, mutate, mutateCart]
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import type { MutationHook } from '@vercel/commerce/utils/types'
|
import type { MutationHook } from '@vercel/commerce/utils/types'
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup'
|
import useSignup, { type UseSignup } from '@vercel/commerce/auth/use-signup'
|
||||||
import type { SignupHook } from '../types/signup'
|
import type { SignupHook } from '@vercel/commerce/types/signup'
|
||||||
import useCustomer from '../customer/use-customer'
|
import useCustomer from '../customer/use-customer'
|
||||||
|
|
||||||
export default useSignup as UseSignup<typeof handler>
|
export default useSignup as UseSignup<typeof handler>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { SWRHook } from '@vercel/commerce/utils/types'
|
import { SWRHook } from '@vercel/commerce/utils/types'
|
||||||
import useCustomer, { UseCustomer } from '@vercel/commerce/customer/use-customer'
|
import useCustomer, {
|
||||||
import type { CustomerHook } from '../types/customer'
|
type UseCustomer,
|
||||||
|
} from '@vercel/commerce/customer/use-customer'
|
||||||
|
import type { CustomerHook } from '@vercel/commerce/types/customer'
|
||||||
|
|
||||||
export default useCustomer as UseCustomer<typeof handler>
|
export default useCustomer as UseCustomer<typeof handler>
|
||||||
|
|
||||||
@ -13,12 +15,14 @@ export const handler: SWRHook<CustomerHook> = {
|
|||||||
const data = await fetch(options)
|
const data = await fetch(options)
|
||||||
return data?.customer ?? null
|
return data?.customer ?? null
|
||||||
},
|
},
|
||||||
useHook: ({ useData }) => (input) => {
|
useHook:
|
||||||
return useData({
|
({ useData }) =>
|
||||||
swrOptions: {
|
(input) => {
|
||||||
revalidateOnFocus: false,
|
return useData({
|
||||||
...input?.swrOptions,
|
swrOptions: {
|
||||||
},
|
revalidateOnFocus: false,
|
||||||
})
|
...input?.swrOptions,
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import * as Core from '@vercel/commerce/types/customer'
|
|
||||||
export type Maybe<T> = T | null
|
|
||||||
export * from '@vercel/commerce/types/customer'
|
|
||||||
export type Scalars = {
|
|
||||||
ID: string
|
|
||||||
String: string
|
|
||||||
Boolean: boolean
|
|
||||||
Int: number
|
|
||||||
Float: number
|
|
||||||
/** The `AnyScalar` type allows any scalar value by examining the input and passing the serialize, parseValue, and parseLiteral operations to their respective types. */
|
|
||||||
AnyScalar: any
|
|
||||||
/** DateTime custom scalar type */
|
|
||||||
DateTime: any
|
|
||||||
/** Object custom scalar type */
|
|
||||||
Object: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Customer = {
|
|
||||||
id: Scalars['Int'],
|
|
||||||
firstName?: Maybe<Scalars['String']>,
|
|
||||||
lastName?: Maybe<Scalars['String']>,
|
|
||||||
email?: Maybe<Scalars['String']>,
|
|
||||||
userName?: Maybe<Scalars['String']>,
|
|
||||||
isAnonymous?: Maybe<Scalars['Boolean']>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CustomerSchema = Core.CustomerSchema
|
|
@ -1,8 +0,0 @@
|
|||||||
import * as Core from '@vercel/commerce/types/login'
|
|
||||||
import type { CustomerUserAuthInfoInput } from '../../schema'
|
|
||||||
|
|
||||||
export * from '@vercel/commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginOperation = Core.LoginOperation & {
|
|
||||||
variables: CustomerUserAuthInfoInput
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/logout'
|
|
@ -1,16 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/page'
|
|
||||||
|
|
||||||
export type Maybe<T> = T | null
|
|
||||||
export type Scalars = {
|
|
||||||
ID: string
|
|
||||||
String: string
|
|
||||||
Boolean: boolean
|
|
||||||
Int: number
|
|
||||||
Float: number
|
|
||||||
/** The `AnyScalar` type allows any scalar value by examining the input and passing the serialize, parseValue, and parseLiteral operations to their respective types. */
|
|
||||||
AnyScalar: any
|
|
||||||
/** DateTime custom scalar type */
|
|
||||||
DateTime: any
|
|
||||||
/** Object custom scalar type */
|
|
||||||
Object: any
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/signup'
|
|
@ -1,6 +1,6 @@
|
|||||||
import type { CartEndpoint } from '.'
|
import type { CartEndpoint } from '.'
|
||||||
import type { RawVariant } from '../../../types/product'
|
import type { RawVariant } from '../../../types/product'
|
||||||
import type { OrdercloudLineItem } from '../../../types/cart'
|
import type { LineItem } from '@vercel/commerce/types/cart'
|
||||||
|
|
||||||
import { serialize } from 'cookie'
|
import { serialize } from 'cookie'
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ const addItem: CartEndpoint['handlers']['addItem'] = async ({
|
|||||||
restBuyerFetch('GET', `/orders/Outgoing/${cartId}`, null, { token }),
|
restBuyerFetch('GET', `/orders/Outgoing/${cartId}`, null, { token }),
|
||||||
restBuyerFetch('GET', `/orders/Outgoing/${cartId}/lineitems`, null, {
|
restBuyerFetch('GET', `/orders/Outgoing/${cartId}/lineitems`, null, {
|
||||||
token,
|
token,
|
||||||
}).then((response: { Items: OrdercloudLineItem[] }) => response.Items),
|
}).then((response: { Items: LineItem[] }) => response.Items),
|
||||||
])
|
])
|
||||||
|
|
||||||
// Format cart
|
// Format cart
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CartSchema } from '../../../types/cart'
|
import type { CartSchema } from '@vercel/commerce/types/cart'
|
||||||
import type { OrdercloudAPI } from '../..'
|
import type { OrdercloudAPI } from '../..'
|
||||||
|
|
||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CheckoutSchema } from '../../../types/checkout'
|
import type { CheckoutSchema } from '@vercel/commerce/types/checkout'
|
||||||
import type { OrdercloudAPI } from '../..'
|
import type { OrdercloudAPI } from '../..'
|
||||||
|
|
||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CustomerAddressSchema } from '../../../../types/customer/address'
|
import type { CustomerAddressSchema } from '@vercel/commerce/types/customer/address'
|
||||||
import type { OrdercloudAPI } from '../../..'
|
import type { OrdercloudAPI } from '../../..'
|
||||||
|
|
||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CustomerCardSchema } from '../../../../types/customer/card'
|
import type { CustomerCardSchema } from '@vercel/commerce/types/customer/card'
|
||||||
import type { OrdercloudAPI } from '../../..'
|
import type { OrdercloudAPI } from '../../..'
|
||||||
|
|
||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import type { Cart, OrdercloudCart, OrdercloudLineItem } from '../../types/cart'
|
import type { Cart } from '@vercel/commerce/types/cart'
|
||||||
|
import type { OrdercloudCart, OrdercloudLineItem } from '../../types/cart'
|
||||||
|
|
||||||
export function formatCart(
|
export function formatCart(
|
||||||
cart: OrdercloudCart,
|
cart: OrdercloudCart,
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
export * from '@vercel/commerce/types/cart'
|
|
||||||
|
|
||||||
export interface OrdercloudCart {
|
export interface OrdercloudCart {
|
||||||
ID: string
|
ID: string
|
||||||
FromUser: {
|
FromUser: {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export * from '@vercel/commerce/types/checkout'
|
|
@ -1,5 +1,3 @@
|
|||||||
export * from '@vercel/commerce/types/customer/address'
|
|
||||||
|
|
||||||
export interface OrdercloudAddress {
|
export interface OrdercloudAddress {
|
||||||
ID: string
|
ID: string
|
||||||
FromCompanyID: string
|
FromCompanyID: string
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
export * from '@vercel/commerce/types/customer/card'
|
|
||||||
|
|
||||||
export interface OredercloudCreditCard {
|
export interface OredercloudCreditCard {
|
||||||
ID: string
|
ID: string
|
||||||
Editable: boolean
|
Editable: boolean
|
||||||
|
@ -11,7 +11,7 @@ import useCart from './use-cart'
|
|||||||
import * as mutation from '../utils/mutations'
|
import * as mutation from '../utils/mutations'
|
||||||
import { getCheckoutId, checkoutToCart } from '../utils'
|
import { getCheckoutId, checkoutToCart } from '../utils'
|
||||||
import { Mutation, MutationCheckoutLineDeleteArgs } from '../../schema'
|
import { Mutation, MutationCheckoutLineDeleteArgs } from '../../schema'
|
||||||
import { LineItem, RemoveItemHook } from '../types/cart'
|
import type { LineItem, RemoveItemHook } from '@vercel/commerce/types/cart'
|
||||||
|
|
||||||
export default useRemoveItem as UseRemoveItem<typeof handler>
|
export default useRemoveItem as UseRemoveItem<typeof handler>
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user