Skip to content

Commit d4fe2e1

Browse files
authored
[BUG] Vercel project prop (#15418)
* require team prop * pnpm-lock.yaml * updates * get repoId from project * fix typo * update additionalProps
1 parent ea6d76b commit d4fe2e1

File tree

7 files changed

+100
-47
lines changed

7 files changed

+100
-47
lines changed

components/vercel_token_auth/actions/cancel-deployment/cancel-deployment.mjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs";
33
export default {
44
key: "vercel_token_auth-cancel-deployment",
55
name: "Cancel Deployment",
6-
description: "Cancel a deployment which is currently building. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/cancel-a-deployment)",
7-
version: "0.0.3",
6+
description: "Cancel a deployment which is currently building. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#cancel-a-deployment)",
7+
version: "0.0.4",
88
type: "action",
99
props: {
1010
vercelTokenAuth,
11-
deployment: {
11+
team: {
1212
propDefinition: [
1313
vercelTokenAuth,
14-
"deployment",
15-
() => ({
16-
state: "BUILDING",
17-
}),
14+
"team",
1815
],
1916
},
20-
team: {
17+
deployment: {
2118
propDefinition: [
2219
vercelTokenAuth,
23-
"team",
20+
"deployment",
21+
(c) => ({
22+
teamId: c.team,
23+
state: "BUILDING",
24+
}),
2425
],
2526
},
2627
},

components/vercel_token_auth/actions/create-deployment/create-deployment.mjs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import vercelTokenAuth from "../../vercel_token_auth.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
23

34
export default {
45
key: "vercel_token_auth-create-deployment",
56
name: "Create Deployment",
6-
description: "Create a new deployment from a GitHub repository. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/create-a-new-deployment)",
7-
version: "0.0.3",
7+
description: "Create a new deployment from a GitHub repository. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#create-a-new-deployment)",
8+
version: "0.0.4",
89
type: "action",
910
props: {
1011
vercelTokenAuth,
@@ -13,29 +14,28 @@ export default {
1314
label: "Name",
1415
description: "A string with the project name used in the deployment URL",
1516
},
17+
team: {
18+
propDefinition: [
19+
vercelTokenAuth,
20+
"team",
21+
],
22+
},
1623
project: {
1724
propDefinition: [
1825
vercelTokenAuth,
1926
"project",
27+
(c) => ({
28+
teamId: c.team,
29+
}),
2030
],
21-
description: "The target project identifier in which the deployment will be created. When defined, this parameter overrides name",
22-
},
23-
repoId: {
24-
type: "string",
25-
label: "Git Source Repository Id",
26-
description: "Id of the source repository",
31+
description: "The target project identifier in which the deployment will be created",
32+
optional: false,
33+
reloadProps: true,
2734
},
2835
branch: {
2936
type: "string",
3037
label: "Branch",
3138
description: "Branch of repository to deploy to",
32-
default: "main",
33-
},
34-
team: {
35-
propDefinition: [
36-
vercelTokenAuth,
37-
"team",
38-
],
3939
},
4040
public: {
4141
type: "boolean",
@@ -44,15 +44,43 @@ export default {
4444
optional: true,
4545
},
4646
},
47+
async additionalProps(props) {
48+
if (!this.project) {
49+
return {};
50+
}
51+
try {
52+
const { link } = await this.vercelTokenAuth.getProject(this.project);
53+
if (link) {
54+
props.branch.description = `Branch of \`${link.repo}\` repository to deploy to`;
55+
props.branch.default = link?.productionBranch || "main";
56+
} else {
57+
props.branch.default = "main";
58+
}
59+
} catch {
60+
props.branch.default = "main";
61+
return {};
62+
}
63+
return {};
64+
},
4765
async run({ $ }) {
66+
if (!this.branch) {
67+
throw new ConfigurationError("Branch prop is required");
68+
}
69+
70+
const { link } = await this.vercelTokenAuth.getProject(this.project, $);
71+
if (!link?.repoId) {
72+
throw new ConfigurationError(`No linked repository found for project with ID: ${this.project}`);
73+
}
74+
const repoId = link.repoId;
75+
4876
const data = {
4977
name: this.name,
5078
project: this.project,
5179
teamId: this.team,
5280
public: this.public,
5381
gitSource: {
5482
type: "github",
55-
repoId: this.repoId,
83+
repoId,
5684
ref: this.branch,
5785
},
5886
};

components/vercel_token_auth/actions/list-deployments/list-deployments.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@ import vercelTokenAuth from "../../vercel_token_auth.app.mjs";
33
export default {
44
key: "vercel_token_auth-list-deployments",
55
name: "List Deployments",
6-
description: "List deployments under the account corresponding to the API token. [See the docs](https://vercel.com/docs/rest-api#endpoints/deployments/list-deployments)",
7-
version: "0.0.3",
6+
description: "List deployments under the account corresponding to the API token. [See the documentation](https://vercel.com/docs/rest-api/endpoints/deployments#list-deployments)",
7+
version: "0.0.4",
88
type: "action",
99
props: {
1010
vercelTokenAuth,
11-
project: {
11+
team: {
1212
propDefinition: [
1313
vercelTokenAuth,
14-
"project",
14+
"team",
1515
],
1616
},
17-
team: {
17+
project: {
1818
propDefinition: [
1919
vercelTokenAuth,
20-
"team",
20+
"project",
21+
(c) => ({
22+
teamId: c.team,
23+
}),
2124
],
2225
},
2326
state: {

components/vercel_token_auth/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/vercel_token_auth",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Pipedream Vercel (token-based auth) Components",
55
"main": "vercel_token_auth.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.2.0"
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}

components/vercel_token_auth/sources/new-deployment/new-deployment.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "vercel_token_auth-new-deployment",
66
name: "New Deployment",
77
description: "Emit new event when a deployment is created",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "source",
1010
dedupe: "unique",
1111
props: {
@@ -17,10 +17,19 @@ export default {
1717
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
1818
},
1919
},
20+
team: {
21+
propDefinition: [
22+
vercelTokenAuth,
23+
"team",
24+
],
25+
},
2026
project: {
2127
propDefinition: [
2228
vercelTokenAuth,
2329
"project",
30+
(c) => ({
31+
teamId: c.team,
32+
}),
2433
],
2534
},
2635
state: {
@@ -63,6 +72,7 @@ export default {
6372
},
6473
async processEvent(max) {
6574
const params = {
75+
teamId: this.team,
6676
projectId: this.project,
6777
state: this.state,
6878
};

components/vercel_token_auth/vercel_token_auth.app.mjs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ export default {
1010
label: "Project",
1111
description: "Filter deployments from the given projectId",
1212
optional: true,
13-
async options() {
14-
const projects = await this.listProjects();
13+
async options({ teamId }) {
14+
const projects = await this.listProjects({
15+
teamId,
16+
});
1517
return projects?.map((project) => ({
1618
label: project.name,
1719
value: project.id,
@@ -22,12 +24,15 @@ export default {
2224
type: "string",
2325
label: "Deployment",
2426
description: "Select the deployment to cancel",
25-
async options({ state }) {
26-
const params = state
27-
? {
28-
state,
29-
}
30-
: {};
27+
async options({
28+
teamId, state,
29+
}) {
30+
const params = {
31+
teamId,
32+
};
33+
if (state) {
34+
params.state = state;
35+
}
3136
const deployments = await this.listDeployments(params);
3237
return deployments?.map((deployment) => ({
3338
label: deployment.name,
@@ -39,7 +44,6 @@ export default {
3944
type: "string",
4045
label: "Team",
4146
description: "The Team identifier or slug to perform the request on behalf of",
42-
optional: true,
4347
async options() {
4448
try {
4549
const teams = await this.listTeams();
@@ -111,10 +115,17 @@ export default {
111115
}
112116
return allResults;
113117
},
114-
async listProjects(max, $) {
118+
async getProject(projectId, $) {
119+
const config = {
120+
endpoint: `v9/projects/${projectId}`,
121+
};
122+
return this.makeRequest(config, $);
123+
},
124+
async listProjects(params, max, $) {
115125
const config = {
116126
method: "GET",
117-
endpoint: "v8/projects",
127+
endpoint: "v9/projects",
128+
params,
118129
};
119130
return this.paginate("projects", config, max, $);
120131
},

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)