forked from triggerdotdev/trigger.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
60 lines (54 loc) · 1.85 KB
/
Copy pathutils.ts
File metadata and controls
60 lines (54 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { CommentEvent, IssueEvent, WebhookPayload } from "./schemas";
import { GetLinearPayload } from "./types";
import { LinearDocument as L } from "@linear/sdk";
export type QueryVariables = {
after: string;
before: string;
first: number;
includeArchived: boolean;
last: number;
orderBy: L.PaginationOrderBy;
};
export type Nullable<T> = Partial<{
[K in keyof T]: T[K] | null;
}>;
export const onCommentProperties = (payload: GetLinearPayload<CommentEvent>) => {
return [
{ label: "Comment ID", text: payload.data.id },
{ label: "Issue ID", text: payload.data.issueId },
{ label: "Issue Title", text: payload.data.issue.title, url: payload.url ?? undefined },
];
};
export const onIssueProperties = (payload: GetLinearPayload<IssueEvent>) => {
return [
{ label: "Issue ID", text: payload.data.id },
{
label: "Issue",
text: `[${payload.data.team.key}-${payload.data.number}] ${payload.data.title}`,
url: payload.url ?? undefined,
},
];
};
export const queryProperties = (query: Nullable<QueryVariables>) => {
return [
...(query.after ? [{ label: "After", text: query.after }] : []),
...(query.before ? [{ label: "Before", text: query.before }] : []),
...(query.first ? [{ label: "First", text: String(query.first) }] : []),
...(query.last ? [{ label: "Last", text: String(query.last) }] : []),
...(query.orderBy ? [{ label: "Order by", text: query.orderBy }] : []),
...(query.includeArchived
? [{ label: "Include archived", text: String(query.includeArchived) }]
: []),
];
};
export const updatedFromProperties = (payload: WebhookPayload) => {
if (payload.action !== "update") return [];
return [
{
label: "Updated Keys",
text: Object.keys(payload.updatedFrom)
.filter((key) => !["editedAt", "updatedAt"].includes(key))
.join(", "),
},
];
};