import { UITypes } from 'nocodb-sdk';
import { createTable } from '../factory/table';
import { createBulkRows } from '../factory/row';
import { createLtarColumn } from '../factory/column';
import { ncAxios } from '../utils/ncAxios';
import type { IInitContext } from './index';
import type { Base } from '../../../src/models';

const countries = [
  'Afghanistan',
  'Algeria',
  'American Samoa',
  'Angola',
  'Anguilla',
  'Argentina',
  'Armenia',
  'Australia',
  'Austria',
  'Azerbaijan',
  'Bahrain',
  'Bangladesh',
  'Belarus',
  'Bolivia',
  'Brazil',
  'Brunei',
  'Bulgaria',
  'Cambodia',
  'Cameroon',
  'Canada',
  'Chad',
  'Chile',
  'China',
  'Colombia',
  'Congo, The Democratic Republic of the',
  'Czech Republic',
  'Dominican Republic',
  'Ecuador',
  'Egypt',
  'Estonia',
  'Ethiopia',
  'Faroe Islands',
  'Finland',
  'France',
  'French Guiana',
  'French Polynesia',
  'Gambia',
  'Germany',
  'Greece',
  'Greenland',
  'Holy See (Vatican City State)',
  'Hong Kong',
  'Hungary',
  'India',
  'Indonesia',
  'Iran',
  'Iraq',
  'Israel',
  'Italy',
  'Japan',
  'Kazakstan',
  'Kenya',
  'Kuwait',
  'Latvia',
  'Liechtenstein',
  'Lithuania',
  'Madagascar',
  'Malawi',
  'Malaysia',
  'Mexico',
  'Moldova',
  'Morocco',
  'Mozambique',
  'Myanmar',
  'Nauru',
  'Nepal',
  'Netherlands',
  'New Zealand',
  'Nigeria',
  'North Korea',
  'Oman',
  'Pakistan',
  'Paraguay',
  'Peru',
  'Philippines',
  'Poland',
  'Puerto Rico',
  'Romania',
  'Runion',
  'Russian Federation',
  'Saint Vincent and the Grenadines',
  'Saudi Arabia',
  'Senegal',
  'Slovakia',
  'South Africa',
  'South Korea',
  'Spain',
  'Sri Lanka',
  'Sudan',
  'Sweden',
  'Switzerland',
  'Taiwan',
  'Tanzania',
  'Thailand',
  'Tonga',
  'Tunisia',
  'Turkey',
  'Turkmenistan',
  'Tuvalu',
  'Ukraine',
  'United Arab Emirates',
  'United Kingdom',
  'United States',
  'Venezuela',
  'Vietnam',
  'Virgin Islands, U.S.',
  'Yemen',
  'Yugoslavia',
  'Zambia',
];

