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,678 +0,0 @@
1
- // account-config.ts — what the /account area is made of (#4984, #7429).
2
- //
3
- // The module contribution contract (spec 7423 D8, D8a; #8231 D4): a module
4
- // extends a site's account area by adding entries to the five arrays below —
5
- // Inbox item kinds, User-settings sections, For-you sources, New actions and
6
- // Billing sections — never a rail entry. An absent module is an absent entry.
7
- // The contract's types live in `@working-theory/templates/account`; a kind's
8
- // label is a message key in the `account` namespace, and a For-you item's
9
- // strings are built through the context's `t`.
10
- //
11
- // `accountExperimentKeys` — mirrors `nav-config.ts`: the OSS template
12
- // declares NO experiments — nothing in `apps/web` runs a diagnostic today, so
13
- // this list ships empty and the Inbox carries no `result` rows. A consuming
14
- // site lists the `experimentKey`s of the diagnostics it runs (the `key` of
15
- // each `waitlistExperiment` it registers) so `/account` can read the
16
- // signed-in respondent's own newest signup for each via
17
- // `waitlistSignups.me(key)` (`GET /v1/waitlist-signups/me?experimentKey=…`,
18
- // #4731 D5). Keys the caller has no signup for come back 404 and are
19
- // skipped, so listing every experiment a site runs is safe.
20
- //
21
- // The base contributions (D9, amended 2026-10-01 by D6a/D8a — #7448) use
22
- // existing reads only, each with the caller's cookie forwarded (`ctx.init`):
23
- //
24
- // - Inbox kind `result` — a row of the All tab: the waitlist signups above
25
- // and, where the workspace module is present, the caller's verified
26
- // submissions to `user` magnets (`member.results`, #10826 D7), each with
27
- // an Open action back to its results.
28
- // - For-you sources `email-unverified` and `payment-due` — needs-you items
29
- // with an Open action to User settings' two pages, `/account/general`
30
- // and `/account/billing` (#8232 D10), never Inbox rows. Neither read carries the time the condition began, so their time
31
- // line is the date of the read rather than an invented "Waiting N".
32
- //
33
- // A 404 means "nothing for this caller" — no signup / no user row / commerce
34
- // module off — and loads `[]`; so does a 401/403 while the email is
35
- // unverified (the `email-unverified` item already says so). Any other
36
- // failure rejects — a 401/403 for a verified email included — so the area
37
- // shows an error row with Retry instead of an empty Inbox (D12).
38
- //
39
- // The member reads (#7920, #8231 D5–D7) — the client's own records, through
40
- // one member API with two callers (roadmap D1): a single site's server calls
41
- // its own API with the caller's session cookie, and a spoke that signs its
42
- // clients in through the hub calls the hub with the client's hub credential.
43
- // `ctx.init` already carries the right one (`forwardedCookieInit()`), so no
44
- // kind here tests the topology:
45
- //
46
- // - Inbox kind `purchase` (`GET /v1/member/purchases`) — the Orders tab
47
- // (#11149; the tab keeps the section id `purchases`). Only a purchase
48
- // linked by the verified-email rule shows (roadmap D3).
49
- // - Inbox kind `appointment` (`GET /v1/member/appointments`) — the
50
- // Scheduled tab, upcoming first, each item flagged by the read's own split.
51
- // - Inbox kinds `piece` (`GET /v1/member/pieces`) and `message`
52
- // (`GET /v1/member/messages`) — rows of All. A message with a file has a
53
- // file action to this site's own member file read,
54
- // `account/inbox/message/[id]/file`, which re-serves the bytes — the
55
- // browser holds no hub credential. A message whose `action` is
56
- // `onboarding` (#8515 D6) has an Open onboarding action to this site's
57
- // own `/account/onboarding`.
58
- // - Inbox kind `request` (`GET /v1/member/requests`, #11157) — the member's
59
- // OWN sent quote requests and messages, the inbound rows the two New
60
- // writes put on their Person. With `message` it makes the Messages tab
61
- // (`accountChatKinds`): a request the member just posted is read again
62
- // on the next render, so it appears under Messages and All without a
63
- // reload (the New menu refreshes the route after a post).
64
- // - For-you source `piece-needs-client` — each piece waiting on the client,
65
- // with an Open action to its Inbox row. It shares the pieces read.
66
- // - For-you source `onboarding-steps` (#11150) — the steps a welcomed
67
- // member has left (`GET /v1/member/welcome`): name, the onboarding form,
68
- // email verification and a first booking, each linking to its page and
69
- // none dismissible. The read also writes the first-sign-in marker and
70
- // sends the welcome email the first time, so a member's first `/account`
71
- // render IS the first sign-in, on a spoke and on the hub alike.
72
- //
73
- // A build with no tenancy module registers no member route, so each of these
74
- // 404s and loads `[]`. A site whose workspace does not resolve gets a 503
75
- // from every member read — the error row — until it sets its own
76
- // `AILK_SPOKE_KEY` (#7633).
77
- //
78
- // The New actions (#8233, spec 8233 D1, D2) — the New menu over the Inbox.
79
- // Each is offered while its member read answers, read with `ctx.init` like
80
- // the kinds above, so a scaffold without a module shows no action that 404s
81
- // on click:
82
- //
83
- // - `schedule-service` — while `GET /v1/member/meeting-types` answers
84
- // (registered with `scheduling` on), `{ items: [] }` included. Since
85
- // #11154 the row navigates to `/account/appointments` (the member's
86
- // Appointments page, which lists the offered types and opens each
87
- // type's booking page) rather than opening a popup; an empty offer
88
- // shows that page's empty line.
89
- // - `request-quote` — while `GET /v1/member/request-form` answers a form;
90
- // `{ form: null }` (switched off) leaves it out like a 404.
91
- // - `send-message` — while `GET /v1/member/messages` answers; the `message`
92
- // kind shares that read (`memberMessages`), one call per request. Since
93
- // #11152 the row navigates to `/account/inbox/thread` (the member's
94
- // thread page: every message between them and the workspace, the
95
- // composer at the foot) rather than opening a lightbox.
96
- //
97
- // A Free build registers none of the three, so it shows no New button; a
98
- // failed read rejects, so the Inbox shows its error row. The popups, the
99
- // menu and their server actions are BASE files, never a module slice's:
100
- // gating is the read's job, and a slice owning a popup would pull this file,
101
- // hence the whole /account area, out of every keyless scaffold (#8233 C1 —
102
- // `paid-module-exclusions.test.ts` pins them).
103
- //
104
- // This file carries only each action's server half (`AccountNewRead`: id,
105
- // label, `available`); the popup each one opens is bound in the route,
106
- // `account/new-popups.tsx`, which composes the full `AccountNewAction` list
107
- // the Inbox page consumes. The reason is create-ailk's spoke closure
108
- // (`spokeExclusions`, `packages/create-ailk/src/topology.ts`): a spoke
109
- // without sign-in drops the whole `(authed)` group and every file that
110
- // imports a file in it, and this is a shared lib file every spoke keeps —
111
- // so it may import nothing under `(authed)`, popups included.
112
-
113
- import {
114
- member,
115
- subscription,
116
- waitlistSignups,
117
- type WaitlistSignupMeResponse,
118
- } from "@working-theory/api-client";
119
- import type {
120
- AccountBillingSection,
121
- AccountContext,
122
- AccountForYouSource,
123
- AccountInboxKind,
124
- AccountNewAction,
125
- AccountSettingsSection,
126
- AccountUser,
127
- } from "@working-theory/templates/account";
128
- import { localeHref } from "@working-theory/ui";
129
- import { MessageBubble } from "@working-theory/ui/blocks";
130
- import { Text } from "@working-theory/ui/primitives";
131
- import type {
132
- MemberAppointment,
133
- MemberMessage,
134
- MemberOnboardingStepId,
135
- MemberPiece,
136
- MemberPurchase,
137
- MemberRequest,
138
- MemberResult,
139
- } from "@working-theory/validation";
140
- import { formatMoney, formatNumber } from "@working-theory/web-i18n";
141
- import { cache, createElement } from "react";
142
-
143
- import { unwrapApiResult } from "./server-api";
144
-
145
- export const accountExperimentKeys: string[] = [];
146
-
147
- // ── Reads ─────────────────────────────────────────────────────────────────────
148
-
149
- /** Structural mirror of `@working-theory/api-client`'s `ApiResult<T>` (not re-exported). */
150
- type ApiResult<T> =
151
- { ok: true; body: T } | { ok: false; status: number; body: unknown };
152
-
153
- /**
154
- * The body, or `null` when the status means "nothing for this caller" (see
155
- * the header); any other failure throws `ApiError`.
156
- */
157
- async function read<T>(
158
- result: Promise<ApiResult<T>>,
159
- user: AccountUser,
160
- ): Promise<T | null> {
161
- const res = await result;
162
- if (!res.ok) {
163
- if (res.status === 404) return null;
164
- if (!user.emailVerified && (res.status === 401 || res.status === 403))
165
- return null;
166
- }
167
- return unwrapApiResult(Promise.resolve(res));
168
- }
169
-
170
- function formatWhen(iso: string, locale: string): string {
171
- return new Intl.DateTimeFormat(locale, {
172
- dateStyle: "medium",
173
- timeStyle: "short",
174
- }).format(new Date(iso));
175
- }
176
-
177
- // ── Base Inbox kinds (D9) ─────────────────────────────────────────────────────
178
-
179
- /** A `result` row: a waitlist signup, or a submission to a `user` magnet (#10826 D7). */
180
- type ResultRecord = WaitlistSignupMeResponse | MemberResult;
181
-
182
- const result: AccountInboxKind<ResultRecord> = {
183
- kind: "result",
184
- label: "results.heading",
185
- section: "updates",
186
- async load({ init, user }) {
187
- // One failed key fails the kind (D12) — never a partial list passed off as whole.
188
- // A 404 from the results read (no workspace module) loads none.
189
- const [signups, results] = await Promise.all([
190
- Promise.all(
191
- accountExperimentKeys.map((key) =>
192
- read(waitlistSignups.me(key, init), user),
193
- ),
194
- ),
195
- read(member.results(init), user),
196
- ]);
197
- return [
198
- ...signups
199
- .filter((s): s is WaitlistSignupMeResponse => s !== null)
200
- .map((s) => ({
201
- id: s.experimentKey,
202
- title: s.experimentKey,
203
- at: s.completedAt,
204
- data: s,
205
- })),
206
- ...(results?.items ?? []).map((r) => ({
207
- id: r.id,
208
- title: r.title,
209
- at: r.submittedAt,
210
- data: r,
211
- })),
212
- ];
213
- },
214
- renderDetail({ data }, { locale, t }) {
215
- if ("magnetSlug" in data) {
216
- return {
217
- actions: [
218
- {
219
- key: "open-result",
220
- label: t("results.open"),
221
- variant: "default" as const,
222
- href: localeHref(locale, data.href),
223
- },
224
- ],
225
- fields: {
226
- heading: t("results.heading"),
227
- items: [
228
- { label: t("results.magnet"), value: data.title },
229
- { label: t("results.submittedAt"), value: formatWhen(data.submittedAt, locale) },
230
- ],
231
- },
232
- };
233
- }
234
- return {
235
- fields: {
236
- heading: t("results.heading"),
237
- items: [
238
- { label: t("results.experiment"), value: data.experimentKey },
239
- { label: t("results.waitlist"), value: data.waitlistKey },
240
- {
241
- label: t("results.tier"),
242
- value: data.tier ?? t("results.unavailable"),
243
- },
244
- {
245
- label: t("results.score"),
246
- value:
247
- data.score === null
248
- ? t("results.unavailable")
249
- : formatNumber(data.score, locale),
250
- },
251
- {
252
- label: t("results.completedAt"),
253
- value: formatWhen(data.completedAt, locale),
254
- },
255
- ],
256
- },
257
- };
258
- },
259
- };
260
-
261
- // ── Member Inbox kinds (#7920, #8231) ────────────────────────────────────────
262
-
263
- const purchase: AccountInboxKind<MemberPurchase> = {
264
- kind: "purchase",
265
- label: "purchases.heading",
266
- section: "purchases",
267
- async load({ init, user }) {
268
- const purchases = (await read(member.purchases(init), user))?.items ?? [];
269
- return purchases.map((p) => ({
270
- id: p.id,
271
- title: p.offering,
272
- at: p.purchasedAt,
273
- data: p,
274
- }));
275
- },
276
- renderDetail({ data }, { locale, t }) {
277
- return {
278
- fields: {
279
- heading: t("purchases.heading"),
280
- items: [
281
- { label: t("purchases.offer"), value: data.offering },
282
- {
283
- label: t("purchases.amount"),
284
- value:
285
- data.amountMinor !== null && data.currency !== null
286
- ? formatMoney(data.amountMinor, data.currency, locale)
287
- : t("purchases.unavailable"),
288
- },
289
- { label: t("purchases.period"), value: data.period ?? t("purchases.unavailable") },
290
- { label: t("purchases.date"), value: formatWhen(data.purchasedAt, locale) },
291
- ],
292
- },
293
- };
294
- },
295
- };
296
-
297
- /** One pieces read per request — the `piece` kind and the For-you source share it. */
298
- const memberPieces = cache((init: AccountContext["init"]) => member.pieces(init));
299
-
300
- async function loadPieces(ctx: AccountContext): Promise<MemberPiece[]> {
301
- return (await read(memberPieces(ctx.init), ctx.user))?.items ?? [];
302
- }
303
-
304
- const piece: AccountInboxKind<MemberPiece> = {
305
- kind: "piece",
306
- label: "pieces.heading",
307
- section: "updates",
308
- async load(ctx) {
309
- return (await loadPieces(ctx)).map((p) => ({
310
- id: p.id,
311
- title: p.title,
312
- at: p.updatedAt,
313
- data: p,
314
- }));
315
- },
316
- renderDetail({ data }, { locale, t }) {
317
- return {
318
- status: data.stage,
319
- ...(data.needsClient ? { lead: t("pieces.needsClient") } : {}),
320
- fields: {
321
- heading: t("pieces.heading"),
322
- items: [
323
- { label: t("pieces.stage"), value: data.stage },
324
- { label: t("pieces.createdAt"), value: formatWhen(data.createdAt, locale) },
325
- { label: t("pieces.updatedAt"), value: formatWhen(data.updatedAt, locale) },
326
- ],
327
- },
328
- };
329
- },
330
- };
331
-
332
- /** One messages read per request — the `message` kind and the Send message action share it. */
333
- const memberMessages = cache((init: AccountContext["init"]) => member.messages(init));
334
-
335
- const message: AccountInboxKind<MemberMessage> = {
336
- kind: "message",
337
- label: "messages.heading",
338
- section: "updates",
339
- async load(ctx) {
340
- const messages = (await read(memberMessages(ctx.init), ctx.user))?.items ?? [];
341
- return messages.map((m) => ({
342
- id: m.id,
343
- title: m.subject,
344
- at: m.createdAt,
345
- data: m,
346
- }));
347
- },
348
- renderDetail({ data }, { locale, t }) {
349
- // An onboarding message (#8515 D6) links to this site's own onboarding
350
- // page, before the file action when both apply; the body stays plain text.
351
- const actions = [
352
- ...(data.action === "onboarding"
353
- ? [
354
- {
355
- key: "onboarding",
356
- label: t("messages.openOnboarding"),
357
- variant: "default" as const,
358
- href: localeHref(locale, "/account/onboarding"),
359
- },
360
- ]
361
- : []),
362
- ...(data.file
363
- ? [
364
- {
365
- key: "file",
366
- label: t("messages.download", { filename: data.file.filename }),
367
- variant: "default" as const,
368
- href: localeHref(
369
- locale,
370
- `/account/inbox/message/${encodeURIComponent(data.id)}/file`,
371
- ),
372
- },
373
- ]
374
- : []),
375
- ];
376
- // #11007 — the detail renders through `InboxItemFrame`'s chat layout
377
- // (`accountChatKinds`): the message is a start-side bubble, captioned
378
- // with when it was sent; an attached file is the bubble's note. The
379
- // member feed carries no sender yet, so every message sits on the start
380
- // side (spec admin-frames-and-list-rails, Clarifications).
381
- const caption = `${t("messages.sentAt")} · ${formatWhen(data.createdAt, locale)}`;
382
- const note = data.file ? `${t("messages.file")} · ${data.file.filename}` : undefined;
383
- return {
384
- ...(actions.length > 0 ? { actions } : {}),
385
- body: createElement(MessageBubble, {
386
- side: "start",
387
- caption,
388
- note,
389
- "data-testid": "account-item-message",
390
- children: createElement(Text, { as: "p", className: "whitespace-pre-wrap" }, data.body),
391
- }),
392
- };
393
- },
394
- };
395
-
396
- /**
397
- * #11157 — the member's own sent rows: the inbound `message` and `quote`
398
- * Interactions the New menu's Send message and Request quote wrote on their
399
- * Person, newest first. The row's title is the subject (a quote request's is
400
- * the form's title); the detail is the member's own bubble, on the end side,
401
- * captioned with when it was sent — a quote request, whose body is empty,
402
- * reads the one sent line. The member thread page (#11152,
403
- * `account/inbox/thread`) lists these beside the provider's messages, oldest
404
- * first.
405
- */
406
- const request: AccountInboxKind<MemberRequest> = {
407
- kind: "request",
408
- label: "requests.heading",
409
- section: "updates",
410
- async load({ init, user }) {
411
- const rows = (await read(member.requests(init), user))?.items ?? [];
412
- return rows.map((r) => ({
413
- id: r.id,
414
- title: r.subject,
415
- at: r.createdAt,
416
- data: r,
417
- }));
418
- },
419
- renderDetail({ data }, { locale, t }) {
420
- const caption = `${t("requests.sentAt")} · ${formatWhen(data.createdAt, locale)}`;
421
- return {
422
- body: createElement(MessageBubble, {
423
- side: "end",
424
- caption,
425
- "data-testid": "account-item-request",
426
- children: createElement(
427
- Text,
428
- { as: "p", className: "whitespace-pre-wrap" },
429
- data.body === "" ? t("requests.quoteSent") : data.body,
430
- ),
431
- }),
432
- };
433
- },
434
- };
435
-
436
- /**
437
- * #11007 — the kinds whose detail is a conversation, rendered through
438
- * `InboxItemFrame`'s `layout="chat"`; every other kind keeps the stacked
439
- * head and fields. #11157 — the same kinds are the Inbox's Messages tab: the
440
- * provider's messages and the member's own sent requests and messages.
441
- */
442
- export const accountChatKinds: ReadonlySet<string> = new Set([message.kind, request.kind]);
443
-
444
- /** Each appointment status's message key — a new status is a type error, never a raw key. */
445
- const APPOINTMENT_STATUS_KEY = {
446
- pending: "appointments.statuses.pending",
447
- confirmed: "appointments.statuses.confirmed",
448
- cancelled: "appointments.statuses.cancelled",
449
- } satisfies Record<MemberAppointment["status"], string>;
450
-
451
- const appointment: AccountInboxKind<MemberAppointment> = {
452
- kind: "appointment",
453
- label: "appointments.heading",
454
- section: "upcoming",
455
- async load({ init, t, user }) {
456
- const appointments = await read(member.appointments(init), user);
457
- if (appointments === null) return [];
458
- // The read's own split decides upcoming — a meeting in progress is upcoming.
459
- const toItem = (a: MemberAppointment, upcoming: boolean) => ({
460
- id: a.id,
461
- title: a.title ?? t("appointments.untitled"),
462
- at: a.startTime,
463
- upcoming,
464
- data: a,
465
- });
466
- return [
467
- ...appointments.upcoming.map((a) => toItem(a, true)),
468
- ...appointments.past.map((a) => toItem(a, false)),
469
- ];
470
- },
471
- renderDetail({ data }, { locale, t }) {
472
- return {
473
- status: t(APPOINTMENT_STATUS_KEY[data.status]),
474
- fields: {
475
- heading: t("appointments.heading"),
476
- items: [
477
- { label: t("appointments.starts"), value: formatWhen(data.startTime, locale) },
478
- { label: t("appointments.ends"), value: formatWhen(data.endTime, locale) },
479
- ],
480
- },
481
- };
482
- },
483
- };
484
-
485
- // ── Base For-you sources (D9 as amended, D8a) ────────────────────────────────
486
-
487
- const emailUnverified: AccountForYouSource = {
488
- id: "email-unverified",
489
- async load({ locale, user, t }) {
490
- if (user.emailVerified) return [];
491
- return [
492
- {
493
- id: "email-unverified",
494
- type: { id: "email", label: t("profile.email"), tone: "needs-you" },
495
- title: t("profile.unverified"),
496
- time: { kind: "at", at: new Date().toISOString() },
497
- action: { kind: "open", href: localeHref(locale, "/account/general") },
498
- dismissible: true,
499
- },
500
- ];
501
- },
502
- };
503
-
504
- const paymentDue: AccountForYouSource = {
505
- id: "payment-due",
506
- async load({ init, locale, t, user }) {
507
- const sub = await read(subscription.me(init), user);
508
- // The API's own `actionRequired` decides — the status is never re-derived.
509
- if (!sub?.actionRequired) return [];
510
- return [
511
- {
512
- id: "payment-due",
513
- type: { id: "payment", label: t("subscription.action"), tone: "needs-you" },
514
- title: t("subscription.headline"),
515
- time: { kind: "at", at: new Date().toISOString() },
516
- action: { kind: "open", href: localeHref(locale, "/account/billing") },
517
- dismissible: true,
518
- },
519
- ];
520
- },
521
- };
522
-
523
- // ── Member For-you source (#7920) ────────────────────────────────────────────
524
-
525
- const pieceNeedsClient: AccountForYouSource = {
526
- id: "piece-needs-client",
527
- async load(ctx) {
528
- const { locale, t } = ctx;
529
- return (await loadPieces(ctx))
530
- .filter((p) => p.needsClient)
531
- .map((p) => ({
532
- id: `piece:${p.id}`,
533
- type: { id: "piece", label: t("pieces.type"), tone: "needs-you" },
534
- title: p.title,
535
- // The read carries no time the piece began waiting — its last update.
536
- time: { kind: "at", at: p.updatedAt },
537
- action: {
538
- kind: "open",
539
- href: localeHref(locale, `/account/inbox/piece/${encodeURIComponent(p.id)}`),
540
- },
541
- dismissible: true,
542
- }));
543
- },
544
- };
545
-
546
- // ── Onboarding-steps For-you source (#11150) ─────────────────────────────────
547
-
548
- /** Each step's page — where the member does it (AC-3). */
549
- const ONBOARDING_STEP_HREF = {
550
- name: "/account/general",
551
- onboarding: "/account/onboarding",
552
- email: "/account/general",
553
- booking: "/account/appointments",
554
- } satisfies Record<MemberOnboardingStepId, string>;
555
-
556
- /** Each step's title key. The name step is the area's own "Add your name" (`account-data.ts`), which yields to it. */
557
- const ONBOARDING_STEP_TITLE = {
558
- name: "forYou.addName",
559
- onboarding: "forYou.onboarding.onboarding",
560
- email: "forYou.onboarding.email",
561
- booking: "forYou.onboarding.booking",
562
- } satisfies Record<MemberOnboardingStepId, string>;
563
-
564
- /**
565
- * The steps a welcomed member has left (#11150 AC-3). One read,
566
- * `GET /v1/member/welcome`, which the API also uses to write the
567
- * first-sign-in marker (and send the welcome email) the first time this
568
- * caller reads it on this workspace — so the source IS the first sign-in's
569
- * trigger, on a spoke through the hub or on the hub itself alike, through
570
- * `ctx.init`. Each step is read from server state, links to its page and
571
- * cannot be dismissed; a done step disappears, and with every step done the
572
- * source is empty, so the panel's empty-hides rule is unchanged. No marker
573
- * (no Person could be made for the caller) is no steps. The area's own
574
- * "Add your name" item yields to the `name` step when both would show
575
- * (`account-data.ts`), so one fact has one row; the `email-unverified`
576
- * source never meets the `email` step, because this read answers a verified
577
- * caller only.
578
- */
579
- const onboardingSteps: AccountForYouSource = {
580
- id: "onboarding-steps",
581
- async load({ init, locale, t, user }) {
582
- const welcome = await read(member.welcome(init), user);
583
- if (welcome === null || welcome.welcomedAt === null) return [];
584
- const at = welcome.welcomedAt;
585
- return welcome.steps
586
- .filter((step) => !step.done)
587
- .map((step) => ({
588
- id: `onboarding:${step.id}`,
589
- type: { id: "onboarding", label: t("forYou.types.onboarding"), tone: "neutral" as const },
590
- title: t(ONBOARDING_STEP_TITLE[step.id]),
591
- time: { kind: "at" as const, at },
592
- action: {
593
- kind: "open" as const,
594
- href: localeHref(locale, ONBOARDING_STEP_HREF[step.id]),
595
- },
596
- dismissible: false,
597
- }));
598
- },
599
- };
600
-
601
- // ── New actions (#8233) ──────────────────────────────────────────────────────
602
-
603
- /**
604
- * A New action's server half — everything but the popup it opens, which
605
- * `account/new-popups.tsx` binds (see the header: this file imports nothing
606
- * under `(authed)`).
607
- */
608
- export type AccountNewRead = Omit<AccountNewAction, "renderPopup">;
609
-
610
- const scheduleService = {
611
- id: "schedule-service",
612
- label: "new.actions.scheduleService",
613
- // #11154 — a link row: the page localizes the path, and no popup binds to it.
614
- href: "/account/appointments",
615
- async available({ init, user }) {
616
- return (await read(member.meetingTypes(init), user)) !== null;
617
- },
618
- } as const satisfies AccountNewRead;
619
-
620
- const requestQuote = {
621
- id: "request-quote",
622
- label: "new.actions.requestQuote",
623
- async available({ init, user }) {
624
- // `form: null` is Request quote switched off — a state, never a 404.
625
- return ((await read(member.requestForm(init), user))?.form ?? null) !== null;
626
- },
627
- } as const satisfies AccountNewRead;
628
-
629
- const sendMessage = {
630
- id: "send-message",
631
- label: "new.actions.sendMessage",
632
- // #11152 — a link row: the member thread page, where the composer posts.
633
- href: "/account/inbox/thread",
634
- async available({ init, user }) {
635
- return (await read(memberMessages(init), user)) !== null;
636
- },
637
- } as const satisfies AccountNewRead;
638
-
639
- // ── Contributions ─────────────────────────────────────────────────────────────
640
-
641
- /** Inbox item kinds, in load order. A module appends its own. */
642
- export const accountInboxKinds: AccountInboxKind[] = [
643
- result,
644
- purchase,
645
- piece,
646
- message,
647
- request,
648
- appointment,
649
- ];
650
-
651
- /** User-settings sections a module adds after the base ones. None in the base area. */
652
- export const accountSettingsSections: AccountSettingsSection[] = [];
653
-
654
- /**
655
- * New-menu actions' server halves, in menu order (#8233 D2). A module appends
656
- * its own read here and binds its popup in `account/new-popups.tsx`, keyed on
657
- * the id — `AccountNewActionId` makes a read with no popup a type error. A
658
- * read carrying `href` is a link row (#11154) and binds no popup.
659
- */
660
- export const accountNewActions = [
661
- scheduleService,
662
- requestQuote,
663
- sendMessage,
664
- ] as const satisfies readonly AccountNewRead[];
665
-
666
- /** The ids `accountNewActions` carries — the keys `new-popups.tsx` must bind. */
667
- export type AccountNewActionId = (typeof accountNewActions)[number]["id"];
668
-
669
- /** Billing-page sections a module adds after the base ones. `member-settings` (#8232) renders it. */
670
- export const accountBillingSections: AccountBillingSection[] = [];
671
-
672
- /** For-you sources, in load order. A module appends its own. */
673
- export const accountForYouSources: AccountForYouSource[] = [
674
- emailUnverified,
675
- paymentDue,
676
- pieceNeedsClient,
677
- onboardingSteps,
678
- ];