create-ailk 0.37.0 → 0.38.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 (232) hide show
  1. package/README.md +149 -2
  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 +7 -2
  6. package/dist/add-route.js +28 -13
  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 +9 -15
  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 +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +28 -1
  36. package/dist/sync-routes.js +144 -11
  37. package/dist/template-record.d.ts +11 -0
  38. package/dist/template-record.js +18 -0
  39. package/dist/topology.d.ts +15 -1
  40. package/dist/topology.js +20 -4
  41. package/dist/update.d.ts +31 -2
  42. package/dist/update.js +627 -99
  43. package/package.json +3 -3
  44. package/templates/README.md +1 -1
  45. package/templates/apps/mcp/CLAUDE.md +5 -3
  46. package/templates/apps/web/CLAUDE.md +62 -20
  47. package/templates/apps/web/account.config.tsx +101 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  51. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  54. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  57. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  58. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  59. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  60. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  61. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  62. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  63. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  64. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  65. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  66. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  67. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  68. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  69. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  70. package/templates/apps/web/app/apple-icon.tsx +72 -0
  71. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  72. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  73. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  74. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  75. package/templates/apps/web/app/og/route.tsx +155 -72
  76. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  77. package/templates/apps/web/i18n/request.ts +44 -1
  78. package/templates/apps/web/jest.config.cjs +13 -1
  79. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  80. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  81. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  82. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  83. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  84. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  85. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  86. package/templates/apps/web/lib/listings.tsx +2 -2
  87. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  88. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  89. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  90. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  91. package/templates/apps/web/lib/served-pages.ts +95 -0
  92. package/templates/apps/web/lib/site-brand.tsx +3 -5
  93. package/templates/apps/web/messages/en.json +8 -684
  94. package/templates/apps/web/middleware.ts +3 -1
  95. package/templates/apps/web/next.config.mjs +27 -0
  96. package/templates/apps/web/package.json +1 -0
  97. package/templates/customizations.yaml +9 -0
  98. package/templates/package.json +3 -1
  99. package/templates/tools/lint-architecture.ts +164 -11
  100. package/versions.json +48 -47
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  119. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  120. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  121. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  122. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  123. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  125. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  126. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  127. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  128. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  135. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  136. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  138. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  139. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  140. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  141. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  142. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  153. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  154. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  157. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  158. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  161. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  162. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  164. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  165. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  166. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  167. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  168. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  169. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  170. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  171. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  173. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  174. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  175. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  176. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  177. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  178. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  179. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  180. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  181. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  182. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  183. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  195. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  196. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  197. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  198. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  199. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  200. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  201. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  214. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  215. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  216. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  217. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  218. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  219. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  220. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  221. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  222. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  224. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  225. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  226. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  227. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  228. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  229. package/templates/apps/web/lib/account-config.ts +0 -678
  230. package/templates/apps/web/lib/checkout-config.ts +0 -16
  231. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  232. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,76 +0,0 @@
