create-ailk 0.37.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- 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 +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- 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/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- 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__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- 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/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* /[locale]/flows/[slug]/results/[payload] — the cold-load results route
|
|
4
|
-
* (#4770).
|
|
5
|
-
*
|
|
6
|
-
* Server-fetches the flow config through `served-flow.ts`'s
|
|
7
|
-
* `readServedFlow(slug)`, uncached (always dynamically rendered — the config
|
|
8
|
-
* is DB-backed live data); any failed read redirects to the landing (#10990
|
|
9
|
-
* D3).
|
|
10
|
-
* Decodes the versioned, answers-only permalink (`decodePermalink`,
|
|
11
|
-
* `@working-theory/validation`) and `redirect()`s to `/[locale]/flows/[slug]`
|
|
12
|
-
* — step 1, never an error page — on ANY of: an invalid payload (FR6), a
|
|
13
|
-
* stale-version payload (FR6), a payload whose own `flowSlug` does not match
|
|
14
|
-
* this route's `[slug]` (D2/FR6), or a served flow that is not a
|
|
15
|
-
* recommending register (D8 — `mode !== "recommending"`, or neither `offers`
|
|
16
|
-
* nor `recommendation.byResult` (#10827) nor a results page — #11013 D-C:
|
|
17
|
-
* spec C's `hasResultsPage`, a recommending flow with no `ending`, widens the
|
|
18
|
-
* guard additively, so every flow the page rendered before still renders —
|
|
19
|
-
* checked against the field `recommend()` is about to be handed rather than
|
|
20
|
-
* inferring the compiler's five-keys-travel-together guarantee).
|
|
21
|
-
*
|
|
22
|
-
* On a valid payload against a recommending flow, renders `ResultsClient`,
|
|
23
|
-
* which runs the already-shipped pure `recommend()` in the browser and
|
|
24
|
-
* renders the returned fits through the existing `RecommendationCard`
|
|
25
|
-
* (D10 — a minimal render; Epic #4759 recomposes it against the LOCKED
|
|
26
|
-
* DESIGN.md).
|
|
27
|
-
*
|
|
28
|
-
* `?checkout=success|cancelled` (#4842 FR7/D6) is read only after every
|
|
29
|
-
* guard above and rendered by `ResultsClient` as a one-line status over the
|
|
30
|
-
* identical recommendation.
|
|
31
|
-
*
|
|
32
|
-
* #9071 D3 — the recommender's landing. A flow with an offer carrying a
|
|
33
|
-
* string `lookupKey` (an Offerings recommender) never renders here: after
|
|
34
|
-
* the recommending guard the page redirects to `/<locale>/pricing?plan=<plan>`
|
|
35
|
-
* when the first fit's lookup key is in the current shown set — read from
|
|
36
|
-
* `offerings.shown()`, the endpoint `/pricing` renders from, through this
|
|
37
|
-
* page's own read shared per instance for 15 seconds — and to `/<locale>/pricing` with no badge otherwise (no fit, a
|
|
38
|
-
* key no longer shown, any failed read). The URL is built only from an
|
|
39
|
-
* allowlisted locale and a `parseLookupKey` plan. A flow with no such offer,
|
|
40
|
-
* or whose first fit carries none, renders as before with no read.
|
|
41
|
-
*
|
|
42
|
-
* #10827 — the by-result rows. `recommend()` returns the first matching
|
|
43
|
-
* row's `routeTo` (a legacy offer rule read as a row when the flow carries
|
|
44
|
-
* no `recommendation.byResult`; the landing above is that row's checkout
|
|
45
|
-
* kind for a `{plan}` key). A checkout row with a full lookup key goes
|
|
46
|
-
* straight to the Offerings buy route while the key is shown; an offering
|
|
47
|
-
* row — or a checkout row whose offering is not shown, a draft — renders
|
|
48
|
-
* the results page with one card named from the offering, priced only
|
|
49
|
-
* while the offering is shown.
|
|
50
|
-
*
|
|
51
|
-
* #11013 D-A, D-G — the page builds the frame's brand on the server (the
|
|
52
|
-
* site's logomark and wordmark, the landing title) and the exit to the
|
|
53
|
-
* flow's landing, and resolves the magnet's Email-links-to offering
|
|
54
|
-
* (`conversionLink.kind === "offering"`, spec C) from the same shown set as
|
|
55
|
-
* a Product card, only when no by-result card won (decision 15). The
|
|
56
|
-
* appointment card is the scheduling layout's (`../layout.tsx`, D-K); this
|
|
57
|
-
* file imports nothing from scheduling.
|
|
58
|
-
*/
|
|
59
|
-
import { offerings } from "@working-theory/api-client";
|
|
60
|
-
import { Image } from "@working-theory/ui/primitives";
|
|
61
|
-
import {
|
|
62
|
-
decodePermalink,
|
|
63
|
-
type FlowConfig,
|
|
64
|
-
type FlowConversionLink,
|
|
65
|
-
type FlowResultRouteTo,
|
|
66
|
-
flowRecommendRegister,
|
|
67
|
-
hasResultsPage,
|
|
68
|
-
parseLookupKey,
|
|
69
|
-
recommend,
|
|
70
|
-
resolveLocalizedString,
|
|
71
|
-
shownOfferingsAnswerSchema,
|
|
72
|
-
type WaitlistAnswers,
|
|
73
|
-
type WorkspaceShownSetWire,
|
|
74
|
-
} from "@working-theory/validation";
|
|
75
|
-
import type { Metadata } from "next";
|
|
76
|
-
import { redirect } from "next/navigation";
|
|
77
|
-
import type { ReactElement } from "react";
|
|
78
|
-
|
|
79
|
-
import { offeringsCheckoutHref } from "../../../../../../lib/offerings-pricing";
|
|
80
|
-
import { siteLogo, siteWordmarkAsset } from "../../../../../../lib/site-logo";
|
|
81
|
-
import { apiOriginConfigured, readServedFlow } from "../../served-flow";
|
|
82
|
-
|
|
83
|
-
import type {
|
|
84
|
-
ResultsConversionCard,
|
|
85
|
-
ResultsOfferingCard,
|
|
86
|
-
ResultsReturnState,
|
|
87
|
-
} from "./ResultsClient";
|
|
88
|
-
import { ResultsClient } from "./ResultsClient";
|
|
89
|
-
|
|
90
|
-
export const dynamic = "force-dynamic";
|
|
91
|
-
|
|
92
|
-
interface Props {
|
|
93
|
-
params: Promise<{ locale: string; slug: string; payload: string }>;
|
|
94
|
-
/** FR7 (#4842) — `?checkout=success|cancelled` after Stripe's hosted page. */
|
|
95
|
-
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* D6 (#4842) — the return micro-state, validated against the two literals;
|
|
100
|
-
* anything else (absent, an array, an unknown value) renders no status line.
|
|
101
|
-
*/
|
|
102
|
-
function resolveReturnState(
|
|
103
|
-
value: string | string[] | undefined,
|
|
104
|
-
): ResultsReturnState | undefined {
|
|
105
|
-
return value === "success" || value === "cancelled" ? value : undefined;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Mirrors `ResultsClient.tsx` — a path is built only from an enabled locale.
|
|
109
|
-
const DEFAULT_LOCALE = "en";
|
|
110
|
-
const ENABLED_LOCALES = (
|
|
111
|
-
process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE
|
|
112
|
-
).split(",");
|
|
113
|
-
|
|
114
|
-
/** #9071 D3a — `/pricing`'s and the buy route's window. */
|
|
115
|
-
const SHOWN_READ_TTL_MS = 15_000;
|
|
116
|
-
/** #9071 NFR-4 — no landing read holds a visitor longer than this. */
|
|
117
|
-
const SHOWN_READ_TIMEOUT_MS = 5_000;
|
|
118
|
-
|
|
119
|
-
let shownRead:
|
|
120
|
-
| { at: number; read: Promise<WorkspaceShownSetWire | null> }
|
|
121
|
-
| undefined;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* #9071 D3a — the current shown set, or `null` for "nothing shown": no API
|
|
125
|
-
* origin in production (no call), `unconnected`, `empty`, an expired set, a
|
|
126
|
-
* non-2xx, a body the schema refuses, a throw, or no answer within 5 s.
|
|
127
|
-
* Concurrent and failed reads are shared like a good one.
|
|
128
|
-
*/
|
|
129
|
-
function readCurrentShownSet(): Promise<WorkspaceShownSetWire | null> {
|
|
130
|
-
if (process.env.NODE_ENV === "production" && !apiOriginConfigured()) {
|
|
131
|
-
return Promise.resolve(null);
|
|
132
|
-
}
|
|
133
|
-
const now = Date.now();
|
|
134
|
-
if (shownRead && now - shownRead.at < SHOWN_READ_TTL_MS) return shownRead.read;
|
|
135
|
-
const read = (async (): Promise<WorkspaceShownSetWire | null> => {
|
|
136
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
137
|
-
try {
|
|
138
|
-
const timeout = new Promise<null>((resolve) => {
|
|
139
|
-
timer = setTimeout(() => resolve(null), SHOWN_READ_TIMEOUT_MS);
|
|
140
|
-
});
|
|
141
|
-
const res = await Promise.race([offerings.shown(), timeout]);
|
|
142
|
-
if (res === null || !res.ok) return null;
|
|
143
|
-
const parsed = shownOfferingsAnswerSchema.safeParse(res.body);
|
|
144
|
-
if (!parsed.success || parsed.data.status !== "shown") return null;
|
|
145
|
-
return parsed.data.shownSet.state === "current" ? parsed.data.shownSet : null;
|
|
146
|
-
} catch {
|
|
147
|
-
return null;
|
|
148
|
-
} finally {
|
|
149
|
-
clearTimeout(timer);
|
|
150
|
-
}
|
|
151
|
-
})();
|
|
152
|
-
shownRead = { at: now, read };
|
|
153
|
-
return read;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function isOfferingsOffer(offer: unknown): boolean {
|
|
157
|
-
return (
|
|
158
|
-
typeof offer === "object" &&
|
|
159
|
-
offer !== null &&
|
|
160
|
-
typeof (offer as { lookupKey?: unknown }).lookupKey === "string"
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** #10827 — a shown set's prices of `offeringKey`: its own key, else its plan's. */
|
|
165
|
-
function shownPricesOf(shown: WorkspaceShownSetWire | null, offeringKey: string) {
|
|
166
|
-
const exact = parseLookupKey(offeringKey);
|
|
167
|
-
const plan = exact?.plan ?? offeringKey;
|
|
168
|
-
const product = shown?.offerings.find((o) => o.prices.some((p) => p.plan === plan));
|
|
169
|
-
const prices = product?.prices ?? [];
|
|
170
|
-
return {
|
|
171
|
-
plan,
|
|
172
|
-
product,
|
|
173
|
-
price:
|
|
174
|
-
exact !== null
|
|
175
|
-
? prices.find((p) => p.lookupKey === offeringKey)
|
|
176
|
-
: (prices.find((p) => p.period === "monthly") ?? prices[0]),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** `/pricing`'s last guard before markup: no format or control characters. */
|
|
181
|
-
function cleanProductText(value: string): string {
|
|
182
|
-
return value.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/gu, "");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* The shown product's Stripe description and marketing features, for the
|
|
187
|
-
* Product card (#11013 D-G), cleaned as `/pricing`'s `features()` cleans them:
|
|
188
|
-
* a feature that is nothing but format characters is dropped.
|
|
189
|
-
*/
|
|
190
|
-
function productCopy(
|
|
191
|
-
product: WorkspaceShownSetWire["offerings"][number] | undefined,
|
|
192
|
-
): Pick<ResultsOfferingCard, "description" | "features"> {
|
|
193
|
-
if (product === undefined) return {};
|
|
194
|
-
const description = product.description !== null ? cleanProductText(product.description) : "";
|
|
195
|
-
return {
|
|
196
|
-
...(description.length > 0 ? { description } : {}),
|
|
197
|
-
features: product.marketingFeatures.map(cleanProductText).filter((feature) => feature.length > 0),
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
type ResultLanding =
|
|
202
|
-
| { kind: "redirect"; url: string }
|
|
203
|
-
| { kind: "render"; card?: ResultsOfferingCard };
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* #9071 D3 / #10827 — where a completed walk lands: a redirect (the
|
|
207
|
-
* `/pricing?plan=` landing, or checkout), or the results page with the
|
|
208
|
-
* matched row's offering card. The served config is not re-parsed here, so
|
|
209
|
-
* every read of it is shape-checked and any throw renders as before.
|
|
210
|
-
*/
|
|
211
|
-
async function resultLanding(
|
|
212
|
-
config: FlowConfig,
|
|
213
|
-
answers: WaitlistAnswers,
|
|
214
|
-
locale: string,
|
|
215
|
-
): Promise<ResultLanding> {
|
|
216
|
-
try {
|
|
217
|
-
const byResult: unknown = config.recommendation?.byResult;
|
|
218
|
-
const authored = Array.isArray(byResult);
|
|
219
|
-
const offers: unknown = config.offers;
|
|
220
|
-
if (!authored && !(Array.isArray(offers) && offers.some(isOfferingsOffer))) {
|
|
221
|
-
return { kind: "render" };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
let routeTo: FlowResultRouteTo | undefined;
|
|
225
|
-
try {
|
|
226
|
-
routeTo = recommend(flowRecommendRegister(config), answers).routeTo;
|
|
227
|
-
} catch {
|
|
228
|
-
routeTo = undefined;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const safeLocale = ENABLED_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
|
|
232
|
-
const base = `/${safeLocale}/pricing`;
|
|
233
|
-
if (routeTo === undefined || routeTo.kind === "none") {
|
|
234
|
-
// An Offerings recommender with no fit lands on /pricing with no badge.
|
|
235
|
-
return authored ? { kind: "render" } : { kind: "redirect", url: base };
|
|
236
|
-
}
|
|
237
|
-
if (!authored && routeTo.kind === "offering") return { kind: "render" };
|
|
238
|
-
|
|
239
|
-
const { offeringKey } = routeTo;
|
|
240
|
-
const shown = await readCurrentShownSet();
|
|
241
|
-
const { plan, product, price } = shownPricesOf(shown, offeringKey);
|
|
242
|
-
// Built from the shown set's own grammar-checked Price, never the config key.
|
|
243
|
-
let checkoutHref: string | null = null;
|
|
244
|
-
if (routeTo.kind === "checkout") {
|
|
245
|
-
// A `{plan}` key lands on /pricing?plan=. A full key goes straight to
|
|
246
|
-
// the buy route — from the browser (`ResultsClient`), because the walk
|
|
247
|
-
// arrives by a client-side navigation and the buy route refuses
|
|
248
|
-
// anything but a top-level document load.
|
|
249
|
-
if (price !== undefined && parseLookupKey(offeringKey) === null) {
|
|
250
|
-
return { kind: "redirect", url: `${base}?plan=${price.plan}` };
|
|
251
|
-
}
|
|
252
|
-
if (price !== undefined) checkoutHref = offeringsCheckoutHref(price.lookupKey);
|
|
253
|
-
if (checkoutHref === null && !authored) return { kind: "redirect", url: base };
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// An offering's card — or a checkout row's offering not shown (a draft).
|
|
257
|
-
const legacy = Array.isArray(offers)
|
|
258
|
-
? (offers as unknown[]).find(
|
|
259
|
-
(o): o is { copy: { name: Parameters<typeof resolveLocalizedString>[0] } } =>
|
|
260
|
-
typeof o === "object" &&
|
|
261
|
-
o !== null &&
|
|
262
|
-
(o as { key?: unknown }).key === offeringKey &&
|
|
263
|
-
(o as { copy?: { name?: unknown } }).copy?.name !== undefined,
|
|
264
|
-
)
|
|
265
|
-
: undefined;
|
|
266
|
-
const title =
|
|
267
|
-
(product !== undefined ? cleanProductText(product.name) : undefined) ??
|
|
268
|
-
(legacy
|
|
269
|
-
? resolveLocalizedString(legacy.copy.name, locale, config.defaultLocale)
|
|
270
|
-
: plan.charAt(0).toUpperCase() + plan.slice(1).replace(/-/g, " "));
|
|
271
|
-
return {
|
|
272
|
-
kind: "render",
|
|
273
|
-
card: {
|
|
274
|
-
offeringKey,
|
|
275
|
-
title,
|
|
276
|
-
...productCopy(product),
|
|
277
|
-
...(price !== undefined
|
|
278
|
-
? {
|
|
279
|
-
price: { amount: price.amount, currency: price.currency, period: price.period },
|
|
280
|
-
href: checkoutHref ?? `${base}?plan=${price.plan}`,
|
|
281
|
-
}
|
|
282
|
-
: {}),
|
|
283
|
-
...(checkoutHref !== null ? { checkoutOnLoad: true } : {}),
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
} catch {
|
|
287
|
-
return { kind: "render" };
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* #11013 D-G (3) — Email links to an offering: the shown product's Product
|
|
293
|
-
* card, with Get Started to its `/pricing?plan=` landing; a product not in
|
|
294
|
-
* the shown set (a draft) gives none. Resolved only when no by-result card
|
|
295
|
-
* won, so the link never costs a second read.
|
|
296
|
-
*/
|
|
297
|
-
async function offeringConversionCard(
|
|
298
|
-
link: FlowConversionLink,
|
|
299
|
-
locale: string,
|
|
300
|
-
): Promise<ResultsConversionCard | undefined> {
|
|
301
|
-
if (link.kind !== "offering") return undefined;
|
|
302
|
-
try {
|
|
303
|
-
const shown = await readCurrentShownSet();
|
|
304
|
-
const { plan, product, price } = shownPricesOf(shown, link.id);
|
|
305
|
-
if (product === undefined) return undefined;
|
|
306
|
-
const safeLocale = ENABLED_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
|
|
307
|
-
return {
|
|
308
|
-
kind: "product",
|
|
309
|
-
name: cleanProductText(product.name),
|
|
310
|
-
...productCopy(product),
|
|
311
|
-
...(price !== undefined
|
|
312
|
-
? { price: { amount: price.amount, currency: price.currency, period: price.period } }
|
|
313
|
-
: {}),
|
|
314
|
-
href: `/${safeLocale}/pricing?plan=${price?.plan ?? plan}`,
|
|
315
|
-
};
|
|
316
|
-
} catch {
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/** The landing title — the record's `landing.title`, else step 1's (`magnet-page.tsx`'s `landingCopy`). */
|
|
322
|
-
function landingTitle(config: FlowConfig, locale: string): string {
|
|
323
|
-
const pick = (value: Record<string, string> | undefined): string | undefined =>
|
|
324
|
-
value === undefined ? undefined : resolveLocalizedString(value, locale, config.defaultLocale);
|
|
325
|
-
return pick(config.landing?.title) ?? pick(config.steps[0]!.copy.title) ?? config.slug;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
329
|
-
const { locale, slug, payload } = await params;
|
|
330
|
-
|
|
331
|
-
const decoded = decodePermalink(payload);
|
|
332
|
-
if (!decoded.ok || decoded.value.flowSlug !== slug) return {};
|
|
333
|
-
|
|
334
|
-
const read = await readServedFlow(slug);
|
|
335
|
-
if (read.kind !== "ok") return {};
|
|
336
|
-
|
|
337
|
-
const { recommendation } = read.config;
|
|
338
|
-
if (!recommendation) return {};
|
|
339
|
-
|
|
340
|
-
return {
|
|
341
|
-
title: resolveLocalizedString(
|
|
342
|
-
recommendation.copy.title,
|
|
343
|
-
locale,
|
|
344
|
-
read.config.defaultLocale,
|
|
345
|
-
),
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
export default async function Page({
|
|
350
|
-
params,
|
|
351
|
-
searchParams,
|
|
352
|
-
}: Props): Promise<ReactElement> {
|
|
353
|
-
const { locale, slug, payload } = await params;
|
|
354
|
-
|
|
355
|
-
const decoded = decodePermalink(payload);
|
|
356
|
-
if (!decoded.ok) {
|
|
357
|
-
redirect(`/${locale}/flows/${slug}`);
|
|
358
|
-
}
|
|
359
|
-
if (decoded.value.flowSlug !== slug) {
|
|
360
|
-
redirect(`/${locale}/flows/${slug}`);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// #10990 D3 — any failed read (refused, non-2xx, a 2xx that is not a
|
|
364
|
-
// flow, no answer within 5 s) lands on the flow's page, never a 500.
|
|
365
|
-
const read = await readServedFlow(slug);
|
|
366
|
-
if (read.kind !== "ok") {
|
|
367
|
-
redirect(`/${locale}/flows/${slug}`);
|
|
368
|
-
}
|
|
369
|
-
const config = read.config as FlowConfig & { conversionLink?: FlowConversionLink };
|
|
370
|
-
// #11013 D-C — today's condition, plus spec C's results-page predicate.
|
|
371
|
-
if (
|
|
372
|
-
config.mode !== "recommending" ||
|
|
373
|
-
(config.offers === undefined &&
|
|
374
|
-
config.recommendation?.byResult === undefined &&
|
|
375
|
-
!hasResultsPage(config))
|
|
376
|
-
) {
|
|
377
|
-
redirect(`/${locale}/flows/${slug}`);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
const landing = await resultLanding(
|
|
381
|
-
config,
|
|
382
|
-
decoded.value.answers,
|
|
383
|
-
locale,
|
|
384
|
-
);
|
|
385
|
-
if (landing.kind === "redirect") redirect(landing.url);
|
|
386
|
-
|
|
387
|
-
// #11013 decision 15 — Email links to, after a by-result card.
|
|
388
|
-
const conversionCard =
|
|
389
|
-
landing.card === undefined && config.conversionLink !== undefined
|
|
390
|
-
? await offeringConversionCard(config.conversionLink, locale)
|
|
391
|
-
: undefined;
|
|
392
|
-
|
|
393
|
-
// FR7 — read AFTER every redirect guard above, so a return param never
|
|
394
|
-
// changes which guard fires or where it sends the visitor.
|
|
395
|
-
const returnState = resolveReturnState((await searchParams)?.checkout);
|
|
396
|
-
|
|
397
|
-
// #11013 D-A — the frame's brand, built here because `site-logo.tsx` reads
|
|
398
|
-
// site config on the server; the exit leaves for the flow's landing.
|
|
399
|
-
const safeLocale = ENABLED_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
|
|
400
|
-
const brand = {
|
|
401
|
-
logomark: siteLogo(),
|
|
402
|
-
wordmark: <Image {...siteWordmarkAsset()} />,
|
|
403
|
-
title: landingTitle(config, locale),
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
return (
|
|
407
|
-
<ResultsClient
|
|
408
|
-
config={config}
|
|
409
|
-
locale={locale}
|
|
410
|
-
answers={decoded.value.answers}
|
|
411
|
-
slug={slug}
|
|
412
|
-
payload={payload}
|
|
413
|
-
brand={brand}
|
|
414
|
-
exitHref={`/${safeLocale}/flows/${slug}`}
|
|
415
|
-
{...(landing.card !== undefined ? { offeringCard: landing.card } : {})}
|
|
416
|
-
{...(conversionCard !== undefined ? { conversionCard } : {})}
|
|
417
|
-
{...(returnState !== undefined ? { returnState } : {})}
|
|
418
|
-
/>
|
|
419
|
-
);
|
|
420
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
"use server";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* save.actions.ts — Get your full report (#11013 spec E, D-F): validates with
|
|
6
|
-
* `flowSaveInputSchema`, calls `flows.resultsEmail` — spec C's
|
|
7
|
-
* `POST /v1/flows/:slug/results-email`, which writes the Lead, records the
|
|
8
|
-
* form's consents and runs the magnet's conversion email — and answers
|
|
9
|
-
* `{ ok: true }`, never an id. It replaced "Email me this plan"
|
|
10
|
-
* (`saveRecommendationAction` → `flows.save`, #4842 D7), which wrote a Lead
|
|
11
|
-
* but ran no conversion. A sibling of `flow.actions.ts` (ADR 0013
|
|
12
|
-
* `*.actions.ts`).
|
|
13
|
-
*
|
|
14
|
-
* A thin forwarder (SEC-E-1): the controls on who may attach an email and
|
|
15
|
-
* how often mail is sent — session ownership, dedupe, consent, the
|
|
16
|
-
* per-recipient, per-workspace and per-IP limits — are the route's; this
|
|
17
|
-
* action adds the same slug and body parse, bot check and visitor-IP
|
|
18
|
-
* forwarding its predecessor had, and no trust boundary in the site.
|
|
19
|
-
*
|
|
20
|
-
* Split out of `checkout.actions.ts` by #6786: the results page's email
|
|
21
|
-
* moment ships with the page (the `flows` surface, signal-collectors), while
|
|
22
|
-
* `startCheckoutAction` stays commerce's. The shared validation,
|
|
23
|
-
* IP-forwarding and status → kind helpers are `email-moment.ts`.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { flows } from "@working-theory/api-client";
|
|
27
|
-
import type { FlowSaveInput } from "@working-theory/validation";
|
|
28
|
-
import {
|
|
29
|
-
flowSaveInputSchema,
|
|
30
|
-
flowSlugSchema,
|
|
31
|
-
} from "@working-theory/validation";
|
|
32
|
-
|
|
33
|
-
import { runBotCheck } from "../../../../lib/bot-check";
|
|
34
|
-
|
|
35
|
-
import type { EmailMomentFailure } from "./email-moment";
|
|
36
|
-
import {
|
|
37
|
-
emailMomentFields,
|
|
38
|
-
errorName,
|
|
39
|
-
failureFor,
|
|
40
|
-
resolveVisitorIpInit,
|
|
41
|
-
} from "./email-moment";
|
|
42
|
-
|
|
43
|
-
export type ResultsEmailActionResult = { ok: true } | EmailMomentFailure;
|
|
44
|
-
|
|
45
|
-
export async function sendResultsEmailAction(
|
|
46
|
-
slug: string,
|
|
47
|
-
body: FlowSaveInput,
|
|
48
|
-
): Promise<ResultsEmailActionResult> {
|
|
49
|
-
const parsedSlug = flowSlugSchema.safeParse(slug);
|
|
50
|
-
if (!parsedSlug.success) return { ok: false, kind: "invalid_input" };
|
|
51
|
-
|
|
52
|
-
const parsed = flowSaveInputSchema.safeParse(body);
|
|
53
|
-
if (!parsed.success) return { ok: false, kind: "invalid_input" };
|
|
54
|
-
|
|
55
|
-
const payload = emailMomentFields(parsed.data);
|
|
56
|
-
|
|
57
|
-
// #9255 D4 — the spoke edge's bot check, after the input checks and before
|
|
58
|
-
// the write.
|
|
59
|
-
const botCheck = await runBotCheck({
|
|
60
|
-
source: "bot-check",
|
|
61
|
-
target: "sendResultsEmailAction",
|
|
62
|
-
scope: "write",
|
|
63
|
-
});
|
|
64
|
-
if (botCheck !== "pass") return { ok: false, kind: "unavailable" };
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const visitorIpInit = await resolveVisitorIpInit();
|
|
68
|
-
const res = visitorIpInit
|
|
69
|
-
? await flows.resultsEmail(parsedSlug.data, payload, visitorIpInit)
|
|
70
|
-
: await flows.resultsEmail(parsedSlug.data, payload);
|
|
71
|
-
if (!res.ok) {
|
|
72
|
-
const failure = failureFor(res);
|
|
73
|
-
console.error(
|
|
74
|
-
`[sendResultsEmailAction] slug=${parsedSlug.data} kind=${failure.kind} status=${res.status}`,
|
|
75
|
-
);
|
|
76
|
-
return failure;
|
|
77
|
-
}
|
|
78
|
-
return { ok: true };
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.error(
|
|
81
|
-
`[sendResultsEmailAction] slug=${parsedSlug.data} kind=network errName=${errorName(err)}`,
|
|
82
|
-
);
|
|
83
|
-
return { ok: false, kind: "network" };
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* served-flow.ts — the one read of a served flow config (#10990 D1).
|
|
4
|
-
*
|
|
5
|
-
* `readServedFlow(slug)` asks the hub (`flows.get`) and answers one of four
|
|
6
|
-
* kinds. It is shared by the magnet pages (`magnet-page.tsx`'s `readMagnet`,
|
|
7
|
-
* which adds a 15-second per-instance cache) and the results permalink
|
|
8
|
-
* (`results/[payload]/page.tsx`, uncached). It imports nothing of either
|
|
9
|
-
* page's render graph, so the results route can load it alone.
|
|
10
|
-
*
|
|
11
|
-
* - `ok` only for a 2xx whose body is a served flow (`isServedFlow`).
|
|
12
|
-
* - `absent` only for a 404 (the hub's `flow_not_found`: no such flow, or a
|
|
13
|
-
* draft).
|
|
14
|
-
* - `not-configured` for the hub's 503 `flows_not_configured`, or a failed
|
|
15
|
-
* read with no API origin configured (#9219).
|
|
16
|
-
* - `unavailable` for everything else: a refused connection, any other
|
|
17
|
-
* non-2xx (5xx, 401, 403, 429, …), a 2xx that is not a served flow, and no
|
|
18
|
-
* answer within 5 seconds. A firewall's 403 or a block page's 2xx therefore
|
|
19
|
-
* shows the site's contact email, never a 404 or a 500.
|
|
20
|
-
*/
|
|
21
|
-
import { flows } from "@working-theory/api-client";
|
|
22
|
-
import type { FlowConfig } from "@working-theory/validation";
|
|
23
|
-
|
|
24
|
-
import { browserApiOrigin } from "../../../../lib/api-origin.generated";
|
|
25
|
-
|
|
26
|
-
export type MagnetRead =
|
|
27
|
-
| { kind: "ok"; config: FlowConfig }
|
|
28
|
-
| { kind: "absent" }
|
|
29
|
-
| { kind: "unavailable" }
|
|
30
|
-
| { kind: "not-configured" };
|
|
31
|
-
|
|
32
|
-
/** No flow read holds a visitor longer than this (the results page's #9071 NFR-4 value). */
|
|
33
|
-
export const SERVED_FLOW_TIMEOUT_MS = 5_000;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Whether an API origin is configured: the three names `getApiBase()` in
|
|
37
|
-
* packages/api-client/src/http.ts reads, in step with it on a hub. Without one
|
|
38
|
-
* that function answers `localhost:3001`. The browser-facing origin comes from
|
|
39
|
-
* the topology seam (#7874 D12), which a spoke renders with no env read, so a
|
|
40
|
-
* spoke passes its own `env:check` (#9480). A spoke diverges on purpose: the
|
|
41
|
-
* browser-facing name set on one at runtime counts as no origin here.
|
|
42
|
-
*/
|
|
43
|
-
export function apiOriginConfigured(): boolean {
|
|
44
|
-
return Boolean(
|
|
45
|
-
process.env.AILK_API_URL ||
|
|
46
|
-
browserApiOrigin() ||
|
|
47
|
-
process.env.NEXT_PUBLIC_API_URL,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** The flows route's own answer when its hub has no database (apps/api `flows_not_configured`). */
|
|
52
|
-
function isFlowsNotConfigured(body: unknown): boolean {
|
|
53
|
-
const error = (body as { error?: { code?: unknown } } | null)?.error;
|
|
54
|
-
return error?.code === "flows_not_configured";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** A read that failed: `not-configured` when there is no hub to ask, else `unavailable`. */
|
|
58
|
-
function failedRead(): MagnetRead {
|
|
59
|
-
return apiOriginConfigured() ? { kind: "unavailable" } : { kind: "not-configured" };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Whether a 2xx body is a served flow: only what the renderers dereference
|
|
64
|
-
* before any schema-checked path. Deliberately not `flowConfigSchema` — the
|
|
65
|
-
* hub parses the config before serving it, and a spoke's schema can be older
|
|
66
|
-
* than its hub's.
|
|
67
|
-
*/
|
|
68
|
-
export function isServedFlow(body: unknown): body is FlowConfig {
|
|
69
|
-
if (typeof body !== "object" || body === null) return false;
|
|
70
|
-
const { slug, steps } = body as { slug?: unknown; steps?: unknown };
|
|
71
|
-
return typeof slug === "string" && Array.isArray(steps) && steps.length > 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** The served flow config for `slug`, classified (D1). */
|
|
75
|
-
export async function readServedFlow(slug: string): Promise<MagnetRead> {
|
|
76
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
77
|
-
try {
|
|
78
|
-
const timeout = new Promise<null>((resolve) => {
|
|
79
|
-
timer = setTimeout(() => resolve(null), SERVED_FLOW_TIMEOUT_MS);
|
|
80
|
-
});
|
|
81
|
-
const res = await Promise.race([flows.get(slug), timeout]);
|
|
82
|
-
if (res === null) return failedRead();
|
|
83
|
-
if (res.ok) return isServedFlow(res.body) ? { kind: "ok", config: res.body } : failedRead();
|
|
84
|
-
if (res.status === 503 && isFlowsNotConfigured(res.body)) return { kind: "not-configured" };
|
|
85
|
-
return res.status === 404 ? { kind: "absent" } : failedRead();
|
|
86
|
-
} catch {
|
|
87
|
-
return failedRead();
|
|
88
|
-
} finally {
|
|
89
|
-
clearTimeout(timer);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* /[locale]/flows/[slug]/start — the flow half of the two-route tool
|
|
4
|
-
* (#5053 D3/D5). Standard magnet page (#8840): rendered by
|
|
5
|
-
* `magnet-page.tsx`'s `renderMagnetStart`, chrome-free with the back arrow to
|
|
6
|
-
* `/flows/<slug>` (`lib/magnet-routes.ts`).
|
|
7
|
-
*
|
|
8
|
-
* `flowRouteMetadata` (`@working-theory/metadata`, mounted by the renderer)
|
|
9
|
-
* supplies `noindex, follow` — the whole point of D4 is that this route does
|
|
10
|
-
* NOT write the robots value, it gets it from what it mounts. `follow`, not
|
|
11
|
-
* `nofollow`: the links out of a flow still carry.
|
|
12
|
-
*/
|
|
13
|
-
import type { Metadata } from "next";
|
|
14
|
-
import type { ReactElement } from "react";
|
|
15
|
-
|
|
16
|
-
import { renderMagnetStart, renderMagnetStartMetadata } from "../magnet-page";
|
|
17
|
-
|
|
18
|
-
export const dynamic = "force-dynamic";
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
25
|
-
const { locale, slug } = await params;
|
|
26
|
-
return renderMagnetStartMetadata({ slug, locale });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default async function Page({ params }: Props): Promise<ReactElement> {
|
|
30
|
-
const { locale, slug } = await params;
|
|
31
|
-
return renderMagnetStart({ slug, locale, backHref: `/flows/${slug}` });
|
|
32
|
-
}
|