forges 0.0.0 → 0.1.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 (152) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +72 -0
  3. package/dist/azure-devops/index.d.mts +2 -0
  4. package/dist/azure-devops/index.mjs +1 -0
  5. package/dist/azure-devops-DwQvL4TV.mjs +1355 -0
  6. package/dist/bitbucket/index.d.mts +2 -0
  7. package/dist/bitbucket/index.mjs +1 -0
  8. package/dist/bitbucket-CpcfJlYi.mjs +1171 -0
  9. package/dist/crypto-CQNEyYHD.mjs +156 -0
  10. package/dist/cursor-origin/index.d.mts +2 -0
  11. package/dist/cursor-origin/index.mjs +1 -0
  12. package/dist/cursor-origin-BhqYx2oW.mjs +980 -0
  13. package/dist/define-B2_4ob2i.d.mts +307 -0
  14. package/dist/define-D3yEXtKK.mjs +2276 -0
  15. package/dist/env.d.mts +46 -0
  16. package/dist/env.mjs +283 -0
  17. package/dist/fake/index.d.mts +227 -0
  18. package/dist/fake/index.mjs +1001 -0
  19. package/dist/fetch-D4pSRvvA.d.mts +1723 -0
  20. package/dist/forgejo/index.d.mts +2 -0
  21. package/dist/forgejo/index.mjs +1 -0
  22. package/dist/forgejo-BCefbHUN.mjs +2005 -0
  23. package/dist/gitea/index.d.mts +2 -0
  24. package/dist/gitea/index.mjs +22 -0
  25. package/dist/gitee/index.d.mts +2 -0
  26. package/dist/gitee/index.mjs +1 -0
  27. package/dist/gitee-CA-f7Rs8.mjs +1272 -0
  28. package/dist/github/index.d.mts +2 -0
  29. package/dist/github/index.mjs +1 -0
  30. package/dist/github-B0umL8_f.mjs +3259 -0
  31. package/dist/gitlab/index.d.mts +2 -0
  32. package/dist/gitlab/index.mjs +1 -0
  33. package/dist/gitlab-Bsr__Z0C.mjs +2378 -0
  34. package/dist/graphql-D7uGzZTf.mjs +366 -0
  35. package/dist/index-BQ6VS31s.d.mts +32 -0
  36. package/dist/index-C-jz9Mo3.d.mts +16 -0
  37. package/dist/index-C4fYzmK3.d.mts +102 -0
  38. package/dist/index-CQiIX4SH.d.mts +27 -0
  39. package/dist/index-CTj5gQzl.d.mts +35 -0
  40. package/dist/index-CliBWzOF.d.mts +23 -0
  41. package/dist/index-Cz_y-t3d.d.mts +36 -0
  42. package/dist/index-DEt25E1w.d.mts +77 -0
  43. package/dist/index-DIuS0EOy.d.mts +43 -0
  44. package/dist/index-uSpsMCrC.d.mts +26 -0
  45. package/dist/index.d.mts +41 -0
  46. package/dist/index.mjs +13 -0
  47. package/dist/kit.d.mts +183 -0
  48. package/dist/kit.mjs +4 -0
  49. package/dist/provider-CoZ7cCxp.d.mts +1439 -0
  50. package/dist/provider-Ed1YhkQN.mjs +169 -0
  51. package/dist/pushin/index.d.mts +2 -0
  52. package/dist/pushin/index.mjs +1 -0
  53. package/dist/pushin-CkxgJ2cU.mjs +343 -0
  54. package/dist/schema/Actor.json +96 -0
  55. package/dist/schema/AlertSupport.json +49 -0
  56. package/dist/schema/AuthKind.json +15 -0
  57. package/dist/schema/Branch.json +31 -0
  58. package/dist/schema/ChangedFile.json +58 -0
  59. package/dist/schema/Check.json +169 -0
  60. package/dist/schema/CheckRef.json +114 -0
  61. package/dist/schema/CheckState.json +14 -0
  62. package/dist/schema/ChecksSummary.json +34 -0
  63. package/dist/schema/CiJob.json +186 -0
  64. package/dist/schema/CiJobRef.json +132 -0
  65. package/dist/schema/CiRun.json +234 -0
  66. package/dist/schema/CiRunRef.json +103 -0
  67. package/dist/schema/CodeFragment.json +19 -0
  68. package/dist/schema/CodeMatch.json +128 -0
  69. package/dist/schema/Collaborator.json +169 -0
  70. package/dist/schema/Comment.json +336 -0
  71. package/dist/schema/CommentRef.json +158 -0
  72. package/dist/schema/Commit.json +307 -0
  73. package/dist/schema/CommitRef.json +104 -0
  74. package/dist/schema/CommitSignature.json +118 -0
  75. package/dist/schema/Comparison.json +355 -0
  76. package/dist/schema/Cursor.json +21 -0
  77. package/dist/schema/EventAction.json +33 -0
  78. package/dist/schema/EventDetail.json +649 -0
  79. package/dist/schema/EventKind.json +26 -0
  80. package/dist/schema/FileContent.json +73 -0
  81. package/dist/schema/FileStatus.json +15 -0
  82. package/dist/schema/ForgeCapabilities.json +737 -0
  83. package/dist/schema/ForgeEvent.json +789 -0
  84. package/dist/schema/ForgeInstance.json +7 -0
  85. package/dist/schema/ForgeKind.json +32 -0
  86. package/dist/schema/ForgeWarning.json +49 -0
  87. package/dist/schema/ForgeWarningCode.json +7 -0
  88. package/dist/schema/GetManyResult.json +699 -0
  89. package/dist/schema/Installation.json +131 -0
  90. package/dist/schema/InstallationToken.json +31 -0
  91. package/dist/schema/KnownForgeKind.json +19 -0
  92. package/dist/schema/Label.json +22 -0
  93. package/dist/schema/MergeMethod.json +14 -0
  94. package/dist/schema/Milestone.json +40 -0
  95. package/dist/schema/Notification.json +498 -0
  96. package/dist/schema/NotificationReason.json +28 -0
  97. package/dist/schema/NotificationRef.json +60 -0
  98. package/dist/schema/NotificationSubject.json +376 -0
  99. package/dist/schema/PerKind.json +49 -0
  100. package/dist/schema/PullBranches.json +125 -0
  101. package/dist/schema/PushCommit.json +24 -0
  102. package/dist/schema/Reaction.json +148 -0
  103. package/dist/schema/ReactionContent.json +17 -0
  104. package/dist/schema/ReactionSummary.json +70 -0
  105. package/dist/schema/Release.json +286 -0
  106. package/dist/schema/ReleaseAsset.json +169 -0
  107. package/dist/schema/ReleaseAssetRef.json +138 -0
  108. package/dist/schema/ReleaseRef.json +107 -0
  109. package/dist/schema/Repo.json +354 -0
  110. package/dist/schema/RepoFeatures.json +35 -0
  111. package/dist/schema/RepoPermissions.json +35 -0
  112. package/dist/schema/RepoRef.json +77 -0
  113. package/dist/schema/RepoRole.json +15 -0
  114. package/dist/schema/RepoVisibility.json +12 -0
  115. package/dist/schema/Review.json +371 -0
  116. package/dist/schema/ReviewComment.json +280 -0
  117. package/dist/schema/ReviewCommentInput.json +34 -0
  118. package/dist/schema/ReviewRef.json +158 -0
  119. package/dist/schema/ReviewState.json +15 -0
  120. package/dist/schema/Reviewer.json +133 -0
  121. package/dist/schema/SecurityAlert.json +219 -0
  122. package/dist/schema/SecurityAlertKind.json +14 -0
  123. package/dist/schema/SecurityAlertRef.json +122 -0
  124. package/dist/schema/SecuritySeverity.json +14 -0
  125. package/dist/schema/SourceKind.json +12 -0
  126. package/dist/schema/SubscriptionState.json +12 -0
  127. package/dist/schema/Support.json +23 -0
  128. package/dist/schema/Tag.json +25 -0
  129. package/dist/schema/TextLimits.json +18 -0
  130. package/dist/schema/Thread.json +653 -0
  131. package/dist/schema/ThreadKind.json +14 -0
  132. package/dist/schema/ThreadRef.json +131 -0
  133. package/dist/schema/ThreadStack.json +146 -0
  134. package/dist/schema/ThreadState.json +13 -0
  135. package/dist/schema/TreeEntry.json +46 -0
  136. package/dist/schema/TreeEntryType.json +13 -0
  137. package/dist/schema/UpsertCommentResult.json +355 -0
  138. package/dist/schema/User.json +123 -0
  139. package/dist/schema/Webhook.json +188 -0
  140. package/dist/schema/WebhookDeliveryRecord.json +173 -0
  141. package/dist/schema/WebhookDeliveryRef.json +135 -0
  142. package/dist/schema/WebhookRef.json +105 -0
  143. package/dist/schema/index.d.mts +4 -0
  144. package/dist/schema/index.mjs +3219 -0
  145. package/dist/tangled/index.d.mts +2 -0
  146. package/dist/tangled/index.mjs +1 -0
  147. package/dist/tangled-ChdPmiv-.mjs +1570 -0
  148. package/dist/testing/index.d.mts +123 -0
  149. package/dist/testing/index.mjs +242 -0
  150. package/dist/webhooks-rn9-8lxT.mjs +70 -0
  151. package/package.json +115 -3
  152. package/dist/.gitkeep +0 -0
