oex2003/evolution-api
0
1import { JSONSchema7 } from 'json-schema';2import { v4 } from 'uuid';3 4const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {5 const properties = {};6 propertyNames.forEach(7 (property) =>8 (properties[property] = {9 minLength: 1,10 description: `The "${property}" cannot be empty`,11 }),12 );13 return {14 if: {15 propertyNames: {16 enum: [...propertyNames],17 },18 },19 then: { properties },20 };21};22 23export const proxySchema: JSONSchema7 = {24 $id: v4(),25 type: 'object',26 properties: {27 enabled: { type: 'boolean', enum: [true, false] },28 host: { type: 'string' },29 port: { type: 'string' },30 protocol: { type: 'string' },31 username: { type: 'string' },32 password: { type: 'string' },33 },34 required: ['enabled', 'host', 'port', 'protocol'],35 ...isNotEmpty('enabled', 'host', 'port', 'protocol'),36};37 