diff --git a/CHANGELOG.md b/CHANGELOG.md index f40b876..e18095a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `a ## Unreleased +## contracts@1.1.0 - 2026-11-04 + +### Contracts + +- Hub protocol v2: optional `requires` on a release (`[{ product, version }]`), the sibling + versions it needs. The Hub refuses an update request with `409 REQUIREMENT_NOT_MET` until + they're met (Hub 2.0, ROADMAP-v3 §5). Optional, so the schema stays `/1`-compatible. + ## contracts@1.0.0 - 2026-11-04 ### Monorepo diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 9f1f12f..9b1bcfe 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/contracts", - "version": "1.0.0", + "version": "1.1.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", diff --git a/packages/contracts/samples/hub-heartbeat-response.json b/packages/contracts/samples/hub-heartbeat-response.json index cbec433..e008138 100644 --- a/packages/contracts/samples/hub-heartbeat-response.json +++ b/packages/contracts/samples/hub-heartbeat-response.json @@ -1,7 +1,14 @@ { "licence": "hel1.eyJ2IjoxfQ.c2lnbmF0dXJl", - "latestVersion": "2.3.1", + "latestVersion": "3.0.0", "releases": [ + { + "version": "3.0.0", + "releasedAt": "2026-12-01T10:00:00.000Z", + "urgent": false, + "notes": "- Sign in with your church account", + "requires": [{ "product": "accounts", "version": "1.2.0" }] + }, { "version": "2.3.1", "releasedAt": "2026-11-10T10:00:00.000Z", "urgent": false, "notes": "- Fixed: feed sync after a campus is renamed" } ], "notices": [ diff --git a/packages/contracts/schemas/hub-heartbeat-response.json b/packages/contracts/schemas/hub-heartbeat-response.json index 4e7805c..c0b6aba 100644 --- a/packages/contracts/schemas/hub-heartbeat-response.json +++ b/packages/contracts/schemas/hub-heartbeat-response.json @@ -36,6 +36,31 @@ }, "notes": { "type": "string" + }, + "requires": { + "type": "array", + "items": { + "type": "object", + "properties": { + "product": { + "type": "string", + "enum": [ + "events", + "website", + "app", + "accounts" + ] + }, + "version": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$" + } + }, + "required": [ + "product", + "version" + ] + } } }, "required": [ diff --git a/packages/contracts/schemas/hub-register-response.json b/packages/contracts/schemas/hub-register-response.json index 6b7ea22..68e7ee0 100644 --- a/packages/contracts/schemas/hub-register-response.json +++ b/packages/contracts/schemas/hub-register-response.json @@ -50,6 +50,31 @@ }, "notes": { "type": "string" + }, + "requires": { + "type": "array", + "items": { + "type": "object", + "properties": { + "product": { + "type": "string", + "enum": [ + "events", + "website", + "app", + "accounts" + ] + }, + "version": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$" + } + }, + "required": [ + "product", + "version" + ] + } } }, "required": [ diff --git a/packages/contracts/src/hub.ts b/packages/contracts/src/hub.ts index 7a6dd6a..fe8e3da 100644 --- a/packages/contracts/src/hub.ts +++ b/packages/contracts/src/hub.ts @@ -71,11 +71,21 @@ export function activeMemberBand(count: number): (typeof ACTIVE_MEMBER_BANDS)[nu const count = z.int().nonnegative(); +/** A minimum version of a sibling product that a release needs (`— requires accounts 1.2.0`). */ +export const releaseRequirementSchema = z.object({ product: productSchema, version: semverSchema }); +export type ReleaseRequirement = z.infer; + export const releaseSchema = z.object({ version: semverSchema, releasedAt: dateTimeSchema, urgent: z.boolean(), notes: z.string(), + /** + * contracts 1.1.0 (Hub 2.0): the sibling versions this release needs. The Hub refuses an update + * request (`409 REQUIREMENT_NOT_MET`) until the church's install of each product runs at least + * that version. Optional: absent from Hubs before 2.0 and from protocol v1 replies. + */ + requires: z.array(releaseRequirementSchema).optional(), }); export const noticeSchema = z.object({