/
types.ts
87 lines (76 loc) · 1.74 KB
/
types.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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import type { Octokit } from "@octokit/core";
import type { Endpoints } from "@octokit/types";
export type TreeParameter =
Endpoints["POST /repos/{owner}/{repo}/git/trees"]["parameters"]["tree"];
export type Options = {
owner: string;
repo: string;
title: string;
body: string;
head: string;
changes: Changes | Changes[];
base?: string;
createWhenEmpty?: boolean;
draft?: boolean;
forceFork?: boolean;
update?: boolean;
};
export type Changes = {
files?: {
[path: string]: string | File | UpdateFunction | null | Symbol;
};
emptyCommit?: boolean | string;
commit: string;
committer?: Committer;
author?: Author | undefined;
signature?: SignatureFunction | undefined;
};
// https://developer.github.com/v3/git/blobs/#parameters
export type File = {
content: string;
encoding: "utf-8" | "base64";
mode?: string;
};
export type SignatureFunction = (commitPayload: CommitPayload) => string;
export type UpdateFunctionFile =
| {
exists: true;
size: number;
encoding: "base64";
content: string;
}
| {
exists: false;
size: never;
encoding: never;
content: never;
};
export type UpdateFunction = (
file: UpdateFunctionFile
) => string | File | null | Symbol | Promise<string | File | null | Symbol>;
export type State = {
octokit: Octokit;
owner: string;
repo: string;
ownerOrFork?: string;
latestCommitSha?: string;
latestCommitTreeSha?: string;
treeSha?: string;
};
export type Committer = {
name?: string;
email?: string;
date?: string;
};
export type Author = {
name: string;
email: string;
date?: string;
};
export type CommitPayload = {
message: string;
tree: string;
parents: string[];
author?: Author;
committer?: Committer;
};