@vite-hub/forge 0.1.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.
Files changed (29) hide show
  1. package/README.md +43 -7
  2. package/dist/{association-Cm0dUTDU-CDDhJnIh.js → association-Ds6Tgs0W-Cu9_YCGq.js} +1 -1
  3. package/dist/build/node.d.ts +12 -0
  4. package/dist/build/node.js +106 -0
  5. package/dist/build.d.ts +2 -0
  6. package/dist/build.js +2 -0
  7. package/dist/{events-saDWbqbf-VX_k8jtr.js → events-C6C7lk1x-J8VCAjEX.js} +4 -4
  8. package/dist/{events-DudKM7vq-Cj_PCDdt.js → events-DW3SFUDA-D2rhS9D-.js} +4 -4
  9. package/dist/{events-CeChclTf-CX-gD8oy.js → events-DjRw3KSr-C72gY7Vu.js} +4 -4
  10. package/dist/{events-CRaLy7U3-3PNNp5WZ.js → events-DmSWTdpS-BdJBABfI.js} +4 -4
  11. package/dist/{events-7EBoeIPd-A2RUkJi5.js → events-uCMi3LHU-Bz79PQtq.js} +4 -4
  12. package/dist/{feed-Dyf730Ys-D0HgBba6.js → feed-BlzdKdNv-DbxuSgsx.js} +4 -4
  13. package/dist/{feed-DsC7Vws1-M_de2nSK.js → feed-BwdcTgZq-Bm_c8br8.js} +4 -4
  14. package/dist/{feed-CmBoYS3Z-CuC4i0fH.js → feed-CIaAZINm-Dpe9DxwK.js} +4 -4
  15. package/dist/{forgejo-BN8ItCfl.js → forgejo-UNPc42cY.js} +50 -8
  16. package/dist/{gitee-DExkQP6X-BxJS2dRY.js → gitee-BXyl2_3W-dQOAjWqr.js} +2 -2
  17. package/dist/{github-DtncTfmv.js → github-CUiEF2FK.js} +65 -40
  18. package/dist/{gitlab-BoDm8-BC.js → gitlab-zvWb9zOi.js} +65 -8
  19. package/dist/{graphql-DG5aJBT3-DceyFYdM.js → graphql-BDhuP5jN-BSpB8lWf.js} +59 -7
  20. package/dist/identity-CNTWZZuv.d.ts +27 -0
  21. package/dist/identity-CmVEBLP5.js +38 -0
  22. package/dist/index.d.ts +332 -110
  23. package/dist/index.js +815 -313
  24. package/dist/{knot-BpyTK9D7-CVIsX4I2.js → knot-bGebBK_B-CeDHcJUz.js} +16 -9
  25. package/dist/{tangled-DPt_0u21-zS41xdG5.js → tangled-8lg_73Wi-bSufNXiN.js} +1 -1
  26. package/dist/{templates-Bn8a-pd2-D9DhJEVD.js → templates-BGDqQMu4-PSB43E1j.js} +2 -2
  27. package/dist/{utils-CA_4WJhJ-DNgT61X2.js → utils-DC7MBR65-B7Vr2hFm.js} +3 -306
  28. package/dist/{webhooks-DgHwxxYz-D1V2LOr1.js → webhooks-Bc6QhmI8-CNgCERCq.js} +326 -5
  29. package/package.json +19 -8
@@ -1,7 +1,7 @@
1
- import { $ as toDate, B as milestoneId, C as createListing, D as forgeIterable, F as latestCommentOf, G as requireIssueOrPull, H as rateLimitOf, J as sleep, K as requireThread, L as memo, M as isFirstPage, N as isSecondaryRateLimit, O as getManyConcurrently, P as iteratePages, Q as teamOrg, S as createFetcher, T as degradesToWarning, U as rateLimitPart, V as phased, W as rateLimitReset, X as summariseChecks, Y as soleMergeMethod, _t as reactionContent, a as ForgeApiError, at as versionAtLeast, b as anySignal, c as InsufficientScopeError, ct as REACTION_CONTENTS, d as NotFoundError, dt as isResolvedThread, et as toFileStatus, f as RateLimitedError, g as UnsupportedOperationError, i as ForbiddenError, it as toWarning, j as hostOf, l as MergeBlockedError, lt as githubShapedWeb, n as BranchMovedError, nt as toPage, o as ForgeError, p as ReadOnlyError, q as resolveToken, rt as toPullStats, s as ForgeTimeoutError, st as OWNER_NAME, t as AuthenticationRequiredError, tt as toMergeError, u as MergeConflictError, ut as isNamespaceRef, v as abortable, x as checkRunState, y as actorLogin } from "./utils-CA_4WJhJ-DNgT61X2.js";
2
- import { C as verb, E as signRs256Jwt, S as toFileContent, _ as reviewState, a as verifyHmacSignature, b as supportOnly, c as changeBase64, d as eventTime, f as existingFiles, g as perKind, h as isSha, l as defineForgeProvider, m as inDirectories, p as fromBase64, r as nativeEventsFor, s as WRITE_VERBS, t as eventKindsOf, y as splitMessage } from "./webhooks-DgHwxxYz-D1V2LOr1.js";
3
- import { t as toAuthorAssociation } from "./association-Cm0dUTDU-CDDhJnIh.js";
4
- //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/web-DTc-BDSX.mjs
1
+ import { $ as toDate, B as milestoneId, C as createListing, D as forgeIterable, F as latestCommentOf, G as requireIssueOrPull, H as rateLimitOf, J as sleep, K as requireThread, L as memo, M as isFirstPage, N as isSecondaryRateLimit, O as getManyConcurrently, P as iteratePages, Q as teamOrg, S as createFetcher, T as degradesToWarning, U as rateLimitPart, V as phased, W as rateLimitReset, X as summariseChecks, Y as soleMergeMethod, a as ForgeApiError, at as versionAtLeast, b as anySignal, c as InsufficientScopeError, ct as isNamespaceRef, d as NotFoundError, et as toFileStatus, f as RateLimitedError, g as UnsupportedOperationError, i as ForbiddenError, it as toWarning, j as hostOf, l as MergeBlockedError, lt as isResolvedThread, n as BranchMovedError, nt as toPage, o as ForgeError, p as ReadOnlyError, pt as reactionContent, q as resolveToken, rt as toPullStats, s as ForgeTimeoutError, st as REACTION_CONTENTS, t as AuthenticationRequiredError, tt as toMergeError, u as MergeConflictError, v as abortable, x as checkRunState, y as actorLogin } from "./utils-DC7MBR65-B7Vr2hFm.js";
2
+ import { C as verb, S as toFileContent, T as githubShapedWeb, _ as reviewState, a as verifyHmacSignature, b as supportOnly, c as changeBase64, d as eventTime, f as existingFiles, g as perKind, h as isSha, j as signRs256Jwt, l as defineForgeProvider, m as inDirectories, p as fromBase64, r as nativeEventsFor, s as WRITE_VERBS, t as eventKindsOf, w as OWNER_NAME, y as splitMessage } from "./webhooks-Bc6QhmI8-CNgCERCq.js";
3
+ import { t as toAuthorAssociation } from "./association-Ds6Tgs0W-Cu9_YCGq.js";
4
+ //#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/web-tS2yAE66.mjs
5
5
  const RESERVED_PATHS = [
6
6
  "about",
7
7
  "account",
@@ -79,7 +79,7 @@ const GITHUB_WEB = {
79
79
  }
80
80
  };
