Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
69 changes: 69 additions & 0 deletions components/redmine/actions/create-issue/create-issue.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import app from "../../redmine.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "redmine-create-issue",
name: "Create Issue",
description: "Creates a new issue in Redmine. [See the documentation](https://www.redmine.org/projects/redmine/wiki/rest_issues#creating-an-issue)",
version: "0.0.1",
type: "action",
props: {
app,
projectId: {
propDefinition: [
app,
"projectId",
],
},
trackerId: {
propDefinition: [
app,
"trackerId",
],
},
subject: {
type: "string",
label: "Subject",
description: "The subject of the issue",
},
description: {
type: "string",
label: "Description",
description: "The description of the issue",
},
statusId: {
propDefinition: [
app,
"statusId",
],
},
priorityId: {
propDefinition: [
app,
"priorityId",
],
},
},
methods: {
createIssue(args = {}) {
return this.app.post({
path: "/issues.json",
...args,
});
},
},
run({ $: step }) {
const {
createIssue,
...issue
} = this;

return createIssue({
step,
data: {
issue: utils.transformProps(issue),
},
summary: (response) => `Successfully created issue with ID: \`${response.issue?.id}\``,
});
},
};
40 changes: 40 additions & 0 deletions components/redmine/actions/delete-user/delete-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import app from "../../redmine.app.mjs";

export default {
key: "redmine-delete-user",
name: "Delete User",
description: "Deletes a user from the Redmine platform. [See the documentation](https://www.redmine.org/projects/redmine/wiki/rest_users#delete)",
version: "0.0.1",
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
},
methods: {
deleteUser({
userId, ...args
} = {}) {
return this.app.delete({
path: `/users/${userId}.json`,
...args,
});
},
},
run({ $: step }) {
const {
deleteUser,
userId,
} = this;

return deleteUser({
step,
userId,
summary: () => "Successfully deleted user",
});
},
};
75 changes: 75 additions & 0 deletions components/redmine/actions/update-project/update-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import app from "../../redmine.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "redmine-update-project",
name: "Update Project",
description: "Updates an existing project in Redmine. [See the documentation](https://www.redmine.org/projects/redmine/wiki/rest_projects#updating-a-project)",
version: "0.0.1",
type: "action",
props: {
app,
projectId: {
propDefinition: [
app,
"projectId",
],
},
name: {
type: "string",
label: "Name",
description: "The name of the project",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "The description of the project",
optional: true,
},
homepage: {
type: "string",
label: "Homepage",
description: "The homepage of the project",
optional: true,
},
isPublic: {
type: "boolean",
label: "Is Public",
description: "Whether the project is public",
optional: true,
},
inheritMembers: {
type: "boolean",
label: "Inherit Members",
description: "Whether the project should inherit members from its parent",
optional: true,
},
},
methods: {
updateProject({
projectId, ...args
} = {}) {
return this.app.put({
path: `/projects/${projectId}.json`,
...args,
});
},
},
run({ $: step }) {
const {
updateProject,
projectId,
...project
} = this;

return updateProject({
step,
projectId,
data: {
project: utils.transformProps(project),
},
summary: () => "Successfully updated project",
});
},
};
15 changes: 15 additions & 0 deletions components/redmine/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const SUMMARY_LABEL = "$summary";
const DOMAIN_PLACEHOLDER = "{domain}";
const BASE_URL = `https://${DOMAIN_PLACEHOLDER}`;
const LAST_CREATED_AT = "lastCreatedAt";
const DEFAULT_MAX = 600;
const DEFAULT_LIMIT = 60;

export default {
SUMMARY_LABEL,
DOMAIN_PLACEHOLDER,
BASE_URL,
DEFAULT_MAX,
DEFAULT_LIMIT,
LAST_CREATED_AT,
};
43 changes: 43 additions & 0 deletions components/redmine/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function toSnakeCase(str) {
return str?.replace(/([A-Z])/g, "_$1").toLowerCase();
}

function keysToSnakeCase(data = {}) {
return Object.entries(data)
.reduce((acc, [
key,
value,
]) => ({
...acc,
[toSnakeCase(key)]: value,
}), {});
}

function transformProps(props) {
if (!props) {
return;
}

return keysToSnakeCase(
Object.fromEntries(
Object.entries(props)
.filter(([
key,
value,
]) => typeof(value) !== "function" && key !== "app"),
),
);
}

async function iterate(iterations) {
const items = [];
for await (const item of iterations) {
items.push(item);
}
return items;
}

export default {
transformProps,
iterate,
};
4 changes: 2 additions & 2 deletions components/redmine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/redmine",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Redmine Components",
"main": "redmine.app.mjs",
"keywords": [
Expand All @@ -12,4 +12,4 @@
"publishConfig": {
"access": "public"
}
}
}
Loading