@pipedream/linear_app 0.4.1 → 0.4.2
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.
- package/actions/create-issue/create-issue.mjs +1 -1
- package/actions/get-issue/get-issue.mjs +1 -1
- package/actions/get-teams/get-teams.mjs +1 -1
- package/actions/search-issues/search-issues.mjs +1 -1
- package/actions/update-issue/update-issue.mjs +1 -1
- package/common/constants.mjs +3 -1
- package/common/utils.mjs +11 -0
- package/linear_app.app.mjs +20 -31
- package/package.json +1 -1
- package/sources/comment-created-instant/comment-created-instant.mjs +17 -11
- package/sources/common/webhook.mjs +25 -30
- package/sources/issue-created-instant/issue-created-instant.mjs +15 -11
- package/sources/issue-updated-instant/issue-updated-instant.mjs +15 -11
|
@@ -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
|
+
version: "0.3.6",
|
|
9
9
|
props: {
|
|
10
10
|
linearApp,
|
|
11
11
|
teamId: {
|
|
@@ -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.
|
|
7
|
+
version: "0.0.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linearApp,
|
|
@@ -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
|
+
version: "0.1.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.1.
|
|
9
|
+
version: "0.1.4",
|
|
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.0.
|
|
8
|
+
version: "0.0.5",
|
|
9
9
|
props: {
|
|
10
10
|
linearApp,
|
|
11
11
|
issueId: {
|
package/common/constants.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const WEBHOOK_ID = "webhookId";
|
|
2
2
|
const LINEAR_DELIVERY_HEADER = "linear-delivery";
|
|
3
|
-
const DEFAULT_LIMIT =
|
|
3
|
+
const DEFAULT_LIMIT = 100;
|
|
4
|
+
const DEFAULT_MAX_RECORDS = 200;
|
|
4
5
|
|
|
5
6
|
const ACTION = {
|
|
6
7
|
CREATE: "create",
|
|
@@ -46,6 +47,7 @@ export default {
|
|
|
46
47
|
WEBHOOK_ID,
|
|
47
48
|
LINEAR_DELIVERY_HEADER,
|
|
48
49
|
DEFAULT_LIMIT,
|
|
50
|
+
DEFAULT_MAX_RECORDS,
|
|
49
51
|
ACTION,
|
|
50
52
|
RESOURCE_TYPE,
|
|
51
53
|
RESOURCE_TYPES,
|
package/common/utils.mjs
ADDED
package/linear_app.app.mjs
CHANGED
|
@@ -203,42 +203,31 @@ export default {
|
|
|
203
203
|
},
|
|
204
204
|
};
|
|
205
205
|
},
|
|
206
|
-
async *paginateResources({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
let
|
|
206
|
+
async *paginateResources({
|
|
207
|
+
resourcesFn,
|
|
208
|
+
resourcesFnArgs,
|
|
209
|
+
max = constants.DEFAULT_MAX_RECORDS,
|
|
210
|
+
}) {
|
|
211
|
+
let counter = 0;
|
|
212
|
+
let hasNextPage;
|
|
213
|
+
let endCursor;
|
|
212
214
|
do {
|
|
213
215
|
const {
|
|
214
216
|
nodes,
|
|
215
217
|
pageInfo,
|
|
216
|
-
} = await resourcesFn(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
} while (hasNextPage);
|
|
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;
|
|
218
|
+
} = await resourcesFn({
|
|
219
|
+
after: endCursor,
|
|
220
|
+
first: constants.DEFAULT_LIMIT,
|
|
221
|
+
...resourcesFnArgs,
|
|
222
|
+
});
|
|
223
|
+
for (const node of nodes) {
|
|
224
|
+
counter += 1;
|
|
225
|
+
yield node;
|
|
239
226
|
}
|
|
240
|
-
|
|
241
|
-
|
|
227
|
+
({
|
|
228
|
+
hasNextPage, endCursor,
|
|
229
|
+
} = pageInfo);
|
|
230
|
+
} while (hasNextPage && counter < max);
|
|
242
231
|
},
|
|
243
232
|
},
|
|
244
233
|
};
|
package/package.json
CHANGED
|
@@ -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.
|
|
10
|
+
version: "0.0.4",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
@@ -19,27 +19,33 @@ export default {
|
|
|
19
19
|
getWebhookLabel() {
|
|
20
20
|
return "Comment created";
|
|
21
21
|
},
|
|
22
|
-
getActions() {
|
|
23
|
-
return [
|
|
24
|
-
constants.ACTION.CREATE,
|
|
25
|
-
];
|
|
26
|
-
},
|
|
27
22
|
getResourcesFn() {
|
|
28
23
|
return this.linearApp.listComments;
|
|
29
24
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
25
|
+
getResourcesFnArgs() {
|
|
26
|
+
return {
|
|
27
|
+
sortBy: "createdAt",
|
|
28
|
+
filter: {
|
|
29
|
+
issue: {
|
|
30
|
+
project: {
|
|
31
|
+
id: {
|
|
32
|
+
eq: this.projectId,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
33
38
|
},
|
|
34
39
|
getMetadata(resource) {
|
|
35
40
|
const {
|
|
36
41
|
delivery,
|
|
42
|
+
body,
|
|
37
43
|
data,
|
|
38
44
|
createdAt,
|
|
39
45
|
} = resource;
|
|
40
46
|
return {
|
|
41
|
-
id: delivery,
|
|
42
|
-
summary: `New comment event created: ${data
|
|
47
|
+
id: delivery || resource.id,
|
|
48
|
+
summary: `New comment event created: ${data?.body || body}`,
|
|
43
49
|
ts: Date.parse(createdAt),
|
|
44
50
|
};
|
|
45
51
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import linearApp from "../../linear_app.app.mjs";
|
|
2
2
|
import constants from "../../common/constants.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
6
|
props: {
|
|
@@ -11,7 +12,12 @@ export default {
|
|
|
11
12
|
linearApp,
|
|
12
13
|
"teamId",
|
|
13
14
|
],
|
|
14
|
-
|
|
15
|
+
},
|
|
16
|
+
projectId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
linearApp,
|
|
19
|
+
"projectId",
|
|
20
|
+
],
|
|
15
21
|
},
|
|
16
22
|
http: "$.interface.http",
|
|
17
23
|
db: "$.service.db",
|
|
@@ -32,15 +38,15 @@ export default {
|
|
|
32
38
|
getWebhookLabel() {
|
|
33
39
|
throw new Error("getWebhookLabel is not implemented");
|
|
34
40
|
},
|
|
35
|
-
getActions() {
|
|
36
|
-
throw new Error("getActions is not implemented");
|
|
37
|
-
},
|
|
38
41
|
getMetadata() {
|
|
39
42
|
throw new Error("getMetadata is not implemented");
|
|
40
43
|
},
|
|
41
44
|
getResourcesFn() {
|
|
42
45
|
throw new Error("Get resource function not implemented");
|
|
43
46
|
},
|
|
47
|
+
getResourcesFnArgs() {
|
|
48
|
+
throw new Error("Get resource function arguments not implemented");
|
|
49
|
+
},
|
|
44
50
|
getLoadedProjectId() {
|
|
45
51
|
throw new Error("Get loaded project ID not implemented");
|
|
46
52
|
},
|
|
@@ -49,38 +55,27 @@ export default {
|
|
|
49
55
|
async deploy() {
|
|
50
56
|
// Retrieve historical events
|
|
51
57
|
console.log("Retrieving historical events...");
|
|
52
|
-
const
|
|
58
|
+
const stream = this.linearApp.paginateResources({
|
|
53
59
|
resourcesFn: this.getResourcesFn(),
|
|
60
|
+
resourcesFnArgs: this.getResourcesFnArgs(),
|
|
54
61
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const [
|
|
62
|
-
action,
|
|
63
|
-
] = this.getActions();
|
|
64
|
-
const [
|
|
65
|
-
resourceType,
|
|
66
|
-
] = this.getResourceTypes();
|
|
67
|
-
this.$emit(event, {
|
|
68
|
-
id: event.id,
|
|
69
|
-
ts: Date.parse(event.updatedAt),
|
|
70
|
-
summary: `New ${action} ${resourceType} event: ${event.id}`,
|
|
62
|
+
const resources = await utils.streamIterator(stream);
|
|
63
|
+
|
|
64
|
+
resources
|
|
65
|
+
.reverse()
|
|
66
|
+
.forEach((resource) => {
|
|
67
|
+
this.$emit(resource, this.getMetadata(resource));
|
|
71
68
|
});
|
|
72
|
-
}
|
|
73
69
|
},
|
|
74
70
|
async activate() {
|
|
75
|
-
const params = {
|
|
76
|
-
resourceTypes: this.getResourceTypes(),
|
|
77
|
-
url: this.http.endpoint,
|
|
78
|
-
label: this.getWebhookLabel(),
|
|
79
|
-
};
|
|
80
|
-
|
|
81
71
|
for (const teamId of this.teamIds) {
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
const { _webhook: webhook } =
|
|
73
|
+
await this.linearApp.createWebhook({
|
|
74
|
+
teamId,
|
|
75
|
+
resourceTypes: this.getResourceTypes(),
|
|
76
|
+
url: this.http.endpoint,
|
|
77
|
+
label: this.getWebhookLabel(),
|
|
78
|
+
});
|
|
84
79
|
this.setWebhookId(teamId, webhook.id);
|
|
85
80
|
}
|
|
86
81
|
},
|
|
@@ -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.
|
|
10
|
+
version: "0.2.3",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
@@ -19,27 +19,31 @@ export default {
|
|
|
19
19
|
getWebhookLabel() {
|
|
20
20
|
return "Issue created";
|
|
21
21
|
},
|
|
22
|
-
getActions() {
|
|
23
|
-
return [
|
|
24
|
-
constants.ACTION.CREATE,
|
|
25
|
-
];
|
|
26
|
-
},
|
|
27
22
|
getResourcesFn() {
|
|
28
23
|
return this.linearApp.listIssues;
|
|
29
24
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
25
|
+
getResourcesFnArgs() {
|
|
26
|
+
return {
|
|
27
|
+
sortBy: "createdAt",
|
|
28
|
+
filter: {
|
|
29
|
+
project: {
|
|
30
|
+
id: {
|
|
31
|
+
eq: this.projectId,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
33
36
|
},
|
|
34
37
|
getMetadata(resource) {
|
|
35
38
|
const {
|
|
36
39
|
delivery,
|
|
40
|
+
title,
|
|
37
41
|
data,
|
|
38
42
|
createdAt,
|
|
39
43
|
} = resource;
|
|
40
44
|
return {
|
|
41
|
-
id: delivery,
|
|
42
|
-
summary: `Issue created: ${data
|
|
45
|
+
id: delivery || resource.id,
|
|
46
|
+
summary: `Issue created: ${data?.title || title}`,
|
|
43
47
|
ts: Date.parse(createdAt),
|
|
44
48
|
};
|
|
45
49
|
},
|
|
@@ -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.
|
|
10
|
+
version: "0.2.3",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
@@ -19,27 +19,31 @@ export default {
|
|
|
19
19
|
getWebhookLabel() {
|
|
20
20
|
return "Issue updated";
|
|
21
21
|
},
|
|
22
|
-
getActions() {
|
|
23
|
-
return [
|
|
24
|
-
constants.ACTION.UPDATE,
|
|
25
|
-
];
|
|
26
|
-
},
|
|
27
22
|
getResourcesFn() {
|
|
28
23
|
return this.linearApp.listIssues;
|
|
29
24
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
25
|
+
getResourcesFnArgs() {
|
|
26
|
+
return {
|
|
27
|
+
sortBy: "updatedAt",
|
|
28
|
+
filter: {
|
|
29
|
+
project: {
|
|
30
|
+
id: {
|
|
31
|
+
eq: this.projectId,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
33
36
|
},
|
|
34
37
|
getMetadata(resource) {
|
|
35
38
|
const {
|
|
36
39
|
delivery,
|
|
40
|
+
title,
|
|
37
41
|
data,
|
|
38
42
|
updatedAt,
|
|
39
43
|
} = resource;
|
|
40
44
|
return {
|
|
41
|
-
id: delivery,
|
|
42
|
-
summary: `Issue Updated: ${data
|
|
45
|
+
id: delivery || resource.id,
|
|
46
|
+
summary: `Issue Updated: ${data?.title || title}`,
|
|
43
47
|
ts: Date.parse(updatedAt),
|
|
44
48
|
};
|
|
45
49
|
},
|