@pipedream/linear_app 0.3.4 → 0.4.0
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/linear_app.app.mjs +23 -0
- package/package.json +1 -1
- package/sources/comment-created-instant/comment-created-instant.mjs +43 -0
- package/sources/common/webhook.mjs +23 -0
- package/sources/issue-created-instant/issue-created-instant.mjs +4 -1
- package/sources/issue-updated-instant/issue-updated-instant.mjs +4 -1
package/linear_app.app.mjs
CHANGED
|
@@ -171,6 +171,9 @@ export default {
|
|
|
171
171
|
async listIssueLabels(variables = {}) {
|
|
172
172
|
return this.client().issueLabels(variables);
|
|
173
173
|
},
|
|
174
|
+
async listComments(variables = {}) {
|
|
175
|
+
return this.client().comments(variables);
|
|
176
|
+
},
|
|
174
177
|
async listResourcesOptions({
|
|
175
178
|
prevContext, resourcesFn, resouceMapper,
|
|
176
179
|
}) {
|
|
@@ -200,5 +203,25 @@ export default {
|
|
|
200
203
|
},
|
|
201
204
|
};
|
|
202
205
|
},
|
|
206
|
+
async *paginateResources({ resourcesFn }) {
|
|
207
|
+
const params = {
|
|
208
|
+
after: null,
|
|
209
|
+
first: constants.DEFAULT_LIMIT,
|
|
210
|
+
};
|
|
211
|
+
let hasNextPage = true;
|
|
212
|
+
do {
|
|
213
|
+
const {
|
|
214
|
+
nodes,
|
|
215
|
+
pageInfo,
|
|
216
|
+
} = await resourcesFn(params);
|
|
217
|
+
for (const d of nodes) {
|
|
218
|
+
yield d;
|
|
219
|
+
}
|
|
220
|
+
hasNextPage = pageInfo.hasNextPage;
|
|
221
|
+
if (hasNextPage) {
|
|
222
|
+
params.after = pageInfo.endCursor;
|
|
223
|
+
}
|
|
224
|
+
} while (hasNextPage);
|
|
225
|
+
},
|
|
203
226
|
},
|
|
204
227
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import common from "../common/webhook.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "linear_app-comment-created-instant",
|
|
7
|
+
name: "New Created Comment (Instant)",
|
|
8
|
+
description: "Emit new event when a new comment is created. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
|
|
9
|
+
type: "source",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
methods: {
|
|
13
|
+
...common.methods,
|
|
14
|
+
getResourceTypes() {
|
|
15
|
+
return [
|
|
16
|
+
constants.RESOURCE_TYPE.COMMENT,
|
|
17
|
+
];
|
|
18
|
+
},
|
|
19
|
+
getWebhookLabel() {
|
|
20
|
+
return "Comment created";
|
|
21
|
+
},
|
|
22
|
+
getActions() {
|
|
23
|
+
return [
|
|
24
|
+
constants.ACTION.CREATE,
|
|
25
|
+
];
|
|
26
|
+
},
|
|
27
|
+
getResourcesFn() {
|
|
28
|
+
return this.linearApp.listComments;
|
|
29
|
+
},
|
|
30
|
+
getMetadata(resource) {
|
|
31
|
+
const {
|
|
32
|
+
delivery,
|
|
33
|
+
data,
|
|
34
|
+
createdAt,
|
|
35
|
+
} = resource;
|
|
36
|
+
return {
|
|
37
|
+
id: delivery,
|
|
38
|
+
summary: `Comment created: ${data.title}`,
|
|
39
|
+
ts: Date.parse(createdAt),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -51,8 +51,31 @@ export default {
|
|
|
51
51
|
getMetadata() {
|
|
52
52
|
throw new Error("getMetadata is not implemented");
|
|
53
53
|
},
|
|
54
|
+
getResourcesFn() {
|
|
55
|
+
throw new Error("Get resource function not implemented");
|
|
56
|
+
},
|
|
54
57
|
},
|
|
55
58
|
hooks: {
|
|
59
|
+
async deploy() {
|
|
60
|
+
// Retrieve historical events
|
|
61
|
+
console.log("Retrieving historical events...");
|
|
62
|
+
const events = this.linearApp.paginateResources({
|
|
63
|
+
resourcesFn: this.getResourcesFn(),
|
|
64
|
+
});
|
|
65
|
+
for await (const event of events) {
|
|
66
|
+
const [
|
|
67
|
+
action,
|
|
68
|
+
] = this.getActions();
|
|
69
|
+
const [
|
|
70
|
+
resourceType,
|
|
71
|
+
] = this.getResourceTypes();
|
|
72
|
+
this.$emit(event, {
|
|
73
|
+
id: event.id,
|
|
74
|
+
ts: Date.parse(event.updatedAt),
|
|
75
|
+
summary: `New ${action} ${resourceType} event: ${event.id}`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
56
79
|
async activate() {
|
|
57
80
|
const params = {
|
|
58
81
|
resourceTypes: this.getResourceTypes(),
|
|
@@ -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.
|
|
10
|
+
version: "0.2.0",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
@@ -24,6 +24,9 @@ export default {
|
|
|
24
24
|
constants.ACTION.CREATE,
|
|
25
25
|
];
|
|
26
26
|
},
|
|
27
|
+
getResourcesFn() {
|
|
28
|
+
return this.linearApp.listIssues;
|
|
29
|
+
},
|
|
27
30
|
getMetadata(resource) {
|
|
28
31
|
const {
|
|
29
32
|
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.
|
|
10
|
+
version: "0.2.0",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
@@ -24,6 +24,9 @@ export default {
|
|
|
24
24
|
constants.ACTION.UPDATE,
|
|
25
25
|
];
|
|
26
26
|
},
|
|
27
|
+
getResourcesFn() {
|
|
28
|
+
return this.linearApp.listIssues;
|
|
29
|
+
},
|
|
27
30
|
getMetadata(resource) {
|
|
28
31
|
const {
|
|
29
32
|
delivery,
|