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,306 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* D6a, D9, D12; #8231 D3; DESIGN.md §5.4).
|
|
4
|
-
*
|
|
5
|
-
* RSC, rendered inside the account layout's SignedInShell. One filtered
|
|
6
|
-
* list: the tabs All · Messages · Orders · Scheduled (#11149, operator
|
|
7
|
-
* rulings 2026-11-08), each with a count, All selected, through the shared
|
|
8
|
-
* `InboxList` (`@working-theory/templates/account`). `?tab=<id>` opens
|
|
9
|
-
* another tab; any other value, the frame's own `?tab=for-you` included,
|
|
10
|
-
* opens All:
|
|
11
|
-
*
|
|
12
|
-
* - All — every loaded row, newest first: the union of the other tabs,
|
|
13
|
-
* each row once, plus the kinds in `updates` or `needs-you` (`result`,
|
|
14
|
-
* `piece`), which show here only.
|
|
15
|
-
* - Messages (#11157) — the conversation kinds (`accountChatKinds`): the
|
|
16
|
-
* provider's messages and the member's own sent requests and messages,
|
|
17
|
-
* newest first, each the entry the member thread page opens. A request
|
|
18
|
-
* the member just posted is here and under All on the next render (the
|
|
19
|
-
* New menu refreshes the route after a post).
|
|
20
|
-
* - Orders — the kinds whose section is `purchases` (the `purchase` kind,
|
|
21
|
-
* and any a module adds), newest first. The tab keeps the contract's
|
|
22
|
-
* id, `purchases` (the section id, the `purchase` kind and
|
|
23
|
-
* `GET /v1/member/purchases` are unchanged); only its label — the key
|
|
24
|
-
* `inbox.tabs.purchases` — reads Orders, the Admin's word for the same
|
|
25
|
-
* records (#9170).
|
|
26
|
-
* - Scheduled — the kinds whose section is `upcoming` (`appointment`):
|
|
27
|
-
* first the items still upcoming, soonest first (no time last), then the
|
|
28
|
-
* rest, newest first. Each kind's own read decides which is upcoming.
|
|
29
|
-
*
|
|
30
|
-
* No lead line under the title (#11149): the Admin's Inbox has none, and
|
|
31
|
-
* the tabs say what the list holds. The tabs follow the title row at the
|
|
32
|
-
* list's own `mt-block-loose`, the token the Admin's list sits at.
|
|
33
|
-
*
|
|
34
|
-
* What needs the person is never an Inbox row: `email-unverified`,
|
|
35
|
-
* `payment-due` and "Add your name" are For-you items (D9 as amended). From
|
|
36
|
-
* `md` up they are the layout's aside.
|
|
37
|
-
*
|
|
38
|
-
* #7469 (DESIGN.md §2b as amended 2026-10-01, matching the Admin's §5.15) —
|
|
39
|
-
* below `md` the route is the phone's two main tabs, one `PhoneTabPanel`
|
|
40
|
-
* each (the frame hands the tab over from `?tab=`):
|
|
41
|
-
* - Inbox — the filter tabs and the list only, in RowGroup's inset card.
|
|
42
|
-
* No For-you stack and no bottom sheet, and no lead on the phone.
|
|
43
|
-
* - For you — every For-you item as rows of one inset card, each with its
|
|
44
|
-
* type tag, title, Open or View, and ✕; the empty line when none waits,
|
|
45
|
-
* and D12's error row above the list when a For-you source failed.
|
|
46
|
-
* The h1 sits above both panels, visually hidden below `md` (the phone has
|
|
47
|
-
* no large title). At `md`+ only the Inbox panel shows.
|
|
48
|
-
*
|
|
49
|
-
* D12 — any read that fails (a kind or a For-you source) renders an error
|
|
50
|
-
* row with Retry above the list; the list then holds what DID load, never a
|
|
51
|
-
* silently empty Inbox.
|
|
52
|
-
*
|
|
53
|
-
* #8233 D4 — New sits in the h1's header row (and, below `md`, in the
|
|
54
|
-
* frame's phone top bar): its rows are `new-popups.tsx`'s `newActions` — the
|
|
55
|
-
* `accountNewActions` of `lib/account-config.ts` with their popups bound —
|
|
56
|
-
* whose `available` read resolved `true`, each opening its popup over the
|
|
57
|
-
* Inbox. None offered (a Free build) → no New at all. A read that rejected
|
|
58
|
-
* drops its row and shows the error row too — a failed read is never silent.
|
|
59
|
-
*
|
|
60
|
-
* #8765 D8 — the Inbox renders nothing about agreements: an outstanding
|
|
61
|
-
* sign-up agreement is asked by the layout's full-page interstitial, before
|
|
62
|
-
* this page loads at all.
|
|
63
|
-
*/
|
|
1
|
+
// Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
|
|
2
|
+
import Page from "@working-theory/account/page";
|
|
64
3
|
|
|
65
|
-
import
|
|
66
|
-
ForYouPanel,
|
|
67
|
-
InboxList,
|
|
68
|
-
PhoneTabPanel,
|
|
69
|
-
type AccountContext,
|
|
70
|
-
type InboxListRow,
|
|
71
|
-
} from "@working-theory/templates/account";
|
|
72
|
-
import { localeHref } from "@working-theory/ui";
|
|
73
|
-
import { Heading, LocalTime } from "@working-theory/ui/primitives";
|
|
74
|
-
import {
|
|
75
|
-
CalendarClock,
|
|
76
|
-
ClipboardList,
|
|
77
|
-
Receipt,
|
|
78
|
-
type LucideProps,
|
|
79
|
-
} from "lucide-react";
|
|
80
|
-
import type { Metadata } from "next";
|
|
81
|
-
import { headers } from "next/headers";
|
|
82
|
-
import { getTranslations } from "next-intl/server";
|
|
83
|
-
import type { ComponentType, ReactElement } from "react";
|
|
4
|
+
import config from "../../../../account.config";
|
|
84
5
|
|
|
85
|
-
|
|
86
|
-
import { SITE_NAME } from "../../../../lib/site-brand";
|
|
87
|
-
import { readSession } from "../../../../lib/topology.generated";
|
|
6
|
+
export { generateMetadata } from "@working-theory/account/page";
|
|
88
7
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
loadInboxItems,
|
|
94
|
-
logReadFailure,
|
|
95
|
-
type LoadedInboxItem,
|
|
96
|
-
} from "./account-data";
|
|
97
|
-
import { outstandingAgreements } from "./agreements-gate";
|
|
98
|
-
import { ErrorRow } from "./error-row";
|
|
99
|
-
import { ACCOUNT_PERSIST_KEY, forYouLabels } from "./for-you-labels";
|
|
100
|
-
import { NewMenu, type NewMenuAction } from "./new-menu";
|
|
101
|
-
import { newActions } from "./new-popups";
|
|
102
|
-
|
|
103
|
-
interface Props {
|
|
104
|
-
params: Promise<{ locale: string }>;
|
|
105
|
-
/** `?tab=` — an Inbox tab id opens that tab (#11149); the frame reads the same key for the phone's For you tab. */
|
|
106
|
-
searchParams?: Promise<{ tab?: string | string[] }>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
110
|
-
const { locale } = await params;
|
|
111
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
112
|
-
// Signed out, the `(authed)` layout renders the sign-in gate in this page's
|
|
113
|
-
// place, so the title names THAT state — "Sign in · <site>" — not the Inbox
|
|
114
|
-
// the visitor cannot see yet (#8790 AC-1). The session read is the layout's
|
|
115
|
-
// own (`topology.generated`'s `readSession`); any failure keeps the Inbox
|
|
116
|
-
// title, exactly as before.
|
|
117
|
-
const session = await readSession(await headers()).catch(() => null);
|
|
118
|
-
if (!session) {
|
|
119
|
-
return {
|
|
120
|
-
title: `${t("gate.title")} · ${SITE_NAME}`,
|
|
121
|
-
description: t("description"),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
return { title: t("inbox.title"), description: t("description") };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** The base kinds' row glyphs — a bare icon, never an icon square (§5.4). */
|
|
128
|
-
const KIND_ICON: Record<string, ComponentType<LucideProps>> = {
|
|
129
|
-
result: ClipboardList,
|
|
130
|
-
purchase: Receipt,
|
|
131
|
-
appointment: CalendarClock,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/** Soonest first; an item with no time sorts last. */
|
|
135
|
-
function soonestFirst(a: LoadedInboxItem, b: LoadedInboxItem): number {
|
|
136
|
-
if (a.item.at === undefined) return b.item.at === undefined ? 0 : 1;
|
|
137
|
-
if (b.item.at === undefined) return -1;
|
|
138
|
-
return Date.parse(a.item.at) - Date.parse(b.item.at);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** The New actions this caller is offered; a rejected read drops its row and sets `failed`. */
|
|
142
|
-
async function loadNewActions(
|
|
143
|
-
ctx: AccountContext,
|
|
144
|
-
): Promise<{ actions: NewMenuAction[]; failed: boolean }> {
|
|
145
|
-
const settled = await Promise.allSettled(
|
|
146
|
-
newActions.map((action) => action.available(ctx)),
|
|
147
|
-
);
|
|
148
|
-
const actions: NewMenuAction[] = [];
|
|
149
|
-
settled.forEach((result, i) => {
|
|
150
|
-
const action = newActions[i]!;
|
|
151
|
-
if (result.status === "rejected")
|
|
152
|
-
logReadFailure(`new:${action.id}`, result.reason);
|
|
153
|
-
else if (result.value)
|
|
154
|
-
actions.push({
|
|
155
|
-
id: action.id,
|
|
156
|
-
label: ctx.t(action.label),
|
|
157
|
-
// #11154 — a link row navigates to its page; the rest open a popup.
|
|
158
|
-
...(action.href !== undefined
|
|
159
|
-
? { href: localeHref(ctx.locale, action.href) }
|
|
160
|
-
: { popup: action.renderPopup?.(ctx) }),
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
return {
|
|
164
|
-
actions,
|
|
165
|
-
failed: settled.some((result) => result.status === "rejected"),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** Upcoming items first, soonest first; then the rest, as loaded (newest first). */
|
|
170
|
-
function scheduledOrder(rows: readonly LoadedInboxItem[]): LoadedInboxItem[] {
|
|
171
|
-
const upcoming = rows
|
|
172
|
-
.filter(({ item }) => item.upcoming === true)
|
|
173
|
-
.sort(soonestFirst);
|
|
174
|
-
return [...upcoming, ...rows.filter(({ item }) => item.upcoming !== true)];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export default async function AccountInboxPage({
|
|
178
|
-
params,
|
|
179
|
-
searchParams,
|
|
180
|
-
}: Props): Promise<ReactElement | null> {
|
|
181
|
-
const { locale } = await params;
|
|
182
|
-
const requestedTab = ((await searchParams) ?? {}).tab;
|
|
183
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
184
|
-
const session = await accountSession(locale);
|
|
185
|
-
|
|
186
|
-
// The layout shows the interstitial in place of this page while an
|
|
187
|
-
// agreement is outstanding, but the App Router still renders the page: no
|
|
188
|
-
// Inbox loader may run meanwhile (`member.messages` stamps `readAt`, #8765 D7).
|
|
189
|
-
if (session && (await outstandingAgreements(session.ctx)).length > 0) return null;
|
|
190
|
-
|
|
191
|
-
// The contract's translator, for keys that are data (a kind's `label`).
|
|
192
|
-
const translate = session?.ctx.t ?? ((key: string): string => key);
|
|
193
|
-
const [inbox, forYou, newMenu] = session
|
|
194
|
-
? await Promise.all([
|
|
195
|
-
loadInboxItems(session.ctx),
|
|
196
|
-
loadForYou(locale),
|
|
197
|
-
loadNewActions(session.ctx),
|
|
198
|
-
])
|
|
199
|
-
: [
|
|
200
|
-
{ items: [], failed: false },
|
|
201
|
-
{ items: [], failed: false, now: "" },
|
|
202
|
-
{ actions: [], failed: false },
|
|
203
|
-
];
|
|
204
|
-
|
|
205
|
-
// #11175: the caption carries the day as a `LocalTime` node — the server
|
|
206
|
-
// fallback zone in this RSC's render, the viewer's own once the row
|
|
207
|
-
// hydrates.
|
|
208
|
-
const toRow = ({ kind, item }: LoadedInboxItem): InboxListRow => {
|
|
209
|
-
const label = translate(kind.label);
|
|
210
|
-
const icon = KIND_ICON[kind.kind];
|
|
211
|
-
return {
|
|
212
|
-
id: `${kind.kind}:${item.id}`,
|
|
213
|
-
...(icon ? { icon } : {}),
|
|
214
|
-
caption: item.at ? (
|
|
215
|
-
<>
|
|
216
|
-
{label}
|
|
217
|
-
{" · "}
|
|
218
|
-
<LocalTime at={item.at} preset="month-day" locale={locale} />
|
|
219
|
-
</>
|
|
220
|
-
) : (
|
|
221
|
-
label
|
|
222
|
-
),
|
|
223
|
-
title: item.title,
|
|
224
|
-
href: inboxItemHref(locale, kind.kind, item.id),
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const all = inbox.items.map(toRow);
|
|
229
|
-
// #11157 — the conversation kinds alone: the provider's messages and the
|
|
230
|
-
// member's own sent requests and messages, newest first as loaded.
|
|
231
|
-
const messages = inbox.items
|
|
232
|
-
.filter(({ kind }) => accountChatKinds.has(kind.kind))
|
|
233
|
-
.map(toRow);
|
|
234
|
-
// #11149 — the Orders tab: the kinds whose section is `purchases`.
|
|
235
|
-
const purchases = inbox.items
|
|
236
|
-
.filter(({ kind }) => kind.section === "purchases")
|
|
237
|
-
.map(toRow);
|
|
238
|
-
const scheduled = scheduledOrder(
|
|
239
|
-
inbox.items.filter(({ kind }) => kind.section === "upcoming"),
|
|
240
|
-
).map(toRow);
|
|
241
|
-
const failed = inbox.failed || forYou.failed || newMenu.failed;
|
|
242
|
-
// The `purchases` tab is Orders: the contract's section id, the Admin's word (#11149).
|
|
243
|
-
const tabs = [
|
|
244
|
-
{ id: "all", label: t("inbox.tabs.all"), count: all.length, rows: all },
|
|
245
|
-
{ id: "messages", label: t("inbox.tabs.messages"), count: messages.length, rows: messages },
|
|
246
|
-
{ id: "purchases", label: t("inbox.tabs.purchases"), count: purchases.length, rows: purchases },
|
|
247
|
-
{ id: "scheduled", label: t("inbox.tabs.scheduled"), count: scheduled.length, rows: scheduled },
|
|
248
|
-
];
|
|
249
|
-
|
|
250
|
-
return (
|
|
251
|
-
// The phone's top bar already clears the canvas — no top inset there.
|
|
252
|
-
<div className="max-w-3xl py-8 max-md:pt-0" data-testid="account-inbox">
|
|
253
|
-
{/* The page's one h1, on both phone tabs; visually hidden on the phone,
|
|
254
|
-
which has no large title (§5.15). New sits beside it (#8233 D4). */}
|
|
255
|
-
<div className="flex items-center justify-between gap-2">
|
|
256
|
-
<Heading level={1} visual={2} className="max-md:sr-only">
|
|
257
|
-
{t("inbox.title")}
|
|
258
|
-
</Heading>
|
|
259
|
-
<NewMenu
|
|
260
|
-
actions={newMenu.actions}
|
|
261
|
-
labels={{ trigger: t("new.trigger"), close: t("new.close") }}
|
|
262
|
-
/>
|
|
263
|
-
</div>
|
|
264
|
-
<PhoneTabPanel tabs={["inbox"]} desktop data-testid="inbox-panel-inbox">
|
|
265
|
-
{failed ? (
|
|
266
|
-
<ErrorRow
|
|
267
|
-
message={t("inbox.error")}
|
|
268
|
-
retryLabel={t("inbox.retry")}
|
|
269
|
-
className="mt-block-loose"
|
|
270
|
-
/>
|
|
271
|
-
) : null}
|
|
272
|
-
|
|
273
|
-
<InboxList
|
|
274
|
-
tabs={tabs}
|
|
275
|
-
// #11149 — `?tab=<id>` opens that tab; anything else (a repeated
|
|
276
|
-
// value, the frame's `for-you`) opens All.
|
|
277
|
-
defaultTab={tabs.find((tab) => tab.id === requestedTab)?.id ?? "all"}
|
|
278
|
-
{...(failed ? {} : { emptyLine: t("inbox.empty") })}
|
|
279
|
-
/>
|
|
280
|
-
</PhoneTabPanel>
|
|
281
|
-
|
|
282
|
-
{/* #7469 — the phone For you tab: every item, rows of one inset card.
|
|
283
|
-
At `md`+ the same items are the layout's aside. D12 here too: a
|
|
284
|
-
failed source shows the error row, and never the empty line alone. */}
|
|
285
|
-
<PhoneTabPanel tabs={["for-you"]} data-testid="inbox-panel-for-you">
|
|
286
|
-
{forYou.failed ? (
|
|
287
|
-
<ErrorRow
|
|
288
|
-
message={t("inbox.error")}
|
|
289
|
-
retryLabel={t("inbox.retry")}
|
|
290
|
-
className="mb-block-loose"
|
|
291
|
-
/>
|
|
292
|
-
) : null}
|
|
293
|
-
{forYou.failed && forYou.items.length === 0 ? null : (
|
|
294
|
-
<ForYouPanel
|
|
295
|
-
variant="list"
|
|
296
|
-
items={forYou.items}
|
|
297
|
-
persistKey={ACCOUNT_PERSIST_KEY}
|
|
298
|
-
labels={forYouLabels(translate)}
|
|
299
|
-
locale={locale}
|
|
300
|
-
now={forYou.now}
|
|
301
|
-
/>
|
|
302
|
-
)}
|
|
303
|
-
</PhoneTabPanel>
|
|
304
|
-
</div>
|
|
305
|
-
);
|
|
8
|
+
export default async function Route(
|
|
9
|
+
props: Omit<Parameters<typeof Page>[0], "config">,
|
|
10
|
+
) {
|
|
11
|
+
return Page({ ...props, config });
|
|
306
12
|
}
|
|
@@ -1,102 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* `GET /[locale]/account/privacy/export`.
|
|
4
|
-
*
|
|
5
|
-
* The Privacy tab's "Export data" button links here. The browser holds
|
|
6
|
-
* neither the client's hub credential (sealed in the `hub-session` cookie)
|
|
7
|
-
* nor this site's spoke key, so this route reads `GET /v1/member/data-export`
|
|
8
|
-
* with `forwardedCookieInit()` — the caller's own credential, so a person
|
|
9
|
-
* only ever gets their own records — and streams the JSON back unread.
|
|
10
|
-
*
|
|
11
|
-
* The same contract as the member file reads (`inbox/message/[id]/file`):
|
|
12
|
-
* the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
|
|
13
|
-
* `Content-Disposition` (attachment, `your-data.json`), `X-Content-Type-Options:
|
|
14
|
-
* nosniff`, the sandbox `Content-Security-Policy` and `Cache-Control: private,
|
|
15
|
-
* no-store` — so the file is never a document on this origin and never cached
|
|
16
|
-
* on the way. A hub answer missing any of the five is refused 502 rather than
|
|
17
|
-
* served without it.
|
|
18
|
-
*
|
|
19
|
-
* A refusal has no body: a cross-site navigation (`Sec-Fetch-Site` other
|
|
20
|
-
* than `same-origin` or `none` — a third-party link must not spend the
|
|
21
|
-
* person's hourly exports or drop a file on their disk) is a 403 before any
|
|
22
|
-
* call; no credential (signed out) is a 401, a hub 4xx keeps its status (a
|
|
23
|
-
* 429 when the person's hourly exports are spent), and a hub 5xx, a
|
|
24
|
-
* transport the api-client refuses or a hub call that throws is a 502.
|
|
25
|
-
*/
|
|
26
|
-
import { member, type MemberFileHeaders } from "@working-theory/api-client";
|
|
27
|
-
|
|
28
|
-
import { forwardedCookieInit } from "../../../../../../lib/server-api";
|
|
29
|
-
|
|
30
|
-
/** The response header each of the five hub headers goes out under. */
|
|
31
|
-
const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
|
|
32
|
-
contentType: "Content-Type",
|
|
33
|
-
contentDisposition: "Content-Disposition",
|
|
34
|
-
contentTypeOptions: "X-Content-Type-Options",
|
|
35
|
-
contentSecurityPolicy: "Content-Security-Policy",
|
|
36
|
-
cacheControl: "Cache-Control",
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function refusal(status: number, retryAfterSeconds?: number): Response {
|
|
40
|
-
return new Response(null, {
|
|
41
|
-
status,
|
|
42
|
-
headers: {
|
|
43
|
-
"Cache-Control": "private, no-store",
|
|
44
|
-
// A 429 keeps the hub's retry hint: the api-client answers the JSON
|
|
45
|
-
// body, not the headers, and the API's refusal names the seconds.
|
|
46
|
-
...(retryAfterSeconds === undefined
|
|
47
|
-
? {}
|
|
48
|
-
: { "Retry-After": String(retryAfterSeconds) }),
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** The API's `retryAfterSeconds`, when the refusal body carries one. */
|
|
54
|
-
function retryAfterOf(body: unknown): number | undefined {
|
|
55
|
-
const seconds = (body as { retryAfterSeconds?: unknown } | null)
|
|
56
|
-
?.retryAfterSeconds;
|
|
57
|
-
return typeof seconds === "number" && Number.isFinite(seconds)
|
|
58
|
-
? seconds
|
|
59
|
-
: undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
|
|
63
|
-
function refusalStatus(status: number, body: unknown): number {
|
|
64
|
-
if (status === 0) {
|
|
65
|
-
const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
|
|
66
|
-
return code === "unauthorized" ? 401 : 502;
|
|
67
|
-
}
|
|
68
|
-
return status >= 500 ? 502 : status;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// platform-decisions-waiver: api-versioning — a page-scoped download link on the site's own account area, not an API contract; it re-serves the versioned hub route /v1/member/data-export
|
|
72
|
-
export async function GET(request: Request): Promise<Response> {
|
|
73
|
-
const site = request.headers.get("sec-fetch-site");
|
|
74
|
-
if (site !== null && site !== "same-origin" && site !== "none")
|
|
75
|
-
return refusal(403);
|
|
76
|
-
|
|
77
|
-
// The api-client throws, rather than answering `{ ok: false }`, on a
|
|
78
|
-
// network failure or a redirect — that is a 502 too, never Next's own 500.
|
|
79
|
-
let res: Awaited<ReturnType<typeof member.exportData>>;
|
|
80
|
-
try {
|
|
81
|
-
res = await member.exportData(await forwardedCookieInit());
|
|
82
|
-
} catch {
|
|
83
|
-
return refusal(502);
|
|
84
|
-
}
|
|
85
|
-
if (!res.ok)
|
|
86
|
-
return refusal(refusalStatus(res.status, res.body), retryAfterOf(res.body));
|
|
87
|
-
|
|
88
|
-
const { stream, headers } = res.body;
|
|
89
|
-
const out = new Headers();
|
|
90
|
-
for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [
|
|
91
|
-
keyof MemberFileHeaders,
|
|
92
|
-
string,
|
|
93
|
-
][]) {
|
|
94
|
-
const value = headers[key];
|
|
95
|
-
if (value === null) {
|
|
96
|
-
await stream.cancel();
|
|
97
|
-
return refusal(502);
|
|
98
|
-
}
|
|
99
|
-
out.set(name, value);
|
|
100
|
-
}
|
|
101
|
-
return new Response(stream, { status: 200, headers: out });
|
|
102
|
-
}
|
|
1
|
+
// Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
|
|
2
|
+
export { GET } from "@working-theory/account/privacy/export/route";
|
|
@@ -1,240 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* RSC, outside the account layout's SignedInShell (#8430), in the member's
|
|
6
|
-
* settings frame (D7) — standalone, the Admin's shape. In DOM order:
|
|
7
|
-
*
|
|
8
|
-
* 1. The title and the lead, with "Privacy Policy" linked to the site's
|
|
9
|
-
* privacy policy (`consentPoliciesFor(locale).privacy`, #8765 D9).
|
|
10
|
-
* 2. One card:
|
|
11
|
-
* - account-privacy-data-use — "How we use your data", collapsed, a
|
|
12
|
-
* disclosure button whose chevron expands it in place to the two
|
|
13
|
-
* bullets (`DataUseDisclosure`);
|
|
14
|
-
* - account-privacy-data-consent — one `ConsentSwitchList` row per
|
|
15
|
-
* `area: "data"` purpose, the shipped one being "Help improve our AI
|
|
16
|
-
* models" (`ai_training`, #11164 AC-2: a consent, off until ticked,
|
|
17
|
-
* written through `setConsentAction`), with its description and the
|
|
18
|
-
* given/withdrawn date line; a site that declares none shows the one
|
|
19
|
-
* line. A failed consents read shows the unavailable line in its place
|
|
20
|
-
* and everything else still renders.
|
|
21
|
-
* 3. One card: account-privacy-your-data — the "Your data" table
|
|
22
|
-
* (`AccountDataTable`): Export data, a download of the person's own
|
|
23
|
-
* records through this site's `./export` route; Delete stored sessions,
|
|
24
|
-
* which confirms first, then calls `deleteStoredSessionsAction` and
|
|
25
|
-
* reports the count. The same card on every surface, a spoke that
|
|
26
|
-
* signs in through its hub included (#11194): the two member routes
|
|
27
|
-
* the table calls are on `HUB_SESSION_ROUTES`, each answered for the
|
|
28
|
-
* spoke's own workspace from the hub session.
|
|
29
|
-
*
|
|
30
|
-
* Gone (#11164 rulings 1, 2, 5, 6): the Cookies section (the choice cannot
|
|
31
|
-
* change without a new banner prompt), the summary row, the agreements list
|
|
32
|
-
* (the ledger keeps the record) and the account-deletion line and button. An
|
|
33
|
-
* account-deletion request now lives in the Delete row's confirmation, which
|
|
34
|
-
* points at Support — on every surface but a hub-mode spoke whose hub answers
|
|
35
|
-
* no member route (`via: "none"`), where Support must not take it
|
|
36
|
-
* (SEC-7894-11); `POST /v1/member/deletion-request` is unchanged.
|
|
37
|
-
*
|
|
38
|
-
* The registry purpose this app names itself: `ai_training` →
|
|
39
|
-
* `settings.privacy.purposes.ai_training` (title, description); a purpose a
|
|
40
|
-
* site adds is labelled by its statement and described by its description.
|
|
41
|
-
* The lead is one `t.rich` message whose `<policy>` tag is the link (the
|
|
42
|
-
* billing tab's `accessEnds` idiom); the metadata description is the same
|
|
43
|
-
* message through `t.markup` with the tag dropped.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
import { member } from "@working-theory/api-client";
|
|
47
|
-
import {
|
|
48
|
-
AccountDataTable,
|
|
49
|
-
AccountSettingsFrame,
|
|
50
|
-
AccountSettingsPane,
|
|
51
|
-
ConsentSwitchList,
|
|
52
|
-
DataUseDisclosure,
|
|
53
|
-
type ConsentSwitchRow,
|
|
54
|
-
} from "@working-theory/templates/account";
|
|
55
|
-
import { localeHref } from "@working-theory/ui";
|
|
56
|
-
import {
|
|
57
|
-
Link,
|
|
58
|
-
SERVER_TIME_ZONE,
|
|
59
|
-
Text,
|
|
60
|
-
formatLocalTime,
|
|
61
|
-
} from "@working-theory/ui/primitives";
|
|
62
|
-
import { AI_TRAINING_PURPOSE_ID } from "@working-theory/validation";
|
|
63
|
-
import type { Metadata } from "next";
|
|
64
|
-
import { getTranslations } from "next-intl/server";
|
|
65
|
-
import type { ReactElement } from "react";
|
|
66
|
-
|
|
67
|
-
import { consentPoliciesFor } from "../../../../../lib/consent-policies";
|
|
68
|
-
import { accountSession } from "../account-data";
|
|
69
|
-
import { loadProfileSource } from "../general/profile-source";
|
|
70
|
-
import { memberSettingsFrame, type Translate } from "../settings-frame";
|
|
71
|
-
|
|
72
|
-
import { deleteStoredSessionsAction, setConsentAction } from "./actions";
|
|
73
|
-
|
|
74
|
-
interface Props {
|
|
75
|
-
params: Promise<{ locale: string }>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
79
|
-
const { locale } = await params;
|
|
80
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
81
|
-
return {
|
|
82
|
-
title: t("settings.privacy.title"),
|
|
83
|
-
description: t.markup("settings.privacy.lead", {
|
|
84
|
-
policy: (chunks) => chunks,
|
|
85
|
-
}),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default async function AccountPrivacyPage({
|
|
90
|
-
params,
|
|
91
|
-
}: Props): Promise<ReactElement> {
|
|
92
|
-
const { locale } = await params;
|
|
93
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
94
|
-
const session = await accountSession(locale);
|
|
95
|
-
const frame = memberSettingsFrame(
|
|
96
|
-
locale,
|
|
97
|
-
t as unknown as Translate,
|
|
98
|
-
"privacy",
|
|
99
|
-
);
|
|
100
|
-
const policyHref =
|
|
101
|
-
consentPoliciesFor(locale)["privacy"] ?? localeHref(locale, "/privacy");
|
|
102
|
-
const lead = t.rich("settings.privacy.lead", {
|
|
103
|
-
policy: (chunks) => (
|
|
104
|
-
<Link href={policyHref} data-testid="account-privacy-policy">
|
|
105
|
-
{chunks}
|
|
106
|
-
</Link>
|
|
107
|
-
),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Unreachable behind the (authed) gate; a session that expired between
|
|
111
|
-
// the layout and the page renders the pane's title alone.
|
|
112
|
-
if (!session) {
|
|
113
|
-
return (
|
|
114
|
-
<AccountSettingsFrame {...frame} name="">
|
|
115
|
-
<AccountSettingsPane
|
|
116
|
-
id="account-settings-privacy"
|
|
117
|
-
title={t("settings.privacy.title")}
|
|
118
|
-
lead={lead}
|
|
119
|
-
>
|
|
120
|
-
{null}
|
|
121
|
-
</AccountSettingsPane>
|
|
122
|
-
</AccountSettingsFrame>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const { ctx } = session;
|
|
127
|
-
const name = ctx.user.name || ctx.user.email;
|
|
128
|
-
const source = await loadProfileSource(ctx);
|
|
129
|
-
|
|
130
|
-
let dataRows: ConsentSwitchRow[] = [];
|
|
131
|
-
let consentsAvailable = true;
|
|
132
|
-
try {
|
|
133
|
-
const res = await member.consents(ctx.init, { locale });
|
|
134
|
-
if (res.ok) {
|
|
135
|
-
dataRows = res.body.purposes
|
|
136
|
-
.filter((purpose) => purpose.area === "data")
|
|
137
|
-
.map((purpose) => ({
|
|
138
|
-
id: purpose.id,
|
|
139
|
-
...(purpose.id === AI_TRAINING_PURPOSE_ID
|
|
140
|
-
? {
|
|
141
|
-
label: t("settings.privacy.purposes.ai_training.title"),
|
|
142
|
-
description: t(
|
|
143
|
-
"settings.privacy.purposes.ai_training.description",
|
|
144
|
-
),
|
|
145
|
-
}
|
|
146
|
-
: {
|
|
147
|
-
label: purpose.statement,
|
|
148
|
-
...(purpose.description
|
|
149
|
-
? { description: purpose.description }
|
|
150
|
-
: {}),
|
|
151
|
-
}),
|
|
152
|
-
granted: purpose.effective,
|
|
153
|
-
...(purpose.state
|
|
154
|
-
? {
|
|
155
|
-
dateLine: purpose.state.granted
|
|
156
|
-
? t("settings.privacy.given", {
|
|
157
|
-
date: formatDate(purpose.state.at, locale),
|
|
158
|
-
})
|
|
159
|
-
: t("settings.privacy.withdrawn", {
|
|
160
|
-
date: formatDate(purpose.state.at, locale),
|
|
161
|
-
}),
|
|
162
|
-
}
|
|
163
|
-
: {}),
|
|
164
|
-
}));
|
|
165
|
-
} else {
|
|
166
|
-
consentsAvailable = false;
|
|
167
|
-
}
|
|
168
|
-
} catch {
|
|
169
|
-
consentsAvailable = false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<AccountSettingsFrame {...frame} name={name}>
|
|
174
|
-
<AccountSettingsPane
|
|
175
|
-
id="account-settings-privacy"
|
|
176
|
-
title={t("settings.privacy.title")}
|
|
177
|
-
lead={lead}
|
|
178
|
-
>
|
|
179
|
-
<>
|
|
180
|
-
<DataUseDisclosure
|
|
181
|
-
title={t("settings.privacy.dataUse.title")}
|
|
182
|
-
bullets={[
|
|
183
|
-
t("settings.privacy.dataUse.bullet1"),
|
|
184
|
-
t("settings.privacy.dataUse.bullet2"),
|
|
185
|
-
]}
|
|
186
|
-
testId="account-privacy-data-use"
|
|
187
|
-
/>
|
|
188
|
-
{consentsAvailable ? (
|
|
189
|
-
<ConsentSwitchList
|
|
190
|
-
rows={dataRows}
|
|
191
|
-
onChange={setConsentAction}
|
|
192
|
-
emptyLine={t("settings.privacy.consentsEmpty")}
|
|
193
|
-
testIdPrefix="account-privacy-data-consent"
|
|
194
|
-
/>
|
|
195
|
-
) : (
|
|
196
|
-
<span data-testid="account-privacy-unavailable">
|
|
197
|
-
<Text as="p" variant="body-sm" tone="muted" className="pt-3">
|
|
198
|
-
{t("settings.privacy.unavailable")}
|
|
199
|
-
</Text>
|
|
200
|
-
</span>
|
|
201
|
-
)}
|
|
202
|
-
</>
|
|
203
|
-
<AccountDataTable
|
|
204
|
-
exportHref={localeHref(locale, "/account/privacy/export")}
|
|
205
|
-
onDeleteSessions={deleteStoredSessionsAction}
|
|
206
|
-
supportHref={
|
|
207
|
-
source.via === "none"
|
|
208
|
-
? null
|
|
209
|
-
: localeHref(locale, "/account/support")
|
|
210
|
-
}
|
|
211
|
-
testIdPrefix="account-privacy-your-data"
|
|
212
|
-
labels={{
|
|
213
|
-
title: t("settings.privacy.yourData.title"),
|
|
214
|
-
exportLabel: t("settings.privacy.yourData.exportLabel"),
|
|
215
|
-
exportButton: t("settings.privacy.yourData.exportButton"),
|
|
216
|
-
deleteLabel: t("settings.privacy.yourData.deleteLabel"),
|
|
217
|
-
deleteDescription: t("settings.privacy.yourData.deleteDescription"),
|
|
218
|
-
deleteButton: t("settings.privacy.yourData.deleteButton"),
|
|
219
|
-
confirmTitle: t("settings.privacy.yourData.confirmTitle"),
|
|
220
|
-
confirmBody: t("settings.privacy.yourData.confirmBody"),
|
|
221
|
-
confirmCancel: t("settings.privacy.yourData.confirmCancel"),
|
|
222
|
-
confirmDelete: t("settings.privacy.yourData.confirmDelete"),
|
|
223
|
-
deleting: t("settings.privacy.yourData.deleting"),
|
|
224
|
-
deleteFailed: t("settings.privacy.yourData.deleteFailed"),
|
|
225
|
-
accountDeletion: t("settings.privacy.yourData.accountDeletion"),
|
|
226
|
-
accountDeletionLink: t(
|
|
227
|
-
"settings.privacy.yourData.accountDeletionLink",
|
|
228
|
-
),
|
|
229
|
-
}}
|
|
230
|
-
/>
|
|
231
|
-
</AccountSettingsPane>
|
|
232
|
-
</AccountSettingsFrame>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// #11159: a `t()` argument is a string, so this RSC reads the day in the
|
|
237
|
-
// server fallback zone — never the host's, which the unpinned form read.
|
|
238
|
-
function formatDate(iso: string, locale: string): string {
|
|
239
|
-
return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
|
|
240
|
-
}
|
|
1
|
+
// Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
|
|
2
|
+
export { default } from "@working-theory/account/privacy/page";
|
|
3
|
+
export { generateMetadata } from "@working-theory/account/privacy/page";
|