create-ailk 0.37.1 → 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 (230) 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 +18 -11
  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 +14 -1
  36. package/dist/sync-routes.js +86 -5
  37. package/dist/topology.d.ts +15 -1
  38. package/dist/topology.js +20 -4
  39. package/dist/update.d.ts +17 -2
  40. package/dist/update.js +480 -77
  41. package/package.json +3 -3
  42. package/templates/README.md +1 -1
  43. package/templates/apps/mcp/CLAUDE.md +5 -3
  44. package/templates/apps/web/CLAUDE.md +62 -20
  45. package/templates/apps/web/account.config.tsx +101 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  47. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  52. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  54. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  55. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  57. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  58. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  59. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  60. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  61. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  62. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  63. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  64. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  65. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  66. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  67. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  68. package/templates/apps/web/app/apple-icon.tsx +72 -0
  69. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  70. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  71. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  72. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  73. package/templates/apps/web/app/og/route.tsx +155 -72
  74. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  75. package/templates/apps/web/i18n/request.ts +44 -1
  76. package/templates/apps/web/jest.config.cjs +13 -1
  77. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  78. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  79. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  80. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  81. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  82. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  83. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  84. package/templates/apps/web/lib/listings.tsx +2 -2
  85. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  86. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  87. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  88. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  89. package/templates/apps/web/lib/served-pages.ts +95 -0
  90. package/templates/apps/web/lib/site-brand.tsx +3 -5
  91. package/templates/apps/web/messages/en.json +8 -684
  92. package/templates/apps/web/middleware.ts +3 -1
  93. package/templates/apps/web/next.config.mjs +27 -0
  94. package/templates/apps/web/package.json +1 -0
  95. package/templates/customizations.yaml +9 -0
  96. package/templates/package.json +3 -1
  97. package/templates/tools/lint-architecture.ts +164 -11
  98. package/versions.json +48 -47
  99. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  100. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  119. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  120. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  121. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  122. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  123. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  125. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  126. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  127. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  128. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  135. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  136. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  138. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  139. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  140. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  141. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  142. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  153. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  154. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  157. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  158. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  161. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  162. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  164. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  165. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  166. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  167. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  168. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  169. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  170. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  171. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  173. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  174. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  175. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  176. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  177. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  178. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  179. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  180. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  181. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  182. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  183. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  195. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  196. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  197. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  198. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  199. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  200. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  201. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  214. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  215. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  216. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  217. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  218. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  219. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  220. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  221. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  222. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  224. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  225. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  226. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  227. package/templates/apps/web/lib/account-config.ts +0 -678
  228. package/templates/apps/web/lib/checkout-config.ts +0 -16
  229. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  230. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,406 +1,3 @@
