create-ailk 0.37.1 → 0.39.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 (318) hide show
  1. package/README.md +129 -0
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +2 -2
  6. package/dist/add-route.js +19 -12
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +12 -16
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +73 -2
  26. package/dist/routes.d.ts +130 -0
  27. package/dist/routes.js +954 -0
  28. package/dist/site-manifest.js +6 -4
  29. package/dist/site-roster.d.ts +11 -2
  30. package/dist/site-roster.js +63 -21
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +26 -0
  34. package/dist/surfaces.js +105 -293
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +108 -10
  37. package/dist/template-record.js +3 -1
  38. package/dist/topology.d.ts +26 -1
  39. package/dist/topology.js +273 -7
  40. package/dist/update.d.ts +17 -2
  41. package/dist/update.js +480 -77
  42. package/package.json +3 -3
  43. package/templates/README.md +1 -1
  44. package/templates/apps/mcp/CLAUDE.md +5 -3
  45. package/templates/apps/web/CLAUDE.md +87 -23
  46. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
  47. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
  48. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  49. package/templates/apps/web/account.config.tsx +100 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
  52. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/layout.tsx +46 -29
  54. package/templates/apps/web/app/apple-icon.tsx +72 -0
  55. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  56. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  57. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  58. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  59. package/templates/apps/web/app/og/route.tsx +155 -72
  60. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  61. package/templates/apps/web/auth.config.tsx +107 -0
  62. package/templates/apps/web/auth.ts +2 -1
  63. package/templates/apps/web/i18n/request.ts +51 -1
  64. package/templates/apps/web/jest.config.cjs +17 -1
  65. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  66. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
  67. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  68. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  69. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  70. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  71. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  72. package/templates/apps/web/lib/listings.tsx +2 -2
  73. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  74. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  75. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  76. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  77. package/templates/apps/web/lib/served-pages.ts +95 -0
  78. package/templates/apps/web/lib/server-api.ts +1 -1
  79. package/templates/apps/web/lib/site-brand.tsx +3 -5
  80. package/templates/apps/web/lib/topology.generated.ts +5 -0
  81. package/templates/apps/web/messages/en.json +8 -836
  82. package/templates/apps/web/middleware.ts +15 -26
  83. package/templates/apps/web/next.config.mjs +35 -0
  84. package/templates/apps/web/package.json +2 -0
  85. package/templates/apps/web/types/messages.d.ts +6 -1
  86. package/templates/customizations.yaml +9 -0
  87. package/templates/package.json +3 -1
  88. package/templates/tools/lint-architecture.ts +164 -11
  89. package/versions.json +49 -47
  90. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  91. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  92. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  93. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  94. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  95. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  96. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  97. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  98. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  99. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  100. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  101. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  102. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  103. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  104. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  105. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  106. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  107. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  108. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  109. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  110. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  111. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  112. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  113. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  114. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  115. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  116. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  117. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  118. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  119. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  120. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  121. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  122. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  123. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  124. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  125. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  126. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  127. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  128. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  129. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  130. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  131. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  132. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  133. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  134. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  135. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  136. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  137. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  138. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  139. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  140. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  141. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  142. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  143. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  144. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  145. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  146. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  147. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
  148. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  149. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  150. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
  151. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
  152. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  153. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  154. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
  155. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  156. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  157. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  158. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  159. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  160. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  161. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
  162. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  163. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  164. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
  165. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  166. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  167. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  168. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  169. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  170. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  171. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  172. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  173. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  174. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  175. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  176. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
  177. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  178. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  179. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  180. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  181. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  182. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
  183. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  184. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
  185. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  186. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
  187. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  188. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  189. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  190. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  191. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  192. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  193. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
  194. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
  195. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  196. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  197. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  198. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
  199. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  200. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  201. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
  202. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
  203. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  204. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  205. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
  206. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
  207. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  208. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  209. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  210. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
  211. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  212. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  213. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
  214. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  215. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  216. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
  217. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  218. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  219. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  220. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  221. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  222. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  223. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  224. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  225. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  226. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  227. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  228. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  229. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  230. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  231. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  232. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  233. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  234. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  235. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  236. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  237. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  238. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  239. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  240. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  241. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  242. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  243. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  244. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  245. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  246. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  247. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  248. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  249. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  250. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  251. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  252. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  253. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  254. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  255. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  256. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  257. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  258. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  259. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  260. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  261. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  262. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  263. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  264. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  265. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  266. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  267. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  268. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  269. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  270. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  271. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  272. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  273. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  274. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  275. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  276. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  277. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  278. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  279. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  280. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  281. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  282. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  283. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  284. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  285. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  286. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  287. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  288. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  289. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  290. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  291. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  292. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  293. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  294. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  295. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  296. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  297. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  298. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  299. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  300. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  301. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  302. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  303. package/templates/apps/web/lib/account-config.ts +0 -678
  304. package/templates/apps/web/lib/auth-routes.ts +0 -125
  305. package/templates/apps/web/lib/checkout-config.ts +0 -16
  306. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  307. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  308. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  309. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  310. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  311. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  312. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  313. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  314. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  315. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  316. package/templates/apps/web/lib/next-path.ts +0 -35
  317. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  318. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,184 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * artifacts/artifact-actions.ts — the review write (#8234, spec
5
- * docs/specs/8234-member-artifacts-account-artifacts-and-spec.md D6; the
6
- * write is #8170's `POST /v1/member/artifacts/:pieceId/review`) and a
7
- * proposal's payment (#8516, spec
8
- * docs/specs/8516-proposals-as-an-artifact-kind-spec.md D19; the write is
9
- * `POST /v1/member/artifacts/:pieceId/payment`).
10
- *
11
- * `submitArtifactReview`, the review form's action, posts
12
- * Approve or Request changes on a piece's latest version through
13
- * `member.reviewArtifact` with `forwardedCookieInit()`'s init as built — the
14
- * session cookie plus the request's `Origin` on a single site, the hub
15
- * credential on a hub-mode spoke — so nothing here tests the topology. The
16
- * body is the strict `MemberReviewBody` (`version`, `review`, `comment`), so
17
- * no title, stage, note or link can be posted (AC-MAA-05). The posted
18
- * `pieceId` and `version` are untrusted: they are shape-checked here, and the
19
- * API scopes them to the Person the credential resolves.
20
- *
21
- * A proposal's payment (#8516 D19). An approval whose answered artifact owes
22
- * a payment (`paymentDue`) goes straight on to it; `payForProposal`, the Pay
23
- * now form's action, does the same from the artifact page. Both run the one
24
- * private `startProposalPayment`: `member.payArtifact` with the same init,
25
- * then `redirect()` — only to a URL `isStripeCheckoutUrl` admits, so the
26
- * client is never sent anywhere but Stripe's hosted Checkout page. The
27
- * amount is the API's, from the stored proposal; nothing posted here names
28
- * one. Any other outcome is `payment_failed`, and the review stays recorded,
29
- * so the page offers Pay now. `redirect()` throws `NEXT_REDIRECT` by design,
30
- * so it is called outside any try/catch (`../actions.ts`'s idiom).
31
- *
32
- * Not a `*.actions.ts` file and no `*Action`-suffixed export: apps/mcp's
33
- * parity test reads that suffix, and the member writes have no MCP twin by
34
- * decision (8170's header). The reads the pages share live in
35
- * `artifact-data.ts`, never here — every export of this module is a POST
36
- * endpoint. A log line carries `err.name` only — never the comment, an id
37
- * or a Checkout URL.
38
- */
39
-
40
- import { member } from "@working-theory/api-client";
41
- import {
42
- isStripeCheckoutUrl,
43
- memberReviewBodySchema,
44
- memberReviewParamsSchema,
45
- type MemberReviewBody,
46
- } from "@working-theory/validation";
47
- import { redirect } from "next/navigation";
48
-
49
- import { forwardedCookieInit } from "../../../../../lib/server-api";
50
-
51
- import { paymentDue } from "./artifact-data";
52
-
53
- /** What the review form shows after a submit. */
54
- export type ArtifactReviewState =
55
- | { kind: "idle" }
56
- | { kind: "reviewed" }
57
- | {
58
- kind: "error";
59
- reason:
60
- | "comment_required"
61
- | "closed"
62
- | "not_latest"
63
- | "rate_limited"
64
- | "failed"
65
- | "payment_failed";
66
- };
67
-
68
- export type ArtifactReviewReason = Extract<
69
- ArtifactReviewState,
70
- { kind: "error" }
71
- >["reason"];
72
-
73
- /** What the Pay now form shows after a submit that did not leave for Stripe. */
74
- export type ProposalPayState =
75
- { kind: "idle" } | { kind: "error"; reason: "payment_failed" };
76
-
77
- const PAYMENT_FAILED = { kind: "error", reason: "payment_failed" } as const;
78
-
79
- function error(reason: ArtifactReviewReason): ArtifactReviewState {
80
- return { kind: "error", reason };
81
- }
82
-
83
- /** A form field as a string; a missing or file field is empty. */
84
- function field(formData: FormData, name: string): string {
85
- const value = formData.get(name);
86
- return typeof value === "string" ? value : "";
87
- }
88
-
89
- /** The refusal's reason, from the api-client's `{ ok: false, status, body }`. */
90
- function refusalReason(status: number, body: unknown): ArtifactReviewReason {
91
- const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
92
- if (code === "review_closed") return "closed";
93
- if (code === "version_not_latest") return "not_latest";
94
- // The route's own budget answers `too_many_requests`; the hub's
95
- // per-person budget and the per-IP limiter answer `429 rate_limited`.
96
- if (code === "too_many_requests" || status === 429) return "rate_limited";
97
- return "failed";
98
- }
99
-
100
- /** Approve, or request changes with a comment, on a piece's latest version. */
101
- export async function submitArtifactReview(
102
- _prev: ArtifactReviewState,
103
- formData: FormData,
104
- ): Promise<ArtifactReviewState> {
105
- const pieceId = field(formData, "pieceId");
106
- const review = field(formData, "review");
107
- const comment = field(formData, "comment").trim();
108
-
109
- if (review === "changes-requested" && comment === "")
110
- return error("comment_required");
111
-
112
- const candidate = {
113
- version: Number(field(formData, "version")),
114
- review,
115
- ...(comment !== "" ? { comment } : {}),
116
- };
117
- if (!memberReviewParamsSchema.safeParse({ pieceId }).success)
118
- return error("failed");
119
- const parsed = memberReviewBodySchema.safeParse(candidate);
120
- if (!parsed.success) {
121
- // A comment of control or bidi characters only is stripped to nothing
122
- // by the server's `plainText`; to the person that is a missing comment.
123
- const onComment = parsed.error.issues.some(
124
- (issue) => issue.path[0] === "comment",
125
- );
126
- return error(
127
- review === "changes-requested" && onComment
128
- ? "comment_required"
129
- : "failed",
130
- );
131
- }
132
- const body: MemberReviewBody = parsed.data;
133
-
134
- let res: Awaited<ReturnType<typeof member.reviewArtifact>>;
135
- try {
136
- res = await member.reviewArtifact(
137
- pieceId,
138
- body,
139
- await forwardedCookieInit(),
140
- );
141
- } catch (err) {
142
- console.error(
143
- `[account] review failed errName=${err instanceof Error ? err.name : "unknown"}`,
144
- );
145
- return error("failed");
146
- }
147
- if (!res.ok) return error(refusalReason(res.status, res.body));
148
- if (body.review === "approved" && paymentDue(res.body.artifact))
149
- return startProposalPayment(pieceId);
150
- return { kind: "reviewed" };
151
- }
152
-
153
- /** Pay now: open the approved proposal's payment and go to it. */
154
- export async function payForProposal(
155
- _prev: ProposalPayState,
156
- formData: FormData,
157
- ): Promise<ProposalPayState> {
158
- const pieceId = field(formData, "pieceId");
159
- if (!memberReviewParamsSchema.safeParse({ pieceId }).success)
160
- return PAYMENT_FAILED;
161
- return startProposalPayment(pieceId);
162
- }
163
-
164
- /**
165
- * Ask the API for the proposal's Stripe Checkout page and redirect there.
166
- * Never returns on success; anything short of a Stripe Checkout URL is
167
- * `payment_failed`.
168
- */
169
- async function startProposalPayment(
170
- pieceId: string,
171
- ): Promise<typeof PAYMENT_FAILED> {
172
- let url: string | null = null;
173
- try {
174
- const res = await member.payArtifact(pieceId, await forwardedCookieInit());
175
- if (res.ok && isStripeCheckoutUrl(res.body.url)) url = res.body.url;
176
- } catch (err) {
177
- console.error(
178
- `[account] payment failed errName=${err instanceof Error ? err.name : "unknown"}`,
179
- );
180
- }
181
- if (url === null) return PAYMENT_FAILED;
182
- // Outside any try/catch on purpose — see the file header.
183
- redirect(url);
184
- }
@@ -1,197 +0,0 @@
1
- /**
2
- * artifacts/artifact-data.ts — the Artifacts pages' read and its helpers
3
- * (#8234, spec docs/specs/8234-member-artifacts-account-artifacts-and-spec.md
4
- * D2, C6; #11161).
5
- *
6
- * The list and the artifact page read the same artifacts, so the read lives
7
- * here — not in `artifact-actions.ts`, where every export of a
8
- * `"use server"` module is a POST endpoint, and not in
9
- * `lib/account-config.ts`, whose `read()` stays private. The account area's
10
- * read rule is restated: a 404 (no tenancy module, or a spoke route the hub
11
- * does not admit) is "nothing delivered"; a 401 or 403 is the same while the
12
- * person's email is unverified; anything else throws, so the page shows its
13
- * error row with Retry (spec 7423 D12), never an empty list.
14
- *
15
- * The read serves versions newest first and at least one (8169 D6), so
16
- * `versions[0]` is the latest version. Items keep the read's order — newest
17
- * delivery first — and are never re-sorted here.
18
- *
19
- * #11161 (operator rulings 2026-11-08): the member's Status is the piece's
20
- * STAGE — the provider's own pipeline, served per artifact as `stage` with
21
- * its `stageLabel`, and as the workspace's declared list `stages` with
22
- * `stageLabels`, in declared order. The version review (approved / changes
23
- * requested / none) is a tag beside it, never a status of its own. A stage
24
- * reads for a member by its LABEL — the one the provider set in the Admin's
25
- * Artifact stages section (point 6), never the slug; the terminal default
26
- * reads "Delivered" until the provider renames it. A hub older than the
27
- * labels serves the slug alone, which reads as its default label
28
- * (`defaultPieceStageLabel`); one older still serves no stage, so its
29
- * artifacts have no stage facet and the facet group is the four defaults.
30
- */
31
-
32
- import { member } from "@working-theory/api-client";
33
- import type { AccountContext } from "@working-theory/templates/account";
34
- import { localeHref } from "@working-theory/ui";
35
- import {
36
- defaultPieceStageLabel,
37
- type MemberArtifact,
38
- type MemberPieceVersion,
39
- } from "@working-theory/validation";
40
- import { cache } from "react";
41
-
42
- import { unwrapApiResult } from "../../../../../lib/server-api";
43
-
44
- /** One declared stage: the slug (the key) and the label a member reads. */
45
- export interface MemberStage {
46
- slug: string;
47
- label: string;
48
- }
49
-
50
- export interface MemberArtifacts {
51
- /** Newest delivery first, the read's order. */
52
- items: MemberArtifact[];
53
- /** The workspace's declared stages, in declared order, each with its label. */
54
- stages: MemberStage[];
55
- }
56
-
57
- /** The four product-default stages, for an older hub that serves no list. */
58
- const DEFAULT_STAGES = ["requested", "in-progress", "in-review", "delivered"];
59
-
60
- const stagesOf = (slugs: readonly string[], labels: readonly string[] = []): MemberStage[] =>
61
- slugs.map((slug, index) => ({ slug, label: labels[index] ?? defaultPieceStageLabel(slug) }));
62
-
63
- const EMPTY: MemberArtifacts = { items: [], stages: stagesOf(DEFAULT_STAGES) };
64
-
65
- /** The member's artifacts and the workspace's stages. One read per request. */
66
- export const loadArtifacts = cache(
67
- async (ctx: AccountContext): Promise<MemberArtifacts> => {
68
- const res = await member.artifacts(ctx.init);
69
- if (!res.ok) {
70
- if (res.status === 404) return EMPTY;
71
- if (!ctx.user.emailVerified && (res.status === 401 || res.status === 403)) return EMPTY;
72
- }
73
- const body = await unwrapApiResult(Promise.resolve(res));
74
- return {
75
- items: body.items,
76
- stages: body.stages === undefined ? EMPTY.stages : stagesOf(body.stages, body.stageLabels),
77
- };
78
- },
79
- );
80
-
81
- export type ArtifactState = "approved" | "changes-requested" | "ready";
82
-
83
- /**
84
- * The `account` catalog key that names each review state as a TAG — none for
85
- * `ready`, whose artifact carries no review tag (#11161).
86
- */
87
- export const STATE_KEYS = {
88
- approved: "artifacts.states.approved",
89
- "changes-requested": "artifacts.states.changesRequested",
90
- } as const satisfies Partial<Record<ArtifactState, string>>;
91
-
92
- /** The artifact's review state, from its approval and its latest version. */
93
- export function artifactState(a: MemberArtifact): ArtifactState {
94
- if (a.approvedAt !== null) return "approved";
95
- return a.versions[0]?.review === "changes-requested"
96
- ? "changes-requested"
97
- : "ready";
98
- }
99
-
100
- /**
101
- * An artifact's stage as a member reads it (#11161): the label the hub served
102
- * with it; for a hub older than the labels, the slug's default label; for one
103
- * that serves no stage, `null`.
104
- */
105
- export function artifactStageLabel(a: MemberArtifact): string | null {
106
- if (a.stage === undefined) return null;
107
- return a.stageLabel ?? defaultPieceStageLabel(a.stage);
108
- }
109
-
110
- /** A facet's glyph by its place in the declared order: first dashed, last a check, the rest a dot. */
111
- export function stageGlyph(
112
- index: number,
113
- count: number,
114
- ): "circle-dashed" | "circle-dot" | "circle-check" {
115
- if (index === 0) return "circle-dashed";
116
- if (index === count - 1) return "circle-check";
117
- return "circle-dot";
118
- }
119
-
120
- /** The `artifacts.types.*` key naming a version's file type — the Admin's own labels (#11161). */
121
- const TYPE_KEYS = {
122
- "application/pdf": "artifacts.types.pdf",
123
- "image/png": "artifacts.types.png",
124
- "image/jpeg": "artifacts.types.jpeg",
125
- "image/gif": "artifacts.types.gif",
126
- "image/webp": "artifacts.types.webp",
127
- "image/avif": "artifacts.types.avif",
128
- } as const;
129
- type TypeKey =
130
- | (typeof TYPE_KEYS)[keyof typeof TYPE_KEYS]
131
- | "artifacts.types.file"
132
- | "artifacts.types.link";
133
-
134
- const isNamedType = (contentType: string): contentType is keyof typeof TYPE_KEYS =>
135
- Object.prototype.hasOwnProperty.call(TYPE_KEYS, contentType);
136
-
137
- /** The Type cell: the latest version's file type, or Link (#11161). Read as the preview reads it: parameters dropped, case folded. */
138
- export function versionTypeKey(v: MemberPieceVersion): TypeKey {
139
- if (v.file === null) return "artifacts.types.link";
140
- const type = (v.file.contentType.split(";")[0] ?? "").trim().toLowerCase();
141
- return isNamedType(type) ? TYPE_KEYS[type] : "artifacts.types.file";
142
- }
143
-
144
- /**
145
- * True while the latest version can be reviewed: the artifact is not
146
- * approved and that version has no review yet (8170 C7 — a reviewed version
147
- * is `review_closed` until the provider delivers the next one).
148
- */
149
- export function isReviewable(a: MemberArtifact): boolean {
150
- return a.approvedAt === null && a.versions[0]?.review === null;
151
- }
152
-
153
- /**
154
- * True for a proposal (#8516 D19). An older hub serves no `kind` (D4: the
155
- * key is optional), and such an artifact is a deliverable.
156
- */
157
- export function isProposal(a: MemberArtifact): boolean {
158
- return a.kind === "proposal";
159
- }
160
-
161
- /**
162
- * True while an approved, priced proposal waits on the client's payment
163
- * (#8516 D19). The API serves `due` only where a payment surface answers,
164
- * so anything else — `null`, `paid` or an older hub's missing key — is not.
165
- */
166
- export function paymentDue(a: MemberArtifact): boolean {
167
- return a.payment?.status === "due";
168
- }
169
-
170
- /** The artifact page of one piece. */
171
- export function artifactHref(locale: string, pieceId: string): string {
172
- return localeHref(
173
- locale,
174
- `/account/artifacts/${encodeURIComponent(pieceId)}`,
175
- );
176
- }
177
-
178
- /** The download route of one version's file. */
179
- export function versionFileHref(
180
- locale: string,
181
- pieceId: string,
182
- version: number,
183
- ): string {
184
- return `${artifactHref(locale, pieceId)}/versions/${version}/file`;
185
- }
186
-
187
- /**
188
- * The preview route of one version's file (#11161): the same route, asked
189
- * to answer inline — which it does for an image or a PDF only.
190
- */
191
- export function versionPreviewHref(
192
- locale: string,
193
- pieceId: string,
194
- version: number,
195
- ): string {
196
- return `${versionFileHref(locale, pieceId, version)}?inline=1`;
197
- }
@@ -1,182 +0,0 @@
1
- /**
2
- * /[locale]/account/artifacts — Library › Artifacts (#8338, spec
3
- * docs/specs/8338-account-artifacts-structured-like-the-spec.md D3; D3
4
- * supersedes #8234's D3, which rendered the flat Inbox-style list.
5
- *
6
- * RSC, inside the account layout's SignedInShell (the rail's Artifacts row,
7
- * #8231 D1, is selected here). Renders `AccountListFrame` — the Admin Docs
8
- * page's structure: a second column with an "All Artifacts" count and a
9
- * Status facet group — the workspace's declared piece stages, every one in
10
- * declared order and read by its LABEL (#11161; default Requested · In
11
- * progress · In review · Delivered), each counted over every artifact with
12
- * zeros kept — and a table of Title · Type · Version · Status in the read's
13
- * order — newest delivery first. Type is the latest version's file type (the
14
- * Admin's own labels) or Link; Version its number; Status the piece's stage
15
- * label as a tag,
16
- * with the member's review of the latest version (Approved / Changes
17
- * requested) as a second tag when there is one — stage and review are never
18
- * combined into one state. The Status column is wide enough for its longest
19
- * stage label (#8361). Below `md` the column becomes a filter select and the
20
- * table becomes the phone row list.
21
- *
22
- * A 404 read (no tenancy module, or a spoke route the hub does not admit)
23
- * shows the frame with every count at 0 and the plain empty line; any other
24
- * failed read renders today's error row with Retry and no frame (spec 7423
25
- * D12). Nothing here tests the topology: the same file serves a single site
26
- * and a hub-mode spoke.
27
- *
28
- * A proposal (#8516, spec docs/specs/8516-proposals-as-an-artifact-kind-spec.md
29
- * D19) reads "Proposal · Version <n>" in its caption and Latest cell; a
30
- * deliverable reads as before.
31
- */
32
-
33
- import {
34
- AccountListFrame,
35
- type AccountListFrameRow,
36
- } from "@working-theory/templates/account";
37
- import {
38
- Heading,
39
- Text,
40
- } from "@working-theory/ui/primitives";
41
- import type { MemberArtifact } from "@working-theory/validation";
42
- import type { Metadata } from "next";
43
- import { getTranslations } from "next-intl/server";
44
- import type { ReactElement } from "react";
45
-
46
- import { accountSession, logReadFailure } from "../account-data";
47
- import { ErrorRow } from "../error-row";
48
-
49
- import {
50
- artifactHref,
51
- artifactStageLabel,
52
- artifactState,
53
- isProposal,
54
- loadArtifacts,
55
- stageGlyph,
56
- STATE_KEYS,
57
- versionTypeKey,
58
- type MemberArtifacts,
59
- } from "./artifact-data";
60
-
61
- interface Props {
62
- params: Promise<{ locale: string }>;
63
- }
64
-
65
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
66
- const { locale } = await params;
67
- const t = await getTranslations({ locale, namespace: "account" });
68
- return { title: t("artifacts.title") };
69
- }
70
-
71
- export default async function AccountArtifactsPage({
72
- params,
73
- }: Props): Promise<ReactElement> {
74
- const { locale } = await params;
75
- const t = await getTranslations({ locale, namespace: "account" });
76
- const session = await accountSession(locale);
77
-
78
- const heading = (
79
- <>
80
- <Heading level={1} visual={2}>
81
- {t("artifacts.title")}
82
- </Heading>
83
- <Text as="p" variant="body-sm" tone="muted" className="mt-block-tight">
84
- {t("artifacts.lead")}
85
- </Text>
86
- </>
87
- );
88
-
89
- // Unreachable behind the (authed) gate — the layout renders the sign-in
90
- // gate instead — but the page still renders in parallel with it, so a
91
- // `notFound()` here streams a 404 digest over the gate (the scaffold render
92
- // sweep's `/account/artifacts -> streamed not-found`). Mirror
93
- // `../general/page.tsx`: the heading alone.
94
- if (!session) {
95
- return (
96
- <div className="max-w-3xl py-8" data-testid="artifacts">
97
- {heading}
98
- </div>
99
- );
100
- }
101
-
102
- let artifacts: MemberArtifacts | null;
103
- try {
104
- artifacts = await loadArtifacts(session.ctx);
105
- } catch (err) {
106
- logReadFailure("artifacts", err);
107
- artifacts = null;
108
- }
109
-
110
- if (artifacts === null) {
111
- return (
112
- <div className="max-w-3xl py-8" data-testid="artifacts">
113
- {heading}
114
- <ErrorRow
115
- className="mt-block-loose"
116
- message={t("artifacts.error")}
117
- retryLabel={t("artifacts.retry")}
118
- />
119
- </div>
120
- );
121
- }
122
-
123
- const { items, stages } = artifacts;
124
- const row = (artifact: MemberArtifact): AccountListFrameRow => {
125
- const state = artifactState(artifact);
126
- const latest = artifact.versions[0]!;
127
- // An older hub serves no stage: the row sits under All alone.
128
- const stageWord = artifactStageLabel(artifact);
129
- const reviewWord = state === "ready" ? null : t(STATE_KEYS[state]);
130
- const versionWord = t("artifacts.version", { version: latest.version });
131
- const latestWord = isProposal(artifact)
132
- ? `${t("artifacts.proposal.caption")} · ${versionWord}`
133
- : versionWord;
134
- return {
135
- id: artifact.id,
136
- title: artifact.title,
137
- href: artifactHref(locale, artifact.id),
138
- // An older hub serves no stage: the empty facet matches no group row,
139
- // so the artifact sits under All alone.
140
- facet: artifact.stage ?? "",
141
- caption: [latestWord, stageWord, reviewWord].filter(Boolean).join(" · "),
142
- cells: {
143
- type: t(versionTypeKey(latest)),
144
- version: latestWord,
145
- },
146
- tags: { status: [stageWord, reviewWord].filter((word) => word !== null) },
147
- };
148
- };
149
-
150
- return (
151
- <AccountListFrame
152
- title={t("artifacts.title")}
153
- lead={t("artifacts.lead")}
154
- glyph="layers"
155
- all={{ label: t("artifacts.all") }}
156
- group={{
157
- heading: t("artifacts.statusGroup"),
158
- facets: stages.map((stage, index) => ({
159
- id: stage.slug,
160
- label: stage.label,
161
- glyph: stageGlyph(index, stages.length),
162
- })),
163
- }}
164
- columns={[
165
- { key: "title", header: t("artifacts.columns.title") },
166
- { key: "type", header: t("artifacts.columns.type"), width: "1/6", minWidth: "24" },
167
- { key: "version", header: t("artifacts.columns.version"), width: "1/6", minWidth: "28" },
168
- // Sized by the frame from the longest stage label (#8361).
169
- { key: "status", header: t("artifacts.columns.status"), fit: "facets", kind: "tags" },
170
- ]}
171
- rows={items.map(row)}
172
- labels={{
173
- nav: t("artifacts.facets"),
174
- table: t("artifacts.title"),
175
- filter: t("artifacts.filter"),
176
- empty: t("artifacts.empty"),
177
- facetEmpty: t("artifacts.facetEmpty"),
178
- }}
179
- testIdPrefix="artifacts"
180
- />
181
- );
182
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * `billingOfferings` (#11165 AC-2, AC-3) — the shown set's share of User
3
- * settings › Billing, as a pure function: the base plan (the lowest-priced
4
- * live plan), the Upgrade target (the next live plan above it by price —
5
- * Essentials → Growth on a three-plan set), the first live offer, and the
6
- * no-plan case. Sits beside the module: architecture.yaml bans a relative
7
- * `../billing/` import from the account tree's own suites.
8
- */
9
- import type { OfferingsProduct, WorkspaceShownSetWire } from "@working-theory/validation";
10
-
11
- import { billingOfferings } from "../offerings";
12
-
13
- function plan(slug: string, name: string, amount: number, extra: Partial<OfferingsProduct> = {}): OfferingsProduct {
14
- return {
15
- productId: `prod_${slug.replace(/-/g, "")}`,
16
- plan: slug,
17
- name,
18
- description: null,
19
- marketingFeatures: [],
20
- unitLabel: null,
21
- note: null,
22
- termsNote: null,
23
- ailkGroup: "plan",
24
- ailkOrder: null,
25
- prices: [
26
- {
27
- priceId: `price_${slug.replace(/-/g, "")}_monthly`,
28
- lookupKey: `${slug}_monthly`,
29
- plan: slug,
30
- period: "monthly",
31
- interval: "month",
32
- amount,
33
- currency: "usd",
34
- },
35
- ],
36
- recommended: false,
37
- ...extra,
38
- };
39
- }
40
-
41
- const OFFER: OfferingsProduct = {
42
- ...plan("welcome", "Two weeks of Growth, on us", 0),
43
- productId: "prod_welcome",
44
- description: "Try the Growth plan for two weeks before you commit.",
45
- ailkGroup: "offer",
46
- prices: [
47
- { priceId: "price_welcome_once", lookupKey: "welcome_once", plan: "welcome", period: "once", interval: null, amount: 0, currency: "usd" },
48
- ],
49
- image: "https://files.stripe.com/links/offer.png",
50
- promotionCode: "WELCOME20",
51
- };
52
-
53
- /** Growth listed before Essentials, so the order under test is the price's, not the snapshot's. */
54
- function threePlans(offerings: OfferingsProduct[] = [plan("growth", "Growth", 2_500_000), plan("essentials", "Essentials", 1_250_000), plan("scale", "Scale", 5_000_000)]): WorkspaceShownSetWire {
55
- return {
56
- productIds: offerings.map((o) => o.productId),
57
- recommended: { plan: null, addon: null },
58
- offerings,
59
- state: "current",
60
- snapshotAt: "2026-11-08T00:00:00.000Z",
61
- };
62
- }
63
-
64
-
65
- describe("billingOfferings — the shown set's share (#11165 AC-2, AC-3)", () => {
66
- it("pins Essentials → Growth on the three-plan set, by price and not by the snapshot's order, and the first offer", () => {
67
- const out = billingOfferings(threePlans([OFFER, plan("growth", "Growth", 2_500_000), plan("essentials", "Essentials", 1_250_000), plan("scale", "Scale", 5_000_000)]));
68
- expect(out.base).toMatchObject({ name: "Essentials", price: { amountMinor: 1_250_000, currency: "usd", interval: "month" }, checkoutHref: "/api/offerings/checkout/essentials_monthly" });
69
- expect(out.next).toMatchObject({ name: "Growth", checkoutHref: "/api/offerings/checkout/growth_monthly" });
70
- expect(out.offer).toEqual({
71
- productId: "prod_welcome",
72
- name: "Two weeks of Growth, on us",
73
- description: "Try the Growth plan for two weeks before you commit.",
74
- image: "https://files.stripe.com/links/offer.png",
75
- claimHref: "/api/offerings/checkout/welcome_once?promo=WELCOME20",
76
- });
77
- });
78
-
79
- it("the no-plan case: a set of add-ons and offers only, an expired set, or an unparsable body contributes nothing", () => {
80
- const empty = { base: null, next: null, offer: null };
81
- expect(billingOfferings(threePlans([{ ...plan("seo", "SEO audit", 1000), ailkGroup: "addon" }]))).toEqual(empty);
82
- expect(billingOfferings({ ...threePlans(), state: "expired", offerings: [] })).toEqual(empty);
83
- expect(billingOfferings({ nonsense: true })).toEqual(empty);
84
- expect(billingOfferings(threePlans([OFFER])).base).toBeNull();
85
- });
86
-
87
- it("one plan has a base and no next; an offer with no promotion code or image links its checkout bare", () => {
88
- const out = billingOfferings(threePlans([plan("essentials", "Essentials", 1_250_000), { ...OFFER, promotionCode: undefined, image: undefined }]));
89
- expect(out.base?.name).toBe("Essentials");
90
- expect(out.next).toBeNull();
91
- expect(out.offer).toMatchObject({ claimHref: "/api/offerings/checkout/welcome_once", image: null });
92
- });
93
-
94
- it("strips format characters from Stripe text and turns a description's line breaks into spaces", () => {
95
- const out = billingOfferings(threePlans([plan("essentials", "Ess‮entials", 1_250_000, { description: "Two sites,\none seat." })]));
96
- expect(out.base?.name).toBe("Essentials");
97
- expect(out.base?.description).toBe("Two sites, one seat.");
98
- });
99
- });