'use strict';
var mongoose = require('mongoose');
var ShortId = require('@hoist/mongoose-shortid');
var timestamps = require('mongoose-timestamp');
var BBPromise = require('bluebird');
var Schema = mongoose.Schema;
var environments = ['live', 'test', 'dev'];
var mongooseDelete = require('@hoist/mongoose-delete');
var keygen = require('keygenerator');
var ConnectorSettingSchema = new Schema({
  schemaVersion: String,
  _id: {
    type: ShortId,
    base: 64,
    retries: 4,
    len: 20
  },
  application: {
    type: ShortId,
    ref: 'Application',
    index: true,
    required: 'connectors must belong to an application'
  },
  environment: {
    type: String,
    enum: {
      values: environments,
      message: 'connectors must belong to a valid environment'
    },
    required: 'connectors must belong to a valid environment'
  },
  name: {
    type: String,
    required: 'connector must have a name'
  },
  connectorType: String,
  settings: {
    type: Schema.Types.Mixed
  },
  isOneClickConnector: Boolean,
  key: {
    type: String,
    required: true,
    default: function () {
      return keygen._();
    }
  },
  defaultKey:{
    type:String
  }
});

ConnectorSettingSchema.plugin(timestamps);
ConnectorSettingSchema.plugin(mongooseDelete);
ConnectorSettingSchema.index({
  key: 1,
  application: 1,
  environment: 1
}, {
  unique: true
});
mongoose.model('ConnectorSetting', ConnectorSettingSchema);

var ConnectorSetting = mongoose.model('ConnectorSetting');
BBPromise.promisifyAll(ConnectorSetting);
BBPromise.promisifyAll(ConnectorSetting.prototype);
exports.name = 'ConnectorSetting';
exports.model = ConnectorSetting;

@@ -988,16 +988,134 @@
 ed%0A  %7D,%0A
+  subscribedEvents: %7B%0A    type: %5BString%5D,%0A    required: false,%0A    default: function () %7B%0A      return %5B%5D;%0A    %7D%0A  %7D,%0A
   isOneC
@@ -1261,16 +1261,17 @@
 aultKey:
+ 
 %7B%0A    ty
@@ -1273,16 +1273,17 @@
    type:
+ 
 String%0A 

add subscribedEvents to the connector instance