@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.
Files changed (39) hide show
  1. package/actions/add-task-to-section/add-task-to-section.mjs +79 -0
  2. package/actions/common/common.mjs +26 -0
  3. package/actions/common/constants.mjs +22 -0
  4. package/actions/create-project/create-project.mjs +142 -0
  5. package/actions/create-subtask/create-subtask.mjs +132 -0
  6. package/actions/create-task/create-task.mjs +147 -0
  7. package/actions/create-task-comment/create-task-comment.mjs +66 -0
  8. package/actions/delete-task/delete-task.mjs +34 -0
  9. package/actions/find-task-by-id/find-task-by-id.mjs +32 -0
  10. package/actions/search-projects/search-projects.mjs +50 -0
  11. package/actions/search-sections/search-sections.mjs +25 -0
  12. package/actions/search-tasks/search-tasks.mjs +74 -0
  13. package/actions/search-user-projects/search-user-projects.mjs +47 -0
  14. package/actions/update-task/update-task.mjs +125 -0
  15. package/asana.app.mjs +377 -0
  16. package/package.json +19 -19
  17. package/sources/common/common.mjs +75 -0
  18. package/sources/new-completed-task/new-completed-task.mjs +60 -0
  19. package/sources/new-project/new-project.mjs +50 -0
  20. package/sources/new-story/new-story.mjs +57 -0
  21. package/sources/new-subtask/new-subtask.mjs +72 -0
  22. package/sources/new-tag/new-tag.mjs +45 -0
  23. package/sources/new-task/new-task.mjs +56 -0
  24. package/sources/new-team/new-team.mjs +42 -0
  25. package/sources/new-user/new-user.mjs +50 -0
  26. package/sources/new-workspace/new-workspace.mjs +34 -0
  27. package/sources/tag-added-to-task/tag-added-to-task.mjs +71 -0
  28. package/sources/updated-task-in-project/updated-task-in-project.mjs +72 -0
  29. package/asana.app.js +0 -190
  30. package/sources/completed-task/completed-task.js +0 -76
  31. package/sources/new-project/new-project.js +0 -68
  32. package/sources/new-story/new-story.js +0 -75
  33. package/sources/new-subtask/new-subtask.js +0 -84
  34. package/sources/new-task-in-project/new-task-in-project.js +0 -75
  35. package/sources/new-team/new-team.js +0 -32
  36. package/sources/new-user/new-user.js +0 -68
  37. package/sources/new-workspace/new-workspace.js +0 -31
  38. package/sources/tag-added-to-task/tag-added-to-task.js +0 -84
  39. package/sources/updated-task-in-project/updated-task-in-project.js +0 -83
