@replohq/sdk 1.9.0 → 1.9.1

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 (49) hide show
  1. package/_vendor/replo-utils/lib/json.mjs +5 -2
  2. package/_vendor/replo-utils/lib/misc.mjs +3 -2
  3. package/_vendor/replo-utils/lib/object.mjs +5 -0
  4. package/_vendor/schemas/contentEntry.mjs +3 -1
  5. package/_vendor/schemas/contentManifest.mjs +6 -3
  6. package/_vendor/schemas/money.mjs +3 -2
  7. package/_vendor/schemas/routing/locale.d.ts +1 -1
  8. package/_vendor/schemas/routing/locale.mjs +3 -2
  9. package/_vendor/schemas/routing/rules.mjs +3 -2
  10. package/analytics/sinks/converge-event-mapper.js +4 -10
  11. package/cart/buy-now-action.d.ts +0 -2
  12. package/cart/buy-now-action.js +0 -1
  13. package/cart/cart-actions.d.ts +1 -5
  14. package/cart/cart-actions.js +5 -21
  15. package/cart/cart-loader.d.ts +1 -4
  16. package/cart/cart-loader.js +2 -5
  17. package/cart/cart-provider.d.ts +1 -3
  18. package/cart/cart-provider.js +14 -34
  19. package/cart/cart-schema.d.ts +0 -3
  20. package/cart/cart-schema.js +1 -2
  21. package/cart/cart-types.d.ts +0 -12
  22. package/cart/gateways/cart-gateway.d.ts +2 -10
  23. package/cart/gateways/cookie-cart-gateway.d.ts +2 -10
  24. package/cart/gateways/cookie-cart-gateway.js +1 -8
  25. package/cart/gateways/resolver-cart-gateway.js +2 -25
  26. package/cart/hooks/use-buy-now.js +1 -4
  27. package/chunk-ACQS4AG5.mjs +592 -0
  28. package/{chunk-VKO7P3ED.mjs → chunk-C37TXOGI.mjs} +3 -10
  29. package/chunk-EUIVDITZ.mjs +15 -0
  30. package/{chunk-7OPH5UFQ.mjs → chunk-GZWV5XKV.mjs} +4 -5
  31. package/chunk-SSBIMQES.mjs +755 -0
  32. package/chunk-VVB7BEDE.mjs +84 -0
  33. package/chunk-ZKAX2FW3.mjs +703 -0
  34. package/gateways/canopy-api.d.ts +0 -6
  35. package/gateways/canopy-api.js +1 -8
  36. package/lib/buildMetadata.js +3 -3
  37. package/loaders/collection-loader-args.d.ts +1 -2
  38. package/loaders/collection-products-loader-args.d.ts +1 -2
  39. package/loaders/product-loader-args.d.ts +1 -2
  40. package/package.json +4 -8
  41. package/providers/replo-provider.d.ts +1 -5
  42. package/providers/replo-provider.js +2 -5
  43. package/_vendor/schemas/generated/storefrontCountryCode.d.ts +0 -10
  44. package/cart/cart-country-context.d.ts +0 -2
  45. package/cart/cart-country-context.js +0 -6
  46. package/chunk-AL3F36PH.mjs +0 -1392
  47. package/chunk-GV5FY7ZZ.mjs +0 -78
  48. package/loaders/markets.d.ts +0 -1
  49. package/loaders/markets.js +0 -0
@@ -1,3 +1,6 @@
1
- export { jsonStringifyOrNull, omitJsonObjectFieldsOrNull, parseJsonOrNull } from '../../../chunk-VKO7P3ED.mjs';
2
- import '../../../chunk-GV5FY7ZZ.mjs';
1
+ export { jsonStringifyOrNull, omitJsonObjectFieldsOrNull, parseJsonOrNull } from '../../../chunk-C37TXOGI.mjs';
2
+ import '../../../chunk-VVB7BEDE.mjs';
3
+ import '../../../chunk-ACQS4AG5.mjs';
4
+ import '../../../chunk-EUIVDITZ.mjs';
5
+ import '../../../chunk-SSBIMQES.mjs';
3
6
  import '../../../chunk-UJCSKKID.mjs';
