@thorprovider/storefront 0.7.0 → 0.9.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 +22 -2
- package/assets/templates/AGENTS.md +14 -2
- package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +621 -80
- package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +346 -38
- package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
- package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
- package/assets/templates/app/lib/__STOREFRONT__/ports.ts +18 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
- package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +21 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +4 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
- package/assets/templates/features/checkout/handlers.ts +24 -4
- package/assets/templates/features/customer-addresses/handlers.ts +11 -0
- package/assets/templates/features/customer-addresses/state.ts +33 -0
- package/assets/templates/features/customer-auth/state.ts +10 -0
- package/assets/templates/features/customer-profile/handlers.ts +11 -0
- package/assets/templates/features/customer-profile/state.ts +18 -0
- package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
- package/assets/templates/views/account/assembly/assembly.json +41 -0
- package/assets/templates/views/account/assembly/index.skeleton.tsx +229 -0
- package/assets/templates/views/account/assembly/registry.skeleton.tsx +1116 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
- package/assets/templates/views/account/content.ts +326 -0
- package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
- package/assets/templates/views/account/index.tsx +218 -35
- package/assets/templates/views/account/order-detail.client.tsx +35 -0
- package/assets/templates/views/account/order-detail.defaults.ts +457 -0
- package/assets/templates/views/account/orders-advanced.client.tsx +166 -0
- package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
- package/assets/templates/views/account/registry.tsx +944 -369
- package/assets/templates/views/account/schema.ts +50 -0
- package/assets/templates/views/account/sections-data.ts +2 -0
- package/assets/templates/views/cart/content.ts +1 -0
- package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
- package/assets/templates/views/category/content.ts +2 -0
- package/assets/templates/views/category/index.tsx +2 -0
- package/assets/templates/views/category/sections-data.ts +2 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
- package/assets/templates/views/checkout/content.ts +51 -0
- package/assets/templates/views/checkout/index.tsx +1 -1
- package/assets/templates/views/checkout/props.ts +10 -2
- package/assets/templates/views/checkout/registry.tsx +104 -42
- package/assets/templates/views/checkout/schema.ts +76 -1
- package/assets/templates/views/home/assembly/assembly.json +22 -1
- package/assets/templates/views/home/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/home/content.ts +2 -0
- package/assets/templates/views/home/index.tsx +1 -0
- package/assets/templates/views/home/sections-data.ts +2 -0
- package/assets/templates/views/product/content.ts +1 -0
- package/assets/templates/views/static/content.ts +1 -0
- package/bin/storefront.js +343 -13
- package/package.json +2 -1
- package/recipes/adapter-surface.json +158 -0
- package/recipes/archetypes.json +38 -3
- package/recipes/catalog.json +138 -1
- package/recipes/feature.schema.json +9 -0
- package/recipes/features.json +72 -1
- package/recipes/manifest.schema.json +5 -0
- package/recipes/recipe.schema.json +13 -1
- package/recipes/recipes.json +34 -5
- package/recipes/section.schema.json +112 -0
- package/recipes/sections.json +281 -4
- package/recipes/validate.mjs +83 -1
- package/scripts/adapter-surface.mjs +41 -0
- package/scripts/agent-blocks.mjs +700 -0
- package/scripts/block-validator.mjs +45 -0
- package/scripts/candidate.mjs +5 -4
- package/scripts/composers.mjs +7 -2
- package/scripts/default-sections.mjs +78 -0
- package/scripts/file-classes.mjs +14 -0
- package/scripts/generate-adapter-surface.mjs +148 -0
- package/scripts/operations.mjs +100 -0
- package/scripts/reconcile.mjs +67 -39
- package/scripts/section-configure.mjs +316 -0
- package/scripts/sync-assets.mjs +1 -0
- package/scripts/view-assembly.mjs +101 -14
- package/skills/sf-feature/SKILL.md +19 -0
- package/skills/sf-view-gen/SKILL.md +73 -7
- package/skills/sf-view-gen/assets/recipes/archetypes.json +38 -3
- package/skills/sf-view-gen/assets/recipes/catalog.json +138 -1
- package/skills/sf-view-gen/assets/recipes/features.json +72 -1
- package/skills/sf-view-gen/assets/recipes/recipes.json +34 -5
- package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
- package/skills/sf-view-gen/assets/recipes/sections.json +281 -4
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
- package/skills/sf-view-gen/scripts/validate.mjs +83 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: universal-banner (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in universal-banner.tsx. @thorprovider/blocks ships a
|
|
5
|
+
// 'use client' boundary, but this fragment keeps the explicit client boundary so
|
|
6
|
+
// the section composes identically in any consumer graph.
|
|
7
|
+
|
|
8
|
+
import { useEffect, useState } from 'react'
|
|
9
|
+
import { UniversalBanner } from '@thorprovider/blocks'
|
|
10
|
+
import { universalBannerPropsSchema } from './schema.universal-banner'
|
|
11
|
+
import type { ViewRegistry } from '../types'
|
|
12
|
+
|
|
13
|
+
export const universalBannerRegistry: ViewRegistry = {
|
|
14
|
+
UniversalBanner: ({ props }) => {
|
|
15
|
+
const parsed = universalBannerPropsSchema.parse(props)
|
|
16
|
+
const [now, setNow] = useState(parsed.data.now)
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setNow(new Date().toISOString())
|
|
19
|
+
}, [])
|
|
20
|
+
return (
|
|
21
|
+
<UniversalBanner data={{ ...parsed.data, now }} />
|
|
22
|
+
)
|
|
23
|
+
},
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Optional section fragment: universal-banner (mirrors recipes/sections.json)
|
|
2
|
+
// Server-side part: element type + zod catalog entry. The component mappings
|
|
3
|
+
// live in universal-banner.client.tsx ('use client') and are composed via composeSections.
|
|
4
|
+
|
|
5
|
+
import { universalBannerPropsSchema } from './schema.universal-banner'
|
|
6
|
+
|
|
7
|
+
export const universalBannerSection = {
|
|
8
|
+
elementType: 'UniversalBanner',
|
|
9
|
+
catalog: {
|
|
10
|
+
UniversalBanner: {
|
|
11
|
+
props: universalBannerPropsSchema,
|
|
12
|
+
description: 'UniversalBanner presentation section (delivery universal-banner).',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
registryModule: './universal-banner.client',
|
|
16
|
+
}
|
|
@@ -506,6 +506,88 @@ export function isCuratedFeature(name) {
|
|
|
506
506
|
return getFeature(name)?.mvp === true
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
/**
|
|
510
|
+
* The feature's declared lifecycle status. Absent status defaults to
|
|
511
|
+
* `executable` for a curated feature and `held` for a non-curated one, so an
|
|
512
|
+
* older registry keeps its previous meaning without a migration pass.
|
|
513
|
+
*/
|
|
514
|
+
export function featureStatus(name) {
|
|
515
|
+
const feature = getFeature(name)
|
|
516
|
+
if (!feature) return null
|
|
517
|
+
if (feature.status === 'executable' || feature.status === 'gated' || feature.status === 'held') {
|
|
518
|
+
return feature.status
|
|
519
|
+
}
|
|
520
|
+
return feature.mvp === true ? 'executable' : 'held'
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const FEATURE_STATUSES = new Set(['executable', 'gated', 'held'])
|
|
524
|
+
const FEATURE_LIST_FIELDS = ['requires', 'backendCapabilities']
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Validate the feature registry's lifecycle declarations. The published JSON
|
|
528
|
+
* schema covers shape; this covers the cross-entry invariants the schema cannot
|
|
529
|
+
* express (held needs a reason and an owner, status and `mvp` agree, a
|
|
530
|
+
* dependency names a real feature, and no feature depends on itself).
|
|
531
|
+
*
|
|
532
|
+
* Returns `{ ok, errors }`; the registry is read-only input.
|
|
533
|
+
*/
|
|
534
|
+
export function validateFeatureRegistry(registry = features) {
|
|
535
|
+
const errors = []
|
|
536
|
+
const list = Array.isArray(registry?.features) ? registry.features : []
|
|
537
|
+
const names = new Set()
|
|
538
|
+
|
|
539
|
+
for (const feature of list) {
|
|
540
|
+
if (!isPlainObject(feature) || typeof feature.name !== 'string' || feature.name === '') {
|
|
541
|
+
errors.push('Every feature entry needs a non-empty string "name".')
|
|
542
|
+
continue
|
|
543
|
+
}
|
|
544
|
+
const { name } = feature
|
|
545
|
+
if (names.has(name)) errors.push(`Feature "${name}" is declared more than once.`)
|
|
546
|
+
names.add(name)
|
|
547
|
+
|
|
548
|
+
const status = feature.status ?? (feature.mvp === true ? 'executable' : 'held')
|
|
549
|
+
if (!FEATURE_STATUSES.has(status)) {
|
|
550
|
+
errors.push(
|
|
551
|
+
`Feature "${name}" declares unknown status "${String(feature.status)}". Allowed: executable, gated, held.`
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
if (status === 'held') {
|
|
555
|
+
if (feature.mvp === true) {
|
|
556
|
+
errors.push(`Feature "${name}" is held and must not declare mvp: true.`)
|
|
557
|
+
}
|
|
558
|
+
if (typeof feature.reason !== 'string' || feature.reason.trim() === '') {
|
|
559
|
+
errors.push(`Held feature "${name}" must declare a non-empty "reason".`)
|
|
560
|
+
}
|
|
561
|
+
if (typeof feature.owner !== 'string' || feature.owner.trim() === '') {
|
|
562
|
+
errors.push(`Held feature "${name}" must declare a non-empty "owner".`)
|
|
563
|
+
}
|
|
564
|
+
} else if (feature.mvp !== true) {
|
|
565
|
+
errors.push(`Feature "${name}" is "${status}" and must declare mvp: true.`)
|
|
566
|
+
}
|
|
567
|
+
for (const field of FEATURE_LIST_FIELDS) {
|
|
568
|
+
if (!hasOwn(feature, field)) continue
|
|
569
|
+
const value = feature[field]
|
|
570
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {
|
|
571
|
+
errors.push(`Feature "${name}" field "${field}" must be an array of non-empty strings.`)
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
for (const feature of list) {
|
|
577
|
+
if (!isPlainObject(feature) || typeof feature.name !== 'string') continue
|
|
578
|
+
const requires = Array.isArray(feature.requires) ? feature.requires : []
|
|
579
|
+
for (const dependency of requires) {
|
|
580
|
+
if (dependency === feature.name) {
|
|
581
|
+
errors.push(`Feature "${feature.name}" must not require itself.`)
|
|
582
|
+
} else if (!names.has(dependency)) {
|
|
583
|
+
errors.push(`Feature "${feature.name}" requires unknown feature "${dependency}".`)
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return { ok: errors.length === 0, errors }
|
|
589
|
+
}
|
|
590
|
+
|
|
509
591
|
/**
|
|
510
592
|
* The starter composition: every curated (installable) feature plus every
|
|
511
593
|
* curated view no installed curated feature owns. A feature-owned view (for
|
|
@@ -523,7 +605,7 @@ export function starterComposition(registries = {}) {
|
|
|
523
605
|
const recipeSource = registries.recipes ?? recipes
|
|
524
606
|
const featureSource = registries.features ?? features
|
|
525
607
|
const featureNames = featureSource.features
|
|
526
|
-
.filter((f) => f.mvp === true)
|
|
608
|
+
.filter((f) => f.mvp === true && f.starter !== false)
|
|
527
609
|
.map((f) => f.name)
|
|
528
610
|
const ownedViews = new Set()
|
|
529
611
|
for (const name of featureNames) {
|