Skip to content
Snippets Groups Projects
Commit 91e0fd73 authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-2958-AddJSONSchema' into 'master'

Добавлена спецификация JSON Schema для схемы коллекций

See merge request perxis/perxis-go!430
parents 72602c62 7cf1e930
No related branches found
No related tags found
No related merge requests found
{
"$schema": "https://json-schema.org/draft-07/schema",
"title": "Perxis Collection Schema",
"$defs": {
"view": {
"type": "object",
"properties": {
"widget": {
"description": "Виджет для отображения поля в списке",
"type": "string"
},
"options": {
"description": "Опции виджета, на усмотрения виджета",
"type": "object"
}
}
},
"translation": {
"type": "object",
"properties": {
"locale": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"locale"
]
},
"include": {
"type": "object",
"properties": {
"ref": {
"description": "Идентификатор коллекции подключаемой схемы",
"type": "string"
},
"optional": {
"description": "Параметр определяющий обязательность подключение схемы",
"type": "boolean"
}
}
},
"field": {
"type": "object",
"properties": {
"type": {
"description": "Тип поля. Доступные значения: bool, array, file, location, number, object, reference, string, time, timestamp",
"type": "string",
"enum": [
"bool",
"array",
"file",
"location",
"number",
"object",
"reference",
"string",
"time",
"timestamp"
]
},
"title": {
"description": "Заголовок поля",
"type": "string"
},
"description": {
"description": "Описание поля",
"type": "string"
},
"translations": {
"description": "Локализация заголовка и описания поля",
"type": "array",
"items": {
"$ref": "#/$defs/translation"
}
},
"options": {
"description": "Может содержать правила валидации или модификации данных для поля",
"type": "object",
"properties": {
"readonly": {
"description": "Только для чтения",
"type": "boolean"
},
"required": {
"description": "Обязательно для заполнения. Не учитывается для переводов",
"type": "boolean"
},
"value": {
"description": "Формула значения (опционально). В случае если формула указана, то при сохранении значение из данных будет заменено на результат вычисления формулы",
"type": "string"
}
}
},
"ui": {
"description": "Описывает отображение объекта в интерфейсе",
"type": "object",
"properties": {
"widget": {
"description": "Виджет для отображения поля",
"type": "string"
},
"placeholder": {
"description": "Местозаполнитель для полей",
"type": "string"
},
"options": {
"description": "Опции виджета, на усмотрения виджета",
"type": "object",
"properties": {
"title": {
"description": "Поле используемое в качестве заголовка при отображении",
"type": "string"
},
"key": {
"description": "Поле используемое в качестве ключевого значения",
"type": "string"
},
"subtitle": {
"description": "Поле используемое в качестве подзаголовков при отображении",
"type": "string"
},
"description": {
"description": "Поле используемое в качестве описания при отображении",
"type": "string"
},
"icon": {
"description": "Поле используемое в качестве имени иконки (из библиотеки приложения) при отображении",
"type": "string"
},
"images": {
"description": "Поля используемые в качестве изображений. Поддерживаются поля типа file и reference. В случае file файл должен должен быть изображением. В случае reference, в схеме коллекции на элемент которой ссылается reference должно быть указано поле ui.options.images которое в свою очередь так же может указывать на поля типа file и reference и.т.д",
"type": "array",
"items": {
"type": "string"
}
},
"refs": {
"description": "Определяет какие поля (Reference/[]Reference) используются для отображения связанных записей, а так же их порядок",
"type": "array",
"items": {
"type": "object",
"properties": {
"field": {
"description": "Имя поля для отображения",
"type": "string"
},
"expand": {
"description": "Раздел поля раскрыт (по умолчанию отображается свернутым)",
"type": "boolean"
}
}
}
},
"fields": {
"description": "Порядок следования полей по умолчанию. Параметр указывает только порядок следования",
"type": "array",
"items": {
"type": "string"
}
},
"color": {
"description": "Поле используемое в качестве цвета фона при отображении записи в таблице и в виджете Block/BlockList. В качестве значения поля используемого для указания цвета может быть: Название цвета antd: magenta, red, volcano, orange, gold, lime, green, cyan, blue, geekblue, purple. Название статуса antd: success, processing, error, warning, default. Любое значение цвета, которое поддерживается библиотекой TinyColor: hex: #ff0000 hex8: #ff0000ff rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) hsv: hsv(0, 100%, 100%)",
"type": "string"
},
"collection_icon": {
"description": "Название иконки для отображения коллекции в меню или в списке коллекций",
"type": "string"
},
"fieldProps": {
"description": "Параметры отображения поля в grid сетке"
}
}
},
"read_view": {
"description": "Настройки для отображения экрана в режиме просмотра элемента",
"$ref": "#/$defs/view"
},
"edit_view": {
"description": "Настройки для отображения экрана в режиме редактирования элемента",
"$ref": "#/$defs/view"
},
"list_view": {
"description": "Настройки для отображения экрана в режиме списке элементов",
"allOf": [
{
"$ref": "#/$defs/view"
},
{
"properties": {
"options": {
"properties": {
"fields": {
"description": "Список отображаемых полей и порядок их отображения в списке по умолчанию (пользователь может изменить). Если не задан, то используется основной параметр fields",
"type": "array",
"items": {
"type": "string"
}
},
"sort": {
"description": "Настройка сортировки списка по умолчанию",
"type": "array",
"items": {
"type": "string"
}
},
"page_size": {
"description": "Настройка размера страниц по умолчанию",
"type": "integer"
}
}
}
}
}
]
}
},
"allOf": [
{
"if": {
"properties": {
"widget": {
"const": "LogViewer"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"maxHeight": {
"description": "Высота поля, число отображаемых строк",
"type": "integer"
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "RTE"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"mediaCollections": {
"description": "Список коллекций доступных при вставке изображения",
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "CodeEditor"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"height": {
"description": "Высота редактора, число отображаемых строк",
"type": "integer"
},
"defaultLanguage": {
"description": "Язык по-умолчанию. Доступны для выбора - html, json, markdown, plaintext, yaml. Если не указан, будет выбран plaintext",
"type": "string",
"enum": [
"html",
"json",
"markdown",
"plaintext",
"yaml"
]
},
"allowChangeLanguage": {
"description": "Активация возможности переключения языка в самом виджете во время редактирования кода",
"type": "boolean"
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "DateTimePicker"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"properties": {
"format": {
"description": "Используется метод format библиотеки dayjs https://day.js.org/docs/en/display/format",
"type": "string"
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "TimestampPicker"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"properties": {
"format": {
"description": "Используется метод format библиотеки dayjs https://day.js.org/docs/en/display/format",
"type": "string"
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "Select"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"properties": {
"enum": {
"description": "",
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": [
"string",
"integer"
]
},
"color": {
"description": "Цвет тега как в документации https://ant.design/components/tag/",
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "SelectList"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"properties": {
"enum": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": [
"string",
"integer"
]
},
"color": {
"description": "Цвет тега как в документации https://ant.design/components/tag/",
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "Radio"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"option_type": {
"description": "Тип переключателей",
"type": "string",
"enum": [
"button",
"default"
]
}
},
"allOf": [
{
"if": {
"properties": {
"option_type": {
"const": "default"
}
}
},
"then": {
"properties": {
"direction": {
"description": "Вариант отображения переключателей",
"type": "string",
"enum": [
"horizontal",
"vertical"
]
}
}
}
}
]
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "SpaceSelect"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"allowSpacesFromAllOrgs": {
"description": "Выбор пространств из всех доступных организаций",
"type": "boolean"
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "Group"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"group": {
"description": "Разместить поля по grid сетке",
"type": "boolean"
},
"groupProps": {
"description": "Параметры grid сетки, компонент Row",
"type": "object"
}
}
}
}
}
},
{
"if": {
"anyOf": [
{
"properties": {
"widget": {
"const": "Lookup"
}
}
},
{
"properties": {
"widget": {
"const": "LookupList"
}
}
}
]
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"itemsFilter": {
"description": "Дополнительная фильтрация элементов с возможностью подстановки значений из текущего контекста",
"type": "string"
},
"collectionsFilter": {
"description": "Дополнительная фильтрация коллекций с возможностью подстановки значений из текущего контекста. Указывается массив значений для фильтрации по id",
"type": "array"
},
"allowedCollections": {
"type": "array",
"items": {
"type": "object",
"properties": {
"valueField": {
"description": "Имя поля значения",
"type": "string"
},
"collection": {
"description": "ID коллекции",
"type": "string"
},
"titleField": {
"description": "Имя поля заголовка",
"type": "string"
},
"descriptionField": {
"description": "Имя поля описания",
"type": "string"
},
"imageField": {
"description": "Имя поля изображения",
"type": "string"
}
},
"required": [
"valueField",
"collection"
]
}
}
}
}
}
}
},
{
"if": {
"anyOf": [
{
"properties": {
"widget": {
"const": "Block"
}
}
},
{
"properties": {
"widget": {
"const": "BlockList"
}
}
}
]
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"create": {
"description": "Настройки интерфейса создания новых элементов в виджете",
"type": "object",
"properties": {
"disable": {
"description": "Создание элементов отключено (только выбор существующих)",
"type": "boolean"
},
"classes": {
"description": "Классы действий применимые для создания",
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
},
{
"if": {
"anyOf": [
{
"properties": {
"widget": {
"const": "Reference"
}
}
},
{
"properties": {
"widget": {
"const": "ReferenceList"
}
}
}
]
},
"then": {
"properties": {
"list_view": {
"properties": {
"options": {
"properties": {
"allow_preview": {
"description": "Отображение предпросмотра ссылки как Блока во всплывающем окошке при наведении на тег ссылки в таблице элементов",
"type": "boolean"
}
}
}
}
},
"options": {
"type": "object",
"properties": {
"itemsFilter": {
"description": "Дополнительная фильтрация элементов с возможностью подстановки значений из текущего контекста",
"type": "string"
},
"collectionsFilter": {
"description": "Дополнительная фильтрация коллекций с возможностью подстановки значений из текущего контекста",
"type": "array"
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "Media"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"type": "object",
"properties": {
"size": {
"description": "Размер изображения",
"type": "string",
"enum": [
"small",
"middle",
"large"
]
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "MediaList"
}
}
},
"then": {
"properties": {
"list_view": {
"type": "object",
"properties": {
"options": {
"type": "object",
"properties": {
"images_count": {
"description": "Количество отображаемых изображений",
"type": "integer"
},
"size": {
"description": "Размер изображения",
"type": "string",
"enum": [
"small",
"middle",
"large"
]
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"widget": {
"const": "Collection"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"includeHidden": {
"description": "Показывать скрытые коллекции в списке возможных вариантов",
"type": "boolean"
}
}
}
}
}
}
]
},
"includes": {
"description": "Включает в поле другие схемы",
"type": "array",
"items": {
"$ref": "#/$defs/include"
}
},
"single_locale": {
"description": "Флаг, показывающий, что данные в поле не могут быть локализованы",
"type": "boolean"
},
"indexed": {
"description": "Флаг, определяющий индексацию данных в этом поле для ускорения фильтрации",
"type": "boolean"
},
"unique": {
"description": "Флаг, указывающий, что поле может иметь только уникальное значение среди всех записей в коллекции. При попытке добавить дублирующее значение будет возвращена ошибка и отказ сохранить или обновить запись. Для переводов записи на другие языки проверка уникальности осуществляется отдельно для каждого языка",
"type": "boolean"
},
"text_search": {
"description": "Флаг, указывающий, что по данному полю должен осуществляться полнотекстовый поиск. Полнотекстовый поиск выполняется по всем полям с данным флагом и их переводам",
"type": "boolean"
},
"condition": {
"description": "Формула, результат вычисление определяет видимость поля и присутствия поля данных. Формула должна возвращать булево значение. Если данный параметр не указан, то поле считается видимым",
"type": "string"
},
"additional_values": {
"description": "Позволяет указывать дополнительные пользовательские значения вне ограничений наложенных правилами Enum, Lookup и другими правилами ограничивающими значения поля",
"type": "boolean"
}
},
"required": [
"type"
],
"allOf": [
{
"if": {
"properties": {
"type": {
"const": "bool"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"enum": {
"description": "Выбор из заданных значений",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "boolean"
}
}
}
},
"default": {
"type": "boolean"
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"Checkbox",
"Switch"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "array"
}
}
},
"then": {
"properties": {
"params": {
"type": "object",
"properties": {
"item": {
"description": "Описание типа поля элементов",
"$ref": "#/$defs/field"
}
},
"required": [
"item"
]
},
"options": {
"type": "object",
"properties": {
"maxItems": {
"description": "Максимальное количество элементов в поле",
"type": "integer"
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"SelectList",
"SpaceSelect",
"LocaleSelect",
"List",
"Tags",
"LookupList",
"BlockList",
"ReferenceList",
"MediaList",
"Collection"
]
}
}
}
},
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"type": {
"const": "file"
}
}
},
"then": {
"properties": {
"options": {
"type": "object"
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"File"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "location"
}
}
},
"then": {
"properties": {
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup"
]
},
"options": {
"type": "object"
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "number"
}
}
},
"then": {
"properties": {
"params": {
"type": "object",
"properties": {
"format": {
"description": "Конкретный числовой тип данных",
"type": "string",
"enum": [
"int",
"float"
]
}
},
"required": [
"format"
]
},
"options": {
"type": "object",
"properties": {
"max": {
"description": "Максимальное значение",
"type": "integer"
},
"min": {
"description": "Минимальное значение",
"type": "integer"
},
"multipleOf": {
"description": "Кратность",
"type": "integer"
},
"enum": {
"description": "Выбор из заданных значений",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "integer"
}
}
}
},
"default": {
"description": "Значение по умолчанию",
"type": "integer"
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"NumberInput",
"Select",
"SelectList",
"Radio"
]
}
}
}
},
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"type": {
"const": "object"
}
}
},
"then": {
"properties": {
"options": {
"type": "object",
"properties": {
"default": {
"description": "Значение по умолчанию",
"type": "object"
}
}
},
"params": {
"type": "object",
"properties": {
"inline": {
"description": "флаг, указывающий на то что объект является “встроенным” в родительский объект",
"type": "boolean"
},
"fields": {
"description": "Список полей объекта с описанием",
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"$ref": "#/$defs/field"
}
}
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"Group",
"Tabs",
"Accordion"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "reference"
}
}
},
"then": {
"properties": {
"params": {
"type": "object",
"properties": {
"allowedCollections": {
"description": "Список коллекций, ссылки на элементы которых могут быть использованы в поле. Поддерживаются glob выражения. Необязательно для заполнения - в случае, если поле не заполнено, разрешен поиск по всем коллекциям",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
"options": {
"type": "object",
"properties": {
"minItems": {
"description": "Минимальное количество связей в поле",
"type": "integer"
},
"maxItems": {
"description": "Максимальное количество связей в поле",
"type": "integer"
},
"enum": {
"description": "Выбор из заданных значений",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "object"
}
}
}
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"Block",
"Reference",
"Media"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "string"
}
}
},
"then": {
"properties": {
"options": {
"properties": {
"maxLength": {
"description": "Максимальное количество символов в тексте",
"type": "integer"
},
"minLength": {
"description": "Минимальное количество символов в тексте",
"type": "integer"
},
"enum": {
"description": "Выбор из заданных значений",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"default": {
"description": "Значение по умолчанию",
"type": "string"
},
"trimSpace": {
"description": "Убрать лишние пробелы в начале и конце строки",
"type": "boolean"
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"StringInput",
"Textarea",
"LogViewer",
"RTE",
"CodeEditor",
"SchemaEditor",
"Timezone",
"Select",
"Radio",
"Password",
"Icon",
"SpaceSelect",
"LocaleSelect",
"Collection"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "time"
}
}
},
"then": {
"properties": {
"params": {
"type": "object",
"properties": {
"layout": {
"description": "Формат времени. Необязательно к заполнению. По умолчанию предполагается формат времени, описанный RFC3339. Можно указать другой формат. Для описания необходимо использовать конкретную дату Mon Jan 2 15:04:05 MST 2006 (Unix 1136239445)",
"type": "string"
}
}
},
"options": {
"properties": {
"default": {
"description": "Значение по умолчанию",
"type": "string"
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"DateTimePicker"
]
}
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "timestamp"
}
}
},
"then": {
"properties": {
"options": {
"properties": {
"default": {
"description": "Значение по умолчанию",
"type": "integer"
}
}
}
},
"ui": {
"properties": {
"widget": {
"enum": [
"Lookup",
"TimestampPicker"
]
}
}
}
}
}
]
}
},
"anyOf": [
{
"$ref": "#/$defs/field",
"properties": {
"metadata": {
"type": [
"object",
"null"
],
"properties": {
"collection_id": {
"type": "string"
},
"collection_name": {
"type": "string"
},
"collection_hidden": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"schema": {
"type": "object",
"allOf": [
{
"$ref": "#/$defs/field"
}
],
"properties": {
"loaded": {
"type": "boolean"
},
"metadata": {
"type": [
"object",
"null"
]
}
}
},
"no_data": {
"description": "Коллекция не содержит данных",
"type": "boolean"
},
"single": {
"description": "Коллекция может содержать ровно одну запись",
"type": "boolean"
},
"hidden": {
"description": "Скрыть коллекцию в интерфейсе от пользователя",
"type": "boolean"
},
"no_archive": {
"description": "Коллекция без архива",
"type": "boolean"
},
"no_publish": {
"description": "Коллекция без публикации",
"type": "boolean"
},
"no_revisions": {
"description": "Коллекция без истории изменений (ревизии)",
"type": "boolean"
},
"max_revisions": {
"description": "Старые ревизии сверх указанного количества будут автоматически удаляться. 0, пусто - без ограничений",
"type": "integer"
},
"revision_ttl": {
"description": "Ревизии старше указанного времени хранения будут автоматически удалятся. 0, пусто - без ограничений",
"type": "integer"
}
},
"required": [
"id",
"name",
"schema"
],
"additionalProperties": false
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment