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,182 +0,0 @@
1
- /**
2
- * account-data.ts — the base account area's server reads (#7430, spec 7423
3
- * U4 · D6a, D8, D9, D12).
4
- *
5
- * One module the layout (the For-you aside), the Inbox and the item detail
6
- * share, so every page reads the contributions in `lib/account-config.ts`
7
- * the same way:
8
- *
9
- * - `accountSession(locale)` — the `AccountContext` every contribution
10
- * receives (locale, the session's person, the `account` translator and
11
- * the caller's forwarded cookie), or `null` with no session.
12
- * - `loadInboxItems(ctx)` — every kind's items, newest first, with
13
- * `failed` set when any kind's read rejected (D12: the Inbox then shows
14
- * an error row with Retry, never a silently partial or empty list).
15
- * - `loadForYou(locale)` — every For-you source's items plus the area's own
16
- * "Add your name" item (an accepted applicant arrives with no name,
17
- * #7418) — unless the `onboarding-steps` source already asks for the
18
- * name (#11150) — with the same `failed` flag.
19
- *
20
- * `cache()` dedupes the reads within one request: the layout's aside and the
21
- * Inbox's phone For you tab render the same items from one set of API calls.
22
- */
23
-
24
- import type {
25
- AccountContext,
26
- AccountInboxItem,
27
- AccountInboxKind,
28
- AccountTranslate,
29
- ForYouItem,
30
- } from "@working-theory/templates/account";
31
- import { localeHref } from "@working-theory/ui";
32
- import { Icon } from "@working-theory/ui/primitives";
33
- import { UserRound } from "lucide-react";
34
- import { headers } from "next/headers";
35
- import { getTranslations } from "next-intl/server";
36
- import { cache, createElement } from "react";
37
-
38
- import { accountForYouSources, accountInboxKinds } from "../../../../lib/account-config";
39
- import { forwardedCookieInit } from "../../../../lib/server-api";
40
- import { readSession } from "../../../../lib/topology.generated";
41
-
42
- /** The session's person, plus what the frame shows beyond the contract. */
43
- export interface AccountSession {
44
- ctx: AccountContext;
45
- /** ISO-8601 time the person's account was created, when the session carries it. */
46
- createdAt?: string | undefined;
47
- }
48
-
49
- /** The `AccountContext` for this request, or `null` when there is no session. */
50
- export const accountSession = cache(
51
- async (locale: string): Promise<AccountSession | null> => {
52
- // Through the generated seam (#7894 D10): Better Auth on a hub, the sealed
53
- // hub-session cookie on a spoke that signs in through its hub.
54
- const session = await readSession(await headers());
55
- if (!session) return null;
56
- // The contract's translator takes any key: a contribution's keys (a
57
- // kind's `label`, a section's `title`) are data, which next-intl's
58
- // literal-key typing cannot see. The runtime call is the same function.
59
- const t = (await getTranslations({ locale, namespace: "account" })) as unknown as AccountTranslate;
60
- const { name, email, emailVerified, createdAt } = session.user;
61
- return {
62
- ctx: {
63
- locale,
64
- user: { name: name ? name : null, email, emailVerified },
65
- t,
66
- init: await forwardedCookieInit(),
67
- },
68
- ...(createdAt ? { createdAt: new Date(createdAt).toISOString() } : {}),
69
- };
70
- },
71
- );
72
-
73
- /**
74
- * Logs a failed contribution read, PII-safe (`err.name` only — the
75
- * `actions.ts` idiom): the person sees the error row; the operator sees why.
76
- */
77
- export function logReadFailure(source: string, err: unknown): void {
78
- console.error(
79
- `[account] read failed source=${source} errName=${err instanceof Error ? err.name : "unknown"}`,
80
- );
81
- }
82
-
83
- /** The detail route of one Inbox item. */
84
- export function inboxItemHref(locale: string, kind: string, id: string): string {
85
- return localeHref(
86
- locale,
87
- `/account/inbox/${encodeURIComponent(kind)}/${encodeURIComponent(id)}`,
88
- );
89
- }
90
-
91
- // ── Inbox rows ───────────────────────────────────────────────────────────────
92
-
93
- /** One loaded item with the kind it came from — what a tab's row is built from. */
94
- export interface LoadedInboxItem {
95
- kind: AccountInboxKind;
96
- item: AccountInboxItem;
97
- }
98
-
99
- export interface LoadedInbox {
100
- items: LoadedInboxItem[];
101
- /** True when any kind's read rejected (D12). */
102
- failed: boolean;
103
- }
104
-
105
- const newestFirst = (a: LoadedInboxItem, b: LoadedInboxItem): number =>
106
- (b.item.at ?? "").localeCompare(a.item.at ?? "");
107
-
108
- /** Every kind's items, newest first. A rejected kind sets `failed`. */
109
- export async function loadInboxItems(ctx: AccountContext): Promise<LoadedInbox> {
110
- const settled = await Promise.allSettled(
111
- accountInboxKinds.map(async (kind) =>
112
- (await kind.load(ctx)).map((item) => ({ kind, item })),
113
- ),
114
- );
115
- settled.forEach((r, i) => {
116
- if (r.status === "rejected") logReadFailure(`kind:${accountInboxKinds[i]!.kind}`, r.reason);
117
- });
118
- const items = settled.flatMap((r) => (r.status === "fulfilled" ? r.value : []));
119
- return {
120
- items: items.sort(newestFirst),
121
- failed: settled.some((r) => r.status === "rejected"),
122
- };
123
- }
124
-
125
- // ── For you ──────────────────────────────────────────────────────────────────
126
-
127
- export interface LoadedForYou {
128
- items: ForYouItem[];
129
- /** True when any source's read rejected (D12). */
130
- failed: boolean;
131
- }
132
-
133
- /**
134
- * The area's own For-you item: a member with no name is asked for one
135
- * (operator fold-in 2026-10-01). It waits on them from the moment their
136
- * account exists; with no creation time on the session, from now.
137
- */
138
- function addNameItem(session: AccountSession, now: string): ForYouItem[] {
139
- const { ctx } = session;
140
- if (ctx.user.name) return [];
141
- return [
142
- {
143
- id: "add-name",
144
- type: {
145
- id: "profile",
146
- label: ctx.t("forYou.types.profile"),
147
- // The tag's glyph (DESIGN.md §5.4c: icon + label). An element, not a
148
- // component, so it crosses the server → client boundary.
149
- icon: createElement(Icon, { icon: UserRound, size: "xs", decorative: true }),
150
- tone: "needs-you",
151
- },
152
- title: ctx.t("forYou.addName"),
153
- time: { kind: "waiting", at: session.createdAt ?? now },
154
- action: { kind: "open", href: localeHref(ctx.locale, "/account/general") },
155
- dismissible: true,
156
- },
157
- ];
158
- }
159
-
160
- /** Every For-you source's items, plus the area's own. Deduped per request. */
161
- export const loadForYou = cache(
162
- async (locale: string): Promise<LoadedForYou & { now: string }> => {
163
- const now = new Date().toISOString();
164
- const session = await accountSession(locale);
165
- if (!session) return { items: [], failed: false, now };
166
- const settled = await Promise.allSettled(
167
- accountForYouSources.map((source) => source.load(session.ctx)),
168
- );
169
- settled.forEach((r, i) => {
170
- if (r.status === "rejected") logReadFailure(`foryou:${accountForYouSources[i]!.id}`, r.reason);
171
- });
172
- const items = settled.flatMap((r) => (r.status === "fulfilled" ? r.value : []));
173
- // #11150 — a welcomed member's `name` onboarding step says the same thing
174
- // and cannot be dismissed; the area's own item yields to it.
175
- const nameStep = items.some((item) => item.id === "onboarding:name");
176
- return {
177
- items: [...(nameStep ? [] : addNameItem(session, now)), ...items],
178
- failed: settled.some((r) => r.status === "rejected"),
179
- now,
180
- };
181
- },
182
- );
@@ -1,353 +0,0 @@
1
- "use client"; // the shell owns collapse state; sign-out is a client-side hub-session POST or Better Auth call + router navigation
2
-
3
- /**
4
- * AccountFrame — the account area's SignedInShell composition (#7430, spec
5
- * 7423 D13; DESIGN.md §2b). The layout (an RSC) resolves the strings, the
6
- * logo and the For-you items; this component wires them to the shell with
7
- * what only the client has: the current path and the sign-out call.
8
- *
9
- * `createAuthClient()` at module scope is the `(auth)` cards' idiom. Log
10
- * out ends the session, then navigates and refreshes so every RSC under the
11
- * `(authed)` gate re-reads the (now absent) session.
12
- *
13
- * #8465 — a spoke that signs in through its hub (#7894) holds its session in
14
- * a sealed cookie only `POST /api/hub-session/sign-out` clears (it also
15
- * revokes the credential at the hub); Better Auth's `signOut()` hits a route
16
- * that spoke does not serve. The server layout reads the generated seam's
17
- * `SIGN_OUT_ENDPOINT` and hands it down as `signOutEndpoint` — the signed-in
18
- * Nav's own pattern, because a client component cannot import the seam. With
19
- * an endpoint, Log out POSTs it and navigates to the sign-in page only when
20
- * the answer was 2xx; a refused or failed sign-out (a 403 on an Origin
21
- * mismatch, a 5xx, a network error) leaves the cookie valid, so the frame
22
- * stays on the page and says so, never routing away with a live session.
23
- * Without an endpoint (a hub or a single site) nothing changes: Better Auth,
24
- * then home. That logic is the exported `useAccountSignOut`, so the
25
- * agreements interstitial's Sign out ends the session the same way (#8765 D7).
26
- *
27
- * #8231 D1, as amended by #8334 — the rail reads Inbox, a Library group
28
- * holding Artifacts and Appointments (#11154), and the footer's ?. Settings is not a rail row: it lives
29
- * in the avatar menu, as on the Admin (the operator's 2026-10-11 Phase 6
30
- * read), so no row is selected on a Settings page. A row is selected on its
31
- * own path and the paths under it; the Inbox also on an item's page
32
- * (/account/inbox/…).
33
- *
34
- * #7469 (DESIGN.md §2b as amended 2026-10-01, matching the Admin's §5.15) —
35
- * below `md` the bar reads avatar · Inbox · For you · Help, with no count
36
- * on any tab. For you is a page of the Inbox route (`?tab=for-you`): the
37
- * frame reads the URL and hands the tab to the page (`PhoneTabProvider`),
38
- * which shows one panel per tab. At `md`+ nothing changes — For you stays
39
- * the aside.
40
- *
41
- * #8233 D4 — on the Inbox route itself the phone top bar's trailing cell is
42
- * an empty node handed to the page (`NewMenuSlotProvider`), which portals
43
- * its compact New into it; every other path has no trailing cell.
44
- *
45
- * #8337 D4 — the `data-ailk-shell="account"` marker on a `display: contents`
46
- * wrapper around `SignedInShell`: the layout's `shell-vars` reset
47
- * (`:root:has([data-ailk-shell])`) matches only while this frame is in the
48
- * document, so the Admin's colour tokens reach the shell and everything it
49
- * portals to `document.body` (the avatar/help menus, For-you, New, the phone
50
- * sheets) without the wrapper adding a box — `contents` keeps the shell's own
51
- * layout (`min-h-screen`) unchanged.
52
- *
53
- * #8430 — the User settings routes take the screen as the Admin's do: the
54
- * frame renders the page alone, inside the marker only — no rail, no Inbox,
55
- * no AppShell — and the page draws the shared `AccountSettingsFrame` in its
56
- * standalone shape, its own column flush and full height with Back to the
57
- * Inbox at its top. The marker stays, so the Admin's tokens still reach the
58
- * settings in both modes. Which routes those are is `isSettingsPath` — an
59
- * exact match on `SETTINGS_ROUTES`, the list the settings tabs read too
60
- * (#8441), so a sub-route stays inside the shell.
61
- */
62
-
63
- import {
64
- ForYouPanel,
65
- PhoneTabProvider,
66
- useForYouDismissed,
67
- type ForYouItem,
68
- type ForYouLabels,
69
- } from "@working-theory/templates/account";
70
- import {
71
- SignedInShell,
72
- type SignedInShellLabels,
73
- type SignedInShellProps,
74
- } from "@working-theory/templates/shells";
75
- import { localeHref } from "@working-theory/ui";
76
- import { InlineMessage, Link } from "@working-theory/ui/primitives";
77
- import { createAuthClient } from "better-auth/react";
78
- import { CalendarClock, Inbox, Layers, Settings, Sparkles } from "lucide-react";
79
- import { usePathname, useRouter, useSearchParams } from "next/navigation";
80
- import { useState, type ReactElement, type ReactNode } from "react";
81
-
82
- import { ACCOUNT_PERSIST_KEY } from "./for-you-labels";
83
- import { NewMenuSlotProvider } from "./new-menu";
84
- import { isSettingsPath } from "./settings-frame";
85
-
86
- const authClient = createAuthClient();
87
-
88
- /** The phone For you tab's `?tab=` value (#7469). */
89
- const FOR_YOU_TAB = "for-you";
90
-
91
- export interface AccountFrameLabels extends SignedInShellLabels {
92
- /** The logo link's accessible name. */
93
- home: string;
94
- inbox: string;
95
- /** The phone's For you tab label (#7469). */
96
- forYou: string;
97
- settings: string;
98
- /** The rail's Library group heading (#8231 D1). */
99
- library: string;
100
- artifacts: string;
101
- /** The Library group's Appointments row (#11154). */
102
- appointments: string;
103
- /** Shown when a hub sign-out is refused or fails (#8465). */
104
- signOutFailed: string;
105
- }
106
-
107
- export interface AccountFrameProps {
108
- locale: string;
109
- user: { name: string; email: string };
110
- /** The site's logo (the layout's `siteLogo()`), at most 32px tall. */
111
- logo: ReactNode;
112
- helpItems: NonNullable<SignedInShellProps["helpItems"]>;
113
- forYou: { items: readonly ForYouItem[]; now: string; labels: ForYouLabels };
114
- labels: AccountFrameLabels;
115
- /**
116
- * Where Log out POSTs on a spoke that signs in through its hub (the seam's
117
- * `SIGN_OUT_ENDPOINT`, read by the server layout). Absent or `null`: Better
118
- * Auth's client signs out (#8465).
119
- */
120
- signOutEndpoint?: string | null;
121
- /** Where Log out lands after a hub sign-out; defaults to the site home. */
122
- signInHref?: string;
123
- children: ReactNode;
124
- }
125
-
126
- export interface AccountSignOutOptions {
127
- locale: string;
128
- /** The seam's `SIGN_OUT_ENDPOINT`; absent or `null`: Better Auth signs out (#8465). */
129
- signOutEndpoint?: string | null | undefined;
130
- /** Where a hub sign-out lands; defaults to the site home. */
131
- signInHref?: string | undefined;
132
- }
133
-
134
- export interface AccountSignOut {
135
- onSignOut: () => void;
136
- /** True after a hub sign-out was refused or failed: the session is still live. */
137
- signOutFailed: boolean;
138
- }
139
-
140
- /**
141
- * The account area's Log out — the frame's, and the agreements
142
- * interstitial's Sign out (#8765 D7), so both end the session the same way.
143
- * With an endpoint (a spoke that signs in through its hub) it POSTs it and
144
- * navigates to the sign-in page only on a 2xx; a refused or failed sign-out
145
- * sets `signOutFailed` and navigates nowhere (#8465). Without one, Better
146
- * Auth signs out, then home.
147
- */
148
- export function useAccountSignOut({
149
- locale,
150
- signOutEndpoint,
151
- signInHref,
152
- }: AccountSignOutOptions): AccountSignOut {
153
- const router = useRouter();
154
- const [signOutFailed, setSignOutFailed] = useState(false);
155
- const homeHref = localeHref(locale, "/");
156
-
157
- const onSignOut = (): void => {
158
- void (async () => {
159
- setSignOutFailed(false);
160
- if (signOutEndpoint) {
161
- // A refused or failed sign-out leaves the session cookie valid, so the
162
- // page must not pretend otherwise by navigating away (#8465).
163
- try {
164
- const res = await fetch(signOutEndpoint, { method: "POST", credentials: "same-origin" });
165
- if (!res.ok) {
166
- setSignOutFailed(true);
167
- return;
168
- }
169
- } catch {
170
- setSignOutFailed(true);
171
- return;
172
- }
173
- router.push(signInHref ?? homeHref);
174
- router.refresh();
175
- return;
176
- }
177
- try {
178
- await authClient.signOut();
179
- } catch {
180
- // The refresh below re-reads the session either way: a sign-out that
181
- // failed lands the person back on a page that still knows them.
182
- }
183
- router.push(homeHref);
184
- router.refresh();
185
- })();
186
- };
187
-
188
- return { onSignOut, signOutFailed };
189
- }
190
-
191
- export function AccountFrame({
192
- locale,
193
- user,
194
- logo,
195
- helpItems,
196
- forYou,
197
- labels,
198
- signOutEndpoint,
199
- signInHref,
200
- children,
201
- }: AccountFrameProps): ReactElement {
202
- const pathname = usePathname();
203
- const searchParams = useSearchParams();
204
- const [dismissed] = useForYouDismissed(ACCOUNT_PERSIST_KEY);
205
- const [topBarActions, setTopBarActions] = useState<HTMLElement | null>(null);
206
- const { onSignOut, signOutFailed } = useAccountSignOut({ locale, signOutEndpoint, signInHref });
207
-
208
- const homeHref = localeHref(locale, "/");
209
- const inboxHref = localeHref(locale, "/account");
210
- const artifactsHref = localeHref(locale, "/account/artifacts");
211
- const appointmentsHref = localeHref(locale, "/account/appointments");
212
- const settingsHref = localeHref(locale, "/account/general");
213
- const within = (href: string): boolean => pathname === href || pathname.startsWith(`${href}/`);
214
-
215
- // #8430 — a Settings page draws its own standalone frame: the marker only.
216
- if (isSettingsPath(pathname, locale)) {
217
- return (
218
- <div className="contents" data-ailk-shell="account" data-testid="account-shell">
219
- {children}
220
- </div>
221
- );
222
- }
223
-
224
- // The Inbox row stays selected on an item's own page (/account/inbox/…).
225
- const onInbox = pathname === inboxHref || pathname.startsWith(`${inboxHref}/inbox/`);
226
- const activePath = onInbox
227
- ? inboxHref
228
- : within(artifactsHref)
229
- ? artifactsHref
230
- : within(appointmentsHref)
231
- ? appointmentsHref
232
- : undefined;
233
- // #7469 — the phone tab: For you only on the Inbox route itself.
234
- const phoneTab =
235
- pathname === inboxHref && searchParams?.get("tab") === FOR_YOU_TAB ? FOR_YOU_TAB : "inbox";
236
- // #8233 D4 — the Inbox route's New lives in the top bar; nowhere else.
237
- const onInboxRoute = pathname === inboxHref;
238
-
239
- const {
240
- home,
241
- inbox,
242
- forYou: forYouLabel,
243
- settings,
244
- library,
245
- artifacts,
246
- appointments,
247
- signOutFailed: signOutFailedLabel,
248
- ...shellLabels
249
- } = labels;
250
-
251
- // D13 — the logo only: no box, no name, no popover; it links home. The
252
- // same link is the phone top bar's leading cell.
253
- const logoLink = (
254
- <Link
255
- href={homeHref}
256
- variant="unstyled"
257
- aria-label={home}
258
- className="flex h-8 max-h-8 items-center rounded-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent)"
259
- data-testid="account-site-logo"
260
- >
261
- {logo}
262
- </Link>
263
- );
264
-
265
- const forYouLeft = forYou.items.filter((item) => !dismissed.has(item.id));
266
-
267
- return (
268
- <div className="contents" data-ailk-shell="account" data-testid="account-shell">
269
- <SignedInShell
270
- persistKey={ACCOUNT_PERSIST_KEY}
271
- locale={locale}
272
- navItems={[{ labelKey: "inbox", label: inbox, path: "/account", icon: Inbox }]}
273
- railGroups={[
274
- {
275
- key: "library",
276
- heading: library,
277
- items: [
278
- { labelKey: "artifacts", label: artifacts, path: "/account/artifacts", icon: Layers },
279
- {
280
- labelKey: "appointments",
281
- label: appointments,
282
- path: "/account/appointments",
283
- icon: CalendarClock,
284
- },
285
- ],
286
- },
287
- ]}
288
- tabItems={[
289
- { key: "inbox", label: inbox, href: inboxHref, icon: Inbox, isActive: onInbox && phoneTab === "inbox" },
290
- {
291
- key: FOR_YOU_TAB,
292
- label: forYouLabel,
293
- href: `${inboxHref}?tab=${FOR_YOU_TAB}`,
294
- icon: Sparkles,
295
- isActive: phoneTab === FOR_YOU_TAB,
296
- },
297
- ]}
298
- {...(activePath ? { activePath } : {})}
299
- user={user}
300
- userMenuItems={[
301
- {
302
- id: "settings",
303
- label: settings,
304
- icon: Settings,
305
- href: settingsHref,
306
- },
307
- ]}
308
- onSignOut={onSignOut}
309
- userDisplay="avatar"
310
- accountMenuLayout="card"
311
- helpItems={helpItems}
312
- railHeader={logoLink}
313
- topBarStart={logoLink}
314
- {...(onInboxRoute
315
- ? {
316
- topBarEnd: (
317
- <span
318
- ref={setTopBarActions}
319
- className="flex items-center"
320
- data-testid="account-top-bar-actions"
321
- />
322
- ),
323
- }
324
- : {})}
325
- {...(forYouLeft.length > 0
326
- ? {
327
- aside: (
328
- <ForYouPanel
329
- items={forYouLeft}
330
- persistKey={ACCOUNT_PERSIST_KEY}
331
- labels={forYou.labels}
332
- locale={locale}
333
- now={forYou.now}
334
- />
335
- ),
336
- }
337
- : {})}
338
- labels={shellLabels}
339
- >
340
- {signOutFailed ? (
341
- <InlineMessage variant="error" className="px-4 pt-3" data-testid="account-sign-out-error">
342
- {signOutFailedLabel}
343
- </InlineMessage>
344
- ) : null}
345
- <PhoneTabProvider tab={phoneTab}>
346
- <NewMenuSlotProvider node={onInboxRoute ? topBarActions : null}>
347
- {children}
348
- </NewMenuSlotProvider>
349
- </PhoneTabProvider>
350
- </SignedInShell>
351
- </div>
352
- );
353
- }
@@ -1,57 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * account/actions.ts — User settings › Billing's Server Action.
5
- *
6
- * `openBillingPortal` — User settings › Billing's Manage billing (#6038,
7
- * D5): mints a Stripe billing-portal session on SUBMIT, never on render, and
8
- * hands the browser straight to it via `redirect()`.
9
- *
10
- * The portal URL is never embedded in page data — it is created here, on
11
- * click, and never rendered into HTML or a client bundle (D5's precise
12
- * claim: `redirect()` DOES surface the target in the address bar/history/
13
- * navigation telemetry for a Server Action, which is inherent to any hosted-
14
- * portal handoff, not something this design avoids).
15
- *
16
- * Where the portal comes from is `billing-source.ts`'s `billingPortalUrl()`
17
- * (#8217, spec docs/specs/8217-spoke-billing-spoke-checkout-reads-spec.md
18
- * D10, D11), the account tree's billing seam — this file tests no topology:
19
- *
20
- * - A single site: the hub's `POST /v1/subscription/portal-session`, with
21
- * the caller's cookie and real `Origin` forwarded, which `apps/api`'s
22
- * `authPreHandler` checks against its trusted origins on this
23
- * cookie-authenticated mutating request; the route accepts only a cookie
24
- * session, never a bearer (D3.1/D5).
25
- * - A spoke that signs in through its hub: the hub's
26
- * `POST /v1/member/billing/portal-session` (#11165), minted through the
27
- * workspace's Organization's Stripe connection for the customer the hub
28
- * vouches for, returning to this page on the spoke's registered origin;
29
- * where the hub has no portal to open (an older hub, no connection), the
30
- * spoke's own Stripe key through the rendered billing action (spec 8217),
31
- * never from this action's input.
32
- * - A spoke with neither: no portal, so nothing to redirect to.
33
- *
34
- * It takes no argument, so nothing a browser sends can name a customer.
35
- * Next's Server Action origin check applies as before.
36
- *
37
- * `redirect()` throws `NEXT_REDIRECT` by design — called OUTSIDE any
38
- * try/catch (mirrors `checkout.actions.ts`'s idiom) so a catch never
39
- * swallows the navigation this action exists to perform.
40
- */
41
-
42
- import { redirect } from "next/navigation";
43
-
44
- import { billingPortalUrl } from "./billing-source";
45
-
46
- /**
47
- * Opens the caller's own Stripe billing-portal session and redirects there.
48
- * Never returns on success. With no portal (a failed mint, logged PII-safe by
49
- * `billingPortalUrl`, or none to open), it returns and the page stays as it
50
- * is — there is no error UI slot on this button.
51
- */
52
- export async function openBillingPortal(): Promise<void> {
53
- const url = await billingPortalUrl();
54
- if (url === null) return;
55
- // Outside any try/catch on purpose — see the file header.
56
- redirect(url);
57
- }
@@ -1,58 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * account/agreements-actions.ts — the account interstitial's one write
5
- * (#8765 D7, spec docs/specs/8765-sign-up-refuses-without-the-spec.md).
6
- *
7
- * `acceptAccountAgreementsAction` posts the sign-up agreements the
8
- * interstitial (`agreements-prompt.tsx`) showed to `POST /v1/consent/account`
9
- * (`consent.acceptAccountAgreements`), with the caller's forwarded cookie —
10
- * or, on a spoke that signs in through its hub, the hub credential
11
- * `forwardedCookieInit` returns — so the grant is account-level: subject
12
- * `user`, in the deployment's site workspace, read by the hub and every
13
- * spoke alike (C3). The API appends only when no grant exists at the current
14
- * version, so a double click adds nothing.
15
- *
16
- * It answers `{ ok }` only; the interstitial refreshes on `ok` and the
17
- * layout's next read decides whether the account loads. A refusal or a throw
18
- * is `{ ok: false }`, never a throw, so the interstitial shows its error line.
19
- *
20
- * Kept as its OWN file, separate from this directory's `actions.ts`
21
- * (Billing's `openBillingPortal`): that file imports `billing-source.ts`,
22
- * which pulls in `account-data.ts`, `@working-theory/ui` and `lucide-react`.
23
- */
24
-
25
- import { consent } from "@working-theory/api-client";
26
- import { getLocale } from "next-intl/server";
27
-
28
- import { forwardedCookieInit } from "../../../../lib/server-api";
29
-
30
- /** PII-safe: the status or the error's name, never the ids' owner. */
31
- function logAcceptFailed(reason: string): void {
32
- console.error("[account]", {
33
- event: "account-agreements",
34
- outcome: "accept_failed",
35
- reason,
36
- });
37
- }
38
-
39
- export interface AcceptAccountAgreementsResult {
40
- ok: boolean;
41
- }
42
-
43
- export async function acceptAccountAgreementsAction(
44
- purposeIds: string[],
45
- ): Promise<AcceptAccountAgreementsResult> {
46
- try {
47
- const locale = await getLocale();
48
- const res = await consent.acceptAccountAgreements(
49
- { purposeIds, locale },
50
- await forwardedCookieInit(),
51
- );
52
- if (!res.ok) logAcceptFailed(String(res.status));
53
- return { ok: res.ok };
54
- } catch (err) {
55
- logAcceptFailed(err instanceof Error ? err.name : "unknown");
56
- return { ok: false };
57
- }
58
- }