generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.ts
30 lines (27 loc) · 1.14 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
28
29
30
import { EmitterWebhookEvent as WebhookEvent, EmitterWebhookEventName as WebhookEventName } from "@octokit/webhooks";
import { Octokit } from "@octokit/rest";
import { PluginSettings } from "./plugin-inputs";
import { createAdapters } from "../adapters";
export type SupportedEventsU = "issue_comment.created";
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: {
UBIQUIBOT_TOKEN: string;
SUPABASE_URL: string;
SUPABASE_KEY: string;
};
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;
};
}