Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
101248195f | ||
|
|
805967a85a | ||
|
|
8055e1ec62 | ||
|
|
799c193fe1 | ||
|
|
f651ae2530 | ||
|
|
74dee881e4 | ||
|
|
969d0110a1 | ||
|
|
fd097d8446 | ||
|
|
9cf2956aff | ||
|
|
986d69d51d | ||
|
|
d3789f9b30 | ||
|
|
ce169851f7 | ||
|
|
0b518761b7 | ||
|
|
a5e3a6bb6c | ||
|
|
2e8e4c04ca | ||
|
|
7391f97cfa | ||
|
|
c8e270dbf1 | ||
|
|
b2a163bb39 | ||
|
|
2eef8d1da3 | ||
|
|
dfd7278f7b | ||
|
|
aacfd228a6 |
@@ -2,6 +2,84 @@
|
||||
|
||||
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
|
||||
|
||||
## events@3.9.0 + website@1.9.0 + accounts@1.10.0 - 2026-12-01
|
||||
|
||||
The church's details from Accounts on every site, section backgrounds, one colour picker (Joshua,
|
||||
2026-12-01). No migrations; no contracts change.
|
||||
|
||||
- **Events 3.9.0:** the Accounts profile's name, logo, icon, colours and contact details win over
|
||||
Events' own settings while Accounts is connected (pages, emails, WhatsApp, PDFs), and Settings
|
||||
shows them read-only with a link to Accounts. The logo from Accounts is copied for PDFs, and SVG logos
|
||||
are drawn in PDFs (`svg-to-pdfkit`, new dependency). Fixes Events keeping its old church after a demo scenario load.
|
||||
- **Website 1.9.0:** a background for each homepage section in the church's colours; "More info"
|
||||
instead of "Register" for events without registration; the shared colour field in Church
|
||||
details.
|
||||
- **Accounts 1.10.0:** the shared colour field in Church profile.
|
||||
- **`@crosscode/ui` 0.4.0:** `ColourField` and `isHexColour`.
|
||||
- Checked: Events backend tests (828), Website backend tests (149), typecheck and lint of every
|
||||
changed app.
|
||||
|
||||
## contracts@1.24.0 - 2026-11-30
|
||||
|
||||
Cross Code's devotionals two years ahead, and Apps fetch 2 weeks (Joshua, 2026-11-30). Additive.
|
||||
|
||||
- `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS` (24): how far ahead the Hub schedules them.
|
||||
- `CROSSCODE_DEVOTIONALS_FETCH_DAYS` (14): the most days one `GET /api/v2/devotionals` answer
|
||||
covers, `from` included. `CROSSCODE_DEVOTIONALS_AHEAD_MONTHS` (3) is kept but deprecated.
|
||||
- The devotionals CSV takes 800 rows and 8 MB (was 400 and 2 MB), so two years fit in one file; a
|
||||
date past `latestDate` says "too far ahead (the last day is …)" instead of naming 3 months.
|
||||
- Checked: contracts' tests (341), typecheck.
|
||||
|
||||
## agent@1.7.0 + contracts@1.23.0 + crosscode script - 2026-11-30
|
||||
|
||||
Church App 1.0.0 groundwork in the server agent (docs/APP-1.0-PLAN.md §12, "Demo scenarios").
|
||||
|
||||
- **Contracts 1.23.0:** the `seed-scenario` job (`church`, `scenario`, optional `adminEmail`; 45
|
||||
minutes): a whole demo scenario in one job, on whatever the church has installed.
|
||||
`SEED_SCENARIO_JOB_MIN_AGENT` (1.7.0). Additive.
|
||||
- **Agent 1.7.0:** `seed-scenario` → `crosscode demo <church> --scenario <s>`; `seed-demo` for `accounts` and `app` (`crosscode demo <church> <product> …`),
|
||||
and `scenario` passed on as `--scenario` for every product (contracts `SEED_SCENARIO_MIN_AGENT`,
|
||||
`SEED_APP_DEMO_MIN_AGENT`). Events' jobs keep their old form (no product).
|
||||
- **crosscode script:** `crosscode demo <church> --scenario <s>` (no product, no profile) loads the
|
||||
scenario on every product the church has here, in deploy order, skipping the others; checks
|
||||
every installed release against the scenario minimums first; each product takes its own
|
||||
backup; the first failure stops the rest and names what's out of step (`loaded`, `skipped` in
|
||||
the report). Events' demo is now `cmd_demo_events`. `crosscode demo <church> app …` says the
|
||||
App's demo comes with App 1.0.0, instead of misreading `app` as a second church.
|
||||
|
||||
## website@1.8.0 + crosscode script - 2026-11-30
|
||||
|
||||
Church App 1.0.0 groundwork in the Church Website (docs/APP-1.0-PLAN.md §12, "Demo scenarios"). No
|
||||
migration. Details in `apps/website/CHANGELOG.md`.
|
||||
|
||||
- **Website 1.8.0:** `npm run demo -- --profile <p> --scenario <p>` loads a profile as part of its
|
||||
demo scenario: the leaders are the scenario's people (`@crosscode/demo`), the pastor the home
|
||||
page's and the messages' speaker; with a linked Cross Events, Events' events show through the
|
||||
feed (Show events from, fetched at once) instead of the profile's own.
|
||||
- **crosscode script:** `crosscode demo <church> website … --scenario <p>` passes it on and refuses a
|
||||
Website before 1.8.0; the Website installs and builds `packages/demo`.
|
||||
|
||||
## contracts@1.22.0 - 2026-11-30
|
||||
|
||||
Bible translations for the Church App's devotionals (docs/BIBLE-PERMISSIONS.md, APP-1.0-PLAN.md §6
|
||||
and decision 14). Additive except for the notice texts and one translation's name; no id changes,
|
||||
nothing has shown them yet.
|
||||
|
||||
- **Only free translations in 1.0:** each translation has a `licence` ("public-domain" or
|
||||
"permission"); `FREE_BIBLE_TRANSLATION_IDS` (KJV, BSB) is what the Hub and the App offer, and
|
||||
`checkDevotionalCsv(text, { translations })` refuses any other, naming the publisher to ask.
|
||||
- **The Berean Standard Bible (`BSB`)**, public domain since 2023, YouVersion 3034. The CSV template
|
||||
and the devotionals sample now quote the BSB and the KJV.
|
||||
- **Notices corrected** to each publisher's current wording: NLT (Tyndale House Ministries), ESV
|
||||
(ESV Text Edition: 2025, the Creative Commons and translation clauses), AFR53 and AFR83 (the
|
||||
Bible Society's digital short form). The NIV and NKJV notices were already right.
|
||||
- **`AFR83` is named "Afrikaans 1983/1992-vertaling"**, as the Bible Society names it.
|
||||
- **New per translation:** `acknowledgement` (the full notice, for the App's Acknowledgements
|
||||
page), `disclaimer` (the Bible Society's, required with its translations next to content it
|
||||
hasn't approved; null for the others), `publisher` and `permissionsUrl` (null for the KJV).
|
||||
- **`FREE_QUOTE_VERSES`** (500) and **`quotedVerses(passages)`**: verses quoted per translation,
|
||||
so the Hub and the App can warn before the free allowance runs out. `devotionalDisclaimer`.
|
||||
|
||||
## events@3.8.0 + @crosscode/demo 1.1.0 + crosscode script - 2026-11-30
|
||||
|
||||
Church App 1.0.0 groundwork in Cross Events (docs/APP-1.0-PLAN.md §8 and §12). One migration.
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
# Cross Code platform
|
||||
|
||||
The monorepo for the Cross Code products that come after Cross Events, and the formats they share.
|
||||
The plan for every product is in [`docs/ROADMAP-v3.md`](./docs/ROADMAP-v3.md) (decided 2026-11-03); where
|
||||
things stand is in [`docs/HANDOVER.md`](./docs/HANDOVER.md).
|
||||
The monorepo for every Cross Code product except the Hub, and the formats they share. The plan for
|
||||
every product is in [`docs/ROADMAP-v3.md`](./docs/ROADMAP-v3.md) (decided 2026-11-03); where things
|
||||
stand is in [`docs/HANDOVER.md`](./docs/HANDOVER.md), and the latest release of everything in
|
||||
[`docs/VERSIONS.md`](./docs/VERSIONS.md).
|
||||
|
||||
| Folder | What | Status |
|
||||
|--------|------|--------|
|
||||
| `packages/contracts` | `@crosscode/contracts`: the shared JSON formats (zod schemas, JSON Schema, TypeScript types, sample payloads) used by every product, including Cross Events and the Hub | Phase 0, in progress |
|
||||
| `packages/ui` | `@crosscode/ui`: shared UI for the Website, App and Accounts | Placeholder, filled in during the Website phase |
|
||||
| `apps/accounts` | Accounts: the per-church sign-in (OpenID Connect) | Placeholder (phase 3) |
|
||||
| `apps/website` | Church Website | Placeholder (phase 5) |
|
||||
| `apps/app` | Church App (PWA) | Placeholder (phase 6) |
|
||||
| `apps/events` | Cross Events (moved in from `joshua/hope-events` in 2.2.0) | Released and in use |
|
||||
| `apps/accounts` | Accounts: the per-church sign-in (OpenID Connect), the church profile | Released and in use |
|
||||
| `apps/website` | Church Website | Released and in use (phase 5) |
|
||||
| `apps/app` | Church App (PWA, House of Prayer) | Placeholder, being built (phase 6, [`docs/APP-1.0-PLAN.md`](./docs/APP-1.0-PLAN.md)) |
|
||||
| `apps/agent` | The server agent: runs the Hub's signed jobs through the `crosscode` script | Released and in use |
|
||||
| `packages/contracts` | `@crosscode/contracts`: the shared JSON formats (zod schemas, JSON Schema, TypeScript types, sample payloads) used by every product, including the Hub | Released and in use |
|
||||
| `packages/auth-client` | `@crosscode/auth-client`: how a product signs in through Accounts | In use |
|
||||
| `packages/seo` | `@crosscode/seo`: JSON-LD and meta for every public site | In use |
|
||||
| `packages/ui` | `@crosscode/ui`: fonts, brand style, `ChurchFooter` | In use |
|
||||
| `packages/demo` | `@crosscode/demo`: the demo scenarios' churches, people and logos | In use (Accounts, Events, the Website) |
|
||||
| `scripts/` | The `crosscode` script: install, deploy, demo, env, export, uninstall on the servers | In use (`main` is the release) |
|
||||
|
||||
Cross Events (`joshua/hope-events`) moves in as `apps/events` in Events 2.2.0
|
||||
([`docs/EVENTS-2.2-PLAN.md`](./docs/EVENTS-2.2-PLAN.md)). Cross Code Hub (`joshua/events-hub`) stays in
|
||||
its own repo and gets `@crosscode/contracts` as a packed release committed there (decision 22).
|
||||
Cross Code Hub (`joshua/events-hub`) stays in its own repo and gets `@crosscode/contracts` as a
|
||||
packed release committed there (decision 22).
|
||||
|
||||
## Docs
|
||||
|
||||
@@ -22,8 +28,11 @@ its own repo and gets `@crosscode/contracts` as a packed release committed there
|
||||
|------|------|
|
||||
| [`docs/ROADMAP-v3.md`](./docs/ROADMAP-v3.md) | The plan: products, contracts, Accounts, sync, Hub, servers, build order, pricing, decisions |
|
||||
| [`docs/HANDOVER.md`](./docs/HANDOVER.md) | Where each phase stands and what's next |
|
||||
| [`docs/VERSIONS.md`](./docs/VERSIONS.md) | The latest release of everything, and what's deployed where |
|
||||
| [`docs/hub-protocol.md`](./docs/hub-protocol.md) | Install ↔ Hub protocol, versions 1 and 2 (a copy lives in `events-hub`) |
|
||||
| [`docs/EVENTS-2.2-PLAN.md`](./docs/EVENTS-2.2-PLAN.md) | Phase 1b: Cross Events into the monorepo, the `crosscode` script |
|
||||
| `docs/*-PLAN.md` | Each phase's plan and decisions (Events 2.2, 2.4, 3.0; Accounts 1.0; Agent 1.0; Website 1.0; App 1.0) |
|
||||
| [`docs/ROLLOUT-1.0.md`](./docs/ROLLOUT-1.0.md) | The rollout checklist |
|
||||
| [`docs/BIBLE-PERMISSIONS.md`](./docs/BIBLE-PERMISSIONS.md) | The Bible publishers' terms for the Church App's devotionals, the permission requests and their status |
|
||||
|
||||
## Rules (ROADMAP-v3 §1)
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# Changelog — Accounts
|
||||
|
||||
## [1.10.0] - 2026-12-01
|
||||
|
||||
No migration, no new .env variables, no backend change. Needs `@crosscode/ui` 0.4.0 (built with
|
||||
Accounts).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Admin → Church profile:** the main and accent colours use the shared colour field
|
||||
(`ColourField`, `@crosscode/ui` 0.4.0): a swatch, the hex code to type or paste, a preview, and a
|
||||
message when the code isn't a colour, as Cross Events' Branding settings. Cross Events 3.9.0
|
||||
now takes the church's name, logo, colours and contact details from this profile too.
|
||||
|
||||
## [1.9.0] - 2026-11-30
|
||||
|
||||
Needs contracts 1.21.0 and the new shared package `@crosscode/demo` (built with Accounts; the
|
||||
|
||||
@@ -16,6 +16,10 @@ sign-in settings, linked products and the church profile here.
|
||||
- Roles stay in each product: Accounts only knows who someone is (plan §2, "Roles stay in each
|
||||
product").
|
||||
- Products sign in with `@crosscode/auth-client` (packages/auth-client).
|
||||
- 1.9.0: the church's one set of email and WhatsApp settings for the App (`messaging.get`,
|
||||
`messaging.changed`); the WhatsApp opt-out for every product (`src/accounts/whatsapp.ts`, its own
|
||||
WAWP webhook in `src/links/whatsappWebhook.ts`); demo scenarios (`npm run demo -- --profile
|
||||
<scenario> --force`, `src/demo/scenario.ts`, with `@crosscode/demo`; demo sites only).
|
||||
|
||||
Local development: Postgres in `backend/.env` (`DATABASE_URL`, `ACCOUNTS_URL=http://localhost:3200`,
|
||||
`LINKS_ALLOW_PRIVATE=true`), `npx prisma migrate deploy`, then `npm run dev` in both folders (the
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
What each version changes for the church, in plain language (read by the Hub like Cross Events'
|
||||
WHATS-NEW.md; a section shows once its version is tagged).
|
||||
|
||||
## 1.10.0
|
||||
|
||||
- **An easier colour picker** in **Church profile**: pick your main and accent colours, or type or
|
||||
paste their codes (like #1f4e79), and see them straight away.
|
||||
- Your Events site (from version 3.9.0) now uses the name, logo, colours and contact details in
|
||||
your church profile here, as your website does, so you change them in one place.
|
||||
|
||||
## 1.9.0
|
||||
|
||||
- **STOP works for every site.** Someone who replies STOP to your church's WhatsApp number gets no
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/accounts-backend",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.0",
|
||||
"description": "Cross Code Accounts: the church's sign-in (OpenID Connect provider), account pages API and admin API",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/accounts-frontend",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.0",
|
||||
"private": true,
|
||||
"description": "Cross Code Accounts: the church's sign-in pages, the account page and admin",
|
||||
"scripts": {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
AlertTriangle, ArrowRight, Building2, CheckCircle2, ChevronRight, DatabaseBackup, Download, Eye, FileText, KeyRound, Link2, LogIn, Mail, MessageCircle, Play,
|
||||
RefreshCw, ScrollText, Search, ShieldCheck, Timer, UserX, Users,
|
||||
} from "lucide-react";
|
||||
import { Button, Checkbox, Field, Notice } from "@crosscode/ui";
|
||||
import { Button, Checkbox, ColourField, Field, Notice } from "@crosscode/ui";
|
||||
import { ADMIN_GROUPS, ADMIN_NAV, AppShell, PageTitle, ShellLoading, type ShellUser } from "@/components/AppShell";
|
||||
import { NoticeText } from "@/components/NoticeText";
|
||||
import { Card, Heading } from "@/components/Panel";
|
||||
@@ -325,6 +325,8 @@ type ChurchData = { name: string; shortName: string | null; branding: { logoUrl:
|
||||
function Church({ flash }: { flash: Flash }) {
|
||||
const [c, setC] = useState<ChurchData | null>(null);
|
||||
const [fields, setFields] = useState<Record<string, string>>({});
|
||||
// The two colours as typed (ColourField is controlled); the saved ones until changed.
|
||||
const [colours, setColours] = useState<{ primary?: string; accent?: string }>({});
|
||||
useExternalEffect(() => {
|
||||
let alive = true;
|
||||
call<ChurchData>("GET", "/admin/church").then((r) => { if (alive && r.ok) setC(r.data); });
|
||||
@@ -344,14 +346,16 @@ function Church({ flash }: { flash: Flash }) {
|
||||
branding: { ...c.branding, logoUrl: nul(f.get("logoUrl")), colours: { primary: f.get("primary"), accent: nul(f.get("accent")) } },
|
||||
contact: { ...c.contact, email: nul(f.get("email")), phone: nul(f.get("phone")), whatsapp: nul(f.get("whatsapp")) },
|
||||
});
|
||||
if (r.ok) { setC(r.data); setFields({}); flash("success", "Saved. The church's products are told about the change."); } else { setFields(r.error.fields ?? {}); flash("error", r.error.message); }
|
||||
if (r.ok) { setC(r.data); setFields({}); setColours({}); flash("success", "Saved. The church's products are told about the change."); } else { setFields(r.error.fields ?? {}); flash("error", r.error.message); }
|
||||
}}>
|
||||
<Field label="Name" name="name" defaultValue={c.name} required error={fields.name} />
|
||||
<Field label="Short name" name="shortName" defaultValue={c.shortName ?? ""} maxLength={30} hint="For small spaces, like the authenticator app's label." error={fields.shortName} />
|
||||
<Field label="Logo address (https://…)" name="logoUrl" type="url" defaultValue={c.branding.logoUrl ?? ""} error={fields["branding.logoUrl"]} />
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field label="Main colour" name="primary" type="color" defaultValue={c.branding.colours.primary} />
|
||||
<Field label="Accent colour" name="accent" type="color" defaultValue={c.branding.colours.accent ?? "#f2a900"} />
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<ColourField label="Main colour" name="primary" value={colours.primary ?? c.branding.colours.primary} onChange={(primary) => setColours((x) => ({ ...x, primary }))}
|
||||
hint="Buttons, links and headings on every site." error={fields["branding.colours.primary"]} />
|
||||
<ColourField label="Accent colour" name="accent" value={colours.accent ?? c.branding.colours.accent ?? "#f2a900"} onChange={(accent) => setColours((x) => ({ ...x, accent }))}
|
||||
hint="Highlights and touches beside the main colour." error={fields["branding.colours.accent"]} />
|
||||
</div>
|
||||
<Field label="Office email" name="email" type="email" defaultValue={c.contact.email ?? ""} error={fields["contact.email"]} />
|
||||
<Field label="Office phone" name="phone" defaultValue={c.contact.phone ?? ""} hint="With the country code, e.g. +27161234567." error={fields["contact.phone"]} />
|
||||
|
||||
@@ -13,6 +13,16 @@ Write for the person updating servers: what the agent can now do from the Hub, a
|
||||
contracts version needs it. The developer log is the commit history of apps/agent.
|
||||
-->
|
||||
|
||||
## 1.7.0
|
||||
|
||||
- **Demo scenarios.** The Hub (2.26.0 and later) can load a whole demo church on a demo client:
|
||||
Accounts first, then Cross Events, the Website and the App, the same church and people in each.
|
||||
It's one job: the server loads **whatever the client has installed** and skips the rest, so a
|
||||
client with only Accounts and the Website gets both. Every product's release is checked first
|
||||
(Accounts 1.9.0, Events 3.8.0, Website 1.8.0); if one fails part-way, the report says which
|
||||
products are out of step. The agent also runs single demo jobs for Accounts and (from App
|
||||
1.0.0) the Church App. Single-product demo data works as before.
|
||||
|
||||
## 1.6.0
|
||||
|
||||
- **Demo data for the Church Website.** The Hub (2.25.0 and later) can load one of the Website's
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/agent",
|
||||
"version": "1.6.0",
|
||||
"version": "1.7.0",
|
||||
"private": true,
|
||||
"description": "The server agent: runs the crosscode script for signed jobs from Cross Code Hub, reports stats (docs/AGENT-1.0-PLAN.md)",
|
||||
"license": "UNLICENSED",
|
||||
|
||||
@@ -58,10 +58,20 @@ export function crosscodeArgs(job: agent.AgentJob, opts: { exportFile?: string }
|
||||
if (job.args.restart) out.push("--restart");
|
||||
return out;
|
||||
}
|
||||
case "seed-demo":
|
||||
case "seed-demo": {
|
||||
// 1.6.0: the Website's demo names the product; Events' (no product) keeps its old form.
|
||||
return ["demo", job.args.church, ...(job.args.product === "website" ? ["website"] : []), "--profile", job.args.profile,
|
||||
...(job.args.adminEmail ? ["--admin-email", job.args.adminEmail] : [])];
|
||||
// 1.7.0: the App's and Accounts' too, and a demo scenario passed on (`--scenario`), so each
|
||||
// product can tell a scenario load from a single one.
|
||||
const a = job.args;
|
||||
const product = a.product && a.product !== "events" ? [a.product] : [];
|
||||
return ["demo", a.church, ...product, "--profile", a.profile,
|
||||
...(a.scenario ? ["--scenario", a.scenario] : []),
|
||||
...(a.adminEmail ? ["--admin-email", a.adminEmail] : [])];
|
||||
}
|
||||
case "seed-scenario":
|
||||
// 1.7.0: a whole demo scenario. No product named: the script loads every product the church
|
||||
// has on this server, Accounts first, and skips the others.
|
||||
return ["demo", job.args.church, "--scenario", job.args.scenario, ...(job.args.adminEmail ? ["--admin-email", job.args.adminEmail] : [])];
|
||||
case "export":
|
||||
if (!opts.exportFile) throw new Error("export needs a file to write");
|
||||
return ["export", job.args.church, ...(job.args.products ?? []), "--out", opts.exportFile];
|
||||
|
||||
@@ -12,7 +12,7 @@ import { paths } from "./paths";
|
||||
* the tools that are there; anything missing is null rather than an error.
|
||||
*/
|
||||
|
||||
export const AGENT_VERSION = "1.6.0";
|
||||
export const AGENT_VERSION = "1.7.0";
|
||||
|
||||
function run(cmd: string, args: string[], timeoutMs = 10_000): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@@ -52,6 +52,26 @@ describe("crosscode arguments for each job", () => {
|
||||
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "events", profile: "small" } }))).toEqual(["demo", "hope", "--profile", "small"]);
|
||||
});
|
||||
|
||||
it("seed-scenario 1.7.0: one job, no product named, so the server seeds whatever the church has", () => {
|
||||
expect(crosscodeArgs(parsed({ type: "seed-scenario", args: { church: "demo2", scenario: "community-family" } }))).toEqual(["demo", "demo2", "--scenario", "community-family"]);
|
||||
expect(crosscodeArgs(parsed({ type: "seed-scenario", args: { church: "demo2", scenario: "bold-youth", adminEmail: "jane@hope.test" } })))
|
||||
.toEqual(["demo", "demo2", "--scenario", "bold-youth", "--admin-email", "jane@hope.test"]);
|
||||
expect(() => parsed({ type: "seed-scenario", args: { church: "demo2", scenario: "bold-youth", products: ["website"] } })).toThrow();
|
||||
});
|
||||
|
||||
it("seed-demo 1.7.0: the App's and Accounts' demos, and a scenario passed on to every product", () => {
|
||||
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "app", profile: "community-family" } }))).toEqual(["demo", "hope", "app", "--profile", "community-family"]);
|
||||
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "accounts", profile: "bold-youth", scenario: "bold-youth" } })))
|
||||
.toEqual(["demo", "hope", "accounts", "--profile", "bold-youth", "--scenario", "bold-youth"]);
|
||||
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "website", profile: "clean-campus", scenario: "clean-campus" } })))
|
||||
.toEqual(["demo", "hope", "website", "--profile", "clean-campus", "--scenario", "clean-campus"]);
|
||||
// Events keeps its old form (no product), with the scenario and the admin kept.
|
||||
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "events", profile: "bold-youth", scenario: "bold-youth", adminEmail: "jane@hope.test" } })))
|
||||
.toEqual(["demo", "hope", "--profile", "bold-youth", "--scenario", "bold-youth", "--admin-email", "jane@hope.test"]);
|
||||
// A scenario's profile must be the scenario's for that product (the contracts refuse the job).
|
||||
expect(() => parsed({ type: "seed-demo", args: { church: "hope", product: "website", profile: "bold-plant", scenario: "bold-youth" } })).toThrow();
|
||||
});
|
||||
|
||||
it("env-read and env-set (1.3.0): crosscode env, each value its own argument", () => {
|
||||
expect(crosscodeArgs(parsed({ type: "env-read", args: { church: "hope", product: "accounts" } }))).toEqual(["env", "hope", "accounts"]);
|
||||
expect(crosscodeArgs(parsed({
|
||||
|
||||
@@ -5,6 +5,41 @@ All notable changes to this project are documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project follows [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [3.9.0] - 2026-12-01
|
||||
|
||||
No migration, no new settings or environment variables. One new dependency: `svg-to-pdfkit`
|
||||
0.1.8 (MIT, pure JavaScript; draws SVG logos in PDFs). Works with any Accounts; nothing changes on
|
||||
a site without Accounts.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The church's details come from Accounts.** The church profile set only the fonts, corners and
|
||||
footer, so after a change in Accounts (or a demo scenario loaded on a new church) Events kept its
|
||||
own old name, logo and colours while the Website showed the new ones. Now, while Accounts is
|
||||
connected, the profile's name, logo, icon, main and accent colours, email, phone and address win
|
||||
over `org_name`, `logo_url`, `favicon_url`, `primary_color`, `accent_color`, `org_email`,
|
||||
`org_phone` and `org_address` everywhere: the public settings (`GET /api/v2/settings`), and
|
||||
everything that reads the settings cache (emails, WhatsApp, PDFs, 2FA labels). Only what the
|
||||
profile has: no icon or accent there keeps this site's own. `org_tagline` and `secondary_color`
|
||||
stay this site's (`src/accounts/church.ts` `churchSettings`, `utils/settingsCache.js`
|
||||
`setAccountsOverrides`). `church.changed` fetches the profile straight away; disconnecting
|
||||
Accounts brings the site's own back. The look sent to Accounts on a move stays this site's own
|
||||
(`getStoredSetting`).
|
||||
- **PDFs with the church's logo from Accounts.** Tickets, invoices, receipts, certificates and
|
||||
privacy exports could only draw a logo uploaded here. The logo from Accounts is copied into
|
||||
`uploads/accounts` (once per address, when the profile arrives or the first PDF needs it; old
|
||||
copies removed; 2 MB at most; `utils/logoCopy.js`). PNG and JPEG are drawn as pictures and SVG
|
||||
(the demo churches' logos, and an SVG uploaded here) as shapes with `svg-to-pdfkit`
|
||||
(`drawLogo`); an SVG never opens a file or address it names. WebP and GIF show the name only.
|
||||
- A logo address on another `localhost` port (Accounts in development) is no longer rewritten to
|
||||
the API's address; only this site's own uploads are (`resolveToApiOrigin`).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Settings → Organisation and Branding** show the fields Accounts sets read-only, with a link to
|
||||
the church profile in Accounts, and never send them back (`GET /api/v2/settings/all` adds
|
||||
`accounts_managed`, the keys Accounts sets, with Accounts' values).
|
||||
|
||||
## [3.8.0] - 2026-11-30
|
||||
|
||||
Needs contracts 1.21.0 and `@crosscode/demo` 1.1.0 (built with Events; the `crosscode` script on
|
||||
|
||||
@@ -765,8 +765,11 @@ registered for; always sent) or **News & announcements** (only to people who opt
|
||||
on that channel and haven't unsubscribed). News emails carry an unsubscribe link and
|
||||
one-click `List-Unsubscribe` headers; news WhatsApps end with "Reply STOP" and a link.
|
||||
Event updates say why they were sent and link to the preferences. A STOP reply on
|
||||
WhatsApp turns off WhatsApp news (through WAWP's `message` webhook, checked against a
|
||||
secret in the webhook URL).
|
||||
WhatsApp (through WAWP's `message` webhook, checked against a secret in the webhook URL)
|
||||
**stops every WhatsApp message to that number** from 3.8.0, event updates, tickets and
|
||||
codes included (they go by email), and from the church's other sites too: it's passed on
|
||||
to the church's Accounts, where the person turns WhatsApp back on (without Accounts, by
|
||||
replying START).
|
||||
|
||||
**Privacy notice** (`/legal/privacy`) — edited in **Admin → Privacy (POPIA)**
|
||||
(`/dashboard/admin/privacy`): sections start from the built-in text; drafts, preview,
|
||||
|
||||
@@ -12,6 +12,18 @@ Write for church admins, not developers: no environment variables, endpoints or
|
||||
developer log is CHANGELOG.md. A tagged version without a section here shows "No details given".
|
||||
-->
|
||||
|
||||
## 3.9.0
|
||||
|
||||
- **Your church's name, logo, colours and contact details now come from your church profile in
|
||||
Accounts**, as they do on your website. Change them once in Accounts and your Events site shows
|
||||
the change within moments, in its pages, emails and WhatsApp messages too. Before, Events kept
|
||||
the details it had been given when it was set up.
|
||||
- In **Site settings → Organisation and Branding**, those details are shown but can't be changed
|
||||
there any more; a link takes you to your church profile in Accounts. Your tagline and secondary
|
||||
colour are still set in Events.
|
||||
- **Tickets, invoices and certificates show your church's logo from Accounts** (PNG, JPEG or
|
||||
SVG).
|
||||
|
||||
## 3.8.0
|
||||
|
||||
- **STOP now means no WhatsApp at all.** Someone who replies STOP to your church's WhatsApp number
|
||||
|
||||
@@ -11,7 +11,27 @@ showing it to:
|
||||
| `npm run demo:ministry` | One campus with weekly ministry | The Alpha Course running now (sessions, attendance, late joining, certificates), a finished Marriage Course with certificates, a 3-day conference sold by day, **Kids Church** with families, children, rooms and check-ins, **volunteer rosters**, a **Men's Breakfast series** with followers and a **season pass**, plus a family day, women's conference and carols. |
|
||||
| `npm run demo:multicampus` | A church with several campuses | **Campuses** Central, North and South (switched on), events per campus and church-wide, home campuses, staff limited to a campus (Anri Botha → North, Daniel Pillay → South), the breakfast series moving between campuses, kids church and rosters at two campuses, and all the events-demo events spread over the campuses. |
|
||||
|
||||
`npm run demo:list` prints the same list. Kids church always has a session **today** with
|
||||
**3.8.0: the eight demo scenarios** (docs/APP-1.0-PLAN.md §12). Each is named after its
|
||||
Website demo profile and is one of the churches every product of a demo client shows:
|
||||
|
||||
| Profile | Church | Built as |
|
||||
|---|---|---|
|
||||
| `heritage-parish` | St Columba's Church | small |
|
||||
| `heritage-city` | Grace Cathedral | events |
|
||||
| `bold-youth` | Ignite Church | events |
|
||||
| `bold-plant` | Harbour City Church | small |
|
||||
| `community-family` | Acacia Hill Church (cross-demo2) | ministry |
|
||||
| `community-town` | Karoo Gemeenskapskerk | small |
|
||||
| `clean-modern` | Northpoint Church | ministry |
|
||||
| `clean-campus` | Riverside Church (three campuses) | multicampus |
|
||||
|
||||
They use the church's own people from `@crosscode/demo` (its leads are the staff and the event
|
||||
contacts; the same people, with the same accounts, as in Accounts, the Website and the App) and
|
||||
its own campuses. Load Accounts' part first (`crosscode demo <church> accounts --profile …`), then
|
||||
`npm run set-demo -- --profile=<scenario> --yes` (or `crosscode demo <church> --profile <scenario>`).
|
||||
A small church's events sell only to the people it has.
|
||||
|
||||
`npm run demo:list` prints every profile. Kids church always has a session **today** with
|
||||
children checked in right now, so the kids desk and room screens have something live to
|
||||
show on any day.
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ npm run prisma:generate
|
||||
|
||||
### Demo data
|
||||
|
||||
`npm run set-demo -- --profile=<small|events|ministry|multicampus>` wipes the database (keeping site settings and the admin account) and stages demo data for that kind of church; from the repo root it's `npm run demo:<name>` (`npm run demo:list` describes them). See [DEMO_DATA.md](DEMO_DATA.md).
|
||||
`npm run set-demo -- --profile=<small|events|ministry|multicampus|a demo scenario>` (3.8.0: the eight scenarios, e.g. `community-family`) wipes the database (keeping site settings and the admin account) and stages demo data for that kind of church; from the repo root it's `npm run demo:<name>` (`npm run demo:list` describes them). See [DEMO_DATA.md](DEMO_DATA.md).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-backend",
|
||||
"version": "3.8.0",
|
||||
"version": "3.9.0",
|
||||
"description": "Event Management System Backend",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
@@ -45,6 +45,7 @@
|
||||
"pg-boss": "^11.1.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"raw-body": "^3.0.0",
|
||||
"svg-to-pdfkit": "0.1.8",
|
||||
"swagger-ui-dist": "^5.34.0",
|
||||
"tsx": "^4.23.15",
|
||||
"typescript": "^5.9.3",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* The church profile from the church's Accounts (3.7.0, docs/WEBSITE-1.0-PLAN.md §9): the brand
|
||||
* style (fonts and corners) and what the shared footer shows (service times, address, contact,
|
||||
* social, the church's other sites). Accounts owns it and serves it publicly at
|
||||
* `GET /api/church/v1`; this keeps a copy in memory for the public pages (`GET /api/v2/church`).
|
||||
* The church profile from the church's Accounts (3.7.0, docs/WEBSITE-1.0-PLAN.md §9). Accounts owns
|
||||
* it and serves it publicly at `GET /api/church/v1`; this keeps a copy in memory for the public
|
||||
* pages (`GET /api/v2/church`: the brand style and the shared footer).
|
||||
*
|
||||
* The church's own details in it (name, logo, icon, colours, contact details) also win over
|
||||
* this site's settings of the same name (`churchSettings`, through utils/settingsCache), so a change
|
||||
* in Accounts (or a new demo church) shows here as it does on the church's Website.
|
||||
*
|
||||
* Fetched again after 10 minutes, or at once when Accounts sends `church.changed`
|
||||
* (`POST /api/church/v1/changed`, src/links/routes.ts). While Accounts can't be reached the last
|
||||
@@ -12,6 +15,11 @@
|
||||
import { CHURCH_PATHS, churchSchema, type Church } from '@crosscode/contracts';
|
||||
import { accountsLink } from './client';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const { setAccountsOverrides } = require('../utils/settingsCache') as { setAccountsOverrides(map: Record<string, string>): void };
|
||||
const { pdfLogoPath } = require('../utils/logoCopy') as { pdfLogoPath(url: string): Promise<string | null> };
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
|
||||
const FRESH_MS = 10 * 60e3;
|
||||
const RETRY_MS = 60e3;
|
||||
const TIMEOUT_MS = 5000;
|
||||
@@ -20,6 +28,28 @@ type Cached = { url: string; church: Church | null; at: number; ok: boolean };
|
||||
let cached: Cached | null = null;
|
||||
let pending: Promise<Church | null> | null = null;
|
||||
|
||||
/**
|
||||
* This site's settings that the church profile sets, with its values. Only what the profile has:
|
||||
* a church without an icon keeps this site's favicon, without an accent its accent colour.
|
||||
* `secondary_color` and `org_tagline` aren't in the profile, so they stay this site's own.
|
||||
*/
|
||||
export function churchSettings(church: Church | null): Record<string, string> {
|
||||
if (!church) return {};
|
||||
const a = church.contact.address;
|
||||
const address = a ? [a.line1, a.line2, a.suburb, a.city, a.province, a.postalCode].filter((x) => x && x.trim()).join(', ') : null;
|
||||
const out: Record<string, string | null> = {
|
||||
org_name: church.name,
|
||||
logo_url: church.branding.logoUrl,
|
||||
favicon_url: church.branding.iconUrl,
|
||||
primary_color: church.branding.colours.primary,
|
||||
accent_color: church.branding.colours.accent,
|
||||
org_email: church.contact.email,
|
||||
org_phone: church.contact.phone,
|
||||
org_address: address,
|
||||
};
|
||||
return Object.fromEntries(Object.entries(out).filter((e): e is [string, string] => typeof e[1] === 'string' && e[1] !== ''));
|
||||
}
|
||||
|
||||
async function fetchProfile(accountsUrl: string): Promise<Church> {
|
||||
const res = await fetch(`${accountsUrl.replace(/\/+$/, '')}${CHURCH_PATHS.profile}`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(TIMEOUT_MS) });
|
||||
if (!res.ok) throw new Error(`Accounts answered ${res.status}`);
|
||||
@@ -36,7 +66,12 @@ export async function churchProfile(): Promise<Church | null> {
|
||||
} catch {
|
||||
return cached?.church ?? null;
|
||||
}
|
||||
if (!link) return null;
|
||||
if (!link) {
|
||||
// Disconnected from Accounts: this site's own settings again.
|
||||
if (cached) cached = null;
|
||||
setAccountsOverrides({});
|
||||
return null;
|
||||
}
|
||||
const url = link.url;
|
||||
if (cached && cached.url === url && Date.now() - cached.at < (cached.ok ? FRESH_MS : RETRY_MS)) return cached.church;
|
||||
if (!pending) {
|
||||
@@ -44,10 +79,14 @@ export async function churchProfile(): Promise<Church | null> {
|
||||
pending = fetchProfile(url)
|
||||
.then((church) => {
|
||||
cached = { url, church, at: Date.now(), ok: true };
|
||||
setAccountsOverrides(churchSettings(church));
|
||||
// A copy of the logo for PDFs, made now rather than while a ticket is being sent.
|
||||
if (church.branding.logoUrl) pdfLogoPath(church.branding.logoUrl).catch(() => {});
|
||||
return church;
|
||||
}, (e: Error) => {
|
||||
console.warn('[church] profile not fetched from Accounts:', e.message);
|
||||
cached = { url, church: last, at: Date.now(), ok: false };
|
||||
setAccountsOverrides(churchSettings(last));
|
||||
return last;
|
||||
})
|
||||
.finally(() => { pending = null; });
|
||||
@@ -55,13 +94,23 @@ export async function churchProfile(): Promise<Church | null> {
|
||||
return pending;
|
||||
}
|
||||
|
||||
/** `church.changed`: the next `churchProfile()` fetches it again (the last copy is shown meanwhile). */
|
||||
/** This site's settings the church profile sets right now (fetching it when it's due). Never throws. */
|
||||
export async function churchSettingsNow(): Promise<Record<string, string>> {
|
||||
return churchSettings(await churchProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* `church.changed`: fetched again straight away, so emails and pages that read the settings
|
||||
* without waiting get the new details within moments (the last copy is used meanwhile).
|
||||
*/
|
||||
export function churchChanged(): void {
|
||||
if (cached) cached = { ...cached, at: 0 };
|
||||
churchProfile().catch(() => {});
|
||||
}
|
||||
|
||||
/** Tests: start with nothing. */
|
||||
export function resetChurchProfile(): void {
|
||||
cached = null;
|
||||
pending = null;
|
||||
setAccountsOverrides({});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import type { ChurchLook } from '@crosscode/contracts';
|
||||
import { siteUrl } from '../feed/context';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const { getSetting } = require('../utils/settingsCache') as { getSetting(k: string, f?: string): Promise<string> };
|
||||
// This site's own values: they fill what Accounts doesn't have, so never Accounts' own (settingsCache).
|
||||
const { getStoredSetting: getSetting } = require('../utils/settingsCache') as { getStoredSetting(k: string, f?: string): Promise<string> };
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
|
||||
const hex = (v: string) => (/^#[0-9a-fA-F]{6}$/.test(v) ? v : null);
|
||||
|
||||
@@ -41,11 +41,22 @@ const PUBLIC_KEYS = [
|
||||
// @desc Get public app settings
|
||||
// @route GET /api/settings
|
||||
// @access Public
|
||||
// The church's own details from its Accounts profile (name, logo, colours, contact): they win over
|
||||
// this site's settings of the same name while Accounts is connected (src/accounts/church.ts).
|
||||
async function fromAccounts() {
|
||||
try {
|
||||
return await require('../accounts/church').churchSettingsNow();
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const getSettings = async (req, res) => {
|
||||
try {
|
||||
const rows = await prisma.appSetting.findMany({ where: { key: { in: PUBLIC_KEYS } } });
|
||||
const [rows, accounts] = await Promise.all([prisma.appSetting.findMany({ where: { key: { in: PUBLIC_KEYS } } }), fromAccounts()]);
|
||||
const settings = {};
|
||||
for (const r of rows) settings[r.key] = r.value;
|
||||
for (const [k, v] of Object.entries(accounts)) if (PUBLIC_KEYS.includes(k)) settings[k] = v;
|
||||
res.json(settings);
|
||||
} catch (e) {
|
||||
res.status(500).json({ message: safeErrorMessage(e) });
|
||||
@@ -79,6 +90,11 @@ const getAllSettings = async (req, res) => {
|
||||
settings[r.key] = r.value;
|
||||
}
|
||||
}
|
||||
// What the site uses for the keys Accounts sets, and which they are, so Settings shows them
|
||||
// read-only with a link to change them in Accounts.
|
||||
const accounts = await fromAccounts();
|
||||
Object.assign(settings, accounts);
|
||||
settings.accounts_managed = Object.keys(accounts).join(',');
|
||||
res.json(settings);
|
||||
} catch (e) {
|
||||
res.status(500).json({ message: safeErrorMessage(e) });
|
||||
@@ -96,7 +112,7 @@ const updateSettings = async (req, res) => {
|
||||
}
|
||||
|
||||
const ops = Object.entries(updates)
|
||||
.filter(([k, v]) => v !== undefined && v !== null && !PRIVATE_KEYS.has(k))
|
||||
.filter(([k, v]) => v !== undefined && v !== null && !PRIVATE_KEYS.has(k) && k !== 'accounts_managed')
|
||||
.map(([key, value]) => {
|
||||
let storedValue = String(value);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const PDFDocument = require('pdfkit');
|
||||
const QRCode = require('qrcode');
|
||||
const { drawLogo } = require('./logoCopy');
|
||||
const prisma = require('../config/db');
|
||||
const { activeSessions, completionMet, normalizeCertificateConfig, attendanceBySession, groupTickets, TIMEZONE } = require('./sessions');
|
||||
|
||||
@@ -189,7 +190,7 @@ function drawTemplate(doc, template, ctx) {
|
||||
doc.rect(0, 0, 28, H).fill(color);
|
||||
doc.rect(28, 0, 6, H).fill(lighten(color, 0.6));
|
||||
const x = 90;
|
||||
safeImage(doc, logo, x, 70, { fit: [120, 50] });
|
||||
drawLogo(doc, logo, x, 70, { fit: [120, 50] });
|
||||
doc.font('Helvetica').fontSize(11).fillColor(color).text(branding.name.toUpperCase(), x, 150, { characterSpacing: 2 });
|
||||
doc.font('Helvetica-Bold').fontSize(36).fillColor('#0f172a').text(title, x, 175, { width: W - x - 80 });
|
||||
doc.font('Helvetica').fontSize(13).fillColor('#64748b').text('Presented to', x, 260);
|
||||
@@ -202,7 +203,7 @@ function drawTemplate(doc, template, ctx) {
|
||||
if (template === 'church') {
|
||||
doc.rect(0, 0, W, H).fill(lighten(color, 0.94));
|
||||
doc.rect(30, 30, W - 60, H - 60).lineWidth(1).strokeColor(lighten(color, 0.4)).stroke();
|
||||
const hasLogo = safeImage(doc, logo, W / 2 - 50, 55, { fit: [100, 70], align: 'center' });
|
||||
const hasLogo = drawLogo(doc, logo, W / 2 - 50, 55, { fit: [100, 70], align: 'center' });
|
||||
const top = hasLogo ? 150 : 115;
|
||||
doc.font('Times-Italic').fontSize(14).fillColor(color).text(branding.name, 0, top, { width: W, align: 'center' });
|
||||
doc.font('Times-Bold').fontSize(34).fillColor('#1e293b').text(title, 60, top + 26, { width: W - 120, align: 'center' });
|
||||
@@ -228,7 +229,7 @@ function drawTemplate(doc, template, ctx) {
|
||||
const y = top ? 48 + rnd() * 50 : 110 + rnd() * (H - 260);
|
||||
doc.circle(x, y, 3 + rnd() * 5).fill(bright[i % bright.length]);
|
||||
}
|
||||
safeImage(doc, logo, W / 2 - 40, 100, { fit: [80, 50], align: 'center' });
|
||||
drawLogo(doc, logo, W / 2 - 40, 100, { fit: [80, 50], align: 'center' });
|
||||
doc.font('Helvetica-Bold').fontSize(38).fillColor(color).text(title, 100, 165, { width: W - 200, align: 'center' });
|
||||
doc.font('Helvetica-Bold').fontSize(15).fillColor('#f59e0b').text('Well done,', 0, 230, { width: W, align: 'center' });
|
||||
doc.font('Helvetica-Bold').fontSize(36).fillColor('#1e293b').text(cert.name, 100, 250, { width: W - 200, align: 'center' });
|
||||
@@ -244,7 +245,7 @@ function drawTemplate(doc, template, ctx) {
|
||||
for (const [cx, cy] of [[34, 34], [W - 34, 34], [34, H - 34], [W - 34, H - 34]]) {
|
||||
doc.circle(cx, cy, 6).fill(color);
|
||||
}
|
||||
safeImage(doc, logo, W / 2 - 45, 70, { fit: [90, 55], align: 'center' });
|
||||
drawLogo(doc, logo, W / 2 - 45, 70, { fit: [90, 55], align: 'center' });
|
||||
doc.font('Times-Bold').fontSize(38).fillColor('#1e293b').text(title.toUpperCase(), 60, 150, { width: W - 120, align: 'center', characterSpacing: 1.5 });
|
||||
doc.font('Times-Italic').fontSize(14).fillColor('#64748b').text('This certificate is proudly presented to', 0, 212, { width: W, align: 'center' });
|
||||
doc.font('Times-BoldItalic').fontSize(34).fillColor(color).text(cert.name, 60, 236, { width: W - 120, align: 'center' });
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
// The logo for PDFs (tickets, invoices, receipts, certificates, privacy exports). PDFs need a file
|
||||
// on disk. A logo uploaded here already is one; the church's logo from its Accounts profile is an
|
||||
// address on another site, so a copy is kept in uploads/accounts (one per address, made when the
|
||||
// profile arrives or the first PDF needs it; older copies are removed).
|
||||
//
|
||||
// PNG and JPEG are drawn as pictures; SVG (the demo churches' logos, and many churches') is drawn
|
||||
// as shapes with svg-to-pdfkit (`drawLogo`). Anything else (WebP, GIF) isn't copied, and the PDFs
|
||||
// show the church's name without a logo.
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const SVGtoPDF = require('svg-to-pdfkit');
|
||||
const { UPLOADS_DIR, uploadsDir } = require('./uploads');
|
||||
|
||||
const MAX_BYTES = 2 * 1024 * 1024;
|
||||
const TIMEOUT_MS = 5000;
|
||||
const EXT = { png: 'png', jpeg: 'jpg', svg: 'svg' };
|
||||
|
||||
/** PNG, JPEG or SVG by the file's own bytes (never by what a server says it is), else null. */
|
||||
function logoKind(buf) {
|
||||
if (buf.length >= 8 && buf.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))) return 'png';
|
||||
if (buf.length >= 3 && buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) return 'jpeg';
|
||||
const head = buf.subarray(0, 4096).toString('utf8').replace(/^/, '').trimStart();
|
||||
if (head.startsWith('<') && /<svg[\s>]/i.test(head)) return 'svg';
|
||||
return null;
|
||||
}
|
||||
|
||||
const nameFor = (url) => `logo-${crypto.createHash('sha256').update(url).digest('hex').slice(0, 16)}`;
|
||||
|
||||
/** An outside address the site may fetch the logo from: https, or http while developing. */
|
||||
function fetchable(url) {
|
||||
try {
|
||||
const u = new URL(url);
|
||||
return u.protocol === 'https:' || (u.protocol === 'http:' && process.env.NODE_ENV !== 'production');
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function existingCopy(url) {
|
||||
const base = nameFor(url);
|
||||
for (const ext of Object.values(EXT)) {
|
||||
const p = path.join(UPLOADS_DIR, 'accounts', `${base}.${ext}`);
|
||||
if (fs.existsSync(p)) return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Addresses tried lately that gave no usable logo: not fetched again for 10 minutes.
|
||||
const misses = new Map();
|
||||
const MISS_MS = 10 * 60e3;
|
||||
const pending = new Map();
|
||||
|
||||
async function download(url) {
|
||||
const res = await fetch(url, { signal: AbortSignal.timeout(TIMEOUT_MS), redirect: 'follow' });
|
||||
if (!res.ok) throw new Error(`answered ${res.status}`);
|
||||
if (Number(res.headers.get('content-length') || 0) > MAX_BYTES) throw new Error('is larger than 2 MB');
|
||||
const buf = Buffer.from(await res.arrayBuffer());
|
||||
if (buf.length > MAX_BYTES) throw new Error('is larger than 2 MB');
|
||||
const kind = logoKind(buf);
|
||||
if (!kind) return null; // WebP, GIF…: not drawable in a PDF
|
||||
const dir = uploadsDir('accounts');
|
||||
const base = nameFor(url);
|
||||
const file = path.join(dir, `${base}.${EXT[kind]}`);
|
||||
fs.writeFileSync(file, buf);
|
||||
// The church changed its logo: the copies of the old ones go.
|
||||
for (const f of fs.readdirSync(dir)) if (f.startsWith('logo-') && !f.startsWith(`${base}.`)) fs.rmSync(path.join(dir, f), { force: true });
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* The logo as a file a PDF can draw (`drawLogo`), or null. `logoUrl` is the logo_url setting: a
|
||||
* path on this site (/uploads/…) or the church's logo address from Accounts. Never throws.
|
||||
*/
|
||||
async function pdfLogoPath(logoUrl) {
|
||||
const url = String(logoUrl || '').trim();
|
||||
if (!url) return null;
|
||||
if (!/^https?:\/\//i.test(url)) {
|
||||
const p = path.join(UPLOADS_DIR, '..', url.replace(/^\//, ''));
|
||||
try {
|
||||
return fs.existsSync(p) && logoKind(fs.readFileSync(p)) ? p : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!fetchable(url)) return null;
|
||||
const have = existingCopy(url);
|
||||
if (have) return have;
|
||||
const missed = misses.get(url);
|
||||
if (missed && Date.now() - missed < MISS_MS) return null;
|
||||
if (!pending.has(url)) {
|
||||
pending.set(url, download(url)
|
||||
.catch((e) => {
|
||||
console.warn(`[logo] the church's logo couldn't be copied for PDFs: ${url} ${e.message}`);
|
||||
return null;
|
||||
})
|
||||
.then((file) => {
|
||||
if (!file) misses.set(url, Date.now());
|
||||
return file;
|
||||
})
|
||||
.finally(() => pending.delete(url)));
|
||||
}
|
||||
return pending.get(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the logo `file` (from pdfLogoPath) at x, y within `fit` [w, h], as doc.image does; centred
|
||||
* in that box with `align: 'center'`. True when drawn. Never throws.
|
||||
*/
|
||||
function drawLogo(doc, file, x, y, { fit, align } = {}) {
|
||||
if (!file) return false;
|
||||
try {
|
||||
if (file.toLowerCase().endsWith('.svg')) {
|
||||
const [width, height] = fit || [100, 50];
|
||||
SVGtoPDF(doc, fs.readFileSync(file, 'utf8'), x, y, {
|
||||
width,
|
||||
height,
|
||||
preserveAspectRatio: align === 'center' ? 'xMidYMid meet' : 'xMinYMid meet',
|
||||
// Only pictures inside the SVG itself: never a file or address it names.
|
||||
imageCallback: (link) => (/^data:image\/(png|jpe?g);base64,/i.test(String(link).trim()) ? String(link).replace(/\s+/g, '') : ''),
|
||||
warningCallback: () => {},
|
||||
});
|
||||
} else {
|
||||
doc.image(file, x, y, { fit, ...(align ? { align } : {}) });
|
||||
}
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Tests: forget the addresses that gave nothing. */
|
||||
function resetLogoCopies() {
|
||||
misses.clear();
|
||||
}
|
||||
|
||||
module.exports = { pdfLogoPath, drawLogo, resetLogoCopies, logoKind };
|
||||
@@ -55,11 +55,8 @@ async function getBranding() {
|
||||
getSetting('logo_url', ''),
|
||||
]);
|
||||
const url = (process.env.FRONTEND_URL || process.env.APP_BASE_URL || 'http://localhost:3001').replace(/\/$/, '');
|
||||
let logoPath = null;
|
||||
if (logoUrl) {
|
||||
const p = path.join(__dirname, '..', '..', 'public', logoUrl.replace(/^\//, ''));
|
||||
if (fs.existsSync(p)) logoPath = p;
|
||||
}
|
||||
// An uploaded logo, or a copy of the church's logo from Accounts (utils/logoCopy.js).
|
||||
const logoPath = await require('./logoCopy').pdfLogoPath(logoUrl);
|
||||
return { name, address, email, phone, brandColor: primary || accent || '#1e3a5f', url, logoPath };
|
||||
}
|
||||
|
||||
@@ -196,7 +193,7 @@ async function generateReceiptPdf(payment) {
|
||||
const bannerH = 150;
|
||||
doc.rect(0, 0, pageWidth, bannerH).fill(org.brandColor);
|
||||
if (org.logoPath) {
|
||||
try { doc.image(org.logoPath, marginX, 28, { fit: [36, 36] }); } catch {}
|
||||
require('./logoCopy').drawLogo(doc, org.logoPath, marginX, 28, { fit: [36, 36] });
|
||||
}
|
||||
doc.fillColor('#ffffff').font('Helvetica-Bold').fontSize(13).text(org.name, marginX + (org.logoPath ? 46 : 0), 38, { width: 260 });
|
||||
doc.font('Helvetica-Bold').fontSize(26).text('Payment Receipt', marginX, 68, { width: 320 });
|
||||
@@ -301,7 +298,7 @@ async function generateInvoicePdf(registration, { paymentUrl = null, totalDue =
|
||||
doc.rect(0, 0, sidebarW, pageHeight).fill('#111827');
|
||||
let sy = 40;
|
||||
if (org.logoPath) {
|
||||
try { doc.image(org.logoPath, 28, sy, { fit: [32, 32] }); sy += 0; } catch {}
|
||||
require('./logoCopy').drawLogo(doc, org.logoPath, 28, sy, { fit: [32, 32] });
|
||||
}
|
||||
doc.font('Helvetica-Bold').fontSize(12).fillColor('#ffffff').text(org.name, org.logoPath ? 68 : 28, sy + 8, { width: sidebarW - (org.logoPath ? 96 : 56) });
|
||||
sy += 60;
|
||||
|
||||
@@ -17,9 +17,37 @@ let _cache = {};
|
||||
let _lastFetch = 0;
|
||||
const TTL_MS = 60 * 1000;
|
||||
|
||||
/**
|
||||
* The church's own details from its Accounts profile (src/accounts/church.ts): name, logo, icon,
|
||||
* colours and contact details. Accounts owns them, so while it's connected they win over this
|
||||
* site's own settings everywhere (pages, emails, PDFs). Empty without Accounts.
|
||||
*/
|
||||
let _fromAccounts = {};
|
||||
|
||||
/** Set by src/accounts/church.ts whenever it has (or loses) the church profile. */
|
||||
function setAccountsOverrides(map) {
|
||||
_fromAccounts = { ...(map || {}) };
|
||||
}
|
||||
|
||||
/** The keys Accounts sets right now, with their values. */
|
||||
function accountsOverrides() {
|
||||
return { ..._fromAccounts };
|
||||
}
|
||||
|
||||
/** The church profile is kept fresh as the settings are (it caches itself for 10 minutes). */
|
||||
function refreshChurchProfile() {
|
||||
try {
|
||||
const p = require('../accounts/church').churchProfile();
|
||||
if (p && typeof p.catch === 'function') p.catch(() => {});
|
||||
} catch {
|
||||
// No Accounts code in this context (some tests): the site's own settings stand.
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshIfStale() {
|
||||
const now = Date.now();
|
||||
if (now - _lastFetch < TTL_MS && _lastFetch > 0) return;
|
||||
refreshChurchProfile();
|
||||
try {
|
||||
const rows = await prisma.appSetting.findMany();
|
||||
const fresh = {};
|
||||
@@ -38,6 +66,13 @@ async function refreshIfStale() {
|
||||
* @returns {string}
|
||||
*/
|
||||
function _getSync(key, envFallback = '') {
|
||||
const a = _fromAccounts[key];
|
||||
if (typeof a === 'string' && a !== '') return a;
|
||||
return _getStoredSync(key, envFallback);
|
||||
}
|
||||
|
||||
/** This site's own value, ignoring Accounts (for sending this site's look to Accounts, src/accounts/look.ts). */
|
||||
function _getStoredSync(key, envFallback = '') {
|
||||
const v = _cache[key];
|
||||
const raw = (v !== undefined && v !== null && v !== '') ? v : (envFallback || '');
|
||||
if (ENCRYPTED_KEYS.has(key) && isEncrypted(raw)) {
|
||||
@@ -76,4 +111,10 @@ function invalidate() {
|
||||
refreshIfStale().catch(() => {});
|
||||
}
|
||||
|
||||
module.exports = { getSetting, getSettingSync, warmCache, invalidate, ENCRYPTED_KEYS };
|
||||
/** As getSetting, but this site's own value even when Accounts sets the key. */
|
||||
async function getStoredSetting(key, envFallback = '') {
|
||||
await refreshIfStale();
|
||||
return _getStoredSync(key, envFallback);
|
||||
}
|
||||
|
||||
module.exports = { getSetting, getSettingSync, getStoredSetting, warmCache, invalidate, setAccountsOverrides, accountsOverrides, ENCRYPTED_KEYS };
|
||||
@@ -37,8 +37,9 @@ const realFetch = global.fetch;
|
||||
|
||||
beforeAll(() => {
|
||||
global.fetch = (async (url: string) => {
|
||||
// The logo, copied for PDFs (utils/logoCopy.js): not part of these tests.
|
||||
if (url !== `https://accounts.hope.test${CHURCH_PATHS.profile}`) return new Response('', { status: 404 });
|
||||
fetches++;
|
||||
expect(url).toBe(`https://accounts.hope.test${CHURCH_PATHS.profile}`);
|
||||
const next = answers.shift() ?? 200;
|
||||
if (next === 'down') throw new Error('connect ECONNREFUSED');
|
||||
return new Response(JSON.stringify(profile), { status: next, headers: { 'content-type': 'application/json' } });
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
// The church's own details from Accounts (name, logo, icon, colours, contact) win over this site's
|
||||
// settings of the same name: on the public settings, in Settings (read-only), and for everything
|
||||
// that reads them through the settings cache (emails, PDFs). Without Accounts, the site's own stand.
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
type Link = { installId: string; product: string; url: string; secret: string; updatedAt: Date };
|
||||
const mockLinks: Link[] = [];
|
||||
const mockRows: { key: string; value: string }[] = [];
|
||||
jest.mock('../src/config/db', () => ({
|
||||
productLink: {
|
||||
findFirst: async ({ where }: { where: { product: string } }) => mockLinks.find((l) => l.product === where.product) ?? null,
|
||||
},
|
||||
appSetting: {
|
||||
findMany: async (q?: { where?: { key?: { in?: string[] } } }) => mockRows.filter((r) => !q?.where?.key?.in || q.where.key.in.includes(r.key)),
|
||||
},
|
||||
}));
|
||||
|
||||
process.env.JWT_SECRET = 'a-test-secret-that-is-long-enough-for-the-encryption';
|
||||
|
||||
import { CHURCH_PATHS } from '@crosscode/contracts';
|
||||
import { churchProfile, churchSettings, resetChurchProfile } from '../src/accounts/church';
|
||||
import { churchLook } from '../src/accounts/look';
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const settingsCache = require('../src/utils/settingsCache');
|
||||
const { getSettings, getAllSettings } = require('../src/controllers/settingsController');
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
|
||||
const SAMPLES = path.join(path.dirname(require.resolve('@crosscode/contracts/package.json')), 'samples');
|
||||
const sample = () => JSON.parse(fs.readFileSync(path.join(SAMPLES, 'church.json'), 'utf8'));
|
||||
let profile = sample();
|
||||
const realFetch = global.fetch;
|
||||
|
||||
beforeAll(() => {
|
||||
global.fetch = (async (url: string) => {
|
||||
if (url !== `https://accounts.hope.test${CHURCH_PATHS.profile}`) return new Response('', { status: 404 }); // the logo (logoCopy tests)
|
||||
return new Response(JSON.stringify(profile), { status: 200, headers: { 'content-type': 'application/json' } });
|
||||
}) as typeof fetch;
|
||||
});
|
||||
afterAll(() => { global.fetch = realFetch; });
|
||||
|
||||
beforeEach(() => {
|
||||
resetChurchProfile();
|
||||
mockLinks.length = 0;
|
||||
mockRows.length = 0;
|
||||
mockRows.push(
|
||||
{ key: 'org_name', value: 'Old Demo Church' },
|
||||
{ key: 'org_tagline', value: 'Our own tagline' },
|
||||
{ key: 'primary_color', value: '#111111' },
|
||||
{ key: 'secondary_color', value: '#222222' },
|
||||
{ key: 'logo_url', value: '/uploads/old-logo.png' },
|
||||
);
|
||||
settingsCache.invalidate();
|
||||
profile = sample();
|
||||
});
|
||||
|
||||
const connectAccounts = () => mockLinks.push({ installId: 'acc', product: 'accounts', url: 'https://accounts.hope.test/', secret: 'x', updatedAt: new Date() });
|
||||
|
||||
async function call(handler: (req: unknown, res: unknown) => Promise<void>): Promise<Record<string, string>> {
|
||||
let body: Record<string, string> = {};
|
||||
await handler({}, { json: (b: Record<string, string>) => { body = b; }, status() { return this; } });
|
||||
return body;
|
||||
}
|
||||
|
||||
describe("the church's details from Accounts", () => {
|
||||
test('only what the profile has', () => {
|
||||
profile.branding.iconUrl = null;
|
||||
profile.branding.colours.accent = null;
|
||||
const s = churchSettings(profile);
|
||||
expect(s.org_name).toBe(profile.name);
|
||||
expect(s.primary_color).toBe(profile.branding.colours.primary);
|
||||
expect('favicon_url' in s).toBe(false);
|
||||
expect('accent_color' in s).toBe(false);
|
||||
expect(churchSettings(null)).toEqual({});
|
||||
});
|
||||
|
||||
test('without Accounts, the site keeps its own', async () => {
|
||||
const s = await call(getSettings);
|
||||
expect(s.org_name).toBe('Old Demo Church');
|
||||
expect((await call(getAllSettings)).accounts_managed).toBe('');
|
||||
});
|
||||
|
||||
test("with Accounts, the public settings show the church's, and keep what the profile doesn't set", async () => {
|
||||
connectAccounts();
|
||||
const s = await call(getSettings);
|
||||
expect(s.org_name).toBe(profile.name);
|
||||
expect(s.primary_color).toBe(profile.branding.colours.primary);
|
||||
expect(s.logo_url).toBe(profile.branding.logoUrl);
|
||||
expect(s.org_tagline).toBe('Our own tagline');
|
||||
expect(s.secondary_color).toBe('#222222');
|
||||
});
|
||||
|
||||
test('Settings marks the ones Accounts sets', async () => {
|
||||
connectAccounts();
|
||||
const all = await call(getAllSettings);
|
||||
expect(all.org_name).toBe(profile.name);
|
||||
expect(all.accounts_managed.split(',')).toEqual(expect.arrayContaining(['org_name', 'primary_color', 'logo_url']));
|
||||
expect(all.accounts_managed.split(',')).not.toContain('secondary_color');
|
||||
});
|
||||
|
||||
test('the settings cache (emails, PDFs) uses them once the profile is in, and the look sent to Accounts stays the site\'s own', async () => {
|
||||
connectAccounts();
|
||||
await settingsCache.warmCache();
|
||||
await churchProfile();
|
||||
expect(settingsCache.getSettingSync('org_name', 'Cross Code')).toBe(profile.name);
|
||||
expect(await settingsCache.getStoredSetting('org_name')).toBe('Old Demo Church');
|
||||
expect((await churchLook()).name).toBe('Old Demo Church');
|
||||
});
|
||||
|
||||
test('a church that changes its name in Accounts (a new demo church) is shown after church.changed', async () => {
|
||||
connectAccounts();
|
||||
await churchProfile();
|
||||
profile.name = 'Grace Fellowship';
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
require('../src/accounts/church').churchChanged();
|
||||
await churchProfile();
|
||||
expect(settingsCache.getSettingSync('org_name')).toBe('Grace Fellowship');
|
||||
expect((await call(getSettings)).org_name).toBe('Grace Fellowship');
|
||||
});
|
||||
|
||||
test('disconnected from Accounts: back to the site\'s own', async () => {
|
||||
connectAccounts();
|
||||
await churchProfile();
|
||||
mockLinks.length = 0;
|
||||
await churchProfile();
|
||||
expect(settingsCache.getSettingSync('org_name')).toBe('Old Demo Church');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
// The logo for PDFs: an uploaded one is used as it is; the church's logo from Accounts (an address
|
||||
// on another site) is copied into uploads/accounts once, when it's a PNG, JPEG or SVG; drawLogo
|
||||
// draws either kind into a PDF.
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const { pdfLogoPath, drawLogo, resetLogoCopies } = require('../src/utils/logoCopy') as {
|
||||
pdfLogoPath(u: string): Promise<string | null>;
|
||||
drawLogo(doc: unknown, file: string | null, x: number, y: number, o?: { fit?: [number, number]; align?: string }): boolean;
|
||||
resetLogoCopies(): void;
|
||||
};
|
||||
const PDFDocument = require('pdfkit');
|
||||
const { UPLOADS_DIR } = require('../src/utils/uploads') as { UPLOADS_DIR: string };
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
|
||||
const PNG = Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), Buffer.alloc(32)]);
|
||||
const SVG = Buffer.from('<?xml version="1.0"?>\n<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><rect width="512" height="512" fill="#1f4e79"/><path d="M232 96h48v320h-48z" fill="#fff"/></svg>');
|
||||
const WEBP = Buffer.concat([Buffer.from('RIFF'), Buffer.alloc(4), Buffer.from('WEBPVP8 ')]);
|
||||
const COPIES = path.join(UPLOADS_DIR, 'accounts');
|
||||
const realFetch = global.fetch;
|
||||
let served: Record<string, Buffer | number> = {};
|
||||
let fetched: string[] = [];
|
||||
|
||||
beforeAll(() => {
|
||||
global.fetch = (async (url: string) => {
|
||||
fetched.push(url);
|
||||
const body = served[url];
|
||||
if (body === undefined || typeof body === 'number') return new Response('', { status: typeof body === 'number' ? body : 404 });
|
||||
return new Response(new Uint8Array(body), { status: 200 });
|
||||
}) as typeof fetch;
|
||||
});
|
||||
afterAll(() => {
|
||||
global.fetch = realFetch;
|
||||
fs.rmSync(COPIES, { recursive: true, force: true });
|
||||
});
|
||||
beforeEach(() => {
|
||||
fs.rmSync(COPIES, { recursive: true, force: true });
|
||||
resetLogoCopies();
|
||||
served = {};
|
||||
fetched = [];
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
});
|
||||
afterEach(() => { jest.restoreAllMocks(); });
|
||||
|
||||
function pdfOf(draw: (doc: unknown) => void): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
const doc = new PDFDocument({ compress: false });
|
||||
const parts: Buffer[] = [];
|
||||
doc.on('data', (b: Buffer) => parts.push(b));
|
||||
doc.on('end', () => resolve(Buffer.concat(parts).toString('latin1')));
|
||||
draw(doc);
|
||||
doc.end();
|
||||
});
|
||||
}
|
||||
|
||||
test("the church's PNG logo from Accounts is copied once, and used from the copy after", async () => {
|
||||
served['https://accounts.hope.test/logo.png'] = PNG;
|
||||
const p = await pdfLogoPath('https://accounts.hope.test/logo.png');
|
||||
expect(p && path.dirname(p)).toBe(COPIES);
|
||||
expect(fs.readFileSync(p!)).toEqual(PNG);
|
||||
expect(await pdfLogoPath('https://accounts.hope.test/logo.png')).toBe(p);
|
||||
expect(fetched).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('a new logo replaces the copy of the old one', async () => {
|
||||
served['https://accounts.hope.test/old.png'] = PNG;
|
||||
served['https://accounts.hope.test/new.png'] = PNG;
|
||||
const old = await pdfLogoPath('https://accounts.hope.test/old.png');
|
||||
const next = await pdfLogoPath('https://accounts.hope.test/new.png');
|
||||
expect(next).not.toBe(old);
|
||||
expect(fs.existsSync(old!)).toBe(false);
|
||||
expect(fs.readdirSync(COPIES)).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("an SVG logo (the demo churches') is copied too", async () => {
|
||||
served['https://accounts.hope.test/logo.svg'] = SVG;
|
||||
const p = await pdfLogoPath('https://accounts.hope.test/logo.svg');
|
||||
expect(p?.endsWith('.svg')).toBe(true);
|
||||
});
|
||||
|
||||
test("a logo a PDF can't draw, or one that can't be fetched, gives none (the PDF shows the name), and isn't fetched again at once", async () => {
|
||||
served['https://accounts.hope.test/logo.webp'] = WEBP;
|
||||
served['https://accounts.hope.test/gone.png'] = 404;
|
||||
expect(await pdfLogoPath('https://accounts.hope.test/logo.webp')).toBeNull();
|
||||
expect(await pdfLogoPath('https://accounts.hope.test/gone.png')).toBeNull();
|
||||
expect(await pdfLogoPath('https://accounts.hope.test/logo.webp')).toBeNull();
|
||||
expect(fetched).toHaveLength(2);
|
||||
});
|
||||
|
||||
test('drawLogo draws an SVG logo as shapes in its colours, and never opens a file the SVG names', async () => {
|
||||
fs.mkdirSync(COPIES, { recursive: true });
|
||||
const file = path.join(COPIES, 'logo-test.svg');
|
||||
fs.writeFileSync(file, SVG);
|
||||
let drawn = false;
|
||||
const pdf = await pdfOf((doc) => { drawn = drawLogo(doc, file, 40, 40, { fit: [60, 60], align: 'center' }); });
|
||||
expect(drawn).toBe(true);
|
||||
expect(pdf).toMatch(/0\.12156\d* 0\.30588\d* 0\.47450\d* scn/); // #1f4e79
|
||||
|
||||
const picture = path.join(COPIES, 'logo-test.png');
|
||||
fs.writeFileSync(picture, PNG);
|
||||
const sneaky = path.join(COPIES, 'logo-sneaky.svg');
|
||||
const href = picture.split(path.sep).join('/');
|
||||
fs.writeFileSync(sneaky, `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><image href="${href}" width="10" height="10"/></svg>`);
|
||||
const out = await pdfOf((doc) => { drawLogo(doc, sneaky, 0, 0, { fit: [10, 10] }); });
|
||||
expect(out).not.toContain('/Subtype /Image');
|
||||
});
|
||||
|
||||
test("drawLogo gives false, without throwing, for a file it can't draw", async () => {
|
||||
fs.mkdirSync(COPIES, { recursive: true });
|
||||
const bad = path.join(COPIES, 'logo-bad.png');
|
||||
fs.writeFileSync(bad, 'not a picture');
|
||||
let drawn = true;
|
||||
await pdfOf((doc) => { drawn = drawLogo(doc, bad, 0, 0, { fit: [10, 10] }); });
|
||||
expect(drawn).toBe(false);
|
||||
expect(drawLogo({}, null, 0, 0)).toBe(false);
|
||||
});
|
||||
|
||||
test('a logo uploaded here is used as it is; nothing for no logo', async () => {
|
||||
fs.mkdirSync(COPIES, { recursive: true });
|
||||
fs.writeFileSync(path.join(COPIES, 'own.png'), PNG);
|
||||
expect(await pdfLogoPath('/uploads/accounts/own.png')).toBe(path.join(COPIES, 'own.png'));
|
||||
expect(await pdfLogoPath('')).toBeNull();
|
||||
expect(await pdfLogoPath('/uploads/accounts/missing.png')).toBeNull();
|
||||
expect(fetched).toHaveLength(0);
|
||||
});
|
||||
@@ -1,5 +1,11 @@
|
||||
# Handover — where things stand and how to carry on
|
||||
|
||||
> **2026-11-30:** Events is now at **3.8.0** (released, not deployed; 3.7.2 is rolled out). Where
|
||||
> it stands and what's next is kept in the root [HANDOVER.md](../../../docs/HANDOVER.md) and
|
||||
> [VERSIONS.md](../../../docs/VERSIONS.md); this file keeps the "where the code lives" notes.
|
||||
> Changed since the note below: STOP stops all WhatsApp (see "Where WhatsApp STOP lives (3.8.0)")
|
||||
> and the demo has the eight demo scenarios (see "Demo data").
|
||||
|
||||
Last updated: 2026-11-18, after **2.3.1** (Next.js 16.4.6 for security advisories, on top of 2.3.0;
|
||||
released, not deployed yet; servers still run 2.1.1 until they're adopted, see the root
|
||||
[ROLLOUT-1.0.md](../../../docs/ROLLOUT-1.0.md)).
|
||||
@@ -263,7 +269,8 @@ Plan and reasons: the root [EVENTS-2.4-PLAN.md](../../../docs/EVENTS-2.4-PLAN.md
|
||||
`CommunicationConsent`), unsubscribe tokens (HMAC with `JWT_SECRET`, never expire),
|
||||
`filterRecipients` (every bulk send goes through it: `kind` 'update' passes, 'news' only to
|
||||
opted-in accounts and not to `MessagingOptOut` addresses), email/WhatsApp footers, STOP
|
||||
handling, data requests, `deletionBlockers`, `anonymiseUser`, `exportUserData` + PDF.
|
||||
handling (news off; from 3.8.0 all WhatsApp too, below), data requests, `deletionBlockers`,
|
||||
`anonymiseUser`, `exportUserData` + PDF.
|
||||
Tests: `backend/tests/privacy.test.js`; e2e: `e2e/privacy.spec.ts`.
|
||||
- `controllers/privacyController.js` + `routes/privacyRoutes.js` (`/api/privacy`).
|
||||
- Bulk sends: `broadcastController`, `whatsappBroadcastController`, and `emailEventAttendees` /
|
||||
@@ -472,6 +479,22 @@ Plan and reasons: the root [EVENTS-2.4-PLAN.md](../../../docs/EVENTS-2.4-PLAN.md
|
||||
- Frontend: `components/admin/WebhooksTab.tsx`. Tests: `tests/webhooks.test.js`, e2e
|
||||
`webhooks.spec.ts` (runs a receiver on localhost:5199; e2e backend has `WEBHOOKS_ALLOW_PRIVATE`).
|
||||
|
||||
## Where WhatsApp STOP lives (3.8.0)
|
||||
|
||||
- APP-1.0-PLAN decision 11: STOP to the church's WhatsApp number stops **all** WhatsApp from every
|
||||
one of the church's products (event updates, tickets, kids messages, 2FA codes), not only news.
|
||||
- `src/utils/whatsappStop.js`: `isWhatsAppStopped` (by number in `WhatsAppStop`, or an account with
|
||||
`User.whatsappOptedOut`, set from Accounts' `user.updated` `whatsapp_opted_out`), `recordStop`,
|
||||
`clearStop`, `isStartKeyword`. `sendText` / `sendPdf` (`utils/whatsapp.js`) check it before every
|
||||
message; only the reply that confirms a STOP is sent anyway (`evenIfStopped`). 2FA codes for a
|
||||
stopped number go by email (`utils/twoFactor.js`).
|
||||
- The webhook (`handleIncomingMessage`): STOP → kept, news off (`privacy.whatsAppStop`), passed on to
|
||||
Accounts (`src/accounts/whatsappOptOut.ts`, `whatsapp.optout`); the reply links Accounts' account
|
||||
page. START turns it back on only without Accounts (with Accounts it's turned on there, and
|
||||
`updateLocalCopy` clears this site's STOP for the number).
|
||||
- **Anything new that sends WhatsApp** goes through `sendText` / `sendPdf`, never WAWP directly.
|
||||
- Tests: `tests/whatsappStop.test.js`, `tests/accountsWhatsappOptOut.test.ts`.
|
||||
|
||||
## Demo data (1.48.2)
|
||||
|
||||
- `backend/scripts/set-demo.js` builds everything in memory and writes it with `createMany` in one
|
||||
@@ -486,6 +509,14 @@ Plan and reasons: the root [EVENTS-2.4-PLAN.md](../../../docs/EVENTS-2.4-PLAN.md
|
||||
- Tried by seeding all four into a throwaway database and calling the API (events, series page and
|
||||
report, season pass, kids board, roster, attendance registers, certificate check, cashups, campus
|
||||
scoping).
|
||||
- **3.8.0, the demo scenarios** (APP-1.0-PLAN §12): `PROFILES` also has one per scenario
|
||||
(`agent.DEMO_SCENARIOS`), each a copy of one of the four kinds (`SCENARIO_KINDS`) built around
|
||||
the scenario's church from `@crosscode/demo`: its people (`buildScenarioPeople`: leads become the
|
||||
staff, at most 260 members), its campuses (`buildCampuses`), its staff as event contacts
|
||||
(`staffName`). Builders stop when a small church runs out of people (`nextBuyer` returns null),
|
||||
so don't add one that needs a fixed number of people without the same guard. The scenario's
|
||||
own people are never sent to `people.removeDemo` (Accounts loaded them first). All eight and
|
||||
the four were loaded into a throwaway PostgreSQL 18 database before release.
|
||||
|
||||
## Where the dashboard and palette live (1.49.0)
|
||||
|
||||
@@ -745,6 +776,10 @@ Plan and reasons: the root [EVENTS-2.4-PLAN.md](../../../docs/EVENTS-2.4-PLAN.md
|
||||
into WAWP (events `message` + `session.status`), and only for senders WhatsApp identifies by
|
||||
phone number — a sender known only by a "LID" is logged and ignored (they can still use the
|
||||
link in the message).
|
||||
- (3.8.0) No test yet for a 2FA code falling back to email for a number that replied STOP.
|
||||
- (3.8.0) The demo scenarios reuse the four demos' events: a scenario's own events (Grace
|
||||
Cathedral's concert series, Ignite's youth conference) and Afrikaans content for Karoo
|
||||
Gemeenskapskerk aren't built yet.
|
||||
- There's no log of individual messages sent, so "Download my data" can't include "messages
|
||||
sent to you" yet.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "3.8.0",
|
||||
"version": "3.9.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -26,6 +26,7 @@ import { errorMessage } from "@/lib/utils";
|
||||
import { BackLink } from "@/components/shared/BackLink";
|
||||
import { uploadImage } from "@/lib/eventSetup";
|
||||
import { useExternalEffect } from "@/lib/hooks";
|
||||
import { useChurch } from "@/contexts/ChurchContext";
|
||||
|
||||
type TabId = "organisation" | "campuses" | "branding" | "notifications" | "email" | "legal" | "whatsapp" | "payments" | "webhooks" | "linked" | "signin" | "backups" | "jobs" | "licence" | "ai";
|
||||
|
||||
@@ -48,7 +49,7 @@ const TABS: { id: TabId; label: string; icon: LucideIcon }[] = [
|
||||
];
|
||||
|
||||
const inputCls =
|
||||
"w-full border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-400";
|
||||
"w-full border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-400 disabled:bg-gray-50 disabled:text-gray-500";
|
||||
|
||||
/** The code from Search Console's verification meta tag; accepts the whole tag or just the code. */
|
||||
function googleVerificationCode(input: string): string {
|
||||
@@ -56,6 +57,20 @@ function googleVerificationCode(input: string): string {
|
||||
return (m ? m[1] : input).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shown above Organisation and Branding while the church's Accounts sets some of their fields:
|
||||
* those come from the church profile (on all the church's sites) and are changed there.
|
||||
*/
|
||||
function FromAccountsNotice({ what, href }: { what: string; href: string | null }) {
|
||||
return (
|
||||
<div className="rounded-lg border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-900">
|
||||
Your church's {what} come from its church profile in Accounts, so every one of its sites shows the same.
|
||||
They can't be changed here.{" "}
|
||||
{href ? <a href={href} className="font-medium underline">Change them in Accounts ↗</a> : "Change them in Accounts, under Church profile."}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Field({
|
||||
label, hint, required, children,
|
||||
}: {
|
||||
@@ -146,6 +161,14 @@ function SiteSettingsPageInner() {
|
||||
const [faviconPreview, setFaviconPreview] = useState<string | null>(null);
|
||||
const faviconRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// ── From Accounts ── the settings the church profile sets (name, logo, colours, contact): shown,
|
||||
// not editable, and never sent back. The church profile's own page in Accounts changes them.
|
||||
const [managed, setManaged] = useState<Set<string>>(new Set());
|
||||
const church = useChurch();
|
||||
const accountsChurchUrl = church ? `${church.links.accounts.replace(/\/+$/, "")}/admin/church` : null;
|
||||
const fromAccounts = (key: string) => managed.has(key);
|
||||
const ownOnly = (updates: Record<string, string>) => Object.fromEntries(Object.entries(updates).filter(([k]) => !managed.has(k)));
|
||||
|
||||
// ── Notifications ──
|
||||
const [notifEmails, setNotifEmails] = useState("");
|
||||
|
||||
@@ -206,6 +229,7 @@ function SiteSettingsPageInner() {
|
||||
setLegalEffectiveDate(s.legal_effective_date || "");
|
||||
setConsentRetentionDays(s.consent_medical_retention_days || "30");
|
||||
setNotifyOnImpersonation(s.notify_user_on_impersonation === "true");
|
||||
setManaged(new Set((s.accounts_managed || "").split(",").filter(Boolean)));
|
||||
})
|
||||
.catch((e: unknown) => setResult({ ok: false, message: errorMessage(e) || "Failed to load settings" }))
|
||||
.finally(() => setLoadingInitial(false));
|
||||
@@ -220,7 +244,7 @@ function SiteSettingsPageInner() {
|
||||
setSaving(true);
|
||||
setResult(null);
|
||||
try {
|
||||
await apiV2Data("put", "/settings", { authToken: token, body: updates });
|
||||
await apiV2Data("put", "/settings", { authToken: token, body: ownOnly(updates) });
|
||||
setResult({ ok: true, message: "Saved." });
|
||||
reloadSettings();
|
||||
} catch (e) {
|
||||
@@ -271,13 +295,13 @@ function SiteSettingsPageInner() {
|
||||
|
||||
await apiV2Data("put", "/settings", {
|
||||
authToken: token,
|
||||
body: {
|
||||
body: ownOnly({
|
||||
primary_color: primaryColor,
|
||||
secondary_color: secondaryColor,
|
||||
accent_color: accentColor,
|
||||
logo_url: finalLogoUrl,
|
||||
favicon_url: finalFaviconUrl,
|
||||
},
|
||||
}),
|
||||
});
|
||||
setLogoUrl(finalLogoUrl);
|
||||
setLogoFile(null);
|
||||
@@ -303,13 +327,13 @@ function SiteSettingsPageInner() {
|
||||
try {
|
||||
await apiV2Data("put", "/settings", {
|
||||
authToken: token,
|
||||
body: { primary_color: "", secondary_color: "", accent_color: "", logo_url: "", favicon_url: "" },
|
||||
body: ownOnly({ primary_color: "", secondary_color: "", accent_color: "", logo_url: "", favicon_url: "" }),
|
||||
});
|
||||
setPrimaryColor("#4F46E5");
|
||||
if (!fromAccounts("primary_color")) setPrimaryColor("#4F46E5");
|
||||
setSecondaryColor("#8B5CF6");
|
||||
setAccentColor("#EC4899");
|
||||
setLogoUrl(""); setLogoFile(null); setLogoPreview(null);
|
||||
setFaviconUrl(""); setFaviconFile(null); setFaviconPreview(null);
|
||||
if (!fromAccounts("accent_color")) setAccentColor("#EC4899");
|
||||
if (!fromAccounts("logo_url")) { setLogoUrl(""); setLogoFile(null); setLogoPreview(null); }
|
||||
if (!fromAccounts("favicon_url")) { setFaviconUrl(""); setFaviconFile(null); setFaviconPreview(null); }
|
||||
setSuggestedColors([]);
|
||||
setResult({ ok: true, message: "Reset to defaults." });
|
||||
reloadSettings();
|
||||
@@ -433,9 +457,10 @@ function SiteSettingsPageInner() {
|
||||
{activeTab === "organisation" && (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-lg font-semibold text-gray-900">Organisation details</h2>
|
||||
{["org_name", "org_email", "org_phone", "org_address"].some(fromAccounts) && <FromAccountsNotice what="name and contact details" href={accountsChurchUrl} />}
|
||||
<Field label="Organisation name" required>
|
||||
<input className={inputCls} placeholder="Your Organisation"
|
||||
value={orgName} onChange={e => setOrgName(e.target.value)} />
|
||||
value={orgName} disabled={fromAccounts("org_name")} onChange={e => setOrgName(e.target.value)} />
|
||||
</Field>
|
||||
<Field label="Tagline">
|
||||
<input className={inputCls} placeholder="Connecting community through events"
|
||||
@@ -444,16 +469,16 @@ function SiteSettingsPageInner() {
|
||||
<div className="grid sm:grid-cols-2 gap-4">
|
||||
<Field label="Contact email">
|
||||
<input type="email" className={inputCls} placeholder="admin@yourchurch.org"
|
||||
value={orgEmail} onChange={e => setOrgEmail(e.target.value)} />
|
||||
value={orgEmail} disabled={fromAccounts("org_email")} onChange={e => setOrgEmail(e.target.value)} />
|
||||
</Field>
|
||||
<Field label="Phone">
|
||||
<input className={inputCls} placeholder="+27 12 345 6789"
|
||||
value={orgPhone} onChange={e => setOrgPhone(e.target.value)} />
|
||||
value={orgPhone} disabled={fromAccounts("org_phone")} onChange={e => setOrgPhone(e.target.value)} />
|
||||
</Field>
|
||||
</div>
|
||||
<Field label="Address" hint="Used as the default location for new events.">
|
||||
<input className={inputCls} placeholder="123 Church St, City"
|
||||
value={orgAddress} onChange={e => setOrgAddress(e.target.value)} />
|
||||
value={orgAddress} disabled={fromAccounts("org_address")} onChange={e => setOrgAddress(e.target.value)} />
|
||||
{orgAddress.trim() && (
|
||||
<a href={mapsSearchUrl(orgAddress.trim())} target="_blank" rel="noopener noreferrer"
|
||||
className="inline-block text-xs text-brand-600 hover:underline mt-1">
|
||||
@@ -477,14 +502,15 @@ function SiteSettingsPageInner() {
|
||||
{activeTab === "branding" && (
|
||||
<div className="space-y-5">
|
||||
<h2 className="text-lg font-semibold text-gray-900">Branding</h2>
|
||||
{["primary_color", "accent_color", "logo_url", "favicon_url"].some(fromAccounts) && <FromAccountsNotice what="logo and colours" href={accountsChurchUrl} />}
|
||||
|
||||
<div className="grid sm:grid-cols-3 gap-4">
|
||||
<ColorPickerField label="Primary" hint="Buttons, links, nav highlights, and the email header/CTA."
|
||||
value={primaryColor} onChange={setPrimaryColor} />
|
||||
value={primaryColor} onChange={setPrimaryColor} disabled={fromAccounts("primary_color")} />
|
||||
<ColorPickerField label="Secondary" hint="Subtle backgrounds and outline-button borders/text."
|
||||
value={secondaryColor} onChange={setSecondaryColor} />
|
||||
<ColorPickerField label="Accent" hint="Hover states and highlight chips/badges."
|
||||
value={accentColor} onChange={setAccentColor} />
|
||||
value={accentColor} onChange={setAccentColor} disabled={fromAccounts("accent_color")} />
|
||||
</div>
|
||||
|
||||
<Field label="Site logo" hint="PNG, JPG, SVG or WebP, max 2 MB. Displayed in the navigation bar.">
|
||||
@@ -492,16 +518,16 @@ function SiteSettingsPageInner() {
|
||||
<div className="mb-3 flex items-center gap-3">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={currentLogoSrc} alt="Current logo" className="h-16 object-contain border rounded p-1 bg-gray-50" />
|
||||
<button
|
||||
{!fromAccounts("logo_url") && <button
|
||||
type="button"
|
||||
className="text-xs text-red-500 hover:text-red-700"
|
||||
onClick={() => { setLogoUrl(""); setLogoFile(null); setLogoPreview(null); setSuggestedColors([]); if (fileRef.current) fileRef.current.value = ""; }}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</button>}
|
||||
</div>
|
||||
)}
|
||||
<input ref={fileRef} type="file" accept="image/*" onChange={e => handleLogoFileChange(e.target.files?.[0])} className="text-sm" />
|
||||
{!fromAccounts("logo_url") && <input ref={fileRef} type="file" accept="image/*" onChange={e => handleLogoFileChange(e.target.files?.[0])} className="text-sm" />}
|
||||
{suggestedColors.length > 0 && (
|
||||
<div className="mt-3 border rounded-lg p-3 bg-gray-50">
|
||||
<p className="text-xs font-medium text-gray-600 mb-2">Suggested from your logo — click a swatch to apply it</p>
|
||||
@@ -524,21 +550,21 @@ function SiteSettingsPageInner() {
|
||||
<div className="mb-3 flex items-center gap-3">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={currentFaviconSrc} alt="Current favicon" className="h-8 w-8 object-contain border rounded p-1 bg-gray-50" />
|
||||
<button
|
||||
{!fromAccounts("favicon_url") && <button
|
||||
type="button"
|
||||
className="text-xs text-red-500 hover:text-red-700"
|
||||
onClick={() => { setFaviconUrl(""); setFaviconFile(null); setFaviconPreview(null); if (faviconRef.current) faviconRef.current.value = ""; }}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</button>}
|
||||
</div>
|
||||
)}
|
||||
<input ref={faviconRef} type="file" accept=".ico,.png,.svg,image/x-icon,image/png,image/svg+xml" onChange={e => {
|
||||
{!fromAccounts("favicon_url") && <input ref={faviconRef} type="file" accept=".ico,.png,.svg,image/x-icon,image/png,image/svg+xml" onChange={e => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
setFaviconFile(file);
|
||||
setFaviconPreview(URL.createObjectURL(file));
|
||||
}} className="text-sm" />
|
||||
}} className="text-sm" />}
|
||||
</Field>
|
||||
|
||||
<div className="flex items-center justify-between pt-4 border-t mt-6 flex-wrap gap-3">
|
||||
|
||||
@@ -5,12 +5,14 @@ import { isValidHex } from "@/lib/colorScale";
|
||||
|
||||
/** A native color swatch + hex text input, shared by the admin Branding tab and the setup wizard's Branding step. */
|
||||
export function ColorPickerField({
|
||||
label, hint, value, onChange,
|
||||
label, hint, value, onChange, disabled,
|
||||
}: {
|
||||
label: string;
|
||||
hint?: string;
|
||||
value: string;
|
||||
onChange: (hex: string) => void;
|
||||
/** Set elsewhere (the church profile in Accounts): shown, not changed here. */
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const valid = isValidHex(value);
|
||||
return (
|
||||
@@ -19,13 +21,15 @@ export function ColorPickerField({
|
||||
<div className="flex items-center gap-3">
|
||||
<input
|
||||
type="color"
|
||||
className="h-10 w-20 border rounded cursor-pointer shrink-0"
|
||||
disabled={disabled}
|
||||
className="h-10 w-20 border rounded cursor-pointer shrink-0 disabled:cursor-not-allowed"
|
||||
value={valid ? value : "#000000"}
|
||||
onChange={e => onChange(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
className={`w-full border rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand-400 ${valid ? "" : "border-red-300"}`}
|
||||
className={`w-full border rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand-400 disabled:bg-gray-50 disabled:text-gray-500 ${valid ? "" : "border-red-300"}`}
|
||||
placeholder="#2563eb"
|
||||
disabled={disabled}
|
||||
value={value}
|
||||
onChange={e => onChange(e.target.value)}
|
||||
/>
|
||||
|
||||
@@ -52,15 +52,18 @@ function computeApiBase(): string {
|
||||
export const API_BASE = computeApiBase();
|
||||
|
||||
// Resolve a URL or path to use the API origin. If it's a relative path, prefix with API_BASE.
|
||||
// If it's an absolute URL but points to localhost/127.0.0.1/::1, rewrite its origin to API_BASE.
|
||||
// If it's an absolute URL to this site's own uploads on localhost/127.0.0.1/::1, rewrite its
|
||||
// origin to API_BASE. Another localhost address (the church's Accounts in development, whose logo
|
||||
// the site now shows) is left as it is.
|
||||
export function resolveToApiOrigin(urlOrPath: string | null | undefined): string | null {
|
||||
const raw = (urlOrPath || "").trim();
|
||||
if (!raw) return null;
|
||||
try {
|
||||
if (raw.startsWith("http")) {
|
||||
const u = new URL(raw);
|
||||
const isLocal = ["localhost", "127.0.0.1", "::1"].includes(u.hostname);
|
||||
if (isLocal && API_BASE) {
|
||||
const isLocal = ["localhost", "127.0.0.1", "::1", "[::1]"].includes(u.hostname);
|
||||
const ownUpload = /^\/(api\/)?uploads\//.test(u.pathname);
|
||||
if (isLocal && ownUpload && API_BASE) {
|
||||
const api = new URL(API_BASE);
|
||||
u.protocol = api.protocol;
|
||||
u.hostname = api.hostname;
|
||||
|
||||
@@ -1,5 +1,55 @@
|
||||
# Changelog — Church Website
|
||||
|
||||
## [1.9.0] — 2026-12-01
|
||||
|
||||
No migration, no new environment settings. Needs `@crosscode/ui` 0.4.0 (built with the Website).
|
||||
|
||||
### Added
|
||||
|
||||
- **A background for each homepage section** (Template and style → Home page layout), from the
|
||||
church's colours: as the style sets it (the default), white, soft main colour, soft accent
|
||||
colour, main colour, or deep main colour. Stored on the design's home entry (`background`,
|
||||
`SECTION_BACKGROUNDS` in `src/site/variants.ts`), kept through a template switch, checked by
|
||||
`cleanDesign`, and carried to the snapshot's section. On the main colour, text, links and
|
||||
buttons use the palette's on-brand colour; on the deep shade, white. A layout with its own
|
||||
background (`cc-own-bg`: a photo, a band) and the top of the page keep theirs; Section colour's
|
||||
tinted and mixed patterns skip a section that has its own.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Events from Cross Events** say "Register on our Events site" only when they take
|
||||
registrations and are open; contact-only, full or closed ones say "More info on our Events
|
||||
site". The site's events carry the registration's `mode`.
|
||||
- **Church details:** the main and accent colours use the shared colour field (`ColourField`,
|
||||
`@crosscode/ui` 0.4.0): a swatch, the hex code to type or paste, and a preview, as Cross Events'
|
||||
Branding settings.
|
||||
|
||||
## [1.8.0] — 2026-11-30
|
||||
|
||||
No migration, no new environment settings. The backend now uses `@crosscode/demo` (built by
|
||||
`crosscode deploy` with the other shared packages).
|
||||
|
||||
### Added
|
||||
|
||||
- **Demo scenarios** (APP-1.0-PLAN §12): `npm run demo -- --profile <p> --scenario <p>` (the
|
||||
scenario must be the profile of the same name) loads a profile as part of the scenario, so the
|
||||
Website shows the same church as Accounts, Cross Events and the App.
|
||||
- **Leaders:** each profile's `scenarioTeam` (`src/demo/seeds.ts`) names four parts, roles and
|
||||
portraits, the pastor first; the names are the scenario's people from `demoPeople`. The pastor
|
||||
is the home page's pastor and the messages' speaker, and every portrait's alt text is the new
|
||||
name. None of the profile's own leader names is left.
|
||||
- **Events:** with a linked Cross Events, a scenario load makes no simple events of its own (and
|
||||
no pictures for them), turns on that link's **Show events from** and fetches Events' whole
|
||||
feed at once (`syncLink`, full), so Events' events show, never copied. If Events can't be
|
||||
reached the load still succeeds and says so; the 15-minute sync catches up. Without Events, the
|
||||
profile's own three events, as before.
|
||||
- On a site with no church profile at all, a scenario saves the scenario's church (from
|
||||
`@crosscode/demo`) instead of Acacia Hill.
|
||||
- `crosscode demo <church> website --profile <p> --scenario <p>` passes `--scenario` on (agent
|
||||
1.7.0 sends it for the Hub's **Load a demo scenario**) and refuses a release before 1.8.0;
|
||||
`packages/demo` joins the Website's shared packages (`website_shared_packages`,
|
||||
`website_build`).
|
||||
|
||||
## [1.7.1] — 2026-11-28
|
||||
|
||||
One migration (`20261128000000_photo_framing`: a nullable `framing` column on `Ministry`,
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
What each version changes for the church, in plain language (read by the Hub like Cross Events'
|
||||
WHATS-NEW.md; a section shows once its version is tagged).
|
||||
|
||||
## 1.9.0
|
||||
|
||||
- **Choose a background for each homepage section.** In **Template and style → Home page layout**,
|
||||
each section now has a background in your church's colours: white, a soft wash of your main or
|
||||
accent colour, your main colour, or a deep shade of it. Text and buttons change to stay easy to
|
||||
read. Leave it as it is and the section follows your style's section colour, as before.
|
||||
- **Events say "More info" when there's nothing to register for.** An event from your Events site
|
||||
only says "Register on our Events site" when people can register; events where people just
|
||||
contact the church say "More info on our Events site".
|
||||
- **An easier colour picker** in **Church details**: pick a colour, or type or paste its code
|
||||
(like #1f4e79), and see it straight away.
|
||||
|
||||
## 1.8.0
|
||||
|
||||
- Behind the scenes, Cross Code's demonstration websites can now be loaded as part of a whole demo
|
||||
church, with the same people and events as its Accounts, Events site and App. Nothing changes on
|
||||
your own website.
|
||||
|
||||
## 1.7.1
|
||||
|
||||
- **Move and zoom now works for ministries, your team and events too**, not only for page
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/website-backend",
|
||||
"version": "1.7.1",
|
||||
"version": "1.9.0",
|
||||
"description": "Church Website: the public site's content API, the admin API, publishing and uploads",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -20,6 +20,7 @@
|
||||
"dependencies": {
|
||||
"@crosscode/auth-client": "*",
|
||||
"@crosscode/contracts": "*",
|
||||
"@crosscode/demo": "*",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"cron-parser": "^5.10.2",
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
* npm run demo -- --template heritage|bold|community|clean [--force] the Acacia Hill church (development)
|
||||
* npm run demo -- --profile <profile> [--force] one of the eight demo churches (1.3.0),
|
||||
* keeping the church's profile and settings
|
||||
* npm run demo -- --profile <profile> --scenario <profile> [--force] 1.8.0: as part of that demo scenario
|
||||
* (its people lead; with Cross Events
|
||||
* linked, Events' events through the feed)
|
||||
* npm run demo -- --list the profiles
|
||||
*
|
||||
* It replaces the site's content, so a site that has been published needs --force. On a server,
|
||||
@@ -22,7 +25,7 @@ const arg = (name: string) => {
|
||||
const i = process.argv.indexOf(`--${name}`);
|
||||
return i > 0 ? process.argv[i + 1] : undefined;
|
||||
};
|
||||
const usage = 'Usage: npm run demo -- --template heritage|bold|community|clean | --profile <profile> [--force] | --list';
|
||||
const usage = 'Usage: npm run demo -- --template heritage|bold|community|clean | --profile <profile> [--scenario <profile>] [--force] | --list';
|
||||
|
||||
if (process.argv.includes('--list')) {
|
||||
for (const s of demoSeeds()) console.log(`${s.id.padEnd(18)} ${s.label}`);
|
||||
@@ -35,6 +38,18 @@ if (!what.success) {
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
// A demo scenario loads the profile of the same name (contracts agent.DEMO_SCENARIOS).
|
||||
const scenarioArg = arg('scenario');
|
||||
const scenario = scenarioArg !== undefined ? agent.demoScenarioSchema.safeParse(scenarioArg) : null;
|
||||
if (scenario && !scenario.success) {
|
||||
console.error(`Unknown scenario "${scenarioArg}" (npm run demo -- --list).`);
|
||||
process.exit(2);
|
||||
}
|
||||
if (scenario && scenario.data !== profileArg) {
|
||||
console.error(`The ${scenario.data} scenario loads the ${scenario.data} profile: --profile ${scenario.data} --scenario ${scenario.data}.`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const db = new PrismaClient({ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }) });
|
||||
const ctx = createCtx(loadConfig(), db);
|
||||
const published = await db.siteVersion.findFirst({ where: { NOT: { publishedBy: 'demo' } } });
|
||||
@@ -43,6 +58,9 @@ if (published && !process.argv.includes('--force')) {
|
||||
await db.$disconnect();
|
||||
process.exit(1);
|
||||
}
|
||||
const version = await loadDemo(ctx, what.data);
|
||||
console.log(`Demo ${what.data} loaded and published (version ${version.number}).`);
|
||||
const version = await loadDemo(ctx, what.data, { scenario: scenario?.data });
|
||||
console.log(`Demo ${what.data}${scenario ? ' (demo scenario)' : ''} loaded and published (version ${version.number}).`);
|
||||
const sync = version.eventsSync;
|
||||
if (sync?.ok) console.log(`Showing Cross Events' events: ${sync.imported} fetched.`);
|
||||
else if (sync) console.warn(`Cross Events' events couldn't be fetched yet (${sync.error}); the next sync, within 15 minutes, brings them.`);
|
||||
await db.$disconnect();
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Prisma } from '../generated/prisma/client.js';
|
||||
import { ApiError } from '../http.js';
|
||||
import { BLOCK_SCHEMAS, isBlockType, rowFraming, SECTION_SCHEMAS } from '../site/sections.js';
|
||||
import { cleanDesign } from '../site/snapshot.js';
|
||||
import { BUTTONS, IMAGE_TREATMENTS, isVariant, SECTION_COLOURS, SECTION_TYPES, sectionTypeSchema, SPACINGS, switchTemplate, TEMPLATE_HEADERS, type SectionType } from '../site/variants.js';
|
||||
import { BUTTONS, IMAGE_TREATMENTS, isVariant, SECTION_BACKGROUNDS, SECTION_COLOURS, SECTION_TYPES, sectionTypeSchema, SPACINGS, switchTemplate, TEMPLATE_HEADERS, type SectionType } from '../site/variants.js';
|
||||
|
||||
type Who = { id: string; role: string };
|
||||
|
||||
@@ -55,7 +55,7 @@ export async function getDesign(ctx: Ctx) {
|
||||
const designPatch = z.object({
|
||||
template: websiteTemplateSchema.optional(),
|
||||
variants: z.record(z.string(), z.string()).optional(),
|
||||
home: z.array(z.object({ section: sectionTypeSchema, hidden: z.boolean() })).max(SECTION_TYPES.length).optional(),
|
||||
home: z.array(z.object({ section: sectionTypeSchema, hidden: z.boolean(), background: z.enum(SECTION_BACKGROUNDS).optional() })).max(SECTION_TYPES.length).optional(),
|
||||
style: z.object({
|
||||
sectionColour: z.enum(SECTION_COLOURS).optional(),
|
||||
spacing: z.enum(SPACINGS).optional(),
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
* icon and the admins, and name the church in the copy. A template alone (development, e2e) is
|
||||
* still Acacia Hill, profile and all, exactly as before.
|
||||
*
|
||||
* 1.8.0: a demo scenario (`--scenario`, APP-1.0-PLAN §12) loads a profile as part of the same
|
||||
* church in every product: the leaders are the scenario's people (`@crosscode/demo`), and with a
|
||||
* linked Cross Events the site shows Events' events through the feed instead of making its own.
|
||||
*
|
||||
* It replaces the Website's content (never the admins), so the script refuses on a site that has
|
||||
* been published unless told otherwise.
|
||||
*/
|
||||
@@ -18,12 +22,13 @@ import { fileURLToPath } from 'node:url';
|
||||
import { CHURCH_SCHEMA, WEBSITE_TEMPLATES, type agent, type Church, type WebsiteTemplate } from '@crosscode/contracts';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { churchProfile } from '../church/profile.js';
|
||||
import { markRemoved, notifyLinks } from '../feed/feed.js';
|
||||
import { demoChurch, demoParts, demoPeople } from '@crosscode/demo';
|
||||
import { markRemoved, notifyLinks, syncLink, type SyncResult } from '../feed/feed.js';
|
||||
import type { SectionData } from '../site/sections.js';
|
||||
import { publish } from '../site/snapshot.js';
|
||||
import { TEMPLATE_HEADERS, TEMPLATE_VARIANTS, SECTION_TYPES, defaultDesign, type SiteDesign } from '../site/variants.js';
|
||||
import { MAX_WIDTH, WIDTHS, processImage, type Sizes } from '../admin/media.js';
|
||||
import { DEMO_SEEDS, type DemoPhotos, type DemoSeed } from './seeds.js';
|
||||
import { DEMO_SEEDS, type DemoPhotos, type DemoSeed, type ProfileSeed } from './seeds.js';
|
||||
|
||||
export const DEMO_COLOURS = { primary: '#1d5c63', accent: '#e0a458' };
|
||||
|
||||
@@ -57,6 +62,41 @@ export function demoProfile(publicUrl: string): Church {
|
||||
} as Church;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.8.0: a scenario's church as a profile, for a scenario loaded on a site that has no profile at
|
||||
* all (Accounts normally has it first and the site reads it from there).
|
||||
*/
|
||||
export function scenarioProfile(publicUrl: string, scenario: agent.DemoScenarioKey): Church {
|
||||
const p = demoChurch(scenario).profile;
|
||||
const base = demoProfile(publicUrl);
|
||||
return {
|
||||
...base,
|
||||
name: p.name, shortName: p.shortName, timezone: p.timezone, locale: p.locale, campuses: p.campuses, serviceTimes: p.serviceTimes, social: p.social,
|
||||
branding: { ...base.branding, colours: p.colours, style: p.style },
|
||||
contact: { ...p.contact, phone: null, whatsapp: null },
|
||||
links: { ...base.links, accounts: `https://example.com/accounts/${demoChurch(scenario).slug}` },
|
||||
} as Church;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.8.0: a profile's seed with the scenario's people as its leaders (`scenarioTeam`), the pastor
|
||||
* first, each with the portrait chosen for them.
|
||||
*/
|
||||
export function scenarioSeed(seed: ProfileSeed, scenario: agent.DemoScenarioKey): DemoSeed {
|
||||
const parts = demoParts(scenario);
|
||||
const leads = demoPeople(scenario).filter((p) => parts.has(p.email));
|
||||
const team = seed.scenarioTeam.map(([part, role, photo]) => {
|
||||
const person = leads.find((p) => parts.get(p.email)!.includes(part));
|
||||
if (!person) throw new Error(`The ${scenario} scenario has no one who is ${part}.`);
|
||||
return { name: person.name, role, photo };
|
||||
});
|
||||
return {
|
||||
...seed,
|
||||
leaders: team.map((l) => [l.name, l.role]),
|
||||
photos: { ...seed.photos, pastor: team[0]!.photo, team: [team[1]!.photo, team[2]!.photo, team[3]!.photo] },
|
||||
};
|
||||
}
|
||||
|
||||
/** Hills, a sun and a path in the church's colours (SVG): what stands in for a demo photo that is missing. */
|
||||
export function illustration(seed: number, w = 1600, h = 1000, colours: { primary: string; accent: string } = DEMO_COLOURS): string {
|
||||
const hues = [colours.primary, colours.accent, '#7fb7be', '#f3e3c3', '#284b52'];
|
||||
@@ -132,14 +172,14 @@ async function demoAsset(ctx: Ctx, uploadDir: string, key: string, alt: string,
|
||||
}
|
||||
|
||||
/** The demo's pictures by slot (hero, collage2, collage3, welcome, pastor, invite, and the four ministries). */
|
||||
async function demoMedia(ctx: Ctx, uploadDir: string, photos: DemoPhotos, pastorName: string, team: string[], colours: { primary: string; accent: string }): Promise<Ids> {
|
||||
async function demoMedia(ctx: Ctx, uploadDir: string, photos: DemoPhotos, pastorName: string, team: string[], colours: { primary: string; accent: string }, withEvents: boolean): Promise<Ids> {
|
||||
const slots: [string, string, string | null][] = [
|
||||
['hero', photos.hero, null], ['collage2', photos.collage[0], null], ['collage3', photos.collage[1], null],
|
||||
['welcome', photos.welcome, null], ['pastor', photos.pastor, pastorName], ['invite', photos.invite, null],
|
||||
...photos.ministries.map((p, i) => [`ministry${i}`, p, null] as [string, string, string | null]),
|
||||
...photos.team.map((p, i) => [`team${i}`, p, team[i] ?? null] as [string, string, string | null]),
|
||||
...photos.messages.map((p, i) => [`message${i}`, p, null] as [string, string, string | null]),
|
||||
...photos.events.map((p, i) => [`event${i}`, p, null] as [string, string, string | null]),
|
||||
...(withEvents ? photos.events : []).map((p, i) => [`event${i}`, p, null] as [string, string, string | null]),
|
||||
];
|
||||
fs.mkdirSync(path.join(uploadDir, 'demo'), { recursive: true });
|
||||
const ids: Ids = {};
|
||||
@@ -224,18 +264,27 @@ export const isDemoTemplate = (v: string): v is WebsiteTemplate => (WEBSITE_TEMP
|
||||
* Replaces the content with a demo, then publishes it. `what`: a template (the Acacia Hill church,
|
||||
* its profile saved too) or a demo profile (keeps the church's profile; Acacia Hill's is saved
|
||||
* only on a site that has none at all, so the site still has a name).
|
||||
*
|
||||
* `scenario` (1.8.0): part of loading that demo scenario, whose church the profile is (the same
|
||||
* name: the script refuses any other). The leaders are the scenario's people, and with a linked
|
||||
* Cross Events the site makes no events of its own: it shows Events' through the feed.
|
||||
*/
|
||||
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string } = {}) {
|
||||
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string; scenario?: agent.DemoScenarioKey } = {}) {
|
||||
const db = ctx.db;
|
||||
const uploadDir = opts.uploadDir ?? ctx.config.uploadDir ?? defaultUploadDir();
|
||||
const classic = isDemoTemplate(what);
|
||||
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : DEMO_SEEDS[what];
|
||||
const scenario = opts.scenario ?? null;
|
||||
if (scenario && scenario !== what) throw new Error(`The ${scenario} scenario loads the ${scenario} profile, not ${what}.`);
|
||||
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : scenario ? scenarioSeed(DEMO_SEEDS[what], scenario) : DEMO_SEEDS[what];
|
||||
const extra = classic ? CLASSIC : null;
|
||||
// A scenario's events are Cross Events' when the church has it: shown through the feed, never copied.
|
||||
const eventsLink = scenario ? await db.productLink.findFirst({ where: { product: 'events' } }) : null;
|
||||
|
||||
// The church: Acacia Hill for a template; else whoever the site belongs to.
|
||||
// The church: Acacia Hill for a template; else whoever the site belongs to (in a scenario,
|
||||
// Accounts has the scenario's church by now).
|
||||
let church = classic ? null : await churchProfile(ctx);
|
||||
if (!church) {
|
||||
church = demoProfile(ctx.config.publicUrl);
|
||||
church = scenario ? scenarioProfile(ctx.config.publicUrl, scenario) : demoProfile(ctx.config.publicUrl);
|
||||
await ctx.settings.set('church_profile_local', JSON.stringify(church));
|
||||
}
|
||||
const name = church.name;
|
||||
@@ -261,7 +310,7 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe
|
||||
const [pastorName] = seed.leaders[0]!;
|
||||
const ministryNames = seed.ministries.map(([, n]) => t(n));
|
||||
const speaker = extra?.pastorName ?? pastorName;
|
||||
const img = await demoMedia(ctx, uploadDir, seed.photos, speaker, seed.leaders.slice(1).map(([name]) => name), colours);
|
||||
const img = await demoMedia(ctx, uploadDir, seed.photos, speaker, seed.leaders.slice(1).map(([name]) => name), colours, !eventsLink);
|
||||
const design = classic ? defaultDesign(seed.template) : seedDesign(seed.template, seed.alternate);
|
||||
await db.siteDesign.create({ data: { id: 1, template: seed.template, variants: design.variants as never, home: design.home as never, style: design.style as never } });
|
||||
|
||||
@@ -330,12 +379,18 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe
|
||||
}
|
||||
n = 0;
|
||||
const made: string[] = [];
|
||||
for (const [slug, title, inDays, description] of seed.events) {
|
||||
for (const [slug, title, inDays, description] of eventsLink ? [] : seed.events) {
|
||||
const startsAt = new Date(Math.floor((now.getTime() + inDays * day) / day) * day + 8 * 3600e3);
|
||||
made.push((await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), imageId: img[`event${n++}`] ?? null, publishedAt: now } })).id);
|
||||
}
|
||||
const version = await publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`);
|
||||
// Linked products fetch the feed now, not at their next poll (one try; the poll catches up).
|
||||
await notifyLinks(ctx, [...gone, ...made]).catch(() => {});
|
||||
return version;
|
||||
let eventsSync: SyncResult | null = null;
|
||||
if (eventsLink) {
|
||||
// Show Events' events (the scenario loaded them just before), the whole list at once.
|
||||
const link = await db.productLink.update({ where: { installId: eventsLink.installId }, data: { showEvents: true } });
|
||||
eventsSync = await syncLink(ctx, link, { full: true });
|
||||
}
|
||||
return { ...version, eventsSync };
|
||||
}
|
||||
|
||||
@@ -8,9 +8,15 @@
|
||||
* profile of each template starts on the template's other recommended variants and header, so the
|
||||
* eight show every recommended look.
|
||||
*
|
||||
* 1.8.0: a profile is also a demo scenario's church (contracts `agent.DEMO_SCENARIOS`, APP-1.0-PLAN
|
||||
* §12). Loaded as part of the scenario (`--scenario`), its leaders are the scenario's people from
|
||||
* `@crosscode/demo` (`scenarioTeam`: their part, role and portrait), the same people as in Accounts,
|
||||
* Cross Events and the App.
|
||||
*
|
||||
* Every person and place in here is made up. A profile id never changes once released.
|
||||
*/
|
||||
import { agent, type WebsiteTemplate } from '@crosscode/contracts';
|
||||
import type { DemoPart } from '@crosscode/demo';
|
||||
|
||||
type WebsiteDemoProfile = agent.WebsiteDemoProfile;
|
||||
|
||||
@@ -36,6 +42,11 @@ export type DemoSeed = {
|
||||
ministries: [string, string, string][];
|
||||
/** Four: [name, role]. The first is the pastor on the home page and the speaker of the messages. */
|
||||
leaders: [string, string][];
|
||||
/**
|
||||
* 1.8.0, a scenario load: four leaders as [part, role, portrait], the pastor first. Their names
|
||||
* are the scenario's people with that part (`demoPeople`); the portraits suit them (photos.json).
|
||||
*/
|
||||
scenarioTeam?: [DemoPart, string, string][];
|
||||
series: [string, string];
|
||||
/** Three: [slug, title, days ago, passage]. */
|
||||
messages: [string, string, number, string][];
|
||||
@@ -68,7 +79,10 @@ export type DemoPhotos = {
|
||||
|
||||
const visitButton: Button = { label: 'Plan your visit', href: '/visit' };
|
||||
|
||||
export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
/** A demo profile: one of the eight, each also a demo scenario's church. */
|
||||
export type ProfileSeed = DemoSeed & { id: WebsiteDemoProfile; scenarioTeam: [DemoPart, string, string][] };
|
||||
|
||||
export const DEMO_SEEDS: Record<WebsiteDemoProfile, ProfileSeed> = {
|
||||
'heritage-parish': {
|
||||
id: 'heritage-parish', template: 'heritage', label: 'Heritage: a parish church with a long history', alternate: false,
|
||||
hero: { headline: 'Worshipping together since 1896', subline: 'An old church with a warm welcome in the heart of {city}. Traditional services, every generation together.', button: visitButton },
|
||||
@@ -95,6 +109,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['pastoral-care', 'Pastoral visiting', 'Home communion and visits for those who can\'t come to church.'],
|
||||
],
|
||||
leaders: [['The Revd Margaret Pillay', 'Rector'], ['The Revd Sipho Ndlovu', 'Assistant priest'], ['Anne Fourie', 'Director of music'], ['David Smith', 'Churchwarden']],
|
||||
scenarioTeam: [['pastor', 'Rector', 'pastor-margaret'], ['worship', 'Director of music', 'team-sipho'], ['kids', 'Sunday school', 'team-anne'], ['prayer-coordinator', 'Prayer coordinator', 'team-david']],
|
||||
series: ['the-lords-prayer', 'The Lord\'s Prayer'],
|
||||
messages: [['your-kingdom-come', 'Your kingdom come', 3, 'Matthew 6:10'], ['our-daily-bread', 'Our daily bread', 10, 'Matthew 6:11'], ['forgive-us', 'Forgive us as we forgive', 17, 'Matthew 6:12']],
|
||||
events: [
|
||||
@@ -131,6 +146,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['soup-kitchen', 'The soup kitchen', 'Soup and bread for anyone who needs it, every weekday at noon.'],
|
||||
],
|
||||
leaders: [['Canon Peter Mahlangu', 'Vicar'], ['The Revd Claire Jacobs', 'City chaplain'], ['Tom Venter', 'Organist'], ['Nomsa Khumalo', 'Soup kitchen coordinator']],
|
||||
scenarioTeam: [['pastor', 'Vicar', 'pastor-peter'], ['prayer-coordinator', 'Prayer coordinator', 'team-claire'], ['worship', 'Organist', 'team-nomsa'], ['youth', 'Students and young adults', 'team-tom']],
|
||||
series: ['songs-of-ascent', 'Songs of Ascent'],
|
||||
messages: [['unless-the-lord-builds', 'Unless the Lord builds the house', 4, 'Psalm 127'], ['i-lift-up-my-eyes', 'I lift up my eyes', 11, 'Psalm 121'], ['how-good-and-pleasant', 'How good and pleasant', 18, 'Psalm 133']],
|
||||
events: [
|
||||
@@ -167,6 +183,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['groups', 'Connect groups', 'Meet in a home during the week and do life together.'],
|
||||
],
|
||||
leaders: [['Jason and Lindi Naidoo', 'Lead pastors'], ['Kagiso Molefe', 'Youth pastor'], ['Megan Steyn', 'Worship pastor'], ['Ruan Pretorius', 'Connect groups']],
|
||||
scenarioTeam: [['pastor', 'Lead pastor', 'team-kagiso'], ['youth', 'Youth pastor', 'team-ayesha'], ['worship', 'Worship pastor', 'team-megan'], ['prayer-coordinator', 'Prayer and connect groups', 'team-ruan']],
|
||||
series: ['unstoppable', 'Unstoppable'],
|
||||
messages: [['fearless', 'Fearless', 3, 'Joshua 1:9'], ['all-in', 'All in', 10, 'Romans 12:1-2'], ['no-turning-back', 'No turning back', 17, 'Luke 9:62']],
|
||||
events: [
|
||||
@@ -203,6 +220,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['dinner-church', 'Dinner church', 'Supper and a conversation about Jesus on Wednesdays.'],
|
||||
],
|
||||
leaders: [['Ben and Zanele Moore', 'Church planters'], ['Ayesha Patel', 'Kids'], ['Chris Hendricks', 'Music'], ['Grace Okafor', 'Community']],
|
||||
scenarioTeam: [['pastor', 'Church planter', 'team-sipho'], ['kids', 'Kids', 'team-ayesha'], ['worship', 'Music', 'team-ruan'], ['prayer-coordinator', 'Prayer and community', 'team-lerato']],
|
||||
series: ['new-beginnings', 'New beginnings'],
|
||||
messages: [['why-church', 'Why church?', 4, 'Acts 2:42-47'], ['the-first-step', 'The first step', 11, 'Mark 1:16-20'], ['a-seat-at-the-table', 'A seat at the table', 18, 'Luke 14:15-24']],
|
||||
events: [
|
||||
@@ -239,6 +257,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['home-groups', 'Home groups', 'Twelve groups across {city}, every Tuesday or Wednesday.'],
|
||||
],
|
||||
leaders: [['Pastor Andile Zulu', 'Senior pastor'], ['Michelle de Beer', 'Children\'s pastor'], ['Kevin and Tracy Reddy', 'Home groups'], ['Lwazi Mthembu', 'Youth']],
|
||||
scenarioTeam: [['pastor', 'Senior pastor', 'pastor-andile'], ['kids', 'Children\'s pastor', 'team-michelle'], ['prayer-coordinator', 'Prayer coordinator', 'team-lerato'], ['youth', 'Youth', 'team-johan']],
|
||||
series: ['family-matters', 'Family matters'],
|
||||
messages: [['love-at-home', 'Love at home', 3, '1 Corinthians 13'], ['raising-faith', 'Raising faith', 10, 'Deuteronomy 6:4-9'], ['better-together', 'Better together', 17, 'Ecclesiastes 4:9-12']],
|
||||
events: [
|
||||
@@ -275,6 +294,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['outreach', 'Farm outreach', 'Visits, food parcels and prayer for farmworker families.'],
|
||||
],
|
||||
leaders: [['Ds. Willem Coetzee', 'Minister'], ['Elsie Maritz', 'Sunday school'], ['Bongani Sithole', 'Farm outreach'], ['Marie Louw', 'Music']],
|
||||
scenarioTeam: [['pastor', 'Minister', 'pastor-willem'], ['kids', 'Sunday school', 'team-elsie'], ['worship', 'Music', 'team-pieter'], ['prayer-coordinator', 'Prayer', 'team-marie']],
|
||||
series: ['seasons', 'Seasons'],
|
||||
messages: [['a-time-to-plant', 'A time to plant', 4, 'Ecclesiastes 3:1-8'], ['waiting-for-rain', 'Waiting for rain', 11, 'James 5:7-8'], ['the-harvest-is-plentiful', 'The harvest is plentiful', 18, 'Matthew 9:35-38']],
|
||||
events: [
|
||||
@@ -311,6 +331,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['alpha', 'Alpha', 'Ten weeks, a meal and a conversation about life and faith.'],
|
||||
],
|
||||
leaders: [['Daniel Joubert', 'Pastor'], ['Refilwe Mokoena', 'Kids'], ['Sam Abrahams', 'Music'], ['Nadia Govender', 'Alpha']],
|
||||
scenarioTeam: [['pastor', 'Pastor', 'pastor-daniel'], ['kids', 'Kids', 'team-bongani'], ['worship', 'Music', 'team-nadia'], ['prayer-coordinator', 'Prayer', 'team-refilwe']],
|
||||
series: ['questions', 'Questions'],
|
||||
messages: [['why-suffering', 'Why is there suffering?', 3, 'Romans 8:18-28'], ['can-i-trust-the-bible', 'Can I trust the Bible?', 10, '2 Timothy 3:14-17'], ['who-is-jesus', 'Who is Jesus?', 17, 'Mark 8:27-30']],
|
||||
events: [
|
||||
@@ -347,6 +368,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
['international', 'International students', 'A welcome, a meal and help settling in.'],
|
||||
],
|
||||
leaders: [['Dr Ian Mabaso', 'Pastor'], ['Lisa Roberts', 'Student worker'], ['Thabo Nkosi', 'Music'], ['Priya Singh', 'International students']],
|
||||
scenarioTeam: [['pastor', 'Pastor', 'pastor-ian'], ['youth', 'Students', 'team-thabo'], ['worship', 'Music', 'team-lisa'], ['prayer-coordinator', 'Prayer', 'team-priya']],
|
||||
series: ['big-questions', 'Big questions'],
|
||||
messages: [['what-is-truth', 'What is truth?', 4, 'John 18:37-38'], ['does-god-care', 'Does God care?', 11, 'Psalm 139'], ['what-makes-a-good-life', 'What makes a good life?', 18, 'Micah 6:8']],
|
||||
events: [
|
||||
@@ -360,4 +382,4 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
|
||||
};
|
||||
|
||||
/** The profiles in the contracts' order (what the Hub offers). */
|
||||
export const demoSeeds = (): DemoSeed[] => agent.WEBSITE_DEMO_PROFILES.map((id: WebsiteDemoProfile) => DEMO_SEEDS[id]);
|
||||
export const demoSeeds = (): ProfileSeed[] => agent.WEBSITE_DEMO_PROFILES.map((id: WebsiteDemoProfile) => DEMO_SEEDS[id]);
|
||||
|
||||
@@ -26,7 +26,8 @@ export type SiteEvent = {
|
||||
/** An outside link for more information or signing up (the Website's own events). */
|
||||
link: string | null;
|
||||
from: 'website' | 'events' | 'app';
|
||||
registration: { status: string; priceFromCents: number | null } | null;
|
||||
/** From Cross Events: how it's joined (`origin`: register there; `contact`: ask the church; `none`: just come), whether it's open, and from what price. */
|
||||
registration: { mode: string; status: string; priceFromCents: number | null } | null;
|
||||
};
|
||||
|
||||
export type SiteMessage = {
|
||||
@@ -147,7 +148,7 @@ async function liveEvents(ctx: Ctx): Promise<SiteEvent[]> {
|
||||
return [{
|
||||
title: e.title, summary: e.summary ?? null, startsAt: e.startsAt, endsAt: e.endsAt ?? null, allDay: !!e.allDay, location: e.location?.name ?? null,
|
||||
image: e.imageUrl ? { url: e.imageUrl, alt: e.title, width: null, height: null } : null, url: e.origin.url, slug: null, link: null, from: e.origin.product,
|
||||
registration: e.registration ? { status: e.registration.status, priceFromCents: e.registration.priceFrom?.amountCents ?? null } : null,
|
||||
registration: e.registration ? { mode: e.registration.mode, status: e.registration.status, priceFromCents: e.registration.priceFrom?.amountCents ?? null } : null,
|
||||
} satisfies SiteEvent];
|
||||
});
|
||||
return [...own, ...copies].sort((a, b) => a.startsAt.localeCompare(b.startsAt));
|
||||
|
||||
@@ -11,7 +11,7 @@ import { WEBSITE_TEMPLATES, type WebsiteTemplate } from '@crosscode/contracts';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { audit } from '../lib/audit.js';
|
||||
import { parseSectionData } from './sections.js';
|
||||
import { defaultDesign, isVariant, SECTION_TYPES, switchTemplate, type SectionType, type SiteDesign } from './variants.js';
|
||||
import { defaultDesign, isVariant, SECTION_BACKGROUNDS, SECTION_TYPES, switchTemplate, type SectionBackground, type SectionType, type SiteDesign } from './variants.js';
|
||||
|
||||
export const SNAPSHOT_VERSION = 1;
|
||||
|
||||
@@ -34,7 +34,8 @@ export const framed = (img: Image | null, f: unknown): Image | null => {
|
||||
|
||||
type MediaRow = { id: string; filename: string; alt: string; width: number | null; height: number | null; sizes?: unknown };
|
||||
|
||||
export type SnapshotSection = { type: string; variant: string | null; data: Record<string, unknown> };
|
||||
/** `background`: a homepage section's own background (variants.ts SECTION_BACKGROUNDS), when it has one. */
|
||||
export type SnapshotSection = { type: string; variant: string | null; data: Record<string, unknown>; background?: SectionBackground };
|
||||
|
||||
export type SnapshotPage = {
|
||||
kind: string;
|
||||
@@ -87,7 +88,11 @@ export function cleanDesign(saved: { template: string; variants: unknown; home:
|
||||
const v = (saved.variants ?? {}) as Record<string, unknown>;
|
||||
for (const s of SECTION_TYPES) if (typeof v[s] === 'string' && isVariant(s, v[s] as string)) variants[s] = v[s] as string;
|
||||
const home = Array.isArray(saved.home)
|
||||
? (saved.home as { section?: unknown; hidden?: unknown }[]).filter((e) => SECTION_TYPES.includes(e?.section as SectionType)).map((e) => ({ section: e.section as SectionType, hidden: !!e.hidden }))
|
||||
? (saved.home as { section?: unknown; hidden?: unknown; background?: unknown }[]).filter((e) => SECTION_TYPES.includes(e?.section as SectionType)).map((e) => ({
|
||||
section: e.section as SectionType,
|
||||
hidden: !!e.hidden,
|
||||
...((SECTION_BACKGROUNDS as readonly unknown[]).includes(e.background) ? { background: e.background as SectionBackground } : {}),
|
||||
}))
|
||||
: base.home;
|
||||
// Every section listed once: any missing one is added at the end, hidden.
|
||||
for (const s of SECTION_TYPES) if (!home.some((e) => e.section === s)) home.push({ section: s, hidden: true });
|
||||
@@ -176,7 +181,7 @@ export function snapshotFrom(source: Source, media: MediaRow[]): Snapshot {
|
||||
const data = parseSectionData(entry.section, byType.get(entry.section)?.data);
|
||||
if (!data) continue;
|
||||
collect(data);
|
||||
sections.push({ type: entry.section, variant: d.variants[entry.section], data });
|
||||
sections.push({ type: entry.section, variant: d.variants[entry.section], data, ...(entry.background ? { background: entry.background } : {}) });
|
||||
}
|
||||
} else {
|
||||
for (const x of p.sections) {
|
||||
|
||||
@@ -104,8 +104,18 @@ export function headerIsTransparent(template: WebsiteTemplate, header: string, h
|
||||
return template === 'bold' && header === 'transparent' && heroVariant !== null && ['photo', 'video', 'collage'].includes(heroVariant);
|
||||
}
|
||||
|
||||
/** A homepage entry: the section and whether it shows. */
|
||||
export type HomeEntry = { section: SectionType; hidden: boolean };
|
||||
/**
|
||||
* A homepage section's own background: always from the church's colours, so it stays on brand.
|
||||
* Left out, the section follows the site's Section colour (style). `light` is plain white; `tint`
|
||||
* and `accent` are soft washes of the main and accent colours; `brand` is the main colour itself and
|
||||
* `dark` a deep shade of it, both with light text. A layout with its own background (a photo, a
|
||||
* band) keeps it.
|
||||
*/
|
||||
export const SECTION_BACKGROUNDS = ['light', 'tint', 'accent', 'brand', 'dark'] as const;
|
||||
export type SectionBackground = (typeof SECTION_BACKGROUNDS)[number];
|
||||
|
||||
/** A homepage entry: the section, whether it shows, and its own background when it has one. */
|
||||
export type HomeEntry = { section: SectionType; hidden: boolean; background?: SectionBackground };
|
||||
|
||||
const order = (shown: SectionType[], hidden: SectionType[] = []): HomeEntry[] => [
|
||||
...shown.map((section) => ({ section, hidden: false })),
|
||||
@@ -184,7 +194,12 @@ export function switchTemplate(current: SiteDesign, to: WebsiteTemplate): { desi
|
||||
}
|
||||
|
||||
const homeUntouched = sameOrder(current.home, TEMPLATE_HOME_ORDER[from]);
|
||||
const home = homeUntouched ? target.home : current.home.map((e) => ({ ...e }));
|
||||
// The order may move to the new template's; each section keeps the background it was given.
|
||||
const backgrounds = new Map(current.home.flatMap((e) => (e.background ? [[e.section, e.background] as const] : [])));
|
||||
const home = (homeUntouched ? target.home : current.home).map(({ background: _b, ...e }) => {
|
||||
const background = backgrounds.get(e.section);
|
||||
return background ? { ...e, background } : e;
|
||||
});
|
||||
if (homeUntouched && !sameOrder(current.home, target.home)) changes.push({ what: 'home', from: `${from} order`, to: `${to} order` });
|
||||
|
||||
const style = { ...current.style };
|
||||
|
||||
@@ -114,7 +114,7 @@ describe('showing events from Cross Events (Show events from)', () => {
|
||||
if (c.mode === 'published') {
|
||||
assert.equal(c.events[0]!.title, 'Youth camp');
|
||||
assert.equal(c.events[0]!.url, 'https://events.hope.test/events/6c7d');
|
||||
assert.deepEqual(c.events[0]!.registration, { status: 'open', priceFromCents: 45000 });
|
||||
assert.deepEqual(c.events[0]!.registration, { mode: 'origin', status: 'open', priceFromCents: 45000 });
|
||||
}
|
||||
assert.match(String((await db.productLink.findUnique({ where: { installId: EVENTS_ID } }))!.lastSyncError), /1 event\(s\) skipped/);
|
||||
});
|
||||
|
||||
@@ -3,9 +3,13 @@ import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
import type { AddressInfo } from 'node:net';
|
||||
import express from 'express';
|
||||
import request from 'supertest';
|
||||
import { WEBSITE_TEMPLATES, agent } from '@crosscode/contracts';
|
||||
import { demoProfile, loadDemo, seedDesign } from '../src/demo/demoChurch.js';
|
||||
import { EVENT_FEED_SCHEMA, EVENT_SCHEMA, WEBSITE_TEMPLATES, agent } from '@crosscode/contracts';
|
||||
import { demoChurch, demoParts, demoPeople } from '@crosscode/demo';
|
||||
import { demoProfile, loadDemo, scenarioProfile, seedDesign } from '../src/demo/demoChurch.js';
|
||||
import { DEMO_SEEDS, demoSeeds } from '../src/demo/seeds.js';
|
||||
import { messageThumbnail, siteContent, spotifyEmbed, youtubeId } from '../src/site/content.js';
|
||||
import { buildPalette, contrast, hexToRgb } from '../src/site/palette.js';
|
||||
@@ -208,6 +212,82 @@ describe('the public site\'s content', () => {
|
||||
assert.ok(c.mode === 'published' && JSON.stringify(c.snapshot).includes('Welcome to Acacia Hill'));
|
||||
});
|
||||
|
||||
for (const profile of agent.WEBSITE_DEMO_PROFILES) {
|
||||
it(`1.8.0: the ${profile} scenario's people lead the ${profile} profile`, async () => {
|
||||
const scenario = profile as agent.DemoScenarioKey;
|
||||
const h = await harness({ linked: false });
|
||||
const dir = tmp();
|
||||
await h.ctx.settings.set('church_profile_local', JSON.stringify(scenarioProfile('http://x.test', scenario)));
|
||||
await loadDemo(h.ctx, profile, { uploadDir: dir, scenario });
|
||||
const c = await siteContent(h.ctx);
|
||||
assert.ok(c.mode === 'published');
|
||||
const seed = DEMO_SEEDS[profile];
|
||||
const parts = demoParts(scenario);
|
||||
const leads = demoPeople(scenario).filter((p) => parts.has(p.email));
|
||||
const expected = seed.scenarioTeam.map(([part, role]) => [leads.find((p) => parts.get(p.email)!.includes(part))!.name, role]);
|
||||
assert.deepEqual(c.snapshot.leaders.map((l) => [l.name, l.role]), expected, 'the scenario\'s people, the pastor first');
|
||||
assert.equal(new Set(expected.map(([name]) => name)).size, 4, 'four different people');
|
||||
for (const [i, l] of c.snapshot.leaders.entries()) assert.equal(l.photo?.alt, expected[i]![0], `${l.name}'s portrait is named for them`);
|
||||
assert.ok(fs.existsSync(path.join(dir, 'demo', `${seed.scenarioTeam[0]![2]}.webp`)), 'the pastor\'s portrait chosen for them');
|
||||
const welcome = c.snapshot.pages[0]!.sections.find((s) => s.type === 'welcome')!.data as { pastor: { name: string; role: string } };
|
||||
assert.deepEqual([welcome.pastor.name, welcome.pastor.role], expected[0]);
|
||||
for (const m of c.messages) assert.equal(m.speaker, expected[0]![0], 'the pastor preaches');
|
||||
const all = JSON.stringify(c.snapshot);
|
||||
for (const [name] of seed.leaders) if (!expected.some(([n]) => n === name)) assert.ok(!all.includes(name), `none of the profile's own leaders (${name})`);
|
||||
assert.equal(c.church?.name, demoChurch(scenario).profile.name);
|
||||
assert.equal(c.events.length, 3, 'without Cross Events, the profile\'s own events');
|
||||
});
|
||||
}
|
||||
|
||||
it('1.8.0: a scenario on a site with no church profile saves the scenario\'s church, not Acacia Hill', async () => {
|
||||
const h = await harness({ linked: false });
|
||||
await loadDemo(h.ctx, 'bold-plant', { uploadDir: tmp(), scenario: 'bold-plant' });
|
||||
const c = await siteContent(h.ctx);
|
||||
assert.equal(c.church?.name, demoChurch('bold-plant').profile.name);
|
||||
assert.ok(c.mode === 'published' && !JSON.stringify(c.snapshot).includes('Acacia'));
|
||||
});
|
||||
|
||||
it('1.8.0: a scenario loads only the profile of the same name', async () => {
|
||||
const h = await harness({ linked: false });
|
||||
await assert.rejects(loadDemo(h.ctx, 'bold-plant', { uploadDir: tmp(), scenario: 'bold-youth' }), /bold-youth profile/);
|
||||
assert.equal(await h.db.siteVersion.count(), 0, 'nothing changed');
|
||||
});
|
||||
|
||||
it('1.8.0: with Cross Events linked, a scenario shows Events\' events through the feed and makes none of its own', async () => {
|
||||
const eventsId = '5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e';
|
||||
const start = new Date(Date.now() + 9 * 864e5);
|
||||
const event = {
|
||||
schema: EVENT_SCHEMA, id: '6c7d8e9f-0a1b-4c2d-8e3f-4a5b6c7d8e9f', origin: { product: 'events', installId: eventsId, url: 'https://events.ignite.test/events/conf' },
|
||||
status: 'published', updatedAt: new Date().toISOString(), title: 'Ignite youth conference', summary: null, description: null, imageUrl: null, timezone: 'Africa/Johannesburg',
|
||||
startsAt: start.toISOString(), endsAt: new Date(start.getTime() + 3600e3).toISOString(), allDay: false, sessions: [], location: { name: 'The auditorium', address: null, onlineUrl: null },
|
||||
campus: null, series: null, tags: [], registration: { mode: 'origin', url: 'https://events.ignite.test/events/conf', status: 'open', opensAt: null, closesAt: null, priceFrom: null },
|
||||
};
|
||||
const fake = express();
|
||||
fake.get('/api/feed/v1/events', (_req, res) => { res.json({ schema: EVENT_FEED_SCHEMA, generatedAt: new Date().toISOString(), deleted: [], events: [event] }); });
|
||||
fake.post('/api/feed/v1/changed', (_req, res) => { res.status(202).json({ accepted: true }); });
|
||||
const server = http.createServer(fake);
|
||||
await new Promise<void>((r) => server.listen(0, '127.0.0.1', () => r()));
|
||||
try {
|
||||
const h = await harness({ linked: false, env: { LINKS_ALLOW_PRIVATE: 'true' } });
|
||||
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
|
||||
await h.db.productLink.create({ data: { installId: eventsId, product: 'events', url, publicKey: 'x', secret: h.ctx.secrets.encrypt('events-link-secret-0123456789abcdef'), connectedAt: new Date(), showEvents: false } });
|
||||
const version = await loadDemo(h.ctx, 'bold-youth', { uploadDir: tmp(), scenario: 'bold-youth' });
|
||||
assert.equal(version.eventsSync?.ok, true, version.eventsSync?.error);
|
||||
assert.equal(await h.db.simpleEvent.count(), 0, 'no events of its own');
|
||||
assert.equal((await h.db.productLink.findUnique({ where: { installId: eventsId } }))?.showEvents, true, 'Show events from Cross Events');
|
||||
const c = await siteContent(h.ctx);
|
||||
assert.ok(c.mode === 'published');
|
||||
assert.deepEqual(c.events.map((e) => [e.title, e.from]), [['Ignite youth conference', 'events']]);
|
||||
assert.equal(await h.db.mediaAsset.count(), 16, 'no pictures for events it doesn\'t make');
|
||||
|
||||
// A single profile load (no scenario) still makes its own, as before.
|
||||
await loadDemo(h.ctx, 'bold-youth', { uploadDir: tmp() });
|
||||
assert.equal(await h.db.simpleEvent.count(), 3);
|
||||
} finally {
|
||||
await new Promise((r) => server.close(r));
|
||||
}
|
||||
});
|
||||
|
||||
it('serves the uploads, never a folder or outside it, and the content over HTTP', async () => {
|
||||
const dir = tmp();
|
||||
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
SECTION_TYPES, SECTION_VARIANTS, TEMPLATE_HEADERS, TEMPLATE_HOME_ORDER, TEMPLATE_STYLE, TEMPLATE_VARIANTS,
|
||||
defaultDesign, defaultVariant, headerIsTransparent, isRecommended, isVariant, switchTemplate,
|
||||
} from '../src/site/variants.js';
|
||||
import { cleanDesign } from '../src/site/snapshot.js';
|
||||
|
||||
describe('section variants (WEBSITE-1.0-PLAN §3, decision 16)', () => {
|
||||
it('has the 26 confirmed variant ids', () => {
|
||||
@@ -101,3 +102,20 @@ describe('switching template', () => {
|
||||
assert.deepEqual(switchTemplate(there, 'heritage').design, defaultDesign('heritage'));
|
||||
});
|
||||
});
|
||||
|
||||
describe("a section's own background", () => {
|
||||
it('stays with its section through a template switch, whether the order moves or not', () => {
|
||||
const start = defaultDesign('heritage');
|
||||
start.home = start.home.map((e) => (e.section === 'events' ? { ...e, background: 'brand' as const } : e));
|
||||
const moved = switchTemplate(start, 'bold').design;
|
||||
assert.equal(moved.home.find((e) => e.section === 'events')?.background, 'brand');
|
||||
assert.deepEqual(moved.home.map((e) => e.section), defaultDesign('bold').home.map((e) => e.section));
|
||||
assert.equal(moved.home.filter((e) => e.background).length, 1);
|
||||
});
|
||||
|
||||
it('is kept by cleanDesign only when it is one of the church-colour choices', () => {
|
||||
const d = cleanDesign({ template: 'clean', variants: {}, home: [{ section: 'welcome', hidden: false, background: 'tint' }, { section: 'events', hidden: false, background: 'hot-pink' }], style: {} });
|
||||
assert.equal(d.home.find((e) => e.section === 'welcome')?.background, 'tint');
|
||||
assert.equal('background' in d.home.find((e) => e.section === 'events')!, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/website-frontend",
|
||||
"version": "1.7.1",
|
||||
"version": "1.9.0",
|
||||
"private": true,
|
||||
"description": "Church Website: the church's public site in its template, and the admin",
|
||||
"scripts": {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
import { useState } from "react";
|
||||
import type { Church } from "@crosscode/contracts";
|
||||
import { ColourField } from "@crosscode/ui";
|
||||
import { api, canEdit } from "@/admin/api";
|
||||
import { ImagePicker } from "@/admin/media";
|
||||
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
|
||||
@@ -55,8 +56,10 @@ export default function ChurchDetails() {
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<Field label="Church name" error={err("name")}><input className={inputClass} value={c.name} maxLength={200} onChange={(e) => set({ name: e.target.value })} /></Field>
|
||||
<Field label="Short name" hint="For tight spaces." error={err("shortName")}><input className={inputClass} value={c.shortName ?? ""} maxLength={30} onChange={(e) => set({ shortName: e.target.value || null })} /></Field>
|
||||
<Field label="Main colour" error={err("branding.colours.primary")}><input type="color" className="h-10 w-20" value={c.branding.colours.primary} onChange={(e) => set({ branding: { ...c.branding, colours: { ...c.branding.colours, primary: e.target.value } } })} /></Field>
|
||||
<Field label="Accent colour"><input type="color" className="h-10 w-20" value={c.branding.colours.accent ?? "#999999"} onChange={(e) => set({ branding: { ...c.branding, colours: { ...c.branding.colours, accent: e.target.value } } })} /></Field>
|
||||
<ColourField label="Main colour" hint="Buttons, links and headings on every site." error={err("branding.colours.primary")} disabled={!editor}
|
||||
value={c.branding.colours.primary} onChange={(primary) => set({ branding: { ...c.branding, colours: { ...c.branding.colours, primary } } })} />
|
||||
<ColourField label="Accent colour" hint="Highlights and touches beside the main colour." error={err("branding.colours.accent")} disabled={!editor}
|
||||
value={c.branding.colours.accent ?? "#999999"} onChange={(accent) => set({ branding: { ...c.branding, colours: { ...c.branding.colours, accent } } })} />
|
||||
<Field label="Fonts" hint="Shared by all your sites. Your template suggests some.">
|
||||
<select className={inputClass} value={c.branding.style?.fontPairing ?? ""} onChange={(e) => set({ branding: { ...c.branding, style: { fontPairing: (e.target.value || null) as never, corners: c.branding.style?.corners ?? null } } })}>
|
||||
{PAIRINGS.map(([v, l]) => <option key={v} value={v}>{l}</option>)}
|
||||
|
||||
@@ -12,7 +12,18 @@ import { api } from "@/admin/api";
|
||||
import { WithPreview } from "@/admin/LivePreview";
|
||||
import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Tabs, Title, useAction, useAdmin } from "@/admin/ui";
|
||||
|
||||
type Design = { template: string; variants: Record<string, string>; home: { section: string; hidden: boolean }[]; style: Record<string, string> };
|
||||
type HomeEntry = { section: string; hidden: boolean; background?: string };
|
||||
type Design = { template: string; variants: Record<string, string>; home: HomeEntry[]; style: Record<string, string> };
|
||||
|
||||
/** A section's own background (backend variants.ts SECTION_BACKGROUNDS), each from the church's colours; "" follows Style → Section colour. */
|
||||
const BACKGROUNDS: { id: string; name: string; swatch: string }[] = [
|
||||
{ id: "", name: "As the style sets it", swatch: "repeating-linear-gradient(45deg, #fff 0 4px, rgb(var(--brand-tint)) 4px 8px)" },
|
||||
{ id: "light", name: "White", swatch: "#fff" },
|
||||
{ id: "tint", name: "Soft main colour", swatch: "rgb(var(--brand-tint))" },
|
||||
{ id: "accent", name: "Soft accent colour", swatch: "linear-gradient(rgb(var(--accent) / 0.12), rgb(var(--accent) / 0.12)), #fff" },
|
||||
{ id: "brand", name: "Main colour", swatch: "rgb(var(--brand))" },
|
||||
{ id: "dark", name: "Deep main colour", swatch: "linear-gradient(rgb(0 0 0 / 0.35), rgb(0 0 0 / 0.35)), rgb(var(--brand-dark))" },
|
||||
];
|
||||
type Options = { variants: Record<string, Record<string, string[]>>; headers: Record<string, string[]> };
|
||||
|
||||
const TEMPLATES = [
|
||||
@@ -94,7 +105,7 @@ export default function TemplatePage() {
|
||||
)}
|
||||
|
||||
{tab === "home" && (
|
||||
<Panel title="Home page: sections and layouts" icon={ListOrdered} sub={<>Every layout works in every template; the first ones listed suit {TEMPLATES.find((t) => t.id === design.template)?.name} best. What each section says is on the home page, under Pages.</>}>
|
||||
<Panel title="Home page: sections and layouts" icon={ListOrdered} sub={<>Every layout works in every template; the first ones listed suit {TEMPLATES.find((t) => t.id === design.template)?.name} best. Each section can have its own background in your church's colours (a layout with a photo or band keeps its own). What each section says is on the home page, under Pages.</>}>
|
||||
<ul className="divide-y divide-gray-100">
|
||||
{design.home.map((e, i) => {
|
||||
const recommended = options.variants[design.template]?.[e.section] ?? [];
|
||||
@@ -107,6 +118,16 @@ export default function TemplatePage() {
|
||||
onChange={(ev) => save({ variants: { [e.section]: ev.target.value } })}>
|
||||
{ordered.map((v) => <option key={v} value={v}>{VARIANT_NAMES[v]}{recommended.includes(v) ? " (suits this template)" : ""}</option>)}
|
||||
</select>
|
||||
{/* The top of the page draws its own background (photo, colour or plain). */}
|
||||
{e.section !== "hero" && (
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="h-6 w-6 shrink-0 rounded border border-gray-300" style={{ background: BACKGROUNDS.find((b) => b.id === (e.background ?? ""))?.swatch }} aria-hidden />
|
||||
<select aria-label={`${SECTIONS[e.section]} background`} title="Background" className={`${inputClass} w-48`} value={e.background ?? ""} disabled={busy}
|
||||
onChange={(ev) => save({ home: design.home.map(({ background: _b, ...x }) => (x.section === e.section ? (ev.target.value ? { ...x, background: ev.target.value } : x) : { ...x, ...(_b ? { background: _b } : {}) })) })}>
|
||||
{BACKGROUNDS.map((b) => <option key={b.id} value={b.id}>{b.id ? b.name : `Background: ${b.name.toLowerCase()}`}</option>)}
|
||||
</select>
|
||||
</span>
|
||||
)}
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" checked={!e.hidden} disabled={busy} onChange={(ev) => save({ home: design.home.map((x) => (x.section === e.section ? { ...x, hidden: !ev.target.checked } : x)) })} />
|
||||
Show
|
||||
|
||||
@@ -59,18 +59,18 @@ h1, h2, h3 {
|
||||
* Section colour: tinted alternates the church colour as a soft background; mixed adds dark bands.
|
||||
* Never on a section that sets its own background (cc-own-bg: a banner, a photo, a dark band).
|
||||
*/
|
||||
[data-section-colour="tinted"] .cc-section:not(.cc-own-bg):nth-of-type(even) { background: rgb(var(--brand-tint)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) { background: rgb(var(--brand-dark)); color: rgb(var(--on-brand)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-card { background: rgb(255 255 255 / 0.06); border-color: rgb(255 255 255 / 0.2); color: inherit; }
|
||||
[data-section-colour="tinted"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(even) { background: rgb(var(--brand-tint)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) { background: rgb(var(--brand-dark)); color: rgb(var(--on-brand)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-card { background: rgb(255 255 255 / 0.06); border-color: rgb(255 255 255 / 0.2); color: inherit; }
|
||||
|
||||
/* Text on a dark background (Bold's cards and bands, a dark section): light, and still AA. */
|
||||
.cc-dark .cc-muted, [data-template="bold"] .cc-card .cc-muted,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-muted { color: rgb(255 255 255 / 0.8); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-muted { color: rgb(255 255 255 / 0.8); }
|
||||
.cc-dark .cc-link, .cc-dark .cc-eyebrow, .cc-dark .cc-brand-text,
|
||||
[data-template="bold"] .cc-card .cc-link, [data-template="bold"] .cc-card .cc-eyebrow, [data-template="bold"] .cc-card .cc-brand-text,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-link,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-eyebrow,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-brand-text { color: rgb(255 255 255); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-link,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-eyebrow,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-brand-text { color: rgb(255 255 255); }
|
||||
|
||||
.cc-muted { color: rgb(75 85 99); }
|
||||
/* The church's colour as text (made AA on light by the palette): here, not a utility, so the dark rules above win. */
|
||||
@@ -108,10 +108,32 @@ h1, h2, h3 {
|
||||
[data-buttons="pill"] .cc-btn { border-radius: 9999px; }
|
||||
[data-template="bold"] .cc-btn { @apply uppercase tracking-wider; }
|
||||
/* A button on a photo or a dark band: always light on dark. */
|
||||
.cc-on-dark .cc-btn, .cc-dark .cc-btn, [data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-btn {
|
||||
.cc-on-dark .cc-btn, .cc-dark .cc-btn, [data-section-colour="mixed"] .cc-section:not(.cc-own-bg):not([data-bg]):nth-of-type(3n) .cc-btn {
|
||||
background: rgb(255 255 255); color: rgb(17 24 39); border-color: rgb(255 255 255);
|
||||
}
|
||||
|
||||
/*
|
||||
* A homepage section's own background (Template → Home page), always from the church's colours.
|
||||
* It replaces the Section colour's pattern for that section; a layout with its own background
|
||||
* (cc-own-bg: a photo, a band) keeps it. On the main colour, text is the palette's on-brand
|
||||
* colour (AA); on the deep shade, white.
|
||||
*/
|
||||
.cc-section[data-bg="light"]:not(.cc-own-bg) { background: rgb(255 255 255); }
|
||||
.cc-section[data-bg="tint"]:not(.cc-own-bg) { background: rgb(var(--brand-tint)); }
|
||||
.cc-section[data-bg="accent"]:not(.cc-own-bg) { background: rgb(var(--accent) / 0.12); }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) { background: rgb(var(--brand)); color: rgb(var(--on-brand)); }
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) { background: linear-gradient(rgb(0 0 0 / 0.35), rgb(0 0 0 / 0.35)), rgb(var(--brand-dark)); color: rgb(255 255 255); }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) .cc-card,
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) .cc-card { background: rgb(255 255 255 / 0.08); border-color: rgb(255 255 255 / 0.25); color: inherit; box-shadow: none; }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) .cc-muted { color: rgb(var(--on-brand) / 0.85); }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) :is(.cc-link, .cc-eyebrow, .cc-brand-text) { color: rgb(var(--on-brand)); }
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) .cc-muted { color: rgb(255 255 255 / 0.8); }
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) :is(.cc-link, .cc-eyebrow, .cc-brand-text) { color: rgb(255 255 255); }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) .cc-btn { background: rgb(var(--on-brand)); color: rgb(var(--brand)); border-color: rgb(var(--on-brand)); }
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) .cc-btn { background: rgb(255 255 255); color: rgb(17 24 39); border-color: rgb(255 255 255); }
|
||||
.cc-section[data-bg="brand"]:not(.cc-own-bg) .cc-btn:hover,
|
||||
.cc-section[data-bg="dark"]:not(.cc-own-bg) .cc-btn:hover { opacity: 0.9; }
|
||||
|
||||
/* Cards. */
|
||||
.cc-card { @apply overflow-hidden bg-white; border-radius: var(--cc-radius, 0.5rem); }
|
||||
[data-template="heritage"] .cc-card { border: 1px solid rgb(var(--brand-text) / 0.2); }
|
||||
|
||||
@@ -9,8 +9,9 @@ import { Button, cx, DateBadge, dayName, fmtDate, fmtTime, Img, Paragraphs, Pict
|
||||
import type { SectionProps, SiteEvent } from "../types";
|
||||
import { Hero } from "./Hero";
|
||||
|
||||
const Section = ({ children, className, id }: { children: React.ReactNode; className?: string; id?: string }) => (
|
||||
<section id={id} className={cx("cc-section", className)}>{children}</section>
|
||||
/** `data-bg`: the section's own background, when the church gave it one (globals.css). */
|
||||
const Section = ({ p, children, className, id }: { p: SectionProps; children: React.ReactNode; className?: string; id?: string }) => (
|
||||
<section id={id} data-bg={p.section.background} className={cx("cc-section", className)}>{children}</section>
|
||||
);
|
||||
|
||||
const tz = (p: SectionProps) => p.site.church?.timezone ?? "Africa/Johannesburg";
|
||||
@@ -79,7 +80,7 @@ function ServiceTimes(p: SectionProps) {
|
||||
if (p.section.variant === "map") {
|
||||
const geo = p.site.church?.contact.address?.geo;
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap grid items-stretch gap-8 md:grid-cols-2">
|
||||
{panel}
|
||||
{geo ? (
|
||||
@@ -90,7 +91,7 @@ function ServiceTimes(p: SectionProps) {
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
return <Section><div className="cc-wrap"><div className={cx(p.template === "heritage" ? "mx-auto max-w-xl" : "max-w-2xl")}>{panel}</div></div></Section>;
|
||||
return <Section p={p}><div className="cc-wrap"><div className={cx(p.template === "heritage" ? "mx-auto max-w-xl" : "max-w-2xl")}>{panel}</div></div></Section>;
|
||||
}
|
||||
|
||||
// ─── Welcome: Text · Image and text · With pastor's photo and quote ────────────────
|
||||
@@ -108,7 +109,7 @@ function Welcome(p: SectionProps) {
|
||||
if (p.section.variant === "pastor" && d.pastor) {
|
||||
const photo = media(p.site, d.pastor.photoId, p.section.data);
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap grid items-center gap-10 md:grid-cols-[2fr_3fr]">
|
||||
<figure className={cx(centred && "text-center")}>
|
||||
<Img image={photo} ratio="aspect-[4/5]" className={cx(p.template === "community" && "rounded-[2rem]", centred && "mx-auto max-w-xs")} />
|
||||
@@ -122,7 +123,7 @@ function Welcome(p: SectionProps) {
|
||||
}
|
||||
if (p.section.variant === "image-text") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className={cx("grid items-center gap-10 md:grid-cols-2", p.template === "bold" ? "px-0 md:gap-0" : "cc-wrap")}>
|
||||
<Img image={media(p.site, d.imageId, p.section.data)} ratio={p.template === "bold" ? "aspect-square md:aspect-auto md:h-full md:min-h-[28rem]" : "aspect-[4/3]"} className={cx(p.template === "community" && "rounded-[2rem]", p.template === "bold" && "rounded-none")} />
|
||||
<div className={cx(p.template === "bold" && "px-6 py-10 sm:px-12")}>{words}</div>
|
||||
@@ -130,7 +131,7 @@ function Welcome(p: SectionProps) {
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
return <Section><div className="cc-wrap"><div className="cc-text">{words}</div></div></Section>;
|
||||
return <Section p={p}><div className="cc-wrap"><div className="cc-text">{words}</div></div></Section>;
|
||||
}
|
||||
|
||||
// ─── Ministries: Cards · List · Alternating bands ───────────────────────────────
|
||||
@@ -145,7 +146,7 @@ function Ministries(p: SectionProps) {
|
||||
|
||||
if (p.section.variant === "bands") {
|
||||
return (
|
||||
<Section className="!pb-0">
|
||||
<Section p={p} className="!pb-0">
|
||||
<div className="cc-wrap">{head}</div>
|
||||
<div className={cx(p.template === "bold" ? "" : "cc-wrap space-y-10")}>
|
||||
{list.map((m, i) => (
|
||||
@@ -165,7 +166,7 @@ function Ministries(p: SectionProps) {
|
||||
}
|
||||
if (p.section.variant === "list") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ul className={cx("divide-y", p.template === "heritage" ? "mx-auto max-w-2xl divide-brand-text/20" : "divide-gray-200")}>
|
||||
@@ -181,7 +182,7 @@ function Ministries(p: SectionProps) {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ul className={cx("grid gap-6", list.length > 3 ? "sm:grid-cols-2 lg:grid-cols-4" : "sm:grid-cols-3")}>
|
||||
@@ -220,7 +221,7 @@ function Team(p: SectionProps) {
|
||||
);
|
||||
if (p.section.variant === "list") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ul className="mx-auto max-w-2xl divide-y divide-gray-200">
|
||||
@@ -233,7 +234,7 @@ function Team(p: SectionProps) {
|
||||
if (p.section.variant === "featured") {
|
||||
const [lead, ...rest] = people;
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
{face(lead!, true)}
|
||||
@@ -242,7 +243,7 @@ function Team(p: SectionProps) {
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
return <Section><div className="cc-wrap">{head}<div className="grid grid-cols-2 gap-8 sm:grid-cols-4">{people.map((l) => face(l))}</div></div></Section>;
|
||||
return <Section p={p}><div className="cc-wrap">{head}<div className="grid grid-cols-2 gap-8 sm:grid-cols-4">{people.map((l) => face(l))}</div></div></Section>;
|
||||
}
|
||||
|
||||
// ─── Upcoming events: Cards · List · Calendar strip ─────────────────────────────
|
||||
@@ -253,7 +254,12 @@ export function EventLine({ e, timeZone }: { e: SiteEvent; timeZone: string }) {
|
||||
<>
|
||||
<time dateTime={e.startsAt} className="cc-muted block text-sm">{when}</time>
|
||||
{e.location && <span className="cc-muted block text-sm">{e.location}</span>}
|
||||
{e.registration && e.registration.status === "open" && <span className="cc-eyebrow mt-1 block text-xs">Register on our Events site</span>}
|
||||
{e.registration && e.from === "events" && (
|
||||
<span className="cc-eyebrow mt-1 block text-xs">
|
||||
{/* Only an event that takes registrations says "Register"; a contact-only one (or a full or closed one) has its details there. */}
|
||||
{(e.registration.mode ?? "origin") === "origin" && e.registration.status === "open" ? "Register on our Events site" : "More info on our Events site"}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -266,11 +272,11 @@ function Events(p: SectionProps) {
|
||||
const head = <SectionHeading heading={d.heading ?? "Coming up"} centred={p.template === "heritage"} />;
|
||||
const more = page && <p className={cx("mt-8", p.template === "heritage" && "text-center")}><a href={page.path} className="cc-link font-semibold">All events</a></p>;
|
||||
if (!list.length) {
|
||||
return <Section><div className="cc-wrap">{head}<p className="cc-muted">Nothing on the calendar just now. Check back soon.</p></div></Section>;
|
||||
return <Section p={p}><div className="cc-wrap">{head}<p className="cc-muted">Nothing on the calendar just now. Check back soon.</p></div></Section>;
|
||||
}
|
||||
if (p.section.variant === "cards") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
@@ -294,7 +300,7 @@ function Events(p: SectionProps) {
|
||||
}
|
||||
if (p.section.variant === "calendar") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ol className="flex snap-x gap-4 overflow-x-auto pb-4">
|
||||
@@ -314,7 +320,7 @@ function Events(p: SectionProps) {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<ul className={cx("divide-y divide-gray-200", p.template === "heritage" && "mx-auto max-w-2xl")}>
|
||||
@@ -351,7 +357,7 @@ function LatestMessage(p: SectionProps) {
|
||||
);
|
||||
if (p.section.variant === "compact") {
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
<div className="flex flex-col gap-4 border-y border-gray-200 py-6 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div><p className="cc-eyebrow">{d.heading ?? "Latest message"}</p><p className="font-heading text-xl font-semibold">{m.title}</p><p className="cc-muted text-sm">{meta}</p></div>
|
||||
@@ -363,7 +369,7 @@ function LatestMessage(p: SectionProps) {
|
||||
}
|
||||
if (p.section.variant === "video") {
|
||||
return (
|
||||
<Section className={cx(p.template === "bold" && "cc-own-bg cc-dark bg-gray-950 text-white")}>
|
||||
<Section p={p} className={cx(p.template === "bold" && "cc-own-bg cc-dark bg-gray-950 text-white")}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<MessagePlayer title={m.title} embedUrl={m.embedUrl} thumbnail={m.thumbnail} url={m.url} source={m.source} />
|
||||
@@ -373,7 +379,7 @@ function LatestMessage(p: SectionProps) {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap">
|
||||
{head}
|
||||
<div className="cc-card grid items-center gap-0 md:grid-cols-2">
|
||||
@@ -414,7 +420,7 @@ function Invitation(p: SectionProps) {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap text-center">
|
||||
<h2 className="cc-h2">{d.heading}</h2>
|
||||
{d.text && <p className="cc-muted mx-auto mt-4 max-w-2xl text-lg">{d.text}</p>}
|
||||
@@ -428,13 +434,13 @@ function Invitation(p: SectionProps) {
|
||||
|
||||
function TextBlock(p: SectionProps) {
|
||||
const d = p.section.data as { heading: string | null; body: string };
|
||||
return <Section><div className="cc-wrap"><div className="cc-text">{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /></div></div></Section>;
|
||||
return <Section p={p}><div className="cc-wrap"><div className="cc-text">{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /></div></div></Section>;
|
||||
}
|
||||
|
||||
function ImageTextBlock(p: SectionProps) {
|
||||
const d = p.section.data as { heading: string | null; body: string; imageId: string | null; button: ButtonData };
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<div className="cc-wrap grid items-center gap-10 md:grid-cols-2">
|
||||
<Img image={media(p.site, d.imageId, p.section.data)} className={cx(p.template === "community" && "rounded-[2rem]")} />
|
||||
<div>{d.heading && <h2 className="cc-h2 mb-6">{d.heading}</h2>}<Paragraphs text={d.body} /><div className="mt-6"><Button button={d.button} /></div></div>
|
||||
@@ -446,7 +452,7 @@ function ImageTextBlock(p: SectionProps) {
|
||||
function QuoteBlock(p: SectionProps) {
|
||||
const d = p.section.data as { quote: string; by: string | null };
|
||||
return (
|
||||
<Section>
|
||||
<Section p={p}>
|
||||
<figure className="cc-wrap text-center">
|
||||
<blockquote className="font-heading mx-auto max-w-3xl text-2xl leading-snug sm:text-3xl">“{d.quote}”</blockquote>
|
||||
{str(d.by) && <figcaption className="cc-muted mt-4">{d.by}</figcaption>}
|
||||
|
||||
@@ -12,7 +12,8 @@ export type Focus = { x: number; y: number; zoom: number };
|
||||
|
||||
export type Image = { url: string; alt: string; width: number | null; height: number | null; srcset?: { webp: string; jpg: string }; focus?: Focus };
|
||||
|
||||
export type Section = { type: string; variant: string | null; data: Record<string, unknown> };
|
||||
/** `background`: a homepage section's own background (light | tint | accent | brand | dark), when it has one. */
|
||||
export type Section = { type: string; variant: string | null; data: Record<string, unknown>; background?: "light" | "tint" | "accent" | "brand" | "dark" };
|
||||
|
||||
export type Page = {
|
||||
kind: string;
|
||||
@@ -59,7 +60,7 @@ export type SiteEvent = {
|
||||
slug: string | null;
|
||||
link: string | null;
|
||||
from: "website" | "events" | "app";
|
||||
registration: { status: string; priceFromCents: number | null } | null;
|
||||
registration: { mode: string; status: string; priceFromCents: number | null } | null;
|
||||
};
|
||||
|
||||
export type SiteMessage = {
|
||||
|
||||
@@ -102,7 +102,8 @@ build differs from this plan, see [Changes while building](#changes-while-buildi
|
||||
| `deploy` | `crosscode deploy <church> [products] [--version …] --json` | emergency only |
|
||||
| `adopt` / `adopt-undo` | `crosscode adopt …` | no |
|
||||
| `restart` | `crosscode restart <church> [product]` (PM2 reload) | no |
|
||||
| `seed-demo` | `crosscode demo <church> --profile <profile> [--admin-email …]` (backup, demo data, reload; agent 1.2.0+) | no, but only for installs marked as demo sites in the Hub, and typing the short name |
|
||||
| `seed-demo` | `crosscode demo <church> [website\|app\|accounts] --profile <profile> [--scenario <s>] [--admin-email …]` (backup, demo data, reload; agent 1.2.0+, the Website 1.6.0+, Accounts, the App and `--scenario` 1.7.0+) | no, but only for installs marked as demo sites in the Hub, and typing the short name |
|
||||
| `seed-scenario` | `crosscode demo <church> --scenario <s> [--admin-email …]`: a whole demo scenario on every product the church has installed, Accounts first, the rest skipped; every release checked first (contracts 1.23.0, agent 1.7.0+) | no, as `seed-demo` |
|
||||
| `export` | `crosscode export <church> --json` (§9) | no |
|
||||
| `uninstall` | `crosscode uninstall <church> --json` | **yes**, and typing the short name |
|
||||
| `purge` | `crosscode purge <church>` (deletes the 30-day keep, §9) | no (scheduled at uninstall) |
|
||||
|
||||
+118
-61
@@ -28,20 +28,31 @@ look comes from the church profile (colours, logo, fonts, corners) and it shares
|
||||
links with the Website and Cross Events, so the three feel like one church.
|
||||
|
||||
**Where things stand:** every earlier phase is released and rolled out, including the Church Website
|
||||
at Hope Family Church and a second church (confirmed by Joshua 2026-11-30).
|
||||
at Hope Family Church and a second church (confirmed by Joshua 2026-11-30). **Phase 6 progress
|
||||
(2026-11-30):** `contracts@1.20.0` to `1.23.0`, `accounts@1.9.0`, `events@3.8.0`, `website@1.8.0` and
|
||||
`agent@1.7.0` released (not deployed yet), with the new shared package `@crosscode/demo` 1.1.0
|
||||
(§12, "Demo scenarios"); Hub `v2.26.0` and `v2.26.1` with `contracts@1.24.0` (devotionals two years
|
||||
ahead, Apps fetch 2 weeks, today included) released, and **the Hub runs 2.26.1 with two years of
|
||||
Cross Code's devotionals** (Joshua, 2026-12-01).
|
||||
The Bible publishers' terms were checked ([BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)): 1.0
|
||||
uses only the free translations, the KJV and the Berean Standard Bible (decision 14, contracts 1.22.0).
|
||||
**Now: `app@1.0.0`** (§15), built in slices (HANDOVER, "Next up"). The foundation is done
|
||||
(2026-12-01, `apps/app` on the branch `feat/app-scaffold`, pushed, merged into main when 1.0.0 is done; not released: §1, §2, the roles and active members of §10, the Hub
|
||||
client of §12); the House of Prayer is next.
|
||||
|
||||
**Who uses 1.0:** the demo church (cross-demo2, Acacia Hill) first, then Hope Family Church. Then
|
||||
it goes on sale (crosscode-site, ROADMAP §9).
|
||||
|
||||
**Done when:**
|
||||
|
||||
- `app@1.0.0`, `contracts@1.20.0` (released 2026-11-30), `contracts@1.21.0` (released 2026-11-30), `accounts@1.9.0`,
|
||||
`events@3.8.0`, `website@1.8.0`, `agent@1.7.0` and Hub `v2.26.0` are tagged; the Hub installs
|
||||
- `app@1.0.0`, `contracts@1.20.0` (released 2026-11-30), `contracts@1.21.0` (released 2026-11-30), `contracts@1.22.0` (released 2026-11-30), `accounts@1.9.0`
|
||||
(released 2026-11-30), `events@3.8.0` (released 2026-11-30), `website@1.8.0` (released 2026-11-30), `agent@1.7.0` (released 2026-11-30) and Hub `v2.26.0` (released 2026-11-30) are tagged; the Hub installs
|
||||
the App from New install (after Accounts) and lists its releases.
|
||||
- On a demo client, **Load a demo scenario** in the Hub loads Accounts, Events, the Website and
|
||||
the App with the same church, people and events, in one step (§12, "Demo scenarios").
|
||||
- The Hub holds 3 months of Cross Code devotionals (written or imported from CSV), and an App set to
|
||||
"From Cross Code" shows and sends them.
|
||||
- The Hub holds at least 3 months of Cross Code devotionals (written or imported from CSV) in the free
|
||||
translations (KJV, BSB; decision 14) (**done**: two years, Joshua 2026-12-01), and an App set to
|
||||
"From Cross Code" shows and sends them with the translation's notice.
|
||||
- A member can add the App to their home screen (Android and iPhone), sign in once, book a one-off
|
||||
or recurring prayer slot, get its reminder by email or WhatsApp, and change or cancel it within
|
||||
the rules.
|
||||
@@ -263,39 +274,58 @@ Decision 1: **two sources**, chosen in Settings → Devotionals:
|
||||
devotional, with its translation and copyright line, and **Read in YouVersion** opens it at
|
||||
`bible.com` (the passage in that translation; YouVersion's app opens instead where it's
|
||||
installed). The YouVersion link is built from the reference and the translation's YouVersion id.
|
||||
- **Translations** (decision 10): each devotional, from Cross Code or the church's own, picks one
|
||||
of seven:
|
||||
- **Translations** (decisions 10 and 14): **App 1.0 offers only the free (public-domain)
|
||||
translations**, for Cross Code's devotionals and a church's own alike:
|
||||
|
||||
| Id | Translation | Language |
|
||||
|---|---|---|
|
||||
| `NLT` | New Living Translation | English |
|
||||
| `ESV` | English Standard Version | English |
|
||||
| `NIV` | New International Version | English |
|
||||
| `NKJV` | New King James Version | English |
|
||||
| `KJV` | King James Version | English |
|
||||
| `AFR53` | Afrikaans 1933/1953-vertaling | Afrikaans |
|
||||
| `AFR83` | Afrikaans 1983-vertaling | Afrikaans |
|
||||
| Id | Translation | Language | In 1.0 |
|
||||
|---|---|---|---|
|
||||
| `KJV` | King James Version | English | ✅ public domain |
|
||||
| `BSB` | Berean Standard Bible (modern English; public domain since 30 April 2023) | English | ✅ public domain |
|
||||
| `NLT` | New Living Translation | English | later, with Tyndale's permission |
|
||||
| `ESV` | English Standard Version | English | later, with Crossway's permission |
|
||||
| `NIV` | New International Version | English | later, with Biblica's permission |
|
||||
| `NKJV` | New King James Version | English | later, with HarperCollins Christian's permission |
|
||||
| `AFR53` | Afrikaans 1933/1953-vertaling | Afrikaans | later, with the Bible Society's permission |
|
||||
| `AFR83` | Afrikaans 1983/1992-vertaling (1983 with the 1992 rewordings) | Afrikaans | later, with the Bible Society's permission |
|
||||
|
||||
The list lives in the contracts with each one's YouVersion id and copyright line, so the Hub,
|
||||
the App and the CSV import agree; an id never changes once released, and more can be added.
|
||||
The Afrikaans pair is the proposal (the 2020-vertaling or the Nuwe Lewende Vertaling could
|
||||
replace one).
|
||||
- **Licensing:** every one but the KJV is under copyright (the Afrikaans ones with the Bible
|
||||
Society of South Africa). Each publisher lets its text be quoted within limits (a number of
|
||||
verses, never a whole book, with its notice), so a devotional quotes **the passage it's about,
|
||||
not whole chapters**, and the App always shows that translation's copyright line under the
|
||||
verse. The Hub and the App warn when a passage is longer than 25 verses. Before Cross Code's
|
||||
devotionals go out to churches, check each publisher's terms for use in an app (or ask for
|
||||
permission); the church is responsible for its own.
|
||||
The list lives in the contracts with each one's YouVersion id, notices and `licence`, so the Hub,
|
||||
the App and the CSV import agree; an id never changes once released, and more can be added. The
|
||||
Hub and the App offer `FREE_BIBLE_TRANSLATION_IDS` only, and the CSV import refuses any other
|
||||
(`checkDevotionalCsv(…, { translations })`, naming the publisher to ask). A translation joins
|
||||
when its publisher gives written permission (a contracts release moves it to `public-domain`
|
||||
or a new `licensed` value, and the Hub and the App offer it from their next release). **There
|
||||
is no free Afrikaans translation** (the Bible Society holds both, and eBible lists none), so an
|
||||
Afrikaans church's devotionals are written in Afrikaans and quote the KJV or BSB until one is
|
||||
cleared.
|
||||
- **Licensing** (checked 2026-11-30, [BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)): every
|
||||
translation but the KJV and BSB is under copyright. Each publisher allows **500 verses** without
|
||||
asking, counted across the whole work (Biblica: the whole app), never a whole book, with its
|
||||
notice. **Daily devotionals pass that in two or three months, and the App is sold**, so using
|
||||
them needs each publisher's **written permission**. Decision 14: 1.0 doesn't wait for it; the
|
||||
requests are drafted in BIBLE-PERMISSIONS.md for when Cross Code wants a translation. A
|
||||
devotional quotes **the passage it's about, not whole chapters**; the Hub and the App warn when
|
||||
a passage is longer than 25 verses.
|
||||
- **Notices** (contracts 1.22.0): the translation's `copyright` line under every quoted passage
|
||||
(screen, email and WhatsApp) and an **Acknowledgements** page (linked from the footer and the
|
||||
devotional) with each used translation's `acknowledgement`. Not required for the KJV and BSB,
|
||||
but shown anyway (the Berean translators ask for it). A translation added later brings its
|
||||
publisher's exact wording, and for the Bible Society's their `disclaimer` with every devotional.
|
||||
- **No AI on Bible text:** Crossway (ESV) and Biblica (NIV) forbid it without a separate licence,
|
||||
so no AI feature reads, writes, translates or summarises a devotional's passage (§4 already keeps
|
||||
AI away from prayer).
|
||||
- **The Hub** (Hub 2.26.0, decision 1): a **Devotionals** page to write and schedule Cross Code's
|
||||
devotionals **up to 3 months ahead**, with a calendar showing which days are filled, and an
|
||||
devotionals **up to two years ahead** (Hub 2.26.1, contracts 1.24.0; 3 months in 2.26.0), with a calendar showing which days are filled, and an
|
||||
**Import CSV** button: upload, a preview with every row checked (date, required fields, a
|
||||
reference YouVersion understands, a date already taken), then import the valid rows, replacing
|
||||
or skipping days already filled. Columns: `date, title, passage, translation, passage_text,
|
||||
body, prayer, author`. A template CSV can be downloaded from the page.
|
||||
- **Getting them to the App:** an App on "From Cross Code" fetches the next 3 months from the Hub
|
||||
(`GET /api/v2/devotionals`, with its licence token) once a night and keeps them, so a Hub outage
|
||||
changes nothing (ROADMAP §1, rule 2). Edits in the Hub reach the App by the next night, or at
|
||||
- **Getting them to the App:** the Hub holds up to two years (it has two, Joshua 2026-12-01), but
|
||||
sends an App only the next **2 weeks, today included**: today and the 13 days after it
|
||||
(`GET /api/v2/devotionals?from=<today in the church's timezone>`, with its licence token;
|
||||
Joshua, 2026-11-30: 2 weeks at most, contracts `CROSSCODE_DEVOTIONALS_FETCH_DAYS`). The App
|
||||
fetches once a night, replaces its copy of those 14 days and keeps what it already has (days
|
||||
before today stay for the archive), so a Hub outage of less than 2 weeks changes nothing
|
||||
(ROADMAP §1, rule 2). Edits in the Hub reach the App by the next night, or at
|
||||
once with **Sync now** in the App's settings. The format is `crosscode.devotional/1`
|
||||
(contracts 1.20.0), so a church's own and Cross Code's devotionals look the same.
|
||||
- **Our own:** the same fields and the same CSV import in the App's admin, scheduled as far ahead as
|
||||
@@ -418,9 +448,9 @@ the band in Settings → Licence. Visitors browsing signed out never count.
|
||||
Network) used for billing, with the band from the heartbeat shown on the install and a
|
||||
**renewal check** (the tier is checked once a year at renewal, ROADMAP §10) that flags an install
|
||||
whose band is above its tier; the FastPanel email for `app.`; the App in Jobs' product filter
|
||||
(already) and demo data; and **Devotionals** (§6): write and schedule up to 3 months ahead, the
|
||||
calendar, Import CSV with its preview, and `GET /api/v2/devotionals` for App installs (licence
|
||||
token, App licences only).
|
||||
(already) and demo data; and **Devotionals** (§6): write and schedule up to two years ahead (2.26.1), the
|
||||
calendar, Import CSV with its preview (the free translations only, §6), and
|
||||
`GET /api/v2/devotionals` for App installs (licence token, App licences only).
|
||||
- **Contracts 1.20.0:** `app` in `DEMO_PRODUCTS`; the `app` section of the church export; the
|
||||
App's modules list (`APP_MODULES`); `crosscode.devotional/1` and the devotionals reply; the CSV
|
||||
columns and row checks (shared by the Hub and the App); `messaging.get` for the App (§8); the
|
||||
@@ -480,12 +510,12 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
|
||||
| Scenario | Church | Website | Events (built from) | App |
|
||||
|---|---|---|---|---|
|
||||
| `heritage-parish` | **St Columba's**: a 120-year-old parish church, small and older, Sunday 09:00 | `heritage-parish` | `small`: carol service, harvest festival, a funeral-tea roster | a quiet wall (about 10 of 24 hours), Cross Code's devotionals in NKJV, a Lent campaign |
|
||||
| `heritage-parish` | **St Columba's**: a 120-year-old parish church, small and older, Sunday 09:00 | `heritage-parish` | `small`: carol service, harvest festival, a funeral-tea roster | a quiet wall (about 10 of 24 hours), Cross Code's devotionals in the KJV, a Lent campaign |
|
||||
| `heritage-city` | **Grace Cathedral**: city centre, three Sunday services, lunchtime prayer | `heritage-city` | `events`: a concert series, ticketed Easter services | full in office hours with gaps at night, a weekday lunchtime focus, announcements per service |
|
||||
| `bold-youth` | **Ignite Church**: young and music-led | `bold-youth` | `events`: a youth conference with paid registration, a worship night | a 21-day campaign before the conference, testimonies, WhatsApp reminders, NLT devotionals |
|
||||
| `bold-youth` | **Ignite Church**: young and music-led | `bold-youth` | `events`: a youth conference with paid registration, a worship night | a 21-day campaign before the conference, testimonies, WhatsApp reminders, BSB devotionals |
|
||||
| `bold-plant` | **Harbour City**: a 2-year-old plant in a school hall | `bold-plant` | `small`: launch Sunday, a newcomers' lunch | a wall still filling up (the admin's setup checklist half done), the pastor's own devotionals |
|
||||
| `community-family` | **Acacia Hill**: a family church (cross-demo2, the mockup's church) | `community-family` | `ministry`: kids' club, Alpha, family camp, volunteer rosters | full with a few gaps (as in the mockup), a 21-day campaign, members' requests waiting for approval |
|
||||
| `community-town` | **Karoo Gemeenskapskerk**: a country-town church, mostly Afrikaans | `community-town` | `small`: a bazaar, a prayer breakfast | AFR83 devotionals of its own, 30-minute slots, the area's emergency numbers |
|
||||
| `community-town` | **Karoo Gemeenskapskerk**: a country-town church, mostly Afrikaans | `community-town` | `small`: a bazaar, a prayer breakfast | Afrikaans devotionals of its own (quoting the BSB until an Afrikaans translation is cleared), 30-minute slots, the area's emergency numbers |
|
||||
| `clean-modern` | **Northpoint**: a contemporary church of about 600 | `clean-modern` | `ministry`: courses, groups launch, serve teams | every hour covered, target 2 per slot, Cross Code's devotionals, announcements by WhatsApp |
|
||||
| `clean-campus` | **Riverside**: three campuses near the university | `clean-campus` | `multicampus`: student welcome week at one campus, a combined worship night | one wall for three campuses, announcements per campus, students on the 02:00 slots |
|
||||
|
||||
@@ -496,15 +526,24 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
profile it uses for each product (`accounts`, `events`, `website`, `app`), so the Hub and the
|
||||
agent agree; a test checks every profile it names exists. `seed-demo` takes an optional
|
||||
`scenario`, and `accounts` joins `DEMO_PRODUCTS` (its demo is the church profile and the people).
|
||||
- **Agent 1.7.0:** runs `crosscode demo <church> <product> --profile <p> [--scenario <s>]` for
|
||||
every product, so a product can tell a scenario load from a single one.
|
||||
- **Agent 1.7.0** (released 2026-11-30): runs `crosscode demo <church> <product> --profile <p>
|
||||
[--scenario <s>]` for every product, so a product can tell a scenario load from a single one,
|
||||
and the whole scenario in **one `seed-scenario` job** (contracts 1.23.0, Joshua 2026-11-30):
|
||||
`crosscode demo <church> --scenario <s>` **seeds whatever the church has installed** on that
|
||||
server, Accounts first, then Events, the Website and the App, and skips the products it doesn't
|
||||
have (a client with only Accounts and the Website gets both). Every installed release is
|
||||
checked against `DEMO_SCENARIO_MIN_VERSIONS` before anything changes; the first failure stops
|
||||
the rest and names the products now out of step (the report's `loaded` and `skipped`).
|
||||
Each product also works without the others: the Website without Accounts uses the scenario's
|
||||
own church profile, without Events its own events; the App without Events its own events.
|
||||
- **Hub 2.26.0:** on a demo client (every install marked as a demo site), **Load a demo
|
||||
scenario**: pick one from the list, see which installs it will replace (and any product the
|
||||
client has that the scenario doesn't cover), type the client's short name once, and the Hub
|
||||
queues one batch in order: **Accounts first** (profile and people), then **Events**, the
|
||||
**Website** and the **App**, each job starting only after the one before it succeeded; a failure
|
||||
stops the rest and says which product is now out of step. At the end the products sync the
|
||||
event feed, and one email reports the whole batch. The client page shows the scenario last
|
||||
sends **one `seed-scenario` job** to the client's server (agent 1.7.0+). The server loads every
|
||||
product the client has there, **Accounts first** (profile and people), then **Events**, the
|
||||
**Website** and the **App**, skipping what isn't installed; a failure stops the rest and the
|
||||
report says which products are now out of step. The Website and the App fetch Events' feed as
|
||||
they load, and one email reports the job. The client page shows the scenario last
|
||||
loaded and when. Loading one product's demo on its own stays (as now), marked "out of step with
|
||||
the scenario" until a scenario is loaded again. The Hub refuses a scenario when an install
|
||||
needs a newer release (each scenario lists the minimum versions it needs).
|
||||
@@ -518,17 +557,21 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
|
||||
| Repo | Change | Version |
|
||||
|------|--------|---------|
|
||||
| `crosscode-platform` `apps/app` | New (§1–§12), with `CHANGELOG.md`, `WHATS-NEW.md`, `env.template.json`, e2e, demo data | `app@1.0.0` |
|
||||
| `crosscode-platform` `apps/app` | New (§1–§12), with `CHANGELOG.md`, `WHATS-NEW.md`, `env.template.json`, e2e, demo data | `app@1.0.0` (**being built** on `feat/app-scaffold`; the foundation done 2026-12-01) |
|
||||
| `crosscode-platform` `packages/contracts` | `app` in `DEMO_PRODUCTS`, `APP_MODULES`, the `app` part of the church export, `crosscode.devotional/1` and its CSV rules, the translations, `messaging.get`, `whatsapp.optout` | `contracts@1.20.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `packages/contracts` | `agent.DEMO_SCENARIOS`, `scenario` in `seed-demo`, `accounts` in `DEMO_PRODUCTS` | `contracts@1.21.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `apps/accounts` | `messaging.get` for linked products, a hint when the messaging settings change, the WhatsApp opt-out for every product; demo data (the scenario's church profile with its logo and icon, and its people) | `accounts@1.9.0` |
|
||||
| `crosscode-platform` `apps/events` | STOP replies passed to Accounts; the opt-out read from Accounts; demo profiles reworked to the scenarios | `events@3.8.0` |
|
||||
| `crosscode-platform` `apps/website` | Demo profiles take the scenario's people and events (`--scenario`) | `website@1.8.0` |
|
||||
| `crosscode-platform` `apps/agent` | `seed-demo` for `app` and `accounts`, `--scenario` passed on | `agent@1.7.0` |
|
||||
| `crosscode-platform` `packages/contracts` | The free translations only in 1.0 (`licence`, `FREE_BIBLE_TRANSLATION_IDS`, the CSV `translations` option), the Berean Standard Bible (`BSB`) added; the publishers' exact notices (`copyright`, `acknowledgement`, the Bible Society's `disclaimer`), `publisher` and `permissionsUrl`, `FREE_QUOTE_VERSES`, `quotedVerses`; `AFR83` named "Afrikaans 1983/1992-vertaling" | `contracts@1.22.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `packages/contracts` | `seed-scenario`: a whole demo scenario in one job, on whatever the church has installed (`SEED_SCENARIO_JOB_MIN_AGENT`) | `contracts@1.23.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `packages/contracts` | `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS` (24: the Hub's two years ahead), `CROSSCODE_DEVOTIONALS_FETCH_DAYS` (14: an App's nightly fetch), the CSV up to 800 rows and 8 MB | `contracts@1.24.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `apps/accounts` | `messaging.get` for linked products, a hint when the messaging settings change, the WhatsApp opt-out for every product; demo data (the scenario's church profile with its logo and icon, and its people) | `accounts@1.9.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `apps/events` | STOP stops all WhatsApp, passed to Accounts; the opt-out read from Accounts; a demo profile per scenario (its four kept) | `events@3.8.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `apps/website` | Demo profiles take the scenario's people and events (`--scenario`) | `website@1.8.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `apps/agent` | `seed-demo` for `app` and `accounts`, `--scenario` passed on; `seed-scenario` (the whole scenario on what's installed) | `agent@1.7.0` (**released 2026-11-30**) |
|
||||
| `crosscode-platform` `packages/demo` | New: the scenarios' churches, people (`gender` from 1.1.0) and SVG logos | `@crosscode/demo` 1.1.0 (workspace, **released with Accounts 1.9.0 / Events 3.8.0**) |
|
||||
| `crosscode-platform` `packages/ui` | The tab bar and bottom sheet, if worth sharing; otherwise nothing | workspace |
|
||||
| `crosscode-platform` `packages/seo` | `Article` builder for devotionals and announcements; the icon generator for the manifest | workspace |
|
||||
| `crosscode-platform` `scripts/` | `products/app.sh`, `app.env.template.json`, bats tests | — |
|
||||
| `events-hub` | App in New install, its releases, env template, billing on the band, renewal check, FastPanel email, Devotionals (write, schedule 3 months ahead, Import CSV, the endpoint for Apps), **Load a demo scenario** on a demo client (vendored contracts 1.21.0) | Hub `v2.26.0` |
|
||||
| `events-hub` | App in New install, its releases, env template, billing on the band, renewal check, FastPanel email, Devotionals (write, schedule up to two years ahead, Import CSV in the free translations, the endpoint for Apps), **Load a demo scenario** on a demo client (one `seed-scenario` job; vendored contracts 1.23.0) | Hub `v2.26.0` (**released 2026-11-30**); `v2.26.1`: two years ahead, Apps fetch 2 weeks (**released 2026-11-30**) |
|
||||
| `crosscode-site` | Church App on sale (ROADMAP §9): its page, the active-member tiers, House of Prayer screenshots, the bundle examples (§10), FAQ, `SoftwareApplication` JSON-LD | `v1.10.0` |
|
||||
|
||||
## 14. Testing
|
||||
@@ -541,9 +584,11 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
Member, the 8-day sign-in renewed up to 90 days, active-member counting and the band, the export
|
||||
and delete hooks, the devotional CSV checks (a bad date, a missing field, a reference YouVersion
|
||||
can't open, a day already filled), the YouVersion links, the nightly Cross Code fetch (and the
|
||||
last copy kept when the Hub is down), `messaging.get`.
|
||||
- **Hub:** the Devotionals page, Import CSV with its preview, the 3-month limit, and the endpoint
|
||||
refusing anything but an App licence.
|
||||
last copy kept when the Hub is down), `messaging.get`, the notice under every quoted passage
|
||||
(screen, email, WhatsApp), only the free translations offered and imported.
|
||||
- **Hub:** the Devotionals page, Import CSV with its preview, the two-year limit (3 months in
|
||||
2.26.0), a translation that isn't free refused, the endpoint answering 14 days from `from` (today
|
||||
included) and refusing anything but an App licence.
|
||||
- **Playwright** (phone, tablet and desktop): browse signed out; sign in from a slot and land back
|
||||
on it with the sheet open (through 2FA); book once, weekly and daily; skip, change and cancel;
|
||||
the 8-hour rule; two browsers, one books, the other's view updates live (and with the stream
|
||||
@@ -564,12 +609,16 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
## 15. Releasing and rolling it out
|
||||
|
||||
1. `contracts@1.20.0` (**released 2026-11-30**), then `accounts@1.9.0` (`messaging.get`, the
|
||||
WhatsApp opt-out) and `events@3.8.0` (STOP passed to Accounts), rolled out to every church.
|
||||
WhatsApp opt-out) and `events@3.8.0` (STOP passed to Accounts), **both released 2026-11-30**,
|
||||
rolled out to every church (not yet).
|
||||
2. `contracts@1.21.0` (demo scenarios, **released 2026-11-30**), with the scenario demo loaders in Accounts 1.9.0, Events
|
||||
3.8.0, `website@1.8.0`, and `agent@1.7.0`.
|
||||
3. Hub `v2.26.0` (vendored contracts 1.21.0) deployed, and the first 3 months of Cross Code
|
||||
devotionals written or imported.
|
||||
4. `app@1.0.0` tagged after the e2e and Lighthouse runs.
|
||||
3.8.0, `website@1.8.0` and `agent@1.7.0` (**both released 2026-11-30**).
|
||||
3. Hub `v2.26.0` (vendored contracts 1.23.0; **released 2026-11-30**) and `v2.26.1` (contracts 1.24.0:
|
||||
two years ahead, Apps fetch 2 weeks, today included; **released 2026-11-30**) deployed, and the
|
||||
first 3 months of Cross Code devotionals written or imported, in the KJV or BSB (decision 14).
|
||||
**Done:** the Hub runs 2.26.1 and holds two years (Joshua, 2026-12-01).
|
||||
4. `app@1.0.0` tagged after the e2e and Lighthouse runs. **Being built** from 2026-12-01 on `feat/app-scaffold` (merged into main when done): the
|
||||
foundation is done (`apps/app/CHANGELOG.md`, "Unreleased"); the slices are in the HANDOVER.
|
||||
5. **cross-demo2** (Acacia Hill): New install → App, every demo scenario loaded once, the
|
||||
throwaway test above.
|
||||
6. **Hope Family Church:** New install → App; the prayer coordinators set the wall up before it's
|
||||
@@ -580,8 +629,8 @@ data that describes **the same church**, so a demo shows the three products work
|
||||
|
||||
Made by Joshua on 2026-11-30, after the first draft and the mockup:
|
||||
|
||||
1. **Devotionals have two sources:** from Cross Code (written in the Hub, scheduled up to 3 months
|
||||
ahead, with a CSV import) or the church's own (§6). Verses open in **YouVersion**.
|
||||
1. **Devotionals have two sources:** from Cross Code (written in the Hub, scheduled up to two years
|
||||
ahead (changed from 3 months by Joshua, 2026-11-30; Apps fetch 2 weeks at a time), with a CSV import) or the church's own (§6). Verses open in **YouVersion**.
|
||||
2. **The House of Prayer is a 24-hour clock**, not a grid (§3; mockup redrawn).
|
||||
3. **Ask for prayer as drawn**, and **every shared request is approved first** (§4).
|
||||
4. **One set of email and WhatsApp credentials per church,** shared by Events, Accounts and the
|
||||
@@ -600,6 +649,7 @@ Made by Joshua on 2026-11-30, after the first draft and the mockup:
|
||||
panels and stat cards), not a new style (§10; mockup redrawn).
|
||||
10. **Each devotional uses one of NLT, ESV, NIV, NKJV, KJV or two Afrikaans translations**
|
||||
(proposed: 1933/1953 and 1983), quoting only the passage, with its copyright line (§6).
|
||||
Narrowed by decision 14: only the free ones (KJV, BSB) in 1.0.
|
||||
11. **Accounts keeps the WhatsApp opt-out for every product,** so a STOP to the shared number
|
||||
reaches the App, Events and Accounts alike (§8). Adds Events 3.8.0.
|
||||
12. **Home shows today's prayer clock** in small, as the House of Prayer does (mockup redrawn).
|
||||
@@ -608,6 +658,10 @@ Made by Joshua on 2026-11-30, after the first draft and the mockup:
|
||||
contracts 1.21.0, agent 1.7.0 and Website 1.8.0, and demo data in Accounts 1.9.0. Eight
|
||||
scenarios, one per Website demo profile, each its own church: a scenario load replaces the
|
||||
church profile with its own name, logo, icon, colours and details.
|
||||
14. **Only free Bible translations in 1.0** (added later on 2026-11-30, after the publishers'
|
||||
terms were checked: none covers a sold app past 500 verses): the KJV and the Berean Standard
|
||||
Bible. The others stay in the contracts and join when a publisher gives written permission;
|
||||
that doesn't hold up this plan (§6, [BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)).
|
||||
|
||||
The other proposals as first written, confirmed:
|
||||
|
||||
@@ -643,6 +697,9 @@ for a group; an app-store release; moving to the church's own domain (as the Web
|
||||
## Still open
|
||||
|
||||
- ~~Which two Afrikaans translations~~: 1933/1953 and 1983, confirmed by Joshua 2026-11-30 (YouVersion ids checked, contracts 1.20.0).
|
||||
- **The publishers' terms** for quoting each translation in an app (§6), checked before Cross
|
||||
Code's devotionals go out; ask for permission where the terms don't cover it.
|
||||
- ~~The publishers' terms~~: checked 2026-11-30 ([BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)).
|
||||
None covers a sold app past 500 verses, so 1.0 uses only the free translations (decision 14).
|
||||
The permission requests are drafted for later; nothing in this plan waits for them.
|
||||
- **An Afrikaans translation** (1.x): none is free. Ask the Bible Society when an Afrikaans church
|
||||
needs one (the request is drafted in BIBLE-PERMISSIONS.md).
|
||||
- ~~The demo scenarios~~: eight, one per Website demo profile, each its own church with its own logo and details; Acacia Hill is `community-family` (Joshua, 2026-11-30).
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
# Bible translations: permissions for the Church App
|
||||
|
||||
Written 2026-11-30 for [APP-1.0-PLAN.md](./APP-1.0-PLAN.md) §6 (decisions 5 and 10), which said:
|
||||
"before Cross Code's devotionals go out to churches, check each publisher's terms for use in an
|
||||
app". This file holds what each publisher allows, where each request stands and the requests
|
||||
themselves. **Update the status table when a publisher answers.**
|
||||
|
||||
Sources, read 2026-11-30: crossway.org/permissions, harpercollinschristian.com (Sales and rights →
|
||||
Permissions), the Bible Society of South Africa's *Copyright Policy 2022* (updated 18 July 2022,
|
||||
linked from biblesociety.co.za → Copyright and permissions), and Tyndale's and Biblica's
|
||||
permissions pages (copied by Joshua into `temp/`, as their sites refuse automated reading).
|
||||
|
||||
## Decision: only free translations in App 1.0
|
||||
|
||||
**Joshua, 2026-11-30:** App 1.0 and the Hub use only the free, public-domain translations: the
|
||||
**KJV** and the **Berean Standard Bible** (BSB, dedicated to the public domain under CC0 on
|
||||
30 April 2023, berean.bible/terms.htm; bible.com version 3034). The others stay in the contracts
|
||||
and join when a publisher gives written permission; **nothing in APP-1.0-PLAN waits for that**.
|
||||
The requests below are drafted for when Cross Code wants a translation, and aren't sent yet.
|
||||
|
||||
There is **no free Afrikaans translation**: the Bible Society holds the 1933/1953, 1983/1992 and
|
||||
2020 translations, and eBible lists none. The World English Bible is also public domain but was
|
||||
left out (its own copyright page was gone when checked, and the BSB covers modern English).
|
||||
|
||||
## The short answer
|
||||
|
||||
**No publisher's free allowance covers Cross Code's devotionals.** Every one but the KJV allows
|
||||
about **500 verses** without asking, but:
|
||||
|
||||
1. **The 500 count across the whole work**, not per devotional. Biblica says so outright: on a
|
||||
website or app "the General Use Guidelines apply to the entire platform". A daily devotional of
|
||||
5–10 verses passes 500 within two or three months; a year is about 2 000–3 500 verses.
|
||||
2. **The App is commercial.** Churches pay for it (a subscription by active-member band). The Bible
|
||||
Society's policy calls anything "subject to a sale, lease or trade agreement" commercial; Biblica's
|
||||
free "Express Licensing" for apps excludes "sales, subscriptions"; Tyndale's free allowance
|
||||
covers only "print or eBook" use.
|
||||
|
||||
So Cross Code needs **written permission from each publisher** whose translation its devotionals
|
||||
use, hence the decision above.
|
||||
|
||||
A church's own devotionals are limited to the free translations too in 1.0. When a translation
|
||||
needing permission is added later, `quotedVerses` and `FREE_QUOTE_VERSES` (contracts 1.22.0) let
|
||||
the Hub and the App count verses against the allowance.
|
||||
|
||||
## Status
|
||||
|
||||
| Translation | Publisher | Free use | Our use | Request | Status |
|
||||
|---|---|---|---|---|---|
|
||||
| `KJV` | none (public domain; Crown rights in the UK only) | everything | covered | none needed | ✅ In 1.0 |
|
||||
| `BSB` | none (public domain, CC0, since 2023-04-30) | everything; attribution "appreciated but not required", the Berean name only for the verbatim text | covered | none needed | ✅ In 1.0 |
|
||||
| `NLT` | Tyndale House Publishers | 500 verses, **print or eBook only** | not covered (an app, past 500, commercial) | [Tyndale](#tyndale-nlt) | Later (not sent) |
|
||||
| `ESV` | Crossway | 500 verses (print, digital, audio); its API free for non-commercial use only | not covered (past 500, commercial app) | [Crossway](#crossway-esv) | Later (not sent) |
|
||||
| `NIV` | Biblica, Inc. (South Africa is "rest of the world") | 500 verses **across the whole platform**; Express Licensing only for non-commercial apps without AI | not covered | [Biblica](#biblica-niv) | Later (not sent) |
|
||||
| `NKJV` | HarperCollins Christian Publishing (Thomas Nelson) | 500 verses in any form; apps: "contact our licensing department" | not covered | [HarperCollins](#harpercollins-christian-nkjv) | Later (not sent; 6–8 weeks to answer) |
|
||||
| `AFR53`, `AFR83` | Bible Society of South Africa | 500 verses, plus a copy of the work couriered to them | not covered (past 500, commercial) | [Bible Society](#bible-society-of-south-africa-afr53-afr83) | Later (not sent) |
|
||||
|
||||
When a request is answered, record here the date, any fee, the conditions (a verse cap, a notice,
|
||||
reporting) and where the letter is kept, then release contracts with the translation's `licence`
|
||||
changed, so the Hub and the App offer it (APP-1.0-PLAN §6).
|
||||
|
||||
## What each publisher requires
|
||||
|
||||
### Every translation
|
||||
|
||||
- **The exact notice, under every quote.** The texts are in `packages/contracts/src/bible.ts`
|
||||
(`copyright` under the verse, `acknowledgement` for the App's **Acknowledgements** page). Copy
|
||||
them from the publisher; never reword them.
|
||||
- **Quote exactly**, punctuation and capitals included (Tyndale, Crossway, Biblica), from the latest
|
||||
edition (Biblica: only its latest editions; Crossway: ESV Text Edition 2025).
|
||||
- **Never a whole book**, and quotes under 25% of the work (the devotionals are mostly the writer's
|
||||
text, so this holds; the Hub and App warn past 25 verses in one passage).
|
||||
- **No AI on Bible text.** Crossway: the ESV text may not be "used, accessed, or processed by any
|
||||
AI system". Biblica: any use "in connection with artificial intelligence, machine learning, large
|
||||
language models, chatbots" needs a separate licence. So **no AI feature may ever read, write,
|
||||
translate or summarise a devotional's passage** (Events' AI buttons, anything added to the Hub
|
||||
or the App later). The App already keeps AI away from prayer (§4); this extends it to devotionals.
|
||||
- **Permission is for the use asked for and isn't passed on** (Tyndale: "you may not pass permission
|
||||
on to another person"). So each request names the whole chain: Cross Code writes, the Hub
|
||||
distributes to each church's App, the App shows it and sends it by email and WhatsApp.
|
||||
|
||||
### Tyndale (NLT)
|
||||
|
||||
- Free: up to 500 verses "in any print or eBook form", under 25% of the work, never a complete book.
|
||||
Online sermons and posts have their own limits (50 or 250 verses per recording, non-commercial).
|
||||
**Apps aren't covered at all.**
|
||||
- Notice (only the NLT): "Scripture quotations are taken from the Holy Bible, New Living
|
||||
Translation, copyright © 1996, 2004, 2015 by Tyndale House Ministries. Used by permission. All
|
||||
rights reserved." With several translations: "Scripture quotations marked (NLT) are taken from…".
|
||||
(Our 1.20.0 notice still said "Tyndale House Foundation … Carol Stream, Illinois"; fixed in
|
||||
contracts 1.22.0.)
|
||||
- Ask: permission@tyndale.com or the Permissions Questionnaire on tyndale.com/permissions.
|
||||
|
||||
### Crossway (ESV)
|
||||
|
||||
- Free: up to 500 verses in print, digital or audio, under half of any book and under 25% of the
|
||||
work, not in a commentary. Websites, blogs and social media are listed as covered uses.
|
||||
- The ESV API (api.esv.org) is free "for non-commercial use" only.
|
||||
- Notice: "Scripture quotations are from the ESV® Bible (The Holy Bible, English Standard
|
||||
Version®), © 2001 by Crossway, a publishing ministry of Good News Publishers. ESV Text Edition:
|
||||
2025. …" with the Creative Commons and translation clauses, ending "Used by permission. All
|
||||
rights reserved." **Check the text in `bible.ts` against crossway.org/permissions word for word
|
||||
before the App ships**: the page reader could only confirm its clauses and their order.
|
||||
- "ESV" and "English Standard Version" are trademarks: fine to label a quote, not for branding.
|
||||
- No AI (above).
|
||||
- Ask: the Digital form at crossway.org/permissions/digital/.
|
||||
|
||||
### Biblica (NIV)
|
||||
|
||||
- Outside North America, the UK and Europe, Biblica itself handles every commercial use "including
|
||||
non-print and audio". South Africa is in that group.
|
||||
- Free: 500 verses or fewer **in total**, never a complete book, under 25% of the "product,
|
||||
publication, or platform", with the notice; on a website or app, for the whole platform.
|
||||
- **Express Licensing** (free, through api.bible or platform.youversion.com) is only for apps that
|
||||
are "truly non-commercial (no sales, subscriptions, …)" and have no AI features. The App is sold,
|
||||
so it doesn't qualify.
|
||||
- Licences for a full Bible or New Testament only go to registered legal entities (not our case,
|
||||
but the request comes from Cross Code as a company).
|
||||
- Notice: Biblica offers to provide the correct one. Ours ("Scripture quotations taken from The
|
||||
Holy Bible, New International Version® NIV®. Copyright © 1973, 1978, 1984, 2011 by Biblica,
|
||||
Inc.™ Used by permission. All rights reserved worldwide.") is the one Biblica has long asked for;
|
||||
**ask them to confirm it** in the request.
|
||||
- No AI (above).
|
||||
- Ask: the Permission Request Form on biblica.com/permissions.
|
||||
|
||||
### HarperCollins Christian (NKJV)
|
||||
|
||||
- Free: up to 500 verses "in any form (written, visual, electronic, or audio)", under 25% of the
|
||||
work, under half of any book, not in a commentary, properly cited.
|
||||
- Apps: "for a smartphone app or other digital product … contact our licensing department".
|
||||
- Notice (ours is right): "Scripture taken from the New King James Version®. Copyright © 1982 by
|
||||
Thomas Nelson. Used by permission. All rights reserved."
|
||||
- Ask: the HarperCollins Christian Permission Request Form
|
||||
(cognitoforms.com/HarperCollinsChristianPublishing/PermissionsForm); questions to
|
||||
HCCPpermissions@HarperCollins.com. **6–8 weeks** on average; no phone calls, no duplicate
|
||||
requests, incomplete requests are ignored.
|
||||
|
||||
### Bible Society of South Africa (AFR53, AFR83)
|
||||
|
||||
- Both are theirs: "Bybel in Afrikaans 1933/1953-vertaling" and "Bybel in Afrikaans 1983-vertaling
|
||||
met herformulerings tot en met 1992" (policy §3 a and c). "Ou Vertaling" and "Nuwe Vertaling"
|
||||
are not official names and may not be used (§6).
|
||||
- Free (§4): up to 500 verses, under 50% of a book and under 25% of the work, with a notice, **and
|
||||
one copy of the work couriered** to the Copyright Officer (134 Edward Street, Bellville 7530) with
|
||||
an email to copyright@biblesociety.co.za. For an app, ask what they want instead.
|
||||
- Past that, or commercial (§5): a formal application, made **during planning, before release**.
|
||||
Two copies of a commercial product are due after publication. A fee may be set case by case
|
||||
(§7.2); they may require a **text release** (their files, for this use only, never passed on;
|
||||
§7.3). Permission is per edition (§7.1).
|
||||
- Apps (§3): a complete Bible text in "mobile application software" needs written permission (we
|
||||
quote passages only). Social media: one verse at a time (§6.2); media and "social media
|
||||
campaigns" go to biblia@biblesociety.co.za (§5.3). Name WhatsApp and email sends in the request.
|
||||
- Notices (§6.2, digital): the short form on every screen with the text, the full form in an
|
||||
acknowledgements section, and **the disclaimer** with them whenever their text is next to
|
||||
content they haven't approved (§6.4), which is every devotional. All three are in `bible.ts`. Our
|
||||
copy of the Afrikaans disclaimer reads "beskou kan word" where the policy has the typo "can word".
|
||||
- Ask: copyright@biblesociety.co.za (the application form for legal entities is linked from their
|
||||
page), 021 910 8777. Post: PO Box 5500, Tyger Valley 7536.
|
||||
|
||||
## The requests
|
||||
|
||||
Fill in the bracketed details before sending. Each describes the same use, so the answers can be
|
||||
compared. Send them from Cross Code's address, not a personal one, and keep the replies (and any
|
||||
licence) with the company's records; note where in the status table.
|
||||
|
||||
**The use, in one paragraph** (paste into each form's description field):
|
||||
|
||||
> Cross Code [company name and registration number], South Africa, makes the Church App, a web app
|
||||
> that churches in South Africa subscribe to (priced by how many members use it). Each church has
|
||||
> its own App at its own address. Cross Code writes a daily devotional that churches can choose to
|
||||
> show: each quotes one Bible passage (usually 3–10 verses, never more than 25, never a whole
|
||||
> chapter's worth of a short book), shown in full above the devotional with your copyright notice
|
||||
> under it, followed by the devotional (about 300–600 words of our own) and a prayer. The
|
||||
> devotional is shown in the App (public pages, as text, not downloadable), kept by the App for
|
||||
> offline reading on the member's phone, and sent at the member's request by email and WhatsApp
|
||||
> (the title, the passage and a link to the App). A "Read in YouVersion" link opens the passage on
|
||||
> bible.com. We expect about [365] devotionals a year in [translation], about [2 500] verses a
|
||||
> year, the same for every church that chooses them; we start with [N] churches and expect
|
||||
> [N] within a year. No AI is used with the Bible text. We would like permission for this use,
|
||||
> and to know any fee, the notice you want and any conditions.
|
||||
|
||||
### Tyndale (NLT)
|
||||
|
||||
To: permission@tyndale.com (or the Permissions Questionnaire)
|
||||
Subject: Permission request: NLT in a church devotional app (South Africa)
|
||||
|
||||
> Dear Permissions team,
|
||||
>
|
||||
> We would like permission to quote the New Living Translation in daily devotionals in a church
|
||||
> app. Your fair-use guideline covers print and eBook use up to 500 verses; ours is an app, sold to
|
||||
> churches by subscription, and goes past 500 verses within a few months.
|
||||
>
|
||||
> [The use, in one paragraph.]
|
||||
>
|
||||
> We would show the notice "Scripture quotations are taken from the Holy Bible, New Living
|
||||
> Translation, copyright © 1996, 2004, 2015 by Tyndale House Ministries. Used by permission. All
|
||||
> rights reserved." under every passage. Since each church's App shows the devotionals Cross Code
|
||||
> writes, please let us know whether your permission to Cross Code covers their display in every
|
||||
> subscribing church's App.
|
||||
>
|
||||
> Kind regards,
|
||||
> [name], Cross Code
|
||||
> [email, phone, address]
|
||||
|
||||
### Crossway (ESV)
|
||||
|
||||
Form: crossway.org/permissions/digital/ (description field):
|
||||
|
||||
> [The use, in one paragraph.] We would show your full ESV notice (ESV Text Edition: 2025) under
|
||||
> every passage and quote the current ESV text exactly. We understand the ESV API's free terms
|
||||
> are for non-commercial use; we would like to know whether we may use the API or must supply
|
||||
> the text ourselves, and any fee. The ESV text will not be processed by any AI system.
|
||||
|
||||
### Biblica (NIV)
|
||||
|
||||
Form: Permission Request Form on biblica.com/permissions (rest of the world, digital, commercial):
|
||||
|
||||
> [The use, in one paragraph.] We understand your General Use Guidelines apply to the whole
|
||||
> platform and that Express Licensing is for non-commercial apps only, so we are asking for
|
||||
> permission. We would quote the latest NIV text exactly and show this notice under every passage;
|
||||
> please confirm it is the one you want: "Scripture quotations taken from The Holy Bible, New
|
||||
> International Version® NIV®. Copyright © 1973, 1978, 1984, 2011 by Biblica, Inc.™ Used by
|
||||
> permission. All rights reserved worldwide." The App has no AI or machine-learning features that
|
||||
> use the Bible text. Cross Code is a registered company ([registration number]).
|
||||
|
||||
### HarperCollins Christian (NKJV)
|
||||
|
||||
Form: HarperCollins Christian Permission Request Form (fill in every field; incomplete requests
|
||||
aren't considered):
|
||||
|
||||
> [The use, in one paragraph.] We would show "Scripture taken from the New King James Version®.
|
||||
> Copyright © 1982 by Thomas Nelson. Used by permission. All rights reserved." under every
|
||||
> passage. Your page asks smartphone apps and other digital products to contact the licensing
|
||||
> department; please pass this on if that is the right place.
|
||||
|
||||
### Bible Society of South Africa (AFR53, AFR83)
|
||||
|
||||
To: copyright@biblesociety.co.za, with the application form for legal entities
|
||||
Subject: Aansoek om kopiereg-toestemming: Bybel in Afrikaans 1933/1953 en 1983/1992 in 'n kerk-app
|
||||
(Application for copyright permission: the Afrikaans 1933/1953 and 1983/1992 Bibles in a church app)
|
||||
|
||||
> Geagte Regspraktisyn en Kopieregbeampte / Dear Legal Practitioner and Copyright Officer,
|
||||
>
|
||||
> We apply, in the planning phase as your Copyright Policy 2022 asks, for permission to quote
|
||||
> the Bybel in Afrikaans 1933/1953-vertaling and the Bybel in Afrikaans 1983-vertaling met
|
||||
> herformulerings tot en met 1992 in daily devotionals in a church app. The use is commercial as
|
||||
> your policy defines it (churches subscribe to the App) and will pass 500 verses a year.
|
||||
>
|
||||
> [The use, in one paragraph.]
|
||||
>
|
||||
> We would show your digital short notice under every passage, the full notice on the App's
|
||||
> Acknowledgements page, and your disclaimer with every devotional (policy §6.2 and §6.4). The
|
||||
> devotionals are also sent by email and WhatsApp to members who ask for them; please tell us
|
||||
> whether that needs your Communications and Marketing department (§5.3). As an app has no
|
||||
> physical copy to courier, please tell us what you would like instead (for example, access to a
|
||||
> demonstration App). We would also like to know any fee, and whether you require a text release.
|
||||
>
|
||||
> Churches in the App can also write their own devotionals; they would apply to you themselves.
|
||||
>
|
||||
> Vriendelike groete / Kind regards,
|
||||
> [name], Cross Code
|
||||
> [email, phone, address]
|
||||
+124
-13
@@ -1,6 +1,6 @@
|
||||
# Handover — Cross Code, all products
|
||||
|
||||
Last updated: 2026-11-30. **The plan is [ROADMAP-v3.md](./ROADMAP-v3.md)** (decided 2026-11-03,
|
||||
Last updated: 2026-12-01. **The plan is [ROADMAP-v3.md](./ROADMAP-v3.md)** (decided 2026-11-03,
|
||||
decisions table near the end). This file says where each phase stands and what comes next.
|
||||
Product-specific notes (where the code lives, known gaps) stay with each product: Cross Events'
|
||||
are in [`apps/events/docs/HANDOVER.md`](../apps/events/docs/HANDOVER.md), and the Hub's are in
|
||||
@@ -16,7 +16,7 @@ every release).
|
||||
|
||||
| Repo | What |
|
||||
|------|------|
|
||||
| `joshua/crosscode-platform` (this one) | Contracts, the apps (Events from 2.2.0; Accounts, Website and App to come), shared packages, the `crosscode` script (`scripts/`), the server agent (`apps/agent`), and these docs |
|
||||
| `joshua/crosscode-platform` (this one) | Contracts, the apps (Events, Accounts, the Website; the App in phase 6), shared packages (`contracts`, `auth-client`, `seo`, `ui`, `demo`), the `crosscode` script (`scripts/`), the server agent (`apps/agent`), and these docs |
|
||||
| `joshua/hope-events` | Cross Events up to 2.1.x. Frozen; archived once every install is adopted (EVENTS-2.2-PLAN §7) |
|
||||
| `joshua/events-hub` | Cross Code Hub. Its own server, its own `scripts/deploy.sh` |
|
||||
| `joshua/crosscode-site` | crosscode.co.za. Updated at the end of every phase that changes what it says (ROADMAP §9) |
|
||||
@@ -25,19 +25,41 @@ every release).
|
||||
|
||||
| Phase | What | State |
|
||||
|-------|------|-------|
|
||||
| 0 | contracts 1.0.0 → 1.17.0 | **Released and in use.** Not published to a registry (decision 22): the Hub gets a packed release committed to its repo (`backend/vendor/`) |
|
||||
| 1 | Hub 2.0 → 2.20.0 | **Released, deployed and tested** (Hub `v2.20.0`) |
|
||||
| 0 | contracts 1.0.0 → 1.21.0 | **Released and in use.** Not published to a registry (decision 22): the Hub gets a packed release committed to its repo (`backend/vendor/`) |
|
||||
| 1 | Hub 2.0 → 2.20.0 | **Released, deployed and tested** (Hub `v2.20.0`; now `v2.26.1`, released 2026-11-30 and running by 2026-12-01 with two years of devotionals; VERSIONS.md) |
|
||||
| 1b | Cross Events 2.2.0: moved here as `apps/events`, the `crosscode` script | **Released, rolled out and tested.** Every install adopted onto the monorepo |
|
||||
| 1c | Cross Events 2.3.x: authenticator app 2FA | **Released and rolled out** (carried into Accounts in phase 4) |
|
||||
| 1d | Agent 1.x + Hub 2.1+ | **Released, rolled out and tested** (agent `1.5.0` on every server: from 1.4.0 the Hub reads and changes frps's / frpc's config and probes ports before an install; from 1.5.0 one product of a church can be uninstalled, exported or purged) |
|
||||
| 2 | Cross Events 2.4.0: protocol v2, Linked products, event feed, `packages/seo` | **Released, rolled out and tested** ([EVENTS-2.4-PLAN.md](./EVENTS-2.4-PLAN.md)) |
|
||||
| 3 | Accounts 1.0.0 | **Released, rolled out and tested** (now `accounts@1.6.0`; [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md)) |
|
||||
| 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (now `events@3.7.0`; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed |
|
||||
| 3 | Accounts 1.0.0 | **Released, rolled out and tested** (`accounts@1.8.0` rolled out; `1.9.0` released 2026-11-30 for phase 6, not deployed; [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md)) |
|
||||
| 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (`events@3.7.2` rolled out; `3.8.0` released 2026-11-30 for phase 6, not deployed; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed |
|
||||
| 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) |
|
||||
| 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26. **Done** (confirmed by Joshua 2026-11-30): crosscode-site deployed, Hope Family Church and a second church live, the remaining release checks finished. Now `website@1.7.1` (VERSIONS.md) |
|
||||
| 6 | Church App 1.0.0 | **Being planned** (2026-11-30): [APP-1.0-PLAN.md](./APP-1.0-PLAN.md), decisions confirmed 2026-11-30 (two left in "Still open"); mockup on the Design canvas "Church App 1.0 mockup" |
|
||||
| 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26. **Done** (confirmed by Joshua 2026-11-30): crosscode-site deployed, Hope Family Church and a second church live, the remaining release checks finished. Now `website@1.8.0` (VERSIONS.md) |
|
||||
| 6 | Church App 1.0.0 | **Under way** (planned and started 2026-11-30): [APP-1.0-PLAN.md](./APP-1.0-PLAN.md), decisions confirmed 2026-11-30 (decision 13, the demo scenarios, added the same day); mockup on the Design canvas "Church App 1.0 mockup". Released 2026-11-30: `contracts@1.20.0` to `1.24.0`, `accounts@1.9.0`, `events@3.8.0`, `website@1.8.0`, `agent@1.7.0` (not deployed), Hub `v2.26.0` and `v2.26.1` (running, with two years of Cross Code's devotionals; below). **`app@1.0.0` being built** from 2026-12-01 on the branch `feat/app-scaffold` (pushed; merged into main only when 1.0.0 is done): the foundation done, the modules next |
|
||||
| 7 | App 1.x | Not started |
|
||||
|
||||
## Released 2026-11-30 (phase 6, first steps)
|
||||
|
||||
Tagged and pushed on 2026-11-30. **The Hub (2.26.1) runs**, with two years of Cross Code's
|
||||
devotionals (Joshua, 2026-12-01); the rest is **not deployed yet** (Accounts and Events have one
|
||||
migration each; the Website and the agent none). Details in
|
||||
[VERSIONS.md](./VERSIONS.md), [CHANGELOG.md](../CHANGELOG.md) and the apps' CHANGELOGs.
|
||||
|
||||
| Release | What |
|
||||
|---------|------|
|
||||
| `contracts@1.20.0` | The App's contracts: `crosscode.devotional/1` and the devotionals CSV checks (shared by the Hub and the App), the Bible books and seven translations with YouVersion ids, `messaging.get` / `messaging.changed`, `whatsapp.optout` and `whatsapp_opted_out`, `APP_MODULES`, the `app` part of the church export |
|
||||
| `contracts@1.21.0` | `agent.DEMO_SCENARIOS`: the eight demo churches, one per Website demo profile; `scenario` in `seed-demo`, `accounts` in `DEMO_PRODUCTS` |
|
||||
| `accounts@1.9.0`, `@crosscode/demo` 1.0.0 | `messaging.get` for the App; the WhatsApp opt-out for every product (STOP kept per number and account, Accounts' own WAWP webhook, "Turn WhatsApp back on"); a scenario's church profile, SVG logo and icon, and people (`crosscode demo <church> accounts --profile <scenario>`) |
|
||||
| `contracts@1.22.0` | Only free Bible translations in 1.0 (KJV and the new BSB: `licence`, `FREE_BIBLE_TRANSLATION_IDS`, the CSV `translations` option); the publishers' exact notices (NLT, ESV and the Afrikaans ones were out of date), the Bible Society's disclaimer, an `acknowledgement` per translation, who to ask, `FREE_QUOTE_VERSES` and `quotedVerses` ([BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)) |
|
||||
| `events@3.8.0`, `@crosscode/demo` 1.1.0 | STOP stops all WhatsApp (not only news), checked before every message and passed on to Accounts; the eight scenarios as Events demo profiles, around each church's own people and campuses |
|
||||
| `contracts@1.23.0`, `agent@1.7.0` | `seed-scenario`: a whole demo scenario in one job, on whatever the church has installed (Accounts first, the rest skipped, every release checked first); `seed-demo` for Accounts and the App, and `--scenario` passed on to every product |
|
||||
| `website@1.8.0` | A profile loaded with `--scenario` takes the scenario's people as its leaders and, with a linked Cross Events, shows Events' events through the feed instead of its own; `crosscode demo <church> website --scenario`; `packages/demo` built with the Website. No migration |
|
||||
| `contracts@1.24.0`, Hub `v2.26.1` | Devotionals up to two years ahead (a CSV of two years in one file); `GET /api/v2/devotionals` answers 2 weeks, today included (what an App fetches each night). No migration |
|
||||
| Hub `v2.26.0` | The App from New install (Accounts 1.9.0 first) and in every product list and filter; **Load a demo scenario** on a demo client (one `seed-scenario` job, "out of step" installs); demo data for every product; the Website's and App's .env; **Devotionals** (3 months ahead, Import CSV, KJV/BSB only) and `GET /api/v2/devotionals` (hub-protocol.md §3c); the App's tier alert. One migration (Hub) |
|
||||
|
||||
All four were checked on PostgreSQL 18 (local, details in `temp/`, never committed): migrations,
|
||||
scenario loads, the opt-out.
|
||||
|
||||
## Released 2026-11-23
|
||||
|
||||
All tagged, pushed and deployed on 2026-11-23. Details in [VERSIONS.md](./VERSIONS.md) and the Hub's
|
||||
@@ -100,11 +122,63 @@ Everything up to and including phase 5 (the Church Website) is released and roll
|
||||
Family Church and a second church are live on the Website, crosscode-site sells it (confirmed by
|
||||
Joshua 2026-11-30; VERSIONS.md, "Deployed / rolled out").
|
||||
|
||||
1. **Phase 6, Church App 1.0.0** (ROADMAP §7, §9). Planned in [APP-1.0-PLAN.md](./APP-1.0-PLAN.md)
|
||||
(2026-11-30, decisions confirmed): contracts 1.20.0 → Accounts 1.9.0 (shared email and
|
||||
WhatsApp for the App, the WhatsApp opt-out for every product) and Events 3.8.0 (STOP passed to
|
||||
Accounts) → Hub 2.26.0 (with Cross Code devotionals) → `app@1.0.0` → cross-demo2 (with a throwaway install from the Hub) → Hope Family
|
||||
Church → crosscode-site 1.10.0 (the App on sale).
|
||||
1. **Phase 6, Church App 1.0.0** (ROADMAP §7, §9), [APP-1.0-PLAN.md](./APP-1.0-PLAN.md) §15.
|
||||
**Done 2026-11-30 (released):** contracts 1.20.0 to 1.24.0, Accounts 1.9.0, Events 3.8.0,
|
||||
Website 1.8.0, agent 1.7.0 (not deployed), Hub 2.26.0 and 2.26.1 (running, with two years of
|
||||
devotionals). The Bible publishers' terms checked: none covers a sold app, so **1.0 uses only the
|
||||
free translations, the KJV and the Berean Standard Bible** (APP-1.0-PLAN decision 14); the
|
||||
permission requests for the others are drafted in [BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)
|
||||
for later, and nothing waits for them. **Next:**
|
||||
1. ~~**Website 1.8.0**~~: **released 2026-11-30** (not deployed). A profile loaded with
|
||||
`--scenario` takes the scenario's people as leaders (`scenarioTeam` in `src/demo/seeds.ts`)
|
||||
and, with a linked Cross Events, shows Events' events through the feed; `crosscode demo
|
||||
<church> website --scenario`; the Website builds `packages/demo`.
|
||||
2. ~~**Agent 1.7.0**~~ and **contracts 1.23.0**: **released 2026-11-30** (not rolled out).
|
||||
`seed-demo` for `app` and `accounts`, `--scenario` passed on; the new `seed-scenario` job
|
||||
(`crosscode demo <church> --scenario <s>`) loads the scenario on every product the church
|
||||
has installed, skipping the rest, every release checked first; `crosscode demo <church> app` refused clearly until
|
||||
App 1.0.0 brings `scripts/products/app.sh` and the App's demo.
|
||||
3. ~~**Hub 2.26.0**~~ and ~~**2.26.1**~~ (with contracts 1.24.0): **released 2026-11-30, and
|
||||
the Hub runs 2.26.1 with two years of Cross Code's devotionals** (Joshua, 2026-12-01). Was:
|
||||
the App in New install and releases, billing on the active-member band, **Load a demo
|
||||
scenario** on a demo client (one `seed-scenario` job, agent 1.7.0+: the server seeds
|
||||
whatever the client has installed, Accounts first; show the report's `loaded` /
|
||||
`skipped`), the **Devotionals** page (up to two years ahead from 2.26.1, Import CSV, the free
|
||||
translations only: KJV and BSB) and `GET /api/v2/devotionals`: an App gets **2 weeks, today
|
||||
included** (today and the 13 days after it) per fetch, once a night. Keep the Hub filled
|
||||
well ahead: a day missing there is missing in every App.
|
||||
4. **`app@1.0.0`: being built** (from 2026-12-01, `apps/app`) on the branch
|
||||
**`feat/app-scaffold`** (pushed to c-git), in slices, each with its tests. The branch is
|
||||
**not merged into main until `app@1.0.0` is done** (Joshua, 2026-12-01): build every slice
|
||||
there, merge main into it when docs or shared packages change on main, and leave main's
|
||||
`apps/app` the placeholder until then. Docs about the App's progress go to main as well.
|
||||
1. ~~**The foundation**~~ (done 2026-12-01, not released; `apps/app/CHANGELOG.md`,
|
||||
"Unreleased"): backend and frontend as the Website's; the Hub client (`CCP-`, product
|
||||
`app`, the active-member band in the heartbeat); links and sign-in through Accounts
|
||||
(everyone a Member; 8 days renewed up to 90; every role only with 2FA; the first Owner
|
||||
from `HUB_ADMIN_EMAIL`); modules on and off; the manifest, icons, service worker, "Add to
|
||||
home screen", the tab bar and Me; the admin's first dashboard. One migration (`init`,
|
||||
checked on PostgreSQL 18: applies, no diff). 27 backend tests.
|
||||
2. **House of Prayer** (§3): slots in the church's timezone, commitments as rules, the
|
||||
24-hour clock, live coverage (SSE), reminders, renewals, "I prayed", campaigns,
|
||||
testimonies, the access log.
|
||||
3. **Prayer requests** (§4), with moderation and escalation.
|
||||
4. **Announcements, devotionals and events** (§5–§7): Cross Code's devotionals fetched each
|
||||
night from the Hub (`from` = today in the church's timezone; the App replaces its copy of
|
||||
those 14 days and keeps the rest), the church's own with the CSV import, the event feed.
|
||||
5. **Email and WhatsApp** (§8): the church's settings from Accounts (`messaging.get`), the
|
||||
STOP check before every WhatsApp, the sends and their counts.
|
||||
6. **The rest of the admin** (§10): side menu, setup checklist, members and roles, settings,
|
||||
background jobs, audit and access logs; the export (§11) and backups.
|
||||
7. **Demo and servers**: the Acacia Hill demo and the eight scenarios (`cmd_demo_scenario`),
|
||||
`scripts/products/app.sh` and `app.env.template.json` (with the Hub's: the env template
|
||||
in three places).
|
||||
8. **e2e, axe and Lighthouse** (§14), then the tag.
|
||||
|
||||
Then cross-demo2 (every scenario loaded, the throwaway install from the Hub) → Hope Family
|
||||
Church → crosscode-site 1.10.0 (the App on sale).
|
||||
Deploying Accounts 1.9.0, Events 3.8.0 and Website 1.8.0 to the churches can happen any time before the App;
|
||||
a church without Cross Events gives WAWP the address in Accounts → Admin → Email and WhatsApp.
|
||||
Done (confirmed by Joshua 2026-11-25): `hope-events` is archived, and every FastPanel site set up
|
||||
before Hub 2.10.0, and the Hub's own site, has `location ^~ /api/`.
|
||||
|
||||
@@ -148,6 +222,38 @@ rollout.
|
||||
- **Demo data:** Hub → the install's page → Mark as a demo site → Load demo data (Hub 2.4.0, agent
|
||||
1.2.0; `crosscode demo <church> --profile …` on the server). By hand, run `npm run demo:*` as the
|
||||
site's user (`sudo -u cc-<church> …`): only that user can read the `.env`.
|
||||
- **Demo scenarios** (APP-1.0-PLAN §12, from 2026-11-30): eight preset churches, the list in
|
||||
contracts `agent.DEMO_SCENARIOS`, each church's profile, people and logo in `packages/demo`
|
||||
(`@crosscode/demo`, built by every product that uses it). **Accounts loads first**
|
||||
(`crosscode demo <church> accounts --profile <scenario>`: profile, logo, people), then Events,
|
||||
the Website and the App with the same profile name. People keep the same account id everywhere
|
||||
and on every load (`demoId`); everything is at example.com with no phone numbers. A new demo
|
||||
feature that should look the same in every product goes in `packages/demo`, not in one app.
|
||||
**A whole scenario is one job** (contracts 1.23.0 `seed-scenario`, agent 1.7.0):
|
||||
`crosscode demo <church> --scenario <s>` loads it on **whatever the church has installed**,
|
||||
Accounts first, and skips the rest (a client with only Accounts and the Website gets both).
|
||||
Every product must also work without the others (the Website without Accounts uses the
|
||||
scenario's own profile, without Events its own events); the App 1.0.0 must do the same, and
|
||||
add its branch to `cmd_demo_scenario` in `scripts/lib/manage.sh`.
|
||||
- **WhatsApp STOP** (APP-1.0-PLAN decision 11, from Accounts 1.9.0 / Events 3.8.0): STOP means no
|
||||
WhatsApp from any product, of any kind. Accounts keeps it (`whatsapp_opted_out` in
|
||||
`user.updated`); every product checks it before sending (Events: `utils/whatsappStop.js`), and
|
||||
whichever product receives a STOP passes it on with `whatsapp.optout`. The App and the Website
|
||||
must do the same.
|
||||
- **Cross Code's devotionals** (Hub 2.26.1, contracts 1.24.0): the Hub schedules them up to two
|
||||
years ahead (`CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS`; two years are in it, Joshua 2026-12-01),
|
||||
an App fetches 2 weeks each night, today included (`CROSSCODE_DEVOTIONALS_FETCH_DAYS`, 14 days:
|
||||
today and the 13 after it; Joshua 2026-11-30: 2 weeks at most), so a day not filled 2 weeks
|
||||
ahead is missing in every App until it is. A CSV holds up to 800 rows (8 MB).
|
||||
- **The Church App's foundation** (from 2026-12-01, `apps/app` on `feat/app-scaffold`): ports 5400 (backend) and 3400
|
||||
(frontend) in development; `APP_SECRET`, `APP_URL`, `APP_API_URL` in its env template (the
|
||||
Hub reads `apps/app/env.template.json` at the tag); its session cookie is `cca_session`. A
|
||||
module's tables, jobs, export records and memoryDb defaults are added with the module. Every
|
||||
page that shows prayer is `noindex` (next.config.ts and robots.ts list `/prayer`).
|
||||
- **Bible text** (BIBLE-PERMISSIONS.md, from contracts 1.22.0): the Hub and the App offer only
|
||||
`FREE_BIBLE_TRANSLATION_IDS` (KJV, BSB). Any other needs its publisher's written permission
|
||||
first, then brings its exact `copyright` line (and the Bible Society's `disclaimer` for
|
||||
AFR53/AFR83), copied from the publisher, never reworded. **No AI on Bible text**, ever: Crossway and Biblica forbid it.
|
||||
- **A new Events install never takes over an existing database**: moving an existing site is
|
||||
`adopt`, not a New install pointed at the old database.
|
||||
- **Prisma in the monorepo:** each app other than Events sets its own generator `output`, so
|
||||
@@ -168,6 +274,11 @@ rollout.
|
||||
address there doesn't change the Hub's domain for the install or FastPanel.
|
||||
- **Demo data keeps the links** to the church's other products (`KEEP_TABLES` in
|
||||
`apps/events/backend/scripts/set-demo.js`). Anything that must survive a demo load goes there.
|
||||
- **A local PostgreSQL** is on the dev machine (`temp/database details.txt`, git-ignored; the user is
|
||||
`postgres`, the file says `postges`). Use a throwaway database per check (`cc_<app>_<version>_check`),
|
||||
run `prisma migrate deploy` and `prisma migrate diff --from-config-datasource --to-schema …`, and drop
|
||||
it afterwards. Never print the password. Events' database has an older drift on
|
||||
`_EventNotifyRecipients` (an index Prisma now wants as a primary key), not from 3.8.0.
|
||||
- **Releasing:** branch → merge → tag (`<product>@<version>` here, `v<version>` in events-hub and
|
||||
crosscode-site) → push, with a CHANGELOG entry, and `npm run check` first. Pushes to c-git often
|
||||
fail authentication the first time; retry once. A push can also hang waiting on a login prompt
|
||||
|
||||
+2
-2
@@ -641,8 +641,8 @@ Planned in [AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md). In short:
|
||||
| 2 | **Cross Events 2.4.0** | Reports `product: "events"` (protocol v2), **Linked products**, the event feed (publish + show events from siblings), `packages/seo` (§11) with canonical links for imported events. **Planned and built 2026-11-18:** [EVENTS-2.4-PLAN.md](./EVENTS-2.4-PLAN.md) (also needs contracts 1.4.0 and Hub 2.2.0, for a public key in the v2 heartbeat); not tagged yet | Small; ready for when the Website exists |
|
||||
| 3 | **Accounts 1.0.0** | OIDC provider, sign-in, 2FA (email, WhatsApp, authenticator app), password reset, consent and notice, export / delete fan-out, admin, install script. [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md) (with contracts 1.5.0, `packages/auth-client`, Hub 2.3.0). **Released 2026-11-18** (`accounts@1.0.0`, 1.0.1 on 2026-11-19); the VM test and a run on real Postgres are still to do before a church gets it | Every later product signs in through it |
|
||||
| 4 | **Cross Events 3.0.0** | Sign-in moves to Accounts; user migration keeping password hashes; migration guide. **Planned 2026-11-19:** [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md) (with contracts 1.8.0, Accounts 1.1.0, Hub 2.5.0; decisions confirmed 2026-11-19) | Breaking change, so a major version. **Moved before the Website on 2026-11-19** (decision 38): Events is the product churches use today, so Accounts is proven on real users first, and the Website then starts with a church whose people already have accounts |
|
||||
| 5 | **Church Website 1.0.0** | Public site with the **four templates** (§6), admin, simple events + feed, SEO (§11), Hope Family Church as the first church, then a second test church on a different template to prove it repeats. **Planned 2026-11-21:** [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) (with contracts 1.17.0, Accounts 1.7.0, Events 3.7.0 for the shared fonts and footer, Hub 2.21.0) | More churches need a website than an app; it also covers the "website only" case. Built on Accounts from day one |
|
||||
| 6 | **Church App 1.0.0** | Foundation (PWA, branding, Accounts), House of Prayer, announcements, devotionals, events (simple + feed) | Starts with shared users and the feed already in place |
|
||||
| 5 | **Church Website 1.0.0** | Public site with the **four templates** (§6), admin, simple events + feed, SEO (§11), Hope Family Church as the first church, then a second test church on a different template to prove it repeats. **Planned 2026-11-21:** [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) (with contracts 1.17.0, Accounts 1.7.0, Events 3.7.0 for the shared fonts and footer, Hub 2.21.0). **Released 2026-11-26, done 2026-11-30** (Hope Family Church and a second church live, crosscode-site sells it) | More churches need a website than an app; it also covers the "website only" case. Built on Accounts from day one |
|
||||
| 6 | **Church App 1.0.0** | Foundation (PWA, branding, Accounts), House of Prayer, announcements, devotionals, events (simple + feed). **Planned 2026-11-30:** [APP-1.0-PLAN.md](./APP-1.0-PLAN.md) (with contracts 1.20.0 and 1.21.0, Accounts 1.9.0, Events 3.8.0, Website 1.8.0, agent 1.7.0, Hub 2.26.0; also **demo scenarios**: eight preset churches loaded into every product of a demo client). contracts 1.20.0 to 1.24.0, Accounts 1.9.0, Events 3.8.0, Website 1.8.0, agent 1.7.0 and Hub 2.26.0 / 2.26.1 **released 2026-11-30**; the Hub runs 2.26.1 with two years of devotionals; **App 1.0.0 being built** from 2026-12-01 on the branch `feat/app-scaffold` (the foundation done) | Starts with shared users and the feed already in place |
|
||||
| 7 | Church App 1.x | Reading plans, sermons, groups, pastoral care, serving, giving links, directory | After House of Prayer is in use |
|
||||
|
||||
Each phase adds help content, audit log entries, tests, a CHANGELOG entry and updates to the
|
||||
|
||||
+63
-13
@@ -1,6 +1,6 @@
|
||||
# Versions — the latest release of everything
|
||||
|
||||
Last updated: 2026-11-30. Taken from the git tags, which is what a release is here (branch → merge →
|
||||
Last updated: 2026-12-01. Taken from the git tags, which is what a release is here (branch → merge →
|
||||
tag → push, see [HANDOVER.md](./HANDOVER.md) "Releasing"). **Update this file with every release.**
|
||||
|
||||
"Released" means tagged and pushed. Whether a release is **deployed** or rolled out is recorded
|
||||
@@ -10,14 +10,14 @@ separately below; the two often differ.
|
||||
|
||||
| What | Repo | Latest | Tag | Released |
|
||||
|------|------|--------|-----|----------|
|
||||
| Cross Events | `crosscode-platform` (`apps/events`) | **3.8.0** | `events@3.8.0` | 2026-11-30 |
|
||||
| Church Website | `crosscode-platform` (`apps/website`) | **1.7.1** | `website@1.7.1` | 2026-11-28 |
|
||||
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.9.0** | `accounts@1.9.0` | 2026-11-30 |
|
||||
| Server agent | `crosscode-platform` (`apps/agent`) | **1.6.0** | `agent@1.6.0` | 2026-11-27 |
|
||||
| Contracts | `crosscode-platform` (`packages/contracts`) | **1.21.0** | `contracts@1.21.0` | 2026-11-30 |
|
||||
| Cross Code Hub | `events-hub` | **2.25.1** | `v2.25.1` | 2026-11-27 |
|
||||
| Cross Events | `crosscode-platform` (`apps/events`) | **3.9.0** | `events@3.9.0` | 2026-12-01 |
|
||||
| Church Website | `crosscode-platform` (`apps/website`) | **1.9.0** | `website@1.9.0` | 2026-12-01 |
|
||||
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.10.0** | `accounts@1.10.0` | 2026-12-01 |
|
||||
| Server agent | `crosscode-platform` (`apps/agent`) | **1.7.0** | `agent@1.7.0` | 2026-11-30 |
|
||||
| Contracts | `crosscode-platform` (`packages/contracts`) | **1.24.0** | `contracts@1.24.0` | 2026-11-30 |
|
||||
| Cross Code Hub | `events-hub` | **2.26.1** | `v2.26.1` | 2026-11-30 |
|
||||
| crosscode.co.za | `crosscode-site` | **1.9.1** | `v1.9.1` | 2026-11-27 |
|
||||
| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-30 (last change: Events takes the demo scenarios as profiles, `crosscode demo <church> accounts`, `--scenario` on every demo, Accounts and Events build `packages/demo`) |
|
||||
| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-30 (last change: `crosscode demo <church> --scenario <s>` loads a whole scenario on whatever is installed; `crosscode demo <church> app` refused clearly until App 1.0.0; `--scenario` passed on to the Website's demo, the Website builds `packages/demo`; before that Events takes the demo scenarios as profiles, `crosscode demo <church> accounts`, Accounts and Events build `packages/demo`) |
|
||||
|
||||
The `crosscode` script has no version: every server's copy (`/opt/crosscode/tools`) pulls `main`
|
||||
on each run, so merging to `main` and pushing releases it. Its changes are listed in
|
||||
@@ -28,17 +28,67 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste
|
||||
| What | Where | Version in package.json |
|
||||
|------|-------|-------------------------|
|
||||
| `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) |
|
||||
| `@crosscode/demo` | `packages/demo` | 1.1.0 (the demo scenarios' churches, people and logos; ships with Accounts 1.9.0 and Events 3.8.0) |
|
||||
| `@crosscode/demo` | `packages/demo` | 1.1.0 (the demo scenarios' churches, people and logos; ships with Accounts 1.9.0, Events 3.8.0 and Website 1.8.0) |
|
||||
| `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) |
|
||||
| `@crosscode/ui` | `packages/ui` | 0.3.0 (fonts, `ChurchFooter`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0) |
|
||||
| Website | `apps/website` | 1.7.1 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.7.0 on 2026-11-27, 1.7.1 on 2026-11-28; installed for the demo church cross-demo2 (1.7.1) only, Hope Family Church next) |
|
||||
| App | `apps/app` | 0.0.0 (not started, phase 6) |
|
||||
| `@crosscode/ui` | `packages/ui` | 0.4.0 (fonts, `ChurchFooter`, `ColourField`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0, 0.4.0 with Accounts 1.10.0 and Website 1.9.0) |
|
||||
| Website | `apps/website` | 1.9.0 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.7.0 on 2026-11-27, 1.7.1 on 2026-11-28, 1.8.0 on 2026-11-30, 1.9.0 on 2026-12-01; tagged as `website@…`; see "Deployed / rolled out" for where it runs) |
|
||||
| App | `apps/app` | 0.0.0 on main (a placeholder); 0.1.0 on the branch `feat/app-scaffold`, being built from 2026-12-01 (phase 6; not released, merged and tagged `app@1.0.0` when the plan is built) |
|
||||
|
||||
These shared packages ship inside the apps that use them, from the same checkout, so they don't
|
||||
need their own tags until something outside this repo depends on them.
|
||||
|
||||
## What each latest release was for
|
||||
|
||||
- **Events 3.9.0 + Website 1.9.0 + Accounts 1.10.0 + `@crosscode/ui` 0.4.0 (2026-12-01):** Events
|
||||
takes the church's name, logo, icon, colours and contact details from the Accounts profile
|
||||
(pages, emails, WhatsApp, PDFs; Settings shows them read-only), so a change in Accounts or a
|
||||
demo scenario load shows on Events as on the Website; the Accounts logo is copied for PDFs, and SVG
|
||||
logos are drawn in them (`svg-to-pdfkit`). The Website gets a background per homepage section in the church's colours, and
|
||||
"More info" instead of "Register" for events without registration. Accounts' Church profile and
|
||||
the Website's Church details use one colour field (`ColourField`, like Events' picker). No
|
||||
migrations, no contracts change, works with any Accounts. Checked: Events backend tests (828),
|
||||
Website backend tests (149), typecheck and lint of every changed app. Not deployed.
|
||||
|
||||
- **Hub 2.26.1 + contracts 1.24.0 (2026-11-30):** Cross Code's devotionals can be scheduled up to
|
||||
**two years ahead** (was 3 months; `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS`), and a CSV holds two
|
||||
years in one file (800 rows, 8 MB). `GET /api/v2/devotionals` answers **2 weeks, today included**
|
||||
(`CROSSCODE_DEVOTIONALS_FETCH_DAYS`), not 3 months: what an App fetches each night. No
|
||||
migration. Checked: contracts' tests (341), the Hub's backend tests (301), frontend typecheck and
|
||||
lint. Deployed by 2026-12-01, with two years of Cross Code's devotionals imported (Joshua).
|
||||
- **Hub 2.26.0 (2026-11-30):** the Church App (APP-1.0-PLAN §6, §12). The App from New install on
|
||||
`app.<address>`, with Accounts 1.9.0 first (also without "requires" in its notes), and in every
|
||||
product list and filter (installs, Updates). **Load a demo scenario** on a demo client: one
|
||||
`seed-scenario` job (agent 1.7.0+), the installs it replaces and what stops it, the scenario
|
||||
last loaded, installs "out of step". Demo data for every product (the App's and Accounts' on
|
||||
their own; Events' eight scenario churches need 3.8.0). The Website's and App's .env from the
|
||||
Hub. **Devotionals**: written or imported from CSV up to 3 months ahead in the KJV or BSB, and
|
||||
`GET /api/v2/devotionals` for App licences (hub-protocol.md §3c). An alert when an App's
|
||||
active-member band is above its tier. Contracts 1.23.0 vendored. One migration
|
||||
(`20261130120000_app_scenarios_devotionals`, checked on PostgreSQL 18: applies, no diff).
|
||||
Checked: the backend tests (301), frontend typecheck, lint and build. Deployed (2.26.1 runs).
|
||||
- **Server agent 1.7.0 + contracts 1.23.0 + crosscode script (2026-11-30):** demo scenarios
|
||||
(APP-1.0-PLAN §12): the `seed-scenario` job, one per scenario load, which the server runs on
|
||||
**whatever the client has installed** (Accounts first, the rest skipped, every release checked
|
||||
first, the first failure naming what's out of step); `seed-demo` for Accounts and the App, and
|
||||
`--scenario` passed on to every product. For the Hub 2.26.0's **Load a demo scenario** (it
|
||||
vendors contracts 1.23.0). Checked: contracts (340), the agent's tests (60, the two version
|
||||
numbers match), the script's demo bats (21), `npm run check`. Not rolled out yet (Update
|
||||
agent from the Hub).
|
||||
- **Church Website 1.8.0 + crosscode script (2026-11-30):** demo scenarios (APP-1.0-PLAN §12): a
|
||||
profile loaded with `--scenario` takes the scenario's people as its leaders (the pastor first,
|
||||
each with a portrait chosen for them) and, with a linked Cross Events, shows Events' events
|
||||
through the feed instead of making its own. `crosscode demo <church> website --scenario`; the
|
||||
Website builds `packages/demo`. **No migration.** Checked: the Website's backend tests (147), the
|
||||
script's bats (demo and website), `npm run check`, and on PostgreSQL 18 scenario and profile loads
|
||||
(with an unreachable Events link too: the load succeeds and says the feed will catch up). Not
|
||||
deployed yet.
|
||||
- **Contracts 1.22.0 (2026-11-30):** only free Bible translations in App 1.0 (KJV and the new
|
||||
Berean Standard Bible, `licence`, `FREE_BIBLE_TRANSLATION_IDS`, the CSV import's `translations`);
|
||||
the Bible publishers' exact notices for the Church App's
|
||||
devotionals (NLT, ESV, AFR53 and AFR83 corrected; `AFR83` named "Afrikaans 1983/1992-vertaling"),
|
||||
the Bible Society's disclaimer, an `acknowledgement`, `publisher` and `permissionsUrl` per
|
||||
translation, `FREE_QUOTE_VERSES` and `quotedVerses` ([BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)).
|
||||
Nothing uses them yet: the Hub 2.26.0 and the App 1.0.0 will. Checked: `npm run check`.
|
||||
- **Cross Events 3.8.0 + `@crosscode/demo` 1.1.0 + crosscode script (2026-11-30):** STOP to the
|
||||
church's WhatsApp number stops all WhatsApp from Events (event updates, tickets and codes too;
|
||||
codes by email), checked before every message, passed on to Accounts and read back from it
|
||||
@@ -412,7 +462,7 @@ you deploy one.
|
||||
|
||||
| What | Running | Since | Notes |
|
||||
|------|---------|-------|-------|
|
||||
| Hub | 2.25.1 | 2026-11-28 | Jobs → Product filter lists every product |
|
||||
| Hub | 2.26.1 | by 2026-12-01 | The App, demo scenarios, Devotionals (two years of Cross Code's imported; Apps get 2 weeks, today included) |
|
||||
| Agent on church-server1 | 1.6.0 | 2026-11-27 | |
|
||||
| Agent on the central server | 1.6.0 | 2026-11-27 | |
|
||||
| Cross Events (churches) | 3.7.2 | 2026-11-27 | |
|
||||
|
||||
@@ -259,6 +259,25 @@ X-Hub-Install / X-Hub-Timestamp / X-Hub-Signature (as in §3)
|
||||
- Rate-limited to 60 a minute per IP (against runaway loops; money is limited by the cap).
|
||||
- A Hub older than 1.6.0 answers `404 NOT_FOUND`: the install treats that as "AI off".
|
||||
|
||||
## 3c. Devotionals (Church App, Hub 2.26.0)
|
||||
|
||||
`GET /api/v2/devotionals?from=YYYY-MM-DD` (contracts `hub.DEVOTIONALS_PATH`), with
|
||||
`Authorization: Bearer <the install's licence token>` (§4); no signature. An App set to "From
|
||||
Cross Code" calls it once a night (and on "Sync now") and keeps what it gets, so a Hub outage
|
||||
of less than 2 weeks changes nothing.
|
||||
|
||||
- `from` defaults to today (South Africa); the answer covers `from` and the 13 days after it
|
||||
(2 weeks, contracts `CROSSCODE_DEVOTIONALS_FETCH_DAYS`; Hub 2.26.0 answered 3 months), one
|
||||
devotional per day at most, oldest first (`devotionalsReplySchema`, `crosscode.devotional/1`,
|
||||
each with `source: "crosscode"`). The App replaces its copy of that range: a day missing from
|
||||
the list was removed in the Hub.
|
||||
- Only the free translations are ever in it (KJV, BSB: contracts `FREE_BIBLE_TRANSLATION_IDS`);
|
||||
the App shows each passage's `copyright` line under it.
|
||||
- `401 BAD_LICENCE`: no token, a forged one, or an unknown licence. `403 NOT_AN_APP`: another
|
||||
product's licence. `403 LICENCE_INACTIVE`: suspended, revoked, or past its grace days.
|
||||
`400 INVALID_REQUEST`: `from` isn't a date. Rate-limited to 20 a minute per IP.
|
||||
- A Hub older than 2.26.0 answers `404 NOT_FOUND`: the App keeps what it has.
|
||||
|
||||
## 4. Licence token
|
||||
|
||||
`hel1.<payload>.<signature>` — `payload` is base64url JSON, `signature` is the base64url
|
||||
|
||||
Generated
+20
-9
@@ -51,7 +51,7 @@
|
||||
},
|
||||
"apps/accounts/backend": {
|
||||
"name": "@crosscode/accounts-backend",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
@@ -89,7 +89,7 @@
|
||||
},
|
||||
"apps/accounts/frontend": {
|
||||
"name": "@crosscode/accounts-frontend",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.0",
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
"@crosscode/ui": "*",
|
||||
@@ -115,7 +115,7 @@
|
||||
},
|
||||
"apps/agent": {
|
||||
"name": "@crosscode/agent",
|
||||
"version": "1.6.0",
|
||||
"version": "1.7.0",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
@@ -134,7 +134,7 @@
|
||||
},
|
||||
"apps/events/backend": {
|
||||
"name": "@crosscode/events-backend",
|
||||
"version": "3.8.0",
|
||||
"version": "3.9.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@cj-tech-master/excelts": "^10.2.0",
|
||||
@@ -160,6 +160,7 @@
|
||||
"pg-boss": "^11.1.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"raw-body": "^3.0.0",
|
||||
"svg-to-pdfkit": "0.1.8",
|
||||
"swagger-ui-dist": "^5.34.0",
|
||||
"tsx": "^4.23.15",
|
||||
"typescript": "^5.9.3",
|
||||
@@ -185,7 +186,7 @@
|
||||
},
|
||||
"apps/events/frontend": {
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "3.8.0",
|
||||
"version": "3.9.0",
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
"@crosscode/seo": "*",
|
||||
@@ -362,11 +363,12 @@
|
||||
},
|
||||
"apps/website/backend": {
|
||||
"name": "@crosscode/website-backend",
|
||||
"version": "1.7.1",
|
||||
"version": "1.9.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@crosscode/auth-client": "*",
|
||||
"@crosscode/contracts": "*",
|
||||
"@crosscode/demo": "*",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"cron-parser": "^5.10.2",
|
||||
@@ -391,7 +393,7 @@
|
||||
},
|
||||
"apps/website/frontend": {
|
||||
"name": "@crosscode/website-frontend",
|
||||
"version": "1.7.1",
|
||||
"version": "1.9.0",
|
||||
"dependencies": {
|
||||
"@crosscode/contracts": "*",
|
||||
"@crosscode/seo": "*",
|
||||
@@ -21284,6 +21286,15 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/svg-to-pdfkit": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/svg-to-pdfkit/-/svg-to-pdfkit-0.1.8.tgz",
|
||||
"integrity": "sha512-QItiGZBy5TstGy+q8mjQTMGRlDDOARXLxH+sgVm1n/LYeo0zFcQlcCh8m4zi8QxctrxB9Kue/lStc/RD5iLadQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pdfkit": ">=0.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/swagger-ui-dist": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.34.0.tgz",
|
||||
@@ -23191,7 +23202,7 @@
|
||||
},
|
||||
"packages/contracts": {
|
||||
"name": "@crosscode/contracts",
|
||||
"version": "1.21.0",
|
||||
"version": "1.24.0",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"zod": "^4.6.7"
|
||||
@@ -23243,7 +23254,7 @@
|
||||
},
|
||||
"packages/ui": {
|
||||
"name": "@crosscode/ui",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/dm-sans": "5.3.0",
|
||||
"@fontsource-variable/eb-garamond": "5.3.0",
|
||||
|
||||
@@ -16,8 +16,8 @@ Events and the Hub, uses it, so the key fields are the same in every product's J
|
||||
| Hub protocol v2 | `protocolVersion: 2` | Register, heartbeat (stats per product), linked products, update requests, AI, licence token | `src/hub.ts` (exported as `hub`) |
|
||||
| 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`) |
|
||||
| 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`. From 1.22.0: the Berean Standard Bible, `licence` and `FREE_BIBLE_TRANSLATION_IDS` (only those in App 1.0), each publisher's exact notices (`copyright` under the verse, `acknowledgement`, the Bible Society's `disclaimer`), who to ask (`publisher`, `permissionsUrl`), `FREE_QUOTE_VERSES` and `quotedVerses` (docs/BIBLE-PERMISSIONS.md) | `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`. From 1.23.0: the `seed-scenario` job, a whole scenario in one job on whatever the church has installed (`SEED_SCENARIO_JOB_MIN_AGENT`) | `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.21.0",
|
||||
"version": "1.24.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",
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
"passage": {
|
||||
"reference": "1 Corinthians 13:4–7",
|
||||
"location": { "book": "1CO", "chapter": 13, "verse": 4, "endChapter": 13, "endVerse": 7 },
|
||||
"translation": "NLT",
|
||||
"text": "Love is patient and kind. Love is not jealous or boastful or proud or rude. It does not demand its own way. It is not irritable, and it keeps no record of being wronged. It does not rejoice about injustice but rejoices whenever the truth wins out. Love never gives up, never loses faith, is always hopeful, and endures through every circumstance."
|
||||
"translation": "BSB",
|
||||
"text": "Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It is not rude, it is not self-seeking, it is not easily angered, it keeps no account of wrongs. Love takes no pleasure in evil, but rejoices in the truth. It bears all things, believes all things, hopes all things, endures all things."
|
||||
},
|
||||
"body": "Paul wrote these words to a church that was proud of its gifts.\n\nLove is the gift that makes the others worth having.",
|
||||
"prayer": "Lord, teach me to love the way you love me.",
|
||||
@@ -25,14 +25,14 @@
|
||||
"id": "4c5d6e7f-8a9b-4c0d-9e1f-3a4b5c6d7e8f",
|
||||
"source": "crosscode",
|
||||
"date": "2027-01-06",
|
||||
"title": "Die Here is my herder",
|
||||
"title": "The Lord is my shepherd",
|
||||
"passage": {
|
||||
"reference": "Psalms 23:1–3",
|
||||
"location": { "book": "PSA", "chapter": 23, "verse": 1, "endChapter": 23, "endVerse": 3 },
|
||||
"translation": "AFR83",
|
||||
"text": "Die Here is my herder, ek kom niks kort nie. Hy laat my rus in groen weivelde. Hy bring my by waters waar daar vrede is. Hy gee my nuwe krag. Hy lei my op die regte paaie tot eer van sy Naam."
|
||||
"translation": "KJV",
|
||||
"text": "The LORD is my shepherd; I shall not want. He maketh me to lie down in green pastures: he leadeth me beside the still waters. He restoreth my soul: he leadeth me in the paths of righteousness for his name's sake."
|
||||
},
|
||||
"body": "Vandag herinner Dawid ons dat ons nie alleen loop nie.",
|
||||
"body": "Today David reminds us that we never walk alone.",
|
||||
"prayer": null,
|
||||
"author": null,
|
||||
"updatedAt": "2026-12-01T10:00:00.000Z"
|
||||
|
||||
@@ -914,6 +914,121 @@
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"const": "crosscode.agent-job/1"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^job_[A-Za-z0-9_-]{8,64}$"
|
||||
},
|
||||
"serverId": {
|
||||
"type": "string",
|
||||
"pattern": "^srv_[A-Za-z0-9_-]{8,64}$"
|
||||
},
|
||||
"config": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alg": {
|
||||
"type": "string",
|
||||
"const": "x25519-hkdf-sha256-aes-256-gcm"
|
||||
},
|
||||
"epk": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{43}$"
|
||||
},
|
||||
"iv": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{16}$"
|
||||
},
|
||||
"ciphertext": {
|
||||
"type": "string",
|
||||
"maxLength": 200000,
|
||||
"pattern": "^[A-Za-z0-9_-]+$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"alg",
|
||||
"epk",
|
||||
"iv",
|
||||
"ciphertext"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"notBefore": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
||||
},
|
||||
"signature": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{86}$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"const": "seed-scenario"
|
||||
},
|
||||
"args": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"church": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z][a-z0-9-]{1,30}$"
|
||||
},
|
||||
"scenario": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"heritage-parish",
|
||||
"heritage-city",
|
||||
"bold-youth",
|
||||
"bold-plant",
|
||||
"community-family",
|
||||
"community-town",
|
||||
"clean-modern",
|
||||
"clean-campus"
|
||||
]
|
||||
},
|
||||
"adminEmail": {
|
||||
"type": "string",
|
||||
"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,}$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"church",
|
||||
"scenario"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schema",
|
||||
"id",
|
||||
"serverId",
|
||||
"notBefore",
|
||||
"expiresAt",
|
||||
"signature",
|
||||
"type",
|
||||
"args"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"adopt-undo",
|
||||
"restart",
|
||||
"seed-demo",
|
||||
"seed-scenario",
|
||||
"env-read",
|
||||
"env-set",
|
||||
"export",
|
||||
|
||||
@@ -1965,7 +1965,8 @@
|
||||
"NKJV",
|
||||
"KJV",
|
||||
"AFR53",
|
||||
"AFR83"
|
||||
"AFR83",
|
||||
"BSB"
|
||||
]
|
||||
},
|
||||
"text": {
|
||||
|
||||
@@ -133,7 +133,8 @@
|
||||
"NKJV",
|
||||
"KJV",
|
||||
"AFR53",
|
||||
"AFR83"
|
||||
"AFR83",
|
||||
"BSB"
|
||||
]
|
||||
},
|
||||
"text": {
|
||||
|
||||
@@ -153,7 +153,8 @@
|
||||
"NKJV",
|
||||
"KJV",
|
||||
"AFR53",
|
||||
"AFR83"
|
||||
"AFR83",
|
||||
"BSB"
|
||||
]
|
||||
},
|
||||
"text": {
|
||||
|
||||
@@ -169,7 +169,7 @@ export const DEMO_SCENARIOS: readonly DemoScenario[] = [
|
||||
}),
|
||||
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.",
|
||||
description: "Mostly Afrikaans. A bazaar and a prayer breakfast, its own Afrikaans devotionals, 30-minute prayer slots.",
|
||||
campuses: 1, language: "af", appActiveMembers: "101–300",
|
||||
}),
|
||||
scenario("clean-modern", {
|
||||
@@ -203,6 +203,9 @@ 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";
|
||||
|
||||
/** 1.23.0: the first agent that runs `seed-scenario` jobs (a whole scenario on whatever the church has installed). */
|
||||
export const SEED_SCENARIO_JOB_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,
|
||||
@@ -305,6 +308,17 @@ export const jobArgsSchemas = {
|
||||
ctx.addIssue({ code: "custom", path: ["profile"], message: `the ${a.scenario} scenario loads ${demoScenario(a.scenario).profiles[product]} in ${DEMO_PRODUCT_NAMES[product]}` });
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* 1.23.0: `crosscode demo <church> --scenario <s> [--admin-email <email>] --json`: a whole demo
|
||||
* scenario in one job, on **every product the church has on that server**, in
|
||||
* `DEMO_SCENARIO_ORDER` (Accounts first); products it doesn't have are skipped, so a demo client
|
||||
* with only Accounts and the Website gets both. The script checks every installed product's
|
||||
* release (`DEMO_SCENARIO_MIN_VERSIONS`) before changing anything, and stops at the first
|
||||
* failure, naming the products now out of step. The report's `result`: `loaded` and `skipped`
|
||||
* (products, space-separated). `adminEmail`: Events' account kept, as in `seed-demo`.
|
||||
* Agent 1.7.0+ (`SEED_SCENARIO_JOB_MIN_AGENT`).
|
||||
*/
|
||||
"seed-scenario": z.strictObject({ church: shortNameSchema, scenario: demoScenarioSchema, adminEmail: z.email().max(254).optional() }),
|
||||
/**
|
||||
* `crosscode env <church> <product> --json`: the product's .env values, secrets hidden (only
|
||||
* whether they're set). The report's `result` is an {@link envReadResultSchema}.
|
||||
@@ -380,7 +394,7 @@ export const CENTRAL_JOB_TYPES: readonly JobType[] = ["check-ports", "status", "
|
||||
|
||||
/** Time limits per job type, in minutes (§3). A job past it is stopped and reported as failed. */
|
||||
export const JOB_TIME_LIMIT_MINUTES: Record<JobType, number> = {
|
||||
install: 30, "add-product": 30, deploy: 20, adopt: 30, "adopt-undo": 15, restart: 5, "seed-demo": 15, "env-read": 2, "env-set": 20, export: 20,
|
||||
install: 30, "add-product": 30, deploy: 20, adopt: 30, "adopt-undo": 15, restart: 5, "seed-demo": 15, "seed-scenario": 45, "env-read": 2, "env-set": 20, export: 20,
|
||||
uninstall: 20, purge: 10, "update-agent": 15, "check-ports": 2, status: 3,
|
||||
"frp-read": 2, "frp-write": 5, "probe-ports": 2,
|
||||
};
|
||||
@@ -425,7 +439,7 @@ function jobOf<T extends JobType>(type: T) {
|
||||
}
|
||||
|
||||
export const agentJobSchema = z.discriminatedUnion("type", [
|
||||
jobOf("install"), jobOf("add-product"), jobOf("deploy"), jobOf("adopt"), jobOf("adopt-undo"), jobOf("restart"), jobOf("seed-demo"),
|
||||
jobOf("install"), jobOf("add-product"), jobOf("deploy"), jobOf("adopt"), jobOf("adopt-undo"), jobOf("restart"), jobOf("seed-demo"), jobOf("seed-scenario"),
|
||||
jobOf("env-read"), jobOf("env-set"), jobOf("export"), jobOf("uninstall"), jobOf("purge"), jobOf("update-agent"), jobOf("check-ports"), jobOf("status"),
|
||||
jobOf("frp-read"), jobOf("frp-write"), jobOf("probe-ports"),
|
||||
]);
|
||||
|
||||
@@ -14,37 +14,85 @@ import { z } from "zod";
|
||||
/**
|
||||
* The translations a devotional can use. An id never changes once released; more can be added.
|
||||
* `youVersionId` is the version's number on bible.com (`bible.com/bible/<id>/JHN.3.16.<abbr>`).
|
||||
* `copyright` is shown under the verse wherever it's quoted. Check each publisher's terms for use
|
||||
* in an app before Cross Code's devotionals go out (APP-1.0-PLAN, "Still open").
|
||||
*
|
||||
* The notices are the publishers' own wording (checked 2026-11-30, docs/BIBLE-PERMISSIONS.md):
|
||||
* - `copyright` is shown under the verse, wherever it's quoted.
|
||||
* - `acknowledgement` is the full notice, for the App's Acknowledgements page (the Bible Society
|
||||
* asks for the long form there and allows the short one next to the text).
|
||||
* - `disclaimer`, where not null, goes with the notice whenever the translation is quoted next to
|
||||
* content the publisher hasn't approved, which is every devotional (Bible Society, §6.4).
|
||||
* - `publisher` and `permissionsUrl`: who to ask past the free allowance (`FREE_QUOTE_VERSES`).
|
||||
* - `licence`: "public-domain" may be used freely; "permission" needs the publisher's written
|
||||
* permission for our use. **App 1.0 and the Hub offer only the public-domain ones**
|
||||
* (`FREE_BIBLE_TRANSLATION_IDS`, decided by Joshua 2026-11-30); the others stay in the list,
|
||||
* ids unchanged, for when a publisher says yes.
|
||||
*
|
||||
* None of these lets Cross Code quote past that allowance: that needs each publisher's written
|
||||
* permission (docs/BIBLE-PERMISSIONS.md). Never send a passage's text to an AI feature: Crossway
|
||||
* (ESV) and Biblica (NIV) forbid it outright without a separate licence.
|
||||
*/
|
||||
const BIBLE_SOCIETY_DISCLAIMER_AF =
|
||||
"Die Bybelgenootskap van Suid-Afrika verklaar hiermee dat die mening, sienings en teologiese standpunte in die bykomende materiaal in hierdie publikasie nie noodwendig dié van die Bybelgenootskap van Suid-Afrika weerspieël nie. Die Bybelgenootskap van Suid-Afrika onderskryf nie die gebruik van Bybelteks op enige manier of op enige platform wat moontlik as antichristelik beskou kan word of wat onwettige aktiwiteite bevorder.";
|
||||
const BIBLE_SOCIETY = { licence: "permission", publisher: "Bible Society of South Africa", permissionsUrl: "https://biblesociety.co.za/index/copyright-and-permissions/" } as const;
|
||||
|
||||
export const BIBLE_TRANSLATIONS = [
|
||||
{
|
||||
id: "NLT", name: "New Living Translation", language: "en", youVersionId: 116,
|
||||
copyright: "Scripture quotations are taken from the Holy Bible, New Living Translation, copyright © 1996, 2004, 2015 by Tyndale House Foundation. Used by permission of Tyndale House Publishers, Carol Stream, Illinois 60188. All rights reserved.",
|
||||
copyright: "Scripture quotations are taken from the Holy Bible, New Living Translation, copyright © 1996, 2004, 2015 by Tyndale House Ministries. Used by permission. All rights reserved.",
|
||||
acknowledgement: "Scripture quotations marked (NLT) are taken from the Holy Bible, New Living Translation, copyright © 1996, 2004, 2015 by Tyndale House Ministries. Used by permission. All rights reserved.",
|
||||
disclaimer: null,
|
||||
licence: "permission", publisher: "Tyndale House Publishers", permissionsUrl: "https://www.tyndale.com/permissions",
|
||||
},
|
||||
{
|
||||
id: "ESV", name: "English Standard Version", language: "en", youVersionId: 59,
|
||||
copyright: "Scripture quotations are from the ESV® Bible (The Holy Bible, English Standard Version®), © 2001 by Crossway, a publishing ministry of Good News Publishers. Used by permission. All rights reserved.",
|
||||
copyright: "Scripture quotations are from the ESV® Bible (The Holy Bible, English Standard Version®), © 2001 by Crossway, a publishing ministry of Good News Publishers. ESV Text Edition: 2025. The ESV text may not be quoted in any publication made available to the public by a Creative Commons license. The ESV may not be translated in whole or in part into any other language. Used by permission. All rights reserved.",
|
||||
acknowledgement: "Scripture quotations marked (ESV) are from the ESV® Bible (The Holy Bible, English Standard Version®), © 2001 by Crossway, a publishing ministry of Good News Publishers. ESV Text Edition: 2025. The ESV text may not be quoted in any publication made available to the public by a Creative Commons license. The ESV may not be translated in whole or in part into any other language. Used by permission. All rights reserved.",
|
||||
disclaimer: null,
|
||||
licence: "permission", publisher: "Crossway", permissionsUrl: "https://www.crossway.org/permissions/digital/",
|
||||
},
|
||||
{
|
||||
id: "NIV", name: "New International Version", language: "en", youVersionId: 111,
|
||||
copyright: "Scripture quotations taken from The Holy Bible, New International Version® NIV®. Copyright © 1973, 1978, 1984, 2011 by Biblica, Inc.™ Used by permission. All rights reserved worldwide.",
|
||||
acknowledgement: "Scripture quotations marked (NIV) are taken from The Holy Bible, New International Version® NIV®. Copyright © 1973, 1978, 1984, 2011 by Biblica, Inc.™ Used by permission. All rights reserved worldwide.",
|
||||
disclaimer: null,
|
||||
licence: "permission", publisher: "Biblica, Inc.", permissionsUrl: "https://www.biblica.com/permissions/",
|
||||
},
|
||||
{
|
||||
id: "NKJV", name: "New King James Version", language: "en", youVersionId: 114,
|
||||
copyright: "Scripture taken from the New King James Version®. Copyright © 1982 by Thomas Nelson. Used by permission. All rights reserved.",
|
||||
acknowledgement: "Scripture marked (NKJV) taken from the New King James Version®. Copyright © 1982 by Thomas Nelson. Used by permission. All rights reserved.",
|
||||
disclaimer: null,
|
||||
licence: "permission", publisher: "HarperCollins Christian Publishing (Thomas Nelson)", permissionsUrl: "https://www.harpercollinschristian.com/sales-and-rights/permissions/",
|
||||
},
|
||||
{
|
||||
id: "KJV", name: "King James Version", language: "en", youVersionId: 1,
|
||||
copyright: "King James Version. Public domain.",
|
||||
acknowledgement: "Scripture quotations marked (KJV) are from the King James Version, which is in the public domain.",
|
||||
disclaimer: null,
|
||||
licence: "public-domain", publisher: null, permissionsUrl: null,
|
||||
},
|
||||
{
|
||||
id: "AFR53", name: "Afrikaans 1933/1953-vertaling", language: "af", youVersionId: 5,
|
||||
copyright: "Die Bybel in Afrikaans, 1933/1953-vertaling. © Bybelgenootskap van Suid-Afrika. Gebruik met toestemming.",
|
||||
copyright: "Bybel in Afrikaans 1933/1953-vertaling © Bybelgenootskap van Suid-Afrika 1933, 1953. Digitale Weergawe © Bybelgenootskap van Suid-Afrika 2012. Alle regte voorbehou. www.biblesociety.co.za / www.biblesa.co.za.",
|
||||
acknowledgement: "Skrifaanhalings geneem uit die Bybel in Afrikaans 1933/1953-vertaling © Bybelgenootskap van Suid-Afrika 1933, 1953. Digitale Weergawe © Bybelgenootskap van Suid-Afrika 2012. Gebruik met toestemming. Alle regte voorbehou. www.biblesociety.co.za / www.biblesa.co.za. Kontak: copyright@biblesociety.co.za",
|
||||
disclaimer: BIBLE_SOCIETY_DISCLAIMER_AF,
|
||||
...BIBLE_SOCIETY,
|
||||
},
|
||||
{
|
||||
id: "AFR83", name: "Afrikaans 1983-vertaling", language: "af", youVersionId: 6,
|
||||
copyright: "Die Bybel in Afrikaans, 1983-vertaling. © Bybelgenootskap van Suid-Afrika 1983. Gebruik met toestemming.",
|
||||
id: "AFR83", name: "Afrikaans 1983/1992-vertaling", language: "af", youVersionId: 6,
|
||||
copyright: "Bybel in Afrikaans 1983-vertaling met herformulerings tot en met 1992 © Bybelgenootskap van Suid-Afrika 1983, 1992. Alle regte voorbehou. www.biblesociety.co.za / www.biblesa.co.za.",
|
||||
acknowledgement: "Skrifaanhalings geneem uit die Bybel in Afrikaans 1983-vertaling met herformulerings tot en met 1992 © Bybelgenootskap van Suid-Afrika 1983, 1992. Gebruik met toestemming. Alle regte voorbehou. www.biblesociety.co.za / www.biblesa.co.za. Kontak: copyright@biblesociety.co.za",
|
||||
disclaimer: BIBLE_SOCIETY_DISCLAIMER_AF,
|
||||
...BIBLE_SOCIETY,
|
||||
},
|
||||
{
|
||||
// Dedicated to the public domain (CC0) on 30 April 2023 (berean.bible/terms.htm). The
|
||||
// attribution is "appreciated but not required"; the Berean name only for the verbatim text.
|
||||
id: "BSB", name: "Berean Standard Bible", language: "en", youVersionId: 3034,
|
||||
copyright: "Berean Standard Bible (BSB). Public domain.",
|
||||
acknowledgement: "The Holy Bible, Berean Standard Bible, BSB is produced in cooperation with Bible Hub, Discovery Bible, OpenBible.com, and the Berean Bible Translation Committee. This text of God's Word has been dedicated to the public domain.",
|
||||
disclaimer: null,
|
||||
licence: "public-domain", publisher: null, permissionsUrl: null,
|
||||
},
|
||||
] as const;
|
||||
|
||||
@@ -53,6 +101,9 @@ export const BIBLE_TRANSLATION_IDS = BIBLE_TRANSLATIONS.map((t) => t.id) as [Bib
|
||||
export const bibleTranslationIdSchema = z.enum(BIBLE_TRANSLATION_IDS);
|
||||
export type BibleTranslationId = z.infer<typeof bibleTranslationIdSchema>;
|
||||
|
||||
/** The translations anyone may quote freely: the only ones the Hub and App 1.0 offer. */
|
||||
export const FREE_BIBLE_TRANSLATION_IDS: readonly BibleTranslationId[] = BIBLE_TRANSLATIONS.filter((t) => t.licence === "public-domain").map((t) => t.id);
|
||||
|
||||
export function bibleTranslation(id: BibleTranslationId): BibleTranslation {
|
||||
return BIBLE_TRANSLATIONS.find((t) => t.id === id)!;
|
||||
}
|
||||
@@ -60,6 +111,14 @@ export function bibleTranslation(id: BibleTranslationId): BibleTranslation {
|
||||
/** A passage longer than this gets a warning: quote the passage, not whole chapters (§6). */
|
||||
export const PASSAGE_WARN_VERSES = 25;
|
||||
|
||||
/**
|
||||
* What every publisher but the KJV's lets anyone quote without asking, counted across the whole
|
||||
* work (Biblica: across a whole app or website), with the quotes under 25% of it and never a whole
|
||||
* book. Cross Code's devotionals, and a church's own, pass it within a few months, so each needs
|
||||
* the publisher's written permission (docs/BIBLE-PERMISSIONS.md).
|
||||
*/
|
||||
export const FREE_QUOTE_VERSES = 500;
|
||||
|
||||
// ─── Books ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
* wrote it in the App, so both show and send alike.
|
||||
*
|
||||
* Cross Code's reach an App set to "From Cross Code" from the Hub: `GET /api/v2/devotionals`
|
||||
* (`hub.DEVOTIONALS_PATH`), once a night, the next 3 months (`devotionalsReplySchema`).
|
||||
* (`hub.DEVOTIONALS_PATH`), once a night, the next 2 weeks at most (1.24.0, `CROSSCODE_DEVOTIONALS_FETCH_DAYS`;
|
||||
* `devotionalsReplySchema`).
|
||||
*
|
||||
* Both write them by hand or import a CSV (`DEVOTIONAL_CSV_COLUMNS`, `checkDevotionalCsv`), with
|
||||
* the same checks in the Hub and the App.
|
||||
@@ -25,9 +26,21 @@ export const DEVOTIONAL_SOURCES = ["crosscode", "church"] as const;
|
||||
export const devotionalSourceSchema = z.enum(DEVOTIONAL_SOURCES);
|
||||
export type DevotionalSource = z.infer<typeof devotionalSourceSchema>;
|
||||
|
||||
/** How far ahead the Hub schedules Cross Code's devotionals, and how far ahead an App fetches them. */
|
||||
/**
|
||||
* 1.24.0: the most days one `GET /api/v2/devotionals` answer covers, `from` included (two weeks):
|
||||
* an App fetches them each night, so it always has the days ahead even if the Hub is down for a while.
|
||||
*/
|
||||
export const CROSSCODE_DEVOTIONALS_FETCH_DAYS = 14;
|
||||
|
||||
/**
|
||||
* @deprecated 1.24.0: the Hub schedules `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS` ahead and an App
|
||||
* fetches `CROSSCODE_DEVOTIONALS_FETCH_DAYS`. Kept so nothing that read it breaks.
|
||||
*/
|
||||
export const CROSSCODE_DEVOTIONALS_AHEAD_MONTHS = 3;
|
||||
|
||||
/** 1.24.0: how far ahead the Hub schedules Cross Code's devotionals (two years; was 3 months). */
|
||||
export const CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS = 24;
|
||||
|
||||
export const DEVOTIONAL_LIMITS = { title: 200, reference: 100, passageText: 10_000, body: 20_000, prayer: 5_000, author: 200 } as const;
|
||||
|
||||
/**
|
||||
@@ -66,14 +79,15 @@ export type Devotional = z.infer<typeof devotionalSchema>;
|
||||
|
||||
/**
|
||||
* The Hub's answer to `GET /api/v2/devotionals?from=YYYY-MM-DD`: Cross Code's devotionals from
|
||||
* `from` to `to` (3 months on), one per day at most, oldest first. The App replaces its copy of
|
||||
* `from` to `to` (1.24.0: at most `CROSSCODE_DEVOTIONALS_FETCH_DAYS` days, `from` included; 3 months
|
||||
* before), one per day at most, oldest first. The App replaces its copy of
|
||||
* that range with them (a day missing from the list was removed in the Hub).
|
||||
*/
|
||||
export const devotionalsReplySchema = z.object({
|
||||
schema: z.literal(DEVOTIONAL_SCHEMA),
|
||||
from: dateSchema,
|
||||
to: dateSchema,
|
||||
devotionals: z.array(devotionalSchema.extend({ source: z.literal("crosscode") })).max(100),
|
||||
devotionals: z.array(devotionalSchema.extend({ source: z.literal("crosscode") })).max(100), // 14 from 1.24.0; 100 kept for older Hubs
|
||||
generatedAt: dateTimeSchema,
|
||||
});
|
||||
export type DevotionalsReply = z.infer<typeof devotionalsReplySchema>;
|
||||
@@ -83,6 +97,30 @@ export function devotionalCopyright(passage: Pick<DevotionalPassage, "translatio
|
||||
return bibleTranslation(passage.translation).copyright;
|
||||
}
|
||||
|
||||
/** The publisher's disclaimer shown with the copyright line, or null (Bible Society translations only). */
|
||||
export function devotionalDisclaimer(passage: Pick<DevotionalPassage, "translation">): string | null {
|
||||
return bibleTranslation(passage.translation).disclaimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verses quoted per translation, for the free allowance (`FREE_QUOTE_VERSES`, counted across the
|
||||
* whole App). A passage across chapters can't be counted (verse counts per chapter aren't kept)
|
||||
* and goes in `uncounted`, so a warning can say the total is at least this.
|
||||
*/
|
||||
export function quotedVerses(passages: readonly Pick<DevotionalPassage, "location" | "translation">[]): {
|
||||
verses: Partial<Record<BibleTranslationId, number>>;
|
||||
uncounted: Partial<Record<BibleTranslationId, number>>;
|
||||
} {
|
||||
const verses: Partial<Record<BibleTranslationId, number>> = {};
|
||||
const uncounted: Partial<Record<BibleTranslationId, number>> = {};
|
||||
for (const p of passages) {
|
||||
const n = passageVerseCount(p.location);
|
||||
if (n === null) uncounted[p.translation] = (uncounted[p.translation] ?? 0) + 1;
|
||||
else verses[p.translation] = (verses[p.translation] ?? 0) + n;
|
||||
}
|
||||
return { verses, uncounted };
|
||||
}
|
||||
|
||||
// ─── CSV import ──────────────────────────────────────────────────────────────
|
||||
|
||||
/** The columns, in this order in the template. A file may order them differently. */
|
||||
@@ -90,9 +128,12 @@ export const DEVOTIONAL_CSV_COLUMNS = ["date", "title", "passage", "translation"
|
||||
export type DevotionalCsvColumn = (typeof DEVOTIONAL_CSV_COLUMNS)[number];
|
||||
const REQUIRED_COLUMNS: readonly DevotionalCsvColumn[] = ["date", "title", "passage", "translation", "passage_text", "body"];
|
||||
|
||||
/** Rows per import (a year and a bit), and the file size the Hub and App accept. */
|
||||
export const DEVOTIONAL_CSV_MAX_ROWS = 400;
|
||||
export const DEVOTIONAL_CSV_MAX_BYTES = 2 * 1024 * 1024;
|
||||
/**
|
||||
* Rows per import and the file size the Hub and App accept. 1.24.0: two years and a bit (800 rows,
|
||||
* 8 MB; was 400 and 2 MB), so the Hub's two years ahead fit in one file.
|
||||
*/
|
||||
export const DEVOTIONAL_CSV_MAX_ROWS = 800;
|
||||
export const DEVOTIONAL_CSV_MAX_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* Reads CSV (RFC 4180: quoted fields, `""` for a quote, line breaks inside quotes), with or
|
||||
@@ -156,8 +197,10 @@ export interface DevotionalCsvResult {
|
||||
export interface DevotionalCsvOptions {
|
||||
/** Dates that already have a devotional. */
|
||||
taken?: Iterable<string>;
|
||||
/** The last date allowed (the Hub: 3 months from today). Later dates are errors. */
|
||||
/** The last date allowed (the Hub: two years from today). Later dates are errors. */
|
||||
latestDate?: string;
|
||||
/** The translations allowed (the Hub and App 1.0: `FREE_BIBLE_TRANSLATION_IDS`). Any by default. */
|
||||
translations?: readonly BibleTranslationId[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +209,7 @@ export interface DevotionalCsvOptions {
|
||||
* twice in the file, a date already filled). Never throws.
|
||||
*/
|
||||
export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions = {}): DevotionalCsvResult {
|
||||
if (text.length > DEVOTIONAL_CSV_MAX_BYTES) return { fileError: "The file is larger than 2 MB", rows: [] };
|
||||
if (text.length > DEVOTIONAL_CSV_MAX_BYTES) return { fileError: `The file is larger than ${DEVOTIONAL_CSV_MAX_BYTES / 1024 / 1024} MB`, rows: [] };
|
||||
const all = parseCsv(text);
|
||||
const header = all[0];
|
||||
if (!header) return { fileError: "The file is empty", rows: [] };
|
||||
@@ -202,7 +245,7 @@ export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions =
|
||||
|
||||
const date = required("date", "The date");
|
||||
if (date && !dateSchema.safeParse(date).success) errors.push({ column: "date", message: `"${date}" isn't a date (use YYYY-MM-DD, e.g. 2027-01-05)` });
|
||||
else if (date && options.latestDate && date > options.latestDate) errors.push({ column: "date", message: `${date} is more than ${CROSSCODE_DEVOTIONALS_AHEAD_MONTHS} months ahead (the last day is ${options.latestDate})` });
|
||||
else if (date && options.latestDate && date > options.latestDate) errors.push({ column: "date", message: `${date} is too far ahead (the last day is ${options.latestDate})` });
|
||||
else if (date && seen.has(date)) errors.push({ column: "date", message: `${date} is also on line ${seen.get(date)}` });
|
||||
if (date && !seen.has(date)) seen.set(date, line);
|
||||
|
||||
@@ -211,7 +254,10 @@ export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions =
|
||||
|
||||
const translationText = required("translation", "The translation");
|
||||
const translation = BIBLE_TRANSLATION_IDS.find((id) => id === translationText.toUpperCase().replace(/\s/g, "")) as BibleTranslationId | undefined;
|
||||
if (translationText && !translation) errors.push({ column: "translation", message: `"${translationText}" isn't one of ${BIBLE_TRANSLATION_IDS.join(", ")}` });
|
||||
if (translationText && !translation) errors.push({ column: "translation", message: `"${translationText}" isn't one of ${(options.translations ?? BIBLE_TRANSLATION_IDS).join(", ")}` });
|
||||
else if (translation && options.translations && !options.translations.includes(translation)) {
|
||||
errors.push({ column: "translation", message: `${translation} needs ${bibleTranslation(translation).publisher ?? "the publisher"}'s permission; use ${options.translations.join(" or ")}` });
|
||||
}
|
||||
|
||||
const reference = required("passage", "The passage");
|
||||
const parsed = reference ? parseBibleReference(reference) : null;
|
||||
@@ -265,8 +311,8 @@ export const DEVOTIONAL_CSV_TEMPLATE = devotionalCsv([{
|
||||
date: "2027-01-05",
|
||||
title: "Love that never gives up",
|
||||
passage: "1 Corinthians 13:4-7",
|
||||
translation: "NLT",
|
||||
passage_text: "Love is patient and kind. Love is not jealous or boastful or proud or rude. It does not demand its own way. It is not irritable, and it keeps no record of being wronged. It does not rejoice about injustice but rejoices whenever the truth wins out. Love never gives up, never loses faith, is always hopeful, and endures through every circumstance.",
|
||||
translation: "BSB",
|
||||
passage_text: "Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It is not rude, it is not self-seeking, it is not easily angered, it keeps no account of wrongs. Love takes no pleasure in evil, but rejoices in the truth. It bears all things, believes all things, hopes all things, endures all things.",
|
||||
body: "Paul wrote these words to a church that was proud of its gifts...\n\nA second paragraph after a blank line.",
|
||||
prayer: "Lord, teach me to love the way you love me.",
|
||||
author: "Cross Code",
|
||||
|
||||
@@ -327,8 +327,8 @@ export type StorageRequestResponse = z.infer<typeof storageRequestResponseSchema
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Cross Code's devotionals (contracts 1.20.0, Hub 2.26.0, APP-1.0-PLAN §6): an App set to "From
|
||||
// Cross Code" fetches the next 3 months once a night (and on "Sync now"), and keeps its copy, so a
|
||||
// Hub outage changes nothing. `GET /api/v2/devotionals?from=YYYY-MM-DD` with
|
||||
// Cross Code" fetches the next 2 weeks once a night (1.24.0, `CROSSCODE_DEVOTIONALS_FETCH_DAYS`; 3 months
|
||||
// before) and on "Sync now", and keeps its copy, so a Hub outage of under 2 weeks changes nothing. `GET /api/v2/devotionals?from=YYYY-MM-DD` with
|
||||
// `Authorization: Bearer <the install's licence token>`; App licences only (`403 NOT_AN_APP`),
|
||||
// active or in grace (`403 LICENCE_INACTIVE`). The answer is a `devotionalsReplySchema`.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -230,6 +230,23 @@ describe("demo scenarios (1.21.0)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("seed-scenario jobs (1.23.0)", () => {
|
||||
const args = (a: Record<string, unknown>) => agent.jobArgsSchemas["seed-scenario"].safeParse(a).success;
|
||||
|
||||
it("takes a church and a scenario (the products are whatever the church has installed)", () => {
|
||||
expect(args({ church: "demo2", scenario: "community-family" })).toBe(true);
|
||||
expect(args({ church: "demo2", scenario: "community-family", adminEmail: "jane@hope.test" })).toBe(true);
|
||||
expect(args({ church: "demo2", scenario: "nowhere" })).toBe(false);
|
||||
expect(args({ church: "demo2" })).toBe(false);
|
||||
expect(args({ church: "demo2", scenario: "bold-youth", products: ["website"] })).toBe(false);
|
||||
expect(args({ church: "demo2", scenario: "bold-youth", adminEmail: "x; rm -rf /" })).toBe(false);
|
||||
expect(agent.JOB_TYPES).toContain("seed-scenario");
|
||||
expect(agent.CENTRAL_JOB_TYPES).not.toContain("seed-scenario");
|
||||
expect(agent.JOB_TIME_LIMIT_MINUTES["seed-scenario"]).toBeGreaterThanOrEqual(agent.JOB_TIME_LIMIT_MINUTES["seed-demo"] * 3);
|
||||
expect(agent.SEED_SCENARIO_JOB_MIN_AGENT).toBe("1.7.0");
|
||||
});
|
||||
});
|
||||
|
||||
describe("env-read and env-set jobs (1.12.0)", () => {
|
||||
const set = (a: Record<string, unknown>) => agent.jobArgsSchemas["env-set"].safeParse({ church: "hope", product: "events", file: "backend/.env", set: {}, unset: [], restart: true, ...a });
|
||||
it("read one product", () => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import {
|
||||
BIBLE_BOOKS, BIBLE_TRANSLATIONS, DEVOTIONAL_CSV_COLUMNS, DEVOTIONAL_CSV_TEMPLATE, checkDevotionalCsv, devotionalCsv,
|
||||
devotionalsReplySchema, findBibleBook, formatBibleReference, parseBibleReference, parseCsv, passageVerseCount, youVersionUrl,
|
||||
BIBLE_BOOKS, BIBLE_TRANSLATIONS, DEVOTIONAL_CSV_COLUMNS, FREE_BIBLE_TRANSLATION_IDS, FREE_QUOTE_VERSES, DEVOTIONAL_CSV_TEMPLATE, checkDevotionalCsv, devotionalCsv,
|
||||
devotionalDisclaimer, devotionalsReplySchema, findBibleBook, quotedVerses, formatBibleReference, parseBibleReference, parseCsv, passageVerseCount, youVersionUrl,
|
||||
type PassageLocation,
|
||||
CROSSCODE_DEVOTIONALS_FETCH_DAYS, CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS, DEVOTIONAL_CSV_MAX_ROWS,
|
||||
} from "../src";
|
||||
import { sample } from "./helpers";
|
||||
|
||||
@@ -33,11 +34,47 @@ describe("Bible books and translations", () => {
|
||||
expect(findBibleBook("Nowhere")).toBeNull();
|
||||
});
|
||||
|
||||
it("has the seven translations, with unique ids and YouVersion numbers", () => {
|
||||
expect(BIBLE_TRANSLATIONS.map((t) => t.id)).toEqual(["NLT", "ESV", "NIV", "NKJV", "KJV", "AFR53", "AFR83"]);
|
||||
expect(new Set(BIBLE_TRANSLATIONS.map((t) => t.youVersionId)).size).toBe(7);
|
||||
it("has the eight translations, with unique ids and YouVersion numbers", () => {
|
||||
expect(BIBLE_TRANSLATIONS.map((t) => t.id)).toEqual(["NLT", "ESV", "NIV", "NKJV", "KJV", "AFR53", "AFR83", "BSB"]);
|
||||
expect(new Set(BIBLE_TRANSLATIONS.map((t) => t.youVersionId)).size).toBe(8);
|
||||
for (const t of BIBLE_TRANSLATIONS) expect(t.copyright.length).toBeGreaterThan(10);
|
||||
});
|
||||
|
||||
it("carries each publisher's notices, with a publisher to ask for all but the public-domain ones", () => {
|
||||
expect(FREE_BIBLE_TRANSLATION_IDS).toEqual(["KJV", "BSB"]);
|
||||
for (const t of BIBLE_TRANSLATIONS) {
|
||||
const free = FREE_BIBLE_TRANSLATION_IDS.includes(t.id);
|
||||
expect(t.licence).toBe(free ? "public-domain" : "permission");
|
||||
expect(t.acknowledgement.length).toBeGreaterThan(t.id === "KJV" ? 10 : 50);
|
||||
expect(t.publisher === null).toBe(free);
|
||||
expect(t.permissionsUrl === null).toBe(free);
|
||||
}
|
||||
expect(youVersionUrl(ok("John 3:16"), "BSB")).toBe("https://www.bible.com/bible/3034/JHN.3.16.BSB");
|
||||
expect(BIBLE_TRANSLATIONS.find((t) => t.id === "NLT")!.copyright).toContain("Tyndale House Ministries");
|
||||
expect(BIBLE_TRANSLATIONS.find((t) => t.id === "ESV")!.copyright).toContain("ESV Text Edition: 2025");
|
||||
expect(FREE_QUOTE_VERSES).toBe(500);
|
||||
});
|
||||
|
||||
it("gives the Bible Society's translations their disclaimer and official names", () => {
|
||||
for (const t of BIBLE_TRANSLATIONS) {
|
||||
expect(t.disclaimer !== null).toBe(t.language === "af");
|
||||
expect(t.acknowledgement).not.toMatch(/Ou Vertaling|Nuwe Vertaling/);
|
||||
}
|
||||
expect(devotionalDisclaimer({ translation: "AFR83" })).toContain("Bybelgenootskap van Suid-Afrika verklaar");
|
||||
expect(devotionalDisclaimer({ translation: "NIV" })).toBeNull();
|
||||
expect(BIBLE_TRANSLATIONS.find((t) => t.id === "AFR83")!.copyright).toContain("1983-vertaling met herformulerings tot en met 1992");
|
||||
});
|
||||
|
||||
it("counts the verses quoted per translation, passages across chapters apart", () => {
|
||||
const r = quotedVerses([
|
||||
{ location: ok("John 3:16-18"), translation: "NIV" },
|
||||
{ location: ok("Ps 23:1-6"), translation: "NIV" },
|
||||
{ location: ok("Rom 8:38-9:2"), translation: "NIV" },
|
||||
{ location: ok("Gen 1:1"), translation: "KJV" },
|
||||
]);
|
||||
expect(r.verses).toEqual({ NIV: 9, KJV: 1 });
|
||||
expect(r.uncounted).toEqual({ NIV: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseBibleReference", () => {
|
||||
@@ -118,7 +155,15 @@ describe("checkDevotionalCsv", () => {
|
||||
expect(r.fileError).toBeNull();
|
||||
expect(r.rows).toHaveLength(1);
|
||||
expect(r.rows[0]!.errors).toEqual([]);
|
||||
expect(r.rows[0]!.devotional?.passage).toMatchObject({ reference: "1 Corinthians 13:4–7", translation: "NLT" });
|
||||
expect(r.rows[0]!.devotional?.passage).toMatchObject({ reference: "1 Corinthians 13:4–7", translation: "BSB" });
|
||||
expect(checkDevotionalCsv(DEVOTIONAL_CSV_TEMPLATE, { translations: FREE_BIBLE_TRANSLATION_IDS }).rows[0]!.errors).toEqual([]);
|
||||
});
|
||||
|
||||
it("refuses a translation that isn't allowed, naming the publisher to ask", () => {
|
||||
const r = checkDevotionalCsv(devotionalCsv([row({ translation: "NIV" }), row({ date: "2027-01-06", translation: "kjv" })]), { translations: FREE_BIBLE_TRANSLATION_IDS });
|
||||
expect(r.rows[0]!.devotional).toBeNull();
|
||||
expect(r.rows[0]!.errors).toEqual([{ column: "translation", message: "NIV needs Biblica, Inc.'s permission; use KJV or BSB" }]);
|
||||
expect(r.rows[1]!.devotional?.passage.translation).toBe("KJV");
|
||||
});
|
||||
|
||||
it("turns a good row into a devotional, in the translation's language, empty optional fields null", () => {
|
||||
@@ -158,7 +203,17 @@ describe("checkDevotionalCsv", () => {
|
||||
expect(r.rows[0]).toMatchObject({ taken: true, errors: [] });
|
||||
expect(r.rows[1]!.warnings[0]!.message).toContain("40 verses");
|
||||
expect(r.rows[1]!.devotional).not.toBeNull();
|
||||
expect(r.rows[2]!.errors[0]!.message).toContain("more than 3 months ahead");
|
||||
expect(r.rows[2]!.errors[0]!.message).toContain("too far ahead (the last day is 2027-03-31)");
|
||||
});
|
||||
|
||||
it("1.24.0: two years ahead in the Hub, in one file; Apps fetch 2 weeks", () => {
|
||||
expect([CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS, CROSSCODE_DEVOTIONALS_FETCH_DAYS]).toEqual([24, 14]);
|
||||
const start = Date.UTC(2027, 0, 1);
|
||||
const rows = Array.from({ length: 731 }, (_, i) => row({ date: new Date(start + i * 864e5).toISOString().slice(0, 10), translation: "KJV" }));
|
||||
const r = checkDevotionalCsv(devotionalCsv(rows), { latestDate: "2028-12-31" });
|
||||
expect(DEVOTIONAL_CSV_MAX_ROWS).toBeGreaterThanOrEqual(731);
|
||||
expect(r.fileError).toBeNull();
|
||||
expect(r.rows.filter((x) => x.devotional)).toHaveLength(731);
|
||||
});
|
||||
|
||||
it("refuses a file without the required columns, or without rows", () => {
|
||||
|
||||
@@ -8,8 +8,10 @@ their demo data around the same people (same `sub` in every product: `demoId`).
|
||||
- `DEMO_CHURCHES`, `demoChurch(scenario)`: each church's profile (name, colours, font pairing,
|
||||
corners, campuses, service times, contact, social links) and the mark its logo is drawn with.
|
||||
- `demoPeople(scenario)`: the leads (pastor, office, prayer coordinator…) and members, enough for
|
||||
the scenario's App active-member band. `demoParts(scenario)`: what each lead does.
|
||||
the scenario's App active-member band, each with a `gender` (1.1.0, for Events' gendered events)
|
||||
and a campus where the church has campuses. `demoParts(scenario)`: what each lead does.
|
||||
- `demoIconSvg`, `demoLogoSvg`: the logo and icon, drawn for the demo.
|
||||
|
||||
Everything is fictional: people and church addresses are at `example.com`, there are no phone
|
||||
numbers, and the password is `Demo@1234`. Ships inside the apps that use it (not tagged).
|
||||
numbers, and the password is `Demo@1234`. Ships inside the apps that use it (not tagged): Accounts
|
||||
1.9.0 and Events 3.8.0 so far; the Website and the App next. Each product's install script builds it.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/ui",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"description": "Shared UI for the church's sign-in pages, Website and App: the branded shell, forms and buttons, the church's fonts and footer (Tailwind; apps compile the source with transpilePackages)",
|
||||
"main": "src/index.tsx",
|
||||
|
||||
@@ -97,6 +97,62 @@ export function Field({ label, error, hint, id, className, ...rest }: FieldProps
|
||||
);
|
||||
}
|
||||
|
||||
export const isHexColour = (v: string) => /^#[0-9a-fA-F]{6}$/.test(v.trim());
|
||||
|
||||
type ColourFieldProps = {
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (hex: string) => void;
|
||||
hint?: React.ReactNode;
|
||||
error?: string | null;
|
||||
/** For a form read with FormData: the hex is sent under this name. */
|
||||
name?: string;
|
||||
id?: string;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* A colour: the swatch to pick it, the hex code to type or paste it, and a bar showing it, as Cross
|
||||
* Events' Branding settings. Controlled: `value` is what's typed, so it can be half-typed; it's a
|
||||
* colour once it reads `#rrggbb` (`isHexColour`), and says so when it doesn't.
|
||||
*/
|
||||
export function ColourField({ label, value, onChange, hint, error, name, id, disabled }: ColourFieldProps) {
|
||||
const fieldId = id ?? `f-${label.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
||||
const valid = isHexColour(value);
|
||||
const problem = error || (valid ? null : "Enter a colour code like #1f4e79.");
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<label htmlFor={fieldId} className="mb-1 block text-sm font-medium text-gray-800">{label}</label>
|
||||
<div className="flex items-center gap-3">
|
||||
<input
|
||||
type="color"
|
||||
aria-label={`${label}: pick`}
|
||||
disabled={disabled}
|
||||
className="h-10 w-20 shrink-0 cursor-pointer rounded-[var(--cc-radius-sm,0.5rem)] border border-gray-300 bg-white p-1 disabled:cursor-not-allowed"
|
||||
value={valid ? value.trim().toLowerCase() : "#000000"}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
id={fieldId}
|
||||
name={name}
|
||||
disabled={disabled}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
placeholder="#1f4e79"
|
||||
aria-invalid={!!problem}
|
||||
aria-describedby={problem ? `${fieldId}-error` : undefined}
|
||||
className={cx("w-full rounded-[var(--cc-radius-sm,0.5rem)] border px-3 py-2.5 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-brand/50", problem ? "border-red-500" : "border-gray-300")}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-2 h-6 rounded-[var(--cc-radius-sm,0.5rem)] border border-gray-200 transition-colors" style={{ background: valid ? value.trim() : "#f1f5f9" }} aria-hidden />
|
||||
{hint && !problem && <p className="mt-1 text-xs text-gray-500">{hint}</p>}
|
||||
{problem && <p id={`${fieldId}-error`} className="mt-1 text-sm text-red-700">{problem}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes<HTMLInputElement> & { label: React.ReactNode; hint?: React.ReactNode }) {
|
||||
return (
|
||||
<label className="mb-3 flex items-start gap-3 text-sm">
|
||||
|
||||
+100
-7
@@ -11,17 +11,25 @@ crosscode demo <church> --profile <profile> [--admin-email <email>]
|
||||
(small, events, ministry, multicampus, or from
|
||||
3.8.0 a demo scenario's church); a backup
|
||||
is taken first, one admin account is kept
|
||||
crosscode demo <church> website --profile <profile>
|
||||
crosscode demo <church> website --profile <profile> [--scenario <profile>]
|
||||
replace the Website's content with a demo church
|
||||
(heritage-parish, heritage-city, bold-youth,
|
||||
bold-plant, community-family, community-town,
|
||||
clean-modern, clean-campus); a backup is taken
|
||||
first; the church's profile, settings and admins stay
|
||||
first; the church's profile, settings and admins stay;
|
||||
from 1.8.0, --scenario: the scenario's people lead,
|
||||
and a linked Cross Events' events show instead
|
||||
crosscode demo <church> accounts --profile <scenario> [--scenario <scenario>]
|
||||
a demo scenario's church (profile, logo, icon) and
|
||||
people in Accounts (the eight scenarios, as the
|
||||
Website's profiles); a backup is taken first;
|
||||
real people and admins stay
|
||||
crosscode demo <church> --scenario <scenario> [--admin-email <email>]
|
||||
a whole demo scenario on every product the church
|
||||
has here, Accounts first (then Events, the Website,
|
||||
the App); products it doesn't have are skipped.
|
||||
Every release is checked first; it stops at the
|
||||
first failure and says what's out of step
|
||||
crosscode env <church> <product> the product's .env values (secrets hidden)
|
||||
crosscode env <church> <product> [--file backend/.env] --set NAME=value … [--unset NAME …] [--restart]
|
||||
change values (a copy is kept; never secrets or
|
||||
@@ -108,8 +116,10 @@ DEMO_SCENARIOS="$WEBSITE_DEMO_PROFILES"
|
||||
# `crosscode demo <church> website --profile <p>`: the Website's content instead (cmd_demo_website).
|
||||
# `crosscode demo <church> accounts --profile <scenario>`: a scenario's church and people (cmd_demo_accounts).
|
||||
# `--scenario <s>` (agent 1.7.0): part of loading that scenario; the profile must be the scenario's.
|
||||
# `--scenario <s>` with no product and no profile (the Hub's seed-scenario job): the whole scenario
|
||||
# on every product the church has (cmd_demo_scenario).
|
||||
cmd_demo() {
|
||||
local church="" product="events" profile="" email="" scenario="" dir user app
|
||||
local church="" product="" profile="" email="" scenario=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--profile) [ $# -ge 2 ] || die "--profile needs a value."; profile="$2"; shift 2 ;;
|
||||
@@ -117,16 +127,25 @@ cmd_demo() {
|
||||
--scenario) [ $# -ge 2 ] || die "--scenario needs a value."; scenario="$2"; shift 2 ;;
|
||||
-h|--help) manage_usage; return 0 ;;
|
||||
-*) die "Unknown option $1 (crosscode help demo)." ;;
|
||||
events|website|accounts) [ -n "$church" ] || die "Name the church first (crosscode demo hope website …)."; product="$1"; shift ;;
|
||||
events|website|accounts|app) [ -n "$church" ] || die "Name the church first (crosscode demo hope website …)."; product="$1"; shift ;;
|
||||
*) [ -z "$church" ] || die "One church at a time."; church="$1"; shift ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$church" ] || die "Name the church."
|
||||
if [ -n "$scenario" ] && [ -z "$product" ] && [ -z "$profile" ]; then
|
||||
[[ " $DEMO_SCENARIOS " == *" $scenario "* ]] || die "--scenario: one of $DEMO_SCENARIOS."
|
||||
[ -z "$email" ] || [[ "$email" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]] || die "--admin-email: not an email address."
|
||||
cmd_demo_scenario "$church" "$scenario" "$email"
|
||||
return
|
||||
fi
|
||||
product="${product:-events}"
|
||||
if [ -n "$scenario" ]; then
|
||||
[[ " $DEMO_SCENARIOS " == *" $scenario "* ]] || die "--scenario: one of $DEMO_SCENARIOS."
|
||||
# Every product loads the profile named after the scenario (contracts DEMO_SCENARIOS).
|
||||
[ "$profile" = "$scenario" ] || die "--scenario $scenario loads the $scenario profile in $product, not $profile."
|
||||
fi
|
||||
# Agent 1.7.0 sends the App's demo jobs; the App and its demo come with App 1.0.0.
|
||||
[ "$product" != app ] || die "The Church App's demo data comes with App 1.0.0 (this crosscode has none yet)."
|
||||
if [ "$product" = accounts ]; then
|
||||
[[ " $DEMO_SCENARIOS " == *" $profile "* ]] || die "--profile: one of $DEMO_SCENARIOS."
|
||||
[ -z "$email" ] || die "--admin-email: Accounts' demo keeps every admin."
|
||||
@@ -136,11 +155,17 @@ cmd_demo() {
|
||||
if [ "$product" = website ]; then
|
||||
[[ " $WEBSITE_DEMO_PROFILES " == *" $profile "* ]] || die "--profile: one of $WEBSITE_DEMO_PROFILES."
|
||||
[ -z "$email" ] || die "--admin-email: the Website's demo keeps every admin."
|
||||
cmd_demo_website "$church" "$profile"
|
||||
cmd_demo_website "$church" "$profile" "$scenario"
|
||||
return
|
||||
fi
|
||||
[[ " $DEMO_PROFILES " == *" $profile "* ]] || die "--profile: one of $DEMO_PROFILES."
|
||||
[ -z "$email" ] || [[ "$email" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]] || die "--admin-email: not an email address."
|
||||
cmd_demo_events "$church" "$profile" "$email"
|
||||
}
|
||||
|
||||
# Events' demo data (set-demo.js): backup, the profile as the site's user, reload.
|
||||
cmd_demo_events() {
|
||||
local church="$1" profile="$2" email="${3:-}" dir user app
|
||||
require_root
|
||||
load_church "$church"
|
||||
church_has_product events || die "$church has no Cross Events."
|
||||
@@ -168,6 +193,67 @@ cmd_demo() {
|
||||
die "Events didn't answer after the reload (sudo -u $user pm2 logs)."
|
||||
}
|
||||
|
||||
# The first release of each product that loads a demo scenario (contracts DEMO_SCENARIO_MIN_VERSIONS).
|
||||
scenario_min_version() {
|
||||
case "$1" in accounts) echo 1.9.0 ;; events) echo 3.8.0 ;; website) echo 1.8.0 ;; app) echo 1.0.0 ;; esac
|
||||
}
|
||||
|
||||
product_title() {
|
||||
case "$1" in accounts) echo Accounts ;; events) echo "Cross Events" ;; website) echo "The Website" ;; app) echo "The App" ;; *) echo "$1" ;; esac
|
||||
}
|
||||
|
||||
# A whole demo scenario (contracts seed-scenario, agent 1.7.0): every product the church has on this
|
||||
# server, in deploy order (Accounts first: the others read its profile and people; Events before the
|
||||
# Website and the App, which show its events through the feed). Products it doesn't have are
|
||||
# skipped, so a client with only Accounts and the Website gets both. Every product's release is
|
||||
# checked before anything changes; each product takes its own backup; the first failure stops the
|
||||
# rest and says which products are now out of step.
|
||||
cmd_demo_scenario() {
|
||||
local church="$1" scenario="$2" email="${3:-}" p q v min seen
|
||||
local -a todo=() skipped=() loaded=() behind=()
|
||||
require_root
|
||||
load_church "$church"
|
||||
for p in "${PRODUCT_ORDER[@]}"; do
|
||||
if church_has_product "$p"; then todo+=("$p"); else skipped+=("$p"); fi
|
||||
done
|
||||
[ "${#todo[@]}" -gt 0 ] || die "$church has no products on this server."
|
||||
|
||||
step "Demo scenario $scenario: checking ${todo[*]}"
|
||||
[ "${#skipped[@]}" -eq 0 ] || info "Not installed, so skipped: ${skipped[*]}"
|
||||
for p in "${todo[@]}"; do
|
||||
# The App and its demo come with App 1.0.0 (scripts/products/app.sh).
|
||||
[ "$p" != app ] || die "The Church App's demo data comes with App 1.0.0 (this crosscode has none yet). Nothing was changed."
|
||||
# shellcheck source=/dev/null
|
||||
source "$CROSSCODE_HOME/products/$p.sh"
|
||||
v="$("${p}_expected_version" "$(pvar "$p" DIR)" 2>/dev/null || true)"
|
||||
min="$(scenario_min_version "$p")"
|
||||
version_ge "${v:-0.0.0}" "$min" ||
|
||||
die "$(product_title "$p") is ${v:-unknown} here: a demo scenario needs $min or later. Deploy it first; nothing was changed."
|
||||
done
|
||||
|
||||
for p in "${todo[@]}"; do
|
||||
# Each in a subshell: its die stops only that product, so the summary below can say what's
|
||||
# out of step.
|
||||
if ! (
|
||||
case "$p" in
|
||||
accounts) cmd_demo_accounts "$church" "$scenario" ;;
|
||||
events) cmd_demo_events "$church" "$scenario" "$email" ;;
|
||||
website) cmd_demo_website "$church" "$scenario" "$scenario" ;;
|
||||
esac
|
||||
); then
|
||||
seen=0
|
||||
for q in "${todo[@]}"; do [ "$q" = "$p" ] && seen=1; [ "$seen" = 1 ] && behind+=("$q"); done
|
||||
report_result loaded "${loaded[*]}"
|
||||
report_result skipped "${skipped[*]}"
|
||||
die "$(product_title "$p")'s demo failed (see above), so the scenario stopped. Loaded: ${loaded[*]:-none}. Out of step with $scenario: ${behind[*]}. Load the scenario again once it's fixed."
|
||||
fi
|
||||
loaded+=("$p")
|
||||
done
|
||||
report_result loaded "${loaded[*]}"
|
||||
report_result skipped "${skipped[*]}"
|
||||
step "Demo scenario $scenario loaded: ${loaded[*]}${skipped[*]:+ (not installed: ${skipped[*]})}"
|
||||
}
|
||||
|
||||
# Accounts' part of a demo scenario (Accounts 1.9.0+, backend/scripts/demo.ts): the scenario's
|
||||
# church profile (with its logo and icon) and its people; real people and admins stay. Backup first;
|
||||
# Accounts tells the linked products the church changed. Loaded before the other products'.
|
||||
@@ -201,7 +287,8 @@ cmd_demo_accounts() {
|
||||
# the eight demo churches, keeping the church's profile, the site settings and the admins. Backup
|
||||
# first; then reloaded, so nothing cached from before is shown.
|
||||
cmd_demo_website() {
|
||||
local church="$1" profile="$2" dir user app
|
||||
local church="$1" profile="$2" scenario="${3:-}" dir user app
|
||||
local -a scenario_args=()
|
||||
require_root
|
||||
load_church "$church"
|
||||
church_has_product website || die "$church has no Church Website."
|
||||
@@ -211,12 +298,18 @@ cmd_demo_website() {
|
||||
user="$(pvar website USER)"
|
||||
app="$(website_app "$dir")"
|
||||
[ -f "$app/backend/src/demo/seeds.ts" ] || die "This release of the Website ($(checkout_ref "$dir" website)) has no demo profiles (1.3.0 or later has)."
|
||||
if [ -n "$scenario" ]; then
|
||||
# 1.8.0: the scenario's people lead, and Cross Events' events show through the feed.
|
||||
grep -q scenarioTeam "$app/backend/src/demo/seeds.ts" ||
|
||||
die "This release of the Website ($(checkout_ref "$dir" website)) has no demo scenarios (1.8.0 or later has)."
|
||||
scenario_args=(--scenario "$scenario")
|
||||
fi
|
||||
|
||||
step "Website: backup first"
|
||||
website_backup "$dir" "$user" || die "The backup failed, so the demo wasn't loaded."
|
||||
|
||||
step "Website: demo ($profile)"
|
||||
run_as "$user" "$app/backend" npm run --silent demo -- --profile "$profile" --force ||
|
||||
run_as "$user" "$app/backend" npm run --silent demo -- --profile "$profile" "${scenario_args[@]+"${scenario_args[@]}"}" --force ||
|
||||
die "The demo wasn't loaded (see above). If it got as far as changing anything, the backup from just now has the content from before."
|
||||
|
||||
step "Website: reloading PM2"
|
||||
|
||||
@@ -17,10 +17,11 @@ website_expected_version() {
|
||||
node -p 'require(process.argv[1]).version' "$(website_app "$1")/backend/package.json"
|
||||
}
|
||||
|
||||
# The shared packages the Website is built with (contracts, auth-client for signing in, ui and seo for its pages).
|
||||
# The shared packages the Website is built with (contracts, auth-client for signing in, ui and seo for its pages,
|
||||
# 1.8.0: demo for the demo scenarios).
|
||||
website_shared_packages() {
|
||||
local p
|
||||
for p in packages/contracts packages/ui packages/auth-client packages/seo; do
|
||||
for p in packages/contracts packages/ui packages/auth-client packages/seo packages/demo; do
|
||||
[ -f "$1/$p/package.json" ] && printf '%s\n' "$p"
|
||||
done
|
||||
}
|
||||
@@ -54,7 +55,7 @@ website_migrate() {
|
||||
|
||||
website_build() {
|
||||
local p
|
||||
for p in packages/contracts packages/auth-client packages/seo; do
|
||||
for p in packages/contracts packages/auth-client packages/seo packages/demo; do
|
||||
[ ! -f "$1/$p/package.json" ] || run_as "$2" "$1/$p" npm run build || return 1
|
||||
done
|
||||
run_as "$2" "$(website_app "$1")/backend" npm run build &&
|
||||
|
||||
+75
-6
@@ -18,7 +18,7 @@ setup() {
|
||||
mkdir -p "$CROSSCODE_HOME/products" "$TMP/sites/hope/events/apps/events/backend/scripts"
|
||||
touch "$TMP/sites/hope/events/apps/events/backend/scripts/set-demo.js"
|
||||
mkdir -p "$TMP/sites/hope/website/apps/website/backend/src/demo"
|
||||
touch "$TMP/sites/hope/website/apps/website/backend/src/demo/seeds.ts"
|
||||
echo "scenarioTeam" > "$TMP/sites/hope/website/apps/website/backend/src/demo/seeds.ts"
|
||||
mkdir -p "$TMP/sites/hope/accounts/apps/accounts/backend/scripts"
|
||||
touch "$TMP/sites/hope/accounts/apps/accounts/backend/scripts/demo.ts"
|
||||
cat > "$CROSSCODE_HOME/products/accounts.sh" <<EOF3
|
||||
@@ -26,29 +26,30 @@ accounts_app() { printf '%s/apps/accounts' "\$1"; }
|
||||
accounts_backup() { echo "backup \$2" >> "$CALLS"; [ -z "\${FAIL_BACKUP:-}" ]; }
|
||||
accounts_reload() { echo "reload \$2" >> "$CALLS"; }
|
||||
accounts_health_url() { echo http://127.0.0.1:5200/api/health; }
|
||||
accounts_expected_version() { echo 1.9.0; }
|
||||
accounts_expected_version() { echo \${ACCOUNTS_VERSION:-1.9.0}; }
|
||||
EOF3
|
||||
cat > "$CROSSCODE_HOME/products/website.sh" <<EOF2
|
||||
website_app() { printf '%s/apps/website' "\$1"; }
|
||||
website_backup() { echo "backup \$2" >> "$CALLS"; [ -z "\${FAIL_BACKUP:-}" ]; }
|
||||
website_reload() { echo "reload \$2" >> "$CALLS"; }
|
||||
website_health_url() { echo http://127.0.0.1:5300/api/health; }
|
||||
website_expected_version() { echo 1.3.0; }
|
||||
website_expected_version() { echo \${WEBSITE_VERSION:-1.3.0}; }
|
||||
EOF2
|
||||
cat > "$CROSSCODE_HOME/products/events.sh" <<EOF
|
||||
events_app() { printf '%s/apps/events' "\$1"; }
|
||||
events_backup() { echo "backup \$2" >> "$CALLS"; [ -z "\${FAIL_BACKUP:-}" ]; }
|
||||
events_reload() { echo "reload \$2" >> "$CALLS"; }
|
||||
events_health_url() { echo http://127.0.0.1:20001/health; }
|
||||
events_expected_version() { echo 2.4.1; }
|
||||
events_expected_version() { echo \${EVENTS_VERSION:-2.4.1}; }
|
||||
EOF
|
||||
require_root() { :; }
|
||||
load_church() { [ "$1" = hope ] || die "There's no church $1 here."; }
|
||||
church_has_product() { [ "$1" = events ] || [ "$1" = website ] || [ "$1" = accounts ]; }
|
||||
HAS="${HAS:-events website accounts}"
|
||||
church_has_product() { [[ " $HAS " == *" $1 "* ]]; }
|
||||
pvar() { case "$2" in DIR) echo "$TMP/sites/hope/$1" ;; USER) echo "cc-hope-$1" ;; esac; }
|
||||
checkout_ref() { echo "$2@1.0.0"; }
|
||||
wait_for_version() { echo "wait $2" >> "$CALLS"; }
|
||||
run_as() { local user="$1" dir="$2"; shift 2; echo "run $user ${dir#"$TMP"/} $*" >> "$CALLS"; [ -z "${FAIL_SEED:-}" ]; }
|
||||
run_as() { local user="$1" dir="$2"; shift 2; echo "run $user ${dir#"$TMP"/} $*" >> "$CALLS"; [ -z "${FAIL_SEED:-}" ] && [ "$user" != "${FAIL_USER:-}" ]; }
|
||||
}
|
||||
|
||||
@test "the profile and admin email are checked before anything else" {
|
||||
@@ -156,6 +157,28 @@ wait 1.9.0" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "website 1.8.0: --scenario is passed on, and only to a release that has scenarios" {
|
||||
run cmd_demo hope website --profile bold-youth --scenario bold-youth
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$(cat "$CALLS")" == *"npm run --silent demo -- --profile bold-youth --scenario bold-youth --force"* ]]
|
||||
: > "$CALLS"
|
||||
: > "$TMP/sites/hope/website/apps/website/backend/src/demo/seeds.ts"
|
||||
run cmd_demo hope website --profile bold-youth --scenario bold-youth
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"no demo scenarios"* ]]
|
||||
[ ! -s "$CALLS" ]
|
||||
run cmd_demo hope website --profile bold-youth
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$(cat "$CALLS")" == *"demo -- --profile bold-youth --force"* ]]
|
||||
}
|
||||
|
||||
@test "the App's demo (agent 1.7.0 sends it) is refused clearly until App 1.0.0" {
|
||||
run cmd_demo hope app --profile community-family --scenario community-family
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"comes with App 1.0.0"* ]]
|
||||
[ ! -s "$CALLS" ]
|
||||
}
|
||||
|
||||
@test "a failed Accounts demo isn't followed by a reload" {
|
||||
FAIL_SEED=1 run cmd_demo hope accounts --profile clean-modern
|
||||
[ "$status" -eq 1 ]
|
||||
@@ -167,3 +190,49 @@ wait 1.9.0" ]
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$(cat "$CALLS")" == *"node scripts/set-demo.js --profile=clean-campus --yes"* ]]
|
||||
}
|
||||
|
||||
@test "seed-scenario: only Accounts and the Website installed, both loaded in order, the rest skipped" {
|
||||
HAS="accounts website" WEBSITE_VERSION=1.8.0 run cmd_demo hope --scenario bold-youth
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(grep '^run' "$CALLS")" = "run cc-hope-accounts sites/hope/accounts/apps/accounts/backend npm run --silent demo -- --profile bold-youth --force
|
||||
run cc-hope-website sites/hope/website/apps/website/backend npm run --silent demo -- --profile bold-youth --scenario bold-youth --force" ]
|
||||
[[ "$output" == *"Not installed, so skipped: events app"* ]]
|
||||
[[ "$(cat "$CALLS")" != *"cc-hope-events"* ]]
|
||||
}
|
||||
|
||||
@test "seed-scenario: every product the church has, Accounts, Events, then the Website" {
|
||||
EVENTS_VERSION=3.8.0 WEBSITE_VERSION=1.8.0 run cmd_demo hope --scenario clean-campus --admin-email jane@hope.test
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(grep '^run' "$CALLS" | cut -d' ' -f2)" = "cc-hope-accounts
|
||||
cc-hope-events
|
||||
cc-hope-website" ]
|
||||
[[ "$(cat "$CALLS")" == *"DEMO_ADMIN_EMAIL=jane@hope.test node scripts/set-demo.js --profile=clean-campus --yes"* ]]
|
||||
}
|
||||
|
||||
@test "seed-scenario: a release too old for scenarios stops it before anything changes" {
|
||||
EVENTS_VERSION=3.7.2 WEBSITE_VERSION=1.8.0 run cmd_demo hope --scenario bold-plant
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Cross Events is 3.7.2 here: a demo scenario needs 3.8.0 or later"* ]]
|
||||
[ ! -s "$CALLS" ]
|
||||
}
|
||||
|
||||
@test "seed-scenario: the first failure stops the rest and says what's out of step" {
|
||||
EVENTS_VERSION=3.8.0 WEBSITE_VERSION=1.8.0 FAIL_USER=cc-hope-events run cmd_demo hope --scenario bold-plant
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Cross Events's demo failed"* ]]
|
||||
[[ "$output" == *"Loaded: accounts. Out of step with bold-plant: events website"* ]]
|
||||
[[ "$(cat "$CALLS")" != *"cc-hope-website"* ]]
|
||||
}
|
||||
|
||||
@test "seed-scenario: an App installed is refused (its demo comes with App 1.0.0), nothing changed" {
|
||||
HAS="accounts app" run cmd_demo hope --scenario bold-plant
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"comes with App 1.0.0"* ]]
|
||||
[ ! -s "$CALLS" ]
|
||||
}
|
||||
|
||||
@test "seed-scenario: a known scenario only" {
|
||||
run cmd_demo hope --scenario nowhere
|
||||
[ "$status" -eq 1 ]
|
||||
[ ! -s "$CALLS" ]
|
||||
}
|
||||
|
||||
@@ -48,6 +48,17 @@ checkout() {
|
||||
[ "$(cut -d'|' -f2 "$CALLS" | tr '\n' ' ')" = "new/packages/contracts new/packages/auth-client new/packages/seo new/apps/website/backend new/apps/website/frontend " ]
|
||||
}
|
||||
|
||||
@test "1.8.0: demo is installed and built too (after contracts), where the release has it" {
|
||||
checkout new
|
||||
mkdir -p "$TMP/new/packages/demo"
|
||||
echo '{"name":"@crosscode/demo"}' > "$TMP/new/packages/demo/package.json"
|
||||
website_install_deps "$TMP/new" hope
|
||||
grep -qx 'hope|new|npm ci --include=dev --no-audit --no-fund --include-workspace-root -w packages/contracts -w packages/ui -w packages/auth-client -w packages/seo -w packages/demo -w apps/website/backend -w apps/website/frontend' "$CALLS"
|
||||
: > "$CALLS"
|
||||
website_build "$TMP/new" hope
|
||||
[ "$(cut -d'|' -f2 "$CALLS" | tr '\n' ' ')" = "new/packages/contracts new/packages/auth-client new/packages/seo new/packages/demo new/apps/website/backend new/apps/website/frontend " ]
|
||||
}
|
||||
|
||||
@test "ports default to 5300 / 3300, else church.env's" {
|
||||
[ "$(website_api_port)" = 5300 ]
|
||||
[ "$(website_web_port)" = 3300 ]
|
||||
|
||||
Reference in New Issue
Block a user