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,15 +1,28 @@
1
1
  /**
2
2
  * Universal OG image route — /og?title=...&schemaType=...
3
3
  *
4
+ * The `card` share style (#11244): a 1200×630 card built from the site's
5
+ * brand — its photo (a Person site's `siteIdentity.image`) or else its brand
6
+ * mark, the page title set large, and the site name and domain. It replaced
7
+ * the plain brand-colour block with the title on it.
8
+ *
4
9
  * Design decisions (per spec § 3):
5
10
  * - next/og ImageResponse at 1200×630 (Open Graph standard)
6
11
  * - System sans-serif only — no .ttf fetches (the #1 source of OG bugs)
7
- * - force-static: Vercel caches generated images at the edge after first request
12
+ * - Node.js runtime (#11244, was edge): the card reads the site's own name,
13
+ * photo and mark from `content/_site.mdx` and `public/`, which the edge
14
+ * runtime has no filesystem for. Only the title and type come from the
15
+ * query; no image URL does, so the route fetches nothing a link names —
16
+ * only the operator's own photo URL and its own origin's mark.
17
+ * - force-dynamic: the card is drawn from its query (#11239 — each page links
18
+ * /og?title=<page title>&schemaType=<type>); force-static handed the handler
19
+ * an empty query, so every page's card read the site name. Each distinct
20
+ * URL is cached for a day (CARD_CACHE_CONTROL) in place of ImageResponse's
21
+ * production default, max-age=0.
22
+ * - Text is fg on the bg surface; the brand fill is an accent rule only — the
23
+ * fills-only pairing.
8
24
  * - Fallback strategy: on any ImageResponse throw, return a 302 redirect to
9
- * /og-default.png (the static PNG in apps/web/public/). The redirect is
10
- * edge-compatible (no fs access needed) and exposing the fallback URL is
11
- * acceptable per spec § 3 ("redirecting is simpler but exposes the fallback URL;
12
- * both acceptable"). Chosen over stream-bytes because edge runtime has no fs.
25
+ * /og-default.png (the static PNG in apps/web/public/).
13
26
  *
14
27
  * Sanitization:
15
28
  * - Strip control characters \x00–\x1F and \x7F from title and schemaType
@@ -22,124 +35,194 @@
22
35
  * a JSX tree to PNG — it reads only inline styles, supports no stylesheet or
23
36
  * Tailwind classes, and cannot render @working-theory/ui components.
24
37
  */
38
+ import { readFileSync } from "node:fs";
39
+ import { extname, join, resolve, sep } from "node:path";
40
+
25
41
  import { clientError } from "@working-theory/page-renderer/edge";
42
+ import { BrandLogomarkSchema } from "@working-theory/site-config/schema";
26
43
  import { tokens } from "@working-theory/theme";
27
44
  import { ImageResponse } from "next/og";
45
+ import { parse as parseYaml } from "yaml";
46
+
47
+ import {
48
+ resolveContentRoot,
49
+ SITE_BASE_URL,
50
+ SITE_LOGOMARK,
51
+ SITE_NAME,
52
+ } from "../../lib/site-brand";
28
53
 
29
- export const runtime = "edge";
30
- export const dynamic = "force-static";
54
+ export const runtime = "nodejs";
55
+ export const dynamic = "force-dynamic";
31
56
 
32
57
  // Strips C0 control characters (U+0000–U+001F) and DEL (U+007F).
33
58
  // eslint-disable-next-line no-control-regex
34
59
  const CONTROL_CHAR_RE = new RegExp("[\u0000-\u001F\u007F]", "g");
35
60
 
36
61
  const SYSTEM_FONT = "system-ui, -apple-system, sans-serif";
62
+ const CARD_CACHE_CONTROL = "public, max-age=86400, s-maxage=86400";
63
+ const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
64
+ const MIME: Record<string, string> = {
65
+ ".svg": "image/svg+xml",
66
+ ".png": "image/png",
67
+ ".jpg": "image/jpeg",
68
+ ".jpeg": "image/jpeg",
69
+ ".webp": "image/webp",
70
+ };
37
71
 
38
72
  function sanitize(raw: string, cap: number): string {
39
73
  return raw.replace(CONTROL_CHAR_RE, "").slice(0, cap);
40
74
  }
41
75
 
