diff --git a/components/ui/LoadingDots/LoadingDots.tsx b/components/ui/LoadingDots/LoadingDots.tsx index 10e5bbae1..bebe5ef1d 100644 --- a/components/ui/LoadingDots/LoadingDots.tsx +++ b/components/ui/LoadingDots/LoadingDots.tsx @@ -3,9 +3,6 @@ import s from './LoadingDots.module.css' const LoadingDots: React.FC = () => { return ( - - - ) } diff --git a/framework/types.d.ts b/framework/types.d.ts index e5b1ed7c1..6a4baffd1 100644 --- a/framework/types.d.ts +++ b/framework/types.d.ts @@ -131,7 +131,7 @@ interface Cart extends Entity { id: string | undefined currency: { code: string } taxIncluded?: boolean - items: Pick & CartItem[] + items: (Pick & CartItem)[] subTotal: number | string total: number | string customerId: Customer['id'] diff --git a/framework/vendure/README.md b/framework/vendure/README.md index 7beee6c14..37a71f81e 100644 --- a/framework/vendure/README.md +++ b/framework/vendure/README.md @@ -44,11 +44,7 @@ yarn add storefront-data-hooks After install, the first thing you do is: set your environment variables in `.env.local` ```sh -BIGCOMMERCE_STOREFRONT_API_URL=<> -BIGCOMMERCE_STOREFRONT_API_TOKEN=<> -BIGCOMMERCE_STORE_API_URL=<> -BIGCOMMERCE_STORE_API_TOKEN=<> -BIGCOMMERCE_STORE_API_CLIENT_ID=<> +VENDURE_SHOP_API_URL=<> ``` ## General Usage diff --git a/framework/vendure/api/cart/handlers/add-item.ts b/framework/vendure/api/cart/handlers/add-item.ts deleted file mode 100644 index f58a6c43c..000000000 --- a/framework/vendure/api/cart/handlers/add-item.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { parseCartItem } from '../../utils/parse-item' -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -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)], - ...(!cartId && config.storeChannelId - ? { channel_id: config.storeChannelId } - : {}), - }), - } - 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/framework/vendure/api/cart/handlers/get-cart.ts b/framework/vendure/api/cart/handlers/get-cart.ts deleted file mode 100644 index 9fb42d730..000000000 --- a/framework/vendure/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/framework/vendure/api/cart/handlers/remove-item.ts b/framework/vendure/api/cart/handlers/remove-item.ts deleted file mode 100644 index c980cbb42..000000000 --- a/framework/vendure/api/cart/handlers/remove-item.ts +++ /dev/null @@ -1,33 +0,0 @@ -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -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/framework/vendure/api/cart/handlers/update-item.ts b/framework/vendure/api/cart/handlers/update-item.ts deleted file mode 100644 index df9ccaee8..000000000 --- a/framework/vendure/api/cart/handlers/update-item.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { parseCartItem } from '../../utils/parse-item' -import getCartCookie from '../../utils/get-cart-cookie' -import type { CartHandlers } from '..' - -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/framework/vendure/api/cart/index.ts b/framework/vendure/api/cart/index.ts deleted file mode 100644 index 5ff2d975b..000000000 --- a/framework/vendure/api/cart/index.ts +++ /dev/null @@ -1,116 +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' - -type OptionSelections = { - option_id: Number - option_value: Number|String -} - -export type ItemBody = { - productId: number - variantId: number - quantity?: number - optionSelections?: OptionSelections -} - -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/framework/vendure/api/catalog/handlers/get-products.ts b/framework/vendure/api/catalog/handlers/get-products.ts deleted file mode 100644 index 894dc5cf3..000000000 --- a/framework/vendure/api/catalog/handlers/get-products.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { Product } from 'framework/types' -import getAllProducts, { ProductEdge } from '../../../product/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]: Product - }>((prods, p) => { - prods[p.id] = p - return prods - }, {}) - - const products: Product[] = 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/framework/vendure/api/catalog/products.ts b/framework/vendure/api/catalog/products.ts deleted file mode 100644 index fe5b807c6..000000000 --- a/framework/vendure/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 getProducts from './handlers/get-products' -import { Product } from 'framework/types' - -export type SearchProductsData = { - products: Product[] - found: boolean -} - -export type ProductsHandlers = { - getProducts: BigcommerceHandler< - SearchProductsData, - { search?: 'string'; category?: string; brand?: string; sort?: string } - > -} - -const METHODS = ['GET'] - -// TODO(lf): 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/framework/vendure/api/checkout.ts b/framework/vendure/api/checkout.ts deleted file mode 100644 index 530f4c40a..000000000 --- a/framework/vendure/api/checkout.ts +++ /dev/null @@ -1,77 +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) { - res.redirect('/cart') - return - } - - 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/framework/vendure/api/customers/handlers/get-logged-in-customer.ts b/framework/vendure/api/customers/handlers/get-logged-in-customer.ts deleted file mode 100644 index d2c689cd3..000000000 --- a/framework/vendure/api/customers/handlers/get-logged-in-customer.ts +++ /dev/null @@ -1,58 +0,0 @@ -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/framework/vendure/api/customers/handlers/login.ts b/framework/vendure/api/customers/handlers/login.ts deleted file mode 100644 index 9e019f3a0..000000000 --- a/framework/vendure/api/customers/handlers/login.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { FetcherError } from '@commerce/utils/errors' -import login from '../../../auth/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/framework/vendure/api/customers/handlers/logout.ts b/framework/vendure/api/customers/handlers/logout.ts deleted file mode 100644 index 937ce0954..000000000 --- a/framework/vendure/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/framework/vendure/api/customers/handlers/signup.ts b/framework/vendure/api/customers/handlers/signup.ts deleted file mode 100644 index 1b24db0cc..000000000 --- a/framework/vendure/api/customers/handlers/signup.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { BigcommerceApiError } from '../../utils/errors' -import login from '../../../auth/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/framework/vendure/api/customers/index.ts b/framework/vendure/api/customers/index.ts deleted file mode 100644 index 5af4d1d1d..000000000 --- a/framework/vendure/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/framework/vendure/api/customers/login.ts b/framework/vendure/api/customers/login.ts deleted file mode 100644 index e8f24a92d..000000000 --- a/framework/vendure/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/framework/vendure/api/customers/logout.ts b/framework/vendure/api/customers/logout.ts deleted file mode 100644 index 0a4965245..000000000 --- a/framework/vendure/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/framework/vendure/api/customers/signup.ts b/framework/vendure/api/customers/signup.ts deleted file mode 100644 index aa26f78cf..000000000 --- a/framework/vendure/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/framework/vendure/api/definitions/catalog.ts b/framework/vendure/api/definitions/catalog.ts deleted file mode 100644 index 2c483f781..000000000 --- a/framework/vendure/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/framework/vendure/api/definitions/store-content.ts b/framework/vendure/api/definitions/store-content.ts deleted file mode 100644 index f00c28844..000000000 --- a/framework/vendure/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/framework/vendure/api/definitions/wishlist.ts b/framework/vendure/api/definitions/wishlist.ts deleted file mode 100644 index 6ec21c103..000000000 --- a/framework/vendure/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/framework/vendure/api/fragments/cart.ts b/framework/vendure/api/fragments/cart.ts index ed720d24b..ddca79a9a 100644 --- a/framework/vendure/api/fragments/cart.ts +++ b/framework/vendure/api/fragments/cart.ts @@ -8,6 +8,9 @@ export const cartFragment = /* GraphQL */ ` total totalWithTax currencyCode + customer { + id + } lines { id quantity @@ -16,6 +19,7 @@ export const cartFragment = /* GraphQL */ ` preview } productVariant { + id name product { slug diff --git a/framework/vendure/api/fragments/search-result.ts b/framework/vendure/api/fragments/search-result.ts new file mode 100644 index 000000000..5ca6c1522 --- /dev/null +++ b/framework/vendure/api/fragments/search-result.ts @@ -0,0 +1,19 @@ +export const searchResultFragment = /* GraphQL */ ` + fragment SearchResult on SearchResult { + productId + productName + description + description + slug + sku + currencyCode + productAsset { + id + preview + } + priceWithTax { + ... on SinglePrice { value } + ... on PriceRange { min max } + } + } +` diff --git a/framework/vendure/api/index.ts b/framework/vendure/api/index.ts index 653fa379c..4bd6aaace 100644 --- a/framework/vendure/api/index.ts +++ b/framework/vendure/api/index.ts @@ -1,7 +1,5 @@ -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 VendureConfig extends CommerceAPIConfig {} diff --git a/framework/vendure/api/utils/create-api-handler.ts b/framework/vendure/api/utils/create-api-handler.ts deleted file mode 100644 index dee29d60c..000000000 --- a/framework/vendure/api/utils/create-api-handler.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next' -import { VendureConfig, getConfig } from '..' - -export type BigcommerceApiHandler< - T = any, - H extends BigcommerceHandlers = {}, - Options extends {} = {} -> = ( - req: NextApiRequest, - res: NextApiResponse<BigcommerceApiResponse<T>>, - config: VendureConfig, - 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: VendureConfig - 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?: VendureConfig - 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/framework/vendure/api/utils/errors.ts b/framework/vendure/api/utils/errors.ts deleted file mode 100644 index 77e2007fc..000000000 --- a/framework/vendure/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/framework/vendure/api/utils/fetch-graphql-api.ts b/framework/vendure/api/utils/fetch-graphql-api.ts index ff0ab6e71..63c573840 100644 --- a/framework/vendure/api/utils/fetch-graphql-api.ts +++ b/framework/vendure/api/utils/fetch-graphql-api.ts @@ -27,7 +27,7 @@ const fetchGraphqlApi: GraphQLFetcher = async ( const json = await res.json() if (json.errors) { throw new FetcherError({ - errors: json.errors ?? [{ message: 'Failed to fetch Bigcommerce API' }], + errors: json.errors ?? [{ message: 'Failed to fetch Vendure API' }], status: res.status, }) } diff --git a/framework/vendure/api/utils/fetch-store-api.ts b/framework/vendure/api/utils/fetch-store-api.ts deleted file mode 100644 index 7e59b9f06..000000000 --- a/framework/vendure/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/framework/vendure/api/utils/filter-edges.ts b/framework/vendure/api/utils/filter-edges.ts deleted file mode 100644 index 09cd20640..000000000 --- a/framework/vendure/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/framework/vendure/api/utils/get-cart-cookie.ts b/framework/vendure/api/utils/get-cart-cookie.ts deleted file mode 100644 index 7ca6cd5e4..000000000 --- a/framework/vendure/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/framework/vendure/api/utils/is-allowed-method.ts b/framework/vendure/api/utils/is-allowed-method.ts deleted file mode 100644 index 78bbba568..000000000 --- a/framework/vendure/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/framework/vendure/api/utils/parse-item.ts b/framework/vendure/api/utils/parse-item.ts deleted file mode 100644 index 132f269f6..000000000 --- a/framework/vendure/api/utils/parse-item.ts +++ /dev/null @@ -1,14 +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, - option_selections: item.optionSelections -}) diff --git a/framework/vendure/api/utils/set-product-locale-meta.ts b/framework/vendure/api/utils/set-product-locale-meta.ts deleted file mode 100644 index 974a197bd..000000000 --- a/framework/vendure/api/utils/set-product-locale-meta.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ProductNode } from '../../product/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/framework/vendure/api/utils/types.ts b/framework/vendure/api/utils/types.ts deleted file mode 100644 index 56f9c1728..000000000 --- a/framework/vendure/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/framework/vendure/api/wishlist/handlers/add-item.ts b/framework/vendure/api/wishlist/handlers/add-item.ts deleted file mode 100644 index 00d7b06bd..000000000 --- a/framework/vendure/api/wishlist/handlers/add-item.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { WishlistHandlers } from '..' -import getCustomerId from '../../../customer/get-customer-id' -import getCustomerWishlist from '../../../customer/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/framework/vendure/api/wishlist/handlers/get-wishlist.ts b/framework/vendure/api/wishlist/handlers/get-wishlist.ts deleted file mode 100644 index 3737c033a..000000000 --- a/framework/vendure/api/wishlist/handlers/get-wishlist.ts +++ /dev/null @@ -1,37 +0,0 @@ -import getCustomerId from '../../../customer/get-customer-id' -import getCustomerWishlist from '../../../customer/get-customer-wishlist' -import type { Wishlist, WishlistHandlers } from '..' - -// Return wishlist info -const getWishlist: WishlistHandlers['getWishlist'] = async ({ - res, - body: { customerToken, includeProducts }, - 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 }, - includeProducts, - config, - }) - - result = { data: wishlist } - } - - res.status(200).json({ data: result.data ?? null }) -} - -export default getWishlist diff --git a/framework/vendure/api/wishlist/handlers/remove-item.ts b/framework/vendure/api/wishlist/handlers/remove-item.ts deleted file mode 100644 index a9cfd9db5..000000000 --- a/framework/vendure/api/wishlist/handlers/remove-item.ts +++ /dev/null @@ -1,39 +0,0 @@ -import getCustomerId from '../../../customer/get-customer-id' -import getCustomerWishlist, { - Wishlist, -} from '../../../customer/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/framework/vendure/api/wishlist/index.ts b/framework/vendure/api/wishlist/index.ts deleted file mode 100644 index e892d2e78..000000000 --- a/framework/vendure/api/wishlist/index.ts +++ /dev/null @@ -1,103 +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 { - Wishlist, - WishlistItem, -} from '../../customer/get-customer-wishlist' -import getWishlist from './handlers/get-wishlist' -import addItem from './handlers/add-item' -import removeItem from './handlers/remove-item' - -export type { Wishlist, WishlistItem } - -export type ItemBody = { - productId: Product['id'] - variantId: ProductVariant['id'] -} - -export type AddItemBody = { item: ItemBody } - -export type RemoveItemBody = { itemId: Product['id'] } - -export type WishlistBody = { - customer_id: Customer['id'] - is_public: number - name: string - items: any[] -} - -export type AddWishlistBody = { wishlist: WishlistBody } - -export type WishlistHandlers = { - getWishlist: BigcommerceHandler< - Wishlist, - { customerToken?: string; includeProducts?: boolean } - > - 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, - includeProducts: req.query.products === '1', - } - 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/framework/vendure/auth/login.ts b/framework/vendure/auth/login.ts index 25119757b..ab2c0db00 100644 --- a/framework/vendure/auth/login.ts +++ b/framework/vendure/auth/login.ts @@ -6,8 +6,10 @@ import { VendureConfig, getConfig } from '../api' export const loginMutation = /* GraphQL */ ` mutation login($email: String!, $password: String!) { - login(email: $email, password: $password) { - result + login(username: $email, password: $password) { + ...on CurrentUser { + id + } } } ` diff --git a/framework/vendure/cart/use-add-item.tsx b/framework/vendure/cart/use-add-item.tsx index fe889be7e..3ca93020f 100644 --- a/framework/vendure/cart/use-add-item.tsx +++ b/framework/vendure/cart/use-add-item.tsx @@ -5,6 +5,7 @@ import useCartAddItem from '@commerce/cart/use-add-item' import useCart from './use-cart' import { useCallback } from 'react' import { cartFragment } from '../api/fragments/cart' +import { AddItemToOrderMutation, AddItemToOrderMutationVariables } from '@framework/schema' export const addItemToOrderMutation = /* GraphQL */ ` mutation addItemToOrder($variantId: ID!, $quantity: Int!) { @@ -17,7 +18,7 @@ export const addItemToOrderMutation = /* GraphQL */ ` export type AddItemInput = { productId?: number; variantId: number; quantity?: number; }; -export const fetcher: HookFetcher<Cart, AddItemInput> = ( +export const fetcher: HookFetcher<AddItemToOrderMutation, AddItemToOrderMutationVariables> = ( options, { variantId, quantity }, fetch @@ -48,7 +49,7 @@ export function extendHook(customFetcher: typeof fetcher) { return useCallback( async function addItem(input: AddItemInput) { - const data = await fn({ quantity: input.quantity, variantId: input.variantId }) + const data = await fn({ quantity: input.quantity || 1, variantId: input.variantId }) await mutate(data, false) return data }, diff --git a/framework/vendure/cart/use-cart.tsx b/framework/vendure/cart/use-cart.tsx index 1f0c72bd5..8372c8d69 100644 --- a/framework/vendure/cart/use-cart.tsx +++ b/framework/vendure/cart/use-cart.tsx @@ -1,12 +1,9 @@ -import fetchGraphqlApi from '@framework/api/utils/fetch-graphql-api' import { HookFetcher } from '@commerce/utils/types' import useData, { SwrOptions } from '@commerce/utils/use-data' -import useCommerceCart, { CartInput } from '@commerce/cart/use-cart' import useResponse from '@commerce/utils/use-response' -import useAction from '@commerce/utils/use-action' -import { useCallback } from 'react' -import { normalizeCart } from '../../bigcommerce/lib/normalize' import { cartFragment } from '../api/fragments/cart' +import { CartFragment } from '../schema' +import { normalizeCart } from '@framework/lib/normalize' export const getCartQuery = /* GraphQL */ ` query activeOrder { @@ -17,7 +14,7 @@ export const getCartQuery = /* GraphQL */ ` ${cartFragment} ` -export const fetcher: HookFetcher<any | null> = ( +export const fetcher: HookFetcher<any, null> = ( options, input, fetch @@ -25,30 +22,23 @@ export const fetcher: HookFetcher<any | null> = ( return fetch({ ...options, query: getCartQuery }) } +export type CartResult = { + activeOrder?: CartFragment; + addItemToOrder?: CartFragment; + adjustOrderLine?: CartFragment; + removeOrderLine?: CartFragment; +} + export function extendHook( customFetcher: typeof fetcher, swrOptions?: SwrOptions<any | null> ) { const useCart = () => { - const response = useData({ query: getCartQuery }, [], customFetcher, swrOptions) + const response = useData<CartResult>({ query: getCartQuery }, [], customFetcher, swrOptions) const res = useResponse(response, { normalizer: (data => { const order = data?.activeOrder || data?.addItemToOrder || data?.adjustOrderLine || data?.removeOrderLine; - return (order ? { - id: order.id, - currency: { code: order.currencyCode }, - subTotal: order.subTotalWithTax / 100, - total: order.totalWithTax / 100, - items: order.lines?.map(l => ({ - id: l.id, - name: l.productVariant.name, - quantity: l.quantity, - url: l.productVariant.product.slug, - variantId: l.productVariant.id, - productId: l.productVariant.productId, - images: [{ url: l.featuredAsset?.preview }] - })) - } : null) + return (order ? normalizeCart(order) : null) }), descriptors: { isEmpty: { diff --git a/framework/vendure/cart/use-remove-item.tsx b/framework/vendure/cart/use-remove-item.tsx index 16483954f..0ddff2077 100644 --- a/framework/vendure/cart/use-remove-item.tsx +++ b/framework/vendure/cart/use-remove-item.tsx @@ -1,43 +1,47 @@ import { useCallback } from 'react' import { HookFetcher } from '@commerce/utils/types' import useCartRemoveItem from '@commerce/cart/use-remove-item' -import useCart, { Cart } from './use-cart' +import useCart from './use-cart' import { cartFragment } from '@framework/api/fragments/cart' +import { RemoveOrderLineMutation, RemoveOrderLineMutationVariables } from '@framework/schema' export const removeOrderLineMutation = /* GraphQL */ ` mutation removeOrderLine($orderLineId: ID!) { removeOrderLine(orderLineId: $orderLineId) { + __typename ...Cart } } ${cartFragment} ` -export const fetcher: HookFetcher<Cart | null, any> = ( +export const fetcher: HookFetcher<RemoveOrderLineMutation, RemoveOrderLineMutationVariables> = ( options, - { lineId }, + { orderLineId }, fetch ) => { return fetch({ ...options, query: removeOrderLineMutation, - variables: { orderLineId: lineId }, + variables: { orderLineId }, }) } export function extendHook(customFetcher: typeof fetcher) { const useRemoveItem = (item?: any) => { const { mutate } = useCart() - const fn = useCartRemoveItem<Cart | null, any>( + const fn = useCartRemoveItem<RemoveOrderLineMutation, RemoveOrderLineMutationVariables>( {}, customFetcher ) return useCallback( async function removeItem(input: any) { - const data = await fn({ lineId: input.id }) - await mutate(data, false) - return data + const { removeOrderLine } = await fn({ orderLineId: input.id }) + if (removeOrderLine.__typename === 'Order') { + await mutate({ removeOrderLine }, false) + } + return { removeOrderLine } }, [fn, mutate] ) diff --git a/framework/vendure/cart/use-update-item.tsx b/framework/vendure/cart/use-update-item.tsx index fc42da311..a768c21e4 100644 --- a/framework/vendure/cart/use-update-item.tsx +++ b/framework/vendure/cart/use-update-item.tsx @@ -2,8 +2,9 @@ import { useCallback } from 'react' import debounce from 'lodash.debounce' import type { HookFetcher } from '@commerce/utils/types' import useCartUpdateItem from '@commerce/cart/use-update-item' -import useCart, { Cart } from './use-cart' +import useCart from './use-cart' import { cartFragment } from '@framework/api/fragments/cart' +import { AdjustOrderLineMutation, AdjustOrderLineMutationVariables } from '@framework/schema' export const adjustOrderLineMutation = /* GraphQL */ ` mutation adjustOrderLine($orderLineId: ID!, $quantity: Int!) { @@ -13,34 +14,36 @@ export const adjustOrderLineMutation = /* GraphQL */ ` } ${cartFragment} ` -export const fetcher: HookFetcher<Cart | null, any> = ( +export const fetcher: HookFetcher<AdjustOrderLineMutation, AdjustOrderLineMutationVariables> = ( options, - { lineId, quantity }, + { orderLineId, quantity }, fetch ) => { return fetch({ ...options, query: adjustOrderLineMutation, - variables: { orderLineId: lineId, quantity }, + variables: { orderLineId, quantity }, }) } function extendHook(customFetcher: typeof fetcher, cfg?: { wait?: number }) { const useUpdateItem = (item?: any) => { const { mutate } = useCart() - const fn = useCartUpdateItem<Cart | null, any>( + const fn = useCartUpdateItem<AdjustOrderLineMutation, AdjustOrderLineMutationVariables>( {}, customFetcher ) return useCallback( debounce(async (input: any) => { - const data = await fn({ - lineId: item.id, + const { adjustOrderLine } = await fn({ + orderLineId: item.id, quantity: input.quantity, }) - await mutate(data, false) - return data + if (adjustOrderLine.__typename === 'Order') { + await mutate({ adjustOrderLine }, false) + } + return { adjustOrderLine } }, cfg?.wait ?? 500), [fn, mutate] ) diff --git a/framework/vendure/codegen.json b/framework/vendure/codegen.json index f4d3b798c..5efb16912 100644 --- a/framework/vendure/codegen.json +++ b/framework/vendure/codegen.json @@ -2,11 +2,24 @@ "schema": { "http://localhost:3001/shop-api": {} }, + "documents": [ + { + "./framework/vendure/**/*.{ts,tsx}": { + "noRequire": true + } + } + ], "generates": { "./framework/vendure/schema.d.ts": { "plugins": [ - "typescript" - ] + "typescript", + "typescript-operations" + ], + "config": { + "scalars": { + "ID": "number" + } + } }, "./framework/vendure/schema.graphql": { "plugins": [ diff --git a/framework/vendure/common/get-all-pages.ts b/framework/vendure/common/get-all-pages.ts index 37018e2a8..1611846c5 100644 --- a/framework/vendure/common/get-all-pages.ts +++ b/framework/vendure/common/get-all-pages.ts @@ -1,8 +1,6 @@ -import type { RecursivePartial, RecursiveRequired } from '../api/utils/types' -import { VendureConfig, getConfig } from '../api' -import { definitions } from '../api/definitions/store-content' +import { getConfig, VendureConfig } from '../api' -export type Page = definitions['page_Full'] +export type Page = any; export type GetAllPagesResult< T extends { pages: any[] } = { pages: Page[] } diff --git a/framework/vendure/common/get-page.ts b/framework/vendure/common/get-page.ts index 32ce4dadd..310fff50e 100644 --- a/framework/vendure/common/get-page.ts +++ b/framework/vendure/common/get-page.ts @@ -1,8 +1,6 @@ -import type { RecursivePartial, RecursiveRequired } from '../api/utils/types' import { VendureConfig, getConfig } from '../api' -import { definitions } from '../api/definitions/store-content' -export type Page = definitions['page_Full'] +export type Page = any; export type GetPageResult<T extends { page?: any } = { page?: Page }> = T @@ -36,17 +34,6 @@ async function getPage({ 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 {} } diff --git a/framework/vendure/common/get-site-info.ts b/framework/vendure/common/get-site-info.ts index 579814abc..c297ecad7 100644 --- a/framework/vendure/common/get-site-info.ts +++ b/framework/vendure/common/get-site-info.ts @@ -1,6 +1,6 @@ -import type { RecursivePartial, RecursiveRequired } from '../api/utils/types' -import filterEdges from '../api/utils/filter-edges' import { VendureConfig, getConfig } from '../api' +import { GetCollectionsQuery } from '@framework/schema' +import { arrayToTree } from '@framework/lib/array-to-tree'; export const getCollectionsQuery = /* GraphQL */ ` query getCollections { @@ -37,81 +37,23 @@ async function getSiteInfo({ 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<any>( + const { data } = await config.fetch<GetCollectionsQuery>( query, { variables } ) const categories = arrayToTree(data.collections?.items.map(i => ({ ...i, entityId: i.id, - name: i.name, path: i.slug, - description: i.description, productCount: i.productVariants.totalItems, }))).children; - const brands = data.site?.brands?.edges + const brands = [] as any[]; return { - categories: (categories as RecursiveRequired<typeof categories>) ?? [], - brands: [], + categories: categories ?? [], + brands, } } export default getSiteInfo -export type HasParent = { id: string; parent?: { id: string } | null }; -export type TreeNode<T extends HasParent> = T & { children: Array<TreeNode<T>>; expanded: boolean }; -export type RootNode<T extends HasParent> = { id?: string; children: Array<TreeNode<T>> }; - -export function arrayToTree<T extends HasParent>(nodes: T[], currentState?: RootNode<T>): RootNode<T> { - const topLevelNodes: Array<TreeNode<T>> = []; - const mappedArr: { [id: string]: TreeNode<T> } = {}; - const currentStateMap = treeToMap(currentState); - - // First map the nodes of the array to an object -> create a hash table. - for (const node of nodes) { - mappedArr[node.id] = { ...(node as any), children: [] }; - } - - for (const id of nodes.map(n => n.id)) { - if (mappedArr.hasOwnProperty(id)) { - const mappedElem = mappedArr[id]; - mappedElem.expanded = currentStateMap.get(id)?.expanded ?? false; - const parent = mappedElem.parent; - if (!parent) { - continue; - } - // If the element is not at the root level, add it to its parent array of children. - const parentIsRoot = !mappedArr[parent.id]; - if (!parentIsRoot) { - if (mappedArr[parent.id]) { - mappedArr[parent.id].children.push(mappedElem); - } else { - mappedArr[parent.id] = { children: [mappedElem] } as any; - } - } else { - topLevelNodes.push(mappedElem); - } - } - } - // tslint:disable-next-line:no-non-null-assertion - const rootId = topLevelNodes.length ? topLevelNodes[0].parent!.id : undefined; - return { id: rootId, children: topLevelNodes }; -} - -/** - * Converts an existing tree (as generated by the arrayToTree function) into a flat - * Map. This is used to persist certain states (e.g. `expanded`) when re-building the - * tree. - */ -function treeToMap<T extends HasParent>(tree?: RootNode<T>): Map<string, TreeNode<T>> { - const nodeMap = new Map<string, TreeNode<T>>(); - function visit(node: TreeNode<T>) { - nodeMap.set(node.id, node); - node.children.forEach(visit); - } - if (tree) { - visit(tree as TreeNode<T>); - } - return nodeMap; -} diff --git a/framework/vendure/customer/get-customer-id.ts b/framework/vendure/customer/get-customer-id.ts index d8a15af85..9fb5f6eea 100644 --- a/framework/vendure/customer/get-customer-id.ts +++ b/framework/vendure/customer/get-customer-id.ts @@ -1,7 +1,7 @@ import { GetCustomerIdQuery } from '../schema' import { VendureConfig, getConfig } from '../api' -export const getCustomerIdQuery = /* GraphQL */ ` +export const getCustomerIdQuery = /* */ ` query getCustomerId { customer { entityId diff --git a/framework/vendure/lib/array-to-tree.ts b/framework/vendure/lib/array-to-tree.ts new file mode 100644 index 000000000..a2f15c2b9 --- /dev/null +++ b/framework/vendure/lib/array-to-tree.ts @@ -0,0 +1,56 @@ +export type HasParent = { id: number; parent?: { id: number } | null }; +export type TreeNode<T extends HasParent> = T & { children: Array<TreeNode<T>>; expanded: boolean }; +export type RootNode<T extends HasParent> = { id?: number; children: Array<TreeNode<T>> }; + +export function arrayToTree<T extends HasParent>(nodes: T[], currentState?: RootNode<T>): RootNode<T> { + const topLevelNodes: Array<TreeNode<T>> = []; + const mappedArr: { [id: string]: TreeNode<T> } = {}; + const currentStateMap = treeToMap(currentState); + + // First map the nodes of the array to an object -> create a hash table. + for (const node of nodes) { + mappedArr[node.id] = { ...(node as any), children: [] }; + } + + for (const id of nodes.map(n => n.id)) { + if (mappedArr.hasOwnProperty(id)) { + const mappedElem = mappedArr[id]; + mappedElem.expanded = currentStateMap.get(id)?.expanded ?? false; + const parent = mappedElem.parent; + if (!parent) { + continue; + } + // If the element is not at the root level, add it to its parent array of children. + const parentIsRoot = !mappedArr[parent.id]; + if (!parentIsRoot) { + if (mappedArr[parent.id]) { + mappedArr[parent.id].children.push(mappedElem); + } else { + mappedArr[parent.id] = { children: [mappedElem] } as any; + } + } else { + topLevelNodes.push(mappedElem); + } + } + } + // tslint:disable-next-line:no-non-null-assertion + const rootId = topLevelNodes.length ? topLevelNodes[0].parent!.id : undefined; + return { id: rootId, children: topLevelNodes }; +} + +/** + * Converts an existing tree (as generated by the arrayToTree function) into a flat + * Map. This is used to persist certain states (e.g. `expanded`) when re-building the + * tree. + */ +function treeToMap<T extends HasParent>(tree?: RootNode<T>): Map<number, TreeNode<T>> { + const nodeMap = new Map<number, TreeNode<T>>(); + function visit(node: TreeNode<T>) { + nodeMap.set(node.id, node); + node.children.forEach(visit); + } + if (tree) { + visit(tree as TreeNode<T>); + } + return nodeMap; +} diff --git a/framework/vendure/lib/normalize.ts b/framework/vendure/lib/normalize.ts index bbce17214..2268f36e1 100644 --- a/framework/vendure/lib/normalize.ts +++ b/framework/vendure/lib/normalize.ts @@ -1,4 +1,5 @@ import update from '@framework/lib/immutability' +import { CartFragment, SearchResultFragment } from '@framework/schema' function normalizeProductOption(productOption: any) { const { @@ -60,59 +61,47 @@ export function normalizeProduct(productNode: any): Product { price: { $set: { value: prices?.price.value, - currencyCode: prices?.price.currencyCode, - }, + currencyCode: prices?.price.currencyCode + } }, - $unset: ['entityId'], + $unset: ['entityId'] }) } -export function normalizeCart(data: any): Cart { - return update(data, { - $auto: { - items: { $set: data?.line_items?.physical_items?.map(itemsToProducts) }, - subTotal: { $set: data?.base_amount }, - total: { $set: data?.cart_amount }, +export function normalizeSearchResult(item: SearchResultFragment): Product { + return { + id: item.productId, + name: item.productName, + description: item.description, + slug: item.slug, + path: item.slug, + images: [{ url: item.productAsset?.preview || '' }], + variants: [], + price: { + value: ((item.priceWithTax as any).min / 100), + currencyCode: item.currencyCode }, - $unset: ['created_time', 'coupons', 'line_items', 'email'], - }) + options: [], + sku: item.sku + } } -function itemsToProducts(item: any): CartItem { - const { - id, - name, - quantity, - product_id, - variant_id, - image_url, - list_price, - sale_price, - extended_list_price, - extended_sale_price, - ...rest - } = item - - return update(item, { - $auto: { - prices: { - $auto: { - listPrice: { $set: list_price }, - salePrice: { $set: sale_price }, - extendedListPrice: { $set: extended_list_price }, - extendedSalePrice: { $set: extended_sale_price }, - }, - }, - images: { - $set: [ - { - alt: name, - url: image_url, - }, - ], - }, - productId: { $set: product_id }, - variantId: { $set: variant_id }, - }, - }) +export function normalizeCart(order: CartFragment): Cart { + return { + id: order.id.toString(), + currency: { code: order.currencyCode }, + subTotal: order.subTotalWithTax / 100, + total: order.totalWithTax / 100, + customerId: order.customer?.id as number, + items: order.lines?.map(l => ({ + id: l.id, + name: l.productVariant.name, + quantity: l.quantity, + url: l.productVariant.product.slug, + variantId: l.productVariant.id, + productId: l.productVariant.productId, + images: [{ url: l.featuredAsset?.preview || '' }], + prices: [] + })) + } } diff --git a/framework/vendure/product/get-all-product-paths.ts b/framework/vendure/product/get-all-product-paths.ts index b320e9295..54d9e865c 100644 --- a/framework/vendure/product/get-all-product-paths.ts +++ b/framework/vendure/product/get-all-product-paths.ts @@ -2,8 +2,6 @@ import type { GetAllProductPathsQuery, GetAllProductPathsQueryVariables, } from '../schema' -import type { RecursivePartial, RecursiveRequired } from '../api/utils/types' -import filterEdges from '../api/utils/filter-edges' import { VendureConfig, getConfig } from '../api' export const getAllProductPathsQuery = /* GraphQL */ ` @@ -16,17 +14,7 @@ export const getAllProductPathsQuery = /* GraphQL */ ` } ` -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 +export type GetAllProductPathsResult = { products: Array<{ node: { path: string; } }> }; async function getAllProductPaths(opts?: { variables?: GetAllProductPathsQueryVariables @@ -40,7 +28,7 @@ async function getAllProductPaths< query: string variables?: V config?: VendureConfig -}): Promise<GetAllProductPathsResult<T>> +}): Promise<GetAllProductPathsResult> async function getAllProductPaths({ query = getAllProductPathsQuery, @@ -54,9 +42,7 @@ async function getAllProductPaths({ 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 { data } = await config.fetch<GetAllProductPathsQuery>(query, { variables }) const products = data.products.items return { diff --git a/framework/vendure/product/get-all-products.ts b/framework/vendure/product/get-all-products.ts index dfb1255b4..48e536fdb 100644 --- a/framework/vendure/product/get-all-products.ts +++ b/framework/vendure/product/get-all-products.ts @@ -1,9 +1,7 @@ -import type { RecursivePartial, RecursiveRequired } from '../api/utils/types' -import filterEdges from '../api/utils/filter-edges' -import setProductLocaleMeta from '../api/utils/set-product-locale-meta' -import { productConnectionFragment } from '../api/fragments/product' -import { VendureConfig, getConfig } from '../api' -import { normalizeProduct } from '../lib/normalize' +import { getConfig, VendureConfig } from '../api' +import { searchResultFragment } from '@framework/api/fragments/search-result' +import { GetAllProductsQuery } from '@framework/schema' +import { normalizeSearchResult } from '@framework/lib/normalize' export const getAllProductsQuery = /* GraphQL */ ` query getAllProducts( @@ -11,24 +9,11 @@ export const getAllProductsQuery = /* GraphQL */ ` ) { search(input: $input) { items { - productId - productName - description - description - slug - sku - currencyCode - productAsset { - id - preview - } - priceWithTax { - ... on SinglePrice { value } - ... on PriceRange { min max } - } + ...SearchResult } } } + ${searchResultFragment} ` export type ProductVariables = { first?: number; } @@ -53,31 +38,17 @@ async function getAllProducts({ const variables = { input: { take: vars.first, - groupByProduct: true, + groupByProduct: true } } - const { data } = await config.fetch( + const { data } = await config.fetch<GetAllProductsQuery>( query, { variables } ) - return { products: data.search.items.map((item: any) => { - return { - id: item.productId, - name: item.productName, - description: item.description, - slug: item.slug, - path: item.slug, - images: [{ url: item.productAsset?.preview }], - variants: [], - price: { - value: (item.priceWithTax.min / 100), - currencyCode: item.currencyCode, - }, - options: [], - sku: item.sku, - } - }) } + return { + products: data.search.items.map(item => normalizeSearchResult(item)) + } } export default getAllProducts diff --git a/framework/vendure/product/get-product.ts b/framework/vendure/product/get-product.ts index efc76ef7e..e72bba630 100644 --- a/framework/vendure/product/get-product.ts +++ b/framework/vendure/product/get-product.ts @@ -1,7 +1,4 @@ -import setProductLocaleMeta from '../api/utils/set-product-locale-meta' -import { productInfoFragment } from '../api/fragments/product' -import { VendureConfig, getConfig } from '../api' -import { normalizeProduct } from '@framework/lib/normalize' +import { getConfig, VendureConfig } from '../api' export const getProductQuery = /* GraphQL */ ` query getProduct($slug: String!) { diff --git a/framework/vendure/product/use-search.tsx b/framework/vendure/product/use-search.tsx index 961f4335b..b3ad5bb76 100644 --- a/framework/vendure/product/use-search.tsx +++ b/framework/vendure/product/use-search.tsx @@ -1,33 +1,21 @@ 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' import useResponse from '@commerce/utils/use-response' +import { searchResultFragment } from '@framework/api/fragments/search-result' +import { SearchQuery } from '@framework/schema' +import { normalizeSearchResult } from '@framework/lib/normalize' export const searchQuery = /* GraphQL */ ` query search($input: SearchInput!) { search(input: $input) { items { - productId - currencyCode - productName - description - priceWithTax { - ...on SinglePrice { - value - } - ...on PriceRange { - min max - } - } - productAsset { - preview - } - slug + ...SearchResult } totalItems } } + ${searchResultFragment} ` export type SearchProductsInput = { @@ -37,7 +25,7 @@ export type SearchProductsInput = { sort?: string } -export const fetcher: HookFetcher<SearchProductsData, SearchProductsInput> = ( +export const fetcher: HookFetcher<SearchQuery, SearchProductsInput> = ( options, { search, categoryId, brandId, sort }, fetch @@ -59,7 +47,7 @@ export function extendHook( swrOptions?: SwrOptions<any, SearchProductsInput> ) { const useSearch = (input: SearchProductsInput = {}) => { - const response = useCommerceSearch( + const response = useCommerceSearch<SearchQuery, SearchProductsInput>( {}, [ ['search', input.search], @@ -74,22 +62,8 @@ export function extendHook( return useResponse(response, { normalizer: data => { return { - found: data?.search.totalItems > 0, - products: data?.search.items.map((item: any) => ({ - id: item.productId, - name: item.productName, - description: item.description, - slug: item.slug, - path: item.slug, - images: [{ url: item.productAsset?.preview }], - variants: [], - price: { - value: (item.priceWithTax.min / 100), - currencyCode: item.currencyCode - }, - options: [], - sku: item.sku - })) ?? [], + found: data?.search.totalItems && data?.search.totalItems > 0, + products: data?.search.items.map(item => normalizeSearchResult(item)) ?? [] } } }) diff --git a/framework/vendure/schema.d.ts b/framework/vendure/schema.d.ts index 8d8594cab..756f7d824 100644 --- a/framework/vendure/schema.d.ts +++ b/framework/vendure/schema.d.ts @@ -8,7 +8,7 @@ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> } /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: string + ID: number String: string Boolean: boolean Int: number @@ -2795,3 +2795,193 @@ export type NativeAuthInput = { username: Scalars['String'] password: Scalars['String'] } + +export type CartFragment = { __typename?: 'Order' } & Pick< + Order, + | 'id' + | 'code' + | 'totalQuantity' + | 'subTotal' + | 'subTotalWithTax' + | 'total' + | 'totalWithTax' + | 'currencyCode' +> & { + customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>> + lines: Array< + { __typename?: 'OrderLine' } & Pick<OrderLine, 'id' | 'quantity'> & { + featuredAsset?: Maybe< + { __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview'> + > + productVariant: { __typename?: 'ProductVariant' } & Pick< + ProductVariant, + 'id' | 'name' | 'productId' + > & { product: { __typename?: 'Product' } & Pick<Product, 'slug'> } + } + > + } + +export type SearchResultFragment = { __typename?: 'SearchResult' } & Pick< + SearchResult, + 'productId' | 'productName' | 'description' | 'slug' | 'sku' | 'currencyCode' +> & { + productAsset?: Maybe< + { __typename?: 'SearchResultAsset' } & Pick< + SearchResultAsset, + 'id' | 'preview' + > + > + priceWithTax: + | ({ __typename?: 'PriceRange' } & Pick<PriceRange, 'min' | 'max'>) + | ({ __typename?: 'SinglePrice' } & Pick<SinglePrice, 'value'>) + } + +export type LoginMutationVariables = Exact<{ + email: Scalars['String'] + password: Scalars['String'] +}> + +export type LoginMutation = { __typename?: 'Mutation' } & { + login: + | ({ __typename?: 'CurrentUser' } & Pick<CurrentUser, 'id'>) + | { __typename?: 'InvalidCredentialsError' } + | { __typename?: 'NotVerifiedError' } + | { __typename?: 'NativeAuthStrategyError' } +} + +export type AddItemToOrderMutationVariables = Exact<{ + variantId: Scalars['ID'] + quantity: Scalars['Int'] +}> + +export type AddItemToOrderMutation = { __typename?: 'Mutation' } & { + addItemToOrder: + | ({ __typename?: 'Order' } & CartFragment) + | { __typename?: 'OrderModificationError' } + | { __typename?: 'OrderLimitError' } + | { __typename?: 'NegativeQuantityError' } + | { __typename?: 'InsufficientStockError' } +} + +export type ActiveOrderQueryVariables = Exact<{ [key: string]: never }> + +export type ActiveOrderQuery = { __typename?: 'Query' } & { + activeOrder?: Maybe<{ __typename?: 'Order' } & CartFragment> +} + +export type RemoveOrderLineMutationVariables = Exact<{ + orderLineId: Scalars['ID'] +}> + +export type RemoveOrderLineMutation = { __typename?: 'Mutation' } & { + removeOrderLine: + | ({ __typename: 'Order' } & CartFragment) + | { __typename: 'OrderModificationError' } +} + +export type AdjustOrderLineMutationVariables = Exact<{ + orderLineId: Scalars['ID'] + quantity: Scalars['Int'] +}> + +export type AdjustOrderLineMutation = { __typename?: 'Mutation' } & { + adjustOrderLine: + | ({ __typename?: 'Order' } & CartFragment) + | { __typename?: 'OrderModificationError' } + | { __typename?: 'OrderLimitError' } + | { __typename?: 'NegativeQuantityError' } + | { __typename?: 'InsufficientStockError' } +} + +export type GetCollectionsQueryVariables = Exact<{ [key: string]: never }> + +export type GetCollectionsQuery = { __typename?: 'Query' } & { + collections: { __typename?: 'CollectionList' } & { + items: Array< + { __typename?: 'Collection' } & Pick< + Collection, + 'id' | 'name' | 'description' | 'slug' + > & { + productVariants: { __typename?: 'ProductVariantList' } & Pick< + ProductVariantList, + 'totalItems' + > + parent?: Maybe<{ __typename?: 'Collection' } & Pick<Collection, 'id'>> + children?: Maybe< + Array<{ __typename?: 'Collection' } & Pick<Collection, 'id'>> + > + } + > + } +} + +export type GetAllProductPathsQueryVariables = Exact<{ + first?: Maybe<Scalars['Int']> +}> + +export type GetAllProductPathsQuery = { __typename?: 'Query' } & { + products: { __typename?: 'ProductList' } & { + items: Array<{ __typename?: 'Product' } & Pick<Product, 'slug'>> + } +} + +export type GetAllProductsQueryVariables = Exact<{ + input: SearchInput +}> + +export type GetAllProductsQuery = { __typename?: 'Query' } & { + search: { __typename?: 'SearchResponse' } & { + items: Array<{ __typename?: 'SearchResult' } & SearchResultFragment> + } +} + +export type GetProductQueryVariables = Exact<{ + slug: Scalars['String'] +}> + +export type GetProductQuery = { __typename?: 'Query' } & { + product?: Maybe< + { __typename?: 'Product' } & Pick< + Product, + 'id' | 'name' | 'slug' | 'description' + > & { + assets: Array< + { __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview' | 'name'> + > + variants: Array< + { __typename?: 'ProductVariant' } & Pick< + ProductVariant, + 'id' | 'priceWithTax' | 'currencyCode' + > & { + options: Array< + { __typename?: 'ProductOption' } & Pick< + ProductOption, + 'id' | 'name' | 'code' | 'groupId' + > + > + } + > + optionGroups: Array< + { __typename?: 'ProductOptionGroup' } & Pick< + ProductOptionGroup, + 'code' | 'name' + > & { + options: Array< + { __typename?: 'ProductOption' } & Pick<ProductOption, 'name'> + > + } + > + } + > +} + +export type SearchQueryVariables = Exact<{ + input: SearchInput +}> + +export type SearchQuery = { __typename?: 'Query' } & { + search: { __typename?: 'SearchResponse' } & Pick< + SearchResponse, + 'totalItems' + > & { items: Array<{ __typename?: 'SearchResult' } & SearchResultFragment> } +} diff --git a/framework/vendure/scripts/generate-definitions.js b/framework/vendure/scripts/generate-definitions.js deleted file mode 100644 index bcae741c8..000000000 --- a/framework/vendure/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 = `http://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()