Contracts 1.0.0: generated JSON Schema for every contract

- schemas/: JSON Schema (draft 2020-12) generated from the zod schemas by
  npm run build (scripts/json-schemas.cjs), exported as
  @crosscode/contracts/schemas/*
- Test: files match the zod schemas, every sample passes them (Ajv)
- Version 1.0.0, CHANGELOG and README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 14:30:37 +02:00
co-authored by Claude Opus 5.5
parent ea1575f716
commit 9e94c82502
35 changed files with 4330 additions and 5 deletions
+7 -1
View File
@@ -4,6 +4,8 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `a
## Unreleased
## contracts@1.0.0 - 2026-11-04
### Monorepo
- Set up: npm workspaces (`packages/*`, `apps/*`), shared TypeScript, ESLint and Jest setup,
@@ -12,7 +14,7 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `a
schema-name helpers every contract uses (`crosscode.<name>/<major>`).
- `packages/ui`, `apps/accounts`, `apps/website`, `apps/app`: placeholders.
### Contracts (towards 1.0.0)
### Contracts
- `crosscode.event/1` and `crosscode.event-feed/1`: the event, the feed response and the
`event.changed` webhook. Checks that `startsAt` / `endsAt` match the sessions and that only
@@ -30,3 +32,7 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `a
products in the replies, `customerId` / `product` in the licence token.
- `@crosscode/contracts/signing` (Node only): the Hub's HMAC scheme for the Hub and product links.
- Sample payloads for every contract in `samples/`, checked by the tests.
- **JSON Schema** (draft 2020-12) for every contract in `schemas/`, generated from the zod
schemas by `npm run build` (`scripts/json-schemas.cjs`), for consumers that don't use
TypeScript or zod. A test checks the files match the zod schemas and that every sample passes
them (Ajv). Checks JSON Schema can't express (e.g. `startsAt` matching the sessions) only run in zod.
+1 -1
View File
@@ -8,7 +8,7 @@ export default defineConfig([
...tseslint.configs.recommended,
{
files: ["**/*.cjs", "**/jest.config.js"],
languageOptions: { sourceType: "commonjs", globals: { module: "writable", require: "readonly" } },
languageOptions: { sourceType: "commonjs", globals: { module: "writable", require: "readonly", __dirname: "readonly", process: "readonly", console: "readonly" } },
rules: { "@typescript-eslint/no-require-imports": "off" },
},
{
+97
View File
@@ -3363,6 +3363,48 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/ajv-formats": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
"integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ajv": "^8.0.0"
},
"peerDependencies": {
"ajv": "^8.0.0"
},
"peerDependenciesMeta": {
"ajv": {
"optional": true
}
}
},
"node_modules/ajv-formats/node_modules/ajv": {
"version": "8.20.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/ajv-formats/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT"
},
"node_modules/ansi-escapes": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
@@ -4318,6 +4360,23 @@
"dev": true,
"license": "MIT"
},
"node_modules/fast-uri": {
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
"integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/fb-watchman": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.4.tgz",
@@ -6212,6 +6271,16 @@
"node": ">=0.10.0"
}
},
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/resolve-cwd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
@@ -7210,8 +7279,36 @@
"license": "UNLICENSED",
"dependencies": {
"zod": "^4.6.7"
},
"devDependencies": {
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1"
}
},
"packages/contracts/node_modules/ajv": {
"version": "8.20.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"packages/contracts/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT"
},
"packages/ui": {
"name": "@crosscode/ui",
"version": "0.0.0"
+10 -1
View File
@@ -1,7 +1,7 @@
# @crosscode/contracts
Everything that crosses between Cross Code products is defined once, here (ROADMAP-v3 §2):
zod schemas, TypeScript types and sample payloads (`samples/`). Every product, including Cross
zod schemas, JSON Schema (`schemas/`), TypeScript types and sample payloads (`samples/`). Every product, including Cross
Events and the Hub, uses it, so the key fields are the same in every product's JSON.
| Contract | Schema name | Used for | Source |
@@ -62,6 +62,15 @@ for install → Hub; `LINK_HEADERS` (`X-Crosscode-Sender`, `-Timestamp`, `-Signa
`event.changed` webhooks and Accounts back-channel calls, with the secret set up by **Connect**.
Verify the raw bytes before parsing the JSON.
### JSON Schema
`schemas/` has a JSON Schema (draft 2020-12) for every contract, for consumers that don't use
TypeScript or zod (e.g. `@crosscode/contracts/schemas/event.json`). They are generated from the
zod schemas by `npm run build`; commit them with the change (a test fails when they're out of
date). They allow unknown fields, like the zod schemas. The zod schemas stay the source of truth:
a few checks can't be written in JSON Schema (e.g. `startsAt` / `endsAt` matching the sessions,
only Cross Events using `registration.mode: "origin"`), so use the zod schemas where you can.
## Versioning
- Every payload carries its `schema` name: `crosscode.<name>/<major>` (`parseSchemaName`, `isSchema`).
+7 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/contracts",
"version": "0.1.0",
"version": "1.0.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",
@@ -28,6 +28,7 @@
"default": "./dist/signing.js"
}
},
"./schemas/*": "./schemas/*",
"./package.json": "./package.json"
},
"files": [
@@ -38,7 +39,7 @@
],
"sideEffects": false,
"scripts": {
"build": "tsup",
"build": "tsup && node scripts/json-schemas.cjs",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "jest"
},
@@ -52,5 +53,9 @@
"type": "git",
"url": "https://c-git.crosscode.co.za/joshua/crosscode-platform.git",
"directory": "packages/contracts"
},
"devDependencies": {
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1"
}
}
@@ -0,0 +1,204 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/accounts-call.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.updated"
},
"profile": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"given_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"family_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"email": {
"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,}$"
},
"email_verified": {
"type": "boolean"
},
"phone_number": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"phone_number_verified": {
"type": "boolean"
},
"news_consent": {
"type": "object",
"properties": {
"email": {
"type": "boolean"
},
"whatsapp": {
"type": "boolean"
}
},
"required": [
"email",
"whatsapp"
]
}
},
"required": [
"name",
"given_name",
"family_name",
"email",
"email_verified",
"phone_number",
"phone_number_verified",
"news_consent"
]
}
},
"required": [
"schema",
"callId",
"occurredAt",
"sub",
"type",
"profile"
]
},
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.deleted"
},
"approvedAt": {
"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))$"
}
},
"required": [
"schema",
"callId",
"occurredAt",
"sub",
"type",
"approvedAt"
]
},
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.export"
},
"exportId": {
"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",
"callId",
"occurredAt",
"sub",
"type",
"exportId"
]
}
]
}
+549
View File
@@ -0,0 +1,549 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/church.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"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"
]
}
},
"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"
]
}
@@ -0,0 +1,35 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/event-changed.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.event-feed/1"
},
"type": {
"type": "string",
"const": "event.changed"
},
"occurredAt": {
"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))$"
},
"eventIds": {
"maxItems": 100,
"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",
"type",
"occurredAt",
"eventIds"
]
}
+440
View File
@@ -0,0 +1,440 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/event-feed.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.event-feed/1"
},
"generatedAt": {
"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))$"
},
"events": {
"type": "array",
"items": {
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.event/1"
},
"id": {
"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)$"
},
"origin": {
"type": "object",
"properties": {
"product": {
"type": "string",
"enum": [
"events",
"website",
"app"
]
},
"installId": {
"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)$"
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"product",
"installId",
"url"
]
},
"status": {
"type": "string",
"enum": [
"published",
"cancelled"
]
},
"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))$"
},
"title": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"summary": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"description": {
"anyOf": [
{
"type": "string",
"maxLength": 20000
},
{
"type": "null"
}
]
},
"imageUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"timezone": {
"type": "string",
"pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
},
"startsAt": {
"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))$"
},
"endsAt": {
"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))$"
},
"allDay": {
"type": "boolean"
},
"sessions": {
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"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)$"
},
"label": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"startsAt": {
"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))$"
},
"endsAt": {
"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))$"
},
"location": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"cancelled": {
"type": "boolean"
}
},
"required": [
"id",
"label",
"startsAt",
"endsAt",
"location",
"cancelled"
]
}
},
"location": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"address": {
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"onlineUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"address",
"onlineUrl"
]
},
{
"type": "null"
}
]
},
"campus": {
"anyOf": [
{
"type": "object",
"properties": {
"slug": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
},
"required": [
"slug",
"name"
]
},
{
"type": "null"
}
]
},
"series": {
"anyOf": [
{
"type": "object",
"properties": {
"id": {
"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)$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
},
"required": [
"id",
"name"
]
},
{
"type": "null"
}
]
},
"tags": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
}
},
"registration": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"origin",
"external",
"contact",
"none"
]
},
"url": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"status": {
"type": "string",
"enum": [
"open",
"not_open",
"closed",
"full",
"waitlist"
]
},
"opensAt": {
"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"
}
]
},
"closesAt": {
"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"
}
]
},
"priceFrom": {
"anyOf": [
{
"type": "object",
"properties": {
"amountCents": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
}
},
"required": [
"amountCents",
"currency"
]
},
{
"type": "null"
}
]
}
},
"required": [
"mode",
"url",
"status",
"opensAt",
"closesAt",
"priceFrom"
]
}
},
"required": [
"schema",
"id",
"origin",
"status",
"updatedAt",
"title",
"summary",
"description",
"imageUrl",
"timezone",
"startsAt",
"endsAt",
"allDay",
"sessions",
"location",
"campus",
"series",
"tags",
"registration"
]
}
},
"deleted": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"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)$"
},
"deletedAt": {
"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))$"
}
},
"required": [
"id",
"deletedAt"
]
}
}
},
"required": [
"schema",
"generatedAt",
"events",
"deleted"
]
}
+395
View File
@@ -0,0 +1,395 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/event.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.event/1"
},
"id": {
"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)$"
},
"origin": {
"type": "object",
"properties": {
"product": {
"type": "string",
"enum": [
"events",
"website",
"app"
]
},
"installId": {
"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)$"
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"product",
"installId",
"url"
]
},
"status": {
"type": "string",
"enum": [
"published",
"cancelled"
]
},
"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))$"
},
"title": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"summary": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"description": {
"anyOf": [
{
"type": "string",
"maxLength": 20000
},
{
"type": "null"
}
]
},
"imageUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"timezone": {
"type": "string",
"pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
},
"startsAt": {
"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))$"
},
"endsAt": {
"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))$"
},
"allDay": {
"type": "boolean"
},
"sessions": {
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"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)$"
},
"label": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"startsAt": {
"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))$"
},
"endsAt": {
"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))$"
},
"location": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"cancelled": {
"type": "boolean"
}
},
"required": [
"id",
"label",
"startsAt",
"endsAt",
"location",
"cancelled"
]
}
},
"location": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"address": {
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"onlineUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"address",
"onlineUrl"
]
},
{
"type": "null"
}
]
},
"campus": {
"anyOf": [
{
"type": "object",
"properties": {
"slug": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
},
"required": [
"slug",
"name"
]
},
{
"type": "null"
}
]
},
"series": {
"anyOf": [
{
"type": "object",
"properties": {
"id": {
"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)$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
},
"required": [
"id",
"name"
]
},
{
"type": "null"
}
]
},
"tags": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"maxLength": 100,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
}
},
"registration": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"origin",
"external",
"contact",
"none"
]
},
"url": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
},
"status": {
"type": "string",
"enum": [
"open",
"not_open",
"closed",
"full",
"waitlist"
]
},
"opensAt": {
"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"
}
]
},
"closesAt": {
"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"
}
]
},
"priceFrom": {
"anyOf": [
{
"type": "object",
"properties": {
"amountCents": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
}
},
"required": [
"amountCents",
"currency"
]
},
{
"type": "null"
}
]
}
},
"required": [
"mode",
"url",
"status",
"opensAt",
"closesAt",
"priceFrom"
]
}
},
"required": [
"schema",
"id",
"origin",
"status",
"updatedAt",
"title",
"summary",
"description",
"imageUrl",
"timezone",
"startsAt",
"endsAt",
"allDay",
"sessions",
"location",
"campus",
"series",
"tags",
"registration"
]
}
+96
View File
@@ -0,0 +1,96 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/health.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"uptimeSeconds": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"db": {
"type": "boolean"
},
"jobs": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"failedLast24h": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"mode",
"failedLast24h"
]
},
"lastBackupAt": {
"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"
}
]
},
"disk": {
"anyOf": [
{
"type": "object",
"properties": {
"freeBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totalBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"freeBytes",
"totalBytes"
]
},
{
"type": "null"
}
]
},
"errorsLast24h": {
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"pendingMigrations": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"uptimeSeconds",
"db",
"jobs",
"lastBackupAt",
"disk",
"errorsLast24h",
"pendingMigrations"
]
}
@@ -0,0 +1,49 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-ai-complete-request.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"helper": {
"type": "string",
"maxLength": 60,
"pattern": "^[a-z][a-z0-9_]*$"
},
"system": {
"type": "string"
},
"input": {
"type": "string"
},
"schema": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
},
"maxTokens": {
"type": "integer",
"minimum": 1,
"maximum": 8000
},
"effort": {
"type": "string",
"enum": [
"low",
"medium",
"high"
]
}
},
"required": [
"protocolVersion",
"helper",
"system",
"input",
"maxTokens"
]
}
@@ -0,0 +1,86 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-ai-complete-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"output": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
}
]
},
"usage": {
"type": "object",
"properties": {
"inputTokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"outputTokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"inputTokens",
"outputTokens"
]
},
"chargedCents": {
"type": "number",
"minimum": 0
},
"status": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"capReached": {
"type": "boolean"
},
"capCents": {
"type": "number",
"minimum": 0
},
"usedCents": {
"type": "number",
"minimum": 0
},
"usedPercent": {
"type": "number",
"minimum": 0
},
"renewsOn": {
"type": "string",
"format": "date",
"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])))$"
}
},
"required": [
"enabled",
"capReached",
"capCents",
"usedCents",
"usedPercent",
"renewsOn"
]
}
},
"required": [
"output",
"usage",
"chargedCents",
"status"
]
}
@@ -0,0 +1,14 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-ai-status-request.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
}
},
"required": [
"protocolVersion"
]
}
@@ -0,0 +1,38 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-ai-status.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"capReached": {
"type": "boolean"
},
"capCents": {
"type": "number",
"minimum": 0
},
"usedCents": {
"type": "number",
"minimum": 0
},
"usedPercent": {
"type": "number",
"minimum": 0
},
"renewsOn": {
"type": "string",
"format": "date",
"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])))$"
}
},
"required": [
"enabled",
"capReached",
"capCents",
"usedCents",
"usedPercent",
"renewsOn"
]
}
+18
View File
@@ -0,0 +1,18 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-error.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "string",
"pattern": "^[A-Z][A-Z0-9_]*$"
}
},
"required": [
"message",
"code"
]
}
@@ -0,0 +1,922 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-heartbeat-request.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"health": {
"type": "object",
"properties": {
"uptimeSeconds": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"db": {
"type": "boolean"
},
"jobs": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"failedLast24h": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"mode",
"failedLast24h"
]
},
"lastBackupAt": {
"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"
}
]
},
"disk": {
"anyOf": [
{
"type": "object",
"properties": {
"freeBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totalBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"freeBytes",
"totalBytes"
]
},
{
"type": "null"
}
]
},
"errorsLast24h": {
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"pendingMigrations": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"uptimeSeconds",
"db",
"jobs",
"lastBackupAt",
"disk",
"errorsLast24h",
"pendingMigrations"
]
},
"product": {
"type": "string",
"const": "events"
},
"stats": {
"type": "object",
"properties": {
"users": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"events": {
"type": "object",
"properties": {
"active": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"upcoming": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"total": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"active",
"upcoming",
"total"
]
},
"registrations": {
"type": "object",
"properties": {
"last30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"total": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"last30d",
"total"
]
},
"tickets": {
"type": "object",
"properties": {
"last30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"total": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"last30d",
"total"
]
},
"checkIns": {
"type": "object",
"properties": {
"last30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"last30d"
]
},
"messages": {
"anyOf": [
{
"type": "object",
"properties": {
"email30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"whatsapp30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"email30d",
"whatsapp30d"
]
},
{
"type": "null"
}
]
},
"paymentProviders": {
"type": "array",
"items": {
"type": "string"
}
},
"campuses": {
"type": "boolean"
},
"campusCount": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"income": {
"type": "object",
"properties": {
"last30d": {
"type": "string",
"enum": [
"R0–R1 000",
"R1 001–R5 000",
"R5 001–R20 000",
"R20 001–R50 000",
"R50 001–R100 000",
"R100 001–R150 000",
"R150 001–R250 000",
"R250 001–R400 000",
"R400 001–R700 000",
"R700 001–R1 000 000",
"R1 000 001–R2 500 000",
"R2 500 001–R5 000 000",
"R5 000 001–R10 000 000",
"over R10 000 000"
]
},
"allTime": {
"type": "string",
"enum": [
"R0–R1 000",
"R1 001–R5 000",
"R5 001–R20 000",
"R20 001–R50 000",
"R50 001–R100 000",
"R100 001–R150 000",
"R150 001–R250 000",
"R250 001–R400 000",
"R400 001–R700 000",
"R700 001–R1 000 000",
"R1 000 001–R2 500 000",
"R2 500 001–R5 000 000",
"R5 000 001–R10 000 000",
"over R10 000 000"
]
},
"eventIncome12m": {
"type": "string",
"enum": [
"R0–R1 000",
"R1 001–R5 000",
"R5 001–R20 000",
"R20 001–R50 000",
"R50 001–R100 000",
"R100 001–R150 000",
"R150 001–R250 000",
"R250 001–R400 000",
"R400 001–R700 000",
"R700 001–R1 000 000",
"R1 000 001–R2 500 000",
"R2 500 001–R5 000 000",
"R5 000 001–R10 000 000",
"over R10 000 000"
]
}
},
"required": [
"last30d",
"allTime",
"eventIncome12m"
]
}
},
"required": [
"users",
"events",
"registrations",
"tickets",
"checkIns",
"messages",
"paymentProviders",
"campuses",
"campusCount",
"income"
]
}
},
"required": [
"protocolVersion",
"version",
"health",
"product",
"stats"
]
},
{
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"health": {
"type": "object",
"properties": {
"uptimeSeconds": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"db": {
"type": "boolean"
},
"jobs": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"failedLast24h": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"mode",
"failedLast24h"
]
},
"lastBackupAt": {
"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"
}
]
},
"disk": {
"anyOf": [
{
"type": "object",
"properties": {
"freeBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totalBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"freeBytes",
"totalBytes"
]
},
{
"type": "null"
}
]
},
"errorsLast24h": {
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"pendingMigrations": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"uptimeSeconds",
"db",
"jobs",
"lastBackupAt",
"disk",
"errorsLast24h",
"pendingMigrations"
]
},
"product": {
"type": "string",
"const": "website"
},
"stats": {
"type": "object",
"properties": {
"pages": {
"type": "object",
"properties": {
"published": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"drafts": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"published",
"drafts"
]
},
"messages": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"last30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"total",
"last30d"
]
},
"events": {
"type": "object",
"properties": {
"upcomingSimple": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"imported": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"upcomingSimple",
"imported"
]
},
"editors": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"storage": {
"type": "object",
"properties": {
"usedBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"includedBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"usedBytes",
"includedBytes"
]
}
},
"required": [
"pages",
"messages",
"events",
"editors",
"storage"
]
}
},
"required": [
"protocolVersion",
"version",
"health",
"product",
"stats"
]
},
{
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"health": {
"type": "object",
"properties": {
"uptimeSeconds": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"db": {
"type": "boolean"
},
"jobs": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"failedLast24h": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"mode",
"failedLast24h"
]
},
"lastBackupAt": {
"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"
}
]
},
"disk": {
"anyOf": [
{
"type": "object",
"properties": {
"freeBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totalBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"freeBytes",
"totalBytes"
]
},
{
"type": "null"
}
]
},
"errorsLast24h": {
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"pendingMigrations": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"uptimeSeconds",
"db",
"jobs",
"lastBackupAt",
"disk",
"errorsLast24h",
"pendingMigrations"
]
},
"product": {
"type": "string",
"const": "app"
},
"stats": {
"type": "object",
"properties": {
"activeMembers90d": {
"type": "string",
"enum": [
"0–100",
"101–300",
"301–750",
"751–2 000",
"2 001–5 000",
"over 5 000"
]
},
"modules": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$"
}
},
"prayer": {
"type": "object",
"properties": {
"coverageLast7dPercent": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"activeCommitments": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"coverageLast7dPercent",
"activeCommitments"
]
},
"announcements": {
"type": "object",
"properties": {
"last30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"last30d"
]
},
"messages": {
"type": "object",
"properties": {
"email30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"whatsapp30d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"email30d",
"whatsapp30d"
]
}
},
"required": [
"activeMembers90d",
"modules",
"prayer",
"announcements",
"messages"
]
}
},
"required": [
"protocolVersion",
"version",
"health",
"product",
"stats"
]
},
{
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"health": {
"type": "object",
"properties": {
"uptimeSeconds": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"db": {
"type": "boolean"
},
"jobs": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"failedLast24h": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"mode",
"failedLast24h"
]
},
"lastBackupAt": {
"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"
}
]
},
"disk": {
"anyOf": [
{
"type": "object",
"properties": {
"freeBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totalBytes": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"freeBytes",
"totalBytes"
]
},
{
"type": "null"
}
]
},
"errorsLast24h": {
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"pendingMigrations": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"uptimeSeconds",
"db",
"jobs",
"lastBackupAt",
"disk",
"errorsLast24h",
"pendingMigrations"
]
},
"product": {
"type": "string",
"const": "accounts"
},
"stats": {
"type": "object",
"properties": {
"accounts": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"active90d": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"total",
"active90d"
]
},
"twoFactor": {
"type": "object",
"properties": {
"email": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"whatsapp": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"totp": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"off": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"email",
"whatsapp",
"totp",
"off"
]
},
"linkedProducts": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"accounts",
"twoFactor",
"linkedProducts"
]
}
},
"required": [
"protocolVersion",
"version",
"health",
"product",
"stats"
]
}
]
}
@@ -0,0 +1,163 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-heartbeat-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"licence": {
"type": "string"
},
"latestVersion": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
{
"type": "null"
}
]
},
"releases": {
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"releasedAt": {
"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))$"
},
"urgent": {
"type": "boolean"
},
"notes": {
"type": "string"
}
},
"required": [
"version",
"releasedAt",
"urgent",
"notes"
]
}
},
"notices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"level": {
"type": "string",
"enum": [
"info",
"maintenance",
"warning"
]
},
"title": {
"type": "string"
},
"message": {
"type": "string"
},
"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"
}
]
},
"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))$"
}
},
"required": [
"id",
"level",
"title",
"message",
"startsAt",
"endsAt",
"updatedAt"
]
}
},
"linkedProducts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"product": {
"type": "string",
"enum": [
"events",
"website",
"app",
"accounts"
]
},
"installId": {
"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)$"
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"publicKey": {
"type": "string",
"pattern": "^-----BEGIN PUBLIC KEY-----.*"
}
},
"required": [
"product",
"installId",
"url",
"publicKey"
]
}
},
"serverTime": {
"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))$"
}
},
"required": [
"licence",
"latestVersion",
"releases",
"notices",
"linkedProducts",
"serverTime"
]
}
@@ -0,0 +1,101 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-licence-payload.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"v": {
"type": "number",
"const": 1
},
"licenceId": {
"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)$"
},
"installId": {
"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)$"
},
"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)$"
},
"product": {
"type": "string",
"enum": [
"events",
"website",
"app",
"accounts"
]
},
"customer": {
"type": "string"
},
"plan": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"active",
"suspended",
"revoked"
]
},
"licenceExpiresAt": {
"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"
}
]
},
"graceDays": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"issuedAt": {
"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))$"
},
"validUntil": {
"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))$"
},
"limits": {
"type": "object",
"properties": {
"aiMonthlyCapCents": {
"type": "number",
"minimum": 0
}
},
"required": [
"aiMonthlyCapCents"
]
}
},
"required": [
"v",
"licenceId",
"installId",
"customer",
"plan",
"status",
"licenceExpiresAt",
"graceDays",
"issuedAt",
"validUntil",
"limits"
]
}
@@ -0,0 +1,32 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-public-key-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersions": {
"type": "array",
"items": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"keyId": {
"type": "string"
},
"algorithm": {
"type": "string",
"const": "Ed25519"
},
"publicKey": {
"type": "string",
"pattern": "^-----BEGIN PUBLIC KEY-----.*"
}
},
"required": [
"protocolVersions",
"keyId",
"algorithm",
"publicKey"
]
}
@@ -0,0 +1,154 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-register-request.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"licenceKey": {
"type": "string",
"pattern": "^[A-Z]{3}(-[A-Z0-9]{4}){4}$"
},
"product": {
"type": "string",
"enum": [
"events",
"website",
"app",
"accounts"
]
},
"install": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"adminContact": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"type": "null"
}
]
},
"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"
}
]
}
},
"required": [
"name",
"email"
]
},
{
"type": "null"
}
]
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"timezone": {
"type": "string",
"pattern": "^[A-Za-z_]+(\\/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
},
"server": {
"type": "object",
"properties": {
"node": {
"type": "string"
},
"postgres": {
"type": [
"string",
"null"
]
},
"os": {
"type": "string"
}
},
"required": [
"node",
"postgres",
"os"
]
},
"features": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string"
},
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"publicKey": {
"type": "string",
"pattern": "^-----BEGIN PUBLIC KEY-----.*"
}
},
"required": [
"name",
"url",
"adminContact",
"version",
"timezone",
"server",
"features",
"publicKey"
]
}
},
"required": [
"protocolVersion",
"licenceKey",
"product",
"install"
]
}
@@ -0,0 +1,174 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-register-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"installId": {
"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)$"
},
"installSecret": {
"type": "string",
"minLength": 32
},
"licence": {
"type": "string"
},
"heartbeatIntervalMinutes": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"latestVersion": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
{
"type": "null"
}
]
},
"releases": {
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"releasedAt": {
"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))$"
},
"urgent": {
"type": "boolean"
},
"notes": {
"type": "string"
}
},
"required": [
"version",
"releasedAt",
"urgent",
"notes"
]
}
},
"notices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"level": {
"type": "string",
"enum": [
"info",
"maintenance",
"warning"
]
},
"title": {
"type": "string"
},
"message": {
"type": "string"
},
"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"
}
]
},
"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))$"
}
},
"required": [
"id",
"level",
"title",
"message",
"startsAt",
"endsAt",
"updatedAt"
]
}
},
"linkedProducts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"product": {
"type": "string",
"enum": [
"events",
"website",
"app",
"accounts"
]
},
"installId": {
"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)$"
},
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"publicKey": {
"type": "string",
"pattern": "^-----BEGIN PUBLIC KEY-----.*"
}
},
"required": [
"product",
"installId",
"url",
"publicKey"
]
}
}
},
"required": [
"installId",
"installSecret",
"licence",
"heartbeatIntervalMinutes",
"latestVersion",
"releases",
"notices",
"linkedProducts"
]
}
@@ -0,0 +1,13 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-update-request-cancel-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"cancelled": {
"type": "boolean"
}
},
"required": [
"cancelled"
]
}
@@ -0,0 +1,14 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-update-request-cancel.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
}
},
"required": [
"protocolVersion"
]
}
@@ -0,0 +1,32 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-update-request-response.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"requestedAt": {
"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))$"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
},
"alreadyRequested": {
"type": "boolean"
},
"changed": {
"type": "boolean"
},
"previousVersion": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
}
},
"required": [
"requestedAt",
"version",
"alreadyRequested",
"changed"
]
}
@@ -0,0 +1,19 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-update-request.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocolVersion": {
"type": "number",
"const": 2
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
}
},
"required": [
"protocolVersion",
"version"
]
}
@@ -0,0 +1,125 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/identity-claims.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"given_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"family_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"email": {
"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,}$"
},
"email_verified": {
"type": "boolean"
},
"phone_number": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"phone_number_verified": {
"type": "boolean"
},
"news_consent": {
"type": "object",
"properties": {
"email": {
"type": "boolean"
},
"whatsapp": {
"type": "boolean"
}
},
"required": [
"email",
"whatsapp"
]
},
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"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)$"
},
"amr": {
"maxItems": 10,
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 20
}
},
"two_factor": {
"anyOf": [
{
"type": "string",
"enum": [
"email",
"whatsapp",
"totp"
]
},
{
"type": "null"
}
]
},
"privacy_notice_version": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"name",
"given_name",
"family_name",
"email",
"email_verified",
"phone_number",
"phone_number_verified",
"news_consent",
"schema",
"sub",
"amr",
"two_factor",
"privacy_notice_version"
]
}
@@ -0,0 +1,52 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-deleted-reply.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"status": {
"type": "string",
"const": "deleted"
}
},
"required": [
"schema",
"status"
]
},
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"status": {
"type": "string",
"const": "deferred"
},
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 500
},
"retryAfter": {
"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))$"
}
},
"required": [
"schema",
"status",
"reason",
"retryAfter"
]
}
]
}
@@ -0,0 +1,43 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-deleted.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.deleted"
},
"approvedAt": {
"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))$"
}
},
"required": [
"schema",
"callId",
"occurredAt",
"sub",
"type",
"approvedAt"
]
}
@@ -0,0 +1,77 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-export-reply.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"exportId": {
"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)$"
},
"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)$"
},
"product": {
"type": "string",
"enum": [
"events",
"website",
"app",
"accounts"
]
},
"generatedAt": {
"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))$"
},
"sections": {
"maxItems": 100,
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"maxLength": 50,
"pattern": "^[a-z][a-z0-9_]*$"
},
"title": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"records": {
"type": "array",
"items": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
}
}
},
"required": [
"key",
"title",
"records"
]
}
}
},
"required": [
"schema",
"exportId",
"sub",
"product",
"generatedAt",
"sections"
]
}
@@ -0,0 +1,43 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-export.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.export"
},
"exportId": {
"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",
"callId",
"occurredAt",
"sub",
"type",
"exportId"
]
}
@@ -0,0 +1,19 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-updated-reply.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"ok": {
"type": "boolean",
"const": true
}
},
"required": [
"schema",
"ok"
]
}
@@ -0,0 +1,118 @@
{
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/user-updated.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity/1"
},
"callId": {
"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)$"
},
"occurredAt": {
"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))$"
},
"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)$"
},
"type": {
"type": "string",
"const": "user.updated"
},
"profile": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"given_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"family_name": {
"anyOf": [
{
"type": "string",
"maxLength": 100
},
{
"type": "null"
}
]
},
"email": {
"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,}$"
},
"email_verified": {
"type": "boolean"
},
"phone_number": {
"anyOf": [
{
"type": "string",
"pattern": "^\\+[1-9]\\d{6,14}$"
},
{
"type": "null"
}
]
},
"phone_number_verified": {
"type": "boolean"
},
"news_consent": {
"type": "object",
"properties": {
"email": {
"type": "boolean"
},
"whatsapp": {
"type": "boolean"
}
},
"required": [
"email",
"whatsapp"
]
}
},
"required": [
"name",
"given_name",
"family_name",
"email",
"email_verified",
"phone_number",
"phone_number_verified",
"news_consent"
]
}
},
"required": [
"schema",
"callId",
"occurredAt",
"sub",
"type",
"profile"
]
}
+101
View File
@@ -0,0 +1,101 @@
// Generates the JSON Schema files in `schemas/` from the zod schemas (ROADMAP-v3 §2), for
// consumers that don't use TypeScript or zod. Run after the build (`npm run build` does it):
// node scripts/json-schemas.cjs write schemas/
// node scripts/json-schemas.cjs --check fail if schemas/ is out of date
// The test (tests/json-schemas.test.ts) uses `buildSchemas` with the source, so the files in git
// always match the zod schemas.
const { z } = require("zod");
const fs = require("node:fs");
const path = require("node:path");
const BASE_ID = "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/";
/** File name (without .json) → schema, from the package exports (`c`) and `c.hub`. */
function contracts(c) {
return {
"event": c.eventSchema,
"event-feed": c.eventFeedSchema,
"event-changed": c.eventChangedSchema,
"church": c.churchSchema,
"identity-claims": c.identityClaimsSchema,
"accounts-call": c.accountsCallSchema,
"user-updated": c.userUpdatedSchema,
"user-updated-reply": c.userUpdatedReplySchema,
"user-deleted": c.userDeletedSchema,
"user-deleted-reply": c.userDeletedReplySchema,
"user-export": c.userExportSchema,
"user-export-reply": c.userExportReplySchema,
"hub-register-request": c.hub.registerRequestSchema,
"hub-register-response": c.hub.registerResponseSchema,
"hub-heartbeat-request": c.hub.heartbeatRequestSchema,
"hub-heartbeat-response": c.hub.heartbeatResponseSchema,
"hub-licence-payload": c.hub.licencePayloadSchema,
"hub-public-key-response": c.hub.publicKeyResponseSchema,
"hub-update-request": c.hub.updateRequestSchema,
"hub-update-request-response": c.hub.updateRequestResponseSchema,
"hub-update-request-cancel": c.hub.updateRequestCancelSchema,
"hub-update-request-cancel-response": c.hub.updateRequestCancelResponseSchema,
"hub-ai-status-request": c.hub.aiStatusRequestSchema,
"hub-ai-status": c.hub.aiStatusSchema,
"hub-ai-complete-request": c.hub.aiCompleteRequestSchema,
"hub-ai-complete-response": c.hub.aiCompleteResponseSchema,
"hub-error": c.hub.hubErrorSchema,
"health": c.hub.healthSchema,
};
}
// zod writes .startsWith() / .endsWith() / .includes() as a `format` that isn't a JSON Schema
// format (strict validators such as Ajv refuse it) next to a `pattern` that does the real check.
const ZOD_ONLY_FORMATS = new Set(["starts_with", "ends_with", "includes"]);
function dropZodFormats(ctx) {
const json = ctx.jsonSchema;
if (ZOD_ONLY_FORMATS.has(json.format) && json.pattern) delete json.format;
}
/**
* name → JSON Schema (draft 2020-12). `io: "input"` describes what may be sent: unknown fields
* are allowed (consumers drop them, never refuse them) and defaults are optional.
* Checks zod can't express in JSON Schema (refinements, e.g. startsAt matching the sessions)
* only run in zod.
*/
function buildSchemas(c) {
const out = {};
for (const [name, schema] of Object.entries(contracts(c))) {
if (!schema) throw new Error(`json-schemas: no schema exported for "${name}"`);
out[name] = { $id: `${BASE_ID}${name}.json`, ...z.toJSONSchema(schema, { io: "input", override: dropZodFormats }) };
}
return out;
}
const serialise = (json) => `${JSON.stringify(json, null, 2)}\n`;
function main() {
const dir = path.join(__dirname, "..", "schemas");
const schemas = buildSchemas(require("../dist/index.js"));
const check = process.argv.includes("--check");
const stale = [];
if (!check) fs.mkdirSync(dir, { recursive: true });
const wanted = new Set(Object.keys(schemas).map((n) => `${n}.json`));
for (const [name, json] of Object.entries(schemas)) {
const file = path.join(dir, `${name}.json`);
const text = serialise(json);
const current = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null;
if (current === text) continue;
if (check) stale.push(`${name}.json`);
else fs.writeFileSync(file, text);
}
for (const file of fs.existsSync(dir) ? fs.readdirSync(dir) : []) {
if (!file.endsWith(".json") || wanted.has(file)) continue;
if (check) stale.push(`${file} (no longer generated)`);
else fs.unlinkSync(path.join(dir, file));
}
if (check && stale.length) {
console.error(`schemas/ is out of date: ${stale.join(", ")}. Run npm run build.`);
process.exit(1);
}
console.log(check ? "schemas/ is up to date" : `Wrote ${Object.keys(schemas).length} JSON Schema files to schemas/`);
}
if (require.main === module) main();
module.exports = { buildSchemas, serialise };
@@ -0,0 +1,82 @@
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import Ajv2020 from "ajv/dist/2020";
import addFormats from "ajv-formats";
import * as contracts from "../src";
import { SAMPLES, sample } from "./helpers";
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { buildSchemas, serialise } = require("../scripts/json-schemas.cjs") as {
buildSchemas: (c: typeof contracts) => Record<string, object>;
serialise: (json: object) => string;
};
const SCHEMAS_DIR = join(__dirname, "..", "schemas");
const schemas = buildSchemas(contracts);
/** Every sample file and the JSON Schema (file name without .json) it must pass. */
const SAMPLE_SCHEMA: Record<string, string> = {
"event.json": "event",
"event-simple.json": "event",
"event-feed.json": "event-feed",
"event-changed.json": "event-changed",
"church.json": "church",
"identity-claims.json": "identity-claims",
"user-updated.json": "user-updated",
"user-deleted.json": "user-deleted",
"user-deleted-reply.json": "user-deleted-reply",
"user-export.json": "user-export",
"user-export-reply.json": "user-export-reply",
"hub-register-request.json": "hub-register-request",
"hub-register-response.json": "hub-register-response",
"hub-heartbeat-events.json": "hub-heartbeat-request",
"hub-heartbeat-website.json": "hub-heartbeat-request",
"hub-heartbeat-app.json": "hub-heartbeat-request",
"hub-heartbeat-accounts.json": "hub-heartbeat-request",
"hub-heartbeat-response.json": "hub-heartbeat-response",
"hub-licence-payload.json": "hub-licence-payload",
};
describe("JSON Schema (schemas/)", () => {
it("the files in schemas/ match the zod schemas (run npm run build after changing a contract)", () => {
const files = readdirSync(SCHEMAS_DIR).filter((f) => f.endsWith(".json")).sort();
expect(files).toEqual(Object.keys(schemas).map((n) => `${n}.json`).sort());
for (const [name, json] of Object.entries(schemas)) {
expect(readFileSync(join(SCHEMAS_DIR, `${name}.json`), "utf8").replace(/\r\n/g, "\n")).toBe(serialise(json));
}
});
const ajv = new Ajv2020({ allErrors: true, strict: true });
addFormats(ajv);
for (const json of Object.values(schemas)) ajv.addSchema(json);
const validatorFor = (name: string) => {
const validate = ajv.getSchema((schemas[name] as { $id: string }).$id);
if (!validate) throw new Error(`no JSON Schema "${name}"`);
return validate;
};
it("every JSON Schema compiles", () => {
for (const name of Object.keys(schemas)) expect(() => validatorFor(name)).not.toThrow();
});
it("every sample has a JSON Schema", () => {
const files = readdirSync(SAMPLES).filter((f) => f.endsWith(".json"));
expect(files.filter((f) => !(f in SAMPLE_SCHEMA))).toEqual([]);
});
it.each(Object.entries(SAMPLE_SCHEMA))("%s passes the JSON Schema %s", (file, name) => {
const validate = validatorFor(name);
validate(sample(file));
expect(validate.errors ?? []).toEqual([]);
});
it("refuses a payload with a wrong schema name", () => {
const validate = validatorFor("event");
expect(validate({ ...(sample("event.json") as object), schema: "crosscode.event/2" })).toBe(false);
});
it("allows fields it doesn't know (consumers drop them, never refuse them)", () => {
const validate = validatorFor("event");
expect(validate({ ...(sample("event.json") as object), somethingNew: true })).toBe(true);
});
});