@thorprovider/storefront 0.9.0 → 0.11.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 +8 -5
- package/assets/templates/app/app/globals.css +0 -1
- package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +4 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +130 -12
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +156 -9
- package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +38 -3
- package/assets/templates/app/lib/__STOREFRONT__/fulfillment-evidence-port.ts +31 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +21 -4
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +6 -2
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-aftersales.ts +55 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-capabilities.ts +79 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-mapper.ts +653 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-money.ts +39 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +6 -7
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-reorder.ts +62 -0
- package/assets/templates/app/lib/__STOREFRONT__/ports.ts +13 -3
- package/assets/templates/views/account/assembly/assembly.json +0 -5
- package/assets/templates/views/account/assembly/index.skeleton.tsx +51 -0
- package/assets/templates/views/account/assembly/registry.skeleton.tsx +120 -68
- package/assets/templates/views/account/content.ts +13 -7
- package/assets/templates/views/account/fulfillment-evidence.client.tsx +34 -0
- package/assets/templates/views/account/fulfillment-evidence.defaults.ts +145 -0
- package/assets/templates/views/account/fulfillment-evidence.schema.ts +15 -0
- package/assets/templates/views/account/index.tsx +44 -3
- package/assets/templates/views/account/order-detail-flows.defaults.ts +106 -0
- package/assets/templates/views/account/order-detail-invoice.ts +136 -0
- package/assets/templates/views/account/order-detail-sheet.tsx +100 -0
- package/assets/templates/views/account/order-detail-sheets.tsx +122 -0
- package/assets/templates/views/account/order-detail.client.tsx +401 -1
- package/assets/templates/views/account/orders-advanced.client.tsx +10 -99
- package/assets/templates/views/account/orders-advanced.defaults.ts +7 -7
- package/assets/templates/views/account/registry.tsx +120 -69
- package/assets/templates/views/account/schema.ts +2 -0
- package/assets/templates/views/home/assembly/assembly.json +1 -1
- package/assets/templates/views/home/assembly/index.skeleton.tsx +3 -1
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +1 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/element.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +10 -0
- package/assets/templates/views/home/content.ts +248 -2
- package/assets/templates/views/home/data.ts +10 -1
- package/assets/templates/views/home/index.tsx +7 -6
- package/assets/templates/views/home/props.ts +7 -1
- package/assets/templates/views/home/registry.tsx +11 -28
- package/assets/templates/views/home/schema.ts +163 -0
- package/assets/templates/views/product/data.ts +13 -6
- package/assets/templates/views/product/index.tsx +3 -3
- package/bin/storefront.js +18 -18
- package/package.json +1 -1
- package/recipes/adapter-surface.json +1 -0
- package/recipes/archetypes.json +5 -1
- package/recipes/catalog.json +9 -1
- package/recipes/recipes.json +5 -4
- package/scripts/candidate.mjs +59 -14
- package/scripts/file-classes.mjs +4 -0
- package/scripts/mock-capabilities.mjs +22 -0
- package/scripts/reconcile.mjs +5 -2
- package/scripts/render-templates.mjs +126 -43
- package/skills/sf-view-gen/assets/recipes/archetypes.json +5 -1
- package/skills/sf-view-gen/assets/recipes/catalog.json +9 -1
- package/skills/sf-view-gen/assets/recipes/recipes.json +5 -4
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +0 -5
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +0 -5
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +0 -1
|
@@ -21,4 +21,13 @@ export function toNavCategories(
|
|
|
21
21
|
// by default: a data-bound section with no entry renders an `unconfigured`
|
|
22
22
|
// state. Entries whose id is no longer referenced by the composition are kept
|
|
23
23
|
// but never queried, so re-adding the section with the same id restores them.
|
|
24
|
-
export const sectionSources: Record<string, unknown> = {
|
|
24
|
+
export const sectionSources: Record<string, unknown> = {
|
|
25
|
+
// The seeded merchandising grid: the mock catalog's real `best-sellers`
|
|
26
|
+
// collection through the canonical catalog bridge. The id matches the
|
|
27
|
+
// auto-minted instance id of the recipe's default `products` seed.
|
|
28
|
+
'home-products-1': {
|
|
29
|
+
kind: 'products',
|
|
30
|
+
query: { collections: ['best-sellers'], pageSize: 8 },
|
|
31
|
+
maxItems: 8,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
@@ -12,6 +12,7 @@ import type { ViewModule } from '../types'
|
|
|
12
12
|
import { registry } from './registry'
|
|
13
13
|
import { sectionData } from './sections-data'
|
|
14
14
|
import { benefitsProps, categoriesProps, heroProps } from './props'
|
|
15
|
+
import * as homeProps from './props'
|
|
15
16
|
import * as homeData from './data'
|
|
16
17
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
17
18
|
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
@@ -21,14 +22,14 @@ import {
|
|
|
21
22
|
featurePropsSchema,
|
|
22
23
|
storefrontHeroPropsSchema,
|
|
23
24
|
} from './schema'
|
|
25
|
+
import * as homeSchemas from './schema'
|
|
24
26
|
|
|
25
27
|
// The element tree is derived wiring; the rendered props come from the
|
|
26
28
|
// user-owned ./props.ts module so they survive sync and unit removal.
|
|
27
29
|
const elements: Record<string, StorefrontElement> = {
|
|
28
30
|
'home.hero': {
|
|
29
|
-
type: '
|
|
30
|
-
props:
|
|
31
|
-
on: { addClickedToCart: { action: 'addClickedToCart' }, openProduct: { action: 'openProduct' } },
|
|
31
|
+
type: 'UniversalBanner',
|
|
32
|
+
props: homeProps.heroBannerProps,
|
|
32
33
|
},
|
|
33
34
|
'home.benefits': {
|
|
34
35
|
type: 'Feature',
|
|
@@ -42,9 +43,9 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const catalog = {
|
|
45
|
-
|
|
46
|
-
props:
|
|
47
|
-
description: '
|
|
46
|
+
UniversalBanner: {
|
|
47
|
+
props: homeSchemas.universalBannerPropsSchema,
|
|
48
|
+
description: 'Campaign banner collection (presentations: single, grid, carousel).',
|
|
48
49
|
},
|
|
49
50
|
Feature: {
|
|
50
51
|
props: featurePropsSchema,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// and binds them into the element tree, so edits here survive `storefront sync`
|
|
5
5
|
// and unit removal. Plain data only: no React and no server imports.
|
|
6
6
|
|
|
7
|
-
import { benefitsContent, categoriesContent, heroContent, heroImage } from './content'
|
|
7
|
+
import { benefitsContent, categoriesContent, heroContent, heroBannerData, heroImage } from './content'
|
|
8
8
|
|
|
9
9
|
export const heroProps = {
|
|
10
10
|
...heroContent,
|
|
@@ -12,6 +12,12 @@ export const heroProps = {
|
|
|
12
12
|
heroImage,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// Banner-hero campaign props (hero slot, UniversalBanner variant). The wrapper
|
|
16
|
+
// shape mirrors `universalBannerPropsSchema` in ./schema.ts.
|
|
17
|
+
export const heroBannerProps = {
|
|
18
|
+
data: heroBannerData,
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
export const benefitsProps = {
|
|
16
22
|
...benefitsContent,
|
|
17
23
|
}
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
// the boundary instead of rendering undefined fields or literal icon tags.
|
|
12
12
|
|
|
13
13
|
import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
|
|
14
|
+
import { UniversalBanner as UniversalBannerBlock } from '@thorprovider/blocks'
|
|
14
15
|
import { CategoryGrid as CategoryGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/product-category-grid'
|
|
15
|
-
import { StorefrontHero as StorefrontHeroBlock } from '@thorprovider/blocks/blocks/e-commerce/storefront-hero/storefront-hero'
|
|
16
16
|
import { Feature as FeatureBlock } from '@thorprovider/blocks/blocks/marketing/features/feature'
|
|
17
|
+
import { useEffect, useState } from 'react'
|
|
17
18
|
import { useStateStore } from '@json-render/react'
|
|
18
19
|
import { resolveIcon } from '../../icon-map'
|
|
19
20
|
import type { ViewRegistry } from '../types'
|
|
@@ -26,33 +27,15 @@ import {
|
|
|
26
27
|
} from './schema'
|
|
27
28
|
|
|
28
29
|
export const registry: ViewRegistry = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
products={hero.products}
|
|
39
|
-
titleAccent={hero.titleAccent}
|
|
40
|
-
badge={hero.badge}
|
|
41
|
-
primaryCta={hero.primaryCta}
|
|
42
|
-
secondaryCta={hero.secondaryCta}
|
|
43
|
-
heroImage={hero.heroImage}
|
|
44
|
-
rotationInterval={hero.rotationInterval}
|
|
45
|
-
onAddToCart={(product) => {
|
|
46
|
-
// Product-card shortcut: add the first purchasable variant.
|
|
47
|
-
set('/lastClicked', product)
|
|
48
|
-
emit('addClickedToCart')
|
|
49
|
-
}}
|
|
50
|
-
onBuyNow={(product) => {
|
|
51
|
-
set('/lastClicked', product)
|
|
52
|
-
emit('openProduct')
|
|
53
|
-
}}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
30
|
+
UniversalBanner: ({ props }) => {
|
|
31
|
+
// The banner hero parses through the same contract the editorial section
|
|
32
|
+
// uses; `now` refreshes at mount so schedule awareness starts truthful.
|
|
33
|
+
const parsed = featureSchemas.universalBannerPropsSchema.parse(props)
|
|
34
|
+
const [now, setNow] = useState(parsed.data.now)
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setNow(new Date().toISOString())
|
|
37
|
+
}, [])
|
|
38
|
+
return <UniversalBannerBlock data={{ ...parsed.data, now }} />
|
|
56
39
|
},
|
|
57
40
|
Feature: ({ props }) => {
|
|
58
41
|
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
@@ -194,6 +194,167 @@ export const categoryGridPropsSchema = z.object({
|
|
|
194
194
|
skeletonCount: z.number().int().positive().optional(),
|
|
195
195
|
})
|
|
196
196
|
|
|
197
|
+
// Local mirror of the canonical UniversalBanner contract (delivery
|
|
198
|
+
// universal-banner, contract version 4.1.0) — the same shape the editorial
|
|
199
|
+
// section fragment mirrors. Kept local (not imported from the section module)
|
|
200
|
+
// so the home view stays self-contained for homes generated before that
|
|
201
|
+
// delivery. The React-only callbacks (onBannerClick, onCtaClick) are
|
|
202
|
+
// intentionally absent: they are consumer bindings, not serializable props.
|
|
203
|
+
const bannerTargetSchema = z.object({
|
|
204
|
+
kind: z.string(),
|
|
205
|
+
id: z.string().optional(),
|
|
206
|
+
slug: z.string().optional(),
|
|
207
|
+
query: z.string().optional(),
|
|
208
|
+
url: z.string().optional(),
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
const bannerPresentationSchema = z.object({
|
|
212
|
+
mode: z.enum(['image-only', 'overlay', 'split']),
|
|
213
|
+
width: z.enum(['full', 'content', 'custom']),
|
|
214
|
+
maxWidth: z.enum(['sm', 'md', 'lg', 'xl']).optional(),
|
|
215
|
+
height: z.enum(['auto', 'fixed', 'adaptive']),
|
|
216
|
+
heightToken: z.enum(['sm', 'md', 'lg', 'xl']).optional(),
|
|
217
|
+
aspect: z.enum(['square', 'video', 'photo', 'wide', 'tall', 'natural']),
|
|
218
|
+
fit: z.enum(['natural', 'cover', 'contain']),
|
|
219
|
+
focal: z.enum(['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right']),
|
|
220
|
+
align: z.enum(['center', 'start', 'end']),
|
|
221
|
+
radius: z.enum(['md', 'lg', 'xl', 'none', '2xl']),
|
|
222
|
+
surface: z.enum(['primary', 'secondary', 'none', 'card', 'muted', 'accent']),
|
|
223
|
+
overlay: z.enum(['none', 'scrim', 'gradient']),
|
|
224
|
+
overlayOpacity: z.enum(['light', 'medium', 'strong']),
|
|
225
|
+
padding: z.enum(['sm', 'md', 'lg', 'none']),
|
|
226
|
+
textScale: z.enum(['sm', 'md', 'lg']),
|
|
227
|
+
splitSide: z.enum(['media-start', 'media-end']).optional(),
|
|
228
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
const bannerOverrideSchema = z.object({
|
|
232
|
+
mode: z.enum(['image-only', 'overlay', 'split']).optional(),
|
|
233
|
+
width: z.enum(['full', 'content', 'custom']).optional(),
|
|
234
|
+
maxWidth: z.enum(['sm', 'md', 'lg', 'xl']).optional(),
|
|
235
|
+
height: z.enum(['auto', 'fixed', 'adaptive']).optional(),
|
|
236
|
+
heightToken: z.enum(['sm', 'md', 'lg', 'xl']).optional(),
|
|
237
|
+
aspect: z.enum(['square', 'video', 'photo', 'wide', 'tall', 'natural']).optional(),
|
|
238
|
+
fit: z.enum(['natural', 'cover', 'contain']).optional(),
|
|
239
|
+
focal: z.enum(['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right']).optional(),
|
|
240
|
+
align: z.enum(['center', 'start', 'end']).optional(),
|
|
241
|
+
radius: z.enum(['md', 'lg', 'xl', 'none', '2xl']).optional(),
|
|
242
|
+
surface: z.enum(['primary', 'secondary', 'none', 'card', 'muted', 'accent']).optional(),
|
|
243
|
+
overlay: z.enum(['none', 'scrim', 'gradient']).optional(),
|
|
244
|
+
overlayOpacity: z.enum(['light', 'medium', 'strong']).optional(),
|
|
245
|
+
padding: z.enum(['sm', 'md', 'lg', 'none']).optional(),
|
|
246
|
+
textScale: z.enum(['sm', 'md', 'lg']).optional(),
|
|
247
|
+
splitSide: z.enum(['media-start', 'media-end']).optional(),
|
|
248
|
+
hiddenFields: z.array(z.string()).optional(),
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
const bannerScheduleSchema = z.object({
|
|
252
|
+
from: z.string().optional(),
|
|
253
|
+
to: z.string().optional(),
|
|
254
|
+
timezone: z.string(),
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
export const universalBannerDataSchema = z.object({
|
|
258
|
+
campaign: z.object({
|
|
259
|
+
schemaVersion: z.number(),
|
|
260
|
+
campaignId: z.string(),
|
|
261
|
+
banners: z.array(
|
|
262
|
+
z.object({
|
|
263
|
+
id: z.string(),
|
|
264
|
+
campaignId: z.string(),
|
|
265
|
+
content: z.object({
|
|
266
|
+
name: z.string(),
|
|
267
|
+
alt: z.string(),
|
|
268
|
+
title: z.string().optional(),
|
|
269
|
+
subtitle: z.string().optional(),
|
|
270
|
+
description: z.string().optional(),
|
|
271
|
+
badge: z.string().optional(),
|
|
272
|
+
target: bannerTargetSchema.optional(),
|
|
273
|
+
ctas: z.array(
|
|
274
|
+
z.object({
|
|
275
|
+
id: z.string(),
|
|
276
|
+
label: z.string(),
|
|
277
|
+
target: bannerTargetSchema,
|
|
278
|
+
tone: z.enum(['primary', 'secondary']),
|
|
279
|
+
}),
|
|
280
|
+
),
|
|
281
|
+
}),
|
|
282
|
+
media: z.object({
|
|
283
|
+
desktop: z.string().optional(),
|
|
284
|
+
tablet: z.string().optional(),
|
|
285
|
+
mobile: z.string().optional(),
|
|
286
|
+
}),
|
|
287
|
+
presentation: bannerPresentationSchema,
|
|
288
|
+
responsive: z
|
|
289
|
+
.object({
|
|
290
|
+
md: bannerOverrideSchema.optional(),
|
|
291
|
+
'2xl': bannerOverrideSchema.optional(),
|
|
292
|
+
base: bannerOverrideSchema.optional(),
|
|
293
|
+
})
|
|
294
|
+
.optional(),
|
|
295
|
+
schedule: bannerScheduleSchema.optional(),
|
|
296
|
+
visible: z.boolean(),
|
|
297
|
+
}),
|
|
298
|
+
),
|
|
299
|
+
}),
|
|
300
|
+
config: z.object({
|
|
301
|
+
schemaVersion: z.number(),
|
|
302
|
+
blockId: z.string(),
|
|
303
|
+
name: z.string(),
|
|
304
|
+
visible: z.boolean(),
|
|
305
|
+
schedule: bannerScheduleSchema.optional(),
|
|
306
|
+
scheduleAware: z.boolean(),
|
|
307
|
+
responsiveEnabled: z.boolean(),
|
|
308
|
+
presentation: z.enum(['single', 'grid', 'carousel']),
|
|
309
|
+
preset: z.enum(['custom', 'one', 'two', 'three', 'four', 'mosaic', 'hero-two', 'hero-three']),
|
|
310
|
+
refs: z.array(
|
|
311
|
+
z.object({
|
|
312
|
+
bannerId: z.string(),
|
|
313
|
+
overrides: bannerOverrideSchema.optional(),
|
|
314
|
+
}),
|
|
315
|
+
),
|
|
316
|
+
layout: z.object({
|
|
317
|
+
gapX: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
318
|
+
gapY: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
319
|
+
maxWidth: z.enum(['full', 'sm', 'md', 'lg', 'xl']),
|
|
320
|
+
maxHeight: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
321
|
+
align: z.enum(['center', 'start', 'end']),
|
|
322
|
+
radius: z.enum(['md', 'lg', 'xl', 'none', '2xl']),
|
|
323
|
+
columns: z.object({ md: z.number(), '2xl': z.number(), base: z.number() }).optional(),
|
|
324
|
+
spans: z.array(z.number()).optional(),
|
|
325
|
+
}),
|
|
326
|
+
carousel: z.object({
|
|
327
|
+
visible: z.object({ md: z.number(), '2xl': z.number(), base: z.number() }),
|
|
328
|
+
autoplay: z.boolean(),
|
|
329
|
+
intervalMs: z.number(),
|
|
330
|
+
loop: z.boolean(),
|
|
331
|
+
indicators: z.boolean(),
|
|
332
|
+
carouselOnMobile: z.boolean(),
|
|
333
|
+
peek: z.boolean(),
|
|
334
|
+
story: z.boolean(),
|
|
335
|
+
}),
|
|
336
|
+
rules: z.object({
|
|
337
|
+
emptyLabel: z.string(),
|
|
338
|
+
inactiveLabel: z.string(),
|
|
339
|
+
danglingLabel: z.string(),
|
|
340
|
+
}),
|
|
341
|
+
}),
|
|
342
|
+
now: z.string(),
|
|
343
|
+
banner: z.object({
|
|
344
|
+
carouselPrevious: z.string(),
|
|
345
|
+
carouselNext: z.string(),
|
|
346
|
+
carouselStatus: z.string(),
|
|
347
|
+
carouselRole: z.string(),
|
|
348
|
+
storyPrevious: z.string(),
|
|
349
|
+
storyNext: z.string(),
|
|
350
|
+
storyRole: z.string(),
|
|
351
|
+
}),
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
export const universalBannerPropsSchema = z.object({
|
|
355
|
+
data: universalBannerDataSchema,
|
|
356
|
+
})
|
|
357
|
+
|
|
197
358
|
export type FeaturedProduct = z.infer<typeof featuredProductSchema>
|
|
198
359
|
export type FeatureItem = z.infer<typeof featureItemSchema>
|
|
199
360
|
export type CategoryCard = z.infer<typeof categoryCardSchema>
|
|
@@ -208,3 +369,5 @@ export type FeatureCardsSpecProps = z.infer<typeof featureCardsSpecSchema>
|
|
|
208
369
|
export type FeatureSplitSpecProps = z.infer<typeof featureSplitSpecSchema>
|
|
209
370
|
export type CategoryCardProps = z.infer<typeof categoryCardPropsSchema>
|
|
210
371
|
export type CategoryGridProps = z.infer<typeof categoryGridPropsSchema>
|
|
372
|
+
export type UniversalBannerData = z.infer<typeof universalBannerDataSchema>
|
|
373
|
+
export type UniversalBannerProps = z.infer<typeof universalBannerPropsSchema>
|
|
@@ -40,11 +40,18 @@ export function buildSelectedProduct(
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* Selection starts empty so a real choice is always the shopper's: with several
|
|
44
|
+
* variants the detail's `onAddToCart` can never silently add the first one
|
|
45
|
+
* (listing cards use the separate first-purchasable-variant shortcut instead).
|
|
46
|
+
* The one exception is a product with a single purchasable variant — there is
|
|
47
|
+
* nothing to choose, and leaving it unselected disabled the only call to action
|
|
48
|
+
* with no visible reason. That variant is preselected.
|
|
47
49
|
*/
|
|
48
|
-
export function initialSelectedVariantId(
|
|
49
|
-
|
|
50
|
+
export function initialSelectedVariantId(
|
|
51
|
+
detail: CatalogProductDetail | null | undefined,
|
|
52
|
+
): string | null {
|
|
53
|
+
if (!detail || detail.variants.length !== 1) return null
|
|
54
|
+
const [only] = detail.variants
|
|
55
|
+
const purchasable = only.availableForSale && only.price.status === 'available'
|
|
56
|
+
return purchasable ? only.id : null
|
|
50
57
|
}
|
|
@@ -130,9 +130,9 @@ export const product: ViewModule = {
|
|
|
130
130
|
|
|
131
131
|
return {
|
|
132
132
|
selectedProduct: buildSelectedProduct(result.detail),
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
selectedVariantId: initialSelectedVariantId(),
|
|
133
|
+
// The shopper selects explicitly; only a single-variant product starts
|
|
134
|
+
// preselected (listing cards use the card shortcut instead).
|
|
135
|
+
selectedVariantId: initialSelectedVariantId(result.detail),
|
|
136
136
|
productQuantity: 1,
|
|
137
137
|
productReviews: [],
|
|
138
138
|
hasProductReviews: false,
|
package/bin/storefront.js
CHANGED
|
@@ -61,7 +61,6 @@ import {
|
|
|
61
61
|
findPack,
|
|
62
62
|
parseRuntimeCommerceImports,
|
|
63
63
|
verifyPackExports,
|
|
64
|
-
verifyPackManifest,
|
|
65
64
|
verifyRegistryToolset,
|
|
66
65
|
} from '../scripts/candidate.mjs'
|
|
67
66
|
import {
|
|
@@ -97,6 +96,7 @@ import {
|
|
|
97
96
|
} from '../recipes/validate.mjs'
|
|
98
97
|
import { CATALOG_VERSION, loadCatalog } from '../recipes/catalog.mjs'
|
|
99
98
|
import { OPERATION_NAMES, installGateDiagnostics } from '../scripts/operations.mjs'
|
|
99
|
+
import { MOCK_BACKEND_CAPABILITIES } from '../scripts/mock-capabilities.mjs'
|
|
100
100
|
import {
|
|
101
101
|
applyProject,
|
|
102
102
|
executeOperations,
|
|
@@ -957,32 +957,32 @@ async function create(args) {
|
|
|
957
957
|
if (plan.missingPacks.length > 0) {
|
|
958
958
|
console.error(`Refusing to create: missing packed local candidate(s) in ${resolve(args.packs)}:`)
|
|
959
959
|
for (const name of plan.missingPacks) console.error(` ${name}`)
|
|
960
|
-
console.error('Pack each @thorprovider/* package with `yarn pack --filename <slug>-<version>.tgz
|
|
960
|
+
console.error('Pack each @thorprovider/* package with `yarn pack --filename <slug>-<version>.tgz`,')
|
|
961
|
+
console.error('or let `consumer:create --pack-path <dir>` build and pack the current workspaces.')
|
|
961
962
|
return 1
|
|
962
963
|
}
|
|
963
964
|
|
|
964
965
|
// Integrity guard for the local candidate packs. A `--packs` directory can be
|
|
965
966
|
// stale: a tarball packed before a public export was added still resolves for
|
|
966
967
|
// the same exact version, so the generated project imports a symbol the
|
|
967
|
-
// packed dist does not export.
|
|
968
|
-
//
|
|
969
|
-
//
|
|
970
|
-
//
|
|
968
|
+
// packed dist does not export. The planner already verified each pack's
|
|
969
|
+
// manifest (readable, expected package name, declared version, and for the
|
|
970
|
+
// CLI pack the running CLI version) and adopted its versions; here the
|
|
971
|
+
// remaining Tier-2 check verifies that the packed runtime actually exports
|
|
972
|
+
// every value the generated host imports from `@thorprovider/runtime/commerce`
|
|
973
|
+
// before the first write.
|
|
971
974
|
if (args.packs) {
|
|
972
975
|
const packsDir = resolve(args.packs)
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
console.error(`Refusing to create: ${guard.message} (${guard.code})`)
|
|
978
|
-
return 1
|
|
979
|
-
}
|
|
976
|
+
if (plan.invalidPacks.length > 0) {
|
|
977
|
+
console.error(`Refusing to create: invalid packed local candidate(s) in ${packsDir}:`)
|
|
978
|
+
for (const pack of plan.invalidPacks) console.error(` ${pack.name}: ${pack.message} (${pack.code})`)
|
|
979
|
+
return 1
|
|
980
980
|
}
|
|
981
981
|
const commerceTemplate = join(PKG_ROOT, 'assets', 'templates', 'app', 'lib', '__STOREFRONT__', 'commerce.ts')
|
|
982
982
|
const requiredExports = parseRuntimeCommerceImports(readFileSync(commerceTemplate, 'utf8'))
|
|
983
983
|
const runtimeName = '@thorprovider/runtime'
|
|
984
984
|
const runtimeGuard = verifyPackExports({
|
|
985
|
-
tgzPath: findPack(packsDir, runtimeName,
|
|
985
|
+
tgzPath: findPack(packsDir, runtimeName, plan.dependencies[runtimeName]),
|
|
986
986
|
innerPath: 'package/dist/commerce/index.mjs',
|
|
987
987
|
requiredExports,
|
|
988
988
|
})
|
|
@@ -1302,10 +1302,10 @@ async function setup(args) {
|
|
|
1302
1302
|
// No publishable key: nothing to connect. Leave the store in mock mode and exit
|
|
1303
1303
|
// successfully so `setup` is safe to run in CI/bootstrap without a key.
|
|
1304
1304
|
if (!publishableKey) {
|
|
1305
|
-
// Mock mode
|
|
1306
|
-
//
|
|
1307
|
-
//
|
|
1308
|
-
recordCapabilities(target, [])
|
|
1305
|
+
// Mock mode has no endpoint to probe, but its provider has a fixed contract:
|
|
1306
|
+
// record what it actually advertises so capability-gated modules (profile,
|
|
1307
|
+
// address book) install on a demo store instead of being refused.
|
|
1308
|
+
recordCapabilities(target, [...MOCK_BACKEND_CAPABILITIES])
|
|
1309
1309
|
console.log('storefront setup: no publishable key — leaving THOR_DATA_SOURCE=mock.')
|
|
1310
1310
|
return 0
|
|
1311
1311
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thorprovider/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Deterministic storefront scaffolder and installable OpenCode skill suite for Thor Commerce (Next.js, @thorprovider/blocks, @thorprovider/adapters, Medusa)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "bin/storefront.js",
|
package/recipes/archetypes.json
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
"description": "Archetype (intent) layer. Maps a slot to named intents so selection is by meaning, not by variant ordinal. Each intent resolves to a variant that MUST be allowed by the recipe for that slot.",
|
|
5
5
|
"slots": {
|
|
6
6
|
"home.hero": {
|
|
7
|
-
"default": "
|
|
7
|
+
"default": "campaign",
|
|
8
8
|
"intents": {
|
|
9
|
+
"campaign": {
|
|
10
|
+
"variant": "UniversalBanner",
|
|
11
|
+
"when": "A deal-forward multi-banner campaign wall grounded in the connected catalog (universal-banner family)."
|
|
12
|
+
},
|
|
9
13
|
"compact": {
|
|
10
14
|
"variant": "StorefrontHero",
|
|
11
15
|
"when": "A simple, text-forward hero with a single call to action (canonical `presentation: 'compact'`)."
|
package/recipes/catalog.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Initial semantic executable catalog (E1 tasks 1.2-1.3), classified by source-shape inspection of the @thorprovider/blocks prop contracts and the view templates. Scope: every slot the curated MVP views (home, product, category, checkout, account) render by default, covering both the selectable archetype slots declared by recipes/archetypes.json and the nested default slots that have no archetype (category.productCard, checkout.confirmation) so no legacy default support is dropped. The account view declares canonical LoginPage card/social presentations and SignUpPage1; legacy LoginPage1/LoginPage2 names resolve to card/social through legacyAliases, with social remaining held pending verified account lifecycle wiring. A variant is `executable` only when the slot's canonical data shape can feed its block props without a prop bridge and without inventing data; every other non-default variant is `held` with the specific reason. The one non-default structural choice is home.benefits, which selects between the two bounded presentations (`cards`, `split`) of the single canonical `Feature` block (identical item contract, no bridge); the retired numbered names `Feature1`/`Feature2` resolve through the slot's `legacyAliases`. E2 task 6.1 declares the base listing slot category.filter CategoryFilter2 as the single controlled listing (dataShape `CatalogQuery & CatalogResults`, state controlled) with the search/filter controls contributed by the logical mounts category.search / category.filters (no second block). Source-shape compatibility is not end-to-end backend behavior proof: the render is executable, but the category.search.apply / category.filter.apply actions remain held under the capability catalog (owner: storefront-catalog-search-filters, E2) until a real runtime proof. The `capabilities` map declares those operational capabilities with their requirements and verification state; E1 declares the held category.filter.apply action, E2 adds the held category.search.apply action and the held category.price.range capability that gates the category-filters showPrice option; no capability is claimed verified. The home.hero variants of the retired numbered family (StorefrontHero1/2/5/6) resolve through the slot's `legacyAliases` to the single canonical `StorefrontHero`, whose bounded presentation options (`compact`, `showcase`, `editorial`, `promotional`) preserve the four structural identities; the extended editorial/promotional sections render only from host-supplied data and are omitted otherwise. The category.productCard slot's retired numbered family (ProductCard1/2/3/5) and the previous `ProductCard` variant resolve through the slot's `legacyAliases` to the single canonical `ProductGrid` listing, which renders `ProductCard` item cells with bounded presentation options (`classic`, `minimal`, `rich`) that preserve the three structural identities; the rich presentation's wishlist and view-similar affordances are host-owned and optional, evidence (rating, badge, compare-at) renders only from host-supplied data, and the comparison-table variant `ProductCard5` was discarded as a listing controller, not a card presentation.",
|
|
5
5
|
"slots": {
|
|
6
6
|
"home.hero": {
|
|
7
|
-
"default": "
|
|
7
|
+
"default": "UniversalBanner",
|
|
8
8
|
"legacyAliases": {
|
|
9
9
|
"StorefrontHero1": "StorefrontHero",
|
|
10
10
|
"StorefrontHero2": "StorefrontHero",
|
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
"requirements": [
|
|
32
32
|
"heroProducts"
|
|
33
33
|
]
|
|
34
|
+
},
|
|
35
|
+
"UniversalBanner": {
|
|
36
|
+
"status": "executable",
|
|
37
|
+
"block": "UniversalBanner",
|
|
38
|
+
"dataShape": "UniversalBannerData",
|
|
39
|
+
"events": [],
|
|
40
|
+
"state": "uncontrolled",
|
|
41
|
+
"requirements": []
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
},
|
package/recipes/recipes.json
CHANGED
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"categories"
|
|
14
14
|
],
|
|
15
15
|
"defaultVariants": {
|
|
16
|
-
"hero": "
|
|
16
|
+
"hero": "UniversalBanner",
|
|
17
17
|
"benefits": "cards",
|
|
18
18
|
"categories": "CategoryGrid"
|
|
19
19
|
},
|
|
20
20
|
"allowedVariants": {
|
|
21
21
|
"hero": [
|
|
22
|
-
"StorefrontHero"
|
|
22
|
+
"StorefrontHero",
|
|
23
|
+
"UniversalBanner"
|
|
23
24
|
],
|
|
24
25
|
"benefits": [
|
|
25
26
|
"cards",
|
|
@@ -55,8 +56,8 @@
|
|
|
55
56
|
],
|
|
56
57
|
"defaultSections": [
|
|
57
58
|
{
|
|
58
|
-
"type": "
|
|
59
|
-
"after": "
|
|
59
|
+
"type": "products",
|
|
60
|
+
"after": "benefits"
|
|
60
61
|
}
|
|
61
62
|
],
|
|
62
63
|
"maxSections": 4
|
package/scripts/candidate.mjs
CHANGED
|
@@ -37,16 +37,20 @@ export const CANDIDATE_TOOLSET = Object.freeze({
|
|
|
37
37
|
'next-themes': '0.4.6',
|
|
38
38
|
'lucide-react': '1.47.0',
|
|
39
39
|
motion: '13.4.3',
|
|
40
|
+
// The animation utilities the blocks use (`animate-in`, `fade-in-0`, …). The
|
|
41
|
+
// stylesheet imports it only when it is installed, so the dependency must be
|
|
42
|
+
// part of the generated project's set.
|
|
43
|
+
'tw-animate-css': '1.3.3',
|
|
40
44
|
zod: '3.25.76',
|
|
41
45
|
'@json-render/core': '0.21.0',
|
|
42
46
|
'@json-render/react': '0.21.0',
|
|
43
47
|
'@json-render/next': '0.21.0',
|
|
44
48
|
}),
|
|
45
49
|
local: Object.freeze({
|
|
46
|
-
'@thorprovider/blocks': '4.3.
|
|
47
|
-
'@thorprovider/adapters': '5.
|
|
48
|
-
'@thorprovider/runtime': '0.
|
|
49
|
-
'@thorprovider/types': '7.
|
|
50
|
+
'@thorprovider/blocks': '4.3.2',
|
|
51
|
+
'@thorprovider/adapters': '5.6.0',
|
|
52
|
+
'@thorprovider/runtime': '0.8.0',
|
|
53
|
+
'@thorprovider/types': '7.7.0',
|
|
50
54
|
}),
|
|
51
55
|
})
|
|
52
56
|
|
|
@@ -64,14 +68,15 @@ export function packSlug(name) {
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
|
-
* Find the local tarball for a package in a packs directory.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
71
|
+
* Find the local tarball for a package in a packs directory. Prefers the
|
|
72
|
+
* deterministic plain `<slug>.tgz` name (what `consumer:create --pack-path`
|
|
73
|
+
* writes), then falls back to the documented `yarn pack --filename
|
|
74
|
+
* <slug>-<version>.tgz` name, or any `.tgz` containing the slug.
|
|
70
75
|
*/
|
|
71
76
|
export function findPack(packsDir, name, version) {
|
|
72
77
|
if (!existsSync(packsDir)) return null
|
|
73
78
|
const slug = packSlug(name)
|
|
74
|
-
const named = [`${slug}-${version}.tgz
|
|
79
|
+
const named = version ? [`${slug}.tgz`, `${slug}-${version}.tgz`] : [`${slug}.tgz`]
|
|
75
80
|
for (const file of named) {
|
|
76
81
|
const abs = join(packsDir, file)
|
|
77
82
|
if (existsSync(abs)) return abs
|
|
@@ -89,6 +94,13 @@ export function findPack(packsDir, name, version) {
|
|
|
89
94
|
* - `resolutions`: when `packsDir` is given, name -> `file:<abs>` mapping each
|
|
90
95
|
* local `@thorprovider/*` package (and the CLI) to its packed tarball.
|
|
91
96
|
* - `missingPacks`: local packages requested but absent from the packs dir.
|
|
97
|
+
* - `invalidPacks`: local packages whose tarball was found but rejected —
|
|
98
|
+
* unreadable, wrong manifest name, no version, or (for the CLI pack) a
|
|
99
|
+
* version other than the running CLI.
|
|
100
|
+
*
|
|
101
|
+
* Without a packs dir, versions are the pinned registry candidates. With one,
|
|
102
|
+
* each dependency version is adopted from the verified tarball manifest, so a
|
|
103
|
+
* local pack may carry unreleased versions that differ from the pins.
|
|
92
104
|
*/
|
|
93
105
|
export function buildInstallPlan({ cliVersion, packsDir, toolset = CANDIDATE_TOOLSET } = {}) {
|
|
94
106
|
const dependencies = {
|
|
@@ -98,15 +110,46 @@ export function buildInstallPlan({ cliVersion, packsDir, toolset = CANDIDATE_TOO
|
|
|
98
110
|
}
|
|
99
111
|
const resolutions = {}
|
|
100
112
|
const missingPacks = []
|
|
113
|
+
const invalidPacks = []
|
|
101
114
|
if (packsDir) {
|
|
102
115
|
const local = { ...toolset.local, '@thorprovider/storefront': cliVersion }
|
|
103
|
-
for (const [name,
|
|
104
|
-
const pack = findPack(packsDir, name,
|
|
105
|
-
if (!pack)
|
|
106
|
-
|
|
116
|
+
for (const [name, pinnedVersion] of Object.entries(local)) {
|
|
117
|
+
const pack = findPack(packsDir, name, pinnedVersion)
|
|
118
|
+
if (!pack) {
|
|
119
|
+
missingPacks.push(name)
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
const manifest = readPackManifest(pack)
|
|
123
|
+
if (!manifest) {
|
|
124
|
+
invalidPacks.push({ name, code: 'E_PACK_UNREADABLE', message: `${pack}: cannot read as a package tarball` })
|
|
125
|
+
continue
|
|
126
|
+
}
|
|
127
|
+
if (manifest.name !== name) {
|
|
128
|
+
invalidPacks.push({
|
|
129
|
+
name,
|
|
130
|
+
code: 'E_PACK_NAME_MISMATCH',
|
|
131
|
+
message: `${pack} declares ${manifest.name}, expected ${name}`,
|
|
132
|
+
})
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
135
|
+
const version = typeof manifest.version === 'string' && manifest.version ? manifest.version : null
|
|
136
|
+
if (!version) {
|
|
137
|
+
invalidPacks.push({ name, code: 'E_PACK_VERSION_MISSING', message: `${pack} declares no version` })
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
if (name === '@thorprovider/storefront' && version !== cliVersion) {
|
|
141
|
+
invalidPacks.push({
|
|
142
|
+
name,
|
|
143
|
+
code: 'E_PACK_CLI_MISMATCH',
|
|
144
|
+
message: `${pack} declares ${manifest.name}@${version}, expected the running CLI ${cliVersion} — repack the candidate`,
|
|
145
|
+
})
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
dependencies[name] = version
|
|
149
|
+
resolutions[name] = `file:${pack}`
|
|
107
150
|
}
|
|
108
151
|
}
|
|
109
|
-
return { dependencies, resolutions, missingPacks, scaffolder: toolset.scaffolder, packageManager: toolset.packageManager }
|
|
152
|
+
return { dependencies, resolutions, missingPacks, invalidPacks, scaffolder: toolset.scaffolder, packageManager: toolset.packageManager }
|
|
110
153
|
}
|
|
111
154
|
|
|
112
155
|
/** Read the actual version of a sibling monorepo package (drift guard). */
|
|
@@ -282,6 +325,9 @@ export function blockSpecifierPath(specifier) {
|
|
|
282
325
|
if (specifier === '@thorprovider/blocks/contracts') return 'package/dist/lib/contracts.mjs'
|
|
283
326
|
if (specifier === '@thorprovider/blocks/ports') return 'package/dist/ports/index.mjs'
|
|
284
327
|
if (specifier === '@thorprovider/blocks/styles.css') return 'package/styles.css'
|
|
328
|
+
if (specifier === '@thorprovider/blocks/order-history-engine') {
|
|
329
|
+
return 'package/dist/blocks/designs/order-history/engine.mjs'
|
|
330
|
+
}
|
|
285
331
|
if (!specifier.startsWith('@thorprovider/blocks/')) return null
|
|
286
332
|
return `package/dist/${specifier.slice('@thorprovider/blocks/'.length)}.mjs`
|
|
287
333
|
}
|
|
@@ -522,4 +568,3 @@ export async function verifyRegistryToolset({
|
|
|
522
568
|
for (const result of Object.values(resolved)) result.cleanup?.()
|
|
523
569
|
return { ok: errors.length === 0, errors }
|
|
524
570
|
}
|
|
525
|
-
|