Files
racket-wiki/static/schemas/racket-wiki-cmap-bundle-v1.schema.json
T

183 lines
6.3 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://racket-wiki.local/schemas/racket-wiki-cmap-bundle-v1.schema.json",
"title": "Racket Wiki CMap bundle version 1",
"type": "object",
"required": ["format", "formatVersion", "rootCmapSlug", "cmaps", "concepts", "pages"],
"properties": {
"$schema": { "type": "string" },
"format": { "const": "racket-wiki-cmap-bundle" },
"formatVersion": { "const": 1 },
"exportedAt": { "type": "string", "format": "date-time" },
"generator": { "type": "string" },
"rootCmapSlug": { "$ref": "#/$defs/slug" },
"cmaps": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/cmap" }
},
"concepts": {
"type": "array",
"items": { "$ref": "#/$defs/concept" }
},
"pages": {
"type": "array",
"items": { "$ref": "#/$defs/page" }
},
"missing": {
"type": "object",
"properties": {
"cmaps": { "type": "array", "items": { "$ref": "#/$defs/slug" } },
"pages": { "type": "array", "items": { "type": "string", "minLength": 1 } }
},
"additionalProperties": false
}
},
"additionalProperties": false,
"$defs": {
"slug": {
"type": "string",
"pattern": "^[\\p{L}\\p{N}][\\p{L}\\p{N}._-]{0,119}$"
},
"conceptId": {
"type": "string",
"anyOf": [
{ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" },
{ "pattern": "^new:[A-Za-z0-9][A-Za-z0-9._-]{0,119}$" }
]
},
"concept": {
"type": "object",
"required": ["id", "label"],
"properties": {
"id": { "$ref": "#/$defs/conceptId" },
"label": { "type": "string", "minLength": 1 },
"synopsis": { "type": "string" },
"aspects": { "type": "array", "items": { "type": "string" } },
"tags": { "type": "array", "items": {} },
"descriptionPageSlug": { "type": ["string", "null"] },
"pageSlug": { "type": ["string", "null"] },
"cmapSlug": { "type": ["string", "null"] },
"externalUrl": { "type": ["string", "null"], "pattern": "^[hH][tT][tT][pP][sS]?://" },
"imageSource": { "type": ["string", "null"] }
},
"additionalProperties": false
},
"conceptReference": {
"type": "object",
"required": ["id"],
"properties": { "id": { "$ref": "#/$defs/conceptId" } },
"additionalProperties": false
},
"item": {
"type": "object",
"required": ["id", "x", "y"],
"properties": {
"id": { "type": "integer" },
"conceptId": { "$ref": "#/$defs/conceptId" },
"kind": { "enum": ["concept", "page", "submap", "phrase"] },
"label": { "type": "string" },
"x": { "type": "number" },
"y": { "type": "number" },
"width": { "type": "number" },
"height": { "type": "number" },
"parentSubmapId": { "type": ["integer", "null"] },
"hidden": { "type": "boolean" },
"backgroundColor": { "type": "string" },
"borderColor": { "type": "string" },
"textColor": { "type": "string" },
"fontFamily": { "type": "string" },
"fontSize": { "type": "number" },
"fontWeight": { "type": "string" },
"fontStyle": { "type": "string" },
"synopsisFontSize": { "type": "number" },
"synopsisFontWeight": { "type": "string" },
"synopsisFontStyle": { "type": "string" },
"submapBackgroundColor": { "type": "string" },
"submapBorderColor": { "type": "string" }
},
"allOf": [
{
"if": { "required": ["kind"], "properties": { "kind": { "const": "phrase" } } },
"then": { "required": ["label"] },
"else": { "required": ["conceptId"] }
}
],
"additionalProperties": true
},
"connector": {
"type": "object",
"required": ["sourceId", "targetId"],
"properties": {
"id": { "type": "integer" },
"sourceId": { "type": "integer" },
"targetId": { "type": "integer" },
"hasArrow": { "type": "boolean" }
},
"additionalProperties": true
},
"document": {
"type": "object",
"required": ["concepts", "items", "connectors"],
"properties": {
"schemaVersion": { "type": "integer" },
"metadata": { "type": "object", "additionalProperties": true },
"derivedView": {
"type": "object",
"required": ["sourceCmapSlug", "rootItemId"],
"properties": {
"sourceCmapSlug": { "$ref": "#/$defs/slug" },
"rootItemId": { "type": "integer" }
},
"additionalProperties": false
},
"concepts": { "type": "array", "items": { "$ref": "#/$defs/conceptReference" } },
"items": { "type": "array", "items": { "$ref": "#/$defs/item" } },
"connectors": { "type": "array", "items": { "$ref": "#/$defs/connector" } },
"conceptMaps": { "type": "array" },
"viewport": { "type": "object" }
},
"additionalProperties": true
},
"cmap": {
"type": "object",
"required": ["slug", "title", "document"],
"properties": {
"slug": { "$ref": "#/$defs/slug" },
"title": { "type": "string", "minLength": 1 },
"document": { "$ref": "#/$defs/document" }
},
"additionalProperties": false
},
"page": {
"type": "object",
"required": ["reference", "title", "markdown", "tags"],
"properties": {
"reference": { "type": "string", "minLength": 1 },
"title": { "type": "string", "minLength": 1 },
"markdown": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"attachments": {
"type": "array",
"items": { "$ref": "#/$defs/attachment" }
}
},
"additionalProperties": false
},
"attachment": {
"type": "object",
"required": ["url", "name", "mimeType", "contentBase64"],
"properties": {
"url": { "type": "string", "pattern": "^/uploads/" },
"name": { "type": "string", "minLength": 1 },
"mimeType": { "type": "string", "minLength": 1 },
"contentBase64": {
"type": "string",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
}
},
"additionalProperties": false
}
}
}