import { DataSource } from 'typeorm';

const tableName = 'field_metadata';

export const seedFieldMetadata = async (
  workspaceDataSource: DataSource,
  schemaName: string,
) => {
  await workspaceDataSource
    .createQueryBuilder()
    .insert()
    .into(`${schemaName}.${tableName}`, [
      'objectId',
      'isCustom',
      'workspaceId',
      'isActive',
      'type',
      'name',
      'label',
      'targetColumnMap',
      'description',
      'icon',
      'isNullable',
    ])
    .orIgnore()
    .values([
      // Companies
      {
        objectId: '1a8487a0-480c-434e-b4c7-e22408b97047',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'name',
        label: 'Name',
        targetColumnMap: {
          value: 'name',
        },
        description: 'Name of the company',
        icon: 'IconBuildingSkyscraper',
        isNullable: false,
      },
      {
        objectId: '1a8487a0-480c-434e-b4c7-e22408b97047',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'domainName',
        label: 'Domain Name',
        targetColumnMap: {
          value: 'domainName',
        },
        description: 'Domain name of the company',
        icon: 'IconLink',
        isNullable: true,
      },
      {
        objectId: '1a8487a0-480c-434e-b4c7-e22408b97047',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'address',
        label: 'Address',
        targetColumnMap: {
          value: 'address',
        },
        description: 'Address of the company',
        icon: 'IconMap',
        isNullable: true,
      },
      {
        objectId: '1a8487a0-480c-434e-b4c7-e22408b97047',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'employees',
        label: 'Employees',
        targetColumnMap: {
          value: 'employees',
        },
        description: 'Number of employees',
        icon: 'IconUsers',
        isNullable: true,
      },
      // Views
      {
        objectId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'name',
        label: 'Name',
        targetColumnMap: {
          value: 'name',
        },
        description: 'View name',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'objectId',
        label: 'Object Id',
        targetColumnMap: {
          value: 'objectId',
        },
        description: 'View target object',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'type',
        label: 'Type',
        targetColumnMap: {
          value: 'type',
        },
        description: 'View type',
        icon: null,
        isNullable: false,
      },
      // View Fields
      {
        objectId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'fieldId',
        label: 'Field Id',
        targetColumnMap: {
          value: 'fieldId',
        },
        description: 'View Field target field',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'viewId',
        label: 'View Id',
        targetColumnMap: {
          value: 'viewId',
        },
        description: 'View Field related view',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'BOOLEAN',
        name: 'isVisible',
        label: 'Visible',
        targetColumnMap: {
          value: 'isVisible',
        },
        description: 'View Field visibility',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'NUMBER',
        name: 'size',
        label: 'Size',
        targetColumnMap: {
          value: 'size',
        },
        description: 'View Field size',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'NUMBER',
        name: 'position',
        label: 'Position',
        targetColumnMap: {
          value: 'position',
        },
        description: 'View Field position',
        icon: null,
        isNullable: false,
      },
      // View Filters
      {
        objectId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'fieldId',
        label: 'Field Id',
        targetColumnMap: {
          value: 'fieldId',
        },
        description: 'View Filter target field',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'viewId',
        label: 'View Id',
        targetColumnMap: {
          value: 'viewId',
        },
        description: 'View Filter related view',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'operand',
        label: 'Operand',
        targetColumnMap: {
          value: 'operand',
        },
        description: 'View Filter operand',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'value',
        label: 'Value',
        targetColumnMap: {
          value: 'value',
        },
        description: 'View Filter value',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'displayValue',
        label: 'Display Value',
        targetColumnMap: {
          value: 'displayValue',
        },
        description: 'View Filter Display Value',
        icon: null,
        isNullable: false,
      },
      // View Sorts
      {
        objectId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'fieldId',
        label: 'Field Id',
        targetColumnMap: {
          value: 'fieldId',
        },
        description: 'View Sort target field',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'viewId',
        label: 'View Id',
        targetColumnMap: {
          value: 'viewId',
        },
        description: 'View Sort related view',
        icon: null,
        isNullable: false,
      },
      {
        objectId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
        isCustom: false,
        workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
        isActive: true,
        type: 'TEXT',
        name: 'direction',
        label: 'Direction',
        targetColumnMap: {
          value: 'direction',
        },
        description: 'View Sort direction',
        icon: null,
        isNullable: false,
      },
    ])
    .execute();
};
