Skip to content

Commit e04aeed

Browse files
committed
Refactor Dart component to enhance task management features
- Renamed and updated prop definitions for better clarity, including changing `dartboardId` to `dartboard`. - Introduced new optional properties: `tags`, `priority`, `size`, `status`, `type`, and `customProperties` to support enhanced task attributes. - Updated task creation and update methods to reflect new property structure and improved API paths. - Added utility function `parseObject` for better handling of input data formats. - Incremented version numbers for task-related actions to reflect changes.
1 parent 99c1c03 commit e04aeed

File tree

6 files changed

+394
-157
lines changed

6 files changed

+394
-157
lines changed
Lines changed: 91 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import dart from "../../dart.app.mjs";
23

34
export default {
45
key: "dart-create-task",
56
name: "Create Task",
6-
description: "Creates a new task within a dartboard. [See the documentation](https://app.itsdart.com/api/v0/docs/)",
7-
version: "0.0.4",
7+
description: "Creates a new task within a dartboard. [See the documentation](https://app.dartai.com/api/v0/public/docs/#/Task/createTask)",
8+
version: "1.0.0",
89
annotations: {
910
destructiveHint: false,
1011
openWorldHint: true,
@@ -13,77 +14,128 @@ export default {
1314
type: "action",
1415
props: {
1516
dart,
16-
dartboardId: {
17+
title: {
1718
propDefinition: [
1819
dart,
19-
"dartboardId",
20+
"title",
2021
],
2122
},
22-
duid: {
23-
type: "string",
24-
label: "Task DUID",
25-
description: "A unique identifier for the task. Must contain at least 12 characters.",
23+
parentId: {
24+
propDefinition: [
25+
dart,
26+
"taskId",
27+
],
28+
label: "Parent Task ID",
29+
description: "The universal, unique ID of the parent task. These tasks have a parent-child relationship where the current task is the child and this task ID corresponds to the parent. Subtasks inherit context from their parent and are typically smaller units of work",
2630
},
27-
title: {
31+
dartboard: {
2832
propDefinition: [
2933
dart,
30-
"taskName",
34+
"dartboard",
3135
],
36+
label: "Dartboard",
37+
description: "The full title of the dartboard, which is a project or list of tasks",
3238
},
33-
description: {
39+
type: {
3440
propDefinition: [
3541
dart,
36-
"taskDescription",
42+
"type",
3743
],
3844
},
39-
dueAt: {
45+
status: {
4046
propDefinition: [
4147
dart,
42-
"dueAt",
48+
"status",
49+
],
50+
label: "Status",
51+
description: "The status from the list of available statuses",
52+
},
53+
description: {
54+
type: "string",
55+
label: "Description",
56+
description: "A longer description of the task, which can include markdown formatting",
57+
},
58+
assignees: {
59+
propDefinition: [
60+
dart,
61+
"assigneeIds",
4362
],
63+
label: "Assignees",
64+
description: "The names or emails of the users that the task is assigned to. Either this or assignee must be included, depending on whether the workspaces allows multiple assignees or not",
4465
},
45-
assigneeIds: {
66+
assignee: {
4667
propDefinition: [
4768
dart,
4869
"assigneeIds",
4970
],
71+
type: "string",
72+
label: "Assignee",
73+
description: "The name or email of the user that the task is assigned to. Either this or assignees must be included, depending on whether the workspaces allows multiple assignees or not",
74+
},
75+
tags: {
76+
propDefinition: [
77+
dart,
78+
"tags",
79+
],
80+
label: "Tags",
81+
description: "Any tags that should be applied to the task, which can be used to filter and search for tasks. Tags are also known as labels or components and are strings that can be anything, but should be short and descriptive",
5082
},
5183
priority: {
5284
propDefinition: [
5385
dart,
5486
"priority",
5587
],
88+
label: "Priority",
89+
description: "The priority, which is a string that can be one of the specified options. This is used to sort tasks and determine which tasks should be done first",
90+
},
91+
startAt: {
92+
propDefinition: [
93+
dart,
94+
"startAt",
95+
],
96+
},
97+
dueAt: {
98+
propDefinition: [
99+
dart,
100+
"dueAt",
101+
],
102+
},
103+
size: {
104+
propDefinition: [
105+
dart,
106+
"size",
107+
],
108+
},
109+
customProperties: {
110+
propDefinition: [
111+
dart,
112+
"customProperties",
113+
],
56114
},
57115
},
58116
async run({ $ }) {
59-
const response = await this.dart.createTransaction({
117+
const { item: response } = await this.dart.createTask({
60118
$,
61119
data: {
62-
clientDuid: this.duid,
63-
items: [
64-
{
65-
duid: this.duid,
66-
operations: [
67-
{
68-
model: "task",
69-
kind: "create",
70-
data: {
71-
duid: this.duid,
72-
dartboardDuid: this.dartboardId,
73-
title: this.title,
74-
description: this.description,
75-
dueAt: this.dueAt,
76-
assigneeDuids: this.assigneeIds,
77-
priority: this.priority,
78-
},
79-
},
80-
],
81-
kind: "task_create",
82-
},
83-
],
120+
item: {
121+
title: this.title,
122+
parentId: this.parentId,
123+
dartboard: this.dartboard,
124+
type: this.type,
125+
status: this.status,
126+
description: this.description,
127+
assignees: parseObject(this.assignees),
128+
assignee: this.assignee,
129+
tags: parseObject(this.tags),
130+
priority: this.priority,
131+
startAt: this.startAt,
132+
dueAt: this.dueAt,
133+
size: this.size,
134+
customProperties: parseObject(this.customProperties),
135+
},
84136
},
85137
});
86-
$.export("$summary", `Created task "${this.title}"`);
138+
$.export("$summary", `Successfully created task wiht ID: ${response.id}`);
87139
return response;
88140
},
89141
};
Lines changed: 93 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import dart from "../../dart.app.mjs";
23

34
export default {
45
key: "dart-find-or-create-task",
56
name: "Find or Create Task",
6-
description: "Checks for an existing task within a dartboard using the 'task-name'. If it doesn't exist, a new task is created. [See the documentation](https://app.itsdart.com/api/v0/docs/)",
7-
version: "0.0.4",
7+
description: "Checks for an existing task within a dartboard using the 'task-name'. If it doesn't exist, a new task is created. [See the documentation](https://app.dartai.com/api/v0/public/docs/#/Task/createTask)",
8+
version: "1.0.0",
89
annotations: {
910
destructiveHint: false,
1011
openWorldHint: true,
@@ -13,96 +14,141 @@ export default {
1314
type: "action",
1415
props: {
1516
dart,
16-
dartboardId: {
17+
dartboard: {
1718
propDefinition: [
1819
dart,
19-
"dartboardId",
20+
"dartboard",
2021
],
22+
optional: false,
2123
},
22-
taskName: {
24+
title: {
2325
propDefinition: [
2426
dart,
2527
"taskName",
2628
],
2729
},
28-
duid: {
29-
type: "string",
30-
label: "Task DUID",
31-
description: "If the task is not found, a unique identifier to assign to the newly created task. Must contain at least 12 characters.",
30+
parentId: {
31+
propDefinition: [
32+
dart,
33+
"taskId",
34+
],
35+
label: "Parent Task ID",
36+
description: "The universal, unique ID of the parent task. These tasks have a parent-child relationship where the current task is the child and this task ID corresponds to the parent. Subtasks inherit context from their parent and are typically smaller units of work",
3237
},
33-
description: {
38+
type: {
3439
propDefinition: [
3540
dart,
36-
"taskDescription",
41+
"type",
3742
],
3843
},
39-
dueAt: {
44+
status: {
4045
propDefinition: [
4146
dart,
42-
"dueAt",
47+
"status",
4348
],
49+
label: "Status",
50+
description: "The status from the list of available statuses",
4451
},
45-
assigneeIds: {
52+
description: {
53+
type: "string",
54+
label: "Description",
55+
description: "A longer description of the task, which can include markdown formatting",
56+
},
57+
assignees: {
4658
propDefinition: [
4759
dart,
4860
"assigneeIds",
4961
],
62+
label: "Assignees",
63+
description: "The names or emails of the users that the task is assigned to. Either this or assignee must be included, depending on whether the workspaces allows multiple assignees or not",
64+
},
65+
assignee: {
66+
propDefinition: [
67+
dart,
68+
"assigneeIds",
69+
],
70+
type: "string",
71+
label: "Assignee",
72+
description: "The name or email of the user that the task is assigned to. Either this or assignees must be included, depending on whether the workspaces allows multiple assignees or not",
73+
},
74+
tags: {
75+
propDefinition: [
76+
dart,
77+
"tags",
78+
],
79+
label: "Tags",
80+
description: "Any tags that should be applied to the task, which can be used to filter and search for tasks. Tags are also known as labels or components and are strings that can be anything, but should be short and descriptive",
5081
},
5182
priority: {
5283
propDefinition: [
5384
dart,
5485
"priority",
5586
],
87+
label: "Priority",
88+
description: "The priority, which is a string that can be one of the specified options. This is used to sort tasks and determine which tasks should be done first",
89+
},
90+
startAt: {
91+
propDefinition: [
92+
dart,
93+
"startAt",
94+
],
95+
},
96+
dueAt: {
97+
propDefinition: [
98+
dart,
99+
"dueAt",
100+
],
101+
},
102+
size: {
103+
propDefinition: [
104+
dart,
105+
"size",
106+
],
107+
},
108+
customProperties: {
109+
propDefinition: [
110+
dart,
111+
"customProperties",
112+
],
56113
},
57114
},
58115
async run({ $ }) {
59116
const { results } = await this.dart.listTasks({
60117
$,
61118
params: {
62119
title: this.taskName,
120+
dartboard: this.dartboard,
63121
},
64122
});
65123

66-
const matchingTasks = results.filter(({ dartboardDuid }) => dartboardDuid === this.dartboardId);
67-
68-
if (matchingTasks?.length) {
69-
$.export("$summary", `Successfully found task "${this.taskName}"`);
70-
return matchingTasks;
124+
if (results?.length) {
125+
$.export("$summary", `Successfully found task with ID: ${results[0].id}`);
126+
return results;
71127
}
72128

73-
const response = await this.dart.createTransaction({
129+
const { item: response } = await this.dart.createTask({
74130
$,
75131
data: {
76-
clientDuid: this.duid,
77-
items: [
78-
{
79-
duid: this.duid,
80-
operations: [
81-
{
82-
model: "task",
83-
kind: "create",
84-
data: {
85-
duid: this.duid,
86-
dartboardDuid: this.dartboardId,
87-
title: this.taskName,
88-
description: this.description,
89-
dueAt: this.dueAt,
90-
assigneeDuids: this.assigneeIds,
91-
priority: this.priority,
92-
},
93-
},
94-
],
95-
kind: "task_create",
96-
},
97-
],
132+
item: {
133+
title: this.title,
134+
parentId: this.parentId,
135+
dartboard: this.dartboard,
136+
type: this.type,
137+
status: this.status,
138+
description: this.description,
139+
assignees: parseObject(this.assignees),
140+
assignee: this.assignee,
141+
tags: parseObject(this.tags),
142+
priority: this.priority,
143+
startAt: this.startAt,
144+
dueAt: this.dueAt,
145+
size: this.size,
146+
customProperties: parseObject(this.customProperties),
147+
},
98148
},
99149
});
100150

101-
if (!response.results[0].success) {
102-
throw new Error(response.results[0].message);
103-
}
104-
105-
$.export("$summary", `Created task: "${this.taskName}"`);
151+
$.export("$summary", `Successfully created task with ID: ${response.duid || response.id}`);
106152
return response;
107153
},
108154
};

0 commit comments

Comments
 (0)