@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.
Files changed (151) hide show
  1. package/README.md +22 -2
  2. package/assets/templates/AGENTS.md +14 -2
  3. package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
  4. package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
  5. package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
  6. package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +621 -80
  9. package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +346 -38
  11. package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +26 -0
  14. package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
  15. package/assets/templates/app/lib/__STOREFRONT__/ports.ts +18 -0
  16. package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
  17. package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
  18. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +21 -0
  19. package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
  20. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
  21. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
  22. package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
  23. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +4 -1
  24. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
  25. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
  26. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
  27. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
  28. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
  29. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
  30. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
  31. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
  32. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
  33. package/assets/templates/features/checkout/handlers.ts +24 -4
  34. package/assets/templates/features/customer-addresses/handlers.ts +11 -0
  35. package/assets/templates/features/customer-addresses/state.ts +33 -0
  36. package/assets/templates/features/customer-auth/state.ts +10 -0
  37. package/assets/templates/features/customer-profile/handlers.ts +11 -0
  38. package/assets/templates/features/customer-profile/state.ts +18 -0
  39. package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
  40. package/assets/templates/views/account/assembly/assembly.json +41 -0
  41. package/assets/templates/views/account/assembly/index.skeleton.tsx +229 -0
  42. package/assets/templates/views/account/assembly/registry.skeleton.tsx +1116 -0
  43. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
  44. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
  45. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
  46. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
  47. package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
  48. package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
  49. package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
  50. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +5 -0
  51. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +5 -0
  52. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +1 -0
  53. package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
  54. package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
  55. package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
  56. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
  57. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
  58. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
  59. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
  60. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
  61. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
  62. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
  63. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
  64. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
  65. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
  66. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
  67. package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
  68. package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
  69. package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
  70. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
  71. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
  72. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
  73. package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
  74. package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
  75. package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
  76. package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
  77. package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
  78. package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
  79. package/assets/templates/views/account/content.ts +326 -0
  80. package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
  81. package/assets/templates/views/account/index.tsx +218 -35
  82. package/assets/templates/views/account/order-detail.client.tsx +35 -0
  83. package/assets/templates/views/account/order-detail.defaults.ts +457 -0
  84. package/assets/templates/views/account/orders-advanced.client.tsx +166 -0
  85. package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
  86. package/assets/templates/views/account/registry.tsx +944 -369
  87. package/assets/templates/views/account/schema.ts +50 -0
  88. package/assets/templates/views/account/sections-data.ts +2 -0
  89. package/assets/templates/views/cart/content.ts +1 -0
  90. package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
  91. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
  92. package/assets/templates/views/category/content.ts +2 -0
  93. package/assets/templates/views/category/index.tsx +2 -0
  94. package/assets/templates/views/category/sections-data.ts +2 -0
  95. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
  96. package/assets/templates/views/checkout/content.ts +51 -0
  97. package/assets/templates/views/checkout/index.tsx +1 -1
  98. package/assets/templates/views/checkout/props.ts +10 -2
  99. package/assets/templates/views/checkout/registry.tsx +104 -42
  100. package/assets/templates/views/checkout/schema.ts +76 -1
  101. package/assets/templates/views/home/assembly/assembly.json +22 -1
  102. package/assets/templates/views/home/assembly/index.skeleton.tsx +1 -0
  103. package/assets/templates/views/home/content.ts +2 -0
  104. package/assets/templates/views/home/index.tsx +1 -0
  105. package/assets/templates/views/home/sections-data.ts +2 -0
  106. package/assets/templates/views/product/content.ts +1 -0
  107. package/assets/templates/views/static/content.ts +1 -0
  108. package/bin/storefront.js +343 -13
  109. package/package.json +2 -1
  110. package/recipes/adapter-surface.json +158 -0
  111. package/recipes/archetypes.json +38 -3
  112. package/recipes/catalog.json +138 -1
  113. package/recipes/feature.schema.json +9 -0
  114. package/recipes/features.json +72 -1
  115. package/recipes/manifest.schema.json +5 -0
  116. package/recipes/recipe.schema.json +13 -1
  117. package/recipes/recipes.json +34 -5
  118. package/recipes/section.schema.json +112 -0
  119. package/recipes/sections.json +281 -4
  120. package/recipes/validate.mjs +83 -1
  121. package/scripts/adapter-surface.mjs +41 -0
  122. package/scripts/agent-blocks.mjs +700 -0
  123. package/scripts/block-validator.mjs +45 -0
  124. package/scripts/candidate.mjs +5 -4
  125. package/scripts/composers.mjs +7 -2
  126. package/scripts/default-sections.mjs +78 -0
  127. package/scripts/file-classes.mjs +14 -0
  128. package/scripts/generate-adapter-surface.mjs +148 -0
  129. package/scripts/operations.mjs +100 -0
  130. package/scripts/reconcile.mjs +67 -39
  131. package/scripts/section-configure.mjs +316 -0
  132. package/scripts/sync-assets.mjs +1 -0
  133. package/scripts/view-assembly.mjs +101 -14
  134. package/skills/sf-feature/SKILL.md +19 -0
  135. package/skills/sf-view-gen/SKILL.md +73 -7
  136. package/skills/sf-view-gen/assets/recipes/archetypes.json +38 -3
  137. package/skills/sf-view-gen/assets/recipes/catalog.json +138 -1
  138. package/skills/sf-view-gen/assets/recipes/features.json +72 -1
  139. package/skills/sf-view-gen/assets/recipes/recipes.json +34 -5
  140. package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
  141. package/skills/sf-view-gen/assets/recipes/sections.json +281 -4
  142. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
  143. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
  144. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
  145. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
  146. package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
  147. package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
  148. package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
  149. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
  150. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
  151. package/skills/sf-view-gen/scripts/validate.mjs +83 -1
