Skip to content

Commit 084c77d

Browse files
committed
create-task
1 parent 4b5a9bf commit 084c77d

File tree

8 files changed

+218
-26
lines changed

8 files changed

+218
-26
lines changed

components/nifty/actions/assign-task/assign-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "nifty-assign-task",
55
name: "Assign Task to Team Member",
66
description: "Assigns a specific task to a team member in Nifty. [See the documentation](https://openapi.niftypm.com/api#put-api-v1-0-tasks-task_id-assignees)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
nifty,

components/nifty/actions/create-message/create-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "nifty-create-message",
66
name: "Create Message",
77
description: "Sends a new message in a team's discussion. [See the documentation](https://openapi.niftypm.com/api)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
nifty,

components/nifty/actions/create-project/create-project.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "nifty-create-project",
88
name: "Create Project",
99
description: "Creates a new project in a designated portfolio. [See the documentation](https://openapi.niftypm.com/api#/Projects/ProjectAPIController_createProject)",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
nifty,
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import nifty from "../../nifty.app.mjs";
2+
3+
export default {
4+
key: "nifty-create-task",
5+
name: "Create Task",
6+
description: "Creates a new task. [See the documentation](https://developers.niftypm.com/operation/operation-taskapicontroller_createtask)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
nifty,
11+
projectId: {
12+
propDefinition: [
13+
nifty,
14+
"projectId",
15+
],
16+
},
17+
taskGroupId: {
18+
propDefinition: [
19+
nifty,
20+
"taskGroupId",
21+
(c) => ({
22+
projectId: c.projectId,
23+
}),
24+
],
25+
},
26+
name: {
27+
type: "string",
28+
label: "Name",
29+
description: "The name of the task",
30+
},
31+
description: {
32+
type: "string",
33+
label: "Description",
34+
description: "A description of the task",
35+
optional: true,
36+
},
37+
order: {
38+
type: "integer",
39+
label: "Order",
40+
description: "The order of the task",
41+
optional: true,
42+
},
43+
parentTaskId: {
44+
propDefinition: [
45+
nifty,
46+
"taskId",
47+
(c) => ({
48+
projectId: c.projectId,
49+
}),
50+
],
51+
label: "Parent Task ID",
52+
description: "Enter a parent task ID to create this task as subtask of another task",
53+
optional: true,
54+
},
55+
milestoneId: {
56+
propDefinition: [
57+
nifty,
58+
"milestoneId",
59+
(c) => ({
60+
projectId: c.projectId,
61+
}),
62+
],
63+
},
64+
dueDate: {
65+
type: "string",
66+
label: "Due Date",
67+
description: "Due date of the task in ISO-8601 format",
68+
optional: true,
69+
},
70+
startDate: {
71+
type: "string",
72+
label: "Start Date",
73+
description: "Start date of the task in ISO-8601 format",
74+
optional: true,
75+
},
76+
assigneeIds: {
77+
propDefinition: [
78+
nifty,
79+
"memberId",
80+
],
81+
type: "string[]",
82+
label: "Assignee IDs",
83+
description: "An array of assignee IDs to assigne to the task",
84+
optional: true,
85+
},
86+
labels: {
87+
type: "string[]",
88+
label: "Labels",
89+
description: "An array of labels to add to the tasK",
90+
optional: true,
91+
},
92+
},
93+
async run({ $ }) {
94+
const response = await this.nifty.createTask({
95+
$,
96+
data: {
97+
task_group_id: this.taskGroupId,
98+
name: this.name,
99+
description: this.description,
100+
order: this.order,
101+
task_id: this.parentTaskId,
102+
milestone_id: this.milestoneId,
103+
due_date: this.dueDate,
104+
start_date: this.startDate,
105+
assignee_ids: this.assigneeIds,
106+
labels: this.labels,
107+
},
108+
});
109+
$.export("$summary", `Successfully created task with ID: ${response.id}`);
110+
return response;
111+
},
112+
};

components/nifty/nifty.app.mjs

