create-ailk 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +18 -11
- 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 +9 -15
- 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 +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +86 -5
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- 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 +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- 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/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -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/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- 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/__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/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/__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/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-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/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/message/[id]/file/__tests__/route.test.ts +0 -215
- 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/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/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/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/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/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/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-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/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/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- 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,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* settings-frame.tsx — User settings' four tabs, General · Security ·
|
|
3
|
-
* Notifications · Billing (#8339 D7; builds on #8232 D1).
|
|
4
|
-
*
|
|
5
|
-
* `memberSettingsFrame` supplies the member's half of the shared
|
|
6
|
-
* `AccountSettingsFrame` (@working-theory/templates/account, spec 8339 D2):
|
|
7
|
-
* `standalone: true` — the Admin's shape, full height and flush, because the
|
|
8
|
-
* account layout renders these routes outside its AppShell (#8430) — Back to
|
|
9
|
-
* the Inbox, and the tabs of `SETTINGS_ROUTES`. Every member settings page
|
|
10
|
-
* calls it and renders the result through `AccountSettingsFrame` (General,
|
|
11
|
-
* via the shared `AccountSettings`) or directly (Security, Notifications,
|
|
12
|
-
* Billing).
|
|
13
|
-
*
|
|
14
|
-
* `SettingsSection` is the shape a contributed section
|
|
15
|
-
* (`accountSettingsSections`, `accountBillingSections`) and Billing's own
|
|
16
|
-
* trailing content take; since #11167 the pane draws every group as a card,
|
|
17
|
-
* so the section carries no top rule of its own.
|
|
18
|
-
*
|
|
19
|
-
* #8441 — `SETTINGS_ROUTES` is the ONE place the settings routes are named:
|
|
20
|
-
* the tabs here and `isSettingsPath` (which `account-frame.tsx` takes these
|
|
21
|
-
* routes out of its shell with) both read it, so a tab added here is a tab
|
|
22
|
-
* that renders outside the shell — never a second `<main>` nested in the
|
|
23
|
-
* shell's. Adding a tab is one line here (plus its page and message).
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import type { AccountSettingsFrameProps, AccountSettingsTab } from "@working-theory/templates/account";
|
|
27
|
-
import { localeHref } from "@working-theory/ui";
|
|
28
|
-
import { Heading, Icon, Text } from "@working-theory/ui/primitives";
|
|
29
|
-
import { Bell, CreditCard, Lock, ShieldCheck, UserRound } from "lucide-react";
|
|
30
|
-
import type { ReactElement, ReactNode } from "react";
|
|
31
|
-
|
|
32
|
-
/** The `next-intl` translator General/Security/Notifications/Billing each
|
|
33
|
-
* hold. Widened from `getTranslations`'s own literal-key-checked type (the
|
|
34
|
-
* `AccountTranslate` idiom, `account-data.ts`) — a settings page's own
|
|
35
|
-
* string keys are static, but the function is shared across four route
|
|
36
|
-
* files with four different generic instantiations. Call sites cast their
|
|
37
|
-
* own `t` with `as unknown as Translate`. */
|
|
38
|
-
export type Translate = (key: string, values?: Record<string, unknown>) => string;
|
|
39
|
-
|
|
40
|
-
/** User settings' tabs, in the reference's order (#8339 D7; #8438 D14 adds
|
|
41
|
-
* Privacy before Billing) — each one a route that renders outside the
|
|
42
|
-
* account shell (#8430, #8441). */
|
|
43
|
-
export const SETTINGS_ROUTES = [
|
|
44
|
-
{ key: "general", path: "/account/general", titleKey: "settings.general.title", icon: UserRound },
|
|
45
|
-
{ key: "security", path: "/account/security", titleKey: "settings.security.title", icon: ShieldCheck },
|
|
46
|
-
{ key: "notifications", path: "/account/notifications", titleKey: "settings.notifications.title", icon: Bell },
|
|
47
|
-
{ key: "privacy", path: "/account/privacy", titleKey: "settings.privacy.title", icon: Lock },
|
|
48
|
-
{ key: "billing", path: "/account/billing", titleKey: "settings.billing.title", icon: CreditCard },
|
|
49
|
-
] as const;
|
|
50
|
-
|
|
51
|
-
export type SettingsTabKey = (typeof SETTINGS_ROUTES)[number]["key"];
|
|
52
|
-
|
|
53
|
-
/** Whether `pathname` is one of `SETTINGS_ROUTES`: the request locale's
|
|
54
|
-
* `/<locale>` prefix removed, then the rest compared whole — so a sub-route
|
|
55
|
-
* (`/account/billing/history`) is not a settings route unless it is listed. */
|
|
56
|
-
export function isSettingsPath(pathname: string, locale: string): boolean {
|
|
57
|
-
const prefix = `/${locale}`;
|
|
58
|
-
const bare =
|
|
59
|
-
pathname === prefix || pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;
|
|
60
|
-
return SETTINGS_ROUTES.some(({ path }) => path === bare);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** The member's half of `AccountSettingsFrameProps` — every settings page's
|
|
64
|
-
* `frame` prop, less `name` (the caller's own session) and `children`. */
|
|
65
|
-
export function memberSettingsFrame(
|
|
66
|
-
locale: string,
|
|
67
|
-
t: Translate,
|
|
68
|
-
active: SettingsTabKey,
|
|
69
|
-
): Omit<AccountSettingsFrameProps, "name" | "children"> {
|
|
70
|
-
const tabs: readonly AccountSettingsTab[] = SETTINGS_ROUTES.map(({ key, path, titleKey, icon }) => ({
|
|
71
|
-
key,
|
|
72
|
-
label: t(titleKey),
|
|
73
|
-
href: localeHref(locale, path),
|
|
74
|
-
icon: <Icon icon={icon} size="sm" decorative className="shrink-0" />,
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
standalone: true,
|
|
79
|
-
back: { label: t("settings.back"), href: localeHref(locale, "/account") },
|
|
80
|
-
railLabel: t("settings.title"),
|
|
81
|
-
accountLabel: t("settings.account"),
|
|
82
|
-
menuLabel: t("settings.menu"),
|
|
83
|
-
closeMenuLabel: t("settings.closeMenu"),
|
|
84
|
-
tabs,
|
|
85
|
-
active,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** The section role DESIGN.md §5.12 names: a title, a muted subtitle, then the fields — one card of the pane (#11167). */
|
|
90
|
-
export function SettingsSection({
|
|
91
|
-
id,
|
|
92
|
-
title,
|
|
93
|
-
lead,
|
|
94
|
-
children,
|
|
95
|
-
}: {
|
|
96
|
-
id: string;
|
|
97
|
-
title: string;
|
|
98
|
-
lead?: string;
|
|
99
|
-
children: ReactNode;
|
|
100
|
-
}): ReactElement {
|
|
101
|
-
return (
|
|
102
|
-
<section
|
|
103
|
-
id={id}
|
|
104
|
-
aria-labelledby={`${id}-title`}
|
|
105
|
-
className="flex scroll-mt-8 flex-col gap-4"
|
|
106
|
-
data-testid={`account-settings-${id}`}
|
|
107
|
-
>
|
|
108
|
-
<div>
|
|
109
|
-
<Heading level={2} visual={4} id={`${id}-title`}>
|
|
110
|
-
{title}
|
|
111
|
-
</Heading>
|
|
112
|
-
{lead ? (
|
|
113
|
-
<Text as="p" variant="body-sm" tone="muted" className="mt-1">
|
|
114
|
-
{lead}
|
|
115
|
-
</Text>
|
|
116
|
-
) : null}
|
|
117
|
-
</div>
|
|
118
|
-
{children}
|
|
119
|
-
</section>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* account/sign-in-method.ts (server code) — how a member signs in, for User settings ›
|
|
3
|
-
* Security's sign-in block (#8232, spec
|
|
4
|
-
* docs/specs/8232-member-settings-account-general-and-spec.md D7).
|
|
5
|
-
*
|
|
6
|
-
* One of the account tree's TWO topology seams (roadmap D1; the other is
|
|
7
|
-
* `billing-source.ts`): no other file under the account tree tests
|
|
8
|
-
* `SIGN_IN_PROVIDER`, `TOPOLOGY` or `SIGN_IN_ENABLED`.
|
|
9
|
-
*
|
|
10
|
-
* - A spoke that signs in through its hub (`SIGN_IN_PROVIDER === "hub"`,
|
|
11
|
-
* #7894) answers `hub`, with the hub's host when it is configured.
|
|
12
|
-
* - Any other site answers `site`, with the sign-in methods this deployment
|
|
13
|
-
* has configured. Better Auth's session does not say which one this
|
|
14
|
-
* member used, so the list is the deployment's (C7).
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { getActiveProviderIds } from "../../../../lib/auth-env";
|
|
18
|
-
import { hubSessionConfig } from "../../../../lib/hub-session/config";
|
|
19
|
-
import { SIGN_IN_PROVIDER } from "../../../../lib/topology.generated";
|
|
20
|
-
|
|
21
|
-
/** The sign-in methods General names, in the order it lists them. */
|
|
22
|
-
export const SIGN_IN_METHODS = ["google", "github", "magic-link", "email"] as const;
|
|
23
|
-
|
|
24
|
-
export type SignInMethodId = (typeof SIGN_IN_METHODS)[number];
|
|
25
|
-
|
|
26
|
-
export type SignInMethod =
|
|
27
|
-
| { kind: "hub"; hubHost: string | null }
|
|
28
|
-
| { kind: "site"; methods: SignInMethodId[] };
|
|
29
|
-
|
|
30
|
-
export function signInMethod(): SignInMethod {
|
|
31
|
-
if (SIGN_IN_PROVIDER === "hub") {
|
|
32
|
-
const config = hubSessionConfig();
|
|
33
|
-
return { kind: "hub", hubHost: config === null ? null : new URL(config.hubOrigin).host };
|
|
34
|
-
}
|
|
35
|
-
const active = new Set(getActiveProviderIds());
|
|
36
|
-
return { kind: "site", methods: SIGN_IN_METHODS.filter((id) => active.has(id)) };
|
|
37
|
-
}
|
|
@@ -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
|
-
});
|