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:
@@ -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>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user