Skip to content

Commit fc658c0

Browse files
committed
Merge branch 'canary' into sync-integrations-makeswift
2 parents f15e9db + 4d30763 commit fc658c0

46 files changed

Lines changed: 6324 additions & 812 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ bigcommerce-graphql.d.ts
2020
coverage/
2121
.history
2222
.unlighthouse
23+
.bigcommerce

core/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ messages/*.d.json.ts
5050

5151
# Build config
5252
build-config.json
53+
54+
# OpenNext
55+
.open-next
56+
.wrangler
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client';
2+
3+
import { preconnect } from 'react-dom';
4+
5+
export function CheckoutPreconnect({ url }: { url: string }) {
6+
preconnect(url);
7+
8+
return null;
9+
}

core/app/[locale]/(default)/cart/page-data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ const CartPageQuery = graphql(
190190
`
191191
query CartPageQuery($cartId: String) {
192192
site {
193+
settings {
194+
url {
195+
checkoutUrl
196+
}
197+
}
193198
cart(entityId: $cartId) {
194199
entityId
195200
version

core/app/[locale]/(default)/cart/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { updateCouponCode } from './_actions/update-coupon-code';
1313
import { updateLineItem } from './_actions/update-line-item';
1414
import { updateShippingInfo } from './_actions/update-shipping-info';
1515
import { CartViewed } from './_components/cart-viewed';
16+
import { CheckoutPreconnect } from './_components/checkout-preconnect';
1617
import { getCart, getShippingCountries } from './page-data';
1718

1819
interface Props {
@@ -153,10 +154,13 @@ export default async function Cart({ params }: Props) {
153154
const showShippingForm =
154155
shippingConsignment?.address && !shippingConsignment.selectedShippingOption;
155156

157+
const checkoutUrl = data.site.settings?.url.checkoutUrl;
158+
156159
return (
157160
<>
158161
<Slot label="Cart top content" snapshotId="cart-top-content" />
159162
<CartAnalyticsProvider data={Streamable.from(() => getAnalyticsData(cartId))}>
163+
{checkoutUrl ? <CheckoutPreconnect url={checkoutUrl} /> : null}
160164
<CartComponent
161165
cart={{
162166
lineItems: formattedLineItems,
@@ -219,6 +223,7 @@ export default async function Cart({ params }: Props) {
219223
incrementLineItemLabel={t('increment')}
220224
key={`${cart.entityId}-${cart.version}`}
221225
lineItemAction={updateLineItem}
226+
lineItemActionPendingLabel={t('cartUpdateInProgress')}
222227
shipping={{
223228
action: updateShippingInfo,
224229
countries,

core/auth/anonymous-session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const anonymousSignIn = async (user: Partial<AnonymousUser> = { cartId: n
2929
});
3030

3131
cookieJar.set(`${cookiePrefix}${anonymousCookieName}`, jwt, {
32-
secure: true,
32+
secure: useSecureCookies,
3333
sameSite: 'lax',
3434
// We set the maxAge to 7 days as a good default for anonymous sessions.
3535
// This can be adjusted based on your application's needs.
@@ -70,7 +70,7 @@ export const clearAnonymousSession = async () => {
7070

7171
cookieJar.delete({
7272
name: `${cookiePrefix}${anonymousCookieName}`,
73-
secure: true,
73+
secure: useSecureCookies,
7474
sameSite: 'lax',
7575
httpOnly: true,
7676
});

core/lib/kv/adapters/bc.ts

Lines changed: 0 additions & 101 deletions
This file was deleted.

core/lib/kv/adapters/upstash.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@ import { Redis } from '@upstash/redis';
22

33
import { KvAdapter, SetCommandOptions } from '../types';
44

5-
import { MemoryKvAdapter } from './memory';
6-
7-
const memoryKv = new MemoryKvAdapter();
8-
95
export class UpstashKvAdapter implements KvAdapter {
106
private upstashKv = Redis.fromEnv();
11-
private memoryKv = memoryKv;
127

138
async mget<Data>(...keys: string[]) {
14-
const memoryValues = await this.memoryKv.mget<Data>(...keys);
15-
16-
return memoryValues.length ? memoryValues : this.upstashKv.mget<Data[]>(keys);
9+
return this.upstashKv.mget<Data[]>(keys);
1710
}
1811

1912
async set<Data>(key: string, value: Data, opts?: SetCommandOptions) {
20-
await this.memoryKv.set(key, value, opts);
21-
2213
const response = await this.upstashKv.set(key, value, opts);
2314

2415
if (response === 'OK') {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { getCache } from '@vercel/functions';
2+
3+
import { KvAdapter, SetCommandOptions } from '../types';
4+
5+
export class RuntimeCacheAdapter implements KvAdapter {
6+
private cache = getCache();
7+
8+
async mget<Data>(...keys: string[]): Promise<Array<Data | null>> {
9+
this.logger(
10+
`MGET - Keys: ${keys.toString()} - Source: RUNTIME_CACHE - Fetching ${keys.length} keys`,
11+
);
12+
13+
try {
14+
const values = await Promise.all(
15+
keys.map(async (key) => {
16+
try {
17+
// Use the Runtime Cache API
18+
const cachedValue = await this.cache.get(key);
19+
20+
if (cachedValue !== null) {
21+
this.logger(`RUNTIME_CACHE GET - Key: ${key} - Found: true`);
22+
23+
return cachedValue;
24+
}
25+
26+
this.logger(`RUNTIME_CACHE GET - Key: ${key} - Found: false`);
27+
28+
return null;
29+
} catch (error) {
30+
this.logger(
31+
`RUNTIME_CACHE GET ERROR - Key: ${key} - Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
32+
);
33+
34+
return null;
35+
}
36+
}),
37+
);
38+
39+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
40+
return values as Array<Data | null>;
41+
} catch (error) {
42+
this.logger(
43+
`RUNTIME_CACHE ACCESS ERROR - Returning null values: ${error instanceof Error ? error.message : 'Unknown error'}`,
44+
);
45+
46+
// Return null for all keys if Runtime Cache is unavailable
47+
return keys.map(() => null);
48+
}
49+
}
50+
51+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
52+
async set<Data>(key: string, value: Data, _opts?: SetCommandOptions): Promise<Data | null> {
53+
this.logger(`SET - Key: ${key} - Setting in runtime cache`);
54+
55+
try {
56+
await this.cache.set(key, value);
57+
this.logger(`RUNTIME_CACHE SET - Key: ${key} - Success`);
58+
} catch (error) {
59+
this.logger(
60+
`RUNTIME_CACHE SET ERROR - Key: ${key} - Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
61+
);
62+
}
63+
64+
return value;
65+
}
66+
67+
private logger(message: string) {
68+
// Check if logging is enabled using the same logic as the main KV class
69+
const loggingEnabled =
70+
(process.env.NODE_ENV !== 'production' && process.env.KV_LOGGER !== 'false') ||
71+
process.env.KV_LOGGER === 'true';
72+
73+
if (loggingEnabled) {
74+
// eslint-disable-next-line no-console
75+
console.log(`[BigCommerce] Runtime Cache ${message}`);
76+
}
77+
}
78+
}

core/lib/kv/adapters/vercel.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)