CartMutation
Discriminated union of every operation the kernel can route to an adapter.
Pass to ; the kernel dispatches on kind to the
corresponding adapter method, guarded by .
Definition
type CartMutation = { attributes: KV[]; kind: 'add-line'; quantity: number; snapshot: ProductSnapshot; variantId: string } | { kind: 'update-line'; lineId: string; quantity: number } | { kind: 'remove-line'; lineId: string } | { kind: 'clear' } | { code: string; kind: 'apply-discount' } | { code: string; kind: 'remove-discount' } | { code: string; kind: 'apply-gift-card' } | { id: string; kind: 'remove-gift-card' } | { kind: 'update-note'; note: string } | { attributes: KV[]; kind: 'update-attributes' } | { kind: 'update-buyer-identity' } | { kind: 'custom'; name: string; payload: unknown };{ attributes: KV[]; kind: 'add-line'; quantity: number; snapshot: ProductSnapshot; variantId: string } | { kind: 'update-line'; lineId: string; quantity: number } | { kind: 'remove-line'; lineId: string } | { kind: 'clear' } | { code: string; kind: 'apply-discount' } | { code: string; kind: 'remove-discount' } | { code: string; kind: 'apply-gift-card' } | { id: string; kind: 'remove-gift-card' } | { kind: 'update-note'; note: string } | { attributes: KV[]; kind: 'update-attributes' } | { kind: 'update-buyer-identity' } | { kind: 'custom'; name: string; payload: unknown }
Example
const mutation: CartMutation = { kind: 'add-line', variantId: 'v_1', quantity: 2 };
await kernel.mutate(ctx, mutation);Related
RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter
CartMiddleware
Higherorder function that wraps a to inject crosscutting behavior (logging, retrying, tracing). Middleware layers compose into a single pipeline via .
CartNotFoundError
Thrown by adapters when a cart id is resolvable in the request but no cart exists upstream — distinct from a transport failure.