Gesso Commerce
API library for connecting Gesso frontends with various commerce backends.
Introduction
Setup
- Make sure your commit messages follow Conventional Commits specification, which will be required for making new releases.
Testing
Uses Vitest. Spec files are colocated with source files (*.spec.ts, *.spec.tsx).
Notes
Compatibility Notes (Phased Cart Architecture)
Recent internal improvements introduced phased cart state (initPhase, activeCartPhase, collectionPhase) and an explicit migration from a temporary placeholder cart (id '') to the first real server cart. These changes are backwards compatible:
- Public hook contract (
useCart) is unchanged (method names & return shape preserved). - Plugin interfaces (Shopify, BigCommerce, Drupal Commerce, etc.) are not modified; only initialization timing is tightened.
- Placeholder migration runs only when a real cart id first appears; if a plugin already returns a real id immediately, behavior is identical.
- Phases never regress (e.g. once
initPhase === 'ready'it does not return tofetching).
Potential edge issues now mitigated:
- Eliminates lingering phantom placeholder entries in multi-cart scenarios.
- Ensures cookie (
gesso-cartId) is written promptly, reducing duplicate anonymous cart creation risk. - Guarantees
lastStableCartrecords the real cart (not the placeholder) for accurate rollback & empty-state logic.
If writing a new plugin:
- Always return a stable
idfor any persisted cart. - Return
undefined(or a terminal cart) only when no active cart exists yet; the provider will supply a placeholder until one is created. - Avoid relying on the placeholder cart persisting after a real cart id is available; that sentinel is internal only.
If you observe unexpected behavior, enable development logging and inspect the phased state to confirm transitions (initPhase, activeCartPhase). Open an issue with a reproduction including those values.