From 0e804d09f913030b5ef850016b15cfcfd7b11430 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Wed, 2 Jun 2021 16:46:38 +0200 Subject: [PATCH] Update Vendure provider to latest API changes (#352) Relates to #349 --- framework/vendure/.env.template | 3 + framework/vendure/api/cart/index.ts | 1 - framework/vendure/api/catalog/index.ts | 1 - framework/vendure/api/catalog/products.ts | 1 - framework/vendure/api/customers/index.ts | 1 - framework/vendure/api/customers/login.ts | 1 - framework/vendure/api/customers/logout.ts | 1 - framework/vendure/api/customers/signup.ts | 1 - framework/vendure/api/endpoints/cart/index.ts | 1 + .../vendure/api/endpoints/catalog/index.ts | 1 + .../vendure/api/endpoints/catalog/products.ts | 1 + .../api/{ => endpoints}/checkout/index.ts | 41 +- .../vendure/api/endpoints/customer/index.ts | 1 + .../vendure/api/endpoints/login/index.ts | 1 + .../vendure/api/endpoints/logout/index.ts | 1 + .../vendure/api/endpoints/signup/index.ts | 1 + .../vendure/api/endpoints/wishlist/index.tsx | 1 + framework/vendure/api/index.ts | 60 +-- .../vendure/api/operations/get-all-pages.ts | 41 ++ .../api/operations/get-all-product-paths.ts | 52 ++ .../api/operations/get-all-products.ts | 46 ++ .../api/operations/get-customer-wishlist.ts | 23 + framework/vendure/api/operations/get-page.ts | 45 ++ .../vendure/api/operations/get-product.ts | 69 +++ .../vendure/api/operations/get-site-info.ts | 50 ++ framework/vendure/api/operations/login.ts | 60 +++ .../vendure/api/utils/fetch-graphql-api.ts | 5 +- framework/vendure/api/wishlist/index.tsx | 2 - framework/vendure/auth/index.ts | 3 + framework/vendure/auth/use-login.tsx | 5 +- framework/vendure/auth/use-logout.tsx | 5 +- framework/vendure/auth/use-signup.tsx | 5 +- framework/vendure/cart/index.ts | 3 +- framework/vendure/cart/use-add-item.tsx | 8 +- framework/vendure/cart/use-cart-actions.tsx | 13 - framework/vendure/cart/use-cart.tsx | 15 +- framework/vendure/cart/use-remove-item.tsx | 26 +- framework/vendure/cart/use-update-item.tsx | 30 +- framework/vendure/common/get-all-pages.ts | 35 -- framework/vendure/common/get-page.ts | 40 -- framework/vendure/common/get-site-info.ts | 43 -- .../vendure/customer/get-customer-wishlist.ts | 18 - framework/vendure/customer/use-customer.tsx | 6 +- .../vendure/product/get-all-product-paths.ts | 48 -- framework/vendure/product/get-all-products.ts | 39 -- framework/vendure/product/get-product.ts | 64 --- framework/vendure/product/index.ts | 2 - framework/vendure/product/use-search.tsx | 15 +- framework/vendure/schema.d.ts | 487 +++++++++++------- framework/vendure/schema.graphql | 478 +++++++++++++---- framework/vendure/types.ts | 5 - framework/vendure/types/cart.ts | 1 + framework/vendure/types/checkout.ts | 1 + framework/vendure/types/common.ts | 1 + framework/vendure/types/customer.ts | 1 + framework/vendure/types/index.ts | 25 + framework/vendure/types/login.ts | 12 + framework/vendure/types/logout.ts | 1 + framework/vendure/types/page.ts | 1 + framework/vendure/types/product.ts | 1 + framework/vendure/types/signup.ts | 1 + framework/vendure/types/site.ts | 1 + framework/vendure/types/wishlist.ts | 1 + .../vendure/{lib => utils}/array-to-tree.ts | 0 .../{lib => utils}/fragments/cart-fragment.ts | 2 + .../fragments/search-result-fragment.ts | 0 .../mutations/add-item-to-order-mutation.ts | 0 .../mutations/adjust-order-line-mutation.ts | 0 .../mutations/log-in-mutation.ts | 0 .../mutations/log-out-mutation.ts | 0 .../mutations/remove-order-line-mutation.ts | 0 .../mutations/sign-up-mutation.ts | 0 framework/vendure/{lib => utils}/normalize.ts | 7 +- .../queries/active-customer-query.ts | 0 .../queries/get-all-product-paths-query.ts | 0 .../queries/get-all-products-query.ts | 0 .../{lib => utils}/queries/get-cart-query.ts | 0 .../queries/get-collections-query.ts | 0 .../queries/get-product-query.ts | 0 .../{lib => utils}/queries/search-query.ts | 0 framework/vendure/wishlist/use-wishlist.tsx | 2 +- 81 files changed, 1265 insertions(+), 698 deletions(-) delete mode 100644 framework/vendure/api/cart/index.ts delete mode 100644 framework/vendure/api/catalog/index.ts delete mode 100644 framework/vendure/api/catalog/products.ts delete mode 100644 framework/vendure/api/customers/index.ts delete mode 100644 framework/vendure/api/customers/login.ts delete mode 100644 framework/vendure/api/customers/logout.ts delete mode 100644 framework/vendure/api/customers/signup.ts create mode 100644 framework/vendure/api/endpoints/cart/index.ts create mode 100644 framework/vendure/api/endpoints/catalog/index.ts create mode 100644 framework/vendure/api/endpoints/catalog/products.ts rename framework/vendure/api/{ => endpoints}/checkout/index.ts (66%) create mode 100644 framework/vendure/api/endpoints/customer/index.ts create mode 100644 framework/vendure/api/endpoints/login/index.ts create mode 100644 framework/vendure/api/endpoints/logout/index.ts create mode 100644 framework/vendure/api/endpoints/signup/index.ts create mode 100644 framework/vendure/api/endpoints/wishlist/index.tsx create mode 100644 framework/vendure/api/operations/get-all-pages.ts create mode 100644 framework/vendure/api/operations/get-all-product-paths.ts create mode 100644 framework/vendure/api/operations/get-all-products.ts create mode 100644 framework/vendure/api/operations/get-customer-wishlist.ts create mode 100644 framework/vendure/api/operations/get-page.ts create mode 100644 framework/vendure/api/operations/get-product.ts create mode 100644 framework/vendure/api/operations/get-site-info.ts create mode 100644 framework/vendure/api/operations/login.ts delete mode 100644 framework/vendure/api/wishlist/index.tsx create mode 100644 framework/vendure/auth/index.ts delete mode 100644 framework/vendure/cart/use-cart-actions.tsx delete mode 100644 framework/vendure/common/get-all-pages.ts delete mode 100644 framework/vendure/common/get-page.ts delete mode 100644 framework/vendure/common/get-site-info.ts delete mode 100644 framework/vendure/customer/get-customer-wishlist.ts delete mode 100644 framework/vendure/product/get-all-product-paths.ts delete mode 100644 framework/vendure/product/get-all-products.ts delete mode 100644 framework/vendure/product/get-product.ts delete mode 100644 framework/vendure/types.ts create mode 100644 framework/vendure/types/cart.ts create mode 100644 framework/vendure/types/checkout.ts create mode 100644 framework/vendure/types/common.ts create mode 100644 framework/vendure/types/customer.ts create mode 100644 framework/vendure/types/index.ts create mode 100644 framework/vendure/types/login.ts create mode 100644 framework/vendure/types/logout.ts create mode 100644 framework/vendure/types/page.ts create mode 100644 framework/vendure/types/product.ts create mode 100644 framework/vendure/types/signup.ts create mode 100644 framework/vendure/types/site.ts create mode 100644 framework/vendure/types/wishlist.ts rename framework/vendure/{lib => utils}/array-to-tree.ts (100%) rename framework/vendure/{lib => utils}/fragments/cart-fragment.ts (91%) rename framework/vendure/{lib => utils}/fragments/search-result-fragment.ts (100%) rename framework/vendure/{lib => utils}/mutations/add-item-to-order-mutation.ts (100%) rename framework/vendure/{lib => utils}/mutations/adjust-order-line-mutation.ts (100%) rename framework/vendure/{lib => utils}/mutations/log-in-mutation.ts (100%) rename framework/vendure/{lib => utils}/mutations/log-out-mutation.ts (100%) rename framework/vendure/{lib => utils}/mutations/remove-order-line-mutation.ts (100%) rename framework/vendure/{lib => utils}/mutations/sign-up-mutation.ts (100%) rename framework/vendure/{lib => utils}/normalize.ts (89%) rename framework/vendure/{lib => utils}/queries/active-customer-query.ts (100%) rename framework/vendure/{lib => utils}/queries/get-all-product-paths-query.ts (100%) rename framework/vendure/{lib => utils}/queries/get-all-products-query.ts (100%) rename framework/vendure/{lib => utils}/queries/get-cart-query.ts (100%) rename framework/vendure/{lib => utils}/queries/get-collections-query.ts (100%) rename framework/vendure/{lib => utils}/queries/get-product-query.ts (100%) rename framework/vendure/{lib => utils}/queries/search-query.ts (100%) diff --git a/framework/vendure/.env.template b/framework/vendure/.env.template index d8f7f14b5..f4823038d 100644 --- a/framework/vendure/.env.template +++ b/framework/vendure/.env.template @@ -1 +1,4 @@ +COMMERCE_PROVIDER=vendure + NEXT_PUBLIC_VENDURE_SHOP_API_URL=http://localhost:3001/shop-api +NEXT_PUBLIC_VENDURE_LOCAL_URL=/vendure-shop-api diff --git a/framework/vendure/api/cart/index.ts b/framework/vendure/api/cart/index.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/cart/index.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/catalog/index.ts b/framework/vendure/api/catalog/index.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/catalog/index.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/catalog/products.ts b/framework/vendure/api/catalog/products.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/catalog/products.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/customers/index.ts b/framework/vendure/api/customers/index.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/customers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/customers/login.ts b/framework/vendure/api/customers/login.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/customers/login.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/customers/logout.ts b/framework/vendure/api/customers/logout.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/customers/logout.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/customers/signup.ts b/framework/vendure/api/customers/signup.ts deleted file mode 100644 index ea9b101e1..000000000 --- a/framework/vendure/api/customers/signup.ts +++ /dev/null @@ -1 +0,0 @@ -export default function () {} diff --git a/framework/vendure/api/endpoints/cart/index.ts b/framework/vendure/api/endpoints/cart/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/cart/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/catalog/index.ts b/framework/vendure/api/endpoints/catalog/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/catalog/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/catalog/products.ts b/framework/vendure/api/endpoints/catalog/products.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/catalog/products.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/checkout/index.ts b/framework/vendure/api/endpoints/checkout/index.ts similarity index 66% rename from framework/vendure/api/checkout/index.ts rename to framework/vendure/api/endpoints/checkout/index.ts index 08b21f6a9..00c17f993 100644 --- a/framework/vendure/api/checkout/index.ts +++ b/framework/vendure/api/endpoints/checkout/index.ts @@ -1,6 +1,13 @@ import { NextApiHandler } from 'next' +import { CommerceAPI, createEndpoint, GetAPISchema } from '@commerce/api' +import { CheckoutSchema } from '@commerce/types/checkout' +import checkoutEndpoint from '@commerce/api/endpoints/checkout' -const checkoutApi = async (req: any, res: any, config: any) => { +const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({ + req, + res, + config, +}) => { try { const html = ` @@ -37,27 +44,15 @@ const checkoutApi = async (req: any, res: any, config: any) => { } } -export function createApiHandler( - handler: any, - handlers: H, - defaultOptions: Options -) { - return function getApiHandler({ - config, - operations, - options, - }: { - config?: any - operations?: Partial - options?: Options extends {} ? Partial : never - } = {}): NextApiHandler { - const ops = { ...operations, ...handlers } - const opts = { ...defaultOptions, ...options } +export type CheckoutAPI = GetAPISchema - return function apiHandler(req, res) { - return handler(req, res, config, ops, opts) - } - } -} +export type CheckoutEndpoint = CheckoutAPI['endpoint'] -export default createApiHandler(checkoutApi, {}, {}) +export const handlers: CheckoutEndpoint['handlers'] = { checkout } + +const checkoutApi = createEndpoint({ + handler: checkoutEndpoint, + handlers, +}) + +export default checkoutApi diff --git a/framework/vendure/api/endpoints/customer/index.ts b/framework/vendure/api/endpoints/customer/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/customer/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/login/index.ts b/framework/vendure/api/endpoints/login/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/login/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/logout/index.ts b/framework/vendure/api/endpoints/logout/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/logout/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/signup/index.ts b/framework/vendure/api/endpoints/signup/index.ts new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/signup/index.ts @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/endpoints/wishlist/index.tsx b/framework/vendure/api/endpoints/wishlist/index.tsx new file mode 100644 index 000000000..491bf0ac9 --- /dev/null +++ b/framework/vendure/api/endpoints/wishlist/index.tsx @@ -0,0 +1 @@ +export default function noopApi(...args: any[]): void {} diff --git a/framework/vendure/api/index.ts b/framework/vendure/api/index.ts index f6b06a10c..6762ee6aa 100644 --- a/framework/vendure/api/index.ts +++ b/framework/vendure/api/index.ts @@ -1,6 +1,16 @@ -import type { CommerceAPIConfig } from '@commerce/api' +import type { APIProvider, CommerceAPIConfig } from '@commerce/api' +import { CommerceAPI, getCommerceApi as commerceApi } from '@commerce/api' import fetchGraphqlApi from './utils/fetch-graphql-api' +import login from './operations/login' +import getAllPages from './operations/get-all-pages' +import getPage from './operations/get-page' +import getSiteInfo from './operations/get-site-info' +import getCustomerWishlist from './operations/get-customer-wishlist' +import getAllProductPaths from './operations/get-all-product-paths' +import getAllProducts from './operations/get-all-products' +import getProduct from './operations/get-product' + export interface VendureConfig extends CommerceAPIConfig {} const API_URL = process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL @@ -11,41 +21,33 @@ if (!API_URL) { ) } -export class Config { - private config: VendureConfig - - constructor(config: VendureConfig) { - this.config = { - ...config, - } - } - - getConfig(userConfig: Partial = {}) { - return Object.entries(userConfig).reduce( - (cfg, [key, value]) => Object.assign(cfg, { [key]: value }), - { ...this.config } - ) - } - - setConfig(newConfig: Partial) { - Object.assign(this.config, newConfig) - } -} - const ONE_DAY = 60 * 60 * 24 -const config = new Config({ +const config: VendureConfig = { commerceUrl: API_URL, apiToken: '', cartCookie: '', customerCookie: '', cartCookieMaxAge: ONE_DAY * 30, fetch: fetchGraphqlApi, -}) - -export function getConfig(userConfig?: Partial) { - return config.getConfig(userConfig) } -export function setConfig(newConfig: Partial) { - return config.setConfig(newConfig) +const operations = { + login, + getAllPages, + getPage, + getSiteInfo, + getCustomerWishlist, + getAllProductPaths, + getAllProducts, + getProduct, +} + +export const provider = { config, operations } + +export type Provider = typeof provider + +export function getCommerceApi

( + customProvider: P = provider as any +): CommerceAPI

{ + return commerceApi(customProvider) } diff --git a/framework/vendure/api/operations/get-all-pages.ts b/framework/vendure/api/operations/get-all-pages.ts new file mode 100644 index 000000000..43170cda8 --- /dev/null +++ b/framework/vendure/api/operations/get-all-pages.ts @@ -0,0 +1,41 @@ +import { VendureConfig } from '../' +import { OperationContext } from '@commerce/api/operations' +import { Provider } from '../../../bigcommerce/api' + +export type Page = any + +export type GetAllPagesResult< + T extends { pages: any[] } = { pages: Page[] } +> = T + +export default function getAllPagesOperation({ + commerce, +}: OperationContext) { + async function getAllPages(opts?: { + config?: Partial + preview?: boolean + }): Promise + + async function getAllPages(opts: { + url: string + config?: Partial + preview?: boolean + }): Promise> + + async function getAllPages({ + config: cfg, + preview, + }: { + url?: string + config?: Partial + preview?: boolean + } = {}): Promise { + const config = commerce.getConfig(cfg) + + return { + pages: [], + } + } + + return getAllPages +} diff --git a/framework/vendure/api/operations/get-all-product-paths.ts b/framework/vendure/api/operations/get-all-product-paths.ts new file mode 100644 index 000000000..54ca3b136 --- /dev/null +++ b/framework/vendure/api/operations/get-all-product-paths.ts @@ -0,0 +1,52 @@ +import { OperationContext, OperationOptions } from '@commerce/api/operations' +import type { GetAllProductPathsQuery } from '../../schema' +import { Provider } from '../index' +import { getAllProductPathsQuery } from '../../utils/queries/get-all-product-paths-query' +import { GetAllProductPathsOperation } from '@commerce/types/product' +import { BigcommerceConfig } from '../../../bigcommerce/api' + +export type GetAllProductPathsResult = { + products: Array<{ node: { path: string } }> +} + +export default function getAllProductPathsOperation({ + commerce, +}: OperationContext) { + async function getAllProductPaths< + T extends GetAllProductPathsOperation + >(opts?: { + variables?: T['variables'] + config?: BigcommerceConfig + }): Promise + + async function getAllProductPaths( + opts: { + variables?: T['variables'] + config?: BigcommerceConfig + } & OperationOptions + ): Promise + + async function getAllProductPaths({ + query = getAllProductPathsQuery, + variables, + config: cfg, + }: { + query?: string + variables?: T['variables'] + config?: BigcommerceConfig + } = {}): Promise { + const config = commerce.getConfig(cfg) + // 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(query, { + variables, + }) + const products = data.products.items + + return { + products: products.map((p) => ({ path: `/${p.slug}` })), + } + } + + return getAllProductPaths +} diff --git a/framework/vendure/api/operations/get-all-products.ts b/framework/vendure/api/operations/get-all-products.ts new file mode 100644 index 000000000..68d4ce9b7 --- /dev/null +++ b/framework/vendure/api/operations/get-all-products.ts @@ -0,0 +1,46 @@ +import { Product } from '@commerce/types/product' +import { Provider, VendureConfig } from '../' +import { GetAllProductsQuery } from '../../schema' +import { normalizeSearchResult } from '../../utils/normalize' +import { getAllProductsQuery } from '../../utils/queries/get-all-products-query' +import { OperationContext } from '@commerce/api/operations' + +export type ProductVariables = { first?: number } + +export default function getAllProductsOperation({ + commerce, +}: OperationContext) { + async function getAllProducts(opts?: { + variables?: ProductVariables + config?: Partial + preview?: boolean + }): Promise<{ products: Product[] }> + + async function getAllProducts({ + query = getAllProductsQuery, + variables: { ...vars } = {}, + config: cfg, + }: { + query?: string + variables?: ProductVariables + config?: Partial + preview?: boolean + } = {}): Promise<{ products: Product[] | any[] }> { + const config = commerce.getConfig(cfg) + const variables = { + input: { + take: vars.first, + groupByProduct: true, + }, + } + const { data } = await config.fetch(query, { + variables, + }) + + return { + products: data.search.items.map((item) => normalizeSearchResult(item)), + } + } + + return getAllProducts +} diff --git a/framework/vendure/api/operations/get-customer-wishlist.ts b/framework/vendure/api/operations/get-customer-wishlist.ts new file mode 100644 index 000000000..0040ef36d --- /dev/null +++ b/framework/vendure/api/operations/get-customer-wishlist.ts @@ -0,0 +1,23 @@ +import { OperationContext } from '@commerce/api/operations' +import { Provider, VendureConfig } from '../' + +export default function getCustomerWishlistOperation({ + commerce, +}: OperationContext) { + async function getCustomerWishlist({ + config: cfg, + variables, + includeProducts, + }: { + url?: string + variables: any + config?: Partial + includeProducts?: boolean + }): Promise { + // Not implemented as Vendure does not ship with wishlist functionality at present + const config = commerce.getConfig(cfg) + return { wishlist: {} } + } + + return getCustomerWishlist +} diff --git a/framework/vendure/api/operations/get-page.ts b/framework/vendure/api/operations/get-page.ts new file mode 100644 index 000000000..59717dc84 --- /dev/null +++ b/framework/vendure/api/operations/get-page.ts @@ -0,0 +1,45 @@ +import { VendureConfig, Provider } from '../' +import { OperationContext } from '@commerce/api/operations' + +export type Page = any + +export type GetPageResult = T + +export type PageVariables = { + id: number +} + +export default function getPageOperation({ + commerce, +}: OperationContext) { + async function getPage(opts: { + url?: string + variables: PageVariables + config?: Partial + preview?: boolean + }): Promise + + async function getPage(opts: { + url: string + variables: V + config?: Partial + preview?: boolean + }): Promise> + + async function getPage({ + url, + variables, + config: cfg, + preview, + }: { + url?: string + variables: PageVariables + config?: Partial + preview?: boolean + }): Promise { + const config = commerce.getConfig(cfg) + return {} + } + + return getPage +} diff --git a/framework/vendure/api/operations/get-product.ts b/framework/vendure/api/operations/get-product.ts new file mode 100644 index 000000000..4ab9ed2d9 --- /dev/null +++ b/framework/vendure/api/operations/get-product.ts @@ -0,0 +1,69 @@ +import { Product } from '@commerce/types/product' +import { OperationContext } from '@commerce/api/operations' +import { Provider, VendureConfig } from '../' +import { GetProductQuery } from '../../schema' +import { getProductQuery } from '../../utils/queries/get-product-query' + +export default function getProductOperation({ + commerce, +}: OperationContext) { + async function getProduct({ + query = getProductQuery, + variables, + config: cfg, + }: { + query?: string + variables: { slug: string } + config?: Partial + preview?: boolean + }): Promise { + const config = commerce.getConfig(cfg) + + const locale = config.locale + const { data } = await config.fetch(query, { variables }) + const product = data.product + + if (product) { + const getOptionGroupName = (id: string): string => { + return product.optionGroups.find((og) => og.id === id)!.name + } + return { + product: { + id: product.id, + name: product.name, + description: product.description, + slug: product.slug, + images: product.assets.map((a) => ({ + url: a.preview, + alt: a.name, + })), + variants: product.variants.map((v) => ({ + id: v.id, + options: v.options.map((o) => ({ + // This __typename property is required in order for the correct + // variant selection to work, see `components/product/helpers.ts` + // `getVariant()` function. + __typename: 'MultipleChoiceOption', + id: o.id, + displayName: getOptionGroupName(o.groupId), + values: [{ label: o.name }], + })), + })), + price: { + value: product.variants[0].priceWithTax / 100, + currencyCode: product.variants[0].currencyCode, + }, + options: product.optionGroups.map((og) => ({ + id: og.id, + displayName: og.name, + values: og.options.map((o) => ({ label: o.name })), + })), + } as Product, + } + } + + return {} + } + + return getProduct +} diff --git a/framework/vendure/api/operations/get-site-info.ts b/framework/vendure/api/operations/get-site-info.ts new file mode 100644 index 000000000..acfcea424 --- /dev/null +++ b/framework/vendure/api/operations/get-site-info.ts @@ -0,0 +1,50 @@ +import { Provider, VendureConfig } from '../' +import { GetCollectionsQuery } from '../../schema' +import { arrayToTree } from '../../utils/array-to-tree' +import { getCollectionsQuery } from '../../utils/queries/get-collections-query' +import { OperationContext } from '@commerce/api/operations' +import { Category } from '@commerce/types/site' + +export type GetSiteInfoResult< + T extends { categories: any[]; brands: any[] } = { + categories: Category[] + brands: any[] + } +> = T + +export default function getSiteInfoOperation({ + commerce, +}: OperationContext) { + async function getSiteInfo({ + query = getCollectionsQuery, + variables, + config: cfg, + }: { + query?: string + variables?: any + config?: Partial + preview?: boolean + } = {}): Promise { + const config = commerce.getConfig(cfg) + // 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(query, { + variables, + }) + const collections = data.collections?.items.map((i) => ({ + ...i, + entityId: i.id, + path: i.slug, + productCount: i.productVariants.totalItems, + })) + const categories = arrayToTree(collections).children + const brands = [] as any[] + + return { + categories: categories ?? [], + brands, + } + } + + return getSiteInfo +} diff --git a/framework/vendure/api/operations/login.ts b/framework/vendure/api/operations/login.ts new file mode 100644 index 000000000..4ad408e0a --- /dev/null +++ b/framework/vendure/api/operations/login.ts @@ -0,0 +1,60 @@ +import type { ServerResponse } from 'http' +import type { + OperationContext, + OperationOptions, +} from '@commerce/api/operations' +import { ValidationError } from '@commerce/utils/errors' +import type { LoginOperation } from '../../types/login' +import type { LoginMutation } from '../../schema' +import { Provider, VendureConfig } from '..' +import { loginMutation } from '../../utils/mutations/log-in-mutation' + +export default function loginOperation({ + commerce, +}: OperationContext) { + async function login(opts: { + variables: T['variables'] + config?: Partial + res: ServerResponse + }): Promise + + async function login( + opts: { + variables: T['variables'] + config?: Partial + res: ServerResponse + } & OperationOptions + ): Promise + + async function login({ + query = loginMutation, + variables, + res: response, + config: cfg, + }: { + query?: string + variables: T['variables'] + res: ServerResponse + config?: Partial + }): Promise { + const config = commerce.getConfig(cfg) + + const { data, res } = await config.fetch(query, { + variables, + }) + switch (data.login.__typename) { + case 'NativeAuthStrategyError': + case 'InvalidCredentialsError': + case 'NotVerifiedError': + throw new ValidationError({ + code: data.login.errorCode, + message: data.login.message, + }) + } + return { + result: data.login.id, + } + } + + return login +} diff --git a/framework/vendure/api/utils/fetch-graphql-api.ts b/framework/vendure/api/utils/fetch-graphql-api.ts index f769123e4..64a02dde5 100644 --- a/framework/vendure/api/utils/fetch-graphql-api.ts +++ b/framework/vendure/api/utils/fetch-graphql-api.ts @@ -1,6 +1,6 @@ import { FetcherError } from '@commerce/utils/errors' import type { GraphQLFetcher } from '@commerce/api' -import { getConfig } from '..' +import { getCommerceApi } from '../' import fetch from './fetch' const fetchGraphqlApi: GraphQLFetcher = async ( @@ -8,12 +8,11 @@ const fetchGraphqlApi: GraphQLFetcher = async ( { variables, preview } = {}, fetchOptions ) => { - const config = getConfig() + const config = getCommerceApi().getConfig() const res = await fetch(config.commerceUrl, { ...fetchOptions, method: 'POST', headers: { - Authorization: `Bearer ${config.apiToken}`, ...fetchOptions?.headers, 'Content-Type': 'application/json', }, diff --git a/framework/vendure/api/wishlist/index.tsx b/framework/vendure/api/wishlist/index.tsx deleted file mode 100644 index a72856673..000000000 --- a/framework/vendure/api/wishlist/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export type WishlistItem = { product: any; id: number } -export default function () {} diff --git a/framework/vendure/auth/index.ts b/framework/vendure/auth/index.ts new file mode 100644 index 000000000..36e757a89 --- /dev/null +++ b/framework/vendure/auth/index.ts @@ -0,0 +1,3 @@ +export { default as useLogin } from './use-login' +export { default as useLogout } from './use-logout' +export { default as useSignup } from './use-signup' diff --git a/framework/vendure/auth/use-login.tsx b/framework/vendure/auth/use-login.tsx index f0fc85cbc..f10e38d0f 100644 --- a/framework/vendure/auth/use-login.tsx +++ b/framework/vendure/auth/use-login.tsx @@ -1,14 +1,15 @@ import { useCallback } from 'react' import { MutationHook } from '@commerce/utils/types' import useLogin, { UseLogin } from '@commerce/auth/use-login' +import { LoginHook } from '../types/login' import { CommerceError, ValidationError } from '@commerce/utils/errors' import useCustomer from '../customer/use-customer' import { LoginMutation, LoginMutationVariables } from '../schema' -import { loginMutation } from '../lib/mutations/log-in-mutation' +import { loginMutation } from '../utils/mutations/log-in-mutation' export default useLogin as UseLogin -export const handler: MutationHook = { +export const handler: MutationHook = { fetchOptions: { query: loginMutation, }, diff --git a/framework/vendure/auth/use-logout.tsx b/framework/vendure/auth/use-logout.tsx index 93ba665b8..29bf5cb0d 100644 --- a/framework/vendure/auth/use-logout.tsx +++ b/framework/vendure/auth/use-logout.tsx @@ -3,11 +3,12 @@ import { MutationHook } from '@commerce/utils/types' import useLogout, { UseLogout } from '@commerce/auth/use-logout' import useCustomer from '../customer/use-customer' import { LogoutMutation } from '../schema' -import { logoutMutation } from '../lib/mutations/log-out-mutation' +import { logoutMutation } from '../utils/mutations/log-out-mutation' +import { LogoutHook } from '../types/logout' export default useLogout as UseLogout -export const handler: MutationHook = { +export const handler: MutationHook = { fetchOptions: { query: logoutMutation, }, diff --git a/framework/vendure/auth/use-signup.tsx b/framework/vendure/auth/use-signup.tsx index 816b95738..864b1a18a 100644 --- a/framework/vendure/auth/use-signup.tsx +++ b/framework/vendure/auth/use-signup.tsx @@ -8,7 +8,8 @@ import { SignupMutation, SignupMutationVariables, } from '../schema' -import { signupMutation } from '../lib/mutations/sign-up-mutation' +import { signupMutation } from '../utils/mutations/sign-up-mutation' +import { SignupHook } from '../types/signup' export default useSignup as UseSignup @@ -19,7 +20,7 @@ export type SignupInput = { password: string } -export const handler: MutationHook = { +export const handler: MutationHook = { fetchOptions: { query: signupMutation, }, diff --git a/framework/vendure/cart/index.ts b/framework/vendure/cart/index.ts index 43c6db2b7..3b8ba990e 100644 --- a/framework/vendure/cart/index.ts +++ b/framework/vendure/cart/index.ts @@ -1,5 +1,4 @@ export { default as useCart } from './use-cart' export { default as useAddItem } from './use-add-item' export { default as useRemoveItem } from './use-remove-item' -export { default as useWishlistActions } from './use-cart-actions' -export { default as useUpdateItem } from './use-cart-actions' +export { default as useUpdateItem } from './use-update-item' diff --git a/framework/vendure/cart/use-add-item.tsx b/framework/vendure/cart/use-add-item.tsx index 42c5e5a63..88bff40e4 100644 --- a/framework/vendure/cart/use-add-item.tsx +++ b/framework/vendure/cart/use-add-item.tsx @@ -1,16 +1,16 @@ -import { Cart, CartItemBody } from '@commerce/types' import useAddItem, { UseAddItem } from '@commerce/cart/use-add-item' import { CommerceError } from '@commerce/utils/errors' import { MutationHook } from '@commerce/utils/types' import { useCallback } from 'react' import useCart from './use-cart' import { AddItemToOrderMutation } from '../schema' -import { normalizeCart } from '../lib/normalize' -import { addItemToOrderMutation } from '../lib/mutations/add-item-to-order-mutation' +import { normalizeCart } from '../utils/normalize' +import { addItemToOrderMutation } from '../utils/mutations/add-item-to-order-mutation' +import { AddItemHook } from '../types/cart' export default useAddItem as UseAddItem -export const handler: MutationHook = { +export const handler: MutationHook = { fetchOptions: { query: addItemToOrderMutation, }, diff --git a/framework/vendure/cart/use-cart-actions.tsx b/framework/vendure/cart/use-cart-actions.tsx deleted file mode 100644 index abb4a998e..000000000 --- a/framework/vendure/cart/use-cart-actions.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import useAddItem from './use-add-item' -import useRemoveItem from './use-remove-item' -import useUpdateItem from './use-update-item' - -// This hook is probably not going to be used, but it's here -// to show how a commerce should be structuring it -export default function useCartActions() { - const addItem = useAddItem() - const updateItem = useUpdateItem() - const removeItem = useRemoveItem() - - return { addItem, updateItem, removeItem } -} diff --git a/framework/vendure/cart/use-cart.tsx b/framework/vendure/cart/use-cart.tsx index ee9975f87..400df0c8c 100644 --- a/framework/vendure/cart/use-cart.tsx +++ b/framework/vendure/cart/use-cart.tsx @@ -1,10 +1,10 @@ -import { Cart } from '@commerce/types' import { SWRHook } from '@commerce/utils/types' -import useCart, { FetchCartInput, UseCart } from '@commerce/cart/use-cart' +import useCart, { UseCart } from '@commerce/cart/use-cart' import { ActiveOrderQuery, CartFragment } from '../schema' -import { normalizeCart } from '../lib/normalize' +import { normalizeCart } from '../utils/normalize' import { useMemo } from 'react' -import { getCartQuery } from '../lib/queries/get-cart-query' +import { getCartQuery } from '../utils/queries/get-cart-query' +import { GetCartHook } from '../types/cart' export type CartResult = { activeOrder?: CartFragment @@ -15,12 +15,7 @@ export type CartResult = { export default useCart as UseCart -export const handler: SWRHook< - Cart | null, - {}, - FetchCartInput, - { isEmpty?: boolean } -> = { +export const handler: SWRHook = { fetchOptions: { query: getCartQuery, }, diff --git a/framework/vendure/cart/use-remove-item.tsx b/framework/vendure/cart/use-remove-item.tsx index f23f04d00..39855e1ac 100644 --- a/framework/vendure/cart/use-remove-item.tsx +++ b/framework/vendure/cart/use-remove-item.tsx @@ -1,25 +1,31 @@ import { useCallback } from 'react' -import { HookFetcherContext, MutationHookContext } from '@commerce/utils/types' +import { + HookFetcherContext, + MutationHook, + MutationHookContext, + SWRHook, +} from '@commerce/utils/types' import useRemoveItem, { UseRemoveItem } from '@commerce/cart/use-remove-item' import { CommerceError } from '@commerce/utils/errors' +import { Cart } from '@commerce/types/cart' import useCart from './use-cart' import { RemoveOrderLineMutation, RemoveOrderLineMutationVariables, } from '../schema' -import { Cart, LineItem, RemoveCartItemBody } from '@commerce/types' -import { normalizeCart } from '../lib/normalize' -import { removeOrderLineMutation } from '../lib/mutations/remove-order-line-mutation' +import { normalizeCart } from '../utils/normalize' +import { RemoveItemHook } from '../types/cart' +import { removeOrderLineMutation } from '../utils/mutations/remove-order-line-mutation' export default useRemoveItem as UseRemoveItem -export const handler = { +export const handler: MutationHook = { fetchOptions: { query: removeOrderLineMutation, }, - async fetcher({ input, options, fetch }: HookFetcherContext) { + async fetcher({ input, options, fetch }) { const variables: RemoveOrderLineMutationVariables = { - orderLineId: input.id, + orderLineId: input.itemId, } const { removeOrderLine } = await fetch({ ...options, @@ -31,14 +37,12 @@ export const handler = { } throw new CommerceError(removeOrderLine) }, - useHook: ({ - fetch, - }: MutationHookContext) => (ctx = {}) => { + useHook: ({ fetch }) => () => { const { mutate } = useCart() return useCallback( async function removeItem(input) { - const data = await fetch({ input }) + const data = await fetch({ input: { itemId: input.id } }) await mutate(data, false) return data }, diff --git a/framework/vendure/cart/use-update-item.tsx b/framework/vendure/cart/use-update-item.tsx index 4e871514e..d04de944a 100644 --- a/framework/vendure/cart/use-update-item.tsx +++ b/framework/vendure/cart/use-update-item.tsx @@ -1,20 +1,24 @@ import { useCallback } from 'react' -import { HookFetcherContext, MutationHookContext } from '@commerce/utils/types' +import { + HookFetcherContext, + MutationHook, + MutationHookContext, +} from '@commerce/utils/types' import { CommerceError, ValidationError } from '@commerce/utils/errors' import useUpdateItem, { UseUpdateItem } from '@commerce/cart/use-update-item' -import { - Cart, - CartItemBody, - LineItem, - UpdateCartItemBody, -} from '@commerce/types' +import { CartItemBody, LineItem } from '@commerce/types/cart' import useCart from './use-cart' import { AdjustOrderLineMutation, AdjustOrderLineMutationVariables, } from '../schema' -import { normalizeCart } from '../lib/normalize' -import { adjustOrderLineMutation } from '../lib/mutations/adjust-order-line-mutation' +import { normalizeCart } from '../utils/normalize' +import { adjustOrderLineMutation } from '../utils/mutations/adjust-order-line-mutation' +import { UpdateItemHook } from '../types/cart' + +export type UpdateItemActionInput = T extends LineItem + ? Partial + : UpdateItemHook['actionInput'] export default useUpdateItem as UseUpdateItem @@ -22,7 +26,7 @@ export const handler = { fetchOptions: { query: adjustOrderLineMutation, }, - async fetcher(context: HookFetcherContext>) { + async fetcher(context: HookFetcherContext) { const { input, options, fetch } = context const variables: AdjustOrderLineMutationVariables = { quantity: input.item.quantity || 1, @@ -38,9 +42,7 @@ export const handler = { } throw new CommerceError(adjustOrderLine) }, - useHook: ({ - fetch, - }: MutationHookContext>) => ( + useHook: ({ fetch }: MutationHookContext) => ( ctx: { item?: LineItem wait?: number @@ -50,7 +52,7 @@ export const handler = { const { mutate } = useCart() return useCallback( - async function addItem(input: Partial) { + async function addItem(input: UpdateItemActionInput) { const itemId = item?.id const productId = input.productId ?? item?.productId const variantId = input.productId ?? item?.variantId diff --git a/framework/vendure/common/get-all-pages.ts b/framework/vendure/common/get-all-pages.ts deleted file mode 100644 index 1200b02b1..000000000 --- a/framework/vendure/common/get-all-pages.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { getConfig, VendureConfig } from '../api' - -export type Page = any - -export type GetAllPagesResult< - T extends { pages: any[] } = { pages: Page[] } -> = T - -async function getAllPages(opts?: { - config?: VendureConfig - preview?: boolean -}): Promise - -async function getAllPages(opts: { - url: string - config?: VendureConfig - preview?: boolean -}): Promise> - -async function getAllPages({ - config, - preview, -}: { - url?: string - config?: VendureConfig - preview?: boolean -} = {}): Promise { - config = getConfig(config) - - return { - pages: [], - } -} - -export default getAllPages diff --git a/framework/vendure/common/get-page.ts b/framework/vendure/common/get-page.ts deleted file mode 100644 index 48a183630..000000000 --- a/framework/vendure/common/get-page.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { VendureConfig, getConfig } from '../api' - -export type Page = any - -export type GetPageResult = T - -export type PageVariables = { - id: number -} - -async function getPage(opts: { - url?: string - variables: PageVariables - config?: VendureConfig - preview?: boolean -}): Promise - -async function getPage(opts: { - url: string - variables: V - config?: VendureConfig - preview?: boolean -}): Promise> - -async function getPage({ - url, - variables, - config, - preview, -}: { - url?: string - variables: PageVariables - config?: VendureConfig - preview?: boolean -}): Promise { - config = getConfig(config) - return {} -} - -export default getPage diff --git a/framework/vendure/common/get-site-info.ts b/framework/vendure/common/get-site-info.ts deleted file mode 100644 index 99836c28b..000000000 --- a/framework/vendure/common/get-site-info.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { getConfig, VendureConfig } from '../api' -import { GetCollectionsQuery } from '../schema' -import { arrayToTree } from '../lib/array-to-tree' -import { getCollectionsQuery } from '../lib/queries/get-collections-query' -import { Category } from '@commerce/types' - -export type GetSiteInfoResult< - T extends { categories: any[]; brands: any[] } = { - categories: Category[] - brands: any[] - } -> = T - -async function getSiteInfo({ - query = getCollectionsQuery, - variables, - config, -}: { - query?: string - variables?: any - config?: VendureConfig - preview?: boolean -} = {}): Promise { - 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(query, { variables }) - const collections = data.collections?.items.map((i) => ({ - ...i, - entityId: i.id, - path: i.slug, - productCount: i.productVariants.totalItems, - })) - const categories = arrayToTree(collections).children - const brands = [] as any[] - - return { - categories: categories ?? [], - brands, - } -} - -export default getSiteInfo diff --git a/framework/vendure/customer/get-customer-wishlist.ts b/framework/vendure/customer/get-customer-wishlist.ts deleted file mode 100644 index 81ec96956..000000000 --- a/framework/vendure/customer/get-customer-wishlist.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { getConfig, VendureConfig } from '../api' - -async function getCustomerWishlist({ - config, - variables, - includeProducts, -}: { - url?: string - variables: any - config?: VendureConfig - includeProducts?: boolean -}): Promise { - // Not implemented as Vendure does not ship with wishlist functionality at present - config = getConfig(config) - return { wishlist: {} } -} - -export default getCustomerWishlist diff --git a/framework/vendure/customer/use-customer.tsx b/framework/vendure/customer/use-customer.tsx index 4de821253..1d5a53d48 100644 --- a/framework/vendure/customer/use-customer.tsx +++ b/framework/vendure/customer/use-customer.tsx @@ -1,12 +1,12 @@ import { SWRHook } from '@commerce/utils/types' import useCustomer, { UseCustomer } from '@commerce/customer/use-customer' -import { Customer } from '@commerce/types' import { ActiveCustomerQuery } from '../schema' -import { activeCustomerQuery } from '../lib/queries/active-customer-query' +import { activeCustomerQuery } from '../utils/queries/active-customer-query' +import { CustomerHook } from '../types/customer' export default useCustomer as UseCustomer -export const handler: SWRHook = { +export const handler: SWRHook = { fetchOptions: { query: activeCustomerQuery, }, diff --git a/framework/vendure/product/get-all-product-paths.ts b/framework/vendure/product/get-all-product-paths.ts deleted file mode 100644 index dfbaff1b8..000000000 --- a/framework/vendure/product/get-all-product-paths.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { - GetAllProductPathsQuery, - GetAllProductPathsQueryVariables, -} from '../schema' -import { getConfig, VendureConfig } from '../api' -import { getAllProductPathsQuery } from '../lib/queries/get-all-product-paths-query' - -export type GetAllProductPathsResult = { - products: Array<{ node: { path: string } }> -} - -async function getAllProductPaths(opts?: { - variables?: GetAllProductPathsQueryVariables - config?: VendureConfig -}): Promise - -async function getAllProductPaths< - T extends { products: any[] }, - V = any ->(opts: { - query: string - variables?: V - config?: VendureConfig -}): Promise - -async function getAllProductPaths({ - query = getAllProductPathsQuery, - variables, - config, -}: { - query?: string - variables?: GetAllProductPathsQueryVariables - config?: VendureConfig -} = {}): Promise { - 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(query, { - variables, - }) - const products = data.products.items - - return { - products: products.map((p) => ({ node: { path: `/${p.slug}` } })), - } -} - -export default getAllProductPaths diff --git a/framework/vendure/product/get-all-products.ts b/framework/vendure/product/get-all-products.ts deleted file mode 100644 index b292e0246..000000000 --- a/framework/vendure/product/get-all-products.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Product } from '@commerce/types' -import { getConfig, VendureConfig } from '../api' -import { GetAllProductsQuery } from '../schema' -import { normalizeSearchResult } from '../lib/normalize' -import { getAllProductsQuery } from '../lib/queries/get-all-products-query' - -export type ProductVariables = { first?: number } - -async function getAllProducts(opts?: { - variables?: ProductVariables - config?: VendureConfig - preview?: boolean -}): Promise<{ products: Product[] }> - -async function getAllProducts({ - query = getAllProductsQuery, - variables: { ...vars } = {}, - config, -}: { - query?: string - variables?: ProductVariables - config?: VendureConfig - preview?: boolean -} = {}): Promise<{ products: Product[] | any[] }> { - config = getConfig(config) - const variables = { - input: { - take: vars.first, - groupByProduct: true, - }, - } - const { data } = await config.fetch(query, { variables }) - - 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 deleted file mode 100644 index 4427707bd..000000000 --- a/framework/vendure/product/get-product.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Product } from '@commerce/types' -import { getConfig, VendureConfig } from '../api' -import { GetProductQuery } from '../schema' -import { getProductQuery } from '../lib/queries/get-product-query' - -async function getProduct({ - query = getProductQuery, - variables, - config, -}: { - query?: string - variables: { slug: string } - config?: VendureConfig - preview?: boolean -}): Promise { - config = getConfig(config) - - const locale = config.locale - const { data } = await config.fetch(query, { variables }) - const product = data.product - - if (product) { - const getOptionGroupName = (id: string): string => { - return product.optionGroups.find((og) => og.id === id)!.name - } - return { - product: { - id: product.id, - name: product.name, - description: product.description, - slug: product.slug, - images: product.assets.map((a) => ({ - url: a.preview, - alt: a.name, - })), - variants: product.variants.map((v) => ({ - id: v.id, - options: v.options.map((o) => ({ - // This __typename property is required in order for the correct - // variant selection to work, see `components/product/helpers.ts` - // `getVariant()` function. - __typename: 'MultipleChoiceOption', - id: o.id, - displayName: getOptionGroupName(o.groupId), - values: [{ label: o.name }], - })), - })), - price: { - value: product.variants[0].priceWithTax / 100, - currencyCode: product.variants[0].currencyCode, - }, - options: product.optionGroups.map((og) => ({ - id: og.id, - displayName: og.name, - values: og.options.map((o) => ({ label: o.name })), - })), - } as Product, - } - } - - return {} -} - -export default getProduct diff --git a/framework/vendure/product/index.ts b/framework/vendure/product/index.ts index b290c189f..426a3edcd 100644 --- a/framework/vendure/product/index.ts +++ b/framework/vendure/product/index.ts @@ -1,4 +1,2 @@ export { default as usePrice } from './use-price' export { default as useSearch } from './use-search' -export { default as getProduct } from './get-product' -export { default as getAllProducts } from './get-all-products' diff --git a/framework/vendure/product/use-search.tsx b/framework/vendure/product/use-search.tsx index 00d9db36c..e34db2ac2 100644 --- a/framework/vendure/product/use-search.tsx +++ b/framework/vendure/product/use-search.tsx @@ -1,9 +1,10 @@ import { SWRHook } from '@commerce/utils/types' import useSearch, { UseSearch } from '@commerce/product/use-search' -import { Product } from '@commerce/types' +import { Product } from '@commerce/types/product' import { SearchQuery, SearchQueryVariables } from '../schema' -import { normalizeSearchResult } from '../lib/normalize' -import { searchQuery } from '../lib/queries/search-query' +import { normalizeSearchResult } from '../utils/normalize' +import { searchQuery } from '../utils/queries/search-query' +import { SearchProductsHook } from '../types/product' export default useSearch as UseSearch @@ -19,11 +20,7 @@ export type SearchProductsData = { found: boolean } -export const handler: SWRHook< - SearchProductsData, - SearchProductsInput, - SearchProductsInput -> = { +export const handler: SWRHook = { fetchOptions: { query: searchQuery, }, @@ -33,7 +30,7 @@ export const handler: SWRHook< const variables: SearchQueryVariables = { input: { term: input.search, - collectionId: input.categoryId, + collectionId: input.categoryId?.toString(), groupByProduct: true, // TODO: what is the "sort" value? }, diff --git a/framework/vendure/schema.d.ts b/framework/vendure/schema.d.ts index 78e821257..9d6b53c52 100644 --- a/framework/vendure/schema.d.ts +++ b/framework/vendure/schema.d.ts @@ -437,6 +437,13 @@ export type ProductVariantList = PaginatedList & { totalItems: Scalars['Int'] } +export type ProductVariantListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + export enum GlobalFlag { True = 'TRUE', False = 'FALSE', @@ -463,6 +470,7 @@ export enum DeletionResult { * @docsCategory common */ export enum Permission { + Placeholder = 'Placeholder', /** Authenticated means simply that the user is logged in */ Authenticated = 'Authenticated', /** SuperAdmin has unrestricted access to all operations */ @@ -471,22 +479,24 @@ export enum Permission { Owner = 'Owner', /** Public means any unauthenticated user may perform the operation */ Public = 'Public', - /** Grants permission to create Catalog */ + /** Grants permission to update GlobalSettings */ + UpdateGlobalSettings = 'UpdateGlobalSettings', + /** Grants permission to create Products, Facets, Assets, Collections */ CreateCatalog = 'CreateCatalog', - /** Grants permission to read Catalog */ + /** Grants permission to read Products, Facets, Assets, Collections */ ReadCatalog = 'ReadCatalog', - /** Grants permission to update Catalog */ + /** Grants permission to update Products, Facets, Assets, Collections */ UpdateCatalog = 'UpdateCatalog', - /** Grants permission to delete Catalog */ + /** Grants permission to delete Products, Facets, Assets, Collections */ DeleteCatalog = 'DeleteCatalog', - /** Grants permission to create Customer */ - CreateCustomer = 'CreateCustomer', - /** Grants permission to read Customer */ - ReadCustomer = 'ReadCustomer', - /** Grants permission to update Customer */ - UpdateCustomer = 'UpdateCustomer', - /** Grants permission to delete Customer */ - DeleteCustomer = 'DeleteCustomer', + /** Grants permission to create PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings */ + CreateSettings = 'CreateSettings', + /** Grants permission to read PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings */ + ReadSettings = 'ReadSettings', + /** Grants permission to update PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings */ + UpdateSettings = 'UpdateSettings', + /** Grants permission to delete PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings */ + DeleteSettings = 'DeleteSettings', /** Grants permission to create Administrator */ CreateAdministrator = 'CreateAdministrator', /** Grants permission to read Administrator */ @@ -495,6 +505,62 @@ export enum Permission { UpdateAdministrator = 'UpdateAdministrator', /** Grants permission to delete Administrator */ DeleteAdministrator = 'DeleteAdministrator', + /** Grants permission to create Asset */ + CreateAsset = 'CreateAsset', + /** Grants permission to read Asset */ + ReadAsset = 'ReadAsset', + /** Grants permission to update Asset */ + UpdateAsset = 'UpdateAsset', + /** Grants permission to delete Asset */ + DeleteAsset = 'DeleteAsset', + /** Grants permission to create Channel */ + CreateChannel = 'CreateChannel', + /** Grants permission to read Channel */ + ReadChannel = 'ReadChannel', + /** Grants permission to update Channel */ + UpdateChannel = 'UpdateChannel', + /** Grants permission to delete Channel */ + DeleteChannel = 'DeleteChannel', + /** Grants permission to create Collection */ + CreateCollection = 'CreateCollection', + /** Grants permission to read Collection */ + ReadCollection = 'ReadCollection', + /** Grants permission to update Collection */ + UpdateCollection = 'UpdateCollection', + /** Grants permission to delete Collection */ + DeleteCollection = 'DeleteCollection', + /** Grants permission to create Country */ + CreateCountry = 'CreateCountry', + /** Grants permission to read Country */ + ReadCountry = 'ReadCountry', + /** Grants permission to update Country */ + UpdateCountry = 'UpdateCountry', + /** Grants permission to delete Country */ + DeleteCountry = 'DeleteCountry', + /** Grants permission to create Customer */ + CreateCustomer = 'CreateCustomer', + /** Grants permission to read Customer */ + ReadCustomer = 'ReadCustomer', + /** Grants permission to update Customer */ + UpdateCustomer = 'UpdateCustomer', + /** Grants permission to delete Customer */ + DeleteCustomer = 'DeleteCustomer', + /** Grants permission to create CustomerGroup */ + CreateCustomerGroup = 'CreateCustomerGroup', + /** Grants permission to read CustomerGroup */ + ReadCustomerGroup = 'ReadCustomerGroup', + /** Grants permission to update CustomerGroup */ + UpdateCustomerGroup = 'UpdateCustomerGroup', + /** Grants permission to delete CustomerGroup */ + DeleteCustomerGroup = 'DeleteCustomerGroup', + /** Grants permission to create Facet */ + CreateFacet = 'CreateFacet', + /** Grants permission to read Facet */ + ReadFacet = 'ReadFacet', + /** Grants permission to update Facet */ + UpdateFacet = 'UpdateFacet', + /** Grants permission to delete Facet */ + DeleteFacet = 'DeleteFacet', /** Grants permission to create Order */ CreateOrder = 'CreateOrder', /** Grants permission to read Order */ @@ -503,6 +569,22 @@ export enum Permission { UpdateOrder = 'UpdateOrder', /** Grants permission to delete Order */ DeleteOrder = 'DeleteOrder', + /** Grants permission to create PaymentMethod */ + CreatePaymentMethod = 'CreatePaymentMethod', + /** Grants permission to read PaymentMethod */ + ReadPaymentMethod = 'ReadPaymentMethod', + /** Grants permission to update PaymentMethod */ + UpdatePaymentMethod = 'UpdatePaymentMethod', + /** Grants permission to delete PaymentMethod */ + DeletePaymentMethod = 'DeletePaymentMethod', + /** Grants permission to create Product */ + CreateProduct = 'CreateProduct', + /** Grants permission to read Product */ + ReadProduct = 'ReadProduct', + /** Grants permission to update Product */ + UpdateProduct = 'UpdateProduct', + /** Grants permission to delete Product */ + DeleteProduct = 'DeleteProduct', /** Grants permission to create Promotion */ CreatePromotion = 'CreatePromotion', /** Grants permission to read Promotion */ @@ -511,14 +593,54 @@ export enum Permission { UpdatePromotion = 'UpdatePromotion', /** Grants permission to delete Promotion */ DeletePromotion = 'DeletePromotion', - /** Grants permission to create Settings */ - CreateSettings = 'CreateSettings', - /** Grants permission to read Settings */ - ReadSettings = 'ReadSettings', - /** Grants permission to update Settings */ - UpdateSettings = 'UpdateSettings', - /** Grants permission to delete Settings */ - DeleteSettings = 'DeleteSettings', + /** Grants permission to create ShippingMethod */ + CreateShippingMethod = 'CreateShippingMethod', + /** Grants permission to read ShippingMethod */ + ReadShippingMethod = 'ReadShippingMethod', + /** Grants permission to update ShippingMethod */ + UpdateShippingMethod = 'UpdateShippingMethod', + /** Grants permission to delete ShippingMethod */ + DeleteShippingMethod = 'DeleteShippingMethod', + /** Grants permission to create Tag */ + CreateTag = 'CreateTag', + /** Grants permission to read Tag */ + ReadTag = 'ReadTag', + /** Grants permission to update Tag */ + UpdateTag = 'UpdateTag', + /** Grants permission to delete Tag */ + DeleteTag = 'DeleteTag', + /** Grants permission to create TaxCategory */ + CreateTaxCategory = 'CreateTaxCategory', + /** Grants permission to read TaxCategory */ + ReadTaxCategory = 'ReadTaxCategory', + /** Grants permission to update TaxCategory */ + UpdateTaxCategory = 'UpdateTaxCategory', + /** Grants permission to delete TaxCategory */ + DeleteTaxCategory = 'DeleteTaxCategory', + /** Grants permission to create TaxRate */ + CreateTaxRate = 'CreateTaxRate', + /** Grants permission to read TaxRate */ + ReadTaxRate = 'ReadTaxRate', + /** Grants permission to update TaxRate */ + UpdateTaxRate = 'UpdateTaxRate', + /** Grants permission to delete TaxRate */ + DeleteTaxRate = 'DeleteTaxRate', + /** Grants permission to create System */ + CreateSystem = 'CreateSystem', + /** Grants permission to read System */ + ReadSystem = 'ReadSystem', + /** Grants permission to update System */ + UpdateSystem = 'UpdateSystem', + /** Grants permission to delete System */ + DeleteSystem = 'DeleteSystem', + /** Grants permission to create Zone */ + CreateZone = 'CreateZone', + /** Grants permission to read Zone */ + ReadZone = 'ReadZone', + /** Grants permission to update Zone */ + UpdateZone = 'UpdateZone', + /** Grants permission to delete Zone */ + DeleteZone = 'DeleteZone', } export enum SortOrder { @@ -734,10 +856,24 @@ export type DateOperators = { between?: Maybe } +/** + * Used to construct boolean expressions for filtering search results + * by FacetValue ID. Examples: + * + * * ID=1 OR ID=2: `{ facetValueFilters: [{ or: [1,2] }] }` + * * ID=1 AND ID=2: `{ facetValueFilters: [{ and: 1 }, { and: 2 }] }` + * * ID=1 AND (ID=2 OR ID=3): `{ facetValueFilters: [{ and: 1 }, { or: [2,3] }] }` + */ +export type FacetValueFilterInput = { + and?: Maybe + or?: Maybe> +} + export type SearchInput = { term?: Maybe facetValueIds?: Maybe> facetValueOperator?: Maybe + facetValueFilters?: Maybe> collectionId?: Maybe collectionSlug?: Maybe groupByProduct?: Maybe @@ -802,6 +938,7 @@ export type ShippingMethodQuote = { id: Scalars['ID'] price: Scalars['Int'] priceWithTax: Scalars['Int'] + code: Scalars['String'] name: Scalars['String'] description: Scalars['String'] /** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */ @@ -812,6 +949,8 @@ export type PaymentMethodQuote = { __typename?: 'PaymentMethodQuote' id: Scalars['ID'] code: Scalars['String'] + name: Scalars['String'] + description: Scalars['String'] isEligible: Scalars['Boolean'] eligibilityMessage?: Maybe } @@ -1307,6 +1446,13 @@ export type CustomerGroupCustomersArgs = { options?: Maybe } +export type CustomerListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + export type Customer = Node & { __typename?: 'Customer' id: Scalars['ID'] @@ -1425,6 +1571,13 @@ export type HistoryEntryList = PaginatedList & { totalItems: Scalars['Int'] } +export type HistoryEntryListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + /** * @description * Languages in the form of a ISO 639-1 language code with optional @@ -1777,12 +1930,7 @@ export type Order = Node & { * methods. */ surcharges: Array - /** - * Order-level adjustments to the order total, such as discounts from promotions - * @deprecated Use `discounts` instead - */ - adjustments: Array - discounts: Array + discounts: Array /** An array of all coupon codes applied to the Order */ couponCodes: Array /** Promotions applied to the order. Only gets populated after the payment process has completed. */ @@ -1861,7 +2009,16 @@ export type ShippingLine = { priceWithTax: Scalars['Int'] discountedPrice: Scalars['Int'] discountedPriceWithTax: Scalars['Int'] - discounts: Array + discounts: Array +} + +export type Discount = { + __typename?: 'Discount' + adjustmentSource: Scalars['String'] + type: AdjustmentType + description: Scalars['String'] + amount: Scalars['Int'] + amountWithTax: Scalars['Int'] } export type OrderItem = Node & { @@ -1894,8 +2051,6 @@ export type OrderItem = Node & { /** The proratedUnitPrice including tax */ proratedUnitPriceWithTax: Scalars['Int'] unitTax: Scalars['Int'] - /** @deprecated `unitPrice` is now always without tax */ - unitPriceIncludesTax: Scalars['Boolean'] taxRate: Scalars['Float'] adjustments: Array taxLines: Array @@ -1939,8 +2094,6 @@ export type OrderLine = Node & { proratedUnitPriceWithTax: Scalars['Int'] quantity: Scalars['Int'] items: Array - /** @deprecated Use `linePriceWithTax` instead */ - totalPrice: Scalars['Int'] taxRate: Scalars['Float'] /** The total price of the line excluding tax and discounts. */ linePrice: Scalars['Int'] @@ -1960,9 +2113,7 @@ export type OrderLine = Node & { proratedLinePriceWithTax: Scalars['Int'] /** The total tax on this line */ lineTax: Scalars['Int'] - /** @deprecated Use `discounts` instead */ - adjustments: Array - discounts: Array + discounts: Array taxLines: Array order: Order customFields?: Maybe @@ -2105,13 +2256,9 @@ export type SearchResult = { slug: Scalars['String'] productId: Scalars['ID'] productName: Scalars['String'] - /** @deprecated Use `productAsset.preview` instead */ - productPreview: Scalars['String'] productAsset?: Maybe productVariantId: Scalars['ID'] productVariantName: Scalars['String'] - /** @deprecated Use `productVariantAsset.preview` instead */ - productVariantPreview: Scalars['String'] productVariantAsset?: Maybe price: SearchResultPrice priceWithTax: SearchResultPrice @@ -2191,8 +2338,6 @@ export type ProductVariant = Node & { assets: Array price: Scalars['Int'] currencyCode: CurrencyCode - /** @deprecated price now always excludes tax */ - priceIncludesTax: Scalars['Boolean'] priceWithTax: Scalars['Int'] stockLevel: Scalars['String'] taxRateApplied: TaxRate @@ -2200,7 +2345,7 @@ export type ProductVariant = Node & { options: Array facetValues: Array translations: Array - customFields?: Maybe + customFields?: Maybe } export type ProductVariantTranslation = { @@ -2524,6 +2669,10 @@ export type NoActiveOrderError = ErrorResult & { message: Scalars['String'] } +export type AuthenticationInput = { + native?: Maybe +} + export type RegisterCustomerInput = { emailAddress: Scalars['String'] title?: Maybe @@ -2541,6 +2690,10 @@ export type UpdateCustomerInput = { customFields?: Maybe } +export type UpdateOrderInput = { + customFields?: Maybe +} + /** Passed as input to the `addPaymentToOrder` mutation. */ export type PaymentInput = { /** This field should correspond to the `code` property of a PaymentMethodHandler. */ @@ -2553,6 +2706,27 @@ export type PaymentInput = { metadata: Scalars['JSON'] } +export type CollectionListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + +export type OrderListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + +export type ProductListOptions = { + skip?: Maybe + take?: Maybe + sort?: Maybe + filter?: Maybe +} + export type UpdateOrderItemsResult = | Order | OrderModificationError @@ -2646,48 +2820,6 @@ export type AuthenticationResult = export type ActiveOrderResult = Order | NoActiveOrderError -export type CollectionListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - -export type ProductListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - -export type ProductVariantListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - -export type CustomerListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - -export type OrderListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - -export type HistoryEntryListOptions = { - skip?: Maybe - take?: Maybe - sort?: Maybe - filter?: Maybe -} - export type CollectionFilterParameter = { createdAt?: Maybe updatedAt?: Maybe @@ -2734,9 +2866,9 @@ export type ProductVariantFilterParameter = { name?: Maybe price?: Maybe currencyCode?: Maybe - priceIncludesTax?: Maybe priceWithTax?: Maybe stockLevel?: Maybe + discountPrice?: Maybe } export type ProductVariantSortParameter = { @@ -2749,6 +2881,7 @@ export type ProductVariantSortParameter = { price?: Maybe priceWithTax?: Maybe stockLevel?: Maybe + discountPrice?: Maybe } export type CustomerFilterParameter = { @@ -2817,12 +2950,9 @@ export type HistoryEntrySortParameter = { updatedAt?: Maybe } -export type UpdateOrderInput = { - customFields?: Maybe -} - -export type AuthenticationInput = { - native?: Maybe +export type ProductVariantCustomFields = { + __typename?: 'ProductVariantCustomFields' + discountPrice?: Maybe } export type NativeAuthInput = { @@ -2846,14 +2976,19 @@ export type CartFragment = { __typename?: 'Order' } & Pick< lines: Array< { __typename?: 'OrderLine' } & Pick< OrderLine, - 'id' | 'quantity' | 'linePriceWithTax' | 'discountedLinePriceWithTax' + | 'id' + | 'quantity' + | 'linePriceWithTax' + | 'discountedLinePriceWithTax' + | 'unitPriceWithTax' + | 'discountedUnitPriceWithTax' > & { featuredAsset?: Maybe< { __typename?: 'Asset' } & Pick > discounts: Array< - { __typename?: 'Adjustment' } & Pick< - Adjustment, + { __typename?: 'Discount' } & Pick< + Discount, 'description' | 'amount' > > @@ -2886,51 +3021,6 @@ export type SearchResultFragment = { __typename?: 'SearchResult' } & Pick< | ({ __typename?: 'SinglePrice' } & Pick) } -export type LoginMutationVariables = Exact<{ - username: Scalars['String'] - password: Scalars['String'] -}> - -export type LoginMutation = { __typename?: 'Mutation' } & { - login: - | ({ __typename: 'CurrentUser' } & Pick) - | ({ __typename: 'InvalidCredentialsError' } & Pick< - InvalidCredentialsError, - 'errorCode' | 'message' - >) - | ({ __typename: 'NotVerifiedError' } & Pick< - NotVerifiedError, - 'errorCode' | 'message' - >) - | ({ __typename: 'NativeAuthStrategyError' } & Pick< - NativeAuthStrategyError, - 'errorCode' | 'message' - >) -} - -export type LogoutMutationVariables = Exact<{ [key: string]: never }> - -export type LogoutMutation = { __typename?: 'Mutation' } & { - logout: { __typename?: 'Success' } & Pick -} - -export type SignupMutationVariables = Exact<{ - input: RegisterCustomerInput -}> - -export type SignupMutation = { __typename?: 'Mutation' } & { - registerCustomerAccount: - | ({ __typename: 'Success' } & Pick) - | ({ __typename: 'MissingPasswordError' } & Pick< - MissingPasswordError, - 'errorCode' | 'message' - >) - | ({ __typename: 'NativeAuthStrategyError' } & Pick< - NativeAuthStrategyError, - 'errorCode' | 'message' - >) -} - export type AddItemToOrderMutationVariables = Exact<{ variantId: Scalars['ID'] quantity: Scalars['Int'] @@ -2957,25 +3047,6 @@ export type AddItemToOrderMutation = { __typename?: 'Mutation' } & { >) } -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' } & Pick< - OrderModificationError, - 'errorCode' | 'message' - >) -} - export type AdjustOrderLineMutationVariables = Exact<{ orderLineId: Scalars['ID'] quantity: Scalars['Int'] @@ -3002,26 +3073,62 @@ export type AdjustOrderLineMutation = { __typename?: 'Mutation' } & { >) } -export type GetCollectionsQueryVariables = Exact<{ [key: string]: never }> +export type LoginMutationVariables = Exact<{ + username: Scalars['String'] + password: Scalars['String'] +}> -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> - children?: Maybe< - Array<{ __typename?: 'Collection' } & Pick> - > - } - > - } +export type LoginMutation = { __typename?: 'Mutation' } & { + login: + | ({ __typename: 'CurrentUser' } & Pick) + | ({ __typename: 'InvalidCredentialsError' } & Pick< + InvalidCredentialsError, + 'errorCode' | 'message' + >) + | ({ __typename: 'NotVerifiedError' } & Pick< + NotVerifiedError, + 'errorCode' | 'message' + >) + | ({ __typename: 'NativeAuthStrategyError' } & Pick< + NativeAuthStrategyError, + 'errorCode' | 'message' + >) +} + +export type LogoutMutationVariables = Exact<{ [key: string]: never }> + +export type LogoutMutation = { __typename?: 'Mutation' } & { + logout: { __typename?: 'Success' } & Pick +} + +export type RemoveOrderLineMutationVariables = Exact<{ + orderLineId: Scalars['ID'] +}> + +export type RemoveOrderLineMutation = { __typename?: 'Mutation' } & { + removeOrderLine: + | ({ __typename: 'Order' } & CartFragment) + | ({ __typename: 'OrderModificationError' } & Pick< + OrderModificationError, + 'errorCode' | 'message' + >) +} + +export type SignupMutationVariables = Exact<{ + input: RegisterCustomerInput +}> + +export type SignupMutation = { __typename?: 'Mutation' } & { + registerCustomerAccount: + | ({ __typename: 'Success' } & Pick) + | ({ __typename: 'MissingPasswordError' } & Pick< + MissingPasswordError, + 'errorCode' | 'message' + >) + | ({ __typename: 'NativeAuthStrategyError' } & Pick< + NativeAuthStrategyError, + 'errorCode' | 'message' + >) } export type ActiveCustomerQueryVariables = Exact<{ [key: string]: never }> @@ -3055,6 +3162,34 @@ export type GetAllProductsQuery = { __typename?: 'Query' } & { } } +export type ActiveOrderQueryVariables = Exact<{ [key: string]: never }> + +export type ActiveOrderQuery = { __typename?: 'Query' } & { + activeOrder?: Maybe<{ __typename?: 'Order' } & CartFragment> +} + +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> + children?: Maybe< + Array<{ __typename?: 'Collection' } & Pick> + > + } + > + } +} + export type GetProductQueryVariables = Exact<{ slug: Scalars['String'] }> diff --git a/framework/vendure/schema.graphql b/framework/vendure/schema.graphql index 88812044e..326e2bca5 100644 --- a/framework/vendure/schema.graphql +++ b/framework/vendure/schema.graphql @@ -386,6 +386,13 @@ type ProductVariantList implements PaginatedList { totalItems: Int! } +input ProductVariantListOptions { + skip: Int + take: Int + sort: ProductVariantSortParameter + filter: ProductVariantFilterParameter +} + enum GlobalFlag { TRUE FALSE @@ -417,6 +424,8 @@ GraphQL resolvers via the {@link Allow} decorator. @docsCategory common """ enum Permission { + Placeholder + """ Authenticated means simply that the user is logged in """ @@ -438,44 +447,49 @@ enum Permission { Public """ - Grants permission to create Catalog + Grants permission to update GlobalSettings + """ + UpdateGlobalSettings + + """ + Grants permission to create Products, Facets, Assets, Collections """ CreateCatalog """ - Grants permission to read Catalog + Grants permission to read Products, Facets, Assets, Collections """ ReadCatalog """ - Grants permission to update Catalog + Grants permission to update Products, Facets, Assets, Collections """ UpdateCatalog """ - Grants permission to delete Catalog + Grants permission to delete Products, Facets, Assets, Collections """ DeleteCatalog """ - Grants permission to create Customer + Grants permission to create PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings """ - CreateCustomer + CreateSettings """ - Grants permission to read Customer + Grants permission to read PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings """ - ReadCustomer + ReadSettings """ - Grants permission to update Customer + Grants permission to update PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings """ - UpdateCustomer + UpdateSettings """ - Grants permission to delete Customer + Grants permission to delete PaymentMethods, ShippingMethods, TaxCategories, TaxRates, Zones, Countries, System & GlobalSettings """ - DeleteCustomer + DeleteSettings """ Grants permission to create Administrator @@ -497,6 +511,146 @@ enum Permission { """ DeleteAdministrator + """ + Grants permission to create Asset + """ + CreateAsset + + """ + Grants permission to read Asset + """ + ReadAsset + + """ + Grants permission to update Asset + """ + UpdateAsset + + """ + Grants permission to delete Asset + """ + DeleteAsset + + """ + Grants permission to create Channel + """ + CreateChannel + + """ + Grants permission to read Channel + """ + ReadChannel + + """ + Grants permission to update Channel + """ + UpdateChannel + + """ + Grants permission to delete Channel + """ + DeleteChannel + + """ + Grants permission to create Collection + """ + CreateCollection + + """ + Grants permission to read Collection + """ + ReadCollection + + """ + Grants permission to update Collection + """ + UpdateCollection + + """ + Grants permission to delete Collection + """ + DeleteCollection + + """ + Grants permission to create Country + """ + CreateCountry + + """ + Grants permission to read Country + """ + ReadCountry + + """ + Grants permission to update Country + """ + UpdateCountry + + """ + Grants permission to delete Country + """ + DeleteCountry + + """ + Grants permission to create Customer + """ + CreateCustomer + + """ + Grants permission to read Customer + """ + ReadCustomer + + """ + Grants permission to update Customer + """ + UpdateCustomer + + """ + Grants permission to delete Customer + """ + DeleteCustomer + + """ + Grants permission to create CustomerGroup + """ + CreateCustomerGroup + + """ + Grants permission to read CustomerGroup + """ + ReadCustomerGroup + + """ + Grants permission to update CustomerGroup + """ + UpdateCustomerGroup + + """ + Grants permission to delete CustomerGroup + """ + DeleteCustomerGroup + + """ + Grants permission to create Facet + """ + CreateFacet + + """ + Grants permission to read Facet + """ + ReadFacet + + """ + Grants permission to update Facet + """ + UpdateFacet + + """ + Grants permission to delete Facet + """ + DeleteFacet + """ Grants permission to create Order """ @@ -517,6 +671,46 @@ enum Permission { """ DeleteOrder + """ + Grants permission to create PaymentMethod + """ + CreatePaymentMethod + + """ + Grants permission to read PaymentMethod + """ + ReadPaymentMethod + + """ + Grants permission to update PaymentMethod + """ + UpdatePaymentMethod + + """ + Grants permission to delete PaymentMethod + """ + DeletePaymentMethod + + """ + Grants permission to create Product + """ + CreateProduct + + """ + Grants permission to read Product + """ + ReadProduct + + """ + Grants permission to update Product + """ + UpdateProduct + + """ + Grants permission to delete Product + """ + DeleteProduct + """ Grants permission to create Promotion """ @@ -538,24 +732,124 @@ enum Permission { DeletePromotion """ - Grants permission to create Settings + Grants permission to create ShippingMethod """ - CreateSettings + CreateShippingMethod """ - Grants permission to read Settings + Grants permission to read ShippingMethod """ - ReadSettings + ReadShippingMethod """ - Grants permission to update Settings + Grants permission to update ShippingMethod """ - UpdateSettings + UpdateShippingMethod """ - Grants permission to delete Settings + Grants permission to delete ShippingMethod """ - DeleteSettings + DeleteShippingMethod + + """ + Grants permission to create Tag + """ + CreateTag + + """ + Grants permission to read Tag + """ + ReadTag + + """ + Grants permission to update Tag + """ + UpdateTag + + """ + Grants permission to delete Tag + """ + DeleteTag + + """ + Grants permission to create TaxCategory + """ + CreateTaxCategory + + """ + Grants permission to read TaxCategory + """ + ReadTaxCategory + + """ + Grants permission to update TaxCategory + """ + UpdateTaxCategory + + """ + Grants permission to delete TaxCategory + """ + DeleteTaxCategory + + """ + Grants permission to create TaxRate + """ + CreateTaxRate + + """ + Grants permission to read TaxRate + """ + ReadTaxRate + + """ + Grants permission to update TaxRate + """ + UpdateTaxRate + + """ + Grants permission to delete TaxRate + """ + DeleteTaxRate + + """ + Grants permission to create System + """ + CreateSystem + + """ + Grants permission to read System + """ + ReadSystem + + """ + Grants permission to update System + """ + UpdateSystem + + """ + Grants permission to delete System + """ + DeleteSystem + + """ + Grants permission to create Zone + """ + CreateZone + + """ + Grants permission to read Zone + """ + ReadZone + + """ + Grants permission to update Zone + """ + UpdateZone + + """ + Grants permission to delete Zone + """ + DeleteZone } enum SortOrder { @@ -789,10 +1083,24 @@ input DateOperators { between: DateRange } +""" +Used to construct boolean expressions for filtering search results +by FacetValue ID. Examples: + +* ID=1 OR ID=2: `{ facetValueFilters: [{ or: [1,2] }] }` +* ID=1 AND ID=2: `{ facetValueFilters: [{ and: 1 }, { and: 2 }] }` +* ID=1 AND (ID=2 OR ID=3): `{ facetValueFilters: [{ and: 1 }, { or: [2,3] }] }` +""" +input FacetValueFilterInput { + and: ID + or: [ID!] +} + input SearchInput { term: String facetValueIds: [ID!] facetValueOperator: LogicalOperator + facetValueFilters: [FacetValueFilterInput!] collectionId: ID collectionSlug: String groupByProduct: Boolean @@ -857,6 +1165,7 @@ type ShippingMethodQuote { id: ID! price: Int! priceWithTax: Int! + code: String! name: String! description: String! @@ -869,6 +1178,8 @@ type ShippingMethodQuote { type PaymentMethodQuote { id: ID! code: String! + name: String! + description: String! isEligible: Boolean! eligibilityMessage: String } @@ -1817,6 +2128,13 @@ type CustomerGroup implements Node { customers(options: CustomerListOptions): CustomerList! } +input CustomerListOptions { + skip: Int + take: Int + sort: CustomerSortParameter + filter: CustomerFilterParameter +} + type Customer implements Node { id: ID! createdAt: DateTime! @@ -1922,6 +2240,13 @@ type HistoryEntryList implements PaginatedList { totalItems: Int! } +input HistoryEntryListOptions { + skip: Int + take: Int + sort: HistoryEntrySortParameter + filter: HistoryEntryFilterParameter +} + """ @description Languages in the form of a ISO 639-1 language code with optional @@ -2751,12 +3076,7 @@ type Order implements Node { methods. """ surcharges: [Surcharge!]! - - """ - Order-level adjustments to the order total, such as discounts from promotions - """ - adjustments: [Adjustment!]! @deprecated(reason: "Use `discounts` instead") - discounts: [Adjustment!]! + discounts: [Discount!]! """ An array of all coupon codes applied to the Order @@ -2857,7 +3177,15 @@ type ShippingLine { priceWithTax: Int! discountedPrice: Int! discountedPriceWithTax: Int! - discounts: [Adjustment!]! + discounts: [Discount!]! +} + +type Discount { + adjustmentSource: String! + type: AdjustmentType! + description: String! + amount: Int! + amountWithTax: Int! } type OrderItem implements Node { @@ -2903,8 +3231,6 @@ type OrderItem implements Node { """ proratedUnitPriceWithTax: Int! unitTax: Int! - unitPriceIncludesTax: Boolean! - @deprecated(reason: "`unitPrice` is now always without tax") taxRate: Float! adjustments: [Adjustment!]! taxLines: [TaxLine!]! @@ -2967,7 +3293,6 @@ type OrderLine implements Node { proratedUnitPriceWithTax: Int! quantity: Int! items: [OrderItem!]! - totalPrice: Int! @deprecated(reason: "Use `linePriceWithTax` instead") taxRate: Float! """ @@ -3006,8 +3331,7 @@ type OrderLine implements Node { The total tax on this line """ lineTax: Int! - adjustments: [Adjustment!]! @deprecated(reason: "Use `discounts` instead") - discounts: [Adjustment!]! + discounts: [Discount!]! taxLines: [TaxLine!]! order: Order! customFields: JSON @@ -3137,13 +3461,9 @@ type SearchResult { slug: String! productId: ID! productName: String! - productPreview: String! - @deprecated(reason: "Use `productAsset.preview` instead") productAsset: SearchResultAsset productVariantId: ID! productVariantName: String! - productVariantPreview: String! - @deprecated(reason: "Use `productVariantAsset.preview` instead") productVariantAsset: SearchResultAsset price: SearchResultPrice! priceWithTax: SearchResultPrice! @@ -3229,8 +3549,6 @@ type ProductVariant implements Node { assets: [Asset!]! price: Int! currencyCode: CurrencyCode! - priceIncludesTax: Boolean! - @deprecated(reason: "price now always excludes tax") priceWithTax: Int! stockLevel: String! taxRateApplied: TaxRate! @@ -3238,7 +3556,7 @@ type ProductVariant implements Node { options: [ProductOption!]! facetValues: [FacetValue!]! translations: [ProductVariantTranslation!]! - customFields: JSON + customFields: ProductVariantCustomFields } type ProductVariantTranslation { @@ -3550,6 +3868,10 @@ type NoActiveOrderError implements ErrorResult { message: String! } +input AuthenticationInput { + native: NativeAuthInput +} + input RegisterCustomerInput { emailAddress: String! title: String @@ -3567,6 +3889,10 @@ input UpdateCustomerInput { customFields: JSON } +input UpdateOrderInput { + customFields: JSON +} + """ Passed as input to the `addPaymentToOrder` mutation. """ @@ -3584,6 +3910,27 @@ input PaymentInput { metadata: JSON! } +input CollectionListOptions { + skip: Int + take: Int + sort: CollectionSortParameter + filter: CollectionFilterParameter +} + +input OrderListOptions { + skip: Int + take: Int + sort: OrderSortParameter + filter: OrderFilterParameter +} + +input ProductListOptions { + skip: Int + take: Int + sort: ProductSortParameter + filter: ProductFilterParameter +} + union UpdateOrderItemsResult = Order | OrderModificationError @@ -3675,48 +4022,6 @@ union AuthenticationResult = union ActiveOrderResult = Order | NoActiveOrderError -input CollectionListOptions { - skip: Int - take: Int - sort: CollectionSortParameter - filter: CollectionFilterParameter -} - -input ProductListOptions { - skip: Int - take: Int - sort: ProductSortParameter - filter: ProductFilterParameter -} - -input ProductVariantListOptions { - skip: Int - take: Int - sort: ProductVariantSortParameter - filter: ProductVariantFilterParameter -} - -input CustomerListOptions { - skip: Int - take: Int - sort: CustomerSortParameter - filter: CustomerFilterParameter -} - -input OrderListOptions { - skip: Int - take: Int - sort: OrderSortParameter - filter: OrderFilterParameter -} - -input HistoryEntryListOptions { - skip: Int - take: Int - sort: HistoryEntrySortParameter - filter: HistoryEntryFilterParameter -} - input CollectionFilterParameter { createdAt: DateOperators updatedAt: DateOperators @@ -3763,9 +4068,9 @@ input ProductVariantFilterParameter { name: StringOperators price: NumberOperators currencyCode: StringOperators - priceIncludesTax: BooleanOperators priceWithTax: NumberOperators stockLevel: StringOperators + discountPrice: NumberOperators } input ProductVariantSortParameter { @@ -3778,6 +4083,7 @@ input ProductVariantSortParameter { price: SortOrder priceWithTax: SortOrder stockLevel: SortOrder + discountPrice: SortOrder } input CustomerFilterParameter { @@ -3846,12 +4152,8 @@ input HistoryEntrySortParameter { updatedAt: SortOrder } -input UpdateOrderInput { - customFields: JSON -} - -input AuthenticationInput { - native: NativeAuthInput +type ProductVariantCustomFields { + discountPrice: Int } input NativeAuthInput { diff --git a/framework/vendure/types.ts b/framework/vendure/types.ts deleted file mode 100644 index ed39b5493..000000000 --- a/framework/vendure/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as Core from '@commerce/types' - -export interface LineItem extends Core.LineItem { - options?: any[] -} diff --git a/framework/vendure/types/cart.ts b/framework/vendure/types/cart.ts new file mode 100644 index 000000000..6ed5c6c64 --- /dev/null +++ b/framework/vendure/types/cart.ts @@ -0,0 +1 @@ +export * from '@commerce/types/cart' diff --git a/framework/vendure/types/checkout.ts b/framework/vendure/types/checkout.ts new file mode 100644 index 000000000..4e2412ef6 --- /dev/null +++ b/framework/vendure/types/checkout.ts @@ -0,0 +1 @@ +export * from '@commerce/types/checkout' diff --git a/framework/vendure/types/common.ts b/framework/vendure/types/common.ts new file mode 100644 index 000000000..b52c33a4d --- /dev/null +++ b/framework/vendure/types/common.ts @@ -0,0 +1 @@ +export * from '@commerce/types/common' diff --git a/framework/vendure/types/customer.ts b/framework/vendure/types/customer.ts new file mode 100644 index 000000000..87c9afcc4 --- /dev/null +++ b/framework/vendure/types/customer.ts @@ -0,0 +1 @@ +export * from '@commerce/types/customer' diff --git a/framework/vendure/types/index.ts b/framework/vendure/types/index.ts new file mode 100644 index 000000000..7ab0b7f64 --- /dev/null +++ b/framework/vendure/types/index.ts @@ -0,0 +1,25 @@ +import * as Cart from './cart' +import * as Checkout from './checkout' +import * as Common from './common' +import * as Customer from './customer' +import * as Login from './login' +import * as Logout from './logout' +import * as Page from './page' +import * as Product from './product' +import * as Signup from './signup' +import * as Site from './site' +import * as Wishlist from './wishlist' + +export type { + Cart, + Checkout, + Common, + Customer, + Login, + Logout, + Page, + Product, + Signup, + Site, + Wishlist, +} diff --git a/framework/vendure/types/login.ts b/framework/vendure/types/login.ts new file mode 100644 index 000000000..16bae8f65 --- /dev/null +++ b/framework/vendure/types/login.ts @@ -0,0 +1,12 @@ +import * as Core from '@commerce/types/login' +import type { LoginMutationVariables } from '../schema' +import { LoginBody, LoginTypes } from '@commerce/types/login' + +export * from '@commerce/types/login' + +export type LoginHook = { + data: null + actionInput: LoginBody + fetcherInput: LoginBody + body: T['body'] +} diff --git a/framework/vendure/types/logout.ts b/framework/vendure/types/logout.ts new file mode 100644 index 000000000..9f0a466af --- /dev/null +++ b/framework/vendure/types/logout.ts @@ -0,0 +1 @@ +export * from '@commerce/types/logout' diff --git a/framework/vendure/types/page.ts b/framework/vendure/types/page.ts new file mode 100644 index 000000000..20ec8ea38 --- /dev/null +++ b/framework/vendure/types/page.ts @@ -0,0 +1 @@ +export * from '@commerce/types/page' diff --git a/framework/vendure/types/product.ts b/framework/vendure/types/product.ts new file mode 100644 index 000000000..c776d58fa --- /dev/null +++ b/framework/vendure/types/product.ts @@ -0,0 +1 @@ +export * from '@commerce/types/product' diff --git a/framework/vendure/types/signup.ts b/framework/vendure/types/signup.ts new file mode 100644 index 000000000..58543c6f6 --- /dev/null +++ b/framework/vendure/types/signup.ts @@ -0,0 +1 @@ +export * from '@commerce/types/signup' diff --git a/framework/vendure/types/site.ts b/framework/vendure/types/site.ts new file mode 100644 index 000000000..bfef69cf9 --- /dev/null +++ b/framework/vendure/types/site.ts @@ -0,0 +1 @@ +export * from '@commerce/types/site' diff --git a/framework/vendure/types/wishlist.ts b/framework/vendure/types/wishlist.ts new file mode 100644 index 000000000..8907fbf82 --- /dev/null +++ b/framework/vendure/types/wishlist.ts @@ -0,0 +1 @@ +export * from '@commerce/types/wishlist' diff --git a/framework/vendure/lib/array-to-tree.ts b/framework/vendure/utils/array-to-tree.ts similarity index 100% rename from framework/vendure/lib/array-to-tree.ts rename to framework/vendure/utils/array-to-tree.ts diff --git a/framework/vendure/lib/fragments/cart-fragment.ts b/framework/vendure/utils/fragments/cart-fragment.ts similarity index 91% rename from framework/vendure/lib/fragments/cart-fragment.ts rename to framework/vendure/utils/fragments/cart-fragment.ts index 36371e07c..54ac08912 100644 --- a/framework/vendure/lib/fragments/cart-fragment.ts +++ b/framework/vendure/utils/fragments/cart-fragment.ts @@ -17,6 +17,8 @@ export const cartFragment = /* GraphQL */ ` quantity linePriceWithTax discountedLinePriceWithTax + unitPriceWithTax + discountedUnitPriceWithTax featuredAsset { id preview diff --git a/framework/vendure/lib/fragments/search-result-fragment.ts b/framework/vendure/utils/fragments/search-result-fragment.ts similarity index 100% rename from framework/vendure/lib/fragments/search-result-fragment.ts rename to framework/vendure/utils/fragments/search-result-fragment.ts diff --git a/framework/vendure/lib/mutations/add-item-to-order-mutation.ts b/framework/vendure/utils/mutations/add-item-to-order-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/add-item-to-order-mutation.ts rename to framework/vendure/utils/mutations/add-item-to-order-mutation.ts diff --git a/framework/vendure/lib/mutations/adjust-order-line-mutation.ts b/framework/vendure/utils/mutations/adjust-order-line-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/adjust-order-line-mutation.ts rename to framework/vendure/utils/mutations/adjust-order-line-mutation.ts diff --git a/framework/vendure/lib/mutations/log-in-mutation.ts b/framework/vendure/utils/mutations/log-in-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/log-in-mutation.ts rename to framework/vendure/utils/mutations/log-in-mutation.ts diff --git a/framework/vendure/lib/mutations/log-out-mutation.ts b/framework/vendure/utils/mutations/log-out-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/log-out-mutation.ts rename to framework/vendure/utils/mutations/log-out-mutation.ts diff --git a/framework/vendure/lib/mutations/remove-order-line-mutation.ts b/framework/vendure/utils/mutations/remove-order-line-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/remove-order-line-mutation.ts rename to framework/vendure/utils/mutations/remove-order-line-mutation.ts diff --git a/framework/vendure/lib/mutations/sign-up-mutation.ts b/framework/vendure/utils/mutations/sign-up-mutation.ts similarity index 100% rename from framework/vendure/lib/mutations/sign-up-mutation.ts rename to framework/vendure/utils/mutations/sign-up-mutation.ts diff --git a/framework/vendure/lib/normalize.ts b/framework/vendure/utils/normalize.ts similarity index 89% rename from framework/vendure/lib/normalize.ts rename to framework/vendure/utils/normalize.ts index c64ff2136..09c1c6e42 100644 --- a/framework/vendure/lib/normalize.ts +++ b/framework/vendure/utils/normalize.ts @@ -1,4 +1,5 @@ -import { Cart, Product } from '@commerce/types' +import { Product } from '@commerce/types/product' +import { Cart } from '@commerce/types/cart' import { CartFragment, SearchResultFragment } from '../schema' export function normalizeSearchResult(item: SearchResultFragment): Product { @@ -43,8 +44,8 @@ export function normalizeCart(order: CartFragment): Cart { id: l.productVariant.id, name: l.productVariant.name, sku: l.productVariant.sku, - price: l.discountedLinePriceWithTax / 100, - listPrice: l.linePriceWithTax / 100, + price: l.discountedUnitPriceWithTax / 100, + listPrice: l.unitPriceWithTax / 100, image: { url: l.featuredAsset?.preview + '?preset=thumb' || '', }, diff --git a/framework/vendure/lib/queries/active-customer-query.ts b/framework/vendure/utils/queries/active-customer-query.ts similarity index 100% rename from framework/vendure/lib/queries/active-customer-query.ts rename to framework/vendure/utils/queries/active-customer-query.ts diff --git a/framework/vendure/lib/queries/get-all-product-paths-query.ts b/framework/vendure/utils/queries/get-all-product-paths-query.ts similarity index 100% rename from framework/vendure/lib/queries/get-all-product-paths-query.ts rename to framework/vendure/utils/queries/get-all-product-paths-query.ts diff --git a/framework/vendure/lib/queries/get-all-products-query.ts b/framework/vendure/utils/queries/get-all-products-query.ts similarity index 100% rename from framework/vendure/lib/queries/get-all-products-query.ts rename to framework/vendure/utils/queries/get-all-products-query.ts diff --git a/framework/vendure/lib/queries/get-cart-query.ts b/framework/vendure/utils/queries/get-cart-query.ts similarity index 100% rename from framework/vendure/lib/queries/get-cart-query.ts rename to framework/vendure/utils/queries/get-cart-query.ts diff --git a/framework/vendure/lib/queries/get-collections-query.ts b/framework/vendure/utils/queries/get-collections-query.ts similarity index 100% rename from framework/vendure/lib/queries/get-collections-query.ts rename to framework/vendure/utils/queries/get-collections-query.ts diff --git a/framework/vendure/lib/queries/get-product-query.ts b/framework/vendure/utils/queries/get-product-query.ts similarity index 100% rename from framework/vendure/lib/queries/get-product-query.ts rename to framework/vendure/utils/queries/get-product-query.ts diff --git a/framework/vendure/lib/queries/search-query.ts b/framework/vendure/utils/queries/search-query.ts similarity index 100% rename from framework/vendure/lib/queries/search-query.ts rename to framework/vendure/utils/queries/search-query.ts diff --git a/framework/vendure/wishlist/use-wishlist.tsx b/framework/vendure/wishlist/use-wishlist.tsx index d2ce9db5b..da941bf31 100644 --- a/framework/vendure/wishlist/use-wishlist.tsx +++ b/framework/vendure/wishlist/use-wishlist.tsx @@ -1,5 +1,5 @@ // TODO: replace this hook and other wishlist hooks with a handler, or remove them if -// Shopify doesn't have a wishlist +// Vendure doesn't have a built-in wishlist import { HookFetcher } from '@commerce/utils/types' import { Product } from '../schema'