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,218 +0,0 @@
1
- /**
2
- * /[locale]/account/general — User settings › General (#8339 D8; builds on
3
- * #8232 D2).
4
- *
5
- * RSC, outside the account layout's SignedInShell (#8430), in the member's
6
- * settings frame (D7; five tabs since #8438 D14) — standalone, the Admin's
7
- * shape. Renders the shared
8
- * `AccountSettings` composition (@working-theory/templates/account, spec
9
- * 8339 D4) — the same General form the Admin renders — through the client
10
- * adapter `GeneralSettings` (`profile-form.tsx`). Below the form, each a
11
- * card of the pane (#11167 — the pane draws every direct child as one):
12
- *
13
- * - the contact details (`ContactDetails` over `AccountContactDetails`,
14
- * #8435 D13) — only on the member path, seeded from `member.contact` and
15
- * saved by `saveContact`, which also derives the account name from the
16
- * first and last names (#11167 ruling 5 — the member General renders no
17
- * Name field);
18
- * - the phone step (`PhoneVerification`, #11106 D9) — on a hub only: the
19
- * person sets and verifies their own number, read from their Better Auth
20
- * session; a build without the phone plugin shows the not-available line;
21
- * - any section a module contributes (`accountSettingsSections`);
22
- * - `BillingAnchor`, which forwards a `#billing` fragment to Billing — it
23
- * renders nothing, so it sits beside the composition, not in a card.
24
- *
25
- * Color mode renders on every site (#11167 ruling 3, as on the Admin); the
26
- * one-palette gate of #7430 is gone. The Photo and the person's name come
27
- * from `loadProfileSource` (D3) — on the member path the photo is the hub's
28
- * (#11167 ruling 4).
29
- *
30
- * Sign-in moved to Security, cookie settings moved to Notifications then to
31
- * Privacy (#8339 C6), and Request account deletion moved to Privacy (#8438
32
- * D16) — General no longer renders any of the three.
33
- *
34
- * Whether the profile and deletion go through the member API is
35
- * `loadProfileSource` (D3), never a topology test here.
36
- */
37
-
38
- import { member } from "@working-theory/api-client";
39
- import {
40
- AccountSettingsFrame,
41
- AccountSettingsPane,
42
- type AccountContact,
43
- } from "@working-theory/templates/account";
44
- import { Text } from "@working-theory/ui/primitives";
45
- import type { Metadata } from "next";
46
- import { headers } from "next/headers";
47
- import { getTranslations } from "next-intl/server";
48
- import type { ReactElement } from "react";
49
-
50
- import { accountSettingsSections } from "../../../../../lib/account-config";
51
- import { readPhoneStep, TOPOLOGY } from "../../../../../lib/topology.generated";
52
- import { accountSession } from "../account-data";
53
- import { memberSettingsFrame, SettingsSection, type Translate } from "../settings-frame";
54
-
55
- import { BillingAnchor } from "./billing-anchor";
56
- import { ContactDetails } from "./contact-details";
57
- import { PhoneVerification, type PhoneVerificationLabels } from "./phone-verification";
58
- import { GeneralSettings } from "./profile-form";
59
- import { loadProfileSource } from "./profile-source";
60
-
61
- interface Props {
62
- params: Promise<{ locale: string }>;
63
- }
64
-
65
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
66
- const { locale } = await params;
67
- const t = await getTranslations({ locale, namespace: "account" });
68
- return { title: t("settings.general.title"), description: t("settings.general.lead") };
69
- }
70
-
71
- export default async function AccountGeneralPage({ params }: Props): Promise<ReactElement> {
72
- const { locale } = await params;
73
- const t = await getTranslations({ locale, namespace: "account" });
74
- const session = await accountSession(locale);
75
-
76
- // Unreachable behind the (authed) gate; a session that expired between
77
- // the layout and the page renders the pane's title alone.
78
- if (!session) {
79
- return (
80
- <AccountSettingsFrame {...memberSettingsFrame(locale, t as unknown as Translate, "general")} name="">
81
- <AccountSettingsPane
82
- id="account-settings-general"
83
- title={t("settings.general.title")}
84
- lead={t("settings.general.lead")}
85
- >
86
- {null}
87
- </AccountSettingsPane>
88
- </AccountSettingsFrame>
89
- );
90
- }
91
-
92
- const { ctx } = session;
93
- const source = await loadProfileSource(ctx);
94
- // The phone step reads through the generated seam (#11138); a spoke's hub
95
- // holds the person, so a spoke has none.
96
- const phoneStep = TOPOLOGY === "spoke" ? null : await readPhoneStep(await headers());
97
- const phoneLabels: PhoneVerificationLabels = {
98
- title: t("profile.phoneTitle"),
99
- lead: t("profile.phoneLead"),
100
- number: t("profile.phoneNumber"),
101
- numberHint: t("profile.phoneNumberHint"),
102
- sendCode: t("profile.phoneSendCode"),
103
- sending: t("profile.phoneSending"),
104
- code: t("profile.phoneCode"),
105
- codeHint: t("profile.phoneCodeHint"),
106
- verify: t("profile.phoneVerify"),
107
- verifying: t("profile.phoneVerifying"),
108
- verified: t("profile.phoneVerified"),
109
- remove: t("profile.phoneRemove"),
110
- sent: t("profile.phoneSent"),
111
- unavailable: t("profile.phoneUnavailable"),
112
- unverifiedEmail: t("profile.phoneUnverifiedEmail"),
113
- errors: {
114
- invalid_number: t("profile.phoneErrors.invalid_number"),
115
- invalid_code: t("profile.phoneErrors.invalid_code"),
116
- taken: t("profile.phoneErrors.taken"),
117
- too_many: t("profile.phoneErrors.too_many"),
118
- unverified: t("profile.phoneErrors.unverified"),
119
- signed_out: t("profile.phoneErrors.signed_out"),
120
- unavailable: t("profile.phoneErrors.unavailable"),
121
- failed: t("profile.phoneErrors.failed"),
122
- },
123
- };
124
-
125
- // #8435 D13 — the person's confirmed contact on this site. A failed read
126
- // renders the section's "unavailable" line, never the form: a form seeded
127
- // from nothing would offer to replace details it never showed.
128
- let contactRead: { ok: true; contact: AccountContact | null } | { ok: false } | null = null;
129
- if (source.via === "member") {
130
- try {
131
- const res = await member.contact(ctx.init);
132
- contactRead = res.ok ? { ok: true, contact: res.body.contact } : { ok: false };
133
- } catch {
134
- contactRead = { ok: false };
135
- }
136
- }
137
-
138
- return (
139
- <>
140
- <GeneralSettings
141
- frame={memberSettingsFrame(locale, t as unknown as Translate, "general")}
142
- user={{ name: ctx.user.name ?? "", email: ctx.user.email, image: source.image }}
143
- labels={{
144
- title: t("settings.general.title"),
145
- lead: t("settings.general.lead"),
146
- colorMode: t("settings.general.colorMode"),
147
- light: t("settings.general.light"),
148
- auto: t("settings.general.auto"),
149
- dark: t("settings.general.dark"),
150
- emailLabel: t("settings.general.email"),
151
- nameLabel: t("settings.general.name"),
152
- photoLabel: t("settings.general.photo"),
153
- photoPlaceholder: t("settings.general.photoPlaceholder"),
154
- saveButton: t("settings.general.save"),
155
- saving: t("settings.general.saving"),
156
- saved: t("settings.general.saved"),
157
- saveError: t("settings.general.saveError"),
158
- nameRequired: t("settings.general.nameRequired"),
159
- photoInvalid: t("settings.general.photoInvalid"),
160
- unverified: t("settings.general.unverified"),
161
- unavailable: t("settings.general.unavailable"),
162
- }}
163
- colorMode={{ cookieName: process.env.NEXT_PUBLIC_THEME_COOKIE_NAME ?? "ailk-theme" }}
164
- via={source.via}
165
- >
166
- {contactRead ? (
167
- <div data-testid="account-contact-section">
168
- {contactRead.ok ? (
169
- <ContactDetails
170
- contact={contactRead.contact}
171
- labels={{
172
- title: t("settings.general.contact.title"),
173
- givenName: t("settings.general.contact.givenName"),
174
- familyName: t("settings.general.contact.familyName"),
175
- telephone: t("settings.general.contact.telephone"),
176
- address: t("settings.general.contact.address"),
177
- companyName: t("settings.general.contact.companyName"),
178
- jobTitle: t("settings.general.contact.jobTitle"),
179
- save: t("settings.general.contact.save"),
180
- saving: t("settings.general.contact.saving"),
181
- saved: t("settings.general.contact.saved"),
182
- addressIncomplete: t("settings.general.contact.addressIncomplete"),
183
- errors: {
184
- telephone: t("settings.general.contact.errors.telephone"),
185
- invalid: t("settings.general.contact.errors.invalid"),
186
- unverified: t("settings.general.contact.errors.unverified"),
187
- unavailable: t("settings.general.contact.errors.unavailable"),
188
- failed: t("settings.general.contact.errors.failed"),
189
- },
190
- }}
191
- />
192
- ) : (
193
- <span data-testid="account-contact-unavailable">
194
- <Text as="p" variant="body-sm" tone="muted">
195
- {t("settings.general.contact.unavailable")}
196
- </Text>
197
- </span>
198
- )}
199
- </div>
200
- ) : null}
201
- {phoneStep ? (
202
- <PhoneVerification
203
- available={phoneStep.available}
204
- emailVerified={ctx.user.emailVerified}
205
- phone={phoneStep.phone}
206
- labels={phoneLabels}
207
- />
208
- ) : null}
209
- {accountSettingsSections.map((section) => (
210
- <SettingsSection key={section.id} id={section.id} title={ctx.t(section.title)}>
211
- {section.render(ctx)}
212
- </SettingsSection>
213
- ))}
214
- </GeneralSettings>
215
- <BillingAnchor locale={locale} />
216
- </>
217
- );
218
- }
@@ -1,122 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * general/phone-actions.ts — User settings › General's phone step (#11106,
5
- * spec docs/specs/11106-the-workforce-foundation-roles-by-spec.md D9).
6
- *
7
- * Three server actions over Better Auth's phone plugin, each a SERVER call
8
- * with the request's own headers, so the plugin and its guard (`auth.ts`'s
9
- * `phoneVerificationGuard`) see the person's session:
10
- *
11
- * - `sendPhoneCode` → `auth.api.sendPhoneNumberOTP` — texts a six-digit
12
- * code through the apps/api relay;
13
- * - `verifyPhoneCode` → `auth.api.verifyPhoneNumber({ updatePhoneNumber:
14
- * true })` — the one writer of `phoneNumber` and `phoneNumberVerified`;
15
- * - `removePhone` → `auth.api.updateUser({ phoneNumber: null })`, which
16
- * the plugin turns into `phoneNumberVerified: false`.
17
- *
18
- * Each reaches the plugin through the generated seam's `loadPhoneApi`
19
- * (`lib/topology.generated.ts`, #11138), never `auth.ts` directly, so a spoke
20
- * that signs in through its hub keeps this file: there the seam answers null
21
- * and every action answers `unavailable`.
22
- *
23
- * They take no identity argument: who comes from the session alone. Each
24
- * answers `{ ok: true }` or a refusal `reason` the island maps to its own
25
- * line. No log line, and no answer, carries the number or the code: a log
26
- * line names the action and the plugin's error code only.
27
- *
28
- * Not a `*.actions.ts` file and no `*Action`-suffixed export: the phone step
29
- * is a person's own act on the hub, with no MCP twin (apps/mcp's parity test
30
- * reads that suffix).
31
- */
32
-
33
- import { headers } from "next/headers";
34
-
35
- import { loadPhoneApi } from "../../../../../lib/topology.generated";
36
-
37
- export type PhoneActionResult =
38
- | { ok: true }
39
- | {
40
- ok: false;
41
- reason:
42
- | "invalid_number"
43
- | "invalid_code"
44
- | "taken"
45
- | "too_many"
46
- | "unverified"
47
- | "signed_out"
48
- | "unavailable"
49
- | "failed";
50
- };
51
-
52
- /** The plugin's error code of a thrown `APIError`, when it has one. */
53
- function errorCode(err: unknown): string | null {
54
- const code = (err as { body?: { code?: unknown } } | null)?.body?.code;
55
- return typeof code === "string" ? code : null;
56
- }
57
-
58
- const REASONS: Record<string, Exclude<PhoneActionResult, { ok: true }>["reason"]> = {
59
- INVALID_PHONE_NUMBER: "invalid_number",
60
- INVALID_OTP: "invalid_code",
61
- OTP_EXPIRED: "invalid_code",
62
- OTP_NOT_FOUND: "invalid_code",
63
- TOO_MANY_ATTEMPTS: "too_many",
64
- PHONE_NUMBER_EXIST: "taken",
65
- EMAIL_NOT_VERIFIED: "unverified",
66
- SESSION_REQUIRED: "signed_out",
67
- };
68
-
69
- function refused(action: string, err: unknown): PhoneActionResult {
70
- const code = errorCode(err);
71
- console.error(`[phone-actions] ${action} refused code=${code ?? "none"}`);
72
- return { ok: false, reason: (code && REASONS[code]) || "failed" };
73
- }
74
-
75
- const isText = (value: unknown, max: number): value is string =>
76
- typeof value === "string" && value.length > 0 && value.length <= max;
77
-
78
- export async function sendPhoneCode(phoneNumber: unknown): Promise<PhoneActionResult> {
79
- // Action input is untrusted: the plugin's validator is the real check.
80
- if (!isText(phoneNumber, 16)) return { ok: false, reason: "invalid_number" };
81
- // The generated seam: null on a spoke or a build without the step.
82
- const api = await loadPhoneApi();
83
- if (!api) return { ok: false, reason: "unavailable" };
84
- try {
85
- await api.sendPhoneNumberOTP({ body: { phoneNumber }, headers: await headers() });
86
- return { ok: true };
87
- } catch (err) {
88
- return refused("sendPhoneCode", err);
89
- }
90
- }
91
-
92
- export async function verifyPhoneCode(
93
- phoneNumber: unknown,
94
- code: unknown,
95
- ): Promise<PhoneActionResult> {
96
- if (!isText(phoneNumber, 16)) return { ok: false, reason: "invalid_number" };
97
- if (!isText(code, 6)) return { ok: false, reason: "invalid_code" };
98
- const api = await loadPhoneApi();
99
- if (!api) return { ok: false, reason: "unavailable" };
100
- try {
101
- await api.verifyPhoneNumber({
102
- body: { phoneNumber, code, updatePhoneNumber: true },
103
- headers: await headers(),
104
- });
105
- return { ok: true };
106
- } catch (err) {
107
- return refused("verifyPhoneCode", err);
108
- }
109
- }
110
-
111
- export async function removePhone(): Promise<PhoneActionResult> {
112
- const api = await loadPhoneApi();
113
- if (!api) return { ok: false, reason: "unavailable" };
114
- try {
115
- // The plugin's own clearing write (`phoneNumber: null` also sets
116
- // `phoneNumberVerified: false`).
117
- await api.updateUser({ body: { phoneNumber: null }, headers: await headers() });
118
- return { ok: true };
119
- } catch (err) {
120
- return refused("removePhone", err);
121
- }
122
- }
@@ -1,215 +0,0 @@
1
- "use client"; // owns the number and code fields and the three action calls
2
-
3
- /**
4
- * PhoneVerification — User settings › General's phone step (#11106, spec
5
- * docs/specs/11106-the-workforce-foundation-roles-by-spec.md D9).
6
- *
7
- * The one place a person sets their own phone. Two states:
8
- *
9
- * - no verified number: the number field and Send code; once a code is
10
- * sent, the code field and Verify (`verifyPhoneCode`, which writes the
11
- * number only after the code matches);
12
- * - a verified number: the number with "Verified" and Remove.
13
- *
14
- * `available: false` (a build without the step) renders the not-available
15
- * line, and an unverified email renders the confirm-email line, with no
16
- * form. Every string arrives as a prop from the page's `account.profile.*`
17
- * messages; the number and the code never leave this island except to the
18
- * server actions, which log neither.
19
- */
20
-
21
- import {
22
- Badge,
23
- Button,
24
- Field,
25
- Heading,
26
- InlineMessage,
27
- Input,
28
- Text,
29
- } from "@working-theory/ui/primitives";
30
- import { useRouter } from "next/navigation";
31
- import { useState, useTransition, type FormEvent, type ReactElement } from "react";
32
-
33
- import {
34
- removePhone,
35
- sendPhoneCode,
36
- verifyPhoneCode,
37
- type PhoneActionResult,
38
- } from "./phone-actions";
39
-
40
- export interface PhoneVerificationLabels {
41
- title: string;
42
- lead: string;
43
- number: string;
44
- numberHint: string;
45
- sendCode: string;
46
- sending: string;
47
- code: string;
48
- codeHint: string;
49
- verify: string;
50
- verifying: string;
51
- verified: string;
52
- remove: string;
53
- sent: string;
54
- unavailable: string;
55
- unverifiedEmail: string;
56
- errors: Record<Exclude<PhoneActionResult, { ok: true }>["reason"], string>;
57
- }
58
-
59
- export function PhoneVerification({
60
- available,
61
- emailVerified,
62
- phone,
63
- labels,
64
- }: {
65
- available: boolean;
66
- emailVerified: boolean;
67
- phone: { number: string; verified: boolean } | null;
68
- labels: PhoneVerificationLabels;
69
- }): ReactElement {
70
- const router = useRouter();
71
- const [number, setNumber] = useState("");
72
- const [code, setCode] = useState("");
73
- const [codeSent, setCodeSent] = useState(false);
74
- const [error, setError] = useState<string | null>(null);
75
- const [pending, startTransition] = useTransition();
76
-
77
- const run = (action: () => Promise<PhoneActionResult>, onOk: () => void) => {
78
- setError(null);
79
- startTransition(async () => {
80
- const result = await action();
81
- if (result.ok) onOk();
82
- else setError(labels.errors[result.reason]);
83
- });
84
- };
85
-
86
- const onSend = (event: FormEvent<HTMLFormElement>) => {
87
- event.preventDefault();
88
- run(
89
- () => sendPhoneCode(number.trim()),
90
- () => setCodeSent(true),
91
- );
92
- };
93
-
94
- const onVerify = (event: FormEvent<HTMLFormElement>) => {
95
- event.preventDefault();
96
- run(
97
- () => verifyPhoneCode(number.trim(), code.trim()),
98
- () => {
99
- setCode("");
100
- setCodeSent(false);
101
- router.refresh();
102
- },
103
- );
104
- };
105
-
106
- const onRemove = () => run(removePhone, () => router.refresh());
107
-
108
- let body: ReactElement;
109
- if (!available) {
110
- body = (
111
- <Text as="p" variant="body-sm" tone="muted" data-testid="account-phone-unavailable">
112
- {labels.unavailable}
113
- </Text>
114
- );
115
- } else if (phone?.verified) {
116
- body = (
117
- <div className="flex flex-wrap items-center gap-3" data-testid="account-phone-verified">
118
- <Text as="span" variant="body" data-testid="account-phone-number">
119
- {phone.number}
120
- </Text>
121
- <Badge data-testid="account-phone-verified-badge">{labels.verified}</Badge>
122
- <Button
123
- type="button"
124
- variant="ghost"
125
- size="big"
126
- disabled={pending}
127
- onClick={onRemove}
128
- data-testid="account-phone-remove"
129
- >
130
- {labels.remove}
131
- </Button>
132
- </div>
133
- );
134
- } else if (!emailVerified) {
135
- body = (
136
- <Text as="p" variant="body-sm" tone="muted" data-testid="account-phone-unverified-email">
137
- {labels.unverifiedEmail}
138
- </Text>
139
- );
140
- } else {
141
- body = (
142
- <div className="flex flex-col gap-4">
143
- <form onSubmit={onSend} className="flex flex-col gap-3" data-testid="account-phone-send-form">
144
- <Field label={labels.number} htmlFor="account-phone-number-input" helperText={labels.numberHint}>
145
- <Input
146
- type="tel"
147
- size="big"
148
- inputMode="tel"
149
- autoComplete="tel"
150
- value={number}
151
- onChange={(e) => setNumber(e.target.value)}
152
- required
153
- data-testid="account-phone-number-input"
154
- />
155
- </Field>
156
- <Button
157
- type="submit"
158
- variant="secondary"
159
- size="big"
160
- disabled={pending || number.trim() === ""}
161
- data-testid="account-phone-send"
162
- >
163
- {pending && !codeSent ? labels.sending : labels.sendCode}
164
- </Button>
165
- </form>
166
- {codeSent ? (
167
- <form onSubmit={onVerify} className="flex flex-col gap-3" data-testid="account-phone-verify-form">
168
- <InlineMessage variant="success" role="status" data-testid="account-phone-sent">
169
- {labels.sent}
170
- </InlineMessage>
171
- <Field label={labels.code} htmlFor="account-phone-code-input" helperText={labels.codeHint}>
172
- <Input
173
- type="text"
174
- size="big"
175
- inputMode="numeric"
176
- autoComplete="one-time-code"
177
- maxLength={6}
178
- value={code}
179
- onChange={(e) => setCode(e.target.value)}
180
- required
181
- data-testid="account-phone-code-input"
182
- />
183
- </Field>
184
- <Button
185
- type="submit"
186
- size="big"
187
- disabled={pending || code.trim() === ""}
188
- data-testid="account-phone-verify"
189
- >
190
- {pending ? labels.verifying : labels.verify}
191
- </Button>
192
- </form>
193
- ) : null}
194
- </div>
195
- );
196
- }
197
-
198
- return (
199
- <section className="flex flex-col gap-3" data-testid="account-phone-section" aria-labelledby="account-phone-title">
200
- {/* A level-2 heading: one group of the pane, beside Contact details (#11167 ruling 11). */}
201
- <Heading level={2} visual={4} id="account-phone-title">
202
- {labels.title}
203
- </Heading>
204
- <Text as="p" variant="body-sm" tone="muted">
205
- {labels.lead}
206
- </Text>
207
- {body}
208
- {error ? (
209
- <InlineMessage variant="error" role="alert" data-testid="account-phone-error">
210
- {error}
211
- </InlineMessage>
212
- ) : null}
213
- </section>
214
- );
215
- }
@@ -1,73 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * general/photo-actions.ts — User settings › General's photo write on the
5
- * member path (#11167 ruling 5).
6
- *
7
- * The member General renders no Name field: the account name follows the
8
- * contact's first and last names (`contact-actions.ts`), so the profile form
9
- * saves the photo alone — `member.updateProfile({ image })`, `PATCH
10
- * /v1/member/profile` with no `name` key, so a person who has not set a name
11
- * yet can still set their photo. `null` (or a blank link) clears it. The
12
- * session is not re-sealed: a hub session carries no photo (`profile-source.ts`
13
- * reads it from the member API instead).
14
- *
15
- * It sends `forwardedCookieInit()`'s init, as `profile-actions.ts`'s
16
- * `saveProfile` does, and maps the same refusals: `photo` (`400
17
- * link_not_https`), `unverified` (`403`), `unavailable` (`404`, `503`), else
18
- * `failed`. Logs carry a status or `err.name` only — never a link.
19
- *
20
- * Not a `*.actions.ts` file and no `*Action`-suffixed export: the write has no
21
- * MCP twin by decision (8170's header), and apps/mcp's parity test reads that
22
- * suffix.
23
- */
24
-
25
- import { member } from "@working-theory/api-client";
26
-
27
- import { forwardedCookieInit } from "../../../../../lib/server-api";
28
-
29
- /** PII-safe error identity for logs (the `profile-actions.ts` idiom: `err.name` only). */
30
- function errorName(err: unknown): string {
31
- return err instanceof Error ? err.name : "unknown";
32
- }
33
-
34
- /** The `error.code` of a member write's refusal body, when it has one. */
35
- function errorCode(body: unknown): string | null {
36
- if (typeof body !== "object" || body === null) return null;
37
- const error = (body as { error?: unknown }).error;
38
- if (typeof error !== "object" || error === null) return null;
39
- const code = (error as { code?: unknown }).code;
40
- return typeof code === "string" ? code : null;
41
- }
42
-
43
- export type SavePhotoResult =
44
- | { ok: true; image: string | null }
45
- | { ok: false; reason: "photo" | "unverified" | "unavailable" | "failed" };
46
-
47
- /** Saves the member's photo alone: `null` or a blank link clears it. */
48
- export async function savePhoto(
49
- image: string | null,
50
- ): Promise<SavePhotoResult> {
51
- // Action input is untrusted: anything but a string or null is refused,
52
- // never read as "clear the photo".
53
- if (image !== null && typeof image !== "string")
54
- return { ok: false, reason: "photo" };
55
- try {
56
- const res = await member.updateProfile(
57
- { image: image?.trim() || null },
58
- await forwardedCookieInit(),
59
- );
60
- if (res.ok) return { ok: true, image: res.body.image };
61
- console.error(`[photo-actions] savePhoto status=${res.status}`);
62
- if (res.status === 400 && errorCode(res.body) === "link_not_https") {
63
- return { ok: false, reason: "photo" };
64
- }
65
- if (res.status === 403) return { ok: false, reason: "unverified" };
66
- if (res.status === 404 || res.status === 503)
67
- return { ok: false, reason: "unavailable" };
68
- return { ok: false, reason: "failed" };
69
- } catch (err) {
70
- console.error(`[photo-actions] savePhoto errName=${errorName(err)}`);
71
- return { ok: false, reason: "failed" };
72
- }
73
- }