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,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* account/billing/offerings.ts — what the shown set contributes to User
|
|
3
|
-
* settings › Billing (#11165 rulings A and B2): the base plan a member
|
|
4
|
-
* without a subscription starts on, the plan Upgrade goes to, and the offer
|
|
5
|
-
* card.
|
|
6
|
-
*
|
|
7
|
-
* One pure function over the Offerings shown set (`GET /v1/content/shown-offerings`,
|
|
8
|
-
* #8924 — the read `/pricing` renders from, parsed by the same schema):
|
|
9
|
-
*
|
|
10
|
-
* - `base` — the shown set's lowest-priced LIVE plan: every `plan` Product
|
|
11
|
-
* of a `current` set, ordered by its card price (its first shown Price —
|
|
12
|
-
* monthly before yearly before one-time, the order the snapshot keeps).
|
|
13
|
-
* A set with no live plan has none, and the page renders no plan card.
|
|
14
|
-
* - `next` — the plan Upgrade goes to: the next live plan above the base
|
|
15
|
-
* by price. Stripe has no upgrade relation and neither does our model,
|
|
16
|
-
* so next-by-price is the rule (operator, 2026-11-08). None with one plan.
|
|
17
|
-
* - `offer` — the first live `offer` Product (#11166): its name, description,
|
|
18
|
-
* first image and the Claim offer target — the Offerings checkout for its
|
|
19
|
-
* first Price (`offeringsCheckoutHref`, T3) with the product's promotion
|
|
20
|
-
* code carried as `?promo=` when it has one. Applying that code at Checkout
|
|
21
|
-
* is the buy route's and the checkout API's — neither reads it yet, so the
|
|
22
|
-
* link reaches Checkout at the Price's own amount (a follow-up named on
|
|
23
|
-
* #11165).
|
|
24
|
-
*
|
|
25
|
-
* Stripe text crosses into markup here, so contract 8879 T2 binds it: every
|
|
26
|
-
* string is emitted as plain text, format characters removed.
|
|
27
|
-
*/
|
|
28
|
-
import {
|
|
29
|
-
workspaceShownSetWireSchema,
|
|
30
|
-
type MemberBillingPlan,
|
|
31
|
-
type OfferingsPrice,
|
|
32
|
-
type OfferingsProduct,
|
|
33
|
-
} from "@working-theory/validation";
|
|
34
|
-
|
|
35
|
-
import { offeringsCheckoutHref } from "../../../../../lib/offerings-pricing";
|
|
36
|
-
|
|
37
|
-
export interface BillingPlanView {
|
|
38
|
-
productId: string;
|
|
39
|
-
name: string;
|
|
40
|
-
description: string | null;
|
|
41
|
-
/** The card price, in the hub read's own shape so one label serves both. */
|
|
42
|
-
price: NonNullable<MemberBillingPlan["price"]>;
|
|
43
|
-
/** The Offerings checkout for the plan's card price, or `null` when its key is outside the grammar. */
|
|
44
|
-
checkoutHref: string | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface BillingOfferView {
|
|
48
|
-
productId: string;
|
|
49
|
-
name: string;
|
|
50
|
-
description: string | null;
|
|
51
|
-
image: string | null;
|
|
52
|
-
/** The Offerings checkout for the offer's first Price, or `null` when its key is outside the grammar. */
|
|
53
|
-
claimHref: string | null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface BillingOfferings {
|
|
57
|
-
base: BillingPlanView | null;
|
|
58
|
-
next: BillingPlanView | null;
|
|
59
|
-
offer: BillingOfferView | null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const NO_BILLING_OFFERINGS: BillingOfferings = { base: null, next: null, offer: null };
|
|
63
|
-
|
|
64
|
-
// Cc, Cf, Zl, Zp and Cs — the T1 classes, the last guard before markup.
|
|
65
|
-
const FORMAT_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/gu;
|
|
66
|
-
|
|
67
|
-
function plain(text: string | null): string | null {
|
|
68
|
-
if (text === null) return null;
|
|
69
|
-
const stripped = text.replace(FORMAT_CHARACTERS, (ch) => (ch === "\n" ? " " : "")).trim();
|
|
70
|
-
return stripped.length > 0 ? stripped : null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** The Price a plan's card shows: its first shown Price, in the snapshot's period order. */
|
|
74
|
-
function cardPrice(product: OfferingsProduct): OfferingsPrice | undefined {
|
|
75
|
-
return product.prices[0];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function planView(product: OfferingsProduct, price: OfferingsPrice): BillingPlanView {
|
|
79
|
-
return {
|
|
80
|
-
productId: product.productId,
|
|
81
|
-
name: plain(product.name) ?? product.productId,
|
|
82
|
-
description: plain(product.description),
|
|
83
|
-
price: { amountMinor: price.amount, currency: price.currency, interval: price.interval },
|
|
84
|
-
checkoutHref: offeringsCheckoutHref(price.lookupKey),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** The Claim offer target: the checkout for the offer's price, carrying its promotion code. */
|
|
89
|
-
function claimHrefOf(product: OfferingsProduct): string | null {
|
|
90
|
-
const price = cardPrice(product);
|
|
91
|
-
const href = price === undefined ? null : offeringsCheckoutHref(price.lookupKey);
|
|
92
|
-
if (href === null) return null;
|
|
93
|
-
return product.promotionCode === undefined ? href : `${href}?promo=${encodeURIComponent(product.promotionCode)}`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** The Billing page's share of a shown set; anything but a current, parsable set contributes nothing. */
|
|
97
|
-
export function billingOfferings(shownSet: unknown): BillingOfferings {
|
|
98
|
-
const parsed = workspaceShownSetWireSchema.safeParse(shownSet);
|
|
99
|
-
if (!parsed.success || parsed.data.state !== "current") return NO_BILLING_OFFERINGS;
|
|
100
|
-
|
|
101
|
-
const plans = parsed.data.offerings
|
|
102
|
-
.filter((product) => product.ailkGroup === "plan")
|
|
103
|
-
.map((product) => ({ product, price: cardPrice(product) }))
|
|
104
|
-
.filter((entry): entry is { product: OfferingsProduct; price: OfferingsPrice } => entry.price !== undefined)
|
|
105
|
-
// A stable sort, so two plans at one price keep the snapshot's order.
|
|
106
|
-
.sort((a, b) => a.price.amount - b.price.amount);
|
|
107
|
-
const base = plans[0] === undefined ? null : planView(plans[0].product, plans[0].price);
|
|
108
|
-
const next = plans[1] === undefined ? null : planView(plans[1].product, plans[1].price);
|
|
109
|
-
|
|
110
|
-
const first = parsed.data.offerings.find((product) => product.ailkGroup === "offer");
|
|
111
|
-
const offer: BillingOfferView | null =
|
|
112
|
-
first === undefined
|
|
113
|
-
? null
|
|
114
|
-
: {
|
|
115
|
-
productId: first.productId,
|
|
116
|
-
name: plain(first.name) ?? first.productId,
|
|
117
|
-
description: plain(first.description),
|
|
118
|
-
image: first.image ?? null,
|
|
119
|
-
claimHref: claimHrefOf(first),
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return { base, next, offer };
|
|
123
|
-
}
|
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/account/billing — User settings › Billing (#8339 D8; #11165,
|
|
3
|
-
* the operator's rulings of 2026-11-08 against the organization Billing's
|
|
4
|
-
* card shape).
|
|
5
|
-
*
|
|
6
|
-
* RSC, outside the account layout's SignedInShell (#8430), in the member's
|
|
7
|
-
* settings frame (D7) — since #11167 every group is a card the pane draws.
|
|
8
|
-
* The page, top to bottom, by `loadBilling()` and `loadBillingOfferings()`
|
|
9
|
-
* (`billing-source.ts`, the billing topology seam):
|
|
10
|
-
*
|
|
11
|
-
* (A) the OFFER CARD — the first live Offer product of the shown set
|
|
12
|
-
* (#11166), when the workspace shows one: its Stripe name, description
|
|
13
|
-
* and first image, Claim offer to the Offerings checkout, an x that
|
|
14
|
-
* dismisses it for this person (`OfferCard`, remembered under a key
|
|
15
|
-
* derived from the person's email, never the email itself);
|
|
16
|
-
* (B) the PLAN CARD, one of two (`CurrentPlanCard`): (B1) a current
|
|
17
|
-
* subscription — the plan name with its price beside it, one line
|
|
18
|
-
* ("Renews on December 1 · Visa 4242"; "Payment due"; "Access ends
|
|
19
|
-
* <date>") and Manage plan, which opens Stripe's Customer Portal and
|
|
20
|
-
* returns here; (B2) no subscription — the shown set's lowest-priced
|
|
21
|
-
* live plan, its Stripe description (or the fallback line until the
|
|
22
|
-
* operator sets one) and Upgrade to the Offerings checkout for the
|
|
23
|
-
* next live plan above it by price; a shown set with no live plan
|
|
24
|
-
* renders no plan card. A failed read is the error row with Retry,
|
|
25
|
-
* never a false "no subscription";
|
|
26
|
-
* (C) HISTORY — the member's paid invoices and purchases, newest first,
|
|
27
|
-
* Date (MM/DD/YYYY) · Offering · Amount · Receipt (`BillingHistoryCard`),
|
|
28
|
-
* absent when there are none.
|
|
29
|
-
*
|
|
30
|
-
* Then one plain line when some of the member's billing is on a Stripe
|
|
31
|
-
* account this spoke's key cannot read (#8217 D12), each section a module
|
|
32
|
-
* contributes (`accountBillingSections`, #8231 D4) and each the site adds
|
|
33
|
-
* (`siteBillingSections`, #9401 D7). The old "Current plan" heading, the
|
|
34
|
-
* plain purchases list and "You don't have a subscription." are gone.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
import { createHash } from "node:crypto";
|
|
38
|
-
|
|
39
|
-
import {
|
|
40
|
-
AccountSettingsFrame,
|
|
41
|
-
AccountSettingsPane,
|
|
42
|
-
BillingHistoryCard,
|
|
43
|
-
CurrentPlanCard,
|
|
44
|
-
OfferCard,
|
|
45
|
-
type BillingHistoryRowView,
|
|
46
|
-
} from "@working-theory/templates/account";
|
|
47
|
-
import { Button, Link, MoneyAmount, Text } from "@working-theory/ui/primitives";
|
|
48
|
-
import type { Metadata } from "next";
|
|
49
|
-
import { getTranslations } from "next-intl/server";
|
|
50
|
-
import type { ReactElement, ReactNode } from "react";
|
|
51
|
-
|
|
52
|
-
import { accountBillingSections } from "../../../../../lib/account-config";
|
|
53
|
-
import { formatMinorUnits } from "../../../../../lib/offerings-pricing";
|
|
54
|
-
import { siteBillingSections } from "../../../../../lib/site-contributions";
|
|
55
|
-
import { accountSession } from "../account-data";
|
|
56
|
-
import { openBillingPortal } from "../actions";
|
|
57
|
-
import {
|
|
58
|
-
type BillingHistoryState,
|
|
59
|
-
type BillingPlanState,
|
|
60
|
-
type BillingState,
|
|
61
|
-
loadBilling,
|
|
62
|
-
loadBillingOfferings,
|
|
63
|
-
} from "../billing-source";
|
|
64
|
-
import { ErrorRow } from "../error-row";
|
|
65
|
-
import {
|
|
66
|
-
memberSettingsFrame,
|
|
67
|
-
SettingsSection,
|
|
68
|
-
type Translate as MemberTranslate,
|
|
69
|
-
} from "../settings-frame";
|
|
70
|
-
|
|
71
|
-
import type { BillingOfferView, BillingPlanView } from "./offerings";
|
|
72
|
-
|
|
73
|
-
interface Props {
|
|
74
|
-
params: Promise<{ locale: string }>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
78
|
-
const { locale } = await params;
|
|
79
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
80
|
-
return {
|
|
81
|
-
title: t("settings.billing.title"),
|
|
82
|
-
description: t("settings.billing.lead"),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
type Translate = Awaited<ReturnType<typeof getTranslations<"account">>>;
|
|
87
|
-
|
|
88
|
-
// The pill: 44px on a phone (the primary-action floor) and full width there,
|
|
89
|
-
// 36px from md up — the settings cards' one submit style (#11167).
|
|
90
|
-
const PILL_CLASS =
|
|
91
|
-
"max-md:w-full max-md:min-h-11 !rounded-full whitespace-nowrap";
|
|
92
|
-
|
|
93
|
-
/** A day as the mockup writes it — "December 1" — read in UTC, the server's zone. */
|
|
94
|
-
function monthDay(iso: string, locale: string): ReactNode {
|
|
95
|
-
return (
|
|
96
|
-
<time dateTime={iso}>
|
|
97
|
-
{new Intl.DateTimeFormat(locale, {
|
|
98
|
-
month: "long",
|
|
99
|
-
day: "numeric",
|
|
100
|
-
timeZone: "UTC",
|
|
101
|
-
}).format(new Date(iso))}
|
|
102
|
-
</time>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** A History date as MM/DD/YYYY in the page's locale, read in UTC. */
|
|
107
|
-
function numericDate(iso: string, locale: string): string {
|
|
108
|
-
return new Intl.DateTimeFormat(locale, {
|
|
109
|
-
month: "2-digit",
|
|
110
|
-
day: "2-digit",
|
|
111
|
-
year: "numeric",
|
|
112
|
-
timeZone: "UTC",
|
|
113
|
-
}).format(new Date(iso));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** "Visa 4242" — Stripe's lower-case brand, capitalized. */
|
|
117
|
-
function cardLabel(
|
|
118
|
-
card: BillingPlanState["card"],
|
|
119
|
-
t: Translate,
|
|
120
|
-
): string | null {
|
|
121
|
-
if (card === null) return null;
|
|
122
|
-
const brand = card.brand.charAt(0).toUpperCase() + card.brand.slice(1);
|
|
123
|
-
return t("settings.billing.card", { brand, last4: card.last4 });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** "$12,500/mo" — the amount in the price's currency, with its interval word. */
|
|
127
|
-
function priceLabel(
|
|
128
|
-
price: NonNullable<BillingPlanState["price"]>,
|
|
129
|
-
locale: string,
|
|
130
|
-
t: Translate,
|
|
131
|
-
): string {
|
|
132
|
-
const amount = formatMinorUnits(price.amountMinor, price.currency, locale);
|
|
133
|
-
if (price.interval === "month")
|
|
134
|
-
return t("settings.billing.perMonth", { amount });
|
|
135
|
-
if (price.interval === "year")
|
|
136
|
-
return t("settings.billing.perYear", { amount });
|
|
137
|
-
return amount;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function Subscription({
|
|
141
|
-
state,
|
|
142
|
-
locale,
|
|
143
|
-
t,
|
|
144
|
-
}: {
|
|
145
|
-
state: Extract<BillingState, { kind: "subscription" }>;
|
|
146
|
-
locale: string;
|
|
147
|
-
t: Translate;
|
|
148
|
-
}): ReactElement {
|
|
149
|
-
const { plan } = state;
|
|
150
|
-
const { renewsAt, accessEndsAt } = plan;
|
|
151
|
-
// The one line under the name: the renewal while it renews, the access
|
|
152
|
-
// end once it is set to end, else the status word — then the card on file.
|
|
153
|
-
const status: ReactNode =
|
|
154
|
-
renewsAt !== null &&
|
|
155
|
-
(plan.status === "active" || plan.status === "trialing")
|
|
156
|
-
? t.rich("settings.billing.renews", {
|
|
157
|
-
date: () => monthDay(renewsAt, locale),
|
|
158
|
-
})
|
|
159
|
-
: plan.status === "canceled" && accessEndsAt !== null
|
|
160
|
-
? t.rich("settings.billing.accessEnds", {
|
|
161
|
-
date: () => monthDay(accessEndsAt, locale),
|
|
162
|
-
})
|
|
163
|
-
: t(`settings.billing.statuses.${plan.status}`);
|
|
164
|
-
const card = cardLabel(plan.card, t);
|
|
165
|
-
return (
|
|
166
|
-
<CurrentPlanCard
|
|
167
|
-
name={plan.name ?? t("settings.billing.unnamedPlan")}
|
|
168
|
-
price={
|
|
169
|
-
plan.price === null ? undefined : priceLabel(plan.price, locale, t)
|
|
170
|
-
}
|
|
171
|
-
line={
|
|
172
|
-
<span data-testid="account-billing-status">
|
|
173
|
-
{status}
|
|
174
|
-
{card !== null ? (
|
|
175
|
-
<>
|
|
176
|
-
{" · "}
|
|
177
|
-
<span data-testid="account-billing-payment">{card}</span>
|
|
178
|
-
</>
|
|
179
|
-
) : null}
|
|
180
|
-
</span>
|
|
181
|
-
}
|
|
182
|
-
action={
|
|
183
|
-
state.portalAvailable ? (
|
|
184
|
-
<form action={openBillingPortal}>
|
|
185
|
-
<Button
|
|
186
|
-
type="submit"
|
|
187
|
-
className={PILL_CLASS}
|
|
188
|
-
data-testid="account-billing-manage"
|
|
189
|
-
>
|
|
190
|
-
{t("settings.billing.manage")}
|
|
191
|
-
</Button>
|
|
192
|
-
</form>
|
|
193
|
-
) : undefined
|
|
194
|
-
}
|
|
195
|
-
testId="account-billing"
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** The base plan a member without a subscription starts on, with Upgrade to the next (#11165 B2). */
|
|
201
|
-
function BasePlan({
|
|
202
|
-
base,
|
|
203
|
-
next,
|
|
204
|
-
locale,
|
|
205
|
-
t,
|
|
206
|
-
}: {
|
|
207
|
-
base: BillingPlanView;
|
|
208
|
-
next: BillingPlanView | null;
|
|
209
|
-
locale: string;
|
|
210
|
-
t: Translate;
|
|
211
|
-
}): ReactElement {
|
|
212
|
-
const upgradeHref = next?.checkoutHref ?? null;
|
|
213
|
-
return (
|
|
214
|
-
<CurrentPlanCard
|
|
215
|
-
name={base.name}
|
|
216
|
-
price={priceLabel(base.price, locale, t)}
|
|
217
|
-
description={base.description ?? t("settings.billing.planFallback")}
|
|
218
|
-
action={
|
|
219
|
-
upgradeHref !== null ? (
|
|
220
|
-
<Button asChild className={PILL_CLASS}>
|
|
221
|
-
<Link
|
|
222
|
-
href={upgradeHref}
|
|
223
|
-
variant="bare"
|
|
224
|
-
data-testid="account-billing-upgrade"
|
|
225
|
-
>
|
|
226
|
-
{t("settings.billing.upgrade")}
|
|
227
|
-
</Link>
|
|
228
|
-
</Button>
|
|
229
|
-
) : undefined
|
|
230
|
-
}
|
|
231
|
-
testId="account-billing"
|
|
232
|
-
/>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/** The History card (#11165 C): the error row for a failed read, else the rows — the page renders it only when there are any. */
|
|
237
|
-
function History({
|
|
238
|
-
history,
|
|
239
|
-
locale,
|
|
240
|
-
t,
|
|
241
|
-
}: {
|
|
242
|
-
history: BillingHistoryState;
|
|
243
|
-
locale: string;
|
|
244
|
-
t: Translate;
|
|
245
|
-
}): ReactElement {
|
|
246
|
-
if (history.kind === "failed") {
|
|
247
|
-
return (
|
|
248
|
-
<div data-testid="account-billing-history-error">
|
|
249
|
-
<ErrorRow
|
|
250
|
-
message={t("settings.billing.historyUnavailable")}
|
|
251
|
-
retryLabel={t("inbox.retry")}
|
|
252
|
-
/>
|
|
253
|
-
</div>
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
const rows: BillingHistoryRowView[] = history.items.map((item) => ({
|
|
257
|
-
id: item.id,
|
|
258
|
-
date: numericDate(item.paidAt, locale),
|
|
259
|
-
dateTime: item.paidAt,
|
|
260
|
-
offering: item.offering,
|
|
261
|
-
amount:
|
|
262
|
-
item.amountMinor !== null && item.currency !== null ? (
|
|
263
|
-
<MoneyAmount
|
|
264
|
-
amountMinor={item.amountMinor}
|
|
265
|
-
currency={item.currency}
|
|
266
|
-
locale={locale}
|
|
267
|
-
/>
|
|
268
|
-
) : (
|
|
269
|
-
"—"
|
|
270
|
-
),
|
|
271
|
-
receiptHref: item.receiptUrl,
|
|
272
|
-
}));
|
|
273
|
-
return (
|
|
274
|
-
<BillingHistoryCard
|
|
275
|
-
rows={rows}
|
|
276
|
-
labels={{
|
|
277
|
-
title: t("settings.billing.history"),
|
|
278
|
-
date: t("settings.billing.historyDate"),
|
|
279
|
-
offering: t("settings.billing.historyOffering"),
|
|
280
|
-
amount: t("settings.billing.historyAmount"),
|
|
281
|
-
receipt: t("settings.billing.historyReceipt"),
|
|
282
|
-
view: t("settings.billing.historyView"),
|
|
283
|
-
}}
|
|
284
|
-
testIdPrefix="account-billing-history"
|
|
285
|
-
/>
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* The offer dismissal's per-person key: a SHA-256 digest of the person's
|
|
291
|
-
* email under a fixed label, computed on the server, so the browser's store
|
|
292
|
-
* names no address and a shared browser keeps each person's dismissals
|
|
293
|
-
* apart. A pseudonym, not a secret: the stored value is product ids only.
|
|
294
|
-
*/
|
|
295
|
-
function offerPersistKey(email: string): string {
|
|
296
|
-
const digest = createHash("sha256")
|
|
297
|
-
.update(`ailk:billing-offer:${email.trim().toLowerCase()}`)
|
|
298
|
-
.digest("hex");
|
|
299
|
-
return `account:billing-offer:${digest.slice(0, 16)}`;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* The offer card (#11165 A), built as the pane's DIRECT child — the pane
|
|
304
|
-
* reads `ownCard` off the element it is given — so it draws its own card and
|
|
305
|
-
* a dismissal leaves no shell; the page builds it only for a live offer.
|
|
306
|
-
*/
|
|
307
|
-
function offerCard(
|
|
308
|
-
offer: BillingOfferView & { claimHref: string },
|
|
309
|
-
email: string,
|
|
310
|
-
t: Translate,
|
|
311
|
-
): ReactElement {
|
|
312
|
-
return (
|
|
313
|
-
<OfferCard
|
|
314
|
-
id={offer.productId}
|
|
315
|
-
persistKey={offerPersistKey(email)}
|
|
316
|
-
title={offer.name}
|
|
317
|
-
description={offer.description}
|
|
318
|
-
image={
|
|
319
|
-
offer.image === null ? null : { src: offer.image, alt: offer.name }
|
|
320
|
-
}
|
|
321
|
-
claimHref={offer.claimHref}
|
|
322
|
-
claimLabel={t("settings.billing.claimOffer")}
|
|
323
|
-
dismissLabel={t("settings.billing.dismissOffer")}
|
|
324
|
-
testId="account-billing-offer"
|
|
325
|
-
cardTestId="account-settings-billing-card"
|
|
326
|
-
ownCard
|
|
327
|
-
/>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export default async function AccountBillingPage({
|
|
332
|
-
params,
|
|
333
|
-
}: Props): Promise<ReactElement> {
|
|
334
|
-
const { locale } = await params;
|
|
335
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
336
|
-
const session = await accountSession(locale);
|
|
337
|
-
const frame = memberSettingsFrame(
|
|
338
|
-
locale,
|
|
339
|
-
t as unknown as MemberTranslate,
|
|
340
|
-
"billing",
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
// Unreachable behind the (authed) gate; a session that expired between
|
|
344
|
-
// the layout and the page renders the pane's title alone.
|
|
345
|
-
if (!session) {
|
|
346
|
-
return (
|
|
347
|
-
<AccountSettingsFrame {...frame} name="">
|
|
348
|
-
<AccountSettingsPane
|
|
349
|
-
id="account-settings-billing"
|
|
350
|
-
title={t("settings.billing.title")}
|
|
351
|
-
lead=""
|
|
352
|
-
>
|
|
353
|
-
{null}
|
|
354
|
-
</AccountSettingsPane>
|
|
355
|
-
</AccountSettingsFrame>
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const { ctx } = session;
|
|
360
|
-
const [{ state, history }, offerings] = await Promise.all([
|
|
361
|
-
loadBilling(ctx.init),
|
|
362
|
-
loadBillingOfferings(),
|
|
363
|
-
]);
|
|
364
|
-
const name = ctx.user.name || ctx.user.email;
|
|
365
|
-
// Every pane child below is one card, so each slot is decided here and a
|
|
366
|
-
// slot with nothing to show passes nothing — never an empty card (#11165).
|
|
367
|
-
const offer =
|
|
368
|
-
offerings.offer !== null && offerings.offer.claimHref !== null
|
|
369
|
-
? { ...offerings.offer, claimHref: offerings.offer.claimHref }
|
|
370
|
-
: null;
|
|
371
|
-
const hasHistory = history.kind === "failed" || history.items.length > 0;
|
|
372
|
-
|
|
373
|
-
return (
|
|
374
|
-
<AccountSettingsFrame {...frame} name={name}>
|
|
375
|
-
<AccountSettingsPane
|
|
376
|
-
id="account-settings-billing"
|
|
377
|
-
title={t("settings.billing.title")}
|
|
378
|
-
lead={t("settings.billing.lead")}
|
|
379
|
-
>
|
|
380
|
-
{offer !== null ? offerCard(offer, ctx.user.email, t) : null}
|
|
381
|
-
|
|
382
|
-
{state.kind === "subscription" ? (
|
|
383
|
-
<Subscription state={state} locale={locale} t={t} />
|
|
384
|
-
) : state.kind === "none" ? (
|
|
385
|
-
offerings.base !== null ? (
|
|
386
|
-
<BasePlan
|
|
387
|
-
base={offerings.base}
|
|
388
|
-
next={offerings.next}
|
|
389
|
-
locale={locale}
|
|
390
|
-
t={t}
|
|
391
|
-
/>
|
|
392
|
-
) : null
|
|
393
|
-
) : (
|
|
394
|
-
<ErrorRow
|
|
395
|
-
message={t("settings.billing.unavailable")}
|
|
396
|
-
retryLabel={t("inbox.retry")}
|
|
397
|
-
/>
|
|
398
|
-
)}
|
|
399
|
-
|
|
400
|
-
{state.kind !== "failed" && state.unreadable ? (
|
|
401
|
-
<div data-testid="account-billing-unreadable">
|
|
402
|
-
<Text as="p" variant="body-sm" tone="muted">
|
|
403
|
-
{t("settings.billing.unreadable")}
|
|
404
|
-
</Text>
|
|
405
|
-
</div>
|
|
406
|
-
) : null}
|
|
407
|
-
|
|
408
|
-
{hasHistory ? (
|
|
409
|
-
<History history={history} locale={locale} t={t} />
|
|
410
|
-
) : null}
|
|
411
|
-
|
|
412
|
-
{[...accountBillingSections, ...siteBillingSections].map((section) => (
|
|
413
|
-
<SettingsSection
|
|
414
|
-
key={section.id}
|
|
415
|
-
id={section.id}
|
|
416
|
-
title={ctx.t(section.title)}
|
|
417
|
-
>
|
|
418
|
-
{section.render(ctx)}
|
|
419
|
-
</SettingsSection>
|
|
420
|
-
))}
|
|
421
|
-
</AccountSettingsPane>
|
|
422
|
-
</AccountSettingsFrame>
|
|
423
|
-
);
|
|
424
|
-
}
|