@pipedream/asana 0.4.0 → 0.5.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/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-tags-added-to-any-task",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "Tags added to any task (Instant)",
|
|
9
|
+
description: "Emit a new event each time a tag is added to any task, optionally filtering by a given set of tags.",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
props: {
|
|
13
|
+
...common.props,
|
|
14
|
+
project: {
|
|
15
|
+
label: "Project",
|
|
16
|
+
description: "Gid of a project.",
|
|
17
|
+
type: "string",
|
|
18
|
+
propDefinition: [
|
|
19
|
+
asana,
|
|
20
|
+
"projects",
|
|
21
|
+
(c) => ({
|
|
22
|
+
workspace: c.workspace,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
tags: {
|
|
27
|
+
optional: true,
|
|
28
|
+
propDefinition: [
|
|
29
|
+
asana,
|
|
30
|
+
"tags",
|
|
31
|
+
(c) => ({
|
|
32
|
+
tags: c.tags,
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
...common.methods,
|
|
39
|
+
getWebhookFilter() {
|
|
40
|
+
return {
|
|
41
|
+
filters: [
|
|
42
|
+
{
|
|
43
|
+
action: "added",
|
|
44
|
+
resource_type: "task",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
resource: this.project,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
async emitEvent(event) {
|
|
51
|
+
const { tags } = this;
|
|
52
|
+
const { events = [] } = event.body || {};
|
|
53
|
+
|
|
54
|
+
const promises = events
|
|
55
|
+
.filter(({ parent }) => {
|
|
56
|
+
return tags?.length
|
|
57
|
+
? tags.includes(String(parent.gid))
|
|
58
|
+
: true;
|
|
59
|
+
})
|
|
60
|
+
.map(async (event) => ({
|
|
61
|
+
event,
|
|
62
|
+
task: await this.asana.getTask(event.resource.gid),
|
|
63
|
+
tag: await this.asana.getTag(event.parent.gid),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const responses = await Promise.all(promises);
|
|
67
|
+
|
|
68
|
+
responses.forEach((response) => {
|
|
69
|
+
const {
|
|
70
|
+
event, task, tag,
|
|
71
|
+
} = response;
|
|
72
|
+
const ts = Date.parse(event.created_at);
|
|
73
|
+
this.$emit(
|
|
74
|
+
response,
|
|
75
|
+
{
|
|
76
|
+
id: `${tag.gid}-${ts}`,
|
|
77
|
+
summary: `${tag.name} added to ${task.name}`,
|
|
78
|
+
ts,
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|