Merge branch 'release/2.0' (2.0.0: release commit)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -5,7 +5,12 @@ versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
Hub 2.0.0, Cross Code Hub, in steps (`docs/HUB-2.0-PLAN.md`).
|
||||
## [2.0.0] - 2026-11-05
|
||||
|
||||
**Cross Code Hub**: every product a church has — Cross Events, Accounts, Church Website, Church App —
|
||||
in one place (ROADMAP-v3 phase 1; built in steps, `docs/HUB-2.0-PLAN.md`). **Before deploying, see
|
||||
`deployment.md` → "Upgrading to 2.0"** (run `check-hub2` first). Cross Events 2.1.x installs keep
|
||||
working unchanged (protocol 1). Protocol 2 is described in `docs/hub-protocol.md` §6.
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
# Cross Events Hub
|
||||
# Cross Code Hub
|
||||
|
||||
Joshua's central management app for every **Cross Events** install: customers, licences,
|
||||
install health and usage, and alerts. Customers never log in here.
|
||||
Joshua's central management app for every Cross Code product a church has — **Cross Events**,
|
||||
**Accounts**, the **Church Website** and the **Church App**: customers, a licence per product,
|
||||
releases per product, install health and usage, AI, billing and alerts. Customers never log in here.
|
||||
(Until 2.0 this was the Cross Events Hub; the plan for 2.0 is `docs/HUB-2.0-PLAN.md`, and the
|
||||
roadmap is `hope-events/docs/ROADMAP-v3.md`.)
|
||||
|
||||
> **Naming:** Cross Events was called **Hope Events** until October 2026. Older commits, the
|
||||
> `hope-events` repo name and the `hel1.` licence-token prefix still use the old name. The
|
||||
> prefix is part of the protocol, so it stays.
|
||||
> `events-hub` repo name, the `CEH-` licence-key prefix and the `hel1.` licence-token prefix still
|
||||
> use the old names. The prefixes are part of the protocol, so they stay.
|
||||
|
||||
- `backend/` — Express + Prisma (Postgres) API, port 5200
|
||||
- `frontend/` — Next.js dashboard, port 3200
|
||||
- `docs/hub-protocol.md` — the contract with Cross Events installs (a copy lives in the
|
||||
`hope-events` repo; change both together)
|
||||
- `docs/hub-protocol.md` — the contract with installs, protocol 1 (Cross Events 2.1) and 2 (every
|
||||
product); a copy lives in the `hope-events` repo, and the v2 formats are in `@crosscode/contracts`
|
||||
- `backend/vendor/crosscode-contracts-<version>.tgz` — the shared formats, committed so deploys
|
||||
need no package registry. To update: `npm pack` in `crosscode-platform/packages/contracts` at its
|
||||
new tag, put the file here, `npm install --save file:vendor/<file>` in `backend`, remove the old file
|
||||
|
||||
**Products** (Hub 2.0): every licence and install is for one product. A church has at most one
|
||||
licence per product that isn't revoked; generating its first product licence also makes its free
|
||||
Accounts licence. Keys: `CEH-` Events, `CCA-` Accounts, `CCW-` Website, `CCP-` App.
|
||||
|
||||
Installs only ever call the Hub (register, heartbeat); the Hub never reaches into an install
|
||||
and holds no church data — just versions, health and aggregate counts.
|
||||
@@ -41,28 +51,34 @@ and `HUB_PUBLIC_KEY` (the public key shown in Hub → Settings) in Cross Events'
|
||||
|
||||
## Releases and notices
|
||||
|
||||
- **Releases** come from git: every `v1.2.3` tag of `joshua/hope-events` is a release, the newest is
|
||||
the latest version, and the notes churches see come from `WHATS-NEW.md` on that repo's default branch (only for
|
||||
tagged versions, so notes can be written ahead or corrected later). The Hub checks every 15 minutes (and on **Sync now**, Releases page). So releasing
|
||||
Cross Events is: write the version's section in `WHATS-NEW.md`, tag, push — installs see the
|
||||
update with their next heartbeat.
|
||||
- **Releases** come from git, per product (Releases page → Release sources): each source is a
|
||||
repository, a tag prefix and a notes file. By default every product comes from
|
||||
`joshua/crosscode-platform` (`events@1.2.3`, `accounts@…`, `website@…`, `app@…`, notes in
|
||||
`apps/<product>/WHATS-NEW.md`), and Cross Events before the move also from `joshua/hope-events`
|
||||
(`v1.2.3`, `WHATS-NEW.md`). A product's newest tag is its latest version; notes show for tagged
|
||||
versions only (so they can be written ahead or corrected later). A heading like
|
||||
`## 3.0.0 — requires accounts 1.2.0` makes Request update wait until the church's Accounts is new
|
||||
enough. The Hub checks every 15 minutes (and on **Sync now**); an unreachable source never removes
|
||||
releases. So releasing is: write the version's section in the notes file, tag, push — that
|
||||
product's installs see the update with their next heartbeat.
|
||||
- **Notices** (Notices page) are banners on churches' sites for their admins and supervisors, emails
|
||||
to them, or both — e.g. planned maintenance.
|
||||
|
||||
## AI (Cross Events 2.0)
|
||||
## AI
|
||||
|
||||
Sites call AI through the Hub (protocol §3b), so the Claude API key never leaves this server.
|
||||
Set it up in **Settings → AI**: the key, the model (Claude Sonnet 5.5 by default; choosing one from the
|
||||
list fills in its prices, kept in `backend/src/utils/aiModels.js` — update that list in a release when
|
||||
Anthropic's prices change), the exchange rate and the default markup — AI stays off for every site
|
||||
until the key and exchange rate are saved;
|
||||
**Test the saved key** checks them. Each licence has a monthly **AI cap** in rand (0 = off) and an
|
||||
optional markup override, on the customer's page. The cap counts what the church is charged
|
||||
(real cost plus markup); the Hub checks the worst case before every call, so a month can't run over.
|
||||
**Test the saved key** checks them. Each church has a monthly **AI cap** in rand (0 = off) and an
|
||||
optional markup override, on the customer's page, shared by all its sites (Hub 2.0). The cap counts
|
||||
what the church is charged (real cost plus markup); the Hub checks the worst case before every call,
|
||||
so a month can't run over.
|
||||
Use per site (real cost, charged, profit) is on Settings → AI and on each install's page. No prompt
|
||||
or response text is stored.
|
||||
|
||||
## Billing (1.7.0)
|
||||
## Billing
|
||||
|
||||
Invoices, receipts, statements and notices of licence change, each emailed (styled HTML) with a PDF.
|
||||
The code is in `backend/src/utils/billing/` (`compute.js` the rules, `pdf.js` the documents, `email.js`
|
||||
@@ -117,7 +133,9 @@ installs check licences with the public key, which is built into Cross Events
|
||||
|
||||
## Deploying
|
||||
|
||||
Same pattern as Cross Events: on the server (`events-hub.crosscode.co.za`), behind nginx with
|
||||
See `deployment.md` (and its "Upgrading to 2.0" before deploying 2.0 the first time). In short: the
|
||||
same pattern as Cross Events: on the server (`events-hub.crosscode.co.za`, with `hub.crosscode.co.za`
|
||||
as the new address), behind nginx with
|
||||
HTTPS, two PM2 processes (`backend`: `npm start`; `frontend`: `npm run build && npm start`),
|
||||
`TRUST_PROXY=1`, `FRONTEND_URL=https://events-hub.crosscode.co.za`, and the frontend's
|
||||
`NEXT_PUBLIC_API_URL` set to the public API address (e.g. `https://events-hub.crosscode.co.za`
|
||||
@@ -126,4 +144,7 @@ with nginx routing `/api` to port 5200). Back up the database daily, plus the si
|
||||
## Tests
|
||||
|
||||
`cd backend && npm test` — encryption, licence tokens, request signatures, two-factor codes
|
||||
(RFC 6238 vector) and alert rules.
|
||||
(RFC 6238 vector), alert rules, products and licences, protocol v1 and v2 (every contract sample
|
||||
through the routes), releases per product and requirements, billing (prices, bundles, add-ons,
|
||||
prorating, the address, monthly recurring revenue) and AI. `cd frontend && npx eslint src` and
|
||||
`npx tsc --noEmit` check the dashboard.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^1.3.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"private": true,
|
||||
"description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats",
|
||||
"main": "src/index.js",
|
||||
|
||||
@@ -368,6 +368,31 @@ From then on the checkout is detached, so use the script rather than `git pull`.
|
||||
|
||||
Installs keep working while the Hub is briefly down (licences are valid offline for 30 days).
|
||||
|
||||
### Upgrading to 2.0 (Cross Code Hub)
|
||||
|
||||
2.0 changes the database a lot (products, releases per product, billing per church, the church's
|
||||
address, AI per church). The migrations carry everything over, but one thing has to be right first.
|
||||
|
||||
1. **Check first** (changes nothing): from the new checkout, before deploying,
|
||||
```bash
|
||||
git fetch --tags && git checkout v2.0.0 -- backend/scripts/check-hub2.js
|
||||
(cd backend && node scripts/check-hub2.js)
|
||||
git checkout -- backend/scripts/check-hub2.js 2>/dev/null || rm -f backend/scripts/check-hub2.js
|
||||
```
|
||||
It lists any church with two licences that aren't revoked. 2.0 allows one licence per product
|
||||
per church, so the migration would stop on them (naming them, and the deploy rolls back). Revoke
|
||||
the one that isn't used, then deploy.
|
||||
2. **Deploy** as usual: `bash scripts/deploy.sh v2.0.0`. Cross Events installs on 2.1.x keep
|
||||
working unchanged (protocol 1).
|
||||
3. **After deploying**: each billed licence's schedule is now its church's (customer page →
|
||||
Billing → Billing schedule); check one or two churches' **Next invoice**. Releases sync from the
|
||||
default sources (Releases page): Cross Events from `crosscode-platform` (`events@…`) and from
|
||||
`hope-events` (`v…`) as before.
|
||||
4. **The new address `hub.crosscode.co.za`** (optional, any time): add it to DNS and frp the same
|
||||
way as `events-hub.crosscode.co.za` (steps 2–3), add it as an alias of the site in FASTPANEL with
|
||||
its certificate (step 5), add it to `FRONTEND_URL` only if you move the dashboard to it, and keep
|
||||
`events-hub.crosscode.co.za` working: installs point at it (`HUB_URL`) until they're updated.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# Hub 2.0.0 — plan
|
||||
|
||||
**Done:** all eight steps, released as **2.0.0** on 2026-11-05 (CHANGELOG.md). Before deploying it the
|
||||
first time, see `deployment.md` → "Upgrading to 2.0". Step 7 also added the install page's list of
|
||||
the church's other products; step 4 added the next-invoice preview planned for step 7.
|
||||
|
||||
Cross Events Hub becomes **Cross Code Hub**: every product's customers, licences, stats, AI and
|
||||
billing in one place (ROADMAP-v3 §5, phase 1, in `hope-events/docs/ROADMAP-v3.md`). Planned
|
||||
2026-11-04. Each step is its own branch (`feat/hub2-<step>`), merged with its tests into
|
||||
|
||||
+42
-5
@@ -1,9 +1,13 @@
|
||||
# Hub protocol (version 1)
|
||||
# Hub protocol (versions 1 and 2)
|
||||
|
||||
The contract between a **Cross Events install** (the church's site) and the **Cross Events
|
||||
Hub** (`events-hub.crosscode.co.za`). A copy of this file lives in both repositories
|
||||
(`joshua/hope-events` → `docs/hub-protocol.md`, `joshua/events-hub` → `docs/hub-protocol.md`);
|
||||
change both together.
|
||||
The contract between an **install** (one of a church's products: Cross Events, Accounts, Church
|
||||
Website, Church App) and **Cross Code Hub** (`hub.crosscode.co.za`; `events-hub.crosscode.co.za`
|
||||
keeps working as an alias). Sections 1–5 describe **version 1**, which Cross Events 2.1 speaks;
|
||||
**[version 2](#6-protocol-version-2-hub-20)** (every product, Hub 2.0) is section 6. A copy of this
|
||||
file lives in both repositories (`joshua/hope-events` → `docs/hub-protocol.md`,
|
||||
`joshua/events-hub` → `docs/hub-protocol.md`); change both together. From Hub 2.0 the formats are
|
||||
defined once, in `@crosscode/contracts` (`crosscode-platform/packages/contracts`, `src/hub.ts`,
|
||||
with JSON Schema and samples).
|
||||
|
||||
Principles:
|
||||
|
||||
@@ -288,3 +292,36 @@ grace starts). Blocking the Hub can't keep a suspended licence active for more t
|
||||
fields to a heartbeat or a token doesn't need a new version — both sides ignore fields they
|
||||
don't know.
|
||||
- The Hub accepts protocol `N` and `N-1`; anything else is `400 UNSUPPORTED_PROTOCOL`.
|
||||
|
||||
## 6. Protocol version 2 (Hub 2.0)
|
||||
|
||||
The formats are in `@crosscode/contracts` (`hub.registerRequestSchema`, `hub.heartbeatRequestSchema`,
|
||||
… with JSON Schema in `schemas/hub-*.json` and samples in `samples/hub-*.json`). The Hub accepts
|
||||
versions 1 and 2 (`/api/public-key` lists `[1, 2]`); a v1 request is treated as Cross Events and
|
||||
answered exactly as in sections 1–5. Signing, offline licence checks, update requests and AI calls
|
||||
are as in version 1.
|
||||
|
||||
What version 2 changes:
|
||||
|
||||
| | Version 1 | Version 2 |
|
||||
|---|---|---|
|
||||
| Who | Cross Events | Every product: `product` is `events`, `accounts`, `website` or `app` |
|
||||
| Licence keys | `CEH-…` | `CEH-` Events, `CCA-` Accounts, `CCW-` Website, `CCP-` App |
|
||||
| Register | as §2 | adds `product` (must match the licence: `409 WRONG_PRODUCT`) and `install.publicKey` (the install's Ed25519 public key, PEM) |
|
||||
| Heartbeat | as §3 | adds `product` (must match the install: `409 WRONG_PRODUCT`); `stats` per product (Events as v1; Website: pages, messages, events, editors, `storage`; App: `activeMembers90d` band, modules, prayer coverage; Accounts: accounts, 2FA methods) |
|
||||
| Replies | as §2, §3 | add `linkedProducts`: the church's other installs in use that have a public key, as `{ product, installId, url, publicKey }`, nothing else. Releases carry `requires` (below) |
|
||||
| Bodies | checked by hand | checked against the contract schemas: `400 INVALID_REQUEST` with the field that's wrong; unknown fields are dropped |
|
||||
| Licence token | as §4 | also `customerId` and `product` (still `v: 1`; a v1 install ignores them). `limits.aiMonthlyCapCents` is the church's cap |
|
||||
|
||||
**Releases per product.** An install is told its own product's releases and latest version. A
|
||||
release can need a minimum version of a sibling (`— requires accounts 1.2.0` in its WHATS-NEW.md
|
||||
heading): v2 replies carry it as `requires: [{ product, version }]`, and an update request answers
|
||||
`409 REQUIREMENT_NOT_MET` (with `requirements: [{ product, version, current }]` and a message saying
|
||||
what's needed) until the church's install of that product runs that version or later.
|
||||
|
||||
**AI.** The monthly cap and markup are the church's, shared by all its installs: a call from any of
|
||||
them counts what all of them used this month.
|
||||
|
||||
**Moving an install to v2** (e.g. Cross Events 2.4.0): register again with `protocolVersion: 2`,
|
||||
the product and a public key (same licence and address: same install id, new secret), then send v2
|
||||
heartbeats. Nothing on the Hub needs changing.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-frontend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.536.0",
|
||||
"next": "^15.5.24",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3200",
|
||||
|
||||
Reference in New Issue
Block a user