Files
metabuilder/packages/json_script_example/seed/components.schema.json
2025-12-31 15:06:10 +00:00

317 lines
8.4 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://metabuilder.dev/schemas/json-script-components.schema.json",
"title": "JSON Script Components",
"description": "Declarative UI component definitions for JSON scripts",
"type": "object",
"required": ["schema_version", "package"],
"properties": {
"$schema": {
"type": "string",
"description": "JSON Schema reference"
},
"schema_version": {
"type": "string",
"description": "Schema version",
"pattern": "^\\d+\\.\\d+\\.\\d+$"
},
"package": {
"type": "string",
"description": "Package identifier"
},
"description": {
"type": "string",
"description": "Component file description"
},
"exports": {
"type": "object",
"description": "Exported components",
"properties": {
"components": {
"type": "array",
"items": { "type": "string" }
}
}
},
"components": {
"type": "array",
"description": "Component definitions",
"items": {
"$ref": "#/definitions/component"
}
}
},
"definitions": {
"component": {
"type": "object",
"required": ["id", "name", "render"],
"properties": {
"id": {
"type": "string",
"description": "Unique component identifier (snake_case)"
},
"name": {
"type": "string",
"description": "Component name (PascalCase)"
},
"exported": {
"type": "boolean",
"description": "Whether component is exported",
"default": false
},
"docstring": {
"$ref": "#/definitions/docstring"
},
"props": {
"type": "array",
"description": "Component prop definitions",
"items": {
"$ref": "#/definitions/prop"
}
},
"state": {
"type": "object",
"description": "Component state with initial values",
"additionalProperties": true
},
"handlers": {
"type": "object",
"description": "Event handler definitions",
"additionalProperties": {
"$ref": "#/definitions/handler"
}
},
"computed": {
"type": "object",
"description": "Computed property definitions",
"additionalProperties": {
"$ref": "#/definitions/computedProperty"
}
},
"render": {
"$ref": "#/definitions/renderDefinition"
}
}
},
"prop": {
"type": "object",
"required": ["name", "type"],
"properties": {
"name": {
"type": "string",
"description": "Prop name"
},
"type": {
"type": "string",
"description": "Prop type",
"enum": ["string", "number", "boolean", "object", "array", "function", "any"]
},
"optional": {
"type": "boolean",
"description": "Whether prop is optional",
"default": false
},
"default": {
"description": "Default prop value"
},
"description": {
"type": "string",
"description": "Prop description"
}
}
},
"handler": {
"type": "object",
"required": ["body"],
"properties": {
"params": {
"type": "array",
"description": "Handler parameter names",
"items": { "type": "string" }
},
"body": {
"type": "array",
"description": "Handler statements",
"items": {
"$ref": "#/definitions/statement"
}
}
}
},
"computedProperty": {
"type": "object",
"required": ["deps", "compute"],
"properties": {
"deps": {
"type": "array",
"description": "Dependencies to watch",
"items": { "type": "string" }
},
"compute": {
"description": "Computation expression or call"
}
}
},
"renderDefinition": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"description": "Render type",
"enum": ["component", "element"]
},
"template": {
"$ref": "#/definitions/templateNode"
}
}
},
"templateNode": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"description": "HTML element type or 'component'"
},
"className": {
"type": "string",
"description": "CSS class name"
},
"style": {
"type": "object",
"description": "Inline styles"
},
"children": {
"oneOf": [
{ "type": "string" },
{ "type": "array", "items": { "$ref": "#/definitions/templateNodeOrString" } }
]
},
"name": {
"type": "string",
"description": "Component name (when type is 'component')"
},
"props": {
"type": "object",
"description": "Component props"
},
"inputType": {
"type": "string",
"description": "Input type (for input elements)"
},
"value": {
"description": "Input value"
},
"onChange": {
"description": "Change handler reference"
},
"onClick": {
"description": "Click handler reference"
},
"if": {
"description": "Conditional rendering expression"
},
"each": {
"type": "string",
"description": "Array reference for iteration"
},
"as": {
"type": "string",
"description": "Item variable name for iteration"
}
}
},
"templateNodeOrString": {
"oneOf": [
{ "type": "string" },
{ "$ref": "#/definitions/templateNode" }
]
},
"statement": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"description": "Statement type",
"enum": [
"setState",
"call_expression",
"if",
"return",
"const_declaration",
"let_declaration",
"assignment",
"comment"
]
},
"updates": {
"type": "object",
"description": "State updates (for setState)"
},
"callee": {
"type": "string",
"description": "Function to call"
},
"args": {
"type": "array",
"description": "Function arguments"
}
}
},
"docstring": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "Brief summary"
},
"description": {
"type": "string",
"description": "Detailed description"
},
"props": {
"type": "array",
"description": "Prop documentation",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"description": { "type": "string" },
"optional": { "type": "boolean" },
"default": {}
}
}
},
"examples": {
"type": "array",
"description": "Usage examples",
"items": {
"type": "object",
"properties": {
"title": { "type": "string" },
"code": { "type": "string" }
}
}
},
"since": {
"type": "string",
"description": "Version when added"
},
"tags": {
"type": "array",
"description": "Documentation tags",
"items": { "type": "string" }
},
"see": {
"type": "array",
"description": "Related references",
"items": { "type": "string" }
}
}
}
}
}