@pipedream/linear_app 0.5.3 → 0.5.5

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.4.3",
8
+ version: "0.4.5",
9
9
  props: {
10
10
  linearApp,
11
11
  teamId: {
@@ -14,6 +14,15 @@ export default {
14
14
  "teamId",
15
15
  ],
16
16
  },
17
+ projectId: {
18
+ propDefinition: [
19
+ linearApp,
20
+ "projectId",
21
+ ({ teamId }) => ({
22
+ teamId,
23
+ }),
24
+ ],
25
+ },
17
26
  title: {
18
27
  propDefinition: [
19
28
  linearApp,
@@ -44,6 +53,8 @@ export default {
44
53
  },
45
54
  async run({ $ }) {
46
55
  const {
56
+ linearApp,
57
+ projectId,
47
58
  title,
48
59
  description,
49
60
  teamId,
@@ -52,8 +63,9 @@ export default {
52
63
  } = this;
53
64
 
54
65
  const response =
55
- await this.linearApp.createIssue({
66
+ await linearApp.createIssue({
56
67
  teamId,
68
+ projectId,
57
69
  title,
58
70
  description,
59
71
  assigneeId,
@@ -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.1.3",
7
+ version: "0.1.5",
8
8
  type: "action",
9
9
  props: {
10
10
  linearApp,
@@ -17,8 +17,15 @@ export default {
17
17
  },
18
18
  },
19
19
  async run({ $ }) {
20
- const issue = await this.linearApp.getIssue(this.issueId);
21
- $.export("$summary", `Found issue with ID ${this.issueId}`);
20
+ const {
21
+ linearApp,
22
+ issueId,
23
+ } = this;
24
+
25
+ const issue = await linearApp.getIssue({
26
+ issueId,
27
+ });
28
+ $.export("$summary", `Found issue with ID ${issueId}`);
22
29
  return issue;
23
30
  },
24
31
  };
@@ -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.2.3",
7
+ version: "0.2.5",
8
8
  type: "action",
9
9
  props: {
10
10
  linearApp,
@@ -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.2.3",
9
+ version: "0.2.5",
10
10
  props: {
11
11
  linearApp,
12
12
  query: {
@@ -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.1.3",
8
+ version: "0.1.5",
9
9
  props: {
10
10
  linearApp,
11
11
  teamId: {
@@ -43,65 +43,6 @@ const ORDER_BY_OPTIONS = [
43
43
  },
44
44
  ];
45
45
 
46
- const ISSUE_NODES = `
47
- id
48
- title
49
- description
50
- boardOrder
51
- branchName
52
- createdAt
53
- customerTicketCount
54
- identifier
55
- number
56
- priority
57
- priorityLabel
58
- sortOrder
59
- updatedAt
60
- url
61
- assignee {
62
- id
63
- name
64
- email
65
- }
66
- creator {
67
- id
68
- name
69
- email
70
- }
71
- project {
72
- id
73
- name
74
- }
75
- state {
76
- id
77
- name
78
- }
79
- team {
80
- id
81
- name
82
- }
83
- `;
84
-
85
- const COMMENT_NODES = `
86
- id
87
- body
88
- createdAt
89
- reactionData
90
- updatedAt
91
- issue {
92
- id
93
- title
94
- project {
95
- id
96
- name
97
- }
98
- }
99
- user {
100
- id
101
- name
102
- }
103
- `;
104
-
105
46
  export default {
106
47
  WEBHOOK_ID,
107
48
  LINEAR_DELIVERY_HEADER,
@@ -113,6 +54,4 @@ export default {
113
54
  CLIENT_IPS,
114
55
  ORDER_BY_OPTIONS,
115
56
  FIELD,
116
- ISSUE_NODES,
117
- COMMENT_NODES,
118
57
  };
@@ -0,0 +1,104 @@
1
+ export default {
2
+ pageInfo: `
3
+ fragment PageInfo on PageInfo {
4
+ startCursor
5
+ endCursor
6
+ hasPreviousPage
7
+ hasNextPage
8
+ }
9
+ `,
10
+ issue: `
11
+ fragment Issue on Issue {
12
+ trashed
13
+ labelIds
14
+ url
15
+ identifier
16
+ priorityLabel
17
+ previousIdentifiers
18
+ customerTicketCount
19
+ branchName
20
+ botActor {
21
+ avatarUrl
22
+ name
23
+ userDisplayName
24
+ subType
25
+ type
26
+ id
27
+ }
28
+ cycle {
29
+ id
30
+ }
31
+ dueDate
32
+ estimate
33
+ description
34
+ title
35
+ number
36
+ lastAppliedTemplate {
37
+ id
38
+ }
39
+ updatedAt
40
+ sortOrder
41
+ subIssueSortOrder
42
+ parent {
43
+ id
44
+ }
45
+ priority
46
+ project {
47
+ id
48
+ }
49
+ projectMilestone {
50
+ id
51
+ }
52
+ team {
53
+ id
54
+ }
55
+ archivedAt
56
+ createdAt
57
+ startedTriageAt
58
+ triagedAt
59
+ autoArchivedAt
60
+ autoClosedAt
61
+ canceledAt
62
+ completedAt
63
+ startedAt
64
+ snoozedUntilAt
65
+ id
66
+ assignee {
67
+ id
68
+ }
69
+ creator {
70
+ id
71
+ }
72
+ snoozedBy {
73
+ id
74
+ }
75
+ favorite {
76
+ id
77
+ }
78
+ state {
79
+ id
80
+ }
81
+ }
82
+ `,
83
+ comment: `
84
+ fragment Comment on Comment {
85
+ id
86
+ body
87
+ createdAt
88
+ reactionData
89
+ updatedAt
90
+ issue {
91
+ id
92
+ title
93
+ project {
94
+ id
95
+ name
96
+ }
97
+ }
98
+ user {
99
+ id
100
+ name
101
+ }
102
+ }
103
+ `,
104
+ };
@@ -0,0 +1,60 @@
1
+ import fragments from "./fragments.mjs";
2
+
3
+ export default {
4
+ getIssue: `
5
+ query GetIssue($issueId: String!) {
6
+ issue(id: $issueId) {
7
+ ...Issue
8
+ }
9
+ }
10
+ ${fragments.issue}
11
+ `,
12
+ listIssues: `
13
+ query ListIssues(
14
+ $filter: IssueFilter,
15
+ $before: String,
16
+ $after: String,
17
+ $first: Int,
18
+ $last: Int,
19
+ $includeArchived: Boolean,
20
+ $orderBy: PaginationOrderBy
21
+ ) {
22
+ issues(
23
+ filter: $filter,
24
+ before: $before,
25
+ after: $after,
26
+ first: $first,
27
+ last: $last,
28
+ includeArchived: $includeArchived,
29
+ orderBy: $orderBy
30
+ ) {
31
+ pageInfo {
32
+ ...PageInfo
33
+ }
34
+ nodes {
35
+ ...Issue
36
+ }
37
+ }
38
+ }
39
+ ${fragments.issue}
40
+ ${fragments.pageInfo}
41
+ `,
42
+ getComment: `
43
+ query GetComment($commentId: String!) {
44
+ comment(id: $commentId) {
45
+ ...Comment
46
+ }
47
+ }
48
+ ${fragments.comment}
49
+ `,
50
+ listProjects: `
51
+ query ListProjects {
52
+ projects {
53
+ nodes {
54
+ id
55
+ name
56
+ }
57
+ }
58
+ }
59
+ `,
60
+ };
package/common/utils.mjs CHANGED
@@ -8,6 +8,15 @@ async function streamIterator(stream) {
8
8
  return resources;
9
9
  }
10
10
 
11
+ function strToObj(str) {
12
+ var obj = {};
13
+ if (str && typeof str === "string") {
14
+ var objStr = str.match(/\{(.)+\}/g);
15
+ eval("obj =" + objStr);
16
+ }
17
+ return obj;
18
+ }
19
+
11
20
  function buildVariables(endCursor, args) {
12
21
  const title = args.filter.query
13
22
  ? `title: { containsIgnoreCase: "${args.filter.query}" }`
@@ -18,13 +27,13 @@ function buildVariables(endCursor, args) {
18
27
  const projectId = args.filter.projectId
19
28
  ? `, project: { id: { eq: "${args.filter.projectId}" } }`
20
29
  : "";
21
- const team = args.filter.team
30
+ const team = args.filter.team && args.filter.team.id
22
31
  ? `, team: { id: { in: ${JSON.stringify(args.filter.team.id.in)} } }`
23
32
  : "";
24
33
  const project = args.filter.project && args.filter.project.id.eq
25
34
  ? `, project: { id: { eq: "${args.filter.project.id.eq}" } }`
26
35
  : "";
27
- const state = args.filter.state
36
+ const state = args.filter.state && args.filter.state.id.eq
28
37
  ? `, state: { id: { eq: "${args.filter.state.id.eq}" } }`
29
38
  : "";
30
39
  const assigneeId = args.filter.assigneeId
@@ -39,7 +48,7 @@ function buildVariables(endCursor, args) {
39
48
  }
40
49
 
41
50
  const orderBy = args.orderBy
42
- ? `, orderBy: ${args.orderBy}`
51
+ ? `, orderBy: "${args.orderBy}"`
43
52
  : "";
44
53
  const includeArchived = args.includeArchived
45
54
  ? `, includeArchived: ${args.includeArchived}`
@@ -47,10 +56,11 @@ function buildVariables(endCursor, args) {
47
56
  const after = endCursor
48
57
  ? `, after: "${endCursor}"`
49
58
  : "";
50
- return `filter: { ${filter} }, first: ${constants.DEFAULT_LIMIT}${orderBy}${includeArchived}${after}`;
59
+ return strToObj(`{ filter: { ${filter} }, first: ${constants.DEFAULT_LIMIT}${orderBy}${includeArchived}${after} }`);
51
60
  }
52
61
 
53
62
  export default {
54
63
  streamIterator,
64
+ strToObj,
55
65
  buildVariables,
56
66
  };
@@ -2,6 +2,7 @@ import { LinearClient } from "@linear/sdk";
2
2
  import constants from "./common/constants.mjs";
3
3
  import utils from "./common/utils.mjs";
4
4
  import { axios } from "@pipedream/platform";
5
+ import queries from "./common/queries.mjs";
5
6
 
6
7
  export default {
7
8
  type: "app",
@@ -57,7 +58,9 @@ export default {
57
58
  label: "Project",
58
59
  description: "The identifier or key of the project associated with the issue",
59
60
  optional: true,
60
- async options({ prevContext }) {
61
+ async options({
62
+ teamId, prevContext,
63
+ }) {
61
64
  return this.listResourcesOptions({
62
65
  prevContext,
63
66
  resourcesFn: this.listProjects,
@@ -67,6 +70,17 @@ export default {
67
70
  label: name,
68
71
  value: id,
69
72
  }),
73
+ resourcesArgs: teamId && {
74
+ filter: {
75
+ issues: {
76
+ team: {
77
+ id: {
78
+ eq: teamId,
79
+ },
80
+ },
81
+ },
82
+ },
83
+ },
70
84
  });
71
85
  },
72
86
  },
@@ -172,7 +186,7 @@ export default {
172
186
  Authorization: `${this.$auth.api_key}`,
173
187
  };
174
188
  },
175
- async makeAxiosRequest({
189
+ makeAxiosRequest({
176
190
  $ = this, ...args
177
191
  }) {
178
192
  return axios($, {
@@ -181,6 +195,12 @@ export default {
181
195
  ...args,
182
196
  });
183
197
  },
198
+ post(args = {}) {
199
+ return this.makeAxiosRequest({
200
+ method: "POST",
201
+ ...args,
202
+ });
203
+ },
184
204
  getClientOptions(options = {}) {
185
205
  return {
186
206
  apiKey: this.$auth.api_key,
@@ -205,18 +225,19 @@ export default {
205
225
  return this.client().updateIssue(issueId, input);
206
226
  },
207
227
  async listIssues(variables) {
208
- return this.client().issues(variables);
228
+ const { data: { issues } } = await this.post({
229
+ data: {
230
+ query: queries.listIssues,
231
+ variables,
232
+ },
233
+ });
234
+ return issues;
209
235
  },
210
- async getIssue(id) {
211
- const { data: { issue } } = await this.makeAxiosRequest({
212
- method: "POST",
236
+ async getIssue(variables) {
237
+ const { data: { issue } } = await this.post({
213
238
  data: {
214
- query: `
215
- {
216
- issue(id: "${id}") {
217
- ${constants.ISSUE_NODES}
218
- }
219
- }`,
239
+ query: queries.getIssue,
240
+ variables,
220
241
  },
221
242
  });
222
243
  return issue;
@@ -236,11 +257,11 @@ export default {
236
257
  async listTeams(variables = {}) {
237
258
  return this.client().teams(variables);
238
259
  },
239
- async listProjects() {
240
- const { data: { projects } } = await this.makeAxiosRequest({
241
- method: "POST",
260
+ async listProjects(variables) {
261
+ const { data: { projects } } = await this.post({
242
262
  data: {
243
- query: "{ projects { nodes { id name } } }",
263
+ query: queries.listProjects,
264
+ variables,
244
265
  },
245
266
  });
246
267
  return projects;
@@ -257,16 +278,11 @@ export default {
257
278
  async listComments(variables = {}) {
258
279
  return this.client().comments(variables);
259
280
  },
260
- async getComment(id) {
261
- const { data: { comment } } = await this.makeAxiosRequest({
262
- method: "POST",
281
+ async getComment(variables) {
282
+ const { data: { comment } } = await this.post({
263
283
  data: {
264
- query: `
265
- {
266
- comment(id: "${id}") {
267
- ${constants.COMMENT_NODES}
268
- }
269
- }`,
284
+ query: queries.getComment,
285
+ variables,
270
286
  },
271
287
  });
272
288
  return comment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/linear_app",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Pipedream Linear_app Components",
5
5
  "main": "linear_app.app.mjs",
6
6
  "keywords": [
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@linear/sdk": "^2.6.0",
17
+ "@linear/sdk": "^13.0.0",
18
18
  "@pipedream/platform": "^1.3.0"
19
19
  }
20
20
  }
@@ -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.1.3",
10
+ version: "0.1.5",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -26,7 +26,9 @@ export default {
26
26
  return false;
27
27
  },
28
28
  async isFromProject(body) {
29
- const comment = await this.linearApp.getComment(body.data.id);
29
+ const comment = await this.linearApp.getComment({
30
+ commentId: body.data.id,
31
+ });
30
32
  return !this.projectId || comment?.issue?.project?.id == this.projectId;
31
33
  },
32
34
  getResourcesFnArgs() {
@@ -78,6 +78,17 @@ export default {
78
78
  });
79
79
  },
80
80
  async activate() {
81
+ const args = {
82
+ resourceTypes: this.getResourceTypes(),
83
+ url: this.http.endpoint,
84
+ label: this.getWebhookLabel(),
85
+ };
86
+ if (!this.teamIds && !this.teamId) {
87
+ args.allPublicTeams = true;
88
+ const { _webhook: webhook } = await this.linearApp.createWebhook(args);
89
+ this.setWebhookId("1", webhook.id);
90
+ return;
91
+ }
81
92
  const teamIds = this.teamIds || [
82
93
  this.teamId,
83
94
  ];
@@ -85,14 +96,19 @@ export default {
85
96
  const { _webhook: webhook } =
86
97
  await this.linearApp.createWebhook({
87
98
  teamId,
88
- resourceTypes: this.getResourceTypes(),
89
- url: this.http.endpoint,
90
- label: this.getWebhookLabel(),
99
+ ...args,
91
100
  });
92
101
  this.setWebhookId(teamId, webhook.id);
93
102
  }
94
103
  },
95
104
  async deactivate() {
105
+ if (!this.teamIds && !this.teamId) {
106
+ const webhookId = this.getWebhookId("1");
107
+ if (webhookId) {
108
+ await this.linearApp.deleteWebhook(webhookId);
109
+ }
110
+ return;
111
+ }
96
112
  const teamIds = this.teamIds || [
97
113
  this.teamId,
98
114
  ];
@@ -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.3.3",
10
+ version: "0.3.5",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -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.3.3",
10
+ version: "0.3.5",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Issue Status Updated (Instant)",
8
8
  description: "Emit new event when the status of an issue is updated. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
9
9
  type: "source",
10
- version: "0.1.3",
10
+ version: "0.1.5",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  linearApp: common.props.linearApp,
@@ -20,6 +20,7 @@ export default {
20
20
  common.props.linearApp,
21
21
  "teamId",
22
22
  ],
23
+ optional: true,
23
24
  },
24
25
  projectId: {
25
26
  propDefinition: [
@@ -55,7 +56,7 @@ export default {
55
56
  return {
56
57
  sortBy: "updatedAt",
57
58
  filter: {
58
- team: {
59
+ team: this.teamId && {
59
60
  id: {
60
61
  in: [
61
62
  this.teamId,