create-ailk 0.39.0 → 0.40.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 (187) hide show
  1. package/dist/add-route.js +15 -0
  2. package/dist/body-heading.d.ts +2 -1
  3. package/dist/body-heading.js +31 -3
  4. package/dist/module-architecture.js +0 -3
  5. package/dist/remove-module.js +13 -4
  6. package/dist/routes.d.ts +7 -0
  7. package/dist/routes.js +1 -1
  8. package/dist/site-roster.js +7 -1
  9. package/dist/surfaces.d.ts +2 -0
  10. package/dist/surfaces.js +59 -172
  11. package/package.json +3 -3
  12. package/templates/apps/web/CLAUDE.md +7 -1
  13. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
  14. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
  15. package/templates/apps/web/app/[locale]/layout.tsx +1 -1
  16. package/templates/apps/web/i18n/request.ts +5 -1
  17. package/templates/apps/web/jest.config.cjs +6 -0
  18. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  19. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  20. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  21. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  22. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  23. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  24. package/templates/apps/web/lib/pricing-page.ts +3 -3
  25. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
  26. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
  27. package/templates/apps/web/lib/site-header.ts +1 -1
  28. package/templates/apps/web/messages/en.json +0 -119
  29. package/templates/apps/web/next.config.mjs +7 -0
  30. package/templates/apps/web/package.json +1 -0
  31. package/templates/apps/web/site-pages.config.tsx +85 -0
  32. package/templates/tools/body-heading.ts +30 -3
  33. package/versions.json +50 -49
  34. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  35. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  36. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  37. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  38. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  39. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  40. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  41. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  42. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  43. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  44. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  45. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  46. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  47. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  48. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  49. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  50. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  51. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  52. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  53. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  54. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  55. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  56. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  57. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  58. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  59. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  60. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  61. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  62. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  63. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  64. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  65. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  66. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  67. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  68. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  69. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  70. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  71. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  72. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  73. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  74. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  75. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  76. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  77. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  78. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  79. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  80. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  81. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  82. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  83. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  84. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  85. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  86. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  87. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  88. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  89. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  90. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  91. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  92. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  93. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  94. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  95. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  96. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  97. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  98. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  99. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  100. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  101. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  102. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  103. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  104. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  105. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  106. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  107. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  108. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  109. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  110. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  111. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  112. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  113. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  114. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  115. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  116. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  117. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  118. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  119. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  120. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  121. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  122. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  123. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  124. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  125. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  126. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  127. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  128. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  129. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  130. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  131. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  132. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  133. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  134. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  135. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  136. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  137. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  138. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  139. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  140. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  141. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  142. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  143. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  144. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  145. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  146. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  147. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  148. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  149. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  150. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  151. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  152. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  153. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  155. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  156. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  157. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  158. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  159. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  160. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  161. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  162. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  163. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  164. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  165. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  166. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  167. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  168. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  169. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  170. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  171. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  172. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  173. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  174. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  175. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  176. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  177. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  178. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  179. package/templates/apps/web/lib/hub-children.tsx +0 -351
  180. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  181. package/templates/apps/web/lib/posting-title.ts +0 -39
  182. package/templates/apps/web/lib/route-family.ts +0 -69
  183. package/templates/apps/web/lib/service-listing.ts +0 -89
  184. package/templates/apps/web/lib/template-listing.ts +0 -169
  185. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  186. package/templates/apps/web/src/lib/lead-write.ts +0 -90
  187. /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
