15f17d27e0
* Unleash GPT magic * Clean up after GPT * All the hooks * Provisional integration catalog entry * Sample webhook jobs * Attachments with alpha warnings * Remove some verbose logs * Fix IP restrictions * Remove tunnel * Revert "Remove tunnel" This reverts commit c5b69ce6524e3b40c26b66cdc56e087b8576b8c6. * Resolve event name clashes * Remove circular dependency * Use correct payload uuid * Schema fixes * Fix webhook event name * Start to Linearify catalog entry * Remove todo * More catalog updates * Make OAuth work * Rename webhook helper * Schema juggling * More discrimination * Add Issue SLA event * Simplify triggers * Handle rate limits * Fix Project schema * Payload examples * Improve event props * Remove redundant source metadata * One type to rule them all * Recursive WithoutFunctions type * Linear output serializer * Some tasks * Update catalog entry * Dynamic usage sample * Bump version * Remove tunnel * More tasks * Add optional skipRetrying on runTask errors * Fail fast on user errors * Entity getter tasks * Another couple of tasks * Token to apiKey * Sort tasks * Add filtered issue SLA triggers * Add docs * Type fixes * Job catalog examples * Serialization helper docs * Add changeset * Refactor webhooks * Enhance properties * Pagination helper and docs * Clean up imports * Change misc catalog job --------- Co-authored-by: Matt Aitken <matt@mattaitken.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
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(", "),
|
|
},
|
|
];
|
|
};
|