diff --git a/components/tomtom/actions/autocomplete-search/autocomplete-search.mjs b/components/tomtom/actions/autocomplete-search/autocomplete-search.mjs new file mode 100644 index 0000000000000..c8a8e1b810718 --- /dev/null +++ b/components/tomtom/actions/autocomplete-search/autocomplete-search.mjs @@ -0,0 +1,47 @@ +import app from "../../tomtom.app.mjs"; + +export default { + key: "tomtom-autocomplete-search", + name: "Autocomplete Search", + description: "Get search terms based on the provided query. [See the documentation](https://developer.tomtom.com/search-api/documentation/autocomplete-service/autocomplete)", + version: "0.0.1", + annotations: { + openWorldHint: true, + destructiveHint: false, + readOnlyHint: true, + }, + type: "action", + props: { + app, + query: { + propDefinition: [ + app, + "query", + ], + }, + language: { + propDefinition: [ + app, + "language", + ], + }, + extension: { + propDefinition: [ + app, + "extension", + ], + }, + }, + async run({ $ }) { + const response = await this.app.autocompleteSearch({ + $, + extension: this.extension, + query: this.query, + params: { + language: this.language, + }, + }); + $.export("$summary", "Successfully retrieved " + response.results.length + " results"); + return response; + }, +}; diff --git a/components/tomtom/actions/nearby-search/nearby-search.mjs b/components/tomtom/actions/nearby-search/nearby-search.mjs new file mode 100644 index 0000000000000..784847e08c585 --- /dev/null +++ b/components/tomtom/actions/nearby-search/nearby-search.mjs @@ -0,0 +1,61 @@ +import app from "../../tomtom.app.mjs"; + +export default { + key: "tomtom-nearby-search", + name: "Nearby Search", + description: "Get Points of Interest around your current location. [See the documentation](https://developer.tomtom.com/search-api/documentation/search-service/search-service)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + language: { + propDefinition: [ + app, + "language", + ], + }, + lat: { + propDefinition: [ + app, + "lat", + ], + }, + lon: { + propDefinition: [ + app, + "lon", + ], + }, + radius: { + propDefinition: [ + app, + "radius", + ], + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.app.nearbySearch({ + $, + params: { + language: this.language, + lat: this.lat, + lon: this.lon, + radius: this.radius, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully retrieved " + response.results.length + " results"); + return response; + }, +}; diff --git a/components/tomtom/actions/poi-search/poi-search.mjs b/components/tomtom/actions/poi-search/poi-search.mjs new file mode 100644 index 0000000000000..e8c426648844d --- /dev/null +++ b/components/tomtom/actions/poi-search/poi-search.mjs @@ -0,0 +1,68 @@ +import app from "../../tomtom.app.mjs"; + +export default { + key: "tomtom-poi-search", + name: "POI Search", + description: "Search for Points of Interest. [See the documentation](https://developer.tomtom.com/search-api/documentation/search-service/points-of-interest-search)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + query: { + propDefinition: [ + app, + "query", + ], + }, + language: { + propDefinition: [ + app, + "language", + ], + }, + lat: { + propDefinition: [ + app, + "lat", + ], + }, + lon: { + propDefinition: [ + app, + "lon", + ], + }, + radius: { + propDefinition: [ + app, + "radius", + ], + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.app.poiSearch({ + $, + query: this.query, + params: { + language: this.language, + lat: this.lat, + lon: this.lon, + radius: this.radius, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully retrieved " + response.results.length + " results"); + return response; + }, +}; diff --git a/components/tomtom/common/constants.mjs b/components/tomtom/common/constants.mjs new file mode 100644 index 0000000000000..37a017c3d703b --- /dev/null +++ b/components/tomtom/common/constants.mjs @@ -0,0 +1,222 @@ +export default { + EXTENSIONS: [ + "json", + "jsonp", + "js", + "xml", + ], + LANGUAGES: [ + { + "value": "af-ZA", + "label": "Afrikaans", + }, + { + "value": "ar", + "label": "Arabic", + }, + { + "value": "eu-ES", + "label": "Basque", + }, + { + "value": "bg-BG", + "label": "Bulgarian", + }, + { + "value": "ca-ES", + "label": "Catalan (Spain)", + }, + { + "value": "zh-CN", + "label": "Chinese (PRC)", + }, + { + "value": "zh-TW", + "label": "Chinese (Taiwan)", + }, + { + "value": "cs-CZ", + "label": "Czech", + }, + { + "value": "da-DK", + "label": "Danish", + }, + { + "value": "nl-BE", + "label": "Dutch (Belgium)", + }, + { + "value": "nl-NL", + "label": "Dutch", + }, + { + "value": "en-AU", + "label": "English (Australia)", + }, + { + "value": "en-NZ", + "label": "English (New Zealand)", + }, + { + "value": "en-GB", + "label": "English (Great Britain)", + }, + { + "value": "en-US", + "label": "English (USA)", + }, + { + "value": "et-EE", + "label": "Estonian", + }, + { + "value": "fi-FI", + "label": "Finnish", + }, + { + "value": "fr-CA", + "label": "French (Canada)", + }, + { + "value": "fr-FR", + "label": "French", + }, + { + "value": "gl-ES", + "label": "Galician", + }, + { + "value": "de-DE", + "label": "German", + }, + { + "value": "el-GR", + "label": "Greek", + }, + { + "value": "hr-HR", + "label": "Croatian", + }, + { + "value": "he-IL", + "label": "Hebrew", + }, + { + "value": "hu-HU", + "label": "Hungarian", + }, + { + "value": "id-ID", + "label": "Indonesian", + }, + { + "value": "it-IT", + "label": "Italian", + }, + { + "value": "kk-KZ", + "label": "Kazakh", + }, + { + "value": "ko-KR", + "label": "Korean written in the Hangul script.", + }, + { + "value": "ko-Latn-KR", + "label": "Korean written in the Latin script.", + }, + { + "value": "ko-Kore-KR", + "label": "Korean written in the Hangul script.", + }, + { + "value": "lv-LV", + "label": "Latvian", + }, + { + "value": "lt-LT", + "label": "Lithuanian", + }, + { + "value": "ms-MY", + "label": "Malay", + }, + { + "value": "no-NO", + "label": "Norwegian", + }, + { + "value": "nb-NO", + "label": "Norwegian", + }, + { + "value": "pl-PL", + "label": "Polish", + }, + { + "value": "pt-BR", + "label": "Portuguese (Brazil)", + }, + { + "value": "pt-PT", + "label": "Portuguese (Portugal)", + }, + { + "value": "ro-RO", + "label": "Romanian", + }, + { + "value": "ru-RU", + "label": "Russian written in the Cyrillic script.", + }, + { + "value": "ru-Latn-RU", + "label": "Russian written in the Latin script.", + }, + { + "value": "ru-Cyrl-RU", + "label": "Russian written in the Cyrillic script.", + }, + { + "value": "sr-RS", + "label": "Serbian", + }, + { + "value": "sk-SK", + "label": "Slovak", + }, + { + "value": "sl-SI", + "label": "Slovenian", + }, + { + "value": "es-ES", + "label": "Castilian Spanish", + }, + { + "value": "es-419", + "label": "Latin American Spanish", + }, + { + "value": "sv-SE", + "label": "Swedish", + }, + { + "value": "th-TH", + "label": "Thai", + }, + { + "value": "tr-TR", + "label": "Turkish", + }, + { + "value": "uk-UA", + "label": "Ukranian", + }, + { + "value": "vi-VN", + "label": "Vietnamese", + }, + ], +}; diff --git a/components/tomtom/package.json b/components/tomtom/package.json index ef4b2db67d596..74f7dede85306 100644 --- a/components/tomtom/package.json +++ b/components/tomtom/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/tomtom", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream TomTom Components", "main": "tomtom.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/tomtom/tomtom.app.mjs b/components/tomtom/tomtom.app.mjs index 627cff85a8ccd..a5b4abf673c44 100644 --- a/components/tomtom/tomtom.app.mjs +++ b/components/tomtom/tomtom.app.mjs @@ -1,11 +1,100 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "tomtom", - propDefinitions: {}, + propDefinitions: { + query: { + type: "string", + label: "Query", + description: "The search query", + }, + language: { + type: "string", + label: "Language", + description: "The language of the search results", + options: constants.LANGUAGES, + }, + lat: { + type: "string", + label: "Latitude", + description: "The latitude of the search center", + }, + lon: { + type: "string", + label: "Longitude", + description: "The longitude of the search center", + }, + radius: { + type: "string", + label: "Radius", + description: "The radius of the search area in meters", + optional: true, + }, + limit: { + type: "string", + label: "Limit", + description: "The maximum number of results to return", + optional: true, + }, + extension: { + type: "string", + label: "Extension", + description: "Expected response format", + options: constants.EXTENSIONS, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.tomtom.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + params, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + params: { + key: `${this.$auth.api_key}`, + ...params, + }, + }); + }, + + async autocompleteSearch({ + extension, + query, + ...args + }) { + return this._makeRequest({ + path: `/search/2/autocomplete/${query}.${extension}`, + ...args, + }); + }, + + async nearbySearch({ + extension, + ...args + }) { + return this._makeRequest({ + path: `/search/2/nearbySearch/.${extension}`, + ...args, + }); + }, + async poiSearch({ + extension, + query, + ...args + }) { + return this._makeRequest({ + path: `/search/2/poiSearch/${query}.${extension}`, + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ef46e344909ae..b0c31132371de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3414,8 +3414,7 @@ importers: components/cronly: {} - components/cronlytic: - specifiers: {} + components/cronlytic: {} components/crossmint: {} @@ -3624,8 +3623,7 @@ importers: components/data_police_uk: {} - components/data_soap: - specifiers: {} + components/data_soap: {} components/data_stores: dependencies: @@ -3733,13 +3731,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/decodo: - specifiers: {} + components/decodo: {} components/deel: {} - components/deep_tagger: - specifiers: {} + components/deep_tagger: {} components/deepgram: dependencies: @@ -3834,8 +3830,7 @@ importers: specifier: ^0.3.2 version: 0.3.2 - components/deutschlandgpt: - specifiers: {} + components/deutschlandgpt: {} components/dev_to: dependencies: @@ -4110,8 +4105,7 @@ importers: specifier: ^3.1.0 version: 3.1.0 - components/documentero: - specifiers: {} + components/documentero: {} components/documenterra: dependencies: @@ -4365,8 +4359,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/dumplingai: - specifiers: {} + components/dumplingai: {} components/dungeon_fighter_online: {} @@ -4433,8 +4426,7 @@ importers: components/easy_projects: {} - components/easy_redmine: - specifiers: {} + components/easy_redmine: {} components/easybroker: {} @@ -4481,8 +4473,7 @@ importers: components/ebay: {} - components/echowin: - specifiers: {} + components/echowin: {} components/echtpost_postcards: dependencies: @@ -4803,8 +4794,7 @@ importers: specifier: ^1.1.1 version: 1.6.6 - components/evervault: - specifiers: {} + components/evervault: {} components/everwebinar: dependencies: @@ -4871,8 +4861,7 @@ importers: components/extracta_ai: {} - components/extruct_ai: - specifiers: {} + components/extruct_ai: {} components/eyepop_ai: {} @@ -4986,8 +4975,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/featherless: - specifiers: {} + components/featherless: {} components/feathery: dependencies: @@ -5056,8 +5044,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/filescan: - specifiers: {} + components/filescan: {} components/filestack: dependencies: @@ -5995,8 +5982,7 @@ importers: components/google_chat_developer_app: {} - components/google_chat_service_account_key: - specifiers: {} + components/google_chat_service_account_key: {} components/google_classroom: dependencies: @@ -6499,8 +6485,7 @@ importers: components/hana: {} - components/handelsregister_ai: - specifiers: {} + components/handelsregister_ai: {} components/handwrytten: {} @@ -6548,8 +6533,7 @@ importers: specifier: ^2.29.4 version: 2.30.1 - components/hasdata: - specifiers: {} + components/hasdata: {} components/hashnode: {} @@ -7382,8 +7366,7 @@ importers: specifier: ^1.1.1 version: 1.6.6 - components/ipregistry: - specifiers: {} + components/ipregistry: {} components/ipstack: dependencies: @@ -8237,8 +8220,7 @@ importers: specifier: ^1.0.3 version: 1.0.3 - components/linkupapi: - specifiers: {} + components/linkupapi: {} components/linode: dependencies: @@ -14897,7 +14879,11 @@ importers: components/tomba: {} - components/tomtom: {} + components/tomtom: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/toneden: {} @@ -31542,22 +31528,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@10.0.0: resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==}