import Migration, { MigrationFunction } from '@watermarkchurch/contentful-migration'

// Generated by contentful-schema-diff // from contentful-export-4gyidsb2jx1u-rorJeremy-2018-10-18T15-41-43.json // to 7yx6ovlj39n5/master export = function (migration: Migration, { makeRequest, spaceId, accessToken }) {

/************  section-contact-form  ******************/

var sectionContactForm = migration.createContentType('section-contact-form', {
  displayField: 'internalTitle',
  name: 'Section: Contact Form',
  description:
    'A Contact Form section contains a Form with several Form Fields.  The responses to the form will be collected and provided to the appropriate administrator.'
})

sectionContactForm.createField('internalTitle', {
  name: 'Internal Title (Contentful Only)',
  type: 'Symbol',
  localized: false,
  required: true,
  validations: [],
  disabled: false,
  omitted: false
})

sectionContactForm.createField('text', {
  name: 'Text',
  type: 'Text',
  localized: false,
  required: true,
  validations: [],
  disabled: false,
  omitted: false
})

sectionContactForm.createField('fields', {
  name: 'Fields',
  type: 'Array',
  localized: false,
  required: true,
  validations: [],
  disabled: false,
  omitted: false,
  items: {
    type: 'Link',
    validations: [
      {
        linkContentType: ['formField']
      }
    ],
    linkType: 'Entry'
  }
})

sectionContactForm.createField('submitButtonText', {
  name: 'Submit Button Text',
  type: 'Symbol',
  localized: false,
  required: false,
  validations: [],
  disabled: false,
  omitted: false
})

sectionContactForm.createField('notificationEmail', {
  name: 'NotificationEmail',
  type: 'Symbol',
  localized: false,
  required: true,
  validations: [
    {
      regexp: {
        pattern:
          '^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$',
        flags: null
      },
      message: 'Must be a valid email address.'
    }
  ],
  disabled: false,
  omitted: false
})

sectionContactForm.changeEditorInterface('internalTitle', 'singleLine')

sectionContactForm.changeEditorInterface('text', 'markdown')

sectionContactForm.changeEditorInterface('fields', 'entryLinksEditor')

sectionContactForm.changeEditorInterface('submitButtonText', 'singleLine')

sectionContactForm.changeEditorInterface('notificationEmail', 'singleLine', {
  helpText:
    'This is the email address where the form submission notification goes.'
})

/************  formField  ******************/

var formfield = migration.createContentType('formField', {
  displayField: 'internalTitle',
  name: 'Form Field',
  description: 'A Form Field represents a piece of information you want to collect from a user via a Form.'
})

formfield.createField('internalTitle', {
  name: 'Internal Title (Contentful Only)',
  type: 'Symbol',
  localized: false,
  required: true,
  validations: [],
  disabled: false,
  omitted: true
})

formfield.createField('title', {
  name: 'Title',
  type: 'Symbol',
  localized: false,
  required: false,
  validations: [],
  disabled: false,
  omitted: false
})

formfield.createField('inputType', {
  name: 'Input Type',
  type: 'Symbol',
  localized: false,
  required: true,
  validations:
    [{
      in:
        ['text',
          'email',
          'textarea']
    }],
  disabled: false,
  omitted: false
})

formfield.changeEditorInterface('title', 'singleLine')

formfield.changeEditorInterface('inputType', 'radio')

formfield.changeEditorInterface('internalTitle', 'singleLine')

} as MigrationFunction