Skip to content

Commit

Permalink
IN-4072 Use proxy-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
sethidden committed Mar 28, 2024
1 parent f58b16c commit 0aa5752
Show file tree
Hide file tree
Showing 95 changed files with 673 additions and 1,233 deletions.
17 changes: 17 additions & 0 deletions .changeset/thirty-socks-sleep.md
Original file line number Diff line number Diff line change
@@ -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';
```

- [REMOVED] `ContextualizedEndpoints` type. Use `Endpoints` instead.

```diff
- import { ContextualizedEndpoints } from '@vue-storefront/magento-api';
+ import { Endpoints } from '@vue-storefront/magento-api';
```
2 changes: 1 addition & 1 deletion packages/api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/addBundleProductsToCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ 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" },
customHeaders: CustomHeaders = {}
): Promise<FetchResult<AddBundleProductsToCartMutation>> => {
const { addBundleProductsToCart: addBundleProductsToCartGQL } = context.extendQuery(customQuery, {
addBundleProductsToCart: {
query: addBundleProductsToCart,
query: addBundleProductsToCartQuery,
variables: { input },
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/addProductToWishList/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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" },
customHeaders: CustomHeaders = {}
): Promise<FetchResult<AddProductsToWishlistMutation>> => {
const { addProductsToWishlist: addProductsToWishlistGQL } = context.extendQuery(customQuery, {
addProductsToWishlist: {
query: addProductsToWishlist,
query: addProductsToWishListQuery,
variables: { ...input },
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/addProductsToCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/addSimpleProductsToCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ 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" },
customHeaders: CustomHeaders = {}
): Promise<FetchResult<AddSimpleProductsToCartMutation>> => {
const { addSimpleProductsToCart: addSimpleProductsToCartGQL } = context.extendQuery(customQuery, {
addSimpleProductsToCart: {
query: addSimpleProductsToCart,
query: addSimpleProductsToCartQuery,
variables: { input },
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/applyCouponToCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/availableStores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApolloQueryResult<AvailableStoresQuery>> => {
const { availableStores: availableStoresGQL } = context.extendQuery(customQuery, {
availableStores: {
query: availableStores,
query: availableStoresQuery,
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/cart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/cartTotalQty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApolloQueryResult<CartQuery>> =>
export const cartTotalQty = async (context: Context, cartId: string, customHeaders: CustomHeaders = {}): Promise<ApolloQueryResult<CartQuery>> =>
context.client.query<CartQuery, CartQueryVariables>({
query: gql`
${cartTotalQtyQuery}
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/categoryList/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/categorySearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/changeCustomerPassword/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -18,7 +18,7 @@ export default async (
try {
const { changeCustomerPassword: changeCustomerPasswordGQL } = context.extendQuery(customQuery, {
changeCustomerPassword: {
query: changeCustomerPassword,
query: changeCustomerPasswordQuery,
variables: { ...params },
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/cmsBlocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/cmsPage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/countries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/country/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/createCustomer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -36,7 +36,7 @@ export default async (

const { createCustomer: createCustomerGQL } = context.extendQuery(customQuery, {
createCustomer: {
query: createCustomer,
query: createCustomerQuery,
variables: { input: variables },
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/createCustomerAddress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/createEmptyCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FetchResult<CreateEmptyCartMutation>> =>
export const createEmptyCart = async (context: Context, customHeaders: CustomHeaders = {}): Promise<FetchResult<CreateEmptyCartMutation>> =>
context.client.mutate<CreateEmptyCartMutation>({
mutation: gql`
${createEmptyCart}
${createEmptyCartQuery}
`,
context: {
headers: getHeaders(context, customHeaders),
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/createProductReview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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";

/**
* Creates a new product review
*/
export default async (
export const createProductReview = async (
context: Context,
input: CreateProductReviewInput,
customHeaders: CustomHeaders = {}
Expand All @@ -34,7 +34,7 @@ export default async (

return context.client.mutate<CreateProductReviewMutation, { input: CreateProductReviewInput }>({
mutation: gql`
${createProductReview}
${createProductReviewQuery}
`,
variables: { input: variables },
context: {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/currency/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/customMutation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types";
import { Context } from "../../types/context";
import getHeaders from "../getHeaders";

export default async <MUTATION = any, MUTATION_VARIABLES = any>(
export const customMutation = async <MUTATION = any, MUTATION_VARIABLES = any>(
context: Context,
{
mutation,
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/api/customQuery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CustomHeaders } from "@vue-storefront/magento-types";
import { Context } from "../../types/context";
import getHeaders from "../getHeaders";

export default async <QUERY = any, QUERY_VARIABLES = any>(
export const customQuery = async <QUERY = any, QUERY_VARIABLES = any>(
context: Context,
{
query,
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/customer/index.ts
Original file line number Diff line number Diff line change
@@ -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<ApolloQueryResult<CustomerQuery>> => {
const { customer: customerGQL } = context.extendQuery(customQuery, {
customer: {
query: customer,
query: customerQuery,
},
});

Expand Down
Loading

0 comments on commit 0aa5752

Please sign in to comment.