generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext.ts
27 lines (24 loc) · 1.11 KB
/
context.ts
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
import { Octokit } from "@octokit/rest";
import { EmitterWebhookEvent as WebhookEvent, EmitterWebhookEventName as WebhookEventName } from "@octokit/webhooks";
import { createAdapters } from "../adapters";
import { Env } from "./env";
import { PluginSettings } from "./plugin-inputs";
export type SupportedEventsU = "issue_comment.created"; // Add more events here
export type SupportedEvents = {
[K in SupportedEventsU]: K extends WebhookEventName ? WebhookEvent<K> : never;
};
export interface Context<T extends SupportedEventsU = SupportedEventsU, TU extends SupportedEvents[T] = SupportedEvents[T]> {
eventName: T;
payload: TU["payload"];
octokit: InstanceType<typeof Octokit>;
adapters: ReturnType<typeof createAdapters>;
config: PluginSettings;
env: Env;
logger: {
fatal: (message: unknown, ...optionalParams: unknown[]) => void;
error: (message: unknown, ...optionalParams: unknown[]) => void;
warn: (message: unknown, ...optionalParams: unknown[]) => void;
info: (message: unknown, ...optionalParams: unknown[]) => void;
debug: (message: unknown, ...optionalParams: unknown[]) => void;
};
}