Skip to content

Commit fefc43c

Browse files
authored
New Components - height (#12331)
* height init * new components * pnpm-lock.yaml * update * update * update
1 parent c08ad75 commit fefc43c

File tree

14 files changed

+744
-8
lines changed

14 files changed

+744
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import height from "../../height.app.mjs";
2+
3+
export default {
4+
key: "height-create-task",
5+
name: "Create Task",
6+
description: "Creates a new task within your workspace. [See the documentation](https://height.notion.site/Create-a-task-b50565736830422684b28ae570a53a9e)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
height,
11+
taskName: {
12+
propDefinition: [
13+
height,
14+
"taskName",
15+
],
16+
},
17+
listIds: {
18+
propDefinition: [
19+
height,
20+
"listIds",
21+
],
22+
},
23+
description: {
24+
propDefinition: [
25+
height,
26+
"description",
27+
],
28+
},
29+
status: {
30+
propDefinition: [
31+
height,
32+
"status",
33+
],
34+
},
35+
assigneeIds: {
36+
propDefinition: [
37+
height,
38+
"assigneeIds",
39+
],
40+
},
41+
parentTaskId: {
42+
propDefinition: [
43+
height,
44+
"taskId",
45+
],
46+
label: "Parent Task ID",
47+
description: "The task ID of the parent task",
48+
optional: true,
49+
},
50+
},
51+
async run({ $ }) {
52+
const response = await this.height.createTask({
53+
$,
54+
data: {
55+
name: this.taskName,
56+
listIds: this.listIds,
57+
description: this.description,
58+
status: this.status,
59+
assigneesIds: this.assigneeIds,
60+
parentTaskId: this.parentTaskId,
61+
},
62+
});
63+
$.export("$summary", `Successfully created task ${this.taskName}`);
64+
return response;
65+
},
66+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import height from "../../height.app.mjs";
2+
3+
export default {
4+
key: "height-search-tasks",
5+
name: "Search Tasks",
6+
description: "Searches for tasks within your workspace using a text query. [See the documentation](https://height.notion.site/Search-tasks-bb201e3db042442e9a1d0686a7b271a2)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
height,
11+
query: {
12+
type: "string",
13+
label: "Query",
14+
description: "Full text search on the task",
15+
},
16+
},
17+
async run({ $ }) {
18+
const { list } = await this.height.searchTasks({
19+
$,
20+
params: {
21+
query: this.query,
22+
filters: {
23+
status: {
24+
values: [
25+
"backLog",
26+
"inProgress",
27+
"done",
28+
],
29+
},
30+
},
31+
},
32+
});
33+
$.export("$summary", `Found ${list.length} task${list.length === 1
34+
? ""
35+
: "s"} matching the query "${this.query}"`);
36+
return list;
37+
},
38+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import height from "../../height.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "height-update-task",
6+
name: "Update Task",
7+
description: "Updates a specified task within your workspace. [See the documentation](https://height.notion.site/Update-tasks-53d72cb0059a4e0e81cc2fcbfcbf9d0a)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
height,
12+
taskId: {
13+
propDefinition: [
14+
height,
15+
"taskId",
16+
],
17+
},
18+
taskName: {
19+
propDefinition: [
20+
height,
21+
"taskName",
22+
],
23+
optional: true,
24+
},
25+
description: {
26+
propDefinition: [
27+
height,
28+
"description",
29+
],
30+
},
31+
listIdsToAdd: {
32+
propDefinition: [
33+
height,
34+
"listIds",
35+
(c) => ({
36+
taskId: c.taskId,
37+
excludeTaskLists: true,
38+
}),
39+
],
40+
optional: true,
41+
label: "Lists to Add",
42+
description: "Lists to add the task to",
43+
},
44+
listIdsToRemove: {
45+
propDefinition: [
46+
height,
47+
"listIds",
48+
(c) => ({
49+
taskId: c.taskId,
50+
}),
51+
],
52+
optional: true,
53+
label: "Lists to Remove",
54+
description: "Lists to remove the task from",
55+
},
56+
assigneeIdsToAdd: {
57+
propDefinition: [
58+
height,
59+
"assigneeIds",
60+
(c) => ({
61+
taskId: c.taskId,
62+
excludeTaskAssignees: true,
63+
}),
64+
],
65+
label: "Assignees to Add",
66+
description: "The assignees to add to this task",
67+
},
68+
assigneeIdsToRemove: {
69+
propDefinition: [
70+
height,
71+
"assigneeIds",
72+
(c) => ({
73+
taskId: c.taskId,
74+
}),
75+
],
76+
label: "Assignees to Remove",
77+
description: "The assignees to remove from this task",
78+
},
79+
parentTaskId: {
80+
propDefinition: [
81+
height,
82+
"taskId",
83+
],
84+
label: "Parent Task ID",
85+
description: "The task ID of the parent task",
86+
optional: true,
87+
},
88+
},
89+
async run({ $ }) {
90+
if (!this.taskName
91+
&& !this.description
92+
&& !this.listIdsToAdd
93+
&& !this.listIdsToRemove
94+
&& !this.assigneeIdsToAdd
95+
&& !this.assigneeIdsToRemove
96+
&& !this.parentTaskId
97+
) {
98+
throw new ConfigurationError("Please specify at least one field to update");
99+
}
100+
101+
const effects = [];
102+
if (this.taskName) {
103+
effects.push({
104+
type: "name",
105+
name: this.taskName,
106+
});
107+
}
108+
if (this.description) {
109+
effects.push({
110+
type: "description",
111+
description: {
112+
message: this.description,
113+
},
114+
});
115+
}
116+
if (this.listIdsToAdd || this.listIdsToRemove) {
117+
effects.push({
118+
type: "lists",
119+
listIds: {
120+
add: this.listIdsToAdd,
121+
remove: this.listIdsToRemove,
122+
},
123+
});
124+
}
125+
if (this.assigneeIdsToAdd || this.assigneeIdsToRemove) {
126+
effects.push({
127+
type: "assignees",
128+
assigneeIds: {
129+
add: this.assigneeIdsToAdd,
130+
remove: this.assigneeIdsToRemove,
131+
},
132+
});
133+
}
134+
if (this.parentTaskId) {
135+
effects.push({
136+
type: "parentTask",
137+
parentTaskId: this.parentTaskId,
138+
});
139+
}
140+
let response;
141+
try {
142+
response = await this.height.updateTask({
143+
$,
144+
data: {
145+
patches: [
146+
{
147+
taskIds: [
148+
this.taskId,
149+
],
150+
effects,
151+
},
152+
],
153+
},
154+
});
155+
} catch (e) {
156+
const messageText = JSON.parse(e.message).error.message;
157+
if (messageText === "listIds can't be empty.") {
158+
throw new Error("Task must belong to at least one list");
159+
}
160+
throw new Error(messageText);
161+
}
162+
$.export("$summary", `Task ${this.taskId} updated successfully`);
163+
return response;
164+
},
165+
};

0 commit comments

Comments
 (0)