<commit_before>'use strict';
var _ = require('lodash');

var ObjectId = require('mongoose').Schema.Types.ObjectId;

function UiFormOptions(opts) {
  var options = _.cloneDeep(opts);
  // todo: add support of html 5 input types
  //email//tel//number//search//range//url//color//date//datetime//time//month//week
  // todo: check enum
  // todo: check email
  if (options.type === String){
    // todo: use options.uiForm.type
    // todo: check default type for String
    options.type = 'text' || 'textarea';
  }

  if (options.type === Number){
    // todo: use options.uiForm.type
    // todo: check default type for Number
    options.type = 'number';
  }

  if (options.type === Boolean){
    // todo: use options.uiForm.type
    // todo: check default type for Boolean
    options.type = 'checkbox';
  }

  if (options.type === Date){
    // todo: use options.uiForm.type
    // todo: check default type for Date
    options.type = 'date';
  }

  // this is direct reference type
  if (options.type === ObjectId && options.ref){
    // todo: use options.uiForm.type
    // todo: check default type for ObjectId||ref field
    options.type = 'select' || 'typeahead';
  }

  // _id - field
  if (options.type === ObjectId && !options.ref){
    options.type = 'text';
    options.editable = false;
    options.visible = false;
  }

  // array of refs
  if (Array.isArray(options.type) && options.type[0] && !!options.type[0].ref){
    options.type = 'arrayRef';
  }

  // array
  if (Array.isArray(options.type)){
    options.type = 'array';
    options.hideLabels = true;
  }

  if (options.ref && !options.uiForm){
    console.warn('add uiForm to path: %s', options.ref);
  }

  if (this.auto === true){
    this.visible = this.visible || false;
    delete this.auto;
  }

  options.visible = (options.visible === false) ? false : true;
  _.merge(this, options, options.uiForm);
}

function MongooseUtils() {<commit_msg>referenced types<commit_after>'use strict';
var _ = require('lodash');

var ObjectId = require('mongoose').Schema.Types.ObjectId;

function UiFormOptions(opts) {
  var options = _.cloneDeep(opts);
  Object.defineProperty(options, '_type', { value:options.type});
  // todo: add support of html 5 input types
  //email//tel//number//search//range//url//color//date//datetime//time//month//week
  // todo: check enum
  // todo: check email
  if (options.type === String){
    // todo: use options.uiForm.type
    // todo: check default type for String
    options.type = 'text' || 'textarea';
  }

  if (options.type === Number){
    // todo: use options.uiForm.type
    // todo: check default type for Number
    options.type = 'number';
  }

  if (options.type === Boolean){
    // todo: use options.uiForm.type
    // todo: check default type for Boolean
    options.type = 'checkbox';
  }

  if (options.type === Date){
    // todo: use options.uiForm.type
    // todo: check default type for Date
    options.type = 'date';
  }

  // _id - field
  if (options.type === ObjectId && !options.ref){
    options.type = 'text';
    options.editable = false;
    options.visible = false;
  }

  // this is direct reference type
  if (options.type === ObjectId && options.ref){
    // todo: use options.uiForm.type
    // todo: check default type for ObjectId||ref field
    options.type = 'select' || 'typeahead';
  }

  // array of refs
  if (Array.isArray(options.type) && options.type[0] && !!options.type[0].ref){
    options.ref = options.type[0].ref;
    options.type = 'arrayRef';
  }

  // array
  if (Array.isArray(options.type)){
    options.type = 'array';
    options.hideLabels = true;
  }

  if (options.ref && !options.uiForm){
    console.warn('add uiForm to path: %s', options.ref);
  }

  if (this.auto === true){
    this.visible = this.visible || false;
    delete this.auto;
  }

  options.visible = (options.visible === false) ? false : true;
  _.merge(this, options, options.uiForm);
}

function MongooseUtils() {
{'fraction_non_alphanumeric': 0.16195048004042445, 'fraction_numerical': 0.0017685699848408287, 'mean_word_length': 2.8214285714285716, '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': '6289508', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1253, 'n_words': 328}