create-ailk 0.34.1 → 0.36.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 (139) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +37 -4
  3. package/component-catalog.md +11 -9
  4. package/dist/add-module.js +7 -2
  5. package/dist/derive-architecture.js +2 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/env-catalog.js +8 -0
  9. package/dist/module-architecture.js +9 -0
  10. package/dist/programmatic.js +5 -2
  11. package/dist/site-listing-path.d.ts +8 -0
  12. package/dist/site-listing-path.js +8 -0
  13. package/dist/surfaces.d.ts +20 -0
  14. package/dist/surfaces.js +32 -3
  15. package/dist/template-record.js +2 -0
  16. package/dist/topology.d.ts +4 -4
  17. package/dist/topology.js +104 -60
  18. package/dist/update.js +11 -0
  19. package/package.json +3 -3
  20. package/templates/.env.example +21 -0
  21. package/templates/apps/api/.env.example +7 -0
  22. package/templates/apps/api/CLAUDE.md +14 -9
  23. package/templates/apps/mcp/CLAUDE.md +18 -7
  24. package/templates/apps/web/.env.example +16 -0
  25. package/templates/apps/web/CLAUDE.md +46 -5
  26. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  29. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  30. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  31. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  32. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  33. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  34. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
  40. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
  41. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
  42. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
  43. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  44. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  45. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  47. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  53. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  54. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  55. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  56. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
  57. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
  58. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  59. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  60. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
  61. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
  62. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
  63. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
  64. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
  65. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
  66. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
  67. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
  68. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
  69. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
  70. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
  71. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
  72. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
  73. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
  74. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
  75. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
  76. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
  77. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
  78. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
  79. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
  80. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
  81. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
  82. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
  83. package/templates/apps/web/app/[locale]/layout.tsx +42 -76
  84. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  85. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  86. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  87. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
  88. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
  89. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  90. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  91. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  92. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  93. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  94. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  95. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  96. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
  97. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  98. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  99. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  100. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  101. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  102. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  103. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  104. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
  105. package/templates/apps/web/app/llms.txt/route.ts +14 -2
  106. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
  107. package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
  108. package/templates/apps/web/auth.ts +133 -6
  109. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  110. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  111. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  112. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  113. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  114. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  115. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  116. package/templates/apps/web/lib/account-config.ts +24 -9
  117. package/templates/apps/web/lib/auth-email.ts +62 -6
  118. package/templates/apps/web/lib/auth-env.ts +13 -0
  119. package/templates/apps/web/lib/auth-sms.ts +180 -0
  120. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  121. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  122. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  123. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  124. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  125. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  126. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  127. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  128. package/templates/apps/web/lib/site-header.ts +14 -1
  129. package/templates/apps/web/lib/site-listing.ts +7 -0
  130. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  131. package/templates/apps/web/lib/topology.generated.ts +39 -0
  132. package/templates/apps/web/messages/en.json +125 -21
  133. package/templates/apps/web/middleware.ts +34 -2
  134. package/templates/apps/web/security-headers.config.ts +21 -0
  135. package/versions.json +47 -47
  136. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  137. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  138. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  139. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -6,8 +6,8 @@
6
6
  * Composes the shipped `AuthCard` block (`intent="sign-in"`, `footer="none"`)
7
7
  * and wires its provider buttons / password form to the Better Auth client
