Team Ai
Apppublic

oex2003/evolution-api

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
flowise.schema.ts112 linesDownload Raw Back to validate
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 flowiseSchema: JSONSchema7 = {24  $id: v4(),25  type: 'object',26  properties: {27    enabled: { type: 'boolean' },28    description: { type: 'string' },29    apiUrl: { type: 'string' },30    apiKey: { type: 'string' },31    triggerType: { type: 'string', enum: ['all', 'keyword', 'none', 'advanced'] },32    triggerOperator: { type: 'string', enum: ['equals', 'contains', 'startsWith', 'endsWith', 'regex'] },33    triggerValue: { type: 'string' },34    expire: { type: 'integer' },35    keywordFinish: { type: 'string' },36    delayMessage: { type: 'integer' },37    unknownMessage: { type: 'string' },38    listeningFromMe: { type: 'boolean' },39    stopBotFromMe: { type: 'boolean' },40    keepOpen: { type: 'boolean' },41    debounceTime: { type: 'integer' },42    ignoreJids: { type: 'array', items: { type: 'string' } },43    splitMessages: { type: 'boolean' },44    timePerChar: { type: 'integer' },45  },46  required: ['enabled', 'apiUrl', 'triggerType'],47  ...isNotEmpty('enabled', 'apiUrl', 'triggerType'),48};49 50export const flowiseStatusSchema: JSONSchema7 = {51  $id: v4(),52  type: 'object',53  properties: {54    remoteJid: { type: 'string' },55    status: { type: 'string', enum: ['opened', 'closed', 'paused', 'delete'] },56  },57  required: ['remoteJid', 'status'],58  ...isNotEmpty('remoteJid', 'status'),59};60 61export const flowiseSettingSchema: JSONSchema7 = {62  $id: v4(),63  type: 'object',64  properties: {65    expire: { type: 'integer' },66    keywordFinish: { type: 'string' },67    delayMessage: { type: 'integer' },68    unknownMessage: { type: 'string' },69    listeningFromMe: { type: 'boolean' },70    stopBotFromMe: { type: 'boolean' },71    keepOpen: { type: 'boolean' },72    debounceTime: { type: 'integer' },73    ignoreJids: { type: 'array', items: { type: 'string' } },74    flowiseIdFallback: { type: 'string' },75    splitMessages: { type: 'boolean' },76    timePerChar: { type: 'integer' },77  },78  required: [79    'expire',80    'keywordFinish',81    'delayMessage',82    'unknownMessage',83    'listeningFromMe',84    'stopBotFromMe',85    'keepOpen',86    'debounceTime',87    'ignoreJids',88  ],89  ...isNotEmpty(90    'expire',91    'keywordFinish',92    'delayMessage',93    'unknownMessage',94    'listeningFromMe',95    'stopBotFromMe',96    'keepOpen',97    'debounceTime',98    'ignoreJids',99  ),100};101 102export const flowiseIgnoreJidSchema: JSONSchema7 = {103  $id: v4(),104  type: 'object',105  properties: {106    remoteJid: { type: 'string' },107    action: { type: 'string', enum: ['add', 'remove'] },108  },109  required: ['remoteJid', 'action'],110  ...isNotEmpty('remoteJid', 'action'),111};112