Events 3.3.0, Accounts 1.3.0, contracts 1.11.0: Accounts looks like Events, backups; sign-out and upload fixes

- Accounts: account and admin pages in Cross Events' layout (top bar, sidebar,
  a page per section, dark footer); quick links to the church's sites
  (GET /me/apps); nightly pg_dump backups with Admin -> Backups (run, keep,
  download, audited; heartbeat lastBackupAt); a fuller built-in privacy notice
  with headings and bullets; a fixed favicon. /backups/ ignored (anchored, so
  src/backups is kept).
- Contracts 1.11.0: people.removeDemo (only @example.com, never an admin).
- Events: uploads served from the folder they're saved in (a backend started
  outside backend/ answered 404 for a logo it had just saved); Branding checks
  the file loads before saving; logout waits for the sign-out call so Accounts
  signs out too; set-demo removes the last demo's people from Accounts.
Tests: Accounts 62 + e2e 8, Events 782, contracts 225; npm run check passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 11:19:57 +02:00
co-authored by Claude Opus 5.5
parent 8ee64bb9c9
commit 8856d6b35d
61 changed files with 1514 additions and 162 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/contracts",
"version": "1.10.0",
"version": "1.11.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",
@@ -0,0 +1,5 @@
{
"schema": "crosscode.identity-request/1",
"removed": 1,
"kept": [{ "sub": "7c3d4e5f-6a7b-4c8d-8e9f-1a2b3c4d5e6f", "reason": "not_demo" }]
}
@@ -0,0 +1,7 @@
{
"schema": "crosscode.identity-request/1",
"actor": "8d2e4f6a-1b3c-4d5e-8f7a-9b0c1d2e3f4a",
"requestId": "5a1c2d3e-4f5a-4b6c-8d7e-9f0a1b2c3d4e",
"type": "people.removeDemo",
"subs": ["6b2c3d4e-5f6a-4b7c-9d8e-0f1a2b3c4d5e", "7c3d4e5f-6a7b-4c8d-8e9f-1a2b3c4d5e6f"]
}
@@ -810,6 +810,52 @@
"channel"
]
},
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity-request/1"
},
"requestId": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"actor": {
"anyOf": [
{
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
{
"type": "null"
}
]
},
"type": {
"type": "string",
"const": "people.removeDemo"
},
"subs": {
"maxItems": 1000,
"type": "array",
"items": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
}
},
"required": [
"schema",
"requestId",
"actor",
"type",
"subs"
]
},
{
"type": "object",
"properties": {
@@ -0,0 +1,47 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/people-remove-demo-reply.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity-request/1"
},
"removed": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"kept": {
"maxItems": 1000,
"type": "array",
"items": {
"type": "object",
"properties": {
"sub": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"reason": {
"type": "string",
"enum": [
"not_demo",
"admin",
"unknown"
]
}
},
"required": [
"sub",
"reason"
]
}
}
},
"required": [
"schema",
"removed",
"kept"
]
}
@@ -66,6 +66,7 @@ function contracts(c) {
"people-ensure-reply": c.peopleEnsureReplySchema,
"messaging-status-reply": c.messagingStatusReplySchema,
"messaging-test-reply": c.messagingTestReplySchema,
"people-remove-demo-reply": c.peopleRemoveDemoReplySchema,
};
}
+26 -2
View File
@@ -19,7 +19,8 @@ import { schemaName } from "./schema-name";
* - **`people.*`**: what a product's admin can do to someone's account from the product (add a
* person, change their name or email, reset 2FA, unlock, deactivate, news off from an
* unsubscribe link). Accounts only acts on people the product knows (signed in through it or
* imported by it), and audits each with the product and the admin's `sub`.
* imported by it), and audits each with the product and the admin's `sub`. 1.11.0 adds
* `people.removeDemo`: new demo data in a product removes the old demo people's accounts.
*/
export const IDENTITY_REQUEST_SCHEMA = schemaName("identity-request", 1);
@@ -155,6 +156,21 @@ export const peopleSetActiveSchema = base.extend({ type: z.literal("people.setAc
/** Only ever turns news off (an unsubscribe link); turning it on is the person's own choice in Accounts. */
export const peopleNewsOffSchema = base.extend({ type: z.literal("people.newsOff"), ...onePerson, channel: z.enum(["email", "whatsapp", "all"]) });
/** The one address domain demo people have (RFC 2606: reserved, so no real person has it). */
export const DEMO_EMAIL_DOMAIN = "example.com";
/** Accounts per `people.removeDemo`. */
export const REMOVE_DEMO_MAX = 1000;
/**
* 1.11.0: the product's demo data was replaced (a new demo profile), so the old demo people's
* accounts go too: signed out everywhere and anonymised. Accounts only removes accounts the
* product knows, at `@example.com`, that aren't Accounts admins; it says why it kept any other.
*/
export const peopleRemoveDemoSchema = base.extend({
type: z.literal("people.removeDemo"),
subs: z.array(idSchema).max(REMOVE_DEMO_MAX),
});
// ─── messaging.* (contracts 1.9.0) ───────────────────────────────────────────
/** SMTP settings as Cross Events and Accounts both keep them (`smtp_*`). `pass` sealed; null: keep the saved one. */
@@ -200,7 +216,7 @@ export const churchBrandingSchema = base.extend({ type: z.literal("church.brandi
export const identityRequestSchema = z.discriminatedUnion("type", [
importBeginSchema, importBatchSchema, importFinishSchema, importAbortSchema,
peopleEnsureSchema, peopleUpdateSchema, peopleResetTwoFactorSchema, peopleUnlockSchema, peopleSetActiveSchema, peopleNewsOffSchema,
messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
peopleRemoveDemoSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
]);
export type IdentityRequest = z.infer<typeof identityRequestSchema>;
export type IdentityRequestType = IdentityRequest["type"];
@@ -250,6 +266,14 @@ export const peopleEnsureReplySchema = z.object({
emailSent: z.boolean().optional(),
});
/** people.removeDemo: how many accounts went, and each one kept with why. */
export const peopleRemoveDemoReplySchema = z.object({
schema: z.literal(IDENTITY_REQUEST_SCHEMA),
removed: z.int().nonnegative(),
kept: z.array(z.object({ sub: idSchema, reason: z.enum(["not_demo", "admin", "unknown"]) })).max(REMOVE_DEMO_MAX),
});
export type PeopleRemoveDemoReply = z.infer<typeof peopleRemoveDemoReplySchema>;
export const okReplySchema = z.object({ schema: z.literal(IDENTITY_REQUEST_SCHEMA), ok: z.literal(true) });
/** messaging.status: what's set up (no secrets; `from` and `host` to recognise it). */
@@ -40,6 +40,13 @@ describe("crosscode.identity-request/1", () => {
expect(identityRequestSchema.safeParse({ ...set, email: { ...set.email, settings: { ...set.email.settings, pass: "plain-password" } } }).success).toBe(false);
});
test("people.removeDemo: at most 1000 accounts at a time", () => {
const r = sample<{ subs: string[] }>("people-remove-demo.json");
expect(identityRequestSchema.safeParse(r).success).toBe(true);
expect(identityRequestSchema.safeParse({ ...r, subs: Array.from({ length: 1001 }, () => r.subs[0]) }).success).toBe(false);
expect(identityRequestSchema.safeParse({ ...r, subs: ["not-an-id"] }).success).toBe(false);
});
test("unknown request types are refused", () => {
expect(identityRequestSchema.safeParse({ ...sample("people-ensure.json"), type: "people.delete" }).success).toBe(false);
});
@@ -48,6 +48,8 @@ const SAMPLE_SCHEMA: Record<string, string> = {
"people-ensure-reply.json": "people-ensure-reply",
"messaging-set.json": "identity-request",
"messaging-test-reply.json": "messaging-test-reply",
"people-remove-demo.json": "identity-request",
"people-remove-demo-reply.json": "people-remove-demo-reply",
};
describe("JSON Schema (schemas/)", () => {
+3
View File
@@ -17,6 +17,7 @@ import {
importBatchReplySchema,
peopleEnsureReplySchema,
messagingTestReplySchema,
peopleRemoveDemoReplySchema,
userDeletedReplySchema,
userExportReplySchema,
} from "../src";
@@ -56,6 +57,8 @@ const SCHEMAS: Record<string, z.ZodType> = {
"people-ensure-reply.json": peopleEnsureReplySchema,
"messaging-set.json": identityRequestSchema,
"messaging-test-reply.json": messagingTestReplySchema,
"people-remove-demo.json": identityRequestSchema,
"people-remove-demo-reply.json": peopleRemoveDemoReplySchema,
};
describe("samples", () => {