@pipedream/asana 0.3.1 → 0.3.4
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/add-task-to-section/add-task-to-section.mjs +79 -0
- package/actions/common/common.mjs +26 -0
- package/actions/common/constants.mjs +22 -0
- package/actions/create-project/create-project.mjs +142 -0
- package/actions/create-subtask/create-subtask.mjs +132 -0
- package/actions/create-task/create-task.mjs +147 -0
- package/actions/create-task-comment/create-task-comment.mjs +66 -0
- package/actions/delete-task/delete-task.mjs +34 -0
- package/actions/find-task-by-id/find-task-by-id.mjs +32 -0
- package/actions/search-projects/search-projects.mjs +50 -0
- package/actions/search-sections/search-sections.mjs +25 -0
- package/actions/search-tasks/search-tasks.mjs +74 -0
- package/actions/search-user-projects/search-user-projects.mjs +47 -0
- package/actions/update-task/update-task.mjs +125 -0
- package/asana.app.mjs +377 -0
- package/package.json +19 -19
- package/sources/common/common.mjs +75 -0
- package/sources/new-completed-task/new-completed-task.mjs +60 -0
- package/sources/new-project/new-project.mjs +50 -0
- package/sources/new-story/new-story.mjs +57 -0
- package/sources/new-subtask/new-subtask.mjs +72 -0
- package/sources/new-tag/new-tag.mjs +45 -0
- package/sources/new-task/new-task.mjs +56 -0
- package/sources/new-team/new-team.mjs +42 -0
- package/sources/new-user/new-user.mjs +50 -0
- package/sources/new-workspace/new-workspace.mjs +34 -0
- package/sources/tag-added-to-task/tag-added-to-task.mjs +71 -0
- package/sources/updated-task-in-project/updated-task-in-project.mjs +72 -0
- package/asana.app.js +0 -190
- package/sources/completed-task/completed-task.js +0 -76
- package/sources/new-project/new-project.js +0 -68
- package/sources/new-story/new-story.js +0 -75
- package/sources/new-subtask/new-subtask.js +0 -84
- package/sources/new-task-in-project/new-task-in-project.js +0 -75
- package/sources/new-team/new-team.js +0 -32
- package/sources/new-user/new-user.js +0 -68
- package/sources/new-workspace/new-workspace.js +0 -31
- package/sources/tag-added-to-task/tag-added-to-task.js +0 -84
- package/sources/updated-task-in-project/updated-task-in-project.js +0 -83
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
2
|
+
"name": "@pipedream/asana",
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "Pipedream Asana Components",
|
|
5
|
+
"main": "asana.app.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pipedream",
|
|
8
|
+
"asana"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://pipedream.com/apps/asana",
|
|
11
|
+
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"axios": "^0.21.1"
|
|
15
|
+
},
|
|
16
|
+
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import asana from "../../asana.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
props: {
|
|
5
|
+
asana,
|
|
6
|
+
db: "$.service.db",
|
|
7
|
+
http: {
|
|
8
|
+
type: "$.interface.http",
|
|
9
|
+
customResponse: true,
|
|
10
|
+
},
|
|
11
|
+
workspace: {
|
|
12
|
+
label: "Workspace",
|
|
13
|
+
description: "Gid of a workspace.",
|
|
14
|
+
type: "string",
|
|
15
|
+
propDefinition: [
|
|
16
|
+
asana,
|
|
17
|
+
"workspaces",
|
|
18
|
+
],
|
|
19
|
+
optional: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
async _respondWebHook(http, event) {
|
|
24
|
+
http.respond({
|
|
25
|
+
status: 200,
|
|
26
|
+
headers: {
|
|
27
|
+
"x-hook-secret": event.headers["x-hook-secret"],
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
_getWebhookId() {
|
|
32
|
+
return this.db.get("webhookId");
|
|
33
|
+
},
|
|
34
|
+
_setWebhookId(webhookId) {
|
|
35
|
+
this.db.set("webhookId", webhookId);
|
|
36
|
+
},
|
|
37
|
+
_getTasks() {
|
|
38
|
+
return this.db.get("tasks");
|
|
39
|
+
},
|
|
40
|
+
_setTasks(tasks) {
|
|
41
|
+
this.db.set("tasks", tasks);
|
|
42
|
+
},
|
|
43
|
+
getWebhookFilter() {
|
|
44
|
+
throw new Error("getWebhookFilter is not implemented");
|
|
45
|
+
},
|
|
46
|
+
emitEvent(event) {
|
|
47
|
+
throw new Error("emitEvent is not implemented", event);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
hooks: {
|
|
51
|
+
async activate() {
|
|
52
|
+
const response = await this.asana.createWebHook({
|
|
53
|
+
data: {
|
|
54
|
+
...this.getWebhookFilter(),
|
|
55
|
+
target: this.http.endpoint,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this._setWebhookId(response.gid);
|
|
60
|
+
|
|
61
|
+
if (this.tasks) {
|
|
62
|
+
this._setTasks(this.tasks);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async deactivate() {
|
|
66
|
+
const webhookId = this._getWebhookId();
|
|
67
|
+
await this.asana.deleteWebhook(webhookId);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
async run(event) {
|
|
71
|
+
await this._respondWebHook(this.http, event);
|
|
72
|
+
|
|
73
|
+
await this.emitEvent(event);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-new-completed-task",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "New Completed Task (Instant)",
|
|
9
|
+
description: "Emit new event for each task completed in a project.",
|
|
10
|
+
version: "0.1.0",
|
|
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
|
+
},
|
|
27
|
+
|
|
28
|
+
methods: {
|
|
29
|
+
...common.methods,
|
|
30
|
+
getWebhookFilter() {
|
|
31
|
+
return {
|
|
32
|
+
filters: [
|
|
33
|
+
{
|
|
34
|
+
action: "changed",
|
|
35
|
+
resource_type: "task",
|
|
36
|
+
fields: [
|
|
37
|
+
"completed",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
resource: this.project,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
async emitEvent(event) {
|
|
45
|
+
const { body } = event;
|
|
46
|
+
|
|
47
|
+
if (!body || !body.events) return;
|
|
48
|
+
|
|
49
|
+
for (const e of body.events) {
|
|
50
|
+
const task = await this.asana.getTask(e.resource.gid);
|
|
51
|
+
|
|
52
|
+
this.$emit(task, {
|
|
53
|
+
id: task.gid,
|
|
54
|
+
summary: task.name,
|
|
55
|
+
ts: Date.now(),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
type: "source",
|
|
6
|
+
key: "asana-new-project",
|
|
7
|
+
name: "New Project Added To Workspace (Instant)",
|
|
8
|
+
description: "Emit new event for each new project added to a workspace.",
|
|
9
|
+
version: "0.1.0",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
workspace: {
|
|
14
|
+
...common.props.workspace,
|
|
15
|
+
label: "Workspace",
|
|
16
|
+
description: "Gid of a workspace.",
|
|
17
|
+
optional: false,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
methods: {
|
|
22
|
+
...common.methods,
|
|
23
|
+
getWebhookFilter() {
|
|
24
|
+
return {
|
|
25
|
+
filters: [
|
|
26
|
+
{
|
|
27
|
+
action: "added",
|
|
28
|
+
resource_type: "project",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
resource: this.workspace,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async emitEvent(event) {
|
|
35
|
+
const { body } = event;
|
|
36
|
+
|
|
37
|
+
if (!body || !body.events) return;
|
|
38
|
+
|
|
39
|
+
for (const e of body.events) {
|
|
40
|
+
const project = await this.asana.getProject(e.resource.gid);
|
|
41
|
+
|
|
42
|
+
this.$emit(project, {
|
|
43
|
+
id: project.gid,
|
|
44
|
+
summary: project.name,
|
|
45
|
+
ts: Date.now(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-new-story",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "New Story Added To Project (Instant)",
|
|
9
|
+
description: "Emit new event for each story added to a project.",
|
|
10
|
+
version: "0.1.0",
|
|
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
|
+
},
|
|
27
|
+
|
|
28
|
+
methods: {
|
|
29
|
+
...common.methods,
|
|
30
|
+
getWebhookFilter() {
|
|
31
|
+
return {
|
|
32
|
+
filters: [
|
|
33
|
+
{
|
|
34
|
+
action: "added",
|
|
35
|
+
resource_type: "story",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
resource: this.project,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
async emitEvent(event) {
|
|
42
|
+
const { body } = event;
|
|
43
|
+
|
|
44
|
+
if (!body || !body.events) return;
|
|
45
|
+
|
|
46
|
+
for (const e of body.events) {
|
|
47
|
+
const story = await this.asana.getStory(e.resource.gid);
|
|
48
|
+
|
|
49
|
+
this.$emit(story, {
|
|
50
|
+
id: story.gid,
|
|
51
|
+
summary: story.text,
|
|
52
|
+
ts: Date.now(),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-new-subtask",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "New Subtask (Instant)",
|
|
9
|
+
description: "Emit new event for each subtask added to a project.",
|
|
10
|
+
version: "0.1.0",
|
|
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
|
+
tasks: {
|
|
27
|
+
propDefinition: [
|
|
28
|
+
asana,
|
|
29
|
+
"tasks",
|
|
30
|
+
(c) => ({
|
|
31
|
+
projects: c.project,
|
|
32
|
+
}),
|
|
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 { body } = event;
|
|
52
|
+
if (!body || !body.events) return;
|
|
53
|
+
|
|
54
|
+
const tasks = this.db.get("tasks");
|
|
55
|
+
|
|
56
|
+
for (const e of body.events) {
|
|
57
|
+
if (!e.parent || e.parent.resource_type !== "task") continue;
|
|
58
|
+
|
|
59
|
+
if (!tasks || tasks.length <= 0 || Object.keys(tasks).length <= 0 ||
|
|
60
|
+
tasks.includes(e.parent.gid)) {
|
|
61
|
+
const task = await this.asana.getTask(e.resource.gid);
|
|
62
|
+
|
|
63
|
+
this.$emit(task, {
|
|
64
|
+
id: task.gid,
|
|
65
|
+
summary: task.name,
|
|
66
|
+
ts: Date.now(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import asana from "../../asana.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "asana-new-tag",
|
|
5
|
+
type: "source",
|
|
6
|
+
name: "New Tag",
|
|
7
|
+
description: "Emit new event for each tag created in a workspace.",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
dedupe: "unique",
|
|
10
|
+
props: {
|
|
11
|
+
asana,
|
|
12
|
+
workspace: {
|
|
13
|
+
label: "Workspace",
|
|
14
|
+
description: "Gid of a workspace.",
|
|
15
|
+
type: "string",
|
|
16
|
+
propDefinition: [
|
|
17
|
+
asana,
|
|
18
|
+
"workspaces",
|
|
19
|
+
],
|
|
20
|
+
optional: true,
|
|
21
|
+
},
|
|
22
|
+
timer: {
|
|
23
|
+
type: "$.interface.timer",
|
|
24
|
+
default: {
|
|
25
|
+
intervalSeconds: 60 * 15,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
async run() {
|
|
31
|
+
const tags = await this.asana.getTags(this.organization);
|
|
32
|
+
|
|
33
|
+
for (let tag of tags) {
|
|
34
|
+
tag = await this.asana.getTag(tag.gid);
|
|
35
|
+
|
|
36
|
+
if (this.workspace && tag.workspace.gid !== this.workspace) continue;
|
|
37
|
+
|
|
38
|
+
this.$emit(tag, {
|
|
39
|
+
id: tag.gid,
|
|
40
|
+
summary: tag.name,
|
|
41
|
+
ts: Date.now(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-new-task",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "New Task (Instant)",
|
|
9
|
+
description: "Emit new event for each task added to a project. [See docs here](https://developers.asana.com/docs/establish-a-webhook)",
|
|
10
|
+
version: "0.1.0",
|
|
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
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
...common.methods,
|
|
26
|
+
getWebhookFilter() {
|
|
27
|
+
return {
|
|
28
|
+
filters: [
|
|
29
|
+
{
|
|
30
|
+
action: "added",
|
|
31
|
+
resource_type: "task",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
resource: this.project,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
async emitEvent(event) {
|
|
38
|
+
const { body } = event;
|
|
39
|
+
|
|
40
|
+
if (!body || !body.events) return;
|
|
41
|
+
|
|
42
|
+
for (const e of body.events) {
|
|
43
|
+
// This conditional ignore when Asana fire a new subtask event
|
|
44
|
+
if (e.parent && e.parent.resource_type === "task") continue;
|
|
45
|
+
|
|
46
|
+
const task = await this.asana.getTask(e.resource.gid);
|
|
47
|
+
|
|
48
|
+
this.$emit(task, {
|
|
49
|
+
id: task.gid,
|
|
50
|
+
summary: task.name,
|
|
51
|
+
ts: Date.now(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import asana from "../../asana.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "asana-new-team",
|
|
5
|
+
type: "source",
|
|
6
|
+
name: "New Team",
|
|
7
|
+
description: "Emit new event for each task added to an organization.",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
dedupe: "unique",
|
|
10
|
+
props: {
|
|
11
|
+
asana,
|
|
12
|
+
organization: {
|
|
13
|
+
label: "Organization",
|
|
14
|
+
description: "Gid of a organization.",
|
|
15
|
+
type: "string",
|
|
16
|
+
propDefinition: [
|
|
17
|
+
asana,
|
|
18
|
+
"organizations",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
timer: {
|
|
22
|
+
type: "$.interface.timer",
|
|
23
|
+
default: {
|
|
24
|
+
intervalSeconds: 60 * 15,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async run() {
|
|
30
|
+
const teams = await this.asana.getTeams(this.organization);
|
|
31
|
+
|
|
32
|
+
for (let team of teams) {
|
|
33
|
+
team = await this.asana.getTeam(team.gid);
|
|
34
|
+
|
|
35
|
+
this.$emit(team, {
|
|
36
|
+
id: team.gid,
|
|
37
|
+
summary: team.name,
|
|
38
|
+
ts: Date.now(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "asana-new-user",
|
|
6
|
+
type: "source",
|
|
7
|
+
name: "New User (Instant)",
|
|
8
|
+
description: "Emit new event for each user added to a workspace.",
|
|
9
|
+
version: "0.1.0",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
workspace: {
|
|
14
|
+
...common.props.workspace,
|
|
15
|
+
label: "Workspace",
|
|
16
|
+
description: "Gid of a workspace.",
|
|
17
|
+
optional: false,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
methods: {
|
|
22
|
+
...common.methods,
|
|
23
|
+
getWebhookFilter() {
|
|
24
|
+
return {
|
|
25
|
+
filters: [
|
|
26
|
+
{
|
|
27
|
+
action: "added",
|
|
28
|
+
resource_type: "workspace_membership",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
resource: this.workspace,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async emitEvent(event) {
|
|
35
|
+
const { body } = event;
|
|
36
|
+
if (!body || !body.events) return;
|
|
37
|
+
|
|
38
|
+
for (const e of body.events) {
|
|
39
|
+
const membership = await this.asana.getWorkspaceMembership(e.resource.gid);
|
|
40
|
+
const user = await this.asana.getUser(membership.user.gid);
|
|
41
|
+
|
|
42
|
+
this.$emit(user, {
|
|
43
|
+
id: user.gid,
|
|
44
|
+
summary: user.name,
|
|
45
|
+
ts: Date.now(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import asana from "../../asana.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: "source",
|
|
5
|
+
key: "asana-new-workspace",
|
|
6
|
+
name: "New Workspace Added",
|
|
7
|
+
description: "Emit new event each time you add a new workspace/organization.",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
dedupe: "unique",
|
|
10
|
+
props: {
|
|
11
|
+
asana,
|
|
12
|
+
db: "$.service.db",
|
|
13
|
+
timer: {
|
|
14
|
+
type: "$.interface.timer",
|
|
15
|
+
default: {
|
|
16
|
+
intervalSeconds: 60 * 15,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const workspaces = await this.asana.getWorkspaces();
|
|
23
|
+
|
|
24
|
+
for (let workspace of workspaces) {
|
|
25
|
+
workspace = await this.asana.getWorkspace(workspace.gid);
|
|
26
|
+
|
|
27
|
+
this.$emit(workspace, {
|
|
28
|
+
id: workspace.gid,
|
|
29
|
+
summary: workspace.name,
|
|
30
|
+
ts: Date.now(),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
|
+
const { asana } = common.props;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "asana-tag-added-to-task",
|
|
7
|
+
type: "source",
|
|
8
|
+
name: "New Tag Added To Task (Instant)",
|
|
9
|
+
description: "Emit new event for each new tag added to a task.",
|
|
10
|
+
version: "0.1.0",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
project: {
|
|
14
|
+
label: "Project",
|
|
15
|
+
description: "Gid of a project.",
|
|
16
|
+
type: "string",
|
|
17
|
+
propDefinition: [
|
|
18
|
+
asana,
|
|
19
|
+
"projects",
|
|
20
|
+
(c) => ({
|
|
21
|
+
workspace: c.workspace,
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
tasks: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
asana,
|
|
28
|
+
"tasks",
|
|
29
|
+
(c) => ({
|
|
30
|
+
projects: c.project,
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
...common.methods,
|
|
37
|
+
getWebhookFilter() {
|
|
38
|
+
return {
|
|
39
|
+
filters: [
|
|
40
|
+
{
|
|
41
|
+
action: "added",
|
|
42
|
+
resource_type: "task",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
resource: this.project,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
async emitEvent(event) {
|
|
49
|
+
const { body } = event;
|
|
50
|
+
if (!body || !body.events) return;
|
|
51
|
+
|
|
52
|
+
const tasks = this.db.get("tasks");
|
|
53
|
+
|
|
54
|
+
for (const e of body.events) {
|
|
55
|
+
if (e.parent.resource_type !== "tag") continue;
|
|
56
|
+
|
|
57
|
+
if (!tasks || tasks.length <= 0 || Object.keys(tasks).length <= 0 ||
|
|
58
|
+
tasks.includes(e.resource.gid)) {
|
|
59
|
+
const task = await this.asana.getTask(e.resource.gid);
|
|
60
|
+
const tag = await this.asana.getTag(e.parent.gid);
|
|
61
|
+
|
|
62
|
+
this.$emit(tag, {
|
|
63
|
+
id: tag.gid,
|
|
64
|
+
summary: `${tag.name} added to ${task.name}`,
|
|
65
|
+
ts: Date.now(),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|