Interface: ExecuteWithCartRecoveryOptions<T>
Type Parameters
T
T
Properties
cartClient
cartClient:
CartClient
cookieMaxAge?
optionalcookieMaxAge?:number
Cookie maxAge override propagated to cookieStore.set.
cookieStore
cookieStore:
CartCookieStore
ensureCart?
optionalensureCart?: () =>Promise<{cart:CartFragment;secret?:string|null; }>
Initial-create fallback when the cookie is empty. Defaults to
cartClient.create(). Must return the created cart together with its
one-time secret so the runner persists the composite cookie.
Returns
Promise<{ cart: CartFragment; secret?: string | null; }>
initialCartId?
optionalinitialCartId?:string|null
Server-known cart-id seed used when the cookie store is empty. Cookie wins when present; the seed only fills the gap on first interaction.
Accepts either a bare cart id ("<cartId>") or the composite cookie value
("<cartId>.<secret>"). When the seed carries a secret, the runner persists
the composite cookie so subsequent reads and writes send the access secret
and reach the seeded cart. A bare cart id is persisted as-is and degrades to
a fresh cart on the next write (the secret is required to reach an existing
cart).
On Phase 0 the runner eagerly copies the seed into the cookie store so
cross-tab tabs observe the same cart-id and recovery semantics match
the standard cookie-driven path. If the seed is stale the recovery
runner clears it via the usual Phase 2a/2b flow (bail with
cart-expired for state-dependent ops, atomic recreate for replayable
ops) — no special-case code needed at this layer.
Use cases: env seed for dev sample storefronts (sample cart fixture without a product listing), magic-link checkout, embedded iframe (parent supplies cart-id via postMessage), customer-service "view this cart" UI, server-side recovery, multi-cart B2B selectors.
onExpired?
optionalonExpired?: (event) =>void
Optional listener fired before the runner throws CartRecoveryNotPossibleError.
Parameters
event
Returns
void
operation
operation:
CartRecoveryOperation<T>