Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusing Gitlab components for Developer App #11603

Merged
merged 29 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fe3bdb7
New app/package
GTFalcao Apr 20, 2024
1ffc938
Creating actions reusing Gitlab actions
GTFalcao Apr 20, 2024
f1022d6
Package update
GTFalcao Apr 20, 2024
723b691
pnpm
GTFalcao Apr 20, 2024
8cf54e5
Mapping propDefinitions to new app
GTFalcao Apr 21, 2024
21fc2d7
Adjusting actions' propDefinitions
GTFalcao Apr 21, 2024
ec7552d
Adjusting sources to use mapped propDefinitions
GTFalcao Apr 21, 2024
6900332
Removing unused file
GTFalcao Apr 21, 2024
7c1e6d9
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 23, 2024
2762c39
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 23, 2024
ca6be9e
Fixing import error for sources
GTFalcao Apr 23, 2024
e933e9b
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 24, 2024
07be7c3
Updating list projects
GTFalcao Apr 24, 2024
19b5358
Gitlab version bumps
GTFalcao Apr 24, 2024
915b5bc
package newline
GTFalcao Apr 24, 2024
0abac63
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 25, 2024
e6c2d0b
Description update
GTFalcao Apr 25, 2024
a0dbf27
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 25, 2024
6de10ea
Making username required
GTFalcao Apr 25, 2024
6aa908f
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 29, 2024
f8a946e
Fix labels and parentId optional
GTFalcao Apr 29, 2024
b075f7d
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao Apr 30, 2024
df7054c
Fixing 'new milstone'
GTFalcao Apr 30, 2024
55bb59d
Adjusting 'new review request'
GTFalcao Apr 30, 2024
8579c06
Update issue: fixing labels on request
GTFalcao Apr 30, 2024
4584668
Replacing node-fetch with axios
GTFalcao Apr 30, 2024
45ca5d0
Merge branch 'master' into 11547-gitlab-developer-app-components
GTFalcao May 3, 2024
816ddb8
Splittin group path and group id
GTFalcao May 3, 2024
ed11902
Adding error treatment for source
GTFalcao May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/gitlab/actions/create-branch/create-branch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gitlab-create-branch",
name: "Create Branch",
description: "Create a new branch in the repository. [See the documentation](https://docs.gitlab.com/ee/api/branches.html#create-repository-branch)",
version: "0.3.1",
version: "0.3.2",
type: "action",
props: {
gitlab,
Expand Down
17 changes: 9 additions & 8 deletions components/gitlab/actions/create-epic/create-epic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@ export default {
key: "gitlab-create-epic",
name: "Create Epic",
description: "Creates a new epic. [See the documentation](https://docs.gitlab.com/ee/api/epics.html#new-epic)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
gitlab,
groupPath: {
groupId: {
propDefinition: [
gitlab,
"groupPath",
"groupId",
],
},
parent_id: {
propDefinition: [
gitlab,
"epicIid",
(c) => ({
groupId: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
label: "Parent ID",
optional: true,
},
title: {
propDefinition: [
Expand All @@ -36,8 +37,8 @@ export default {
propDefinition: [
gitlab,
"groupLabels",
(c) => ({
groupId: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
},
Expand Down Expand Up @@ -115,7 +116,7 @@ export default {
]));
data.labels = data.labels?.join();

const response = await this.gitlab.createEpic(this.groupPath, {
const response = await this.gitlab.createEpic(this.groupId, {
data,
});
$.export("$summary", `Created epic ${this.title}`);
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/actions/create-issue/create-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gitlab-create-issue",
name: "Create issue",
description: "Creates a new issue. [See the documentation](https://docs.gitlab.com/ee/api/issues.html#new-issue)",
version: "0.2.1",
version: "0.2.2",
type: "action",
props: {
gitlab,
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/actions/get-issue/get-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gitlab-get-issue",
name: "Get Issue",
description: "Gets a single issue from repository. [See the documentation](https://docs.gitlab.com/ee/api/issues.html#single-project-issue)",
version: "0.2.1",
version: "0.2.2",
type: "action",
props: {
gitlab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gitlab-get-repo-branch",
name: "Get Repo Branch",
description: "Get a single project repository branch. [See the documentation](https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch)",
version: "0.2.1",
version: "0.2.2",
type: "action",
props: {
gitlab,
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/actions/list-commits/list-commits.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gitlab-list-commits",
name: "List Commits",
description: "List commits in a repository branch. [See the documentation](https://docs.gitlab.com/ee/api/commits.html#list-repository-commits)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
gitlab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gitlab-list-repo-branches",
name: "List Repo Branches",
description: "Get a list of repository branches from a project. [See the documentation](https://docs.gitlab.com/ee/api/branches.html#list-repository-branches)",
version: "0.2.1",
version: "0.2.2",
type: "action",
props: {
gitlab,
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/actions/search-issues/search-issues.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gitlab-search-issues",
name: "Search Issues",
description: "Search for issues in a repository with a query. [See the documentation](https://docs.gitlab.com/ee/api/issues.html#list-issues)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
gitlab,
Expand Down
28 changes: 14 additions & 14 deletions components/gitlab/actions/update-epic/update-epic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ export default {
key: "gitlab-update-epic",
name: "Update Epic",
description: "Updates an epic. [See the documentation](https://docs.gitlab.com/ee/api/epics.html#update-epic)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
gitlab,
groupPath: {
groupId: {
propDefinition: [
gitlab,
"groupPath",
"groupId",
],
},
epicIid: {
propDefinition: [
gitlab,
"epicIid",
(c) => ({
groupId: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
},
add_labels: {
propDefinition: [
gitlab,
"groupLabels",
(c) => ({
groupId: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
label: "Add labels",
Expand All @@ -51,8 +51,8 @@ export default {
propDefinition: [
gitlab,
"groupLabels",
(c) => ({
groupPath: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
description: "Comma-separated label names for an issue. Set to an empty string to unassign all labels.",
Expand All @@ -61,8 +61,8 @@ export default {
propDefinition: [
gitlab,
"epicIid",
(c) => ({
groupPath: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
label: "Parent Id",
Expand All @@ -73,8 +73,8 @@ export default {
propDefinition: [
gitlab,
"groupLabels",
(c) => ({
groupPath: c.groupPath,
({ groupId }) => ({
groupId,
}),
],
label: "Remove labels",
Expand Down Expand Up @@ -163,7 +163,7 @@ export default {
]));
data.labels = data.labels?.join();

const response = await this.gitlab.updateEpic(this.groupPath, this.epicIid, {
const response = await this.gitlab.updateEpic(this.groupId, this.epicIid, {
data,
});
$.export("$summary", `Updated epic ${this.epicIid}`);
Expand Down
7 changes: 5 additions & 2 deletions components/gitlab/actions/update-issue/update-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gitlab-update-issue",
name: "Update Issue",
description: "Updates an existing project issue. [See the documentation](https://docs.gitlab.com/ee/api/issues.html#edit-issue)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
gitlab,
Expand Down Expand Up @@ -75,14 +75,17 @@ export default {
},
},
async run({ $ }) {
const labels = Array.isArray(this.labels)
? this.labels.join()
: this.labels;
const data = lodash.pickBy({
title: this.title,
description: this.description,
assignee_ids: this.assignee_ids,
state_event: this.stateEvent,
discussion_locked: this.discussionLocked,
labels,
});
data.labels = data.labels?.join();
const response = await this.gitlab.editIssue(this.projectId, this.issueIid, {
data,
});
Expand Down
28 changes: 23 additions & 5 deletions components/gitlab/gitlab.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,28 @@ export default {
}));
},
},
groupPath: {
groupId: {
type: "string",
label: "Group ID",
description: "The group path, as displayed in the main group page. You must be an Owner of this group",
description: "Select a Group or use a custom Group ID. You must be an Owner of this group",
async options({ page }) {
const response = await this.listGroups({
params: {
min_access_level: 50, // owner role
top_level_only: true, // only can use on root groups
page: page + 1,
},
});
return response.map((group) => ({
label: group.full_path,
value: group.id,
}));
},
},
groupPath: {
type: "string",
label: "Group Path",
description: "Select a Group or use a custom Group Path, as displayed in the main group page. You must be an Owner of this group",
async options({ page }) {
const response = await this.listGroups({
params: {
Expand Down Expand Up @@ -78,7 +96,7 @@ export default {
epicIid: {
type: "string",
label: "Epic Internal ID",
description: "The internal ID of a project's epic",
description: "The internal ID of a project's epic. [This feature is restricted to Gitlab's Premium and Ultimate tiers.](https://docs.gitlab.com/ee/api/epics.html)",
async options({
page, groupId,
}) {
Expand Down Expand Up @@ -125,7 +143,7 @@ export default {
page: page + 1,
},
});
return response.data.map((label) => label.name);
return response?.map?.((label) => label.name);
},
},
assignee: {
Expand Down Expand Up @@ -273,7 +291,7 @@ export default {
},
listProjects(opts = {}) {
return this._makeRequest({
path: `/users/${this._userId()}/projects`,
path: "/projects",
...opts,
});
},
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gitlab",
"version": "0.5.5",
"version": "0.5.6",
"description": "Pipedream Gitlab Components",
"main": "gitlab.app.mjs",
"keywords": [
Expand Down
13 changes: 5 additions & 8 deletions components/gitlab/sources/new-audit-event/new-audit-event.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import gitlab from "../../gitlab.app.mjs";
import base from "../common/base.mjs";
import fetch from "node-fetch";
import {
create_destination,
list_destinations,
Expand All @@ -12,7 +11,7 @@ export default {
key: "gitlab-new-audit-event",
name: "New Audit Event (Instant)",
description: "Emit new event when a new audit event is created",
version: "0.1.2",
version: "0.1.3",
dedupe: "unique",
type: "source",
props: {
Expand Down Expand Up @@ -40,18 +39,16 @@ export default {
const query = create_destination(this.http.endpoint, this.groupPath);

try {
await fetch(`https://${this._getBaseApiUrl()}/api/graphql`, {
await this.gitlab._makeRequest({
url: `https://${this._getBaseApiUrl()}/api/graphql`,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${this.gitlab.$auth.oauth_access_token}`,
},
body: JSON.stringify({
query,
}),
})
.then((r) => r.json());
data: query,
});

} catch (err) {
console.log(`Error thrown during activation: ${JSON.stringify(err)}`);
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/sources/new-branch/new-branch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gitlab-new-branch",
name: "New Branch (Instant)",
description: "Emit new event when a new branch is created",
version: "0.1.1",
version: "0.1.2",
dedupe: "unique",
type: "source",
hooks: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gitlab-new-commit-comment",
name: "New Commit Comment (Instant)",
description: "Emit new event when a commit receives a comment",
version: "0.1.1",
version: "0.1.2",
dedupe: "unique",
type: "source",
hooks: {
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/sources/new-commit/new-commit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "gitlab-new-commit",
name: "New Commit (Instant)",
description: "Emit new event when a new commit is pushed to a branch",
version: "0.1.2",
version: "0.1.3",
dedupe: "unique",
type: "source",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/gitlab/sources/new-issue/new-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gitlab-new-issue",
name: "New Issue (Instant)",
description: "Emit new event when an issue is created in a project",
version: "0.1.1",
version: "0.1.2",
dedupe: "unique",
type: "source",
hooks: {
Expand Down
3 changes: 2 additions & 1 deletion components/gitlab/sources/new-mention/new-mention.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "gitlab-new-mention",
name: "New Mention (Instant)",
description: "Emit new event when you are @mentioned in a new commit, comment, issue or pull request",
version: "0.1.1",
version: "0.1.2",
dedupe: "unique",
type: "source",
props: {
Expand All @@ -20,6 +20,7 @@ export default {
projectId: c.projectId,
}),
],
optional: false,
label: "Username",
description: "The GitLab Username whose mentions will emit events",
withLabel: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gitlab-new-merge-request",
name: "New Merge Request (Instant)",
description: "Emit new event when a merge request is created",
version: "0.1.1",
version: "0.1.2",
dedupe: "unique",
type: "source",
hooks: {
Expand All @@ -18,7 +18,7 @@ export default {
methods: {
...base.methods,
isNewMergeRequest(event) {
const { action } = event.object_attributes;
const action = event?.object_attributes?.action;
const expectedAction = "open";
return action === expectedAction;
},
Expand Down
Loading
Loading