create-ailk 0.46.0 → 0.46.2
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 +481 -4
- package/component-catalog.md +9 -6
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +56 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +390 -1
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +503 -1
- package/templates/apps/web/lib/offerings-pricing.ts +231 -26
- package/templates/apps/web/lib/pricing-page.ts +332 -22
- package/templates/apps/web/messages/en.json +1 -0
- package/versions.json +50 -50
|
@@ -17,12 +17,20 @@
|
|
|
17
17
|
* section that lists its own `offeringPlans` is a plan group (#12103 D2): it
|
|
18
18
|
* shows exactly those plans' Stripe cards, and none is removed.
|
|
19
19
|
*
|
|
20
|
+
* A section's `source` (#12140, spec
|
|
21
|
+
* docs/specs/12140-pricing-sections-bind-to-offerings-spec.md D2) says where
|
|
22
|
+
* its plans come from: `offerings` binds it to the shown set in the layout its
|
|
23
|
+
* own `variant` names; `written` keeps it as authored, never linking the
|
|
24
|
+
* Offerings checkout. A page with no `source` anywhere renders as before.
|
|
25
|
+
*
|
|
20
26
|
* Stripe text reaches markup only as React text through `offeringsPricing`,
|
|
21
27
|
* and JSON-LD only through renderPage's serializer (T4).
|
|
22
28
|
*
|
|
23
29
|
* Base tree: no paid import, no `oss: false`.
|
|
24
30
|
*/
|
|
25
31
|
import { offerings } from "@working-theory/api-client";
|
|
32
|
+
import type { DetailPage } from "@working-theory/site-pages/lib/route-family";
|
|
33
|
+
import { contactFormText } from "@working-theory/site-pages/pages/contact/contact-form-text";
|
|
26
34
|
import { ContactFallback } from "@working-theory/ui";
|
|
27
35
|
import {
|
|
28
36
|
LOOKUP_KEY_PLAN_PATTERN,
|
|
@@ -31,16 +39,15 @@ import {
|
|
|
31
39
|
import { getTranslations } from "next-intl/server";
|
|
32
40
|
import { createElement, type ReactNode } from "react";
|
|
33
41
|
|
|
34
|
-
import { contactFormText } from "@working-theory/site-pages/pages/contact/contact-form-text";
|
|
35
|
-
import { readSiteContactEmail } from "./site-contact-email";
|
|
36
|
-
|
|
37
42
|
import { browserApiOrigin } from "./api-origin.generated";
|
|
38
43
|
import {
|
|
44
|
+
OFFERINGS_CHECKOUT_PATH,
|
|
39
45
|
offeringsPricing,
|
|
40
46
|
type OfferingsPricing,
|
|
41
47
|
type OfferingsPricingLabels,
|
|
42
48
|
} from "./offerings-pricing";
|
|
43
|
-
import
|
|
49
|
+
import { readSiteContactEmail } from "./site-contact-email";
|
|
50
|
+
|
|
44
51
|
|
|
45
52
|
type PricingSection = Extract<PageSection, { type: "pricing" }>;
|
|
46
53
|
type PricingData = PricingSection["data"];
|
|
@@ -163,7 +170,9 @@ export async function offeringsCopy(locale: string): Promise<{
|
|
|
163
170
|
addonsHeadline: string;
|
|
164
171
|
}> {
|
|
165
172
|
const t = await getTranslations({ locale, namespace: "pricingOfferings" });
|
|
166
|
-
const period = (
|
|
173
|
+
const period = (
|
|
174
|
+
key: "monthly" | "annual" | "oneTime" | "billedYearly",
|
|
175
|
+
) => {
|
|
167
176
|
const phrase = t(key, KEEP_AMOUNT_PLACEHOLDER);
|
|
168
177
|
return (amount: string) => phrase.replace("{amount}", () => amount);
|
|
169
178
|
};
|
|
@@ -174,6 +183,7 @@ export async function offeringsCopy(locale: string): Promise<{
|
|
|
174
183
|
monthly: period("monthly"),
|
|
175
184
|
annual: period("annual"),
|
|
176
185
|
oneTime: period("oneTime"),
|
|
186
|
+
billedYearly: period("billedYearly"),
|
|
177
187
|
withRequired: (plan, required) =>
|
|
178
188
|
t("withRequired", KEEP_BUNDLE_PLACEHOLDERS)
|
|
179
189
|
.replace("{plan}", () => plan)
|
|
@@ -209,6 +219,11 @@ const AUTHORED_COPY_FIELDS = [
|
|
|
209
219
|
"surface",
|
|
210
220
|
"note",
|
|
211
221
|
"collapseFeaturesOnMobile",
|
|
222
|
+
// #12141 D9 — the plan bar's options, so a connected section keeps them.
|
|
223
|
+
"planBar",
|
|
224
|
+
"comparisonPlanBar",
|
|
225
|
+
// #12174 D2 — where a level card's switch sits.
|
|
226
|
+
"levelSwitchPlacement",
|
|
212
227
|
] as const satisfies readonly (keyof PricingData)[];
|
|
213
228
|
|
|
214
229
|
function authoredCopy(
|
|
@@ -227,6 +242,134 @@ function isPricing(section: PageSection): section is PricingSection {
|
|
|
227
242
|
return section.type === "pricing";
|
|
228
243
|
}
|
|
229
244
|
|
|
245
|
+
/** A section bound to the workspace's Offerings (#12140 D1). */
|
|
246
|
+
function isBound(section: PageSection): section is PricingSection {
|
|
247
|
+
return isPricing(section) && section.data.source === "offerings";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A section whose plans stay as written on a connected page (#12140 D1). */
|
|
251
|
+
function isWritten(section: PageSection): section is PricingSection {
|
|
252
|
+
return isPricing(section) && section.data.source === "written";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** A section with no `source` — every pricing section before #12140. */
|
|
256
|
+
function isUnbound(section: PageSection): section is PricingSection {
|
|
257
|
+
return isPricing(section) && section.data.source === undefined;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Whether `href` reaches the Offerings checkout route, read as a browser
|
|
262
|
+
* resolves it — a relative, absolute or dot-segment form alike, on any host,
|
|
263
|
+
* whatever the case (#12140 D2 rule 7). The path is read percent-decoded too,
|
|
264
|
+
* as the router decodes it, so `/api/%6Ffferings/checkout` is caught. An href
|
|
265
|
+
* no URL parser accepts is one a browser cannot follow either.
|
|
266
|
+
*/
|
|
267
|
+
function linksOfferingsCheckout(href: string | undefined): boolean {
|
|
268
|
+
if (href === undefined) return false;
|
|
269
|
+
const base = "https://site.invalid";
|
|
270
|
+
const reaches = (path: string) =>
|
|
271
|
+
path.toLowerCase().startsWith(OFFERINGS_CHECKOUT_PATH);
|
|
272
|
+
let path: string;
|
|
273
|
+
try {
|
|
274
|
+
path = new URL(href, base).pathname;
|
|
275
|
+
} catch {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
if (reaches(path)) return true;
|
|
279
|
+
try {
|
|
280
|
+
return reaches(new URL(decodeURIComponent(path), base).pathname);
|
|
281
|
+
} catch {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
type PricingPlan = PricingData["plans"][number];
|
|
287
|
+
|
|
288
|
+
/** Whether a card, or any of its levels (#12174 D7), links the Offerings checkout. */
|
|
289
|
+
function sellsOfferings(plan: PricingPlan): boolean {
|
|
290
|
+
return [plan, ...(plan.levels ?? [])].some(
|
|
291
|
+
(shown) =>
|
|
292
|
+
linksOfferingsCheckout(shown.cta.href) ||
|
|
293
|
+
linksOfferingsCheckout(shown.annualCtaHref),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
type ComparisonGroups = NonNullable<PricingData["comparisonGroups"]>;
|
|
298
|
+
|
|
299
|
+
/** Whether any comparison cell's `link` reaches the Offerings checkout. */
|
|
300
|
+
function cellsSellOfferings(groups: ComparisonGroups | undefined): boolean {
|
|
301
|
+
return (groups ?? []).some((group) =>
|
|
302
|
+
group.rows.some((row) =>
|
|
303
|
+
Object.values(row.values).some(
|
|
304
|
+
(value) =>
|
|
305
|
+
typeof value === "object" && linksOfferingsCheckout(value.link?.href),
|
|
306
|
+
),
|
|
307
|
+
),
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* A written section with every card, extra tier and add-on tile that links the
|
|
313
|
+
* Offerings checkout dropped, and every comparison cell's link that does
|
|
314
|
+
* (#12140 D2 rule 7), so a written price can never sell an Offerings Price;
|
|
315
|
+
* the section itself when nothing is dropped.
|
|
316
|
+
*/
|
|
317
|
+
function withoutCheckoutLinks(section: PricingSection): PricingSection {
|
|
318
|
+
const { extraTier, ...data } = section.data;
|
|
319
|
+
const plans = data.plans.filter((plan) => !sellsOfferings(plan));
|
|
320
|
+
const addons = data.addons?.filter(
|
|
321
|
+
(addon) => !linksOfferingsCheckout(addon.cta?.href),
|
|
322
|
+
);
|
|
323
|
+
const dropTier = extraTier !== undefined && sellsOfferings(extraTier);
|
|
324
|
+
const dropCells = cellsSellOfferings(data.comparisonGroups);
|
|
325
|
+
if (
|
|
326
|
+
plans.length === data.plans.length &&
|
|
327
|
+
addons?.length === data.addons?.length &&
|
|
328
|
+
!dropTier &&
|
|
329
|
+
!dropCells
|
|
330
|
+
)
|
|
331
|
+
return section;
|
|
332
|
+
return {
|
|
333
|
+
...section,
|
|
334
|
+
data: {
|
|
335
|
+
...data,
|
|
336
|
+
plans,
|
|
337
|
+
...(addons !== undefined ? { addons } : {}),
|
|
338
|
+
...(dropCells && data.comparisonGroups
|
|
339
|
+
? { comparisonGroups: withoutCellLinks(data.comparisonGroups, true) }
|
|
340
|
+
: {}),
|
|
341
|
+
...(extraTier !== undefined && !dropTier ? { extraTier } : {}),
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The page's comparison grid with each object cell's `link` dropped (#12140
|
|
348
|
+
* D6): its cells are hand-written, so a bound section carries no authored href.
|
|
349
|
+
* With `checkoutOnly` (a written section, D2 rule 7), only a link that reaches
|
|
350
|
+
* the Offerings checkout is dropped.
|
|
351
|
+
*/
|
|
352
|
+
function withoutCellLinks(
|
|
353
|
+
groups: ComparisonGroups,
|
|
354
|
+
checkoutOnly = false,
|
|
355
|
+
): ComparisonGroups {
|
|
356
|
+
return groups.map((group) => ({
|
|
357
|
+
...group,
|
|
358
|
+
rows: group.rows.map((row) => ({
|
|
359
|
+
...row,
|
|
360
|
+
values: Object.fromEntries(
|
|
361
|
+
Object.entries(row.values).map(([key, value]) => {
|
|
362
|
+
if (typeof value !== "object") return [key, value];
|
|
363
|
+
if (checkoutOnly && !linksOfferingsCheckout(value.link?.href))
|
|
364
|
+
return [key, value];
|
|
365
|
+
const { link: _, ...cell } = value;
|
|
366
|
+
return [key, cell];
|
|
367
|
+
}),
|
|
368
|
+
),
|
|
369
|
+
})),
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
|
|
230
373
|
/** Where a section with no slot goes: after a leading hero, else first. */
|
|
231
374
|
function insertionIndex(sections: PageSection[]): number {
|
|
232
375
|
return sections[0]?.type === "hero" ? 1 : 0;
|
|
@@ -237,6 +380,18 @@ function isPlansSection(section: PageSection): section is PricingSection {
|
|
|
237
380
|
return isPricing(section) && section.data.variant !== "addons";
|
|
238
381
|
}
|
|
239
382
|
|
|
383
|
+
/**
|
|
384
|
+
* The Offerings plans a section names: its `offeringPlans`, else the plans of
|
|
385
|
+
* its `offeringGroups`' levels (#12174 D6), else none.
|
|
386
|
+
*/
|
|
387
|
+
function namedPlans(section: PricingSection): string[] | undefined {
|
|
388
|
+
const { offeringPlans, offeringGroups } = section.data;
|
|
389
|
+
return (
|
|
390
|
+
offeringPlans ??
|
|
391
|
+
offeringGroups?.flatMap((group) => group.levels.map((level) => level.plan))
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
240
395
|
/**
|
|
241
396
|
* Each plan group's Stripe plans fragment (#12103 D2), keyed by its section:
|
|
242
397
|
* `null` when none of the group's plans is shown.
|
|
@@ -250,6 +405,15 @@ export type OfferingsGroups = ReadonlyMap<PricingSection, PricingData | null>;
|
|
|
250
405
|
* — the page's `plans`, less every plan a group lists — for the unlisted plans
|
|
251
406
|
* slot and the add-ons slot. A page with no group maps exactly as before, with
|
|
252
407
|
* `groups` empty.
|
|
408
|
+
*
|
|
409
|
+
* Each bound section (#12140 D3, D7) is mapped alone into `groups` too, for
|
|
410
|
+
* its own `offeringPlans` else the page's `plans`: a plans section in the
|
|
411
|
+
* layout its `variant` names, an `addons` section to its add-on tiles. The
|
|
412
|
+
* plans a bound section lists are excluded from the page-level mapping.
|
|
413
|
+
*
|
|
414
|
+
* A bound section's `offeringGroups` (#12174 D6) narrow it to its levels'
|
|
415
|
+
* plans and map them as level cards (`offeringsPricing`'s `levelGroups`);
|
|
416
|
+
* those plans are excluded from the page-level mapping too.
|
|
253
417
|
*/
|
|
254
418
|
export function offeringsFragments(
|
|
255
419
|
declared: PageSection[],
|
|
@@ -263,10 +427,11 @@ export function offeringsFragments(
|
|
|
263
427
|
const { locale, labels, plans } = options;
|
|
264
428
|
const listed = declared.filter(
|
|
265
429
|
(s): s is PricingSection =>
|
|
266
|
-
isPlansSection(s) && s.data.offeringPlans !== undefined,
|
|
430
|
+
isUnbound(s) && isPlansSection(s) && s.data.offeringPlans !== undefined,
|
|
267
431
|
);
|
|
268
|
-
const
|
|
269
|
-
const
|
|
432
|
+
const bound = declared.filter(isBound);
|
|
433
|
+
const exclude = [...listed, ...bound].flatMap((s) => namedPlans(s) ?? []);
|
|
434
|
+
const groups = new Map<PricingSection, PricingData | null>(
|
|
270
435
|
listed.map((section) => [
|
|
271
436
|
section,
|
|
272
437
|
offeringsPricing(shownSet, {
|
|
@@ -276,6 +441,20 @@ export function offeringsFragments(
|
|
|
276
441
|
})?.plans ?? null,
|
|
277
442
|
]),
|
|
278
443
|
);
|
|
444
|
+
for (const section of bound) {
|
|
445
|
+
const { variant, offeringGroups } = section.data;
|
|
446
|
+
const addons = variant === "addons";
|
|
447
|
+
const mapped = offeringsPricing(shownSet, {
|
|
448
|
+
locale,
|
|
449
|
+
labels,
|
|
450
|
+
plans: namedPlans(section) ?? plans,
|
|
451
|
+
...(offeringGroups ? { levelGroups: offeringGroups } : {}),
|
|
452
|
+
...(variant === "addons"
|
|
453
|
+
? {}
|
|
454
|
+
: { layout: variant ?? "three-tiers-with-toggle" }),
|
|
455
|
+
});
|
|
456
|
+
groups.set(section, (addons ? mapped?.addons : mapped?.plans) ?? null);
|
|
457
|
+
}
|
|
279
458
|
const pricing = offeringsPricing(shownSet, {
|
|
280
459
|
locale,
|
|
281
460
|
labels,
|
|
@@ -285,25 +464,106 @@ export function offeringsFragments(
|
|
|
285
464
|
return { pricing, groups };
|
|
286
465
|
}
|
|
287
466
|
|
|
467
|
+
/** The layouts that render every plan they are given (#12174 D7). */
|
|
468
|
+
const EVERY_PLAN_LAYOUTS: ReadonlySet<PricingData["variant"]> = new Set([
|
|
469
|
+
"three-tiers-with-toggle",
|
|
470
|
+
"with-comparison-table",
|
|
471
|
+
"band-hero",
|
|
472
|
+
] as const);
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* A bound section's `writtenPlans` that go in its grid (#12174 D7): none when
|
|
476
|
+
* its layout renders fewer plans than it is given (a hidden card would still
|
|
477
|
+
* publish an `Offer`), and never one that links the Offerings checkout.
|
|
478
|
+
*/
|
|
479
|
+
function writtenCards(section: PricingSection): PricingPlan[] {
|
|
480
|
+
const { writtenPlans, variant } = section.data;
|
|
481
|
+
if (!writtenPlans || !EVERY_PLAN_LAYOUTS.has(variant ?? "three-tiers-with-toggle"))
|
|
482
|
+
return [];
|
|
483
|
+
return writtenPlans.filter((plan) => !sellsOfferings(plan));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* `fragment` with `section`'s written cards after its Offerings cards
|
|
488
|
+
* (#12174 D7). With no Offerings card (`fragment` null) the written cards
|
|
489
|
+
* stand alone in the section's layout, so it is not removed while one
|
|
490
|
+
* remains (#12174 decision 6); `null` when there is neither.
|
|
491
|
+
*/
|
|
492
|
+
function withWrittenCards(
|
|
493
|
+
section: PricingSection,
|
|
494
|
+
fragment: PricingData | null,
|
|
495
|
+
): PricingData | null {
|
|
496
|
+
const written = writtenCards(section);
|
|
497
|
+
if (written.length === 0) return fragment;
|
|
498
|
+
const variant = section.data.variant ?? "three-tiers-with-toggle";
|
|
499
|
+
const base: PricingData = fragment ?? {
|
|
500
|
+
variant,
|
|
501
|
+
cardLayout: "centered",
|
|
502
|
+
...(variant === "three-tiers-with-toggle" ? { billingToggle: false } : {}),
|
|
503
|
+
plans: [],
|
|
504
|
+
};
|
|
505
|
+
return { ...base, plans: [...base.plans, ...written] };
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* The key of the card `recommend` names: a card's own key, else the key of
|
|
510
|
+
* the level card one of whose levels sells that plan (#12174 decision 9, the
|
|
511
|
+
* recommender's landing `?plan=<plan>`); `recommend` itself when neither.
|
|
512
|
+
* Only an Offerings section's cards are mapped: a written section and the
|
|
513
|
+
* "as written" states keep #8842's match on a card's own key.
|
|
514
|
+
*/
|
|
515
|
+
function recommendedCard(plans: PricingPlan[], recommend: string): string {
|
|
516
|
+
const wanted = recommend.toLowerCase();
|
|
517
|
+
if (plans.some((card) => card.key?.toLowerCase() === wanted)) return recommend;
|
|
518
|
+
const seller = plans.find((card) =>
|
|
519
|
+
card.levels?.some((level) => level.key?.toLowerCase() === wanted),
|
|
520
|
+
);
|
|
521
|
+
return seller?.key ?? recommend;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/** What a bound section keeps from the page beside its copy (#12140 D6). */
|
|
525
|
+
const BOUND_KEPT_FIELDS = [
|
|
526
|
+
"source",
|
|
527
|
+
"keyPointsPanel",
|
|
528
|
+
"narrative",
|
|
529
|
+
"bandSurface",
|
|
530
|
+
] as const satisfies readonly (keyof PricingData)[];
|
|
531
|
+
|
|
288
532
|
/**
|
|
289
533
|
* One Stripe plans section in `slot`'s place: the slot's authored copy, the
|
|
290
534
|
* mapper's fragment, the slot's own `cardLayout` over the mapper's (#12103
|
|
291
535
|
* D6; `billingToggle` stays the mapper's computed one), and a `?plan=`
|
|
292
536
|
* recommendation (#8842) — applied by each section to its own cards.
|
|
537
|
+
*
|
|
538
|
+
* A bound slot (#12140 D6) also keeps its `source`, its band parts, its
|
|
539
|
+
* comparison grid (cell links dropped) and its own `features` over the
|
|
540
|
+
* mapper's; never an authored plan, extra tier or comparison-cell link.
|
|
293
541
|
*/
|
|
294
542
|
function stripePlansSection(
|
|
295
543
|
slot: PricingSection | undefined,
|
|
296
544
|
fragment: PricingData,
|
|
297
|
-
|
|
545
|
+
named: string | undefined,
|
|
298
546
|
recommendedLabel: string,
|
|
299
547
|
): PricingSection {
|
|
548
|
+
const recommend =
|
|
549
|
+
named === undefined ? undefined : recommendedCard(fragment.plans, named);
|
|
550
|
+
const bound = slot !== undefined && isBound(slot);
|
|
551
|
+
const cardLayout = slot?.data.cardLayout ?? fragment.cardLayout;
|
|
552
|
+
const features = bound
|
|
553
|
+
? (slot.data.features ?? fragment.features)
|
|
554
|
+
: undefined;
|
|
555
|
+
const comparisonGroups = bound ? slot.data.comparisonGroups : undefined;
|
|
300
556
|
return {
|
|
301
557
|
id: slot?.id ?? "offerings-plans",
|
|
302
558
|
type: "pricing",
|
|
303
559
|
data: {
|
|
304
|
-
...authoredCopy(slot),
|
|
560
|
+
...authoredCopy(slot, bound ? BOUND_KEPT_FIELDS : []),
|
|
561
|
+
...(comparisonGroups
|
|
562
|
+
? { comparisonGroups: withoutCellLinks(comparisonGroups) }
|
|
563
|
+
: {}),
|
|
305
564
|
...fragment,
|
|
306
|
-
cardLayout
|
|
565
|
+
...(cardLayout !== undefined ? { cardLayout } : {}),
|
|
566
|
+
...(features !== undefined ? { features } : {}),
|
|
307
567
|
// A `?plan=` recommendation moves the mapper's highlight onto the named
|
|
308
568
|
// plan and wears `recommendedLabel` (#8842); the mapper's own
|
|
309
569
|
// "Recommended" pill label would ride along as a second label, so it is
|
|
@@ -335,6 +595,12 @@ function stripePlansSection(
|
|
|
335
595
|
* slot is inserted after a leading hero (the add-ons directly after the last
|
|
336
596
|
* plans section) — except the plans fragment on a page with plan groups, which
|
|
337
597
|
* has said what it shows and gets no inserted section. No other section moves.
|
|
598
|
+
*
|
|
599
|
+
* With `source` (#12140 D2): each bound section in `groups` is placed the same
|
|
600
|
+
* way, an `addons` one as add-on tiles; each written section stays where it
|
|
601
|
+
* is, without Offerings checkout links, taking a `{plan}`-grammar `?plan=`;
|
|
602
|
+
* the two slots are chosen among unbound sections only; and a page that
|
|
603
|
+
* declares a `source` gets no inserted section.
|
|
338
604
|
*/
|
|
339
605
|
export function withOfferings(
|
|
340
606
|
sections: PageSection[],
|
|
@@ -345,11 +611,15 @@ export function withOfferings(
|
|
|
345
611
|
groups?: OfferingsGroups,
|
|
346
612
|
): PageSection[] {
|
|
347
613
|
const grouped = groups !== undefined && groups.size > 0;
|
|
614
|
+
const declaresSource = sections.some(
|
|
615
|
+
(s) => isPricing(s) && s.data.source !== undefined,
|
|
616
|
+
);
|
|
348
617
|
const plansSlot = sections.find(
|
|
349
|
-
(s): s is PricingSection =>
|
|
618
|
+
(s): s is PricingSection =>
|
|
619
|
+
isUnbound(s) && isPlansSection(s) && !groups?.has(s),
|
|
350
620
|
);
|
|
351
621
|
const addonsSlot = sections.find(
|
|
352
|
-
(s): s is PricingSection =>
|
|
622
|
+
(s): s is PricingSection => isUnbound(s) && s.data.variant === "addons",
|
|
353
623
|
);
|
|
354
624
|
const recommend =
|
|
355
625
|
plan !== undefined && LOOKUP_KEY_PLAN_PATTERN.test(plan) ? plan : undefined;
|
|
@@ -373,8 +643,37 @@ export function withOfferings(
|
|
|
373
643
|
const stripePlans: PageSection[] = [];
|
|
374
644
|
for (const section of sections) {
|
|
375
645
|
if (!isPricing(section)) placed.push(section);
|
|
376
|
-
else if (
|
|
377
|
-
const
|
|
646
|
+
else if (section.data.source === "written") {
|
|
647
|
+
const written = withoutCheckoutLinks(section);
|
|
648
|
+
placed.push(
|
|
649
|
+
recommend === undefined
|
|
650
|
+
? written
|
|
651
|
+
: {
|
|
652
|
+
...written,
|
|
653
|
+
// Render-time fields the section reads (#8842), not authored ones.
|
|
654
|
+
data: {
|
|
655
|
+
...written.data,
|
|
656
|
+
recommended: recommend,
|
|
657
|
+
recommendedLabel,
|
|
658
|
+
} as PricingData,
|
|
659
|
+
},
|
|
660
|
+
);
|
|
661
|
+
} else if (
|
|
662
|
+
section.data.source === "offerings" &&
|
|
663
|
+
section.data.variant === "addons"
|
|
664
|
+
) {
|
|
665
|
+
const fragment = groups?.get(section);
|
|
666
|
+
if (fragment)
|
|
667
|
+
placed.push({
|
|
668
|
+
id: section.id,
|
|
669
|
+
type: "pricing",
|
|
670
|
+
data: {
|
|
671
|
+
...authoredCopy(section, ["addonLayout", "source"]),
|
|
672
|
+
...fragment,
|
|
673
|
+
} as PricingData,
|
|
674
|
+
});
|
|
675
|
+
} else if (groups?.has(section)) {
|
|
676
|
+
const fragment = withWrittenCards(section, groups.get(section) ?? null);
|
|
378
677
|
if (fragment) {
|
|
379
678
|
const group = stripePlansSection(
|
|
380
679
|
section,
|
|
@@ -391,11 +690,11 @@ export function withOfferings(
|
|
|
391
690
|
} else if (section === addonsSlot && addonsSection)
|
|
392
691
|
placed.push(addonsSection);
|
|
393
692
|
}
|
|
394
|
-
if (plansSection && !plansSlot && !grouped) {
|
|
693
|
+
if (plansSection && !plansSlot && !grouped && !declaresSource) {
|
|
395
694
|
placed.splice(insertionIndex(placed), 0, plansSection);
|
|
396
695
|
stripePlans.push(plansSection);
|
|
397
696
|
}
|
|
398
|
-
if (addonsSection && !addonsSlot) {
|
|
697
|
+
if (addonsSection && !addonsSlot && !declaresSource) {
|
|
399
698
|
const plansAt = Math.max(-1, ...stripePlans.map((s) => placed.indexOf(s)));
|
|
400
699
|
placed.splice(
|
|
401
700
|
plansAt >= 0 ? plansAt + 1 : insertionIndex(placed),
|
|
@@ -464,11 +763,16 @@ export function pagePlans(frontmatter: unknown): string[] | undefined {
|
|
|
464
763
|
* One Pricing page's sections in its Offerings state (#10044 D5): `/pricing`'s
|
|
465
764
|
* three-state choice with the page's own `plans` passed through.
|
|
466
765
|
* - `plans: []` → the written sections, no Stripe read;
|
|
766
|
+
* - every pricing section `source: written` (#12140 D2 rule 1) → the same,
|
|
767
|
+
* no read;
|
|
467
768
|
* - unconnected → the written sections (`?plan=` moving the recommendation);
|
|
468
769
|
* - shown → the page's Stripe cards in place of its `pricing` sections,
|
|
469
770
|
* when any of its plans is shown — each plan group's own plans in its
|
|
470
|
-
* place (#12103 D2);
|
|
771
|
+
* place (#12103 D2), each bound and written section in its place (#12140);
|
|
772
|
+
* a page whose only pricing left is written takes the contact email;
|
|
471
773
|
* - anything else → the contact email in their place.
|
|
774
|
+
* On the written states a `source: written` section never links the
|
|
775
|
+
* Offerings checkout (#12140 D2 rule 7).
|
|
472
776
|
*/
|
|
473
777
|
export async function pricingSections(
|
|
474
778
|
declared: PageSection[],
|
|
@@ -479,9 +783,13 @@ export async function pricingSections(
|
|
|
479
783
|
},
|
|
480
784
|
): Promise<PageSection[]> {
|
|
481
785
|
const { plans, plan, locale } = options;
|
|
482
|
-
const
|
|
483
|
-
|
|
786
|
+
const written = declared.some(isWritten)
|
|
787
|
+
? declared.map((s) => (isWritten(s) ? withoutCheckoutLinks(s) : s))
|
|
788
|
+
: declared;
|
|
789
|
+
const asWritten = () => (plan ? withRecommendedPlan(written, plan) : written);
|
|
484
790
|
if (plans !== undefined && plans.length === 0) return asWritten();
|
|
791
|
+
const priced = declared.filter(isPricing);
|
|
792
|
+
if (priced.length > 0 && priced.every(isWritten)) return asWritten();
|
|
485
793
|
|
|
486
794
|
const read = await readShownOfferings();
|
|
487
795
|
if (read.kind === "unconnected") return asWritten();
|
|
@@ -502,8 +810,10 @@ export async function pricingSections(
|
|
|
502
810
|
addonsHeadline,
|
|
503
811
|
groups,
|
|
504
812
|
);
|
|
505
|
-
// Every pricing section left is a Stripe one; none
|
|
506
|
-
|
|
813
|
+
// Every pricing section left but a written one is a Stripe one; none
|
|
814
|
+
// means nothing shown, and written prices never stand in for the
|
|
815
|
+
// catalogue (#12140 D2 rule 5).
|
|
816
|
+
if (placed.some((s) => isPricing(s) && !isWritten(s))) return placed;
|
|
507
817
|
}
|
|
508
818
|
}
|
|
509
819
|
return withContactFallback(declared);
|
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
"monthly": "{amount}/mo",
|
|
141
141
|
"annual": "{amount}/yr",
|
|
142
142
|
"oneTime": "{amount} one-time",
|
|
143
|
+
"billedYearly": "billed {amount} yearly",
|
|
143
144
|
"withRequired": "{plan} + {required}",
|
|
144
145
|
"depositNote": "{deposit} deposit due today; the balance is invoiced."
|
|
145
146
|
},
|
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.76.0",
|
|
3
|
+
"@working-theory/admin-ui": "0.76.0",
|
|
4
|
+
"@working-theory/aeo": "0.76.0",
|
|
5
|
+
"@working-theory/agent-context": "0.76.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.76.0",
|
|
10
|
+
"@working-theory/api": "0.76.0",
|
|
11
|
+
"@working-theory/api-client": "0.76.0",
|
|
12
|
+
"@working-theory/auth": "0.76.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.76.0",
|
|
15
|
+
"@working-theory/common": "0.76.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.76.0",
|
|
18
|
+
"@working-theory/content-projection": "0.76.0",
|
|
19
|
+
"@working-theory/email": "0.76.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.76.0",
|
|
22
|
+
"@working-theory/fumadocs-schema": "0.76.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.76.0",
|
|
25
|
+
"@working-theory/license": "0.76.0",
|
|
26
|
+
"@working-theory/mcp-server": "0.76.0",
|
|
27
|
+
"@working-theory/metadata": "0.76.0",
|
|
28
|
+
"@working-theory/observability": "0.76.0",
|
|
29
|
+
"@working-theory/page-renderer": "0.76.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.16.
|
|
47
|
-
"@working-theory/api-hub": "0.
|
|
48
|
-
"@working-theory/api-multi-tenant": "0.5.
|
|
49
|
-
"@working-theory/api-scheduling": "0.6.
|
|
50
|
-
"@working-theory/api-signal-collectors": "0.7.
|
|
51
|
-
"@working-theory/api-workspace": "0.18.
|
|
31
|
+
"@working-theory/schema": "0.76.0",
|
|
32
|
+
"@working-theory/schema-pack-registry": "0.76.0",
|
|
33
|
+
"@working-theory/schema-validator": "0.76.0",
|
|
34
|
+
"@working-theory/sections-registry": "0.76.0",
|
|
35
|
+
"@working-theory/site-config": "0.76.0",
|
|
36
|
+
"@working-theory/site-pages": "0.76.0",
|
|
37
|
+
"@working-theory/spoke-checkout": "0.7.32",
|
|
38
|
+
"@working-theory/stripe-client": "0.76.0",
|
|
39
|
+
"@working-theory/templates": "0.76.0",
|
|
40
|
+
"@working-theory/theme": "0.76.0",
|
|
41
|
+
"@working-theory/ui": "0.76.0",
|
|
42
|
+
"@working-theory/validation": "0.76.0",
|
|
43
|
+
"@working-theory/web-i18n": "0.76.0",
|
|
44
|
+
"@working-theory/admin": "0.26.0",
|
|
45
|
+
"@working-theory/api-commerce": "0.2.10",
|
|
46
|
+
"@working-theory/api-content-write": "0.16.2",
|
|
47
|
+
"@working-theory/api-hub": "0.9.0",
|
|
48
|
+
"@working-theory/api-multi-tenant": "0.5.2",
|
|
49
|
+
"@working-theory/api-scheduling": "0.6.15",
|
|
50
|
+
"@working-theory/api-signal-collectors": "0.7.5",
|
|
51
|
+
"@working-theory/api-workspace": "0.18.2",
|
|
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.16.
|
|
56
|
+
"@working-theory/mcp-scheduling": "0.4.17",
|
|
57
|
+
"@working-theory/mcp-signal-collectors": "0.2.30",
|
|
58
|
+
"@working-theory/mcp-workspace": "0.16.2",
|
|
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.76.0",
|
|
62
|
+
"@working-theory/ui-docs-blog": "0.76.0",
|
|
63
|
+
"@working-theory/ui-scheduling": "0.76.0",
|
|
64
|
+
"@working-theory/ui-signal-collectors": "0.76.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.76.0"
|
|
69
69
|
}
|