42
76
  function serveFallback(): Response {
43
- // 302 redirect to the static PNG served by Next.js from /public.
44
- // Edge-compatible: no fs access required.
45
- // Using new Response + Location header instead of Response.redirect() because
46
- // Response.redirect() requires an absolute URL in the Fetch API spec, but
47
- // relative redirects work correctly in Next.js edge middleware at runtime.
77
+ // A relative Location: Response.redirect() needs an absolute URL, and the
78
+ // static PNG is served from /public on the request's own origin.
48
79
  return new Response(null, {
49
80
  status: 302,
50
81
  headers: { Location: "/og-default.png" },
51
82
  });
52
83
  }
53
84
 
54
- export async function GET(request: Request): Promise<Response> {
55
- const { searchParams } = new URL(request.url);
85
+ /** A Person site's photo — `siteIdentity.image`, an https URL — if it has one. */
86
+ function sitePhotoUrl(): string | undefined {
87
+ try {
88
+ const raw = readFileSync(join(resolveContentRoot(), "_site.mdx"), "utf8");
89
+ const parsed: unknown = parseYaml(FRONTMATTER_RE.exec(raw)?.[1] ?? "");
90
+ const identity = (parsed as { siteIdentity?: { kind?: unknown; image?: unknown } } | null)
91
+ ?.siteIdentity;
92
+ const image = identity?.kind === "Person" ? identity.image : undefined;
93
+ return typeof image === "string" && /^https:\/\//.test(image) ? image : undefined;
94
+ } catch {
95
+ return undefined;
96
+ }
97
+ }
56
98
 
57
- const rawTitle = searchParams.get("title") ?? "";
58
- const rawSchemaType = searchParams.get("schemaType") ?? "";
99
+ /** The site's brand mark's path under `public/`: `brand.logomark.light`, else /logomark.svg. */
100
+ function siteMarkPath(): string | undefined {
101
+ try {
102
+ return SITE_LOGOMARK === undefined
103
+ ? "/logomark.svg"
104
+ : BrandLogomarkSchema.parse(SITE_LOGOMARK).light;
105
+ } catch {
106
+ return undefined;
107
+ }
108
+ }
59
109
 
60
- // #4157 — env-var override only, no `lib/site-brand.tsx` import: this
61
- // route runs in the Edge runtime (`export const runtime = "edge"` above),
62
- // which has no filesystem, so it cannot read `content/_site.mdx` the way
63
- // the other five #4157 sites do (all Node.js runtime). The fallback is
64
- // therefore a neutral, non-vendor default rather than the site's actual
65
- // resolved identity — set NEXT_PUBLIC_SITE_NAME / NEXT_PUBLIC_SITE_WORDMARK
66
- // to override it. See docs/specs/4157-scaffold-brand-defaults-spec.md
67
- // § Design Decisions (D2).
68
- const siteName = process.env.NEXT_PUBLIC_SITE_NAME ?? "My Site";
69
- const wordmark = process.env.NEXT_PUBLIC_SITE_WORDMARK ?? "example.com";
110
+ /**
111
+ * An image as a data URI, read before the card renders: Satori fetches an
112
+ * `<img>` while the response streams, after this handler's try/catch, so a
113
+ * dead or slow image would break the card rather than drop out of it. A site
114
+ * path is read from `public/` (never outside it), else fetched from the
115
+ * site's own `SITE_BASE_URL` — never the request's Host, which the caller
116
+ * picks — since a serverless bundle may not carry `public/`. Any
117
+ * failure, or more than two seconds, is `undefined`.
118
+ */
119
+ async function imageDataUri(src: string): Promise<string | undefined> {
120
+ if (src.startsWith("/") && !src.startsWith("//")) {
121
+ const type = MIME[extname(src).toLowerCase()];
122
+ if (type === undefined) return undefined;
123
+ const root = resolve(process.cwd(), "public");
124
+ const file = resolve(root, `.${src}`);
125
+ if (!file.startsWith(root + sep)) return undefined;
126
+ try {
127
+ return `data:${type};base64,${readFileSync(file).toString("base64")}`;
128
+ } catch {
129
+ return fetchDataUri(new URL(src, SITE_BASE_URL).href);
130
+ }
131
+ }
132
+ return /^https:\/\//.test(src) ? fetchDataUri(src) : undefined;
133
+ }
70
134
 
71
- const title = sanitize(rawTitle || siteName, 200);
72
- const schemaType = rawSchemaType ? sanitize(rawSchemaType, 50) : "";
135
+ async function fetchDataUri(url: string): Promise<string | undefined> {
136
+ try {
137
+ const res = await fetch(url, { signal: AbortSignal.timeout(2000) });
138
+ const type = res.headers.get("content-type")?.split(";")[0]?.trim() ?? "";
139
+ if (!res.ok || !Object.values(MIME).includes(type)) return undefined;
140
+ return `data:${type};base64,${Buffer.from(await res.arrayBuffer()).toString("base64")}`;
141
+ } catch {
142
+ return undefined;
143
+ }
144
+ }
145
+
146
+ function siteDomain(): string {
147
+ try {
148
+ return new URL(SITE_BASE_URL).host;
149
+ } catch {
150
+ return SITE_BASE_URL;
151
+ }
152
+ }
153
+
154
+ export async function GET(request: Request): Promise<Response> {
155
+ const { searchParams } = new URL(request.url);
156
+
157
+ const title = sanitize(searchParams.get("title") || SITE_NAME, 200);
158
+ const schemaType = sanitize(searchParams.get("schemaType") ?? "", 50);
73
159
 
74
160
  // Post-sanitization empty title → fallback
75
161
  if (!title) {
76
162
  return serveFallback();
77
163
  }
78
164
 
165
+ const colors = tokens.colors.light;
166
+ const photoUrl = sitePhotoUrl();
167
+ const photo = photoUrl === undefined ? undefined : await imageDataUri(photoUrl);
168
+ const markPath = photo === undefined ? siteMarkPath() : undefined;
169
+ const mark = markPath === undefined ? undefined : await imageDataUri(markPath);
170
+
79
171
  try {
80
172
  return new ImageResponse(
81
173
  <div
174
+ data-card="share"
175
+ data-schema-type={schemaType || undefined}
82
176
  style={{
83
177
  display: "flex",
84
- flexDirection: "column",
85
- justifyContent: "center",
86
- alignItems: "flex-start",
87
178
  width: "100%",
88
179
  height: "100%",
89
- backgroundColor: tokens.colors.light.brand,
90
- padding: "80px",
180
+ backgroundColor: colors.bg,
91
181
  fontFamily: SYSTEM_FONT,
92
- position: "relative",
93
182
  }}
94
183
  >
95
- {schemaType ? (
184
+ <div style={{ display: "flex", width: "16px", height: "100%", backgroundColor: colors.brand }} />
185
+ <div
186
+ style={{
187
+ display: "flex",
188
+ flexDirection: "column",
189
+ justifyContent: "space-between",
190
+ flex: 1,
191
+ padding: "72px 80px",
192
+ }}
193
+ >
194
+ <div style={{ display: "flex", alignItems: "center", gap: "20px" }}>
195
+ {mark ? <img src={mark} alt="" width={64} height={64} /> : null}
196
+ <div style={{ color: colors.fg, fontSize: "30px", fontWeight: 600 }}>{SITE_NAME}</div>
197
+ </div>
96
198
  <div
97
199
  style={{
98
- position: "absolute",
99
- top: "48px",
100
- right: "48px",
101
- backgroundColor: "rgba(0,0,0,0.25)",
102
- color: tokens.colors.light.fg,
103
- borderRadius: "9999px",
104
- padding: "6px 18px",
105
- fontSize: "18px",
106
- fontFamily: SYSTEM_FONT,
200
+ display: "flex",
201
+ color: colors.fg,
202
+ fontSize: title.length > 60 ? "60px" : "76px",
203
+ fontWeight: 700,
204
+ lineHeight: 1.1,
205
+ letterSpacing: "-0.02em",
107
206
  }}
108
207
  >
109
- {schemaType}
208
+ {title}
110
209
  </div>
111
- ) : null}
112
-
113
- <div
114
- style={{
115
- color: tokens.colors.light.fg,
116
- fontSize: "56px",
117
- fontWeight: 700,
118
- lineHeight: 1.1,
119
- maxWidth: "880px",
120
- fontFamily: SYSTEM_FONT,
121
- }}
122
- >
123
- {title}
124
- </div>
125
-
126
- <div
127
- style={{
128
- position: "absolute",
129
- bottom: "48px",
130
- right: "48px",
131
- color: tokens.colors.light.fg,
132
- fontSize: "24px",
133
- opacity: 0.75,
134
- fontFamily: SYSTEM_FONT,
135
- }}
136
- >
137
- {wordmark}
210
+ <div style={{ color: colors.textMuted, fontSize: "26px" }}>{siteDomain()}</div>
138
211
  </div>
212
+ {photo ? (
213
+ <img
214
+ src={photo}
215
+ alt=""
216
+ width={420}
217
+ height={630}
218
+ style={{ width: "420px", height: "630px", objectFit: "cover" }}
219
+ />
220
+ ) : null}
139
221
  </div>,
140
222
  {
141
223
  width: 1200,
142
224
  height: 630,
225
+ headers: { "Cache-Control": CARD_CACHE_CONTROL },
143
226
  },
144
227
  );
145
228
  } catch (err) {
@@ -12,6 +12,18 @@
12
12
  import type { ContentAdapter } from "@working-theory/content-adapters";
13
13
  import type { SiteListing } from "@working-theory/page-renderer";
14
14
 
15
+ // The site's own flags and listing are per-site files (`create-ailk` writes
16
+ // the flags; the listing is site-owned): this suite tests a site with public
17
+ // pages and the empty listing, never the site's own values (#11246).
18
+ // eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
19
+ jest.mock("../../../lib/modules.generated", () => ({
20
+ __esModule: true,
21
+ ...jest.requireActual<object>("../../../lib/modules.generated"),
22
+ PUBLIC_PAGES: true,
23
+ }));
24
+ // eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
25
+ jest.mock("../../../lib/site-listing", () => ({ __esModule: true, SITE_LISTING: {} }));
26
+
15
27
  import { createSitemapHandler } from "../route";
16
28
 
17
29
  const BASE = "https://example.com";
@@ -12,11 +12,31 @@
12
12
  // into plain objects, takes only string leaves and skips prototype keys, so
13
13
  // it can neither mutate the imported catalog nor pollute `Object.prototype`.
14
14
  //
15
+ // A page package's catalog (#11219, ADR 0040 rule 5) is added the same way,
16
+ // before the overlay: `@working-theory/account` ships the `account` keys its
17
+ // pages read, and a key this site's catalog carries is the site's override.
18
+ // `@working-theory/ui-signal-collectors` ships the `flow` and `flowVerify`
19
+ // keys of the flows pages (#11251 D6), `@working-theory/ui-scheduling` the
20
+ // `schedule` keys of the booking pages (#11252 D4),
21
+ // `@working-theory/ui-commerce` the `checkoutThankYou`, `checkoutUnavailable`
22
+ // and `purchase` keys of the checkout and purchase pages (#11253 D4), and
23
+ // `@working-theory/ui-docs-blog` the `docs` and `blog` keys of the docs and
24
+ // blog pages (#11254 D4), each read through the paid-sections registry, whose
25
+ // stub answers `null` on a site without the module.
26
+ //
15
27
  // Spec: docs/internal/specs/i18n-phase1-s2-next-intl-foundation-spec.md
16
28
 
29
+ import { accountMessages } from "@working-theory/account";
17
30
  import type { AbstractIntlMessages } from "next-intl";
18
31
  import { getRequestConfig } from "next-intl/server";
19
32
 
33
+ import {
34
+ loadUiCommerce,
35
+ loadUiDocsBlog,
36
+ loadUiScheduling,
37
+ loadUiSignalCollectors,
38
+ } from "../lib/paid-sections.generated";
39
+
20
40
  const DEFAULT_LOCALE = "en";
21
41
 
22
42
  const UNSAFE_KEYS: ReadonlySet<string> = new Set([
@@ -76,9 +96,32 @@ export default getRequestConfig(async ({ requestLocale }) => {
76
96
  messages = (fallback.default ?? fallback) as AbstractIntlMessages;
77
97
  }
78
98
 
99
+ // #11219 (ADR 0040 rule 5) — a page package's catalog ships with the
100
+ // package; this site's catalog holds overrides only, so the package's keys
101
+ // are added under it and a key the site carries keeps the site's value.
102
+ const packaged = accountMessages(locale) ?? accountMessages(DEFAULT_LOCALE) ?? {};
103
+ const signalCollectors = await loadUiSignalCollectors();
104
+ const flows =
105
+ signalCollectors?.flowsMessages(locale) ?? signalCollectors?.flowsMessages(DEFAULT_LOCALE) ?? {};
106
+ const scheduling = await loadUiScheduling();
107
+ const schedule =
108
+ scheduling?.schedulingMessages(locale) ?? scheduling?.schedulingMessages(DEFAULT_LOCALE) ?? {};
109
+ const commerce = await loadUiCommerce();
110
+ const checkout = commerce?.commerceMessages(locale) ?? commerce?.commerceMessages(DEFAULT_LOCALE) ?? {};
111
+ const docsBlog = await loadUiDocsBlog();
112
+ const docsAndBlog =
113
+ docsBlog?.docsBlogMessages(locale) ?? docsBlog?.docsBlogMessages(DEFAULT_LOCALE) ?? {};
114
+ const withPackages = mergeAddOnly(
115
+ mergeAddOnly(
116
+ mergeAddOnly(mergeAddOnly(mergeAddOnly(messages as Catalog, packaged), flows), schedule),
117
+ checkout,
118
+ ),
119
+ docsAndBlog,
120
+ );
121
+
79
122
  const overlay = await loadSiteOverlay(locale);
80
123
  return {
81
124
  locale,
82
- messages: mergeAddOnly(messages, overlay) as AbstractIntlMessages,
125
+ messages: mergeAddOnly(withPackages, overlay) as AbstractIntlMessages,
83
126
  };
84
127
  });
@@ -1,7 +1,7 @@
1
1
  // Mirrors apps/api's ts-jest setup (CONVENTIONS.md mentions Vitest aspirationally,
2
2
  // but no Vitest is installed anywhere yet). JSDOM env so RTL can mount components.
3
3
  /**
4
- * #10699 D4: lib/runtime-source.ts derives the toc through
4
+ * #10699 D4: the runtime source (moved into the docs-blog package by #11254) derives the toc through
5
5
  * fumadocs-core/content/toc, whose remark closure ships ESM only. These are
6
6
  * pnpm-store name prefixes (the `tools/jest/mdxeditor-esm.cjs` shape, inlined
7
7
  * because a scaffold's copy of this file has no `tools/`): `mdast-util-`
@@ -139,6 +139,18 @@ module.exports = {
139
139
  // The Edge-safe `./stealth` subpath (#8511) → source, like the root entry.
140
140
  "^@working-theory/web-i18n/stealth$":
141
141
  "<rootDir>/node_modules/@working-theory/web-i18n/dist/stealth-metadata.js",
142
+ // #11219 (ADR 0040) — the account page package's site seam resolves to
143
+ // this app's account.config.tsx, as next.config.mjs aliases it. The
144
+ // package itself needs no mapper: it ships TypeScript source and its
145
+ // `exports` name the files, so node resolution lands on them and ts-jest
146
+ // compiles them like this app's own.
147
+ "^@working-theory/account/site$": "<rootDir>/account.config.tsx",
148
+ // The package's modules resolve `next/headers` and `better-auth/react`
149
+ // from their own install, a second physical copy of each (the #5025
150
+ // class above), so a test's `jest.mock()` of either would miss them.
151
+ // Collapse every copy onto the one this app resolves.
152
+ "^next/headers$": require.resolve("next/headers"),
153
+ "^better-auth/react$": require.resolve("better-auth/react"),
142
154
  // The dependency-free tenancy-constants subpath (database/tenancy.ts).
143
155
  // Mapped to source like every sibling above; `database/dist` is not
144
156
  // built in this workspace pre-`pnpm build`.
@@ -180,6 +180,17 @@ async function runFlow(): Promise<Flow> {
180
180
  };
181
181
  }
182
182
 
183
+ // The hub topology this flow tests, never the site's generated seam
184
+ // (#11246): the child process has no jest.mock, so the seam's module slot is
185
+ // filled with the site-provider fixture before `auth.ts` first requires it.
186
+ const seamPath = require.resolve("../topology.generated");
187
+ const { siteTopology } =
188
+ require("./fixtures/site-topology") as typeof import("./fixtures/site-topology");
189
+ require.cache[seamPath] = Object.assign(new Module(seamPath), {
190
+ filename: seamPath,
191
+ loaded: true,
192
+ exports: siteTopology(),
193
+ });
183
194
  const { createAuth } = require("../../auth") as typeof import("../../auth");
184
195
  const { consent } =
185
196
  require("@working-theory/api-client") as typeof import("@working-theory/api-client");
@@ -0,0 +1,70 @@
1
+ // site-topology.ts — the hub render of `lib/topology.generated.ts`, for a
2
+ // suite that tests the site sign-in provider (#11246).
3
+ //
4
+ // The generated seam is written per site: `SIGN_IN_PROVIDER` is `"hub"` on
5
+ // every spoke that signs in through its hub, so a suite that reads the real
6
+ // file tests whichever topology the site happens to be. A suite written for
7
+ // the site provider mocks the seam with this instead:
8
+ //
9
+ // jest.mock("<…>/lib/topology.generated", () =>
10
+ // jest.requireActual("<…>/lib/__tests__/fixtures/site-topology").siteTopology(),
11
+ // );
12
+ //
13
+ // Every value is create-ailk's hub render (`renderWebSeam("hub")` in
14
+ // packages/create-ailk/src/topology.ts — keep the two in step); the
15
+ // return type is the seam's own, so a new seam export fails `tsc` here until
16
+ // it is added. The readers load `auth.ts` only when called, as the hub render
17
+ // does, so a suite's own `auth` mock answers them.
18
+ import type * as Seam from "../../topology.generated";
19
+
20
+ export function siteTopology(): typeof Seam & { __esModule: true } {
21
+ return {
22
+ __esModule: true,
23
+ TOPOLOGY: "hub",
24
+ UNSERVED_MCP_TOOLS: [],
25
+ SIGN_IN_ENABLED: true,
26
+ SIGN_IN_PROVIDER: "site",
27
+ SIGN_IN_PATH: "/sign-in",
28
+ SIGN_UP_PATH: "/sign-up",
29
+ SIGN_OUT_ENDPOINT: null,
30
+ async readSession(headers) {
31
+ const { auth } = await import("../../../auth");
32
+ return auth.api.getSession({ headers });
33
+ },
34
+ async readOwnAccounts(headers) {
35
+ const { auth } = await import("../../../auth");
36
+ return auth.api.listUserAccounts({ headers });
37
+ },
38
+ async readPhoneStep(headers) {
39
+ const { auth } = await import("../../../auth");
40
+ const api: object = auth.api;
41
+ const available = "sendPhoneNumberOTP" in api;
42
+ if (!available) return { available, phone: null };
43
+ const session = await auth.api.getSession({ headers });
44
+ const user = (session?.user ?? {}) as {
45
+ phoneNumber?: unknown;
46
+ phoneNumberVerified?: unknown;
47
+ };
48
+ const phone =
49
+ typeof user.phoneNumber === "string" && user.phoneNumber !== ""
50
+ ? {
51
+ number: user.phoneNumber,
52
+ verified: user.phoneNumberVerified === true,
53
+ }
54
+ : null;
55
+ return { available, phone };
56
+ },
57
+ async loadPhoneApi() {
58
+ const { auth, phoneStepActive } = await import("../../../auth");
59
+ return phoneStepActive() ? auth.api : null;
60
+ },
61
+ async registerSiteStores() {
62
+ const { registerLicenseKeyStore } =
63
+ await import("../../license-key-store");
64
+ await registerLicenseKeyStore();
65
+ },
66
+ loadSpokeBilling() {
67
+ return Promise.resolve(null);
68
+ },
69
+ };
70
+ }
@@ -73,6 +73,20 @@ describe("navMessageKeys", () => {
73
73
  ).toEqual(["a", "b"]);
74
74
  });
75
75
 
76
+ it("leaves out a message with an ICU argument (it is not a bare label)", () => {
77
+ expect(
78
+ navMessageKeys({
79
+ nav: {
80
+ home: "Home",
81
+ backTo: "Back to {name}",
82
+ feature1: "'{Feature 1}'",
83
+ dont: "Don't miss {name}'s page",
84
+ quoted: "It''s here",
85
+ },
86
+ }),
87
+ ).toEqual(["home", "feature1", "quoted"]);
88
+ });
89
+
76
90
  it("is empty when there is no nav namespace", () => {
77
91
  expect(navMessageKeys({})).toEqual([]);
78
92
  expect(navMessageKeys(undefined)).toEqual([]);