@pipedream/monday 0.3.3
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-board/create-board.mjs +80 -0
- package/actions/create-group/create-group.mjs +49 -0
- package/actions/create-item/create-item.mjs +74 -0
- package/actions/create-update/create-update.mjs +72 -0
- package/actions/update-item-name/update-item-name.mjs +62 -0
- package/common/constants.mjs +18 -0
- package/common/mutations.mjs +83 -0
- package/common/queries.mjs +65 -0
- package/common/utils.mjs +30 -0
- package/monday.app.mjs +335 -0
- package/package.json +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2020 Pipedream, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import monday from "../../monday.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "monday-create-board",
|
|
6
|
+
name: "Create Board",
|
|
7
|
+
description: "Creates a new board. [See the docs here](https://api.developer.monday.com/docs/boards#create-a-board)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
monday,
|
|
12
|
+
boardName: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
monday,
|
|
15
|
+
"boardName",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
boardKind: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
monday,
|
|
21
|
+
"boardKind",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
folderId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
monday,
|
|
27
|
+
"folderId",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
workspaceId: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
monday,
|
|
33
|
+
"workspaceId",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
templateId: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
monday,
|
|
39
|
+
"templateId",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
async run({ $ }) {
|
|
44
|
+
const {
|
|
45
|
+
boardName,
|
|
46
|
+
boardKind,
|
|
47
|
+
folderId,
|
|
48
|
+
workspaceId,
|
|
49
|
+
templateId,
|
|
50
|
+
} = this;
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
data,
|
|
54
|
+
errors,
|
|
55
|
+
error_code: errorCode,
|
|
56
|
+
error_message: errorMessage,
|
|
57
|
+
} =
|
|
58
|
+
await this.monday.createBoard({
|
|
59
|
+
boardName,
|
|
60
|
+
boardKind,
|
|
61
|
+
folderId: utils.emptyStrToUndefined(folderId),
|
|
62
|
+
workspaceId: utils.emptyStrToUndefined(workspaceId),
|
|
63
|
+
templateId: utils.emptyStrToUndefined(templateId),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (errors) {
|
|
67
|
+
throw new Error(`Failed to create board: ${errors[0].message}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (errorMessage) {
|
|
71
|
+
throw new Error(`Failed to create board [${errorCode}]: ${errorMessage}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const { id: boardId } = data.create_board;
|
|
75
|
+
|
|
76
|
+
$.export("$summary", `Successfully created a new board with ID: ${boardId}`);
|
|
77
|
+
|
|
78
|
+
return boardId;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import monday from "../../monday.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "monday-create-group",
|
|
5
|
+
name: "Create Group",
|
|
6
|
+
description: "Creates a new group in a specific board. [See the docs here](https://api.developer.monday.com/docs/groups-queries#create-a-group)",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
monday,
|
|
11
|
+
boardId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
monday,
|
|
14
|
+
"boardId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
groupName: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
monday,
|
|
20
|
+
"groupName",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
const {
|
|
26
|
+
data,
|
|
27
|
+
errors,
|
|
28
|
+
error_message: errorMessage,
|
|
29
|
+
} =
|
|
30
|
+
await this.monday.createGroup({
|
|
31
|
+
boardId: +this.boardId,
|
|
32
|
+
groupName: this.groupName,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (errors) {
|
|
36
|
+
throw new Error(`Failed to create group: ${errors[0].message}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (errorMessage) {
|
|
40
|
+
throw new Error(`Failed to create group: ${errorMessage}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const { id: groupId } = data.create_group;
|
|
44
|
+
|
|
45
|
+
$.export("$summary", `Successfully created a new group with ID: ${groupId}`);
|
|
46
|
+
|
|
47
|
+
return groupId;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import monday from "../../monday.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "monday-create-item",
|
|
6
|
+
name: "Create Item",
|
|
7
|
+
description: "Creates an item. [See the docs here](https://api.developer.monday.com/docs/items-queries#create-an-item)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
monday,
|
|
12
|
+
boardId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
monday,
|
|
15
|
+
"boardId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
groupId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
monday,
|
|
21
|
+
"groupId",
|
|
22
|
+
({ boardId }) => ({
|
|
23
|
+
boardId: +boardId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
itemName: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
monday,
|
|
30
|
+
"itemName",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
columnValues: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
monday,
|
|
36
|
+
"itemColumnValues",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
createLabels: {
|
|
40
|
+
propDefinition: [
|
|
41
|
+
monday,
|
|
42
|
+
"itemCreateLabels",
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async run({ $ }) {
|
|
47
|
+
const {
|
|
48
|
+
data,
|
|
49
|
+
errors,
|
|
50
|
+
error_message: errorMessage,
|
|
51
|
+
} =
|
|
52
|
+
await this.monday.createItem({
|
|
53
|
+
boardId: +this.boardId,
|
|
54
|
+
groupId: utils.emptyStrToUndefined(this.groupId),
|
|
55
|
+
itemName: utils.emptyStrToUndefined(this.itemName),
|
|
56
|
+
columnValues: utils.strinfied(this.columnValues),
|
|
57
|
+
createLabels: utils.emptyStrToUndefined(this.createLabels),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (errors) {
|
|
61
|
+
throw new Error(`Failed to create item: ${errors[0].message}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (errorMessage) {
|
|
65
|
+
throw new Error(`Failed to create item: ${errorMessage}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const { id: itemId } = data.create_item;
|
|
69
|
+
|
|
70
|
+
$.export("$summary", `Successfully created a new item with ID: ${itemId}`);
|
|
71
|
+
|
|
72
|
+
return itemId;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import monday from "../../monday.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "monday-create-update",
|
|
6
|
+
name: "Create an Update",
|
|
7
|
+
description: "Creates a new update. [See the docs here](https://api.developer.monday.com/docs/updates-queries#create-an-update)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
monday,
|
|
12
|
+
updateBody: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
monday,
|
|
15
|
+
"updateBody",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
boardId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
monday,
|
|
21
|
+
"boardId",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
itemId: {
|
|
25
|
+
optional: false,
|
|
26
|
+
propDefinition: [
|
|
27
|
+
monday,
|
|
28
|
+
"itemId",
|
|
29
|
+
({ boardId }) => ({
|
|
30
|
+
boardId: +boardId,
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
parentId: {
|
|
35
|
+
label: "Parent Update ID",
|
|
36
|
+
description: "The parent post identifier",
|
|
37
|
+
propDefinition: [
|
|
38
|
+
monday,
|
|
39
|
+
"updateId",
|
|
40
|
+
({ boardId }) => ({
|
|
41
|
+
boardId: +boardId,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async run({ $ }) {
|
|
47
|
+
const {
|
|
48
|
+
data,
|
|
49
|
+
errors,
|
|
50
|
+
error_message: errorMessage,
|
|
51
|
+
} =
|
|
52
|
+
await this.monday.createUpdate({
|
|
53
|
+
updateBody: this.updateBody,
|
|
54
|
+
itemId: +this.itemId,
|
|
55
|
+
parentId: utils.toNumber(this.parentId),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (errors) {
|
|
59
|
+
throw new Error(`Failed to create update: ${errors[0].message}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (errorMessage) {
|
|
63
|
+
throw new Error(`Failed to create update: ${errorMessage}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { id: updateId } = data.create_update;
|
|
67
|
+
|
|
68
|
+
$.export("$summary", `Successfully created a new update with ID: ${updateId}`);
|
|
69
|
+
|
|
70
|
+
return updateId;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import monday from "../../monday.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "monday-update-item-name",
|
|
5
|
+
name: "Update Item Name",
|
|
6
|
+
description: "Update an item's name. [See the docs here](https://api.developer.monday.com/docs/item-name)",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
monday,
|
|
11
|
+
boardId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
monday,
|
|
14
|
+
"boardId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
itemId: {
|
|
18
|
+
optional: false,
|
|
19
|
+
propDefinition: [
|
|
20
|
+
monday,
|
|
21
|
+
"itemId",
|
|
22
|
+
({ boardId }) => ({
|
|
23
|
+
boardId: +boardId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
itemName: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
monday,
|
|
30
|
+
"itemName",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
async run({ $ }) {
|
|
35
|
+
const {
|
|
36
|
+
data,
|
|
37
|
+
errors,
|
|
38
|
+
error_message: errorMessage,
|
|
39
|
+
} =
|
|
40
|
+
await this.monday.updateItemName({
|
|
41
|
+
boardId: +this.boardId,
|
|
42
|
+
itemId: +this.itemId,
|
|
43
|
+
columnValues: JSON.stringify({
|
|
44
|
+
name: this.itemName,
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (errors) {
|
|
49
|
+
throw new Error(`Failed to update the item name: ${errors[0].message}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (errorMessage) {
|
|
53
|
+
throw new Error(`Failed to update the item name: ${errorMessage}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { id: updateItemId } = data.change_multiple_column_values;
|
|
57
|
+
|
|
58
|
+
$.export("$summary", `Successfully updated item ${updateItemId} to name ${this.itemName}`);
|
|
59
|
+
|
|
60
|
+
return updateItemId;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const BOARD_KIND_OPTIONS = [
|
|
2
|
+
{
|
|
3
|
+
value: "public",
|
|
4
|
+
label: "Public boards",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
value: "private",
|
|
8
|
+
label: "Private boards",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
value: "share",
|
|
12
|
+
label: "Shareable boards",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
BOARD_KIND_OPTIONS,
|
|
18
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
createBoard: `
|
|
3
|
+
mutation createBoard (
|
|
4
|
+
$boardName: String!
|
|
5
|
+
$boardKind: BoardKind!
|
|
6
|
+
$folderId: Int
|
|
7
|
+
$workspaceId: Int
|
|
8
|
+
$templateId: Int
|
|
9
|
+
) {
|
|
10
|
+
create_board (
|
|
11
|
+
board_name: $boardName
|
|
12
|
+
board_kind: $boardKind
|
|
13
|
+
folder_id: $folderId
|
|
14
|
+
workspace_id: $workspaceId
|
|
15
|
+
template_id: $templateId
|
|
16
|
+
) {
|
|
17
|
+
id
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
createGroup: `
|
|
22
|
+
mutation createGroup (
|
|
23
|
+
$boardId: Int!
|
|
24
|
+
$groupName: String!
|
|
25
|
+
) {
|
|
26
|
+
create_group (
|
|
27
|
+
board_id: $boardId
|
|
28
|
+
group_name: $groupName
|
|
29
|
+
) {
|
|
30
|
+
id
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
createItem: `
|
|
35
|
+
mutation createItem (
|
|
36
|
+
$itemName: String
|
|
37
|
+
$boardId: Int!
|
|
38
|
+
$groupId: String
|
|
39
|
+
$columnValues: JSON
|
|
40
|
+
$createLabels: Boolean
|
|
41
|
+
) {
|
|
42
|
+
create_item (
|
|
43
|
+
item_name: $itemName
|
|
44
|
+
board_id: $boardId
|
|
45
|
+
group_id: $groupId
|
|
46
|
+
column_values: $columnValues
|
|
47
|
+
create_labels_if_missing: $createLabels
|
|
48
|
+
) {
|
|
49
|
+
id
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
createUpdate: `
|
|
54
|
+
mutation createUpdate (
|
|
55
|
+
$updateBody: String!
|
|
56
|
+
$itemId: Int
|
|
57
|
+
$parentId: Int
|
|
58
|
+
) {
|
|
59
|
+
create_update (
|
|
60
|
+
body: $updateBody
|
|
61
|
+
item_id: $itemId
|
|
62
|
+
parent_id: $parentId
|
|
63
|
+
) {
|
|
64
|
+
id
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`,
|
|
68
|
+
updateItemName: `
|
|
69
|
+
mutation updateItemName (
|
|
70
|
+
$boardId: Int!
|
|
71
|
+
$itemId: Int!
|
|
72
|
+
$columnValues: JSON!
|
|
73
|
+
) {
|
|
74
|
+
change_multiple_column_values (
|
|
75
|
+
board_id: $boardId
|
|
76
|
+
item_id: $itemId
|
|
77
|
+
column_values: $columnValues
|
|
78
|
+
) {
|
|
79
|
+
id
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
listBoards: `
|
|
3
|
+
query listBoards (
|
|
4
|
+
$page: Int = 1
|
|
5
|
+
) {
|
|
6
|
+
boards(
|
|
7
|
+
page: $page
|
|
8
|
+
state: all
|
|
9
|
+
order_by: created_at
|
|
10
|
+
) {
|
|
11
|
+
id
|
|
12
|
+
name
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`,
|
|
16
|
+
listWorkspacesBoards: `
|
|
17
|
+
query {
|
|
18
|
+
boards (
|
|
19
|
+
limit: 200
|
|
20
|
+
state: all
|
|
21
|
+
order_by: created_at
|
|
22
|
+
) {
|
|
23
|
+
workspace {
|
|
24
|
+
id
|
|
25
|
+
name
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
listGroupsBoards: `
|
|
31
|
+
query listGroups ($boardId: Int!) {
|
|
32
|
+
boards (ids: [$boardId]) {
|
|
33
|
+
groups {
|
|
34
|
+
id
|
|
35
|
+
title
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
listItemsBoard: `
|
|
41
|
+
query listItems ($boardId: Int!) {
|
|
42
|
+
boards (ids: [$boardId]) {
|
|
43
|
+
items {
|
|
44
|
+
id
|
|
45
|
+
name
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
listUpdatesBoard: `
|
|
51
|
+
query listUpdates (
|
|
52
|
+
$boardId: Int!,
|
|
53
|
+
$page: Int = 1
|
|
54
|
+
) {
|
|
55
|
+
boards (ids: [$boardId]) {
|
|
56
|
+
updates (
|
|
57
|
+
page: $page
|
|
58
|
+
) {
|
|
59
|
+
id
|
|
60
|
+
body
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function emptyStrToUndefined(value) {
|
|
2
|
+
const trimmed = typeof(value) === "string" && value.trim();
|
|
3
|
+
return trimmed === ""
|
|
4
|
+
? undefined
|
|
5
|
+
: value;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function strinfied(value) {
|
|
9
|
+
return typeof(value) === "object"
|
|
10
|
+
? JSON.stringify(value)
|
|
11
|
+
: emptyStrToUndefined(value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function strNumber(value) {
|
|
15
|
+
return Number.isInteger(parseInt(value, 10))
|
|
16
|
+
? parseInt(value, 10)
|
|
17
|
+
: emptyStrToUndefined(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toNumber(value) {
|
|
21
|
+
return typeof(value) === "number"
|
|
22
|
+
? value
|
|
23
|
+
: strNumber(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
emptyStrToUndefined,
|
|
28
|
+
strinfied,
|
|
29
|
+
toNumber,
|
|
30
|
+
};
|
package/monday.app.mjs
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import mondaySdk from "monday-sdk-js";
|
|
2
|
+
import uniqBy from "lodash.uniqby";
|
|
3
|
+
import map from "lodash.map";
|
|
4
|
+
import flatMap from "lodash.flatmap";
|
|
5
|
+
import constants from "./common/constants.mjs";
|
|
6
|
+
import mutations from "./common/mutations.mjs";
|
|
7
|
+
import queries from "./common/queries.mjs";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
type: "app",
|
|
11
|
+
app: "monday",
|
|
12
|
+
propDefinitions: {
|
|
13
|
+
boardId: {
|
|
14
|
+
type: "integer",
|
|
15
|
+
label: "Board ID",
|
|
16
|
+
description: "The board's unique identifier",
|
|
17
|
+
async options({ page }) {
|
|
18
|
+
return this.listBoardsOptions({
|
|
19
|
+
page: page + 1,
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
boardName: {
|
|
24
|
+
type: "string",
|
|
25
|
+
label: "Board Name",
|
|
26
|
+
description: "The board's name",
|
|
27
|
+
},
|
|
28
|
+
boardKind: {
|
|
29
|
+
type: "string",
|
|
30
|
+
label: "Board Kind",
|
|
31
|
+
description: "The board's kind (`public` / `private` / `share`)",
|
|
32
|
+
options: constants.BOARD_KIND_OPTIONS,
|
|
33
|
+
},
|
|
34
|
+
folderId: {
|
|
35
|
+
type: "integer",
|
|
36
|
+
label: "Folder ID",
|
|
37
|
+
description: "Board folder ID",
|
|
38
|
+
optional: true,
|
|
39
|
+
},
|
|
40
|
+
workspaceId: {
|
|
41
|
+
type: "integer",
|
|
42
|
+
label: "Workspace ID",
|
|
43
|
+
description: "Board workspace ID. If you don't specify this field, the board will be created in the **Main Workspace**",
|
|
44
|
+
optional: true,
|
|
45
|
+
async options() {
|
|
46
|
+
return this.listWorkspacesOptions();
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
templateId: {
|
|
50
|
+
type: "integer",
|
|
51
|
+
label: "Board Template ID",
|
|
52
|
+
description: "Board ID saved as a custom template. The ID can be obteined from the url in browser selecting the corresponding board (e.g. `https://{subdomain}.monday.com/boards/2419687965`) where `2419687965` is the ID of the template",
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
groupName: {
|
|
56
|
+
type: "string",
|
|
57
|
+
label: "Group Name",
|
|
58
|
+
description: "The name of the new group",
|
|
59
|
+
},
|
|
60
|
+
groupId: {
|
|
61
|
+
type: "string",
|
|
62
|
+
label: "Group ID",
|
|
63
|
+
description: "The group's unique identifier",
|
|
64
|
+
optional: true,
|
|
65
|
+
async options({ boardId }) {
|
|
66
|
+
return this.listGroupsOptions({
|
|
67
|
+
boardId,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
itemName: {
|
|
72
|
+
type: "string",
|
|
73
|
+
label: "Item Name",
|
|
74
|
+
description: "The item's name",
|
|
75
|
+
},
|
|
76
|
+
itemColumnValues: {
|
|
77
|
+
type: "object",
|
|
78
|
+
label: "Item Column Values",
|
|
79
|
+
description: "The column values of the new item",
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
82
|
+
itemCreateLabels: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
label: "Item Create Labels",
|
|
85
|
+
description: "Create Status/Dropdown labels if they're missing. (Requires permission to change board structure)",
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
updateBody: {
|
|
89
|
+
type: "string",
|
|
90
|
+
label: "Update Body",
|
|
91
|
+
description: "The update text",
|
|
92
|
+
},
|
|
93
|
+
itemId: {
|
|
94
|
+
type: "integer",
|
|
95
|
+
label: "Item ID",
|
|
96
|
+
description: "The item's unique identifier",
|
|
97
|
+
optional: true,
|
|
98
|
+
async options({ boardId }) {
|
|
99
|
+
return this.listItemsOptions({
|
|
100
|
+
boardId,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
updateId: {
|
|
105
|
+
type: "integer",
|
|
106
|
+
label: "Update ID",
|
|
107
|
+
description: "The update's unique identifier",
|
|
108
|
+
optional: true,
|
|
109
|
+
async options({
|
|
110
|
+
page, boardId,
|
|
111
|
+
}) {
|
|
112
|
+
return this.listUpdatesOptions({
|
|
113
|
+
boardId,
|
|
114
|
+
page: page + 1,
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
methods: {
|
|
120
|
+
async makeRequest({
|
|
121
|
+
query, options,
|
|
122
|
+
}) {
|
|
123
|
+
const monday = mondaySdk();
|
|
124
|
+
monday.setToken(this.$auth.api_key);
|
|
125
|
+
return monday.api(query, options);
|
|
126
|
+
},
|
|
127
|
+
async createBoard(variables) {
|
|
128
|
+
return this.makeRequest({
|
|
129
|
+
query: mutations.createBoard,
|
|
130
|
+
options: {
|
|
131
|
+
variables,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
async createGroup(variables) {
|
|
136
|
+
return this.makeRequest({
|
|
137
|
+
query: mutations.createGroup,
|
|
138
|
+
options: {
|
|
139
|
+
variables,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
async createItem(variables) {
|
|
144
|
+
return this.makeRequest({
|
|
145
|
+
query: mutations.createItem,
|
|
146
|
+
options: {
|
|
147
|
+
variables,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
async createUpdate(variables) {
|
|
152
|
+
return this.makeRequest({
|
|
153
|
+
query: mutations.createUpdate,
|
|
154
|
+
options: {
|
|
155
|
+
variables,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
async updateItemName(variables) {
|
|
160
|
+
return this.makeRequest({
|
|
161
|
+
query: mutations.updateItemName,
|
|
162
|
+
options: {
|
|
163
|
+
variables,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
async listBoards(variables) {
|
|
168
|
+
return this.makeRequest({
|
|
169
|
+
query: queries.listBoards,
|
|
170
|
+
options: {
|
|
171
|
+
variables,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
async listItemsBoard(variables) {
|
|
176
|
+
return this.makeRequest({
|
|
177
|
+
query: queries.listItemsBoard,
|
|
178
|
+
options: {
|
|
179
|
+
variables,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
async listUpdatesBoard(variables) {
|
|
184
|
+
return this.makeRequest({
|
|
185
|
+
query: queries.listUpdatesBoard,
|
|
186
|
+
options: {
|
|
187
|
+
variables,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
async listWorkspacesBoards() {
|
|
192
|
+
return this.makeRequest({
|
|
193
|
+
query: queries.listWorkspacesBoards,
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
async listGroupsBoards(variables) {
|
|
197
|
+
return this.makeRequest({
|
|
198
|
+
query: queries.listGroupsBoards,
|
|
199
|
+
options: {
|
|
200
|
+
variables,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
async listBoardsOptions(variables) {
|
|
205
|
+
const {
|
|
206
|
+
data,
|
|
207
|
+
errors,
|
|
208
|
+
error_message: errorMessage,
|
|
209
|
+
} = await this.listBoards(variables);
|
|
210
|
+
|
|
211
|
+
if (errors) {
|
|
212
|
+
throw new Error(`Error fetching boards: ${errors[0].message}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (errorMessage) {
|
|
216
|
+
throw new Error(`Failure fetching boards: ${errorMessage}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const { boards } = data;
|
|
220
|
+
return boards
|
|
221
|
+
.map(({
|
|
222
|
+
id, name,
|
|
223
|
+
}) => ({
|
|
224
|
+
label: name,
|
|
225
|
+
value: id,
|
|
226
|
+
}));
|
|
227
|
+
},
|
|
228
|
+
async listWorkspacesOptions() {
|
|
229
|
+
const {
|
|
230
|
+
data,
|
|
231
|
+
errors,
|
|
232
|
+
error_message: errorMessage,
|
|
233
|
+
} = await this.listWorkspacesBoards();
|
|
234
|
+
|
|
235
|
+
if (errors) {
|
|
236
|
+
throw new Error(`Error listing workspaces: ${errors[0].message}`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (errorMessage) {
|
|
240
|
+
throw new Error(`Failed to list workspaces: ${errorMessage}`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const { boards } = data;
|
|
244
|
+
const options =
|
|
245
|
+
boards
|
|
246
|
+
.filter(({ workspace }) => workspace)
|
|
247
|
+
.map(({ workspace }) => ({
|
|
248
|
+
label: workspace.name,
|
|
249
|
+
value: workspace.id,
|
|
250
|
+
}));
|
|
251
|
+
return uniqBy(options, "value");
|
|
252
|
+
},
|
|
253
|
+
async listGroupsOptions(variables) {
|
|
254
|
+
const {
|
|
255
|
+
errors,
|
|
256
|
+
data,
|
|
257
|
+
error_message: errorMessage,
|
|
258
|
+
} = await this.listGroupsBoards(variables);
|
|
259
|
+
|
|
260
|
+
if (errors) {
|
|
261
|
+
throw new Error(`Failed to list groups: ${errors[0].message}`);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (errorMessage) {
|
|
265
|
+
throw new Error(`Failed to list groups: ${errorMessage}`);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const { boards } = data;
|
|
269
|
+
const options =
|
|
270
|
+
flatMap(boards, ({ groups }) =>
|
|
271
|
+
map(groups, ({
|
|
272
|
+
id, title,
|
|
273
|
+
}) =>
|
|
274
|
+
({
|
|
275
|
+
value: id,
|
|
276
|
+
label: title,
|
|
277
|
+
})));
|
|
278
|
+
return options;
|
|
279
|
+
},
|
|
280
|
+
async listItemsOptions(variables) {
|
|
281
|
+
const {
|
|
282
|
+
errors,
|
|
283
|
+
data,
|
|
284
|
+
error_message: errorMessage,
|
|
285
|
+
} = await this.listItemsBoard(variables);
|
|
286
|
+
|
|
287
|
+
if (errors) {
|
|
288
|
+
throw new Error(`Failed to list items: ${errors[0].message}`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (errorMessage) {
|
|
292
|
+
throw new Error(`Failed to list items: ${errorMessage}`);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const { boards } = data;
|
|
296
|
+
const options =
|
|
297
|
+
flatMap(boards, ({ items }) =>
|
|
298
|
+
map(items, ({
|
|
299
|
+
id, name,
|
|
300
|
+
}) =>
|
|
301
|
+
({
|
|
302
|
+
value: id,
|
|
303
|
+
label: name,
|
|
304
|
+
})));
|
|
305
|
+
return options;
|
|
306
|
+
},
|
|
307
|
+
async listUpdatesOptions(variables) {
|
|
308
|
+
const {
|
|
309
|
+
errors,
|
|
310
|
+
data,
|
|
311
|
+
error_message: errorMessage,
|
|
312
|
+
} = await this.listUpdatesBoard(variables);
|
|
313
|
+
|
|
314
|
+
if (errors) {
|
|
315
|
+
throw new Error(`Failed to list updates: ${errors[0].message}`);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (errorMessage) {
|
|
319
|
+
throw new Error(`Failed to list updates: ${errorMessage}`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const { boards } = data;
|
|
323
|
+
const options =
|
|
324
|
+
flatMap(boards, ({ updates }) =>
|
|
325
|
+
map(updates, ({
|
|
326
|
+
id, body,
|
|
327
|
+
}) =>
|
|
328
|
+
({
|
|
329
|
+
value: id,
|
|
330
|
+
label: body,
|
|
331
|
+
})));
|
|
332
|
+
return options;
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipedream/monday",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Pipedream Monday Components",
|
|
5
|
+
"main": "monday.app.mjs",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pipedream",
|
|
8
|
+
"monday"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://pipedream.com/apps/monday",
|
|
11
|
+
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"lodash.flatmap": "^4.5.0",
|
|
19
|
+
"lodash.map": "^4.6.0",
|
|
20
|
+
"lodash.uniqby": "^4.7.0",
|
|
21
|
+
"monday-sdk-js": "^0.1.3"
|
|
22
|
+
}
|
|
23
|
+
}
|