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..3b8ca4131e72c 100644 --- a/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs +++ b/components/vercel_token_auth/actions/create-deployment/create-deployment.mjs @@ -1,10 +1,11 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; 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,29 +14,28 @@ 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", - }, - repoId: { - type: "string", - label: "Git Source Repository Id", - description: "Id of the source repository", + description: "The target project identifier in which the deployment will be created", + optional: false, + reloadProps: true, }, branch: { type: "string", label: "Branch", description: "Branch of repository to deploy to", - default: "main", - }, - team: { - propDefinition: [ - vercelTokenAuth, - "team", - ], }, public: { type: "boolean", @@ -44,7 +44,35 @@ export default { optional: true, }, }, + async additionalProps(props) { + if (!this.project) { + return {}; + } + 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"; + } + } catch { + 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}`); + } + const repoId = link.repoId; + const data = { name: this.name, project: this.project, @@ -52,7 +80,7 @@ export default { public: this.public, gitSource: { type: "github", - repoId: this.repoId, + repoId, ref: this.branch, }, }; 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..d3a456581a761 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.team, + }), ], }, 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..9474844f7d640 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.team, + }), ], }, state: { @@ -63,6 +72,7 @@ export default { }, async processEvent(max) { const params = { + teamId: this.team, 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..6da875a429ffb 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,17 @@ export default { } return allResults; }, - async listProjects(max, $) { + async getProject(projectId, $) { + const config = { + endpoint: `v9/projects/${projectId}`, + }; + return this.makeRequest(config, $); + }, + async listProjects(params, max, $) { const config = { method: "GET", - endpoint: "v8/projects", + endpoint: "v9/projects", + params, }; return this.paginate("projects", config, max, $); }, 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: