From 566f48e5d260d829e379797b89ba9cafd049ec39 Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Wed, 27 Mar 2024 17:13:54 +0100 Subject: [PATCH 01/10] IN-4072 Use proxy-sdk --- .changeset/thirty-socks-sleep.md | 17 + packages/api-client/package.json | 2 +- .../src/api/addBundleProductsToCart/index.ts | 6 +- .../addConfigurableProductsToCart/index.ts | 2 +- .../addDownloadableProductsToCart/index.ts | 2 +- .../src/api/addProductToWishList/index.ts | 6 +- .../src/api/addProductsToCart/index.ts | 2 +- .../src/api/addSimpleProductsToCart/index.ts | 6 +- .../src/api/addVirtualProductsToCart/index.ts | 2 +- .../src/api/applyCouponToCart/index.ts | 2 +- .../src/api/availableStores/index.ts | 6 +- packages/api-client/src/api/cart/index.ts | 2 +- .../api-client/src/api/cartTotalQty/index.ts | 2 +- .../api-client/src/api/categoryList/index.ts | 2 +- .../src/api/categorySearch/index.ts | 2 +- .../src/api/changeCustomerPassword/index.ts | 6 +- .../api-client/src/api/cmsBlocks/index.ts | 2 +- packages/api-client/src/api/cmsPage/index.ts | 2 +- .../api-client/src/api/countries/index.ts | 2 +- packages/api-client/src/api/country/index.ts | 2 +- .../src/api/createCustomer/index.ts | 6 +- .../src/api/createCustomerAddress/index.ts | 2 +- .../src/api/createEmptyCart/index.ts | 6 +- .../src/api/createProductReview/index.ts | 6 +- packages/api-client/src/api/currency/index.ts | 2 +- .../src/api/customMutation/index.ts | 2 +- .../api-client/src/api/customQuery/index.ts | 2 +- packages/api-client/src/api/customer/index.ts | 6 +- .../api-client/src/api/customerCart/index.ts | 2 +- .../src/api/customerOrders/index.ts | 2 +- .../src/api/customerProductReview/index.ts | 6 +- .../src/api/deleteCustomerAddress/index.ts | 2 +- .../src/api/generateCustomerToken/index.ts | 6 +- .../index.ts | 5 +- .../index.ts | 2 +- .../api/getAvailablePaymentMethods/index.ts | 2 +- .../api/getAvailableShippingMethods/index.ts | 2 +- .../src/api/getCustomerAddresses/index.ts | 2 +- packages/api-client/src/api/index.ts | 132 +++--- .../api-client/src/api/mergeCarts/index.ts | 6 +- .../api-client/src/api/placeOrder/index.ts | 2 +- .../src/api/productDetails/index.ts | 2 +- .../api-client/src/api/productReview/index.ts | 6 +- .../api/productReviewRatingsMetadata/index.ts | 6 +- packages/api-client/src/api/products/index.ts | 2 +- .../src/api/relatedProducts/index.ts | 2 +- .../src/api/removeCouponFromCart/index.ts | 2 +- .../src/api/removeItemFromCart/index.ts | 2 +- .../api/removeProductsFromWishlist/index.ts | 6 +- .../api/requestPasswordResetEmail/index.ts | 2 +- .../api-client/src/api/resetPassword/index.ts | 2 +- packages/api-client/src/api/reviews/index.ts | 2 +- .../src/api/revokeCustomerToken/index.ts | 6 +- packages/api-client/src/api/route/index.ts | 2 +- .../src/api/setBillingAddressOnCart/index.ts | 6 +- .../src/api/setGuestEmailOnCart/index.ts | 2 +- .../src/api/setPaymentMethodOnCart/index.ts | 2 +- .../api/setShippingAddressesOnCart/index.ts | 2 +- .../src/api/setShippingMethodsOnCart/index.ts | 2 +- .../api-client/src/api/storeConfig/index.ts | 2 +- .../api/subscribeEmailToNewsletter/index.ts | 2 +- .../src/api/updateCartItems/index.ts | 2 +- .../src/api/updateCustomer/index.ts | 6 +- .../src/api/updateCustomerAddress/index.ts | 2 +- .../src/api/updateCustomerEmail/index.ts | 6 +- .../src/api/upsellProducts/index.ts | 6 +- .../api-client/src/api/urlResolver/index.ts | 2 +- packages/api-client/src/api/wishlist/index.ts | 2 +- .../src/api/wishlistItemsCount/index.ts | 2 +- .../api-client/src/types/api/endpoints.ts | 12 + packages/api-client/src/types/api/index.ts | 1 + packages/api-client/src/types/context.ts | 5 - .../api-client/src/types/context/index.ts | 5 + packages/api-types/src/Api.ts | 381 ------------------ .../load-tests/src/query/storeConfig.gql.js | 3 +- .../tests/magento/addSimpleProductToCart.js | 28 +- .../src/tests/magento/createCustomer.js | 28 +- .../src/tests/magento/createEmptyGuestCart.js | 30 +- .../src/tests/magento/storeConfig.js | 25 +- .../src/tests/magento/utils/getHeaders.js | 2 +- .../src/tests/middleware/createCustomer.js | 36 +- .../tests/middleware/createEmptyGuestCart.js | 28 +- .../src/tests/middleware/storeConfig.js | 20 +- .../tests/middleware/utils/customerData.js | 4 +- .../src/tests/middleware/utils/getHeaders.js | 6 +- .../src/tests/scenarios/browsingProduct.js | 169 ++++---- .../tests/scenarios/buyProductAsAGuestUser.js | 318 +++++---------- .../tests/scenarios/newUserRegistration.js | 118 +++--- .../src/tests/scenarios/searchProduct.js | 170 ++++---- packages/load-tests/src/utils/customerData.js | 4 +- packages/load-tests/src/utils/getCookies.js | 6 +- .../method-bootstrapper/file-operations.js | 106 ++--- packages/method-bootstrapper/index.js | 23 +- packages/method-bootstrapper/utils.js | 4 +- yarn.lock | 8 +- 95 files changed, 673 insertions(+), 1233 deletions(-) create mode 100644 .changeset/thirty-socks-sleep.md create mode 100644 packages/api-client/src/types/api/endpoints.ts create mode 100644 packages/api-client/src/types/api/index.ts delete mode 100644 packages/api-client/src/types/context.ts create mode 100644 packages/api-client/src/types/context/index.ts diff --git a/.changeset/thirty-socks-sleep.md b/.changeset/thirty-socks-sleep.md new file mode 100644 index 000000000..08032423b --- /dev/null +++ b/.changeset/thirty-socks-sleep.md @@ -0,0 +1,17 @@ +--- +"@vue-storefront/magento-api": major +--- + +- **[BREAKING]** `Endpoints` interface. Previously, each endpoint contained `context` param, which is internal and shouldn't be exposed in the final interface. Now, `Endpoints` interface properties don't contain `context` param. If you need to use `context` param, you should use `ApiMethods` type. + +```diff +- import { Endpoints } from '@vue-storefront/magento-api'; ++ import { ApiMethods } from '@vue-storefront/magento-api'; +``` + +- **[BREAKING]** Removed `ContextualizedEndpoints` type. Use `Endpoints` instead. + +```diff +- import { ContextualizedEndpoints } from '@vue-storefront/magento-api'; ++ import { Endpoints } from '@vue-storefront/magento-api'; +``` diff --git a/packages/api-client/package.json b/packages/api-client/package.json index 437b62846..6224b5507 100644 --- a/packages/api-client/package.json +++ b/packages/api-client/package.json @@ -24,8 +24,8 @@ "dependencies": { "@apollo/client": "3.8.7", "@nuxtjs/composition-api": "0.31.0", - "@vue-storefront/middleware": "^3.5.0", "@vue-storefront/magento-types": "1.0.2", + "@vue-storefront/middleware": "^3.9.0", "agentkeepalive": "^4.2.1", "consola": "^3.1.0", "dotenv": "^16.0.1", diff --git a/packages/api-client/src/api/addBundleProductsToCart/index.ts b/packages/api-client/src/api/addBundleProductsToCart/index.ts index 531e6640b..2b6430cce 100644 --- a/packages/api-client/src/api/addBundleProductsToCart/index.ts +++ b/packages/api-client/src/api/addBundleProductsToCart/index.ts @@ -7,11 +7,11 @@ import type { CustomHeaders, } from "@vue-storefront/magento-types"; -import addBundleProductsToCart from "./addBundleProductsToCart"; +import addBundleProductsToCartQuery from "./addBundleProductsToCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const addBundleProductsToCart = async ( context: Context, input: AddBundleProductsToCartInput, customQuery: CustomQuery = { addBundleProductsToCart: "addBundleProductsToCart" }, @@ -19,7 +19,7 @@ export default async ( ): Promise> => { const { addBundleProductsToCart: addBundleProductsToCartGQL } = context.extendQuery(customQuery, { addBundleProductsToCart: { - query: addBundleProductsToCart, + query: addBundleProductsToCartQuery, variables: { input }, }, }); diff --git a/packages/api-client/src/api/addConfigurableProductsToCart/index.ts b/packages/api-client/src/api/addConfigurableProductsToCart/index.ts index 59ab547ce..dc28afafa 100644 --- a/packages/api-client/src/api/addConfigurableProductsToCart/index.ts +++ b/packages/api-client/src/api/addConfigurableProductsToCart/index.ts @@ -17,7 +17,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function addConfigurableProductsToCart( +export async function addConfigurableProductsToCart( context: Context, input: AddConfigurableProductsToCartInput, customQuery: CustomQuery = { addConfigurableProductsToCart: "addConfigurableProductsToCart" }, diff --git a/packages/api-client/src/api/addDownloadableProductsToCart/index.ts b/packages/api-client/src/api/addDownloadableProductsToCart/index.ts index 649db2a6f..13ece73a5 100644 --- a/packages/api-client/src/api/addDownloadableProductsToCart/index.ts +++ b/packages/api-client/src/api/addDownloadableProductsToCart/index.ts @@ -17,7 +17,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function addDownloadableProductsToCart( +export async function addDownloadableProductsToCart( context: Context, input: AddDownloadableProductsToCartInput, customQuery: CustomQuery = { addDownloadableProductsToCart: "addDownloadableProductsToCart" }, diff --git a/packages/api-client/src/api/addProductToWishList/index.ts b/packages/api-client/src/api/addProductToWishList/index.ts index eed0262fb..f099f0ade 100644 --- a/packages/api-client/src/api/addProductToWishList/index.ts +++ b/packages/api-client/src/api/addProductToWishList/index.ts @@ -1,11 +1,11 @@ import { FetchResult, gql } from "@apollo/client/core"; import { CustomQuery, AddProductsToWishlistMutation, AddProductsToWishlistMutationVariables } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import addProductsToWishlist from "./addProductsToWishlist"; +import addProductsToWishListQuery from "./addProductsToWishlist"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const addProductToWishList = async ( context: Context, input: AddProductsToWishlistMutationVariables, customQuery: CustomQuery = { addProductsToWishlist: "addProductsToWishlist" }, @@ -13,7 +13,7 @@ export default async ( ): Promise> => { const { addProductsToWishlist: addProductsToWishlistGQL } = context.extendQuery(customQuery, { addProductsToWishlist: { - query: addProductsToWishlist, + query: addProductsToWishListQuery, variables: { ...input }, }, }); diff --git a/packages/api-client/src/api/addProductsToCart/index.ts b/packages/api-client/src/api/addProductsToCart/index.ts index b96459318..211a0eb7e 100644 --- a/packages/api-client/src/api/addProductsToCart/index.ts +++ b/packages/api-client/src/api/addProductsToCart/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function addProductsToCart( +export async function addProductsToCart( context: Context, input: AddProductsToCartInput, customQuery: CustomQuery = { addProductsToCart: "addProductsToCart" }, diff --git a/packages/api-client/src/api/addSimpleProductsToCart/index.ts b/packages/api-client/src/api/addSimpleProductsToCart/index.ts index 69ed44843..29970e9b6 100644 --- a/packages/api-client/src/api/addSimpleProductsToCart/index.ts +++ b/packages/api-client/src/api/addSimpleProductsToCart/index.ts @@ -6,11 +6,11 @@ import { AddSimpleProductsToCartMutationVariables, } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import addSimpleProductsToCart from "./addSimpleProductsToCart"; +import addSimpleProductsToCartQuery from "./addSimpleProductsToCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const addSimpleProductsToCart = async ( context: Context, input: AddSimpleProductsToCartInput, customQuery: CustomQuery = { addSimpleProductsToCart: "addSimpleProductsToCart" }, @@ -18,7 +18,7 @@ export default async ( ): Promise> => { const { addSimpleProductsToCart: addSimpleProductsToCartGQL } = context.extendQuery(customQuery, { addSimpleProductsToCart: { - query: addSimpleProductsToCart, + query: addSimpleProductsToCartQuery, variables: { input }, }, }); diff --git a/packages/api-client/src/api/addVirtualProductsToCart/index.ts b/packages/api-client/src/api/addVirtualProductsToCart/index.ts index be9d2ca9b..5b9d13ab0 100644 --- a/packages/api-client/src/api/addVirtualProductsToCart/index.ts +++ b/packages/api-client/src/api/addVirtualProductsToCart/index.ts @@ -17,7 +17,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function addVirtualProductsToCart( +export async function addVirtualProductsToCart( context: Context, input: AddVirtualProductsToCartInput, customQuery: CustomQuery = { addVirtualProductsToCart: "addVirtualProductsToCart" }, diff --git a/packages/api-client/src/api/applyCouponToCart/index.ts b/packages/api-client/src/api/applyCouponToCart/index.ts index c44799ab8..59086255e 100644 --- a/packages/api-client/src/api/applyCouponToCart/index.ts +++ b/packages/api-client/src/api/applyCouponToCart/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function applyCouponToCart( +export async function applyCouponToCart( context: Context, input: ApplyCouponToCartInput, customQuery: CustomQuery = { applyCouponToCart: "applyCouponToCart" }, diff --git a/packages/api-client/src/api/availableStores/index.ts b/packages/api-client/src/api/availableStores/index.ts index 586f8cdb6..a207dc250 100644 --- a/packages/api-client/src/api/availableStores/index.ts +++ b/packages/api-client/src/api/availableStores/index.ts @@ -2,21 +2,21 @@ import { ApolloQueryResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { AvailableStoresQuery, CustomQuery } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import availableStores from "./availableStores"; +import availableStoresQuery from "./availableStores"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Returns list of available stores */ -export default async ( +export const availableStores = async ( context: Context, customQuery: CustomQuery = { availableStores: "availableStores" }, customHeaders: CustomHeaders = {} ): Promise> => { const { availableStores: availableStoresGQL } = context.extendQuery(customQuery, { availableStores: { - query: availableStores, + query: availableStoresQuery, }, }); diff --git a/packages/api-client/src/api/cart/index.ts b/packages/api-client/src/api/cart/index.ts index 735529f7f..4dc5c907c 100644 --- a/packages/api-client/src/api/cart/index.ts +++ b/packages/api-client/src/api/cart/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function cart( +export async function cart( context: Context, cartId: string, customQuery: CustomQuery = { cart: "cart" }, diff --git a/packages/api-client/src/api/cartTotalQty/index.ts b/packages/api-client/src/api/cartTotalQty/index.ts index be7fb5450..b50fb16f8 100644 --- a/packages/api-client/src/api/cartTotalQty/index.ts +++ b/packages/api-client/src/api/cartTotalQty/index.ts @@ -6,7 +6,7 @@ import cartTotalQtyQuery from "./cartTotalQty"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async (context: Context, cartId: string, customHeaders: CustomHeaders = {}): Promise> => +export const cartTotalQty = async (context: Context, cartId: string, customHeaders: CustomHeaders = {}): Promise> => context.client.query({ query: gql` ${cartTotalQtyQuery} diff --git a/packages/api-client/src/api/categoryList/index.ts b/packages/api-client/src/api/categoryList/index.ts index 41175909c..9b4532ee3 100644 --- a/packages/api-client/src/api/categoryList/index.ts +++ b/packages/api-client/src/api/categoryList/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function categoryList( +export async function categoryList( context: Context, params: QueryCategoryListArgs, customQuery: CustomQuery = { categoryList: "categoryList" }, diff --git a/packages/api-client/src/api/categorySearch/index.ts b/packages/api-client/src/api/categorySearch/index.ts index 342d9af69..82f5e31c9 100644 --- a/packages/api-client/src/api/categorySearch/index.ts +++ b/packages/api-client/src/api/categorySearch/index.ts @@ -15,7 +15,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function categorySearch( +export async function categorySearch( context: Context, filters: CategorySearchQueryVariables, customQuery: CustomQuery = { categorySearch: "categorySearch" }, diff --git a/packages/api-client/src/api/changeCustomerPassword/index.ts b/packages/api-client/src/api/changeCustomerPassword/index.ts index 61c85f371..e6ac15c8b 100644 --- a/packages/api-client/src/api/changeCustomerPassword/index.ts +++ b/packages/api-client/src/api/changeCustomerPassword/index.ts @@ -2,14 +2,14 @@ import { FetchResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { ChangeCustomerPasswordMutation, ChangeCustomerPasswordMutationVariables, CustomQuery } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import changeCustomerPassword from "./changeCustomerPassword"; +import changeCustomerPasswordQuery from "./changeCustomerPassword"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Changes password of the current customer. To override the default query, use the `changeCustomerPassword` query key. */ -export default async ( +export const changeCustomerPassword = async ( context: Context, params: { currentPassword: string; newPassword: string }, customQuery: CustomQuery = { changeCustomerPassword: "changeCustomerPassword" }, @@ -18,7 +18,7 @@ export default async ( try { const { changeCustomerPassword: changeCustomerPasswordGQL } = context.extendQuery(customQuery, { changeCustomerPassword: { - query: changeCustomerPassword, + query: changeCustomerPasswordQuery, variables: { ...params }, }, }); diff --git a/packages/api-client/src/api/cmsBlocks/index.ts b/packages/api-client/src/api/cmsBlocks/index.ts index f873f4923..d569c8e37 100644 --- a/packages/api-client/src/api/cmsBlocks/index.ts +++ b/packages/api-client/src/api/cmsBlocks/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] - (optional) - custom GraphQL query that extends the default cmsBlocks query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function getCmsBlocks( +export async function getCmsBlocks( context: Context, identifiers: string, customQuery: CustomQuery = { cmsBlocks: "cmsBlocks" }, diff --git a/packages/api-client/src/api/cmsPage/index.ts b/packages/api-client/src/api/cmsPage/index.ts index c44f0cb66..00a79e034 100644 --- a/packages/api-client/src/api/cmsPage/index.ts +++ b/packages/api-client/src/api/cmsPage/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param customQuery - (optional) - custom query that extends default cmsPage GraphQL query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function getCmsPage( +export async function getCmsPage( context: Context, identifier: string, customQuery: CustomQuery = { cmsPage: "cmsPage" }, diff --git a/packages/api-client/src/api/countries/index.ts b/packages/api-client/src/api/countries/index.ts index 6e8040e6c..a0705b69c 100644 --- a/packages/api-client/src/api/countries/index.ts +++ b/packages/api-client/src/api/countries/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function countries( +export async function countries( context: Context, customQuery: CustomQuery = { countries: "countries" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/country/index.ts b/packages/api-client/src/api/country/index.ts index 48df0f68f..a779f8127 100644 --- a/packages/api-client/src/api/country/index.ts +++ b/packages/api-client/src/api/country/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function country( +export async function country( context: Context, id: string, customQuery: CustomQuery = { country: "country" }, diff --git a/packages/api-client/src/api/createCustomer/index.ts b/packages/api-client/src/api/createCustomer/index.ts index 29fdb3174..da8fa0f73 100644 --- a/packages/api-client/src/api/createCustomer/index.ts +++ b/packages/api-client/src/api/createCustomer/index.ts @@ -4,14 +4,14 @@ import { CreateCustomerMutation, CreateCustomerMutationVariables, CustomerCreate import { GraphQLError } from "graphql"; import gql from "graphql-tag"; import recaptchaValidator from "../../helpers/recaptcha/recaptchaValidator"; -import createCustomer from "./createCustomer"; +import createCustomerQuery from "./createCustomer"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Registers a new customer. To override the default query, use the `createCustomer` query key. */ -export default async ( +export const createCustomer = async ( context: Context, input: CustomerCreateInput, customQuery: CustomQuery = { createCustomer: "createCustomer" }, @@ -36,7 +36,7 @@ export default async ( const { createCustomer: createCustomerGQL } = context.extendQuery(customQuery, { createCustomer: { - query: createCustomer, + query: createCustomerQuery, variables: { input: variables }, }, }); diff --git a/packages/api-client/src/api/createCustomerAddress/index.ts b/packages/api-client/src/api/createCustomerAddress/index.ts index e0337445c..158313601 100644 --- a/packages/api-client/src/api/createCustomerAddress/index.ts +++ b/packages/api-client/src/api/createCustomerAddress/index.ts @@ -19,7 +19,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function createCustomerAddress( +export async function createCustomerAddress( context: Context, input: CustomerAddressInput, customQuery: CustomQuery = { createCustomerAddress: "createCustomerAddress" }, diff --git a/packages/api-client/src/api/createEmptyCart/index.ts b/packages/api-client/src/api/createEmptyCart/index.ts index ec83d3800..416115d2d 100644 --- a/packages/api-client/src/api/createEmptyCart/index.ts +++ b/packages/api-client/src/api/createEmptyCart/index.ts @@ -2,14 +2,14 @@ import { FetchResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CreateEmptyCartMutation } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import createEmptyCart from "./createEmptyCart"; +import createEmptyCartQuery from "./createEmptyCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async (context: Context, customHeaders: CustomHeaders = {}): Promise> => +export const createEmptyCart = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => context.client.mutate({ mutation: gql` - ${createEmptyCart} + ${createEmptyCartQuery} `, context: { headers: getHeaders(context, customHeaders), diff --git a/packages/api-client/src/api/createProductReview/index.ts b/packages/api-client/src/api/createProductReview/index.ts index 58db8a41f..862a6b492 100644 --- a/packages/api-client/src/api/createProductReview/index.ts +++ b/packages/api-client/src/api/createProductReview/index.ts @@ -3,7 +3,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CreateProductReviewInput, CreateProductReviewMutation } from "@vue-storefront/magento-types"; import { GraphQLError } from "graphql"; import gql from "graphql-tag"; -import createProductReview from "./createProductReview"; +import createProductReviewQuery from "./createProductReview"; import { Context } from "../../types/context"; import recaptchaValidator from "../../helpers/recaptcha/recaptchaValidator"; import getHeaders from "../getHeaders"; @@ -11,7 +11,7 @@ import getHeaders from "../getHeaders"; /** * Creates a new product review */ -export default async ( +export const createProductReview = async ( context: Context, input: CreateProductReviewInput, customHeaders: CustomHeaders = {} @@ -34,7 +34,7 @@ export default async ( return context.client.mutate({ mutation: gql` - ${createProductReview} + ${createProductReviewQuery} `, variables: { input: variables }, context: { diff --git a/packages/api-client/src/api/currency/index.ts b/packages/api-client/src/api/currency/index.ts index 6ae07b7ea..e794c9dad 100644 --- a/packages/api-client/src/api/currency/index.ts +++ b/packages/api-client/src/api/currency/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function currency( +export async function currency( context: Context, customQuery: CustomQuery = { currency: "currency" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/customMutation/index.ts b/packages/api-client/src/api/customMutation/index.ts index 2168e1621..80a62f501 100644 --- a/packages/api-client/src/api/customMutation/index.ts +++ b/packages/api-client/src/api/customMutation/index.ts @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const customMutation = async ( context: Context, { mutation, diff --git a/packages/api-client/src/api/customQuery/index.ts b/packages/api-client/src/api/customQuery/index.ts index 942f3b57c..71fc11803 100644 --- a/packages/api-client/src/api/customQuery/index.ts +++ b/packages/api-client/src/api/customQuery/index.ts @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const customQuery = async ( context: Context, { query, diff --git a/packages/api-client/src/api/customer/index.ts b/packages/api-client/src/api/customer/index.ts index 4dfd8b1d5..d1c29bca0 100644 --- a/packages/api-client/src/api/customer/index.ts +++ b/packages/api-client/src/api/customer/index.ts @@ -1,21 +1,21 @@ import { ApolloQueryResult, gql } from "@apollo/client/core"; import { CustomQuery, CustomerQuery } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import customer from "./customer"; +import customerQuery from "./customer"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Returns the information about the current customer. To override the default query, use the `customer` query key. */ -export default async ( +export const customer = async ( context: Context, customQuery: CustomQuery = { customer: "customer" }, customHeaders: CustomHeaders = {} ): Promise> => { const { customer: customerGQL } = context.extendQuery(customQuery, { customer: { - query: customer, + query: customerQuery, }, }); diff --git a/packages/api-client/src/api/customerCart/index.ts b/packages/api-client/src/api/customerCart/index.ts index 03194099f..57efed71b 100644 --- a/packages/api-client/src/api/customerCart/index.ts +++ b/packages/api-client/src/api/customerCart/index.ts @@ -11,7 +11,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function customerCart( +export async function customerCart( context: Context, customQuery: CustomQuery = { customerCart: "customerCart" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/customerOrders/index.ts b/packages/api-client/src/api/customerOrders/index.ts index 294d00b89..39ca1a748 100644 --- a/packages/api-client/src/api/customerOrders/index.ts +++ b/packages/api-client/src/api/customerOrders/index.ts @@ -20,7 +20,7 @@ type Variables = { /** * Returns customer orders. To override the default query, use the `customerOrders` query key. */ -export default async ( +export const customerOrders = async ( context: Context, searchParams: GetOrdersSearchParams, customQuery: CustomQuery = { customerOrders: "customerOrders" }, diff --git a/packages/api-client/src/api/customerProductReview/index.ts b/packages/api-client/src/api/customerProductReview/index.ts index e9d7fe7cd..e6e150b9a 100644 --- a/packages/api-client/src/api/customerProductReview/index.ts +++ b/packages/api-client/src/api/customerProductReview/index.ts @@ -7,7 +7,7 @@ import { CustomQuery, } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import customerProductReview from "./customerProductReview"; +import customerProductReviewQuery from "./customerProductReview"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -17,7 +17,7 @@ import getHeaders from "../getHeaders"; * @deprecated Use {@link @vue-storefront/magento-api#reviews} instead. * */ -export default async ( +export const customerProductReview = async ( context: Context, searchParams?: CustomerProductReviewParams, customQuery: CustomQuery = { reviews: "reviews" }, @@ -35,7 +35,7 @@ export default async ( const { reviews } = context.extendQuery(customQuery, { reviews: { - query: customerProductReview, + query: customerProductReviewQuery, variables, }, }); diff --git a/packages/api-client/src/api/deleteCustomerAddress/index.ts b/packages/api-client/src/api/deleteCustomerAddress/index.ts index 9bfce968d..89fe2ef3d 100644 --- a/packages/api-client/src/api/deleteCustomerAddress/index.ts +++ b/packages/api-client/src/api/deleteCustomerAddress/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param addressId ID of the customer address to delete * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function deleteCustomerAddress( +export async function deleteCustomerAddress( context: Context, addressId: number, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/generateCustomerToken/index.ts b/packages/api-client/src/api/generateCustomerToken/index.ts index c586e30b0..627f93c96 100644 --- a/packages/api-client/src/api/generateCustomerToken/index.ts +++ b/packages/api-client/src/api/generateCustomerToken/index.ts @@ -4,14 +4,14 @@ import { GraphQLError } from "graphql"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; import recaptchaValidator from "../../helpers/recaptcha/recaptchaValidator"; -import generateCustomerToken from "./generateCustomerToken"; +import generateCustomerTokenQuery from "./generateCustomerToken"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Logs in the customer based on provided username and password. To override the default query, use the `generateCustomerToken` query key. */ -export default async ( +export const generateCustomerToken = async ( context: Context, params: { email: string; @@ -38,7 +38,7 @@ export default async ( const { generateCustomerToken: generateCustomerTokenGQL } = context.extendQuery(customQuery, { generateCustomerToken: { - query: generateCustomerToken, + query: generateCustomerTokenQuery, variables: { email: params.email, password: params.password, diff --git a/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts b/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts index 72e83c380..b5cf92751 100644 --- a/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts +++ b/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts @@ -6,7 +6,10 @@ import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; import CustomerAvailablePaymentMethods from "./CustomerPaymentMethods"; -export default async (context: Context, customHeaders: CustomHeaders = {}): Promise> => { +export const getAvailableCustomerPaymentMethods = async ( + context: Context, + customHeaders: CustomHeaders = {} +): Promise> => { try { return await context.client.query({ query: gql` diff --git a/packages/api-client/src/api/getAvailableCustomerShippingMethods/index.ts b/packages/api-client/src/api/getAvailableCustomerShippingMethods/index.ts index 3494efbf3..ad322cc82 100644 --- a/packages/api-client/src/api/getAvailableCustomerShippingMethods/index.ts +++ b/packages/api-client/src/api/getAvailableCustomerShippingMethods/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function getAvailableCustomerShippingMethods( +export async function getAvailableCustomerShippingMethods( context: Context, customQuery: CustomQuery = { shippingMethods: "shippingMethods" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/getAvailablePaymentMethods/index.ts b/packages/api-client/src/api/getAvailablePaymentMethods/index.ts index caba9d315..608788cfe 100644 --- a/packages/api-client/src/api/getAvailablePaymentMethods/index.ts +++ b/packages/api-client/src/api/getAvailablePaymentMethods/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param cartId cart ID * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function getAvailablePaymentMethods( +export async function getAvailablePaymentMethods( context: Context, cartId: string, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/getAvailableShippingMethods/index.ts b/packages/api-client/src/api/getAvailableShippingMethods/index.ts index 6f38c4c0d..0d220dfc8 100644 --- a/packages/api-client/src/api/getAvailableShippingMethods/index.ts +++ b/packages/api-client/src/api/getAvailableShippingMethods/index.ts @@ -5,7 +5,7 @@ import { Context } from "../../types/context"; import GuestAvailableShippingMethods from "./GuestAvailableShippingMethods"; import getHeaders from "../getHeaders"; -export default async ( +export const getAvailableShippingMethods = async ( context: Context, params: GuestAvailableShippingMethodsQueryVariables, customQuery: CustomQuery = { shippingMethods: "shippingMethods" }, diff --git a/packages/api-client/src/api/getCustomerAddresses/index.ts b/packages/api-client/src/api/getCustomerAddresses/index.ts index a4d00ab5b..300866e4d 100644 --- a/packages/api-client/src/api/getCustomerAddresses/index.ts +++ b/packages/api-client/src/api/getCustomerAddresses/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] - (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function getCustomerAddresses( +export async function getCustomerAddresses( context: Context, customQuery: CustomQuery = { getCustomerAddresses: "getCustomerAddresses" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/index.ts b/packages/api-client/src/api/index.ts index ca0d228bf..05c2cdee4 100644 --- a/packages/api-client/src/api/index.ts +++ b/packages/api-client/src/api/index.ts @@ -1,66 +1,66 @@ -export { default as addBundleProductsToCart } from "./addBundleProductsToCart"; -export { default as addConfigurableProductsToCart } from "./addConfigurableProductsToCart"; -export { default as addProductsToCart } from "./addProductsToCart"; -export { default as addProductToWishList } from "./addProductToWishList"; -export { default as addSimpleProductsToCart } from "./addSimpleProductsToCart"; -export { default as addDownloadableProductsToCart } from "./addDownloadableProductsToCart"; -export { default as addVirtualProductsToCart } from "./addVirtualProductsToCart"; -export { default as applyCouponToCart } from "./applyCouponToCart"; -export { default as availableStores } from "./availableStores"; -export { default as cart } from "./cart"; -export { default as cartTotalQty } from "./cartTotalQty"; -export { default as categoryList } from "./categoryList"; -export { default as categorySearch } from "./categorySearch"; -export { default as changeCustomerPassword } from "./changeCustomerPassword"; -export { default as cmsBlocks } from "./cmsBlocks"; -export { default as cmsPage } from "./cmsPage"; -export { default as countries } from "./countries"; -export { default as country } from "./country"; -export { default as createCustomer } from "./createCustomer"; -export { default as createCustomerAddress } from "./createCustomerAddress"; -export { default as createEmptyCart } from "./createEmptyCart"; -export { default as createProductReview } from "./createProductReview"; -export { default as currency } from "./currency"; -export { default as customer } from "./customer"; -export { default as customerCart } from "./customerCart"; -export { default as customerOrders } from "./customerOrders"; -export { default as customerProductReview } from "./customerProductReview"; -export { default as customMutation } from "./customMutation"; -export { default as customQuery } from "./customQuery"; -export { default as deleteCustomerAddress } from "./deleteCustomerAddress"; -export { default as generateCustomerToken } from "./generateCustomerToken"; -export { default as getAvailableCustomerPaymentMethods } from "./getAvailableCustomerPaymentMethods"; -export { default as getAvailableCustomerShippingMethods } from "./getAvailableCustomerShippingMethods"; -export { default as getAvailablePaymentMethods } from "./getAvailablePaymentMethods"; -export { default as getAvailableShippingMethods } from "./getAvailableShippingMethods"; -export { default as getCustomerAddresses } from "./getCustomerAddresses"; -export { default as mergeCarts } from "./mergeCarts"; -export { default as placeOrder } from "./placeOrder"; -export { default as productDetails } from "./productDetails"; -export { default as productReview } from "./productReview"; -export { default as productReviewRatingsMetadata } from "./productReviewRatingsMetadata"; -export { default as products } from "./products"; -export { default as relatedProducts } from "./relatedProducts"; -export { default as removeCouponFromCart } from "./removeCouponFromCart"; -export { default as removeItemFromCart } from "./removeItemFromCart"; -export { default as removeProductsFromWishlist } from "./removeProductsFromWishlist"; -export { default as requestPasswordResetEmail } from "./requestPasswordResetEmail"; -export { default as resetPassword } from "./resetPassword"; -export { default as revokeCustomerToken } from "./revokeCustomerToken"; -export { default as setBillingAddressOnCart } from "./setBillingAddressOnCart"; -export { default as setGuestEmailOnCart } from "./setGuestEmailOnCart"; -export { default as setPaymentMethodOnCart } from "./setPaymentMethodOnCart"; -export { default as setShippingAddressesOnCart } from "./setShippingAddressesOnCart"; -export { default as setShippingMethodsOnCart } from "./setShippingMethodsOnCart"; -export { default as storeConfig } from "./storeConfig"; -export { default as subscribeEmailToNewsletter } from "./subscribeEmailToNewsletter"; -export { default as updateCartItems } from "./updateCartItems"; -export { default as updateCustomer } from "./updateCustomer"; -export { default as updateCustomerAddress } from "./updateCustomerAddress"; -export { default as updateCustomerEmail } from "./updateCustomerEmail"; -export { default as upsellProducts } from "./upsellProducts"; -export { default as urlResolver } from "./urlResolver"; -export { default as route } from "./route"; -export { default as reviews } from "./reviews"; -export { default as wishlist } from "./wishlist"; -export { default as wishlistItemsCount } from "./wishlistItemsCount"; +export * from "./addBundleProductsToCart"; +export * from "./addConfigurableProductsToCart"; +export * from "./addProductsToCart"; +export * from "./addProductToWishList"; +export * from "./addSimpleProductsToCart"; +export * from "./addDownloadableProductsToCart"; +export * from "./addVirtualProductsToCart"; +export * from "./applyCouponToCart"; +export * from "./availableStores"; +export * from "./cart"; +export * from "./cartTotalQty"; +export * from "./categoryList"; +export * from "./categorySearch"; +export * from "./changeCustomerPassword"; +export * from "./cmsBlocks"; +export * from "./cmsPage"; +export * from "./countries"; +export * from "./country"; +export * from "./createCustomer"; +export * from "./createCustomerAddress"; +export * from "./createEmptyCart"; +export * from "./createProductReview"; +export * from "./currency"; +export * from "./customer"; +export * from "./customerCart"; +export * from "./customerOrders"; +export * from "./customerProductReview"; +export * from "./customMutation"; +export * from "./customQuery"; +export * from "./deleteCustomerAddress"; +export * from "./generateCustomerToken"; +export * from "./getAvailableCustomerPaymentMethods"; +export * from "./getAvailableCustomerShippingMethods"; +export * from "./getAvailablePaymentMethods"; +export * from "./getAvailableShippingMethods"; +export * from "./getCustomerAddresses"; +export * from "./mergeCarts"; +export * from "./placeOrder"; +export * from "./productDetails"; +export * from "./productReview"; +export * from "./productReviewRatingsMetadata"; +export * from "./products"; +export * from "./relatedProducts"; +export * from "./removeCouponFromCart"; +export * from "./removeItemFromCart"; +export * from "./removeProductsFromWishlist"; +export * from "./requestPasswordResetEmail"; +export * from "./resetPassword"; +export * from "./revokeCustomerToken"; +export * from "./setBillingAddressOnCart"; +export * from "./setGuestEmailOnCart"; +export * from "./setPaymentMethodOnCart"; +export * from "./setShippingAddressesOnCart"; +export * from "./setShippingMethodsOnCart"; +export * from "./storeConfig"; +export * from "./subscribeEmailToNewsletter"; +export * from "./updateCartItems"; +export * from "./updateCustomer"; +export * from "./updateCustomerAddress"; +export * from "./updateCustomerEmail"; +export * from "./upsellProducts"; +export * from "./urlResolver"; +export * from "./route"; +export * from "./reviews"; +export * from "./wishlist"; +export * from "./wishlistItemsCount"; diff --git a/packages/api-client/src/api/mergeCarts/index.ts b/packages/api-client/src/api/mergeCarts/index.ts index 859336818..b20428dcc 100644 --- a/packages/api-client/src/api/mergeCarts/index.ts +++ b/packages/api-client/src/api/mergeCarts/index.ts @@ -1,11 +1,11 @@ import { FetchResult, gql } from "@apollo/client/core"; import { CustomQuery, MergeCartsMutation, MergeCartsMutationVariables } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import mergeCarts from "./mergeCarts"; +import mergeCartsQuery from "./mergeCarts"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const mergeCarts = async ( context: Context, params: { sourceCartId: string; @@ -16,7 +16,7 @@ export default async ( ): Promise> => { const { mergeCarts: mergeCartsGQL } = context.extendQuery(customQuery, { mergeCarts: { - query: mergeCarts, + query: mergeCartsQuery, variables: { sourceCartId: params.sourceCartId, destinationCartId: params.destinationCartId, diff --git a/packages/api-client/src/api/placeOrder/index.ts b/packages/api-client/src/api/placeOrder/index.ts index c17fac9c6..a512eda5f 100644 --- a/packages/api-client/src/api/placeOrder/index.ts +++ b/packages/api-client/src/api/placeOrder/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param input the order's input, containing the cart's ID * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function placeOrder( +export async function placeOrder( context: Context, input: PlaceOrderInput, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/productDetails/index.ts b/packages/api-client/src/api/productDetails/index.ts index a7f53857a..4e48a7d4a 100644 --- a/packages/api-client/src/api/productDetails/index.ts +++ b/packages/api-client/src/api/productDetails/index.ts @@ -30,7 +30,7 @@ type Variables = { * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function productDetails( +export async function productDetails( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { productDetails: "productDetails" }, diff --git a/packages/api-client/src/api/productReview/index.ts b/packages/api-client/src/api/productReview/index.ts index ae0e7ef6c..21c9f778e 100644 --- a/packages/api-client/src/api/productReview/index.ts +++ b/packages/api-client/src/api/productReview/index.ts @@ -9,7 +9,7 @@ import { ProductReviewQueryVariables, } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import productReview from "./productReview"; +import productReviewQuery from "./productReview"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -24,7 +24,7 @@ type Variables = { /** * Returns reviews of the provided product */ -export default async ( +export const productReview = async ( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { productReview: "productReview" }, @@ -49,7 +49,7 @@ export default async ( const { productReview: productReviewGQL } = context.extendQuery(customQuery, { productReview: { - query: productReview, + query: productReviewQuery, variables, }, }); diff --git a/packages/api-client/src/api/productReviewRatingsMetadata/index.ts b/packages/api-client/src/api/productReviewRatingsMetadata/index.ts index eefc07e90..c78e9d247 100644 --- a/packages/api-client/src/api/productReviewRatingsMetadata/index.ts +++ b/packages/api-client/src/api/productReviewRatingsMetadata/index.ts @@ -1,21 +1,21 @@ import { ApolloQueryResult, gql } from "@apollo/client/core"; import { CustomQuery, ProductReviewRatingsMetadataQuery } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import productReviewRatingsMetadata from "./productReviewRatingsMetadata"; +import productReviewRatingsMetadataQuery from "./productReviewRatingsMetadata"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Returns the active ratings attributes and the values each rating can have. */ -export default async ( +export const productReviewRatingsMetadata = async ( context: Context, customQuery: CustomQuery = { productReviewRatingsMetadata: "productReviewRatingsMetadata" }, customHeaders: CustomHeaders = {} ): Promise> => { const { productReviewRatingsMetadata: productReviewRatingsMetadataGQL } = context.extendQuery(customQuery, { productReviewRatingsMetadata: { - query: productReviewRatingsMetadata, + query: productReviewRatingsMetadataQuery, }, }); diff --git a/packages/api-client/src/api/products/index.ts b/packages/api-client/src/api/products/index.ts index 3065ecade..1342da789 100644 --- a/packages/api-client/src/api/products/index.ts +++ b/packages/api-client/src/api/products/index.ts @@ -31,7 +31,7 @@ type Variables = { * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function products( +export async function products( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { products: "products" }, diff --git a/packages/api-client/src/api/relatedProducts/index.ts b/packages/api-client/src/api/relatedProducts/index.ts index e8b23bc78..cbcd5bf32 100644 --- a/packages/api-client/src/api/relatedProducts/index.ts +++ b/packages/api-client/src/api/relatedProducts/index.ts @@ -30,7 +30,7 @@ type Variables = { * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function relatedProducts( +export async function relatedProducts( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { relatedProducts: "relatedProducts" }, diff --git a/packages/api-client/src/api/removeCouponFromCart/index.ts b/packages/api-client/src/api/removeCouponFromCart/index.ts index ee6e50f5a..17c788d99 100644 --- a/packages/api-client/src/api/removeCouponFromCart/index.ts +++ b/packages/api-client/src/api/removeCouponFromCart/index.ts @@ -18,7 +18,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function removeCouponFromCart( +export async function removeCouponFromCart( context: Context, input: RemoveCouponFromCartInput, customQuery: CustomQuery = { removeCouponFromCart: "removeCouponFromCart" }, diff --git a/packages/api-client/src/api/removeItemFromCart/index.ts b/packages/api-client/src/api/removeItemFromCart/index.ts index abec39a10..e382802f2 100644 --- a/packages/api-client/src/api/removeItemFromCart/index.ts +++ b/packages/api-client/src/api/removeItemFromCart/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function removeItemFromCart( +export async function removeItemFromCart( context: Context, input: RemoveItemFromCartInput, customQuery: CustomQuery = { removeItemFromCart: "removeItemFromCart" }, diff --git a/packages/api-client/src/api/removeProductsFromWishlist/index.ts b/packages/api-client/src/api/removeProductsFromWishlist/index.ts index 1f388a99d..ebd3a9e94 100644 --- a/packages/api-client/src/api/removeProductsFromWishlist/index.ts +++ b/packages/api-client/src/api/removeProductsFromWishlist/index.ts @@ -2,11 +2,11 @@ import { FetchResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CustomQuery, RemoveProductsFromWishlistMutation, RemoveProductsFromWishlistMutationVariables } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import removeProductsFromWishlist from "./removeProductsFromWishlist"; +import removeProductsFromWishlistQuery from "./removeProductsFromWishlist"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const removeProductsFromWishlist = async ( context: Context, input: RemoveProductsFromWishlistMutationVariables, customQuery: CustomQuery = { removeProductsFromWishlist: "removeProductsFromWishlist" }, @@ -14,7 +14,7 @@ export default async ( ): Promise> => { const { removeProductsFromWishlist: removeProductsFromWishlistGQL } = context.extendQuery(customQuery, { removeProductsFromWishlist: { - query: removeProductsFromWishlist, + query: removeProductsFromWishlistQuery, variables: { ...input }, }, }); diff --git a/packages/api-client/src/api/requestPasswordResetEmail/index.ts b/packages/api-client/src/api/requestPasswordResetEmail/index.ts index 330674888..6ef58a6df 100644 --- a/packages/api-client/src/api/requestPasswordResetEmail/index.ts +++ b/packages/api-client/src/api/requestPasswordResetEmail/index.ts @@ -15,7 +15,7 @@ import getHeaders from "../getHeaders"; * @param input Email for which to request a password reset * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function requestPasswordResetEmail( +export async function requestPasswordResetEmail( context: Context, input: RequestPasswordResetEmailMutationVariables, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/resetPassword/index.ts b/packages/api-client/src/api/resetPassword/index.ts index f908b34a9..c96bd2339 100644 --- a/packages/api-client/src/api/resetPassword/index.ts +++ b/packages/api-client/src/api/resetPassword/index.ts @@ -15,7 +15,7 @@ import getHeaders from "../getHeaders"; * @param input Params used to reset a user's password * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function resetPassword( +export async function resetPassword( context: Context, input: ResetPasswordMutationVariables, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/reviews/index.ts b/packages/api-client/src/api/reviews/index.ts index d3cf27dc6..4ded7ada5 100644 --- a/packages/api-client/src/api/reviews/index.ts +++ b/packages/api-client/src/api/reviews/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; /** * Returns product reviews created by the current customer */ -export default async ( +export const reviews = async ( context: Context, searchParams?: CustomerProductReviewParams, customQuery: CustomQuery = { reviews: "reviews" }, diff --git a/packages/api-client/src/api/revokeCustomerToken/index.ts b/packages/api-client/src/api/revokeCustomerToken/index.ts index b031bd74f..d8e0e4628 100644 --- a/packages/api-client/src/api/revokeCustomerToken/index.ts +++ b/packages/api-client/src/api/revokeCustomerToken/index.ts @@ -2,17 +2,17 @@ import { FetchResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { RevokeCustomerTokenMutation } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import revokeCustomerToken from "./revokeCustomerToken"; +import revokeCustomerTokenMutation from "./revokeCustomerToken"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Logs out the current customer. To override the default query, use the `revokeCustomerToken` query key. */ -export default async (context: Context, customHeaders: CustomHeaders = {}): Promise> => +export const revokeCustomerToken = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => context.client.mutate({ mutation: gql` - ${revokeCustomerToken} + ${revokeCustomerTokenMutation} `, context: { headers: getHeaders(context, customHeaders), diff --git a/packages/api-client/src/api/route/index.ts b/packages/api-client/src/api/route/index.ts index b295c0d9c..6425a932c 100644 --- a/packages/api-client/src/api/route/index.ts +++ b/packages/api-client/src/api/route/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function route( +export async function route( context: Context, url: string, customQuery: CustomQuery = { route: "route" }, diff --git a/packages/api-client/src/api/setBillingAddressOnCart/index.ts b/packages/api-client/src/api/setBillingAddressOnCart/index.ts index a5cad4bc4..2b21f3464 100644 --- a/packages/api-client/src/api/setBillingAddressOnCart/index.ts +++ b/packages/api-client/src/api/setBillingAddressOnCart/index.ts @@ -7,11 +7,11 @@ import { SetBillingAddressOnCartMutationVariables, } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import setBillingAddressOnCart from "./setBillingAddressOnCart"; +import setBillingAddressOnCartQuery from "./setBillingAddressOnCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const setBillingAddressOnCart = async ( context: Context, input: SetBillingAddressOnCartInput, customQuery: CustomQuery = { setBillingAddressOnCart: "setBillingAddressOnCart" }, @@ -19,7 +19,7 @@ export default async ( ): Promise> => { const { setBillingAddressOnCart: setBillingAddressOnCartGQL } = context.extendQuery(customQuery, { setBillingAddressOnCart: { - query: setBillingAddressOnCart, + query: setBillingAddressOnCartQuery, variables: { input }, }, }); diff --git a/packages/api-client/src/api/setGuestEmailOnCart/index.ts b/packages/api-client/src/api/setGuestEmailOnCart/index.ts index d508e5cb6..0ca60726b 100644 --- a/packages/api-client/src/api/setGuestEmailOnCart/index.ts +++ b/packages/api-client/src/api/setGuestEmailOnCart/index.ts @@ -18,7 +18,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - Custom query that will extend default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function setGuestEmailOnCart( +export async function setGuestEmailOnCart( context: Context, input: SetGuestEmailOnCartInput, customQuery: CustomQuery = { setGuestEmailOnCart: "setGuestEmailOnCart" }, diff --git a/packages/api-client/src/api/setPaymentMethodOnCart/index.ts b/packages/api-client/src/api/setPaymentMethodOnCart/index.ts index 24cf2b6c5..00304895c 100644 --- a/packages/api-client/src/api/setPaymentMethodOnCart/index.ts +++ b/packages/api-client/src/api/setPaymentMethodOnCart/index.ts @@ -20,7 +20,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function setPaymentMethodOnCart( +export async function setPaymentMethodOnCart( context: Context, input: SetPaymentMethodOnCartInputs, customQuery: CustomQuery = { setPaymentMethodOnCart: "setPaymentMethodOnCart" }, diff --git a/packages/api-client/src/api/setShippingAddressesOnCart/index.ts b/packages/api-client/src/api/setShippingAddressesOnCart/index.ts index c91be35ad..5e87c1d8a 100644 --- a/packages/api-client/src/api/setShippingAddressesOnCart/index.ts +++ b/packages/api-client/src/api/setShippingAddressesOnCart/index.ts @@ -19,7 +19,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function setShippingAddressesOnCart( +export async function setShippingAddressesOnCart( context: Context, input: SetShippingAddressesOnCartInput, customQuery: CustomQuery = { setShippingAddressesOnCart: "setShippingAddressesOnCart" }, diff --git a/packages/api-client/src/api/setShippingMethodsOnCart/index.ts b/packages/api-client/src/api/setShippingMethodsOnCart/index.ts index 65e9a5a4f..3120d2a43 100644 --- a/packages/api-client/src/api/setShippingMethodsOnCart/index.ts +++ b/packages/api-client/src/api/setShippingMethodsOnCart/index.ts @@ -19,7 +19,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function setShippingMethodsOnCart( +export async function setShippingMethodsOnCart( context: Context, input: SetShippingMethodsOnCartInput, customQuery: CustomQuery = { setShippingMethodsOnCart: "setShippingMethodsOnCart" }, diff --git a/packages/api-client/src/api/storeConfig/index.ts b/packages/api-client/src/api/storeConfig/index.ts index cfb8a520d..5a30845dc 100644 --- a/packages/api-client/src/api/storeConfig/index.ts +++ b/packages/api-client/src/api/storeConfig/index.ts @@ -12,7 +12,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function storeConfig( +export async function storeConfig( context: Context, customQuery: CustomQuery = { storeConfig: "storeConfig" }, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/subscribeEmailToNewsletter/index.ts b/packages/api-client/src/api/subscribeEmailToNewsletter/index.ts index f13de01f2..e047d0d01 100644 --- a/packages/api-client/src/api/subscribeEmailToNewsletter/index.ts +++ b/packages/api-client/src/api/subscribeEmailToNewsletter/index.ts @@ -11,7 +11,7 @@ import getHeaders from "../getHeaders"; * @param input params with the email to subscribe * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function subscribeEmailToNewsletter( +export async function subscribeEmailToNewsletter( context: Context, { email }: SubscribeEmailToNewsletterMutationVariables, customHeaders: CustomHeaders = {} diff --git a/packages/api-client/src/api/updateCartItems/index.ts b/packages/api-client/src/api/updateCartItems/index.ts index 5b6c287dc..855490f26 100644 --- a/packages/api-client/src/api/updateCartItems/index.ts +++ b/packages/api-client/src/api/updateCartItems/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param customQuery custom GraphQL query that extends the default one * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function updateCartItems( +export async function updateCartItems( context: Context, input: UpdateCartItemsInput, customQuery: CustomQuery = { updateCartItems: "updateCartItems" }, diff --git a/packages/api-client/src/api/updateCustomer/index.ts b/packages/api-client/src/api/updateCustomer/index.ts index 1687bf6f9..70e5c7014 100644 --- a/packages/api-client/src/api/updateCustomer/index.ts +++ b/packages/api-client/src/api/updateCustomer/index.ts @@ -2,14 +2,14 @@ import { FetchResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CustomerUpdateInput, CustomQuery, UpdateCustomerMutation, UpdateCustomerMutationVariables } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import updateCustomer from "./updateCustomer"; +import updateCustomerQuery from "./updateCustomer"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; /** * Updates the data of the current customer. To override the default query, use the `updateCustomer` query key. */ -export default async ( +export const updateCustomer = async ( context: Context, input: CustomerUpdateInput, customQuery: CustomQuery = { updateCustomer: "updateCustomer" }, @@ -17,7 +17,7 @@ export default async ( ): Promise> => { const { updateCustomer: updateCustomerGQL } = context.extendQuery(customQuery, { updateCustomer: { - query: updateCustomer, + query: updateCustomerQuery, variables: { input }, }, }); diff --git a/packages/api-client/src/api/updateCustomerAddress/index.ts b/packages/api-client/src/api/updateCustomerAddress/index.ts index 283116a15..88a3f87cb 100644 --- a/packages/api-client/src/api/updateCustomerAddress/index.ts +++ b/packages/api-client/src/api/updateCustomerAddress/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function updateCustomerAddress( +export async function updateCustomerAddress( context: Context, params: UpdateCustomerAddressMutationVariables, customQuery: CustomQuery = { updateCustomerAddress: "updateCustomerAddress" }, diff --git a/packages/api-client/src/api/updateCustomerEmail/index.ts b/packages/api-client/src/api/updateCustomerEmail/index.ts index bb6d47740..941984040 100644 --- a/packages/api-client/src/api/updateCustomerEmail/index.ts +++ b/packages/api-client/src/api/updateCustomerEmail/index.ts @@ -1,11 +1,11 @@ import { FetchResult, gql } from "@apollo/client/core"; import { CustomQuery, UpdateCustomerEmailMutation, UpdateCustomerEmailMutationVariables } from "@vue-storefront/magento-types"; import type { CustomHeaders } from "@vue-storefront/magento-types"; -import updateCustomerEmail from "./updateCustomerEmail"; +import updateCustomerEmailQuery from "./updateCustomerEmail"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async ( +export const updateCustomerEmail = async ( context: Context, input: UpdateCustomerEmailMutationVariables, customQuery: CustomQuery = { updateCustomerEmail: "updateCustomerEmail" }, @@ -13,7 +13,7 @@ export default async ( ): Promise> => { const { updateCustomerEmail: updateCustomerEmailGQL } = context.extendQuery(customQuery, { updateCustomerEmail: { - query: updateCustomerEmail, + query: updateCustomerEmailQuery, variables: { ...input }, }, }); diff --git a/packages/api-client/src/api/upsellProducts/index.ts b/packages/api-client/src/api/upsellProducts/index.ts index 7dab5ff8e..a9ff21001 100644 --- a/packages/api-client/src/api/upsellProducts/index.ts +++ b/packages/api-client/src/api/upsellProducts/index.ts @@ -9,7 +9,7 @@ import type { UpsellProductsQueryVariables, } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import upsellProducts from "./upsellProducts"; +import upsellProductsQuery from "./upsellProducts"; import type { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -24,7 +24,7 @@ type Variables = { /** * Returns upsell products matching the provided parameters. To override the default query, use the `upsellProducts` query key. */ -export default async ( +export const upsellProducts = async ( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { upsellProducts: "upsellProducts" }, @@ -49,7 +49,7 @@ export default async ( const { upsellProducts: upsellProductsGQL } = context.extendQuery(customQuery, { upsellProducts: { - query: upsellProducts, + query: upsellProductsQuery, variables, }, }); diff --git a/packages/api-client/src/api/urlResolver/index.ts b/packages/api-client/src/api/urlResolver/index.ts index 828c307c4..25723435c 100644 --- a/packages/api-client/src/api/urlResolver/index.ts +++ b/packages/api-client/src/api/urlResolver/index.ts @@ -13,7 +13,7 @@ import getHeaders from "../getHeaders"; * @param customHeaders (optional) - custom headers that extends the default headers * @deprecated - use route instead */ -export default async function urlResolver( +export async function urlResolver( context: Context, url: string, customQuery: CustomQuery = { urlResolver: "urlResolver" }, diff --git a/packages/api-client/src/api/wishlist/index.ts b/packages/api-client/src/api/wishlist/index.ts index 8682282ae..99cc15a73 100644 --- a/packages/api-client/src/api/wishlist/index.ts +++ b/packages/api-client/src/api/wishlist/index.ts @@ -10,7 +10,7 @@ type Variables = { currentPage: number; }; -export default async ( +export const wishlist = async ( context: Context, searchParams: WishlistQueryVariables, customQuery: CustomQuery = { wishlist: "wishlist" }, diff --git a/packages/api-client/src/api/wishlistItemsCount/index.ts b/packages/api-client/src/api/wishlistItemsCount/index.ts index 4c70558e9..8d7fe65ba 100644 --- a/packages/api-client/src/api/wishlistItemsCount/index.ts +++ b/packages/api-client/src/api/wishlistItemsCount/index.ts @@ -6,7 +6,7 @@ import wishlistItemsCountQuery from "./wishlistItemsCount"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export default async (context: Context, customHeaders: CustomHeaders = {}): Promise> => +export const wishlistItemsCount = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => context.client.query({ query: gql` ${wishlistItemsCountQuery} diff --git a/packages/api-client/src/types/api/endpoints.ts b/packages/api-client/src/types/api/endpoints.ts new file mode 100644 index 000000000..cadf78755 --- /dev/null +++ b/packages/api-client/src/types/api/endpoints.ts @@ -0,0 +1,12 @@ +import { WithoutContext } from "@vue-storefront/middleware"; +import * as apiMethods from "../../api"; + +/** + * ApiMethods type of the Magento 2 integration. + */ +export type ApiMethods = typeof apiMethods; + +/** + * Interface of the Magento 2 integration + */ +export type Endpoints = WithoutContext; diff --git a/packages/api-client/src/types/api/index.ts b/packages/api-client/src/types/api/index.ts new file mode 100644 index 000000000..c87f309a7 --- /dev/null +++ b/packages/api-client/src/types/api/index.ts @@ -0,0 +1 @@ +export * from './endpoints'; diff --git a/packages/api-client/src/types/context.ts b/packages/api-client/src/types/context.ts deleted file mode 100644 index 1b832596a..000000000 --- a/packages/api-client/src/types/context.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ApiClientMethods, IntegrationContext } from "@vue-storefront/middleware"; -import { MagentoApiMethods } from "@vue-storefront/magento-types"; -import { ClientInstance, Config } from "./setup"; - -export type Context = IntegrationContext>; diff --git a/packages/api-client/src/types/context/index.ts b/packages/api-client/src/types/context/index.ts new file mode 100644 index 000000000..a879992c4 --- /dev/null +++ b/packages/api-client/src/types/context/index.ts @@ -0,0 +1,5 @@ +import { type ApiClientMethods, type IntegrationContext } from "@vue-storefront/middleware"; +import { type ClientInstance, type Config } from "../setup"; +import { type Endpoints } from "../api" + +export type Context = IntegrationContext>; diff --git a/packages/api-types/src/Api.ts b/packages/api-types/src/Api.ts index ebf11a812..e9bb292e3 100644 --- a/packages/api-types/src/Api.ts +++ b/packages/api-types/src/Api.ts @@ -153,384 +153,3 @@ export enum MagentoCustomerGender { } export declare type CustomHeaders = Record; - -export interface MagentoApiMethods { - addBundleProductsToCart( - input: AddBundleProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addConfigurableProductsToCart( - input: AddConfigurableProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addProductsToCart( - input: AddProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addProductToWishList( - input: AddProductsToWishlistMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addSimpleProductsToCart( - input: AddSimpleProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addDownloadableProductsToCart( - input: AddDownloadableProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - addVirtualProductsToCart( - input: AddVirtualProductsToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - applyCouponToCart( - input: ApplyCouponToCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - availableStores( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - cart( - cartId: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - cartTotalQty( - cartId: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - categoryList( - categoryFilter?: CategoryListQueryVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - categorySearch( - categoryFilter?: CategorySearchQueryVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - changeCustomerPassword( - params: { currentPassword: string; newPassword: string }, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - cmsBlocks( - identifiers: string[], - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - cmsPage( - identifier: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - countries( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - country( - id: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - createCustomer( - input: CustomerCreateInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - createCustomerAddress( - input: CustomerAddressInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - createEmptyCart( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - createProductReview( - input: CreateProductReviewInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - currency( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - customer( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - customerCart( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - customerOrders( - searchParams: GetOrdersSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - customQuery(params: { - query: string, - queryVariables?: QUERY_VARIABLES, - fetchPolicy?: FetchPolicy, - customHeaders?: CustomHeaders, - }): Promise>; - - customMutation(params: { - mutation: string, - mutationVariables: MUTATION_VARIABLES, - fetchPolicy?: Extract, - customHeaders?: CustomHeaders, - }): Promise>; - - customerProductReview( - input: CustomerProductReviewParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - deleteCustomerAddress( - addressId: number, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - generateCustomerToken( - params: { email: string, password: string, recaptchaToken: string }, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - getAvailableCustomerPaymentMethods( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - getAvailableCustomerShippingMethods( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - getAvailablePaymentMethods( - cartId: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - getAvailableShippingMethods( - params: { cartId: string }, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - getCustomerAddresses( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - mergeCarts( - params: { sourceCartId: string; destinationCartId: string }, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - placeOrder( - input: PlaceOrderInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - productDetails( - searchParams: GetProductSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - productReview( - searchParams: GetProductSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - productReviewRatingsMetadata( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - products( - searchParams: GetProductSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - relatedProducts( - searchParams: GetProductSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - removeCouponFromCart( - input: RemoveCouponFromCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - removeItemFromCart( - input: RemoveItemFromCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - removeProductsFromWishlist( - input: RemoveProductsFromWishlistMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - revokeCustomerToken( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - requestPasswordResetEmail( - input: RequestPasswordResetEmailMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - resetPassword( - input: ResetPasswordMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - setBillingAddressOnCart( - input: SetBillingAddressOnCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - setGuestEmailOnCart( - input: SetGuestEmailOnCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - setPaymentMethodOnCart( - input: SetPaymentMethodOnCartInputs, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - setShippingAddressesOnCart( - input: SetShippingAddressesOnCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - setShippingMethodsOnCart( - input: SetShippingMethodsOnCartInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - storeConfig( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - subscribeEmailToNewsletter( - input: SubscribeEmailToNewsletterMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - updateCartItems( - input: UpdateCartItemsInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - updateCustomer( - input: CustomerUpdateInput, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - updateCustomerAddress( - input: { addressId: number; input: CustomerAddressInput; }, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - updateCustomerEmail( - input: UpdateCustomerEmailMutationVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - upsellProducts( - searchParams: GetProductSearchParams, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - urlResolver( - url: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - route( - url: string, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>>; - - wishlist( - searchParams: WishlistQueryVariables, - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; - - wishlistItemsCount( - customQuery?: CustomQuery, - customHeaders?: CustomHeaders - ): Promise>; -} diff --git a/packages/load-tests/src/query/storeConfig.gql.js b/packages/load-tests/src/query/storeConfig.gql.js index 367c7886a..fa7399824 100644 --- a/packages/load-tests/src/query/storeConfig.gql.js +++ b/packages/load-tests/src/query/storeConfig.gql.js @@ -14,4 +14,5 @@ export const StoreConfigQuery = ` } `; -export const StoreConfigQueryString = 'query=query%20storeConfig%20%7B%0A%20%20%20%20storeConfig%20%7B%0A%20%20%20%20%20%20%20%20store_code,%0A%20%20%20%20%20%20%20%20default_title,%0A%20%20%20%20%20%20%20%20store_name,%0A%20%20%20%20%20%20%20%20default_display_currency_code,%0A%20%20%20%20%20%20%20%20locale,%0A%20%20%20%20%20%20%20%20header_logo_src,%0A%20%20%20%20%20%20%20%20logo_width,%0A%20%20%20%20%20%20%20%20logo_height,%0A%20%20%20%20%20%20%20%20logo_alt%0A%20%20%20%20%7D%0A%20%20%7D&variables=%7B%7D&operationName=storeConfig'; +export const StoreConfigQueryString = + "query=query%20storeConfig%20%7B%0A%20%20%20%20storeConfig%20%7B%0A%20%20%20%20%20%20%20%20store_code,%0A%20%20%20%20%20%20%20%20default_title,%0A%20%20%20%20%20%20%20%20store_name,%0A%20%20%20%20%20%20%20%20default_display_currency_code,%0A%20%20%20%20%20%20%20%20locale,%0A%20%20%20%20%20%20%20%20header_logo_src,%0A%20%20%20%20%20%20%20%20logo_width,%0A%20%20%20%20%20%20%20%20logo_height,%0A%20%20%20%20%20%20%20%20logo_alt%0A%20%20%20%20%7D%0A%20%20%7D&variables=%7B%7D&operationName=storeConfig"; diff --git a/packages/load-tests/src/tests/magento/addSimpleProductToCart.js b/packages/load-tests/src/tests/magento/addSimpleProductToCart.js index 9f6de3f65..0b24a69d6 100644 --- a/packages/load-tests/src/tests/magento/addSimpleProductToCart.js +++ b/packages/load-tests/src/tests/magento/addSimpleProductToCart.js @@ -1,24 +1,24 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { group, check } from 'k6'; -import http from 'k6/http'; +import { group, check } from "k6"; +import http from "k6/http"; -import getHeaders from './utils/getHeaders.js'; -import { AddProductsToCart } from '../../mutation/addProductsToCart.js'; -import CreateEmptyGuestCart from './createEmptyGuestCart.js'; +import getHeaders from "./utils/getHeaders.js"; +import { AddProductsToCart } from "../../mutation/addProductsToCart.js"; +import CreateEmptyGuestCart from "./createEmptyGuestCart.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; let response; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -26,26 +26,26 @@ export default function main() { headers: getHeaders(), }; - group('[Magento] addSimpleProductToGuestCart', () => { + group("[Magento] addSimpleProductToGuestCart", () => { const { cartId } = CreateEmptyGuestCart(); - group('add a simple product to the cart', () => { + group("add a simple product to the cart", () => { response = http.post( `${BASE_URL}`, JSON.stringify({ query: AddProductsToCart, variables: { cartId, - cartItems: [{ quantity: Math.floor(Math.random() * 10), sku: '24-WG02' }], + cartItems: [{ quantity: Math.floor(Math.random() * 10), sku: "24-WG02" }], }, }), - params, + params ); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, - 'includes cart data': (r) => r.body.includes('addProductsToCart'), + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, + "includes cart data": (r) => r.body.includes("addProductsToCart"), }); }); }); diff --git a/packages/load-tests/src/tests/magento/createCustomer.js b/packages/load-tests/src/tests/magento/createCustomer.js index a382e3ab9..f5b38dd28 100644 --- a/packages/load-tests/src/tests/magento/createCustomer.js +++ b/packages/load-tests/src/tests/magento/createCustomer.js @@ -1,24 +1,24 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { group, check } from 'k6'; -import http from 'k6/http'; +import { group, check } from "k6"; +import http from "k6/http"; -import getHeaders from './utils/getHeaders.js'; -import { CreateCustomer } from '../../mutation/createCustomer.js'; -import { customerData } from '../../utils/customerData.js'; +import getHeaders from "./utils/getHeaders.js"; +import { CreateCustomer } from "../../mutation/createCustomer.js"; +import { customerData } from "../../utils/customerData.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; let response; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -26,7 +26,7 @@ export default function main() { headers: getHeaders(), }; - group('[Magento] create a customer account', () => { + group("[Magento] create a customer account", () => { response = http.post( `${BASE_URL}`, JSON.stringify({ @@ -34,18 +34,18 @@ export default function main() { variables: { input: { email: customerData.getEmail(), - password: 'Abcd123!', - firstname: 'Load', - lastname: 'Test', + password: "Abcd123!", + firstname: "Load", + lastname: "Test", }, }, }), - params, + params ); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, }); }); } diff --git a/packages/load-tests/src/tests/magento/createEmptyGuestCart.js b/packages/load-tests/src/tests/magento/createEmptyGuestCart.js index 64e850e4c..5a1b9d983 100644 --- a/packages/load-tests/src/tests/magento/createEmptyGuestCart.js +++ b/packages/load-tests/src/tests/magento/createEmptyGuestCart.js @@ -1,24 +1,24 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { sleep, group, check } from 'k6'; -import http from 'k6/http'; +import { sleep, group, check } from "k6"; +import http from "k6/http"; -import jsonpath from 'https://jslib.k6.io/jsonpath/1.0.2/index.js'; -import getHeaders from './utils/getHeaders.js'; -import { CreateEmptyCartMutation } from '../../mutation/createEmptyCart.js'; +import jsonpath from "https://jslib.k6.io/jsonpath/1.0.2/index.js"; +import getHeaders from "./utils/getHeaders.js"; +import { CreateEmptyCartMutation } from "../../mutation/createEmptyCart.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; const vars = {}; let response; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -26,19 +26,15 @@ export default function main() { headers: getHeaders(), }; - group('[Magento] create an empty cart', () => { - response = http.post( - `${BASE_URL}`, - JSON.stringify({ query: CreateEmptyCartMutation }), - params, - ); + group("[Magento] create an empty cart", () => { + response = http.post(`${BASE_URL}`, JSON.stringify({ query: CreateEmptyCartMutation }), params); sleep(0.2); - [vars.cartId] = jsonpath.query(response.json(), '$.data.createEmptyCart'); + [vars.cartId] = jsonpath.query(response.json(), "$.data.createEmptyCart"); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, - 'includes cart id': () => vars.cartId, + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, + "includes cart id": () => vars.cartId, }); }); diff --git a/packages/load-tests/src/tests/magento/storeConfig.js b/packages/load-tests/src/tests/magento/storeConfig.js index 1e1285d92..d9da47b8e 100644 --- a/packages/load-tests/src/tests/magento/storeConfig.js +++ b/packages/load-tests/src/tests/magento/storeConfig.js @@ -1,22 +1,22 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { sleep, check, group } from 'k6'; -import http from 'k6/http'; +import { sleep, check, group } from "k6"; +import http from "k6/http"; -import getHeaders from './utils/getHeaders.js'; -import { StoreConfigQueryString } from '../../query/storeConfig.gql.js'; +import getHeaders from "./utils/getHeaders.js"; +import { StoreConfigQueryString } from "../../query/storeConfig.gql.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -24,18 +24,15 @@ export default function main() { headers: getHeaders(), }; - group('[Magento] storeConfig', () => { - const response = http.get( - `${BASE_URL}/graphql?${StoreConfigQueryString}`, - params, - ); + group("[Magento] storeConfig", () => { + const response = http.get(`${BASE_URL}/graphql?${StoreConfigQueryString}`, params); sleep(0.5); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, - 'includes storeConfig data': (r) => r.body.includes('storeConfig'), + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, + "includes storeConfig data": (r) => r.body.includes("storeConfig"), }); }); } diff --git a/packages/load-tests/src/tests/magento/utils/getHeaders.js b/packages/load-tests/src/tests/magento/utils/getHeaders.js index 7f21f7703..b3b17c2ab 100644 --- a/packages/load-tests/src/tests/magento/utils/getHeaders.js +++ b/packages/load-tests/src/tests/magento/utils/getHeaders.js @@ -1,5 +1,5 @@ const getHeaders = () => ({ - 'Content-Type': 'application/json', + "Content-Type": "application/json", }); export default getHeaders; diff --git a/packages/load-tests/src/tests/middleware/createCustomer.js b/packages/load-tests/src/tests/middleware/createCustomer.js index c85a174ce..60c1f2939 100644 --- a/packages/load-tests/src/tests/middleware/createCustomer.js +++ b/packages/load-tests/src/tests/middleware/createCustomer.js @@ -1,23 +1,23 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { sleep, group, check } from 'k6'; -import http from 'k6/http'; +import { sleep, group, check } from "k6"; +import http from "k6/http"; -import getHeaders from './utils/getHeaders.js'; -import { customerData } from './utils/customerData.js'; +import getHeaders from "./utils/getHeaders.js"; +import { customerData } from "./utils/customerData.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; let response; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -25,24 +25,26 @@ export default function main() { headers: getHeaders(), }; - group('[Middleware] create a customer account', () => { + group("[Middleware] create a customer account", () => { response = http.post( `${BASE_URL}/magento/createCustomer`, - JSON.stringify([{ - email: customerData.getEmail(), - password: 'Abcd123!', - firstname: 'Load', - lastname: 'Test', - recaptchaToken: '12345', - }]), - params, + JSON.stringify([ + { + email: customerData.getEmail(), + password: "Abcd123!", + firstname: "Load", + lastname: "Test", + recaptchaToken: "12345", + }, + ]), + params ); sleep(2); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, }); }); } diff --git a/packages/load-tests/src/tests/middleware/createEmptyGuestCart.js b/packages/load-tests/src/tests/middleware/createEmptyGuestCart.js index 6eae6a2f0..4c6ab6811 100644 --- a/packages/load-tests/src/tests/middleware/createEmptyGuestCart.js +++ b/packages/load-tests/src/tests/middleware/createEmptyGuestCart.js @@ -1,23 +1,23 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { sleep, group, check } from 'k6'; -import http from 'k6/http'; +import { sleep, group, check } from "k6"; +import http from "k6/http"; -import jsonpath from 'https://jslib.k6.io/jsonpath/1.0.2/index.js'; -import getHeaders from './utils/getHeaders.js'; +import jsonpath from "https://jslib.k6.io/jsonpath/1.0.2/index.js"; +import getHeaders from "./utils/getHeaders.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 1, - duration: '1s', + duration: "1s", }; const { BASE_URL } = __ENV; const vars = {}; let response; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -25,21 +25,17 @@ export default function main() { headers: getHeaders(), }; - group('[Middleware] create an empty cart', () => { - response = http.post( - `${BASE_URL}/magento/createEmptyCart`, - '[]', - params, - ); + group("[Middleware] create an empty cart", () => { + response = http.post(`${BASE_URL}/magento/createEmptyCart`, "[]", params); sleep(1); - [vars.cartId] = jsonpath.query(response.json(), '$.data.createEmptyCart'); + [vars.cartId] = jsonpath.query(response.json(), "$.data.createEmptyCart"); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, - 'includes cart id': () => vars.cartId, + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, + "includes cart id": () => vars.cartId, }); }); diff --git a/packages/load-tests/src/tests/middleware/storeConfig.js b/packages/load-tests/src/tests/middleware/storeConfig.js index 96a128a89..839359737 100644 --- a/packages/load-tests/src/tests/middleware/storeConfig.js +++ b/packages/load-tests/src/tests/middleware/storeConfig.js @@ -1,20 +1,20 @@ // Creator: k6 Browser Recorder 0.6.2 (+ handmade cleanups) -import { sleep, check, group } from 'k6'; -import http from 'k6/http'; -import getHeaders from './utils/getHeaders.js'; +import { sleep, check, group } from "k6"; +import http from "k6/http"; +import getHeaders from "./utils/getHeaders.js"; /** * @type {import('k6/options').Options} */ export const options = { vus: 150, - duration: '1m', + duration: "1m", }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } export default function main() { @@ -22,19 +22,19 @@ export default function main() { headers: getHeaders(), }; - group('[Middleware] storeConfig', () => { + group("[Middleware] storeConfig", () => { const response = http.post( `${BASE_URL}/git magento/customQuery`, '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', - params, + params ); sleep(0.5); check(response, { - 'is status 200': (r) => r.status === 200, - 'does not have errors': (r) => !r.json().errors, - 'includes storeConfig data': (r) => r.body.includes('storeConfig'), + "is status 200": (r) => r.status === 200, + "does not have errors": (r) => !r.json().errors, + "includes storeConfig data": (r) => r.body.includes("storeConfig"), }); }); } diff --git a/packages/load-tests/src/tests/middleware/utils/customerData.js b/packages/load-tests/src/tests/middleware/utils/customerData.js index 59ed2defb..aa8cde37a 100644 --- a/packages/load-tests/src/tests/middleware/utils/customerData.js +++ b/packages/load-tests/src/tests/middleware/utils/customerData.js @@ -1,7 +1,7 @@ -const chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; +const chars = "abcdefghijklmnopqrstuvwxyz1234567890"; export const getEmail = (length = 15) => { - let string = ''; + let string = ""; for (let i = 0; i < length; i++) { string += chars[Math.floor(Math.random() * chars.length)]; } diff --git a/packages/load-tests/src/tests/middleware/utils/getHeaders.js b/packages/load-tests/src/tests/middleware/utils/getHeaders.js index b70f2919c..e5dd566b4 100644 --- a/packages/load-tests/src/tests/middleware/utils/getHeaders.js +++ b/packages/load-tests/src/tests/middleware/utils/getHeaders.js @@ -1,7 +1,7 @@ const getHeaders = () => ({ - 'content-type': 'application/json', - accept: 'application/json, text/plain, */*', - cookie: 'vsf-store=default; vsf-locale=default; vsf-currency=USD', + "content-type": "application/json", + accept: "application/json, text/plain, */*", + cookie: "vsf-store=default; vsf-locale=default; vsf-currency=USD", }); export default getHeaders; diff --git a/packages/load-tests/src/tests/scenarios/browsingProduct.js b/packages/load-tests/src/tests/scenarios/browsingProduct.js index 3be57b28a..f3a07eabc 100644 --- a/packages/load-tests/src/tests/scenarios/browsingProduct.js +++ b/packages/load-tests/src/tests/scenarios/browsingProduct.js @@ -1,39 +1,39 @@ // Creator: k6 Browser Recorder 0.6.2 -import { check, sleep, group } from 'k6'; -import http from 'k6/http'; +import { check, sleep, group } from "k6"; +import http from "k6/http"; -import jsonpath from 'https://jslib.k6.io/jsonpath/1.0.2/index.js'; -import { setDefaultCookies } from './utils/setDefaultCookies.js'; +import jsonpath from "https://jslib.k6.io/jsonpath/1.0.2/index.js"; +import { setDefaultCookies } from "./utils/setDefaultCookies.js"; export const options = { vus: 200, - duration: '5m', + duration: "5m", thresholds: { - http_req_failed: ['rate<0.01'], // http errors should be less than 1% - http_req_duration: ['p(80)<250'], // 80% of requests should be below 250ms + http_req_failed: ["rate<0.01"], // http errors should be less than 1% + http_req_duration: ["p(80)<250"], // 80% of requests should be below 250ms }, }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } const headers = { - accept: 'application/json, text/plain, */*', - 'content-type': 'application/json', - 'upgrade-insecure-requests': '1', - 'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', + accept: "application/json, text/plain, */*", + "content-type": "application/json", + "upgrade-insecure-requests": "1", + "sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"macOS"', }; const executeCommonChecks = (res) => { check(res, { - 'is status 200': (r) => r.status === 200, - 'has no errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "has no errors": (r) => !r.json().errors, }); }; @@ -43,16 +43,13 @@ export default function main() { const vars = {}; setDefaultCookies(BASE_URL); group(`Browsing for a product - page ${BASE_URL}`, () => { - group('Visit the homepage', () => { - res = http.get( - `${BASE_URL}/default`, - { - headers, - }, - ); + group("Visit the homepage", () => { + res = http.get(`${BASE_URL}/default`, { + headers, + }); check(res, { - 'is status 200': (r) => r.status === 200, + "is status 200": (r) => r.status === 200, }); sleep(0.9); @@ -62,7 +59,7 @@ export default function main() { '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -72,7 +69,7 @@ export default function main() { '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -82,7 +79,7 @@ export default function main() { '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -94,22 +91,18 @@ export default function main() { '[{"query":"\\n query categoryList {\\n categories {\\n items {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n }\\n }\\n }\\n }\\n }\\n }\\n \\n fragment CategoryFields on CategoryTree {\\n is_anchor\\n name\\n position\\n product_count\\n uid\\n url_path\\n url_suffix\\n include_in_menu\\n }\\n\\n"}]', { headers, - }, + } ); executeCommonChecks(res); }); - group('Go to the Men category page', () => { - res = http.post( - `${BASE_URL}/api/magento/route`, - '["/men.html",null]', - { - headers, - }, - ); + group("Go to the Men category page", () => { + res = http.post(`${BASE_URL}/api/magento/route`, '["/men.html",null]', { + headers, + }); check(res, { - 'is status 200': (r) => r.status === 200, + "is status 200": (r) => r.status === 200, }); res = http.post( @@ -117,7 +110,7 @@ export default function main() { '[{"query":"\\n query categoryList {\\n categories {\\n items {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n }\\n }\\n }\\n }\\n }\\n }\\n \\n fragment CategoryFields on CategoryTree {\\n is_anchor\\n name\\n position\\n product_count\\n uid\\n url_path\\n url_suffix\\n include_in_menu\\n }\\n\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -126,18 +119,18 @@ export default function main() { '[{"query":"\\n query getCategoryContentData($filters: CategoryFilterInput) {\\n categoryList(filters: $filters) {\\n uid\\n display_mode\\n landing_page\\n cms_block {\\n identifier\\n content\\n }\\n }\\n }\\n","queryVariables":{"filters":{"category_uid":{"eq":"MTE="}}}}]', { headers, - }, + } ); executeCommonChecks(res); - [vars.uid1] = jsonpath.query(res.json(), '$.data.categoryList[0].uid'); + [vars.uid1] = jsonpath.query(res.json(), "$.data.categoryList[0].uid"); res = http.post( `${BASE_URL}/api/magento/customQuery`, `[{"query":"\\n query getFacetData($search: String = \\"\\", $filter: ProductAttributeFilterInput, $pageSize: Int = 10, $currentPage: Int = 1, $sort: ProductAttributeSortInput) {\\n products(search: $search, filter: $filter, pageSize: $pageSize, currentPage: $currentPage, sort: $sort) {\\n items {\\n __typename\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n url_key\\n url_rewrites {\\n url\\n }\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n }\\n page_info {\\n current_page\\n page_size\\n total_pages\\n }\\n total_count\\n }\\n }\\n","queryVariables":{"pageSize":10,"search":"","filter":{"category_uid":{"in":["${vars.uid1}"]}},"sort":{},"currentPage":1}}]`, { headers, - }, + } ); executeCommonChecks(res); @@ -146,22 +139,18 @@ export default function main() { `[{"query":"\\n query getProductFiltersByCategory($categoryIdFilter: FilterEqualTypeInput!) {\\n products(filter: { category_uid: $categoryIdFilter }) {\\n aggregations {\\n label\\n count\\n attribute_code\\n options {\\n count\\n label\\n value\\n __typename\\n }\\n position\\n __typename\\n }\\n __typename\\n }\\n }\\n","queryVariables":{"categoryIdFilter":{"eq":"${vars.uid1}"}}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(3); }); - group('Sort by name ASC', () => { - res = http.post( - `${BASE_URL}/api/magento/route`, - '["/men.html",null]', - { - headers, - }, - ); + group("Sort by name ASC", () => { + res = http.post(`${BASE_URL}/api/magento/route`, '["/men.html",null]', { + headers, + }); check(res, { - 'is status 200': (r) => r.status === 200, + "is status 200": (r) => r.status === 200, }); res = http.post( @@ -169,7 +158,7 @@ export default function main() { `[{"query":"\\n query getCategoryContentData($filters: CategoryFilterInput) {\\n categoryList(filters: $filters) {\\n uid\\n display_mode\\n landing_page\\n cms_block {\\n identifier\\n content\\n }\\n }\\n }\\n","queryVariables":{"filters":{"category_uid":{"eq":"${vars.uid1}"}}}}]`, { headers, - }, + } ); executeCommonChecks(res); @@ -178,22 +167,18 @@ export default function main() { `[{"query":"\\n query getFacetData($search: String = \\"\\", $filter: ProductAttributeFilterInput, $pageSize: Int = 10, $currentPage: Int = 1, $sort: ProductAttributeSortInput) {\\n products(search: $search, filter: $filter, pageSize: $pageSize, currentPage: $currentPage, sort: $sort) {\\n items {\\n __typename\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n url_key\\n url_rewrites {\\n url\\n }\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n }\\n page_info {\\n current_page\\n page_size\\n total_pages\\n }\\n total_count\\n }\\n }\\n","queryVariables":{"pageSize":10,"search":"","filter":{"category_uid":{"in":["${vars.uid1}"]}},"sort":{"name":"DESC"},"currentPage":1}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(3); }); - group('Sort by Price ASC', () => { - res = http.post( - `${BASE_URL}/api/magento/route`, - '["/men.html",null]', - { - headers, - }, - ); + group("Sort by Price ASC", () => { + res = http.post(`${BASE_URL}/api/magento/route`, '["/men.html",null]', { + headers, + }); check(res, { - 'is status 200': (r) => r.status === 200, + "is status 200": (r) => r.status === 200, }); res = http.post( @@ -201,32 +186,28 @@ export default function main() { `[{"query":"\\n query getCategoryContentData($filters: CategoryFilterInput) {\\n categoryList(filters: $filters) {\\n uid\\n display_mode\\n landing_page\\n cms_block {\\n identifier\\n content\\n }\\n }\\n }\\n","queryVariables":{"filters":{"category_uid":{"eq":"${vars.uid1}"}}}}]`, { headers, - }, + } ); executeCommonChecks(res); - [vars.uid2] = jsonpath.query(res.json(), '$.data.categoryList[0].uid'); + [vars.uid2] = jsonpath.query(res.json(), "$.data.categoryList[0].uid"); res = http.post( `${BASE_URL}/api/magento/customQuery`, `[{"query":"\\n query getFacetData($search: String = \\"\\", $filter: ProductAttributeFilterInput, $pageSize: Int = 10, $currentPage: Int = 1, $sort: ProductAttributeSortInput) {\\n products(search: $search, filter: $filter, pageSize: $pageSize, currentPage: $currentPage, sort: $sort) {\\n items {\\n __typename\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n url_key\\n url_rewrites {\\n url\\n }\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n }\\n page_info {\\n current_page\\n page_size\\n total_pages\\n }\\n total_count\\n }\\n }\\n","queryVariables":{"pageSize":10,"search":"","filter":{"category_uid":{"in":["${vars.uid1}"]}},"sort":{"price":"ASC"},"currentPage":1}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(3); }); - group('Filter list by the price', () => { - res = http.post( - `${BASE_URL}/api/magento/route`, - '["/men.html",null]', - { - headers, - }, - ); + group("Filter list by the price", () => { + res = http.post(`${BASE_URL}/api/magento/route`, '["/men.html",null]', { + headers, + }); check(res, { - 'is status 200': (r) => r.status === 200, + "is status 200": (r) => r.status === 200, }); res = http.post( @@ -234,7 +215,7 @@ export default function main() { `[{"query":"\\n query getCategoryContentData($filters: CategoryFilterInput) {\\n categoryList(filters: $filters) {\\n uid\\n display_mode\\n landing_page\\n cms_block {\\n identifier\\n content\\n }\\n }\\n }\\n","queryVariables":{"filters":{"category_uid":{"eq":"${vars.uid2}"}}}}]`, { headers, - }, + } ); executeCommonChecks(res); @@ -243,19 +224,19 @@ export default function main() { `[{"query":"\\n query getFacetData($search: String = \\"\\", $filter: ProductAttributeFilterInput, $pageSize: Int = 10, $currentPage: Int = 1, $sort: ProductAttributeSortInput) {\\n products(search: $search, filter: $filter, pageSize: $pageSize, currentPage: $currentPage, sort: $sort) {\\n items {\\n __typename\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n url_key\\n url_rewrites {\\n url\\n }\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n }\\n page_info {\\n current_page\\n page_size\\n total_pages\\n }\\n total_count\\n }\\n }\\n","queryVariables":{"pageSize":10,"search":"","filter":{"price":{"from":40,"to":50},"category_uid":{"in":["${vars.uid2}"]}},"sort":{"price":"ASC"},"currentPage":1}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(1.6); }); - group('Visit selected product', () => { + group("Visit selected product", () => { res = http.post( `${BASE_URL}/api/magento/productDetail`, '[{"filter":{"sku":{"eq":"MH06"}},"configurations":[]},{"productDetail":"productDetail"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -264,34 +245,22 @@ export default function main() { '[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"MH06"}},"configurations":[]}}]', { headers, - }, + } ); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/upsellProducts`, - '[{"filter":{"sku":{"eq":"MH06"}}},null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/upsellProducts`, '[{"filter":{"sku":{"eq":"MH06"}}},null]', { + headers, + }); - res = http.post( - `${BASE_URL}/api/magento/relatedProduct`, - '[{"filter":{"sku":{"eq":"MH06"}}},null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/relatedProduct`, '[{"filter":{"sku":{"eq":"MH06"}}},null]', { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/productReviewRatingsMetadata`, - '[null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/productReviewRatingsMetadata`, "[null]", { + headers, + }); }); }); } diff --git a/packages/load-tests/src/tests/scenarios/buyProductAsAGuestUser.js b/packages/load-tests/src/tests/scenarios/buyProductAsAGuestUser.js index eb03d6a17..44eebfe9b 100644 --- a/packages/load-tests/src/tests/scenarios/buyProductAsAGuestUser.js +++ b/packages/load-tests/src/tests/scenarios/buyProductAsAGuestUser.js @@ -1,37 +1,37 @@ // Creator: k6 Browser Recorder 0.6.2 -import { check, sleep, group } from 'k6'; -import http from 'k6/http'; -import jsonpath from 'https://jslib.k6.io/jsonpath/1.0.2/index.js'; -import { setDefaultCookies } from './utils/setDefaultCookies.js'; +import { check, sleep, group } from "k6"; +import http from "k6/http"; +import jsonpath from "https://jslib.k6.io/jsonpath/1.0.2/index.js"; +import { setDefaultCookies } from "./utils/setDefaultCookies.js"; export const options = { vus: 200, - duration: '5m', + duration: "5m", thresholds: { - http_req_failed: ['rate<0.01'], // http errors should be less than 1% - http_req_duration: ['p(80)<250'], // 80% of requests should be below 250ms + http_req_failed: ["rate<0.01"], // http errors should be less than 1% + http_req_duration: ["p(80)<250"], // 80% of requests should be below 250ms }, }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } const headers = { - accept: 'application/json, text/plain, */*', - 'content-type': 'application/json', - 'upgrade-insecure-requests': '1', - 'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', + accept: "application/json, text/plain, */*", + "content-type": "application/json", + "upgrade-insecure-requests": "1", + "sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"macOS"', }; const executeCommonChecks = (res) => { check(res, { - 'is status 200': (r) => r.status === 200, - 'has no errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "has no errors": (r) => !r.json().errors, }); }; @@ -42,13 +42,10 @@ export default function main() { setDefaultCookies(BASE_URL); group(`Buy product as a guest user - page ${BASE_URL}`, () => { - group('Visit the homepage', () => { - res = http.get( - `${BASE_URL}/default`, - { - headers, - }, - ); + group("Visit the homepage", () => { + res = http.get(`${BASE_URL}/default`, { + headers, + }); sleep(0.8); res = http.post( @@ -56,7 +53,7 @@ export default function main() { '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -65,7 +62,7 @@ export default function main() { '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -74,7 +71,7 @@ export default function main() { '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', { headers, - }, + } ); executeCommonChecks(res); sleep(2.7); @@ -84,19 +81,15 @@ export default function main() { '[{"query":"\\n query categoryList {\\n categories {\\n items {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n }\\n }\\n }\\n }\\n }\\n }\\n \\n fragment CategoryFields on CategoryTree {\\n is_anchor\\n name\\n position\\n product_count\\n uid\\n url_path\\n url_suffix\\n include_in_menu\\n }\\n\\n"}]', { headers, - }, + } ); executeCommonChecks(res); }); - group('Select the a category', () => { - res = http.post( - `${BASE_URL}/api/magento/route`, - '["/women.html",null]', - { - headers, - }, - ); + group("Select the a category", () => { + res = http.post(`${BASE_URL}/api/magento/route`, '["/women.html",null]', { + headers, + }); executeCommonChecks(res); res = http.post( @@ -104,7 +97,7 @@ export default function main() { '[{"query":"\\n query categoryList {\\n categories {\\n items {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n children {\\n ...CategoryFields\\n }\\n }\\n }\\n }\\n }\\n }\\n \\n fragment CategoryFields on CategoryTree {\\n is_anchor\\n name\\n position\\n product_count\\n uid\\n url_path\\n url_suffix\\n include_in_menu\\n }\\n\\n"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -113,17 +106,17 @@ export default function main() { '[{"query":"\\n query getCategoryContentData($filters: CategoryFilterInput) {\\n categoryList(filters: $filters) {\\n uid\\n display_mode\\n landing_page\\n cms_block {\\n identifier\\n content\\n }\\n }\\n }\\n","queryVariables":{"filters":{"category_uid":{"eq":"MjA="}}}}]', { headers, - }, + } ); executeCommonChecks(res); - [vars.uid1] = jsonpath.query(res.json(), '$.data.categoryList[0].uid'); + [vars.uid1] = jsonpath.query(res.json(), "$.data.categoryList[0].uid"); res = http.post( `${BASE_URL}/api/magento/customQuery`, `[{"query":"\\n query getFacetData($search: String = \\"\\", $filter: ProductAttributeFilterInput, $pageSize: Int = 10, $currentPage: Int = 1, $sort: ProductAttributeSortInput) {\\n products(search: $search, filter: $filter, pageSize: $pageSize, currentPage: $currentPage, sort: $sort) {\\n items {\\n __typename\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n url_key\\n url_rewrites {\\n url\\n }\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n }\\n page_info {\\n current_page\\n page_size\\n total_pages\\n }\\n total_count\\n }\\n }\\n","queryVariables":{"pageSize":10,"search":"","filter":{"category_uid":{"in":["${vars.uid1}"]}},"sort":{},"currentPage":1}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(0.5); @@ -133,19 +126,19 @@ export default function main() { `[{"query":"\\n query getProductFiltersByCategory($categoryIdFilter: FilterEqualTypeInput!) {\\n products(filter: { category_uid: $categoryIdFilter }) {\\n aggregations {\\n label\\n count\\n attribute_code\\n options {\\n count\\n label\\n value\\n __typename\\n }\\n position\\n __typename\\n }\\n __typename\\n }\\n }\\n","queryVariables":{"categoryIdFilter":{"eq":"${vars.uid1}"}}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(2.1); }); - group('configure the product', () => { + group("configure the product", () => { res = http.post( `${BASE_URL}/api/magento/productDetail`, '[{"filter":{"sku":{"eq":"WSH11"}},"configurations":[]},{"productDetail":"productDetail"}]', { headers, - }, + } ); executeCommonChecks(res); @@ -154,35 +147,23 @@ export default function main() { '[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"WSH11"}},"configurations":[]}}]', { headers, - }, + } ); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/upsellProducts`, - '[{"filter":{"sku":{"eq":"WSH11"}}},null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/upsellProducts`, '[{"filter":{"sku":{"eq":"WSH11"}}},null]', { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/relatedProduct`, - '[{"filter":{"sku":{"eq":"WSH11"}}},null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/relatedProduct`, '[{"filter":{"sku":{"eq":"WSH11"}}},null]', { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/productReviewRatingsMetadata`, - '[null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/productReviewRatingsMetadata`, "[null]", { + headers, + }); executeCommonChecks(res); sleep(1.1); @@ -191,18 +172,18 @@ export default function main() { '[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"WSH11"}},"configurations":["Y29uZmlndXJhYmxlLzkzLzU4"]}}]', { headers, - }, + } ); executeCommonChecks(res); [vars.index01] = jsonpath.query( res.json(), - '$.data.products.items[0].configurable_product_options_selection.options_available_for_selection[1].option_value_uids[0]', + "$.data.products.items[0].configurable_product_options_selection.options_available_for_selection[1].option_value_uids[0]" ); [vars.index11] = jsonpath.query( res.json(), - '$.data.products.items[0].configurable_product_options_selection.options_available_for_selection[0].option_value_uids[1]', + "$.data.products.items[0].configurable_product_options_selection.options_available_for_selection[0].option_value_uids[1]" ); sleep(1.6); @@ -212,34 +193,23 @@ export default function main() { `[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"WSH11"}},"configurations":["${vars.index01}","${vars.index11}"]}}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(0.5); }); - group('Add product to the cart', () => { - res = http.post( - `${BASE_URL}/api/magento/createEmptyCart`, - '[]', - { - headers, - }, - ); + group("Add product to the cart", () => { + res = http.post(`${BASE_URL}/api/magento/createEmptyCart`, "[]", { + headers, + }); executeCommonChecks(res); - [vars.cart_id] = jsonpath.query( - res.json(), - '$.data.createEmptyCart', - ); + [vars.cart_id] = jsonpath.query(res.json(), "$.data.createEmptyCart"); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); res = http.post( @@ -247,67 +217,43 @@ export default function main() { `[{"cartId":"${vars.cart_id}","cartItems":[{"quantity":1,"sku":"WSH11","selected_options":["${vars.index01}","${vars.index11}"]}]},null]`, { headers, - }, + } ); executeCommonChecks(res); sleep(3); }); - group('Go through the checkout', () => { - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + group("Go through the checkout", () => { + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); sleep(5.3); - res = http.post( - `${BASE_URL}/api/magento/setGuestEmailOnCart`, - `[{"email":"john.loadtest@gmail.com","cart_id":"${vars.cart_id}"},null]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/setGuestEmailOnCart`, `[{"email":"john.loadtest@gmail.com","cart_id":"${vars.cart_id}"},null]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/countries`, - '[]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/countries`, "[]", { + headers, + }); executeCommonChecks(res); sleep(2.2); - res = http.post( - `${BASE_URL}/api/magento/country`, - '["PL",null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/country`, '["PL",null]', { + headers, + }); executeCommonChecks(res); sleep(3.9); @@ -316,7 +262,7 @@ export default function main() { `[{"cart_id":"${vars.cart_id}","shipping_addresses":[{"address":{"firstname":"john","lastname":"LoadTest","street":["Load Test 11","11"],"city":"Load Test","region":"PL-10","country_code":"PL","postcode":"11-111","telephone":"123123123","save_in_address_book":false}}]}]`, { headers, - }, + } ); executeCommonChecks(res); sleep(1.6); @@ -326,54 +272,34 @@ export default function main() { `[{"cart_id":"${vars.cart_id}","shipping_methods":[{"carrier_code":"flatrate","method_code":"flatrate"}]},null]`, { headers, - }, + } ); executeCommonChecks(res); sleep(1.3); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/countries`, - '[]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/countries`, "[]", { + headers, + }); executeCommonChecks(res); sleep(1.7); - res = http.post( - `${BASE_URL}/api/magento/country`, - '["PL",null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/country`, '["PL",null]', { + headers, + }); - res = http.post( - `${BASE_URL}/api/magento/country`, - '["PL",null]', - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/country`, '["PL",null]', { + headers, + }); executeCommonChecks(res); sleep(1.4); @@ -382,7 +308,7 @@ export default function main() { `[{"cart_id":"${vars.cart_id}","billing_address":{"address":{"firstname":"john","lastname":"LoadTest","street":["Load Test 11","11"],"city":"Load Test","region":"PL-10","country_code":"PL","postcode":"11-111","telephone":"123123123","save_in_address_book":false},"same_as_shipping":true}},null]`, { headers, - }, + } ); executeCommonChecks(res); @@ -391,57 +317,37 @@ export default function main() { `[{"cart_id":"${vars.cart_id}","shipping_methods":[{"carrier_code":"flatrate","method_code":"flatrate"}]},null]`, { headers, - }, + } ); executeCommonChecks(res); sleep(0.5); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); - res = http.post( - `${BASE_URL}/api/magento/cart`, - `["${vars.cart_id}"]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/cart`, `["${vars.cart_id}"]`, { + headers, + }); executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/getAvailablePaymentMethods`, - `[{"cartId":"${vars.cart_id}"},null]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/getAvailablePaymentMethods`, `[{"cartId":"${vars.cart_id}"},null]`, { + headers, + }); executeCommonChecks(res); sleep(1.2); - res = http.post( - `${BASE_URL}/api/magento/setPaymentMethodOnCart`, - `[{"cart_id":"${vars.cart_id}","payment_method":{"code":"checkmo"}},null]`, - { - headers, - }, - ); + res = http.post(`${BASE_URL}/api/magento/setPaymentMethodOnCart`, `[{"cart_id":"${vars.cart_id}","payment_method":{"code":"checkmo"}},null]`, { + headers, + }); executeCommonChecks(res); sleep(1.5); }); - group('Place the order', () => { - res = http.post( - `${BASE_URL}/api/magento/placeOrder`, - `[{"cart_id":"${vars.cart_id}"},null]`, - { - headers, - }, - ); + group("Place the order", () => { + res = http.post(`${BASE_URL}/api/magento/placeOrder`, `[{"cart_id":"${vars.cart_id}"},null]`, { + headers, + }); executeCommonChecks(res); }); }); diff --git a/packages/load-tests/src/tests/scenarios/newUserRegistration.js b/packages/load-tests/src/tests/scenarios/newUserRegistration.js index d35bf8c53..1f96e783e 100644 --- a/packages/load-tests/src/tests/scenarios/newUserRegistration.js +++ b/packages/load-tests/src/tests/scenarios/newUserRegistration.js @@ -1,36 +1,36 @@ // Creator: k6 Browser Recorder 0.6.2 -import { check, sleep, group } from 'k6'; -import http from 'k6/http'; -import { setDefaultCookies } from './utils/setDefaultCookies.js'; -import { customerData } from '../../utils/customerData.js'; +import { check, sleep, group } from "k6"; +import http from "k6/http"; +import { setDefaultCookies } from "./utils/setDefaultCookies.js"; +import { customerData } from "../../utils/customerData.js"; export const options = { vus: 200, - duration: '5m', + duration: "5m", thresholds: { - http_req_failed: ['rate<0.01'], // http errors should be less than 1% + http_req_failed: ["rate<0.01"], // http errors should be less than 1% }, }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } const headers = { - accept: 'application/json, text/plain, */*', - 'content-type': 'application/json', - 'upgrade-insecure-requests': '1', - 'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', + accept: "application/json, text/plain, */*", + "content-type": "application/json", + "upgrade-insecure-requests": "1", + "sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"macOS"', }; const executeCommonChecks = (res) => { check(res, { - 'is status 200': (r) => r.status === 200, - 'has no errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "has no errors": (r) => !r.json().errors, }); }; @@ -38,58 +38,52 @@ export default function main() { let res; setDefaultCookies(BASE_URL); - group( - `New user registration - page ${BASE_URL}`, - () => { - res = http.get( - `${BASE_URL}/default`, + group(`New user registration - page ${BASE_URL}`, () => { + res = http.get(`${BASE_URL}/default`, { + headers, + }); + sleep(0.6); + + group("Input user data", () => { + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', { headers, - }, + } ); - sleep(0.6); - - group('Input user data', () => { - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', - { - headers, - }, - ); - executeCommonChecks(res); + executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', - { - headers, - }, - ); - executeCommonChecks(res); + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', + { + headers, + } + ); + executeCommonChecks(res); - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', - { - headers, - }, - ); - executeCommonChecks(res); - sleep(8); - }); + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', + { + headers, + } + ); + executeCommonChecks(res); + sleep(8); + }); - group('Save new user', () => { - res = http.post( - `${BASE_URL}/api/magento/createCustomer`, - `[{"email":"${customerData.getEmail()}","password":"Admin123!","recaptchaToken":"recaptcha_bypass_code","firstname":"load","lastname":"test","is_subscribed":false},{}]`, - { - headers, - }, - ); - }); + group("Save new user", () => { + res = http.post( + `${BASE_URL}/api/magento/createCustomer`, + `[{"email":"${customerData.getEmail()}","password":"Admin123!","recaptchaToken":"recaptcha_bypass_code","firstname":"load","lastname":"test","is_subscribed":false},{}]`, + { + headers, + } + ); + }); - executeCommonChecks(res); - }, - ); + executeCommonChecks(res); + }); } diff --git a/packages/load-tests/src/tests/scenarios/searchProduct.js b/packages/load-tests/src/tests/scenarios/searchProduct.js index 00137f70a..688cfa1ac 100644 --- a/packages/load-tests/src/tests/scenarios/searchProduct.js +++ b/packages/load-tests/src/tests/scenarios/searchProduct.js @@ -1,37 +1,37 @@ // Creator: k6 Browser Recorder 0.6.2 -import { check, sleep, group } from 'k6'; -import http from 'k6/http'; -import { setDefaultCookies } from './utils/setDefaultCookies.js'; +import { check, sleep, group } from "k6"; +import http from "k6/http"; +import { setDefaultCookies } from "./utils/setDefaultCookies.js"; export const options = { vus: 200, - duration: '5m', + duration: "5m", thresholds: { - http_req_failed: ['rate<0.01'], // http errors should be less than 1% - http_req_duration: ['p(80)<250'], // 80% of requests should be below 250ms + http_req_failed: ["rate<0.01"], // http errors should be less than 1% + http_req_duration: ["p(80)<250"], // 80% of requests should be below 250ms }, }; const { BASE_URL } = __ENV; if (BASE_URL === undefined) { - throw new Error('BASE_URL is not set'); + throw new Error("BASE_URL is not set"); } const headers = { - accept: 'application/json, text/plain, */*', - 'content-type': 'application/json', - 'upgrade-insecure-requests': '1', - 'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', + accept: "application/json, text/plain, */*", + "content-type": "application/json", + "upgrade-insecure-requests": "1", + "sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"macOS"', }; const executeCommonChecks = (res) => { check(res, { - 'is status 200': (r) => r.status === 200, - 'has no errors': (r) => !r.json().errors, + "is status 200": (r) => r.status === 200, + "has no errors": (r) => !r.json().errors, }); }; @@ -39,87 +39,65 @@ export default function main() { let res; setDefaultCookies(BASE_URL); - group( - `Search Product - page ${BASE_URL}`, - () => { - group('Visit the homepage', () => { - res = http.get( - `${BASE_URL}/default`, - { headers }, - ); - check(res, { - 'is status 200': (r) => r.status === 200, - }); - - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', - { headers }, - ); - executeCommonChecks(res); - sleep(4.1); + group(`Search Product - page ${BASE_URL}`, () => { + group("Visit the homepage", () => { + res = http.get(`${BASE_URL}/default`, { headers }); + check(res, { + "is status 200": (r) => r.status === 200, }); - group('Search for a product', () => { - res = http.post( - `${BASE_URL}/api/magento/products`, - '[{"pageSize":12,"search":"erika"},{"products":"products"}]', - { headers }, - ); - executeCommonChecks(res); - sleep(1.9); - }); - - group('Visit the found product', () => { - res = http.post( - `${BASE_URL}/api/magento/productDetail`, - '[{"filter":{"sku":{"eq":"WSH12"}},"configurations":[]},{"productDetail":"productDetail"}]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/customQuery`, - '[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"WSH12"}},"configurations":[]}}]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/relatedProduct`, - '[{"filter":{"sku":{"eq":"WSH12"}}},null]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/upsellProducts`, - '[{"filter":{"sku":{"eq":"WSH12"}}},null]', - { headers }, - ); - executeCommonChecks(res); - - res = http.post( - `${BASE_URL}/api/magento/productReviewRatingsMetadata`, - '[null]', - { headers }, - ); - executeCommonChecks(res); - }); - }, - ); + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query storeConfig {\\n storeConfig {\\n store_code,\\n default_title,\\n store_name,\\n default_display_currency_code,\\n locale,\\n header_logo_src,\\n logo_width,\\n logo_height,\\n logo_alt\\n }\\n }\\n"}]', + { headers } + ); + executeCommonChecks(res); + + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', + { headers } + ); + executeCommonChecks(res); + + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query getStoresAndCurrencies {\\n availableStores {\\n store_code\\n }\\n currency {\\n available_currency_codes\\n }\\n }\\n"}]', + { headers } + ); + executeCommonChecks(res); + sleep(4.1); + }); + + group("Search for a product", () => { + res = http.post(`${BASE_URL}/api/magento/products`, '[{"pageSize":12,"search":"erika"},{"products":"products"}]', { headers }); + executeCommonChecks(res); + sleep(1.9); + }); + + group("Visit the found product", () => { + res = http.post( + `${BASE_URL}/api/magento/productDetail`, + '[{"filter":{"sku":{"eq":"WSH12"}},"configurations":[]},{"productDetail":"productDetail"}]', + { headers } + ); + executeCommonChecks(res); + + res = http.post( + `${BASE_URL}/api/magento/customQuery`, + '[{"query":"\\n query getProductPriceBySku(\\n $filter: ProductAttributeFilterInput,\\n $configurations: [ID!]\\n ) {\\n products(filter: $filter) {\\n items {\\n price_range {\\n ...PriceRangeFields\\n }\\n\\n ... on ConfigurableProduct {\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n configurable_product_options_selection(configurableOptionValueUids: $configurations) {\\n options_available_for_selection {\\n attribute_code\\n option_value_uids\\n }\\n media_gallery {\\n disabled\\n label\\n position\\n url\\n }\\n variant {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n\\n ... on BundleProduct {\\n items {\\n position\\n required\\n sku\\n title\\n type\\n uid\\n options {\\n can_change_quantity\\n is_default\\n position\\n uid\\n quantity\\n product {\\n uid\\n sku\\n name\\n price_range {\\n ...PriceRangeFields\\n }\\n }\\n }\\n }\\n }\\n\\n ... on GroupedProduct {\\n items {\\n position\\n qty\\n product {\\n uid\\n sku\\n name\\n stock_status\\n only_x_left_in_stock\\n price_range {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n thumbnail {\\n url\\n position\\n disabled\\n label\\n }\\n }\\n }\\n }\\n\\n }\\n }\\n }\\n \\n fragment PriceRangeFields on PriceRange {\\n maximum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n minimum_price {\\n final_price {\\n currency\\n value\\n }\\n regular_price {\\n currency\\n value\\n }\\n }\\n }\\n\\n","queryVariables":{"filter":{"sku":{"eq":"WSH12"}},"configurations":[]}}]', + { headers } + ); + executeCommonChecks(res); + + res = http.post(`${BASE_URL}/api/magento/relatedProduct`, '[{"filter":{"sku":{"eq":"WSH12"}}},null]', { headers }); + executeCommonChecks(res); + + res = http.post(`${BASE_URL}/api/magento/upsellProducts`, '[{"filter":{"sku":{"eq":"WSH12"}}},null]', { headers }); + executeCommonChecks(res); + + res = http.post(`${BASE_URL}/api/magento/productReviewRatingsMetadata`, "[null]", { headers }); + executeCommonChecks(res); + }); + }); } diff --git a/packages/load-tests/src/utils/customerData.js b/packages/load-tests/src/utils/customerData.js index 59ed2defb..aa8cde37a 100644 --- a/packages/load-tests/src/utils/customerData.js +++ b/packages/load-tests/src/utils/customerData.js @@ -1,7 +1,7 @@ -const chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; +const chars = "abcdefghijklmnopqrstuvwxyz1234567890"; export const getEmail = (length = 15) => { - let string = ''; + let string = ""; for (let i = 0; i < length; i++) { string += chars[Math.floor(Math.random() * chars.length)]; } diff --git a/packages/load-tests/src/utils/getCookies.js b/packages/load-tests/src/utils/getCookies.js index fefd5d14f..c5be5c758 100644 --- a/packages/load-tests/src/utils/getCookies.js +++ b/packages/load-tests/src/utils/getCookies.js @@ -1,7 +1,7 @@ const getCookies = () => ({ - 'vsf-store': 'default', - 'vsf-locale': 'default', - 'vsf-currency': 'USD', + "vsf-store": "default", + "vsf-locale": "default", + "vsf-currency": "USD", }); export default getCookies; diff --git a/packages/method-bootstrapper/file-operations.js b/packages/method-bootstrapper/file-operations.js index bd0045e1f..61779bb76 100644 --- a/packages/method-bootstrapper/file-operations.js +++ b/packages/method-bootstrapper/file-operations.js @@ -1,9 +1,9 @@ // This file contains functions that modify files in such a way that add a new SDK method -const fsPromises = require('fs/promises'); -const path = require('path'); -const handlebars = require('handlebars'); -const utils = require('./utils'); +const fsPromises = require("fs/promises"); +const path = require("path"); +const handlebars = require("handlebars"); +const utils = require("./utils"); /** * Creates 'src/methods/methodName/index.ts' with partially filled out content @@ -14,22 +14,13 @@ const utils = require('./utils'); * @param {string} methodName Name of the method to create */ module.exports.createMethodImplementationFile = async (methodsDirectoryPath, methodName) => { - console.info('Creating method folder'); + console.info("Creating method folder"); const methodFolderPath = path.join(methodsDirectoryPath, methodName); - await fsPromises.mkdir( - methodFolderPath, - ); + await fsPromises.mkdir(methodFolderPath); const template = handlebars.compile( - await fsPromises.readFile( - path.join( - __dirname, - 'handlebars-templates', - 'method-implementation-file.handlebars', - ), - { encoding: 'utf8' }, - ), + await fsPromises.readFile(path.join(__dirname, "handlebars-templates", "method-implementation-file.handlebars"), { encoding: "utf8" }) ); const contents = template({ @@ -38,11 +29,8 @@ module.exports.createMethodImplementationFile = async (methodsDirectoryPath, met capitalizedMethodName: utils.capitalize(methodName), }); - console.info('Creating method implementation file'); - await fsPromises.writeFile( - path.join(methodFolderPath, 'index.ts'), - contents, - ); + console.info("Creating method implementation file"); + await fsPromises.writeFile(path.join(methodFolderPath, "index.ts"), contents); }; /** @@ -51,11 +39,8 @@ module.exports.createMethodImplementationFile = async (methodsDirectoryPath, met * @param {string} methodName */ module.exports.patchMethodIndexFile = async (methodsDirectoryPath, methodName) => { - console.info('Adding method export to methods index.ts'); - await fsPromises.appendFile( - path.join(methodsDirectoryPath, 'index.ts'), - `export { ${methodName} } from './${methodName}';`, - ); + console.info("Adding method export to methods index.ts"); + await fsPromises.appendFile(path.join(methodsDirectoryPath, "index.ts"), `export { ${methodName} } from './${methodName}';`); }; /** @@ -68,14 +53,7 @@ module.exports.patchMethodIndexFile = async (methodsDirectoryPath, methodName) = */ module.exports.createMethodIntegrationTestFile = async (integrationTestDirectoryPath, methodName) => { const template = handlebars.compile( - await fsPromises.readFile( - path.join( - __dirname, - 'handlebars-templates', - 'method-integration-test-file.handlebars', - ), - { encoding: 'utf8' }, - ), + await fsPromises.readFile(path.join(__dirname, "handlebars-templates", "method-integration-test-file.handlebars"), { encoding: "utf8" }) ); const contents = template({ @@ -84,11 +62,8 @@ module.exports.createMethodIntegrationTestFile = async (integrationTestDirectory capitalizedMethodName: utils.capitalize(methodName), }); - console.info('Creating method integration test file'); - await fsPromises.writeFile( - path.join(integrationTestDirectoryPath, `${methodName}.integration.spec.ts`), - contents, - ); + console.info("Creating method integration test file"); + await fsPromises.writeFile(path.join(integrationTestDirectoryPath, `${methodName}.integration.spec.ts`), contents); }; /** @@ -101,14 +76,7 @@ module.exports.createMethodIntegrationTestFile = async (integrationTestDirectory */ module.exports.createMethodUnitTestFile = async (unitTestDirectoryPath, methodName) => { const template = handlebars.compile( - await fsPromises.readFile( - path.join( - __dirname, - 'handlebars-templates', - 'method-unit-test-file.handlebars', - ), - { encoding: 'utf8' }, - ), + await fsPromises.readFile(path.join(__dirname, "handlebars-templates", "method-unit-test-file.handlebars"), { encoding: "utf8" }) ); const contents = template({ @@ -117,11 +85,8 @@ module.exports.createMethodUnitTestFile = async (unitTestDirectoryPath, methodNa capitalizedMethodName: utils.capitalize(methodName), }); - console.info('Creating method unit test file'); - await fsPromises.writeFile( - path.join(unitTestDirectoryPath, `${methodName}.unit.spec.ts`), - contents, - ); + console.info("Creating method unit test file"); + await fsPromises.writeFile(path.join(unitTestDirectoryPath, `${methodName}.unit.spec.ts`), contents); }; /** @@ -133,22 +98,12 @@ module.exports.createMethodUnitTestFile = async (unitTestDirectoryPath, methodNa * @param {string} methodName */ module.exports.createMethodCustomQueryFile = async (customQueriesDirectoryPath, methodName) => { - const newCustomQueryFolderPath = path.join( - customQueriesDirectoryPath, - methodName, - ); + const newCustomQueryFolderPath = path.join(customQueriesDirectoryPath, methodName); await fsPromises.mkdir(newCustomQueryFolderPath); const template = handlebars.compile( - await fsPromises.readFile( - path.join( - __dirname, - 'handlebars-templates', - 'method-custom-query-file.handlebars', - ), - { encoding: 'utf8' }, - ), + await fsPromises.readFile(path.join(__dirname, "handlebars-templates", "method-custom-query-file.handlebars"), { encoding: "utf8" }) ); const contents = template({ @@ -157,11 +112,8 @@ module.exports.createMethodCustomQueryFile = async (customQueriesDirectoryPath, capitalizedMethodName: utils.capitalize(methodName), }); - console.info('Creating method custom query file'); - await fsPromises.writeFile( - path.join(newCustomQueryFolderPath, 'index.ts'), - contents, - ); + console.info("Creating method custom query file"); + await fsPromises.writeFile(path.join(newCustomQueryFolderPath, "index.ts"), contents); }; /** @@ -175,21 +127,21 @@ module.exports.createMethodCustomQueryFile = async (customQueriesDirectoryPath, * We need to read the file, modify its contents, then write to it again */ module.exports.patchCustomQueriesIndexFile = async (customQueriesDirectoryPath, methodName) => { - console.info('Adding customQuery export to jest.customQueries.ts'); + console.info("Adding customQuery export to jest.customQueries.ts"); - const customQueriesIndexFile = path.join(customQueriesDirectoryPath, 'jest.customQueries.ts'); + const customQueriesIndexFile = path.join(customQueriesDirectoryPath, "jest.customQueries.ts"); - const contents = await fsPromises.readFile(customQueriesIndexFile, { encoding: 'utf8' }); + const contents = await fsPromises.readFile(customQueriesIndexFile, { encoding: "utf8" }); /** * @param {string} fileContents Contents of the `jest.customQueries.ts` file */ const addNewCustomQuery = (fileContents) => { // like findIndex, but starts looking from the end of the array - const customQueriesObjectClosingBraceIndex = fileContents.lastIndexOf('}'); + const customQueriesObjectClosingBraceIndex = fileContents.lastIndexOf("}"); if (customQueriesObjectClosingBraceIndex === -1) { - throw new Error('Couldn\'t find closing brace in jest.customQueries.ts'); + throw new Error("Couldn't find closing brace in jest.customQueries.ts"); } const result = [...fileContents]; @@ -202,9 +154,9 @@ module.exports.patchCustomQueriesIndexFile = async (customQueriesDirectoryPath, // replace 0 array items (append only) ... 0, // add the following contents - ...`,\n '${utils.kebabize(methodName)}-custom-query': ${methodName}`, + ...`,\n '${utils.kebabize(methodName)}-custom-query': ${methodName}` ) - .join(''); + .join(""); result.unshift(`import { ${methodName} } from './${methodName}';\n`); @@ -213,6 +165,6 @@ module.exports.patchCustomQueriesIndexFile = async (customQueriesDirectoryPath, const newContents = addNewCustomQuery(contents); - console.info('Patching jest.customQueries.ts'); + console.info("Patching jest.customQueries.ts"); await fsPromises.writeFile(customQueriesIndexFile, newContents); }; diff --git a/packages/method-bootstrapper/index.js b/packages/method-bootstrapper/index.js index 6c442b7fa..455b7bbc9 100755 --- a/packages/method-bootstrapper/index.js +++ b/packages/method-bootstrapper/index.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -const fsPromises = require('fs/promises'); -const path = require('path'); -const fileOperations = require('./file-operations'); +const fsPromises = require("fs/promises"); +const path = require("path"); +const fileOperations = require("./file-operations"); // Use IIFE for "top level await", because regular top level await is not present in raw node 16 // eslint-disable-next-line unicorn/prefer-top-level-await @@ -9,28 +9,25 @@ const fileOperations = require('./file-operations'); const methodName = process.argv[2]; if (!methodName) { - console.error('\nerror: method name missing\nusage: npx mkmethod [method name]\n'); + console.error("\nerror: method name missing\nusage: npx mkmethod [method name]\n"); return; } const folderWhereTheCommandWasRanIn = process.cwd(); const folders = { - testIntegrations: path.join(folderWhereTheCommandWasRanIn, '__tests__', 'integration'), - testUnit: path.join(folderWhereTheCommandWasRanIn, '__tests__', 'unit'), - methods: path.join(folderWhereTheCommandWasRanIn, 'src', 'methods'), - customQueries: path.join(folderWhereTheCommandWasRanIn, '__tests__', 'integration', '__config__', 'customQueries'), + testIntegrations: path.join(folderWhereTheCommandWasRanIn, "__tests__", "integration"), + testUnit: path.join(folderWhereTheCommandWasRanIn, "__tests__", "unit"), + methods: path.join(folderWhereTheCommandWasRanIn, "src", "methods"), + customQueries: path.join(folderWhereTheCommandWasRanIn, "__tests__", "integration", "__config__", "customQueries"), }; // Checks if all folders required folders are accessible try { - await Promise.all( - Object.values(folders) - .map((folderPath) => fsPromises.access(folderPath)), - ); + await Promise.all(Object.values(folders).map((folderPath) => fsPromises.access(folderPath))); } catch (e) { - throw new Error('The method bootstrapper expects a certain directory structure. One of the folders is inaccessible', { cause: e }); + throw new Error("The method bootstrapper expects a certain directory structure. One of the folders is inaccessible", { cause: e }); } await fileOperations.createMethodImplementationFile(folders.methods, methodName); diff --git a/packages/method-bootstrapper/utils.js b/packages/method-bootstrapper/utils.js index acf7e0fd3..5851b1f30 100644 --- a/packages/method-bootstrapper/utils.js +++ b/packages/method-bootstrapper/utils.js @@ -8,9 +8,9 @@ module.exports.kebabize = (camelCaseString) => .map((letter, index) => { const isUppercase = letter === letter.toUpperCase(); const isFirst = index === 0; - return (isUppercase && !isFirst) ? `-${letter.toLowerCase()}` : letter; + return isUppercase && !isFirst ? `-${letter.toLowerCase()}` : letter; }) - .join(''); + .join(""); /** * @param {string} string diff --git a/yarn.lock b/yarn.lock index 1973291ab..d3d01aa22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2982,10 +2982,10 @@ ts-jest "^29.1.0" ts-node "^10.9.1" -"@vue-storefront/middleware@^3.5.0": - version "3.5.0" - resolved "https://registry.yarnpkg.com/@vue-storefront/middleware/-/middleware-3.5.0.tgz#54221d1419ce20c7433157827f3f572b84c36379" - integrity sha512-jn0pLSiytBSo8F8nPRQEVJGU3K7fkHq5NHvKEEwPQg2KyxMOB6atBTKkWzrIxehfEfATcjhO04+RyxW43QbFBg== +"@vue-storefront/middleware@^3.9.0": + version "3.9.0" + resolved "https://registry.yarnpkg.com/@vue-storefront/middleware/-/middleware-3.9.0.tgz#58ec3c0e5f6c0b706187f8a87c1ee014b92fa4e4" + integrity sha512-4NSga6xlPETMHeROHyANfv8282pV2viBHIW3ivytmxzdWJN1pLh/rwM9sKgPdpjhZF9mBAzxsRCo7KCf5R7Oyw== dependencies: consola "^2.15.3" cookie-parser "^1.4.6" From 4935af904fa5872323ba0970021ca94d95e2211c Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Thu, 28 Mar 2024 07:57:19 +0100 Subject: [PATCH 02/10] BREAKING remove MagentoApiMethods from Config --- packages/api-client/src/types/setup.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/api-client/src/types/setup.ts b/packages/api-client/src/types/setup.ts index a70ece667..de0a2a8be 100644 --- a/packages/api-client/src/types/setup.ts +++ b/packages/api-client/src/types/setup.ts @@ -1,6 +1,5 @@ import { ApolloClient, ApolloClientOptions } from "@apollo/client/core"; import { HttpOptions } from "@apollo/client/link/http/selectHttpOptionsAndBody"; -import { MagentoApiMethods } from "@vue-storefront/magento-types"; export interface Storage { set: (name: string, value: any) => void; @@ -96,7 +95,6 @@ export interface Config extends ClientConfig { customOptions?: ApolloClientOptions; customApolloHttpLinkOptions?: HttpOptions; magentoApiEndpoint: string; - overrides: MagentoApiMethods; recaptcha: RecaptchaConfig; imageProvider: string; magentoBaseUrl: string; From 67c84d51be650e33f320ed281ad685925fbf7ae3 Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Thu, 28 Mar 2024 09:24:50 +0100 Subject: [PATCH 03/10] Align test state with current storeconfig state Somebody changed the magento store config and didnt tell anybody --- packages/api-client/__tests__/mockData/api/storeConfig.ts | 4 ++-- packages/api-client/src/api/storeConfig/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/api-client/__tests__/mockData/api/storeConfig.ts b/packages/api-client/__tests__/mockData/api/storeConfig.ts index ee147805c..e86ff2b64 100644 --- a/packages/api-client/__tests__/mockData/api/storeConfig.ts +++ b/packages/api-client/__tests__/mockData/api/storeConfig.ts @@ -12,7 +12,7 @@ const STORE_CONFIG_MOCK_RESP = { configurable_thumbnail_source: "parent", copyright: "Copyright © 2013-present Magento, Inc. All rights reserved.", default_description: null, - default_display_currency_code: "USD", + default_display_currency_code: "EUR", default_keywords: null, default_title: "Magento Commerce", grid_per_page: 12, @@ -24,7 +24,7 @@ const STORE_CONFIG_MOCK_RESP = { list_mode: "grid-list", list_per_page: 10, list_per_page_values: "5,10,15,20,25", - locale: "en_US", + locale: "en_EN", logo_alt: null, logo_height: null, logo_width: null, diff --git a/packages/api-client/src/api/storeConfig/index.ts b/packages/api-client/src/api/storeConfig/index.ts index 5a30845dc..28370d791 100644 --- a/packages/api-client/src/api/storeConfig/index.ts +++ b/packages/api-client/src/api/storeConfig/index.ts @@ -2,7 +2,7 @@ import { ApolloQueryResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CustomQuery, StoreConfigQuery } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import storeConfigMutation from "./storeConfig"; +import storeConfigQuery from "./storeConfig"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -19,7 +19,7 @@ export async function storeConfig( ): Promise> { const { storeConfig: storeConfigGQL } = context.extendQuery(customQuery, { storeConfig: { - query: storeConfigMutation, + query: storeConfigQuery, }, }); From 9b81f508939576d07ac216061f7714458f35fb38 Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Thu, 28 Mar 2024 09:36:51 +0100 Subject: [PATCH 04/10] fix wrongly renamed methods --- packages/api-client/src/api/cmsBlocks/index.ts | 2 +- packages/api-client/src/api/cmsPage/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-client/src/api/cmsBlocks/index.ts b/packages/api-client/src/api/cmsBlocks/index.ts index d569c8e37..fbf703d55 100644 --- a/packages/api-client/src/api/cmsBlocks/index.ts +++ b/packages/api-client/src/api/cmsBlocks/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] - (optional) - custom GraphQL query that extends the default cmsBlocks query * @param customHeaders (optional) - custom headers that extends the default headers */ -export async function getCmsBlocks( +export async function cmsBlocks( context: Context, identifiers: string, customQuery: CustomQuery = { cmsBlocks: "cmsBlocks" }, diff --git a/packages/api-client/src/api/cmsPage/index.ts b/packages/api-client/src/api/cmsPage/index.ts index 00a79e034..657d35ec6 100644 --- a/packages/api-client/src/api/cmsPage/index.ts +++ b/packages/api-client/src/api/cmsPage/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param customQuery - (optional) - custom query that extends default cmsPage GraphQL query * @param customHeaders (optional) - custom headers that extends the default headers */ -export async function getCmsPage( +export async function cmsPage( context: Context, identifier: string, customQuery: CustomQuery = { cmsPage: "cmsPage" }, From bb133b0b3fb1a2a93b9366cd95245221eb7908ac Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Tue, 9 Apr 2024 22:17:48 +0200 Subject: [PATCH 05/10] refactor: use function syntax --- .changeset/thirty-socks-sleep.md | 4 ++-- packages/api-client/src/api-extractor-data.ts | 3 ++- .../api-client/src/api/addBundleProductsToCart/index.ts | 9 ++++++--- .../api-client/src/api/addProductToWishList/index.ts | 6 +++--- .../api-client/src/api/addSimpleProductsToCart/index.ts | 6 +++--- packages/api-client/src/api/availableStores/index.ts | 6 +++--- packages/api-client/src/api/cartTotalQty/index.ts | 5 +++-- .../api-client/src/api/changeCustomerPassword/index.ts | 6 +++--- packages/api-client/src/api/cmsBlocks/index.ts | 4 ++-- packages/api-client/src/api/cmsPage/index.ts | 4 ++-- packages/api-client/src/api/createCustomer/index.ts | 6 +++--- packages/api-client/src/api/createEmptyCart/index.ts | 5 +++-- packages/api-client/src/api/createProductReview/index.ts | 6 +++--- packages/api-client/src/api/customMutation/index.ts | 7 ++++--- packages/api-client/src/api/customQuery/index.ts | 7 ++++--- packages/api-client/src/api/customer/index.ts | 6 +++--- packages/api-client/src/api/customerOrders/index.ts | 6 +++--- .../api-client/src/api/customerProductReview/index.ts | 6 +++--- .../api-client/src/api/generateCustomerToken/index.ts | 6 +++--- .../src/api/getAvailableCustomerPaymentMethods/index.ts | 6 +++--- .../src/api/getAvailableShippingMethods/index.ts | 6 +++--- packages/api-client/src/api/mergeCarts/index.ts | 6 +++--- packages/api-client/src/api/productReview/index.ts | 6 +++--- .../src/api/productReviewRatingsMetadata/index.ts | 6 +++--- .../src/api/removeProductsFromWishlist/index.ts | 6 +++--- packages/api-client/src/api/reviews/index.ts | 6 +++--- packages/api-client/src/api/revokeCustomerToken/index.ts | 5 +++-- .../api-client/src/api/setBillingAddressOnCart/index.ts | 6 +++--- packages/api-client/src/api/updateCustomer/index.ts | 6 +++--- packages/api-client/src/api/updateCustomerEmail/index.ts | 6 +++--- packages/api-client/src/api/upsellProducts/index.ts | 6 +++--- packages/api-client/src/api/wishlist/index.ts | 6 +++--- packages/api-client/src/api/wishlistItemsCount/index.ts | 5 +++-- packages/api-client/src/types/api/endpoints.ts | 4 ++-- packages/api-client/src/types/context/index.ts | 6 +++--- packages/api-client/src/types/index.ts | 3 +++ 36 files changed, 108 insertions(+), 95 deletions(-) create mode 100644 packages/api-client/src/types/index.ts diff --git a/.changeset/thirty-socks-sleep.md b/.changeset/thirty-socks-sleep.md index 08032423b..6ed7dac07 100644 --- a/.changeset/thirty-socks-sleep.md +++ b/.changeset/thirty-socks-sleep.md @@ -2,14 +2,14 @@ "@vue-storefront/magento-api": major --- -- **[BREAKING]** `Endpoints` interface. Previously, each endpoint contained `context` param, which is internal and shouldn't be exposed in the final interface. Now, `Endpoints` interface properties don't contain `context` param. If you need to use `context` param, you should use `ApiMethods` type. +- **[CHANGED]** `Endpoints` interface. Previously, each endpoint contained `context` param, which is internal and shouldn't be exposed in the final interface. Now, `Endpoints` interface properties don't contain `context` param. If you need to use `context` param, you should use `ApiMethods` type. ```diff - import { Endpoints } from '@vue-storefront/magento-api'; + import { ApiMethods } from '@vue-storefront/magento-api'; ``` -- **[BREAKING]** Removed `ContextualizedEndpoints` type. Use `Endpoints` instead. +- **[CHANGED]** Removed `ContextualizedEndpoints` type. Use `Endpoints` instead. ```diff - import { ContextualizedEndpoints } from '@vue-storefront/magento-api'; diff --git a/packages/api-client/src/api-extractor-data.ts b/packages/api-client/src/api-extractor-data.ts index ae687d105..e1dfc4cbd 100644 --- a/packages/api-client/src/api-extractor-data.ts +++ b/packages/api-client/src/api-extractor-data.ts @@ -1,5 +1,5 @@ /** - * Api Client for Magento 2 integration for Vue Storefront 2. + * `api-client` of Magento 2 integration. * * @remarks * The `@vue-storefront/magento-api` library includes Apollo Client, @@ -10,3 +10,4 @@ */ export * from "./api"; +export * from "./types"; diff --git a/packages/api-client/src/api/addBundleProductsToCart/index.ts b/packages/api-client/src/api/addBundleProductsToCart/index.ts index 2b6430cce..4425fb0f2 100644 --- a/packages/api-client/src/api/addBundleProductsToCart/index.ts +++ b/packages/api-client/src/api/addBundleProductsToCart/index.ts @@ -11,12 +11,15 @@ import addBundleProductsToCartQuery from "./addBundleProductsToCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const addBundleProductsToCart = async ( +/** + * Test + */ +export async function addBundleProductsToCart( context: Context, input: AddBundleProductsToCartInput, customQuery: CustomQuery = { addBundleProductsToCart: "addBundleProductsToCart" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { addBundleProductsToCart: addBundleProductsToCartGQL } = context.extendQuery(customQuery, { addBundleProductsToCart: { query: addBundleProductsToCartQuery, @@ -31,4 +34,4 @@ export const addBundleProductsToCart = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/addProductToWishList/index.ts b/packages/api-client/src/api/addProductToWishList/index.ts index f099f0ade..f210c8e72 100644 --- a/packages/api-client/src/api/addProductToWishList/index.ts +++ b/packages/api-client/src/api/addProductToWishList/index.ts @@ -5,12 +5,12 @@ import addProductsToWishListQuery from "./addProductsToWishlist"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const addProductToWishList = async ( +export async function addProductToWishList( context: Context, input: AddProductsToWishlistMutationVariables, customQuery: CustomQuery = { addProductsToWishlist: "addProductsToWishlist" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { addProductsToWishlist: addProductsToWishlistGQL } = context.extendQuery(customQuery, { addProductsToWishlist: { query: addProductsToWishListQuery, @@ -26,4 +26,4 @@ export const addProductToWishList = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/addSimpleProductsToCart/index.ts b/packages/api-client/src/api/addSimpleProductsToCart/index.ts index 29970e9b6..736842e1f 100644 --- a/packages/api-client/src/api/addSimpleProductsToCart/index.ts +++ b/packages/api-client/src/api/addSimpleProductsToCart/index.ts @@ -10,12 +10,12 @@ import addSimpleProductsToCartQuery from "./addSimpleProductsToCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const addSimpleProductsToCart = async ( +export async function addSimpleProductsToCart( context: Context, input: AddSimpleProductsToCartInput, customQuery: CustomQuery = { addSimpleProductsToCart: "addSimpleProductsToCart" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { addSimpleProductsToCart: addSimpleProductsToCartGQL } = context.extendQuery(customQuery, { addSimpleProductsToCart: { query: addSimpleProductsToCartQuery, @@ -29,4 +29,4 @@ export const addSimpleProductsToCart = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/availableStores/index.ts b/packages/api-client/src/api/availableStores/index.ts index a207dc250..16d0fe4fd 100644 --- a/packages/api-client/src/api/availableStores/index.ts +++ b/packages/api-client/src/api/availableStores/index.ts @@ -9,11 +9,11 @@ import getHeaders from "../getHeaders"; /** * Returns list of available stores */ -export const availableStores = async ( +export async function availableStores( context: Context, customQuery: CustomQuery = { availableStores: "availableStores" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { availableStores: availableStoresGQL } = context.extendQuery(customQuery, { availableStores: { query: availableStoresQuery, @@ -28,4 +28,4 @@ export const availableStores = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/cartTotalQty/index.ts b/packages/api-client/src/api/cartTotalQty/index.ts index b50fb16f8..404b48bce 100644 --- a/packages/api-client/src/api/cartTotalQty/index.ts +++ b/packages/api-client/src/api/cartTotalQty/index.ts @@ -6,8 +6,8 @@ import cartTotalQtyQuery from "./cartTotalQty"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const cartTotalQty = async (context: Context, cartId: string, customHeaders: CustomHeaders = {}): Promise> => - context.client.query({ +export async function cartTotalQty(context: Context, cartId: string, customHeaders: CustomHeaders = {}): Promise> { + return context.client.query({ query: gql` ${cartTotalQtyQuery} `, @@ -16,3 +16,4 @@ export const cartTotalQty = async (context: Context, cartId: string, customHeade headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/api/changeCustomerPassword/index.ts b/packages/api-client/src/api/changeCustomerPassword/index.ts index e6ac15c8b..03279c5d5 100644 --- a/packages/api-client/src/api/changeCustomerPassword/index.ts +++ b/packages/api-client/src/api/changeCustomerPassword/index.ts @@ -9,12 +9,12 @@ import getHeaders from "../getHeaders"; /** * Changes password of the current customer. To override the default query, use the `changeCustomerPassword` query key. */ -export const changeCustomerPassword = async ( +export async function changeCustomerPassword( context: Context, params: { currentPassword: string; newPassword: string }, customQuery: CustomQuery = { changeCustomerPassword: "changeCustomerPassword" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { try { const { changeCustomerPassword: changeCustomerPasswordGQL } = context.extendQuery(customQuery, { changeCustomerPassword: { @@ -41,4 +41,4 @@ export const changeCustomerPassword = async ( } throw error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/cmsBlocks/index.ts b/packages/api-client/src/api/cmsBlocks/index.ts index fbf703d55..49982e7d3 100644 --- a/packages/api-client/src/api/cmsBlocks/index.ts +++ b/packages/api-client/src/api/cmsBlocks/index.ts @@ -2,7 +2,7 @@ import { ApolloQueryResult } from "@apollo/client/core"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CmsBlockQuery, CmsBlockQueryVariables, CustomQuery } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import cmsBlocks from "./cmsBlocks"; +import cmsBlocksQuery from "./cmsBlocks"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -22,7 +22,7 @@ export async function cmsBlocks( ): Promise> { const { cmsBlocks: cmsBlocksGQL } = context.extendQuery(customQuery, { cmsBlocks: { - query: cmsBlocks, + query: cmsBlocksQuery, variables: { identifiers }, }, }); diff --git a/packages/api-client/src/api/cmsPage/index.ts b/packages/api-client/src/api/cmsPage/index.ts index 657d35ec6..178ff738f 100644 --- a/packages/api-client/src/api/cmsPage/index.ts +++ b/packages/api-client/src/api/cmsPage/index.ts @@ -3,7 +3,7 @@ import consola from "consola"; import type { CustomHeaders } from "@vue-storefront/magento-types"; import { CmsPageQuery, CmsPageQueryVariables, CustomQuery } from "@vue-storefront/magento-types"; import gql from "graphql-tag"; -import cmsPage from "./cmsPage"; +import cmsPageQuery from "./cmsPage"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; @@ -23,7 +23,7 @@ export async function cmsPage( try { const { cmsPage: cmsPageGQL } = context.extendQuery(customQuery, { cmsPage: { - query: cmsPage, + query: cmsPageQuery, variables: { identifier }, }, }); diff --git a/packages/api-client/src/api/createCustomer/index.ts b/packages/api-client/src/api/createCustomer/index.ts index da8fa0f73..cc1a7e47e 100644 --- a/packages/api-client/src/api/createCustomer/index.ts +++ b/packages/api-client/src/api/createCustomer/index.ts @@ -11,12 +11,12 @@ import getHeaders from "../getHeaders"; /** * Registers a new customer. To override the default query, use the `createCustomer` query key. */ -export const createCustomer = async ( +export async function createCustomer( context: Context, input: CustomerCreateInput, customQuery: CustomQuery = { createCustomer: "createCustomer" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { try { const { recaptchaToken, ...variables } = input; @@ -60,4 +60,4 @@ export const createCustomer = async ( } throw error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/createEmptyCart/index.ts b/packages/api-client/src/api/createEmptyCart/index.ts index 416115d2d..cbb1bd224 100644 --- a/packages/api-client/src/api/createEmptyCart/index.ts +++ b/packages/api-client/src/api/createEmptyCart/index.ts @@ -6,8 +6,8 @@ import createEmptyCartQuery from "./createEmptyCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const createEmptyCart = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => - context.client.mutate({ +export async function createEmptyCart(context: Context, customHeaders: CustomHeaders = {}): Promise> { + return context.client.mutate({ mutation: gql` ${createEmptyCartQuery} `, @@ -15,3 +15,4 @@ export const createEmptyCart = async (context: Context, customHeaders: CustomHea headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/api/createProductReview/index.ts b/packages/api-client/src/api/createProductReview/index.ts index 862a6b492..b288654cf 100644 --- a/packages/api-client/src/api/createProductReview/index.ts +++ b/packages/api-client/src/api/createProductReview/index.ts @@ -11,11 +11,11 @@ import getHeaders from "../getHeaders"; /** * Creates a new product review */ -export const createProductReview = async ( +export async function createProductReview( context: Context, input: CreateProductReviewInput, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { recaptchaToken, ...variables } = input; if (context.config.recaptcha.isEnabled) { @@ -41,4 +41,4 @@ export const createProductReview = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/customMutation/index.ts b/packages/api-client/src/api/customMutation/index.ts index 80a62f501..8b27d84a6 100644 --- a/packages/api-client/src/api/customMutation/index.ts +++ b/packages/api-client/src/api/customMutation/index.ts @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const customMutation = async ( +export async function customMutation( context: Context, { mutation, @@ -17,8 +17,8 @@ export const customMutation = async ( fetchPolicy?: Extract; customHeaders?: CustomHeaders; } -): Promise> => - context.client.mutate({ +): Promise> { + return context.client.mutate({ mutation: gql` ${mutation} `, @@ -28,3 +28,4 @@ export const customMutation = async ( headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/api/customQuery/index.ts b/packages/api-client/src/api/customQuery/index.ts index 71fc11803..c11758ae9 100644 --- a/packages/api-client/src/api/customQuery/index.ts +++ b/packages/api-client/src/api/customQuery/index.ts @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const customQuery = async ( +export async function customQuery( context: Context, { query, @@ -17,8 +17,8 @@ export const customQuery = async ( fetchPolicy?: FetchPolicy; customHeaders?: CustomHeaders; } -): Promise> => - context.client.query({ +): Promise> { + return context.client.query({ query: gql` ${query} `, @@ -28,3 +28,4 @@ export const customQuery = async ( headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/api/customer/index.ts b/packages/api-client/src/api/customer/index.ts index d1c29bca0..7322837a0 100644 --- a/packages/api-client/src/api/customer/index.ts +++ b/packages/api-client/src/api/customer/index.ts @@ -8,11 +8,11 @@ import getHeaders from "../getHeaders"; /** * Returns the information about the current customer. To override the default query, use the `customer` query key. */ -export const customer = async ( +export async function customer( context: Context, customQuery: CustomQuery = { customer: "customer" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { customer: customerGQL } = context.extendQuery(customQuery, { customer: { query: customerQuery, @@ -27,4 +27,4 @@ export const customer = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/customerOrders/index.ts b/packages/api-client/src/api/customerOrders/index.ts index 39ca1a748..27a106e9b 100644 --- a/packages/api-client/src/api/customerOrders/index.ts +++ b/packages/api-client/src/api/customerOrders/index.ts @@ -20,12 +20,12 @@ type Variables = { /** * Returns customer orders. To override the default query, use the `customerOrders` query key. */ -export const customerOrders = async ( +export async function customerOrders( context: Context, searchParams: GetOrdersSearchParams, customQuery: CustomQuery = { customerOrders: "customerOrders" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -57,4 +57,4 @@ export const customerOrders = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/customerProductReview/index.ts b/packages/api-client/src/api/customerProductReview/index.ts index e6e150b9a..c96be6e81 100644 --- a/packages/api-client/src/api/customerProductReview/index.ts +++ b/packages/api-client/src/api/customerProductReview/index.ts @@ -17,12 +17,12 @@ import getHeaders from "../getHeaders"; * @deprecated Use {@link @vue-storefront/magento-api#reviews} instead. * */ -export const customerProductReview = async ( +export async function customerProductReview( context: Context, searchParams?: CustomerProductReviewParams, customQuery: CustomQuery = { reviews: "reviews" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -53,4 +53,4 @@ export const customerProductReview = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/generateCustomerToken/index.ts b/packages/api-client/src/api/generateCustomerToken/index.ts index 627f93c96..368495eff 100644 --- a/packages/api-client/src/api/generateCustomerToken/index.ts +++ b/packages/api-client/src/api/generateCustomerToken/index.ts @@ -11,7 +11,7 @@ import getHeaders from "../getHeaders"; /** * Logs in the customer based on provided username and password. To override the default query, use the `generateCustomerToken` query key. */ -export const generateCustomerToken = async ( +export async function generateCustomerToken( context: Context, params: { email: string; @@ -20,7 +20,7 @@ export const generateCustomerToken = async ( }, customQuery: CustomQuery = { generateCustomerToken: "generateCustomerToken" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { try { if (context.config.recaptcha.isEnabled) { /** @@ -65,4 +65,4 @@ export const generateCustomerToken = async ( } throw error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts b/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts index b5cf92751..50231c910 100644 --- a/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts +++ b/packages/api-client/src/api/getAvailableCustomerPaymentMethods/index.ts @@ -6,10 +6,10 @@ import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; import CustomerAvailablePaymentMethods from "./CustomerPaymentMethods"; -export const getAvailableCustomerPaymentMethods = async ( +export async function getAvailableCustomerPaymentMethods( context: Context, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { try { return await context.client.query({ query: gql` @@ -22,4 +22,4 @@ export const getAvailableCustomerPaymentMethods = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/getAvailableShippingMethods/index.ts b/packages/api-client/src/api/getAvailableShippingMethods/index.ts index 0d220dfc8..51705f4b1 100644 --- a/packages/api-client/src/api/getAvailableShippingMethods/index.ts +++ b/packages/api-client/src/api/getAvailableShippingMethods/index.ts @@ -5,12 +5,12 @@ import { Context } from "../../types/context"; import GuestAvailableShippingMethods from "./GuestAvailableShippingMethods"; import getHeaders from "../getHeaders"; -export const getAvailableShippingMethods = async ( +export async function getAvailableShippingMethods( context: Context, params: GuestAvailableShippingMethodsQueryVariables, customQuery: CustomQuery = { shippingMethods: "shippingMethods" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { shippingMethods } = context.extendQuery(customQuery, { shippingMethods: { query: GuestAvailableShippingMethods, @@ -31,4 +31,4 @@ export const getAvailableShippingMethods = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/mergeCarts/index.ts b/packages/api-client/src/api/mergeCarts/index.ts index b20428dcc..c6bc66895 100644 --- a/packages/api-client/src/api/mergeCarts/index.ts +++ b/packages/api-client/src/api/mergeCarts/index.ts @@ -5,7 +5,7 @@ import mergeCartsQuery from "./mergeCarts"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const mergeCarts = async ( +export async function mergeCarts( context: Context, params: { sourceCartId: string; @@ -13,7 +13,7 @@ export const mergeCarts = async ( }, customQuery: CustomQuery = { mergeCarts: "mergeCarts" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { mergeCarts: mergeCartsGQL } = context.extendQuery(customQuery, { mergeCarts: { query: mergeCartsQuery, @@ -33,4 +33,4 @@ export const mergeCarts = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/productReview/index.ts b/packages/api-client/src/api/productReview/index.ts index 21c9f778e..129aae401 100644 --- a/packages/api-client/src/api/productReview/index.ts +++ b/packages/api-client/src/api/productReview/index.ts @@ -24,12 +24,12 @@ type Variables = { /** * Returns reviews of the provided product */ -export const productReview = async ( +export async function productReview( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { productReview: "productReview" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -67,4 +67,4 @@ export const productReview = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/productReviewRatingsMetadata/index.ts b/packages/api-client/src/api/productReviewRatingsMetadata/index.ts index c78e9d247..d092e9e1f 100644 --- a/packages/api-client/src/api/productReviewRatingsMetadata/index.ts +++ b/packages/api-client/src/api/productReviewRatingsMetadata/index.ts @@ -8,11 +8,11 @@ import getHeaders from "../getHeaders"; /** * Returns the active ratings attributes and the values each rating can have. */ -export const productReviewRatingsMetadata = async ( +export async function productReviewRatingsMetadata( context: Context, customQuery: CustomQuery = { productReviewRatingsMetadata: "productReviewRatingsMetadata" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { productReviewRatingsMetadata: productReviewRatingsMetadataGQL } = context.extendQuery(customQuery, { productReviewRatingsMetadata: { query: productReviewRatingsMetadataQuery, @@ -27,4 +27,4 @@ export const productReviewRatingsMetadata = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/removeProductsFromWishlist/index.ts b/packages/api-client/src/api/removeProductsFromWishlist/index.ts index ebd3a9e94..86f66bf22 100644 --- a/packages/api-client/src/api/removeProductsFromWishlist/index.ts +++ b/packages/api-client/src/api/removeProductsFromWishlist/index.ts @@ -6,12 +6,12 @@ import removeProductsFromWishlistQuery from "./removeProductsFromWishlist"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const removeProductsFromWishlist = async ( +export async function removeProductsFromWishlist( context: Context, input: RemoveProductsFromWishlistMutationVariables, customQuery: CustomQuery = { removeProductsFromWishlist: "removeProductsFromWishlist" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { removeProductsFromWishlist: removeProductsFromWishlistGQL } = context.extendQuery(customQuery, { removeProductsFromWishlist: { query: removeProductsFromWishlistQuery, @@ -28,4 +28,4 @@ export const removeProductsFromWishlist = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/reviews/index.ts b/packages/api-client/src/api/reviews/index.ts index 4ded7ada5..0014ed715 100644 --- a/packages/api-client/src/api/reviews/index.ts +++ b/packages/api-client/src/api/reviews/index.ts @@ -14,12 +14,12 @@ import getHeaders from "../getHeaders"; /** * Returns product reviews created by the current customer */ -export const reviews = async ( +export async function reviews( context: Context, searchParams?: CustomerProductReviewParams, customQuery: CustomQuery = { reviews: "reviews" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -50,4 +50,4 @@ export const reviews = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/revokeCustomerToken/index.ts b/packages/api-client/src/api/revokeCustomerToken/index.ts index d8e0e4628..d9d0d3812 100644 --- a/packages/api-client/src/api/revokeCustomerToken/index.ts +++ b/packages/api-client/src/api/revokeCustomerToken/index.ts @@ -9,8 +9,8 @@ import getHeaders from "../getHeaders"; /** * Logs out the current customer. To override the default query, use the `revokeCustomerToken` query key. */ -export const revokeCustomerToken = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => - context.client.mutate({ +export async function revokeCustomerToken(context: Context, customHeaders: CustomHeaders = {}): Promise> { + return context.client.mutate({ mutation: gql` ${revokeCustomerTokenMutation} `, @@ -18,3 +18,4 @@ export const revokeCustomerToken = async (context: Context, customHeaders: Custo headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/api/setBillingAddressOnCart/index.ts b/packages/api-client/src/api/setBillingAddressOnCart/index.ts index 2b21f3464..a63cbbc9d 100644 --- a/packages/api-client/src/api/setBillingAddressOnCart/index.ts +++ b/packages/api-client/src/api/setBillingAddressOnCart/index.ts @@ -11,12 +11,12 @@ import setBillingAddressOnCartQuery from "./setBillingAddressOnCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const setBillingAddressOnCart = async ( +export async function setBillingAddressOnCart( context: Context, input: SetBillingAddressOnCartInput, customQuery: CustomQuery = { setBillingAddressOnCart: "setBillingAddressOnCart" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { setBillingAddressOnCart: setBillingAddressOnCartGQL } = context.extendQuery(customQuery, { setBillingAddressOnCart: { query: setBillingAddressOnCartQuery, @@ -33,4 +33,4 @@ export const setBillingAddressOnCart = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/updateCustomer/index.ts b/packages/api-client/src/api/updateCustomer/index.ts index 70e5c7014..3e586feee 100644 --- a/packages/api-client/src/api/updateCustomer/index.ts +++ b/packages/api-client/src/api/updateCustomer/index.ts @@ -9,12 +9,12 @@ import getHeaders from "../getHeaders"; /** * Updates the data of the current customer. To override the default query, use the `updateCustomer` query key. */ -export const updateCustomer = async ( +export async function updateCustomer( context: Context, input: CustomerUpdateInput, customQuery: CustomQuery = { updateCustomer: "updateCustomer" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { updateCustomer: updateCustomerGQL } = context.extendQuery(customQuery, { updateCustomer: { query: updateCustomerQuery, @@ -31,4 +31,4 @@ export const updateCustomer = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/updateCustomerEmail/index.ts b/packages/api-client/src/api/updateCustomerEmail/index.ts index 941984040..c2823f787 100644 --- a/packages/api-client/src/api/updateCustomerEmail/index.ts +++ b/packages/api-client/src/api/updateCustomerEmail/index.ts @@ -5,12 +5,12 @@ import updateCustomerEmailQuery from "./updateCustomerEmail"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const updateCustomerEmail = async ( +export async function updateCustomerEmail( context: Context, input: UpdateCustomerEmailMutationVariables, customQuery: CustomQuery = { updateCustomerEmail: "updateCustomerEmail" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const { updateCustomerEmail: updateCustomerEmailGQL } = context.extendQuery(customQuery, { updateCustomerEmail: { query: updateCustomerEmailQuery, @@ -27,4 +27,4 @@ export const updateCustomerEmail = async ( headers: getHeaders(context, customHeaders), }, }); -}; +} diff --git a/packages/api-client/src/api/upsellProducts/index.ts b/packages/api-client/src/api/upsellProducts/index.ts index a9ff21001..0fdb4b62d 100644 --- a/packages/api-client/src/api/upsellProducts/index.ts +++ b/packages/api-client/src/api/upsellProducts/index.ts @@ -24,12 +24,12 @@ type Variables = { /** * Returns upsell products matching the provided parameters. To override the default query, use the `upsellProducts` query key. */ -export const upsellProducts = async ( +export async function upsellProducts( context: Context, searchParams?: GetProductSearchParams, customQuery: CustomQuery = { upsellProducts: "upsellProducts" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -67,4 +67,4 @@ export const upsellProducts = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/wishlist/index.ts b/packages/api-client/src/api/wishlist/index.ts index 99cc15a73..f74a729d3 100644 --- a/packages/api-client/src/api/wishlist/index.ts +++ b/packages/api-client/src/api/wishlist/index.ts @@ -10,12 +10,12 @@ type Variables = { currentPage: number; }; -export const wishlist = async ( +export async function wishlist( context: Context, searchParams: WishlistQueryVariables, customQuery: CustomQuery = { wishlist: "wishlist" }, customHeaders: CustomHeaders = {} -): Promise> => { +): Promise> { const defaultParams = { pageSize: 10, currentPage: 1, @@ -44,4 +44,4 @@ export const wishlist = async ( } catch (error) { throw error.graphQLErrors?.[0].message || error.networkError?.result || error; } -}; +} diff --git a/packages/api-client/src/api/wishlistItemsCount/index.ts b/packages/api-client/src/api/wishlistItemsCount/index.ts index 8d7fe65ba..6afa345ff 100644 --- a/packages/api-client/src/api/wishlistItemsCount/index.ts +++ b/packages/api-client/src/api/wishlistItemsCount/index.ts @@ -6,8 +6,8 @@ import wishlistItemsCountQuery from "./wishlistItemsCount"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -export const wishlistItemsCount = async (context: Context, customHeaders: CustomHeaders = {}): Promise> => - context.client.query({ +export async function wishlistItemsCount(context: Context, customHeaders: CustomHeaders = {}): Promise> { + return context.client.query({ query: gql` ${wishlistItemsCountQuery} `, @@ -15,3 +15,4 @@ export const wishlistItemsCount = async (context: Context, customHeaders: Custom headers: getHeaders(context, customHeaders), }, }); +} diff --git a/packages/api-client/src/types/api/endpoints.ts b/packages/api-client/src/types/api/endpoints.ts index cadf78755..4f732f31b 100644 --- a/packages/api-client/src/types/api/endpoints.ts +++ b/packages/api-client/src/types/api/endpoints.ts @@ -2,11 +2,11 @@ import { WithoutContext } from "@vue-storefront/middleware"; import * as apiMethods from "../../api"; /** - * ApiMethods type of the Magento 2 integration. + * Methods of the API client. */ export type ApiMethods = typeof apiMethods; /** - * Interface of the Magento 2 integration + * Endpoints available in the Magento integration. */ export type Endpoints = WithoutContext; diff --git a/packages/api-client/src/types/context/index.ts b/packages/api-client/src/types/context/index.ts index a879992c4..c5c0813b4 100644 --- a/packages/api-client/src/types/context/index.ts +++ b/packages/api-client/src/types/context/index.ts @@ -1,5 +1,5 @@ -import { type ApiClientMethods, type IntegrationContext } from "@vue-storefront/middleware"; +import { type IntegrationContext } from "@vue-storefront/middleware"; import { type ClientInstance, type Config } from "../setup"; -import { type Endpoints } from "../api" +import { type Endpoints } from "../api"; -export type Context = IntegrationContext>; +export type Context = IntegrationContext; diff --git a/packages/api-client/src/types/index.ts b/packages/api-client/src/types/index.ts new file mode 100644 index 000000000..f50a0b45d --- /dev/null +++ b/packages/api-client/src/types/index.ts @@ -0,0 +1,3 @@ +export * from "./api"; +export * from "./context"; +export * from "./setup"; From 001250753666a06eb0fae37229233917c8d4d32c Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Tue, 9 Apr 2024 22:26:38 +0200 Subject: [PATCH 06/10] remove test comment --- packages/api-client/src/api/addBundleProductsToCart/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/api-client/src/api/addBundleProductsToCart/index.ts b/packages/api-client/src/api/addBundleProductsToCart/index.ts index 4425fb0f2..ba0d6fe49 100644 --- a/packages/api-client/src/api/addBundleProductsToCart/index.ts +++ b/packages/api-client/src/api/addBundleProductsToCart/index.ts @@ -11,9 +11,6 @@ import addBundleProductsToCartQuery from "./addBundleProductsToCart"; import { Context } from "../../types/context"; import getHeaders from "../getHeaders"; -/** - * Test - */ export async function addBundleProductsToCart( context: Context, input: AddBundleProductsToCartInput, From a2821263b5d3054ca556fd7d1233a8552a32a947 Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Wed, 10 Apr 2024 12:28:22 +0200 Subject: [PATCH 07/10] revert prop removal --- packages/api-client/src/types/setup.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/api-client/src/types/setup.ts b/packages/api-client/src/types/setup.ts index de0a2a8be..29a2b7a54 100644 --- a/packages/api-client/src/types/setup.ts +++ b/packages/api-client/src/types/setup.ts @@ -1,5 +1,6 @@ import { ApolloClient, ApolloClientOptions } from "@apollo/client/core"; import { HttpOptions } from "@apollo/client/link/http/selectHttpOptionsAndBody"; +import { Endpoints } from "./api"; export interface Storage { set: (name: string, value: any) => void; @@ -95,6 +96,7 @@ export interface Config extends ClientConfig { customOptions?: ApolloClientOptions; customApolloHttpLinkOptions?: HttpOptions; magentoApiEndpoint: string; + overrides: Endpoints; recaptcha: RecaptchaConfig; imageProvider: string; magentoBaseUrl: string; From 26b1c4920fcce8f71c4c1974907261d9a71c0317 Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Wed, 10 Apr 2024 12:43:32 +0200 Subject: [PATCH 08/10] fix build issues --- packages/api-client/rollup.config.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/api-client/rollup.config.js b/packages/api-client/rollup.config.js index cce6f33a1..029049b21 100644 --- a/packages/api-client/rollup.config.js +++ b/packages/api-client/rollup.config.js @@ -1,12 +1,7 @@ -import json from "@rollup/plugin-json"; - import { generateBaseConfig, generateServerConfig } from "@vue-storefront/rollup-config"; import package_ from "./package.json"; const baseConfig = generateBaseConfig(package_); const serverConfig = generateServerConfig(package_); -baseConfig.plugins.push(json()); -serverConfig.plugins.push(json()); - export default [baseConfig, serverConfig]; From 37d3e34f1ef314915e59715d5af92f58f3740b29 Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Thu, 11 Apr 2024 10:47:07 +0200 Subject: [PATCH 09/10] update eslint dependencies --- package.json | 2 +- packages/api-client/src/types/api/index.ts | 2 +- yarn.lock | 111 +++++++++++++-------- 3 files changed, 69 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 283a8ac54..5e665d20f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "devDependencies": { "@changesets/cli": "^2.26.1", "@vue-storefront/api-extractor-config": "^0.0.5", - "@vue-storefront/eslint-config-integrations": "^0.0.20", + "@vue-storefront/eslint-config-integrations": "^0.0.21", "@vue-storefront/integrations-tsconfig": "^0.0.4", "@vue-storefront/jest-config": "^0.0.4", "@vue-storefront/rollup-config": "^0.0.7", diff --git a/packages/api-client/src/types/api/index.ts b/packages/api-client/src/types/api/index.ts index c87f309a7..6615d73b9 100644 --- a/packages/api-client/src/types/api/index.ts +++ b/packages/api-client/src/types/api/index.ts @@ -1 +1 @@ -export * from './endpoints'; +export * from "./endpoints"; diff --git a/yarn.lock b/yarn.lock index d34513eb7..6a457dc57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -875,10 +875,15 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== -"@eslint/eslintrc@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.0.tgz#82256f164cc9e0b59669efc19d57f8092706841d" - integrity sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A== +"@eslint-community/regexpp@^4.6.1": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" + integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== + +"@eslint/eslintrc@^2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad" + integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -890,10 +895,10 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.44.0": - version "8.44.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.44.0.tgz#961a5903c74139390478bdc808bcde3fc45ab7af" - integrity sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw== +"@eslint/js@8.57.0": + version "8.57.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f" + integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g== "@gar/promisify@^1.0.1": version "1.1.3" @@ -1288,13 +1293,13 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@humanwhocodes/config-array@^0.11.10": - version "0.11.10" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.10.tgz#5a3ffe32cc9306365fb3fd572596cd602d5e12d2" - integrity sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ== +"@humanwhocodes/config-array@^0.11.14": + version "0.11.14" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b" + integrity sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg== dependencies: - "@humanwhocodes/object-schema" "^1.2.1" - debug "^4.1.1" + "@humanwhocodes/object-schema" "^2.0.2" + debug "^4.3.1" minimatch "^3.0.5" "@humanwhocodes/module-importer@^1.0.1": @@ -1302,10 +1307,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== -"@humanwhocodes/object-schema@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" - integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@humanwhocodes/object-schema@^2.0.2": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" + integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== "@hutson/parse-repository-url@^3.0.0": version "3.0.2" @@ -3063,6 +3068,11 @@ "@typescript-eslint/types" "5.61.0" eslint-visitor-keys "^3.3.0" +"@ungap/structured-clone@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" + integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== + "@vue-storefront/api-extractor-config@^0.0.5": version "0.0.5" resolved "https://registry.yarnpkg.com/@vue-storefront/api-extractor-config/-/api-extractor-config-0.0.5.tgz#61fc8a380202531bf82584bdb417e468a2e533a4" @@ -3071,14 +3081,14 @@ "@microsoft/api-documenter" "^7.13.30" "@microsoft/api-extractor" "^7.18.1" -"@vue-storefront/eslint-config-integrations@^0.0.20": - version "0.0.20" - resolved "https://registry.yarnpkg.com/@vue-storefront/eslint-config-integrations/-/eslint-config-integrations-0.0.20.tgz#eaf2851eb33bde0a7a0c9194f9e15a6f194cf953" - integrity sha512-iWhadbcxdL9mDKZ+mlw+mCnbSNSXxmrPNbrvcW12w3IqfvmMf0eGUf+f5/ySplgotnNOKIN2+Sq5B9YwLf3V/g== +"@vue-storefront/eslint-config-integrations@^0.0.21": + version "0.0.21" + resolved "https://registry.yarnpkg.com/@vue-storefront/eslint-config-integrations/-/eslint-config-integrations-0.0.21.tgz#12a5a664859288274bb6502da21c68ce8062bd55" + integrity sha512-leD6wYorkZ+a++k0OAQ8iWkqBkPQTuK8F3HxNI7+cTpJjF249G5v9arrkSsxWc47v1dt8zAdetA//tDLweBuew== dependencies: "@typescript-eslint/eslint-plugin" "^5.59.9" "@typescript-eslint/parser" "^5.59.9" - eslint "^8.42.0" + eslint "^8.55.0" eslint-config-airbnb-base "^15.0.0" eslint-config-prettier "^8.8.0" eslint-plugin-import "^2.27.5" @@ -3352,7 +3362,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@~6.12.6: +ajv@^6.12.3, ajv@^6.12.4, ajv@~6.12.6: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -5190,10 +5200,10 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-scope@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.0.tgz#f21ebdafda02352f103634b96dd47d9f81ca117b" - integrity sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw== +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" @@ -5203,27 +5213,33 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== -eslint@^8.42.0: - version "8.44.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.44.0.tgz#51246e3889b259bbcd1d7d736a0c10add4f0e500" - integrity sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A== +eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + +eslint@^8.55.0: + version "8.57.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668" + integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ== dependencies: "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.4.0" - "@eslint/eslintrc" "^2.1.0" - "@eslint/js" "8.44.0" - "@humanwhocodes/config-array" "^0.11.10" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.4" + "@eslint/js" "8.57.0" + "@humanwhocodes/config-array" "^0.11.14" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" - ajv "^6.10.0" + "@ungap/structured-clone" "^1.2.0" + ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" doctrine "^3.0.0" escape-string-regexp "^4.0.0" - eslint-scope "^7.2.0" - eslint-visitor-keys "^3.4.1" - espree "^9.6.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -5233,7 +5249,6 @@ eslint@^8.42.0: globals "^13.19.0" graphemer "^1.4.0" ignore "^5.2.0" - import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" is-path-inside "^3.0.3" @@ -5245,7 +5260,6 @@ eslint@^8.42.0: natural-compare "^1.4.0" optionator "^0.9.3" strip-ansi "^6.0.1" - strip-json-comments "^3.1.0" text-table "^0.2.0" espree@^9.6.0: @@ -5257,6 +5271,15 @@ espree@^9.6.0: acorn-jsx "^5.3.2" eslint-visitor-keys "^3.4.1" +espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== + dependencies: + acorn "^8.9.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" + esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" @@ -6253,7 +6276,7 @@ immutable@~3.7.6: resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.7.6.tgz#13b4d3cb12befa15482a26fe1b2ebae640071e4b" integrity sha512-AizQPcaofEtO11RZhPPHBOJRdo/20MKQF9mBLnVkBoyHi1/zXK8fzVdnEpSV9gxqtnh6Qomfp3F0xT5qP/vThw== -import-fresh@^3.0.0, import-fresh@^3.2.1: +import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -9958,7 +9981,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: +strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== From a948cf6475dd939c38ae68946a8838dcf5c1209c Mon Sep 17 00:00:00 2001 From: Wojciech Sikora Date: Thu, 11 Apr 2024 10:57:30 +0200 Subject: [PATCH 10/10] fix test issues --- packages/api-client/src/api/categories/index.ts | 2 +- packages/api-client/src/api/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/api-client/src/api/categories/index.ts b/packages/api-client/src/api/categories/index.ts index 9c8dbe99f..852d21ac0 100644 --- a/packages/api-client/src/api/categories/index.ts +++ b/packages/api-client/src/api/categories/index.ts @@ -14,7 +14,7 @@ import getHeaders from "../getHeaders"; * @param [customQuery] (optional) - custom GraphQL query that extends the default query * @param customHeaders (optional) - custom headers that extends the default headers */ -export default async function categories( +export async function categories( context: Context, params: QueryCategoriesArgs, customQuery: CustomQuery = { categories: "categories" }, diff --git a/packages/api-client/src/api/index.ts b/packages/api-client/src/api/index.ts index 05c2cdee4..97afd3e36 100644 --- a/packages/api-client/src/api/index.ts +++ b/packages/api-client/src/api/index.ts @@ -9,6 +9,7 @@ export * from "./applyCouponToCart"; export * from "./availableStores"; export * from "./cart"; export * from "./cartTotalQty"; +export * from "./categories"; export * from "./categoryList"; export * from "./categorySearch"; export * from "./changeCustomerPassword";