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,98 +0,0 @@
|
|
|
1
|
-
"use client"; // submits through the account's Server Action and shows its outcome
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SupportForm — Contact support's form (#7430, spec 7423 D11): a subject and
|
|
5
|
-
* a message, filed by `submitSupportRequest` as a contact lead of kind
|
|
6
|
-
* `support`. The email is the session's, so the form never asks for it.
|
|
7
|
-
* The fields are controlled so a failed submit keeps what was typed.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
Button,
|
|
12
|
-
InlineMessage,
|
|
13
|
-
Input,
|
|
14
|
-
Label,
|
|
15
|
-
Textarea,
|
|
16
|
-
} from "@working-theory/ui/primitives";
|
|
17
|
-
import { useActionState, useId, useState, type ReactElement } from "react";
|
|
18
|
-
|
|
19
|
-
import { submitSupportRequest, type SupportRequestState } from "../support-actions";
|
|
20
|
-
|
|
21
|
-
export interface SupportFormLabels {
|
|
22
|
-
subject: string;
|
|
23
|
-
message: string;
|
|
24
|
-
submit: string;
|
|
25
|
-
submitting: string;
|
|
26
|
-
required: string;
|
|
27
|
-
success: string;
|
|
28
|
-
error: string;
|
|
29
|
-
unavailable: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function SupportForm({ labels }: { labels: SupportFormLabels }): ReactElement {
|
|
33
|
-
const subjectId = useId();
|
|
34
|
-
const messageId = useId();
|
|
35
|
-
const [subject, setSubject] = useState("");
|
|
36
|
-
const [message, setMessage] = useState("");
|
|
37
|
-
const [state, formAction, pending] = useActionState<SupportRequestState, FormData>(
|
|
38
|
-
submitSupportRequest,
|
|
39
|
-
{ kind: "idle" },
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
if (state.kind === "success") {
|
|
43
|
-
return (
|
|
44
|
-
<InlineMessage variant="success" role="status" className="text-body-sm">
|
|
45
|
-
{labels.success}
|
|
46
|
-
</InlineMessage>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<form action={formAction} className="flex flex-col gap-4" data-testid="account-support-form">
|
|
52
|
-
<input type="hidden" name="kind" value="support" />
|
|
53
|
-
<div className="flex flex-col gap-2">
|
|
54
|
-
<Label htmlFor={subjectId}>{labels.subject}</Label>
|
|
55
|
-
<Input
|
|
56
|
-
id={subjectId}
|
|
57
|
-
name="subject"
|
|
58
|
-
value={subject}
|
|
59
|
-
maxLength={200}
|
|
60
|
-
required
|
|
61
|
-
onChange={(event) => setSubject(event.target.value)}
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
64
|
-
<div className="flex flex-col gap-2">
|
|
65
|
-
<Label htmlFor={messageId}>{labels.message}</Label>
|
|
66
|
-
<Textarea
|
|
67
|
-
id={messageId}
|
|
68
|
-
name="message"
|
|
69
|
-
value={message}
|
|
70
|
-
rows={6}
|
|
71
|
-
maxLength={5000}
|
|
72
|
-
required
|
|
73
|
-
onChange={(event) => setMessage(event.target.value)}
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
{state.kind === "error" ? (
|
|
77
|
-
<InlineMessage variant="error">
|
|
78
|
-
{state.reason === "required"
|
|
79
|
-
? labels.required
|
|
80
|
-
: state.reason === "unavailable"
|
|
81
|
-
? labels.unavailable
|
|
82
|
-
: labels.error}
|
|
83
|
-
</InlineMessage>
|
|
84
|
-
) : null}
|
|
85
|
-
<div>
|
|
86
|
-
<Button
|
|
87
|
-
type="submit"
|
|
88
|
-
disabled={pending}
|
|
89
|
-
// 44px on a phone (a touch-first context); the 36px primary from md up (DESIGN.md §4).
|
|
90
|
-
className="max-md:min-h-11"
|
|
91
|
-
data-testid="account-support-submit"
|
|
92
|
-
>
|
|
93
|
-
{pending ? labels.submitting : labels.submit}
|
|
94
|
-
</Button>
|
|
95
|
-
</div>
|
|
96
|
-
</form>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* account/support-actions.ts — the account area's Support request action.
|
|
5
|
-
*
|
|
6
|
-
* `submitSupportRequest` (#7430, spec 7423 D11) — files a Support request
|
|
7
|
-
* as a contact lead: `POST /v1/leads/submit` with `source: "web"`, the
|
|
8
|
-
* session's email and the payload `{ kind: "support", subject, message }`.
|
|
9
|
-
* Every request it files is `support`, whatever is posted (#8232 D12): an
|
|
10
|
-
* account-deletion request goes through `member.requestDeletion`
|
|
11
|
-
* (`profile-actions.ts`), which files it with the deployment that holds the
|
|
12
|
-
* account, so this action needs no topology test (SEC-7894-11). No `siteId` — the
|
|
13
|
-
* route resolves the tenant server-side and ignores a posted one (#6203).
|
|
14
|
-
* The request lands in the admin Inbox as a message. Not a `*Action`-suffixed
|
|
15
|
-
* export in a `*.actions.ts` file: lead capture already has its MCP twin
|
|
16
|
-
* (`captureLeadAction` ↔ `ailkCaptureLead`), so this is not a second
|
|
17
|
-
* Server-Action/MCP-tool pair (apps/mcp's parity test).
|
|
18
|
-
*
|
|
19
|
-
* Its own module, apart from `actions.ts`, so `create-ailk sync-routes` can
|
|
20
|
-
* bring it along with the Support and User settings routes as a new file: a
|
|
21
|
-
* scaffold's existing `actions.ts` is never overwritten.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { leads, visitorForwardHeaders } from "@working-theory/api-client";
|
|
25
|
-
import { headers } from "next/headers";
|
|
26
|
-
|
|
27
|
-
import { readSession } from "../../../../lib/topology.generated";
|
|
28
|
-
|
|
29
|
-
/** PII-safe error identity for logs (the `checkout.actions.ts` idiom: `err.name` only). */
|
|
30
|
-
function errorName(err: unknown): string {
|
|
31
|
-
return err instanceof Error ? err.name : "unknown";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** What the request forms render after a submit. */
|
|
35
|
-
export type SupportRequestState =
|
|
36
|
-
| { kind: "idle" }
|
|
37
|
-
| { kind: "success" }
|
|
38
|
-
| { kind: "error"; reason: "required" | "failed" | "unavailable" };
|
|
39
|
-
|
|
40
|
-
const MAX_SUBJECT = 200;
|
|
41
|
-
const MAX_MESSAGE = 5000;
|
|
42
|
-
|
|
43
|
-
function field(formData: FormData, name: string): string {
|
|
44
|
-
const value = formData.get(name);
|
|
45
|
-
return typeof value === "string" ? value.trim() : "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** A 503 whose body names `lead_capture_not_configured` (contact.actions.ts's reading). */
|
|
49
|
-
function isNotConfigured(res: { status: number; body: unknown }): boolean {
|
|
50
|
-
return (
|
|
51
|
-
res.status === 503 &&
|
|
52
|
-
typeof res.body === "object" &&
|
|
53
|
-
res.body !== null &&
|
|
54
|
-
(res.body as { error?: unknown }).error === "lead_capture_not_configured"
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Files the signed-in member's Support request. The email is
|
|
60
|
-
* the session's own — never a form field — so a request always names the
|
|
61
|
-
* person who sent it.
|
|
62
|
-
*/
|
|
63
|
-
export async function submitSupportRequest(
|
|
64
|
-
_prev: SupportRequestState,
|
|
65
|
-
formData: FormData,
|
|
66
|
-
): Promise<SupportRequestState> {
|
|
67
|
-
const subject = field(formData, "subject");
|
|
68
|
-
const message = field(formData, "message");
|
|
69
|
-
if (!subject || !message || subject.length > MAX_SUBJECT || message.length > MAX_MESSAGE) {
|
|
70
|
-
return { kind: "error", reason: "required" };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const requestHeaders = await headers();
|
|
75
|
-
const session = await readSession(requestHeaders);
|
|
76
|
-
if (!session) return { kind: "error", reason: "failed" };
|
|
77
|
-
|
|
78
|
-
const body = {
|
|
79
|
-
source: "web",
|
|
80
|
-
email: session.user.email,
|
|
81
|
-
payload: { kind: "support", subject, message },
|
|
82
|
-
};
|
|
83
|
-
// #7394 — a spoke counts the request against the visitor's own budget.
|
|
84
|
-
const forwarded = visitorForwardHeaders(
|
|
85
|
-
requestHeaders,
|
|
86
|
-
process.env.AILK_VISITOR_FORWARD_KEY,
|
|
87
|
-
);
|
|
88
|
-
const res = forwarded
|
|
89
|
-
? await leads.submit(body, { headers: forwarded })
|
|
90
|
-
: await leads.submit(body);
|
|
91
|
-
if (!res.ok) {
|
|
92
|
-
console.error(`[submitSupportRequest] status=${res.status}`);
|
|
93
|
-
return { kind: "error", reason: isNotConfigured(res) ? "unavailable" : "failed" };
|
|
94
|
-
}
|
|
95
|
-
return { kind: "success" };
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(`[submitSupportRequest] errName=${errorName(err)}`);
|
|
98
|
-
return { kind: "error", reason: "failed" };
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The standard checkout return pages (#8748 D1, D5, D11; spec
|
|
3
|
-
* docs/specs/8748-a-standard-spoke-checkout-route-spec.md AC-2).
|
|
4
|
-
*
|
|
5
|
-
* Both pages are noindex, render their namespace's copy, read no search
|
|
6
|
-
* parameter and never import the checkout standard. On any build that is
|
|
7
|
-
* not a spoke they call `notFound()` before reading a translation.
|
|
8
|
-
*/
|
|
9
|
-
import { readFileSync } from "node:fs";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
|
|
12
|
-
import { render } from "@testing-library/react";
|
|
13
|
-
|
|
14
|
-
const mockNotFound = jest.fn(() => {
|
|
15
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
16
|
-
});
|
|
17
|
-
jest.mock("next/navigation", () => ({
|
|
18
|
-
__esModule: true,
|
|
19
|
-
notFound: () => mockNotFound(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const mockGetTranslations = jest.fn();
|
|
23
|
-
jest.mock("next-intl/server", () => {
|
|
24
|
-
const actual = jest.requireActual("next-intl/server");
|
|
25
|
-
return {
|
|
26
|
-
...actual,
|
|
27
|
-
getTranslations: (arg: unknown) => {
|
|
28
|
-
mockGetTranslations(arg);
|
|
29
|
-
return actual.getTranslations(arg);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const mockTopology: { value: "hub" | "spoke" } = { value: "spoke" };
|
|
35
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: the topology is a generated constant (#7426), not a runtime input; the seam IS the boundary between a hub and a spoke build, and no env or HTTP surface selects it.
|
|
36
|
-
jest.mock("../../../../lib/topology.generated", () => ({
|
|
37
|
-
__esModule: true,
|
|
38
|
-
get TOPOLOGY() {
|
|
39
|
-
return mockTopology.value;
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
// The thank-you page reads a paid session through the package (#8757 D13);
|
|
44
|
-
// with no `session_id` it never calls it, so a stub is enough here.
|
|
45
|
-
// `virtual`: CI runs this suite before the package's dist is built.
|
|
46
|
-
jest.mock(
|
|
47
|
-
"@working-theory/spoke-checkout",
|
|
48
|
-
() => ({ __esModule: true, readPaidCheckoutEmail: jest.fn(async () => null) }),
|
|
49
|
-
{ virtual: true },
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
import messages from "../../../../messages/en.json";
|
|
53
|
-
import ThankYouPage, {
|
|
54
|
-
generateMetadata as thankYouMetadata,
|
|
55
|
-
} from "../thank-you/page";
|
|
56
|
-
import UnavailablePage, {
|
|
57
|
-
generateMetadata as unavailableMetadata,
|
|
58
|
-
} from "../unavailable/page";
|
|
59
|
-
|
|
60
|
-
type PageModule = {
|
|
61
|
-
name: string;
|
|
62
|
-
dir: string;
|
|
63
|
-
namespace: "checkoutThankYou" | "checkoutUnavailable";
|
|
64
|
-
Page: typeof ThankYouPage;
|
|
65
|
-
generateMetadata: typeof thankYouMetadata;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const PAGES: PageModule[] = [
|
|
69
|
-
{
|
|
70
|
-
name: "thank-you",
|
|
71
|
-
dir: "thank-you",
|
|
72
|
-
namespace: "checkoutThankYou",
|
|
73
|
-
Page: ThankYouPage,
|
|
74
|
-
generateMetadata: thankYouMetadata,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "unavailable",
|
|
78
|
-
dir: "unavailable",
|
|
79
|
-
namespace: "checkoutUnavailable",
|
|
80
|
-
Page: UnavailablePage,
|
|
81
|
-
generateMetadata: unavailableMetadata,
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
const params = (): Promise<{ locale: string }> =>
|
|
86
|
-
Promise.resolve({ locale: "en" });
|
|
87
|
-
|
|
88
|
-
function source(dir: string): string {
|
|
89
|
-
return readFileSync(join(__dirname, "..", dir, "page.tsx"), "utf8");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
beforeEach(() => {
|
|
93
|
-
mockNotFound.mockClear();
|
|
94
|
-
mockGetTranslations.mockClear();
|
|
95
|
-
mockTopology.value = "spoke";
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe.each(PAGES)("the checkout $name page (#8748 AC-2)", (page) => {
|
|
99
|
-
it("is noindex", async () => {
|
|
100
|
-
const metadata = await page.generateMetadata({ params: params() });
|
|
101
|
-
expect(metadata.robots).toEqual({ index: false, follow: false });
|
|
102
|
-
expect(metadata.title).toBe(messages[page.namespace].title);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("renders its namespace's title", async () => {
|
|
106
|
-
const { getByText } = render(await page.Page({ params: params() }));
|
|
107
|
-
expect(getByText(messages[page.namespace].title)).toBeTruthy();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("never imports lib/checkout, and only the thank-you page reads searchParams (#8757 D13)", () => {
|
|
111
|
-
const text = source(page.dir);
|
|
112
|
-
expect(text).not.toMatch(/lib\/checkout["']/);
|
|
113
|
-
if (page.dir !== "thank-you") expect(text).not.toContain("searchParams");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("calls notFound() before any translation read when the build is a hub (D11)", async () => {
|
|
117
|
-
mockTopology.value = "hub";
|
|
118
|
-
await expect(page.Page({ params: params() })).rejects.toThrow(
|
|
119
|
-
"NEXT_NOT_FOUND",
|
|
120
|
-
);
|
|
121
|
-
await expect(page.generateMetadata({ params: params() })).rejects.toThrow(
|
|
122
|
-
"NEXT_NOT_FOUND",
|
|
123
|
-
);
|
|
124
|
-
expect(mockNotFound).toHaveBeenCalledTimes(2);
|
|
125
|
-
expect(mockGetTranslations).not.toHaveBeenCalled();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("the checkout unavailable page's way out", () => {
|
|
130
|
-
it("links /contact", async () => {
|
|
131
|
-
const { container } = render(await UnavailablePage({ params: params() }));
|
|
132
|
-
const hrefs = [...container.querySelectorAll("a")].map((a) =>
|
|
133
|
-
a.getAttribute("href"),
|
|
134
|
-
);
|
|
135
|
-
expect(hrefs.some((href) => href === "/contact" || href === "/en/contact")).toBe(
|
|
136
|
-
true,
|
|
137
|
-
);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The checkout thank-you page's "Open your account" link (#8757 D13, AC-9).
|
|
3
|
-
*
|
|
4
|
-
* A `session_id` of a paid session of this site renders the link with the
|
|
5
|
-
* buyer's email (`accountInviteHref`); anything the package answers `null`
|
|
6
|
-
* for renders it with no email. The page is noindex, sends no referrer,
|
|
7
|
-
* renders dynamically, never touches a cookie, and over a visitor's budget
|
|
8
|
-
* of 10 reads per 10 minutes it makes no Stripe read at all.
|
|
9
|
-
*/
|
|
10
|
-
import { readFileSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
|
|
13
|
-
import { render } from "@testing-library/react";
|
|
14
|
-
import { localeHref } from "@working-theory/ui";
|
|
15
|
-
|
|
16
|
-
const mockRead = jest.fn<Promise<string | null>, [{ site: string }, string]>();
|
|
17
|
-
// `virtual`: CI runs this suite before the package's dist is built.
|
|
18
|
-
jest.mock(
|
|
19
|
-
"@working-theory/spoke-checkout",
|
|
20
|
-
() => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
readPaidCheckoutEmail: (config: { site: string }, id: string) =>
|
|
23
|
-
mockRead(config, id),
|
|
24
|
-
}),
|
|
25
|
-
{ virtual: true },
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
jest.mock("next/navigation", () => ({
|
|
29
|
-
__esModule: true,
|
|
30
|
-
notFound: () => {
|
|
31
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
32
|
-
},
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const mockVisitor = { ip: "203.0.113.7" };
|
|
36
|
-
jest.mock("next/headers", () => ({
|
|
37
|
-
__esModule: true,
|
|
38
|
-
headers: jest.fn(async () => ({
|
|
39
|
-
// #9967 D1 — the limiter reads only the edge-set address, on Vercel.
|
|
40
|
-
get: (name: string) =>
|
|
41
|
-
name === "x-vercel-forwarded-for" ? mockVisitor.ip : null,
|
|
42
|
-
})),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: SIGN_IN_PROVIDER and TOPOLOGY are generated per-build constants (#8757 D13), not runtime inputs; no env or HTTP surface selects them.
|
|
46
|
-
jest.mock("../../../../lib/topology.generated", () => ({
|
|
47
|
-
__esModule: true,
|
|
48
|
-
SIGN_IN_PROVIDER: "site",
|
|
49
|
-
TOPOLOGY: "spoke",
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
import { accountInviteHref } from "../../../../lib/account-invite";
|
|
53
|
-
import { checkoutConfig } from "../../../../lib/checkout-config";
|
|
54
|
-
import messages from "../../../../messages/en.json";
|
|
55
|
-
import { __resetRateLimit } from "../../../../src/lib/rate-limit";
|
|
56
|
-
import * as pageModule from "../thank-you/page";
|
|
57
|
-
|
|
58
|
-
const SESSION = "cs_test_paidOwnSite01";
|
|
59
|
-
const EMAIL = "buyer@example.com";
|
|
60
|
-
|
|
61
|
-
const params = (): Promise<{ locale: string }> =>
|
|
62
|
-
Promise.resolve({ locale: "en" });
|
|
63
|
-
const search = (q: Record<string, string>) => Promise.resolve(q);
|
|
64
|
-
|
|
65
|
-
async function linkHref(
|
|
66
|
-
q: Record<string, string> = { session_id: SESSION },
|
|
67
|
-
): Promise<string> {
|
|
68
|
-
const { getByTestId, unmount } = render(
|
|
69
|
-
await pageModule.default({ params: params(), searchParams: search(q) }),
|
|
70
|
-
);
|
|
71
|
-
const link = getByTestId("checkout-open-account");
|
|
72
|
-
expect(link.textContent).toBe(messages.checkoutThankYou.openAccount);
|
|
73
|
-
const href = link.getAttribute("href") ?? "";
|
|
74
|
-
unmount();
|
|
75
|
-
return href;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const priorVercel = process.env.VERCEL;
|
|
79
|
-
|
|
80
|
-
beforeEach(() => {
|
|
81
|
-
mockRead.mockReset();
|
|
82
|
-
__resetRateLimit();
|
|
83
|
-
mockVisitor.ip = "203.0.113.7";
|
|
84
|
-
process.env.VERCEL = "1";
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
afterAll(() => {
|
|
88
|
-
if (priorVercel === undefined) delete process.env.VERCEL;
|
|
89
|
-
else process.env.VERCEL = priorVercel;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe("the thank-you page's account link (#8757 D13, AC-9)", () => {
|
|
93
|
-
it("links accountInviteHref(locale, email) for a paid own-site session", async () => {
|
|
94
|
-
mockRead.mockResolvedValue(EMAIL);
|
|
95
|
-
expect(await linkHref()).toBe(accountInviteHref("en", EMAIL));
|
|
96
|
-
expect(mockRead).toHaveBeenCalledWith(
|
|
97
|
-
{ site: checkoutConfig.site },
|
|
98
|
-
SESSION,
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("links with no email parameter when the read answers null", async () => {
|
|
103
|
-
mockRead.mockResolvedValue(null);
|
|
104
|
-
const href = await linkHref();
|
|
105
|
-
expect(href).not.toContain("email=");
|
|
106
|
-
expect(href).toBe(localeHref("en", "/account"));
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("links with no email and makes no read when there is no session_id", async () => {
|
|
110
|
-
expect(await linkHref({})).not.toContain("email=");
|
|
111
|
-
expect(mockRead).not.toHaveBeenCalled();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("makes no read on the 11th visit from one visitor within 10 minutes", async () => {
|
|
115
|
-
mockRead.mockResolvedValue(EMAIL);
|
|
116
|
-
for (let i = 0; i < 10; i += 1) await linkHref();
|
|
117
|
-
expect(mockRead).toHaveBeenCalledTimes(10);
|
|
118
|
-
const href = await linkHref();
|
|
119
|
-
expect(mockRead).toHaveBeenCalledTimes(10);
|
|
120
|
-
expect(href).not.toContain("email=");
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("counts each visitor separately", async () => {
|
|
124
|
-
mockRead.mockResolvedValue(EMAIL);
|
|
125
|
-
for (let i = 0; i < 10; i += 1) await linkHref();
|
|
126
|
-
mockVisitor.ip = "198.51.100.9";
|
|
127
|
-
expect(await linkHref()).toBe(accountInviteHref("en", EMAIL));
|
|
128
|
-
expect(mockRead).toHaveBeenCalledTimes(11);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("is noindex, sends no referrer and renders dynamically", async () => {
|
|
132
|
-
const metadata = await pageModule.generateMetadata({ params: params() });
|
|
133
|
-
expect(metadata.referrer).toBe("no-referrer");
|
|
134
|
-
expect(metadata.robots).toEqual({ index: false, follow: false });
|
|
135
|
-
expect(pageModule.dynamic).toBe("force-dynamic");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("never reads or sets a cookie", () => {
|
|
139
|
-
const text = readFileSync(
|
|
140
|
-
join(__dirname, "..", "thank-you", "page.tsx"),
|
|
141
|
-
"utf8",
|
|
142
|
-
);
|
|
143
|
-
expect(text).not.toMatch(/\bcookies\b/);
|
|
144
|
-
expect(text).not.toMatch(/\.set\(/);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// The checkout thank-you page — Standard spoke checkout page (#8748).
|
|
2
|
-
// Kept current by `create-ailk update`: do not edit it. This site's checkout
|
|
3
|
-
// data is lib/checkout-config.ts, the one file to edit.
|
|
4
|
-
// Stripe returns a buyer here after paying. It calls neither the hub nor any
|
|
5
|
-
// fulfilment: the webhook is what fulfils the order. It reads the one
|
|
6
|
-
// `session_id` Stripe appended, to offer "Open your account" with the buyer's
|
|
7
|
-
// email (#8757 D13): a paid session of this site, under 24 hours old, read
|
|
8
|
-
// within a per-visitor budget, held per server instance (best effort: the
|
|
9
|
-
// session id's length, not this budget, is what stops guessing). It never
|
|
10
|
-
// sets a cookie and never signs anyone in. It is served on a spoke only: any other build answers notFound().
|
|
11
|
-
import { readPaidCheckoutEmail } from "@working-theory/spoke-checkout";
|
|
12
|
-
import { Button, Container, Link, localeHref } from "@working-theory/ui";
|
|
13
|
-
import { SectionRenderer } from "@working-theory/ui/sections";
|
|
14
|
-
import type { PageSection } from "@working-theory/validation";
|
|
15
|
-
import type { Metadata } from "next";
|
|
16
|
-
import { headers } from "next/headers";
|
|
17
|
-
import { notFound } from "next/navigation";
|
|
18
|
-
import { getTranslations } from "next-intl/server";
|
|
19
|
-
import type { ReactElement } from "react";
|
|
20
|
-
|
|
21
|
-
import { accountInviteHref } from "../../../../lib/account-invite";
|
|
22
|
-
import { checkoutConfig } from "../../../../lib/checkout-config";
|
|
23
|
-
import { TOPOLOGY } from "../../../../lib/topology.generated";
|
|
24
|
-
import {
|
|
25
|
-
checkRateLimit,
|
|
26
|
-
clientIpFromHeaders,
|
|
27
|
-
} from "../../../../src/lib/rate-limit";
|
|
28
|
-
|
|
29
|
-
// Next sends `private, no-cache, no-store` for a force-dynamic render, so the
|
|
30
|
-
// page (it can carry an email) is never cached (#8757 D13).
|
|
31
|
-
export const dynamic = "force-dynamic";
|
|
32
|
-
|
|
33
|
-
/** The Stripe reads one visitor may spend: 10 per 10 minutes (#8757 D13). */
|
|
34
|
-
const PAID_EMAIL_READS = 10;
|
|
35
|
-
const PAID_EMAIL_WINDOW_MS = 10 * 60 * 1000;
|
|
36
|
-
|
|
37
|
-
interface Props {
|
|
38
|
-
params: Promise<{ locale: string }>;
|
|
39
|
-
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
43
|
-
if (TOPOLOGY !== "spoke") notFound();
|
|
44
|
-
const { locale } = await params;
|
|
45
|
-
const t = await getTranslations({ locale, namespace: "checkoutThankYou" });
|
|
46
|
-
return {
|
|
47
|
-
title: t("title"),
|
|
48
|
-
robots: { index: false, follow: false },
|
|
49
|
-
referrer: "no-referrer",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** The buyer's email, or `null` — over the visitor's budget, no Stripe call. */
|
|
54
|
-
async function paidEmail(
|
|
55
|
-
sessionId: string | string[] | undefined,
|
|
56
|
-
): Promise<string | null> {
|
|
57
|
-
// A repeated `session_id` is ignored, like a missing one.
|
|
58
|
-
if (typeof sessionId !== "string" || sessionId === "") return null;
|
|
59
|
-
const visitor = clientIpFromHeaders(await headers());
|
|
60
|
-
if (
|
|
61
|
-
!checkRateLimit(
|
|
62
|
-
`checkout-paid-email:${visitor}`,
|
|
63
|
-
PAID_EMAIL_READS,
|
|
64
|
-
PAID_EMAIL_WINDOW_MS,
|
|
65
|
-
)
|
|
66
|
-
) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return readPaidCheckoutEmail({ site: checkoutConfig.site }, sessionId);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default async function Page({
|
|
73
|
-
params,
|
|
74
|
-
searchParams,
|
|
75
|
-
}: Props): Promise<ReactElement> {
|
|
76
|
-
if (TOPOLOGY !== "spoke") notFound();
|
|
77
|
-
const { locale } = await params;
|
|
78
|
-
const t = await getTranslations({ locale, namespace: "checkoutThankYou" });
|
|
79
|
-
const sessionId = (await searchParams)?.session_id;
|
|
80
|
-
const email = await paidEmail(sessionId);
|
|
81
|
-
const href =
|
|
82
|
-
(email === null ? null : accountInviteHref(locale, email)) ??
|
|
83
|
-
localeHref(locale, "/account");
|
|
84
|
-
const sections: PageSection[] = [
|
|
85
|
-
{
|
|
86
|
-
id: "checkout-thank-you",
|
|
87
|
-
type: "content-block",
|
|
88
|
-
data: { headline: t("title"), body: t("body") },
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
return (
|
|
92
|
-
<main id="main">
|
|
93
|
-
<SectionRenderer
|
|
94
|
-
sections={sections}
|
|
95
|
-
locale={locale}
|
|
96
|
-
leadingSectionOwnsTitle
|
|
97
|
-
/>
|
|
98
|
-
{/* Session Replay records the DOM, so the link (it can carry the email) is blocked from it. */}
|
|
99
|
-
<Container className="pb-section">
|
|
100
|
-
<div data-sentry-block>
|
|
101
|
-
<Button asChild variant="outline" className="min-h-11">
|
|
102
|
-
<Link
|
|
103
|
-
href={href}
|
|
104
|
-
variant="bare"
|
|
105
|
-
data-testid="checkout-open-account"
|
|
106
|
-
>
|
|
107
|
-
{t("openAccount")}
|
|
108
|
-
</Link>
|
|
109
|
-
</Button>
|
|
110
|
-
</div>
|
|
111
|
-
</Container>
|
|
112
|
-
</main>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// The checkout unavailable page — Standard spoke checkout page (#8748).
|
|
2
|
-
// Kept current by `create-ailk update`: do not edit it. This site's checkout
|
|
3
|
-
// data is lib/checkout-config.ts, the one file to edit.
|
|
4
|
-
// Every refused buy lands here. It never says why: a reason is a probe's
|
|
5
|
-
// answer, and the buyer needs only that nothing was charged.
|
|
6
|
-
// It is served on a spoke only: any other build answers notFound().
|
|
7
|
-
import { SectionRenderer } from "@working-theory/ui/sections";
|
|
8
|
-
import type { PageSection } from "@working-theory/validation";
|
|
9
|
-
import type { Metadata } from "next";
|
|
10
|
-
import { notFound } from "next/navigation";
|
|
11
|
-
import { getTranslations } from "next-intl/server";
|
|
12
|
-
import type { ReactElement } from "react";
|
|
13
|
-
|
|
14
|
-
import { TOPOLOGY } from "../../../../lib/topology.generated";
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
params: Promise<{ locale: string }>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
21
|
-
if (TOPOLOGY !== "spoke") notFound();
|
|
22
|
-
const { locale } = await params;
|
|
23
|
-
const t = await getTranslations({ locale, namespace: "checkoutUnavailable" });
|
|
24
|
-
return { title: t("title"), robots: { index: false, follow: false } };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default async function Page({ params }: Props): Promise<ReactElement> {
|
|
28
|
-
if (TOPOLOGY !== "spoke") notFound();
|
|
29
|
-
const { locale } = await params;
|
|
30
|
-
const t = await getTranslations({ locale, namespace: "checkoutUnavailable" });
|
|
31
|
-
const sections: PageSection[] = [
|
|
32
|
-
{
|
|
33
|
-
id: "checkout-unavailable",
|
|
34
|
-
type: "content-block",
|
|
35
|
-
data: { headline: t("title"), body: t("body") },
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: "checkout-unavailable-cta",
|
|
39
|
-
type: "cta",
|
|
40
|
-
data: {
|
|
41
|
-
headline: t("ctaHeadline"),
|
|
42
|
-
primaryCta: { label: t("ctaLabel"), href: "/contact" },
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
return (
|
|
47
|
-
<main id="main">
|
|
48
|
-
<SectionRenderer sections={sections} locale={locale} leadingSectionOwnsTitle />
|
|
49
|
-
</main>
|
|
50
|
-
);
|
|
51
|
-
}
|