create-ailk 0.35.1 → 0.37.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 (169) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +51 -1
  3. package/component-catalog.md +8 -5
  4. package/dist/lib/env-catalog.js +8 -0
  5. package/dist/surfaces.js +66 -22
  6. package/dist/topology.d.ts +4 -4
  7. package/dist/topology.js +104 -60
  8. package/dist/update.d.ts +19 -1
  9. package/dist/update.js +293 -35
  10. package/package.json +3 -3
  11. package/templates/.env.example +38 -0
  12. package/templates/apps/api/.env.example +45 -0
  13. package/templates/apps/api/CLAUDE.md +12 -4
  14. package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
  15. package/templates/apps/mcp/CLAUDE.md +4 -2
  16. package/templates/apps/web/.env.example +16 -0
  17. package/templates/apps/web/CLAUDE.md +73 -5
  18. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  19. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
  20. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
  21. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
  22. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  23. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  24. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  25. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  26. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  29. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  30. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +241 -66
  31. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
  32. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
  33. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
  34. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
  40. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
  41. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
  42. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
  43. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
  44. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
  45. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
  46. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
  47. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
  51. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
  53. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
  54. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
  55. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
  56. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
  57. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
  58. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
  59. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
  60. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
  61. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
  62. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
  63. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  64. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  65. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  66. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  67. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
  68. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
  69. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
  70. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
  71. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  72. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +215 -0
  73. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
  74. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
  75. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
  76. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
  77. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
  78. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
  79. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
  80. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
  81. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  82. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  83. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  84. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  85. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  86. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +9 -6
  87. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
  88. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
  89. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
  90. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
  91. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
  92. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
  93. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
  94. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
  95. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
  96. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
  97. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
  98. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
  99. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  100. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
  101. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  102. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  103. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
  104. package/templates/apps/web/app/[locale]/layout.tsx +24 -75
  105. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  106. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  107. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  108. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +166 -7
  109. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
  110. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  111. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  112. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  113. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
  114. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
  115. package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
  116. package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
  117. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  118. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  119. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  120. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  121. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +738 -7
  122. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  123. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  124. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  125. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  126. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  127. package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
  128. package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
  129. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  130. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  131. package/templates/apps/web/auth.ts +133 -6
  132. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  133. package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
  134. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  135. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  136. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  137. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  138. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
  139. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  140. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  141. package/templates/apps/web/lib/account-config.ts +132 -8
  142. package/templates/apps/web/lib/auth-email.ts +62 -6
  143. package/templates/apps/web/lib/auth-env.ts +13 -0
  144. package/templates/apps/web/lib/auth-routes.ts +11 -6
  145. package/templates/apps/web/lib/auth-sms.ts +180 -0
  146. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  147. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  148. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  149. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  150. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  151. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  152. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  153. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  154. package/templates/apps/web/lib/offerings-pricing.ts +4 -1
  155. package/templates/apps/web/lib/site-header.ts +14 -1
  156. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  157. package/templates/apps/web/lib/topology.generated.ts +39 -0
  158. package/templates/apps/web/messages/en.json +264 -96
  159. package/templates/apps/web/middleware.ts +34 -2
  160. package/templates/apps/web/security-headers.config.ts +21 -0
  161. package/versions.json +48 -48
  162. package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
  163. package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
  164. package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
  165. package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
  166. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  167. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  168. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  169. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -142,6 +142,27 @@ export const SCHEDULING_CSP: CspDirectiveMap = Object.freeze({
142
142
  export const SCHEDULING_SECURITY_HEADERS: Readonly<Record<string, string>> =
143
143
  Object.freeze(buildHeaders({ csp: SCHEDULING_CSP }));
144
144
 
145
+ /**
146
+ * Google One Tap's CSP additions (#11096 D10, SEC-11096-10). A spoke that
147
+ * signs in through its hub and sets `AILK_HUB_ONE_TAP=on` loads Google's
148
+ * Identity Services script on its signed-out account page, which fetches,
149
+ * styles and frames from Google. Only such a spoke names Google:
150
+ * `middleware.ts` applies this map while the setting is on, as it applies
151
+ * `SCHEDULING_CSP` on booking paths. `'self'` in `frame-src` keeps
152
+ * same-origin frames working, which `default-src 'self'` allowed until the
153
+ * directive existed.
154
+ */
155
+ export const ONE_TAP_CSP: CspDirectiveMap = Object.freeze({
156
+ "script-src": Object.freeze(["https://accounts.google.com/gsi/client"]),
157
+ "connect-src": Object.freeze(["https://accounts.google.com/gsi/"]),
158
+ "style-src": Object.freeze(["https://accounts.google.com/gsi/"]),
159
+ "frame-src": Object.freeze(["'self'", "https://accounts.google.com"]),
160
+ });
161
+
162
+ /** The header map for a One Tap spoke's pages: the default plus `ONE_TAP_CSP`. */
163
+ export const ONE_TAP_SECURITY_HEADERS: Readonly<Record<string, string>> =
164
+ Object.freeze(buildHeaders({ csp: ONE_TAP_CSP }));
165
+
145
166
  /** Write every entry from a header map onto a Headers object. */
146
167
  export function applyHeaders(
147
168
  target: Headers,
package/versions.json CHANGED
@@ -1,66 +1,66 @@
1
1
  {
2
- "@working-theory/admin-ui": "0.59.0",
3
- "@working-theory/aeo": "0.59.0",
4
- "@working-theory/agent-context": "0.59.0",
2
+ "@working-theory/admin-ui": "0.61.0",
3
+ "@working-theory/aeo": "0.61.0",
4
+ "@working-theory/agent-context": "0.61.0",
5
5
  "@working-theory/agent-contract": "0.1.0",
6
6
  "@working-theory/agent-memory": "0.0.0",
7
7
  "@working-theory/ai": "0.1.0",
8
- "@working-theory/analytics": "0.59.0",
9
- "@working-theory/api": "0.59.0",
10
- "@working-theory/api-client": "0.59.0",
8
+ "@working-theory/analytics": "0.61.0",
9
+ "@working-theory/api": "0.61.0",
10
+ "@working-theory/api-client": "0.61.0",
11
11
  "@working-theory/cda-filesystem": "0.0.0",
12
- "@working-theory/cli": "0.59.0",
13
- "@working-theory/common": "0.59.0",
12
+ "@working-theory/cli": "0.61.0",
13
+ "@working-theory/common": "0.61.0",
14
14
  "@working-theory/consent": "0.1.0",
15
- "@working-theory/content-adapters": "0.59.0",
16
- "@working-theory/content-projection": "0.59.0",
17
- "@working-theory/email": "0.59.0",
15
+ "@working-theory/content-adapters": "0.61.0",
16
+ "@working-theory/content-projection": "0.61.0",
17
+ "@working-theory/email": "0.61.0",
18
18
  "@working-theory/env": "0.0.0",
19
- "@working-theory/eslint-config": "0.59.0",
20
- "@working-theory/fumadocs-schema": "0.59.0",
21
- "@working-theory/ids": "0.20.0",
22
- "@working-theory/jsonld": "0.59.0",
23
- "@working-theory/license": "0.59.0",
24
- "@working-theory/mcp-server": "0.59.0",
25
- "@working-theory/metadata": "0.59.0",
26
- "@working-theory/observability": "0.59.0",
27
- "@working-theory/page-renderer": "0.59.0",
19
+ "@working-theory/eslint-config": "0.61.0",
20
+ "@working-theory/fumadocs-schema": "0.61.0",
21
+ "@working-theory/ids": "0.20.1",
22
+ "@working-theory/jsonld": "0.61.0",
23
+ "@working-theory/license": "0.61.0",
24
+ "@working-theory/mcp-server": "0.61.0",
25
+ "@working-theory/metadata": "0.61.0",
26
+ "@working-theory/observability": "0.61.0",
27
+ "@working-theory/page-renderer": "0.61.0",
28
28
  "@working-theory/plugin-mcp": "0.1.3",
29
- "@working-theory/schema": "0.59.0",
30
- "@working-theory/schema-pack-registry": "0.59.0",
31
- "@working-theory/schema-validator": "0.59.0",
32
- "@working-theory/sections-registry": "0.59.0",
33
- "@working-theory/site-config": "0.59.0",
34
- "@working-theory/spoke-checkout": "0.7.15",
35
- "@working-theory/stripe-client": "0.59.0",
36
- "@working-theory/templates": "0.59.0",
37
- "@working-theory/theme": "0.59.0",
38
- "@working-theory/ui": "0.59.0",
39
- "@working-theory/validation": "0.59.0",
40
- "@working-theory/web-i18n": "0.59.0",
41
- "@working-theory/admin": "0.13.0",
42
- "@working-theory/api-commerce": "0.1.13",
43
- "@working-theory/api-content-write": "0.7.2",
44
- "@working-theory/api-hub": "0.4.5",
45
- "@working-theory/api-multi-tenant": "0.2.8",
46
- "@working-theory/api-scheduling": "0.4.10",
47
- "@working-theory/api-signal-collectors": "0.5.0",
48
- "@working-theory/api-workspace": "0.7.2",
29
+ "@working-theory/schema": "0.61.0",
30
+ "@working-theory/schema-pack-registry": "0.61.0",
31
+ "@working-theory/schema-validator": "0.61.0",
32
+ "@working-theory/sections-registry": "0.61.0",
33
+ "@working-theory/site-config": "0.61.0",
34
+ "@working-theory/spoke-checkout": "0.7.17",
35
+ "@working-theory/stripe-client": "0.61.0",
36
+ "@working-theory/templates": "0.61.0",
37
+ "@working-theory/theme": "0.61.0",
38
+ "@working-theory/ui": "0.61.0",
39
+ "@working-theory/validation": "0.61.0",
40
+ "@working-theory/web-i18n": "0.61.0",
41
+ "@working-theory/admin": "0.15.0",
42
+ "@working-theory/api-commerce": "0.1.15",
43
+ "@working-theory/api-content-write": "0.9.0",
44
+ "@working-theory/api-hub": "0.6.0",
45
+ "@working-theory/api-multi-tenant": "0.3.1",
46
+ "@working-theory/api-scheduling": "0.6.0",
47
+ "@working-theory/api-signal-collectors": "0.6.1",
48
+ "@working-theory/api-workspace": "0.9.0",
49
49
  "@working-theory/billing-client": "0.0.0",
50
50
  "@working-theory/branding": "0.0.0",
51
51
  "@working-theory/license-client": "0.0.0",
52
52
  "@working-theory/license-manifest": "0.0.0",
53
- "@working-theory/mcp-scheduling": "0.4.0",
54
- "@working-theory/mcp-signal-collectors": "0.2.13",
55
- "@working-theory/mcp-workspace": "0.8.0",
53
+ "@working-theory/mcp-scheduling": "0.4.2",
54
+ "@working-theory/mcp-signal-collectors": "0.2.15",
55
+ "@working-theory/mcp-workspace": "0.8.2",
56
56
  "@working-theory/partner-session": "0.0.0",
57
57
  "@working-theory/preview-protocol": "0.0.0",
58
- "@working-theory/ui-commerce": "0.23.37",
59
- "@working-theory/ui-docs-blog": "0.23.37",
60
- "@working-theory/ui-scheduling": "0.25.11",
61
- "@working-theory/ui-signal-collectors": "0.29.0",
58
+ "@working-theory/ui-commerce": "0.23.39",
59
+ "@working-theory/ui-docs-blog": "0.23.39",
60
+ "@working-theory/ui-scheduling": "0.25.13",
61
+ "@working-theory/ui-signal-collectors": "0.29.2",
62
62
  "@working-theory/web": "0.0.0",
63
63
  "@working-theory/app-api": "1.0.0",
64
64
  "@working-theory/mcp": "0.0.0",
65
- "@working-theory/database": "0.59.0"
65
+ "@working-theory/database": "0.61.0"
66
66
  }
@@ -1,276 +0,0 @@
1
- "use client"; // reads meeting types and slots on demand and posts a controlled form
2
-
3
- /**
4
- * ScheduleService — the New menu's Schedule service popup (#8233, spec D5,
5
- * D8, D10; AC-MAA-10). On open it reads the meeting types the provider
6
- * offers its clients (`readMeetingTypes`) and lists only those; picking one
7
- * reads that type's open times for the next 14 days in the browser's time
8
- * zone (`readSlots`, which computes the range on the server). Book posts the
9
- * type, the slot's start as served, the time zone and optional notes to
10
- * `member.book` — no name and no email: the server takes the verified email
11
- * and the name from the session.
12
- *
13
- * With no type offered it says no times are offered and, when Send message
14
- * is on the menu, offers to switch to it. A taken slot (`slot_unavailable`)
15
- * re-reads the picked type's times and keeps the type and the notes; every
16
- * other refusal shows its plain message with everything kept.
17
- */
18
-
19
- import {
20
- Button,
21
- Label,
22
- RadioGroup,
23
- RadioGroupItem,
24
- Text,
25
- Textarea,
26
- } from "@working-theory/ui/primitives";
27
- import type { MemberMeetingType, SchedulingSlot } from "@working-theory/validation";
28
- import {
29
- startTransition,
30
- useActionState,
31
- useId,
32
- useMemo,
33
- useRef,
34
- useState,
35
- type FormEvent,
36
- type ReactElement,
37
- } from "react";
38
-
39
- import { bookService, readMeetingTypes, readSlots, type NewActionState } from "../new-actions";
40
- import {
41
- NewPopupRefusal,
42
- NewPopupStatus,
43
- useNewMenuPopup,
44
- useOpenRead,
45
- type NewPopupLabels,
46
- } from "../new-menu";
47
-
48
- export interface ScheduleServiceLabels extends NewPopupLabels {
49
- service: string;
50
- /** Carries a literal `{minutes}`, filled per type here. */
51
- duration: string;
52
- time: string;
53
- notes: string;
54
- submit: string;
55
- none: string;
56
- suggest: string;
57
- noSlots: string;
58
- }
59
-
60
- export interface ScheduleServiceProps {
61
- locale: string;
62
- labels: ScheduleServiceLabels;
63
- }
64
-
65
- const SEND_MESSAGE = "send-message";
66
-
67
- export function ScheduleService({ locale, labels }: ScheduleServiceProps): ReactElement {
68
- const popup = useNewMenuPopup();
69
- const [read, retry] = useOpenRead(readMeetingTypes);
70
- if (read === "loading" || read.kind === "error") {
71
- return <NewPopupStatus failed={read !== "loading"} labels={labels} onRetry={retry} />;
72
- }
73
- if (read.items.length === 0) {
74
- return (
75
- <div className="flex flex-col gap-4" data-testid="new-schedule-none">
76
- <Text as="p" variant="body-sm">
77
- {labels.none}
78
- </Text>
79
- {popup.has(SEND_MESSAGE) ? (
80
- <div>
81
- <Button
82
- variant="outline"
83
- className="max-md:min-h-11"
84
- onClick={() => popup.open(SEND_MESSAGE)}
85
- data-testid="new-schedule-suggest"
86
- >
87
- {labels.suggest}
88
- </Button>
89
- </div>
90
- ) : null}
91
- </div>
92
- );
93
- }
94
- return <BookingForm types={read.items} locale={locale} labels={labels} />;
95
- }
96
-
97
- type Slots = { kind: "idle" | "loading" | "error" } | { kind: "ok"; slots: SchedulingSlot[] };
98
-
99
- function BookingForm({
100
- types,
101
- locale,
102
- labels,
103
- }: {
104
- types: readonly MemberMeetingType[];
105
- locale: string;
106
- labels: ScheduleServiceLabels;
107
- }): ReactElement {
108
- const popup = useNewMenuPopup();
109
- const id = useId();
110
- const timeZone = useMemo(() => Intl.DateTimeFormat().resolvedOptions().timeZone, []);
111
- const [slug, setSlug] = useState("");
112
- const [start, setStart] = useState("");
113
- const [notes, setNotes] = useState("");
114
- const [slots, setSlots] = useState<Slots>({ kind: "idle" });
115
- // Only the newest slots read lands: a quick second pick never shows the first's times.
116
- const latestRead = useRef(0);
117
-
118
- const loadSlots = (picked: string): void => {
119
- const readId = ++latestRead.current;
120
- setSlots({ kind: "loading" });
121
- const land = (next: Slots): void => {
122
- if (readId === latestRead.current) setSlots(next);
123
- };
124
- readSlots({ slug: picked, timeZone }).then(
125
- (result) => land(result.kind === "ok" ? { kind: "ok", slots: result.slots } : { kind: "error" }),
126
- () => land({ kind: "error" }),
127
- );
128
- };
129
-
130
- const [state, dispatch, pending] = useActionState<NewActionState, FormData>(
131
- async (prev, formData) => {
132
- const next = await bookService(prev, formData);
133
- if (next.kind === "success") popup.close(true);
134
- if (next.kind === "error" && next.code === "slot_unavailable") {
135
- const picked = formData.get("slug");
136
- setStart("");
137
- if (typeof picked === "string") loadSlots(picked);
138
- }
139
- return next;
140
- },
141
- { kind: "idle" },
142
- );
143
-
144
- const onSubmit = (event: FormEvent<HTMLFormElement>): void => {
145
- event.preventDefault();
146
- const formData = new FormData();
147
- formData.set("slug", slug);
148
- formData.set("start", start);
149
- formData.set("timeZone", timeZone);
150
- formData.set("notes", notes);
151
- startTransition(() => dispatch(formData));
152
- };
153
-
154
- const dayFormat = new Intl.DateTimeFormat(locale, {
155
- weekday: "long",
156
- month: "long",
157
- day: "numeric",
158
- timeZone,
159
- });
160
- const timeFormat = new Intl.DateTimeFormat(locale, { timeStyle: "short", timeZone });
161
- const days: { day: string; slots: { slot: SchedulingSlot; index: number }[] }[] = [];
162
- if (slots.kind === "ok") {
163
- slots.slots.forEach((slot, index) => {
164
- const day = dayFormat.format(new Date(slot.start));
165
- const last = days[days.length - 1];
166
- if (last?.day === day) last.slots.push({ slot, index });
167
- else days.push({ day, slots: [{ slot, index }] });
168
- });
169
- }
170
-
171
- return (
172
- <form onSubmit={onSubmit} className="flex flex-col gap-4" data-testid="new-schedule-form">
173
- <div className="flex flex-col gap-2">
174
- <Text as="p" id={`${id}-service`} variant="body-sm" className="font-semibold">
175
- {labels.service}
176
- </Text>
177
- <RadioGroup
178
- aria-labelledby={`${id}-service`}
179
- value={slug}
180
- onValueChange={(picked) => {
181
- setSlug(picked);
182
- setStart("");
183
- loadSlots(picked);
184
- }}
185
- >
186
- {types.map((type) => (
187
- <div key={type.slug} className="flex min-h-11 items-center gap-3">
188
- <RadioGroupItem
189
- id={`${id}-type-${type.slug}`}
190
- value={type.slug}
191
- data-testid={`new-schedule-type-${type.slug}`}
192
- />
193
- <Label htmlFor={`${id}-type-${type.slug}`} className="flex flex-wrap gap-x-2">
194
- {type.title}{" "}
195
- <Text as="span" variant="caption">
196
- {labels.duration.replace("{minutes}", String(type.durationMinutes))}
197
- </Text>
198
- </Label>
199
- </div>
200
- ))}
201
- </RadioGroup>
202
- </div>
203
-
204
- {slots.kind === "loading" || slots.kind === "error" ? (
205
- <NewPopupStatus
206
- failed={slots.kind === "error"}
207
- labels={labels}
208
- onRetry={() => loadSlots(slug)}
209
- />
210
- ) : null}
211
- {slots.kind === "ok" && slots.slots.length === 0 ? (
212
- <Text as="p" variant="body-sm" data-testid="new-schedule-no-slots">
213
- {labels.noSlots}
214
- </Text>
215
- ) : null}
216
- {days.length > 0 ? (
217
- <div className="flex flex-col gap-2">
218
- <Text as="p" id={`${id}-time`} variant="body-sm" className="font-semibold">
219
- {labels.time}
220
- </Text>
221
- <RadioGroup aria-labelledby={`${id}-time`} value={start} onValueChange={setStart}>
222
- {days.map(({ day, slots: daySlots }) => (
223
- <div key={day} className="flex flex-col gap-1">
224
- <Text as="p" variant="caption">
225
- {day}
226
- </Text>
227
- {daySlots.map(({ slot, index }) => (
228
- <div key={slot.start} className="flex min-h-11 items-center gap-3">
229
- <RadioGroupItem
230
- id={`${id}-slot-${index}`}
231
- value={slot.start}
232
- data-testid={`new-schedule-slot-${index}`}
233
- />
234
- <Label htmlFor={`${id}-slot-${index}`}>
235
- {timeFormat.format(new Date(slot.start))}
236
- </Label>
237
- </div>
238
- ))}
239
- </div>
240
- ))}
241
- </RadioGroup>
242
- </div>
243
- ) : null}
244
-
245
- <div className="flex flex-col gap-2">
246
- <div className="flex items-baseline gap-2">
247
- <Label htmlFor={`${id}-notes`}>{labels.notes}</Label>
248
- <Text as="span" variant="caption">
249
- {labels.optional}
250
- </Text>
251
- </div>
252
- <Textarea
253
- id={`${id}-notes`}
254
- name="notes"
255
- rows={3}
256
- value={notes}
257
- onChange={(event) => setNotes(event.target.value)}
258
- data-testid="new-schedule-notes"
259
- />
260
- </div>
261
-
262
- {state.kind === "error" ? <NewPopupRefusal code={state.code} labels={labels} /> : null}
263
- <div>
264
- <Button
265
- type="submit"
266
- disabled={pending || slug === "" || start === ""}
267
- // 44px on a phone (a touch-first context); the 36px primary from md up.
268
- className="max-md:min-h-11"
269
- data-testid="new-schedule-submit"
270
- >
271
- {pending ? labels.submitting : labels.submit}
272
- </Button>
273
- </div>
274
- </form>
275
- );
276
- }
@@ -1,128 +0,0 @@
1
- "use client"; // a controlled form posting through the New menu's server action
2
-
3
- /**
4
- * SendMessage — the New menu's Send message popup (#8233, spec D9, D10): a
5
- * subject, a body (line breaks kept) and an optional link, posted to
6
- * `member.sendMessage` by `sendMessage` (`../new-actions.ts`). No name and no
7
- * email: the server takes both from the session.
8
- *
9
- * Every field is controlled and the form posts what the state holds, so a
10
- * refusal — a non-https link above all — shows its plain message with every
11
- * typed value still in place. The link is sent as typed; the server's https
12
- * rule is the only one. A success closes the popup and refreshes the Inbox.
13
- */
14
-
15
- import { Button, Input, Label, Text, Textarea } from "@working-theory/ui/primitives";
16
- import { MESSAGE_BODY_MAX, MESSAGE_SUBJECT_MAX } from "@working-theory/validation";
17
- import {
18
- startTransition,
19
- useActionState,
20
- useId,
21
- useState,
22
- type FormEvent,
23
- type ReactElement,
24
- } from "react";
25
-
26
- import { sendMessage, type NewActionState } from "../new-actions";
27
- import { NewPopupRefusal, useNewMenuPopup, type NewPopupLabels } from "../new-menu";
28
-
29
- export interface SendMessageLabels extends NewPopupLabels {
30
- subject: string;
31
- body: string;
32
- link: string;
33
- linkHelp: string;
34
- submit: string;
35
- }
36
-
37
- export interface SendMessageProps {
38
- locale: string;
39
- labels: SendMessageLabels;
40
- }
41
-
42
- export function SendMessage({ labels }: SendMessageProps): ReactElement {
43
- const popup = useNewMenuPopup();
44
- const id = useId();
45
- const [subject, setSubject] = useState("");
46
- const [body, setBody] = useState("");
47
- const [link, setLink] = useState("");
48
- const [state, dispatch, pending] = useActionState<NewActionState, FormData>(
49
- async (prev, formData) => {
50
- const next = await sendMessage(prev, formData);
51
- if (next.kind === "success") popup.close(true);
52
- return next;
53
- },
54
- { kind: "idle" },
55
- );
56
-
57
- const onSubmit = (event: FormEvent<HTMLFormElement>): void => {
58
- event.preventDefault();
59
- const formData = new FormData();
60
- formData.set("subject", subject);
61
- formData.set("body", body);
62
- formData.set("link", link);
63
- startTransition(() => dispatch(formData));
64
- };
65
-
66
- return (
67
- <form onSubmit={onSubmit} className="flex flex-col gap-4" data-testid="new-message-form">
68
- <div className="flex flex-col gap-2">
69
- <Label htmlFor={`${id}-subject`}>{labels.subject}</Label>
70
- <Input
71
- id={`${id}-subject`}
72
- name="subject"
73
- value={subject}
74
- maxLength={MESSAGE_SUBJECT_MAX}
75
- required
76
- onChange={(event) => setSubject(event.target.value)}
77
- data-testid="new-message-subject"
78
- />
79
- </div>
80
- <div className="flex flex-col gap-2">
81
- <Label htmlFor={`${id}-body`}>{labels.body}</Label>
82
- <Textarea
83
- id={`${id}-body`}
84
- name="body"
85
- value={body}
86
- rows={5}
87
- maxLength={MESSAGE_BODY_MAX}
88
- required
89
- onChange={(event) => setBody(event.target.value)}
90
- data-testid="new-message-body"
91
- />
92
- </div>
93
- <div className="flex flex-col gap-2">
94
- <div className="flex items-baseline gap-2">
95
- <Label htmlFor={`${id}-link`}>{labels.link}</Label>
96
- <Text as="span" variant="caption">
97
- {labels.optional}
98
- </Text>
99
- </div>
100
- <Input
101
- id={`${id}-link`}
102
- name="link"
103
- type="text"
104
- inputMode="url"
105
- value={link}
106
- aria-describedby={`${id}-link-help`}
107
- onChange={(event) => setLink(event.target.value)}
108
- data-testid="new-message-link"
109
- />
110
- <Text as="p" id={`${id}-link-help`} variant="caption">
111
- {labels.linkHelp}
112
- </Text>
113
- </div>
114
- {state.kind === "error" ? <NewPopupRefusal code={state.code} labels={labels} /> : null}
115
- <div>
116
- <Button
117
- type="submit"
118
- disabled={pending}
119
- // 44px on a phone (a touch-first context); the 36px primary from md up.
120
- className="max-md:min-h-11"
121
- data-testid="new-message-submit"
122
- >
123
- {pending ? labels.submitting : labels.submit}
124
- </Button>
125
- </div>
126
- </form>
127
- );
128
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * `siteThemeModeCount` (#7742 D2 / AC-2): a design pinned to light has one
3
- * colour mode whatever its palette declares; without the pin, the declared
4
- * palette decides, as before.
5
- */
6
- import type { SiteChrome } from "../../../../../../lib/site-chrome";
7
-
8
- const mockSiteChrome: SiteChrome = {
9
- nav: "full",
10
- footer: "columns",
11
- announcementBanner: false,
12
- home: "default",
13
- };
14
- // eslint-disable-next-line no-restricted-syntax -- #507: `site-chrome.ts` is a generated data module with no external boundary to mock instead; this is the seam theme-modes.ts itself reads.
15
- jest.mock("../../../../../../lib/site-chrome", () => ({
16
- __esModule: true,
17
- siteChrome: mockSiteChrome,
18
- }));
19
-
20
- // Both palettes declared — the count is 2 without the pin.
21
- // eslint-disable-next-line no-restricted-syntax -- #507: the one seam onto `_site.mdx`; the palette is the test's to set.
22
- jest.mock("../../../../../../lib/site-theme", () => ({
23
- __esModule: true,
24
- loadSiteBrandTokens: () => ({ colors: { light: { bg: "#ffffff" }, dark: { bg: "#000000" } } }),
25
- }));
26
-
27
- import { siteThemeModeCount } from "../theme-modes";
28
-
29
- afterEach(() => {
30
- delete mockSiteChrome.colorMode;
31
- });
32
-
33
- describe("siteThemeModeCount (#7742 D2)", () => {
34
- it('colorMode: "light" gives 1 even when both palettes are declared', () => {
35
- mockSiteChrome.colorMode = "light";
36
- expect(siteThemeModeCount()).toBe(1);
37
- });
38
-
39
- it("without colorMode the same palette gives 2", () => {
40
- expect(siteThemeModeCount()).toBe(2);
41
- });
42
- });
@@ -1,40 +0,0 @@
1
- /**
2
- * theme-modes.ts — how many color modes the site's theme defines (#7430,
3
- * operator fold-in 2026-10-01: the color-mode control renders only on a
4
- * site whose theme has more than one).
5
- *
6
- * Read from the same `content/_site.mdx` overlay the locale layout applies
7
- * (`loadSiteBrandTokens`):
8
- *
9
- * - no `theme:` colours (the default palette, light AND dark) → 2;
10
- * - colours declared for both `light` and `dark` → 2;
11
- * - colours declared for ONE mode only → 1. A site that designs a single
12
- * palette (samhenry's light-only DESIGN.md) declares just that mode, and
13
- * the other mode's defaults are not its design.
14
- *
15
- * A theme the loader rejects counts as the default (2): the layout surfaces
16
- * that error itself, and settings must not be where it first appears.
17
- *
18
- * A design that pins the mode (`colorMode: "light"`, #7742 D2) has one mode
19
- * whatever its palette declares, so the settings control hides there too.
20
- */
21
-
22
- import { siteChrome, type SiteChrome } from "../../../../../lib/site-chrome";
23
- import { loadSiteBrandTokens } from "../../../../../lib/site-theme";
24
-
25
- /** Widened as the locale layout reads it: an older generated file has no `colorMode`. */
26
- const chrome: SiteChrome & { colorMode?: "light" } = siteChrome;
27
-
28
- export function siteThemeModeCount(): 1 | 2 {
29
- if (chrome.colorMode === "light") return 1;
30
- try {
31
- const colors = loadSiteBrandTokens()?.["colors"];
32
- if (typeof colors !== "object" || colors === null) return 2;
33
- const declared = (["light", "dark"] as const).filter(
34
- (mode) => (colors as Record<string, unknown>)[mode] !== undefined,
35
- );
36
- return declared.length === 1 ? 1 : 2;
37
- } catch {
38
- return 2;
39
- }
40
- }