contracts 1.21.0: demo scenarios, eight churches across every product

agent.DEMO_SCENARIOS (one per Website demo profile, each its own fictional
church), DEMO_SCENARIO_ORDER (Accounts first), DEMO_SCENARIO_MIN_VERSIONS,
scenario in seed-demo, accounts in DEMO_PRODUCTS, a profile per scenario for
Events and the App, SEED_SCENARIO_MIN_AGENT (1.7.0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 10:11:46 +02:00
co-authored by Claude Opus 5.5
parent b720706143
commit 7032e16894
9 changed files with 245 additions and 24 deletions
+127 -9
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { dateTimeSchema, productSchema } from "./common";
import type { ACTIVE_MEMBER_BANDS } from "./hub";
/**
* The server agent (docs/AGENT-1.0-PLAN.md, ROADMAP-v3 phase 1d): what the Hub and the agent on
@@ -72,18 +73,120 @@ export const WEBSITE_DEMO_PROFILES = [
export const websiteDemoProfileSchema = z.enum(WEBSITE_DEMO_PROFILES);
export type WebsiteDemoProfile = z.infer<typeof websiteDemoProfileSchema>;
/** The Church App's demo data sets (1.20.0): Acacia Hill, the demo church (APP-1.0-PLAN §12). */
export const APP_DEMO_PROFILES = ["acacia-hill"] as const;
// ─── Demo scenarios (1.21.0, APP-1.0-PLAN §12 "Demo scenarios") ──────────────
/**
* A demo scenario loads every product of a demo client with the same church: Accounts' church
* profile (its own name, logo, icon, colours and details) and people, then Events, the Website and
* the App, each with that church's data. One per Website demo profile, keyed by it.
*/
export const DEMO_SCENARIO_KEYS = WEBSITE_DEMO_PROFILES;
export const demoScenarioSchema = z.enum(DEMO_SCENARIO_KEYS);
export type DemoScenarioKey = z.infer<typeof demoScenarioSchema>;
/**
* Cross Events' demo data sets: the four single-product ones (`set-demo.js`) and, from Events
* 3.8.0, one per scenario, named after it.
*/
export const EVENTS_DEMO_PROFILES = [...DEMO_PROFILES, ...DEMO_SCENARIO_KEYS] as const;
export const eventsDemoProfileSchema = z.enum(EVENTS_DEMO_PROFILES);
/**
* The Church App's demo data sets: one per scenario (1.21.0; 1.20.0's `acacia-hill` is the
* `community-family` scenario, and no App had shipped with it).
*/
export const APP_DEMO_PROFILES = DEMO_SCENARIO_KEYS;
export const appDemoProfileSchema = z.enum(APP_DEMO_PROFILES);
export type AppDemoProfile = z.infer<typeof appDemoProfileSchema>;
/** The products with demo data (`seed-demo` jobs). 1.20.0 adds `app`. */
export const DEMO_PRODUCTS = ["events", "website", "app"] as const;
/** Accounts' demo data sets (1.21.0): a scenario's church profile and people. One per scenario. */
export const ACCOUNTS_DEMO_PROFILES = DEMO_SCENARIO_KEYS;
/** The products with demo data (`seed-demo` jobs). 1.20.0 adds `app`, 1.21.0 `accounts`. */
export const DEMO_PRODUCTS = ["events", "website", "app", "accounts"] as const;
export const demoProductSchema = z.enum(DEMO_PRODUCTS);
export type DemoProduct = z.infer<typeof demoProductSchema>;
/** Each demo product's profiles. */
export const DEMO_PROFILES_BY_PRODUCT: Record<DemoProduct, readonly string[]> = { events: DEMO_PROFILES, website: WEBSITE_DEMO_PROFILES, app: APP_DEMO_PROFILES };
export const DEMO_PROFILES_BY_PRODUCT: Record<DemoProduct, readonly string[]> = {
events: EVENTS_DEMO_PROFILES, website: WEBSITE_DEMO_PROFILES, app: APP_DEMO_PROFILES, accounts: ACCOUNTS_DEMO_PROFILES,
};
const DEMO_PRODUCT_NAMES: Record<DemoProduct, string> = { events: "Cross Events", website: "Website", app: "App", accounts: "Accounts" };
/** The order a scenario loads in: Accounts first (the profile and people the others read). */
export const DEMO_SCENARIO_ORDER = ["accounts", "events", "website", "app"] as const satisfies readonly DemoProduct[];
/** The first release of each product that loads a scenario (`--scenario`). The Hub refuses a scenario for an older install. */
export const DEMO_SCENARIO_MIN_VERSIONS: Record<DemoProduct, string> = { accounts: "1.9.0", events: "3.8.0", website: "1.8.0", app: "1.0.0" };
export interface DemoScenario {
key: DemoScenarioKey;
/** The church's name in the demo. */
church: string;
/** For the Hub's list. */
label: string;
description: string;
/** The profile each product loads. */
profiles: { accounts: string; events: string; website: string; app: string };
/** Campuses in the church profile. */
campuses: number;
/** The demo's main language (Afrikaans content and devotionals for `af`). */
language: "en" | "af";
/** The App's active-member band its people give it, so the scenarios show the Hub's tiers. */
appActiveMembers: (typeof ACTIVE_MEMBER_BANDS)[number];
}
const scenario = (key: DemoScenarioKey, s: Omit<DemoScenario, "key" | "profiles">): DemoScenario =>
({ key, ...s, profiles: { accounts: key, events: key, website: key, app: key } });
/** The eight scenarios (Joshua, 2026-11-30). Every church and person in them is fictional. */
export const DEMO_SCENARIOS: readonly DemoScenario[] = [
scenario("heritage-parish", {
church: "St Columba's", label: "Heritage: St Columba's, a parish church",
description: "A 120-year-old parish church, small and older, one Sunday service. Carols, a harvest festival, a quiet prayer wall and a Lent campaign.",
campuses: 1, language: "en", appActiveMembers: "0–100",
}),
scenario("heritage-city", {
church: "Grace Cathedral", label: "Heritage: Grace Cathedral, a city-centre church",
description: "Three Sunday services and lunchtime prayer. A concert series, ticketed Easter services, a prayer wall full in office hours with gaps at night.",
campuses: 1, language: "en", appActiveMembers: "301–750",
}),
scenario("bold-youth", {
church: "Ignite Church", label: "Bold: Ignite Church, young and music-led",
description: "A youth conference with paid registration and a worship night, a 21-day prayer campaign before it, testimonies and WhatsApp reminders.",
campuses: 1, language: "en", appActiveMembers: "751–2 000",
}),
scenario("bold-plant", {
church: "Harbour City", label: "Bold: Harbour City, a new church plant",
description: "Two years old, meeting in a school hall. Launch Sunday, a newcomers' lunch, a prayer wall still filling up and the admin's setup half done.",
campuses: 1, language: "en", appActiveMembers: "0–100",
}),
scenario("community-family", {
church: "Acacia Hill", label: "Community: Acacia Hill, a family church",
description: "The mockup's church (cross-demo2). Kids' club, Alpha, family camp and volunteer rosters, a 21-day campaign, prayer requests waiting for approval.",
campuses: 1, language: "en", appActiveMembers: "101–300",
}),
scenario("community-town", {
church: "Karoo Gemeenskapskerk", label: "Community: Karoo Gemeenskapskerk, a country-town church",
description: "Mostly Afrikaans. A bazaar and a prayer breakfast, its own AFR83 devotionals, 30-minute prayer slots.",
campuses: 1, language: "af", appActiveMembers: "101–300",
}),
scenario("clean-modern", {
church: "Northpoint", label: "Clean: Northpoint, a contemporary church",
description: "About 600 people. Courses, a groups launch and serve teams, every prayer hour covered twice, announcements by WhatsApp.",
campuses: 1, language: "en", appActiveMembers: "301–750",
}),
scenario("clean-campus", {
church: "Riverside", label: "Clean: Riverside, three campuses near the university",
description: "Student welcome week at one campus and a combined worship night, one prayer wall for all three, announcements per campus.",
campuses: 3, language: "en", appActiveMembers: "2 001–5 000",
}),
];
export function demoScenario(key: DemoScenarioKey): DemoScenario {
return DEMO_SCENARIOS.find((s) => s.key === key)!;
}
/** The first agent that runs `seed-demo` jobs (an older one refuses the unknown type). */
export const SEED_DEMO_MIN_AGENT = "1.2.0";
@@ -97,6 +200,14 @@ export const SEED_WEBSITE_DEMO_MIN_AGENT = "1.6.0";
*/
export const SEED_APP_DEMO_MIN_AGENT = "1.7.0";
/** 1.21.0: the first agent that runs `seed-demo` for Accounts and with a `scenario` (passed on as `--scenario`). */
export const SEED_SCENARIO_MIN_AGENT = "1.7.0";
/** The first agent that runs a product's `seed-demo` jobs. */
export const SEED_DEMO_MIN_AGENT_BY_PRODUCT: Record<DemoProduct, string> = {
events: SEED_DEMO_MIN_AGENT, website: SEED_WEBSITE_DEMO_MIN_AGENT, app: SEED_APP_DEMO_MIN_AGENT, accounts: SEED_SCENARIO_MIN_AGENT,
};
/** The first agent that runs `env-read` and `env-set` jobs (an older one refuses the unknown types). */
export const ENV_JOBS_MIN_AGENT = "1.3.0";
@@ -170,22 +281,29 @@ export const jobArgsSchemas = {
/** `crosscode restart <church> [product] --json` (PM2 reload) */
restart: z.strictObject({ church: shortNameSchema, product: productSchema.optional() }),
/**
* `crosscode demo <church> [website|app] --profile <profile> [--admin-email <email>] --json`: replaces
* `crosscode demo <church> [website|app|accounts] --profile <profile> [--scenario <s>] [--admin-email <email>] --json`: replaces
* Cross Events' data (or, 1.19.0 with `product: "website"`, the Website's content) with a demo
* set (a backup is taken first); 1.20.0 adds `product: "app"` (the App's prayer wall, campaign,
* testimonies, devotionals, announcements and events). The Hub only makes it for installs marked as demo sites.
* `adminEmail` (Events only): the account kept (default: the release's own choice). No `product`
* is Events, so older Hubs' jobs mean what they did.
* is Events, so older Hubs' jobs mean what they did. 1.21.0: `product: "accounts"` (the
* scenario's church profile, with its logo and icon, and its people) and `scenario`: one job per
* product in `DEMO_SCENARIO_ORDER`, each with the scenario's profile for that product.
*/
"seed-demo": z.strictObject({
church: shortNameSchema,
product: demoProductSchema.optional(),
profile: z.union([demoProfileSchema, websiteDemoProfileSchema, appDemoProfileSchema]),
profile: z.union([eventsDemoProfileSchema, websiteDemoProfileSchema, appDemoProfileSchema]),
adminEmail: z.email().max(254).optional(),
/** 1.21.0: part of loading this scenario (the profile must be the scenario's for the product). */
scenario: demoScenarioSchema.optional(),
}).superRefine((a, ctx) => {
const product = a.product ?? "events";
if (!DEMO_PROFILES_BY_PRODUCT[product].includes(a.profile)) ctx.addIssue({ code: "custom", path: ["profile"], message: `${a.profile} isn't a ${product} demo` });
if (product !== "events" && a.adminEmail) ctx.addIssue({ code: "custom", path: ["adminEmail"], message: `the ${product === "app" ? "App" : "Website"}'s demo keeps every admin` });
if (product !== "events" && a.adminEmail) ctx.addIssue({ code: "custom", path: ["adminEmail"], message: `the ${DEMO_PRODUCT_NAMES[product]}'s demo keeps every admin` });
if (a.scenario && demoScenario(a.scenario).profiles[product] !== a.profile) {
ctx.addIssue({ code: "custom", path: ["profile"], message: `the ${a.scenario} scenario loads ${demoScenario(a.scenario).profiles[product]} in ${DEMO_PRODUCT_NAMES[product]}` });
}
}),
/**
* `crosscode env <church> <product> --json`: the product's .env values, secrets hidden (only