diff --git a/components/anchor_browser/anchor_browser.app.mjs b/components/anchor_browser/anchor_browser.app.mjs index 0f7c1724e365a..e56fe6fa9191c 100644 --- a/components/anchor_browser/anchor_browser.app.mjs +++ b/components/anchor_browser/anchor_browser.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/apiary/actions/create-api-project/create-api-project.mjs b/components/apiary/actions/create-api-project/create-api-project.mjs new file mode 100644 index 0000000000000..3a75d6d15089e --- /dev/null +++ b/components/apiary/actions/create-api-project/create-api-project.mjs @@ -0,0 +1,51 @@ +import app from "../../apiary.app.mjs"; + +export default { + key: "apiary-create-api-project", + name: "Create API Project", + description: "Create a new API project. [See the documentation](https://apiary.docs.apiary.io/#reference/blueprint/create-api-project/create-api-project)", + version: "0.0.1", + type: "action", + props: { + app, + type: { + propDefinition: [ + app, + "type", + ], + }, + public: { + propDefinition: [ + app, + "public", + ], + }, + desiredName: { + propDefinition: [ + app, + "desiredName", + ], + }, + code: { + propDefinition: [ + app, + "code", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createApiProject({ + $, + data: { + type: this.type, + public: this.public, + desiredName: this.desiredName, + code: this.code, + }, + }); + + $.export("$summary", `Successfully created a new API Project with the following domain: ${response.domain}`); + + return response; + }, +}; diff --git a/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs b/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs new file mode 100644 index 0000000000000..d6b4b4e0a654d --- /dev/null +++ b/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs @@ -0,0 +1,28 @@ +import app from "../../apiary.app.mjs"; + +export default { + key: "apiary-fetch-blueprint", + name: "Fetch Blueprint", + description: "Fetch an API Blueprint for a particular API. [See the documentation](https://apiary.docs.apiary.io/#reference/blueprint/fetch-blueprint/fetch-blueprint)", + version: "0.0.1", + type: "action", + props: { + app, + apiSubdomain: { + propDefinition: [ + app, + "apiSubdomain", + ], + }, + }, + async run({ $ }) { + const response = await this.app.fetchBlueprint({ + $, + apiSubdomain: this.apiSubdomain, + }); + + $.export("$summary", "Successfully fetched the blueprint for the specified API Subdomain"); + + return response; + }, +}; diff --git a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs new file mode 100644 index 0000000000000..849a281d6eef1 --- /dev/null +++ b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs @@ -0,0 +1,37 @@ +import app from "../../apiary.app.mjs"; + +export default { + key: "apiary-publish-blueprint", + name: "Publish Blueprint", + description: "Publish an API Blueprint for a particular API. [See the documentation](https://apiary.docs.apiary.io/#reference/blueprint/publish-blueprint/publish-blueprint)", + version: "0.0.1", + type: "action", + props: { + app, + apiSubdomain: { + propDefinition: [ + app, + "apiSubdomain", + ], + }, + code: { + propDefinition: [ + app, + "code", + ], + }, + }, + async run({ $ }) { + const response = await this.app.publishBlueprint({ + $, + apiSubdomain: this.apiSubdomain, + data: { + code: this.code, + }, + }); + + $.export("$summary", `Successfully published the blueprint with the subdomain '${this.apiSubdomain}'`); + + return response; + }, +}; diff --git a/components/apiary/apiary.app.mjs b/components/apiary/apiary.app.mjs index 68fa35d300f6a..50e194a6d9a88 100644 --- a/components/apiary/apiary.app.mjs +++ b/components/apiary/apiary.app.mjs @@ -1,11 +1,113 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "apiary", - propDefinitions: {}, + propDefinitions: { + apiSubdomain: { + type: "string", + label: "API Subdomain", + description: "Subdomain of the API", + async options() { + const response = await this.listApis(); + const apisSubdomains = response.apis; + return apisSubdomains.map(({ + apiSubdomain, apiName, + }) => ({ + value: apiSubdomain, + label: apiName, + })); + }, + }, + type: { + type: "string", + label: "API Type", + description: "Type of the API", + options: constants.API_TYPES, + }, + public: { + type: "boolean", + label: "Public", + description: "Defines if the API is public or private", + }, + desiredName: { + type: "string", + label: "Desired Name", + description: "If the desiredName is already taken, a different domain will be generated for your API Project. It can be later changed in the settings", + }, + code: { + type: "string", + label: "Code", + description: "`FORMAT: 1`", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.apiary.io"; + }, + _headers({ + headers = {}, legacy = false, + }) { + return legacy + ? { + ...headers, + Authentication: `Token ${this.$auth.token}`, + } + : { + ...headers, + Authorization: `Bearer ${this.$auth.token}`, + }; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + legacy, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: this._headers({ + headers, + legacy, + }), + }); + }, + async createApiProject(args = {}) { + return this._makeRequest({ + path: "/blueprint/create", + method: "post", + legacy: true, + ...args, + }); + }, + async fetchBlueprint({ + apiSubdomain, ...args + }) { + return this._makeRequest({ + path: `/blueprint/get/${apiSubdomain}`, + legacy: true, + ...args, + }); + }, + async publishBlueprint({ + apiSubdomain, ...args + }) { + return this._makeRequest({ + path: `/blueprint/publish/${apiSubdomain}`, + method: "post", + legacy: true, + ...args, + }); + }, + async listApis(args = {}) { + return this._makeRequest({ + path: "/me/apis", + ...args, + }); }, }, }; diff --git a/components/apiary/common/constants.mjs b/components/apiary/common/constants.mjs new file mode 100644 index 0000000000000..37d6f3d16a52f --- /dev/null +++ b/components/apiary/common/constants.mjs @@ -0,0 +1,6 @@ +export default { + API_TYPES: [ + "personal", + "team", + ], +}; diff --git a/components/apiary/package.json b/components/apiary/package.json index 10ef237db78c2..7cef2e4294e92 100644 --- a/components/apiary/package.json +++ b/components/apiary/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/apiary", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream apiary Components", "main": "apiary.app.mjs", "keywords": [ @@ -8,11 +8,11 @@ "apiary" ], "homepage": "https://pipedream.com/apps/apiary", - "author": "Pipedream support@pipedream.com (https://pipedream.com/)", + "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" }, "dependencies": { - "@pipedream/platform": "^3.0.0" + "@pipedream/platform": "^3.0.3" } } diff --git a/components/cloudentity/cloudentity.app.mjs b/components/cloudentity/cloudentity.app.mjs index 8b5d7da0371df..0a02b61f83628 100644 --- a/components/cloudentity/cloudentity.app.mjs +++ b/components/cloudentity/cloudentity.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/databricks_oauth/databricks_oauth.app.mjs b/components/databricks_oauth/databricks_oauth.app.mjs index 988a11d43cab3..c121ac766d0fd 100644 --- a/components/databricks_oauth/databricks_oauth.app.mjs +++ b/components/databricks_oauth/databricks_oauth.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/griptape/griptape.app.mjs b/components/griptape/griptape.app.mjs index eb43c6973a913..e22b5bb97d96e 100644 --- a/components/griptape/griptape.app.mjs +++ b/components/griptape/griptape.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/ihomefinder/ihomefinder.app.mjs b/components/ihomefinder/ihomefinder.app.mjs index 15f1f4274994b..0884f78348eba 100644 --- a/components/ihomefinder/ihomefinder.app.mjs +++ b/components/ihomefinder/ihomefinder.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/jira_data_center/jira_data_center.app.mjs b/components/jira_data_center/jira_data_center.app.mjs index 514daaaea5896..57e8b68f03abd 100644 --- a/components/jira_data_center/jira_data_center.app.mjs +++ b/components/jira_data_center/jira_data_center.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/koyeb/koyeb.app.mjs b/components/koyeb/koyeb.app.mjs index fc0d65b729436..4ab883be94ae7 100644 --- a/components/koyeb/koyeb.app.mjs +++ b/components/koyeb/koyeb.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e6bc42ad713c..150c0c8740689 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -848,7 +848,7 @@ importers: components/apiary: dependencies: '@pipedream/platform': - specifier: ^3.0.0 + specifier: ^3.0.3 version: 3.0.3 components/apiflash: @@ -6133,8 +6133,7 @@ importers: specifier: ^0.12.5 version: 0.12.5 - components/ihomefinder: - specifiers: {} + components/ihomefinder: {} components/ikas: dependencies: @@ -34004,6 +34003,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: