create-cartbase 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/template/app/docs/BUILD-A-STOREFRONT.md +1 -1
  3. package/template/app/docs/README.md +1 -1
  4. package/template/app/docs/auth.md +1 -1
  5. package/template/app/docs/carts.md +3 -3
  6. package/template/app/docs/categories.md +1 -1
  7. package/template/app/docs/checkout.md +135 -78
  8. package/template/app/docs/collections.md +1 -1
  9. package/template/app/docs/components.md +53 -55
  10. package/template/app/docs/consent.md +1 -1
  11. package/template/app/docs/content.md +1 -1
  12. package/template/app/docs/customers.md +1 -1
  13. package/template/app/docs/deploy.md +1 -1
  14. package/template/app/docs/gift-cards.md +1 -1
  15. package/template/app/docs/integrations.md +1 -1
  16. package/template/app/docs/menus.md +1 -1
  17. package/template/app/docs/metaobjects.md +1 -1
  18. package/template/app/docs/orders.md +1 -1
  19. package/template/app/docs/platform.md +1 -1
  20. package/template/app/docs/products.md +1 -1
  21. package/template/app/docs/redirects.md +1 -1
  22. package/template/app/docs/regions.md +1 -1
  23. package/template/app/docs/reviews.md +1 -1
  24. package/template/app/docs/search.md +1 -1
  25. package/template/app/docs/subscriptions.md +1 -1
  26. package/template/app/docs/variables.md +315 -0
  27. package/template/app/next-env.d.ts +6 -0
  28. package/template/app/package.json +1 -1
  29. package/template/app/smoke.mjs +1 -1
  30. package/template/app/src/app/checkout/checkout-page-client.tsx +26 -10
  31. package/template/app/src/app/checkout/mypos-demo-tab.tsx +101 -0
  32. package/template/app/src/app/checkout/page.tsx +48 -51
  33. package/template/app/src/app/order/[id]/confirmed/page.tsx +5 -4
  34. package/template/app/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- # Components — `@cartbase/storefront` UI families
1
+ # Components
2
2
 
3
3
  The component layer of `@cartbase/storefront`: what each family ships, the SDK
4
4
  calls it requires, the admin settings that change its behavior, and its mount
@@ -20,8 +20,7 @@ app's CSS; no component hardcodes a color.
20
20
 
21
21
  ---
22
22
 
23
- ## Family: tracking (`@cartbase/storefront/tracking/*`) — SHIPPED
24
-
23
+ ## Family: tracking (`@cartbase/storefront/tracking/*`)
25
24
  Meta Pixel + GA4 + Rybbit + Consent Mode v2. The Cartbase split of duties:
26
25
  **this package fires client events and writes attribution; server-side CAPI /
27
26
  GA4 Measurement Protocol sending is Cartbase-backend-owned** (the
@@ -154,8 +153,7 @@ Meta side) and `gtag('set','user_data',…)`. Call alongside
154
153
 
155
154
  ---
156
155
 
157
- ## Family: primitives (`@cartbase/storefront/primitives/*`) — SHIPPED
158
-
156
+ ## Family: primitives (`@cartbase/storefront/primitives/*`)
159
157
  Generic shadcn-style building blocks. No SDK calls, no admin settings —
160
158
  pure UI over the theme tokens.
161
159
 
@@ -172,8 +170,7 @@ pure UI over the theme tokens.
172
170
 
173
171
  ---
174
172
 
175
- ## Family: lib (`@cartbase/storefront/lib/*`) — SHIPPED
176
-
173
+ ## Family: lib (`@cartbase/storefront/lib/*`)
177
174
  Pure helpers — no React except `dual-price`, no fetches. The SDK never
178
175
  invents server truths: prices/totals arrive computed from the API
179
176
  (`variant.calculated_price`, `cart.total`); these helpers only select and
@@ -204,11 +201,14 @@ format.
204
201
  - `lib/sort-products` — client-side re-sort of a fetched page
205
202
  (`price_asc|price_desc|created_at`); the API's `order` param stays the
206
203
  authority for paginated listings.
