@decocms/apps-wake 8.1.0-next.0 → 8.1.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/storefront.d.ts +14 -0
  6. package/dist/storefront.d.ts.map +1 -0
  7. package/dist/storefront.js +14 -0
  8. package/dist/storefront.js.map +1 -0
  9. package/dist/storefrontTypes.d.ts +7 -0
  10. package/dist/storefrontTypes.d.ts.map +1 -0
  11. package/dist/storefrontTypes.js +2 -0
  12. package/dist/storefrontTypes.js.map +1 -0
  13. package/dist/utils/client.d.ts +12 -0
  14. package/dist/utils/client.d.ts.map +1 -0
  15. package/dist/utils/client.js +2 -0
  16. package/dist/utils/client.js.map +1 -0
  17. package/dist/utils/gql.d.ts +16 -0
  18. package/dist/utils/gql.d.ts.map +1 -0
  19. package/dist/utils/gql.js +16 -0
  20. package/dist/utils/gql.js.map +1 -0
  21. package/dist/utils/graphql/queries.d.ts +117 -0
  22. package/dist/utils/graphql/queries.d.ts.map +1 -0
  23. package/dist/utils/graphql/queries.js +1323 -0
  24. package/dist/utils/graphql/queries.js.map +1 -0
  25. package/dist/utils/graphql/storefront.graphql.gen.d.ts +10344 -0
  26. package/dist/utils/graphql/storefront.graphql.gen.d.ts.map +1 -0
  27. package/dist/utils/graphql/storefront.graphql.gen.js +9 -0
  28. package/dist/utils/graphql/storefront.graphql.gen.js.map +1 -0
  29. package/dist/utils/graphqlOperationName.d.ts +36 -0
  30. package/dist/utils/graphqlOperationName.d.ts.map +1 -0
  31. package/dist/utils/graphqlOperationName.js +59 -0
  32. package/dist/utils/graphqlOperationName.js.map +1 -0
  33. package/dist/wakeClient.d.ts +54 -0
  34. package/dist/wakeClient.d.ts.map +1 -0
  35. package/dist/wakeClient.js +85 -0
  36. package/dist/wakeClient.js.map +1 -0
  37. package/package.json +26 -37
  38. package/src/index.ts +3 -63
  39. package/src/storefront.ts +1 -1
  40. package/src/storefrontTypes.ts +1 -1
  41. package/src/utils/gql.ts +1 -2
  42. package/src/utils/graphql/queries.ts +1 -1
  43. package/src/wakeClient.ts +3 -3
  44. package/src/__tests__/wakeClient.test.ts +0 -136
  45. package/src/actions/cart/addCoupon.ts +0 -43
  46. package/src/actions/cart/addItem.ts +0 -10
  47. package/src/actions/cart/addItems.ts +0 -50
  48. package/src/actions/cart/addKit.ts +0 -53
  49. package/src/actions/cart/partnerAssociate.ts +0 -48
  50. package/src/actions/cart/partnerDisassociate.ts +0 -43
  51. package/src/actions/cart/removeCoupon.ts +0 -39
  52. package/src/actions/cart/removeKit.ts +0 -56
  53. package/src/actions/cart/updateItemQuantity.ts +0 -69
  54. package/src/actions/newsletter/register.ts +0 -32
  55. package/src/actions/notifyme.ts +0 -28
  56. package/src/actions/review/create.ts +0 -30
  57. package/src/actions/shippingSimulation.ts +0 -60
  58. package/src/actions/submmitForm.ts +0 -25
  59. package/src/actions/wishlist/addProduct.ts +0 -43
  60. package/src/actions/wishlist/removeProduct.ts +0 -45
  61. package/src/client.ts +0 -123
  62. package/src/commerceLoaders.ts +0 -137
  63. package/src/handlers/sitemap.ts +0 -61
  64. package/src/loaders/cart.ts +0 -46
  65. package/src/loaders/partners.ts +0 -58
  66. package/src/loaders/productDetailsPage.ts +0 -174
  67. package/src/loaders/productList.ts +0 -262
  68. package/src/loaders/productListingPage.ts +0 -333
  69. package/src/loaders/proxy.ts +0 -79
  70. package/src/loaders/recommendations.ts +0 -84
  71. package/src/loaders/shop.ts +0 -37
  72. package/src/loaders/suggestion.ts +0 -67
  73. package/src/loaders/user.ts +0 -48
  74. package/src/loaders/wishlist.ts +0 -40
  75. package/src/manifest.gen.ts +0 -69
  76. package/src/mod.ts +0 -88
  77. package/src/registry.ts +0 -9
  78. package/src/utils/authError.ts +0 -107
  79. package/src/utils/authenticate.ts +0 -42
  80. package/src/utils/capitalize.ts +0 -9
  81. package/src/utils/cart.ts +0 -33
  82. package/src/utils/cookies.ts +0 -82
  83. package/src/utils/getVariations.ts +0 -47
  84. package/src/utils/graphql.ts +0 -72
  85. package/src/utils/httpError.ts +0 -15
  86. package/src/utils/instrumentedFetch.ts +0 -46
  87. package/src/utils/operationRouter.ts +0 -51
  88. package/src/utils/parseHeaders.ts +0 -19
  89. package/src/utils/partner.ts +0 -34
  90. package/src/utils/requestCtx.ts +0 -41
  91. package/src/utils/transform.ts +0 -460
  92. package/src/utils/types.ts +0 -6
  93. package/src/utils/user.ts +0 -9
  94. package/tsconfig.json +0 -7
