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
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The site's sign-in configuration (#11257; ADR 0040 rule 4) — the one typed
3
+ * file through which this site customizes and serves `@working-theory/auth`.
4
+ *
5
+ * The default export is `defineAuthConfig({ … })`, which the generated
6
+ * `(auth)` layout file passes to the layout as `config`; it carries no
7
+ * extension point yet (rule 8), and a misspelled key fails `tsc`.
8
+ *
9
+ * The named export `site` is the runtime-services seam (`AuthSite`) the
10
+ * package's pages, actions and handlers read through
11
+ * `@working-theory/auth/site` (aliased here by `next.config.mjs` and
12
+ * `jest.config.cjs`). It never imports `./auth`: Better Auth arrives through
13
+ * the generated topology seam's `loadAuth()` — a dynamic import on a hub,
14
+ * `null` on a spoke — so a spoke keeps this file. A spoke's copy passes
15
+ * `hub: null` and imports none of the hub-only libs.
16
+ *
17
+ * Every value the generated topology seam owns is read through on access,
18
+ * never copied at load: a spoke's topology seam imports the package's
19
+ * hub-session entry, which can load before this file finishes.
20
+ */
21
+ import { type AuthSite, defineAuthConfig } from "@working-theory/auth";
22
+
23
+ import { browserApiOrigin } from "./lib/api-origin.generated";
24
+ import {
25
+ buildAuthEmailRequest,
26
+ confirmSignUpEmail,
27
+ makeSendAccountOpen,
28
+ purchaseCapture,
29
+ } from "./lib/auth-email";
30
+ import {
31
+ getActiveProviderIds,
32
+ hasAnyProvider,
33
+ isAuthRequired,
34
+ isResetAvailable,
35
+ isSignUpOpen,
36
+ magicLinkSendConfigured,
37
+ phoneVerificationConfigured,
38
+ resetSendConfigured,
39
+ } from "./lib/auth-env";
40
+ import { resolveSecret } from "./lib/auth-secret";
41
+ import { runBotCheck } from "./lib/bot-check";
42
+ import { consentPoliciesFor } from "./lib/consent-policies";
43
+ import { SITE_NAME } from "./lib/site-brand";
44
+ import { siteLogo } from "./lib/site-logo";
45
+ import {
46
+ loadAuth,
47
+ readSession,
48
+ SIGN_IN_PROVIDER,
49
+ SIGN_OUT_ENDPOINT,
50
+ TOPOLOGY,
51
+ } from "./lib/topology.generated";
52
+ import {
53
+ clientIpFromHeaders,
54
+ takeVisitorLimit,
55
+ UNKNOWN_VISITOR_FACTOR,
56
+ } from "./src/lib/rate-limit";
57
+ import { resolveBaseUrl } from "./src/lib/routes";
58
+
59
+ export default defineAuthConfig({});
60
+
61
+ export const site = {
62
+ loadAuth: () => loadAuth(),
63
+ env: {
64
+ isAuthRequired: () => isAuthRequired(),
65
+ isSignUpOpen: () => isSignUpOpen(),
66
+ isResetAvailable: () => isResetAvailable(),
67
+ getActiveProviderIds: () => getActiveProviderIds(),
68
+ magicLinkSendConfigured: () => magicLinkSendConfigured(),
69
+ hasAnyProvider: () => hasAnyProvider(),
70
+ resetSendConfigured: () => resetSendConfigured(),
71
+ phoneVerificationConfigured: () => phoneVerificationConfigured(),
72
+ },
73
+ siteLogo: () => siteLogo(),
74
+ get siteName() {
75
+ return SITE_NAME;
76
+ },
77
+ resolveBaseUrl: () => resolveBaseUrl(),
78
+ browserApiOrigin: () => browserApiOrigin(),
79
+ runBotCheck: (input) => runBotCheck(input),
80
+ takeVisitorLimit: (scope, headers, limit, windowMs) =>
81
+ takeVisitorLimit(scope, headers, limit, windowMs),
82
+ clientIpFromHeaders: (headers) => clientIpFromHeaders(headers),
83
+ get unknownVisitorFactor() {
84
+ return UNKNOWN_VISITOR_FACTOR;
85
+ },
86
+ get topology() {
87
+ return TOPOLOGY;
88
+ },
89
+ get signInProvider() {
90
+ return SIGN_IN_PROVIDER;
91
+ },
92
+ get signOutEndpoint() {
93
+ return SIGN_OUT_ENDPOINT;
94
+ },
95
+ readSession: (headers) => readSession(headers),
96
+ hub: {
97
+ resolveSecret: () => resolveSecret(),
98
+ consentPoliciesFor: (locale) => consentPoliciesFor(locale),
99
+ email: {
100
+ confirmSignUpEmail: (nonce) => confirmSignUpEmail(nonce),
101
+ makeSendAccountOpen: (deps) => makeSendAccountOpen(deps),
102
+ buildAuthEmailRequest: (payload, secret) =>
103
+ buildAuthEmailRequest(payload, secret),
104
+ purchaseCapture,
105
+ },
106
+ },
107
+ } satisfies AuthSite;
@@ -25,6 +25,7 @@
25
25
  * docs/internal/specs/ailk-pre-oss-security-phase-0.5-s0.5-better-auth-migration-spec.md.
