create-ailk 0.46.4 → 0.46.6
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 +99 -8
- package/package.json +3 -3
- package/templates/apps/api/CLAUDE.md +6 -2
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -0
- package/templates/apps/web/CLAUDE.md +28 -4
- package/templates/apps/web/app/[locale]/layout.tsx +4 -0
- package/templates/apps/web/lib/__tests__/grid-read.test.ts +212 -0
- package/templates/apps/web/lib/__tests__/hub-read.test.ts +90 -0
- package/templates/apps/web/lib/__tests__/in-page-blocks.test.ts +261 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +89 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +210 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +18 -1
- package/templates/apps/web/lib/grid-read.ts +115 -0
- package/templates/apps/web/lib/hub-read.ts +35 -0
- package/templates/apps/web/lib/in-page-blocks.ts +119 -0
- package/templates/apps/web/lib/in-page-magnet.ts +5 -24
- package/templates/apps/web/lib/offerings-pricing.ts +12 -1
- package/templates/apps/web/lib/pricing-page.ts +33 -2
- package/templates/apps/web/messages/en.json +14 -0
- package/versions.json +50 -50
|
@@ -529,6 +529,15 @@ const NO_STRUCTURED_DATA_ROUTES: ReadonlyArray<{
|
|
|
529
529
|
route: "how-to",
|
|
530
530
|
reason: "hand-composed listing; no HowTo list type exists",
|
|
531
531
|
},
|
|
532
|
+
// #12204 D6 — the three-or-more-segment catch-all serves only a magnet's
|
|
533
|
+
// children at an owner-chosen address (its walk, verify and results pages)
|
|
534
|
+
// through `site.magnetAddress`, and reads no content. Keyed on that call, so
|
|
535
|
+
// a page that renders content here is checked like any other.
|
|
536
|
+
{
|
|
537
|
+
route: "[slug]/[detail]/[...rest]",
|
|
538
|
+
reason: "a magnet's children at its owner-chosen address (#12204 D6), served through site.magnetAddress; no content page behind it",
|
|
539
|
+
requires: ["site.magnetAddress.pageAt"],
|
|
540
|
+
},
|
|
532
541
|
{
|
|
533
542
|
route: "careers/[slug]/[action]",
|
|
534
543
|
reason: "the Free apply form for a posting; noindex, no JSON-LD (#8849 D7)",
|
|
@@ -1051,9 +1060,17 @@ describe("structured data — exemption(route, src) keys the generated checkout
|
|
|
1051
1060
|
expect(exemption("about", GENERATED_SRC)).toBeUndefined();
|
|
1052
1061
|
});
|
|
1053
1062
|
|
|
1063
|
+
it("exempts the magnet-address catch-all only while its page serves through site.magnetAddress (#12204 D6)", () => {
|
|
1064
|
+
const route = "[slug]/[detail]/[...rest]";
|
|
1065
|
+
const served = "const magnet = await site.magnetAddress.pageAt(\n [slug, detail, ...rest],";
|
|
1066
|
+
expect(exemption(route, served)).toContain("#12204 D6");
|
|
1067
|
+
expect(exemption(route, "")).toBeUndefined();
|
|
1068
|
+
expect(exemption(route, 'return renderPage({ type: "LandingPage", slug });')).toBeUndefined();
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1054
1071
|
it("every pre-existing entry still returns its reason for its own route with any src, subtree entries included", () => {
|
|
1055
1072
|
for (const entry of NO_STRUCTURED_DATA_ROUTES) {
|
|
1056
|
-
if (entry.requires !== undefined) continue; //
|
|
1073
|
+
if (entry.requires !== undefined) continue; // a conditional entry keys on its file; see its own case
|
|
1057
1074
|
expect(exemption(entry.route, "")).toBe(entry.reason);
|
|
1058
1075
|
if (entry.subtree === true) {
|
|
1059
1076
|
expect(exemption(`${entry.route}/child`, "")).toBe(entry.reason);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* grid-read.ts — the one read of an Offerings grid for a page (#12370, spec
|
|
3
|
+
* docs/specs/12370-a-comparison-table-reads-an-offerings-grid-spec.md D3),
|
|
4
|
+
* shared by its two callers: a `<Grid … />` block line (`in-page-blocks.ts`)
|
|
5
|
+
* and a `comparison-table` section's `grid` setting (`pricing-page.ts`). It
|
|
6
|
+
* imports neither, so the two can both import it.
|
|
7
|
+
*
|
|
8
|
+
* The public read, `GET /v1/content/grids/:kind/:slug`, goes through
|
|
9
|
+
* api-client `content.grid`, shared per instance for 15 s (`sharedHubRead`),
|
|
10
|
+
* is parsed by `GridAnswerSchema` and worded by
|
|
11
|
+
* `gridSection` with the page locale's `grids` messages — no English default
|
|
12
|
+
* reaches a page (#12222 D18). A read that fails, an answer that does not
|
|
13
|
+
* parse and an empty grid all answer `null`: the caller draws no table. The
|
|
14
|
+
* grid's data is never written anywhere: every render reads the published
|
|
15
|
+
* facts and Stripe's features afresh.
|
|
16
|
+
*
|
|
17
|
+
* The read itself carries no deadline. A block line is bounded by
|
|
18
|
+
* page-renderer's own 3,000 ms backstop; a section is bounded here, by
|
|
19
|
+
* `withinGridDeadline`, at the same 3,000 ms.
|
|
20
|
+
*/
|
|
21
|
+
import { content } from "@working-theory/api-client";
|
|
22
|
+
import {
|
|
23
|
+
GridAnswerSchema,
|
|
24
|
+
gridSection,
|
|
25
|
+
writeBlockLine,
|
|
26
|
+
type ComparisonGrid,
|
|
27
|
+
type GridAnswer,
|
|
28
|
+
type GridBlock,
|
|
29
|
+
type GridLabels,
|
|
30
|
+
type PageSection,
|
|
31
|
+
} from "@working-theory/validation";
|
|
32
|
+
import { getTranslations } from "next-intl/server";
|
|
33
|
+
|
|
34
|
+
import { sharedHubRead } from "./hub-read";
|
|
35
|
+
|
|
36
|
+
/** A grid as either caller names it: a block's fields, or a section's (the same, less `price` and `button`). */
|
|
37
|
+
export type GridSetting = GridBlock | ComparisonGrid;
|
|
38
|
+
|
|
39
|
+
/** A `comparison-table` section's data. */
|
|
40
|
+
export type GridTableData = Extract<PageSection, { type: "comparison-table" }>["data"];
|
|
41
|
+
|
|
42
|
+
/** How long a section waits on its grid before drawing no table: a block line's backstop (page-renderer). */
|
|
43
|
+
export const GRID_READ_DEADLINE_MS = 3_000;
|
|
44
|
+
|
|
45
|
+
/** `read`'s answer, or `null` once GRID_READ_DEADLINE_MS has passed or `read` rejects. */
|
|
46
|
+
export function withinGridDeadline<T>(read: Promise<T | null>): Promise<T | null> {
|
|
47
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
48
|
+
const late = new Promise<null>((resolve) => {
|
|
49
|
+
timer = setTimeout(() => resolve(null), GRID_READ_DEADLINE_MS);
|
|
50
|
+
});
|
|
51
|
+
return Promise.race([read.catch(() => null), late]).finally(() => clearTimeout(timer));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The grid read, or `null` for any failed read or an answer that does not parse. */
|
|
55
|
+
export function readGrid(grid: GridSetting, locale: string): Promise<GridAnswer | null> {
|
|
56
|
+
const key = `grid:${locale}:${writeBlockLine({ tag: "Grid", block: grid as GridBlock })}`;
|
|
57
|
+
return sharedHubRead(key, async () => {
|
|
58
|
+
try {
|
|
59
|
+
const res = await content.grid({
|
|
60
|
+
kind: grid.kind,
|
|
61
|
+
slug: grid.kind === "capabilities" ? grid.products.join(" ") : grid.category,
|
|
62
|
+
show: grid.show,
|
|
63
|
+
...(grid.kind === "capabilities" && grid.levels !== undefined ? { levels: grid.levels.join(" ") } : {}),
|
|
64
|
+
...(grid.kind === "alternatives" && grid.ours !== undefined ? { ours: grid.ours } : {}),
|
|
65
|
+
...(grid.kind === "alternatives" && grid.columns !== undefined ? { columns: grid.columns.join(" ") } : {}),
|
|
66
|
+
locale,
|
|
67
|
+
});
|
|
68
|
+
if (!res.ok) return null;
|
|
69
|
+
const parsed = GridAnswerSchema.safeParse(res.body);
|
|
70
|
+
return parsed.success ? parsed.data : null;
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The page locale's `grids` words (#12222 D18): every fixed word a grid shows. */
|
|
78
|
+
export async function gridLabels(locale: string): Promise<GridLabels> {
|
|
79
|
+
const t = await getTranslations({ locale, namespace: "grids" });
|
|
80
|
+
const dates = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" });
|
|
81
|
+
return {
|
|
82
|
+
fromLevel: (level) => t("fromLevel", { level }),
|
|
83
|
+
addon: t("addon"),
|
|
84
|
+
ourAssessment: t("ourAssessment"),
|
|
85
|
+
checked: (date) => t("checked", { date }),
|
|
86
|
+
factsAsOf: (date) => t("factsAsOf", { date }),
|
|
87
|
+
countOf: (yes, of) => t("countOf", { yes, of }),
|
|
88
|
+
capabilities: t("capabilities"),
|
|
89
|
+
labelHeader: t("labelHeader"),
|
|
90
|
+
planPicker: t("planPicker"),
|
|
91
|
+
formatDate: (isoDate) => dates.format(new Date(`${isoDate}T00:00:00Z`)),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A grid as `comparison-table` data, with the plan slugs of its own columns,
|
|
97
|
+
* or `null` for a failed read or a grid with no row. A block's `price`,
|
|
98
|
+
* `button` and `source` shape the data; a section's grid carries no `price`
|
|
99
|
+
* or `button` (its `planBar` is the one header control).
|
|
100
|
+
*/
|
|
101
|
+
export async function gridTable(
|
|
102
|
+
grid: GridSetting,
|
|
103
|
+
locale: string,
|
|
104
|
+
): Promise<{ data: GridTableData; plans: string[] } | null> {
|
|
105
|
+
const answer = await readGrid(grid, locale);
|
|
106
|
+
if (answer === null) return null;
|
|
107
|
+
const options =
|
|
108
|
+
grid.kind === "capabilities"
|
|
109
|
+
? { price: "price" in grid ? grid.price : undefined, button: "button" in grid ? grid.button : undefined }
|
|
110
|
+
: { source: grid.source };
|
|
111
|
+
const data = gridSection(answer, await gridLabels(locale), options);
|
|
112
|
+
if (data === null) return null;
|
|
113
|
+
const plans = answer.columns.flatMap((column) => (column.ours && column.plan !== undefined ? [column.plan] : []));
|
|
114
|
+
return { data: data as GridTableData, plans };
|
|
115
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hub-read.ts — a hub read shared across requests (#8731).
|
|
3
|
+
*
|
|
4
|
+
* A visitor view carries no forwarding headers, so on a spoke every view
|
|
5
|
+
* would otherwise count against the spoke server's one per-IP limit at the
|
|
6
|
+
* hub. An Admin edit shows within HUB_READ_TTL_MS.
|
|
7
|
+
*
|
|
8
|
+
* A leaf (#12385): it imports no other apps/web module, so `grid-read.ts` and
|
|
9
|
+
* `in-page-magnet.ts` can both import it without closing a cycle through
|
|
10
|
+
* `site-pages.config.tsx`. `in-page-magnet.ts` re-exports both names.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* How long a hub read is shared across requests (#8731). Short, so an Admin
|
|
15
|
+
* edit to the magnet shows within seconds; long enough that a burst of views
|
|
16
|
+
* makes one read of each, not one per view.
|
|
17
|
+
*/
|
|
18
|
+
export const HUB_READ_TTL_MS = 15_000;
|
|
19
|
+
|
|
20
|
+
const hubReads = new Map<string, { at: number; read: Promise<unknown> }>();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `read()`'s result, shared per instance for HUB_READ_TTL_MS. Concurrent calls
|
|
24
|
+
* share one in-flight read. A read that settles to `null` (any failed read,
|
|
25
|
+
* see the readers in `in-page-magnet.ts`) is shared the same way, so a burst
|
|
26
|
+
* against an unreachable hub is not a burst of retries.
|
|
27
|
+
*/
|
|
28
|
+
export function sharedHubRead<T>(key: string, read: () => Promise<T>): Promise<T> {
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
const hit = hubReads.get(key);
|
|
31
|
+
if (hit && now - hit.at < HUB_READ_TTL_MS) return hit.read as Promise<T>;
|
|
32
|
+
const fresh = read();
|
|
33
|
+
hubReads.set(key, { at: now, read: fresh });
|
|
34
|
+
return fresh;
|
|
35
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* in-page-blocks.ts — the site's renderer for a page body's block lines
|
|
3
|
+
* (#12222, spec docs/specs/12222-capabilities-and-alternatives-what-a-spec.md
|
|
4
|
+
* D13, D18; B4 #12293).
|
|
5
|
+
*
|
|
6
|
+
* `@working-theory/page-renderer` finds each `<Offer … />` or `<Grid … />`
|
|
7
|
+
* line in a prose or mdx-body page (`resolveBodyBlocks`, the one grammar
|
|
8
|
+
* `parseBlockLine`) and asks the renderer registered here, at module load,
|
|
9
|
+
* for its node. The locale layout imports this module, as it imports
|
|
10
|
+
* `in-page-magnet`, so every page render has it.
|
|
11
|
+
*
|
|
12
|
+
* - **Offer.** One `pricing` section bound to the shown set
|
|
13
|
+
* (`source: "offerings"`, `offeringPlans`, `billingToggle` from `yearly`),
|
|
14
|
+
* run through `pricingSections` with `recommended` as the page's `?plan=`,
|
|
15
|
+
* so the cards are today's Stripe cards. Anything but Stripe cards — an
|
|
16
|
+
* unconnected site, an expired set, plans not shown — renders nothing.
|
|
17
|
+
* - **Grid.** The public read and its wording are `grid-read.ts`'s
|
|
18
|
+
* (`gridTable`), shared with a `comparison-table` section's `grid` setting
|
|
19
|
+
* (#12370) — no English default reaches a page (D18). With `price` or
|
|
20
|
+
* `button`, the table's plan
|
|
21
|
+
* columns take their price and button from the shown set through
|
|
22
|
+
* `pricingSections`' plan-column resolver. Drawn through `SectionRenderer`.
|
|
23
|
+
*
|
|
24
|
+
* A read that fails, an answer that does not parse, an empty grid or a throw
|
|
25
|
+
* renders nothing (`null`), so a page never breaks on a block; page-renderer
|
|
26
|
+
* adds its own 3,000 ms backstop. The grid's data is never written anywhere:
|
|
27
|
+
* every render reads the published facts and Stripe's features afresh.
|
|
28
|
+
*/
|
|
29
|
+
import { setBodyBlockRenderer, type BodyBlockRenderer } from "@working-theory/page-renderer";
|
|
30
|
+
import { SectionRenderer } from "@working-theory/ui";
|
|
31
|
+
import type { GridBlock, OfferBlock, PageSection } from "@working-theory/validation";
|
|
32
|
+
import { unstable_rethrow } from "next/navigation";
|
|
33
|
+
import { createElement, type ReactElement } from "react";
|
|
34
|
+
|
|
35
|
+
import { gridTable } from "./grid-read";
|
|
36
|
+
import { pricingSections } from "./pricing-page";
|
|
37
|
+
|
|
38
|
+
type Sections = PageSection[];
|
|
39
|
+
|
|
40
|
+
/** The section list as `SectionRenderer` draws it, or `null` when there is none. */
|
|
41
|
+
function drawn(sections: Sections, locale: string): ReactElement | null {
|
|
42
|
+
return sections.length === 0 ? null : createElement(SectionRenderer, { sections, locale });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A bound pricing section for `plans` (#12140 D1), the one shape both blocks hand `pricingSections`. */
|
|
46
|
+
function boundPlans(id: string, plans: readonly string[], billingToggle: boolean): PageSection {
|
|
47
|
+
return {
|
|
48
|
+
type: "pricing",
|
|
49
|
+
id,
|
|
50
|
+
data: {
|
|
51
|
+
plans: [],
|
|
52
|
+
source: "offerings",
|
|
53
|
+
offeringPlans: [...plans],
|
|
54
|
+
...(billingToggle ? { billingToggle: true } : {}),
|
|
55
|
+
},
|
|
56
|
+
} as PageSection;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A pricing section that carries Stripe cards: bound, with plans placed. */
|
|
60
|
+
function carriesCards(section: PageSection): boolean {
|
|
61
|
+
if (section.type !== "pricing") return false;
|
|
62
|
+
const data = section.data as { plans?: unknown[] };
|
|
63
|
+
return Array.isArray(data.plans) && data.plans.length > 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── Offer ──────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export async function renderOffer(block: OfferBlock, locale: string): Promise<ReactElement | null> {
|
|
69
|
+
// The grammar holds one of the two: a slug, or 2–6 plans.
|
|
70
|
+
const plans = block.plans ?? [block.slug!];
|
|
71
|
+
const sections = await pricingSections([boundPlans(`offer-${plans.join("-")}`, plans, block.yearly === true)], {
|
|
72
|
+
plans: undefined,
|
|
73
|
+
plan: block.recommended,
|
|
74
|
+
locale,
|
|
75
|
+
});
|
|
76
|
+
return drawn(sections.filter(carriesCards), locale);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ── Grid ───────────────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
export async function renderGrid(block: GridBlock, locale: string): Promise<ReactElement | null> {
|
|
82
|
+
// The read and its wording are `grid-read.ts`'s, shared with a comparison-table section's `grid` (#12370 D3).
|
|
83
|
+
const read = await gridTable(block, locale);
|
|
84
|
+
if (read === null) return null;
|
|
85
|
+
const table = {
|
|
86
|
+
type: "comparison-table",
|
|
87
|
+
id: `grid-${block.kind}-${block.kind === "capabilities" ? block.products.join("-") : block.category}`,
|
|
88
|
+
data: read.data,
|
|
89
|
+
} as PageSection;
|
|
90
|
+
const { plans } = read;
|
|
91
|
+
if (block.kind !== "capabilities" || (block.price !== true && block.button !== true) || plans.length === 0) {
|
|
92
|
+
return drawn([table], locale);
|
|
93
|
+
}
|
|
94
|
+
// The plan bar's price and button come from the shown set: `pricingSections`
|
|
95
|
+
// resolves a table's plan columns beside a bound pricing section, which is
|
|
96
|
+
// read for that and never drawn.
|
|
97
|
+
const resolved = await pricingSections([boundPlans(`${table.id}-plans`, plans, false), table], {
|
|
98
|
+
plans: undefined,
|
|
99
|
+
plan: undefined,
|
|
100
|
+
locale,
|
|
101
|
+
});
|
|
102
|
+
return drawn(
|
|
103
|
+
resolved.filter((section) => section.type === "comparison-table"),
|
|
104
|
+
locale,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The renderer page-renderer asks for each block line (D13). */
|
|
109
|
+
export const renderBodyBlock: BodyBlockRenderer = async ({ block, locale }) => {
|
|
110
|
+
try {
|
|
111
|
+
return block.tag === "Offer" ? await renderOffer(block.block, locale) : await renderGrid(block.block, locale);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
unstable_rethrow(err);
|
|
114
|
+
console.warn("[body-blocks] render failed; the block is left out");
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
setBodyBlockRenderer(renderBodyBlock);
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* footer signup all read through here.
|
|
9
9
|
*
|
|
10
10
|
* - `sharedHubRead` shares a hub read across requests for HUB_READ_TTL_MS
|
|
11
|
-
* (#8731, moved here from /contact
|
|
11
|
+
* (#8731, moved here from /contact; in `hub-read.ts` since #12385 and
|
|
12
|
+
* re-exported here): a visitor view carries no forwarding
|
|
12
13
|
* headers, so on a spoke every view would otherwise count against the
|
|
13
14
|
* spoke server's one per-IP limit at the hub. An Admin edit shows within
|
|
14
15
|
* that window.
|
|
@@ -59,6 +60,7 @@ import { unstable_rethrow } from "next/navigation";
|
|
|
59
60
|
import { createElement, type ReactElement } from "react";
|
|
60
61
|
|
|
61
62
|
import { consentPoliciesFor } from "./consent-policies";
|
|
63
|
+
import { sharedHubRead } from "./hub-read";
|
|
62
64
|
import { subscribeNewsletterAction } from "./newsletter.actions";
|
|
63
65
|
import type { UiSignalCollectorsContract } from "./paid-section-contracts";
|
|
64
66
|
import { loadUiSignalCollectors } from "./paid-sections.generated";
|
|
@@ -69,14 +71,8 @@ export { fillEndingName } from "@working-theory/validation";
|
|
|
69
71
|
|
|
70
72
|
// ─── Shared hub reads (#8731) ──────────────────────────────────────────────────
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* edit to the magnet shows within seconds; long enough that a burst of views
|
|
75
|
-
* makes one read of each, not one per view.
|
|
76
|
-
*/
|
|
77
|
-
export const HUB_READ_TTL_MS = 15_000;
|
|
78
|
-
|
|
79
|
-
const hubReads = new Map<string, { at: number; read: Promise<unknown> }>();
|
|
74
|
+
// Re-exported under the same names (#12385), so a scaffolded site that imports them from here keeps working.
|
|
75
|
+
export { HUB_READ_TTL_MS, sharedHubRead } from "./hub-read";
|
|
80
76
|
|
|
81
77
|
/**
|
|
82
78
|
* How long a page waits on one hub read before treating it as failed. The
|
|
@@ -94,21 +90,6 @@ function withDeadline<T>(read: Promise<T>, fallback: T): Promise<T> {
|
|
|
94
90
|
return Promise.race([read, late]).finally(() => clearTimeout(timer));
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
/**
|
|
98
|
-
* `read()`'s result, shared per instance for HUB_READ_TTL_MS. Concurrent calls
|
|
99
|
-
* share one in-flight read. A read that settles to `null` (any failed read,
|
|
100
|
-
* see the readers below) is shared the same way, so a burst against an
|
|
101
|
-
* unreachable hub is not a burst of retries.
|
|
102
|
-
*/
|
|
103
|
-
export function sharedHubRead<T>(key: string, read: () => Promise<T>): Promise<T> {
|
|
104
|
-
const now = Date.now();
|
|
105
|
-
const hit = hubReads.get(key);
|
|
106
|
-
if (hit && now - hit.at < HUB_READ_TTL_MS) return hit.read as Promise<T>;
|
|
107
|
-
const fresh = read();
|
|
108
|
-
hubReads.set(key, { at: now, read: fresh });
|
|
109
|
-
return fresh;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
93
|
export type CaptureStatus = Extract<
|
|
113
94
|
Awaited<ReturnType<typeof leads.captureStatus>>,
|
|
114
95
|
{ ok: true }
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
* #12246 — `offeringsPlanColumns` resolves a comparison table's plan columns
|
|
49
49
|
* from the same shown set: each slug's name, price, checkout link and
|
|
50
50
|
* Recommended flag, from the card `planCard` / `bundleCard` builds for it.
|
|
51
|
+
* #12280 — a column's price carries the product's unit, as its card does.
|
|
51
52
|
*/
|
|
52
53
|
import {
|
|
53
54
|
PRICING_SEGMENT_LEVELS_MAX,
|
|
@@ -1187,6 +1188,11 @@ export function offeringsPricing(
|
|
|
1187
1188
|
};
|
|
1188
1189
|
}
|
|
1189
1190
|
|
|
1191
|
+
/** A side's amount and unit as the card draws them, joined by its space (#12280 D2); else `phrase`. */
|
|
1192
|
+
function joinedPrice(part: PriceParts["monthly"], phrase: string | undefined): string | undefined {
|
|
1193
|
+
return part ? `${part.amount} ${part.unit}` : phrase;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1190
1196
|
/**
|
|
1191
1197
|
* Each of `slugs` the shown set shows as a plan column (#12246 D3), by slug:
|
|
1192
1198
|
* a slug `planColumnSlugs` holds, as the card its point product would get —
|
|
@@ -1218,7 +1224,12 @@ export function offeringsPlanColumns(
|
|
|
1218
1224
|
// card's footnote link (`siteOrigin`) and display options never matter here.
|
|
1219
1225
|
const card = point && ownCard(point, shown, false, locale, labels, undefined);
|
|
1220
1226
|
if (!product || !card) continue;
|
|
1221
|
-
|
|
1227
|
+
// #12280 D2, D4 — with a unit noun, a side reads the card's amount and
|
|
1228
|
+
// unit, joined by the card's own space; else the card's phrase, unchanged.
|
|
1229
|
+
const parts = card.priceUnit ? card.priceParts : undefined;
|
|
1230
|
+
const monthly = joinedPrice(parts?.monthly, card.price.monthly);
|
|
1231
|
+
const annual = joinedPrice(parts?.annual, card.price.annual);
|
|
1232
|
+
const { custom } = card.price;
|
|
1222
1233
|
columns.set(slug, {
|
|
1223
1234
|
name: card.name,
|
|
1224
1235
|
price: {
|
|
@@ -59,6 +59,7 @@ import { createElement, type ReactNode } from "react";
|
|
|
59
59
|
import { resolveBaseUrl } from "../src/lib/routes";
|
|
60
60
|
|
|
61
61
|
import { browserApiOrigin } from "./api-origin.generated";
|
|
62
|
+
import { gridTable, withinGridDeadline } from "./grid-read";
|
|
62
63
|
import {
|
|
63
64
|
OFFERINGS_CHECKOUT_PATH,
|
|
64
65
|
collectionPlans,
|
|
@@ -1040,6 +1041,34 @@ function withPlanColumns(
|
|
|
1040
1041
|
});
|
|
1041
1042
|
}
|
|
1042
1043
|
|
|
1044
|
+
/**
|
|
1045
|
+
* The page's grid-bound comparison tables, each read from its Offerings grid
|
|
1046
|
+
* (#12370, spec docs/specs/12370-a-comparison-table-reads-an-offerings-grid-spec.md
|
|
1047
|
+
* D4): a `comparison-table` section whose data carries `grid` takes its
|
|
1048
|
+
* columns and groups from `gridTable` — the Grid block's own read and
|
|
1049
|
+
* wording — and keeps every field it sets itself, so the section's
|
|
1050
|
+
* `headline`, `footnote`, `variant`, `labelHeader`, `yesMark`, `planBar` and
|
|
1051
|
+
* the rest win, and the grid's `labelHeader`, `variant`, `yesMark` and
|
|
1052
|
+
* `footnote` show where the section sets none. A read that fails, takes
|
|
1053
|
+
* longer than 3,000 ms or answers no row removes the table: nothing typed is kept as a fallback.
|
|
1054
|
+
* Run before `withPlanColumns`, so a grid's plan columns resolve from the
|
|
1055
|
+
* shown set as a typed table's do. The input array itself when no table
|
|
1056
|
+
* carries `grid`.
|
|
1057
|
+
*/
|
|
1058
|
+
export async function withGrids(sections: PageSection[], locale: string): Promise<PageSection[]> {
|
|
1059
|
+
if (!sections.some((section) => isComparisonTable(section) && section.data.grid !== undefined)) return sections;
|
|
1060
|
+
const resolved = await Promise.all(
|
|
1061
|
+
sections.map(async (section): Promise<PageSection | null> => {
|
|
1062
|
+
if (!isComparisonTable(section) || section.data.grid === undefined) return section;
|
|
1063
|
+
const { grid, columns: _c, groups: _g, ...own } = section.data;
|
|
1064
|
+
// A throw or a read past its deadline is a failed read: the table is left out, the page still renders.
|
|
1065
|
+
const read = await withinGridDeadline(gridTable(grid, locale));
|
|
1066
|
+
return read === null ? null : { ...section, data: { ...read.data, ...own } };
|
|
1067
|
+
}),
|
|
1068
|
+
);
|
|
1069
|
+
return resolved.filter((section): section is PageSection => section !== null);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1043
1072
|
/**
|
|
1044
1073
|
* The hub's `pricingPagesHeading` override (#12213 AC-1): the heading that
|
|
1045
1074
|
* replaces the `pricingPages.heading` message on the generated `pricing-pages`
|
|
@@ -1078,7 +1107,8 @@ export function pricingPagesSectionEnabled(frontmatter: unknown): boolean {
|
|
|
1078
1107
|
* - anything else → the contact email in their place.
|
|
1079
1108
|
* On the written states a `source: written` section never links the
|
|
1080
1109
|
* Offerings checkout (#12140 D2 rule 7). On every path the authored
|
|
1081
|
-
* render-time fields are removed first, each comparison table
|
|
1110
|
+
* render-time fields are removed first, each grid-bound comparison table is
|
|
1111
|
+
* read from its Offerings grid (#12370 D4), each comparison table's plan columns
|
|
1082
1112
|
* are resolved from the shown set the page read (#12246 D3; typed off the
|
|
1083
1113
|
* shown path), and `?plan=` / `?billing=`'s are set last (#12193 D9, D11).
|
|
1084
1114
|
*/
|
|
@@ -1093,7 +1123,8 @@ export async function pricingSections(
|
|
|
1093
1123
|
): Promise<PageSection[]> {
|
|
1094
1124
|
const { plan, period } = options;
|
|
1095
1125
|
const { sections, source } = await sectionsFor(withoutRenderTimeFields(authored), options);
|
|
1096
|
-
|
|
1126
|
+
const tables = await withGrids(sections, options.locale);
|
|
1127
|
+
return withSelection(withPlanColumns(tables, { source, period }), plan, period);
|
|
1097
1128
|
}
|
|
1098
1129
|
|
|
1099
1130
|
async function sectionsFor(
|
|
@@ -132,11 +132,25 @@
|
|
|
132
132
|
"heading": "Pricing",
|
|
133
133
|
"emptyState": "Pricing page content coming soon."
|
|
134
134
|
},
|
|
135
|
+
"grids": {
|
|
136
|
+
"fromLevel": "From {level}",
|
|
137
|
+
"addon": "Add-on",
|
|
138
|
+
"ourAssessment": "Our assessment",
|
|
139
|
+
"checked": "Checked {date}",
|
|
140
|
+
"factsAsOf": "Facts as of {date}",
|
|
141
|
+
"countOf": "{yes} of {of}",
|
|
142
|
+
"capabilities": "Capabilities",
|
|
143
|
+
"labelHeader": "What you get",
|
|
144
|
+
"planPicker": "Plan"
|
|
145
|
+
},
|
|
135
146
|
"pricingOfferings": {
|
|
136
147
|
"cta": "Get started",
|
|
137
148
|
"recommended": "Recommended",
|
|
138
149
|
"recommendedForYou": "Recommended for you",
|
|
139
150
|
"addonsHeadline": "Add-ons",
|
|
151
|
+
"billingToggleMonthly": "Monthly",
|
|
152
|
+
"billingToggleAnnual": "Annually",
|
|
153
|
+
"billingToggleName": "Billing period",
|
|
140
154
|
"monthly": "{amount}/mo",
|
|
141
155
|
"annual": "{amount}/yr",
|
|
142
156
|
"oneTime": "{amount} one-time",
|
package/versions.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@working-theory/account": "0.
|
|
3
|
-
"@working-theory/admin-ui": "0.
|
|
4
|
-
"@working-theory/aeo": "0.
|
|
5
|
-
"@working-theory/agent-context": "0.
|
|
2
|
+
"@working-theory/account": "0.80.0",
|
|
3
|
+
"@working-theory/admin-ui": "0.80.0",
|
|
4
|
+
"@working-theory/aeo": "0.80.0",
|
|
5
|
+
"@working-theory/agent-context": "0.80.0",
|
|
6
6
|
"@working-theory/agent-contract": "0.1.0",
|
|
7
7
|
"@working-theory/agent-memory": "0.0.0",
|
|
8
8
|
"@working-theory/ai": "0.1.0",
|
|
9
|
-
"@working-theory/analytics": "0.
|
|
10
|
-
"@working-theory/api": "0.
|
|
11
|
-
"@working-theory/api-client": "0.
|
|
12
|
-
"@working-theory/auth": "0.
|
|
9
|
+
"@working-theory/analytics": "0.80.0",
|
|
10
|
+
"@working-theory/api": "0.80.0",
|
|
11
|
+
"@working-theory/api-client": "0.80.0",
|
|
12
|
+
"@working-theory/auth": "0.80.0",
|
|
13
13
|
"@working-theory/cda-filesystem": "0.0.0",
|
|
14
|
-
"@working-theory/cli": "0.
|
|
15
|
-
"@working-theory/common": "0.
|
|
14
|
+
"@working-theory/cli": "0.80.0",
|
|
15
|
+
"@working-theory/common": "0.80.0",
|
|
16
16
|
"@working-theory/consent": "0.1.0",
|
|
17
|
-
"@working-theory/content-adapters": "0.
|
|
18
|
-
"@working-theory/content-projection": "0.
|
|
19
|
-
"@working-theory/email": "0.
|
|
17
|
+
"@working-theory/content-adapters": "0.80.0",
|
|
18
|
+
"@working-theory/content-projection": "0.80.0",
|
|
19
|
+
"@working-theory/email": "0.80.0",
|
|
20
20
|
"@working-theory/env": "0.0.0",
|
|
21
|
-
"@working-theory/eslint-config": "0.
|
|
22
|
-
"@working-theory/fumadocs-schema": "0.
|
|
21
|
+
"@working-theory/eslint-config": "0.80.0",
|
|
22
|
+
"@working-theory/fumadocs-schema": "0.80.0",
|
|
23
23
|
"@working-theory/ids": "0.23.0",
|
|
24
|
-
"@working-theory/jsonld": "0.
|
|
25
|
-
"@working-theory/license": "0.
|
|
26
|
-
"@working-theory/mcp-server": "0.
|
|
27
|
-
"@working-theory/metadata": "0.
|
|
28
|
-
"@working-theory/observability": "0.
|
|
29
|
-
"@working-theory/page-renderer": "0.
|
|
24
|
+
"@working-theory/jsonld": "0.80.0",
|
|
25
|
+
"@working-theory/license": "0.80.0",
|
|
26
|
+
"@working-theory/mcp-server": "0.80.0",
|
|
27
|
+
"@working-theory/metadata": "0.80.0",
|
|
28
|
+
"@working-theory/observability": "0.80.0",
|
|
29
|
+
"@working-theory/page-renderer": "0.80.0",
|
|
30
30
|
"@working-theory/plugin-mcp": "0.1.3",
|
|
31
|
-
"@working-theory/schema": "0.
|
|
32
|
-
"@working-theory/schema-pack-registry": "0.
|
|
33
|
-
"@working-theory/schema-validator": "0.
|
|
34
|
-
"@working-theory/sections-registry": "0.
|
|
35
|
-
"@working-theory/site-config": "0.
|
|
36
|
-
"@working-theory/site-pages": "0.
|
|
37
|
-
"@working-theory/spoke-checkout": "0.7.
|
|
38
|
-
"@working-theory/stripe-client": "0.
|
|
39
|
-
"@working-theory/templates": "0.
|
|
40
|
-
"@working-theory/theme": "0.
|
|
41
|
-
"@working-theory/ui": "0.
|
|
42
|
-
"@working-theory/validation": "0.
|
|
43
|
-
"@working-theory/web-i18n": "0.
|
|
44
|
-
"@working-theory/admin": "0.
|
|
45
|
-
"@working-theory/api-commerce": "0.2.
|
|
46
|
-
"@working-theory/api-content-write": "0.18.
|
|
47
|
-
"@working-theory/api-hub": "0.
|
|
48
|
-
"@working-theory/api-multi-tenant": "0.
|
|
49
|
-
"@working-theory/api-scheduling": "0.6.
|
|
50
|
-
"@working-theory/api-signal-collectors": "0.
|
|
51
|
-
"@working-theory/api-workspace": "0.
|
|
31
|
+
"@working-theory/schema": "0.80.0",
|
|
32
|
+
"@working-theory/schema-pack-registry": "0.80.0",
|
|
33
|
+
"@working-theory/schema-validator": "0.80.0",
|
|
34
|
+
"@working-theory/sections-registry": "0.80.0",
|
|
35
|
+
"@working-theory/site-config": "0.80.0",
|
|
36
|
+
"@working-theory/site-pages": "0.80.0",
|
|
37
|
+
"@working-theory/spoke-checkout": "0.7.37",
|
|
38
|
+
"@working-theory/stripe-client": "0.80.0",
|
|
39
|
+
"@working-theory/templates": "0.80.0",
|
|
40
|
+
"@working-theory/theme": "0.80.0",
|
|
41
|
+
"@working-theory/ui": "0.80.0",
|
|
42
|
+
"@working-theory/validation": "0.80.0",
|
|
43
|
+
"@working-theory/web-i18n": "0.80.0",
|
|
44
|
+
"@working-theory/admin": "0.28.0",
|
|
45
|
+
"@working-theory/api-commerce": "0.2.15",
|
|
46
|
+
"@working-theory/api-content-write": "0.18.2",
|
|
47
|
+
"@working-theory/api-hub": "0.10.0",
|
|
48
|
+
"@working-theory/api-multi-tenant": "0.6.0",
|
|
49
|
+
"@working-theory/api-scheduling": "0.6.20",
|
|
50
|
+
"@working-theory/api-signal-collectors": "0.9.1",
|
|
51
|
+
"@working-theory/api-workspace": "0.20.0",
|
|
52
52
|
"@working-theory/billing-client": "0.0.0",
|
|
53
53
|
"@working-theory/branding": "0.0.0",
|
|
54
54
|
"@working-theory/license-client": "0.0.0",
|
|
55
55
|
"@working-theory/license-manifest": "0.0.0",
|
|
56
|
-
"@working-theory/mcp-scheduling": "0.4.
|
|
57
|
-
"@working-theory/mcp-signal-collectors": "0.2.
|
|
58
|
-
"@working-theory/mcp-workspace": "0.
|
|
56
|
+
"@working-theory/mcp-scheduling": "0.4.22",
|
|
57
|
+
"@working-theory/mcp-signal-collectors": "0.2.35",
|
|
58
|
+
"@working-theory/mcp-workspace": "0.17.1",
|
|
59
59
|
"@working-theory/partner-session": "0.0.0",
|
|
60
60
|
"@working-theory/preview-protocol": "0.0.0",
|
|
61
|
-
"@working-theory/ui-commerce": "0.
|
|
62
|
-
"@working-theory/ui-docs-blog": "0.
|
|
63
|
-
"@working-theory/ui-scheduling": "0.
|
|
64
|
-
"@working-theory/ui-signal-collectors": "0.
|
|
61
|
+
"@working-theory/ui-commerce": "0.80.0",
|
|
62
|
+
"@working-theory/ui-docs-blog": "0.80.0",
|
|
63
|
+
"@working-theory/ui-scheduling": "0.80.0",
|
|
64
|
+
"@working-theory/ui-signal-collectors": "0.80.0",
|
|
65
65
|
"@working-theory/web": "0.0.0",
|
|
66
66
|
"@working-theory/app-api": "1.0.0",
|
|
67
67
|
"@working-theory/mcp": "0.0.0",
|
|
68
|
-
"@working-theory/database": "0.
|
|
68
|
+
"@working-theory/database": "0.80.0"
|
|
69
69
|
}
|