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:
@@ -17,6 +17,7 @@ Events and the Hub, uses it, so the key fields are the same in every product's J
|
||||
| Env template | `crosscode.env-template/1` | Each product's `.env` variables by layer; `missingRequired` and, from 1.6.0, `checkEnvValue` / `invalidValues` (values an app can't start with, e.g. `TRUST_PROXY=TRUE`), which the Hub checks before a job | `src/agent.ts` (exported as `agent`) |
|
||||
| Devotional | `crosscode.devotional/1` | From 1.20.0: one day's devotional for the Church App (Cross Code's from the Hub at `GET /api/v2/devotionals`, or the church's own), the CSV import's columns and row checks (`checkDevotionalCsv`, `DEVOTIONAL_CSV_TEMPLATE`), shared by the Hub and the App | `src/devotional.ts` |
|
||||
| Bible passages | — | From 1.20.0: the 66 books (USFM codes, English and Afrikaans names), the seven translations with their YouVersion ids and copyright lines, `parseBibleReference`, `formatBibleReference`, `youVersionUrl` | `src/bible.ts` |
|
||||
| Demo scenarios | — | From 1.21.0: `agent.DEMO_SCENARIOS`, eight preset churches that load every product of a demo client alike (Accounts first, `DEMO_SCENARIO_ORDER`), each product's profiles, the minimum releases and agent; `seed-demo` takes `scenario` | `src/agent.ts` (exported as `agent`) |
|
||||
| Signing | — | HMAC request signing for the Hub and for product links (Node only) | `src/signing.ts` (`@crosscode/contracts/signing`) |
|
||||
|
||||
## Using it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/contracts",
|
||||
"version": "1.20.0",
|
||||
"version": "1.21.0",
|
||||
"description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads",
|
||||
"license": "UNLICENSED",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -824,7 +824,8 @@
|
||||
"enum": [
|
||||
"events",
|
||||
"website",
|
||||
"app"
|
||||
"app",
|
||||
"accounts"
|
||||
]
|
||||
},
|
||||
"profile": {
|
||||
@@ -835,7 +836,15 @@
|
||||
"small",
|
||||
"events",
|
||||
"ministry",
|
||||
"multicampus"
|
||||
"multicampus",
|
||||
"heritage-parish",
|
||||
"heritage-city",
|
||||
"bold-youth",
|
||||
"bold-plant",
|
||||
"community-family",
|
||||
"community-town",
|
||||
"clean-modern",
|
||||
"clean-campus"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -854,7 +863,14 @@
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"acacia-hill"
|
||||
"heritage-parish",
|
||||
"heritage-city",
|
||||
"bold-youth",
|
||||
"bold-plant",
|
||||
"community-family",
|
||||
"community-town",
|
||||
"clean-modern",
|
||||
"clean-campus"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -864,6 +880,19 @@
|
||||
"maxLength": 254,
|
||||
"format": "email",
|
||||
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
|
||||
},
|
||||
"scenario": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"heritage-parish",
|
||||
"heritage-city",
|
||||
"bold-youth",
|
||||
"bold-plant",
|
||||
"community-family",
|
||||
"community-town",
|
||||
"clean-modern",
|
||||
"clean-campus"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -169,17 +169,64 @@ describe("seed-demo jobs", () => {
|
||||
expect(args({ church: "hope", product: "website", profile: "bold-plant" })).toBe(true);
|
||||
expect(args({ church: "hope", product: "events", profile: "small" })).toBe(true);
|
||||
expect(args({ church: "hope", product: "website", profile: "small" })).toBe(false);
|
||||
expect(args({ church: "hope", profile: "bold-plant" })).toBe(false);
|
||||
// 1.21.0: Events has a profile per scenario too, so a scenario name with no product is an Events demo.
|
||||
expect(args({ church: "hope", profile: "bold-plant" })).toBe(true);
|
||||
expect(args({ church: "hope", product: "website", profile: "clean-campus", adminEmail: "jane@hope.test" })).toBe(false);
|
||||
expect(args({ church: "hope", product: "accounts", profile: "small" })).toBe(false);
|
||||
expect(agent.WEBSITE_DEMO_PROFILES).toHaveLength(8);
|
||||
});
|
||||
it("1.20.0: an App demo names the product and takes only an App profile, without an admin email", () => {
|
||||
expect(agent.DEMO_PRODUCTS).toContain("app");
|
||||
expect(args({ church: "demo2", product: "app", profile: "acacia-hill" })).toBe(true);
|
||||
expect(args({ church: "demo2", product: "app", profile: "bold-plant" })).toBe(false);
|
||||
expect(args({ church: "demo2", profile: "acacia-hill" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "app", profile: "acacia-hill", adminEmail: "jane@hope.test" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "app", profile: "community-family" })).toBe(true);
|
||||
expect(args({ church: "demo2", product: "app", profile: "small" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "app", profile: "acacia-hill" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "app", profile: "community-family", adminEmail: "jane@hope.test" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("demo scenarios (1.21.0)", () => {
|
||||
const args = (a: Record<string, unknown>) => agent.jobArgsSchemas["seed-demo"].safeParse(a).success;
|
||||
|
||||
it("has eight, one per Website demo profile, with unique churches", () => {
|
||||
expect(agent.DEMO_SCENARIOS.map((s) => s.key)).toEqual([...agent.WEBSITE_DEMO_PROFILES]);
|
||||
expect(new Set(agent.DEMO_SCENARIOS.map((s) => s.church)).size).toBe(8);
|
||||
});
|
||||
|
||||
it("names only profiles each product has", () => {
|
||||
for (const s of agent.DEMO_SCENARIOS) {
|
||||
for (const product of agent.DEMO_SCENARIO_ORDER) {
|
||||
expect(agent.DEMO_PROFILES_BY_PRODUCT[product]).toContain(s.profiles[product]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("loads Accounts first, every demo product once, each with a minimum release and agent", () => {
|
||||
expect(agent.DEMO_SCENARIO_ORDER[0]).toBe("accounts");
|
||||
expect([...agent.DEMO_SCENARIO_ORDER].sort()).toEqual([...agent.DEMO_PRODUCTS].sort());
|
||||
for (const p of agent.DEMO_PRODUCTS) {
|
||||
expect(agent.DEMO_SCENARIO_MIN_VERSIONS[p]).toMatch(/^\d+\.\d+\.\d+$/);
|
||||
expect(agent.SEED_DEMO_MIN_AGENT_BY_PRODUCT[p]).toMatch(/^\d+\.\d+\.\d+$/);
|
||||
}
|
||||
});
|
||||
|
||||
it("covers the App's bands from 0–100 to 2 001–5 000", () => {
|
||||
const bands = new Set(agent.DEMO_SCENARIOS.map((s) => s.appActiveMembers));
|
||||
for (const b of ["0–100", "101–300", "301–750", "751–2 000", "2 001–5 000"] as const) expect(bands).toContain(b);
|
||||
});
|
||||
|
||||
it("takes a scenario only with that scenario's profile for the product", () => {
|
||||
expect(args({ church: "demo2", product: "accounts", profile: "clean-campus", scenario: "clean-campus" })).toBe(true);
|
||||
expect(args({ church: "demo2", profile: "bold-youth", scenario: "bold-youth" })).toBe(true);
|
||||
expect(args({ church: "demo2", product: "website", profile: "bold-plant", scenario: "bold-youth" })).toBe(false);
|
||||
expect(args({ church: "demo2", profile: "events", scenario: "bold-youth" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "app", profile: "bold-youth", scenario: "nowhere" })).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps Events' four single-product demos, and Accounts takes no admin email or Events profile", () => {
|
||||
expect(args({ church: "hope", profile: "multicampus" })).toBe(true);
|
||||
expect(args({ church: "hope", profile: "clean-modern" })).toBe(true);
|
||||
expect(args({ church: "demo2", product: "accounts", profile: "small" })).toBe(false);
|
||||
expect(args({ church: "demo2", product: "accounts", profile: "clean-modern", adminEmail: "jane@hope.test" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user