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,154 +0,0 @@
1
- /**
2
- * /[locale]/account/invitations/[invitationId] — accept an invitation to an
3
- * organization (#11106, spec
4
- * docs/specs/11106-the-workforce-foundation-roles-by-spec.md D5; AC-3).
5
- *
6
- * The mailed link is `/sign-in?next=/account/invitations/<id>&email=<address>`:
7
- * a signed-out visitor lands on `/sign-in` with the invited address already
8
- * filled, and this page sits under `(authed)`, whose gate redirects any other
9
- * signed-out visit to `/sign-in?next=…`. Signed in, the page reads the
10
- * invitation (`readInvitation`), which the API answers only for the invited,
11
- * VERIFIED address:
12
- *
13
- * - pending: the organization, the inviter and the role, and Accept — a
14
- * form POST to `acceptInvitation`, which creates the Membership and
15
- * returns here with `?joined=1`. A GET of this page writes nothing;
16
- * - another address: "This invitation is for a different email address.
17
- * Sign out and sign in with the invited address.";
18
- * - no such invitation, or a build without the invitation routes (404):
19
- * `notFound()`;
20
- * - accepted, expired or no longer open: one line saying so.
21
- *
22
- * After joining, the person reaches the Admin through its own sign-in, which
23
- * now admits them. Every string is an `account.invitation.*` message.
24
- */
25
-
26
- import { Button, Container, Heading, InlineMessage, Text } from "@working-theory/ui/primitives";
27
- import type { Metadata } from "next";
28
- import { notFound } from "next/navigation";
29
- import { getTranslations } from "next-intl/server";
30
- import type { ReactElement, ReactNode } from "react";
31
-
32
- import { acceptInvitation, readInvitation } from "./actions";
33
- import { isInvitationId } from "./invitation-id";
34
-
35
- interface Props {
36
- params: Promise<{ locale: string; invitationId: string }>;
37
- searchParams: Promise<{ joined?: string | string[]; error?: string | string[] }>;
38
- }
39
-
40
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
41
- const { locale } = await params;
42
- const t = await getTranslations({ locale, namespace: "account" });
43
- return { title: t("invitation.accept"), robots: { index: false, follow: false } };
44
- }
45
-
46
- /** `?error=` → its line's key; an unknown value is the generic failure. */
47
- const ERROR_KEYS = {
48
- invitation_for_another_address: "invitation.otherAddress",
49
- invitation_not_pending: "invitation.notPending",
50
- invitation_expired: "invitation.expired",
51
- invitation_void: "invitation.void",
52
- already_member: "invitation.alreadyMember",
53
- } as const;
54
-
55
- function errorKeyFor(
56
- error: string | string[] | undefined,
57
- ): (typeof ERROR_KEYS)[keyof typeof ERROR_KEYS] | "invitation.failed" | null {
58
- if (typeof error !== "string") return null;
59
- return Object.hasOwn(ERROR_KEYS, error)
60
- ? ERROR_KEYS[error as keyof typeof ERROR_KEYS]
61
- : "invitation.failed";
62
- }
63
-
64
- function Frame({ children }: { children: ReactNode }): ReactElement {
65
- return (
66
- <Container className="py-section">
67
- <div className="flex max-w-prose flex-col gap-4" data-testid="account-invitation">
68
- {children}
69
- </div>
70
- </Container>
71
- );
72
- }
73
-
74
- export default async function AccountInvitationPage({
75
- params,
76
- searchParams,
77
- }: Props): Promise<ReactElement> {
78
- const { locale, invitationId } = await params;
79
- const { joined, error } = await searchParams;
80
- if (!isInvitationId(invitationId)) notFound();
81
- const t = await getTranslations({ locale, namespace: "account" });
82
- const read = await readInvitation(invitationId);
83
-
84
- if (read.kind === "not_found") notFound();
85
- if (read.kind === "other_address" || read.kind === "failed") {
86
- return (
87
- <Frame>
88
- <InlineMessage
89
- variant="error"
90
- role="alert"
91
- data-testid={read.kind === "other_address" ? "account-invitation-other-address" : "account-invitation-failed"}
92
- >
93
- {t(read.kind === "other_address" ? "invitation.otherAddress" : "invitation.failed")}
94
- </InlineMessage>
95
- </Frame>
96
- );
97
- }
98
-
99
- const { invitation } = read;
100
- const organization = invitation.organizationName;
101
-
102
- if (invitation.status === "accepted" && joined === "1") {
103
- return (
104
- <Frame>
105
- <div data-testid="account-invitation-joined">
106
- <Heading level={1} visual={3}>
107
- {t("invitation.joined", { organization })}
108
- </Heading>
109
- </div>
110
- <Text as="p" variant="body" tone="muted">
111
- {t("invitation.joinedLead")}
112
- </Text>
113
- </Frame>
114
- );
115
- }
116
-
117
- const expired =
118
- invitation.expiresAt !== null && Date.parse(invitation.expiresAt) <= Date.now();
119
- if (invitation.status !== "pending" || expired) {
120
- return (
121
- <Frame>
122
- <InlineMessage variant="default" role="status" data-testid="account-invitation-closed">
123
- {t(expired && invitation.status === "pending" ? "invitation.expired" : "invitation.notPending")}
124
- </InlineMessage>
125
- </Frame>
126
- );
127
- }
128
-
129
- const role = t(`invitation.roles.${invitation.role}`);
130
- const errorKey = errorKeyFor(error);
131
-
132
- return (
133
- <Frame>
134
- <Heading level={1} visual={3}>
135
- {t("invitation.title", { organization })}
136
- </Heading>
137
- <Text as="p" variant="body" data-testid="account-invitation-lead">
138
- {invitation.inviterName
139
- ? t("invitation.lead", { inviter: invitation.inviterName, organization, role })
140
- : t("invitation.leadNoInviter", { organization, role })}
141
- </Text>
142
- {errorKey ? (
143
- <InlineMessage variant="error" role="alert" data-testid="account-invitation-error">
144
- {t(errorKey)}
145
- </InlineMessage>
146
- ) : null}
147
- <form action={acceptInvitation.bind(null, invitationId, locale)} data-testid="account-invitation-form">
148
- <Button type="submit" size="big" data-testid="account-invitation-accept">
149
- {t("invitation.accept")}
150
- </Button>
151
- </form>
152
- </Frame>
153
- );
154
- }
@@ -1,152 +0,0 @@
1
- /**
2
- * The account layout — the base account area's frame (#7430, spec 7423 U4 ·
3
- * D4, D13; DESIGN.md §2b).
4
- *
5
- * RSC. Every `/account` route but the four Settings tabs renders inside
6
- * `SignedInShell` (through the client `AccountFrame`; the tabs draw their own
7
- * standalone settings frame, #8430): the site's logo as the rail's top tile, linking
8
- * home; the rail's rows — Inbox, a Library group holding Artifacts and
9
- * Appointments (#8231 D1, #11154); a footer of the avatar and ? alone;
10
- * the card avatar menu (name, then Settings and Log out); the ? help menu
11
- * (Contact support, and Help center when `AILK_HELP_CENTER_URL` is set);
12
- * and below `md` a tab bar reading avatar · Inbox · For you · Help (#7469).
13
- * The locale layout renders no marketing frame and no consent Banner on
14
- * these paths (D4, `isAccountPath`).
15
- *
16
- * The aside is the For-you panel, fed by `accountForYouSources` plus the
17
- * area's own "Add your name" item (`loadForYou`, deduped per request with
18
- * the Inbox's phone For you tab); with no items there is no aside.
19
- *
20
- * #8465 — `SIGN_OUT_ENDPOINT` (set only on a spoke that signs in through its
21
- * hub) rides down as a prop; the client frame cannot import the generated
22
- * seam. After that sign-out the frame lands on the site's home (#11095 D4):
23
- * the spoke's `/account` would sign the person straight back in while their
24
- * hub session lives.
25
- *
26
- * The `(authed)` layout above owns the signed-out gate, so a missing session
27
- * here is a race (it expired between the two layouts): the page renders
28
- * unframed and degrades on its own.
29
- *
30
- * #8765 D7 — after the session check the layout reads the caller's
31
- * account-level sign-up agreements (`GET /v1/consent/account`). While any
32
- * is not current, it returns `AgreementsInterstitial` IN PLACE of the frame
33
- * and its children, so no account page loads behind it. It fails closed
34
- * (SEC-8765-C): any answer but a 2xx or a 404 — a thrown read, a 401, 403,
35
- * 429 or 5xx — shows the interstitial from the web's own copy of the
36
- * registry, with the "new" title, and logs `read_failed`. Only a 404, an
37
- * older hub with no such route, renders the account as before. The gate is
38
- * on the account area's pages, never the member API (SEC-8765-L).
39
- */
40
-
41
- import { localeHref } from "@working-theory/ui";
42
- import { getTranslations } from "next-intl/server";
43
- import type { ReactElement, ReactNode } from "react";
44
-
45
- import { siteLogo } from "../../../../lib/site-logo";
46
- import { SIGN_OUT_ENDPOINT } from "../../../../lib/topology.generated";
47
-
48
- import { accountSession, loadForYou } from "./account-data";
49
- import { AccountFrame } from "./account-frame";
50
- import { outstandingAgreements } from "./agreements-gate";
51
- import { AgreementsInterstitial } from "./agreements-prompt";
52
- import { forYouLabels } from "./for-you-labels";
53
-
54
- /** The value when it parses as an https URL, else undefined: operator config is rendered as an href. */
55
- function httpsUrl(value: string | undefined): string | undefined {
56
- if (!value) return undefined;
57
- try {
58
- return new URL(value).protocol === "https:" ? value : undefined;
59
- } catch {
60
- return undefined;
61
- }
62
- }
63
-
64
- interface Props {
65
- children: ReactNode;
66
- params: Promise<{ locale: string }>;
67
- }
68
-
69
- export default async function AccountLayout({
70
- children,
71
- params,
72
- }: Props): Promise<ReactElement> {
73
- const { locale } = await params;
74
- const session = await accountSession(locale);
75
- if (!session) return <>{children}</>;
76
-
77
- const t = await getTranslations({ locale, namespace: "account" });
78
- const signOutProps = SIGN_OUT_ENDPOINT
79
- ? {
80
- signOutEndpoint: SIGN_OUT_ENDPOINT,
81
- signInHref: localeHref(locale, "/"),
82
- }
83
- : {};
84
-
85
- const outstanding = await outstandingAgreements(session.ctx);
86
- if (outstanding.length > 0) {
87
- return (
88
- <AgreementsInterstitial
89
- locale={locale}
90
- agreements={outstanding}
91
- {...signOutProps}
92
- labels={{
93
- titleNew: t("agreements.titleNew"),
94
- titleUpdated: t("agreements.titleUpdated"),
95
- lead: t("agreements.lead"),
96
- accept: t("agreements.accept"),
97
- signOut: t("agreements.signOut"),
98
- error: t("agreements.error"),
99
- signOutFailed: t("frame.signOutFailed"),
100
- }}
101
- />
102
- );
103
- }
104
-
105
- const forYou = await loadForYou(locale);
106
- const { name, email } = session.ctx.user;
107
- const helpCenterUrl = httpsUrl(process.env.AILK_HELP_CENTER_URL);
108
-
109
- return (
110
- <AccountFrame
111
- locale={locale}
112
- user={{ name: name ?? email, email }}
113
- logo={siteLogo()}
114
- helpItems={[
115
- {
116
- id: "support",
117
- label: t("frame.contactSupport"),
118
- href: localeHref(locale, "/account/support"),
119
- },
120
- ...(helpCenterUrl
121
- ? [{ id: "help-center", label: t("frame.helpCenter"), href: helpCenterUrl }]
122
- : []),
123
- ]}
124
- forYou={{ items: forYou.items, now: forYou.now, labels: forYouLabels(session.ctx.t) }}
125
- {...signOutProps}
126
- labels={{
127
- home: t("frame.home"),
128
- inbox: t("frame.inbox"),
129
- forYou: t("frame.forYou"),
130
- settings: t("frame.settings"),
131
- library: t("frame.library"),
132
- artifacts: t("frame.artifacts"),
133
- appointments: t("frame.appointments"),
134
- signOutFailed: t("frame.signOutFailed"),
135
- signOut: t("frame.signOut"),
136
- help: t("frame.help"),
137
- accountMenu: t("frame.accountMenu"),
138
- tabBar: t("frame.tabBar"),
139
- sidebar: t("frame.sidebar"),
140
- collapseSidebar: t("frame.collapseSidebar"),
141
- expandSidebar: t("frame.expandSidebar"),
142
- collapseAside: t("frame.collapseAside"),
143
- expandAside: t("frame.expandAside"),
144
- aside: t("forYou.title"),
145
- openAside: t("frame.openAside"),
146
- closeAside: t("frame.closeAside"),
147
- }}
148
- >
149
- {children}
150
- </AccountFrame>
151
- );
152
- }
@@ -1,219 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * account/new-actions.ts — the New menu's reads and writes (#8233, spec
5
- * docs/specs/8233-member-new-menu-the-new-spec.md D5, D6; the writes are
6
- * #8170's).
7
- *
8
- * A popup reads its data when it opens (D5) and posts through a write here:
9
- *
10
- * - `readMeetingTypes` — `member.meetingTypes`, the types the provider
11
- * offers its clients.
12
- * - `readSlots` — `member.availability` for one type, from now to
13
- * `SLOT_WINDOW_DAYS` later. The range is computed here; the browser
14
- * sends only the slug and its time zone.
15
- * - `readRequestForm` — `member.requestForm`, the request-quote magnet's
16
- * current steps, or `form: null` while Request quote is switched off.
17
- * - `sendMessage` · `requestQuote` · `bookService` — `member.sendMessage`,
18
- * `member.requestQuote` and `member.book`.
19
- *
20
- * Every call sends `forwardedCookieInit()`'s init as built: on a single site
21
- * the session cookie plus the request's `Origin` (`apps/api`'s cookie CSRF
22
- * check), on a hub-mode spoke the hub credential — so nothing here tests the
23
- * topology, and no identity is posted: the server takes the name and the
24
- * verified email from the credential (8170 D7).
25
- *
26
- * A value is sent exactly as typed — never trimmed, never given a scheme: the
27
- * server's `plainText` and `isHttpsLink` are the one rule. An optional value
28
- * left empty or all-space is omitted, because the server refuses `""`. A
29
- * refusal maps to its `error.code` when a popup has words for it, else to
30
- * `failed`.
31
- *
32
- * Not a `*.actions.ts` file and no `*Action`-suffixed export: apps/mcp's
33
- * parity test reads that suffix, and these member writes have no MCP twin by
34
- * decision (8170's header). Logs carry the function, the status and the code
35
- * only — never a typed value or a credential.
36
- */
37
-
38
- import { member } from "@working-theory/api-client";
39
- import type {
40
- MemberMeetingType,
41
- MemberRequestFormResponse,
42
- SchedulingSlot,
43
- } from "@working-theory/validation";
44
-
45
- import { forwardedCookieInit } from "../../../../lib/server-api";
46
-
47
- /** How far ahead Schedule service offers times (the read's own cap is 60 days). */
48
- const SLOT_WINDOW_DAYS = 14;
49
- const DAY_MS = 24 * 60 * 60 * 1000;
50
-
51
- /** The refusal codes a popup has its own words for; anything else is `failed`. */
52
- const KNOWN_CODES = [
53
- "link_not_https",
54
- "answers_invalid",
55
- "request_form_off",
56
- "meeting_type_not_offered",
57
- "slot_unavailable",
58
- "too_many_requests",
59
- "invalid_input",
60
- ] as const;
61
-
62
- export type NewActionErrorCode = (typeof KNOWN_CODES)[number] | "failed";
63
-
64
- /** What a popup's form shows after a submit. */
65
- export type NewActionState =
66
- | { kind: "idle" }
67
- | { kind: "success" }
68
- | { kind: "error"; code: NewActionErrorCode };
69
-
70
- export type NewReadResult<T> = ({ kind: "ok" } & T) | { kind: "error" };
71
-
72
- /** Structural mirror of `@working-theory/api-client`'s `ApiResult<T>` (not re-exported). */
73
- type ApiResult<T> = { ok: true; body: T } | { ok: false; status: number; body: unknown };
74
-
75
- /** PII-safe error identity for logs (the `checkout.actions.ts` idiom: `err.name` only). */
76
- function errorName(err: unknown): string {
77
- return err instanceof Error ? err.name : "unknown";
78
- }
79
-
80
- /** The `error.code` of a member refusal body, when it has one. */
81
- function errorCode(body: unknown): string | null {
82
- if (typeof body !== "object" || body === null) return null;
83
- const error = (body as { error?: unknown }).error;
84
- if (typeof error !== "object" || error === null) return null;
85
- const code = (error as { code?: unknown }).code;
86
- return typeof code === "string" ? code : null;
87
- }
88
-
89
- function knownCode(code: string | null): NewActionErrorCode {
90
- return KNOWN_CODES.find((known) => known === code) ?? "failed";
91
- }
92
-
93
- /** A posted value as typed; `undefined` when it is absent or not a string. */
94
- function value(formData: FormData, name: string): string | undefined {
95
- const entry = formData.get(name);
96
- return typeof entry === "string" ? entry : undefined;
97
- }
98
-
99
- /** An optional posted value as typed, or `undefined` when it is empty or all-space. */
100
- function optional(formData: FormData, name: string): string | undefined {
101
- const entry = value(formData, name);
102
- return entry !== undefined && entry.trim() !== "" ? entry : undefined;
103
- }
104
-
105
- async function runRead<T, R>(
106
- name: string,
107
- call: (init: { headers: Record<string, string> }) => Promise<ApiResult<T>>,
108
- shape: (body: T) => R,
109
- ): Promise<NewReadResult<R>> {
110
- try {
111
- const res = await call(await forwardedCookieInit());
112
- if (res.ok) return { kind: "ok", ...shape(res.body) };
113
- console.error(`[new-actions] ${name} status=${res.status} code=${errorCode(res.body) ?? "none"}`);
114
- } catch (err) {
115
- console.error(`[new-actions] ${name} errName=${errorName(err)}`);
116
- }
117
- return { kind: "error" };
118
- }
119
-
120
- /** Action input is untrusted: a hand-built call may post anything but FormData. */
121
- function isFormData(input: unknown): input is FormData {
122
- return input instanceof FormData;
123
- }
124
-
125
- async function runWrite(
126
- name: string,
127
- call: (init: { headers: Record<string, string> }) => Promise<ApiResult<unknown>>,
128
- ): Promise<NewActionState> {
129
- try {
130
- const res = await call(await forwardedCookieInit());
131
- if (res.ok) return { kind: "success" };
132
- const code = knownCode(errorCode(res.body));
133
- console.error(`[new-actions] ${name} status=${res.status} code=${code}`);
134
- return { kind: "error", code };
135
- } catch (err) {
136
- console.error(`[new-actions] ${name} errName=${errorName(err)}`);
137
- return { kind: "error", code: "failed" };
138
- }
139
- }
140
-
141
- // ── Reads (D5) ───────────────────────────────────────────────────────────────
142
-
143
- export async function readMeetingTypes(): Promise<NewReadResult<{ items: MemberMeetingType[] }>> {
144
- return runRead("readMeetingTypes", (init) => member.meetingTypes(init), ({ items }) => ({ items }));
145
- }
146
-
147
- export async function readSlots(input: {
148
- slug: string;
149
- timeZone?: string;
150
- }): Promise<NewReadResult<{ slots: SchedulingSlot[] }>> {
151
- // Action input is untrusted: a hand-built call may send anything.
152
- const { slug, timeZone } = (typeof input === "object" && input !== null ? input : {}) as {
153
- slug?: unknown;
154
- timeZone?: unknown;
155
- };
156
- if (typeof slug !== "string") return { kind: "error" };
157
- const from = new Date();
158
- const to = new Date(from.getTime() + SLOT_WINDOW_DAYS * DAY_MS);
159
- const query = {
160
- slug,
161
- from: from.toISOString(),
162
- to: to.toISOString(),
163
- ...(typeof timeZone === "string" && timeZone !== "" ? { timeZone } : {}),
164
- };
165
- return runRead("readSlots", (init) => member.availability(query, init), ({ slots }) => ({ slots }));
166
- }
167
-
168
- export async function readRequestForm(): Promise<
169
- NewReadResult<{ form: MemberRequestFormResponse["form"] }>
170
- > {
171
- return runRead("readRequestForm", (init) => member.requestForm(init), ({ form }) => ({ form }));
172
- }
173
-
174
- // ── Writes (D6) — `(prev, formData)` for `useActionState` ───────────────────
175
-
176
- export async function sendMessage(
177
- _prev: NewActionState,
178
- formData: FormData,
179
- ): Promise<NewActionState> {
180
- if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
181
- const link = optional(formData, "link");
182
- const body = {
183
- subject: value(formData, "subject") ?? "",
184
- body: value(formData, "body") ?? "",
185
- ...(link === undefined ? {} : { link }),
186
- };
187
- return runWrite("sendMessage", (init) => member.sendMessage(body, init));
188
- }
189
-
190
- /** The answers are the entries named `answer.<field name>`; a blank one is omitted. */
191
- export async function requestQuote(
192
- _prev: NewActionState,
193
- formData: FormData,
194
- ): Promise<NewActionState> {
195
- if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
196
- const answers: Record<string, string> = {};
197
- for (const key of new Set(formData.keys())) {
198
- if (!key.startsWith("answer.")) continue;
199
- const answer = optional(formData, key);
200
- if (answer !== undefined) answers[key.slice("answer.".length)] = answer;
201
- }
202
- return runWrite("requestQuote", (init) => member.requestQuote({ answers }, init));
203
- }
204
-
205
- export async function bookService(
206
- _prev: NewActionState,
207
- formData: FormData,
208
- ): Promise<NewActionState> {
209
- if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
210
- const timeZone = optional(formData, "timeZone");
211
- const notes = optional(formData, "notes");
212
- const body = {
213
- slug: value(formData, "slug") ?? "",
214
- start: value(formData, "start") ?? "",
215
- ...(timeZone === undefined ? {} : { timeZone }),
216
- ...(notes === undefined ? {} : { notes }),
217
- };
218
- return runWrite("bookService", (init) => member.book(body, init));
219
- }