@gfed-medusa/sf-lib-common 2.1.0 → 2.2.0

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 (55) hide show
  1. package/dist/components/breadcrumbs/index.d.ts +2 -2
  2. package/dist/components/cart-mismatch-banner/index.d.ts +2 -2
  3. package/dist/components/cart-mismatch-banner/index.d.ts.map +1 -1
  4. package/dist/components/cart-mismatch-banner/index.js +3 -1
  5. package/dist/components/cart-mismatch-banner/index.js.map +1 -1
  6. package/dist/components/delete-button/index.d.ts.map +1 -1
  7. package/dist/components/delete-button/index.js +3 -1
  8. package/dist/components/delete-button/index.js.map +1 -1
  9. package/dist/components/error-message/index.d.ts +2 -2
  10. package/dist/components/error-message/index.d.ts.map +1 -1
  11. package/dist/components/free-shipping-price-nudge/index.d.ts +2 -2
  12. package/dist/components/interactive-link/index.d.ts +2 -2
  13. package/dist/components/interactive-link/index.d.ts.map +1 -1
  14. package/dist/components/line-item-options/index.d.ts +2 -2
  15. package/dist/components/line-item-price/index.d.ts +2 -2
  16. package/dist/components/localized-client-link/index.d.ts +2 -2
  17. package/dist/components/modal/index.d.ts +2 -2
  18. package/dist/components/preview-price/index.d.ts +2 -2
  19. package/dist/components/preview-price/index.d.ts.map +1 -1
  20. package/dist/components/product-card/index.d.ts +2 -2
  21. package/dist/components/product-preview/index.d.ts +2 -2
  22. package/dist/components/submit-button/index.d.ts +2 -2
  23. package/dist/lib/context/apollo-context.d.ts +2 -2
  24. package/dist/lib/context/modal-context.d.ts +2 -2
  25. package/dist/lib/data/context.d.ts +12 -12
  26. package/dist/lib/data/context.d.ts.map +1 -1
  27. package/dist/lib/data/context.js.map +1 -1
  28. package/dist/lib/data/cookies.d.ts +6 -2
  29. package/dist/lib/data/cookies.d.ts.map +1 -1
  30. package/dist/lib/data/cookies.js +27 -1
  31. package/dist/lib/data/cookies.js.map +1 -1
  32. package/dist/lib/data/customer.d.ts +2 -2
  33. package/dist/lib/data/customer.d.ts.map +1 -1
  34. package/dist/lib/data/customer.js +2 -2
  35. package/dist/lib/data/customer.js.map +1 -1
  36. package/dist/lib/data/next-context.d.ts.map +1 -1
  37. package/dist/lib/data/next-context.js +11 -34
  38. package/dist/lib/data/next-context.js.map +1 -1
  39. package/dist/lib/data/orders.d.ts +2 -1
  40. package/dist/lib/data/orders.d.ts.map +1 -1
  41. package/dist/lib/data/orders.js +3 -3
  42. package/dist/lib/data/orders.js.map +1 -1
  43. package/dist/lib/gql/fragments/cart.d.ts +9 -9
  44. package/dist/lib/gql/fragments/customer.d.ts +3 -3
  45. package/dist/lib/gql/fragments/customer.d.ts.map +1 -1
  46. package/dist/lib/gql/fragments/product.d.ts +8 -8
  47. package/dist/lib/gql/mutations/cart.d.ts +4 -4
  48. package/dist/lib/gql/queries/cart.d.ts +2 -2
  49. package/dist/lib/gql/queries/collections.d.ts +2 -2
  50. package/dist/lib/gql/queries/customer.d.ts +2 -2
  51. package/dist/lib/gql/queries/footer.d.ts +2 -2
  52. package/dist/lib/gql/queries/product.d.ts +3 -3
  53. package/dist/lib/gql/queries/product.d.ts.map +1 -1
  54. package/dist/lib/hooks/use-apollo.d.ts +2 -2
  55. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/components/breadcrumbs/index.d.ts
4
4
  declare const SEPARATOR_ICONS: Record<string, React.ComponentType<{
@@ -14,7 +14,7 @@ declare function Breadcrumbs({
14
14
  iconClassName,
15
15
  iconSize,
16
16
  separatorIcon
17
- }: BreadcrumbsProps): react_jsx_runtime0.JSX.Element;
17
+ }: BreadcrumbsProps): react_jsx_runtime8.JSX.Element;
18
18
  //#endregion
19
19
  export { Breadcrumbs };
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,11 @@
1
1
  import { Cart, Customer } from "../../types/graphql.js";
2
- import * as react_jsx_runtime5 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/cart-mismatch-banner/index.d.ts
5
5
  declare function CartMismatchBanner(props: {
6
6
  customer: Customer;
7
7
  cart: Cart;
8
- }): react_jsx_runtime5.JSX.Element | undefined;
8
+ }): react_jsx_runtime7.JSX.Element | undefined;
9
9
  //#endregion
10
10
  export { CartMismatchBanner };
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAWS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAtB,SAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAYS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAtB,SAAA"}
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { useStorefrontContext } from "../../lib/data/context.js";
3
4
  import { transferCart } from "../../lib/data/customer.js";
