@pipedream/todoist 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/actions/create-filter/create-filter.mjs +66 -0
- package/actions/create-label/create-label.mjs +56 -0
- package/actions/create-project/create-project.mjs +57 -0
- package/actions/create-project-comment/create-project-comment.mjs +42 -0
- package/actions/create-section/create-section.mjs +49 -0
- package/actions/create-task/create-task.mjs +150 -0
- package/actions/create-task-comment/create-task-comment.mjs +51 -0
- package/actions/delete-comment/delete-comment.mjs +56 -0
- package/actions/delete-filter/delete-filter.mjs +30 -0
- package/actions/delete-label/delete-label.mjs +34 -0
- package/actions/delete-project/delete-project.mjs +34 -0
- package/actions/delete-section/delete-section.mjs +43 -0
- package/actions/delete-task/delete-task.mjs +44 -0
- package/actions/export-tasks/export-tasks.mjs +40 -0
- package/actions/find-project/find-project.mjs +51 -0
- package/actions/find-task/find-task.mjs +62 -0
- package/actions/find-user/find-user.mjs +28 -0
- package/actions/get-label/get-label.mjs +26 -0
- package/actions/get-project/get-project.mjs +26 -0
- package/actions/get-project-comment/get-project-comment.mjs +38 -0
- package/actions/get-section/get-section.mjs +38 -0
- package/actions/get-task/get-task.mjs +37 -0
- package/actions/get-task-comment/get-task-comment.mjs +47 -0
- package/actions/import-tasks/import-tasks.mjs +104 -0
- package/actions/invite-user-to-project/invite-user-to-project.mjs +40 -0
- package/actions/list-filters/list-filters.mjs +23 -0
- package/actions/list-labels/list-labels.mjs +21 -0
- package/actions/list-project-comments/list-project-comments.mjs +32 -0
- package/actions/list-projects/list-projects.mjs +22 -0
- package/actions/list-sections/list-sections.mjs +31 -0
- package/actions/list-task-comments/list-task-comments.mjs +40 -0
- package/actions/list-uncompleted-tasks/list-uncompleted-tasks.mjs +53 -0
- package/actions/mark-task-completed/mark-task-completed.mjs +43 -0
- package/actions/move-task-to-section/move-task-to-section.mjs +58 -0
- package/actions/uncomplete-task/uncomplete-task.mjs +42 -0
- package/actions/update-comment/update-comment.mjs +67 -0
- package/actions/update-filter/update-filter.mjs +76 -0
- package/actions/update-label/update-label.mjs +70 -0
- package/actions/update-project/update-project.mjs +62 -0
- package/actions/update-section/update-section.mjs +54 -0
- package/actions/update-task/update-task.mjs +126 -0
- package/colors.mjs +82 -0
- package/package.json +23 -0
- package/resource-types.mjs +15 -0
- package/sources/common-project.mjs +18 -0
- package/sources/common-task.mjs +38 -0
- package/sources/common.mjs +56 -0
- package/sources/completed-task/completed-task.mjs +17 -0
- package/sources/incomplete-task/incomplete-task.mjs +17 -0
- package/sources/new-or-modified-project/new-or-modified-project.mjs +10 -0
- package/sources/new-or-modified-task/new-or-modified-task.mjs +10 -0
- package/sources/new-project/new-project.mjs +11 -0
- package/sources/new-section/new-section.mjs +24 -0
- package/sources/new-task/new-task.mjs +11 -0
- package/sources/sync-resources/sync-resources.mjs +64 -0
- package/todoist.app.mjs +1105 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-delete-task",
|
|
5
|
+
name: "Delete Task",
|
|
6
|
+
description: "Deletes a task. [See the docs here](https://developer.todoist.com/rest/v1/#delete-a-task)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
task: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"task",
|
|
21
|
+
(c) => ({
|
|
22
|
+
project: c.project,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
description: "Select the task to delete",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
async run ({ $ }) {
|
|
29
|
+
const { task } = this;
|
|
30
|
+
const data = {
|
|
31
|
+
taskId: task,
|
|
32
|
+
};
|
|
33
|
+
// No interesting data is returned from Todoist
|
|
34
|
+
await this.todoist.deleteTask({
|
|
35
|
+
$,
|
|
36
|
+
data,
|
|
37
|
+
});
|
|
38
|
+
$.export("$summary", "Successfully deleted task");
|
|
39
|
+
return {
|
|
40
|
+
id: task,
|
|
41
|
+
success: true,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { file } from "tmp-promise";
|
|
4
|
+
import converter from "json-2-csv";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
key: "todoist-export-tasks",
|
|
8
|
+
name: "Export Tasks",
|
|
9
|
+
description: "Export project task names as comma separated file. Returns path to new file. [See Docs](https://developer.todoist.com/rest/v1/#get-active-tasks)",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
type: "action",
|
|
12
|
+
props: {
|
|
13
|
+
todoist,
|
|
14
|
+
project: {
|
|
15
|
+
propDefinition: [
|
|
16
|
+
todoist,
|
|
17
|
+
"project",
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
async run ({ $ }) {
|
|
22
|
+
const { project } = this;
|
|
23
|
+
|
|
24
|
+
const tasks = await this.todoist.getActiveTasks({
|
|
25
|
+
$,
|
|
26
|
+
params: {
|
|
27
|
+
project_id: project,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const csv = await converter.json2csvAsync(tasks);
|
|
31
|
+
|
|
32
|
+
const { path } = await file();
|
|
33
|
+
await fs.promises.appendFile(path, Buffer.from(csv));
|
|
34
|
+
|
|
35
|
+
$.export("$summary", `Successfully exported ${tasks.length} task${tasks.length === 1
|
|
36
|
+
? ""
|
|
37
|
+
: "s"} to "${path}"`);
|
|
38
|
+
return path;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-find-project",
|
|
5
|
+
name: "Find Project",
|
|
6
|
+
description: "Finds a project (by name/title). [See Docs](https://developer.todoist.com/rest/v1/#get-all-projects) Optionally, create one if none are found. [See Docs](https://developer.todoist.com/rest/v1/#create-a-new-project)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
name: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"name",
|
|
15
|
+
],
|
|
16
|
+
description: "The name of the project to search for/create",
|
|
17
|
+
},
|
|
18
|
+
createIfNotFound: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
todoist,
|
|
21
|
+
"createIfNotFound",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async run ({ $ }) {
|
|
26
|
+
const {
|
|
27
|
+
name,
|
|
28
|
+
createIfNotFound,
|
|
29
|
+
} = this;
|
|
30
|
+
const projects = await this.todoist.getProjects({
|
|
31
|
+
$,
|
|
32
|
+
});
|
|
33
|
+
let result = projects.find((project) => project.name == name);
|
|
34
|
+
let summary = result
|
|
35
|
+
? `Project '${name}' found`
|
|
36
|
+
: `Project '${name}' not found`;
|
|
37
|
+
|
|
38
|
+
if (!result && createIfNotFound) {
|
|
39
|
+
result = await this.todoist.createProject({
|
|
40
|
+
$,
|
|
41
|
+
data: {
|
|
42
|
+
name,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
summary += ", Project created";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
$.export("$summary", summary);
|
|
49
|
+
return result;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-find-task",
|
|
5
|
+
name: "Find Task",
|
|
6
|
+
description: "Finds a task by name. [See Docs](https://developer.todoist.com/rest/v1/#get-active-tasks) Optionally, create one if none are found. [See Docs](https://developer.todoist.com/rest/v1/#create-a-new-task)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
content: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"name",
|
|
21
|
+
],
|
|
22
|
+
description: "The name of the task to search for/create",
|
|
23
|
+
},
|
|
24
|
+
createIfNotFound: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
todoist,
|
|
27
|
+
"createIfNotFound",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
async run ({ $ }) {
|
|
32
|
+
const {
|
|
33
|
+
project,
|
|
34
|
+
content,
|
|
35
|
+
createIfNotFound,
|
|
36
|
+
} = this;
|
|
37
|
+
const tasks = await this.todoist.getActiveTasks({
|
|
38
|
+
$,
|
|
39
|
+
params: {
|
|
40
|
+
project_id: project,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
let result = tasks.find((task) => task.content == content);
|
|
44
|
+
let summary = result
|
|
45
|
+
? "Task found"
|
|
46
|
+
: "Task not found";
|
|
47
|
+
|
|
48
|
+
if (!result && createIfNotFound) {
|
|
49
|
+
result = await this.todoist.createTask({
|
|
50
|
+
$,
|
|
51
|
+
data: {
|
|
52
|
+
project_id: project,
|
|
53
|
+
content,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
summary += ", Task created";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$.export("$summary", summary);
|
|
60
|
+
return result;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-find-user",
|
|
5
|
+
name: "Find User",
|
|
6
|
+
description: "Searches by email for a user who is connected/shared with your account. [See the docs here](https://developer.todoist.com/sync/v8/#read-resources)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
email: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"email",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run ({ $ }) {
|
|
19
|
+
const { email } = this;
|
|
20
|
+
const results = await this.todoist.syncCollaborators();
|
|
21
|
+
const { collaborators } = results;
|
|
22
|
+
const result = collaborators.find((user) => user.email == email);
|
|
23
|
+
$.export("$summary", result
|
|
24
|
+
? "User Found"
|
|
25
|
+
: "User Not Found");
|
|
26
|
+
return result;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-label",
|
|
5
|
+
name: "Get Label",
|
|
6
|
+
description: "Returns info about a label. [See the docs here](https://developer.todoist.com/rest/v1/#get-a-label)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
label: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"label",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run ({ $ }) {
|
|
19
|
+
const resp = (await this.todoist.getLabels({
|
|
20
|
+
$,
|
|
21
|
+
id: this.label,
|
|
22
|
+
}));
|
|
23
|
+
$.export("$summary", "Successfully retrieved label");
|
|
24
|
+
return resp;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-project",
|
|
5
|
+
name: "Get Project",
|
|
6
|
+
description: "Returns info about a project. [See the docs here](https://developer.todoist.com/rest/v1/#get-a-project)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run ({ $ }) {
|
|
19
|
+
const resp = (await this.todoist.getProjects({
|
|
20
|
+
$,
|
|
21
|
+
id: this.project,
|
|
22
|
+
}));
|
|
23
|
+
$.export("$summary", "Successfully retrieved project");
|
|
24
|
+
return resp;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-project-comment",
|
|
5
|
+
name: "Get Project Comment",
|
|
6
|
+
description: "Returns info about a project comment. [See the docs here](https://developer.todoist.com/rest/v1/#get-a-comment)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
description: "Project containing the comment",
|
|
17
|
+
},
|
|
18
|
+
commentId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
todoist,
|
|
21
|
+
"commentId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
project: c.project,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
async run ({ $ }) {
|
|
29
|
+
const resp = await this.todoist.getComments({
|
|
30
|
+
$,
|
|
31
|
+
params: {
|
|
32
|
+
comment_id: this.commentId,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
$.export("$summary", "Successfully retrieved comment");
|
|
36
|
+
return resp;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-section",
|
|
5
|
+
name: "Get Section",
|
|
6
|
+
description: "Returns info about a section. [See the docs here](https://developer.todoist.com/rest/v1/#get-a-single-section)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
sectionId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"section",
|
|
21
|
+
(c) => ({
|
|
22
|
+
project: c.project,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
optional: false,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
async run ({ $ }) {
|
|
29
|
+
const resp = await this.todoist.getSections({
|
|
30
|
+
$,
|
|
31
|
+
params: {
|
|
32
|
+
section_id: this.sectionId,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
$.export("$summary", "Successfully retrieved section");
|
|
36
|
+
return resp;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-task",
|
|
5
|
+
name: "Get Task",
|
|
6
|
+
description: "Returns info about a task. [See the docs here](https://developer.todoist.com/rest/v1/#get-an-active-task)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
task: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"task",
|
|
21
|
+
(c) => ({
|
|
22
|
+
project: c.project,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
async run ({ $ }) {
|
|
28
|
+
const resp = await this.todoist.getActiveTasks({
|
|
29
|
+
$,
|
|
30
|
+
params: {
|
|
31
|
+
task_id: this.task,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
$.export("$summary", "Successfully retrieved task");
|
|
35
|
+
return resp;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-get-task-comment",
|
|
5
|
+
name: "Get Task Comment",
|
|
6
|
+
description: "Returns info about a task comment. [See the docs here](https://developer.todoist.com/rest/v1/#get-a-comment)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
task: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"task",
|
|
21
|
+
(c) => ({
|
|
22
|
+
project: c.project,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
optional: true,
|
|
26
|
+
},
|
|
27
|
+
commentId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
todoist,
|
|
30
|
+
"commentId",
|
|
31
|
+
(c) => ({
|
|
32
|
+
task: c.task,
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
async run ({ $ }) {
|
|
38
|
+
const resp = await this.todoist.getComments({
|
|
39
|
+
$,
|
|
40
|
+
params: {
|
|
41
|
+
comment_id: this.commentId,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
$.export("$summary", "Successfully retrieved comment");
|
|
45
|
+
return resp;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import converter from "json-2-csv";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "todoist-import-tasks",
|
|
7
|
+
name: "Import Tasks",
|
|
8
|
+
description: "Import tasks into a selected project. [See Docs](https://developer.todoist.com/sync/v8/#add-an-item)",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "action",
|
|
11
|
+
props: {
|
|
12
|
+
todoist,
|
|
13
|
+
path: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
todoist,
|
|
16
|
+
"path",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
project: {
|
|
20
|
+
propDefinition: [
|
|
21
|
+
todoist,
|
|
22
|
+
"project",
|
|
23
|
+
],
|
|
24
|
+
description: "Project to import tasks into",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
methods: {
|
|
28
|
+
exportSummary($, tasks) {
|
|
29
|
+
$.export("$summary", `Successfully imported ${tasks.length} task${tasks.length === 1
|
|
30
|
+
? ""
|
|
31
|
+
: "s"} from "${this.path}"`);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
async run ({ $ }) {
|
|
35
|
+
const {
|
|
36
|
+
path,
|
|
37
|
+
project,
|
|
38
|
+
} = this;
|
|
39
|
+
|
|
40
|
+
const fileContents = (await fs.promises.readFile(path)).toString();
|
|
41
|
+
const tasks = await converter.csv2jsonAsync(fileContents);
|
|
42
|
+
// CREATE TASKS
|
|
43
|
+
const data = tasks.map((task) => ({
|
|
44
|
+
content: task.content,
|
|
45
|
+
description: task.description,
|
|
46
|
+
project_id: project,
|
|
47
|
+
due: task.due,
|
|
48
|
+
priority: task.priority,
|
|
49
|
+
child_order: task.order,
|
|
50
|
+
labels: task.label_ids,
|
|
51
|
+
}));
|
|
52
|
+
const {
|
|
53
|
+
responses: createResponses,
|
|
54
|
+
tempIds,
|
|
55
|
+
} = await this.todoist.createTasks({
|
|
56
|
+
$,
|
|
57
|
+
data,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const childTasks = tasks.filter((task) => task.parent_id);
|
|
61
|
+
|
|
62
|
+
if (childTasks.length === 0) {
|
|
63
|
+
this.exportSummary($, tasks);
|
|
64
|
+
return {
|
|
65
|
+
createResponses,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// MOVE CHILD TASKS (set parent_id)
|
|
70
|
+
|
|
71
|
+
// `createTasks` returns an array object containing a `temp_id_mapping` property, which maps
|
|
72
|
+
// command `temp_id`s to real task `id`s. Combine these mappings into a single object.
|
|
73
|
+
const tempIdMapping = createResponses.reduce((mapping, response) => {
|
|
74
|
+
mapping = {
|
|
75
|
+
...mapping,
|
|
76
|
+
...response.temp_id_mapping,
|
|
77
|
+
};
|
|
78
|
+
return mapping;
|
|
79
|
+
}, {});
|
|
80
|
+
|
|
81
|
+
// Create mapping from ID of imported task to ID of new task in `project`, using `tempIdMapping`
|
|
82
|
+
const idMapping = tasks.reduce((mapping, task, index) => {
|
|
83
|
+
mapping[task.id] = tempIdMapping[tempIds[index]];
|
|
84
|
+
return mapping;
|
|
85
|
+
}, {});
|
|
86
|
+
|
|
87
|
+
const moveData = childTasks.map((task) => ({
|
|
88
|
+
id: idMapping[task.id],
|
|
89
|
+
parent_id: idMapping[task.parent_id],
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
const { responses: moveResponses } = await this.todoist.moveTasks({
|
|
93
|
+
$,
|
|
94
|
+
data: moveData,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
this.exportSummary($, tasks);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
createResponses,
|
|
101
|
+
moveResponses,
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-invite-user-to-project",
|
|
5
|
+
name: "Invite User To Project",
|
|
6
|
+
description: "Sends email to a person, inviting them to use one of your projects. [See the docs here](https://developer.todoist.com/sync/v8/#share-a-project)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
email: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
todoist,
|
|
20
|
+
"email",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run ({ $ }) {
|
|
25
|
+
const {
|
|
26
|
+
project,
|
|
27
|
+
email,
|
|
28
|
+
} = this;
|
|
29
|
+
const data = {
|
|
30
|
+
project_id: project,
|
|
31
|
+
email,
|
|
32
|
+
};
|
|
33
|
+
const resp = await this.todoist.shareProject({
|
|
34
|
+
$,
|
|
35
|
+
data,
|
|
36
|
+
});
|
|
37
|
+
$.export("$summary", "Successfully invited user");
|
|
38
|
+
return resp;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-list-filters",
|
|
5
|
+
name: "List Filters",
|
|
6
|
+
description: "Returns a list of all filters. [See the docs here](https://developer.todoist.com/sync/v8/#read-resources)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
db: "$.service.db",
|
|
12
|
+
},
|
|
13
|
+
async run ({ $ }) {
|
|
14
|
+
const resp = await this.todoist.getFilters({
|
|
15
|
+
$,
|
|
16
|
+
db: this.db,
|
|
17
|
+
});
|
|
18
|
+
$.export("$summary", `Successfully retrieved ${resp.length} filter${resp.length === 1
|
|
19
|
+
? ""
|
|
20
|
+
: "s"}`);
|
|
21
|
+
return resp;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-list-labels",
|
|
5
|
+
name: "List Labels",
|
|
6
|
+
description: "Returns a list of all labels. [See the docs here](https://developer.todoist.com/rest/v1/#get-all-labels)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
},
|
|
12
|
+
async run ({ $ }) {
|
|
13
|
+
const resp = await this.todoist.getLabels({
|
|
14
|
+
$,
|
|
15
|
+
});
|
|
16
|
+
$.export("$summary", `Successfully retrieved ${resp.length} label${resp.length === 1
|
|
17
|
+
? ""
|
|
18
|
+
: "s"}`);
|
|
19
|
+
return resp;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-list-project-comments",
|
|
5
|
+
name: "List Project Comments",
|
|
6
|
+
description: "Returns a list of comments for a project. [See the docs here](https://developer.todoist.com/rest/v1/#get-all-comments)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
project: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
todoist,
|
|
14
|
+
"project",
|
|
15
|
+
],
|
|
16
|
+
optional: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
async run ({ $ }) {
|
|
20
|
+
const params = {
|
|
21
|
+
project_id: this.project,
|
|
22
|
+
};
|
|
23
|
+
const resp = await this.todoist.getComments({
|
|
24
|
+
$,
|
|
25
|
+
params,
|
|
26
|
+
});
|
|
27
|
+
$.export("$summary", `Successfully retrieved ${resp.length} comment${resp.length === 1
|
|
28
|
+
? ""
|
|
29
|
+
: "s"}`);
|
|
30
|
+
return resp;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import todoist from "../../todoist.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "todoist-list-projects",
|
|
5
|
+
name: "List Projects",
|
|
6
|
+
description: "Returns a list of all projects. [See the docs here](https://developer.todoist.com/rest/v1/#get-all-projects)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
todoist,
|
|
11
|
+
},
|
|
12
|
+
async run ({ $ }) {
|
|
13
|
+
const resp = await this.todoist.getProjects({
|
|
14
|
+
$,
|
|
15
|
+
});
|
|
16
|
+
$.export("$summary", "Successfully retrieved projects");
|
|
17
|
+
$.export("$summary", `Successfully retrieved ${resp.length} project${resp.length === 1
|
|
18
|
+
? ""
|
|
19
|
+
: "s"}`);
|
|
20
|
+
return resp;
|
|
21
|
+
},
|
|
22
|
+
};
|