From b4b1df6353540d6399debc6cb596032b3f3d9bc5 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Fri, 29 Nov 2024 15:10:02 -0300 Subject: [PATCH 1/7] Added actions --- .../create-api-project/create-api-project.mjs | 52 +++++++++++ .../fetch-blueprint/fetch-blueprint.mjs | 29 ++++++ .../publish-blueprint/publish-blueprint.mjs | 29 ++++++ components/apiary/apiary.app.mjs | 92 ++++++++++++++++++- components/apiary/common/contants.mjs | 6 ++ components/apiary/package.json | 18 ++++ 6 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 components/apiary/actions/create-api-project/create-api-project.mjs create mode 100644 components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs create mode 100644 components/apiary/actions/publish-blueprint/publish-blueprint.mjs create mode 100644 components/apiary/common/contants.mjs create mode 100644 components/apiary/package.json 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..fd98e44fbb254 --- /dev/null +++ b/components/apiary/actions/create-api-project/create-api-project.mjs @@ -0,0 +1,52 @@ +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..08ba9292205a5 --- /dev/null +++ b/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs @@ -0,0 +1,29 @@ +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..bb6d48b35c97d --- /dev/null +++ b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs @@ -0,0 +1,29 @@ +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", + ], + }, + }, + + async run({ $ }) { + const response = await this.app.publishBlueprint({ + $, + apiSubdomain: this.apiSubdomain, + }); + + $.export("$summary", `Successfully published the blueprint with the subdomain '${this.apisSubdomain}'`); + + return response; + }, +}; diff --git a/components/apiary/apiary.app.mjs b/components/apiary/apiary.app.mjs index 68fa35d300f6a..e5c55feaea5a0 100644 --- a/components/apiary/apiary.app.mjs +++ b/components/apiary/apiary.app.mjs @@ -1,11 +1,95 @@ +import { axios } from "@pipedream/platform"; +import contants from "./common/contants.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: "Type of the API", + description: "Name of the organization", + options: contants.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"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.token}`, + }, + }); + }, + async createApiProject(args = {}) { + return this._makeRequest({ + path: "/blueprint/create", + method: "post", + ...args, + }); + }, + async fetchBlueprint({ + apiSubdomain, ...args + }) { + return this._makeRequest({ + path: `/blueprint/get/${apiSubdomain}`, + ...args, + }); + }, + async publishBlueprint({ + apiSubdomain, ...args + }) { + return this._makeRequest({ + path: `/blueprint/get/${apiSubdomain}`, + ...args, + }); + }, + async listApis(args = {}) { + return this._makeRequest({ + path: "/me/apis", + ...args, + }); }, }, }; diff --git a/components/apiary/common/contants.mjs b/components/apiary/common/contants.mjs new file mode 100644 index 0000000000000..37d6f3d16a52f --- /dev/null +++ b/components/apiary/common/contants.mjs @@ -0,0 +1,6 @@ +export default { + API_TYPES: [ + "personal", + "team", + ], +}; diff --git a/components/apiary/package.json b/components/apiary/package.json new file mode 100644 index 0000000000000..33991560f0554 --- /dev/null +++ b/components/apiary/package.json @@ -0,0 +1,18 @@ +{ + "name": "@pipedream/apiary", + "version": "0.0.1", + "description": "Pipedream Chat Data Components", + "main": "apiary.app.mjs", + "keywords": [ + "pipedream", + "apiary" + ], + "homepage": "https://pipedream.com/apps/apiary", + "author": "Pipedream (https://pipedream.com/)", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" + } +} \ No newline at end of file From 0e7e7d0debc446e450fe9966fa756efc92ad8485 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Fri, 29 Nov 2024 15:18:23 -0300 Subject: [PATCH 2/7] Added actions --- components/apiary/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/apiary/package.json b/components/apiary/package.json index 33991560f0554..b764e202d6d62 100644 --- a/components/apiary/package.json +++ b/components/apiary/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/apiary", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Chat Data Components", "main": "apiary.app.mjs", "keywords": [ @@ -15,4 +15,4 @@ "dependencies": { "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} From 1b7ff1b4a51b50be2d1d70db84067791e10fb398 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Fri, 29 Nov 2024 15:18:23 -0300 Subject: [PATCH 3/7] Added actions --- components/apiary/package.json | 4 ++-- pnpm-lock.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/apiary/package.json b/components/apiary/package.json index 33991560f0554..b764e202d6d62 100644 --- a/components/apiary/package.json +++ b/components/apiary/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/apiary", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Chat Data Components", "main": "apiary.app.mjs", "keywords": [ @@ -15,4 +15,4 @@ "dependencies": { "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a94d167bd3597..75e44347c8c7b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -706,6 +706,12 @@ importers: components/api_void: {} + components/apiary: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 + components/apify: dependencies: '@pipedream/platform': From b595b43ca26ebefb5fef00da2b62a4d7e7b16825 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 3 Dec 2024 15:42:26 -0300 Subject: [PATCH 4/7] Fixed requested changes --- components/apiary/apiary.app.mjs | 10 +++++----- .../apiary/common/{contants.mjs => constants.mjs} | 0 2 files changed, 5 insertions(+), 5 deletions(-) rename components/apiary/common/{contants.mjs => constants.mjs} (100%) diff --git a/components/apiary/apiary.app.mjs b/components/apiary/apiary.app.mjs index e5c55feaea5a0..ccc369e23a24b 100644 --- a/components/apiary/apiary.app.mjs +++ b/components/apiary/apiary.app.mjs @@ -1,5 +1,5 @@ import { axios } from "@pipedream/platform"; -import contants from "./common/contants.mjs"; +import constants from "./common/constants.mjs"; export default { type: "app", @@ -22,9 +22,9 @@ export default { }, type: { type: "string", - label: "Type of the API", - description: "Name of the organization", - options: contants.API_TYPES, + label: "API Type", + description: "Type of the API", + options: constants.API_TYPES, }, public: { type: "boolean", @@ -81,7 +81,7 @@ export default { apiSubdomain, ...args }) { return this._makeRequest({ - path: `/blueprint/get/${apiSubdomain}`, + path: `/blueprint/publish/${apiSubdomain}`, ...args, }); }, diff --git a/components/apiary/common/contants.mjs b/components/apiary/common/constants.mjs similarity index 100% rename from components/apiary/common/contants.mjs rename to components/apiary/common/constants.mjs From a48c1c61d301116f8900285fff57d44e0597c062 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 3 Dec 2024 16:14:54 -0300 Subject: [PATCH 5/7] Update components/apiary/actions/publish-blueprint/publish-blueprint.mjs Co-authored-by: michelle0927 --- .../apiary/actions/publish-blueprint/publish-blueprint.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs index bb6d48b35c97d..83e3406db9529 100644 --- a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs +++ b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs @@ -22,7 +22,8 @@ export default { apiSubdomain: this.apiSubdomain, }); - $.export("$summary", `Successfully published the blueprint with the subdomain '${this.apisSubdomain}'`); + $.export("$summary", `Successfully published the blueprint with the subdomain '${this.apiSubdomain}'`); + return response; }, From f6052d28ac23be7ce26b94606cbf0d53cee0f72e Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 5 Dec 2024 20:38:50 -0300 Subject: [PATCH 6/7] Fixed requested changes --- .../apiary/actions/publish-blueprint/publish-blueprint.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs index 83e3406db9529..b43b675563e48 100644 --- a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs +++ b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs @@ -24,7 +24,6 @@ export default { $.export("$summary", `Successfully published the blueprint with the subdomain '${this.apiSubdomain}'`); - return response; }, }; From 8268a784bd0bc93c05ef565cce965d59dd0dbe83 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 24 Feb 2025 14:52:07 -0500 Subject: [PATCH 7/7] fixes --- .../create-api-project/create-api-project.mjs | 1 - .../fetch-blueprint/fetch-blueprint.mjs | 1 - .../publish-blueprint/publish-blueprint.mjs | 10 ++++++- components/apiary/apiary.app.mjs | 26 ++++++++++++++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/apiary/actions/create-api-project/create-api-project.mjs b/components/apiary/actions/create-api-project/create-api-project.mjs index fd98e44fbb254..3a75d6d15089e 100644 --- a/components/apiary/actions/create-api-project/create-api-project.mjs +++ b/components/apiary/actions/create-api-project/create-api-project.mjs @@ -33,7 +33,6 @@ export default { ], }, }, - async run({ $ }) { const response = await this.app.createApiProject({ $, diff --git a/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs b/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs index 08ba9292205a5..d6b4b4e0a654d 100644 --- a/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs +++ b/components/apiary/actions/fetch-blueprint/fetch-blueprint.mjs @@ -15,7 +15,6 @@ export default { ], }, }, - async run({ $ }) { const response = await this.app.fetchBlueprint({ $, diff --git a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs index b43b675563e48..849a281d6eef1 100644 --- a/components/apiary/actions/publish-blueprint/publish-blueprint.mjs +++ b/components/apiary/actions/publish-blueprint/publish-blueprint.mjs @@ -14,12 +14,20 @@ export default { "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}'`); diff --git a/components/apiary/apiary.app.mjs b/components/apiary/apiary.app.mjs index ccc369e23a24b..50e194a6d9a88 100644 --- a/components/apiary/apiary.app.mjs +++ b/components/apiary/apiary.app.mjs @@ -46,26 +46,41 @@ export default { _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: { - ...headers, - Authorization: `Bearer ${this.$auth.token}`, - }, + headers: this._headers({ + headers, + legacy, + }), }); }, async createApiProject(args = {}) { return this._makeRequest({ path: "/blueprint/create", method: "post", + legacy: true, ...args, }); }, @@ -74,6 +89,7 @@ export default { }) { return this._makeRequest({ path: `/blueprint/get/${apiSubdomain}`, + legacy: true, ...args, }); }, @@ -82,6 +98,8 @@ export default { }) { return this._makeRequest({ path: `/blueprint/publish/${apiSubdomain}`, + method: "post", + legacy: true, ...args, }); },