_ = require 'lodash'
Promise = require 'bluebird'
Factory = require './factory'
EmbeddedArrayDefinition = require './embedded_array_definition'
MongooseFactory = require './mongoose_factory'
JSONSchemaFactory = require './json_schema_factory'

# it's awkward that these following are instance methods, but it means they'll
# always be available even if a subclass gets exported
Factory::array = (args...) -> new EmbeddedArrayDefinition(args...)
Factory::async = (resolver) ->
  (args...) -> Promise.fromNode(resolver.bind @, args...)
Factory::enum = (array) -> -> _.sample(array)
Factory::mongooseFactory = MongooseFactory.fromModel
Factory::JSONSchemaFactory = JSONSchemaFactory.fromJSONSchema

module.exports = new Factory([])