4
5
  import { useState } from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -11,12 +12,13 @@ function CartMismatchBanner(props) {
11
12
  const { customer, cart } = props;
12
13
  const [isPending, setIsPending] = useState(false);
13
14
  const [actionText, setActionText] = useState("Run transfer again");
15
+ const ctx = useStorefrontContext();
14
16
  if (!customer || !!cart.customerId) return;
15
17
  const handleSubmit = async () => {
16
18
  try {
17
19
  setIsPending(true);
18
20
  setActionText("Transferring..");
19
- await transferCart();
21
+ await transferCart(ctx);
20
22
  } catch {
21
23
  setActionText("Run transfer again");
22
24
  setIsPending(false);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { ExclamationCircleSolid } from '@medusajs/icons';\nimport { Button } from '@medusajs/ui';\n\nimport { transferCart } from '@/lib/data/customer';\nimport { Customer } from '@/types/graphql';\nimport { Cart } from '@/types/graphql';\n\nfunction CartMismatchBanner(props: { customer: Customer; cart: Cart }) {\n const { customer, cart } = props;\n const [isPending, setIsPending] = useState(false);\n const [actionText, setActionText] = useState('Run transfer again');\n\n if (!customer || !!cart.customerId) {\n return;\n }\n\n const handleSubmit = async () => {\n try {\n setIsPending(true);\n setActionText('Transferring..');\n\n await transferCart();\n } catch {\n setActionText('Run transfer again');\n setIsPending(false);\n }\n };\n\n return (\n <div className=\"small:gap-2 small:p-4 mt-2 flex items-center justify-center gap-1 bg-orange-300 p-2 text-center text-sm text-orange-800\">\n <div className=\"small:flex-row small:gap-2 flex flex-col items-center gap-1\">\n <span className=\"flex items-center gap-1\">\n <ExclamationCircleSolid className=\"inline\" />\n Something went wrong when we tried to transfer your cart\n </span>\n\n <span>·</span>\n\n <Button\n variant=\"transparent\"\n className=\"bg-transparent p-0 text-orange-950 hover:bg-transparent focus:bg-transparent active:bg-transparent disabled:text-orange-500\"\n size=\"base\"\n disabled={isPending}\n onClick={handleSubmit}\n >\n {actionText}\n </Button>\n </div>\n </div>\n );\n}\n\nexport { CartMismatchBanner };\n"],"mappings":";;;;;;;;;AAWA,SAAS,mBAAmB,OAA2C;CACrE,MAAM,EAAE,UAAU,SAAS;CAC3B,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,YAAY,iBAAiB,SAAS,qBAAqB;AAElE,KAAI,CAAC,YAAY,CAAC,CAAC,KAAK,WACtB;CAGF,MAAM,eAAe,YAAY;AAC/B,MAAI;AACF,gBAAa,KAAK;AAClB,iBAAc,iBAAiB;AAE/B,SAAM,cAAc;UACd;AACN,iBAAc,qBAAqB;AACnC,gBAAa,MAAM;;;AAIvB,QACE,oBAAC;EAAI,WAAU;YACb,qBAAC;GAAI,WAAU;;IACb,qBAAC;KAAK,WAAU;gBACd,oBAAC,0BAAuB,WAAU,WAAW;MAExC;IAEP,oBAAC,oBAAK,MAAQ;IAEd,oBAAC;KACC,SAAQ;KACR,WAAU;KACV,MAAK;KACL,UAAU;KACV,SAAS;eAER;MACM;;IACL;GACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { ExclamationCircleSolid } from '@medusajs/icons';\nimport { Button } from '@medusajs/ui';\n\nimport { useStorefrontContext } from '@/lib/data/context';\nimport { transferCart } from '@/lib/data/customer';\nimport { Customer } from '@/types/graphql';\nimport { Cart } from '@/types/graphql';\n\nfunction CartMismatchBanner(props: { customer: Customer; cart: Cart }) {\n const { customer, cart } = props;\n const [isPending, setIsPending] = useState(false);\n const [actionText, setActionText] = useState('Run transfer again');\n const ctx = useStorefrontContext();\n\n if (!customer || !!cart.customerId) {\n return;\n }\n\n const handleSubmit = async () => {\n try {\n setIsPending(true);\n setActionText('Transferring..');\n\n await transferCart(ctx);\n } catch {\n setActionText('Run transfer again');\n setIsPending(false);\n }\n };\n\n return (\n <div className=\"small:gap-2 small:p-4 mt-2 flex items-center justify-center gap-1 bg-orange-300 p-2 text-center text-sm text-orange-800\">\n <div className=\"small:flex-row small:gap-2 flex flex-col items-center gap-1\">\n <span className=\"flex items-center gap-1\">\n <ExclamationCircleSolid className=\"inline\" />\n Something went wrong when we tried to transfer your cart\n </span>\n\n <span>·</span>\n\n <Button\n variant=\"transparent\"\n className=\"bg-transparent p-0 text-orange-950 hover:bg-transparent focus:bg-transparent active:bg-transparent disabled:text-orange-500\"\n size=\"base\"\n disabled={isPending}\n onClick={handleSubmit}\n >\n {actionText}\n </Button>\n </div>\n </div>\n );\n}\n\nexport { CartMismatchBanner };\n"],"mappings":";;;;;;;;;;AAYA,SAAS,mBAAmB,OAA2C;CACrE,MAAM,EAAE,UAAU,SAAS;CAC3B,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,YAAY,iBAAiB,SAAS,qBAAqB;CAClE,MAAM,MAAM,sBAAsB;AAElC,KAAI,CAAC,YAAY,CAAC,CAAC,KAAK,WACtB;CAGF,MAAM,eAAe,YAAY;AAC/B,MAAI;AACF,gBAAa,KAAK;AAClB,iBAAc,iBAAiB;AAE/B,SAAM,aAAa,IAAI;UACjB;AACN,iBAAc,qBAAqB;AACnC,gBAAa,MAAM;;;AAIvB,QACE,oBAAC;EAAI,WAAU;YACb,qBAAC;GAAI,WAAU;;IACb,qBAAC;KAAK,WAAU;gBACd,oBAAC,0BAAuB,WAAU,WAAW;MAExC;IAEP,oBAAC,oBAAK,MAAQ;IAEd,oBAAC;KACC,SAAQ;KACR,WAAU;KACV,MAAK;KACL,UAAU;KACV,SAAS;eAER;MACM;;IACL;GACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":[],"mappings":";;;cAOM;;;;;;aAMO,KAAA,CAAM;EANb,SAAA,CAAA,EAAA,MAkCL;CAlCqB,EAAA,GAQrB,kBAAA,CAAA,GAAA,CAAA,OARqB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":[],"mappings":";;;cAQM;;;;;;aAMO,KAAA,CAAM;EANb,SAAA,CAAA,EAAA,MAmCL;CAnCqB,EAAA,GAQrB,kBAAA,CAAA,GAAA,CAAA,OARqB"}
@@ -1,3 +1,4 @@
1
+ import { useStorefrontContext } from "../../lib/data/context.js";
1
2
  import { deleteLineItem } from "../../lib/data/cart.js";
2
3
  import { useState } from "react";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -6,10 +7,11 @@ import { clx } from "@medusajs/ui";
6
7
 
7
8
  //#region src/components/delete-button/index.tsx
8
9
  const DeleteButton = ({ id, children, className }) => {
10
+ const ctx = useStorefrontContext();
9
11
  const [isDeleting, setIsDeleting] = useState(false);
10
12
  const handleDelete = async (id$1) => {
11
13
  setIsDeleting(true);
12
- await deleteLineItem(id$1).catch((err) => {
14
+ await deleteLineItem(id$1, ctx).catch((err) => {
13
15
  setIsDeleting(false);
14
16
  });
15
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["id"],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Spinner, Trash } from '@medusajs/icons';\nimport { clx } from '@medusajs/ui';\n\nimport { deleteLineItem } from '@/lib/data/cart';\n\nconst DeleteButton = ({\n id,\n children,\n className,\n}: {\n id: string;\n children?: React.ReactNode;\n className?: string;\n}) => {\n const [isDeleting, setIsDeleting] = useState(false);\n\n const handleDelete = async (id: string) => {\n setIsDeleting(true);\n await deleteLineItem(id).catch((err) => {\n setIsDeleting(false);\n });\n };\n\n return (\n <div\n className={clx(\n 'text-small-regular flex items-center justify-between',\n className\n )}\n >\n <button\n className=\"text-ui-fg-subtle hover:text-ui-fg-base flex cursor-pointer gap-x-1\"\n onClick={() => handleDelete(id)}\n >\n {isDeleting ? <Spinner className=\"animate-spin\" /> : <Trash />}\n <span>{children}</span>\n </button>\n </div>\n );\n};\n\nexport { DeleteButton };\n"],"mappings":";;;;;;;AAOA,MAAM,gBAAgB,EACpB,IACA,UACA,gBAKI;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CAEnD,MAAM,eAAe,OAAO,SAAe;AACzC,gBAAc,KAAK;AACnB,QAAM,eAAeA,KAAG,CAAC,OAAO,QAAQ;AACtC,iBAAc,MAAM;IACpB;;AAGJ,QACE,oBAAC;EACC,WAAW,IACT,wDACA,UACD;YAED,qBAAC;GACC,WAAU;GACV,eAAe,aAAa,GAAG;cAE9B,aAAa,oBAAC,WAAQ,WAAU,iBAAiB,GAAG,oBAAC,UAAQ,EAC9D,oBAAC,UAAM,WAAgB;IAChB;GACL"}
1
+ {"version":3,"file":"index.js","names":["id"],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Spinner, Trash } from '@medusajs/icons';\nimport { clx } from '@medusajs/ui';\n\nimport { deleteLineItem } from '@/lib/data/cart';\nimport { useStorefrontContext } from '@/lib/data/context';\n\nconst DeleteButton = ({\n id,\n children,\n className,\n}: {\n id: string;\n children?: React.ReactNode;\n className?: string;\n}) => {\n const ctx = useStorefrontContext();\n const [isDeleting, setIsDeleting] = useState(false);\n\n const handleDelete = async (id: string) => {\n setIsDeleting(true);\n await deleteLineItem(id, ctx).catch((err) => {\n setIsDeleting(false);\n });\n };\n\n return (\n <div\n className={clx(\n 'text-small-regular flex items-center justify-between',\n className\n )}\n >\n <button\n className=\"text-ui-fg-subtle hover:text-ui-fg-base flex cursor-pointer gap-x-1\"\n onClick={() => handleDelete(id)}\n >\n {isDeleting ? <Spinner className=\"animate-spin\" /> : <Trash />}\n <span>{children}</span>\n </button>\n </div>\n );\n};\n\nexport { DeleteButton };\n"],"mappings":";;;;;;;;AAQA,MAAM,gBAAgB,EACpB,IACA,UACA,gBAKI;CACJ,MAAM,MAAM,sBAAsB;CAClC,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CAEnD,MAAM,eAAe,OAAO,SAAe;AACzC,gBAAc,KAAK;AACnB,QAAM,eAAeA,MAAI,IAAI,CAAC,OAAO,QAAQ;AAC3C,iBAAc,MAAM;IACpB;;AAGJ,QACE,oBAAC;EACC,WAAW,IACT,wDACA,UACD;YAED,qBAAC;GACC,WAAU;GACV,eAAe,aAAa,GAAG;cAE9B,aAAa,oBAAC,WAAQ,WAAU,iBAAiB,GAAG,oBAAC,UAAQ,EAC9D,oBAAC,UAAM,WAAgB;IAChB;GACL"}
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime4 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime10 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/components/error-message/index.d.ts
4
4
  declare const ErrorMessage: ({
@@ -7,7 +7,7 @@ declare const ErrorMessage: ({
7
7
  }: {
8
8
  error?: string | null;
9
9
  "data-testid"?: string;
10
- }) => react_jsx_runtime4.JSX.Element | null;
10
+ }) => react_jsx_runtime10.JSX.Element | null;
11
11
  //#endregion
12
12
  export { ErrorMessage };
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,kBAAA,CAAA,GAAA,CAAA,OAAA,GAaA,IAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,mBAAA,CAAA,GAAA,CAAA,OAAA,GAaA,IAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Cart } from "../../types/graphql.js";
2
- import * as react_jsx_runtime7 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
3
  import { StoreCartShippingOption } from "@medusajs/types";
4
4
 
5
5
  //#region src/components/free-shipping-price-nudge/index.d.ts
@@ -11,7 +11,7 @@ declare function ShippingPriceNudge({
11
11
  variant?: 'popup' | 'inline';
12
12
  cart: Cart;
13
13
  shippingOptions: StoreCartShippingOption[];
14
- }): react_jsx_runtime7.JSX.Element | undefined;
14
+ }): react_jsx_runtime2.JSX.Element | undefined;
15
15
  //#endregion
16
16
  export { ShippingPriceNudge };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime11 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/components/interactive-link/index.d.ts
4
4
  type InteractiveLinkProps = {
@@ -11,7 +11,7 @@ declare const InteractiveLink: ({
11
11
  children,
12
12
  onClick,
13
13
  ...props
14
- }: InteractiveLinkProps) => react_jsx_runtime2.JSX.Element;
14
+ }: InteractiveLinkProps) => react_jsx_runtime11.JSX.Element;
15
15
  //#endregion
16
16
  export { InteractiveLink };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/interactive-link/index.tsx"],"sourcesContent":[],"mappings":";;;KAKK,oBAAA;;aAEQ,KAAA,CAAM;EAFd,OAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAEuB,CAAA;cAItB,eAAmB,EAAA,CAAA;EAAA,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAKtB,oBALsB,EAAA,GAKF,kBAAA,CAAA,GAAA,CAAA,OALE"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/interactive-link/index.tsx"],"sourcesContent":[],"mappings":";;;KAKK,oBAAA;;aAEQ,KAAA,CAAM;EAFd,OAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAEuB,CAAA;cAItB,eAAmB,EAAA,CAAA;EAAA,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAKtB,oBALsB,EAAA,GAKF,mBAAA,CAAA,GAAA,CAAA,OALE"}
@@ -1,5 +1,5 @@
1
1
  import { Maybe, ProductVariant } from "../../types/graphql.js";
2
- import * as react_jsx_runtime15 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime13 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/line-item-options/index.d.ts
5
5
  type LineItemOptionsProps = {
@@ -11,7 +11,7 @@ declare const LineItemOptions: ({
11
11
  variant,
12
12
  "data-testid": dataTestid,
13
13
  "data-value": dataValue
14
- }: LineItemOptionsProps) => react_jsx_runtime15.JSX.Element;
14
+ }: LineItemOptionsProps) => react_jsx_runtime13.JSX.Element;
15
15
  //#endregion
16
16
  export { LineItemOptions };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { LineItem } from "../../types/graphql.js";
2
- import * as react_jsx_runtime14 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime12 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/line-item-price/index.d.ts
5
5
  type LineItemPriceProps = {
@@ -11,7 +11,7 @@ declare const LineItemPrice: ({
11
11
  item,
12
12
  style,
13
13
  currencyCode
14
- }: LineItemPriceProps) => react_jsx_runtime14.JSX.Element;
14
+ }: LineItemPriceProps) => react_jsx_runtime12.JSX.Element;
15
15
  //#endregion
