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
package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* account/invitations/[invitationId]/actions.ts — the invitee's two calls
|
|
5
|
-
* (#11106, spec docs/specs/11106-the-workforce-foundation-roles-by-spec.md
|
|
6
|
-
* D5): read the invitation, and accept it.
|
|
7
|
-
*
|
|
8
|
-
* GET /v1/invitations/:invitationId → `readInvitation`
|
|
9
|
-
* POST /v1/invitations/:invitationId/accept → `acceptInvitation`
|
|
10
|
-
*
|
|
11
|
-
* Both are server-side fetches carrying the person's own session
|
|
12
|
-
* (`forwardedCookieInit()`: the cookie and, on the POST, the request's
|
|
13
|
-
* `Origin` the API's CSRF check needs). The API answers only the invited,
|
|
14
|
-
* verified address — the invitation id is the only input, never an email.
|
|
15
|
-
* `@working-theory/api-client` carries no invitation namespace, so the call is
|
|
16
|
-
* a bare `fetch` to its `getApiBase()` (the `app/openapi.json/route.ts`
|
|
17
|
-
* precedent).
|
|
18
|
-
*
|
|
19
|
-
* Accepting is a form POST to `acceptInvitation`, bound to the id and locale
|
|
20
|
-
* by the page; it redirects back to the page with `?joined=1` or `?error=<code>`
|
|
21
|
-
* — a GET of the page never writes. Logs carry a status or a code only.
|
|
22
|
-
*
|
|
23
|
-
* Not a `*.actions.ts` file and no `*Action`-suffixed export: accepting is a
|
|
24
|
-
* person's own act with no MCP twin (apps/mcp's parity test reads that
|
|
25
|
-
* suffix).
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import { getApiBase } from "@working-theory/api-client";
|
|
29
|
-
import { localeHref } from "@working-theory/ui";
|
|
30
|
-
import { invitationDetailSchema, type InvitationDetail } from "@working-theory/validation";
|
|
31
|
-
import { redirect } from "next/navigation";
|
|
32
|
-
|
|
33
|
-
import { forwardedCookieInit } from "../../../../../../lib/server-api";
|
|
34
|
-
|
|
35
|
-
import { isInvitationId } from "./invitation-id";
|
|
36
|
-
|
|
37
|
-
/** Bounds the call so a hung apps/api cannot pin a render. */
|
|
38
|
-
const CALL_TIMEOUT_MS = 10_000;
|
|
39
|
-
|
|
40
|
-
export type InvitationRead =
|
|
41
|
-
| { kind: "ok"; invitation: InvitationDetail }
|
|
42
|
-
| { kind: "not_found" }
|
|
43
|
-
| { kind: "other_address" }
|
|
44
|
-
| { kind: "failed" };
|
|
45
|
-
|
|
46
|
-
function errorCode(body: unknown): string | null {
|
|
47
|
-
const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
|
|
48
|
-
return typeof code === "string" ? code : null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function call(
|
|
52
|
-
method: "GET" | "POST",
|
|
53
|
-
path: string,
|
|
54
|
-
): Promise<{ status: number; body: unknown }> {
|
|
55
|
-
const { headers } = await forwardedCookieInit();
|
|
56
|
-
const res = await fetch(`${getApiBase()}${path}`, {
|
|
57
|
-
method,
|
|
58
|
-
headers: { ...headers, ...(method === "POST" ? { "content-type": "application/json" } : {}) },
|
|
59
|
-
...(method === "POST" ? { body: "{}" } : {}),
|
|
60
|
-
cache: "no-store",
|
|
61
|
-
signal: AbortSignal.timeout(CALL_TIMEOUT_MS),
|
|
62
|
-
});
|
|
63
|
-
const body: unknown = await res.json().catch(() => null);
|
|
64
|
-
return { status: res.status, body };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** The invitation, for the signed-in person the API matches to it. */
|
|
68
|
-
export async function readInvitation(invitationId: string): Promise<InvitationRead> {
|
|
69
|
-
if (!isInvitationId(invitationId)) return { kind: "not_found" };
|
|
70
|
-
try {
|
|
71
|
-
const { status, body } = await call("GET", `/v1/invitations/${invitationId}`);
|
|
72
|
-
if (status === 404) return { kind: "not_found" };
|
|
73
|
-
if (status === 403 && errorCode(body) === "invitation_for_another_address") {
|
|
74
|
-
return { kind: "other_address" };
|
|
75
|
-
}
|
|
76
|
-
const data = (body as { ok?: unknown; data?: unknown } | null)?.data;
|
|
77
|
-
const parsed = invitationDetailSchema.safeParse(data);
|
|
78
|
-
if (status === 200 && parsed.success) return { kind: "ok", invitation: parsed.data };
|
|
79
|
-
console.error(`[account-invitation] read status=${status}`);
|
|
80
|
-
return { kind: "failed" };
|
|
81
|
-
} catch (err) {
|
|
82
|
-
console.error(
|
|
83
|
-
`[account-invitation] read errName=${err instanceof Error ? err.name : "unknown"}`,
|
|
84
|
-
);
|
|
85
|
-
return { kind: "failed" };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** The refusal codes the page has a line for; anything else is `failed`. */
|
|
90
|
-
const KNOWN_REFUSALS = new Set([
|
|
91
|
-
"invitation_for_another_address",
|
|
92
|
-
"invitation_not_pending",
|
|
93
|
-
"invitation_expired",
|
|
94
|
-
"invitation_void",
|
|
95
|
-
"already_member",
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
/** Accept — a form POST, bound to the invitation id and locale by the page. */
|
|
99
|
-
export async function acceptInvitation(invitationId: string, locale: string): Promise<void> {
|
|
100
|
-
const page = localeHref(locale, `/account/invitations/${invitationId}`);
|
|
101
|
-
if (!isInvitationId(invitationId)) redirect(`${page}?error=failed`);
|
|
102
|
-
let outcome: string;
|
|
103
|
-
try {
|
|
104
|
-
const { status, body } = await call("POST", `/v1/invitations/${invitationId}/accept`);
|
|
105
|
-
const code = errorCode(body);
|
|
106
|
-
outcome =
|
|
107
|
-
status === 200 ? "joined" : code !== null && KNOWN_REFUSALS.has(code) ? code : "failed";
|
|
108
|
-
if (outcome === "failed") console.error(`[account-invitation] accept status=${status}`);
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.error(
|
|
111
|
-
`[account-invitation] accept errName=${err instanceof Error ? err.name : "unknown"}`,
|
|
112
|
-
);
|
|
113
|
-
outcome = "failed";
|
|
114
|
-
}
|
|
115
|
-
redirect(outcome === "joined" ? `${page}?joined=1` : `${page}?error=${outcome}`);
|
|
116
|
-
}
|
package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The invitation id check the page and `actions.ts` run before any call
|
|
3
|
-
* (#11141). Not in `actions.ts`: Next.js makes every runtime export of a
|
|
4
|
-
* "use server" file a Server Action and fails the build on a synchronous one.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** `invite_` + a uuid — the table's id format, checked before any call. */
|
|
8
|
-
const INVITATION_ID = /^invite_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
9
|
-
|
|
10
|
-
export function isInvitationId(value: string): boolean {
|
|
11
|
-
return INVITATION_ID.test(value);
|
|
12
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* account/new-actions.ts — the New menu's reads and writes (#8233, spec
|
|
5
|
-
* docs/specs/8233-member-new-menu-the-new-spec.md D5, D6; the writes are
|
|
6
|
-
* #8170's).
|
|
7
|
-
*
|
|
8
|
-
* A popup reads its data when it opens (D5) and posts through a write here:
|
|
9
|
-
*
|
|
10
|
-
* - `readMeetingTypes` — `member.meetingTypes`, the types the provider
|
|
11
|
-
* offers its clients.
|
|
12
|
-
* - `readSlots` — `member.availability` for one type, from now to
|
|
13
|
-
* `SLOT_WINDOW_DAYS` later. The range is computed here; the browser
|
|
14
|
-
* sends only the slug and its time zone.
|
|
15
|
-
* - `readRequestForm` — `member.requestForm`, the request-quote magnet's
|
|
16
|
-
* current steps, or `form: null` while Request quote is switched off.
|
|
17
|
-
* - `sendMessage` · `requestQuote` · `bookService` — `member.sendMessage`,
|
|
18
|
-
* `member.requestQuote` and `member.book`.
|
|
19
|
-
*
|
|
20
|
-
* Every call sends `forwardedCookieInit()`'s init as built: on a single site
|
|
21
|
-
* the session cookie plus the request's `Origin` (`apps/api`'s cookie CSRF
|
|
22
|
-
* check), on a hub-mode spoke the hub credential — so nothing here tests the
|
|
23
|
-
* topology, and no identity is posted: the server takes the name and the
|
|
24
|
-
* verified email from the credential (8170 D7).
|
|
25
|
-
*
|
|
26
|
-
* A value is sent exactly as typed — never trimmed, never given a scheme: the
|
|
27
|
-
* server's `plainText` and `isHttpsLink` are the one rule. An optional value
|
|
28
|
-
* left empty or all-space is omitted, because the server refuses `""`. A
|
|
29
|
-
* refusal maps to its `error.code` when a popup has words for it, else to
|
|
30
|
-
* `failed`.
|
|
31
|
-
*
|
|
32
|
-
* Not a `*.actions.ts` file and no `*Action`-suffixed export: apps/mcp's
|
|
33
|
-
* parity test reads that suffix, and these member writes have no MCP twin by
|
|
34
|
-
* decision (8170's header). Logs carry the function, the status and the code
|
|
35
|
-
* only — never a typed value or a credential.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
import { member } from "@working-theory/api-client";
|
|
39
|
-
import type {
|
|
40
|
-
MemberMeetingType,
|
|
41
|
-
MemberRequestFormResponse,
|
|
42
|
-
SchedulingSlot,
|
|
43
|
-
} from "@working-theory/validation";
|
|
44
|
-
|
|
45
|
-
import { forwardedCookieInit } from "../../../../lib/server-api";
|
|
46
|
-
|
|
47
|
-
/** How far ahead Schedule service offers times (the read's own cap is 60 days). */
|
|
48
|
-
const SLOT_WINDOW_DAYS = 14;
|
|
49
|
-
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
50
|
-
|
|
51
|
-
/** The refusal codes a popup has its own words for; anything else is `failed`. */
|
|
52
|
-
const KNOWN_CODES = [
|
|
53
|
-
"link_not_https",
|
|
54
|
-
"answers_invalid",
|
|
55
|
-
"request_form_off",
|
|
56
|
-
"meeting_type_not_offered",
|
|
57
|
-
"slot_unavailable",
|
|
58
|
-
"too_many_requests",
|
|
59
|
-
"invalid_input",
|
|
60
|
-
] as const;
|
|
61
|
-
|
|
62
|
-
export type NewActionErrorCode = (typeof KNOWN_CODES)[number] | "failed";
|
|
63
|
-
|
|
64
|
-
/** What a popup's form shows after a submit. */
|
|
65
|
-
export type NewActionState =
|
|
66
|
-
| { kind: "idle" }
|
|
67
|
-
| { kind: "success" }
|
|
68
|
-
| { kind: "error"; code: NewActionErrorCode };
|
|
69
|
-
|
|
70
|
-
export type NewReadResult<T> = ({ kind: "ok" } & T) | { kind: "error" };
|
|
71
|
-
|
|
72
|
-
/** Structural mirror of `@working-theory/api-client`'s `ApiResult<T>` (not re-exported). */
|
|
73
|
-
type ApiResult<T> = { ok: true; body: T } | { ok: false; status: number; body: unknown };
|
|
74
|
-
|
|
75
|
-
/** PII-safe error identity for logs (the `checkout.actions.ts` idiom: `err.name` only). */
|
|
76
|
-
function errorName(err: unknown): string {
|
|
77
|
-
return err instanceof Error ? err.name : "unknown";
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** The `error.code` of a member refusal body, when it has one. */
|
|
81
|
-
function errorCode(body: unknown): string | null {
|
|
82
|
-
if (typeof body !== "object" || body === null) return null;
|
|
83
|
-
const error = (body as { error?: unknown }).error;
|
|
84
|
-
if (typeof error !== "object" || error === null) return null;
|
|
85
|
-
const code = (error as { code?: unknown }).code;
|
|
86
|
-
return typeof code === "string" ? code : null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function knownCode(code: string | null): NewActionErrorCode {
|
|
90
|
-
return KNOWN_CODES.find((known) => known === code) ?? "failed";
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** A posted value as typed; `undefined` when it is absent or not a string. */
|
|
94
|
-
function value(formData: FormData, name: string): string | undefined {
|
|
95
|
-
const entry = formData.get(name);
|
|
96
|
-
return typeof entry === "string" ? entry : undefined;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** An optional posted value as typed, or `undefined` when it is empty or all-space. */
|
|
100
|
-
function optional(formData: FormData, name: string): string | undefined {
|
|
101
|
-
const entry = value(formData, name);
|
|
102
|
-
return entry !== undefined && entry.trim() !== "" ? entry : undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function runRead<T, R>(
|
|
106
|
-
name: string,
|
|
107
|
-
call: (init: { headers: Record<string, string> }) => Promise<ApiResult<T>>,
|
|
108
|
-
shape: (body: T) => R,
|
|
109
|
-
): Promise<NewReadResult<R>> {
|
|
110
|
-
try {
|
|
111
|
-
const res = await call(await forwardedCookieInit());
|
|
112
|
-
if (res.ok) return { kind: "ok", ...shape(res.body) };
|
|
113
|
-
console.error(`[new-actions] ${name} status=${res.status} code=${errorCode(res.body) ?? "none"}`);
|
|
114
|
-
} catch (err) {
|
|
115
|
-
console.error(`[new-actions] ${name} errName=${errorName(err)}`);
|
|
116
|
-
}
|
|
117
|
-
return { kind: "error" };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** Action input is untrusted: a hand-built call may post anything but FormData. */
|
|
121
|
-
function isFormData(input: unknown): input is FormData {
|
|
122
|
-
return input instanceof FormData;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function runWrite(
|
|
126
|
-
name: string,
|
|
127
|
-
call: (init: { headers: Record<string, string> }) => Promise<ApiResult<unknown>>,
|
|
128
|
-
): Promise<NewActionState> {
|
|
129
|
-
try {
|
|
130
|
-
const res = await call(await forwardedCookieInit());
|
|
131
|
-
if (res.ok) return { kind: "success" };
|
|
132
|
-
const code = knownCode(errorCode(res.body));
|
|
133
|
-
console.error(`[new-actions] ${name} status=${res.status} code=${code}`);
|
|
134
|
-
return { kind: "error", code };
|
|
135
|
-
} catch (err) {
|
|
136
|
-
console.error(`[new-actions] ${name} errName=${errorName(err)}`);
|
|
137
|
-
return { kind: "error", code: "failed" };
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ── Reads (D5) ───────────────────────────────────────────────────────────────
|
|
142
|
-
|
|
143
|
-
export async function readMeetingTypes(): Promise<NewReadResult<{ items: MemberMeetingType[] }>> {
|
|
144
|
-
return runRead("readMeetingTypes", (init) => member.meetingTypes(init), ({ items }) => ({ items }));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export async function readSlots(input: {
|
|
148
|
-
slug: string;
|
|
149
|
-
timeZone?: string;
|
|
150
|
-
}): Promise<NewReadResult<{ slots: SchedulingSlot[] }>> {
|
|
151
|
-
// Action input is untrusted: a hand-built call may send anything.
|
|
152
|
-
const { slug, timeZone } = (typeof input === "object" && input !== null ? input : {}) as {
|
|
153
|
-
slug?: unknown;
|
|
154
|
-
timeZone?: unknown;
|
|
155
|
-
};
|
|
156
|
-
if (typeof slug !== "string") return { kind: "error" };
|
|
157
|
-
const from = new Date();
|
|
158
|
-
const to = new Date(from.getTime() + SLOT_WINDOW_DAYS * DAY_MS);
|
|
159
|
-
const query = {
|
|
160
|
-
slug,
|
|
161
|
-
from: from.toISOString(),
|
|
162
|
-
to: to.toISOString(),
|
|
163
|
-
...(typeof timeZone === "string" && timeZone !== "" ? { timeZone } : {}),
|
|
164
|
-
};
|
|
165
|
-
return runRead("readSlots", (init) => member.availability(query, init), ({ slots }) => ({ slots }));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export async function readRequestForm(): Promise<
|
|
169
|
-
NewReadResult<{ form: MemberRequestFormResponse["form"] }>
|
|
170
|
-
> {
|
|
171
|
-
return runRead("readRequestForm", (init) => member.requestForm(init), ({ form }) => ({ form }));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// ── Writes (D6) — `(prev, formData)` for `useActionState` ───────────────────
|
|
175
|
-
|
|
176
|
-
export async function sendMessage(
|
|
177
|
-
_prev: NewActionState,
|
|
178
|
-
formData: FormData,
|
|
179
|
-
): Promise<NewActionState> {
|
|
180
|
-
if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
|
|
181
|
-
const link = optional(formData, "link");
|
|
182
|
-
const body = {
|
|
183
|
-
subject: value(formData, "subject") ?? "",
|
|
184
|
-
body: value(formData, "body") ?? "",
|
|
185
|
-
...(link === undefined ? {} : { link }),
|
|
186
|
-
};
|
|
187
|
-
return runWrite("sendMessage", (init) => member.sendMessage(body, init));
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** The answers are the entries named `answer.<field name>`; a blank one is omitted. */
|
|
191
|
-
export async function requestQuote(
|
|
192
|
-
_prev: NewActionState,
|
|
193
|
-
formData: FormData,
|
|
194
|
-
): Promise<NewActionState> {
|
|
195
|
-
if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
|
|
196
|
-
const answers: Record<string, string> = {};
|
|
197
|
-
for (const key of new Set(formData.keys())) {
|
|
198
|
-
if (!key.startsWith("answer.")) continue;
|
|
199
|
-
const answer = optional(formData, key);
|
|
200
|
-
if (answer !== undefined) answers[key.slice("answer.".length)] = answer;
|
|
201
|
-
}
|
|
202
|
-
return runWrite("requestQuote", (init) => member.requestQuote({ answers }, init));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export async function bookService(
|
|
206
|
-
_prev: NewActionState,
|
|
207
|
-
formData: FormData,
|
|
208
|
-
): Promise<NewActionState> {
|
|
209
|
-
if (!isFormData(formData)) return { kind: "error", code: "invalid_input" };
|
|
210
|
-
const timeZone = optional(formData, "timeZone");
|
|
211
|
-
const notes = optional(formData, "notes");
|
|
212
|
-
const body = {
|
|
213
|
-
slug: value(formData, "slug") ?? "",
|
|
214
|
-
start: value(formData, "start") ?? "",
|
|
215
|
-
...(timeZone === undefined ? {} : { timeZone }),
|
|
216
|
-
...(notes === undefined ? {} : { notes }),
|
|
217
|
-
};
|
|
218
|
-
return runWrite("bookService", (init) => member.book(body, init));
|
|
219
|
-
}
|