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,306 +0,0 @@
1
- /**
2
- * /[locale]/account — the base account area's Inbox (#7430, spec 7423 U4 ·
3
- * D6a, D9, D12; #8231 D3; DESIGN.md §5.4).
4
- *
5
- * RSC, rendered inside the account layout's SignedInShell. One filtered
6
- * list: the tabs All · Messages · Orders · Scheduled (#11149, operator
7
- * rulings 2026-11-08), each with a count, All selected, through the shared
8
- * `InboxList` (`@working-theory/templates/account`). `?tab=<id>` opens
9
- * another tab; any other value, the frame's own `?tab=for-you` included,
10
- * opens All:
11
- *
12
- * - All — every loaded row, newest first: the union of the other tabs,
13
- * each row once, plus the kinds in `updates` or `needs-you` (`result`,
14
- * `piece`), which show here only.
15
- * - Messages (#11157) — the conversation kinds (`accountChatKinds`): the
16
- * provider's messages and the member's own sent requests and messages,
17
- * newest first, each the entry the member thread page opens. A request
18
- * the member just posted is here and under All on the next render (the
19
- * New menu refreshes the route after a post).
20
- * - Orders — the kinds whose section is `purchases` (the `purchase` kind,
21
- * and any a module adds), newest first. The tab keeps the contract's
22
- * id, `purchases` (the section id, the `purchase` kind and
23
- * `GET /v1/member/purchases` are unchanged); only its label — the key
24
- * `inbox.tabs.purchases` — reads Orders, the Admin's word for the same
25
- * records (#9170).
26
- * - Scheduled — the kinds whose section is `upcoming` (`appointment`):
27
- * first the items still upcoming, soonest first (no time last), then the
28
- * rest, newest first. Each kind's own read decides which is upcoming.
29
- *
30
- * No lead line under the title (#11149): the Admin's Inbox has none, and
31
- * the tabs say what the list holds. The tabs follow the title row at the
32
- * list's own `mt-block-loose`, the token the Admin's list sits at.
33
- *
34
- * What needs the person is never an Inbox row: `email-unverified`,
35
- * `payment-due` and "Add your name" are For-you items (D9 as amended). From
36
- * `md` up they are the layout's aside.
37
- *
38
- * #7469 (DESIGN.md §2b as amended 2026-10-01, matching the Admin's §5.15) —
39
- * below `md` the route is the phone's two main tabs, one `PhoneTabPanel`
40
- * each (the frame hands the tab over from `?tab=`):
41
- * - Inbox — the filter tabs and the list only, in RowGroup's inset card.
42
- * No For-you stack and no bottom sheet, and no lead on the phone.
43
- * - For you — every For-you item as rows of one inset card, each with its
44
- * type tag, title, Open or View, and ✕; the empty line when none waits,
45
- * and D12's error row above the list when a For-you source failed.
46
- * The h1 sits above both panels, visually hidden below `md` (the phone has
47
- * no large title). At `md`+ only the Inbox panel shows.
48
- *
49
- * D12 — any read that fails (a kind or a For-you source) renders an error
50
- * row with Retry above the list; the list then holds what DID load, never a
51
- * silently empty Inbox.
52
- *
53
- * #8233 D4 — New sits in the h1's header row (and, below `md`, in the
54
- * frame's phone top bar): its rows are `new-popups.tsx`'s `newActions` — the
55
- * `accountNewActions` of `lib/account-config.ts` with their popups bound —
56
- * whose `available` read resolved `true`, each opening its popup over the
57
- * Inbox. None offered (a Free build) → no New at all. A read that rejected
58
- * drops its row and shows the error row too — a failed read is never silent.
59
- *
60
- * #8765 D8 — the Inbox renders nothing about agreements: an outstanding
61
- * sign-up agreement is asked by the layout's full-page interstitial, before
62
- * this page loads at all.
63
- */
64
-
65
- import {
66
- ForYouPanel,
67
- InboxList,
68
- PhoneTabPanel,
69
- type AccountContext,
70
- type InboxListRow,
71
- } from "@working-theory/templates/account";
72
- import { localeHref } from "@working-theory/ui";
73
- import { Heading, LocalTime } from "@working-theory/ui/primitives";
74
- import {
75
- CalendarClock,
76
- ClipboardList,
77
- Receipt,
78
- type LucideProps,
79
- } from "lucide-react";
80
- import type { Metadata } from "next";
81
- import { headers } from "next/headers";
82
- import { getTranslations } from "next-intl/server";
83
- import type { ComponentType, ReactElement } from "react";
84
-
85
- import { accountChatKinds } from "../../../../lib/account-config";
86
- import { SITE_NAME } from "../../../../lib/site-brand";
87
- import { readSession } from "../../../../lib/topology.generated";
88
-
89
- import {
90
- accountSession,
91
- inboxItemHref,
92
- loadForYou,
93
- loadInboxItems,
94
- logReadFailure,
95
- type LoadedInboxItem,
96
- } from "./account-data";
97
- import { outstandingAgreements } from "./agreements-gate";
98
- import { ErrorRow } from "./error-row";
99
- import { ACCOUNT_PERSIST_KEY, forYouLabels } from "./for-you-labels";
100
- import { NewMenu, type NewMenuAction } from "./new-menu";
101
- import { newActions } from "./new-popups";
102
-
103
- interface Props {
104
- params: Promise<{ locale: string }>;
105
- /** `?tab=` — an Inbox tab id opens that tab (#11149); the frame reads the same key for the phone's For you tab. */
106
- searchParams?: Promise<{ tab?: string | string[] }>;
107
- }
108
-
109
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
110
- const { locale } = await params;
111
- const t = await getTranslations({ locale, namespace: "account" });
112
- // Signed out, the `(authed)` layout renders the sign-in gate in this page's
113
- // place, so the title names THAT state — "Sign in · <site>" — not the Inbox
114
- // the visitor cannot see yet (#8790 AC-1). The session read is the layout's
115
- // own (`topology.generated`'s `readSession`); any failure keeps the Inbox
116
- // title, exactly as before.
117
- const session = await readSession(await headers()).catch(() => null);
118
- if (!session) {
119
- return {
120
- title: `${t("gate.title")} · ${SITE_NAME}`,
121
- description: t("description"),
122
- };
123
- }
124
- return { title: t("inbox.title"), description: t("description") };
125
- }
126
-
127
- /** The base kinds' row glyphs — a bare icon, never an icon square (§5.4). */
128
- const KIND_ICON: Record<string, ComponentType<LucideProps>> = {
129
- result: ClipboardList,
130
- purchase: Receipt,
131
- appointment: CalendarClock,
132
- };
133
-
134
- /** Soonest first; an item with no time sorts last. */
135
- function soonestFirst(a: LoadedInboxItem, b: LoadedInboxItem): number {
136
- if (a.item.at === undefined) return b.item.at === undefined ? 0 : 1;
137
- if (b.item.at === undefined) return -1;
138
- return Date.parse(a.item.at) - Date.parse(b.item.at);
139
- }
140
-
141
- /** The New actions this caller is offered; a rejected read drops its row and sets `failed`. */
142
- async function loadNewActions(
143
- ctx: AccountContext,
144
- ): Promise<{ actions: NewMenuAction[]; failed: boolean }> {
145
- const settled = await Promise.allSettled(
146
- newActions.map((action) => action.available(ctx)),
147
- );
148
- const actions: NewMenuAction[] = [];
149
- settled.forEach((result, i) => {
150
- const action = newActions[i]!;
151
- if (result.status === "rejected")
152
- logReadFailure(`new:${action.id}`, result.reason);
153
- else if (result.value)
154
- actions.push({
155
- id: action.id,
156
- label: ctx.t(action.label),
157
- // #11154 — a link row navigates to its page; the rest open a popup.
158
- ...(action.href !== undefined
159
- ? { href: localeHref(ctx.locale, action.href) }
160
- : { popup: action.renderPopup?.(ctx) }),
161
- });
162
- });
163
- return {
164
- actions,
165
- failed: settled.some((result) => result.status === "rejected"),
166
- };
167
- }
168
-
169
- /** Upcoming items first, soonest first; then the rest, as loaded (newest first). */
170
- function scheduledOrder(rows: readonly LoadedInboxItem[]): LoadedInboxItem[] {
171
- const upcoming = rows
172
- .filter(({ item }) => item.upcoming === true)
173
- .sort(soonestFirst);
174
- return [...upcoming, ...rows.filter(({ item }) => item.upcoming !== true)];
175
- }
176
-
177
- export default async function AccountInboxPage({
178
- params,
179
- searchParams,
180
- }: Props): Promise<ReactElement | null> {
181
- const { locale } = await params;
182
- const requestedTab = ((await searchParams) ?? {}).tab;
183
- const t = await getTranslations({ locale, namespace: "account" });
184
- const session = await accountSession(locale);
185
-
186
- // The layout shows the interstitial in place of this page while an
187
- // agreement is outstanding, but the App Router still renders the page: no
188
- // Inbox loader may run meanwhile (`member.messages` stamps `readAt`, #8765 D7).
189
- if (session && (await outstandingAgreements(session.ctx)).length > 0) return null;
190
-
191
- // The contract's translator, for keys that are data (a kind's `label`).
192
- const translate = session?.ctx.t ?? ((key: string): string => key);
193
- const [inbox, forYou, newMenu] = session
194
- ? await Promise.all([
195
- loadInboxItems(session.ctx),
196
- loadForYou(locale),
197
- loadNewActions(session.ctx),
198
- ])
199
- : [
200
- { items: [], failed: false },
201
- { items: [], failed: false, now: "" },
202
- { actions: [], failed: false },
203
- ];
204
-
205
- // #11175: the caption carries the day as a `LocalTime` node — the server
206
- // fallback zone in this RSC's render, the viewer's own once the row
207
- // hydrates.
208
- const toRow = ({ kind, item }: LoadedInboxItem): InboxListRow => {
209
- const label = translate(kind.label);
210
- const icon = KIND_ICON[kind.kind];
211
- return {
212
- id: `${kind.kind}:${item.id}`,
213
- ...(icon ? { icon } : {}),
214
- caption: item.at ? (
215
- <>
216
- {label}
217
- {" · "}
218
- <LocalTime at={item.at} preset="month-day" locale={locale} />
219
- </>
220
- ) : (
221
- label
222
- ),
223
- title: item.title,
224
- href: inboxItemHref(locale, kind.kind, item.id),
225
- };
226
- };
227
-
228
- const all = inbox.items.map(toRow);
229
- // #11157 — the conversation kinds alone: the provider's messages and the
230
- // member's own sent requests and messages, newest first as loaded.
231
- const messages = inbox.items
232
- .filter(({ kind }) => accountChatKinds.has(kind.kind))
233
- .map(toRow);
234
- // #11149 — the Orders tab: the kinds whose section is `purchases`.
235
- const purchases = inbox.items
236
- .filter(({ kind }) => kind.section === "purchases")
237
- .map(toRow);
238
- const scheduled = scheduledOrder(
239
- inbox.items.filter(({ kind }) => kind.section === "upcoming"),
240
- ).map(toRow);
241
- const failed = inbox.failed || forYou.failed || newMenu.failed;
242
- // The `purchases` tab is Orders: the contract's section id, the Admin's word (#11149).
243
- const tabs = [
244
- { id: "all", label: t("inbox.tabs.all"), count: all.length, rows: all },
245
- { id: "messages", label: t("inbox.tabs.messages"), count: messages.length, rows: messages },
246
- { id: "purchases", label: t("inbox.tabs.purchases"), count: purchases.length, rows: purchases },
247
- { id: "scheduled", label: t("inbox.tabs.scheduled"), count: scheduled.length, rows: scheduled },
248
- ];
249
-
250
- return (
251
- // The phone's top bar already clears the canvas — no top inset there.
252
- <div className="max-w-3xl py-8 max-md:pt-0" data-testid="account-inbox">
253
- {/* The page's one h1, on both phone tabs; visually hidden on the phone,
254
- which has no large title (§5.15). New sits beside it (#8233 D4). */}
255
- <div className="flex items-center justify-between gap-2">
256
- <Heading level={1} visual={2} className="max-md:sr-only">
257
- {t("inbox.title")}
258
- </Heading>
259
- <NewMenu
260
- actions={newMenu.actions}
261
- labels={{ trigger: t("new.trigger"), close: t("new.close") }}
262
- />
263
- </div>
264
- <PhoneTabPanel tabs={["inbox"]} desktop data-testid="inbox-panel-inbox">
265
- {failed ? (
266
- <ErrorRow
267
- message={t("inbox.error")}
268
- retryLabel={t("inbox.retry")}
269
- className="mt-block-loose"
270
- />
271
- ) : null}
272
-
273
- <InboxList
274
- tabs={tabs}
275
- // #11149 — `?tab=<id>` opens that tab; anything else (a repeated
276
- // value, the frame's `for-you`) opens All.
277
- defaultTab={tabs.find((tab) => tab.id === requestedTab)?.id ?? "all"}
278
- {...(failed ? {} : { emptyLine: t("inbox.empty") })}
279
- />
280
- </PhoneTabPanel>
281
-
282
- {/* #7469 — the phone For you tab: every item, rows of one inset card.
283
- At `md`+ the same items are the layout's aside. D12 here too: a
284
- failed source shows the error row, and never the empty line alone. */}
285
- <PhoneTabPanel tabs={["for-you"]} data-testid="inbox-panel-for-you">
286
- {forYou.failed ? (
287
- <ErrorRow
288
- message={t("inbox.error")}
289
- retryLabel={t("inbox.retry")}
290
- className="mb-block-loose"
291
- />
292
- ) : null}
293
- {forYou.failed && forYou.items.length === 0 ? null : (
294
- <ForYouPanel
295
- variant="list"
296
- items={forYou.items}
297
- persistKey={ACCOUNT_PERSIST_KEY}
298
- labels={forYouLabels(translate)}
299
- locale={locale}
300
- now={forYou.now}
301
- />
302
- )}
303
- </PhoneTabPanel>
304
- </div>
305
- );
306
- }
@@ -1,173 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
-
5
- /**
6
- * The person's data export, re-served (#11164 AC-3) —
7
- * `GET /[locale]/account/privacy/export`.
8
- *
9
- * The api-client's `member.exportData` is the one external boundary mocked;
10
- * `forwardedCookieInit()` and the route's decisions are real (the build's
11
- * own sign-in, a single site: the caller's session cookie). Covers:
12
- * - the read carries the caller's credential and the JSON comes back with
13
- * all five hub headers unchanged;
14
- * - a hub answer missing any of the five is refused 502, its stream
15
- * cancelled — never bytes on this origin without them;
16
- * - a cross-site navigation is refused 403 before any call;
17
- * - refusals map to a status with no body and `private, no-store`: a 4xx
18
- * keeps its status (the 429 when the person's hourly exports are spent),
19
- * a 5xx or a throw is 502, no credential is 401.
20
- */
21
-
22
- const mockExportData = jest.fn();
23
- jest.mock("@working-theory/api-client", () => ({
24
- __esModule: true,
25
- member: { exportData: (...args: unknown[]) => mockExportData(...args) },
26
- }));
27
-
28
- const mockHeaders = jest.fn();
29
- const mockCookies = jest.fn();
30
- jest.mock("next/headers", () => ({
31
- __esModule: true,
32
- headers: (...args: unknown[]) => mockHeaders(...args),
33
- cookies: (...args: unknown[]) => mockCookies(...args),
34
- }));
35
-
36
- import { GET as route } from "../export/route";
37
-
38
- /** A same-origin navigation to the route, unless `site` says otherwise. */
39
- const GET = (site: string | null = "same-origin") =>
40
- route(
41
- new Request("https://site.example.com/account/privacy/export", {
42
- headers: site === null ? {} : { "sec-fetch-site": site },
43
- }),
44
- );
45
-
46
- const FIVE = {
47
- contentType: "application/json; charset=utf-8",
48
- contentDisposition: 'attachment; filename="your-data.json"',
49
- contentTypeOptions: "nosniff",
50
- contentSecurityPolicy:
51
- "default-src 'none'; sandbox; frame-ancestors 'none'; form-action 'none'; base-uri 'none'",
52
- cacheControl: "private, no-store",
53
- };
54
-
55
- beforeEach(() => {
56
- mockExportData.mockReset();
57
- mockHeaders
58
- .mockReset()
59
- .mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
60
- mockCookies.mockReset().mockResolvedValue({ toString: () => "session=abc" });
61
- });
62
-
63
- it("reads the export with the caller's own credential and re-serves it with all five headers unchanged", async () => {
64
- const stream = new ReadableStream<Uint8Array>();
65
- mockExportData.mockResolvedValue({
66
- ok: true,
67
- body: { stream, headers: FIVE },
68
- });
69
- const res = await GET();
70
- expect(mockExportData).toHaveBeenCalledWith({
71
- headers: { cookie: "session=abc", origin: "https://site.example.com" },
72
- });
73
- expect(res.status).toBe(200);
74
- expect(res.body).toBe(stream);
75
- expect(res.headers.get("Content-Type")).toBe(FIVE.contentType);
76
- expect(res.headers.get("Content-Disposition")).toBe(FIVE.contentDisposition);
77
- expect(res.headers.get("X-Content-Type-Options")).toBe("nosniff");
78
- expect(res.headers.get("Content-Security-Policy")).toBe(
79
- FIVE.contentSecurityPolicy,
80
- );
81
- expect(res.headers.get("Cache-Control")).toBe("private, no-store");
82
- });
83
-
84
- it.each(Object.keys(FIVE) as (keyof typeof FIVE)[])(
85
- "a hub answer missing %s is refused 502 with the stream cancelled",
86
- async (missing) => {
87
- const cancel = jest.fn().mockResolvedValue(undefined);
88
- mockExportData.mockResolvedValue({
89
- ok: true,
90
- body: { stream: { cancel }, headers: { ...FIVE, [missing]: null } },
91
- });
92
- const res = await GET();
93
- expect(res.status).toBe(502);
94
- expect(res.body).toBeNull();
95
- expect(res.headers.get("Cache-Control")).toBe("private, no-store");
96
- expect(cancel).toHaveBeenCalledTimes(1);
97
- },
98
- );
99
-
100
- const refusal = (status: number, code: string) => ({
101
- ok: false,
102
- status,
103
- body: { ok: false, error: { code, message: code } },
104
- });
105
-
106
- it.each([
107
- [
108
- "a 429 (the hourly budget spent) answers 429",
109
- refusal(429, "rate_limited"),
110
- 429,
111
- ],
112
- [
113
- "a 403 (email unverified) answers 403",
114
- refusal(403, "email_unverified"),
115
- 403,
116
- ],
117
- [
118
- "a 404 (an older hub with no export route) answers 404",
119
- refusal(404, "not_found"),
120
- 404,
121
- ],
122
- ["a 503 from the hub answers 502", refusal(503, "tenant_unresolved"), 502],
123
- ["no credential (signed out) answers 401", refusal(0, "unauthorized"), 401],
124
- [
125
- "a transport the api-client refuses answers 502",
126
- refusal(0, "insecure_transport"),
127
- 502,
128
- ],
129
- ])("%s with no body and private, no-store", async (_name, answer, status) => {
130
- mockExportData.mockResolvedValue(answer);
131
- const res = await GET();
132
- expect(res.status).toBe(status);
133
- expect(res.body).toBeNull();
134
- expect(res.headers.get("Cache-Control")).toBe("private, no-store");
135
- });
136
-
137
- it("a 429 keeps the hub's retry hint as Retry-After, rebuilt from the refusal's retryAfterSeconds", async () => {
138
- mockExportData.mockResolvedValue({
139
- ok: false,
140
- status: 429,
141
- body: { error: "rate_limited", retryAfterSeconds: 1800 },
142
- });
143
- const res = await GET();
144
- expect(res.status).toBe(429);
145
- expect(res.headers.get("Retry-After")).toBe("1800");
146
- expect(res.body).toBeNull();
147
- });
148
-
149
- it.each(["cross-site", "same-site"])(
150
- "a %s navigation is refused 403 before any call",
151
- async (site) => {
152
- const res = await GET(site);
153
- expect(res.status).toBe(403);
154
- expect(res.body).toBeNull();
155
- expect(mockExportData).not.toHaveBeenCalled();
156
- },
157
- );
158
-
159
- it("a navigation with no Sec-Fetch-Site (an older browser) and a `none` one (the address bar) are served", async () => {
160
- mockExportData.mockResolvedValue({
161
- ok: true,
162
- body: { stream: new ReadableStream<Uint8Array>(), headers: FIVE },
163
- });
164
- expect((await GET(null)).status).toBe(200);
165
- expect((await GET("none")).status).toBe(200);
166
- });
167
-
168
- it("a hub call that throws is a 502, never Next's own 500", async () => {
169
- mockExportData.mockRejectedValue(new Error("ECONNREFUSED"));
170
- const res = await GET();
171
- expect(res.status).toBe(502);
172
- expect(res.body).toBeNull();
173
- });
@@ -1,103 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * A/privacy/actions.ts — the member Privacy and Notifications tabs' one
5
- * consent write path (#8438 D14, D15, spec
6
- * docs/specs/8438-consent-registry-and-ledger-step-spec.md), and the Privacy
7
- * tab's stored-sessions deletion (#11164 AC-3).
8
- *
9
- * `setConsentAction` posts one answer through `POST /v1/member/consents`
10
- * (`member.setConsent`) and answers in `ConsentSwitchList`'s own shape, so
11
- * both tabs' switch lists can call it directly with no adapter. The
12
- * banner's visitor id (`ailk-vid`) rides along as `x-ailk-consent-visitor`
13
- * when present, linking its cookie choices to the client record this write
14
- * resolves or creates (D6, D11, D12) — never failing the write when it is
15
- * absent or invalid.
16
- *
17
- * `deleteStoredSessionsAction` posts `POST /v1/member/stored-sessions/delete`
18
- * (`member.deleteStoredSessions`) with the caller's own credential and
19
- * answers in `AccountDataTable`'s shape: the line to show — the count, or
20
- * that there was nothing to delete — or the failure message. The
21
- * confirmation is the table's; this runs only after it.
22
- */
23
-
24
- import { member } from "@working-theory/api-client";
25
- import type {
26
- AccountDataActionResult,
27
- ConsentSwitchChangeResult,
28
- } from "@working-theory/templates/account";
29
- import {
30
- formatLocalTime,
31
- SERVER_TIME_ZONE,
32
- } from "@working-theory/ui/primitives";
33
- import { cookies } from "next/headers";
34
- import { getLocale, getTranslations } from "next-intl/server";
35
-
36
- import {
37
- consentVisitorHeader,
38
- readConsentVisitor,
39
- } from "../../../../../lib/consent-visitor";
40
- import { forwardedCookieInit } from "../../../../../lib/server-api";
41
-
42
- // #11159: the server fallback zone, never the host's, which the unpinned
43
- // form read; the line is a `t()` string, so no node can carry the viewer's.
44
- function formatDate(iso: string, locale: string): string {
45
- return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
46
- }
47
-
48
- export async function setConsentAction(
49
- purposeId: string,
50
- granted: boolean,
51
- ): Promise<ConsentSwitchChangeResult> {
52
- const [t, locale] = await Promise.all([
53
- getTranslations("account"),
54
- getLocale(),
55
- ]);
56
-
57
- try {
58
- const base = await forwardedCookieInit();
59
- let visitorHeaders: Record<string, string> = {};
60
- try {
61
- const visitorId = readConsentVisitor(await cookies());
62
- if (visitorId) visitorHeaders = consentVisitorHeader(visitorId);
63
- } catch {
64
- // No request scope to read, or no visitor cookie — write with none.
65
- }
66
-
67
- const res = await member.setConsent(
68
- { purposeId, granted, locale },
69
- { headers: { ...base.headers, ...visitorHeaders } },
70
- );
71
- if (!res.ok) {
72
- return { ok: false, message: t("settings.privacy.unavailable") };
73
- }
74
-
75
- const state = res.body.purpose.state;
76
- const at = state?.at ?? new Date().toISOString();
77
- const dateLine = state?.granted
78
- ? t("settings.privacy.given", { date: formatDate(at, locale) })
79
- : t("settings.privacy.withdrawn", { date: formatDate(at, locale) });
80
- return { ok: true, dateLine };
81
- } catch {
82
- return { ok: false, message: t("settings.privacy.unavailable") };
83
- }
84
- }
85
-
86
- export async function deleteStoredSessionsAction(): Promise<AccountDataActionResult> {
87
- const t = await getTranslations("account");
88
- try {
89
- const res = await member.deleteStoredSessions(await forwardedCookieInit());
90
- if (!res.ok) {
91
- return {
92
- ok: false,
93
- message: t("settings.privacy.yourData.deleteFailed"),
94
- };
95
- }
96
- return {
97
- ok: true,
98
- line: t("settings.privacy.yourData.deleted", { count: res.body.deleted }),
99
- };
100
- } catch {
101
- return { ok: false, message: t("settings.privacy.yourData.deleteFailed") };
102
- }
103
- }
@@ -1,102 +0,0 @@
1
- /**
2
- * The person's data export, re-served (#11164 AC-3) —
3
- * `GET /[locale]/account/privacy/export`.
4
- *
5
- * The Privacy tab's "Export data" button links here. The browser holds
6
- * neither the client's hub credential (sealed in the `hub-session` cookie)
7
- * nor this site's spoke key, so this route reads `GET /v1/member/data-export`
8
- * with `forwardedCookieInit()` — the caller's own credential, so a person
9
- * only ever gets their own records — and streams the JSON back unread.
10
- *
11
- * The same contract as the member file reads (`inbox/message/[id]/file`):
12
- * the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
13
- * `Content-Disposition` (attachment, `your-data.json`), `X-Content-Type-Options:
14
- * nosniff`, the sandbox `Content-Security-Policy` and `Cache-Control: private,
15
- * no-store` — so the file is never a document on this origin and never cached
16
- * on the way. A hub answer missing any of the five is refused 502 rather than
17
- * served without it.
18
- *
19
- * A refusal has no body: a cross-site navigation (`Sec-Fetch-Site` other
20
- * than `same-origin` or `none` — a third-party link must not spend the
21
- * person's hourly exports or drop a file on their disk) is a 403 before any
22
- * call; no credential (signed out) is a 401, a hub 4xx keeps its status (a
23
- * 429 when the person's hourly exports are spent), and a hub 5xx, a
24
- * transport the api-client refuses or a hub call that throws is a 502.
25
- */
26
- import { member, type MemberFileHeaders } from "@working-theory/api-client";
27
-
28
- import { forwardedCookieInit } from "../../../../../../lib/server-api";
29
-
30
- /** The response header each of the five hub headers goes out under. */
31
- const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
32
- contentType: "Content-Type",
33
- contentDisposition: "Content-Disposition",
34
- contentTypeOptions: "X-Content-Type-Options",
35
- contentSecurityPolicy: "Content-Security-Policy",
36
- cacheControl: "Cache-Control",
37
- };
38
-
39
- function refusal(status: number, retryAfterSeconds?: number): Response {
40
- return new Response(null, {
41
- status,
42
- headers: {
43
- "Cache-Control": "private, no-store",
44
- // A 429 keeps the hub's retry hint: the api-client answers the JSON
45
- // body, not the headers, and the API's refusal names the seconds.
46
- ...(retryAfterSeconds === undefined
47
- ? {}
48
- : { "Retry-After": String(retryAfterSeconds) }),
49
- },
50
- });
51
- }
52
-
53
- /** The API's `retryAfterSeconds`, when the refusal body carries one. */
54
- function retryAfterOf(body: unknown): number | undefined {
55
- const seconds = (body as { retryAfterSeconds?: unknown } | null)
56
- ?.retryAfterSeconds;
57
- return typeof seconds === "number" && Number.isFinite(seconds)
58
- ? seconds
59
- : undefined;
60
- }
61
-
62
- /** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
63
- function refusalStatus(status: number, body: unknown): number {
64
- if (status === 0) {
65
- const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
66
- return code === "unauthorized" ? 401 : 502;
67
- }
68
- return status >= 500 ? 502 : status;
69
- }
70
-
71
- // platform-decisions-waiver: api-versioning — a page-scoped download link on the site's own account area, not an API contract; it re-serves the versioned hub route /v1/member/data-export
72
- export async function GET(request: Request): Promise<Response> {
73
- const site = request.headers.get("sec-fetch-site");
74
- if (site !== null && site !== "same-origin" && site !== "none")
75
- return refusal(403);
76
-
77
- // The api-client throws, rather than answering `{ ok: false }`, on a
78
- // network failure or a redirect — that is a 502 too, never Next's own 500.
79
- let res: Awaited<ReturnType<typeof member.exportData>>;
80
- try {
81
- res = await member.exportData(await forwardedCookieInit());
82
- } catch {
83
- return refusal(502);
84
- }
85
- if (!res.ok)
86
- return refusal(refusalStatus(res.status, res.body), retryAfterOf(res.body));
87
-
88
- const { stream, headers } = res.body;
89
- const out = new Headers();
90
- for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [
91
- keyof MemberFileHeaders,
92
- string,
93
- ][]) {
94
- const value = headers[key];
95
- if (value === null) {
96
- await stream.cancel();
97
- return refusal(502);
98
- }
99
- out.set(name, value);
100
- }
101
- return new Response(stream, { status: 200, headers: out });
102
- }