From 8ffb26b0ab0147f7d38c96c43f6e111738d00e68 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 27 Jan 2025 14:10:22 -0500 Subject: [PATCH 1/6] require team prop --- .../cancel-deployment/cancel-deployment.mjs | 19 ++++++----- .../create-deployment/create-deployment.mjs | 34 ++++++++++++++----- .../list-deployments/list-deployments.mjs | 15 ++++---- components/vercel_token_auth/package.json | 4 +-- .../sources/new-deployment/new-deployment.mjs | 12 ++++++- .../vercel_token_auth.app.mjs | 27 +++++++++------ 6 files changed, 74 insertions(+), 37 deletions(-) diff --git a/components/vercel_token_auth/actions/cancel-deployment/cancel-deployment.mjs b/components/vercel_token_auth/actions/cancel-deployment/cancel-deployment.mjs index 2b7b8641e07bf..b93afcab43215 100644 --- a/components/vercel_token_auth/actions/cancel-deployment/cancel-deployment.mjs +++ b/components/vercel_token_auth/actions/cancel-deployment/cancel-deployment.mjs @@ -3,24 +3,25 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs"; export default { key: "vercel_token_auth-cancel-deployment", name: "Cancel Deployment", - description: "Cancel a deployment which is currently building. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/cancel-a-deployment)", - version: "0.0.3", + description: "Cancel a deployment which is currently building. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#cancel-a-deployment)", + version: "0.0.4", type: "action", props: { vercelTokenAuth, - deployment: { + team: { propDefinition: [ vercelTokenAuth, - "deployment", - () => ({ - state: "BUILDING", - }), + "team", ], }, - team: { + deployment: { propDefinition: [ vercelTokenAuth, - "team", + "deployment", + (c) => ({ + teamId: c.team, + state: "BUILDING", + }), ], }, }, diff --git a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs index fb8bd8f355039..79612f3584cf4 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -3,8 +3,8 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs"; export default { key: "vercel_token_auth-create-deployment", name: "Create Deployment", - description: "Create a new deployment from a GitHub repository. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/create-a-new-deployment)", - version: "0.0.3", + description: "Create a new deployment from a GitHub repository. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#create-a-new-deployment)", + version: "0.0.4", type: "action", props: { vercelTokenAuth, @@ -13,10 +13,19 @@ export default { label: "Name", description: "A string with the project name used in the deployment URL", }, + team: { + propDefinition: [ + vercelTokenAuth, + "team", + ], + }, project: { propDefinition: [ vercelTokenAuth, "project", + (c) => ({ + teamId: c.team, + }), ], description: "The target project identifier in which the deployment will be created. When defined, this parameter overrides name", }, @@ -31,12 +40,6 @@ export default { description: "Branch of repository to deploy to", default: "main", }, - team: { - propDefinition: [ - vercelTokenAuth, - "team", - ], - }, public: { type: "boolean", label: "Public", @@ -56,6 +59,21 @@ export default { ref: this.branch, }, }; + if (!this.project) { + data.projectSettings = { + buildCommand: null, + commandForIgnoringBuildStep: null, + devCommand: null, + framework: null, + installCommand: null, + nodeVersion: "22.x", + outputDirectory: null, + rootDirectory: null, + serverlessFunctionRegion: null, + skipGitConnectDuringLink: true, + sourceFilesOutsideRootDirectory: true, + }; + } const res = await this.vercelTokenAuth.createDeployment(data, $); $.export("$summary", "Successfully created new deployment"); return res; diff --git a/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs b/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs index 292025bbefae2..09428d2757dae 100644 --- a/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs +++ b/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs @@ -3,21 +3,24 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs"; export default { key: "vercel_token_auth-list-deployments", name: "List Deployments", - description: "List deployments under the account corresponding to the API token. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/list-deployments)", - version: "0.0.3", + description: "List deployments under the account corresponding to the API token. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#list-deployments)", + version: "0.0.4", type: "action", props: { vercelTokenAuth, - project: { + team: { propDefinition: [ vercelTokenAuth, - "project", + "team", ], }, - team: { + project: { propDefinition: [ vercelTokenAuth, - "team", + "project", + (c) => ({ + teamId: c.teamId, + }), ], }, state: { diff --git a/components/vercel_token_auth/package.json b/components/vercel_token_auth/package.json index cfe46a8e5af47..4902eddc8b216 100644 --- a/components/vercel_token_auth/package.json +++ b/components/vercel_token_auth/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/vercel_token_auth", - "version": "0.0.4", + "version": "0.0.5", "description": "Pipedream Vercel (token-based auth) Components", "main": "vercel_token_auth.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.2.0" + "@pipedream/platform": "^3.0.3" } } diff --git a/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs b/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs index a5acebd783e97..c26b6d93e47a5 100644 --- a/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs +++ b/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs @@ -5,7 +5,7 @@ export default { key: "vercel_token_auth-new-deployment", name: "New Deployment", description: "Emit new event when a deployment is created", - version: "0.0.3", + version: "0.0.4", type: "source", dedupe: "unique", props: { @@ -17,10 +17,19 @@ export default { intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, }, }, + team: { + propDefinition: [ + vercelTokenAuth, + "team", + ], + }, project: { propDefinition: [ vercelTokenAuth, "project", + (c) => ({ + teamId: c.teamId, + }), ], }, state: { @@ -63,6 +72,7 @@ export default { }, async processEvent(max) { const params = { + teamId: this.teamId, projectId: this.project, state: this.state, }; diff --git a/components/vercel_token_auth/vercel_token_auth.app.mjs b/components/vercel_token_auth/vercel_token_auth.app.mjs index 875016b98eb62..56c65d13d1806 100644 --- a/components/vercel_token_auth/vercel_token_auth.app.mjs +++ b/components/vercel_token_auth/vercel_token_auth.app.mjs @@ -10,8 +10,10 @@ export default { label: "Project", description: "Filter deployments from the given projectId", optional: true, - async options() { - const projects = await this.listProjects(); + async options({ teamId }) { + const projects = await this.listProjects({ + teamId, + }); return projects?.map((project) => ({ label: project.name, value: project.id, @@ -22,12 +24,15 @@ export default { type: "string", label: "Deployment", description: "Select the deployment to cancel", - async options({ state }) { - const params = state - ? { - state, - } - : {}; + async options({ + teamId, state, + }) { + const params = { + teamId, + }; + if (state) { + params.state = state; + } const deployments = await this.listDeployments(params); return deployments?.map((deployment) => ({ label: deployment.name, @@ -39,7 +44,6 @@ export default { type: "string", label: "Team", description: "The Team identifier or slug to perform the request on behalf of", - optional: true, async options() { try { const teams = await this.listTeams(); @@ -111,10 +115,11 @@ export default { } return allResults; }, - async listProjects(max, $) { + async listProjects(params, max, $) { const config = { method: "GET", - endpoint: "v8/projects", + endpoint: "v9/projects", + params, }; return this.paginate("projects", config, max, $); }, From 104786fae23651efb6df5bafadde7395478c7fbf Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 27 Jan 2025 14:12:33 -0500 Subject: [PATCH 2/6] pnpm-lock.yaml --- pnpm-lock.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 392a4749629d5..d33758e59072d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11466,8 +11466,8 @@ importers: components/vercel_token_auth: dependencies: '@pipedream/platform': - specifier: ^1.2.0 - version: 1.6.6 + specifier: ^3.0.3 + version: 3.0.3 components/verdict_as_a_service: dependencies: From 1fb00894631108503aa7af2537e8b43818bc1e25 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 27 Jan 2025 14:31:33 -0500 Subject: [PATCH 3/6] updates --- .../actions/create-deployment/create-deployment.mjs | 2 +- .../actions/list-deployments/list-deployments.mjs | 2 +- .../sources/new-deployment/new-deployment.mjs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs index 79612f3584cf4..c753016927421 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -59,7 +59,7 @@ export default { ref: this.branch, }, }; - if (!this.project) { + if (!this.project) { // projectSettings required if project is not specified data.projectSettings = { buildCommand: null, commandForIgnoringBuildStep: null, diff --git a/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs b/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs index 09428d2757dae..d3a456581a761 100644 --- a/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs +++ b/components/vercel_token_auth/actions/list-deployments/list-deployments.mjs @@ -19,7 +19,7 @@ export default { vercelTokenAuth, "project", (c) => ({ - teamId: c.teamId, + teamId: c.team, }), ], }, diff --git a/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs b/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs index c26b6d93e47a5..9474844f7d640 100644 --- a/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs +++ b/components/vercel_token_auth/sources/new-deployment/new-deployment.mjs @@ -28,7 +28,7 @@ export default { vercelTokenAuth, "project", (c) => ({ - teamId: c.teamId, + teamId: c.team, }), ], }, @@ -72,7 +72,7 @@ export default { }, async processEvent(max) { const params = { - teamId: this.teamId, + teamId: this.team, projectId: this.project, state: this.state, }; From 7a8480deacac9c8fceaafa173f008498aca98d6f Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 3 Feb 2025 17:28:32 -0500 Subject: [PATCH 4/6] get repoId from project --- .../create-deployment/create-deployment.mjs | 64 +++++++++++-------- .../vercel_token_auth.app.mjs | 6 ++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs index c753016927421..c5e1b02c8732a 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -1,4 +1,5 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "vercel_token_auth-create-deployment", @@ -27,18 +28,9 @@ export default { teamId: c.team, }), ], - description: "The target project identifier in which the deployment will be created. When defined, this parameter overrides name", - }, - repoId: { - type: "string", - label: "Git Source Repository Id", - description: "Id of the source repository", - }, - branch: { - type: "string", - label: "Branch", - description: "Branch of repository to deploy to", - default: "main", + description: "The target project identifier in which the deployment will be created", + optional: false, + reloadProps: true, }, public: { type: "boolean", @@ -47,7 +39,38 @@ export default { optional: true, }, }, + async additionalProps() { + const props = {}; + + if (!this.project) { + return props; + } + + props.branch = { + type: "string", + label: "Branch", + description: "Branch of repository to deploy to", + default: "main", + }; + + try { + const { link } = await this.vercelTokenAuth.getProject(this.project); + if (link) { + props.branch.description = `Branch of \`${link.repo}\` repository to deploye to`; + props.branch.default = link?.productionBranch || "main"; + } + return props; + } catch { + return props; + } + }, async run({ $ }) { + const { link } = await this.vercelTokenAuth.getProject(this.project, $); + if (!link?.repoId) { + throw new ConfigurationError(`No linked repository found for project with ID: ${this.project}`); + } + const repoId = link.repoId; + const data = { name: this.name, project: this.project, @@ -55,25 +78,10 @@ export default { public: this.public, gitSource: { type: "github", - repoId: this.repoId, + repoId, ref: this.branch, }, }; - if (!this.project) { // projectSettings required if project is not specified - data.projectSettings = { - buildCommand: null, - commandForIgnoringBuildStep: null, - devCommand: null, - framework: null, - installCommand: null, - nodeVersion: "22.x", - outputDirectory: null, - rootDirectory: null, - serverlessFunctionRegion: null, - skipGitConnectDuringLink: true, - sourceFilesOutsideRootDirectory: true, - }; - } const res = await this.vercelTokenAuth.createDeployment(data, $); $.export("$summary", "Successfully created new deployment"); return res; diff --git a/components/vercel_token_auth/vercel_token_auth.app.mjs b/components/vercel_token_auth/vercel_token_auth.app.mjs index 56c65d13d1806..6da875a429ffb 100644 --- a/components/vercel_token_auth/vercel_token_auth.app.mjs +++ b/components/vercel_token_auth/vercel_token_auth.app.mjs @@ -115,6 +115,12 @@ export default { } return allResults; }, + async getProject(projectId, $) { + const config = { + endpoint: `v9/projects/${projectId}`, + }; + return this.makeRequest(config, $); + }, async listProjects(params, max, $) { const config = { method: "GET", From 0765fba7e8cd78518bff6599da675395273a90bf Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 3 Feb 2025 17:35:01 -0500 Subject: [PATCH 5/6] fix typo --- .../actions/create-deployment/create-deployment.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs index c5e1b02c8732a..e5c42a5d6e117 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -56,7 +56,7 @@ export default { try { const { link } = await this.vercelTokenAuth.getProject(this.project); if (link) { - props.branch.description = `Branch of \`${link.repo}\` repository to deploye to`; + props.branch.description = `Branch of \`${link.repo}\` repository to deploy to`; props.branch.default = link?.productionBranch || "main"; } return props; From 35fe2a77d53b889b29528a1314292f051608049a Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 4 Feb 2025 10:55:45 -0500 Subject: [PATCH 6/6] update additionalProps --- .../create-deployment/create-deployment.mjs | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs index e5c42a5d6e117..3b8ca4131e72c 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -32,6 +32,11 @@ export default { optional: false, reloadProps: true, }, + branch: { + type: "string", + label: "Branch", + description: "Branch of repository to deploy to", + }, public: { type: "boolean", label: "Public", @@ -39,32 +44,29 @@ export default { optional: true, }, }, - async additionalProps() { - const props = {}; - + async additionalProps(props) { if (!this.project) { - return props; + return {}; } - - props.branch = { - type: "string", - label: "Branch", - description: "Branch of repository to deploy to", - default: "main", - }; - try { const { link } = await this.vercelTokenAuth.getProject(this.project); if (link) { props.branch.description = `Branch of \`${link.repo}\` repository to deploy to`; props.branch.default = link?.productionBranch || "main"; + } else { + props.branch.default = "main"; } - return props; } catch { - return props; + props.branch.default = "main"; + return {}; } + return {}; }, async run({ $ }) { + if (!this.branch) { + throw new ConfigurationError("Branch prop is required"); + } + const { link } = await this.vercelTokenAuth.getProject(this.project, $); if (!link?.repoId) { throw new ConfigurationError(`No linked repository found for project with ID: ${this.project}`);