create-ailk 0.32.0 → 0.34.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.
Files changed (53) hide show
  1. package/README.md +21 -3
  2. package/component-catalog.json +12 -1
  3. package/component-catalog.md +6 -5
  4. package/dist/export-content.d.ts +6 -3
  5. package/dist/export-content.js +82 -11
  6. package/dist/lib/env-catalog.js +4 -0
  7. package/dist/lib/import-mdx.d.ts +111 -0
  8. package/dist/lib/import-mdx.js +648 -46
  9. package/dist/migrate-content.d.ts +3 -1
  10. package/dist/migrate-content.js +52 -1
  11. package/dist/seed-flows.d.ts +1 -1
  12. package/dist/seed-flows.js +9 -4
  13. package/dist/surfaces.js +1 -0
  14. package/package.json +3 -3
  15. package/templates/apps/api/.env.example +11 -0
  16. package/templates/apps/api/CLAUDE.md +7 -5
  17. package/templates/apps/api/src/lib/__mocks__/prisma.ts +13 -0
  18. package/templates/apps/mcp/CLAUDE.md +4 -2
  19. package/templates/apps/web/CLAUDE.md +4 -1
  20. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +28 -0
  21. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +94 -0
  22. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +77 -0
  23. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +79 -14
  24. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +7 -0
  25. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +7 -0
  26. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +7 -0
  27. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +21 -0
  28. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +15 -9
  29. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +38 -105
  30. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +72 -58
  31. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +249 -0
  32. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +164 -20
  33. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +269 -0
  34. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +179 -0
  35. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +108 -40
  36. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +153 -0
  37. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +151 -0
  38. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +1 -1
  39. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +3 -20
  40. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +2 -9
  41. package/templates/apps/web/auth.ts +22 -6
  42. package/templates/apps/web/lib/__tests__/account-config.test.ts +69 -0
  43. package/templates/apps/web/lib/__tests__/auth-email.test.ts +99 -1
  44. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +20 -0
  45. package/templates/apps/web/lib/account-config.ts +52 -14
  46. package/templates/apps/web/lib/auth-email.ts +87 -5
  47. package/templates/apps/web/lib/mcp-oauth.ts +49 -6
  48. package/templates/apps/web/lib/telemetry-scrub.ts +6 -0
  49. package/templates/apps/web/messages/en.json +26 -1
  50. package/templates/database/seed.ts +7 -7
  51. package/versions.json +48 -48
  52. package/templates/apps/web/app/[locale]/thanks/[slug]/AccountInviteLink.tsx +0 -89
  53. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/AccountInviteLink.test.tsx +0 -104
