@app-vitals/agent-admin 1.77.0 → 1.79.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/package.json +2 -2
- package/src/fixtures/github-agent-installation-cassette.json +29 -0
- package/src/github-access-backfill.integration.test.ts +208 -0
- package/src/github-access-backfill.ts +356 -0
- package/src/github-access-backfill.unit.test.ts +351 -0
- package/src/github-agent-installation-crawler.integration.test.ts +262 -0
- package/src/github-agent-installation-crawler.ts +179 -0
- package/src/github-agent-installation-crawler.unit.test.ts +343 -0
- package/src/github-enterprise-client-page.unit.test.ts +100 -0
- package/src/github-enterprise-client.ts +46 -0
- package/src/github-installation-wiring.ts +6 -2
- package/src/github-lookup-client.ts +15 -1
- package/src/github-repo-cache.ts +21 -0
- package/src/installation-ports.ts +14 -0
|
@@ -40,12 +40,14 @@ export interface GithubInstallationWiringDeps {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/** Builds the installer client per call so key rotations are picked up. */
|
|
43
|
-
function lazyInstallerClient(
|
|
43
|
+
export function lazyInstallerClient(
|
|
44
44
|
deps: Pick<
|
|
45
45
|
GithubInstallationWiringDeps,
|
|
46
46
|
"appService" | "fetchFn" | "apiBase" | "now"
|
|
47
47
|
>,
|
|
48
|
-
): InstallationRepoClient &
|
|
48
|
+
): InstallationRepoClient &
|
|
49
|
+
InstalledOrgsClient &
|
|
50
|
+
Required<Pick<InstallationRepoClient, "listInstallationRepositoriesPage">> {
|
|
49
51
|
const client = async (
|
|
50
52
|
accountId?: string | null,
|
|
51
53
|
): Promise<GithubEnterpriseClient> => {
|
|
@@ -72,6 +74,8 @@ function lazyInstallerClient(
|
|
|
72
74
|
(await client(accountId)).listOrgInstallations(org),
|
|
73
75
|
listInstallationRepositories: async (org, id, accountId) =>
|
|
74
76
|
(await client(accountId)).listInstallationRepositories(org, id),
|
|
77
|
+
listInstallationRepositoriesPage: async (org, id, page, accountId) =>
|
|
78
|
+
(await client(accountId)).listInstallationRepositoriesPage(org, id, page),
|
|
75
79
|
addRepositories: async (org, id, names, accountId) =>
|
|
76
80
|
(await client(accountId)).addRepositories(org, id, names),
|
|
77
81
|
removeRepositories: async (org, id, names, accountId) =>
|
|
@@ -345,6 +345,17 @@ export class GithubLookupClient {
|
|
|
345
345
|
repo: string,
|
|
346
346
|
username: string,
|
|
347
347
|
): Promise<RepoRole> {
|
|
348
|
+
return (
|
|
349
|
+
await this.getCollaboratorPermissionWithRateLimit(owner, repo, username)
|
|
350
|
+
).role;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** getCollaboratorPermission plus the quota GitHub reported with the answer. */
|
|
354
|
+
async getCollaboratorPermissionWithRateLimit(
|
|
355
|
+
owner: string,
|
|
356
|
+
repo: string,
|
|
357
|
+
username: string,
|
|
358
|
+
): Promise<{ role: RepoRole; rateLimit: LookupRateLimit }> {
|
|
348
359
|
const { token } = await this.getOrgToken(owner);
|
|
349
360
|
const res = await this.request<{
|
|
350
361
|
permission?: unknown;
|
|
@@ -355,7 +366,10 @@ export class GithubLookupClient {
|
|
|
355
366
|
token,
|
|
356
367
|
"GitHub collaborator permission",
|
|
357
368
|
);
|
|
358
|
-
return
|
|
369
|
+
return {
|
|
370
|
+
role: mapRepoRole(res.data?.role_name ?? res.data?.permission),
|
|
371
|
+
rateLimit: readRateLimit(res.headers),
|
|
372
|
+
};
|
|
359
373
|
}
|
|
360
374
|
|
|
361
375
|
/** Look up a user. A nonexistent login throws kind "not_found". */
|
package/src/github-repo-cache.ts
CHANGED
|
@@ -301,4 +301,25 @@ export class GitHubRepoCacheService {
|
|
|
301
301
|
}
|
|
302
302
|
return query.repos.filter((r) => !settled.has(r));
|
|
303
303
|
}
|
|
304
|
+
|
|
305
|
+
/** Existing access rows for the user over `repos` (any status). */
|
|
306
|
+
async getAccessRows(query: {
|
|
307
|
+
accountId: string;
|
|
308
|
+
org: string;
|
|
309
|
+
username: string;
|
|
310
|
+
repos: string[];
|
|
311
|
+
}) {
|
|
312
|
+
requireNonEmpty("accountId", query.accountId);
|
|
313
|
+
requireNonEmpty("org", query.org);
|
|
314
|
+
requireNonEmpty("username", query.username);
|
|
315
|
+
if (query.repos.length === 0) return [];
|
|
316
|
+
return this.prisma.gitHubRepoAccess.findMany({
|
|
317
|
+
where: {
|
|
318
|
+
accountId: query.accountId,
|
|
319
|
+
org: query.org,
|
|
320
|
+
username: query.username,
|
|
321
|
+
repo: { in: query.repos },
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
304
325
|
}
|
|
@@ -186,6 +186,20 @@ export interface InstallationRepoClient {
|
|
|
186
186
|
installationId: number,
|
|
187
187
|
accountId?: string | null,
|
|
188
188
|
): Promise<{ fullName: string }[]>;
|
|
189
|
+
/**
|
|
190
|
+
* One page of an installation's repositories (GLC-1.5 crawl). Optional so
|
|
191
|
+
* existing implementations stay valid; the crawl requires it.
|
|
192
|
+
*/
|
|
193
|
+
listInstallationRepositoriesPage?(
|
|
194
|
+
org: string,
|
|
195
|
+
installationId: number,
|
|
196
|
+
page: number,
|
|
197
|
+
accountId?: string | null,
|
|
198
|
+
): Promise<{
|
|
199
|
+
repos: { id: number; fullName: string; archived?: boolean }[];
|
|
200
|
+
hasNext: boolean;
|
|
201
|
+
perPage: number;
|
|
202
|
+
}>;
|
|
189
203
|
addRepositories(
|
|
190
204
|
org: string,
|
|
191
205
|
installationId: number,
|