import {JSONSchema7} from 'json-schema'; export default { $id: 'https://schemas.coastapp.com/card/v1/blocks.json', $schema: 'http://json-schema.org/draft-07/schema', title: 'Card Blocks', type: 'array', items: {$ref: '#/definitions/cardBlock'}, minItems: 1, definitions: { cardBlock: { title: 'Card Block', anyOf: [ {$ref: '#/definitions/sequenceNumber'}, {$ref: '#/definitions/field'}, {$ref: '#/definitions/tags'}, {$ref: '#/definitions/cards'}, {$ref: '#/definitions/inCards'}, {$ref: '#/definitions/image'}, {$ref: '#/definitions/input'}, {$ref: '#/definitions/inputAssignee'}, {$ref: '#/definitions/inputDate'}, {$ref: '#/definitions/inputNumber'}, {$ref: '#/definitions/inputTags'}, {$ref: '#/definitions/inputCards'}, {$ref: '#/definitions/inputSubforms'}, {$ref: '#/definitions/inputTodo'}, {$ref: '#/definitions/inputRecurrence'}, {$ref: '#/definitions/inputReminder'}, {$ref: '#/definitions/inputDateRange'}, {$ref: '#/definitions/inputFile'}, {$ref: '#/definitions/seenBy'}, {$ref: '#/definitions/chatThread'}, {$ref: '#/definitions/chatThreadInput'}, {$ref: '#/definitions/dateRange'}, {$ref: '#/definitions/button'}, {$ref: '#/definitions/noCode'}, ], }, sticky: { type: 'string', title: 'Sticky Position', enum: ['top', 'bottom'], }, dateMode: { type: 'string', title: 'Date Mode', enum: ['date', 'time', 'datetime'], default: 'date', }, dateTimeOffset: { type: 'object', title: 'DateTime Offset', additionalProperties: false, properties: { count: {type: 'number', default: 1}, unit: {enum: ['week', 'day', 'hour', 'minute', 'second'], default: 'day'}, }, }, numberMode: { type: 'string', title: 'Number Mode', enum: ['float', 'percent', 'currency'], default: 'float', }, fieldType: { title: 'Field Type', type: 'string', enum: [ 'text', 'textarea', 'noCode', 'date', 'time', 'geolocation', 'address', 'relativeTime', 'datetime', 'float', 'percent', 'currency', 'image', 'file', 'toggle', 'assignee', 'recurrence', 'reminder', 'todo', 'tags', 'channel', 'cards', 'subforms', 'questionTextArea', 'questionCheckbox', 'questionSingleSelect', 'signature', ], default: 'text', }, common: { title: 'Common Properties', type: 'object', additionalProperties: false, properties: { icon: { $ref: 'https://schemas.coastapp.com/card/v1/icon.json', }, textStyle: { $ref: 'https://schemas.coastapp.com/card/v1/textStyle.json', }, theme: { $ref: 'https://schemas.coastapp.com/card/v1/theme.json', }, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, width: { description: 'Width of block when presented as a tabular row. Can be a number in px or string as percentage. Defaults to percentage based on total number of blocks.', anyOf: [{type: 'string'}, {type: 'number'}], }, tableHeader: {type: 'string'}, }, }, sequenceNumber: { title: 'Sequence Number Block', additionalProperties: false, properties: { type: {type: 'string', enum: ['sequenceNumber']}, }, required: ['type'], $injectLocalDef: 'common', }, field: { title: 'Field Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['field']}, label: {type: 'string'}, placeholder: {type: 'string'}, fieldType: {$ref: '#/definitions/fieldType'}, name: {type: 'string'}, }, required: ['type', 'name'], $injectLocalDef: 'common', }, tags: { title: 'Tags Block', description: 'Renders one or more tags in a horizontal layout', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['tags']}, names: {type: 'array', items: {type: 'string'}}, label: {type: 'string'}, placeholder: {type: 'string'}, }, required: ['type', 'names'], $injectLocalDef: 'common', }, cards: { title: 'Cards Block', description: 'Renders one or more related cards in a horizontal layout', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['cards']}, names: {type: 'array', items: {type: 'string'}}, placeholder: {type: 'string'}, mode: {type: 'string', enum: ['quantity']}, label: {type: 'string'}, }, required: ['type', 'names'], $injectLocalDef: 'common', }, inCards: { title: 'In-Cards Block', description: 'Renders one or more in-card counts in a vertical roll-up list', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['in-cards']}, placeholder: {type: 'string'}, mode: {type: 'string', enum: ['count']}, label: {type: 'string'}, }, required: ['type', 'mode'], $injectLocalDef: 'common', }, image: { title: 'Image Block', description: 'Renders a full-width image', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['image']}, name: {type: 'string'}, size: { title: 'Image Size', type: 'string', enum: ['full', 'thumb'], default: 'full', }, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type', 'name'], }, input: { title: 'Input Block', description: 'Form input field', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['input']}, name: {type: 'string'}, fieldType: {$ref: '#/definitions/fieldType'}, label: {type: 'string'}, placeholder: {type: 'string'}, required: {type: 'boolean', default: false}, autoFocus: {type: 'boolean', default: false}, validation: { type: 'object', title: 'Input Validation', additionalProperties: false, properties: { message: {type: 'string'}, regex: {type: 'string'}, min: {type: 'number'}, max: {type: 'number'}, }, }, defaultValue: { oneOf: [ {type: 'string'}, {type: 'number'}, {type: 'boolean'}, {type: 'array', items: {anyOf: [{type: 'string'}, {type: 'number'}]}}, ], }, }, required: ['type', 'name'], $injectLocalDef: 'common', }, inputTags: { title: 'Tags Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['tags']}, readOnly: {type: 'boolean', default: true}, appearance: {type: 'string', enum: ['button']}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputCards: { title: 'Cards Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['cards']}, readOnly: {type: 'boolean', default: true}, mode: {type: 'string', enum: ['quantity']}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputSubforms: { title: 'Subforms Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['subforms']}, readOnly: {type: 'boolean', default: true}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputTodo: { title: 'Todo Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['todo']}, mode: {type: 'string', enum: ['creation', 'completion'], defaultValue: 'creation'}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputRecurrence: { title: 'Recurrence Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['recurrence']}, name: {type: 'string', enum: ['recurrence']}, dateFieldName: {type: 'string'}, }, required: ['fieldType', 'name', 'dateFieldName'], $injectLocalDef: 'input', }, inputReminder: { title: 'Reminder Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['reminder']}, name: {type: 'string', enum: ['reminder']}, mode: {$ref: '#/definitions/dateMode'}, delta: {$ref: '#/definitions/dateTimeOffset'}, deltaOptions: { type: 'array', items: {$ref: '#/definitions/dateTimeOffset'}, }, dateFieldName: {type: 'string', enum: ['startDate', 'endDate']}, recipientFieldName: {type: 'string'}, shouldSendSelector: {$ref: 'https://schemas.coastapp.com/card/v1/selector.json'}, }, required: ['fieldType', 'name', 'dateFieldName', 'recipientFieldName'], $injectLocalDef: 'input', }, inputAssignee: { title: 'Assignee Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['assignee']}, batchTagFieldName: {type: 'string'}, batchLabel: {type: 'string'}, allowBatch: {type: 'boolean', default: false}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputDate: { title: 'Date Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {$ref: '#/definitions/dateMode'}, defaultTime: {type: 'string'}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputNumber: { title: 'Number Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {$ref: '#/definitions/numberMode'}, }, required: ['fieldType'], $injectLocalDef: 'input', }, inputDateRange: { title: 'Date Range Input Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['date-range-input']}, mode: {$ref: '#/definitions/dateMode'}, delta: {$ref: '#/definitions/dateTimeOffset'}, defaultTime: {type: 'string'}, startDateFieldName: {type: 'string', default: 'startDate'}, startDateFieldLabel: {type: 'string'}, endDateFieldName: {type: 'string', default: 'endDate'}, endDateFieldLabel: {type: 'string'}, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type'], }, inputFile: { title: 'File Input Block', type: 'object', additionalProperties: false, properties: { fieldType: {type: 'string', enum: ['file']}, acceptedContentTypes: { type: 'array', items: {type: 'string'}, }, }, required: ['fieldType'], $injectLocalDef: 'input', }, seenBy: { title: 'Seen By Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['seen-by']}, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type'], }, chatThread: { title: 'Chat Thread Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['chat-thread']}, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type'], }, chatThreadInput: { title: 'Chat Thread Input Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['chat-thread-input']}, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type'], }, noCode: { title: 'NoCodeComponentBlock', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['no-code']}, componentId: {type: 'string'}, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, }, required: ['type', 'componentId'], }, dateRange: { title: 'Date Range Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['date-range']}, mode: {$ref: '#/definitions/dateMode'}, label: {type: 'string'}, startDateFieldName: {type: 'string', default: 'startDate'}, endDateFieldName: {type: 'string', default: 'endDate'}, icon: { $ref: 'https://schemas.coastapp.com/card/v1/icon.json', }, textStyle: { $ref: 'https://schemas.coastapp.com/card/v1/textStyle.json', }, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type'], }, button: { title: 'Button Block', type: 'object', additionalProperties: false, properties: { type: {type: 'string', enum: ['button']}, buttons: { title: 'Button Row', type: 'array', items: { title: 'Button', type: 'object', description: 'label or icon is required', additionalProperties: false, properties: { label: {type: 'string'}, icon: { $ref: 'https://schemas.coastapp.com/card/v1/icon.json', }, style: { title: 'ButtonStyle', type: 'string', enum: ['primary', 'secondary'], default: 'primary', }, size: { title: 'ButtonSize', type: 'string', enum: ['normal', 'small'], default: 'normal', }, actions: { $ref: 'https://schemas.coastapp.com/card/v1/actions.json', }, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, }, required: ['actions'], }, minItems: 1, }, selector: { $ref: 'https://schemas.coastapp.com/card/v1/selector.json', }, sticky: {$ref: '#/definitions/sticky'}, }, required: ['type', 'buttons'], }, }, } as JSONSchema7;