@@ -1,89 +0,0 @@
1
- "use client"; // Reads sessionStorage (a browser API) once on mount — a server page cannot.
2
-
3
- /**
4
- * AccountInviteLink — the /thanks page's "Track this in your account" link
5
- * (#8771 D6). The magnet walk writes one `sessionStorage` item,
6
- * `ailk:account-invite`, before it navigates here; this shows the link only
7
- * for the thank-you page that walk was headed to, and only if the stored href
8
- * is a same-site sign-in path. It reads the item once and removes it, so the
9
- * email in the href does not stay in the tab. A refresh shows no link (the
10
- * invite email still carries it).
11
- *
12
- * Base tree: it imports nothing from `flows/**`, so a build without the walk
13
- * still compiles this page.
14
- */
15
- import { Button, Container, Link } from "@working-theory/ui";
16
- import type { ReactElement } from "react";
17
- import { useEffect, useState } from "react";
18
-
19
- /** Must equal `ACCOUNT_INVITE_STORAGE_KEY` in the walk's `FlowStepperClient`. */
20
- const STORAGE_KEY = "ailk:account-invite";
21
- /** A reserved name that never resolves: only used to test an href stays on-site. */
22
- const PLACEHOLDER_ORIGIN = "https://placeholder.invalid";
23
- const HUB_SIGN_IN_PATH = "/api/hub-session/sign-in";
24
-
25
- interface Props {
26
- /** The route's `[slug]` — the hand-off must have been written for this page. */
27
- thanksSlug: string;
28
- /** `contact.trackInAccount`, read on the server. */
29
- label: string;
30
- }
31
-
32
- /** The stored href when it is a same-site sign-in path, else `null`. */
33
- function safeSignInHref(raw: unknown, thanks: unknown, thanksSlug: string): string | null {
34
- if (typeof raw !== "string" || thanks !== thanksSlug) return null;
35
- let url: URL;
36
- try {
37
- url = new URL(raw, PLACEHOLDER_ORIGIN);
38
- } catch {
39
- return null;
40
- }
41
- if (url.origin !== PLACEHOLDER_ORIGIN) return null;
42
- if (url.pathname !== HUB_SIGN_IN_PATH && !url.pathname.endsWith("/sign-in")) {
43
- return null;
44
- }
45
- return raw;
46
- }
47
-
48
- /** Read the hand-off once, remove it, and answer the link to show (or `null`). */
49
- function takeHandOff(thanksSlug: string): string | null {
50
- try {
51
- const stored = window.sessionStorage.getItem(STORAGE_KEY);
52
- if (stored === null) return null;
53
- window.sessionStorage.removeItem(STORAGE_KEY);
54
- const parsed: unknown = JSON.parse(stored);
55
- if (typeof parsed !== "object" || parsed === null) return null;
56
- const { thanks, href } = parsed as { thanks?: unknown; href?: unknown };
57
- return safeSignInHref(href, thanks, thanksSlug);
58
- } catch {
59
- return null;
60
- }
61
- }
62
-
63
- export function AccountInviteLink({ thanksSlug, label }: Props): ReactElement | null {
64
- const [href, setHref] = useState<string | null>(null);
65
-
66
- useEffect(() => {
67
- // Only ever sets the link: React's development double-mount runs this
68
- // twice, and the second run finds the item already removed.
69
- const found = takeHandOff(thanksSlug);
70
- if (found !== null) setHref(found);
71
- }, [thanksSlug]);
72
-
73
- if (href === null) return null;
74
- return (
75
- // Session Replay records the DOM, so the link (it carries the email) is
76
- // blocked from it; `Link` does not forward an undeclared data-* attribute.
77
- // The page shell sets no gutters, so the link sits in its own Container,
78
- // lined up with the thank-you content above it.
79
- <Container className="pb-section">
80
- <div data-sentry-block>
81
- <Button asChild variant="outline" className="min-h-11">
82
- <Link href={href} variant="bare" data-testid="thanks-account-invite">
83
- {label}
84
- </Link>
85
- </Button>
86
- </div>
87
- </Container>
88
- );
89
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * #8771 AC-5 — /thanks shows only its own hand-off: the walk's sessionStorage
3
- * item, for this page's slug, when its href is a same-site sign-in path.
4
- */
5
- import { existsSync, readFileSync } from "node:fs";
6
- import { join } from "node:path";
7
-
8
- import { render, screen } from "@testing-library/react";
9
- import React, { StrictMode } from "react";
10
-
11
- import { AccountInviteLink } from "../AccountInviteLink";
12
-
13
- const KEY = "ailk:account-invite";
14
- const LABEL = "Track this in your account";
15
- const SITE_HREF = "/sign-in?next=%2Faccount&email=jane%40example.com";
16
- const HUB_HREF = "/api/hub-session/sign-in?next=%2Faccount&email=x%40y.example";
17
- const WALK = join(__dirname, "..", "..", "..", "flows", "[slug]", "FlowStepperClient.tsx");
18
- // A Free scaffold ships no magnet walk, and the scaffold matrix runs this suite
19
- // inside one (#8799), so the key check skips where the walk does not exist.
20
- const itWithWalk = existsSync(WALK) ? it : it.skip;
21
-
22
- function store(value: unknown): void {
23
- window.sessionStorage.setItem(KEY, typeof value === "string" ? value : JSON.stringify(value));
24
- }
25
-
26
- function show(slug = "flow-thanks") {
27
- return render(<AccountInviteLink thanksSlug={slug} label={LABEL} />);
28
- }
29
-
30
- beforeEach(() => window.sessionStorage.clear());
31
-
32
- describe("AccountInviteLink", () => {
33
- it("renders the stored link for its own slug, blocked from Replay, and removes the item", () => {
34
- store({ thanks: "flow-thanks", href: SITE_HREF });
35
-
36
- show();
37
-
38
- const link = screen.getByTestId("thanks-account-invite");
39
- expect(link).toHaveAttribute("href", SITE_HREF);
40
- expect(link).toHaveTextContent(LABEL);
41
- expect(link.closest("[data-sentry-block]")).not.toBeNull();
42
- expect(window.sessionStorage.getItem(KEY)).toBeNull();
43
- });
44
-
45
- it("renders a hub spoke's sign-in path under the matching slug", () => {
46
- store({ thanks: "flow-thanks", href: HUB_HREF });
47
- show();
48
- expect(screen.getByTestId("thanks-account-invite")).toHaveAttribute("href", HUB_HREF);
49
- });
50
-
51
- it("renders a locale-prefixed site sign-in path", () => {
52
- store({ thanks: "flow-thanks", href: "/fr/sign-in?email=a%40b.example" });
53
- show();
54
- expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
55
- });
56
-
57
- it.each([
58
- ["another slug", { thanks: "other", href: SITE_HREF }, "flow-thanks"],
59
- ["an off-site href", { thanks: "flow-thanks", href: "https://evil.example/sign-in" }, "flow-thanks"],
60
- ["a protocol-relative href", { thanks: "flow-thanks", href: "//evil.example/sign-in" }, "flow-thanks"],
61
- ["a non-sign-in path", { thanks: "flow-thanks", href: "/account" }, "flow-thanks"],
62
- ["a hub href under another thanks", { thanks: "flow-thanks-qualified", href: HUB_HREF }, "flow-thanks"],
63
- ["a value that is not JSON", "not json", "flow-thanks"],
64
- ["a JSON null", "null", "flow-thanks"],
65
- ])("renders nothing for %s", (_name, value, slug) => {
66
- store(value);
67
- show(slug);
68
- expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
69
- });
70
-
71
- it("renders nothing when sessionStorage throws", () => {
72
- const spy = jest.spyOn(Storage.prototype, "getItem").mockImplementation(() => {
73
- throw new Error("denied");
74
- });
75
- show();
76
- expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
77
- spy.mockRestore();
78
- });
79
-
80
- it("shows the link once: a fresh mount after it (a refresh) renders nothing", () => {
81
- store({ thanks: "flow-thanks", href: SITE_HREF });
82
- const first = show();
83
- expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
84
- first.unmount();
85
-
86
- show();
87
- expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
88
- });
89
-
90
- it("keeps the link under React.StrictMode's double effect", () => {
91
- store({ thanks: "flow-thanks", href: SITE_HREF });
92
- render(
93
- <StrictMode>
94
- <AccountInviteLink thanksSlug="flow-thanks" label={LABEL} />
95
- </StrictMode>,
96
- );
97
- expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
98
- });
99
-
100
- itWithWalk("reads the same storage key the walk writes (the two constants are tied only by this test)", () => {
101
- const walk = readFileSync(WALK, "utf8");
102
- expect(walk).toContain(`ACCOUNT_INVITE_STORAGE_KEY = "${KEY}"`);
103
- });
104
- });