
/**
 * This is a build lambda gets.
 */

var joinText = require('@front.build/fullstack/plugin/join-text')
var checkState = require('@front.build/fullstack/plugin/check-state')
var compareState = require('@front.build/fullstack/plugin/compare-state')
var modelState = require('@front.build/fullstack/plugin/model-state')
var accessContext = require('@front.build/fullstack/plugin/access-context')
var generateID = require('@front.build/fullstack/plugin/generate-id')
var generateData = require('@front.build/fullstack/plugin/generate-data')
var runProcess = require('@front.build/fullstack/plugin/run-process')
var assertState = require('@front.build/fullstack/plugin/assert-state')
var writeFile = require('../plugin/write-file')
var removeFile = require('../plugin/remove-file')
var accessConfig = require('../plugin/access-config')
var accessState = require('../plugin/access-state')
var configLandAccessState = require('../plugin/Config.land-access-config')
var convertTextCase = require('../plugin/convert-text-case')
var fieldBlackAccessState = require('../plugin/Field.black-access-state')
var fieldBlackDispatchAction = require('../plugin/Field.black-dispatch-action')
var fieldBlackPersistState = require('../plugin/Field.black-persist-state')
var fieldBlackUpdateState = require('../plugin/Field.black-update-state')
var herokuAddAddon = require('../plugin/Heroku-add-addon')
var herokuCreateApp = require('../plugin/Heroku-create-app')
var herokuCreateBuild = require('../plugin/Heroku-create-build')
var herokuPollBuild = require('../plugin/Heroku-poll-build')
var lambdaBuildFunction = require('../plugin/Lambda-build-function')
var lambdaInvokeFunction = require('../plugin/Lambda-invoke-function')
var lambdaRewireFunction = require('../plugin/Lambda-rewire-function')
var lambdaUploadFunction = require('../plugin/Lambda-upload-function')
var minifyCSS = require('../plugin/minify-css')
var minifyJS = require('../plugin/minify-js')
var mongoDBAccessState = require('../plugin/MongoDB-access-state')
var mongoDBInitialize = require('../plugin/MongoDB-initialize')
var mongoDBPersistState = require('../plugin/MongoDB-persist-state')
var mongoDBUpdateState = require('../plugin/MongoDB-update-state')
var npmInstall = require('../plugin/NPM-install')
var npmPublish = require('../plugin/NPM-publish')
var persistState = require('../plugin/persist-state')
var pluginLandDispatchAction = require('../plugin/Plugin.land-dispatch-action')
var requestHTTP = require('../plugin/request-http')
var requestJSON = require('../plugin/request-json')
var s3GetBucket = require('../plugin/S3-get-bucket')
var s3Initialize = require('../plugin/S3-initialize')
var s3UploadToBucket = require('../plugin/S3-upload-to-bucket')
var shapeBlackDispatchAction = require('../plugin/Shape.black-dispatch-action')
var updateState = require('../plugin/update-state')
var webpackCreateBuild = require('../plugin/Webpack-create-build')
var runCloudAction = require('../plugin/run-cloud-action')

var State = require('@front.build/fullstack/state')
var Front = require('@front.build/fullstack/front')
var Database = require('@front.build/fullstack/db')
var UI = require('@front.build/fullstack/ui')

module.exports = Build

function Build(plugins) {
  plugins = plugins || {}
  plugins['Join text'] = plugins['Join text'] || joinText
  plugins['Check state'] = plugins['Check state'] || checkState
  plugins['Compare state'] = plugins['Compare state'] || compareState
  plugins['Access context'] = plugins['Access context'] || accessContext
  plugins['Assert state'] = plugins['Assert state'] || assertState
  plugins['Generate ID'] = plugins['Generate ID'] || generateID
  plugins['Generate data'] = plugins['Generate data'] || generateData
  plugins['Run process'] = plugins['Run process'] || runProcess
  plugins['Model state'] = plugins['Model state'] || modelState
  plugins['Write file'] = plugins['Write file'] || writeFile
  plugins['Remove file'] = plugins['Remove file'] || removeFile
  plugins['Access config'] = plugins['Access config'] || accessConfig
  plugins['Access state'] = plugins['Access state'] || accessState
  plugins['Config.land access config'] = plugins['Config.land access config'] || configLandAccessState
  plugins['Convert text case'] = plugins['Convert text case'] || convertTextCase
  plugins['Field.black access state'] = plugins['Field.black access state'] || fieldBlackAccessState
  plugins['Field.black dispatch action'] = plugins['Field.black dispatch action'] || fieldBlackDispatchAction
  plugins['Field.black persist state'] = plugins['Field.black persist state'] || fieldBlackPersistState
  plugins['Field.black update state'] = plugins['Field.black update state'] || fieldBlackUpdateState
  plugins['Heroku add addon'] = plugins['Heroku add addon'] || herokuAddAddon
  plugins['Heroku create app'] = plugins['Heroku create app'] || herokuCreateApp
  plugins['Heroku create build'] = plugins['Heroku create build'] || herokuCreateBuild
  plugins['Heroku poll build'] = plugins['Heroku poll build'] || herokuPollBuild
  plugins['Lambda build function'] = plugins['Lambda build function'] || lambdaBuildFunction
  plugins['Lambda invoke function'] = plugins['Lambda invoke function'] || lambdaInvokeFunction
  plugins['Lambda rewire function'] = plugins['Lambda rewire function'] || lambdaRewireFunction
  plugins['Lambda upload function'] = plugins['Lambda upload function'] || lambdaUploadFunction
  plugins['Minify CSS'] = plugins['Minify CSS'] || minifyCSS
  plugins['Minify JS'] = plugins['Minify JS'] || minifyJS
  plugins['MongoDB access state'] = plugins['MongoDB access state'] || mongoDBAccessState
  plugins['MongoDB initialize'] = plugins['MongoDB initialize'] || mongoDBInitialize
  plugins['MongoDB persist state'] = plugins['MongoDB persist state'] || mongoDBPersistState
  plugins['MongoDB update state'] = plugins['MongoDB update state'] || mongoDBUpdateState
  plugins['NPM install'] = plugins['NPM install'] || npmInstall
  plugins['NPM publish'] = plugins['NPM publish'] || npmPublish
  plugins['Persist state'] = plugins['Persist state'] || persistState
  plugins['Plugin.land dispatch action'] = plugins['Plugin.land dispatch action'] || pluginLandDispatchAction
  plugins['Request HTTP'] = plugins['Request HTTP'] || requestHTTP
  plugins['Request JSON'] = plugins['Request JSON'] || requestJSON
  plugins['Run cloud action'] = plugins['Run cloud action'] || runCloudAction
  plugins['S3 get bucket'] = plugins['S3 get bucket'] || s3GetBucket
  plugins['S3 initialize'] = plugins['S3 initialize'] || s3Initialize
  plugins['S3 upload to bucket'] = plugins['S3 upload to bucket'] || s3UploadToBucket
  plugins['Shape.black dispatch action'] = plugins['Shape.black dispatch action'] || shapeBlackDispatchAction
  plugins['Update state'] = plugins['Update state'] || updateState
  plugins['Webpack create build'] = plugins['Webpack create build'] || webpackCreateBuild
  this.front = new Front(plugins, new State({}))
}

Build.prototype.dispatch = function(action, context, callback) {
  return this.front.dispatch(action, context, callback)
}
