|
| 1 | +import { RestCountriesIcon } from '@/components/icons' |
| 2 | +import { type BlockConfig, IntegrationType } from '@/blocks/types' |
| 3 | +import type { RestCountriesResponse } from '@/tools/restcountries/types' |
| 4 | + |
| 5 | +export const RestCountriesBlock: BlockConfig<RestCountriesResponse> = { |
| 6 | + type: 'restcountries', |
| 7 | + name: 'REST Countries', |
| 8 | + description: 'Look up country reference data', |
| 9 | + longDescription: |
| 10 | + 'Look up country information using the REST Countries API. Search by name, code, region, currency, or language. Does not require OAuth or an API key.', |
| 11 | + docsLink: 'https://docs.sim.ai/tools/restcountries', |
| 12 | + category: 'tools', |
| 13 | + integrationType: IntegrationType.Analytics, |
| 14 | + tags: ['data-analytics', 'knowledge-base'], |
| 15 | + bgColor: '#E8F2FF', |
| 16 | + icon: RestCountriesIcon, |
| 17 | + subBlocks: [ |
| 18 | + { |
| 19 | + id: 'operation', |
| 20 | + title: 'Operation', |
| 21 | + type: 'dropdown', |
| 22 | + options: [ |
| 23 | + { label: 'Search by Name', id: 'restcountries_search_by_name' }, |
| 24 | + { label: 'Get by Code', id: 'restcountries_get_by_code' }, |
| 25 | + { label: 'List by Region', id: 'restcountries_list_by_region' }, |
| 26 | + { label: 'List by Currency', id: 'restcountries_list_by_currency' }, |
| 27 | + { label: 'List by Language', id: 'restcountries_list_by_language' }, |
| 28 | + ], |
| 29 | + value: () => 'restcountries_search_by_name', |
| 30 | + }, |
| 31 | + { |
| 32 | + id: 'name', |
| 33 | + title: 'Country Name', |
| 34 | + type: 'short-input', |
| 35 | + placeholder: 'Canada', |
| 36 | + condition: { field: 'operation', value: 'restcountries_search_by_name' }, |
| 37 | + required: { field: 'operation', value: 'restcountries_search_by_name' }, |
| 38 | + }, |
| 39 | + { |
| 40 | + id: 'fullText', |
| 41 | + title: 'Exact Match', |
| 42 | + type: 'switch', |
| 43 | + condition: { field: 'operation', value: 'restcountries_search_by_name' }, |
| 44 | + mode: 'advanced', |
| 45 | + }, |
| 46 | + { |
| 47 | + id: 'code', |
| 48 | + title: 'Country Code', |
| 49 | + type: 'short-input', |
| 50 | + placeholder: 'US, USA, 840', |
| 51 | + condition: { field: 'operation', value: 'restcountries_get_by_code' }, |
| 52 | + required: { field: 'operation', value: 'restcountries_get_by_code' }, |
| 53 | + }, |
| 54 | + { |
| 55 | + id: 'region', |
| 56 | + title: 'Region', |
| 57 | + type: 'dropdown', |
| 58 | + options: [ |
| 59 | + { label: 'Africa', id: 'Africa' }, |
| 60 | + { label: 'Americas', id: 'Americas' }, |
| 61 | + { label: 'Asia', id: 'Asia' }, |
| 62 | + { label: 'Europe', id: 'Europe' }, |
| 63 | + { label: 'Oceania', id: 'Oceania' }, |
| 64 | + ], |
| 65 | + value: () => 'Europe', |
| 66 | + condition: { field: 'operation', value: 'restcountries_list_by_region' }, |
| 67 | + required: { field: 'operation', value: 'restcountries_list_by_region' }, |
| 68 | + }, |
| 69 | + { |
| 70 | + id: 'currency', |
| 71 | + title: 'Currency', |
| 72 | + type: 'short-input', |
| 73 | + placeholder: 'USD, EUR, dollar', |
| 74 | + condition: { field: 'operation', value: 'restcountries_list_by_currency' }, |
| 75 | + required: { field: 'operation', value: 'restcountries_list_by_currency' }, |
| 76 | + }, |
| 77 | + { |
| 78 | + id: 'language', |
| 79 | + title: 'Language', |
| 80 | + type: 'short-input', |
| 81 | + placeholder: 'English, Spanish, en', |
| 82 | + condition: { field: 'operation', value: 'restcountries_list_by_language' }, |
| 83 | + required: { field: 'operation', value: 'restcountries_list_by_language' }, |
| 84 | + }, |
| 85 | + ], |
| 86 | + tools: { |
| 87 | + access: [ |
| 88 | + 'restcountries_search_by_name', |
| 89 | + 'restcountries_get_by_code', |
| 90 | + 'restcountries_list_by_region', |
| 91 | + 'restcountries_list_by_currency', |
| 92 | + 'restcountries_list_by_language', |
| 93 | + ], |
| 94 | + config: { |
| 95 | + tool: (params) => { |
| 96 | + switch (params.operation) { |
| 97 | + case 'restcountries_get_by_code': |
| 98 | + return 'restcountries_get_by_code' |
| 99 | + case 'restcountries_list_by_region': |
| 100 | + return 'restcountries_list_by_region' |
| 101 | + case 'restcountries_list_by_currency': |
| 102 | + return 'restcountries_list_by_currency' |
| 103 | + case 'restcountries_list_by_language': |
| 104 | + return 'restcountries_list_by_language' |
| 105 | + default: |
| 106 | + return 'restcountries_search_by_name' |
| 107 | + } |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + inputs: { |
| 112 | + operation: { type: 'string', description: 'Country lookup operation to perform' }, |
| 113 | + name: { type: 'string', description: 'Country name to search for' }, |
| 114 | + fullText: { type: 'boolean', description: 'Require an exact country-name match' }, |
| 115 | + code: { type: 'string', description: 'Country code to look up' }, |
| 116 | + region: { type: 'string', description: 'World region to list countries from' }, |
| 117 | + currency: { type: 'string', description: 'Currency code or name to search for' }, |
| 118 | + language: { type: 'string', description: 'Language code or name to search for' }, |
| 119 | + }, |
| 120 | + outputs: { |
| 121 | + countries: { type: 'json', description: 'Countries returned by REST Countries' }, |
| 122 | + count: { type: 'number', description: 'Number of countries returned' }, |
| 123 | + firstCountry: { type: 'json', description: 'First country in the returned list' }, |
| 124 | + }, |
| 125 | +} |
0 commit comments