Skip to content

Commit 5ce7337

Browse files
luancazarinelcaresia
authored andcommitted
New Components - checkvist (#14481)
* checkvist init * [Components] checkvist #13230 Sources - New List - New List Item Actions - Create List Item - Create Multiple List Items - Create New List * pnpm update
1 parent 6956f98 commit 5ce7337

File tree

13 files changed

+527
-4
lines changed

13 files changed

+527
-4
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import checkvist from "../../checkvist.app.mjs";
2+
import { STATUS_OPTIONS } from "../../common/constants.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
4+
5+
export default {
6+
key: "checkvist-create-list-item",
7+
name: "Create List Item",
8+
description: "Creates a new list item within a specified list. [See the documentation](https://checkvist.com/auth/api)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
checkvist,
13+
listId: {
14+
propDefinition: [
15+
checkvist,
16+
"listId",
17+
],
18+
},
19+
content: {
20+
type: "string",
21+
label: "Content",
22+
description: "Block of text containing items to add. Indentations indicate nested list items.",
23+
},
24+
parentId: {
25+
propDefinition: [
26+
checkvist,
27+
"parentId",
28+
({ listId }) => ({
29+
listId,
30+
}),
31+
],
32+
optional: true,
33+
},
34+
tags: {
35+
type: "string[]",
36+
label: "Tags",
37+
description: "An array of tags.",
38+
optional: true,
39+
},
40+
dueDate: {
41+
type: "string",
42+
label: "Due Date",
43+
description: "Due for the task, in Checkvist's smart syntax format.",
44+
optional: true,
45+
},
46+
position: {
47+
type: "integer",
48+
label: "Position",
49+
description: "1-based position of the task (omit to add to the end of the list).",
50+
optional: true,
51+
},
52+
status: {
53+
type: "string",
54+
label: "Status",
55+
description: "Task status",
56+
options: STATUS_OPTIONS,
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.checkvist.createListItem({
62+
$,
63+
listId: this.listId,
64+
data: {
65+
task: {
66+
content: this.content,
67+
parent_id: this.parentId || 0,
68+
tags: parseObject(this.tags)?.join(","),
69+
due_date: this.dueDate,
70+
position: this.position,
71+
status: this.status,
72+
},
73+
},
74+
});
75+
76+
$.export("$summary", `Successfully created a new list item in list with ID ${this.listId}`);
77+
return response;
78+
},
79+
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import checkvist from "../../checkvist.app.mjs";
2+
import {
3+
SEPARATE_LINE_OPTIONS, STATUS_OPTIONS,
4+
} from "../../common/constants.mjs";
5+
6+
export default {
7+
key: "checkvist-create-multiple-list-items",
8+
name: "Create Multiple List Items",
9+
description: "Enables creation of several list items at once from a block of text. Indentations in the text indicate nested list items. [See the documentation](https://checkvist.com/auth/api)",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
checkvist,
14+
listId: {
15+
propDefinition: [
16+
checkvist,
17+
"listId",
18+
],
19+
},
20+
itemsContent: {
21+
type: "string",
22+
label: "Content Items",
23+
description: "list items in the same format, as supported by [Checkvist's import function](https://checkvist.com/help#import).",
24+
},
25+
parentId: {
26+
propDefinition: [
27+
checkvist,
28+
"parentId",
29+
({ listId }) => ({
30+
listId,
31+
}),
32+
],
33+
optional: true,
34+
},
35+
position: {
36+
type: "integer",
37+
label: "Position",
38+
description: "1-based position of the task (omit to add to the end of the list).",
39+
optional: true,
40+
},
41+
parseTasks: {
42+
type: "boolean",
43+
label: "Parse Tasks",
44+
description: "If true, recognize **^due** and **#tags** syntax in imported list items",
45+
},
46+
separateWithEmptyLine: {
47+
type: "string",
48+
label: "Separate With Empty Line",
49+
description: "Select value for List items separator.",
50+
options: SEPARATE_LINE_OPTIONS,
51+
},
52+
status: {
53+
type: "string",
54+
label: "Status",
55+
description: "Task status",
56+
options: STATUS_OPTIONS,
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.checkvist.createMultipleListItems({
62+
$,
63+
listId: this.listId,
64+
data: {
65+
import_content: this.itemsContent,
66+
parent_id: this.parentId,
67+
position: this.position,
68+
parse_tasks: this.parseTasks,
69+
separate_with_empty_line: this.separateWithEmptyLine,
70+
status: this.status,
71+
},
72+
});
73+
74+
$.export("$summary", "Successfully created multiple list items");
75+
return response;
76+
},
77+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import checkvist from "../../checkvist.app.mjs";
2+
3+
export default {
4+
key: "checkvist-create-new-list",
5+
name: "Create New List",
6+
description: "Creates a new list in Checkvist. [See the documentation](https://checkvist.com/auth/api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
checkvist,
11+
name: {
12+
type: "string",
13+
label: "List Name",
14+
description: "Name of the new list to be created",
15+
},
16+
public: {
17+
type: "boolean",
18+
label: "Public",
19+
description: "true for checklist which can be accessed in read-only mode by anyone. Access to such checklists doesn't require authentication.",
20+
optional: true,
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.checkvist.createList({
25+
$,
26+
data: {
27+
name: this.name,
28+
public: this.public,
29+
},
30+
});
31+
32+
$.export("$summary", `Successfully created a new list: ${this.name}`);
33+
return response;
34+
},
35+
};
Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,101 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "checkvist",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
listId: {
8+
type: "string",
9+
label: "List ID",
10+
description: "Select a list to monitor for new items",
11+
async options() {
12+
const lists = await this.getLists({
13+
params: {
14+
skip_stats: true,
15+
},
16+
});
17+
return lists.map(({
18+
id: value, name: label,
19+
}) => ({
20+
label,
21+
value,
22+
}));
23+
},
24+
},
25+
parentId: {
26+
type: "string",
27+
label: "Parent task ID",
28+
description: "Empty for root-level tasks",
29+
async options({ listId }) {
30+
const items = await this.getListItems({
31+
listId,
32+
});
33+
return items.map(({
34+
id: value, content: label,
35+
}) => ({
36+
label,
37+
value,
38+
}));
39+
},
40+
},
41+
},
542
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
43+
_baseUrl() {
44+
return "https://checkvist.com";
45+
},
46+
_auth() {
47+
return {
48+
username: `${this.$auth.username}`,
49+
password: `${this.$auth.api_key}`,
50+
};
51+
},
52+
_makeRequest({
53+
$ = this, path, ...opts
54+
}) {
55+
return axios($, {
56+
url: this._baseUrl() + path,
57+
auth: this._auth(),
58+
...opts,
59+
});
60+
},
61+
getLists(opts = {}) {
62+
return this._makeRequest({
63+
path: "/checklists.json",
64+
...opts,
65+
});
66+
},
67+
getListItems({
68+
listId, ...opts
69+
}) {
70+
return this._makeRequest({
71+
path: `/checklists/${listId}/tasks.json`,
72+
...opts,
73+
});
74+
},
75+
createList(opts = {}) {
76+
return this._makeRequest({
77+
method: "POST",
78+
path: "/checklists.json",
79+
...opts,
80+
});
81+
},
82+
createListItem({
83+
listId, ...opts
84+
}) {
85+
return this._makeRequest({
86+
method: "POST",
87+
path: `/checklists/${listId}/tasks.json`,
88+
...opts,
89+
});
90+
},
91+
createMultipleListItems({
92+
listId, ...opts
93+
}) {
94+
return this._makeRequest({
95+
method: "POST",
96+
path: `/checklists/${listId}/import.json`,
97+
...opts,
98+
});
999
},
10100
},
11101
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const STATUS_OPTIONS = [
2+
{
3+
label: "Open",
4+
value: "0",
5+
},
6+
{
7+
label: "Closed",
8+
value: "1",
9+
},
10+
{
11+
label: "Invalidated",
12+
value: "2",
13+
},
14+
];
15+
16+
export const SEPARATE_LINE_OPTIONS = [
17+
{
18+
label: "Separate with empty line",
19+
value: "singleItem",
20+
},
21+
{
22+
label: "One item per line",
23+
value: "multipleItems",
24+
},
25+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

components/checkvist/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@pipedream/checkvist",
3+
"version": "0.1.0",
4+
"description": "Pipedream Checkvist Components",
5+
"main": "checkvist.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"checkvist"
9+
],
10+
"homepage": "https://pipedream.com/apps/checkvist",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
13+
"publishConfig": {
14+
"access": "public"
15+
},
16+
"dependencies": {
17+
"@pipedream/platform": "^3.0.3"
18+
}
19+
}

0 commit comments

Comments
 (0)