81
81
  //#endregion
82
- //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/github-Cd65-36w.mjs
82
+ //#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/github-B3p2LsXc.mjs
83
83
  const TOKEN_PREFIXES = [
84
84
  ["ghp_", "classic"],
85
85
  ["gho_", "classic"],
@@ -1511,7 +1511,7 @@ function graphqlOperations(document) {
1511
1511
  }
1512
1512
  function createGraphQLClient(fetcher, url, context) {
1513
1513
  return async (document, variables, options) => {
1514
- const query = typeof document === "string" ? (await import("./graphql-DG5aJBT3-DceyFYdM.js"))[document] : document.query;
1514
+ const query = typeof document === "string" ? (await import("./graphql-BDhuP5jN-BSpB8lWf.js"))[document] : document.query;
1515
1515
  const operationName = graphqlOperations(query)[0]?.name;
1516
1516
  const { data, response } = await fetcher.json(url, {
1517
1517
  method: "POST",
@@ -1536,7 +1536,7 @@ function verifyGitHubSignature(delivery, secret) {
1536
1536
  const githubWebhooks = ({ options, instance }) => ({
1537
1537
  events: GITHUB_WEBHOOK_EVENTS,
1538
1538
  verify: (delivery) => verifyGitHubSignature(delivery, options.webhookSecret),
1539
- translate: async (delivery) => (await import("./events-CeChclTf-CX-gD8oy.js")).translateGitHubWebhook(instance, delivery)
1539
+ translate: async (delivery) => (await import("./events-DjRw3KSr-C72gY7Vu.js")).translateGitHubWebhook(instance, delivery)
1540
1540
  });
1541
1541
  const DISCUSSION_CLOSE_REASONS = {
1542
1542
  completed: "resolved",
@@ -1662,7 +1662,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
1662
1662
  })).values()];
1663
1663
  let result;
1664
1664
  try {
1665
- const { query, variables } = (await import("./graphql-DG5aJBT3-DceyFYdM.js")).recentDiscussionsQuery(repos);
1665
+ const { query, variables } = (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).recentDiscussionsQuery(repos);
1666
1666
  result = await graphql({ query }, variables);
1667
1667
  } catch (error) {
1668
1668
  if (error instanceof InsufficientScopeError || error instanceof ForgeApiError && error.status === 200) return [toWarning("discussion_unresolved", error)];
@@ -1744,7 +1744,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
1744
1744
  number: Number(ref.number)
1745
1745
  }, options)).repository?.discussion;
1746
1746
  if (!discussion) throw new NotFoundError(`Discussion ${ref.number} not found`, 404, "", context);
1747
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionThread(ref, discussion);
1747
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionThread(ref, discussion);
1748
1748
  }