26
26
  */
27
27
 
28
+ import { sealMcpCallbacks } from "@working-theory/auth/mcp-continuation";
28
29
  import type { PrismaClient } from "@working-theory/database";
29
30
  import { MCP_SCOPES } from "@working-theory/validation";
30
31
  import { type BetterAuthPlugin, betterAuth } from "better-auth";
@@ -33,7 +34,7 @@ import type { AuthMiddleware } from "better-auth/api";
33
34
  import { nextCookies } from "better-auth/next-js";
34
35
  import { magicLink, mcp, phoneNumber } from "better-auth/plugins";
35
36
 
36
- import { sealMcpCallbacks } from "./app/api/auth/mcp/continuation";
37
+
37
38
  import {
38
39
  authEmailTransport,
39
40
  makeMagicLinkOptions,
@@ -12,11 +12,34 @@
12
12
  // into plain objects, takes only string leaves and skips prototype keys, so
13
13
  // it can neither mutate the imported catalog nor pollute `Object.prototype`.
14
14
  //
15
+ // A page package's catalog (#11219, ADR 0040 rule 5) is added the same way,
16
+ // before the overlay: `@working-theory/account` ships the `account` keys its
17
+ // pages read, and a key this site's catalog carries is the site's override.
18
+ // `@working-theory/ui-signal-collectors` ships the `flow` and `flowVerify`
19
+ // keys of the flows pages (#11251 D6), `@working-theory/ui-scheduling` the
20
+ // `schedule` keys of the booking pages (#11252 D4),
21
+ // `@working-theory/ui-commerce` the `checkoutThankYou`, `checkoutUnavailable`
22
+ // and `purchase` keys of the checkout and purchase pages (#11253 D4), and
23
+ // `@working-theory/ui-docs-blog` the `docs` and `blog` keys of the docs and
24
+ // blog pages (#11254 D4), each read through the paid-sections registry, whose
25
+ // stub answers `null` on a site without the module. `@working-theory/auth`
26
+ // ships the `auth`, `signIn`, `mcpConsent` and `spokeSignIn` keys of the
27
+ // sign-in surfaces (#11257 D12), added after the account catalog.
28
+ //
15
29
  // Spec: docs/internal/specs/i18n-phase1-s2-next-intl-foundation-spec.md
16
30
 
31
+ import { accountMessages } from "@working-theory/account";
32
+ import { authMessages } from "@working-theory/auth";
17
33
  import type { AbstractIntlMessages } from "next-intl";
18
34
  import { getRequestConfig } from "next-intl/server";
19
35
 
36
+ import {
37
+ loadUiCommerce,
38
+ loadUiDocsBlog,
39
+ loadUiScheduling,
40
+ loadUiSignalCollectors,
41
+ } from "../lib/paid-sections.generated";
42
+
20
43
  const DEFAULT_LOCALE = "en";
21
44
 
22
45
  const UNSAFE_KEYS: ReadonlySet<string> = new Set([
@@ -76,9 +99,36 @@ export default getRequestConfig(async ({ requestLocale }) => {
76
99
  messages = (fallback.default ?? fallback) as AbstractIntlMessages;
77
100
  }
78
101
 
102
+ // #11219 (ADR 0040 rule 5) — a page package's catalog ships with the
103
+ // package; this site's catalog holds overrides only, so the package's keys
104
+ // are added under it and a key the site carries keeps the site's value.
105
+ const packaged = accountMessages(locale) ?? accountMessages(DEFAULT_LOCALE) ?? {};
106
+ const signIn = authMessages(locale) ?? authMessages(DEFAULT_LOCALE) ?? {};
107
+ const signalCollectors = await loadUiSignalCollectors();
108
+ const flows =
109
+ signalCollectors?.flowsMessages(locale) ?? signalCollectors?.flowsMessages(DEFAULT_LOCALE) ?? {};
110
+ const scheduling = await loadUiScheduling();
111
+ const schedule =
112
+ scheduling?.schedulingMessages(locale) ?? scheduling?.schedulingMessages(DEFAULT_LOCALE) ?? {};
113
+ const commerce = await loadUiCommerce();
114
+ const checkout = commerce?.commerceMessages(locale) ?? commerce?.commerceMessages(DEFAULT_LOCALE) ?? {};
115
+ const docsBlog = await loadUiDocsBlog();
116
+ const docsAndBlog =
117
+ docsBlog?.docsBlogMessages(locale) ?? docsBlog?.docsBlogMessages(DEFAULT_LOCALE) ?? {};
118
+ const withPackages = mergeAddOnly(
119
+ mergeAddOnly(
120
+ mergeAddOnly(
121
+ mergeAddOnly(mergeAddOnly(mergeAddOnly(messages as Catalog, packaged), signIn), flows),
122
+ schedule,
123
+ ),
124
+ checkout,
125
+ ),
126
+ docsAndBlog,
127
+ );
128
+
79
129
  const overlay = await loadSiteOverlay(locale);
80
130
  return {
81
131
  locale,
82
- messages: mergeAddOnly(messages, overlay) as AbstractIntlMessages,
132
+ messages: mergeAddOnly(withPackages, overlay) as AbstractIntlMessages,
83
133
  };
84
134
  });
@@ -1,7 +1,7 @@
1
1
  // Mirrors apps/api's ts-jest setup (CONVENTIONS.md mentions Vitest aspirationally,
2
2
  // but no Vitest is installed anywhere yet). JSDOM env so RTL can mount components.
3
3
  /**
4
- * #10699 D4: lib/runtime-source.ts derives the toc through
4
+ * #10699 D4: the runtime source (moved into the docs-blog package by #11254) derives the toc through
5
5
  * fumadocs-core/content/toc, whose remark closure ships ESM only. These are
6
6
  * pnpm-store name prefixes (the `tools/jest/mdxeditor-esm.cjs` shape, inlined
7
7
  * because a scaffold's copy of this file has no `tools/`): `mdast-util-`
@@ -139,6 +139,22 @@ module.exports = {
139
139
  // The Edge-safe `./stealth` subpath (#8511) → source, like the root entry.
140
140
  "^@working-theory/web-i18n/stealth$":
141
141
  "<rootDir>/node_modules/@working-theory/web-i18n/dist/stealth-metadata.js",
142
+ // #11219 (ADR 0040) — the account page package's site seam resolves to
143
+ // this app's account.config.tsx, as next.config.mjs aliases it. The
144
+ // package itself needs no mapper: it ships TypeScript source and its
145
+ // `exports` name the files, so node resolution lands on them and ts-jest
146
+ // compiles them like this app's own.
147
+ "^@working-theory/account/site$": "<rootDir>/account.config.tsx",
148
+ // #11257 — the sign-in package's site seam, the same way: next.config.mjs
149
+ // aliases it to auth.config.tsx. The package's own suites run on this
150
+ // config too (packages/auth/jest.config.cjs), against this site.
151
+ "^@working-theory/auth/site$": "<rootDir>/auth.config.tsx",
152
+ // The package's modules resolve `next/headers` and `better-auth/react`
153
+ // from their own install, a second physical copy of each (the #5025
154
+ // class above), so a test's `jest.mock()` of either would miss them.
155
+ // Collapse every copy onto the one this app resolves.
156
+ "^next/headers$": require.resolve("next/headers"),
157
+ "^better-auth/react$": require.resolve("better-auth/react"),
142
158
  // The dependency-free tenancy-constants subpath (database/tenancy.ts).
143
159
  // Mapped to source like every sibling above; `database/dist` is not
144
160
  // built in this workspace pre-`pnpm build`.
@@ -180,6 +180,17 @@ async function runFlow(): Promise<Flow> {
180
180
  };
181
181
  }
182
182
 
183
+ // The hub topology this flow tests, never the site's generated seam
184
+ // (#11246): the child process has no jest.mock, so the seam's module slot is
185
+ // filled with the site-provider fixture before `auth.ts` first requires it.
186
+ const seamPath = require.resolve("../topology.generated");
187
+ const { siteTopology } =
188
+ require("./fixtures/site-topology") as typeof import("./fixtures/site-topology");
189
+ require.cache[seamPath] = Object.assign(new Module(seamPath), {
190
+ filename: seamPath,
191
+ loaded: true,
192
+ exports: siteTopology(),
193
+ });
183
194
  const { createAuth } = require("../../auth") as typeof import("../../auth");
184
195
  const { consent } =
185
196
  require("@working-theory/api-client") as typeof import("@working-theory/api-client");
@@ -0,0 +1,73 @@
1
+ // site-topology.ts — the hub render of `lib/topology.generated.ts`, for a
2
+ // suite that tests the site sign-in provider (#11246).
3
+ //
4
+ // The generated seam is written per site: `SIGN_IN_PROVIDER` is `"hub"` on
5
+ // every spoke that signs in through its hub, so a suite that reads the real
6
+ // file tests whichever topology the site happens to be. A suite written for
7
+ // the site provider mocks the seam with this instead:
8
+ //
9
+ // jest.mock("<…>/lib/topology.generated", () =>
10
+ // jest.requireActual("<…>/lib/__tests__/fixtures/site-topology").siteTopology(),
11
+ // );
12
+ //
13
+ // Every value is create-ailk's hub render (`renderWebSeam("hub")` in
14
+ // packages/create-ailk/src/topology.ts — keep the two in step); the
15
+ // return type is the seam's own, so a new seam export fails `tsc` here until
16
+ // it is added. The readers load `auth.ts` only when called, as the hub render
17
+ // does, so a suite's own `auth` mock answers them.
18
+ import type * as Seam from "../../topology.generated";
19
+
20
+ export function siteTopology(): typeof Seam & { __esModule: true } {
21
+ return {
22
+ __esModule: true,
23
+ TOPOLOGY: "hub",
24
+ UNSERVED_MCP_TOOLS: [],
25
+ SIGN_IN_ENABLED: true,
26
+ SIGN_IN_PROVIDER: "site",
27
+ SIGN_IN_PATH: "/sign-in",
28
+ SIGN_UP_PATH: "/sign-up",
29
+ SIGN_OUT_ENDPOINT: null,
30
+ async readSession(headers) {
31
+ const { auth } = await import("../../../auth");
32
+ return auth.api.getSession({ headers });
33
+ },
34
+ loadAuth() {
35
+ return import("../../../auth").then((m) => m.auth);
36
+ },
37
+ async readOwnAccounts(headers) {
38
+ const { auth } = await import("../../../auth");
39
+ return auth.api.listUserAccounts({ headers });
40
+ },
41
+ async readPhoneStep(headers) {
42
+ const { auth } = await import("../../../auth");
43
+ const api: object = auth.api;
44
+ const available = "sendPhoneNumberOTP" in api;
45
+ if (!available) return { available, phone: null };
46
+ const session = await auth.api.getSession({ headers });
47
+ const user = (session?.user ?? {}) as {
48
+ phoneNumber?: unknown;
49
+ phoneNumberVerified?: unknown;
50
+ };
51
+ const phone =
52
+ typeof user.phoneNumber === "string" && user.phoneNumber !== ""
53
+ ? {
54
+ number: user.phoneNumber,
55
+ verified: user.phoneNumberVerified === true,
56
+ }
57
+ : null;
58
+ return { available, phone };
59
+ },
60
+ async loadPhoneApi() {
61
+ const { auth, phoneStepActive } = await import("../../../auth");
62
+ return phoneStepActive() ? auth.api : null;
63
+ },
64
+ async registerSiteStores() {
65
+ const { registerLicenseKeyStore } =
66
+ await import("../../license-key-store");
67
+ await registerLicenseKeyStore();
68
+ },
69
+ loadSpokeBilling() {
70
+ return Promise.resolve(null);
71
+ },
72
+ };
73
+ }
@@ -73,6 +73,20 @@ describe("navMessageKeys", () => {
73
73
  ).toEqual(["a", "b"]);
74
74
  });
75
75
 
76
+ it("leaves out a message with an ICU argument (it is not a bare label)", () => {
77
+ expect(
78
+ navMessageKeys({
79
+ nav: {
80
+ home: "Home",
81
+ backTo: "Back to {name}",
82
+ feature1: "'{Feature 1}'",
83
+ dont: "Don't miss {name}'s page",
84
+ quoted: "It''s here",
85
+ },
86
+ }),
87
+ ).toEqual(["home", "feature1", "quoted"]);
88
+ });
89
+
76
90
  it("is empty when there is no nav namespace", () => {
77
91
  expect(navMessageKeys({})).toEqual([]);
78
92
  expect(navMessageKeys(undefined)).toEqual([]);
@@ -1,95 +1,182 @@
1
1
  /**
2
- * Tests for the profile back-link rule (#7744 D7).
2
+ * Tests for the bare header's back arrow (operator handoff 2026-11-09,
3
+ * superseding #7744 D7's people-slide rule).
3
4
  *
4
- * On a deck home, a team profile's back arrow returns to the home's people
5
- * slide (`#slide-people`, #7740's anchor for the section id `people`);
6
- * everywhere else it goes home. Covers bare and locale-prefixed profiles, the
7
- * `/team` index, near misses, a non-deck home and the absent-header fail-safe.
5
+ * The arrow goes to the page's served parent, walking up past any ancestor
6
+ * the site does not serve, and home past the top; its label names the
7
+ * destination. Covers parent, skip-to-grandparent, top-level, locale prefix,
8
+ * the absent-header fail-safe, the label sources and the nav walk. The slide
9
+ * return itself is `@working-theory/ui`'s deck-return.ts (its own suite);
10
+ * the last block here pins how the two compose.
8
11
  */
9
12
 
13
+ import { deckReturnHref } from "@working-theory/ui/chrome";
14
+
10
15
  import {
11
16
  backLinkHref,
12
- isTeamProfilePath,
13
- PEOPLE_SLIDE_ANCHOR,
17
+ backLinkName,
18
+ navLabelsByPath,
19
+ servedParent,
14
20
  } from "../profile-back-link";
15
21
 
16
- const LOCALES = ["en", "fr"];
22
+ const LOCALES = ["en", "es"];
23
+ const SERVED = new Set(["/meet", "/about", "/blog", "/blog/series", "/team"]);
24
+ const served = (path: string): boolean => SERVED.has(path);
25
+
26
+ function href(pathname: string | null | undefined, homePath = "/"): string {
27
+ return backLinkHref({ pathname, homePath, locales: LOCALES, served });
28
+ }
29
+
30
+ describe("backLinkHref — the served parent", () => {
31
+ it.each([
32
+ ["/meet/discovery", "/meet"],
33
+ ["/blog/series/post", "/blog/series"],
34
+ ["/about/wendi-henry", "/about"],
35
+ ["/team/first-member", "/team"],
36
+ ["/meet/discovery/", "/meet"],
37
+ ["/meet/discovery?ref=x#top", "/meet"],
38
+ ])("%s → %s", (pathname, expected) => {
39
+ expect(href(pathname)).toBe(expected);
40
+ });
41
+
42
+ it("keeps the locale prefix: /es/meet/discovery → /es/meet", () => {
43
+ expect(href("/es/meet/discovery", "/es")).toBe("/es/meet");
44
+ });
17
45
 
18
- describe("isTeamProfilePath", () => {
19
- it.each(["/team/first-member", "/fr/team/first-member", "/en/team/a"])(
20
- "is true for the profile path %s",
46
+ it("skips a parent the site does not serve and walks up to the grandparent", () => {
47
+ expect(href("/blog/archive/2026/post")).toBe("/blog");
48
+ });
49
+
50
+ it("goes home when no ancestor below the home is served", () => {
51
+ expect(href("/case-studies/acme/details")).toBe("/");
52
+ expect(href("/es/case-studies/acme/details", "/es")).toBe("/es");
53
+ });
54
+
55
+ it.each(["/about", "/meet", "/privacy", "/es/about"])(
56
+ "a top-level page (%s) still goes home",
21
57
  (pathname) => {
22
- expect(isTeamProfilePath(pathname, LOCALES)).toBe(true);
58
+ expect(href(pathname, pathname.startsWith("/es") ? "/es" : "/")).toBe(
59
+ pathname.startsWith("/es") ? "/es" : "/",
60
+ );
23
61
  },
24
62
  );
25
63
 
26
- it.each([
27
- "/team",
28
- "/team/",
29
- "/fr/team",
30
- "/team/a/b",
31
- "/teams/x",
32
- "/about",
33
- "/",
34
- "",
35
- ])("is false for %s", (pathname) => {
36
- expect(isTeamProfilePath(pathname, LOCALES)).toBe(false);
64
+ it("treats a prefix that is not an enabled locale as the first segment", () => {
65
+ expect(backLinkHref({ pathname: "/xx/meet", homePath: "/", locales: ["en"], served })).toBe(
66
+ "/",
67
+ );
37
68
  });
38
69
 
39
- it("treats a prefix that is not an enabled locale as the first segment", () => {
40
- expect(isTeamProfilePath("/xx/team/a", ["en"])).toBe(false);
70
+ it("goes home for an absent pathname", () => {
71
+ expect(href(null)).toBe("/");
72
+ expect(href(undefined)).toBe("/");
73
+ expect(href("")).toBe("/");
74
+ });
75
+
76
+ it("never asks about the home itself", () => {
77
+ const asked: string[] = [];
78
+ servedParent({
79
+ pathname: "/a/b/c",
80
+ locales: LOCALES,
81
+ served: (p) => {
82
+ asked.push(p);
83
+ return false;
84
+ },
85
+ });
86
+ expect(asked).toEqual(["/a/b", "/a"]);
87
+ });
88
+ });
89
+
90
+ describe("backLinkName — the destination named in the label", () => {
91
+ const titles = new Map([
92
+ ["/meet", "Book a meeting with Sam"],
93
+ ["/blog/series", "The series"],
94
+ ["/about", ""],
95
+ ]);
96
+ const navLabels = new Map([["/meet", "Meet"]]);
97
+
98
+ it("prefers the parent's nav label: /meet → Meet", () => {
99
+ expect(backLinkName("/meet", { navLabels, titles })).toBe("Meet");
100
+ });
101
+
102
+ it("falls back to the parent page's title", () => {
103
+ expect(backLinkName("/blog/series", { navLabels, titles })).toBe("The series");
41
104
  });
42
105
 
43
- it("answers false for an absent pathname", () => {
44
- expect(isTeamProfilePath(null, LOCALES)).toBe(false);
45
- expect(isTeamProfilePath(undefined, LOCALES)).toBe(false);
106
+ it("falls back to the last segment in words when neither names it", () => {
107
+ expect(backLinkName("/about", { navLabels, titles })).toBe("About");
108
+ expect(backLinkName("/case-studies", { navLabels: new Map(), titles: new Map() })).toBe(
109
+ "Case studies",
110
+ );
46
111
  });
47
112
  });
48
113
 
49
- describe("backLinkHref", () => {
50
- it("names the people-slide anchor", () => {
51
- expect(PEOPLE_SLIDE_ANCHOR).toBe("slide-people");
114
+ describe("navLabelsByPath", () => {
115
+ it("collects every { labelKey, path } at any depth, first entry winning", () => {
116
+ const labels = navLabelsByPath(
117
+ [
118
+ [
119
+ { labelKey: "product", flyout: { groups: [{ items: [{ labelKey: "f1", path: "/features/one" }] }] } },
120
+ { labelKey: "meet", path: "/meet" },
121
+ ],
122
+ [{ headingKey: "h", items: [{ labelKey: "other", path: "/meet" }, { labelKey: "faq", path: "/faq" }] }],
123
+ ],
124
+ (key) => key.toUpperCase(),
125
+ );
126
+ expect([...labels]).toEqual([
127
+ ["/features/one", "F1"],
128
+ ["/meet", "MEET"],
129
+ ["/faq", "FAQ"],
130
+ ]);
52
131
  });
132
+ });
53
133
 
54
- it("returns /#slide-people for a profile on a deck home", () => {
134
+ // The done-when, end to end: the server href computed here, then the
135
+ // client-side slide return NavBackLink applies on top of it.
136
+ describe("the arrow a visitor gets", () => {
137
+ function arrow(input: { pathname: string; referrer: string; record: object | null }): string {
138
+ const serverHref = href(input.pathname);
139
+ return (
140
+ deckReturnHref({
141
+ backHref: serverHref,
142
+ record: input.record ? JSON.stringify(input.record) : null,
143
+ referrer: input.referrer,
144
+ href: `http://localhost${input.pathname}`,
145
+ }) ?? serverHref
146
+ );
147
+ }
148
+
149
+ it("/about/wendi-henry opened from the human-ai-team slide → /#slide-human-ai-team", () => {
55
150
  expect(
56
- backLinkHref({
57
- pathname: "/team/first-member",
58
- homePath: "/",
59
- home: "deck",
60
- locales: LOCALES,
151
+ arrow({
152
+ pathname: "/about/wendi-henry",
153
+ referrer: "http://localhost/",
154
+ record: { anchor: "slide-human-ai-team", from: "/", to: "/about/wendi-henry" },
61
155
  }),
62
- ).toBe("/#slide-people");
156
+ ).toBe("/#slide-human-ai-team");
63
157
  });
64
158
 
65
- it("keeps the /fr prefix on a non-default locale", () => {
159
+ it("a post opened from the principles slide → /#slide-principles", () => {
66
160
  expect(
67
- backLinkHref({
68
- pathname: "/fr/team/first-member",
69
- homePath: "/fr",
70
- home: "deck",
71
- locales: LOCALES,
161
+ arrow({
162
+ pathname: "/blog/a-post",
163
+ referrer: "http://localhost/",
164
+ record: { anchor: "slide-principles", from: "/", to: "/blog/a-post" },
72
165
  }),
73
- ).toBe("/fr#slide-people");
166
+ ).toBe("/#slide-principles");
74
167
  });
75
168
 
76
- it.each(["/team", "/team/a/b", "/about", "/teams/x", null, undefined])(
77
- "returns the home for %s on a deck home",
78
- (pathname) => {
79
- expect(
80
- backLinkHref({ pathname, homePath: "/", home: "deck", locales: LOCALES }),
81
- ).toBe("/");
82
- },
83
- );
84
-
85
- it("returns the home for a profile when the home is not a deck", () => {
169
+ it("the same post opened from /blog → its parent /blog", () => {
86
170
  expect(
87
- backLinkHref({
88
- pathname: "/team/first-member",
89
- homePath: "/",
90
- home: "default",
91
- locales: LOCALES,
171
+ arrow({
172
+ pathname: "/blog/a-post",
173
+ referrer: "http://localhost/blog",
174
+ record: { anchor: "slide-principles", from: "/", to: "/blog/a-post" },
92
175
  }),
93
- ).toBe("/");
176
+ ).toBe("/blog");
177
+ });
178
+
179
+ it("a direct arrival at /meet/discovery → /meet", () => {
180
+ expect(arrow({ pathname: "/meet/discovery", referrer: "", record: null })).toBe("/meet");
94
181
  });
95
182
  });
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Tests for the served-pages source the bare back arrow walks up through
3
+ * (operator handoff 2026-11-09): listed content pages with their titles,
4
+ * fixed code-rendered routes of the modules this site carries, and a
5
+ * fail-safe when the adapter throws.
6
+ */
7
+
8
+ // A module, not a script: its helpers stay out of the global scope.
9
+ export {};
10
+ // Whether this site carries the scheduling module is the site's own generated
11
+ // flag, so the suite asserts against it: the monorepo serves /meet, a
12
+ // scaffold without scheduling does not (release-check matrix rows, 2026-11-10).
13
+ import { SCHEDULING_PAGES } from "../modules.generated";
14
+
15
+ const mockListPages = jest.fn();
16
+ let mockAdapterThrows = false;
17
+
18
+ jest.mock("@working-theory/page-renderer", () => ({
19
+ ...jest.requireActual("@working-theory/page-renderer"),
20
+ getContentAdapter: () => {
21
+ if (mockAdapterThrows) throw new Error("no adapter");
22
+ return { listPages: mockListPages };
23
+ },
24
+ }));
25
+
26
+ function page(type: string, slug: string, title: string) {
27
+ return { type, slug, title };
28
+ }
29
+
30
+ async function loadServed(locale: string) {
31
+ let servedPages!: typeof import("../served-pages").servedPages;
32
+ jest.isolateModules(() => {
33
+ ({ servedPages } = jest.requireActual("../served-pages"));
34
+ });
35
+ return servedPages(locale);
36
+ }
37
+
38
+ beforeEach(() => {
39
+ mockAdapterThrows = false;
40
+ mockListPages.mockReset();
41
+ mockListPages.mockImplementation((type: string) => {
42
+ if (type === "AboutPage")
43
+ return Promise.resolve([page("AboutPage", "about", "About us")]);
44
+ if (type === "ThankYouPage")
45
+ return Promise.resolve([page("ThankYouPage", "contact", "Thanks")]);
46
+ return Promise.resolve([]);
47
+ });
48
+ });
49
+
50
+ describe("servedPages", () => {
51
+ it("lists a content page at its served path with its title", async () => {
52
+ const pages = await loadServed("en");
53
+ expect(pages.get("/about")).toBe("About us");
54
+ });
55
+
56
+ it("leaves out a ThankYouPage, which the sitemap never lists", async () => {
57
+ const pages = await loadServed("en");
58
+ expect([...pages.values()]).not.toContain("Thanks");
59
+ });
60
+
61
+ it("includes /meet, the scheduling module's code-rendered index, with no title", async () => {
62
+ const pages = await loadServed("en");
63
+ expect(pages.get("/meet")).toBe(SCHEDULING_PAGES ? "" : undefined);
64
+ });
65
+
66
+ it("reads the locale it is asked for", async () => {
67
+ await loadServed("es");
68
+ expect(mockListPages).toHaveBeenCalledWith("AboutPage", "es");
69
+ });
70
+
71
+ it("keeps the code-rendered routes when the adapter throws", async () => {
72
+ mockAdapterThrows = true;
73
+ const pages = await loadServed("en");
74
+ expect(pages.has("/meet")).toBe(SCHEDULING_PAGES);
75
+ expect(pages.has("/about")).toBe(false);
76
+ });
77
+ });