create-ailk 0.46.1 → 0.46.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component-catalog.json +389 -4
- package/component-catalog.md +9 -7
- package/dist/surfaces.js +1 -1
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +156 -2
- package/templates/apps/web/app/globals.css +12 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +4 -0
- package/templates/apps/web/app/llms.txt/route.ts +22 -0
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +4 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +43 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +170 -1
- package/templates/apps/web/lib/__tests__/magnet-addresses.test.ts +406 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +822 -4
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +383 -0
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +44 -0
- package/templates/apps/web/lib/in-page-magnet.ts +86 -9
- package/templates/apps/web/lib/magnet-addresses.ts +317 -0
- package/templates/apps/web/lib/offerings-pricing.ts +477 -40
- package/templates/apps/web/lib/paid-section-contracts.ts +41 -1
- package/templates/apps/web/lib/pricing-page.ts +248 -13
- package/templates/apps/web/lib/served-pages.ts +38 -1
- package/templates/apps/web/messages/en.json +2 -1
- package/templates/apps/web/site-pages.config.tsx +9 -0
- package/versions.json +50 -50
|
@@ -68,7 +68,7 @@ Don't ship a page after one render. The expected per-page loop:
|
|
|
68
68
|
|
|
69
69
|
## Where the base pages live
|
|
70
70
|
|
|
71
|
-
**The base website's pages ship in `@working-theory/site-pages` (#11259, ADR 0040 phase 4).** The home page and the
|
|
71
|
+
**The base website's pages ship in `@working-theory/site-pages` (#11259, ADR 0040 phase 4).** The home page and the 64 pages under the 39 base directories (`[slug]`, `about`, … `working-agreement`, `(authed)/leads`) — with the actions, loaders and libs only they read (`hub-children`, `route-family`, `service-listing`, `template-listing`, `meet-placeholder`, `posting-title`, `lead-write`) and their tests — live in `packages/site-pages/src/{pages,lib}/`, at the paths they had here. This app's `app/[locale]/` holds only the 65 route files `create-ailk routes --write` generates from the package's `routes.json` — never hand-edited, pinned by `routes --check` — plus the module routes under those directories (`careers/apply` and `careers/[slug]/apply`, generated from `@working-theory/ui-signal-collectors` since #11657; `projects/apply`) and `contact/error.tsx`. The package reads the site through one typed file, `site-pages.config.tsx`, whose `site` export answers the `@working-theory/site-pages/site` seam (`next.config.mjs` and `jest.config.cjs` alias it); no page takes a customization option. The ten namespaces those pages read ship in the package (`sitePagesMessages`), merged under this app's catalog by `i18n/request.ts`; a key in `messages/en.json` is an override. `lib/site-contact-email.ts` and `lib/site-contact-lines.ts` (the `_site.mdx` readers the layout and the module pages share) stay the site's. The sections below name the pages by their old `app/[locale]/` place.
|
|
72
72
|
|
|
73
73
|
## The `(auth)` route group — which predicate an affordance keys on
|
|
74
74
|
|
|
@@ -556,6 +556,49 @@ Every multi-step magnet is a page pair (#8840), rendered by one module,
|
|
|
556
556
|
(#8840)` marker, which `lib/__tests__/structured-data.test.tsx` exempts
|
|
557
557
|
from its `renderPage` check. A site adds a magnet by binding a pair to a
|
|
558
558
|
slug, never by copying stepper code.
|
|
559
|
+
- **An owner-chosen address (#12204).** A magnet whose `landingPage` is an
|
|
560
|
+
address — `magnetAddressOf` (`@working-theory/validation`): one or two
|
|
561
|
+
lower-case kebab segments, no reserved first segment, not a listicle's list
|
|
562
|
+
page and not a built-in page that mounts it (`/contact`, `/newsletter`,
|
|
563
|
+
`/trial`, `/careers`) — is served there: its cover at `/<address>`, its walk
|
|
564
|
+
at `/<address>/start` (chrome-free by `isMagnetWalkPath`'s `start` rule), its
|
|
565
|
+
verify page and its `results/<payload>`. `lib/magnet-addresses.ts` is the one
|
|
566
|
+
reader of the hub's table, `GET /v1/flow-addresses` (`flows.addresses()`):
|
|
567
|
+
shared per instance for 15 seconds, a failed read held for that window and
|
|
568
|
+
answered with the last good table, an older hub's 404 read as none, and no
|
|
569
|
+
read at all on a site without `@working-theory/ui-signal-collectors`. It
|
|
570
|
+
serves an address only when nothing on the site claims it first — a static
|
|
571
|
+
route, a reserved segment, an enabled locale, the docs or services base, a
|
|
572
|
+
renamed family, a `LandingPage` or `BlogList` at its first segment, or,
|
|
573
|
+
under the database adapter, a recorded page redirect. The `[slug]`,
|
|
574
|
+
`[slug]/[detail]` and `[slug]/[detail]/[...rest]` pages ask
|
|
575
|
+
`site.magnetAddress` (`site-pages.config.tsx`) only after their own reads
|
|
576
|
+
miss, so a content page always wins. `/flows/<slug>` and its children
|
|
577
|
+
forward to the same child under the address, query kept
|
|
578
|
+
(`site.servedMagnetAddress`, `signal-collectors.config.tsx`); the cover's
|
|
579
|
+
canonical is the address; `/sitemap.xml` and both `/llms.txt` copies list
|
|
580
|
+
it, the hub-listed (visitor) magnets only, and never `/flows/<slug>`
|
|
581
|
+
(`getMagnetAddresses`, default `servedAddresses`). A changed address 404s at
|
|
582
|
+
its old path once the window passes; `/flows/<slug>` always leads to the
|
|
583
|
+
current one.
|
|
584
|
+
- **A magnet inside a page (#12205).** A page section `{ type: "magnet",
|
|
585
|
+
data: { slug } }`, on any page type that takes sections, shows that magnet's
|
|
586
|
+
title card (its landing title, description, Start and time line) between
|
|
587
|
+
the page's own sections; Start opens the magnet's walk — `FlowStepperClient`,
|
|
588
|
+
as `/flows/<slug>/start` mounts it, booking calendar included — in the
|
|
589
|
+
takeover window over the page, at the page's URL, with every other child of
|
|
590
|
+
`<body>` inert, and Esc or the exit closes it in place. Its ending,
|
|
591
|
+
thank-you page and lead are the magnet's own. `renderPage` asks the renderer
|
|
592
|
+
`lib/in-page-magnet.ts` registers (`setMagnetSectionRenderer`) once per slug
|
|
593
|
+
and puts its node into the section through `sectionSlots`; that renderer
|
|
594
|
+
reads the magnet through `readServedMagnet` (15 s share, 2,000 ms deadline;
|
|
595
|
+
page-renderer's backstop is 3,000 ms) and loads `MagnetSectionClient` and
|
|
596
|
+
`bookingStepElement` through `loadUiSignalCollectors()`. A missing, draft or
|
|
597
|
+
deliverable magnet, a body that is not a served flow, a site without the
|
|
598
|
+
package, or any failure removes the section — never a broken form — and a
|
|
599
|
+
page with no `magnet` section reads nothing. The hub refuses a save naming
|
|
600
|
+
a slug the workspace has no magnet at (a slug the draft already holds is
|
|
601
|
+
not re-checked).
|
|
559
602
|
- **The recommender's landing (#9071).** A recommending flow with an offer
|
|
560
603
|
carrying `lookupKey` (an Offerings recommender, such as the standard
|
|
561
604
|
`recommender` magnet the Admin's Offerings page opens) never renders its
|
|
@@ -673,6 +716,105 @@ key), so the page names none. It renders one of three pages:
|
|
|
673
716
|
path written sections give way with the rest. A site whose
|
|
674
717
|
`@working-theory/validation` predates the field strips it and renders the
|
|
675
718
|
section as before, so a seller sets `source` after the site updates.
|
|
719
|
+
- **Level cards and written cards on a bound section (#12174).** A bound
|
|
720
|
+
plans section may set `offeringGroups` in place of `offeringPlans`: each
|
|
721
|
+
group (`key`, `name`, optional `description`, two to four `levels` of
|
|
722
|
+
`{ label, plan }`) becomes one card with a level switch, titled by `name`
|
|
723
|
+
and with its segments labelled by each level's `label` — page content,
|
|
724
|
+
never the Stripe product name or description. A level shows its plan's
|
|
725
|
+
price, note, features and checkout link, as that plan's own card would;
|
|
726
|
+
the card's own fields are its first level's (what the `Offer` reads), a
|
|
727
|
+
level whose plan is not shown is dropped, and a group with none left gives
|
|
728
|
+
no card. The groups' plans are left out of the unbound plans slot, and a
|
|
729
|
+
`?plan=` naming one of them highlights its card. `writtenPlans` (one to
|
|
730
|
+
three written cards) go after the Offerings cards in the same grid — only
|
|
731
|
+
in the toggle, `with-comparison-table` and `band-hero` layouts, which
|
|
732
|
+
render every card — minus any that links `/api/offerings/checkout`, as a
|
|
733
|
+
written section's cards are; when no group yields a card, the written
|
|
734
|
+
cards stand alone and the section stays. `levelSwitchPlacement:
|
|
735
|
+
title-row` moves the switch onto the title's row (default card layout
|
|
736
|
+
only). An unconnected page renders the authored `plans` and reads neither
|
|
737
|
+
field. The schema refuses both fields on a section that is not
|
|
738
|
+
`source: offerings`.
|
|
739
|
+
- **Cards built from Stripe (#12193).** A bound section that names no plans
|
|
740
|
+
— no `offeringPlans`, no `offeringGroups` — builds its cards from Stripe
|
|
741
|
+
metadata alone: plain plans sharing an `ailk_tier` become one level card
|
|
742
|
+
titled with the tier, each level labelled by its `ailk_level`, ordered by
|
|
743
|
+
`ailk_order` and described by its own Stripe description (a level with none
|
|
744
|
+
shows none); a plan with no tier is titled `ailk_name ?? name`, on every
|
|
745
|
+
plan card and add-on tile, while checkout and the Admin keep the Stripe
|
|
746
|
+
name. `offeringCollection` (a plans or `addons` section) shows every shown
|
|
747
|
+
product whose `ailk_collection` matches it, lowercased, and those plans
|
|
748
|
+
leave the unbound slot. A **contact** — a plan or add-on product with no
|
|
749
|
+
Price, an `https:` Stripe URL and an `ailk_plan` slug, switched on in Stripe
|
|
750
|
+
products and shown from its Offerings row — renders in a collection
|
|
751
|
+
section as a contact card or tile: `ailk_price_text` or the translated
|
|
752
|
+
`pricingOfferings.custom` in the price slot, `ailk_cta` on its button, and
|
|
753
|
+
its URL as the link (internal for a same-origin single-slash path, no card
|
|
754
|
+
for a same-origin `/api/` path or one that will not decode, else a new
|
|
755
|
+
tab); it publishes no `Offer`. A lone plan card or add-on tile spans the
|
|
756
|
+
section as the split card; every pricing surface takes its corners from
|
|
757
|
+
`--radius-card`. The toggle opens on Annually, a per-month price from a
|
|
758
|
+
yearly one is whole dollars, and `hideBillingToggle` turns the toggle off
|
|
759
|
+
(a stored `billingToggle: false` on a bound section still hides nothing).
|
|
760
|
+
`?plan=<slug>` opens that level and `?billing=monthly|annual` that period
|
|
761
|
+
in the server HTML, through the render-time `selectedPlan` and
|
|
762
|
+
`billingPeriod`; the JSON-LD lists one `Offer` per level and period from
|
|
763
|
+
the render-time `offerPrices`, each with its billing duration and a
|
|
764
|
+
`?plan=` / `&billing=` URL. No authored copy of a render-time field reaches
|
|
765
|
+
a section. A site and its MCP server take this release with or before
|
|
766
|
+
their hub; a priceless product shows only once it carries `ailk_plan`.
|
|
767
|
+
- **The level card's settings (#12209).** A level card's switch is
|
|
768
|
+
segments (the default) or the Select primitive: `levelSwitchControl` on
|
|
769
|
+
the section, on a written card, or on an `offeringGroups` entry, the card's
|
|
770
|
+
winning; a card with more than four levels takes the select whatever it
|
|
771
|
+
says, and the schema refuses five or more levels on a card whose control
|
|
772
|
+
resolves to segments. A card takes up to 20 levels, and a selecting bound
|
|
773
|
+
section whose `levelSwitchControl` is `select` keeps up to 20 of a tier's
|
|
774
|
+
plans (four otherwise). `levelSwitchPlacement` adds `beside-price` (the end
|
|
775
|
+
of the price line) and `above-button`; a card too narrow for its
|
|
776
|
+
`beside-price` control (under 28rem) or its `title-row` select (under 24rem)
|
|
777
|
+
shows it in its own row through CSS container queries, never a script.
|
|
778
|
+
`levelSwitchDetail: "price"` puts each select item's price for the shown
|
|
779
|
+
period on its row, and a written level's `detail` is its own secondary
|
|
780
|
+
label. Helper text under the switch is page text on a written card
|
|
781
|
+
(`plans[].levelHelper`, a level's `helper` over it) and the plan product's
|
|
782
|
+
Stripe `ailk_helper` (40 characters, read on a plan only) on a card built
|
|
783
|
+
from Stripe; one helper for every level of a Stripe tier card means the same
|
|
784
|
+
`ailk_helper` on each of its products. It is never the unit label.
|
|
785
|
+
`showLevelHeading` shows the chosen level's label and description under the
|
|
786
|
+
line that follows the price in place of row 2, and that line — "billed …
|
|
787
|
+
yearly" — now shows only under an annual price. `separateTiers: true` on a
|
|
788
|
+
selecting bound section shows every plan as its own card, whatever its
|
|
789
|
+
`ailk_tier`. The section keeps `levelSwitchControl`, `levelSwitchDetail` and
|
|
790
|
+
`showLevelHeading`; `separateTiers` is read before mapping and never placed.
|
|
791
|
+
A seller sets `ailk_helper` only after every site and MCP server reading
|
|
792
|
+
that workspace has taken this release with or before its hub: an older
|
|
793
|
+
site's strict shown-set readers refuse a product carrying `switchHelper`
|
|
794
|
+
and show the contact email in place of its Stripe cards. Rolling the hub
|
|
795
|
+
back past this release after a snapshot with the key was written reads
|
|
796
|
+
that snapshot as empty until the bounded refresh rewrites it.
|
|
797
|
+
- **Several prices on one Stripe product (#12210).** A `plan` product may
|
|
798
|
+
carry several prices for one billing period, each a price point with its
|
|
799
|
+
own `{plan}` slug (its lookup key's `{plan}`, so the grammar is unchanged);
|
|
800
|
+
the normalizer keeps up to 20, ordered by period then amount, and reads
|
|
801
|
+
each price's `nickname` (24 characters, on such a product only) as the
|
|
802
|
+
point's label. `lib/offerings-pricing.ts` turns each point into a level of
|
|
803
|
+
the existing level card: its amount, label (the nickname, else its price
|
|
804
|
+
phrase) and checkout link come from the price, its title, description and
|
|
805
|
+
features from the product, and the price phrase is the select item's
|
|
806
|
+
`detail`. A product with points is one card, a tier may mix products and
|
|
807
|
+
points, a card holds at most 20 levels and one with points and more than
|
|
808
|
+
four takes the select. A product is matched by any of its slugs, so
|
|
809
|
+
`plans`, `offeringPlans`, `offeringGroups` and `?plan=` may name any point;
|
|
810
|
+
a bundle requiring a point's slug gives no card. The JSON-LD lists one
|
|
811
|
+
`Offer` per point and period. A shown period shows every point of that
|
|
812
|
+
period, so a price added in Stripe shows and sells with no page edit, Admin
|
|
813
|
+
action or deploy. A product with one price per period renders exactly as
|
|
814
|
+
before. A seller adds a second slug only after every site and MCP server
|
|
815
|
+
reading that workspace has taken this release with or before its hub: an
|
|
816
|
+
older site's strict shown-set readers refuse such a product and show the
|
|
817
|
+
contact email in place of its Stripe cards.
|
|
676
818
|
- **Rollout of the two keys (#12103 D8).** A site's strict shown-set readers
|
|
677
819
|
refuse a product carrying `ctaLabel` or `eyebrow` until they take this
|
|
678
820
|
release, and such a site then shows the contact email in place of its
|
|
@@ -878,7 +1020,19 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
|
|
|
878
1020
|
- Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
|
|
879
1021
|
- Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
|
|
880
1022
|
|
|
881
|
-
Last updated: 2026-11-
|
|
1023
|
+
Last updated: 2026-11-22 — § Pricing page: several prices on one Stripe product — price points, their levels, labels and `detail`, slug matching, one `Offer` per point and the shown-period rule (#12210) — verified against `lib/offerings-pricing.ts`, `packages/api/src/services/offerings/{catalog,index}.ts` and `packages/validation/src/schemas/offerings.ts`.
|
|
1024
|
+
|
|
1025
|
+
Prior: 2026-11-22 — § Pricing page: the level card's settings — the select control, the four placements and their container-query fallback, helper text and `ailk_helper`, the level heading, the annual-only yearly line, 20 levels and `separateTiers` (#12209) — verified against `lib/pricing-page.ts`, `lib/offerings-pricing.ts`, `packages/validation/src/schemas/page-sections.ts` and `packages/ui/src/blocks/PricingTierCard.tsx`.
|
|
1026
|
+
|
|
1027
|
+
Prior: 2026-11-22 — § Magnet pages: a magnet inside a page — the `magnet` section, its renderer seam, the walk over the host page and its fallbacks (#12205) — verified against `lib/in-page-magnet.ts`, `packages/page-renderer/src/magnet-sections.ts` and `packages-paid/ui-signal-collectors/src/pages/flows/[slug]/MagnetSectionClient.tsx`.
|
|
1028
|
+
|
|
1029
|
+
Prior: 2026-11-22 — § Pricing page: cards built from Stripe — tier cards, `ailk_name` titles, `offeringCollection`, contact cards and tiles, the lone wide card, annual first, `hideBillingToggle`, `?billing=` and one `Offer` per level and period (#12193) — verified against `lib/pricing-page.ts`, `lib/offerings-pricing.ts` and `packages/sections-registry/src/contributions.ts`.
|
|
1030
|
+
|
|
1031
|
+
Prior: 2026-11-22 — § Magnet pages: an owner-chosen address — the hub's address table, the shadow rule, the catch-all serving, the `/flows/<slug>` forward and the discovery entries; § Where the base pages live: 65 generated route files (#12204) — verified against `lib/magnet-addresses.ts`, `lib/served-pages.ts`, `site-pages.config.tsx`, `signal-collectors.config.tsx`, `app/{sitemap.xml,llms.txt}/route.ts`, `lib/slices/docs-blog/llms-route.ts` and `packages/site-pages/routes.json`.
|
|
1032
|
+
|
|
1033
|
+
Prior: 2026-11-22 — § Pricing page: a bound section's `offeringGroups` level cards, its `writtenPlans` and `levelSwitchPlacement` (#12174) — verified against `lib/pricing-page.ts` and `lib/offerings-pricing.ts`.
|
|
1034
|
+
|
|
1035
|
+
Prior: 2026-11-21 — § Pricing page: a section's `source` — bound sections in the layout their `variant` names, the `features-and-plans` two-block split, the kept comparison grid, written sections, and the 0.74.0 page with no `source` (#12140) — verified against `lib/pricing-page.ts` and `lib/offerings-pricing.ts`.
|
|
882
1036
|
|
|
883
1037
|
Prior: 2026-11-21 — § Pricing page: a section's `offeringPlans` plan groups, the kept `cardLayout`, the Admin-set Recommended, the `ailk_cta` button label and the add-on's `ailk_eyebrow` and note, and the two keys' rollout order (#12103) — verified against `lib/pricing-page.ts`, `lib/offerings-pricing.ts`, `packages/api/src/services/offerings/catalog.ts` and `packages-paid/api-multi-tenant/src/routes/workspaces/offerings.ts`.
|
|
884
1038
|
|
|
@@ -24,12 +24,24 @@
|
|
|
24
24
|
* the packages arrive from the registry. The node_modules path resolves in both
|
|
25
25
|
* trees — a workspace symlink here, a real install there — so one directive
|
|
26
26
|
* serves both (#4090 item 1).
|
|
27
|
+
*
|
|
28
|
+
* The four paid UI packages (the `paidSectionsPackage` of each module slice in
|
|
29
|
+
* packages/create-ailk/src/module-architecture.ts) render through
|
|
30
|
+
* node_modules too, so each needs its own line, or the classes only it uses
|
|
31
|
+
* are purged: the booker's meta row, card inset and confirm gap in
|
|
32
|
+
* ui-scheduling (#12202). A site without a module has no such directory, and
|
|
33
|
+
* Tailwind v4 skips an @source path that does not exist, so one static list
|
|
34
|
+
* serves every module set.
|
|
27
35
|
*/
|
|
28
36
|
|
|
29
37
|
@import "tailwindcss";
|
|
30
38
|
|
|
31
39
|
@source "../node_modules/@working-theory/ui/dist";
|
|
32
40
|
@source "../node_modules/@working-theory/templates/dist";
|
|
41
|
+
@source "../node_modules/@working-theory/ui-docs-blog/dist";
|
|
42
|
+
@source "../node_modules/@working-theory/ui-scheduling/dist";
|
|
43
|
+
@source "../node_modules/@working-theory/ui-signal-collectors/dist";
|
|
44
|
+
@source "../node_modules/@working-theory/ui-commerce/dist";
|
|
33
45
|
|
|
34
46
|
@import "@working-theory/theme/tokens.css";
|
|
35
47
|
@import "@working-theory/theme/tailwind-preset/index.css";
|
|
@@ -44,6 +44,10 @@ jest.mock("next/cache", () => ({
|
|
|
44
44
|
unstable_cache: (fn: () => Promise<unknown>) => fn,
|
|
45
45
|
}));
|
|
46
46
|
|
|
47
|
+
// #12204 D8 — no magnet address, so no hub read and the bodies are unchanged.
|
|
48
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: the address table's one reader; mocked so no case reads a hub or loads the paid package (#12204)
|
|
49
|
+
jest.mock("../../../lib/magnet-addresses", () => ({ servedAddresses: async () => [] }));
|
|
50
|
+
|
|
47
51
|
type Route = typeof import("../route");
|
|
48
52
|
|
|
49
53
|
const BASE = "https://example.com";
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
* Agent contact (#11423): on a site that serves `/contact` (`MARKETING_PAGES`),
|
|
33
33
|
* the body ends with `agentContactLines` — the operator's decision of
|
|
34
34
|
* 2026-11-11 on #11423.
|
|
35
|
+
*
|
|
36
|
+
* Magnet addresses (#12204 D8): after the content pages, one entry per
|
|
37
|
+
* default-locale address the site serves and the hub lists, never
|
|
38
|
+
* `/flows/<slug>` (`getMagnetAddresses`, default `servedAddresses`).
|
|
35
39
|
*/
|
|
36
40
|
|
|
37
41
|
import {
|
|
@@ -44,6 +48,7 @@ import {
|
|
|
44
48
|
listedPath,
|
|
45
49
|
type SiteListing,
|
|
46
50
|
} from "@working-theory/page-renderer";
|
|
51
|
+
import { magnetAddressLine, type FlowAddressItem } from "@working-theory/validation";
|
|
47
52
|
|
|
48
53
|
import {
|
|
49
54
|
adapterDocsUrl,
|
|
@@ -51,6 +56,7 @@ import {
|
|
|
51
56
|
listDocsPages,
|
|
52
57
|
type DocsIndexPage,
|
|
53
58
|
} from "../../lib/docs-index";
|
|
59
|
+
import { servedAddresses } from "../../lib/magnet-addresses";
|
|
54
60
|
import { MARKETING_PAGES, PUBLIC_PAGES } from "../../lib/modules.generated";
|
|
55
61
|
import { resolveSiteBrand } from "../../lib/site-brand";
|
|
56
62
|
import { SITE_LISTING } from "../../lib/site-listing";
|
|
@@ -83,6 +89,8 @@ export interface LlmsHandlerDeps {
|
|
|
83
89
|
getSiteListing?: () => SiteListing;
|
|
84
90
|
/** Whether this site serves /contact (#11423). Defaults to `MARKETING_PAGES`. */
|
|
85
91
|
hasContactPage?: () => boolean;
|
|
92
|
+
/** The magnet addresses served in a locale (#12204 D8). Defaults to `servedAddresses`. */
|
|
93
|
+
getMagnetAddresses?: (locale: string) => Promise<readonly FlowAddressItem[]>;
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -96,6 +104,7 @@ export function createLlmsHandler(deps: LlmsHandlerDeps = {}) {
|
|
|
96
104
|
const isDiscoverable = deps.discoverable ?? siteLive;
|
|
97
105
|
const resolveSiteListing = deps.getSiteListing ?? (() => SITE_LISTING);
|
|
98
106
|
const resolveHasContactPage = deps.hasContactPage ?? (() => MARKETING_PAGES);
|
|
107
|
+
const resolveMagnetAddresses = deps.getMagnetAddresses ?? servedAddresses;
|
|
99
108
|
|
|
100
109
|
return async function llmsGET(): Promise<Response> {
|
|
101
110
|
// #10040 decision 7 — no public page, no content index: 404 before the adapter.
|
|
@@ -142,6 +151,19 @@ export function createLlmsHandler(deps: LlmsHandlerDeps = {}) {
|
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
|
|
154
|
+
// #12204 D8 — the magnet addresses the site serves and the hub lists, at
|
|
155
|
+
// their one URL; title and purpose collapsed to one line again here
|
|
156
|
+
// (SEC-12204-1), whatever the hub sent.
|
|
157
|
+
const addresses = await resolveMagnetAddresses(defaultLocale).catch(() => []);
|
|
158
|
+
for (const item of addresses) {
|
|
159
|
+
if (!item.listed) continue;
|
|
160
|
+
lines.push(`- Title: ${magnetAddressLine(item.title)}`);
|
|
161
|
+
lines.push(` URL: ${baseUrl}${item.path}`);
|
|
162
|
+
const purpose = magnetAddressLine(item.purpose);
|
|
163
|
+
if (purpose) lines.push(` Description: ${purpose}`);
|
|
164
|
+
lines.push("");
|
|
165
|
+
}
|
|
166
|
+
|
|
145
167
|
// Fumadocs blog corpus — blog index entry first, then per-post entries.
|
|
146
168
|
// blogSource.getPages() returns pages ordered by Fumadocs; the index page
|
|
147
169
|
// (/blog) sorts first naturally because its slug array is empty.
|
|
@@ -24,6 +24,10 @@ jest.mock("../../../lib/modules.generated", () => ({
|
|
|
24
24
|
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
|
|
25
25
|
jest.mock("../../../lib/site-listing", () => ({ __esModule: true, SITE_LISTING: {} }));
|
|
26
26
|
|
|
27
|
+
// #12204 D8 — no magnet address, so no hub read and the bodies are unchanged.
|
|
28
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: the address table's one reader; mocked so no case reads a hub or loads the paid package (#12204)
|
|
29
|
+
jest.mock("../../../lib/magnet-addresses", () => ({ servedAddresses: async () => [] }));
|
|
30
|
+
|
|
27
31
|
import { createSitemapHandler } from "../route";
|
|
28
32
|
|
|
29
33
|
const BASE = "https://example.com";
|
|
@@ -35,6 +35,12 @@
|
|
|
35
35
|
* `DocsDetail` rows, so those rows are listed at the docs path; otherwise
|
|
36
36
|
* those rows are skipped (the MDX docs route never serves them) and the docs
|
|
37
37
|
* directory is listed instead (`getDocsPages`, default `listDocsPages`).
|
|
38
|
+
*
|
|
39
|
+
* Magnet addresses (#12204 D8): after the content pages, one entry per
|
|
40
|
+
* (enabled locale, address the site serves in that locale) — only addresses
|
|
41
|
+
* the hub lists (`listed`), never `/flows/<slug>` — with alternates over the
|
|
42
|
+
* locales it is served in and `lastmod` the magnet's last change
|
|
43
|
+
* (`getMagnetAddresses`, default `servedAddresses`).
|
|
38
44
|
*/
|
|
39
45
|
|
|
40
46
|
import {
|
|
@@ -47,6 +53,7 @@ import {
|
|
|
47
53
|
listedPath,
|
|
48
54
|
type SiteListing,
|
|
49
55
|
} from "@working-theory/page-renderer";
|
|
56
|
+
import type { FlowAddressItem } from "@working-theory/validation";
|
|
50
57
|
|
|
51
58
|
import {
|
|
52
59
|
adapterDocsUrl,
|
|
@@ -54,6 +61,7 @@ import {
|
|
|
54
61
|
listDocsPages,
|
|
55
62
|
type DocsIndexPage,
|
|
56
63
|
} from "../../lib/docs-index";
|
|
64
|
+
import { servedAddresses } from "../../lib/magnet-addresses";
|
|
57
65
|
import { PUBLIC_PAGES } from "../../lib/modules.generated";
|
|
58
66
|
import { SITE_LISTING } from "../../lib/site-listing";
|
|
59
67
|
import { siteLive } from "../../lib/site-visibility";
|
|
@@ -75,6 +83,8 @@ export interface SitemapHandlerDeps {
|
|
|
75
83
|
discoverable?: () => Promise<boolean>;
|
|
76
84
|
/** The site's own listing (#10940 D3). Defaults to `SITE_LISTING`. */
|
|
77
85
|
getSiteListing?: () => SiteListing;
|
|
86
|
+
/** The magnet addresses served in a locale (#12204 D8). Defaults to `servedAddresses`. */
|
|
87
|
+
getMagnetAddresses?: (locale: string) => Promise<readonly FlowAddressItem[]>;
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
function escapeXml(value: string): string {
|
|
@@ -112,6 +122,7 @@ export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
|
112
122
|
const resolveDocsPages = deps.getDocsPages ?? listDocsPages;
|
|
113
123
|
const isDiscoverable = deps.discoverable ?? siteLive;
|
|
114
124
|
const resolveSiteListing = deps.getSiteListing ?? (() => SITE_LISTING);
|
|
125
|
+
const resolveMagnetAddresses = deps.getMagnetAddresses ?? servedAddresses;
|
|
115
126
|
return async function sitemapGET(): Promise<Response> {
|
|
116
127
|
// #10040 decision 7 — no public page, no sitemap: 404 before the adapter.
|
|
117
128
|
if (!PUBLIC_PAGES) return new Response(null, { status: 404 });
|
|
@@ -188,6 +199,38 @@ export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
201
|
|
|
202
|
+
// #12204 D8 — the magnet addresses: listed ones only, each at the one URL
|
|
203
|
+
// per locale it is served at.
|
|
204
|
+
const addressLists = await Promise.all(
|
|
205
|
+
locales.map((locale) => resolveMagnetAddresses(locale).catch(() => [])),
|
|
206
|
+
);
|
|
207
|
+
const servedIn = new Map<string, string[]>();
|
|
208
|
+
for (let i = 0; i < locales.length; i++) {
|
|
209
|
+
for (const item of addressLists[i]!) {
|
|
210
|
+
if (item.listed) servedIn.set(item.path, [...(servedIn.get(item.path) ?? []), locales[i]!]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (let i = 0; i < locales.length; i++) {
|
|
214
|
+
const locale = locales[i]!;
|
|
215
|
+
for (const item of addressLists[i]!) {
|
|
216
|
+
if (!item.listed) continue;
|
|
217
|
+
const path = item.path;
|
|
218
|
+
const alternates = (servedIn.get(path) ?? [])
|
|
219
|
+
.map(
|
|
220
|
+
(alt) =>
|
|
221
|
+
` <xhtml:link rel="alternate" hreflang="${escapeXml(alt)}" href="${escapeXml(buildLocaleUrl(baseUrl, alt, defaultLocale, path))}"/>`,
|
|
222
|
+
)
|
|
223
|
+
.join("\n");
|
|
224
|
+
// x-default names the default-locale URL, so only where it is served.
|
|
225
|
+
const xDefault = (servedIn.get(path) ?? []).includes(defaultLocale)
|
|
226
|
+
? `\n <xhtml:link rel="alternate" hreflang="x-default" href="${escapeXml(buildLocaleUrl(baseUrl, defaultLocale, defaultLocale, path))}"/>`
|
|
227
|
+
: "";
|
|
228
|
+
urlEntries.push(
|
|
229
|
+
` <url>\n <loc>${escapeXml(buildLocaleUrl(baseUrl, locale, defaultLocale, path))}</loc>\n <lastmod>${item.updatedAt.slice(0, 10)}</lastmod>\n${alternates}${xDefault}\n </url>`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
191
234
|
if (!databaseDocs) {
|
|
192
235
|
for (const doc of resolveDocsPages()) pushDocsEntry(doc.url, today);
|
|
193
236
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { LeadCaptureForm } from "@working-theory/ui";
|
|
9
9
|
import {
|
|
10
10
|
contactFormFlowConfig,
|
|
11
|
+
flowConfigSchema,
|
|
11
12
|
newsletterFlowConfig,
|
|
12
13
|
type FlowConfig,
|
|
13
14
|
} from "@working-theory/validation";
|
|
@@ -17,7 +18,6 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
17
18
|
leads: { captureStatus: jest.fn() },
|
|
18
19
|
}));
|
|
19
20
|
|
|
20
|
-
// eslint-disable-next-line no-restricted-syntax -- test-seam mock: a "use server" boundary the module only binds
|
|
21
21
|
jest.mock("@working-theory/site-pages/pages/contact/contact.actions", () => ({
|
|
22
22
|
captureLeadAction: jest.fn(),
|
|
23
23
|
}));
|
|
@@ -263,3 +263,172 @@ describe("readServedMagnet", () => {
|
|
|
263
263
|
expect(await readServedMagnet("down")).toBeNull();
|
|
264
264
|
});
|
|
265
265
|
});
|
|
266
|
+
|
|
267
|
+
// ─── The magnet section's renderer (#12205 D4; AC-4, AC-5) ────────────────────
|
|
268
|
+
|
|
269
|
+
describe("renderMagnetSection", () => {
|
|
270
|
+
type Module = typeof import("../in-page-magnet");
|
|
271
|
+
|
|
272
|
+
const FIVE_TYPES: FlowConfig = flowConfigSchema.parse({
|
|
273
|
+
slug: "five-types",
|
|
274
|
+
defaultLocale: "en",
|
|
275
|
+
steps: [
|
|
276
|
+
{
|
|
277
|
+
key: "about",
|
|
278
|
+
type: "field",
|
|
279
|
+
copy: { title: { en: "About you" } },
|
|
280
|
+
fields: [
|
|
281
|
+
{ name: "email", inputType: "email", required: true, mapsTo: "email", copy: { label: { en: "Email" } } },
|
|
282
|
+
{ name: "site", inputType: "url", copy: { label: { en: "Site" } } },
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
key: "pace",
|
|
287
|
+
type: "segmentation",
|
|
288
|
+
copy: { title: { en: "Pace?" } },
|
|
289
|
+
questions: [{ name: "pace", options: [{ value: "fast", label: { en: "Fast" } }, { value: "slow", label: { en: "Slow" } }] }],
|
|
290
|
+
},
|
|
291
|
+
{ key: "note", type: "message", copy: { title: { en: "A note" } } },
|
|
292
|
+
{ key: "score", type: "aeo_score", copy: { title: { en: "Your score" } }, urlField: "site" },
|
|
293
|
+
{ key: "extra", type: "custom", copy: { title: { en: "Extra" } }, renderer: "extra" },
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
function StubLauncher(): null {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* A fresh copy of the module (its package load is memoized per process),
|
|
303
|
+
* with the site's package answering `ui`, and the registration spied.
|
|
304
|
+
*/
|
|
305
|
+
function load(ui: unknown): {
|
|
306
|
+
mod: Module;
|
|
307
|
+
get: jest.Mock;
|
|
308
|
+
loadUi: jest.Mock;
|
|
309
|
+
register: jest.Mock;
|
|
310
|
+
} {
|
|
311
|
+
jest.resetModules();
|
|
312
|
+
const loadUi = jest.fn(async () => ui);
|
|
313
|
+
const register = jest.fn();
|
|
314
|
+
jest.doMock("../paid-sections.generated", () => ({
|
|
315
|
+
...jest.requireActual("../paid-sections.generated"),
|
|
316
|
+
loadUiSignalCollectors: loadUi,
|
|
317
|
+
}));
|
|
318
|
+
jest.doMock("@working-theory/page-renderer", () => ({
|
|
319
|
+
...jest.requireActual("@working-theory/page-renderer"),
|
|
320
|
+
setMagnetSectionRenderer: register,
|
|
321
|
+
}));
|
|
322
|
+
const mod = require("../in-page-magnet") as Module;
|
|
323
|
+
const get = (require("@working-theory/api-client") as { flows: { get: jest.Mock } }).flows.get;
|
|
324
|
+
return { mod, get, loadUi, register };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
let warn: jest.SpyInstance;
|
|
328
|
+
beforeEach(() => {
|
|
329
|
+
warn = jest.spyOn(console, "warn").mockImplementation(() => {});
|
|
330
|
+
});
|
|
331
|
+
afterEach(() => {
|
|
332
|
+
warn.mockRestore();
|
|
333
|
+
jest.useRealTimers();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("registers itself with page-renderer at module load", () => {
|
|
337
|
+
const { mod, register } = load(null);
|
|
338
|
+
expect(register).toHaveBeenCalledWith(mod.renderMagnetSection);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it.each([
|
|
342
|
+
["absent or a draft (404)", (get: jest.Mock) => get.mockResolvedValueOnce({ ok: false, status: 404, body: {} })],
|
|
343
|
+
["a rejected read", (get: jest.Mock) => get.mockRejectedValueOnce(new Error("hub down"))],
|
|
344
|
+
["a 2xx that is not a served flow", (get: jest.Mock) => get.mockResolvedValueOnce({ ok: true, status: 200, body: { slug: "x" } })],
|
|
345
|
+
])("answers null for %s, and never loads the package", async (_name, arrange) => {
|
|
346
|
+
const { mod, get, loadUi } = load({ MagnetSectionClient: StubLauncher });
|
|
347
|
+
arrange(get);
|
|
348
|
+
expect(await mod.renderMagnetSection({ slug: "x", locale: "en" })).toBeNull();
|
|
349
|
+
expect(loadUi).not.toHaveBeenCalled();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it("answers null for a read that never settles, after 2,000 ms", async () => {
|
|
353
|
+
const { mod, get, loadUi } = load({ MagnetSectionClient: StubLauncher });
|
|
354
|
+
jest.useFakeTimers();
|
|
355
|
+
get.mockReturnValueOnce(new Promise(() => undefined));
|
|
356
|
+
const pending = mod.renderMagnetSection({ slug: "stalled", locale: "en" });
|
|
357
|
+
await jest.advanceTimersByTimeAsync(2_000);
|
|
358
|
+
expect(await pending).toBeNull();
|
|
359
|
+
expect(loadUi).not.toHaveBeenCalled();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("answers null for a deliverable magnet (its one route is /reports/<slug>)", async () => {
|
|
363
|
+
const { mod, get, loadUi } = load({ MagnetSectionClient: StubLauncher });
|
|
364
|
+
get.mockResolvedValueOnce({
|
|
365
|
+
ok: true,
|
|
366
|
+
status: 200,
|
|
367
|
+
body: { ...FIVE_TYPES, deliverable: { kind: "file", gated: true, copy: { title: { en: "Report" } } } },
|
|
368
|
+
});
|
|
369
|
+
expect(await mod.renderMagnetSection({ slug: "five-types", locale: "en" })).toBeNull();
|
|
370
|
+
expect(loadUi).not.toHaveBeenCalled();
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it.each([
|
|
374
|
+
["no package", null],
|
|
375
|
+
["a package without MagnetSectionClient", { flowsMessages: () => ({}) }],
|
|
376
|
+
])("answers null with %s", async (_name, ui) => {
|
|
377
|
+
const { mod, get } = load(ui);
|
|
378
|
+
get.mockResolvedValueOnce({ ok: true, status: 200, body: FIVE_TYPES });
|
|
379
|
+
expect(await mod.renderMagnetSection({ slug: "five-types", locale: "en" })).toBeNull();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("answers the package's launcher over the whole served config", async () => {
|
|
383
|
+
const { mod, get } = load({ MagnetSectionClient: StubLauncher });
|
|
384
|
+
get.mockResolvedValueOnce({ ok: true, status: 200, body: FIVE_TYPES });
|
|
385
|
+
const element = (await mod.renderMagnetSection({ slug: "five-types", locale: "fr" }))!;
|
|
386
|
+
expect(element.type).toBe(StubLauncher);
|
|
387
|
+
const props = element.props as Record<string, unknown>;
|
|
388
|
+
expect(props["config"]).toBe(FIVE_TYPES);
|
|
389
|
+
expect(props["slug"]).toBe("five-types");
|
|
390
|
+
expect(props["locale"]).toBe("fr");
|
|
391
|
+
expect(props["consentPolicies"]).toEqual(expect.any(Object));
|
|
392
|
+
expect(props["brand"]).toEqual({ logomark: expect.anything(), wordmark: expect.anything() });
|
|
393
|
+
expect(props).not.toHaveProperty("bookingStep");
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it("passes the booking step's calendar the package builds, when there is one", async () => {
|
|
397
|
+
const calendar = { type: "div", props: {} };
|
|
398
|
+
const bookingStepElement = jest.fn(async () => calendar);
|
|
399
|
+
const { mod, get } = load({ MagnetSectionClient: StubLauncher, bookingStepElement });
|
|
400
|
+
get.mockResolvedValueOnce({ ok: true, status: 200, body: FIVE_TYPES });
|
|
401
|
+
const element = (await mod.renderMagnetSection({ slug: "five-types", locale: "en" }))!;
|
|
402
|
+
expect(bookingStepElement).toHaveBeenCalledWith(FIVE_TYPES);
|
|
403
|
+
expect((element.props as Record<string, unknown>)["bookingStep"]).toBe(calendar);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("a throw past the read answers null with one warning that names nothing read", async () => {
|
|
407
|
+
const bookingStepElement = jest.fn(async () => {
|
|
408
|
+
throw new Error("five-types exploded");
|
|
409
|
+
});
|
|
410
|
+
const { mod, get } = load({ MagnetSectionClient: StubLauncher, bookingStepElement });
|
|
411
|
+
get.mockResolvedValueOnce({ ok: true, status: 200, body: FIVE_TYPES });
|
|
412
|
+
expect(await mod.renderMagnetSection({ slug: "five-types", locale: "en" })).toBeNull();
|
|
413
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
414
|
+
expect(warn).toHaveBeenCalledWith("[magnet-section] render failed; the section is removed");
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("rethrows Next's control flow", async () => {
|
|
418
|
+
const { redirect } = jest.requireActual("next/navigation") as typeof import("next/navigation");
|
|
419
|
+
let signal: unknown;
|
|
420
|
+
try {
|
|
421
|
+
redirect("/elsewhere");
|
|
422
|
+
} catch (err) {
|
|
423
|
+
signal = err;
|
|
424
|
+
}
|
|
425
|
+
const { mod, get } = load({
|
|
426
|
+
MagnetSectionClient: StubLauncher,
|
|
427
|
+
bookingStepElement: jest.fn(async () => {
|
|
428
|
+
throw signal;
|
|
429
|
+
}),
|
|
430
|
+
});
|
|
431
|
+
get.mockResolvedValueOnce({ ok: true, status: 200, body: FIVE_TYPES });
|
|
432
|
+
await expect(mod.renderMagnetSection({ slug: "five-types", locale: "en" })).rejects.toBe(signal);
|
|
433
|
+
});
|
|
434
|
+
});
|