{"size": 963, "ext": "js", "max_stars_repo_path": "server/GQLFactory/helpers/helperFunctions.js", "max_stars_repo_name": "oslabs-beta/lexiQL", "max_stars_repo_stars_event_min_datetime": "2021-03-22T18:11:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-20T02:58:51.000Z", "max_issues_repo_path": "server/GQLFactory/helpers/helperFunctions.js", "max_issues_repo_name": "BarrBrian/lexiQL", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/GQLFactory/helpers/helperFunctions.js", "max_forks_repo_name": "BarrBrian/lexiQL", "max_forks_repo_forks_event_min_datetime": "2021-03-22T18:11:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-22T18:27:34.000Z"}
{"max_stars_count": 80, "max_issues_count": null, "max_forks_count": 30, "avg_line_length": 20.0625, "max_line_length": 77, "alphanum_fraction": 0.5981308411}
// for future uri validation
// const validateURIFormat = (uri) => {
//     return uri.slice(0, 12).includes('postgres://');
//   };

const isJunctionTable = (foreignKeys, columns) => {
  if (!foreignKeys) return false;
  return Object.keys(foreignKeys).length + 1 === Object.keys(columns).length;
};

const setType = (str) => {
  switch (str) {
    case 'character varying':
      return 'String';
    case 'character':
      return 'String';
    case 'integer':
      return 'Int';
    case 'bigint':
      return 'String';
    case 'text':
      return 'String';
    case 'date':
      return 'String';
    case 'boolean':
      return 'Boolean';
    default:
      return 'String';
  }
};

const typeConversion = {
  'character varying': 'String',
  character: 'String',
  integer: 'Int',
  text: 'String',
  date: 'String',
  boolean: 'Boolean',
  numeric: 'Int',
  bigint: 'String',
};

module.exports = {
  isJunctionTable,
  setType,
  typeConversion,
};
