From 79c60e15e634cfa8ef2925e619fbdc630f98cca2 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 10 Feb 2025 13:42:27 -0500 Subject: [PATCH 1/7] mapbox init --- .../actions/create-tileset/create-tileset.mjs | 47 ++++ .../generate-directions.mjs | 53 +++++ .../geocode-address/geocode-address.mjs | 41 ++++ components/mapbox/mapbox.app.mjs | 209 ++++++++++++++++++ 4 files changed, 350 insertions(+) create mode 100644 components/mapbox/actions/create-tileset/create-tileset.mjs create mode 100644 components/mapbox/actions/generate-directions/generate-directions.mjs create mode 100644 components/mapbox/actions/geocode-address/geocode-address.mjs create mode 100644 components/mapbox/mapbox.app.mjs diff --git a/components/mapbox/actions/create-tileset/create-tileset.mjs b/components/mapbox/actions/create-tileset/create-tileset.mjs new file mode 100644 index 0000000000000..beb95ff1d14c1 --- /dev/null +++ b/components/mapbox/actions/create-tileset/create-tileset.mjs @@ -0,0 +1,47 @@ +import mapbox from "../../mapbox.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "mapbox-create-tileset", + name: "Create Tileset", + description: "Uploads and creates a new tileset from a data source. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + mapbox, + sourceFile: { + propDefinition: [ + "mapbox", + "sourceFile", + ], + }, + tilesetName: { + propDefinition: [ + "mapbox", + "tilesetName", + ], + }, + description: { + propDefinition: [ + "mapbox", + "description", + ], + }, + privacySettings: { + propDefinition: [ + "mapbox", + "privacySettings", + ], + }, + }, + async run({ $ }) { + const response = await this.mapbox.uploadTileset({ + sourceFile: this.sourceFile, + tilesetName: this.tilesetName, + description: this.description, + privacySettings: this.privacySettings, + }); + $.export("$summary", `Created tileset ${this.tilesetName}`); + return response; + }, +}; diff --git a/components/mapbox/actions/generate-directions/generate-directions.mjs b/components/mapbox/actions/generate-directions/generate-directions.mjs new file mode 100644 index 0000000000000..d8b7a80862e94 --- /dev/null +++ b/components/mapbox/actions/generate-directions/generate-directions.mjs @@ -0,0 +1,53 @@ +import mapbox from "../../mapbox.app.mjs"; + +export default { + key: "mapbox-generate-directions", + name: "Generate Directions", + description: "Generates directions between two or more locations using Mapbox API. [See the documentation]().", + version: "0.0.{{ts}}", + type: "action", + props: { + mapbox, + startCoordinate: { + propDefinition: [ + mapbox, + "startCoordinate", + ], + }, + endCoordinate: { + propDefinition: [ + mapbox, + "endCoordinate", + ], + }, + waypoints: { + propDefinition: [ + mapbox, + "waypoints", + ], + }, + transportationMode: { + propDefinition: [ + mapbox, + "transportationMode", + ], + }, + routeType: { + propDefinition: [ + mapbox, + "routeType", + ], + }, + }, + async run({ $ }) { + const directions = await this.mapbox.getDirections({ + startCoordinate: this.startCoordinate, + endCoordinate: this.endCoordinate, + waypoints: this.waypoints, + transportationMode: this.transportationMode, + routeType: this.routeType, + }); + $.export("$summary", "Generated directions successfully."); + return directions; + }, +}; diff --git a/components/mapbox/actions/geocode-address/geocode-address.mjs b/components/mapbox/actions/geocode-address/geocode-address.mjs new file mode 100644 index 0000000000000..40fcdd7034810 --- /dev/null +++ b/components/mapbox/actions/geocode-address/geocode-address.mjs @@ -0,0 +1,41 @@ +import mapbox from "../../mapbox.app.mjs"; + +export default { + key: "mapbox-geocode-address", + name: "Geocode Address", + description: "Retrieves the geocoded location for a given address. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + mapbox, + address: { + propDefinition: [ + mapbox, + "address", + ], + }, + boundingBox: { + propDefinition: [ + mapbox, + "boundingBox", + ], + optional: true, + }, + proximity: { + propDefinition: [ + mapbox, + "proximity", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.mapbox.geocode({ + address: this.address, + boundingBox: this.boundingBox, + proximity: this.proximity, + }); + $.export("$summary", `Geocoded location for address "${this.address}" retrieved successfully`); + return response; + }, +}; diff --git a/components/mapbox/mapbox.app.mjs b/components/mapbox/mapbox.app.mjs new file mode 100644 index 0000000000000..cbcc755c51df1 --- /dev/null +++ b/components/mapbox/mapbox.app.mjs @@ -0,0 +1,209 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "mapbox", + version: "0.0.{{ts}}", + propDefinitions: { + // Geocoding Props + address: { + type: "string", + label: "Address", + description: "The address to geocode", + }, + boundingBox: { + type: "string", + label: "Bounding Box", + description: "Optional bounding box in the format minLng,minLat,maxLng,maxLat", + optional: true, + }, + proximity: { + type: "string", + label: "Proximity", + description: "Optional proximity point in the format longitude,latitude", + optional: true, + }, + // Directions Props + startCoordinate: { + type: "string", + label: "Start Coordinate", + description: "The starting point in the format longitude,latitude", + }, + endCoordinate: { + type: "string", + label: "End Coordinate", + description: "The ending point in the format longitude,latitude", + }, + waypoints: { + type: "string[]", + label: "Waypoints", + description: "Optional waypoints as an array of longitude,latitude strings", + optional: true, + }, + transportationMode: { + type: "string", + label: "Transportation Mode", + description: "Optional transportation mode", + options: [ + { + label: "Driving", + value: "driving", + }, + { + label: "Walking", + value: "walking", + }, + { + label: "Cycling", + value: "cycling", + }, + { + label: "Driving Traffic", + value: "driving-traffic", + }, + ], + optional: true, + }, + routeType: { + type: "string", + label: "Route Type", + description: "Optional route type", + options: [ + { + label: "Fastest", + value: "fastest", + }, + { + label: "Shortest", + value: "shortest", + }, + ], + optional: true, + }, + // Tileset Upload Props + sourceFile: { + type: "string", + label: "Source File", + description: "The source file for the tileset", + }, + tilesetName: { + type: "string", + label: "Tileset Name", + description: "The name of the new tileset", + }, + description: { + type: "string", + label: "Description", + description: "Optional description for the tileset", + optional: true, + }, + privacySettings: { + type: "string", + label: "Privacy Settings", + description: "Optional privacy settings for the tileset", + options: [ + { + label: "Public", + value: "public", + }, + { + label: "Private", + value: "private", + }, + ], + optional: true, + }, + }, + methods: { + _baseUrl() { + return "https://api.mapbox.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path = "/", headers = {}, params = {}, data, ...otherOpts + } = opts; + return axios($, { + method, + url: `${this._baseUrl()}${path}`, + headers: { + ...headers, + }, + params: { + access_token: this.$auth.access_token, + ...params, + }, + data, + ...otherOpts, + }); + }, + async geocode(opts = {}) { + const { + address, boundingBox, proximity, + } = opts; + const params = { + types: "address", + }; + if (boundingBox) { + params.bbox = boundingBox; + } + if (proximity) { + params.proximity = proximity; + } + return this._makeRequest({ + path: `/geocoding/v5/mapbox.places/${encodeURIComponent(address)}.json`, + params, + }); + }, + async getDirections(opts = {}) { + const { + startCoordinate, endCoordinate, waypoints, transportationMode, routeType, + } = opts; + let coordinates = `${startCoordinate};${endCoordinate}`; + if (waypoints && waypoints.length > 0) { + coordinates = `${startCoordinate};${waypoints.join(";")};${endCoordinate}`; + } + const params = {}; + if (transportationMode) { + params.profile = transportationMode; + } + if (routeType) { + params.alternatives = routeType === "fastest" + ? "true" + : "false"; + } + return this._makeRequest({ + path: `/directions/v5/mapbox.${transportationMode || "driving"}/${coordinates}`, + params, + }); + }, + async uploadTileset(opts = {}) { + const { + sourceFile, tilesetName, description, privacySettings, + } = opts; + const params = { + tileset: tilesetName, + }; + if (description) { + params.description = description; + } + if (privacySettings) { + params.private = privacySettings === "private" + ? true + : false; + } + return this._makeRequest({ + method: "POST", + path: `/uploads/v1/${encodeURIComponent(this.$auth.username)}`, + params, + data: { + data: sourceFile, + tileset: { + name: tilesetName, + description: description || "", + private: privacySettings === "private", + }, + }, + }); + }, + }, +}; From 314b041e171b8f2f4806cc33ad782e63d3f0ec52 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 10 Feb 2025 16:16:09 -0500 Subject: [PATCH 2/7] new components --- components/mapbox/.gitignore | 3 - .../actions/create-tileset/create-tileset.mjs | 104 ++++++--- .../generate-directions.mjs | 50 ++-- .../geocode-address/geocode-address.mjs | 36 +-- components/mapbox/app/mapbox.app.ts | 13 -- components/mapbox/common/constants.mjs | 21 ++ components/mapbox/mapbox.app.mjs | 215 ++++-------------- components/mapbox/package.json | 11 +- 8 files changed, 195 insertions(+), 258 deletions(-) delete mode 100644 components/mapbox/.gitignore delete mode 100644 components/mapbox/app/mapbox.app.ts create mode 100644 components/mapbox/common/constants.mjs diff --git a/components/mapbox/.gitignore b/components/mapbox/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/mapbox/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/mapbox/actions/create-tileset/create-tileset.mjs b/components/mapbox/actions/create-tileset/create-tileset.mjs index beb95ff1d14c1..89d28385439d2 100644 --- a/components/mapbox/actions/create-tileset/create-tileset.mjs +++ b/components/mapbox/actions/create-tileset/create-tileset.mjs @@ -1,46 +1,98 @@ import mapbox from "../../mapbox.app.mjs"; -import { axios } from "@pipedream/platform"; +import fs from "fs"; +import FormData from "form-data"; export default { key: "mapbox-create-tileset", name: "Create Tileset", - description: "Uploads and creates a new tileset from a data source. [See the documentation]()", - version: "0.0.{{ts}}", + description: "Uploads and creates a new tileset from a data source. [See the documentation](https://docs.mapbox.com/api/maps/mapbox-tiling-service/)", + version: "0.0.1", type: "action", props: { mapbox, - sourceFile: { - propDefinition: [ - "mapbox", - "sourceFile", - ], + username: { + type: "string", + label: "Username", + description: "The Mapbox username of the account for which to create a tileset source", }, tilesetName: { - propDefinition: [ - "mapbox", - "tilesetName", - ], + type: "string", + label: "Tileset Name", + description: "A unique name for the tileset source to be created. Limited to 32 characters. The only allowed special characters are - and _.", + }, + filePath: { + type: "string", + label: "File Path", + description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", + }, + recipe: { + type: "object", + label: "Recipe", + description: "A recipe that describes how the GeoJSON data you uploaded should be transformed into tiles. For more information on how to create and format recipes, see the ]Recipe reference](https://docs.mapbox.com/mapbox-tiling-service/reference/) and [Recipe examples](https://docs.mapbox.com/mapbox-tiling-service/examples/).", }, description: { - propDefinition: [ - "mapbox", - "description", - ], + type: "string", + label: "Description", + description: "A description of the tileset", + optional: true, }, - privacySettings: { - propDefinition: [ - "mapbox", - "privacySettings", - ], + private: { + type: "boolean", + label: "Private", + description: "Describes whether the tileset must be used with an access token from your Mapbox account. Default is `true`.", + optional: true, }, }, async run({ $ }) { - const response = await this.mapbox.uploadTileset({ - sourceFile: this.sourceFile, - tilesetName: this.tilesetName, - description: this.description, - privacySettings: this.privacySettings, + const filePath = this.filePath.includes("tmp/") + ? this.filePath + : `/tmp/${this.filePath}`; + + // Create Tileset Source + try { + const fileData = new FormData(); + const content = fs.createReadStream(filePath); + fileData.append("file", content); + + await this.mapbox.createTilesetSource({ + $, + username: this.username, + id: this.tilesetName, + data: fileData, + headers: fileData.getHeaders(), + }); + } catch (e) { + throw new Error(`Error uploading file: \`${filePath}\`. Error: ${e}`); + } + + const recipe = typeof this.recipe === "string" + ? JSON.parse(this.recipe) + : this.recipe; + + // Validate Recipe + const { + valid, errors, + } = await this.mapbox.validateRecipe({ + $, + data: recipe, }); + + if (!valid) { + throw new Error(`Error validating recipe: ${errors}`); + } + + // Create Tileset + const response = await this.mapbox.createTileset({ + $, + tilesetId: `${this.username}.${this.tilesetName}`, + data: { + recipe, + name: this.tilesetName, + description: this.description, + private: this.private, + }, + }); + $.export("$summary", `Created tileset ${this.tilesetName}`); return response; }, diff --git a/components/mapbox/actions/generate-directions/generate-directions.mjs b/components/mapbox/actions/generate-directions/generate-directions.mjs index d8b7a80862e94..839d4e5e11ef2 100644 --- a/components/mapbox/actions/generate-directions/generate-directions.mjs +++ b/components/mapbox/actions/generate-directions/generate-directions.mjs @@ -3,28 +3,20 @@ import mapbox from "../../mapbox.app.mjs"; export default { key: "mapbox-generate-directions", name: "Generate Directions", - description: "Generates directions between two or more locations using Mapbox API. [See the documentation]().", - version: "0.0.{{ts}}", + description: "Generates directions between two or more locations using Mapbox API. [See the documentation](https://docs.mapbox.com/api/navigation/directions/).", + version: "0.0.1", type: "action", props: { mapbox, startCoordinate: { - propDefinition: [ - mapbox, - "startCoordinate", - ], + type: "string", + label: "Start Coordinate", + description: "The starting point in the format `longitude,latitude`", }, endCoordinate: { - propDefinition: [ - mapbox, - "endCoordinate", - ], - }, - waypoints: { - propDefinition: [ - mapbox, - "waypoints", - ], + type: "string", + label: "End Coordinate", + description: "The ending point in the format `longitude,latitude`", }, transportationMode: { propDefinition: [ @@ -32,20 +24,34 @@ export default { "transportationMode", ], }, - routeType: { + steps: { + type: "boolean", + label: "Steps", + description: "Whether to return steps and turn-by-turn instructions (`true`) or not (`false`, default)", + }, + alternatives: { + type: "boolean", + label: "Alternatives", + description: "Whether to try to return alternative routes (`true`) or not (`false`, default). An alternative route is a route that is significantly different from the fastest route, but still close in time.", + optional: true, + }, + exclude: { propDefinition: [ mapbox, - "routeType", + "exclude", ], }, }, async run({ $ }) { const directions = await this.mapbox.getDirections({ - startCoordinate: this.startCoordinate, - endCoordinate: this.endCoordinate, - waypoints: this.waypoints, + $, transportationMode: this.transportationMode, - routeType: this.routeType, + coordinates: `${this.startCoordinate};${this.endCoordinate}`, + params: { + steps: this.steps, + alternatives: this.alternatives, + exclude: this.exclude && this.exclude.join(","), + }, }); $.export("$summary", "Generated directions successfully."); return directions; diff --git a/components/mapbox/actions/geocode-address/geocode-address.mjs b/components/mapbox/actions/geocode-address/geocode-address.mjs index 40fcdd7034810..8fb8d9c07765e 100644 --- a/components/mapbox/actions/geocode-address/geocode-address.mjs +++ b/components/mapbox/actions/geocode-address/geocode-address.mjs @@ -3,39 +3,39 @@ import mapbox from "../../mapbox.app.mjs"; export default { key: "mapbox-geocode-address", name: "Geocode Address", - description: "Retrieves the geocoded location for a given address. [See the documentation]()", - version: "0.0.{{ts}}", + description: "Retrieves the geocoded location for a given address. [See the documentation](https://docs.mapbox.com/api/search/geocoding/)", + version: "0.0.1", type: "action", props: { mapbox, address: { - propDefinition: [ - mapbox, - "address", - ], + type: "string", + label: "Address", + description: "The address (or partial address) to geocode. This could be an address, a city name, etc. Must consist of at most 20 words and numbers separated by spacing and punctuation, and at most 256 characters.", }, boundingBox: { - propDefinition: [ - mapbox, - "boundingBox", - ], + type: "string", + label: "Bounding Box", + description: "Limit results to only those contained within the supplied bounding box. Bounding boxes should be supplied as four numbers separated by commas, in `minLon,minLat,maxLon,maxLat` order. The bounding box cannot cross the 180th meridian. You can use the [Location Helper](https://labs.mapbox.com/location-helper) to find a bounding box for use with this API.", optional: true, }, proximity: { - propDefinition: [ - mapbox, - "proximity", - ], + type: "string", + label: "Proximity", + description: "Bias the response to favor results that are closer to this location. Provided as two comma-separated coordinates in `longitude,latitude` order.", optional: true, }, }, async run({ $ }) { const response = await this.mapbox.geocode({ - address: this.address, - boundingBox: this.boundingBox, - proximity: this.proximity, + $, + params: { + q: this.address, + bBox: this.boundingBox, + proximity: this.proximity, + }, }); - $.export("$summary", `Geocoded location for address "${this.address}" retrieved successfully`); + $.export("$summary", `Geocoded location for "${this.address}" retrieved successfully`); return response; }, }; diff --git a/components/mapbox/app/mapbox.app.ts b/components/mapbox/app/mapbox.app.ts deleted file mode 100644 index a778df2269db4..0000000000000 --- a/components/mapbox/app/mapbox.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "mapbox", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); diff --git a/components/mapbox/common/constants.mjs b/components/mapbox/common/constants.mjs new file mode 100644 index 0000000000000..a1101632447cd --- /dev/null +++ b/components/mapbox/common/constants.mjs @@ -0,0 +1,21 @@ +const TRANSPORTATION_MODES = [ + "driving", + "walking", + "cycling", + "driving-traffic", +]; + +const EXCLUDE_OPTIONS = [ + "motorway", + "toll", + "ferry", + "unpaved", + "cash_only_tolls", + "country_border", + "state_border", +]; + +export default { + TRANSPORTATION_MODES, + EXCLUDE_OPTIONS, +}; diff --git a/components/mapbox/mapbox.app.mjs b/components/mapbox/mapbox.app.mjs index cbcc755c51df1..e81a59eeb479d 100644 --- a/components/mapbox/mapbox.app.mjs +++ b/components/mapbox/mapbox.app.mjs @@ -1,116 +1,21 @@ import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; export default { type: "app", app: "mapbox", - version: "0.0.{{ts}}", propDefinitions: { - // Geocoding Props - address: { - type: "string", - label: "Address", - description: "The address to geocode", - }, - boundingBox: { - type: "string", - label: "Bounding Box", - description: "Optional bounding box in the format minLng,minLat,maxLng,maxLat", - optional: true, - }, - proximity: { - type: "string", - label: "Proximity", - description: "Optional proximity point in the format longitude,latitude", - optional: true, - }, - // Directions Props - startCoordinate: { - type: "string", - label: "Start Coordinate", - description: "The starting point in the format longitude,latitude", - }, - endCoordinate: { - type: "string", - label: "End Coordinate", - description: "The ending point in the format longitude,latitude", - }, - waypoints: { - type: "string[]", - label: "Waypoints", - description: "Optional waypoints as an array of longitude,latitude strings", - optional: true, - }, transportationMode: { type: "string", label: "Transportation Mode", - description: "Optional transportation mode", - options: [ - { - label: "Driving", - value: "driving", - }, - { - label: "Walking", - value: "walking", - }, - { - label: "Cycling", - value: "cycling", - }, - { - label: "Driving Traffic", - value: "driving-traffic", - }, - ], - optional: true, + description: "The mode of transportation", + options: constants.TRANSPORTATION_MODES, }, - routeType: { - type: "string", - label: "Route Type", - description: "Optional route type", - options: [ - { - label: "Fastest", - value: "fastest", - }, - { - label: "Shortest", - value: "shortest", - }, - ], - optional: true, - }, - // Tileset Upload Props - sourceFile: { - type: "string", - label: "Source File", - description: "The source file for the tileset", - }, - tilesetName: { - type: "string", - label: "Tileset Name", - description: "The name of the new tileset", - }, - description: { - type: "string", - label: "Description", - description: "Optional description for the tileset", - optional: true, - }, - privacySettings: { - type: "string", - label: "Privacy Settings", - description: "Optional privacy settings for the tileset", - options: [ - { - label: "Public", - value: "public", - }, - { - label: "Private", - value: "private", - }, - ], + exclude: { + type: "string[]", + label: "Exclude", + description: "Exclude certain road types and custom locations from routing", + options: constants.EXCLUDE_OPTIONS, optional: true, }, }, @@ -118,91 +23,59 @@ export default { _baseUrl() { return "https://api.mapbox.com"; }, - async _makeRequest(opts = {}) { - const { - $ = this, method = "GET", path = "/", headers = {}, params = {}, data, ...otherOpts - } = opts; + _makeRequest({ + $ = this, + path, + params, + ...otherOpts + }) { return axios($, { - method, url: `${this._baseUrl()}${path}`, - headers: { - ...headers, - }, params: { access_token: this.$auth.access_token, ...params, }, - data, + debug: true, ...otherOpts, }); }, - async geocode(opts = {}) { - const { - address, boundingBox, proximity, - } = opts; - const params = { - types: "address", - }; - if (boundingBox) { - params.bbox = boundingBox; - } - if (proximity) { - params.proximity = proximity; - } + geocode(opts = {}) { return this._makeRequest({ - path: `/geocoding/v5/mapbox.places/${encodeURIComponent(address)}.json`, - params, + path: "/search/geocode/v6/forward", + ...opts, }); }, - async getDirections(opts = {}) { - const { - startCoordinate, endCoordinate, waypoints, transportationMode, routeType, - } = opts; - let coordinates = `${startCoordinate};${endCoordinate}`; - if (waypoints && waypoints.length > 0) { - coordinates = `${startCoordinate};${waypoints.join(";")};${endCoordinate}`; - } - const params = {}; - if (transportationMode) { - params.profile = transportationMode; - } - if (routeType) { - params.alternatives = routeType === "fastest" - ? "true" - : "false"; - } + getDirections({ + transportationMode, coordinates, ...opts + }) { return this._makeRequest({ - path: `/directions/v5/mapbox.${transportationMode || "driving"}/${coordinates}`, - params, + path: `/directions/v5/mapbox/${transportationMode}/${coordinates}`, + ...opts, }); }, - async uploadTileset(opts = {}) { - const { - sourceFile, tilesetName, description, privacySettings, - } = opts; - const params = { - tileset: tilesetName, - }; - if (description) { - params.description = description; - } - if (privacySettings) { - params.private = privacySettings === "private" - ? true - : false; - } + createTilesetSource({ + username, id, ...opts + }) { return this._makeRequest({ method: "POST", - path: `/uploads/v1/${encodeURIComponent(this.$auth.username)}`, - params, - data: { - data: sourceFile, - tileset: { - name: tilesetName, - description: description || "", - private: privacySettings === "private", - }, - }, + path: `/tilesets/v1/sources/${username}/${id}`, + ...opts, + }); + }, + validateRecipe(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/tilesets/v1/validateRecipe", + ...opts, + }); + }, + createTileset({ + tilesetId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/tilesets/v1/${tilesetId}`, + ...opts, }); }, }, diff --git a/components/mapbox/package.json b/components/mapbox/package.json index 6adaa9ef9e5f5..680b99cc3f4cb 100644 --- a/components/mapbox/package.json +++ b/components/mapbox/package.json @@ -1,18 +1,19 @@ { "name": "@pipedream/mapbox", - "version": "0.0.3", + "version": "0.1.0", "description": "Pipedream Mapbox Components", - "main": "dist/app/mapbox.app.mjs", + "main": "mapbox.app.mjs", "keywords": [ "pipedream", "mapbox" ], - "files": [ - "dist" - ], "homepage": "https://pipedream.com/apps/mapbox", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3", + "form-data": "^4.0.1" } } From 7c74d6a8d25a5d1941f2323ec39ea25b87676eb2 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 10 Feb 2025 16:20:46 -0500 Subject: [PATCH 3/7] update descriptions --- components/mapbox/actions/create-tileset/create-tileset.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mapbox/actions/create-tileset/create-tileset.mjs b/components/mapbox/actions/create-tileset/create-tileset.mjs index 89d28385439d2..671894cd09222 100644 --- a/components/mapbox/actions/create-tileset/create-tileset.mjs +++ b/components/mapbox/actions/create-tileset/create-tileset.mjs @@ -23,12 +23,12 @@ export default { filePath: { type: "string", label: "File Path", - description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", + description: "The path to a tileset source file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", }, recipe: { type: "object", label: "Recipe", - description: "A recipe that describes how the GeoJSON data you uploaded should be transformed into tiles. For more information on how to create and format recipes, see the ]Recipe reference](https://docs.mapbox.com/mapbox-tiling-service/reference/) and [Recipe examples](https://docs.mapbox.com/mapbox-tiling-service/examples/).", + description: "A recipe that describes how the GeoJSON data you uploaded should be transformed into tiles. A tileset source is raw geographic data formatted as [line-delimited GeoJSON](https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON), or a supported [raster file format](https://docs.mapbox.com/mapbox-tiling-service/raster/supported-file-formats/). For more information on how to create and format recipes, see the ]Recipe reference](https://docs.mapbox.com/mapbox-tiling-service/reference/) and [Recipe examples](https://docs.mapbox.com/mapbox-tiling-service/examples/).", }, description: { type: "string", From 4ff2b3fce0b74775a4a112e9d8fc85bd5de1cebf Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 10 Feb 2025 16:21:08 -0500 Subject: [PATCH 4/7] pnpm-lock.yaml --- pnpm-lock.yaml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20bb7dd5b0d53..f9e425321f58f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3258,8 +3258,7 @@ importers: specifier: ^0.12.7 version: 0.12.7 - components/elastic_cloud: - specifiers: {} + components/elastic_cloud: {} components/elastic_email: {} @@ -4209,8 +4208,7 @@ importers: components/glide: {} - components/globalping: - specifiers: {} + components/globalping: {} components/gloria_ai: dependencies: @@ -6339,8 +6337,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/mailtrap: - specifiers: {} + components/mailtrap: {} components/mailwizz: dependencies: @@ -6376,7 +6373,14 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/mapbox: {} + components/mapbox: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 + form-data: + specifier: ^4.0.1 + version: 4.0.1 components/mapulus: dependencies: @@ -9902,8 +9906,7 @@ importers: components/simplybook_me: {} - components/sinch_messagemedia: - specifiers: {} + components/sinch_messagemedia: {} components/sitecreator_io: dependencies: From 0acc9096895568f1cbf940828fbb32d8bb288e1a Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 10 Feb 2025 16:30:14 -0500 Subject: [PATCH 5/7] remove debug --- components/mapbox/mapbox.app.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/mapbox/mapbox.app.mjs b/components/mapbox/mapbox.app.mjs index e81a59eeb479d..e11265eed2e3f 100644 --- a/components/mapbox/mapbox.app.mjs +++ b/components/mapbox/mapbox.app.mjs @@ -35,7 +35,6 @@ export default { access_token: this.$auth.access_token, ...params, }, - debug: true, ...otherOpts, }); }, From cabd2b8b2c2b0bd3dd4d59911e9d12f917e71877 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 11 Feb 2025 11:18:55 -0500 Subject: [PATCH 6/7] updates per code review --- components/mapbox/actions/create-tileset/create-tileset.mjs | 4 ++-- .../actions/generate-directions/generate-directions.mjs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/mapbox/actions/create-tileset/create-tileset.mjs b/components/mapbox/actions/create-tileset/create-tileset.mjs index 671894cd09222..2cc4423f4172f 100644 --- a/components/mapbox/actions/create-tileset/create-tileset.mjs +++ b/components/mapbox/actions/create-tileset/create-tileset.mjs @@ -18,7 +18,7 @@ export default { tilesetName: { type: "string", label: "Tileset Name", - description: "A unique name for the tileset source to be created. Limited to 32 characters. The only allowed special characters are - and _.", + description: "A unique name for the tileset source to be created. Limited to 32 characters. The only allowed special characters are `-` (hyphen) and `_` (underscore)", }, filePath: { type: "string", @@ -28,7 +28,7 @@ export default { recipe: { type: "object", label: "Recipe", - description: "A recipe that describes how the GeoJSON data you uploaded should be transformed into tiles. A tileset source is raw geographic data formatted as [line-delimited GeoJSON](https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON), or a supported [raster file format](https://docs.mapbox.com/mapbox-tiling-service/raster/supported-file-formats/). For more information on how to create and format recipes, see the ]Recipe reference](https://docs.mapbox.com/mapbox-tiling-service/reference/) and [Recipe examples](https://docs.mapbox.com/mapbox-tiling-service/examples/).", + description: "A recipe that describes how the GeoJSON data you uploaded should be transformed into tiles. A tileset source is raw geographic data formatted as [line-delimited GeoJSON](https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON), or a supported [raster file format](https://docs.mapbox.com/mapbox-tiling-service/raster/supported-file-formats/). For more information on how to create and format recipes, see the [Recipe reference](https://docs.mapbox.com/mapbox-tiling-service/reference/) and [Recipe examples](https://docs.mapbox.com/mapbox-tiling-service/examples/).", }, description: { type: "string", diff --git a/components/mapbox/actions/generate-directions/generate-directions.mjs b/components/mapbox/actions/generate-directions/generate-directions.mjs index 839d4e5e11ef2..4794f736cad62 100644 --- a/components/mapbox/actions/generate-directions/generate-directions.mjs +++ b/components/mapbox/actions/generate-directions/generate-directions.mjs @@ -11,12 +11,12 @@ export default { startCoordinate: { type: "string", label: "Start Coordinate", - description: "The starting point in the format `longitude,latitude`", + description: "The starting point in the format `longitude,latitude`, E.g. `37.835819,-85.244869`", }, endCoordinate: { type: "string", label: "End Coordinate", - description: "The ending point in the format `longitude,latitude`", + description: "The ending point in the format `longitude,latitude`, E.g. `37.835819,-85.244869`", }, transportationMode: { propDefinition: [ @@ -28,6 +28,7 @@ export default { type: "boolean", label: "Steps", description: "Whether to return steps and turn-by-turn instructions (`true`) or not (`false`, default)", + optional: true, }, alternatives: { type: "boolean", From 5b470d43552162a3ab029ff7c612e6bbd80da3c8 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 11 Feb 2025 11:26:48 -0500 Subject: [PATCH 7/7] update coordinate examples --- .../actions/generate-directions/generate-directions.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mapbox/actions/generate-directions/generate-directions.mjs b/components/mapbox/actions/generate-directions/generate-directions.mjs index 4794f736cad62..c332eed59a202 100644 --- a/components/mapbox/actions/generate-directions/generate-directions.mjs +++ b/components/mapbox/actions/generate-directions/generate-directions.mjs @@ -11,12 +11,12 @@ export default { startCoordinate: { type: "string", label: "Start Coordinate", - description: "The starting point in the format `longitude,latitude`, E.g. `37.835819,-85.244869`", + description: "The starting point in the format `longitude,latitude`, E.g. `-85.244869,37.835819`", }, endCoordinate: { type: "string", label: "End Coordinate", - description: "The ending point in the format `longitude,latitude`, E.g. `37.835819,-85.244869`", + description: "The ending point in the format `longitude,latitude`, E.g. `-85.244869,37.835819`", }, transportationMode: { propDefinition: [