@goodfellow-cms/github 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.d.ts CHANGED
@@ -4,6 +4,8 @@ import { FakeRepo } from "@goodfellow-cms/core/testing";
4
4
  export interface FakeGitHubUser {
5
5
  login: string;
6
6
  name?: string;
7
+ /** GitHub's number for the account. Defaults to one worked out from the login. */
8
+ id?: number;
7
9
  /** Whether the user may publish. Defaults to true. */
8
10
  push?: boolean;
9
11
  /** Whether the token may write `.github/workflows/`. Defaults to true. */
@@ -80,9 +82,43 @@ export interface FakeGitHubOptions {
80
82
  takenDomains?: string[];
81
83
  /** Other GitHub accounts that exist, which can be invited. Every token's user exists too. */
82
84
  accounts?: string[];
85
+ /** GitHub Apps, which the sign-in worker signs people in with. */
86
+ apps?: FakeGitHubApp[];
87
+ }
88
+ /** A GitHub App, as the sign-in worker uses one: its JWTs, installations, OAuth sign-in and tokens. */
89
+ export interface FakeGitHubApp {
90
+ id: string;
91
+ slug: string;
92
+ clientId: string;
93
+ clientSecret: string;
94
+ /** The app's public key, which its JWTs are checked against. Without it, any JWT naming the app is accepted. */
95
+ publicKey?: CryptoKey;
96
+ /** The most its tokens may be given, as GitHub names permissions. */
97
+ permissions: Record<string, "read" | "write">;
98
+ installations: FakeInstallation[];
99
+ }
100
+ /** An app installed on an account, for some or all of its repositories. */
101
+ export interface FakeInstallation {
102
+ id: number;
103
+ /** The account it's installed on. */
104
+ account: string;
105
+ accountType?: "User" | "Organization";
106
+ /** The repositories it can use, as `owner/name`, or `all` of the account's. */
107
+ repositories: string[] | "all";
108
+ }
109
+ /** A token an app's sign-in made: a person's own, or an installation's for some repositories. */
110
+ export interface FakeIssuedToken {
111
+ token: string;
112
+ kind: "user" | "installation";
113
+ app: string;
114
+ login?: string;
115
+ repositories?: string[];
116
+ permissions: Record<string, string>;
117
+ revoked?: boolean;
83
118
  }
84
119
  /** A repository created through the fake's API, as the setup page creates them. */
85
120
  export interface FakeCreatedRepo {
121
+ id: number;
86
122
  fullName: string;
87
123
  private: boolean;
88
124
  description?: string;
@@ -100,6 +136,20 @@ interface Deployment {
100
136
  }
101
137
  export declare function fakeGitHub(options: FakeGitHubOptions): {
102
138
  repo: FakeRepo;
139
+ /** How many GraphQL requests read files, as `readFiles()` makes. */
140
+ readonly graphqlReads: number;
141
+ /** Tokens apps' sign-ins made, in order. */
142
+ issued: FakeIssuedToken[];
143
+ /** Who commits made through the REST API name as their author, by commit. */
144
+ commitAuthors: Map<string, {
145
+ name?: string;
146
+ email?: string;
147
+ }>;
148
+ authorize: (login: string, clientId: string) => string;
149
+ install: (slug: string, login: string, repositories: string[], account?: string) => {
150
+ code: string;
151
+ installation: number;
152
+ };
103
153
  /** Repositories created through the API, by `owner/name`. */
104
154
  created: Map<string, FakeCreatedRepo>;
105
155
  /** The site's GitHub Pages settings, which tests can change, such as to issue the certificate. */
@@ -117,7 +167,7 @@ export declare function fakeGitHub(options: FakeGitHubOptions): {
117
167
  /** Every request received, for checking what the backend sent. */
118
168
  requests: Request[];
119
169
  /** Simulates someone else publishing. */
120
- commit: (changes: FileChange[], message: string, expectedHead?: string, author?: string) => string;
170
+ commit: (changes: FileChange[], message: string, expectedHead?: string, author?: string, branch?: string) => string;
121
171
  handle: (request: Request) => Promise<Response>;
122
172
  /** A `fetch` that answers from the fake instead of the network. */
123
173
  fetch: typeof fetch;