Hub 2.0 step 1: products foundation

- Product enum (events, accounts, website, app) on Licence and Install,
  Install.publicKey; existing rows are events
- One open licence per product per customer: partial unique index, with a
  migration guard that names customers with duplicates (npm run check:hub2
  lists them beforehand)
- Licence keys per product (CEH-, CCA-, CCW-, CCP-); free Accounts licence
  created with the first other product licence
- Protocol v1 registers Events licences only (409 WRONG_PRODUCT); only Events
  licences can be invoiced until billing per customer
- Cross Code Hub in the UI, emails and PDFs
- @crosscode/contracts 1.0.0 vendored (backend/vendor)
- Steps merge into release/2.0, not main (plan updated)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:28:06 +02:00
co-authored by Claude Opus 5.5
parent fe0f2638c6
commit ad602b2846
30 changed files with 544 additions and 49 deletions
+23
View File
@@ -0,0 +1,23 @@
// The Cross Code products (Hub 2.0). The same list as backend/src/utils/products.js.
export type Product = "events" | "accounts" | "website" | "app";
export const PRODUCTS: Product[] = ["events", "accounts", "website", "app"];
export const PRODUCT_NAMES: Record<Product, string> = {
events: "Cross Events",
accounts: "Accounts",
website: "Church Website",
app: "Church App",
};
/** Where the church enters a licence key, per product. */
export const KEY_WHERE: Record<Product, string> = {
events: "the church's Cross Events setup (or Site settings → Licence)",
accounts: "the church's Accounts setup",
website: "the church's Website setup",
app: "the church's App setup",
};
/** Product order for lists: Events, Accounts, Website, App. */
export const byProduct = <T extends { product: Product }>(a: T, b: T) => PRODUCTS.indexOf(a.product) - PRODUCTS.indexOf(b.product);
+5 -1
View File
@@ -1,8 +1,11 @@
import type { Product } from "./products";
export type Problem = { type: string; level: "info" | "warning" | "critical"; message: string };
export type LicenceStatus = "active" | "suspended" | "revoked";
export type InstallSummary = {
id: string;
product: Product;
name: string;
url: string;
customer: { id: string; name: string } | null;
@@ -18,6 +21,7 @@ export type InstallSummary = {
export type Licence = {
id: string;
key: string;
product: Product;
plan: string;
status: LicenceStatus;
expiresAt: string | null;
@@ -38,7 +42,7 @@ export type Customer = {
notes: string | null;
createdAt: string;
licences: Licence[];
installs: { id: string; url: string; name?: string; lastHeartbeatAt: string | null; releasedAt?: string | null; version?: string | null }[];
installs: { id: string; product: Product; url: string; name?: string; lastHeartbeatAt: string | null; releasedAt?: string | null; version?: string | null }[];
};
export type Health = {