@pipedream/motion 0.0.1 → 0.1.0
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/actions/create-task/create-task.mjs +153 -0
- package/actions/delete-task/delete-task.mjs +32 -0
- package/actions/get-task/get-task.mjs +32 -0
- package/actions/move-workspace/move-workspace.mjs +51 -0
- package/actions/update-task/update-task.mjs +156 -0
- package/motion.app.mjs +260 -0
- package/package.json +5 -5
- package/sources/task-status-updated/task-status-updated.mjs +62 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import motion from "../../motion.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "motion-create-task",
|
|
5
|
+
name: "Create Task",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "Create a new task. [See the documentation](https://docs.usemotion.com/docs/motion-rest-api/0846d1205f9b3-create-task)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
motion,
|
|
11
|
+
workspaceId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
motion,
|
|
14
|
+
"workspaceId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
projectId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
motion,
|
|
20
|
+
"projectId",
|
|
21
|
+
({ workspaceId }) => ({
|
|
22
|
+
workspaceId,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
optional: true,
|
|
26
|
+
},
|
|
27
|
+
dueDate: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
motion,
|
|
30
|
+
"dueDate",
|
|
31
|
+
],
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
duration: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
motion,
|
|
37
|
+
"duration",
|
|
38
|
+
],
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
name: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
motion,
|
|
44
|
+
"name",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
description: {
|
|
48
|
+
propDefinition: [
|
|
49
|
+
motion,
|
|
50
|
+
"description",
|
|
51
|
+
],
|
|
52
|
+
optional: true,
|
|
53
|
+
},
|
|
54
|
+
priority: {
|
|
55
|
+
propDefinition: [
|
|
56
|
+
motion,
|
|
57
|
+
"priority",
|
|
58
|
+
],
|
|
59
|
+
optional: true,
|
|
60
|
+
},
|
|
61
|
+
assigneeId: {
|
|
62
|
+
propDefinition: [
|
|
63
|
+
motion,
|
|
64
|
+
"assigneeId",
|
|
65
|
+
({ workspaceId }) => ({
|
|
66
|
+
workspaceId,
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
labels: {
|
|
72
|
+
propDefinition: [
|
|
73
|
+
motion,
|
|
74
|
+
"labelId",
|
|
75
|
+
({ workspaceId }) => ({
|
|
76
|
+
workspaceId,
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
optional: true,
|
|
80
|
+
},
|
|
81
|
+
status: {
|
|
82
|
+
propDefinition: [
|
|
83
|
+
motion,
|
|
84
|
+
"status",
|
|
85
|
+
({ workspaceId }) => ({
|
|
86
|
+
workspaceId,
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
reloadProps: true,
|
|
90
|
+
optional: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
async additionalProps() {
|
|
94
|
+
const props = {};
|
|
95
|
+
if (this.status === "Auto-Scheduled") {
|
|
96
|
+
props.startDate = {
|
|
97
|
+
type: "string",
|
|
98
|
+
label: "Auto Scheduled Start Date",
|
|
99
|
+
description: "ISO 8601 Date which is trimmed to the start of the day passed. Default: `2023-06-28T06:00:00.000Z` Example: `2023-06-28`.",
|
|
100
|
+
optional: true,
|
|
101
|
+
};
|
|
102
|
+
props.deadlineType = {
|
|
103
|
+
type: "string",
|
|
104
|
+
label: "Auto Scheduled Deadline Type",
|
|
105
|
+
description: "The type of the deadline.",
|
|
106
|
+
options: [
|
|
107
|
+
"HARD",
|
|
108
|
+
"SOFT",
|
|
109
|
+
"NONE",
|
|
110
|
+
],
|
|
111
|
+
optional: true,
|
|
112
|
+
};
|
|
113
|
+
props.schedule = {
|
|
114
|
+
type: "string",
|
|
115
|
+
label: "Schedule",
|
|
116
|
+
description: "Schedule the task must adhere to. Schedule MUST be 'Work Hours' if scheduling the task for another user.",
|
|
117
|
+
default: "Work Hours",
|
|
118
|
+
optional: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return props;
|
|
122
|
+
},
|
|
123
|
+
async run({ $ }) {
|
|
124
|
+
const {
|
|
125
|
+
motion,
|
|
126
|
+
status,
|
|
127
|
+
startDate,
|
|
128
|
+
deadlineType,
|
|
129
|
+
duration,
|
|
130
|
+
schedule,
|
|
131
|
+
...data
|
|
132
|
+
} = this;
|
|
133
|
+
|
|
134
|
+
if (status === "Auto-Scheduled") {
|
|
135
|
+
data.autoScheduled = {};
|
|
136
|
+
if (startDate) data.autoScheduled.startDate = startDate;
|
|
137
|
+
if (deadlineType) data.autoScheduled.deadlineType = deadlineType;
|
|
138
|
+
if (schedule) data.autoScheduled.schedule = schedule;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const response = await motion.createTask({
|
|
142
|
+
$,
|
|
143
|
+
data: {
|
|
144
|
+
...data,
|
|
145
|
+
duration: parseInt(duration) || duration,
|
|
146
|
+
status,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
$.export("$summary", `The task with Id: ${response.id} was successfully created!`);
|
|
151
|
+
return response;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import motion from "../../motion.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "motion-delete-task",
|
|
5
|
+
name: "Delete Task",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "Delete a specific task by Id. [See the documentation](https://docs.usemotion.com/docs/motion-rest-api/963b35f93846f-delete-a-task)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
motion,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
motion,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const {
|
|
20
|
+
motion,
|
|
21
|
+
taskId,
|
|
22
|
+
} = this;
|
|
23
|
+
|
|
24
|
+
const response = await motion.deleteTask({
|
|
25
|
+
$,
|
|
26
|
+
taskId,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
$.export("$summary", `The task with Id: ${taskId} was successfully deleted!`);
|
|
30
|
+
return response;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import motion from "../../motion.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "motion-get-task",
|
|
5
|
+
name: "Retrieve Task",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "Retrieve a specific task by Id. [See the documentation](https://docs.usemotion.com/docs/motion-rest-api/3e8c65ed58693-retrieve-a-task)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
motion,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
motion,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const {
|
|
20
|
+
motion,
|
|
21
|
+
taskId,
|
|
22
|
+
} = this;
|
|
23
|
+
|
|
24
|
+
const response = await motion.getTask({
|
|
25
|
+
$,
|
|
26
|
+
taskId,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
$.export("$summary", `The task with Id: ${taskId} was successfully fetched!`);
|
|
30
|
+
return response;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import motion from "../../motion.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "motion-move-workspace",
|
|
5
|
+
name: "Move Workspace",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "Move a specific task to another workspace. When moving tasks from one workspace to another, the tasks project, status, and label(s) and assignee will all be reset. [See the documentation](https://docs.usemotion.com/docs/motion-rest-api/0440c0ba81f10-move-workspace)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
motion,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
motion,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
workspaceId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
motion,
|
|
20
|
+
"workspaceId",
|
|
21
|
+
],
|
|
22
|
+
description: "The id of the workspace where the task is going.",
|
|
23
|
+
},
|
|
24
|
+
assigneeId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
motion,
|
|
27
|
+
"assigneeId",
|
|
28
|
+
({ workspaceId }) => ({
|
|
29
|
+
workspaceId,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
async run({ $ }) {
|
|
36
|
+
const {
|
|
37
|
+
motion,
|
|
38
|
+
taskId,
|
|
39
|
+
...data
|
|
40
|
+
} = this;
|
|
41
|
+
|
|
42
|
+
const response = await motion.moveWorkspace({
|
|
43
|
+
$,
|
|
44
|
+
taskId,
|
|
45
|
+
data,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
$.export("$summary", `The task with Id: ${taskId} was successfully moved!`);
|
|
49
|
+
return response;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import motion from "../../motion.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "motion-update-task",
|
|
5
|
+
name: "Update Task",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "Update a specific task. [See the documentation](https://docs.usemotion.com/docs/motion-rest-api/a2b2ce881ce26-update-a-task)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
motion,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
motion,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
motion,
|
|
20
|
+
"name",
|
|
21
|
+
],
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
dueDate: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
motion,
|
|
27
|
+
"dueDate",
|
|
28
|
+
],
|
|
29
|
+
optional: true,
|
|
30
|
+
},
|
|
31
|
+
duration: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
motion,
|
|
34
|
+
"duration",
|
|
35
|
+
],
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
projectId: {
|
|
39
|
+
propDefinition: [
|
|
40
|
+
motion,
|
|
41
|
+
"projectId",
|
|
42
|
+
({ taskId }) => ({
|
|
43
|
+
taskId,
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
description: {
|
|
49
|
+
propDefinition: [
|
|
50
|
+
motion,
|
|
51
|
+
"description",
|
|
52
|
+
],
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
priority: {
|
|
56
|
+
propDefinition: [
|
|
57
|
+
motion,
|
|
58
|
+
"priority",
|
|
59
|
+
],
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
assigneeId: {
|
|
63
|
+
propDefinition: [
|
|
64
|
+
motion,
|
|
65
|
+
"assigneeId",
|
|
66
|
+
({ taskId }) => ({
|
|
67
|
+
taskId,
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
optional: true,
|
|
71
|
+
},
|
|
72
|
+
labels: {
|
|
73
|
+
propDefinition: [
|
|
74
|
+
motion,
|
|
75
|
+
"labelId",
|
|
76
|
+
({ taskId }) => ({
|
|
77
|
+
taskId,
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
82
|
+
status: {
|
|
83
|
+
propDefinition: [
|
|
84
|
+
motion,
|
|
85
|
+
"status",
|
|
86
|
+
({ taskId }) => ({
|
|
87
|
+
taskId,
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
reloadProps: true,
|
|
91
|
+
optional: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
async additionalProps() {
|
|
95
|
+
const props = {};
|
|
96
|
+
if (this.status === "Auto-Scheduled") {
|
|
97
|
+
props.startDate = {
|
|
98
|
+
type: "string",
|
|
99
|
+
label: "Auto Scheduled Start Date",
|
|
100
|
+
description: "ISO 8601 Date which is trimmed to the start of the day passed. Default: `2023-06-28T06:00:00.000Z` Example: `2023-06-28`.",
|
|
101
|
+
optional: true,
|
|
102
|
+
};
|
|
103
|
+
props.deadlineType = {
|
|
104
|
+
type: "string",
|
|
105
|
+
label: "Auto Scheduled Deadline Type",
|
|
106
|
+
description: "The type of the deadline.",
|
|
107
|
+
options: [
|
|
108
|
+
"HARD",
|
|
109
|
+
"SOFT",
|
|
110
|
+
"NONE",
|
|
111
|
+
],
|
|
112
|
+
optional: true,
|
|
113
|
+
};
|
|
114
|
+
props.schedule = {
|
|
115
|
+
type: "string",
|
|
116
|
+
label: "Schedule",
|
|
117
|
+
description: "Schedule the task must adhere to. Schedule MUST be 'Work Hours' if scheduling the task for another user.",
|
|
118
|
+
default: "Work Hours",
|
|
119
|
+
optional: true,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return props;
|
|
123
|
+
},
|
|
124
|
+
async run({ $ }) {
|
|
125
|
+
const {
|
|
126
|
+
motion,
|
|
127
|
+
taskId,
|
|
128
|
+
status,
|
|
129
|
+
startDate,
|
|
130
|
+
deadlineType,
|
|
131
|
+
duration,
|
|
132
|
+
schedule,
|
|
133
|
+
...data
|
|
134
|
+
} = this;
|
|
135
|
+
|
|
136
|
+
if (status === "Auto-Scheduled") {
|
|
137
|
+
data.autoScheduled = {};
|
|
138
|
+
if (startDate) data.autoScheduled.startDate = startDate;
|
|
139
|
+
if (deadlineType) data.autoScheduled.deadlineType = deadlineType;
|
|
140
|
+
if (schedule) data.autoScheduled.schedule = schedule;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const response = await motion.updateTask({
|
|
144
|
+
$,
|
|
145
|
+
taskId,
|
|
146
|
+
data: {
|
|
147
|
+
...data,
|
|
148
|
+
duration: parseInt(duration) || duration,
|
|
149
|
+
status,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
$.export("$summary", `The task with Id: ${taskId} was successfully updated!`);
|
|
154
|
+
return response;
|
|
155
|
+
},
|
|
156
|
+
};
|
package/motion.app.mjs
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: "app",
|
|
5
|
+
app: "motion",
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
assigneeId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Assignee Id",
|
|
10
|
+
description: "The user id the task should be assigned to.",
|
|
11
|
+
async options({
|
|
12
|
+
workspaceId, taskId,
|
|
13
|
+
}) {
|
|
14
|
+
if (taskId) {
|
|
15
|
+
const task = await this.getTask({
|
|
16
|
+
taskId,
|
|
17
|
+
});
|
|
18
|
+
workspaceId = task.workspace.id;
|
|
19
|
+
}
|
|
20
|
+
const { users } = await this.listUsers({
|
|
21
|
+
params: {
|
|
22
|
+
workspaceId,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return users.map(({
|
|
27
|
+
id: value, name: label,
|
|
28
|
+
}) => ({
|
|
29
|
+
label,
|
|
30
|
+
value,
|
|
31
|
+
}));
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
description: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "Description",
|
|
37
|
+
description: "Input as GitHub Flavored Markdown.",
|
|
38
|
+
},
|
|
39
|
+
dueDate: {
|
|
40
|
+
type: "string",
|
|
41
|
+
label: "Due Date",
|
|
42
|
+
description: "ISO 8601 Due date on the task. REQUIRED for scheduled tasks Example: `2023-06-28T10:11:14.320-06:00`",
|
|
43
|
+
},
|
|
44
|
+
duration: {
|
|
45
|
+
type: "string",
|
|
46
|
+
label: "Duration",
|
|
47
|
+
description: "A duration can be one of the following... `NONE`, `REMINDER`, or a integer greater than 0.",
|
|
48
|
+
},
|
|
49
|
+
labelId: {
|
|
50
|
+
type: "string[]",
|
|
51
|
+
label: "Labels",
|
|
52
|
+
description: "A list of labels to the task.",
|
|
53
|
+
async options({
|
|
54
|
+
workspaceId, taskId,
|
|
55
|
+
}) {
|
|
56
|
+
if (taskId) {
|
|
57
|
+
const task = await this.getTask({
|
|
58
|
+
taskId,
|
|
59
|
+
});
|
|
60
|
+
workspaceId = task.workspace.id;
|
|
61
|
+
}
|
|
62
|
+
const { workspaces } = await this.listWorkspaces();
|
|
63
|
+
|
|
64
|
+
const labels = workspaces.filter((workspace) => workspace.id === workspaceId)[0].labels;
|
|
65
|
+
|
|
66
|
+
return labels.map((label) => label.name);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
name: {
|
|
70
|
+
type: "string",
|
|
71
|
+
label: "Name",
|
|
72
|
+
description: "Name / title of the task.",
|
|
73
|
+
},
|
|
74
|
+
priority: {
|
|
75
|
+
type: "string",
|
|
76
|
+
label: "Priority",
|
|
77
|
+
description: "The level priority of the task.",
|
|
78
|
+
options: [
|
|
79
|
+
"ASAP",
|
|
80
|
+
"HIGH",
|
|
81
|
+
"MEDIUM",
|
|
82
|
+
"LOW",
|
|
83
|
+
],
|
|
84
|
+
default: "MEDIUM",
|
|
85
|
+
},
|
|
86
|
+
projectId: {
|
|
87
|
+
type: "string",
|
|
88
|
+
label: "Project Id",
|
|
89
|
+
description: "The id of the project.",
|
|
90
|
+
async options({
|
|
91
|
+
workspaceId, taskId,
|
|
92
|
+
}) {
|
|
93
|
+
if (taskId) {
|
|
94
|
+
const task = await this.getTask({
|
|
95
|
+
taskId,
|
|
96
|
+
});
|
|
97
|
+
workspaceId = task.workspace.id;
|
|
98
|
+
}
|
|
99
|
+
const { projects } = await this.listProjects({
|
|
100
|
+
params: {
|
|
101
|
+
workspaceId,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return projects.map(({
|
|
106
|
+
id: value, name: label,
|
|
107
|
+
}) => ({
|
|
108
|
+
label,
|
|
109
|
+
value,
|
|
110
|
+
}));
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
status: {
|
|
114
|
+
type: "string",
|
|
115
|
+
label: "Status",
|
|
116
|
+
description: "The id of the task status.",
|
|
117
|
+
async options({
|
|
118
|
+
workspaceId, taskId,
|
|
119
|
+
}) {
|
|
120
|
+
if (taskId) {
|
|
121
|
+
const task = await this.getTask({
|
|
122
|
+
taskId,
|
|
123
|
+
});
|
|
124
|
+
workspaceId = task.workspace.id;
|
|
125
|
+
}
|
|
126
|
+
const statuses = await this.listStatuses({
|
|
127
|
+
params: {
|
|
128
|
+
workspaceId,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return statuses.map(({ name }) => name);
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
taskId: {
|
|
136
|
+
type: "string",
|
|
137
|
+
label: "Task Id",
|
|
138
|
+
description: "The id of the task.",
|
|
139
|
+
async options() {
|
|
140
|
+
const { tasks } = await this.listTasks();
|
|
141
|
+
|
|
142
|
+
return tasks.map(({
|
|
143
|
+
id: value, name: label,
|
|
144
|
+
}) => ({
|
|
145
|
+
label,
|
|
146
|
+
value,
|
|
147
|
+
}));
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
workspaceId: {
|
|
151
|
+
type: "string",
|
|
152
|
+
label: "Workspace Id",
|
|
153
|
+
description: "The id of the workspace.",
|
|
154
|
+
async options() {
|
|
155
|
+
const { workspaces } = await this.listWorkspaces();
|
|
156
|
+
|
|
157
|
+
return workspaces.map(({
|
|
158
|
+
id: value, name: label,
|
|
159
|
+
}) => ({
|
|
160
|
+
label,
|
|
161
|
+
value,
|
|
162
|
+
}));
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
methods: {
|
|
167
|
+
_apiUrl() {
|
|
168
|
+
return "https://api.usemotion.com/v1";
|
|
169
|
+
// return "https://stoplight.io/mocks/motion/motion-rest-api/33447";
|
|
170
|
+
},
|
|
171
|
+
_getHeaders() {
|
|
172
|
+
return {
|
|
173
|
+
"X-API-Key": this.$auth.api_key,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
async _makeRequest({
|
|
177
|
+
$ = this, path, ...opts
|
|
178
|
+
}) {
|
|
179
|
+
const config = {
|
|
180
|
+
url: `${this._apiUrl()}/${path}`,
|
|
181
|
+
headers: this._getHeaders(),
|
|
182
|
+
...opts,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return axios($, config);
|
|
186
|
+
},
|
|
187
|
+
createTask(args = {}) {
|
|
188
|
+
return this._makeRequest({
|
|
189
|
+
method: "POST",
|
|
190
|
+
path: "tasks",
|
|
191
|
+
...args,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
deleteTask({
|
|
195
|
+
taskId, ...args
|
|
196
|
+
}) {
|
|
197
|
+
return this._makeRequest({
|
|
198
|
+
method: "DELETE",
|
|
199
|
+
path: `tasks/${taskId}`,
|
|
200
|
+
...args,
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
getTask({
|
|
204
|
+
taskId, ...args
|
|
205
|
+
}) {
|
|
206
|
+
return this._makeRequest({
|
|
207
|
+
path: `tasks/${taskId}`,
|
|
208
|
+
...args,
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
listProjects(args = {}) {
|
|
212
|
+
return this._makeRequest({
|
|
213
|
+
path: "projects",
|
|
214
|
+
...args,
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
listStatuses(args = {}) {
|
|
218
|
+
return this._makeRequest({
|
|
219
|
+
path: "statuses",
|
|
220
|
+
...args,
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
listTasks(args = {}) {
|
|
224
|
+
return this._makeRequest({
|
|
225
|
+
path: "tasks",
|
|
226
|
+
...args,
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
listUsers(args = {}) {
|
|
230
|
+
return this._makeRequest({
|
|
231
|
+
path: "users",
|
|
232
|
+
...args,
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
listWorkspaces(args = {}) {
|
|
236
|
+
return this._makeRequest({
|
|
237
|
+
path: "workspaces",
|
|
238
|
+
...args,
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
moveWorkspace({
|
|
242
|
+
taskId, ...args
|
|
243
|
+
}) {
|
|
244
|
+
return this._makeRequest({
|
|
245
|
+
method: "PATCH",
|
|
246
|
+
path: `tasks/${taskId}/move`,
|
|
247
|
+
...args,
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
updateTask({
|
|
251
|
+
taskId, ...args
|
|
252
|
+
}) {
|
|
253
|
+
return this._makeRequest({
|
|
254
|
+
method: "PATCH",
|
|
255
|
+
path: `tasks/${taskId}`,
|
|
256
|
+
...args,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/motion",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream Motion Components",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "motion.app.mjs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pipedream",
|
|
8
8
|
"motion"
|
|
9
9
|
],
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
10
|
"homepage": "https://pipedream.com/apps/motion",
|
|
14
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.5.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
2
|
+
import motion from "../../motion.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "motion-task-status-updated",
|
|
6
|
+
name: "Task Status Updated",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Emit new event when the status of a specific task is updated.",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
motion,
|
|
13
|
+
db: "$.service.db",
|
|
14
|
+
timer: {
|
|
15
|
+
label: "Polling interval",
|
|
16
|
+
description: "Pipedream will poll the Motion API on this schedule",
|
|
17
|
+
type: "$.interface.timer",
|
|
18
|
+
default: {
|
|
19
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
taskId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
motion,
|
|
25
|
+
"taskId",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
_getLastStatusName() {
|
|
31
|
+
return this.db.get("lastStatusName");
|
|
32
|
+
},
|
|
33
|
+
_setLastStatusName(lastStatusName) {
|
|
34
|
+
this.db.set("lastStatusName", lastStatusName);
|
|
35
|
+
},
|
|
36
|
+
async startEvent() {
|
|
37
|
+
const { taskId } = this;
|
|
38
|
+
const lastStatusName = this._getLastStatusName();
|
|
39
|
+
|
|
40
|
+
const task = await this.motion.getTask({
|
|
41
|
+
taskId,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (lastStatusName != task.status.name) {
|
|
45
|
+
const ts = Date.now();
|
|
46
|
+
this.$emit(
|
|
47
|
+
task,
|
|
48
|
+
{
|
|
49
|
+
id: `${task.id}+${ts}`,
|
|
50
|
+
summary: `The status of the task: "${taskId}" was updated!`,
|
|
51
|
+
ts,
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
this._setLastStatusName(task.status.name);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
async run() {
|
|
60
|
+
await this.startEvent();
|
|
61
|
+
},
|
|
62
|
+
};
|