16
16
  export { LineItemPrice };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { AnchorHTMLAttributes, DetailedHTMLProps } from "react";
2
- import * as react_jsx_runtime10 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime15 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/localized-client-link/index.d.ts
5
5
  type LocalizedClientLinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
@@ -11,7 +11,7 @@ declare const LocalizedClientLink: ({
11
11
  children,
12
12
  href,
13
13
  ...props
14
- }: LocalizedClientLinkProps) => react_jsx_runtime10.JSX.Element;
14
+ }: LocalizedClientLinkProps) => react_jsx_runtime15.JSX.Element;
15
15
  //#endregion
16
16
  export { LocalizedClientLink };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime11 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime14 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/modal/index.d.ts
5
5
  type ModalProps = {
@@ -20,7 +20,7 @@ declare const Modal: {
20
20
  children,
21
21
  "data-testid": dataTestId,
22
22
  "aria-label": ariaLabel
23
- }: ModalProps): react_jsx_runtime11.JSX.Element;
23
+ }: ModalProps): react_jsx_runtime14.JSX.Element;
24
24
  Title: React.FC<{
25
25
  children: React.ReactNode;
26
26
  }>;
@@ -1,12 +1,12 @@
1
1
  import { VariantPrice } from "../../types/prices.js";
2
- import * as react_jsx_runtime12 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime9 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/preview-price/index.d.ts
5
5
  declare function PreviewPrice({
6
6
  price
7
7
  }: {
8
8
  price: VariantPrice;
9
- }): react_jsx_runtime12.JSX.Element | null;
9
+ }): react_jsx_runtime9.JSX.Element | null;
10
10
  //#endregion
11
11
  export { PreviewPrice };
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/preview-price/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAIS,YAAA;;;SAAiC;IAAc,mBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/preview-price/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAIS,YAAA;;;SAAiC;IAAc,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime8 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime4 from "react/jsx-runtime";
2
2
  import { VariantProps } from "class-variance-authority";
3
3
  import * as class_variance_authority_types0 from "class-variance-authority/types";
4
4
 
@@ -59,7 +59,7 @@ declare function ProductCard({
59
59
  variant,
60
60
  size,
61
61
  className
62
- }: ProductCardProps): react_jsx_runtime8.JSX.Element;
62
+ }: ProductCardProps): react_jsx_runtime4.JSX.Element;
63
63
  //#endregion
64
64
  export { ProductCard };
65
65
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Product } from "../../types/graphql.js";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/product-preview/index.d.ts
5
5
  type ProductPreviewProps = {
@@ -9,7 +9,7 @@ type ProductPreviewProps = {
9
9
  declare function ProductPreview({
10
10
  product,
11
11
  isFeatured
12
- }: ProductPreviewProps): react_jsx_runtime0.JSX.Element;
12
+ }: ProductPreviewProps): react_jsx_runtime5.JSX.Element;
13
13
  //#endregion
14
14
  export { ProductPreview, ProductPreviewProps };
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime1 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime6 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/submit-button/index.d.ts
5
5
  declare function SubmitButton({
@@ -14,7 +14,7 @@ declare function SubmitButton({
14
14
  className?: string;
15
15
  'data-testid'?: string;
16
16
  isLoading?: boolean;
17
- }): react_jsx_runtime1.JSX.Element;
17
+ }): react_jsx_runtime6.JSX.Element;
18
18
  //#endregion
19
19
  export { SubmitButton };
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import { PropsWithChildren } from "react";
2
- import * as react_jsx_runtime6 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/lib/context/apollo-context.d.ts
5
5
  declare function ApolloClientProvider({
6
6
  children
7
- }: PropsWithChildren): react_jsx_runtime6.JSX.Element;
7
+ }: PropsWithChildren): react_jsx_runtime0.JSX.Element;
8
8
  //#endregion
9
9
  export { ApolloClientProvider };
10
10
  //# sourceMappingURL=apollo-context.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime9 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/lib/context/modal-context.d.ts
5
5
  interface ModalContext {
@@ -13,7 +13,7 @@ interface ModalProviderProps {
13
13
  declare const ModalProvider: ({
14
14
  children,
15
15
  close
16
- }: ModalProviderProps) => react_jsx_runtime9.JSX.Element;
16
+ }: ModalProviderProps) => react_jsx_runtime0.JSX.Element;
17
17
  declare const useModal: () => ModalContext;
18
18
  //#endregion
19
19
  export { ModalProvider, useModal };
@@ -1,18 +1,18 @@
1
1
  import { ReactNode } from "react";
2
- import * as react_jsx_runtime13 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/lib/data/context.d.ts
5
5
  interface StorefrontContext {
6
- cartId?: string;
7
- customerToken?: string;
8
- cacheId?: string;
9
- cookieHeader?: string;
10
- revalidate?: (tag: string) => void;
11
- updateRegion?: (countryCode: string, currentPath: string) => Promise<void>;
12
- setCartId?: (id: string) => Promise<void>;
13
- removeCartId?: () => Promise<void>;
14
- setAuthToken?: (token: string) => Promise<void>;
15
- removeAuthToken?: () => Promise<void>;
6
+ cartId: string;
7
+ customerToken: string;
8
+ cacheId: string;
9
+ cookieHeader: string;
10
+ revalidate: (tag: string) => void;
11
+ updateRegion: (countryCode: string, currentPath: string) => Promise<void>;
12
+ setCartId: (id: string) => Promise<void>;
13
+ removeCartId: () => Promise<void>;
14
+ setAuthToken: (token: string) => Promise<void>;
15
+ removeAuthToken: () => Promise<void>;
16
16
  }
17
17
  declare const StorefrontProvider: ({
18
18
  children,
@@ -20,7 +20,7 @@ declare const StorefrontProvider: ({
20
20
  }: {
21
21
  children: ReactNode;
22
22
  value: StorefrontContext;
23
- }) => react_jsx_runtime13.JSX.Element;
23
+ }) => react_jsx_runtime1.JSX.Element;
24
24
  declare const useStorefrontContext: () => StorefrontContext;
25
25
  //#endregion
26
26
  export { StorefrontContext, StorefrontProvider, useStorefrontContext };
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;UAIiB,iBAAA;;;EAAA,OAAA,CAAA,EAAA,MAAA;EAM8C,YAAA,CAAA,EAAA,MAAA;EACjC,UAAA,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EACP,YAAA,CAAA,EAAA,CAAA,WAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA,EAAA,GAFwC,OAExC,CAAA,IAAA,CAAA;EACa,SAAA,CAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GAFN,OAEM,CAAA,IAAA,CAAA;EACV,YAAA,CAAA,EAAA,GAAA,GAFH,OAEG,CAAA,IAAA,CAAA;EAAO,YAAA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GADG,OACH,CAAA,IAAA,CAAA;EAKpB,eAAA,CAAA,EAAA,GAYZ,GAjByB,OAiBzB,CAAA,IAAA,CAAA;;AAZkC,cAAtB,kBAAsB,EAAA,CAAA;EAAA,QAAA;EAAA;CAAA,EAAA;EAIvB,QAAA,EAAA,SAAA;EACH,KAAA,EAAA,iBAAA;CACR,EAAA,GAAA,mBAAA,CAAA,GAAA,CAAA,OAAA;AAMA,cAEY,oBAFZ,EAAA,GAAA,GAEgC,iBAFhC"}
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;UAIiB,iBAAA;;;EAAA,OAAA,EAAA,MAAA;EAM6C,YAAA,EAAA,MAAA;EACjC,UAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EACP,YAAA,EAAA,CAAA,WAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA,EAAA,GAFwC,OAExC,CAAA,IAAA,CAAA;EACa,SAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GAFN,OAEM,CAAA,IAAA,CAAA;EACV,YAAA,EAAA,GAAA,GAFH,OAEG,CAAA,IAAA,CAAA;EAAO,YAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GADG,OACH,CAAA,IAAA,CAAA;EAOnB,eAAA,EAAA,GAAA,GAPY,OAmBxB,CAAA,IAAA,CAAA;;AAZkC,cAAtB,kBAAsB,EAAA,CAAA;EAAA,QAAA;EAAA;CAAA,EAAA;EAIvB,QAAA,EAAA,SAAA;EACH,KAAA,EAAA,iBAAA;CACR,EAAA,GAAA,kBAAA,CAAA,GAAA,CAAA,OAAA;AAMA,cAEY,oBAFZ,EAAA,GAAA,GAEgC,iBAFhC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, createContext, useContext } from 'react';\n\nexport interface StorefrontContext {\n cartId?: string;\n customerToken?: string;\n cacheId?: string;\n cookieHeader?: string;\n revalidate?: (tag: string) => void;\n updateRegion?: (countryCode: string, currentPath: string) => Promise<void>;\n setCartId?: (id: string) => Promise<void>;\n removeCartId?: () => Promise<void>;\n setAuthToken?: (token: string) => Promise<void>;\n removeAuthToken?: () => Promise<void>;\n}\n\nconst StorefrontReactContext = createContext<StorefrontContext>({});\n\nexport const StorefrontProvider = ({\n children,\n value,\n}: {\n children: ReactNode;\n value: StorefrontContext;\n}) => {\n return (\n <StorefrontReactContext.Provider value={value}>\n {children}\n </StorefrontReactContext.Provider>\n );\n};\n\nexport const useStorefrontContext = () => useContext(StorefrontReactContext);\n"],"mappings":";;;;;;AAiBA,MAAM,yBAAyB,cAAiC,EAAE,CAAC;AAEnE,MAAa,sBAAsB,EACjC,UACA,YAII;AACJ,QACE,oBAAC,uBAAuB;EAAgB;EACrC;GAC+B;;AAItC,MAAa,6BAA6B,WAAW,uBAAuB"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, createContext, useContext } from 'react';\n\nexport interface StorefrontContext {\n cartId: string;\n customerToken: string;\n cacheId: string;\n cookieHeader: string;\n revalidate: (tag: string) => void;\n updateRegion: (countryCode: string, currentPath: string) => Promise<void>;\n setCartId: (id: string) => Promise<void>;\n removeCartId: () => Promise<void>;\n setAuthToken: (token: string) => Promise<void>;\n removeAuthToken: () => Promise<void>;\n}\n\nconst StorefrontReactContext = createContext<StorefrontContext>(\n {} as StorefrontContext\n);\n\nexport const StorefrontProvider = ({\n children,\n value,\n}: {\n children: ReactNode;\n value: StorefrontContext;\n}) => {\n return (\n <StorefrontReactContext.Provider value={value}>\n {children}\n </StorefrontReactContext.Provider>\n );\n};\n\nexport const useStorefrontContext = () => useContext(StorefrontReactContext);\n"],"mappings":";;;;;;AAiBA,MAAM,yBAAyB,cAC7B,EAAE,CACH;AAED,MAAa,sBAAsB,EACjC,UACA,YAII;AACJ,QACE,oBAAC,uBAAuB;EAAgB;EACrC;GAC+B;;AAItC,MAAa,6BAA6B,WAAW,uBAAuB"}
@@ -8,11 +8,15 @@ declare const getCacheTag: (tag: string, ctx: StorefrontContext) => string;
8
8
  declare const getCacheOptions: (tag: string, ctx: StorefrontContext) => {
9
9
  tags: string[];
10
10
  } | {};
