@replohq/sdk 2.4.0 → 2.5.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.
- package/_vendor/replo-utils/lib/crypto.d.ts +1 -0
- package/_vendor/schemas/moneyFormat.mjs +1 -1
- package/_vendor/schemas/routing/locale.mjs +1 -1
- package/_vendor/schemas/routing/rules.mjs +1 -1
- package/cart/cart-actions.js +21 -1
- package/cart/utils/shopify-shared-cart.d.ts +9 -0
- package/cart/utils/shopify-shared-cart.js +33 -0
- package/lib/buildMetadata.js +3 -3
- package/package.json +4 -4
- /package/{chunk-CKRRL66R.mjs → chunk-AE5H7AJS.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../../../chunk-XSMYSAKY.mjs';
|
|
2
|
-
import { ReploError } from '../../../chunk-
|
|
2
|
+
import { ReploError } from '../../../chunk-AE5H7AJS.mjs';
|
|
3
3
|
import '../../../chunk-XGXJOHUY.mjs';
|
|
4
4
|
import '../../../chunk-XWWFRIXV.mjs';
|
|
5
5
|
import '../../../chunk-OPKMOW43.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getParamSegment, getRouteParams, hasRouteParam, matchSource } from '../../../chunk-VPEVERWE.mjs';
|
|
2
2
|
import '../../../chunk-XSMYSAKY.mjs';
|
|
3
|
-
import { ReploError } from '../../../chunk-
|
|
3
|
+
import { ReploError } from '../../../chunk-AE5H7AJS.mjs';
|
|
4
4
|
import '../../../chunk-XGXJOHUY.mjs';
|
|
5
5
|
import '../../../chunk-XWWFRIXV.mjs';
|
|
6
6
|
import '../../../chunk-OPKMOW43.mjs';
|
package/cart/cart-actions.js
CHANGED
|
@@ -10,6 +10,11 @@ import {
|
|
|
10
10
|
loadCartFromCookie,
|
|
11
11
|
saveCartToCookie
|
|
12
12
|
} from "./utils/cookie-cart-persistence";
|
|
13
|
+
import {
|
|
14
|
+
SHARED_SHOPIFY_CART_COOKIE_NAME,
|
|
15
|
+
SHOPIFY_CART_ID_PREFIX,
|
|
16
|
+
shareShopifyCart
|
|
17
|
+
} from "./utils/shopify-shared-cart";
|
|
13
18
|
const SHOPIFY_CART_COOKIE_NAME = "replo_cart_id";
|
|
14
19
|
async function reconcileExistingCart(cart, country) {
|
|
15
20
|
const cartGateway = await getCartGateway();
|
|
@@ -42,11 +47,20 @@ async function getCartAction() {
|
|
|
42
47
|
return await loadCartFromCookie(REPLO_CART_COOKIE_NAME);
|
|
43
48
|
}
|
|
44
49
|
const cookieStore = await cookies();
|
|
50
|
+
const cartGateway = await getCartGateway();
|
|
51
|
+
const sharedToken = checkoutProvider === "shopify" ? cookieStore.get(SHARED_SHOPIFY_CART_COOKIE_NAME)?.value : void 0;
|
|
52
|
+
if (sharedToken) {
|
|
53
|
+
const sharedCart = await cartGateway.getCart(
|
|
54
|
+
`${SHOPIFY_CART_ID_PREFIX}${sharedToken}`
|
|
55
|
+
);
|
|
56
|
+
if (sharedCart) {
|
|
57
|
+
return sharedCart;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
45
60
|
const existingCartId = cookieStore.get(SHOPIFY_CART_COOKIE_NAME)?.value;
|
|
46
61
|
if (!existingCartId) {
|
|
47
62
|
return null;
|
|
48
63
|
}
|
|
49
|
-
const cartGateway = await getCartGateway();
|
|
50
64
|
const cart = await cartGateway.getCart(existingCartId);
|
|
51
65
|
if (!cart) {
|
|
52
66
|
try {
|
|
@@ -58,6 +72,9 @@ async function getCartAction() {
|
|
|
58
72
|
console.warn("Failed to delete cart cookie:", error);
|
|
59
73
|
}
|
|
60
74
|
}
|
|
75
|
+
if (cart && checkoutProvider === "shopify") {
|
|
76
|
+
await shareShopifyCart(cart);
|
|
77
|
+
}
|
|
61
78
|
return cart;
|
|
62
79
|
}
|
|
63
80
|
async function createCartAction(options) {
|
|
@@ -87,6 +104,9 @@ async function createCartAction(options) {
|
|
|
87
104
|
cart.id,
|
|
88
105
|
getCartCookieOptions()
|
|
89
106
|
);
|
|
107
|
+
if (checkoutProvider === "shopify") {
|
|
108
|
+
await shareShopifyCart(cart);
|
|
109
|
+
}
|
|
90
110
|
}
|
|
91
111
|
} catch (cookieError) {
|
|
92
112
|
console.warn("Failed to set cart cookie:", cookieError);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Cart } from "../cart-types";
|
|
2
|
+
export declare const SHARED_SHOPIFY_CART_COOKIE_NAME = "replo_shared_cart";
|
|
3
|
+
export declare const SHOPIFY_CART_ID_PREFIX = "gid://shopify/Cart/";
|
|
4
|
+
/**
|
|
5
|
+
* Shopify reports the store's primary domain as the checkout URL host, so a
|
|
6
|
+
* site served from a subdomain of it (shop.brand.com next to brand.com) can
|
|
7
|
+
* share its cart with the theme without any per-site configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shareShopifyCart(cart: Cart): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cookies, headers } from "next/headers";
|
|
2
|
+
const SHARED_SHOPIFY_CART_COOKIE_NAME = "replo_shared_cart";
|
|
3
|
+
const SHOPIFY_CART_ID_PREFIX = "gid://shopify/Cart/";
|
|
4
|
+
async function shareShopifyCart(cart) {
|
|
5
|
+
if (process.env.IS_REPLO_SANDBOX || !cart.id.startsWith(SHOPIFY_CART_ID_PREFIX) || !cart.checkoutUrl || !URL.canParse(cart.checkoutUrl)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const domain = new URL(cart.checkoutUrl).hostname.toLowerCase().replace(/^www\./, "");
|
|
9
|
+
const host = (await headers()).get("host")?.toLowerCase().split(":")[0];
|
|
10
|
+
if (!host?.endsWith(`.${domain}`)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
(await cookies()).set(
|
|
15
|
+
SHARED_SHOPIFY_CART_COOKIE_NAME,
|
|
16
|
+
cart.id.slice(SHOPIFY_CART_ID_PREFIX.length),
|
|
17
|
+
{
|
|
18
|
+
domain: `.${domain}`,
|
|
19
|
+
path: "/",
|
|
20
|
+
secure: true,
|
|
21
|
+
httpOnly: false,
|
|
22
|
+
sameSite: "lax",
|
|
23
|
+
maxAge: 60 * 60 * 24 * 30
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
SHARED_SHOPIFY_CART_COOKIE_NAME,
|
|
31
|
+
SHOPIFY_CART_ID_PREFIX,
|
|
32
|
+
shareShopifyCart
|
|
33
|
+
};
|
package/lib/buildMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const BUILD_METADATA = {
|
|
2
2
|
"packageName": "@replohq/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"branch": "HEAD",
|
|
5
|
-
"commit": "
|
|
6
|
-
"builtAt": "2026-10-
|
|
5
|
+
"commit": "f408d4d2ca21640258e7b9a8d20c5a92515cf9d6",
|
|
6
|
+
"builtAt": "2026-10-22T19:30:37.074Z"
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"reploBuild": {
|
|
5
5
|
"packageName": "@replohq/sdk",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.5.0",
|
|
7
7
|
"branch": "HEAD",
|
|
8
|
-
"commit": "
|
|
9
|
-
"builtAt": "2026-10-
|
|
8
|
+
"commit": "f408d4d2ca21640258e7b9a8d20c5a92515cf9d6",
|
|
9
|
+
"builtAt": "2026-10-22T19:30:37.074Z"
|
|
10
10
|
},
|
|
11
11
|
"description": "Replo SDK — cart, analytics, and data loaders for agent-built Next.js sites.",
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE",
|
|
File without changes
|