const cities = [
  { City: 'A Corua (La Corua)', CountryId: '87' },
  { City: 'Abha', CountryId: '82' },
  { City: 'Abu Dhabi', CountryId: '101' },
  { City: 'Acua', CountryId: '60' },
  { City: 'Adana', CountryId: '97' },
  { City: 'Addis Abeba', CountryId: '31' },
  { City: 'Aden', CountryId: '107' },
  { City: 'Adoni', CountryId: '44' },
  { City: 'Ahmadnagar', CountryId: '44' },
  { City: 'Akishima', CountryId: '50' },
  { City: 'Akron', CountryId: '103' },
  { City: 'al-Ayn', CountryId: '101' },
  { City: 'al-Hawiya', CountryId: '82' },
  { City: 'al-Manama', CountryId: '11' },
  { City: 'al-Qadarif', CountryId: '89' },
  { City: 'al-Qatif', CountryId: '82' },
  { City: 'Alessandria', CountryId: '49' },
  { City: 'Allappuzha (Alleppey)', CountryId: '44' },
  { City: 'Allende', CountryId: '60' },
  { City: 'Almirante Brown', CountryId: '6' },
  { City: 'Alvorada', CountryId: '15' },
  { City: 'Ambattur', CountryId: '44' },
  { City: 'Amersfoort', CountryId: '67' },
  { City: 'Amroha', CountryId: '44' },
  { City: 'Angra dos Reis', CountryId: '15' },
  { City: 'Anpolis', CountryId: '15' },
  { City: 'Antofagasta', CountryId: '22' },
  { City: 'Aparecida de Goinia', CountryId: '15' },
  { City: 'Apeldoorn', CountryId: '67' },
  { City: 'Araatuba', CountryId: '15' },
  { City: 'Arak', CountryId: '46' },
  { City: 'Arecibo', CountryId: '77' },
  { City: 'Arlington', CountryId: '103' },
  { City: 'Ashdod', CountryId: '48' },
  { City: 'Ashgabat', CountryId: '98' },
  { City: 'Ashqelon', CountryId: '48' },
  { City: 'Asuncin', CountryId: '73' },
  { City: 'Athenai', CountryId: '39' },
  { City: 'Atinsk', CountryId: '80' },
  { City: 'Atlixco', CountryId: '60' },
  { City: 'Augusta-Richmond County', CountryId: '103' },
  { City: 'Aurora', CountryId: '103' },
  { City: 'Avellaneda', CountryId: '6' },
  { City: 'Bag', CountryId: '15' },
  { City: 'Baha Blanca', CountryId: '6' },
  { City: 'Baicheng', CountryId: '23' },
  { City: 'Baiyin', CountryId: '23' },
  { City: 'Baku', CountryId: '10' },
  { City: 'Balaiha', CountryId: '80' },
  { City: 'Balikesir', CountryId: '97' },
  { City: 'Balurghat', CountryId: '44' },
  { City: 'Bamenda', CountryId: '19' },
  { City: 'Bandar Seri Begawan', CountryId: '16' },
  { City: 'Banjul', CountryId: '37' },
  { City: 'Barcelona', CountryId: '104' },
  { City: 'Basel', CountryId: '91' },
  { City: 'Bat Yam', CountryId: '48' },
  { City: 'Batman', CountryId: '97' },
  { City: 'Batna', CountryId: '2' },
  { City: 'Battambang', CountryId: '18' },
  { City: 'Baybay', CountryId: '75' },
  { City: 'Bayugan', CountryId: '75' },
  { City: 'Bchar', CountryId: '2' },
  { City: 'Beira', CountryId: '63' },
  { City: 'Bellevue', CountryId: '103' },
  { City: 'Belm', CountryId: '15' },
  { City: 'Benguela', CountryId: '4' },
  { City: 'Beni-Mellal', CountryId: '62' },
  { City: 'Benin City', CountryId: '69' },
  { City: 'Bergamo', CountryId: '49' },
  { City: 'Berhampore (Baharampur)', CountryId: '44' },
  { City: 'Bern', CountryId: '91' },
  { City: 'Bhavnagar', CountryId: '44' },
  { City: 'Bhilwara', CountryId: '44' },
  { City: 'Bhimavaram', CountryId: '44' },
  { City: 'Bhopal', CountryId: '44' },
  { City: 'Bhusawal', CountryId: '44' },
  { City: 'Bijapur', CountryId: '44' },
  { City: 'Bilbays', CountryId: '29' },
  { City: 'Binzhou', CountryId: '23' },
  { City: 'Birgunj', CountryId: '66' },
  { City: 'Bislig', CountryId: '75' },
  { City: 'Blumenau', CountryId: '15' },
  { City: 'Boa Vista', CountryId: '15' },
  { City: 'Boksburg', CountryId: '85' },
  { City: 'Botosani', CountryId: '78' },
  { City: 'Botshabelo', CountryId: '85' },
  { City: 'Bradford', CountryId: '102' },
  { City: 'Braslia', CountryId: '15' },
  { City: 'Bratislava', CountryId: '84' },
  { City: 'Brescia', CountryId: '49' },
  { City: 'Brest', CountryId: '34' },
  { City: 'Brindisi', CountryId: '49' },
  { City: 'Brockton', CountryId: '103' },
  { City: 'Bucuresti', CountryId: '78' },
  { City: 'Buenaventura', CountryId: '24' },
  { City: 'Bydgoszcz', CountryId: '76' },
  { City: 'Cabuyao', CountryId: '75' },
  { City: 'Callao', CountryId: '74' },
  { City: 'Cam Ranh', CountryId: '105' },
  { City: 'Cape Coral', CountryId: '103' },
  { City: 'Caracas', CountryId: '104' },
  { City: 'Carmen', CountryId: '60' },
  { City: 'Cavite', CountryId: '75' },
  { City: 'Cayenne', CountryId: '35' },
  { City: 'Celaya', CountryId: '60' },
  { City: 'Chandrapur', CountryId: '44' },
  { City: 'Changhwa', CountryId: '92' },
  { City: 'Changzhou', CountryId: '23' },
  { City: 'Chapra', CountryId: '44' },
  { City: 'Charlotte Amalie', CountryId: '106' },
  { City: 'Chatsworth', CountryId: '85' },
  { City: 'Cheju', CountryId: '86' },
  { City: 'Chiayi', CountryId: '92' },
  { City: 'Chisinau', CountryId: '61' },
  { City: 'Chungho', CountryId: '92' },
  { City: 'Cianjur', CountryId: '45' },
  { City: 'Ciomas', CountryId: '45' },
  { City: 'Ciparay', CountryId: '45' },
  { City: 'Citrus Heights', CountryId: '103' },
  { City: 'Citt del Vaticano', CountryId: '41' },
  { City: 'Ciudad del Este', CountryId: '73' },
  { City: 'Clarksville', CountryId: '103' },
  { City: 'Coacalco de Berriozbal', CountryId: '60' },
  { City: 'Coatzacoalcos', CountryId: '60' },
  { City: 'Compton', CountryId: '103' },
  { City: 'Coquimbo', CountryId: '22' },
  { City: 'Crdoba', CountryId: '6' },
  { City: 'Cuauhtmoc', CountryId: '60' },
  { City: 'Cuautla', CountryId: '60' },
  { City: 'Cuernavaca', CountryId: '60' },
  { City: 'Cuman', CountryId: '104' },
  { City: 'Czestochowa', CountryId: '76' },
  { City: 'Dadu', CountryId: '72' },
  { City: 'Dallas', CountryId: '103' },
  { City: 'Datong', CountryId: '23' },
  { City: 'Daugavpils', CountryId: '54' },
  { City: 'Davao', CountryId: '75' },
  { City: 'Daxian', CountryId: '23' },
  { City: 'Dayton', CountryId: '103' },
  { City: 'Deba Habe', CountryId: '69' },
  { City: 'Denizli', CountryId: '97' },
  { City: 'Dhaka', CountryId: '12' },
  { City: 'Dhule (Dhulia)', CountryId: '44' },
  { City: 'Dongying', CountryId: '23' },
  { City: 'Donostia-San Sebastin', CountryId: '87' },
  { City: 'Dos Quebradas', CountryId: '24' },
  { City: 'Duisburg', CountryId: '38' },
  { City: 'Dundee', CountryId: '102' },
  { City: 'Dzerzinsk', CountryId: '80' },
  { City: 'Ede', CountryId: '67' },
  { City: 'Effon-Alaiye', CountryId: '69' },
  { City: 'El Alto', CountryId: '14' },
  { City: 'El Fuerte', CountryId: '60' },
  { City: 'El Monte', CountryId: '103' },
  { City: 'Elista', CountryId: '80' },
  { City: 'Emeishan', CountryId: '23' },
  { City: 'Emmen', CountryId: '67' },
  { City: 'Enshi', CountryId: '23' },
  { City: 'Erlangen', CountryId: '38' },
  { City: 'Escobar', CountryId: '6' },
  { City: 'Esfahan', CountryId: '46' },
  { City: 'Eskisehir', CountryId: '97' },
  { City: 'Etawah', CountryId: '44' },
  { City: 'Ezeiza', CountryId: '6' },
  { City: 'Ezhou', CountryId: '23' },
  { City: 'Faaa', CountryId: '36' },
  { City: 'Fengshan', CountryId: '92' },
  { City: 'Firozabad', CountryId: '44' },
  { City: 'Florencia', CountryId: '24' },
  { City: 'Fontana', CountryId: '103' },
  { City: 'Fukuyama', CountryId: '50' },
  { City: 'Funafuti', CountryId: '99' },
  { City: 'Fuyu', CountryId: '23' },
  { City: 'Fuzhou', CountryId: '23' },
  { City: 'Gandhinagar', CountryId: '44' },
  { City: 'Garden Grove', CountryId: '103' },
  { City: 'Garland', CountryId: '103' },
  { City: 'Gatineau', CountryId: '20' },
  { City: 'Gaziantep', CountryId: '97' },
  { City: 'Gijn', CountryId: '87' },
  { City: 'Gingoog', CountryId: '75' },
  { City: 'Goinia', CountryId: '15' },
  { City: 'Gorontalo', CountryId: '45' },
  { City: 'Grand Prairie', CountryId: '103' },
  { City: 'Graz', CountryId: '9' },
  { City: 'Greensboro', CountryId: '103' },
  { City: 'Guadalajara', CountryId: '60' },
  { City: 'Guaruj', CountryId: '15' },
  { City: 'guas Lindas de Gois', CountryId: '15' },
  { City: 'Gulbarga', CountryId: '44' },
  { City: 'Hagonoy', CountryId: '75' },
  { City: 'Haining', CountryId: '23' },
  { City: 'Haiphong', CountryId: '105' },
  { City: 'Haldia', CountryId: '44' },
  { City: 'Halifax', CountryId: '20' },
  { City: 'Halisahar', CountryId: '44' },
  { City: 'Halle/Saale', CountryId: '38' },
  { City: 'Hami', CountryId: '23' },
  { City: 'Hamilton', CountryId: '68' },
  { City: 'Hanoi', CountryId: '105' },
  { City: 'Hidalgo', CountryId: '60' },
  { City: 'Higashiosaka', CountryId: '50' },
  { City: 'Hino', CountryId: '50' },
  { City: 'Hiroshima', CountryId: '50' },
  { City: 'Hodeida', CountryId: '107' },
  { City: 'Hohhot', CountryId: '23' },
  { City: 'Hoshiarpur', CountryId: '44' },
  { City: 'Hsichuh', CountryId: '92' },
  { City: 'Huaian', CountryId: '23' },
  { City: 'Hubli-Dharwad', CountryId: '44' },
  { City: 'Huejutla de Reyes', CountryId: '60' },
  { City: 'Huixquilucan', CountryId: '60' },
  { City: 'Hunuco', CountryId: '74' },
  { City: 'Ibirit', CountryId: '15' },
  { City: 'Idfu', CountryId: '29' },
  { City: 'Ife', CountryId: '69' },
  { City: 'Ikerre', CountryId: '69' },
  { City: 'Iligan', CountryId: '75' },
  { City: 'Ilorin', CountryId: '69' },
  { City: 'Imus', CountryId: '75' },
  { City: 'Inegl', CountryId: '97' },
  { City: 'Ipoh', CountryId: '59' },
  { City: 'Isesaki', CountryId: '50' },
  { City: 'Ivanovo', CountryId: '80' },
  { City: 'Iwaki', CountryId: '50' },
  { City: 'Iwakuni', CountryId: '50' },
  { City: 'Iwatsuki', CountryId: '50' },
  { City: 'Izumisano', CountryId: '50' },
  { City: 'Jaffna', CountryId: '88' },
  { City: 'Jaipur', CountryId: '44' },
  { City: 'Jakarta', CountryId: '45' },
  { City: 'Jalib al-Shuyukh', CountryId: '53' },
  { City: 'Jamalpur', CountryId: '12' },
  { City: 'Jaroslavl', CountryId: '80' },
  { City: 'Jastrzebie-Zdrj', CountryId: '76' },
  { City: 'Jedda', CountryId: '82' },
  { City: 'Jelets', CountryId: '80' },
  { City: 'Jhansi', CountryId: '44' },
  { City: 'Jinchang', CountryId: '23' },
  { City: 'Jining', CountryId: '23' },
  { City: 'Jinzhou', CountryId: '23' },
  { City: 'Jodhpur', CountryId: '44' },
  { City: 'Johannesburg', CountryId: '85' },
  { City: 'Joliet', CountryId: '103' },
  { City: 'Jos Azueta', CountryId: '60' },
  { City: 'Juazeiro do Norte', CountryId: '15' },
  { City: 'Juiz de Fora', CountryId: '15' },
  { City: 'Junan', CountryId: '23' },
  { City: 'Jurez', CountryId: '60' },
  { City: 'Kabul', CountryId: '1' },
  { City: 'Kaduna', CountryId: '69' },
  { City: 'Kakamigahara', CountryId: '50' },
  { City: 'Kaliningrad', CountryId: '80' },
  { City: 'Kalisz', CountryId: '76' },
  { City: 'Kamakura', CountryId: '50' },
  { City: 'Kamarhati', CountryId: '44' },
  { City: 'Kamjanets-Podilskyi', CountryId: '100' },
  { City: 'Kamyin', CountryId: '80' },
  { City: 'Kanazawa', CountryId: '50' },
  { City: 'Kanchrapara', CountryId: '44' },
  { City: 'Kansas City', CountryId: '103' },
  { City: 'Karnal', CountryId: '44' },
  { City: 'Katihar', CountryId: '44' },
  { City: 'Kermanshah', CountryId: '46' },
  { City: 'Kilis', CountryId: '97' },
  { City: 'Kimberley', CountryId: '85' },
  { City: 'Kimchon', CountryId: '86' },
  { City: 'Kingstown', CountryId: '81' },
  { City: 'Kirovo-Tepetsk', CountryId: '80' },
  { City: 'Kisumu', CountryId: '52' },
  { City: 'Kitwe', CountryId: '109' },
  { City: 'Klerksdorp', CountryId: '85' },
  { City: 'Kolpino', CountryId: '80' },
  { City: 'Konotop', CountryId: '100' },
  { City: 'Koriyama', CountryId: '50' },
  { City: 'Korla', CountryId: '23' },
  { City: 'Korolev', CountryId: '80' },
  { City: 'Kowloon and New Kowloon', CountryId: '42' },
  { City: 'Kragujevac', CountryId: '108' },
  { City: 'Ktahya', CountryId: '97' },
  { City: 'Kuching', CountryId: '59' },
  { City: 'Kumbakonam', CountryId: '44' },
  { City: 'Kurashiki', CountryId: '50' },
  { City: 'Kurgan', CountryId: '80' },
  { City: 'Kursk', CountryId: '80' },
  { City: 'Kuwana', CountryId: '50' },
  { City: 'La Paz', CountryId: '60' },
  { City: 'La Plata', CountryId: '6' },
  { City: 'La Romana', CountryId: '27' },
  { City: 'Laiwu', CountryId: '23' },
  { City: 'Lancaster', CountryId: '103' },
  { City: 'Laohekou', CountryId: '23' },
  { City: 'Lapu-Lapu', CountryId: '75' },
  { City: 'Laredo', CountryId: '103' },
  { City: 'Lausanne', CountryId: '91' },
  { City: 'Le Mans', CountryId: '34' },
  { City: 'Lengshuijiang', CountryId: '23' },
  { City: 'Leshan', CountryId: '23' },
  { City: 'Lethbridge', CountryId: '20' },
  { City: 'Lhokseumawe', CountryId: '45' },
  { City: 'Liaocheng', CountryId: '23' },
  { City: 'Liepaja', CountryId: '54' },
  { City: 'Lilongwe', CountryId: '58' },
  { City: 'Lima', CountryId: '74' },
  { City: 'Lincoln', CountryId: '103' },
  { City: 'Linz', CountryId: '9' },
  { City: 'Lipetsk', CountryId: '80' },
  { City: 'Livorno', CountryId: '49' },
  { City: 'Ljubertsy', CountryId: '80' },
  { City: 'Loja', CountryId: '28' },
  { City: 'London', CountryId: '102' },
  { City: 'London', CountryId: '20' },
  { City: 'Lublin', CountryId: '76' },
  { City: 'Lubumbashi', CountryId: '25' },
  { City: 'Lungtan', CountryId: '92' },
  { City: 'Luzinia', CountryId: '15' },
  { City: 'Madiun', CountryId: '45' },
  { City: 'Mahajanga', CountryId: '57' },
  { City: 'Maikop', CountryId: '80' },
  { City: 'Malm', CountryId: '90' },
  { City: 'Manchester', CountryId: '103' },
  { City: 'Mandaluyong', CountryId: '75' },
  { City: 'Mandi Bahauddin', CountryId: '72' },
  { City: 'Mannheim', CountryId: '38' },
  { City: 'Maracabo', CountryId: '104' },
  { City: 'Mardan', CountryId: '72' },
  { City: 'Maring', CountryId: '15' },
  { City: 'Masqat', CountryId: '71' },
  { City: 'Matamoros', CountryId: '60' },
  { City: 'Matsue', CountryId: '50' },
  { City: 'Meixian', CountryId: '23' },
  { City: 'Memphis', CountryId: '103' },
  { City: 'Merlo', CountryId: '6' },
  { City: 'Mexicali', CountryId: '60' },
  { City: 'Miraj', CountryId: '44' },
  { City: 'Mit Ghamr', CountryId: '29' },
  { City: 'Miyakonojo', CountryId: '50' },
  { City: 'Mogiljov', CountryId: '13' },
  { City: 'Molodetno', CountryId: '13' },
  { City: 'Monclova', CountryId: '60' },
  { City: 'Monywa', CountryId: '64' },
  { City: 'Moscow', CountryId: '80' },
  { City: 'Mosul', CountryId: '47' },
  { City: 'Mukateve', CountryId: '100' },
  { City: 'Munger (Monghyr)', CountryId: '44' },
  { City: 'Mwanza', CountryId: '93' },
  { City: 'Mwene-Ditu', CountryId: '25' },
  { City: 'Myingyan', CountryId: '64' },
  { City: 'Mysore', CountryId: '44' },
  { City: 'Naala-Porto', CountryId: '63' },
  { City: 'Nabereznyje Telny', CountryId: '80' },
  { City: 'Nador', CountryId: '62' },
  { City: 'Nagaon', CountryId: '44' },
  { City: 'Nagareyama', CountryId: '50' },
  { City: 'Najafabad', CountryId: '46' },
  { City: 'Naju', CountryId: '86' },
  { City: 'Nakhon Sawan', CountryId: '94' },
  { City: 'Nam Dinh', CountryId: '105' },
  { City: 'Namibe', CountryId: '4' },
  { City: 'Nantou', CountryId: '92' },
  { City: 'Nanyang', CountryId: '23' },
  { City: 'NDjamna', CountryId: '21' },
  { City: 'Newcastle', CountryId: '85' },
  { City: 'Nezahualcyotl', CountryId: '60' },
  { City: 'Nha Trang', CountryId: '105' },
  { City: 'Niznekamsk', CountryId: '80' },
  { City: 'Novi Sad', CountryId: '108' },
  { City: 'Novoterkassk', CountryId: '80' },
  { City: 'Nukualofa', CountryId: '95' },
  { City: 'Nuuk', CountryId: '40' },
  { City: 'Nyeri', CountryId: '52' },
  { City: 'Ocumare del Tuy', CountryId: '104' },
  { City: 'Ogbomosho', CountryId: '69' },
  { City: 'Okara', CountryId: '72' },
  { City: 'Okayama', CountryId: '50' },
  { City: 'Okinawa', CountryId: '50' },
  { City: 'Olomouc', CountryId: '26' },
  { City: 'Omdurman', CountryId: '89' },
  { City: 'Omiya', CountryId: '50' },
  { City: 'Ondo', CountryId: '69' },
  { City: 'Onomichi', CountryId: '50' },
  { City: 'Oshawa', CountryId: '20' },
  { City: 'Osmaniye', CountryId: '97' },
  { City: 'ostka', CountryId: '100' },
  { City: 'Otsu', CountryId: '50' },
  { City: 'Oulu', CountryId: '33' },
  { City: 'Ourense (Orense)', CountryId: '87' },
  { City: 'Owo', CountryId: '69' },
  { City: 'Oyo', CountryId: '69' },
  { City: 'Ozamis', CountryId: '75' },
  { City: 'Paarl', CountryId: '85' },
  { City: 'Pachuca de Soto', CountryId: '60' },
  { City: 'Pak Kret', CountryId: '94' },
  { City: 'Palghat (Palakkad)', CountryId: '44' },
  { City: 'Pangkal Pinang', CountryId: '45' },
  { City: 'Papeete', CountryId: '36' },
  { City: 'Parbhani', CountryId: '44' },
  { City: 'Pathankot', CountryId: '44' },
  { City: 'Patiala', CountryId: '44' },
  { City: 'Patras', CountryId: '39' },
  { City: 'Pavlodar', CountryId: '51' },
  { City: 'Pemalang', CountryId: '45' },
  { City: 'Peoria', CountryId: '103' },
  { City: 'Pereira', CountryId: '24' },
  { City: 'Phnom Penh', CountryId: '18' },
  { City: 'Pingxiang', CountryId: '23' },
  { City: 'Pjatigorsk', CountryId: '80' },
  { City: 'Plock', CountryId: '76' },
  { City: 'Po', CountryId: '15' },
  { City: 'Ponce', CountryId: '77' },
  { City: 'Pontianak', CountryId: '45' },
  { City: 'Poos de Caldas', CountryId: '15' },
  { City: 'Portoviejo', CountryId: '28' },
  { City: 'Probolinggo', CountryId: '45' },
  { City: 'Pudukkottai', CountryId: '44' },
  { City: 'Pune', CountryId: '44' },
  { City: 'Purnea (Purnia)', CountryId: '44' },
  { City: 'Purwakarta', CountryId: '45' },
  { City: 'Pyongyang', CountryId: '70' },
  { City: 'Qalyub', CountryId: '29' },
  { City: 'Qinhuangdao', CountryId: '23' },
];