@@ -1,3 +1,4 @@
1
- export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-AL3F36PH.mjs';
2
- export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-GV5FY7ZZ.mjs';
1
+ export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-ZKAX2FW3.mjs';
2
+ export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-EUIVDITZ.mjs';
3
+ export { isFunction_default as isFunction } from '../../../chunk-SSBIMQES.mjs';
3
4
  import '../../../chunk-UJCSKKID.mjs';
@@ -0,0 +1,5 @@
1
+ export { deepEqual, filterUndefined, forEachPrimitiveValue, omit, shallowEqual, toNullableIfDefined } from '../../../chunk-VVB7BEDE.mjs';
2
+ import '../../../chunk-ACQS4AG5.mjs';
3
+ import '../../../chunk-EUIVDITZ.mjs';
4
+ import '../../../chunk-SSBIMQES.mjs';
5
+ import '../../../chunk-UJCSKKID.mjs';
@@ -1,3 +1,5 @@
1
- export { CONTENT_MANAGED_ENTRY_VALUE_KEYS, contentEntryFrontmatterSchema, convertLegacyContentEntryDocument, getContentEntryFieldValidationIssues, getContentRenderableEntryValues, parseContentEntryDocument, serializeContentEntryDocument } from '../../chunk-7OPH5UFQ.mjs';
1
+ export { CONTENT_MANAGED_ENTRY_VALUE_KEYS, contentEntryFrontmatterSchema, convertLegacyContentEntryDocument, getContentEntryFieldValidationIssues, getContentRenderableEntryValues, parseContentEntryDocument, serializeContentEntryDocument } from '../../chunk-GZWV5XKV.mjs';
2
2
  import '../../chunk-EUQVEPSD.mjs';
3
+ import '../../chunk-ACQS4AG5.mjs';
4
+ import '../../chunk-SSBIMQES.mjs';
3
5
  import '../../chunk-UJCSKKID.mjs';
@@ -1,7 +1,10 @@
1
- import { parseContentEntryDocument, getContentRenderableEntryValues, getContentEntryFieldValidationIssues } from '../../chunk-7OPH5UFQ.mjs';
1
+ import { parseContentEntryDocument, getContentRenderableEntryValues, getContentEntryFieldValidationIssues } from '../../chunk-GZWV5XKV.mjs';
2
2
  import { isValidContentSlug, CONTENT_COLLECTION_SCHEMA_FILENAME, CONTENT_ENTRY_FILE_EXTENSION, contentCollectionFileSchema, CONTENT_ENTRY_PUBLISHED_FILE_EXTENSION } from '../../chunk-EUQVEPSD.mjs';
3
- import { parseJsonOrNull } from '../../chunk-VKO7P3ED.mjs';
4
- import '../../chunk-GV5FY7ZZ.mjs';
3
+ import { parseJsonOrNull } from '../../chunk-C37TXOGI.mjs';
4
+ import '../../chunk-VVB7BEDE.mjs';
5
+ import '../../chunk-ACQS4AG5.mjs';
6
+ import '../../chunk-EUIVDITZ.mjs';
7
+ import '../../chunk-SSBIMQES.mjs';
5
8
  import '../../chunk-UJCSKKID.mjs';
6
9
  import { z } from 'zod';
7
10
 
@@ -1,6 +1,7 @@
1
1
  import { ReploError } from '../../chunk-YJQVNUW7.mjs';
2
- import '../../chunk-AL3F36PH.mjs';
3
- import '../../chunk-GV5FY7ZZ.mjs';
2
+ import '../../chunk-ZKAX2FW3.mjs';
3
+ import '../../chunk-EUIVDITZ.mjs';
4
+ import '../../chunk-SSBIMQES.mjs';
4
5
  import { __commonJS, __toESM } from '../../chunk-UJCSKKID.mjs';
5
6
  import { z } from 'zod';
6
7
 
