From 037de93e65d05dcb64bf177512ddd0cd507695fb Mon Sep 17 00:00:00 2001 From: Franco Arza Date: Mon, 26 Oct 2020 20:41:01 -0300 Subject: [PATCH 01/23] test improvements --- .../ProductCard/ProductCard.module.css | 19 +++++++------------ pages/index.tsx | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css index 171190df0..a289cc1df 100644 --- a/components/product/ProductCard/ProductCard.module.css +++ b/components/product/ProductCard/ProductCard.module.css @@ -1,5 +1,6 @@ .root { - @apply relative w-full box-border overflow-hidden bg-no-repeat bg-center bg-cover transition ease-linear cursor-pointer; + @apply relative max-h-full w-full box-border overflow-hidden bg-no-repeat bg-center bg-cover transition ease-linear cursor-pointer; + height: 100% !important; &:hover { & .squareBg:before { @@ -119,17 +120,11 @@ } .wishlistButton { - @apply w-10 h-10 flex ml-auto flex items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer; + @apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer; } -.imageContainer { - @apply absolute z-10 inset-0 flex items-center justify-center; - - & > div { - @apply h-full; - & > div { - @apply h-full; - padding-bottom: 0 !important; - } - } +.product-image { + position: absolute; + width: 100%; + height: 100%; } diff --git a/pages/index.tsx b/pages/index.tsx index 5304f691e..44a93c1d7 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -80,8 +80,8 @@ export default function Home({ key={node.path} product={node} // The first image is the largest one in the grid - imgWidth={i === 0 ? '65vw' : '30vw'} - imgHeight={i === 0 ? '45vw' : '22vw'} + imgWidth={i === 0 ? 1600 : 820} + imgHeight={i === 0 ? 1600 : 820} priority /> ))} From 695a446314401722d2b0b4e70b94cf98549a8f78 Mon Sep 17 00:00:00 2001 From: Franco Arza Date: Mon, 26 Oct 2020 21:01:00 -0300 Subject: [PATCH 02/23] improve image component styles --- .../EnhancedImage/EnhancedImage.module.css | 14 +++++++++++++ .../core/EnhancedImage/EnhancedImage.tsx | 3 ++- .../ProductCard/ProductCard.module.css | 6 ------ .../product/ProductCard/ProductCard.tsx | 20 +++++++++---------- 4 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 components/core/EnhancedImage/EnhancedImage.module.css diff --git a/components/core/EnhancedImage/EnhancedImage.module.css b/components/core/EnhancedImage/EnhancedImage.module.css new file mode 100644 index 000000000..9caafc3be --- /dev/null +++ b/components/core/EnhancedImage/EnhancedImage.module.css @@ -0,0 +1,14 @@ +.root { + @apply transform transition-transform duration-500; + height: 100%; + margin: auto; + + &:hover { + transform: scale(1.05); + } + + & div { + height: 100%; + margin: auto; + } +} diff --git a/components/core/EnhancedImage/EnhancedImage.tsx b/components/core/EnhancedImage/EnhancedImage.tsx index 3ff97224b..ceae4918b 100644 --- a/components/core/EnhancedImage/EnhancedImage.tsx +++ b/components/core/EnhancedImage/EnhancedImage.tsx @@ -1,6 +1,7 @@ import { FC } from 'react' import { useInView } from 'react-intersection-observer' import Image from 'next/image' +import s from './EnhancedImage.module.css' type Props = Omit< JSX.IntrinsicElements['img'], @@ -33,7 +34,7 @@ const EnhancedImage: FC = ({ }) return ( -
+
) diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css index a289cc1df..1276a7c0b 100644 --- a/components/product/ProductCard/ProductCard.module.css +++ b/components/product/ProductCard/ProductCard.module.css @@ -122,9 +122,3 @@ .wishlistButton { @apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer; } - -.product-image { - position: absolute; - width: 100%; - height: 100%; -} diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index d48c5b4cf..3f46534d1 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -70,17 +70,15 @@ const ProductCard: FC = ({ variant={p.variants.edges?.[0]!} />
-
- -
+ ) From 78238c7061e0ad2076990c65bda8ce59d4cd0f08 Mon Sep 17 00:00:00 2001 From: Franco Arza Date: Mon, 26 Oct 2020 21:13:58 -0300 Subject: [PATCH 03/23] fix nested css --- .../HomeAllProductsGrid.module.css | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/core/HomeAllProductsGrid/HomeAllProductsGrid.module.css b/components/core/HomeAllProductsGrid/HomeAllProductsGrid.module.css index 464087ebc..ec2f8ea49 100644 --- a/components/core/HomeAllProductsGrid/HomeAllProductsGrid.module.css +++ b/components/core/HomeAllProductsGrid/HomeAllProductsGrid.module.css @@ -4,20 +4,20 @@ @screen md { @apply flex-row; } -} -.asideWrapper { - @apply pr-3 w-full relative; + & .asideWrapper { + @apply pr-3 w-full relative; - @screen md { - @apply w-48; - } -} - -.aside { - @apply flex flex-row w-full justify-around mb-12; - - @screen md { - @apply mb-0 block sticky top-32; + @screen md { + @apply w-48; + } + } + + & .aside { + @apply flex flex-row w-full justify-around mb-12; + + @screen md { + @apply mb-0 block sticky top-32; + } } } From 0478b43e9ce3eee7bd75279269f91d3c0487195a Mon Sep 17 00:00:00 2001 From: Franco Arza Date: Mon, 26 Oct 2020 21:45:39 -0300 Subject: [PATCH 04/23] improve the images --- .../core/EnhancedImage/EnhancedImage.module.css | 14 -------------- components/core/EnhancedImage/EnhancedImage.tsx | 3 +-- .../product/ProductCard/ProductCard.module.css | 8 ++++++++ components/product/ProductCard/ProductCard.tsx | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 components/core/EnhancedImage/EnhancedImage.module.css diff --git a/components/core/EnhancedImage/EnhancedImage.module.css b/components/core/EnhancedImage/EnhancedImage.module.css deleted file mode 100644 index 9caafc3be..000000000 --- a/components/core/EnhancedImage/EnhancedImage.module.css +++ /dev/null @@ -1,14 +0,0 @@ -.root { - @apply transform transition-transform duration-500; - height: 100%; - margin: auto; - - &:hover { - transform: scale(1.05); - } - - & div { - height: 100%; - margin: auto; - } -} diff --git a/components/core/EnhancedImage/EnhancedImage.tsx b/components/core/EnhancedImage/EnhancedImage.tsx index ceae4918b..3ff97224b 100644 --- a/components/core/EnhancedImage/EnhancedImage.tsx +++ b/components/core/EnhancedImage/EnhancedImage.tsx @@ -1,7 +1,6 @@ import { FC } from 'react' import { useInView } from 'react-intersection-observer' import Image from 'next/image' -import s from './EnhancedImage.module.css' type Props = Omit< JSX.IntrinsicElements['img'], @@ -34,7 +33,7 @@ const EnhancedImage: FC = ({ }) return ( -
+
) diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css index 1276a7c0b..412721464 100644 --- a/components/product/ProductCard/ProductCard.module.css +++ b/components/product/ProductCard/ProductCard.module.css @@ -122,3 +122,11 @@ .wishlistButton { @apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer; } + +.product-image { + margin: auto; + + & div { + margin: auto; + } +} diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index e1a0a3d91..3243e8261 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -72,7 +72,7 @@ const ProductCard: FC = ({
Date: Mon, 26 Oct 2020 21:52:36 -0300 Subject: [PATCH 05/23] make the images bigger --- .../ProductCard/ProductCard.module.css | 16 ++++++++++----- .../product/ProductCard/ProductCard.tsx | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css index 412721464..0c8dd1c04 100644 --- a/components/product/ProductCard/ProductCard.module.css +++ b/components/product/ProductCard/ProductCard.module.css @@ -123,10 +123,16 @@ @apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer; } -.product-image { - margin: auto; - - & div { - margin: auto; +.imageContainer { + & > div { + & > div { + height: 100%; + margin: 0 auto; + } } } + +.product-image { + height: 120% !important; + top: -10% !important; +} diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 3243e8261..808e37063 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -70,15 +70,17 @@ const ProductCard: FC = ({ variant={p.variants.edges?.[0]!} /> - +
+ +
) From c7b5c3ddc9a4de20e80d08f7a0abf5b910241f2d Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 27 Oct 2020 02:35:40 +0100 Subject: [PATCH 06/23] use @bigcommerce/storefront-data-hooks --- components/auth/ForgotPassword.tsx | 2 +- components/auth/LoginView.tsx | 2 +- components/auth/SignUpView.tsx | 2 +- components/cart/CartItem/CartItem.tsx | 6 +++--- .../cart/CartSidebarView/CartSidebarView.tsx | 4 ++-- components/core/Footer/Footer.tsx | 2 +- components/core/Layout/Layout.tsx | 4 ++-- components/core/UserNav/DropdownMenu.tsx | 2 +- components/core/UserNav/UserNav.tsx | 4 ++-- .../product/ProductCard/ProductCard.tsx | 4 ++-- .../product/ProductView/ProductView.tsx | 4 ++-- components/product/helpers.ts | 2 +- .../WishlistButton/WishlistButton.tsx | 10 ++++----- package.json | 1 + pages/[...pages].tsx | 4 ++-- pages/api/bigcommerce/cart.ts | 2 +- pages/api/bigcommerce/catalog/products.ts | 2 +- pages/api/bigcommerce/checkout.ts | 2 +- pages/api/bigcommerce/customers/index.ts | 2 +- pages/api/bigcommerce/customers/login.ts | 2 +- pages/api/bigcommerce/customers/logout.ts | 2 +- pages/api/bigcommerce/customers/signup.ts | 2 +- pages/api/bigcommerce/wishlist.ts | 2 +- pages/blog.tsx | 2 +- pages/cart.tsx | 6 +++--- pages/index.tsx | 8 +++---- pages/product/[slug].tsx | 8 +++---- pages/profile.tsx | 2 +- pages/search.tsx | 6 +++--- pages/wishlist.tsx | 6 +++--- yarn.lock | 21 ++++++++++++++----- 31 files changed, 70 insertions(+), 58 deletions(-) diff --git a/components/auth/ForgotPassword.tsx b/components/auth/ForgotPassword.tsx index 1519e371c..f6e342742 100644 --- a/components/auth/ForgotPassword.tsx +++ b/components/auth/ForgotPassword.tsx @@ -3,7 +3,7 @@ import { validate } from 'email-validator' import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' -import useSignup from '@lib/bigcommerce/use-signup' +import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup' interface Props {} diff --git a/components/auth/LoginView.tsx b/components/auth/LoginView.tsx index f41a128f5..33cb88c21 100644 --- a/components/auth/LoginView.tsx +++ b/components/auth/LoginView.tsx @@ -1,6 +1,6 @@ import { FC, useEffect, useState, useCallback } from 'react' import { Logo, Modal, Button, Input } from '@components/ui' -import useLogin from '@lib/bigcommerce/use-login' +import useLogin from '@bigcommerce/storefront-data-hooks/dist/use-login' import { useUI } from '@components/ui/context' import { validate } from 'email-validator' diff --git a/components/auth/SignUpView.tsx b/components/auth/SignUpView.tsx index 2c0e6789c..f0cfa8458 100644 --- a/components/auth/SignUpView.tsx +++ b/components/auth/SignUpView.tsx @@ -3,7 +3,7 @@ import { validate } from 'email-validator' import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' -import useSignup from '@lib/bigcommerce/use-signup' +import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup' interface Props {} diff --git a/components/cart/CartItem/CartItem.tsx b/components/cart/CartItem/CartItem.tsx index 04089fa9b..0a6062545 100644 --- a/components/cart/CartItem/CartItem.tsx +++ b/components/cart/CartItem/CartItem.tsx @@ -3,9 +3,9 @@ import Image from 'next/image' import Link from 'next/link' import { ChangeEvent, useEffect, useState } from 'react' import { Trash, Plus, Minus } from '@components/icons' -import usePrice from '@lib/bigcommerce/use-price' -import useUpdateItem from '@lib/bigcommerce/cart/use-update-item' -import useRemoveItem from '@lib/bigcommerce/cart/use-remove-item' +import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' +import useUpdateItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-update-item' +import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-remove-item' const CartItem = ({ item, diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index fdee9eecb..8f019494b 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -4,8 +4,8 @@ import { UserNav } from '@components/core' import { Button } from '@components/ui' import { ArrowLeft, Bag, Cross, Check } from '@components/icons' import { useUI } from '@components/ui/context' -import useCart from '@lib/bigcommerce/cart/use-cart' -import usePrice from '@lib/bigcommerce/use-price' +import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' +import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' import CartItem from '../CartItem' import s from './CartSidebarView.module.css' diff --git a/components/core/Footer/Footer.tsx b/components/core/Footer/Footer.tsx index 7d2348653..419de5ccc 100644 --- a/components/core/Footer/Footer.tsx +++ b/components/core/Footer/Footer.tsx @@ -2,7 +2,7 @@ import { FC } from 'react' import cn from 'classnames' import Link from 'next/link' import { useRouter } from 'next/router' -import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages' +import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import getSlug from '@utils/get-slug' import { Github } from '@components/icons' import { Logo, Container } from '@components/ui' diff --git a/components/core/Layout/Layout.tsx b/components/core/Layout/Layout.tsx index 85da7e847..392844c10 100644 --- a/components/core/Layout/Layout.tsx +++ b/components/core/Layout/Layout.tsx @@ -1,8 +1,8 @@ import { FC, useCallback, useEffect, useState } from 'react' import cn from 'classnames' import { useRouter } from 'next/router' -import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages' -import { CommerceProvider } from '@lib/bigcommerce' +import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import { CommerceProvider } from '@bigcommerce/storefront-data-hooks/dist' import { CartSidebarView } from '@components/cart' import { Container, Sidebar, Button, Modal, Toast } from '@components/ui' import { Navbar, Featurebar, Footer } from '@components/core' diff --git a/components/core/UserNav/DropdownMenu.tsx b/components/core/UserNav/DropdownMenu.tsx index 82121605e..2d4ccf8b8 100644 --- a/components/core/UserNav/DropdownMenu.tsx +++ b/components/core/UserNav/DropdownMenu.tsx @@ -5,7 +5,7 @@ import cn from 'classnames' import s from './DropdownMenu.module.css' import { Moon, Sun } from '@components/icons' import { Menu, Transition } from '@headlessui/react' -import useLogout from '@lib/bigcommerce/use-logout' +import useLogout from '@bigcommerce/storefront-data-hooks/dist/use-logout' import { useRouter } from 'next/router' interface DropdownMenuProps { diff --git a/components/core/UserNav/UserNav.tsx b/components/core/UserNav/UserNav.tsx index 09513bc03..ab5ea9da1 100644 --- a/components/core/UserNav/UserNav.tsx +++ b/components/core/UserNav/UserNav.tsx @@ -7,8 +7,8 @@ import { Avatar } from '@components/core' import { useUI } from '@components/ui/context' import DropdownMenu from './DropdownMenu' import { Menu } from '@headlessui/react' -import useCart from '@lib/bigcommerce/cart/use-cart' -import useCustomer from '@lib/bigcommerce/use-customer' +import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' +import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' interface Props { className?: string } diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 4323977f3..8c5787d17 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -1,8 +1,8 @@ import type { FC } from 'react' import cn from 'classnames' import Link from 'next/link' -import type { ProductNode } from '@lib/bigcommerce/api/operations/get-all-products' -import usePrice from '@lib/bigcommerce/use-price' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' +import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' import { EnhancedImage } from '@components/core' import s from './ProductCard.module.css' import WishlistButton from '@components/wishlist/WishlistButton' diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx index 0c5caea80..d795c92cc 100644 --- a/components/product/ProductView/ProductView.tsx +++ b/components/product/ProductView/ProductView.tsx @@ -10,8 +10,8 @@ import { Swatch, ProductSlider } from '@components/product' import { Button, Container } from '@components/ui' import { HTMLContent } from '@components/core' -import useAddItem from '@lib/bigcommerce/cart/use-add-item' -import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product' +import useAddItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-add-item' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' import { getProductOptions } from '../helpers' interface Props { diff --git a/components/product/helpers.ts b/components/product/helpers.ts index 892138160..f9e69f954 100644 --- a/components/product/helpers.ts +++ b/components/product/helpers.ts @@ -1,4 +1,4 @@ -import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' export function getProductOptions(product: ProductNode) { const options = product.productOptions.edges?.map(({ node }: any) => ({ diff --git a/components/wishlist/WishlistButton/WishlistButton.tsx b/components/wishlist/WishlistButton/WishlistButton.tsx index e9d6236f0..584fba8c7 100644 --- a/components/wishlist/WishlistButton/WishlistButton.tsx +++ b/components/wishlist/WishlistButton/WishlistButton.tsx @@ -1,10 +1,10 @@ import React, { FC, useState } from 'react' import cn from 'classnames' -import type { ProductNode } from '@lib/bigcommerce/api/operations/get-all-products' -import useAddItem from '@lib/bigcommerce/wishlist/use-add-item' -import useRemoveItem from '@lib/bigcommerce/wishlist/use-remove-item' -import useWishlist from '@lib/bigcommerce/wishlist/use-wishlist' -import useCustomer from '@lib/bigcommerce/use-customer' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' +import useAddItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-add-item' +import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-remove-item' +import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist' +import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' import { Heart } from '@components/icons' import { useUI } from '@components/ui/context' diff --git a/package.json b/package.json index 767c5f07f..70fdaa947 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "singleQuote": true }, "dependencies": { + "@bigcommerce/storefront-data-hooks": "^1.0.0", "@headlessui/react": "^0.2.0", "@next/bundle-analyzer": "^9.5.5", "@react-aria/overlays": "^3.4.0", diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx index 283eedd18..0d1e14fbd 100644 --- a/pages/[...pages].tsx +++ b/pages/[...pages].tsx @@ -1,7 +1,7 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import getSlug from '@utils/get-slug' -import getPage from '@lib/bigcommerce/api/operations/get-page' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import getPage from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-page' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import { Layout, HTMLContent } from '@components/core' export async function getStaticProps({ diff --git a/pages/api/bigcommerce/cart.ts b/pages/api/bigcommerce/cart.ts index a294b05c4..58b49da74 100644 --- a/pages/api/bigcommerce/cart.ts +++ b/pages/api/bigcommerce/cart.ts @@ -1,3 +1,3 @@ -import cartApi from '@lib/bigcommerce/api/cart' +import cartApi from '@bigcommerce/storefront-data-hooks/dist/api/cart' export default cartApi() diff --git a/pages/api/bigcommerce/catalog/products.ts b/pages/api/bigcommerce/catalog/products.ts index 41ec81526..9ff8fbdaa 100644 --- a/pages/api/bigcommerce/catalog/products.ts +++ b/pages/api/bigcommerce/catalog/products.ts @@ -1,3 +1,3 @@ -import catalogProductsApi from '@lib/bigcommerce/api/catalog/products' +import catalogProductsApi from '@bigcommerce/storefront-data-hooks/dist/api/catalog/products' export default catalogProductsApi() diff --git a/pages/api/bigcommerce/checkout.ts b/pages/api/bigcommerce/checkout.ts index 0f6456c73..f8b1aa924 100644 --- a/pages/api/bigcommerce/checkout.ts +++ b/pages/api/bigcommerce/checkout.ts @@ -1,3 +1,3 @@ -import checkoutApi from '@lib/bigcommerce/api/checkout' +import checkoutApi from '@bigcommerce/storefront-data-hooks/dist/api/checkout' export default checkoutApi() diff --git a/pages/api/bigcommerce/customers/index.ts b/pages/api/bigcommerce/customers/index.ts index 67e342604..e349b8292 100644 --- a/pages/api/bigcommerce/customers/index.ts +++ b/pages/api/bigcommerce/customers/index.ts @@ -1,3 +1,3 @@ -import customersApi from '@lib/bigcommerce/api/customers' +import customersApi from '@bigcommerce/storefront-data-hooks/dist/api/customers' export default customersApi() diff --git a/pages/api/bigcommerce/customers/login.ts b/pages/api/bigcommerce/customers/login.ts index b64b2252a..581324491 100644 --- a/pages/api/bigcommerce/customers/login.ts +++ b/pages/api/bigcommerce/customers/login.ts @@ -1,3 +1,3 @@ -import loginApi from '@lib/bigcommerce/api/customers/login' +import loginApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/login' export default loginApi() diff --git a/pages/api/bigcommerce/customers/logout.ts b/pages/api/bigcommerce/customers/logout.ts index 84ac2c7bf..4d3da0d6e 100644 --- a/pages/api/bigcommerce/customers/logout.ts +++ b/pages/api/bigcommerce/customers/logout.ts @@ -1,3 +1,3 @@ -import logoutApi from '@lib/bigcommerce/api/customers/logout' +import logoutApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/logout' export default logoutApi() diff --git a/pages/api/bigcommerce/customers/signup.ts b/pages/api/bigcommerce/customers/signup.ts index d8be5512f..c7ba5db21 100644 --- a/pages/api/bigcommerce/customers/signup.ts +++ b/pages/api/bigcommerce/customers/signup.ts @@ -1,3 +1,3 @@ -import signupApi from '@lib/bigcommerce/api/customers/signup' +import signupApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/signup' export default signupApi() diff --git a/pages/api/bigcommerce/wishlist.ts b/pages/api/bigcommerce/wishlist.ts index cfc3e00d0..b361c87b2 100644 --- a/pages/api/bigcommerce/wishlist.ts +++ b/pages/api/bigcommerce/wishlist.ts @@ -1,3 +1,3 @@ -import wishlistApi from '@lib/bigcommerce/api/wishlist' +import wishlistApi from '@bigcommerce/storefront-data-hooks/dist/api/wishlist' export default wishlistApi() diff --git a/pages/blog.tsx b/pages/blog.tsx index 47b46b627..22c8ebf59 100644 --- a/pages/blog.tsx +++ b/pages/blog.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container } from '@components/ui' diff --git a/pages/cart.tsx b/pages/cart.tsx index 62fd618b4..515060369 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -1,10 +1,10 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import { Layout } from '@components/core' import { Button } from '@components/ui' import { Bag, Cross, Check } from '@components/icons' -import useCart from '@lib/bigcommerce/cart/use-cart' -import usePrice from '@lib/bigcommerce/use-price' +import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' +import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' import { CartItem } from '@components/cart' import { Text } from '@components/ui' diff --git a/pages/index.tsx b/pages/index.tsx index 8f02e3c01..e06598798 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,9 +1,9 @@ import { useMemo } from 'react' import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import { getConfig } from '@lib/bigcommerce/api' -import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' -import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api' +import getAllProducts from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import rangeMap from '@lib/range-map' import { Layout } from '@components/core' import { Grid, Marquee, Hero } from '@components/ui' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 30f708997..b4dd65d56 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -4,12 +4,12 @@ import { InferGetStaticPropsType, } from 'next' import { useRouter } from 'next/router' -import { getConfig } from '@lib/bigcommerce/api' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' -import getProduct from '@lib/bigcommerce/api/operations/get-product' +import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getProduct from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' +import getAllProductPaths from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-product-paths' export async function getStaticProps({ params, diff --git a/pages/profile.tsx b/pages/profile.tsx index c34161360..4dcb39bd7 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -1,6 +1,6 @@ import { Layout } from '@components/core' import { Container, Text } from '@components/ui' -import useCustomer from '@lib/bigcommerce/use-customer' +import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' export default function Profile() { const { data } = useCustomer() console.log(data) diff --git a/pages/search.tsx b/pages/search.tsx index 3d18adb66..5dcf94883 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -5,9 +5,9 @@ import { useRouter } from 'next/router' import { Layout } from '@components/core' import { ProductCard } from '@components/product' import { Container, Grid, Skeleton } from '@components/ui' -import useSearch from '@lib/bigcommerce/products/use-search' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' -import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' +import useSearch from '@bigcommerce/storefront-data-hooks/dist/products/use-search' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' import rangeMap from '@lib/range-map' import getSlug from '@utils/get-slug' import { diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index d765ab28c..fb24adaa5 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -1,11 +1,11 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container, Text } from '@components/ui' import { WishlistCard } from '@components/wishlist' -import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' -import useWishlist from '@lib/bigcommerce/wishlist/use-wishlist' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' +import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist' export async function getStaticProps({ preview }: GetStaticPropsContext) { const { pages } = await getAllPages() diff --git a/yarn.lock b/yarn.lock index 1040a652f..8935552be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1140,6 +1140,17 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" +"@bigcommerce/storefront-data-hooks@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@bigcommerce/storefront-data-hooks/-/storefront-data-hooks-1.0.0.tgz#072160c4d6bfe04b22cf332299f408fd02bfd529" + integrity sha512-LI5uqRv30/UgdGsGN6KXTrFF91z3x+1D7/xIsOdy7KFbaqX0v086OYyi9r35d5DJ0ml3lujnURNClmoDMOglmQ== + dependencies: + "@vercel/fetch" "6.1.0" + cookie "0.4.1" + js-cookie "2.2.1" + lodash.debounce "4.0.8" + swr "0.3.6" + "@csstools/convert-colors@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7" @@ -2400,7 +2411,7 @@ async-retry "^1.3.1" debug "^3.1.0" -"@vercel/fetch@^6.1.0": +"@vercel/fetch@6.1.0", "@vercel/fetch@^6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@vercel/fetch/-/fetch-6.1.0.tgz#4959cd264d25e811b46491818a9d9ca5d752a2a9" integrity sha512-xR0GQggKhPvwEWrqcrobsQFjyR/bDDbX24BkSaRyLzW+8SydKhkBc/mBCUV8h4SBZSlJMJnqhrxjFCZ1uJcqNg== @@ -3573,7 +3584,7 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== -cookie@^0.4.1: +cookie@0.4.1, cookie@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== @@ -5303,7 +5314,7 @@ jest-worker@^26.6.1: merge-stream "^2.0.0" supports-color "^7.0.0" -js-cookie@^2.2.1: +js-cookie@2.2.1, js-cookie@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ== @@ -5592,7 +5603,7 @@ lodash._reinterpolate@^3.0.0: resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= -lodash.debounce@^4.0.8: +lodash.debounce@4.0.8, lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= @@ -8074,7 +8085,7 @@ supports-color@^7.0.0, supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -swr@^0.3.3: +swr@0.3.6, swr@^0.3.3: version "0.3.6" resolved "https://registry.yarnpkg.com/swr/-/swr-0.3.6.tgz#b1d59439e5114fdf95bb408e1c628ff48f967aac" integrity sha512-LHbX9vVQSW8Kgyr86zz2fVVKmmT13qxB61uXuUAg6NT4cGu6afzAzT2SVCGEh8pJAD2o8NTZMgclIUxIAbvk7Q== From 619130a96828f5b132eef200c6cf4f1fe8e6ae69 Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 27 Oct 2020 02:47:56 +0100 Subject: [PATCH 07/23] update package --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8935552be..810216ecf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1142,8 +1142,8 @@ "@bigcommerce/storefront-data-hooks@^1.0.0": version "1.0.0" - resolved "https://registry.yarnpkg.com/@bigcommerce/storefront-data-hooks/-/storefront-data-hooks-1.0.0.tgz#072160c4d6bfe04b22cf332299f408fd02bfd529" - integrity sha512-LI5uqRv30/UgdGsGN6KXTrFF91z3x+1D7/xIsOdy7KFbaqX0v086OYyi9r35d5DJ0ml3lujnURNClmoDMOglmQ== + resolved "https://registry.yarnpkg.com/@bigcommerce/storefront-data-hooks/-/storefront-data-hooks-1.0.0.tgz#1f5fe03f44190552e457609f12976deb159711ed" + integrity sha512-vdfNA8dVVBKjbVwCj4KS4hZULTHYEnH0fRFa3ujPybQbvaVO2ltVRTiGbA+hqCZkSMNI5koE6FEO9CIhMrHFsQ== dependencies: "@vercel/fetch" "6.1.0" cookie "0.4.1" From ae822df68971ae36cd375ab7d0d3abeb4d73e571 Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 27 Oct 2020 02:51:53 +0100 Subject: [PATCH 08/23] remove lib/bigcommerce and lib/commerce --- lib/bigcommerce/api/cart/handlers/add-item.ts | 37 - lib/bigcommerce/api/cart/handlers/get-cart.ts | 29 - .../api/cart/handlers/remove-item.ts | 34 - .../api/cart/handlers/update-item.ts | 36 - lib/bigcommerce/api/cart/index.ts | 110 - .../api/catalog/handlers/get-products.ts | 73 - lib/bigcommerce/api/catalog/products.ts | 48 - lib/bigcommerce/api/checkout.ts | 76 - .../handlers/get-logged-in-customer.ts | 59 - .../api/customers/handlers/login.ts | 49 - .../api/customers/handlers/logout.ts | 23 - .../api/customers/handlers/signup.ts | 62 - lib/bigcommerce/api/customers/index.ts | 46 - lib/bigcommerce/api/customers/login.ts | 45 - lib/bigcommerce/api/customers/logout.ts | 42 - lib/bigcommerce/api/customers/signup.ts | 50 - lib/bigcommerce/api/definitions/catalog.ts | 2993 ----------------- .../api/definitions/store-content.ts | 329 -- lib/bigcommerce/api/definitions/wishlist.ts | 142 - .../api/fragments/category-tree.ts | 9 - lib/bigcommerce/api/fragments/product.ts | 106 - lib/bigcommerce/api/index.ts | 85 - .../api/operations/get-all-pages.ts | 43 - .../api/operations/get-all-product-paths.ts | 71 - .../api/operations/get-all-products.ts | 129 - .../api/operations/get-customer-id.ts | 34 - .../api/operations/get-customer-wishlist.ts | 51 - lib/bigcommerce/api/operations/get-page.ts | 53 - lib/bigcommerce/api/operations/get-product.ts | 90 - .../api/operations/get-site-info.ts | 103 - lib/bigcommerce/api/operations/login.ts | 71 - lib/bigcommerce/api/utils/concat-cookie.ts | 14 - .../api/utils/create-api-handler.ts | 58 - lib/bigcommerce/api/utils/errors.ts | 25 - .../api/utils/fetch-graphql-api.ts | 38 - lib/bigcommerce/api/utils/fetch-store-api.ts | 71 - lib/bigcommerce/api/utils/fetch.ts | 3 - lib/bigcommerce/api/utils/filter-edges.ts | 5 - lib/bigcommerce/api/utils/get-cart-cookie.ts | 20 - .../api/utils/is-allowed-method.ts | 28 - lib/bigcommerce/api/utils/parse-item.ts | 13 - .../api/utils/set-product-locale-meta.ts | 21 - lib/bigcommerce/api/utils/types.ts | 7 - .../api/wishlist/handlers/add-item.ts | 56 - .../api/wishlist/handlers/get-wishlist.ts | 35 - .../api/wishlist/handlers/remove-item.ts | 39 - lib/bigcommerce/api/wishlist/index.ts | 94 - lib/bigcommerce/cart/use-add-item.tsx | 56 - lib/bigcommerce/cart/use-cart-actions.tsx | 13 - lib/bigcommerce/cart/use-cart.tsx | 50 - lib/bigcommerce/cart/use-remove-item.tsx | 51 - lib/bigcommerce/cart/use-update-item.tsx | 70 - lib/bigcommerce/index.tsx | 60 - lib/bigcommerce/products/use-search.tsx | 64 - lib/bigcommerce/schema.d.ts | 1970 ----------- lib/bigcommerce/schema.graphql | 2422 ------------- .../scripts/generate-definitions.js | 49 - lib/bigcommerce/use-customer.tsx | 38 - lib/bigcommerce/use-login.tsx | 54 - lib/bigcommerce/use-logout.tsx | 38 - lib/bigcommerce/use-price.tsx | 2 - lib/bigcommerce/use-signup.tsx | 54 - lib/bigcommerce/wishlist/use-add-item.tsx | 57 - lib/bigcommerce/wishlist/use-remove-item.tsx | 61 - .../wishlist/use-wishlist-actions.tsx | 11 - lib/bigcommerce/wishlist/use-wishlist.tsx | 55 - lib/commerce/api/index.ts | 36 - lib/commerce/cart/use-add-item.tsx | 5 - lib/commerce/cart/use-cart-actions.tsx | 17 - lib/commerce/cart/use-cart.tsx | 31 - lib/commerce/cart/use-remove-item.tsx | 5 - lib/commerce/cart/use-update-item.tsx | 5 - lib/commerce/index.tsx | 51 - lib/commerce/products/use-search.tsx | 5 - lib/commerce/use-customer.tsx | 5 - lib/commerce/use-login.tsx | 5 - lib/commerce/use-logout.tsx | 5 - lib/commerce/use-price.tsx | 64 - lib/commerce/use-signup.tsx | 5 - lib/commerce/utils/errors.ts | 40 - lib/commerce/utils/types.ts | 24 - lib/commerce/utils/use-action.tsx | 15 - lib/commerce/utils/use-data.tsx | 60 - lib/commerce/wishlist/use-add-item.tsx | 5 - lib/commerce/wishlist/use-remove-item.tsx | 5 - lib/commerce/wishlist/use-wishlist.tsx | 17 - 86 files changed, 11235 deletions(-) delete mode 100644 lib/bigcommerce/api/cart/handlers/add-item.ts delete mode 100644 lib/bigcommerce/api/cart/handlers/get-cart.ts delete mode 100644 lib/bigcommerce/api/cart/handlers/remove-item.ts delete mode 100644 lib/bigcommerce/api/cart/handlers/update-item.ts delete mode 100644 lib/bigcommerce/api/cart/index.ts delete mode 100644 lib/bigcommerce/api/catalog/handlers/get-products.ts delete mode 100644 lib/bigcommerce/api/catalog/products.ts delete mode 100644 lib/bigcommerce/api/checkout.ts delete mode 100644 lib/bigcommerce/api/customers/handlers/get-logged-in-customer.ts delete mode 100644 lib/bigcommerce/api/customers/handlers/login.ts delete mode 100644 lib/bigcommerce/api/customers/handlers/logout.ts delete mode 100644 lib/bigcommerce/api/customers/handlers/signup.ts delete mode 100644 lib/bigcommerce/api/customers/index.ts delete mode 100644 lib/bigcommerce/api/customers/login.ts delete mode 100644 lib/bigcommerce/api/customers/logout.ts delete mode 100644 lib/bigcommerce/api/customers/signup.ts delete mode 100644 lib/bigcommerce/api/definitions/catalog.ts delete mode 100644 lib/bigcommerce/api/definitions/store-content.ts delete mode 100644 lib/bigcommerce/api/definitions/wishlist.ts delete mode 100644 lib/bigcommerce/api/fragments/category-tree.ts delete mode 100644 lib/bigcommerce/api/fragments/product.ts delete mode 100644 lib/bigcommerce/api/index.ts delete mode 100644 lib/bigcommerce/api/operations/get-all-pages.ts delete mode 100644 lib/bigcommerce/api/operations/get-all-product-paths.ts delete mode 100644 lib/bigcommerce/api/operations/get-all-products.ts delete mode 100644 lib/bigcommerce/api/operations/get-customer-id.ts delete mode 100644 lib/bigcommerce/api/operations/get-customer-wishlist.ts delete mode 100644 lib/bigcommerce/api/operations/get-page.ts delete mode 100644 lib/bigcommerce/api/operations/get-product.ts delete mode 100644 lib/bigcommerce/api/operations/get-site-info.ts delete mode 100644 lib/bigcommerce/api/operations/login.ts delete mode 100644 lib/bigcommerce/api/utils/concat-cookie.ts delete mode 100644 lib/bigcommerce/api/utils/create-api-handler.ts delete mode 100644 lib/bigcommerce/api/utils/errors.ts delete mode 100644 lib/bigcommerce/api/utils/fetch-graphql-api.ts delete mode 100644 lib/bigcommerce/api/utils/fetch-store-api.ts delete mode 100644 lib/bigcommerce/api/utils/fetch.ts delete mode 100644 lib/bigcommerce/api/utils/filter-edges.ts delete mode 100644 lib/bigcommerce/api/utils/get-cart-cookie.ts delete mode 100644 lib/bigcommerce/api/utils/is-allowed-method.ts delete mode 100644 lib/bigcommerce/api/utils/parse-item.ts delete mode 100644 lib/bigcommerce/api/utils/set-product-locale-meta.ts delete mode 100644 lib/bigcommerce/api/utils/types.ts delete mode 100644 lib/bigcommerce/api/wishlist/handlers/add-item.ts delete mode 100644 lib/bigcommerce/api/wishlist/handlers/get-wishlist.ts delete mode 100644 lib/bigcommerce/api/wishlist/handlers/remove-item.ts delete mode 100644 lib/bigcommerce/api/wishlist/index.ts delete mode 100644 lib/bigcommerce/cart/use-add-item.tsx delete mode 100644 lib/bigcommerce/cart/use-cart-actions.tsx delete mode 100644 lib/bigcommerce/cart/use-cart.tsx delete mode 100644 lib/bigcommerce/cart/use-remove-item.tsx delete mode 100644 lib/bigcommerce/cart/use-update-item.tsx delete mode 100644 lib/bigcommerce/index.tsx delete mode 100644 lib/bigcommerce/products/use-search.tsx delete mode 100644 lib/bigcommerce/schema.d.ts delete mode 100644 lib/bigcommerce/schema.graphql delete mode 100644 lib/bigcommerce/scripts/generate-definitions.js delete mode 100644 lib/bigcommerce/use-customer.tsx delete mode 100644 lib/bigcommerce/use-login.tsx delete mode 100644 lib/bigcommerce/use-logout.tsx delete mode 100644 lib/bigcommerce/use-price.tsx delete mode 100644 lib/bigcommerce/use-signup.tsx delete mode 100644 lib/bigcommerce/wishlist/use-add-item.tsx delete mode 100644 lib/bigcommerce/wishlist/use-remove-item.tsx delete mode 100644 lib/bigcommerce/wishlist/use-wishlist-actions.tsx delete mode 100644 lib/bigcommerce/wishlist/use-wishlist.tsx delete mode 100644 lib/commerce/api/index.ts delete mode 100644 lib/commerce/cart/use-add-item.tsx delete mode 100644 lib/commerce/cart/use-cart-actions.tsx delete mode 100644 lib/commerce/cart/use-cart.tsx delete mode 100644 lib/commerce/cart/use-remove-item.tsx delete mode 100644 lib/commerce/cart/use-update-item.tsx delete mode 100644 lib/commerce/index.tsx delete mode 100644 lib/commerce/products/use-search.tsx delete mode 100644 lib/commerce/use-customer.tsx delete mode 100644 lib/commerce/use-login.tsx delete mode 100644 lib/commerce/use-logout.tsx delete mode 100644 lib/commerce/use-price.tsx delete mode 100644 lib/commerce/use-signup.tsx delete mode 100644 lib/commerce/utils/errors.ts delete mode 100644 lib/commerce/utils/types.ts delete mode 100644 lib/commerce/utils/use-action.tsx delete mode 100644 lib/commerce/utils/use-data.tsx delete mode 100644 lib/commerce/wishlist/use-add-item.tsx delete mode 100644 lib/commerce/wishlist/use-remove-item.tsx delete mode 100644 lib/commerce/wishlist/use-wishlist.tsx diff --git a/lib/bigcommerce/api/cart/handlers/add-item.ts b/lib/bigcommerce/api/cart/handlers/add-item.ts deleted file mode 100644 index c37abeb63..000000000 --- a/lib/bigcommerce/api/cart/handlers/add-item.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { parseCartItem } from '../../utils/parse-item' -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -// Return current cart info -const addItem: CartHandlers['addItem'] = async ({ - res, - body: { cartId, item }, - config, -}) => { - if (!item) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Missing item' }], - }) - } - if (!item.quantity) item.quantity = 1 - - const options = { - method: 'POST', - body: JSON.stringify({ - line_items: [parseCartItem(item)], - }), - } - const { data } = cartId - ? await config.storeApiFetch(`/v3/carts/${cartId}/items`, options) - : await config.storeApiFetch('/v3/carts', options) - - // Create or update the cart cookie - res.setHeader( - 'Set-Cookie', - getCartCookie(config.cartCookie, data.id, config.cartCookieMaxAge) - ) - res.status(200).json({ data }) -} - -export default addItem diff --git a/lib/bigcommerce/api/cart/handlers/get-cart.ts b/lib/bigcommerce/api/cart/handlers/get-cart.ts deleted file mode 100644 index 9fb42d730..000000000 --- a/lib/bigcommerce/api/cart/handlers/get-cart.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { BigcommerceApiError } from '../../utils/errors' -import getCartCookie from '../../utils/get-cart-cookie' -import type { Cart, CartHandlers } from '..' - -// Return current cart info -const getCart: CartHandlers['getCart'] = async ({ - res, - body: { cartId }, - config, -}) => { - let result: { data?: Cart } = {} - - if (cartId) { - try { - result = await config.storeApiFetch(`/v3/carts/${cartId}`) - } catch (error) { - if (error instanceof BigcommerceApiError && error.status === 404) { - // Remove the cookie if it exists but the cart wasn't found - res.setHeader('Set-Cookie', getCartCookie(config.cartCookie)) - } else { - throw error - } - } - } - - res.status(200).json({ data: result.data ?? null }) -} - -export default getCart diff --git a/lib/bigcommerce/api/cart/handlers/remove-item.ts b/lib/bigcommerce/api/cart/handlers/remove-item.ts deleted file mode 100644 index 2ee5dbe16..000000000 --- a/lib/bigcommerce/api/cart/handlers/remove-item.ts +++ /dev/null @@ -1,34 +0,0 @@ -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -// Return current cart info -const removeItem: CartHandlers['removeItem'] = async ({ - res, - body: { cartId, itemId }, - config, -}) => { - if (!cartId || !itemId) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - - const result = await config.storeApiFetch<{ data: any } | null>( - `/v3/carts/${cartId}/items/${itemId}`, - { method: 'DELETE' } - ) - const data = result?.data ?? null - - res.setHeader( - 'Set-Cookie', - data - ? // Update the cart cookie - getCartCookie(config.cartCookie, cartId, config.cartCookieMaxAge) - : // Remove the cart cookie if the cart was removed (empty items) - getCartCookie(config.cartCookie) - ) - res.status(200).json({ data }) -} - -export default removeItem diff --git a/lib/bigcommerce/api/cart/handlers/update-item.ts b/lib/bigcommerce/api/cart/handlers/update-item.ts deleted file mode 100644 index c64c111df..000000000 --- a/lib/bigcommerce/api/cart/handlers/update-item.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { parseCartItem } from '../../utils/parse-item' -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -// Return current cart info -const updateItem: CartHandlers['updateItem'] = async ({ - res, - body: { cartId, itemId, item }, - config, -}) => { - if (!cartId || !itemId || !item) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - - const { data } = await config.storeApiFetch( - `/v3/carts/${cartId}/items/${itemId}`, - { - method: 'PUT', - body: JSON.stringify({ - line_item: parseCartItem(item), - }), - } - ) - - // Update the cart cookie - res.setHeader( - 'Set-Cookie', - getCartCookie(config.cartCookie, cartId, config.cartCookieMaxAge) - ) - res.status(200).json({ data }) -} - -export default updateItem diff --git a/lib/bigcommerce/api/cart/index.ts b/lib/bigcommerce/api/cart/index.ts deleted file mode 100644 index c8a4913d6..000000000 --- a/lib/bigcommerce/api/cart/index.ts +++ /dev/null @@ -1,110 +0,0 @@ -import isAllowedMethod from '../utils/is-allowed-method' -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import { BigcommerceApiError } from '../utils/errors' -import getCart from './handlers/get-cart' -import addItem from './handlers/add-item' -import updateItem from './handlers/update-item' -import removeItem from './handlers/remove-item' - -export type ItemBody = { - productId: number - variantId: number - quantity?: number -} - -export type AddItemBody = { item: ItemBody } - -export type UpdateItemBody = { itemId: string; item: ItemBody } - -export type RemoveItemBody = { itemId: string } - -// TODO: this type should match: -// https://developer.bigcommerce.com/api-reference/cart-checkout/server-server-cart-api/cart/getacart#responses -export type Cart = { - id: string - parent_id?: string - customer_id: number - email: string - currency: { code: string } - tax_included: boolean - base_amount: number - discount_amount: number - cart_amount: number - line_items: { - custom_items: any[] - digital_items: any[] - gift_certificates: any[] - physical_items: any[] - } - // TODO: add missing fields -} - -export type CartHandlers = { - getCart: BigcommerceHandler - addItem: BigcommerceHandler> - updateItem: BigcommerceHandler< - Cart, - { cartId?: string } & Partial - > - removeItem: BigcommerceHandler< - Cart, - { cartId?: string } & Partial - > -} - -const METHODS = ['GET', 'POST', 'PUT', 'DELETE'] - -// TODO: a complete implementation should have schema validation for `req.body` -const cartApi: BigcommerceApiHandler = async ( - req, - res, - config, - handlers -) => { - if (!isAllowedMethod(req, res, METHODS)) return - - const { cookies } = req - const cartId = cookies[config.cartCookie] - - try { - // Return current cart info - if (req.method === 'GET') { - const body = { cartId } - return await handlers['getCart']({ req, res, config, body }) - } - - // Create or add an item to the cart - if (req.method === 'POST') { - const body = { ...req.body, cartId } - return await handlers['addItem']({ req, res, config, body }) - } - - // Update item in cart - if (req.method === 'PUT') { - const body = { ...req.body, cartId } - return await handlers['updateItem']({ req, res, config, body }) - } - - // Remove an item from the cart - if (req.method === 'DELETE') { - const body = { ...req.body, cartId } - return await handlers['removeItem']({ req, res, config, body }) - } - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -export const handlers = { getCart, addItem, updateItem, removeItem } - -export default createApiHandler(cartApi, handlers, {}) diff --git a/lib/bigcommerce/api/catalog/handlers/get-products.ts b/lib/bigcommerce/api/catalog/handlers/get-products.ts deleted file mode 100644 index b05548e40..000000000 --- a/lib/bigcommerce/api/catalog/handlers/get-products.ts +++ /dev/null @@ -1,73 +0,0 @@ -import getAllProducts, { ProductEdge } from '../../operations/get-all-products' -import type { ProductsHandlers } from '../products' - -const SORT: { [key: string]: string | undefined } = { - latest: 'id', - trending: 'total_sold', - price: 'price', -} -const LIMIT = 12 - -// Return current cart info -const getProducts: ProductsHandlers['getProducts'] = async ({ - res, - body: { search, category, brand, sort }, - config, -}) => { - // Use a dummy base as we only care about the relative path - const url = new URL('/v3/catalog/products', 'http://a') - - url.searchParams.set('is_visible', 'true') - url.searchParams.set('limit', String(LIMIT)) - - if (search) url.searchParams.set('keyword', search) - - if (category && Number.isInteger(Number(category))) - url.searchParams.set('categories:in', category) - - if (brand && Number.isInteger(Number(brand))) - url.searchParams.set('brand_id', brand) - - if (sort) { - const [_sort, direction] = sort.split('-') - const sortValue = SORT[_sort] - - if (sortValue && direction) { - url.searchParams.set('sort', sortValue) - url.searchParams.set('direction', direction) - } - } - - // We only want the id of each product - url.searchParams.set('include_fields', 'id') - - const { data } = await config.storeApiFetch<{ data: { id: number }[] }>( - url.pathname + url.search - ) - const entityIds = data.map((p) => p.id) - const found = entityIds.length > 0 - // We want the GraphQL version of each product - const graphqlData = await getAllProducts({ - variables: { first: LIMIT, entityIds }, - config, - }) - // Put the products in an object that we can use to get them by id - const productsById = graphqlData.products.reduce<{ - [k: number]: ProductEdge - }>((prods, p) => { - prods[p.node.entityId] = p - return prods - }, {}) - const products: ProductEdge[] = found ? [] : graphqlData.products - - // Populate the products array with the graphql products, in the order - // assigned by the list of entity ids - entityIds.forEach((id) => { - const product = productsById[id] - if (product) products.push(product) - }) - - res.status(200).json({ data: { products, found } }) -} - -export default getProducts diff --git a/lib/bigcommerce/api/catalog/products.ts b/lib/bigcommerce/api/catalog/products.ts deleted file mode 100644 index 0e3690e55..000000000 --- a/lib/bigcommerce/api/catalog/products.ts +++ /dev/null @@ -1,48 +0,0 @@ -import isAllowedMethod from '../utils/is-allowed-method' -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import { BigcommerceApiError } from '../utils/errors' -import type { ProductEdge } from '../operations/get-all-products' -import getProducts from './handlers/get-products' - -export type SearchProductsData = { - products: ProductEdge[] - found: boolean -} - -export type ProductsHandlers = { - getProducts: BigcommerceHandler< - SearchProductsData, - { search?: 'string'; category?: string; brand?: string; sort?: string } - > -} - -const METHODS = ['GET'] - -// TODO: a complete implementation should have schema validation for `req.body` -const productsApi: BigcommerceApiHandler< - SearchProductsData, - ProductsHandlers -> = async (req, res, config, handlers) => { - if (!isAllowedMethod(req, res, METHODS)) return - - try { - const body = req.query - return await handlers['getProducts']({ req, res, config, body }) - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -export const handlers = { getProducts } - -export default createApiHandler(productsApi, handlers, {}) diff --git a/lib/bigcommerce/api/checkout.ts b/lib/bigcommerce/api/checkout.ts deleted file mode 100644 index aab7c0d7a..000000000 --- a/lib/bigcommerce/api/checkout.ts +++ /dev/null @@ -1,76 +0,0 @@ -import isAllowedMethod from './utils/is-allowed-method' -import createApiHandler, { - BigcommerceApiHandler, -} from './utils/create-api-handler' -import { BigcommerceApiError } from './utils/errors' - -const METHODS = ['GET'] -const fullCheckout = true - -// TODO: a complete implementation should have schema validation for `req.body` -const checkoutApi: BigcommerceApiHandler = async (req, res, config) => { - if (!isAllowedMethod(req, res, METHODS)) return - - const { cookies } = req - const cartId = cookies[config.cartCookie] - - try { - if (!cartId) { - return res.status(404).end() - } - - const { data } = await config.storeApiFetch( - `/v3/carts/${cartId}/redirect_urls`, - { - method: 'POST', - } - ) - - if (fullCheckout) { - res.redirect(data.checkout_url) - return - } - - // TODO: make the embedded checkout work too! - const html = ` - - - - - - Checkout - - - - -
- - - ` - - res.status(200) - res.setHeader('Content-Type', 'text/html') - res.write(html) - res.end() - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -export default createApiHandler(checkoutApi, {}, {}) diff --git a/lib/bigcommerce/api/customers/handlers/get-logged-in-customer.ts b/lib/bigcommerce/api/customers/handlers/get-logged-in-customer.ts deleted file mode 100644 index 698235dda..000000000 --- a/lib/bigcommerce/api/customers/handlers/get-logged-in-customer.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { GetLoggedInCustomerQuery } from '../../../schema' -import type { CustomersHandlers } from '..' - -export const getLoggedInCustomerQuery = /* GraphQL */ ` - query getLoggedInCustomer { - customer { - entityId - firstName - lastName - email - company - customerGroupId - notes - phone - addressCount - attributeCount - storeCredit { - value - currencyCode - } - } - } -` - -export type Customer = NonNullable - -const getLoggedInCustomer: CustomersHandlers['getLoggedInCustomer'] = async ({ - req, - res, - config, -}) => { - const token = req.cookies[config.customerCookie] - - if (token) { - const { data } = await config.fetch( - getLoggedInCustomerQuery, - undefined, - { - headers: { - cookie: `${config.customerCookie}=${token}`, - }, - } - ) - const { customer } = data - - if (!customer) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Customer not found', code: 'not_found' }], - }) - } - - return res.status(200).json({ data: { customer } }) - } - - res.status(200).json({ data: null }) -} - -export default getLoggedInCustomer diff --git a/lib/bigcommerce/api/customers/handlers/login.ts b/lib/bigcommerce/api/customers/handlers/login.ts deleted file mode 100644 index d280a88d8..000000000 --- a/lib/bigcommerce/api/customers/handlers/login.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { FetcherError } from '../../../../commerce/utils/errors' -import login from '../../operations/login' -import type { LoginHandlers } from '../login' - -const invalidCredentials = /invalid credentials/i - -const loginHandler: LoginHandlers['login'] = async ({ - res, - body: { email, password }, - config, -}) => { - // TODO: Add proper validations with something like Ajv - if (!(email && password)) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - // TODO: validate the password and email - // Passwords must be at least 7 characters and contain both alphabetic - // and numeric characters. - - try { - await login({ variables: { email, password }, config, res }) - } catch (error) { - // Check if the email and password didn't match an existing account - if ( - error instanceof FetcherError && - invalidCredentials.test(error.message) - ) { - return res.status(401).json({ - data: null, - errors: [ - { - message: - 'Cannot find an account that matches the provided credentials', - code: 'invalid_credentials', - }, - ], - }) - } - - throw error - } - - res.status(200).json({ data: null }) -} - -export default loginHandler diff --git a/lib/bigcommerce/api/customers/handlers/logout.ts b/lib/bigcommerce/api/customers/handlers/logout.ts deleted file mode 100644 index 937ce0954..000000000 --- a/lib/bigcommerce/api/customers/handlers/logout.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { serialize } from 'cookie' -import { LogoutHandlers } from '../logout' - -const logoutHandler: LogoutHandlers['logout'] = async ({ - res, - body: { redirectTo }, - config, -}) => { - // Remove the cookie - res.setHeader( - 'Set-Cookie', - serialize(config.customerCookie, '', { maxAge: -1, path: '/' }) - ) - - // Only allow redirects to a relative URL - if (redirectTo?.startsWith('/')) { - res.redirect(redirectTo) - } else { - res.status(200).json({ data: null }) - } -} - -export default logoutHandler diff --git a/lib/bigcommerce/api/customers/handlers/signup.ts b/lib/bigcommerce/api/customers/handlers/signup.ts deleted file mode 100644 index ff45adadb..000000000 --- a/lib/bigcommerce/api/customers/handlers/signup.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { BigcommerceApiError } from '../../utils/errors' -import login from '../../operations/login' -import { SignupHandlers } from '../signup' - -const signup: SignupHandlers['signup'] = async ({ - res, - body: { firstName, lastName, email, password }, - config, -}) => { - // TODO: Add proper validations with something like Ajv - if (!(firstName && lastName && email && password)) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - // TODO: validate the password and email - // Passwords must be at least 7 characters and contain both alphabetic - // and numeric characters. - - try { - await config.storeApiFetch('/v3/customers', { - method: 'POST', - body: JSON.stringify([ - { - first_name: firstName, - last_name: lastName, - email, - authentication: { - new_password: password, - }, - }, - ]), - }) - } catch (error) { - if (error instanceof BigcommerceApiError && error.status === 422) { - const hasEmailError = '0.email' in error.data?.errors - - // If there's an error with the email, it most likely means it's duplicated - if (hasEmailError) { - return res.status(400).json({ - data: null, - errors: [ - { - message: 'The email is already in use', - code: 'duplicated_email', - }, - ], - }) - } - } - - throw error - } - - // Login the customer right after creating it - await login({ variables: { email, password }, res, config }) - - res.status(200).json({ data: null }) -} - -export default signup diff --git a/lib/bigcommerce/api/customers/index.ts b/lib/bigcommerce/api/customers/index.ts deleted file mode 100644 index 5af4d1d1d..000000000 --- a/lib/bigcommerce/api/customers/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import isAllowedMethod from '../utils/is-allowed-method' -import { BigcommerceApiError } from '../utils/errors' -import getLoggedInCustomer, { - Customer, -} from './handlers/get-logged-in-customer' - -export type { Customer } - -export type CustomerData = { - customer: Customer -} - -export type CustomersHandlers = { - getLoggedInCustomer: BigcommerceHandler -} - -const METHODS = ['GET'] - -const customersApi: BigcommerceApiHandler< - CustomerData, - CustomersHandlers -> = async (req, res, config, handlers) => { - if (!isAllowedMethod(req, res, METHODS)) return - - try { - const body = null - return await handlers['getLoggedInCustomer']({ req, res, config, body }) - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -const handlers = { getLoggedInCustomer } - -export default createApiHandler(customersApi, handlers, {}) diff --git a/lib/bigcommerce/api/customers/login.ts b/lib/bigcommerce/api/customers/login.ts deleted file mode 100644 index e8f24a92d..000000000 --- a/lib/bigcommerce/api/customers/login.ts +++ /dev/null @@ -1,45 +0,0 @@ -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import isAllowedMethod from '../utils/is-allowed-method' -import { BigcommerceApiError } from '../utils/errors' -import login from './handlers/login' - -export type LoginBody = { - email: string - password: string -} - -export type LoginHandlers = { - login: BigcommerceHandler> -} - -const METHODS = ['POST'] - -const loginApi: BigcommerceApiHandler = async ( - req, - res, - config, - handlers -) => { - if (!isAllowedMethod(req, res, METHODS)) return - - try { - const body = req.body ?? {} - return await handlers['login']({ req, res, config, body }) - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -const handlers = { login } - -export default createApiHandler(loginApi, handlers, {}) diff --git a/lib/bigcommerce/api/customers/logout.ts b/lib/bigcommerce/api/customers/logout.ts deleted file mode 100644 index 0a4965245..000000000 --- a/lib/bigcommerce/api/customers/logout.ts +++ /dev/null @@ -1,42 +0,0 @@ -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import isAllowedMethod from '../utils/is-allowed-method' -import { BigcommerceApiError } from '../utils/errors' -import logout from './handlers/logout' - -export type LogoutHandlers = { - logout: BigcommerceHandler -} - -const METHODS = ['GET'] - -const logoutApi: BigcommerceApiHandler = async ( - req, - res, - config, - handlers -) => { - if (!isAllowedMethod(req, res, METHODS)) return - - try { - const redirectTo = req.query.redirect_to - const body = typeof redirectTo === 'string' ? { redirectTo } : {} - - return await handlers['logout']({ req, res, config, body }) - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -const handlers = { logout } - -export default createApiHandler(logoutApi, handlers, {}) diff --git a/lib/bigcommerce/api/customers/signup.ts b/lib/bigcommerce/api/customers/signup.ts deleted file mode 100644 index aa26f78cf..000000000 --- a/lib/bigcommerce/api/customers/signup.ts +++ /dev/null @@ -1,50 +0,0 @@ -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import isAllowedMethod from '../utils/is-allowed-method' -import { BigcommerceApiError } from '../utils/errors' -import signup from './handlers/signup' - -export type SignupBody = { - firstName: string - lastName: string - email: string - password: string -} - -export type SignupHandlers = { - signup: BigcommerceHandler> -} - -const METHODS = ['POST'] - -const signupApi: BigcommerceApiHandler = async ( - req, - res, - config, - handlers -) => { - if (!isAllowedMethod(req, res, METHODS)) return - - const { cookies } = req - const cartId = cookies[config.cartCookie] - - try { - const body = { ...req.body, cartId } - return await handlers['signup']({ req, res, config, body }) - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -const handlers = { signup } - -export default createApiHandler(signupApi, handlers, {}) diff --git a/lib/bigcommerce/api/definitions/catalog.ts b/lib/bigcommerce/api/definitions/catalog.ts deleted file mode 100644 index 2c483f781..000000000 --- a/lib/bigcommerce/api/definitions/catalog.ts +++ /dev/null @@ -1,2993 +0,0 @@ -/** - * This file was auto-generated by swagger-to-ts. - * Do not make direct changes to the file. - */ - -export interface definitions { - /** - * Common Modifier properties. - */ - productModifier_Base: { - /** - * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. - */ - type: - | 'date' - | 'checkbox' - | 'file' - | 'text' - | 'multi_line_text' - | 'numbers_only_text' - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - /** - * Whether or not this modifer is required or not at checkout. Required in a /POST. - */ - required: boolean - /** - * The order the modifiers display on the product detail page. - */ - sort_order?: number - config?: definitions['config_Full'] - /** - * The name of the option shown on the storefront. - */ - display_name?: string - } - /** - * Product Modifier - */ - productModifier_Full: definitions['productModifier_Base'] & { - /** - * The unique numeric ID of the modifier; increments sequentially. - */ - id?: number - /** - * The unique numeric ID of the product to which the option belongs. - */ - product_id?: number - /** - * The unique option name. Auto-generated from the display name, a timestamp, and the product ID. - */ - name?: string - option_values?: definitions['productModifierOptionValue_Full'][] - } - /** - * The model for a POST to create a modifier on a product. - */ - productModifier_Post: { - /** - * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. - */ - type: - | 'date' - | 'checkbox' - | 'file' - | 'text' - | 'multi_line_text' - | 'numbers_only_text' - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - /** - * Whether or not this modifer is required or not at checkout. Required in a /POST. - */ - required: boolean - /** - * The order the modifiers display on the product detail page. - */ - sort_order?: number - /** - * The values for option config can vary based on the Modifier created. - */ - config?: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - option_values?: (({ - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - adjusters?: { - /** - * Adjuster for Complex Rules. - */ - price?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * Adjuster for Complex Rules. - */ - weight?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. - */ - image_url?: string - purchasing_disabled?: { - /** - * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. - */ - status?: boolean - /** - * The message displayed on the storefront when the purchasing disabled status is `true`. - */ - message?: string - } - } - }) & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - })[] - } & { - /** - * The name of the option shown on the storefront. - */ - display_name: string - } - /** - * The model for a PUT to update a modifier on a product. - */ - productModifier_Put: { - /** - * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. - */ - type: - | 'date' - | 'checkbox' - | 'file' - | 'text' - | 'multi_line_text' - | 'numbers_only_text' - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - /** - * Whether or not this modifer is required or not at checkout. Required in a /POST. - */ - required: boolean - /** - * The order the modifiers display on the product detail page. - */ - sort_order?: number - /** - * The values for option config can vary based on the Modifier created. - */ - config?: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - option_values?: (({ - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - adjusters?: { - /** - * Adjuster for Complex Rules. - */ - price?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * Adjuster for Complex Rules. - */ - weight?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. - */ - image_url?: string - purchasing_disabled?: { - /** - * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. - */ - status?: boolean - /** - * The message displayed on the storefront when the purchasing disabled status is `true`. - */ - message?: string - } - } - }) & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - })[] - } - /** - * Common Product Modifer `option_value` properties. - */ - productModifierOptionValue_Base: { - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. If no data is available, returns `null`. - */ - value_data?: { [key: string]: any } - adjusters?: definitions['adjusters_Full'] - } - /** - * Product Modifer `option_value`. - */ - productModifierOptionValue_Full: definitions['productModifierOptionValue_Base'] & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - option_id?: number - } - /** - * The model for a POST to create a modifier value on a product. - */ - productModifierOptionValue_Post: { - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - adjusters?: { - /** - * Adjuster for Complex Rules. - */ - price?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * Adjuster for Complex Rules. - */ - weight?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. - */ - image_url?: string - purchasing_disabled?: { - /** - * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. - */ - status?: boolean - /** - * The message displayed on the storefront when the purchasing disabled status is `true`. - */ - message?: string - } - } - } - /** - * The model for a PUT to update a modifier value on a product. - */ - productModifierOptionValue_Put: ({ - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - adjusters?: { - /** - * Adjuster for Complex Rules. - */ - price?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * Adjuster for Complex Rules. - */ - weight?: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. - */ - image_url?: string - purchasing_disabled?: { - /** - * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. - */ - status?: boolean - /** - * The message displayed on the storefront when the purchasing disabled status is `true`. - */ - message?: string - } - } - }) & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - } - resp_productionOption: { - data?: definitions['productOption_Full'] - /** - * Empty meta object; may be used later. - */ - meta?: { ''?: string } - } - /** - * Common Option properties. - */ - productOption_Base: { - /** - * The unique numerical ID of the option, increments sequentially. - */ - id?: number - /** - * The unique numerical ID of the product to which the option belongs. - */ - product_id?: number - /** - * The name of the option shown on the storefront. - */ - display_name?: string - /** - * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. - */ - type?: - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - config?: definitions['productOptionConfig_Full'] - /** - * Order in which the option is displayed on the storefront. - */ - sort_order?: number - option_values?: definitions['productOptionOptionValue_Full'] - } - productOption_Full: definitions['productOption_Base'] & { - /** - * The unique option name, auto-generated from the display name, a timestamp, and the product ID. - */ - name?: string - } - /** - * The model for a POST to create options on a product. - */ - productOption_Post: { - /** - * The unique numerical ID of the option, increments sequentially. - */ - id?: number - /** - * The unique numerical ID of the product to which the option belongs. - */ - product_id?: number - /** - * The name of the option shown on the storefront. - */ - display_name?: string - /** - * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. - */ - type?: - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - /** - * The values for option config can vary based on the Modifier created. - */ - config?: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - /** - * Order in which the option is displayed on the storefront. - */ - sort_order?: number - option_values?: ({ - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - })[] - /** - * Publicly available image url - */ - image_url?: string - } - /** - * The model for a PUT to update options on a product. - */ - productOption_Put: { - /** - * The unique numerical ID of the option, increments sequentially. - */ - id?: number - /** - * The unique numerical ID of the product to which the option belongs. - */ - product_id?: number - /** - * The name of the option shown on the storefront. - */ - display_name?: string - /** - * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. - */ - type?: - | 'radio_buttons' - | 'rectangles' - | 'dropdown' - | 'product_list' - | 'product_list_with_images' - | 'swatch' - /** - * The values for option config can vary based on the Modifier created. - */ - config?: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - /** - * Order in which the option is displayed on the storefront. - */ - sort_order?: number - option_values?: ({ - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - })[] - /** - * Publicly available image url - */ - image_url?: string - } - /** - * Returns the categories tree, a nested lineage of the categories with parent->child relationship. The Category objects returned are simplified versions of the category objects returned in the rest of this API. - */ - categoriesTree_Resp: { - data?: definitions['categoriesTreeNode_Full'][] - meta?: definitions['metaEmpty_Full'] - } - /** - * Used to reflect parent <> child category relationships. Used by Category Tree. - */ - categoriesTreeNode_Full: { - /** - * The unique numeric ID of the category; increments sequentially. - */ - id?: number - /** - * The unique numeric ID of the category's parent. This field controls where the category sits in the tree of categories that organize the catalog. - */ - parent_id?: number - /** - * The name displayed for the category. Name is unique with respect to the category's siblings. - */ - name?: string - /** - * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the category will be displayed. If `false`, the category will be hidden from view. - */ - is_visible?: boolean - /** - * The custom URL for the category on the storefront. - */ - url?: string - /** - * The list of children of the category. - */ - children?: definitions['categoriesTreeNode_Full'][] - } - /** - * Common Category object properties. - */ - category_Full: { - /** - * Unique ID of the *Category*. Increments sequentially. - * Read-Only. - */ - id?: number - /** - * The unique numeric ID of the category's parent. This field controls where the category sits in the tree of categories that organize the catalog. - * Required in a POST if creating a child category. - */ - parent_id: number - /** - * The name displayed for the category. Name is unique with respect to the category's siblings. - * Required in a POST. - */ - name: string - /** - * The product description, which can include HTML formatting. - */ - description?: string - /** - * Number of views the category has on the storefront. - */ - views?: number - /** - * Priority this category will be given when included in the menu and category pages. The lower the number, the closer to the top of the results the category will be. - */ - sort_order?: number - /** - * Custom title for the category page. If not defined, the category name will be used as the meta title. - */ - page_title?: string - /** - * A comma-separated list of keywords that can be used to locate the category when searching the store. - */ - search_keywords?: string - /** - * Custom meta keywords for the category page. If not defined, the store's default keywords will be used. Must post as an array like: ["awesome","sauce"]. - */ - meta_keywords?: string[] - /** - * Custom meta description for the category page. If not defined, the store's default meta description will be used. - */ - meta_description?: string - /** - * A valid layout file. (Please refer to [this article](https://support.bigcommerce.com/articles/Public/Creating-Custom-Template-Files/) on creating category files.) This field is writable only for stores with a Blueprint theme applied. - */ - layout_file?: string - /** - * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the category will be displayed. If `false`, the category will be hidden from view. - */ - is_visible?: boolean - /** - * Determines how the products are sorted on category page load. - */ - default_product_sort?: - | 'use_store_settings' - | 'featured' - | 'newest' - | 'best_selling' - | 'alpha_asc' - | 'alpha_desc' - | 'avg_customer_review' - | 'price_asc' - | 'price_desc' - /** - * Image URL used for this category on the storefront. Images can be uploaded via form file post to `/categories/{categoryId}/image`, or by providing a publicly accessible URL in this field. - */ - image_url?: string - custom_url?: definitions['customUrl_Full'] - } - /** - * Common Brand properties. - */ - brand_Full: { - /** - * Unique ID of the *Brand*. Read-Only. - */ - id?: number - /** - * The name of the brand. Must be unique. - * Required in POST. - */ - name: string - /** - * The title shown in the browser while viewing the brand. - */ - page_title?: string - /** - * Comma-separated list of meta keywords to include in the HTML. - */ - meta_keywords?: string[] - /** - * A meta description to include. - */ - meta_description?: string - /** - * A comma-separated list of keywords that can be used to locate this brand. - */ - search_keywords?: string - /** - * Image URL used for this category on the storefront. Images can be uploaded via form file post to `/brands/{brandId}/image`, or by providing a publicly accessible URL in this field. - */ - image_url?: string - custom_url?: definitions['customUrl_Full'] - } - /** - * Common Variant properties. - */ - productVariant_Base: { - /** - * The cost price of the variant. Not affected by Price List prices. - */ - cost_price?: number - /** - * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. - */ - price?: number - /** - * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. - */ - sale_price?: number - /** - * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. - */ - retail_price?: number - /** - * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. - */ - weight?: number - /** - * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. - */ - width?: number - /** - * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. - */ - height?: number - /** - * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. - */ - depth?: number - /** - * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. - */ - is_free_shipping?: boolean - /** - * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * If `true`, this variant will not be purchasable on the storefront. - */ - purchasing_disabled?: boolean - /** - * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. - */ - purchasing_disabled_message?: string - /** - * The UPC code used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. - */ - inventory_level?: number - /** - * When the variant hits this inventory level, it is considered low stock. - */ - inventory_warning_level?: number - /** - * Identifies where in a warehouse the variant is located. - */ - bin_picking_number?: string - } - productVariant_Full: definitions['productVariant_Base'] & { - id?: number - product_id?: number - sku?: string - /** - * Read-only reference to v2 API's SKU ID. Null if it is a base variant. - */ - sku_id?: number - /** - * Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant. - */ - option_values?: definitions['productVariantOptionValue_Base'][] - /** - * The price of the variant as seen on the storefront. This price takes into account `sale_price` and any price adjustment rules that are applicable to this variant. - */ - calculated_price?: number - } - /** - * The model for a POST to create variants on a product. - */ - productVariant_Post: { - /** - * The cost price of the variant. Not affected by Price List prices. - */ - cost_price?: number - /** - * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. - */ - price?: number - /** - * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. - */ - sale_price?: number - /** - * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. - */ - retail_price?: number - /** - * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. - */ - weight?: number - /** - * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. - */ - width?: number - /** - * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. - */ - height?: number - /** - * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. - */ - depth?: number - /** - * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. - */ - is_free_shipping?: boolean - /** - * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * If `true`, this variant will not be purchasable on the storefront. - */ - purchasing_disabled?: boolean - /** - * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. - */ - purchasing_disabled_message?: string - /** - * The UPC code used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. - */ - inventory_level?: number - /** - * When the variant hits this inventory level, it is considered low stock. - */ - inventory_warning_level?: number - /** - * Identifies where in a warehouse the variant is located. - */ - bin_picking_number?: string - } & { - product_id?: number - sku?: string - /** - * Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant. - */ - option_values?: { id?: number; option_id?: number }[] - } - variantCollection_Put: definitions['productVariant_Full'][] - /** - * The model for a PUT to update variants on a product. - */ - variant_Put: { - /** - * The cost price of the variant. Not affected by Price List prices. - */ - cost_price?: number - /** - * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. - */ - price?: number - /** - * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. - */ - sale_price?: number - /** - * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. - */ - retail_price?: number - /** - * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. - */ - weight?: number - /** - * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. - */ - width?: number - /** - * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. - */ - height?: number - /** - * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. - */ - depth?: number - /** - * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. - */ - is_free_shipping?: boolean - /** - * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * If `true`, this variant will not be purchasable on the storefront. - */ - purchasing_disabled?: boolean - /** - * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. - */ - purchasing_disabled_message?: string - /** - * The UPC code used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. - */ - inventory_level?: number - /** - * When the variant hits this inventory level, it is considered low stock. - */ - inventory_warning_level?: number - /** - * Identifies where in a warehouse the variant is located. - */ - bin_picking_number?: string - } & { id?: number } - /** - * The model for a POST to create variants on a product. - */ - productVariant_Post_Product: definitions['productVariant_Base'] & { - sku?: string - option_values?: { - /** - * The name of the option. - */ - option_display_name?: string - /** - * The label of the option value. - */ - label?: string - }[] - } - /** - * The model for a PUT to update variants on a product. - */ - productVariant_Put_Product: { - /** - * The cost price of the variant. Not affected by Price List prices. - */ - cost_price?: number - /** - * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. - */ - price?: number - /** - * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. - */ - sale_price?: number - /** - * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. - */ - retail_price?: number - /** - * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. - */ - weight?: number - /** - * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. - */ - width?: number - /** - * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. - */ - height?: number - /** - * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. - */ - depth?: number - /** - * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. - */ - is_free_shipping?: boolean - /** - * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * If `true`, this variant will not be purchasable on the storefront. - */ - purchasing_disabled?: boolean - /** - * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. - */ - purchasing_disabled_message?: string - /** - * The UPC code used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. - */ - inventory_level?: number - /** - * When the variant hits this inventory level, it is considered low stock. - */ - inventory_warning_level?: number - /** - * Identifies where in a warehouse the variant is located. - */ - bin_picking_number?: string - product_id?: number - sku?: string - } - productVariantOptionValue_Full: { - /** - * The name of the option. - */ - option_display_name?: string - /** - * The label of the option value. - */ - label?: string - } & definitions['productVariantOptionValue_Base'] - /** - * The model for a POST to create option values on a product. - */ - productOptionValue_Post_Product: { - /** - * The name of the option. - */ - option_display_name?: string - /** - * The label of the option value. - */ - label?: string - } - /** - * Common Product Variant Option properties. - */ - productVariantOptionValue_Base: { id?: number; option_id?: number } - /** - * The model for a POST to create option values on a variant. - */ - productVariantOptionValue_Post: { id?: number; option_id?: number } - resp_productOptionValue: { - data?: definitions['productOptionOptionValue_Full'] - /** - * Empty meta object; may be used later. - */ - meta?: { ''?: string } - } - /** - * Common Product Option `option_value` properties. - */ - productOptionOptionValue_Base: { - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. If no data is available, returns `null`. - */ - value_data?: { [key: string]: any } - } - /** - * Product Option `option_value`. - */ - productOptionOptionValue_Full: definitions['productOptionOptionValue_Base'] & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - } - /** - * The model for a POST to create option values on a product. - */ - productOptionValue_Post: { - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } - /** - * The model for a PUT to update option values on a product. - */ - productOptionValue_Put: { - /** - * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. - */ - is_default?: boolean - /** - * The text display identifying the value on the storefront. Required in a /POST. - */ - label: string - /** - * The order in which the value will be displayed on the product page. Required in a /POST. - */ - sort_order: number - /** - * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. - */ - value_data?: { [key: string]: any } - } & { - /** - * The unique numeric ID of the value; increments sequentially. - */ - id?: number - } - /** - * Common ProductImage properties. - */ - productImage_Base: { - /** - * The local path to the original image file uploaded to BigCommerce. - */ - image_file?: string - /** - * Flag for identifying whether the image is used as the product's thumbnail. - */ - is_thumbnail?: boolean - /** - * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. - */ - sort_order?: number - /** - * The description for the image. - */ - description?: string - /** - * Must be a fully qualified URL path, including protocol. Limit of 8MB per file. - */ - image_url?: string - } - /** - * The model for a POST to create an image on a product. - */ - productImage_Post: { - /** - * The unique numeric ID of the image; increments sequentially. - */ - id?: number - /** - * The unique numeric identifier for the product with which the image is associated. - */ - product_id?: number - /** - * The local path to the original image file uploaded to BigCommerce. - */ - image_file?: string - /** - * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. - */ - url_zoom?: string - /** - * The standard URL for this image. By default, this is used for product-page images. - */ - url_standard?: string - /** - * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. - */ - url_thumbnail?: string - /** - * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. - */ - url_tiny?: string - /** - * The date on which the product image was modified. - */ - date_modified?: string - /** - * Flag for identifying whether the image is used as the product's thumbnail. - */ - is_thumbnail?: boolean - /** - * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. - */ - sort_order?: number - /** - * The description for the image. - */ - description?: string - } & { - /** - * Must be a fully qualified URL path, including protocol. Limit of 8MB per file. - */ - image_url?: string - /** - * Must be sent as a multipart/form-data field in the request body. - */ - image_file?: string - } - /** - * The model for a PUT to update applicable Product Image fields. - */ - productImage_Put: { - /** - * The unique numeric ID of the image; increments sequentially. - */ - id?: number - /** - * The unique numeric identifier for the product with which the image is associated. - */ - product_id?: number - /** - * The local path to the original image file uploaded to BigCommerce. - */ - image_file?: string - /** - * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. - */ - url_zoom?: string - /** - * The standard URL for this image. By default, this is used for product-page images. - */ - url_standard?: string - /** - * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. - */ - url_thumbnail?: string - /** - * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. - */ - url_tiny?: string - /** - * The date on which the product image was modified. - */ - date_modified?: string - /** - * Flag for identifying whether the image is used as the product's thumbnail. - */ - is_thumbnail?: boolean - /** - * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. - */ - sort_order?: number - /** - * The description for the image. - */ - description?: string - } - /** - * The model for a POST to create a video on a product. - */ - productVideo_Base: { - /** - * The title for the video. If left blank, this will be filled in according to data on a host site. - */ - title?: string - /** - * The description for the video. If left blank, this will be filled in according to data on a host site. - */ - description?: string - /** - * The order in which the video will be displayed on the product page. Higher integers give the video a lower priority. When updating, if the video is given a lower priority, all videos with a `sort_order` the same as or greater than the video's new `sort_order` value will have their `sort_order`s reordered. - */ - sort_order?: number - /** - * The video type (a short name of a host site). - */ - type?: 'youtube' - /** - * The ID of the video on a host site. - */ - video_id?: string - } - /** - * A product video model. - */ - productVideo_Full: definitions['productVideo_Base'] & { - /** - * The unique numeric ID of the product video; increments sequentially. - */ - id?: number - /** - * The unique numeric identifier for the product with which the image is associated. - */ - product_id?: number - /** - * Length of the video. This will be filled in according to data on a host site. - */ - length?: string - } - /** - * The model for a POST to create a video on a product. - */ - productVideo_Post: definitions['productVideo_Base'] - /** - * The model for a PUT to update a video on a product. - */ - productVideo_Put: definitions['productVideo_Base'] & { - /** - * The unique numeric ID of the product video; increments sequentially. - */ - id?: number - } - productReview_Base: { - /** - * The title for the product review. - * Required in /POST. - */ - title: string - /** - * The text for the product review. - */ - text?: string - /** - * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. - */ - status?: string - /** - * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. - */ - rating?: number - /** - * The email of the reviewer. Must be a valid email, or an empty string. - */ - email?: string - /** - * The name of the reviewer. - */ - name?: string - /** - * Date the product was reviewed. Required in /POST. - */ - date_reviewed: string - } - /** - * A product review model. - */ - productReview_Full: definitions['productReview_Base'] & { - /** - * The unique numeric ID of the product review; increments sequentially. - */ - id?: number - /** - * The unique numeric identifier for the product with which the review is associated. - */ - product_id?: number - /** - * Date the product review was created. - */ - date_created?: string - /** - * Date the product review was modified. - */ - date_modified?: string - } - /** - * The model for a POST to create a product review. - */ - productReview_Post: { - /** - * The title for the product review. - * Required in /POST. - */ - title: string - /** - * The text for the product review. - */ - text?: string - /** - * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. - */ - status?: string - /** - * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. - */ - rating?: number - /** - * The email of the reviewer. Must be a valid email, or an empty string. - */ - email?: string - /** - * The name of the reviewer. - */ - name?: string - /** - * Date the product was reviewed. Required in /POST. - */ - date_reviewed: string - } - /** - * The model for a PUT to update a product review. - */ - productReview_Put: { - /** - * The title for the product review. - * Required in /POST. - */ - title: string - /** - * The text for the product review. - */ - text?: string - /** - * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. - */ - status?: string - /** - * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. - */ - rating?: number - /** - * The email of the reviewer. Must be a valid email, or an empty string. - */ - email?: string - /** - * The name of the reviewer. - */ - name?: string - /** - * Date the product was reviewed. Required in /POST. - */ - date_reviewed: string - } - /** - * Image Response returns for: - * * Create Variant Image - * * Create Modifier Image - * * Create Category Image - * * Create Brand Image - */ - resp_productImage: { - data?: definitions['productImage_Full'] - /** - * Empty meta object; may be used later. - */ - meta?: { [key: string]: any } - } - /** - * An object containing a publicly accessible image URL, or a form post that contains an image file. - */ - resourceImage_Full: { - /** - * A public URL for a GIF, JPEG, or PNG image. Limit of 8MB per file. - */ - image_url?: string - } - product_Post: definitions['product_Base'] & { - variants?: definitions['productVariant_Post_Product'] - } - /** - * The model for a PUT to update a product. - */ - product_Put: { - /** - * The unique numerical ID of the product; increments sequentially. - */ - id?: number - } & definitions['product_Base'] & { - variants?: definitions['productVariant_Put_Product'] - } - /** - * Catalog Summary object describes a lightweight summary of the catalog. - */ - catalogSummary_Full: { - /** - * A count of all inventory items in the catalog. - */ - inventory_count?: number - /** - * Total value of store's inventory. - */ - inventory_value?: number - /** - * ID of the category containing the most products. - */ - primary_category_id?: number - /** - * Name of the category containing the most products. - */ - primary_category_name?: string - /** - * Total number of variants - */ - variant_count?: number - /** - * Highest priced variant - */ - highest_variant_price?: number - /** - * Average price of all variants - */ - average_variant_price?: number - /** - * Lowest priced variant in the store - */ - lowest_variant_price?: string - oldest_variant_date?: string - newest_variant_date?: string - } - /** - * Metafield for products, categories, variants, and brands. The max number of metafields allowed on each product, category, variant, or brand is fifty. For more information, see [Platform Limits](https://support.bigcommerce.com/s/article/Platform-Limits) in the Help Center. - */ - metafield_Base: { - /** - * Unique ID of the *Metafield*. Read-Only. - */ - id?: number - /** - * Determines the visibility and writeability of the field by other API consumers. - * - * |Value|Description - * |-|-| - * |`app_only`|Private to the app that owns the field| - * |`read`|Visible to other API consumers| - * |`write`|Open for reading and writing by other API consumers| - * |`read_and_sf_access`|Visible to other API consumers, including on storefront| - * |`write_and_sf_access`|Open for reading and writing by other API consumers, including on storefront| - */ - permission_set: - | 'app_only' - | 'read' - | 'write' - | 'read_and_sf_access' - | 'write_and_sf_access' - /** - * Namespace for the metafield, for organizational purposes. This is set set by the developer. Required for POST. - */ - namespace: string - /** - * The name of the field, for example: `location_id`, `color`. Required for POST. - */ - key: string - /** - * The value of the field, for example: `1`, `blue`. Required for POST. - */ - value: string - /** - * Description for the metafields. - */ - description?: string - /** - * The type of resource with which the metafield is associated. - */ - resource_type?: 'category' | 'brand' | 'product' | 'variant' - /** - * The ID for the resource with which the metafield is associated. - */ - resource_id?: number - /** - * Date and time of the metafield's creation. Read-Only. - */ - date_created?: string - /** - * Date and time when the metafield was last updated. Read-Only. - */ - date_modified?: string - } - /** - * Common ComplexRule properties. - */ - complexRule_Base: { - /** - * The unique numeric ID of the rule; increments sequentially. - * Read-Only - */ - id?: number - /** - * The unique numeric ID of the product with which the rule is associated; increments sequentially. - */ - product_id?: number - /** - * The priority to give this rule when making adjustments to the product properties. - */ - sort_order?: number - /** - * Flag for determining whether the rule is to be used when adjusting a product's price, weight, image, or availabilty. - */ - enabled?: boolean - /** - * Flag for determining whether other rules should not be applied after this rule has been applied. - */ - stop?: boolean - /** - * Flag for determining whether the rule should disable purchasing of a product when the conditions are applied. - */ - purchasing_disabled?: boolean - /** - * Message displayed on the storefront when a rule disables the purchasing of a product. - */ - purchasing_disabled_message?: string - /** - * Flag for determining whether the rule should hide purchasing of a product when the conditions are applied. - */ - purchasing_hidden?: boolean - /** - * The URL for an image displayed on the storefront when the conditions are applied. Limit of 8MB per file. - */ - image_url?: string - price_adjuster?: definitions['adjuster_Full'] - weight_adjuster?: definitions['adjuster_Full'] - conditions?: definitions['complexRuleConditionBase'][] - } - /** - * Gets custom fields associated with a product. These allow you to specify additional information that will appear on the product's page, such as a book's ISBN or a DVD's release date. - */ - productCustomField_Base: { - /** - * The unique numeric ID of the custom field; increments sequentially. - * Read-Only - */ - id?: number - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - name: string - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - value: string - } - /** - * The model for a POST to create a custom field on a product. - */ - productCustomField_Post: { - /** - * The unique numeric ID of the custom field; increments sequentially. - * Read-Only - */ - id?: number - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - name: string - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - value: string - } - /** - * The model for a PUT to update a custom field on a product. - */ - productCustomField_Put: { - /** - * The unique numeric ID of the custom field; increments sequentially. - * Read-Only - */ - id?: number - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - name: string - /** - * The name of the field, shown on the storefront, orders, etc. Required for /POST - */ - value: string - } - /** - * Complex rules may return with conditions that apply to one or more variants, or with a single modifier value (if the rules were created using the v2 API or the control panel). Complex rules created or updated in the v3 API must have conditions that either reference multiple `modifier_value_id`'s, or else reference a `modifier_value_id` and a `variant_id`. - */ - complexRuleConditionBase: { - /** - * The unique numeric ID of the rule condition; increments sequentially. Read-Only - */ - id?: number - /** - * The unique numeric ID of the rule with which the condition is associated. - * Read-Only - */ - rule_id?: number - /** - * The unique numeric ID of the modifier with which the rule condition is associated. - * Required in /POST. - */ - modifier_id: number - /** - * The unique numeric ID of the modifier value with which the rule condition is associated. - * Required in /POST. - */ - modifier_value_id: number - /** - * The unique numeric ID of the variant with which the rule condition is associated. - * Required in /POST. - */ - variant_id: number - /** - * (READ-ONLY:) The unique numeric ID of the SKU (v2 API), or Combination, with which the rule condition is associated. This is to maintain cross-compatibility between v2 and v3. - */ - combination_id?: number - } - /** - * The custom URL for the category on the storefront. - */ - customUrl_Full: { - /** - * Category URL on the storefront. - */ - url?: string - /** - * Returns `true` if the URL has been changed from its default state (the auto-assigned URL that BigCommerce provides). - */ - is_customized?: boolean - } - /** - * Common Bulk Pricing Rule properties - */ - bulkPricingRule_Full: { - /** - * Unique ID of the *Bulk Pricing Rule*. Read-Only. - */ - id?: number - /** - * The minimum inclusive quantity of a product to satisfy this rule. Must be greater than or equal to zero. - * Required in /POST. - */ - quantity_min: number - /** - * The maximum inclusive quantity of a product to satisfy this rule. Must be greater than the `quantity_min` value – unless this field has a value of 0 (zero), in which case there will be no maximum bound for this rule. - * Required in /POST. - */ - quantity_max: number - /** - * The type of adjustment that is made. Values: `price` - the adjustment amount per product; `percent` - the adjustment as a percentage of the original price; `fixed` - the adjusted absolute price of the product. - * Required in /POST. - */ - type: 'price' | 'percent' | 'fixed' - /** - * The discount can be a fixed dollar amount or a percentage. For a fixed dollar amount enter it as an integer and the response will return as an integer. For percentage enter the amount as the percentage divided by 100 using string format. For example 10% percent would be “.10”. The response will return as an integer. - * Required in /POST. - */ - amount: number - } - /** - * The values for option config can vary based on the Modifier created. - */ - productOptionConfig_Full: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - /** - * Adjuster for Complex Rules. - */ - adjuster_Full: { - /** - * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster?: 'relative' | 'percentage' - /** - * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. - */ - adjuster_value?: number - } - /** - * Errors during batch usage for the BigCommerce API. - */ - resp_variantBatchError: { - batch_errors?: (definitions['error_Base'] & { - errors?: { additionalProperties?: string } - })[] - } - /** - * Data about the response, including pagination and collection totals. - */ - metaCollection_Full: { pagination?: definitions['pagination_Full'] } - /** - * Data about the response, including pagination and collection totals. - */ - pagination_Full: { - /** - * Total number of items in the result set. - */ - total?: number - /** - * Total number of items in the collection response. - */ - count?: number - /** - * The amount of items returned in the collection per page, controlled by the limit parameter. - */ - per_page?: number - /** - * The page you are currently on within the collection. - */ - current_page?: number - /** - * The total number of pages in the collection. - */ - total_pages?: number - /** - * Pagination links for the previous and next parts of the whole collection. - */ - links?: { - /** - * Link to the previous page returned in the response. - */ - previous?: string - /** - * Link to the current page returned in the response. - */ - current?: string - /** - * Link to the next page returned in the response. - */ - next?: string - } - } - /** - * Empty meta object; may be used later. - */ - metaEmpty_Full: { [key: string]: any } - errorResponse_Full: definitions['error_Base'] & { - errors?: definitions['detailedErrors'] - } - /** - * Error payload for the BigCommerce API. - */ - error_Base: { - /** - * The HTTP status code. - */ - status?: number - /** - * The error title describing the particular error. - */ - title?: string - type?: string - instance?: string - } - /** - * Error payload for the BigCommerce API. - */ - errorNotFound: { - /** - * 404 HTTP status code. - */ - status?: number - /** - * The error title describing the particular error. - */ - title?: string - type?: string - instance?: string - } - /** - * A gift-certificate model. - */ - giftCertificate_Full: { - /** - * The gift-certificate code. - */ - code?: string - /** - * The balance on a gift certificate when it was purchased. - */ - original_balance?: number - /** - * The balance on a gift certificate at the time of this purchase. - */ - starting_balance?: number - /** - * The remaining balance on a gift certificate. - */ - remaining_balance?: number - /** - * The status of a gift certificate: `active` - gift certificate is active; `pending` - gift certificate purchase is pending; `disabled` - gift certificate is disabled; `expired` - gift certificate is expired. - */ - status?: 'active' | 'pending' | 'disabled' | 'expired' - } - /** - * No-content response for the BigCommerce API. - */ - errorNoContent: { - /** - * 204 HTTP status code. - */ - status?: number - /** - * The error title describing the situation. - */ - title?: string - type?: string - instance?: string - } - detailedErrors: { additionalProperties?: string } - product_Full: definitions['product_Base'] & { - /** - * The date on which the product was created. - */ - date_created?: string - /** - * The date on which the product was modified. - */ - date_modified?: string - /** - * ID of the product. Read Only. - */ - id?: number - /** - * The unique identifier of the base variant associated with a simple product. This value is `null` for complex products. - */ - base_variant_id?: number - /** - * The price of the product as seen on the storefront. It will be equal to the `sale_price`, if set, and the `price` if there is not a `sale_price`. - */ - calculated_price?: number - options?: definitions['productOption_Base'][] - modifiers?: definitions['productModifier_Full'][] - /** - * Minimum Advertised Price. - */ - map_price?: number - /** - * Indicates that the product is in an Option Set (legacy V2 concept). - */ - option_set_id?: number - /** - * Legacy template setting which controls if the option set shows up to the side of or below the product image and description. - */ - option_set_display?: string - } & { variants?: definitions['productVariant_Full'] } - /** - * Common ProductImage properties. - */ - productImage_Full: definitions['productImage_Base'] & { - /** - * The unique numeric ID of the image; increments sequentially. - */ - id?: number - /** - * The unique numeric identifier for the product with which the image is associated. - */ - product_id?: number - /** - * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. - */ - url_zoom?: string - /** - * The standard URL for this image. By default, this is used for product-page images. - */ - url_standard?: string - /** - * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. - */ - url_thumbnail?: string - /** - * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. - */ - url_tiny?: string - /** - * The date on which the product image was modified. - */ - date_modified?: string - } - metafield_Post: definitions['metafield_Base'] - /** - * The model for batch updating products. - */ - product_Put_Collection: ({ - /** - * The unique numerical ID of the product; increments sequentially. Required on batch product `PUT` requests. - */ - id: number - } & definitions['product_Base'])[] - /** - * The values for option config can vary based on the Modifier created. - */ - config_Full: { - /** - * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. - */ - default_value?: string - /** - * (checkbox) Flag for setting the checkbox to be checked by default. - */ - checked_by_default?: boolean - /** - * (checkbox) Label displayed for the checkbox option. - */ - checkbox_label?: string - /** - * (date) Flag to limit the dates allowed to be entered on a date option. - */ - date_limited?: boolean - /** - * (date) The type of limit that is allowed to be entered on a date option. - */ - date_limit_mode?: 'earliest' | 'range' | 'latest' - /** - * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_earliest_value?: string - /** - * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. - */ - date_latest_value?: string - /** - * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. - */ - file_types_mode?: 'specific' | 'all' - /** - * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: - * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). - * `other` - Allows file types defined in the `file_types_other` array. - */ - file_types_supported?: string[] - /** - * (file) A list of other file types allowed with the file upload option. - */ - file_types_other?: string[] - /** - * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. - */ - file_max_size?: number - /** - * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. - */ - text_characters_limited?: boolean - /** - * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. - */ - text_min_length?: number - /** - * (text, multi_line_text) The maximum length allowed for a text or multi line text option. - */ - text_max_length?: number - /** - * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. - */ - text_lines_limited?: boolean - /** - * (multi_line_text) The maximum number of lines allowed on a multi-line text input. - */ - text_max_lines?: number - /** - * (numbers_only_text) Flag to limit the value of a number option. - */ - number_limited?: boolean - /** - * (numbers_only_text) The type of limit on values entered for a number option. - */ - number_limit_mode?: 'lowest' | 'highest' | 'range' - /** - * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. - */ - number_lowest_value?: number - /** - * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. - */ - number_highest_value?: number - /** - * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. - */ - number_integers_only?: boolean - /** - * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. - */ - product_list_adjusts_inventory?: boolean - /** - * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. - */ - product_list_adjusts_pricing?: boolean - /** - * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. - */ - product_list_shipping_calc?: 'none' | 'weight' | 'package' - } - adjusters_Full: { - price?: definitions['adjuster_Full'] - weight?: definitions['adjuster_Full'] - /** - * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. - */ - image_url?: string - purchasing_disabled?: { - /** - * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. - */ - status?: boolean - /** - * The message displayed on the storefront when the purchasing disabled status is `true`. - */ - message?: string - } - } - /** - * Variant properties used on: - * * `/catalog/products/variants` - * * `/catalog/variants` - */ - variant_Base: { - /** - * The cost price of the variant. Not affected by Price List prices. - */ - cost_price?: number - /** - * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. - */ - price?: number - /** - * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. - */ - sale_price?: number - /** - * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. - */ - retail_price?: number - /** - * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. - */ - weight?: number - /** - * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. - */ - width?: number - /** - * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. - */ - height?: number - /** - * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. - */ - depth?: number - /** - * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. - */ - is_free_shipping?: boolean - /** - * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * If `true`, this variant will not be purchasable on the storefront. - */ - purchasing_disabled?: boolean - /** - * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. - */ - purchasing_disabled_message?: string - /** - * The UPC code used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. - */ - inventory_level?: number - /** - * When the variant hits this inventory level, it is considered low stock. - */ - inventory_warning_level?: number - /** - * Identifies where in a warehouse the variant is located. - */ - bin_picking_number?: string - } - /** - * Shared `Product` properties used in: - * * `POST` - * * `PUT` - * * `GET` - */ - product_Base: { - /** - * The product name. - */ - name?: string - /** - * The product type. One of: `physical` - a physical stock unit, `digital` - a digital download. - */ - type?: 'physical' | 'digital' - /** - * User defined product code/stock keeping unit (SKU). - */ - sku?: string - /** - * The product description, which can include HTML formatting. - */ - description?: string - /** - * Weight of the product, which can be used when calculating shipping costs. This is based on the unit set on the store - */ - weight?: number - /** - * Width of the product, which can be used when calculating shipping costs. - */ - width?: number - /** - * Depth of the product, which can be used when calculating shipping costs. - */ - depth?: number - /** - * Height of the product, which can be used when calculating shipping costs. - */ - height?: number - /** - * The price of the product. The price should include or exclude tax, based on the store settings. - */ - price?: number - /** - * The cost price of the product. Stored for reference only; it is not used or displayed anywhere on the store. - */ - cost_price?: number - /** - * The retail cost of the product. If entered, the retail cost price will be shown on the product page. - */ - retail_price?: number - /** - * If entered, the sale price will be used instead of value in the price field when calculating the product's cost. - */ - sale_price?: number - /** - * The ID of the tax class applied to the product. (NOTE: Value ignored if automatic tax is enabled.) - */ - tax_class_id?: number - /** - * Accepts AvaTax System Tax Codes, which identify products and services that fall into special sales-tax categories. By using these codes, merchants who subscribe to BigCommerce's Avalara Premium integration can calculate sales taxes more accurately. Stores without Avalara Premium will ignore the code when calculating sales tax. Do not pass more than one code. The codes are case-sensitive. For details, please see Avalara's documentation. - */ - product_tax_code?: string - /** - * An array of IDs for the categories to which this product belongs. When updating a product, if an array of categories is supplied, all product categories will be overwritten. Does not accept more than 1,000 ID values. - */ - categories?: number[] - /** - * A product can be added to an existing brand during a product /PUT or /POST. - */ - brand_id?: number - /** - * Current inventory level of the product. Simple inventory tracking must be enabled (See the `inventory_tracking` field) for this to take any effect. - */ - inventory_level?: number - /** - * Inventory warning level for the product. When the product's inventory level drops below the warning level, the store owner will be informed. Simple inventory tracking must be enabled (see the `inventory_tracking` field) for this to take any effect. - */ - inventory_warning_level?: number - /** - * The type of inventory tracking for the product. Values are: `none` - inventory levels will not be tracked; `product` - inventory levels will be tracked using the `inventory_level` and `inventory_warning_level` fields; `variant` - inventory levels will be tracked based on variants, which maintain their own warning levels and inventory levels. - */ - inventory_tracking?: 'none' | 'product' | 'variant' - /** - * A fixed shipping cost for the product. If defined, this value will be used during checkout instead of normal shipping-cost calculation. - */ - fixed_cost_shipping_price?: number - /** - * Flag used to indicate whether the product has free shipping. If `true`, the shipping cost for the product will be zero. - */ - is_free_shipping?: boolean - /** - * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the product will be displayed. If `false`, the product will be hidden from view. - */ - is_visible?: boolean - /** - * Flag to determine whether the product should be included in the `featured products` panel when viewing the store. - */ - is_featured?: boolean - /** - * An array of IDs for the related products. - */ - related_products?: number[] - /** - * Warranty information displayed on the product page. Can include HTML formatting. - */ - warranty?: string - /** - * The BIN picking number for the product. - */ - bin_picking_number?: string - /** - * The layout template file used to render this product category. This field is writable only for stores with a Blueprint theme applied. - */ - layout_file?: string - /** - * The product UPC code, which is used in feeds for shopping comparison sites and external channel integrations. - */ - upc?: string - /** - * A comma-separated list of keywords that can be used to locate the product when searching the store. - */ - search_keywords?: string - /** - * Availability of the product. Availability options are: `available` - the product can be purchased on the storefront; `disabled` - the product is listed in the storefront, but cannot be purchased; `preorder` - the product is listed for pre-orders. - */ - availability?: 'available' | 'disabled' | 'preorder' - /** - * Availability text displayed on the checkout page, under the product title. Tells the customer how long it will normally take to ship this product, such as: 'Usually ships in 24 hours.' - */ - availability_description?: string - /** - * Type of gift-wrapping options. Values: `any` - allow any gift-wrapping options in the store; `none` - disallow gift-wrapping on the product; `list` – provide a list of IDs in the `gift_wrapping_options_list` field. - */ - gift_wrapping_options_type?: 'any' | 'none' | 'list' - /** - * A list of gift-wrapping option IDs. - */ - gift_wrapping_options_list?: number[] - /** - * Priority to give this product when included in product lists on category pages and in search results. Lower integers will place the product closer to the top of the results. - */ - sort_order?: number - /** - * The product condition. Will be shown on the product page if the `is_condition_shown` field's value is `true`. Possible values: `New`, `Used`, `Refurbished`. - */ - condition?: 'New' | 'Used' | 'Refurbished' - /** - * Flag used to determine whether the product condition is shown to the customer on the product page. - */ - is_condition_shown?: boolean - /** - * The minimum quantity an order must contain, to be eligible to purchase this product. - */ - order_quantity_minimum?: number - /** - * The maximum quantity an order can contain when purchasing the product. - */ - order_quantity_maximum?: number - /** - * Custom title for the product page. If not defined, the product name will be used as the meta title. - */ - page_title?: string - /** - * Custom meta keywords for the product page. If not defined, the store's default keywords will be used. - */ - meta_keywords?: string[] - /** - * Custom meta description for the product page. If not defined, the store's default meta description will be used. - */ - meta_description?: string - /** - * The number of times the product has been viewed. - */ - view_count?: number - /** - * Pre-order release date. See the `availability` field for details on setting a product's availability to accept pre-orders. - */ - preorder_release_date?: string - /** - * Custom expected-date message to display on the product page. If undefined, the message defaults to the storewide setting. Can contain the `%%DATE%%` placeholder, which will be substituted for the release date. - */ - preorder_message?: string - /** - * If set to true then on the preorder release date the preorder status will automatically be removed. - * If set to false, then on the release date the preorder status **will not** be removed. It will need to be changed manually either in the - * control panel or using the API. Using the API set `availability` to `available`. - */ - is_preorder_only?: boolean - /** - * False by default, indicating that this product's price should be shown on the product page. If set to `true`, the price is hidden. (NOTE: To successfully set `is_price_hidden` to `true`, the `availability` value must be `disabled`.) - */ - is_price_hidden?: boolean - /** - * By default, an empty string. If `is_price_hidden` is `true`, the value of `price_hidden_label` is displayed instead of the price. (NOTE: To successfully set a non-empty string value with `is_price_hidden` set to `true`, the `availability` value must be `disabled`.) - */ - price_hidden_label?: string - custom_url?: definitions['customUrl_Full'] - /** - * Type of product, defaults to `product`. - */ - open_graph_type?: - | 'product' - | 'album' - | 'book' - | 'drink' - | 'food' - | 'game' - | 'movie' - | 'song' - | 'tv_show' - /** - * Title of the product, if not specified the product name will be used instead. - */ - open_graph_title?: string - /** - * Description to use for the product, if not specified then the meta_description will be used instead. - */ - open_graph_description?: string - /** - * Flag to determine if product description or open graph description is used. - */ - open_graph_use_meta_description?: boolean - /** - * Flag to determine if product name or open graph name is used. - */ - open_graph_use_product_name?: boolean - /** - * Flag to determine if product image or open graph image is used. - */ - open_graph_use_image?: boolean - /** - * The brand can be created during a product PUT or POST request. If the brand already exists then the product will be added. If not the brand will be created and the product added. If using `brand_name` it performs a fuzzy match and adds the brand. eg. "Common Good" and "Common good" are the same. Brand name does not return as part of a product response. Only the `brand_id`. - */ - 'brand_name or brand_id'?: string - /** - * Global Trade Item Number - */ - gtin?: string - /** - * Manufacturer Part Number - */ - mpn?: string - /** - * The total rating for the product. - */ - reviews_rating_sum?: number - /** - * The number of times the product has been rated. - */ - reviews_count?: number - /** - * The total quantity of this product sold. - */ - total_sold?: number - custom_fields?: definitions['productCustomField_Put'][] - bulk_pricing_rules?: definitions['bulkPricingRule_Full'][] - images?: definitions['productImage_Full'][] - primary_image?: definitions['productImage_Full'] - videos?: definitions['productVideo_Full'][] - } - /** - * Properties for updating metafields. - */ - metafield_Put: { - /** - * Unique ID of the *Metafield*. Read-Only. - */ - id?: number - } & definitions['metafield_Base'] - metafield_Full: definitions['metafield_Put'] & { - /** - * Date and time of the metafield's creation. Read-Only. - */ - date_created?: string - /** - * Date and time when the metafield was last updated. Read-Only. - */ - date_modified?: string - } - /** - * The model for a PUT to update variants on a product. - */ - productVariant_Put: definitions['productVariant_Base'] & { - product_id?: number - sku?: string - } -} diff --git a/lib/bigcommerce/api/definitions/store-content.ts b/lib/bigcommerce/api/definitions/store-content.ts deleted file mode 100644 index f00c28844..000000000 --- a/lib/bigcommerce/api/definitions/store-content.ts +++ /dev/null @@ -1,329 +0,0 @@ -/** - * This file was auto-generated by swagger-to-ts. - * Do not make direct changes to the file. - */ - -export interface definitions { - blogPost_Full: { - /** - * ID of this blog post. (READ-ONLY) - */ - id?: number - } & definitions['blogPost_Base'] - addresses: { - /** - * Full URL of where the resource is located. - */ - url?: string - /** - * Resource being accessed. - */ - resource?: string - } - formField: { - /** - * Name of the form field - */ - name?: string - /** - * Value of the form field - */ - value?: string - } - page_Full: { - /** - * ID of the page. - */ - id?: number - } & definitions['page_Base'] - redirect: { - /** - * Numeric ID of the redirect. - */ - id?: number - /** - * The path from which to redirect. - */ - path: string - forward: definitions['forward'] - /** - * URL of the redirect. READ-ONLY - */ - url?: string - } - forward: { - /** - * The type of redirect. If it is a `manual` redirect then type will always be manual. Dynamic redirects will have the type of the page. Such as product or category. - */ - type?: string - /** - * Reference of the redirect. Dynamic redirects will have the category or product number. Manual redirects will have the url that is being directed to. - */ - ref?: number - } - customer_Full: { - /** - * Unique numeric ID of this customer. This is a READ-ONLY field; do not set or modify its value in a POST or PUT request. - */ - id?: number - /** - * Not returned in any responses, but accepts up to two fields allowing you to set the customer’s password. If a password is not supplied, it is generated automatically. For further information about using this object, please see the Customers resource documentation. - */ - _authentication?: { - force_reset?: string - password?: string - password_confirmation?: string - } - /** - * The name of the company for which the customer works. - */ - company?: string - /** - * First name of the customer. - */ - first_name: string - /** - * Last name of the customer. - */ - last_name: string - /** - * Email address of the customer. - */ - email: string - /** - * Phone number of the customer. - */ - phone?: string - /** - * Date on which the customer registered from the storefront or was created in the control panel. This is a READ-ONLY field; do not set or modify its value in a POST or PUT request. - */ - date_created?: string - /** - * Date on which the customer updated their details in the storefront or was updated in the control panel. This is a READ-ONLY field; do not set or modify its value in a POST or PUT request. - */ - date_modified?: string - /** - * The amount of credit the customer has. (Float, Float as String, Integer) - */ - store_credit?: string - /** - * The customer’s IP address when they signed up. - */ - registration_ip_address?: string - /** - * The group to which the customer belongs. - */ - customer_group_id?: number - /** - * Store-owner notes on the customer. - */ - notes?: string - /** - * Used to identify customers who fall into special sales-tax categories – in particular, those who are fully or partially exempt from paying sales tax. Can be blank, or can contain a single AvaTax code. (The codes are case-sensitive.) Stores that subscribe to BigCommerce’s Avalara Premium integration will use this code to determine how/whether to apply sales tax. Does not affect sales-tax calculations for stores that do not subscribe to Avalara Premium. - */ - tax_exempt_category?: string - /** - * Records whether the customer would like to receive marketing content from this store. READ-ONLY.This is a READ-ONLY field; do not set or modify its value in a POST or PUT request. - */ - accepts_marketing?: boolean - addresses?: definitions['addresses'] - /** - * Array of custom fields. This is a READ-ONLY field; do not set or modify its value in a POST or PUT request. - */ - form_fields?: definitions['formField'][] - /** - * Force a password change on next login. - */ - reset_pass_on_login?: boolean - } - categoryAccessLevel: { - /** - * + `all` - Customers can access all categories - * + `specific` - Customers can access a specific list of categories - * + `none` - Customers are prevented from viewing any of the categories in this group. - */ - type?: 'all' | 'specific' | 'none' - /** - * Is an array of category IDs and should be supplied only if `type` is specific. - */ - categories?: string[] - } - timeZone: { - /** - * a string identifying the time zone, in the format: /. - */ - name?: string - /** - * a negative or positive number, identifying the offset from UTC/GMT, in seconds, during winter/standard time. - */ - raw_offset?: number - /** - * "-/+" offset from UTC/GMT, in seconds, during summer/daylight saving time. - */ - dst_offset?: number - /** - * a boolean indicating whether this time zone observes daylight saving time. - */ - dst_correction?: boolean - date_format?: definitions['dateFormat'] - } - count_Response: { count?: number } - dateFormat: { - /** - * string that defines dates’ display format, in the pattern: M jS Y - */ - display?: string - /** - * string that defines the CSV export format for orders, customers, and products, in the pattern: M jS Y - */ - export?: string - /** - * string that defines dates’ extended-display format, in the pattern: M jS Y @ g:i A. - */ - extended_display?: string - } - blogTags: { tag?: string; post_ids?: number[] }[] - blogPost_Base: { - /** - * Title of this blog post. - */ - title: string - /** - * URL for the public blog post. - */ - url?: string - /** - * URL to preview the blog post. (READ-ONLY) - */ - preview_url?: string - /** - * Text body of the blog post. - */ - body: string - /** - * Tags to characterize the blog post. - */ - tags?: string[] - /** - * Summary of the blog post. (READ-ONLY) - */ - summary?: string - /** - * Whether the blog post is published. - */ - is_published?: boolean - published_date?: definitions['publishedDate'] - /** - * Published date in `ISO 8601` format. - */ - published_date_iso8601?: string - /** - * Description text for this blog post’s `` element. - */ - meta_description?: string - /** - * Keywords for this blog post’s `` element. - */ - meta_keywords?: string - /** - * Name of the blog post’s author. - */ - author?: string - /** - * Local path to a thumbnail uploaded to `product_images/` via [WebDav](https://support.bigcommerce.com/s/article/File-Access-WebDAV). - */ - thumbnail_path?: string - } - publishedDate: { timezone_type?: string; date?: string; timezone?: string } - /** - * Not returned in any responses, but accepts up to two fields allowing you to set the customer’s password. If a password is not supplied, it is generated automatically. For further information about using this object, please see the Customers resource documentation. - */ - authentication: { - force_reset?: string - password?: string - password_confirmation?: string - } - customer_Base: { [key: string]: any } - page_Base: { - /** - * ID of any parent Web page. - */ - parent_id?: number - /** - * `page`: free-text page - * `link`: link to another web address - * `rss_feed`: syndicated content from an RSS feed - * `contact_form`: When the store's contact form is used. - */ - type: 'page' | 'rss_feed' | 'contact_form' | 'raw' | 'link' - /** - * Where the page’s type is a contact form: object whose members are the fields enabled (in the control panel) for storefront display. Possible members are:`fullname`: full name of the customer submitting the form; `phone`: customer’s phone number, as submitted on the form; `companyname`: customer’s submitted company name; `orderno`: customer’s submitted order number; `rma`: customer’s submitted RMA (Return Merchandise Authorization) number. - */ - contact_fields?: string - /** - * Where the page’s type is a contact form: email address that receives messages sent via the form. - */ - email?: string - /** - * Page name, as displayed on the storefront. - */ - name: string - /** - * Relative URL on the storefront for this page. - */ - url?: string - /** - * Description contained within this page’s `` element. - */ - meta_description?: string - /** - * HTML or variable that populates this page’s `` element, in default/desktop view. Required in POST if page type is `raw`. - */ - body: string - /** - * HTML to use for this page's body when viewed in the mobile template (deprecated). - */ - mobile_body?: string - /** - * If true, this page has a mobile version. - */ - has_mobile_version?: boolean - /** - * If true, this page appears in the storefront’s navigation menu. - */ - is_visible?: boolean - /** - * If true, this page is the storefront’s home page. - */ - is_homepage?: boolean - /** - * Text specified for this page’s `` element. (If empty, the value of the name property is used.) - */ - meta_title?: string - /** - * Layout template for this page. This field is writable only for stores with a Blueprint theme applied. - */ - layout_file?: string - /** - * Order in which this page should display on the storefront. (Lower integers specify earlier display.) - */ - sort_order?: number - /** - * Comma-separated list of keywords that shoppers can use to locate this page when searching the store. - */ - search_keywords?: string - /** - * Comma-separated list of SEO-relevant keywords to include in the page’s `<meta/>` element. - */ - meta_keywords?: string - /** - * If page type is `rss_feed` the n this field is visisble. Required in POST required for `rss page` type. - */ - feed: string - /** - * If page type is `link` this field is returned. Required in POST to create a `link` page. - */ - link: string - content_type?: 'application/json' | 'text/javascript' | 'text/html' - } -} diff --git a/lib/bigcommerce/api/definitions/wishlist.ts b/lib/bigcommerce/api/definitions/wishlist.ts deleted file mode 100644 index 6ec21c103..000000000 --- a/lib/bigcommerce/api/definitions/wishlist.ts +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by swagger-to-ts. - * Do not make direct changes to the file. - */ - -export interface definitions { - wishlist_Post: { - /** - * The customer id. - */ - customer_id: number - /** - * Whether the wishlist is available to the public. - */ - is_public?: boolean - /** - * The title of the wishlist. - */ - name?: string - /** - * Array of Wishlist items. - */ - items?: { - /** - * The ID of the product. - */ - product_id?: number - /** - * The variant ID of the product. - */ - variant_id?: number - }[] - } - wishlist_Put: { - /** - * The customer id. - */ - customer_id: number - /** - * Whether the wishlist is available to the public. - */ - is_public?: boolean - /** - * The title of the wishlist. - */ - name?: string - /** - * Array of Wishlist items. - */ - items?: { - /** - * The ID of the item - */ - id?: number - /** - * The ID of the product. - */ - product_id?: number - /** - * The variant ID of the item. - */ - variant_id?: number - }[] - } - wishlist_Full: { - /** - * Wishlist ID, provided after creating a wishlist with a POST. - */ - id?: number - /** - * The ID the customer to which the wishlist belongs. - */ - customer_id?: number - /** - * The Wishlist's name. - */ - name?: string - /** - * Whether the Wishlist is available to the public. - */ - is_public?: boolean - /** - * The token of the Wishlist. This is created internally within BigCommerce. The Wishlist ID is to be used for external apps. Read-Only - */ - token?: string - /** - * Array of Wishlist items - */ - items?: definitions['wishlistItem_Full'][] - } - wishlistItem_Full: { - /** - * The ID of the item - */ - id?: number - /** - * The ID of the product. - */ - product_id?: number - /** - * The variant ID of the item. - */ - variant_id?: number - } - wishlistItem_Post: { - /** - * The ID of the product. - */ - product_id?: number - /** - * The variant ID of the product. - */ - variant_id?: number - } - /** - * Data about the response, including pagination and collection totals. - */ - pagination: { - /** - * Total number of items in the result set. - */ - total?: number - /** - * Total number of items in the collection response. - */ - count?: number - /** - * The amount of items returned in the collection per page, controlled by the limit parameter. - */ - per_page?: number - /** - * The page you are currently on within the collection. - */ - current_page?: number - /** - * The total number of pages in the collection. - */ - total_pages?: number - } - error: { status?: number; title?: string; type?: string } - metaCollection: { pagination?: definitions['pagination'] } -} diff --git a/lib/bigcommerce/api/fragments/category-tree.ts b/lib/bigcommerce/api/fragments/category-tree.ts deleted file mode 100644 index e26f17195..000000000 --- a/lib/bigcommerce/api/fragments/category-tree.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const categoryTreeItemFragment = /* GraphQL */ ` - fragment categoryTreeItem on CategoryTreeItem { - entityId - name - path - description - productCount - } -` diff --git a/lib/bigcommerce/api/fragments/product.ts b/lib/bigcommerce/api/fragments/product.ts deleted file mode 100644 index 73856ca2c..000000000 --- a/lib/bigcommerce/api/fragments/product.ts +++ /dev/null @@ -1,106 +0,0 @@ -export const swatchOptionFragment = /* GraphQL */ ` - fragment swatchOption on SwatchOptionValue { - isDefault - hexColors - } -` - -export const multipleChoiceOptionFragment = /* GraphQL */ ` - fragment multipleChoiceOption on MultipleChoiceOption { - entityId - values { - edges { - node { - label - ...swatchOption - } - } - } - } - - ${swatchOptionFragment} -` - -export const productInfoFragment = /* GraphQL */ ` - fragment productInfo on Product { - entityId - name - path - brand { - entityId - } - description - prices { - price { - value - currencyCode - } - salePrice { - value - currencyCode - } - retailPrice { - value - currencyCode - } - } - images { - edges { - node { - urlOriginal - altText - isDefault - } - } - } - variants { - edges { - node { - entityId - defaultImage { - urlOriginal - altText - isDefault - } - } - } - } - productOptions { - edges { - node { - entityId - displayName - ...multipleChoiceOption - } - } - } - localeMeta: metafields(namespace: $locale, keys: ["name", "description"]) - @include(if: $hasLocale) { - edges { - node { - key - value - } - } - } - } - - ${multipleChoiceOptionFragment} -` - -export const productConnectionFragment = /* GraphQL */ ` - fragment productConnnection on ProductConnection { - pageInfo { - startCursor - endCursor - } - edges { - cursor - node { - ...productInfo - } - } - } - - ${productInfoFragment} -` diff --git a/lib/bigcommerce/api/index.ts b/lib/bigcommerce/api/index.ts deleted file mode 100644 index 78215d4d6..000000000 --- a/lib/bigcommerce/api/index.ts +++ /dev/null @@ -1,85 +0,0 @@ -import type { RequestInit } from '@vercel/fetch' -import type { CommerceAPIConfig } from '../../commerce/api' -import fetchGraphqlApi from './utils/fetch-graphql-api' -import fetchStoreApi from './utils/fetch-store-api' - -export interface BigcommerceConfig extends CommerceAPIConfig { - // Indicates if the returned metadata with translations should be applied to the - // data or returned as it is - applyLocale?: boolean - storeApiUrl: string - storeApiToken: string - storeApiClientId: string - storeApiFetch<T>(endpoint: string, options?: RequestInit): Promise<T> -} - -const API_URL = process.env.BIGCOMMERCE_STOREFRONT_API_URL -const API_TOKEN = process.env.BIGCOMMERCE_STOREFRONT_API_TOKEN -const STORE_API_URL = process.env.BIGCOMMERCE_STORE_API_URL -const STORE_API_TOKEN = process.env.BIGCOMMERCE_STORE_API_TOKEN -const STORE_API_CLIENT_ID = process.env.BIGCOMMERCE_STORE_API_CLIENT_ID - -if (!API_URL) { - throw new Error( - `The environment variable BIGCOMMERCE_STOREFRONT_API_URL is missing and it's required to access your store` - ) -} - -if (!API_TOKEN) { - throw new Error( - `The environment variable BIGCOMMERCE_STOREFRONT_API_TOKEN is missing and it's required to access your store` - ) -} - -if (!(STORE_API_URL && STORE_API_TOKEN && STORE_API_CLIENT_ID)) { - throw new Error( - `The environment variables BIGCOMMERCE_STORE_API_URL, BIGCOMMERCE_STORE_API_TOKEN, BIGCOMMERCE_STORE_API_CLIENT_ID have to be set in order to access the REST API of your store` - ) -} - -export class Config { - private config: BigcommerceConfig - - constructor(config: Omit<BigcommerceConfig, 'customerCookie'>) { - this.config = { - ...config, - // The customerCookie is not customizable for now, BC sets the cookie and it's - // not important to rename it - customerCookie: 'SHOP_TOKEN', - } - } - - getConfig(userConfig: Partial<BigcommerceConfig> = {}) { - return Object.entries(userConfig).reduce<BigcommerceConfig>( - (cfg, [key, value]) => Object.assign(cfg, { [key]: value }), - { ...this.config } - ) - } - - setConfig(newConfig: Partial<BigcommerceConfig>) { - Object.assign(this.config, newConfig) - } -} - -const ONE_DAY = 60 * 60 * 24 -const config = new Config({ - commerceUrl: API_URL, - apiToken: API_TOKEN, - cartCookie: process.env.BIGCOMMERCE_CART_COOKIE ?? 'bc_cartId', - cartCookieMaxAge: ONE_DAY * 30, - fetch: fetchGraphqlApi, - applyLocale: true, - // REST API only - storeApiUrl: STORE_API_URL, - storeApiToken: STORE_API_TOKEN, - storeApiClientId: STORE_API_CLIENT_ID, - storeApiFetch: fetchStoreApi, -}) - -export function getConfig(userConfig?: Partial<BigcommerceConfig>) { - return config.getConfig(userConfig) -} - -export function setConfig(newConfig: Partial<BigcommerceConfig>) { - return config.setConfig(newConfig) -} diff --git a/lib/bigcommerce/api/operations/get-all-pages.ts b/lib/bigcommerce/api/operations/get-all-pages.ts deleted file mode 100644 index 9fe83f2a1..000000000 --- a/lib/bigcommerce/api/operations/get-all-pages.ts +++ /dev/null @@ -1,43 +0,0 @@ -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import { BigcommerceConfig, getConfig } from '..' -import { definitions } from '../definitions/store-content' - -export type Page = definitions['page_Full'] - -export type GetAllPagesResult< - T extends { pages: any[] } = { pages: Page[] } -> = T - -async function getAllPages(opts?: { - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetAllPagesResult> - -async function getAllPages<T extends { pages: any[] }>(opts: { - url: string - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetAllPagesResult<T>> - -async function getAllPages({ - config, - preview, -}: { - url?: string - config?: BigcommerceConfig - preview?: boolean -} = {}): Promise<GetAllPagesResult> { - config = getConfig(config) - // RecursivePartial forces the method to check for every prop in the data, which is - // required in case there's a custom `url` - const { data } = await config.storeApiFetch< - RecursivePartial<{ data: Page[] }> - >('/v3/content/pages') - const pages = (data as RecursiveRequired<typeof data>) ?? [] - - return { - pages: preview ? pages : pages.filter((p) => p.is_visible), - } -} - -export default getAllPages diff --git a/lib/bigcommerce/api/operations/get-all-product-paths.ts b/lib/bigcommerce/api/operations/get-all-product-paths.ts deleted file mode 100644 index 71522be35..000000000 --- a/lib/bigcommerce/api/operations/get-all-product-paths.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { - GetAllProductPathsQuery, - GetAllProductPathsQueryVariables, -} from '../../schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import filterEdges from '../utils/filter-edges' -import { BigcommerceConfig, getConfig } from '..' - -export const getAllProductPathsQuery = /* GraphQL */ ` - query getAllProductPaths($first: Int = 100) { - site { - products(first: $first) { - edges { - node { - path - } - } - } - } - } -` - -export type ProductPath = NonNullable< - NonNullable<GetAllProductPathsQuery['site']['products']['edges']>[0] -> - -export type ProductPaths = ProductPath[] - -export type { GetAllProductPathsQueryVariables } - -export type GetAllProductPathsResult< - T extends { products: any[] } = { products: ProductPaths } -> = T - -async function getAllProductPaths(opts?: { - variables?: GetAllProductPathsQueryVariables - config?: BigcommerceConfig -}): Promise<GetAllProductPathsResult> - -async function getAllProductPaths< - T extends { products: any[] }, - V = any ->(opts: { - query: string - variables?: V - config?: BigcommerceConfig -}): Promise<GetAllProductPathsResult<T>> - -async function getAllProductPaths({ - query = getAllProductPathsQuery, - variables, - config, -}: { - query?: string - variables?: GetAllProductPathsQueryVariables - config?: BigcommerceConfig -} = {}): Promise<GetAllProductPathsResult> { - config = getConfig(config) - // RecursivePartial forces the method to check for every prop in the data, which is - // required in case there's a custom `query` - const { data } = await config.fetch< - RecursivePartial<GetAllProductPathsQuery> - >(query, { variables }) - const products = data.site?.products?.edges - - return { - products: filterEdges(products as RecursiveRequired<typeof products>), - } -} - -export default getAllProductPaths diff --git a/lib/bigcommerce/api/operations/get-all-products.ts b/lib/bigcommerce/api/operations/get-all-products.ts deleted file mode 100644 index f67d62831..000000000 --- a/lib/bigcommerce/api/operations/get-all-products.ts +++ /dev/null @@ -1,129 +0,0 @@ -import type { - GetAllProductsQuery, - GetAllProductsQueryVariables, -} from '../../schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import filterEdges from '../utils/filter-edges' -import setProductLocaleMeta from '../utils/set-product-locale-meta' -import { productConnectionFragment } from '../fragments/product' -import { BigcommerceConfig, getConfig } from '..' - -export const getAllProductsQuery = /* GraphQL */ ` - query getAllProducts( - $hasLocale: Boolean = false - $locale: String = "null" - $entityIds: [Int!] - $first: Int = 10 - $products: Boolean = false - $featuredProducts: Boolean = false - $bestSellingProducts: Boolean = false - $newestProducts: Boolean = false - ) { - site { - products(first: $first, entityIds: $entityIds) @include(if: $products) { - ...productConnnection - } - featuredProducts(first: $first) @include(if: $featuredProducts) { - ...productConnnection - } - bestSellingProducts(first: $first) @include(if: $bestSellingProducts) { - ...productConnnection - } - newestProducts(first: $first) @include(if: $newestProducts) { - ...productConnnection - } - } - } - - ${productConnectionFragment} -` - -export type ProductEdge = NonNullable< - NonNullable<GetAllProductsQuery['site']['products']['edges']>[0] -> - -export type ProductNode = ProductEdge['node'] - -export type GetAllProductsResult< - T extends Record<keyof GetAllProductsResult, any[]> = { - products: ProductEdge[] - } -> = T - -const FIELDS = [ - 'products', - 'featuredProducts', - 'bestSellingProducts', - 'newestProducts', -] - -export type ProductTypes = - | 'products' - | 'featuredProducts' - | 'bestSellingProducts' - | 'newestProducts' - -export type ProductVariables = { field?: ProductTypes } & Omit< - GetAllProductsQueryVariables, - ProductTypes | 'hasLocale' -> - -async function getAllProducts(opts?: { - variables?: ProductVariables - config?: BigcommerceConfig -}): Promise<GetAllProductsResult> - -async function getAllProducts< - T extends Record<keyof GetAllProductsResult, any[]>, - V = any ->(opts: { - query: string - variables?: V - config?: BigcommerceConfig -}): Promise<GetAllProductsResult<T>> - -async function getAllProducts({ - query = getAllProductsQuery, - variables: { field = 'products', ...vars } = {}, - config, -}: { - query?: string - variables?: ProductVariables - config?: BigcommerceConfig -} = {}): Promise<GetAllProductsResult> { - config = getConfig(config) - - const locale = vars.locale || config.locale - const variables: GetAllProductsQueryVariables = { - ...vars, - locale, - hasLocale: !!locale, - } - - if (!FIELDS.includes(field)) { - throw new Error( - `The field variable has to match one of ${FIELDS.join(', ')}` - ) - } - - variables[field] = true - - // RecursivePartial forces the method to check for every prop in the data, which is - // required in case there's a custom `query` - const { data } = await config.fetch<RecursivePartial<GetAllProductsQuery>>( - query, - { variables } - ) - const edges = data.site?.[field]?.edges - const products = filterEdges(edges as RecursiveRequired<typeof edges>) - - if (locale && config.applyLocale) { - products.forEach((product: RecursivePartial<ProductEdge>) => { - if (product.node) setProductLocaleMeta(product.node) - }) - } - - return { products } -} - -export default getAllProducts diff --git a/lib/bigcommerce/api/operations/get-customer-id.ts b/lib/bigcommerce/api/operations/get-customer-id.ts deleted file mode 100644 index 7fe84093e..000000000 --- a/lib/bigcommerce/api/operations/get-customer-id.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { GetCustomerIdQuery } from '../../schema' -import { BigcommerceConfig, getConfig } from '..' - -export const getCustomerIdQuery = /* GraphQL */ ` - query getCustomerId { - customer { - entityId - } - } -` - -async function getCustomerId({ - customerToken, - config, -}: { - customerToken: string - config?: BigcommerceConfig -}): Promise<number | undefined> { - config = getConfig(config) - - const { data } = await config.fetch<GetCustomerIdQuery>( - getCustomerIdQuery, - undefined, - { - headers: { - cookie: `${config.customerCookie}=${customerToken}`, - }, - } - ) - - return data?.customer?.entityId -} - -export default getCustomerId diff --git a/lib/bigcommerce/api/operations/get-customer-wishlist.ts b/lib/bigcommerce/api/operations/get-customer-wishlist.ts deleted file mode 100644 index 093b136f1..000000000 --- a/lib/bigcommerce/api/operations/get-customer-wishlist.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import { BigcommerceConfig, getConfig } from '..' -import { definitions } from '../definitions/wishlist' - -export type Wishlist = definitions['wishlist_Full'] - -export type GetCustomerWishlistResult< - T extends { wishlist?: any } = { wishlist?: Wishlist } -> = T - -export type GetCustomerWishlistVariables = { - customerId: number -} - -async function getCustomerWishlist(opts: { - variables: GetCustomerWishlistVariables - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetCustomerWishlistResult> - -async function getCustomerWishlist< - T extends { wishlist?: any }, - V = any ->(opts: { - url: string - variables: V - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetCustomerWishlistResult<T>> - -async function getCustomerWishlist({ - config, - variables, -}: { - url?: string - variables: GetCustomerWishlistVariables - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetCustomerWishlistResult> { - config = getConfig(config) - - const { data } = await config.storeApiFetch< - RecursivePartial<{ data: Wishlist[] }> - >(`/v3/wishlists?customer_id=${variables.customerId}`) - const wishlists = (data as RecursiveRequired<typeof data>) ?? [] - const wishlist = wishlists[0] - - return { wishlist } -} - -export default getCustomerWishlist diff --git a/lib/bigcommerce/api/operations/get-page.ts b/lib/bigcommerce/api/operations/get-page.ts deleted file mode 100644 index 3010dd34c..000000000 --- a/lib/bigcommerce/api/operations/get-page.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import { BigcommerceConfig, getConfig } from '..' -import { definitions } from '../definitions/store-content' - -export type Page = definitions['page_Full'] - -export type GetPageResult<T extends { page?: any } = { page?: Page }> = T - -export type PageVariables = { - id: number -} - -async function getPage(opts: { - url?: string - variables: PageVariables - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetPageResult> - -async function getPage<T extends { page?: any }, V = any>(opts: { - url: string - variables: V - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetPageResult<T>> - -async function getPage({ - url, - variables, - config, - preview, -}: { - url?: string - variables: PageVariables - config?: BigcommerceConfig - preview?: boolean -}): Promise<GetPageResult> { - config = getConfig(config) - // RecursivePartial forces the method to check for every prop in the data, which is - // required in case there's a custom `url` - const { data } = await config.storeApiFetch<RecursivePartial<{ data: Page[] }>>( - url || `/v3/content/pages?id=${variables.id}&include=body` - ) - const firstPage = data?.[0] - const page = firstPage as RecursiveRequired<typeof firstPage> - - if (preview || page?.is_visible) { - return { page } - } - return {} -} - -export default getPage diff --git a/lib/bigcommerce/api/operations/get-product.ts b/lib/bigcommerce/api/operations/get-product.ts deleted file mode 100644 index 5071f68ec..000000000 --- a/lib/bigcommerce/api/operations/get-product.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { GetProductQuery, GetProductQueryVariables } from '../../schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import setProductLocaleMeta from '../utils/set-product-locale-meta' -import { productInfoFragment } from '../fragments/product' -import { BigcommerceConfig, getConfig } from '..' - -export const getProductQuery = /* GraphQL */ ` - query getProduct( - $hasLocale: Boolean = false - $locale: String = "null" - $path: String! - ) { - site { - route(path: $path) { - node { - __typename - ... on Product { - ...productInfo - } - } - } - } - } - - ${productInfoFragment} -` - -export type ProductNode = Extract< - GetProductQuery['site']['route']['node'], - { __typename: 'Product' } -> - -export type GetProductResult< - T extends { product?: any } = { product?: ProductNode } -> = T - -export type ProductVariables = { locale?: string } & ( - | { path: string; slug?: never } - | { path?: never; slug: string } -) - -async function getProduct(opts: { - variables: ProductVariables - config?: BigcommerceConfig -}): Promise<GetProductResult> - -async function getProduct<T extends { product?: any }, V = any>(opts: { - query: string - variables: V - config?: BigcommerceConfig -}): Promise<GetProductResult<T>> - -async function getProduct({ - query = getProductQuery, - variables: { slug, ...vars }, - config, -}: { - query?: string - variables: ProductVariables - config?: BigcommerceConfig -}): Promise<GetProductResult> { - config = getConfig(config) - - const locale = vars.locale || config.locale - const variables: GetProductQueryVariables = { - ...vars, - locale, - hasLocale: !!locale, - path: slug ? `/${slug}/` : vars.path!, - } - const { data } = await config.fetch<RecursivePartial<GetProductQuery>>( - query, - { variables } - ) - const product = data.site?.route?.node - - if (product?.__typename === 'Product') { - if (locale && config.applyLocale) { - setProductLocaleMeta(product) - } - - return { - product: product as RecursiveRequired<typeof product>, - } - } - - return {} -} - -export default getProduct diff --git a/lib/bigcommerce/api/operations/get-site-info.ts b/lib/bigcommerce/api/operations/get-site-info.ts deleted file mode 100644 index 0a6e84f0f..000000000 --- a/lib/bigcommerce/api/operations/get-site-info.ts +++ /dev/null @@ -1,103 +0,0 @@ -import type { GetSiteInfoQuery, GetSiteInfoQueryVariables } from '../../schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' -import filterEdges from '../utils/filter-edges' -import { BigcommerceConfig, getConfig } from '..' -import { categoryTreeItemFragment } from '../fragments/category-tree' - -// Get 3 levels of categories -export const getSiteInfoQuery = /* GraphQL */ ` - query getSiteInfo { - site { - categoryTree { - ...categoryTreeItem - children { - ...categoryTreeItem - children { - ...categoryTreeItem - } - } - } - brands { - pageInfo { - startCursor - endCursor - } - edges { - cursor - node { - entityId - name - defaultImage { - urlOriginal - altText - } - pageTitle - metaDesc - metaKeywords - searchKeywords - path - } - } - } - } - } - ${categoryTreeItemFragment} -` - -export type CategoriesTree = NonNullable< - GetSiteInfoQuery['site']['categoryTree'] -> - -export type BrandEdge = NonNullable< - NonNullable<GetSiteInfoQuery['site']['brands']['edges']>[0] -> - -export type Brands = BrandEdge[] - -export type GetSiteInfoResult< - T extends { categories: any[]; brands: any[] } = { - categories: CategoriesTree - brands: Brands - } -> = T - -async function getSiteInfo(opts?: { - variables?: GetSiteInfoQueryVariables - config?: BigcommerceConfig -}): Promise<GetSiteInfoResult> - -async function getSiteInfo< - T extends { categories: any[]; brands: any[] }, - V = any ->(opts: { - query: string - variables?: V - config?: BigcommerceConfig -}): Promise<GetSiteInfoResult<T>> - -async function getSiteInfo({ - query = getSiteInfoQuery, - variables, - config, -}: { - query?: string - variables?: GetSiteInfoQueryVariables - config?: BigcommerceConfig -} = {}): Promise<GetSiteInfoResult> { - config = getConfig(config) - // RecursivePartial forces the method to check for every prop in the data, which is - // required in case there's a custom `query` - const { data } = await config.fetch<RecursivePartial<GetSiteInfoQuery>>( - query, - { variables } - ) - const categories = data.site?.categoryTree - const brands = data.site?.brands?.edges - - return { - categories: (categories as RecursiveRequired<typeof categories>) ?? [], - brands: filterEdges(brands as RecursiveRequired<typeof brands>), - } -} - -export default getSiteInfo diff --git a/lib/bigcommerce/api/operations/login.ts b/lib/bigcommerce/api/operations/login.ts deleted file mode 100644 index e16502af0..000000000 --- a/lib/bigcommerce/api/operations/login.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { ServerResponse } from 'http' -import type { LoginMutation, LoginMutationVariables } from '../../schema' -import type { RecursivePartial } from '../utils/types' -import concatHeader from '../utils/concat-cookie' -import { BigcommerceConfig, getConfig } from '..' - -export const loginMutation = /* GraphQL */ ` - mutation login($email: String!, $password: String!) { - login(email: $email, password: $password) { - result - } - } -` - -export type LoginResult<T extends { result?: any } = { result?: string }> = T - -export type LoginVariables = LoginMutationVariables - -async function login(opts: { - variables: LoginVariables - config?: BigcommerceConfig - res: ServerResponse -}): Promise<LoginResult> - -async function login<T extends { result?: any }, V = any>(opts: { - query: string - variables: V - res: ServerResponse - config?: BigcommerceConfig -}): Promise<LoginResult<T>> - -async function login({ - query = loginMutation, - variables, - res: response, - config, -}: { - query?: string - variables: LoginVariables - res: ServerResponse - config?: BigcommerceConfig -}): Promise<LoginResult> { - config = getConfig(config) - - const { data, res } = await config.fetch<RecursivePartial<LoginMutation>>( - query, - { variables } - ) - // Bigcommerce returns a Set-Cookie header with the auth cookie - let cookie = res.headers.get('Set-Cookie') - - if (cookie && typeof cookie === 'string') { - // In development, don't set a secure cookie or the browser will ignore it - if (process.env.NODE_ENV !== 'production') { - cookie = cookie.replace('; Secure', '') - // SameSite=none can't be set unless the cookie is Secure - cookie = cookie.replace('; SameSite=none', '; SameSite=lax') - } - - response.setHeader( - 'Set-Cookie', - concatHeader(response.getHeader('Set-Cookie'), cookie)! - ) - } - - return { - result: data.login?.result, - } -} - -export default login diff --git a/lib/bigcommerce/api/utils/concat-cookie.ts b/lib/bigcommerce/api/utils/concat-cookie.ts deleted file mode 100644 index 362e12e99..000000000 --- a/lib/bigcommerce/api/utils/concat-cookie.ts +++ /dev/null @@ -1,14 +0,0 @@ -type Header = string | number | string[] | undefined - -export default function concatHeader(prev: Header, val: Header) { - if (!val) return prev - if (!prev) return val - - if (Array.isArray(prev)) return prev.concat(String(val)) - - prev = String(prev) - - if (Array.isArray(val)) return [prev].concat(val) - - return [prev, String(val)] -} diff --git a/lib/bigcommerce/api/utils/create-api-handler.ts b/lib/bigcommerce/api/utils/create-api-handler.ts deleted file mode 100644 index 315ec464b..000000000 --- a/lib/bigcommerce/api/utils/create-api-handler.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next' -import { BigcommerceConfig, getConfig } from '..' - -export type BigcommerceApiHandler< - T = any, - H extends BigcommerceHandlers = {}, - Options extends {} = {} -> = ( - req: NextApiRequest, - res: NextApiResponse<BigcommerceApiResponse<T>>, - config: BigcommerceConfig, - handlers: H, - // Custom configs that may be used by a particular handler - options: Options -) => void | Promise<void> - -export type BigcommerceHandler<T = any, Body = null> = (options: { - req: NextApiRequest - res: NextApiResponse<BigcommerceApiResponse<T>> - config: BigcommerceConfig - body: Body -}) => void | Promise<void> - -export type BigcommerceHandlers<T = any> = { - [k: string]: BigcommerceHandler<T, any> -} - -export type BigcommerceApiResponse<T> = { - data: T | null - errors?: { message: string; code?: string }[] -} - -export default function createApiHandler< - T = any, - H extends BigcommerceHandlers = {}, - Options extends {} = {} ->( - handler: BigcommerceApiHandler<T, H, Options>, - handlers: H, - defaultOptions: Options -) { - return function getApiHandler({ - config, - operations, - options, - }: { - config?: BigcommerceConfig - operations?: Partial<H> - options?: Options extends {} ? Partial<Options> : never - } = {}): NextApiHandler { - const ops = { ...operations, ...handlers } - const opts = { ...defaultOptions, ...options } - - return function apiHandler(req, res) { - return handler(req, res, getConfig(config), ops, opts) - } - } -} diff --git a/lib/bigcommerce/api/utils/errors.ts b/lib/bigcommerce/api/utils/errors.ts deleted file mode 100644 index 77e2007fc..000000000 --- a/lib/bigcommerce/api/utils/errors.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Response } from '@vercel/fetch' - -// Used for GraphQL errors -export class BigcommerceGraphQLError extends Error {} - -export class BigcommerceApiError extends Error { - status: number - res: Response - data: any - - constructor(msg: string, res: Response, data?: any) { - super(msg) - this.name = 'BigcommerceApiError' - this.status = res.status - this.res = res - this.data = data - } -} - -export class BigcommerceNetworkError extends Error { - constructor(msg: string) { - super(msg) - this.name = 'BigcommerceNetworkError' - } -} diff --git a/lib/bigcommerce/api/utils/fetch-graphql-api.ts b/lib/bigcommerce/api/utils/fetch-graphql-api.ts deleted file mode 100644 index 02df1337c..000000000 --- a/lib/bigcommerce/api/utils/fetch-graphql-api.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { FetcherError } from '../../../commerce/utils/errors' -import type { GraphQLFetcher } from '../../../commerce/api' -import { getConfig } from '..' -import fetch from './fetch' - -const fetchGraphqlApi: GraphQLFetcher = async ( - query: string, - { variables, preview } = {}, - fetchOptions -) => { - // log.warn(query) - const config = getConfig() - const res = await fetch(config.commerceUrl + (preview ? '/preview' : ''), { - ...fetchOptions, - method: 'POST', - headers: { - Authorization: `Bearer ${config.apiToken}`, - ...fetchOptions?.headers, - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query, - variables, - }), - }) - - const json = await res.json() - if (json.errors) { - throw new FetcherError({ - errors: json.errors ?? [{ message: 'Failed to fetch Bigcommerce API' }], - status: res.status, - }) - } - - return { data: json.data, res } -} - -export default fetchGraphqlApi diff --git a/lib/bigcommerce/api/utils/fetch-store-api.ts b/lib/bigcommerce/api/utils/fetch-store-api.ts deleted file mode 100644 index 7e59b9f06..000000000 --- a/lib/bigcommerce/api/utils/fetch-store-api.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { RequestInit, Response } from '@vercel/fetch' -import { getConfig } from '..' -import { BigcommerceApiError, BigcommerceNetworkError } from './errors' -import fetch from './fetch' - -export default async function fetchStoreApi<T>( - endpoint: string, - options?: RequestInit -): Promise<T> { - const config = getConfig() - let res: Response - - try { - res = await fetch(config.storeApiUrl + endpoint, { - ...options, - headers: { - ...options?.headers, - 'Content-Type': 'application/json', - 'X-Auth-Token': config.storeApiToken, - 'X-Auth-Client': config.storeApiClientId, - }, - }) - } catch (error) { - throw new BigcommerceNetworkError( - `Fetch to Bigcommerce failed: ${error.message}` - ) - } - - const contentType = res.headers.get('Content-Type') - const isJSON = contentType?.includes('application/json') - - if (!res.ok) { - const data = isJSON ? await res.json() : await getTextOrNull(res) - const headers = getRawHeaders(res) - const msg = `Big Commerce API error (${ - res.status - }) \nHeaders: ${JSON.stringify(headers, null, 2)}\n${ - typeof data === 'string' ? data : JSON.stringify(data, null, 2) - }` - - throw new BigcommerceApiError(msg, res, data) - } - - if (res.status !== 204 && !isJSON) { - throw new BigcommerceApiError( - `Fetch to Bigcommerce API failed, expected JSON content but found: ${contentType}`, - res - ) - } - - // If something was removed, the response will be empty - return res.status === 204 ? null : await res.json() -} - -function getRawHeaders(res: Response) { - const headers: { [key: string]: string } = {} - - res.headers.forEach((value, key) => { - headers[key] = value - }) - - return headers -} - -function getTextOrNull(res: Response) { - try { - return res.text() - } catch (err) { - return null - } -} diff --git a/lib/bigcommerce/api/utils/fetch.ts b/lib/bigcommerce/api/utils/fetch.ts deleted file mode 100644 index 9d9fff3ed..000000000 --- a/lib/bigcommerce/api/utils/fetch.ts +++ /dev/null @@ -1,3 +0,0 @@ -import zeitFetch from '@vercel/fetch' - -export default zeitFetch() diff --git a/lib/bigcommerce/api/utils/filter-edges.ts b/lib/bigcommerce/api/utils/filter-edges.ts deleted file mode 100644 index 09cd20640..000000000 --- a/lib/bigcommerce/api/utils/filter-edges.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default function filterEdges<T>( - edges: (T | null | undefined)[] | null | undefined -) { - return edges?.filter((edge): edge is T => !!edge) ?? [] -} diff --git a/lib/bigcommerce/api/utils/get-cart-cookie.ts b/lib/bigcommerce/api/utils/get-cart-cookie.ts deleted file mode 100644 index 7ca6cd5e4..000000000 --- a/lib/bigcommerce/api/utils/get-cart-cookie.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { serialize, CookieSerializeOptions } from 'cookie' - -export default function getCartCookie( - name: string, - cartId?: string, - maxAge?: number -) { - const options: CookieSerializeOptions = - cartId && maxAge - ? { - maxAge, - expires: new Date(Date.now() + maxAge * 1000), - secure: process.env.NODE_ENV === 'production', - path: '/', - sameSite: 'lax', - } - : { maxAge: -1, path: '/' } // Removes the cookie - - return serialize(name, cartId || '', options) -} diff --git a/lib/bigcommerce/api/utils/is-allowed-method.ts b/lib/bigcommerce/api/utils/is-allowed-method.ts deleted file mode 100644 index 78bbba568..000000000 --- a/lib/bigcommerce/api/utils/is-allowed-method.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' - -export default function isAllowedMethod( - req: NextApiRequest, - res: NextApiResponse, - allowedMethods: string[] -) { - const methods = allowedMethods.includes('OPTIONS') - ? allowedMethods - : [...allowedMethods, 'OPTIONS'] - - if (!req.method || !methods.includes(req.method)) { - res.status(405) - res.setHeader('Allow', methods.join(', ')) - res.end() - return false - } - - if (req.method === 'OPTIONS') { - res.status(200) - res.setHeader('Allow', methods.join(', ')) - res.setHeader('Content-Length', '0') - res.end() - return false - } - - return true -} diff --git a/lib/bigcommerce/api/utils/parse-item.ts b/lib/bigcommerce/api/utils/parse-item.ts deleted file mode 100644 index 2a2c87dde..000000000 --- a/lib/bigcommerce/api/utils/parse-item.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { ItemBody as WishlistItemBody } from '../wishlist' -import type { ItemBody } from '../cart' - -export const parseWishlistItem = (item: WishlistItemBody) => ({ - product_id: item.productId, - variant_id: item.variantId, -}) - -export const parseCartItem = (item: ItemBody) => ({ - quantity: item.quantity, - product_id: item.productId, - variant_id: item.variantId, -}) diff --git a/lib/bigcommerce/api/utils/set-product-locale-meta.ts b/lib/bigcommerce/api/utils/set-product-locale-meta.ts deleted file mode 100644 index 767286477..000000000 --- a/lib/bigcommerce/api/utils/set-product-locale-meta.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ProductNode } from '../operations/get-all-products' -import type { RecursivePartial } from './types' - -export default function setProductLocaleMeta( - node: RecursivePartial<ProductNode> -) { - if (node.localeMeta?.edges) { - node.localeMeta.edges = node.localeMeta.edges.filter((edge) => { - const { key, value } = edge?.node ?? {} - if (key && key in node) { - ;(node as any)[key] = value - return false - } - return true - }) - - if (!node.localeMeta.edges.length) { - delete node.localeMeta - } - } -} diff --git a/lib/bigcommerce/api/utils/types.ts b/lib/bigcommerce/api/utils/types.ts deleted file mode 100644 index 56f9c1728..000000000 --- a/lib/bigcommerce/api/utils/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type RecursivePartial<T> = { - [P in keyof T]?: RecursivePartial<T[P]> -} - -export type RecursiveRequired<T> = { - [P in keyof T]-?: RecursiveRequired<T[P]> -} diff --git a/lib/bigcommerce/api/wishlist/handlers/add-item.ts b/lib/bigcommerce/api/wishlist/handlers/add-item.ts deleted file mode 100644 index a02ef4434..000000000 --- a/lib/bigcommerce/api/wishlist/handlers/add-item.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { WishlistHandlers } from '..' -import getCustomerId from '../../operations/get-customer-id' -import getCustomerWishlist from '../../operations/get-customer-wishlist' -import { parseWishlistItem } from '../../utils/parse-item' - -// Returns the wishlist of the signed customer -const addItem: WishlistHandlers['addItem'] = async ({ - res, - body: { customerToken, item }, - config, -}) => { - if (!item) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Missing item' }], - }) - } - - const customerId = - customerToken && (await getCustomerId({ customerToken, config })) - - if (!customerId) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - - const { wishlist } = await getCustomerWishlist({ - variables: { customerId }, - config, - }) - const options = { - method: 'POST', - body: JSON.stringify( - wishlist - ? { - items: [parseWishlistItem(item)], - } - : { - name: 'Wishlist', - customer_id: customerId, - items: [parseWishlistItem(item)], - is_public: false, - } - ), - } - - const { data } = wishlist - ? await config.storeApiFetch(`/v3/wishlists/${wishlist.id}/items`, options) - : await config.storeApiFetch('/v3/wishlists', options) - - res.status(200).json({ data }) -} - -export default addItem diff --git a/lib/bigcommerce/api/wishlist/handlers/get-wishlist.ts b/lib/bigcommerce/api/wishlist/handlers/get-wishlist.ts deleted file mode 100644 index a77cf4467..000000000 --- a/lib/bigcommerce/api/wishlist/handlers/get-wishlist.ts +++ /dev/null @@ -1,35 +0,0 @@ -import getCustomerId from '../../operations/get-customer-id' -import type { Wishlist, WishlistHandlers } from '..' -import getCustomerWishlist from '../../operations/get-customer-wishlist' - -// Return wishlist info -const getWishlist: WishlistHandlers['getWishlist'] = async ({ - res, - body: { customerToken }, - config, -}) => { - let result: { data?: Wishlist } = {} - - if (customerToken) { - const customerId = - customerToken && (await getCustomerId({ customerToken, config })) - - if (!customerId) { - // If the customerToken is invalid, then this request is too - return res.status(404).json({ - data: null, - errors: [{ message: 'Wishlist not found' }], - }) - } - - const { wishlist } = await getCustomerWishlist({ - variables: { customerId }, - config, - }) - result = { data: wishlist } - } - - res.status(200).json({ data: result.data ?? null }) -} - -export default getWishlist diff --git a/lib/bigcommerce/api/wishlist/handlers/remove-item.ts b/lib/bigcommerce/api/wishlist/handlers/remove-item.ts deleted file mode 100644 index 29b6eff60..000000000 --- a/lib/bigcommerce/api/wishlist/handlers/remove-item.ts +++ /dev/null @@ -1,39 +0,0 @@ -import getCustomerId from '../../operations/get-customer-id' -import getCustomerWishlist, { - Wishlist, -} from '../../operations/get-customer-wishlist' -import type { WishlistHandlers } from '..' - -// Return current wishlist info -const removeItem: WishlistHandlers['removeItem'] = async ({ - res, - body: { customerToken, itemId }, - config, -}) => { - const customerId = - customerToken && (await getCustomerId({ customerToken, config })) - const { wishlist } = - (customerId && - (await getCustomerWishlist({ - variables: { customerId }, - config, - }))) || - {} - - if (!wishlist || !itemId) { - return res.status(400).json({ - data: null, - errors: [{ message: 'Invalid request' }], - }) - } - - const result = await config.storeApiFetch<{ data: Wishlist } | null>( - `/v3/wishlists/${wishlist.id}/items/${itemId}`, - { method: 'DELETE' } - ) - const data = result?.data ?? null - - res.status(200).json({ data }) -} - -export default removeItem diff --git a/lib/bigcommerce/api/wishlist/index.ts b/lib/bigcommerce/api/wishlist/index.ts deleted file mode 100644 index 79f0a9c1a..000000000 --- a/lib/bigcommerce/api/wishlist/index.ts +++ /dev/null @@ -1,94 +0,0 @@ -import isAllowedMethod from '../utils/is-allowed-method' -import createApiHandler, { - BigcommerceApiHandler, - BigcommerceHandler, -} from '../utils/create-api-handler' -import { BigcommerceApiError } from '../utils/errors' -import getWishlist from './handlers/get-wishlist' -import addItem from './handlers/add-item' -import removeItem from './handlers/remove-item' -import { definitions } from '../definitions/wishlist' - -export type ItemBody = { - productId: number - variantId: number -} - -export type AddItemBody = { item: ItemBody } - -export type RemoveItemBody = { itemId: string } - -export type WishlistBody = { - customer_id: number - is_public: number - name: string - items: any[] -} - -export type AddWishlistBody = { wishlist: WishlistBody } - -export type Wishlist = definitions['wishlist_Full'] - -export type WishlistHandlers = { - getWishlist: BigcommerceHandler<Wishlist, { customerToken?: string }> - addItem: BigcommerceHandler< - Wishlist, - { customerToken?: string } & Partial<AddItemBody> - > - removeItem: BigcommerceHandler< - Wishlist, - { customerToken?: string } & Partial<RemoveItemBody> - > -} - -const METHODS = ['GET', 'POST', 'DELETE'] - -// TODO: a complete implementation should have schema validation for `req.body` -const wishlistApi: BigcommerceApiHandler<Wishlist, WishlistHandlers> = async ( - req, - res, - config, - handlers -) => { - if (!isAllowedMethod(req, res, METHODS)) return - - const { cookies } = req - const customerToken = cookies[config.customerCookie] - - try { - // Return current wishlist info - if (req.method === 'GET') { - const body = { customerToken } - return await handlers['getWishlist']({ req, res, config, body }) - } - - // Add an item to the wishlist - if (req.method === 'POST') { - const body = { ...req.body, customerToken } - return await handlers['addItem']({ req, res, config, body }) - } - - // Remove an item from the wishlist - if (req.method === 'DELETE') { - const body = { ...req.body, customerToken } - return await handlers['removeItem']({ req, res, config, body }) - } - } catch (error) { - console.error(error) - - const message = - error instanceof BigcommerceApiError - ? 'An unexpected error ocurred with the Bigcommerce API' - : 'An unexpected error ocurred' - - res.status(500).json({ data: null, errors: [{ message }] }) - } -} - -export const handlers = { - getWishlist, - addItem, - removeItem, -} - -export default createApiHandler(wishlistApi, handlers, {}) diff --git a/lib/bigcommerce/cart/use-add-item.tsx b/lib/bigcommerce/cart/use-add-item.tsx deleted file mode 100644 index 75e8ec3e6..000000000 --- a/lib/bigcommerce/cart/use-add-item.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useCallback } from 'react' -import type { HookFetcher } from '../../commerce/utils/types' -import { CommerceError } from '../../commerce/utils/errors' -import useCartAddItem from '../../commerce/cart/use-add-item' -import type { ItemBody, AddItemBody } from '../api/cart' -import useCart, { Cart } from './use-cart' - -const defaultOpts = { - url: '/api/bigcommerce/cart', - method: 'POST', -} - -export type AddItemInput = ItemBody - -export const fetcher: HookFetcher<Cart, AddItemBody> = ( - options, - { item }, - fetch -) => { - if ( - item.quantity && - (!Number.isInteger(item.quantity) || item.quantity! < 1) - ) { - throw new CommerceError({ - message: 'The item quantity has to be a valid integer greater than 0', - }) - } - - return fetch({ - ...defaultOpts, - ...options, - body: { item }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useAddItem = () => { - const { mutate } = useCart() - const fn = useCartAddItem(defaultOpts, customFetcher) - - return useCallback( - async function addItem(input: AddItemInput) { - const data = await fn({ item: input }) - await mutate(data, false) - return data - }, - [fn, mutate] - ) - } - - useAddItem.extend = extendHook - - return useAddItem -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/cart/use-cart-actions.tsx b/lib/bigcommerce/cart/use-cart-actions.tsx deleted file mode 100644 index abb4a998e..000000000 --- a/lib/bigcommerce/cart/use-cart-actions.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import useAddItem from './use-add-item' -import useRemoveItem from './use-remove-item' -import useUpdateItem from './use-update-item' - -// This hook is probably not going to be used, but it's here -// to show how a commerce should be structuring it -export default function useCartActions() { - const addItem = useAddItem() - const updateItem = useUpdateItem() - const removeItem = useRemoveItem() - - return { addItem, updateItem, removeItem } -} diff --git a/lib/bigcommerce/cart/use-cart.tsx b/lib/bigcommerce/cart/use-cart.tsx deleted file mode 100644 index a80d3e091..000000000 --- a/lib/bigcommerce/cart/use-cart.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import type { HookFetcher } from '../../commerce/utils/types' -import type { SwrOptions } from '../../commerce/utils/use-data' -import useCommerceCart, { CartInput } from '../../commerce/cart/use-cart' -import type { Cart } from '../api/cart' - -const defaultOpts = { - url: '/api/bigcommerce/cart', - method: 'GET', -} - -export type { Cart } - -export const fetcher: HookFetcher<Cart | null, CartInput> = ( - options, - { cartId }, - fetch -) => { - return cartId ? fetch({ ...defaultOpts, ...options }) : null -} - -export function extendHook( - customFetcher: typeof fetcher, - swrOptions?: SwrOptions<Cart | null, CartInput> -) { - const useCart = () => { - const response = useCommerceCart(defaultOpts, [], customFetcher, { - revalidateOnFocus: false, - ...swrOptions, - }) - - // Uses a getter to only calculate the prop when required - // response.data is also a getter and it's better to not trigger it early - Object.defineProperty(response, 'isEmpty', { - get() { - return Object.values(response.data?.line_items ?? {}).every( - (items) => !items.length - ) - }, - set: (x) => x, - }) - - return response - } - - useCart.extend = extendHook - - return useCart -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/cart/use-remove-item.tsx b/lib/bigcommerce/cart/use-remove-item.tsx deleted file mode 100644 index 319b722d3..000000000 --- a/lib/bigcommerce/cart/use-remove-item.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { useCallback } from 'react' -import { HookFetcher } from '../../commerce/utils/types' -import useCartRemoveItem from '../../commerce/cart/use-remove-item' -import type { RemoveItemBody } from '../api/cart' -import useCart, { Cart } from './use-cart' - -const defaultOpts = { - url: '/api/bigcommerce/cart', - method: 'DELETE', -} - -export type RemoveItemInput = { - id: string -} - -export const fetcher: HookFetcher<Cart | null, RemoveItemBody> = ( - options, - { itemId }, - fetch -) => { - return fetch({ - ...defaultOpts, - ...options, - body: { itemId }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useRemoveItem = () => { - const { mutate } = useCart() - const fn = useCartRemoveItem<Cart | null, RemoveItemBody>( - defaultOpts, - customFetcher - ) - - return useCallback( - async function removeItem(input: RemoveItemInput) { - const data = await fn({ itemId: input.id }) - await mutate(data, false) - return data - }, - [fn, mutate] - ) - } - - useRemoveItem.extend = extendHook - - return useRemoveItem -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/cart/use-update-item.tsx b/lib/bigcommerce/cart/use-update-item.tsx deleted file mode 100644 index e335677d6..000000000 --- a/lib/bigcommerce/cart/use-update-item.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { useCallback } from 'react' -import debounce from 'lodash.debounce' -import type { HookFetcher } from '../../commerce/utils/types' -import { CommerceError } from '../../commerce/utils/errors' -import useCartUpdateItem from '../../commerce/cart/use-update-item' -import type { ItemBody, UpdateItemBody } from '../api/cart' -import { fetcher as removeFetcher } from './use-remove-item' -import useCart, { Cart } from './use-cart' - -const defaultOpts = { - url: '/api/bigcommerce/cart', - method: 'PUT', -} - -export type UpdateItemInput = Partial<{ id: string } & ItemBody> - -export const fetcher: HookFetcher<Cart | null, UpdateItemBody> = ( - options, - { itemId, item }, - fetch -) => { - 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) { - return removeFetcher(null, { itemId }, fetch) - } - } else if (item.quantity) { - throw new CommerceError({ - message: 'The item quantity has to be a valid integer', - }) - } - - return fetch({ - ...defaultOpts, - ...options, - body: { itemId, item }, - }) -} - -function extendHook(customFetcher: typeof fetcher, cfg?: { wait?: number }) { - const useUpdateItem = (item?: any) => { - const { mutate } = useCart() - const fn = useCartUpdateItem<Cart | null, UpdateItemBody>( - defaultOpts, - customFetcher - ) - - return useCallback( - debounce(async (input: UpdateItemInput) => { - const data = await fn({ - itemId: input.id ?? item?.id, - item: { - productId: input.productId ?? item?.product_id, - variantId: input.productId ?? item?.variant_id, - quantity: input.quantity, - }, - }) - await mutate(data, false) - return data - }, cfg?.wait ?? 500), - [fn, mutate] - ) - } - - useUpdateItem.extend = extendHook - - return useUpdateItem -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/index.tsx b/lib/bigcommerce/index.tsx deleted file mode 100644 index 96faef82b..000000000 --- a/lib/bigcommerce/index.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { ReactNode } from 'react' -import { - CommerceConfig, - CommerceProvider as CoreCommerceProvider, - useCommerce as useCoreCommerce, -} from '../commerce' -import { FetcherError } from '../commerce/utils/errors' - -async function getText(res: Response) { - try { - return (await res.text()) || res.statusText - } catch (error) { - return res.statusText - } -} - -async function getError(res: Response) { - if (res.headers.get('Content-Type')?.includes('application/json')) { - const data = await res.json() - return new FetcherError({ errors: data.errors, status: res.status }) - } - return new FetcherError({ message: await getText(res), status: res.status }) -} - -export const bigcommerceConfig: CommerceConfig = { - locale: 'en-us', - cartCookie: 'bc_cartId', - async fetcher({ url, method = 'GET', variables, body: bodyObj }) { - const hasBody = Boolean(variables || bodyObj) - const body = hasBody - ? JSON.stringify(variables ? { variables } : bodyObj) - : undefined - const headers = hasBody ? { 'Content-Type': 'application/json' } : undefined - const res = await fetch(url!, { method, body, headers }) - - if (res.ok) { - const { data } = await res.json() - return data - } - - throw await getError(res) - }, -} - -export type BigcommerceConfig = Partial<CommerceConfig> - -export type BigcommerceProps = { - children?: ReactNode - locale: string -} & BigcommerceConfig - -export function CommerceProvider({ children, ...config }: BigcommerceProps) { - return ( - <CoreCommerceProvider config={{ ...bigcommerceConfig, ...config }}> - {children} - </CoreCommerceProvider> - ) -} - -export const useCommerce = () => useCoreCommerce() diff --git a/lib/bigcommerce/products/use-search.tsx b/lib/bigcommerce/products/use-search.tsx deleted file mode 100644 index f90051887..000000000 --- a/lib/bigcommerce/products/use-search.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import type { HookFetcher } from '../../commerce/utils/types' -import type { SwrOptions } from '../../commerce/utils/use-data' -import useCommerceSearch from '../../commerce/products/use-search' -import type { SearchProductsData } from '../api/catalog/products' - -const defaultOpts = { - url: '/api/bigcommerce/catalog/products', - method: 'GET', -} - -export type SearchProductsInput = { - search?: string - categoryId?: number - brandId?: number - sort?: string -} - -export const fetcher: HookFetcher<SearchProductsData, SearchProductsInput> = ( - options, - { search, categoryId, brandId, sort }, - fetch -) => { - // Use a dummy base as we only care about the relative path - const url = new URL(options?.url ?? defaultOpts.url, 'http://a') - - if (search) url.searchParams.set('search', search) - if (Number.isInteger(categoryId)) - url.searchParams.set('category', String(categoryId)) - if (Number.isInteger(categoryId)) - url.searchParams.set('brand', String(brandId)) - if (sort) url.searchParams.set('sort', sort) - - return fetch({ - url: url.pathname + url.search, - method: options?.method ?? defaultOpts.method, - }) -} - -export function extendHook( - customFetcher: typeof fetcher, - swrOptions?: SwrOptions<SearchProductsData, SearchProductsInput> -) { - const useSearch = (input: SearchProductsInput = {}) => { - const response = useCommerceSearch( - defaultOpts, - [ - ['search', input.search], - ['categoryId', input.categoryId], - ['brandId', input.brandId], - ['sort', input.sort], - ], - customFetcher, - { revalidateOnFocus: false, ...swrOptions } - ) - - return response - } - - useSearch.extend = extendHook - - return useSearch -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/schema.d.ts b/lib/bigcommerce/schema.d.ts deleted file mode 100644 index aaafbe312..000000000 --- a/lib/bigcommerce/schema.d.ts +++ /dev/null @@ -1,1970 +0,0 @@ -export type Maybe<T> = T | null -export type Exact<T extends { [key: string]: unknown }> = { - [K in keyof T]: T[K] -} -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: string - String: string - Boolean: boolean - Int: number - Float: number - DateTime: any - /** The `BigDecimal` scalar type represents signed fractional values with arbitrary precision. */ - BigDecimal: any - /** The `Long` scalar type represents non-fractional signed whole numeric values. Long can represent values between -(2^63) and 2^63 - 1. */ - Long: any -} - -/** Login result */ -export type LoginResult = { - __typename?: 'LoginResult' - /** The result of a login */ - result: Scalars['String'] -} - -/** Logout result */ -export type LogoutResult = { - __typename?: 'LogoutResult' - /** The result of a logout */ - result: Scalars['String'] -} - -export type Mutation = { - __typename?: 'Mutation' - login: LoginResult - logout: LogoutResult -} - -export type MutationLoginArgs = { - email: Scalars['String'] - password: Scalars['String'] -} - -/** Aggregated */ -export type Aggregated = { - __typename?: 'Aggregated' - /** Number of available products in stock. This can be 'null' if inventory is not set orif the store's Inventory Settings disable displaying stock levels on the storefront. */ - availableToSell: Scalars['Long'] - /** Indicates a threshold low-stock level. This can be 'null' if the inventory warning level is not set or if the store's Inventory Settings disable displaying stock levels on the storefront. */ - warningLevel: Scalars['Int'] -} - -/** Aggregated Product Inventory */ -export type AggregatedInventory = { - __typename?: 'AggregatedInventory' - /** Number of available products in stock. This can be 'null' if inventory is not set orif the store's Inventory Settings disable displaying stock levels on the storefront. */ - availableToSell: Scalars['Int'] - /** Indicates a threshold low-stock level. This can be 'null' if the inventory warning level is not set or if the store's Inventory Settings disable displaying stock levels on the storefront. */ - warningLevel: Scalars['Int'] -} - -/** Brand */ -export type Brand = Node & { - __typename?: 'Brand' - /** The ID of an object */ - id: Scalars['ID'] - /** Id of the brand. */ - entityId: Scalars['Int'] - /** Name of the brand. */ - name: Scalars['String'] - /** Default image for brand. */ - defaultImage?: Maybe<Image> - /** Page title for the brand. */ - pageTitle: Scalars['String'] - /** Meta description for the brand. */ - metaDesc: Scalars['String'] - /** Meta keywords for the brand. */ - metaKeywords: Array<Scalars['String']> - /** Search keywords for the brand. */ - searchKeywords: Array<Scalars['String']> - /** Path for the brand page. */ - path: Scalars['String'] - products: ProductConnection - /** Metafield data related to a brand. */ - metafields: MetafieldConnection -} - -/** Brand */ -export type BrandProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Brand */ -export type BrandMetafieldsArgs = { - namespace: Scalars['String'] - keys?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A connection to a list of items. */ -export type BrandConnection = { - __typename?: 'BrandConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<BrandEdge>>> -} - -/** An edge in a connection. */ -export type BrandEdge = { - __typename?: 'BrandEdge' - /** The item at the end of the edge. */ - node: Brand - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Breadcrumb */ -export type Breadcrumb = { - __typename?: 'Breadcrumb' - /** Category id. */ - entityId: Scalars['Int'] - /** Name of the category. */ - name: Scalars['String'] -} - -/** A connection to a list of items. */ -export type BreadcrumbConnection = { - __typename?: 'BreadcrumbConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<BreadcrumbEdge>>> -} - -/** An edge in a connection. */ -export type BreadcrumbEdge = { - __typename?: 'BreadcrumbEdge' - /** The item at the end of the edge. */ - node: Breadcrumb - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Bulk pricing tier that sets a fixed price for the product or variant. */ -export type BulkPricingFixedPriceDiscount = BulkPricingTier & { - __typename?: 'BulkPricingFixedPriceDiscount' - /** This price will override the current product price. */ - price: Scalars['BigDecimal'] - /** Minimum item quantity that applies to this bulk pricing tier. */ - minimumQuantity: Scalars['Int'] - /** Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. */ - maximumQuantity?: Maybe<Scalars['Int']> -} - -/** Bulk pricing tier that reduces the price of the product or variant by a percentage. */ -export type BulkPricingPercentageDiscount = BulkPricingTier & { - __typename?: 'BulkPricingPercentageDiscount' - /** The percentage that will be removed from the product price. */ - percentOff: Scalars['BigDecimal'] - /** Minimum item quantity that applies to this bulk pricing tier. */ - minimumQuantity: Scalars['Int'] - /** Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. */ - maximumQuantity?: Maybe<Scalars['Int']> -} - -/** Bulk pricing tier that will subtract an amount from the price of the product or variant. */ -export type BulkPricingRelativePriceDiscount = BulkPricingTier & { - __typename?: 'BulkPricingRelativePriceDiscount' - /** The price of the product/variant will be reduced by this priceAdjustment. */ - priceAdjustment: Scalars['BigDecimal'] - /** Minimum item quantity that applies to this bulk pricing tier. */ - minimumQuantity: Scalars['Int'] - /** Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. */ - maximumQuantity?: Maybe<Scalars['Int']> -} - -/** A set of bulk pricing tiers that define price discounts which apply when purchasing specified quantities of a product or variant. */ -export type BulkPricingTier = { - /** Minimum item quantity that applies to this bulk pricing tier. */ - minimumQuantity: Scalars['Int'] - /** Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. */ - maximumQuantity?: Maybe<Scalars['Int']> -} - -/** Product Option */ -export type CatalogProductOption = { - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** Product Option Value */ -export type CatalogProductOptionValue = { - /** Unique ID for the option value. */ - entityId: Scalars['Int'] - /** Label for the option value. */ - label: Scalars['String'] - /** Indicates whether this value is the chosen default selected value. */ - isDefault: Scalars['Boolean'] -} - -/** Category */ -export type Category = Node & { - __typename?: 'Category' - /** The ID of an object */ - id: Scalars['ID'] - /** Unique ID for the category. */ - entityId: Scalars['Int'] - /** Category name. */ - name: Scalars['String'] - /** Category path. */ - path: Scalars['String'] - /** Default image for the category. */ - defaultImage?: Maybe<Image> - /** Category description. */ - description: Scalars['String'] - /** Category breadcrumbs. */ - breadcrumbs: BreadcrumbConnection - products: ProductConnection - /** Metafield data related to a category. */ - metafields: MetafieldConnection -} - -/** Category */ -export type CategoryBreadcrumbsArgs = { - depth: Scalars['Int'] - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Category */ -export type CategoryProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Category */ -export type CategoryMetafieldsArgs = { - namespace: Scalars['String'] - keys?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A connection to a list of items. */ -export type CategoryConnection = { - __typename?: 'CategoryConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<CategoryEdge>>> -} - -/** An edge in a connection. */ -export type CategoryEdge = { - __typename?: 'CategoryEdge' - /** The item at the end of the edge. */ - node: Category - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** An item in a tree of categories. */ -export type CategoryTreeItem = { - __typename?: 'CategoryTreeItem' - /** The id category. */ - entityId: Scalars['Int'] - /** The name of category. */ - name: Scalars['String'] - /** Path assigned to this category */ - path: Scalars['String'] - /** The description of this category. */ - description: Scalars['String'] - /** The number of products in this category. */ - productCount: Scalars['Int'] - /** Subcategories of this category */ - children: Array<CategoryTreeItem> -} - -/** A simple yes/no question represented by a checkbox. */ -export type CheckboxOption = CatalogProductOption & { - __typename?: 'CheckboxOption' - /** Indicates the default checked status. */ - checkedByDefault: Scalars['Boolean'] - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** Contact field */ -export type ContactField = { - __typename?: 'ContactField' - /** Store address line. */ - address: Scalars['String'] - /** Store country. */ - country: Scalars['String'] - /** Store address type. */ - addressType: Scalars['String'] - /** Store email. */ - email: Scalars['String'] - /** Store phone number. */ - phone: Scalars['String'] -} - -/** Custom field */ -export type CustomField = { - __typename?: 'CustomField' - /** Custom field id. */ - entityId: Scalars['Int'] - /** Name of the custom field. */ - name: Scalars['String'] - /** Value of the custom field. */ - value: Scalars['String'] -} - -/** A connection to a list of items. */ -export type CustomFieldConnection = { - __typename?: 'CustomFieldConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<CustomFieldEdge>>> -} - -/** An edge in a connection. */ -export type CustomFieldEdge = { - __typename?: 'CustomFieldEdge' - /** The item at the end of the edge. */ - node: CustomField - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** A customer that shops on a store */ -export type Customer = { - __typename?: 'Customer' - /** The ID of the customer. */ - entityId: Scalars['Int'] - /** The company name of the customer. */ - company: Scalars['String'] - /** The customer group id of the customer. */ - customerGroupId: Scalars['Int'] - /** The email address of the customer. */ - email: Scalars['String'] - /** The first name of the customer. */ - firstName: Scalars['String'] - /** The last name of the customer. */ - lastName: Scalars['String'] - /** The notes of the customer. */ - notes: Scalars['String'] - /** The phone number of the customer. */ - phone: Scalars['String'] - /** The tax exempt category of the customer. */ - taxExemptCategory: Scalars['String'] - /** Customer addresses count. */ - addressCount: Scalars['Int'] - /** Customer attributes count. */ - attributeCount: Scalars['Int'] - /** Customer store credit. */ - storeCredit: Array<Money> - /** Customer attributes. */ - attributes: CustomerAttributes -} - -/** A custom, store-specific attribute for a customer */ -export type CustomerAttribute = { - __typename?: 'CustomerAttribute' - /** The ID of the custom customer attribute */ - entityId: Scalars['Int'] - /** The value of the custom customer attribute */ - value?: Maybe<Scalars['String']> - /** The name of the custom customer attribute */ - name: Scalars['String'] -} - -/** Custom, store-specific customer attributes */ -export type CustomerAttributes = { - __typename?: 'CustomerAttributes' - attribute: CustomerAttribute -} - -/** Custom, store-specific customer attributes */ -export type CustomerAttributesAttributeArgs = { - entityId: Scalars['Int'] -} - -/** A calendar for allowing selection of a date. */ -export type DateFieldOption = CatalogProductOption & { - __typename?: 'DateFieldOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** Date Time Extended */ -export type DateTimeExtended = { - __typename?: 'DateTimeExtended' - /** ISO-8601 formatted date in UTC */ - utc: Scalars['DateTime'] -} - -/** Display field */ -export type DisplayField = { - __typename?: 'DisplayField' - /** Short date format. */ - shortDateFormat: Scalars['String'] - /** Extended date format. */ - extendedDateFormat: Scalars['String'] -} - -/** A form allowing selection and uploading of a file from the user's local computer. */ -export type FileUploadFieldOption = CatalogProductOption & { - __typename?: 'FileUploadFieldOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** Image */ -export type Image = { - __typename?: 'Image' - /** Absolute path to image using store CDN. */ - url: Scalars['String'] - /** Absolute path to original image using store CDN. */ - urlOriginal: Scalars['String'] - /** Text description of an image that can be used for SEO and/or accessibility purposes. */ - altText: Scalars['String'] - /** Indicates whether this is the primary image. */ - isDefault: Scalars['Boolean'] -} - -/** Image */ -export type ImageUrlArgs = { - width: Scalars['Int'] - height?: Maybe<Scalars['Int']> -} - -/** A connection to a list of items. */ -export type ImageConnection = { - __typename?: 'ImageConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<ImageEdge>>> -} - -/** An edge in a connection. */ -export type ImageEdge = { - __typename?: 'ImageEdge' - /** The item at the end of the edge. */ - node: Image - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** An inventory */ -export type Inventory = { - __typename?: 'Inventory' - /** Locations */ - locations: LocationConnection -} - -/** An inventory */ -export type InventoryLocationsArgs = { - entityIds?: Maybe<Array<Scalars['Int']>> - codes?: Maybe<Array<Scalars['String']>> - typeIds?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Inventory By Locations */ -export type InventoryByLocations = { - __typename?: 'InventoryByLocations' - /** Location id. */ - locationEntityId: Scalars['Long'] - /** Number of available products in stock. */ - availableToSell: Scalars['Long'] - /** Indicates a threshold low-stock level. */ - warningLevel: Scalars['Int'] - /** Indicates whether this product is in stock. */ - isInStock: Scalars['Boolean'] -} - -/** A connection to a list of items. */ -export type LocationConnection = { - __typename?: 'LocationConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<LocationEdge>>> -} - -/** An edge in a connection. */ -export type LocationEdge = { - __typename?: 'LocationEdge' - /** The item at the end of the edge. */ - node: InventoryByLocations - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Logo field */ -export type LogoField = { - __typename?: 'LogoField' - /** Logo title. */ - title: Scalars['String'] - /** Store logo image. */ - image: Image -} - -/** Measurement */ -export type Measurement = { - __typename?: 'Measurement' - /** Unformatted weight measurement value. */ - value: Scalars['Float'] - /** Unit of measurement. */ - unit: Scalars['String'] -} - -/** A connection to a list of items. */ -export type MetafieldConnection = { - __typename?: 'MetafieldConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<MetafieldEdge>>> -} - -/** An edge in a connection. */ -export type MetafieldEdge = { - __typename?: 'MetafieldEdge' - /** The item at the end of the edge. */ - node: Metafields - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Key/Value pairs of data attached tied to a resource entity (product, brand, category, etc.) */ -export type Metafields = { - __typename?: 'Metafields' - /** The ID of an object */ - id: Scalars['ID'] - /** The ID of the metafield when referencing via our backend API. */ - entityId: Scalars['Int'] - /** A label for identifying a metafield data value. */ - key: Scalars['String'] - /** A metafield value. */ - value: Scalars['String'] -} - -/** A money object - includes currency code and a money amount */ -export type Money = { - __typename?: 'Money' - /** Currency code of the current money. */ - currencyCode: Scalars['String'] - /** The amount of money. */ - value: Scalars['BigDecimal'] -} - -/** A min and max pair of money objects */ -export type MoneyRange = { - __typename?: 'MoneyRange' - /** Minimum money object. */ - min: Money - /** Maximum money object. */ - max: Money -} - -/** A multi-line text input field, aka a text box. */ -export type MultiLineTextFieldOption = CatalogProductOption & { - __typename?: 'MultiLineTextFieldOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** An option type that has a fixed list of values. */ -export type MultipleChoiceOption = CatalogProductOption & { - __typename?: 'MultipleChoiceOption' - /** The chosen display style for this multiple choice option. */ - displayStyle: Scalars['String'] - /** List of option values. */ - values: ProductOptionValueConnection - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** An option type that has a fixed list of values. */ -export type MultipleChoiceOptionValuesArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A simple multiple choice value comprised of an id and a label. */ -export type MultipleChoiceOptionValue = CatalogProductOptionValue & { - __typename?: 'MultipleChoiceOptionValue' - /** Unique ID for the option value. */ - entityId: Scalars['Int'] - /** Label for the option value. */ - label: Scalars['String'] - /** Indicates whether this value is the chosen default selected value. */ - isDefault: Scalars['Boolean'] -} - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID'] -} - -/** A single line text input field that only accepts numbers. */ -export type NumberFieldOption = CatalogProductOption & { - __typename?: 'NumberFieldOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** A connection to a list of items. */ -export type OptionConnection = { - __typename?: 'OptionConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<OptionEdge>>> -} - -/** An edge in a connection. */ -export type OptionEdge = { - __typename?: 'OptionEdge' - /** The item at the end of the edge. */ - node: ProductOption - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** A connection to a list of items. */ -export type OptionValueConnection = { - __typename?: 'OptionValueConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<OptionValueEdge>>> -} - -/** An edge in a connection. */ -export type OptionValueEdge = { - __typename?: 'OptionValueEdge' - /** The item at the end of the edge. */ - node: ProductOptionValue - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -export type OptionValueId = { - optionEntityId: Scalars['Int'] - valueEntityId: Scalars['Int'] -} - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo' - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean'] - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean'] - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe<Scalars['String']> - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe<Scalars['String']> -} - -/** The min and max range of prices that apply to this product. */ -export type PriceRanges = { - __typename?: 'PriceRanges' - /** Product price min/max range. */ - priceRange: MoneyRange - /** Product retail price min/max range. */ - retailPriceRange?: Maybe<MoneyRange> -} - -/** The various prices that can be set on a product. */ -export type Prices = { - __typename?: 'Prices' - /** Calculated price of the product. */ - price: Money - /** Sale price of the product. */ - salePrice?: Maybe<Money> - /** Original price of the product. */ - basePrice?: Maybe<Money> - /** Retail price of the product. */ - retailPrice?: Maybe<Money> - /** Minimum advertised price of the product. */ - mapPrice?: Maybe<Money> - /** Product price min/max range. */ - priceRange: MoneyRange - /** Product retail price min/max range. */ - retailPriceRange?: Maybe<MoneyRange> - /** The difference between the retail price (MSRP) and the current price, which can be presented to the shopper as their savings. */ - saved?: Maybe<Money> - /** List of bulk pricing tiers applicable to a product or variant. */ - bulkPricing: Array<BulkPricingTier> -} - -/** Product */ -export type Product = Node & { - __typename?: 'Product' - /** The ID of an object */ - id: Scalars['ID'] - /** Id of the product. */ - entityId: Scalars['Int'] - /** Default product variant when no options are selected. */ - sku: Scalars['String'] - /** Relative URL path to product page. */ - path: Scalars['String'] - /** Name of the product. */ - name: Scalars['String'] - /** Description of the product. */ - description: Scalars['String'] - /** Description of the product in plain text. */ - plainTextDescription: Scalars['String'] - /** Warranty information of the product. */ - warranty: Scalars['String'] - /** Minimum purchasable quantity for this product in a single order. */ - minPurchaseQuantity?: Maybe<Scalars['Int']> - /** Maximum purchasable quantity for this product in a single order. */ - maxPurchaseQuantity?: Maybe<Scalars['Int']> - /** Absolute URL path for adding a product to cart. */ - addToCartUrl: Scalars['String'] - /** Absolute URL path for adding a product to customer's wishlist. */ - addToWishlistUrl: Scalars['String'] - /** Prices object determined by supplied product ID, variant ID, and selected option IDs. */ - prices?: Maybe<Prices> - /** - * The minimum and maximum price of this product based on variant pricing and/or modifier price rules. - * @deprecated Use priceRanges inside prices node instead. - */ - priceRanges?: Maybe<PriceRanges> - /** Weight of the product. */ - weight?: Maybe<Measurement> - /** Height of the product. */ - height?: Maybe<Measurement> - /** Width of the product. */ - width?: Maybe<Measurement> - /** Depth of the product. */ - depth?: Maybe<Measurement> - /** Product options. */ - options: OptionConnection - /** Product options. */ - productOptions: ProductOptionConnection - /** Summary of the product reviews, includes the total number of reviews submitted and summation of the ratings on the reviews (ratings range from 0-5 per review). */ - reviewSummary: Reviews - /** Type of product, ex: physical, digital */ - type: Scalars['String'] - /** - * The availability state of the product. - * @deprecated Use status inside availabilityV2 instead. - */ - availability: Scalars['String'] - /** - * A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - * @deprecated Use description inside availabilityV2 instead. - */ - availabilityDescription: Scalars['String'] - /** The availability state of the product. */ - availabilityV2: ProductAvailability - /** List of categories associated with the product. */ - categories: CategoryConnection - /** Brand associated with the product. */ - brand?: Maybe<Brand> - /** Variants associated with the product. */ - variants: VariantConnection - /** Custom fields of the product. */ - customFields: CustomFieldConnection - /** A list of the images for a product. */ - images: ImageConnection - /** Default image for a product. */ - defaultImage?: Maybe<Image> - /** Related products for this product. */ - relatedProducts: RelatedProductsConnection - /** Inventory information of the product. */ - inventory: ProductInventory - /** Metafield data related to a product. */ - metafields: MetafieldConnection - /** - * Product creation date - * @deprecated Alpha version. Do not use in production. - */ - createdAt: DateTimeExtended -} - -/** Product */ -export type ProductPlainTextDescriptionArgs = { - characterLimit?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductPricesArgs = { - includeTax?: Maybe<Scalars['Boolean']> - currencyCode?: Maybe<CurrencyCode> -} - -/** Product */ -export type ProductPriceRangesArgs = { - includeTax?: Maybe<Scalars['Boolean']> -} - -/** Product */ -export type ProductOptionsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductProductOptionsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductCategoriesArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductVariantsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> - entityIds?: Maybe<Array<Scalars['Int']>> - optionValueIds?: Maybe<Array<OptionValueId>> -} - -/** Product */ -export type ProductCustomFieldsArgs = { - names?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductImagesArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductRelatedProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product */ -export type ProductMetafieldsArgs = { - namespace: Scalars['String'] - keys?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Product availability */ -export type ProductAvailability = { - /** The availability state of the product. */ - status: ProductAvailabilityStatus - /** A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. */ - description: Scalars['String'] -} - -/** Product availability status */ -export enum ProductAvailabilityStatus { - Available = 'Available', - Preorder = 'Preorder', - Unavailable = 'Unavailable', -} - -/** Available Product */ -export type ProductAvailable = ProductAvailability & { - __typename?: 'ProductAvailable' - /** The availability state of the product. */ - status: ProductAvailabilityStatus - /** A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. */ - description: Scalars['String'] -} - -/** A connection to a list of items. */ -export type ProductConnection = { - __typename?: 'ProductConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<ProductEdge>>> -} - -/** An edge in a connection. */ -export type ProductEdge = { - __typename?: 'ProductEdge' - /** The item at the end of the edge. */ - node: Product - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Product Inventory Information */ -export type ProductInventory = { - __typename?: 'ProductInventory' - /** Indicates whether this product is in stock. */ - isInStock: Scalars['Boolean'] - /** Indicates whether this product's inventory is being tracked on variant level. If true, you may wish to check the variants node to understand the true inventory of each individual variant, rather than relying on this product-level aggregate to understand how many items may be added to cart. */ - hasVariantInventory: Scalars['Boolean'] - /** Aggregated product inventory information. This data may not be available if not set or if the store's Inventory Settings have disabled displaying stock levels on the storefront. */ - aggregated?: Maybe<AggregatedInventory> -} - -/** Product Option */ -export type ProductOption = { - __typename?: 'ProductOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] - /** Option values. */ - values: OptionValueConnection -} - -/** Product Option */ -export type ProductOptionValuesArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A connection to a list of items. */ -export type ProductOptionConnection = { - __typename?: 'ProductOptionConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<ProductOptionEdge>>> -} - -/** An edge in a connection. */ -export type ProductOptionEdge = { - __typename?: 'ProductOptionEdge' - /** The item at the end of the edge. */ - node: CatalogProductOption - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Product Option Value */ -export type ProductOptionValue = { - __typename?: 'ProductOptionValue' - /** Unique ID for the option value. */ - entityId: Scalars['Int'] - /** Label for the option value. */ - label: Scalars['String'] -} - -/** A connection to a list of items. */ -export type ProductOptionValueConnection = { - __typename?: 'ProductOptionValueConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<ProductOptionValueEdge>>> -} - -/** An edge in a connection. */ -export type ProductOptionValueEdge = { - __typename?: 'ProductOptionValueEdge' - /** The item at the end of the edge. */ - node: CatalogProductOptionValue - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** A Product PickList Value - a product to be mapped to the base product if selected. */ -export type ProductPickListOptionValue = CatalogProductOptionValue & { - __typename?: 'ProductPickListOptionValue' - /** The ID of the product associated with this option value. */ - productId: Scalars['Int'] - /** Unique ID for the option value. */ - entityId: Scalars['Int'] - /** Label for the option value. */ - label: Scalars['String'] - /** Indicates whether this value is the chosen default selected value. */ - isDefault: Scalars['Boolean'] -} - -/** PreOrder Product */ -export type ProductPreOrder = ProductAvailability & { - __typename?: 'ProductPreOrder' - /** The message to be shown in the store when a product is put into the pre-order availability state, e.g. "Expected release date is %%DATE%%" */ - message?: Maybe<Scalars['String']> - /** Product release date */ - willBeReleasedAt?: Maybe<DateTimeExtended> - /** The availability state of the product. */ - status: ProductAvailabilityStatus - /** A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. */ - description: Scalars['String'] -} - -/** Unavailable Product */ -export type ProductUnavailable = ProductAvailability & { - __typename?: 'ProductUnavailable' - /** The message to be shown in the store when "Call for pricing" is enabled for this product, e.g. "Contact us at 555-5555" */ - message?: Maybe<Scalars['String']> - /** The availability state of the product. */ - status: ProductAvailabilityStatus - /** A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. */ - description: Scalars['String'] -} - -export type Query = { - __typename?: 'Query' - site: Site - /** The currently logged in customer. */ - customer?: Maybe<Customer> - /** Fetches an object given its ID */ - node?: Maybe<Node> - /** @deprecated Alpha version. Do not use in production. */ - inventory: Inventory -} - -export type QueryNodeArgs = { - id: Scalars['ID'] -} - -/** A connection to a list of items. */ -export type RelatedProductsConnection = { - __typename?: 'RelatedProductsConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<RelatedProductsEdge>>> -} - -/** An edge in a connection. */ -export type RelatedProductsEdge = { - __typename?: 'RelatedProductsEdge' - /** The item at the end of the edge. */ - node: Product - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Review Rating Summary */ -export type Reviews = { - __typename?: 'Reviews' - /** Total number of reviews on product. */ - numberOfReviews: Scalars['Int'] - /** Summation of rating scores from each review. */ - summationOfRatings: Scalars['Int'] -} - -/** route */ -export type Route = { - __typename?: 'Route' - /** node */ - node?: Maybe<Node> -} - -/** Store settings information from the control panel. */ -export type Settings = { - __typename?: 'Settings' - /** The name of the store. */ - storeName: Scalars['String'] - /** The hash of the store. */ - storeHash: Scalars['String'] - /** The current store status. */ - status: StorefrontStatusType - /** Logo information for the store. */ - logo: LogoField - /** Contact information for the store. */ - contact?: Maybe<ContactField> - /** Store urls. */ - url: UrlField - /** Store display format information. */ - display: DisplayField - /** Channel ID. */ - channelId: Scalars['Long'] -} - -/** A site */ -export type Site = { - __typename?: 'Site' - categoryTree: Array<CategoryTreeItem> - /** Details of the brand. */ - brands: BrandConnection - /** Details of the products. */ - products: ProductConnection - /** Details of the newest products. */ - newestProducts: ProductConnection - /** Details of the best selling products. */ - bestSellingProducts: ProductConnection - /** Details of the featured products. */ - featuredProducts: ProductConnection - /** A single product object with variant pricing overlay capabilities. */ - product?: Maybe<Product> - /** Route for a node */ - route: Route - /** Store settings. */ - settings?: Maybe<Settings> -} - -/** A site */ -export type SiteBrandsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> - productEntityIds?: Maybe<Array<Scalars['Int']>> -} - -/** A site */ -export type SiteProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> - ids?: Maybe<Array<Scalars['ID']>> - entityIds?: Maybe<Array<Scalars['Int']>> -} - -/** A site */ -export type SiteNewestProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A site */ -export type SiteBestSellingProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A site */ -export type SiteFeaturedProductsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A site */ -export type SiteProductArgs = { - id?: Maybe<Scalars['ID']> - entityId?: Maybe<Scalars['Int']> - variantEntityId?: Maybe<Scalars['Int']> - optionValueIds?: Maybe<Array<OptionValueId>> - sku?: Maybe<Scalars['String']> -} - -/** A site */ -export type SiteRouteArgs = { - path: Scalars['String'] -} - -/** Storefront Mode */ -export enum StorefrontStatusType { - Launched = 'LAUNCHED', - Maintenance = 'MAINTENANCE', - PreLaunch = 'PRE_LAUNCH', - Hibernation = 'HIBERNATION', -} - -/** A swatch option value - swatch values can be associated with a list of hexidecimal colors or an image. */ -export type SwatchOptionValue = CatalogProductOptionValue & { - __typename?: 'SwatchOptionValue' - /** List of up to 3 hex encoded colors to associate with a swatch value. */ - hexColors: Array<Scalars['String']> - /** Absolute path of a swatch texture image. */ - imageUrl?: Maybe<Scalars['String']> - /** Unique ID for the option value. */ - entityId: Scalars['Int'] - /** Label for the option value. */ - label: Scalars['String'] - /** Indicates whether this value is the chosen default selected value. */ - isDefault: Scalars['Boolean'] -} - -/** A swatch option value - swatch values can be associated with a list of hexidecimal colors or an image. */ -export type SwatchOptionValueImageUrlArgs = { - width: Scalars['Int'] - height?: Maybe<Scalars['Int']> -} - -/** A single line text input field. */ -export type TextFieldOption = CatalogProductOption & { - __typename?: 'TextFieldOption' - /** Unique ID for the option. */ - entityId: Scalars['Int'] - /** Display name for the option. */ - displayName: Scalars['String'] - /** One of the option values is required to be selected for the checkout. */ - isRequired: Scalars['Boolean'] -} - -/** Url field */ -export type UrlField = { - __typename?: 'UrlField' - /** Store url. */ - vanityUrl: Scalars['String'] - /** CDN url to fetch assets. */ - cdnUrl: Scalars['String'] -} - -/** Variant */ -export type Variant = Node & { - __typename?: 'Variant' - /** The ID of an object */ - id: Scalars['ID'] - /** Id of the variant. */ - entityId: Scalars['Int'] - /** Sku of the variant. */ - sku: Scalars['String'] - /** The variant's weight. If a weight was not explicitly specified on the variant, this will be the product's weight. */ - weight?: Maybe<Measurement> - /** The variant's height. If a height was not explicitly specified on the variant, this will be the product's height. */ - height?: Maybe<Measurement> - /** The variant's width. If a width was not explicitly specified on the variant, this will be the product's width. */ - width?: Maybe<Measurement> - /** The variant's depth. If a depth was not explicitly specified on the variant, this will be the product's depth. */ - depth?: Maybe<Measurement> - /** The options which define a variant. */ - options: OptionConnection - /** Product options that compose this variant. */ - productOptions: ProductOptionConnection - /** Default image for a variant. */ - defaultImage?: Maybe<Image> - /** Variant prices */ - prices?: Maybe<Prices> - /** Variant inventory */ - inventory?: Maybe<VariantInventory> - /** Metafield data related to a variant. */ - metafields: MetafieldConnection -} - -/** Variant */ -export type VariantOptionsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Variant */ -export type VariantProductOptionsArgs = { - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Variant */ -export type VariantPricesArgs = { - includeTax?: Maybe<Scalars['Boolean']> - currencyCode?: Maybe<CurrencyCode> -} - -/** Variant */ -export type VariantMetafieldsArgs = { - namespace: Scalars['String'] - keys?: Maybe<Array<Scalars['String']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** A connection to a list of items. */ -export type VariantConnection = { - __typename?: 'VariantConnection' - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** A list of edges. */ - edges?: Maybe<Array<Maybe<VariantEdge>>> -} - -/** An edge in a connection. */ -export type VariantEdge = { - __typename?: 'VariantEdge' - /** The item at the end of the edge. */ - node: Variant - /** A cursor for use in pagination. */ - cursor: Scalars['String'] -} - -/** Variant Inventory */ -export type VariantInventory = { - __typename?: 'VariantInventory' - /** Aggregated product variant inventory information. This data may not be available if not set or if the store's Inventory Settings have disabled displaying stock levels on the storefront. */ - aggregated?: Maybe<Aggregated> - /** Indicates whether this product is in stock. */ - isInStock: Scalars['Boolean'] - /** Inventory by locations. */ - byLocation?: Maybe<LocationConnection> -} - -/** Variant Inventory */ -export type VariantInventoryByLocationArgs = { - locationEntityIds?: Maybe<Array<Scalars['Int']>> - before?: Maybe<Scalars['String']> - after?: Maybe<Scalars['String']> - first?: Maybe<Scalars['Int']> - last?: Maybe<Scalars['Int']> -} - -/** Please select a currency */ -export enum CurrencyCode { - Adp = 'ADP', - Aed = 'AED', - Afa = 'AFA', - Afn = 'AFN', - Alk = 'ALK', - All = 'ALL', - Amd = 'AMD', - Ang = 'ANG', - Aoa = 'AOA', - Aok = 'AOK', - Aon = 'AON', - Aor = 'AOR', - Ara = 'ARA', - Arl = 'ARL', - Arm = 'ARM', - Arp = 'ARP', - Ars = 'ARS', - Ats = 'ATS', - Aud = 'AUD', - Awg = 'AWG', - Azm = 'AZM', - Azn = 'AZN', - Bad = 'BAD', - Bam = 'BAM', - Ban = 'BAN', - Bbd = 'BBD', - Bdt = 'BDT', - Bec = 'BEC', - Bef = 'BEF', - Bel = 'BEL', - Bgl = 'BGL', - Bgm = 'BGM', - Bgn = 'BGN', - Bgo = 'BGO', - Bhd = 'BHD', - Bif = 'BIF', - Bmd = 'BMD', - Bnd = 'BND', - Bob = 'BOB', - Bol = 'BOL', - Bop = 'BOP', - Bov = 'BOV', - Brb = 'BRB', - Brc = 'BRC', - Bre = 'BRE', - Brl = 'BRL', - Brn = 'BRN', - Brr = 'BRR', - Brz = 'BRZ', - Bsd = 'BSD', - Btn = 'BTN', - Buk = 'BUK', - Bwp = 'BWP', - Byb = 'BYB', - Byr = 'BYR', - Bzd = 'BZD', - Cad = 'CAD', - Cdf = 'CDF', - Che = 'CHE', - Chf = 'CHF', - Chw = 'CHW', - Cle = 'CLE', - Clf = 'CLF', - Clp = 'CLP', - Cnx = 'CNX', - Cny = 'CNY', - Cop = 'COP', - Cou = 'COU', - Crc = 'CRC', - Csd = 'CSD', - Csk = 'CSK', - Cve = 'CVE', - Cyp = 'CYP', - Czk = 'CZK', - Ddm = 'DDM', - Dem = 'DEM', - Djf = 'DJF', - Dkk = 'DKK', - Dop = 'DOP', - Dzd = 'DZD', - Ecs = 'ECS', - Ecv = 'ECV', - Eek = 'EEK', - Egp = 'EGP', - Ern = 'ERN', - Esa = 'ESA', - Esb = 'ESB', - Esp = 'ESP', - Etb = 'ETB', - Eur = 'EUR', - Fim = 'FIM', - Fjd = 'FJD', - Fkp = 'FKP', - Frf = 'FRF', - Gbp = 'GBP', - Gek = 'GEK', - Gel = 'GEL', - Ghc = 'GHC', - Ghs = 'GHS', - Gip = 'GIP', - Gmd = 'GMD', - Gnf = 'GNF', - Gns = 'GNS', - Gqe = 'GQE', - Grd = 'GRD', - Gtq = 'GTQ', - Gwe = 'GWE', - Gwp = 'GWP', - Gyd = 'GYD', - Hkd = 'HKD', - Hnl = 'HNL', - Hrd = 'HRD', - Hrk = 'HRK', - Htg = 'HTG', - Huf = 'HUF', - Idr = 'IDR', - Iep = 'IEP', - Ilp = 'ILP', - Ilr = 'ILR', - Ils = 'ILS', - Inr = 'INR', - Iqd = 'IQD', - Isj = 'ISJ', - Isk = 'ISK', - Itl = 'ITL', - Jmd = 'JMD', - Jod = 'JOD', - Jpy = 'JPY', - Kes = 'KES', - Kgs = 'KGS', - Khr = 'KHR', - Kmf = 'KMF', - Krh = 'KRH', - Kro = 'KRO', - Krw = 'KRW', - Kwd = 'KWD', - Kyd = 'KYD', - Kzt = 'KZT', - Lak = 'LAK', - Lbp = 'LBP', - Lkr = 'LKR', - Lrd = 'LRD', - Lsl = 'LSL', - Ltl = 'LTL', - Ltt = 'LTT', - Luc = 'LUC', - Luf = 'LUF', - Lul = 'LUL', - Lvl = 'LVL', - Lvr = 'LVR', - Lyd = 'LYD', - Mad = 'MAD', - Maf = 'MAF', - Mcf = 'MCF', - Mdc = 'MDC', - Mdl = 'MDL', - Mga = 'MGA', - Mgf = 'MGF', - Mkd = 'MKD', - Mkn = 'MKN', - Mlf = 'MLF', - Mmk = 'MMK', - Mnt = 'MNT', - Mop = 'MOP', - Mro = 'MRO', - Mtl = 'MTL', - Mtp = 'MTP', - Mur = 'MUR', - Mvp = 'MVP', - Mvr = 'MVR', - Mwk = 'MWK', - Mxn = 'MXN', - Mxp = 'MXP', - Mxv = 'MXV', - Myr = 'MYR', - Mze = 'MZE', - Mzm = 'MZM', - Mzn = 'MZN', - Nad = 'NAD', - Ngn = 'NGN', - Nic = 'NIC', - Nio = 'NIO', - Nlg = 'NLG', - Nok = 'NOK', - Npr = 'NPR', - Nzd = 'NZD', - Omr = 'OMR', - Pab = 'PAB', - Pei = 'PEI', - Pen = 'PEN', - Pes = 'PES', - Pgk = 'PGK', - Php = 'PHP', - Pkr = 'PKR', - Pln = 'PLN', - Plz = 'PLZ', - Pte = 'PTE', - Pyg = 'PYG', - Qar = 'QAR', - Rhd = 'RHD', - Rol = 'ROL', - Ron = 'RON', - Rsd = 'RSD', - Rub = 'RUB', - Rur = 'RUR', - Rwf = 'RWF', - Sar = 'SAR', - Sbd = 'SBD', - Scr = 'SCR', - Sdd = 'SDD', - Sdg = 'SDG', - Sdp = 'SDP', - Sek = 'SEK', - Sgd = 'SGD', - Shp = 'SHP', - Sit = 'SIT', - Skk = 'SKK', - Sll = 'SLL', - Sos = 'SOS', - Srd = 'SRD', - Srg = 'SRG', - Ssp = 'SSP', - Std = 'STD', - Sur = 'SUR', - Svc = 'SVC', - Syp = 'SYP', - Szl = 'SZL', - Thb = 'THB', - Tjr = 'TJR', - Tjs = 'TJS', - Tmm = 'TMM', - Tmt = 'TMT', - Tnd = 'TND', - Top = 'TOP', - Tpe = 'TPE', - Trl = 'TRL', - Try = 'TRY', - Ttd = 'TTD', - Twd = 'TWD', - Tzs = 'TZS', - Uah = 'UAH', - Uak = 'UAK', - Ugs = 'UGS', - Ugx = 'UGX', - Usd = 'USD', - Usn = 'USN', - Uss = 'USS', - Uyi = 'UYI', - Uyp = 'UYP', - Uyu = 'UYU', - Uzs = 'UZS', - Veb = 'VEB', - Vef = 'VEF', - Vnd = 'VND', - Vnn = 'VNN', - Vuv = 'VUV', - Wst = 'WST', - Xaf = 'XAF', - Xcd = 'XCD', - Xeu = 'XEU', - Xfo = 'XFO', - Xfu = 'XFU', - Xof = 'XOF', - Xpf = 'XPF', - Xre = 'XRE', - Ydd = 'YDD', - Yer = 'YER', - Yud = 'YUD', - Yum = 'YUM', - Yun = 'YUN', - Yur = 'YUR', - Zal = 'ZAL', - Zar = 'ZAR', - Zmk = 'ZMK', - Zmw = 'ZMW', - Zrn = 'ZRN', - Zrz = 'ZRZ', - Zwd = 'ZWD', - Zwl = 'ZWL', - Zwr = 'ZWR', -} - -export type GetLoggedInCustomerQueryVariables = Exact<{ [key: string]: never }> - -export type GetLoggedInCustomerQuery = { __typename?: 'Query' } & { - customer?: Maybe< - { __typename?: 'Customer' } & Pick< - Customer, - | 'entityId' - | 'firstName' - | 'lastName' - | 'email' - | 'company' - | 'customerGroupId' - | 'notes' - | 'phone' - | 'addressCount' - | 'attributeCount' - > & { - storeCredit: Array< - { __typename?: 'Money' } & Pick<Money, 'value' | 'currencyCode'> - > - } - > -} - -export type CategoryTreeItemFragment = { - __typename?: 'CategoryTreeItem' -} & Pick< - CategoryTreeItem, - 'entityId' | 'name' | 'path' | 'description' | 'productCount' -> - -export type SwatchOptionFragment = { __typename?: 'SwatchOptionValue' } & Pick< - SwatchOptionValue, - 'isDefault' | 'hexColors' -> - -export type MultipleChoiceOptionFragment = { - __typename?: 'MultipleChoiceOption' -} & Pick<MultipleChoiceOption, 'entityId'> & { - values: { __typename?: 'ProductOptionValueConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'ProductOptionValueEdge' } & { - node: - | ({ __typename?: 'MultipleChoiceOptionValue' } & Pick< - MultipleChoiceOptionValue, - 'label' - >) - | ({ __typename?: 'ProductPickListOptionValue' } & Pick< - ProductPickListOptionValue, - 'label' - >) - | ({ __typename?: 'SwatchOptionValue' } & Pick< - SwatchOptionValue, - 'label' - > & - SwatchOptionFragment) - } - > - > - > - } - } - -export type ProductInfoFragment = { __typename?: 'Product' } & Pick< - Product, - 'entityId' | 'name' | 'path' | 'description' -> & { - brand?: Maybe<{ __typename?: 'Brand' } & Pick<Brand, 'entityId'>> - prices?: Maybe< - { __typename?: 'Prices' } & { - price: { __typename?: 'Money' } & Pick<Money, 'value' | 'currencyCode'> - salePrice?: Maybe< - { __typename?: 'Money' } & Pick<Money, 'value' | 'currencyCode'> - > - retailPrice?: Maybe< - { __typename?: 'Money' } & Pick<Money, 'value' | 'currencyCode'> - > - } - > - images: { __typename?: 'ImageConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'ImageEdge' } & { - node: { __typename?: 'Image' } & Pick< - Image, - 'urlOriginal' | 'altText' | 'isDefault' - > - } - > - > - > - } - variants: { __typename?: 'VariantConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'VariantEdge' } & { - node: { __typename?: 'Variant' } & Pick<Variant, 'entityId'> & { - defaultImage?: Maybe< - { __typename?: 'Image' } & Pick< - Image, - 'urlOriginal' | 'altText' | 'isDefault' - > - > - } - } - > - > - > - } - productOptions: { __typename?: 'ProductOptionConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'ProductOptionEdge' } & { - node: - | ({ __typename?: 'CheckboxOption' } & Pick< - CheckboxOption, - 'entityId' | 'displayName' - >) - | ({ __typename?: 'DateFieldOption' } & Pick< - DateFieldOption, - 'entityId' | 'displayName' - >) - | ({ __typename?: 'FileUploadFieldOption' } & Pick< - FileUploadFieldOption, - 'entityId' | 'displayName' - >) - | ({ __typename?: 'MultiLineTextFieldOption' } & Pick< - MultiLineTextFieldOption, - 'entityId' | 'displayName' - >) - | ({ __typename?: 'MultipleChoiceOption' } & Pick< - MultipleChoiceOption, - 'entityId' | 'displayName' - > & - MultipleChoiceOptionFragment) - | ({ __typename?: 'NumberFieldOption' } & Pick< - NumberFieldOption, - 'entityId' | 'displayName' - >) - | ({ __typename?: 'TextFieldOption' } & Pick< - TextFieldOption, - 'entityId' | 'displayName' - >) - } - > - > - > - } - localeMeta: { __typename?: 'MetafieldConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'MetafieldEdge' } & { - node: { __typename?: 'Metafields' } & Pick< - Metafields, - 'key' | 'value' - > - } - > - > - > - } - } - -export type ProductConnnectionFragment = { - __typename?: 'ProductConnection' -} & { - pageInfo: { __typename?: 'PageInfo' } & Pick< - PageInfo, - 'startCursor' | 'endCursor' - > - edges?: Maybe< - Array< - Maybe< - { __typename?: 'ProductEdge' } & Pick<ProductEdge, 'cursor'> & { - node: { __typename?: 'Product' } & ProductInfoFragment - } - > - > - > -} - -export type GetAllProductPathsQueryVariables = Exact<{ - first?: Maybe<Scalars['Int']> -}> - -export type GetAllProductPathsQuery = { __typename?: 'Query' } & { - site: { __typename?: 'Site' } & { - products: { __typename?: 'ProductConnection' } & { - edges?: Maybe< - Array< - Maybe< - { __typename?: 'ProductEdge' } & { - node: { __typename?: 'Product' } & Pick<Product, 'path'> - } - > - > - > - } - } -} - -export type GetAllProductsQueryVariables = Exact<{ - hasLocale?: Maybe<Scalars['Boolean']> - locale?: Maybe<Scalars['String']> - entityIds?: Maybe<Array<Scalars['Int']>> - first?: Maybe<Scalars['Int']> - products?: Maybe<Scalars['Boolean']> - featuredProducts?: Maybe<Scalars['Boolean']> - bestSellingProducts?: Maybe<Scalars['Boolean']> - newestProducts?: Maybe<Scalars['Boolean']> -}> - -export type GetAllProductsQuery = { __typename?: 'Query' } & { - site: { __typename?: 'Site' } & { - products: { __typename?: 'ProductConnection' } & ProductConnnectionFragment - featuredProducts: { - __typename?: 'ProductConnection' - } & ProductConnnectionFragment - bestSellingProducts: { - __typename?: 'ProductConnection' - } & ProductConnnectionFragment - newestProducts: { - __typename?: 'ProductConnection' - } & ProductConnnectionFragment - } -} - -export type GetCustomerIdQueryVariables = Exact<{ [key: string]: never }> - -export type GetCustomerIdQuery = { __typename?: 'Query' } & { - customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'entityId'>> -} - -export type GetProductQueryVariables = Exact<{ - hasLocale?: Maybe<Scalars['Boolean']> - locale?: Maybe<Scalars['String']> - path: Scalars['String'] -}> - -export type GetProductQuery = { __typename?: 'Query' } & { - site: { __typename?: 'Site' } & { - route: { __typename?: 'Route' } & { - node?: Maybe< - | { __typename: 'Brand' } - | { __typename: 'Category' } - | ({ __typename: 'Product' } & ProductInfoFragment) - | { __typename: 'Variant' } - > - } - } -} - -export type GetSiteInfoQueryVariables = Exact<{ [key: string]: never }> - -export type GetSiteInfoQuery = { __typename?: 'Query' } & { - site: { __typename?: 'Site' } & { - categoryTree: Array< - { __typename?: 'CategoryTreeItem' } & { - children: Array< - { __typename?: 'CategoryTreeItem' } & { - children: Array< - { __typename?: 'CategoryTreeItem' } & CategoryTreeItemFragment - > - } & CategoryTreeItemFragment - > - } & CategoryTreeItemFragment - > - brands: { __typename?: 'BrandConnection' } & { - pageInfo: { __typename?: 'PageInfo' } & Pick< - PageInfo, - 'startCursor' | 'endCursor' - > - edges?: Maybe< - Array< - Maybe< - { __typename?: 'BrandEdge' } & Pick<BrandEdge, 'cursor'> & { - node: { __typename?: 'Brand' } & Pick< - Brand, - | 'entityId' - | 'name' - | 'pageTitle' - | 'metaDesc' - | 'metaKeywords' - | 'searchKeywords' - | 'path' - > & { - defaultImage?: Maybe< - { __typename?: 'Image' } & Pick< - Image, - 'urlOriginal' | 'altText' - > - > - } - } - > - > - > - } - } -} - -export type LoginMutationVariables = Exact<{ - email: Scalars['String'] - password: Scalars['String'] -}> - -export type LoginMutation = { __typename?: 'Mutation' } & { - login: { __typename?: 'LoginResult' } & Pick<LoginResult, 'result'> -} diff --git a/lib/bigcommerce/schema.graphql b/lib/bigcommerce/schema.graphql deleted file mode 100644 index 79de347fe..000000000 --- a/lib/bigcommerce/schema.graphql +++ /dev/null @@ -1,2422 +0,0 @@ -""" -Login result -""" -type LoginResult { - """ - The result of a login - """ - result: String! -} - -""" -Logout result -""" -type LogoutResult { - """ - The result of a logout - """ - result: String! -} - -type Mutation { - login(email: String!, password: String!): LoginResult! - logout: LogoutResult! -} - -""" -Aggregated -""" -type Aggregated { - """ - Number of available products in stock. This can be 'null' if inventory is not set orif the store's Inventory Settings disable displaying stock levels on the storefront. - """ - availableToSell: Long! - - """ - Indicates a threshold low-stock level. This can be 'null' if the inventory warning level is not set or if the store's Inventory Settings disable displaying stock levels on the storefront. - """ - warningLevel: Int! -} - -""" -Aggregated Product Inventory -""" -type AggregatedInventory { - """ - Number of available products in stock. This can be 'null' if inventory is not set orif the store's Inventory Settings disable displaying stock levels on the storefront. - """ - availableToSell: Int! - - """ - Indicates a threshold low-stock level. This can be 'null' if the inventory warning level is not set or if the store's Inventory Settings disable displaying stock levels on the storefront. - """ - warningLevel: Int! -} - -""" -Brand -""" -type Brand implements Node { - """ - The ID of an object - """ - id: ID! - - """ - Id of the brand. - """ - entityId: Int! - - """ - Name of the brand. - """ - name: String! - - """ - Default image for brand. - """ - defaultImage: Image - - """ - Page title for the brand. - """ - pageTitle: String! - - """ - Meta description for the brand. - """ - metaDesc: String! - - """ - Meta keywords for the brand. - """ - metaKeywords: [String!]! - - """ - Search keywords for the brand. - """ - searchKeywords: [String!]! - - """ - Path for the brand page. - """ - path: String! - products( - before: String - after: String - first: Int - last: Int - ): ProductConnection! - - """ - Metafield data related to a brand. - """ - metafields( - namespace: String! - keys: [String!] = [] - before: String - after: String - first: Int - last: Int - ): MetafieldConnection! -} - -""" -A connection to a list of items. -""" -type BrandConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [BrandEdge] -} - -""" -An edge in a connection. -""" -type BrandEdge { - """ - The item at the end of the edge. - """ - node: Brand! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Breadcrumb -""" -type Breadcrumb { - """ - Category id. - """ - entityId: Int! - - """ - Name of the category. - """ - name: String! -} - -""" -A connection to a list of items. -""" -type BreadcrumbConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [BreadcrumbEdge] -} - -""" -An edge in a connection. -""" -type BreadcrumbEdge { - """ - The item at the end of the edge. - """ - node: Breadcrumb! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Bulk pricing tier that sets a fixed price for the product or variant. -""" -type BulkPricingFixedPriceDiscount implements BulkPricingTier { - """ - This price will override the current product price. - """ - price: BigDecimal! - - """ - Minimum item quantity that applies to this bulk pricing tier. - """ - minimumQuantity: Int! - - """ - Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. - """ - maximumQuantity: Int -} - -""" -Bulk pricing tier that reduces the price of the product or variant by a percentage. -""" -type BulkPricingPercentageDiscount implements BulkPricingTier { - """ - The percentage that will be removed from the product price. - """ - percentOff: BigDecimal! - - """ - Minimum item quantity that applies to this bulk pricing tier. - """ - minimumQuantity: Int! - - """ - Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. - """ - maximumQuantity: Int -} - -""" -Bulk pricing tier that will subtract an amount from the price of the product or variant. -""" -type BulkPricingRelativePriceDiscount implements BulkPricingTier { - """ - The price of the product/variant will be reduced by this priceAdjustment. - """ - priceAdjustment: BigDecimal! - - """ - Minimum item quantity that applies to this bulk pricing tier. - """ - minimumQuantity: Int! - - """ - Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. - """ - maximumQuantity: Int -} - -""" -A set of bulk pricing tiers that define price discounts which apply when purchasing specified quantities of a product or variant. -""" -interface BulkPricingTier { - """ - Minimum item quantity that applies to this bulk pricing tier. - """ - minimumQuantity: Int! - - """ - Maximum item quantity that applies to this bulk pricing tier - if not defined then the tier does not have an upper bound. - """ - maximumQuantity: Int -} - -""" -Product Option -""" -interface CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -Product Option Value -""" -interface CatalogProductOptionValue { - """ - Unique ID for the option value. - """ - entityId: Int! - - """ - Label for the option value. - """ - label: String! - - """ - Indicates whether this value is the chosen default selected value. - """ - isDefault: Boolean! -} - -""" -Category -""" -type Category implements Node { - """ - The ID of an object - """ - id: ID! - - """ - Unique ID for the category. - """ - entityId: Int! - - """ - Category name. - """ - name: String! - - """ - Category path. - """ - path: String! - - """ - Default image for the category. - """ - defaultImage: Image - - """ - Category description. - """ - description: String! - - """ - Category breadcrumbs. - """ - breadcrumbs( - depth: Int! - before: String - after: String - first: Int - last: Int - ): BreadcrumbConnection! - products( - before: String - after: String - first: Int - last: Int - ): ProductConnection! - - """ - Metafield data related to a category. - """ - metafields( - namespace: String! - keys: [String!] = [] - before: String - after: String - first: Int - last: Int - ): MetafieldConnection! -} - -""" -A connection to a list of items. -""" -type CategoryConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [CategoryEdge] -} - -""" -An edge in a connection. -""" -type CategoryEdge { - """ - The item at the end of the edge. - """ - node: Category! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -An item in a tree of categories. -""" -type CategoryTreeItem { - """ - The id category. - """ - entityId: Int! - - """ - The name of category. - """ - name: String! - - """ - Path assigned to this category - """ - path: String! - - """ - The description of this category. - """ - description: String! - - """ - The number of products in this category. - """ - productCount: Int! - - """ - Subcategories of this category - """ - children: [CategoryTreeItem!]! -} - -""" -A simple yes/no question represented by a checkbox. -""" -type CheckboxOption implements CatalogProductOption { - """ - Indicates the default checked status. - """ - checkedByDefault: Boolean! - - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -Contact field -""" -type ContactField { - """ - Store address line. - """ - address: String! - - """ - Store country. - """ - country: String! - - """ - Store address type. - """ - addressType: String! - - """ - Store email. - """ - email: String! - - """ - Store phone number. - """ - phone: String! -} - -""" -Custom field -""" -type CustomField { - """ - Custom field id. - """ - entityId: Int! - - """ - Name of the custom field. - """ - name: String! - - """ - Value of the custom field. - """ - value: String! -} - -""" -A connection to a list of items. -""" -type CustomFieldConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [CustomFieldEdge] -} - -""" -An edge in a connection. -""" -type CustomFieldEdge { - """ - The item at the end of the edge. - """ - node: CustomField! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -A customer that shops on a store -""" -type Customer { - """ - The ID of the customer. - """ - entityId: Int! - - """ - The company name of the customer. - """ - company: String! - - """ - The customer group id of the customer. - """ - customerGroupId: Int! - - """ - The email address of the customer. - """ - email: String! - - """ - The first name of the customer. - """ - firstName: String! - - """ - The last name of the customer. - """ - lastName: String! - - """ - The notes of the customer. - """ - notes: String! - - """ - The phone number of the customer. - """ - phone: String! - - """ - The tax exempt category of the customer. - """ - taxExemptCategory: String! - - """ - Customer addresses count. - """ - addressCount: Int! - - """ - Customer attributes count. - """ - attributeCount: Int! - - """ - Customer store credit. - """ - storeCredit: [Money!]! - - """ - Customer attributes. - """ - attributes: CustomerAttributes! -} - -""" -A custom, store-specific attribute for a customer -""" -type CustomerAttribute { - """ - The ID of the custom customer attribute - """ - entityId: Int! - - """ - The value of the custom customer attribute - """ - value: String - - """ - The name of the custom customer attribute - """ - name: String! -} - -""" -Custom, store-specific customer attributes -""" -type CustomerAttributes { - attribute( - """ - The ID of the customer attribute - """ - entityId: Int! - ): CustomerAttribute! -} - -""" -A calendar for allowing selection of a date. -""" -type DateFieldOption implements CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -scalar DateTime - -""" -Date Time Extended -""" -type DateTimeExtended { - """ - ISO-8601 formatted date in UTC - """ - utc: DateTime! -} - -""" -Display field -""" -type DisplayField { - """ - Short date format. - """ - shortDateFormat: String! - - """ - Extended date format. - """ - extendedDateFormat: String! -} - -""" -A form allowing selection and uploading of a file from the user's local computer. -""" -type FileUploadFieldOption implements CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -Image -""" -type Image { - """ - Absolute path to image using store CDN. - """ - url(width: Int!, height: Int): String! - - """ - Absolute path to original image using store CDN. - """ - urlOriginal: String! - - """ - Text description of an image that can be used for SEO and/or accessibility purposes. - """ - altText: String! - - """ - Indicates whether this is the primary image. - """ - isDefault: Boolean! -} - -""" -A connection to a list of items. -""" -type ImageConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [ImageEdge] -} - -""" -An edge in a connection. -""" -type ImageEdge { - """ - The item at the end of the edge. - """ - node: Image! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -An inventory -""" -type Inventory { - """ - Locations - """ - locations( - entityIds: [Int!] - codes: [String!] - typeIds: [String!] - before: String - after: String - first: Int - last: Int - ): LocationConnection! -} - -""" -Inventory By Locations -""" -type InventoryByLocations { - """ - Location id. - """ - locationEntityId: Long! - - """ - Number of available products in stock. - """ - availableToSell: Long! - - """ - Indicates a threshold low-stock level. - """ - warningLevel: Int! - - """ - Indicates whether this product is in stock. - """ - isInStock: Boolean! -} - -""" -A connection to a list of items. -""" -type LocationConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [LocationEdge] -} - -""" -An edge in a connection. -""" -type LocationEdge { - """ - The item at the end of the edge. - """ - node: InventoryByLocations! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Logo field -""" -type LogoField { - """ - Logo title. - """ - title: String! - - """ - Store logo image. - """ - image: Image! -} - -""" -Measurement -""" -type Measurement { - """ - Unformatted weight measurement value. - """ - value: Float! - - """ - Unit of measurement. - """ - unit: String! -} - -""" -A connection to a list of items. -""" -type MetafieldConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [MetafieldEdge] -} - -""" -An edge in a connection. -""" -type MetafieldEdge { - """ - The item at the end of the edge. - """ - node: Metafields! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Key/Value pairs of data attached tied to a resource entity (product, brand, category, etc.) -""" -type Metafields { - """ - The ID of an object - """ - id: ID! - - """ - The ID of the metafield when referencing via our backend API. - """ - entityId: Int! - - """ - A label for identifying a metafield data value. - """ - key: String! - - """ - A metafield value. - """ - value: String! -} - -""" -A money object - includes currency code and a money amount -""" -type Money { - """ - Currency code of the current money. - """ - currencyCode: String! - - """ - The amount of money. - """ - value: BigDecimal! -} - -""" -A min and max pair of money objects -""" -type MoneyRange { - """ - Minimum money object. - """ - min: Money! - - """ - Maximum money object. - """ - max: Money! -} - -""" -A multi-line text input field, aka a text box. -""" -type MultiLineTextFieldOption implements CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -An option type that has a fixed list of values. -""" -type MultipleChoiceOption implements CatalogProductOption { - """ - The chosen display style for this multiple choice option. - """ - displayStyle: String! - - """ - List of option values. - """ - values( - before: String - after: String - first: Int - last: Int - ): ProductOptionValueConnection! - - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -A simple multiple choice value comprised of an id and a label. -""" -type MultipleChoiceOptionValue implements CatalogProductOptionValue { - """ - Unique ID for the option value. - """ - entityId: Int! - - """ - Label for the option value. - """ - label: String! - - """ - Indicates whether this value is the chosen default selected value. - """ - isDefault: Boolean! -} - -""" -An object with an ID -""" -interface Node { - """ - The id of the object. - """ - id: ID! -} - -""" -A single line text input field that only accepts numbers. -""" -type NumberFieldOption implements CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -A connection to a list of items. -""" -type OptionConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [OptionEdge] -} - -""" -An edge in a connection. -""" -type OptionEdge { - """ - The item at the end of the edge. - """ - node: ProductOption! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -A connection to a list of items. -""" -type OptionValueConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [OptionValueEdge] -} - -""" -An edge in a connection. -""" -type OptionValueEdge { - """ - The item at the end of the edge. - """ - node: ProductOptionValue! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -input OptionValueId { - optionEntityId: Int! - valueEntityId: Int! -} - -""" -Information about pagination in a connection. -""" -type PageInfo { - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - - """ - When paginating backwards, the cursor to continue. - """ - startCursor: String - - """ - When paginating forwards, the cursor to continue. - """ - endCursor: String -} - -""" -The min and max range of prices that apply to this product. -""" -type PriceRanges { - """ - Product price min/max range. - """ - priceRange: MoneyRange! - - """ - Product retail price min/max range. - """ - retailPriceRange: MoneyRange -} - -""" -The various prices that can be set on a product. -""" -type Prices { - """ - Calculated price of the product. - """ - price: Money! - - """ - Sale price of the product. - """ - salePrice: Money - - """ - Original price of the product. - """ - basePrice: Money - - """ - Retail price of the product. - """ - retailPrice: Money - - """ - Minimum advertised price of the product. - """ - mapPrice: Money - - """ - Product price min/max range. - """ - priceRange: MoneyRange! - - """ - Product retail price min/max range. - """ - retailPriceRange: MoneyRange - - """ - The difference between the retail price (MSRP) and the current price, which can be presented to the shopper as their savings. - """ - saved: Money - - """ - List of bulk pricing tiers applicable to a product or variant. - """ - bulkPricing: [BulkPricingTier!]! -} - -""" -Product -""" -type Product implements Node { - """ - The ID of an object - """ - id: ID! - - """ - Id of the product. - """ - entityId: Int! - - """ - Default product variant when no options are selected. - """ - sku: String! - - """ - Relative URL path to product page. - """ - path: String! - - """ - Name of the product. - """ - name: String! - - """ - Description of the product. - """ - description: String! - - """ - Description of the product in plain text. - """ - plainTextDescription(characterLimit: Int = 120): String! - - """ - Warranty information of the product. - """ - warranty: String! - - """ - Minimum purchasable quantity for this product in a single order. - """ - minPurchaseQuantity: Int - - """ - Maximum purchasable quantity for this product in a single order. - """ - maxPurchaseQuantity: Int - - """ - Absolute URL path for adding a product to cart. - """ - addToCartUrl: String! - - """ - Absolute URL path for adding a product to customer's wishlist. - """ - addToWishlistUrl: String! - - """ - Prices object determined by supplied product ID, variant ID, and selected option IDs. - """ - prices(includeTax: Boolean = false, currencyCode: currencyCode): Prices - - """ - The minimum and maximum price of this product based on variant pricing and/or modifier price rules. - """ - priceRanges(includeTax: Boolean = false): PriceRanges - @deprecated(reason: "Use priceRanges inside prices node instead.") - - """ - Weight of the product. - """ - weight: Measurement - - """ - Height of the product. - """ - height: Measurement - - """ - Width of the product. - """ - width: Measurement - - """ - Depth of the product. - """ - depth: Measurement - - """ - Product options. - """ - options( - before: String - after: String - first: Int - last: Int - ): OptionConnection! - - """ - Product options. - """ - productOptions( - before: String - after: String - first: Int - last: Int - ): ProductOptionConnection! - - """ - Summary of the product reviews, includes the total number of reviews submitted and summation of the ratings on the reviews (ratings range from 0-5 per review). - """ - reviewSummary: Reviews! - - """ - Type of product, ex: physical, digital - """ - type: String! - - """ - The availability state of the product. - """ - availability: String! - @deprecated(reason: "Use status inside availabilityV2 instead.") - - """ - A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - """ - availabilityDescription: String! - @deprecated(reason: "Use description inside availabilityV2 instead.") - - """ - The availability state of the product. - """ - availabilityV2: ProductAvailability! - - """ - List of categories associated with the product. - """ - categories( - before: String - after: String - first: Int - last: Int - ): CategoryConnection! - - """ - Brand associated with the product. - """ - brand: Brand - - """ - Variants associated with the product. - """ - variants( - before: String - after: String - first: Int - last: Int - entityIds: [Int!] = [] - optionValueIds: [OptionValueId!] = [] - ): VariantConnection! - - """ - Custom fields of the product. - """ - customFields( - names: [String!] = [] - before: String - after: String - first: Int - last: Int - ): CustomFieldConnection! - - """ - A list of the images for a product. - """ - images(before: String, after: String, first: Int, last: Int): ImageConnection! - - """ - Default image for a product. - """ - defaultImage: Image - - """ - Related products for this product. - """ - relatedProducts( - before: String - after: String - first: Int - last: Int - ): RelatedProductsConnection! - - """ - Inventory information of the product. - """ - inventory: ProductInventory! - - """ - Metafield data related to a product. - """ - metafields( - namespace: String! - keys: [String!] = [] - before: String - after: String - first: Int - last: Int - ): MetafieldConnection! - - """ - Product creation date - """ - createdAt: DateTimeExtended! - @deprecated(reason: "Alpha version. Do not use in production.") -} - -""" -Product availability -""" -interface ProductAvailability { - """ - The availability state of the product. - """ - status: ProductAvailabilityStatus! - - """ - A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - """ - description: String! -} - -""" -Product availability status -""" -enum ProductAvailabilityStatus { - Available - Preorder - Unavailable -} - -""" -Available Product -""" -type ProductAvailable implements ProductAvailability { - """ - The availability state of the product. - """ - status: ProductAvailabilityStatus! - - """ - A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - """ - description: String! -} - -""" -A connection to a list of items. -""" -type ProductConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [ProductEdge] -} - -""" -An edge in a connection. -""" -type ProductEdge { - """ - The item at the end of the edge. - """ - node: Product! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Product Inventory Information -""" -type ProductInventory { - """ - Indicates whether this product is in stock. - """ - isInStock: Boolean! - - """ - Indicates whether this product's inventory is being tracked on variant level. If true, you may wish to check the variants node to understand the true inventory of each individual variant, rather than relying on this product-level aggregate to understand how many items may be added to cart. - """ - hasVariantInventory: Boolean! - - """ - Aggregated product inventory information. This data may not be available if not set or if the store's Inventory Settings have disabled displaying stock levels on the storefront. - """ - aggregated: AggregatedInventory -} - -""" -Product Option -""" -type ProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! - - """ - Option values. - """ - values( - before: String - after: String - first: Int - last: Int - ): OptionValueConnection! -} - -""" -A connection to a list of items. -""" -type ProductOptionConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [ProductOptionEdge] -} - -""" -An edge in a connection. -""" -type ProductOptionEdge { - """ - The item at the end of the edge. - """ - node: CatalogProductOption! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Product Option Value -""" -type ProductOptionValue { - """ - Unique ID for the option value. - """ - entityId: Int! - - """ - Label for the option value. - """ - label: String! -} - -""" -A connection to a list of items. -""" -type ProductOptionValueConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [ProductOptionValueEdge] -} - -""" -An edge in a connection. -""" -type ProductOptionValueEdge { - """ - The item at the end of the edge. - """ - node: CatalogProductOptionValue! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -A Product PickList Value - a product to be mapped to the base product if selected. -""" -type ProductPickListOptionValue implements CatalogProductOptionValue { - """ - The ID of the product associated with this option value. - """ - productId: Int! - - """ - Unique ID for the option value. - """ - entityId: Int! - - """ - Label for the option value. - """ - label: String! - - """ - Indicates whether this value is the chosen default selected value. - """ - isDefault: Boolean! -} - -""" -PreOrder Product -""" -type ProductPreOrder implements ProductAvailability { - """ - The message to be shown in the store when a product is put into the pre-order availability state, e.g. "Expected release date is %%DATE%%" - """ - message: String - - """ - Product release date - """ - willBeReleasedAt: DateTimeExtended - - """ - The availability state of the product. - """ - status: ProductAvailabilityStatus! - - """ - A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - """ - description: String! -} - -""" -Unavailable Product -""" -type ProductUnavailable implements ProductAvailability { - """ - The message to be shown in the store when "Call for pricing" is enabled for this product, e.g. "Contact us at 555-5555" - """ - message: String - - """ - The availability state of the product. - """ - status: ProductAvailabilityStatus! - - """ - A few words telling the customer how long it will normally take to ship this product, such as 'Usually ships in 24 hours'. - """ - description: String! -} - -type Query { - site: Site! - - """ - The currently logged in customer. - """ - customer: Customer - - """ - Fetches an object given its ID - """ - node( - """ - The ID of an object - """ - id: ID! - ): Node - inventory: Inventory! - @deprecated(reason: "Alpha version. Do not use in production.") -} - -""" -A connection to a list of items. -""" -type RelatedProductsConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [RelatedProductsEdge] -} - -""" -An edge in a connection. -""" -type RelatedProductsEdge { - """ - The item at the end of the edge. - """ - node: Product! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Review Rating Summary -""" -type Reviews { - """ - Total number of reviews on product. - """ - numberOfReviews: Int! - - """ - Summation of rating scores from each review. - """ - summationOfRatings: Int! -} - -""" -route -""" -type Route { - """ - node - """ - node: Node -} - -""" -Store settings information from the control panel. -""" -type Settings { - """ - The name of the store. - """ - storeName: String! - - """ - The hash of the store. - """ - storeHash: String! - - """ - The current store status. - """ - status: StorefrontStatusType! - - """ - Logo information for the store. - """ - logo: LogoField! - - """ - Contact information for the store. - """ - contact: ContactField - - """ - Store urls. - """ - url: UrlField! - - """ - Store display format information. - """ - display: DisplayField! - - """ - Channel ID. - """ - channelId: Long! -} - -""" -A site -""" -type Site { - categoryTree: [CategoryTreeItem!]! - - """ - Details of the brand. - """ - brands( - before: String - after: String - first: Int - last: Int - productEntityIds: [Int!] = [] - ): BrandConnection! - - """ - Details of the products. - """ - products( - before: String - after: String - first: Int - last: Int - ids: [ID!] = [] - entityIds: [Int!] = [] - ): ProductConnection! - - """ - Details of the newest products. - """ - newestProducts( - before: String - after: String - first: Int - last: Int - ): ProductConnection! - - """ - Details of the best selling products. - """ - bestSellingProducts( - before: String - after: String - first: Int - last: Int - ): ProductConnection! - - """ - Details of the featured products. - """ - featuredProducts( - before: String - after: String - first: Int - last: Int - ): ProductConnection! - - """ - A single product object with variant pricing overlay capabilities. - """ - product( - id: ID - entityId: Int - variantEntityId: Int - optionValueIds: [OptionValueId!] = [] - sku: String - ): Product - - """ - Route for a node - """ - route(path: String!): Route! - - """ - Store settings. - """ - settings: Settings -} - -""" -Storefront Mode -""" -enum StorefrontStatusType { - LAUNCHED - MAINTENANCE - PRE_LAUNCH - HIBERNATION -} - -""" -A swatch option value - swatch values can be associated with a list of hexidecimal colors or an image. -""" -type SwatchOptionValue implements CatalogProductOptionValue { - """ - List of up to 3 hex encoded colors to associate with a swatch value. - """ - hexColors: [String!]! - - """ - Absolute path of a swatch texture image. - """ - imageUrl(width: Int!, height: Int): String - - """ - Unique ID for the option value. - """ - entityId: Int! - - """ - Label for the option value. - """ - label: String! - - """ - Indicates whether this value is the chosen default selected value. - """ - isDefault: Boolean! -} - -""" -A single line text input field. -""" -type TextFieldOption implements CatalogProductOption { - """ - Unique ID for the option. - """ - entityId: Int! - - """ - Display name for the option. - """ - displayName: String! - - """ - One of the option values is required to be selected for the checkout. - """ - isRequired: Boolean! -} - -""" -Url field -""" -type UrlField { - """ - Store url. - """ - vanityUrl: String! - - """ - CDN url to fetch assets. - """ - cdnUrl: String! -} - -""" -Variant -""" -type Variant implements Node { - """ - The ID of an object - """ - id: ID! - - """ - Id of the variant. - """ - entityId: Int! - - """ - Sku of the variant. - """ - sku: String! - - """ - The variant's weight. If a weight was not explicitly specified on the variant, this will be the product's weight. - """ - weight: Measurement - - """ - The variant's height. If a height was not explicitly specified on the variant, this will be the product's height. - """ - height: Measurement - - """ - The variant's width. If a width was not explicitly specified on the variant, this will be the product's width. - """ - width: Measurement - - """ - The variant's depth. If a depth was not explicitly specified on the variant, this will be the product's depth. - """ - depth: Measurement - - """ - The options which define a variant. - """ - options( - before: String - after: String - first: Int - last: Int - ): OptionConnection! - - """ - Product options that compose this variant. - """ - productOptions( - before: String - after: String - first: Int - last: Int - ): ProductOptionConnection! - - """ - Default image for a variant. - """ - defaultImage: Image - - """ - Variant prices - """ - prices(includeTax: Boolean = false, currencyCode: currencyCode): Prices - - """ - Variant inventory - """ - inventory: VariantInventory - - """ - Metafield data related to a variant. - """ - metafields( - namespace: String! - keys: [String!] = [] - before: String - after: String - first: Int - last: Int - ): MetafieldConnection! -} - -""" -A connection to a list of items. -""" -type VariantConnection { - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - - """ - A list of edges. - """ - edges: [VariantEdge] -} - -""" -An edge in a connection. -""" -type VariantEdge { - """ - The item at the end of the edge. - """ - node: Variant! - - """ - A cursor for use in pagination. - """ - cursor: String! -} - -""" -Variant Inventory -""" -type VariantInventory { - """ - Aggregated product variant inventory information. This data may not be available if not set or if the store's Inventory Settings have disabled displaying stock levels on the storefront. - """ - aggregated: Aggregated - - """ - Indicates whether this product is in stock. - """ - isInStock: Boolean! - - """ - Inventory by locations. - """ - byLocation( - locationEntityIds: [Int!] = [] - before: String - after: String - first: Int - last: Int - ): LocationConnection -} - -""" -Please select a currency -""" -enum currencyCode { - ADP - AED - AFA - AFN - ALK - ALL - AMD - ANG - AOA - AOK - AON - AOR - ARA - ARL - ARM - ARP - ARS - ATS - AUD - AWG - AZM - AZN - BAD - BAM - BAN - BBD - BDT - BEC - BEF - BEL - BGL - BGM - BGN - BGO - BHD - BIF - BMD - BND - BOB - BOL - BOP - BOV - BRB - BRC - BRE - BRL - BRN - BRR - BRZ - BSD - BTN - BUK - BWP - BYB - BYR - BZD - CAD - CDF - CHE - CHF - CHW - CLE - CLF - CLP - CNX - CNY - COP - COU - CRC - CSD - CSK - CVE - CYP - CZK - DDM - DEM - DJF - DKK - DOP - DZD - ECS - ECV - EEK - EGP - ERN - ESA - ESB - ESP - ETB - EUR - FIM - FJD - FKP - FRF - GBP - GEK - GEL - GHC - GHS - GIP - GMD - GNF - GNS - GQE - GRD - GTQ - GWE - GWP - GYD - HKD - HNL - HRD - HRK - HTG - HUF - IDR - IEP - ILP - ILR - ILS - INR - IQD - ISJ - ISK - ITL - JMD - JOD - JPY - KES - KGS - KHR - KMF - KRH - KRO - KRW - KWD - KYD - KZT - LAK - LBP - LKR - LRD - LSL - LTL - LTT - LUC - LUF - LUL - LVL - LVR - LYD - MAD - MAF - MCF - MDC - MDL - MGA - MGF - MKD - MKN - MLF - MMK - MNT - MOP - MRO - MTL - MTP - MUR - MVP - MVR - MWK - MXN - MXP - MXV - MYR - MZE - MZM - MZN - NAD - NGN - NIC - NIO - NLG - NOK - NPR - NZD - OMR - PAB - PEI - PEN - PES - PGK - PHP - PKR - PLN - PLZ - PTE - PYG - QAR - RHD - ROL - RON - RSD - RUB - RUR - RWF - SAR - SBD - SCR - SDD - SDG - SDP - SEK - SGD - SHP - SIT - SKK - SLL - SOS - SRD - SRG - SSP - STD - SUR - SVC - SYP - SZL - THB - TJR - TJS - TMM - TMT - TND - TOP - TPE - TRL - TRY - TTD - TWD - TZS - UAH - UAK - UGS - UGX - USD - USN - USS - UYI - UYP - UYU - UZS - VEB - VEF - VND - VNN - VUV - WST - XAF - XCD - XEU - XFO - XFU - XOF - XPF - XRE - YDD - YER - YUD - YUM - YUN - YUR - ZAL - ZAR - ZMK - ZMW - ZRN - ZRZ - ZWD - ZWL - ZWR -} - -""" -The `BigDecimal` scalar type represents signed fractional values with arbitrary precision. -""" -scalar BigDecimal - -""" -The `Long` scalar type represents non-fractional signed whole numeric values. Long can represent values between -(2^63) and 2^63 - 1. -""" -scalar Long diff --git a/lib/bigcommerce/scripts/generate-definitions.js b/lib/bigcommerce/scripts/generate-definitions.js deleted file mode 100644 index a2b830d3b..000000000 --- a/lib/bigcommerce/scripts/generate-definitions.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Generates definitions for REST API endpoints that are being - * used by ../api using https://github.com/drwpow/swagger-to-ts - */ -const { readFileSync, promises } = require('fs') -const path = require('path') -const fetch = require('node-fetch') -const swaggerToTS = require('@manifoldco/swagger-to-ts').default - -async function getSchema(filename) { - const url = `https://next-api.stoplight.io/projects/8433/files/${filename}` - const res = await fetch(url) - - if (!res.ok) { - throw new Error(`Request failed with ${res.status}: ${res.statusText}`) - } - - return res.json() -} - -const schemas = Object.entries({ - '../api/definitions/catalog.ts': - 'BigCommerce_Catalog_API.oas2.yml?ref=version%2F20.930', - '../api/definitions/store-content.ts': - 'BigCommerce_Store_Content_API.oas2.yml?ref=version%2F20.930', - '../api/definitions/wishlist.ts': - 'BigCommerce_Wishlist_API.oas2.yml?ref=version%2F20.930', - // swagger-to-ts is not working for the schema of the cart API - // '../api/definitions/cart.ts': - // 'BigCommerce_Server_to_Server_Cart_API.oas2.yml', -}) - -async function writeDefinitions() { - const ops = schemas.map(async ([dest, filename]) => { - const destination = path.join(__dirname, dest) - const schema = await getSchema(filename) - const definition = swaggerToTS(schema.content, { - prettierConfig: 'package.json', - }) - - await promises.writeFile(destination, definition) - - console.log(`✔️ Added definitions for: ${dest}`) - }) - - await Promise.all(ops) -} - -writeDefinitions() diff --git a/lib/bigcommerce/use-customer.tsx b/lib/bigcommerce/use-customer.tsx deleted file mode 100644 index 8f99d5cde..000000000 --- a/lib/bigcommerce/use-customer.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import type { HookFetcher } from '../commerce/utils/types' -import type { SwrOptions } from '../commerce/utils/use-data' -import useCommerceCustomer from '../commerce/use-customer' -import type { Customer, CustomerData } from './api/customers' - -const defaultOpts = { - url: '/api/bigcommerce/customers', - method: 'GET', -} - -export type { Customer } - -export const fetcher: HookFetcher<Customer | null> = async ( - options, - _, - fetch -) => { - const data = await fetch<CustomerData | null>({ ...defaultOpts, ...options }) - return data?.customer ?? null -} - -export function extendHook( - customFetcher: typeof fetcher, - swrOptions?: SwrOptions<Customer | null> -) { - const useCustomer = () => { - return useCommerceCustomer(defaultOpts, [], customFetcher, { - revalidateOnFocus: false, - ...swrOptions, - }) - } - - useCustomer.extend = extendHook - - return useCustomer -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/use-login.tsx b/lib/bigcommerce/use-login.tsx deleted file mode 100644 index b74a0f976..000000000 --- a/lib/bigcommerce/use-login.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { useCallback } from 'react' -import type { HookFetcher } from '../commerce/utils/types' -import { CommerceError } from '../commerce/utils/errors' -import useCommerceLogin from '../commerce/use-login' -import type { LoginBody } from './api/customers/login' -import useCustomer from './use-customer' - -const defaultOpts = { - url: '/api/bigcommerce/customers/login', - method: 'POST', -} - -export type LoginInput = LoginBody - -export const fetcher: HookFetcher<null, LoginBody> = ( - options, - { email, password }, - fetch -) => { - if (!(email && password)) { - throw new CommerceError({ - message: - 'A first name, last name, email and password are required to login', - }) - } - - return fetch({ - ...defaultOpts, - ...options, - body: { email, password }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useLogin = () => { - const { revalidate } = useCustomer() - const fn = useCommerceLogin<null, LoginInput>(defaultOpts, customFetcher) - - return useCallback( - async function login(input: LoginInput) { - const data = await fn(input) - await revalidate() - return data - }, - [fn] - ) - } - - useLogin.extend = extendHook - - return useLogin -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/use-logout.tsx b/lib/bigcommerce/use-logout.tsx deleted file mode 100644 index fda8e4c69..000000000 --- a/lib/bigcommerce/use-logout.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useCallback } from 'react' -import type { HookFetcher } from '../commerce/utils/types' -import useCommerceLogout from '../commerce/use-logout' -import useCustomer from './use-customer' - -const defaultOpts = { - url: '/api/bigcommerce/customers/logout', - method: 'GET', -} - -export const fetcher: HookFetcher<null> = (options, _, fetch) => { - return fetch({ - ...defaultOpts, - ...options, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useLogout = () => { - const { mutate } = useCustomer() - const fn = useCommerceLogout<null>(defaultOpts, customFetcher) - - return useCallback( - async function login() { - const data = await fn(null) - await mutate(null, false) - return data - }, - [fn] - ) - } - - useLogout.extend = extendHook - - return useLogout -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/use-price.tsx b/lib/bigcommerce/use-price.tsx deleted file mode 100644 index 0ee1a3533..000000000 --- a/lib/bigcommerce/use-price.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from '../commerce/use-price' -export { default } from '../commerce/use-price' diff --git a/lib/bigcommerce/use-signup.tsx b/lib/bigcommerce/use-signup.tsx deleted file mode 100644 index 9ff52a57a..000000000 --- a/lib/bigcommerce/use-signup.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { useCallback } from 'react' -import type { HookFetcher } from '../commerce/utils/types' -import { CommerceError } from '../commerce/utils/errors' -import useCommerceSignup from '../commerce/use-signup' -import type { SignupBody } from './api/customers/signup' -import useCustomer from './use-customer' - -const defaultOpts = { - url: '/api/bigcommerce/customers/signup', - method: 'POST', -} - -export type SignupInput = SignupBody - -export const fetcher: HookFetcher<null, SignupBody> = ( - options, - { firstName, lastName, email, password }, - fetch -) => { - if (!(firstName && lastName && email && password)) { - throw new CommerceError({ - message: - 'A first name, last name, email and password are required to signup', - }) - } - - return fetch({ - ...defaultOpts, - ...options, - body: { firstName, lastName, email, password }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useSignup = () => { - const { revalidate } = useCustomer() - const fn = useCommerceSignup<null, SignupInput>(defaultOpts, customFetcher) - - return useCallback( - async function signup(input: SignupInput) { - const data = await fn(input) - await revalidate() - return data - }, - [fn] - ) - } - - useSignup.extend = extendHook - - return useSignup -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/wishlist/use-add-item.tsx b/lib/bigcommerce/wishlist/use-add-item.tsx deleted file mode 100644 index c5f608579..000000000 --- a/lib/bigcommerce/wishlist/use-add-item.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useCallback } from 'react' -import { HookFetcher } from '../../commerce/utils/types' -import { CommerceError } from '../../commerce/utils/errors' -import useWishlistAddItem from '../../commerce/wishlist/use-add-item' -import type { ItemBody, AddItemBody } from '../api/wishlist' -import useCustomer from '../use-customer' -import useWishlist, { Wishlist } from './use-wishlist' - -const defaultOpts = { - url: '/api/bigcommerce/wishlist', - method: 'POST', -} - -export type AddItemInput = ItemBody - -export const fetcher: HookFetcher<Wishlist, AddItemBody> = ( - options, - { item }, - fetch -) => { - // TODO: add validations before doing the fetch - return fetch({ - ...defaultOpts, - ...options, - body: { item }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useAddItem = () => { - const { data: customer } = useCustomer() - const { mutate } = useWishlist() - const fn = useWishlistAddItem(defaultOpts, customFetcher) - - return useCallback( - async function addItem(input: AddItemInput) { - if (!customer) { - // A signed customer is required in order to have a wishlist - throw new CommerceError({ - message: 'Signed customer not found', - }) - } - - const data = await fn({ item: input }) - await mutate(data, false) - return data - }, - [fn, mutate, customer] - ) - } - - useAddItem.extend = extendHook - - return useAddItem -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/wishlist/use-remove-item.tsx b/lib/bigcommerce/wishlist/use-remove-item.tsx deleted file mode 100644 index f8a4ddba9..000000000 --- a/lib/bigcommerce/wishlist/use-remove-item.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { useCallback } from 'react' -import { HookFetcher } from '../../commerce/utils/types' -import { CommerceError } from '../../commerce/utils/errors' -import useWishlistRemoveItem from '../../commerce/wishlist/use-remove-item' -import type { RemoveItemBody } from '../api/wishlist' -import useCustomer from '../use-customer' -import useWishlist, { Wishlist } from './use-wishlist' - -const defaultOpts = { - url: '/api/bigcommerce/wishlist', - method: 'DELETE', -} - -export type RemoveItemInput = { - id: string | number -} - -export const fetcher: HookFetcher<Wishlist | null, RemoveItemBody> = ( - options, - { itemId }, - fetch -) => { - return fetch({ - ...defaultOpts, - ...options, - body: { itemId }, - }) -} - -export function extendHook(customFetcher: typeof fetcher) { - const useRemoveItem = () => { - const { data: customer } = useCustomer() - const { mutate } = useWishlist() - const fn = useWishlistRemoveItem<Wishlist | null, RemoveItemBody>( - defaultOpts, - customFetcher - ) - - return useCallback( - async function removeItem(input: RemoveItemInput) { - if (!customer) { - // A signed customer is required in order to have a wishlist - throw new CommerceError({ - message: 'Signed customer not found', - }) - } - - const data = await fn({ itemId: String(input.id) }) - await mutate(data, false) - return data - }, - [fn, mutate, customer] - ) - } - - useRemoveItem.extend = extendHook - - return useRemoveItem -} - -export default extendHook(fetcher) diff --git a/lib/bigcommerce/wishlist/use-wishlist-actions.tsx b/lib/bigcommerce/wishlist/use-wishlist-actions.tsx deleted file mode 100644 index 711d00516..000000000 --- a/lib/bigcommerce/wishlist/use-wishlist-actions.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import useAddItem from './use-add-item' -import useRemoveItem from './use-remove-item' - -// This hook is probably not going to be used, but it's here -// to show how a commerce should be structuring it -export default function useWishlistActions() { - const addItem = useAddItem() - const removeItem = useRemoveItem() - - return { addItem, removeItem } -} diff --git a/lib/bigcommerce/wishlist/use-wishlist.tsx b/lib/bigcommerce/wishlist/use-wishlist.tsx deleted file mode 100644 index ac2f9d496..000000000 --- a/lib/bigcommerce/wishlist/use-wishlist.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { HookFetcher } from '../../commerce/utils/types' -import { SwrOptions } from '../../commerce/utils/use-data' -import useCommerceWishlist from '../../commerce/wishlist/use-wishlist' -import type { Wishlist } from '../api/wishlist' -import useCustomer from '../use-customer' - -const defaultOpts = { - url: '/api/bigcommerce/wishlist', - method: 'GET', -} - -export type { Wishlist } - -export const fetcher: HookFetcher<Wishlist | null, { customerId?: number }> = ( - options, - { customerId }, - fetch -) => { - return customerId ? fetch({ ...defaultOpts, ...options }) : null -} - -export function extendHook( - customFetcher: typeof fetcher, - swrOptions?: SwrOptions<Wishlist | null, { customerId?: number }> -) { - const useWishlists = () => { - const { data: customer } = useCustomer() - const response = useCommerceWishlist( - defaultOpts, - [['customerId', customer?.entityId]], - customFetcher, - { - revalidateOnFocus: false, - ...swrOptions, - } - ) - - // Uses a getter to only calculate the prop when required - // response.data is also a getter and it's better to not trigger it early - Object.defineProperty(response, 'isEmpty', { - get() { - return (response.data?.items?.length || 0) > 0 - }, - set: (x) => x, - }) - - return response - } - - useWishlists.extend = extendHook - - return useWishlists -} - -export default extendHook(fetcher) diff --git a/lib/commerce/api/index.ts b/lib/commerce/api/index.ts deleted file mode 100644 index b1ef09a62..000000000 --- a/lib/commerce/api/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { RequestInit, Response } from '@vercel/fetch' - -export interface CommerceAPIConfig { - locale?: string - commerceUrl: string - apiToken: string - cartCookie: string - cartCookieMaxAge: number - customerCookie: string - fetch<Data = any, Variables = any>( - query: string, - queryData?: CommerceAPIFetchOptions<Variables>, - fetchOptions?: RequestInit - ): Promise<GraphQLFetcherResult<Data>> -} - -export type GraphQLFetcher< - Data extends GraphQLFetcherResult = GraphQLFetcherResult, - Variables = any -> = ( - query: string, - queryData?: CommerceAPIFetchOptions<Variables>, - fetchOptions?: RequestInit -) => Promise<Data> - -export interface GraphQLFetcherResult<Data = any> { - data: Data - res: Response -} - -export interface CommerceAPIFetchOptions<Variables> { - variables?: Variables - preview?: boolean -} - -// TODO: define interfaces for all the available operations and API endpoints diff --git a/lib/commerce/cart/use-add-item.tsx b/lib/commerce/cart/use-add-item.tsx deleted file mode 100644 index f6c069f2b..000000000 --- a/lib/commerce/cart/use-add-item.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from '../utils/use-action' - -const useAddItem = useAction - -export default useAddItem diff --git a/lib/commerce/cart/use-cart-actions.tsx b/lib/commerce/cart/use-cart-actions.tsx deleted file mode 100644 index 3ba4b2e1a..000000000 --- a/lib/commerce/cart/use-cart-actions.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import type { HookFetcher, HookFetcherOptions } from '../utils/types' -import useAddItem from './use-add-item' -import useRemoveItem from './use-remove-item' -import useUpdateItem from './use-update-item' - -// This hook is probably not going to be used, but it's here -// to show how a commerce should be structuring it -export default function useCartActions<T, Input>( - options: HookFetcherOptions, - fetcher: HookFetcher<T, Input> -) { - const addItem = useAddItem<T, Input>(options, fetcher) - const updateItem = useUpdateItem<T, Input>(options, fetcher) - const removeItem = useRemoveItem<T, Input>(options, fetcher) - - return { addItem, updateItem, removeItem } -} diff --git a/lib/commerce/cart/use-cart.tsx b/lib/commerce/cart/use-cart.tsx deleted file mode 100644 index 8aefc3e68..000000000 --- a/lib/commerce/cart/use-cart.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import type { responseInterface } from 'swr' -import Cookies from 'js-cookie' -import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types' -import useData, { SwrOptions } from '../utils/use-data' -import { useCommerce } from '..' - -export type CartResponse<Result> = responseInterface<Result, Error> & { - isEmpty: boolean -} - -export type CartInput = { - cartId: string | undefined -} - -export default function useCart<Result>( - options: HookFetcherOptions, - input: HookInput, - fetcherFn: HookFetcher<Result, CartInput>, - swrOptions?: SwrOptions<Result, CartInput> -) { - const { cartCookie } = useCommerce() - - const fetcher: typeof fetcherFn = (options, input, fetch) => { - input.cartId = Cookies.get(cartCookie) - return fetcherFn(options, input, fetch) - } - - const response = useData(options, input, fetcher, swrOptions) - - return Object.assign(response, { isEmpty: true }) as CartResponse<Result> -} diff --git a/lib/commerce/cart/use-remove-item.tsx b/lib/commerce/cart/use-remove-item.tsx deleted file mode 100644 index dfa60c363..000000000 --- a/lib/commerce/cart/use-remove-item.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from '../utils/use-action' - -const useRemoveItem = useAction - -export default useRemoveItem diff --git a/lib/commerce/cart/use-update-item.tsx b/lib/commerce/cart/use-update-item.tsx deleted file mode 100644 index 1c6261054..000000000 --- a/lib/commerce/cart/use-update-item.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from '../utils/use-action' - -const useUpdateItem = useAction - -export default useUpdateItem diff --git a/lib/commerce/index.tsx b/lib/commerce/index.tsx deleted file mode 100644 index 8fc156922..000000000 --- a/lib/commerce/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { - ReactNode, - MutableRefObject, - createContext, - useContext, - useMemo, - useRef, -} from 'react' -import { Fetcher } from './utils/types' - -const Commerce = createContext<CommerceContextValue | {}>({}) - -export type CommerceProps = { - children?: ReactNode - config: CommerceConfig -} - -export type CommerceConfig = { fetcher: Fetcher<any> } & Omit< - CommerceContextValue, - 'fetcherRef' -> - -export type CommerceContextValue = { - fetcherRef: MutableRefObject<Fetcher<any>> - locale: string - cartCookie: string -} - -export function CommerceProvider({ children, config }: CommerceProps) { - if (!config) { - throw new Error('CommerceProvider requires a valid config object') - } - - const fetcherRef = useRef(config.fetcher) - // Because the config is an object, if the parent re-renders this provider - // will re-render every consumer unless we memoize the config - const cfg = useMemo( - () => ({ - fetcherRef, - locale: config.locale, - cartCookie: config.cartCookie, - }), - [config.locale, config.cartCookie] - ) - - return <Commerce.Provider value={cfg}>{children}</Commerce.Provider> -} - -export function useCommerce<T extends CommerceContextValue>() { - return useContext(Commerce) as T -} diff --git a/lib/commerce/products/use-search.tsx b/lib/commerce/products/use-search.tsx deleted file mode 100644 index 637c8a899..000000000 --- a/lib/commerce/products/use-search.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useData from '../utils/use-data' - -const useSearch = useData - -export default useSearch diff --git a/lib/commerce/use-customer.tsx b/lib/commerce/use-customer.tsx deleted file mode 100644 index 8e2ff3ec2..000000000 --- a/lib/commerce/use-customer.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useData from './utils/use-data' - -const useCustomer = useData - -export default useCustomer diff --git a/lib/commerce/use-login.tsx b/lib/commerce/use-login.tsx deleted file mode 100644 index 2a251fea3..000000000 --- a/lib/commerce/use-login.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from './utils/use-action' - -const useLogin = useAction - -export default useLogin diff --git a/lib/commerce/use-logout.tsx b/lib/commerce/use-logout.tsx deleted file mode 100644 index ef3fc4135..000000000 --- a/lib/commerce/use-logout.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from './utils/use-action' - -const useLogout = useAction - -export default useLogout diff --git a/lib/commerce/use-price.tsx b/lib/commerce/use-price.tsx deleted file mode 100644 index 9a3fc4b6e..000000000 --- a/lib/commerce/use-price.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { useMemo } from 'react' -import { useCommerce } from '.' - -export function formatPrice({ - amount, - currencyCode, - locale, -}: { - amount: number - currencyCode: string - locale: string -}) { - const formatCurrency = new Intl.NumberFormat(locale, { - style: 'currency', - currency: currencyCode, - }) - - return formatCurrency.format(amount) -} - -export function formatVariantPrice({ - amount, - baseAmount, - currencyCode, - locale, -}: { - baseAmount: number - amount: number - currencyCode: string - locale: string -}) { - const hasDiscount = baseAmount > amount - const formatDiscount = new Intl.NumberFormat(locale, { style: 'percent' }) - const discount = hasDiscount - ? formatDiscount.format((baseAmount - amount) / baseAmount) - : null - - const price = formatPrice({ amount, currencyCode, locale }) - const basePrice = hasDiscount - ? formatPrice({ amount: baseAmount, currencyCode, locale }) - : null - - return { price, basePrice, discount } -} - -export default function usePrice( - data?: { - amount: number - baseAmount?: number - currencyCode: string - } | null -) { - const { amount, baseAmount, currencyCode } = data ?? {} - const { locale } = useCommerce() - const value = useMemo(() => { - if (typeof amount !== 'number' || !currencyCode) return '' - - return baseAmount - ? formatVariantPrice({ amount, baseAmount, currencyCode, locale }) - : formatPrice({ amount, currencyCode, locale }) - }, [amount, baseAmount, currencyCode]) - - return typeof value === 'string' ? { price: value } : value -} diff --git a/lib/commerce/use-signup.tsx b/lib/commerce/use-signup.tsx deleted file mode 100644 index 08ddb22c0..000000000 --- a/lib/commerce/use-signup.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from './utils/use-action' - -const useSignup = useAction - -export default useSignup diff --git a/lib/commerce/utils/errors.ts b/lib/commerce/utils/errors.ts deleted file mode 100644 index 76f899ab7..000000000 --- a/lib/commerce/utils/errors.ts +++ /dev/null @@ -1,40 +0,0 @@ -export type ErrorData = { - message: string - code?: string -} - -export type ErrorProps = { - code?: string -} & ( - | { message: string; errors?: never } - | { message?: never; errors: ErrorData[] } -) - -export class CommerceError extends Error { - code?: string - errors: ErrorData[] - - constructor({ message, code, errors }: ErrorProps) { - const error: ErrorData = message - ? { message, ...(code ? { code } : {}) } - : errors![0] - - super(error.message) - this.errors = message ? [error] : errors! - - if (error.code) this.code = error.code - } -} - -export class FetcherError extends CommerceError { - status: number - - constructor( - options: { - status: number - } & ErrorProps - ) { - super(options) - this.status = options.status - } -} diff --git a/lib/commerce/utils/types.ts b/lib/commerce/utils/types.ts deleted file mode 100644 index 5fd18d46d..000000000 --- a/lib/commerce/utils/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Core fetcher added by CommerceProvider -export type Fetcher<T> = (options: FetcherOptions) => T | Promise<T> - -export type FetcherOptions = { - url?: string - query?: string - method?: string - variables?: any - body?: any -} - -export type HookFetcher<Result, Input = null> = ( - options: HookFetcherOptions | null, - input: Input, - fetch: <T = Result>(options: FetcherOptions) => Promise<T> -) => Result | Promise<Result> - -export type HookFetcherOptions = { - query?: string - url?: string - method?: string -} - -export type HookInput = [string, string | number | undefined][] diff --git a/lib/commerce/utils/use-action.tsx b/lib/commerce/utils/use-action.tsx deleted file mode 100644 index 24593383f..000000000 --- a/lib/commerce/utils/use-action.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { useCallback } from 'react' -import type { HookFetcher, HookFetcherOptions } from './types' -import { useCommerce } from '..' - -export default function useAction<T, Input = null>( - options: HookFetcherOptions, - fetcher: HookFetcher<T, Input> -) { - const { fetcherRef } = useCommerce() - - return useCallback( - (input: Input) => fetcher(options, input, fetcherRef.current), - [fetcher] - ) -} diff --git a/lib/commerce/utils/use-data.tsx b/lib/commerce/utils/use-data.tsx deleted file mode 100644 index dd5917ccb..000000000 --- a/lib/commerce/utils/use-data.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import useSWR, { ConfigInterface, responseInterface } from 'swr' -import type { HookInput, HookFetcher, HookFetcherOptions } from './types' -import { CommerceError } from './errors' -import { useCommerce } from '..' - -export type SwrOptions<Result, Input = null> = ConfigInterface< - Result, - CommerceError, - HookFetcher<Result, Input> -> - -export type UseData = <Result = any, Input = null>( - options: HookFetcherOptions | (() => HookFetcherOptions | null), - input: HookInput, - fetcherFn: HookFetcher<Result, Input>, - swrOptions?: SwrOptions<Result, Input> -) => responseInterface<Result, CommerceError> - -const useData: UseData = (options, input, fetcherFn, swrOptions) => { - const { fetcherRef } = useCommerce() - const fetcher = async ( - url?: string, - query?: string, - method?: string, - ...args: any[] - ) => { - try { - return await fetcherFn( - { url, query, method }, - // Transform the input array into an object - args.reduce((obj, val, i) => { - obj[input[i][0]!] = val - return obj - }, {}), - fetcherRef.current - ) - } catch (error) { - // SWR will not log errors, but any error that's not an instance - // of CommerceError is not welcomed by this hook - if (!(error instanceof CommerceError)) { - console.error(error) - } - throw error - } - } - const response = useSWR( - () => { - const opts = typeof options === 'function' ? options() : options - return opts - ? [opts.url, opts.query, opts.method, ...input.map((e) => e[1])] - : null - }, - fetcher, - swrOptions - ) - - return response -} - -export default useData diff --git a/lib/commerce/wishlist/use-add-item.tsx b/lib/commerce/wishlist/use-add-item.tsx deleted file mode 100644 index f6c069f2b..000000000 --- a/lib/commerce/wishlist/use-add-item.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from '../utils/use-action' - -const useAddItem = useAction - -export default useAddItem diff --git a/lib/commerce/wishlist/use-remove-item.tsx b/lib/commerce/wishlist/use-remove-item.tsx deleted file mode 100644 index dfa60c363..000000000 --- a/lib/commerce/wishlist/use-remove-item.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import useAction from '../utils/use-action' - -const useRemoveItem = useAction - -export default useRemoveItem diff --git a/lib/commerce/wishlist/use-wishlist.tsx b/lib/commerce/wishlist/use-wishlist.tsx deleted file mode 100644 index 7b2981412..000000000 --- a/lib/commerce/wishlist/use-wishlist.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import type { responseInterface } from 'swr' -import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types' -import useData, { SwrOptions } from '../utils/use-data' - -export type WishlistResponse<Result> = responseInterface<Result, Error> & { - isEmpty: boolean -} - -export default function useWishlist<Result, Input = null>( - options: HookFetcherOptions, - input: HookInput, - fetcherFn: HookFetcher<Result, Input>, - swrOptions?: SwrOptions<Result, Input> -) { - const response = useData(options, input, fetcherFn, swrOptions) - return Object.assign(response, { isEmpty: true }) as WishlistResponse<Result> -} From 86ee3cce21960da5715a24f1a07bcbb28dbf696e Mon Sep 17 00:00:00 2001 From: luc <luc.leray@gmail.com> Date: Tue, 27 Oct 2020 03:02:27 +0100 Subject: [PATCH 09/23] import from @bigcommerce/storefront-data-hooks --- components/auth/ForgotPassword.tsx | 2 +- components/auth/LoginView.tsx | 2 +- components/auth/SignUpView.tsx | 2 +- components/cart/CartItem/CartItem.tsx | 6 +++--- components/cart/CartSidebarView/CartSidebarView.tsx | 4 ++-- components/core/Footer/Footer.tsx | 2 +- components/core/Layout/Layout.tsx | 4 ++-- components/core/UserNav/DropdownMenu.tsx | 2 +- components/core/UserNav/UserNav.tsx | 4 ++-- components/product/ProductCard/ProductCard.tsx | 4 ++-- components/product/ProductView/ProductView.tsx | 4 ++-- components/product/helpers.ts | 2 +- components/wishlist/WishlistButton/WishlistButton.tsx | 10 +++++----- pages/[...pages].tsx | 4 ++-- pages/api/bigcommerce/cart.ts | 2 +- pages/api/bigcommerce/catalog/products.ts | 2 +- pages/api/bigcommerce/checkout.ts | 2 +- pages/api/bigcommerce/customers/index.ts | 2 +- pages/api/bigcommerce/customers/login.ts | 2 +- pages/api/bigcommerce/customers/logout.ts | 2 +- pages/api/bigcommerce/customers/signup.ts | 2 +- pages/api/bigcommerce/wishlist.ts | 2 +- pages/blog.tsx | 2 +- pages/cart.tsx | 6 +++--- pages/index.tsx | 8 ++++---- pages/product/[slug].tsx | 8 ++++---- pages/profile.tsx | 2 +- pages/search.tsx | 6 +++--- pages/wishlist.tsx | 6 +++--- 29 files changed, 53 insertions(+), 53 deletions(-) diff --git a/components/auth/ForgotPassword.tsx b/components/auth/ForgotPassword.tsx index f6e342742..5450069f0 100644 --- a/components/auth/ForgotPassword.tsx +++ b/components/auth/ForgotPassword.tsx @@ -3,7 +3,7 @@ import { validate } from 'email-validator' import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' -import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup' +import useSignup from '@bigcommerce/storefront-data-hooks/use-signup' interface Props {} diff --git a/components/auth/LoginView.tsx b/components/auth/LoginView.tsx index 33cb88c21..1ffd7fb1a 100644 --- a/components/auth/LoginView.tsx +++ b/components/auth/LoginView.tsx @@ -1,6 +1,6 @@ import { FC, useEffect, useState, useCallback } from 'react' import { Logo, Modal, Button, Input } from '@components/ui' -import useLogin from '@bigcommerce/storefront-data-hooks/dist/use-login' +import useLogin from '@bigcommerce/storefront-data-hooks/use-login' import { useUI } from '@components/ui/context' import { validate } from 'email-validator' diff --git a/components/auth/SignUpView.tsx b/components/auth/SignUpView.tsx index f0cfa8458..b1b2fef45 100644 --- a/components/auth/SignUpView.tsx +++ b/components/auth/SignUpView.tsx @@ -3,7 +3,7 @@ import { validate } from 'email-validator' import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' -import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup' +import useSignup from '@bigcommerce/storefront-data-hooks/use-signup' interface Props {} diff --git a/components/cart/CartItem/CartItem.tsx b/components/cart/CartItem/CartItem.tsx index 0a6062545..61906960f 100644 --- a/components/cart/CartItem/CartItem.tsx +++ b/components/cart/CartItem/CartItem.tsx @@ -3,9 +3,9 @@ import Image from 'next/image' import Link from 'next/link' import { ChangeEvent, useEffect, useState } from 'react' import { Trash, Plus, Minus } from '@components/icons' -import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' -import useUpdateItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-update-item' -import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-remove-item' +import usePrice from '@bigcommerce/storefront-data-hooks/use-price' +import useUpdateItem from '@bigcommerce/storefront-data-hooks/cart/use-update-item' +import useRemoveItem from '@bigcommerce/storefront-data-hooks/cart/use-remove-item' const CartItem = ({ item, diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index 8f019494b..6a1abcfc8 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -4,8 +4,8 @@ import { UserNav } from '@components/core' import { Button } from '@components/ui' import { ArrowLeft, Bag, Cross, Check } from '@components/icons' import { useUI } from '@components/ui/context' -import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' -import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' +import useCart from '@bigcommerce/storefront-data-hooks/cart/use-cart' +import usePrice from '@bigcommerce/storefront-data-hooks/use-price' import CartItem from '../CartItem' import s from './CartSidebarView.module.css' diff --git a/components/core/Footer/Footer.tsx b/components/core/Footer/Footer.tsx index 419de5ccc..968ebecb1 100644 --- a/components/core/Footer/Footer.tsx +++ b/components/core/Footer/Footer.tsx @@ -2,7 +2,7 @@ import { FC } from 'react' import cn from 'classnames' import Link from 'next/link' import { useRouter } from 'next/router' -import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import type { Page } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import getSlug from '@utils/get-slug' import { Github } from '@components/icons' import { Logo, Container } from '@components/ui' diff --git a/components/core/Layout/Layout.tsx b/components/core/Layout/Layout.tsx index 392844c10..9ac0a74ed 100644 --- a/components/core/Layout/Layout.tsx +++ b/components/core/Layout/Layout.tsx @@ -1,8 +1,8 @@ import { FC, useCallback, useEffect, useState } from 'react' import cn from 'classnames' import { useRouter } from 'next/router' -import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' -import { CommerceProvider } from '@bigcommerce/storefront-data-hooks/dist' +import type { Page } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' +import { CommerceProvider } from '@bigcommerce/storefront-data-hooks' import { CartSidebarView } from '@components/cart' import { Container, Sidebar, Button, Modal, Toast } from '@components/ui' import { Navbar, Featurebar, Footer } from '@components/core' diff --git a/components/core/UserNav/DropdownMenu.tsx b/components/core/UserNav/DropdownMenu.tsx index 2d4ccf8b8..c950f60cb 100644 --- a/components/core/UserNav/DropdownMenu.tsx +++ b/components/core/UserNav/DropdownMenu.tsx @@ -5,7 +5,7 @@ import cn from 'classnames' import s from './DropdownMenu.module.css' import { Moon, Sun } from '@components/icons' import { Menu, Transition } from '@headlessui/react' -import useLogout from '@bigcommerce/storefront-data-hooks/dist/use-logout' +import useLogout from '@bigcommerce/storefront-data-hooks/use-logout' import { useRouter } from 'next/router' interface DropdownMenuProps { diff --git a/components/core/UserNav/UserNav.tsx b/components/core/UserNav/UserNav.tsx index ab5ea9da1..cb8ffeaec 100644 --- a/components/core/UserNav/UserNav.tsx +++ b/components/core/UserNav/UserNav.tsx @@ -7,8 +7,8 @@ import { Avatar } from '@components/core' import { useUI } from '@components/ui/context' import DropdownMenu from './DropdownMenu' import { Menu } from '@headlessui/react' -import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' -import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' +import useCart from '@bigcommerce/storefront-data-hooks/cart/use-cart' +import useCustomer from '@bigcommerce/storefront-data-hooks/use-customer' interface Props { className?: string } diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 345c31177..80d6c8f00 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -1,8 +1,8 @@ import type { FC } from 'react' import cn from 'classnames' import Link from 'next/link' -import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' -import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-products' +import usePrice from '@bigcommerce/storefront-data-hooks/use-price' import { EnhancedImage } from '@components/core' import s from './ProductCard.module.css' import WishlistButton from '@components/wishlist/WishlistButton' diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx index d795c92cc..0530fb186 100644 --- a/components/product/ProductView/ProductView.tsx +++ b/components/product/ProductView/ProductView.tsx @@ -10,8 +10,8 @@ import { Swatch, ProductSlider } from '@components/product' import { Button, Container } from '@components/ui' import { HTMLContent } from '@components/core' -import useAddItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-add-item' -import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' +import useAddItem from '@bigcommerce/storefront-data-hooks/cart/use-add-item' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/api/operations/get-product' import { getProductOptions } from '../helpers' interface Props { diff --git a/components/product/helpers.ts b/components/product/helpers.ts index f9e69f954..9b89bb3db 100644 --- a/components/product/helpers.ts +++ b/components/product/helpers.ts @@ -1,4 +1,4 @@ -import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/api/operations/get-product' export function getProductOptions(product: ProductNode) { const options = product.productOptions.edges?.map(({ node }: any) => ({ diff --git a/components/wishlist/WishlistButton/WishlistButton.tsx b/components/wishlist/WishlistButton/WishlistButton.tsx index 584fba8c7..084007e88 100644 --- a/components/wishlist/WishlistButton/WishlistButton.tsx +++ b/components/wishlist/WishlistButton/WishlistButton.tsx @@ -1,10 +1,10 @@ import React, { FC, useState } from 'react' import cn from 'classnames' -import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' -import useAddItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-add-item' -import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-remove-item' -import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist' -import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' +import type { ProductNode } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-products' +import useAddItem from '@bigcommerce/storefront-data-hooks/wishlist/use-add-item' +import useRemoveItem from '@bigcommerce/storefront-data-hooks/wishlist/use-remove-item' +import useWishlist from '@bigcommerce/storefront-data-hooks/wishlist/use-wishlist' +import useCustomer from '@bigcommerce/storefront-data-hooks/use-customer' import { Heart } from '@components/icons' import { useUI } from '@components/ui/context' diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx index 0d1e14fbd..787c72ee4 100644 --- a/pages/[...pages].tsx +++ b/pages/[...pages].tsx @@ -1,7 +1,7 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import getSlug from '@utils/get-slug' -import getPage from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-page' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getPage from '@bigcommerce/storefront-data-hooks/api/operations/get-page' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import { Layout, HTMLContent } from '@components/core' export async function getStaticProps({ diff --git a/pages/api/bigcommerce/cart.ts b/pages/api/bigcommerce/cart.ts index 58b49da74..bbd70db52 100644 --- a/pages/api/bigcommerce/cart.ts +++ b/pages/api/bigcommerce/cart.ts @@ -1,3 +1,3 @@ -import cartApi from '@bigcommerce/storefront-data-hooks/dist/api/cart' +import cartApi from '@bigcommerce/storefront-data-hooks/api/cart' export default cartApi() diff --git a/pages/api/bigcommerce/catalog/products.ts b/pages/api/bigcommerce/catalog/products.ts index 9ff8fbdaa..7ba267ec1 100644 --- a/pages/api/bigcommerce/catalog/products.ts +++ b/pages/api/bigcommerce/catalog/products.ts @@ -1,3 +1,3 @@ -import catalogProductsApi from '@bigcommerce/storefront-data-hooks/dist/api/catalog/products' +import catalogProductsApi from '@bigcommerce/storefront-data-hooks/api/catalog/products' export default catalogProductsApi() diff --git a/pages/api/bigcommerce/checkout.ts b/pages/api/bigcommerce/checkout.ts index f8b1aa924..6895076b6 100644 --- a/pages/api/bigcommerce/checkout.ts +++ b/pages/api/bigcommerce/checkout.ts @@ -1,3 +1,3 @@ -import checkoutApi from '@bigcommerce/storefront-data-hooks/dist/api/checkout' +import checkoutApi from '@bigcommerce/storefront-data-hooks/api/checkout' export default checkoutApi() diff --git a/pages/api/bigcommerce/customers/index.ts b/pages/api/bigcommerce/customers/index.ts index e349b8292..21f53dbdc 100644 --- a/pages/api/bigcommerce/customers/index.ts +++ b/pages/api/bigcommerce/customers/index.ts @@ -1,3 +1,3 @@ -import customersApi from '@bigcommerce/storefront-data-hooks/dist/api/customers' +import customersApi from '@bigcommerce/storefront-data-hooks/api/customers' export default customersApi() diff --git a/pages/api/bigcommerce/customers/login.ts b/pages/api/bigcommerce/customers/login.ts index 581324491..44aec1f7f 100644 --- a/pages/api/bigcommerce/customers/login.ts +++ b/pages/api/bigcommerce/customers/login.ts @@ -1,3 +1,3 @@ -import loginApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/login' +import loginApi from '@bigcommerce/storefront-data-hooks/api/customers/login' export default loginApi() diff --git a/pages/api/bigcommerce/customers/logout.ts b/pages/api/bigcommerce/customers/logout.ts index 4d3da0d6e..29cc21063 100644 --- a/pages/api/bigcommerce/customers/logout.ts +++ b/pages/api/bigcommerce/customers/logout.ts @@ -1,3 +1,3 @@ -import logoutApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/logout' +import logoutApi from '@bigcommerce/storefront-data-hooks/api/customers/logout' export default logoutApi() diff --git a/pages/api/bigcommerce/customers/signup.ts b/pages/api/bigcommerce/customers/signup.ts index c7ba5db21..9ce5c889b 100644 --- a/pages/api/bigcommerce/customers/signup.ts +++ b/pages/api/bigcommerce/customers/signup.ts @@ -1,3 +1,3 @@ -import signupApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/signup' +import signupApi from '@bigcommerce/storefront-data-hooks/api/customers/signup' export default signupApi() diff --git a/pages/api/bigcommerce/wishlist.ts b/pages/api/bigcommerce/wishlist.ts index b361c87b2..d918c4bf1 100644 --- a/pages/api/bigcommerce/wishlist.ts +++ b/pages/api/bigcommerce/wishlist.ts @@ -1,3 +1,3 @@ -import wishlistApi from '@bigcommerce/storefront-data-hooks/dist/api/wishlist' +import wishlistApi from '@bigcommerce/storefront-data-hooks/api/wishlist' export default wishlistApi() diff --git a/pages/blog.tsx b/pages/blog.tsx index 22c8ebf59..2ba94b109 100644 --- a/pages/blog.tsx +++ b/pages/blog.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container } from '@components/ui' diff --git a/pages/cart.tsx b/pages/cart.tsx index 515060369..00b2a5cb1 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -1,10 +1,10 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import { Layout } from '@components/core' import { Button } from '@components/ui' import { Bag, Cross, Check } from '@components/icons' -import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' -import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' +import useCart from '@bigcommerce/storefront-data-hooks/cart/use-cart' +import usePrice from '@bigcommerce/storefront-data-hooks/use-price' import { CartItem } from '@components/cart' import { Text } from '@components/ui' diff --git a/pages/index.tsx b/pages/index.tsx index dc3f97679..b76361d78 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,9 +1,9 @@ import { useMemo } from 'react' import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api' -import getAllProducts from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products' -import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import { getConfig } from '@bigcommerce/storefront-data-hooks/api' +import getAllProducts from '@bigcommerce/storefront-data-hooks/api/operations/get-all-products' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/api/operations/get-site-info' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import rangeMap from '@lib/range-map' import { Layout } from '@components/core' import { Grid, Marquee, Hero } from '@components/ui' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index b4dd65d56..e42d53d4d 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -4,12 +4,12 @@ import { InferGetStaticPropsType, } from 'next' import { useRouter } from 'next/router' -import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' -import getProduct from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' +import { getConfig } from '@bigcommerce/storefront-data-hooks/api' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' +import getProduct from '@bigcommerce/storefront-data-hooks/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-product-paths' +import getAllProductPaths from '@bigcommerce/storefront-data-hooks/api/operations/get-all-product-paths' export async function getStaticProps({ params, diff --git a/pages/profile.tsx b/pages/profile.tsx index 4dcb39bd7..3c52f5fee 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -1,6 +1,6 @@ import { Layout } from '@components/core' import { Container, Text } from '@components/ui' -import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' +import useCustomer from '@bigcommerce/storefront-data-hooks/use-customer' export default function Profile() { const { data } = useCustomer() console.log(data) diff --git a/pages/search.tsx b/pages/search.tsx index 5dcf94883..1bc672fbf 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -5,9 +5,9 @@ import { useRouter } from 'next/router' import { Layout } from '@components/core' import { ProductCard } from '@components/product' import { Container, Grid, Skeleton } from '@components/ui' -import useSearch from '@bigcommerce/storefront-data-hooks/dist/products/use-search' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' -import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' +import useSearch from '@bigcommerce/storefront-data-hooks/products/use-search' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/api/operations/get-site-info' import rangeMap from '@lib/range-map' import getSlug from '@utils/get-slug' import { diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index fb24adaa5..ab76c0c85 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -1,11 +1,11 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages' +import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container, Text } from '@components/ui' import { WishlistCard } from '@components/wishlist' -import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info' -import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist' +import getSiteInfo from '@bigcommerce/storefront-data-hooks/api/operations/get-site-info' +import useWishlist from '@bigcommerce/storefront-data-hooks/wishlist/use-wishlist' export async function getStaticProps({ preview }: GetStaticPropsContext) { const { pages } = await getAllPages() From a56a2f55331f629d328e34df209a488210794634 Mon Sep 17 00:00:00 2001 From: Belen Curcio <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:22:27 -0300 Subject: [PATCH 10/23] Changes --- components/auth/ForgotPassword.tsx | 16 ---------------- .../cart/CartSidebarView/CartSidebarView.tsx | 4 ++-- components/core/Footer/Footer.module.css | 9 +++++++++ components/core/Footer/Footer.tsx | 6 ++++-- 4 files changed, 15 insertions(+), 20 deletions(-) create mode 100644 components/core/Footer/Footer.module.css diff --git a/components/auth/ForgotPassword.tsx b/components/auth/ForgotPassword.tsx index f6e342742..261c171af 100644 --- a/components/auth/ForgotPassword.tsx +++ b/components/auth/ForgotPassword.tsx @@ -1,9 +1,7 @@ import { FC, useEffect, useState, useCallback } from 'react' import { validate } from 'email-validator' -import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' -import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup' interface Props {} @@ -15,7 +13,6 @@ const ForgotPassword: FC<Props> = () => { const [dirty, setDirty] = useState(false) const [disabled, setDisabled] = useState(false) - const signup = useSignup() const { setModalView, closeModal } = useUI() const handleSignup = async () => { @@ -23,19 +20,6 @@ const ForgotPassword: FC<Props> = () => { setDirty(true) handleValidation() } - - // try { - // setLoading(true) - // setMessage('') - // await signup({ - // email, - // }) - // setLoading(false) - // closeModal() - // } catch ({ errors }) { - // setMessage(errors[0].message) - // setLoading(false) - // } } const handleValidation = useCallback(() => { diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index 8f019494b..0c8a2db3f 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -2,7 +2,7 @@ import { FC } from 'react' import cn from 'classnames' import { UserNav } from '@components/core' import { Button } from '@components/ui' -import { ArrowLeft, Bag, Cross, Check } from '@components/icons' +import { Bag, Cross, Check } from '@components/icons' import { useUI } from '@components/ui/context' import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart' import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price' @@ -47,7 +47,7 @@ const CartSidebarView: FC = () => { aria-label="Close panel" className="hover:text-gray-500 transition ease-in-out duration-150" > - <ArrowLeft className="h-6 w-6" /> + <Cross className="h-6 w-6" /> </button> </div> <div className="space-y-1"> diff --git a/components/core/Footer/Footer.module.css b/components/core/Footer/Footer.module.css new file mode 100644 index 000000000..259318ecf --- /dev/null +++ b/components/core/Footer/Footer.module.css @@ -0,0 +1,9 @@ +.link { + & > svg { + @apply transform duration-75 ease-linear; + } + + &:hover > svg { + @apply scale-110; + } +} diff --git a/components/core/Footer/Footer.tsx b/components/core/Footer/Footer.tsx index 419de5ccc..b4472c287 100644 --- a/components/core/Footer/Footer.tsx +++ b/components/core/Footer/Footer.tsx @@ -7,7 +7,7 @@ import getSlug from '@utils/get-slug' import { Github } from '@components/icons' import { Logo, Container } from '@components/ui' import { I18nWidget } from '@components/core' - +import s from './Footer.module.css' interface Props { className?: string children?: any @@ -83,7 +83,9 @@ const Footer: FC<Props> = ({ className, pages }) => { </div> <div className="col-span-1 lg:col-span-6 flex items-start lg:justify-end text-primary"> <div className="flex space-x-6 items-center h-10"> - <Github /> + <a href="https://github.com/vercel/commerce" className={s.link}> + <Github /> + </a> <I18nWidget /> </div> </div> From d79ddb07febae19b02982a83ea24520453b502fe Mon Sep 17 00:00:00 2001 From: B <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:38:06 -0300 Subject: [PATCH 11/23] Update README.md --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a586199d2..6f1330d9c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,32 @@ # Next.js Commerce +The all-in-one starter kit for high-performance ecommerce sites. With a few clicks, Next.js developers can clone, deploy, and fully customize it. +Start right now at nextjs.org/commerce. -## Features +Demo live at: https://commerce-demo.vercel.app/ -## Todo +This project is currently under development. + +## Why +Ecommerce is one of the most important uses of the web and together we can raise the standard for ecommerce sites. + +## Goals and Features +- Performant by default +- SEO Ready +- Internationalization +- Responsive +- UI Components +- Theming +- Standarized Data Hooks +- Integrations - Integrate seamlessly with the most common ecommerce platforms. ## Contribute +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 yarn: `npm install -g yarn` +4. Install the dependencies: `yarn` +5. Run `yarn dev` to build and watch for code changes +7. The development branch is `development` (this is the branch pull requests should be made against). +On a release, the relevant parts of the changes in the `staging` branch are rebased into `master`. + From 1c454f35ec512e57721317d5ceb0eb8734a20259 Mon Sep 17 00:00:00 2001 From: B <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:39:33 -0300 Subject: [PATCH 12/23] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f1330d9c..54ebd4793 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Next.js Commerce The all-in-one starter kit for high-performance ecommerce sites. With a few clicks, Next.js developers can clone, deploy, and fully customize it. -Start right now at nextjs.org/commerce. +Start right now at [nextjs.org/commerce](https://nextjs.org/commerce) -Demo live at: https://commerce-demo.vercel.app/ +Demo live at: [commerce-demo.vercel.app](https://commerce-demo.vercel.app/) This project is currently under development. From a4941ad67873c6a29ec17e26c6b40988f6899d98 Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Mon, 26 Oct 2020 23:42:45 -0300 Subject: [PATCH 13/23] Add support for dynamic flags images and alts --- components/core/I18nWidget/I18nWidget.tsx | 38 ++++++++++++++++++---- public/flag-en-us.svg | 1 + public/flag-es.svg | 1 + public/flag-us.png | Bin 762 -> 0 bytes 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 public/flag-en-us.svg create mode 100644 public/flag-es.svg delete mode 100644 public/flag-us.png diff --git a/components/core/I18nWidget/I18nWidget.tsx b/components/core/I18nWidget/I18nWidget.tsx index 132553f7f..31f2db76f 100644 --- a/components/core/I18nWidget/I18nWidget.tsx +++ b/components/core/I18nWidget/I18nWidget.tsx @@ -6,21 +6,47 @@ import { Menu } from '@headlessui/react' import { DoubleChevron } from '@components/icons' import s from './I18nWidget.module.css' -const LOCALES_MAP: Record<string, string> = { - es: 'Español', - 'en-US': 'English', +interface LOCALE_DATA { + name: string + img: { + filename: string + alt: string + } +} + +const LOCALES_MAP: Record<string, LOCALE_DATA> = { + es: { + name: 'Español', + img: { + filename: 'flag-es.svg', + alt: 'Bandera española', + }, + }, + 'en-US': { + name: 'English', + img: { + filename: 'flag-en-us.svg', + alt: 'US Flag', + }, + }, } const I18nWidget: FC = () => { const { locale, locales, defaultLocale = 'en-US' } = useRouter() const options = locales?.filter((val) => val !== locale) + const currentLocale = locale || defaultLocale + return ( <nav className={s.root}> <Menu> <Menu.Button className={s.button} aria-label="Language selector"> - <img className="mr-2" src="/flag-us.png" alt="US Flag" /> - <span className="mr-2">{LOCALES_MAP[locale || defaultLocale]}</span> + <img + className="block mr-2 w-5" + src={`/${LOCALES_MAP[currentLocale].img.filename}`} + alt={LOCALES_MAP[currentLocale].img.alt} + /> + <span className="mr-2">{LOCALES_MAP[currentLocale].name}</span> {options && ( <span> <DoubleChevron /> @@ -35,7 +61,7 @@ const I18nWidget: FC = () => { {({ active }) => ( <Link href="/" locale={locale}> <a className={cn(s.item, { [s.active]: active })}> - {LOCALES_MAP[locale]} + {LOCALES_MAP[locale].name} </a> </Link> )} diff --git a/public/flag-en-us.svg b/public/flag-en-us.svg new file mode 100644 index 000000000..5e77dee30 --- /dev/null +++ b/public/flag-en-us.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><circle cx="256" cy="256" r="256" fill="#f0f0f0"/><g fill="#d80027"><path d="M244.87 256H512c0-23.106-3.08-45.49-8.819-66.783H244.87V256zM244.87 122.435h229.556a257.35 257.35 0 00-59.07-66.783H244.87v66.783zM256 512c60.249 0 115.626-20.824 159.356-55.652H96.644C140.374 491.176 195.751 512 256 512zM37.574 389.565h436.852a254.474 254.474 0 0028.755-66.783H8.819a254.474 254.474 0 0028.755 66.783z"/></g><path d="M118.584 39.978h23.329l-21.7 15.765 8.289 25.509-21.699-15.765-21.699 15.765 7.16-22.037a257.407 257.407 0 00-49.652 55.337h7.475l-13.813 10.035a255.58 255.58 0 00-6.194 10.938l6.596 20.301-12.306-8.941a253.567 253.567 0 00-8.372 19.873l7.267 22.368h26.822l-21.7 15.765 8.289 25.509-21.699-15.765-12.998 9.444A258.468 258.468 0 000 256h256V0c-50.572 0-97.715 14.67-137.416 39.978zm9.918 190.422l-21.699-15.765L85.104 230.4l8.289-25.509-21.7-15.765h26.822l8.288-25.509 8.288 25.509h26.822l-21.7 15.765 8.289 25.509zm-8.289-100.083l8.289 25.509-21.699-15.765-21.699 15.765 8.289-25.509-21.7-15.765h26.822l8.288-25.509 8.288 25.509h26.822l-21.7 15.765zM220.328 230.4l-21.699-15.765L176.93 230.4l8.289-25.509-21.7-15.765h26.822l8.288-25.509 8.288 25.509h26.822l-21.7 15.765 8.289 25.509zm-8.289-100.083l8.289 25.509-21.699-15.765-21.699 15.765 8.289-25.509-21.7-15.765h26.822l8.288-25.509 8.288 25.509h26.822l-21.7 15.765zm0-74.574l8.289 25.509-21.699-15.765-21.699 15.765 8.289-25.509-21.7-15.765h26.822l8.288-25.509 8.288 25.509h26.822l-21.7 15.765z" fill="#0052b4"/></svg> \ No newline at end of file diff --git a/public/flag-es.svg b/public/flag-es.svg new file mode 100644 index 000000000..5e8e8f08f --- /dev/null +++ b/public/flag-es.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M0 256c0 31.314 5.633 61.31 15.923 89.043L256 367.304l240.077-22.261C506.367 317.31 512 287.314 512 256s-5.633-61.31-15.923-89.043L256 144.696 15.923 166.957C5.633 194.69 0 224.686 0 256z" fill="#ffda44"/><g fill="#d80027"><path d="M496.077 166.957C459.906 69.473 366.071 0 256 0S52.094 69.473 15.923 166.957h480.154zM15.923 345.043C52.094 442.527 145.929 512 256 512s203.906-69.473 240.077-166.957H15.923z"/></g></svg> \ No newline at end of file diff --git a/public/flag-us.png b/public/flag-us.png deleted file mode 100644 index 763f34fbf6d24f03b0090f3645f8719a2bd76807..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 762 zcmV<W0tNkvP)<h;3K|Lk000e1NJLTq000;O000;W1^@s6;CDUv00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yP<VFdsH0*^^VK~#7FwUte1 z6G0Tm-)=W<qzP^a(JHiA5X4WK92Bh|Bo-7}C3-5fRSKS^35W+Tr5D9o$U?-EB7zZ7 zBt@HoMcI_9co0lMErKx-4~=PJ)_g!0my9#32}#;bS51G1-T%xm??3b2>?{R3aa|F4 zV1R!(a|=+ZByF6!7u7S5X&CgH=(4OgjvU%%b%f^@IMPR}4;nHj1|_T_G(r=WaPW>+ z3~I%|e$hcGv>y+;NV~J0gSoGgIySi_y*!B7lrWw==B6krv8qAfS!{UvLsBTp3T(Bt zLNX^qwSIiQ3mV|VCPH;bO^Uk5XNNzh^FrGO7Gfy{OhyLU@Di$Z?$YH(2L4R%09eC8 zVc8CFT6lBIx;R-ap_OG|CH-hV1gl}#Zg-k4`l2-krvk6yg9keJ8)6JhIN;eXJJf5! z^9x5n2N9eqcg5i7m^cI!eOu4WDJSUS=fZcl`ON8vT7$lQ9iBH|vN+d8IKF!md`cBG zbx{y>8Q_(Vs5>DIPvB)1A>ax)&m<)TE&X7pqR)V3CHC-s3*#CS9r-1NBLT=NpT7GB zTAILi>#6~PLkRH<-V0Y=W%7p%jWj_z=L6l?tUMD+zW`Xw{O*{q8r0H%f%5(%P-Gie z$6;-7szsJ(UuTglbI?R8MJA2n)$398=VEIXI5RWktr{5mJfm#qE*CTrI+qVYI9TH- zqUKSlY2`Lu>>cp6(DYkq0<@yI%ev-&fUjCFvuB4N{)19l@>y<<Yu_h$dtUVKc<bX) z8YcYGlW7s<3q0t6vA0JI2ltY{SyY!nnRHM85VX)93aLl9{yUNI(I&@x)HZoHq7|c| sK{ctKeg{R<s)@oViOm!D6ME+T0`BRUVWfOux&QzG07*qoM6N<$f_UXbivR!s From 9c266d2611238983e8cab0ec7808764b1df4d5f8 Mon Sep 17 00:00:00 2001 From: Belen Curcio <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:43:34 -0300 Subject: [PATCH 14/23] Changes --- components/wishlist/WishlistButton/WishlistButton.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/wishlist/WishlistButton/WishlistButton.tsx b/components/wishlist/WishlistButton/WishlistButton.tsx index 584fba8c7..5680ad3a9 100644 --- a/components/wishlist/WishlistButton/WishlistButton.tsx +++ b/components/wishlist/WishlistButton/WishlistButton.tsx @@ -62,9 +62,10 @@ const WishlistButton: FC<Props> = ({ return ( <button - {...props} + aria-label="Add to wishlist" className={cn({ 'opacity-50': loading }, className)} onClick={handleWishlistChange} + {...props} > <Heart fill={itemInWishlist ? 'var(--pink)' : 'none'} /> </button> From 7fe9462855079f3f94ab6db7076839fabeacf3fa Mon Sep 17 00:00:00 2001 From: B <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:52:11 -0300 Subject: [PATCH 15/23] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54ebd4793..6bd5057ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Next.js Commerce -The all-in-one starter kit for high-performance ecommerce sites. With a few clicks, Next.js developers can clone, deploy, and fully customize it. -Start right now at [nextjs.org/commerce](https://nextjs.org/commerce) +The all-in-one starter kit for high-performance e-commerce sites. With a few clicks, Next.js developers can clone, deploy and fully own their own store. +Start right now at nextjs.org/commerce Demo live at: [commerce-demo.vercel.app](https://commerce-demo.vercel.app/) From b840842ee9635c0cdde46bff6caaf9e7535dfd84 Mon Sep 17 00:00:00 2001 From: B <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:52:16 -0300 Subject: [PATCH 16/23] Update README.md From eac2d17946c95a67d9cbf963e2e3cd7222e17914 Mon Sep 17 00:00:00 2001 From: Belen Curcio <curciobelen@gmail.com> Date: Mon, 26 Oct 2020 23:53:00 -0300 Subject: [PATCH 17/23] Flags --- .../cart/CartSidebarView/CartSidebarView.tsx | 2 +- components/core/I18nWidget/I18nWidget.tsx | 4 ++-- public/flag-es-ar.svg | 20 +++++++++++++++++++ public/flag-es-co.svg | 10 ++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 public/flag-es-ar.svg create mode 100644 public/flag-es-co.svg diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index 0c8a2db3f..52a9ee9af 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -51,7 +51,7 @@ const CartSidebarView: FC = () => { </button> </div> <div className="space-y-1"> - <UserNav /> + <UserNav className="" /> </div> </div> </header> diff --git a/components/core/I18nWidget/I18nWidget.tsx b/components/core/I18nWidget/I18nWidget.tsx index 31f2db76f..6bbed6179 100644 --- a/components/core/I18nWidget/I18nWidget.tsx +++ b/components/core/I18nWidget/I18nWidget.tsx @@ -18,8 +18,8 @@ const LOCALES_MAP: Record<string, LOCALE_DATA> = { es: { name: 'Español', img: { - filename: 'flag-es.svg', - alt: 'Bandera española', + filename: 'flag-es-co.svg', + alt: 'Bandera Colombiana', }, }, 'en-US': { diff --git a/public/flag-es-ar.svg b/public/flag-es-ar.svg new file mode 100644 index 000000000..4d6ffc474 --- /dev/null +++ b/public/flag-es-ar.svg @@ -0,0 +1,20 @@ +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M0.75 12C0.75 14.2069 1.38787 16.263 2.4855 18H21.5145C22.6121 16.263 23.25 14.2069 23.25 12C23.25 9.79312 22.6121 7.737 21.5145 6H2.4855C1.38787 7.737 0.75 9.79312 0.75 12Z" fill="#F9F9F9"/> +<path d="M21.5144 6C19.5212 2.84625 16.0064 0.75 11.9999 0.75C7.99335 0.75 4.47848 2.84625 2.48535 6H21.5144Z" fill="#B4D7EE"/> +<path d="M2.48535 18C4.47848 21.1537 7.99335 23.25 11.9999 23.25C16.0064 23.25 19.5212 21.1537 21.5144 18H2.48535Z" fill="#B4D7EE"/> +<path d="M17.1536 11.9359L14.0921 11.8204C14.091 11.8088 14.0906 11.7971 14.0895 11.7855C14.5901 11.6936 14.9467 11.4109 15.4661 11.4578C16.1025 11.5148 16.4625 11.1653 16.7096 11.0843C16.9571 11.0033 17.1052 11.172 17.1405 11.0996C17.1757 11.0269 16.98 10.8671 16.6282 10.9193C16.2765 10.971 16.1719 11.2384 15.3949 11.1754C14.7349 11.1221 14.5039 11.3873 14.016 11.4124C14.0115 11.3966 14.007 11.3809 14.0021 11.3651L16.7857 10.0879C16.7857 10.0879 16.875 10.0508 16.8502 9.99113C16.8262 9.93151 16.7362 9.96863 16.7362 9.96863L13.8641 11.0336C13.8589 11.0235 13.854 11.0126 13.8484 11.0025C14.2759 10.7265 14.4967 10.3286 14.9944 10.173C15.6045 9.98213 15.8032 9.52163 16.0012 9.35213C16.1985 9.18226 16.4002 9.28163 16.4051 9.20101C16.4096 9.12038 16.1677 9.04801 15.8629 9.23063C15.5576 9.41326 15.5629 9.70013 14.8211 9.93938C14.1911 10.1426 14.079 10.476 13.6384 10.686C13.6282 10.6733 13.6177 10.6609 13.6069 10.6481L15.69 8.40226C15.69 8.40226 15.759 8.33363 15.7136 8.28788C15.6679 8.24176 15.5989 8.31076 15.5989 8.31076L13.353 10.3939C13.3444 10.3864 13.3354 10.3789 13.3267 10.3718C13.6159 9.95288 13.668 9.50026 14.0685 9.16613C14.559 8.75663 14.5661 8.25526 14.6842 8.02276C14.8016 7.79063 15.0255 7.80488 14.9992 7.72876C14.973 7.65263 14.7217 7.67813 14.5099 7.96351C14.2976 8.24888 14.4124 8.51176 13.8184 9.01726C13.3144 9.44626 13.3395 9.79688 13.0125 10.1599C12.9979 10.152 12.9829 10.1445 12.9682 10.1366L14.0332 7.26451C14.0332 7.26451 14.0707 7.17488 14.0104 7.15013C13.95 7.12501 13.9129 7.21463 13.9129 7.21463L12.6352 9.99788C12.6247 9.99451 12.6131 9.99113 12.6019 9.98776C12.7091 9.49013 12.5839 9.05213 12.8261 8.59051C13.1224 8.02426 12.9375 7.55813 12.9574 7.29826C12.9772 7.03838 13.1895 6.96638 13.1362 6.90601C13.0819 6.84563 12.8602 6.96526 12.7736 7.31026C12.687 7.65526 12.8936 7.85401 12.5381 8.54813C12.2362 9.13726 12.3926 9.45226 12.2295 9.91238C12.2134 9.91088 12.1972 9.90938 12.1807 9.90788L12.0656 6.84638C12.0656 6.84638 12.0656 6.74963 12.0011 6.74963C11.9366 6.74963 11.9366 6.84638 11.9366 6.84638L11.8211 9.90788C11.8099 9.90863 11.7979 9.90938 11.7866 9.91051C11.6947 9.40988 11.4116 9.05326 11.4585 8.53388C11.5155 7.89751 11.166 7.53751 11.085 7.29001C11.004 7.04251 11.1727 6.89438 11.1 6.85913C11.0272 6.82388 10.8679 7.01963 10.9204 7.37138C10.9721 7.72313 11.2391 7.82776 11.1765 8.60513C11.1232 9.26476 11.388 9.49576 11.4135 9.98363C11.3977 9.98813 11.382 9.99263 11.3666 9.99751L10.089 7.21426C10.089 7.21426 10.0519 7.12463 9.99225 7.14938C9.93262 7.17376 9.96975 7.26376 9.96975 7.26376L11.0344 10.1355C11.0242 10.1411 11.0137 10.1456 11.0036 10.1513C10.7272 9.72376 10.3294 9.50288 10.1741 9.00526C9.98325 8.39513 9.52275 8.19638 9.35287 7.99876C9.18337 7.80113 9.28275 7.60013 9.20212 7.59488C9.1215 7.59038 9.04912 7.83188 9.23175 8.13713C9.41437 8.44238 9.70125 8.43676 9.94087 9.17888C10.1441 9.80851 10.4775 9.92101 10.6879 10.362C10.6751 10.3721 10.6624 10.3826 10.6496 10.3931L8.40375 8.31001C8.40375 8.31001 8.33512 8.24138 8.28937 8.28676C8.24362 8.33251 8.31225 8.40113 8.31225 8.40113L10.3954 10.647C10.3879 10.656 10.3804 10.6646 10.3729 10.6736C9.954 10.3841 9.50137 10.332 9.16725 9.93188C8.75737 9.44138 8.256 9.43388 8.0235 9.31613C7.79137 9.19876 7.806 8.97488 7.7295 9.00113C7.653 9.02776 7.67887 9.27863 7.96425 9.49088C8.24962 9.70276 8.5125 9.58801 9.018 10.182C9.447 10.6864 9.798 10.6613 10.1602 10.9883C10.1524 11.0029 10.1449 11.0179 10.137 11.0325L7.26525 9.96751C7.26525 9.96751 7.17563 9.93038 7.15088 9.99038C7.12538 10.0504 7.215 10.0875 7.215 10.0875L9.99825 11.3648C9.9945 11.376 9.9915 11.3873 9.98812 11.3981C9.49012 11.2909 9.0525 11.4161 8.59088 11.1743C8.02463 10.8776 7.5585 11.0629 7.299 11.0434C7.03912 11.0235 6.96712 10.8109 6.90637 10.8645C6.84637 10.9185 6.966 11.1401 7.31062 11.2268C7.65562 11.3134 7.85437 11.1068 8.5485 11.4619C9.13725 11.7638 9.45262 11.6074 9.91275 11.7705C9.91087 11.7866 9.90975 11.8031 9.90825 11.8193L6.84675 11.9348C6.84675 11.9348 6.75 11.9348 6.75 11.9993C6.75 12.0641 6.84675 12.0638 6.84675 12.0638L9.90825 12.1793C9.90937 12.1909 9.90975 12.2025 9.91087 12.2138C9.41025 12.3053 9.05362 12.5888 8.53425 12.5419C7.89787 12.4849 7.53787 12.834 7.29037 12.9154C7.04287 12.996 6.89475 12.8276 6.8595 12.9C6.82425 12.9728 7.02 13.1321 7.37175 13.08C7.7235 13.0279 7.82812 12.7613 8.6055 12.8239C9.26512 12.8771 9.49612 12.612 9.984 12.5869C9.9885 12.6023 9.99262 12.6184 9.99787 12.6338L7.21463 13.911C7.21463 13.911 7.125 13.9485 7.14975 14.0081C7.1745 14.0678 7.26413 14.0306 7.26413 14.0306L10.1362 12.9656C10.1415 12.9758 10.1464 12.987 10.152 12.9964C9.7245 13.2731 9.50362 13.671 9.00562 13.8263C8.3955 14.0175 8.19712 14.478 7.99912 14.6471C7.8015 14.817 7.60012 14.7176 7.59525 14.7983C7.59037 14.8789 7.83225 14.9513 8.1375 14.7686C8.44275 14.5864 8.43712 14.2991 9.17925 14.0595C9.80925 13.8563 9.92137 13.5229 10.3624 13.3133C10.3725 13.3256 10.383 13.338 10.3935 13.3508L8.31037 15.597C8.31037 15.597 8.24175 15.6656 8.28712 15.7114C8.33287 15.7568 8.4015 15.6885 8.4015 15.6885L10.6474 13.605C10.6564 13.6129 10.665 13.62 10.674 13.6275C10.3849 14.0464 10.3327 14.499 9.93225 14.8331C9.44175 15.2426 9.43462 15.7444 9.3165 15.9769C9.19912 16.209 8.97487 16.1944 9.0015 16.2709C9.02812 16.347 9.279 16.3215 9.49125 16.0358C9.7035 15.75 9.58837 15.4879 10.1824 14.9824C10.6867 14.553 10.6616 14.2024 10.9886 13.8394C11.0032 13.8476 11.0182 13.8551 11.0329 13.8626L9.96825 16.7351C9.96825 16.7351 9.93075 16.8244 9.99075 16.8495C10.0507 16.875 10.0879 16.7854 10.0879 16.7854L11.3655 14.0021C11.3764 14.0055 11.3876 14.0089 11.3989 14.0123C11.2916 14.5095 11.4169 14.9475 11.1746 15.4095C10.8784 15.9761 11.0632 16.4419 11.0434 16.7014C11.0239 16.9609 10.8112 17.0336 10.8649 17.0936C10.9189 17.154 11.1405 17.0344 11.2271 16.6894C11.3137 16.3444 11.1071 16.146 11.4626 15.4515C11.7641 14.8628 11.6077 14.5478 11.7712 14.0869C11.7874 14.0891 11.8039 14.0899 11.82 14.0918L11.9351 17.1529C11.9351 17.1529 11.9351 17.25 11.9996 17.25C12.0645 17.25 12.0641 17.1529 12.0641 17.1529L12.1796 14.0918C12.1912 14.0906 12.2029 14.0899 12.2141 14.0891C12.3056 14.5898 12.5887 14.946 12.5419 15.4658C12.4849 16.1021 12.8344 16.4621 12.9154 16.7096C12.9967 16.9571 12.828 17.1053 12.9007 17.1401C12.9731 17.1754 13.1325 16.9796 13.0804 16.6275C13.0286 16.2758 12.7612 16.1711 12.8242 15.3941C12.8775 14.7349 12.6127 14.5035 12.5869 14.0156C12.6026 14.0111 12.6184 14.007 12.6341 14.0018L13.9114 16.785C13.9114 16.785 13.9489 16.8746 14.0085 16.8503C14.0681 16.8255 14.0314 16.7359 14.0314 16.7359L12.9664 13.8641C12.9765 13.8581 12.987 13.854 12.9971 13.848C13.2731 14.2755 13.671 14.4964 13.827 14.9944C14.0175 15.6045 14.478 15.8029 14.6479 16.0009C14.8174 16.1985 14.7184 16.3995 14.7986 16.4044C14.8789 16.4093 14.9516 16.1674 14.7694 15.8625C14.5864 15.5573 14.2995 15.5629 14.0599 14.8208C13.8566 14.1908 13.5232 14.0786 13.3132 13.6376C13.326 13.6275 13.3387 13.617 13.3515 13.6065L15.597 15.69C15.597 15.69 15.666 15.7586 15.7114 15.7129C15.7571 15.6675 15.6885 15.5985 15.6885 15.5985L13.6054 13.353C13.6129 13.344 13.6204 13.335 13.6279 13.326C14.0467 13.6155 14.499 13.6676 14.8335 14.0681C15.2434 14.559 15.7447 14.5661 15.9772 14.6839C16.2094 14.8013 16.1947 15.0255 16.2712 14.9993C16.3477 14.9723 16.3222 14.7218 16.0365 14.5091C15.7507 14.2976 15.4879 14.412 14.9824 13.8184C14.5537 13.3136 14.2027 13.3391 13.8397 13.0121C13.8476 12.9975 13.8559 12.9829 13.8634 12.9675L16.7351 14.0329C16.7351 14.0329 16.8247 14.07 16.8495 14.0104C16.8754 13.9493 16.7861 13.9125 16.7861 13.9125L14.0025 12.6349C14.0062 12.624 14.0092 12.6128 14.0122 12.6019C14.5102 12.7088 14.9479 12.5835 15.4099 12.8258C15.9761 13.122 16.4426 12.9368 16.7017 12.9566C16.9616 12.9765 17.0336 13.1891 17.0944 13.1355C17.1544 13.0819 17.0347 12.8603 16.6901 12.7729C16.3451 12.6866 16.146 12.8929 15.4522 12.5378C14.8631 12.2363 14.5477 12.3926 14.0876 12.2291C14.0895 12.213 14.0906 12.1965 14.0921 12.1804L17.1536 12.0649C17.1536 12.0649 17.2504 12.0649 17.2504 12.0004C17.2504 11.9355 17.1536 11.9359 17.1536 11.9359Z" fill="#F6B40E"/> +<path d="M13.116 11.7262C13.011 11.6134 12.8598 11.5515 12.717 11.5515C12.5733 11.5515 12.4361 11.6137 12.3555 11.7431C12.5167 11.8882 12.8737 11.9036 13.116 11.7262ZM13.0027 11.7097C12.9412 11.7769 12.8662 11.8166 12.7878 11.8327C12.8291 11.8069 12.8572 11.7615 12.8572 11.7094C12.8572 11.6602 12.8328 11.6171 12.7957 11.5909C12.9007 11.6081 12.9881 11.6587 13.0027 11.7097ZM12.6187 11.598C12.5868 11.6246 12.5658 11.6644 12.5658 11.7094C12.5658 11.7645 12.5973 11.8125 12.6427 11.8369C12.5617 11.826 12.4841 11.793 12.4207 11.7427C12.4713 11.6629 12.543 11.6182 12.6187 11.598Z" fill="#85340A"/> +<path d="M12.7436 11.4514C12.5336 11.4514 12.4856 11.4997 12.3881 11.5804C12.2914 11.661 12.243 11.6449 12.2269 11.661C12.2111 11.6771 12.2269 11.7255 12.2591 11.7094C12.2914 11.6932 12.3562 11.661 12.453 11.58C12.5501 11.4994 12.6469 11.4994 12.7436 11.4994C13.0342 11.4994 13.1959 11.7416 13.2281 11.7255C13.2604 11.7094 13.0669 11.4514 12.7436 11.4514Z" fill="#85340A"/> +<path d="M13.3252 11.548L13.3242 11.547V11.548" fill="#85340A"/> +<path d="M12.1285 11.3861C12.106 11.4461 12.0892 11.5076 12.0779 11.5702C12.0355 11.8102 12.0809 12.0622 12.2095 12.3071C12.2257 12.291 12.2579 12.2749 12.274 12.2749C12.13 12.0712 12.0727 11.8725 12.1053 11.6887C12.1218 11.5942 12.1623 11.5035 12.2257 11.4191C12.484 11.1769 12.9517 11.2249 13.3233 11.5474C12.9678 11.0632 12.4837 11.0955 12.1285 11.3861Z" fill="#85340A"/> +<path d="M12.4842 11.871C12.3544 11.8065 12.3225 11.7743 12.2903 11.7743C12.258 11.7743 12.258 11.8065 12.4193 11.9033C12.5805 12 12.8554 12.0161 13.1303 11.8065C12.807 11.9359 12.6132 11.9359 12.4842 11.871Z" fill="#85340A"/> +<path d="M12.3078 12.48C12.2564 12.48 12.214 12.4391 12.211 12.3877C12.1953 12.4192 12.133 12.513 12.0104 12.5179C11.8874 12.513 11.8251 12.4192 11.8098 12.3877C11.8068 12.4391 11.764 12.48 11.7126 12.48C11.6586 12.48 11.6159 12.4365 11.6159 12.3832C11.6159 12.342 11.641 12.3045 11.6796 12.2906C11.6103 12.3034 11.5615 12.3645 11.5615 12.4342C11.5615 12.5149 11.6279 12.579 11.7081 12.579C11.7554 12.579 11.7993 12.5565 11.8263 12.5175C11.8821 12.5595 11.9594 12.564 12.001 12.5647C12.0074 12.5647 12.0156 12.5647 12.0201 12.5647C12.0614 12.564 12.139 12.5595 12.1949 12.5175C12.2223 12.5565 12.2658 12.579 12.3126 12.579C12.3929 12.579 12.4596 12.5149 12.4596 12.4342C12.4596 12.3645 12.4101 12.3034 12.3415 12.2906C12.3801 12.3045 12.4053 12.342 12.4053 12.3832C12.4045 12.4365 12.3614 12.48 12.3078 12.48Z" fill="#85340A"/> +<path d="M11.9985 12.8175H12.0008C12.0653 12.8175 12.162 12.7391 12.2749 12.8036C12.3878 12.8681 12.4538 12.9319 12.5352 12.9645C12.3893 12.8674 12.3233 12.7211 12.1617 12.7211C12.1294 12.7211 12.0653 12.7388 12.0008 12.771H11.9985C11.934 12.7388 11.8699 12.7211 11.8377 12.7211C11.676 12.7211 11.6119 12.8678 11.4668 12.9645C11.5474 12.9319 11.6112 12.8681 11.7244 12.8036C11.8377 12.7391 11.934 12.8175 11.9985 12.8175Z" fill="#85340A"/> +<path d="M12.001 12.9304H11.9988C11.9384 12.9304 11.89 12.9068 11.7839 12.9116C11.7213 12.9143 11.6388 12.927 11.521 12.9619C11.5045 12.9619 11.4869 12.9619 11.4678 12.9638C11.8071 12.996 11.644 13.1903 11.9991 13.1903H12.0014C12.3565 13.1903 12.196 12.9956 12.5354 12.9638C12.5133 12.9619 12.493 12.9604 12.4746 12.9604C12.1611 12.8681 12.0959 12.9304 12.001 12.9304ZM12.0014 13.1415H11.9991C11.7265 13.1415 11.8105 12.9585 11.5293 12.9615C11.5278 12.9615 11.5255 12.9623 11.524 12.9623C11.8064 12.9019 11.8709 12.9968 11.9988 12.9968H12.001C12.1281 12.9968 12.1926 12.903 12.4701 12.9608C12.1934 12.9593 12.2729 13.1415 12.0014 13.1415Z" fill="#85340A"/> +<path d="M12.0006 13.1962C11.8401 13.1962 11.71 13.3271 11.71 13.4872C11.7418 13.3526 11.8626 13.2574 12.0006 13.2574C12.1393 13.2574 12.2593 13.3526 12.2912 13.4872C12.2916 13.3267 12.1615 13.1962 12.0006 13.1962Z" fill="#85340A"/> +<path d="M10.6953 11.548L10.6963 11.547L10.6953 11.548Z" fill="#85340A"/> +<path d="M11.7939 11.4187C11.8569 11.5035 11.8978 11.5939 11.9143 11.6884C11.9465 11.8725 11.8892 12.0712 11.7452 12.2745C11.7613 12.2745 11.7939 12.2906 11.81 12.3067C11.9383 12.0619 11.9837 11.8099 11.9417 11.5699C11.9308 11.5072 11.9135 11.4457 11.891 11.3857C11.5359 11.0951 11.0514 11.0629 10.6963 11.5466C11.0672 11.2249 11.5355 11.1765 11.7939 11.4187Z" fill="#85340A"/> +<path d="M11.5671 11.5804C11.6638 11.661 11.7287 11.6933 11.7609 11.7098C11.7928 11.7259 11.8093 11.6775 11.7928 11.6614C11.7767 11.6453 11.7287 11.6614 11.6312 11.5808C11.5344 11.5001 11.4861 11.4518 11.2761 11.4518C10.9532 11.4518 10.7593 11.7101 10.7916 11.7263C10.8238 11.7424 10.9854 11.5001 11.2761 11.5001C11.3732 11.4998 11.4696 11.4998 11.5671 11.5804Z" fill="#85340A"/> +<path d="M10.9056 11.7412C10.9919 11.8189 11.1336 11.8586 11.2844 11.853C11.2851 11.853 11.2859 11.8534 11.2863 11.8534C11.2878 11.8534 11.2893 11.853 11.2908 11.853C11.4201 11.8466 11.5555 11.8061 11.6658 11.7247C11.5608 11.6119 11.4096 11.55 11.2664 11.55C11.1235 11.5496 10.9859 11.6119 10.9053 11.7412H10.9056ZM10.9716 11.7412C11.0286 11.6497 11.1141 11.6047 11.2023 11.5894C11.1648 11.6156 11.1404 11.6587 11.1404 11.7079C11.1404 11.7656 11.1745 11.8151 11.2236 11.8387C11.1321 11.8324 11.0425 11.7979 10.9716 11.7412ZM11.5525 11.7082C11.5011 11.7645 11.44 11.8016 11.3755 11.8215C11.4093 11.7949 11.431 11.754 11.431 11.7079C11.431 11.6621 11.4096 11.622 11.3766 11.5954C11.4678 11.6167 11.5398 11.6625 11.5525 11.7082Z" fill="#85340A"/> +<path d="M11.7267 11.7743C11.6945 11.7743 11.6622 11.8065 11.5328 11.871C11.4035 11.9355 11.21 11.9355 10.8867 11.8065C11.1612 12.0165 11.4357 12.0004 11.5973 11.9033C11.7593 11.8065 11.7593 11.7743 11.7267 11.7743Z" fill="#85340A"/> +</svg> diff --git a/public/flag-es-co.svg b/public/flag-es-co.svg new file mode 100644 index 000000000..618820393 --- /dev/null +++ b/public/flag-es-co.svg @@ -0,0 +1,10 @@ +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> +<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24"> +<path fill-rule="evenodd" clip-rule="evenodd" d="M21.5144 6C19.5212 2.84625 16.0064 0.75 11.9999 0.75C7.99335 0.75 4.47848 2.84625 2.48535 6H2.4855C1.38787 7.737 0.75 9.79313 0.75 12C0.75 14.2069 1.38787 16.263 2.4855 18H2.48535C4.47848 21.1537 7.99335 23.25 11.9999 23.25C16.0064 23.25 19.5212 21.1537 21.5144 18H21.5145C22.6121 16.263 23.25 14.2069 23.25 12C23.25 9.79313 22.6121 7.737 21.5145 6H21.5144Z" fill="#B4D7EE"/> +</mask> +<g mask="url(#mask0)"> +<rect x="-2" y="-1" width="27" height="14" fill="#FCD116"/> +<rect x="-2" y="13" width="27" height="6" fill="#003893"/> +<rect x="-2" y="19" width="27" height="6" fill="#CE1126"/> +</g> +</svg> From 71e0d0a31564b8942fd06ba32c5ab634d5de047e Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 00:06:27 -0300 Subject: [PATCH 18/23] Make language switcher to change language but stay on the current page --- components/core/I18nWidget/I18nWidget.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/core/I18nWidget/I18nWidget.tsx b/components/core/I18nWidget/I18nWidget.tsx index 6bbed6179..428f7bc1f 100644 --- a/components/core/I18nWidget/I18nWidget.tsx +++ b/components/core/I18nWidget/I18nWidget.tsx @@ -32,7 +32,12 @@ const LOCALES_MAP: Record<string, LOCALE_DATA> = { } const I18nWidget: FC = () => { - const { locale, locales, defaultLocale = 'en-US' } = useRouter() + const { + locale, + locales, + defaultLocale = 'en-US', + asPath: currentPath, + } = useRouter() const options = locales?.filter((val) => val !== locale) const currentLocale = locale || defaultLocale @@ -59,7 +64,7 @@ const I18nWidget: FC = () => { {options.map((locale) => ( <Menu.Item key={locale}> {({ active }) => ( - <Link href="/" locale={locale}> + <Link href={currentPath} locale={locale}> <a className={cn(s.item, { [s.active]: active })}> {LOCALES_MAP[locale].name} </a> From f843e6b12db60ac83ed53aba58d055bd021995bb Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 00:20:27 -0300 Subject: [PATCH 19/23] Make add to wishlist action to work --- components/product/ProductView/ProductView.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx index d795c92cc..cc0ced281 100644 --- a/components/product/ProductView/ProductView.tsx +++ b/components/product/ProductView/ProductView.tsx @@ -13,6 +13,7 @@ import { HTMLContent } from '@components/core' import useAddItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-add-item' import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product' import { getProductOptions } from '../helpers' +import WishlistButton from '@components/wishlist/WishlistButton' interface Props { className?: string @@ -143,9 +144,11 @@ const ProductView: FC<Props> = ({ product, className }) => { </div> {/* TODO make it work */} - <div className={s.wishlistButton}> - <Heart /> - </div> + <WishlistButton + className={s.wishlistButton} + productId={product.entityId} + variant={product.variants.edges?.[0]!} + /> </div> </Container> ) From b23896998c74dc4cf181e1abc79d63220542d741 Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 00:31:44 -0300 Subject: [PATCH 20/23] Add link for slim version of product card --- .../product/ProductCard/ProductCard.tsx | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 345c31177..cad54c4da 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -31,56 +31,56 @@ const ProductCard: FC<Props> = ({ currencyCode: p.prices?.price?.currencyCode!, }) - if (variant === 'slim') { - return ( - <div className="relative overflow-hidden box-border"> - <div className="absolute inset-0 flex items-center justify-end mr-8 z-20"> - <span className="bg-black text-white inline-block p-3 font-bold text-xl break-words"> - {p.name} - </span> - </div> - <EnhancedImage - src={p.images.edges?.[0]?.node.urlOriginal!} - alt={p.name} - width={imgWidth} - height={imgHeight} - priority={priority} - quality="90" - /> - </div> - ) - } - return ( <Link href={`/product${p.path}`}> <a className={cn(s.root, { [s.simple]: variant === 'simple' }, className)} > - <div className={s.squareBg} /> - <div className="flex flex-row justify-between box-border w-full z-20 absolute"> - <div className="absolute top-0 left-0 pr-16 max-w-full"> - <h3 className={s.productTitle}> - <span>{p.name}</span> - </h3> - <span className={s.productPrice}>{price}</span> + {variant === 'slim' ? ( + <div className="relative overflow-hidden box-border"> + <div className="absolute inset-0 flex items-center justify-end mr-8 z-20"> + <span className="bg-black text-white inline-block p-3 font-bold text-xl break-words"> + {p.name} + </span> + </div> + <EnhancedImage + src={p.images.edges?.[0]?.node.urlOriginal!} + alt={p.name} + width={imgWidth} + height={imgHeight} + priority={priority} + quality="90" + /> </div> - <WishlistButton - className={s.wishlistButton} - productId={p.entityId} - variant={p.variants.edges?.[0]!} - /> - </div> - <div className={s.imageContainer}> - <EnhancedImage - alt={p.name} - className={cn('w-full object-cover', s['product-image'])} - src={src} - width={imgWidth} - height={imgHeight} - priority={priority} - quality="90" - /> - </div> + ) : ( + <> + <div className={s.squareBg} /> + <div className="flex flex-row justify-between box-border w-full z-20 absolute"> + <div className="absolute top-0 left-0 pr-16 max-w-full"> + <h3 className={s.productTitle}> + <span>{p.name}</span> + </h3> + <span className={s.productPrice}>{price}</span> + </div> + <WishlistButton + className={s.wishlistButton} + productId={p.entityId} + variant={p.variants.edges?.[0]!} + /> + </div> + <div className={s.imageContainer}> + <EnhancedImage + alt={p.name} + className={cn('w-full object-cover', s['product-image'])} + src={src} + width={imgWidth} + height={imgHeight} + priority={priority} + quality="90" + /> + </div> + </> + )} </a> </Link> ) From 2ae113ed6610d7f1331fec64913da6e13ab28b9f Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 00:52:49 -0300 Subject: [PATCH 21/23] Adds some extra logic for handling sidebar --- components/core/UserNav/DropdownMenu.tsx | 4 ++++ components/core/UserNav/UserNav.tsx | 9 +++------ components/ui/context.tsx | 8 ++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/core/UserNav/DropdownMenu.tsx b/components/core/UserNav/DropdownMenu.tsx index 2d4ccf8b8..85a856f6c 100644 --- a/components/core/UserNav/DropdownMenu.tsx +++ b/components/core/UserNav/DropdownMenu.tsx @@ -4,6 +4,7 @@ import { useTheme } from 'next-themes' import cn from 'classnames' import s from './DropdownMenu.module.css' import { Moon, Sun } from '@components/icons' +import { useUI } from '@components/ui/context' import { Menu, Transition } from '@headlessui/react' import useLogout from '@bigcommerce/storefront-data-hooks/dist/use-logout' import { useRouter } from 'next/router' @@ -32,6 +33,8 @@ const DropdownMenu: FC<DropdownMenuProps> = ({ open = false }) => { const logout = useLogout() const { pathname } = useRouter() + const { closeSidebarIfPresent } = useUI() + return ( <Transition show={open} @@ -51,6 +54,7 @@ const DropdownMenu: FC<DropdownMenuProps> = ({ open = false }) => { className={cn(s.link, { [s.active]: pathname === href, })} + onClick={closeSidebarIfPresent} > {name} </a> diff --git a/components/core/UserNav/UserNav.tsx b/components/core/UserNav/UserNav.tsx index ab5ea9da1..e86591073 100644 --- a/components/core/UserNav/UserNav.tsx +++ b/components/core/UserNav/UserNav.tsx @@ -21,21 +21,18 @@ const UserNav: FC<Props> = ({ className, children, ...props }) => { const { data } = useCart() const { data: customer } = useCustomer() - const { openSidebar, closeSidebar, displaySidebar, openModal } = useUI() + const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI() const itemsCount = Object.values(data?.line_items ?? {}).reduce(countItems, 0) return ( <nav className={cn(s.root, className)}> <div className={s.mainContainer}> <ul className={s.list}> - <li - className={s.item} - onClick={(e) => (displaySidebar ? closeSidebar() : openSidebar())} - > + <li className={s.item} onClick={toggleSidebar}> <Bag /> {itemsCount > 0 && <span className={s.bagCount}>{itemsCount}</span>} </li> <Link href="/wishlist"> - <li className={s.item}> + <li className={s.item} onClick={closeSidebarIfPresent}> <Heart /> </li> </Link> diff --git a/components/ui/context.tsx b/components/ui/context.tsx index 14b4af6c5..8fff349fd 100644 --- a/components/ui/context.tsx +++ b/components/ui/context.tsx @@ -131,6 +131,12 @@ export const UIProvider: FC = (props) => { const openSidebar = () => dispatch({ type: 'OPEN_SIDEBAR' }) const closeSidebar = () => dispatch({ type: 'CLOSE_SIDEBAR' }) + const toggleSidebar = () => + state.displaySidebar + ? dispatch({ type: 'CLOSE_SIDEBAR' }) + : dispatch({ type: 'OPEN_SIDEBAR' }) + const closeSidebarIfPresent = () => + state.displaySidebar && dispatch({ type: 'CLOSE_SIDEBAR' }) const openDropdown = () => dispatch({ type: 'OPEN_DROPDOWN' }) const closeDropdown = () => dispatch({ type: 'CLOSE_DROPDOWN' }) @@ -149,6 +155,8 @@ export const UIProvider: FC = (props) => { ...state, openSidebar, closeSidebar, + toggleSidebar, + closeSidebarIfPresent, openDropdown, closeDropdown, openModal, From 07f9ecb32f64736f81cfc2513c7fa272fca975ae Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 01:09:55 -0300 Subject: [PATCH 22/23] Make profile left column size consistent --- pages/profile.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pages/profile.tsx b/pages/profile.tsx index 4dcb39bd7..78e2fb05a 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -3,21 +3,23 @@ import { Container, Text } from '@components/ui' import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer' export default function Profile() { const { data } = useCustomer() - console.log(data) + return ( <Container> <Text variant="pageHeading">My Profile</Text> {data && ( - <div className="max-w-2xl flex flex-col space-y-5"> - <div> - <Text variant="sectionHeading">Full Name</Text> - <span> - {data.firstName} {data.lastName} - </span> - </div> - <div> - <Text variant="sectionHeading">Email</Text> - <span>{data.email}</span> + <div className="grid lg:grid-cols-12"> + <div className="lg:col-span-8 pr-4"> + <div> + <Text variant="sectionHeading">Full Name</Text> + <span> + {data.firstName} {data.lastName} + </span> + </div> + <div className="mt-5"> + <Text variant="sectionHeading">Email</Text> + <span>{data.email}</span> + </div> </div> </div> )} From 3583a6590aa959df7ef14045ac6436c1b2b87607 Mon Sep 17 00:00:00 2001 From: Martin Bavio <mbavio@gmail.com> Date: Tue, 27 Oct 2020 01:19:47 -0300 Subject: [PATCH 23/23] Make auth modals to have proper forms --- components/auth/ForgotPassword.tsx | 13 +++++++++---- components/auth/LoginView.tsx | 13 +++++++++---- components/auth/SignUpView.tsx | 13 +++++++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/components/auth/ForgotPassword.tsx b/components/auth/ForgotPassword.tsx index 261c171af..597ee328e 100644 --- a/components/auth/ForgotPassword.tsx +++ b/components/auth/ForgotPassword.tsx @@ -15,7 +15,9 @@ const ForgotPassword: FC<Props> = () => { const { setModalView, closeModal } = useUI() - const handleSignup = async () => { + const handleResetPassword = async (e: React.SyntheticEvent<EventTarget>) => { + e.preventDefault() + if (!dirty && !disabled) { setDirty(true) handleValidation() @@ -34,7 +36,10 @@ const ForgotPassword: FC<Props> = () => { }, [handleValidation]) return ( - <div className="w-80 flex flex-col justify-between p-3"> + <form + onSubmit={handleResetPassword} + className="w-80 flex flex-col justify-between p-3" + > <div className="flex justify-center pb-12 "> <Logo width="64px" height="64px" /> </div> @@ -47,7 +52,7 @@ const ForgotPassword: FC<Props> = () => { <div className="pt-2 w-full flex flex-col"> <Button variant="slim" - onClick={() => handleSignup()} + type="submit" loading={loading} disabled={disabled} > @@ -66,7 +71,7 @@ const ForgotPassword: FC<Props> = () => { </a> </span> </div> - </div> + </form> ) } diff --git a/components/auth/LoginView.tsx b/components/auth/LoginView.tsx index 33cb88c21..785d9ab8a 100644 --- a/components/auth/LoginView.tsx +++ b/components/auth/LoginView.tsx @@ -18,7 +18,9 @@ const LoginView: FC<Props> = () => { const login = useLogin() - const handleLogin = async () => { + const handleLogin = async (e: React.SyntheticEvent<EventTarget>) => { + e.preventDefault() + if (!dirty && !disabled) { setDirty(true) handleValidation() @@ -54,7 +56,10 @@ const LoginView: FC<Props> = () => { }, [handleValidation]) return ( - <div className="w-80 flex flex-col justify-between p-3"> + <form + onSubmit={handleLogin} + className="w-80 flex flex-col justify-between p-3" + > <div className="flex justify-center pb-12 "> <Logo width="64px" height="64px" /> </div> @@ -75,7 +80,7 @@ const LoginView: FC<Props> = () => { <Button variant="slim" - onClick={() => handleLogin()} + type="submit" loading={loading} disabled={disabled} > @@ -92,7 +97,7 @@ const LoginView: FC<Props> = () => { </a> </div> </div> - </div> + </form> ) } diff --git a/components/auth/SignUpView.tsx b/components/auth/SignUpView.tsx index f0cfa8458..adc091732 100644 --- a/components/auth/SignUpView.tsx +++ b/components/auth/SignUpView.tsx @@ -21,7 +21,9 @@ const SignUpView: FC<Props> = () => { const signup = useSignup() const { setModalView, closeModal } = useUI() - const handleSignup = async () => { + const handleSignup = async (e: React.SyntheticEvent<EventTarget>) => { + e.preventDefault() + if (!dirty && !disabled) { setDirty(true) handleValidation() @@ -59,7 +61,10 @@ const SignUpView: FC<Props> = () => { }, [handleValidation]) return ( - <div className="w-80 flex flex-col justify-between p-3"> + <form + onSubmit={handleSignup} + className="w-80 flex flex-col justify-between p-3" + > <div className="flex justify-center pb-12 "> <Logo width="64px" height="64px" /> </div> @@ -83,7 +88,7 @@ const SignUpView: FC<Props> = () => { <div className="pt-2 w-full flex flex-col"> <Button variant="slim" - onClick={() => handleSignup()} + type="submit" loading={loading} disabled={disabled} > @@ -102,7 +107,7 @@ const SignUpView: FC<Props> = () => { </a> </span> </div> - </div> + </form> ) }