<commit_before>import * as Ajv from 'ajv'
import { LOG_LEVEL } from '../../ds-types/src/index'

const LogLevelValidation = {
  type: ['string', 'integer'],
  enum: [
    'DEBUG', LOG_LEVEL.DEBUG,
    'INFO', LOG_LEVEL.INFO,
    'WARN', LOG_LEVEL.WARN,
    'ERROR', LOG_LEVEL.ERROR,
    'OFF', LOG_LEVEL.OFF
  ]
}

function getPluginOptions (name: string, types: string[], properties: any) {
  return {
    [name]: {
      type: 'object',
      properties: {
        type: { type: 'string', enum: types },
        name: { type: 'string', minLength: 1 },
        path: { type: 'string', minLength: 1 },
        options: {
          type: 'object',
          properties
        }
      },
      oneRequired: ['type', 'name', 'path']
    }
  }
}

const generalOptions = {
  libDir: { type: ['string', 'null'] },
  serverName: { type: 'string', minLength: 1 },
  externalUrl: { type: ['null', 'string'] },
  showLogo: { type: 'boolean' },
  exitOnFatalError: { type: 'boolean' },
  dependencyInitializationTimeout: { type: 'number', minimum: 1000 },
  logLevel: LogLevelValidation
}

const enabledFeatures = {
  enabledFeatures: {
    record: { type: 'boolean' },
    event: { type: 'boolean' },
    rpc: { type: 'boolean' },
    presence: { type: 'boolean' },
    monitoring: { type: 'boolean' },
  }
}

const rpcOptions = {
  rpc: {
    type: ['object'],
    ackTimeout: { type: 'integer', minimum: 1 },
    responseTimeout: { type: 'integer', minimum: 1 }
  }
}

const recordOptions = {
  record: {
    type: ['object'],
    cacheRetrievalTimeout: { type: 'integer', minimum: 50 },
    storageRetrievalTimeout: { type: 'integer', minimum: 50 },
    storageExclusionPrefixes: { type: ['null', 'array'], items: { type: 'string' } },
    storageHotPathPrefixes: { type: ['null', 'array'], items: { type: 'string' } }
  }
}

const listenOptions = {
  listen: {
    type: ['object'],
    shuffleProviders: { type: 'boolean' },
    responseTimeout: { type: 'integer', minimum: 50 },
    rematchInterval: { type: 'integer', minimum: 50 },
    matchCooldown: { type: 'integer', minimum: 50 },
  }
}

const httpServer = getPluginOptions(
  'httpServer',
  ['default', 'uws'],
  {
      host: { type: 'string', minLength: 1 },
      port: { type: 'integer', minimum: 1 },
      allowAllOrigins: { type: 'boolean' },
      origins: { type: 'array', items: { type: 'string', format: 'uri' } },
  }
)

const cacheOptions = getPluginOptions(
  'cache',
  ['default'],
  {
      host: { type: 'string', minLength: 1 },
      port: { type: 'integer', minimum: 1 },
  }
)

const storageOptions = getPluginOptions(
  'storage',
  ['default'],
  {
      host: { type: 'string', minLength: 1 },
      port: { type: 'integer', minimum: 1 },
  }
)

const authenticationOptions = {
  auth: {
    type: 'array',
    items: {
      properties: {
        type: { type: 'string', enum: ['none', 'file', 'http', 'storage'] },
        name: { type: 'string', minLength: 1 },
        path: { type: 'string', minLength: 1 },<commit_msg>fix: removing config validation for cache and storage<commit_after>import * as Ajv from 'ajv'
import { LOG_LEVEL } from '../../ds-types/src/index'

const LogLevelValidation = {
  type: ['string', 'integer'],
  enum: [
    'DEBUG', LOG_LEVEL.DEBUG,
    'INFO', LOG_LEVEL.INFO,
    'WARN', LOG_LEVEL.WARN,
    'ERROR', LOG_LEVEL.ERROR,
    'OFF', LOG_LEVEL.OFF
  ]
}

function getPluginOptions (name: string, types: string[], properties: any) {
  return {
    [name]: {
      type: 'object',
      properties: {
        type: { type: 'string', enum: types },
        name: { type: 'string', minLength: 1 },
        path: { type: 'string', minLength: 1 },
        options: {
          type: 'object',
          properties
        }
      },
      oneRequired: ['type', 'name', 'path']
    }
  }
}

const generalOptions = {
  libDir: { type: ['string', 'null'] },
  serverName: { type: 'string', minLength: 1 },
  externalUrl: { type: ['null', 'string'] },
  showLogo: { type: 'boolean' },
  exitOnFatalError: { type: 'boolean' },
  dependencyInitializationTimeout: { type: 'number', minimum: 1000 },
  logLevel: LogLevelValidation
}

const enabledFeatures = {
  enabledFeatures: {
    record: { type: 'boolean' },
    event: { type: 'boolean' },
    rpc: { type: 'boolean' },
    presence: { type: 'boolean' },
    monitoring: { type: 'boolean' },
  }
}

const rpcOptions = {
  rpc: {
    type: ['object'],
    ackTimeout: { type: 'integer', minimum: 1 },
    responseTimeout: { type: 'integer', minimum: 1 }
  }
}

const recordOptions = {
  record: {
    type: ['object'],
    cacheRetrievalTimeout: { type: 'integer', minimum: 50 },
    storageRetrievalTimeout: { type: 'integer', minimum: 50 },
    storageExclusionPrefixes: { type: ['null', 'array'], items: { type: 'string' } },
    storageHotPathPrefixes: { type: ['null', 'array'], items: { type: 'string' } }
  }
}

const listenOptions = {
  listen: {
    type: ['object'],
    shuffleProviders: { type: 'boolean' },
    responseTimeout: { type: 'integer', minimum: 50 },
    rematchInterval: { type: 'integer', minimum: 50 },
    matchCooldown: { type: 'integer', minimum: 50 },
  }
}

const httpServer = getPluginOptions(
  'httpServer',
  ['default', 'uws'],
  {
      host: { type: 'string', minLength: 1 },
      port: { type: 'integer', minimum: 1 },
      allowAllOrigins: { type: 'boolean' },
      origins: { type: 'array', items: { type: 'string', format: 'uri' } },
  }
)

const cacheOptions = getPluginOptions(
  'cache',
  ['default'],
  {
  }
)

const storageOptions = getPluginOptions(
  'storage',
  ['default'],
  {
  }
)

const authenticationOptions = {
  auth: {
    type: 'array',
    items: {
      properties: {
        type: { type: 'string', enum: ['none', 'file', 'http', 'storage'] },
        name: { type: 'string', minLength: 1 },
        path: { type: 'string', minLength: 1 },
{'fraction_non_alphanumeric': 0.17991132332878582, 'fraction_numerical': 0.008526603001364257, 'mean_word_length': 3.028159340659341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5605083', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1924, 'n_words': 499}