@pipedream/linear_app 0.4.0 → 0.4.1

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
  key: "linear_app-create-issue",
6
6
  name: "Create Issue",
7
7
  description: "Create an issue (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api#creating-and-editing-issues)",
8
- version: "0.3.4",
8
+ version: "0.3.5",
9
9
  props: {
10
10
  linearApp,
11
11
  teamId: {
@@ -52,7 +52,7 @@ export default {
52
52
  const summary = response.success
53
53
  ? `Created issue ${response._issue.id}`
54
54
  : "Failed to create issue";
55
- $.export("summary", summary);
55
+ $.export("$summary", summary);
56
56
 
57
57
  return response;
58
58
  },
@@ -4,7 +4,7 @@ export default {
4
4
  key: "linear_app-get-issue",
5
5
  name: "Get Issue",
6
6
  description: "Get an issue by ID (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  linearApp,
@@ -18,7 +18,7 @@ export default {
18
18
  },
19
19
  async run({ $ }) {
20
20
  const issue = await this.linearApp.getIssue(this.issueId);
21
- $.export("summary", `Found issue with ID ${this.issueId}`);
21
+ $.export("$summary", `Found issue with ID ${this.issueId}`);
22
22
  return issue;
23
23
  },
24
24
  };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "linear_app-get-teams",
5
5
  name: "Get Teams",
6
6
  description: "Get all the teams (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)",
7
- version: "0.1.3",
7
+ version: "0.1.4",
8
8
  type: "action",
9
9
  props: {
10
10
  linearApp,
@@ -12,7 +12,7 @@ export default {
12
12
  async run({ $ }) {
13
13
  const { nodes: teams } = await this.linearApp.listTeams();
14
14
 
15
- $.export("summary", `Found ${teams.length} teams(s)`);
15
+ $.export("$summary", `Found ${teams.length} teams(s)`);
16
16
 
17
17
  return teams;
18
18
  },
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Search Issues",
7
7
  description: "Search issues (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)",
8
8
  type: "action",
9
- version: "0.1.2",
9
+ version: "0.1.3",
10
10
  props: {
11
11
  linearApp,
12
12
  query: {
@@ -111,7 +111,7 @@ export default {
111
111
  hasNextPage = pageInfo.hasNextPage;
112
112
  } while (hasNextPage);
113
113
 
114
- $.export("summary", `Found ${issues.length} issues`);
114
+ $.export("$summary", `Found ${issues.length} issues`);
115
115
 
116
116
  return issues;
117
117
  },
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Update Issue",
6
6
  description: "Update an issue (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api#creating-and-editing-issues)",
7
7
  type: "action",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  props: {
10
10
  linearApp,
11
11
  issueId: {
@@ -65,7 +65,7 @@ export default {
65
65
  const summary = response.summary
66
66
  ? `Updated issue ${response._issue.id}`
67
67
  : "Failed to update issue";
68
- $.export("summary", summary);
68
+ $.export("$summary", summary);
69
69
 
70
70
  return response;
71
71
  },
@@ -223,5 +223,22 @@ export default {
223
223
  }
224
224
  } while (hasNextPage);
225
225
  },
226
+ isActionSet(body, actions) {
227
+ if (!actions.includes(body?.action)) {
228
+ return false;
229
+ }
230
+ return true;
231
+ },
232
+ async isProjectIdSet(body, projectId) {
233
+ if (projectId) {
234
+ if (!body.data?.projectId) {
235
+ const issue = body.data?.issue?.id && await this.getIssue(body.data?.issue?.id);
236
+ return issue?._project?.id === projectId;
237
+ } else {
238
+ return body.data.projectId === projectId;
239
+ }
240
+ }
241
+ return true;
242
+ },
226
243
  },
227
244
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/linear_app",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Pipedream Linear_app Components",
5
5
  "main": "linear_app.app.mjs",
6
6
  "keywords": [
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Created Comment (Instant)",
8
8
  description: "Emit new event when a new comment is created. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
9
9
  type: "source",
10
- version: "0.0.1",
10
+ version: "0.0.3",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -27,6 +27,10 @@ export default {
27
27
  getResourcesFn() {
28
28
  return this.linearApp.listComments;
29
29
  },
30
+ async getLoadedProjectId(event) {
31
+ return event?._project?.id
32
+ || (await this.linearApp.getIssue(event?._issue?.id))?._project?.id;
33
+ },
30
34
  getMetadata(resource) {
31
35
  const {
32
36
  delivery,
@@ -35,7 +39,7 @@ export default {
35
39
  } = resource;
36
40
  return {
37
41
  id: delivery,
38
- summary: `Comment created: ${data.title}`,
42
+ summary: `New comment event created: ${data.body}`,
39
43
  ts: Date.parse(createdAt),
40
44
  };
41
45
  },
@@ -4,37 +4,24 @@ import constants from "../../common/constants.mjs";
4
4
  export default {
5
5
  props: {
6
6
  linearApp,
7
- teamId: {
7
+ teamIds: {
8
+ label: "Team IDs",
9
+ type: "string[]",
8
10
  propDefinition: [
9
11
  linearApp,
10
12
  "teamId",
11
13
  ],
12
14
  optional: true,
13
15
  },
14
- projectId: {
15
- propDefinition: [
16
- linearApp,
17
- "projectId",
18
- ],
19
- },
20
16
  http: "$.interface.http",
21
17
  db: "$.service.db",
22
18
  },
23
19
  methods: {
24
- setWebhookId(id) {
25
- this.db.set(constants.WEBHOOK_ID, id);
20
+ setWebhookId(teamId, id) {
21
+ this.db.set(`webhook-${teamId}`, id);
26
22
  },
27
- getWebhookId() {
28
- return this.db.get(constants.WEBHOOK_ID);
29
- },
30
- isRelevant(body) {
31
- if (!this.getActions().includes(body?.action)) {
32
- return false;
33
- }
34
- if (this.projectId) {
35
- return body.data.projectId === this.projectId;
36
- }
37
- return true;
23
+ getWebhookId(teamId) {
24
+ return this.db.get(`webhook-${teamId}`);
38
25
  },
39
26
  isWebhookValid(clientIp) {
40
27
  return constants.CLIENT_IPS.includes(clientIp);
@@ -54,6 +41,9 @@ export default {
54
41
  getResourcesFn() {
55
42
  throw new Error("Get resource function not implemented");
56
43
  },
44
+ getLoadedProjectId() {
45
+ throw new Error("Get loaded project ID not implemented");
46
+ },
57
47
  },
58
48
  hooks: {
59
49
  async deploy() {
@@ -63,6 +53,11 @@ export default {
63
53
  resourcesFn: this.getResourcesFn(),
64
54
  });
65
55
  for await (const event of events) {
56
+ const loadedProjectId = await this.getLoadedProjectId(event);
57
+ if (this.projectId && loadedProjectId !== this.projectId) {
58
+ continue;
59
+ }
60
+ event.projectId = loadedProjectId;
66
61
  const [
67
62
  action,
68
63
  ] = this.getActions();
@@ -83,19 +78,18 @@ export default {
83
78
  label: this.getWebhookLabel(),
84
79
  };
85
80
 
86
- if (this.teamId) {
87
- params.teamId = this.teamId;
88
- } else {
89
- params.allPublicTeams = true;
81
+ for (const teamId of this.teamIds) {
82
+ params.teamId = teamId;
83
+ const { _webhook: webhook } = await this.linearApp.createWebhook(params);
84
+ this.setWebhookId(teamId, webhook.id);
90
85
  }
91
-
92
- const { _webhook: webhook } = await this.linearApp.createWebhook(params);
93
- this.setWebhookId(webhook.id);
94
86
  },
95
87
  async deactivate() {
96
- const webhookId = this.getWebhookId();
97
- if (webhookId) {
98
- await this.linearApp.deleteWebhook(webhookId);
88
+ for (const teamId of this.teamIds) {
89
+ const webhookId = this.getWebhookId(teamId);
90
+ if (webhookId) {
91
+ await this.linearApp.deleteWebhook(webhookId);
92
+ }
99
93
  }
100
94
  },
101
95
  },
@@ -118,9 +112,6 @@ export default {
118
112
  return;
119
113
  }
120
114
 
121
- if (!this.isRelevant(body)) {
122
- return;
123
- }
124
115
  const meta = this.getMetadata(resource);
125
116
  this.$emit(body, meta);
126
117
  },
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Created Issue (Instant)",
8
8
  description: "Emit new event when a new issue is created. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
9
9
  type: "source",
10
- version: "0.2.0",
10
+ version: "0.2.2",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -27,6 +27,10 @@ export default {
27
27
  getResourcesFn() {
28
28
  return this.linearApp.listIssues;
29
29
  },
30
+ async getLoadedProjectId(event) {
31
+ return event?._project?.id
32
+ || (await this.linearApp.getIssue(event?.id))?._project?.id;
33
+ },
30
34
  getMetadata(resource) {
31
35
  const {
32
36
  delivery,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Updated Issue (Instant)",
8
8
  description: "Emit new event when an issue is updated. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
9
9
  type: "source",
10
- version: "0.2.0",
10
+ version: "0.2.2",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -27,6 +27,10 @@ export default {
27
27
  getResourcesFn() {
28
28
  return this.linearApp.listIssues;
29
29
  },
30
+ async getLoadedProjectId(event) {
31
+ return event?._project?.id
32
+ || (await this.linearApp.getIssue(event?.id))?._project?.id;
33
+ },
30
34
  getMetadata(resource) {
31
35
  const {
32
36
  delivery,