Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
feat: Add SDK retry logic, Zod schemas, and @spree/next package
Damian Legawiec59ba2992547b
diff --git a/packages/next/dist/actions/addresses.d.ts b/packages/next/dist/actions/addresses.d.tsnew file mode 100644index 0000000000..bd8228d11f--- /dev/null+++ b/packages/next/dist/actions/addresses.d.ts@@ -0,0 +1,26 @@+import { AddressParams, StoreAddress } from '@spree/sdk';++/**+ * List the authenticated customer's addresses.+ */+declare function listAddresses(): Promise<{+ data: StoreAddress[];+}>;+/**+ * Get a single address by ID.+ */+declare function getAddress(id: string): Promise<StoreAddress>;+/**+ * Create a new address for the customer.+ */+declare function createAddress(params: AddressParams): Promise<StoreAddress>;+/**+ * Update an existing address.+ */+declare function updateAddress(id: string, params: Partial<AddressParams>): Promise<StoreAddress>;+/**+ * Delete an address.+ */+declare function deleteAddress(id: string): Promise<void>;++export { createAddress, deleteAddress, getAddress, listAddresses, updateAddress };diff --git a/packages/next/dist/actions/addresses.js b/packages/next/dist/actions/addresses.jsnew file mode 100644index 0000000000..195b133155--- /dev/null+++ b/packages/next/dist/actions/addresses.js@@ -0,0 +1,157 @@+"use server";++// src/actions/addresses.ts+import { revalidateTag } from "next/cache";++// src/auth-helpers.ts+import { SpreeError } from "@spree/sdk";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/auth-helpers.ts+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/addresses.ts+async function listAddresses() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.list(void 0, options);+ });+}+async function getAddress(id) {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.get(id, options);+ });+}+async function createAddress(params) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.create(params, options);+ });+ revalidateTag("addresses");+ return result;+}+async function updateAddress(id, params) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.update(id, params, options);+ });+ revalidateTag("addresses");+ return result;+}+async function deleteAddress(id) {+ await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.delete(id, options);+ });+ revalidateTag("addresses");+}+export {+ createAddress,+ deleteAddress,+ getAddress,+ listAddresses,+ updateAddress+};+//# sourceMappingURL=addresses.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/addresses.js.map b/packages/next/dist/actions/addresses.js.mapnew file mode 100644index 0000000000..70632865e2--- /dev/null+++ b/packages/next/dist/actions/addresses.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/actions/addresses.ts","../../src/auth-helpers.ts","../../src/config.ts","../../src/cookies.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreAddress, AddressParams } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's addresses.\n */\nexport async function listAddresses(): Promise<{ data: StoreAddress[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.addresses.list(undefined, options);\n });\n}\n\n/**\n * Get a single address by ID.\n */\nexport async function getAddress(id: string): Promise<StoreAddress> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.addresses.get(id, options);\n });\n}\n\n/**\n * Create a new address for the customer.\n */\nexport async function createAddress(params: AddressParams): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.create(params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Update an existing address.\n */\nexport async function updateAddress(\n id: string,\n params: Partial<AddressParams>\n): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.update(id, params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Delete an address.\n */\nexport async function deleteAddress(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.delete(id, options);\n });\n revalidateTag('addresses');\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n"],"mappings":";;;AAEA,SAAS,qBAAqB;;;ACF9B,SAAS,kBAAkB;;;ACA3B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,QAAQ;AACrB,oBA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AsB,cACpB,IACA,QACuB;AACvB,QAAM,SAAS,MAAM,gBAAgB,OAAO,YAAY;AACtD,WAAO,UAAU,EAAE,SAAS,UAAU,OAAO,IAAI,QAAQ,OAAO;AAAA,EAClE,CAAC;AACD,gBAAc,WAAW;AACzB,SAAO;AACT;AAKA,eAAsB,cAAc,IAA2B;AAC7D,QAAM,gBAAgB,OAAO,YAAY;AACvC,WAAO,UAAU,EAAE,SAAS,UAAU,OAAO,IAAI,OAAO;AAAA,EAC1D,CAAC;AACD,gBAAc,WAAW;AAC3B;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/actions/auth.d.ts b/packages/next/dist/actions/auth.d.tsnew file mode 100644index 0000000000..5870068154--- /dev/null+++ b/packages/next/dist/actions/auth.d.ts@@ -0,0 +1,48 @@+import { StoreUser } from '@spree/sdk';++/**+ * Login with email and password.+ * Automatically associates any guest cart with the authenticated user.+ */+declare function login(email: string, password: string): Promise<{+ success: boolean;+ user?: {+ id: string;+ email: string;+ first_name?: string | null;+ last_name?: string | null;+ };+ error?: string;+}>;+/**+ * Register a new customer account.+ * Automatically associates any guest cart with the new account.+ */+declare function register(email: string, password: string, passwordConfirmation: string): Promise<{+ success: boolean;+ user?: {+ id: string;+ email: string;+ first_name?: string | null;+ last_name?: string | null;+ };+ error?: string;+}>;+/**+ * Logout the current user.+ */+declare function logout(): Promise<void>;+/**+ * Get the currently authenticated customer. Returns null if not logged in.+ */+declare function getCustomer(): Promise<StoreUser | null>;+/**+ * Update the current customer's profile.+ */+declare function updateCustomer(data: {+ first_name?: string;+ last_name?: string;+ email?: string;+}): Promise<StoreUser>;++export { getCustomer, login, logout, register, updateCustomer };diff --git a/packages/next/dist/actions/auth.js b/packages/next/dist/actions/auth.jsnew file mode 100644index 0000000000..b042f9c26e--- /dev/null+++ b/packages/next/dist/actions/auth.js@@ -0,0 +1,215 @@+"use server";++// src/actions/auth.ts+import { revalidateTag } from "next/cache";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_CART_COOKIE = "_spree_cart_token";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getCartCookieName() {+ try {+ return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;+ } catch {+ return DEFAULT_CART_COOKIE;+ }+}+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getCartToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getCartCookieName())?.value;+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/auth-helpers.ts+import { SpreeError } from "@spree/sdk";+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/auth.ts+async function login(email, password) {+ try {+ const result = await getClient().auth.login({ email, password });+ await setAccessToken(result.token);+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken+ });+ } catch {+ }+ }+ revalidateTag("customer");+ revalidateTag("cart");+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : "Invalid email or password"+ };+ }+}+async function register(email, password, passwordConfirmation) {+ try {+ const result = await getClient().auth.register({+ email,+ password,+ password_confirmation: passwordConfirmation+ });+ await setAccessToken(result.token);+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken+ });+ } catch {+ }+ }+ revalidateTag("customer");+ revalidateTag("cart");+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : "Registration failed"+ };+ }+}+async function logout() {+ await clearAccessToken();+ revalidateTag("customer");+ revalidateTag("cart");+ revalidateTag("addresses");+ revalidateTag("credit-cards");+}+async function getCustomer() {+ const token = await getAccessToken();+ if (!token) return null;+ try {+ return await withAuthRefresh(async (options) => {+ return getClient().customer.get(options);+ });+ } catch {+ await clearAccessToken();+ return null;+ }+}+async function updateCustomer(data) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.update(data, options);+ });+ revalidateTag("customer");+ return result;+}+export {+ getCustomer,+ login,+ logout,+ register,+ updateCustomer+};+//# sourceMappingURL=auth.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/auth.js.map b/packages/next/dist/actions/auth.js.mapnew file mode 100644index 0000000000..ce5af76323--- /dev/null+++ b/packages/next/dist/actions/auth.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/actions/auth.ts","../../src/config.ts","../../src/cookies.ts","../../src/auth-helpers.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreUser } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { setAccessToken, clearAccessToken, getAccessToken, getCartToken } from '../cookies';\nimport { withAuthRefresh } from '../auth-helpers';\n\n/**\n * Login with email and password.\n * Automatically associates any guest cart with the authenticated user.\n */\nexport async function login(\n email: string,\n password: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().auth.login({ email, password });\n await setAccessToken(result.token);\n\n // Associate guest cart if one exists\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Cart association failure is non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Invalid email or password',\n };\n }\n}\n\n/**\n * Register a new customer account.\n * Automatically associates any guest cart with the new account.\n */\nexport async function register(\n email: string,\n password: string,\n passwordConfirmation: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().auth.register({\n email,\n password,\n password_confirmation: passwordConfirmation,\n });\n await setAccessToken(result.token);\n\n // Associate guest cart\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Registration failed',\n };\n }\n}\n\n/**\n * Logout the current user.\n */\nexport async function logout(): Promise<void> {\n await clearAccessToken();\n revalidateTag('customer');\n revalidateTag('cart');\n revalidateTag('addresses');\n revalidateTag('credit-cards');\n}\n\n/**\n * Get the currently authenticated customer. Returns null if not logged in.\n */\nexport async function getCustomer(): Promise<StoreUser | null> {\n const token = await getAccessToken();\n if (!token) return null;\n\n try {\n return await withAuthRefresh(async (options) => {\n return getClient().customer.get(options);\n });\n } catch {\n await clearAccessToken();\n return null;\n }\n}\n\n/**\n * Update the current customer's profile.\n */\nexport async function updateCustomer(\n data: { first_name?: string; last_name?: string; email?: string }\n): Promise<StoreUser> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.update(data, options);\n });\n revalidateTag('customer');\n return result;\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n"],"mappings":";;;AAEA,SAAS,qBAAqB;;;ACF9B,SAAS,yBAA2C;A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AAA,IAClD;AAAA,EACF;AACF;AAKA,eAAsB,SAAwB;AAC5C,QAAM,iBAAiB;AACvB,gBAAc,UAAU;AACxB,gBAAc,MAAM;AACpB,gBAAc,WAAW;AACzB,gBAAc,cAAc;AAC9B;AAKA,eAAsB,cAAyC;AAC7D,QAAM,QAAQ,MAAM,eAAe;AACnC,MAAI,CAAC,MAAO,QAAO;AAEnB,MAAI;AACF,WAAO,MAAM,gBAAgB,OAAO,YAAY;AAC9C,aAAO,UAAU,EAAE,SAAS,IAAI,OAAO;AAAA,IACzC,CAAC;AAAA,EACH,QAAQ;AACN,UAAM,iBAAiB;AACvB,WAAO;AAAA,EACT;AACF;AAKA,eAAsB,eACpB,MACoB;AACpB,QAAM,SAAS,MAAM,gBAAgB,OAAO,YAAY;AACtD,WAAO,UAAU,EAAE,SAAS,OAAO,MAAM,OAAO;AAAA,EAClD,CAAC;AACD,gBAAc,UAAU;AACxB,SAAO;AACT;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/actions/cart.d.ts b/packages/next/dist/actions/cart.d.tsnew file mode 100644index 0000000000..b6d47fb77c--- /dev/null+++ b/packages/next/dist/actions/cart.d.ts@@ -0,0 +1,39 @@+import { StoreLineItem, StoreOrder } from '@spree/sdk';++/**+ * Get the current cart. Returns null if no cart exists.+ */+declare function getCart(): Promise<(StoreOrder & {+ token: string;+}) | null>;+/**+ * Get existing cart or create a new one.+ */+declare function getOrCreateCart(): Promise<StoreOrder & {+ token: string;+}>;+/**+ * Add an item to the cart. Creates a cart if none exists.+ */+declare function addItem(variantId: string, quantity?: number): Promise<StoreLineItem>;+/**+ * Update a line item quantity in the cart.+ */+declare function updateItem(lineItemId: string, quantity: number): Promise<StoreLineItem>;+/**+ * Remove a line item from the cart.+ */+declare function removeItem(lineItemId: string): Promise<void>;+/**+ * Clear the cart (abandons the current cart).+ */+declare function clearCart(): Promise<void>;+/**+ * Associate a guest cart with the currently authenticated user.+ * Call this after login/register when the user has an existing guest cart.+ */+declare function associateCart(): Promise<(StoreOrder & {+ token: string;+}) | null>;++export { addItem, associateCart, clearCart, getCart, getOrCreateCart, removeItem, updateItem };diff --git a/packages/next/dist/actions/cart.js b/packages/next/dist/actions/cart.jsnew file mode 100644index 0000000000..6d44fd655f--- /dev/null+++ b/packages/next/dist/actions/cart.js@@ -0,0 +1,170 @@+"use server";++// src/actions/cart.ts+import { revalidateTag } from "next/cache";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_CART_COOKIE = "_spree_cart_token";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getCartCookieName() {+ try {+ return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;+ } catch {+ return DEFAULT_CART_COOKIE;+ }+}+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getCartToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getCartCookieName())?.value;+}+async function setCartToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: CART_TOKEN_MAX_AGE+ });+}+async function clearCartToken() {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}++// src/actions/cart.ts+async function getCart() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) return null;+ try {+ return await getClient().cart.get({ orderToken, token });+ } catch {+ return null;+ }+}+async function getOrCreateCart() {+ const existing = await getCart();+ if (existing) return existing;+ const token = await getAccessToken();+ const cart = await getClient().cart.create(token ? { token } : void 0);+ if (cart.token) {+ await setCartToken(cart.token);+ }+ revalidateTag("cart");+ return cart;+}+async function addItem(variantId, quantity = 1) {+ const cart = await getOrCreateCart();+ const orderToken = cart.token;+ const token = await getAccessToken();+ const lineItem = await getClient().orders.lineItems.create(+ cart.id,+ { variant_id: variantId, quantity },+ { orderToken, token }+ );+ revalidateTag("cart");+ return lineItem;+}+async function updateItem(lineItemId, quantity) {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error("No cart found");+ const cart = await getClient().cart.get({ orderToken, token });+ const lineItem = await getClient().orders.lineItems.update(+ cart.id,+ lineItemId,+ { quantity },+ { orderToken, token }+ );+ revalidateTag("cart");+ return lineItem;+}+async function removeItem(lineItemId) {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error("No cart found");+ const cart = await getClient().cart.get({ orderToken, token });+ await getClient().orders.lineItems.delete(cart.id, lineItemId, {+ orderToken,+ token+ });+ revalidateTag("cart");+}+async function clearCart() {+ await clearCartToken();+ revalidateTag("cart");+}+async function associateCart() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken || !token) return null;+ try {+ const result = await getClient().cart.associate({ orderToken, token });+ revalidateTag("cart");+ return result;+ } catch {+ await clearCartToken();+ revalidateTag("cart");+ return null;+ }+}+export {+ addItem,+ associateCart,+ clearCart,+ getCart,+ getOrCreateCart,+ removeItem,+ updateItem+};+//# sourceMappingURL=cart.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/cart.js.map b/packages/next/dist/actions/cart.js.mapnew file mode 100644index 0000000000..66210a78bf--- /dev/null+++ b/packages/next/dist/actions/cart.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/actions/cart.ts","../../src/config.ts","../../src/cookies.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreLineItem } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, setCartToken, clearCartToken, getAccessToken } from '../cookies';\n\n/**\n * Get the current cart. Returns null if no cart exists.\n */\nexport async function getCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) return null;\n\n try {\n return await getClient().cart.get({ orderToken, token });\n } catch {\n return null;\n }\n}\n\n/**\n * Get existing cart or create a new one.\n */\nexport async function getOrCreateCart(): Promise<StoreOrder & { token: string }> {\n const existing = await getCart();\n if (existing) return existing;\n\n const token = await getAccessToken();\n const cart = await getClient().cart.create(token ? { token } : undefined);\n\n if (cart.token) {\n await setCartToken(cart.token);\n }\n\n revalidateTag('cart');\n return cart;\n}\n\n/**\n * Add an item to the cart. Creates a cart if none exists.\n */\nexport async function addItem(\n variantId: string,\n quantity: number = 1\n): Promise<StoreLineItem> {\n const cart = await getOrCreateCart();\n const orderToken = cart.token;\n const token = await getAccessToken();\n\n const lineItem = await getClient().orders.lineItems.create(\n cart.id,\n { variant_id: variantId, quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return lineItem;\n}\n\n/**\n * Update a line item quantity in the cart.\n */\nexport async function updateItem(\n lineItemId: string,\n quantity: number\n): Promise<StoreLineItem> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().cart.get({ orderToken, token });\n\n const lineItem = await getClient().orders.lineItems.update(\n cart.id,\n lineItemId,\n { quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return lineItem;\n}\n\n/**\n * Remove a line item from the cart.\n */\nexport async function removeItem(lineItemId: string): Promise<void> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().cart.get({ orderToken, token });\n\n await getClient().orders.lineItems.delete(cart.id, lineItemId, {\n orderToken,\n token,\n });\n\n revalidateTag('cart');\n}\n\n/**\n * Clear the cart (abandons the current cart).\n */\nexport async function clearCart(): Promise<void> {\n await clearCartToken();\n revalidateTag('cart');\n}\n\n/**\n * Associate a guest cart with the currently authenticated user.\n * Call this after login/register when the user has an existing guest cart.\n */\nexport async function associateCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken || !token) return null;\n\n try {\n const result = await getClient().cart.associate({ orderToken, token });\n revalidateTag('cart');\n return result;\n } catch {\n // Cart might already belong to another user — clear it\n await clearCartToken();\n revalidateTag('cart');\n return null;\n }\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n"],"mappings":";;;AAEA,SAAS,qBAAqB;;;ACF9B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,QAAQ;AACrB,oBAAc,EAAE,SAAS,OAAO,CAAC;AAAA,IACnC,OAAO;AACL,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,YAA6B;AAC3C,MAAI,CAAC,SAAS;AACZ,cAAU;AAAA,EACZ;AACA,SAAO;AACT;;;AC/CA,SAAS,eAAe;AAGxB,IAAM,sBAAsB;AAC5B,IAAM,8BAA8B;AACpC,IAAM,qBAAqB,KAAK,KAAK,KAAK;AAC1C,IAAM,uBAAuB,KAAK,KAAK,KAAK;AAE5C,SAAS,oBAA4B;AACnC,MAAI;AACF,WAAO,UAAU,EAAE,kBAAkB;AAAA,EACvC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,2BAAmC;AAC1C,MAAI;AACF,WAAO,UAAU,EAAE,yBAAyB;AAAA,EAC9C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,eAAsB,eAA4C;AAChE,QAAM,cAAc,MAAM,QAAQ;AAClC,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;AACrB,kBAAc,MAAM;AACpB,WAAO;AAAA,EACT;AACF;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/actions/checkout.d.ts b/packages/next/dist/actions/checkout.d.tsnew file mode 100644index 0000000000..6bd9354743--- /dev/null+++ b/packages/next/dist/actions/checkout.d.ts@@ -0,0 +1,48 @@+import { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';++/**+ * Get the current checkout order state.+ */+declare function getCheckout(orderId: string): Promise<StoreOrder>;+/**+ * Update shipping and/or billing addresses on the order.+ */+declare function updateAddresses(orderId: string, params: {+ email?: string;+ ship_address?: AddressParams;+ bill_address?: AddressParams;+ ship_address_id?: string;+ bill_address_id?: string;+}): Promise<StoreOrder>;+/**+ * Advance the checkout to the next step.+ */+declare function advance(orderId: string): Promise<StoreOrder>;+/**+ * Move the checkout to the next step (alias for advance).+ */+declare function next(orderId: string): Promise<StoreOrder>;+/**+ * Get shipments for the order (includes available shipping rates).+ */+declare function getShipments(orderId: string): Promise<{+ data: StoreShipment[];+}>;+/**+ * Select a shipping rate for a shipment.+ */+declare function selectShippingRate(orderId: string, shipmentId: string, shippingRateId: string): Promise<StoreShipment>;+/**+ * Apply a coupon code to the order.+ */+declare function applyCoupon(orderId: string, code: string): Promise<StoreOrder>;+/**+ * Remove a coupon/promotion from the order.+ */+declare function removeCoupon(orderId: string, promotionId: string): Promise<StoreOrder>;+/**+ * Complete the checkout and place the order.+ */+declare function complete(orderId: string): Promise<StoreOrder>;++export { advance, applyCoupon, complete, getCheckout, getShipments, next, removeCoupon, selectShippingRate, updateAddresses };diff --git a/packages/next/dist/actions/checkout.js b/packages/next/dist/actions/checkout.jsnew file mode 100644index 0000000000..4c57bc6fe9--- /dev/null+++ b/packages/next/dist/actions/checkout.js@@ -0,0 +1,142 @@+"use server";++// src/actions/checkout.ts+import { revalidateTag } from "next/cache";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_CART_COOKIE = "_spree_cart_token";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getCartCookieName() {+ try {+ return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;+ } catch {+ return DEFAULT_CART_COOKIE;+ }+}+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getCartToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getCartCookieName())?.value;+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}++// src/actions/checkout.ts+async function getCheckoutOptions() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ return { orderToken, token };+}+async function getCheckout(orderId) {+ const options = await getCheckoutOptions();+ return getClient().orders.get(orderId, void 0, options);+}+async function updateAddresses(orderId, params) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.update(orderId, params, options);+ revalidateTag("checkout");+ return result;+}+async function advance(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.advance(orderId, options);+ revalidateTag("checkout");+ return result;+}+async function next(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.next(orderId, options);+ revalidateTag("checkout");+ return result;+}+async function getShipments(orderId) {+ const options = await getCheckoutOptions();+ return getClient().orders.shipments.list(orderId, options);+}+async function selectShippingRate(orderId, shipmentId, shippingRateId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.shipments.update(+ orderId,+ shipmentId,+ { selected_shipping_rate_id: shippingRateId },+ options+ );+ revalidateTag("checkout");+ return result;+}+async function applyCoupon(orderId, code) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.apply(orderId, code, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+async function removeCoupon(orderId, promotionId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+async function complete(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.complete(orderId, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+export {+ advance,+ applyCoupon,+ complete,+ getCheckout,+ getShipments,+ next,+ removeCoupon,+ selectShippingRate,+ updateAddresses+};+//# sourceMappingURL=checkout.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/checkout.js.map b/packages/next/dist/actions/checkout.js.mapnew file mode 100644index 0000000000..f054f71dc3--- /dev/null+++ b/packages/next/dist/actions/checkout.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/actions/checkout.ts","../../src/config.ts","../../src/cookies.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Get the current checkout order state.\n */\nexport async function getCheckout(\n orderId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n return getClient().orders.get(orderId, undefined, options);\n}\n\n/**\n * Update shipping and/or billing addresses on the order.\n */\nexport async function updateAddresses(\n orderId: string,\n params: {\n email?: string;\n ship_address?: AddressParams;\n bill_address?: AddressParams;\n ship_address_id?: string;\n bill_address_id?: string;\n }\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.update(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Advance the checkout to the next step.\n */\nexport async function advance(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.advance(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Move the checkout to the next step (alias for advance).\n */\nexport async function next(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.next(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get shipments for the order (includes available shipping rates).\n */\nexport async function getShipments(\n orderId: string\n): Promise<{ data: StoreShipment[] }> {\n const options = await getCheckoutOptions();\n return getClient().orders.shipments.list(orderId, options);\n}\n\n/**\n * Select a shipping rate for a shipment.\n */\nexport async function selectShippingRate(\n orderId: string,\n shipmentId: string,\n shippingRateId: string\n): Promise<StoreShipment> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.shipments.update(\n orderId,\n shipmentId,\n { selected_shipping_rate_id: shippingRateId },\n options\n );\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Apply a coupon code to the order.\n */\nexport async function applyCoupon(\n orderId: string,\n code: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.couponCodes.apply(orderId, code, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Remove a coupon/promotion from the order.\n */\nexport async function removeCoupon(\n orderId: string,\n promotionId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Complete the checkout and place the order.\n */\nexport async function complete(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.complete(orderId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n"],"mappings":";;;AAEA,SAAS,qBAAqB;;;ACF9B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,QAAQ;AACrB,o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UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,QAAQ,SAAS,OAAO;AAChE,gBAAc,UAAU;AACxB,SAAO;AACT;AAKA,eAAsB,KAAK,SAAsC;AAC/D,QAAM,UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,KAAK,SAAS,OAAO;AAC7D,gBAAc,UAAU;AACxB,SAAO;AACT;AAKA,eAAsB,aACpB,SACoC;AACpC,QAAM,UAAU,MAAM,mBAAmB;AACzC,SAAO,UAAU,EAAE,OAAO,UAAU,KAAK,SAAS,OAAO;AAC3D;AAKA,eAAsB,mBACpB,SACA,YACA,gBACwB;AACxB,QAAM,UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,UAAU;AAAA,IAChD;AAAA,IACA;AAAA,IACA,EAAE,2BAA2B,eAAe;AAAA,IAC5C;AAAA,EACF;AACA,gBAAc,UAAU;AACxB,SAAO;AACT;AAKA,eAAsB,YACpB,SACA,MACqB;AACrB,QAAM,UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,YAAY,MAAM,SAAS,MAAM,OAAO;AAChF,gBAAc,UAAU;AACxB,gBAAc,MAAM;AACpB,SAAO;AACT;AAKA,eAAsB,aACpB,SACA,aACqB;AACrB,QAAM,UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,YAAY,OAAO,SAAS,aAAa,OAAO;AACxF,gBAAc,UAAU;AACxB,gBAAc,MAAM;AACpB,SAAO;AACT;AAKA,eAAsB,SAAS,SAAsC;AACnE,QAAM,UAAU,MAAM,mBAAmB;AACzC,QAAM,SAAS,MAAM,UAAU,EAAE,OAAO,SAAS,SAAS,OAAO;AACjE,gBAAc,UAAU;AACxB,gBAAc,MAAM;AACpB,SAAO;AACT;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/actions/credit-cards.d.ts b/packages/next/dist/actions/credit-cards.d.tsnew file mode 100644index 0000000000..973740a0d9--- /dev/null+++ b/packages/next/dist/actions/credit-cards.d.ts@@ -0,0 +1,14 @@+import { StoreCreditCard } from '@spree/sdk';++/**+ * List the authenticated customer's credit cards.+ */+declare function listCreditCards(): Promise<{+ data: StoreCreditCard[];+}>;+/**+ * Delete a credit card.+ */+declare function deleteCreditCard(id: string): Promise<void>;++export { deleteCreditCard, listCreditCards };diff --git a/packages/next/dist/actions/credit-cards.js b/packages/next/dist/actions/credit-cards.jsnew file mode 100644index 0000000000..3dfc8ffbe3--- /dev/null+++ b/packages/next/dist/actions/credit-cards.js@@ -0,0 +1,135 @@+"use server";++// src/actions/credit-cards.ts+import { revalidateTag } from "next/cache";++// src/auth-helpers.ts+import { SpreeError } from "@spree/sdk";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/auth-helpers.ts+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/credit-cards.ts+async function listCreditCards() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.list(void 0, options);+ });+}+async function deleteCreditCard(id) {+ await withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.delete(id, options);+ });+ revalidateTag("credit-cards");+}+export {+ deleteCreditCard,+ listCreditCards+};+//# sourceMappingURL=credit-cards.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/credit-cards.js.map b/packages/next/dist/actions/credit-cards.js.mapnew file mode 100644index 0000000000..a8df7f33b5--- /dev/null+++ b/packages/next/dist/actions/credit-cards.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/actions/credit-cards.ts","../../src/auth-helpers.ts","../../src/config.ts","../../src/cookies.ts"],"sourcesContent":["'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCreditCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's credit cards.\n */\nexport async function listCreditCards(): Promise<{ data: StoreCreditCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.creditCards.list(undefined, options);\n });\n}\n\n/**\n * Delete a credit card.\n */\nexport async function deleteCreditCard(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().customer.creditCards.delete(id, options);\n });\n revalidateTag('credit-cards');\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n"],"mappings":";;;AAEA,SAAS,qBAAqB;;;ACF9B,SAAS,kBAAkB;;;ACA3B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,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ards.d.tsnew file mode 100644index 0000000000..a441afa8d7--- /dev/null+++ b/packages/next/dist/actions/gift-cards.d.ts@@ -0,0 +1,14 @@+import { StoreGiftCard } from '@spree/sdk';++/**+ * List the authenticated customer's gift cards.+ */+declare function listGiftCards(): Promise<{+ data: StoreGiftCard[];+}>;+/**+ * Get a single gift card by ID.+ */+declare function getGiftCard(id: string): Promise<StoreGiftCard>;++export { getGiftCard, listGiftCards };diff --git a/packages/next/dist/actions/gift-cards.js b/packages/next/dist/actions/gift-cards.jsnew file mode 100644index 0000000000..c9ac363aae--- /dev/null+++ b/packages/next/dist/actions/gift-cards.js@@ -0,0 +1,131 @@+"use server";++// src/auth-helpers.ts+import { SpreeError } from "@spree/sdk";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/auth-helpers.ts+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/gift-cards.ts+async function listGiftCards() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.list(void 0, options);+ });+}+async function getGiftCard(id) {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.get(id, options);+ });+}+export {+ getGiftCard,+ listGiftCards+};+//# sourceMappingURL=gift-cards.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/gift-cards.js.map b/packages/next/dist/actions/gift-cards.js.mapnew file mode 100644index 0000000000..450ac4aa77--- /dev/null+++ b/packages/next/dist/actions/gift-cards.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/auth-helpers.ts","../../src/config.ts","../../src/cookies.ts","../../src/actions/gift-cards.ts"],"sourcesContent":["import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","'use server';\n\nimport type { StoreGiftCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's gift cards.\n */\nexport async function listGiftCards(): Promise<{ data: StoreGiftCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.giftCards.list(undefined, options);\n });\n}\n\n/**\n * Get a single gift card by ID.\n */\nexport async function getGiftCard(id: string): Promise<StoreGiftCard> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.giftCards.get(id, options);\n });\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;;;ACA3B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,QAAQ;AACrB,oBAAc,EAAE,SAAS,OAAO,CAAC;AAAA,IACnC,OA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AAU,EAAE,KAAK,QAAQ,EAAE,MAAM,CAAC;AAC1D,cAAM,eAAe,UAAU,KAAK;AACpC,eAAO,EAAE,OAAO,UAAU,MAAM;AAAA,MAClC,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO,EAAE,MAAM;AACjB;AAQA,eAAsB,gBACpB,IACY;AACZ,QAAM,UAAU,MAAM,eAAe;AAErC,MAAI,CAAC,QAAQ,OAAO;AAClB,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AAEA,MAAI;AACF,WAAO,MAAM,GAAG,OAAO;AAAA,EACzB,SAAS,OAAgB;AAEvB,QAAI,iBAAiB,cAAc,MAAM,WAAW,KAAK;AACvD,UAAI;AACF,cAAM,YAAY,MAAM,UAAU,EAAE,KAAK,QAAQ,EAAE,OAAO,QAAQ,MAAM,CAAC;AACzE,cAAM,eAAe,UAAU,KAAK;AACpC,eAAO,MAAM,GAAG,EAAE,OAAO,UAAU,MAAM,CAAC;AAAA,MAC5C,QAAQ;AAEN,cAAM,iBAAiB;AACvB,cAAM;AAAA,MACR;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;;;AG7DA,eAAsB,gBAAoD;AACxE,SAAO,gBAAgB,OAAO,YAAY;AACxC,WAAO,UAAU,EAAE,SAAS,UAAU,KAAK,QAAW,OAAO;AAAA,EAC/D,CAAC;AACH;AAKA,eAAsB,YAAY,IAAoC;AACpE,SAAO,gBAAgB,OAAO,YAAY;AACxC,WAAO,UAAU,EAAE,SAAS,UAAU,IAAI,IAAI,OAAO;AAAA,EACvD,CAAC;AACH;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/actions/orders.d.ts b/packages/next/dist/actions/orders.d.tsnew file mode 100644index 0000000000..6250349767--- /dev/null+++ b/packages/next/dist/actions/orders.d.ts@@ -0,0 +1,12 @@+import { StoreOrder, PaginatedResponse } from '@spree/sdk';++/**+ * List the authenticated customer's orders.+ */+declare function listOrders(params?: Record<string, unknown>): Promise<PaginatedResponse<StoreOrder>>;+/**+ * Get a single order by ID or number.+ */+declare function getOrder(idOrNumber: string, params?: Record<string, unknown>): Promise<StoreOrder>;++export { getOrder, listOrders };diff --git a/packages/next/dist/actions/orders.js b/packages/next/dist/actions/orders.jsnew file mode 100644index 0000000000..182a0fdcbc--- /dev/null+++ b/packages/next/dist/actions/orders.js@@ -0,0 +1,131 @@+"use server";++// src/auth-helpers.ts+import { SpreeError } from "@spree/sdk";++// src/config.ts+import { createSpreeClient } from "@spree/sdk";+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/cookies.ts+import { cookies } from "next/headers";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/auth-helpers.ts+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/orders.ts+async function listOrders(params) {+ return withAuthRefresh(async (options) => {+ return getClient().orders.list(params, options);+ });+}+async function getOrder(idOrNumber, params) {+ return withAuthRefresh(async (options) => {+ return getClient().orders.get(idOrNumber, params, options);+ });+}+export {+ getOrder,+ listOrders+};+//# sourceMappingURL=orders.js.map\ No newline at end of filediff --git a/packages/next/dist/actions/orders.js.map b/packages/next/dist/actions/orders.js.mapnew file mode 100644index 0000000000..9cba64ecf9--- /dev/null+++ b/packages/next/dist/actions/orders.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/auth-helpers.ts","../../src/config.ts","../../src/cookies.ts","../../src/actions/orders.ts"],"sourcesContent":["import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","'use server';\n\nimport type { StoreOrder, PaginatedResponse } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's orders.\n */\nexport async function listOrders(\n params?: Record<string, unknown>\n): Promise<PaginatedResponse<StoreOrder>> {\n return withAuthRefresh(async (options) => {\n return getClient().orders.list(params, options);\n });\n}\n\n/**\n * Get a single order by ID or number.\n */\nexport async function getOrder(\n idOrNumber: string,\n params?: Record<string, unknown>\n): Promise<StoreOrder> {\n return withAuthRefresh(async (options) => {\n return getClient().orders.get(idOrNumber, params, options);\n });\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;;;ACA3B,SAAS,yBAA2C;AAGpD,IAAI,UAA8B;AAClC,IAAI,UAAkC;AAO/B,SAAS,cAAc,QAA+B;AAC3D,YAAU;AACV,YAAU,kBAAkB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB,CAAC;AACH;AAMO,SAAS,YAAyB;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,QAAQ;AACrB,oBAAc,EAAE,SAAS,OAAO,CAAC;AAAA,IACnC,OAAO;AACL,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,YAA6B;AAC3C,MAAI,CAAC,SAAS;AACZ,cAAU;AA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;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO,EAAE,MAAM;AACjB;AAQA,eAAsB,gBACpB,IACY;AACZ,QAAM,UAAU,MAAM,eAAe;AAErC,MAAI,CAAC,QAAQ,OAAO;AAClB,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AAEA,MAAI;AACF,WAAO,MAAM,GAAG,OAAO;AAAA,EACzB,SAAS,OAAgB;AAEvB,QAAI,iBAAiB,cAAc,MAAM,WAAW,KAAK;AACvD,UAAI;AACF,cAAM,YAAY,MAAM,UAAU,EAAE,KAAK,QAAQ,EAAE,OAAO,QAAQ,MAAM,CAAC;AACzE,cAAM,eAAe,UAAU,KAAK;AACpC,eAAO,MAAM,GAAG,EAAE,OAAO,UAAU,MAAM,CAAC;AAAA,MAC5C,QAAQ;AAEN,cAAM,iBAAiB;AACvB,cAAM;AAAA,MACR;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;;;AG7DA,eAAsB,WACpB,QACwC;AACxC,SAAO,gBAAgB,OAAO,YAAY;AACxC,WAAO,UAAU,EAAE,OAAO,KAAK,QAAQ,OAAO;AAAA,EAChD,CAAC;AACH;AAKA,eAAsB,SACpB,YACA,QACqB;AACrB,SAAO,gBAAgB,OAAO,YAAY;AACxC,WAAO,UAAU,EAAE,OAAO,IAAI,YAAY,QAAQ,OAAO;AAAA,EAC3D,CAAC;AACH;","names":[]}\ No newline at end of filediff --git a/packages/next/dist/config.d.ts b/packages/next/dist/config.d.tsnew file mode 100644index 0000000000..206d002577--- /dev/null+++ b/packages/next/dist/config.d.ts@@ -0,0 +1,26 @@+import { SpreeClient } from '@spree/sdk';+import { SpreeNextConfig } from './types.js';++/**+ * Initialize the Spree Next.js integration.+ * Call this once in your app (e.g., in `lib/storefront.ts`).+ * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.+ */+declare function initSpreeNext(config: SpreeNextConfig): void;+/**+ * Get the SpreeClient instance. Auto-initializes from env vars if needed.+ * @internal+ */+declare function getClient(): SpreeClient;+/**+ * Get the current config. Auto-initializes from env vars if needed.+ * @internal+ */+declare function getConfig(): SpreeNextConfig;+/**+ * Reset the client (useful for testing).+ * @internal+ */+declare function resetClient(): void;++export { getClient, getConfig, initSpreeNext, resetClient };diff --git a/packages/next/dist/config.js b/packages/next/dist/config.jsnew file mode 100644index 0000000000..8ca9b11bd6--- /dev/null+++ b/packages/next/dist/config.js@@ -0,0 +1,40 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}+function resetClient() {+ _client = null;+ _config = null;+}++export { getClient, getConfig, initSpreeNext, resetClient };+//# sourceMappingURL=config.js.map+//# sourceMappingURL=config.js.map\ No newline at end of filediff --git a/packages/next/dist/config.js.map b/packages/next/dist/config.js.mapnew file mode 100644index 0000000000..b665ef9ea7--- /dev/null+++ b/packages/next/dist/config.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../src/config.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAClC,IAAI,OAAA,GAAkC,IAAA;AAO/B,SAAS,cAAc,MAAA,EAA+B;AAC3D,EAAA,OAAA,GAAU,MAAA;AACV,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,GAA6B;AAC3C,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,SAAA,EAAU;AAAA,EACZ;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,WAAA,GAAoB;AAClC,EAAA,OAAA,GAAU,IAAA;AACV,EAAA,OAAA,GAAU,IAAA;AACZ","file":"config.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/data/countries.d.ts b/packages/next/dist/data/countries.d.tsnew file mode 100644index 0000000000..4056db0fba--- /dev/null+++ b/packages/next/dist/data/countries.d.ts@@ -0,0 +1,15 @@+import { StoreCountry } from '@spree/sdk';+import { SpreeNextOptions } from '../types.js';++/**+ * List all available countries.+ */+declare function listCountries(options?: SpreeNextOptions): Promise<{+ data: StoreCountry[];+}>;+/**+ * Get a single country by ISO code.+ */+declare function getCountry(iso: string, options?: SpreeNextOptions): Promise<StoreCountry>;++export { getCountry, listCountries };diff --git a/packages/next/dist/data/countries.js b/packages/next/dist/data/countries.jsnew file mode 100644index 0000000000..577e5acbc5--- /dev/null+++ b/packages/next/dist/data/countries.js@@ -0,0 +1,42 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+function initSpreeNext(config) {+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}++// src/data/countries.ts+async function listCountries(options) {+ return getClient().countries.list({+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getCountry(iso, options) {+ return getClient().countries.get(iso, {+ locale: options?.locale,+ currency: options?.currency+ });+}++export { getCountry, listCountries };+//# sourceMappingURL=countries.js.map+//# sourceMappingURL=countries.js.map\ No newline at end of filediff --git a/packages/next/dist/data/countries.js.map b/packages/next/dist/data/countries.js.mapnew file mode 100644index 0000000000..4f6a7a185c--- /dev/null+++ b/packages/next/dist/data/countries.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/config.ts","../../src/data/countries.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,cACpB,OAAA,EACmC;AACnC,EAAA,OAAO,SAAA,EAAU,CAAE,SAAA,CAAU,IAAA,CAAK;AAAA,IAChC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,UAAA,CACpB,KACA,OAAA,EACuB;AACvB,EAAA,OAAO,SAAA,EAAU,CAAE,SAAA,CAAU,GAAA,CAAI,GAAA,EAAK;AAAA,IACpC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"countries.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List all available countries.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single country by ISO code.\n */\nexport async function getCountry(\n iso: string,\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().countries.get(iso, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/data/products.d.ts b/packages/next/dist/data/products.d.tsnew file mode 100644index 0000000000..fd781f73a1--- /dev/null+++ b/packages/next/dist/data/products.d.ts@@ -0,0 +1,19 @@+import { StoreProduct, ProductFiltersResponse, PaginatedResponse } from '@spree/sdk';+import { SpreeNextOptions } from '../types.js';++/**+ * List products with optional filtering, sorting, and pagination.+ */+declare function listProducts(params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<PaginatedResponse<StoreProduct>>;+/**+ * Get a single product by slug or ID.+ */+declare function getProduct(slugOrId: string, params?: {+ includes?: string;+}, options?: SpreeNextOptions): Promise<StoreProduct>;+/**+ * Get available product filters (price ranges, option values, etc.).+ */+declare function getProductFilters(params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<ProductFiltersResponse>;++export { getProduct, getProductFilters, listProducts };diff --git a/packages/next/dist/data/products.js b/packages/next/dist/data/products.jsnew file mode 100644index 0000000000..c81ff9e608--- /dev/null+++ b/packages/next/dist/data/products.js@@ -0,0 +1,48 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+function initSpreeNext(config) {+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}++// src/data/products.ts+async function listProducts(params, options) {+ return getClient().products.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getProduct(slugOrId, params, options) {+ return getClient().products.get(slugOrId, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getProductFilters(params, options) {+ return getClient().products.filters(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++export { getProduct, getProductFilters, listProducts };+//# sourceMappingURL=products.js.map+//# sourceMappingURL=products.js.map\ No newline at end of filediff --git a/packages/next/dist/data/products.js.map b/packages/next/dist/data/products.js.mapnew file mode 100644index 0000000000..07b4e4c695--- /dev/null+++ b/packages/next/dist/data/products.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/config.ts","../../src/data/products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AA,EAAS;AAAA,GACpB,CAAA;AACH","file":"products.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreProduct, PaginatedResponse, ProductFiltersResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List products with optional filtering, sorting, and pagination.\n */\nexport async function listProducts(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().products.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single product by slug or ID.\n */\nexport async function getProduct(\n slugOrId: string,\n params?: { includes?: string },\n options?: SpreeNextOptions\n): Promise<StoreProduct> {\n return getClient().products.get(slugOrId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get available product filters (price ranges, option values, etc.).\n */\nexport async function getProductFilters(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<ProductFiltersResponse> {\n return getClient().products.filters(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/data/store.d.ts b/packages/next/dist/data/store.d.tsnew file mode 100644index 0000000000..8ca532e48e--- /dev/null+++ b/packages/next/dist/data/store.d.ts@@ -0,0 +1,9 @@+import { StoreStore } from '@spree/sdk';+import { SpreeNextOptions } from '../types.js';++/**+ * Get the current store configuration.+ */+declare function getStore(options?: SpreeNextOptions): Promise<StoreStore>;++export { getStore };diff --git a/packages/next/dist/data/store.js b/packages/next/dist/data/store.jsnew file mode 100644index 0000000000..fcebbaa8d3--- /dev/null+++ b/packages/next/dist/data/store.js@@ -0,0 +1,36 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+function initSpreeNext(config) {+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}++// src/data/store.ts+async function getStore(options) {+ return getClient().store.get({+ locale: options?.locale,+ currency: options?.currency+ });+}++export { getStore };+//# sourceMappingURL=store.js.map+//# sourceMappingURL=store.js.map\ No newline at end of filediff --git a/packages/next/dist/data/store.js.map b/packages/next/dist/data/store.js.mapnew file mode 100644index 0000000000..ea3fe97178--- /dev/null+++ b/packages/next/dist/data/store.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/config.ts","../../src/data/store.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,SAAS,OAAA,EAAiD;AAC9E,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,GAAA,CAAI;AAAA,IAC3B,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"store.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreStore } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * Get the current store configuration.\n */\nexport async function getStore(options?: SpreeNextOptions): Promise<StoreStore> {\n return getClient().store.get({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/data/taxonomies.d.ts b/packages/next/dist/data/taxonomies.d.tsnew file mode 100644index 0000000000..f7feb82c01--- /dev/null+++ b/packages/next/dist/data/taxonomies.d.ts@@ -0,0 +1,13 @@+import { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';+import { SpreeNextOptions } from '../types.js';++/**+ * List taxonomies with optional filtering and pagination.+ */+declare function listTaxonomies(params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<PaginatedResponse<StoreTaxonomy>>;+/**+ * Get a single taxonomy by ID.+ */+declare function getTaxonomy(id: string, params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<StoreTaxonomy>;++export { getTaxonomy, listTaxonomies };diff --git a/packages/next/dist/data/taxonomies.js b/packages/next/dist/data/taxonomies.jsnew file mode 100644index 0000000000..c2670fb32b--- /dev/null+++ b/packages/next/dist/data/taxonomies.js@@ -0,0 +1,42 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+function initSpreeNext(config) {+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}++// src/data/taxonomies.ts+async function listTaxonomies(params, options) {+ return getClient().taxonomies.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getTaxonomy(id, params, options) {+ return getClient().taxonomies.get(id, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++export { getTaxonomy, listTaxonomies };+//# sourceMappingURL=taxonomies.js.map+//# sourceMappingURL=taxonomies.js.map\ No newline at end of filediff --git a/packages/next/dist/data/taxonomies.js.map b/packages/next/dist/data/taxonomies.js.mapnew file mode 100644index 0000000000..887be7ccb8--- /dev/null+++ b/packages/next/dist/data/taxonomies.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/config.ts","../../src/data/taxonomies.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,cAAA,CACpB,QACA,OAAA,EAC2C;AAC3C,EAAA,OAAO,SAAA,EAAU,CAAE,UAAA,CAAW,IAAA,CAAK,MAAA,EAAQ;AAAA,IACzC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,WAAA,CACpB,EAAA,EACA,MAAA,EACA,OAAA,EACwB;AACxB,EAAA,OAAO,SAAA,EAAU,CAAE,UAAA,CAAW,GAAA,CAAI,IAAI,MAAA,EAAQ;AAAA,IAC5C,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"taxonomies.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxonomies with optional filtering and pagination.\n */\nexport async function listTaxonomies(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxonomy>> {\n return getClient().taxonomies.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxonomy by ID.\n */\nexport async function getTaxonomy(\n id: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxonomy> {\n return getClient().taxonomies.get(id, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/data/taxons.d.ts b/packages/next/dist/data/taxons.d.tsnew file mode 100644index 0000000000..004960c376--- /dev/null+++ b/packages/next/dist/data/taxons.d.ts@@ -0,0 +1,17 @@+import { StoreTaxon, PaginatedResponse, StoreProduct } from '@spree/sdk';+import { SpreeNextOptions } from '../types.js';++/**+ * List taxons (categories) with optional filtering and pagination.+ */+declare function listTaxons(params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<PaginatedResponse<StoreTaxon>>;+/**+ * Get a single taxon by ID or permalink.+ */+declare function getTaxon(idOrPermalink: string, params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<StoreTaxon>;+/**+ * List products within a taxon.+ */+declare function listTaxonProducts(taxonId: string, params?: Record<string, unknown>, options?: SpreeNextOptions): Promise<PaginatedResponse<StoreProduct>>;++export { getTaxon, listTaxonProducts, listTaxons };diff --git a/packages/next/dist/data/taxons.js b/packages/next/dist/data/taxons.jsnew file mode 100644index 0000000000..97329e8655--- /dev/null+++ b/packages/next/dist/data/taxons.js@@ -0,0 +1,48 @@+import { createSpreeClient } from '@spree/sdk';++// src/config.ts+var _client = null;+function initSpreeNext(config) {+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}++// src/data/taxons.ts+async function listTaxons(params, options) {+ return getClient().taxons.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getTaxon(idOrPermalink, params, options) {+ return getClient().taxons.get(idOrPermalink, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function listTaxonProducts(taxonId, params, options) {+ return getClient().taxons.products.list(taxonId, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++export { getTaxon, listTaxonProducts, listTaxons };+//# sourceMappingURL=taxons.js.map+//# sourceMappingURL=taxons.js.map\ No newline at end of filediff --git a/packages/next/dist/data/taxons.js.map b/packages/next/dist/data/taxons.js.mapnew file mode 100644index 0000000000..5062930786--- /dev/null+++ b/packages/next/dist/data/taxons.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../../src/config.ts","../../src/data/taxons.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,UAAA,CACpB,QACA,OAAA,EACwC;AACxC,EAAA,OAAO,SAAA,EAAU,CAAE,MAAA,CAAO,IAAA,CAAK,MAAA,EAAQ;AAAA,IACrC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,QAAA,CACpB,aAAA,EACA,MAAA,EACA,OAAA,EACqB;AACrB,EAAA,OAAO,SAAA,EAAU,CAAE,MAAA,CAAO,GAAA,CAAI,eAAe,MAAA,EAAQ;AAAA,IACnD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,iBAAA,CACpB,OAAA,EACA,MAAA,EACA,OAAA,EAC0C;AAC1C,EAAA,OAAO,WAAU,CAAE,MAAA,CAAO,QAAA,CAAS,IAAA,CAAK,SAAS,MAAA,EAAQ;AAAA,IACvD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"taxons.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreTaxon, StoreProduct, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxons (categories) with optional filtering and pagination.\n */\nexport async function listTaxons(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxon>> {\n return getClient().taxons.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxon by ID or permalink.\n */\nexport async function getTaxon(\n idOrPermalink: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxon> {\n return getClient().taxons.get(idOrPermalink, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * List products within a taxon.\n */\nexport async function listTaxonProducts(\n taxonId: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().taxons.products.list(taxonId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/index.d.ts b/packages/next/dist/index.d.tsnew file mode 100644index 0000000000..090f418324--- /dev/null+++ b/packages/next/dist/index.d.ts@@ -0,0 +1,191 @@+export { getClient, initSpreeNext } from './config.js';+export { SpreeNextConfig, SpreeNextOptions } from './types.js';+export { getProduct, getProductFilters, listProducts } from './data/products.js';+export { getTaxon, listTaxonProducts, listTaxons } from './data/taxons.js';+export { getTaxonomy, listTaxonomies } from './data/taxonomies.js';+export { getStore } from './data/store.js';+export { getCountry, listCountries } from './data/countries.js';+import { StoreLineItem, StoreOrder, StoreShipment, AddressParams, StoreUser, StoreAddress, PaginatedResponse, StoreCreditCard, StoreGiftCard } from '@spree/sdk';+export { AddressParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreGiftCard, StoreImage, StoreLineItem, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy, StoreUser, StoreVariant } from '@spree/sdk';++/**+ * Get the current cart. Returns null if no cart exists.+ */+declare function getCart(): Promise<(StoreOrder & {+ token: string;+}) | null>;+/**+ * Get existing cart or create a new one.+ */+declare function getOrCreateCart(): Promise<StoreOrder & {+ token: string;+}>;+/**+ * Add an item to the cart. Creates a cart if none exists.+ */+declare function addItem(variantId: string, quantity?: number): Promise<StoreLineItem>;+/**+ * Update a line item quantity in the cart.+ */+declare function updateItem(lineItemId: string, quantity: number): Promise<StoreLineItem>;+/**+ * Remove a line item from the cart.+ */+declare function removeItem(lineItemId: string): Promise<void>;+/**+ * Clear the cart (abandons the current cart).+ */+declare function clearCart(): Promise<void>;+/**+ * Associate a guest cart with the currently authenticated user.+ * Call this after login/register when the user has an existing guest cart.+ */+declare function associateCart(): Promise<(StoreOrder & {+ token: string;+}) | null>;++/**+ * Get the current checkout order state.+ */+declare function getCheckout(orderId: string): Promise<StoreOrder>;+/**+ * Update shipping and/or billing addresses on the order.+ */+declare function updateAddresses(orderId: string, params: {+ email?: string;+ ship_address?: AddressParams;+ bill_address?: AddressParams;+ ship_address_id?: string;+ bill_address_id?: string;+}): Promise<StoreOrder>;+/**+ * Advance the checkout to the next step.+ */+declare function advance(orderId: string): Promise<StoreOrder>;+/**+ * Move the checkout to the next step (alias for advance).+ */+declare function next(orderId: string): Promise<StoreOrder>;+/**+ * Get shipments for the order (includes available shipping rates).+ */+declare function getShipments(orderId: string): Promise<{+ data: StoreShipment[];+}>;+/**+ * Select a shipping rate for a shipment.+ */+declare function selectShippingRate(orderId: string, shipmentId: string, shippingRateId: string): Promise<StoreShipment>;+/**+ * Apply a coupon code to the order.+ */+declare function applyCoupon(orderId: string, code: string): Promise<StoreOrder>;+/**+ * Remove a coupon/promotion from the order.+ */+declare function removeCoupon(orderId: string, promotionId: string): Promise<StoreOrder>;+/**+ * Complete the checkout and place the order.+ */+declare function complete(orderId: string): Promise<StoreOrder>;++/**+ * Login with email and password.+ * Automatically associates any guest cart with the authenticated user.+ */+declare function login(email: string, password: string): Promise<{+ success: boolean;+ user?: {+ id: string;+ email: string;+ first_name?: string | null;+ last_name?: string | null;+ };+ error?: string;+}>;+/**+ * Register a new customer account.+ * Automatically associates any guest cart with the new account.+ */+declare function register(email: string, password: string, passwordConfirmation: string): Promise<{+ success: boolean;+ user?: {+ id: string;+ email: string;+ first_name?: string | null;+ last_name?: string | null;+ };+ error?: string;+}>;+/**+ * Logout the current user.+ */+declare function logout(): Promise<void>;+/**+ * Get the currently authenticated customer. Returns null if not logged in.+ */+declare function getCustomer(): Promise<StoreUser | null>;+/**+ * Update the current customer's profile.+ */+declare function updateCustomer(data: {+ first_name?: string;+ last_name?: string;+ email?: string;+}): Promise<StoreUser>;++/**+ * List the authenticated customer's addresses.+ */+declare function listAddresses(): Promise<{+ data: StoreAddress[];+}>;+/**+ * Get a single address by ID.+ */+declare function getAddress(id: string): Promise<StoreAddress>;+/**+ * Create a new address for the customer.+ */+declare function createAddress(params: AddressParams): Promise<StoreAddress>;+/**+ * Update an existing address.+ */+declare function updateAddress(id: string, params: Partial<AddressParams>): Promise<StoreAddress>;+/**+ * Delete an address.+ */+declare function deleteAddress(id: string): Promise<void>;++/**+ * List the authenticated customer's orders.+ */+declare function listOrders(params?: Record<string, unknown>): Promise<PaginatedResponse<StoreOrder>>;+/**+ * Get a single order by ID or number.+ */+declare function getOrder(idOrNumber: string, params?: Record<string, unknown>): Promise<StoreOrder>;++/**+ * List the authenticated customer's credit cards.+ */+declare function listCreditCards(): Promise<{+ data: StoreCreditCard[];+}>;+/**+ * Delete a credit card.+ */+declare function deleteCreditCard(id: string): Promise<void>;++/**+ * List the authenticated customer's gift cards.+ */+declare function listGiftCards(): Promise<{+ data: StoreGiftCard[];+}>;+/**+ * Get a single gift card by ID.+ */+declare function getGiftCard(id: string): Promise<StoreGiftCard>;++export { addItem, advance, applyCoupon, associateCart, clearCart, complete, createAddress, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getCustomer, getGiftCard, getOrCreateCart, getOrder, getShipments, listAddresses, listCreditCards, listGiftCards, listOrders, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem };diff --git a/packages/next/dist/index.js b/packages/next/dist/index.jsnew file mode 100644index 0000000000..d8d2ac0cfd--- /dev/null+++ b/packages/next/dist/index.js@@ -0,0 +1,502 @@+import { createSpreeClient, SpreeError } from '@spree/sdk';+import { revalidateTag } from 'next/cache';+import { cookies } from 'next/headers';++// src/config.ts+var _client = null;+var _config = null;+function initSpreeNext(config) {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey+ });+}+function getClient() {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."+ );+ }+ }+ return _client;+}+function getConfig() {+ if (!_config) {+ getClient();+ }+ return _config;+}++// src/data/products.ts+async function listProducts(params, options) {+ return getClient().products.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getProduct(slugOrId, params, options) {+ return getClient().products.get(slugOrId, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getProductFilters(params, options) {+ return getClient().products.filters(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++// src/data/taxons.ts+async function listTaxons(params, options) {+ return getClient().taxons.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getTaxon(idOrPermalink, params, options) {+ return getClient().taxons.get(idOrPermalink, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function listTaxonProducts(taxonId, params, options) {+ return getClient().taxons.products.list(taxonId, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++// src/data/taxonomies.ts+async function listTaxonomies(params, options) {+ return getClient().taxonomies.list(params, {+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getTaxonomy(id, params, options) {+ return getClient().taxonomies.get(id, params, {+ locale: options?.locale,+ currency: options?.currency+ });+}++// src/data/store.ts+async function getStore(options) {+ return getClient().store.get({+ locale: options?.locale,+ currency: options?.currency+ });+}++// src/data/countries.ts+async function listCountries(options) {+ return getClient().countries.list({+ locale: options?.locale,+ currency: options?.currency+ });+}+async function getCountry(iso, options) {+ return getClient().countries.get(iso, {+ locale: options?.locale,+ currency: options?.currency+ });+}+var DEFAULT_CART_COOKIE = "_spree_cart_token";+var DEFAULT_ACCESS_TOKEN_COOKIE = "_spree_jwt";+var CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30;+var ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7;+function getCartCookieName() {+ try {+ return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;+ } catch {+ return DEFAULT_CART_COOKIE;+ }+}+function getAccessTokenCookieName() {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}+async function getCartToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getCartCookieName())?.value;+}+async function setCartToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: CART_TOKEN_MAX_AGE+ });+}+async function clearCartToken() {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}+async function getAccessToken() {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}+async function setAccessToken(token) {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === "production",+ sameSite: "lax",+ path: "/",+ maxAge: ACCESS_TOKEN_MAX_AGE+ });+}+async function clearAccessToken() {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), "", {+ maxAge: -1,+ path: "/"+ });+}++// src/actions/cart.ts+async function getCart() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) return null;+ try {+ return await getClient().cart.get({ orderToken, token });+ } catch {+ return null;+ }+}+async function getOrCreateCart() {+ const existing = await getCart();+ if (existing) return existing;+ const token = await getAccessToken();+ const cart = await getClient().cart.create(token ? { token } : void 0);+ if (cart.token) {+ await setCartToken(cart.token);+ }+ revalidateTag("cart");+ return cart;+}+async function addItem(variantId, quantity = 1) {+ const cart = await getOrCreateCart();+ const orderToken = cart.token;+ const token = await getAccessToken();+ const lineItem = await getClient().orders.lineItems.create(+ cart.id,+ { variant_id: variantId, quantity },+ { orderToken, token }+ );+ revalidateTag("cart");+ return lineItem;+}+async function updateItem(lineItemId, quantity) {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error("No cart found");+ const cart = await getClient().cart.get({ orderToken, token });+ const lineItem = await getClient().orders.lineItems.update(+ cart.id,+ lineItemId,+ { quantity },+ { orderToken, token }+ );+ revalidateTag("cart");+ return lineItem;+}+async function removeItem(lineItemId) {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error("No cart found");+ const cart = await getClient().cart.get({ orderToken, token });+ await getClient().orders.lineItems.delete(cart.id, lineItemId, {+ orderToken,+ token+ });+ revalidateTag("cart");+}+async function clearCart() {+ await clearCartToken();+ revalidateTag("cart");+}+async function associateCart() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken || !token) return null;+ try {+ const result = await getClient().cart.associate({ orderToken, token });+ revalidateTag("cart");+ return result;+ } catch {+ await clearCartToken();+ revalidateTag("cart");+ return null;+ }+}+async function getCheckoutOptions() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ return { orderToken, token };+}+async function getCheckout(orderId) {+ const options = await getCheckoutOptions();+ return getClient().orders.get(orderId, void 0, options);+}+async function updateAddresses(orderId, params) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.update(orderId, params, options);+ revalidateTag("checkout");+ return result;+}+async function advance(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.advance(orderId, options);+ revalidateTag("checkout");+ return result;+}+async function next(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.next(orderId, options);+ revalidateTag("checkout");+ return result;+}+async function getShipments(orderId) {+ const options = await getCheckoutOptions();+ return getClient().orders.shipments.list(orderId, options);+}+async function selectShippingRate(orderId, shipmentId, shippingRateId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.shipments.update(+ orderId,+ shipmentId,+ { selected_shipping_rate_id: shippingRateId },+ options+ );+ revalidateTag("checkout");+ return result;+}+async function applyCoupon(orderId, code) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.apply(orderId, code, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+async function removeCoupon(orderId, promotionId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+async function complete(orderId) {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.complete(orderId, options);+ revalidateTag("checkout");+ revalidateTag("cart");+ return result;+}+async function getAuthOptions() {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }+ try {+ const payload = JSON.parse(atob(token.split(".")[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1e3);+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ }+ }+ } catch {+ }+ return { token };+}+async function withAuthRefresh(fn) {+ const options = await getAuthOptions();+ if (!options.token) {+ throw new Error("Not authenticated");+ }+ try {+ return await fn(options);+ } catch (error) {+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}++// src/actions/auth.ts+async function login(email, password) {+ try {+ const result = await getClient().auth.login({ email, password });+ await setAccessToken(result.token);+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken+ });+ } catch {+ }+ }+ revalidateTag("customer");+ revalidateTag("cart");+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : "Invalid email or password"+ };+ }+}+async function register(email, password, passwordConfirmation) {+ try {+ const result = await getClient().auth.register({+ email,+ password,+ password_confirmation: passwordConfirmation+ });+ await setAccessToken(result.token);+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken+ });+ } catch {+ }+ }+ revalidateTag("customer");+ revalidateTag("cart");+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : "Registration failed"+ };+ }+}+async function logout() {+ await clearAccessToken();+ revalidateTag("customer");+ revalidateTag("cart");+ revalidateTag("addresses");+ revalidateTag("credit-cards");+}+async function getCustomer() {+ const token = await getAccessToken();+ if (!token) return null;+ try {+ return await withAuthRefresh(async (options) => {+ return getClient().customer.get(options);+ });+ } catch {+ await clearAccessToken();+ return null;+ }+}+async function updateCustomer(data) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.update(data, options);+ });+ revalidateTag("customer");+ return result;+}+async function listAddresses() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.list(void 0, options);+ });+}+async function getAddress(id) {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.get(id, options);+ });+}+async function createAddress(params) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.create(params, options);+ });+ revalidateTag("addresses");+ return result;+}+async function updateAddress(id, params) {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.update(id, params, options);+ });+ revalidateTag("addresses");+ return result;+}+async function deleteAddress(id) {+ await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.delete(id, options);+ });+ revalidateTag("addresses");+}++// src/actions/orders.ts+async function listOrders(params) {+ return withAuthRefresh(async (options) => {+ return getClient().orders.list(params, options);+ });+}+async function getOrder(idOrNumber, params) {+ return withAuthRefresh(async (options) => {+ return getClient().orders.get(idOrNumber, params, options);+ });+}+async function listCreditCards() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.list(void 0, options);+ });+}+async function deleteCreditCard(id) {+ await withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.delete(id, options);+ });+ revalidateTag("credit-cards");+}++// src/actions/gift-cards.ts+async function listGiftCards() {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.list(void 0, options);+ });+}+async function getGiftCard(id) {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.get(id, options);+ });+}++export { addItem, advance, applyCoupon, associateCart, clearCart, complete, createAddress, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getClient, getCountry, getCustomer, getGiftCard, getOrCreateCart, getOrder, getProduct, getProductFilters, getShipments, getStore, getTaxon, getTaxonomy, initSpreeNext, listAddresses, listCountries, listCreditCards, listGiftCards, listOrders, listProducts, listTaxonProducts, listTaxonomies, listTaxons, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem };+//# sourceMappingURL=index.js.map+//# sourceMappingURL=index.js.map\ No newline at end of filediff --git a/packages/next/dist/index.js.map b/packages/next/dist/index.js.mapnew file mode 100644index 0000000000..91f1ba56eb--- /dev/null+++ b/packages/next/dist/index.js.map@@ -0,0 +1 @@+{"version":3,"sources":["../src/config.ts","../src/data/products.ts","../src/data/taxons.ts","../src/data/taxonomies.ts","../src/data/store.ts","../src/data/countries.ts","../src/cookies.ts","../src/actions/cart.ts","../src/actions/checkout.ts","../src/auth-helpers.ts","../src/actions/auth.ts","../src/actions/addresses.ts","../src/actions/orders.ts","../src/actions/credit-cards.ts","../src/actions/gift-cards.ts"],"names":["revalidateTag"],"mappings":";;;;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAClC,IAAI,OAAA,GAAkC,IAAA;AAO/B,SAAS,cAAc,MAAA,EAA+B;AAC3D,EAAA,OAAA,GAAU,MAAA;AACV,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,GAA6B;AAC3C,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,SAAA,EAAU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,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,WAAU,CAAE,QAAA,CAAS,SAAA,CAAU,IAAA,CAAK,QAAW,OAAO,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;AAKA,eAAsB,YAAY,EAAA,EAAoC;AACpE,EAAA,OAAO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,WAAU,CAAE,QAAA,CAAS,SAAA,CAAU,GAAA,CAAI,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreProduct, PaginatedResponse, ProductFiltersResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List products with optional filtering, sorting, and pagination.\n */\nexport async function listProducts(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().products.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single product by slug or ID.\n */\nexport async function getProduct(\n slugOrId: string,\n params?: { includes?: string },\n options?: SpreeNextOptions\n): Promise<StoreProduct> {\n return getClient().products.get(slugOrId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get available product filters (price ranges, option values, etc.).\n */\nexport async function getProductFilters(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<ProductFiltersResponse> {\n return getClient().products.filters(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxon, StoreProduct, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxons (categories) with optional filtering and pagination.\n */\nexport async function listTaxons(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxon>> {\n return getClient().taxons.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxon by ID or permalink.\n */\nexport async function getTaxon(\n idOrPermalink: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxon> {\n return getClient().taxons.get(idOrPermalink, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * List products within a taxon.\n */\nexport async function listTaxonProducts(\n taxonId: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().taxons.products.list(taxonId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxonomies with optional filtering and pagination.\n */\nexport async function listTaxonomies(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxonomy>> {\n return getClient().taxonomies.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxonomy by ID.\n */\nexport async function getTaxonomy(\n id: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxonomy> {\n return getClient().taxonomies.get(id, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreStore } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * Get the current store configuration.\n */\nexport async function getStore(options?: SpreeNextOptions): Promise<StoreStore> {\n return getClient().store.get({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List all available countries.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single country by ISO code.\n */\nexport async function getCountry(\n iso: string,\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().countries.get(iso, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreLineItem } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, setCartToken, clearCartToken, getAccessToken } from '../cookies';\n\n/**\n * Get the current cart. Returns null if no cart exists.\n */\nexport async function getCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) return null;\n\n try {\n return await getClient().cart.get({ orderToken, token });\n } catch {\n return null;\n }\n}\n\n/**\n * Get existing cart or create a new one.\n */\nexport async function getOrCreateCart(): Promise<StoreOrder & { token: string }> {\n const existing = await getCart();\n if (existing) return existing;\n\n const token = await getAccessToken();\n const cart = await getClient().cart.create(token ? { token } : undefined);\n\n if (cart.token) {\n await setCartToken(cart.token);\n }\n\n revalidateTag('cart');\n return cart;\n}\n\n/**\n * Add an item to the cart. Creates a cart if none exists.\n */\nexport async function addItem(\n variantId: string,\n quantity: number = 1\n): Promise<StoreLineItem> {\n const cart = await getOrCreateCart();\n const orderToken = cart.token;\n const token = await getAccessToken();\n\n const lineItem = await getClient().orders.lineItems.create(\n cart.id,\n { variant_id: variantId, quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return lineItem;\n}\n\n/**\n * Update a line item quantity in the cart.\n */\nexport async function updateItem(\n lineItemId: string,\n quantity: number\n): Promise<StoreLineItem> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().cart.get({ orderToken, token });\n\n const lineItem = await getClient().orders.lineItems.update(\n cart.id,\n lineItemId,\n { quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return lineItem;\n}\n\n/**\n * Remove a line item from the cart.\n */\nexport async function removeItem(lineItemId: string): Promise<void> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().cart.get({ orderToken, token });\n\n await getClient().orders.lineItems.delete(cart.id, lineItemId, {\n orderToken,\n token,\n });\n\n revalidateTag('cart');\n}\n\n/**\n * Clear the cart (abandons the current cart).\n */\nexport async function clearCart(): Promise<void> {\n await clearCartToken();\n revalidateTag('cart');\n}\n\n/**\n * Associate a guest cart with the currently authenticated user.\n * Call this after login/register when the user has an existing guest cart.\n */\nexport async function associateCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken || !token) return null;\n\n try {\n const result = await getClient().cart.associate({ orderToken, token });\n revalidateTag('cart');\n return result;\n } catch {\n // Cart might already belong to another user — clear it\n await clearCartToken();\n revalidateTag('cart');\n return null;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Get the current checkout order state.\n */\nexport async function getCheckout(\n orderId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n return getClient().orders.get(orderId, undefined, options);\n}\n\n/**\n * Update shipping and/or billing addresses on the order.\n */\nexport async function updateAddresses(\n orderId: string,\n params: {\n email?: string;\n ship_address?: AddressParams;\n bill_address?: AddressParams;\n ship_address_id?: string;\n bill_address_id?: string;\n }\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.update(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Advance the checkout to the next step.\n */\nexport async function advance(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.advance(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Move the checkout to the next step (alias for advance).\n */\nexport async function next(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.next(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get shipments for the order (includes available shipping rates).\n */\nexport async function getShipments(\n orderId: string\n): Promise<{ data: StoreShipment[] }> {\n const options = await getCheckoutOptions();\n return getClient().orders.shipments.list(orderId, options);\n}\n\n/**\n * Select a shipping rate for a shipment.\n */\nexport async function selectShippingRate(\n orderId: string,\n shipmentId: string,\n shippingRateId: string\n): Promise<StoreShipment> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.shipments.update(\n orderId,\n shipmentId,\n { selected_shipping_rate_id: shippingRateId },\n options\n );\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Apply a coupon code to the order.\n */\nexport async function applyCoupon(\n orderId: string,\n code: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.couponCodes.apply(orderId, code, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Remove a coupon/promotion from the order.\n */\nexport async function removeCoupon(\n orderId: string,\n promotionId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Complete the checkout and place the order.\n */\nexport async function complete(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().orders.complete(orderId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreUser } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { setAccessToken, clearAccessToken, getAccessToken, getCartToken } from '../cookies';\nimport { withAuthRefresh } from '../auth-helpers';\n\n/**\n * Login with email and password.\n * Automatically associates any guest cart with the authenticated user.\n */\nexport async function login(\n email: string,\n password: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().auth.login({ email, password });\n await setAccessToken(result.token);\n\n // Associate guest cart if one exists\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Cart association failure is non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Invalid email or password',\n };\n }\n}\n\n/**\n * Register a new customer account.\n * Automatically associates any guest cart with the new account.\n */\nexport async function register(\n email: string,\n password: string,\n passwordConfirmation: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().auth.register({\n email,\n password,\n password_confirmation: passwordConfirmation,\n });\n await setAccessToken(result.token);\n\n // Associate guest cart\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Registration failed',\n };\n }\n}\n\n/**\n * Logout the current user.\n */\nexport async function logout(): Promise<void> {\n await clearAccessToken();\n revalidateTag('customer');\n revalidateTag('cart');\n revalidateTag('addresses');\n revalidateTag('credit-cards');\n}\n\n/**\n * Get the currently authenticated customer. Returns null if not logged in.\n */\nexport async function getCustomer(): Promise<StoreUser | null> {\n const token = await getAccessToken();\n if (!token) return null;\n\n try {\n return await withAuthRefresh(async (options) => {\n return getClient().customer.get(options);\n });\n } catch {\n await clearAccessToken();\n return null;\n }\n}\n\n/**\n * Update the current customer's profile.\n */\nexport async function updateCustomer(\n data: { first_name?: string; last_name?: string; email?: string }\n): Promise<StoreUser> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.update(data, options);\n });\n revalidateTag('customer');\n return result;\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreAddress, AddressParams } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's addresses.\n */\nexport async function listAddresses(): Promise<{ data: StoreAddress[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.addresses.list(undefined, options);\n });\n}\n\n/**\n * Get a single address by ID.\n */\nexport async function getAddress(id: string): Promise<StoreAddress> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.addresses.get(id, options);\n });\n}\n\n/**\n * Create a new address for the customer.\n */\nexport async function createAddress(params: AddressParams): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.create(params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Update an existing address.\n */\nexport async function updateAddress(\n id: string,\n params: Partial<AddressParams>\n): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.update(id, params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Delete an address.\n */\nexport async function deleteAddress(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().customer.addresses.delete(id, options);\n });\n revalidateTag('addresses');\n}\n","'use server';\n\nimport type { StoreOrder, PaginatedResponse } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's orders.\n */\nexport async function listOrders(\n params?: Record<string, unknown>\n): Promise<PaginatedResponse<StoreOrder>> {\n return withAuthRefresh(async (options) => {\n return getClient().orders.list(params, options);\n });\n}\n\n/**\n * Get a single order by ID or number.\n */\nexport async function getOrder(\n idOrNumber: string,\n params?: Record<string, unknown>\n): Promise<StoreOrder> {\n return withAuthRefresh(async (options) => {\n return getClient().orders.get(idOrNumber, params, options);\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCreditCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's credit cards.\n */\nexport async function listCreditCards(): Promise<{ data: StoreCreditCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.creditCards.list(undefined, options);\n });\n}\n\n/**\n * Delete a credit card.\n */\nexport async function deleteCreditCard(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().customer.creditCards.delete(id, options);\n });\n revalidateTag('credit-cards');\n}\n","'use server';\n\nimport type { StoreGiftCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's gift cards.\n */\nexport async function listGiftCards(): Promise<{ data: StoreGiftCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.giftCards.list(undefined, options);\n });\n}\n\n/**\n * Get a single gift card by ID.\n */\nexport async function getGiftCard(id: string): Promise<StoreGiftCard> {\n return withAuthRefresh(async (options) => {\n return getClient().customer.giftCards.get(id, options);\n });\n}\n"]}\ No newline at end of filediff --git a/packages/next/dist/types.d.ts b/packages/next/dist/types.d.tsnew file mode 100644index 0000000000..5bcf80be5a--- /dev/null+++ b/packages/next/dist/types.d.ts@@ -0,0 +1,22 @@+interface SpreeNextConfig {+ /** Base URL of the Spree API (e.g., 'https://api.mystore.com') */+ baseUrl: string;+ /** Publishable API key for store access */+ apiKey: string;+ /** Cookie name for the cart order token (default: '_spree_cart_token') */+ cartCookieName?: string;+ /** Cookie name for the JWT access token (default: '_spree_jwt') */+ accessTokenCookieName?: string;+ /** Default locale for API requests */+ defaultLocale?: string;+ /** Default currency for API requests */+ defaultCurrency?: string;+}+interface SpreeNextOptions {+ /** Locale for translated content (e.g., 'en', 'fr') */+ locale?: string;+ /** Currency for prices (e.g., 'USD', 'EUR') */+ currency?: string;+}++export type { SpreeNextConfig, SpreeNextOptions };diff --git a/packages/next/dist/types.js b/packages/next/dist/types.jsnew file mode 100644index 0000000000..6bd95cc39d--- /dev/null+++ b/packages/next/dist/types.js@@ -0,0 +1,3 @@++//# sourceMappingURL=types.js.map+//# sourceMappingURL=types.js.map\ No newline at end of filediff --git a/packages/next/dist/types.js.map b/packages/next/dist/types.js.mapnew file mode 100644index 0000000000..efc9e48573--- /dev/null+++ b/packages/next/dist/types.js.map@@ -0,0 +1 @@+{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}\ No newline at end of filediff --git a/packages/next/package-lock.json b/packages/next/package-lock.jsonnew file mode 100644index 0000000000..a487552148--- /dev/null+++ b/packages/next/package-lock.json@@ -0,0 +1,2919 @@+{+ "name": "@spree/next",+ "version": "0.1.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "@spree/next",+ "version": "0.1.0",+ "license": "MIT",+ "devDependencies": {+ "@spree/sdk": "file:../sdk",+ "@types/node": "^20.0.0",+ "@types/react": "^19.0.0",+ "next": "^15.3.3",+ "react": "^19.0.0",+ "tsup": "^8.0.0",+ "typescript": "^5.3.0",+ "vitest": "^4.0.18"+ },+ "peerDependencies": {+ "@spree/sdk": ">=0.1.0",+ "next": ">=15.0.0",+ "react": ">=19.0.0"+ }+ },+ "../sdk": {+ "name": "@spree/sdk",+ "version": "0.1.4",+ "dev": true,+ "license": "MIT",+ "devDependencies": {+ "@changesets/changelog-github": "^0.5.2",+ "@changesets/cli": "^2.29.8",+ "@types/node": "^20.0.0",+ "@vitest/coverage-v8": "^4.0.18",+ "msw": "^2.12.9",+ "tsup": "^8.0.0",+ "tsx": "^4.0.0",+ "typescript": "^5.3.0",+ "vitest": "^4.0.18"+ },+ "engines": {+ "node": ">=18.0.0"+ },+ "peerDependencies": {+ "typescript": ">=4.7.0"+ },+ "peerDependenciesMeta": {+ "typescript": {+ "optional": true+ }+ }+ },+ "node_modules/@emnapi/runtime": {+ "version": "1.8.1",+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.8.1.tgz",+ "integrity": "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^2.4.0"+ }+ },+ "node_modules/@esbuild/aix-ppc64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",+ "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "aix"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-arm": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz",+ "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz",+ "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz",+ "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/darwin-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz",+ "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/darwin-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz",+ "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/freebsd-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz",+ "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/freebsd-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz",+ "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-arm": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz",+ "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz",+ "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-ia32": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz",+ "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-loong64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz",+ "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==",+ "cpu": [+ "loong64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-mips64el": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz",+ "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==",+ "cpu": [+ "mips64el"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-ppc64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz",+ "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-riscv64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz",+ "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-s390x": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz",+ "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz",+ "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/netbsd-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz",+ "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/netbsd-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz",+ "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openbsd-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz",+ "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openbsd-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz",+ "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openharmony-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz",+ "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/sunos-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz",+ "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "sunos"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-arm64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz",+ "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-ia32": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz",+ "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-x64": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz",+ "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@img/colour": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz",+ "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==",+ "dev": true,+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@img/sharp-darwin-arm64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz",+ "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-darwin-arm64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-darwin-x64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz",+ "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-darwin-x64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-libvips-darwin-arm64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz",+ "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "darwin"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-darwin-x64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz",+ "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "darwin"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-arm": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz",+ "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-arm64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz",+ "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-ppc64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz",+ "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-riscv64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz",+ "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-s390x": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz",+ "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linux-x64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz",+ "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz",+ "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz",+ "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "linux"+ ],+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-linux-arm": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz",+ "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-arm": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linux-arm64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz",+ "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-arm64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linux-ppc64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz",+ "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-ppc64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linux-riscv64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz",+ "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-riscv64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linux-s390x": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz",+ "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-s390x": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linux-x64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz",+ "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linux-x64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linuxmusl-arm64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz",+ "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-linuxmusl-x64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz",+ "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-libvips-linuxmusl-x64": "1.2.4"+ }+ },+ "node_modules/@img/sharp-wasm32": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz",+ "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==",+ "cpu": [+ "wasm32"+ ],+ "dev": true,+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",+ "optional": true,+ "dependencies": {+ "@emnapi/runtime": "^1.7.0"+ },+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-arm64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz",+ "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-ia32": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz",+ "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@img/sharp-win32-x64": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz",+ "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "Apache-2.0 AND LGPL-3.0-or-later",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ }+ },+ "node_modules/@jridgewell/gen-mapping": {+ "version": "0.3.13",+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.0",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/resolve-uri": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.0.0"+ }+ },+ "node_modules/@jridgewell/sourcemap-codec": {+ "version": "1.5.5",+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",+ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@jridgewell/trace-mapping": {+ "version": "0.3.31",+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/resolve-uri": "^3.1.0",+ "@jridgewell/sourcemap-codec": "^1.4.14"+ }+ },+ "node_modules/@next/env": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.12.tgz",+ "integrity": "sha512-pUvdJN1on574wQHjaBfNGDt9Mz5utDSZFsIIQkMzPgNS8ZvT4H2mwOrOIClwsQOb6EGx5M76/CZr6G8i6pSpLg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@next/swc-darwin-arm64": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.12.tgz",+ "integrity": "sha512-RnRjBtH8S8eXCpUNkQ+543DUc7ys8y15VxmFU9HRqlo9BG3CcBUiwNtF8SNoi2xvGCVJq1vl2yYq+3oISBS0Zg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-darwin-x64": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.12.tgz",+ "integrity": "sha512-nqa9/7iQlboF1EFtNhWxQA0rQstmYRSBGxSM6g3GxvxHxcoeqVXfGNr9stJOme674m2V7r4E3+jEhhGvSQhJRA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-gnu": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.12.tgz",+ "integrity": "sha512-dCzAjqhDHwmoB2M4eYfVKqXs99QdQxNQVpftvP1eGVppamXh/OkDAwV737Zr0KPXEqRUMN4uCjh6mjO+XtF3Mw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-musl": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.12.tgz",+ "integrity": "sha512-+fpGWvQiITgf7PUtbWY1H7qUSnBZsPPLyyq03QuAKpVoTy/QUx1JptEDTQMVvQhvizCEuNLEeghrQUyXQOekuw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-gnu": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.12.tgz",+ "integrity": "sha512-jSLvgdRRL/hrFAPqEjJf1fFguC719kmcptjNVDJl26BnJIpjL3KH5h6mzR4mAweociLQaqvt4UyzfbFjgAdDcw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-musl": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.12.tgz",+ "integrity": "sha512-/uaF0WfmYqQgLfPmN6BvULwxY0dufI2mlN2JbOKqqceZh1G4hjREyi7pg03zjfyS6eqNemHAZPSoP84x17vo6w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-arm64-msvc": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.12.tgz",+ "integrity": "sha512-xhsL1OvQSfGmlL5RbOmU+FV120urrgFpYLq+6U8C6KIym32gZT6XF/SDE92jKzzlPWskkbjOKCpqk5m4i8PEfg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-x64-msvc": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.12.tgz",+ "integrity": "sha512-Z1Dh6lhFkxvBDH1FoW6OU/L6prYwPSlwjLiZkExIAh8fbP6iI/M7iGTQAJPYJ9YFlWobCZ1PHbchFhFYb2ADkw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@rollup/rollup-android-arm-eabi": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz",+ "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ]+ },+ "node_modules/@rollup/rollup-android-arm64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz",+ "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ]+ },+ "node_modules/@rollup/rollup-darwin-arm64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz",+ "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ]+ },+ "node_modules/@rollup/rollup-darwin-x64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz",+ "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ]+ },+ "node_modules/@rollup/rollup-freebsd-arm64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz",+ "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ]+ },+ "node_modules/@rollup/rollup-freebsd-x64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz",+ "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ]+ },+ "node_modules/@rollup/rollup-linux-arm-gnueabihf": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz",+ "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-arm-musleabihf": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz",+ "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-arm64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz",+ "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-arm64-musl": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz",+ "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-loong64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz",+ "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==",+ "cpu": [+ "loong64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-loong64-musl": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz",+ "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==",+ "cpu": [+ "loong64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-ppc64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz",+ "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-ppc64-musl": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz",+ "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-riscv64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz",+ "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-riscv64-musl": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz",+ "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-s390x-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz",+ "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-x64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz",+ "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-linux-x64-musl": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz",+ "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },+ "node_modules/@rollup/rollup-openbsd-x64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz",+ "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openbsd"+ ]+ },+ "node_modules/@rollup/rollup-openharmony-arm64": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz",+ "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ]+ },+ "node_modules/@rollup/rollup-win32-arm64-msvc": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz",+ "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ]+ },+ "node_modules/@rollup/rollup-win32-ia32-msvc": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz",+ "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ]+ },+ "node_modules/@rollup/rollup-win32-x64-gnu": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz",+ "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ]+ },+ "node_modules/@rollup/rollup-win32-x64-msvc": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz",+ "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ]+ },+ "node_modules/@spree/sdk": {+ "resolved": "../sdk",+ "link": true+ },+ "node_modules/@standard-schema/spec": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",+ "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@swc/helpers": {+ "version": "0.5.15",+ "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz",+ "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",+ "dev": true,+ "license": "Apache-2.0",+ "dependencies": {+ "tslib": "^2.8.0"+ }+ },+ "node_modules/@types/chai": {+ "version": "5.2.3",+ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",+ "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/deep-eql": "*",+ "assertion-error": "^2.0.1"+ }+ },+ "node_modules/@types/deep-eql": {+ "version": "4.0.2",+ "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",+ "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/estree": {+ "version": "1.0.8",+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",+ "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/node": {+ "version": "20.19.33",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.33.tgz",+ "integrity": "sha512-Rs1bVAIdBs5gbTIKza/tgpMuG1k3U/UMJLWecIMxNdJFDMzcM5LOiLVRYh3PilWEYDIeUDv7bpiHPLPsbydGcw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "undici-types": "~6.21.0"+ }+ },+ "node_modules/@types/react": {+ "version": "19.2.13",+ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.13.tgz",+ "integrity": "sha512-KkiJeU6VbYbUOp5ITMIc7kBfqlYkKA5KhEHVrGMmUUMt7NeaZg65ojdPk+FtNrBAOXNVM5QM72jnADjM+XVRAQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "csstype": "^3.2.2"+ }+ },+ "node_modules/@vitest/expect": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz",+ "integrity": "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@standard-schema/spec": "^1.0.0",+ "@types/chai": "^5.2.2",+ "@vitest/spy": "4.0.18",+ "@vitest/utils": "4.0.18",+ "chai": "^6.2.1",+ "tinyrainbow": "^3.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/mocker": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.18.tgz",+ "integrity": "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/spy": "4.0.18",+ "estree-walker": "^3.0.3",+ "magic-string": "^0.30.21"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "msw": "^2.4.9",+ "vite": "^6.0.0 || ^7.0.0-0"+ },+ "peerDependenciesMeta": {+ "msw": {+ "optional": true+ },+ "vite": {+ "optional": true+ }+ }+ },+ "node_modules/@vitest/pretty-format": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.18.tgz",+ "integrity": "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "tinyrainbow": "^3.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/runner": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.18.tgz",+ "integrity": "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/utils": "4.0.18",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/snapshot": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.18.tgz",+ "integrity": "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.0.18",+ "magic-string": "^0.30.21",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/spy": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.18.tgz",+ "integrity": "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/utils": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.18.tgz",+ "integrity": "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.0.18",+ "tinyrainbow": "^3.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/acorn": {+ "version": "8.15.0",+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",+ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "acorn": "bin/acorn"+ },+ "engines": {+ "node": ">=0.4.0"+ }+ },+ "node_modules/any-promise": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",+ "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/assertion-error": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",+ "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/bundle-require": {+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz",+ "integrity": "sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "load-tsconfig": "^0.2.3"+ },+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "peerDependencies": {+ "esbuild": ">=0.18"+ }+ },+ "node_modules/cac": {+ "version": "6.7.14",+ "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",+ "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/caniuse-lite": {+ "version": "1.0.30001769",+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz",+ "integrity": "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/browserslist"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "CC-BY-4.0"+ },+ "node_modules/chai": {+ "version": "6.2.2",+ "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",+ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/chokidar": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "readdirp": "^4.0.1"+ },+ "engines": {+ "node": ">= 14.16.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/client-only": {+ "version": "0.0.1",+ "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",+ "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/commander": {+ "version": "4.1.1",+ "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",+ "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 6"+ }+ },+ "node_modules/confbox": {+ "version": "0.1.8",+ "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz",+ "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/consola": {+ "version": "3.4.2",+ "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz",+ "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": "^14.18.0 || >=16.10.0"+ }+ },+ "node_modules/csstype": {+ "version": "3.2.3",+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",+ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/debug": {+ "version": "4.4.3",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "node_modules/detect-libc": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",+ "dev": true,+ "license": "Apache-2.0",+ "optional": true,+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/es-module-lexer": {+ "version": "1.7.0",+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",+ "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/esbuild": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz",+ "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "bin": {+ "esbuild": "bin/esbuild"+ },+ "engines": {+ "node": ">=18"+ },+ "optionalDependencies": {+ "@esbuild/aix-ppc64": "0.27.3",+ "@esbuild/android-arm": "0.27.3",+ "@esbuild/android-arm64": "0.27.3",+ "@esbuild/android-x64": "0.27.3",+ "@esbuild/darwin-arm64": "0.27.3",+ "@esbuild/darwin-x64": "0.27.3",+ "@esbuild/freebsd-arm64": "0.27.3",+ "@esbuild/freebsd-x64": "0.27.3",+ "@esbuild/linux-arm": "0.27.3",+ "@esbuild/linux-arm64": "0.27.3",+ "@esbuild/linux-ia32": "0.27.3",+ "@esbuild/linux-loong64": "0.27.3",+ "@esbuild/linux-mips64el": "0.27.3",+ "@esbuild/linux-ppc64": "0.27.3",+ "@esbuild/linux-riscv64": "0.27.3",+ "@esbuild/linux-s390x": "0.27.3",+ "@esbuild/linux-x64": "0.27.3",+ "@esbuild/netbsd-arm64": "0.27.3",+ "@esbuild/netbsd-x64": "0.27.3",+ "@esbuild/openbsd-arm64": "0.27.3",+ "@esbuild/openbsd-x64": "0.27.3",+ "@esbuild/openharmony-arm64": "0.27.3",+ "@esbuild/sunos-x64": "0.27.3",+ "@esbuild/win32-arm64": "0.27.3",+ "@esbuild/win32-ia32": "0.27.3",+ "@esbuild/win32-x64": "0.27.3"+ }+ },+ "node_modules/estree-walker": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/estree": "^1.0.0"+ }+ },+ "node_modules/expect-type": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz",+ "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=12.0.0"+ }+ },+ "node_modules/fdir": {+ "version": "6.5.0",+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12.0.0"+ },+ "peerDependencies": {+ "picomatch": "^3 || ^4"+ },+ "peerDependenciesMeta": {+ "picomatch": {+ "optional": true+ }+ }+ },+ "node_modules/fix-dts-default-cjs-exports": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/fix-dts-default-cjs-exports/-/fix-dts-default-cjs-exports-1.0.1.tgz",+ "integrity": "sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "magic-string": "^0.30.17",+ "mlly": "^1.7.4",+ "rollup": "^4.34.8"+ }+ },+ "node_modules/fsevents": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },+ "node_modules/joycon": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",+ "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/lilconfig": {+ "version": "3.1.3",+ "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz",+ "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=14"+ },+ "funding": {+ "url": "https://github.com/sponsors/antonk52"+ }+ },+ "node_modules/lines-and-columns": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",+ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/load-tsconfig": {+ "version": "0.2.5",+ "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz",+ "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ }+ },+ "node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/mlly": {+ "version": "1.8.0",+ "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.0.tgz",+ "integrity": "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "acorn": "^8.15.0",+ "pathe": "^2.0.3",+ "pkg-types": "^1.3.1",+ "ufo": "^1.6.1"+ }+ },+ "node_modules/ms": {+ "version": "2.1.3",+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/mz": {+ "version": "2.7.0",+ "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",+ "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "any-promise": "^1.0.0",+ "object-assign": "^4.0.1",+ "thenify-all": "^1.0.0"+ }+ },+ "node_modules/nanoid": {+ "version": "3.3.11",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",+ "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "bin": {+ "nanoid": "bin/nanoid.cjs"+ },+ "engines": {+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"+ }+ },+ "node_modules/next": {+ "version": "15.5.12",+ "resolved": "https://registry.npmjs.org/next/-/next-15.5.12.tgz",+ "integrity": "sha512-Fi/wQ4Etlrn60rz78bebG1i1SR20QxvV8tVp6iJspjLUSHcZoeUXCt+vmWoEcza85ElZzExK/jJ/F6SvtGktjA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@next/env": "15.5.12",+ "@swc/helpers": "0.5.15",+ "caniuse-lite": "^1.0.30001579",+ "postcss": "8.4.31",+ "styled-jsx": "5.1.6"+ },+ "bin": {+ "next": "dist/bin/next"+ },+ "engines": {+ "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"+ },+ "optionalDependencies": {+ "@next/swc-darwin-arm64": "15.5.12",+ "@next/swc-darwin-x64": "15.5.12",+ "@next/swc-linux-arm64-gnu": "15.5.12",+ "@next/swc-linux-arm64-musl": "15.5.12",+ "@next/swc-linux-x64-gnu": "15.5.12",+ "@next/swc-linux-x64-musl": "15.5.12",+ "@next/swc-win32-arm64-msvc": "15.5.12",+ "@next/swc-win32-x64-msvc": "15.5.12",+ "sharp": "^0.34.3"+ },+ "peerDependencies": {+ "@opentelemetry/api": "^1.1.0",+ "@playwright/test": "^1.51.1",+ "babel-plugin-react-compiler": "*",+ "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",+ "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",+ "sass": "^1.3.0"+ },+ "peerDependenciesMeta": {+ "@opentelemetry/api": {+ "optional": true+ },+ "@playwright/test": {+ "optional": true+ },+ "babel-plugin-react-compiler": {+ "optional": true+ },+ "sass": {+ "optional": true+ }+ }+ },+ "node_modules/object-assign": {+ "version": "4.1.1",+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/obug": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz",+ "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==",+ "dev": true,+ "funding": [+ "https://github.com/sponsors/sxzz",+ "https://opencollective.com/debug"+ ],+ "license": "MIT"+ },+ "node_modules/pathe": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/picocolors": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/picomatch": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",+ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },+ "node_modules/pirates": {+ "version": "4.0.7",+ "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz",+ "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 6"+ }+ },+ "node_modules/pkg-types": {+ "version": "1.3.1",+ "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz",+ "integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "confbox": "^0.1.8",+ "mlly": "^1.7.4",+ "pathe": "^2.0.1"+ }+ },+ "node_modules/postcss": {+ "version": "8.4.31",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",+ "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.6",+ "picocolors": "^1.0.0",+ "source-map-js": "^1.0.2"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/postcss-load-config": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz",+ "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "lilconfig": "^3.1.1"+ },+ "engines": {+ "node": ">= 18"+ },+ "peerDependencies": {+ "jiti": ">=1.21.0",+ "postcss": ">=8.0.9",+ "tsx": "^4.8.1",+ "yaml": "^2.4.2"+ },+ "peerDependenciesMeta": {+ "jiti": {+ "optional": true+ },+ "postcss": {+ "optional": true+ },+ "tsx": {+ "optional": true+ },+ "yaml": {+ "optional": true+ }+ }+ },+ "node_modules/react": {+ "version": "19.2.4",+ "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",+ "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/react-dom": {+ "version": "19.2.4",+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz",+ "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==",+ "dev": true,+ "license": "MIT",+ "peer": true,+ "dependencies": {+ "scheduler": "^0.27.0"+ },+ "peerDependencies": {+ "react": "^19.2.4"+ }+ },+ "node_modules/readdirp": {+ "version": "4.1.2",+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 14.18.0"+ },+ "funding": {+ "type": "individual",+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/resolve-from": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/rollup": {+ "version": "4.57.1",+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz",+ "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/estree": "1.0.8"+ },+ "bin": {+ "rollup": "dist/bin/rollup"+ },+ "engines": {+ "node": ">=18.0.0",+ "npm": ">=8.0.0"+ },+ "optionalDependencies": {+ "@rollup/rollup-android-arm-eabi": "4.57.1",+ "@rollup/rollup-android-arm64": "4.57.1",+ "@rollup/rollup-darwin-arm64": "4.57.1",+ "@rollup/rollup-darwin-x64": "4.57.1",+ "@rollup/rollup-freebsd-arm64": "4.57.1",+ "@rollup/rollup-freebsd-x64": "4.57.1",+ "@rollup/rollup-linux-arm-gnueabihf": "4.57.1",+ "@rollup/rollup-linux-arm-musleabihf": "4.57.1",+ "@rollup/rollup-linux-arm64-gnu": "4.57.1",+ "@rollup/rollup-linux-arm64-musl": "4.57.1",+ "@rollup/rollup-linux-loong64-gnu": "4.57.1",+ "@rollup/rollup-linux-loong64-musl": "4.57.1",+ "@rollup/rollup-linux-ppc64-gnu": "4.57.1",+ "@rollup/rollup-linux-ppc64-musl": "4.57.1",+ "@rollup/rollup-linux-riscv64-gnu": "4.57.1",+ "@rollup/rollup-linux-riscv64-musl": "4.57.1",+ "@rollup/rollup-linux-s390x-gnu": "4.57.1",+ "@rollup/rollup-linux-x64-gnu": "4.57.1",+ "@rollup/rollup-linux-x64-musl": "4.57.1",+ "@rollup/rollup-openbsd-x64": "4.57.1",+ "@rollup/rollup-openharmony-arm64": "4.57.1",+ "@rollup/rollup-win32-arm64-msvc": "4.57.1",+ "@rollup/rollup-win32-ia32-msvc": "4.57.1",+ "@rollup/rollup-win32-x64-gnu": "4.57.1",+ "@rollup/rollup-win32-x64-msvc": "4.57.1",+ "fsevents": "~2.3.2"+ }+ },+ "node_modules/scheduler": {+ "version": "0.27.0",+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",+ "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",+ "dev": true,+ "license": "MIT",+ "peer": true+ },+ "node_modules/semver": {+ "version": "7.7.4",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",+ "dev": true,+ "license": "ISC",+ "optional": true,+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/sharp": {+ "version": "0.34.5",+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz",+ "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==",+ "dev": true,+ "hasInstallScript": true,+ "license": "Apache-2.0",+ "optional": true,+ "dependencies": {+ "@img/colour": "^1.0.0",+ "detect-libc": "^2.1.2",+ "semver": "^7.7.3"+ },+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/libvips"+ },+ "optionalDependencies": {+ "@img/sharp-darwin-arm64": "0.34.5",+ "@img/sharp-darwin-x64": "0.34.5",+ "@img/sharp-libvips-darwin-arm64": "1.2.4",+ "@img/sharp-libvips-darwin-x64": "1.2.4",+ "@img/sharp-libvips-linux-arm": "1.2.4",+ "@img/sharp-libvips-linux-arm64": "1.2.4",+ "@img/sharp-libvips-linux-ppc64": "1.2.4",+ "@img/sharp-libvips-linux-riscv64": "1.2.4",+ "@img/sharp-libvips-linux-s390x": "1.2.4",+ "@img/sharp-libvips-linux-x64": "1.2.4",+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.4",+ "@img/sharp-libvips-linuxmusl-x64": "1.2.4",+ "@img/sharp-linux-arm": "0.34.5",+ "@img/sharp-linux-arm64": "0.34.5",+ "@img/sharp-linux-ppc64": "0.34.5",+ "@img/sharp-linux-riscv64": "0.34.5",+ "@img/sharp-linux-s390x": "0.34.5",+ "@img/sharp-linux-x64": "0.34.5",+ "@img/sharp-linuxmusl-arm64": "0.34.5",+ "@img/sharp-linuxmusl-x64": "0.34.5",+ "@img/sharp-wasm32": "0.34.5",+ "@img/sharp-win32-arm64": "0.34.5",+ "@img/sharp-win32-ia32": "0.34.5",+ "@img/sharp-win32-x64": "0.34.5"+ }+ },+ "node_modules/siginfo": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/source-map": {+ "version": "0.7.6",+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",+ "integrity": "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==",+ "dev": true,+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">= 12"+ }+ },+ "node_modules/source-map-js": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",+ "dev": true,+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/stackback": {+ "version": "0.0.2",+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/std-env": {+ "version": "3.10.0",+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz",+ "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/styled-jsx": {+ "version": "5.1.6",+ "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz",+ "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "client-only": "0.0.1"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "peerDependencies": {+ "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0"+ },+ "peerDependenciesMeta": {+ "@babel/core": {+ "optional": true+ },+ "babel-plugin-macros": {+ "optional": true+ }+ }+ },+ "node_modules/sucrase": {+ "version": "3.35.1",+ "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz",+ "integrity": "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/gen-mapping": "^0.3.2",+ "commander": "^4.0.0",+ "lines-and-columns": "^1.1.6",+ "mz": "^2.7.0",+ "pirates": "^4.0.1",+ "tinyglobby": "^0.2.11",+ "ts-interface-checker": "^0.1.9"+ },+ "bin": {+ "sucrase": "bin/sucrase",+ "sucrase-node": "bin/sucrase-node"+ },+ "engines": {+ "node": ">=16 || 14 >=14.17"+ }+ },+ "node_modules/thenify": {+ "version": "3.3.1",+ "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",+ "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "any-promise": "^1.0.0"+ }+ },+ "node_modules/thenify-all": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz",+ "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "thenify": ">= 3.1.0 < 4"+ },+ "engines": {+ "node": ">=0.8"+ }+ },+ "node_modules/tinybench": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",+ "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tinyexec": {+ "version": "0.3.2",+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz",+ "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tinyglobby": {+ "version": "0.2.15",+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",+ "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "fdir": "^6.5.0",+ "picomatch": "^4.0.3"+ },+ "engines": {+ "node": ">=12.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/SuperchupuDev"+ }+ },+ "node_modules/tinyrainbow": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz",+ "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=14.0.0"+ }+ },+ "node_modules/tree-kill": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",+ "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "tree-kill": "cli.js"+ }+ },+ "node_modules/ts-interface-checker": {+ "version": "0.1.13",+ "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",+ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==",+ "dev": true,+ "license": "Apache-2.0"+ },+ "node_modules/tslib": {+ "version": "2.8.1",+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",+ "dev": true,+ "license": "0BSD"+ },+ "node_modules/tsup": {+ "version": "8.5.1",+ "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.5.1.tgz",+ "integrity": "sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "bundle-require": "^5.1.0",+ "cac": "^6.7.14",+ "chokidar": "^4.0.3",+ "consola": "^3.4.0",+ "debug": "^4.4.0",+ "esbuild": "^0.27.0",+ "fix-dts-default-cjs-exports": "^1.0.0",+ "joycon": "^3.1.1",+ "picocolors": "^1.1.1",+ "postcss-load-config": "^6.0.1",+ "resolve-from": "^5.0.0",+ "rollup": "^4.34.8",+ "source-map": "^0.7.6",+ "sucrase": "^3.35.0",+ "tinyexec": "^0.3.2",+ "tinyglobby": "^0.2.11",+ "tree-kill": "^1.2.2"+ },+ "bin": {+ "tsup": "dist/cli-default.js",+ "tsup-node": "dist/cli-node.js"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@microsoft/api-extractor": "^7.36.0",+ "@swc/core": "^1",+ "postcss": "^8.4.12",+ "typescript": ">=4.5.0"+ },+ "peerDependenciesMeta": {+ "@microsoft/api-extractor": {+ "optional": true+ },+ "@swc/core": {+ "optional": true+ },+ "postcss": {+ "optional": true+ },+ "typescript": {+ "optional": true+ }+ }+ },+ "node_modules/typescript": {+ "version": "5.9.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",+ "dev": true,+ "license": "Apache-2.0",+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/ufo": {+ "version": "1.6.3",+ "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.3.tgz",+ "integrity": "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/undici-types": {+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/vite": {+ "version": "7.3.1",+ "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz",+ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "esbuild": "^0.27.0",+ "fdir": "^6.5.0",+ "picomatch": "^4.0.3",+ "postcss": "^8.5.6",+ "rollup": "^4.43.0",+ "tinyglobby": "^0.2.15"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "funding": {+ "url": "https://github.com/vitejs/vite?sponsor=1"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.3"+ },+ "peerDependencies": {+ "@types/node": "^20.19.0 || >=22.12.0",+ "jiti": ">=1.21.0",+ "less": "^4.0.0",+ "lightningcss": "^1.21.0",+ "sass": "^1.70.0",+ "sass-embedded": "^1.70.0",+ "stylus": ">=0.54.8",+ "sugarss": "^5.0.0",+ "terser": "^5.16.0",+ "tsx": "^4.8.1",+ "yaml": "^2.4.2"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "jiti": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "lightningcss": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "sass-embedded": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ },+ "tsx": {+ "optional": true+ },+ "yaml": {+ "optional": true+ }+ }+ },+ "node_modules/vite/node_modules/postcss": {+ "version": "8.5.6",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",+ "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.11",+ "picocolors": "^1.1.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/vitest": {+ "version": "4.0.18",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz",+ "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/expect": "4.0.18",+ "@vitest/mocker": "4.0.18",+ "@vitest/pretty-format": "4.0.18",+ "@vitest/runner": "4.0.18",+ "@vitest/snapshot": "4.0.18",+ "@vitest/spy": "4.0.18",+ "@vitest/utils": "4.0.18",+ "es-module-lexer": "^1.7.0",+ "expect-type": "^1.2.2",+ "magic-string": "^0.30.21",+ "obug": "^2.1.1",+ "pathe": "^2.0.3",+ "picomatch": "^4.0.3",+ "std-env": "^3.10.0",+ "tinybench": "^2.9.0",+ "tinyexec": "^1.0.2",+ "tinyglobby": "^0.2.15",+ "tinyrainbow": "^3.0.3",+ "vite": "^6.0.0 || ^7.0.0",+ "why-is-node-running": "^2.3.0"+ },+ "bin": {+ "vitest": "vitest.mjs"+ },+ "engines": {+ "node": "^20.0.0 || ^22.0.0 || >=24.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "@edge-runtime/vm": "*",+ "@opentelemetry/api": "^1.9.0",+ "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",+ "@vitest/browser-playwright": "4.0.18",+ "@vitest/browser-preview": "4.0.18",+ "@vitest/browser-webdriverio": "4.0.18",+ "@vitest/ui": "4.0.18",+ "happy-dom": "*",+ "jsdom": "*"+ },+ "peerDependenciesMeta": {+ "@edge-runtime/vm": {+ "optional": true+ },+ "@opentelemetry/api": {+ "optional": true+ },+ "@types/node": {+ "optional": true+ },+ "@vitest/browser-playwright": {+ "optional": true+ },+ "@vitest/browser-preview": {+ "optional": true+ },+ "@vitest/browser-webdriverio": {+ "optional": true+ },+ "@vitest/ui": {+ "optional": true+ },+ "happy-dom": {+ "optional": true+ },+ "jsdom": {+ "optional": true+ }+ }+ },+ "node_modules/vitest/node_modules/tinyexec": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz",+ "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/why-is-node-running": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",+ "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "siginfo": "^2.0.0",+ "stackback": "0.0.2"+ },+ "bin": {+ "why-is-node-running": "cli.js"+ },+ "engines": {+ "node": ">=8"+ }+ }+ }+}diff --git a/packages/next/package.json b/packages/next/package.jsonnew file mode 100644index 0000000000..1609596a1d--- /dev/null+++ b/packages/next/package.json@@ -0,0 +1,64 @@+{+ "name": "@spree/next",+ "version": "0.1.0",+ "description": "Next.js integration for Spree Commerce — server actions, caching, and cookie-based auth",+ "type": "module",+ "main": "./dist/index.js",+ "types": "./dist/index.d.ts",+ "exports": {+ ".": {+ "import": {+ "types": "./dist/index.d.ts",+ "default": "./dist/index.js"+ }+ }+ },+ "files": [+ "dist",+ "README.md"+ ],+ "scripts": {+ "build": "tsup",+ "dev": "tsup --watch",+ "typecheck": "tsc --noEmit",+ "test": "vitest run",+ "test:watch": "vitest",+ "clean": "rm -rf dist",+ "prepublishOnly": "npm run build"+ },+ "keywords": [+ "spree",+ "commerce",+ "ecommerce",+ "nextjs",+ "server-actions",+ "typescript",+ "headless"+ ],+ "author": "Vendo Connect Inc.",+ "license": "MIT",+ "repository": {+ "type": "git",+ "url": "https://github.com/spree/spree.git",+ "directory": "packages/next"+ },+ "homepage": "https://spreecommerce.org",+ "bugs": {+ "url": "https://github.com/spree/spree/issues"+ },+ "peerDependencies": {+ "@spree/sdk": ">=0.1.0",+ "next": ">=15.0.0",+ "react": ">=19.0.0"+ },+ "devDependencies": {+ "@spree/sdk": "file:../sdk",+ "@types/node": "^20.0.0",+ "@types/react": "^19.0.0",+ "next": "^15.3.3",+ "react": "^19.0.0",+ "tsup": "^8.0.0",+ "typescript": "^5.3.0",+ "vitest": "^4.0.18"+ }+}diff --git a/packages/next/src/actions/addresses.ts b/packages/next/src/actions/addresses.tsnew file mode 100644index 0000000000..1901a53b2d--- /dev/null+++ b/packages/next/src/actions/addresses.ts@@ -0,0 +1,59 @@+'use server';++import { revalidateTag } from 'next/cache';+import type { StoreAddress, AddressParams } from '@spree/sdk';+import { withAuthRefresh } from '../auth-helpers';+import { getClient } from '../config';++/**+ * List the authenticated customer's addresses.+ */+export async function listAddresses(): Promise<{ data: StoreAddress[] }> {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.list(undefined, options);+ });+}++/**+ * Get a single address by ID.+ */+export async function getAddress(id: string): Promise<StoreAddress> {+ return withAuthRefresh(async (options) => {+ return getClient().customer.addresses.get(id, options);+ });+}++/**+ * Create a new address for the customer.+ */+export async function createAddress(params: AddressParams): Promise<StoreAddress> {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.create(params, options);+ });+ revalidateTag('addresses');+ return result;+}++/**+ * Update an existing address.+ */+export async function updateAddress(+ id: string,+ params: Partial<AddressParams>+): Promise<StoreAddress> {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.update(id, params, options);+ });+ revalidateTag('addresses');+ return result;+}++/**+ * Delete an address.+ */+export async function deleteAddress(id: string): Promise<void> {+ await withAuthRefresh(async (options) => {+ return getClient().customer.addresses.delete(id, options);+ });+ revalidateTag('addresses');+}diff --git a/packages/next/src/actions/auth.ts b/packages/next/src/actions/auth.tsnew file mode 100644index 0000000000..c0eeb9f6c3--- /dev/null+++ b/packages/next/src/actions/auth.ts@@ -0,0 +1,125 @@+'use server';++import { revalidateTag } from 'next/cache';+import type { StoreUser } from '@spree/sdk';+import { getClient } from '../config';+import { setAccessToken, clearAccessToken, getAccessToken, getCartToken } from '../cookies';+import { withAuthRefresh } from '../auth-helpers';++/**+ * Login with email and password.+ * Automatically associates any guest cart with the authenticated user.+ */+export async function login(+ email: string,+ password: string+): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {+ try {+ const result = await getClient().auth.login({ email, password });+ await setAccessToken(result.token);++ // Associate guest cart if one exists+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken,+ });+ } catch {+ // Cart association failure is non-fatal+ }+ }++ revalidateTag('customer');+ revalidateTag('cart');+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : 'Invalid email or password',+ };+ }+}++/**+ * Register a new customer account.+ * Automatically associates any guest cart with the new account.+ */+export async function register(+ email: string,+ password: string,+ passwordConfirmation: string+): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {+ try {+ const result = await getClient().auth.register({+ email,+ password,+ password_confirmation: passwordConfirmation,+ });+ await setAccessToken(result.token);++ // Associate guest cart+ const cartToken = await getCartToken();+ if (cartToken) {+ try {+ await getClient().cart.associate({+ token: result.token,+ orderToken: cartToken,+ });+ } catch {+ // Non-fatal+ }+ }++ revalidateTag('customer');+ revalidateTag('cart');+ return { success: true, user: result.user };+ } catch (error) {+ return {+ success: false,+ error: error instanceof Error ? error.message : 'Registration failed',+ };+ }+}++/**+ * Logout the current user.+ */+export async function logout(): Promise<void> {+ await clearAccessToken();+ revalidateTag('customer');+ revalidateTag('cart');+ revalidateTag('addresses');+ revalidateTag('credit-cards');+}++/**+ * Get the currently authenticated customer. Returns null if not logged in.+ */+export async function getCustomer(): Promise<StoreUser | null> {+ const token = await getAccessToken();+ if (!token) return null;++ try {+ return await withAuthRefresh(async (options) => {+ return getClient().customer.get(options);+ });+ } catch {+ await clearAccessToken();+ return null;+ }+}++/**+ * Update the current customer's profile.+ */+export async function updateCustomer(+ data: { first_name?: string; last_name?: string; email?: string }+): Promise<StoreUser> {+ const result = await withAuthRefresh(async (options) => {+ return getClient().customer.update(data, options);+ });+ revalidateTag('customer');+ return result;+}diff --git a/packages/next/src/actions/cart.ts b/packages/next/src/actions/cart.tsnew file mode 100644index 0000000000..c082048d43--- /dev/null+++ b/packages/next/src/actions/cart.ts@@ -0,0 +1,131 @@+'use server';++import { revalidateTag } from 'next/cache';+import type { StoreOrder, StoreLineItem } from '@spree/sdk';+import { getClient } from '../config';+import { getCartToken, setCartToken, clearCartToken, getAccessToken } from '../cookies';++/**+ * Get the current cart. Returns null if no cart exists.+ */+export async function getCart(): Promise<(StoreOrder & { token: string }) | null> {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) return null;++ try {+ return await getClient().cart.get({ orderToken, token });+ } catch {+ return null;+ }+}++/**+ * Get existing cart or create a new one.+ */+export async function getOrCreateCart(): Promise<StoreOrder & { token: string }> {+ const existing = await getCart();+ if (existing) return existing;++ const token = await getAccessToken();+ const cart = await getClient().cart.create(token ? { token } : undefined);++ if (cart.token) {+ await setCartToken(cart.token);+ }++ revalidateTag('cart');+ return cart;+}++/**+ * Add an item to the cart. Creates a cart if none exists.+ */+export async function addItem(+ variantId: string,+ quantity: number = 1+): Promise<StoreLineItem> {+ const cart = await getOrCreateCart();+ const orderToken = cart.token;+ const token = await getAccessToken();++ const lineItem = await getClient().orders.lineItems.create(+ cart.id,+ { variant_id: variantId, quantity },+ { orderToken, token }+ );++ revalidateTag('cart');+ return lineItem;+}++/**+ * Update a line item quantity in the cart.+ */+export async function updateItem(+ lineItemId: string,+ quantity: number+): Promise<StoreLineItem> {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error('No cart found');++ const cart = await getClient().cart.get({ orderToken, token });++ const lineItem = await getClient().orders.lineItems.update(+ cart.id,+ lineItemId,+ { quantity },+ { orderToken, token }+ );++ revalidateTag('cart');+ return lineItem;+}++/**+ * Remove a line item from the cart.+ */+export async function removeItem(lineItemId: string): Promise<void> {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken && !token) throw new Error('No cart found');++ const cart = await getClient().cart.get({ orderToken, token });++ await getClient().orders.lineItems.delete(cart.id, lineItemId, {+ orderToken,+ token,+ });++ revalidateTag('cart');+}++/**+ * Clear the cart (abandons the current cart).+ */+export async function clearCart(): Promise<void> {+ await clearCartToken();+ revalidateTag('cart');+}++/**+ * Associate a guest cart with the currently authenticated user.+ * Call this after login/register when the user has an existing guest cart.+ */+export async function associateCart(): Promise<(StoreOrder & { token: string }) | null> {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ if (!orderToken || !token) return null;++ try {+ const result = await getClient().cart.associate({ orderToken, token });+ revalidateTag('cart');+ return result;+ } catch {+ // Cart might already belong to another user — clear it+ await clearCartToken();+ revalidateTag('cart');+ return null;+ }+}diff --git a/packages/next/src/actions/checkout.ts b/packages/next/src/actions/checkout.tsnew file mode 100644index 0000000000..4dc2bb005a--- /dev/null+++ b/packages/next/src/actions/checkout.ts@@ -0,0 +1,129 @@+'use server';++import { revalidateTag } from 'next/cache';+import type { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';+import { getClient } from '../config';+import { getCartToken, getAccessToken } from '../cookies';++async function getCheckoutOptions() {+ const orderToken = await getCartToken();+ const token = await getAccessToken();+ return { orderToken, token };+}++/**+ * Get the current checkout order state.+ */+export async function getCheckout(+ orderId: string+): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ return getClient().orders.get(orderId, undefined, options);+}++/**+ * Update shipping and/or billing addresses on the order.+ */+export async function updateAddresses(+ orderId: string,+ params: {+ email?: string;+ ship_address?: AddressParams;+ bill_address?: AddressParams;+ ship_address_id?: string;+ bill_address_id?: string;+ }+): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.update(orderId, params, options);+ revalidateTag('checkout');+ return result;+}++/**+ * Advance the checkout to the next step.+ */+export async function advance(orderId: string): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.advance(orderId, options);+ revalidateTag('checkout');+ return result;+}++/**+ * Move the checkout to the next step (alias for advance).+ */+export async function next(orderId: string): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.next(orderId, options);+ revalidateTag('checkout');+ return result;+}++/**+ * Get shipments for the order (includes available shipping rates).+ */+export async function getShipments(+ orderId: string+): Promise<{ data: StoreShipment[] }> {+ const options = await getCheckoutOptions();+ return getClient().orders.shipments.list(orderId, options);+}++/**+ * Select a shipping rate for a shipment.+ */+export async function selectShippingRate(+ orderId: string,+ shipmentId: string,+ shippingRateId: string+): Promise<StoreShipment> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.shipments.update(+ orderId,+ shipmentId,+ { selected_shipping_rate_id: shippingRateId },+ options+ );+ revalidateTag('checkout');+ return result;+}++/**+ * Apply a coupon code to the order.+ */+export async function applyCoupon(+ orderId: string,+ code: string+): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.apply(orderId, code, options);+ revalidateTag('checkout');+ revalidateTag('cart');+ return result;+}++/**+ * Remove a coupon/promotion from the order.+ */+export async function removeCoupon(+ orderId: string,+ promotionId: string+): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);+ revalidateTag('checkout');+ revalidateTag('cart');+ return result;+}++/**+ * Complete the checkout and place the order.+ */+export async function complete(orderId: string): Promise<StoreOrder> {+ const options = await getCheckoutOptions();+ const result = await getClient().orders.complete(orderId, options);+ revalidateTag('checkout');+ revalidateTag('cart');+ return result;+}diff --git a/packages/next/src/actions/credit-cards.ts b/packages/next/src/actions/credit-cards.tsnew file mode 100644index 0000000000..96452c5f9c--- /dev/null+++ b/packages/next/src/actions/credit-cards.ts@@ -0,0 +1,25 @@+'use server';++import { revalidateTag } from 'next/cache';+import type { StoreCreditCard } from '@spree/sdk';+import { withAuthRefresh } from '../auth-helpers';+import { getClient } from '../config';++/**+ * List the authenticated customer's credit cards.+ */+export async function listCreditCards(): Promise<{ data: StoreCreditCard[] }> {+ return withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.list(undefined, options);+ });+}++/**+ * Delete a credit card.+ */+export async function deleteCreditCard(id: string): Promise<void> {+ await withAuthRefresh(async (options) => {+ return getClient().customer.creditCards.delete(id, options);+ });+ revalidateTag('credit-cards');+}diff --git a/packages/next/src/actions/gift-cards.ts b/packages/next/src/actions/gift-cards.tsnew file mode 100644index 0000000000..6e8c7f842a--- /dev/null+++ b/packages/next/src/actions/gift-cards.ts@@ -0,0 +1,23 @@+'use server';++import type { StoreGiftCard } from '@spree/sdk';+import { withAuthRefresh } from '../auth-helpers';+import { getClient } from '../config';++/**+ * List the authenticated customer's gift cards.+ */+export async function listGiftCards(): Promise<{ data: StoreGiftCard[] }> {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.list(undefined, options);+ });+}++/**+ * Get a single gift card by ID.+ */+export async function getGiftCard(id: string): Promise<StoreGiftCard> {+ return withAuthRefresh(async (options) => {+ return getClient().customer.giftCards.get(id, options);+ });+}diff --git a/packages/next/src/actions/orders.ts b/packages/next/src/actions/orders.tsnew file mode 100644index 0000000000..659db94c5b--- /dev/null+++ b/packages/next/src/actions/orders.ts@@ -0,0 +1,28 @@+'use server';++import type { StoreOrder, PaginatedResponse } from '@spree/sdk';+import { withAuthRefresh } from '../auth-helpers';+import { getClient } from '../config';++/**+ * List the authenticated customer's orders.+ */+export async function listOrders(+ params?: Record<string, unknown>+): Promise<PaginatedResponse<StoreOrder>> {+ return withAuthRefresh(async (options) => {+ return getClient().orders.list(params, options);+ });+}++/**+ * Get a single order by ID or number.+ */+export async function getOrder(+ idOrNumber: string,+ params?: Record<string, unknown>+): Promise<StoreOrder> {+ return withAuthRefresh(async (options) => {+ return getClient().orders.get(idOrNumber, params, options);+ });+}diff --git a/packages/next/src/auth-helpers.ts b/packages/next/src/auth-helpers.tsnew file mode 100644index 0000000000..43491ffa84--- /dev/null+++ b/packages/next/src/auth-helpers.ts@@ -0,0 +1,71 @@+import { SpreeError } from '@spree/sdk';+import type { RequestOptions } from '@spree/sdk';+import { getClient } from './config';+import { getAccessToken, setAccessToken, clearAccessToken } from './cookies';++/**+ * Get auth request options from the current JWT token.+ * Proactively refreshes the token if it expires within 1 hour.+ */+export async function getAuthOptions(): Promise<RequestOptions> {+ const token = await getAccessToken();+ if (!token) {+ return {};+ }++ // Check if token is close to expiry by decoding JWT payload+ try {+ const payload = JSON.parse(atob(token.split('.')[1]));+ const exp = payload.exp;+ const now = Math.floor(Date.now() / 1000);++ // Refresh if token expires in less than 1 hour+ if (exp && exp - now < 3600) {+ try {+ const refreshed = await getClient().auth.refresh({ token });+ await setAccessToken(refreshed.token);+ return { token: refreshed.token };+ } catch {+ // Refresh failed — use existing token, it might still work+ }+ }+ } catch {+ // Can't decode JWT — use it as-is, the server will reject if invalid+ }++ return { token };+}++/**+ * Execute an authenticated request with automatic token refresh on 401.+ * @param fn - Function that takes RequestOptions and returns a promise+ * @returns The result of the function+ * @throws SpreeError if auth fails after refresh attempt+ */+export async function withAuthRefresh<T>(+ fn: (options: RequestOptions) => Promise<T>+): Promise<T> {+ const options = await getAuthOptions();++ if (!options.token) {+ throw new Error('Not authenticated');+ }++ try {+ return await fn(options);+ } catch (error: unknown) {+ // If 401, try refreshing the token once+ if (error instanceof SpreeError && error.status === 401) {+ try {+ const refreshed = await getClient().auth.refresh({ token: options.token });+ await setAccessToken(refreshed.token);+ return await fn({ token: refreshed.token });+ } catch {+ // Refresh failed — clear token and rethrow+ await clearAccessToken();+ throw error;+ }+ }+ throw error;+ }+}diff --git a/packages/next/src/config.ts b/packages/next/src/config.tsnew file mode 100644index 0000000000..9a397d61ab--- /dev/null+++ b/packages/next/src/config.ts@@ -0,0 +1,57 @@+import { createSpreeClient, type SpreeClient } from '@spree/sdk';+import type { SpreeNextConfig } from './types';++let _client: SpreeClient | null = null;+let _config: SpreeNextConfig | null = null;++/**+ * Initialize the Spree Next.js integration.+ * Call this once in your app (e.g., in `lib/storefront.ts`).+ * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_API_KEY env vars.+ */+export function initSpreeNext(config: SpreeNextConfig): void {+ _config = config;+ _client = createSpreeClient({+ baseUrl: config.baseUrl,+ apiKey: config.apiKey,+ });+}++/**+ * Get the SpreeClient instance. Auto-initializes from env vars if needed.+ * @internal+ */+export function getClient(): SpreeClient {+ if (!_client) {+ const baseUrl = process.env.SPREE_API_URL;+ const apiKey = process.env.SPREE_API_KEY;+ if (baseUrl && apiKey) {+ initSpreeNext({ baseUrl, apiKey });+ } else {+ throw new Error(+ '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables.'+ );+ }+ }+ return _client!;+}++/**+ * Get the current config. Auto-initializes from env vars if needed.+ * @internal+ */+export function getConfig(): SpreeNextConfig {+ if (!_config) {+ getClient(); // triggers auto-init+ }+ return _config!;+}++/**+ * Reset the client (useful for testing).+ * @internal+ */+export function resetClient(): void {+ _client = null;+ _config = null;+}diff --git a/packages/next/src/cookies.ts b/packages/next/src/cookies.tsnew file mode 100644index 0000000000..63905dde69--- /dev/null+++ b/packages/next/src/cookies.ts@@ -0,0 +1,75 @@+import { cookies } from 'next/headers';+import { getConfig } from './config';++const DEFAULT_CART_COOKIE = '_spree_cart_token';+const DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';+const CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days+const ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days++function getCartCookieName(): string {+ try {+ return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;+ } catch {+ return DEFAULT_CART_COOKIE;+ }+}++function getAccessTokenCookieName(): string {+ try {+ return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;+ } catch {+ return DEFAULT_ACCESS_TOKEN_COOKIE;+ }+}++// --- Cart Token ---++export async function getCartToken(): Promise<string | undefined> {+ const cookieStore = await cookies();+ return cookieStore.get(getCartCookieName())?.value;+}++export async function setCartToken(token: string): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === 'production',+ sameSite: 'lax',+ path: '/',+ maxAge: CART_TOKEN_MAX_AGE,+ });+}++export async function clearCartToken(): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getCartCookieName(), '', {+ maxAge: -1,+ path: '/',+ });+}++// --- Access Token (JWT) ---++export async function getAccessToken(): Promise<string | undefined> {+ const cookieStore = await cookies();+ return cookieStore.get(getAccessTokenCookieName())?.value;+}++export async function setAccessToken(token: string): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === 'production',+ sameSite: 'lax',+ path: '/',+ maxAge: ACCESS_TOKEN_MAX_AGE,+ });+}++export async function clearAccessToken(): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getAccessTokenCookieName(), '', {+ maxAge: -1,+ path: '/',+ });+}diff --git a/packages/next/src/data/countries.ts b/packages/next/src/data/countries.tsnew file mode 100644index 0000000000..2a9c632672--- /dev/null+++ b/packages/next/src/data/countries.ts@@ -0,0 +1,28 @@+import type { StoreCountry } from '@spree/sdk';+import { getClient } from '../config';+import type { SpreeNextOptions } from '../types';++/**+ * List all available countries.+ */+export async function listCountries(+ options?: SpreeNextOptions+): Promise<{ data: StoreCountry[] }> {+ return getClient().countries.list({+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * Get a single country by ISO code.+ */+export async function getCountry(+ iso: string,+ options?: SpreeNextOptions+): Promise<StoreCountry> {+ return getClient().countries.get(iso, {+ locale: options?.locale,+ currency: options?.currency,+ });+}diff --git a/packages/next/src/data/products.ts b/packages/next/src/data/products.tsnew file mode 100644index 0000000000..258763a635--- /dev/null+++ b/packages/next/src/data/products.ts@@ -0,0 +1,43 @@+import type { StoreProduct, PaginatedResponse, ProductFiltersResponse } from '@spree/sdk';+import { getClient } from '../config';+import type { SpreeNextOptions } from '../types';++/**+ * List products with optional filtering, sorting, and pagination.+ */+export async function listProducts(+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<PaginatedResponse<StoreProduct>> {+ return getClient().products.list(params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * Get a single product by slug or ID.+ */+export async function getProduct(+ slugOrId: string,+ params?: { includes?: string },+ options?: SpreeNextOptions+): Promise<StoreProduct> {+ return getClient().products.get(slugOrId, params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * Get available product filters (price ranges, option values, etc.).+ */+export async function getProductFilters(+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<ProductFiltersResponse> {+ return getClient().products.filters(params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}diff --git a/packages/next/src/data/store.ts b/packages/next/src/data/store.tsnew file mode 100644index 0000000000..92bfdc1b8e--- /dev/null+++ b/packages/next/src/data/store.ts@@ -0,0 +1,13 @@+import type { StoreStore } from '@spree/sdk';+import { getClient } from '../config';+import type { SpreeNextOptions } from '../types';++/**+ * Get the current store configuration.+ */+export async function getStore(options?: SpreeNextOptions): Promise<StoreStore> {+ return getClient().store.get({+ locale: options?.locale,+ currency: options?.currency,+ });+}diff --git a/packages/next/src/data/taxonomies.ts b/packages/next/src/data/taxonomies.tsnew file mode 100644index 0000000000..df70ff7d29--- /dev/null+++ b/packages/next/src/data/taxonomies.ts@@ -0,0 +1,30 @@+import type { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';+import { getClient } from '../config';+import type { SpreeNextOptions } from '../types';++/**+ * List taxonomies with optional filtering and pagination.+ */+export async function listTaxonomies(+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<PaginatedResponse<StoreTaxonomy>> {+ return getClient().taxonomies.list(params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * Get a single taxonomy by ID.+ */+export async function getTaxonomy(+ id: string,+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<StoreTaxonomy> {+ return getClient().taxonomies.get(id, params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}diff --git a/packages/next/src/data/taxons.ts b/packages/next/src/data/taxons.tsnew file mode 100644index 0000000000..3eee6f4fc0--- /dev/null+++ b/packages/next/src/data/taxons.ts@@ -0,0 +1,44 @@+import type { StoreTaxon, StoreProduct, PaginatedResponse } from '@spree/sdk';+import { getClient } from '../config';+import type { SpreeNextOptions } from '../types';++/**+ * List taxons (categories) with optional filtering and pagination.+ */+export async function listTaxons(+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<PaginatedResponse<StoreTaxon>> {+ return getClient().taxons.list(params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * Get a single taxon by ID or permalink.+ */+export async function getTaxon(+ idOrPermalink: string,+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<StoreTaxon> {+ return getClient().taxons.get(idOrPermalink, params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}++/**+ * List products within a taxon.+ */+export async function listTaxonProducts(+ taxonId: string,+ params?: Record<string, unknown>,+ options?: SpreeNextOptions+): Promise<PaginatedResponse<StoreProduct>> {+ return getClient().taxons.products.list(taxonId, params, {+ locale: options?.locale,+ currency: options?.currency,+ });+}diff --git a/packages/next/src/index.ts b/packages/next/src/index.tsnew file mode 100644index 0000000000..fb1170c364--- /dev/null+++ b/packages/next/src/index.ts@@ -0,0 +1,82 @@+// Configuration+export { initSpreeNext, getClient } from './config';+export type { SpreeNextConfig, SpreeNextOptions } from './types';++// Data reads (plain async functions — wrap with "use cache" in your app)+export { listProducts, getProduct, getProductFilters } from './data/products';+export { listTaxons, getTaxon, listTaxonProducts } from './data/taxons';+export { listTaxonomies, getTaxonomy } from './data/taxonomies';+export { getStore } from './data/store';+export { listCountries, getCountry } from './data/countries';++// Server actions (mutations + auth-dependent reads)+export {+ getCart,+ getOrCreateCart,+ addItem,+ updateItem,+ removeItem,+ clearCart,+ associateCart,+} from './actions/cart';++export {+ getCheckout,+ updateAddresses,+ advance,+ next,+ getShipments,+ selectShippingRate,+ applyCoupon,+ removeCoupon,+ complete,+} from './actions/checkout';++export {+ login,+ register,+ logout,+ getCustomer,+ updateCustomer,+} from './actions/auth';++export {+ listAddresses,+ getAddress,+ createAddress,+ updateAddress,+ deleteAddress,+} from './actions/addresses';++export { listOrders, getOrder } from './actions/orders';+export { listCreditCards, deleteCreditCard } from './actions/credit-cards';+export { listGiftCards, getGiftCard } from './actions/gift-cards';++// Re-export commonly used SDK types for convenience+export type {+ StoreProduct,+ StoreOrder,+ StoreLineItem,+ StoreVariant,+ StoreTaxon,+ StoreTaxonomy,+ StoreCountry,+ StoreStore,+ StoreAddress,+ StoreUser,+ StoreCreditCard,+ StoreGiftCard,+ StoreShipment,+ StoreShippingRate,+ StorePayment,+ StorePaymentMethod,+ StoreImage,+ StoreOptionType,+ StoreOptionValue,+ StorePrice,+ StoreOrderPromotion,+ PaginatedResponse,+ AddressParams,+ ProductFiltersResponse,+ SpreeError,+} from '@spree/sdk';diff --git a/packages/next/src/types.ts b/packages/next/src/types.tsnew file mode 100644index 0000000000..475bd7e683--- /dev/null+++ b/packages/next/src/types.ts@@ -0,0 +1,21 @@+export interface SpreeNextConfig {+ /** Base URL of the Spree API (e.g., 'https://api.mystore.com') */+ baseUrl: string;+ /** Publishable API key for store access */+ apiKey: string;+ /** Cookie name for the cart order token (default: '_spree_cart_token') */+ cartCookieName?: string;+ /** Cookie name for the JWT access token (default: '_spree_jwt') */+ accessTokenCookieName?: string;+ /** Default locale for API requests */+ defaultLocale?: string;+ /** Default currency for API requests */+ defaultCurrency?: string;+}++export interface SpreeNextOptions {+ /** Locale for translated content (e.g., 'en', 'fr') */+ locale?: string;+ /** Currency for prices (e.g., 'USD', 'EUR') */+ currency?: string;+}diff --git a/packages/next/tests/actions/auth.test.ts b/packages/next/tests/actions/auth.test.tsnew file mode 100644index 0000000000..09d31bbb24--- /dev/null+++ b/packages/next/tests/actions/auth.test.ts@@ -0,0 +1,117 @@+import { describe, it, expect, beforeEach, vi } from 'vitest';+import { mockCookieStore } from '../setup';+import { initSpreeNext, resetClient } from '../../src/config';++const mockClient = {+ auth: {+ login: vi.fn(),+ register: vi.fn(),+ refresh: vi.fn(),+ },+ customer: {+ get: vi.fn(),+ update: vi.fn(),+ },+ cart: {+ associate: vi.fn(),+ },+};++vi.mock('@spree/sdk', () => ({+ createSpreeClient: vi.fn(() => mockClient),+ SpreeError: class SpreeError extends Error {+ public readonly code: string;+ public readonly status: number;+ constructor(response: { error: { code: string; message: string } }, status: number) {+ super(response.error.message);+ this.code = response.error.code;+ this.status = status;+ }+ },+}));++import { login, register, logout, getCustomer, updateCustomer } from '../../src/actions/auth';+import { revalidateTag } from 'next/cache';++describe('auth actions', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ resetClient();+ initSpreeNext({ baseUrl: 'https://api.test.com', apiKey: 'pk_test' });+ });++ describe('login', () => {+ it('returns user on success and sets token', async () => {+ const authResult = {+ token: 'jwt_new',+ user: { id: '1', email: '[email protected]', first_name: 'Test', last_name: 'User' },+ };+ mockCookieStore.get.mockReturnValue(undefined); // no cart token+ mockClient.auth.login.mockResolvedValue(authResult);++ const result = await login('[email protected]', 'password123');+ expect(result.success).toBe(true);+ expect(result.user).toEqual(authResult.user);+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_jwt',+ 'jwt_new',+ expect.any(Object)+ );+ expect(revalidateTag).toHaveBeenCalledWith('customer');+ });++ it('associates guest cart after login', async () => {+ const authResult = { token: 'jwt_new', user: { id: '1', email: '[email protected]' } };+ mockCookieStore.get+ .mockReturnValueOnce({ value: 'guest_cart_token' }); // getCartToken+ mockClient.auth.login.mockResolvedValue(authResult);+ mockClient.cart.associate.mockResolvedValue({});++ await login('[email protected]', 'pass');+ expect(mockClient.cart.associate).toHaveBeenCalledWith({+ token: 'jwt_new',+ orderToken: 'guest_cart_token',+ });+ });++ it('returns error on failure', async () => {+ mockClient.auth.login.mockRejectedValue(new Error('Invalid credentials'));++ const result = await login('[email protected]', 'wrong');+ expect(result.success).toBe(false);+ expect(result.error).toBe('Invalid credentials');+ });+ });++ describe('logout', () => {+ it('clears access token and invalidates caches', async () => {+ await logout();+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_jwt',+ '',+ expect.objectContaining({ maxAge: -1 })+ );+ expect(revalidateTag).toHaveBeenCalledWith('customer');+ expect(revalidateTag).toHaveBeenCalledWith('cart');+ expect(revalidateTag).toHaveBeenCalledWith('addresses');+ expect(revalidateTag).toHaveBeenCalledWith('credit-cards');+ });+ });++ describe('getCustomer', () => {+ it('returns null when not authenticated', async () => {+ mockCookieStore.get.mockReturnValue(undefined);+ const customer = await getCustomer();+ expect(customer).toBeNull();+ });++ it('returns customer when authenticated', async () => {+ const mockUser = { id: '1', email: '[email protected]' };+ mockCookieStore.get.mockReturnValue({ value: 'valid_jwt' });+ mockClient.customer.get.mockResolvedValue(mockUser);++ const customer = await getCustomer();+ expect(customer).toEqual(mockUser);+ });+ });+});diff --git a/packages/next/tests/actions/cart.test.ts b/packages/next/tests/actions/cart.test.tsnew file mode 100644index 0000000000..cce87d12b8--- /dev/null+++ b/packages/next/tests/actions/cart.test.ts@@ -0,0 +1,161 @@+import { describe, it, expect, beforeEach, vi } from 'vitest';+import { mockCookieStore } from '../setup';+import { initSpreeNext, resetClient } from '../../src/config';++// Mock the SDK client+const mockClient = {+ cart: {+ get: vi.fn(),+ create: vi.fn(),+ associate: vi.fn(),+ },+ orders: {+ lineItems: {+ create: vi.fn(),+ update: vi.fn(),+ delete: vi.fn(),+ },+ },+};++vi.mock('@spree/sdk', () => ({+ createSpreeClient: vi.fn(() => mockClient),+}));++import { getCart, getOrCreateCart, addItem, updateItem, removeItem, clearCart, associateCart } from '../../src/actions/cart';+import { revalidateTag } from 'next/cache';++describe('cart actions', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ resetClient();+ initSpreeNext({ baseUrl: 'https://api.test.com', apiKey: 'pk_test' });+ });++ describe('getCart', () => {+ it('returns null when no tokens exist', async () => {+ mockCookieStore.get.mockReturnValue(undefined);+ const cart = await getCart();+ expect(cart).toBeNull();+ });++ it('returns cart when order token exists', async () => {+ const mockCart = { id: '1', token: 'order_abc', line_items: [] };+ mockCookieStore.get.mockReturnValue({ value: 'order_abc' });+ mockClient.cart.get.mockResolvedValue(mockCart);++ const cart = await getCart();+ expect(cart).toEqual(mockCart);+ expect(mockClient.cart.get).toHaveBeenCalledWith(+ expect.objectContaining({ orderToken: 'order_abc' })+ );+ });++ it('returns null when cart fetch fails', async () => {+ mockCookieStore.get.mockReturnValue({ value: 'bad_token' });+ mockClient.cart.get.mockRejectedValue(new Error('Not found'));++ const cart = await getCart();+ expect(cart).toBeNull();+ });+ });++ describe('getOrCreateCart', () => {+ it('returns existing cart if available', async () => {+ const mockCart = { id: '1', token: 'existing', line_items: [] };+ mockCookieStore.get.mockReturnValue({ value: 'existing' });+ mockClient.cart.get.mockResolvedValue(mockCart);++ const cart = await getOrCreateCart();+ expect(cart).toEqual(mockCart);+ expect(mockClient.cart.create).not.toHaveBeenCalled();+ });++ it('creates new cart when none exists', async () => {+ const newCart = { id: '2', token: 'new_token', line_items: [] };+ mockCookieStore.get.mockReturnValue(undefined);+ mockClient.cart.create.mockResolvedValue(newCart);++ const cart = await getOrCreateCart();+ expect(cart).toEqual(newCart);+ expect(mockClient.cart.create).toHaveBeenCalled();+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_cart_token',+ 'new_token',+ expect.any(Object)+ );+ });+ });++ describe('addItem', () => {+ it('adds line item and invalidates cache', async () => {+ const mockCart = { id: '1', token: 'cart_token', line_items: [] };+ const mockLineItem = { id: 'li_1', quantity: 2, variant_id: 'v1' };+ mockCookieStore.get.mockReturnValue({ value: 'cart_token' });+ mockClient.cart.get.mockResolvedValue(mockCart);+ mockClient.orders.lineItems.create.mockResolvedValue(mockLineItem);++ const result = await addItem('v1', 2);+ expect(result).toEqual(mockLineItem);+ expect(mockClient.orders.lineItems.create).toHaveBeenCalledWith(+ '1',+ { variant_id: 'v1', quantity: 2 },+ expect.objectContaining({ orderToken: 'cart_token' })+ );+ expect(revalidateTag).toHaveBeenCalledWith('cart');+ });+ });++ describe('removeItem', () => {+ it('deletes line item and invalidates cache', async () => {+ const mockCart = { id: '1', token: 'cart_token' };+ mockCookieStore.get.mockReturnValue({ value: 'cart_token' });+ mockClient.cart.get.mockResolvedValue(mockCart);+ mockClient.orders.lineItems.delete.mockResolvedValue(undefined);++ await removeItem('li_1');+ expect(mockClient.orders.lineItems.delete).toHaveBeenCalledWith(+ '1',+ 'li_1',+ expect.objectContaining({ orderToken: 'cart_token' })+ );+ expect(revalidateTag).toHaveBeenCalledWith('cart');+ });+ });++ describe('clearCart', () => {+ it('clears cart cookie and invalidates cache', async () => {+ await clearCart();+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_cart_token',+ '',+ expect.objectContaining({ maxAge: -1 })+ );+ expect(revalidateTag).toHaveBeenCalledWith('cart');+ });+ });++ describe('associateCart', () => {+ it('returns null when no cart token', async () => {+ mockCookieStore.get.mockReturnValue(undefined);+ const result = await associateCart();+ expect(result).toBeNull();+ });++ it('associates cart when both tokens exist', async () => {+ const mockCart = { id: '1', token: 'cart_token' };+ // First call returns cart token, second returns access token+ mockCookieStore.get+ .mockReturnValueOnce({ value: 'cart_token' })+ .mockReturnValueOnce({ value: 'jwt_token' });+ mockClient.cart.associate.mockResolvedValue(mockCart);++ const result = await associateCart();+ expect(result).toEqual(mockCart);+ expect(mockClient.cart.associate).toHaveBeenCalledWith({+ orderToken: 'cart_token',+ token: 'jwt_token',+ });+ });+ });+});diff --git a/packages/next/tests/config.test.ts b/packages/next/tests/config.test.tsnew file mode 100644index 0000000000..0e7173f4a7--- /dev/null+++ b/packages/next/tests/config.test.ts@@ -0,0 +1,27 @@+import { describe, it, expect, beforeEach } from 'vitest';+import { initSpreeNext, getClient, resetClient } from '../src/config';++describe('config', () => {+ beforeEach(() => {+ resetClient();+ delete process.env.SPREE_API_URL;+ delete process.env.SPREE_API_KEY;+ });++ it('initializes from explicit config', () => {+ initSpreeNext({ baseUrl: 'https://api.test.com', apiKey: 'pk_test' });+ const client = getClient();+ expect(client).toBeDefined();+ });++ it('auto-initializes from env vars', () => {+ process.env.SPREE_API_URL = 'https://api.env.com';+ process.env.SPREE_API_KEY = 'pk_env';+ const client = getClient();+ expect(client).toBeDefined();+ });++ it('throws when no config and no env vars', () => {+ expect(() => getClient()).toThrow('@spree/next is not configured');+ });+});diff --git a/packages/next/tests/cookies.test.ts b/packages/next/tests/cookies.test.tsnew file mode 100644index 0000000000..e10a842bc9--- /dev/null+++ b/packages/next/tests/cookies.test.ts@@ -0,0 +1,86 @@+import { describe, it, expect, beforeEach, vi } from 'vitest';+import { mockCookieStore } from './setup';+import {+ getCartToken,+ setCartToken,+ clearCartToken,+ getAccessToken,+ setAccessToken,+ clearAccessToken,+} from '../src/cookies';++describe('cookies', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ describe('cart token', () => {+ it('reads cart token from cookies', async () => {+ mockCookieStore.get.mockReturnValue({ value: 'cart_abc123' });+ const token = await getCartToken();+ expect(token).toBe('cart_abc123');+ expect(mockCookieStore.get).toHaveBeenCalledWith('_spree_cart_token');+ });++ it('returns undefined when no cart token', async () => {+ mockCookieStore.get.mockReturnValue(undefined);+ const token = await getCartToken();+ expect(token).toBeUndefined();+ });++ it('sets cart token with httpOnly cookie', async () => {+ await setCartToken('cart_new');+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_cart_token',+ 'cart_new',+ expect.objectContaining({+ httpOnly: true,+ sameSite: 'lax',+ path: '/',+ maxAge: 60 * 60 * 24 * 30,+ })+ );+ });++ it('clears cart token', async () => {+ await clearCartToken();+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_cart_token',+ '',+ expect.objectContaining({ maxAge: -1 })+ );+ });+ });++ describe('access token', () => {+ it('reads access token from cookies', async () => {+ mockCookieStore.get.mockReturnValue({ value: 'jwt_token_xyz' });+ const token = await getAccessToken();+ expect(token).toBe('jwt_token_xyz');+ expect(mockCookieStore.get).toHaveBeenCalledWith('_spree_jwt');+ });++ it('sets access token with httpOnly cookie', async () => {+ await setAccessToken('jwt_new');+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_jwt',+ 'jwt_new',+ expect.objectContaining({+ httpOnly: true,+ sameSite: 'lax',+ path: '/',+ maxAge: 60 * 60 * 24 * 7,+ })+ );+ });++ it('clears access token', async () => {+ await clearAccessToken();+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_jwt',+ '',+ expect.objectContaining({ maxAge: -1 })+ );+ });+ });+});diff --git a/packages/next/tests/setup.ts b/packages/next/tests/setup.tsnew file mode 100644index 0000000000..cae1a8d54b--- /dev/null+++ b/packages/next/tests/setup.ts@@ -0,0 +1,21 @@+import { vi } from 'vitest';++// Mock next/headers+const mockCookieStore = {+ get: vi.fn(),+ set: vi.fn(),+ delete: vi.fn(),+};++vi.mock('next/headers', () => ({+ cookies: vi.fn(() => Promise.resolve(mockCookieStore)),+}));++// Mock next/cache+vi.mock('next/cache', () => ({+ cacheTag: vi.fn(),+ cacheLife: vi.fn(),+ revalidateTag: vi.fn(),+}));++export { mockCookieStore };diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.jsonnew file mode 100644index 0000000000..d14d224772--- /dev/null+++ b/packages/next/tsconfig.json@@ -0,0 +1,24 @@+{+ "compilerOptions": {+ "target": "ES2022",+ "module": "ESNext",+ "moduleResolution": "bundler",+ "lib": ["ES2022"],+ "strict": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "declaration": true,+ "declarationMap": true,+ "sourceMap": true,+ "outDir": "./dist",+ "rootDir": "./src",+ "noUnusedLocals": true,+ "noUnusedParameters": true,+ "noImplicitReturns": true,+ "noFallthroughCasesInSwitch": true,+ "jsx": "react-jsx"+ },+ "include": ["src"],+ "exclude": ["node_modules", "dist", "tests"]+}diff --git a/packages/next/tsup.config.ts b/packages/next/tsup.config.tsnew file mode 100644index 0000000000..a05591a7d8--- /dev/null+++ b/packages/next/tsup.config.ts@@ -0,0 +1,41 @@+import { defineConfig } from 'tsup';++export default defineConfig([+ // Plain modules (no directive) — config, types, data reads+ {+ entry: {+ index: 'src/index.ts',+ config: 'src/config.ts',+ types: 'src/types.ts',+ 'data/products': 'src/data/products.ts',+ 'data/taxons': 'src/data/taxons.ts',+ 'data/taxonomies': 'src/data/taxonomies.ts',+ 'data/store': 'src/data/store.ts',+ 'data/countries': 'src/data/countries.ts',+ },+ format: ['esm'],+ dts: true,+ splitting: false,+ sourcemap: true,+ clean: true,+ treeshake: true,+ external: ['next', 'next/cache', 'next/headers', '@spree/sdk', 'react'],+ },+ // Server action files — need "use server" banner preserved+ {+ entry: {+ 'actions/cart': 'src/actions/cart.ts',+ 'actions/checkout': 'src/actions/checkout.ts',+ 'actions/auth': 'src/actions/auth.ts',+ 'actions/addresses': 'src/actions/addresses.ts',+ 'actions/orders': 'src/actions/orders.ts',+ 'actions/credit-cards': 'src/actions/credit-cards.ts',+ 'actions/gift-cards': 'src/actions/gift-cards.ts',+ },+ format: ['esm'],+ dts: true,+ splitting: false,+ sourcemap: true,+ external: ['next', 'next/cache', 'next/headers', '@spree/sdk', 'react'],+ },+]);diff --git a/packages/next/vitest.config.ts b/packages/next/vitest.config.tsnew file mode 100644index 0000000000..bb6c7c414f--- /dev/null+++ b/packages/next/vitest.config.ts@@ -0,0 +1,9 @@+import { defineConfig } from 'vitest/config';++export default defineConfig({+ test: {+ environment: 'node',+ setupFiles: ['./tests/setup.ts'],+ include: ['tests/**/*.test.ts'],+ },+});diff --git a/packages/sdk/package-lock.json b/packages/sdk/package-lock.jsonindex a1380ddfa0..a2ce8aea1e 100644--- a/packages/sdk/package-lock.json+++ b/packages/sdk/package-lock.json@@ -1,13 +1,13 @@{"name": "@spree/sdk",- "version": "0.1.0",+ "version": "0.1.4","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@spree/sdk",- "version": "0.1.0",- "license": "BSD-3-Clause",+ "version": "0.1.4",+ "license": "MIT","devDependencies": {"@changesets/changelog-github": "^0.5.2","@changesets/cli": "^2.29.8",@@ -17,17 +17,22 @@"tsup": "^8.0.0","tsx": "^4.0.0","typescript": "^5.3.0",- "vitest": "^4.0.18"+ "vitest": "^4.0.18",+ "zod": "^4.3.6"},"engines": {"node": ">=18.0.0"},"peerDependencies": {- "typescript": ">=4.7.0"+ "typescript": ">=4.7.0",+ "zod": ">=3.0.0"},"peerDependenciesMeta": {"typescript": {"optional": true+ },+ "zod": {+ "optional": true}}},@@ -4109,6 +4114,16 @@"funding": {"url": "https://github.com/sponsors/sindresorhus"}+ },+ "node_modules/zod": {+ "version": "4.3.6",+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",+ "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/colinhacks"+ }}}}diff --git a/packages/sdk/package.json b/packages/sdk/package.jsonindex e605c382fd..ff9b4e76e2 100644--- a/packages/sdk/package.json+++ b/packages/sdk/package.json@@ -26,6 +26,16 @@"types": "./dist/types/index.d.cts","default": "./dist/types/index.cjs"}+ },+ "./zod": {+ "import": {+ "types": "./dist/zod/index.d.ts",+ "default": "./dist/zod/index.js"+ },+ "require": {+ "types": "./dist/zod/index.d.cts",+ "default": "./dist/zod/index.cjs"+ }}},"files": [@@ -33,6 +43,7 @@"README.md"],"scripts": {+ "generate:zod": "tsx scripts/generate-zod.ts","build": "tsup","dev": "tsup --watch","console": "tsx console.ts",@@ -75,14 +86,19 @@"tsup": "^8.0.0","tsx": "^4.0.0","typescript": "^5.3.0",- "vitest": "^4.0.18"+ "vitest": "^4.0.18",+ "zod": "^4.3.6"},"peerDependencies": {- "typescript": ">=4.7.0"+ "typescript": ">=4.7.0",+ "zod": ">=3.0.0"},"peerDependenciesMeta": {"typescript": {"optional": true+ },+ "zod": {+ "optional": true}},"engines": {diff --git a/packages/sdk/scripts/generate-zod.ts b/packages/sdk/scripts/generate-zod.tsnew file mode 100644index 0000000000..d07ef08ec3--- /dev/null+++ b/packages/sdk/scripts/generate-zod.ts@@ -0,0 +1,270 @@+import * as fs from 'node:fs';+import * as path from 'node:path';++const TYPES_DIR = path.resolve(import.meta.dirname, '../src/types/generated');+const ZOD_DIR = path.resolve(import.meta.dirname, '../src/zod/generated');++interface FieldDef {+ name: string;+ type: string;+ optional: boolean;+}++interface ParsedType {+ typeName: string;+ fields: FieldDef[];+}++function parseTypeFile(content: string): ParsedType | null {+ const typeNameMatch = content.match(/^type\s+(\w+)\s*=\s*\{/m);+ if (!typeNameMatch) return null;+ const typeName = typeNameMatch[1];++ const bodyMatch = content.match(/type\s+\w+\s*=\s*\{([\s\S]*?)\}/);+ if (!bodyMatch) return null;++ const body = bodyMatch[1];+ const fields: FieldDef[] = [];+ const fieldRegex = /^\s+(\w+)(\?)?\s*:\s*(.+?)\s*;?\s*$/gm;+ let match: RegExpExecArray | null;+ while ((match = fieldRegex.exec(body)) !== null) {+ fields.push({+ name: match[1],+ type: match[3].replace(/;$/, '').trim(),+ optional: match[2] === '?',+ });+ }++ return { typeName, fields };+}++function isTypeReference(typeStr: string): boolean {+ return /^[A-Z]\w+$/.test(typeStr);+}++function isPrimitive(t: string): boolean {+ return t === 'string' || t === 'number' || t === 'boolean';+}++function primitiveOrRef(inner: string, referencedTypes: Set<string>, cyclicTypes: Set<string>): string {+ if (isPrimitive(inner)) return `z.${inner}()`;+ if (isTypeReference(inner)) {+ referencedTypes.add(inner);+ if (cyclicTypes.has(inner)) {+ return `z.lazy(() => ${inner}Schema)`;+ }+ return `${inner}Schema`;+ }+ return 'z.any()';+}++function typeToZod(typeStr: string, referencedTypes: Set<string>, cyclicTypes: Set<string>): string {+ const t = typeStr.trim();++ // Record<string, unknown> | null+ if (/^Record<string,\s*unknown>\s*\|\s*null$/.test(t)) {+ return 'z.record(z.string(), z.unknown()).nullable()';+ }+ if (/^Record<string,\s*unknown>$/.test(t)) {+ return 'z.record(z.string(), z.unknown())';+ }+ if (t === 'any') return 'z.any()';++ // Array<T> | null+ const arrayNullableMatch = t.match(/^Array<(.+)>\s*\|\s*null$/);+ if (arrayNullableMatch) {+ return `z.array(${primitiveOrRef(arrayNullableMatch[1].trim(), referencedTypes, cyclicTypes)}).nullable()`;+ }++ // Array<T>+ const arrayMatch = t.match(/^Array<(.+)>$/);+ if (arrayMatch) {+ return `z.array(${primitiveOrRef(arrayMatch[1].trim(), referencedTypes, cyclicTypes)})`;+ }++ // String literal unions: 'a' | 'b' | 'c'+ if (/^'[^']*'(\s*\|\s*'[^']*')+$/.test(t)) return 'z.string()';+ // String literal union | null+ if (/^'[^']*'(\s*\|\s*'[^']*')*\s*\|\s*null$/.test(t)) return 'z.string().nullable()';++ // T | null+ const nullableMatch = t.match(/^(\w+)\s*\|\s*null$/);+ if (nullableMatch) {+ const base = nullableMatch[1].trim();+ if (isPrimitive(base)) return `z.${base}().nullable()`;+ if (isTypeReference(base)) {+ referencedTypes.add(base);+ if (cyclicTypes.has(base)) {+ return `z.lazy(() => ${base}Schema).nullable()`;+ }+ return `${base}Schema.nullable()`;+ }+ }++ // Simple primitive+ if (isPrimitive(t)) return `z.${t}()`;++ // Type reference+ if (isTypeReference(t)) {+ referencedTypes.add(t);+ if (cyclicTypes.has(t)) {+ return `z.lazy(() => ${t}Schema)`;+ }+ return `${t}Schema`;+ }++ return 'z.any()';+}++function generateZodFile(parsed: ParsedType, cyclicTypes: Set<string>): string {+ const referencedTypes = new Set<string>();+ const fieldLines: string[] = [];++ for (const field of parsed.fields) {+ let zodExpr = typeToZod(field.type, referencedTypes, cyclicTypes);+ if (field.optional) zodExpr += '.optional()';+ fieldLines.push(` ${field.name}: ${zodExpr},`);+ }++ // Don't import self-references (self-referencing types use z.lazy)+ const refImports = Array.from(referencedTypes)+ .filter((ref) => ref !== parsed.typeName)+ .sort()+ .map((ref) => `import { ${ref}Schema } from './${ref}';`);++ const isCyclic = cyclicTypes.has(parsed.typeName);++ // For cyclic types, add explicit type annotation to break circular inference+ const schemaDecl = isCyclic+ ? `export const ${parsed.typeName}Schema: z.ZodObject<any> = z.object({`+ : `export const ${parsed.typeName}Schema = z.object({`;++ const lines: string[] = [+ '// This file is auto-generated. Do not edit directly.',+ "import { z } from 'zod';",+ ...refImports,+ '',+ schemaDecl,+ ...fieldLines,+ '});',+ '',+ `export type ${parsed.typeName} = z.infer<typeof ${parsed.typeName}Schema>;`,+ '',+ ];++ return lines.join('\n');+}++/** Extract type references from field types */+function extractTypeRefs(fields: FieldDef[]): Set<string> {+ const refs = new Set<string>();+ for (const field of fields) {+ const t = field.type.trim();+ // Array<T>+ const arrayMatch = t.match(/Array<(\w+)>/);+ if (arrayMatch && isTypeReference(arrayMatch[1])) refs.add(arrayMatch[1]);+ // T | null+ const nullableMatch = t.match(/^(\w+)\s*\|\s*null$/);+ if (nullableMatch && isTypeReference(nullableMatch[1])) refs.add(nullableMatch[1]);+ // Plain T+ if (isTypeReference(t)) refs.add(t);+ }+ return refs;+}++/** Detect all types involved in circular dependencies */+function detectCyclicTypes(parsedTypes: Map<string, ParsedType>): Set<string> {+ const deps = new Map<string, Set<string>>();+ for (const [name, parsed] of parsedTypes) {+ deps.set(name, extractTypeRefs(parsed.fields));+ }++ const cyclic = new Set<string>();+ const visited = new Set<string>();+ const inStack = new Set<string>();++ function dfs(node: string, path: string[]): void {+ if (inStack.has(node)) {+ // Found a cycle — mark all nodes in the cycle+ const cycleStart = path.indexOf(node);+ for (let i = cycleStart; i < path.length; i++) {+ cyclic.add(path[i]);+ }+ return;+ }+ if (visited.has(node)) return;++ visited.add(node);+ inStack.add(node);+ path.push(node);++ for (const dep of deps.get(node) ?? []) {+ if (deps.has(dep)) {+ dfs(dep, path);+ }+ }++ path.pop();+ inStack.delete(node);+ }++ for (const name of deps.keys()) {+ dfs(name, []);+ }++ return cyclic;+}++function main(): void {+ if (fs.existsSync(ZOD_DIR)) {+ fs.rmSync(ZOD_DIR, { recursive: true });+ }+ fs.mkdirSync(ZOD_DIR, { recursive: true });++ const files = fs+ .readdirSync(TYPES_DIR)+ .filter((f) => f.endsWith('.ts') && f !== 'index.ts')+ .sort();++ // First pass: parse all type files+ const parsedTypes = new Map<string, ParsedType>();+ for (const file of files) {+ const filePath = path.join(TYPES_DIR, file);+ const content = fs.readFileSync(filePath, 'utf-8');+ const parsed = parseTypeFile(content);+ if (!parsed) {+ console.warn(`Skipping ${file}: could not parse type definition`);+ continue;+ }+ parsedTypes.set(parsed.typeName, parsed);+ }++ // Detect cycles+ const cyclicTypes = detectCyclicTypes(parsedTypes);+ if (cyclicTypes.size > 0) {+ console.log(`Detected circular dependencies: ${Array.from(cyclicTypes).join(', ')}`);+ console.log('Using z.lazy() for these references.\n');+ }++ const generatedNames: string[] = [];++ for (const [, parsed] of parsedTypes) {+ fs.writeFileSync(+ path.join(ZOD_DIR, `${parsed.typeName}.ts`),+ generateZodFile(parsed, cyclicTypes),+ 'utf-8'+ );+ generatedNames.push(parsed.typeName);+ console.log(`Generated: ${parsed.typeName}.ts`);+ }++ const indexLines = [+ '// This file is auto-generated. Do not edit directly.',+ ...generatedNames.map((n) => `export { ${n}Schema, type ${n} } from './${n}';`),+ '',+ ];+ fs.writeFileSync(path.join(ZOD_DIR, 'index.ts'), indexLines.join('\n'), 'utf-8');+ console.log(`\nGenerated barrel: index.ts (${generatedNames.length} schemas)`);+}++main();diff --git a/packages/sdk/src/client.ts b/packages/sdk/src/client.tsindex 5617436da2..407b3747bf 100644--- a/packages/sdk/src/client.ts+++ b/packages/sdk/src/client.ts@@ -35,6 +35,19 @@ import type {// Re-export types for convenienceexport type { AddressParams, StoreCreditCard };+export interface RetryConfig {+ /** Maximum number of retries (default: 2) */+ maxRetries?: number;+ /** HTTP status codes to retry on (default: [429, 500, 502, 503, 504]) */+ retryOnStatus?: number[];+ /** Base delay in ms for exponential backoff (default: 300) */+ baseDelay?: number;+ /** Maximum delay in ms (default: 10000) */+ maxDelay?: number;+ /** Whether to retry on network errors (default: true) */+ retryOnNetworkError?: boolean;+}+export interface SpreeClientConfig {/** Base URL of the Spree API (e.g., 'https://api.mystore.com') */baseUrl: string;@@ -42,6 +55,8 @@ export interface SpreeClientConfig {apiKey: string;/** Custom fetch implementation (optional, defaults to global fetch) */fetch?: typeof fetch;+ /** Retry configuration. Enabled by default. Pass false to disable. */+ retry?: RetryConfig | false;}export interface RequestOptions {@@ -75,12 +90,50 @@ export class SpreeClient {private readonly baseUrl: string;private readonly apiKey: string;private readonly fetchFn: typeof fetch;+ private readonly retryConfig: Required<RetryConfig> | false;constructor(config: SpreeClientConfig) {this.baseUrl = config.baseUrl.replace(/\/$/, '');this.apiKey = config.apiKey;// Bind fetch to globalThis to avoid "Illegal invocation" errors in browsersthis.fetchFn = config.fetch || fetch.bind(globalThis);++ if (config.retry === false) {+ this.retryConfig = false;+ } else {+ this.retryConfig = {+ maxRetries: config.retry?.maxRetries ?? 2,+ retryOnStatus: config.retry?.retryOnStatus ?? [429, 500, 502, 503, 504],+ baseDelay: config.retry?.baseDelay ?? 300,+ maxDelay: config.retry?.maxDelay ?? 10000,+ retryOnNetworkError: config.retry?.retryOnNetworkError ?? true,+ };+ }+ }++ private calculateDelay(attempt: number, config: Required<RetryConfig>): number {+ const exponentialDelay = config.baseDelay * Math.pow(2, attempt);+ const jitter = Math.random() * config.baseDelay;+ return Math.min(exponentialDelay + jitter, config.maxDelay);+ }++ private sleep(ms: number): Promise<void> {+ return new Promise((resolve) => setTimeout(resolve, ms));+ }++ private shouldRetryOnStatus(method: string, status: number, config: Required<RetryConfig>): boolean {+ const isIdempotent = method === 'GET' || method === 'HEAD';+ // Idempotent methods: retry on all configured statuses+ // Non-idempotent: only retry on 429 (rate limit)+ if (isIdempotent) {+ return config.retryOnStatus.includes(status);+ }+ return status === 429;+ }++ private shouldRetryOnNetworkError(method: string, config: Required<RetryConfig>): boolean {+ if (!config.retryOnNetworkError) return false;+ return method === 'GET' || method === 'HEAD';}private async request<T>(@@ -134,23 +187,57 @@ export class SpreeClient {requestHeaders['x-spree-currency'] = currency;}- const response = await this.fetchFn(url.toString(), {- method,- headers: requestHeaders,- body: body ? JSON.stringify(body) : undefined,- });+ const maxAttempts = this.retryConfig ? this.retryConfig.maxRetries + 1 : 1;++ for (let attempt = 0; attempt < maxAttempts; attempt++) {+ try {+ const response = await this.fetchFn(url.toString(), {+ method,+ headers: requestHeaders,+ body: body ? JSON.stringify(body) : undefined,+ });++ if (!response.ok) {+ const isLastAttempt = attempt >= maxAttempts - 1;++ if (!isLastAttempt && this.retryConfig && this.shouldRetryOnStatus(method, response.status, this.retryConfig)) {+ const retryAfter = response.headers.get('Retry-After');+ const delay = retryAfter+ ? Math.min(parseInt(retryAfter, 10) * 1000, this.retryConfig.maxDelay)+ : this.calculateDelay(attempt, this.retryConfig);+ await this.sleep(delay);+ continue;+ }- if (!response.ok) {- const errorBody = await response.json() as ErrorResponse;- throw new SpreeError(errorBody, response.status);- }+ const errorBody = await response.json() as ErrorResponse;+ throw new SpreeError(errorBody, response.status);+ }++ // Handle 204 No Content+ if (response.status === 204) {+ return undefined as T;+ }++ return response.json() as Promise<T>;+ } catch (error) {+ if (error instanceof SpreeError) {+ throw error;+ }++ const isLastAttempt = attempt >= maxAttempts - 1;++ if (!isLastAttempt && this.retryConfig && this.shouldRetryOnNetworkError(method, this.retryConfig)) {+ const delay = this.calculateDelay(attempt, this.retryConfig);+ await this.sleep(delay);+ continue;+ }- // Handle 204 No Content- if (response.status === 204) {- return undefined as T;+ throw error;+ }}- return response.json() as Promise<T>;+ // This should never be reached, but TypeScript needs it+ throw new Error('Unexpected end of retry loop');}// ============================================diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.tsindex 2567c7c5e9..5b1d920369 100644--- a/packages/sdk/src/index.ts+++ b/packages/sdk/src/index.ts@@ -1,6 +1,6 @@// Main clientexport { SpreeClient, SpreeError, createSpreeClient } from './client';-export type { SpreeClientConfig, RequestOptions } from './client';+export type { SpreeClientConfig, RequestOptions, RetryConfig } from './client';// All typesexport * from './types';diff --git a/packages/sdk/src/zod/generated/AdminMetafield.ts b/packages/sdk/src/zod/generated/AdminMetafield.tsnew file mode 100644index 0000000000..807918425c--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminMetafield.ts@@ -0,0 +1,13 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const AdminMetafieldSchema = z.object({+ id: z.string(),+ name: z.string(),+ type: z.string(),+ key: z.string(),+ value: z.any(),+ display_on: z.string(),+});++export type AdminMetafield = z.infer<typeof AdminMetafieldSchema>;diff --git a/packages/sdk/src/zod/generated/AdminOrder.ts b/packages/sdk/src/zod/generated/AdminOrder.tsnew file mode 100644index 0000000000..2453f1927d--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminOrder.ts@@ -0,0 +1,62 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminUserSchema } from './AdminUser';+import { StoreAddressSchema } from './StoreAddress';+import { StoreLineItemSchema } from './StoreLineItem';+import { StoreOrderPromotionSchema } from './StoreOrderPromotion';+import { StorePaymentSchema } from './StorePayment';+import { StorePaymentMethodSchema } from './StorePaymentMethod';+import { StoreShipmentSchema } from './StoreShipment';++export const AdminOrderSchema: z.ZodObject<any> = z.object({+ id: z.string(),+ number: z.string(),+ state: z.string(),+ token: z.string(),+ email: z.string().nullable(),+ special_instructions: z.string().nullable(),+ currency: z.string(),+ item_count: z.number(),+ shipment_state: z.string().nullable(),+ payment_state: z.string().nullable(),+ item_total: z.string(),+ display_item_total: z.string(),+ ship_total: z.string(),+ display_ship_total: z.string(),+ adjustment_total: z.string(),+ display_adjustment_total: z.string(),+ promo_total: z.string(),+ display_promo_total: z.string(),+ tax_total: z.string(),+ display_tax_total: z.string(),+ included_tax_total: z.string(),+ display_included_tax_total: z.string(),+ additional_tax_total: z.string(),+ display_additional_tax_total: z.string(),+ total: z.string(),+ display_total: z.string(),+ completed_at: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ order_promotions: z.array(StoreOrderPromotionSchema).optional(),+ line_items: z.array(StoreLineItemSchema).optional(),+ shipments: z.array(StoreShipmentSchema).optional(),+ payments: z.array(StorePaymentSchema).optional(),+ bill_address: StoreAddressSchema.optional(),+ ship_address: StoreAddressSchema.optional(),+ payment_methods: z.array(StorePaymentMethodSchema),+ channel: z.string().nullable(),+ last_ip_address: z.string().nullable(),+ considered_risky: z.boolean(),+ confirmation_delivered: z.boolean(),+ store_owner_notification_delivered: z.boolean(),+ internal_note: z.string().nullable(),+ approver_id: z.string().nullable(),+ canceled_at: z.string().nullable(),+ approved_at: z.string().nullable(),+ canceler_id: z.string().nullable(),+ created_by_id: z.string().nullable(),+ user: z.lazy(() => AdminUserSchema).optional(),+});++export type AdminOrder = z.infer<typeof AdminOrderSchema>;diff --git a/packages/sdk/src/zod/generated/AdminPrice.ts b/packages/sdk/src/zod/generated/AdminPrice.tsnew file mode 100644index 0000000000..542039c0e4--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminPrice.ts@@ -0,0 +1,19 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const AdminPriceSchema = z.object({+ id: z.string(),+ amount: z.string().nullable(),+ amount_in_cents: z.number().nullable(),+ compare_at_amount: z.string().nullable(),+ compare_at_amount_in_cents: z.number().nullable(),+ currency: z.string().nullable(),+ display_amount: z.string().nullable(),+ display_compare_at_amount: z.string().nullable(),+ price_list_id: z.string().nullable(),+ variant_id: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+});++export type AdminPrice = z.infer<typeof AdminPriceSchema>;diff --git a/packages/sdk/src/zod/generated/AdminProduct.ts b/packages/sdk/src/zod/generated/AdminProduct.tsnew file mode 100644index 0000000000..4ee6f6c987--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminProduct.ts@@ -0,0 +1,45 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminMetafieldSchema } from './AdminMetafield';+import { AdminVariantSchema } from './AdminVariant';+import { StoreImageSchema } from './StoreImage';+import { StoreOptionTypeSchema } from './StoreOptionType';+import { StorePriceSchema } from './StorePrice';+import { StoreTaxonSchema } from './StoreTaxon';++export const AdminProductSchema = z.object({+ id: z.string(),+ name: z.string(),+ description: z.string().nullable(),+ slug: z.string(),+ meta_description: z.string().nullable(),+ meta_keywords: z.string().nullable(),+ variant_count: z.number(),+ available_on: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ purchasable: z.boolean(),+ in_stock: z.boolean(),+ backorderable: z.boolean(),+ available: z.boolean(),+ default_variant_id: z.string(),+ thumbnail_url: z.string().nullable(),+ tags: z.array(z.string()),+ price: StorePriceSchema,+ original_price: StorePriceSchema.nullable(),+ images: z.array(StoreImageSchema).optional(),+ variants: z.array(AdminVariantSchema).optional(),+ default_variant: AdminVariantSchema.optional(),+ master_variant: AdminVariantSchema.optional(),+ option_types: z.array(StoreOptionTypeSchema).optional(),+ taxons: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(AdminMetafieldSchema).optional(),+ status: z.string(),+ make_active_at: z.string().nullable(),+ discontinue_on: z.string().nullable(),+ deleted_at: z.string().nullable(),+ cost_price: z.number().nullable(),+ cost_currency: z.string().nullable(),+});++export type AdminProduct = z.infer<typeof AdminProductSchema>;diff --git a/packages/sdk/src/zod/generated/AdminTaxon.ts b/packages/sdk/src/zod/generated/AdminTaxon.tsnew file mode 100644index 0000000000..430a87f76d--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminTaxon.ts@@ -0,0 +1,35 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminMetafieldSchema } from './AdminMetafield';+import { StoreTaxonSchema } from './StoreTaxon';++export const AdminTaxonSchema = z.object({+ id: z.string(),+ name: z.string(),+ permalink: z.string(),+ position: z.number(),+ depth: z.number(),+ meta_title: z.string().nullable(),+ meta_description: z.string().nullable(),+ meta_keywords: z.string().nullable(),+ children_count: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ parent_id: z.string().nullable(),+ taxonomy_id: z.string(),+ description: z.string(),+ description_html: z.string(),+ image_url: z.string().nullable(),+ square_image_url: z.string().nullable(),+ is_root: z.boolean(),+ is_child: z.boolean(),+ is_leaf: z.boolean(),+ parent: z.lazy(() => StoreTaxonSchema).optional(),+ children: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ ancestors: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(AdminMetafieldSchema).optional(),+ lft: z.number(),+ rgt: z.number(),+});++export type AdminTaxon = z.infer<typeof AdminTaxonSchema>;diff --git a/packages/sdk/src/zod/generated/AdminTaxonomy.ts b/packages/sdk/src/zod/generated/AdminTaxonomy.tsnew file mode 100644index 0000000000..a258aef664--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminTaxonomy.ts@@ -0,0 +1,18 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminMetafieldSchema } from './AdminMetafield';+import { StoreTaxonSchema } from './StoreTaxon';++export const AdminTaxonomySchema = z.object({+ id: z.string(),+ name: z.string(),+ position: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ root_id: z.string().nullable(),+ root: z.lazy(() => StoreTaxonSchema).optional(),+ taxons: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(AdminMetafieldSchema).optional(),+});++export type AdminTaxonomy = z.infer<typeof AdminTaxonomySchema>;diff --git a/packages/sdk/src/zod/generated/AdminUser.ts b/packages/sdk/src/zod/generated/AdminUser.tsnew file mode 100644index 0000000000..0b38fc0fa9--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminUser.ts@@ -0,0 +1,28 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminOrderSchema } from './AdminOrder';+import { StoreAddressSchema } from './StoreAddress';++export const AdminUserSchema: z.ZodObject<any> = z.object({+ id: z.string(),+ email: z.string(),+ first_name: z.string().nullable(),+ last_name: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ addresses: z.array(StoreAddressSchema),+ default_billing_address: StoreAddressSchema,+ default_shipping_address: StoreAddressSchema,+ phone: z.string().nullable(),+ login: z.string().nullable(),+ accepts_email_marketing: z.boolean(),+ last_sign_in_at: z.string().nullable(),+ current_sign_in_at: z.string().nullable(),+ sign_in_count: z.number(),+ failed_attempts: z.number(),+ last_sign_in_ip: z.string().nullable(),+ current_sign_in_ip: z.string().nullable(),+ orders: z.array(z.lazy(() => AdminOrderSchema)).optional(),+});++export type AdminUser = z.infer<typeof AdminUserSchema>;diff --git a/packages/sdk/src/zod/generated/AdminVariant.ts b/packages/sdk/src/zod/generated/AdminVariant.tsnew file mode 100644index 0000000000..1b99599867--- /dev/null+++ b/packages/sdk/src/zod/generated/AdminVariant.ts@@ -0,0 +1,41 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { AdminMetafieldSchema } from './AdminMetafield';+import { AdminPriceSchema } from './AdminPrice';+import { StoreImageSchema } from './StoreImage';+import { StoreOptionValueSchema } from './StoreOptionValue';+import { StorePriceSchema } from './StorePrice';++export const AdminVariantSchema = z.object({+ id: z.string(),+ product_id: z.string(),+ sku: z.string().nullable(),+ is_master: z.boolean(),+ options_text: z.string(),+ track_inventory: z.boolean(),+ image_count: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ thumbnail: z.string().nullable(),+ purchasable: z.boolean(),+ in_stock: z.boolean(),+ backorderable: z.boolean(),+ weight: z.number().nullable(),+ height: z.number().nullable(),+ width: z.number().nullable(),+ depth: z.number().nullable(),+ price: StorePriceSchema,+ original_price: StorePriceSchema.nullable(),+ images: z.array(StoreImageSchema).optional(),+ option_values: z.array(StoreOptionValueSchema),+ metafields: z.array(AdminMetafieldSchema).optional(),+ position: z.number(),+ tax_category_id: z.string().nullable(),+ deleted_at: z.string().nullable(),+ cost_price: z.number().nullable(),+ cost_currency: z.string().nullable(),+ total_on_hand: z.number().nullable(),+ prices: z.array(AdminPriceSchema).optional(),+});++export type AdminVariant = z.infer<typeof AdminVariantSchema>;diff --git a/packages/sdk/src/zod/generated/StoreAddress.ts b/packages/sdk/src/zod/generated/StoreAddress.tsnew file mode 100644index 0000000000..5e94d1f086--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreAddress.ts@@ -0,0 +1,22 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreAddressSchema = z.object({+ id: z.string(),+ firstname: z.string().nullable(),+ lastname: z.string().nullable(),+ full_name: z.string(),+ address1: z.string().nullable(),+ address2: z.string().nullable(),+ city: z.string().nullable(),+ zipcode: z.string().nullable(),+ phone: z.string().nullable(),+ company: z.string().nullable(),+ country_name: z.string(),+ country_iso: z.string(),+ state_text: z.string().nullable(),+ state_abbr: z.string().nullable(),+ state_name: z.string().nullable(),+});++export type StoreAddress = z.infer<typeof StoreAddressSchema>;diff --git a/packages/sdk/src/zod/generated/StoreBase.ts b/packages/sdk/src/zod/generated/StoreBase.tsnew file mode 100644index 0000000000..1eaf2f58c6--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreBase.ts@@ -0,0 +1,8 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreBaseSchema = z.object({+ id: z.string(),+});++export type StoreBase = z.infer<typeof StoreBaseSchema>;diff --git a/packages/sdk/src/zod/generated/StoreCountry.ts b/packages/sdk/src/zod/generated/StoreCountry.tsnew file mode 100644index 0000000000..d7dbd57ce5--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreCountry.ts@@ -0,0 +1,16 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreStateSchema } from './StoreState';++export const StoreCountrySchema = z.object({+ iso: z.string(),+ iso3: z.string(),+ name: z.string(),+ states_required: z.boolean(),+ zipcode_required: z.boolean(),+ default_currency: z.string().nullable(),+ default_locale: z.string().nullable(),+ states: z.array(StoreStateSchema).optional(),+});++export type StoreCountry = z.infer<typeof StoreCountrySchema>;diff --git a/packages/sdk/src/zod/generated/StoreCreditCard.ts b/packages/sdk/src/zod/generated/StoreCreditCard.tsnew file mode 100644index 0000000000..aba8f9626c--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreCreditCard.ts@@ -0,0 +1,14 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreCreditCardSchema = z.object({+ id: z.string(),+ cc_type: z.string(),+ last_digits: z.string(),+ month: z.number(),+ year: z.number(),+ name: z.string().nullable(),+ default: z.boolean(),+});++export type StoreCreditCard = z.infer<typeof StoreCreditCardSchema>;diff --git a/packages/sdk/src/zod/generated/StoreDigitalLink.ts b/packages/sdk/src/zod/generated/StoreDigitalLink.tsnew file mode 100644index 0000000000..ba9e3f971f--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreDigitalLink.ts@@ -0,0 +1,16 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreDigitalLinkSchema = z.object({+ id: z.string(),+ access_counter: z.number(),+ filename: z.string(),+ content_type: z.string(),+ created_at: z.string(),+ updated_at: z.string(),+ authorizable: z.boolean(),+ expired: z.boolean(),+ access_limit_exceeded: z.boolean(),+});++export type StoreDigitalLink = z.infer<typeof StoreDigitalLinkSchema>;diff --git a/packages/sdk/src/zod/generated/StoreGiftCard.ts b/packages/sdk/src/zod/generated/StoreGiftCard.tsnew file mode 100644index 0000000000..0b6eca1b6c--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreGiftCard.ts@@ -0,0 +1,24 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreGiftCardSchema = z.object({+ id: z.string(),+ code: z.string(),+ state: z.string(),+ currency: z.string(),+ amount: z.number(),+ amount_used: z.number(),+ amount_authorized: z.number(),+ amount_remaining: z.number(),+ display_amount: z.string(),+ display_amount_used: z.string(),+ display_amount_remaining: z.string(),+ expires_at: z.string().nullable(),+ redeemed_at: z.string().nullable(),+ expired: z.boolean(),+ active: z.boolean(),+ created_at: z.string(),+ updated_at: z.string(),+});++export type StoreGiftCard = z.infer<typeof StoreGiftCardSchema>;diff --git a/packages/sdk/src/zod/generated/StoreImage.ts b/packages/sdk/src/zod/generated/StoreImage.tsnew file mode 100644index 0000000000..133e1c77f5--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreImage.ts@@ -0,0 +1,21 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreImageSchema = z.object({+ id: z.string(),+ viewable_id: z.string(),+ position: z.number(),+ alt: z.string().nullable(),+ viewable_type: z.string(),+ created_at: z.string(),+ updated_at: z.string(),+ original_url: z.string().nullable(),+ mini_url: z.string().nullable(),+ small_url: z.string().nullable(),+ medium_url: z.string().nullable(),+ large_url: z.string().nullable(),+ xlarge_url: z.string().nullable(),+ og_image_url: z.string().nullable(),+});++export type StoreImage = z.infer<typeof StoreImageSchema>;diff --git a/packages/sdk/src/zod/generated/StoreLineItem.ts b/packages/sdk/src/zod/generated/StoreLineItem.tsnew file mode 100644index 0000000000..30ee305a78--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreLineItem.ts@@ -0,0 +1,36 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreOptionValueSchema } from './StoreOptionValue';++export const StoreLineItemSchema = z.object({+ id: z.string(),+ variant_id: z.string(),+ quantity: z.number(),+ name: z.string(),+ slug: z.string(),+ options_text: z.string(),+ price: z.string(),+ display_price: z.string(),+ total: z.string(),+ display_total: z.string(),+ adjustment_total: z.string(),+ display_adjustment_total: z.string(),+ additional_tax_total: z.string(),+ display_additional_tax_total: z.string(),+ included_tax_total: z.string(),+ display_included_tax_total: z.string(),+ promo_total: z.string(),+ display_promo_total: z.string(),+ pre_tax_amount: z.string(),+ display_pre_tax_amount: z.string(),+ discounted_amount: z.string(),+ display_discounted_amount: z.string(),+ display_compare_at_amount: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ compare_at_amount: z.string().nullable(),+ thumbnail_url: z.string().nullable(),+ option_values: z.array(StoreOptionValueSchema),+});++export type StoreLineItem = z.infer<typeof StoreLineItemSchema>;diff --git a/packages/sdk/src/zod/generated/StoreMetafield.ts b/packages/sdk/src/zod/generated/StoreMetafield.tsnew file mode 100644index 0000000000..30ef89e6d5--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreMetafield.ts@@ -0,0 +1,12 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreMetafieldSchema = z.object({+ id: z.string(),+ name: z.string(),+ type: z.string(),+ key: z.string(),+ value: z.any(),+});++export type StoreMetafield = z.infer<typeof StoreMetafieldSchema>;diff --git a/packages/sdk/src/zod/generated/StoreOptionType.ts b/packages/sdk/src/zod/generated/StoreOptionType.tsnew file mode 100644index 0000000000..3222133475--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreOptionType.ts@@ -0,0 +1,11 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreOptionTypeSchema = z.object({+ id: z.string(),+ name: z.string(),+ presentation: z.string(),+ position: z.number(),+});++export type StoreOptionType = z.infer<typeof StoreOptionTypeSchema>;diff --git a/packages/sdk/src/zod/generated/StoreOptionValue.ts b/packages/sdk/src/zod/generated/StoreOptionValue.tsnew file mode 100644index 0000000000..2d0bc5b393--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreOptionValue.ts@@ -0,0 +1,14 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreOptionValueSchema = z.object({+ id: z.string(),+ option_type_id: z.string(),+ name: z.string(),+ presentation: z.string(),+ position: z.number(),+ option_type_name: z.string(),+ option_type_presentation: z.string(),+});++export type StoreOptionValue = z.infer<typeof StoreOptionValueSchema>;diff --git a/packages/sdk/src/zod/generated/StoreOrder.ts b/packages/sdk/src/zod/generated/StoreOrder.tsnew file mode 100644index 0000000000..9ad16f43d1--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreOrder.ts@@ -0,0 +1,49 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreAddressSchema } from './StoreAddress';+import { StoreLineItemSchema } from './StoreLineItem';+import { StoreOrderPromotionSchema } from './StoreOrderPromotion';+import { StorePaymentSchema } from './StorePayment';+import { StorePaymentMethodSchema } from './StorePaymentMethod';+import { StoreShipmentSchema } from './StoreShipment';++export const StoreOrderSchema = z.object({+ id: z.string(),+ number: z.string(),+ state: z.string(),+ token: z.string(),+ email: z.string().nullable(),+ special_instructions: z.string().nullable(),+ currency: z.string(),+ item_count: z.number(),+ shipment_state: z.string().nullable(),+ payment_state: z.string().nullable(),+ item_total: z.string(),+ display_item_total: z.string(),+ ship_total: z.string(),+ display_ship_total: z.string(),+ adjustment_total: z.string(),+ display_adjustment_total: z.string(),+ promo_total: z.string(),+ display_promo_total: z.string(),+ tax_total: z.string(),+ display_tax_total: z.string(),+ included_tax_total: z.string(),+ display_included_tax_total: z.string(),+ additional_tax_total: z.string(),+ display_additional_tax_total: z.string(),+ total: z.string(),+ display_total: z.string(),+ completed_at: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ order_promotions: z.array(StoreOrderPromotionSchema).optional(),+ line_items: z.array(StoreLineItemSchema).optional(),+ shipments: z.array(StoreShipmentSchema).optional(),+ payments: z.array(StorePaymentSchema).optional(),+ bill_address: StoreAddressSchema.optional(),+ ship_address: StoreAddressSchema.optional(),+ payment_methods: z.array(StorePaymentMethodSchema),+});++export type StoreOrder = z.infer<typeof StoreOrderSchema>;diff --git a/packages/sdk/src/zod/generated/StoreOrderPromotion.ts b/packages/sdk/src/zod/generated/StoreOrderPromotion.tsnew file mode 100644index 0000000000..f4c770ee30--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreOrderPromotion.ts@@ -0,0 +1,14 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreOrderPromotionSchema = z.object({+ id: z.string(),+ promotion_id: z.string(),+ name: z.string(),+ description: z.string().nullable(),+ code: z.string().nullable(),+ amount: z.string(),+ display_amount: z.string(),+});++export type StoreOrderPromotion = z.infer<typeof StoreOrderPromotionSchema>;diff --git a/packages/sdk/src/zod/generated/StorePayment.ts b/packages/sdk/src/zod/generated/StorePayment.tsnew file mode 100644index 0000000000..ef289c965a--- /dev/null+++ b/packages/sdk/src/zod/generated/StorePayment.ts@@ -0,0 +1,18 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StorePaymentMethodSchema } from './StorePaymentMethod';++export const StorePaymentSchema = z.object({+ id: z.string(),+ payment_method_id: z.string(),+ state: z.string(),+ response_code: z.string().nullable(),+ number: z.string(),+ amount: z.string(),+ display_amount: z.string(),+ created_at: z.string(),+ updated_at: z.string(),+ payment_method: StorePaymentMethodSchema,+});++export type StorePayment = z.infer<typeof StorePaymentSchema>;diff --git a/packages/sdk/src/zod/generated/StorePaymentMethod.ts b/packages/sdk/src/zod/generated/StorePaymentMethod.tsnew file mode 100644index 0000000000..e8c51bfe05--- /dev/null+++ b/packages/sdk/src/zod/generated/StorePaymentMethod.ts@@ -0,0 +1,11 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StorePaymentMethodSchema = z.object({+ id: z.string(),+ name: z.string(),+ description: z.string().nullable(),+ type: z.string(),+});++export type StorePaymentMethod = z.infer<typeof StorePaymentMethodSchema>;diff --git a/packages/sdk/src/zod/generated/StorePrice.ts b/packages/sdk/src/zod/generated/StorePrice.tsnew file mode 100644index 0000000000..f03426ee49--- /dev/null+++ b/packages/sdk/src/zod/generated/StorePrice.ts@@ -0,0 +1,16 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StorePriceSchema = z.object({+ id: z.string(),+ amount: z.string().nullable(),+ amount_in_cents: z.number().nullable(),+ compare_at_amount: z.string().nullable(),+ compare_at_amount_in_cents: z.number().nullable(),+ currency: z.string().nullable(),+ display_amount: z.string().nullable(),+ display_compare_at_amount: z.string().nullable(),+ price_list_id: z.string().nullable(),+});++export type StorePrice = z.infer<typeof StorePriceSchema>;diff --git a/packages/sdk/src/zod/generated/StoreProduct.ts b/packages/sdk/src/zod/generated/StoreProduct.tsnew file mode 100644index 0000000000..f1b0c07aa8--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreProduct.ts@@ -0,0 +1,39 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreImageSchema } from './StoreImage';+import { StoreMetafieldSchema } from './StoreMetafield';+import { StoreOptionTypeSchema } from './StoreOptionType';+import { StorePriceSchema } from './StorePrice';+import { StoreTaxonSchema } from './StoreTaxon';+import { StoreVariantSchema } from './StoreVariant';++export const StoreProductSchema = z.object({+ id: z.string(),+ name: z.string(),+ description: z.string().nullable(),+ slug: z.string(),+ meta_description: z.string().nullable(),+ meta_keywords: z.string().nullable(),+ variant_count: z.number(),+ available_on: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ purchasable: z.boolean(),+ in_stock: z.boolean(),+ backorderable: z.boolean(),+ available: z.boolean(),+ default_variant_id: z.string(),+ thumbnail_url: z.string().nullable(),+ tags: z.array(z.string()),+ price: StorePriceSchema,+ original_price: StorePriceSchema.nullable(),+ images: z.array(StoreImageSchema).optional(),+ variants: z.array(StoreVariantSchema).optional(),+ default_variant: StoreVariantSchema.optional(),+ master_variant: StoreVariantSchema.optional(),+ option_types: z.array(StoreOptionTypeSchema).optional(),+ taxons: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(StoreMetafieldSchema).optional(),+});++export type StoreProduct = z.infer<typeof StoreProductSchema>;diff --git a/packages/sdk/src/zod/generated/StoreShipment.ts b/packages/sdk/src/zod/generated/StoreShipment.tsnew file mode 100644index 0000000000..faa906f7d1--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreShipment.ts@@ -0,0 +1,23 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreShippingMethodSchema } from './StoreShippingMethod';+import { StoreShippingRateSchema } from './StoreShippingRate';+import { StoreStockLocationSchema } from './StoreStockLocation';++export const StoreShipmentSchema = z.object({+ id: z.string(),+ number: z.string(),+ state: z.string(),+ tracking: z.string().nullable(),+ tracking_url: z.string().nullable(),+ cost: z.string(),+ display_cost: z.string(),+ shipped_at: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ shipping_method: StoreShippingMethodSchema,+ stock_location: StoreStockLocationSchema,+ shipping_rates: z.array(StoreShippingRateSchema),+});++export type StoreShipment = z.infer<typeof StoreShipmentSchema>;diff --git a/packages/sdk/src/zod/generated/StoreShippingMethod.ts b/packages/sdk/src/zod/generated/StoreShippingMethod.tsnew file mode 100644index 0000000000..d2ed751887--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreShippingMethod.ts@@ -0,0 +1,10 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreShippingMethodSchema = z.object({+ id: z.string(),+ name: z.string(),+ code: z.string().nullable(),+});++export type StoreShippingMethod = z.infer<typeof StoreShippingMethodSchema>;diff --git a/packages/sdk/src/zod/generated/StoreShippingRate.ts b/packages/sdk/src/zod/generated/StoreShippingRate.tsnew file mode 100644index 0000000000..33451cb095--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreShippingRate.ts@@ -0,0 +1,15 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreShippingMethodSchema } from './StoreShippingMethod';++export const StoreShippingRateSchema = z.object({+ id: z.string(),+ shipping_method_id: z.string(),+ name: z.string(),+ selected: z.boolean(),+ cost: z.number(),+ display_cost: z.string(),+ shipping_method: StoreShippingMethodSchema,+});++export type StoreShippingRate = z.infer<typeof StoreShippingRateSchema>;diff --git a/packages/sdk/src/zod/generated/StoreState.ts b/packages/sdk/src/zod/generated/StoreState.tsnew file mode 100644index 0000000000..381c363e8d--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreState.ts@@ -0,0 +1,9 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreStateSchema = z.object({+ abbr: z.string(),+ name: z.string(),+});++export type StoreState = z.infer<typeof StoreStateSchema>;diff --git a/packages/sdk/src/zod/generated/StoreStockLocation.ts b/packages/sdk/src/zod/generated/StoreStockLocation.tsnew file mode 100644index 0000000000..cf2a39ed13--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreStockLocation.ts@@ -0,0 +1,16 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';++export const StoreStockLocationSchema = z.object({+ id: z.string(),+ state_abbr: z.string().nullable(),+ name: z.string(),+ address1: z.string().nullable(),+ city: z.string().nullable(),+ zipcode: z.string().nullable(),+ country_iso: z.string().nullable(),+ country_name: z.string().nullable(),+ state_text: z.string().nullable(),+});++export type StoreStockLocation = z.infer<typeof StoreStockLocationSchema>;diff --git a/packages/sdk/src/zod/generated/StoreStore.ts b/packages/sdk/src/zod/generated/StoreStore.tsnew file mode 100644index 0000000000..8f12e86f0a--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreStore.ts@@ -0,0 +1,31 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StorePaymentMethodSchema } from './StorePaymentMethod';++export const StoreStoreSchema = z.object({+ id: z.string(),+ name: z.string(),+ url: z.string(),+ meta_description: z.string().nullable(),+ meta_keywords: z.string().nullable(),+ seo_title: z.string().nullable(),+ default_currency: z.string(),+ code: z.string(),+ default: z.boolean(),+ facebook: z.string().nullable(),+ twitter: z.string().nullable(),+ instagram: z.string().nullable(),+ customer_support_email: z.string().nullable(),+ default_locale: z.string(),+ created_at: z.string(),+ updated_at: z.string(),+ default_country_iso: z.string().nullable(),+ supported_currencies: z.array(z.string()),+ favicon_image_url: z.string().nullable(),+ logo_image_url: z.string().nullable(),+ social_image_url: z.string().nullable(),+ supported_locales: z.array(z.string()),+ payment_methods: z.array(StorePaymentMethodSchema),+});++export type StoreStore = z.infer<typeof StoreStoreSchema>;diff --git a/packages/sdk/src/zod/generated/StoreTaxon.ts b/packages/sdk/src/zod/generated/StoreTaxon.tsnew file mode 100644index 0000000000..30ad79f4fc--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreTaxon.ts@@ -0,0 +1,32 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreMetafieldSchema } from './StoreMetafield';++export const StoreTaxonSchema: z.ZodObject<any> = z.object({+ id: z.string(),+ name: z.string(),+ permalink: z.string(),+ position: z.number(),+ depth: z.number(),+ meta_title: z.string().nullable(),+ meta_description: z.string().nullable(),+ meta_keywords: z.string().nullable(),+ children_count: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ parent_id: z.string().nullable(),+ taxonomy_id: z.string(),+ description: z.string(),+ description_html: z.string(),+ image_url: z.string().nullable(),+ square_image_url: z.string().nullable(),+ is_root: z.boolean(),+ is_child: z.boolean(),+ is_leaf: z.boolean(),+ parent: z.lazy(() => StoreTaxonSchema).optional(),+ children: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ ancestors: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(StoreMetafieldSchema).optional(),+});++export type StoreTaxon = z.infer<typeof StoreTaxonSchema>;diff --git a/packages/sdk/src/zod/generated/StoreTaxonomy.ts b/packages/sdk/src/zod/generated/StoreTaxonomy.tsnew file mode 100644index 0000000000..5f57eb1743--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreTaxonomy.ts@@ -0,0 +1,18 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreMetafieldSchema } from './StoreMetafield';+import { StoreTaxonSchema } from './StoreTaxon';++export const StoreTaxonomySchema = z.object({+ id: z.string(),+ name: z.string(),+ position: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ root_id: z.string().nullable(),+ root: z.lazy(() => StoreTaxonSchema).optional(),+ taxons: z.array(z.lazy(() => StoreTaxonSchema)).optional(),+ metafields: z.array(StoreMetafieldSchema).optional(),+});++export type StoreTaxonomy = z.infer<typeof StoreTaxonomySchema>;diff --git a/packages/sdk/src/zod/generated/StoreUser.ts b/packages/sdk/src/zod/generated/StoreUser.tsnew file mode 100644index 0000000000..d05cb13a54--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreUser.ts@@ -0,0 +1,17 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreAddressSchema } from './StoreAddress';++export const StoreUserSchema = z.object({+ id: z.string(),+ email: z.string(),+ first_name: z.string().nullable(),+ last_name: z.string().nullable(),+ created_at: z.string(),+ updated_at: z.string(),+ addresses: z.array(StoreAddressSchema),+ default_billing_address: StoreAddressSchema,+ default_shipping_address: StoreAddressSchema,+});++export type StoreUser = z.infer<typeof StoreUserSchema>;diff --git a/packages/sdk/src/zod/generated/StoreVariant.ts b/packages/sdk/src/zod/generated/StoreVariant.tsnew file mode 100644index 0000000000..8364fe1ee6--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreVariant.ts@@ -0,0 +1,33 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreImageSchema } from './StoreImage';+import { StoreMetafieldSchema } from './StoreMetafield';+import { StoreOptionValueSchema } from './StoreOptionValue';+import { StorePriceSchema } from './StorePrice';++export const StoreVariantSchema = z.object({+ id: z.string(),+ product_id: z.string(),+ sku: z.string().nullable(),+ is_master: z.boolean(),+ options_text: z.string(),+ track_inventory: z.boolean(),+ image_count: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ thumbnail: z.string().nullable(),+ purchasable: z.boolean(),+ in_stock: z.boolean(),+ backorderable: z.boolean(),+ weight: z.number().nullable(),+ height: z.number().nullable(),+ width: z.number().nullable(),+ depth: z.number().nullable(),+ price: StorePriceSchema,+ original_price: StorePriceSchema.nullable(),+ images: z.array(StoreImageSchema).optional(),+ option_values: z.array(StoreOptionValueSchema),+ metafields: z.array(StoreMetafieldSchema).optional(),+});++export type StoreVariant = z.infer<typeof StoreVariantSchema>;diff --git a/packages/sdk/src/zod/generated/StoreWishedItem.ts b/packages/sdk/src/zod/generated/StoreWishedItem.tsnew file mode 100644index 0000000000..4164afdf1d--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreWishedItem.ts@@ -0,0 +1,15 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreVariantSchema } from './StoreVariant';++export const StoreWishedItemSchema = z.object({+ id: z.string(),+ variant_id: z.string(),+ wishlist_id: z.string(),+ quantity: z.number(),+ created_at: z.string(),+ updated_at: z.string(),+ variant: StoreVariantSchema,+});++export type StoreWishedItem = z.infer<typeof StoreWishedItemSchema>;diff --git a/packages/sdk/src/zod/generated/StoreWishlist.ts b/packages/sdk/src/zod/generated/StoreWishlist.tsnew file mode 100644index 0000000000..f88f2bbe25--- /dev/null+++ b/packages/sdk/src/zod/generated/StoreWishlist.ts@@ -0,0 +1,16 @@+// This file is auto-generated. Do not edit directly.+import { z } from 'zod';+import { StoreWishedItemSchema } from './StoreWishedItem';++export const StoreWishlistSchema = z.object({+ id: z.string(),+ name: z.string(),+ token: z.string(),+ created_at: z.string(),+ updated_at: z.string(),+ is_default: z.boolean(),+ is_private: z.boolean(),+ items: z.array(StoreWishedItemSchema).optional(),+});++export type StoreWishlist = z.infer<typeof StoreWishlistSchema>;diff --git a/packages/sdk/src/zod/generated/index.ts b/packages/sdk/src/zod/generated/index.tsnew file mode 100644index 0000000000..31a810231d--- /dev/null+++ b/packages/sdk/src/zod/generated/index.ts@@ -0,0 +1,38 @@+// This file is auto-generated. Do not edit directly.+export { AdminMetafieldSchema, type AdminMetafield } from './AdminMetafield';+export { AdminOrderSchema, type AdminOrder } from './AdminOrder';+export { AdminPriceSchema, type AdminPrice } from './AdminPrice';+export { AdminProductSchema, type AdminProduct } from './AdminProduct';+export { AdminTaxonSchema, type AdminTaxon } from './AdminTaxon';+export { AdminTaxonomySchema, type AdminTaxonomy } from './AdminTaxonomy';+export { AdminUserSchema, type AdminUser } from './AdminUser';+export { AdminVariantSchema, type AdminVariant } from './AdminVariant';+export { StoreAddressSchema, type StoreAddress } from './StoreAddress';+export { StoreBaseSchema, type StoreBase } from './StoreBase';+export { StoreCountrySchema, type StoreCountry } from './StoreCountry';+export { StoreCreditCardSchema, type StoreCreditCard } from './StoreCreditCard';+export { StoreDigitalLinkSchema, type StoreDigitalLink } from './StoreDigitalLink';+export { StoreGiftCardSchema, type StoreGiftCard } from './StoreGiftCard';+export { StoreImageSchema, type StoreImage } from './StoreImage';+export { StoreLineItemSchema, type StoreLineItem } from './StoreLineItem';+export { StoreMetafieldSchema, type StoreMetafield } from './StoreMetafield';+export { StoreOptionTypeSchema, type StoreOptionType } from './StoreOptionType';+export { StoreOptionValueSchema, type StoreOptionValue } from './StoreOptionValue';+export { StoreOrderSchema, type StoreOrder } from './StoreOrder';+export { StoreOrderPromotionSchema, type StoreOrderPromotion } from './StoreOrderPromotion';+export { StorePaymentSchema, type StorePayment } from './StorePayment';+export { StorePaymentMethodSchema, type StorePaymentMethod } from './StorePaymentMethod';+export { StorePriceSchema, type StorePrice } from './StorePrice';+export { StoreProductSchema, type StoreProduct } from './StoreProduct';+export { StoreShipmentSchema, type StoreShipment } from './StoreShipment';+export { StoreShippingMethodSchema, type StoreShippingMethod } from './StoreShippingMethod';+export { StoreShippingRateSchema, type StoreShippingRate } from './StoreShippingRate';+export { StoreStateSchema, type StoreState } from './StoreState';+export { StoreStockLocationSchema, type StoreStockLocation } from './StoreStockLocation';+export { StoreStoreSchema, type StoreStore } from './StoreStore';+export { StoreTaxonSchema, type StoreTaxon } from './StoreTaxon';+export { StoreTaxonomySchema, type StoreTaxonomy } from './StoreTaxonomy';+export { StoreUserSchema, type StoreUser } from './StoreUser';+export { StoreVariantSchema, type StoreVariant } from './StoreVariant';+export { StoreWishedItemSchema, type StoreWishedItem } from './StoreWishedItem';+export { StoreWishlistSchema, type StoreWishlist } from './StoreWishlist';diff --git a/packages/sdk/src/zod/index.ts b/packages/sdk/src/zod/index.tsnew file mode 100644index 0000000000..69e4e4eb8b--- /dev/null+++ b/packages/sdk/src/zod/index.ts@@ -0,0 +1 @@+export * from './generated';diff --git a/packages/sdk/tests/retry.test.ts b/packages/sdk/tests/retry.test.tsnew file mode 100644index 0000000000..426ba7369d--- /dev/null+++ b/packages/sdk/tests/retry.test.ts@@ -0,0 +1,189 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { createSpreeClient, SpreeError } from '../src/client';++function jsonResponse(body: object, status = 200, headers: Record<string, string> = {}): Response {+ return new Response(JSON.stringify(body), {+ status,+ headers: { 'Content-Type': 'application/json', ...headers },+ });+}++function errorResponse(status: number, code = 'error', message = 'Error', headers: Record<string, string> = {}): Response {+ return new Response(+ JSON.stringify({ error: { code, message } }),+ { status, headers: { 'Content-Type': 'application/json', ...headers } }+ );+}++describe('Retry logic', () => {+ const baseConfig = { baseUrl: 'https://api.test.com', apiKey: 'pk_test' };++ describe('GET requests', () => {+ it('retries on 500 and succeeds', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(500))+ .mockResolvedValueOnce(jsonResponse({ name: 'Test Store' }));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });+ const result = await client.store.get();++ expect(result).toEqual({ name: 'Test Store' });+ expect(mockFetch).toHaveBeenCalledTimes(2);+ });++ it('retries on 429 and succeeds', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(429, 'rate_limited', 'Too many requests'))+ .mockResolvedValueOnce(jsonResponse({ name: 'Test Store' }));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });+ const result = await client.store.get();++ expect(result).toEqual({ name: 'Test Store' });+ expect(mockFetch).toHaveBeenCalledTimes(2);+ });++ it('retries on 502, 503, 504', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(502))+ .mockResolvedValueOnce(errorResponse(503))+ .mockResolvedValueOnce(jsonResponse({ name: 'Test Store' }));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });+ const result = await client.store.get();++ expect(result).toEqual({ name: 'Test Store' });+ expect(mockFetch).toHaveBeenCalledTimes(3);+ });++ it('throws after max retries exhausted', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValue(errorResponse(500, 'server_error', 'Internal error'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });++ await expect(client.store.get()).rejects.toThrow(SpreeError);+ // 1 initial + 2 retries = 3 attempts+ expect(mockFetch).toHaveBeenCalledTimes(3);+ });++ it('retries on network errors for GET', async () => {+ const mockFetch = vi.fn()+ .mockRejectedValueOnce(new TypeError('fetch failed'))+ .mockResolvedValueOnce(jsonResponse({ name: 'Test Store' }));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });+ const result = await client.store.get();++ expect(result).toEqual({ name: 'Test Store' });+ expect(mockFetch).toHaveBeenCalledTimes(2);+ });++ it('does not retry on 400 (client error)', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(400, 'bad_request', 'Bad request'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });++ await expect(client.store.get()).rejects.toThrow(SpreeError);+ expect(mockFetch).toHaveBeenCalledTimes(1);+ });++ it('does not retry on 401 (unauthorized)', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(401, 'unauthorized', 'Unauthorized'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });++ await expect(client.store.get()).rejects.toThrow(SpreeError);+ expect(mockFetch).toHaveBeenCalledTimes(1);+ });+ });++ describe('POST requests (non-idempotent)', () => {+ it('retries POST on 429 only', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(429, 'rate_limited', 'Too many requests'))+ .mockResolvedValueOnce(jsonResponse({ token: 'abc', user: { id: '1', email: '[email protected]' } }));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });+ const result = await client.auth.login({ email: '[email protected]', password: 'pass' });++ expect(result.token).toBe('abc');+ expect(mockFetch).toHaveBeenCalledTimes(2);+ });++ it('does NOT retry POST on 500', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(500, 'server_error', 'Internal error'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });++ await expect(+ client.auth.login({ email: '[email protected]', password: 'pass' })+ ).rejects.toThrow(SpreeError);+ expect(mockFetch).toHaveBeenCalledTimes(1);+ });++ it('does NOT retry POST on network errors', async () => {+ const mockFetch = vi.fn()+ .mockRejectedValueOnce(new TypeError('fetch failed'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch });++ await expect(+ client.auth.login({ email: '[email protected]', password: 'pass' })+ ).rejects.toThrow(TypeError);+ expect(mockFetch).toHaveBeenCalledTimes(1);+ });+ });++ describe('retry: false disables retries', () => {+ it('does not retry when retry is disabled', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(500, 'server_error', 'Internal error'));++ const client = createSpreeClient({ ...baseConfig, fetch: mockFetch, retry: false });++ await expect(client.store.get()).rejects.toThrow(SpreeError);+ expect(mockFetch).toHaveBeenCalledTimes(1);+ });+ });++ describe('custom retry config', () => {+ it('respects custom maxRetries', async () => {+ const mockFetch = vi.fn()+ .mockResolvedValue(errorResponse(500, 'server_error', 'Internal error'));++ const client = createSpreeClient({+ ...baseConfig,+ fetch: mockFetch,+ retry: { maxRetries: 4, baseDelay: 10 },+ });++ await expect(client.store.get()).rejects.toThrow(SpreeError);+ // 1 initial + 4 retries = 5 attempts+ expect(mockFetch).toHaveBeenCalledTimes(5);+ });++ it('respects Retry-After header', async () => {+ const start = Date.now();+ const mockFetch = vi.fn()+ .mockResolvedValueOnce(errorResponse(429, 'rate_limited', 'Too many requests', { 'Retry-After': '1' }))+ .mockResolvedValueOnce(jsonResponse({ name: 'Test Store' }));++ const client = createSpreeClient({+ ...baseConfig,+ fetch: mockFetch,+ retry: { baseDelay: 10 },+ });++ const result = await client.store.get();+ const elapsed = Date.now() - start;++ expect(result).toEqual({ name: 'Test Store' });+ // Retry-After: 1 = 1000ms delay+ expect(elapsed).toBeGreaterThanOrEqual(900);+ });+ });+});diff --git a/packages/sdk/tsup.config.ts b/packages/sdk/tsup.config.tsindex 6c4d000d66..c03032f44e 100644--- a/packages/sdk/tsup.config.ts+++ b/packages/sdk/tsup.config.ts@@ -4,6 +4,7 @@ export default defineConfig({entry: {index: 'src/index.ts','types/index': 'src/types/index.ts',+ 'zod/index': 'src/zod/index.ts',},format: ['cjs', 'esm'],dts: true,