207
- - `lib/payment-constants` — `isStripeLike` / `isPaypal` / `isManual` +
208
- `paymentInfoMap`. Translated to Cartbase ids: matches `pp_stripe` exactly
209
- (code truth `src/lib/stripe/providers.ts`) plus legacy provider prefixes;
210
- `pp_system_default` = COD. Affected by: enabled payment providers +
211
- checkout rules (which ids ever reach the client).
204
+ - `lib/payment-constants` — `isStripeLike` / `isPaypal` +
205
+ `paymentInfoMap`. Two tender shapes since the pp_* kill: a processor
206
+ `provider_id` (`pp_stripe` exact, code truth
207
+ `src/lib/stripe/providers.ts`, plus legacy Medusa-era prefixes as
208
+ fallbacks) or a merchant METHOD rendered by its snapshot NAME — a
209
+ method never has a provider id to bucket. Affected by: connected
210
+ processors + enabled methods + checkout rules (which entries ever
211
+ reach the client).
212
212
  - `lib/store-api-error` — `storeApiError(err)`: display-boundary normalizer
213
213
  (capitalized message + terminal period).
214
214
  Catch `StoreApiError` directly instead when branching on `status`/`code`.
@@ -217,8 +217,7 @@ format.
217
217
 
218
218
  ---
219
219
 
220
- ## Family: checkout (`@cartbase/storefront/checkout/*`) — SHIPPED
221
-
220
+ ## Family: checkout (`@cartbase/storefront/checkout/*`)
222
221
  The full checkout page family, production-proven (deferred-
223
222
  intent architecture — no payment session exists until Buy click) onto the
224
223
  Cartbase orchestration endpoints. The flow every component serves
@@ -227,7 +226,7 @@ Cartbase orchestration endpoints. The flow every component serves
227
226
  ```
228
227
  listShippingOptions(cart_id) + listPaymentProviders(cart_id) (render pickers)
229
228
  → Buy click → prepareCheckout (ONE atomic, compensated call)
230
- → pp_stripe: stripe.confirmPayment(client_secret) | pp_cod/pp_manual: skip
229
+ → pp_stripe: stripe.confirmPayment(client_secret) | merchant method: skip
231
230
  → completeCart → navigate to the confirmed page
232
231
  ```
233
232
 
@@ -264,21 +263,24 @@ code-first through the error-copy maps, never raw API strings.
264
263
  call REACTIVELY from Elements `loaderror` only), `carts.completeCart`.
265
264
  - **Props contract** — `{client, cart, customer, availableShippingMethods,
266
265
  availablePaymentMethods, countryCode?, countries?, paymentMethodFilter?,
267
- codConfig?, orderConfirmedPath?, onOrderPlaced?,
266
+ orderConfirmedPath?, onOrderPlaced?,
268
267
  resolveTrackingMetadata?, logError?}`. `countries` is caller-supplied
269
- (Cartbase regions embed NO countries array). `codConfig` = the
270
- integrations `cod` block the COD fee prediction is never hardcoded.
271
- `logError` replaces the legacy log writers (all production log
272
- points preserved). Returns the full orchestration surface
273
- (`performBuyClick`, `optimisticTotal(Cents)`, `deliveryReady`, …).
268
+ (Cartbase regions embed NO countries array). Fee prediction is never
269
+ hardcoded: each method LISTING entry carries its own
270
+ `fee_amount`/`fee_label`. `logError` replaces the legacy log writers
271
+ (all production log points preserved). Returns the full orchestration
272
+ surface (`performBuyClick`, `optimisticTotal(Cents)`, `deliveryReady`, …).
274
273
  - **Cartbase specifics** — zero-remainder gift path: `prepareCheckout`
275
- returning `client_secret:null` + `provider_id:null` SKIPS Stripe and
276
- completes on the gift session ([gift-cards.md](gift-cards.md)). Provider
277
- ids are `pp_stripe`/`pp_cod`/`pp_manual` exactly; `pp_manual` doubles as
278
- the offline tab when no true COD provider exists (fee predicted only for
279
- `pp_cod`). COD fee reads the cart-level `cod_fee_total` decoration.
274
+ returning `client_secret:null` + `provider_id:null` +
275
+ `payment_method_id:null` SKIPS Stripe and completes on the gift session
276
+ ([gift-cards.md](gift-cards.md)). Processors are `pp_stripe` exactly;
277
+ merchant methods list as `{payment_method_id, name, kind, instructions,
278
+ fee_amount, fee_label}` entries the COD-kind method wins the offline
279
+ tab, else the first manual method. The charged fee reads the cart-level
280
+ `payment_method_fee_total` decoration.
280
281
  - **Settings** — checkout rules (filter the listings + complete guard),
281
- COD integration (fee), Stripe credentials, gift cards, `accounts_mode`.
282
+ the methods' own fee configuration (Payments settings), Stripe
283
+ credentials, gift cards, `accounts_mode`.
282
284
 
283
285
  ### `<CheckoutClient />` — `checkout/checkout-client`
284
286
 
