import {JSONSchema7} from 'json-schema'; export default { $id: 'https://schemas.coastapp.com/card/v1/selector.json', $schema: 'http://json-schema.org/draft-07/schema', title: 'Selector', type: 'array', items: { anyOf: [{$ref: '#/definitions/fieldExpression'}, {$ref: '#/definitions/logicalExpression'}], }, minItems: 1, definitions: { fieldExpression: { type: 'object', title: 'Field Expression', additionalProperties: false, properties: { field: {type: 'string'}, op: { type: 'string', title: 'Field Expression Op', enum: ['=', '<', '>', '<=', '>=', '!=', 'in', '!in', 'includes', '!includes'], }, value: { title: 'Field Expression Value', anyOf: [ {type: 'string'}, {type: 'number'}, {type: 'boolean'}, {type: 'array', items: {anyOf: [{type: 'string'}, {type: 'number'}]}}, {$ref: 'https://schemas.coastapp.com/card/v1/token.json'}, ], }, }, required: ['field', 'op', 'value'], }, logicalExpression: { type: 'object', title: 'Logical Expression', additionalProperties: false, properties: { op: {type: 'string', title: 'Logical Expression Op', enum: ['and', 'or'], default: 'and'}, expressions: { title: 'Logical Expressions', type: 'array', items: { anyOf: [ {$ref: '#/definitions/fieldExpression'}, {$ref: '#/definitions/logicalExpression'}, ], }, }, }, required: ['expressions'], }, }, } as JSONSchema7;