@thorprovider/storefront 0.4.0-mvp.0 → 0.4.0
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.
- package/README.md +174 -156
- package/VENDOR.md +69 -0
- package/assets/openspec/config.yaml +38 -0
- package/assets/templates/AGENTS.md +76 -0
- package/assets/templates/app/app/[[...slug]]/page.tsx +56 -2
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +44 -2
- package/assets/templates/app/app/globals.css +5 -8
- package/assets/templates/app/app/layout.tsx +1 -5
- package/assets/templates/app/app/robots.ts +9 -3
- package/assets/templates/app/app/sitemap.ts +64 -5
- package/assets/templates/app/lib/__STOREFRONT__/account-boundary.client.tsx +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +461 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-mutation.client.ts +46 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-reconcile.client.ts +465 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +177 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.ts +44 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +65 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +135 -16
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +19 -9
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +61 -0
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +36 -4
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +17 -18
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +209 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.ts +247 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +123 -62
- package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +3 -0
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +78 -25
- package/assets/templates/app/lib/__STOREFRONT__/section-observation.ts +182 -0
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +128 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +31 -7
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +81 -26
- package/assets/templates/app/lib/__STOREFRONT__/spec/seo.ts +165 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +4 -2
- package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +26 -7
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +100 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +39 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +1 -1
- package/assets/templates/features/checkout/handlers.ts +6 -0
- package/assets/templates/features/customer-auth/handlers.ts +19 -23
- package/assets/templates/features/customer-auth/state.ts +31 -1
- package/assets/templates/views/account/index.tsx +20 -8
- package/assets/templates/views/account/registry.tsx +294 -154
- package/assets/templates/views/account/schema.ts +1 -0
- package/assets/templates/views/cart/content.ts +11 -0
- package/assets/templates/views/cart/data.ts +23 -0
- package/assets/templates/views/cart/index.tsx +53 -0
- package/assets/templates/views/cart/props.ts +12 -0
- package/assets/templates/views/cart/registry.tsx +82 -0
- package/assets/templates/views/cart/schema.ts +52 -0
- package/assets/templates/views/category/assembly/assembly.json +2 -1
- package/assets/templates/views/category/assembly/index.skeleton.tsx +64 -6
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +7 -6
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +5 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/catalog.part +4 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/element.part +7 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/registry.part +18 -0
- package/assets/templates/views/category/index.tsx +76 -7
- package/assets/templates/views/category/props.ts +7 -0
- package/assets/templates/views/category/registry.tsx +25 -6
- package/assets/templates/views/category/schema.ts +13 -0
- package/assets/templates/views/checkout/registry.tsx +3 -5
- package/assets/templates/views/home/assembly/assembly.json +12 -3
- package/assets/templates/views/home/assembly/index.skeleton.tsx +24 -5
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +4 -1
- package/assets/templates/views/home/assembly/slots/benefits/cards/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/cards/registry.part +17 -0
- package/assets/templates/views/home/assembly/slots/benefits/split/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part +6 -2
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +8 -0
- package/assets/templates/views/home/assembly/slots/categories/{ProductCategory2 → CategoryGrid}/element.part +1 -1
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +31 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/element.part +5 -0
- package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/registry.part +5 -3
- package/assets/templates/views/home/content.ts +22 -0
- package/assets/templates/views/home/data.ts +9 -0
- package/assets/templates/views/home/index.tsx +34 -11
- package/assets/templates/views/home/props.ts +1 -0
- package/assets/templates/views/home/registry.tsx +41 -17
- package/assets/templates/views/home/schema.ts +141 -24
- package/assets/templates/views/product/data.ts +5 -3
- package/assets/templates/views/product/index.tsx +49 -5
- package/assets/templates/views/product/props.ts +7 -0
- package/assets/templates/views/product/registry.tsx +34 -5
- package/assets/templates/views/product/schema.ts +49 -1
- package/assets/templates/views/static/content.ts +4 -4
- package/assets/templates/views/static/index.tsx +1 -1
- package/bin/storefront.js +1231 -154
- package/examples/merchandising/category-led.json +37 -0
- package/examples/merchandising/collection-led.json +37 -0
- package/package.json +10 -7
- package/recipes/archetypes.json +33 -46
- package/recipes/catalog.json +245 -153
- package/recipes/catalog.mjs +10 -0
- package/recipes/catalog.schema.json +4 -0
- package/recipes/features.json +28 -5
- package/recipes/recipe.schema.json +1 -1
- package/recipes/recipes.json +159 -59
- package/recipes/sections.json +10 -0
- package/recipes/validate.mjs +75 -4
- package/scripts/candidate.mjs +4 -4
- package/scripts/composers.mjs +25 -5
- package/scripts/env-file.mjs +86 -0
- package/scripts/file-classes.mjs +15 -0
- package/scripts/migrate-english-routes.mjs +276 -0
- package/scripts/ownership-conflict.mjs +5 -2
- package/scripts/pinning.mjs +74 -5
- package/scripts/plan-apply.mjs +149 -5
- package/scripts/reconcile.mjs +49 -11
- package/scripts/render-templates.mjs +97 -44
- package/scripts/section-config.mjs +253 -0
- package/scripts/starter.mjs +17 -0
- package/scripts/theme/color.mjs +185 -0
- package/scripts/theme/css-theme.mjs +233 -0
- package/scripts/theme/fonts.mjs +123 -0
- package/scripts/theme/import-export.mjs +125 -0
- package/scripts/theme/preset.mjs +93 -0
- package/scripts/theme/theme-plan.mjs +292 -0
- package/scripts/theme/tokens.mjs +137 -0
- package/scripts/view-assembly.mjs +57 -3
- package/scripts/view-selection.mjs +1 -1
- package/skills/sf-feature/SKILL.md +32 -19
- package/skills/sf-setup/SKILL.md +79 -0
- package/skills/sf-theme-gen/SKILL.md +99 -36
- package/skills/sf-theme-gen/references/shadcn-theming.md +87 -0
- package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md +15 -19
- package/skills/{shadcn-theming → sf-theme-gen}/references/theming-guide.md +6 -11
- package/skills/sf-view-gen/SKILL.md +63 -40
- package/skills/sf-view-gen/assets/recipes/archetypes.json +33 -46
- package/skills/sf-view-gen/assets/recipes/catalog.json +245 -153
- package/skills/sf-view-gen/assets/recipes/catalog.schema.json +4 -0
- package/skills/sf-view-gen/assets/recipes/features.json +28 -5
- package/skills/sf-view-gen/assets/recipes/recipes.json +159 -59
- package/skills/sf-view-gen/assets/recipes/sections.json +10 -0
- package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +100 -0
- package/skills/sf-view-gen/assets/templates/views/sections/products.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +39 -0
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +1 -1
- package/skills/{json-render-core/SKILL.md → sf-view-gen/references/json-render-core.md} +4 -27
- package/skills/{json-render-next/SKILL.md → sf-view-gen/references/json-render-next.md} +5 -8
- package/skills/{json-render-react/SKILL.md → sf-view-gen/references/json-render-react.md} +3 -5
- package/skills/{json-render-shadcn/SKILL.md → sf-view-gen/references/json-render-shadcn.md} +3 -5
- package/skills/sf-view-gen/references/views.md +28 -37
- package/skills/sf-view-gen/scripts/catalog.mjs +10 -0
- package/skills/sf-view-gen/scripts/validate.mjs +75 -4
- package/skills/storefront-workflow/SKILL.md +94 -31
- package/skills/{storefront-best-practices/reference/design.md → storefront-workflow/references/design-consistency.md} +13 -29
- package/CHANGELOG.md +0 -84
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +0 -10
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +0 -4
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +0 -16
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +0 -4
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/element.part +0 -5
- package/assets/templates/views/user-panel/index.tsx +0 -106
- package/assets/templates/views/user-panel/registry.tsx +0 -54
- package/assets/templates/views/user-panel/schema.ts +0 -79
- package/commands/sf-add-view.md +0 -57
- package/commands/sf-feature.md +0 -28
- package/commands/sf-theme.md +0 -26
- package/commands/sf-view.md +0 -67
- package/skills/building-storefronts/SKILL.md +0 -178
- package/skills/building-storefronts/references/frontend-integration.md +0 -229
- package/skills/json-render-remotion/SKILL.md +0 -111
- package/skills/json-render-solid/SKILL.md +0 -204
- package/skills/nextjs-shadcn/SKILL.md +0 -367
- package/skills/nextjs-shadcn/references/architecture.md +0 -499
- package/skills/nextjs-shadcn/references/project-setup.md +0 -162
- package/skills/nextjs-shadcn/references/shadcn-platform.md +0 -261
- package/skills/nextjs-shadcn/references/sidebar.md +0 -274
- package/skills/nextjs-shadcn/references/styling.md +0 -555
- package/skills/shadcn-component-discovery/SKILL.md +0 -273
- package/skills/shadcn-component-discovery/references/registries.md +0 -226
- package/skills/shadcn-theming/SKILL.md +0 -104
- package/skills/storefront-best-practices/SKILL.md +0 -421
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +0 -123
- package/skills/storefront-best-practices/reference/components/cart-popup.md +0 -189
- package/skills/storefront-best-practices/reference/components/country-selector.md +0 -298
- package/skills/storefront-best-practices/reference/components/footer.md +0 -112
- package/skills/storefront-best-practices/reference/components/hero.md +0 -241
- package/skills/storefront-best-practices/reference/components/megamenu.md +0 -239
- package/skills/storefront-best-practices/reference/components/navbar.md +0 -397
- package/skills/storefront-best-practices/reference/components/popups.md +0 -221
- package/skills/storefront-best-practices/reference/components/product-card.md +0 -125
- package/skills/storefront-best-practices/reference/components/product-reviews.md +0 -217
- package/skills/storefront-best-practices/reference/components/product-slider.md +0 -174
- package/skills/storefront-best-practices/reference/components/search.md +0 -101
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +0 -391
- package/skills/storefront-best-practices/reference/features/promotions.md +0 -307
- package/skills/storefront-best-practices/reference/features/wishlist.md +0 -230
- package/skills/storefront-best-practices/reference/layouts/account.md +0 -380
- package/skills/storefront-best-practices/reference/layouts/cart.md +0 -316
- package/skills/storefront-best-practices/reference/layouts/checkout.md +0 -486
- package/skills/storefront-best-practices/reference/layouts/home-page.md +0 -264
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +0 -231
- package/skills/storefront-best-practices/reference/layouts/product-details.md +0 -527
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +0 -520
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +0 -356
- package/skills/storefront-best-practices/reference/medusa.md +0 -307
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/element.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/element.part +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/mobile-responsiveness.md +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/seo.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Optional section fragment: logoCloud (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LogoCloudBlock from '@thorprovider/blocks/blocks/marketing/logo-clouds/logo-cloud-1'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
// Mirrors the LogoCloud1Platform/LogoCloud1Props block contracts. `id` is a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Optional section fragment: pricing (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import PricingBlock from '@thorprovider/blocks/blocks/marketing/pricing/pricing-section-1'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
// Mirrors the PricingTier/PricingSection1Props block contracts.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: products (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in products.tsx. A data-bound section
|
|
5
|
+
// renders one of two verified presentations (the canonical ProductGrid listing,
|
|
6
|
+
// or the combined grid-and-carousel ProductShowcase1) chosen by the resolved
|
|
7
|
+
// `variant`. The selection and resolved products arrive through the view state;
|
|
8
|
+
// this boundary only validates them and wires navigation/purchase callbacks.
|
|
9
|
+
|
|
10
|
+
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
11
|
+
import ProductShowcase1Block from '@thorprovider/blocks/blocks/e-commerce/product-list/product-showcase-1'
|
|
12
|
+
import type { ProductPresentation } from '@thorprovider/blocks/contracts'
|
|
13
|
+
import { useStateStore } from '@json-render/react'
|
|
14
|
+
import { useSectionObservation } from '../../section-observation'
|
|
15
|
+
import { productsPropsSchema, type ProductsStatus } from './schema.products'
|
|
16
|
+
import type { ViewRegistry } from '../types'
|
|
17
|
+
|
|
18
|
+
// Truthful, actionable messages for the non-`ready` states. A failed or
|
|
19
|
+
// unconfigured section never fabricates products.
|
|
20
|
+
function sectionStatusMessage(status: ProductsStatus): string {
|
|
21
|
+
switch (status) {
|
|
22
|
+
case 'unconfigured':
|
|
23
|
+
return 'Esta sección de productos aún no tiene una selección configurada.'
|
|
24
|
+
case 'empty':
|
|
25
|
+
return 'Esta selección no tiene productos disponibles por ahora.'
|
|
26
|
+
case 'invalid-query':
|
|
27
|
+
return 'La selección de productos de esta sección no es válida.'
|
|
28
|
+
case 'unsupported-query':
|
|
29
|
+
return 'Esta selección usa criterios que el catálogo no admite.'
|
|
30
|
+
case 'unmounted-capability':
|
|
31
|
+
return 'Esta selección requiere una capacidad que este catálogo no tiene montada.'
|
|
32
|
+
case 'data-error':
|
|
33
|
+
return 'No se pudieron cargar los productos de esta sección.'
|
|
34
|
+
default:
|
|
35
|
+
return ''
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const productsRegistry: ViewRegistry = {
|
|
40
|
+
Products: ({ props, emit }) => {
|
|
41
|
+
const { set } = useStateStore()
|
|
42
|
+
const parsed = productsPropsSchema.parse(props)
|
|
43
|
+
const { containerRef, noteProductClick } = useSectionObservation({
|
|
44
|
+
sectionId: parsed.sectionId ?? '',
|
|
45
|
+
sectionType: parsed.sectionType ?? 'products',
|
|
46
|
+
...(parsed.variant ? { sectionVariant: parsed.variant } : {}),
|
|
47
|
+
...(parsed.objective ? { objective: parsed.objective } : {}),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (parsed.status !== 'ready') {
|
|
51
|
+
return (
|
|
52
|
+
<section
|
|
53
|
+
aria-label={parsed.heading ?? 'Productos'}
|
|
54
|
+
className="mx-auto w-full max-w-7xl px-4 py-12"
|
|
55
|
+
>
|
|
56
|
+
{parsed.heading ? (
|
|
57
|
+
<h2 className="mb-2 text-2xl font-semibold tracking-tight">{parsed.heading}</h2>
|
|
58
|
+
) : null}
|
|
59
|
+
<p className="text-sm text-muted-foreground">{sectionStatusMessage(parsed.status)}</p>
|
|
60
|
+
</section>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The detail affordance opens the product so a variant is chosen explicitly.
|
|
65
|
+
// It is also the section's observation origin (disabled by default).
|
|
66
|
+
const openProduct = (product: ProductPresentation) => {
|
|
67
|
+
noteProductClick(product)
|
|
68
|
+
set('/lastClicked', product)
|
|
69
|
+
emit('openProduct')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Product-card shortcut: the add affordance adds the product's first
|
|
73
|
+
// purchasable variant (resolved server-side from the product id), then opens
|
|
74
|
+
// the mini-cart. It is not the section's observation origin.
|
|
75
|
+
const addToCart = (product: ProductPresentation) => {
|
|
76
|
+
set('/lastClicked', product)
|
|
77
|
+
emit('addClickedToCart')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const shared = {
|
|
81
|
+
onAddToCart: addToCart,
|
|
82
|
+
onProductClick: openProduct,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div ref={containerRef}>
|
|
87
|
+
{parsed.variant === 'ProductShowcase1' ? (
|
|
88
|
+
<ProductShowcase1Block
|
|
89
|
+
{...shared}
|
|
90
|
+
heading={parsed.heading}
|
|
91
|
+
description={parsed.description}
|
|
92
|
+
products={parsed.products}
|
|
93
|
+
/>
|
|
94
|
+
) : (
|
|
95
|
+
<ProductGridBlock {...shared} heading={parsed.heading} items={parsed.products} />
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
)
|
|
99
|
+
},
|
|
100
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Optional section fragment: products (mirrors recipes/sections.json)
|
|
2
|
+
// Server-side part: element type + zod catalog entry. The component mappings
|
|
3
|
+
// live in products.client.tsx ('use client'). Unlike the stateless editorial
|
|
4
|
+
// fragments (faq/cta), the products section is data-bound: its per-instance
|
|
5
|
+
// selection is resolved by the host loader and delivered through the view state,
|
|
6
|
+
// so this catalog entry describes the *resolved* props shape.
|
|
7
|
+
|
|
8
|
+
import { productsPropsSchema } from './schema.products'
|
|
9
|
+
|
|
10
|
+
export const productsSection = {
|
|
11
|
+
elementType: 'Products',
|
|
12
|
+
catalog: {
|
|
13
|
+
Products: {
|
|
14
|
+
props: productsPropsSchema,
|
|
15
|
+
description: 'Data-bound product presentation (grid or combined grid-and-carousel).',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
registryModule: './products.client',
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Optional section fragment: products (mirrors recipes/sections.json) — shared contract.
|
|
2
|
+
// Zod mirror of the resolved Products section props, shared by the server catalog
|
|
3
|
+
// (products.tsx) and the client registry (products.client.tsx). The product list
|
|
4
|
+
// reuses the canonical presentation contract owned by @thorprovider/blocks so the
|
|
5
|
+
// section renders exactly what the host mapped from the catalog result.
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import { productPresentationSchema } from '@thorprovider/blocks/contracts'
|
|
9
|
+
|
|
10
|
+
// The per-instance resolution status the host loader computes for a data-bound
|
|
11
|
+
// section. `ready`/`empty` carry resolved products; the remaining states carry no
|
|
12
|
+
// products and render an actionable, truthful message instead.
|
|
13
|
+
export const productsStatusSchema = z.enum([
|
|
14
|
+
'unconfigured',
|
|
15
|
+
'ready',
|
|
16
|
+
'empty',
|
|
17
|
+
'invalid-query',
|
|
18
|
+
'unsupported-query',
|
|
19
|
+
'unmounted-capability',
|
|
20
|
+
'data-error',
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export const productsPropsSchema = z.object({
|
|
24
|
+
sectionId: z.string().min(1).optional(),
|
|
25
|
+
sectionType: z.string().min(1).optional(),
|
|
26
|
+
variant: z.string().optional(),
|
|
27
|
+
// Defensive defaults: a missing resolved state (e.g. the view loader could not
|
|
28
|
+
// run) degrades to a truthful error instead of crashing the render.
|
|
29
|
+
status: productsStatusSchema.default('data-error'),
|
|
30
|
+
products: z.array(productPresentationSchema).default([]),
|
|
31
|
+
heading: z.string().optional(),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
objective: z.string().optional(),
|
|
34
|
+
ctaLabel: z.string().optional(),
|
|
35
|
+
ctaHref: z.string().optional(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export type ProductsProps = z.infer<typeof productsPropsSchema>
|
|
39
|
+
export type ProductsStatus = z.infer<typeof productsStatusSchema>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Optional section fragment: statistics (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import StatisticBlock from '@thorprovider/blocks/blocks/marketing/statistics/statistic-1'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
import { resolveIcon } from '../../icon-map'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Optional section fragment: testimonials (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import TestimonialBlock from '@thorprovider/blocks/blocks/marketing/testimonials/testimonial-1'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
// Mirrors the Testimonial1Item/Testimonial1Props block contracts.
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
syncCheckoutAddressAction,
|
|
16
16
|
} from '../../actions'
|
|
17
17
|
import type { CartStatePatch, PlaceOrderResult } from '../../commerce'
|
|
18
|
+
import { recordConfirmedTransition } from '../../section-observation'
|
|
18
19
|
|
|
19
20
|
// The always-required core of an address. Optional fields (province, phone,
|
|
20
21
|
// postal code) are left to the runtime validator so the host does not impose a
|
|
@@ -49,6 +50,9 @@ export function useCheckoutHandlers() {
|
|
|
49
50
|
const applyResult = (result: PlaceOrderResult) => {
|
|
50
51
|
set('/checkoutPending', false)
|
|
51
52
|
if (result.status === 'order') {
|
|
53
|
+
// A confirmed, persisted order — observed only on a genuine order result
|
|
54
|
+
// (not captured funds) and only when a section origin exists.
|
|
55
|
+
recordConfirmedTransition('order_confirmed')
|
|
52
56
|
// ONE atomic write carries the order and its backend lines.
|
|
53
57
|
set('/lastReceipt', { order: result.order, lines: result.lines })
|
|
54
58
|
set('/orderStatus', 'complete')
|
|
@@ -93,6 +97,8 @@ export function useCheckoutHandlers() {
|
|
|
93
97
|
|
|
94
98
|
const handlers: Record<string, () => void> = {
|
|
95
99
|
goToCheckout: () => {
|
|
100
|
+
// A confirmed checkout transition (the shopper started checkout).
|
|
101
|
+
recordConfirmedTransition('checkout_started')
|
|
96
102
|
set('/cartOpen', false)
|
|
97
103
|
navigate('/checkout')
|
|
98
104
|
},
|
|
@@ -6,14 +6,26 @@
|
|
|
6
6
|
// registration are invoked directly by the view registry (their credential
|
|
7
7
|
// payload must never enter the state store); these handlers own the non-secret
|
|
8
8
|
// state transitions: the sign-in / sign-up toggle and logout.
|
|
9
|
+
//
|
|
10
|
+
// This hook is also the GLOBAL MOUNT of the shared account lifecycle: because
|
|
11
|
+
// the handlers composer runs inside the shell Layout, calling
|
|
12
|
+
// `useAccountLifecycleMount()` activates the one shared account lifecycle on
|
|
13
|
+
// every storefront route (only while customer-auth is installed). The lifecycle
|
|
14
|
+
// reads the SSR-seeded identity and never fetches on mount/navigation, so there
|
|
15
|
+
// is no competing route bootstrap.
|
|
9
16
|
|
|
10
17
|
import { useEffect } from 'react'
|
|
11
18
|
import { useActions, useStateStore } from '@json-render/react'
|
|
12
|
-
import {
|
|
19
|
+
import { useAccountLifecycleMount } from '../../account-lifecycle.client'
|
|
13
20
|
|
|
14
21
|
export function useCustomerAuthHandlers() {
|
|
15
22
|
const { set } = useStateStore()
|
|
16
23
|
const { registerHandler } = useActions()
|
|
24
|
+
// The shared lifecycle coordinator/reconciliation/mutation API for this tab.
|
|
25
|
+
// Mounted here; consumed by the shell, the account panel, and the account
|
|
26
|
+
// boundary. `lifecycle.logout` is stable across renders, so the effect below
|
|
27
|
+
// can capture it once.
|
|
28
|
+
const lifecycle = useAccountLifecycleMount()
|
|
17
29
|
|
|
18
30
|
useEffect(() => {
|
|
19
31
|
const handlers: Record<string, () => void> = {
|
|
@@ -26,28 +38,12 @@ export function useCustomerAuthHandlers() {
|
|
|
26
38
|
set('/accountMode', 'login')
|
|
27
39
|
},
|
|
28
40
|
logout: () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
set('/accountCustomer', null)
|
|
36
|
-
set('/accountAuthenticated', false)
|
|
37
|
-
set('/accountMode', 'login')
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
set('/accountError', result.error)
|
|
41
|
-
})
|
|
42
|
-
.catch((error) => {
|
|
43
|
-
// Never swallow: log a non-secret context line and surface a message.
|
|
44
|
-
console.error(
|
|
45
|
-
'[storefront/account] logout failed',
|
|
46
|
-
error instanceof Error ? error.message : error,
|
|
47
|
-
)
|
|
48
|
-
set('/accountPending', false)
|
|
49
|
-
set('/accountError', 'No se pudo cerrar la sesión. Inténtalo de nuevo.')
|
|
50
|
-
})
|
|
41
|
+
// The shared lifecycle owns the sign-out mutation: it captures a
|
|
42
|
+
// pre-action generation guard, shows pending, prevents duplicate
|
|
43
|
+
// submits, and on success claims the signed-out projection (all three
|
|
44
|
+
// account keys in lockstep) and refreshes the server. A failure keeps
|
|
45
|
+
// the current valid session — it never claims anonymous.
|
|
46
|
+
void lifecycle.logout()
|
|
51
47
|
},
|
|
52
48
|
}
|
|
53
49
|
|
|
@@ -3,15 +3,29 @@
|
|
|
3
3
|
// the manifest; the state composer spreads it over the core state.
|
|
4
4
|
|
|
5
5
|
import type { Customer } from '@thorprovider/types'
|
|
6
|
+
import type { AccountResolution } from '../../account-session.core'
|
|
6
7
|
import type { AccountOrderView } from '../../state.core'
|
|
7
8
|
|
|
8
9
|
export interface CustomerAuthState {
|
|
9
10
|
/** The resolved customer, or null when unauthenticated. Never a token. */
|
|
10
11
|
accountCustomer: Customer | null
|
|
11
12
|
accountAuthenticated: boolean
|
|
13
|
+
/**
|
|
14
|
+
* The truthful session resolution status seeded by the server projection.
|
|
15
|
+
* `unresolved` is the pre-projection default; `unavailable` is a retryable
|
|
16
|
+
* outage, never a fake sign-out.
|
|
17
|
+
*/
|
|
18
|
+
accountResolution: AccountResolution | 'unresolved'
|
|
12
19
|
/** Which auth surface is mounted: the sign-in page or the registration page. */
|
|
13
20
|
accountMode: 'login' | 'register'
|
|
14
21
|
accountPending: boolean
|
|
22
|
+
/**
|
|
23
|
+
* True while a cross-tab invalidation or a foreground/resume recheck is in
|
|
24
|
+
* flight (task 4.2). The `/account` authenticated region presents a neutral
|
|
25
|
+
* pending surface — never previously held identity/orders — until the
|
|
26
|
+
* authoritative re-resolution settles. Never a fake signed-out state.
|
|
27
|
+
*/
|
|
28
|
+
accountReconciling: boolean
|
|
15
29
|
accountError: string | null
|
|
16
30
|
/** The customer's fetched order-history rows; empty until (or without) a load. */
|
|
17
31
|
accountOrders: AccountOrderView[]
|
|
@@ -19,18 +33,34 @@ export interface CustomerAuthState {
|
|
|
19
33
|
accountOrdersPending: boolean
|
|
20
34
|
/** The order-history load failure, or null when it loaded. */
|
|
21
35
|
accountOrdersError: string | null
|
|
22
|
-
/** The
|
|
36
|
+
/** The backend's real total for the authenticated customer on the store channel. */
|
|
37
|
+
accountOrdersCount: number
|
|
38
|
+
/** The 1-based order-history page currently loaded. */
|
|
39
|
+
accountOrdersPage: number
|
|
40
|
+
/** The bounded page size used for the order-history window. */
|
|
41
|
+
accountOrdersPageSize: number
|
|
42
|
+
/** The real backend order id selected for the inline detail; null when none is open. */
|
|
23
43
|
accountSelectedOrderId: string | null
|
|
24
44
|
}
|
|
25
45
|
|
|
26
46
|
export const customerAuthState: CustomerAuthState = {
|
|
27
47
|
accountCustomer: null,
|
|
28
48
|
accountAuthenticated: false,
|
|
49
|
+
accountResolution: 'unresolved',
|
|
29
50
|
accountMode: 'login',
|
|
30
51
|
accountPending: false,
|
|
52
|
+
accountReconciling: false,
|
|
31
53
|
accountError: null,
|
|
54
|
+
// The identity-dependent private order slice. Its reset lives in
|
|
55
|
+
// `account-private.core` (`emptyAccountPrivateOrderState`); a contract test
|
|
56
|
+
// keeps these initial values identical so the lifecycle's invalidation cannot
|
|
57
|
+
// drift from the seed. The guest cart slice lives in the core state and is
|
|
58
|
+
// never touched by an identity change.
|
|
32
59
|
accountOrders: [],
|
|
33
60
|
accountOrdersPending: false,
|
|
34
61
|
accountOrdersError: null,
|
|
62
|
+
accountOrdersCount: 0,
|
|
63
|
+
accountOrdersPage: 1,
|
|
64
|
+
accountOrdersPageSize: 10,
|
|
35
65
|
accountSelectedOrderId: null,
|
|
36
66
|
}
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
// on the server. Registered by importing it in ../index.ts. Recipe: recipes.json -> "account".
|
|
6
6
|
//
|
|
7
7
|
// The initial render does NOT read the auth cookie here (this module is part of
|
|
8
|
-
// the client catalog graph). The catch-all page
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// the client catalog graph). The catch-all page seeds the account identity for
|
|
9
|
+
// every route (tasks 2.1/2.2) and the globally mounted shared account lifecycle
|
|
10
|
+
// (feature customer-auth handlers) owns identity; the headless `AccountBoot`
|
|
11
|
+
// boundary is passive and only surfaces the retryable unavailable status, so no
|
|
12
|
+
// route-level identity fetch happens here.
|
|
11
13
|
|
|
12
14
|
import { getDataSource } from '../../store-context'
|
|
13
15
|
import { pageRoot } from '../../spec/page-root'
|
|
@@ -22,20 +24,27 @@ import {
|
|
|
22
24
|
accountRegisterPropsSchema,
|
|
23
25
|
} from './schema'
|
|
24
26
|
|
|
25
|
-
//
|
|
26
|
-
// panel.
|
|
27
|
-
//
|
|
27
|
+
// Surfaces: a passive boundary (headless unavailable/retry), sign-in,
|
|
28
|
+
// registration, and the signed-in panel. Sign-in and registration are toggled
|
|
29
|
+
// by `/accountMode` and hidden while the session is `unavailable`, so an outage
|
|
30
|
+
// shows the retryable boundary rather than a false signed-out form; the panel
|
|
31
|
+
// shows only when `/accountAuthenticated` is true.
|
|
28
32
|
const elements: Record<string, StorefrontElement> = {
|
|
29
33
|
'account.boot': {
|
|
30
34
|
type: 'AccountBoot',
|
|
31
35
|
props: {},
|
|
36
|
+
on: { retry: { action: 'retryAccountSession' } },
|
|
32
37
|
},
|
|
33
38
|
'account.login': {
|
|
34
39
|
type: 'AccountLogin',
|
|
35
40
|
visible: {
|
|
36
41
|
$and: [
|
|
37
42
|
{ $state: '/accountAuthenticated', not: true },
|
|
43
|
+
{ $state: '/accountResolution', neq: 'unavailable' },
|
|
38
44
|
{ $state: '/accountMode', eq: 'login' },
|
|
45
|
+
// While a reconciliation is in flight the sign-in form must not appear
|
|
46
|
+
// (that would fake a signed-out state before the server confirms it).
|
|
47
|
+
{ $state: '/accountReconciling', not: true },
|
|
39
48
|
],
|
|
40
49
|
},
|
|
41
50
|
props: accountContent.login,
|
|
@@ -46,7 +55,9 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
46
55
|
visible: {
|
|
47
56
|
$and: [
|
|
48
57
|
{ $state: '/accountAuthenticated', not: true },
|
|
58
|
+
{ $state: '/accountResolution', neq: 'unavailable' },
|
|
49
59
|
{ $state: '/accountMode', eq: 'register' },
|
|
60
|
+
{ $state: '/accountReconciling', not: true },
|
|
50
61
|
],
|
|
51
62
|
},
|
|
52
63
|
props: accountContent.register,
|
|
@@ -68,7 +79,8 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
68
79
|
const catalog = {
|
|
69
80
|
AccountBoot: {
|
|
70
81
|
props: accountEmptyPropsSchema,
|
|
71
|
-
description:
|
|
82
|
+
description:
|
|
83
|
+
'Passive account boundary: shows a retryable unavailable status when the session cannot be resolved, otherwise nothing. Never fetches identity.',
|
|
72
84
|
},
|
|
73
85
|
AccountLogin: {
|
|
74
86
|
props: accountLoginPropsSchema,
|
|
@@ -95,7 +107,7 @@ export const account: ViewModule = {
|
|
|
95
107
|
catalog,
|
|
96
108
|
registry,
|
|
97
109
|
route: {
|
|
98
|
-
path: '/
|
|
110
|
+
path: '/account',
|
|
99
111
|
loaderName: 'account',
|
|
100
112
|
layout: 'default',
|
|
101
113
|
metadata: {
|