UNPKG

4.5 kBTypeScriptView Raw
1import express from "express";
2import type { EmitterWebhookEvent as WebhookEvent, Webhooks } from "@octokit/webhooks";
3import type { LRUCache } from "lru-cache";
4import type { RedisOptions } from "ioredis";
5import type { Options as LoggingOptions } from "pino-http";
6import { Probot } from "./index.js";
7import { Context } from "./context.js";
8import { ProbotOctokit } from "./octokit/probot-octokit.js";
9import type { Logger } from "pino";
10import type { RequestRequestOptions } from "@octokit/types";
11export interface Options {
12 privateKey?: string;
13 githubToken?: string;
14 appId?: number | string;
15 Octokit?: typeof ProbotOctokit;
16 log?: Logger;
17 redisConfig?: RedisOptions | string;
18 secret?: string;
19 logLevel?: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
20 logMessageKey?: string;
21 port?: number;
22 host?: string;
23 baseUrl?: string;
24 request?: RequestRequestOptions;
25 webhookPath?: string;
26}
27export type State = {
28 appId?: number;
29 privateKey?: string;
30 githubToken?: string;
31 log: Logger;
32 Octokit: typeof ProbotOctokit;
33 octokit: ProbotOctokit;
34 cache?: LRUCache<number, string>;
35 webhooks: {
36 secret?: string;
37 };
38 port?: number;
39 host?: string;
40 baseUrl?: string;
41 webhookPath: string;
42 request?: RequestRequestOptions;
43};
44type SimplifiedObject = Omit<Context, keyof WebhookEvent>;
45export type ProbotWebhooks = Webhooks<SimplifiedObject>;
46export type ApplicationFunctionOptions = {
47 getRouter?: (path?: string) => express.Router;
48 cwd?: string;
49 [key: string]: unknown;
50};
51export type ApplicationFunction = (app: Probot, options: ApplicationFunctionOptions) => void | Promise<void>;
52export type ServerOptions = {
53 cwd?: string;
54 log?: Logger;
55 port?: number;
56 host?: string;
57 webhookPath?: string;
58 webhookProxy?: string;
59 Probot: typeof Probot;
60 loggingOptions?: LoggingOptions;
61 request?: RequestRequestOptions;
62};
63export type MiddlewareOptions = {
64 probot: Probot;
65 webhooksPath?: string;
66 [key: string]: unknown;
67};
68export type OctokitOptions = NonNullable<ConstructorParameters<typeof ProbotOctokit>[0]>;
69export type PackageJson = {
70 name?: string;
71 version?: string;
72 description?: string;
73 homepage?: string;
74 repository?: string;
75 engines?: {
76 [key: string]: string;
77 };
78};
79export type Env = Record<Uppercase<string>, string>;
80type ManifestPermissionValue = "read" | "write" | "none";
81type ManifestPermissionScope = "actions" | "checks" | "contents" | "deployments" | "id-token" | "issues" | "discussions" | "packages" | "pages" | "pull-requests" | "repository-projects" | "security-events" | "statuses";
82export type Manifest = {
83 /**
84 * The name of the GitHub App.
85 */
86 name?: string;
87 /**
88 * __Required.__ The homepage of your GitHub App.
89 */
90 url: string;
91 /**
92 * The configuration of the GitHub App's webhook.
93 */
94 hook_attributes?: {
95 url: string;
96 active?: boolean;
97 };
98 /**
99 * The full URL to redirect to after a user initiates the registration of a GitHub App from a manifest.
100 */
101 redirect_url?: string;
102 /**
103 * A full URL to redirect to after someone authorizes an installation. You can provide up to 10 callback URLs.
104 */
105 callback_urls?: string[];
106 /**
107 * A full URL to redirect users to after they install your GitHub App if additional setup is required.
108 */
109 setup_url?: string;
110 /**
111 * A description of the GitHub App.
112 */
113 description?: string;
114 /**
115 * Set to `true` when your GitHub App is available to the public or `false` when it is only accessible to the owner of the app.
116 */
117 public?: boolean;
118 /**
119 * The list of events the GitHub App subscribes to.
120 */
121 default_events?: WebhookEvent[];
122 /**
123 * The set of permissions needed by the GitHub App. The format of the object uses the permission name for the key (for example, `issues`) and the access type for the value (for example, `write`).
124 */
125 default_permissions?: "read-all" | "write-all" | Record<ManifestPermissionScope, ManifestPermissionValue>;
126 /**
127 * Set to `true` to request the user to authorize the GitHub App, after the GitHub App is installed.
128 */
129 request_oauth_on_install?: boolean;
130 /**
131 * Set to `true` to redirect users to the setup_url after they update your GitHub App installation.
132 */
133 setup_on_update?: boolean;
134};
135export {};