@@ -1,111 +0,0 @@
1
- /**
2
- * Display formatting for the waitlist operator dashboard (#4665 D4/D10, UI).
3
- *
4
- * The ONE place a number, rate, or date becomes a string for this surface
5
- * (Rule 10 — formatting happens in `apps/web`, never inside a
6
- * `packages/ui/src/blocks/*` component). Every formatter here is
7
- * locale-aware; the caller supplies the active `[locale]` route segment.
8
- *
9
- * `null` is D4's "unavailable" sentinel (an unscored / non-qualifying
10
- * experiment) — rendered as an em dash, never `0` or an empty string, so an
11
- * unscored row is never misread as a zero row.
12
- */
13
-
14
- import { formatNumber, formatPercent } from "@working-theory/web-i18n";
15
-
16
- /** D4/D9's "no value" rendering — never `0`, never blank. */
17
- export const UNAVAILABLE = "—";
18
-
19
- /** Format a raw count (signups, tier counts, question `answered`). */
20
- export function formatCount(value: number, locale: string): string {
21
- return formatNumber(value, locale);
22
- }
23
-
24
- /**
25
- * Format a rate/share (0–1) as a percentage, or the unavailable sentinel when
26
- * `null` (D4 — `qualified`/`qualificationRate` are `null` for a
27
- * `lead-capture` experiment; a distribution `share` is always a number).
28
- */
29
- export function formatRate(value: number | null, locale: string): string {
30
- if (value === null) return UNAVAILABLE;
31
- return formatPercent(value, locale);
32
- }
33
-
34
- /** Format an ISO-8601 datetime for display (list/comparison/drill-down). */
35
- export function formatDateTime(iso: string, locale: string): string {
36
- return new Intl.DateTimeFormat(locale, {
37
- dateStyle: "medium",
38
- timeStyle: "short",
39
- }).format(new Date(iso));
40
- }
41
-
42
- // ─── FEAT-074 U4a (#4715) — the targeting-maturity Level display ────────────
43
- //
44
- // Presentation-only mapping (spec D5): `level_3` -> the integer `3`,
45
- // `level_0` -> `0` (the Gate). Scoped to the ONE experiment this Level
46
- // vocabulary applies to — every other experiment's tier renders unchanged
47
- // (AC-5's "a non-targeting experiment renders exactly as before"). Pure
48
- // parsing only, no i18n — the CALLER (the page, which already owns every
49
- // `getTranslations` call on this surface) turns the returned number into
50
- // the "Level N" / Gate string via its own `t()`.
51
-
52
- /** The one experiment this Level vocabulary applies to. */
53
- export const TARGETING_MATURITY_EXPERIMENT_KEY = "targeting-maturity";
54
-
55
- const LEVEL_TIER_RE = /^level_(\d+)$/;
56
-
57
- /**
58
- * The Level number for a `targeting-maturity` `level_N` tier — `0` for the
59
- * Gate, `N` otherwise. `null` for any other experiment, a `null` tier, or an
60
- * unrecognized tier shape — the caller falls back to the raw tier /
61
- * `labels.unavailable` unchanged (D5).
62
- */
63
- export function targetingMaturityLevel(
64
- tier: string | null,
65
- experimentKey: string,
66
- ): number | null {
67
- if (experimentKey !== TARGETING_MATURITY_EXPERIMENT_KEY || tier === null) return null;
68
- const match = LEVEL_TIER_RE.exec(tier);
69
- return match ? Number(match[1]) : null;
70
- }
71
-
72
- /**
73
- * The `ref(<name>)` def names that DECIDED the matched tier, for the
74
- * ScoreTrace drill-down's "deciding factors" section (AC-5) — every
75
- * `kind: "predicate"` entry in a `RuleTraceEntry[]`-shaped `ruleTrace`
76
- * whose `tier` equals the signup's own tier AND whose `result` is `true`,
77
- * with every `ref(...)` segment in its `path` extracted (there is no
78
- * separate `def` field — `evaluatePredicateNode`'s own path-building embeds
79
- * each traversed def as `ref(<name>)`). Duck-typed against `unknown`
80
- * (`ruleTrace` is `z.unknown()` at this boundary — `waitlist-dashboard.ts`'s
81
- * schema comment), mirroring the identical extraction the backend's
82
- * `playbook-compile.ts` uses for its Level-1 loop-back framing — this is
83
- * the read-side counterpart, not a fork of it (no shared module: the two
84
- * sides are in different apps, which may not cross-import — `architecture.yaml`).
85
- * `[]` for any other experiment (AC-5's non-targeting byte-unchanged floor).
86
- */
87
- export function decidingDefsFor(
88
- tier: string | null,
89
- ruleTrace: unknown,
90
- experimentKey: string,
91
- ): string[] {
92
- if (experimentKey !== TARGETING_MATURITY_EXPERIMENT_KEY || tier === null) return [];
93
- if (!Array.isArray(ruleTrace)) return [];
94
- const seen = new Set<string>();
95
- const names: string[] = [];
96
- for (const entry of ruleTrace) {
97
- if (typeof entry !== "object" || entry === null) continue;
98
- const e = entry as Record<string, unknown>;
99
- if (e["kind"] !== "predicate" || e["tier"] !== tier || e["result"] !== true) continue;
100
- const path = e["path"];
101
- if (typeof path !== "string") continue;
102
- for (const m of path.matchAll(/ref\(([^)]+)\)/g)) {
103
- const name = m[1]!;
104
- if (!seen.has(name)) {
105
- seen.add(name);
106
- names.push(name);
107
- }
108
- }
109
- }
110
- return names;
111
- }
@@ -1,402 +0,0 @@
1
- /**
2
- * Tests for the `[slug]/[detail]` route — the Free `/meet/<slug>` placeholder
3
- * detail pages (#6897 D2).
4
- *
5
- * - `slug !== "meet"` → notFound() immediately, never reaching getMdxSource.
6
- * - `slug === "meet"` and a BookCall source exists at `detail` → renders
7
- * through renderPage sections mode, no notFound() call.
8
- * - `slug === "meet"` and no BookCall source exists at `detail` → renderPage's
9
- * own detail-route branch (no translationsNamespace passed) calls
10
- * notFound().
11
- */
12
- import React from "react";
13
- import { render } from "@testing-library/react";
14
-
15
- jest.mock("next/navigation", () => ({
16
- __esModule: true,
17
- notFound: jest.fn(() => {
18
- throw new Error("NEXT_NOT_FOUND");
19
- }),
20
- }));
21
-
22
- // #7521 — the paid sections reach the listing extension through the generated
23
- // paid-sections registry, which a keyless scaffold renders as a stub answering
24
- // null. This suite supplies stand-ins through the registry itself, so it
25
- // passes in the monorepo and in every scaffold alike; the real sections are
26
- // `listing-directory.test.tsx`'s (ui-signal-collectors).
27
- // eslint-disable-next-line no-restricted-syntax -- the generated registry is the paid-package boundary; a scaffold renders it with or without the package
28
- jest.mock("../../../../../lib/paid-sections.generated", () => {
29
- const { createElement, Fragment } = jest.requireActual<typeof import("react")>("react");
30
- type Entry = { name: string; profile: Array<{ name: string; label: string; value: string }> };
31
- return {
32
- loadUiCommerce: async () => null,
33
- loadUiSignalCollectors: async () => ({
34
- ListingShelves: () => createElement("div", { "data-testid": "listing-shelves" }),
35
- ListingDetail: ({ entry }: { entry: Entry }) =>
36
- createElement(
37
- Fragment,
38
- null,
39
- createElement("h1", null, entry.name),
40
- createElement(
41
- "dl",
42
- null,
43
- ...entry.profile.flatMap((row) => [
44
- createElement("dt", { key: `${row.name}-dt` }, row.label),
45
- createElement("dd", { key: `${row.name}-dd` }, row.value),
46
- ]),
47
- ),
48
- ),
49
- }),
50
- };
51
- });
52
-
53
- // #10552 — an MDX body's `## ` lines render through the page's own component
54
- // map, so a heading's `id` is the real heading adapter's (AC-4).
55
- jest.mock("next-mdx-remote/rsc", () => {
56
- const { createElement, Fragment } = jest.requireActual<typeof import("react")>("react");
57
- return {
58
- MDXRemote: ({
59
- source,
60
- components,
61
- }: {
62
- source: string;
63
- components: Record<string, React.ComponentType<{ children?: React.ReactNode }>>;
64
- }) =>
65
- createElement(
66
- Fragment,
67
- null,
68
- ...source
69
- .split("\n")
70
- .filter((line) => line.trim() !== "")
71
- .map((line, i) =>
72
- line.startsWith("## ")
73
- ? createElement(components["h2"]!, { key: i }, line.slice(3))
74
- : createElement("p", { key: i }, line),
75
- ),
76
- ),
77
- };
78
- });
79
-
80
- jest.mock("@working-theory/ui", () => ({
81
- // #7789: renderPage's fallback page head renders inside the section Container.
82
- Container: ({ children }: { children?: React.ReactNode }) =>
83
- React.createElement("div", null, children),
84
- // #7521 — the rest of the real barrel, so the listing extension finds
85
- // `localeHref`; the two below still override.
86
- ...jest.requireActual("@working-theory/ui"),
87
- Heading: ({
88
- children,
89
- level,
90
- id,
91
- }: {
92
- children: React.ReactNode;
93
- level: number;
94
- id?: string;
95
- }): React.ReactElement => React.createElement(`h${level}`, id ? { id } : null, children),
96
- SectionRenderer: ({ sections }: { sections: unknown[] }) =>
97
- React.createElement("div", {
98
- "data-testid": "section-renderer",
99
- "data-section-count": String(sections.length),
100
- }),
101
- }));
102
-
103
- import { notFound } from "next/navigation";
104
-
105
- import { listingExtension } from "../../../../../lib/listings";
106
- import DetailPage, { generateMetadata } from "../page";
107
-
108
- // #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
109
- process.env.CONTENT_ADAPTER = "mdx";
110
-
111
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
112
-
113
- function makeSource(slug: string) {
114
- return {
115
- frontmatter: {
116
- type: "BookCall" as const,
117
- slug,
118
- title: `Title for ${slug}`,
119
- description: `Description for ${slug}`,
120
- sections: [
121
- {
122
- id: "hero",
123
- type: "hero" as const,
124
- data: { headline: `Title for ${slug}` },
125
- },
126
- ],
127
- },
128
- body: "",
129
- };
130
- }
131
-
132
- describe("[slug]/[detail] — the Free /meet/<slug> placeholder route (#6897 D2)", () => {
133
- beforeEach(() => {
134
- mockNotFound.mockClear();
135
- });
136
-
137
- it("renders a BookCall seed at meet/<detail> through renderPage sections mode", async () => {
138
- const getMdxSource = jest.fn().mockResolvedValue(makeSource("book-a-call"));
139
-
140
- const element = await DetailPage({
141
- params: Promise.resolve({ locale: "en", slug: "meet", detail: "book-a-call" }),
142
- getMdxSource,
143
- });
144
- const { container } = render(element);
145
-
146
- expect(getMdxSource).toHaveBeenCalledWith("BookCall", "book-a-call", "en");
147
- expect(
148
- container.querySelector("[data-testid='section-renderer']"),
149
- ).not.toBeNull();
150
- expect(
151
- container.querySelector("script[type='application/ld+json']"),
152
- ).not.toBeNull();
153
- expect(mockNotFound).not.toHaveBeenCalled();
154
- });
155
-
156
- it("404s for another hub — no BookCall source is ever read", async () => {
157
- const getMdxSource = jest.fn().mockResolvedValue(makeSource("book-a-call"));
158
-
159
- await expect(
160
- DetailPage({
161
- params: Promise.resolve({ locale: "en", slug: "not-meet", detail: "book-a-call" }),
162
- getMdxSource,
163
- }),
164
- ).rejects.toThrow("NEXT_NOT_FOUND");
165
- expect(mockNotFound).toHaveBeenCalledTimes(1);
166
- // #10552 — the program-event branch reads the Event source first; the
167
- // meet branch's BookCall read never runs for another hub.
168
- expect(getMdxSource).not.toHaveBeenCalledWith("BookCall", expect.anything(), expect.anything());
169
- });
170
-
171
- it("404s for an unknown detail slug under the meet hub", async () => {
172
- const getMdxSource = jest.fn().mockResolvedValue(null);
173
-
174
- await expect(
175
- DetailPage({
176
- params: Promise.resolve({ locale: "en", slug: "meet", detail: "not-a-page" }),
177
- getMdxSource,
178
- }),
179
- ).rejects.toThrow("NEXT_NOT_FOUND");
180
- expect(mockNotFound).toHaveBeenCalledTimes(1);
181
- });
182
- });
183
-
184
- // ── #7521 — a non-meet hub serves a listicle's accepted entry ──────────────
185
- //
186
- // Through the REAL listing extension: the key is set, the API read is a
187
- // fetch stub, and the paid sections are the registry stand-ins mocked above.
188
- describe("[slug]/[detail] — a listicle entry at /<landingPage>/<slug> (#7521)", () => {
189
- const priorKey = process.env["AILK_LISTING_PUBLIC_KEY"];
190
- const priorLocales = process.env["NEXT_PUBLIC_ENABLED_LOCALES"];
191
- const priorFetch = global.fetch;
192
-
193
- beforeEach(() => {
194
- mockNotFound.mockClear();
195
- process.env["AILK_LISTING_PUBLIC_KEY"] = "pk-detail-test";
196
- process.env["NEXT_PUBLIC_ENABLED_LOCALES"] = "en";
197
- global.fetch = jest.fn(async () => ({
198
- ok: true,
199
- status: 200,
200
- json: async () => ({
201
- ok: true,
202
- data: {
203
- landingPage: "/tools",
204
- entryType: "Organization",
205
- entries: [
206
- {
207
- id: "prjl_acme",
208
- slug: "acme",
209
- name: "Acme Tools",
210
- summary: "Tools for teams.",
211
- url: null,
212
- logoMarkUrl: null,
213
- featured: false,
214
- status: "active",
215
- windowEndsAt: null,
216
- decidedAt: null,
217
- waitlistCount: 0,
218
- profile: [{ name: "stage", label: "Stage", value: "Live", kind: "select" }],
219
- },
220
- ],
221
- },
222
- }),
223
- })) as jest.Mock;
224
- });
225
-
226
- afterEach(() => {
227
- if (priorKey === undefined) delete process.env["AILK_LISTING_PUBLIC_KEY"];
228
- else process.env["AILK_LISTING_PUBLIC_KEY"] = priorKey;
229
- if (priorLocales === undefined) delete process.env["NEXT_PUBLIC_ENABLED_LOCALES"];
230
- else process.env["NEXT_PUBLIC_ENABLED_LOCALES"] = priorLocales;
231
- global.fetch = priorFetch;
232
- });
233
-
234
- it("renders the accepted entry with its profile and entry-type JSON-LD", async () => {
235
- // `/tools` is a LandingPage, so the hub guard lets the directory read run.
236
- const getMdxSource = jest
237
- .fn()
238
- .mockImplementation(async (type: string) =>
239
- type === "LandingPage" ? makeSource("tools") : null,
240
- );
241
-
242
- const element = await DetailPage({
243
- params: Promise.resolve({ locale: "en", slug: "tools", detail: "acme" }),
244
- getMdxSource,
245
- });
246
- const { container } = render(element);
247
-
248
- expect(container.querySelector("h1")?.textContent).toBe("Acme Tools");
249
- expect(container.querySelector("dt")?.textContent).toBe("Stage");
250
- expect(container.querySelector("dd")?.textContent).toBe("Live");
251
- const ld = JSON.parse(
252
- container.querySelector("script[type='application/ld+json']")?.textContent ?? "{}",
253
- ) as Record<string, unknown>;
254
- expect(ld["@type"]).toBe("Organization");
255
- expect(String((global.fetch as jest.Mock).mock.calls[0][0])).toContain(
256
- "/v1/project-listings/directory?siteKey=pk-detail-test&landingPage=%2Ftools&locale=en",
257
- );
258
- expect(mockNotFound).not.toHaveBeenCalled();
259
- expect(getMdxSource).toHaveBeenCalledWith("LandingPage", "tools", "en");
260
- expect(getMdxSource).not.toHaveBeenCalledWith("BookCall", expect.anything(), expect.anything());
261
- });
262
-
263
- it("404s for an entry the directory does not hold", async () => {
264
- await expect(
265
- DetailPage({
266
- params: Promise.resolve({ locale: "en", slug: "tools", detail: "nope" }),
267
- getMdxSource: jest.fn().mockResolvedValue(makeSource("tools")),
268
- }),
269
- ).rejects.toThrow("NEXT_NOT_FOUND");
270
- });
271
-
272
- it("404s with no directory read when the hub is not a page (SEC-7521-D1)", async () => {
273
- const getMdxSource = jest.fn(async () => null);
274
-
275
- await expect(
276
- DetailPage({
277
- params: Promise.resolve({ locale: "en", slug: "made-up-hub", detail: "acme" }),
278
- getMdxSource,
279
- }),
280
- ).rejects.toThrow("NEXT_NOT_FOUND");
281
- expect(getMdxSource).toHaveBeenCalledWith("LandingPage", "made-up-hub", "en");
282
- expect(getMdxSource).toHaveBeenCalledWith("BlogList", "made-up-hub", "en");
283
- expect(global.fetch).not.toHaveBeenCalled();
284
- });
285
- });
286
-
287
- // ── #10552 — an Event under a program at /<program>/<event> ─────────────────
288
- describe("[slug]/[detail] — an Event under a program at /<program>/<event> (#10552)", () => {
289
- const landing = (slug: string, title: string) => ({
290
- frontmatter: { type: "LandingPage" as const, slug, title, description: `${title}.` },
291
- body: "",
292
- });
293
- const golf = (frontmatter: Record<string, unknown> = { parent: "younglife" }) => ({
294
- frontmatter: {
295
- type: "Event" as const,
296
- slug: "golf-tournament",
297
- title: "Golf Tournament 2026",
298
- description: "Our annual golf tournament.",
299
- publishedAt: "2026-06-12",
300
- ...frontmatter,
301
- },
302
- body: "Tee off with us.\n\n## Sponsorship\n\nBecome a hole sponsor.",
303
- });
304
- const loader = (
305
- pages: Record<string, ReturnType<typeof landing> | ReturnType<typeof golf>>,
306
- ) => jest.fn(async (type: string, slug: string) => pages[`${type}/${slug}`] ?? null);
307
- const params = (slug: string, detail = "golf-tournament") =>
308
- Promise.resolve({ locale: "en", slug, detail });
309
-
310
- let entryAt: jest.SpyInstance;
311
- beforeEach(() => {
312
- mockNotFound.mockClear();
313
- entryAt = jest.spyOn(listingExtension, "entryAt");
314
- });
315
- afterEach(() => entryAt.mockRestore());
316
-
317
- it("renders the Event with its Event JSON-LD and the program breadcrumb (AC-3)", async () => {
318
- const getMdxSource = loader({
319
- "LandingPage/younglife": landing("younglife", "Young Life"),
320
- "Event/golf-tournament": golf(),
321
- });
322
-
323
- const { container } = render(await DetailPage({ params: params("younglife"), getMdxSource }));
324
-
325
- expect(mockNotFound).not.toHaveBeenCalled();
326
- const ld = JSON.parse(
327
- container.querySelector("script[type='application/ld+json']")?.textContent ?? "{}",
328
- ) as Record<string, unknown>;
329
- const nodes = (ld["@graph"] ?? [ld]) as Array<Record<string, unknown>>;
330
- const event = nodes
331
- .map((node) => node["mainEntity"] as Record<string, unknown> | undefined)
332
- .find((entity) => entity?.["@type"] === "Event");
333
- expect(event).toMatchObject({ name: "Golf Tournament 2026", startDate: "2026-06-12" });
334
- const crumbs = nodes.find((node) => node["@type"] === "BreadcrumbList")?.[
335
- "itemListElement"
336
- ] as Array<Record<string, unknown>>;
337
- expect(crumbs[1]).toMatchObject({ name: "Young Life" });
338
- expect(crumbs[2]?.["item"]).toMatch(/\/younglife\/golf-tournament$/);
339
- expect(entryAt).not.toHaveBeenCalled();
340
-
341
- const metadata = await generateMetadata({ params: params("younglife"), getMdxSource });
342
- expect(metadata.title).toBe("Golf Tournament 2026");
343
- });
344
-
345
- it("offers add-to-calendar for Google, Outlook and Apple (.ics) at the program URL", async () => {
346
- const getMdxSource = loader({
347
- "LandingPage/younglife": landing("younglife", "Young Life"),
348
- "Event/golf-tournament": golf(),
349
- });
350
-
351
- const { container } = render(await DetailPage({ params: params("younglife"), getMdxSource }));
352
-
353
- const href = (id: string) =>
354
- container.querySelector(`[data-testid='add-to-calendar-${id}']`)?.getAttribute("href") ?? "";
355
- expect(href("google")).toMatch(/^https:\/\/calendar\.google\.com\//);
356
- expect(href("outlook")).toMatch(/^https:\/\/outlook\./);
357
- expect(href("apple")).toMatch(/^data:text\/calendar/);
358
- expect(decodeURIComponent(href("apple"))).toContain("/younglife/golf-tournament");
359
- });
360
-
361
- it("supports a #sponsorship anchor from the body heading (AC-4)", async () => {
362
- const getMdxSource = loader({
363
- "LandingPage/younglife": landing("younglife", "Young Life"),
364
- "Event/golf-tournament": golf(),
365
- });
366
-
367
- const { container } = render(await DetailPage({ params: params("younglife"), getMdxSource }));
368
-
369
- const anchors = container.querySelectorAll("#sponsorship");
370
- expect(anchors).toHaveLength(1);
371
- expect(anchors[0]?.tagName).toBe("H2");
372
- expect(anchors[0]?.textContent).toBe("Sponsorship");
373
- });
374
-
375
- it("serves it only under the program it names (AC-5)", async () => {
376
- const cases: Array<[string, ReturnType<typeof loader>]> = [
377
- [
378
- "other",
379
- loader({
380
- "LandingPage/other": landing("other", "Other"),
381
- "LandingPage/younglife": landing("younglife", "Young Life"),
382
- "Event/golf-tournament": golf(),
383
- }),
384
- ],
385
- ["younglife", loader({ "Event/golf-tournament": golf() })],
386
- [
387
- "younglife",
388
- loader({
389
- "LandingPage/younglife": landing("younglife", "Young Life"),
390
- "Event/golf-tournament": golf({}),
391
- }),
392
- ],
393
- ];
394
- for (const [slug, getMdxSource] of cases) {
395
- mockNotFound.mockClear();
396
- await expect(DetailPage({ params: params(slug), getMdxSource })).rejects.toThrow(
397
- "NEXT_NOT_FOUND",
398
- );
399
- expect(mockNotFound).toHaveBeenCalledTimes(1);
400
- }
401
- });
402
- });
@@ -1,143 +0,0 @@
1
- // Two-segment URLs: the Free /meet/<slug> placeholder detail pages (#6897
2
- // D2), an Event under a program (#10552), and a listicle directory's entry
3
- // pages (#7521).
4
- //
5
- // The meet hub: BookCall content served at /meet/<detail> by Next.js
6
- // static-segment precedence: wherever apps/web/app/[locale]/meet/ exists (the
7
- // scheduling module), that directory resolves every /meet/* URL first and this
8
- // route never runs. On a keyless scaffold, this route serves the four Free
9
- // placeholder detail pages. Unknown detail slug → notFound() (renderPage's own
10
- // detail-route branch: no translationsNamespace is passed, so a null source
11
- // 404s rather than rendering an empty-state placeholder — the same contract
12
- // `[slug]/page.tsx` documents).
13
- //
14
- // A program's event: `/<program>/<event>` serves the Event MDX `<event>` when
15
- // its frontmatter `parent` is `<program>` and `/<program>` is a LandingPage —
16
- // before the listing extension, so an event URL costs no listing read. Any
17
- // other combination falls through. A `parent` that names a static top-level
18
- // route directory (`events`, `services`, …) or `meet` is unreachable here:
19
- // Next.js serves the static directory first (spec 10552 § 5.3).
20
- //
21
- // Every other hub: `/<landingPage>/<entry>` for a listicle whose landing page
22
- // is a generic one-segment page (`/tools` → `[slug]/page.tsx`). The listing
23
- // extension (`lib/listings.tsx`) renders the accepted entry, or the route
24
- // 404s — with no key or no paid package it makes no read at all. The first
25
- // segment is the visitor's to choose, so the extension reads the directory
26
- // only once `/<slug>` is proved a page the `[slug]` route serves (a
27
- // LandingPage or BlogList source); a made-up hub costs no API read
28
- // (SEC-7521-D1). No MDX is read at `/<slug>/<detail>`, so no generic
29
- // two-segment content route exists: BookCall's slug pattern forbids "/", and
30
- // a generic join would also be reachable at a one-segment URL through the
31
- // `[slug]` route — a duplicate-content defect.
32
- //
33
- // Deliberately NO generateStaticParams, for the same reason as `[slug]/page.tsx`:
34
- // the locale layout reads cookies()/headers(), so this segment always renders
35
- // on request.
36
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
37
- import {
38
- getMdxSource as loadMdxSource,
39
- renderPage,
40
- renderPageMetadata,
41
- } from "@working-theory/page-renderer";
42
- import type { Metadata } from "next";
43
- import { notFound } from "next/navigation";
44
- import type { ReactElement } from "react";
45
-
46
- import { listingExtension, type HubExists } from "../../../../lib/listings";
47
- import { MEET_PLACEHOLDER_HUB } from "../../../../lib/meet-placeholder";
48
-
49
- /** Whether `/<slug>` is a page the one-segment `[slug]` route would serve. */
50
- function hubPage(
51
- slug: string,
52
- locale: string,
53
- getMdxSource: typeof defaultGetMdxSource = loadMdxSource,
54
- ): HubExists {
55
- return async () =>
56
- (await getMdxSource("LandingPage", slug, locale)) !== null ||
57
- (await getMdxSource("BlogList", slug, locale)) !== null;
58
- }
59
-
60
- /** The Event `detail` when it names `slug` as its program and `/<slug>` is a LandingPage. */
61
- async function programEvent(
62
- slug: string,
63
- detail: string,
64
- locale: string,
65
- getMdxSource: typeof defaultGetMdxSource = loadMdxSource,
66
- ): Promise<Awaited<ReturnType<typeof defaultGetMdxSource>>> {
67
- const source = await getMdxSource("Event", detail, locale);
68
- if (source === null || source.frontmatter.parent !== slug) return null;
69
- return (await getMdxSource("LandingPage", slug, locale)) === null ? null : source;
70
- }
71
-
72
- interface Props {
73
- params: Promise<{ locale: string; slug: string; detail: string }>;
74
- /** Test-only DI override for getMdxSource. Production callers leave undefined. */
75
- getMdxSource?: typeof defaultGetMdxSource;
76
- }
77
-
78
- export async function generateMetadata({
79
- params,
80
- getMdxSource,
81
- }: Pick<Props, "params" | "getMdxSource">): Promise<Metadata> {
82
- const { locale, slug, detail } = await params;
83
- // Mirrors renderPageMetadata's own missing-frontmatter → {} contract: a
84
- // hub with no listing entry is the same "nothing to title" case, not a
85
- // thrown 404 — generateMetadata cannot itself change the response status.
86
- if (slug !== MEET_PLACEHOLDER_HUB) {
87
- if ((await programEvent(slug, detail, locale, getMdxSource)) !== null) {
88
- return renderPageMetadata({
89
- type: "Event",
90
- slug: detail,
91
- locale,
92
- ...(getMdxSource !== undefined && { getMdxSource }),
93
- });
94
- }
95
- return (
96
- (await listingExtension.entryMetadataAt(
97
- `/${slug}/${detail}`,
98
- detail,
99
- locale,
100
- hubPage(slug, locale),
101
- )) ?? {}
102
- );
103
- }
104
- return renderPageMetadata({ type: "BookCall", slug: detail, locale });
105
- }
106
-
107
- export default async function Page({
108
- params,
109
- getMdxSource,
110
- }: Props): Promise<ReactElement> {
111
- const { locale, slug, detail } = await params;
112
- if (slug !== MEET_PLACEHOLDER_HUB) {
113
- const event = await programEvent(slug, detail, locale, getMdxSource);
114
- if (event !== null) {
115
- // A composed Event renders its sections; a prose one its MDX body — the
116
- // rule events/[slug]/page.tsx applies.
117
- const sections = (event.frontmatter as { sections?: unknown[] }).sections;
118
- const composed = Array.isArray(sections) && sections.length > 0;
119
- return renderPage({
120
- type: "Event",
121
- slug: detail,
122
- locale,
123
- ...(composed ? {} : { bodyMode: "mdx-body" as const }),
124
- ...(getMdxSource !== undefined && { getMdxSource }),
125
- });
126
- }
127
- const entry = await listingExtension.entryAt(
128
- `/${slug}/${detail}`,
129
- detail,
130
- locale,
131
- hubPage(slug, locale, getMdxSource),
132
- );
133
- if (entry === null) notFound();
134
- return entry;
135
- }
136
- return renderPage({
137
- type: "BookCall",
138
- slug: detail,
139
- locale,
140
- populatedDescriptionTestId: `${detail}-description`,
141
- ...(getMdxSource !== undefined && { getMdxSource }),
142
- });
143
- }