contracts 1.17.0: brand style, church.update, the Website's export, licence storage limit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 16:25:20 +02:00
co-authored by Claude Opus 5.5
parent 9954e66c33
commit 0e3534f29f
24 changed files with 2326 additions and 12 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/contracts",
"version": "1.16.0",
"version": "1.17.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,171 @@
{
"schema": "crosscode.church-export/1",
"exportedAt": "2026-12-10T12:00:00.000Z",
"product": "website",
"productVersion": "1.0.0",
"church": {
"name": "Grace Demo Church",
"timezone": "Africa/Johannesburg"
},
"people": [
{
"ref": "p1",
"name": "Thandi Example",
"email": "thandi@example.org",
"phone": null,
"role": "editor",
"createdAt": "2026-12-01T08:00:00.000Z",
"consent": {
"email": null,
"whatsapp": null,
"privacyNoticeAcceptedAt": null
}
}
],
"events": [],
"registrations": [],
"payments": [],
"checkIns": [],
"rosters": [],
"settings": {
"coming-soon.line": "Our new website is on its way"
},
"files": [
{
"path": "uploads/media/hero-sunday.jpg",
"bytes": 482113
},
{
"path": "uploads/media/carols.jpg",
"bytes": 203877
}
],
"website": {
"template": "community",
"firstPublishedAt": "2026-12-05T09:00:00.000Z",
"style": {
"sectionColour": "tinted",
"spacing": "airy",
"buttons": "pill",
"imageTreatment": "natural",
"header": "solid"
},
"pages": [
{
"ref": "g1",
"title": "Home",
"path": "/",
"kind": "home",
"inNavigation": true,
"seo": {
"title": null,
"description": "A family church in Meyerton. Join us on Sundays at 09:00."
},
"sections": [
{
"type": "hero",
"variant": "collage",
"hidden": false,
"content": {
"headline": "You belong here",
"images": [
"uploads/media/hero-sunday.jpg"
],
"button": {
"label": "Plan your visit",
"href": "/visit"
}
}
},
{
"type": "service-times",
"variant": "panel",
"hidden": false,
"content": {}
},
{
"type": "latest-message",
"variant": "card",
"hidden": true,
"content": {}
}
]
},
{
"ref": "g2",
"title": "Youth camp",
"path": "/youth-camp",
"kind": "custom",
"inNavigation": false,
"seo": {
"title": "Youth camp 2027",
"description": null
},
"sections": [
{
"type": "text",
"variant": "text",
"hidden": false,
"content": {
"heading": "Youth camp",
"body": "Three days away for grades 8 to 12."
}
}
]
}
],
"messages": [
{
"ref": "m1",
"title": "Hope that holds",
"date": "2026-12-07T07:00:00.000Z",
"speaker": "Pastor Sam Example",
"series": "Advent",
"passage": "Romans 15:13",
"notes": null,
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"source": "youtube-feed",
"hidden": false
}
],
"events": [
{
"ref": "w1",
"title": "Carols by candlelight",
"description": "Bring a blanket.",
"startsAt": "2026-12-20T17:00:00.000Z",
"endsAt": "2026-12-20T19:00:00.000Z",
"location": "The church lawn",
"link": null,
"image": "uploads/media/carols.jpg",
"published": true
}
],
"versions": [
{
"number": 1,
"publishedAt": "2026-12-05T09:00:00.000Z",
"by": "Thandi Example",
"note": "First version"
},
{
"number": 2,
"publishedAt": "2026-12-08T15:30:00.000Z",
"by": "Thandi Example",
"note": null
}
],
"media": [
{
"path": "uploads/media/hero-sunday.jpg",
"alt": "The congregation singing on a Sunday morning",
"caption": null
},
{
"path": "uploads/media/carols.jpg",
"alt": "Candles on the church lawn",
"caption": "Carols 2025"
}
]
}
}
@@ -0,0 +1,81 @@
{
"schema": "crosscode.identity-request/1",
"church": {
"schema": "crosscode.church/1",
"customerId": "c7a1e2d3-4b5c-4d6e-8f70-81a2b3c4d5e6",
"updatedAt": "2026-12-02T10:00:00.000Z",
"name": "Hope Family Church",
"shortName": "Hope Family",
"timezone": "Africa/Johannesburg",
"locale": "en-ZA",
"branding": {
"logoUrl": "https://www.hopefamily.co.za/uploads/logo.png",
"iconUrl": "https://www.hopefamily.co.za/uploads/icon-512.png",
"colours": {
"primary": "#1f4e79",
"accent": "#f2a900"
},
"style": {
"fontPairing": "warm",
"corners": "round"
}
},
"campuses": [
{
"slug": "meyerton",
"name": "Meyerton",
"address": {
"line1": "12 Church Street",
"line2": null,
"suburb": "Meyerton Central",
"city": "Meyerton",
"province": "Gauteng",
"postalCode": "1961",
"country": "ZA",
"geo": {
"lat": -26.5559,
"lng": 28.0141
}
}
}
],
"serviceTimes": [
{
"day": "sunday",
"time": "09:00",
"label": "Morning service",
"campus": "meyerton",
"note": "Kids church during the service"
},
{
"day": "wednesday",
"time": "18:30",
"label": "Prayer evening",
"campus": "meyerton",
"note": null
}
],
"contact": {
"email": "office@hopefamily.co.za",
"phone": "+27161234567",
"whatsapp": "+27821234567",
"address": null
},
"social": [
{
"network": "facebook",
"url": "https://www.facebook.com/hopefamilychurch"
},
{
"network": "youtube",
"url": "https://www.youtube.com/@hopefamilychurch"
}
],
"links": {
"website": "https://www.hopefamily.co.za",
"events": "https://events.hopefamily.co.za",
"app": null,
"accounts": "https://accounts.hopefamily.co.za"
}
}
}
@@ -0,0 +1,31 @@
{
"schema": "crosscode.identity-request/1",
"actor": "6b2c3d4e-5f6a-4b7c-9d8e-0f1a2b3c4d5e",
"requestId": "1f2e3d4c-5b6a-4978-8695-a4b3c2d1e0f9",
"type": "church.update",
"ifUpdatedAt": "2026-11-01T09:00:00.000Z",
"church": {
"branding": {
"style": {
"fontPairing": "warm",
"corners": "round"
}
},
"serviceTimes": [
{
"day": "sunday",
"time": "09:00",
"label": "Morning service",
"campus": "meyerton",
"note": "Kids church during the service"
},
{
"day": "wednesday",
"time": "18:30",
"label": "Prayer evening",
"campus": "meyerton",
"note": null
}
]
}
}
+2 -1
View File
@@ -9,7 +9,8 @@
"branding": {
"logoUrl": "https://www.hopefamily.co.za/uploads/logo.png",
"iconUrl": "https://www.hopefamily.co.za/uploads/icon-512.png",
"colours": { "primary": "#1f4e79", "accent": "#f2a900" }
"colours": { "primary": "#1f4e79", "accent": "#f2a900" },
"style": { "fontPairing": "warm", "corners": "soft" }
},
"campuses": [
{
@@ -0,0 +1,18 @@
{
"v": 1,
"licenceId": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"installId": "6c7d8e9f-0a1b-4c2d-9e3f-4a5b6c7d8e9f",
"customerId": "c7a1e2d3-4b5c-4d6e-8f70-81a2b3c4d5e6",
"product": "website",
"customer": "Hope Family Church",
"plan": "website",
"status": "active",
"licenceExpiresAt": "2027-10-31T21:59:59.000Z",
"graceDays": 14,
"issuedAt": "2026-11-03T10:15:00.000Z",
"validUntil": "2026-12-03T10:15:00.000Z",
"limits": {
"aiMonthlyCapCents": 0,
"storageBytes": 10737418240
}
}
+474 -1
View File
@@ -656,6 +656,446 @@
"bytes"
]
}
},
"website": {
"type": "object",
"properties": {
"template": {
"type": "string",
"enum": [
"heritage",
"bold",
"community",
"clean"
]
},
"firstPublishedAt": {
"anyOf": [
{
"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))$"
},
{
"type": "null"
}
]
},
"style": {
"type": "object",
"propertyNames": {
"type": "string",
"maxLength": 100
},
"additionalProperties": {
"type": "string",
"maxLength": 200
}
},
"pages": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ref": {
"type": "string",
"pattern": "^g[0-9]+$"
},
"title": {
"type": "string",
"maxLength": 300
},
"path": {
"type": "string",
"maxLength": 300,
"pattern": "^\\/[a-z0-9/-]*$"
},
"kind": {
"type": "string",
"maxLength": 40
},
"inNavigation": {
"type": "boolean"
},
"seo": {
"type": "object",
"properties": {
"title": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"description": {
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
}
},
"required": [
"title",
"description"
]
},
"sections": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"maxLength": 60
},
"variant": {
"type": "string",
"maxLength": 60
},
"hidden": {
"type": "boolean"
},
"content": {
"type": "object",
"propertyNames": {
"type": "string",
"maxLength": 100
},
"additionalProperties": {
"$ref": "#/$defs/__schema0"
}
}
},
"required": [
"type",
"variant",
"hidden",
"content"
]
}
}
},
"required": [
"ref",
"title",
"path",
"kind",
"inNavigation",
"seo",
"sections"
]
}
},
"messages": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ref": {
"type": "string",
"pattern": "^m[0-9]+$"
},
"title": {
"type": "string",
"maxLength": 500
},
"date": {
"anyOf": [
{
"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))$"
},
{
"type": "null"
}
]
},
"speaker": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"series": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"passage": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"notes": {
"anyOf": [
{
"type": "string",
"maxLength": 20000
},
{
"type": "null"
}
]
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"source": {
"type": "string",
"enum": [
"youtube-feed",
"manual"
]
},
"hidden": {
"type": "boolean"
}
},
"required": [
"ref",
"title",
"date",
"speaker",
"series",
"passage",
"notes",
"url",
"source",
"hidden"
]
}
},
"events": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ref": {
"type": "string",
"pattern": "^w[0-9]+$"
},
"title": {
"type": "string",
"maxLength": 500
},
"description": {
"anyOf": [
{
"type": "string",
"maxLength": 20000
},
{
"type": "null"
}
]
},
"startsAt": {
"anyOf": [
{
"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))$"
},
{
"type": "null"
}
]
},
"endsAt": {
"anyOf": [
{
"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))$"
},
{
"type": "null"
}
]
},
"location": {
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"link": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"image": {
"anyOf": [
{
"type": "string",
"pattern": "^uploads\\/[A-Za-z0-9._/-]+$"
},
{
"type": "null"
}
]
},
"published": {
"type": "boolean"
}
},
"required": [
"ref",
"title",
"description",
"startsAt",
"endsAt",
"location",
"link",
"image",
"published"
]
}
},
"versions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"number": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"publishedAt": {
"anyOf": [
{
"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))$"
},
{
"type": "null"
}
]
},
"by": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"note": {
"anyOf": [
{
"type": "string",
"maxLength": 1000
},
{
"type": "null"
}
]
}
},
"required": [
"number",
"publishedAt",
"by",
"note"
]
}
},
"media": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string",
"pattern": "^uploads\\/[A-Za-z0-9._/-]+$"
},
"alt": {
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"caption": {
"anyOf": [
{
"type": "string",
"maxLength": 1000
},
{
"type": "null"
}
]
}
},
"required": [
"path",
"alt",
"caption"
]
}
}
},
"required": [
"template",
"firstPublishedAt",
"style",
"pages",
"messages",
"events",
"versions",
"media"
]
}
},
"required": [
@@ -672,5 +1112,38 @@
"rosters",
"settings",
"files"
]
],
"$defs": {
"__schema0": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/__schema0"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema0"
}
}
]
}
}
}
@@ -0,0 +1,608 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/church-update-reply.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity-request/1"
},
"church": {
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.church/1"
},
"customerId": {
"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)$"
},
"updatedAt": {
"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))$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"shortName": {
"anyOf": [
{
"type": "string",
"maxLength": 30
},
{
"type": "null"
}
]
},
"timezone": {
"type": "string",
"pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
},
"locale": {
"type": "string",
"pattern": "^[a-z]{2,3}(-[A-Z]{2})?$"
},
"branding": {
"type": "object",
"properties": {
"logoUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"iconUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"colours": {
"type": "object",
"properties": {
"primary": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"accent": {
"anyOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"type": "null"
}
]
}
},
"required": [
"primary",
"accent"
]
},
"style": {
"type": "object",
"properties": {
"fontPairing": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"classic",
"scholarly",
"editorial",
"impact",
"contemporary",
"friendly",
"warm",
"modern"
]
},
{
"type": "null"
}
]
},
"corners": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"sharp",
"soft",
"round"
]
},
{
"type": "null"
}
]
}
},
"required": [
"fontPairing",
"corners"
]
}
},
"required": [
"logoUrl",
"iconUrl",
"colours"
]
},
"campuses": {
"maxItems": 50,
"type": "array",
"items": {
"type": "object",
"properties": {
"slug": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"address": {
"anyOf": [
{
"type": "object",
"properties": {
"line1": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"line2": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"suburb": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"province": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"postalCode": {
"anyOf": [
{
"type": "string",
"maxLength": 20
},
{
"type": "null"
}
]
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"geo": {
"anyOf": [
{
"type": "object",
"properties": {
"lat": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"lng": {
"type": "number",
"minimum": -180,
"maximum": 180
}
},
"required": [
"lat",
"lng"
]
},
{
"type": "null"
}
]
}
},
"required": [
"line1",
"line2",
"suburb",
"city",
"province",
"postalCode",
"country",
"geo"
]
},
{
"type": "null"
}
]
}
},
"required": [
"slug",
"name",
"address"
]
}
},
"serviceTimes": {
"maxItems": 100,
"type": "array",
"items": {
"type": "object",
"properties": {
"day": {
"type": "string",
"enum": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday"
]
},
"time": {
"type": "string",
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
},
"label": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"campus": {
"anyOf": [
{
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
{
"type": "null"
}
]
},
"note": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
}
},
"required": [
"day",
"time",
"label",
"campus",
"note"
]
}
},
"contact": {
"type": "object",
"properties": {
"email": {
"anyOf": [
{
"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,}$"
},
{
"type": "null"
}
]
},
"phone": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"whatsapp": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"address": {
"anyOf": [
{
"type": "object",
"properties": {
"line1": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"line2": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"suburb": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"province": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"postalCode": {
"anyOf": [
{
"type": "string",
"maxLength": 20
},
{
"type": "null"
}
]
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"geo": {
"anyOf": [
{
"type": "object",
"properties": {
"lat": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"lng": {
"type": "number",
"minimum": -180,
"maximum": 180
}
},
"required": [
"lat",
"lng"
]
},
{
"type": "null"
}
]
}
},
"required": [
"line1",
"line2",
"suburb",
"city",
"province",
"postalCode",
"country",
"geo"
]
},
{
"type": "null"
}
]
}
},
"required": [
"email",
"phone",
"whatsapp",
"address"
]
},
"social": {
"maxItems": 20,
"type": "array",
"items": {
"type": "object",
"properties": {
"network": {
"type": "string",
"enum": [
"facebook",
"instagram",
"youtube",
"tiktok",
"x",
"spotify",
"whatsapp-channel",
"other"
]
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"network",
"url"
]
}
},
"links": {
"type": "object",
"properties": {
"website": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"events": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"app": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"accounts": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"website",
"events",
"app",
"accounts"
]
}
},
"required": [
"schema",
"customerId",
"updatedAt",
"name",
"shortName",
"timezone",
"locale",
"branding",
"campuses",
"serviceTimes",
"contact",
"social",
"links"
]
}
},
"required": [
"schema",
"church"
]
}
+46
View File
@@ -91,6 +91,52 @@
"primary",
"accent"
]
},
"style": {
"type": "object",
"properties": {
"fontPairing": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"classic",
"scholarly",
"editorial",
"impact",
"contemporary",
"friendly",
"warm",
"modern"
]
},
{
"type": "null"
}
]
},
"corners": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"sharp",
"soft",
"round"
]
},
{
"type": "null"
}
]
}
},
"required": [
"fontPairing",
"corners"
]
}
},
"required": [
@@ -78,6 +78,11 @@
"aiMonthlyCapCents": {
"type": "number",
"minimum": 0
},
"storageBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
@@ -1308,6 +1308,548 @@
"church",
"overwrite"
]
},
{
"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": {
"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": {
"type": "string",
"const": "church.update"
},
"ifUpdatedAt": {
"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))$"
},
"church": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"shortName": {
"anyOf": [
{
"type": "string",
"maxLength": 30
},
{
"type": "null"
}
]
},
"timezone": {
"type": "string",
"pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
},
"locale": {
"type": "string",
"pattern": "^[a-z]{2,3}(-[A-Z]{2})?$"
},
"branding": {
"type": "object",
"properties": {
"logoUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"iconUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"colours": {
"type": "object",
"properties": {
"primary": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"accent": {
"anyOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"type": "null"
}
]
}
},
"required": [
"primary",
"accent"
]
},
"style": {
"type": "object",
"properties": {
"fontPairing": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"classic",
"scholarly",
"editorial",
"impact",
"contemporary",
"friendly",
"warm",
"modern"
]
},
{
"type": "null"
}
]
},
"corners": {
"default": null,
"anyOf": [
{
"type": "string",
"enum": [
"sharp",
"soft",
"round"
]
},
{
"type": "null"
}
]
}
},
"required": [
"fontPairing",
"corners"
]
}
}
},
"campuses": {
"maxItems": 50,
"type": "array",
"items": {
"type": "object",
"properties": {
"slug": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"address": {
"anyOf": [
{
"type": "object",
"properties": {
"line1": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"line2": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"suburb": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"province": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"postalCode": {
"anyOf": [
{
"type": "string",
"maxLength": 20
},
{
"type": "null"
}
]
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"geo": {
"anyOf": [
{
"type": "object",
"properties": {
"lat": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"lng": {
"type": "number",
"minimum": -180,
"maximum": 180
}
},
"required": [
"lat",
"lng"
]
},
{
"type": "null"
}
]
}
},
"required": [
"line1",
"line2",
"suburb",
"city",
"province",
"postalCode",
"country",
"geo"
]
},
{
"type": "null"
}
]
}
},
"required": [
"slug",
"name",
"address"
]
}
},
"serviceTimes": {
"maxItems": 100,
"type": "array",
"items": {
"type": "object",
"properties": {
"day": {
"type": "string",
"enum": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday"
]
},
"time": {
"type": "string",
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
},
"label": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"campus": {
"anyOf": [
{
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
{
"type": "null"
}
]
},
"note": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
}
},
"required": [
"day",
"time",
"label",
"campus",
"note"
]
}
},
"contact": {
"type": "object",
"properties": {
"email": {
"anyOf": [
{
"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,}$"
},
{
"type": "null"
}
]
},
"phone": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"whatsapp": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"address": {
"anyOf": [
{
"type": "object",
"properties": {
"line1": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"line2": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"suburb": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"city": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"province": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"postalCode": {
"anyOf": [
{
"type": "string",
"maxLength": 20
},
{
"type": "null"
}
]
},
"country": {
"type": "string",
"pattern": "^[A-Z]{2}$"
},
"geo": {
"anyOf": [
{
"type": "object",
"properties": {
"lat": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"lng": {
"type": "number",
"minimum": -180,
"maximum": 180
}
},
"required": [
"lat",
"lng"
]
},
{
"type": "null"
}
]
}
},
"required": [
"line1",
"line2",
"suburb",
"city",
"province",
"postalCode",
"country",
"geo"
]
},
{
"type": "null"
}
]
}
},
"required": [
"email",
"phone",
"whatsapp",
"address"
]
},
"social": {
"maxItems": 20,
"type": "array",
"items": {
"type": "object",
"properties": {
"network": {
"type": "string",
"enum": [
"facebook",
"instagram",
"youtube",
"tiktok",
"x",
"spotify",
"whatsapp-channel",
"other"
]
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"network",
"url"
]
}
}
}
}
},
"required": [
"schema",
"requestId",
"actor",
"type",
"church"
]
}
]
}
@@ -68,6 +68,7 @@ function contracts(c) {
"messaging-test-reply": c.messagingTestReplySchema,
"people-remove-demo-reply": c.peopleRemoveDemoReplySchema,
"people-check-reply": c.peopleCheckReplySchema,
"church-update-reply": c.churchUpdateReplySchema,
};
}
+76 -2
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { dateTimeSchema, productSchema, timezoneSchema } from "./common";
import { dateTimeSchema, productSchema, timezoneSchema, urlSchema } from "./common";
import { websiteTemplateSchema } from "./style";
/**
* crosscode.church-export/1: a church's data when it leaves (docs/AGENT-1.0-PLAN.md §9). Written
@@ -14,6 +15,7 @@ const ref = (prefix: string) => z.string().regex(new RegExp(`^${prefix}[0-9]+$`)
const text = (max = 20000) => z.string().max(max);
const when = dateTimeSchema.nullable();
const cents = z.int();
const uploadPath = z.string().regex(/^uploads\/[A-Za-z0-9._/-]+$/);
export const exportPersonSchema = z.object({
ref: ref("p"),
@@ -62,6 +64,76 @@ export const exportCheckInSchema = z.object({ eventRef: ref("e"), personRef: ref
export const exportRosterSchema = z.object({ eventRef: ref("e").nullable(), role: text(200), personRef: ref("p").nullable(), startsAt: when, endsAt: when });
// The Website's part (contracts 1.17.0, WEBSITE-1.0-PLAN §11): its content as the admins left it
// (the working copy, including changes not yet published), the publish history's notes, messages,
// simple events and the media library. Images are files in `uploads/`, listed in `files`.
/** A section of a page: its type and layout, and what the admin filled in (text, links, image paths). */
export const exportWebsiteSectionSchema = z.object({
/** E.g. `hero`, `service-times`, `ministries`, `text`, `gallery`. */
type: text(60),
/** E.g. `photo`, `cards`. */
variant: text(60),
hidden: z.boolean(),
content: z.record(z.string().max(100), z.json()),
});
export const exportWebsitePageSchema = z.object({
ref: ref("g"),
title: text(300),
/** The page's path on the site: `/` for home, `/about`, `/youth-camp`. */
path: z.string().regex(/^\/[a-z0-9/-]*$/).max(300),
/** `home`, `about`, `visit`, `contact`, `give`, … or `custom` for a page the church added. */
kind: text(40),
inNavigation: z.boolean(),
seo: z.object({ title: text(300).nullable(), description: text(500).nullable() }),
sections: z.array(exportWebsiteSectionSchema),
});
export const exportWebsiteMessageSchema = z.object({
ref: ref("m"),
title: text(500),
date: when,
speaker: text(300).nullable(),
series: text(300).nullable(),
passage: text(300).nullable(),
notes: text().nullable(),
/** The YouTube or Spotify link (audio and video are never uploaded). */
url: urlSchema,
/** `youtube-feed` when it came in from the channel or playlist by itself. */
source: z.enum(["youtube-feed", "manual"]),
hidden: z.boolean(),
});
/** A simple event made in the Website (Cross Events' own events are in its export's `events`). */
export const exportWebsiteEventSchema = z.object({
ref: ref("w"),
title: text(500),
description: text().nullable(),
startsAt: when,
endsAt: when,
location: text(500).nullable(),
link: urlSchema.nullable(),
image: uploadPath.nullable(),
published: z.boolean(),
});
export const exportWebsiteSchema = z.object({
template: websiteTemplateSchema,
/** Null when the site was never published (it showed Coming soon). */
firstPublishedAt: when,
/** The Website-only style settings (section colour, spacing, buttons, image treatment, header). */
style: z.record(z.string().max(100), z.string().max(200)),
pages: z.array(exportWebsitePageSchema),
messages: z.array(exportWebsiteMessageSchema),
events: z.array(exportWebsiteEventSchema),
/** Every publish, oldest first. The snapshots aren't exported: `pages` is the content. */
versions: z.array(z.object({ number: z.int().positive(), publishedAt: when, by: text(300).nullable(), note: text(1000).nullable() })),
/** The media library: alt text and captions of the files in `uploads/`. */
media: z.array(z.object({ path: uploadPath, alt: text(500).nullable(), caption: text(1000).nullable() })),
});
export type ExportWebsite = z.infer<typeof exportWebsiteSchema>;
export const churchExportSchema = z.object({
schema: z.literal("crosscode.church-export/1"),
exportedAt: dateTimeSchema,
@@ -77,7 +149,9 @@ export const churchExportSchema = z.object({
/** The site's own settings that matter to a church (name, contact, branding), never secrets. */
settings: z.record(z.string().max(100), z.string().max(5000)),
/** Uploaded files in the ZIP's `uploads/` folder. */
files: z.array(z.object({ path: z.string().regex(/^uploads\/[A-Za-z0-9._/-]+$/), bytes: z.int().nonnegative() })),
files: z.array(z.object({ path: uploadPath, bytes: z.int().nonnegative() })),
/** Only in the Website's export (contracts 1.17.0). Its editors are in `people`, with their roles. */
website: exportWebsiteSchema.optional(),
});
export type ChurchExport = z.infer<typeof churchExportSchema>;
+6
View File
@@ -1,6 +1,7 @@
import { z } from "zod";
import { dateTimeSchema, emailSchema, hexColourSchema, idSchema, phoneSchema, slugSchema, timeOfDaySchema, timezoneSchema, urlSchema } from "./common";
import { schemaName } from "./schema-name";
import { brandStyleSchema } from "./style";
/**
* `crosscode.church/1` — the church profile, set once and shared by every product of a church
@@ -68,6 +69,11 @@ export const churchObjectSchema = z
primary: hexColourSchema,
accent: hexColourSchema.nullable(),
}),
/**
* Font pairing and corners, shared by every product (contracts 1.17.0, `./style`). Optional:
* a profile from an Accounts before 1.7.0 has none, which means the defaults.
*/
style: brandStyleSchema.optional(),
}),
/** Empty when campuses are off. */
campuses: z.array(campusSchema).max(50),
+9 -1
View File
@@ -355,6 +355,14 @@ export const licencePayloadSchema = z.object({
graceDays: z.int().nonnegative(),
issuedAt: dateTimeSchema,
validUntil: dateTimeSchema,
limits: z.object({ aiMonthlyCapCents: z.number().nonnegative() }),
limits: z.object({
aiMonthlyCapCents: z.number().nonnegative(),
/**
* The Website's storage limit in bytes: what's included plus any storage add-ons
* (WEBSITE-1.0-PLAN §10, decision 12). Uploads stop when it's full. Only on a Website licence,
* from Hub 2.21.0 (contracts 1.17.0); a Website without it uses its own included amount.
*/
storageBytes: z.int().nonnegative().optional(),
}),
});
export type LicencePayload = z.infer<typeof licencePayloadSchema>;
+40 -1
View File
@@ -2,6 +2,7 @@ import { z } from "zod";
import { dateTimeSchema, emailSchema, idSchema, phoneSchema } from "./common";
import { profileSchema, twoFactorMethodSchema } from "./identity";
import { schemaName } from "./schema-name";
import { churchObjectSchema, churchSchema } from "./church";
/**
* `crosscode.identity-request/1` (contracts 1.8.0, docs/EVENTS-3.0-PLAN.md §4 and §8): what a
@@ -21,6 +22,8 @@ import { schemaName } from "./schema-name";
* 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`. 1.11.0 adds
* `people.removeDemo`: new demo data in a product removes the old demo people's accounts.
* - **`church.*`**: the church profile from a product. `church.branding` (1.9.0) fills in the
* look; `church.update` (1.17.0) changes shared facts from the Website's admin.
*/
export const IDENTITY_REQUEST_SCHEMA = schemaName("identity-request", 1);
@@ -240,10 +243,40 @@ export const messagingSetSchema = messagingTestSchema.extend({ type: z.literal("
*/
export const churchBrandingSchema = base.extend({ type: z.literal("church.branding"), church: churchLookSchema, overwrite: z.boolean() });
/**
* The profile fields a product may change: the profile without what Accounts fills in itself
* (`customerId`, `updatedAt`, `links`).
*/
export const churchEditableSchema = churchObjectSchema.omit({ schema: true, customerId: true, updatedAt: true, links: true });
/**
* 1.17.0: change shared profile facts from a product's admin (the Website's, WEBSITE-1.0-PLAN
* decision 10). The product checks the person may do it (its own roles: Accounts doesn't know
* them) and sends it with them as `actor`; Accounts audits it with the product and the actor.
*
* Only the fields given change. A given field replaces Accounts' value as a whole (a list, an
* address, `branding.colours`), except `branding`, whose own fields can be given one at a time
* (only `style`, say). It goes live at once (shared facts aren't drafts) and Accounts sends
* `church.changed` to every linked product. With `ifUpdatedAt`, Accounts refuses with
* `PROFILE_CHANGED` when the profile changed since (someone saved in between).
*
* Accounts takes it from the Website only (`WRONG_PRODUCT` otherwise) and needs an `actor`
* (`NOT_ALLOWED`). The reply is the profile after the change.
*/
export const churchUpdateSchema = base.extend({
type: z.literal("church.update"),
actor: idSchema,
ifUpdatedAt: dateTimeSchema.optional(),
church: churchEditableSchema
.extend({ branding: churchEditableSchema.shape.branding.partial() })
.partial()
.refine((c) => Object.keys(c).length > 0, "Nothing to change"),
});
export const identityRequestSchema = z.discriminatedUnion("type", [
importBeginSchema, importBatchSchema, importFinishSchema, importAbortSchema,
peopleEnsureSchema, peopleUpdateSchema, peopleResetTwoFactorSchema, peopleUnlockSchema, peopleSetActiveSchema, peopleNewsOffSchema,
peopleRemoveDemoSchema, peopleCheckSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
peopleRemoveDemoSchema, peopleCheckSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema, churchUpdateSchema,
]);
export type IdentityRequest = z.infer<typeof identityRequestSchema>;
export type IdentityRequestType = IdentityRequest["type"];
@@ -323,7 +356,13 @@ export const messagingTestReplySchema = z.object({
});
export type MessagingTestReply = z.infer<typeof messagingTestReplySchema>;
/** church.update: the profile after the change. */
export const churchUpdateReplySchema = z.object({ schema: z.literal(IDENTITY_REQUEST_SCHEMA), church: churchSchema });
export type ChurchUpdateReply = z.infer<typeof churchUpdateReplySchema>;
/** Errors: `{ message, code }` as the other link calls. */
export const IDENTITY_REQUEST_ERROR_CODES = [
"NOT_LINKED", "BAD_SIGNATURE", "STALE_REQUEST", "INVALID_REQUEST", "NOT_MOVING", "WRONG_PRODUCT", "UNKNOWN_PERSON", "EMAIL_TAKEN", "NOT_ALLOWED",
/** 1.17.0, church.update with `ifUpdatedAt`: the profile changed since. */
"PROFILE_CHANGED",
] as const;
+1
View File
@@ -6,6 +6,7 @@ export * from "./schema-name";
export * from "./common";
export * from "./event";
export * from "./church";
export * from "./style";
export * from "./identity";
export * from "./identity-request";
export * from "./return-to";
+73
View File
@@ -0,0 +1,73 @@
import { z } from "zod";
/**
* The church's brand style (contracts 1.17.0, WEBSITE-1.0-PLAN §3 "Font pairings", decision 15):
* a font pairing and a corner style, kept in the church profile (`branding.style`) and used by the
* Website, Accounts' pages, Cross Events' public pages and later the App, so they feel like one
* church. Colours are already in the profile.
*
* The ids are stored in every church's profile, so **an id never changes or goes away** once
* released. Names shown to churches, and the fonts behind an id, may.
*/
/** How a font falls back while it loads, and which metric-matched fallback `@crosscode/ui` uses. */
export const FONT_CATEGORIES = ["serif", "sans-serif"] as const;
export type FontCategory = (typeof FONT_CATEGORIES)[number];
export type FontFace = { family: string; category: FontCategory };
export type FontPairingInfo = { name: string; heading: FontFace; body: FontFace; feel: string };
const serif = (family: string): FontFace => ({ family, category: "serif" });
const sans = (family: string): FontFace => ({ family, category: "sans-serif" });
/** The 8 font pairings, all SIL Open Font License, variable and with Latin Extended. Self-hosted only. */
export const FONT_PAIRINGS = {
classic: { name: "Classic", heading: serif("Lora"), body: sans("Source Sans 3"), feel: "Traditional serif headings, a plain readable body" },
scholarly: { name: "Scholarly", heading: serif("EB Garamond"), body: serif("EB Garamond"), feel: "Old-style book type throughout; dignified" },
editorial: { name: "Editorial", heading: serif("Playfair Display"), body: sans("Inter"), feel: "High-contrast magazine headlines over a neutral body" },
impact: { name: "Impact", heading: sans("Oswald"), body: sans("Source Sans 3"), feel: "Tall condensed headlines; loud over photos" },
contemporary: { name: "Contemporary", heading: sans("Outfit"), body: sans("DM Sans"), feel: "Geometric, modern, light-handed" },
friendly: { name: "Friendly", heading: sans("Nunito"), body: sans("Nunito"), feel: "Rounded ends throughout; warm and informal" },
warm: { name: "Warm", heading: serif("Fraunces"), body: sans("Nunito Sans"), feel: "A soft, characterful serif with a gentle sans" },
modern: { name: "Modern", heading: sans("Inter"), body: sans("Inter"), feel: "One neutral sans; lets colour and photos lead" },
} as const satisfies Record<string, FontPairingInfo>;
export const FONT_PAIRING_IDS = Object.keys(FONT_PAIRINGS) as [keyof typeof FONT_PAIRINGS, ...(keyof typeof FONT_PAIRINGS)[]];
export const fontPairingSchema = z.enum(FONT_PAIRING_IDS);
export type FontPairing = z.infer<typeof fontPairingSchema>;
/** Corner style: the radius of cards, buttons, images and fields. */
export const CORNERS = ["sharp", "soft", "round"] as const;
export const cornersSchema = z.enum(CORNERS);
export type Corners = z.infer<typeof cornersSchema>;
/** What a profile without `corners` means. */
export const DEFAULT_CORNERS: Corners = "soft";
/** The Website's four templates (ROADMAP-v3 decision 19). */
export const WEBSITE_TEMPLATES = ["heritage", "bold", "community", "clean"] as const;
export const websiteTemplateSchema = z.enum(WEBSITE_TEMPLATES);
export type WebsiteTemplate = z.infer<typeof websiteTemplateSchema>;
/**
* The three pairings each template recommends; the first is its default. Every pairing works in
* every template: the others are shown under "More".
*/
export const TEMPLATE_FONT_PAIRINGS: Record<WebsiteTemplate, readonly [FontPairing, FontPairing, FontPairing]> = {
heritage: ["classic", "scholarly", "editorial"],
bold: ["impact", "contemporary", "editorial"],
community: ["friendly", "warm", "contemporary"],
clean: ["modern", "classic", "contemporary"],
};
/**
* `branding.style` in `crosscode.church/1`. Both fields are null until an admin picks one; then
* the Website uses its template's default pairing, and Events and Accounts keep their system fonts.
*
* An id this version doesn't know (from a newer Accounts) reads as null, so a profile with a newer
* pairing never fails to parse: the product just shows its default.
*/
export const brandStyleSchema = z.object({
fontPairing: fontPairingSchema.nullable().catch(null),
corners: cornersSchema.nullable().catch(null),
});
export type BrandStyle = z.infer<typeof brandStyleSchema>;
+2 -2
View File
@@ -141,8 +141,8 @@ describe("exports", () => {
expect(() => decryptExport(file, encryptExport(zip).key)).toThrow();
});
it("the sample has no internal ids", () => {
const data = sample("church-export.json");
it.each(["church-export.json", "church-export-website.json"])("%s has no internal ids", (file) => {
const data = sample(file);
expect(churchExportSchema.safeParse(data).success).toBe(true);
const keys: string[] = [];
const walk = (v: unknown): void => {
@@ -35,7 +35,9 @@ const SAMPLE_SCHEMA: Record<string, string> = {
"hub-heartbeat-accounts.json": "hub-heartbeat-request",
"hub-heartbeat-response.json": "hub-heartbeat-response",
"hub-licence-payload.json": "hub-licence-payload",
"hub-licence-payload-website.json": "hub-licence-payload",
"church-export.json": "church-export",
"church-export-website.json": "church-export",
"church-changed.json": "church-changed",
"link-connect.json": "link-connect",
"link-connected.json": "link-connected",
@@ -52,6 +54,8 @@ const SAMPLE_SCHEMA: Record<string, string> = {
"people-remove-demo-reply.json": "people-remove-demo-reply",
"people-check.json": "identity-request",
"people-check-reply.json": "people-check-reply",
"church-update.json": "identity-request",
"church-update-reply.json": "church-update-reply",
};
describe("JSON Schema (schemas/)", () => {
+5 -1
View File
@@ -17,7 +17,7 @@ import {
importBatchReplySchema,
peopleEnsureReplySchema,
messagingTestReplySchema,
peopleRemoveDemoReplySchema, peopleCheckReplySchema,
peopleRemoveDemoReplySchema, peopleCheckReplySchema, churchUpdateReplySchema,
userDeletedReplySchema,
userExportReplySchema,
} from "../src";
@@ -44,7 +44,9 @@ const SCHEMAS: Record<string, z.ZodType> = {
"hub-heartbeat-accounts.json": hub.heartbeatRequestSchema,
"hub-heartbeat-response.json": hub.heartbeatResponseSchema,
"hub-licence-payload.json": hub.licencePayloadSchema,
"hub-licence-payload-website.json": hub.licencePayloadSchema,
"church-export.json": churchExportSchema,
"church-export-website.json": churchExportSchema,
"church-changed.json": churchChangedSchema,
"link-connect.json": linkConnectSchema,
"link-connected.json": linkConnectedSchema,
@@ -61,6 +63,8 @@ const SCHEMAS: Record<string, z.ZodType> = {
"people-remove-demo-reply.json": peopleRemoveDemoReplySchema,
"people-check.json": identityRequestSchema,
"people-check-reply.json": peopleCheckReplySchema,
"church-update.json": identityRequestSchema,
"church-update-reply.json": churchUpdateReplySchema,
};
describe("samples", () => {
+102
View File
@@ -0,0 +1,102 @@
import {
brandStyleSchema,
churchExportSchema,
churchSchema,
CORNERS,
FONT_PAIRING_IDS,
FONT_PAIRINGS,
hub,
identityRequestSchema,
TEMPLATE_FONT_PAIRINGS,
WEBSITE_TEMPLATES,
} from "../src";
import type { Church, ChurchExport } from "../src";
import { sample } from "./helpers";
describe("brand style (1.17.0)", () => {
it("has the 8 confirmed font pairings, ids unchanged", () => {
// These ids are stored in churches' profiles: changing or removing one is a breaking change.
expect(FONT_PAIRING_IDS).toEqual(["classic", "scholarly", "editorial", "impact", "contemporary", "friendly", "warm", "modern"]);
expect(CORNERS).toEqual(["sharp", "soft", "round"]);
});
it("each template recommends three different pairings, and every pairing is recommended somewhere", () => {
expect(Object.keys(TEMPLATE_FONT_PAIRINGS).sort()).toEqual([...WEBSITE_TEMPLATES].sort());
for (const picks of Object.values(TEMPLATE_FONT_PAIRINGS)) expect(new Set(picks).size).toBe(3);
const recommended = new Set(Object.values(TEMPLATE_FONT_PAIRINGS).flat());
expect([...recommended].sort()).toEqual([...FONT_PAIRING_IDS].sort());
});
it("every pairing names a heading and a body font", () => {
for (const p of Object.values(FONT_PAIRINGS)) {
expect(p.heading.family.length).toBeGreaterThan(0);
expect(p.body.family.length).toBeGreaterThan(0);
}
});
it("a profile without a style still parses (Accounts before 1.7.0)", () => {
const c = sample<Church>("church.json");
delete c.branding.style;
const parsed = churchSchema.parse(c);
expect(parsed.branding.style).toBeUndefined();
});
it("an unknown pairing or corner from a newer Accounts reads as null instead of failing", () => {
expect(brandStyleSchema.parse({ fontPairing: "gothic", corners: "pointy" })).toEqual({ fontPairing: null, corners: null });
const c = sample<Church>("church.json");
const parsed = churchSchema.parse({ ...c, branding: { ...c.branding, style: { fontPairing: "gothic", corners: "round" } } });
expect(parsed.branding.style).toEqual({ fontPairing: null, corners: "round" });
});
});
describe("the Website's export (1.17.0)", () => {
const data = () => sample<ChurchExport>("church-export-website.json");
it("is optional, so Events' and Accounts' exports are unchanged", () => {
const events = churchExportSchema.parse(sample("church-export.json"));
expect(events.website).toBeUndefined();
});
it("refuses an unknown template, a page path that isn't one, and media outside uploads/", () => {
const d = data();
const bad = (website: object) => churchExportSchema.safeParse({ ...d, website: { ...d.website, ...website } }).success;
expect(bad({ template: "minimal" })).toBe(false);
expect(bad({ pages: [{ ...d.website!.pages[0]!, path: "about" }] })).toBe(false);
expect(bad({ media: [{ path: "../etc/passwd", alt: null, caption: null }] })).toBe(false);
});
it("a message is a YouTube-feed or hand-added link", () => {
const d = data();
const msg = { ...d.website!.messages[0]!, source: "upload" };
expect(churchExportSchema.safeParse({ ...d, website: { ...d.website, messages: [msg] } }).success).toBe(false);
});
});
describe("licence storage limit (1.17.0)", () => {
it("is optional, and only whole non-negative bytes", () => {
const lic = sample<hub.LicencePayload>("hub-licence-payload-website.json");
expect(hub.licencePayloadSchema.parse(lic).limits.storageBytes).toBe(10737418240);
expect(hub.licencePayloadSchema.parse(sample("hub-licence-payload.json")).limits.storageBytes).toBeUndefined();
expect(hub.licencePayloadSchema.safeParse({ ...lic, limits: { ...lic.limits, storageBytes: -1 } }).success).toBe(false);
});
});
describe("church.update (1.17.0)", () => {
const req = () => sample<Record<string, unknown>>("church-update.json");
it("needs an actor and something to change", () => {
expect(identityRequestSchema.safeParse({ ...req(), actor: null }).success).toBe(false);
expect(identityRequestSchema.safeParse({ ...req(), church: {} }).success).toBe(false);
});
it("takes part of branding (only the style), but not the fields Accounts fills in", () => {
const parsed = identityRequestSchema.parse({ ...req(), church: { branding: { style: { fontPairing: "modern", corners: null } } } });
expect(parsed.type === "church.update" && parsed.church.branding).toEqual({ style: { fontPairing: "modern", corners: null } });
const withLinks = identityRequestSchema.parse({ ...req(), church: { name: "Hope", links: { accounts: "https://evil.example" }, customerId: "x" } });
expect(withLinks.type === "church.update" && Object.keys(withLinks.church)).toEqual(["name"]);
});
it("still checks what it's given", () => {
expect(identityRequestSchema.safeParse({ ...req(), church: { branding: { colours: { primary: "blue", accent: null } } } }).success).toBe(false);
});
});