create-ailk 0.38.0 → 0.40.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.
- package/dist/add-route.js +16 -1
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/derive-architecture.js +3 -1
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +27 -14
- package/dist/routes.d.ts +36 -2
- package/dist/routes.js +269 -23
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -3
- package/dist/site-roster.js +48 -22
- package/dist/surfaces.d.ts +13 -3
- package/dist/surfaces.js +128 -194
- package/dist/sync-routes.js +22 -5
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +11 -0
- package/dist/topology.js +253 -3
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +32 -4
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +6 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +2 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +2 -2
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +13 -2
- package/templates/apps/web/jest.config.cjs +10 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +0 -271
- package/templates/apps/web/middleware.ts +12 -25
- package/templates/apps/web/next.config.mjs +15 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -48
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SpokeSignIn — the signed-out account page of a spoke that signs in through
|
|
3
|
-
* its hub (#11096 D1, D9, D10; spec docs/specs/11096-the-spoke-hosts-the-sign-spec.md).
|
|
4
|
-
*
|
|
5
|
-
* A Server Component, rendered by the `(authed)` layout through the generated
|
|
6
|
-
* gate seam (`signed-out-gate.generated.tsx`, its `signIn: "hub"` render) for
|
|
7
|
-
* every signed-out account path. The person never sees the hub's brand here:
|
|
8
|
-
*
|
|
9
|
-
* - **The form.** One email field, the hub's sign-up agreements under a
|
|
10
|
-
* "New here?" line (unticked; ticking them makes the request a sign-up),
|
|
11
|
-
* and Continue with Google. It is a native `<form method="post">` to this
|
|
12
|
-
* site's `/api/hub-session/email`, inside `AuthCard`'s `body` (#9662), so
|
|
13
|
-
* it works without JavaScript. No password field, ever (D5), and no link
|
|
14
|
-
* to a hub page: Google goes to this site's own sign-in route with
|
|
15
|
-
* `provider=google`, which the hub's authorize step turns into Google.
|
|
16
|
-
* The agreements' policy links are the hub's (D3).
|
|
17
|
-
* - **Its states**, read from the middleware's `x-search` (a layout gets no
|
|
18
|
-
* `searchParams`): `?sent=1` (check your email), `?error=agreements |
|
|
19
|
-
* unavailable | exists | claim`.
|
|
20
|
-
* - **The purchase link** (`?claim=`, D9): "Open your account", the
|
|
21
|
-
* agreements' statements and one "Open my account" button whose form
|
|
22
|
-
* POSTs the claim to `/api/hub-session/open`. No checkbox: the click is the
|
|
23
|
-
* acceptance. Rendering it changes nothing (SEC-11096-3).
|
|
24
|
-
* - **One Tap** (D10): the `OneTap` island, only when the spoke sets
|
|
25
|
-
* `AILK_HUB_ONE_TAP=on` and its hub reports a client id.
|
|
26
|
-
*
|
|
27
|
-
* Not configured (`hubSessionConfig()` is `null`), it says sign-in isn't
|
|
28
|
-
* available yet and links back to the site. Nothing here logs a claim or
|
|
29
|
-
* anything `x-search` carries.
|
|
30
|
-
*/
|
|
31
|
-
import { localeHref } from "@working-theory/ui";
|
|
32
|
-
import { AuthCard, ConsentStatement } from "@working-theory/ui/blocks";
|
|
33
|
-
import { NavBackLink } from "@working-theory/ui/chrome";
|
|
34
|
-
import {
|
|
35
|
-
Button,
|
|
36
|
-
Checkbox,
|
|
37
|
-
Field,
|
|
38
|
-
InlineMessage,
|
|
39
|
-
Input,
|
|
40
|
-
Link,
|
|
41
|
-
Text,
|
|
42
|
-
} from "@working-theory/ui/primitives";
|
|
43
|
-
import { type HubSignUpAgreement, hubPurchaseClaimSchema } from "@working-theory/validation";
|
|
44
|
-
import { getTranslations } from "next-intl/server";
|
|
45
|
-
import type { ReactElement, ReactNode } from "react";
|
|
46
|
-
|
|
47
|
-
import { SITE_NAME } from "../site-brand";
|
|
48
|
-
import { siteLogo } from "../site-logo";
|
|
49
|
-
|
|
50
|
-
import { hubSessionConfig } from "./config";
|
|
51
|
-
import { readHubSignUp, readOneTapClientId } from "./entry";
|
|
52
|
-
import { OneTap } from "./one-tap";
|
|
53
|
-
import { HUB_SESSION_FALLBACK_PATH, hubNextPath } from "./session";
|
|
54
|
-
|
|
55
|
-
/** The spoke's own routes the page posts or links to. */
|
|
56
|
-
const EMAIL_ROUTE = "/api/hub-session/email";
|
|
57
|
-
const OPEN_ROUTE = "/api/hub-session/open";
|
|
58
|
-
const SIGN_IN_ROUTE = "/api/hub-session/sign-in";
|
|
59
|
-
|
|
60
|
-
export interface SpokeSignInProps {
|
|
61
|
-
locale: string;
|
|
62
|
-
/** The incoming request's headers: `x-pathname` and `x-search` (middleware). */
|
|
63
|
-
requestHeaders: Headers;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type Translate = Awaited<ReturnType<typeof getTranslations>>;
|
|
67
|
-
|
|
68
|
-
/** The one value of `name` in `search`, or `null` (absent or repeated). */
|
|
69
|
-
function single(search: URLSearchParams, name: string): string | null {
|
|
70
|
-
const values = search.getAll(name);
|
|
71
|
-
return values.length === 1 ? (values[0] ?? null) : null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** The page's frame: the back arrow, then the card (the account gate's own shape, #8790). */
|
|
75
|
-
function Frame({
|
|
76
|
-
locale,
|
|
77
|
-
backLabel,
|
|
78
|
-
card,
|
|
79
|
-
}: {
|
|
80
|
-
locale: string;
|
|
81
|
-
backLabel: string;
|
|
82
|
-
card: ReactNode;
|
|
83
|
-
}): ReactElement {
|
|
84
|
-
return (
|
|
85
|
-
<div className="flex min-h-screen flex-col" data-testid="account-sign-in-gate">
|
|
86
|
-
<header className="flex h-16 items-center px-5 md:px-8" data-testid="account-sign-in-gate-header">
|
|
87
|
-
<NavBackLink href={localeHref(locale, "/")} label={backLabel} />
|
|
88
|
-
</header>
|
|
89
|
-
<div className="flex flex-1 flex-col items-center md:justify-center md:py-section">
|
|
90
|
-
{/* AuthShell's 400px column: the cap sits on the wrapper, never on the card. */}
|
|
91
|
-
<div className="w-full max-w-100">{card}</div>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** One agreement's checkbox and statement; posts its purpose id under `agreements`. */
|
|
98
|
-
function AgreementRow({ agreement }: { agreement: HubSignUpAgreement }): ReactElement {
|
|
99
|
-
const id = `spoke-sign-in-agreement-${agreement.purposeId}`;
|
|
100
|
-
return (
|
|
101
|
-
<div className="flex items-start gap-3">
|
|
102
|
-
<Checkbox
|
|
103
|
-
id={id}
|
|
104
|
-
name="agreements"
|
|
105
|
-
value={agreement.purposeId}
|
|
106
|
-
aria-labelledby={`${id}-statement`}
|
|
107
|
-
className="mt-0.5"
|
|
108
|
-
data-testid={id}
|
|
109
|
-
/>
|
|
110
|
-
<ConsentStatement id={`${id}-statement`} statement={agreement.statement} policies={agreement.policies} />
|
|
111
|
-
</div>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** The line a `?error=` state puts above the form, or `null`. */
|
|
116
|
-
function errorLine(error: string | null, t: Translate): ReactNode {
|
|
117
|
-
const lines: Record<string, [string, string]> = {
|
|
118
|
-
unavailable: ["spoke-sign-in-unavailable", t("unavailable")],
|
|
119
|
-
exists: ["spoke-sign-in-exists", t("exists")],
|
|
120
|
-
claim: ["spoke-sign-in-claim-error", t("claimInvalid")],
|
|
121
|
-
};
|
|
122
|
-
const line = error === null ? undefined : lines[error];
|
|
123
|
-
if (line === undefined) return null;
|
|
124
|
-
return (
|
|
125
|
-
<InlineMessage variant={error === "exists" ? "default" : "error"} role="alert" data-testid={line[0]}>
|
|
126
|
-
{line[1]}
|
|
127
|
-
</InlineMessage>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export async function SpokeSignIn({ locale, requestHeaders }: SpokeSignInProps): Promise<ReactElement> {
|
|
132
|
-
const t = await getTranslations({ locale, namespace: "account.spokeSignIn" });
|
|
133
|
-
const gate = await getTranslations({ locale, namespace: "account.gate" });
|
|
134
|
-
const config = hubSessionConfig();
|
|
135
|
-
|
|
136
|
-
if (config === null) {
|
|
137
|
-
return (
|
|
138
|
-
<Frame
|
|
139
|
-
locale={locale}
|
|
140
|
-
backLabel={gate("homeLink")}
|
|
141
|
-
card={
|
|
142
|
-
<AuthCard
|
|
143
|
-
intent="sign-in"
|
|
144
|
-
footer="none"
|
|
145
|
-
headingLevel={1}
|
|
146
|
-
logo={siteLogo()}
|
|
147
|
-
labels={{ signInHeading: gate("emptyHeadline") }}
|
|
148
|
-
subhead={gate("emptyDescription")}
|
|
149
|
-
body={
|
|
150
|
-
<Button asChild variant="secondary" size="big" className="w-full">
|
|
151
|
-
<Link href={localeHref(locale, "/")} variant="bare" data-testid="account-sign-in-gate-home">
|
|
152
|
-
{gate("homeLink")}
|
|
153
|
-
</Link>
|
|
154
|
-
</Button>
|
|
155
|
-
}
|
|
156
|
-
/>
|
|
157
|
-
}
|
|
158
|
-
/>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const search = new URLSearchParams(requestHeaders.get("x-search") ?? "");
|
|
163
|
-
const next = hubNextPath(
|
|
164
|
-
requestHeaders.get("x-pathname") ?? localeHref(locale, HUB_SESSION_FALLBACK_PATH),
|
|
165
|
-
);
|
|
166
|
-
const info = await readHubSignUp(config, locale);
|
|
167
|
-
const agreements = info?.signUpOpen ? info.agreements : [];
|
|
168
|
-
const error = single(search, "error");
|
|
169
|
-
const rawClaim = single(search, "claim");
|
|
170
|
-
const claim = rawClaim !== null && hubPurchaseClaimSchema.safeParse(rawClaim).success ? rawClaim : null;
|
|
171
|
-
const card = (heading: string, subhead: string, body: ReactNode): ReactElement => (
|
|
172
|
-
<Frame
|
|
173
|
-
locale={locale}
|
|
174
|
-
backLabel={gate("homeLink")}
|
|
175
|
-
card={
|
|
176
|
-
<AuthCard
|
|
177
|
-
intent="sign-in"
|
|
178
|
-
footer="none"
|
|
179
|
-
headingLevel={1}
|
|
180
|
-
logo={siteLogo()}
|
|
181
|
-
labels={{ signInHeading: heading }}
|
|
182
|
-
subhead={subhead}
|
|
183
|
-
body={body}
|
|
184
|
-
/>
|
|
185
|
-
}
|
|
186
|
-
/>
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
// D9 — the purchase link. Without the hub's agreements to show, there is
|
|
190
|
-
// nothing to accept, so no button: the form takes over.
|
|
191
|
-
if (claim !== null && agreements.length > 0) {
|
|
192
|
-
return card(
|
|
193
|
-
t("openHeading"),
|
|
194
|
-
t("openLead"),
|
|
195
|
-
<form method="post" action={OPEN_ROUTE} className="flex flex-col gap-4" data-testid="spoke-sign-in-open-form">
|
|
196
|
-
<Input type="hidden" name="claim" value={claim} />
|
|
197
|
-
<div className="flex flex-col gap-2" data-testid="spoke-sign-in-open-terms">
|
|
198
|
-
{agreements.map((agreement) => (
|
|
199
|
-
<ConsentStatement
|
|
200
|
-
key={agreement.purposeId}
|
|
201
|
-
statement={agreement.statement}
|
|
202
|
-
policies={agreement.policies}
|
|
203
|
-
/>
|
|
204
|
-
))}
|
|
205
|
-
</div>
|
|
206
|
-
<Button type="submit" size="big" className="w-full" data-testid="spoke-sign-in-open">
|
|
207
|
-
{t("open")}
|
|
208
|
-
</Button>
|
|
209
|
-
</form>,
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (single(search, "sent") === "1") {
|
|
214
|
-
return card(
|
|
215
|
-
t("sent"),
|
|
216
|
-
t("sentBody"),
|
|
217
|
-
<div className="flex flex-col gap-4" data-testid="spoke-sign-in-sent">
|
|
218
|
-
<Button asChild variant="secondary" size="big" className="w-full">
|
|
219
|
-
<Link href={next} variant="bare" data-testid="spoke-sign-in-back">
|
|
220
|
-
{t("back")}
|
|
221
|
-
</Link>
|
|
222
|
-
</Button>
|
|
223
|
-
</div>,
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const oneTapClientId = config.oneTap ? await readOneTapClientId(config) : null;
|
|
228
|
-
const googleHref = `${SIGN_IN_ROUTE}?${new URLSearchParams({ next, provider: "google" }).toString()}`;
|
|
229
|
-
return card(
|
|
230
|
-
t("heading", { site: SITE_NAME }),
|
|
231
|
-
t("subhead"),
|
|
232
|
-
<div className="flex flex-col gap-4">
|
|
233
|
-
{errorLine(claim !== null ? "unavailable" : error, t)}
|
|
234
|
-
<form method="post" action={EMAIL_ROUTE} className="flex flex-col gap-4" data-testid="spoke-sign-in-form">
|
|
235
|
-
<Input type="hidden" name="next" value={next} />
|
|
236
|
-
<Field label={t("emailLabel")} htmlFor="spoke-sign-in-email">
|
|
237
|
-
<Input
|
|
238
|
-
type="email"
|
|
239
|
-
name="email"
|
|
240
|
-
required
|
|
241
|
-
autoComplete="email"
|
|
242
|
-
size="big"
|
|
243
|
-
data-testid="auth-email"
|
|
244
|
-
/>
|
|
245
|
-
</Field>
|
|
246
|
-
{agreements.length > 0 ? (
|
|
247
|
-
<fieldset className="flex flex-col gap-3" data-testid="spoke-sign-in-agreements">
|
|
248
|
-
<legend className="mb-2">
|
|
249
|
-
<Text as="span" variant="body-sm" tone="muted">
|
|
250
|
-
{t("newHere")}
|
|
251
|
-
</Text>
|
|
252
|
-
</legend>
|
|
253
|
-
{error === "agreements" ? (
|
|
254
|
-
<InlineMessage variant="error" role="alert" data-testid="spoke-sign-in-agreements-error">
|
|
255
|
-
{t("agreementsError")}
|
|
256
|
-
</InlineMessage>
|
|
257
|
-
) : null}
|
|
258
|
-
{agreements.map((agreement) => (
|
|
259
|
-
<AgreementRow key={agreement.purposeId} agreement={agreement} />
|
|
260
|
-
))}
|
|
261
|
-
</fieldset>
|
|
262
|
-
) : null}
|
|
263
|
-
<Button type="submit" size="big" className="w-full" data-testid="spoke-sign-in-submit">
|
|
264
|
-
{t("submit")}
|
|
265
|
-
</Button>
|
|
266
|
-
</form>
|
|
267
|
-
{info?.google ? (
|
|
268
|
-
<Button asChild variant="secondary" size="big" className="w-full">
|
|
269
|
-
<Link href={googleHref} variant="bare" data-testid="spoke-sign-in-google">
|
|
270
|
-
{t("google")}
|
|
271
|
-
</Link>
|
|
272
|
-
</Button>
|
|
273
|
-
) : null}
|
|
274
|
-
{oneTapClientId !== null ? <OneTap clientId={oneTapClientId} next={next} /> : null}
|
|
275
|
-
</div>,
|
|
276
|
-
);
|
|
277
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// The Free `/meet/<slug>` placeholder hub (#6897 D2). `MEET_PLACEHOLDER_HUB`
|
|
2
|
-
// is the one fixed top-level slug the `[slug]/[detail]` route answers under —
|
|
3
|
-
// never a copied literal, so the route and the structured-data walk
|
|
4
|
-
// (`apps/web/lib/__tests__/structured-data.test.tsx`) can never drift.
|
|
5
|
-
export const MEET_PLACEHOLDER_HUB = "meet";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `?next=` sanitizer for the /sign-in page (#4984) and the hub-session
|
|
3
|
-
* callback (#7894 D7 — moved here from `app/[locale]/(auth)/sign-in/`, which
|
|
4
|
-
* re-exports it, so a spoke that drops the `(auth)` group keeps it).
|
|
5
|
-
*
|
|
6
|
-
* The post-sign-in `callbackURL` handed to Better Auth is caller-controlled
|
|
7
|
-
* via the `next` search param, so it must be a SAME-ORIGIN, SAME-APP path —
|
|
8
|
-
* never a foreign origin (open redirect), a protocol-relative URL, a
|
|
9
|
-
* backslash trick browsers normalise to `//`, or a control character that
|
|
10
|
-
* could split a header. Anything that fails falls back to `fallback`.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// U+0000–U+001F and U+007F — the header-splitting / URL-mangling range.
|
|
14
|
-
// eslint-disable-next-line no-control-regex -- the control range is the thing being rejected
|
|
15
|
-
const CONTROL_CHARS = /[\x00-\x1f\x7f]/;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns `raw` when it is a safe in-app path, else `fallback`.
|
|
19
|
-
*
|
|
20
|
-
* Accepts: a string starting with a single "/" (e.g. `/account`,
|
|
21
|
-
* `/en/account?tab=x`, `/waitlist#a`).
|
|
22
|
-
* Rejects: non-strings (incl. Next's `string[]` for a repeated param), "",
|
|
23
|
-
* `//host` (protocol-relative), `/\host` (backslash normalised to `//`),
|
|
24
|
-
* any backslash anywhere, whitespace, control characters, and anything not
|
|
25
|
-
* starting with "/" (`https://…`, `host.tld`).
|
|
26
|
-
*/
|
|
27
|
-
export function resolveNextPath(raw: unknown, fallback: string): string {
|
|
28
|
-
if (typeof raw !== "string") return fallback;
|
|
29
|
-
if (!raw.startsWith("/")) return fallback;
|
|
30
|
-
if (raw.startsWith("//")) return fallback;
|
|
31
|
-
if (raw.includes("\\")) return fallback;
|
|
32
|
-
if (/\s/.test(raw)) return fallback;
|
|
33
|
-
if (CONTROL_CHARS.test(raw)) return fallback;
|
|
34
|
-
return raw;
|
|
35
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The posting a `/careers/<slug>/apply` page applies to, read by its title
|
|
3
|
-
* (#8840 D11). The read sits here, not in a page, so the structured-data walk
|
|
4
|
-
* does not take an apply page for a JobPosting page: the posting's own JSON-LD
|
|
5
|
-
* is `/careers/<slug>`'s. In `lib/` (#8849 D9), not a route directory, so
|
|
6
|
-
* every scaffold carries it: the `signal-collectors` walk and the Free apply
|
|
7
|
-
* page (`careers/[slug]/[action]`) both read it.
|
|
8
|
-
*
|
|
9
|
-
* #10054 D2 — both pages read the posting through `postingForApply`, which
|
|
10
|
-
* also returns the magnet the posting names (`applicationFlow`, checked as a
|
|
11
|
-
* flow slug by the frontmatter schema); one read serves both.
|
|
12
|
-
*/
|
|
13
|
-
import { getMdxSource } from "@working-theory/page-renderer";
|
|
14
|
-
|
|
15
|
-
/** What an apply page needs from its posting. */
|
|
16
|
-
export interface ApplyPosting {
|
|
17
|
-
title: string;
|
|
18
|
-
/** The magnet this posting's apply page runs; absent, the Job application. */
|
|
19
|
-
applicationFlow?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** The posting in `locale`, or `null` when no posting has this slug or it has no title. */
|
|
23
|
-
export async function postingForApply(slug: string, locale: string): Promise<ApplyPosting | null> {
|
|
24
|
-
const source = await getMdxSource("JobPosting", slug, locale);
|
|
25
|
-
if (source === null) return null;
|
|
26
|
-
const { title, applicationFlow } = source.frontmatter as {
|
|
27
|
-
title?: unknown;
|
|
28
|
-
applicationFlow?: unknown;
|
|
29
|
-
};
|
|
30
|
-
if (typeof title !== "string" || title.trim() === "") return null;
|
|
31
|
-
return typeof applicationFlow === "string" && applicationFlow !== ""
|
|
32
|
-
? { title, applicationFlow }
|
|
33
|
-
: { title };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** The posting's title in `locale`, or `null` when no posting has this slug. */
|
|
37
|
-
export async function postingTitle(slug: string, locale: string): Promise<string | null> {
|
|
38
|
-
return (await postingForApply(slug, locale))?.title ?? null;
|
|
39
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The route-family helper (#10051 D5) — the generic half of a content hub
|
|
3
|
-
* that lists its detail pages automatically: read every detail page of one
|
|
4
|
-
* type, and slot a generated section in before the page's closing CTAs.
|
|
5
|
-
*
|
|
6
|
-
* The /templates hub (#10051) is its first caller. It is shaped for the next
|
|
7
|
-
* two: #10043 (a services category page listing its child `Service` pages)
|
|
8
|
-
* and #10044 (a pricing hub listing its offering `Pricing` pages). The
|
|
9
|
-
* /alternatives and /reports routes keep their own local copies (#10051
|
|
10
|
-
* § Out of scope).
|
|
11
|
-
*
|
|
12
|
-
* Base tree: no paid import, no `oss: false`.
|
|
13
|
-
*/
|
|
14
|
-
import {
|
|
15
|
-
getMdxSlugs,
|
|
16
|
-
getMdxSource,
|
|
17
|
-
type getPageSections,
|
|
18
|
-
type SchemaOrgType,
|
|
19
|
-
} from "@working-theory/page-renderer";
|
|
20
|
-
|
|
21
|
-
type Section = Awaited<ReturnType<typeof getPageSections>>[number];
|
|
22
|
-
|
|
23
|
-
/** One detail page as a hub lists it: its slug and raw frontmatter. */
|
|
24
|
-
export interface DetailPage {
|
|
25
|
-
slug: string;
|
|
26
|
-
frontmatter: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Every detail page of `type` for `locale`, loaded through `load` (the
|
|
31
|
-
* content adapter by default), a slug whose load is `null` dropped, sorted
|
|
32
|
-
* by slug so the list is stable. `listSlugs` defaults to the content adapter
|
|
33
|
-
* too; a route passes its own to stay injectable in tests.
|
|
34
|
-
*/
|
|
35
|
-
export async function listDetailPages(
|
|
36
|
-
type: SchemaOrgType,
|
|
37
|
-
locale: string,
|
|
38
|
-
load: typeof getMdxSource = getMdxSource,
|
|
39
|
-
listSlugs: typeof getMdxSlugs = getMdxSlugs,
|
|
40
|
-
): Promise<DetailPage[]> {
|
|
41
|
-
const slugs = await listSlugs(type, locale);
|
|
42
|
-
const pages = await Promise.all(
|
|
43
|
-
slugs.map(async (slug): Promise<DetailPage | null> => {
|
|
44
|
-
const source = await load(type, slug, locale);
|
|
45
|
-
if (source === null) return null;
|
|
46
|
-
return {
|
|
47
|
-
slug,
|
|
48
|
-
frontmatter: source.frontmatter as Record<string, unknown>,
|
|
49
|
-
};
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
52
|
-
return pages
|
|
53
|
-
.filter((page): page is DetailPage => page !== null)
|
|
54
|
-
.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Insert `section` before the trailing run of `cta` sections — the page's
|
|
59
|
-
* closing call to action stays last — or append it when the page does not end
|
|
60
|
-
* in a CTA (the /reports rule, #7745 D4).
|
|
61
|
-
*/
|
|
62
|
-
export function insertBeforeClosingCtas(
|
|
63
|
-
sections: Section[],
|
|
64
|
-
section: Section,
|
|
65
|
-
): Section[] {
|
|
66
|
-
let at = sections.length;
|
|
67
|
-
while (at > 0 && sections[at - 1]?.type === "cta") at -= 1;
|
|
68
|
-
return [...sections.slice(0, at), section, ...sections.slice(at)];
|
|
69
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The services listing (#10043 D8) — a service's public URL under the site's
|
|
3
|
-
* services base and its category, the list a category page shows of its
|
|
4
|
-
* services, and the hub's own section links re-pointed onto the base. Pure,
|
|
5
|
-
* no I/O: the routes load the pages and the translated labels and pass them
|
|
6
|
-
* in, so no user-facing copy lives here (customer-facing-i18n, ADR 0019).
|
|
7
|
-
*
|
|
8
|
-
* Base tree: no paid import, no `oss: false`.
|
|
9
|
-
*/
|
|
10
|
-
import { pagePath } from "@working-theory/templates/routes";
|
|
11
|
-
import type { PageSection } from "@working-theory/validation";
|
|
12
|
-
|
|
13
|
-
import type { DetailPage } from "./route-family";
|
|
14
|
-
import {
|
|
15
|
-
SERVICES_PATH,
|
|
16
|
-
SERVICES_ROUTE,
|
|
17
|
-
toPublicServicesHref,
|
|
18
|
-
} from "./services-path";
|
|
19
|
-
|
|
20
|
-
type ItemsSection = Extract<PageSection, { type: "items" }>;
|
|
21
|
-
|
|
22
|
-
/** The `services` messages namespace labels a category's list reads (#10043 D11). */
|
|
23
|
-
export interface ServiceListingLabels {
|
|
24
|
-
childrenHeading: string;
|
|
25
|
-
viewService: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** A service's public path: `<base>[/<category>]/<slug>`. */
|
|
29
|
-
export function servicePublicPath(slug: string, parent?: string): string {
|
|
30
|
-
return pagePath({ type: "Service", slug, parent }, SERVICES_PATH);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** The services whose `parent` is `category`, from a slug-sorted page list. */
|
|
34
|
-
export function childServices(
|
|
35
|
-
pages: DetailPage[],
|
|
36
|
-
category: string,
|
|
37
|
-
): DetailPage[] {
|
|
38
|
-
return pages.filter((page) => page.frontmatter.parent === category);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The list a category page renders after its body: one card per child service. */
|
|
42
|
-
export function serviceChildrenSection(
|
|
43
|
-
children: DetailPage[],
|
|
44
|
-
labels: ServiceListingLabels,
|
|
45
|
-
): ItemsSection {
|
|
46
|
-
const text = (value: unknown): string | undefined =>
|
|
47
|
-
typeof value === "string" && value.length > 0 ? value : undefined;
|
|
48
|
-
return {
|
|
49
|
-
type: "items",
|
|
50
|
-
id: "service-children",
|
|
51
|
-
data: {
|
|
52
|
-
headline: labels.childrenHeading,
|
|
53
|
-
items: children.map((child) => ({
|
|
54
|
-
title: text(child.frontmatter.title) ?? child.slug,
|
|
55
|
-
description:
|
|
56
|
-
text(child.frontmatter.summary) ??
|
|
57
|
-
text(child.frontmatter.description) ??
|
|
58
|
-
"",
|
|
59
|
-
link: {
|
|
60
|
-
label: labels.viewService,
|
|
61
|
-
href: servicePublicPath(child.slug, text(child.frontmatter.parent)),
|
|
62
|
-
},
|
|
63
|
-
})),
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function mapHrefs(value: unknown): unknown {
|
|
69
|
-
if (Array.isArray(value)) return value.map(mapHrefs);
|
|
70
|
-
if (value === null || typeof value !== "object") return value;
|
|
71
|
-
return Object.fromEntries(
|
|
72
|
-
Object.entries(value).map(([key, entry]) => [
|
|
73
|
-
key,
|
|
74
|
-
key === "href" && typeof entry === "string"
|
|
75
|
-
? toPublicServicesHref(entry)
|
|
76
|
-
: mapHrefs(entry),
|
|
77
|
-
]),
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The hub's sections with every site `href` starting `/services` re-pointed
|
|
83
|
-
* onto the base, at any depth; the same array on a site with no
|
|
84
|
-
* `services.path`.
|
|
85
|
-
*/
|
|
86
|
-
export function withPublicServicesSections<S>(sections: S[]): S[] {
|
|
87
|
-
if (SERVICES_PATH === SERVICES_ROUTE) return sections;
|
|
88
|
-
return sections.map((section) => mapHrefs(section) as S);
|
|
89
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The template-listing mapping (#10051 D6) — a TemplatePage's frontmatter to
|
|
3
|
-
* the /templates hub's card and to the generated sections of its own
|
|
4
|
-
* /templates/<slug> page. Pure, no I/O: the routes load the pages and the
|
|
5
|
-
* translated labels and pass them in, so no user-facing copy lives here
|
|
6
|
-
* (customer-facing-i18n, ADR 0019).
|
|
7
|
-
*
|
|
8
|
-
* Base tree: no paid import, no `oss: false`.
|
|
9
|
-
*/
|
|
10
|
-
import { SITE_CATEGORIES } from "@working-theory/schema/categories";
|
|
11
|
-
import type { PageSection } from "@working-theory/validation";
|
|
12
|
-
|
|
13
|
-
/** The `templates` messages namespace, read by the routes (#10051 D8). */
|
|
14
|
-
export interface TemplateLabels {
|
|
15
|
-
getIt: string;
|
|
16
|
-
startFree: string;
|
|
17
|
-
viewDemo: string;
|
|
18
|
-
viewTemplate: string;
|
|
19
|
-
included: string;
|
|
20
|
-
demoBadge: string;
|
|
21
|
-
/** The tail of a category label cut at {@link MAX_CATEGORY_NAMES}: "+9 more". */
|
|
22
|
-
moreCategories: (count: number) => string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Read the labels from the `templates` namespace's translator. */
|
|
26
|
-
export function templateLabels(
|
|
27
|
-
t: (key: keyof TemplateLabels, values?: { count: number }) => string,
|
|
28
|
-
): TemplateLabels {
|
|
29
|
-
return {
|
|
30
|
-
getIt: t("getIt"),
|
|
31
|
-
startFree: t("startFree"),
|
|
32
|
-
viewDemo: t("viewDemo"),
|
|
33
|
-
viewTemplate: t("viewTemplate"),
|
|
34
|
-
included: t("included"),
|
|
35
|
-
demoBadge: t("demoBadge"),
|
|
36
|
-
moreCategories: (count) => t("moreCategories", { count }),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* At most this many category names show in a card or hero label; the rest
|
|
42
|
-
* collapse into "+N more", so a template listed under twelve categories keeps
|
|
43
|
-
* a one-line label and the card titles in a row stay aligned (design review
|
|
44
|
-
* round 1, B2).
|
|
45
|
-
*/
|
|
46
|
-
export const MAX_CATEGORY_NAMES = 3;
|
|
47
|
-
|
|
48
|
-
/** The TemplatePage frontmatter fields this mapping reads. */
|
|
49
|
-
interface TemplateFrontmatter {
|
|
50
|
-
title?: string;
|
|
51
|
-
description?: string;
|
|
52
|
-
summary?: string;
|
|
53
|
-
thumbnail?: string;
|
|
54
|
-
categories?: readonly string[];
|
|
55
|
-
demoUrl?: string;
|
|
56
|
-
getItUrl?: string;
|
|
57
|
-
price?: number;
|
|
58
|
-
includes?: readonly { title: string; description: string }[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type CardItem = Extract<
|
|
62
|
-
PageSection,
|
|
63
|
-
{ type: "items" }
|
|
64
|
-
>["data"]["items"][number];
|
|
65
|
-
|
|
66
|
-
function fields(frontmatter: unknown): TemplateFrontmatter {
|
|
67
|
-
return (frontmatter ?? {}) as TemplateFrontmatter;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The known category display names, the first {@link MAX_CATEGORY_NAMES}
|
|
72
|
-
* joined and the rest counted; undefined when none is known.
|
|
73
|
-
*/
|
|
74
|
-
function categoryNames(
|
|
75
|
-
categories: readonly string[] | undefined,
|
|
76
|
-
labels: TemplateLabels,
|
|
77
|
-
): string | undefined {
|
|
78
|
-
const names = (categories ?? []).flatMap((slug) => {
|
|
79
|
-
const found = SITE_CATEGORIES.find((category) => category.slug === slug);
|
|
80
|
-
return found === undefined ? [] : [found.name];
|
|
81
|
-
});
|
|
82
|
-
if (names.length === 0) return undefined;
|
|
83
|
-
const shown = names.slice(0, MAX_CATEGORY_NAMES);
|
|
84
|
-
const hidden = names.length - shown.length;
|
|
85
|
-
return hidden > 0
|
|
86
|
-
? [...shown, labels.moreCategories(hidden)].join(" · ")
|
|
87
|
-
: shown.join(" · ");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** One /templates card for a TemplatePage. */
|
|
91
|
-
export function templateCard(
|
|
92
|
-
page: { slug: string; frontmatter: unknown },
|
|
93
|
-
labels: TemplateLabels,
|
|
94
|
-
): CardItem {
|
|
95
|
-
const fm = fields(page.frontmatter);
|
|
96
|
-
const title = fm.title ?? page.slug;
|
|
97
|
-
const eyebrow = categoryNames(fm.categories, labels);
|
|
98
|
-
return {
|
|
99
|
-
title,
|
|
100
|
-
description: fm.summary ?? fm.description ?? "",
|
|
101
|
-
...(fm.thumbnail !== undefined && {
|
|
102
|
-
image: { src: fm.thumbnail, alt: title },
|
|
103
|
-
}),
|
|
104
|
-
...(eyebrow !== undefined && { eyebrow }),
|
|
105
|
-
...(fm.demoUrl !== undefined && { badge: labels.demoBadge }),
|
|
106
|
-
link: { label: labels.viewTemplate, href: `/templates/${page.slug}` },
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** "Start free" for a template priced at exactly 0, else "Get it". */
|
|
111
|
-
export function templateActionLabel(
|
|
112
|
-
price: number | undefined,
|
|
113
|
-
labels: TemplateLabels,
|
|
114
|
-
): string {
|
|
115
|
-
return price === 0 ? labels.startFree : labels.getIt;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The generated top of a /templates/<slug> page: a hero carrying the name,
|
|
120
|
-
* summary, thumbnail, categories, the Get it / Start free action and the
|
|
121
|
-
* View demo link, then the "What's included" list.
|
|
122
|
-
*/
|
|
123
|
-
export function templateDetailSections(
|
|
124
|
-
frontmatter: unknown,
|
|
125
|
-
labels: TemplateLabels,
|
|
126
|
-
): [PageSection, PageSection] {
|
|
127
|
-
const fm = fields(frontmatter);
|
|
128
|
-
const title = fm.title ?? "";
|
|
129
|
-
const subheadline = fm.summary ?? fm.description;
|
|
130
|
-
const eyebrow = categoryNames(fm.categories, labels);
|
|
131
|
-
const hero: PageSection = {
|
|
132
|
-
type: "hero",
|
|
133
|
-
id: "template-hero",
|
|
134
|
-
data: {
|
|
135
|
-
headline: title,
|
|
136
|
-
...(subheadline !== undefined && { subheadline }),
|
|
137
|
-
...(eyebrow !== undefined && { eyebrow }),
|
|
138
|
-
...(fm.thumbnail !== undefined && {
|
|
139
|
-
image: { src: fm.thumbnail, alt: title },
|
|
140
|
-
}),
|
|
141
|
-
...(fm.getItUrl !== undefined && {
|
|
142
|
-
primaryCta: {
|
|
143
|
-
label: templateActionLabel(fm.price, labels),
|
|
144
|
-
href: fm.getItUrl,
|
|
145
|
-
},
|
|
146
|
-
}),
|
|
147
|
-
...(fm.demoUrl !== undefined && {
|
|
148
|
-
secondaryCta: {
|
|
149
|
-
label: labels.viewDemo,
|
|
150
|
-
href: fm.demoUrl,
|
|
151
|
-
variant: "outline" as const,
|
|
152
|
-
},
|
|
153
|
-
}),
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
const included: PageSection = {
|
|
157
|
-
type: "items",
|
|
158
|
-
id: "template-included",
|
|
159
|
-
data: {
|
|
160
|
-
headline: labels.included,
|
|
161
|
-
variant: "minimal",
|
|
162
|
-
items: (fm.includes ?? []).map(({ title: rowTitle, description }) => ({
|
|
163
|
-
title: rowTitle,
|
|
164
|
-
description,
|
|
165
|
-
})),
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
return [hero, included];
|
|
169
|
-
}
|