@pipedream/linear_app 0.4.7 → 0.5.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.8",
8
+ version: "0.4.1",
9
9
  props: {
10
10
  linearApp,
11
11
  teamId: {
@@ -32,6 +32,15 @@ export default {
32
32
  "assigneeId",
33
33
  ],
34
34
  },
35
+ stateId: {
36
+ propDefinition: [
37
+ linearApp,
38
+ "stateId",
39
+ ({ teamId }) => ({
40
+ teamId,
41
+ }),
42
+ ],
43
+ },
35
44
  },
36
45
  async run({ $ }) {
37
46
  const {
@@ -39,6 +48,7 @@ export default {
39
48
  description,
40
49
  teamId,
41
50
  assigneeId,
51
+ stateId,
42
52
  } = this;
43
53
 
44
54
  const response =
@@ -47,6 +57,7 @@ export default {
47
57
  title,
48
58
  description,
49
59
  assigneeId,
60
+ stateId,
50
61
  });
51
62
 
52
63
  const summary = response.success
@@ -1,10 +1,12 @@
1
1
  import linearApp from "../../linear_app.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+ const getAdditionalIssueInformation = utils.getAdditionalIssueInformation;
2
4
 
3
5
  export default {
4
6
  key: "linear_app-get-issue",
5
7
  name: "Get Issue",
6
8
  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.5",
9
+ version: "0.1.1",
8
10
  type: "action",
9
11
  props: {
10
12
  linearApp,
@@ -16,9 +18,14 @@ export default {
16
18
  description: "The issue ID",
17
19
  },
18
20
  },
21
+ methods: {
22
+ getAdditionalIssueInformation,
23
+ },
19
24
  async run({ $ }) {
20
25
  const issue = await this.linearApp.getIssue(this.issueId);
21
26
  $.export("$summary", `Found issue with ID ${this.issueId}`);
22
- return issue;
27
+ return (await this.getAdditionalIssueInformation([
28
+ issue,
29
+ ]))[0];
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.1.7",
7
+ version: "0.2.1",
8
8
  type: "action",
9
9
  props: {
10
10
  linearApp,
@@ -1,12 +1,14 @@
1
- import constants from "../../common/constants.mjs";
2
1
  import linearApp from "../../linear_app.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+ import utils from "../../common/utils.mjs";
4
+ const getAdditionalIssueInformation = utils.getAdditionalIssueInformation;
3
5
 
4
6
  export default {
5
7
  key: "linear_app-search-issues",
6
8
  name: "Search Issues",
7
9
  description: "Search issues (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)",
8
10
  type: "action",
9
- version: "0.1.6",
11
+ version: "0.2.1",
10
12
  props: {
11
13
  linearApp,
12
14
  query: {
@@ -54,6 +56,7 @@ export default {
54
56
  },
55
57
  },
56
58
  methods: {
59
+ getAdditionalIssueInformation,
57
60
  buildFilter() {
58
61
  return {
59
62
  title: {
@@ -112,6 +115,6 @@ export default {
112
115
 
113
116
  $.export("$summary", `Found ${issues.length} issues`);
114
117
 
115
- return issues;
118
+ return await this.getAdditionalIssueInformation(issues);
116
119
  },
117
120
  };
@@ -5,13 +5,23 @@ 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.8",
8
+ version: "0.1.1",
9
9
  props: {
10
10
  linearApp,
11
+ teamId: {
12
+ label: "Current Team",
13
+ propDefinition: [
14
+ linearApp,
15
+ "teamId",
16
+ ],
17
+ },
11
18
  issueId: {
12
19
  propDefinition: [
13
20
  linearApp,
14
21
  "issueId",
22
+ ({ teamId }) => ({
23
+ teamId,
24
+ }),
15
25
  ],
16
26
  },
17
27
  title: {
@@ -28,13 +38,25 @@ export default {
28
38
  "issueDescription",
29
39
  ],
30
40
  },
31
- teamId: {
41
+ teamIdToUpdate: {
42
+ description: "The identifier or key of the team to update the issue to",
32
43
  optional: true,
33
44
  propDefinition: [
34
45
  linearApp,
35
46
  "teamId",
36
47
  ],
37
48
  },
49
+ stateId: {
50
+ propDefinition: [
51
+ linearApp,
52
+ "stateId",
53
+ ({
54
+ teamId, teamIdToUpdate,
55
+ }) => ({
56
+ teamId: teamIdToUpdate || teamId,
57
+ }),
58
+ ],
59
+ },
38
60
  assigneeId: {
39
61
  propDefinition: [
40
62
  linearApp,
@@ -47,7 +69,8 @@ export default {
47
69
  issueId,
48
70
  title,
49
71
  description,
50
- teamId,
72
+ teamIdToUpdate,
73
+ stateId,
51
74
  assigneeId,
52
75
  } = this;
53
76
 
@@ -55,10 +78,11 @@ export default {
55
78
  await this.linearApp.updateIssue({
56
79
  issueId,
57
80
  input: {
58
- teamId,
81
+ teamId: teamIdToUpdate,
59
82
  title,
60
83
  description,
61
84
  assigneeId,
85
+ stateId,
62
86
  },
63
87
  });
64
88
 
package/common/utils.mjs CHANGED
@@ -6,6 +6,33 @@ async function streamIterator(stream) {
6
6
  return resources;
7
7
  }
8
8
 
9
+ async function getAdditionalIssueInformation(issues = []) {
10
+ const updatedIssues = [];
11
+ for (const issue of issues) {
12
+ const {
13
+ _assignee, _creator, _project, _state, _team,
14
+ } = issue;
15
+ if (_assignee?.id) {
16
+ issue._assignee = await this.linearApp.getUser(_assignee.id);
17
+ }
18
+ if (_creator?.id) {
19
+ issue._creator = await this.linearApp.getUser(_creator.id);
20
+ }
21
+ if (_project?.id) {
22
+ issue._project = await this.linearApp.getProject(_project.id);
23
+ }
24
+ if (_state?.id) {
25
+ issue._state = await this.linearApp.getState(_state.id);
26
+ }
27
+ if (_team?.id) {
28
+ issue._team = await this.linearApp.getTeam(_team.id);
29
+ }
30
+ updatedIssues.push(issue);
31
+ }
32
+ return updatedIssues;
33
+ }
34
+
9
35
  export default {
10
36
  streamIterator,
37
+ getAdditionalIssueInformation,
11
38
  };
@@ -6,35 +6,46 @@ export default {
6
6
  type: "app",
7
7
  app: "linear_app",
8
8
  propDefinitions: {
9
- issueId: {
9
+ teamId: {
10
10
  type: "string",
11
- label: "Issue ID",
12
- description: "The issue ID to update",
11
+ label: "Team",
12
+ description: "The identifier or key of the team associated with the issue",
13
13
  async options({ prevContext }) {
14
14
  return this.listResourcesOptions({
15
15
  prevContext,
16
- resourcesFn: this.listIssues,
16
+ resourcesFn: this.listTeams,
17
17
  resouceMapper: ({
18
- id, title,
18
+ id, name,
19
19
  }) => ({
20
- label: title,
20
+ label: name,
21
21
  value: id,
22
22
  }),
23
23
  });
24
24
  },
25
25
  },
26
- teamId: {
26
+ issueId: {
27
27
  type: "string",
28
- label: "Team ID",
29
- description: "The identifier or key of the team associated with the issue",
30
- async options({ prevContext }) {
28
+ label: "Issue",
29
+ description: "The issue to update",
30
+ async options({
31
+ teamId, prevContext,
32
+ }) {
31
33
  return this.listResourcesOptions({
32
34
  prevContext,
33
- resourcesFn: this.listTeams,
35
+ resourcesFn: this.listIssues,
36
+ resourcesArgs: teamId && {
37
+ filter: {
38
+ team: {
39
+ id: {
40
+ eq: teamId,
41
+ },
42
+ },
43
+ },
44
+ },
34
45
  resouceMapper: ({
35
- id, name,
46
+ id, title,
36
47
  }) => ({
37
- label: name,
48
+ label: title,
38
49
  value: id,
39
50
  }),
40
51
  });
@@ -42,7 +53,7 @@ export default {
42
53
  },
43
54
  projectId: {
44
55
  type: "string",
45
- label: "Project ID",
56
+ label: "Project",
46
57
  description: "The identifier or key of the project associated with the issue",
47
58
  optional: true,
48
59
  async options({ prevContext }) {
@@ -65,8 +76,8 @@ export default {
65
76
  },
66
77
  assigneeId: {
67
78
  type: "string",
68
- label: "Assignee ID",
69
- description: "The identifier of the user to assign the issue to",
79
+ label: "Assignee",
80
+ description: "The user to assign to the issue",
70
81
  optional: true,
71
82
  async options({ prevContext }) {
72
83
  return this.listResourcesOptions({
@@ -81,6 +92,35 @@ export default {
81
92
  });
82
93
  },
83
94
  },
95
+ stateId: {
96
+ type: "string",
97
+ label: "State (Status)",
98
+ description: "The state (status) to assign to the issue",
99
+ optional: true,
100
+ async options({
101
+ teamId, prevContext,
102
+ }) {
103
+ return this.listResourcesOptions({
104
+ prevContext,
105
+ resourcesFn: this.listStates,
106
+ resourcesArgs: teamId && {
107
+ filter: {
108
+ team: {
109
+ id: {
110
+ eq: teamId,
111
+ },
112
+ },
113
+ },
114
+ },
115
+ resouceMapper: ({
116
+ id: value, name: label,
117
+ }) => ({
118
+ label,
119
+ value,
120
+ }),
121
+ });
122
+ },
123
+ },
84
124
  boardOrder: {
85
125
  type: "string",
86
126
  label: "Board order",
@@ -169,6 +209,18 @@ export default {
169
209
  async getIssue(id) {
170
210
  return this.client().issue(id);
171
211
  },
212
+ async getUser(id) {
213
+ return this.client().user(id);
214
+ },
215
+ async getProject(id) {
216
+ return this.client().project(id);
217
+ },
218
+ async getState(id) {
219
+ return this.client().workflowState(id);
220
+ },
221
+ async getTeam(id) {
222
+ return this.client().team(id);
223
+ },
172
224
  async listTeams(variables = {}) {
173
225
  return this.client().teams(variables);
174
226
  },
@@ -184,6 +236,9 @@ export default {
184
236
  async listUsers(variables = {}) {
185
237
  return this.client().users(variables);
186
238
  },
239
+ async listStates(variables = {}) {
240
+ return this.client().workflowStates(variables);
241
+ },
187
242
  async listIssues(variables = {}) {
188
243
  return this.client().issues(variables);
189
244
  },
@@ -194,8 +249,8 @@ export default {
194
249
  return this.client().comments(variables);
195
250
  },
196
251
  async listResourcesOptions({
197
- prevContext, resourcesFn, resouceMapper,
198
- }) {
252
+ prevContext, resourcesFn, resourcesArgs, resouceMapper,
253
+ } = {}) {
199
254
  const {
200
255
  after,
201
256
  hasNextPage,
@@ -212,6 +267,7 @@ export default {
212
267
  await resourcesFn({
213
268
  after,
214
269
  first: constants.DEFAULT_LIMIT,
270
+ ...resourcesArgs,
215
271
  });
216
272
 
217
273
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/linear_app",
3
- "version": "0.4.7",
3
+ "version": "0.5.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.7",
10
+ version: "0.1.1",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,
@@ -1,6 +1,7 @@
1
1
  import linearApp from "../../linear_app.app.mjs";
2
2
  import constants from "../../common/constants.mjs";
3
3
  import utils from "../../common/utils.mjs";
4
+ const getAdditionalIssueInformation = utils.getAdditionalIssueInformation;
4
5
 
5
6
  export default {
6
7
  props: {
@@ -23,6 +24,7 @@ export default {
23
24
  db: "$.service.db",
24
25
  },
25
26
  methods: {
27
+ getAdditionalIssueInformation,
26
28
  setWebhookId(teamId, id) {
27
29
  this.db.set(`webhook-${teamId}`, id);
28
30
  },
@@ -65,7 +67,11 @@ export default {
65
67
  resourcesFn: this.getResourcesFn(),
66
68
  resourcesFnArgs: this.getResourcesFnArgs(),
67
69
  });
68
- const resources = await utils.streamIterator(stream);
70
+ let resources = await utils.streamIterator(stream);
71
+
72
+ if (this.getResourceTypes().includes(constants.RESOURCE_TYPE.ISSUE)) {
73
+ resources = await this.getAdditionalIssueInformation(resources);
74
+ }
69
75
 
70
76
  resources
71
77
  .reverse()
@@ -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.6",
10
+ version: "0.3.1",
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.2.6",
10
+ version: "0.3.1",
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.0.1",
10
+ version: "0.1.1",
11
11
  dedupe: "unique",
12
12
  methods: {
13
13
  ...common.methods,