@@ -383,11 +385,11 @@ code-first through the error-copy maps, never raw API strings.
383
385
  badge. `LineItemCard` is the standalone card variant.
384
386
  - **SDK calls** — `carts.updateLineItem` (quantity); child widgets below.
385
387
  Totals are rendered STRAIGHT from the cart decoration: `item_total`,
386
- `shipping_total`, `cod_fee_total`/`cod_fee_label`, `discount_total`,
388
+ `shipping_total`, `payment_method_fee_total`/`payment_method_fee_label`, `discount_total`,
387
389
  `tax_total`, `total`, `gift_card_total`, `gift_card_remainder`.
388
390
  - **Props contract** — `{client, cart, optimisticShippingCost,
389
391
  onOptimisticShippingClear?, optimisticCodFee?, onOptimisticCodFeeClear?,
390
- codFeeLabel?, showGiftCards?, onCartChange?}`. Optimistic values clear
392
+ methodFeeLabel?, showGiftCards?, onCartChange?}`. Optimistic values clear
391
393
  automatically once the server cart catches up.
392
394
  - **Settings** — COD integration (fee row), gift cards, promotions.
393
395
 
@@ -445,8 +447,7 @@ extra modules beyond the per-file exports, imported from
445
447
 
446
448
  ---
447
449
 
448
- ## Family: cart-drawer (`@cartbase/storefront/cart-drawer/*`) — SHIPPED
449
-
450
+ ## Family: cart-drawer (`@cartbase/storefront/cart-drawer/*`)
450
451
  Sliding cart UI, production-proven layout. All
451
452
  components are `"use client"`. Money is EUR decimal major units everywhere
452
453
  (cart totals are SERVER truth from the decorated cart — components render,
@@ -570,8 +571,8 @@ Domain doc for every call: [carts.md](carts.md); gift-card tender:
570
571
  - **Purpose** — full totals breakdown rendered EXACTLY from the decorated
571
572
  cart: `subtotal`, `discount_total` (>0, negated for display),
572
573
  `shipping_total` (once a shipping method is set; 0 renders FREE; before
573
- that "calculated at checkout"), `tax_total` (>0), `cod_fee_total` (>0,
574
- labeled by the server's `cod_fee_label`), `total`, then one row per
574
+ that "calculated at checkout"), `tax_total` (>0), `payment_method_fee_total` (>0,
575
+ labeled by the server's `payment_method_fee_label`), `total`, then one row per
575
576
  applied gift card (masked `last4`, negated; a depleted card stays listed
576
577
  at 0) and `gift_card_remainder` — what the remainder provider charges.
577
578
  Row selection is the pure `selectSummaryRows(cart)` (unit-tested).
@@ -609,8 +610,7 @@ Domain doc for every call: [carts.md](carts.md); gift-card tender:
609
610
 
610
611
  ---
611
612
 
612
- ## Family: products (`@cartbase/storefront/products/*`) — SHIPPED
613
-
613
+ ## Family: products (`@cartbase/storefront/products/*`)
614
614
  The PDP + product-card family, production-proven. All prices
615
615
  render the SERVER-computed `variant.calculated_price` via
616
616
  `lib/get-product-price` (Cartbase's flat `price_list_type` wire shape) — no
@@ -754,8 +754,7 @@ with a legacy flat-row fallback. Unit-tested
754
754
  `ProductLabelsProvider` for i18n; `addToCart`/`openCart` seams as on
755
755
  `ProductActions`.
756
756
 
757
- ## Family: store (`@cartbase/storefront/store/*`) — SHIPPED
758
-
757
+ ## Family: store (`@cartbase/storefront/store/*`)
759
758
  The listing family: paginated grids, sort, collection/category/search
760
759
  templates. Sorting discipline: the API's `order` param is the authority for
761
760
  paginated listings; client-side re-sort (`lib/sort-products`) exists ONLY
@@ -859,8 +858,7 @@ search UIs (chips, drawers) that want the same URL contract.
859
858
 
860
859
  ---
861
860
 
862
- ## Family: order (`@cartbase/storefront/order/*`) — SHIPPED
863
-
861
+ ## Family: order (`@cartbase/storefront/order/*`)
864
862
  Order confirmation + account order views, production-proven. Some
865
863
  platforms ship ONE `StoreOrder` object carrying computed line
866
864
  totals, order totals, shipping methods and payments; Cartbase splits those
@@ -894,7 +892,7 @@ component also takes a `labels` prop pick.
894
892
  rybbit, deduped by `order.display_id`) is APP-OWNED: fire it from the
895
893
  confirmation route exactly once per order per the tracking family's
896
894
  dedupe contract — the template deliberately does NOT fire it.
897
- - **Settings** — COD settings (fee row presence + `cod_fee_label`),
895
+ - **Settings** — COD settings (fee row presence + `payment_method_fee_label`),
898
896
  checkout rules (which provider ids appear), store locales (labels pack).
899
897
 
900
898
  ### `<OrderConfirmationHeader order />` — `order/order-confirmation-header`
@@ -917,19 +915,19 @@ component also takes a `labels` prop pick.
917
915
  COD fees are never line items, so on pure Cartbase data the filter is a
918
916
  no-op safety net. Newest-first sort by `createdAt` when present.
919
917
 
920
- ### `<OrderTotals totals currencyCode items? codFeeLabel? />` — `order/order-totals`
918
+ ### `<OrderTotals totals currencyCode items? methodFeeLabel? />` — `order/order-totals`
921
919
 
922
920
  - **Purpose** — the money breakdown: Subtotal / Shipping (FREE badge at
923
921
  0) / COD fee / Discount (negated) / Tax / Total, all via `DualPrice`.
924
922
  - **Data seam** — `OrderTotalsSource` (the decorated cart satisfies it:
925
923
  `item_subtotal`, `shipping_subtotal`, `discount_total`, `tax_total`,
926
- `total`, `cod_fee_total`, `cod_fee_label`); the summary snapshot adapts
924
+ `total`, `payment_method_fee_total`, `payment_method_fee_label`); the summary snapshot adapts
927
925
  via `orderTotalsFromSummary`. Row policy is the pure, unit-tested
928
- `selectOrderTotalsRows`: native `cod_fee_total` wins over a legacy fee
926
+ `selectOrderTotalsRows`: native `payment_method_fee_total` wins over a legacy fee
929
927
  LINE; a legacy fee line's net is subtracted from the visible subtotal
930
- (v2.3.1 production fix); COD label preference `codFeeLabel` prop →
931
- server `cod_fee_label` → fee-line title → `labels.codFee`.
932
- - **Settings** — COD settings (`cod_fee_total`/`cod_fee_label`),
928
+ (v2.3.1 production fix); COD label preference `methodFeeLabel` prop →
929
+ server `payment_method_fee_label` → fee-line title → `labels.paymentMethodFee`.
930
+ - **Settings** — COD settings (`payment_method_fee_total`/`payment_method_fee_label`),
933
931
  promotions (discount row).
934
932
 
935
933
  ### `<OrderAddressCard order />` — `order/order-address-card`
@@ -954,11 +952,13 @@ component also takes a `labels` prop pick.
954
952
 
955
953
  ### `<OrderPaymentCard providerId cardLast4? />` — `order/order-payment-card`
956
954
 
957
- - Payment method card; `resolvePaymentTitle` buckets the provider id via
958
- `lib/payment-constants` (`pp_stripe` card, `pp_system_default` COD)
959
- through the locale pack, falling back to `paymentInfoMap` then the raw
960
- id. Payment internals never cross the Cartbase store surface — the id
961
- arrives via props from checkout state.
955
+ - Payment method card; `resolvePaymentTitle(providerId, titles,
956
+ methodName?)` the method's merchant NAME wins verbatim when present
957
+ (the snapshot from session data); otherwise the processor id buckets
958
+ via `lib/payment-constants` (`pp_stripe` = card) through the locale
959
+ pack, falling back to `paymentInfoMap` then the raw id. Payment
960
+ internals never cross the Cartbase store surface — both arrive via
961
+ props from checkout state.
962
962
 
963
963
  ### `<OrderTimeline fulfillmentStatus? />` — `order/order-timeline`
964
964
 
@@ -975,8 +975,7 @@ component also takes a `labels` prop pick.
975
975
 
976
976
  ---
977
977
 
978
- ## Family: common (`@cartbase/storefront/common/*`) — SHIPPED
979
-
978
+ ## Family: common (`@cartbase/storefront/common/*`)
980
979
  Shared storefront chrome, production-proven.
981
980
 
982
981
  ### `<LocalizedLink href … />` — `common/localized-link`
@@ -1028,8 +1027,7 @@ Shared storefront chrome, production-proven.
1028
1027
 
1029
1028
  ---
1030
1029
 
1031
- ## Family: reviews-ui (`@cartbase/storefront/reviews-ui`) — SHIPPED
1032
-
1030
+ ## Family: reviews-ui (`@cartbase/storefront/reviews-ui`)
1033
1031
  Verified-purchase review components, ported from a production storefront,
1034
1032
  over `api/reviews`. ONE barrel export seam: everything imports from
1035
1033
  `@cartbase/storefront/reviews-ui`. Endpoint truth:
@@ -1,4 +1,4 @@
1
- # Consent — Consent Mode v2 banner config
1
+ # Consent
2
2
 
3
3
  The store's CMP configuration for the built-in Consent Mode v2 banner
4
4
  (consent-management card). Defaults are **always applied server-side**, so
@@ -1,4 +1,4 @@
1
- # Content — pages + blogs
1
+ # Content
2
2
 
3
3
  Shopify Storefront `Page` / `Article` shapes **verbatim** so storefront code
4
4
  ports 1:1. **PUBLISHED only** — drafts and deleted rows 404 (lib status
@@ -1,4 +1,4 @@
1
- # Customers — profile, addresses, documents
1
+ # Customers
2
2
 
3
3
  The signed-in customer surface. Every endpoint here requires a **customer
4
4
  session**: `authorization: Bearer <supabase jwt>` (minted by the
@@ -1,4 +1,4 @@
1
- # Deploy & hosting
1
+ # Deploy
2
2
 
3
3
  Cartbase builds and hosts your storefront. You send the app's source files
4
4
  — one snapshot of the whole project — and Cartbase turns it into a
@@ -1,4 +1,4 @@
1
- # Gift cards — tender on carts
1
+ # Gift cards
2
2
 
3
3
  Gift-card redemption is a **payment tender** (`pp_giftcard`), never a
4
4
  discount: cart totals and VAT compute first and **never move**; applied
@@ -1,4 +1,4 @@
1
- # Store integrations config — carriers, COD, tracking, lockers
1
+ # Integrations
2
2
 
3
3
  Store-public integration configuration for render/checkout time
4
4
  (couriers-port + tracking-integrations cards). The payload is **composed**
@@ -1,4 +1,4 @@
1
- # Menus — backend-owned navigation
1
+ # Menus
2
2
 
3
3
  Shopify Storefront `Menu` shape **verbatim** (content-navigation card).
4
4
  Items store a typed resource reference; `url` is **computed at read time**
@@ -1,4 +1,4 @@
1
- # Metaobjects — merchant-defined content types
1
+ # Metaobjects
2
2
 
3
3
  Merchant-defined structured content (size charts, brand profiles, FAQ
4
4
  blocks) served by TYPE + HANDLE (metaobjects card). **ACTIVE entries only —
@@ -1,4 +1,4 @@
1
- # Orders — customer reads + transfers
1
+ # Orders
2
2
 
3
3
  The authenticated customer's order surface: list, detail (items +
4
4
  fulfillments with tracking + addresses) and order transfers. There is **no
@@ -1,4 +1,4 @@
1
- # Platform fingerprints — Cartbase detection
1
+ # Platform fingerprints
2
2
 
3
3
  Every Cartbase-powered storefront emits a small, deliberate set of signals
4
4
  so platform-detection tools (Wappalyzer, BuiltWith) classify the site as
@@ -1,4 +1,4 @@
1
- # Products & variants
1
+ # Products
2
2
 
3
3
  The catalog read surface. The product object documented here is THE
4
4
  canonical shape every discovery endpoint reuses (search results, collection
@@ -1,4 +1,4 @@
1
- # URL redirects — 404-path lookup
1
+ # Redirects
2
2
 
3
3
  Exact-match redirect lookup (seo-listings card 21). **Hot-path rule: call
4
4
  this ONLY from the storefront's not-found handler** — never on regular page
@@ -1,4 +1,4 @@
1
- # Regions, currencies, locales
1
+ # Regions
2
2
 
3
3
  Catalog-context primitives a storefront resolves at boot: regions feed the
4
4
  pricing context (`region_id` → region currency), currencies tell you what the
@@ -1,4 +1,4 @@
1
- # Reviews — widget, token wizard, photo rewards
1
+ # Reviews
2
2
 
3
3
  Verified-purchase reviews. Reviews exist **only** via a
4
4
  single-use, order-scoped, expiring **token** minted by the request scanner
@@ -1,4 +1,4 @@
1
- # Search & related products
1
+ # Search
2
2
 
3
3
  Configurable storefront search (search-discovery card) plus the PDP's
4
4
  related-products rail. Results are the SAME canonical product objects the
@@ -1,4 +1,4 @@
1
- # Subscriptions — the customer portal
1
+ # Subscriptions
2
2
 
3
3
  The "My subscriptions" surface (subscriptions-portal card): list, detail,
4
4
  schedule control, contract edits, cancel/reactivate and payment-method