1
- /**
2
- * /[locale]/account/artifacts/[pieceId] — one artifact (#8234, spec
3
- * docs/specs/8234-member-artifacts-account-artifacts-and-spec.md D4).
4
- *
5
- * RSC, inside the account layout's SignedInShell, through the shared
6
- * `InboxItemFrame`: back to Artifacts, the title, the piece's stage as its
7
- * status (#11161 — the provider's own pipeline, read as on the list), the
8
- * review of the latest version as a tag beside it when there is one, and —
9
- * once approved — "Approved <date>". The body lists every served version in
10
- * the read's order, newest first: its number, its delivery date, its note,
11
- * the member's own review when there is one (a tag and the dated line), and
12
- * its action — Download for a file (re-served by
13
- * `versions/[version]/file/route.ts`) or View for an https link, opened in a
14
- * new tab. A link that is not https renders no action. The read serves no
15
- * deliverer (8169 D6), so none is shown.
16
- *
17
- * #11161 — an image or a PDF version renders INLINE above its Download
18
- * (`ArtifactVersionPreview`: the AssetLightbox for an image, the
19
- * document-viewer section for a PDF), from the same route asked to answer
20
- * inline (`?inline=1`), which it does for those two types only, under the
21
- * hub's sandbox CSP and `nosniff` (docs/security/member-artifact-preview.md).
22
- * Every other file keeps Download alone.
23
- *
24
- * Inside the latest version only: the review form while it is reviewable
25
- * (not approved, no review yet — `isReviewable`), else the waiting line once
26
- * the member asked for changes; nothing once approved. Nothing limits how
27
- * often: every new latest version is reviewable again (#8140 disposition 3).
28
- *
29
- * The artifact is found the way the Inbox item page finds its item: the
30
- * artifacts read runs (deduped per request) and `[pieceId]` is matched raw or
31
- * decoded. No session, no match or a 404 read is a not-found; any other
32
- * failed read renders the error row with Retry (spec 7423 D12). Titles,
33
- * notes and comments render as text only.
34
- *
35
- * A proposal (#8516, spec docs/specs/8516-proposals-as-an-artifact-kind-spec.md
36
- * D19) is the same page with its own words: the caption "Proposal", its
37
- * price ("Price <amount>", formatted from minor units), and the review form
38
- * as "Your decision on version <n>" with Approve proposal / Request changes.
39
- * In the latest version's place, once approved: Pay now (`pay-form.tsx`)
40
- * while the payment is due, "Paid <date>" once paid, and — back from
41
- * Stripe's success page (`?paid=1`) before the webhook lands — the pending
42
- * line instead of Pay now. A deliverable, or an older hub's artifact with
43
- * no `kind`, renders exactly as before.
44
- */
45
-
46
- import {
47
- ArtifactVersionPreview,
48
- InboxItemFrame,
49
- previewKind,
50
- type ArtifactVersionPreviewLabels,
51
- } from "@working-theory/templates/account";
52
- import { localeHref } from "@working-theory/ui";
53
- import {
54
- Badge,
55
- Button,
56
- Heading,
57
- Link,
58
- LocalTime,
59
- Text,
60
- } from "@working-theory/ui/primitives";
61
- import {
62
- isHttpsLink,
63
- type MemberArtifact,
64
- type MemberPieceVersion,
65
- } from "@working-theory/validation";
66
- import type { Metadata } from "next";
67
- import { notFound } from "next/navigation";
68
- import { getTranslations } from "next-intl/server";
69
- import type { ReactElement } from "react";
70
-
71
- import { accountSession, logReadFailure } from "../../account-data";
72
- import { ErrorRow } from "../../error-row";
73
- import {
74
- artifactStageLabel,
75
- artifactState,
76
- isProposal,
77
- isReviewable,
78
- loadArtifacts,
79
- paymentDue,
80
- STATE_KEYS,
81
- versionFileHref,
82
- versionPreviewHref,
83
- versionTypeKey,
84
- } from "../artifact-data";
85
-
86
- import { PayForm, type PayFormLabels } from "./pay-form";
87
- import { ReviewForm, type ReviewFormLabels } from "./review-form";
88
-
89
- interface Props {
90
- params: Promise<{ locale: string; pieceId: string }>;
91
- searchParams?: Promise<Record<string, string | string[] | undefined>>;
92
- }
93
-
94
- /**
95
- * A segment, percent-decoded when it decodes — matched in both forms, so an
96
- * id is found whether or not the framework already decoded it.
97
- */
98
- function decodeSegment(segment: string): string {
99
- try {
100
- return decodeURIComponent(segment);
101
- } catch {
102
- return segment;
103
- }
104
- }
105
-
106
- /**
107
- * A proposal's price in the reader's locale. The hub's answer is not parsed
108
- * here, so a currency Intl cannot format falls back to the amount and code
109
- * rather than erroring the page.
110
- */
111
- function formatPrice(
112
- price: { amount: number; currency: string },
113
- locale: string,
114
- ): string {
115
- try {
116
- return new Intl.NumberFormat(locale, {
117
- style: "currency",
118
- currency: price.currency.toUpperCase(),
119
- }).format(price.amount / 100);
120
- } catch {
121
- return `${String(price.amount / 100)} ${price.currency.toUpperCase()}`;
122
- }
123
- }
124
-
125
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
126
- const { locale } = await params;
127
- const t = await getTranslations({ locale, namespace: "account" });
128
- return { title: t("artifacts.title") };
129
- }
130
-
131
- export default async function AccountArtifactPage({
132
- params,
133
- searchParams,
134
- }: Props): Promise<ReactElement> {
135
- const { locale, pieceId: segment } = await params;
136
- const t = await getTranslations({ locale, namespace: "account" });
137
- const session = await accountSession(locale);
138
- if (!session) notFound();
139
-
140
- let artifacts: MemberArtifact[];
141
- try {
142
- artifacts = (await loadArtifacts(session.ctx)).items;
143
- } catch (err) {
144
- logReadFailure("artifacts", err);
145
- return (
146
- <div className="max-w-3xl py-8" data-testid="artifact">
147
- <ErrorRow
148
- message={t("artifacts.itemError")}
149
- retryLabel={t("artifacts.retry")}
150
- />
151
- </div>
152
- );
153
- }
154
-
155
- const artifact = artifacts.find(
156
- (candidate) =>
157
- candidate.id === segment || candidate.id === decodeSegment(segment),
158
- );
159
- if (!artifact) notFound();
160
-
161
- // #11175: every dated message carries a `<date>` tag, rendered through
162
- // `t.rich` as a `LocalTime` node — the server fallback zone in this RSC's
163
- // render, the viewer's own once the page hydrates.
164
- const dateTag = (iso: string): { date: () => ReactElement } => ({
165
- date: () => <LocalTime at={iso} preset="date" locale={locale} />,
166
- });
167
- const state = artifactState(artifact);
168
- const reviewTag = state === "ready" ? null : t(STATE_KEYS[state]);
169
- const reviewable = isReviewable(artifact);
170
- const latest = artifact.versions[0]!.version;
171
- const proposal = isProposal(artifact);
172
- const price =
173
- proposal && artifact.price ? formatPrice(artifact.price, locale) : null;
174
- const due = proposal && paymentDue(artifact);
175
- // Stripe's success page returns here with `?paid=1`; until the webhook
176
- // stamps the payment, the page says so instead of offering Pay now again.
177
- const returnedPaid = due && (await searchParams)?.paid === "1";
178
- const paidAt =
179
- proposal && artifact.payment?.status === "paid"
180
- ? artifact.payment.paidAt
181
- : null;
182
- const payLabels: PayFormLabels = {
183
- pay: t("artifacts.proposal.pay"),
184
- paying: t("artifacts.proposal.paying"),
185
- error: t("artifacts.proposal.payError"),
186
- };
187
- const labels: ReviewFormLabels = {
188
- heading: proposal
189
- ? t("artifacts.proposal.heading", { version: latest })
190
- : t("artifacts.review.heading", { version: latest }),
191
- comment: t("artifacts.review.comment"),
192
- commentHint: t("artifacts.review.commentHint"),
193
- approve: proposal
194
- ? t("artifacts.proposal.approve")
195
- : t("artifacts.review.approve"),
196
- requestChanges: t("artifacts.review.requestChanges"),
197
- submitting: t("artifacts.review.submitting"),
198
- sent: t("artifacts.review.sent"),
199
- errors: {
200
- comment_required: t("artifacts.review.errors.commentRequired"),
201
- closed: t("artifacts.review.errors.closed"),
202
- not_latest: t("artifacts.review.errors.notLatest"),
203
- rate_limited: t("artifacts.review.errors.rateLimited"),
204
- failed: t("artifacts.review.errors.failed"),
205
- payment_failed: t("artifacts.proposal.payError"),
206
- },
207
- };
208
-
209
- const previewLabels = (filename: string): ArtifactVersionPreviewLabels => ({
210
- open: t("artifacts.preview.open", { filename }),
211
- details: t("artifacts.preview.details"),
212
- filename: t("artifacts.preview.filename"),
213
- type: t("artifacts.preview.type"),
214
- zoomIn: t("artifacts.preview.zoomIn"),
215
- zoomOut: t("artifacts.preview.zoomOut"),
216
- copyLink: t("artifacts.preview.copyLink"),
217
- });
218
-
219
- // An image or a PDF version, inline (#11161); any other file has none.
220
- const versionPreview = (v: MemberPieceVersion): ReactElement | null => {
221
- if (v.file === null) return null;
222
- const kind = previewKind(v.file.contentType);
223
- if (kind === null) return null;
224
- return (
225
- <ArtifactVersionPreview
226
- kind={kind}
227
- src={versionPreviewHref(locale, artifact.id, v.version)}
228
- filename={v.file.filename}
229
- typeLabel={t(versionTypeKey(v))}
230
- labels={previewLabels(v.file.filename)}
231
- testIdPrefix={`artifact-version-${v.version}-preview`}
232
- />
233
- );
234
- };
235
-
236
- // The one action of a version: Download a file, View an https link, else none.
237
- const versionAction = (v: MemberPieceVersion): ReactElement | null => {
238
- if (v.file !== null) {
239
- return (
240
- <Button asChild variant="outline" className="max-md:min-h-11">
241
- <Link
242
- href={versionFileHref(locale, artifact.id, v.version)}
243
- variant="bare"
244
- data-testid={`artifact-version-${v.version}-download`}
245
- >
246
- {t("artifacts.download", { filename: v.file.filename })}
247
- </Link>
248
- </Button>
249
- );
250
- }
251
- if (isHttpsLink(v.link)) {
252
- return (
253
- <Button asChild variant="outline" className="max-md:min-h-11">
254
- <Link
255
- href={v.link}
256
- external
257
- variant="bare"
258
- data-testid={`artifact-version-${v.version}-view`}
259
- >
260
- {t("artifacts.view")}
261
- </Link>
262
- </Button>
263
- );
264
- }
265
- return null;
266
- };
267
-
268
- return (
269
- <InboxItemFrame
270
- back={{
271
- href: localeHref(locale, "/account/artifacts"),
272
- label: t("artifacts.back"),
273
- }}
274
- caption={
275
- proposal ? t("artifacts.proposal.caption") : t("artifacts.caption")
276
- }
277
- title={artifact.title}
278
- // An older hub serves no stage; the review tag alone then.
279
- status={artifactStageLabel(artifact) ?? undefined}
280
- tags={reviewTag === null ? [] : [reviewTag]}
281
- lead={
282
- artifact.approvedAt !== null
283
- ? t.rich("artifacts.approvedOn", dateTag(artifact.approvedAt))
284
- : null
285
- }
286
- testIdPrefix="artifact"
287
- >
288
- {price !== null ? (
289
- <div className="mt-block-tight" data-testid="artifact-price">
290
- <Text as="p" variant="body" className="font-semibold">
291
- {t("artifacts.proposal.price", { amount: price })}
292
- </Text>
293
- </div>
294
- ) : null}
295
- <section className="mt-block-loose">
296
- <Heading level={2} visual={4} className="!text-body font-semibold">
297
- {t("artifacts.versions")}
298
- </Heading>
299
- <div className="mt-block-tight flex flex-col gap-4">
300
- {artifact.versions.map((v) => {
301
- const action = versionAction(v);
302
- const preview = versionPreview(v);
303
- return (
304
- <div
305
- key={v.version}
306
- className="rounded-md border-hairline border-(--color-border) p-card"
307
- data-testid={`artifact-version-${v.version}`}
308
- >
309
- <Text as="p" variant="body" className="font-semibold">
310
- {t("artifacts.version", { version: v.version })}
311
- </Text>
312
- <Text as="p" variant="body-sm" tone="muted">
313
- {t.rich("artifacts.deliveredOn", dateTag(v.deliveredAt))}
314
- </Text>
315
- {v.note !== null ? (
316
- <Text
317
- as="p"
318
- variant="body-sm"
319
- className="mt-2 whitespace-pre-line"
320
- >
321
- {v.note}
322
- </Text>
323
- ) : null}
324
- {v.review !== null && v.reviewedAt !== null ? (
325
- <div className="mt-2">
326
- <Badge
327
- variant="outline"
328
- size="sm"
329
- className="mb-1"
330
- data-testid={`artifact-version-${v.version}-review`}
331
- >
332
- {v.review === "approved"
333
- ? t("artifacts.states.approved")
334
- : t("artifacts.states.changesRequested")}
335
- </Badge>
336
- <Text as="p" variant="body-sm" tone="muted">
337
- {v.review === "approved"
338
- ? t.rich("artifacts.reviewApproved", dateTag(v.reviewedAt))
339
- : t.rich(
340
- "artifacts.reviewChangesRequested",
341
- dateTag(v.reviewedAt),
342
- )}
343
- </Text>
344
- {v.reviewComment !== null ? (
345
- <Text
346
- as="p"
347
- variant="body-sm"
348
- className="whitespace-pre-line"
349
- >
350
- {v.reviewComment}
351
- </Text>
352
- ) : null}
353
- </div>
354
- ) : null}
355
- {preview !== null ? (
356
- <div className="mt-block-tight">{preview}</div>
357
- ) : null}
358
- {action !== null ? (
359
- <div className="mt-block-tight">{action}</div>
360
- ) : null}
361
- {v.version === latest && reviewable ? (
362
- <ReviewForm
363
- pieceId={artifact.id}
364
- version={v.version}
365
- labels={labels}
366
- pay={proposal ? payLabels : undefined}
367
- />
368
- ) : null}
369
- {v.version === latest && due && !returnedPaid ? (
370
- <PayForm pieceId={artifact.id} labels={payLabels} />
371
- ) : null}
372
- {v.version === latest && returnedPaid ? (
373
- <div
374
- className="mt-block-tight"
375
- data-testid="artifact-paid-pending"
376
- >
377
- <Text as="p" variant="body-sm">
378
- {t("artifacts.proposal.paidPending")}
379
- </Text>
380
- </div>
381
- ) : null}
382
- {v.version === latest && paidAt !== null ? (
383
- <div className="mt-block-tight" data-testid="artifact-paid">
384
- <Text as="p" variant="body-sm">
385
- {t.rich("artifacts.proposal.paid", dateTag(paidAt))}
386
- </Text>
387
- </div>
388
- ) : null}
389
- {v.version === latest && state === "changes-requested" ? (
390
- <div
391
- className="mt-block-tight"
392
- data-testid="artifact-review-waiting"
393
- >
394
- <Text as="p" variant="body-sm">
395
- {t("artifacts.review.waiting")}
396
- </Text>
397
- </div>
398
- ) : null}
399
- </div>
400
- );
401
- })}
402
- </div>
403
- </section>
404
- </InboxItemFrame>
405
- );
406
- }
1
+ // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
+ export { default } from "@working-theory/account/artifacts/[pieceId]/page";
3
+ export { generateMetadata } from "@working-theory/account/artifacts/[pieceId]/page";
@@ -1,190 +1,2 @@
1
- /**
2
- * A delivered version's file, re-served (#8234, spec
3
- * docs/specs/8234-member-artifacts-account-artifacts-and-spec.md D5) —
4
- * `GET /[locale]/account/artifacts/:pieceId/versions/:version/file`.
5
- *
6
- * A file version's Download on the artifact page links here. The browser
7
- * holds neither the client's hub credential nor this site's spoke key, so
8
- * this route reads `GET /v1/member/artifacts/:pieceId/versions/:version/file`
9
- * with `forwardedCookieInit()` — the caller's own credential, so a client
10
- * only ever gets their own file — and streams the bytes back unread. It
11
- * mirrors `inbox/message/[id]/file/route.ts`: an app route file is not a
12
- * shared module, so the header map and the refusal mapping are copied.
13
- *
14
- * SEC-7877-D (the obligation in `@working-theory/api-client`'s `member.ts`):
15
- * the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
16
- * `Content-Disposition` (attachment), `X-Content-Type-Options: nosniff`, the
17
- * sandbox `Content-Security-Policy` and `Cache-Control: private, no-store` —
18
- * so the file is never a document on this origin and never cached on the way.
19
- * A hub answer missing any of the five is refused 502 rather than served
20
- * without it — and so is one whose safety headers carry the wrong value
21
- * (#8320, #9965 D8): presence alone is not the hub's promise.
22
- *
23
- * #11161 — the preview mode, the one amendment to that obligation (recorded
24
- * in `docs/security/member-artifact-preview.md`): `?inline=1` asks for the
25
- * bytes as a document the artifact page can render in place. The route
26
- * answers `Content-Disposition: inline` ONLY when the hub's `Content-Type`
27
- * is `image/*` (never SVG) or `application/pdf`, with the download name the
28
- * hub pinned and the other four headers still unchanged — so the document
29
- * renders inside the sandbox CSP's opaque origin (no script, no cookie, no
30
- * same-origin access) and `nosniff` holds the type. Any other type, and
31
- * every request without the flag, is `attachment` exactly as the hub sent
32
- * it. The hub itself never answers inline.
33
- *
34
- * The params are shape-checked before any call (a malformed piece id or a
35
- * version that is not a whole number from 1 is a 404 with no call). A
36
- * refusal has no body: no credential (signed out) is a 401, a hub 4xx keeps
37
- * its status, and a hub 5xx, a transport the api-client refuses or a hub call
38
- * that throws is a 502.
39
- */
40
- import { member, type MemberFileHeaders } from "@working-theory/api-client";
41
- import { memberArtifactFileParamsSchema } from "@working-theory/validation";
42
-
43
- import { forwardedCookieInit } from "../../../../../../../../../lib/server-api";
44
-
45
- interface Context {
46
- params: Promise<{ locale: string; pieceId: string; version: string }>;
47
- }
48
-
49
- /** The response header each of the five hub headers goes out under. */
50
- const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
51
- contentType: "Content-Type",
52
- contentDisposition: "Content-Disposition",
53
- contentTypeOptions: "X-Content-Type-Options",
54
- contentSecurityPolicy: "Content-Security-Policy",
55
- cacheControl: "Cache-Control",
56
- };
57
-
58
- /**
59
- * HTTP's own whitespace — SP and HTAB, never JS `\s`. A browser reads any
60
- * other byte (a non-breaking space among them) as part of the token, so a
61
- * check that trimmed or split on it would pass a value it does not describe.
62
- */
63
- const HTTP_VALUE = /^[\t\x20-\x7e]*$/;
64
- const httpTrim = (value: string) => value.replace(/^[ \t]+|[ \t]+$/g, "");
65
-
66
- /**
67
- * #11161 — the two type families a preview may render inline: raster images
68
- * and PDF. SVG is refused by name (it is not attachable either, SEC-7877-D),
69
- * so a hub that ever stored one still serves it as an attachment.
70
- */
71
- export function isInlinePreviewType(contentType: string): boolean {
72
- const type = httpTrim(contentType.split(";")[0] ?? "").toLowerCase();
73
- return type === "application/pdf" || (type.startsWith("image/") && type !== "image/svg+xml");
74
- }
75
-
76
- /**
77
- * The CSP's directives by name, or `null` for two policies joined or a
78
- * directive named twice — a browser enforces the first copy, so a check that
79
- * read a later one could pass a policy it does not describe.
80
- */
81
- function cspDirectives(policy: string): Map<string, string> | null {
82
- // `Headers.get` joins two CSP headers with ", " — a second policy the hub
83
- // never sent (#9965 SEC-9965-16).
84
- if (policy.includes(",")) return null;
85
- const directives = new Map<string, string>();
86
- for (const part of policy.split(";")) {
87
- const [name = "", ...rest] = httpTrim(part).split(/[ \t]+/);
88
- if (!name) continue;
89
- if (directives.has(name)) return null;
90
- directives.set(name, rest.join(" "));
91
- }
92
- return directives;
93
- }
94
-
95
- /**
96
- * Whether each safety header carries the value the hub sends (D8). Every
97
- * comparison is case-insensitive and trimmed of SP and HTAB, and a value
98
- * carrying any byte outside visible ASCII, SP and HTAB is refused before it
99
- * is parsed. `Content-Type` is not checked: the other four contain it.
100
- */
101
- const SAFE_VALUE: Partial<
102
- Record<keyof MemberFileHeaders, (value: string) => boolean>
103
- > = {
104
- contentTypeOptions: (value) => value === "nosniff",
105
- contentDisposition: (value) => /^attachment[ \t]*(;|$)/.test(value),
106
- contentSecurityPolicy: (value) => {
107
- const directives = cspDirectives(value);
108
- const sandbox = directives?.get("sandbox");
109
- return (
110
- sandbox !== undefined &&
111
- !sandbox.split(" ").includes("allow-scripts") &&
112
- directives?.get("default-src") === "'none'"
113
- );
114
- },
115
- cacheControl: (value) => {
116
- const directives = value.split(",").map((part) => part.trim());
117
- return directives.includes("private") && directives.includes("no-store");
118
- },
119
- };
120
-
121
- function refusal(status: number): Response {
122
- return new Response(null, {
123
- status,
124
- headers: { "Cache-Control": "private, no-store" },
125
- });
126
- }
127
-
128
- /** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
129
- function refusalStatus(status: number, body: unknown): number {
130
- if (status === 0) {
131
- const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
132
- return code === "unauthorized" ? 401 : 502;
133
- }
134
- return status >= 500 ? 502 : status;
135
- }
136
-
137
- // platform-decisions-waiver: api-versioning — a page-scoped download link on the site's own account area, not an API contract; it re-serves the versioned hub route /v1/member/artifacts/:pieceId/versions/:version/file
138
- export async function GET(
139
- request: Request,
140
- { params }: Context,
141
- ): Promise<Response> {
142
- // Exactly the two segments the strict schema takes — `params` also carries `locale`.
143
- const { pieceId, version } = await params;
144
- const inline = new URL(request.url).searchParams.get("inline") === "1";
145
- const parsed = memberArtifactFileParamsSchema.safeParse({ pieceId, version });
146
- if (!parsed.success) return refusal(404);
147
-
148
- // The api-client throws, rather than answering `{ ok: false }`, on a
149
- // network failure or a redirect — that is a 502 too, never Next's own 500.
150
- let res: Awaited<ReturnType<typeof member.artifactFile>>;
151
- try {
152
- res = await member.artifactFile(
153
- parsed.data.pieceId,
154
- parsed.data.version,
155
- await forwardedCookieInit(),
156
- );
157
- } catch {
158
- return refusal(502);
159
- }
160
- if (!res.ok) return refusal(refusalStatus(res.status, res.body));
161
-
162
- const { stream, headers } = res.body;
163
- const out = new Headers();
164
- for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [
165
- keyof MemberFileHeaders,
166
- string,
167
- ][]) {
168
- const value = headers[key];
169
- const check = SAFE_VALUE[key];
170
- const safe =
171
- value !== null &&
172
- (check === undefined ||
173
- (HTTP_VALUE.test(value) && check(httpTrim(value).toLowerCase())));
174
- if (!safe) {
175
- await stream.cancel();
176
- return refusal(502);
177
- }
178
- out.set(name, value);
179
- }
180
- // #11161 — the preview mode: inline for an image or a PDF, the hub's
181
- // attachment disposition (already checked above) rewritten in place with
182
- // the same pinned filename; everything else stays an attachment.
183
- if (inline && headers.contentType !== null && isInlinePreviewType(headers.contentType)) {
184
- out.set(
185
- "Content-Disposition",
186
- (out.get("Content-Disposition") ?? "").replace(/^[ \t]*attachment/i, "inline"),
187
- );
188
- }
189
- return new Response(stream, { status: 200, headers: out });
190
- }
1
+ // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
+ export { GET } from "@working-theory/account/artifacts/[pieceId]/versions/[version]/file/route";