11
- declare const getCartId: (ctx: StorefrontContext) => string | undefined;
11
+ declare const getCartId: (ctx: StorefrontContext) => string;
12
+ declare function setCartIdAction(id: string): Promise<void>;
13
+ declare function removeCartIdAction(): Promise<void>;
14
+ declare function setAuthTokenAction(token: string): Promise<void>;
15
+ declare function removeAuthTokenAction(): Promise<void>;
12
16
  declare const setCartId: (id: string, ctx: StorefrontContext) => Promise<void>;
13
17
  declare const removeCartId: (ctx: StorefrontContext) => Promise<void>;
14
18
  declare const setAuthToken: (token: string, ctx: StorefrontContext) => Promise<void>;
15
19
  declare const removeAuthToken: (ctx: StorefrontContext) => Promise<void>;
16
20
  //#endregion
17
- export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId, removeAuthToken, removeCartId, setAuthToken, setCartId };
21
+ export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId, removeAuthToken, removeAuthTokenAction, removeCartId, removeCartIdAction, setAuthToken, setAuthTokenAction, setCartId, setCartIdAction };
18
22
  //# sourceMappingURL=cookies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.d.ts","names":[],"sources":["../../../src/lib/data/cookies.ts"],"sourcesContent":[],"mappings":";;;cAEa,sBACN;;AADP,CAAA,GAAa,CAAA,CAAA;AAYA,cAAA,WAAiC,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA,MAAA;AAUlD,cAAA,eAEN,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA;EAeX,IAAA,EAAA,MAEZ,EAAA;AAED,CAAA,GAAa,CAAA,CAAA;AAMA,cAVA,SAcZ,EAJuC,CAAA,GAAA,EAVT,iBAU0B,EAAA,GAAA,MAAA,GAAA,SAAA;AAM5C,cAZA,SAgBZ,EAJsD,CAAA,EAAA,EAAA,MAAA,EAAA,GAAA,EAZN,iBAYuB,EAAA,GAZN,OAYM,CAAA,IAAA,CAAA;AAM3D,cAZA,YAgBZ,EAJ0C,CAAA,GAAA,EAZH,iBAYoB,EAAA,GAZH,OAYG,CAAA,IAAA,CAAA;cAN/C,mCAA0C,sBAAiB;cAM3D,uBAA8B,sBAAiB"}
1
+ {"version":3,"file":"cookies.d.ts","names":[],"sources":["../../../src/lib/data/cookies.ts"],"sourcesContent":[],"mappings":";;;cAEa,sBACN;;AADP,CAAA,GAAa,CAAA,CAAA;AAYA,cAAA,WAAiC,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA,MAAA;AAUlD,cAAA,eAEN,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA;EAeX,IAAA,EAAA,MAEZ,EAAA;AAED,CAAA,GAAsB,CAAA,CAAA;AAWA,cAfT,SAe2B,EAAA,CAAA,GAAA,EAfT,iBAeS,EAAA,GAAA,MAAA;AAMlB,iBAjBA,eAAA,CAiBgC,EAAA,EAAA,MAAA,CAAA,EAjBN,OAiBM,CAAA,IAAA,CAAA;AAWhC,iBAjBA,kBAAA,CAAA,CAiBqB,EAjBH,OAiBG,CAAA,IAAA,CAAA;AAM9B,iBAjBS,kBAAA,CAiB2B,KAAiB,EAAA,MAAA,CAAA,EAjBZ,OAiBY,CAAA,IAAA,CAAA;AAMrD,iBAZS,qBAAA,CAAA,CAYkB,EAZG,OAYc,CAAA,IAAA,CAAA;AAM5C,cAZA,SAgBZ,EAJsD,CAAA,EAAA,EAAA,MAAA,EAAA,GAAA,EAZN,iBAYuB,EAAA,GAZN,OAYM,CAAA,IAAA,CAAA;AAM3D,cAZA,YAgBZ,EAJ0C,CAAA,GAAA,EAZH,iBAYoB,EAAA,GAZH,OAYG,CAAA,IAAA,CAAA;cAN/C,mCAA0C,sBAAiB;cAM3D,uBAA8B,sBAAiB"}
@@ -18,6 +18,32 @@ const getCacheOptions = (tag, ctx) => {
18
18
  const getCartId = (ctx) => {
19
19
  return ctx.cartId;
20
20
  };
21
+ async function setCartIdAction(id) {
22
+ const { cookies } = await import("next/headers");
23
+ (await cookies()).set("_medusa_cart_id", id, {
24
+ maxAge: 3600 * 24 * 7,
25
+ httpOnly: true,
26
+ sameSite: "strict",
27
+ secure: false
28
+ });
29
+ }
30
+ async function removeCartIdAction() {
31
+ const { cookies } = await import("next/headers");
32
+ (await cookies()).set("_medusa_cart_id", "", { maxAge: -1 });
33
+ }
34
+ async function setAuthTokenAction(token) {
35
+ const { cookies } = await import("next/headers");
36
+ (await cookies()).set("_medusa_jwt", token, {
37
+ maxAge: 3600 * 24 * 7,
38
+ httpOnly: true,
39
+ sameSite: "strict",
40
+ secure: false
41
+ });
42
+ }
43
+ async function removeAuthTokenAction() {
44
+ const { cookies } = await import("next/headers");
45
+ (await cookies()).set("_medusa_jwt", "", { maxAge: -1 });
46
+ }
21
47
  const setCartId = async (id, ctx) => {
22
48
  if (ctx.setCartId) await ctx.setCartId(id);
23
49
  };
@@ -32,5 +58,5 @@ const removeAuthToken = async (ctx) => {
32
58
  };
33
59
 
34
60
  //#endregion
35
- export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId, removeAuthToken, removeCartId, setAuthToken, setCartId };
61
+ export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId, removeAuthToken, removeAuthTokenAction, removeCartId, removeCartIdAction, setAuthToken, setAuthTokenAction, setCartId, setCartIdAction };
36
62
  //# sourceMappingURL=cookies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.js","names":[],"sources":["../../../src/lib/data/cookies.ts"],"sourcesContent":["import type { StorefrontContext } from './context';\n\nexport const getAuthHeaders = (\n ctx: StorefrontContext\n): { authorization: string } | {} => {\n const token = ctx.customerToken;\n\n if (!token) {\n return {};\n }\n\n return { authorization: `Bearer ${token}` };\n};\n\nexport const getCacheTag = (tag: string, ctx: StorefrontContext): string => {\n const cacheId = ctx.cacheId;\n\n if (!cacheId) {\n return '';\n }\n\n return `${tag}-${cacheId}`;\n};\n\nexport const getCacheOptions = (\n tag: string,\n ctx: StorefrontContext\n): { tags: string[] } | {} => {\n if (typeof window !== 'undefined') {\n return {};\n }\n\n const cacheTag = getCacheTag(tag, ctx);\n\n if (!cacheTag) {\n return {};\n }\n\n return { tags: [`${cacheTag}`] };\n};\n\nexport const getCartId = (ctx: StorefrontContext) => {\n return ctx.cartId;\n};\n\nexport const setCartId = async (id: string, ctx: StorefrontContext) => {\n if (ctx.setCartId) {\n await ctx.setCartId(id);\n }\n};\n\nexport const removeCartId = async (ctx: StorefrontContext) => {\n if (ctx.removeCartId) {\n await ctx.removeCartId();\n }\n};\n\nexport const setAuthToken = async (token: string, ctx: StorefrontContext) => {\n if (ctx.setAuthToken) {\n await ctx.setAuthToken(token);\n }\n};\n\nexport const removeAuthToken = async (ctx: StorefrontContext) => {\n if (ctx.removeAuthToken) {\n await ctx.removeAuthToken();\n }\n};\n"],"mappings":";AAEA,MAAa,kBACX,QACmC;CACnC,MAAM,QAAQ,IAAI;AAElB,KAAI,CAAC,MACH,QAAO,EAAE;AAGX,QAAO,EAAE,eAAe,UAAU,SAAS;;AAG7C,MAAa,eAAe,KAAa,QAAmC;CAC1E,MAAM,UAAU,IAAI;AAEpB,KAAI,CAAC,QACH,QAAO;AAGT,QAAO,GAAG,IAAI,GAAG;;AAGnB,MAAa,mBACX,KACA,QAC4B;AAC5B,KAAI,OAAO,WAAW,YACpB,QAAO,EAAE;CAGX,MAAM,WAAW,YAAY,KAAK,IAAI;AAEtC,KAAI,CAAC,SACH,QAAO,EAAE;AAGX,QAAO,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE;;AAGlC,MAAa,aAAa,QAA2B;AACnD,QAAO,IAAI;;AAGb,MAAa,YAAY,OAAO,IAAY,QAA2B;AACrE,KAAI,IAAI,UACN,OAAM,IAAI,UAAU,GAAG;;AAI3B,MAAa,eAAe,OAAO,QAA2B;AAC5D,KAAI,IAAI,aACN,OAAM,IAAI,cAAc;;AAI5B,MAAa,eAAe,OAAO,OAAe,QAA2B;AAC3E,KAAI,IAAI,aACN,OAAM,IAAI,aAAa,MAAM;;AAIjC,MAAa,kBAAkB,OAAO,QAA2B;AAC/D,KAAI,IAAI,gBACN,OAAM,IAAI,iBAAiB"}