@@ -1,43 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { AddCoupon } from "../../utils/graphql/queries";
4
- import type {
5
- AddCouponMutation,
6
- CheckoutFragment,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import {
10
- currentRequestHeaders,
11
- currentResponseHeaders,
12
- forwardedHeaders,
13
- } from "../../utils/requestCtx";
14
-
15
- export interface Props {
16
- coupon: string;
17
- }
18
-
19
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
20
- const storefront = getWakeClient();
21
- const cartId = getCartCookie(currentRequestHeaders());
22
- const headers = forwardedHeaders();
23
-
24
- if (!cartId) {
25
- throw new HttpError(400, "Missing cart cookie");
26
- }
27
-
28
- const data = await storefront.query<AddCouponMutation>(
29
- AddCoupon,
30
- { checkoutId: cartId, ...props },
31
- headers,
32
- );
33
-
34
- const checkoutId = data.checkout?.checkoutId;
35
-
36
- if (checkoutId && cartId !== checkoutId) {
37
- setCartCookie(currentResponseHeaders(), checkoutId);
38
- }
39
-
40
- return data.checkout ?? {};
41
- };
42
-
43
- export default action;
@@ -1,10 +0,0 @@
1
- import type { CheckoutFragment } from "../../utils/graphql/storefront.graphql.gen";
2
- import addItems, { type CartItem as Props } from "./addItems";
3
-
4
- export type { CartItem as Props } from "./addItems";
5
-
6
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
7
- return await addItems({ products: [props] });
8
- };
9
-
10
- export default action;
@@ -1,50 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { AddItemToCart } from "../../utils/graphql/queries";
4
- import type {
5
- AddItemToCartMutation,
6
- CheckoutFragment,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import {
10
- currentRequestHeaders,
11
- currentResponseHeaders,
12
- forwardedHeaders,
13
- } from "../../utils/requestCtx";
14
-
15
- export interface CartItem {
16
- productVariantId: number;
17
- quantity: number;
18
- customization?: { customizationId: number; value: string }[];
19
- subscription?: { subscriptionGroupId: number; recurringTypeId: number };
20
- }
21
-
22
- export interface Props {
23
- products: CartItem[];
24
- }
25
-
26
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
27
- const storefront = getWakeClient();
28
- const cartId = getCartCookie(currentRequestHeaders());
29
- const headers = forwardedHeaders();
30
-
31
- if (!cartId) {
32
- throw new HttpError(400, "Missing cart cookie");
33
- }
34
-
35
- const data = await storefront.query<AddItemToCartMutation>(
36
- AddItemToCart,
37
- { input: { id: cartId, products: props.products } },
38
- headers,
39
- );
40
-
41
- const checkoutId = data.checkout?.checkoutId;
42
-
43
- if (checkoutId && cartId !== checkoutId) {
44
- setCartCookie(currentResponseHeaders(), checkoutId);
45
- }
46
-
47
- return data.checkout ?? {};
48
- };
49
-
50
- export default action;
@@ -1,53 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { AddKit } from "../../utils/graphql/queries";
4
- import type { AddKitMutation, CheckoutFragment } from "../../utils/graphql/storefront.graphql.gen";
5
- import { HttpError } from "../../utils/httpError";
6
- import {
7
- currentRequestHeaders,
8
- currentResponseHeaders,
9
- forwardedHeaders,
10
- } from "../../utils/requestCtx";
11
-
12
- export interface KitItemVariant {
13
- productVariantId: number;
14
- quantity: number;
15
- }
16
-
17
- export interface KitItem {
18
- productId: number;
19
- variants: KitItemVariant[];
20
- }
21
-
22
- export interface Props {
23
- products: KitItem[];
24
- quantity: number;
25
- kitId: number;
26
- }
27
-
28
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
29
- const storefront = getWakeClient();
30
- const cartId = getCartCookie(currentRequestHeaders());
31
- const headers = forwardedHeaders();
32
- const { quantity, kitId, products } = props;
33
-
34
- if (!cartId) {
35
- throw new HttpError(400, "Missing cart cookie");
36
- }
37
-
38
- const data = await storefront.query<AddKitMutation>(
39
- AddKit,
40
- { input: { id: cartId, quantity, kitId, products } },
41
- headers,
42
- );
43
-
44
- const checkoutId = data.checkout?.checkoutId;
45
-
46
- if (checkoutId && cartId !== checkoutId) {
47
- setCartCookie(currentResponseHeaders(), checkoutId);
48
- }
49
-
50
- return data.checkout ?? {};
51
- };
52
-
53
- export default action;
@@ -1,48 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { CheckoutPartnerAssociate } from "../../utils/graphql/queries";
4
- import type {
5
- CheckoutFragment,
6
- CheckoutPartnerAssociateMutation,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import { setPartnerCookie } from "../../utils/partner";
10
- import {
11
- currentRequestHeaders,
12
- currentResponseHeaders,
13
- forwardedHeaders,
14
- } from "../../utils/requestCtx";
15
-
16
- export interface Props {
17
- partnerAccessToken: string;
18
- }
19
-
20
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
21
- const storefront = getWakeClient();
22
- const cartId = getCartCookie(currentRequestHeaders());
23
- const headers = forwardedHeaders();
24
- const { partnerAccessToken } = props;
25
-
26
- if (!cartId) {
27
- throw new HttpError(400, "Missing cart cookie");
28
- }
29
-
30
- const data = await storefront.query<CheckoutPartnerAssociateMutation>(
31
- CheckoutPartnerAssociate,
32
- { checkoutId: cartId, partnerAccessToken },
33
- headers,
34
- );
35
-
36
- const checkoutId = data.checkout?.checkoutId;
37
- const responseHeaders = currentResponseHeaders();
38
-
39
- if (checkoutId && cartId !== checkoutId) {
40
- setCartCookie(responseHeaders, checkoutId);
41
- }
42
-
43
- setPartnerCookie(responseHeaders, partnerAccessToken);
44
-
45
- return data.checkout ?? {};
46
- };
47
-
48
- export default action;
@@ -1,43 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { CheckoutPartnerDisassociate } from "../../utils/graphql/queries";
4
- import type {
5
- CheckoutFragment,
6
- CheckoutPartnerDisassociateMutation,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import { deletePartnerCookie } from "../../utils/partner";
10
- import {
11
- currentRequestHeaders,
12
- currentResponseHeaders,
13
- forwardedHeaders,
14
- } from "../../utils/requestCtx";
15
-
16
- const action = async (): Promise<Partial<CheckoutFragment>> => {
17
- const storefront = getWakeClient();
18
- const cartId = getCartCookie(currentRequestHeaders());
19
- const headers = forwardedHeaders();
20
-
21
- if (!cartId) {
22
- throw new HttpError(400, "Missing cart cookie");
23
- }
24
-
25
- const data = await storefront.query<CheckoutPartnerDisassociateMutation>(
26
- CheckoutPartnerDisassociate,
27
- { checkoutId: cartId },
28
- headers,
29
- );
30
-
31
- const checkoutId = data.checkout?.checkoutId;
32
- const responseHeaders = currentResponseHeaders();
33
-
34
- if (checkoutId && cartId !== checkoutId) {
35
- setCartCookie(responseHeaders, checkoutId);
36
- }
37
-
38
- deletePartnerCookie(responseHeaders);
39
-
40
- return data.checkout ?? {};
41
- };
42
-
43
- export default action;
@@ -1,39 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { RemoveCoupon } from "../../utils/graphql/queries";
4
- import type {
5
- CheckoutFragment,
6
- RemoveCouponMutation,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import {
10
- currentRequestHeaders,
11
- currentResponseHeaders,
12
- forwardedHeaders,
13
- } from "../../utils/requestCtx";
14
-
15
- const action = async (): Promise<Partial<CheckoutFragment>> => {
16
- const storefront = getWakeClient();
17
- const cartId = getCartCookie(currentRequestHeaders());
18
- const headers = forwardedHeaders();
19
-
20
- if (!cartId) {
21
- throw new HttpError(400, "Missing cart cookie");
22
- }
23
-
24
- const data = await storefront.query<RemoveCouponMutation>(
25
- RemoveCoupon,
26
- { checkoutId: cartId },
27
- headers,
28
- );
29
-
30
- const checkoutId = data.checkout?.checkoutId;
31
-
32
- if (checkoutId && cartId !== checkoutId) {
33
- setCartCookie(currentResponseHeaders(), checkoutId);
34
- }
35
-
36
- return data.checkout ?? {};
37
- };
38
-
39
- export default action;
@@ -1,56 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { getCartCookie, setCartCookie } from "../../utils/cart";
3
- import { RemoveKit } from "../../utils/graphql/queries";
4
- import type {
5
- CheckoutFragment,
6
- RemoveKitMutation,
7
- } from "../../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../../utils/httpError";
9
- import {
10
- currentRequestHeaders,
11
- currentResponseHeaders,
12
- forwardedHeaders,
13
- } from "../../utils/requestCtx";
14
-
15
- export interface KitItemVariant {
16
- productVariantId: number;
17
- quantity: number;
18
- }
19
-
20
- export interface KitItem {
21
- productId: number;
22
- variants: KitItemVariant[];
23
- }
24
-
25
- export interface Props {
26
- products: KitItem[];
27
- quantity: number;
28
- kitId: number;
29
- }
30
-
31
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
32
- const storefront = getWakeClient();
33
- const cartId = getCartCookie(currentRequestHeaders());
34
- const headers = forwardedHeaders();
35
- const { quantity, kitId, products } = props;
36
-
37
- if (!cartId) {
38
- throw new HttpError(400, "Missing cart cookie");
39
- }
40
-
41
- const data = await storefront.query<RemoveKitMutation>(
42
- RemoveKit,
43
- { input: { id: cartId, quantity, kitId, products } },
44
- headers,
45
- );
46
-
47
- const checkoutId = data.checkout?.checkoutId;
48
-
49
- if (checkoutId && cartId !== checkoutId) {
50
- setCartCookie(currentResponseHeaders(), checkoutId);
51
- }
52
-
53
- return data.checkout ?? {};
54
- };
55
-
56
- export default action;
@@ -1,69 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import cartLoader from "../../loaders/cart";
3
- import { getCartCookie, setCartCookie } from "../../utils/cart";
4
- import { RemoveItemFromCart } from "../../utils/graphql/queries";
5
- import type {
6
- CheckoutFragment,
7
- RemoveItemFromCartMutation,
8
- } from "../../utils/graphql/storefront.graphql.gen";
9
- import { HttpError } from "../../utils/httpError";
10
- import {
11
- currentRequestHeaders,
12
- currentResponseHeaders,
13
- forwardedHeaders,
14
- } from "../../utils/requestCtx";
15
- import addItem from "./addItem";
16
-
17
- export interface Props {
18
- productVariantId: number;
19
- quantity: number;
20
- customization?: { customizationId: number; value: string }[];
21
- subscription?: { subscriptionGroupId: number; recurringTypeId: number };
22
- }
23
-
24
- const removeFromCart = (props: Props, cartId: string, headers: Record<string, string>) =>
25
- getWakeClient().query<RemoveItemFromCartMutation>(
26
- RemoveItemFromCart,
27
- { input: { id: cartId, products: [props] } },
28
- headers,
29
- );
30
-
31
- const action = async (props: Props): Promise<Partial<CheckoutFragment>> => {
32
- const cartId = getCartCookie(currentRequestHeaders());
33
- const headers = forwardedHeaders();
34
-
35
- if (!cartId) {
36
- throw new HttpError(400, "Missing cart cookie");
37
- }
38
-
39
- /*
40
- * get cart
41
- * find the current product on cart
42
- * the current amount
43
- * calculate the difference between the current item amount and requested new amount
44
- */
45
-
46
- const cart = await cartLoader();
47
- const item = cart.products?.find((item) => item?.productVariantId === props.productVariantId);
48
- const quantityItem = item?.quantity ?? 0;
49
- const quantity = props.quantity - quantityItem;
50
-
51
- let checkout: Partial<CheckoutFragment> | undefined;
52
-
53
- if (props.quantity > 0 && quantity > 0) {
54
- checkout = await addItem({ ...props, quantity });
55
- } else {
56
- const data = await removeFromCart({ ...props, quantity: -quantity }, cartId, headers);
57
- checkout = data.checkout ?? undefined;
58
- }
59
-
60
- const checkoutId = checkout?.checkoutId;
61
-
62
- if (checkoutId && cartId !== checkoutId) {
63
- setCartCookie(currentResponseHeaders(), checkoutId);
64
- }
65
-
66
- return checkout ?? {};
67
- };
68
-
69
- export default action;
@@ -1,32 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { CreateNewsletterRegister } from "../../utils/graphql/queries";
3
- import type {
4
- CreateNewsletterRegisterMutation,
5
- NewsletterNode,
6
- } from "../../utils/graphql/storefront.graphql.gen";
7
- import { HttpError } from "../../utils/httpError";
8
- import { forwardedHeaders } from "../../utils/requestCtx";
9
-
10
- export interface Props {
11
- email: string;
12
- name: string;
13
- }
14
-
15
- const action = async (props: Props): Promise<NewsletterNode> => {
16
- const storefront = getWakeClient();
17
- const headers = forwardedHeaders();
18
-
19
- const data = await storefront.query<CreateNewsletterRegisterMutation>(
20
- CreateNewsletterRegister,
21
- { input: { ...props } },
22
- headers,
23
- );
24
-
25
- if (!data.createNewsletterRegister) {
26
- throw new HttpError(400, "Error on Register");
27
- }
28
-
29
- return data.createNewsletterRegister;
30
- };
31
-
32
- export default action;
@@ -1,28 +0,0 @@
1
- import { getWakeClient } from "../client";
2
- import { ProductRestockAlert } from "../utils/graphql/queries";
3
- import type {
4
- ProductRestockAlertMutation,
5
- RestockAlertNode,
6
- } from "../utils/graphql/storefront.graphql.gen";
7
- import { forwardedHeaders } from "../utils/requestCtx";
8
-
9
- export interface Props {
10
- email: string;
11
- name: string;
12
- productVariantId: number;
13
- }
14
-
15
- const action = async (props: Props): Promise<RestockAlertNode | null> => {
16
- const storefront = getWakeClient();
17
- const headers = forwardedHeaders();
18
-
19
- const data = await storefront.query<ProductRestockAlertMutation>(
20
- ProductRestockAlert,
21
- { input: props },
22
- headers,
23
- );
24
-
25
- return data.productRestockAlert ?? null;
26
- };
27
-
28
- export default action;
@@ -1,30 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import { CreateProductReview } from "../../utils/graphql/queries";
3
- import type {
4
- CreateProductReviewMutation,
5
- Review,
6
- } from "../../utils/graphql/storefront.graphql.gen";
7
- import { forwardedHeaders } from "../../utils/requestCtx";
8
-
9
- export interface Props {
10
- email: string;
11
- name: string;
12
- productVariantId: number;
13
- rating: number;
14
- review: string;
15
- }
16
-
17
- const action = async (props: Props): Promise<Review | null> => {
18
- const storefront = getWakeClient();
19
- const headers = forwardedHeaders();
20
-
21
- const data = await storefront.query<CreateProductReviewMutation>(
22
- CreateProductReview,
23
- props as unknown as Record<string, unknown>,
24
- headers,
25
- );
26
-
27
- return data.createProductReview ?? null;
28
- };
29
-
30
- export default action;
@@ -1,60 +0,0 @@
1
- import { getWakeClient } from "../client";
2
- import { getCartCookie } from "../utils/cart";
3
- import { ShippingQuotes } from "../utils/graphql/queries";
4
- import type {
5
- ShippingQuotesQuery,
6
- ShippingQuotesQueryVariables,
7
- } from "../utils/graphql/storefront.graphql.gen";
8
- import { HttpError } from "../utils/httpError";
9
- import { currentRequestHeaders, forwardedHeaders } from "../utils/requestCtx";
10
-
11
- export interface Props {
12
- cep?: string;
13
- simulateCartItems?: boolean;
14
- productVariantId?: number;
15
- quantity?: number;
16
- useSelectedAddress?: boolean;
17
- }
18
-
19
- const buildSimulationParams = (props: Props, checkoutId?: string): ShippingQuotesQueryVariables => {
20
- const { cep, simulateCartItems, productVariantId, quantity, useSelectedAddress } = props;
21
-
22
- const defaultQueryParams = {
23
- cep,
24
- useSelectedAddress,
25
- };
26
-
27
- if (simulateCartItems) {
28
- if (!checkoutId) throw new HttpError(400, "Missing cart cookie");
29
-
30
- return {
31
- ...defaultQueryParams,
32
- checkoutId,
33
- };
34
- }
35
-
36
- return {
37
- ...defaultQueryParams,
38
- productVariantId,
39
- quantity,
40
- };
41
- };
42
-
43
- const action = async (props: Props): Promise<ShippingQuotesQuery["shippingQuotes"]> => {
44
- const storefront = getWakeClient();
45
- const headers = forwardedHeaders();
46
-
47
- const cartId = getCartCookie(currentRequestHeaders());
48
-
49
- const simulationParams = buildSimulationParams(props, cartId);
50
-
51
- const data = await storefront.query<ShippingQuotesQuery>(
52
- ShippingQuotes,
53
- { ...simulationParams },
54
- headers,
55
- );
56
-
57
- return data.shippingQuotes ?? [];
58
- };
59
-
60
- export default action;
@@ -1,25 +0,0 @@
1
- import { getWakeClient } from "../client";
2
- import { SendGenericForm } from "../utils/graphql/queries";
3
- import type { SendGenericFormMutation } from "../utils/graphql/storefront.graphql.gen";
4
- import { forwardedHeaders } from "../utils/requestCtx";
5
-
6
- export interface Props {
7
- body: unknown;
8
- // file: Upload,
9
- recaptchaToken: string;
10
- }
11
-
12
- const action = async (props: Props): Promise<SendGenericFormMutation["sendGenericForm"]> => {
13
- const storefront = getWakeClient();
14
- const headers = forwardedHeaders();
15
-
16
- const data = await storefront.query<SendGenericFormMutation>(
17
- SendGenericForm,
18
- props as unknown as Record<string, unknown>,
19
- headers,
20
- );
21
-
22
- return data.sendGenericForm!;
23
- };
24
-
25
- export default action;
@@ -1,43 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import authenticate from "../../utils/authenticate";
3
- import { WishlistAddProduct } from "../../utils/graphql/queries";
4
- import type {
5
- ProductFragment,
6
- WishlistAddProductMutation,
7
- WishlistReducedProductFragment,
8
- } from "../../utils/graphql/storefront.graphql.gen";
9
- import { forwardedHeaders } from "../../utils/requestCtx";
10
-
11
- export interface Props {
12
- productId: number;
13
- }
14
-
15
- const action = async (props: Props): Promise<WishlistReducedProductFragment[] | null> => {
16
- const storefront = getWakeClient();
17
- const { productId } = props;
18
- const customerAccessToken = await authenticate();
19
- const headers = forwardedHeaders();
20
-
21
- if (!customerAccessToken) return [];
22
-
23
- const data = await storefront.query<WishlistAddProductMutation>(
24
- WishlistAddProduct,
25
- { customerAccessToken, productId },
26
- headers,
27
- );
28
-
29
- const products = data.wishlistAddProduct;
30
-
31
- if (!Array.isArray(products)) {
32
- return null;
33
- }
34
-
35
- return products
36
- .filter((node): node is ProductFragment => Boolean(node))
37
- .map(({ productId, productName }) => ({
38
- productId,
39
- productName,
40
- }));
41
- };
42
-
43
- export default action;
@@ -1,45 +0,0 @@
1
- import { getWakeClient } from "../../client";
2
- import authenticate from "../../utils/authenticate";
3
- import { WishlistRemoveProduct } from "../../utils/graphql/queries";
4
- import type {
5
- ProductFragment,
6
- WishlistReducedProductFragment,
7
- WishlistRemoveProductMutation,
8
- } from "../../utils/graphql/storefront.graphql.gen";
9
- import { forwardedHeaders } from "../../utils/requestCtx";
10
-
11
- export interface Props {
12
- productId: number;
13
- }
14
-
15
- const action = async (props: Props): Promise<WishlistReducedProductFragment[] | null> => {
16
- const storefront = getWakeClient();
17
- const { productId } = props;
18
-
19
- const headers = forwardedHeaders();
20
-
21
- const customerAccessToken = await authenticate();
22
-
23
- if (!customerAccessToken) return [];
24
-
25
- const data = await storefront.query<WishlistRemoveProductMutation>(
26
- WishlistRemoveProduct,
27
- { customerAccessToken, productId },
28
- headers,
29
- );
30
-
31
- const products = data.wishlistRemoveProduct;
32
-
33
- if (!Array.isArray(products)) {
34
- return null;
35
- }
36
-
37
- return products
38
- .filter((node): node is ProductFragment => Boolean(node))
39
- .map(({ productId, productName }) => ({
40
- productId,
41
- productName,
42
- }));
43
- };
44
-
45
- export default action;