@@ -0,0 +1,366 @@
1
+ import { O as toDate } from "./define-D3yEXtKK.mjs";
2
+ import { i as FORGE } from "./github-B0umL8_f.mjs";
3
+ //#region src/github/graphql.ts
4
+ const ACTOR_FIELDS = `__typename login avatarUrl url ... on User { databaseId name } ... on Bot { databaseId }`;
5
+ const USER_FIELDS = `__typename login avatarUrl url databaseId name`;
6
+ const DISCUSSION_FIELDS = `id number title body closed stateReason url createdAt updatedAt closedAt locked
7
+ author { ${ACTOR_FIELDS} }
8
+ labels(first: 50) { nodes { name color description } }
9
+ comments { totalCount }`;
10
+ const DISCUSSION_THREAD = `query DiscussionThread($owner: String!, $name: String!, $number: Int!) {
11
+ repository(owner: $owner, name: $name) {
12
+ discussion(number: $number) {
13
+ ${DISCUSSION_FIELDS}
14
+ }
15
+ }
16
+ }`;
17
+ const DISCUSSIONS_LIST = `query DiscussionsList($owner: String!, $name: String!, $first: Int!, $after: String, $field: DiscussionOrderField!, $direction: OrderDirection!) {
18
+ repository(owner: $owner, name: $name) {
19
+ discussions(first: $first, after: $after, orderBy: { field: $field, direction: $direction }) {
20
+ pageInfo { hasNextPage endCursor }
21
+ nodes {
22
+ ${DISCUSSION_FIELDS}
23
+ }
24
+ }
25
+ }
26
+ }`;
27
+ const UPDATE_DISCUSSION = `mutation UpdateDiscussion($id: ID!, $title: String, $body: String) {
28
+ updateDiscussion(input: { discussionId: $id, title: $title, body: $body }) { discussion { ${DISCUSSION_FIELDS} } }
29
+ }`;
30
+ const COMMENT_FIELDS = `id databaseId body createdAt updatedAt url author { ${ACTOR_FIELDS} }`;
31
+ const UPDATE_DISCUSSION_COMMENT = `mutation UpdateDiscussionComment($id: ID!, $body: String!) {
32
+ updateDiscussionComment(input: { commentId: $id, body: $body }) { comment { ${COMMENT_FIELDS} } }
33
+ }`;
34
+ const DELETE_DISCUSSION_COMMENT = `mutation DeleteDiscussionComment($id: ID!) {
35
+ deleteDiscussionComment(input: { id: $id }) { comment { id } }
36
+ }`;
37
+ const SUBSCRIPTION_STATE = `query SubscriptionState($owner: String!, $name: String!, $number: Int!, $discussion: Boolean!) {
38
+ repository(owner: $owner, name: $name) {
39
+ issueOrPullRequest(number: $number) @skip(if: $discussion) {
40
+ ... on Issue { id viewerSubscription }
41
+ ... on PullRequest { id viewerSubscription }
42
+ }
43
+ discussion(number: $number) @include(if: $discussion) { id viewerSubscription }
44
+ }
45
+ }`;
46
+ const UPDATE_SUBSCRIPTION = `mutation UpdateSubscription($id: ID!, $state: SubscriptionState!) {
47
+ updateSubscription(input: { subscribableId: $id, state: $state }) { subscribable { viewerSubscription } }
48
+ }`;
49
+ const ISSUE_FIELDS = `id number title body state stateReason createdAt updatedAt closedAt url locked
50
+ author { ${ACTOR_FIELDS} }
51
+ assignees(first: 20) { nodes { ${USER_FIELDS} } }
52
+ labels(first: 50) { nodes { name color description } }
53
+ comments { totalCount }
54
+ participants(first: 20) { nodes { ${USER_FIELDS} } }
55
+ milestone { number title state description dueOn url }
56
+ viewerSubscription`;
57
+ const PULL_FIELDS = `id number title body state isDraft createdAt updatedAt closedAt mergedAt url locked
58
+ author { ${ACTOR_FIELDS} }
59
+ assignees(first: 20) { nodes { ${USER_FIELDS} } }
60
+ labels(first: 50) { nodes { name color description } }
61
+ comments { totalCount }
62
+ participants(first: 20) { nodes { ${USER_FIELDS} } }
63
+ milestone { number title state description dueOn url }
64
+ viewerSubscription
65
+ headRefName headRefOid baseRefName baseRefOid
66
+ headRepository { databaseId name owner { login } }
67
+ mergeCommit { oid }
68
+ commits(last: 1) { nodes { commit { statusCheckRollup { state contexts { totalCount checkRunCountsByState { state count } statusContextCountsByState { state count } } } } } }
69
+ reviewRequests(first: 20) { nodes { requestedReviewer { __typename ... on User { login databaseId avatarUrl url } ... on Bot { login databaseId avatarUrl url } ... on Team { slug databaseId name url } } } }`;
70
+ /** One aliased query reading many issues, pull requests and discussions. */
71
+ function threadsBatchQuery(refs) {
72
+ const variables = {};
73
+ const declarations = [];
74
+ const fields = refs.map((ref, index) => {
75
+ variables[`o${index}`] = ref.repo.owner;
76
+ variables[`n${index}`] = ref.repo.name;
77
+ variables[`k${index}`] = Number(ref.number);
78
+ declarations.push(`$o${index}: String!`, `$n${index}: String!`, `$k${index}: Int!`);
79
+ return `t${index}: repository(owner: $o${index}, name: $n${index}) { ${ref.kind === "discussion" ? `discussion(number: $k${index}) { ${DISCUSSION_FIELDS} }` : `issueOrPullRequest(number: $k${index}) { __typename ... on Issue { ${ISSUE_FIELDS} } ... on PullRequest { ${PULL_FIELDS} } }`} }`;
80
+ });
81
+ return {
82
+ query: `query ThreadsBatch(${declarations.join(", ")}) {\n ${fields.join("\n ")}\n}`,
83
+ variables
84
+ };
85
+ }
86
+ /** A GraphQL milestone as the model holds it. */
87
+ function toGraphQLMilestone(raw) {
88
+ return raw ? {
89
+ id: String(raw.number),
90
+ title: raw.title,
91
+ state: raw.state === "CLOSED" ? "closed" : "open",
92
+ description: raw.description ?? void 0,
93
+ dueOn: toDate(raw.dueOn),
94
+ url: raw.url,
95
+ raw
96
+ } : void 0;
97
+ }
98
+ function toViewerSubscription(value) {
99
+ return value === "SUBSCRIBED" ? "subscribed" : value === "IGNORED" ? "ignored" : value === "UNSUBSCRIBED" ? "none" : void 0;
100
+ }
101
+ const FAILED_RUNS = /* @__PURE__ */ new Set([
102
+ "FAILURE",
103
+ "TIMED_OUT",
104
+ "CANCELLED",
105
+ "ACTION_REQUIRED",
106
+ "STARTUP_FAILURE"
107
+ ]);
108
+ const FAILED_STATUSES = /* @__PURE__ */ new Set(["FAILURE", "ERROR"]);
109
+ function toRollupSummary(rollup, url) {
110
+ const failed = (rollup.contexts.checkRunCountsByState ?? []).filter(({ state }) => FAILED_RUNS.has(state)).reduce((sum, { count }) => sum + count, 0) + (rollup.contexts.statusContextCountsByState ?? []).filter(({ state }) => FAILED_STATUSES.has(state)).reduce((sum, { count }) => sum + count, 0);
111
+ return {
112
+ state: rollup.state === "SUCCESS" ? "success" : rollup.state === "FAILURE" || rollup.state === "ERROR" ? "failure" : rollup.state === "PENDING" || rollup.state === "EXPECTED" ? "pending" : "unknown",
113
+ stateRaw: rollup.state.toLowerCase(),
114
+ total: rollup.contexts.totalCount,
115
+ failed,
116
+ ...url ? { url: `${url}/checks` } : {}
117
+ };
118
+ }
119
+ function toGraphQLThread(ref, raw) {
120
+ const instance = ref.instance;
121
+ const isPull = raw.__typename === "PullRequest";
122
+ const kind = isPull ? "pull_request" : "issue";
123
+ const state = raw.state === "MERGED" ? "merged" : raw.state === "OPEN" ? "open" : raw.state === "CLOSED" ? "closed" : "unknown";
124
+ const reviewers = (raw.reviewRequests?.nodes ?? []).flatMap(({ requestedReviewer: reviewer }) => {
125
+ if (!reviewer) return [];
126
+ const isTeam = reviewer.__typename === "Team";
127
+ return [{
128
+ actor: isTeam ? {
129
+ forge: FORGE,
130
+ instance,
131
+ login: reviewer.slug ?? "",
132
+ id: String(reviewer.databaseId ?? reviewer.slug),
133
+ name: reviewer.name,
134
+ url: reviewer.url,
135
+ typeRaw: "Team",
136
+ isBotHint: false
137
+ } : toGraphQLActor(instance, reviewer),
138
+ state: "pending",
139
+ stateRaw: "requested",
140
+ ...isTeam ? { isTeam: true } : {}
141
+ }];
142
+ });
143
+ return {
144
+ ref: {
145
+ ...ref,
146
+ kind,
147
+ externalId: raw.id
148
+ },
149
+ kind,
150
+ title: raw.title,
151
+ body: raw.body,
152
+ state,
153
+ stateRaw: raw.state.toLowerCase(),
154
+ stateReason: raw.stateReason?.toLowerCase() ?? void 0,
155
+ isDraft: raw.isDraft ?? false,
156
+ author: toGraphQLActor(instance, raw.author),
157
+ assignees: (raw.assignees?.nodes ?? []).flatMap((actor) => toGraphQLActor(instance, actor) ?? []),
158
+ participants: (raw.participants?.nodes ?? []).flatMap((actor) => toGraphQLActor(instance, actor) ?? []),
159
+ milestone: toGraphQLMilestone(raw.milestone),
160
+ subscription: toViewerSubscription(raw.viewerSubscription),
161
+ reviewers,
162
+ labels: (raw.labels?.nodes ?? []).map((label) => ({
163
+ name: label.name,
164
+ colour: label.color,
165
+ description: label.description ?? void 0
166
+ })),
167
+ url: raw.url,
168
+ createdAt: toDate(raw.createdAt),
169
+ updatedAt: toDate(raw.updatedAt),
170
+ closedAt: toDate(raw.closedAt),
171
+ lastActivityAt: toDate(raw.updatedAt),
172
+ locked: raw.locked,
173
+ commentCount: raw.comments?.totalCount,
174
+ ...isPull && raw.commits?.nodes[0]?.commit.statusCheckRollup ? { checks: toRollupSummary(raw.commits.nodes[0].commit.statusCheckRollup, raw.url) } : {},
175
+ branches: isPull && raw.headRefName && raw.baseRefName ? {
176
+ head: {
177
+ ref: raw.headRefName,
178
+ sha: raw.headRefOid,
179
+ repo: raw.headRepository ? {
180
+ forge: FORGE,
181
+ instance,
182
+ owner: raw.headRepository.owner.login,
183
+ name: raw.headRepository.name,
184
+ externalId: raw.headRepository.databaseId === void 0 ? void 0 : String(raw.headRepository.databaseId)
185
+ } : void 0
186
+ },
187
+ base: {
188
+ ref: raw.baseRefName,
189
+ sha: raw.baseRefOid
190
+ },
191
+ mergeCommitSha: raw.mergeCommit?.oid
192
+ } : void 0,
193
+ raw
194
+ };
195
+ }
196
+ /** Lists recent discussions in several repositories at once, for resolving notification subjects. */
197
+ function recentDiscussionsQuery(repos) {
198
+ const variables = {};
199
+ const declarations = [];
200
+ const fields = repos.map((repo, index) => {
201
+ variables[`o${index}`] = repo.owner;
202
+ variables[`n${index}`] = repo.name;
203
+ declarations.push(`$o${index}: String!`, `$n${index}: String!`);
204
+ return `r${index}: repository(owner: $o${index}, name: $n${index}) { discussions(first: 50, orderBy: { field: UPDATED_AT, direction: DESC }) { nodes { id number title updatedAt } } }`;
205
+ });
206
+ return {
207
+ query: `query RecentDiscussions(${declarations.join(", ")}) {\n ${fields.join("\n ")}\n}`,
208
+ variables
209
+ };
210
+ }
211
+ const DISCUSSION_COMMENTS = `query DiscussionComments($owner: String!, $name: String!, $number: Int!, $after: String) {
212
+ repository(owner: $owner, name: $name) {
213
+ discussion(number: $number) {
214
+ comments(first: 50, after: $after) {
215
+ pageInfo { hasNextPage endCursor }
216
+ nodes {
217
+ id databaseId body createdAt url
218
+ author { ${ACTOR_FIELDS} }
219
+ replies(first: 50) { nodes { id databaseId body createdAt url author { ${ACTOR_FIELDS} } } }
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }`;
225
+ const ADD_DISCUSSION_COMMENT = `mutation AddDiscussionComment($id: ID!, $body: String!) {
226
+ addDiscussionComment(input: { discussionId: $id, body: $body }) { comment { ${COMMENT_FIELDS} } }
227
+ }`;
228
+ const CLOSE_DISCUSSION = `mutation CloseDiscussion($id: ID!, $reason: DiscussionCloseReason) {
229
+ closeDiscussion(input: { discussionId: $id, reason: $reason }) { discussion { id } }
230
+ }`;
231
+ const REOPEN_DISCUSSION = `mutation ReopenDiscussion($id: ID!) {
232
+ reopenDiscussion(input: { discussionId: $id }) { discussion { id } }
233
+ }`;
234
+ function toGraphQLActor(instance, actor) {
235
+ if (!actor) return;
236
+ return {
237
+ forge: FORGE,
238
+ instance,
239
+ login: actor.login,
240
+ id: String(actor.databaseId ?? actor.login),
241
+ name: actor.name,
242
+ avatarUrl: actor.avatarUrl,
243
+ url: actor.url,
244
+ typeRaw: actor.__typename,
245
+ isBotHint: actor.__typename === "Bot" || actor.login.endsWith("[bot]")
246
+ };
247
+ }
248
+ function toDiscussionThread(ref, raw) {
249
+ return {
250
+ ref: {
251
+ ...ref,
252
+ externalId: raw.id
253
+ },
254
+ kind: "discussion",
255
+ title: raw.title,
256
+ body: raw.body,
257
+ state: raw.closed ? "closed" : "open",
258
+ stateRaw: raw.closed ? "closed" : "open",
259
+ stateReason: raw.stateReason?.toLowerCase(),
260
+ isDraft: false,
261
+ author: toGraphQLActor(ref.instance, raw.author),
262
+ assignees: [],
263
+ reviewers: [],
264
+ lastActivityAt: toDate(raw.updatedAt),
265
+ url: raw.url,
266
+ createdAt: toDate(raw.createdAt),
267
+ updatedAt: toDate(raw.updatedAt),
268
+ closedAt: toDate(raw.closedAt),
269
+ labels: (raw.labels?.nodes ?? []).map((label) => ({
270
+ name: label.name,
271
+ colour: label.color,
272
+ description: label.description ?? void 0
273
+ })),
274
+ locked: raw.locked,
275
+ commentCount: raw.comments?.totalCount,
276
+ raw
277
+ };
278
+ }
279
+ function toDiscussionCommentEvent(ref, comment, isReply) {
280
+ const actor = toGraphQLActor(ref.instance, comment.author);
281
+ return {
282
+ forge: FORGE,
283
+ instance: ref.instance,
284
+ id: comment.id,
285
+ kind: "comment",
286
+ kindRaw: isReply ? "DiscussionCommentReply" : "DiscussionComment",
287
+ summary: `${actor?.login ?? "someone"} ${isReply ? "replied" : "commented"}`,
288
+ occurredAt: toDate(comment.createdAt) ?? /* @__PURE__ */ new Date(0),
289
+ actor,
290
+ repo: ref.repo,
291
+ thread: ref,
292
+ source: "poll",
293
+ payload: comment
294
+ };
295
+ }
296
+ function toDiscussionComment(thread, raw) {
297
+ return {
298
+ ref: {
299
+ forge: FORGE,
300
+ instance: thread.instance,
301
+ thread,
302
+ id: raw.id
303
+ },
304
+ body: raw.body ?? "",
305
+ author: toGraphQLActor(thread.instance, raw.author),
306
+ createdAt: toDate(raw.createdAt),
307
+ updatedAt: toDate(raw.updatedAt),
308
+ url: raw.url,
309
+ raw
310
+ };
311
+ }
312
+ const REPOSITORY_ID = `query RepositoryId($owner: String!, $name: String!) {
313
+ repository(owner: $owner, name: $name) { id }
314
+ }`;
315
+ const TRANSFER_ISSUE = `mutation TransferIssue($issue: ID!, $repo: ID!) {
316
+ transferIssue(input: { issueId: $issue, repositoryId: $repo }) { issue { id number } }
317
+ }`;
318
+ const MARK_DUPLICATE = `mutation MarkDuplicate($canonical: ID!, $duplicate: ID!) {
319
+ closeIssue(input: { issueId: $duplicate, stateReason: DUPLICATE, duplicateIssueId: $canonical }) { issue { __typename } }
320
+ }`;
321
+ const NODE_REACTIONS = `query NodeReactions($id: ID!, $after: String) {
322
+ node(id: $id) {
323
+ ... on Reactable {
324
+ reactions(first: 100, after: $after) {
325
+ pageInfo { hasNextPage endCursor }
326
+ nodes { content createdAt user { __typename login databaseId name avatarUrl url } }
327
+ }
328
+ }
329
+ }
330
+ }`;
331
+ const ADD_REACTION = `mutation AddReaction($id: ID!, $content: ReactionContent!) {
332
+ addReaction(input: { subjectId: $id, content: $content }) { reaction { content } }
333
+ }`;
334
+ const REMOVE_REACTION = `mutation RemoveReaction($id: ID!, $content: ReactionContent!) {
335
+ removeReaction(input: { subjectId: $id, content: $content }) { reaction { content } }
336
+ }`;
337
+ /** The GraphQL `ReactionContent` enum, by the model's name for each reaction. */
338
+ const REACTION_CONTENT = {
339
+ "+1": "THUMBS_UP",
340
+ "-1": "THUMBS_DOWN",
341
+ "laugh": "LAUGH",
342
+ "confused": "CONFUSED",
343
+ "heart": "HEART",
344
+ "hooray": "HOORAY",
345
+ "rocket": "ROCKET",
346
+ "eyes": "EYES"
347
+ };
348
+ /** The model's name for each GraphQL `ReactionContent` value. */
349
+ const GRAPHQL_REACTIONS = Object.fromEntries(Object.entries(REACTION_CONTENT).map(([content, graphql]) => [graphql, content]));
350
+ const REVIEW_THREADS = `query ReviewThreads($owner: String!, $name: String!, $number: Int!) {
351
+ repository(owner: $owner, name: $name) {
352
+ pullRequest(number: $number) {
353
+ reviewThreads(first: 100) {
354
+ nodes { id isResolved comments(first: 100) { nodes { databaseId } } }
355
+ }
356
+ }
357
+ }
358
+ }`;
359
+ const RESOLVE_REVIEW_THREAD = `mutation ResolveReviewThread($id: ID!) {
360
+ resolveReviewThread(input: { threadId: $id }) { thread { isResolved } }
361
+ }`;
362
+ const UNRESOLVE_REVIEW_THREAD = `mutation UnresolveReviewThread($id: ID!) {
363
+ unresolveReviewThread(input: { threadId: $id }) { thread { isResolved } }
364
+ }`;
365
+ //#endregion
366
+ export { ADD_DISCUSSION_COMMENT, ADD_REACTION, CLOSE_DISCUSSION, DELETE_DISCUSSION_COMMENT, DISCUSSIONS_LIST, DISCUSSION_COMMENTS, DISCUSSION_THREAD, GRAPHQL_REACTIONS, MARK_DUPLICATE, NODE_REACTIONS, REACTION_CONTENT, REMOVE_REACTION, REOPEN_DISCUSSION, REPOSITORY_ID, RESOLVE_REVIEW_THREAD, REVIEW_THREADS, SUBSCRIPTION_STATE, TRANSFER_ISSUE, UNRESOLVE_REVIEW_THREAD, UPDATE_DISCUSSION, UPDATE_DISCUSSION_COMMENT, UPDATE_SUBSCRIPTION, recentDiscussionsQuery, threadsBatchQuery, toDiscussionComment, toDiscussionCommentEvent, toDiscussionThread, toGraphQLActor, toGraphQLMilestone, toGraphQLThread, toViewerSubscription };
@@ -0,0 +1,32 @@
1
+ import { M as TokenAuth, P as VerbScopes, a as BasicAuth, m as ForgeOptionsBase, n as AnonymousAuth, q as ForgeVerb } from "./provider-CoZ7cCxp.mjs";
2
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
3
+ //#region src/bitbucket/index.d.ts
4
+ /**
5
+ * Bitbucket Cloud credentials.
6
+ *
7
+ * - `token`: an OAuth access token or a repository, project or workspace
8
+ * access token, sent as a bearer token.
9
+ * - `basic`: an Atlassian account email and API token.
10
+ */
11
+ type BitbucketAuth = TokenAuth | BasicAuth | AnonymousAuth;
12
+ /** Options for `bitbucket()`. */
13
+ interface BitbucketOptions extends ForgeOptionsBase {
14
+ /**
15
+ * How to authenticate. Without credentials, only public reads work.
16
+ * @default { type: 'anonymous' }
17
+ */
18
+ auth?: BitbucketAuth;
19
+ /**
20
+ * API base.
21
+ * @default https://api.bitbucket.org/2.0
22
+ */
23
+ baseUrl?: string;
24
+ }
25
+ /** Creates a Bitbucket Cloud provider. */
26
+ declare const bitbucket: ProviderFactoryFunction<BitbucketOptions>;
27
+ /** `bitbucket()` without webhook ingestion, for bundles that never receive a delivery. */
28
+ declare const bitbucketLite: ProviderFactoryFunction<BitbucketOptions>;
29
+ /** Bitbucket Cloud scopes, as an app password or OAuth consumer grants them. */
30
+ declare function bitbucketScopesFor(verb: ForgeVerb): VerbScopes;
31
+ //#endregion
32
+ export { bitbucketScopesFor as a, bitbucketLite as i, BitbucketOptions as n, bitbucket as r, BitbucketAuth as t };
@@ -0,0 +1,16 @@
1
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
2
+ import { i as ForgejoProfile, r as ForgejoOptions } from "./index-DIuS0EOy.mjs";
3
+ //#region src/gitea/index.d.ts
4
+ /** Options for `gitea()`, the same as for `forgejo()`. */
5
+ type GiteaOptions = ForgejoOptions;
6
+ /**
7
+ * Gitea shares Forgejo's REST API. It differs in its default instance, its
8
+ * webhook headers (`X-Gitea-*` only) and its capability profile.
9
+ */
10
+ declare const GITEA_PROFILE: ForgejoProfile;
11
+ /** Creates a Gitea provider for gitea.com or any self-hosted Gitea instance. */
12
+ declare const gitea: ProviderFactoryFunction<GiteaOptions>;
13
+ /** `gitea()` without webhook ingestion, for bundles that never receive a delivery. */
14
+ declare const giteaLite: ProviderFactoryFunction<GiteaOptions>;
15
+ //#endregion
16
+ export { giteaLite as i, GiteaOptions as n, gitea as r, GITEA_PROFILE as t };
@@ -0,0 +1,102 @@
1
+ import { Ln as ThreadKind, dn as RepoRef, n as FetchLike } from "./fetch-D4pSRvvA.mjs";
2
+ import { m as ForgeOptionsBase, n as AnonymousAuth } from "./provider-CoZ7cCxp.mjs";
3
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
4
+ //#region src/tangled/subscribe.d.ts
5
+ /** The subset of the WHATWG `WebSocket` the subscription uses. */
6
+ interface WebSocketLike {
7
+ /** Registers a listener for a socket event. */
8
+ addEventListener: (type: "open" | "message" | "error" | "close", listener: (event: {
9
+ data?: unknown;
10
+ code?: number;
11
+ reason?: string;
12
+ }) => void) => void;
13
+ /** Closes the socket, optionally with a close code and reason. */
14
+ close: (code?: number, reason?: string) => void;
15
+ }
16
+ /** Opens a WebSocket for a URL, such as `url => new WebSocket(url)`. */
17
+ type WebSocketFactory = (url: string) => WebSocketLike;
18
+ //#endregion
19
+ //#region src/tangled/index.d.ts
20
+ /**
21
+ * Credentials for writing records. Reads are public and need none.
22
+ *
23
+ * - `app_password` creates a session on the account's PDS.
24
+ * - `oauth` takes a `fetch` from an atproto OAuth client that already signs
25
+ * requests (DPoP) for `pds`.
26
+ */
27
+ type TangledAuth = AnonymousAuth | {
28
+ type: "app_password";
29
+ identifier: string;
30
+ password: string;
31
+ pds?: string;
32
+ } | {
33
+ type: "oauth";
34
+ did: string;
35
+ pds: string;
36
+ fetch: FetchLike;
37
+ };
38
+ /** Options for `tangled()`. */
39
+ interface TangledOptions extends ForgeOptionsBase {
40
+ /** An app password session, an OAuth client that signs requests, or none for anonymous reads. */
41
+ auth?: TangledAuth;
42
+ /**
43
+ * Appview web root, used for links and as the `instance`.
44
+ * @default https://tangled.org
45
+ */
46
+ baseUrl?: string;
47
+ /**
48
+ * Base for `request()`: a Bobbin-compatible XRPC index. Defaults to
49
+ * `https://api.tangled.org`, Tangled's public instance.
50
+ */
51
+ apiUrl?: string;
52
+ /** PLC directory for `did:plc` resolution. Defaults to the public directory, which is community infrastructure. */
53
+ plcUrl?: string;
54
+ /** Constellation-compatible backlink index. */
55
+ backlinksUrl?: string;
56
+ /**
57
+ * Service for `com.atproto.identity.resolveHandle`, so a `RepoRef.owner` can
58
+ * be a handle. Defaults to `https://public.api.bsky.app`.
59
+ */
60
+ handleResolverUrl?: string;
61
+ /**
62
+ * Slingshot-compatible record cache, for example
63
+ * `https://slingshot.microcosm.blue`. By default records are read from each
64
+ * author's PDS.
65
+ */
66
+ recordsUrl?: string;
67
+ /** Jetstream `subscribe` endpoint. */
68
+ jetstreamUrl?: string;
69
+ /** Defaults to the global `WebSocket`. */
70
+ webSocket?: WebSocketFactory;
71
+ /**
72
+ * Base URL of a service implementing the experimental
73
+ * `org.tangled.temp.notification.*` lexicons (Tangled's deliberi). Its
74
+ * service DID is derived as `did:web:<host>`. Requires `auth`. The lexicons
75
+ * live in Tangled's `temp` namespace and may change or disappear, so the
76
+ * resulting capabilities report `'experimental'`, or `'unverified'`.
77
+ */
78
+ notificationsUrl?: string;
79
+ /**
80
+ * Maps a per-repo display number (as carried by webhooks) to the thread's
81
+ * AT-URI. When provided, `webhooks.ingest()` uses it to fill `number`.
82
+ * Records carry no numbers; the mapping exists only in an index of the
83
+ * appview's numbering.
84
+ */
85
+ resolveDisplayNumber?: (repo: RepoRef, kind: ThreadKind, displayNumber: string) => Promise<string | undefined>;
86
+ /** Maps a knot host to the host that accepts git over SSH for it. `knot1.tangled.sh` maps to `tangled.org` by default. */
87
+ sshHosts?: Record<string, string>;
88
+ /**
89
+ * Where `threads.list` reads from. `'records'` (the default) reads every
90
+ * record and computes state with the appview's rule. `'index'` reads the
91
+ * Bobbin index at `apiUrl` instead: one request per page, but its states may
92
+ * lag behind the records, and every listing carries an `index_possibly_stale`
93
+ * warning.
94
+ */
95
+ listSource?: "records" | "index";
96
+ }
97
+ /** Creates a Tangled provider. Records are read from PDSes; pushes arrive through Jetstream. */
98
+ declare const tangled: ProviderFactoryFunction<TangledOptions>;
99
+ /** `tangled()` without webhook ingestion, for bundles that never receive a delivery. */
100
+ declare const tangledLite: ProviderFactoryFunction<TangledOptions>;
101
+ //#endregion
102
+ export { WebSocketFactory as a, tangledLite as i, TangledOptions as n, WebSocketLike as o, tangled as r, TangledAuth as t };
@@ -0,0 +1,27 @@
1
+ import { M as TokenAuth, P as VerbScopes, m as ForgeOptionsBase, n as AnonymousAuth, q as ForgeVerb, r as AppAuth } from "./provider-CoZ7cCxp.mjs";
2
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
3
+ //#region src/github/auth.d.ts
4
+ /** The credentials GitHub accepts: a token, a GitHub App, or none for anonymous reads. */
5
+ type GitHubAuth = TokenAuth | AppAuth | AnonymousAuth;
6
+ //#endregion
7
+ //#region src/github/index.d.ts
8
+ /** Options for `github()`. */
9
+ interface GitHubOptions extends ForgeOptionsBase {
10
+ /**
11
+ * How to authenticate. Without credentials, only public reads work.
12
+ * @default { type: 'anonymous' }
13
+ */
14
+ auth?: GitHubAuth;
15
+ }
16
+ /** Creates a GitHub provider for github.com or a GitHub Enterprise Server instance. */
17
+ declare const github: ProviderFactoryFunction<GitHubOptions>;
18
+ /** `github()` without webhook ingestion, for bundles that never receive a delivery. */
19
+ declare const githubLite: ProviderFactoryFunction<GitHubOptions>;
20
+ /**
21
+ * Token scopes and fine-grained permissions GitHub documents per endpoint
22
+ * group. Classic scopes are the ones an OAuth consent screen asks for; the
23
+ * permissions are the fine-grained token and app equivalents.
24
+ */
25
+ declare function githubScopesFor(verb: ForgeVerb): VerbScopes;
26
+ //#endregion
27
+ export { GitHubAuth as a, githubScopesFor as i, github as n, githubLite as r, GitHubOptions as t };
@@ -0,0 +1,35 @@
1
+ import { M as TokenAuth, a as BasicAuth, m as ForgeOptionsBase, n as AnonymousAuth } from "./provider-CoZ7cCxp.mjs";
2
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
3
+ //#region src/azure-devops/index.d.ts
4
+ /** The REST API version sent with every request; preview endpoints set their own. */
5
+ declare const AZURE_DEVOPS_API_VERSION = "7.1";
6
+ /** A personal access token (sent as basic auth with an empty user name), or explicit basic credentials. */
7
+ type AzureDevOpsAuth = TokenAuth | BasicAuth | AnonymousAuth;
8
+ /** Options for `azureDevOps()`. */
9
+ interface AzureDevOpsOptions extends ForgeOptionsBase {
10
+ /**
11
+ * How to authenticate. Without credentials, only public reads work.
12
+ * @default { type: 'anonymous' }
13
+ */
14
+ auth?: AzureDevOpsAuth;
15
+ /** The organization (or Azure DevOps Server collection) that `repos.list()` lists. */
16
+ organization: string;
17
+ /**
18
+ * For Azure DevOps Server, the server root, for example `https://tfs.example.com/tfs`.
19
+ * @default https://dev.azure.com
20
+ */
21
+ baseUrl?: string;
22
+ /**
23
+ * Work item type `threads.create({ kind: 'issue' })` creates. Scrum projects use `Impediment` or `Product Backlog Item`.
24
+ * @default Issue
25
+ */
26
+ issueType?: string;
27
+ /** `username:password` the service hook subscription sends as basic auth. */
28
+ webhookSecret?: string;
29
+ }
30
+ /** Creates an Azure DevOps provider for one organization on dev.azure.com, or a collection on Azure DevOps Server. */
31
+ declare const azureDevOps: ProviderFactoryFunction<AzureDevOpsOptions>;
32
+ /** `azureDevOps()` without webhook ingestion, for bundles that never receive a delivery. */
33
+ declare const azureDevOpsLite: ProviderFactoryFunction<AzureDevOpsOptions>;
34
+ //#endregion
35
+ export { azureDevOpsLite as a, azureDevOps as i, AzureDevOpsAuth as n, AzureDevOpsOptions as r, AZURE_DEVOPS_API_VERSION as t };
@@ -0,0 +1,23 @@
1
+ import { M as TokenAuth, P as VerbScopes, m as ForgeOptionsBase, n as AnonymousAuth, q as ForgeVerb } from "./provider-CoZ7cCxp.mjs";
2
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
3
+ //#region src/gitlab/index.d.ts
4
+ /** Personal, project, group or OAuth access token. */
5
+ type GitLabAuth = TokenAuth | AnonymousAuth;
6
+ /** Options for `gitlab()`. */
7
+ interface GitLabOptions extends ForgeOptionsBase {
8
+ /**
9
+ * How to authenticate. Without credentials, only public reads work.
10
+ * @default { type: 'anonymous' }
11
+ */
12
+ auth?: GitLabAuth;
13
+ /** Instance root, for example `https://gitlab.com`. */
14
+ baseUrl?: string;
15
+ }
16
+ /** Creates a GitLab provider for gitlab.com or a self-managed instance. */
17
+ declare const gitlab: ProviderFactoryFunction<GitLabOptions>;
18
+ /** `gitlab()` without webhook ingestion, for bundles that never receive a delivery. */
19
+ declare const gitlabLite: ProviderFactoryFunction<GitLabOptions>;
20
+ /** GitLab tokens carry coarse scopes; `api` covers writes and `read_api` reads. */
21
+ declare function gitlabScopesFor(verb: ForgeVerb): VerbScopes;
22
+ //#endregion
23
+ export { gitlabScopesFor as a, gitlabLite as i, GitLabOptions as n, gitlab as r, GitLabAuth as t };
@@ -0,0 +1,36 @@
1
+ import { M as TokenAuth, m as ForgeOptionsBase, n as AnonymousAuth, r as AppAuth } from "./provider-CoZ7cCxp.mjs";
2
+ import { c as ProviderFactoryFunction } from "./define-B2_4ob2i.mjs";
3
+ //#region src/cursor-origin/auth.d.ts
4
+ /**
5
+ * A user access token (what the Origin CLI sends, for example
6
+ * `CURSOR_AUTH_TOKEN`), or an Origin App: its id and Ed25519 PKCS#8 private
7
+ * key, optionally scoped to one installation. Personal Cursor API keys are
8
+ * not Origin bearer tokens.
9
+ */
10
+ type CursorOriginAuth = TokenAuth | AppAuth;
11
+ //#endregion
12
+ //#region src/cursor-origin/index.d.ts
13
+ /** The Origin API version this provider was built against. See `docs/content/4.providers/cursor-origin.md`. */
14
+ declare const ORIGIN_API_VERSION = "v1alpha1";
15
+ /** Options for `cursorOrigin()`. */
16
+ interface CursorOriginOptions extends ForgeOptionsBase {
17
+ /**
18
+ * Token or app credentials. Cursor Origin's API has no anonymous access, so
19
+ * without `auth` the provider only verifies and translates webhook deliveries.
20
+ */
21
+ auth?: CursorOriginAuth | AnonymousAuth;
22
+ /**
23
+ * API root. `/v1/origin` is appended.
24
+ * @default https://api.cursor.com
25
+ */
26
+ baseUrl?: string;
27
+ }
28
+ /**
29
+ * Creates a Cursor Origin provider. Experimental: built against the
30
+ * `v1alpha1` API, which Cursor publishes as Early Beta.
31
+ */
32
+ declare const cursorOrigin: ProviderFactoryFunction<CursorOriginOptions>;
33
+ /** `cursorOrigin()` without webhook ingestion, for bundles that never receive a delivery. */
34
+ declare const cursorOriginLite: ProviderFactoryFunction<CursorOriginOptions>;
35
+ //#endregion
36
+ export { CursorOriginAuth as a, cursorOriginLite as i, ORIGIN_API_VERSION as n, cursorOrigin as r, CursorOriginOptions as t };