1
+ {"version":3,"file":"cookies.js","names":[],"sources":["../../../src/lib/data/cookies.ts"],"sourcesContent":["import type { StorefrontContext } from './context';\n\nexport const getAuthHeaders = (\n ctx: StorefrontContext\n): { authorization: string } | {} => {\n const token = ctx.customerToken;\n\n if (!token) {\n return {};\n }\n\n return { authorization: `Bearer ${token}` };\n};\n\nexport const getCacheTag = (tag: string, ctx: StorefrontContext): string => {\n const cacheId = ctx.cacheId;\n\n if (!cacheId) {\n return '';\n }\n\n return `${tag}-${cacheId}`;\n};\n\nexport const getCacheOptions = (\n tag: string,\n ctx: StorefrontContext\n): { tags: string[] } | {} => {\n if (typeof window !== 'undefined') {\n return {};\n }\n\n const cacheTag = getCacheTag(tag, ctx);\n\n if (!cacheTag) {\n return {};\n }\n\n return { tags: [`${cacheTag}`] };\n};\n\nexport const getCartId = (ctx: StorefrontContext) => {\n return ctx.cartId;\n};\n\nexport async function setCartIdAction(id: string) {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_cart_id', id, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n}\n\nexport async function removeCartIdAction() {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_cart_id', '', { maxAge: -1 });\n}\n\nexport async function setAuthTokenAction(token: string) {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_jwt', token, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n}\n\nexport async function removeAuthTokenAction() {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_jwt', '', { maxAge: -1 });\n}\n\nexport const setCartId = async (id: string, ctx: StorefrontContext) => {\n if (ctx.setCartId) {\n await ctx.setCartId(id);\n }\n};\n\nexport const removeCartId = async (ctx: StorefrontContext) => {\n if (ctx.removeCartId) {\n await ctx.removeCartId();\n }\n};\n\nexport const setAuthToken = async (token: string, ctx: StorefrontContext) => {\n if (ctx.setAuthToken) {\n await ctx.setAuthToken(token);\n }\n};\n\nexport const removeAuthToken = async (ctx: StorefrontContext) => {\n if (ctx.removeAuthToken) {\n await ctx.removeAuthToken();\n }\n};\n"],"mappings":";AAEA,MAAa,kBACX,QACmC;CACnC,MAAM,QAAQ,IAAI;AAElB,KAAI,CAAC,MACH,QAAO,EAAE;AAGX,QAAO,EAAE,eAAe,UAAU,SAAS;;AAG7C,MAAa,eAAe,KAAa,QAAmC;CAC1E,MAAM,UAAU,IAAI;AAEpB,KAAI,CAAC,QACH,QAAO;AAGT,QAAO,GAAG,IAAI,GAAG;;AAGnB,MAAa,mBACX,KACA,QAC4B;AAC5B,KAAI,OAAO,WAAW,YACpB,QAAO,EAAE;CAGX,MAAM,WAAW,YAAY,KAAK,IAAI;AAEtC,KAAI,CAAC,SACH,QAAO,EAAE;AAGX,QAAO,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE;;AAGlC,MAAa,aAAa,QAA2B;AACnD,QAAO,IAAI;;AAGb,eAAsB,gBAAgB,IAAY;CAChD,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI;EAC3B,QAAQ,OAAU,KAAK;EACvB,UAAU;EACV,UAAU;EACV,QAAQ;EACT,CAAC;;AAGJ,eAAsB,qBAAqB;CACzC,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI,EAAE,QAAQ,IAAI,CAAC;;AAG9C,eAAsB,mBAAmB,OAAe;CACtD,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,eAAe,OAAO;EAC1B,QAAQ,OAAU,KAAK;EACvB,UAAU;EACV,UAAU;EACV,QAAQ;EACT,CAAC;;AAGJ,eAAsB,wBAAwB;CAC5C,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,eAAe,IAAI,EAAE,QAAQ,IAAI,CAAC;;AAG1C,MAAa,YAAY,OAAO,IAAY,QAA2B;AACrE,KAAI,IAAI,UACN,OAAM,IAAI,UAAU,GAAG;;AAI3B,MAAa,eAAe,OAAO,QAA2B;AAC5D,KAAI,IAAI,aACN,OAAM,IAAI,cAAc;;AAI5B,MAAa,eAAe,OAAO,OAAe,QAA2B;AAC3E,KAAI,IAAI,aACN,OAAM,IAAI,aAAa,MAAM;;AAIjC,MAAa,kBAAkB,OAAO,QAA2B;AAC/D,KAAI,IAAI,gBACN,OAAM,IAAI,iBAAiB"}
@@ -2,8 +2,8 @@ import { Customer, TransferCartMutation } from "../../types/graphql.js";
2
2
  import { StorefrontContext } from "./context.js";
3
3
 
4
4
  //#region src/lib/data/customer.d.ts
5
- declare const transferCart: (ctx?: StorefrontContext) => Promise<TransferCartMutation["transferCart"] | null>;
6
- declare const retrieveCustomer: (ctx?: StorefrontContext) => Promise<Customer | null>;
5
+ declare const transferCart: (ctx: StorefrontContext) => Promise<TransferCartMutation["transferCart"] | null>;
6
+ declare const retrieveCustomer: (ctx: StorefrontContext) => Promise<Customer | null>;
7
7
  //#endregion
8
8
  export { retrieveCustomer, transferCart };
9
9
  //# sourceMappingURL=customer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customer.d.ts","names":[],"sources":["../../../src/lib/data/customer.ts"],"sourcesContent":[],"mappings":";;;;cAkBa,qBACN,sBACJ,QAAQ;cAgCE,yBACN,sBACJ,QAAQ"}
1
+ {"version":3,"file":"customer.d.ts","names":[],"sources":["../../../src/lib/data/customer.ts"],"sourcesContent":[],"mappings":";;;;cAkBa,oBACN,sBACJ,QAAQ;cAgCE,wBACN,sBACJ,QAAQ"}
@@ -5,7 +5,7 @@ import { medusaError } from "../utils/medusa-error.js";
5
5
  import { getCacheTag, getCartId } from "./cookies.js";
6
6
 
7
7
  //#region src/lib/data/customer.ts