@@ -21,8 +21,8 @@ export declare const localeRoutingConfigSchema: z.ZodObject<{
21
21
  locales: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
22
22
  defaultLocale: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
23
23
  detection: z.ZodDefault<z.ZodEnum<{
24
- country: "country";
25
24
  language: "language";
25
+ country: "country";
26
26
  }>>;
27
27
  urlMode: z.ZodDefault<z.ZodEnum<{
28
28
  prefixed: "prefixed";
@@ -1,6 +1,7 @@
1
1
  import { ReploError } from '../../../chunk-YJQVNUW7.mjs';
2
- import '../../../chunk-AL3F36PH.mjs';
3
- import '../../../chunk-GV5FY7ZZ.mjs';
2
+ import '../../../chunk-ZKAX2FW3.mjs';
3
+ import '../../../chunk-EUIVDITZ.mjs';
4
+ import '../../../chunk-SSBIMQES.mjs';
4
5
  import '../../../chunk-UJCSKKID.mjs';
5
6
  import { z } from 'zod';
6
7
 
@@ -1,7 +1,8 @@
1
1
  import { getParamSegment, getRouteParams, hasRouteParam, matchSource } from '../../../chunk-VPEVERWE.mjs';
2
2
  import { ReploError } from '../../../chunk-YJQVNUW7.mjs';
3
- import '../../../chunk-AL3F36PH.mjs';
4
- import '../../../chunk-GV5FY7ZZ.mjs';
3
+ import '../../../chunk-ZKAX2FW3.mjs';
4
+ import '../../../chunk-EUIVDITZ.mjs';
5
+ import '../../../chunk-SSBIMQES.mjs';
5
6
  import '../../../chunk-UJCSKKID.mjs';
6
7
  import { z } from 'zod';
7
8
 
@@ -1,3 +1,4 @@
1
+ import { filterUndefined } from "../../_vendor/replo-utils/lib/object.mjs";
1
2
  import { z } from "zod";
2
3
  const analyticsRecordSchema = z.record(z.string(), z.unknown());
3
4
  const nonEmptyStringSchema = z.union([
@@ -60,11 +61,6 @@ function optionalProductProperties({
60
61
  image_url: stringFrom(source, ["image_url", "imageUrl", "productImageUrl"]) ?? stringFrom(product, ["imageUrl", "image_url"])
61
62
  };
62
63
  }
63
- function withoutUndefined(record) {
64
- return Object.fromEntries(
65
- Object.entries(record).filter(([, value]) => value !== void 0)
66
- );
67
- }
68
64
  function mapProduct(value, defaults = {}) {
69
65
  const source = parseRecord(value);
70
66
  if (!source) {
@@ -87,9 +83,7 @@ function mapProduct(value, defaults = {}) {
87
83
  name,
88
84
  price,
89
85
  currency,
90
- ...withoutUndefined(
91
- optionalProductProperties({ source, variant, product })
92
- ),
86
+ ...filterUndefined(optionalProductProperties({ source, variant, product })),
93
87
  ...quantity === void 0 ? {} : { quantity }
94
88
  };
95
89
  return mapped;
@@ -129,7 +123,7 @@ function mapConvergeCollection(data) {
129
123
  return {
130
124
  id,
131
125
  name,
132
- ...withoutUndefined({
126
+ ...filterUndefined({
133
127
  description: stringFrom(data, ["description", "collectionDescription"]),
134
128
  items: items.length > 0 ? items : void 0
135
129
  })
@@ -149,7 +143,7 @@ function mapConvergeCart(data) {
149
143
  total_tax: numberFrom(data, ["total_tax", "totalTax"]) ?? 0,
150
144
  total_shipping: numberFrom(data, ["total_shipping", "totalShipping"]) ?? 0,
151
145
  currency,
152
- ...withoutUndefined({
146
+ ...filterUndefined({
153
147
  total_discount: numberFrom(data, ["total_discount", "totalDiscount"]),
154
148
  coupon: couponFrom(data),
155
149
  items: items.length > 0 ? items : void 0
@@ -1,4 +1,3 @@
1
- import type { StorefrontCountryCode } from "../loaders/markets";
2
1
  import type { CartLineAttribute } from "./cart-types";
3
2
  /**
4
3
  * Server action that handles the full buy-now flow:
@@ -20,7 +19,6 @@ export declare function buyNowAction(input: Parameters<typeof buyNowWithRecovery
20
19
  }>;
21
20
  export declare function buyNowWithRecoveryAction(input: {
22
21
  checkoutAttemptId?: string;
23
- country?: StorefrontCountryCode;
24
22
  lineItems: {
25
23
  variantId: string;
26
24
  quantity: number;
@@ -114,7 +114,6 @@ async function buyNowWithRecoveryAction(input) {
114
114
  const cart = await createCartAction({
115
115
  lines: cartLines,
116
116
  skipStoringCart: true,
117
- country: input.country,
118
117
  discountCodes: discountCodes.length > 0 ? discountCodes : void 0
119
118
  });
120
119
  if (!cart?.checkoutUrl) {
@@ -1,4 +1,3 @@
1
- import type { StorefrontCountryCode } from "../loaders/markets";
2
1
  import type { AddToCartPayload, Cart, CartLinePayload, RemoveFromCartPayload, UpdateCartLineItemPayload } from "./cart-types";
3
2
  /**
4
3
  * Gets the existing cart or creates a new one if none exists. This is necessary
@@ -8,9 +7,7 @@ import type { AddToCartPayload, Cart, CartLinePayload, RemoveFromCartPayload, Up
8
7
  *
9
8
  * @returns The existing cart or a newly created cart
10
9
  */
11
- export declare function getOrCreateCartAction(options?: {
12
- country?: StorefrontCountryCode;
13
- }): Promise<Cart | null>;
10
+ export declare function getOrCreateCartAction(): Promise<Cart | null>;
14
11
  /**
15
12
  * Retrieves the current cart from cookies. Returns null if no cart exists or
16
13
  * if the cart has expired/been deleted.
@@ -31,7 +28,6 @@ export declare function createCartAction(options?: {
31
28
  lines?: CartLinePayload[];
32
29
  skipStoringCart?: boolean;
33
30
  discountCodes?: string[];
34
- country?: StorefrontCountryCode;
35
31
  }): Promise<Cart | null>;
36
32
  /**
37
33
  * Adds line items to an existing cart.
@@ -11,20 +11,13 @@ import {
11
11
  saveCartToCookie
12
12
  } from "./utils/cookie-cart-persistence";
13
13
  const SHOPIFY_CART_COOKIE_NAME = "replo_cart_id";
14
- async function getOrCreateCartAction(options) {
14
+ async function getOrCreateCartAction() {
15
15
  const existingCart = await getCartAction();
16
16
  if (existingCart) {
17
17
  const cartGateway = await getCartGateway();
18
- const reconciledCart = await cartGateway.reconcileStoredCart(existingCart);
19
- if (options?.country && reconciledCart.buyerIdentity?.country !== options.country) {
20
- return await cartGateway.updateCartBuyerIdentity({
21
- cartId: reconciledCart.id,
22
- buyerIdentity: { country: options.country }
23
- });
24
- }
25
- return reconciledCart;
18
+ return await cartGateway.reconcileStoredCart(existingCart);
26
19
  }
27
- return await createCartAction({ country: options?.country });
20
+ return await createCartAction();
28
21
  }
29
22
  async function getCartAction() {
30
23
  const checkoutProvider = await getCheckoutProvider();
@@ -51,19 +44,10 @@ async function getCartAction() {
51
44
  return cart;
52
45
  }
53
46
  async function createCartAction(options) {
54
- const {
55
- lines,
56
- skipStoringCart = false,
57
- discountCodes,
58
- country
59
- } = options ?? {};
47
+ const { lines, skipStoringCart = false, discountCodes } = options ?? {};
60
48
  const checkoutProvider = await getCheckoutProvider();
61
49
  const cartGateway = await getCartGateway();
62
- const cart = await cartGateway.createCart({
63
- lines,
64
- discountCodes,
65
- buyerIdentity: country ? { country } : void 0
66
- });
50
+ const cart = await cartGateway.createCart(lines, discountCodes);
67
51
  if (cart && !skipStoringCart) {
68
52
  try {
69
53
  if (checkoutProvider === "stripe") {
@@ -1,4 +1,3 @@
1
- import type { StorefrontCountryCode } from "../loaders/markets";
2
1
  /**
3
2
  * Server component that loads the cart and provides it to child components
4
3
  * through the CartProvider context. In development mode, skips initial
@@ -7,6 +6,4 @@ import type { StorefrontCountryCode } from "../loaders/markets";
7
6
  * @param children - Child components that will have access to the cart
8
7
  * @returns A CartProvider component wrapping the children with cart data
9
8
  */
10
- export declare function CartLoader({ children, country, }: React.PropsWithChildren<{
11
- country?: StorefrontCountryCode;
12
- }>): Promise<import("react/jsx-runtime").JSX.Element>;
9
+ export declare function CartLoader({ children }: React.PropsWithChildren): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -2,16 +2,13 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { unstable_rethrow } from "next/navigation";
3
3
  import { getCartAction } from "./cart-actions";
4
4
  import { CartProvider } from "./cart-provider";
5
- async function CartLoader({
6
- children,
7
- country
8
- }) {
5
+ async function CartLoader({ children }) {
9
6
  const cart = process.env.NODE_ENV === "development" ? null : await getCartAction().catch((error) => {
10
7
  unstable_rethrow(error);
11
8
  console.warn("[Replo] Failed to load cart:", error);
12
9
  return null;
13
10
  });
14
- return /* @__PURE__ */ jsx(CartProvider, { cart, country, children });
11
+ return /* @__PURE__ */ jsx(CartProvider, { cart, children });
15
12
  }
16
13
  export {
17
14
  CartLoader
@@ -1,4 +1,3 @@
1
- import type { StorefrontCountryCode } from "../loaders/markets";
2
1
  import type { Cart, CartLine, CartLineAdjustment, CartLinePayload } from "./cart-types";
3
2
  import React from "react";
4
3
  export type CartOperation = "add" | "update" | "remove" | "discount";
@@ -94,10 +93,9 @@ export interface CartContextType {
94
93
  *
95
94
  * @returns A context provider wrapping the children with cart functionality
96
95
  */
97
- export declare function CartProvider({ children, cart, country, }: React.PropsWithChildren<{
96
+ export declare function CartProvider({ children, cart, }: React.PropsWithChildren<{
98
97
  /** Initial cart data from the server (can be null) */
99
98
  cart: Cart | null;
100
- country?: StorefrontCountryCode;
101
99
  }>): import("react/jsx-runtime").JSX.Element;
102
100
  /**
103
101
  * @deprecated For internal use only. Use useAddToCart or useBuyNow
@@ -12,7 +12,6 @@ import {
12
12
  updateCartDiscountCodesAction,
13
13
  updateCartLineItemAction
14
14
  } from "./cart-actions";
15
- import { CartCountryContext } from "./cart-country-context";
16
15
  import {
17
16
  deriveAddToCartAdjustments,
18
17
  deriveUpdateCartAdjustments
@@ -25,27 +24,18 @@ import { CartContextError, toCartError } from "./utils/cart-error";
25
24
  import { recalculateCartCost } from "./utils/cart-utils";
26
25
  import { createOptimisticSellingPlanAllocation } from "./utils/variant-to-cart-line";
27
26
  let cartCreationPromise = null;
28
- let cartCreationCountry;
29
- function getOrCreateSharedCart(country) {
30
- if (cartCreationPromise && cartCreationCountry === country) {
31
- return cartCreationPromise;
32
- }
33
- const previousCreation = cartCreationPromise;
34
- const creation = (async () => {
35
- if (previousCreation) await previousCreation.catch(() => null);
36
- const cart = await getOrCreateCartAction({ country });
27
+ function getOrCreateSharedCart() {
28
+ cartCreationPromise ??= getOrCreateCartAction().then((cart) => {
37
29
  if (!cart) {
38
30
  throw new CartContextError({
39
31
  message: "Your cart could not be loaded. Please try again."
40
32
  });
41
33
  }
42
34
  return cart;
43
- })().finally(() => {
44
- if (cartCreationPromise === creation) cartCreationPromise = null;
35
+ }).finally(() => {
36
+ cartCreationPromise = null;
45
37
  });
46
- cartCreationCountry = country;
47
- cartCreationPromise = creation;
48
- return creation;
38
+ return cartCreationPromise;
49
39
  }
50
40
  function addLineToCart({
51
41
  cart,
@@ -94,8 +84,7 @@ const CartContext = React.createContext(
94
84
  );
95
85
  function CartProvider({
96
86
  children,
97
- cart,
98
- country
87
+ cart
99
88
  }) {
100
89
  const [cartData, setCartData] = React.useState(cart);
101
90
  const optimisticCart = React.useRef(cart);
@@ -112,10 +101,6 @@ function CartProvider({
112
101
  const [error, setError] = React.useState(null);
113
102
  const clearError = React.useCallback(() => setError(null), []);
114
103
  const isMounted = React.useRef(true);
115
- const marketSelection = React.useRef({ country });
116
- if (marketSelection.current.country !== country) {
117
- marketSelection.current = { country };
118
- }
119
104
  const runWithErrorState = async (operation, mutate) => {
120
105
  setError(null);
121
106
  try {
@@ -190,22 +175,18 @@ function CartProvider({
190
175
  });
191
176
  };
192
177
  const initializeCart = React.useCallback(async () => {
193
- const selection = marketSelection.current;
194
- const loadedCart = await getOrCreateSharedCart(country);
195
- if (!isMounted.current || marketSelection.current !== selection) {
196
- throw new DOMException(
197
- "Cart initialization was superseded",
198
- "AbortError"
199
- );
178
+ const loadedCart = await getOrCreateSharedCart();
179
+ if (!isMounted.current) {
180
+ throw new DOMException("Cart provider was unmounted", "AbortError");
200
181
  }
201
182
  serverCart.current = loadedCart;
202
183
  if (pendingMutations.current === 0) updateCartData(loadedCart);
203
184
  return loadedCart;
204
- }, [country, updateCartData]);
185
+ }, [updateCartData]);
205
186
  React.useEffect(() => {
206
187
  isMounted.current = true;
207
188
  void initializeCart().catch((error2) => {
208
- if (isMounted.current && !(error2 instanceof DOMException && error2.name === "AbortError")) {
189
+ if (isMounted.current) {
209
190
  console.error("[Replo] Error getting or creating cart:", error2);
210
191
  }
211
192
  });
@@ -419,8 +400,7 @@ function CartProvider({
419
400
  const cart2 = await createCartAction({
420
401
  lines,
421
402
  skipStoringCart: true,
422
- discountCodes,
423
- country
403
+ discountCodes
424
404
  });
425
405
  if (cart2) {
426
406
  return cart2;
@@ -432,7 +412,7 @@ function CartProvider({
432
412
  }
433
413
  };
434
414
  const checkoutUrl = cartData?.checkoutUrl ?? "/";
435
- return /* @__PURE__ */ jsx(CartCountryContext.Provider, { value: country, children: /* @__PURE__ */ jsx(
415
+ return /* @__PURE__ */ jsx(
436
416
  CartContext.Provider,
437
417
  {
438
418
  value: {
@@ -456,7 +436,7 @@ function CartProvider({
456
436
  },
457
437
  children
458
438
  }
459
- ) });
439
+ );
460
440
  }
461
441
  function useCartInternal() {
462
442
  const context = React.useContext(CartContext);
@@ -74,8 +74,5 @@ export declare const cartSchema: z.ZodObject<{
74
74
  discountedAmount: z.ZodNumber;
75
75
  title: z.ZodNullable<z.ZodString>;
76
76
  }, z.core.$strip>>>;
77
- buyerIdentity: z.ZodOptional<z.ZodObject<{
78
- country: z.ZodNullable<z.ZodString>;
79
- }, z.core.$strip>>;
80
77
  }, z.core.$strip>;
81
78
  export type Cart = z.infer<typeof cartSchema>;
@@ -66,8 +66,7 @@ const cartSchema = z.object({
66
66
  cost: cartCostSchema,
67
67
  checkoutUrl: z.string().optional(),
68
68
  discountCodes: z.array(cartDiscountCodeSchema).optional(),
69
- discountAllocations: z.array(cartDiscountAllocationSchema).optional(),
70
- buyerIdentity: z.object({ country: z.string().nullable() }).optional()
69
+ discountAllocations: z.array(cartDiscountAllocationSchema).optional()
71
70
  });
72
71
  export {
73
72
  cartSchema
@@ -3,7 +3,6 @@
3
3
  * @module
4
4
  */
5
5
  import type { SellingPlanGroup } from "../loaders/loader-schemas";
6
- import type { StorefrontCountryCode } from "../loaders/markets";
7
6
  export interface Image {
8
7
  url: string;
9
8
  altText: string | null;
@@ -119,14 +118,6 @@ export interface Cart {
119
118
  checkoutUrl?: string;
120
119
  discountCodes?: CartDiscountCode[];
121
120
  discountAllocations?: CartDiscountAllocation[];
122
- /**
123
- * The market Shopify has the cart in. Shopify prices `cost` and the checkout
124
- * from this, not from the catalog country the product loaders pass, so it is
125
- * what tells a market site whether the cart already matches the page.
126
- */
127
- buyerIdentity?: {
128
- country: string | null;
129
- };
130
121
  }
131
122
  /**
132
123
  * How a cart write differed from what the shopper asked for, derived by
@@ -166,6 +157,3 @@ export interface UpdateCartDiscountCodesPayload {
166
157
  cartId: string;
167
158
  discountCodes: string[];
168
159
  }
169
- export interface CartBuyerIdentity {
170
- country: StorefrontCountryCode;
171
- }
@@ -1,4 +1,4 @@
1
- import type { AddToCartPayload, Cart, CartBuyerIdentity, CartLinePayload, RemoveFromCartPayload, UpdateCartDiscountCodesPayload, UpdateCartLineItemPayload } from "../cart-types";
1
+ import type { AddToCartPayload, Cart, CartLinePayload, RemoveFromCartPayload, UpdateCartDiscountCodesPayload, UpdateCartLineItemPayload } from "../cart-types";
2
2
  export interface CartGateway {
3
3
  getCart(cartId: string): Promise<Cart | null>;
4
4
  /**
@@ -8,16 +8,8 @@ export interface CartGateway {
8
8
  * cart unchanged.
9
9
  */
10
10
  reconcileStoredCart(cart: Cart): Promise<Cart>;
11
- createCart(options?: {
12
- lines?: CartLinePayload[];
13
- discountCodes?: string[];
14
- buyerIdentity?: CartBuyerIdentity;
15
- }): Promise<Cart | null>;
11
+ createCart(lines?: CartLinePayload[], discountCodes?: string[]): Promise<Cart | null>;
16
12
  addToCart(cartPayload: AddToCartPayload): Promise<Cart | null>;
17
- updateCartBuyerIdentity(payload: {
18
- cartId: string;
19
- buyerIdentity: CartBuyerIdentity;
20
- }): Promise<Cart | null>;
21
13
  updateCartLineItem(cartPayload: UpdateCartLineItemPayload): Promise<Cart | null>;
22
14
  removeCartLineItems(cartPayload: RemoveFromCartPayload): Promise<Cart | null>;
23
15
  updateCartDiscountCodes(cartPayload: UpdateCartDiscountCodesPayload): Promise<Cart | null>;
@@ -1,5 +1,5 @@
1
1
  import type { ReconciledCartLine } from "../../gateways/canopy-api";
2
- import type { AddToCartPayload, Cart, CartBuyerIdentity, CartLinePayload, RemoveFromCartPayload, UpdateCartDiscountCodesPayload, UpdateCartLineItemPayload } from "../cart-types";
2
+ import type { AddToCartPayload, Cart, CartLinePayload, RemoveFromCartPayload, UpdateCartDiscountCodesPayload, UpdateCartLineItemPayload } from "../cart-types";
3
3
  import type { LineMergeFn } from "../utils/cookie-cart-persistence";
4
4
  import type { CartGateway } from "./cart-gateway";
5
5
  /**
@@ -28,18 +28,10 @@ export declare abstract class CookieBasedCartGateway implements CartGateway {
28
28
  private reconcileForWrite;
29
29
  reconcileStoredCart(cart: Cart): Promise<Cart>;
30
30
  getCart(cartId: string): Promise<Cart | null>;
31
- createCart({ lines, }?: {
32
- lines?: CartLinePayload[];
33
- discountCodes?: string[];
34
- buyerIdentity?: CartBuyerIdentity;
35
- }): Promise<Cart | null>;
31
+ createCart(lines?: CartLinePayload[], _discountCodes?: string[]): Promise<Cart | null>;
36
32
  addToCart(cartPayload: AddToCartPayload): Promise<Cart | null>;
37
33
  updateCartLineItem(cartPayload: UpdateCartLineItemPayload): Promise<Cart | null>;
38
34
  removeCartLineItems(cartPayload: RemoveFromCartPayload): Promise<Cart | null>;
39
35
  updateCartDiscountCodes(cartPayload: UpdateCartDiscountCodesPayload): Promise<Cart | null>;
40
- updateCartBuyerIdentity({ cartId, }: {
41
- cartId: string;
42
- buyerIdentity: CartBuyerIdentity;
43
- }): Promise<Cart | null>;
44
36
  }
45
37
  export {};
@@ -62,9 +62,7 @@ class CookieBasedCartGateway {
62
62
  return null;
63
63
  }
64
64
  }
65
- async createCart({
66
- lines
67
- } = {}) {
65
+ async createCart(lines, _discountCodes) {
68
66
  try {
69
67
  const cart = await createCartWithPersistence({
70
68
  cookieName: this.config.cookieName,
@@ -151,11 +149,6 @@ class CookieBasedCartGateway {
151
149
  return null;
152
150
  }
153
151
  }
154
- async updateCartBuyerIdentity({
155
- cartId
156
- }) {
157
- return this.getCart(cartId);
158
- }
159
152
  }
160
153
  export {
161
154
  CookieBasedCartGateway
@@ -8,11 +8,7 @@ class ResolverCartGateway {
8
8
  const gateway = await getCanopyApiGateway();
9
9
  return await gateway.cartGet({ cartId });
10
10
  }
11
- async createCart({
12
- lines,
13
- discountCodes,
14
- buyerIdentity
15
- } = {}) {
11
+ async createCart(lines, discountCodes) {
16
12
  try {
17
13
  const gateway = await getCanopyApiGateway();
18
14
  return await gateway.cartCreate({
@@ -25,8 +21,7 @@ class ResolverCartGateway {
25
21
  })),
26
22
  sellingPlanId: line.sellingPlanId
27
23
  })),
28
- discountCodes,
29
- country: buyerIdentity?.country
24
+ discountCodes
30
25
  });
31
26
  } catch (error) {
32
27
  console.warn("Failed to create cart via canopy-api:", error);
@@ -99,24 +94,6 @@ class ResolverCartGateway {
99
94
  return null;
100
95
  }
101
96
  }
102
- async updateCartBuyerIdentity({
103
- cartId,
104
- buyerIdentity
105
- }) {
106
- try {
107
- const gateway = await getCanopyApiGateway();
108
- return await gateway.cartUpdateBuyerIdentity({
109
- cartId,
110
- country: buyerIdentity.country
111
- });
112
- } catch (error) {
113
- console.warn(
114
- "Failed to update cart buyer identity via canopy-api:",
115
- error
116
- );
117
- return null;
118
- }
119
- }
120
97
  }
121
98
  async function createResolverCartGateway() {
122
99
  return new ResolverCartGateway();
@@ -4,7 +4,6 @@ import { useClientValue } from "../../hooks/use-client-value";
4
4
  import { CanopyError } from "../../lib/canopy-error";
5
5
  import { navigateExternal } from "../../lib/external-navigation";
6
6
  import { buyNowWithRecoveryAction } from "../buy-now-action";
7
- import { CartCountryContext } from "../cart-country-context";
8
7
  const REPLO_LOCAL_STORAGE_SESSION_KEY = "_replo_sid";
9
8
  const REPLO_SESSION_ID_KEY = "rsid";
10
9
  const REPLO_CLIENT_ID_KEY = "rclid";
@@ -14,7 +13,6 @@ class CheckoutAttemptError extends CanopyError {
14
13
  }
15
14
  const checkoutAttempts = /* @__PURE__ */ new Map();
16
15
  function useBuyNow() {
17
- const country = React.useContext(CartCountryContext);
18
16
  const reploSessionString = useClientValue(
19
17
  () => localStorage.getItem(REPLO_LOCAL_STORAGE_SESSION_KEY),
20
18
  null
@@ -27,7 +25,6 @@ function useBuyNow() {
27
25
  });
28
26
  }
29
27
  const checkoutInput = {
30
- country,
31
28
  lineItems: variants.map((variant) => ({
32
29
  variantId: variant.variantId,
33
30
  quantity: variant.quantity ?? 1,
@@ -85,7 +82,7 @@ function useBuyNow() {
85
82
  navigateExternal(url.toString());
86
83
  return { result: "redirected" };
87
84
  },
88
- [reploSessionString, country]
85
+ [reploSessionString]
89
86
  );
90
87
  return { buyNow };
91
88
  }