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,704 +0,0 @@
1
- /**
2
- * Tests for lib/account-config.ts — the base account area's contributions
3
- * (#7429, spec 7423 U3 · AC-6; amended by #7448, U5 · D6a/D8a/D9; by #8231,
4
- * spec 8231 D4–D7).
5
- *
6
- * Covers:
7
- * 1. The five contribution arrays are exported; the base area ships no
8
- * Settings section or Billing section (modules add those), and the
9
- * three New actions (#8233 D2).
10
- * 2. The Inbox kinds: `result`, `piece` and `message` in `updates` (All
11
- * only), `purchase` in `purchases`, `appointment` in `upcoming`.
12
- * 3. `email-unverified` and `payment-due` are For-you sources — needs-you
13
- * items with an Open action to User settings, never Inbox rows.
14
- * 4. Each contribution maps its read: the session for `email-unverified`,
15
- * `waitlistSignups.me` per configured key for `result`,
16
- * `member.purchases` for `purchase` (never `flowCheckouts.me`),
17
- * `member.appointments` for `appointment`, and `subscription.me`'s own
18
- * `actionRequired` for `payment-due`.
19
- * 5. A 404 — or a 401/403 while the email is unverified — is "nothing for
20
- * this caller" (`[]`); any other failed read rejects, a 401/403 for a
21
- * verified email included, so the Inbox can show an error row (D12).
22
- * 6. The member kinds call on a cookie-session site — no hub-credential
23
- * gate (#8231 D7).
24
- * 7. #8233 D1, D2 — each New action is offered while its member read
25
- * answers: a 404 (or a switched-off request form, or an unverified
26
- * 401/403) is `false`, any other failure rejects. The popups are bound
27
- * in the route (`account/new-popups.tsx`, tested beside it): this file
28
- * imports nothing under `(authed)`.
29
- * 8. #9401 AC-11 — the template's `site-contributions.ts` stub ships no
30
- * Billing section either; a site fills it.
31
- */
32
-
33
- const mockSignupMe = jest.fn();
34
- const mockCheckoutsMe = jest.fn();
35
- const mockSubscriptionMe = jest.fn();
36
- const mockMemberPieces = jest.fn();
37
- const mockMemberMessages = jest.fn();
38
- const mockMemberRequests = jest.fn();
39
- const mockMemberPurchases = jest.fn();
40
- const mockMemberResults = jest.fn();
41
- const mockMemberAppointments = jest.fn();
42
- const mockMemberMeetingTypes = jest.fn();
43
- const mockMemberRequestForm = jest.fn();
44
- const mockMemberWelcome = jest.fn();
45
- jest.mock("@working-theory/api-client", () => ({
46
- __esModule: true,
47
- waitlistSignups: { me: (...args: unknown[]) => mockSignupMe(...args) },
48
- flowCheckouts: { me: (...args: unknown[]) => mockCheckoutsMe(...args) },
49
- subscription: { me: (...args: unknown[]) => mockSubscriptionMe(...args) },
50
- member: {
51
- pieces: (...args: unknown[]) => mockMemberPieces(...args),
52
- messages: (...args: unknown[]) => mockMemberMessages(...args),
53
- requests: (...args: unknown[]) => mockMemberRequests(...args),
54
- purchases: (...args: unknown[]) => mockMemberPurchases(...args),
55
- results: (...args: unknown[]) => mockMemberResults(...args),
56
- appointments: (...args: unknown[]) => mockMemberAppointments(...args),
57
- meetingTypes: (...args: unknown[]) => mockMemberMeetingTypes(...args),
58
- requestForm: (...args: unknown[]) => mockMemberRequestForm(...args),
59
- welcome: (...args: unknown[]) => mockMemberWelcome(...args),
60
- },
61
- }));
62
-
63
- import type {
64
- AccountContext,
65
- AccountForYouSource,
66
- AccountInboxKind,
67
- } from "@working-theory/templates/account";
68
- import { requestQuoteFlowConfig } from "@working-theory/validation";
69
-
70
- import {
71
- accountBillingSections,
72
- accountExperimentKeys,
73
- accountForYouSources,
74
- accountInboxKinds,
75
- accountNewActions,
76
- accountSettingsSections,
77
- type AccountNewRead,
78
- } from "../account-config";
79
- import { siteBillingSections } from "../site-contributions";
80
-
81
- const INIT = { headers: { cookie: "session=abc" } };
82
-
83
- function ctx(overrides: Partial<AccountContext["user"]> = {}): AccountContext {
84
- return {
85
- locale: "en",
86
- user: {
87
- name: "Ada",
88
- email: "ada@example.com",
89
- emailVerified: true,
90
- ...overrides,
91
- },
92
- t: (key) => `t:${key}`,
93
- init: INIT,
94
- };
95
- }
96
-
97
- function kind(id: string): AccountInboxKind {
98
- const found = accountInboxKinds.find((k) => k.kind === id);
99
- if (!found) throw new Error(`no base kind ${id}`);
100
- return found;
101
- }
102
-
103
- function source(id: string): AccountForYouSource {
104
- const found = accountForYouSources.find((s) => s.id === id);
105
- if (!found) throw new Error(`no base For-you source ${id}`);
106
- return found;
107
- }
108
-
109
- const SIGNUP = {
110
- experimentKey: "diag",
111
- waitlistKey: "early",
112
- completedAt: "2026-09-01T10:00:00.000Z",
113
- tier: "gold",
114
- score: 42,
115
- aeoScore: null,
116
- answers: { q3: null },
117
- };
118
-
119
- const PURCHASE = {
120
- id: "pur_1",
121
- offering: "Pro plan",
122
- amountMinor: 4900,
123
- currency: "USD",
124
- period: "month",
125
- purchasedAt: "2026-09-02T10:00:00.000Z",
126
- };
127
-
128
- const APPOINTMENT = {
129
- id: "appt_1",
130
- title: "Kickoff",
131
- startTime: "2026-10-20T15:00:00.000Z",
132
- endTime: "2026-10-20T15:30:00.000Z",
133
- status: "confirmed" as const,
134
- };
135
-
136
- const PIECE = {
137
- id: "piece_1",
138
- title: "Brand guide",
139
- stage: "in_progress",
140
- needsClient: true,
141
- createdAt: "2026-09-01T10:00:00.000Z",
142
- updatedAt: "2026-09-03T10:00:00.000Z",
143
- };
144
-
145
- const MESSAGE = {
146
- id: "intx_1",
147
- subject: "Your draft",
148
- body: "Attached.",
149
- createdAt: "2026-09-04T10:00:00.000Z",
150
- file: null,
151
- readAt: null,
152
- };
153
-
154
- /** #11157 — a quote request the member sent; a quote's body is empty. */
155
- const SENT_REQUEST = {
156
- id: "intx_2",
157
- kind: "quote" as const,
158
- subject: "Request quote",
159
- body: "",
160
- createdAt: "2026-09-05T10:00:00.000Z",
161
- };
162
-
163
- const ok = <T>(body: T) => ({ ok: true as const, body });
164
- const fail = (status: number) => ({ ok: false as const, status, body: null });
165
-
166
- beforeEach(() => {
167
- // A site with no workspace module answers the results read 404.
168
- mockMemberResults.mockResolvedValue(fail(404));
169
- });
170
-
171
- afterEach(() => {
172
- jest.clearAllMocks();
173
- accountExperimentKeys.length = 0;
174
- });
175
-
176
- describe("account-config exports (AC-6)", () => {
177
- it("exports the five contribution arrays", () => {
178
- expect(Array.isArray(accountInboxKinds)).toBe(true);
179
- expect(accountSettingsSections).toEqual([]);
180
- expect(Array.isArray(accountForYouSources)).toBe(true);
181
- });
182
-
183
- it("ships the three New actions, by message key, and no Billing section (#8233 D2)", () => {
184
- expect(accountNewActions.map((a) => [a.id, a.label])).toEqual([
185
- ["schedule-service", "new.actions.scheduleService"],
186
- ["request-quote", "new.actions.requestQuote"],
187
- ["send-message", "new.actions.sendMessage"],
188
- ]);
189
- expect(accountBillingSections).toEqual([]);
190
- });
191
-
192
- it("ships no site Billing section either: the stub is the site's to fill (#9401 AC-11, D7)", () => {
193
- expect(siteBillingSections).toEqual([]);
194
- });
195
-
196
- it("ships the base kinds and the member kinds in their sections (#8231 D4–D6)", () => {
197
- expect(accountInboxKinds.map((k) => [k.kind, k.section])).toEqual([
198
- ["result", "updates"],
199
- ["purchase", "purchases"],
200
- ["piece", "updates"],
201
- ["message", "updates"],
202
- ["request", "updates"],
203
- ["appointment", "upcoming"],
204
- ]);
205
- // No Inbox row asks for a decision — that is the For-you panel's job.
206
- expect(accountInboxKinds.some((k) => k.section === "needs-you")).toBe(false);
207
- });
208
-
209
- it("ships email-unverified, payment-due, piece-needs-client (#7920) and onboarding-steps (#11150) as For-you sources, not Inbox kinds (D9 as amended)", () => {
210
- expect(accountForYouSources.map((s) => s.id)).toEqual([
211
- "email-unverified",
212
- "payment-due",
213
- "piece-needs-client",
214
- "onboarding-steps",
215
- ]);
216
- const kinds = accountInboxKinds.map((k) => k.kind);
217
- expect(kinds).not.toContain("email-unverified");
218
- expect(kinds).not.toContain("payment-due");
219
- });
220
-
221
- it("gives every kind a unique id — the `[kind]` route segment", () => {
222
- const ids = accountInboxKinds.map((k) => k.kind);
223
- expect(new Set(ids).size).toBe(ids.length);
224
- });
225
-
226
- it("names every kind by a message key, never a literal", () => {
227
- for (const k of accountInboxKinds)
228
- expect(k.label).toMatch(/^[a-z]+(\.[A-Za-z]+)+$/);
229
- });
230
- });
231
-
232
- describe("email-unverified — a For-you item from the session", () => {
233
- it("is one needs-you item, opening User settings › General", async () => {
234
- const items = await source("email-unverified").load(
235
- ctx({ emailVerified: false }),
236
- );
237
- expect(items).toHaveLength(1);
238
- expect(items[0]).toMatchObject({
239
- id: "email-unverified",
240
- type: { id: "email", label: "t:profile.email", tone: "needs-you" },
241
- title: "t:profile.unverified",
242
- action: { kind: "open", href: "/account/general" },
243
- dismissible: true,
244
- });
245
- });
246
-
247
- it("is empty when the email is verified, and reads no API", async () => {
248
- await expect(source("email-unverified").load(ctx())).resolves.toEqual([]);
249
- expect(mockSignupMe).not.toHaveBeenCalled();
250
- expect(mockCheckoutsMe).not.toHaveBeenCalled();
251
- expect(mockSubscriptionMe).not.toHaveBeenCalled();
252
- });
253
- });
254
-
255
- describe("result — waitlistSignups.me per accountExperimentKeys", () => {
256
- it("reads each configured key with the forwarded init, skipping a 404", async () => {
257
- accountExperimentKeys.push("diag", "other");
258
- mockSignupMe.mockImplementation(async (key: string) =>
259
- key === "diag" ? ok(SIGNUP) : fail(404),
260
- );
261
- const items = await kind("result").load(ctx());
262
- expect(mockSignupMe).toHaveBeenCalledWith("diag", INIT);
263
- expect(mockSignupMe).toHaveBeenCalledWith("other", INIT);
264
- expect(items).toEqual([
265
- { id: "diag", title: "diag", at: SIGNUP.completedAt, data: SIGNUP },
266
- ]);
267
- });
268
-
269
- it("is empty with no configured key", async () => {
270
- await expect(kind("result").load(ctx())).resolves.toEqual([]);
271
- expect(mockSignupMe).not.toHaveBeenCalled();
272
- });
273
-
274
- it("rejects on a failed read", async () => {
275
- accountExperimentKeys.push("diag");
276
- mockSignupMe.mockResolvedValue(fail(500));
277
- await expect(kind("result").load(ctx())).rejects.toThrow();
278
- });
279
- });
280
-
281
- describe("result — member.results, a User's pending link (#10826 D7, AC-2)", () => {
282
- const RESULT = {
283
- id: "lead_01920000-0000-7000-8000-000000000001",
284
- magnetSlug: "request-quote",
285
- title: "Request a quote",
286
- submittedAt: "2026-11-02T09:00:00.000Z",
287
- href: "/flows/request-quote/results/eyJ2ZXJzaW9uIjoxfQ",
288
- };
289
- const ITEM = { id: RESULT.id, title: "Request a quote", at: RESULT.submittedAt, data: RESULT };
290
-
291
- it("loads member.results items as rows with the forwarded init, beside the signups", async () => {
292
- accountExperimentKeys.push("diag");
293
- mockSignupMe.mockResolvedValue(ok(SIGNUP));
294
- mockMemberResults.mockResolvedValue(ok({ items: [RESULT] }));
295
- const items = await kind("result").load(ctx());
296
- expect(mockMemberResults).toHaveBeenCalledWith(INIT);
297
- expect(items).toEqual([
298
- { id: "diag", title: "diag", at: SIGNUP.completedAt, data: SIGNUP },
299
- ITEM,
300
- ]);
301
- });
302
-
303
- it("loads none on a 404 (no workspace module)", async () => {
304
- mockMemberResults.mockResolvedValue(fail(404));
305
- await expect(kind("result").load(ctx())).resolves.toEqual([]);
306
- });
307
-
308
- it("loads none on a 403 while the email is unverified, and rejects on a 503", async () => {
309
- mockMemberResults.mockResolvedValue(fail(403));
310
- await expect(kind("result").load(ctx({ emailVerified: false }))).resolves.toEqual([]);
311
- mockMemberResults.mockResolvedValue(fail(503));
312
- await expect(kind("result").load(ctx())).rejects.toThrow();
313
- });
314
-
315
- it("details the magnet's title and submitted date, with an Open action to its href", () => {
316
- const detail = kind("result").renderDetail(ITEM, ctx());
317
- expect(detail.fields?.heading).toBe("t:results.heading");
318
- expect(detail.fields?.items.map((i) => i.label)).toEqual([
319
- "t:results.magnet",
320
- "t:results.submittedAt",
321
- ]);
322
- expect(detail.fields?.items[0]?.value).toBe("Request a quote");
323
- expect(detail.actions).toEqual([
324
- {
325
- key: "open-result",
326
- label: "t:results.open",
327
- variant: "default",
328
- href: "/flows/request-quote/results/eyJ2ZXJzaW9uIjoxfQ",
329
- },
330
- ]);
331
- });
332
-
333
- it("still details a waitlist signup as before", () => {
334
- const detail = kind("result").renderDetail(
335
- { id: "diag", title: "diag", at: SIGNUP.completedAt, data: SIGNUP },
336
- ctx(),
337
- );
338
- expect(detail.actions).toBeUndefined();
339
- expect(detail.fields?.items[0]).toEqual({ label: "t:results.experiment", value: "diag" });
340
- });
341
- });
342
-
343
- describe("purchase — member.purchases (#8231 D5)", () => {
344
- const ITEM = { id: "pur_1", title: "Pro plan", at: PURCHASE.purchasedAt, data: PURCHASE };
345
-
346
- it("sits in the purchases section", () => {
347
- expect(kind("purchase").section).toBe("purchases");
348
- });
349
-
350
- it("is one item per purchase, at its purchase time, and never reads flowCheckouts.me", async () => {
351
- mockMemberPurchases.mockResolvedValue(ok({ items: [PURCHASE] }));
352
- const items = await kind("purchase").load(ctx());
353
- expect(mockMemberPurchases).toHaveBeenCalledWith(INIT);
354
- expect(mockCheckoutsMe).not.toHaveBeenCalled();
355
- expect(items).toEqual([ITEM]);
356
- });
357
-
358
- it("is empty on a 404", async () => {
359
- mockMemberPurchases.mockResolvedValue(fail(404));
360
- await expect(kind("purchase").load(ctx())).resolves.toEqual([]);
361
- });
362
-
363
- it.each([401, 403])(
364
- "is empty on a %i while the email is unverified",
365
- async (status) => {
366
- mockMemberPurchases.mockResolvedValue(fail(status));
367
- await expect(
368
- kind("purchase").load(ctx({ emailVerified: false })),
369
- ).resolves.toEqual([]);
370
- },
371
- );
372
-
373
- it.each([401, 403])(
374
- "rejects on a %i for a verified email",
375
- async (status) => {
376
- mockMemberPurchases.mockResolvedValue(fail(status));
377
- await expect(kind("purchase").load(ctx())).rejects.toMatchObject({
378
- status,
379
- });
380
- },
381
- );
382
-
383
- it("rejects on a 503", async () => {
384
- mockMemberPurchases.mockResolvedValue(fail(503));
385
- await expect(kind("purchase").load(ctx())).rejects.toThrow();
386
- });
387
-
388
- it("details the purchase's fields, with no status", () => {
389
- const detail = kind("purchase").renderDetail(ITEM, ctx());
390
- expect(detail.status).toBeUndefined();
391
- expect(detail.fields?.items.map((i) => i.label)).toEqual([
392
- "t:purchases.offer",
393
- "t:purchases.amount",
394
- "t:purchases.period",
395
- "t:purchases.date",
396
- ]);
397
- expect(detail.fields?.items[0]?.value).toBe("Pro plan");
398
- });
399
-
400
- it("shows Not recorded for a null amount or period", () => {
401
- const data = { ...PURCHASE, amountMinor: null, currency: null, period: null };
402
- const detail = kind("purchase").renderDetail({ ...ITEM, data }, ctx());
403
- const values = detail.fields?.items.map((i) => i.value);
404
- expect(values?.[1]).toBe("t:purchases.unavailable");
405
- expect(values?.[2]).toBe("t:purchases.unavailable");
406
- });
407
- });
408
-
409
- describe("appointment — member.appointments (#8231 D6)", () => {
410
- const PAST = {
411
- ...APPOINTMENT,
412
- id: "appt_0",
413
- title: null,
414
- startTime: "2026-09-10T15:00:00.000Z",
415
- endTime: "2026-09-10T15:30:00.000Z",
416
- };
417
-
418
- it("sits in the upcoming section, named by its message key", () => {
419
- expect(kind("appointment").section).toBe("upcoming");
420
- expect(kind("appointment").label).toBe("appointments.heading");
421
- });
422
-
423
- it("returns the upcoming items then the past, flagged, at their start time", async () => {
424
- mockMemberAppointments.mockResolvedValue(ok({ upcoming: [APPOINTMENT], past: [PAST] }));
425
- const items = await kind("appointment").load(ctx());
426
- expect(mockMemberAppointments).toHaveBeenCalledWith(INIT);
427
- expect(items).toEqual([
428
- { id: "appt_1", title: "Kickoff", at: APPOINTMENT.startTime, upcoming: true, data: APPOINTMENT },
429
- { id: "appt_0", title: "t:appointments.untitled", at: PAST.startTime, upcoming: false, data: PAST },
430
- ]);
431
- });
432
-
433
- it("is empty on a 404", async () => {
434
- mockMemberAppointments.mockResolvedValue(fail(404));
435
- await expect(kind("appointment").load(ctx())).resolves.toEqual([]);
436
- });
437
-
438
- it("rejects on a 503", async () => {
439
- mockMemberAppointments.mockResolvedValue(fail(503));
440
- await expect(kind("appointment").load(ctx())).rejects.toThrow();
441
- });
442
-
443
- it("details the status and the start and end", () => {
444
- const item = { id: "appt_1", title: "Kickoff", at: APPOINTMENT.startTime, upcoming: true, data: APPOINTMENT };
445
- const detail = kind("appointment").renderDetail(item, ctx());
446
- expect(detail.status).toBe("t:appointments.statuses.confirmed");
447
- expect(detail.fields?.items.map((i) => i.label)).toEqual([
448
- "t:appointments.starts",
449
- "t:appointments.ends",
450
- ]);
451
- });
452
- });
453
-
454
- describe("member kinds on a cookie-session site — no gate (#8231 D7)", () => {
455
- it("piece reads member.pieces with the cookie init and returns its rows", async () => {
456
- mockMemberPieces.mockResolvedValue(ok({ items: [PIECE] }));
457
- const items = await kind("piece").load(ctx());
458
- expect(mockMemberPieces).toHaveBeenCalledWith(INIT);
459
- expect(items.map((i) => i.id)).toEqual(["piece_1"]);
460
- });
461
-
462
- it("message reads member.messages with the cookie init and returns its rows", async () => {
463
- mockMemberMessages.mockResolvedValue(ok({ items: [MESSAGE] }));
464
- const items = await kind("message").load(ctx());
465
- expect(mockMemberMessages).toHaveBeenCalledWith(INIT);
466
- expect(items.map((i) => i.id)).toEqual(["intx_1"]);
467
- });
468
-
469
- it("piece-needs-client reads member.pieces with the cookie init", async () => {
470
- mockMemberPieces.mockResolvedValue(ok({ items: [PIECE] }));
471
- const items = await source("piece-needs-client").load(ctx());
472
- expect(mockMemberPieces).toHaveBeenCalledWith(INIT);
473
- expect(items.map((i) => i.id)).toEqual(["piece:piece_1"]);
474
- });
475
-
476
- it("request reads member.requests with the cookie init and returns the sent rows, titled by subject (#11157)", async () => {
477
- mockMemberRequests.mockResolvedValue(ok({ items: [SENT_REQUEST] }));
478
- const items = await kind("request").load(ctx());
479
- expect(mockMemberRequests).toHaveBeenCalledWith(INIT);
480
- expect(items.map((i) => [i.id, i.title, i.at])).toEqual([
481
- ["intx_2", "Request quote", "2026-09-05T10:00:00.000Z"],
482
- ]);
483
- });
484
-
485
- it("request is a conversation kind: its detail is the member's own bubble, the sent line for a quote's empty body (#11157)", () => {
486
- const item = { id: "intx_2", title: "Request quote", at: SENT_REQUEST.createdAt, data: SENT_REQUEST };
487
- const detail = kind("request").renderDetail(item, ctx());
488
- expect(detail.actions).toBeUndefined();
489
- expect(detail.fields).toBeUndefined();
490
- const bubble = detail.body as { props: { side: string; caption: string; children: { props: { children: string } } } };
491
- expect(bubble.props.side).toBe("end");
492
- expect(bubble.props.caption).toContain("t:requests.sentAt · ");
493
- expect(bubble.props.children.props.children).toBe("t:requests.quoteSent");
494
- const withBody = kind("request").renderDetail(
495
- { ...item, data: { ...SENT_REQUEST, kind: "message" as const, body: "Hello\nthere" } },
496
- ctx(),
497
- ).body as { props: { children: { props: { children: string } } } };
498
- expect(withBody.props.children.props.children).toBe("Hello\nthere");
499
- });
500
-
501
- it.each([
502
- ["piece", mockMemberPieces],
503
- ["message", mockMemberMessages],
504
- ["request", mockMemberRequests],
505
- ] as const)("%s loads [] on a 404 and rejects on a 500", async (id, mock) => {
506
- mock.mockResolvedValue(fail(404));
507
- await expect(kind(id).load(ctx())).resolves.toEqual([]);
508
- mock.mockResolvedValue(fail(500));
509
- await expect(kind(id).load(ctx())).rejects.toThrow();
510
- });
511
- });
512
-
513
- describe("payment-due — a For-you item from subscription.me's actionRequired", () => {
514
- const SUB = {
515
- actionRequired: true,
516
- status: "past_due",
517
- accessRevokesAt: null,
518
- portalAvailable: true,
519
- };
520
-
521
- it("is one needs-you item, opening User settings › Billing, when the API says action is required", async () => {
522
- mockSubscriptionMe.mockResolvedValue(ok(SUB));
523
- const items = await source("payment-due").load(ctx());
524
- expect(mockSubscriptionMe).toHaveBeenCalledWith(INIT);
525
- expect(items).toHaveLength(1);
526
- expect(items[0]).toMatchObject({
527
- id: "payment-due",
528
- type: { id: "payment", label: "t:subscription.action", tone: "needs-you" },
529
- title: "t:subscription.headline",
530
- action: { kind: "open", href: "/account/billing" },
531
- dismissible: true,
532
- });
533
- });
534
-
535
- it("is empty when it is not — the status is never re-derived", async () => {
536
- mockSubscriptionMe.mockResolvedValue(ok({ ...SUB, actionRequired: false }));
537
- await expect(source("payment-due").load(ctx())).resolves.toEqual([]);
538
- });
539
-
540
- it("is empty on a 404 (the commerce-disabled build)", async () => {
541
- mockSubscriptionMe.mockResolvedValue(fail(404));
542
- await expect(source("payment-due").load(ctx())).resolves.toEqual([]);
543
- });
544
-
545
- it("rejects on a failed read", async () => {
546
- mockSubscriptionMe.mockResolvedValue(fail(500));
547
- await expect(source("payment-due").load(ctx())).rejects.toThrow();
548
- });
549
- });
550
-
551
- // ── #11150 — the onboarding steps ────────────────────────────────────────────
552
-
553
- describe("onboarding-steps — a welcomed member's steps left, from member.welcome (#11150 AC-3)", () => {
554
- const WELCOMED_AT = "2026-11-08T09:00:00.000Z";
555
- const WELCOME = {
556
- welcomedAt: WELCOMED_AT,
557
- steps: [
558
- { id: "name", done: false },
559
- { id: "onboarding", done: false },
560
- { id: "email", done: true },
561
- { id: "booking", done: false },
562
- ],
563
- };
564
-
565
- it("is one item per step not done, each linking to its page, none dismissible, timed at the welcome", async () => {
566
- mockMemberWelcome.mockResolvedValue(ok(WELCOME));
567
- const items = await source("onboarding-steps").load(ctx());
568
- expect(mockMemberWelcome).toHaveBeenCalledWith(INIT);
569
- expect(items.map((item) => item.id)).toEqual([
570
- "onboarding:name",
571
- "onboarding:onboarding",
572
- "onboarding:booking",
573
- ]);
574
- expect(items[0]).toEqual({
575
- id: "onboarding:name",
576
- type: { id: "onboarding", label: "t:forYou.types.onboarding", tone: "neutral" },
577
- // The area's own "Add your name" string — the item it replaces (account-data.ts).
578
- title: "t:forYou.addName",
579
- time: { kind: "at", at: WELCOMED_AT },
580
- action: { kind: "open", href: "/account/general" },
581
- dismissible: false,
582
- });
583
- expect(items.map((item) => (item.action as { href: string }).href)).toEqual([
584
- "/account/general",
585
- "/account/onboarding",
586
- "/account/appointments",
587
- ]);
588
- expect(items.every((item) => item.dismissible === false)).toBe(true);
589
- });
590
-
591
- it("links the email step to General and the booking step to Appointments", async () => {
592
- mockMemberWelcome.mockResolvedValue(
593
- ok({
594
- welcomedAt: WELCOMED_AT,
595
- steps: [
596
- { id: "email", done: false },
597
- { id: "booking", done: false },
598
- ],
599
- }),
600
- );
601
- const items = await source("onboarding-steps").load(ctx({ emailVerified: false }));
602
- expect(items.map((item) => [item.title, (item.action as { href: string }).href])).toEqual([
603
- ["t:forYou.onboarding.email", "/account/general"],
604
- ["t:forYou.onboarding.booking", "/account/appointments"],
605
- ]);
606
- });
607
-
608
- it("is empty once every step is done, so the panel's empty-hides rule holds", async () => {
609
- mockMemberWelcome.mockResolvedValue(
610
- ok({ welcomedAt: WELCOMED_AT, steps: WELCOME.steps.map((step) => ({ ...step, done: true })) }),
611
- );
612
- await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
613
- });
614
-
615
- it("is empty with no marker (no Person could be made), on a 404, and on an unverified 401/403", async () => {
616
- mockMemberWelcome.mockResolvedValueOnce(ok({ welcomedAt: null, steps: [] }));
617
- await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
618
- mockMemberWelcome.mockResolvedValueOnce(fail(404));
619
- await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
620
- mockMemberWelcome.mockResolvedValueOnce(fail(403));
621
- await expect(source("onboarding-steps").load(ctx({ emailVerified: false }))).resolves.toEqual([]);
622
- });
623
-
624
- it("rejects on a failed read, a 403 for a verified email included (D12)", async () => {
625
- mockMemberWelcome.mockResolvedValueOnce(fail(500));
626
- await expect(source("onboarding-steps").load(ctx())).rejects.toThrow();
627
- mockMemberWelcome.mockResolvedValueOnce(fail(403));
628
- await expect(source("onboarding-steps").load(ctx())).rejects.toThrow();
629
- });
630
- });
631
-
632
- // ── #8233 — the New actions ──────────────────────────────────────────────────
633
-
634
- describe("New actions — offered while their member read answers (#8233 D1, D2)", () => {
635
- function action(id: string): AccountNewRead {
636
- const found = accountNewActions.find((a) => a.id === id);
637
- if (!found) throw new Error(`no New action ${id}`);
638
- return found;
639
- }
640
-
641
- const TYPE = { slug: "consult", title: "Consultation", durationMinutes: 30 };
642
- const FORM = {
643
- form: {
644
- title: "Request a quote",
645
- defaultLocale: "en",
646
- steps: requestQuoteFlowConfig.steps,
647
- },
648
- };
649
- const failure = (status: number) => ({
650
- ok: false as const,
651
- status,
652
- body: { ok: false, error: { code: "failed", message: "x" } },
653
- });
654
-
655
- it.each([
656
- ["{ items: [] }", true, ok({ items: [] })],
657
- ["one type", true, ok({ items: [TYPE] })],
658
- ["404", false, fail(404)],
659
- ])("schedule-service: meetingTypes %s → %s", async (_name, offered, answer) => {
660
- mockMemberMeetingTypes.mockResolvedValue(answer);
661
- await expect(action("schedule-service").available(ctx())).resolves.toBe(offered);
662
- expect(mockMemberMeetingTypes).toHaveBeenCalledWith(INIT);
663
- });
664
-
665
- it.each([
666
- ["a form", true, ok(FORM)],
667
- ["{ form: null }", false, ok({ form: null })],
668
- ["404", false, fail(404)],
669
- ])("request-quote: requestForm %s → %s", async (_name, offered, answer) => {
670
- mockMemberRequestForm.mockResolvedValue(answer);
671
- await expect(action("request-quote").available(ctx())).resolves.toBe(offered);
672
- expect(mockMemberRequestForm).toHaveBeenCalledWith(INIT);
673
- });
674
-
675
- it("send-message is a link row to the member thread page (#11152)", () => {
676
- expect(action("send-message").href).toBe("/account/inbox/thread");
677
- expect(action("schedule-service").href).toBe("/account/appointments");
678
- expect(action("request-quote").href).toBeUndefined();
679
- });
680
-
681
- it("send-message: a messages 200 → true, read with ctx.init", async () => {
682
- mockMemberMessages.mockResolvedValue(ok({ items: [] }));
683
- await expect(action("send-message").available(ctx())).resolves.toBe(true);
684
- expect(mockMemberMessages).toHaveBeenCalledWith(INIT);
685
- });
686
-
687
- it("send-message: 404 → false; 403 while the email is unverified → false", async () => {
688
- mockMemberMessages.mockResolvedValue(fail(404));
689
- await expect(action("send-message").available(ctx())).resolves.toBe(false);
690
- mockMemberMessages.mockResolvedValue(fail(403));
691
- await expect(action("send-message").available(ctx({ emailVerified: false }))).resolves.toBe(
692
- false,
693
- );
694
- });
695
-
696
- it.each([
697
- ["schedule-service", 503, mockMemberMeetingTypes],
698
- ["request-quote", 500, mockMemberRequestForm],
699
- ["send-message", 503, mockMemberMessages],
700
- ] as const)("%s rejects on a %i — a failed read is never reported as absent", async (id, status, mock) => {
701
- mock.mockResolvedValue(failure(status));
702
- await expect(action(id).available(ctx())).rejects.toMatchObject({ status });
703
- });
704
- });