{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://truecalc.dev/schema/workbook.v1.schema.json",
"title": "TrueCalc Workbook v1",
"description": "Structural schema for a TrueCalc workbook document (schema spec v1). Rules that JSON Schema cannot express -- canonical key ordering, ECMAScript number formatting, spill reconstruction, duplicate-key rejection, simple-case-fold uniqueness, named-range ref canonicality, and resource limits -- are governed by the prose spec and enforced by Workbook::from_json, not here.",
"type": "object",
"additionalProperties": false,
"required": [
"engine",
"names",
"sheets",
"version"
],
"properties": {
"engine": {
"enum": [
"sheets",
"excel"
]
},
"version": {
"const": "1"
},
"names": {
"type": "array",
"items": {
"$ref": "#/$defs/namedRange"
}
},
"sheets": {
"type": "array",
"items": {
"$ref": "#/$defs/worksheet"
}
}
},
"$defs": {
"worksheet": {
"type": "object",
"additionalProperties": false,
"required": [
"cells",
"name"
],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"cells": {
"type": "object",
"propertyNames": {
"pattern": "^[A-Z]{1,3}[1-9][0-9]{0,7}$"
},
"additionalProperties": {
"$ref": "#/$defs/cell"
}
}
}
},
"cell": {
"type": "object",
"additionalProperties": false,
"required": [
"value"
],
"properties": {
"formula": {
"type": "string"
},
"value": {
"$ref": "#/$defs/value"
}
}
},
"namedRange": {
"type": "object",
"additionalProperties": false,
"required": [
"name",
"ref"
],
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
},
"ref": {
"type": "string"
}
}
},
"value": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "number"
},
"value": {
"type": "number"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "text"
},
"value": {
"type": "string"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "boolean"
},
"value": {
"type": "boolean"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"error"
],
"properties": {
"type": {
"const": "error"
},
"error": {
"type": "string"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "empty"
},
"value": {
"type": "null"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "date"
},
"value": {
"type": "number"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "array"
},
"value": {
"type": "array",
"minItems": 1,
"items": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/scalarValue"
}
}
}
}
}
]
},
"scalarValue": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "number"
},
"value": {
"type": "number"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "text"
},
"value": {
"type": "string"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "boolean"
},
"value": {
"type": "boolean"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"error"
],
"properties": {
"type": {
"const": "error"
},
"error": {
"type": "string"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "empty"
},
"value": {
"type": "null"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "date"
},
"value": {
"type": "number"
}
}
}
]
}
}
}