Skip to content

Commit b5ff4c2

Browse files
Sergio WongSergio Wong
authored andcommitted
breeze components
1 parent 7a78b57 commit b5ff4c2

File tree

7 files changed

+575
-4
lines changed

7 files changed

+575
-4
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import breeze from "../../breeze.app.mjs";
2+
3+
export default {
4+
key: "breeze-create-project",
5+
name: "Create Project",
6+
description: "Establishes a new project in breeze. [See documentation](https://www.breeze.pm/api#:~:text=Create%20a%20project)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
breeze,
16+
workspaceId: {
17+
type: "string",
18+
label: "Workspace ID",
19+
description: "The workspace to associate the project with",
20+
optional: true,
21+
async options() {
22+
const workspaces = await this.breeze.getWorkspaces();
23+
return workspaces.map((workspace) => ({
24+
label: workspace.name || workspace.id,
25+
value: workspace.id,
26+
}));
27+
},
28+
},
29+
projectName: {
30+
type: "string",
31+
label: "Project Name",
32+
description: "The name of the project to create",
33+
},
34+
projectDescription: {
35+
type: "string",
36+
label: "Project Description",
37+
description: "The description of the project",
38+
optional: true,
39+
},
40+
startDate: {
41+
type: "string",
42+
label: "Start Date",
43+
description: "The start date for the project (format: `YYYY-MM-DD`)",
44+
optional: true,
45+
},
46+
endDate: {
47+
type: "string",
48+
label: "End Date",
49+
description: "The end date for the project (format: `YYYY-MM-DD`)",
50+
optional: true,
51+
},
52+
},
53+
async run({ $ }) {
54+
const data = {
55+
workspace_id: this.workspaceId,
56+
name: this.projectName,
57+
description: this.projectDescription,
58+
start_date: this.startDate,
59+
end_date: this.endDate,
60+
};
61+
62+
const response = await this.breeze.createProject({
63+
$,
64+
data,
65+
});
66+
67+
$.export("$summary", `Successfully created project "${this.projectName}"`);
68+
69+
return response;
70+
},
71+
};
72+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import breeze from "../../breeze.app.mjs";
2+
3+
export default {
4+
key: "breeze-create-task",
5+
name: "Create Task",
6+
description: "Generates a new task within an existing project in breeze. [See documentation](https://www.breeze.pm/api#:~:text=Create%20a%20card)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
breeze,
16+
projectId: {
17+
propDefinition: [
18+
breeze,
19+
"projectId",
20+
],
21+
},
22+
stageId: {
23+
propDefinition: [
24+
breeze,
25+
"stageId",
26+
(c) => ({
27+
projectId: c.projectId,
28+
}),
29+
],
30+
},
31+
swimlaneId: {
32+
propDefinition: [
33+
breeze,
34+
"swimlaneId",
35+
(c) => ({
36+
projectId: c.projectId,
37+
}),
38+
],
39+
optional: true,
40+
},
41+
taskName: {
42+
type: "string",
43+
label: "Task Name",
44+
description: "The name of the task to create",
45+
},
46+
taskDescription: {
47+
type: "string",
48+
label: "Task Description",
49+
description: "The description of the task",
50+
optional: true,
51+
},
52+
dueDate: {
53+
type: "string",
54+
label: "Due Date",
55+
description: "The due date for the task (format: `YYYY-MM-DD`)",
56+
optional: true,
57+
},
58+
},
59+
async run({ $ }) {
60+
const data = {
61+
stage_id: this.stageId,
62+
swimlane_id: this.swimlaneId,
63+
name: this.taskName,
64+
description: this.taskDescription,
65+
due_date: this.dueDate,
66+
};
67+
68+
const response = await this.breeze.createTask({
69+
$,
70+
projectId: this.projectId,
71+
data,
72+
});
73+
74+
$.export("$summary", `Successfully created task "${this.taskName}"`);
75+
76+
return response;
77+
},
78+
};
79+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import breeze from "../../breeze.app.mjs";
2+
3+
export default {
4+
key: "breeze-find-project",
5+
name: "Find Project",
6+
description: "Searches for a specific project in breeze using the name. [See documentation](https://www.breeze.pm/api#:~:text=Get%20Projects)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
breeze,
16+
projectName: {
17+
type: "string",
18+
label: "Project Name",
19+
description: "The name of the project to search for",
20+
},
21+
},
22+
async run({ $ }) {
23+
const projects = await this.breeze.getProjects({
24+
$,
25+
});
26+
27+
const matchingProjects = projects.filter((project) =>
28+
project.name?.toLowerCase().includes(this.projectName.toLowerCase()));
29+
30+
$.export("$summary", `Found ${matchingProjects.length} project(s) matching "${this.projectName}"`);
31+
32+
return matchingProjects;
33+
},
34+
};
35+