1749
1749
  async function discussionCommentPage(ref, listOptions) {
1750
1750
  const comments = (await graphql("DISCUSSION_COMMENTS", {
@@ -1825,7 +1825,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
1825
1825
  ref
1826
1826
  });
1827
1827
  if (!batchable.length) return results;
1828
- const g = await import("./graphql-DG5aJBT3-DceyFYdM.js");
1828
+ const g = await import("./graphql-BDhuP5jN-BSpB8lWf.js");
1829
1829
  for (let start = 0; start < batchable.length; start += GRAPHQL_BATCH) {
1830
1830
  const chunk = batchable.slice(start, start + GRAPHQL_BATCH);
1831
1831
  const { query, variables } = g.threadsBatchQuery(chunk.map((item) => item.ref));
@@ -1918,7 +1918,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
1918
1918
  field: query.sort === "created" || !query.sort ? "CREATED_AT" : "UPDATED_AT",
1919
1919
  direction: direction.toUpperCase()
1920
1920
  }, query);
1921
- const { toDiscussionThread } = await import("./graphql-DG5aJBT3-DceyFYdM.js");
1921
+ const { toDiscussionThread } = await import("./graphql-BDhuP5jN-BSpB8lWf.js");
1922
1922
  const discussions = data.repository?.discussions;
1923
1923
  return {
1924
1924
  items: (discussions?.nodes ?? []).map((node) => toDiscussionThread({
@@ -2029,7 +2029,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2029
2029
  async function commentsPage(thread, listOptions = {}) {
2030
2030
  const ref = requireThread(thread, context);
2031
2031
  if (ref.kind === "discussion") {
2032
- const [page, { toDiscussionComment }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-DG5aJBT3-DceyFYdM.js")]);
2032
+ const [page, { toDiscussionComment }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
2033
2033
  return {
2034
2034
  ...page,
2035
2035
  items: page.items.map(({ comment }) => toDiscussionComment(ref, comment))
@@ -2060,7 +2060,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2060
2060
  id,
2061
2061
  reason: reason?.toUpperCase() ?? null
2062
2062
  }, options_)).closeDiscussion : (await graphql("REOPEN_DISCUSSION", { id }, options_)).reopenDiscussion;
2063
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionThread(ref, data.discussion);
2063
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionThread(ref, data.discussion);
2064
2064
  }
2065
2065
  const reason = options_.reasonRaw ?? options_.reason;
2066
2066
  const { data } = await fetcher.json(threadPath(ref), {
@@ -2257,21 +2257,28 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2257
2257
  async function reviewThreadsByComment(ref, options) {
2258
2258
  const byComment = /* @__PURE__ */ new Map();
2259
2259
  if (anonymous) return byComment;
2260
- let data;
2261
- try {
2262
- data = await graphql("REVIEW_THREADS", {
2263
- owner: ref.repo.owner,
2264
- name: ref.repo.name,
2265
- number: Number(ref.number)
2266
- }, options);
2267
- } catch (error) {
2268
- if (error instanceof ForgeError) return byComment;
2269
- throw error;
2270
- }
2271
- for (const node of data.repository?.pullRequest?.reviewThreads.nodes ?? []) for (const comment of node.comments.nodes) if (comment.databaseId !== null) byComment.set(String(comment.databaseId), {
2272
- id: node.id,
2273
- resolved: node.isResolved
2274
- });
2260
+ let after = null;
2261
+ do {
2262
+ let data;
2263
+ try {
2264
+ data = await graphql("REVIEW_THREADS", {
2265
+ owner: ref.repo.owner,
2266
+ name: ref.repo.name,
2267
+ number: Number(ref.number),
2268
+ ...after ? { after } : {}
2269
+ }, options);
2270
+ } catch (error) {
2271
+ if (error instanceof ForgeError) return byComment;
2272
+ throw error;
2273
+ }
2274
+ const threads = data.repository?.pullRequest?.reviewThreads;
2275
+ for (const node of threads?.nodes ?? []) for (const comment of node.comments.nodes) if (comment.databaseId !== null) byComment.set(String(comment.databaseId), {
2276
+ id: node.id,
2277
+ resolved: node.isResolved
2278
+ });
2279
+ const next = threads?.pageInfo?.hasNextPage ? threads.pageInfo.endCursor : null;
2280
+ after = next !== after ? next : null;
2281
+ } while (after);
2275
2282
  return byComment;
2276
2283
  }
2277
2284
  /** Review comments and conversations read for a pull's first page of reviews, reused by its later pages. */
@@ -2299,6 +2306,23 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2299
2306
  if (result.cursor) reviewContext.set(key, kept);
2300
2307
  return toPage(result, (raw) => toReview(ref, raw, comments.filter((comment) => String(comment.pull_request_review_id ?? "") === String(raw.id)).map((comment) => toReviewComment(ref, comment, byComment.get(String(comment.id))))));
2301
2308
  }
2309
+ async function reviewThreadsPage(thread, listOptions = {}) {
2310
+ const ref = requirePull(thread, "read for review threads");
2311
+ const [data, { toReviewThread }] = await Promise.all([graphql("REVIEW_THREAD_PAGE", {
2312
+ owner: ref.repo.owner,
2313
+ name: ref.repo.name,
2314
+ number: Number(ref.number),
2315
+ first: Math.min(listOptions.perPage ?? 50, 100),
2316
+ after: listOptions.cursor?.token ?? null
2317
+ }, listOptions), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
2318
+ const pull = data.repository?.pullRequest;
2319
+ if (!pull) throw new NotFoundError(`Pull request ${ref.number} not found`, 404, "", context);
2320
+ const { nodes, pageInfo } = pull.reviewThreads;
2321
+ return {
2322
+ items: nodes.map((node) => toReviewThread(ref, node)),
2323
+ cursor: pageInfo.hasNextPage && pageInfo.endCursor ? { token: pageInfo.endCursor } : void 0
2324
+ };
2325
+ }
2302
2326
  async function createReview(thread, input, options) {
2303
2327
  const ref = requirePull(thread, "reviewed");
2304
2328
  const { data } = await fetcher.json(`${threadPath(ref)}/reviews`, {
@@ -2317,7 +2341,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2317
2341
  if (thread.kind === "discussion") {
2318
2342
  const data = await graphql("GET_DISCUSSION_COMMENT", { id: ref.id }, options);
2319
2343
  if (!data.node?.id) throw new NotFoundError(`Comment ${ref.id} not found`, 404, "", context);
2320
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionComment(thread, data.node);
2344
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionComment(thread, data.node);
2321
2345
  }
2322
2346
  const { data } = await fetcher.json(commentPath(ref), { signal: options?.signal });
2323
2347
  return toComment(thread, data);
@@ -2374,7 +2398,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2374
2398
  number: Number(ref.number),
2375
2399
  first: Math.min(listOptions.perPage ?? 50, 100),
2376
2400
  after: listOptions.cursor?.token ?? null
2377
- }, listOptions), import("./graphql-DG5aJBT3-DceyFYdM.js")]);
2401
+ }, listOptions), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
2378
2402
  const references = data.repository?.thread?.references;
2379
2403
  if (!references) throw new NotFoundError(`Thread ${ref.number} not found`, 404, "", context);
2380
2404
  return {
@@ -2696,7 +2720,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2696
2720
  signal: listOptions.signal
2697
2721
  });
2698
2722
  const poll = recordPoll(path, listOptions.cursor, result.response);
2699
- const { toFeedEvents } = await import("./events-CeChclTf-CX-gD8oy.js");
2723
+ const { toFeedEvents } = await import("./events-DjRw3KSr-C72gY7Vu.js");
2700
2724
  const page = toPage(result, (raw) => toFeedEvents(instance, raw));
2701
2725
  return {
2702
2726
  ...page,
@@ -2791,7 +2815,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2791
2815
  }
2792
2816
  async function templates(repo, options = {}) {
2793
2817
  const signal = options.signal;
2794
- return (await import("./templates-Bn8a-pd2-D9DhJEVD.js")).readTemplates(repo, options.kind ? [options.kind] : ["issue", "pull_request"], {
2818
+ return (await import("./templates-BGDqQMu4-PSB43E1j.js")).readTemplates(repo, options.kind ? [options.kind] : ["issue", "pull_request"], {
2795
2819
  list: async (ref, path) => {
2796
2820
  const { data } = await fetcher.json(`${repoPath(ref)}/contents${path ? `/${path.split("/").map(encodeURIComponent).join("/")}` : ""}`, { signal });
2797
2821
  return Array.isArray(data) ? data : [];
@@ -2913,7 +2937,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
2913
2937
  expectedHeadOid: head,
2914
2938
  message: splitMessage(input.message),
2915
2939
  fileChanges
2916
- } }, options), import("./graphql-DG5aJBT3-DceyFYdM.js")]);
2940
+ } }, options), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
2917
2941
  return toGraphQLCommit(repo, data.createCommitOnBranch.commit);
2918
2942
  } catch (error) {
2919
2943
  if (input.createFrom !== void 0) await swapBranch(repo, input.branch, head, ZERO_OID).catch(() => {});
@@ -3081,7 +3105,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3081
3105
  const [data, { toGraphQLActor, GRAPHQL_REACTIONS }] = await Promise.all([graphql("NODE_REACTIONS", {
3082
3106
  id,
3083
3107
  after: listOptions.cursor?.token ?? null
3084
- }, listOptions), import("./graphql-DG5aJBT3-DceyFYdM.js")]);
3108
+ }, listOptions), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
3085
3109
  const reactions = data.node?.reactions;
3086
3110
  return {
3087
3111
  items: (reactions?.nodes ?? []).flatMap((raw) => {
@@ -3119,7 +3143,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3119
3143
  if (thread.kind === "discussion") {
3120
3144
  await graphql("ADD_REACTION", {
3121
3145
  id: "thread" in target ? target.id : await nodeId(thread, options),
3122
- content: (await import("./graphql-DG5aJBT3-DceyFYdM.js")).REACTION_CONTENT[reaction]
3146
+ content: (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).REACTION_CONTENT[reaction]
3123
3147
  }, options);
3124
3148
  return;
3125
3149
  }
@@ -3134,7 +3158,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3134
3158
  if (thread.kind === "discussion") {
3135
3159
  await graphql("REMOVE_REACTION", {
3136
3160
  id: "thread" in target ? target.id : await nodeId(thread, options),
3137
- content: (await import("./graphql-DG5aJBT3-DceyFYdM.js")).REACTION_CONTENT[reaction]
3161
+ content: (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).REACTION_CONTENT[reaction]
3138
3162
  }, options);
3139
3163
  return;
3140
3164
  }
@@ -3604,7 +3628,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3604
3628
  eventsPage: verb(true, async (thread, listOptions = {}) => {
3605
3629
  const ref = requireThread(thread, context);
3606
3630
  if (ref.kind === "discussion") {
3607
- const [page, { toDiscussionCommentEvent }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-DG5aJBT3-DceyFYdM.js")]);
3631
+ const [page, { toDiscussionCommentEvent }] = await Promise.all([discussionCommentPage(ref, listOptions), import("./graphql-BDhuP5jN-BSpB8lWf.js")]);
3608
3632
  return {
3609
3633
  ...page,
3610
3634
  items: page.items.map(({ comment, isReply }) => toDiscussionCommentEvent(ref, comment, isReply))
@@ -3650,6 +3674,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3650
3674
  });
3651
3675
  return toReviewComment(pull, data, comment.thread);
3652
3676
  }),
3677
+ reviewThreadsPage: verb(!anonymous, reviewThreadsPage),
3653
3678
  reviewThreads: verb(true, {
3654
3679
  resolveReviewThread: async (_ref, id, options) => {
3655
3680
  await graphql("RESOLVE_REVIEW_THREAD", { id }, options);
@@ -3674,7 +3699,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3674
3699
  id: await discussionId(ref, options),
3675
3700
  body
3676
3701
  }, options);
3677
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionComment(ref, data.addDiscussionComment.comment);
3702
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionComment(ref, data.addDiscussionComment.comment);
3678
3703
  }
3679
3704
  const { data } = await fetcher.json(`${repoPath(ref.repo)}/issues/${encodeURIComponent(ref.number)}/comments`, {
3680
3705
  method: "POST",
@@ -3694,7 +3719,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3694
3719
  id: ref.id,
3695
3720
  body
3696
3721
  }, options);
3697
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionComment(thread, data.updateDiscussionComment.comment);
3722
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionComment(thread, data.updateDiscussionComment.comment);
3698
3723
  }
3699
3724
  const { data } = await fetcher.json(commentPath(ref), {
3700
3725
  method: "PATCH",
@@ -3796,7 +3821,7 @@ function setupGitHub({ options, baseUrl, instance, origin: context, fetcher, cre
3796
3821
  title: input.title,
3797
3822
  body: input.body
3798
3823
  }, options);
3799
- return (await import("./graphql-DG5aJBT3-DceyFYdM.js")).toDiscussionThread(ref, data.updateDiscussion.discussion);
3824
+ return (await import("./graphql-BDhuP5jN-BSpB8lWf.js")).toDiscussionThread(ref, data.updateDiscussion.discussion);
3800
3825
  }
3801
3826
  const target = requireIssueOrPull(ref, context, "update");
3802
3827
  const json = {
@@ -1,6 +1,6 @@
1
- import { $ as toDate, A as hexColour, B as milestoneId, C as createListing, E as firstPageEtag, G as requireIssueOrPull, I as mapConcurrent, K as requireThread, L as memo, M as isFirstPage, O as getManyConcurrently, P as iteratePages, Q as teamOrg, R as memoBy, T as degradesToWarning, U as rateLimitPart, V as phased, Y as soleMergeMethod, Z as syntheticReview, _t as reactionContent, a as ForgeApiError, at as versionAtLeast, c as InsufficientScopeError, d as NotFoundError, g as UnsupportedOperationError, gt as rangeOf, h as UnresolvedThreadError, i as ForbiddenError, it as toWarning, m as TokenRevokedError, n as BranchMovedError, nt as toPage, ot as withEtag, pt as lineOf, q as resolveToken, t as AuthenticationRequiredError, tt as toMergeError, ut as isNamespaceRef, xt as webUrlFor, z as mergeCommitMessage } from "./utils-CA_4WJhJ-DNgT61X2.js";
2
- import { C as verb, S as toFileContent, c as changeBase64, d as eventTime, f as existingFiles, g as perKind, l as defineForgeProvider, o as verifySharedToken, p as fromBase64, r as nativeEventsFor, s as WRITE_VERBS, t as eventKindsOf } from "./webhooks-DgHwxxYz-D1V2LOr1.js";
3
- //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/web-Zu3WSnnL.mjs
1
+ import { $ as toDate, A as hexColour, B as milestoneId, C as createListing, E as firstPageEtag, G as requireIssueOrPull, I as mapConcurrent, K as requireThread, L as memo, M as isFirstPage, O as getManyConcurrently, P as iteratePages, Q as teamOrg, R as memoBy, T as degradesToWarning, U as rateLimitPart, V as phased, Y as soleMergeMethod, Z as syntheticReview, a as ForgeApiError, at as versionAtLeast, c as InsufficientScopeError, ct as isNamespaceRef, d as NotFoundError, g as UnsupportedOperationError, h as UnresolvedThreadError, i as ForbiddenError, it as toWarning, m as TokenRevokedError, n as BranchMovedError, nt as toPage, ot as withEtag, pt as reactionContent, q as resolveToken, t as AuthenticationRequiredError, tt as toMergeError, z as mergeCommitMessage } from "./utils-DC7MBR65-B7Vr2hFm.js";
2
+ import { C as verb, D as rangeOf, E as lineOf, O as webUrlFor, S as toFileContent, c as changeBase64, d as eventTime, f as existingFiles, g as perKind, l as defineForgeProvider, o as verifySharedToken, p as fromBase64, r as nativeEventsFor, s as WRITE_VERBS, t as eventKindsOf } from "./webhooks-Bc6QhmI8-CNgCERCq.js";
3
+ //#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/web-tZM874Sy.mjs
4
4
  const SECTIONS = {
5
5
  issue: "work_items",
6
6
  pull_request: "merge_requests"
@@ -45,7 +45,7 @@ function gitlabWeb(baseUrl) {
45
45
  baseUrl,
46
46
  repo: (repo) => repo.kind === "namespace" ? `/${encode(repo.owner)}` : projectPath(repo),
47
47
  section: (repo, section) => repo.kind === "namespace" ? GROUP_PAGES[section] && `/groups/${encode(repo.owner)}/-/${GROUP_PAGES[section]}` : PAGES[section] && `${projectPath(repo)}/-/${PAGES[section]}`,
48
- thread: (ref) => ref.repo.kind === "namespace" || !SECTIONS[ref.kind] ? void 0 : `${projectPath(ref.repo)}/-/${SECTIONS[ref.kind]}/${encodeURIComponent(ref.number)}`,
48
+ thread: (ref) => ref.repo.kind === "namespace" || !SECTIONS[ref.kind] || !ref.number ? void 0 : `${projectPath(ref.repo)}/-/${SECTIONS[ref.kind]}/${encodeURIComponent(ref.number)}`,
49
49
  comment: (ref) => ref.thread.repo.kind === "namespace" || !SECTIONS[ref.thread.kind] ? void 0 : `${projectPath(ref.thread.repo)}/-/${SECTIONS[ref.thread.kind]}/${encodeURIComponent(ref.thread.number)}#note_${ref.id}`,
50
50
  commit: (repo, sha) => repo.kind === "namespace" ? void 0 : `${projectPath(repo)}/-/commit/${encodeURIComponent(sha)}`,
51
51
  release: (ref) => ref.tag ? `${projectPath(ref.repo)}/-/releases/${encodeURIComponent(ref.tag)}` : void 0,
@@ -127,7 +127,7 @@ function gitlabWeb(baseUrl) {
127
127
  reference: (ref, same, expand) => {
128
128
  if ("sha" in ref) return `${same ? "" : `${ref.repo.owner}/${ref.repo.name}@`}${ref.sha.slice(0, 8)}`;
129
129
  const prefix = PREFIXES[ref.kind];
130
- if (!prefix || ref.repo.kind === "namespace") return;
130
+ if (!prefix || ref.repo.kind === "namespace" || !ref.number) return;
131
131
  return `${same ? "" : `${ref.repo.owner}/${ref.repo.name}`}${prefix}${ref.number}${expand ? "+" : ""}`;
132
132
  },
133
133
  references: REFERENCES
@@ -140,7 +140,7 @@ const GITLAB_WEB = {
140
140
  links: ({ baseUrl }) => gitlabWeb(baseUrl.replace(/\/api\/v4$/, ""))
141
141
  };
142
142
  //#endregion
143
- //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/gitlab-BesCdl-6.mjs
143
+ //#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/gitlab-CoGcd7R7.mjs
144
144
  /**
145
145
  * GitLab subscribes per event with a boolean flag rather than an event name,
146
146
  * so the flag names are the native events.
@@ -704,6 +704,55 @@ function toNoteComment(thread, note, discussion) {
704
704
  raw: note
705
705
  };
706
706
  }
707
+ /** A line of a diff note: the new side where it has one, else the old side. */
708
+ function notedLine(position) {
709
+ if (typeof position?.new_line === "number") return {
710
+ line: position.new_line,
711
+ side: "right"
712
+ };
713
+ return typeof position?.old_line === "number" ? {
714
+ line: position.old_line,
715
+ side: "left"
716
+ } : {};
717
+ }
718
+ /** A resolvable discussion, read as a review conversation. GitLab doesn't say whether one is outdated. */
719
+ function toDiscussionThread(thread, discussion) {
720
+ const notes = discussion.notes.filter((note) => !note.system);
721
+ const position = notes.find((note) => note.position)?.position ?? void 0;
722
+ const path = position?.new_path ?? position?.old_path ?? void 0;
723
+ const { line, side } = notedLine(position);
724
+ const start = notedLine(position?.line_range?.start).line;
725
+ const resolved = notes.every((note) => !note.resolvable || Boolean(note.resolved));
726
+ return {
727
+ id: discussion.id,
728
+ resolved,
729
+ path,
730
+ line,
731
+ startLine: start !== void 0 && start !== line ? start : void 0,
732
+ side,
733
+ comments: notes.map((note) => ({
734
+ ref: {
735
+ forge: FORGE,
736
+ instance: thread.instance,
737
+ thread,
738
+ id: String(note.id)
739
+ },
740
+ body: note.body,
741
+ author: toActor(thread.instance, note.author),
742
+ ...note.position && {
743
+ path: note.position.new_path ?? note.position.old_path ?? void 0,
744
+ ...notedLine(note.position)
745
+ },
746
+ thread: {
747
+ id: discussion.id,
748
+ resolved
749
+ },
750
+ createdAt: toDate(note.created_at),
751
+ raw: note
752
+ })),
753
+ raw: discussion
754
+ };
755
+ }
707
756
  function toCommitComment(commit, comment) {
708
757
  return {
709
758
  ref: {
@@ -1035,7 +1084,7 @@ async function verifyGitLabToken(delivery, secret) {
1035
1084
  const gitlabWebhooks = ({ options, instance }) => ({
1036
1085
  events: GITLAB_WEBHOOK_EVENTS,
1037
1086
  verify: (delivery) => verifyGitLabToken(delivery, options.webhookSecret),
1038
- translate: async (delivery) => (await import("./events-7EBoeIPd-A2RUkJi5.js")).translateGitLabWebhook(instance, delivery)
1087
+ translate: async (delivery) => (await import("./events-uCMi3LHU-Bz79PQtq.js")).translateGitLabWebhook(instance, delivery)
1039
1088
  });
1040
1089
  const PROJECT_ORDER = {
1041
1090
  created: "created_at",
@@ -1597,7 +1646,7 @@ const gitlab = /* @__PURE__ */ defineForgeProvider({
1597
1646
  });
1598
1647
  const warnings = [];
1599
1648
  if (!repo) await resolveProjects([...new Set((result.data ?? []).flatMap((raw) => typeof raw.project_id === "number" ? [raw.project_id] : []))].filter((id) => !projectRefs.has(id)), listOptions.signal, warnings);
1600
- const { toFeedEvent } = await import("./feed-Dyf730Ys-D0HgBba6.js");
1649
+ const { toFeedEvent } = await import("./feed-BlzdKdNv-DbxuSgsx.js");
1601
1650
  return toPage(result, (raw) => toFeedEvent(instance, raw, repo ?? (typeof raw.project_id === "number" ? projectRefs.get(raw.project_id) : void 0)), warnings);
1602
1651
  }
1603
1652
  async function setSubscribed(thread, subscribed, options) {
@@ -2172,6 +2221,14 @@ const gitlab = /* @__PURE__ */ defineForgeProvider({
2172
2221
  }
2173
2222
  };
2174
2223
  }),
2224
+ reviewThreadsPage: verb(!anonymous, async (thread, listOptions = {}) => {
2225
+ const ref = requireMerge(thread, "read for review threads");
2226
+ const page = await list(`${threadPath(ref)}/discussions`, listOptions, (discussion) => discussion);
2227
+ return {
2228
+ ...page,
2229
+ items: page.items.filter((discussion) => discussion.notes.some((note) => note.resolvable)).map((discussion) => toDiscussionThread(ref, discussion))
2230
+ };
2231
+ }),
2175
2232
  reviewThreads: verb(true, {
2176
2233
  resolveReviewThread: (thread, id, options) => setDiscussionResolved(thread, id, true, options),
2177
2234
  unresolveReviewThread: (thread, id, options) => setDiscussionResolved(thread, id, false, options)
@@ -1,7 +1,7 @@
1
- import { $ as toDate, rt as toPullStats } from "./utils-CA_4WJhJ-DNgT61X2.js";
2
- import { d as eventTime } from "./webhooks-DgHwxxYz-D1V2LOr1.js";
3
- import { t as toAuthorAssociation } from "./association-Cm0dUTDU-CDDhJnIh.js";
4
- //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/graphql-DG5aJBT3.mjs
1
+ import { $ as toDate, rt as toPullStats } from "./utils-DC7MBR65-B7Vr2hFm.js";
2
+ import { d as eventTime } from "./webhooks-Bc6QhmI8-CNgCERCq.js";
3
+ import { t as toAuthorAssociation } from "./association-Ds6Tgs0W-Cu9_YCGq.js";
4
+ //#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/graphql-BDhuP5jN.mjs
5
5
  const FORGE = "github";
6
6
  const ACTOR_FIELDS = `__typename login avatarUrl url ... on User { databaseId name } ... on Bot { databaseId }`;
7
7
  const USER_FIELDS = `__typename login avatarUrl url databaseId name`;
@@ -455,15 +455,67 @@ const REACTION_CONTENT = {
455
455
  };
456
456
  /** The model's name for each GraphQL `ReactionContent` value. */
457
457
  const GRAPHQL_REACTIONS = Object.fromEntries(Object.entries(REACTION_CONTENT).map(([content, graphql]) => [graphql, content]));
458
- const REVIEW_THREADS = `query ReviewThreads($owner: String!, $name: String!, $number: Int!) {
458
+ const REVIEW_THREADS = `query ReviewThreads($owner: String!, $name: String!, $number: Int!, $after: String) {
459
459
  repository(owner: $owner, name: $name) {
460
460
  pullRequest(number: $number) {
461
- reviewThreads(first: 100) {
461
+ reviewThreads(first: 100, after: $after) {
462
+ pageInfo { hasNextPage endCursor }
462
463
  nodes { id isResolved comments(first: 100) { nodes { databaseId } } }
463
464
  }
464
465
  }
465
466
  }
466
467
  }`;
468
+ const REVIEW_THREAD_PAGE = `query ReviewThreadPage($owner: String!, $name: String!, $number: Int!, $first: Int!, $after: String) {
469
+ repository(owner: $owner, name: $name) {
470
+ pullRequest(number: $number) {
471
+ reviewThreads(first: $first, after: $after) {
472
+ pageInfo { hasNextPage endCursor }
473
+ nodes {
474
+ id isResolved isOutdated path line startLine originalLine originalStartLine diffSide
475
+ comments(first: 100) {
476
+ nodes { databaseId body path line originalLine createdAt url replyTo { databaseId } author { ${ACTOR_FIELDS} } }
477
+ }
478
+ }
479
+ }
480
+ }
481
+ }
482
+ }`;
483
+ /** An outdated conversation can lose its `line` on the current diff, so it falls back to the line its comments were written on. */
484
+ function toReviewThread(ref, raw) {
485
+ const side = raw.diffSide === "LEFT" ? "left" : raw.diffSide === "RIGHT" ? "right" : void 0;
486
+ const thread = {
487
+ id: raw.id,
488
+ resolved: raw.isResolved
489
+ };
490
+ return {
491
+ id: raw.id,
492
+ resolved: raw.isResolved,
493
+ outdated: raw.isOutdated,
494
+ path: raw.path ?? void 0,
495
+ line: raw.line ?? raw.originalLine ?? void 0,
496
+ startLine: raw.startLine ?? raw.originalStartLine ?? void 0,
497
+ side,
498
+ comments: raw.comments.nodes.map((comment) => ({
499
+ ...comment.databaseId === null ? {} : { ref: {
500
+ forge: FORGE,
501
+ instance: ref.instance,
502
+ thread: ref,
503
+ id: String(comment.databaseId)
504
+ } },
505
+ body: comment.body ?? "",
506
+ author: toGraphQLActor(ref.instance, comment.author),
507
+ path: comment.path ?? void 0,
508
+ line: comment.line ?? comment.originalLine ?? void 0,
509
+ side,
510
+ inReplyTo: typeof comment.replyTo?.databaseId === "number" ? String(comment.replyTo.databaseId) : void 0,
511
+ thread,
512
+ createdAt: toDate(comment.createdAt),
513
+ url: comment.url,
514
+ raw: comment
515
+ })),
516
+ raw
517
+ };
518
+ }
467
519
  const RESOLVE_REVIEW_THREAD = `mutation ResolveReviewThread($id: ID!) {
468
520
  resolveReviewThread(input: { threadId: $id }) { thread { isResolved } }
469
521
  }`;
@@ -486,4 +538,4 @@ const UPDATE_PULL_REQUEST_BRANCH = `mutation UpdatePullRequestBranch($id: ID!, $
486
538
  updatePullRequestBranch(input: { pullRequestId: $id, expectedHeadOid: $sha, updateMethod: $method }) { pullRequest { headRefOid } }
487
539
  }`;
488
540
  //#endregion
489
- export { ADD_DISCUSSION_COMMENT, ADD_REACTION, CLOSE_DISCUSSION, CLOSING_ISSUES, CLOSING_PULL_REQUESTS, CREATE_COMMIT_ON_BRANCH, DELETE_DISCUSSION_COMMENT, DISCUSSIONS_LIST, DISCUSSION_COMMENTS, DISCUSSION_THREAD, GET_DISCUSSION_COMMENT, GRAPHQL_REACTIONS, LOCK_LOCKABLE, MARK_DUPLICATE, MINIMIZE_COMMENT, NODE_REACTIONS, REACTION_CONTENT, REMOVE_REACTION, REOPEN_DISCUSSION, REPOSITORY_ID, RESOLVE_REVIEW_THREAD, REVIEW_THREADS, SPONSORABLE, SUBSCRIPTION_STATE, TRANSFER_ISSUE, UNLOCK_LOCKABLE, UNMINIMIZE_COMMENT, UNRESOLVE_REVIEW_THREAD, UPDATE_DISCUSSION, UPDATE_DISCUSSION_COMMENT, UPDATE_PULL_REQUEST_BRANCH, UPDATE_REFS, UPDATE_SUBSCRIPTION, recentDiscussionsQuery, threadsBatchQuery, toDiscussionComment, toDiscussionCommentEvent, toDiscussionThread, toGraphQLActor, toGraphQLCommit, toGraphQLMilestone, toGraphQLThread, toViewerSubscription };
541
+ export { ADD_DISCUSSION_COMMENT, ADD_REACTION, CLOSE_DISCUSSION, CLOSING_ISSUES, CLOSING_PULL_REQUESTS, CREATE_COMMIT_ON_BRANCH, DELETE_DISCUSSION_COMMENT, DISCUSSIONS_LIST, DISCUSSION_COMMENTS, DISCUSSION_THREAD, GET_DISCUSSION_COMMENT, GRAPHQL_REACTIONS, LOCK_LOCKABLE, MARK_DUPLICATE, MINIMIZE_COMMENT, NODE_REACTIONS, REACTION_CONTENT, REMOVE_REACTION, REOPEN_DISCUSSION, REPOSITORY_ID, RESOLVE_REVIEW_THREAD, REVIEW_THREADS, REVIEW_THREAD_PAGE, SPONSORABLE, SUBSCRIPTION_STATE, TRANSFER_ISSUE, UNLOCK_LOCKABLE, UNMINIMIZE_COMMENT, UNRESOLVE_REVIEW_THREAD, UPDATE_DISCUSSION, UPDATE_DISCUSSION_COMMENT, UPDATE_PULL_REQUEST_BRANCH, UPDATE_REFS, UPDATE_SUBSCRIPTION, recentDiscussionsQuery, threadsBatchQuery, toDiscussionComment, toDiscussionCommentEvent, toDiscussionThread, toGraphQLActor, toGraphQLCommit, toGraphQLMilestone, toGraphQLThread, toReviewThread, toViewerSubscription };
@@ -0,0 +1,27 @@
1
+ //#region src/build/identity.d.ts
2
+ /** The build of an app: the commit and branch, the GitHub repository, and the pull request when the host names it. */
3
+ interface ForgeBuild {
4
+ commit?: string;
5
+ branch?: string;
6
+ /** The GitHub repository, as `owner/name`. */
7
+ repository?: string;
8
+ /** The pull request that the build previews, when the host names it. Never trust it to grant access. */
9
+ pullRequest?: number;
10
+ }
11
+ /** The repository and commit a page says it was built from. A claim, not a proof: check it against the Forge. */
12
+ interface BuildIdentity {
13
+ /** `owner/name`. */
14
+ repository: string;
15
+ /** The full commit SHA, lowercase. */
16
+ commit: string;
17
+ }
18
+ /** The `name` of the `<meta>` tag that holds a page's {@link BuildIdentity}. */
19
+ declare const buildMetaName = "vitehub:build";
20
+ /** The identity of a build, when it has a valid repository and a full commit SHA. */
21
+ declare function buildIdentity(build: ForgeBuild): BuildIdentity | undefined;
22
+ /** The `content` of the `vitehub:build` meta tag, or `undefined` when the build has no identity. */
23
+ declare function buildMetaContent(build: ForgeBuild): string | undefined;
24
+ /** The identity in a `vitehub:build` meta tag's `content`, or `undefined` when it is missing or malformed. */
25
+ declare function parseBuildMeta(content: string | null | undefined): BuildIdentity | undefined;
26
+ //#endregion
27
+ export { buildMetaName as a, buildMetaContent as i, ForgeBuild as n, parseBuildMeta as o, buildIdentity as r, BuildIdentity as t };
@@ -0,0 +1,38 @@
1
+ //#region src/build/identity.ts
2
+ /** The `name` of the `<meta>` tag that holds a page's {@link BuildIdentity}. */
3
+ const buildMetaName = "vitehub:build";
4
+ const repositoryPattern = /^[\w.-]+\/[\w.-]+$/;
5
+ const commitPattern = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
6
+ /** The identity of a build, when it has a valid repository and a full commit SHA. */
7
+ function buildIdentity(build) {
8
+ const repository = build.repository?.trim();
9
+ const commit = build.commit?.trim().toLowerCase();
10
+ if (!repository || !repositoryPattern.test(repository) || !commit || !commitPattern.test(commit)) return void 0;
11
+ return {
12
+ repository,
13
+ commit
14
+ };
15
+ }
16
+ /** The `content` of the `vitehub:build` meta tag, or `undefined` when the build has no identity. */
17
+ function buildMetaContent(build) {
18
+ const identity = buildIdentity(build);
19
+ return identity ? JSON.stringify(identity) : void 0;
20
+ }
21
+ /** The identity in a `vitehub:build` meta tag's `content`, or `undefined` when it is missing or malformed. */
22
+ function parseBuildMeta(content) {
23
+ if (!content) return void 0;
24
+ let value;
25
+ try {
26
+ value = JSON.parse(content);
27
+ } catch {
28
+ return;
29
+ }
30
+ if (!value || typeof value !== "object") return void 0;
31
+ const { repository, commit } = value;
32
+ return typeof repository === "string" && typeof commit === "string" ? buildIdentity({
33
+ repository,
34
+ commit
35
+ }) : void 0;
36
+ }
37
+ //#endregion
38
+ export { parseBuildMeta as i, buildMetaContent as n, buildMetaName as r, buildIdentity as t };