schema/view-file-1.json
|
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://pivotkit.eize.dev/schema/view-file-1.json", "title": "pivotkit view file, format version 1", "description": "A pivotkit view (the report's layout as JSON) with what a person and another pivotkit need to know about it. Readers ignore keys they do not know; a newer formatVersion or view.version is refused. See https://pivotkit.eize.dev/reference/view-file/", "type": "object", "required": ["format", "formatVersion", "view"], "properties": { "$schema": { "description": "This schema's address.", "type": "string" }, "format": { "description": "Marks a view file; a document without it is read as a bare view.", "const": "pivotkit-view" }, "formatVersion": { "description": "The version of this envelope. A reader refuses a newer one.", "const": 1 }, "name": { "description": "What the view shows, for people. Plain text, at most 256 characters.", "type": "string", "maxLength": 256 }, "description": { "description": "More about the view, for people. Plain text, at most 2,000 characters; left out when empty.", "type": "string", "maxLength": 2000 }, "createdAt": { "description": "When the file was written, in UTC (ISO 8601). Optional: a file without it is the same bytes on every export.", "type": "string", "format": "date-time" }, "generator": { "description": "The program that wrote the file.", "type": "object", "properties": { "name": { "type": "string", "maxLength": 256 }, "version": { "type": "string", "maxLength": 256 } }, "required": ["name"] }, "source": { "description": "The data the view was made for.", "type": "object", "properties": { "id": { "description": "The host's stable name of the data (\"sales\").", "type": "string", "maxLength": 256 }, "name": { "description": "The data's name for people.", "type": "string", "maxLength": 256 }, "fields": { "description": "The fields of the data the view uses (rows, columns, values, filters, sort; a grouping as its source field), with their types.", "type": "array", "maxItems": 1000, "items": { "type": "object", "required": ["name", "type"], "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 256 }, "type": { "enum": ["string", "number", "date", "boolean", "null"] } } } } } }, "extensions": { "description": "Reserved for hosts: their own data under a key of their own (a domain or a package name). pivotkit ignores it.", "type": "object" }, "view": { "description": "The view itself, with its own version (pivotkit-core's View). Every reader passes it through normalize() against its data.", "type": "object", "properties": { "version": { "type": "integer", "minimum": 1 }, "filters": { "description": "The filters, applied together (and). Each names a field and its type; normalize() checks the rest. A reader that does not know a type reports that filter as an unused part and leaves it out.", "type": "array", "maxItems": 128, "items": { "type": "object", "required": ["field", "type"], "properties": { "field": { "description": "A column of the data or a grouping of the view.", "type": "string" }, "type": { "description": "The filter's type. The types this version knows are listed; another one (a newer pivotkit's) is valid here, and a reader that does not know it reports it as unused.", "anyOf": [{ "enum": ["include", "exclude", "label", "compare", "relative", "top", "value"] }, { "type": "string" }] } }, "allOf": [ { "if": { "properties": { "type": { "const": "compare" } } }, "then": { "description": "The item itself compared: a number (a grouping's key, year 2022, month 202503) or a date as its calendar day (\"2022-03-01\"); value2 with between and notBetween. A date grouping with a day as the value is compared by its source dates (\"between 2025-01-01 and 2025-12-31\" keeps that year).", "required": ["op", "value"], "properties": { "op": { "enum": ["=", "!=", ">", ">=", "<", "<=", "between", "notBetween"] }, "value": { "description": "A number (also as text, \"2022\") or a date \"2022-03-01\".", "type": ["number", "string"] }, "value2": { "type": ["number", "string"] } } } }, { "if": { "properties": { "type": { "const": "relative" } } }, "then": { "description": "The dates of the last count years, months or days, today's included, on a date field or a grouping of one; today is the reader's. With anchor \"latest\" the range ends with the latest date of the field's data instead of today.", "required": ["unit", "count"], "properties": { "unit": { "enum": ["year", "month", "day"] }, "count": { "type": "integer", "minimum": 1, "maximum": 500 }, "anchor": { "enum": ["today", "latest"] } } } } ] } } } } } } |