import {JSONSchema7} from 'json-schema'; /** * This schema defines a card fragment (to be used to generate a card definition and UI templates) */ export default { $id: 'https://schemas.coastapp.com/card/v1/fragment.json', $schema: 'http://json-schema.org/draft-07/schema', title: 'Card Fragment', type: 'object', additionalProperties: false, properties: { version: {type: 'string', enum: ['v1']}, compose: { type: 'object', title: 'Fragment Compose', additionalProperties: false, properties: { fieldName: {type: 'string', default: 'name'}, blockType: {type: 'string'}, position: {type: 'string', enum: ['prepend', 'append'], default: 'append'}, }, }, items: { type: 'array', items: { title: 'Fragment Item', anyOf: [ { title: 'Fragment Field', type: 'object', additionalProperties: false, properties: { name: {type: 'string'}, type: {type: 'string', enum: ['field']}, fieldType: { $ref: 'https://schemas.coastapp.com/card/v1/blocks.json#/definitions/fieldType', }, label: {type: 'string'}, icon: {$ref: 'https://schemas.coastapp.com/card/v1/icon.json'}, required: {type: 'boolean', default: false}, placeholder: {type: 'string'}, settings: { title: 'Fragment Field Settings', type: 'object', additionalProperties: false, properties: { validation: { type: 'object', additionalProperties: false, properties: { max: {type: 'number', default: 1}, }, }, readOnly: {type: 'boolean', default: true}, options: { type: 'array', items: { $ref: 'https://schemas.coastapp.com/card/v1/tagOption.json', }, }, }, }, }, required: ['type', 'name', 'fieldType', 'label'], }, ], }, minItems: 1, }, }, required: ['version', 'items'], } as JSONSchema7;