{"size": 2301, "ext": "js", "max_stars_repo_path": "dist/types/index.js", "max_stars_repo_name": "staeco/iris-ql", "max_stars_repo_stars_event_min_datetime": "2019-07-23T16:26:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T21:07:49.000Z", "max_issues_repo_path": "dist/types/index.js", "max_issues_repo_name": "staeco/sequelize-api-query", "max_issues_repo_issues_event_min_datetime": "2019-09-12T00:46:56.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-26T22:49:49.000Z", "max_forks_repo_path": "dist/types/index.js", "max_forks_repo_name": "staeco/iris-ql", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 11, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 33.8382352941, "max_line_length": 197, "alphanum_fraction": 0.727944372}
"use strict";

exports.__esModule = true;
exports.text = exports.polygon = exports.point = exports.object = exports.number = exports.multipolygon = exports.multiline = exports.line = exports.date = exports.boolean = exports.array = void 0;

var _sequelize = _interopRequireDefault(require("sequelize"));

var _isNumber = _interopRequireDefault(require("is-number"));

var _humanSchema = require("human-schema");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const wgs84 = 4326;

const geoCast = txt => _sequelize.default.fn('ST_SetSRID', _sequelize.default.fn('ST_GeomFromGeoJSON', txt), wgs84); // Extend human-schema types and:
// - add a hydrate function to go from db text values -> properly typed values
// - make some types more permissive, since queries are often passed in via querystring


const array = { ..._humanSchema.types.array,
  // TODO: recursively map the array against the right types
  // this treats everything as a text array
  // probably need to pass in type and let the db figure out hydrating
  hydrate: txt => _sequelize.default.fn('fix_jsonb_array', txt)
};
exports.array = array;
const object = { ..._humanSchema.types.object,
  hydrate: txt => _sequelize.default.cast(txt, 'jsonb')
};
exports.object = object;
const text = { ..._humanSchema.types.text,
  hydrate: txt => txt
};
exports.text = text;
const number = { ..._humanSchema.types.number,
  test: _isNumber.default,
  hydrate: txt => _sequelize.default.cast(txt, 'numeric')
};
exports.number = number;
const boolean = { ..._humanSchema.types.boolean,
  hydrate: txt => _sequelize.default.cast(txt, 'boolean')
};
exports.boolean = boolean;
const date = { ..._humanSchema.types.date,
  hydrate: txt => _sequelize.default.fn('parse_iso', txt)
};
exports.date = date;
const point = { ..._humanSchema.types.point,
  hydrate: geoCast
};
exports.point = point;
const line = { ..._humanSchema.types.line,
  hydrate: geoCast
};
exports.line = line;
const multiline = { ..._humanSchema.types.multiline,
  hydrate: geoCast
};
exports.multiline = multiline;
const polygon = { ..._humanSchema.types.polygon,
  hydrate: geoCast
};
exports.polygon = polygon;
const multipolygon = { ..._humanSchema.types.multipolygon,
  hydrate: geoCast
};
exports.multipolygon = multipolygon;