export const initTblCountry = async (context: IInitContext, base: Base) => {
  const countryColumns = [
    {
      title: 'id',
      uidt: UITypes.ID,
    },
    {
      title: 'Country',
      uidt: UITypes.SingleLineText,
    },
  ];
  const countryTable = await createTable(context, base, {
    table_name: 'country',
    title: 'Country',
    columns: countryColumns,
  });
  const cityColumns = [
    {
      title: 'id',
      uidt: UITypes.ID,
    },
    {
      title: 'City',
      uidt: UITypes.SingleLineText,
    },
    {
      title: 'Area',
      uidt: UITypes.Decimal,
    },
  ];
  const cityTable = await createTable(context, base, {
    table_name: 'city',
    title: 'City',
    columns: cityColumns,
  });
  const ltarColumn = await createLtarColumn(context, {
    title: 'Cities',
    parentTable: countryTable,
    childTable: cityTable,
    type: 'hm',
  });

  // insert records
  // creating bulk records using older set of APIs
  await createBulkRows(context, {
    base: base,
    table: countryTable,
    values: countries.map((c) => ({ Country: c })),
  });
  await createBulkRows(context, {
    base: base,
    table: cityTable,
    values: cities.slice(0, 100),
  });
  await createBulkRows(context, {
    base: base,
    table: cityTable,
    values: cities.slice(100, 200),
  });
  const ncAxiosLinkAdd = (await ncAxios(context, base.id)).ncAxiosLinkAdd;
  const linkToLtar = (rowId: string, body: any[]) => {
    return ncAxiosLinkAdd({
      urlParams: {
        tableId: countryTable.id,
        linkId: ltarColumn.id,
        rowId: rowId,
      },
      body: body,
      status: 200,
    });
  };

  for (let i = 1; i <= 10; i++) {
    await linkToLtar(
      i.toString(),
      cities
        .map((c, idx) => ({ ...c, id: idx + 1 }))
        .filter((k) => k.id <= 200 && k.CountryId === i.toString())
        .sort((a, b) => a.id - b.id),
    );
  }
  return {
    countryTable,
    cityTable,
  };
};
