@vite-hub/forge 0.5.0 → 0.5.1
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/{association-Ds6Tgs0W-Cu9_YCGq.js → association-Ds6Tgs0W-CgBVH3ii.js} +1 -2
- package/dist/build/node.d.ts +1 -3
- package/dist/build/node.js +3 -5
- package/dist/build.d.ts +1 -1
- package/dist/build.js +1 -2
- package/dist/{definition-0wjaAw2i-BwSDtp9h.js → definition-BQFdu9ti-WxMjcAEl.js} +8 -8
- package/dist/{events-DW3SFUDA-D2rhS9D-.js → events-BL0zcgMf-9TwyYtCt.js} +3 -5
- package/dist/{events-uCMi3LHU-Bz79PQtq.js → events-DDdJnmD2-BSMoOqjV.js} +4 -5
- package/dist/{events-DjRw3KSr-C72gY7Vu.js → events-DHqSJ5KI-z2-5_1vo.js} +59 -60
- package/dist/{events-DmSWTdpS-oDiTlP1L.js → events-DXE-Ul2S-BzTkugIK.js} +4 -5
- package/dist/{feed-BlzdKdNv-DbxuSgsx.js → feed-B1OiHFg0-DevZZe0y.js} +3 -5
- package/dist/{feed-CIaAZINm-Dpe9DxwK.js → feed-DROLF1tb-CtRfA_7N.js} +3 -5
- package/dist/{feed-BwdcTgZq-CbyczJHA.js → feed-iWegqepj-ConxMpg4.js} +3 -5
- package/dist/{forgejo-DgNfNjcW.js → forgejo-4sbZukng.js} +3 -4
- package/dist/{gitea-Zpwj_XHC.js → gitea-Cj7qy2X3.js} +3 -4
- package/dist/{gitee-BXyl2_3W-dQOAjWqr.js → gitee-CKt4pEC0-BuLWggck.js} +2 -3
- package/dist/{github-CUiEF2FK.js → github-CHzhqYOr.js} +377 -293
- package/dist/{gitlab-zvWb9zOi.js → gitlab-CS0shW2u.js} +12 -10
- package/dist/{graphql-BDhuP5jN-BSpB8lWf.js → graphql-DxRA9BGO-BBbmTmWi.js} +43 -33
- package/dist/{identity-CmVEBLP5.js → identity-BwC2_3S9.js} +1 -2
- package/dist/{identity-CNTWZZuv.d.ts → identity-D2-HaDku.d.ts} +0 -2
- package/dist/index.d.ts +35 -38
- package/dist/index.js +26 -45
- package/dist/model-Biiu1CfI-CVLamGai.js +288 -0
- package/dist/{templates-BGDqQMu4-PSB43E1j.js → templates-0m5QBVIh-D1fZeoC-.js} +3 -3
- package/dist/{webhooks-Bc6QhmI8-CNgCERCq.js → webhooks-Bc6QhmI8-eK71_mJE.js} +1034 -98
- package/package.json +6 -6
- package/dist/events-C6C7lk1x-J8VCAjEX.js +0 -131
- package/dist/knot-bGebBK_B-CeDHcJUz.js +0 -350
- package/dist/tangled-8lg_73Wi-bSufNXiN.js +0 -43
- package/dist/utils-DC7MBR65-B7Vr2hFm.js +0 -1214
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as toAuthorAssociation } from "./association-Ds6Tgs0W-
|
|
4
|
-
|
|
1
|
+
import { B as memo, C as abortable, D as createFetcher, E as checkRunState, F as hostOf, G as rateLimitOf, I as isFirstPage, J as requireIssueOrPull, K as rateLimitPart, L as iteratePages, M as getManyConcurrently, O as createListing, Q as summariseChecks, R as latestCommentOf, T as anySignal, U as milestoneId, W as phased, X as resolveToken, Y as requireThread, Z as sleep, _ as OWNER_NAME, _t as signRs256Jwt, a as verifyHmacSignature, at as toWarning, c as defineForgeProvider, ct as changeBase64, d as perKind, dt as inDirectories, et as teamOrg, f as reviewState, ft as isSha, g as verb, it as toPullStats, j as forgeIterable, k as degradesToWarning, lt as existingFiles, m as supportOnly, mt as toFileContent, nt as toFileStatus, ot as versionAtLeast, pt as splitMessage, q as rateLimitReset, r as nativeEventsFor, rt as toPage, s as WRITE_VERBS, t as eventKindsOf, tt as toDate, u as eventTime, ut as fromBase64, w as actorLogin, y as githubShapedWeb } from "./webhooks-Bc6QhmI8-eK71_mJE.js";
|
|
2
|
+
import { A as toMergeError, O as isSecondaryRateLimit, S as ReadOnlyError, T as UnsupportedOperationError, _ as InsufficientScopeError, b as NotFoundError, f as ForbiddenError, g as ForgeTimeoutError, k as soleMergeMethod, l as AuthenticationRequiredError, m as ForgeError, n as isNamespaceRef, p as ForgeApiError, r as isResolvedThread, s as reactionContent, t as REACTION_CONTENTS, u as BranchMovedError, v as MergeBlockedError, x as RateLimitedError, y as MergeConflictError } from "./model-Biiu1CfI-CVLamGai.js";
|
|
3
|
+
import { t as toAuthorAssociation } from "./association-Ds6Tgs0W-CgBVH3ii.js";
|
|
4
|
+
// ../../node_modules/.pnpm/forges@0.4.1/node_modules/forges/dist/web-C4ZtN2uk.mjs
|
|
5
5
|
const RESERVED_PATHS = [
|
|
6
6
|
"about",
|
|
7
7
|
"account",
|
|
@@ -78,8 +78,7 @@ const GITHUB_WEB = {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/github-B3p2LsXc.mjs
|
|
81
|
+
// ../../node_modules/.pnpm/forges@0.4.1/node_modules/forges/dist/definition-s83gxg2p.mjs
|
|
83
82
|
const TOKEN_PREFIXES = [
|
|
84
83
|
["ghp_", "classic"],
|
|
85
84
|
["gho_", "classic"],
|
|
@@ -155,6 +154,92 @@ function createAuthHeaders(auth, credentials) {
|
|
|
155
154
|
if (installationId === void 0) return async () => ({ authorization: `Bearer ${await app.appJwt()}` });
|
|
156
155
|
return async () => ({ authorization: `Bearer ${await app.installationToken(String(installationId))}` });
|
|
157
156
|
}
|
|
157
|
+
function graphqlUrl(baseUrl) {
|
|
158
|
+
const url = new URL(baseUrl);
|
|
159
|
+
if (url.host === "api.github.com") return "https://api.github.com/graphql";
|
|
160
|
+
return `${url.origin}${url.pathname.replace(/\/v3\/?$/, "")}/graphql`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A failed GraphQL response as an error: `InsufficientScopeError` when the token lacks a scope a field needs, and
|
|
164
|
+
* `RateLimitedError` for a rate limit, which GitHub reports with a `200`.
|
|
165
|
+
*/
|
|
166
|
+
function graphqlError(operationName, errors, url, context, response) {
|
|
167
|
+
const message = `GraphQL ${operationName ?? "request"} failed: ${errors?.map((error) => error.message).join("; ") || "Empty GraphQL response"}`;
|
|
168
|
+
const body = JSON.stringify(errors ?? null).slice(0, 512);
|
|
169
|
+
const errorContext = {
|
|
170
|
+
forge: context.forge,
|
|
171
|
+
instance: context.instance,
|
|
172
|
+
url,
|
|
173
|
+
method: "POST"
|
|
174
|
+
};
|
|
175
|
+
const secondary = errors?.some((error) => isSecondaryRateLimit(error.message)) ?? false;
|
|
176
|
+
if (secondary || errors?.some((error) => error.type === "RATE_LIMITED")) {
|
|
177
|
+
const budget = response && rateLimitOf(response);
|
|
178
|
+
const resetAt = response && (rateLimitReset(response, budget) ?? (secondary ? void 0 : budget?.resetAt));
|
|
179
|
+
return new RateLimitedError(message, 200, body, {
|
|
180
|
+
...errorContext,
|
|
181
|
+
resetAt,
|
|
182
|
+
secondary
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const scopeError = errors?.find((error) => error.type === "INSUFFICIENT_SCOPES");
|
|
186
|
+
if (!scopeError) return new ForgeApiError(message, 200, body, errorContext);
|
|
187
|
+
return new InsufficientScopeError(message, 200, body, {
|
|
188
|
+
...errorContext,
|
|
189
|
+
acceptedScopes: quotedScopes(scopeError.message.match(/requires one of the following scopes: \[([^\]]*)\]/)?.[1]),
|
|
190
|
+
grantedScopes: quotedScopes(scopeError.message.match(/has only been granted the: \[([^\]]*)\]/)?.[1])
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function quotedScopes(list) {
|
|
194
|
+
return list === void 0 ? void 0 : [...list.matchAll(/'([^']+)'/g)].map((match) => match[1]);
|
|
195
|
+
}
|
|
196
|
+
const OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
197
|
+
"query",
|
|
198
|
+
"mutation",
|
|
199
|
+
"subscription"
|
|
200
|
+
]);
|
|
201
|
+
/** The operations a GraphQL document declares, read from its top level so that fields, variables, strings and comments don't count. */
|
|
202
|
+
function graphqlOperations(document) {
|
|
203
|
+
const operations = [];
|
|
204
|
+
let depth = 0;
|
|
205
|
+
let definitionStart = true;
|
|
206
|
+
let awaitingName;
|
|
207
|
+
for (const [token] of document.matchAll(/"""(?:\\"""|[\s\S])*?"""|"(?:\\.|[^"\\\n\r])*"|#[^\n\r]*|[{}()]|[$@]?[_a-z]\w*/gi)) {
|
|
208
|
+
if (token[0] === "\"" || token[0] === "#") continue;
|
|
209
|
+
if (token === "{" || token === "(") {
|
|
210
|
+
if (depth === 0 && definitionStart && token === "{") operations.push({ type: "query" });
|
|
211
|
+
depth++;
|
|
212
|
+
definitionStart = false;
|
|
213
|
+
awaitingName = void 0;
|
|
214
|
+
} else if (token === "}" || token === ")") {
|
|
215
|
+
depth--;
|
|
216
|
+
definitionStart = depth === 0 && token === "}";
|
|
217
|
+
} else if (depth === 0) {
|
|
218
|
+
if (awaitingName && /^[_a-z]/i.test(token)) awaitingName.name = token;
|
|
219
|
+
awaitingName = definitionStart && OPERATION_TYPES.has(token) ? { type: token } : void 0;
|
|
220
|
+
if (awaitingName) operations.push(awaitingName);
|
|
221
|
+
definitionStart = false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return operations;
|
|
225
|
+
}
|
|
226
|
+
function createGraphQLClient(fetcher, url, context) {
|
|
227
|
+
return async (document, variables, options) => {
|
|
228
|
+
const query = typeof document === "string" ? (await import("./graphql-DxRA9BGO-BBbmTmWi.js"))[document] : document.query;
|
|
229
|
+
const operationName = graphqlOperations(query)[0]?.name;
|
|
230
|
+
const { data, response } = await fetcher.json(url, {
|
|
231
|
+
method: "POST",
|
|
232
|
+
json: {
|
|
233
|
+
query,
|
|
234
|
+
variables,
|
|
235
|
+
operationName
|
|
236
|
+
},
|
|
237
|
+
signal: options?.signal
|
|
238
|
+
});
|
|
239
|
+
if (data.errors?.length || !data.data) throw graphqlError(operationName, data.errors, url, context, response);
|
|
240
|
+
return data.data;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
158
243
|
/** Native GitHub event names per normalised kind, for hook subscriptions. */
|
|
159
244
|
const GITHUB_NATIVE_EVENTS = {
|
|
160
245
|
comment: [
|
|
@@ -345,12 +430,11 @@ const GITHUB_WEBHOOK_EVENTS = [
|
|
|
345
430
|
action: "untyped"
|
|
346
431
|
}
|
|
347
432
|
];
|
|
348
|
-
|
|
349
|
-
function toActor(instance, user) {
|
|
433
|
+
function toActor(origin, user) {
|
|
350
434
|
if (!user?.login) return;
|
|
351
435
|
return {
|
|
352
|
-
forge:
|
|
353
|
-
instance,
|
|
436
|
+
forge: origin.forge,
|
|
437
|
+
instance: origin.instance,
|
|
354
438
|
login: user.login,
|
|
355
439
|
id: String(user.id ?? user.login),
|
|
356
440
|
name: user.name ?? void 0,
|
|
@@ -361,9 +445,9 @@ function toActor(instance, user) {
|
|
|
361
445
|
...user.type === "Bot" && user.login.endsWith("[bot]") ? { app: { slug: user.login.slice(0, -5) } } : {}
|
|
362
446
|
};
|
|
363
447
|
}
|
|
364
|
-
function toUser(
|
|
448
|
+
function toUser(origin, user) {
|
|
365
449
|
return {
|
|
366
|
-
...toActor(
|
|
450
|
+
...toActor(origin, user),
|
|
367
451
|
bio: user.bio ?? void 0,
|
|
368
452
|
company: user.company ?? void 0,
|
|
369
453
|
location: user.location ?? void 0,
|
|
@@ -375,22 +459,22 @@ function toUser(instance, user) {
|
|
|
375
459
|
raw: user
|
|
376
460
|
};
|
|
377
461
|
}
|
|
378
|
-
function toRepoRef(
|
|
462
|
+
function toRepoRef(origin, repo) {
|
|
379
463
|
const [owner, name] = repo.full_name.split("/");
|
|
380
464
|
return {
|
|
381
|
-
forge:
|
|
382
|
-
instance,
|
|
465
|
+
forge: origin.forge,
|
|
466
|
+
instance: origin.instance,
|
|
383
467
|
owner: repo.owner?.login ?? owner ?? "",
|
|
384
468
|
name: repo.name ?? name ?? "",
|
|
385
469
|
externalId: repo.id === void 0 ? void 0 : String(repo.id)
|
|
386
470
|
};
|
|
387
471
|
}
|
|
388
472
|
/** Reads `owner` and `name` out of an API repository URL, which search results carry instead of a nested repository. */
|
|
389
|
-
function repoRefFromApiUrl(
|
|
473
|
+
function repoRefFromApiUrl(origin, url) {
|
|
390
474
|
const [, owner, name] = url?.match(/\/repos\/([^/]+)\/([^/]+)$/) ?? [];
|
|
391
475
|
return owner && name ? {
|
|
392
|
-
forge:
|
|
393
|
-
instance,
|
|
476
|
+
forge: origin.forge,
|
|
477
|
+
instance: origin.instance,
|
|
394
478
|
owner,
|
|
395
479
|
name
|
|
396
480
|
} : void 0;
|
|
@@ -422,17 +506,17 @@ function toMergeCommit(raw) {
|
|
|
422
506
|
squash
|
|
423
507
|
} : void 0;
|
|
424
508
|
}
|
|
425
|
-
function toRepo(
|
|
509
|
+
function toRepo(origin, raw) {
|
|
426
510
|
const visibility = raw.visibility === "internal" ? "internal" : raw.private || raw.visibility === "private" ? "private" : "public";
|
|
427
511
|
return {
|
|
428
|
-
ref: toRepoRef(
|
|
512
|
+
ref: toRepoRef(origin, raw),
|
|
429
513
|
description: raw.description ?? void 0,
|
|
430
514
|
defaultBranch: raw.default_branch,
|
|
431
515
|
visibility,
|
|
432
516
|
visibilityRaw: raw.visibility ?? (raw.private === void 0 ? void 0 : raw.private ? "private" : "public"),
|
|
433
517
|
isFork: raw.fork ?? false,
|
|
434
518
|
isArchived: raw.archived ?? false,
|
|
435
|
-
parent: raw.parent ? toRepoRef(
|
|
519
|
+
parent: raw.parent ? toRepoRef(origin, raw.parent) : void 0,
|
|
436
520
|
topics: raw.topics ?? [],
|
|
437
521
|
url: raw.html_url,
|
|
438
522
|
cloneUrls: raw.clone_url || raw.ssh_url ? {
|
|
@@ -442,7 +526,7 @@ function toRepo(instance, raw) {
|
|
|
442
526
|
createdAt: toDate(raw.created_at),
|
|
443
527
|
updatedAt: toDate(raw.updated_at),
|
|
444
528
|
pushedAt: toDate(raw.pushed_at),
|
|
445
|
-
owner: toActor(
|
|
529
|
+
owner: toActor(origin, raw.owner),
|
|
446
530
|
language: raw.language ?? void 0,
|
|
447
531
|
homepage: raw.homepage || void 0,
|
|
448
532
|
licence: raw.license?.spdx_id && raw.license.spdx_id !== "NOASSERTION" ? raw.license.spdx_id : void 0,
|
|
@@ -516,15 +600,15 @@ function toRole(raw) {
|
|
|
516
600
|
if (!permissions) return "none";
|
|
517
601
|
return permissions.admin ? "admin" : permissions.maintain ? "maintain" : permissions.push ? "write" : permissions.triage ? "triage" : permissions.pull ? "read" : "none";
|
|
518
602
|
}
|
|
519
|
-
function toCollaborator(
|
|
603
|
+
function toCollaborator(origin, raw) {
|
|
520
604
|
return {
|
|
521
|
-
actor: toActor(
|
|
605
|
+
actor: toActor(origin, raw),
|
|
522
606
|
role: toRole(raw),
|
|
523
607
|
roleRaw: raw.role_name,
|
|
524
608
|
raw
|
|
525
609
|
};
|
|
526
610
|
}
|
|
527
|
-
function toContributor(
|
|
611
|
+
function toContributor(origin, raw) {
|
|
528
612
|
if (!("login" in raw)) return {
|
|
529
613
|
name: raw.name || void 0,
|
|
530
614
|
email: raw.email || void 0,
|
|
@@ -532,14 +616,14 @@ function toContributor(instance, raw) {
|
|
|
532
616
|
raw
|
|
533
617
|
};
|
|
534
618
|
return {
|
|
535
|
-
actor: toActor(
|
|
619
|
+
actor: toActor(origin, raw),
|
|
536
620
|
contributions: raw.contributions,
|
|
537
621
|
raw
|
|
538
622
|
};
|
|
539
623
|
}
|
|
540
|
-
function toContributorStats(
|
|
624
|
+
function toContributorStats(origin, raw) {
|
|
541
625
|
return {
|
|
542
|
-
actor: toActor(
|
|
626
|
+
actor: toActor(origin, raw.author),
|
|
543
627
|
commits: raw.total,
|
|
544
628
|
weeks: raw.weeks.map((week) => ({
|
|
545
629
|
week: /* @__PURE__ */ new Date(week.w * 1e3),
|
|
@@ -550,18 +634,18 @@ function toContributorStats(instance, raw) {
|
|
|
550
634
|
raw
|
|
551
635
|
};
|
|
552
636
|
}
|
|
553
|
-
function toTeam(
|
|
637
|
+
function toTeam(origin, org, raw) {
|
|
554
638
|
const parent = raw.parent ? {
|
|
555
|
-
forge:
|
|
556
|
-
instance,
|
|
639
|
+
forge: origin.forge,
|
|
640
|
+
instance: origin.instance,
|
|
557
641
|
org,
|
|
558
642
|
id: String(raw.parent.id),
|
|
559
643
|
slug: raw.parent.slug
|
|
560
644
|
} : void 0;
|
|
561
645
|
return {
|
|
562
646
|
ref: {
|
|
563
|
-
forge:
|
|
564
|
-
instance,
|
|
647
|
+
forge: origin.forge,
|
|
648
|
+
instance: origin.instance,
|
|
565
649
|
org,
|
|
566
650
|
id: String(raw.id),
|
|
567
651
|
slug: raw.slug
|
|
@@ -625,15 +709,15 @@ const SECURITY_SUBJECTS_KIND = {
|
|
|
625
709
|
function lastSegment(url) {
|
|
626
710
|
return /\/([^/?#]+)\/?$/.exec(url ?? "")?.[1];
|
|
627
711
|
}
|
|
628
|
-
function toSubject(
|
|
629
|
-
const repo = toRepoRef(
|
|
712
|
+
function toSubject(origin, raw) {
|
|
713
|
+
const repo = toRepoRef(origin, raw.repository);
|
|
630
714
|
const type = raw.subject.type;
|
|
631
715
|
const kind = toThreadKind(type);
|
|
632
716
|
if (kind) return {
|
|
633
717
|
type: "thread",
|
|
634
718
|
thread: {
|
|
635
|
-
forge:
|
|
636
|
-
instance,
|
|
719
|
+
forge: origin.forge,
|
|
720
|
+
instance: origin.instance,
|
|
637
721
|
repo,
|
|
638
722
|
kind,
|
|
639
723
|
typeRaw: type,
|
|
@@ -644,8 +728,8 @@ function toSubject(instance, raw) {
|
|
|
644
728
|
if (sha) return {
|
|
645
729
|
type: "commit",
|
|
646
730
|
commit: {
|
|
647
|
-
forge:
|
|
648
|
-
instance,
|
|
731
|
+
forge: origin.forge,
|
|
732
|
+
instance: origin.instance,
|
|
649
733
|
repo,
|
|
650
734
|
sha
|
|
651
735
|
}
|
|
@@ -653,8 +737,8 @@ function toSubject(instance, raw) {
|
|
|
653
737
|
if (type === "Release") return {
|
|
654
738
|
type: "release",
|
|
655
739
|
release: {
|
|
656
|
-
forge:
|
|
657
|
-
instance,
|
|
740
|
+
forge: origin.forge,
|
|
741
|
+
instance: origin.instance,
|
|
658
742
|
repo,
|
|
659
743
|
id: lastSegment(raw.subject.url) ?? raw.id
|
|
660
744
|
}
|
|
@@ -664,8 +748,8 @@ function toSubject(instance, raw) {
|
|
|
664
748
|
return {
|
|
665
749
|
type: "security_alert",
|
|
666
750
|
alert: {
|
|
667
|
-
forge:
|
|
668
|
-
instance,
|
|
751
|
+
forge: origin.forge,
|
|
752
|
+
instance: origin.instance,
|
|
669
753
|
repo,
|
|
670
754
|
id: lastSegment(raw.subject.url) ?? raw.id,
|
|
671
755
|
...kind ? { kind } : {}
|
|
@@ -684,13 +768,13 @@ function toSubject(instance, raw) {
|
|
|
684
768
|
url: raw.subject.url ?? void 0
|
|
685
769
|
};
|
|
686
770
|
}
|
|
687
|
-
function toNotification(
|
|
688
|
-
const subject = toSubject(
|
|
771
|
+
function toNotification(origin, raw) {
|
|
772
|
+
const subject = toSubject(origin, raw);
|
|
689
773
|
const latestComment = latestCommentOf(subject, raw.subject.latest_comment_url);
|
|
690
774
|
return {
|
|
691
775
|
ref: {
|
|
692
|
-
forge:
|
|
693
|
-
instance,
|
|
776
|
+
forge: origin.forge,
|
|
777
|
+
instance: origin.instance,
|
|
694
778
|
id: raw.id
|
|
695
779
|
},
|
|
696
780
|
subject,
|
|
@@ -724,9 +808,9 @@ function toLabels(labels) {
|
|
|
724
808
|
}] : [];
|
|
725
809
|
});
|
|
726
810
|
}
|
|
727
|
-
function toReviewers(
|
|
811
|
+
function toReviewers(origin, raw) {
|
|
728
812
|
const users = (raw.requested_reviewers ?? []).flatMap((user) => {
|
|
729
|
-
const actor = toActor(
|
|
813
|
+
const actor = toActor(origin, user);
|
|
730
814
|
return actor ? [{
|
|
731
815
|
actor,
|
|
732
816
|
state: "pending",
|
|
@@ -735,8 +819,8 @@ function toReviewers(instance, raw) {
|
|
|
735
819
|
});
|
|
736
820
|
const teams = (raw.requested_teams ?? []).map((team) => ({
|
|
737
821
|
actor: {
|
|
738
|
-
forge:
|
|
739
|
-
instance,
|
|
822
|
+
forge: origin.forge,
|
|
823
|
+
instance: origin.instance,
|
|
740
824
|
login: team.slug,
|
|
741
825
|
id: String(team.id),
|
|
742
826
|
name: team.name,
|
|
@@ -766,17 +850,17 @@ function toThread(ref, raw) {
|
|
|
766
850
|
stateRaw: raw.state,
|
|
767
851
|
stateReason: raw.state_reason ?? void 0,
|
|
768
852
|
isDraft: raw.draft ?? false,
|
|
769
|
-
author: toActor(ref
|
|
853
|
+
author: toActor(ref, raw.user),
|
|
770
854
|
...toAuthorAssociation(raw.author_association),
|
|
771
|
-
assignees: (raw.assignees ?? []).flatMap((user) => toActor(ref
|
|
772
|
-
reviewers: toReviewers(ref
|
|
855
|
+
assignees: (raw.assignees ?? []).flatMap((user) => toActor(ref, user) ?? []),
|
|
856
|
+
reviewers: toReviewers(ref, raw),
|
|
773
857
|
labels: toLabels(raw.labels),
|
|
774
858
|
url: raw.html_url,
|
|
775
859
|
createdAt: toDate(raw.created_at),
|
|
776
860
|
updatedAt: toDate(raw.updated_at),
|
|
777
861
|
closedAt: toDate(raw.closed_at),
|
|
778
862
|
mergedAt: toDate(raw.merged_at ?? raw.pull_request?.merged_at),
|
|
779
|
-
mergedBy: toActor(ref
|
|
863
|
+
mergedBy: toActor(ref, raw.merged_by),
|
|
780
864
|
lastActivityAt: toDate(raw.updated_at),
|
|
781
865
|
locked: raw.locked,
|
|
782
866
|
commentCount: raw.comments,
|
|
@@ -787,7 +871,7 @@ function toThread(ref, raw) {
|
|
|
787
871
|
head: {
|
|
788
872
|
ref: raw.head.ref,
|
|
789
873
|
sha: raw.head.sha,
|
|
790
|
-
repo: raw.head.repo ? toRepoRef(ref
|
|
874
|
+
repo: raw.head.repo ? toRepoRef(ref, raw.head.repo) : void 0
|
|
791
875
|
},
|
|
792
876
|
base: {
|
|
793
877
|
ref: raw.base.ref,
|
|
@@ -807,29 +891,29 @@ function toThread(ref, raw) {
|
|
|
807
891
|
function toComment(thread, raw) {
|
|
808
892
|
return {
|
|
809
893
|
ref: {
|
|
810
|
-
forge:
|
|
894
|
+
forge: thread.forge,
|
|
811
895
|
instance: thread.instance,
|
|
812
896
|
thread,
|
|
813
897
|
id: String(raw.id)
|
|
814
898
|
},
|
|
815
|
-
...commentFields(thread
|
|
899
|
+
...commentFields(thread, raw)
|
|
816
900
|
};
|
|
817
901
|
}
|
|
818
902
|
function toCommitComment(commit, raw) {
|
|
819
903
|
return {
|
|
820
904
|
ref: {
|
|
821
|
-
forge:
|
|
905
|
+
forge: commit.forge,
|
|
822
906
|
instance: commit.instance,
|
|
823
907
|
commit,
|
|
824
908
|
id: String(raw.id)
|
|
825
909
|
},
|
|
826
|
-
...commentFields(commit
|
|
910
|
+
...commentFields(commit, raw)
|
|
827
911
|
};
|
|
828
912
|
}
|
|
829
|
-
function commentFields(
|
|
913
|
+
function commentFields(origin, raw) {
|
|
830
914
|
return {
|
|
831
915
|
body: raw.body ?? "",
|
|
832
|
-
author: toActor(
|
|
916
|
+
author: toActor(origin, raw.user),
|
|
833
917
|
...toAuthorAssociation(raw.author_association),
|
|
834
918
|
createdAt: toDate(raw.created_at),
|
|
835
919
|
updatedAt: toDate(raw.updated_at),
|
|
@@ -879,15 +963,15 @@ function summarise(entry, kind, actor) {
|
|
|
879
963
|
}
|
|
880
964
|
}
|
|
881
965
|
/** A `cross-referenced` entry names the thread that mentioned this one; a `referenced` entry names a commit. */
|
|
882
|
-
function crossReference(
|
|
966
|
+
function crossReference(origin, thread, entry) {
|
|
883
967
|
const source = entry.source?.issue;
|
|
884
968
|
if (source) {
|
|
885
|
-
const repo = source.repository ? toRepoRef(
|
|
969
|
+
const repo = source.repository ? toRepoRef(origin, source.repository) : thread.repo;
|
|
886
970
|
return {
|
|
887
971
|
type: "referenced",
|
|
888
972
|
from: {
|
|
889
|
-
forge:
|
|
890
|
-
instance,
|
|
973
|
+
forge: origin.forge,
|
|
974
|
+
instance: origin.instance,
|
|
891
975
|
repo,
|
|
892
976
|
kind: source.pull_request ? "pull_request" : "issue",
|
|
893
977
|
number: String(source.number)
|
|
@@ -898,21 +982,21 @@ function crossReference(instance, thread, entry) {
|
|
|
898
982
|
return entry.commit_id ? {
|
|
899
983
|
type: "referenced",
|
|
900
984
|
from: {
|
|
901
|
-
forge:
|
|
902
|
-
instance,
|
|
985
|
+
forge: origin.forge,
|
|
986
|
+
instance: origin.instance,
|
|
903
987
|
repo: thread.repo,
|
|
904
988
|
sha: entry.commit_id
|
|
905
989
|
},
|
|
906
990
|
fromRepo: thread.repo
|
|
907
991
|
} : { type: "referenced" };
|
|
908
992
|
}
|
|
909
|
-
function timelineDetail(
|
|
993
|
+
function timelineDetail(origin, thread, entry, kind) {
|
|
910
994
|
switch (kind) {
|
|
911
995
|
case "comment": return {
|
|
912
996
|
type: "comment",
|
|
913
997
|
comment: entry.id !== void 0 ? {
|
|
914
|
-
forge:
|
|
915
|
-
instance,
|
|
998
|
+
forge: origin.forge,
|
|
999
|
+
instance: origin.instance,
|
|
916
1000
|
thread,
|
|
917
1001
|
id: String(entry.id)
|
|
918
1002
|
} : void 0,
|
|
@@ -924,8 +1008,8 @@ function timelineDetail(instance, thread, entry, kind) {
|
|
|
924
1008
|
stateRaw: entry.state,
|
|
925
1009
|
body: entry.body ?? void 0,
|
|
926
1010
|
review: entry.id !== void 0 ? {
|
|
927
|
-
forge:
|
|
928
|
-
instance,
|
|
1011
|
+
forge: origin.forge,
|
|
1012
|
+
instance: origin.instance,
|
|
929
1013
|
thread,
|
|
930
1014
|
id: String(entry.id)
|
|
931
1015
|
} : void 0
|
|
@@ -936,9 +1020,9 @@ function timelineDetail(instance, thread, entry, kind) {
|
|
|
936
1020
|
} : void 0;
|
|
937
1021
|
case "assignment": return {
|
|
938
1022
|
type: "assignment",
|
|
939
|
-
assignee: toActor(
|
|
1023
|
+
assignee: toActor(origin, entry.assignee ?? entry.requested_reviewer)
|
|
940
1024
|
};
|
|
941
|
-
case "referenced": return crossReference(
|
|
1025
|
+
case "referenced": return crossReference(origin, thread, entry);
|
|
942
1026
|
case "state_change": return entry.event === "convert_to_draft" || entry.event === "ready_for_review" ? {
|
|
943
1027
|
type: "state_change",
|
|
944
1028
|
state: "open",
|
|
@@ -951,16 +1035,16 @@ function timelineDetail(instance, thread, entry, kind) {
|
|
|
951
1035
|
default: return;
|
|
952
1036
|
}
|
|
953
1037
|
}
|
|
954
|
-
function toEvent(
|
|
1038
|
+
function toEvent(origin, thread, entry, source = "poll") {
|
|
955
1039
|
const kind = toEventKind(entry.event);
|
|
956
|
-
const actor = toActor(
|
|
1040
|
+
const actor = toActor(origin, entry.actor ?? entry.user);
|
|
957
1041
|
return {
|
|
958
|
-
forge:
|
|
959
|
-
instance,
|
|
1042
|
+
forge: origin.forge,
|
|
1043
|
+
instance: origin.instance,
|
|
960
1044
|
id: String(entry.node_id ?? entry.id ?? entry.sha ?? `${thread.number ?? ""}-${entry.event}-${entry.created_at}`),
|
|
961
1045
|
kind,
|
|
962
1046
|
kindRaw: entry.event,
|
|
963
|
-
detail: timelineDetail(
|
|
1047
|
+
detail: timelineDetail(origin, thread, entry, kind),
|
|
964
1048
|
summary: summarise(entry, kind, actor),
|
|
965
1049
|
...eventTime(toDate(entry.created_at ?? entry.submitted_at ?? entry.author?.date ?? entry.committer?.date), /* @__PURE__ */ new Date(0)),
|
|
966
1050
|
actor,
|
|
@@ -978,7 +1062,7 @@ function toCheckRun(repo, raw) {
|
|
|
978
1062
|
const runId = raw.html_url?.match(ACTIONS_JOB_URL)?.[1];
|
|
979
1063
|
return {
|
|
980
1064
|
ref: {
|
|
981
|
-
forge:
|
|
1065
|
+
forge: repo.forge,
|
|
982
1066
|
instance: repo.instance,
|
|
983
1067
|
repo,
|
|
984
1068
|
id: String(raw.id),
|
|
@@ -993,7 +1077,7 @@ function toCheckRun(repo, raw) {
|
|
|
993
1077
|
startedAt: toDate(raw.started_at),
|
|
994
1078
|
completedAt: toDate(raw.completed_at),
|
|
995
1079
|
...runId ? { run: {
|
|
996
|
-
forge:
|
|
1080
|
+
forge: repo.forge,
|
|
997
1081
|
instance: repo.instance,
|
|
998
1082
|
repo,
|
|
999
1083
|
id: runId
|
|
@@ -1005,7 +1089,7 @@ function toStatusCheck(repo, raw) {
|
|
|
1005
1089
|
const state = statusState(raw.state);
|
|
1006
1090
|
return {
|
|
1007
1091
|
ref: {
|
|
1008
|
-
forge:
|
|
1092
|
+
forge: repo.forge,
|
|
1009
1093
|
instance: repo.instance,
|
|
1010
1094
|
repo,
|
|
1011
1095
|
id: String(raw.id),
|
|
@@ -1022,10 +1106,10 @@ function toStatusCheck(repo, raw) {
|
|
|
1022
1106
|
}
|
|
1023
1107
|
function toRelease(repo, raw) {
|
|
1024
1108
|
const ref = {
|
|
1025
|
-
forge:
|
|
1109
|
+
forge: repo.forge,
|
|
1026
1110
|
instance: repo.instance,
|
|
1027
1111
|
repo,
|
|
1028
|
-
id: String(raw.id),
|
|
1112
|
+
id: raw.id === void 0 ? raw.tag_name : String(raw.id),
|
|
1029
1113
|
tag: raw.tag_name
|
|
1030
1114
|
};
|
|
1031
1115
|
return {
|
|
@@ -1036,13 +1120,13 @@ function toRelease(repo, raw) {
|
|
|
1036
1120
|
isDraft: raw.draft,
|
|
1037
1121
|
isPrerelease: raw.prerelease,
|
|
1038
1122
|
immutable: raw.immutable,
|
|
1039
|
-
author: toActor(repo
|
|
1123
|
+
author: toActor(repo, raw.author),
|
|
1040
1124
|
publishedAt: toDate(raw.published_at),
|
|
1041
1125
|
createdAt: toDate(raw.created_at),
|
|
1042
1126
|
url: raw.html_url,
|
|
1043
1127
|
assets: raw.assets?.map((asset) => ({
|
|
1044
1128
|
...asset.id === void 0 ? {} : { ref: {
|
|
1045
|
-
forge:
|
|
1129
|
+
forge: repo.forge,
|
|
1046
1130
|
instance: repo.instance,
|
|
1047
1131
|
repo,
|
|
1048
1132
|
release: ref,
|
|
@@ -1078,7 +1162,7 @@ function toDependabotAlert(repo, raw) {
|
|
|
1078
1162
|
const pkg = raw.dependency?.package;
|
|
1079
1163
|
return {
|
|
1080
1164
|
ref: {
|
|
1081
|
-
forge:
|
|
1165
|
+
forge: repo.forge,
|
|
1082
1166
|
instance: repo.instance,
|
|
1083
1167
|
repo,
|
|
1084
1168
|
id: String(raw.number),
|
|
@@ -1109,7 +1193,7 @@ function toCodeScanningAlert(repo, raw) {
|
|
|
1109
1193
|
const severityRaw = raw.rule?.security_severity_level ?? raw.rule?.severity ?? void 0;
|
|
1110
1194
|
return {
|
|
1111
1195
|
ref: {
|
|
1112
|
-
forge:
|
|
1196
|
+
forge: repo.forge,
|
|
1113
1197
|
instance: repo.instance,
|
|
1114
1198
|
repo,
|
|
1115
1199
|
id: String(raw.number),
|
|
@@ -1135,7 +1219,7 @@ function toSecretScanningAlert(repo, raw) {
|
|
|
1135
1219
|
const state = raw.state === "open" ? "open" : raw.state === "resolved" ? raw.resolution === "revoked" ? "fixed" : "dismissed" : "unknown";
|
|
1136
1220
|
return {
|
|
1137
1221
|
ref: {
|
|
1138
|
-
forge:
|
|
1222
|
+
forge: repo.forge,
|
|
1139
1223
|
instance: repo.instance,
|
|
1140
1224
|
repo,
|
|
1141
1225
|
id: String(raw.number),
|
|
@@ -1161,7 +1245,7 @@ function toRepositoryAdvisory(repo, raw) {
|
|
|
1161
1245
|
const vulnerability = raw.vulnerabilities?.find((item) => item.package?.name);
|
|
1162
1246
|
return {
|
|
1163
1247
|
ref: {
|
|
1164
|
-
forge:
|
|
1248
|
+
forge: repo.forge,
|
|
1165
1249
|
instance: repo.instance,
|
|
1166
1250
|
repo,
|
|
1167
1251
|
id: raw.ghsa_id,
|
|
@@ -1191,13 +1275,13 @@ function toRepositoryAdvisory(repo, raw) {
|
|
|
1191
1275
|
function toReviewComment(thread, raw, reviewThread) {
|
|
1192
1276
|
return {
|
|
1193
1277
|
ref: {
|
|
1194
|
-
forge:
|
|
1278
|
+
forge: thread.forge,
|
|
1195
1279
|
instance: thread.instance,
|
|
1196
1280
|
thread,
|
|
1197
1281
|
id: String(raw.id)
|
|
1198
1282
|
},
|
|
1199
1283
|
body: raw.body ?? "",
|
|
1200
|
-
author: toActor(thread
|
|
1284
|
+
author: toActor(thread, raw.user),
|
|
1201
1285
|
path: raw.path,
|
|
1202
1286
|
line: raw.line ?? raw.original_line ?? void 0,
|
|
1203
1287
|
side: raw.side?.toLowerCase() === "left" ? "left" : raw.side ? "right" : void 0,
|
|
@@ -1211,12 +1295,12 @@ function toReviewComment(thread, raw, reviewThread) {
|
|
|
1211
1295
|
function toReview(thread, raw, comments) {
|
|
1212
1296
|
return {
|
|
1213
1297
|
ref: {
|
|
1214
|
-
forge:
|
|
1298
|
+
forge: thread.forge,
|
|
1215
1299
|
instance: thread.instance,
|
|
1216
1300
|
thread,
|
|
1217
1301
|
id: String(raw.id)
|
|
1218
1302
|
},
|
|
1219
|
-
author: toActor(thread
|
|
1303
|
+
author: toActor(thread, raw.user),
|
|
1220
1304
|
state: reviewState(raw.state),
|
|
1221
1305
|
stateRaw: raw.state,
|
|
1222
1306
|
body: raw.body || void 0,
|
|
@@ -1229,7 +1313,7 @@ function toReview(thread, raw, comments) {
|
|
|
1229
1313
|
function toWorkflowRun(repo, raw) {
|
|
1230
1314
|
return {
|
|
1231
1315
|
ref: {
|
|
1232
|
-
forge:
|
|
1316
|
+
forge: repo.forge,
|
|
1233
1317
|
instance: repo.instance,
|
|
1234
1318
|
repo,
|
|
1235
1319
|
id: String(raw.id)
|
|
@@ -1242,7 +1326,7 @@ function toWorkflowRun(repo, raw) {
|
|
|
1242
1326
|
branch: raw.head_branch ?? void 0,
|
|
1243
1327
|
sha: raw.head_sha,
|
|
1244
1328
|
url: raw.html_url,
|
|
1245
|
-
actor: toActor(repo
|
|
1329
|
+
actor: toActor(repo, raw.actor),
|
|
1246
1330
|
createdAt: toDate(raw.created_at),
|
|
1247
1331
|
startedAt: toDate(raw.run_started_at),
|
|
1248
1332
|
completedAt: raw.status === "completed" ? toDate(raw.updated_at) : void 0,
|
|
@@ -1252,7 +1336,7 @@ function toWorkflowRun(repo, raw) {
|
|
|
1252
1336
|
function toWorkflowJob(run, raw) {
|
|
1253
1337
|
return {
|
|
1254
1338
|
ref: {
|
|
1255
|
-
forge:
|
|
1339
|
+
forge: run.forge,
|
|
1256
1340
|
instance: run.instance,
|
|
1257
1341
|
repo: run.repo,
|
|
1258
1342
|
id: String(raw.id),
|
|
@@ -1282,7 +1366,7 @@ function toChangedFile(raw) {
|
|
|
1282
1366
|
function toCommit(repo, raw) {
|
|
1283
1367
|
return {
|
|
1284
1368
|
ref: {
|
|
1285
|
-
forge:
|
|
1369
|
+
forge: repo.forge,
|
|
1286
1370
|
instance: repo.instance,
|
|
1287
1371
|
repo,
|
|
1288
1372
|
sha: raw.sha
|
|
@@ -1290,13 +1374,13 @@ function toCommit(repo, raw) {
|
|
|
1290
1374
|
sha: raw.sha,
|
|
1291
1375
|
message: raw.commit.message,
|
|
1292
1376
|
author: {
|
|
1293
|
-
actor: toActor(repo
|
|
1377
|
+
actor: toActor(repo, raw.author),
|
|
1294
1378
|
name: raw.commit.author?.name,
|
|
1295
1379
|
email: raw.commit.author?.email,
|
|
1296
1380
|
date: toDate(raw.commit.author?.date)
|
|
1297
1381
|
},
|
|
1298
1382
|
committer: {
|
|
1299
|
-
actor: toActor(repo
|
|
1383
|
+
actor: toActor(repo, raw.committer),
|
|
1300
1384
|
name: raw.commit.committer?.name,
|
|
1301
1385
|
email: raw.commit.committer?.email,
|
|
1302
1386
|
date: toDate(raw.commit.committer?.date)
|
|
@@ -1316,7 +1400,7 @@ function toCommit(repo, raw) {
|
|
|
1316
1400
|
function toGitCommit(repo, raw) {
|
|
1317
1401
|
return {
|
|
1318
1402
|
ref: {
|
|
1319
|
-
forge:
|
|
1403
|
+
forge: repo.forge,
|
|
1320
1404
|
instance: repo.instance,
|
|
1321
1405
|
repo,
|
|
1322
1406
|
sha: raw.sha
|
|
@@ -1407,7 +1491,7 @@ function toWebhook(target, raw) {
|
|
|
1407
1491
|
const nativeEvents = raw.events ?? [];
|
|
1408
1492
|
return {
|
|
1409
1493
|
ref: {
|
|
1410
|
-
forge:
|
|
1494
|
+
forge: target.forge,
|
|
1411
1495
|
instance: target.instance,
|
|
1412
1496
|
target,
|
|
1413
1497
|
id: String(raw.id)
|
|
@@ -1426,7 +1510,7 @@ function toWebhookDelivery(hook, raw) {
|
|
|
1426
1510
|
const status = raw.status_code ?? 0;
|
|
1427
1511
|
return {
|
|
1428
1512
|
ref: {
|
|
1429
|
-
forge:
|
|
1513
|
+
forge: hook.forge,
|
|
1430
1514
|
instance: hook.instance,
|
|
1431
1515
|
hook,
|
|
1432
1516
|
id: String(raw.id),
|
|
@@ -1440,92 +1524,6 @@ function toWebhookDelivery(hook, raw) {
|
|
|
1440
1524
|
raw
|
|
1441
1525
|
};
|
|
1442
1526
|
}
|
|
1443
|
-
function graphqlUrl(baseUrl) {
|
|
1444
|
-
const url = new URL(baseUrl);
|
|
1445
|
-
if (url.host === "api.github.com") return "https://api.github.com/graphql";
|
|
1446
|
-
return `${url.origin}${url.pathname.replace(/\/v3\/?$/, "")}/graphql`;
|
|
1447
|
-
}
|
|
1448
|
-
/**
|
|
1449
|
-
* A failed GraphQL response as an error: `InsufficientScopeError` when the token lacks a scope a field needs, and
|
|
1450
|
-
* `RateLimitedError` for a rate limit, which GitHub reports with a `200`.
|
|
1451
|
-
*/
|
|
1452
|
-
function graphqlError(operationName, errors, url, context, response) {
|
|
1453
|
-
const message = `GraphQL ${operationName ?? "request"} failed: ${errors?.map((error) => error.message).join("; ") || "Empty GraphQL response"}`;
|
|
1454
|
-
const body = JSON.stringify(errors ?? null).slice(0, 512);
|
|
1455
|
-
const errorContext = {
|
|
1456
|
-
forge: FORGE,
|
|
1457
|
-
instance: context.instance,
|
|
1458
|
-
url,
|
|
1459
|
-
method: "POST"
|
|
1460
|
-
};
|
|
1461
|
-
const secondary = errors?.some((error) => isSecondaryRateLimit(error.message)) ?? false;
|
|
1462
|
-
if (secondary || errors?.some((error) => error.type === "RATE_LIMITED")) {
|
|
1463
|
-
const budget = response && rateLimitOf(response);
|
|
1464
|
-
const resetAt = response && (rateLimitReset(response, budget) ?? (secondary ? void 0 : budget?.resetAt));
|
|
1465
|
-
return new RateLimitedError(message, 200, body, {
|
|
1466
|
-
...errorContext,
|
|
1467
|
-
resetAt,
|
|
1468
|
-
secondary
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
const scopeError = errors?.find((error) => error.type === "INSUFFICIENT_SCOPES");
|
|
1472
|
-
if (!scopeError) return new ForgeApiError(message, 200, body, errorContext);
|
|
1473
|
-
return new InsufficientScopeError(message, 200, body, {
|
|
1474
|
-
...errorContext,
|
|
1475
|
-
acceptedScopes: quotedScopes(scopeError.message.match(/requires one of the following scopes: \[([^\]]*)\]/)?.[1]),
|
|
1476
|
-
grantedScopes: quotedScopes(scopeError.message.match(/has only been granted the: \[([^\]]*)\]/)?.[1])
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
function quotedScopes(list) {
|
|
1480
|
-
return list === void 0 ? void 0 : [...list.matchAll(/'([^']+)'/g)].map((match) => match[1]);
|
|
1481
|
-
}
|
|
1482
|
-
const OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
1483
|
-
"query",
|
|
1484
|
-
"mutation",
|
|
1485
|
-
"subscription"
|
|
1486
|
-
]);
|
|
1487
|
-
/** The operations a GraphQL document declares, read from its top level so that fields, variables, strings and comments don't count. */
|
|
1488
|
-
function graphqlOperations(document) {
|
|
1489
|
-
const operations = [];
|
|
1490
|
-
let depth = 0;
|
|
1491
|
-
let definitionStart = true;
|
|
1492
|
-
let awaitingName;
|
|
1493
|
-
for (const [token] of document.matchAll(/"""(?:\\"""|[\s\S])*?"""|"(?:\\.|[^"\\\n\r])*"|#[^\n\r]*|[{}()]|[$@]?[_a-z]\w*/gi)) {
|
|
1494
|
-
if (token[0] === "\"" || token[0] === "#") continue;
|
|
1495
|
-
if (token === "{" || token === "(") {
|
|
1496
|
-
if (depth === 0 && definitionStart && token === "{") operations.push({ type: "query" });
|
|
1497
|
-
depth++;
|
|
1498
|
-
definitionStart = false;
|
|
1499
|
-
awaitingName = void 0;
|
|
1500
|
-
} else if (token === "}" || token === ")") {
|
|
1501
|
-
depth--;
|
|
1502
|
-
definitionStart = depth === 0 && token === "}";
|
|
1503
|
-
} else if (depth === 0) {
|
|
1504
|
-
if (awaitingName && /^[_a-z]/i.test(token)) awaitingName.name = token;
|
|
1505
|
-
awaitingName = definitionStart && OPERATION_TYPES.has(token) ? { type: token } : void 0;
|
|
1506
|
-
if (awaitingName) operations.push(awaitingName);
|
|
1507
|
-
definitionStart = false;
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
return operations;
|
|
1511
|
-
}
|
|
1512
|
-
function createGraphQLClient(fetcher, url, context) {
|
|
1513
|
-
return async (document, variables, options) => {
|
|
1514
|
-
const query = typeof document === "string" ? (await import("./graphql-BDhuP5jN-BSpB8lWf.js"))[document] : document.query;
|
|
1515
|
-
const operationName = graphqlOperations(query)[0]?.name;
|
|
1516
|
-
const { data, response } = await fetcher.json(url, {
|
|
1517
|
-
method: "POST",
|
|
1518
|
-
json: {
|
|
1519
|
-
query,
|
|
1520
|
-
variables,
|
|
1521
|
-
operationName
|
|
1522
|
-
},
|
|
1523
|
-
signal: options?.signal
|
|
1524
|
-
});
|
|
1525
|
-
if (data.errors?.length || !data.data) throw graphqlError(operationName, data.errors, url, context, response);
|
|
1526
|
-
return data.data;
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
1527
|
const SIGNATURE_HEADER = "x-hub-signature-256";
|
|
1530
1528
|
function verifyGitHubSignature(delivery, secret) {
|
|
1531
1529
|
return verifyHmacSignature(delivery, secret, {
|
|
@@ -1533,11 +1531,13 @@ function verifyGitHubSignature(delivery, secret) {
|
|
|
1533
1531
|
prefix: "sha256="
|
|
1534
1532
|
});
|
|
1535
1533
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1534
|
+
function githubWebhooks(events) {
|
|
1535
|
+
return ({ options, origin }) => ({
|
|
1536
|
+
events,
|
|
1537
|
+
verify: (delivery) => verifyGitHubSignature(delivery, options.webhookSecret),
|
|
1538
|
+
translate: async (delivery) => (await import("./events-DHqSJ5KI-z2-5_1vo.js")).translateGitHubWebhook(origin, delivery)
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
1541
|
const DISCUSSION_CLOSE_REASONS = {
|
|
1542
1542
|
completed: "resolved",
|
|
1543
1543
|
duplicate: "duplicate"
|
|
@@ -1551,6 +1551,8 @@ const GHES_MARK_DONE = "3.13";
|
|
|
1551
1551
|
/** GitHub Enterprise Server versions with the Dependabot alerts REST API. */
|
|
1552
1552
|
const GHES_DEPENDABOT_ALERTS = "3.8";
|
|
1553
1553
|
const GRAPHQL_BATCH = 20;
|
|
1554
|
+
/** Each alias reads one scalar from one owner, so a chunk holds far more accounts than a thread batch. */
|
|
1555
|
+
const SPONSORABLE_BATCH = 50;
|
|
1554
1556
|
const LOCK_REASONS = {
|
|
1555
1557
|
off_topic: "off-topic",
|
|
1556
1558
|
too_heated: "too heated",
|
|
@@ -1633,7 +1635,8 @@ function advancedFreeText(text) {
|
|
|
1633
1635
|
}
|
|
1634
1636
|
return parts.map((part, index) => index % 2 ? part : part.replace(/[()\s]+/g, " ")).join("\"").trim();
|
|
1635
1637
|
}
|
|
1636
|
-
function setupGitHub(
|
|
1638
|
+
function setupGitHub(ctx, profile) {
|
|
1639
|
+
const { options, baseUrl, instance, origin: context, fetcher, createFetcher, derive, state: credentials } = ctx;
|
|
1637
1640
|
const list = createListing(fetcher, "per_page");
|
|
1638
1641
|
const auth = options.auth ?? { type: "anonymous" };
|
|
1639
1642
|
/** GitHub GraphQL needs a credential, so anonymous providers stay on REST. */
|
|
@@ -1648,7 +1651,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1648
1651
|
const host = hostOf(baseUrl);
|
|
1649
1652
|
/** GitHub Enterprise Server; `ghe.com` data residency hosts follow github.com. */
|
|
1650
1653
|
const enterprise = host !== "api.github.com" && !isGheCom(host);
|
|
1651
|
-
const graphql = createGraphQLClient(fetcher, graphqlUrl(baseUrl),
|
|
1654
|
+
const graphql = createGraphQLClient(fetcher, graphqlUrl(baseUrl), context);
|
|
1652
1655
|
/**
|
|
1653
1656
|
* Discussion notification subjects carry no URL. The repo's most recently
|
|
1654
1657
|
* updated discussions are listed and matched on an exact, unique title.
|
|
@@ -1662,7 +1665,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1662
1665
|
})).values()];
|
|
1663
1666
|
let result;
|
|
1664
1667
|
try {
|
|
1665
|
-
const { query, variables } = (await import("./graphql-
|
|
1668
|
+
const { query, variables } = (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).recentDiscussionsQuery(repos);
|
|
1666
1669
|
result = await graphql({ query }, variables);
|
|
1667
1670
|
} catch (error) {
|
|
1668
1671
|
if (error instanceof InsufficientScopeError || error instanceof ForgeApiError && error.status === 200) return [toWarning("discussion_unresolved", error)];
|
|
@@ -1720,7 +1723,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1720
1723
|
etag: listOptions.cursor?.nextUrl ? void 0 : listOptions.cursor?.etag,
|
|
1721
1724
|
signal: listOptions.signal
|
|
1722
1725
|
});
|
|
1723
|
-
const items = (result.data ?? []).map((raw) => toNotification(
|
|
1726
|
+
const items = (result.data ?? []).map((raw) => toNotification(context, raw));
|
|
1724
1727
|
const warnings = await resolveDiscussionNumbers(items);
|
|
1725
1728
|
const etag = listOptions.cursor?.nextUrl ? void 0 : result.cursor?.etag ?? listOptions.cursor?.etag;
|
|
1726
1729
|
return {
|
|
@@ -1744,7 +1747,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1744
1747
|
number: Number(ref.number)
|
|
1745
1748
|
}, options)).repository?.discussion;
|
|
1746
1749
|
if (!discussion) throw new NotFoundError(`Discussion ${ref.number} not found`, 404, "", context);
|
|
1747
|
-
return (await import("./graphql-
|
|
1750
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionThread(ref, discussion);
|
|
1748
1751
|
}
|
|
1749
1752
|
async function discussionCommentPage(ref, listOptions) {
|
|
1750
1753
|
const comments = (await graphql("DISCUSSION_COMMENTS", {
|
|
@@ -1771,7 +1774,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1771
1774
|
const result = toThread(ref, data);
|
|
1772
1775
|
if (ref.kind === "pull_request" && data.head?.sha) try {
|
|
1773
1776
|
const checks = await headChecks(ref.repo, data.head.sha, options?.signal);
|
|
1774
|
-
result.checks = summariseChecks(checks.items.map((check) => check.state), data.html_url ? `${data.html_url}/checks` :
|
|
1777
|
+
result.checks = summariseChecks(checks.items.map((check) => check.state), data.html_url && profile.checkRuns ? `${data.html_url}/checks` : data.html_url);
|
|
1775
1778
|
if (checks.warnings?.length) result.warnings = [...result.warnings ?? [], ...checks.warnings];
|
|
1776
1779
|
} catch (error) {
|
|
1777
1780
|
if (!degradesToWarning(error)) throw error;
|
|
@@ -1781,7 +1784,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1781
1784
|
}
|
|
1782
1785
|
async function headChecks(repo, sha, signal) {
|
|
1783
1786
|
let checkRunTotal;
|
|
1784
|
-
const [runs, status] = await Promise.allSettled([Array.fromAsync(fetcher.items(`${repoPath(repo)}/commits/${sha}/check-runs`, {
|
|
1787
|
+
const [runs, status] = await Promise.allSettled([!profile.checkRuns ? Promise.resolve([]) : Array.fromAsync(fetcher.items(`${repoPath(repo)}/commits/${sha}/check-runs`, {
|
|
1785
1788
|
query: { per_page: 100 },
|
|
1786
1789
|
select: (body, next) => {
|
|
1787
1790
|
const { check_runs, total_count } = body;
|
|
@@ -1812,7 +1815,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1812
1815
|
};
|
|
1813
1816
|
}
|
|
1814
1817
|
async function getMany(refs, options) {
|
|
1815
|
-
if (anonymous) return getManyConcurrently(refs, (ref, getOptions) => ref.kind === "discussion" ? Promise.reject(new UnsupportedOperationError("github does not read discussions without credentials", context)) : get(ref, getOptions), options);
|
|
1818
|
+
if (anonymous || !profile.graphql) return getManyConcurrently(refs, (ref, getOptions) => ref.kind === "discussion" ? Promise.reject(new UnsupportedOperationError("github does not read discussions without credentials", context)) : get(ref, getOptions), options);
|
|
1816
1819
|
const results = Array.from({ length: refs.length });
|
|
1817
1820
|
const batchable = [];
|
|
1818
1821
|
for (const [index, ref] of refs.entries()) if (!isResolvedThread(ref)) results[index] = {
|
|
@@ -1825,7 +1828,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1825
1828
|
ref
|
|
1826
1829
|
});
|
|
1827
1830
|
if (!batchable.length) return results;
|
|
1828
|
-
const g = await import("./graphql-
|
|
1831
|
+
const g = await import("./graphql-DxRA9BGO-BBbmTmWi.js");
|
|
1829
1832
|
for (let start = 0; start < batchable.length; start += GRAPHQL_BATCH) {
|
|
1830
1833
|
const chunk = batchable.slice(start, start + GRAPHQL_BATCH);
|
|
1831
1834
|
const { query, variables } = g.threadsBatchQuery(chunk.map((item) => item.ref));
|
|
@@ -1839,7 +1842,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1839
1842
|
},
|
|
1840
1843
|
signal: options?.signal
|
|
1841
1844
|
});
|
|
1842
|
-
const failure = data.data ? void 0 : graphqlError("ThreadsBatch", data.errors, url,
|
|
1845
|
+
const failure = data.data ? void 0 : graphqlError("ThreadsBatch", data.errors, url, context, response);
|
|
1843
1846
|
if (failure instanceof RateLimitedError) throw failure;
|
|
1844
1847
|
chunk.forEach(({ index, ref }, offset) => {
|
|
1845
1848
|
const node = data.data?.[`t${offset}`];
|
|
@@ -1859,7 +1862,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1859
1862
|
results[index] = {
|
|
1860
1863
|
ok: false,
|
|
1861
1864
|
ref,
|
|
1862
|
-
warning: toWarning("insufficient_scope", graphqlError("ThreadsBatch", [error], url,
|
|
1865
|
+
warning: toWarning("insufficient_scope", graphqlError("ThreadsBatch", [error], url, context), ref.number)
|
|
1863
1866
|
};
|
|
1864
1867
|
return;
|
|
1865
1868
|
}
|
|
@@ -1883,6 +1886,69 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1883
1886
|
}
|
|
1884
1887
|
return results;
|
|
1885
1888
|
}
|
|
1889
|
+
/** Reads each chunk with one aliased GraphQL request; per-login failures become warnings. */
|
|
1890
|
+
async function sponsorableMany(logins, options) {
|
|
1891
|
+
const results = Array.from({ length: logins.length });
|
|
1892
|
+
if (!logins.length) return results;
|
|
1893
|
+
const g = await import("./graphql-DxRA9BGO-BBbmTmWi.js");
|
|
1894
|
+
const url = graphqlUrl(baseUrl);
|
|
1895
|
+
for (let start = 0; start < logins.length; start += SPONSORABLE_BATCH) {
|
|
1896
|
+
const chunk = logins.slice(start, start + SPONSORABLE_BATCH);
|
|
1897
|
+
const { query, variables } = g.sponsorableBatchQuery(chunk);
|
|
1898
|
+
const { data, response } = await fetcher.json(url, {
|
|
1899
|
+
method: "POST",
|
|
1900
|
+
json: {
|
|
1901
|
+
query,
|
|
1902
|
+
variables,
|
|
1903
|
+
operationName: "SponsorableMany"
|
|
1904
|
+
},
|
|
1905
|
+
signal: options?.signal
|
|
1906
|
+
});
|
|
1907
|
+
const requestError = data.errors?.length ? graphqlError("SponsorableMany", data.errors, url, context, response) : void 0;
|
|
1908
|
+
if (requestError instanceof RateLimitedError) throw requestError;
|
|
1909
|
+
const failure = data.data ? void 0 : requestError ?? graphqlError("SponsorableMany", void 0, url, context, response);
|
|
1910
|
+
chunk.forEach((login, offset) => {
|
|
1911
|
+
const index = start + offset;
|
|
1912
|
+
if (failure) {
|
|
1913
|
+
results[index] = {
|
|
1914
|
+
ok: false,
|
|
1915
|
+
login,
|
|
1916
|
+
warning: toWarning(failure instanceof InsufficientScopeError ? "insufficient_scope" : "account_unreadable", failure, login)
|
|
1917
|
+
};
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
const owner = data.data?.[`u${offset}`];
|
|
1921
|
+
if (!owner) {
|
|
1922
|
+
const error = data.errors?.find((error) => error.path?.[0] === `u${offset}`);
|
|
1923
|
+
if (error && error.type !== "NOT_FOUND") {
|
|
1924
|
+
const code = error.type === "INSUFFICIENT_SCOPES" ? "insufficient_scope" : "account_unreadable";
|
|
1925
|
+
results[index] = {
|
|
1926
|
+
ok: false,
|
|
1927
|
+
login,
|
|
1928
|
+
warning: toWarning(code, graphqlError("SponsorableMany", [error], url, context), login)
|
|
1929
|
+
};
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
results[index] = {
|
|
1933
|
+
ok: false,
|
|
1934
|
+
login,
|
|
1935
|
+
warning: {
|
|
1936
|
+
code: "account_not_found",
|
|
1937
|
+
message: error?.message ?? `Account ${login} not found`,
|
|
1938
|
+
subject: login
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
results[index] = {
|
|
1944
|
+
ok: true,
|
|
1945
|
+
login,
|
|
1946
|
+
sponsorable: owner.hasSponsorsListing
|
|
1947
|
+
};
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
return results;
|
|
1951
|
+
}
|
|
1886
1952
|
async function listPage(repo, query = {}) {
|
|
1887
1953
|
const state = query.state ?? "open";
|
|
1888
1954
|
const direction = query.direction ?? "desc";
|
|
@@ -1918,11 +1984,11 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1918
1984
|
field: query.sort === "created" || !query.sort ? "CREATED_AT" : "UPDATED_AT",
|
|
1919
1985
|
direction: direction.toUpperCase()
|
|
1920
1986
|
}, query);
|
|
1921
|
-
const { toDiscussionThread } = await import("./graphql-
|
|
1987
|
+
const { toDiscussionThread } = await import("./graphql-DxRA9BGO-BBbmTmWi.js");
|
|
1922
1988
|
const discussions = data.repository?.discussions;
|
|
1923
1989
|
return {
|
|
1924
1990
|
items: (discussions?.nodes ?? []).map((node) => toDiscussionThread({
|
|
1925
|
-
forge:
|
|
1991
|
+
forge: context.forge,
|
|
1926
1992
|
instance,
|
|
1927
1993
|
repo,
|
|
1928
1994
|
kind: "discussion",
|
|
@@ -1984,7 +2050,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
1984
2050
|
const isPull = Boolean(raw.pull_request || raw.head);
|
|
1985
2051
|
if (query.kind === "issue" && isPull || query.kind === "pull_request" && !isPull || older(raw)) return;
|
|
1986
2052
|
return toThread({
|
|
1987
|
-
forge:
|
|
2053
|
+
forge: context.forge,
|
|
1988
2054
|
instance,
|
|
1989
2055
|
repo,
|
|
1990
2056
|
kind: isPull ? "pull_request" : "issue",
|
|
@@ -2029,7 +2095,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2029
2095
|
async function commentsPage(thread, listOptions = {}) {
|
|
2030
2096
|
const ref = requireThread(thread, context);
|
|
2031
2097
|
if (ref.kind === "discussion") {
|
|
2032
|
-
const [page, { toDiscussionComment }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-
|
|
2098
|
+
const [page, { toDiscussionComment }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
2033
2099
|
return {
|
|
2034
2100
|
...page,
|
|
2035
2101
|
items: page.items.map(({ comment }) => toDiscussionComment(ref, comment))
|
|
@@ -2060,7 +2126,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2060
2126
|
id,
|
|
2061
2127
|
reason: reason?.toUpperCase() ?? null
|
|
2062
2128
|
}, options_)).closeDiscussion : (await graphql("REOPEN_DISCUSSION", { id }, options_)).reopenDiscussion;
|
|
2063
|
-
return (await import("./graphql-
|
|
2129
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionThread(ref, data.discussion);
|
|
2064
2130
|
}
|
|
2065
2131
|
const reason = options_.reasonRaw ?? options_.reason;
|
|
2066
2132
|
const { data } = await fetcher.json(threadPath(ref), {
|
|
@@ -2256,7 +2322,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2256
2322
|
/** Resolvable conversations, by the id of each comment in them; empty when GraphQL is unreachable. */
|
|
2257
2323
|
async function reviewThreadsByComment(ref, options) {
|
|
2258
2324
|
const byComment = /* @__PURE__ */ new Map();
|
|
2259
|
-
if (anonymous) return byComment;
|
|
2325
|
+
if (anonymous || !profile.graphql) return byComment;
|
|
2260
2326
|
let after = null;
|
|
2261
2327
|
do {
|
|
2262
2328
|
let data;
|
|
@@ -2314,7 +2380,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2314
2380
|
number: Number(ref.number),
|
|
2315
2381
|
first: Math.min(listOptions.perPage ?? 50, 100),
|
|
2316
2382
|
after: listOptions.cursor?.token ?? null
|
|
2317
|
-
}, listOptions), import("./graphql-
|
|
2383
|
+
}, listOptions), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
2318
2384
|
const pull = data.repository?.pullRequest;
|
|
2319
2385
|
if (!pull) throw new NotFoundError(`Pull request ${ref.number} not found`, 404, "", context);
|
|
2320
2386
|
const { nodes, pageInfo } = pull.reviewThreads;
|
|
@@ -2341,7 +2407,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2341
2407
|
if (thread.kind === "discussion") {
|
|
2342
2408
|
const data = await graphql("GET_DISCUSSION_COMMENT", { id: ref.id }, options);
|
|
2343
2409
|
if (!data.node?.id) throw new NotFoundError(`Comment ${ref.id} not found`, 404, "", context);
|
|
2344
|
-
return (await import("./graphql-
|
|
2410
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionComment(thread, data.node);
|
|
2345
2411
|
}
|
|
2346
2412
|
const { data } = await fetcher.json(commentPath(ref), { signal: options?.signal });
|
|
2347
2413
|
return toComment(thread, data);
|
|
@@ -2367,7 +2433,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2367
2433
|
async function getJob(ref, options) {
|
|
2368
2434
|
const { data } = await fetcher.json(`${repoPath(ref.repo)}/actions/jobs/${encodeURIComponent(ref.id)}`, { signal: options?.signal });
|
|
2369
2435
|
const run = ref.run ?? (data.run_id === void 0 ? void 0 : {
|
|
2370
|
-
forge:
|
|
2436
|
+
forge: context.forge,
|
|
2371
2437
|
instance,
|
|
2372
2438
|
repo: ref.repo,
|
|
2373
2439
|
id: String(data.run_id)
|
|
@@ -2398,20 +2464,20 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2398
2464
|
number: Number(ref.number),
|
|
2399
2465
|
first: Math.min(listOptions.perPage ?? 50, 100),
|
|
2400
2466
|
after: listOptions.cursor?.token ?? null
|
|
2401
|
-
}, listOptions), import("./graphql-
|
|
2467
|
+
}, listOptions), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
2402
2468
|
const references = data.repository?.thread?.references;
|
|
2403
2469
|
if (!references) throw new NotFoundError(`Thread ${ref.number} not found`, 404, "", context);
|
|
2404
2470
|
return {
|
|
2405
2471
|
items: references.nodes.map((node) => {
|
|
2406
2472
|
const repo = {
|
|
2407
|
-
forge:
|
|
2473
|
+
forge: context.forge,
|
|
2408
2474
|
instance,
|
|
2409
2475
|
owner: node.repository.owner.login,
|
|
2410
2476
|
name: node.repository.name,
|
|
2411
2477
|
externalId: node.repository.databaseId === void 0 ? void 0 : String(node.repository.databaseId)
|
|
2412
2478
|
};
|
|
2413
2479
|
return toGraphQLThread({
|
|
2414
|
-
forge:
|
|
2480
|
+
forge: context.forge,
|
|
2415
2481
|
instance,
|
|
2416
2482
|
repo,
|
|
2417
2483
|
kind: node.__typename === "PullRequest" ? "pull_request" : "issue",
|
|
@@ -2437,14 +2503,14 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2437
2503
|
items: body.repositories,
|
|
2438
2504
|
next
|
|
2439
2505
|
}) : void 0
|
|
2440
|
-
}), (raw) => toRepo(
|
|
2506
|
+
}), (raw) => toRepo(context, raw));
|
|
2441
2507
|
}
|
|
2442
2508
|
/** The authenticated login, read once and reused; reactions are deleted by id, so removing one needs it. */
|
|
2443
2509
|
const viewerLogin = memo(async () => (await fetcher.json("/user")).data.login);
|
|
2444
2510
|
/** `/users/{owner}/repos` serves organisations too, but lists only public repositories. */
|
|
2445
2511
|
async function ownerReposPage(owner, query = {}) {
|
|
2446
2512
|
const visibility = query.visibility === "all" ? void 0 : query.visibility;
|
|
2447
|
-
const read = (path, params) => list(path, query, (raw) => toRepo(
|
|
2513
|
+
const read = (path, params) => list(path, query, (raw) => toRepo(context, raw), { query: {
|
|
2448
2514
|
...params,
|
|
2449
2515
|
sort: query.sort === "name" ? "full_name" : query.sort,
|
|
2450
2516
|
direction: query.direction
|
|
@@ -2573,11 +2639,11 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2573
2639
|
}
|
|
2574
2640
|
});
|
|
2575
2641
|
return toPage(result, (raw) => {
|
|
2576
|
-
const repo = query.repo ?? repoRefFromApiUrl(
|
|
2642
|
+
const repo = query.repo ?? repoRefFromApiUrl(context, raw.repository_url);
|
|
2577
2643
|
if (!repo) return;
|
|
2578
2644
|
const isPull = Boolean(raw.pull_request);
|
|
2579
2645
|
return toThread({
|
|
2580
|
-
forge:
|
|
2646
|
+
forge: context.forge,
|
|
2581
2647
|
instance,
|
|
2582
2648
|
repo,
|
|
2583
2649
|
kind: isPull ? "pull_request" : "issue",
|
|
@@ -2592,7 +2658,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2592
2658
|
const path = `${repoPath(repo)}/stats/contributors`;
|
|
2593
2659
|
for (let attempt = 0;; attempt++) {
|
|
2594
2660
|
const { data, response } = await fetcher.json(path, { signal: statsOptions.signal });
|
|
2595
|
-
if (response.status !== 202) return (data ?? []).map((raw) => toContributorStats(
|
|
2661
|
+
if (response.status !== 202) return (data ?? []).map((raw) => toContributorStats(context, raw));
|
|
2596
2662
|
if (attempt >= CONTRIBUTOR_STATS_DELAYS.length) throw new ForgeApiError(`GitHub is still computing the contributor statistics of ${repo.owner}/${repo.name}`, 202, "", {
|
|
2597
2663
|
...context,
|
|
2598
2664
|
url: fetcher.resolve(path),
|
|
@@ -2634,7 +2700,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2634
2700
|
};
|
|
2635
2701
|
}
|
|
2636
2702
|
});
|
|
2637
|
-
return toPage(result, (raw) => toRepo(
|
|
2703
|
+
return toPage(result, (raw) => toRepo(context, raw), warnings);
|
|
2638
2704
|
}
|
|
2639
2705
|
const COMMIT_SEARCH_SORTS = {
|
|
2640
2706
|
author_date: "author-date",
|
|
@@ -2669,7 +2735,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2669
2735
|
}
|
|
2670
2736
|
});
|
|
2671
2737
|
return toPage(result, (raw) => {
|
|
2672
|
-
const repo = query.repo ?? (raw.repository && toRepoRef(
|
|
2738
|
+
const repo = query.repo ?? (raw.repository && toRepoRef(context, raw.repository));
|
|
2673
2739
|
return repo && toCommit(repo, raw);
|
|
2674
2740
|
});
|
|
2675
2741
|
}
|
|
@@ -2700,7 +2766,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2700
2766
|
}
|
|
2701
2767
|
});
|
|
2702
2768
|
return toPage(result, (raw) => ({
|
|
2703
|
-
repo: query.repo ?? toRepoRef(
|
|
2769
|
+
repo: query.repo ?? toRepoRef(context, raw.repository),
|
|
2704
2770
|
path: raw.path,
|
|
2705
2771
|
ref: new URL(raw.url).searchParams.get("ref") ?? void 0,
|
|
2706
2772
|
fragments: (raw.text_matches ?? []).filter((match) => match.property === "content").map((match) => ({ text: match.fragment })),
|
|
@@ -2720,8 +2786,8 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2720
2786
|
signal: listOptions.signal
|
|
2721
2787
|
});
|
|
2722
2788
|
const poll = recordPoll(path, listOptions.cursor, result.response);
|
|
2723
|
-
const { toFeedEvents } = await import("./events-
|
|
2724
|
-
const page = toPage(result, (raw) => toFeedEvents(
|
|
2789
|
+
const { toFeedEvents } = await import("./events-DHqSJ5KI-z2-5_1vo.js");
|
|
2790
|
+
const page = toPage(result, (raw) => toFeedEvents(context, raw));
|
|
2725
2791
|
return {
|
|
2726
2792
|
...page,
|
|
2727
2793
|
items: page.items.flat(),
|
|
@@ -2736,10 +2802,10 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2736
2802
|
const auth = options.auth;
|
|
2737
2803
|
function toInstallation(raw) {
|
|
2738
2804
|
return {
|
|
2739
|
-
forge:
|
|
2805
|
+
forge: context.forge,
|
|
2740
2806
|
instance,
|
|
2741
2807
|
id: String(raw.id),
|
|
2742
|
-
account: toActor(
|
|
2808
|
+
account: toActor(context, raw.account),
|
|
2743
2809
|
targetTypeRaw: raw.target_type,
|
|
2744
2810
|
repositorySelectionRaw: raw.repository_selection,
|
|
2745
2811
|
raw
|
|
@@ -2815,7 +2881,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2815
2881
|
}
|
|
2816
2882
|
async function templates(repo, options = {}) {
|
|
2817
2883
|
const signal = options.signal;
|
|
2818
|
-
return (await import("./templates-
|
|
2884
|
+
return (await import("./templates-0m5QBVIh-D1fZeoC-.js")).readTemplates(repo, options.kind ? [options.kind] : ["issue", "pull_request"], {
|
|
2819
2885
|
list: async (ref, path) => {
|
|
2820
2886
|
const { data } = await fetcher.json(`${repoPath(ref)}/contents${path ? `/${path.split("/").map(encodeURIComponent).join("/")}` : ""}`, { signal });
|
|
2821
2887
|
return Array.isArray(data) ? data : [];
|
|
@@ -2937,7 +3003,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
2937
3003
|
expectedHeadOid: head,
|
|
2938
3004
|
message: splitMessage(input.message),
|
|
2939
3005
|
fileChanges
|
|
2940
|
-
} }, options), import("./graphql-
|
|
3006
|
+
} }, options), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
2941
3007
|
return toGraphQLCommit(repo, data.createCommitOnBranch.commit);
|
|
2942
3008
|
} catch (error) {
|
|
2943
3009
|
if (input.createFrom !== void 0) await swapBranch(repo, input.branch, head, ZERO_OID).catch(() => {});
|
|
@@ -3105,11 +3171,11 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3105
3171
|
const [data, { toGraphQLActor, GRAPHQL_REACTIONS }] = await Promise.all([graphql("NODE_REACTIONS", {
|
|
3106
3172
|
id,
|
|
3107
3173
|
after: listOptions.cursor?.token ?? null
|
|
3108
|
-
}, listOptions), import("./graphql-
|
|
3174
|
+
}, listOptions), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
3109
3175
|
const reactions = data.node?.reactions;
|
|
3110
3176
|
return {
|
|
3111
3177
|
items: (reactions?.nodes ?? []).flatMap((raw) => {
|
|
3112
|
-
const actor = toGraphQLActor(
|
|
3178
|
+
const actor = toGraphQLActor(context, raw.user);
|
|
3113
3179
|
return actor ? [{
|
|
3114
3180
|
content: reactionContent(GRAPHQL_REACTIONS[raw.content] ?? raw.content),
|
|
3115
3181
|
contentRaw: raw.content,
|
|
@@ -3128,7 +3194,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3128
3194
|
signal: listOptions.signal
|
|
3129
3195
|
});
|
|
3130
3196
|
return toPage(result, (raw) => {
|
|
3131
|
-
const actor = toActor(
|
|
3197
|
+
const actor = toActor(context, raw.user);
|
|
3132
3198
|
return actor && {
|
|
3133
3199
|
content: reactionContent(raw.content),
|
|
3134
3200
|
contentRaw: raw.content,
|
|
@@ -3143,7 +3209,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3143
3209
|
if (thread.kind === "discussion") {
|
|
3144
3210
|
await graphql("ADD_REACTION", {
|
|
3145
3211
|
id: "thread" in target ? target.id : await nodeId(thread, options),
|
|
3146
|
-
content: (await import("./graphql-
|
|
3212
|
+
content: (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).REACTION_CONTENT[reaction]
|
|
3147
3213
|
}, options);
|
|
3148
3214
|
return;
|
|
3149
3215
|
}
|
|
@@ -3158,7 +3224,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3158
3224
|
if (thread.kind === "discussion") {
|
|
3159
3225
|
await graphql("REMOVE_REACTION", {
|
|
3160
3226
|
id: "thread" in target ? target.id : await nodeId(thread, options),
|
|
3161
|
-
content: (await import("./graphql-
|
|
3227
|
+
content: (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).REACTION_CONTENT[reaction]
|
|
3162
3228
|
}, options);
|
|
3163
3229
|
return;
|
|
3164
3230
|
}
|
|
@@ -3253,7 +3319,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3253
3319
|
return toPage(result, (raw) => toWorkflowRun(repo, raw));
|
|
3254
3320
|
}
|
|
3255
3321
|
const spec = {
|
|
3256
|
-
extensions: { graphql: ((document, variables = {}, graphqlOptions) => {
|
|
3322
|
+
extensions: !profile.graphql ? void 0 : { graphql: ((document, variables = {}, graphqlOptions) => {
|
|
3257
3323
|
const query = String(document);
|
|
3258
3324
|
return options.readOnly && graphqlOperations(query).some(({ type }) => type === "mutation") ? Promise.reject(new ReadOnlyError("GraphQL mutations are writes and this github provider is read-only", context)) : graphql({ query }, variables, graphqlOptions);
|
|
3259
3325
|
}) },
|
|
@@ -3367,7 +3433,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3367
3433
|
},
|
|
3368
3434
|
releases: {
|
|
3369
3435
|
listPage: verb(true, releasesPage),
|
|
3370
|
-
get: verb(true, async (ref, options) => toRelease(ref.repo, (await fetcher.json(`${repoPath(ref.repo)}/releases/${encodeURIComponent(ref.id)}`, { signal: options?.signal })).data)),
|
|
3436
|
+
get: verb(true, async (ref, options) => toRelease(ref.repo, (await fetcher.json(profile.releasesByTag ? `${repoPath(ref.repo)}/releases/tags/${encodeURIComponent(ref.tag ?? ref.id)}` : `${repoPath(ref.repo)}/releases/${encodeURIComponent(ref.id)}`, { signal: options?.signal })).data)),
|
|
3371
3437
|
getByTag: verb(true, async (repo, tag, options) => toRelease(repo, (await fetcher.json(`${repoPath(repo)}/releases/tags/${encodeURIComponent(tag)}`, { signal: options?.signal })).data)),
|
|
3372
3438
|
downloadAsset: verb(true, async (ref, downloadOptions = {}) => (await fetcher.stream(`${repoPath(ref.repo)}/releases/assets/${encodeURIComponent(ref.id)}`, {
|
|
3373
3439
|
headers: { accept: "application/octet-stream" },
|
|
@@ -3395,20 +3461,16 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3395
3461
|
},
|
|
3396
3462
|
traits: {
|
|
3397
3463
|
eventKinds: "native",
|
|
3398
|
-
authKinds:
|
|
3399
|
-
"token",
|
|
3400
|
-
"app",
|
|
3401
|
-
"anonymous"
|
|
3402
|
-
],
|
|
3464
|
+
authKinds: profile.authKinds,
|
|
3403
3465
|
limits: {
|
|
3404
3466
|
bodyLength: 65536,
|
|
3405
3467
|
commentLength: 65536,
|
|
3406
3468
|
labelLength: 50
|
|
3407
3469
|
}
|
|
3408
3470
|
},
|
|
3409
|
-
probeVersion: enterprise ? async () => (await fetcher.json("/meta")).data.installed_version : void 0,
|
|
3471
|
+
probeVersion: enterprise && profile.meta ? async () => (await fetcher.json("/meta")).data.installed_version : void 0,
|
|
3410
3472
|
installations: credentials ? verb(true, createInstallationsApi(credentials)) : void 0,
|
|
3411
|
-
web:
|
|
3473
|
+
web: profile.web.links({
|
|
3412
3474
|
baseUrl,
|
|
3413
3475
|
instance
|
|
3414
3476
|
}),
|
|
@@ -3419,7 +3481,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3419
3481
|
json: {
|
|
3420
3482
|
name: "web",
|
|
3421
3483
|
active: input.active ?? true,
|
|
3422
|
-
events: nativeEventsFor(
|
|
3484
|
+
events: nativeEventsFor(profile.nativeEvents, input.events, input.nativeEvents),
|
|
3423
3485
|
config: hookConfig(input)
|
|
3424
3486
|
},
|
|
3425
3487
|
mapError: scopeIs404,
|
|
@@ -3429,7 +3491,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3429
3491
|
method: "PATCH",
|
|
3430
3492
|
json: {
|
|
3431
3493
|
...update.active === void 0 ? {} : { active: update.active },
|
|
3432
|
-
...update.events || update.nativeEvents ? { events: nativeEventsFor(
|
|
3494
|
+
...update.events || update.nativeEvents ? { events: nativeEventsFor(profile.nativeEvents, update.events, update.nativeEvents) } : {},
|
|
3433
3495
|
...update.url || update.secret || update.contentType ? { config: hookConfig(update) } : {}
|
|
3434
3496
|
},
|
|
3435
3497
|
mapError: scopeIs404,
|
|
@@ -3468,15 +3530,16 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3468
3530
|
});
|
|
3469
3531
|
})
|
|
3470
3532
|
},
|
|
3471
|
-
scopes:
|
|
3533
|
+
scopes: profile.scopes,
|
|
3472
3534
|
users: {
|
|
3473
|
-
get: verb(true, async (login, options) => toUser(
|
|
3474
|
-
me: verb(auth.type === "token" && !installation, async (options) => toUser(
|
|
3535
|
+
get: verb(true, async (login, options) => toUser(context, (await fetcher.json(`/users/${encodeURIComponent(login)}`, { signal: options?.signal })).data)),
|
|
3536
|
+
me: verb(auth.type === "token" && !installation, async (options) => toUser(context, (await fetcher.json("/user", { signal: options?.signal })).data)),
|
|
3475
3537
|
sponsorable: verb(!enterprise && !anonymous, async (login, options) => {
|
|
3476
3538
|
const data = await graphql("SPONSORABLE", { login }, options);
|
|
3477
3539
|
if (!data.repositoryOwner) throw new NotFoundError(`Account ${login} not found`, 404, "", context);
|
|
3478
3540
|
return data.repositoryOwner.hasSponsorsListing;
|
|
3479
3541
|
}),
|
|
3542
|
+
sponsorableMany: verb(!enterprise && !anonymous, sponsorableMany),
|
|
3480
3543
|
eventsPage: verb(true, (login, listOptions) => feedPage(`/users/${encodeURIComponent(login)}/events`, listOptions)),
|
|
3481
3544
|
blocking: verb(auth.type === "token" && !installation && (enterprise ? "unverified" : true), {
|
|
3482
3545
|
block: async (login, options) => {
|
|
@@ -3495,7 +3558,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3495
3558
|
},
|
|
3496
3559
|
repos: {
|
|
3497
3560
|
get: verb(true, async (ref, options) => {
|
|
3498
|
-
return toRepo(
|
|
3561
|
+
return toRepo(context, (await fetcher.json(repoPath(ref), { signal: options?.signal })).data);
|
|
3499
3562
|
}),
|
|
3500
3563
|
listPage: verb(!anonymous, (listOptions = {}) => installation ? reposPage(fetcher, "/installation/repositories", true, listOptions) : reposPage(fetcher, "/user/repos", false, listOptions)),
|
|
3501
3564
|
byOwnerPage: verb(true, ownerReposPage),
|
|
@@ -3514,8 +3577,8 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3514
3577
|
const { data } = await fetcher.json(`${repoPath(repo)}/issue-types`, { signal: options?.signal });
|
|
3515
3578
|
return data.map((raw) => toIssueType(raw));
|
|
3516
3579
|
}),
|
|
3517
|
-
collaboratorsPage: verb(!anonymous, (repo, listOptions = {}) => list(`${repoPath(repo)}/collaborators`, listOptions, (raw) => toCollaborator(
|
|
3518
|
-
contributorsPage: verb(true, (repo, listOptions = {}) => list(`${repoPath(repo)}/contributors`, listOptions, (raw) => toContributor(
|
|
3580
|
+
collaboratorsPage: verb(!anonymous, (repo, listOptions = {}) => list(`${repoPath(repo)}/collaborators`, listOptions, (raw) => toCollaborator(context, raw))),
|
|
3581
|
+
contributorsPage: verb(true, (repo, listOptions = {}) => list(`${repoPath(repo)}/contributors`, listOptions, (raw) => toContributor(context, raw), { query: listOptions.includeUnlinked ? { anon: 1 } : {} })),
|
|
3519
3582
|
contributorStats: verb(true, contributorStats),
|
|
3520
3583
|
templates: verb(true, templates),
|
|
3521
3584
|
permissionFor: verb(!anonymous, async (repo, actor, options) => {
|
|
@@ -3550,7 +3613,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3550
3613
|
signal: options?.signal
|
|
3551
3614
|
})).status === 201 ? "invited" : "added" };
|
|
3552
3615
|
}),
|
|
3553
|
-
assignableUsersPage: verb(true, (repo, listOptions = {}) => list(`${repoPath(repo)}/assignees`, listOptions, (raw) => toActor(
|
|
3616
|
+
assignableUsersPage: verb(true, (repo, listOptions = {}) => list(`${repoPath(repo)}/assignees`, listOptions, (raw) => toActor(context, raw))),
|
|
3554
3617
|
reviewerCandidatesPage: verb(!anonymous && "emulated", async (thread, listOptions = {}) => {
|
|
3555
3618
|
const ref = requireThread(thread, context);
|
|
3556
3619
|
const page = await fetcher.page(`${repoPath(ref.repo)}/collaborators`, {
|
|
@@ -3559,13 +3622,13 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3559
3622
|
signal: listOptions.signal
|
|
3560
3623
|
});
|
|
3561
3624
|
const author = page.notModified ? void 0 : (await get(ref, listOptions)).author?.login;
|
|
3562
|
-
return toPage(page, (raw) => raw.login === author ? void 0 : toActor(
|
|
3625
|
+
return toPage(page, (raw) => raw.login === author ? void 0 : toActor(context, raw));
|
|
3563
3626
|
}),
|
|
3564
3627
|
eventsPage: verb(true, (repo, listOptions) => feedPage(`${repoPath(repo)}/events`, listOptions))
|
|
3565
3628
|
},
|
|
3566
3629
|
orgs: {
|
|
3567
|
-
teamsPage: verb(!anonymous, (org, listOptions = {}) => list(`/orgs/${encodeURIComponent(org.owner)}/teams`, listOptions, (raw) => toTeam(
|
|
3568
|
-
teamMembersPage: verb(!anonymous, (team, listOptions = {}) => list(`/orgs/${encodeURIComponent(team.org.owner)}/teams/${encodeURIComponent(team.slug)}/members`, listOptions, (raw) => toActor(
|
|
3630
|
+
teamsPage: verb(!anonymous, (org, listOptions = {}) => list(`/orgs/${encodeURIComponent(org.owner)}/teams`, listOptions, (raw) => toTeam(context, teamOrg(org), raw))),
|
|
3631
|
+
teamMembersPage: verb(!anonymous, (team, listOptions = {}) => list(`/orgs/${encodeURIComponent(team.org.owner)}/teams/${encodeURIComponent(team.slug)}/members`, listOptions, (raw) => toActor(context, raw))),
|
|
3569
3632
|
blocking: verb(enterprise ? "unverified" : true, {
|
|
3570
3633
|
block: async (org, login, options) => {
|
|
3571
3634
|
await fetcher.raw(`/orgs/${encodeURIComponent(org.owner)}/blocks/${encodeURIComponent(login)}`, {
|
|
@@ -3628,13 +3691,13 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3628
3691
|
eventsPage: verb(true, async (thread, listOptions = {}) => {
|
|
3629
3692
|
const ref = requireThread(thread, context);
|
|
3630
3693
|
if (ref.kind === "discussion") {
|
|
3631
|
-
const [page, { toDiscussionCommentEvent }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-
|
|
3694
|
+
const [page, { toDiscussionCommentEvent }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-DxRA9BGO-BBbmTmWi.js")]);
|
|
3632
3695
|
return {
|
|
3633
3696
|
...page,
|
|
3634
3697
|
items: page.items.map(({ comment, isReply }) => toDiscussionCommentEvent(ref, comment, isReply))
|
|
3635
3698
|
};
|
|
3636
3699
|
}
|
|
3637
|
-
return list(`${repoPath(ref.repo)}/issues/${encodeURIComponent(ref.number)}/timeline`, listOptions, (entry) => toEvent(
|
|
3700
|
+
return list(`${repoPath(ref.repo)}/issues/${encodeURIComponent(ref.number)}/timeline`, listOptions, (entry) => toEvent(context, ref, entry));
|
|
3638
3701
|
}),
|
|
3639
3702
|
commentsPage: perKind({
|
|
3640
3703
|
issue: true,
|
|
@@ -3699,7 +3762,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3699
3762
|
id: await discussionId(ref, options),
|
|
3700
3763
|
body
|
|
3701
3764
|
}, options);
|
|
3702
|
-
return (await import("./graphql-
|
|
3765
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionComment(ref, data.addDiscussionComment.comment);
|
|
3703
3766
|
}
|
|
3704
3767
|
const { data } = await fetcher.json(`${repoPath(ref.repo)}/issues/${encodeURIComponent(ref.number)}/comments`, {
|
|
3705
3768
|
method: "POST",
|
|
@@ -3719,7 +3782,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3719
3782
|
id: ref.id,
|
|
3720
3783
|
body
|
|
3721
3784
|
}, options);
|
|
3722
|
-
return (await import("./graphql-
|
|
3785
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionComment(thread, data.updateDiscussionComment.comment);
|
|
3723
3786
|
}
|
|
3724
3787
|
const { data } = await fetcher.json(commentPath(ref), {
|
|
3725
3788
|
method: "PATCH",
|
|
@@ -3759,7 +3822,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3759
3822
|
signal: options?.signal
|
|
3760
3823
|
});
|
|
3761
3824
|
return toThread({
|
|
3762
|
-
forge:
|
|
3825
|
+
forge: context.forge,
|
|
3763
3826
|
instance,
|
|
3764
3827
|
repo,
|
|
3765
3828
|
kind: "issue",
|
|
@@ -3780,7 +3843,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3780
3843
|
signal: options?.signal
|
|
3781
3844
|
});
|
|
3782
3845
|
const ref = {
|
|
3783
|
-
forge:
|
|
3846
|
+
forge: context.forge,
|
|
3784
3847
|
instance,
|
|
3785
3848
|
repo,
|
|
3786
3849
|
kind: "pull_request",
|
|
@@ -3821,7 +3884,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3821
3884
|
title: input.title,
|
|
3822
3885
|
body: input.body
|
|
3823
3886
|
}, options);
|
|
3824
|
-
return (await import("./graphql-
|
|
3887
|
+
return (await import("./graphql-DxRA9BGO-BBbmTmWi.js")).toDiscussionThread(ref, data.updateDiscussion.discussion);
|
|
3825
3888
|
}
|
|
3826
3889
|
const target = requireIssueOrPull(ref, context, "update");
|
|
3827
3890
|
const json = {
|
|
@@ -3948,7 +4011,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3948
4011
|
repo: target.repository.id
|
|
3949
4012
|
}, options);
|
|
3950
4013
|
return {
|
|
3951
|
-
forge:
|
|
4014
|
+
forge: context.forge,
|
|
3952
4015
|
instance,
|
|
3953
4016
|
repo,
|
|
3954
4017
|
kind: "issue",
|
|
@@ -3977,7 +4040,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
3977
4040
|
issue: true,
|
|
3978
4041
|
pull_request: true
|
|
3979
4042
|
}, async (thread, assignees, options) => {
|
|
3980
|
-
return ((await issuePatch(thread, { assignees: assignees.map(actorLogin) }, "assign", options?.signal)).assignees ?? []).flatMap((user) => toActor(
|
|
4043
|
+
return ((await issuePatch(thread, { assignees: assignees.map(actorLogin) }, "assign", options?.signal)).assignees ?? []).flatMap((user) => toActor(context, user) ?? []);
|
|
3981
4044
|
}),
|
|
3982
4045
|
requestReview: perKind({ pull_request: true }, async (thread, reviewers, options) => {
|
|
3983
4046
|
const ref = requireThread(thread, context);
|
|
@@ -4017,31 +4080,50 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
|
|
|
4017
4080
|
})
|
|
4018
4081
|
}
|
|
4019
4082
|
};
|
|
4020
|
-
|
|
4083
|
+
const declared = profile.narrow ? profile.narrow(spec, ctx) : spec;
|
|
4084
|
+
return appItself ? supportOnly(declared, ["installations"]) : declared;
|
|
4085
|
+
}
|
|
4086
|
+
const GITHUB_PROFILE = {
|
|
4087
|
+
forge: "github",
|
|
4088
|
+
web: GITHUB_WEB,
|
|
4089
|
+
authKinds: [
|
|
4090
|
+
"token",
|
|
4091
|
+
"app",
|
|
4092
|
+
"anonymous"
|
|
4093
|
+
],
|
|
4094
|
+
nativeEvents: GITHUB_NATIVE_EVENTS,
|
|
4095
|
+
webhookEvents: GITHUB_WEBHOOK_EVENTS,
|
|
4096
|
+
graphql: true,
|
|
4097
|
+
checkRuns: true,
|
|
4098
|
+
releasesByTag: false,
|
|
4099
|
+
meta: true,
|
|
4100
|
+
scopes: githubScopesFor
|
|
4101
|
+
};
|
|
4102
|
+
function githubDefinition(profile) {
|
|
4103
|
+
return {
|
|
4104
|
+
forge: profile.forge,
|
|
4105
|
+
hasWeb: true,
|
|
4106
|
+
baseUrl: profile.web.baseUrl,
|
|
4107
|
+
apiPath: profile.web.apiPath,
|
|
4108
|
+
anonymous: true,
|
|
4109
|
+
instance: profile.web.instance,
|
|
4110
|
+
headers: {
|
|
4111
|
+
"accept": "application/vnd.github+json",
|
|
4112
|
+
"x-github-api-version": "2022-11-28"
|
|
4113
|
+
},
|
|
4114
|
+
prepare: ({ options, baseUrl, headers, state }) => options.auth?.type === "app" ? state ?? createAppCredentials(options.auth, {
|
|
4115
|
+
baseUrl,
|
|
4116
|
+
fetch: options.fetch,
|
|
4117
|
+
timeout: options.timeout,
|
|
4118
|
+
onRetry: options.onRetry,
|
|
4119
|
+
onRateLimit: options.onRateLimit,
|
|
4120
|
+
headers
|
|
4121
|
+
}) : void 0,
|
|
4122
|
+
authHeaders: ({ options, state }) => createAuthHeaders(options.auth, state),
|
|
4123
|
+
webhooks: githubWebhooks(profile.webhookEvents),
|
|
4124
|
+
setup: (ctx) => setupGitHub(ctx, profile)
|
|
4125
|
+
};
|
|
4021
4126
|
}
|
|
4022
|
-
/** Creates a GitHub provider for github.com or a GitHub Enterprise Server instance. */
|
|
4023
|
-
const github = /* @__PURE__ */ defineForgeProvider({
|
|
4024
|
-
forge: FORGE,
|
|
4025
|
-
hasWeb: true,
|
|
4026
|
-
baseUrl: "https://api.github.com",
|
|
4027
|
-
anonymous: true,
|
|
4028
|
-
instance: webHost,
|
|
4029
|
-
headers: {
|
|
4030
|
-
"accept": "application/vnd.github+json",
|
|
4031
|
-
"x-github-api-version": "2022-11-28"
|
|
4032
|
-
},
|
|
4033
|
-
prepare: ({ options, baseUrl, headers, state }) => options.auth?.type === "app" ? state ?? createAppCredentials(options.auth, {
|
|
4034
|
-
baseUrl,
|
|
4035
|
-
fetch: options.fetch,
|
|
4036
|
-
timeout: options.timeout,
|
|
4037
|
-
onRetry: options.onRetry,
|
|
4038
|
-
onRateLimit: options.onRateLimit,
|
|
4039
|
-
headers
|
|
4040
|
-
}) : void 0,
|
|
4041
|
-
authHeaders: ({ options, state }) => createAuthHeaders(options.auth, state),
|
|
4042
|
-
webhooks: githubWebhooks,
|
|
4043
|
-
setup: setupGitHub
|
|
4044
|
-
});
|
|
4045
4127
|
const PULL_CHECK_READS = /* @__PURE__ */ new Set([
|
|
4046
4128
|
"threads.get",
|
|
4047
4129
|
"threads.getMany",
|
|
@@ -4182,5 +4264,7 @@ function githubScopesFor(verb) {
|
|
|
4182
4264
|
};
|
|
4183
4265
|
return {};
|
|
4184
4266
|
}
|
|
4185
|
-
|
|
4186
|
-
|
|
4267
|
+
// ../../node_modules/.pnpm/forges@0.4.1/node_modules/forges/dist/github/index.mjs
|
|
4268
|
+
/** Creates a GitHub provider for github.com or a GitHub Enterprise Server instance. */
|
|
4269
|
+
const github = /* @__PURE__ */ defineForgeProvider(/* @__PURE__ */ githubDefinition(GITHUB_PROFILE));
|
|
4270
|
+
export { toThreadState as a, github, toRepoRef as i, toIssueType as n, toLabels as r, toActor as t };
|