8
8
  * via the shared `useAuthCardFlow` hook (#6018 AC-3) — the same hook
9
- * `SignUpCard` next door uses, using the SAME `createAuthClient()` idiom the
10
- * `(authed)` group's `SignInGate` uses. The page (RSC) decides providers +
9
+ * `SignUpCard` next door uses, through its one module-scope
10
+ * `createAuthClient()`. The page (RSC) decides providers +
11
11
  * method from auth-env and hands them in; this component never reads env
12
12
  * itself.
13
13
  *
@@ -43,12 +43,18 @@
43
43
  * `magicLinkClient()` plugin, so no ESM-only module enters the client graph
44
44
  * every `(auth)` and `(authed)` suite would then have to mock. The answer is
45
45
  * the same for an address with and without an account, so a success swaps to
46
- * a sent state that never names the address. The gate composes this card too
47
- * (`(authed)/sign-in-gate.tsx`).
46
+ * a sent state that never names the address.
48
47
  *
49
48
  * Hinted email (#8757 D9): the page hands in `defaultEmail` (already checked
50
49
  * by `accountEmailHintSchema`); it reaches AuthCard as the starting value of
51
50
  * every email input. Absent → AuthCard's render is unchanged.
51
+ *
52
+ * Remembered method (#11095 D7): a provider launch writes its id to the
53
+ * `ailk-sign-in-method` cookie (`remembered-method.ts`) before the launch; a
54
+ * password submit or a sign-in-link request clears it. With `remembered` set
55
+ * the card leads with that one provider ("Continue with Google", the SSO
56
+ * stack's 44px button) and "Use another way" restores the full card. Absent,
57
+ * the render is today's.
52
58
  */
53
59
 
54
60
  import {
@@ -57,11 +63,13 @@ import {
57
63
  type AuthCardLabels,
58
64
  type AuthSubmitData,
59
65
  } from "@working-theory/ui/blocks";
60
- import { Alert, AlertDescription } from "@working-theory/ui/primitives";
66
+ import { Alert, AlertDescription, Button } from "@working-theory/ui/primitives";
61
67
  import { useRef, useState, type ReactElement, type ReactNode } from "react";
62
68
 
63
69
  import { authClient, useAuthCardFlow } from "../use-auth-card-flow";
64
70
 
71
+ import { rememberMethod } from "./remembered-method";
72
+
65
73
  /** The OAuth providers this page can launch — a subset of AuthCard's. */
66
74
  export type SignInProvider = "google" | "github";
67
75
 
@@ -113,6 +121,12 @@ export interface SignInCardProps {
113
121
  prospect?: { prompt: string; linkLabel: string; href: string };
114
122
  /** The acknowledgement sentence(s) at the card's foot (#8790 D6). */
115
123
  footnote?: ReactNode;
124
+ /** #11095 D7 — the provider the person last launched, already parsed by the page. */
125
+ remembered?: SignInProvider;
126
+ /** The lead button's prefix in place of `labels.ssoPrefix` ("Continue with"). */
127
+ continueWith?: string;
128
+ /** The control under the lead card that shows every method ("Use another way"). */
129
+ useAnotherWay?: string;
116
130
  }
117
131
 
118
132
  export function SignInCard({
@@ -134,6 +148,9 @@ export function SignInCard({
134
148
  backLink,
135
149
  prospect,
136
150
  footnote,
151
+ remembered,
152
+ continueWith,
153
+ useAnotherWay,
137
154
  }: SignInCardProps): ReactElement {
138
155
  const { errors, providerError, launchProvider, submitPassword } =
139
156
  useAuthCardFlow(next, {
@@ -145,6 +162,8 @@ export function SignInCard({
145
162
  // One request at a time: a double-click would spend two of the per-IP and
146
163
  // per-address sends and mint two live tokens (code review).
147
164
  const emailLinkPending = useRef(false);
165
+ const [expanded, setExpanded] = useState(false);
166
+ const lead = remembered !== undefined && !expanded;
148
167
 
149
168
  const notConfigured =
150
169
  method === "sso" && providers.length === 0 && !emailLink;
@@ -155,12 +174,17 @@ export function SignInCard({
155
174
  ...(method === "password" ? (["password"] as const) : []),
156
175
  ];
157
176
 
177
+ const launch = (provider: SignInProvider): void => {
178
+ rememberMethod(provider);
179
+ void launchProvider(provider);
180
+ };
158
181
  const providerButtons = providers.map((provider) => ({
159
182
  provider,
160
- onClick: () => void launchProvider(provider),
183
+ onClick: () => launch(provider),
161
184
  }));
162
185
 
163
186
  const handleSubmit = (data: AuthSubmitData): void => {
187
+ rememberMethod(null);
164
188
  void submitPassword(
165
189
  authClient.signIn.email({
166
190
  email: data.email,
@@ -173,6 +197,7 @@ export function SignInCard({
173
197
  const requestEmailLink = async (email: string): Promise<void> => {
174
198
  if (emailLinkPending.current) return;
175
199
  emailLinkPending.current = true;
200
+ rememberMethod(null);
176
201
  setEmailLinkError(null);
177
202
  try {
178
203
  const { error } = await authClient.$fetch("/sign-in/magic-link", {
@@ -225,7 +250,7 @@ export function SignInCard({
225
250
  */
226
251
  <div className="flex flex-col gap-4" data-testid="sign-in-page">
227
252
  {backLink ? <AuthBackLink href={backLink.href} label={backLink.label} /> : null}
228
- {method === "sso" && providerError ? (
253
+ {(method === "sso" || lead) && providerError ? (
229
254
  <Alert variant="error" data-testid="sign-in-provider-error">
230
255
  <AlertDescription>{providerError}</AlertDescription>
231
256
  </Alert>
@@ -235,32 +260,64 @@ export function SignInCard({
235
260
  <AlertDescription>{linkNotice}</AlertDescription>
236
261
  </Alert>
237
262
  ) : null}
238
- <AuthCard
239
- intent="sign-in"
240
- method={method}
241
- footer="none"
242
- {...(logo !== undefined ? { logo } : {})}
243
- {...(forgotHref !== undefined ? { forgotHref } : {})}
244
- {...(forgot !== undefined ? { forgot } : {})}
245
- // The heading stands alone (#8790 D3): no subhead unless the card
246
- // is inert and must say why.
247
- subhead={notConfigured ? notConfiguredSubhead : ""}
248
- {...(prospect !== undefined ? { prospect } : {})}
249
- {...(footnote !== undefined ? { footnote } : {})}
250
- providers={providerButtons}
251
- onSubmit={handleSubmit}
252
- errors={
253
- emailLinkError ? { ...errors, emailLink: emailLinkError } : errors
254
- }
255
- labels={labels}
256
- {...(defaultEmail !== undefined ? { defaultEmail } : {})}
257
- {...(methods.length > 0 ? { methodSwitch: { methods } } : {})}
258
- {...(emailLink
259
- ? {
260
- onEmailLink: (email: string) => void requestEmailLink(email),
261
- }
262
- : {})}
263
- />
263
+ {lead ? (
264
+ <>
265
+ <AuthCard
266
+ intent="sign-in"
267
+ method="sso"
268
+ footer="none"
269
+ {...(logo !== undefined ? { logo } : {})}
270
+ subhead=""
271
+ {...(prospect !== undefined ? { prospect } : {})}
272
+ {...(footnote !== undefined ? { footnote } : {})}
273
+ providers={[
274
+ { provider: remembered, onClick: () => launch(remembered) },
275
+ ]}
276
+ labels={{
277
+ ...labels,
278
+ ...(continueWith !== undefined
279
+ ? { ssoPrefix: continueWith }
280
+ : {}),
281
+ }}
282
+ />
283
+ <Button
284
+ variant="ghost"
285
+ size="big"
286
+ type="button"
287
+ onClick={() => setExpanded(true)}
288
+ data-testid="sign-in-use-another-way"
289
+ >
290
+ {useAnotherWay}
291
+ </Button>
292
+ </>
293
+ ) : (
294
+ <AuthCard
295
+ intent="sign-in"
296
+ method={method}
297
+ footer="none"
298
+ {...(logo !== undefined ? { logo } : {})}
299
+ {...(forgotHref !== undefined ? { forgotHref } : {})}
300
+ {...(forgot !== undefined ? { forgot } : {})}
301
+ // The heading stands alone (#8790 D3): no subhead unless the card
302
+ // is inert and must say why.
303
+ subhead={notConfigured ? notConfiguredSubhead : ""}
304
+ {...(prospect !== undefined ? { prospect } : {})}
305
+ {...(footnote !== undefined ? { footnote } : {})}
306
+ providers={providerButtons}
307
+ onSubmit={handleSubmit}
308
+ errors={
309
+ emailLinkError ? { ...errors, emailLink: emailLinkError } : errors
310
+ }
311
+ labels={labels}
312
+ {...(defaultEmail !== undefined ? { defaultEmail } : {})}
313
+ {...(methods.length > 0 ? { methodSwitch: { methods } } : {})}
314
+ {...(emailLink
315
+ ? {
316
+ onEmailLink: (email: string) => void requestEmailLink(email),
317
+ }
318
+ : {})}
319
+ />
320
+ )}
264
321
  </div>
265
322
  );
266
323
  }
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * The `SignInCard`'s translated copy, resolved on the server (#7435 § D9).
3
3
  *
4
- * One helper so `/sign-in` and the `(authed)` gate render the SAME labels from
5
- * the same `signIn` keys — the gate composes `SignInCard` when the email
6
- * sign-in link is on, and a second copy of this object would drift.
4
+ * One helper, so every `SignInCard` renders the SAME labels from the same
5
+ * `signIn` keys — a second copy of this object would drift.
7
6
  *
8
7
  * The heading names the site — "Sign in to <site>" (#9662) — from
9
8
  * `SITE_NAME`, the deployment's own display name (env, else `_site.mdx`),
10
9
  * never from the request.
11
10
  *
12
- * Plain data only: the gate hands this object to a client component, and a
11
+ * Plain data only: the page hands this object to a client component, and a
13
12
  * function cannot cross that boundary (`/sign-in` resolves its "Back to
14
13
  * <spoke>" line itself).
15
14
  */
@@ -39,6 +38,10 @@ export interface SignInCardText {
39
38
  emailLinkLabels: SignInEmailLinkLabels;
40
39
  /** The notice for a link that failed verification (`?error=INVALID_TOKEN`). */
41
40
  emailLinkExpired: string;
41
+ /** #11095 D7 — the remembered provider's button prefix ("Continue with"). */
42
+ continueWith: string;
43
+ /** #11095 D7 — the control that shows every method ("Use another way"). */
44
+ useAnotherWay: string;
42
45
  }
43
46
 
44
47
  export async function resolveSignInCardText(
@@ -84,5 +87,7 @@ export async function resolveSignInCardText(
84
87
  rateLimited: t("emailLinkRateLimited"),
85
88
  },
86
89
  emailLinkExpired: t("emailLinkExpired"),
90
+ continueWith: t("continueWith"),
91
+ useAnotherWay: t("useAnotherWay"),
87
92
  };
88
93
  }