diff --git a/README.md b/README.md index 0d81bf132..0b752d8c6 100644 --- a/README.md +++ b/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 ```bash -pnpm install # run this command in root folder of the mono repo -pnpm dev +pnpm install & pnpm build # run this commands in root folder of the mono repo +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 @@ -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. 2. Create a new branch `git checkout -b MY_BRANCH_NAME` 3. Install the dependencies: `pnpm install` -4. Duplicate `site/.env.template` and rename it to `site/.env.local` -5. Add proper store values to `site/.env.local` -6. Run `pnpm dev` to build the packages and watch for code changes -7. Run `pnpm turbo run build` to check the build after your changes +4. Build the packages: `pnpm build` +5. Duplicate `site/.env.template` and rename it to `site/.env.local` +6. Add proper store values to `site/.env.local` +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 @@ -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. -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. diff --git a/packages/bigcommerce/src/api/endpoints/cart/get-cart.ts b/packages/bigcommerce/src/api/endpoints/cart/get-cart.ts index cce0b2fca..5b48119ca 100644 --- a/packages/bigcommerce/src/api/endpoints/cart/get-cart.ts +++ b/packages/bigcommerce/src/api/endpoints/cart/get-cart.ts @@ -2,7 +2,7 @@ import { normalizeCart } from '../../../lib/normalize' import { BigcommerceApiError } from '../../utils/errors' import getCartCookie from '../../utils/get-cart-cookie' -import type { BigcommerceCart } from '../../../types/cart' +import type { BigcommerceCart } from '../../../types' import type { CartEndpoint } from '.' // Return current cart info diff --git a/packages/bigcommerce/src/api/endpoints/cart/index.ts b/packages/bigcommerce/src/api/endpoints/cart/index.ts index 376651178..92601e189 100644 --- a/packages/bigcommerce/src/api/endpoints/cart/index.ts +++ b/packages/bigcommerce/src/api/endpoints/cart/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getCart from './get-cart' import addItem from './add-item' diff --git a/packages/bigcommerce/src/api/endpoints/catalog/products/index.ts b/packages/bigcommerce/src/api/endpoints/catalog/products/index.ts index 24472434d..8de51fd93 100644 --- a/packages/bigcommerce/src/api/endpoints/catalog/products/index.ts +++ b/packages/bigcommerce/src/api/endpoints/catalog/products/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getProducts from './get-products' diff --git a/packages/bigcommerce/src/api/endpoints/checkout/index.ts b/packages/bigcommerce/src/api/endpoints/checkout/index.ts index 83bc4ae08..908ba0fd7 100644 --- a/packages/bigcommerce/src/api/endpoints/checkout/index.ts +++ b/packages/bigcommerce/src/api/endpoints/checkout/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getCheckout from './get-checkout' diff --git a/packages/bigcommerce/src/api/endpoints/customer/index.ts b/packages/bigcommerce/src/api/endpoints/customer/index.ts index 5efff392c..c719bc38f 100644 --- a/packages/bigcommerce/src/api/endpoints/customer/index.ts +++ b/packages/bigcommerce/src/api/endpoints/customer/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getLoggedInCustomer from './get-logged-in-customer' diff --git a/packages/bigcommerce/src/api/endpoints/login/index.ts b/packages/bigcommerce/src/api/endpoints/login/index.ts index 1ad6f7102..0a4331b33 100644 --- a/packages/bigcommerce/src/api/endpoints/login/index.ts +++ b/packages/bigcommerce/src/api/endpoints/login/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 login from './login' diff --git a/packages/bigcommerce/src/api/endpoints/logout/index.ts b/packages/bigcommerce/src/api/endpoints/logout/index.ts index 94a246f4b..01893c3d4 100644 --- a/packages/bigcommerce/src/api/endpoints/logout/index.ts +++ b/packages/bigcommerce/src/api/endpoints/logout/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 logout from './logout' diff --git a/packages/bigcommerce/src/api/endpoints/signup/index.ts b/packages/bigcommerce/src/api/endpoints/signup/index.ts index 64521f964..3517826aa 100644 --- a/packages/bigcommerce/src/api/endpoints/signup/index.ts +++ b/packages/bigcommerce/src/api/endpoints/signup/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 signup from './signup' diff --git a/packages/bigcommerce/src/api/endpoints/wishlist/get-wishlist.ts b/packages/bigcommerce/src/api/endpoints/wishlist/get-wishlist.ts index 88c10295a..82f468195 100644 --- a/packages/bigcommerce/src/api/endpoints/wishlist/get-wishlist.ts +++ b/packages/bigcommerce/src/api/endpoints/wishlist/get-wishlist.ts @@ -1,4 +1,4 @@ -import type { Wishlist } from '../../../types/wishlist' +import type { Wishlist } from '@vercel/commerce/types/wishlist' import type { WishlistEndpoint } from '.' import getCustomerId from '../../utils/get-customer-id' diff --git a/packages/bigcommerce/src/api/endpoints/wishlist/index.ts b/packages/bigcommerce/src/api/endpoints/wishlist/index.ts index 87728225d..1a337006d 100644 --- a/packages/bigcommerce/src/api/endpoints/wishlist/index.ts +++ b/packages/bigcommerce/src/api/endpoints/wishlist/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getWishlist from './get-wishlist' import addItem from './add-item' diff --git a/packages/bigcommerce/src/api/endpoints/wishlist/remove-item.ts b/packages/bigcommerce/src/api/endpoints/wishlist/remove-item.ts index 9b19d9b42..17b3f6dec 100644 --- a/packages/bigcommerce/src/api/endpoints/wishlist/remove-item.ts +++ b/packages/bigcommerce/src/api/endpoints/wishlist/remove-item.ts @@ -1,5 +1,4 @@ -import type { Wishlist } from '../../../types/wishlist' -import getCustomerWishlist from '../../operations/get-customer-wishlist' +import type { Wishlist } from '@vercel/commerce/types/wishlist' import getCustomerId from '../../utils/get-customer-id' import type { WishlistEndpoint } from '.' diff --git a/packages/bigcommerce/src/api/operations/get-all-pages.ts b/packages/bigcommerce/src/api/operations/get-all-pages.ts index 51d467743..97575d5b7 100644 --- a/packages/bigcommerce/src/api/operations/get-all-pages.ts +++ b/packages/bigcommerce/src/api/operations/get-all-pages.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } 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 { BigcommerceConfig, Provider } from '..' diff --git a/packages/bigcommerce/src/api/operations/get-all-product-paths.ts b/packages/bigcommerce/src/api/operations/get-all-product-paths.ts index 90cdab6fd..6c56ea692 100644 --- a/packages/bigcommerce/src/api/operations/get-all-product-paths.ts +++ b/packages/bigcommerce/src/api/operations/get-all-product-paths.ts @@ -3,7 +3,7 @@ import type { OperationOptions, } from '@vercel/commerce/api/operations' 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 filterEdges from '../utils/filter-edges' import { BigcommerceConfig, Provider } from '..' diff --git a/packages/bigcommerce/src/api/operations/get-all-products.ts b/packages/bigcommerce/src/api/operations/get-all-products.ts index 2833ffcd7..4ec3baba4 100644 --- a/packages/bigcommerce/src/api/operations/get-all-products.ts +++ b/packages/bigcommerce/src/api/operations/get-all-products.ts @@ -6,7 +6,7 @@ import type { GetAllProductsQuery, GetAllProductsQueryVariables, } from '../../../schema' -import type { GetAllProductsOperation } from '../../types/product' +import type { GetAllProductsOperation } from '@vercel/commerce/types/product' import type { RecursivePartial, RecursiveRequired } from '../utils/types' import filterEdges from '../utils/filter-edges' import setProductLocaleMeta from '../utils/set-product-locale-meta' diff --git a/packages/bigcommerce/src/api/operations/get-customer-wishlist.ts b/packages/bigcommerce/src/api/operations/get-customer-wishlist.ts index 1a1ba38ec..cdfd05acf 100644 --- a/packages/bigcommerce/src/api/operations/get-customer-wishlist.ts +++ b/packages/bigcommerce/src/api/operations/get-customer-wishlist.ts @@ -5,7 +5,7 @@ import type { import type { GetCustomerWishlistOperation, Wishlist, -} from '../../types/wishlist' +} from '@vercel/commerce/types/wishlist' import type { RecursivePartial, RecursiveRequired } from '../utils/types' import { BigcommerceConfig, Provider } from '..' import getAllProducts, { ProductEdge } from './get-all-products' diff --git a/packages/bigcommerce/src/api/operations/get-page.ts b/packages/bigcommerce/src/api/operations/get-page.ts index dc38e5088..4a72c5a29 100644 --- a/packages/bigcommerce/src/api/operations/get-page.ts +++ b/packages/bigcommerce/src/api/operations/get-page.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } 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 { BigcommerceConfig, Provider } from '..' import { normalizePage } from '../../lib/normalize' diff --git a/packages/bigcommerce/src/api/operations/get-product.ts b/packages/bigcommerce/src/api/operations/get-product.ts index 9a5691d82..534d173c7 100644 --- a/packages/bigcommerce/src/api/operations/get-product.ts +++ b/packages/bigcommerce/src/api/operations/get-product.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } 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 setProductLocaleMeta from '../utils/set-product-locale-meta' import { productInfoFragment } from '../fragments/product' diff --git a/packages/bigcommerce/src/api/operations/get-site-info.ts b/packages/bigcommerce/src/api/operations/get-site-info.ts index 5fac64d55..d7bc70355 100644 --- a/packages/bigcommerce/src/api/operations/get-site-info.ts +++ b/packages/bigcommerce/src/api/operations/get-site-info.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } 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 filterEdges from '../utils/filter-edges' import type { BigcommerceConfig, Provider } from '..' diff --git a/packages/bigcommerce/src/api/operations/login.ts b/packages/bigcommerce/src/api/operations/login.ts index f5349998f..4a33741f8 100644 --- a/packages/bigcommerce/src/api/operations/login.ts +++ b/packages/bigcommerce/src/api/operations/login.ts @@ -3,7 +3,7 @@ import type { OperationContext, OperationOptions, } 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 { RecursivePartial } from '../utils/types' import concatHeader from '../utils/concat-cookie' diff --git a/packages/bigcommerce/src/api/utils/parse-item.ts b/packages/bigcommerce/src/api/utils/parse-item.ts index b5060430d..324d13a85 100644 --- a/packages/bigcommerce/src/api/utils/parse-item.ts +++ b/packages/bigcommerce/src/api/utils/parse-item.ts @@ -1,5 +1,5 @@ -import type { WishlistItemBody } from '../../types/wishlist' -import type { CartItemBody, SelectedOption } from '../../types/cart' +import type { WishlistItemBody } from '@vercel/commerce/types/wishlist' +import type { CartItemBody, SelectedOption } from '@vercel/commerce/types/cart' type BCWishlistItemBody = { product_id: number diff --git a/packages/bigcommerce/src/auth/use-login.tsx b/packages/bigcommerce/src/auth/use-login.tsx index a71f15983..103c4ccbf 100644 --- a/packages/bigcommerce/src/auth/use-login.tsx +++ b/packages/bigcommerce/src/auth/use-login.tsx @@ -2,7 +2,7 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' 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' export default useLogin as UseLogin diff --git a/packages/bigcommerce/src/auth/use-logout.tsx b/packages/bigcommerce/src/auth/use-logout.tsx index bc5c3a4c0..ff707abf1 100644 --- a/packages/bigcommerce/src/auth/use-logout.tsx +++ b/packages/bigcommerce/src/auth/use-logout.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' 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' export default useLogout as UseLogout diff --git a/packages/bigcommerce/src/auth/use-signup.tsx b/packages/bigcommerce/src/auth/use-signup.tsx index b06126df6..893b2beb2 100644 --- a/packages/bigcommerce/src/auth/use-signup.tsx +++ b/packages/bigcommerce/src/auth/use-signup.tsx @@ -1,8 +1,8 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' -import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup' -import type { SignupHook } from '../types/signup' +import useSignup, { type UseSignup } from '@vercel/commerce/auth/use-signup' +import type { SignupHook } from '@vercel/commerce/types/signup' import useCustomer from '../customer/use-customer' export default useSignup as UseSignup diff --git a/packages/bigcommerce/src/customer/use-customer.tsx b/packages/bigcommerce/src/customer/use-customer.tsx index 0756377ff..e6b8f4968 100644 --- a/packages/bigcommerce/src/customer/use-customer.tsx +++ b/packages/bigcommerce/src/customer/use-customer.tsx @@ -1,8 +1,8 @@ -import { SWRHook } from '@vercel/commerce/utils/types' +import type { SWRHook } from '@vercel/commerce/utils/types' import useCustomer, { - UseCustomer, + type UseCustomer, } 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 diff --git a/packages/bigcommerce/src/lib/normalize.ts b/packages/bigcommerce/src/lib/normalize.ts index 19a3d467a..1cf20b136 100644 --- a/packages/bigcommerce/src/lib/normalize.ts +++ b/packages/bigcommerce/src/lib/normalize.ts @@ -1,7 +1,8 @@ -import type { Product } from '../types/product' -import type { Cart, BigcommerceCart, LineItem } from '../types/cart' -import type { Page } from '../types/page' -import type { BCCategory, BCBrand, Category, Brand } from '../types/site' +import type { Page } from '@vercel/commerce/types/page' +import type { Product } from '@vercel/commerce/types/product' +import type { Cart, LineItem } from '@vercel/commerce/types/cart' +import type { Category, Brand } from '@vercel/commerce/types/site' +import type { BigcommerceCart, BCCategory, BCBrand } from '../types' import { definitions } from '../api/definitions/store-content' import update from './immutability' diff --git a/packages/bigcommerce/src/product/use-search.tsx b/packages/bigcommerce/src/product/use-search.tsx index fd918e341..9fa275f19 100644 --- a/packages/bigcommerce/src/product/use-search.tsx +++ b/packages/bigcommerce/src/product/use-search.tsx @@ -1,6 +1,6 @@ import { SWRHook } from '@vercel/commerce/utils/types' 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 diff --git a/packages/bigcommerce/src/types/cart.ts b/packages/bigcommerce/src/types.ts similarity index 72% rename from packages/bigcommerce/src/types/cart.ts rename to packages/bigcommerce/src/types.ts index 645adaa66..43b65557c 100644 --- a/packages/bigcommerce/src/types/cart.ts +++ b/packages/bigcommerce/src/types.ts @@ -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[0] +> // TODO: this type should match: // https://developer.bigcommerce.com/api-reference/cart-checkout/server-server-cart-api/cart/getacart#responses diff --git a/packages/bigcommerce/src/types/checkout.ts b/packages/bigcommerce/src/types/checkout.ts deleted file mode 100644 index d139db685..000000000 --- a/packages/bigcommerce/src/types/checkout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/checkout' diff --git a/packages/bigcommerce/src/types/common.ts b/packages/bigcommerce/src/types/common.ts deleted file mode 100644 index 23b8daa11..000000000 --- a/packages/bigcommerce/src/types/common.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/common' diff --git a/packages/bigcommerce/src/types/customer.ts b/packages/bigcommerce/src/types/customer.ts deleted file mode 100644 index c637055b9..000000000 --- a/packages/bigcommerce/src/types/customer.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/customer' diff --git a/packages/bigcommerce/src/types/index.ts b/packages/bigcommerce/src/types/index.ts deleted file mode 100644 index 7ab0b7f64..000000000 --- a/packages/bigcommerce/src/types/index.ts +++ /dev/null @@ -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, -} diff --git a/packages/bigcommerce/src/types/login.ts b/packages/bigcommerce/src/types/login.ts deleted file mode 100644 index 438d541b2..000000000 --- a/packages/bigcommerce/src/types/login.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/login' diff --git a/packages/bigcommerce/src/types/logout.ts b/packages/bigcommerce/src/types/logout.ts deleted file mode 100644 index 1de06f8dc..000000000 --- a/packages/bigcommerce/src/types/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/logout' diff --git a/packages/bigcommerce/src/types/page.ts b/packages/bigcommerce/src/types/page.ts deleted file mode 100644 index 12f6b02d7..000000000 --- a/packages/bigcommerce/src/types/page.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/page' diff --git a/packages/bigcommerce/src/types/product.ts b/packages/bigcommerce/src/types/product.ts deleted file mode 100644 index 72ca02f02..000000000 --- a/packages/bigcommerce/src/types/product.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/product' diff --git a/packages/bigcommerce/src/types/signup.ts b/packages/bigcommerce/src/types/signup.ts deleted file mode 100644 index 3f0d1af5a..000000000 --- a/packages/bigcommerce/src/types/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/signup' diff --git a/packages/bigcommerce/src/types/site.ts b/packages/bigcommerce/src/types/site.ts deleted file mode 100644 index 80f9d7e1f..000000000 --- a/packages/bigcommerce/src/types/site.ts +++ /dev/null @@ -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[0] -> diff --git a/packages/bigcommerce/src/types/wishlist.ts b/packages/bigcommerce/src/types/wishlist.ts deleted file mode 100644 index af92d9f63..000000000 --- a/packages/bigcommerce/src/types/wishlist.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/wishlist' diff --git a/packages/bigcommerce/src/wishlist/use-add-item.tsx b/packages/bigcommerce/src/wishlist/use-add-item.tsx index c9e237b0b..ba12eabf8 100644 --- a/packages/bigcommerce/src/wishlist/use-add-item.tsx +++ b/packages/bigcommerce/src/wishlist/use-add-item.tsx @@ -1,8 +1,10 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' -import useAddItem, { UseAddItem } from '@vercel/commerce/wishlist/use-add-item' -import type { AddItemHook } from '../types/wishlist' +import useAddItem, { + type UseAddItem, +} from '@vercel/commerce/wishlist/use-add-item' +import type { AddItemHook } from '@vercel/commerce/types/wishlist' import useCustomer from '../customer/use-customer' import useWishlist from './use-wishlist' diff --git a/packages/bigcommerce/src/wishlist/use-remove-item.tsx b/packages/bigcommerce/src/wishlist/use-remove-item.tsx index 40ca0da04..63cca503d 100644 --- a/packages/bigcommerce/src/wishlist/use-remove-item.tsx +++ b/packages/bigcommerce/src/wishlist/use-remove-item.tsx @@ -2,9 +2,9 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' import useRemoveItem, { - UseRemoveItem, + type UseRemoveItem, } 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 useWishlist from './use-wishlist' diff --git a/packages/bigcommerce/src/wishlist/use-wishlist.tsx b/packages/bigcommerce/src/wishlist/use-wishlist.tsx index f11a75ec0..058b03c8c 100644 --- a/packages/bigcommerce/src/wishlist/use-wishlist.tsx +++ b/packages/bigcommerce/src/wishlist/use-wishlist.tsx @@ -1,11 +1,11 @@ import { useMemo } from 'react' import { SWRHook } from '@vercel/commerce/utils/types' import useWishlist, { - UseWishlist, + type UseWishlist, } from '@vercel/commerce/wishlist/use-wishlist' 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 export const handler: SWRHook = { diff --git a/packages/commerce/src/api/endpoints/cart.ts b/packages/commerce/src/api/endpoints/cart.ts index e5a05dbd6..2964e26c2 100644 --- a/packages/commerce/src/api/endpoints/cart.ts +++ b/packages/commerce/src/api/endpoints/cart.ts @@ -1,4 +1,4 @@ -import type { CartSchema } from '../../types/cart' +import type { CartSchema } from '@vercel/commerce/types/cart' import { CommerceAPIError } from '../utils/errors' import isAllowedOperation from '../utils/is-allowed-operation' import type { GetAPISchema } from '..' diff --git a/packages/commerce/src/auth/use-logout.tsx b/packages/commerce/src/auth/use-logout.tsx index f8eaeb60d..7596b700a 100644 --- a/packages/commerce/src/auth/use-logout.tsx +++ b/packages/commerce/src/auth/use-logout.tsx @@ -1,7 +1,7 @@ import { useHook, useMutationHook } from '../utils/use-hook' import { mutationFetcher } from '../utils/default-fetcher' 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 '..' export type UseLogout< diff --git a/packages/commerce/src/types/checkout.ts b/packages/commerce/src/types/checkout.ts index 6c5d41212..a1ce6937c 100644 --- a/packages/commerce/src/types/checkout.ts +++ b/packages/commerce/src/types/checkout.ts @@ -37,7 +37,7 @@ export type CheckoutBody = { cartId?: string /** * The Card information. - * @see @vercel/commerce/types/customer/card/CardFields + * @see CardFields */ card: CardFields /** diff --git a/packages/commercejs/src/api/endpoints/checkout/index.ts b/packages/commercejs/src/api/endpoints/checkout/index.ts index 1072902e6..6a4eb4864 100644 --- a/packages/commercejs/src/api/endpoints/checkout/index.ts +++ b/packages/commercejs/src/api/endpoints/checkout/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 submitCheckout from './submit-checkout' diff --git a/packages/commercejs/src/api/endpoints/login/index.ts b/packages/commercejs/src/api/endpoints/login/index.ts index a6dbb4432..a47d8e63f 100644 --- a/packages/commercejs/src/api/endpoints/login/index.ts +++ b/packages/commercejs/src/api/endpoints/login/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 login from './login' diff --git a/packages/commercejs/src/api/operations/get-all-pages.ts b/packages/commercejs/src/api/operations/get-all-pages.ts index c8c9e41b2..ae6e6c004 100644 --- a/packages/commercejs/src/api/operations/get-all-pages.ts +++ b/packages/commercejs/src/api/operations/get-all-pages.ts @@ -1,5 +1,5 @@ import type { CommercejsConfig } from '..' -import { GetAllPagesOperation } from '../../types/page' +import { GetAllPagesOperation } from '@vercel/commerce/types/page' export type Page = { url: string } export type GetAllPagesResult = { pages: Page[] } diff --git a/packages/commercejs/src/api/operations/get-all-product-paths.ts b/packages/commercejs/src/api/operations/get-all-product-paths.ts index 03b7eee96..2d81e9ad6 100644 --- a/packages/commercejs/src/api/operations/get-all-product-paths.ts +++ b/packages/commercejs/src/api/operations/get-all-product-paths.ts @@ -1,9 +1,5 @@ import type { OperationContext } from '@vercel/commerce/api/operations' -import type { - GetAllProductPathsOperation, - CommercejsProduct, -} from '../../types/product' - +import type { GetAllProductPathsOperation } from '@vercel/commerce/types/product' import type { CommercejsConfig, Provider } from '..' export type GetAllProductPathsResult = { @@ -22,7 +18,7 @@ export default function getAllProductPathsOperation({ const { data } = await sdkFetch('products', 'list') // Match a path for every product retrieved - const productPaths = data.map(({ permalink }: CommercejsProduct) => ({ + const productPaths = data.map(({ permalink }: { permalink: string }) => ({ path: `/${permalink}`, })) diff --git a/packages/commercejs/src/api/operations/get-all-products.ts b/packages/commercejs/src/api/operations/get-all-products.ts index 485ea22ee..244a590b8 100644 --- a/packages/commercejs/src/api/operations/get-all-products.ts +++ b/packages/commercejs/src/api/operations/get-all-products.ts @@ -1,5 +1,5 @@ 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 { normalizeProduct } from '../../utils/normalize-product' diff --git a/packages/commercejs/src/api/operations/get-page.ts b/packages/commercejs/src/api/operations/get-page.ts index f4b69c90d..e403d1660 100644 --- a/packages/commercejs/src/api/operations/get-page.ts +++ b/packages/commercejs/src/api/operations/get-page.ts @@ -1,4 +1,4 @@ -import { GetPageOperation } from '../../types/page' +import { GetPageOperation } from '@vercel/commerce/types/page' export type Page = any export type GetPageResult = { page?: Page } diff --git a/packages/commercejs/src/api/operations/get-product.ts b/packages/commercejs/src/api/operations/get-product.ts index c8fa5901b..7f11310f9 100644 --- a/packages/commercejs/src/api/operations/get-product.ts +++ b/packages/commercejs/src/api/operations/get-product.ts @@ -1,5 +1,5 @@ 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 { normalizeProduct } from '../../utils/normalize-product' diff --git a/packages/commercejs/src/api/operations/get-site-info.ts b/packages/commercejs/src/api/operations/get-site-info.ts index 0b4046d7c..3b768e611 100644 --- a/packages/commercejs/src/api/operations/get-site-info.ts +++ b/packages/commercejs/src/api/operations/get-site-info.ts @@ -1,5 +1,8 @@ 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 type { CommercejsConfig, Provider } from '../index' diff --git a/packages/commercejs/src/cart/use-add-item.tsx b/packages/commercejs/src/cart/use-add-item.tsx index 3bbad1147..b8fb8cb1c 100644 --- a/packages/commercejs/src/cart/use-add-item.tsx +++ b/packages/commercejs/src/cart/use-add-item.tsx @@ -2,7 +2,7 @@ import type { AddItemHook } from '@vercel/commerce/types/cart' import type { MutationHook } from '@vercel/commerce/utils/types' import { useCallback } from 'react' 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 useCart from './use-cart' diff --git a/packages/commercejs/src/cart/use-cart.tsx b/packages/commercejs/src/cart/use-cart.tsx index 57592ec37..7938c27f9 100644 --- a/packages/commercejs/src/cart/use-cart.tsx +++ b/packages/commercejs/src/cart/use-cart.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react' import type { GetCartHook } from '@vercel/commerce/types/cart' import { SWRHook } from '@vercel/commerce/utils/types' 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' export default useCart as UseCart diff --git a/packages/commercejs/src/cart/use-remove-item.tsx b/packages/commercejs/src/cart/use-remove-item.tsx index c9e57872d..c06ac6d78 100644 --- a/packages/commercejs/src/cart/use-remove-item.tsx +++ b/packages/commercejs/src/cart/use-remove-item.tsx @@ -1,8 +1,10 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import type { RemoveItemHook } from '@vercel/commerce/types/cart' -import useRemoveItem, { UseRemoveItem } from '@vercel/commerce/cart/use-remove-item' -import type { CommercejsCart } from '../types/cart' +import useRemoveItem, { + UseRemoveItem, +} from '@vercel/commerce/cart/use-remove-item' +import type { CommercejsCart } from '../types' import { normalizeCart } from '../utils/normalize-cart' import useCart from './use-cart' diff --git a/packages/commercejs/src/cart/use-update-item.tsx b/packages/commercejs/src/cart/use-update-item.tsx index 1546be036..d9c38c60b 100644 --- a/packages/commercejs/src/cart/use-update-item.tsx +++ b/packages/commercejs/src/cart/use-update-item.tsx @@ -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 { HookFetcherContext, MutationHookContext, @@ -6,8 +10,10 @@ import type { import { ValidationError } from '@vercel/commerce/utils/errors' import debounce from 'lodash.debounce' import { useCallback } from 'react' -import useUpdateItem, { UseUpdateItem } from '@vercel/commerce/cart/use-update-item' -import type { CommercejsCart } from '../types/cart' +import useUpdateItem, { + UseUpdateItem, +} from '@vercel/commerce/cart/use-update-item' +import type { CommercejsCart } from '../types' import { normalizeCart } from '../utils/normalize-cart' import useCart from './use-cart' diff --git a/packages/commercejs/src/customer/use-customer.tsx b/packages/commercejs/src/customer/use-customer.tsx index b121b0974..57d8f702b 100644 --- a/packages/commercejs/src/customer/use-customer.tsx +++ b/packages/commercejs/src/customer/use-customer.tsx @@ -5,7 +5,7 @@ import useCustomer, { UseCustomer, } from '@vercel/commerce/customer/use-customer' 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 export const handler: SWRHook = { diff --git a/packages/commercejs/src/product/use-search.tsx b/packages/commercejs/src/product/use-search.tsx index ec8ad618f..4b43d5aa0 100644 --- a/packages/commercejs/src/product/use-search.tsx +++ b/packages/commercejs/src/product/use-search.tsx @@ -1,7 +1,7 @@ import { SWRHook } from '@vercel/commerce/utils/types' import useSearch, { UseSearch } from '@vercel/commerce/product/use-search' 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 { normalizeProduct } from '../utils/normalize-product' diff --git a/packages/commercejs/src/types.ts b/packages/commercejs/src/types.ts new file mode 100644 index 000000000..c041acc0d --- /dev/null +++ b/packages/commercejs/src/types.ts @@ -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' diff --git a/packages/commercejs/src/types/cart.ts b/packages/commercejs/src/types/cart.ts deleted file mode 100644 index 9de68397b..000000000 --- a/packages/commercejs/src/types/cart.ts +++ /dev/null @@ -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' diff --git a/packages/commercejs/src/types/checkout.ts b/packages/commercejs/src/types/checkout.ts deleted file mode 100644 index 970d5cfad..000000000 --- a/packages/commercejs/src/types/checkout.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '@vercel/commerce/types/checkout' - -export type { CheckoutCapture as CommercejsCheckoutCapture } from '@chec/commerce.js/types/checkout-capture' diff --git a/packages/commercejs/src/types/common.ts b/packages/commercejs/src/types/common.ts deleted file mode 100644 index 23b8daa11..000000000 --- a/packages/commercejs/src/types/common.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/common' diff --git a/packages/commercejs/src/types/customer.ts b/packages/commercejs/src/types/customer.ts deleted file mode 100644 index c637055b9..000000000 --- a/packages/commercejs/src/types/customer.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/customer' diff --git a/packages/commercejs/src/types/index.ts b/packages/commercejs/src/types/index.ts deleted file mode 100644 index 7ab0b7f64..000000000 --- a/packages/commercejs/src/types/index.ts +++ /dev/null @@ -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, -} diff --git a/packages/commercejs/src/types/login.ts b/packages/commercejs/src/types/login.ts deleted file mode 100644 index 438d541b2..000000000 --- a/packages/commercejs/src/types/login.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/login' diff --git a/packages/commercejs/src/types/logout.ts b/packages/commercejs/src/types/logout.ts deleted file mode 100644 index 1de06f8dc..000000000 --- a/packages/commercejs/src/types/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/logout' diff --git a/packages/commercejs/src/types/page.ts b/packages/commercejs/src/types/page.ts deleted file mode 100644 index 12f6b02d7..000000000 --- a/packages/commercejs/src/types/page.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/page' diff --git a/packages/commercejs/src/types/product.ts b/packages/commercejs/src/types/product.ts deleted file mode 100644 index 7cdab703e..000000000 --- a/packages/commercejs/src/types/product.ts +++ /dev/null @@ -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' diff --git a/packages/commercejs/src/types/signup.ts b/packages/commercejs/src/types/signup.ts deleted file mode 100644 index 3f0d1af5a..000000000 --- a/packages/commercejs/src/types/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/signup' diff --git a/packages/commercejs/src/types/site.ts b/packages/commercejs/src/types/site.ts deleted file mode 100644 index 346278b43..000000000 --- a/packages/commercejs/src/types/site.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '@vercel/commerce/types/site' - -export type { Category as CommercejsCategory } from '@chec/commerce.js/types/category' diff --git a/packages/commercejs/src/types/wishlist.ts b/packages/commercejs/src/types/wishlist.ts deleted file mode 100644 index af92d9f63..000000000 --- a/packages/commercejs/src/types/wishlist.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/wishlist' diff --git a/packages/commercejs/src/utils/normalize-cart.ts b/packages/commercejs/src/utils/normalize-cart.ts index c01ea6dea..6bb7334be 100644 --- a/packages/commercejs/src/utils/normalize-cart.ts +++ b/packages/commercejs/src/utils/normalize-cart.ts @@ -1,9 +1,5 @@ -import type { - Cart, - LineItem, - CommercejsCart, - CommercejsLineItem, -} from '../types/cart' +import type { Cart, LineItem } from '@vercel/commerce/types/cart' +import type { CommercejsCart, CommercejsLineItem } from '../types' type CommercejsLineItemType = CommercejsLineItem & { image: { url: string } } diff --git a/packages/commercejs/src/utils/normalize-checkout.ts b/packages/commercejs/src/utils/normalize-checkout.ts index db136e0b8..5120bee2e 100644 --- a/packages/commercejs/src/utils/normalize-checkout.ts +++ b/packages/commercejs/src/utils/normalize-checkout.ts @@ -1,6 +1,6 @@ import type { CardFields } from '@vercel/commerce/types/customer/card' 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. diff --git a/packages/commercejs/src/utils/normalize-product.ts b/packages/commercejs/src/utils/normalize-product.ts index 2c8a5654a..2bd45921f 100644 --- a/packages/commercejs/src/utils/normalize-product.ts +++ b/packages/commercejs/src/utils/normalize-product.ts @@ -1,8 +1,5 @@ -import type { - Product, - CommercejsProduct, - CommercejsVariant, -} from '../types/product' +import type { Product } from '@vercel/commerce/types/product' +import type { CommercejsProduct, CommercejsVariant } from '../types' function getOptionsFromVariantGroups( variantGroups: CommercejsProduct['variant_groups'] diff --git a/packages/kibocommerce/src/api/endpoints/customer/index.ts b/packages/kibocommerce/src/api/endpoints/customer/index.ts index 20bd44da9..a329f66b8 100644 --- a/packages/kibocommerce/src/api/endpoints/customer/index.ts +++ b/packages/kibocommerce/src/api/endpoints/customer/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 getLoggedInCustomer from './customer' diff --git a/packages/kibocommerce/src/api/endpoints/login/index.ts b/packages/kibocommerce/src/api/endpoints/login/index.ts index 679a92d90..73e89ebdd 100644 --- a/packages/kibocommerce/src/api/endpoints/login/index.ts +++ b/packages/kibocommerce/src/api/endpoints/login/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 login from './login' @@ -15,6 +15,4 @@ const loginApi = createEndpoint({ handlers, }) -export default loginApi; - - +export default loginApi diff --git a/packages/kibocommerce/src/api/endpoints/logout/index.ts b/packages/kibocommerce/src/api/endpoints/logout/index.ts index 00804afb3..55f68fcbf 100644 --- a/packages/kibocommerce/src/api/endpoints/logout/index.ts +++ b/packages/kibocommerce/src/api/endpoints/logout/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 logout from './logout' diff --git a/packages/kibocommerce/src/api/endpoints/signup/index.ts b/packages/kibocommerce/src/api/endpoints/signup/index.ts index 8b2fec006..4b9bd9a0e 100644 --- a/packages/kibocommerce/src/api/endpoints/signup/index.ts +++ b/packages/kibocommerce/src/api/endpoints/signup/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' 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 signup from './signup' diff --git a/packages/kibocommerce/src/api/operations/get-page.ts b/packages/kibocommerce/src/api/operations/get-page.ts index 4bc984de2..aed8e02c1 100644 --- a/packages/kibocommerce/src/api/operations/get-page.ts +++ b/packages/kibocommerce/src/api/operations/get-page.ts @@ -2,7 +2,7 @@ import type { OperationContext } from '@vercel/commerce/api/operations' import type { KiboCommerceConfig, KiboCommerceProvider } from '..' import { normalizePage } from '../../lib/normalize' 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' export default function getPageOperation({ commerce }: OperationContext) { diff --git a/packages/kibocommerce/src/auth/use-login.tsx b/packages/kibocommerce/src/auth/use-login.tsx index c9d1fac17..324c9d3fe 100644 --- a/packages/kibocommerce/src/auth/use-login.tsx +++ b/packages/kibocommerce/src/auth/use-login.tsx @@ -1,9 +1,9 @@ -import { MutationHook } from '@vercel/commerce/utils/types' -import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login' +import type { MutationHook } from '@vercel/commerce/utils/types' +import useLogin, { type UseLogin } from '@vercel/commerce/auth/use-login' import { useCallback } from 'react' 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 useCart from '../cart/use-cart' export default useLogin as UseLogin diff --git a/packages/kibocommerce/src/auth/use-logout.tsx b/packages/kibocommerce/src/auth/use-logout.tsx index 83e5a4b0c..ee6c78de7 100644 --- a/packages/kibocommerce/src/auth/use-logout.tsx +++ b/packages/kibocommerce/src/auth/use-logout.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' 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 useCart from '../cart/use-cart' @@ -12,18 +12,20 @@ export const handler: MutationHook = { url: '/api/logout', method: 'GET', }, - useHook: ({ fetch }) => () => { - const { mutate } = useCustomer() - const { mutate: mutateCart } = useCart() + useHook: + ({ fetch }) => + () => { + const { mutate } = useCustomer() + const { mutate: mutateCart } = useCart() - return useCallback( - async function logout() { - const data = await fetch() - await mutate(null, false) - await mutateCart(null, false) - return data - }, - [fetch, mutate, mutateCart] - ) - }, + return useCallback( + async function logout() { + const data = await fetch() + await mutate(null, false) + await mutateCart(null, false) + return data + }, + [fetch, mutate, mutateCart] + ) + }, } diff --git a/packages/kibocommerce/src/auth/use-signup.tsx b/packages/kibocommerce/src/auth/use-signup.tsx index b06126df6..893b2beb2 100644 --- a/packages/kibocommerce/src/auth/use-signup.tsx +++ b/packages/kibocommerce/src/auth/use-signup.tsx @@ -1,8 +1,8 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' -import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup' -import type { SignupHook } from '../types/signup' +import useSignup, { type UseSignup } from '@vercel/commerce/auth/use-signup' +import type { SignupHook } from '@vercel/commerce/types/signup' import useCustomer from '../customer/use-customer' export default useSignup as UseSignup diff --git a/packages/kibocommerce/src/customer/use-customer.tsx b/packages/kibocommerce/src/customer/use-customer.tsx index 73e804a4b..be13e6cfa 100644 --- a/packages/kibocommerce/src/customer/use-customer.tsx +++ b/packages/kibocommerce/src/customer/use-customer.tsx @@ -1,6 +1,8 @@ import { SWRHook } from '@vercel/commerce/utils/types' -import useCustomer, { UseCustomer } from '@vercel/commerce/customer/use-customer' -import type { CustomerHook } from '../types/customer' +import useCustomer, { + type UseCustomer, +} from '@vercel/commerce/customer/use-customer' +import type { CustomerHook } from '@vercel/commerce/types/customer' export default useCustomer as UseCustomer @@ -13,12 +15,14 @@ export const handler: SWRHook = { const data = await fetch(options) return data?.customer ?? null }, - useHook: ({ useData }) => (input) => { - return useData({ - swrOptions: { - revalidateOnFocus: false, - ...input?.swrOptions, - }, - }) - }, + useHook: + ({ useData }) => + (input) => { + return useData({ + swrOptions: { + revalidateOnFocus: false, + ...input?.swrOptions, + }, + }) + }, } diff --git a/packages/kibocommerce/src/types/customer.ts b/packages/kibocommerce/src/types/customer.ts deleted file mode 100644 index 29f68fef1..000000000 --- a/packages/kibocommerce/src/types/customer.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as Core from '@vercel/commerce/types/customer' -export type Maybe = 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, - lastName?: Maybe, - email?: Maybe, - userName?: Maybe, - isAnonymous?: Maybe -} - -export type CustomerSchema = Core.CustomerSchema diff --git a/packages/kibocommerce/src/types/login.ts b/packages/kibocommerce/src/types/login.ts deleted file mode 100644 index 2e7b198b2..000000000 --- a/packages/kibocommerce/src/types/login.ts +++ /dev/null @@ -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 -} diff --git a/packages/kibocommerce/src/types/logout.ts b/packages/kibocommerce/src/types/logout.ts deleted file mode 100644 index 1de06f8dc..000000000 --- a/packages/kibocommerce/src/types/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/logout' diff --git a/packages/kibocommerce/src/types/page.ts b/packages/kibocommerce/src/types/page.ts deleted file mode 100644 index 158716bc1..000000000 --- a/packages/kibocommerce/src/types/page.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from '@vercel/commerce/types/page' - -export type Maybe = 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 -} diff --git a/packages/kibocommerce/src/types/signup.ts b/packages/kibocommerce/src/types/signup.ts deleted file mode 100644 index 3f0d1af5a..000000000 --- a/packages/kibocommerce/src/types/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/signup' diff --git a/packages/ordercloud/src/api/endpoints/cart/add-item.ts b/packages/ordercloud/src/api/endpoints/cart/add-item.ts index 28d372bd0..8894d921d 100644 --- a/packages/ordercloud/src/api/endpoints/cart/add-item.ts +++ b/packages/ordercloud/src/api/endpoints/cart/add-item.ts @@ -1,6 +1,6 @@ import type { CartEndpoint } from '.' import type { RawVariant } from '../../../types/product' -import type { OrdercloudLineItem } from '../../../types/cart' +import type { LineItem } from '@vercel/commerce/types/cart' 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}/lineitems`, null, { token, - }).then((response: { Items: OrdercloudLineItem[] }) => response.Items), + }).then((response: { Items: LineItem[] }) => response.Items), ]) // Format cart diff --git a/packages/ordercloud/src/api/endpoints/cart/index.ts b/packages/ordercloud/src/api/endpoints/cart/index.ts index f36364c46..e458964f9 100644 --- a/packages/ordercloud/src/api/endpoints/cart/index.ts +++ b/packages/ordercloud/src/api/endpoints/cart/index.ts @@ -1,4 +1,4 @@ -import type { CartSchema } from '../../../types/cart' +import type { CartSchema } from '@vercel/commerce/types/cart' import type { OrdercloudAPI } from '../..' import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' diff --git a/packages/ordercloud/src/api/endpoints/checkout/index.ts b/packages/ordercloud/src/api/endpoints/checkout/index.ts index 44a9a6933..49f10361a 100644 --- a/packages/ordercloud/src/api/endpoints/checkout/index.ts +++ b/packages/ordercloud/src/api/endpoints/checkout/index.ts @@ -1,4 +1,4 @@ -import type { CheckoutSchema } from '../../../types/checkout' +import type { CheckoutSchema } from '@vercel/commerce/types/checkout' import type { OrdercloudAPI } from '../..' import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' diff --git a/packages/ordercloud/src/api/endpoints/customer/address/index.ts b/packages/ordercloud/src/api/endpoints/customer/address/index.ts index f6ab7e306..34e80c8dd 100644 --- a/packages/ordercloud/src/api/endpoints/customer/address/index.ts +++ b/packages/ordercloud/src/api/endpoints/customer/address/index.ts @@ -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 { GetAPISchema, createEndpoint } from '@vercel/commerce/api' diff --git a/packages/ordercloud/src/api/endpoints/customer/card/index.ts b/packages/ordercloud/src/api/endpoints/customer/card/index.ts index 7116e3cb5..302009a89 100644 --- a/packages/ordercloud/src/api/endpoints/customer/card/index.ts +++ b/packages/ordercloud/src/api/endpoints/customer/card/index.ts @@ -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 { GetAPISchema, createEndpoint } from '@vercel/commerce/api' diff --git a/packages/ordercloud/src/api/utils/cart.ts b/packages/ordercloud/src/api/utils/cart.ts index 716f3521e..fd0c79bf3 100644 --- a/packages/ordercloud/src/api/utils/cart.ts +++ b/packages/ordercloud/src/api/utils/cart.ts @@ -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( cart: OrdercloudCart, diff --git a/packages/ordercloud/src/types/cart.ts b/packages/ordercloud/src/types/cart.ts index 4f89aacad..1fbeb09b5 100644 --- a/packages/ordercloud/src/types/cart.ts +++ b/packages/ordercloud/src/types/cart.ts @@ -1,5 +1,3 @@ -export * from '@vercel/commerce/types/cart' - export interface OrdercloudCart { ID: string FromUser: { diff --git a/packages/ordercloud/src/types/checkout.ts b/packages/ordercloud/src/types/checkout.ts deleted file mode 100644 index d139db685..000000000 --- a/packages/ordercloud/src/types/checkout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/checkout' diff --git a/packages/ordercloud/src/types/customer/address.ts b/packages/ordercloud/src/types/customer/address.ts index bf5148353..ec7e5d74e 100644 --- a/packages/ordercloud/src/types/customer/address.ts +++ b/packages/ordercloud/src/types/customer/address.ts @@ -1,5 +1,3 @@ -export * from '@vercel/commerce/types/customer/address' - export interface OrdercloudAddress { ID: string FromCompanyID: string diff --git a/packages/ordercloud/src/types/customer/card.ts b/packages/ordercloud/src/types/customer/card.ts index ade1adb91..8b4851cdb 100644 --- a/packages/ordercloud/src/types/customer/card.ts +++ b/packages/ordercloud/src/types/customer/card.ts @@ -1,5 +1,3 @@ -export * from '@vercel/commerce/types/customer/card' - export interface OredercloudCreditCard { ID: string Editable: boolean diff --git a/packages/saleor/src/cart/use-remove-item.tsx b/packages/saleor/src/cart/use-remove-item.tsx index b3969aeb8..f3972c49b 100644 --- a/packages/saleor/src/cart/use-remove-item.tsx +++ b/packages/saleor/src/cart/use-remove-item.tsx @@ -11,7 +11,7 @@ import useCart from './use-cart' import * as mutation from '../utils/mutations' import { getCheckoutId, checkoutToCart } from '../utils' 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 diff --git a/packages/saleor/src/cart/use-update-item.tsx b/packages/saleor/src/cart/use-update-item.tsx index ffca9b2f8..6fc6d2b10 100644 --- a/packages/saleor/src/cart/use-update-item.tsx +++ b/packages/saleor/src/cart/use-update-item.tsx @@ -1,19 +1,23 @@ import { useCallback } from 'react' import debounce from 'lodash.debounce' -import type { HookFetcherContext, MutationHookContext } from '@vercel/commerce/utils/types' +import type { + HookFetcherContext, + MutationHookContext, +} from '@vercel/commerce/utils/types' import { ValidationError } from '@vercel/commerce/utils/errors' -import useUpdateItem, { UseUpdateItem } from '@vercel/commerce/cart/use-update-item' +import useUpdateItem, { + UseUpdateItem, +} from '@vercel/commerce/cart/use-update-item' import useCart from './use-cart' import { handler as removeItemHandler } from './use-remove-item' -import type { LineItem } from '../types' import { checkoutToCart } from '../utils' import { getCheckoutId } from '../utils' -import { Mutation, MutationCheckoutLinesUpdateArgs } from '../../schema' import * as mutation from '../utils/mutations' -import type { UpdateItemHook } from '../types/cart' +import type { UpdateItemHook, LineItem } from '@vercel/commerce/types/cart' +import type { Mutation, MutationCheckoutLinesUpdateArgs } from '../../schema' export type UpdateItemActionInput = T extends LineItem ? Partial @@ -23,7 +27,11 @@ export default useUpdateItem as UseUpdateItem export const handler = { fetchOptions: { query: mutation.CheckoutLineUpdate }, - async fetcher({ input: { itemId, item }, options, fetch }: HookFetcherContext) { + async fetcher({ + input: { itemId, item }, + options, + fetch, + }: HookFetcherContext) { if (Number.isInteger(item.quantity)) { // Also allow the update hook to remove an item if the quantity is lower than 1 if (item.quantity! < 1) { @@ -40,7 +48,10 @@ export const handler = { } const checkoutId = getCheckoutId().checkoutId - const { checkoutLinesUpdate } = await fetch({ + const { checkoutLinesUpdate } = await fetch< + Mutation, + MutationCheckoutLinesUpdateArgs + >({ ...options, variables: { checkoutId, diff --git a/packages/saleor/src/types/cart.ts b/packages/saleor/src/types/cart.ts deleted file mode 100644 index 5774033e1..000000000 --- a/packages/saleor/src/types/cart.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as Core from '@vercel/commerce/types/cart' - -export * from '@vercel/commerce/types/cart' - -export type SaleorCart = {} - -/** - * Extend core cart types - */ - -export type Cart = Core.Cart & { - lineItems: Core.LineItem[] - url?: string -} - -export type CartHooks = Core.CartHooks - -export type GetCartHook = CartHooks['getCart'] -export type AddItemHook = CartHooks['addItem'] -export type UpdateItemHook = CartHooks['updateItem'] -export type RemoveItemHook = CartHooks['removeItem'] - -export type CartSchema = Core.CartSchema - -export type CartHandlers = Core.CartHandlers - -export type GetCartHandler = CartHandlers['getCart'] -export type AddItemHandler = CartHandlers['addItem'] -export type UpdateItemHandler = CartHandlers['updateItem'] -export type RemoveItemHandler = CartHandlers['removeItem'] diff --git a/packages/shopify/src/api/endpoints/checkout/index.ts b/packages/shopify/src/api/endpoints/checkout/index.ts index 64020810d..bcccf150c 100644 --- a/packages/shopify/src/api/endpoints/checkout/index.ts +++ b/packages/shopify/src/api/endpoints/checkout/index.ts @@ -1,6 +1,6 @@ import { GetAPISchema, createEndpoint } from '@vercel/commerce/api' import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout' -import type { CheckoutSchema } from '../../../types/checkout' +import type { CheckoutSchema } from '@vercel/commerce/types/checkout' import type { ShopifyAPI } from '../..' import getCheckout from './get-checkout' diff --git a/packages/shopify/src/api/operations/get-all-pages.ts b/packages/shopify/src/api/operations/get-all-pages.ts index 2f6cc0916..55c1d7d69 100644 --- a/packages/shopify/src/api/operations/get-all-pages.ts +++ b/packages/shopify/src/api/operations/get-all-pages.ts @@ -9,7 +9,7 @@ import { } from '../../../schema' import { normalizePages } from '../../utils' import type { ShopifyConfig, Provider } from '..' -import type { GetAllPagesOperation, Page } from '../../types/page' +import type { GetAllPagesOperation, Page } from '@vercel/commerce/types/page' import getAllPagesQuery from '../../utils/queries/get-all-pages-query' export default function getAllPagesOperation({ diff --git a/packages/shopify/src/api/operations/get-all-product-paths.ts b/packages/shopify/src/api/operations/get-all-product-paths.ts index e5a7d2d8e..0155bf6cd 100644 --- a/packages/shopify/src/api/operations/get-all-product-paths.ts +++ b/packages/shopify/src/api/operations/get-all-product-paths.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } from '@vercel/commerce/api/operations' -import { GetAllProductPathsOperation } from '../../types/product' +import { GetAllProductPathsOperation } from '@vercel/commerce/types/product' import { GetAllProductPathsQuery, GetAllProductPathsQueryVariables, diff --git a/packages/shopify/src/api/operations/get-all-products.ts b/packages/shopify/src/api/operations/get-all-products.ts index 003e27204..fcab20128 100644 --- a/packages/shopify/src/api/operations/get-all-products.ts +++ b/packages/shopify/src/api/operations/get-all-products.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } from '@vercel/commerce/api/operations' -import { GetAllProductsOperation } from '../../types/product' +import { GetAllProductsOperation } from '@vercel/commerce/types/product' import { GetAllProductsQuery, GetAllProductsQueryVariables, diff --git a/packages/shopify/src/api/operations/get-page.ts b/packages/shopify/src/api/operations/get-page.ts index 2cea52194..e6ba19ce5 100644 --- a/packages/shopify/src/api/operations/get-page.ts +++ b/packages/shopify/src/api/operations/get-page.ts @@ -9,7 +9,7 @@ import { GetPageQueryVariables, Page as ShopifyPage, } from '../../../schema' -import { GetPageOperation } from '../../types/page' +import { GetPageOperation } from '@vercel/commerce/types/page' import getPageQuery from '../../utils/queries/get-page-query' export default function getPageOperation({ diff --git a/packages/shopify/src/api/operations/get-product.ts b/packages/shopify/src/api/operations/get-product.ts index 1697b0feb..76a3c865f 100644 --- a/packages/shopify/src/api/operations/get-product.ts +++ b/packages/shopify/src/api/operations/get-product.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } from '@vercel/commerce/api/operations' -import { GetProductOperation } from '../../types/product' +import { GetProductOperation } from '@vercel/commerce/types/product' import { normalizeProduct, getProductQuery } from '../../utils' import type { ShopifyConfig, Provider } from '..' import { diff --git a/packages/shopify/src/api/operations/get-site-info.ts b/packages/shopify/src/api/operations/get-site-info.ts index 7113999b5..f7602025c 100644 --- a/packages/shopify/src/api/operations/get-site-info.ts +++ b/packages/shopify/src/api/operations/get-site-info.ts @@ -4,7 +4,7 @@ import type { } from '@vercel/commerce/api/operations' import { GetSiteInfoQueryVariables } from '../../../schema' import type { ShopifyConfig, Provider } from '..' -import { GetSiteInfoOperation } from '../../types/site' +import { GetSiteInfoOperation } from '@vercel/commerce/types/site' import { getCategories, getBrands } from '../../utils' diff --git a/packages/shopify/src/api/operations/login.ts b/packages/shopify/src/api/operations/login.ts index 5fad769bd..89f402256 100644 --- a/packages/shopify/src/api/operations/login.ts +++ b/packages/shopify/src/api/operations/login.ts @@ -1,6 +1,6 @@ import type { ServerResponse } from 'http' import type { OperationContext } from '@vercel/commerce/api/operations' -import type { LoginOperation } from '../../types/login' +import type { LoginOperation } from '@vercel/commerce/types/login' import type { ShopifyConfig, Provider } from '..' import { customerAccessTokenCreateMutation, diff --git a/packages/shopify/src/auth/use-login.tsx b/packages/shopify/src/auth/use-login.tsx index c9d183e33..81ec35636 100644 --- a/packages/shopify/src/auth/use-login.tsx +++ b/packages/shopify/src/auth/use-login.tsx @@ -1,8 +1,8 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' -import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login' -import type { LoginHook } from '../types/login' +import useLogin, { type UseLogin } from '@vercel/commerce/auth/use-login' +import type { LoginHook } from '@vercel/commerce/types/login' import useCustomer from '../customer/use-customer' import { diff --git a/packages/shopify/src/auth/use-logout.tsx b/packages/shopify/src/auth/use-logout.tsx index c37b0fcc9..d43420525 100644 --- a/packages/shopify/src/auth/use-logout.tsx +++ b/packages/shopify/src/auth/use-logout.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' 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 customerAccessTokenDeleteMutation from '../utils/mutations/customer-access-token-delete' import { getCustomerToken, setCustomerToken } from '../utils/customer-token' diff --git a/packages/shopify/src/auth/use-signup.tsx b/packages/shopify/src/auth/use-signup.tsx index 8af0fec7d..90a4c443a 100644 --- a/packages/shopify/src/auth/use-signup.tsx +++ b/packages/shopify/src/auth/use-signup.tsx @@ -1,8 +1,8 @@ import { useCallback } from 'react' import type { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError } from '@vercel/commerce/utils/errors' -import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup' -import type { SignupHook } from '../types/signup' +import useSignup, { type UseSignup } from '@vercel/commerce/auth/use-signup' +import type { SignupHook } from '@vercel/commerce/types/signup' import useCustomer from '../customer/use-customer' import { Mutation, MutationCustomerCreateArgs } from '../../schema' diff --git a/packages/shopify/src/cart/use-cart.tsx b/packages/shopify/src/cart/use-cart.tsx index 2fe68beef..2400debb1 100644 --- a/packages/shopify/src/cart/use-cart.tsx +++ b/packages/shopify/src/cart/use-cart.tsx @@ -1,10 +1,11 @@ -import { useMemo } from 'react' -import useCommerceCart, { UseCart } from '@vercel/commerce/cart/use-cart' +import type { SWRHook } from '@vercel/commerce/utils/types' +import type { GetCartHook } from '@vercel/commerce/types/cart' + +import { useMemo } from 'react' +import useCommerceCart, { type UseCart } from '@vercel/commerce/cart/use-cart' -import { SWRHook } from '@vercel/commerce/utils/types' import { checkoutToCart } from '../utils' import getCheckoutQuery from '../utils/queries/get-checkout-query' -import { GetCartHook } from '../types/cart' import Cookies from 'js-cookie' import { diff --git a/packages/shopify/src/cart/use-remove-item.tsx b/packages/shopify/src/cart/use-remove-item.tsx index d04c7c5d2..eefeed135 100644 --- a/packages/shopify/src/cart/use-remove-item.tsx +++ b/packages/shopify/src/cart/use-remove-item.tsx @@ -7,7 +7,11 @@ import { ValidationError } from '@vercel/commerce/utils/errors' import useRemoveItem, { UseRemoveItem, } from '@vercel/commerce/cart/use-remove-item' -import type { Cart, LineItem, RemoveItemHook } from '../types/cart' +import type { + Cart, + LineItem, + RemoveItemHook, +} from '@vercel/commerce/types/cart' import useCart from './use-cart' export type RemoveItemFn = T extends LineItem diff --git a/packages/shopify/src/cart/use-update-item.tsx b/packages/shopify/src/cart/use-update-item.tsx index 0e8258a51..3767c6174 100644 --- a/packages/shopify/src/cart/use-update-item.tsx +++ b/packages/shopify/src/cart/use-update-item.tsx @@ -1,23 +1,26 @@ -import { useCallback } from 'react' -import debounce from 'lodash.debounce' +import type { UpdateItemHook, LineItem } from '@vercel/commerce/types/cart' +import type { + Mutation, + MutationCheckoutLineItemsUpdateArgs, +} from '../../schema' import type { HookFetcherContext, MutationHookContext, } from '@vercel/commerce/utils/types' + +import { useCallback } from 'react' +import debounce from 'lodash.debounce' import { ValidationError } from '@vercel/commerce/utils/errors' import useUpdateItem, { - UseUpdateItem, + type UseUpdateItem, } from '@vercel/commerce/cart/use-update-item' - import useCart from './use-cart' import { handler as removeItemHandler } from './use-remove-item' -import type { UpdateItemHook, LineItem } from '../types/cart' import { getCheckoutId, checkoutLineItemUpdateMutation, checkoutToCart, } from '../utils' -import { Mutation, MutationCheckoutLineItemsUpdateArgs } from '../../schema' export type UpdateItemActionInput = T extends LineItem ? Partial diff --git a/packages/shopify/src/customer/use-customer.tsx b/packages/shopify/src/customer/use-customer.tsx index 65e960240..804d6a877 100644 --- a/packages/shopify/src/customer/use-customer.tsx +++ b/packages/shopify/src/customer/use-customer.tsx @@ -1,10 +1,10 @@ -import useCustomer, { - UseCustomer, -} from '@vercel/commerce/customer/use-customer' -import type { CustomerHook } from '../types/customer' -import { SWRHook } from '@vercel/commerce/utils/types' +import type { SWRHook } from '@vercel/commerce/utils/types' +import type { CustomerHook } from '@vercel/commerce/types/customer' +import type { GetCustomerQuery, GetCustomerQueryVariables } from '../../schema' import { getCustomerQuery, getCustomerToken } from '../utils' -import { GetCustomerQuery, GetCustomerQueryVariables } from '../../schema' +import useCustomer, { + type UseCustomer, +} from '@vercel/commerce/customer/use-customer' export default useCustomer as UseCustomer diff --git a/packages/shopify/src/product/use-search.tsx b/packages/shopify/src/product/use-search.tsx index 582423e9f..6d6b9add5 100644 --- a/packages/shopify/src/product/use-search.tsx +++ b/packages/shopify/src/product/use-search.tsx @@ -16,7 +16,7 @@ import { normalizeProduct, } from '../utils' -import type { SearchProductsHook } from '../types/product' +import type { SearchProductsHook } from '@vercel/commerce/types/product' export type SearchProductsInput = { search?: string diff --git a/packages/shopify/src/types/cart.ts b/packages/shopify/src/types/cart.ts deleted file mode 100644 index e6838fb45..000000000 --- a/packages/shopify/src/types/cart.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/cart' diff --git a/packages/shopify/src/types/checkout.ts b/packages/shopify/src/types/checkout.ts deleted file mode 100644 index d139db685..000000000 --- a/packages/shopify/src/types/checkout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/checkout' diff --git a/packages/shopify/src/types/common.ts b/packages/shopify/src/types/common.ts deleted file mode 100644 index 23b8daa11..000000000 --- a/packages/shopify/src/types/common.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/common' diff --git a/packages/shopify/src/types/customer.ts b/packages/shopify/src/types/customer.ts deleted file mode 100644 index c637055b9..000000000 --- a/packages/shopify/src/types/customer.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/customer' diff --git a/packages/shopify/src/types/index.ts b/packages/shopify/src/types/index.ts deleted file mode 100644 index 7ab0b7f64..000000000 --- a/packages/shopify/src/types/index.ts +++ /dev/null @@ -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, -} diff --git a/packages/shopify/src/types/login.ts b/packages/shopify/src/types/login.ts deleted file mode 100644 index 438d541b2..000000000 --- a/packages/shopify/src/types/login.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/login' diff --git a/packages/shopify/src/types/logout.ts b/packages/shopify/src/types/logout.ts deleted file mode 100644 index 1de06f8dc..000000000 --- a/packages/shopify/src/types/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/logout' diff --git a/packages/shopify/src/types/page.ts b/packages/shopify/src/types/page.ts deleted file mode 100644 index 12f6b02d7..000000000 --- a/packages/shopify/src/types/page.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/page' diff --git a/packages/shopify/src/types/product.ts b/packages/shopify/src/types/product.ts deleted file mode 100644 index 72ca02f02..000000000 --- a/packages/shopify/src/types/product.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/product' diff --git a/packages/shopify/src/types/signup.ts b/packages/shopify/src/types/signup.ts deleted file mode 100644 index 3f0d1af5a..000000000 --- a/packages/shopify/src/types/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/signup' diff --git a/packages/shopify/src/types/site.ts b/packages/shopify/src/types/site.ts deleted file mode 100644 index 96a2e476e..000000000 --- a/packages/shopify/src/types/site.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/site' diff --git a/packages/shopify/src/types/wishlist.ts b/packages/shopify/src/types/wishlist.ts deleted file mode 100644 index af92d9f63..000000000 --- a/packages/shopify/src/types/wishlist.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/wishlist' diff --git a/packages/shopify/src/utils/checkout-to-cart.ts b/packages/shopify/src/utils/checkout-to-cart.ts index 97b3f0a21..a487eeee5 100644 --- a/packages/shopify/src/utils/checkout-to-cart.ts +++ b/packages/shopify/src/utils/checkout-to-cart.ts @@ -1,4 +1,4 @@ -import type { Cart } from '../types/cart' +import type { Cart } from '@vercel/commerce/types/cart' import { CommerceError } from '@vercel/commerce/utils/errors' import { diff --git a/packages/shopify/src/utils/get-categories.ts b/packages/shopify/src/utils/get-categories.ts index e5ca16dad..2bae3c3b5 100644 --- a/packages/shopify/src/utils/get-categories.ts +++ b/packages/shopify/src/utils/get-categories.ts @@ -1,6 +1,6 @@ -import type { Category } from '../types/site' -import { ShopifyConfig } from '../api' -import { CollectionEdge } from '../../schema' +import type { Category } from '@vercel/commerce/types/site' +import type { ShopifyConfig } from '../api' +import type { CollectionEdge } from '../../schema' import { normalizeCategory } from './normalize' import getSiteCollectionsQuery from './queries/get-all-collections-query' diff --git a/packages/shopify/src/utils/get-search-variables.ts b/packages/shopify/src/utils/get-search-variables.ts index f4863650d..330465c87 100644 --- a/packages/shopify/src/utils/get-search-variables.ts +++ b/packages/shopify/src/utils/get-search-variables.ts @@ -1,5 +1,5 @@ import getSortVariables from './get-sort-variables' -import { SearchProductsBody } from '../types/product' +import { SearchProductsBody } from '@vercel/commerce/types/product' export const getSearchVariables = ({ brandId, diff --git a/packages/shopify/src/utils/normalize.ts b/packages/shopify/src/utils/normalize.ts index e63989270..066daff33 100644 --- a/packages/shopify/src/utils/normalize.ts +++ b/packages/shopify/src/utils/normalize.ts @@ -1,9 +1,9 @@ -import type { Page } from '../types/page' -import type { Product } from '../types/product' -import type { Cart, LineItem } from '../types/cart' -import type { Category } from '../types/site' +import type { Page } from '@vercel/commerce/types/page' +import type { Product } from '@vercel/commerce/types/product' +import type { Cart, LineItem } from '@vercel/commerce/types/cart' +import type { Category } from '@vercel/commerce/types/site' -import { +import type { Product as ShopifyProduct, Checkout, CheckoutLineItemEdge, @@ -16,6 +16,7 @@ import { PageEdge, Collection, } from '../../schema' + import { colorMap } from './colors' const money = ({ amount, currencyCode }: MoneyV2) => { diff --git a/packages/swell/src/api/operations/get-all-pages.ts b/packages/swell/src/api/operations/get-all-pages.ts index 15fb1520e..13ae77b83 100644 --- a/packages/swell/src/api/operations/get-all-pages.ts +++ b/packages/swell/src/api/operations/get-all-pages.ts @@ -1,6 +1,6 @@ -import { Provider, SwellConfig } from '..' +import type { Provider, SwellConfig } from '..' import type { OperationContext } from '@vercel/commerce/api/operations' -import type { Page } from '../../types/page' +import type { Page } from '@vercel/commerce/types/page' export type GetAllPagesResult = T diff --git a/packages/swell/src/api/operations/get-page.ts b/packages/swell/src/api/operations/get-page.ts index 76d7eb7f9..5fc4d282e 100644 --- a/packages/swell/src/api/operations/get-page.ts +++ b/packages/swell/src/api/operations/get-page.ts @@ -1,10 +1,10 @@ -import { Page } from '../../../schema' -import { SwellConfig, Provider } from '..' -import { +import type { Page } from '../../../schema' +import type { SwellConfig, Provider } from '..' +import type { OperationContext, OperationOptions, } from '@vercel/commerce/api/operations' -import { GetPageOperation } from '../../types/page' +import type { GetPageOperation } from '@vercel/commerce/types/page' export type GetPageResult = T diff --git a/packages/swell/src/api/operations/login.ts b/packages/swell/src/api/operations/login.ts index 44ff37a53..cd1c77655 100644 --- a/packages/swell/src/api/operations/login.ts +++ b/packages/swell/src/api/operations/login.ts @@ -3,7 +3,7 @@ import type { OperationContext, OperationOptions, } from '@vercel/commerce/api/operations' -import type { LoginOperation } from '../../types/login' +import type { LoginOperation } from '@vercel/commerce/types/login' import { Provider, SwellConfig } from '..' export default function loginOperation({ diff --git a/packages/swell/src/auth/use-login.tsx b/packages/swell/src/auth/use-login.tsx index b3fe9f52d..ea7110aca 100644 --- a/packages/swell/src/auth/use-login.tsx +++ b/packages/swell/src/auth/use-login.tsx @@ -1,14 +1,15 @@ -import { useCallback } from 'react' +import type { LoginHook } from '@vercel/commerce/types/login' import type { MutationHook } from '@vercel/commerce/utils/types' -import { CommerceError, ValidationError } from '@vercel/commerce/utils/errors' -import useCustomer from '../customer/use-customer' -import { +import type { CustomerUserError, Mutation, MutationCheckoutCreateArgs, } from '../../schema' -import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login' -import { LoginHook } from '../types/login' + +import { useCallback } from 'react' +import { CommerceError, ValidationError } from '@vercel/commerce/utils/errors' +import useCustomer from '../customer/use-customer' +import useLogin, { type UseLogin } from '@vercel/commerce/auth/use-login' import { setCustomerToken } from '../utils' export default useLogin as UseLogin diff --git a/packages/swell/src/auth/use-logout.tsx b/packages/swell/src/auth/use-logout.tsx index 08eec0bac..e0fdb8ff6 100644 --- a/packages/swell/src/auth/use-logout.tsx +++ b/packages/swell/src/auth/use-logout.tsx @@ -1,9 +1,10 @@ -import { useCallback } from 'react' +import type { LogoutHook } from '@vercel/commerce/types/logout' import type { MutationHook } from '@vercel/commerce/utils/types' + +import { useCallback } from 'react' import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout' import useCustomer from '../customer/use-customer' import { getCustomerToken, setCustomerToken } from '../utils/customer-token' -import { LogoutHook } from '../types/logout' export default useLogout as UseLogout diff --git a/packages/swell/src/auth/use-signup.tsx b/packages/swell/src/auth/use-signup.tsx index 581312db9..080302791 100644 --- a/packages/swell/src/auth/use-signup.tsx +++ b/packages/swell/src/auth/use-signup.tsx @@ -1,9 +1,10 @@ -import { useCallback } from 'react' +import type { SignupHook } from '@vercel/commerce/types/signup' import type { MutationHook } from '@vercel/commerce/utils/types' + +import { useCallback } from 'react' 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 useCustomer from '../customer/use-customer' -import { SignupHook } from '../types/signup' import handleLogin from '../utils/handle-login' export default useSignup as UseSignup diff --git a/packages/swell/src/cart/use-add-item.tsx b/packages/swell/src/cart/use-add-item.tsx index 048a1f45d..e80c71624 100644 --- a/packages/swell/src/cart/use-add-item.tsx +++ b/packages/swell/src/cart/use-add-item.tsx @@ -1,11 +1,12 @@ +import type { AddItemHook } from '@vercel/commerce/types/cart' import type { MutationHook } from '@vercel/commerce/utils/types' + import { CommerceError } from '@vercel/commerce/utils/errors' -import useAddItem, { UseAddItem } from '@vercel/commerce/cart/use-add-item' +import useAddItem, { type UseAddItem } from '@vercel/commerce/cart/use-add-item' import useCart from './use-cart' import { checkoutToCart } from './utils' import { getCheckoutId } from '../utils' import { useCallback } from 'react' -import { AddItemHook } from '../types/cart' export default useAddItem as UseAddItem diff --git a/packages/swell/src/cart/use-update-item.tsx b/packages/swell/src/cart/use-update-item.tsx index c741250c2..8a3a5191b 100644 --- a/packages/swell/src/cart/use-update-item.tsx +++ b/packages/swell/src/cart/use-update-item.tsx @@ -1,23 +1,25 @@ -import { useCallback } from 'react' -import debounce from 'lodash.debounce' import type { HookFetcherContext, - MutationHook, MutationHookContext, } from '@vercel/commerce/utils/types' + +import type { UpdateItemHook, LineItem } from '@vercel/commerce/types/cart' + +import { useCallback } from 'react' +import debounce from 'lodash.debounce' + import { ValidationError } from '@vercel/commerce/utils/errors' // import useUpdateItem, { // UpdateItemInput as UpdateItemInputBase, // UseUpdateItem, // } from '@vercel/commerce/cart/use-update-item' import useUpdateItem, { - UseUpdateItem, + type UseUpdateItem, } from '@vercel/commerce/cart/use-update-item' import useCart from './use-cart' import { handler as removeItemHandler } from './use-remove-item' -import { CartItemBody, LineItem } from '@vercel/commerce/types/cart' import { checkoutToCart } from './utils' -import { UpdateItemHook } from '../types/cart' + // export type UpdateItemInput = T extends LineItem // ? Partial> // : UpdateItemInputBase diff --git a/packages/swell/src/cart/utils/checkout-to-cart.ts b/packages/swell/src/cart/utils/checkout-to-cart.ts index c9becb104..af7d89602 100644 --- a/packages/swell/src/cart/utils/checkout-to-cart.ts +++ b/packages/swell/src/cart/utils/checkout-to-cart.ts @@ -1,4 +1,4 @@ -import { Cart } from '../../types' +import type { Cart } from '@vercel/commerce/types/cart' import { CommerceError } from '@vercel/commerce/utils/errors' import { diff --git a/packages/swell/src/customer/use-customer.tsx b/packages/swell/src/customer/use-customer.tsx index 0875310fd..45b81b2ff 100644 --- a/packages/swell/src/customer/use-customer.tsx +++ b/packages/swell/src/customer/use-customer.tsx @@ -1,9 +1,10 @@ +import type { SWRHook } from '@vercel/commerce/utils/types' +import type { CustomerHook } from '@vercel/commerce/types/customer' + import useCustomer, { - UseCustomer, + type UseCustomer, } from '@vercel/commerce/customer/use-customer' -import { SWRHook } from '@vercel/commerce/utils/types' import { normalizeCustomer } from '../utils/normalize' -import type { CustomerHook } from '../types/customer' export default useCustomer as UseCustomer diff --git a/packages/swell/src/product/use-search.tsx b/packages/swell/src/product/use-search.tsx index b996099a4..81f8596d9 100644 --- a/packages/swell/src/product/use-search.tsx +++ b/packages/swell/src/product/use-search.tsx @@ -1,8 +1,9 @@ +import type { SwellProduct } from '../types' +import type { SearchProductsHook } from '@vercel/commerce/types/product' + import { SWRHook } from '@vercel/commerce/utils/types' -import useSearch, { UseSearch } from '@vercel/commerce/product/use-search' +import useSearch, { type UseSearch } from '@vercel/commerce/product/use-search' import { normalizeProduct } from '../utils' -import { SwellProduct } from '../types' -import type { SearchProductsHook } from '../types/product' export default useSearch as UseSearch diff --git a/packages/swell/src/types.ts b/packages/swell/src/types.ts index b02bbd8ca..5d3e7507e 100644 --- a/packages/swell/src/types.ts +++ b/packages/swell/src/types.ts @@ -1,6 +1,4 @@ -import * as Core from '@vercel/commerce/types/cart' -import { Customer } from '@vercel/commerce/types' -import { CheckoutLineItem } from '../schema' +import type { CheckoutLineItem } from '../schema' export type SwellImage = { file: { @@ -88,15 +86,6 @@ export type SwellCheckout = { lineItems: CheckoutLineItem[] } -export interface Cart extends Core.Cart { - id: string - lineItems: LineItem[] -} - -export interface LineItem extends Core.LineItem { - options?: any[] -} - /** * Cart mutations */ @@ -105,8 +94,3 @@ export type OptionSelections = { option_id: number option_value: number | string } - -export type CartItemBody = Core.CartItemBody & { - productId: string // The product id is always required for BC - optionSelections?: OptionSelections -} diff --git a/packages/swell/src/utils/get-categories.ts b/packages/swell/src/utils/get-categories.ts index ab38bae96..ee951b335 100644 --- a/packages/swell/src/utils/get-categories.ts +++ b/packages/swell/src/utils/get-categories.ts @@ -1,5 +1,5 @@ import { SwellConfig } from '../api' -import { Category } from '../types/site' +import type { Category } from '@vercel/commerce/types/site' const getCategories = async (config: SwellConfig): Promise => { const data = await config.fetch('categories', 'get') diff --git a/packages/swell/src/utils/normalize.ts b/packages/swell/src/utils/normalize.ts index ebc4298ef..89bcd06f0 100644 --- a/packages/swell/src/utils/normalize.ts +++ b/packages/swell/src/utils/normalize.ts @@ -1,9 +1,9 @@ -import { Customer } from '../types/customer' -import { Product, ProductOption } from '../types/product' -import { MoneyV2 } from '../../schema' +import type { Cart, LineItem } from '@vercel/commerce/types/cart' +import type { Customer } from '@vercel/commerce/types/customer' +import type { Product, ProductOption } from '@vercel/commerce/types/product' +import type { MoneyV2 } from '../../schema' import type { - Cart, CartLineItem, SwellCustomer, SwellProduct, @@ -12,7 +12,6 @@ import type { ProductOptionValue, SwellProductOptionValue, SwellCart, - LineItem, } from '../types' const money = ({ amount, currencyCode }: MoneyV2) => { @@ -214,7 +213,8 @@ function normalizeLineItem({ discounts: [], options: [ { - value: variant?.name, + name: variant?.name!, + value: variant?.name!, }, ], } diff --git a/packages/vendure/src/api/operations/login.ts b/packages/vendure/src/api/operations/login.ts index 07ee5fa1d..494af1f75 100644 --- a/packages/vendure/src/api/operations/login.ts +++ b/packages/vendure/src/api/operations/login.ts @@ -4,7 +4,7 @@ import type { OperationOptions, } from '@vercel/commerce/api/operations' import { ValidationError } from '@vercel/commerce/utils/errors' -import type { LoginOperation } from '../../types/login' +import type { LoginOperation } from '@vercel/commerce/types/login' import type { LoginMutation } from '../../../schema' import { Provider, VendureConfig } from '..' import { loginMutation } from '../../utils/mutations/log-in-mutation' diff --git a/packages/vendure/src/auth/use-login.tsx b/packages/vendure/src/auth/use-login.tsx index ce1a45456..56c701119 100644 --- a/packages/vendure/src/auth/use-login.tsx +++ b/packages/vendure/src/auth/use-login.tsx @@ -1,10 +1,10 @@ import { useCallback } from 'react' import { MutationHook } from '@vercel/commerce/utils/types' -import useLogin, { UseLogin } from '@vercel/commerce/auth/use-login' -import { LoginHook } from '../types/login' +import useLogin, { type UseLogin } from '@vercel/commerce/auth/use-login' +import type { LoginHook } from '@vercel/commerce/types/login' import { CommerceError, ValidationError } from '@vercel/commerce/utils/errors' import useCustomer from '../customer/use-customer' -import { LoginMutation, LoginMutationVariables } from '../../schema' +import type { LoginMutation, LoginMutationVariables } from '../../schema' import { loginMutation } from '../utils/mutations/log-in-mutation' export default useLogin as UseLogin diff --git a/packages/vendure/src/auth/use-logout.tsx b/packages/vendure/src/auth/use-logout.tsx index 8a099cf77..e24976a94 100644 --- a/packages/vendure/src/auth/use-logout.tsx +++ b/packages/vendure/src/auth/use-logout.tsx @@ -1,10 +1,10 @@ import { useCallback } from 'react' -import { MutationHook } from '@vercel/commerce/utils/types' -import useLogout, { UseLogout } from '@vercel/commerce/auth/use-logout' +import type { MutationHook } from '@vercel/commerce/utils/types' +import useLogout, { type UseLogout } from '@vercel/commerce/auth/use-logout' import useCustomer from '../customer/use-customer' -import { LogoutMutation } from '../../schema' +import type { LogoutMutation } from '../../schema' import { logoutMutation } from '../utils/mutations/log-out-mutation' -import { LogoutHook } from '../types/logout' +import type { LogoutHook } from '@vercel/commerce/types/logout' export default useLogout as UseLogout diff --git a/packages/vendure/src/auth/use-signup.tsx b/packages/vendure/src/auth/use-signup.tsx index 0c19c91bb..3586ca66b 100644 --- a/packages/vendure/src/auth/use-signup.tsx +++ b/packages/vendure/src/auth/use-signup.tsx @@ -1,15 +1,11 @@ import { useCallback } from 'react' import { MutationHook } from '@vercel/commerce/utils/types' import { CommerceError, ValidationError } 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 useCustomer from '../customer/use-customer' -import { - RegisterCustomerInput, - SignupMutation, - SignupMutationVariables, -} from '../../schema' +import type { SignupMutation, SignupMutationVariables } from '../../schema' import { signupMutation } from '../utils/mutations/sign-up-mutation' -import { SignupHook } from '../types/signup' +import type { SignupHook } from '@vercel/commerce/types/signup' export default useSignup as UseSignup diff --git a/packages/vendure/src/cart/use-add-item.tsx b/packages/vendure/src/cart/use-add-item.tsx index d7bb0bf66..1b6f85040 100644 --- a/packages/vendure/src/cart/use-add-item.tsx +++ b/packages/vendure/src/cart/use-add-item.tsx @@ -1,12 +1,12 @@ import useAddItem, { UseAddItem } from '@vercel/commerce/cart/use-add-item' import { CommerceError } from '@vercel/commerce/utils/errors' -import { MutationHook } from '@vercel/commerce/utils/types' +import type { MutationHook } from '@vercel/commerce/utils/types' import { useCallback } from 'react' import useCart from './use-cart' import { AddItemToOrderMutation } from '../../schema' import { normalizeCart } from '../utils/normalize' import { addItemToOrderMutation } from '../utils/mutations/add-item-to-order-mutation' -import { AddItemHook } from '../types/cart' +import type { AddItemHook } from '@vercel/commerce/types/cart' export default useAddItem as UseAddItem diff --git a/packages/vendure/src/cart/use-cart.tsx b/packages/vendure/src/cart/use-cart.tsx index 750f11040..e298bf9f4 100644 --- a/packages/vendure/src/cart/use-cart.tsx +++ b/packages/vendure/src/cart/use-cart.tsx @@ -1,10 +1,10 @@ import { SWRHook } from '@vercel/commerce/utils/types' -import useCart, { UseCart } from '@vercel/commerce/cart/use-cart' +import useCart, { type UseCart } from '@vercel/commerce/cart/use-cart' import { ActiveOrderQuery, CartFragment } from '../../schema' import { normalizeCart } from '../utils/normalize' import { useMemo } from 'react' import { getCartQuery } from '../utils/queries/get-cart-query' -import { GetCartHook } from '../types/cart' +import type { GetCartHook } from '@vercel/commerce/types/cart' export type CartResult = { activeOrder?: CartFragment diff --git a/packages/vendure/src/cart/use-remove-item.tsx b/packages/vendure/src/cart/use-remove-item.tsx index 2aa316505..fbd07a31e 100644 --- a/packages/vendure/src/cart/use-remove-item.tsx +++ b/packages/vendure/src/cart/use-remove-item.tsx @@ -1,22 +1,17 @@ import { useCallback } from 'react' -import { - HookFetcherContext, - MutationHook, - MutationHookContext, - SWRHook, -} from '@vercel/commerce/utils/types' +import type { MutationHook } from '@vercel/commerce/utils/types' import useRemoveItem, { UseRemoveItem, } from '@vercel/commerce/cart/use-remove-item' import { CommerceError } from '@vercel/commerce/utils/errors' -import { Cart } from '@vercel/commerce/types/cart' + import useCart from './use-cart' import { RemoveOrderLineMutation, RemoveOrderLineMutationVariables, } from '../../schema' import { normalizeCart } from '../utils/normalize' -import { RemoveItemHook } from '../types/cart' +import type { RemoveItemHook } from '@vercel/commerce/types/cart' import { removeOrderLineMutation } from '../utils/mutations/remove-order-line-mutation' export default useRemoveItem as UseRemoveItem diff --git a/packages/vendure/src/cart/use-update-item.tsx b/packages/vendure/src/cart/use-update-item.tsx index 2f3c8d47b..f97f15d1d 100644 --- a/packages/vendure/src/cart/use-update-item.tsx +++ b/packages/vendure/src/cart/use-update-item.tsx @@ -8,7 +8,6 @@ import { CommerceError, ValidationError } from '@vercel/commerce/utils/errors' import useUpdateItem, { UseUpdateItem, } from '@vercel/commerce/cart/use-update-item' -import { CartItemBody, LineItem } from '@vercel/commerce/types/cart' import useCart from './use-cart' import { AdjustOrderLineMutation, @@ -16,7 +15,7 @@ import { } from '../../schema' import { normalizeCart } from '../utils/normalize' import { adjustOrderLineMutation } from '../utils/mutations/adjust-order-line-mutation' -import { UpdateItemHook } from '../types/cart' +import type { UpdateItemHook, LineItem } from '@vercel/commerce/types/cart' export type UpdateItemActionInput = T extends LineItem ? Partial diff --git a/packages/vendure/src/customer/use-customer.tsx b/packages/vendure/src/customer/use-customer.tsx index 80da077ff..00b14a46a 100644 --- a/packages/vendure/src/customer/use-customer.tsx +++ b/packages/vendure/src/customer/use-customer.tsx @@ -4,7 +4,7 @@ import useCustomer, { } from '@vercel/commerce/customer/use-customer' import { ActiveCustomerQuery } from '../../schema' import { activeCustomerQuery } from '../utils/queries/active-customer-query' -import { CustomerHook } from '../types/customer' +import { CustomerHook } from '@vercel/commerce/types/customer' export default useCustomer as UseCustomer diff --git a/packages/vendure/src/product/use-search.tsx b/packages/vendure/src/product/use-search.tsx index 86c6467d1..bd380cf41 100644 --- a/packages/vendure/src/product/use-search.tsx +++ b/packages/vendure/src/product/use-search.tsx @@ -4,7 +4,7 @@ import { Product } from '@vercel/commerce/types/product' import { SearchQuery, SearchQueryVariables } from '../../schema' import { normalizeSearchResult } from '../utils/normalize' import { searchQuery } from '../utils/queries/search-query' -import { SearchProductsHook } from '../types/product' +import type { SearchProductsHook } from '@vercel/commerce/types/product' export default useSearch as UseSearch diff --git a/packages/vendure/src/types/cart.ts b/packages/vendure/src/types/cart.ts deleted file mode 100644 index e6838fb45..000000000 --- a/packages/vendure/src/types/cart.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/cart' diff --git a/packages/vendure/src/types/checkout.ts b/packages/vendure/src/types/checkout.ts deleted file mode 100644 index d139db685..000000000 --- a/packages/vendure/src/types/checkout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/checkout' diff --git a/packages/vendure/src/types/common.ts b/packages/vendure/src/types/common.ts deleted file mode 100644 index 23b8daa11..000000000 --- a/packages/vendure/src/types/common.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/common' diff --git a/packages/vendure/src/types/customer.ts b/packages/vendure/src/types/customer.ts deleted file mode 100644 index c637055b9..000000000 --- a/packages/vendure/src/types/customer.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/customer' diff --git a/packages/vendure/src/types/index.ts b/packages/vendure/src/types/index.ts deleted file mode 100644 index 7ab0b7f64..000000000 --- a/packages/vendure/src/types/index.ts +++ /dev/null @@ -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, -} diff --git a/packages/vendure/src/types/login.ts b/packages/vendure/src/types/login.ts deleted file mode 100644 index 438d541b2..000000000 --- a/packages/vendure/src/types/login.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/login' diff --git a/packages/vendure/src/types/logout.ts b/packages/vendure/src/types/logout.ts deleted file mode 100644 index 1de06f8dc..000000000 --- a/packages/vendure/src/types/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/logout' diff --git a/packages/vendure/src/types/page.ts b/packages/vendure/src/types/page.ts deleted file mode 100644 index 12f6b02d7..000000000 --- a/packages/vendure/src/types/page.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/page' diff --git a/packages/vendure/src/types/product.ts b/packages/vendure/src/types/product.ts deleted file mode 100644 index 72ca02f02..000000000 --- a/packages/vendure/src/types/product.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/product' diff --git a/packages/vendure/src/types/signup.ts b/packages/vendure/src/types/signup.ts deleted file mode 100644 index 3f0d1af5a..000000000 --- a/packages/vendure/src/types/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/signup' diff --git a/packages/vendure/src/types/site.ts b/packages/vendure/src/types/site.ts deleted file mode 100644 index 96a2e476e..000000000 --- a/packages/vendure/src/types/site.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/site' diff --git a/packages/vendure/src/types/wishlist.ts b/packages/vendure/src/types/wishlist.ts deleted file mode 100644 index af92d9f63..000000000 --- a/packages/vendure/src/types/wishlist.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@vercel/commerce/types/wishlist' diff --git a/packages/vendure/src/wishlist/use-wishlist.tsx b/packages/vendure/src/wishlist/use-wishlist.tsx index b91a98530..cb9dcc815 100644 --- a/packages/vendure/src/wishlist/use-wishlist.tsx +++ b/packages/vendure/src/wishlist/use-wishlist.tsx @@ -1,7 +1,7 @@ // TODO: replace this hook and other wishlist hooks with a handler, or remove them if // Vendure doesn't have a built-in wishlist -import { HookFetcher } from '@vercel/commerce/utils/types' +import type { HookFetcher } from '@vercel/commerce/utils/types' import type { Wishlist } from '@vercel/commerce/types/wishlist' const defaultOpts = {}