Lines changed: 99 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
propDefinitions: {
88
appId: {
99
type: "string",
10-
label: "App Id",
10+
label: "App ID",
1111
description: `The unique identifier for the App. On Nifty, a new app can be created by following these steps:
1212
1. Access Profile Settings > App Center > Integrate with API > Create a new App.
1313
2. In the Create App popup, add the following Pipedream Redirect URL to the Redirect URLs: \`https://api.pipedream.com/connect/oauth/oa_aWyi2m/callback\`.
@@ -20,30 +20,33 @@ export default {
2020
},
2121
});
2222

23-
return apps.map(({ id: value, name: label }) => ({
23+
return apps.map(({
24+
id: value, name: label,
25+
}) => ({
2426
label,
2527
value,
2628
}));
2729
},
2830
},
2931
memberId: {
3032
type: "string",
31-
label: "Member Id",
32-
description:
33-
"The unique identifier for the member that the task will be assigned.",
33+
label: "Member ID",
34+
description: "The unique identifier for the member that the task will be assigned",
3435
async options() {
3536
const members = await this.listMembers();
3637

37-
return members.map(({ id: value, name: label }) => ({
38+
return members.map(({
39+
id: value, name: label,
40+
}) => ({
3841
label,
3942
value,
4043
}));
4144
},
4245
},
4346
projectId: {
4447
type: "string",
45-
label: "Project Id",
46-
description: "The unique identifier for the project.",
48+
label: "Project ID",
49+
description: "The unique identifier for the project",
4750
async options({ page }) {
4851
const { projects } = await this.listProjects({
4952
params: {
@@ -52,34 +55,41 @@ export default {
5255
},
5356
});
5457

55-
return projects.map(({ id: value, name: label }) => ({
58+
return projects.map(({
59+
id: value, name: label,
60+
}) => ({
5661
label,
5762
value,
5863
}));
5964
},
6065
},
6166
taskId: {
6267
type: "string",
63-
label: "Task Id",
64-
description: "The unique identifier for the task.",
65-
async options({ page }) {
68+
label: "Task ID",
69+
description: "The unique identifier for the task",
70+
async options({
71+
page, projectId,
72+
}) {
6673
const { tasks } = await this.listTasks({
6774
params: {
6875
limit: LIMIT,
6976
offset: LIMIT * page,
77+
project_id: projectId,
7078
},
7179
});
7280

73-
return tasks.map(({ id: value, name: label }) => ({
81+
return tasks.map(({
82+
id: value, name: label,
83+
}) => ({
7484
label,
7585
value,
7686
}));
7787
},
7888
},
7989
templateId: {
8090
type: "string",
81-
label: "Template Id",
82-
description: "The unique identifier for the template.",
91+
label: "Template ID",
92+
description: "The unique identifier for the template",
8393
async options({ page }) {
8494
const { items } = await this.listTemplates({
8595
params: {
@@ -89,12 +99,63 @@ export default {
8999
},
90100
});
91101

92-
return items.map(({ id: value, name: label }) => ({
102+
return items.map(({
103+
id: value, name: label,
104+
}) => ({
105+
label,
106+
value,
107+
}));
108+
},
109+
},
110+
milestoneId: {
111+
type: "string",
112+
label: "Milestone ID",
113+
description: "The unique identifier of a milestone",
114+
optional: true,
115+
async options({
116+
page, projectId,
117+
}) {
118+
const { items } = await this.listMilestones({
119+
params: {
120+
limit: LIMIT,
121+
offset: LIMIT * page,
122+
project_id: projectId,
123+
},
124+
});
125+
126+
return items.map(({
127+
id: value, name: label,
128+
}) => ({
93129
label,
94130
value,
95131
}));
96132
},
97133
},
134+
taskGroupId: {
135+
type: "string",
136+
label: "Task Group ID",
137+
description: "The unique identifier of a task group",
138+
async options({
139+
page, projectId,
140+
}) {
141+
const { items } = await this.listMilestones({
142+
params: {
143+
limit: LIMIT,
144+
offset: LIMIT * page,
145+
project_id: projectId,
146+
},
147+
});
148+
149+
return items
150+
.filter(({ task_group }) => task_group )
151+
.map(({
152+
task_group: value, name: label,
153+
}) => ({
154+
label,
155+
value,
156+
}));
157+
},
158+
},
98159
},
99160
methods: {
100161
_baseUrl() {
@@ -105,7 +166,9 @@ export default {
105166
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
106167
};
107168
},
108-
_makeRequest({ $ = this, path, ...opts }) {
169+
_makeRequest({
170+
$ = this, path, ...opts
171+
}) {
109172
return axios($, {
110173
url: this._baseUrl() + path,
111174
headers: this._headers(),
@@ -160,6 +223,12 @@ export default {
160223
...opts,
161224
});
162225
},
226+
listMilestones(opts = {}) {
227+
return this._makeRequest({
228+
path: "/milestones",
229+
...opts,
230+
});
231+
},
163232
listTemplates(opts = {}) {
164233
return this._makeRequest({
165234
path: "/templates",
@@ -173,7 +242,9 @@ export default {
173242
...opts,
174243
});
175244
},
176-
deleteHook({ hookId, ...opts }) {
245+
deleteHook({
246+
hookId, ...opts
247+
}) {
177248
return this._makeRequest({
178249
method: "DELETE",
179250
path: `/webhooks/${hookId}`,
@@ -187,7 +258,9 @@ export default {
187258
...opts,
188259
});
189260
},
190-
assignTask({ taskId, ...opts }) {
261+
assignTask({
262+
taskId, ...opts
263+
}) {
191264
return this._makeRequest({
192265
method: "PUT",
193266
path: `/tasks/${taskId}/assignees`,
@@ -201,5 +274,12 @@ export default {
201274
...opts,
202275
});
203276
},
277+
createTask(opts = {}) {
278+
return this._makeRequest({
279+
method: "POST",
280+
path: "/tasks",
281+
...opts,
282+
});
283+
},
204284
},
205285
};

components/nifty/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/nifty",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Nifty Components",
55
"main": "nifty.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.5.1"
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}

components/nifty/sources/new-message-posted/new-message-posted.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "nifty-new-message-posted",
77
name: "New Message Posted",
88
description: "Emit new event when a new message is posted in a team's discussion.",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {

components/nifty/sources/new-task-created/new-task-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "nifty-new-task-created",
77
name: "New Task Created",
88
description: "Emit new event when a task is created in a project.",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {

0 commit comments

Comments
 (0)