8
- const transferCart = async (ctx = {}) => {
8
+ const transferCart = async (ctx) => {
9
9
  const cartId = getCartId(ctx);
10
10
  if (!cartId) return null;
11
11
  try {
@@ -23,7 +23,7 @@ const transferCart = async (ctx = {}) => {
23
23
  return null;
24
24
  }
25
25
  };
26
- const retrieveCustomer = async (ctx = {}) => {
26
+ const retrieveCustomer = async (ctx) => {
27
27
  const cookieHeader = ctx.cookieHeader;
28
28
  const apolloClient = createServerApolloClient(cookieHeader);
29
29
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"customer.js","names":[],"sources":["../../../src/lib/data/customer.ts"],"sourcesContent":["import {\n Customer,\n GetCustomerQuery,\n GetCustomerQueryVariables,\n TransferCartMutation,\n TransferCartMutationVariables,\n} from '../../types/graphql';\nimport {\n createServerApolloClient,\n graphqlFetch,\n graphqlMutation,\n} from '../gql/apollo-client';\nimport { TRANSFER_CART_MUTATION } from '../gql/mutations/cart';\nimport { GET_CUSTOMER_QUERY } from '../gql/queries/customer';\nimport { medusaError } from '../utils/medusa-error';\nimport { StorefrontContext } from './context';\nimport { getCacheTag, getCartId } from './cookies';\n\nexport const transferCart = async (\n ctx: StorefrontContext = {}\n): Promise<TransferCartMutation['transferCart'] | null> => {\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n return null;\n }\n\n try {\n const result = await graphqlMutation<\n TransferCartMutation,\n TransferCartMutationVariables\n >({\n mutation: TRANSFER_CART_MUTATION,\n variables: {\n cartId,\n },\n });\n\n const cart = result?.transferCart ?? null;\n\n if (cart && ctx.revalidate) {\n const cartCacheTag = getCacheTag('carts', ctx);\n ctx.revalidate(cartCacheTag);\n }\n\n return cart;\n } catch (err) {\n medusaError(err);\n return null;\n }\n};\n\nexport const retrieveCustomer = async (\n ctx: StorefrontContext = {}\n): Promise<Customer | null> => {\n const cookieHeader = ctx.cookieHeader;\n const apolloClient = createServerApolloClient(cookieHeader);\n\n try {\n const customer = await graphqlFetch<\n GetCustomerQuery,\n GetCustomerQueryVariables\n >(\n {\n query: GET_CUSTOMER_QUERY,\n fetchPolicy: 'network-only',\n },\n apolloClient\n ).then((response) => response?.me ?? null);\n\n return customer;\n } catch {\n return null;\n }\n};\n"],"mappings":";;;;;;;AAkBA,MAAa,eAAe,OAC1B,MAAyB,EAAE,KAC8B;CACzD,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,OACH,QAAO;AAGT,KAAI;EAWF,MAAM,QAVS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW,EACT,QACD;GACF,CAAC,GAEmB,gBAAgB;AAErC,MAAI,QAAQ,IAAI,YAAY;GAC1B,MAAM,eAAe,YAAY,SAAS,IAAI;AAC9C,OAAI,WAAW,aAAa;;AAG9B,SAAO;UACA,KAAK;AACZ,cAAY,IAAI;AAChB,SAAO;;;AAIX,MAAa,mBAAmB,OAC9B,MAAyB,EAAE,KACE;CAC7B,MAAM,eAAe,IAAI;CACzB,MAAM,eAAe,yBAAyB,aAAa;AAE3D,KAAI;AAYF,SAXiB,MAAM,aAIrB;GACE,OAAO;GACP,aAAa;GACd,EACD,aACD,CAAC,MAAM,aAAa,UAAU,MAAM,KAAK;SAGpC;AACN,SAAO"}
1
+ {"version":3,"file":"customer.js","names":[],"sources":["../../../src/lib/data/customer.ts"],"sourcesContent":["import {\n Customer,\n GetCustomerQuery,\n GetCustomerQueryVariables,\n TransferCartMutation,\n TransferCartMutationVariables,\n} from '../../types/graphql';\nimport {\n createServerApolloClient,\n graphqlFetch,\n graphqlMutation,\n} from '../gql/apollo-client';\nimport { TRANSFER_CART_MUTATION } from '../gql/mutations/cart';\nimport { GET_CUSTOMER_QUERY } from '../gql/queries/customer';\nimport { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport { getCacheTag, getCartId } from './cookies';\n\nexport const transferCart = async (\n ctx: StorefrontContext\n): Promise<TransferCartMutation['transferCart'] | null> => {\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n return null;\n }\n\n try {\n const result = await graphqlMutation<\n TransferCartMutation,\n TransferCartMutationVariables\n >({\n mutation: TRANSFER_CART_MUTATION,\n variables: {\n cartId,\n },\n });\n\n const cart = result?.transferCart ?? null;\n\n if (cart && ctx.revalidate) {\n const cartCacheTag = getCacheTag('carts', ctx);\n ctx.revalidate(cartCacheTag);\n }\n\n return cart;\n } catch (err) {\n medusaError(err);\n return null;\n }\n};\n\nexport const retrieveCustomer = async (\n ctx: StorefrontContext\n): Promise<Customer | null> => {\n const cookieHeader = ctx.cookieHeader;\n const apolloClient = createServerApolloClient(cookieHeader);\n\n try {\n const customer = await graphqlFetch<\n GetCustomerQuery,\n GetCustomerQueryVariables\n >(\n {\n query: GET_CUSTOMER_QUERY,\n fetchPolicy: 'network-only',\n },\n apolloClient\n ).then((response) => response?.me ?? null);\n\n return customer;\n } catch {\n return null;\n }\n};\n"],"mappings":";;;;;;;AAkBA,MAAa,eAAe,OAC1B,QACyD;CACzD,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,OACH,QAAO;AAGT,KAAI;EAWF,MAAM,QAVS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW,EACT,QACD;GACF,CAAC,GAEmB,gBAAgB;AAErC,MAAI,QAAQ,IAAI,YAAY;GAC1B,MAAM,eAAe,YAAY,SAAS,IAAI;AAC9C,OAAI,WAAW,aAAa;;AAG9B,SAAO;UACA,KAAK;AACZ,cAAY,IAAI;AAChB,SAAO;;;AAIX,MAAa,mBAAmB,OAC9B,QAC6B;CAC7B,MAAM,eAAe,IAAI;CACzB,MAAM,eAAe,yBAAyB,aAAa;AAE3D,KAAI;AAYF,SAXiB,MAAM,aAIrB;GACE,OAAO;GACP,aAAa;GACd,EACD,aACD,CAAC,MAAM,aAAa,UAAU,MAAM,KAAK;SAGpC;AACN,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"next-context.d.ts","names":[],"sources":["../../../src/lib/data/next-context.ts"],"sourcesContent":[],"mappings":";;;cASa,0BAA+B,QAAQ;iBA8C9B,kBAAA,4CAED"}
1
+ {"version":3,"file":"next-context.d.ts","names":[],"sources":["../../../src/lib/data/next-context.ts"],"sourcesContent":[],"mappings":";;;cAkBa,0BAA+B,QAAQ;iBAiB9B,kBAAA,4CAED"}
@@ -1,4 +1,6 @@
1
- import { getCacheTag, getCartId } from "./cookies.js";
1
+ 'use server';
2
+
3
+ import { getCacheTag, getCartId, removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction } from "./cookies.js";
2
4
  import { updateCart } from "./cart.js";
3
5
  import { getRegion } from "./regions.js";
4
6
  import { redirect } from "next/navigation";
@@ -9,41 +11,16 @@ import { cookies } from "next/headers";
9
11
  const resolveNextContext = async () => {
10
12
  const cookieStore = await cookies();
11
13
  return {
12
- cartId: cookieStore.get("_medusa_cart_id")?.value,
13
- customerToken: cookieStore.get("_medusa_jwt")?.value,
14
- cacheId: cookieStore.get("_medusa_cache_id")?.value,
14
+ cartId: cookieStore.get("_medusa_cart_id")?.value ?? "",
15
+ customerToken: cookieStore.get("_medusa_jwt")?.value ?? "",
16
+ cacheId: cookieStore.get("_medusa_cache_id")?.value ?? "",
15
17
  cookieHeader: cookieStore.toString(),
16
18
  revalidate: (tag) => revalidateTag(tag),
17
- updateRegion: async (countryCode, currentPath) => {
18
- "use server";
19
- await updateRegionAction(countryCode, currentPath);
20
- },
21
- setCartId: async (id) => {
22
- "use server";
23
- (await cookies()).set("_medusa_cart_id", id, {
24
- maxAge: 3600 * 24 * 7,
25
- httpOnly: true,
26
- sameSite: "strict",
27
- secure: false
28
- });
29
- },
30
- removeCartId: async () => {
31
- "use server";
32
- (await cookies()).set("_medusa_cart_id", "", { maxAge: -1 });
33
- },
34
- setAuthToken: async (token) => {
35
- "use server";
36
- (await cookies()).set("_medusa_jwt", token, {
37
- maxAge: 3600 * 24 * 7,
38
- httpOnly: true,
39
- sameSite: "strict",
40
- secure: false
41
- });
42
- },
43
- removeAuthToken: async () => {
44
- "use server";
45
- (await cookies()).set("_medusa_jwt", "", { maxAge: -1 });
46
- }
19
+ updateRegion: updateRegionAction,
20
+ setCartId: setCartIdAction,
21
+ removeCartId: removeCartIdAction,
22
+ setAuthToken: setAuthTokenAction,
23
+ removeAuthToken: removeAuthTokenAction
47
24
  };
48
25
  };
49
26
  async function updateRegionAction(countryCode, currentPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"next-context.js","names":[],"sources":["../../../src/lib/data/next-context.ts"],"sourcesContent":["import { revalidateTag } from 'next/cache';\nimport { cookies } from 'next/headers';\nimport { redirect } from 'next/navigation';\n\nimport { updateCart } from './cart';\nimport { StorefrontContext } from './context';\nimport { getCacheTag, getCartId } from './cookies';\nimport { getRegion } from './regions';\n\nexport const resolveNextContext = async (): Promise<StorefrontContext> => {\n const cookieStore = await cookies();\n\n return {\n cartId: cookieStore.get('_medusa_cart_id')?.value,\n customerToken: cookieStore.get('_medusa_jwt')?.value,\n cacheId: cookieStore.get('_medusa_cache_id')?.value,\n cookieHeader: cookieStore.toString(),\n revalidate: (tag: string) => revalidateTag(tag),\n updateRegion: async (countryCode: string, currentPath: string) => {\n 'use server';\n await updateRegionAction(countryCode, currentPath);\n },\n setCartId: async (id: string) => {\n 'use server';\n const c = await cookies();\n c.set('_medusa_cart_id', id, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n },\n removeCartId: async () => {\n 'use server';\n const c = await cookies();\n c.set('_medusa_cart_id', '', { maxAge: -1 });\n },\n setAuthToken: async (token: string) => {\n 'use server';\n const c = await cookies();\n c.set('_medusa_jwt', token, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n },\n removeAuthToken: async () => {\n 'use server';\n const c = await cookies();\n c.set('_medusa_jwt', '', { maxAge: -1 });\n },\n };\n};\n\nexport async function updateRegionAction(\n countryCode: string,\n currentPath: string\n) {\n const ctx = await resolveNextContext();\n const cartId = getCartId(ctx);\n const region = await getRegion(countryCode, ctx);\n\n if (!region) {\n throw new Error(`Region not found for country code: ${countryCode}`);\n }\n\n if (cartId) {\n await updateCart({ regionId: region.id }, ctx);\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n }\n\n const regionCacheTag = getCacheTag('regions', ctx);\n revalidateTag(regionCacheTag);\n\n const productsCacheTag = getCacheTag('products', ctx);\n revalidateTag(productsCacheTag);\n\n redirect(`/${countryCode}${currentPath}`);\n}\n"],"mappings":";;;;;;;;AASA,MAAa,qBAAqB,YAAwC;CACxE,MAAM,cAAc,MAAM,SAAS;AAEnC,QAAO;EACL,QAAQ,YAAY,IAAI,kBAAkB,EAAE;EAC5C,eAAe,YAAY,IAAI,cAAc,EAAE;EAC/C,SAAS,YAAY,IAAI,mBAAmB,EAAE;EAC9C,cAAc,YAAY,UAAU;EACpC,aAAa,QAAgB,cAAc,IAAI;EAC/C,cAAc,OAAO,aAAqB,gBAAwB;AAChE;AACA,SAAM,mBAAmB,aAAa,YAAY;;EAEpD,WAAW,OAAO,OAAe;AAC/B;AAEA,IADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI;IAC3B,QAAQ,OAAU,KAAK;IACvB,UAAU;IACV,UAAU;IACV,QAAQ;IACT,CAAC;;EAEJ,cAAc,YAAY;AACxB;AAEA,IADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI,EAAE,QAAQ,IAAI,CAAC;;EAE9C,cAAc,OAAO,UAAkB;AACrC;AAEA,IADU,MAAM,SAAS,EACvB,IAAI,eAAe,OAAO;IAC1B,QAAQ,OAAU,KAAK;IACvB,UAAU;IACV,UAAU;IACV,QAAQ;IACT,CAAC;;EAEJ,iBAAiB,YAAY;AAC3B;AAEA,IADU,MAAM,SAAS,EACvB,IAAI,eAAe,IAAI,EAAE,QAAQ,IAAI,CAAC;;EAE3C;;AAGH,eAAsB,mBACpB,aACA,aACA;CACA,MAAM,MAAM,MAAM,oBAAoB;CACtC,MAAM,SAAS,UAAU,IAAI;CAC7B,MAAM,SAAS,MAAM,UAAU,aAAa,IAAI;AAEhD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,sCAAsC,cAAc;AAGtE,KAAI,QAAQ;AACV,QAAM,WAAW,EAAE,UAAU,OAAO,IAAI,EAAE,IAAI;AAE9C,gBADqB,YAAY,SAAS,IAAI,CACnB;;AAI7B,eADuB,YAAY,WAAW,IAAI,CACrB;AAG7B,eADyB,YAAY,YAAY,IAAI,CACtB;AAE/B,UAAS,IAAI,cAAc,cAAc"}
1
+ {"version":3,"file":"next-context.js","names":[],"sources":["../../../src/lib/data/next-context.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport { cookies } from 'next/headers';\nimport { redirect } from 'next/navigation';\n\nimport { updateCart } from './cart';\nimport { StorefrontContext } from './context';\nimport {\n getCacheTag,\n getCartId,\n removeAuthTokenAction,\n removeCartIdAction,\n setAuthTokenAction,\n setCartIdAction,\n} from './cookies';\nimport { getRegion } from './regions';\n\nexport const resolveNextContext = async (): Promise<StorefrontContext> => {\n const cookieStore = await cookies();\n\n return {\n cartId: cookieStore.get('_medusa_cart_id')?.value ?? '',\n customerToken: cookieStore.get('_medusa_jwt')?.value ?? '',\n cacheId: cookieStore.get('_medusa_cache_id')?.value ?? '',\n cookieHeader: cookieStore.toString(),\n revalidate: (tag: string) => revalidateTag(tag),\n updateRegion: updateRegionAction,\n setCartId: setCartIdAction,\n removeCartId: removeCartIdAction,\n setAuthToken: setAuthTokenAction,\n removeAuthToken: removeAuthTokenAction,\n };\n};\n\nexport async function updateRegionAction(\n countryCode: string,\n currentPath: string\n) {\n const ctx = await resolveNextContext();\n const cartId = getCartId(ctx);\n const region = await getRegion(countryCode, ctx);\n\n if (!region) {\n throw new Error(`Region not found for country code: ${countryCode}`);\n }\n\n if (cartId) {\n await updateCart({ regionId: region.id }, ctx);\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n }\n\n const regionCacheTag = getCacheTag('regions', ctx);\n revalidateTag(regionCacheTag);\n\n const productsCacheTag = getCacheTag('products', ctx);\n revalidateTag(productsCacheTag);\n\n redirect(`/${countryCode}${currentPath}`);\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,qBAAqB,YAAwC;CACxE,MAAM,cAAc,MAAM,SAAS;AAEnC,QAAO;EACL,QAAQ,YAAY,IAAI,kBAAkB,EAAE,SAAS;EACrD,eAAe,YAAY,IAAI,cAAc,EAAE,SAAS;EACxD,SAAS,YAAY,IAAI,mBAAmB,EAAE,SAAS;EACvD,cAAc,YAAY,UAAU;EACpC,aAAa,QAAgB,cAAc,IAAI;EAC/C,cAAc;EACd,WAAW;EACX,cAAc;EACd,cAAc;EACd,iBAAiB;EAClB;;AAGH,eAAsB,mBACpB,aACA,aACA;CACA,MAAM,MAAM,MAAM,oBAAoB;CACtC,MAAM,SAAS,UAAU,IAAI;CAC7B,MAAM,SAAS,MAAM,UAAU,aAAa,IAAI;AAEhD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,sCAAsC,cAAc;AAGtE,KAAI,QAAQ;AACV,QAAM,WAAW,EAAE,UAAU,OAAO,IAAI,EAAE,IAAI;AAE9C,gBADqB,YAAY,SAAS,IAAI,CACnB;;AAI7B,eADuB,YAAY,WAAW,IAAI,CACrB;AAG7B,eADyB,YAAY,YAAY,IAAI,CACtB;AAE/B,UAAS,IAAI,cAAc,cAAc"}
@@ -1,7 +1,8 @@
1
1
  import { Order } from "../../types/graphql.js";
2
+ import { StorefrontContext } from "./context.js";
2
3
 
3
4
  //#region src/lib/data/orders.d.ts
4
- declare const retrieveOrder: (id: string) => Promise<Order>;
5
+ declare const retrieveOrder: (id: string, ctx: StorefrontContext) => Promise<Order>;
5
6
  //#endregion
6
7
  export { retrieveOrder };
7
8
  //# sourceMappingURL=orders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"orders.d.ts","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":[],"mappings":";;;cAOa,+BAAiC,QAsB7C,KAAA"}
1
+ {"version":3,"file":"orders.d.ts","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":[],"mappings":";;;;cAQa,iCAAwC,sBAAiB,QAAA,KAAA"}
@@ -4,9 +4,9 @@ import { sdk } from "../config/medusa.js";
4
4
  import { normalizeOrder } from "../utils/normalize-functions.js";
5
5
 
6
6
  //#region src/lib/data/orders.ts
7
- const retrieveOrder = async (id) => {
8
- const headers = { ...await getAuthHeaders() };
9
- const next = { ...await getCacheOptions("orders") };
7
+ const retrieveOrder = async (id, ctx) => {
8
+ const headers = { ...getAuthHeaders(ctx) };
9
+ const next = { ...getCacheOptions("orders", ctx) };
10
10
  return sdk.client.fetch(`/store/orders/${id}`, {
11
11
  method: "GET",
12
12
  query: { fields: "*payment_collections.payments,*items,*items.metadata,*items.variant,*items.product" },
@@ -1 +1 @@
1
- {"version":3,"file":"orders.js","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":["import { HttpTypes } from '@medusajs/types';\n\nimport { sdk } from '../config/medusa';\nimport { medusaError } from '../utils/medusa-error';\nimport { normalizeOrder } from '../utils/normalize-functions';\nimport { getAuthHeaders, getCacheOptions } from './cookies';\n\nexport const retrieveOrder = async (id: string) => {\n const headers = {\n ...(await getAuthHeaders()),\n };\n\n const next = {\n ...(await getCacheOptions('orders')),\n };\n\n return sdk.client\n .fetch<HttpTypes.StoreOrderResponse>(`/store/orders/${id}`, {\n method: 'GET',\n query: {\n fields:\n '*payment_collections.payments,*items,*items.metadata,*items.variant,*items.product',\n },\n headers,\n next,\n cache: 'force-cache',\n })\n .then(({ order }) => order && normalizeOrder(order))\n .catch((err) => medusaError(err));\n};\n"],"mappings":";;;;;;AAOA,MAAa,gBAAgB,OAAO,OAAe;CACjD,MAAM,UAAU,EACd,GAAI,MAAM,gBAAgB,EAC3B;CAED,MAAM,OAAO,EACX,GAAI,MAAM,gBAAgB,SAAS,EACpC;AAED,QAAO,IAAI,OACR,MAAoC,iBAAiB,MAAM;EAC1D,QAAQ;EACR,OAAO,EACL,QACE,sFACH;EACD;EACA;EACA,OAAO;EACR,CAAC,CACD,MAAM,EAAE,YAAY,SAAS,eAAe,MAAM,CAAC,CACnD,OAAO,QAAQ,YAAY,IAAI,CAAC"}
1
+ {"version":3,"file":"orders.js","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":["import { HttpTypes } from '@medusajs/types';\n\nimport { sdk } from '../config/medusa';\nimport { medusaError } from '../utils/medusa-error';\nimport { normalizeOrder } from '../utils/normalize-functions';\nimport { StorefrontContext } from './context';\nimport { getAuthHeaders, getCacheOptions } from './cookies';\n\nexport const retrieveOrder = async (id: string, ctx: StorefrontContext) => {\n const headers = {\n ...getAuthHeaders(ctx),\n };\n\n const next = {\n ...getCacheOptions('orders', ctx),\n };\n\n return sdk.client\n .fetch<HttpTypes.StoreOrderResponse>(`/store/orders/${id}`, {\n method: 'GET',\n query: {\n fields:\n '*payment_collections.payments,*items,*items.metadata,*items.variant,*items.product',\n },\n headers,\n next,\n cache: 'force-cache',\n })\n .then(({ order }) => order && normalizeOrder(order))\n .catch((err) => medusaError(err));\n};\n"],"mappings":";;;;;;AAQA,MAAa,gBAAgB,OAAO,IAAY,QAA2B;CACzE,MAAM,UAAU,EACd,GAAG,eAAe,IAAI,EACvB;CAED,MAAM,OAAO,EACX,GAAG,gBAAgB,UAAU,IAAI,EAClC;AAED,QAAO,IAAI,OACR,MAAoC,iBAAiB,MAAM;EAC1D,QAAQ;EACR,OAAO,EACL,QACE,sFACH;EACD;EACA;EACA,OAAO;EACR,CAAC,CACD,MAAM,EAAE,YAAY,SAAS,eAAe,MAAM,CAAC,CACnD,OAAO,QAAQ,YAAY,IAAI,CAAC"}
@@ -1,14 +1,14 @@
1
- import * as _apollo_client2 from "@apollo/client";
1
+ import * as _apollo_client0 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/fragments/cart.d.ts
4
- declare const LINE_ITEM_FRAGMENT: _apollo_client2.DocumentNode;
5
- declare const COUNTRY_FRAGMENT: _apollo_client2.DocumentNode;
6
- declare const REGION_FRAGMENT: _apollo_client2.DocumentNode;
7
- declare const SHIPPING_METHODS_FRAGMENT: _apollo_client2.DocumentNode;
8
- declare const PAYMENT_COLLECTION_FRAGMENT: _apollo_client2.DocumentNode;
9
- declare const ADDRESS_FRAGMENT: _apollo_client2.DocumentNode;
10
- declare const PROMOTION_FRAGMENT: _apollo_client2.DocumentNode;
11
- declare const CART_FRAGMENT: _apollo_client2.DocumentNode;
4
+ declare const LINE_ITEM_FRAGMENT: _apollo_client0.DocumentNode;
5
+ declare const COUNTRY_FRAGMENT: _apollo_client0.DocumentNode;
6
+ declare const REGION_FRAGMENT: _apollo_client0.DocumentNode;
7
+ declare const SHIPPING_METHODS_FRAGMENT: _apollo_client0.DocumentNode;
8
+ declare const PAYMENT_COLLECTION_FRAGMENT: _apollo_client0.DocumentNode;
9
+ declare const ADDRESS_FRAGMENT: _apollo_client0.DocumentNode;
10
+ declare const PROMOTION_FRAGMENT: _apollo_client0.DocumentNode;
11
+ declare const CART_FRAGMENT: _apollo_client0.DocumentNode;
12
12
  //#endregion
13
13
  export { ADDRESS_FRAGMENT, CART_FRAGMENT, COUNTRY_FRAGMENT, LINE_ITEM_FRAGMENT, PAYMENT_COLLECTION_FRAGMENT, PROMOTION_FRAGMENT, REGION_FRAGMENT, SHIPPING_METHODS_FRAGMENT };
14
14
  //# sourceMappingURL=cart.d.ts.map
@@ -1,8 +1,8 @@
1
- import * as _apollo_client11 from "@apollo/client";
1
+ import * as _apollo_client8 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/fragments/customer.d.ts
4
- declare const CUSTOMER_ADDRESS_FRAGMENT: _apollo_client11.DocumentNode;
5
- declare const CUSTOMER_FRAGMENT: _apollo_client11.DocumentNode;
4
+ declare const CUSTOMER_ADDRESS_FRAGMENT: _apollo_client8.DocumentNode;
5
+ declare const CUSTOMER_FRAGMENT: _apollo_client8.DocumentNode;
6
6
  //#endregion
7
7
  export { CUSTOMER_ADDRESS_FRAGMENT, CUSTOMER_FRAGMENT };
8
8
  //# sourceMappingURL=customer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customer.d.ts","names":[],"sources":["../../../../src/lib/gql/fragments/customer.ts"],"sourcesContent":[],"mappings":";;;cAEa,2BAkBZ,gBAAA,CAlBqC;cAoBzB,mBAeZ,gBAAA,CAf6B"}
1
+ {"version":3,"file":"customer.d.ts","names":[],"sources":["../../../../src/lib/gql/fragments/customer.ts"],"sourcesContent":[],"mappings":";;;cAEa,2BAkBZ,eAAA,CAlBqC;cAoBzB,mBAeZ,eAAA,CAf6B"}
@@ -1,13 +1,13 @@
1
- import * as _apollo_client19 from "@apollo/client";
1
+ import * as _apollo_client10 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/fragments/product.d.ts
4
- declare const PRICE_FRAGMENT: _apollo_client19.DocumentNode;
5
- declare const PRODUCT_VARIANT_FRAGMENT: _apollo_client19.DocumentNode;
6
- declare const PRODUCT_HIT_FRAGMENT: _apollo_client19.DocumentNode;
7
- declare const PRODUCT_CATEGORY_FRAGMENT: _apollo_client19.DocumentNode;
8
- declare const PRODUCT_COLLECTION_FRAGMENT: _apollo_client19.DocumentNode;
9
- declare const PRODUCT_IMAGE_FRAGMENT: _apollo_client19.DocumentNode;
10
- declare const COLLECTION_PRODUCTS_FRAGMENT: _apollo_client19.DocumentNode;
4
+ declare const PRICE_FRAGMENT: _apollo_client10.DocumentNode;
5
+ declare const PRODUCT_VARIANT_FRAGMENT: _apollo_client10.DocumentNode;
6
+ declare const PRODUCT_HIT_FRAGMENT: _apollo_client10.DocumentNode;
7
+ declare const PRODUCT_CATEGORY_FRAGMENT: _apollo_client10.DocumentNode;
8
+ declare const PRODUCT_COLLECTION_FRAGMENT: _apollo_client10.DocumentNode;
9
+ declare const PRODUCT_IMAGE_FRAGMENT: _apollo_client10.DocumentNode;
10
+ declare const COLLECTION_PRODUCTS_FRAGMENT: _apollo_client10.DocumentNode;
11
11
  //#endregion
12
12
  export { COLLECTION_PRODUCTS_FRAGMENT, PRICE_FRAGMENT, PRODUCT_CATEGORY_FRAGMENT, PRODUCT_COLLECTION_FRAGMENT, PRODUCT_HIT_FRAGMENT, PRODUCT_IMAGE_FRAGMENT, PRODUCT_VARIANT_FRAGMENT };
13
13
  //# sourceMappingURL=product.d.ts.map
@@ -1,9 +1,9 @@
1
- import * as _apollo_client14 from "@apollo/client";
1
+ import * as _apollo_client17 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/mutations/cart.d.ts
4
- declare const UPDATE_CART_MUTATION: _apollo_client14.DocumentNode;
5
- declare const DELETE_LINE_ITEM_MUTATION: _apollo_client14.DocumentNode;
6
- declare const TRANSFER_CART_MUTATION: _apollo_client14.DocumentNode;
4
+ declare const UPDATE_CART_MUTATION: _apollo_client17.DocumentNode;
5
+ declare const DELETE_LINE_ITEM_MUTATION: _apollo_client17.DocumentNode;
6
+ declare const TRANSFER_CART_MUTATION: _apollo_client17.DocumentNode;
7
7
  //#endregion
8
8
  export { DELETE_LINE_ITEM_MUTATION, TRANSFER_CART_MUTATION, UPDATE_CART_MUTATION };
9
9
  //# sourceMappingURL=cart.d.ts.map
@@ -1,7 +1,7 @@
1
- import * as _apollo_client18 from "@apollo/client";
1
+ import * as _apollo_client21 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/queries/cart.d.ts
4
- declare const GET_CART_QUERY: _apollo_client18.DocumentNode;
4
+ declare const GET_CART_QUERY: _apollo_client21.DocumentNode;
5
5
  //#endregion
6
6
  export { GET_CART_QUERY };
7
7
  //# sourceMappingURL=cart.d.ts.map
@@ -1,7 +1,7 @@
1
- import * as _apollo_client10 from "@apollo/client";
1
+ import * as _apollo_client20 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/queries/collections.d.ts
4
- declare const GET_COLLECTIONS_QUERY: _apollo_client10.DocumentNode;
4
+ declare const GET_COLLECTIONS_QUERY: _apollo_client20.DocumentNode;
5
5
  //#endregion
6
6
  export { GET_COLLECTIONS_QUERY };
7
7
  //# sourceMappingURL=collections.d.ts.map
@@ -1,7 +1,7 @@
1
- import * as _apollo_client13 from "@apollo/client";
1
+ import * as _apollo_client22 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/queries/customer.d.ts
4
- declare const GET_CUSTOMER_QUERY: _apollo_client13.DocumentNode;
4
+ declare const GET_CUSTOMER_QUERY: _apollo_client22.DocumentNode;
5
5
  //#endregion
6
6
  export { GET_CUSTOMER_QUERY };
7
7
  //# sourceMappingURL=customer.d.ts.map
@@ -1,7 +1,7 @@
1
- import * as _apollo_client17 from "@apollo/client";
1
+ import * as _apollo_client23 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/queries/footer.d.ts
4
- declare const GET_FOOTER_QUERY: _apollo_client17.DocumentNode;
4
+ declare const GET_FOOTER_QUERY: _apollo_client23.DocumentNode;
5
5
  //#endregion
6
6
  export { GET_FOOTER_QUERY };
7
7
  //# sourceMappingURL=footer.d.ts.map
@@ -1,8 +1,8 @@
1
- import * as _apollo_client0 from "@apollo/client";
1
+ import * as _apollo_client24 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/gql/queries/product.d.ts
4
- declare const SEARCH_SUGGESTIONS_QUERY: _apollo_client0.DocumentNode;
5
- declare const GET_PRODUCT_CATEGORIES_QUERY: _apollo_client0.DocumentNode;
4
+ declare const SEARCH_SUGGESTIONS_QUERY: _apollo_client24.DocumentNode;
5
+ declare const GET_PRODUCT_CATEGORIES_QUERY: _apollo_client24.DocumentNode;
6
6
  //#endregion
7
7
  export { GET_PRODUCT_CATEGORIES_QUERY, SEARCH_SUGGESTIONS_QUERY };
8
8
  //# sourceMappingURL=product.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"product.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/product.ts"],"sourcesContent":[],"mappings":";;;cAOa,0BASZ,eAAA,CAToC;cAWxB,8BA4BZ,eAAA,CA5BwC"}
1
+ {"version":3,"file":"product.d.ts","names":[],"sources":["../../../../src/lib/gql/queries/product.ts"],"sourcesContent":[],"mappings":";;;cAOa,0BASZ,gBAAA,CAToC;cAWxB,8BA4BZ,gBAAA,CA5BwC"}
@@ -1,7 +1,7 @@
1
- import * as _apollo_client0 from "@apollo/client";
1
+ import * as _apollo_client7 from "@apollo/client";
2
2
 
3
3
  //#region src/lib/hooks/use-apollo.d.ts
4
- declare function useApollo(): _apollo_client0.ApolloClient;
4
+ declare function useApollo(): _apollo_client7.ApolloClient;
5
5
  //#endregion
6
6
  export { useApollo };
7
7
  //# sourceMappingURL=use-apollo.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfed-medusa/sf-lib-common",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@apollo/client": "^4.0.9",
42
- "@gfed-medusa/sf-lib-ui": "^1.1.0",
42
+ "@gfed-medusa/sf-lib-ui": "^1.2.0",
43
43
  "@headlessui/react": "^2.2.9",
44
44
  "@medusajs/js-sdk": "^2.12.1",
45
45
  "@medusajs/types": "^2.12.1",
@@ -90,6 +90,7 @@
90
90
  "codegen:watch": "graphql-codegen --config codegen.ts --watch",
91
91
  "dev": "tsdown --watch",
92
92
  "format:fix": "prettier --write .",
93
+ "check-types": "tsc --noEmit",
93
94
  "lint": "eslint . --max-warnings 40"
94
95
  }
95
96
  }