1
- /**
2
- * appointments/appointments-data.ts — the Appointments pages' reads and
3
- * helpers (#11154).
4
- *
5
- * The list and the booking page read the same offer, so the read lives here
6
- * (the `artifacts/artifact-data.ts` shape): `GET /v1/member/meeting-types`,
7
- * the types the provider offers its clients — `customerSlugs` ∩ `enabledSlugs`
8
- * (#11122 D6) — through `member.meetingTypes` with the caller's forwarded
9
- * credential. The account area's read rule is restated: a 404 (no tenancy
10
- * module, or a spoke route the hub does not admit) is "nothing offered"; a
11
- * 401 or 403 is the same while the person's email is unverified; anything
12
- * else throws, so the page shows its error row with Retry (spec 7423 D12),
13
- * never an empty list.
14
- *
15
- * The member read carries each type's Cal.com link (`calLink`, #11154), read
16
- * from the account handle on the server. The public meetings read is never
17
- * used: its Live set excludes the client-only slugs (#11122 D6), so it never
18
- * lists an offered type. A type with no link (the handle could not be read)
19
- * makes the booking page say it could not load.
20
- *
21
- * These are BASE files, like the New menu's (#8233 C1): the reads 404 on a
22
- * build without the scheduling module, so nothing here imports the module's
23
- * own `lib/meetings.tsx`.
24
- */
25
-
26
- import { member } from "@working-theory/api-client";
27
- import type { AccountContext } from "@working-theory/templates/account";
28
- import { localeHref } from "@working-theory/ui";
29
- import {
30
- meetingSlugSchema,
31
- type MemberMeetingType,
32
- } from "@working-theory/validation";
33
- import { formatMoney } from "@working-theory/web-i18n";
34
- import { cache } from "react";
35
-
36
- import { unwrapApiResult } from "../../../../../lib/server-api";
37
-
38
- /** The types the member may book, in the workspace's stored order. One read per request. */
39
- export const loadMeetingTypes = cache(
40
- async (ctx: AccountContext): Promise<MemberMeetingType[]> => {
41
- const res = await member.meetingTypes(ctx.init);
42
- if (!res.ok) {
43
- if (res.status === 404) return [];
44
- if (!ctx.user.emailVerified && (res.status === 401 || res.status === 403))
45
- return [];
46
- }
47
- return (await unwrapApiResult(Promise.resolve(res))).items;
48
- },
49
- );
50
-
51
- /**
52
- * Whether a segment can be a type's page: the one slug grammar, and no `.`
53
- * — a dotted path skips the middleware matcher, so its page would carry no
54
- * security headers (the `/meet/<slug>` rule, SEC-8843-F).
55
- */
56
- export function isTypePath(slug: string): boolean {
57
- return meetingSlugSchema.safeParse(slug).success && !slug.includes(".");
58
- }
59
-
60
- /** The booking page of one type. */
61
- export function appointmentHref(locale: string, slug: string): string {
62
- return localeHref(
63
- locale,
64
- `/account/appointments/${encodeURIComponent(slug)}`,
65
- );
66
- }
67
-
68
- /** A type's price in the reader's locale; none, or none to pay, reads `free`. */
69
- export function formatTypePrice(
70
- price: MemberMeetingType["price"],
71
- locale: string,
72
- free: string,
73
- ): string {
74
- if (price === undefined || price.amountMinor === 0) return free;
75
- return formatMoney(price.amountMinor, price.currency, locale);
76
- }
@@ -1,65 +0,0 @@
1
- "use client"; // holds the Pay now Server Action's state: its pending label and error line
2
-
3
- /**
4
- * PayForm — Pay now on an approved proposal (#8516, spec
5
- * docs/specs/8516-proposals-as-an-artifact-kind-spec.md D19). The artifact
6
- * page renders it in the latest version's place while the payment is due.
7
- *
8
- * One primary button and nothing else: no input of any kind, so no card,
9
- * number or expiry field can ever live here — the client pays on Stripe's
10
- * hosted Checkout page, which `payForProposal` redirects to. The piece goes
11
- * as the button's own name and value, and the amount is the API's, from the
12
- * stored proposal. A payment that could not open shows the error line; a
13
- * successful one never returns. Every string arrives through `labels`.
14
- */
15
-
16
- import { Button, InlineMessage } from "@working-theory/ui/primitives";
17
- import { useActionState, type ReactElement } from "react";
18
-
19
- import { payForProposal, type ProposalPayState } from "../artifact-actions";
20
-
21
- export interface PayFormLabels {
22
- pay: string;
23
- paying: string;
24
- error: string;
25
- }
26
-
27
- export function PayForm({
28
- pieceId,
29
- labels,
30
- }: {
31
- pieceId: string;
32
- labels: PayFormLabels;
33
- }): ReactElement {
34
- const [state, formAction, pending] = useActionState<
35
- ProposalPayState,
36
- FormData
37
- >(payForProposal, { kind: "idle" });
38
-
39
- return (
40
- <form
41
- action={formAction}
42
- className="mt-block-tight flex flex-col gap-4"
43
- data-testid="artifact-pay-form"
44
- >
45
- {state.kind === "error" ? (
46
- <InlineMessage variant="error" data-testid="artifact-pay-error">
47
- {labels.error}
48
- </InlineMessage>
49
- ) : null}
50
- <div>
51
- <Button
52
- type="submit"
53
- name="pieceId"
54
- value={pieceId}
55
- // The page's one primary action: a 44px target at every width.
56
- size="big"
57
- disabled={pending}
58
- data-testid="artifact-pay"
59
- >
60
- {pending ? labels.paying : labels.pay}
61
- </Button>
62
- </div>
63
- </form>
64
- );
65
- }
@@ -1,172 +0,0 @@
1
- "use client"; // submits through the review Server Action and shows its outcome
2
-
3
- /**
4
- * ReviewForm — Approve or Request changes on an artifact's latest version
5
- * (#8234, spec docs/specs/8234-member-artifacts-account-artifacts-and-spec.md
6
- * D7). The artifact page renders it only while that version is reviewable
7
- * (not approved, no review yet — `isReviewable`).
8
- *
9
- * The comment is controlled, so a refused review keeps what was typed
10
- * (AC-MAA-07). A review that went through shows the sent line and refreshes
11
- * the page once, which re-reads the artifact and shows Approved or the
12
- * waiting line in the form's place. Every string arrives through `labels`.
13
- *
14
- * A proposal (#8516, spec docs/specs/8516-proposals-as-an-artifact-kind-spec.md
15
- * D19) passes its own heading and Approve label, and `pay`: an approval
16
- * whose payment could not open (`payment_failed` — the review itself is
17
- * recorded) shows the error line and Pay now in the form's place, so the
18
- * client can try again at once. A deliverable passes no `pay` and renders
19
- * as before.
20
- */
21
-
22
- import {
23
- Button,
24
- Heading,
25
- InlineMessage,
26
- Label,
27
- Text,
28
- Textarea,
29
- } from "@working-theory/ui/primitives";
30
- import { REVIEW_COMMENT_MAX } from "@working-theory/validation";
31
- import { useRouter } from "next/navigation";
32
- import {
33
- useActionState,
34
- useEffect,
35
- useId,
36
- useState,
37
- type ReactElement,
38
- } from "react";
39
-
40
- import {
41
- submitArtifactReview,
42
- type ArtifactReviewReason,
43
- type ArtifactReviewState,
44
- } from "../artifact-actions";
45
-
46
- import { PayForm, type PayFormLabels } from "./pay-form";
47
-
48
- export interface ReviewFormLabels {
49
- heading: string;
50
- comment: string;
51
- commentHint: string;
52
- approve: string;
53
- requestChanges: string;
54
- submitting: string;
55
- sent: string;
56
- errors: Record<ArtifactReviewReason, string>;
57
- }
58
-
59
- export function ReviewForm({
60
- pieceId,
61
- version,
62
- labels,
63
- pay,
64
- }: {
65
- pieceId: string;
66
- version: number;
67
- labels: ReviewFormLabels;
68
- /** A proposal's Pay now labels, for an approval whose payment did not open. */
69
- pay?: PayFormLabels | undefined;
70
- }): ReactElement {
71
- const commentId = useId();
72
- const hintId = useId();
73
- const router = useRouter();
74
- const [comment, setComment] = useState("");
75
- const [state, formAction, pending] = useActionState<
76
- ArtifactReviewState,
77
- FormData
78
- >(submitArtifactReview, { kind: "idle" });
79
- const reviewed = state.kind === "reviewed";
80
-
81
- // Once per sent review: the page re-reads and replaces this form.
82
- useEffect(() => {
83
- if (reviewed) router.refresh();
84
- }, [reviewed, router]);
85
-
86
- if (
87
- pay !== undefined &&
88
- state.kind === "error" &&
89
- state.reason === "payment_failed"
90
- ) {
91
- return (
92
- <div className="mt-block-tight flex flex-col gap-4">
93
- <InlineMessage variant="error" data-testid="artifact-review-error">
94
- {labels.errors.payment_failed}
95
- </InlineMessage>
96
- <PayForm pieceId={pieceId} labels={pay} />
97
- </div>
98
- );
99
- }
100
-
101
- if (reviewed) {
102
- return (
103
- <InlineMessage
104
- variant="success"
105
- role="status"
106
- className="mt-block-tight text-body-sm"
107
- data-testid="artifact-review-sent"
108
- >
109
- {labels.sent}
110
- </InlineMessage>
111
- );
112
- }
113
-
114
- return (
115
- <form
116
- action={formAction}
117
- className="mt-block-tight flex flex-col gap-4"
118
- data-testid="artifact-review-form"
119
- >
120
- <Heading level={3} visual={4} className="!text-body font-semibold">
121
- {labels.heading}
122
- </Heading>
123
- <input type="hidden" name="pieceId" value={pieceId} />
124
- <input type="hidden" name="version" value={String(version)} />
125
- <div className="flex flex-col gap-2">
126
- <Label htmlFor={commentId}>{labels.comment}</Label>
127
- <Textarea
128
- id={commentId}
129
- name="comment"
130
- value={comment}
131
- rows={4}
132
- maxLength={REVIEW_COMMENT_MAX}
133
- aria-describedby={hintId}
134
- onChange={(event) => setComment(event.target.value)}
135
- data-testid="artifact-review-comment"
136
- />
137
- <Text as="p" id={hintId} variant="caption" tone="muted">
138
- {labels.commentHint}
139
- </Text>
140
- </div>
141
- {state.kind === "error" ? (
142
- <InlineMessage variant="error" data-testid="artifact-review-error">
143
- {labels.errors[state.reason]}
144
- </InlineMessage>
145
- ) : null}
146
- <div className="flex flex-wrap gap-2">
147
- <Button
148
- type="submit"
149
- name="review"
150
- value="approved"
151
- disabled={pending}
152
- // 44px on a phone (a touch-first context); the 36px default from md up.
153
- className="max-md:min-h-11"
154
- data-testid="artifact-review-approve"
155
- >
156
- {pending ? labels.submitting : labels.approve}
157
- </Button>
158
- <Button
159
- type="submit"
160
- name="review"
161
- value="changes-requested"
162
- variant="outline"
163
- disabled={pending}
164
- className="max-md:min-h-11"
165
- data-testid="artifact-review-request-changes"
166
- >
167
- {labels.requestChanges}
168
- </Button>
169
- </div>
170
- </form>
171
- );
172
- }
@@ -1,333 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
-
5
- /**
6
- * A delivered version's file, re-served (#8234, spec 8234 D5, AC-3;
7
- * SEC-7877-D) — `GET /[locale]/account/artifacts/:pieceId/versions/:version/file`.
8
- *
9
- * The api-client's `member.artifactFile` is the one external boundary
10
- * mocked; `forwardedCookieInit()` and the route's decisions are real (the
11
- * build's own sign-in, a single site: the caller's session cookie). Covers:
12
- * - the read carries exactly the piece id, the version as a number and the
13
- * caller's credential, and the bytes come back with all five hub headers
14
- * unchanged;
15
- * - a hub answer missing any of the five is refused 502, its stream
16
- * cancelled — never bytes on this origin without them;
17
- * - so is one carrying a safety header with the wrong value (#8320, #9965
18
- * D8): presence is not enough;
19
- * - malformed params are a 404 with no call — and `locale`, which Next
20
- * always passes, never makes a real request fail;
21
- * - refusals map to a status with no body and `private, no-store`;
22
- * - the preview mode (#11161 AC-4): `?inline=1` answers `inline` for an
23
- * image or a PDF only — the other four headers unchanged — and
24
- * `attachment` for every other type, and without the flag always;
25
- * - the route reads no topology constant.
26
- */
27
-
28
- import { readFileSync } from "node:fs";
29
- import { join } from "node:path";
30
-
31
- const mockArtifactFile = jest.fn();
32
- jest.mock("@working-theory/api-client", () => ({
33
- __esModule: true,
34
- member: { artifactFile: (...args: unknown[]) => mockArtifactFile(...args) },
35
- }));
36
-
37
- const mockHeaders = jest.fn();
38
- const mockCookies = jest.fn();
39
- jest.mock("next/headers", () => ({
40
- __esModule: true,
41
- headers: (...args: unknown[]) => mockHeaders(...args),
42
- cookies: (...args: unknown[]) => mockCookies(...args),
43
- }));
44
-
45
- import { previewKind } from "@working-theory/templates/account";
46
-
47
- import { GET, isInlinePreviewType } from "../[pieceId]/versions/[version]/file/route";
48
-
49
- const SITE = "https://site.example.com";
50
- const PIECE = "piece_01920000-0000-7000-8000-000000000001";
51
- const ROUTE_FILE = join(
52
- __dirname,
53
- "..",
54
- "[pieceId]",
55
- "versions",
56
- "[version]",
57
- "file",
58
- "route.ts",
59
- );
60
-
61
- const FILE_HEADERS = {
62
- contentType: "application/pdf",
63
- contentDisposition: 'attachment; filename="brief-v2.pdf"',
64
- contentTypeOptions: "nosniff",
65
- contentSecurityPolicy: "default-src 'none'; sandbox",
66
- cacheControl: "private, no-store",
67
- };
68
-
69
- function fileResult(
70
- headers: Partial<Record<keyof typeof FILE_HEADERS, string | null>> = {},
71
- ) {
72
- return {
73
- ok: true,
74
- body: {
75
- stream: new Response("%PDF-1.7 bytes").body,
76
- headers: { ...FILE_HEADERS, ...headers },
77
- },
78
- };
79
- }
80
-
81
- function get(pieceId = PIECE, version = "2", query = ""): Promise<Response> {
82
- return GET(
83
- new Request(
84
- `${SITE}/account/artifacts/${pieceId}/versions/${version}/file${query}`,
85
- ),
86
- {
87
- params: Promise.resolve({ locale: "en", pieceId, version }),
88
- },
89
- );
90
- }
91
-
92
- async function expectBodylessRefusal(
93
- res: Response,
94
- status: number,
95
- ): Promise<void> {
96
- expect(res.status).toBe(status);
97
- expect(res.headers.get("cache-control")).toBe("private, no-store");
98
- expect(res.headers.get("content-disposition")).toBeNull();
99
- await expect(res.text()).resolves.toBe("");
100
- }
101
-
102
- beforeEach(() => {
103
- mockHeaders.mockReset().mockResolvedValue(new Headers());
104
- mockCookies.mockReset().mockResolvedValue({ toString: () => "session=abc" });
105
- mockArtifactFile.mockReset().mockResolvedValue(fileResult());
106
- });
107
-
108
- describe("the version file read", () => {
109
- it("reads the file with the piece id, the version as a number and the caller's credential, and re-serves it with all five headers unchanged", async () => {
110
- const res = await get();
111
- expect(mockArtifactFile).toHaveBeenCalledTimes(1);
112
- expect(mockArtifactFile).toHaveBeenCalledWith(PIECE, 2, {
113
- headers: { cookie: "session=abc" },
114
- });
115
- expect(res.status).toBe(200);
116
- expect(res.headers.get("content-type")).toBe(FILE_HEADERS.contentType);
117
- expect(res.headers.get("content-disposition")).toBe(
118
- FILE_HEADERS.contentDisposition,
119
- );
120
- expect(res.headers.get("x-content-type-options")).toBe(
121
- FILE_HEADERS.contentTypeOptions,
122
- );
123
- expect(res.headers.get("content-security-policy")).toBe(
124
- FILE_HEADERS.contentSecurityPolicy,
125
- );
126
- expect(res.headers.get("cache-control")).toBe(FILE_HEADERS.cacheControl);
127
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
128
- });
129
-
130
- it("forwards the request's Origin with the cookie, as forwardedCookieInit builds it", async () => {
131
- mockHeaders.mockResolvedValue(new Headers({ origin: SITE }));
132
- await get();
133
- expect(mockArtifactFile).toHaveBeenCalledWith(PIECE, 2, {
134
- headers: { cookie: "session=abc", origin: SITE },
135
- });
136
- });
137
-
138
- it.each(Object.keys(FILE_HEADERS) as (keyof typeof FILE_HEADERS)[])(
139
- "refuses 502 with no bytes when the hub's answer lacks %s",
140
- async (name) => {
141
- const result = fileResult({ [name]: null });
142
- const cancel = jest.spyOn(result.body.stream as ReadableStream, "cancel");
143
- mockArtifactFile.mockResolvedValue(result);
144
- const res = await get();
145
- expect(cancel).toHaveBeenCalled();
146
- await expectBodylessRefusal(res, 502);
147
- },
148
- );
149
-
150
- it.each([
151
- [
152
- "an inline Content-Disposition",
153
- { contentDisposition: "inline; filename=a.pdf" },
154
- ],
155
- [
156
- "X-Content-Type-Options other than nosniff",
157
- { contentTypeOptions: "sniff" },
158
- ],
159
- [
160
- "a Content-Security-Policy with no sandbox",
161
- { contentSecurityPolicy: "default-src *" },
162
- ],
163
- [
164
- "a sandbox that allows scripts",
165
- { contentSecurityPolicy: "default-src 'none'; sandbox allow-scripts" },
166
- ],
167
- [
168
- "a sandbox with default-src other than 'none'",
169
- { contentSecurityPolicy: "default-src *; sandbox" },
170
- ],
171
- [
172
- "two CSP headers, joined (the hub's plus default-src *)",
173
- { contentSecurityPolicy: "default-src 'none'; sandbox, default-src *" },
174
- ],
175
- [
176
- "a repeated sandbox directive, whose first copy allows scripts",
177
- {
178
- contentSecurityPolicy:
179
- "sandbox allow-scripts; sandbox; default-src 'none'",
180
- },
181
- ],
182
- // HTTP whitespace is SP and HTAB only: a browser reads a non-breaking
183
- // space as part of the token, so a value JS would trim to the safe one
184
- // is not the safe one.
185
- [
186
- "an attachment Content-Disposition with a non-breaking space",
187
- { contentDisposition: "attachment\u00a0; filename=x.html" },
188
- ],
189
- [
190
- "nosniff followed by a non-breaking space",
191
- { contentTypeOptions: "nosniff\u00a0" },
192
- ],
193
- [
194
- "a CSP whose directives are split by non-breaking spaces",
195
- { contentSecurityPolicy: "default-src\u00a0'none'; sandbox\u00a0" },
196
- ],
197
- [
198
- "a public, cacheable Cache-Control",
199
- { cacheControl: "public, max-age=3600" },
200
- ],
201
- [
202
- "a Cache-Control without no-store",
203
- { cacheControl: "private, max-age=60" },
204
- ],
205
- ])("refuses 502 with no bytes on %s", async (_case, headers) => {
206
- const result = fileResult(headers);
207
- const cancel = jest.spyOn(result.body.stream as ReadableStream, "cancel");
208
- mockArtifactFile.mockResolvedValue(result);
209
- const res = await get();
210
- expect(cancel).toHaveBeenCalled();
211
- await expectBodylessRefusal(res, 502);
212
- });
213
-
214
- it("serves the hub's own attachment policy, compared case-insensitively", async () => {
215
- mockArtifactFile.mockResolvedValue(
216
- fileResult({
217
- contentDisposition: 'Attachment; filename="brief-v2.pdf"',
218
- contentTypeOptions: "NoSniff",
219
- contentSecurityPolicy:
220
- "default-src 'none'; sandbox; frame-ancestors 'none'; form-action 'none'; base-uri 'none'",
221
- cacheControl: "no-store, Private",
222
- }),
223
- );
224
- const res = await get();
225
- expect(res.status).toBe(200);
226
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
227
- });
228
-
229
- it.each([
230
- ["a version of 0", PIECE, "0"],
231
- ["a version that is not a number", PIECE, "abc"],
232
- ["a fractional version", PIECE, "1.5"],
233
- ["a malformed piece id", "x", "2"],
234
- ])("%s is a 404 with no call", async (_case, pieceId, version) => {
235
- const res = await get(pieceId, version);
236
- expect(mockArtifactFile).not.toHaveBeenCalled();
237
- await expectBodylessRefusal(res, 404);
238
- });
239
-
240
- it.each([
241
- ["a status-0 unauthorized (signed out)", 0, "unauthorized", 401],
242
- ["a status-0 insecure_transport", 0, "insecure_transport", 502],
243
- ["a hub 404", 404, "not_found", 404],
244
- ["a hub 403", 403, "forbidden", 403],
245
- ["a hub 500", 500, "internal", 502],
246
- ])("%s answers %#", async (_case, hubStatus, code, status) => {
247
- mockArtifactFile.mockResolvedValue({
248
- ok: false,
249
- status: hubStatus,
250
- body: { ok: false, error: { code, message: "x" } },
251
- });
252
- await expectBodylessRefusal(await get(), status);
253
- });
254
-
255
- it("a hub call that throws answers 502 with no body", async () => {
256
- mockArtifactFile.mockRejectedValue(new TypeError("fetch failed"));
257
- await expectBodylessRefusal(await get(), 502);
258
- });
259
-
260
- describe("the preview mode (#11161 AC-4)", () => {
261
- it.each([
262
- ["a PDF", "application/pdf"],
263
- ["a PNG", "image/png"],
264
- ["a JPEG with a parameter", "image/jpeg; charset=binary"],
265
- ])("?inline=1 answers %s inline, the pinned filename and the other four headers unchanged", async (_case, contentType) => {
266
- mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
267
- const res = await get(PIECE, "2", "?inline=1");
268
- expect(res.status).toBe(200);
269
- expect(res.headers.get("content-type")).toBe(contentType);
270
- expect(res.headers.get("content-disposition")).toBe('inline; filename="brief-v2.pdf"');
271
- expect(res.headers.get("x-content-type-options")).toBe("nosniff");
272
- expect(res.headers.get("content-security-policy")).toBe(FILE_HEADERS.contentSecurityPolicy);
273
- expect(res.headers.get("cache-control")).toBe("private, no-store");
274
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
275
- });
276
-
277
- it.each([
278
- ["SVG", "image/svg+xml"],
279
- ["HTML", "text/html"],
280
- ["a zip", "application/zip"],
281
- ["an octet stream", "application/octet-stream"],
282
- ])("?inline=1 keeps %s an attachment", async (_case, contentType) => {
283
- mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
284
- const res = await get(PIECE, "2", "?inline=1");
285
- expect(res.status).toBe(200);
286
- expect(res.headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
287
- });
288
-
289
- it("without the flag, a PDF stays an attachment; another value of the flag is no flag", async () => {
290
- expect((await get()).headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
291
- expect((await get(PIECE, "2", "?inline=true")).headers.get("content-disposition")).toBe(
292
- FILE_HEADERS.contentDisposition,
293
- );
294
- });
295
-
296
- it("the preview mode still refuses a hub answer that is not an attachment — it rewrites the checked value, never trusts an inline one", async () => {
297
- const result = fileResult({ contentDisposition: "inline; filename=a.pdf" });
298
- mockArtifactFile.mockResolvedValue(result);
299
- await expectBodylessRefusal(await get(PIECE, "2", "?inline=1"), 502);
300
- });
301
-
302
- it.each([
303
- "application/pdf",
304
- "Application/PDF",
305
- " image/png ",
306
- "image/jpeg; charset=binary",
307
- "image/webp",
308
- "image/svg+xml",
309
- "image/svg+xml;charset=utf-8",
310
- "text/html",
311
- "application/pdfx",
312
- "application/zip",
313
- "",
314
- ])("the page's previewKind agrees with the route's inline predicate on %j", (contentType) => {
315
- expect(previewKind(contentType) !== null).toBe(isInlinePreviewType(contentType));
316
- });
317
-
318
- it("isInlinePreviewType admits image/* but SVG and application/pdf, case-insensitively, and nothing else", () => {
319
- expect(isInlinePreviewType("application/pdf")).toBe(true);
320
- expect(isInlinePreviewType("Application/PDF")).toBe(true);
321
- expect(isInlinePreviewType("image/webp")).toBe(true);
322
- expect(isInlinePreviewType("image/svg+xml")).toBe(false);
323
- expect(isInlinePreviewType("text/html")).toBe(false);
324
- expect(isInlinePreviewType("application/pdfx")).toBe(false);
325
- });
326
- });
327
-
328
- it("reads no topology constant", () => {
329
- expect(readFileSync(ROUTE_FILE, "utf8")).not.toContain(
330
- "topology.generated",
331
- );
332
- });
333
- });