create-ailk 0.37.0 → 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 +149 -2
- 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 +7 -2
- package/dist/add-route.js +28 -13
- 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 +28 -1
- package/dist/sync-routes.js +144 -11
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +31 -2
- package/dist/update.js +627 -99
- 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,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Account page's phone step (#11106, spec
|
|
3
|
-
* docs/specs/11106-the-workforce-foundation-roles-by-spec.md D9; AC-6's
|
|
4
|
-
* "a user sets and verifies a phone in the hub's Account settings").
|
|
5
|
-
*
|
|
6
|
-
* - the island: send a code, then verify it; a verified number shows with
|
|
7
|
-
* "Verified" and Remove; a refusal shows its line; a build without the
|
|
8
|
-
* step, or an unverified email, shows its line and no form;
|
|
9
|
-
* - the server actions: each is a SERVER call on the plugin with the
|
|
10
|
-
* request's headers, `verifyPhoneCode` always with `updatePhoneNumber:
|
|
11
|
-
* true`, Remove writes `phoneNumber: null`, a refusal maps to its reason,
|
|
12
|
-
* a build without the step answers `unavailable` with no call, and no log
|
|
13
|
-
* line carries the number or the code.
|
|
14
|
-
*/
|
|
15
|
-
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
16
|
-
|
|
17
|
-
const mockSendOtp = jest.fn();
|
|
18
|
-
const mockVerify = jest.fn();
|
|
19
|
-
const mockUpdateUser = jest.fn();
|
|
20
|
-
const mockPhoneStepActive = jest.fn();
|
|
21
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: auth.ts is Better Auth's server singleton (a DB/HTTP boundary); its phone endpoints are the actions' one dependency.
|
|
22
|
-
jest.mock("../../../../../../auth", () => ({
|
|
23
|
-
__esModule: true,
|
|
24
|
-
phoneStepActive: () => mockPhoneStepActive(),
|
|
25
|
-
auth: {
|
|
26
|
-
api: {
|
|
27
|
-
sendPhoneNumberOTP: (...args: unknown[]) => mockSendOtp(...args),
|
|
28
|
-
verifyPhoneNumber: (...args: unknown[]) => mockVerify(...args),
|
|
29
|
-
updateUser: (...args: unknown[]) => mockUpdateUser(...args),
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const REQUEST_HEADERS = new Headers({ cookie: "better-auth.session_token=abc" });
|
|
35
|
-
jest.mock("next/headers", () => ({
|
|
36
|
-
__esModule: true,
|
|
37
|
-
headers: jest.fn(async () => REQUEST_HEADERS),
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
const mockRefresh = jest.fn();
|
|
41
|
-
jest.mock("next/navigation", () => ({
|
|
42
|
-
__esModule: true,
|
|
43
|
-
useRouter: () => ({ refresh: mockRefresh }),
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
import { removePhone, sendPhoneCode, verifyPhoneCode } from "../phone-actions";
|
|
47
|
-
import { PhoneVerification, type PhoneVerificationLabels } from "../phone-verification";
|
|
48
|
-
|
|
49
|
-
const NUMBER = "+15555550123";
|
|
50
|
-
const CODE = "482913";
|
|
51
|
-
|
|
52
|
-
const LABELS: PhoneVerificationLabels = {
|
|
53
|
-
title: "Phone",
|
|
54
|
-
lead: "Only you can set it.",
|
|
55
|
-
number: "Mobile number",
|
|
56
|
-
numberHint: "Include the country code.",
|
|
57
|
-
sendCode: "Send code",
|
|
58
|
-
sending: "Sending…",
|
|
59
|
-
code: "Code",
|
|
60
|
-
codeHint: "Six digits.",
|
|
61
|
-
verify: "Verify",
|
|
62
|
-
verifying: "Verifying…",
|
|
63
|
-
verified: "Verified",
|
|
64
|
-
remove: "Remove",
|
|
65
|
-
sent: "We texted you a code.",
|
|
66
|
-
unavailable: "Phone verification isn't available on this site.",
|
|
67
|
-
unverifiedEmail: "Confirm your email address first.",
|
|
68
|
-
errors: {
|
|
69
|
-
invalid_number: "Bad number.",
|
|
70
|
-
invalid_code: "Bad code.",
|
|
71
|
-
taken: "Taken.",
|
|
72
|
-
too_many: "Too many.",
|
|
73
|
-
unverified: "Unverified.",
|
|
74
|
-
signed_out: "Signed out.",
|
|
75
|
-
unavailable: "Unavailable.",
|
|
76
|
-
failed: "Failed.",
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const apiError = (code: string) => Object.assign(new Error(code), { body: { code } });
|
|
81
|
-
|
|
82
|
-
let logLines: string[] = [];
|
|
83
|
-
beforeEach(() => {
|
|
84
|
-
jest.clearAllMocks();
|
|
85
|
-
mockPhoneStepActive.mockReturnValue(true);
|
|
86
|
-
mockSendOtp.mockResolvedValue({ message: "code sent" });
|
|
87
|
-
mockVerify.mockResolvedValue({ status: true });
|
|
88
|
-
mockUpdateUser.mockResolvedValue({ status: true });
|
|
89
|
-
logLines = [];
|
|
90
|
-
jest.spyOn(console, "error").mockImplementation((...args: unknown[]) => {
|
|
91
|
-
logLines.push(args.map(String).join(" "));
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
afterEach(() => {
|
|
96
|
-
jest.restoreAllMocks();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe("the island", () => {
|
|
100
|
-
it("sends a code, then verifies it, and refreshes the page", async () => {
|
|
101
|
-
render(<PhoneVerification available emailVerified phone={null} labels={LABELS} />);
|
|
102
|
-
fireEvent.change(screen.getByTestId("account-phone-number-input"), { target: { value: NUMBER } });
|
|
103
|
-
await act(async () => {
|
|
104
|
-
fireEvent.click(screen.getByTestId("account-phone-send"));
|
|
105
|
-
});
|
|
106
|
-
expect(mockSendOtp).toHaveBeenCalledWith({ body: { phoneNumber: NUMBER }, headers: REQUEST_HEADERS });
|
|
107
|
-
expect(screen.getByTestId("account-phone-sent")).toHaveTextContent(LABELS.sent);
|
|
108
|
-
|
|
109
|
-
fireEvent.change(screen.getByTestId("account-phone-code-input"), { target: { value: CODE } });
|
|
110
|
-
await act(async () => {
|
|
111
|
-
fireEvent.click(screen.getByTestId("account-phone-verify"));
|
|
112
|
-
});
|
|
113
|
-
expect(mockVerify).toHaveBeenCalledWith({
|
|
114
|
-
body: { phoneNumber: NUMBER, code: CODE, updatePhoneNumber: true },
|
|
115
|
-
headers: REQUEST_HEADERS,
|
|
116
|
-
});
|
|
117
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("a refused code shows its line and refreshes nothing", async () => {
|
|
121
|
-
mockVerify.mockRejectedValue(apiError("INVALID_OTP"));
|
|
122
|
-
render(<PhoneVerification available emailVerified phone={null} labels={LABELS} />);
|
|
123
|
-
fireEvent.change(screen.getByTestId("account-phone-number-input"), { target: { value: NUMBER } });
|
|
124
|
-
await act(async () => {
|
|
125
|
-
fireEvent.click(screen.getByTestId("account-phone-send"));
|
|
126
|
-
});
|
|
127
|
-
fireEvent.change(screen.getByTestId("account-phone-code-input"), { target: { value: CODE } });
|
|
128
|
-
await act(async () => {
|
|
129
|
-
fireEvent.click(screen.getByTestId("account-phone-verify"));
|
|
130
|
-
});
|
|
131
|
-
expect(screen.getByTestId("account-phone-error")).toHaveTextContent(LABELS.errors.invalid_code);
|
|
132
|
-
expect(mockRefresh).not.toHaveBeenCalled();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("a verified number shows with Verified and Remove, which clears it", async () => {
|
|
136
|
-
render(
|
|
137
|
-
<PhoneVerification available emailVerified phone={{ number: NUMBER, verified: true }} labels={LABELS} />,
|
|
138
|
-
);
|
|
139
|
-
expect(screen.getByTestId("account-phone-number")).toHaveTextContent(NUMBER);
|
|
140
|
-
expect(screen.getByTestId("account-phone-verified")).toHaveTextContent(LABELS.verified);
|
|
141
|
-
expect(screen.queryByTestId("account-phone-number-input")).toBeNull();
|
|
142
|
-
await act(async () => {
|
|
143
|
-
fireEvent.click(screen.getByTestId("account-phone-remove"));
|
|
144
|
-
});
|
|
145
|
-
expect(mockUpdateUser).toHaveBeenCalledWith({ body: { phoneNumber: null }, headers: REQUEST_HEADERS });
|
|
146
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("a build without the step shows the not-available line and no form", () => {
|
|
150
|
-
render(<PhoneVerification available={false} emailVerified phone={null} labels={LABELS} />);
|
|
151
|
-
expect(screen.getByTestId("account-phone-unavailable")).toHaveTextContent(LABELS.unavailable);
|
|
152
|
-
expect(screen.queryByTestId("account-phone-send-form")).toBeNull();
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("an unverified email shows the confirm-email line and no form", () => {
|
|
156
|
-
render(<PhoneVerification available emailVerified={false} phone={null} labels={LABELS} />);
|
|
157
|
-
expect(screen.getByTestId("account-phone-unverified-email")).toHaveTextContent(LABELS.unverifiedEmail);
|
|
158
|
-
expect(screen.queryByTestId("account-phone-send-form")).toBeNull();
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe("the server actions", () => {
|
|
163
|
-
it.each([
|
|
164
|
-
["INVALID_PHONE_NUMBER", "invalid_number"],
|
|
165
|
-
["EMAIL_NOT_VERIFIED", "unverified"],
|
|
166
|
-
["SESSION_REQUIRED", "signed_out"],
|
|
167
|
-
["SOMETHING_ELSE", "failed"],
|
|
168
|
-
])("sendPhoneCode maps %s to %s", async (code, reason) => {
|
|
169
|
-
mockSendOtp.mockRejectedValue(apiError(code));
|
|
170
|
-
expect(await sendPhoneCode(NUMBER)).toEqual({ ok: false, reason });
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it.each([
|
|
174
|
-
["INVALID_OTP", "invalid_code"],
|
|
175
|
-
["TOO_MANY_ATTEMPTS", "too_many"],
|
|
176
|
-
["PHONE_NUMBER_EXIST", "taken"],
|
|
177
|
-
])("verifyPhoneCode maps %s to %s", async (code, reason) => {
|
|
178
|
-
mockVerify.mockRejectedValue(apiError(code));
|
|
179
|
-
expect(await verifyPhoneCode(NUMBER, CODE)).toEqual({ ok: false, reason });
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("verifyPhoneCode always asks for updatePhoneNumber, never a sign-in", async () => {
|
|
183
|
-
expect(await verifyPhoneCode(NUMBER, CODE)).toEqual({ ok: true });
|
|
184
|
-
expect(mockVerify.mock.calls[0]![0].body.updatePhoneNumber).toBe(true);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("refuses untrusted input before any call", async () => {
|
|
188
|
-
expect(await sendPhoneCode({ phoneNumber: NUMBER })).toEqual({ ok: false, reason: "invalid_number" });
|
|
189
|
-
expect(await verifyPhoneCode(NUMBER, "1234567")).toEqual({ ok: false, reason: "invalid_code" });
|
|
190
|
-
expect(mockSendOtp).not.toHaveBeenCalled();
|
|
191
|
-
expect(mockVerify).not.toHaveBeenCalled();
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("a build without the step answers unavailable with no call", async () => {
|
|
195
|
-
mockPhoneStepActive.mockReturnValue(false);
|
|
196
|
-
expect(await sendPhoneCode(NUMBER)).toEqual({ ok: false, reason: "unavailable" });
|
|
197
|
-
expect(await verifyPhoneCode(NUMBER, CODE)).toEqual({ ok: false, reason: "unavailable" });
|
|
198
|
-
expect(await removePhone()).toEqual({ ok: false, reason: "unavailable" });
|
|
199
|
-
expect(mockSendOtp).not.toHaveBeenCalled();
|
|
200
|
-
expect(mockVerify).not.toHaveBeenCalled();
|
|
201
|
-
expect(mockUpdateUser).not.toHaveBeenCalled();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("no log line carries the number or the code", async () => {
|
|
205
|
-
mockSendOtp.mockRejectedValue(apiError("INVALID_PHONE_NUMBER"));
|
|
206
|
-
mockVerify.mockRejectedValue(apiError("INVALID_OTP"));
|
|
207
|
-
await sendPhoneCode(NUMBER);
|
|
208
|
-
await verifyPhoneCode(NUMBER, CODE);
|
|
209
|
-
expect(logLines.length).toBe(2);
|
|
210
|
-
for (const line of logLines) {
|
|
211
|
-
expect(line).not.toContain(NUMBER.slice(1));
|
|
212
|
-
expect(line).not.toContain(CODE);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
});
|
package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment node
|
|
3
|
-
*
|
|
4
|
-
* User settings › General reaches sign-in only through the generated seam
|
|
5
|
-
* (#11138). A spoke that signs in through its hub keeps this page, but not
|
|
6
|
-
* `auth.ts` or any other sign-in or database file, so a direct import here
|
|
7
|
-
* would make create-ailk's spoke closure drop the page with them and refuse.
|
|
8
|
-
* Every non-test source file under `account/general` is read, and none may
|
|
9
|
-
* name one of those files, statically or by `import()`/`require`; the phone
|
|
10
|
-
* step goes through `loadPhoneApi` in `lib/topology.generated.ts` instead.
|
|
11
|
-
*/
|
|
12
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
13
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
14
|
-
|
|
15
|
-
const GENERAL = resolve(__dirname, "..");
|
|
16
|
-
const WEB = resolve(GENERAL, "../../../../..");
|
|
17
|
-
|
|
18
|
-
/** The sign-in and database files a spoke does not carry, relative to apps/web. */
|
|
19
|
-
const SIGN_IN_FILES = [
|
|
20
|
-
"auth",
|
|
21
|
-
"lib/prisma-for-auth",
|
|
22
|
-
"lib/mcp-oauth",
|
|
23
|
-
"lib/license-key-store",
|
|
24
|
-
"app/api/auth",
|
|
25
|
-
"app/[locale]/(auth)",
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const sources = readdirSync(GENERAL).filter((name) => /\.tsx?$/.test(name));
|
|
29
|
-
|
|
30
|
-
function specifiers(text: string): string[] {
|
|
31
|
-
return [
|
|
32
|
-
...text.matchAll(/(?:\bfrom\s+|\bimport\s*\(\s*|\brequire\s*\(\s*)["'`]([^"'`]+)["'`]/g),
|
|
33
|
-
].map((m) => m[1] as string);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
describe("account/general imports sign-in only through the seam (#11138)", () => {
|
|
37
|
-
it("reads every source file", () => {
|
|
38
|
-
expect(sources).toEqual(expect.arrayContaining(["page.tsx", "phone-actions.ts"]));
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it.each(sources)("%s names no sign-in or database file", (name) => {
|
|
42
|
-
const file = join(GENERAL, name);
|
|
43
|
-
const reached = specifiers(readFileSync(file, "utf8"))
|
|
44
|
-
.filter((spec) => spec.startsWith("."))
|
|
45
|
-
.map((spec) =>
|
|
46
|
-
relative(WEB, resolve(dirname(file), spec))
|
|
47
|
-
.split("\\")
|
|
48
|
-
.join("/")
|
|
49
|
-
.replace(/\.tsx?$/, ""),
|
|
50
|
-
);
|
|
51
|
-
expect(
|
|
52
|
-
reached.filter((target) =>
|
|
53
|
-
SIGN_IN_FILES.some((seed) => target === seed || target.startsWith(`${seed}/`)),
|
|
54
|
-
),
|
|
55
|
-
).toEqual([]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("the phone step reads the seam", () => {
|
|
59
|
-
for (const name of ["page.tsx", "phone-actions.ts"]) {
|
|
60
|
-
expect(readFileSync(join(GENERAL, name), "utf8")).toMatch(
|
|
61
|
-
/from "\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/lib\/topology\.generated"/,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The account name the contact derives (#11167 ruling 5): "First Last" from
|
|
3
|
-
* the contact's given and family names, and the rule for when the account
|
|
4
|
-
* name may follow it — while it is empty, or equals what the PREVIOUS contact
|
|
5
|
-
* derived, so a name the person set by hand is never overwritten.
|
|
6
|
-
*
|
|
7
|
-
* Not in `contact-actions.ts`: Next.js makes every runtime export of a
|
|
8
|
-
* "use server" file a Server Action and fails the build on a synchronous one
|
|
9
|
-
* (the `invitation-id.ts` rule, #11141).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { PROFILE_NAME_MAX } from "@working-theory/validation";
|
|
13
|
-
|
|
14
|
-
export type ContactNames = { givenName: string | null; familyName: string | null } | null;
|
|
15
|
-
|
|
16
|
-
/** "First Last", trimmed and cut to the profile name's width; `""` with neither name. */
|
|
17
|
-
export function derivedAccountName(contact: ContactNames): string {
|
|
18
|
-
return [contact?.givenName, contact?.familyName]
|
|
19
|
-
.map((part) => part?.trim() ?? "")
|
|
20
|
-
.filter((part) => part !== "")
|
|
21
|
-
.join(" ")
|
|
22
|
-
.slice(0, PROFILE_NAME_MAX)
|
|
23
|
-
.trim();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Whether the account name may follow the contact: it is empty, or it is
|
|
28
|
-
* exactly what the previous contact derived (so it was never set by hand).
|
|
29
|
-
*/
|
|
30
|
-
export function accountNameFollowsContact(
|
|
31
|
-
current: string | null | undefined,
|
|
32
|
-
previous: ContactNames,
|
|
33
|
-
): boolean {
|
|
34
|
-
const name = current?.trim() ?? "";
|
|
35
|
-
return name === "" || name === derivedAccountName(previous);
|
|
36
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client"; // reads the URL fragment, which only the browser has
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* BillingAnchor — forwards `/account/general#billing` to `/account/billing`
|
|
5
|
-
* (#8232, spec docs/specs/8232-member-settings-account-general-and-spec.md
|
|
6
|
-
* D8, C6).
|
|
7
|
-
*
|
|
8
|
-
* A URL fragment is never sent to the server, so `/account/settings` cannot
|
|
9
|
-
* redirect `#billing` itself: it redirects to `/account/general`, the browser
|
|
10
|
-
* carries the fragment across that redirect, and this part of General sends
|
|
11
|
-
* a `#billing` on to Billing. `#general`, or no fragment, stays on General.
|
|
12
|
-
* It renders nothing.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { localeHref } from "@working-theory/ui";
|
|
16
|
-
import { useRouter } from "next/navigation";
|
|
17
|
-
import { useEffect } from "react";
|
|
18
|
-
|
|
19
|
-
export function BillingAnchor({ locale }: { locale: string }): null {
|
|
20
|
-
const router = useRouter();
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (window.location.hash === "#billing") {
|
|
23
|
-
router.replace(localeHref(locale, "/account/billing"));
|
|
24
|
-
}
|
|
25
|
-
}, [locale, router]);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* general/contact-actions.ts — User settings › General's contact-details write
|
|
5
|
-
* (#8435, spec docs/specs/8435-contact-details-on-the-client-spec.md D13; the
|
|
6
|
-
* route is `PATCH /v1/member/profile/contact`).
|
|
7
|
-
*
|
|
8
|
-
* `saveContact` replaces the member's contact details on THIS site —
|
|
9
|
-
* `member.updateContact`, never the hub account's name and photo
|
|
10
|
-
* (`profile-actions.ts`'s `saveProfile` is that) and never another site's
|
|
11
|
-
* record. It sends `forwardedCookieInit()`'s init: on a single site the session
|
|
12
|
-
* cookie plus the request's `Origin`, which `apps/api`'s cookie CSRF check
|
|
13
|
-
* needs; on a hub-mode spoke the hub credential. It takes no identity
|
|
14
|
-
* argument — who comes from the forwarded credential alone.
|
|
15
|
-
*
|
|
16
|
-
* It answers `{ ok: true }` or a refusal `reason` the form maps to its own
|
|
17
|
-
* line: `telephone` (a number that is not E.164, `400 telephone_invalid`),
|
|
18
|
-
* `invalid` (any other refused body), `unverified` (`403`), `unavailable`
|
|
19
|
-
* (`404`, `503`, or `409 contact_unavailable` — a Person of that email held by
|
|
20
|
-
* another account), else `failed`. Logs carry a status or `err.name` only —
|
|
21
|
-
* never a name, a number, an address or an email.
|
|
22
|
-
*
|
|
23
|
-
* #11167 ruling 5 — the account name follows the contact. The member General
|
|
24
|
-
* renders no Name field; after a save that succeeded, `followContactName`
|
|
25
|
-
* derives "First Last" from the saved contact's given and family names and
|
|
26
|
-
* writes it as the account name (`member.updateProfile({ name })`, then the
|
|
27
|
-
* hub-session re-seal) ONLY while the account name is empty or equals the
|
|
28
|
-
* value the PREVIOUS contact derived — a name the person set by hand (on the
|
|
29
|
-
* Admin, or before this ruling) is never overwritten. The rule itself is
|
|
30
|
-
* `account-name.ts`. The account name is the stored one (`member.profile`,
|
|
31
|
-
* never the session's copy, which a spoke's cookie holds from its last
|
|
32
|
-
* re-seal), and the previous contact is `member.contact`, both read before
|
|
33
|
-
* the save; an unreadable name follows nothing, an unreadable contact counts
|
|
34
|
-
* as none, so only an empty name is then followed. A failed follow is logged
|
|
35
|
-
* and the save still answers `{ ok: true }`: the contact IS saved.
|
|
36
|
-
*
|
|
37
|
-
* Not a `*.actions.ts` file and no `*Action`-suffixed export: the write has no
|
|
38
|
-
* MCP twin by decision (8435 D12), and apps/mcp's parity test reads that
|
|
39
|
-
* suffix.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
import { member } from "@working-theory/api-client";
|
|
43
|
-
|
|
44
|
-
import { resealHubSession } from "../../../../../lib/hub-session/reseal";
|
|
45
|
-
import { forwardedCookieInit } from "../../../../../lib/server-api";
|
|
46
|
-
|
|
47
|
-
import { accountNameFollowsContact, type ContactNames, derivedAccountName } from "./account-name";
|
|
48
|
-
|
|
49
|
-
/** PII-safe error identity for logs (the `profile-actions.ts` idiom: `err.name` only). */
|
|
50
|
-
function errorName(err: unknown): string {
|
|
51
|
-
return err instanceof Error ? err.name : "unknown";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The `error.code` of a member write's refusal body, when it has one. */
|
|
55
|
-
function errorCode(body: unknown): string | null {
|
|
56
|
-
if (typeof body !== "object" || body === null) return null;
|
|
57
|
-
const error = (body as { error?: unknown }).error;
|
|
58
|
-
if (typeof error !== "object" || error === null) return null;
|
|
59
|
-
const code = (error as { code?: unknown }).code;
|
|
60
|
-
return typeof code === "string" ? code : null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type SaveContactResult =
|
|
64
|
-
| { ok: true }
|
|
65
|
-
| {
|
|
66
|
-
ok: false;
|
|
67
|
-
reason: "telephone" | "invalid" | "unverified" | "unavailable" | "failed";
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
type Init = Awaited<ReturnType<typeof forwardedCookieInit>>;
|
|
71
|
-
|
|
72
|
-
/** The person's confirmed contact before the save, or `null` when unread. */
|
|
73
|
-
async function previousContact(init: Init): Promise<ContactNames> {
|
|
74
|
-
try {
|
|
75
|
-
const res = await member.contact(init);
|
|
76
|
-
return res.ok ? res.body.contact : null;
|
|
77
|
-
} catch {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** The stored account name (`""` when none), or `undefined` when it cannot be read. */
|
|
83
|
-
async function currentAccountName(init: Init): Promise<string | undefined> {
|
|
84
|
-
try {
|
|
85
|
-
const res = await member.profile(init);
|
|
86
|
-
return res.ok ? (res.body.name ?? "") : undefined;
|
|
87
|
-
} catch {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Writes the derived name as the account name when the rule allows; never throws. */
|
|
93
|
-
async function followContactName(
|
|
94
|
-
current: string | undefined,
|
|
95
|
-
previous: ContactNames,
|
|
96
|
-
next: ContactNames,
|
|
97
|
-
init: Init,
|
|
98
|
-
): Promise<void> {
|
|
99
|
-
const derived = derivedAccountName(next);
|
|
100
|
-
if (derived === "" || current === undefined) return;
|
|
101
|
-
if (!accountNameFollowsContact(current, previous) || current.trim() === derived) return;
|
|
102
|
-
try {
|
|
103
|
-
const res = await member.updateProfile({ name: derived }, init);
|
|
104
|
-
if (!res.ok) {
|
|
105
|
-
console.error(`[contact-actions] followContactName status=${res.status}`);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if ((await resealHubSession()) === "failed") {
|
|
109
|
-
console.error("[contact-actions] followContactName reseal=failed");
|
|
110
|
-
}
|
|
111
|
-
} catch (err) {
|
|
112
|
-
console.error(`[contact-actions] followContactName errName=${errorName(err)}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export async function saveContact(
|
|
117
|
-
input: Parameters<typeof member.updateContact>[0],
|
|
118
|
-
): Promise<SaveContactResult> {
|
|
119
|
-
// Action input is untrusted: a hand-built call may send anything, and the
|
|
120
|
-
// API's own schema is the validator — a non-object is refused before any call.
|
|
121
|
-
if (typeof input !== "object" || input === null)
|
|
122
|
-
return { ok: false, reason: "invalid" };
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
const init = await forwardedCookieInit();
|
|
126
|
-
const [previous, current] = await Promise.all([previousContact(init), currentAccountName(init)]);
|
|
127
|
-
const res = await member.updateContact(input, init);
|
|
128
|
-
if (res.ok) {
|
|
129
|
-
await followContactName(current, previous, res.body.contact, init);
|
|
130
|
-
return { ok: true };
|
|
131
|
-
}
|
|
132
|
-
console.error(`[contact-actions] saveContact status=${res.status}`);
|
|
133
|
-
if (res.status === 400) {
|
|
134
|
-
return {
|
|
135
|
-
ok: false,
|
|
136
|
-
reason:
|
|
137
|
-
errorCode(res.body) === "telephone_invalid" ? "telephone" : "invalid",
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
if (res.status === 403) return { ok: false, reason: "unverified" };
|
|
141
|
-
if (res.status === 404 || res.status === 409 || res.status === 503) {
|
|
142
|
-
return { ok: false, reason: "unavailable" };
|
|
143
|
-
}
|
|
144
|
-
return { ok: false, reason: "failed" };
|
|
145
|
-
} catch (err) {
|
|
146
|
-
console.error(`[contact-actions] saveContact errName=${errorName(err)}`);
|
|
147
|
-
return { ok: false, reason: "failed" };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use client"; // owns the router.refresh() that follows a contact save
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ContactDetails — User settings › General's contact section on the member
|
|
5
|
-
* path (#8435 D13; #11167 ruling 5): the shared `AccountContactDetails` over
|
|
6
|
-
* `saveContact`, plus one thing the server action cannot do — after a save
|
|
7
|
-
* that succeeded it refreshes the route, so the rail's name shows the
|
|
8
|
-
* "First Last" the save may have derived for the account.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
AccountContactDetails,
|
|
13
|
-
type AccountContact,
|
|
14
|
-
type AccountContactLabels,
|
|
15
|
-
type AccountContactSaveResult,
|
|
16
|
-
} from "@working-theory/templates/account";
|
|
17
|
-
import { useRouter } from "next/navigation";
|
|
18
|
-
import type { ReactElement } from "react";
|
|
19
|
-
|
|
20
|
-
import { saveContact } from "./contact-actions";
|
|
21
|
-
|
|
22
|
-
export function ContactDetails({
|
|
23
|
-
contact,
|
|
24
|
-
labels,
|
|
25
|
-
}: {
|
|
26
|
-
contact: AccountContact | null;
|
|
27
|
-
labels: AccountContactLabels;
|
|
28
|
-
}): ReactElement {
|
|
29
|
-
const router = useRouter();
|
|
30
|
-
|
|
31
|
-
async function onSave(
|
|
32
|
-
next: AccountContact,
|
|
33
|
-
): Promise<AccountContactSaveResult> {
|
|
34
|
-
const result = await saveContact(next);
|
|
35
|
-
if (result.ok) router.refresh();
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<AccountContactDetails contact={contact} labels={labels} onSave={onSave} />
|
|
41
|
-
);
|
|
42
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use client"; // calls the deletion server action on click and shows the answer in place
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* DeletionRequest — User settings › General › Privacy's "Request account
|
|
5
|
-
* deletion" (#8232, spec docs/specs/8232-member-settings-account-general-and-spec.md
|
|
6
|
-
* D5; roadmap D10, #8140 disposition 1).
|
|
7
|
-
*
|
|
8
|
-
* Moved here from `settings/deletion-request.tsx` (#7430) rather than edited
|
|
9
|
-
* in place (C3): `sync-routes` never overwrites a file a scaffold already
|
|
10
|
-
* has, so a synced General importing a changed copy would not compile.
|
|
11
|
-
*
|
|
12
|
-
* Who takes it is `via` (General's `loadProfileSource`, D3):
|
|
13
|
-
*
|
|
14
|
-
* - `member` — the member API answers: Request calls the
|
|
15
|
-
* `requestAccountDeletion` server action (`POST /v1/member/deletion-request`)
|
|
16
|
-
* with an empty body, so the API's own subject and message go to the
|
|
17
|
-
* operator. The API files it with the deployment that holds the account
|
|
18
|
-
* and answers which operator that is; the success line follows that
|
|
19
|
-
* answer, so nothing here tests the topology. An operator completes it —
|
|
20
|
-
* nothing is deleted on click.
|
|
21
|
-
* - `session` — a build with no member API: a pointer to Support, which
|
|
22
|
-
* files into this site's own operator inbox.
|
|
23
|
-
* - `none` — a hub-mode spoke whose hub answers no member route: the
|
|
24
|
-
* unavailable line alone. No Support pointer, because Support on a spoke
|
|
25
|
-
* files into the spoke's own inbox, and a request about a hub account
|
|
26
|
-
* must never land there (SEC-7894-11).
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { Button, InlineMessage, Link, Text } from "@working-theory/ui/primitives";
|
|
30
|
-
import { useState, useTransition, type ReactElement } from "react";
|
|
31
|
-
|
|
32
|
-
import { requestAccountDeletion, type AccountDeletionResult } from "../profile-actions";
|
|
33
|
-
|
|
34
|
-
export interface DeletionRequestLabels {
|
|
35
|
-
lead: string;
|
|
36
|
-
action: string;
|
|
37
|
-
sentSite: string;
|
|
38
|
-
sentHub: string;
|
|
39
|
-
unverified: string;
|
|
40
|
-
unavailable: string;
|
|
41
|
-
error: string;
|
|
42
|
-
viaSupport: string;
|
|
43
|
-
supportLink: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function DeletionRequest({
|
|
47
|
-
via,
|
|
48
|
-
supportHref,
|
|
49
|
-
labels,
|
|
50
|
-
}: {
|
|
51
|
-
via: "member" | "session" | "none";
|
|
52
|
-
/** This site's own Support page (`/account/support`, localized). */
|
|
53
|
-
supportHref: string;
|
|
54
|
-
labels: DeletionRequestLabels;
|
|
55
|
-
}): ReactElement {
|
|
56
|
-
const [result, setResult] = useState<AccountDeletionResult | null>(null);
|
|
57
|
-
const [pending, startTransition] = useTransition();
|
|
58
|
-
|
|
59
|
-
if (via === "none") {
|
|
60
|
-
return (
|
|
61
|
-
<div data-testid="account-deletion-unavailable">
|
|
62
|
-
<Text as="p" variant="body-sm" tone="muted">
|
|
63
|
-
{labels.unavailable}
|
|
64
|
-
</Text>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (via === "session") {
|
|
70
|
-
return (
|
|
71
|
-
<div className="flex flex-col items-start gap-2">
|
|
72
|
-
<Text as="p" variant="body-sm" tone="muted">
|
|
73
|
-
{labels.viaSupport}
|
|
74
|
-
</Text>
|
|
75
|
-
<Link
|
|
76
|
-
href={supportHref}
|
|
77
|
-
className="inline-flex min-h-6 items-center"
|
|
78
|
-
data-testid="account-deletion-support"
|
|
79
|
-
>
|
|
80
|
-
{labels.supportLink}
|
|
81
|
-
</Link>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (result?.ok) {
|
|
87
|
-
return (
|
|
88
|
-
<InlineMessage variant="success" role="status" className="text-body-sm">
|
|
89
|
-
{result.sentTo === "hub-operator" ? labels.sentHub : labels.sentSite}
|
|
90
|
-
</InlineMessage>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const error =
|
|
95
|
-
result === null
|
|
96
|
-
? null
|
|
97
|
-
: result.reason === "unverified"
|
|
98
|
-
? labels.unverified
|
|
99
|
-
: result.reason === "unavailable"
|
|
100
|
-
? labels.unavailable
|
|
101
|
-
: labels.error;
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div className="flex flex-col items-start gap-2">
|
|
105
|
-
<Text as="p" variant="body-sm" tone="muted">
|
|
106
|
-
{labels.lead}
|
|
107
|
-
</Text>
|
|
108
|
-
<Button
|
|
109
|
-
type="button"
|
|
110
|
-
variant="outline"
|
|
111
|
-
// #8339 D8 — the Admin's pill Save shape, now that deletion sits on
|
|
112
|
-
// the shared General composition's pane.
|
|
113
|
-
className="!h-11 md:!h-10 !rounded-full !px-5"
|
|
114
|
-
disabled={pending}
|
|
115
|
-
onClick={() => {
|
|
116
|
-
startTransition(async () => {
|
|
117
|
-
try {
|
|
118
|
-
setResult(await requestAccountDeletion());
|
|
119
|
-
} catch {
|
|
120
|
-
// A network failure throws rather than answering a reason.
|
|
121
|
-
setResult({ ok: false, reason: "failed" });
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}}
|
|
125
|
-
data-testid="account-deletion-request"
|
|
126
|
-
>
|
|
127
|
-
{labels.action}
|
|
128
|
-
</Button>
|
|
129
|
-
{error !== null ? <InlineMessage variant="error">{error}</InlineMessage> : null}
|
|
130
|
-
</div>
|
|
131
|
-
);
|
|
132
|
-
}
|