@@ -1,68 +0,0 @@
1
- const asana = require("../../asana.app.js");
2
-
3
- module.exports = {
4
- name: "User Added To Workspace (Instant)",
5
- key: "asana-new-user",
6
- description: "Emits an event for each new user added to a workspace.",
7
- version: "0.0.2",
8
- dedupe: "unique",
9
- props: {
10
- asana,
11
- workspaceId: { propDefinition: [asana, "workspaceId"] },
12
- db: "$.service.db",
13
- http: {
14
- type: "$.interface.http",
15
- customResponse: true,
16
- },
17
- },
18
-
19
- hooks: {
20
- async activate() {
21
- const body = {
22
- data: {
23
- filters: [
24
- {
25
- action: "added",
26
- resource_type: "workspace_membership",
27
- },
28
- ],
29
- resource: this.workspaceId,
30
- target: this.http.endpoint,
31
- },
32
- };
33
- const resp = await this.asana.createHook(body);
34
- this.db.set("hookId", resp.data.gid);
35
- },
36
- async deactivate() {
37
- console.log(this.db.get("hookId"));
38
- await this.asana.deleteHook(this.db.get("hookId"));
39
- },
40
- },
41
-
42
- async run(event) {
43
- // validate signature
44
- if (!this.asana.verifyAsanaWebhookRequest(event))
45
- return;
46
-
47
- this.http.respond({
48
- status: 200,
49
- headers: {
50
- "x-hook-secret": event.headers["x-hook-secret"],
51
- },
52
- });
53
-
54
- const { body } = event;
55
- if (!body || !body.events) {
56
- return;
57
- }
58
-
59
- for (const e of body.events) {
60
- let user = await this.asana.getUser(e.user.gid);
61
- this.$emit(user, {
62
- id: user.gid,
63
- summary: user.name,
64
- ts: Date.now(),
65
- });
66
- }
67
- },
68
- };
@@ -1,31 +0,0 @@
1
- const asana = require("../../asana.app.js");
2
-
3
- module.exports = {
4
- name: "Workspace Added",
5
- key: "asana-new-workspace",
6
- description: "Emits an event each time you add a new workspace/organization.",
7
- version: "0.0.1",
8
- dedupe: "unique",
9
- props: {
10
- asana,
11
- db: "$.service.db",
12
- timer: {
13
- type: "$.interface.timer",
14
- default: {
15
- intervalSeconds: 60 * 15,
16
- },
17
- },
18
- },
19
-
20
- async run(event) {
21
- let results = await this.asana.getWorkspaces();
22
- for (const result of results) {
23
- let workspace = await this.asana.getWorkspace(result.gid);
24
- this.$emit(workspace, {
25
- id: workspace.gid,
26
- summary: workspace.name,
27
- ts: Date.now(),
28
- });
29
- }
30
- },
31
- };
@@ -1,84 +0,0 @@
1
- const asana = require("../../asana.app.js");
2
-
3
- module.exports = {
4
- name: "Tag Added To Task (Instant)",
5
- key: "asana-tag-added-to-task",
6
- description: "Emits an event for each new tag added to a task.",
7
- version: "0.0.2",
8
- props: {
9
- asana,
10
- workspaceId: { propDefinition: [asana, "workspaceId"] },
11
- projectId: {
12
- propDefinition: [
13
- asana,
14
- "projectId",
15
- (c) => ({ workspaceId: c.workspaceId }),
16
- ],
17
- },
18
- taskIds: {
19
- propDefinition: [asana, "taskIds", (c) => ({ projectId: c.projectId })],
20
- },
21
- db: "$.service.db",
22
- http: {
23
- type: "$.interface.http",
24
- customResponse: true,
25
- },
26
- },
27
-
28
- hooks: {
29
- async activate() {
30
- const body = {
31
- data: {
32
- filters: [
33
- {
34
- action: "added",
35
- resource_subtype: "tag",
36
- resource_type: "task",
37
- },
38
- ],
39
- resource: this.projectId,
40
- target: this.http.endpoint,
41
- },
42
- };
43
- const resp = await this.asana.createHook(body);
44
- this.db.set("hookId", resp.data.gid);
45
- this.db.set("taskIds", this.taskIds);
46
- },
47
- async deactivate() {
48
- console.log(this.db.get("hookId"));
49
- await this.asana.deleteHook(this.db.get("hookId"));
50
- },
51
- },
52
-
53
- async run(event) {
54
- // validate signature
55
- if (!this.asana.verifyAsanaWebhookRequest(event))
56
- return;
57
-
58
- this.http.respond({
59
- status: 200,
60
- headers: {
61
- "x-hook-secret": event.headers["x-hook-secret"],
62
- },
63
- });
64
-
65
- const { body } = event;
66
- if (!body || !body.events) {
67
- return;
68
- }
69
-
70
- const taskIds = this.db.get("taskIds");
71
-
72
- for (const e of body.events) {
73
- if (!taskIds || (taskIds.length < 0) || (Object.keys(taskIds).length === 0) || (taskIds && taskIds.includes(e.resource.gid))) {
74
- let task = await this.asana.getTask(e.resource.gid);
75
- let tag = await this.asana.getTag(e.parent.gid);
76
- this.$emit(tag, {
77
- id: tag.gid,
78
- summary: `${tag.name} added to ${task.name}`,
79
- ts: Date.now(),
80
- });
81
- }
82
- }
83
- },
84
- };
@@ -1,83 +0,0 @@
1
- const asana = require("../../asana.app.js");
2
-
3
- module.exports = {
4
- name: "Task Updated In Project (Instant)",
5
- key: "asana-task-updated-in-project",
6
- description: "Emits an event for each task updated in a project.",
7
- version: "0.0.2",
8
- props: {
9
- asana,
10
- workspaceId: { propDefinition: [asana, "workspaceId"] },
11
- projectId: {
12
- propDefinition: [
13
- asana,
14
- "projectId",
15
- (c) => ({ workspaceId: c.workspaceId }),
16
- ],
17
- },
18
- taskIds: {
19
- propDefinition: [asana, "taskIds", (c) => ({ projectId: c.projectId })],
20
- },
21
- db: "$.service.db",
22
- http: {
23
- type: "$.interface.http",
24
- customResponse: true,
25
- },
26
- },
27
-
28
- hooks: {
29
- async activate() {
30
- const body = {
31
- data: {
32
- filters: [
33
- {
34
- action: "changed",
35
- resource_type: "task",
36
- },
37
- ],
38
- resource: this.projectId,
39
- target: this.http.endpoint,
40
- },
41
- };
42
- const resp = await this.asana.createHook(body);
43
- this.db.set("hookId", resp.data.gid);
44
- this.db.set("taskIds", this.taskIds);
45
- },
46
- async deactivate() {
47
- console.log(this.db.get("hookId"));
48
- await this.asana.deleteHook(this.db.get("hookId"));
49
- },
50
- },
51
-
52
- async run(event) {
53
- // validate signature
54
- if (!this.asana.verifyAsanaWebhookRequest(event))
55
- return;
56
-
57
- this.http.respond({
58
- status: 200,
59
- headers: {
60
- "x-hook-secret": event.headers["x-hook-secret"],
61
- },
62
- });
63
-
64
- const { body } = event;
65
- if (!body || !body.events) {
66
- return;
67
- }
68
-
69
- const taskIds = this.db.get("taskIds");
70
-
71
- for (const e of body.events) {
72
- if (!taskIds || (taskIds.length < 0) || (Object.keys(taskIds).length === 0) || (taskIds && taskIds.includes(e.resource.gid))) {
73
- let task = await this.asana.getTask(e.resource.gid);
74
- task.change = e.change;
75
- this.$emit(task, {
76
- id: task.gid,
77
- summary: task.name,
78
- ts: Date.now(),
79
- });
80
- }
81
- }
82
- },
83
- };