@@ -17,10 +17,10 @@
17
17
  // selectable set is exactly the fragment set, which a parity test pins to the
18
18
  // semantic catalog's `executable` entries.
19
19
 
20
- import { existsSync, readFileSync, readdirSync } from 'node:fs'
20
+ import { existsSync, lstatSync, readFileSync, readdirSync } from 'node:fs'
21
21
  import { mkdir, writeFile } from 'node:fs/promises'
22
22
  import path from 'node:path'
23
- import { isSlotSectionEntry } from './section-compat.mjs'
23
+ import { isEditorialSectionEntry, isSlotSectionEntry } from './section-compat.mjs'
24
24
  import { resolveLegacyVariant } from '../recipes/validate.mjs'
25
25
 
26
26
  export const ASSEMBLY_DIRNAME = 'assembly'
@@ -124,8 +124,7 @@ function renderBlockImports(bindings) {
124
124
 
125
125
  // The import line that lets an editorial element read its user-owned instance
126
126
  // content from the view's `content.ts` (`sectionContent[id]`). Emitted only when
127
- // the ordered composition contains at least one editorial instance, so the
128
- // default (slot-only) composition keeps its exact output.
127
+ // the ordered composition contains at least one editorial instance.
129
128
  function renderSectionImports(modules) {
130
129
  const lines = [...modules]
131
130
  .sort((a, b) => a.localeCompare(b))
@@ -144,6 +143,17 @@ function renderSectionRegistryImports(byModule) {
144
143
 
145
144
  const SECTION_CONTENT_EXPORT = 'sectionContent'
146
145
 
146
+ // JSON string contents safely escape backslashes, quotes, and control chars.
147
+ // Keep the surrounding single quotes so ordinary generated output is unchanged.
148
+ function tsStringLiteral(value) {
149
+ const contents = JSON.stringify(value)
150
+ .slice(1, -1)
151
+ .replace(/'/g, "\\'")
152
+ .replace(/\u2028/g, '\\u2028')
153
+ .replace(/\u2029/g, '\\u2029')
154
+ return `'${contents}'`
155
+ }
156
+
147
157
  // One editorial instance's element: a persisted instance id, the section's
148
158
  // registered element type, and its props read from the view's user-owned
149
159
  // `content.ts` by id (falling back to the section fragment's declared neutral
@@ -151,8 +161,9 @@ const SECTION_CONTENT_EXPORT = 'sectionContent'
151
161
  function renderEditorialElement(entry, def) {
152
162
  const fallback =
153
163
  typeof def.defaultProps === 'string' && def.defaultProps.length > 0 ? def.defaultProps : '{}'
154
- const props = `${SECTION_CONTENT_EXPORT}['${entry.id}'] ?? ${fallback}`
155
- return ` '${entry.id}': {\n type: '${def.elementType}',\n props: ${props},\n },`
164
+ const id = tsStringLiteral(entry.id)
165
+ const props = `sectionData[${id}] ?? ${SECTION_CONTENT_EXPORT}[${id}] ?? ${fallback}`
166
+ return ` ${id}: {\n type: '${def.elementType}',\n props: ${props},\n },`
156
167
  }
157
168
 
158
169
  // One editorial instance's client registry binding: the section element type
@@ -177,16 +188,17 @@ function renderDataBoundElement(entry, def) {
177
188
  `Data-bound section "${entry.type}" instance "${entry.id}" has no variant and no declared defaultVariant.`,
178
189
  )
179
190
  }
191
+ const id = tsStringLiteral(entry.id)
180
192
  return [
181
- ` '${entry.id}': {`,
193
+ ` ${id}: {`,
182
194
  ` type: '${def.elementType}',`,
183
195
  ` props: {`,
184
- ` ...(${SECTION_CONTENT_EXPORT}['${entry.id}'] ?? {}),`,
185
- ` sectionId: '${entry.id}',`,
196
+ ` ...(${SECTION_CONTENT_EXPORT}[${id}] ?? {}),`,
197
+ ` sectionId: ${id},`,
186
198
  ` sectionType: '${entry.type}',`,
187
199
  ` variant: '${variant}',`,
188
- ` products: { $state: '/sections/${entry.id}/products' },`,
189
- ` status: { $state: '/sections/${entry.id}/status' },`,
200
+ ` products: { $state: ${tsStringLiteral(`/sections/${entry.id}/products`)} },`,
201
+ ` status: { $state: ${tsStringLiteral(`/sections/${entry.id}/status`)} },`,
190
202
  ` },`,
191
203
  ` on: { addClickedToCart: { action: 'addClickedToCart' }, openProduct: { action: 'openProduct' } },`,
192
204
  ` },`,
@@ -264,7 +276,7 @@ export function assembleView(templateDir, selection = {}, sections = null) {
264
276
  if (existsSync(bindingPath)) {
265
277
  bindings.push(JSON.parse(readFileSync(bindingPath, 'utf8')))
266
278
  }
267
- slotIds.push(`'${slot.id}'`)
279
+ slotIds.push(tsStringLiteral(slot.id))
268
280
  continue
269
281
  }
270
282
  const def = sectionMeta[entry.type]
@@ -285,10 +297,10 @@ export function assembleView(templateDir, selection = {}, sections = null) {
285
297
  // duplicate object keys in the derived `registry.tsx`.
286
298
  if (registryTypes.has(def.elementType)) registry.pop()
287
299
  else registryTypes.add(def.elementType)
288
- slotIds.push(`'${entry.id}'`)
300
+ slotIds.push(tsStringLiteral(entry.id))
289
301
  sectionPropsModules.add(def.propsModule ?? './content')
290
302
  sectionRegistryImports.set(def.registryModule, def.registryExport)
291
- if (def.dataBound === true) dataBoundIds.push(`'${entry.id}'`)
303
+ if (def.dataBound === true) dataBoundIds.push(tsStringLiteral(entry.id))
292
304
  }
293
305
 
294
306
  const indexSkeleton = readFileSync(path.join(assemblyDir(templateDir), 'index.skeleton.tsx'), 'utf8')
@@ -343,3 +355,78 @@ export async function writeViewAssembly({
343
355
  }
344
356
  return changed
345
357
  }
358
+
359
+ function safeSidecarId(id) {
360
+ return (
361
+ typeof id === 'string' &&
362
+ id.trim().length > 0 &&
363
+ id !== '.' &&
364
+ id !== '..' &&
365
+ !id.includes('..') &&
366
+ !id.includes('/') &&
367
+ !id.includes('\\') &&
368
+ !id.includes('\0') &&
369
+ !id.startsWith('slot:')
370
+ )
371
+ }
372
+
373
+ function renderSectionsData(imports) {
374
+ const lines = ['// Generated by @thorprovider/storefront. Do not edit directly.']
375
+ for (const entry of imports) {
376
+ lines.push(`import sectionData${entry.index} from ${tsStringLiteral(entry.module)}`)
377
+ }
378
+ if (imports.length === 0) {
379
+ lines.push('export const sectionData: Record<string, Record<string, unknown>> = {}', '')
380
+ return lines.join('\n')
381
+ }
382
+ lines.push('', 'export const sectionData: Record<string, Record<string, unknown>> = {')
383
+ for (const entry of imports) {
384
+ lines.push(` ${tsStringLiteral(entry.id)}: sectionData${entry.index} as Record<string, unknown>,`)
385
+ }
386
+ lines.push('}', '')
387
+ return lines.join('\n')
388
+ }
389
+
390
+ /**
391
+ * Generate the derived data map for editorial sidecars belonging to the
392
+ * manifest's ordered normalized sections. Sidecars are retained when an
393
+ * instance is removed; only current safe ids with regular files are imported.
394
+ */
395
+ export async function writeSectionsData({ viewDir, sections = [], dryRun = false } = {}) {
396
+ const sectionsDir = path.join(viewDir, 'sections')
397
+ const imports = []
398
+ const sectionsDirIsDirectory = existsSync(sectionsDir) && lstatSync(sectionsDir).isDirectory()
399
+
400
+ if (sectionsDirIsDirectory && Array.isArray(sections)) {
401
+ for (const entry of sections) {
402
+ if (!isEditorialSectionEntry(entry) || !safeSidecarId(entry.id)) continue
403
+ const sidecarPath = path.join(sectionsDir, `${entry.id}.json`)
404
+ const relativePath = path.relative(sectionsDir, sidecarPath)
405
+ if (
406
+ relativePath === '' ||
407
+ relativePath.startsWith(`..${path.sep}`) ||
408
+ relativePath === '..' ||
409
+ path.isAbsolute(relativePath) ||
410
+ !existsSync(sidecarPath) ||
411
+ !lstatSync(sidecarPath).isFile()
412
+ ) {
413
+ continue
414
+ }
415
+ imports.push({
416
+ id: entry.id,
417
+ index: imports.length,
418
+ module: `./sections/${entry.id}.json`,
419
+ })
420
+ }
421
+ }
422
+
423
+ const dest = path.join(viewDir, 'sections-data.ts')
424
+ const next = renderSectionsData(imports)
425
+ const prev = existsSync(dest) ? readFileSync(dest, 'utf8') : null
426
+ if (prev === next) return []
427
+ if (!dryRun) {
428
+ await mkdir(path.dirname(dest), { recursive: true })
429
+ await writeFile(dest, next)
430
+ }
431
+ return [dest]
432
+ }
@@ -40,6 +40,25 @@ not read the JSON files directly; they are an implementation detail.
40
40
  - **Held feature** — `mvp: false`. The CLI rejects it before any write; report it
41
41
  as not available rather than trying to install it.
42
42
 
43
+ ## Checkout route requests
44
+
45
+ Checkout requests stay with the checkout feature: it owns the hosted `/checkout`
46
+ route. The agent does not select an editorial section for checkout requests. Do
47
+ not use `view add checkout` or create a second checkout page. When useful,
48
+ explain that the host-driven checkout renders host-owned
49
+ cart/contact/address state, backend grouped delivery, payment methods,
50
+ and designer order confirmation; `blocks show checkout-commerce-v1 --json`
51
+ describes that route surface, not an editorial section to configure.
52
+
53
+ For checkout customization, discuss or edit only user-owned checkout files:
54
+ `views/checkout/{content,props,data,schema}.ts`, under the project's declared
55
+ ownership rules. Generated checkout files (route, registry, adapter, state, and
56
+ handler wiring) remain CLI-owned and must not be edited by the agent.
57
+ Transactional data and actions are host-owned: never serialize or author cart
58
+ contents/totals, shopper identity or addresses, fulfillment groups/selections,
59
+ payment methods/selections, order actions, or confirmation as agent-side data.
60
+ Use the normal `feature add|remove checkout` CLI workflow for structural changes.
61
+
43
62
  ## Add a feature
44
63
 
45
64
  ```bash
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sf-view-gen
3
- description: Add or remove a Thor Commerce storefront view, compose and reorder a view's executable sections, or customize a view's user-owned files. Use when the user asks to add or remove a view (home, category, product, cart, account, static), add/remove/reorder a section (faq, cta, products), change a variant, or change a view's content, props, or data. Delegates every structural write to the `storefront` CLI.
3
+ description: Add or remove a Thor Commerce storefront view, compose and reorder a view's executable sections, choose or customize an editorial section from its purpose, or customize a view's user-owned files. Use when the user describes an outcome for an editorial section, asks to add or remove a view or section, change a variant, or change a view's content, props, or data. Delegates every structural write to the `storefront` CLI.
4
4
  ---
5
5
 
6
6
  # sf-view-gen
@@ -83,7 +83,7 @@ natural language and never types a command.
83
83
  `sections --json` installed-instance list as the set of available types.
84
84
  2. Only `executable` types may be composed; a `held` type is refused with the
85
85
  `reason` the registry reports — relay that reason, never invent one. A
86
- `dataBound` `products` instance is configured separately by the developer in
86
+ `dataBound` instance is configured separately by the developer in
87
87
  `views/<view>/data.ts` → `sectionSources[id]` (a canonical query — not a sales
88
88
  ranking); its variant only changes presentation, and until the selection is set
89
89
  the instance renders a truthful "needs configuration" state that `doctor`
@@ -123,17 +123,83 @@ through the CLI (`view add`/`remove` with `--variant`, or a `section.add` /
123
123
  `index.tsx` or registry to swap an import identifier. Variant changes go through
124
124
  the CLI plan/apply path so the manifest and the derived files stay in sync.
125
125
 
126
+ ## Choose and configure an editorial block
127
+
128
+ Route wrong surfaces before considering an editorial section: navigation or a
129
+ header belongs to the shell/view procedure; a product listing belongs to its
130
+ owning product view or feature procedure; checkout and account behavior belong
131
+ to their owning `sf-feature` procedures. Do not select an editorial section for
132
+ any of these requests.
133
+
134
+ 1. Read the installed-only catalog from the storefront project root:
135
+
136
+ ```bash
137
+ npx @thorprovider/storefront blocks list --json
138
+ ```
139
+
140
+ 2. Choose by each ready card's `purpose`, `useWhen`, and `avoidWhen`, not by its
141
+ name. If two cards plausibly match the described outcome, ask one clarifying
142
+ question before choosing. If no ready card matches, or the closest card is
143
+ pending or exempt, explain the unavailable capability and do not configure
144
+ it.
145
+ 3. Read the full card for the selected `<type>`:
146
+
147
+ ```bash
148
+ npx @thorprovider/storefront blocks show <type> --json
149
+ ```
150
+
151
+ Use this output for the complete example, editable fields, host-only fields,
152
+ validator, and installed instance ids. Configure only an instance id listed
153
+ for the target view.
154
+ 4. Start from a complete example returned by `show`. Adapt only the user's
155
+ content values in its user-owned data fields; preserve the example's shape,
156
+ never invent fields, and do not supply host-only fields.
157
+ 5. Save the candidate data as JSON and validate it without writing:
158
+
159
+ ```bash
160
+ npx @thorprovider/storefront section configure <view> <id> --data <file|-> --dry-run --json
161
+ ```
162
+
163
+ Repair only the reported data paths, then repeat the dry run until valid.
164
+ 6. Run the same command without `--dry-run` to write the validated configuration:
165
+
166
+ ```bash
167
+ npx @thorprovider/storefront section configure <view> <id> --data <file|-> --json
168
+ ```
169
+
170
+ 7. Regenerate and verify:
171
+
172
+ ```bash
173
+ npx @thorprovider/storefront sync
174
+ npx @thorprovider/storefront doctor
175
+ ```
176
+
177
+ 8. Explain the block's purpose and when not to use it. Describe which fields
178
+ customize content, media, composition, scheduling, and responsiveness, and
179
+ distinguish user-editable fields from host-only fields.
180
+
126
181
  ## Customize a view
127
182
 
128
- Only **user-owned** files may be edited by hand. They are consumed by thin
129
- derived wrappers, so `sync` regenerates the wrappers around your edits.
183
+ Only the listed user-owned files may be edited by hand. `content.ts` is
184
+ user-owned and may be edited for view-level content that is not section-instance
185
+ configuration. For section-instance content, use `section configure`; never
186
+ hand-edit the `sectionContent` map in `content.ts`, a `sections/<id>.json`
187
+ sidecar, or derived files. A configured sidecar wins over
188
+ `sectionContent[id]`, which remains the fallback when no sidecar exists.
130
189
 
131
- User-owned (edit these): `lib/<name>/views/<view>/content.ts`, `props.ts`,
132
- `data.ts`, `schema.ts`, and `lib/<name>/mappers.ts`.
190
+ User-owned (edit these): `lib/<name>/views/<view>/content.ts` (non-section view
191
+ content), `props.ts`, `data.ts`, `schema.ts`, and `lib/<name>/mappers.ts`.
133
192
 
134
193
  Derived (never edit; the CLI regenerates them): `index.tsx`, `registry.tsx`,
135
194
  `lib/<name>/views/index.ts`, `lib/<name>/views/registry.ts`, `catalog.ts`,
136
- `runtime.ts`, `spec/index.ts`, `state.ts`, `handlers.ts`.
195
+ `runtime.ts`, `spec/index.ts`, `state.ts`, `handlers.ts`, and
196
+ `lib/<name>/views/<view>/sections-data.ts`.
197
+
198
+ The CLI writes `sections/<id>.json` only through `section configure`; never
199
+ hand-edit that sidecar or the derived `sections-data.ts`. Keep `content.ts` as a
200
+ hand-edit target for non-section view content, but do not customize section
201
+ instances through its `sectionContent` map. For an instance with a sidecar, its
202
+ data wins over the `content.ts` fallback.
137
203
 
138
204
  1. Read the current user-owned files for the view.
139
205
  2. Apply the requested change there. Preserve exported names, element ids, and
@@ -146,15 +146,50 @@
146
146
  }
147
147
  },
148
148
  "account.orders": {
149
- "default": "cards",
149
+ "default": "advanced",
150
150
  "intents": {
151
+ "advanced": {
152
+ "variant": "OrderHistoryAdvanced",
153
+ "when": "The signed-in shopper's full order history: search, quick filters, sort, counts and order cards driven by the host `OrdersPort` (the default surface)."
154
+ },
151
155
  "cards": {
152
156
  "variant": "OrderHistory",
153
- "when": "A signed-in shopper's order history with one card per order and details on demand (canonical `presentation: 'cards'`)."
157
+ "when": "A minimal order history rendered by the canonical `OrderHistory` block with one summary card per order and no query controls."
154
158
  },
155
159
  "rows": {
156
160
  "variant": "OrderHistory",
157
- "when": "A compact, list-first order history with one bordered row per order (canonical `presentation: 'rows'`)."
161
+ "when": "A minimal, list-first order history rendered by the canonical `OrderHistory` block in its `rows` presentation."
162
+ }
163
+ }
164
+ },
165
+ "account.summary": {
166
+ "default": "stack",
167
+ "intents": {
168
+ "stack": {
169
+ "variant": "stack",
170
+ "when": "A single scrolling account page: identity, then every installed module in order, with in-page navigation (canonical `presentation: 'stack'`)."
171
+ },
172
+ "tabs": {
173
+ "variant": "tabs",
174
+ "when": "One module visible at a time behind a tablist (canonical `presentation: 'tabs'`)."
175
+ }
176
+ }
177
+ },
178
+ "account.profile": {
179
+ "default": "form",
180
+ "intents": {
181
+ "form": {
182
+ "variant": "form",
183
+ "when": "The shopper's editable profile fields, with the email control present only when the backend supports changing it."
184
+ }
185
+ }
186
+ },
187
+ "account.addresses": {
188
+ "default": "cards",
189
+ "intents": {
190
+ "cards": {
191
+ "variant": "cards",
192
+ "when": "The shopper's saved addresses as cards, with create, edit, delete, and default-address actions."
158
193
  }
159
194
  }
160
195
  }
@@ -329,7 +329,7 @@
329
329
  }
330
330
  },
331
331
  "account.orders": {
332
- "default": "OrderHistory",
332
+ "default": "OrderHistoryAdvanced",
333
333
  "variants": {
334
334
  "OrderHistory": {
335
335
  "status": "executable",
@@ -343,12 +343,149 @@
343
343
  "accountCustomer",
344
344
  "accountAuthenticated"
345
345
  ]
346
+ },
347
+ "OrderHistoryAdvanced": {
348
+ "status": "executable",
349
+ "block": "OrderHistoryAdvanced",
350
+ "dataShape": "OrdersPage (host OrdersPort; B2C MVP)",
351
+ "events": [
352
+ "viewOrder",
353
+ "queryChange",
354
+ "presentationChange",
355
+ "orderAction",
356
+ "bulkAction"
357
+ ],
358
+ "state": "uncontrolled",
359
+ "requirements": [
360
+ "accountAuthenticated",
361
+ "ordersPort"
362
+ ]
346
363
  }
347
364
  },
348
365
  "legacyAliases": {
349
366
  "OrderHistory2": "OrderHistory"
350
367
  }
351
368
  },
369
+ "account.summary": {
370
+ "default": "stack",
371
+ "variants": {
372
+ "stack": {
373
+ "status": "executable",
374
+ "block": "AccountFrame",
375
+ "dataShape": "Customer & AccountModule[]",
376
+ "events": [
377
+ "selectModule"
378
+ ],
379
+ "state": "controlled",
380
+ "requirements": [
381
+ "accountCustomer",
382
+ "accountAuthenticated"
383
+ ]
384
+ },
385
+ "tabs": {
386
+ "status": "executable",
387
+ "block": "AccountFrame",
388
+ "dataShape": "Customer & AccountModule[]",
389
+ "events": [
390
+ "selectModule"
391
+ ],
392
+ "state": "controlled",
393
+ "requirements": [
394
+ "accountCustomer",
395
+ "accountAuthenticated"
396
+ ]
397
+ },
398
+ "sidebar": {
399
+ "status": "held",
400
+ "reason": "A dashboard sidebar nests the account navigation inside the storefront chrome and needs a layout the generated storefront does not provide yet.",
401
+ "block": "AccountFrame",
402
+ "dataShape": "Customer & AccountModule[]",
403
+ "events": [
404
+ "selectModule"
405
+ ],
406
+ "state": "controlled",
407
+ "requirements": [
408
+ "accountCustomer",
409
+ "accountAuthenticated"
410
+ ]
411
+ }
412
+ }
413
+ },
414
+ "account.profile": {
415
+ "default": "CustomerProfileAdvanced",
416
+ "variants": {
417
+ "form": {
418
+ "status": "executable",
419
+ "block": "ProfileForm",
420
+ "dataShape": "ProfileField[] & ProfileFormLabels",
421
+ "events": [
422
+ "submit"
423
+ ],
424
+ "state": "controlled",
425
+ "requirements": [
426
+ "accountCustomer",
427
+ "accountAuthenticated",
428
+ "accountProfileAvailable"
429
+ ]
430
+ },
431
+ "CustomerProfileAdvanced": {
432
+ "status": "executable",
433
+ "block": "CustomerProfile",
434
+ "dataShape": "CustomerProfileSnapshot (host CustomerProfilePort)",
435
+ "events": [
436
+ "manageOrganization",
437
+ "requestVerification",
438
+ "retry"
439
+ ],
440
+ "state": "controlled",
441
+ "requirements": [
442
+ "accountAuthenticated",
443
+ "customerProfilePort"
444
+ ]
445
+ }
446
+ }
447
+ },
448
+ "account.addresses": {
449
+ "default": "AddressBookAdvanced",
450
+ "variants": {
451
+ "cards": {
452
+ "status": "executable",
453
+ "block": "AddressBook",
454
+ "dataShape": "AccountAddressView[] & AddressBookLabels",
455
+ "events": [
456
+ "create",
457
+ "edit",
458
+ "delete",
459
+ "setDefaultShipping",
460
+ "setDefaultBilling"
461
+ ],
462
+ "state": "controlled",
463
+ "requirements": [
464
+ "accountCustomer",
465
+ "accountAuthenticated",
466
+ "accountAddressesAvailable"
467
+ ]
468
+ },
469
+ "AddressBookAdvanced": {
470
+ "status": "executable",
471
+ "block": "AddressBookAdvanced",
472
+ "dataShape": "AddressListResult (host AddressBookPort)",
473
+ "events": [
474
+ "create",
475
+ "edit",
476
+ "delete",
477
+ "setDefault",
478
+ "select"
479
+ ],
480
+ "state": "controlled",
481
+ "requirements": [
482
+ "accountAuthenticated",
483
+ "accountAddressesAvailable",
484
+ "addressesPort"
485
+ ]
486
+ }
487
+ }
488
+ },
352
489
  "category.breadcrumb": {
353
490
  "default": "Breadcrumb",
354
491
  "variants": {
@@ -4,6 +4,7 @@
4
4
  {
5
5
  "name": "checkout",
6
6
  "mvp": true,
7
+ "status": "executable",
7
8
  "description": "Multi-step checkout: cart validation, shipping, payment, and order placement.",
8
9
  "route": "/checkout",
9
10
  "views": ["checkout"],
@@ -29,6 +30,7 @@
29
30
  {
30
31
  "name": "customer-auth",
31
32
  "mvp": true,
33
+ "status": "executable",
32
34
  "description": "Customer authentication: registration, login, logout, and a minimal signed-in state. Owns the account view.",
33
35
  "route": "/account",
34
36
  "views": ["account"],
@@ -44,9 +46,57 @@
44
46
  "config": { "type": "object", "additionalProperties": false, "properties": {} },
45
47
  "surfaces": []
46
48
  },
49
+ {
50
+ "name": "customer-profile",
51
+ "mvp": true,
52
+ "starter": false,
53
+ "status": "gated",
54
+ "description": "Signed-in profile editor for the account area (name, phone, and email only where the backend supports changing it). Module of customer-auth.",
55
+ "views": [],
56
+ "state": ["accountProfileAvailable", "accountProfilePending", "accountProfileError"],
57
+ "handlers": [],
58
+ "requires": ["customer-auth"],
59
+ "adapter": { "needs": ["updateCustomer"] },
60
+ "backendCapabilities": ["updateProfile"],
61
+ "config": { "type": "object", "additionalProperties": false, "properties": {} },
62
+ "surfaces": []
63
+ },
64
+ {
65
+ "name": "customer-addresses",
66
+ "mvp": true,
67
+ "starter": false,
68
+ "status": "gated",
69
+ "description": "Signed-in address book for the account area (list, create, edit, delete, default shipping and billing). Module of customer-auth.",
70
+ "views": [],
71
+ "state": [
72
+ "accountAddressesAvailable",
73
+ "accountAddresses",
74
+ "accountAddressesPending",
75
+ "accountAddressesError",
76
+ "accountAddressFormOpen",
77
+ "accountAddressEditingId",
78
+ "accountAddressMutationPending",
79
+ "accountAddressMutationError",
80
+ "accountAddressFieldErrors"
81
+ ],
82
+ "handlers": [],
83
+ "requires": ["customer-auth"],
84
+ "adapter": {
85
+ "needs": [
86
+ "getCustomerAddresses",
87
+ "createCustomerAddress",
88
+ "updateCustomerAddress",
89
+ "deleteCustomerAddress"
90
+ ]
91
+ },
92
+ "backendCapabilities": ["manageAddresses"],
93
+ "config": { "type": "object", "additionalProperties": false, "properties": {} },
94
+ "surfaces": []
95
+ },
47
96
  {
48
97
  "name": "static-pages",
49
98
  "mvp": true,
99
+ "status": "executable",
50
100
  "description": "Content-driven static pages (contact, legal, about) served with per-page metadata. Owns the static view.",
51
101
  "route": "/contact",
52
102
  "views": ["static"],
@@ -59,6 +109,7 @@
59
109
  {
60
110
  "name": "benefits",
61
111
  "mvp": true,
112
+ "status": "executable",
62
113
  "description": "Bounded editorial benefits feature that mounts at the home benefits slot; config selects the canonical Feature block's presentation (compact -> cards, detailed -> split) while the item content stays user-owned.",
63
114
  "views": [],
64
115
  "state": [],
@@ -78,6 +129,7 @@
78
129
  {
79
130
  "name": "catalog-search",
80
131
  "mvp": true,
132
+ "status": "executable",
81
133
  "description": "Optional category-listing search control (E2). Installation is presence, not an enabled flag; the config only supplies an optional placeholder. The search input contributes to the single controlled CategoryListing at the category.search logical slot and never adds a block.",
82
134
  "views": [],
83
135
  "state": [],
@@ -96,6 +148,7 @@
96
148
  {
97
149
  "name": "category-filters",
98
150
  "mvp": true,
151
+ "status": "executable",
99
152
  "description": "Optional category-listing filter controls (E2). Installation is presence, not an enabled flag; the config selects which demonstrated basic filters show (filterSet) and whether the price control is shown (showPrice). The controls contribute to the single controlled CategoryListing at the category.filters logical slot and never add a block.",
100
153
  "views": [],
101
154
  "state": [],
@@ -125,6 +178,7 @@
125
178
  {
126
179
  "name": "navigability",
127
180
  "mvp": true,
181
+ "status": "executable",
128
182
  "description": "Cross-cutting navigability feature: entity-derived breadcrumbs with BreadcrumbList structured data on the product and category surfaces, plus skip-to-content, current-page indication, back-to-top, and a mobile bottom navigation in the shared shell.",
129
183
  "views": [],
130
184
  "state": [],
@@ -148,15 +202,32 @@
148
202
  {
149
203
  "name": "recommendations",
150
204
  "mvp": false,
205
+ "status": "held",
206
+ "reason": "No provider method backs a related-products read; the surface is injected through a catalog fallback and is outside the curated MVP set.",
207
+ "owner": "post-MVP recommendations change",
151
208
  "description": "Related-products surface injected into the product view.",
152
209
  "views": [],
153
210
  "state": ["recommendedProducts"],
154
211
  "handlers": [],
155
- "adapter": { "needs": ["getRelatedProducts"], "fallback": "catalog" },
212
+ "adapter": { "needs": [] },
156
213
  "config": { "type": "object", "additionalProperties": false, "properties": {} },
157
214
  "surfaces": [
158
215
  { "host": "product", "slot": "product.related", "element": "ProductGrid" }
159
216
  ]
217
+ },
218
+ {
219
+ "name": "customer-security",
220
+ "mvp": false,
221
+ "status": "held",
222
+ "reason": "Account deletion has no backend endpoint (the adapter throws NOT_IMPLEMENTED) and customer email change is not supported by the Medusa store API.",
223
+ "owner": "future customer-security change",
224
+ "description": "Account security controls: password reset, email change, and account deletion.",
225
+ "views": [],
226
+ "state": [],
227
+ "handlers": [],
228
+ "adapter": { "needs": [] },
229
+ "config": { "type": "object", "additionalProperties": false, "properties": {} },
230
+ "surfaces": []
160
231
  }
161
232
  ]
162
233
  }