components/breeze/breeze.app.mjs

Lines changed: 130 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,137 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "breeze",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
projectId: {
8+
type: "string",
9+
label: "Project ID",
10+
description: "The project to associate the task with",
11+
async options() {
12+
const projects = await this.getProjects();
13+
return projects.map((project) => ({
14+
label: project.name || project.id,
15+
value: project.id,
16+
}));
17+
},
18+
},
19+
stageId: {
20+
type: "string",
21+
label: "Stage ID",
22+
description: "The stage (list) to associate the task with",
23+
async options({ projectId }) {
24+
if (!projectId) return [];
25+
const lists = await this.getLists({
26+
projectId,
27+
});
28+
return lists.map((list) => ({
29+
label: list.name || list.id,
30+
value: list.id,
31+
}));
32+
},
33+
},
34+
swimlaneId: {
35+
type: "string",
36+
label: "Swimlane ID",
37+
description: "The swimlane to associate the task with",
38+
async options({ projectId }) {
39+
if (!projectId) return [];
40+
const swimlanes = await this.getSwimlanes({
41+
projectId,
42+
});
43+
return swimlanes.map((swimlane) => ({
44+
label: swimlane.name || swimlane.id,
45+
value: swimlane.id,
46+
}));
47+
},
48+
},
49+
taskId: {
50+
type: "string",
51+
label: "Task ID",
52+
description: "The task to monitor",
53+
async options({ projectId }) {
54+
if (!projectId) return [];
55+
const tasks = await this.getTasks({
56+
projectId,
57+
});
58+
return tasks.map((task) => ({
59+
label: task.name || task.id,
60+
value: task.id,
61+
}));
62+
},
63+
},
64+
},
565
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
66+
_baseUrl() {
67+
return "https://api.breeze.pm";
68+
},
69+
async _makeRequest(opts = {}) {
70+
const {
71+
$ = this,
72+
path,
73+
...otherOpts
74+
} = opts;
75+
return axios($, {
76+
...otherOpts,
77+
url: this._baseUrl() + path,
78+
params: {
79+
api_token: this.$auth.api_token,
80+
...otherOpts.params,
81+
},
82+
});
83+
},
84+
async getWorkspaces(args = {}) {
85+
return this._makeRequest({
86+
path: "/workspaces.json",
87+
...args,
88+
});
89+
},
90+
async getProjects(args = {}) {
91+
return this._makeRequest({
92+
path: "/projects.json",
93+
...args,
94+
});
95+
},
96+
async getLists({
97+
projectId, ...args
98+
} = {}) {
99+
return this._makeRequest({
100+
path: `/projects/${projectId}/stages.json`,
101+
...args,
102+
});
103+
},
104+
async getSwimlanes({
105+
projectId, ...args
106+
} = {}) {
107+
return this._makeRequest({
108+
path: `/projects/${projectId}/swimlanes.json`,
109+
...args,
110+
});
111+
},
112+
async getTasks({
113+
projectId, ...args
114+
} = {}) {
115+
return this._makeRequest({
116+
path: `/V2/projects/${projectId}/cards.json`,
117+
...args,
118+
});
119+
},
120+
async createTask({
121+
projectId, ...args
122+
} = {}) {
123+
return this._makeRequest({
124+
path: `/projects/${projectId}/cards.json`,
125+
method: "post",
126+
...args,
127+
});
128+
},
129+
async createProject(args = {}) {
130+
return this._makeRequest({
131+
path: "/projects.json",
132+
method: "post",
133+
...args,
134+
});
9135
},
10136
},
11137
};

0 commit comments

Comments
 (0)