@pipedream/asana 0.3.4 → 0.3.6

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.
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Add Task To Section",
6
6
  description: "Add a task to a specific, existing section. This will remove the task from other sections of the project. [See the docs here](https://developers.asana.com/docs/add-task-to-section)",
7
7
  key: "asana-add-task-to-section",
8
- version: "0.2.0",
8
+ version: "0.2.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-create-project",
6
6
  name: "Create Project",
7
7
  description: "Create a new project in a workspace or team. [See the docs here](https://developers.asana.com/docs/create-a-project)",
8
- version: "0.9.0",
8
+ version: "0.9.1",
9
9
  type: "action",
10
10
  props: {
11
11
  asana,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-create-subtask",
6
6
  name: "Create Subtask",
7
7
  description: "Creates a new subtask and adds it to the parent task. [See the docs here](https://developers.asana.com/docs/create-a-subtask)",
8
- version: "0.3.0",
8
+ version: "0.3.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-create-task",
6
6
  name: "Create Task",
7
7
  description: "Creates a new task. [See the docs here](https://developers.asana.com/docs/create-a-task)",
8
- version: "0.3.0",
8
+ version: "0.3.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-create-task-comment",
6
6
  name: "Create Task Comment",
7
7
  description: "Adds a comment to a task. [See the docs here](https://developers.asana.com/docs/create-a-story-on-a-task)",
8
- version: "0.2.0",
8
+ version: "0.2.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-delete-task",
6
6
  name: "Delete Task",
7
7
  description: "Deletes a specific and existing task. [See the docs here](https://developers.asana.com/docs/delete-a-task)",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-find-task-by-id",
6
6
  name: "Find Task by ID",
7
7
  description: "Searches for a task by id. Returns the complete task record for a single task. [See the docs here](https://developers.asana.com/docs/get-a-task)",
8
- version: "0.2.0",
8
+ version: "0.2.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -3,7 +3,7 @@ import asana from "../../asana.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "asana-search-projects",
6
- version: "0.2.0",
6
+ version: "0.2.1",
7
7
  name: "Search Projects",
8
8
  description: "Finds an existing project. [See the docs here](https://developers.asana.com/docs/get-multiple-projects)",
9
9
  props: {
@@ -4,7 +4,7 @@ export default {
4
4
  key: "asana-search-sections",
5
5
  name: "Search Sections",
6
6
  description: "Searches for a section by name within a particular project. [See the docs here](https://developers.asana.com/docs/get-sections-in-a-project)",
7
- version: "0.2.0",
7
+ version: "0.2.1",
8
8
  type: "action",
9
9
  props: {
10
10
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-search-tasks",
6
6
  name: "Search Tasks",
7
7
  description: "Searches for a Task by name within a Project. [See the docs here](https://developers.asana.com/docs/get-multiple-tasks)",
8
- version: "0.2.0",
8
+ version: "0.2.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-search-user-projects",
6
6
  name: "Get list of user projects",
7
7
  description: "Return list of projects given the user and workspace gid. [See the docs here](https://developers.asana.com/docs/get-multiple-projects)",
8
- version: "0.4.0",
8
+ version: "0.4.1",
9
9
  type: "action",
10
10
  props: {
11
11
  asana,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-update-task",
6
6
  name: "Update Task",
7
7
  description: "Updates a specific and existing task. [See the docs here](https://developers.asana.com/docs/update-a-task)",
8
- version: "0.3.0",
8
+ version: "0.3.1",
9
9
  type: "action",
10
10
  props: {
11
11
  ...common.props,
package/asana.app.mjs CHANGED
@@ -10,7 +10,7 @@ export default {
10
10
  type: "string[]",
11
11
  async options() {
12
12
  const organizations = await this.getOrganizations();
13
-
13
+
14
14
  return organizations.map((organization) => ({
15
15
  label: organization.name,
16
16
  value: organization.gid,
@@ -90,15 +90,16 @@ export default {
90
90
  type: "string[]",
91
91
  async options({ project }) {
92
92
  const tasks = await this.getTasks({
93
- project,
94
- });
95
-
96
- return tasks.map((task) => {
97
- return {
98
- label: task.name,
99
- value: task.gid,
100
- };
93
+ params: {
94
+ project,
95
+ },
101
96
  });
97
+ return tasks.map(({
98
+ name: label, gid: value,
99
+ }) => ({
100
+ label,
101
+ value,
102
+ }));
102
103
  },
103
104
  },
104
105
  sections: {
@@ -149,11 +150,12 @@ export default {
149
150
  * @returns {string} The request result data.
150
151
  */
151
152
  async _makeRequest(path, options = {}, $ = this) {
152
- return axios($, {
153
+ const config = {
153
154
  url: `${this._apiUrl()}/${path}`,
154
155
  headers: this._headers(),
155
156
  ...options,
156
- });
157
+ };
158
+ return axios($, config);
157
159
  },
158
160
  /**
159
161
  * Create a webhook
@@ -257,7 +259,8 @@ export default {
257
259
  * @returns {string} An Asana Task.
258
260
  */
259
261
  async getTask(taskId, $) {
260
- return (await this._makeRequest(`tasks/${taskId}`), {}, $).data;
262
+ const response = await this._makeRequest(`tasks/${taskId}`, {}, $);
263
+ return response.data;
261
264
  },
262
265
  /**
263
266
  * Get an Asana Task list.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@pipedream/asana",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Pipedream Asana Components",
5
- "main": "asana.app.js",
5
+ "main": "asana.app.mjs",
6
6
  "keywords": [
7
7
  "pipedream",
8
8
  "asana"
@@ -34,12 +34,6 @@ export default {
34
34
  _setWebhookId(webhookId) {
35
35
  this.db.set("webhookId", webhookId);
36
36
  },
37
- _getTasks() {
38
- return this.db.get("tasks");
39
- },
40
- _setTasks(tasks) {
41
- this.db.set("tasks", tasks);
42
- },
43
37
  getWebhookFilter() {
44
38
  throw new Error("getWebhookFilter is not implemented");
45
39
  },
@@ -57,10 +51,6 @@ export default {
57
51
  });
58
52
 
59
53
  this._setWebhookId(response.gid);
60
-
61
- if (this.tasks) {
62
- this._setTasks(this.tasks);
63
- }
64
54
  },
65
55
  async deactivate() {
66
56
  const webhookId = this._getWebhookId();
@@ -7,7 +7,7 @@ export default {
7
7
  type: "source",
8
8
  name: "New Completed Task (Instant)",
9
9
  description: "Emit new event for each task completed in a project.",
10
- version: "0.1.0",
10
+ version: "0.1.1",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "asana-new-project",
7
7
  name: "New Project Added To Workspace (Instant)",
8
8
  description: "Emit new event for each new project added to a workspace.",
9
- version: "0.1.0",
9
+ version: "0.1.1",
10
10
  dedupe: "unique",
11
11
  props: {
12
12
  ...common.props,
@@ -7,7 +7,7 @@ export default {
7
7
  type: "source",
8
8
  name: "New Story Added To Project (Instant)",
9
9
  description: "Emit new event for each story added to a project.",
10
- version: "0.1.0",
10
+ version: "0.1.1",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -7,7 +7,7 @@ export default {
7
7
  type: "source",
8
8
  name: "New Subtask (Instant)",
9
9
  description: "Emit new event for each subtask added to a project.",
10
- version: "0.1.0",
10
+ version: "1.0.1",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -24,16 +24,16 @@ export default {
24
24
  ],
25
25
  },
26
26
  tasks: {
27
+ optional: true,
27
28
  propDefinition: [
28
29
  asana,
29
30
  "tasks",
30
31
  (c) => ({
31
- projects: c.project,
32
+ project: c.project,
32
33
  }),
33
34
  ],
34
35
  },
35
36
  },
36
-
37
37
  methods: {
38
38
  ...common.methods,
39
39
  getWebhookFilter() {
@@ -48,25 +48,32 @@ export default {
48
48
  };
49
49
  },
50
50
  async emitEvent(event) {
51
- const { body } = event;
52
- if (!body || !body.events) return;
53
-
54
- const tasks = this.db.get("tasks");
51
+ const { tasks } = this;
52
+ const { events = [] } = event.body || {};
55
53
 
56
- for (const e of body.events) {
57
- if (!e.parent || e.parent.resource_type !== "task") continue;
54
+ const promises = events
55
+ .filter(({ parent }) => parent.resource_type === "task")
56
+ .filter(({ resource }) => {
57
+ return tasks?.length
58
+ ? tasks.includes(String(resource.gid))
59
+ : true;
60
+ })
61
+ .map(async (event) => ({
62
+ event,
63
+ task: await this.asana.getTask(event.resource.gid),
64
+ }));
58
65
 
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);
66
+ const responses = await Promise.all(promises);
62
67
 
63
- this.$emit(task, {
64
- id: task.gid,
65
- summary: task.name,
66
- ts: Date.now(),
67
- });
68
- }
69
- }
68
+ responses.forEach(({
69
+ event, task,
70
+ }) => {
71
+ this.$emit(task, {
72
+ id: task.gid,
73
+ summary: task.name,
74
+ ts: Date.parse(event.created_at),
75
+ });
76
+ });
70
77
  },
71
78
  },
72
79
  };
@@ -5,7 +5,7 @@ export default {
5
5
  type: "source",
6
6
  name: "New Tag",
7
7
  description: "Emit new event for each tag created in a workspace.",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  dedupe: "unique",
10
10
  props: {
11
11
  asana,
@@ -7,7 +7,7 @@ export default {
7
7
  type: "source",
8
8
  name: "New Task (Instant)",
9
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",
10
+ version: "0.1.1",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  type: "source",
6
6
  name: "New Team",
7
7
  description: "Emit new event for each task added to an organization.",
8
- version: "0.1.0",
8
+ version: "0.1.1",
9
9
  dedupe: "unique",
10
10
  props: {
11
11
  asana,
@@ -6,7 +6,7 @@ export default {
6
6
  type: "source",
7
7
  name: "New User (Instant)",
8
8
  description: "Emit new event for each user added to a workspace.",
9
- version: "0.1.0",
9
+ version: "0.1.1",
10
10
  dedupe: "unique",
11
11
  props: {
12
12
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "asana-new-workspace",
6
6
  name: "New Workspace Added",
7
7
  description: "Emit new event each time you add a new workspace/organization.",
8
- version: "0.1.0",
8
+ version: "0.1.1",
9
9
  dedupe: "unique",
10
10
  props: {
11
11
  asana,
@@ -7,7 +7,8 @@ export default {
7
7
  type: "source",
8
8
  name: "New Tag Added To Task (Instant)",
9
9
  description: "Emit new event for each new tag added to a task.",
10
- version: "0.1.0",
10
+ version: "0.1.1",
11
+ dedupe: "unique",
11
12
  props: {
12
13
  ...common.props,
13
14
  project: {
@@ -23,11 +24,12 @@ export default {
23
24
  ],
24
25
  },
25
26
  tasks: {
27
+ optional: true,
26
28
  propDefinition: [
27
29
  asana,
28
30
  "tasks",
29
31
  (c) => ({
30
- projects: c.project,
32
+ project: c.project,
31
33
  }),
32
34
  ],
33
35
  },
@@ -46,26 +48,33 @@ export default {
46
48
  };
47
49
  },
48
50
  async emitEvent(event) {
49
- const { body } = event;
50
- if (!body || !body.events) return;
51
+ const { tasks } = this;
52
+ const { events = [] } = event.body || {};
51
53
 
52
- const tasks = this.db.get("tasks");
54
+ const promises = events
55
+ .filter(({ resource }) => {
56
+ return tasks?.length
57
+ ? tasks.includes(String(resource.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
+ }));
53
65
 
54
- for (const e of body.events) {
55
- if (e.parent.resource_type !== "tag") continue;
66
+ const responses = await Promise.all(promises);
56
67
 
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
- }
68
+ responses.forEach(({
69
+ event, task, tag,
70
+ }) => {
71
+ const ts = Date.parse(event.created_at);
72
+ this.$emit(tag, {
73
+ id: `${tag.gid}-${ts}`,
74
+ summary: `${tag.name} added to ${task.name}`,
75
+ ts,
76
+ });
77
+ });
69
78
  },
70
79
  },
71
80
  };
@@ -3,11 +3,11 @@ const { asana } = common.props;
3
3
 
4
4
  export default {
5
5
  ...common,
6
- key: "asana-new-subtask",
6
+ key: "asana-task-updated-in-project",
7
7
  type: "source",
8
- name: "New Update To Task (Instant)",
8
+ name: "Task Updated In Project (Instant)",
9
9
  description: "Emit new event for each update to a task.",
10
- version: "0.1.1",
10
+ version: "1.0.1",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  ...common.props,
@@ -24,11 +24,12 @@ export default {
24
24
  ],
25
25
  },
26
26
  tasks: {
27
+ optional: true,
27
28
  propDefinition: [
28
29
  asana,
29
30
  "tasks",
30
31
  (c) => ({
31
- projects: c.project,
32
+ project: c.project,
32
33
  }),
33
34
  ],
34
35
  },
@@ -47,26 +48,32 @@ export default {
47
48
  };
48
49
  },
49
50
  async emitEvent(event) {
50
- const { body } = event;
51
- if (!body || !body.events) return;
51
+ const { tasks } = this;
52
+ const { events = [] } = event.body || {};
52
53
 
53
- const tasks = this.db.get("tasks");
54
+ const promises = events
55
+ .filter(({ resource }) => {
56
+ return tasks?.length
57
+ ? tasks.includes(String(resource.gid))
58
+ : true;
59
+ })
60
+ .map(async (event) => ({
61
+ event,
62
+ task: await this.asana.getTask(event.resource.gid),
63
+ }));
54
64
 
55
- for (const e of body.events) {
56
- // This conditional ignore when Asana fire a subtask update event
57
- if (e.parent && e.parent.resource_type === "task") continue;
65
+ const responses = await Promise.all(promises);
58
66
 
59
- if (!tasks || tasks.length <= 0 || Object.keys(tasks).length <= 0 ||
60
- tasks.includes(e.resource.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
- }
67
+ responses.forEach(({
68
+ event, task,
69
+ }) => {
70
+ const ts = Date.parse(event.created_at);
71
+ this.$emit(task, {
72
+ id: `${task.gid}-${ts}`,
73
+ summary: task.name,
74
+ ts,
75
+ });
76
+ });
70
77
  },
71
78
  },
72
79
  };