@gitkraken/core-gitlens 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 (1375) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +30 -0
  3. package/LICENSE.plus +40 -0
  4. package/README.md +54 -0
  5. package/dist/git/cache.d.ts +140 -0
  6. package/dist/git/cache.d.ts.map +1 -0
  7. package/dist/git/cache.js +765 -0
  8. package/dist/git/cache.js.map +1 -0
  9. package/dist/git/context.d.ts +238 -0
  10. package/dist/git/context.d.ts.map +1 -0
  11. package/dist/git/context.js +11 -0
  12. package/dist/git/context.js.map +1 -0
  13. package/dist/git/errors.d.ts +419 -0
  14. package/dist/git/errors.d.ts.map +1 -0
  15. package/dist/git/errors.js +681 -0
  16. package/dist/git/errors.js.map +1 -0
  17. package/dist/git/exec.types.d.ts +66 -0
  18. package/dist/git/exec.types.d.ts.map +1 -0
  19. package/dist/git/exec.types.js +2 -0
  20. package/dist/git/exec.types.js.map +1 -0
  21. package/dist/git/features.d.ts +8 -0
  22. package/dist/git/features.d.ts.map +1 -0
  23. package/dist/git/features.js +18 -0
  24. package/dist/git/features.js.map +1 -0
  25. package/dist/git/models/author.d.ts +17 -0
  26. package/dist/git/models/author.d.ts.map +1 -0
  27. package/dist/git/models/author.js +2 -0
  28. package/dist/git/models/author.js.map +1 -0
  29. package/dist/git/models/autolink.d.ts +51 -0
  30. package/dist/git/models/autolink.d.ts.map +1 -0
  31. package/dist/git/models/autolink.js +2 -0
  32. package/dist/git/models/autolink.js.map +1 -0
  33. package/dist/git/models/blame.d.ts +41 -0
  34. package/dist/git/models/blame.d.ts.map +1 -0
  35. package/dist/git/models/blame.js +2 -0
  36. package/dist/git/models/blame.js.map +1 -0
  37. package/dist/git/models/branch.d.ts +85 -0
  38. package/dist/git/models/branch.d.ts.map +1 -0
  39. package/dist/git/models/branch.js +174 -0
  40. package/dist/git/models/branch.js.map +1 -0
  41. package/dist/git/models/commit.d.ts +163 -0
  42. package/dist/git/models/commit.d.ts.map +1 -0
  43. package/dist/git/models/commit.js +496 -0
  44. package/dist/git/models/commit.js.map +1 -0
  45. package/dist/git/models/contributor.d.ts +40 -0
  46. package/dist/git/models/contributor.d.ts.map +1 -0
  47. package/dist/git/models/contributor.js +67 -0
  48. package/dist/git/models/contributor.js.map +1 -0
  49. package/dist/git/models/defaultBranch.d.ts +6 -0
  50. package/dist/git/models/defaultBranch.d.ts.map +1 -0
  51. package/dist/git/models/defaultBranch.js +2 -0
  52. package/dist/git/models/defaultBranch.js.map +1 -0
  53. package/dist/git/models/diff.d.ts +73 -0
  54. package/dist/git/models/diff.d.ts.map +1 -0
  55. package/dist/git/models/diff.js +2 -0
  56. package/dist/git/models/diff.js.map +1 -0
  57. package/dist/git/models/file.d.ts +23 -0
  58. package/dist/git/models/file.d.ts.map +1 -0
  59. package/dist/git/models/file.js +2 -0
  60. package/dist/git/models/file.js.map +1 -0
  61. package/dist/git/models/fileChange.d.ts +50 -0
  62. package/dist/git/models/fileChange.d.ts.map +1 -0
  63. package/dist/git/models/fileChange.js +69 -0
  64. package/dist/git/models/fileChange.js.map +1 -0
  65. package/dist/git/models/fileStatus.d.ts +33 -0
  66. package/dist/git/models/fileStatus.d.ts.map +1 -0
  67. package/dist/git/models/fileStatus.js +29 -0
  68. package/dist/git/models/fileStatus.js.map +1 -0
  69. package/dist/git/models/graph.d.ts +171 -0
  70. package/dist/git/models/graph.d.ts.map +1 -0
  71. package/dist/git/models/graph.js +2 -0
  72. package/dist/git/models/graph.js.map +1 -0
  73. package/dist/git/models/graphSearch.d.ts +48 -0
  74. package/dist/git/models/graphSearch.d.ts.map +1 -0
  75. package/dist/git/models/graphSearch.js +2 -0
  76. package/dist/git/models/graphSearch.js.map +1 -0
  77. package/dist/git/models/issue.d.ts +69 -0
  78. package/dist/git/models/issue.d.ts.map +1 -0
  79. package/dist/git/models/issue.js +68 -0
  80. package/dist/git/models/issue.js.map +1 -0
  81. package/dist/git/models/issueOrPullRequest.d.ts +19 -0
  82. package/dist/git/models/issueOrPullRequest.d.ts.map +1 -0
  83. package/dist/git/models/issueOrPullRequest.js +2 -0
  84. package/dist/git/models/issueOrPullRequest.js.map +1 -0
  85. package/dist/git/models/lineRange.d.ts +8 -0
  86. package/dist/git/models/lineRange.d.ts.map +1 -0
  87. package/dist/git/models/lineRange.js +2 -0
  88. package/dist/git/models/lineRange.js.map +1 -0
  89. package/dist/git/models/log.d.ts +19 -0
  90. package/dist/git/models/log.d.ts.map +1 -0
  91. package/dist/git/models/log.js +2 -0
  92. package/dist/git/models/log.js.map +1 -0
  93. package/dist/git/models/mergeConflicts.d.ts +23 -0
  94. package/dist/git/models/mergeConflicts.d.ts.map +1 -0
  95. package/dist/git/models/mergeConflicts.js +2 -0
  96. package/dist/git/models/mergeConflicts.js.map +1 -0
  97. package/dist/git/models/patch.d.ts +22 -0
  98. package/dist/git/models/patch.d.ts.map +1 -0
  99. package/dist/git/models/patch.js +2 -0
  100. package/dist/git/models/patch.js.map +1 -0
  101. package/dist/git/models/pausedOperationStatus.d.ts +52 -0
  102. package/dist/git/models/pausedOperationStatus.d.ts.map +1 -0
  103. package/dist/git/models/pausedOperationStatus.js +2 -0
  104. package/dist/git/models/pausedOperationStatus.js.map +1 -0
  105. package/dist/git/models/pullRequest.d.ts +125 -0
  106. package/dist/git/models/pullRequest.d.ts.map +1 -0
  107. package/dist/git/models/pullRequest.js +127 -0
  108. package/dist/git/models/pullRequest.js.map +1 -0
  109. package/dist/git/models/rebase.d.ts +51 -0
  110. package/dist/git/models/rebase.d.ts.map +1 -0
  111. package/dist/git/models/rebase.js +2 -0
  112. package/dist/git/models/rebase.js.map +1 -0
  113. package/dist/git/models/reference.d.ts +48 -0
  114. package/dist/git/models/reference.d.ts.map +1 -0
  115. package/dist/git/models/reference.js +2 -0
  116. package/dist/git/models/reference.js.map +1 -0
  117. package/dist/git/models/reflog.d.ts +33 -0
  118. package/dist/git/models/reflog.d.ts.map +1 -0
  119. package/dist/git/models/reflog.js +85 -0
  120. package/dist/git/models/reflog.js.map +1 -0
  121. package/dist/git/models/remote.d.ts +37 -0
  122. package/dist/git/models/remote.d.ts.map +1 -0
  123. package/dist/git/models/remote.js +98 -0
  124. package/dist/git/models/remote.js.map +1 -0
  125. package/dist/git/models/remoteProvider.d.ts +112 -0
  126. package/dist/git/models/remoteProvider.d.ts.map +1 -0
  127. package/dist/git/models/remoteProvider.js +154 -0
  128. package/dist/git/models/remoteProvider.js.map +1 -0
  129. package/dist/git/models/remoteResource.d.ts +78 -0
  130. package/dist/git/models/remoteResource.d.ts.map +1 -0
  131. package/dist/git/models/remoteResource.js +13 -0
  132. package/dist/git/models/remoteResource.js.map +1 -0
  133. package/dist/git/models/repository.d.ts +106 -0
  134. package/dist/git/models/repository.d.ts.map +1 -0
  135. package/dist/git/models/repository.js +324 -0
  136. package/dist/git/models/repository.js.map +1 -0
  137. package/dist/git/models/repositoryChangeEvent.d.ts +17 -0
  138. package/dist/git/models/repositoryChangeEvent.d.ts.map +1 -0
  139. package/dist/git/models/repositoryChangeEvent.js +26 -0
  140. package/dist/git/models/repositoryChangeEvent.js.map +1 -0
  141. package/dist/git/models/repositoryIdentities.d.ts +72 -0
  142. package/dist/git/models/repositoryIdentities.d.ts.map +1 -0
  143. package/dist/git/models/repositoryIdentities.js +7 -0
  144. package/dist/git/models/repositoryIdentities.js.map +1 -0
  145. package/dist/git/models/repositoryMetadata.d.ts +12 -0
  146. package/dist/git/models/repositoryMetadata.d.ts.map +1 -0
  147. package/dist/git/models/repositoryMetadata.js +2 -0
  148. package/dist/git/models/repositoryMetadata.js.map +1 -0
  149. package/dist/git/models/resourceDescriptor.d.ts +12 -0
  150. package/dist/git/models/resourceDescriptor.d.ts.map +1 -0
  151. package/dist/git/models/resourceDescriptor.js +2 -0
  152. package/dist/git/models/resourceDescriptor.js.map +1 -0
  153. package/dist/git/models/revision.d.ts +7 -0
  154. package/dist/git/models/revision.d.ts.map +1 -0
  155. package/dist/git/models/revision.js +6 -0
  156. package/dist/git/models/revision.js.map +1 -0
  157. package/dist/git/models/search.d.ts +66 -0
  158. package/dist/git/models/search.d.ts.map +1 -0
  159. package/dist/git/models/search.js +48 -0
  160. package/dist/git/models/search.js.map +1 -0
  161. package/dist/git/models/shortlog.d.ts +6 -0
  162. package/dist/git/models/shortlog.d.ts.map +1 -0
  163. package/dist/git/models/shortlog.js +2 -0
  164. package/dist/git/models/shortlog.js.map +1 -0
  165. package/dist/git/models/signature.d.ts +26 -0
  166. package/dist/git/models/signature.d.ts.map +1 -0
  167. package/dist/git/models/signature.js +2 -0
  168. package/dist/git/models/signature.js.map +1 -0
  169. package/dist/git/models/staging.d.ts +24 -0
  170. package/dist/git/models/staging.d.ts.map +1 -0
  171. package/dist/git/models/staging.js +2 -0
  172. package/dist/git/models/staging.js.map +1 -0
  173. package/dist/git/models/stash.d.ts +6 -0
  174. package/dist/git/models/stash.d.ts.map +1 -0
  175. package/dist/git/models/stash.js +2 -0
  176. package/dist/git/models/stash.js.map +1 -0
  177. package/dist/git/models/status.d.ts +55 -0
  178. package/dist/git/models/status.d.ts.map +1 -0
  179. package/dist/git/models/status.js +208 -0
  180. package/dist/git/models/status.js.map +1 -0
  181. package/dist/git/models/statusFile.d.ts +28 -0
  182. package/dist/git/models/statusFile.d.ts.map +1 -0
  183. package/dist/git/models/statusFile.js +114 -0
  184. package/dist/git/models/statusFile.js.map +1 -0
  185. package/dist/git/models/tag.d.ts +26 -0
  186. package/dist/git/models/tag.d.ts.map +1 -0
  187. package/dist/git/models/tag.js +73 -0
  188. package/dist/git/models/tag.js.map +1 -0
  189. package/dist/git/models/tree.d.ts +10 -0
  190. package/dist/git/models/tree.d.ts.map +1 -0
  191. package/dist/git/models/tree.js +2 -0
  192. package/dist/git/models/tree.js.map +1 -0
  193. package/dist/git/models/user.d.ts +7 -0
  194. package/dist/git/models/user.d.ts.map +1 -0
  195. package/dist/git/models/user.js +2 -0
  196. package/dist/git/models/user.js.map +1 -0
  197. package/dist/git/models/worktree.d.ts +51 -0
  198. package/dist/git/models/worktree.d.ts.map +1 -0
  199. package/dist/git/models/worktree.js +136 -0
  200. package/dist/git/models/worktree.js.map +1 -0
  201. package/dist/git/parsers/diffParser.d.ts +45 -0
  202. package/dist/git/parsers/diffParser.d.ts.map +1 -0
  203. package/dist/git/parsers/diffParser.js +628 -0
  204. package/dist/git/parsers/diffParser.js.map +1 -0
  205. package/dist/git/parsers/rebaseTodoParser.d.ts +15 -0
  206. package/dist/git/parsers/rebaseTodoParser.d.ts.map +1 -0
  207. package/dist/git/parsers/rebaseTodoParser.js +215 -0
  208. package/dist/git/parsers/rebaseTodoParser.js.map +1 -0
  209. package/dist/git/providers/blame.d.ts +15 -0
  210. package/dist/git/providers/blame.d.ts.map +1 -0
  211. package/dist/git/providers/blame.js +2 -0
  212. package/dist/git/providers/blame.js.map +1 -0
  213. package/dist/git/providers/branches.d.ts +80 -0
  214. package/dist/git/providers/branches.d.ts.map +1 -0
  215. package/dist/git/providers/branches.js +2 -0
  216. package/dist/git/providers/branches.js.map +1 -0
  217. package/dist/git/providers/commits.d.ts +102 -0
  218. package/dist/git/providers/commits.d.ts.map +1 -0
  219. package/dist/git/providers/commits.js +2 -0
  220. package/dist/git/providers/commits.js.map +1 -0
  221. package/dist/git/providers/config.d.ts +64 -0
  222. package/dist/git/providers/config.d.ts.map +1 -0
  223. package/dist/git/providers/config.js +2 -0
  224. package/dist/git/providers/config.js.map +1 -0
  225. package/dist/git/providers/contributors.d.ts +26 -0
  226. package/dist/git/providers/contributors.d.ts.map +1 -0
  227. package/dist/git/providers/contributors.js +2 -0
  228. package/dist/git/providers/contributors.js.map +1 -0
  229. package/dist/git/providers/diff.d.ts +73 -0
  230. package/dist/git/providers/diff.d.ts.map +1 -0
  231. package/dist/git/providers/diff.js +2 -0
  232. package/dist/git/providers/diff.js.map +1 -0
  233. package/dist/git/providers/graph.d.ts +20 -0
  234. package/dist/git/providers/graph.d.ts.map +1 -0
  235. package/dist/git/providers/graph.js +2 -0
  236. package/dist/git/providers/graph.js.map +1 -0
  237. package/dist/git/providers/operations.d.ts +65 -0
  238. package/dist/git/providers/operations.d.ts.map +1 -0
  239. package/dist/git/providers/operations.js +2 -0
  240. package/dist/git/providers/operations.js.map +1 -0
  241. package/dist/git/providers/patch.d.ts +27 -0
  242. package/dist/git/providers/patch.d.ts.map +1 -0
  243. package/dist/git/providers/patch.js +2 -0
  244. package/dist/git/providers/patch.js.map +1 -0
  245. package/dist/git/providers/pausedOperations.d.ts +11 -0
  246. package/dist/git/providers/pausedOperations.d.ts.map +1 -0
  247. package/dist/git/providers/pausedOperations.js +2 -0
  248. package/dist/git/providers/pausedOperations.js.map +1 -0
  249. package/dist/git/providers/provider.d.ts +57 -0
  250. package/dist/git/providers/provider.d.ts.map +1 -0
  251. package/dist/git/providers/provider.js +2 -0
  252. package/dist/git/providers/provider.js.map +1 -0
  253. package/dist/git/providers/refs.d.ts +22 -0
  254. package/dist/git/providers/refs.d.ts.map +1 -0
  255. package/dist/git/providers/refs.js +2 -0
  256. package/dist/git/providers/refs.js.map +1 -0
  257. package/dist/git/providers/remotes.d.ts +25 -0
  258. package/dist/git/providers/remotes.d.ts.map +1 -0
  259. package/dist/git/providers/remotes.js +2 -0
  260. package/dist/git/providers/remotes.js.map +1 -0
  261. package/dist/git/providers/revision.d.ts +28 -0
  262. package/dist/git/providers/revision.d.ts.map +1 -0
  263. package/dist/git/providers/revision.js +2 -0
  264. package/dist/git/providers/revision.js.map +1 -0
  265. package/dist/git/providers/shared/remotes.d.ts +25 -0
  266. package/dist/git/providers/shared/remotes.d.ts.map +1 -0
  267. package/dist/git/providers/shared/remotes.js +79 -0
  268. package/dist/git/providers/shared/remotes.js.map +1 -0
  269. package/dist/git/providers/staging.d.ts +22 -0
  270. package/dist/git/providers/staging.d.ts.map +1 -0
  271. package/dist/git/providers/staging.js +2 -0
  272. package/dist/git/providers/staging.js.map +1 -0
  273. package/dist/git/providers/stash.d.ts +41 -0
  274. package/dist/git/providers/stash.d.ts.map +1 -0
  275. package/dist/git/providers/stash.js +2 -0
  276. package/dist/git/providers/stash.js.map +1 -0
  277. package/dist/git/providers/status.d.ts +30 -0
  278. package/dist/git/providers/status.d.ts.map +1 -0
  279. package/dist/git/providers/status.js +2 -0
  280. package/dist/git/providers/status.js.map +1 -0
  281. package/dist/git/providers/tags.d.ts +18 -0
  282. package/dist/git/providers/tags.d.ts.map +1 -0
  283. package/dist/git/providers/tags.js +2 -0
  284. package/dist/git/providers/tags.js.map +1 -0
  285. package/dist/git/providers/types.d.ts +28 -0
  286. package/dist/git/providers/types.d.ts.map +1 -0
  287. package/dist/git/providers/types.js +2 -0
  288. package/dist/git/providers/types.js.map +1 -0
  289. package/dist/git/providers/worktrees.d.ts +23 -0
  290. package/dist/git/providers/worktrees.d.ts.map +1 -0
  291. package/dist/git/providers/worktrees.js +2 -0
  292. package/dist/git/providers/worktrees.js.map +1 -0
  293. package/dist/git/remotes/azure-devops.d.ts +43 -0
  294. package/dist/git/remotes/azure-devops.d.ts.map +1 -0
  295. package/dist/git/remotes/azure-devops.js +248 -0
  296. package/dist/git/remotes/azure-devops.js.map +1 -0
  297. package/dist/git/remotes/bitbucket-server.d.ts +32 -0
  298. package/dist/git/remotes/bitbucket-server.d.ts.map +1 -0
  299. package/dist/git/remotes/bitbucket-server.js +145 -0
  300. package/dist/git/remotes/bitbucket-server.js.map +1 -0
  301. package/dist/git/remotes/bitbucket.d.ts +29 -0
  302. package/dist/git/remotes/bitbucket.d.ts.map +1 -0
  303. package/dist/git/remotes/bitbucket.js +114 -0
  304. package/dist/git/remotes/bitbucket.js.map +1 -0
  305. package/dist/git/remotes/custom.d.ts +26 -0
  306. package/dist/git/remotes/custom.d.ts.map +1 -0
  307. package/dist/git/remotes/custom.js +111 -0
  308. package/dist/git/remotes/custom.js.map +1 -0
  309. package/dist/git/remotes/gerrit.d.ts +31 -0
  310. package/dist/git/remotes/gerrit.d.ts.map +1 -0
  311. package/dist/git/remotes/gerrit.js +146 -0
  312. package/dist/git/remotes/gerrit.js.map +1 -0
  313. package/dist/git/remotes/gitea.d.ts +30 -0
  314. package/dist/git/remotes/gitea.d.ts.map +1 -0
  315. package/dist/git/remotes/gitea.js +148 -0
  316. package/dist/git/remotes/gitea.js.map +1 -0
  317. package/dist/git/remotes/github.d.ts +41 -0
  318. package/dist/git/remotes/github.d.ts.map +1 -0
  319. package/dist/git/remotes/github.js +198 -0
  320. package/dist/git/remotes/github.js.map +1 -0
  321. package/dist/git/remotes/gitlab.d.ts +35 -0
  322. package/dist/git/remotes/gitlab.d.ts.map +1 -0
  323. package/dist/git/remotes/gitlab.js +232 -0
  324. package/dist/git/remotes/gitlab.js.map +1 -0
  325. package/dist/git/remotes/google-source.d.ts +17 -0
  326. package/dist/git/remotes/google-source.d.ts.map +1 -0
  327. package/dist/git/remotes/google-source.js +32 -0
  328. package/dist/git/remotes/google-source.js.map +1 -0
  329. package/dist/git/remotes/matcher.d.ts +35 -0
  330. package/dist/git/remotes/matcher.d.ts.map +1 -0
  331. package/dist/git/remotes/matcher.js +140 -0
  332. package/dist/git/remotes/matcher.js.map +1 -0
  333. package/dist/git/repositoryService.d.ts +127 -0
  334. package/dist/git/repositoryService.d.ts.map +1 -0
  335. package/dist/git/repositoryService.js +54 -0
  336. package/dist/git/repositoryService.js.map +1 -0
  337. package/dist/git/service.d.ts +112 -0
  338. package/dist/git/service.d.ts.map +1 -0
  339. package/dist/git/service.js +303 -0
  340. package/dist/git/service.js.map +1 -0
  341. package/dist/git/utils/autolink.utils.d.ts +13 -0
  342. package/dist/git/utils/autolink.utils.d.ts.map +1 -0
  343. package/dist/git/utils/autolink.utils.js +147 -0
  344. package/dist/git/utils/autolink.utils.js.map +1 -0
  345. package/dist/git/utils/blame.utils.d.ts +47 -0
  346. package/dist/git/utils/blame.utils.d.ts.map +1 -0
  347. package/dist/git/utils/blame.utils.js +239 -0
  348. package/dist/git/utils/blame.utils.js.map +1 -0
  349. package/dist/git/utils/branch.utils.d.ts +22 -0
  350. package/dist/git/utils/branch.utils.d.ts.map +1 -0
  351. package/dist/git/utils/branch.utils.js +122 -0
  352. package/dist/git/utils/branch.utils.js.map +1 -0
  353. package/dist/git/utils/commit.utils.d.ts +26 -0
  354. package/dist/git/utils/commit.utils.d.ts.map +1 -0
  355. package/dist/git/utils/commit.utils.js +54 -0
  356. package/dist/git/utils/commit.utils.js.map +1 -0
  357. package/dist/git/utils/contributor.utils.d.ts +15 -0
  358. package/dist/git/utils/contributor.utils.d.ts.map +1 -0
  359. package/dist/git/utils/contributor.utils.js +55 -0
  360. package/dist/git/utils/contributor.utils.js.map +1 -0
  361. package/dist/git/utils/fetch.utils.d.ts +20 -0
  362. package/dist/git/utils/fetch.utils.d.ts.map +1 -0
  363. package/dist/git/utils/fetch.utils.js +47 -0
  364. package/dist/git/utils/fetch.utils.js.map +1 -0
  365. package/dist/git/utils/fileStatus.utils.d.ts +24 -0
  366. package/dist/git/utils/fileStatus.utils.d.ts.map +1 -0
  367. package/dist/git/utils/fileStatus.utils.js +45 -0
  368. package/dist/git/utils/fileStatus.utils.js.map +1 -0
  369. package/dist/git/utils/issue.utils.d.ts +4 -0
  370. package/dist/git/utils/issue.utils.d.ts.map +1 -0
  371. package/dist/git/utils/issue.utils.js +76 -0
  372. package/dist/git/utils/issue.utils.js.map +1 -0
  373. package/dist/git/utils/issueOrPullRequest.utils.d.ts +3 -0
  374. package/dist/git/utils/issueOrPullRequest.utils.d.ts.map +1 -0
  375. package/dist/git/utils/issueOrPullRequest.utils.js +22 -0
  376. package/dist/git/utils/issueOrPullRequest.utils.js.map +1 -0
  377. package/dist/git/utils/mergeConflicts.utils.d.ts +3 -0
  378. package/dist/git/utils/mergeConflicts.utils.d.ts.map +1 -0
  379. package/dist/git/utils/mergeConflicts.utils.js +19 -0
  380. package/dist/git/utils/mergeConflicts.utils.js.map +1 -0
  381. package/dist/git/utils/pausedOperationStatus.utils.d.ts +58 -0
  382. package/dist/git/utils/pausedOperationStatus.utils.d.ts.map +1 -0
  383. package/dist/git/utils/pausedOperationStatus.utils.js +133 -0
  384. package/dist/git/utils/pausedOperationStatus.utils.js.map +1 -0
  385. package/dist/git/utils/pullRequest.utils.d.ts +12 -0
  386. package/dist/git/utils/pullRequest.utils.d.ts.map +1 -0
  387. package/dist/git/utils/pullRequest.utils.js +124 -0
  388. package/dist/git/utils/pullRequest.utils.js.map +1 -0
  389. package/dist/git/utils/rebase.utils.d.ts +19 -0
  390. package/dist/git/utils/rebase.utils.d.ts.map +1 -0
  391. package/dist/git/utils/rebase.utils.js +93 -0
  392. package/dist/git/utils/rebase.utils.js.map +1 -0
  393. package/dist/git/utils/reference.utils.d.ts +56 -0
  394. package/dist/git/utils/reference.utils.d.ts.map +1 -0
  395. package/dist/git/utils/reference.utils.js +191 -0
  396. package/dist/git/utils/reference.utils.js.map +1 -0
  397. package/dist/git/utils/remote.utils.d.ts +17 -0
  398. package/dist/git/utils/remote.utils.d.ts.map +1 -0
  399. package/dist/git/utils/remote.utils.js +124 -0
  400. package/dist/git/utils/remote.utils.js.map +1 -0
  401. package/dist/git/utils/repository.utils.d.ts +5 -0
  402. package/dist/git/utils/repository.utils.d.ts.map +1 -0
  403. package/dist/git/utils/repository.utils.js +15 -0
  404. package/dist/git/utils/repository.utils.js.map +1 -0
  405. package/dist/git/utils/resourceDescriptor.utils.d.ts +4 -0
  406. package/dist/git/utils/resourceDescriptor.utils.d.ts.map +1 -0
  407. package/dist/git/utils/resourceDescriptor.utils.js +17 -0
  408. package/dist/git/utils/resourceDescriptor.utils.js.map +1 -0
  409. package/dist/git/utils/revision.utils.d.ts +36 -0
  410. package/dist/git/utils/revision.utils.d.ts.map +1 -0
  411. package/dist/git/utils/revision.utils.js +114 -0
  412. package/dist/git/utils/revision.utils.js.map +1 -0
  413. package/dist/git/utils/search.utils.d.ts +15 -0
  414. package/dist/git/utils/search.utils.d.ts.map +1 -0
  415. package/dist/git/utils/search.utils.js +422 -0
  416. package/dist/git/utils/search.utils.js.map +1 -0
  417. package/dist/git/utils/sorting.d.ts +34 -0
  418. package/dist/git/utils/sorting.d.ts.map +1 -0
  419. package/dist/git/utils/sorting.js +203 -0
  420. package/dist/git/utils/sorting.js.map +1 -0
  421. package/dist/git/utils/status.utils.d.ts +20 -0
  422. package/dist/git/utils/status.utils.d.ts.map +1 -0
  423. package/dist/git/utils/status.utils.js +82 -0
  424. package/dist/git/utils/status.utils.js.map +1 -0
  425. package/dist/git/utils/statusFile.utils.d.ts +8 -0
  426. package/dist/git/utils/statusFile.utils.d.ts.map +1 -0
  427. package/dist/git/utils/statusFile.utils.js +76 -0
  428. package/dist/git/utils/statusFile.utils.js.map +1 -0
  429. package/dist/git/utils/tag.utils.d.ts +7 -0
  430. package/dist/git/utils/tag.utils.d.ts.map +1 -0
  431. package/dist/git/utils/tag.utils.js +13 -0
  432. package/dist/git/utils/tag.utils.js.map +1 -0
  433. package/dist/git/utils/tooltip.utils.d.ts +14 -0
  434. package/dist/git/utils/tooltip.utils.d.ts.map +1 -0
  435. package/dist/git/utils/tooltip.utils.js +29 -0
  436. package/dist/git/utils/tooltip.utils.js.map +1 -0
  437. package/dist/git/utils/uriAuthority.d.ts +16 -0
  438. package/dist/git/utils/uriAuthority.d.ts.map +1 -0
  439. package/dist/git/utils/uriAuthority.js +20 -0
  440. package/dist/git/utils/uriAuthority.js.map +1 -0
  441. package/dist/git/utils/user.utils.d.ts +3 -0
  442. package/dist/git/utils/user.utils.d.ts.map +1 -0
  443. package/dist/git/utils/user.utils.js +12 -0
  444. package/dist/git/utils/user.utils.js.map +1 -0
  445. package/dist/git/utils/worktree.utils.d.ts +7 -0
  446. package/dist/git/utils/worktree.utils.d.ts.map +1 -0
  447. package/dist/git/utils/worktree.utils.js +15 -0
  448. package/dist/git/utils/worktree.utils.js.map +1 -0
  449. package/dist/git/watching/changeEvent.d.ts +47 -0
  450. package/dist/git/watching/changeEvent.d.ts.map +1 -0
  451. package/dist/git/watching/changeEvent.js +69 -0
  452. package/dist/git/watching/changeEvent.js.map +1 -0
  453. package/dist/git/watching/classifyChange.d.ts +16 -0
  454. package/dist/git/watching/classifyChange.d.ts.map +1 -0
  455. package/dist/git/watching/classifyChange.js +61 -0
  456. package/dist/git/watching/classifyChange.js.map +1 -0
  457. package/dist/git/watching/gitIgnoreFilter.d.ts +58 -0
  458. package/dist/git/watching/gitIgnoreFilter.d.ts.map +1 -0
  459. package/dist/git/watching/gitIgnoreFilter.js +109 -0
  460. package/dist/git/watching/gitIgnoreFilter.js.map +1 -0
  461. package/dist/git/watching/initWatcher.d.ts +33 -0
  462. package/dist/git/watching/initWatcher.d.ts.map +1 -0
  463. package/dist/git/watching/initWatcher.js +59 -0
  464. package/dist/git/watching/initWatcher.js.map +1 -0
  465. package/dist/git/watching/provider.d.ts +23 -0
  466. package/dist/git/watching/provider.d.ts.map +1 -0
  467. package/dist/git/watching/provider.js +2 -0
  468. package/dist/git/watching/provider.js.map +1 -0
  469. package/dist/git/watching/watchGroup.d.ts +54 -0
  470. package/dist/git/watching/watchGroup.d.ts.map +1 -0
  471. package/dist/git/watching/watchGroup.js +139 -0
  472. package/dist/git/watching/watchGroup.js.map +1 -0
  473. package/dist/git/watching/watchService.d.ts +79 -0
  474. package/dist/git/watching/watchService.d.ts.map +1 -0
  475. package/dist/git/watching/watchService.js +282 -0
  476. package/dist/git/watching/watchService.js.map +1 -0
  477. package/dist/git/watching/watchSession.d.ts +118 -0
  478. package/dist/git/watching/watchSession.d.ts.map +1 -0
  479. package/dist/git/watching/watchSession.js +274 -0
  480. package/dist/git/watching/watchSession.js.map +1 -0
  481. package/dist/git/watching/watcherPatterns.d.ts +21 -0
  482. package/dist/git/watching/watcherPatterns.d.ts.map +1 -0
  483. package/dist/git/watching/watcherPatterns.js +36 -0
  484. package/dist/git/watching/watcherPatterns.js.map +1 -0
  485. package/dist/git-cli/cliGitProvider.d.ts +133 -0
  486. package/dist/git-cli/cliGitProvider.d.ts.map +1 -0
  487. package/dist/git-cli/cliGitProvider.js +273 -0
  488. package/dist/git-cli/cliGitProvider.js.map +1 -0
  489. package/dist/git-cli/exec/exec.d.ts +4 -0
  490. package/dist/git-cli/exec/exec.d.ts.map +1 -0
  491. package/dist/git-cli/exec/exec.errors.d.ts +2 -0
  492. package/dist/git-cli/exec/exec.errors.d.ts.map +1 -0
  493. package/dist/git-cli/exec/exec.errors.js +2 -0
  494. package/dist/git-cli/exec/exec.errors.js.map +1 -0
  495. package/dist/git-cli/exec/exec.js +3 -0
  496. package/dist/git-cli/exec/exec.js.map +1 -0
  497. package/dist/git-cli/exec/exec.types.d.ts +2 -0
  498. package/dist/git-cli/exec/exec.types.d.ts.map +1 -0
  499. package/dist/git-cli/exec/exec.types.js +2 -0
  500. package/dist/git-cli/exec/exec.types.js.map +1 -0
  501. package/dist/git-cli/exec/features.d.ts +3 -0
  502. package/dist/git-cli/exec/features.d.ts.map +1 -0
  503. package/dist/git-cli/exec/features.js +2 -0
  504. package/dist/git-cli/exec/features.js.map +1 -0
  505. package/dist/git-cli/exec/git.d.ts +228 -0
  506. package/dist/git-cli/exec/git.d.ts.map +1 -0
  507. package/dist/git-cli/exec/git.js +823 -0
  508. package/dist/git-cli/exec/git.js.map +1 -0
  509. package/dist/git-cli/exec/gitQueue.d.ts +68 -0
  510. package/dist/git-cli/exec/gitQueue.d.ts.map +1 -0
  511. package/dist/git-cli/exec/gitQueue.js +207 -0
  512. package/dist/git-cli/exec/gitQueue.js.map +1 -0
  513. package/dist/git-cli/exec/locator.d.ts +14 -0
  514. package/dist/git-cli/exec/locator.d.ts.map +1 -0
  515. package/dist/git-cli/exec/locator.js +133 -0
  516. package/dist/git-cli/exec/locator.js.map +1 -0
  517. package/dist/git-cli/parsers/blameParser.d.ts +30 -0
  518. package/dist/git-cli/parsers/blameParser.d.ts.map +1 -0
  519. package/dist/git-cli/parsers/blameParser.js +339 -0
  520. package/dist/git-cli/parsers/blameParser.js.map +1 -0
  521. package/dist/git-cli/parsers/indexParser.d.ts +4 -0
  522. package/dist/git-cli/parsers/indexParser.d.ts.map +1 -0
  523. package/dist/git-cli/parsers/indexParser.js +226 -0
  524. package/dist/git-cli/parsers/indexParser.js.map +1 -0
  525. package/dist/git-cli/parsers/logParser.d.ts +178 -0
  526. package/dist/git-cli/parsers/logParser.d.ts.map +1 -0
  527. package/dist/git-cli/parsers/logParser.js +1166 -0
  528. package/dist/git-cli/parsers/logParser.js.map +1 -0
  529. package/dist/git-cli/parsers/mergeTreeParser.d.ts +7 -0
  530. package/dist/git-cli/parsers/mergeTreeParser.d.ts.map +1 -0
  531. package/dist/git-cli/parsers/mergeTreeParser.js +74 -0
  532. package/dist/git-cli/parsers/mergeTreeParser.js.map +1 -0
  533. package/dist/git-cli/parsers/refParser.d.ts +34 -0
  534. package/dist/git-cli/parsers/refParser.d.ts.map +1 -0
  535. package/dist/git-cli/parsers/refParser.js +148 -0
  536. package/dist/git-cli/parsers/refParser.js.map +1 -0
  537. package/dist/git-cli/parsers/reflogParser.d.ts +12 -0
  538. package/dist/git-cli/parsers/reflogParser.d.ts.map +1 -0
  539. package/dist/git-cli/parsers/reflogParser.js +181 -0
  540. package/dist/git-cli/parsers/reflogParser.js.map +1 -0
  541. package/dist/git-cli/parsers/remoteParser.d.ts +4 -0
  542. package/dist/git-cli/parsers/remoteParser.d.ts.map +1 -0
  543. package/dist/git-cli/parsers/remoteParser.js +128 -0
  544. package/dist/git-cli/parsers/remoteParser.js.map +1 -0
  545. package/dist/git-cli/parsers/shortlogParser.d.ts +4 -0
  546. package/dist/git-cli/parsers/shortlogParser.d.ts.map +1 -0
  547. package/dist/git-cli/parsers/shortlogParser.js +51 -0
  548. package/dist/git-cli/parsers/shortlogParser.js.map +1 -0
  549. package/dist/git-cli/parsers/signatureParser.d.ts +21 -0
  550. package/dist/git-cli/parsers/signatureParser.d.ts.map +1 -0
  551. package/dist/git-cli/parsers/signatureParser.js +139 -0
  552. package/dist/git-cli/parsers/signatureParser.js.map +1 -0
  553. package/dist/git-cli/parsers/statusParser.d.ts +4 -0
  554. package/dist/git-cli/parsers/statusParser.d.ts.map +1 -0
  555. package/dist/git-cli/parsers/statusParser.js +216 -0
  556. package/dist/git-cli/parsers/statusParser.js.map +1 -0
  557. package/dist/git-cli/parsers/treeParser.d.ts +3 -0
  558. package/dist/git-cli/parsers/treeParser.d.ts.map +1 -0
  559. package/dist/git-cli/parsers/treeParser.js +110 -0
  560. package/dist/git-cli/parsers/treeParser.js.map +1 -0
  561. package/dist/git-cli/parsers/worktreeParser.d.ts +5 -0
  562. package/dist/git-cli/parsers/worktreeParser.d.ts.map +1 -0
  563. package/dist/git-cli/parsers/worktreeParser.js +136 -0
  564. package/dist/git-cli/parsers/worktreeParser.js.map +1 -0
  565. package/dist/git-cli/providers/blame.d.ts +26 -0
  566. package/dist/git-cli/providers/blame.d.ts.map +1 -0
  567. package/dist/git-cli/providers/blame.js +426 -0
  568. package/dist/git-cli/providers/blame.js.map +1 -0
  569. package/dist/git-cli/providers/branches.d.ts +87 -0
  570. package/dist/git-cli/providers/branches.d.ts.map +1 -0
  571. package/dist/git-cli/providers/branches.js +1153 -0
  572. package/dist/git-cli/providers/branches.js.map +1 -0
  573. package/dist/git-cli/providers/commitFilesetUtils.d.ts +4 -0
  574. package/dist/git-cli/providers/commitFilesetUtils.d.ts.map +1 -0
  575. package/dist/git-cli/providers/commitFilesetUtils.js +20 -0
  576. package/dist/git-cli/providers/commitFilesetUtils.js.map +1 -0
  577. package/dist/git-cli/providers/commits.d.ts +49 -0
  578. package/dist/git-cli/providers/commits.d.ts.map +1 -0
  579. package/dist/git-cli/providers/commits.js +1151 -0
  580. package/dist/git-cli/providers/commits.js.map +1 -0
  581. package/dist/git-cli/providers/config.d.ts +74 -0
  582. package/dist/git-cli/providers/config.d.ts.map +1 -0
  583. package/dist/git-cli/providers/config.js +588 -0
  584. package/dist/git-cli/providers/config.js.map +1 -0
  585. package/dist/git-cli/providers/contributors.d.ts +31 -0
  586. package/dist/git-cli/providers/contributors.d.ts.map +1 -0
  587. package/dist/git-cli/providers/contributors.js +350 -0
  588. package/dist/git-cli/providers/contributors.js.map +1 -0
  589. package/dist/git-cli/providers/diff.d.ts +99 -0
  590. package/dist/git-cli/providers/diff.d.ts.map +1 -0
  591. package/dist/git-cli/providers/diff.js +786 -0
  592. package/dist/git-cli/providers/diff.js.map +1 -0
  593. package/dist/git-cli/providers/graph.d.ts +31 -0
  594. package/dist/git-cli/providers/graph.d.ts.map +1 -0
  595. package/dist/git-cli/providers/graph.js +703 -0
  596. package/dist/git-cli/providers/graph.js.map +1 -0
  597. package/dist/git-cli/providers/operations.d.ts +75 -0
  598. package/dist/git-cli/providers/operations.d.ts.map +1 -0
  599. package/dist/git-cli/providers/operations.js +564 -0
  600. package/dist/git-cli/providers/operations.js.map +1 -0
  601. package/dist/git-cli/providers/patch.d.ts +38 -0
  602. package/dist/git-cli/providers/patch.d.ts.map +1 -0
  603. package/dist/git-cli/providers/patch.js +324 -0
  604. package/dist/git-cli/providers/patch.js.map +1 -0
  605. package/dist/git-cli/providers/pausedOperations.d.ts +22 -0
  606. package/dist/git-cli/providers/pausedOperations.d.ts.map +1 -0
  607. package/dist/git-cli/providers/pausedOperations.js +411 -0
  608. package/dist/git-cli/providers/pausedOperations.js.map +1 -0
  609. package/dist/git-cli/providers/refs.d.ts +32 -0
  610. package/dist/git-cli/providers/refs.d.ts.map +1 -0
  611. package/dist/git-cli/providers/refs.js +149 -0
  612. package/dist/git-cli/providers/refs.js.map +1 -0
  613. package/dist/git-cli/providers/remotes.d.ts +24 -0
  614. package/dist/git-cli/providers/remotes.d.ts.map +1 -0
  615. package/dist/git-cli/providers/remotes.js +94 -0
  616. package/dist/git-cli/providers/remotes.js.map +1 -0
  617. package/dist/git-cli/providers/revision.d.ts +27 -0
  618. package/dist/git-cli/providers/revision.d.ts.map +1 -0
  619. package/dist/git-cli/providers/revision.js +269 -0
  620. package/dist/git-cli/providers/revision.js.map +1 -0
  621. package/dist/git-cli/providers/staging.d.ts +24 -0
  622. package/dist/git-cli/providers/staging.d.ts.map +1 -0
  623. package/dist/git-cli/providers/staging.js +138 -0
  624. package/dist/git-cli/providers/staging.js.map +1 -0
  625. package/dist/git-cli/providers/stash.d.ts +55 -0
  626. package/dist/git-cli/providers/stash.d.ts.map +1 -0
  627. package/dist/git-cli/providers/stash.js +430 -0
  628. package/dist/git-cli/providers/stash.js.map +1 -0
  629. package/dist/git-cli/providers/status.d.ts +38 -0
  630. package/dist/git-cli/providers/status.d.ts.map +1 -0
  631. package/dist/git-cli/providers/status.js +352 -0
  632. package/dist/git-cli/providers/status.js.map +1 -0
  633. package/dist/git-cli/providers/tags.d.ts +29 -0
  634. package/dist/git-cli/providers/tags.d.ts.map +1 -0
  635. package/dist/git-cli/providers/tags.js +190 -0
  636. package/dist/git-cli/providers/tags.js.map +1 -0
  637. package/dist/git-cli/providers/worktrees.d.ts +33 -0
  638. package/dist/git-cli/providers/worktrees.d.ts.map +1 -0
  639. package/dist/git-cli/providers/worktrees.js +175 -0
  640. package/dist/git-cli/providers/worktrees.js.map +1 -0
  641. package/dist/git-cli/service.d.ts +52 -0
  642. package/dist/git-cli/service.d.ts.map +1 -0
  643. package/dist/git-cli/service.js +35 -0
  644. package/dist/git-cli/service.js.map +1 -0
  645. package/dist/plus/ai/constants.d.ts +21 -0
  646. package/dist/plus/ai/constants.d.ts.map +1 -0
  647. package/dist/plus/ai/constants.js +99 -0
  648. package/dist/plus/ai/constants.js.map +1 -0
  649. package/dist/plus/ai/errors.d.ts +25 -0
  650. package/dist/plus/ai/errors.d.ts.map +1 -0
  651. package/dist/plus/ai/errors.js +76 -0
  652. package/dist/plus/ai/errors.js.map +1 -0
  653. package/dist/plus/ai/models/conversation.d.ts +12 -0
  654. package/dist/plus/ai/models/conversation.d.ts.map +1 -0
  655. package/dist/plus/ai/models/conversation.js +27 -0
  656. package/dist/plus/ai/models/conversation.js.map +1 -0
  657. package/dist/plus/ai/models/model.d.ts +34 -0
  658. package/dist/plus/ai/models/model.d.ts.map +1 -0
  659. package/dist/plus/ai/models/model.js +379 -0
  660. package/dist/plus/ai/models/model.js.map +1 -0
  661. package/dist/plus/ai/models/promptTemplates.d.ts +74 -0
  662. package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -0
  663. package/dist/plus/ai/models/promptTemplates.js +2 -0
  664. package/dist/plus/ai/models/promptTemplates.js.map +1 -0
  665. package/dist/plus/ai/models/provider.d.ts +46 -0
  666. package/dist/plus/ai/models/provider.d.ts.map +1 -0
  667. package/dist/plus/ai/models/provider.js +2 -0
  668. package/dist/plus/ai/models/provider.js.map +1 -0
  669. package/dist/plus/ai/models/results.d.ts +5 -0
  670. package/dist/plus/ai/models/results.d.ts.map +1 -0
  671. package/dist/plus/ai/models/results.js +2 -0
  672. package/dist/plus/ai/models/results.js.map +1 -0
  673. package/dist/plus/ai/prompts.d.ts +13 -0
  674. package/dist/plus/ai/prompts.d.ts.map +1 -0
  675. package/dist/plus/ai/prompts.js +517 -0
  676. package/dist/plus/ai/prompts.js.map +1 -0
  677. package/dist/plus/ai/providers/anthropicProvider.d.ts +21 -0
  678. package/dist/plus/ai/providers/anthropicProvider.d.ts.map +1 -0
  679. package/dist/plus/ai/providers/anthropicProvider.js +257 -0
  680. package/dist/plus/ai/providers/anthropicProvider.js.map +1 -0
  681. package/dist/plus/ai/providers/azureProvider.d.ts +18 -0
  682. package/dist/plus/ai/providers/azureProvider.d.ts.map +1 -0
  683. package/dist/plus/ai/providers/azureProvider.js +54 -0
  684. package/dist/plus/ai/providers/azureProvider.js.map +1 -0
  685. package/dist/plus/ai/providers/context.d.ts +23 -0
  686. package/dist/plus/ai/providers/context.d.ts.map +1 -0
  687. package/dist/plus/ai/providers/context.js +2 -0
  688. package/dist/plus/ai/providers/context.js.map +1 -0
  689. package/dist/plus/ai/providers/deepSeekProvider.d.ts +15 -0
  690. package/dist/plus/ai/providers/deepSeekProvider.d.ts.map +1 -0
  691. package/dist/plus/ai/providers/deepSeekProvider.js +35 -0
  692. package/dist/plus/ai/providers/deepSeekProvider.js.map +1 -0
  693. package/dist/plus/ai/providers/geminiProvider.d.ts +15 -0
  694. package/dist/plus/ai/providers/geminiProvider.d.ts.map +1 -0
  695. package/dist/plus/ai/providers/geminiProvider.js +195 -0
  696. package/dist/plus/ai/providers/geminiProvider.js.map +1 -0
  697. package/dist/plus/ai/providers/githubModelsProvider.d.ts +19 -0
  698. package/dist/plus/ai/providers/githubModelsProvider.d.ts.map +1 -0
  699. package/dist/plus/ai/providers/githubModelsProvider.js +51 -0
  700. package/dist/plus/ai/providers/githubModelsProvider.js.map +1 -0
  701. package/dist/plus/ai/providers/gitkrakenProvider.d.ts +18 -0
  702. package/dist/plus/ai/providers/gitkrakenProvider.d.ts.map +1 -0
  703. package/dist/plus/ai/providers/gitkrakenProvider.js +151 -0
  704. package/dist/plus/ai/providers/gitkrakenProvider.js.map +1 -0
  705. package/dist/plus/ai/providers/huggingFaceProvider.d.ts +15 -0
  706. package/dist/plus/ai/providers/huggingFaceProvider.d.ts.map +1 -0
  707. package/dist/plus/ai/providers/huggingFaceProvider.js +39 -0
  708. package/dist/plus/ai/providers/huggingFaceProvider.js.map +1 -0
  709. package/dist/plus/ai/providers/mistralProvider.d.ts +20 -0
  710. package/dist/plus/ai/providers/mistralProvider.d.ts.map +1 -0
  711. package/dist/plus/ai/providers/mistralProvider.js +118 -0
  712. package/dist/plus/ai/providers/mistralProvider.js.map +1 -0
  713. package/dist/plus/ai/providers/ollamaProvider.d.ts +25 -0
  714. package/dist/plus/ai/providers/ollamaProvider.d.ts.map +1 -0
  715. package/dist/plus/ai/providers/ollamaProvider.js +155 -0
  716. package/dist/plus/ai/providers/ollamaProvider.js.map +1 -0
  717. package/dist/plus/ai/providers/openAICompatibleProvider.d.ts +17 -0
  718. package/dist/plus/ai/providers/openAICompatibleProvider.d.ts.map +1 -0
  719. package/dist/plus/ai/providers/openAICompatibleProvider.js +47 -0
  720. package/dist/plus/ai/providers/openAICompatibleProvider.js.map +1 -0
  721. package/dist/plus/ai/providers/openAICompatibleProviderBase.d.ts +39 -0
  722. package/dist/plus/ai/providers/openAICompatibleProviderBase.d.ts.map +1 -0
  723. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +218 -0
  724. package/dist/plus/ai/providers/openAICompatibleProviderBase.js.map +1 -0
  725. package/dist/plus/ai/providers/openRouterProvider.d.ts +17 -0
  726. package/dist/plus/ai/providers/openRouterProvider.d.ts.map +1 -0
  727. package/dist/plus/ai/providers/openRouterProvider.js +57 -0
  728. package/dist/plus/ai/providers/openRouterProvider.js.map +1 -0
  729. package/dist/plus/ai/providers/openaiProvider.d.ts +16 -0
  730. package/dist/plus/ai/providers/openaiProvider.d.ts.map +1 -0
  731. package/dist/plus/ai/providers/openaiProvider.js +34 -0
  732. package/dist/plus/ai/providers/openaiProvider.js.map +1 -0
  733. package/dist/plus/ai/providers/xaiProvider.d.ts +15 -0
  734. package/dist/plus/ai/providers/xaiProvider.d.ts.map +1 -0
  735. package/dist/plus/ai/providers/xaiProvider.js +27 -0
  736. package/dist/plus/ai/providers/xaiProvider.js.map +1 -0
  737. package/dist/plus/ai/utils/ai.utils.d.ts +18 -0
  738. package/dist/plus/ai/utils/ai.utils.d.ts.map +1 -0
  739. package/dist/plus/ai/utils/ai.utils.js +70 -0
  740. package/dist/plus/ai/utils/ai.utils.js.map +1 -0
  741. package/dist/plus/ai/utils/results.utils.d.ts +9 -0
  742. package/dist/plus/ai/utils/results.utils.d.ts.map +1 -0
  743. package/dist/plus/ai/utils/results.utils.js +44 -0
  744. package/dist/plus/ai/utils/results.utils.js.map +1 -0
  745. package/dist/plus/ai/utils/truncation.utils.d.ts +13 -0
  746. package/dist/plus/ai/utils/truncation.utils.d.ts.map +1 -0
  747. package/dist/plus/ai/utils/truncation.utils.js +228 -0
  748. package/dist/plus/ai/utils/truncation.utils.js.map +1 -0
  749. package/dist/plus/git-github/api/config.d.ts +66 -0
  750. package/dist/plus/git-github/api/config.d.ts.map +1 -0
  751. package/dist/plus/git-github/api/config.js +2 -0
  752. package/dist/plus/git-github/api/config.js.map +1 -0
  753. package/dist/plus/git-github/api/github.d.ts +178 -0
  754. package/dist/plus/git-github/api/github.d.ts.map +1 -0
  755. package/dist/plus/git-github/api/github.js +2360 -0
  756. package/dist/plus/git-github/api/github.js.map +1 -0
  757. package/dist/plus/git-github/api/github.utils.d.ts +9 -0
  758. package/dist/plus/git-github/api/github.utils.d.ts.map +1 -0
  759. package/dist/plus/git-github/api/github.utils.js +22 -0
  760. package/dist/plus/git-github/api/github.utils.js.map +1 -0
  761. package/dist/plus/git-github/api/token.d.ts +16 -0
  762. package/dist/plus/git-github/api/token.d.ts.map +1 -0
  763. package/dist/plus/git-github/api/token.js +2 -0
  764. package/dist/plus/git-github/api/token.js.map +1 -0
  765. package/dist/plus/git-github/api/tokenUtils.d.ts +7 -0
  766. package/dist/plus/git-github/api/tokenUtils.d.ts.map +1 -0
  767. package/dist/plus/git-github/api/tokenUtils.js +13 -0
  768. package/dist/plus/git-github/api/tokenUtils.js.map +1 -0
  769. package/dist/plus/git-github/api/types.d.ts +100 -0
  770. package/dist/plus/git-github/api/types.d.ts.map +1 -0
  771. package/dist/plus/git-github/api/types.js +2 -0
  772. package/dist/plus/git-github/api/types.js.map +1 -0
  773. package/dist/plus/git-github/context.d.ts +102 -0
  774. package/dist/plus/git-github/context.d.ts.map +1 -0
  775. package/dist/plus/git-github/context.js +12 -0
  776. package/dist/plus/git-github/context.js.map +1 -0
  777. package/dist/plus/git-github/models.d.ts +204 -0
  778. package/dist/plus/git-github/models.d.ts.map +1 -0
  779. package/dist/plus/git-github/models.js +229 -0
  780. package/dist/plus/git-github/models.js.map +1 -0
  781. package/dist/plus/git-github/providers/github/blame.d.ts +34 -0
  782. package/dist/plus/git-github/providers/github/blame.d.ts.map +1 -0
  783. package/dist/plus/git-github/providers/github/blame.js +155 -0
  784. package/dist/plus/git-github/providers/github/blame.js.map +1 -0
  785. package/dist/plus/git-github/providers/github/branches.d.ts +38 -0
  786. package/dist/plus/git-github/providers/github/branches.d.ts.map +1 -0
  787. package/dist/plus/git-github/providers/github/branches.js +234 -0
  788. package/dist/plus/git-github/providers/github/branches.js.map +1 -0
  789. package/dist/plus/git-github/providers/github/commits.d.ts +36 -0
  790. package/dist/plus/git-github/providers/github/commits.d.ts.map +1 -0
  791. package/dist/plus/git-github/providers/github/commits.js +560 -0
  792. package/dist/plus/git-github/providers/github/commits.js.map +1 -0
  793. package/dist/plus/git-github/providers/github/config.d.ts +11 -0
  794. package/dist/plus/git-github/providers/github/config.d.ts.map +1 -0
  795. package/dist/plus/git-github/providers/github/config.js +47 -0
  796. package/dist/plus/git-github/providers/github/config.js.map +1 -0
  797. package/dist/plus/git-github/providers/github/contributors.d.ts +27 -0
  798. package/dist/plus/git-github/providers/github/contributors.d.ts.map +1 -0
  799. package/dist/plus/git-github/providers/github/contributors.js +218 -0
  800. package/dist/plus/git-github/providers/github/contributors.js.map +1 -0
  801. package/dist/plus/git-github/providers/github/diff.d.ts +33 -0
  802. package/dist/plus/git-github/providers/github/diff.d.ts.map +1 -0
  803. package/dist/plus/git-github/providers/github/diff.js +184 -0
  804. package/dist/plus/git-github/providers/github/diff.js.map +1 -0
  805. package/dist/plus/git-github/providers/github/graph.d.ts +25 -0
  806. package/dist/plus/git-github/providers/github/graph.d.ts.map +1 -0
  807. package/dist/plus/git-github/providers/github/graph.js +372 -0
  808. package/dist/plus/git-github/providers/github/graph.js.map +1 -0
  809. package/dist/plus/git-github/providers/github/refs.d.ts +26 -0
  810. package/dist/plus/git-github/providers/github/refs.d.ts.map +1 -0
  811. package/dist/plus/git-github/providers/github/refs.js +108 -0
  812. package/dist/plus/git-github/providers/github/refs.js.map +1 -0
  813. package/dist/plus/git-github/providers/github/remotes.d.ts +9 -0
  814. package/dist/plus/git-github/providers/github/remotes.d.ts.map +1 -0
  815. package/dist/plus/git-github/providers/github/remotes.js +37 -0
  816. package/dist/plus/git-github/providers/github/remotes.js.map +1 -0
  817. package/dist/plus/git-github/providers/github/revision.d.ts +14 -0
  818. package/dist/plus/git-github/providers/github/revision.d.ts.map +1 -0
  819. package/dist/plus/git-github/providers/github/revision.js +132 -0
  820. package/dist/plus/git-github/providers/github/revision.js.map +1 -0
  821. package/dist/plus/git-github/providers/github/status.d.ts +21 -0
  822. package/dist/plus/git-github/providers/github/status.d.ts.map +1 -0
  823. package/dist/plus/git-github/providers/github/status.js +49 -0
  824. package/dist/plus/git-github/providers/github/status.js.map +1 -0
  825. package/dist/plus/git-github/providers/github/tags.d.ts +22 -0
  826. package/dist/plus/git-github/providers/github/tags.d.ts.map +1 -0
  827. package/dist/plus/git-github/providers/github/tags.js +104 -0
  828. package/dist/plus/git-github/providers/github/tags.js.map +1 -0
  829. package/dist/plus/git-github/providers/githubGitProvider.d.ts +85 -0
  830. package/dist/plus/git-github/providers/githubGitProvider.d.ts.map +1 -0
  831. package/dist/plus/git-github/providers/githubGitProvider.js +130 -0
  832. package/dist/plus/git-github/providers/githubGitProvider.js.map +1 -0
  833. package/dist/plus/git-github/providers/githubProvider.d.ts +55 -0
  834. package/dist/plus/git-github/providers/githubProvider.d.ts.map +1 -0
  835. package/dist/plus/git-github/providers/githubProvider.js +2 -0
  836. package/dist/plus/git-github/providers/githubProvider.js.map +1 -0
  837. package/dist/utils/array.d.ts +27 -0
  838. package/dist/utils/array.d.ts.map +1 -0
  839. package/dist/utils/array.js +142 -0
  840. package/dist/utils/array.js.map +1 -0
  841. package/dist/utils/base64.d.ts +2 -0
  842. package/dist/utils/base64.d.ts.map +1 -0
  843. package/dist/utils/base64.js +2 -0
  844. package/dist/utils/base64.js.map +1 -0
  845. package/dist/utils/brand.d.ts +11 -0
  846. package/dist/utils/brand.d.ts.map +1 -0
  847. package/dist/utils/brand.js +2 -0
  848. package/dist/utils/brand.js.map +1 -0
  849. package/dist/utils/cancellation.d.ts +54 -0
  850. package/dist/utils/cancellation.d.ts.map +1 -0
  851. package/dist/utils/cancellation.js +133 -0
  852. package/dist/utils/cancellation.js.map +1 -0
  853. package/dist/utils/charCode.d.ts +39 -0
  854. package/dist/utils/charCode.d.ts.map +1 -0
  855. package/dist/utils/charCode.js +39 -0
  856. package/dist/utils/charCode.js.map +1 -0
  857. package/dist/utils/color.d.ts +177 -0
  858. package/dist/utils/color.d.ts.map +1 -0
  859. package/dist/utils/color.js +693 -0
  860. package/dist/utils/color.js.map +1 -0
  861. package/dist/utils/counter.d.ts +7 -0
  862. package/dist/utils/counter.d.ts.map +1 -0
  863. package/dist/utils/counter.js +19 -0
  864. package/dist/utils/counter.js.map +1 -0
  865. package/dist/utils/crypto.d.ts +2 -0
  866. package/dist/utils/crypto.d.ts.map +1 -0
  867. package/dist/utils/crypto.js +2 -0
  868. package/dist/utils/crypto.js.map +1 -0
  869. package/dist/utils/date.d.ts +20 -0
  870. package/dist/utils/date.d.ts.map +1 -0
  871. package/dist/utils/date.js +313 -0
  872. package/dist/utils/date.js.map +1 -0
  873. package/dist/utils/debounce.d.ts +108 -0
  874. package/dist/utils/debounce.d.ts.map +1 -0
  875. package/dist/utils/debounce.js +209 -0
  876. package/dist/utils/debounce.js.map +1 -0
  877. package/dist/utils/decorators/debounce.d.ts +3 -0
  878. package/dist/utils/decorators/debounce.d.ts.map +1 -0
  879. package/dist/utils/decorators/debounce.js +21 -0
  880. package/dist/utils/decorators/debounce.js.map +1 -0
  881. package/dist/utils/decorators/gate.d.ts +15 -0
  882. package/dist/utils/decorators/gate.d.ts.map +1 -0
  883. package/dist/utils/decorators/gate.js +129 -0
  884. package/dist/utils/decorators/gate.js.map +1 -0
  885. package/dist/utils/decorators/log.d.ts +46 -0
  886. package/dist/utils/decorators/log.d.ts.map +1 -0
  887. package/dist/utils/decorators/log.js +238 -0
  888. package/dist/utils/decorators/log.js.map +1 -0
  889. package/dist/utils/decorators/memoize.d.ts +17 -0
  890. package/dist/utils/decorators/memoize.d.ts.map +1 -0
  891. package/dist/utils/decorators/memoize.js +63 -0
  892. package/dist/utils/decorators/memoize.js.map +1 -0
  893. package/dist/utils/decorators/resolver.d.ts +12 -0
  894. package/dist/utils/decorators/resolver.d.ts.map +1 -0
  895. package/dist/utils/decorators/resolver.js +85 -0
  896. package/dist/utils/decorators/resolver.js.map +1 -0
  897. package/dist/utils/decorators/sequentialize.d.ts +29 -0
  898. package/dist/utils/decorators/sequentialize.d.ts.map +1 -0
  899. package/dist/utils/decorators/sequentialize.js +81 -0
  900. package/dist/utils/decorators/sequentialize.js.map +1 -0
  901. package/dist/utils/decorators/serializable.d.ts +13 -0
  902. package/dist/utils/decorators/serializable.d.ts.map +1 -0
  903. package/dist/utils/decorators/serializable.js +42 -0
  904. package/dist/utils/decorators/serializable.js.map +1 -0
  905. package/dist/utils/disposable.d.ts +40 -0
  906. package/dist/utils/disposable.d.ts.map +1 -0
  907. package/dist/utils/disposable.js +87 -0
  908. package/dist/utils/disposable.js.map +1 -0
  909. package/dist/utils/encoding.d.ts +3 -0
  910. package/dist/utils/encoding.d.ts.map +1 -0
  911. package/dist/utils/encoding.js +7 -0
  912. package/dist/utils/encoding.js.map +1 -0
  913. package/dist/utils/env/browser/base64.d.ts +9 -0
  914. package/dist/utils/env/browser/base64.d.ts.map +1 -0
  915. package/dist/utils/env/browser/base64.js +42 -0
  916. package/dist/utils/env/browser/base64.js.map +1 -0
  917. package/dist/utils/env/browser/crypto.d.ts +5 -0
  918. package/dist/utils/env/browser/crypto.d.ts.map +1 -0
  919. package/dist/utils/env/browser/crypto.js +18 -0
  920. package/dist/utils/env/browser/crypto.js.map +1 -0
  921. package/dist/utils/env/browser/fs.d.ts +2 -0
  922. package/dist/utils/env/browser/fs.d.ts.map +1 -0
  923. package/dist/utils/env/browser/fs.js +4 -0
  924. package/dist/utils/env/browser/fs.js.map +1 -0
  925. package/dist/utils/env/browser/hex.d.ts +4 -0
  926. package/dist/utils/env/browser/hex.d.ts.map +1 -0
  927. package/dist/utils/env/browser/hex.js +38 -0
  928. package/dist/utils/env/browser/hex.js.map +1 -0
  929. package/dist/utils/env/browser/hrtime.d.ts +2 -0
  930. package/dist/utils/env/browser/hrtime.d.ts.map +1 -0
  931. package/dist/utils/env/browser/hrtime.js +15 -0
  932. package/dist/utils/env/browser/hrtime.js.map +1 -0
  933. package/dist/utils/env/browser/logScope.d.ts +25 -0
  934. package/dist/utils/env/browser/logScope.d.ts.map +1 -0
  935. package/dist/utils/env/browser/logScope.js +53 -0
  936. package/dist/utils/env/browser/logScope.js.map +1 -0
  937. package/dist/utils/env/browser/md5.d.ts +2 -0
  938. package/dist/utils/env/browser/md5.d.ts.map +1 -0
  939. package/dist/utils/env/browser/md5.js +199 -0
  940. package/dist/utils/env/browser/md5.js.map +1 -0
  941. package/dist/utils/env/browser/platform.d.ts +4 -0
  942. package/dist/utils/env/browser/platform.d.ts.map +1 -0
  943. package/dist/utils/env/browser/platform.js +6 -0
  944. package/dist/utils/env/browser/platform.js.map +1 -0
  945. package/dist/utils/env/node/base64.d.ts +9 -0
  946. package/dist/utils/env/node/base64.d.ts.map +1 -0
  947. package/dist/utils/env/node/base64.js +14 -0
  948. package/dist/utils/env/node/base64.js.map +1 -0
  949. package/dist/utils/env/node/crypto.d.ts +5 -0
  950. package/dist/utils/env/node/crypto.d.ts.map +1 -0
  951. package/dist/utils/env/node/crypto.js +14 -0
  952. package/dist/utils/env/node/crypto.js.map +1 -0
  953. package/dist/utils/env/node/exec.d.ts +89 -0
  954. package/dist/utils/env/node/exec.d.ts.map +1 -0
  955. package/dist/utils/env/node/exec.js +277 -0
  956. package/dist/utils/env/node/exec.js.map +1 -0
  957. package/dist/utils/env/node/fs.d.ts +2 -0
  958. package/dist/utils/env/node/fs.d.ts.map +1 -0
  959. package/dist/utils/env/node/fs.js +5 -0
  960. package/dist/utils/env/node/fs.js.map +1 -0
  961. package/dist/utils/env/node/hex.d.ts +4 -0
  962. package/dist/utils/env/node/hex.d.ts.map +1 -0
  963. package/dist/utils/env/node/hex.js +10 -0
  964. package/dist/utils/env/node/hex.js.map +1 -0
  965. package/dist/utils/env/node/hrtime.d.ts +2 -0
  966. package/dist/utils/env/node/hrtime.d.ts.map +1 -0
  967. package/dist/utils/env/node/hrtime.js +2 -0
  968. package/dist/utils/env/node/hrtime.js.map +1 -0
  969. package/dist/utils/env/node/logScope.d.ts +34 -0
  970. package/dist/utils/env/node/logScope.d.ts.map +1 -0
  971. package/dist/utils/env/node/logScope.js +52 -0
  972. package/dist/utils/env/node/logScope.js.map +1 -0
  973. package/dist/utils/env/node/platform.d.ts +4 -0
  974. package/dist/utils/env/node/platform.d.ts.map +1 -0
  975. package/dist/utils/env/node/platform.js +5 -0
  976. package/dist/utils/env/node/platform.js.map +1 -0
  977. package/dist/utils/error.d.ts +18 -0
  978. package/dist/utils/error.d.ts.map +1 -0
  979. package/dist/utils/error.js +19 -0
  980. package/dist/utils/error.js.map +1 -0
  981. package/dist/utils/event.d.ts +59 -0
  982. package/dist/utils/event.d.ts.map +1 -0
  983. package/dist/utils/event.js +183 -0
  984. package/dist/utils/event.js.map +1 -0
  985. package/dist/utils/formatter.d.ts +21 -0
  986. package/dist/utils/formatter.d.ts.map +1 -0
  987. package/dist/utils/formatter.js +139 -0
  988. package/dist/utils/formatter.js.map +1 -0
  989. package/dist/utils/fs.d.ts +2 -0
  990. package/dist/utils/fs.d.ts.map +1 -0
  991. package/dist/utils/fs.js +2 -0
  992. package/dist/utils/fs.js.map +1 -0
  993. package/dist/utils/function.d.ts +24 -0
  994. package/dist/utils/function.d.ts.map +1 -0
  995. package/dist/utils/function.js +103 -0
  996. package/dist/utils/function.js.map +1 -0
  997. package/dist/utils/fuzzy.d.ts +68 -0
  998. package/dist/utils/fuzzy.d.ts.map +1 -0
  999. package/dist/utils/fuzzy.js +134 -0
  1000. package/dist/utils/fuzzy.js.map +1 -0
  1001. package/dist/utils/hash.d.ts +32 -0
  1002. package/dist/utils/hash.d.ts.map +1 -0
  1003. package/dist/utils/hash.js +53 -0
  1004. package/dist/utils/hash.js.map +1 -0
  1005. package/dist/utils/hex.d.ts +2 -0
  1006. package/dist/utils/hex.d.ts.map +1 -0
  1007. package/dist/utils/hex.js +2 -0
  1008. package/dist/utils/hex.js.map +1 -0
  1009. package/dist/utils/hrtime.d.ts +4 -0
  1010. package/dist/utils/hrtime.d.ts.map +1 -0
  1011. package/dist/utils/hrtime.js +7 -0
  1012. package/dist/utils/hrtime.js.map +1 -0
  1013. package/dist/utils/iterable.d.ts +65 -0
  1014. package/dist/utils/iterable.d.ts.map +1 -0
  1015. package/dist/utils/iterable.js +635 -0
  1016. package/dist/utils/iterable.js.map +1 -0
  1017. package/dist/utils/lazy.d.ts +18 -0
  1018. package/dist/utils/lazy.d.ts.map +1 -0
  1019. package/dist/utils/lazy.js +40 -0
  1020. package/dist/utils/lazy.js.map +1 -0
  1021. package/dist/utils/loggable.d.ts +5 -0
  1022. package/dist/utils/loggable.d.ts.map +1 -0
  1023. package/dist/utils/loggable.js +4 -0
  1024. package/dist/utils/loggable.js.map +1 -0
  1025. package/dist/utils/logger.d.ts +63 -0
  1026. package/dist/utils/logger.d.ts.map +1 -0
  1027. package/dist/utils/logger.js +316 -0
  1028. package/dist/utils/logger.js.map +1 -0
  1029. package/dist/utils/logger.scoped.d.ts +56 -0
  1030. package/dist/utils/logger.scoped.d.ts.map +1 -0
  1031. package/dist/utils/logger.scoped.js +166 -0
  1032. package/dist/utils/logger.scoped.js.map +1 -0
  1033. package/dist/utils/markdown.d.ts +9 -0
  1034. package/dist/utils/markdown.d.ts.map +1 -0
  1035. package/dist/utils/markdown.js +100 -0
  1036. package/dist/utils/markdown.js.map +1 -0
  1037. package/dist/utils/mru.d.ts +14 -0
  1038. package/dist/utils/mru.d.ts.map +1 -0
  1039. package/dist/utils/mru.js +63 -0
  1040. package/dist/utils/mru.js.map +1 -0
  1041. package/dist/utils/object.d.ts +62 -0
  1042. package/dist/utils/object.d.ts.map +1 -0
  1043. package/dist/utils/object.js +151 -0
  1044. package/dist/utils/object.js.map +1 -0
  1045. package/dist/utils/paging.d.ts +19 -0
  1046. package/dist/utils/paging.d.ts.map +1 -0
  1047. package/dist/utils/paging.js +32 -0
  1048. package/dist/utils/paging.js.map +1 -0
  1049. package/dist/utils/path.d.ts +17 -0
  1050. package/dist/utils/path.d.ts.map +1 -0
  1051. package/dist/utils/path.js +156 -0
  1052. package/dist/utils/path.js.map +1 -0
  1053. package/dist/utils/platform.d.ts +2 -0
  1054. package/dist/utils/platform.d.ts.map +1 -0
  1055. package/dist/utils/platform.js +2 -0
  1056. package/dist/utils/platform.js.map +1 -0
  1057. package/dist/utils/promise.d.ts +61 -0
  1058. package/dist/utils/promise.d.ts.map +1 -0
  1059. package/dist/utils/promise.js +337 -0
  1060. package/dist/utils/promise.js.map +1 -0
  1061. package/dist/utils/promiseCache.d.ts +337 -0
  1062. package/dist/utils/promiseCache.d.ts.map +1 -0
  1063. package/dist/utils/promiseCache.js +634 -0
  1064. package/dist/utils/promiseCache.js.map +1 -0
  1065. package/dist/utils/searchTree.d.ts +58 -0
  1066. package/dist/utils/searchTree.d.ts.map +1 -0
  1067. package/dist/utils/searchTree.js +394 -0
  1068. package/dist/utils/searchTree.js.map +1 -0
  1069. package/dist/utils/stopwatch.d.ts +41 -0
  1070. package/dist/utils/stopwatch.d.ts.map +1 -0
  1071. package/dist/utils/stopwatch.js +83 -0
  1072. package/dist/utils/stopwatch.js.map +1 -0
  1073. package/dist/utils/string.d.ts +91 -0
  1074. package/dist/utils/string.d.ts.map +1 -0
  1075. package/dist/utils/string.js +803 -0
  1076. package/dist/utils/string.js.map +1 -0
  1077. package/dist/utils/subscriptionManager.d.ts +18 -0
  1078. package/dist/utils/subscriptionManager.d.ts.map +1 -0
  1079. package/dist/utils/subscriptionManager.js +34 -0
  1080. package/dist/utils/subscriptionManager.js.map +1 -0
  1081. package/dist/utils/trie.d.ts +76 -0
  1082. package/dist/utils/trie.d.ts.map +1 -0
  1083. package/dist/utils/trie.js +584 -0
  1084. package/dist/utils/trie.js.map +1 -0
  1085. package/dist/utils/types.d.ts +21 -0
  1086. package/dist/utils/types.d.ts.map +1 -0
  1087. package/dist/utils/types.js +2 -0
  1088. package/dist/utils/types.js.map +1 -0
  1089. package/dist/utils/uri.d.ts +69 -0
  1090. package/dist/utils/uri.d.ts.map +1 -0
  1091. package/dist/utils/uri.js +66 -0
  1092. package/dist/utils/uri.js.map +1 -0
  1093. package/dist/utils/validation.d.ts +14 -0
  1094. package/dist/utils/validation.d.ts.map +1 -0
  1095. package/dist/utils/validation.js +26 -0
  1096. package/dist/utils/validation.js.map +1 -0
  1097. package/dist/utils/version.d.ts +15 -0
  1098. package/dist/utils/version.d.ts.map +1 -0
  1099. package/dist/utils/version.js +66 -0
  1100. package/dist/utils/version.js.map +1 -0
  1101. package/package.json +161 -0
  1102. package/src/git/cache.ts +1152 -0
  1103. package/src/git/context.ts +248 -0
  1104. package/src/git/errors.ts +1121 -0
  1105. package/src/git/exec.types.ts +78 -0
  1106. package/src/git/features.ts +45 -0
  1107. package/src/git/models/author.ts +19 -0
  1108. package/src/git/models/autolink.ts +59 -0
  1109. package/src/git/models/blame.ts +46 -0
  1110. package/src/git/models/branch.ts +236 -0
  1111. package/src/git/models/commit.ts +688 -0
  1112. package/src/git/models/contributor.ts +84 -0
  1113. package/src/git/models/defaultBranch.ts +6 -0
  1114. package/src/git/models/diff.ts +74 -0
  1115. package/src/git/models/file.ts +29 -0
  1116. package/src/git/models/fileChange.ts +82 -0
  1117. package/src/git/models/fileStatus.ts +35 -0
  1118. package/src/git/models/graph.ts +184 -0
  1119. package/src/git/models/graphSearch.ts +53 -0
  1120. package/src/git/models/issue.ts +88 -0
  1121. package/src/git/models/issueOrPullRequest.ts +20 -0
  1122. package/src/git/models/lineRange.ts +7 -0
  1123. package/src/git/models/log.ts +21 -0
  1124. package/src/git/models/mergeConflicts.ts +18 -0
  1125. package/src/git/models/patch.ts +25 -0
  1126. package/src/git/models/pausedOperationStatus.ts +63 -0
  1127. package/src/git/models/pullRequest.ts +161 -0
  1128. package/src/git/models/rebase.ts +60 -0
  1129. package/src/git/models/reference.ts +47 -0
  1130. package/src/git/models/reflog.ts +88 -0
  1131. package/src/git/models/remote.ts +99 -0
  1132. package/src/git/models/remoteProvider.ts +290 -0
  1133. package/src/git/models/remoteResource.ts +87 -0
  1134. package/src/git/models/repository.ts +417 -0
  1135. package/src/git/models/repositoryChangeEvent.ts +30 -0
  1136. package/src/git/models/repositoryIdentities.ts +99 -0
  1137. package/src/git/models/repositoryMetadata.ts +12 -0
  1138. package/src/git/models/resourceDescriptor.ts +11 -0
  1139. package/src/git/models/revision.ts +12 -0
  1140. package/src/git/models/search.ts +123 -0
  1141. package/src/git/models/shortlog.ts +6 -0
  1142. package/src/git/models/signature.ts +29 -0
  1143. package/src/git/models/staging.ts +27 -0
  1144. package/src/git/models/stash.ts +6 -0
  1145. package/src/git/models/status.ts +246 -0
  1146. package/src/git/models/statusFile.ts +116 -0
  1147. package/src/git/models/tag.ts +71 -0
  1148. package/src/git/models/tree.ts +10 -0
  1149. package/src/git/models/user.ts +7 -0
  1150. package/src/git/models/worktree.ts +152 -0
  1151. package/src/git/parsers/diffParser.ts +660 -0
  1152. package/src/git/parsers/rebaseTodoParser.ts +169 -0
  1153. package/src/git/providers/blame.ts +40 -0
  1154. package/src/git/providers/branches.ts +111 -0
  1155. package/src/git/providers/commits.ts +147 -0
  1156. package/src/git/providers/config.ts +104 -0
  1157. package/src/git/providers/contributors.ts +34 -0
  1158. package/src/git/providers/diff.ts +127 -0
  1159. package/src/git/providers/graph.ts +30 -0
  1160. package/src/git/providers/operations.ts +82 -0
  1161. package/src/git/providers/patch.ts +31 -0
  1162. package/src/git/providers/pausedOperations.ts +10 -0
  1163. package/src/git/providers/provider.ts +62 -0
  1164. package/src/git/providers/refs.ts +39 -0
  1165. package/src/git/providers/remotes.ts +33 -0
  1166. package/src/git/providers/revision.ts +28 -0
  1167. package/src/git/providers/shared/remotes.ts +95 -0
  1168. package/src/git/providers/staging.ts +22 -0
  1169. package/src/git/providers/stash.ts +51 -0
  1170. package/src/git/providers/status.ts +42 -0
  1171. package/src/git/providers/tags.ts +28 -0
  1172. package/src/git/providers/types.ts +33 -0
  1173. package/src/git/providers/worktrees.ts +23 -0
  1174. package/src/git/remotes/azure-devops.ts +309 -0
  1175. package/src/git/remotes/bitbucket-server.ts +191 -0
  1176. package/src/git/remotes/bitbucket.ts +144 -0
  1177. package/src/git/remotes/custom.ts +139 -0
  1178. package/src/git/remotes/gerrit.ts +188 -0
  1179. package/src/git/remotes/gitea.ts +186 -0
  1180. package/src/git/remotes/github.ts +238 -0
  1181. package/src/git/remotes/gitlab.ts +272 -0
  1182. package/src/git/remotes/google-source.ts +51 -0
  1183. package/src/git/remotes/matcher.ts +215 -0
  1184. package/src/git/repositoryService.ts +179 -0
  1185. package/src/git/service.ts +365 -0
  1186. package/src/git/utils/autolink.utils.ts +201 -0
  1187. package/src/git/utils/blame.utils.ts +296 -0
  1188. package/src/git/utils/branch.utils.ts +154 -0
  1189. package/src/git/utils/commit.utils.ts +89 -0
  1190. package/src/git/utils/contributor.utils.ts +81 -0
  1191. package/src/git/utils/fetch.utils.ts +48 -0
  1192. package/src/git/utils/fileStatus.utils.ts +49 -0
  1193. package/src/git/utils/issue.utils.ts +81 -0
  1194. package/src/git/utils/issueOrPullRequest.utils.ts +23 -0
  1195. package/src/git/utils/mergeConflicts.utils.ts +21 -0
  1196. package/src/git/utils/pausedOperationStatus.utils.ts +156 -0
  1197. package/src/git/utils/pullRequest.utils.ts +149 -0
  1198. package/src/git/utils/rebase.utils.ts +128 -0
  1199. package/src/git/utils/reference.utils.ts +267 -0
  1200. package/src/git/utils/remote.utils.ts +140 -0
  1201. package/src/git/utils/repository.utils.ts +18 -0
  1202. package/src/git/utils/resourceDescriptor.utils.ts +26 -0
  1203. package/src/git/utils/revision.utils.ts +149 -0
  1204. package/src/git/utils/search.utils.ts +498 -0
  1205. package/src/git/utils/sorting.ts +291 -0
  1206. package/src/git/utils/status.utils.ts +114 -0
  1207. package/src/git/utils/statusFile.utils.ts +182 -0
  1208. package/src/git/utils/tag.utils.ts +17 -0
  1209. package/src/git/utils/tooltip.utils.ts +37 -0
  1210. package/src/git/utils/uriAuthority.ts +34 -0
  1211. package/src/git/utils/user.utils.ts +20 -0
  1212. package/src/git/utils/worktree.utils.ts +21 -0
  1213. package/src/git/watching/changeEvent.ts +90 -0
  1214. package/src/git/watching/classifyChange.ts +81 -0
  1215. package/src/git/watching/gitIgnoreFilter.ts +134 -0
  1216. package/src/git/watching/initWatcher.ts +79 -0
  1217. package/src/git/watching/provider.ts +24 -0
  1218. package/src/git/watching/watchGroup.ts +182 -0
  1219. package/src/git/watching/watchService.ts +350 -0
  1220. package/src/git/watching/watchSession.ts +370 -0
  1221. package/src/git/watching/watcherPatterns.ts +51 -0
  1222. package/src/git-cli/cliGitProvider.ts +436 -0
  1223. package/src/git-cli/exec/exec.errors.ts +1 -0
  1224. package/src/git-cli/exec/exec.ts +11 -0
  1225. package/src/git-cli/exec/exec.types.ts +8 -0
  1226. package/src/git-cli/exec/features.ts +2 -0
  1227. package/src/git-cli/exec/git.ts +1092 -0
  1228. package/src/git-cli/exec/gitQueue.ts +251 -0
  1229. package/src/git-cli/exec/locator.ts +157 -0
  1230. package/src/git-cli/parsers/blameParser.ts +373 -0
  1231. package/src/git-cli/parsers/indexParser.ts +192 -0
  1232. package/src/git-cli/parsers/logParser.ts +1275 -0
  1233. package/src/git-cli/parsers/mergeTreeParser.ts +22 -0
  1234. package/src/git-cli/parsers/refParser.ts +111 -0
  1235. package/src/git-cli/parsers/reflogParser.ts +153 -0
  1236. package/src/git-cli/parsers/remoteParser.ts +95 -0
  1237. package/src/git-cli/parsers/shortlogParser.ts +59 -0
  1238. package/src/git-cli/parsers/signatureParser.ts +162 -0
  1239. package/src/git-cli/parsers/statusParser.ts +209 -0
  1240. package/src/git-cli/parsers/treeParser.ts +61 -0
  1241. package/src/git-cli/parsers/worktreeParser.ts +113 -0
  1242. package/src/git-cli/providers/blame.ts +602 -0
  1243. package/src/git-cli/providers/branches.ts +1491 -0
  1244. package/src/git-cli/providers/commitFilesetUtils.ts +45 -0
  1245. package/src/git-cli/providers/commits.ts +1517 -0
  1246. package/src/git-cli/providers/config.ts +724 -0
  1247. package/src/git-cli/providers/contributors.ts +361 -0
  1248. package/src/git-cli/providers/diff.ts +1084 -0
  1249. package/src/git-cli/providers/graph.ts +799 -0
  1250. package/src/git-cli/providers/operations.ts +776 -0
  1251. package/src/git-cli/providers/patch.ts +326 -0
  1252. package/src/git-cli/providers/pausedOperations.ts +538 -0
  1253. package/src/git-cli/providers/refs.ts +193 -0
  1254. package/src/git-cli/providers/remotes.ts +115 -0
  1255. package/src/git-cli/providers/revision.ts +334 -0
  1256. package/src/git-cli/providers/staging.ts +160 -0
  1257. package/src/git-cli/providers/stash.ts +626 -0
  1258. package/src/git-cli/providers/status.ts +373 -0
  1259. package/src/git-cli/providers/tags.ts +188 -0
  1260. package/src/git-cli/providers/worktrees.ts +229 -0
  1261. package/src/git-cli/service.ts +74 -0
  1262. package/src/plus/ai/constants.ts +121 -0
  1263. package/src/plus/ai/errors.ts +82 -0
  1264. package/src/plus/ai/models/conversation.ts +35 -0
  1265. package/src/plus/ai/models/model.ts +425 -0
  1266. package/src/plus/ai/models/promptTemplates.ts +122 -0
  1267. package/src/plus/ai/models/provider.ts +52 -0
  1268. package/src/plus/ai/models/results.ts +1 -0
  1269. package/src/plus/ai/prompts.ts +528 -0
  1270. package/src/plus/ai/providers/anthropicProvider.ts +308 -0
  1271. package/src/plus/ai/providers/azureProvider.ts +74 -0
  1272. package/src/plus/ai/providers/context.ts +29 -0
  1273. package/src/plus/ai/providers/deepSeekProvider.ts +40 -0
  1274. package/src/plus/ai/providers/geminiProvider.ts +207 -0
  1275. package/src/plus/ai/providers/githubModelsProvider.ts +92 -0
  1276. package/src/plus/ai/providers/gitkrakenProvider.ts +218 -0
  1277. package/src/plus/ai/providers/huggingFaceProvider.ts +51 -0
  1278. package/src/plus/ai/providers/mistralProvider.ts +160 -0
  1279. package/src/plus/ai/providers/ollamaProvider.ts +241 -0
  1280. package/src/plus/ai/providers/openAICompatibleProvider.ts +59 -0
  1281. package/src/plus/ai/providers/openAICompatibleProviderBase.ts +279 -0
  1282. package/src/plus/ai/providers/openRouterProvider.ts +84 -0
  1283. package/src/plus/ai/providers/openaiProvider.ts +46 -0
  1284. package/src/plus/ai/providers/xaiProvider.ts +32 -0
  1285. package/src/plus/ai/utils/ai.utils.ts +79 -0
  1286. package/src/plus/ai/utils/results.utils.ts +50 -0
  1287. package/src/plus/ai/utils/truncation.utils.ts +295 -0
  1288. package/src/plus/git-github/api/config.ts +78 -0
  1289. package/src/plus/git-github/api/github.ts +3424 -0
  1290. package/src/plus/git-github/api/github.utils.ts +36 -0
  1291. package/src/plus/git-github/api/token.ts +15 -0
  1292. package/src/plus/git-github/api/tokenUtils.ts +15 -0
  1293. package/src/plus/git-github/api/types.ts +182 -0
  1294. package/src/plus/git-github/context.ts +107 -0
  1295. package/src/plus/git-github/models.ts +524 -0
  1296. package/src/plus/git-github/providers/github/blame.ts +222 -0
  1297. package/src/plus/git-github/providers/github/branches.ts +356 -0
  1298. package/src/plus/git-github/providers/github/commits.ts +858 -0
  1299. package/src/plus/git-github/providers/github/config.ts +47 -0
  1300. package/src/plus/git-github/providers/github/contributors.ts +313 -0
  1301. package/src/plus/git-github/providers/github/diff.ts +267 -0
  1302. package/src/plus/git-github/providers/github/graph.ts +511 -0
  1303. package/src/plus/git-github/providers/github/refs.ts +137 -0
  1304. package/src/plus/git-github/providers/github/remotes.ts +44 -0
  1305. package/src/plus/git-github/providers/github/revision.ts +141 -0
  1306. package/src/plus/git-github/providers/github/status.ts +63 -0
  1307. package/src/plus/git-github/providers/github/tags.ts +147 -0
  1308. package/src/plus/git-github/providers/githubGitProvider.ts +167 -0
  1309. package/src/plus/git-github/providers/githubProvider.ts +65 -0
  1310. package/src/utils/array.ts +194 -0
  1311. package/src/utils/base64.ts +1 -0
  1312. package/src/utils/brand.ts +9 -0
  1313. package/src/utils/cancellation.ts +150 -0
  1314. package/src/utils/charCode.ts +38 -0
  1315. package/src/utils/color.ts +815 -0
  1316. package/src/utils/counter.ts +21 -0
  1317. package/src/utils/crypto.ts +1 -0
  1318. package/src/utils/date.ts +394 -0
  1319. package/src/utils/debounce.ts +303 -0
  1320. package/src/utils/decorators/debounce.ts +31 -0
  1321. package/src/utils/decorators/gate.ts +167 -0
  1322. package/src/utils/decorators/log.ts +320 -0
  1323. package/src/utils/decorators/memoize.ts +98 -0
  1324. package/src/utils/decorators/resolver.ts +95 -0
  1325. package/src/utils/decorators/sequentialize.ts +116 -0
  1326. package/src/utils/decorators/serializable.ts +42 -0
  1327. package/src/utils/disposable.ts +141 -0
  1328. package/src/utils/encoding.ts +8 -0
  1329. package/src/utils/env/browser/base64.ts +50 -0
  1330. package/src/utils/env/browser/crypto.ts +21 -0
  1331. package/src/utils/env/browser/fs.ts +3 -0
  1332. package/src/utils/env/browser/hex.ts +41 -0
  1333. package/src/utils/env/browser/hrtime.ts +14 -0
  1334. package/src/utils/env/browser/logScope.ts +57 -0
  1335. package/src/utils/env/browser/md5.ts +217 -0
  1336. package/src/utils/env/browser/platform.ts +10 -0
  1337. package/src/utils/env/node/base64.ts +17 -0
  1338. package/src/utils/env/node/crypto.ts +17 -0
  1339. package/src/utils/env/node/exec.ts +471 -0
  1340. package/src/utils/env/node/fs.ts +5 -0
  1341. package/src/utils/env/node/hex.ts +11 -0
  1342. package/src/utils/env/node/hrtime.ts +1 -0
  1343. package/src/utils/env/node/logScope.ts +63 -0
  1344. package/src/utils/env/node/platform.ts +5 -0
  1345. package/src/utils/error.ts +17 -0
  1346. package/src/utils/event.ts +236 -0
  1347. package/src/utils/formatter.ts +205 -0
  1348. package/src/utils/fs.ts +1 -0
  1349. package/src/utils/function.ts +141 -0
  1350. package/src/utils/fuzzy.ts +185 -0
  1351. package/src/utils/hash.ts +60 -0
  1352. package/src/utils/hex.ts +1 -0
  1353. package/src/utils/hrtime.ts +8 -0
  1354. package/src/utils/iterable.ts +787 -0
  1355. package/src/utils/lazy.ts +39 -0
  1356. package/src/utils/loggable.ts +7 -0
  1357. package/src/utils/logger.scoped.ts +237 -0
  1358. package/src/utils/logger.ts +402 -0
  1359. package/src/utils/markdown.ts +114 -0
  1360. package/src/utils/mru.ts +66 -0
  1361. package/src/utils/object.ts +227 -0
  1362. package/src/utils/paging.ts +51 -0
  1363. package/src/utils/path.ts +189 -0
  1364. package/src/utils/platform.ts +1 -0
  1365. package/src/utils/promise.ts +590 -0
  1366. package/src/utils/promiseCache.ts +803 -0
  1367. package/src/utils/searchTree.ts +442 -0
  1368. package/src/utils/stopwatch.ts +125 -0
  1369. package/src/utils/string.ts +964 -0
  1370. package/src/utils/subscriptionManager.ts +40 -0
  1371. package/src/utils/trie.ts +739 -0
  1372. package/src/utils/types.ts +31 -0
  1373. package/src/utils/uri.ts +117 -0
  1374. package/src/utils/validation.ts +38 -0
  1375. package/src/utils/version.ts +79 -0
@@ -0,0 +1,3424 @@
1
+ import {
2
+ AuthenticationError,
3
+ AuthenticationErrorReason,
4
+ RequestClientError,
5
+ RequestNotFoundError,
6
+ RequestRateLimitError,
7
+ } from '../../../git/errors.js';
8
+ import type { Account, UnidentifiedAuthor } from '../../../git/models/author.js';
9
+ import type { DefaultBranch } from '../../../git/models/defaultBranch.js';
10
+ import type { Issue, IssueShape } from '../../../git/models/issue.js';
11
+ import type { IssueOrPullRequest } from '../../../git/models/issueOrPullRequest.js';
12
+ import type { PullRequest } from '../../../git/models/pullRequest.js';
13
+ import { PullRequestMergeMethod } from '../../../git/models/pullRequest.js';
14
+ import type { Provider } from '../../../git/models/remoteProvider.js';
15
+ import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata.js';
16
+ import type { GitRevisionRange } from '../../../git/models/revision.js';
17
+ import type { GitUser } from '../../../git/models/user.js';
18
+ import type { RepositoryVisibility } from '../../../git/providers/types.js';
19
+ import { getGitHubNoReplyAddressParts } from '../../../git/remotes/github.js';
20
+ import {
21
+ createRevisionRange,
22
+ getRevisionRangeParts,
23
+ isRevisionRange,
24
+ isSha,
25
+ } from '../../../git/utils/revision.utils.js';
26
+ import { base64 } from '../../../utils/base64.js';
27
+ import { CancellationError } from '../../../utils/cancellation.js';
28
+ import { trace } from '../../../utils/decorators/log.js';
29
+ import type { Event } from '../../../utils/event.js';
30
+ import { Emitter } from '../../../utils/event.js';
31
+ import { uniqueBy } from '../../../utils/iterable.js';
32
+ import { Logger } from '../../../utils/logger.js';
33
+ import type { ScopedLogger } from '../../../utils/logger.scoped.js';
34
+ import { getScopedLogger } from '../../../utils/logger.scoped.js';
35
+ import type { PagedResult } from '../../../utils/paging.js';
36
+ import { maybeStopWatch } from '../../../utils/stopwatch.js';
37
+ import { parseUri } from '../../../utils/uri.js';
38
+ import type { Version } from '../../../utils/version.js';
39
+ import { fromString, satisfies } from '../../../utils/version.js';
40
+ import { graphql, GraphqlResponseError } from '@octokit/graphql';
41
+ import { request } from '@octokit/request';
42
+ import { RequestError } from '@octokit/request-error';
43
+ import type { Endpoints, RequestParameters } from '@octokit/types';
44
+ import type {
45
+ GitHubBlame,
46
+ GitHubBlameRange,
47
+ GitHubBranch,
48
+ GitHubCommit,
49
+ GitHubCommitRef,
50
+ GitHubContributor,
51
+ GitHubIssue,
52
+ GitHubIssueOrPullRequest,
53
+ GitHubPagedResult,
54
+ GitHubPageInfo,
55
+ GitHubPullRequest,
56
+ GitHubPullRequestLite,
57
+ GitHubPullRequestState,
58
+ GitHubTag,
59
+ } from '../models.js';
60
+ import {
61
+ fromGitHubIssue,
62
+ fromGitHubIssueOrPullRequestState,
63
+ fromGitHubPullRequest,
64
+ fromGitHubPullRequestLite,
65
+ } from '../models.js';
66
+ import type { GitHubApiConfig } from './config.js';
67
+ import type { GitHubTokenInfo } from './token.js';
68
+
69
+ interface CancellationToken {
70
+ isCancellationRequested: boolean;
71
+ onCancellationRequested(fn: () => void): { dispose(): void };
72
+ }
73
+
74
+ const emptyPagedResult: PagedResult<any> = Object.freeze({ values: [] });
75
+ const emptyBlameResult: GitHubBlame = Object.freeze({ ranges: [] });
76
+
77
+ const gqlIssueOrPullRequestFragment = `
78
+ closed
79
+ closedAt
80
+ createdAt
81
+ id
82
+ number
83
+ state
84
+ title
85
+ updatedAt
86
+ url
87
+ `;
88
+ const gqlPullRequestLiteFragment = `
89
+ ${gqlIssueOrPullRequestFragment}
90
+ author {
91
+ login
92
+ avatarUrl(size: $avatarSize)
93
+ url
94
+ }
95
+ baseRefName
96
+ baseRefOid
97
+ headRefName
98
+ headRefOid
99
+ headRepository {
100
+ name
101
+ owner {
102
+ login
103
+ }
104
+ url
105
+ }
106
+ isCrossRepository
107
+ isDraft
108
+ mergedAt
109
+ permalink
110
+ repository {
111
+ isFork
112
+ name
113
+ owner {
114
+ login
115
+ }
116
+ url
117
+ viewerPermission
118
+ }
119
+ `;
120
+ const gqlPullRequestFragment = `
121
+ ${gqlPullRequestLiteFragment}
122
+ additions
123
+ assignees(first: 10) {
124
+ nodes {
125
+ login
126
+ avatarUrl(size: $avatarSize)
127
+ url
128
+ }
129
+ }
130
+ checksUrl
131
+ deletions
132
+ mergeable
133
+ mergedBy {
134
+ login
135
+ }
136
+ reviewDecision
137
+ latestReviews(first: 10) {
138
+ nodes {
139
+ author {
140
+ login
141
+ avatarUrl(size: $avatarSize)
142
+ url
143
+ }
144
+ state
145
+ }
146
+ }
147
+ reviewRequests(first: 10) {
148
+ nodes {
149
+ asCodeOwner
150
+ id
151
+ requestedReviewer {
152
+ ... on User {
153
+ login
154
+ avatarUrl(size: $avatarSize)
155
+ url
156
+ }
157
+ }
158
+ }
159
+ }
160
+ commits(last: 1) {
161
+ nodes {
162
+ commit {
163
+ statusCheckRollup {
164
+ state
165
+ }
166
+ }
167
+ }
168
+ }
169
+ totalCommentsCount
170
+ viewerCanUpdate
171
+ `;
172
+
173
+ const gqIssueFragment = `
174
+ ${gqlIssueOrPullRequestFragment}
175
+ assignees(first: 100) {
176
+ nodes {
177
+ login
178
+ url
179
+ avatarUrl(size: $avatarSize)
180
+ }
181
+ }
182
+ author {
183
+ login
184
+ avatarUrl
185
+ url
186
+ }
187
+ comments {
188
+ totalCount
189
+ }
190
+ labels(first: 20) {
191
+ nodes {
192
+ color
193
+ name
194
+ }
195
+ }
196
+ reactions(content: THUMBS_UP) {
197
+ totalCount
198
+ }
199
+ repository {
200
+ name
201
+ owner {
202
+ login
203
+ }
204
+ viewerPermission
205
+ url
206
+ }
207
+ `;
208
+
209
+ export class GitHubApi {
210
+ private readonly _onDidReauthenticate = new Emitter<void>();
211
+ get onDidReauthenticate(): Event<void> {
212
+ return this._onDidReauthenticate.event;
213
+ }
214
+
215
+ private readonly _disposables: { dispose(): void }[] = [];
216
+
217
+ constructor(readonly config: GitHubApiConfig) {
218
+ this._disposables.push(this._onDidReauthenticate);
219
+ if (config.onConfigChanged != null) {
220
+ this._disposables.push(
221
+ config.onConfigChanged(() => {
222
+ this.resetCaches();
223
+ }),
224
+ );
225
+ }
226
+ }
227
+
228
+ dispose(): void {
229
+ for (const d of this._disposables) {
230
+ d.dispose();
231
+ }
232
+ this._disposables.length = 0;
233
+ }
234
+
235
+ private resetCaches(): void {
236
+ this._defaults.clear();
237
+ this._enterpriseVersions.clear();
238
+ }
239
+
240
+ async getCurrentAccount(
241
+ provider: Provider,
242
+ token: GitHubTokenInfo,
243
+ options?: {
244
+ baseUrl?: string;
245
+ avatarSize?: number;
246
+ },
247
+ ): Promise<Account | undefined> {
248
+ const scope = getScopedLogger();
249
+
250
+ interface QueryResult {
251
+ viewer: {
252
+ name: string | null;
253
+ email: string | null;
254
+ login: string | null;
255
+ avatarUrl: string | null;
256
+ };
257
+ }
258
+
259
+ try {
260
+ const query = `query getCurrentAccount($avatarSize: Int) {
261
+ viewer {
262
+ name
263
+ email
264
+ login
265
+ avatarUrl(size: $avatarSize)
266
+ }
267
+ }`;
268
+
269
+ const rsp = await this.graphql<QueryResult>(provider, token, query, { ...options }, scope);
270
+ if (rsp?.viewer?.login == null) return undefined;
271
+
272
+ return {
273
+ provider: provider,
274
+ id: rsp.viewer.login,
275
+ name: rsp.viewer.name ?? undefined,
276
+ email: rsp.viewer.email ?? undefined,
277
+ // If we are GitHub Enterprise, we may need to convert the avatar URL since it might require authentication
278
+ avatarUrl:
279
+ !rsp.viewer.avatarUrl || isGitHubDotCom(options)
280
+ ? (rsp.viewer.avatarUrl ?? undefined)
281
+ : rsp.viewer.email && options?.baseUrl != null
282
+ ? await this.createEnterpriseAvatarUrl(
283
+ provider,
284
+ token,
285
+ options.baseUrl,
286
+ rsp.viewer.email,
287
+ options.avatarSize,
288
+ )
289
+ : undefined,
290
+ username: rsp.viewer.login ?? undefined,
291
+ };
292
+ } catch (ex) {
293
+ if (ex instanceof RequestNotFoundError) return undefined;
294
+
295
+ throw this.handleException(ex, provider, scope);
296
+ }
297
+ }
298
+
299
+ @trace({
300
+ args: (provider, token, owner, repo, rev) => ({
301
+ provider: provider.name,
302
+ token: `<token:${token.microHash}>`,
303
+ owner: owner,
304
+ repo: repo,
305
+ rev: rev,
306
+ }),
307
+ })
308
+ async getAccountForCommit(
309
+ provider: Provider,
310
+ token: GitHubTokenInfo,
311
+ owner: string,
312
+ repo: string,
313
+ rev: string,
314
+ options?: {
315
+ baseUrl?: string;
316
+ avatarSize?: number;
317
+ },
318
+ ): Promise<Account | UnidentifiedAuthor | undefined> {
319
+ const scope = getScopedLogger();
320
+
321
+ interface QueryResult {
322
+ repository:
323
+ | {
324
+ object:
325
+ | {
326
+ author?: {
327
+ name: string | null;
328
+ email: string | null;
329
+ avatarUrl: string;
330
+ user: {
331
+ login: string | null;
332
+ } | null;
333
+ };
334
+ }
335
+ | null
336
+ | undefined;
337
+ }
338
+ | null
339
+ | undefined;
340
+ }
341
+
342
+ try {
343
+ const query = `query getAccountForCommit(
344
+ $owner: String!
345
+ $repo: String!
346
+ $rev: GitObjectID!
347
+ $avatarSize: Int
348
+ ) {
349
+ repository(name: $repo, owner: $owner) {
350
+ object(oid: $rev) {
351
+ ... on Commit {
352
+ author {
353
+ name
354
+ email
355
+ avatarUrl(size: $avatarSize)
356
+ user {
357
+ login
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }
363
+ }`;
364
+
365
+ const rsp = await this.graphql<QueryResult>(
366
+ provider,
367
+ token,
368
+ query,
369
+ {
370
+ ...options,
371
+ owner: owner,
372
+ repo: repo,
373
+ rev: rev,
374
+ },
375
+ scope,
376
+ );
377
+
378
+ const author = rsp?.repository?.object?.author;
379
+ if (author == null) return undefined;
380
+
381
+ return {
382
+ provider: provider,
383
+ ...(author?.user?.login != null
384
+ ? {
385
+ id: author.user.login,
386
+ username: author.user.login,
387
+ }
388
+ : {
389
+ id: undefined,
390
+ username: undefined,
391
+ }),
392
+ name: author.name ?? undefined,
393
+ email: author.email ?? undefined,
394
+ // If we are GitHub Enterprise, we may need to convert the avatar URL since it might require authentication
395
+ avatarUrl:
396
+ !author.avatarUrl || isGitHubDotCom(options)
397
+ ? (author.avatarUrl ?? undefined)
398
+ : author.email && options?.baseUrl != null
399
+ ? await this.createEnterpriseAvatarUrl(
400
+ provider,
401
+ token,
402
+ options.baseUrl,
403
+ author.email,
404
+ options.avatarSize,
405
+ )
406
+ : undefined,
407
+ };
408
+ } catch (ex) {
409
+ if (ex instanceof RequestNotFoundError) return undefined;
410
+ if (ex.message.includes('Variable $rev of type GitObjectID! was provided invalid value')) {
411
+ return undefined;
412
+ }
413
+
414
+ throw this.handleException(ex, provider, scope);
415
+ }
416
+ }
417
+
418
+ @trace({
419
+ args: (provider, token, owner, repo, email) => ({
420
+ provider: provider.name,
421
+ token: `<token:${token.microHash}>`,
422
+ owner: owner,
423
+ repo: repo,
424
+ email: email,
425
+ }),
426
+ })
427
+ async getAccountForEmail(
428
+ provider: Provider,
429
+ token: GitHubTokenInfo,
430
+ owner: string,
431
+ repo: string,
432
+ email: string,
433
+ options?: {
434
+ baseUrl?: string;
435
+ avatarSize?: number;
436
+ },
437
+ ): Promise<Account | undefined> {
438
+ const scope = getScopedLogger();
439
+
440
+ interface QueryResult {
441
+ search:
442
+ | {
443
+ nodes:
444
+ | {
445
+ name: string | null;
446
+ email: string | null;
447
+ avatarUrl: string;
448
+ login: string | null;
449
+ }[]
450
+ | null
451
+ | undefined;
452
+ }
453
+ | null
454
+ | undefined;
455
+ }
456
+
457
+ try {
458
+ const query = `query getAccountForEmail(
459
+ $emailQuery: String!
460
+ $avatarSize: Int
461
+ ) {
462
+ search(type: USER, query: $emailQuery, first: 1) {
463
+ nodes {
464
+ ... on User {
465
+ name
466
+ email
467
+ avatarUrl(size: $avatarSize)
468
+ login
469
+ }
470
+ }
471
+ }
472
+ }`;
473
+
474
+ const rsp = await this.graphql<QueryResult>(
475
+ provider,
476
+ token,
477
+ query,
478
+ {
479
+ ...options,
480
+ owner: owner,
481
+ repo: repo,
482
+ emailQuery: `in:email ${email}`,
483
+ },
484
+ scope,
485
+ );
486
+
487
+ const author = rsp?.search?.nodes?.[0];
488
+ if (author?.login == null) return undefined;
489
+
490
+ return {
491
+ provider: provider,
492
+ id: author.login,
493
+ name: author.name ?? undefined,
494
+ email: author.email ?? undefined,
495
+ // If we are GitHub Enterprise, we may need to convert the avatar URL since it might require authentication
496
+ avatarUrl:
497
+ !author.avatarUrl || isGitHubDotCom(options)
498
+ ? (author.avatarUrl ?? undefined)
499
+ : author.email && options?.baseUrl != null
500
+ ? await this.createEnterpriseAvatarUrl(
501
+ provider,
502
+ token,
503
+ options.baseUrl,
504
+ author.email,
505
+ options.avatarSize,
506
+ )
507
+ : undefined,
508
+ username: author.login ?? undefined,
509
+ };
510
+ } catch (ex) {
511
+ if (ex instanceof RequestNotFoundError) return undefined;
512
+
513
+ throw this.handleException(ex, provider, scope);
514
+ }
515
+ }
516
+
517
+ @trace({
518
+ args: (provider, token, owner, repo) => ({
519
+ provider: provider.name,
520
+ token: `<token:${token.microHash}>`,
521
+ owner: owner,
522
+ repo: repo,
523
+ }),
524
+ })
525
+ async getDefaultBranch(
526
+ provider: Provider,
527
+ token: GitHubTokenInfo,
528
+ owner: string,
529
+ repo: string,
530
+ options?: {
531
+ baseUrl?: string;
532
+ },
533
+ ): Promise<DefaultBranch | undefined> {
534
+ const scope = getScopedLogger();
535
+
536
+ interface QueryResult {
537
+ repository:
538
+ | {
539
+ defaultBranchRef: { name: string } | null | undefined;
540
+ }
541
+ | null
542
+ | undefined;
543
+ }
544
+
545
+ try {
546
+ const query = `query getDefaultBranch(
547
+ $owner: String!
548
+ $repo: String!
549
+ ) {
550
+ repository(name: $repo, owner: $owner) {
551
+ defaultBranchRef {
552
+ name
553
+ }
554
+ }
555
+ }`;
556
+
557
+ const rsp = await this.graphql<QueryResult>(
558
+ provider,
559
+ token,
560
+ query,
561
+ {
562
+ ...options,
563
+ owner: owner,
564
+ repo: repo,
565
+ },
566
+ scope,
567
+ );
568
+
569
+ const defaultBranch = rsp?.repository?.defaultBranchRef?.name ?? undefined;
570
+ if (defaultBranch == null) return undefined;
571
+
572
+ return {
573
+ provider: provider,
574
+ name: defaultBranch,
575
+ };
576
+ } catch (ex) {
577
+ if (ex instanceof RequestNotFoundError) return undefined;
578
+
579
+ throw this.handleException(ex, provider, scope);
580
+ }
581
+ }
582
+
583
+ @trace({
584
+ args: (provider, token, owner, repo, number) => ({
585
+ provider: provider.name,
586
+ token: `<token:${token.microHash}>`,
587
+ owner: owner,
588
+ repo: repo,
589
+ number: number,
590
+ }),
591
+ })
592
+ async getIssueOrPullRequest(
593
+ provider: Provider,
594
+ token: GitHubTokenInfo,
595
+ owner: string,
596
+ repo: string,
597
+ number: number,
598
+ options?: {
599
+ baseUrl?: string;
600
+ },
601
+ ): Promise<IssueOrPullRequest | undefined> {
602
+ const scope = getScopedLogger();
603
+
604
+ interface QueryResult {
605
+ repository?: { issueOrPullRequest?: GitHubIssueOrPullRequest };
606
+ }
607
+
608
+ try {
609
+ const query = `query getIssueOrPullRequest(
610
+ $owner: String!
611
+ $repo: String!
612
+ $number: Int!
613
+ ) {
614
+ repository(name: $repo, owner: $owner) {
615
+ issueOrPullRequest(number: $number) {
616
+ __typename
617
+ ... on Issue {
618
+ ${gqlIssueOrPullRequestFragment}
619
+ }
620
+ ... on PullRequest {
621
+ ${gqlIssueOrPullRequestFragment}
622
+ }
623
+ }
624
+ }
625
+ }`;
626
+
627
+ const rsp = await this.graphql<QueryResult>(
628
+ provider,
629
+ token,
630
+ query,
631
+ {
632
+ ...options,
633
+ owner: owner,
634
+ repo: repo,
635
+ number: number,
636
+ },
637
+ scope,
638
+ );
639
+
640
+ const issue = rsp?.repository?.issueOrPullRequest;
641
+ if (issue == null) return undefined;
642
+
643
+ return {
644
+ provider: provider,
645
+ type: issue.__typename === 'PullRequest' ? 'pullrequest' : 'issue',
646
+ id: String(issue.number),
647
+ nodeId: issue.id,
648
+ createdDate: new Date(issue.createdAt),
649
+ updatedDate: new Date(issue.updatedAt),
650
+ title: issue.title,
651
+ closed: issue.closed,
652
+ closedDate: issue.closedAt == null ? undefined : new Date(issue.closedAt),
653
+ url: issue.url,
654
+ state: fromGitHubIssueOrPullRequestState(issue.state),
655
+ };
656
+ } catch (ex) {
657
+ if (ex instanceof RequestNotFoundError) return undefined;
658
+
659
+ throw this.handleException(ex, provider, scope);
660
+ }
661
+ }
662
+
663
+ @trace({
664
+ args: (provider, token, owner, repo, number) => ({
665
+ provider: provider.name,
666
+ token: `<token:${token.microHash}>`,
667
+ owner: owner,
668
+ repo: repo,
669
+ number: number,
670
+ }),
671
+ })
672
+ async getIssue(
673
+ provider: Provider,
674
+ token: GitHubTokenInfo,
675
+ owner: string,
676
+ repo: string,
677
+ number: number,
678
+ options?: {
679
+ baseUrl?: string;
680
+ avatarSize?: number;
681
+ includeBody?: boolean;
682
+ },
683
+ ): Promise<Issue | undefined> {
684
+ const scope = getScopedLogger();
685
+
686
+ interface QueryResult {
687
+ repository:
688
+ | {
689
+ issue: GitHubIssue | null | undefined;
690
+ }
691
+ | null
692
+ | undefined;
693
+ }
694
+
695
+ try {
696
+ const query = `query getIssue(
697
+ $owner: String!
698
+ $repo: String!
699
+ $number: Int!
700
+ $avatarSize: Int
701
+ ) {
702
+ repository(name: $repo, owner: $owner) {
703
+ issue(number: $number) {
704
+ ${gqIssueFragment}${
705
+ options?.includeBody
706
+ ? `
707
+ body
708
+ `
709
+ : ''
710
+ }
711
+ }
712
+ }
713
+ }`;
714
+
715
+ const rsp = await this.graphql<QueryResult>(
716
+ provider,
717
+ token,
718
+ query,
719
+ {
720
+ ...options,
721
+ owner: owner,
722
+ repo: repo,
723
+ number: number,
724
+ },
725
+ scope,
726
+ );
727
+
728
+ if (rsp?.repository?.issue == null) return undefined;
729
+
730
+ return fromGitHubIssue(rsp.repository.issue, provider);
731
+ } catch (ex) {
732
+ if (ex instanceof RequestNotFoundError) return undefined;
733
+
734
+ throw this.handleException(ex, provider, scope);
735
+ }
736
+ }
737
+
738
+ @trace({
739
+ args: (provider, token, owner, repo, number) => ({
740
+ provider: provider.name,
741
+ token: `<token:${token.microHash}>`,
742
+ owner: owner,
743
+ repo: repo,
744
+ number: number,
745
+ }),
746
+ })
747
+ async getPullRequest(
748
+ provider: Provider,
749
+ token: GitHubTokenInfo,
750
+ owner: string,
751
+ repo: string,
752
+ number: number,
753
+ options?: {
754
+ baseUrl?: string;
755
+ avatarSize?: number;
756
+ },
757
+ ): Promise<PullRequest | undefined> {
758
+ const scope = getScopedLogger();
759
+
760
+ interface QueryResult {
761
+ repository:
762
+ | {
763
+ pullRequest: GitHubPullRequestLite | null | undefined;
764
+ }
765
+ | null
766
+ | undefined;
767
+ }
768
+
769
+ try {
770
+ const query = `query getPullRequest(
771
+ $owner: String!
772
+ $repo: String!
773
+ $number: Int!
774
+ $avatarSize: Int
775
+ ) {
776
+ repository(name: $repo, owner: $owner) {
777
+ pullRequest(number: $number) {
778
+ ${gqlPullRequestFragment}
779
+ }
780
+ }
781
+ }`;
782
+
783
+ const rsp = await this.graphql<QueryResult>(
784
+ provider,
785
+ token,
786
+ query,
787
+ {
788
+ ...options,
789
+ owner: owner,
790
+ repo: repo,
791
+ number: number,
792
+ },
793
+ scope,
794
+ );
795
+
796
+ if (rsp?.repository?.pullRequest == null) return undefined;
797
+
798
+ return fromGitHubPullRequestLite(rsp.repository.pullRequest, provider);
799
+ } catch (ex) {
800
+ if (ex instanceof RequestNotFoundError) return undefined;
801
+
802
+ throw this.handleException(ex, provider, scope);
803
+ }
804
+ }
805
+
806
+ @trace({
807
+ args: (provider, token, owner, repo, branch) => ({
808
+ provider: provider.name,
809
+ token: `<token:${token.microHash}>`,
810
+ owner: owner,
811
+ repo: repo,
812
+ branch: branch,
813
+ }),
814
+ })
815
+ async getPullRequestForBranch(
816
+ provider: Provider,
817
+ token: GitHubTokenInfo,
818
+ owner: string,
819
+ repo: string,
820
+ branch: string,
821
+ options?: {
822
+ baseUrl?: string;
823
+ avatarSize?: number;
824
+ include?: GitHubPullRequestState[];
825
+ },
826
+ ): Promise<PullRequest | undefined> {
827
+ const scope = getScopedLogger();
828
+
829
+ interface QueryResult {
830
+ repository:
831
+ | {
832
+ ref:
833
+ | {
834
+ associatedPullRequests?: {
835
+ nodes?: GitHubPullRequestLite[];
836
+ };
837
+ }
838
+ | null
839
+ | undefined;
840
+ }
841
+ | null
842
+ | undefined;
843
+ }
844
+
845
+ try {
846
+ const query = `query getPullRequestForBranch(
847
+ $owner: String!
848
+ $repo: String!
849
+ $branch: String!
850
+ $limit: Int!
851
+ $include: [PullRequestState!]
852
+ $avatarSize: Int
853
+ ) {
854
+ repository(name: $repo, owner: $owner) {
855
+ ref(qualifiedName: $branch) {
856
+ associatedPullRequests(first: $limit, orderBy: {field: UPDATED_AT, direction: DESC}, states: $include) {
857
+ nodes {
858
+ ${gqlPullRequestLiteFragment}
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }`;
864
+
865
+ const rsp = await this.graphql<QueryResult>(
866
+ provider,
867
+ token,
868
+ query,
869
+ {
870
+ ...options,
871
+ owner: owner,
872
+ repo: repo,
873
+ branch: `refs/heads/${branch}`,
874
+ // Since GitHub sort doesn't seem to really work, look for a max of 10 PRs and then sort them ourselves
875
+ limit: 10,
876
+ },
877
+ scope,
878
+ );
879
+
880
+ // If the pr is not from a fork, keep it e.g. show root pr's on forks, otherwise, ensure the repo owners match
881
+ const prs = rsp?.repository?.ref?.associatedPullRequests?.nodes?.filter(
882
+ pr => pr != null && (!pr.repository.isFork || pr.repository.owner.login === owner),
883
+ );
884
+ if (prs == null || prs.length === 0) return undefined;
885
+
886
+ if (prs.length > 1) {
887
+ prs.sort(
888
+ (a, b) =>
889
+ (a.repository.owner.login === owner ? -1 : 1) - (b.repository.owner.login === owner ? -1 : 1) ||
890
+ (a.state === 'OPEN' ? -1 : 1) - (b.state === 'OPEN' ? -1 : 1) ||
891
+ new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),
892
+ );
893
+ }
894
+
895
+ return fromGitHubPullRequestLite(prs[0], provider);
896
+ } catch (ex) {
897
+ if (ex instanceof RequestNotFoundError) return undefined;
898
+
899
+ throw this.handleException(ex, provider, scope);
900
+ }
901
+ }
902
+
903
+ @trace({
904
+ args: (provider, token, owner, repo, rev) => ({
905
+ provider: provider.name,
906
+ token: `<token:${token.microHash}>`,
907
+ owner: owner,
908
+ repo: repo,
909
+ rev: rev,
910
+ }),
911
+ })
912
+ async getPullRequestForCommit(
913
+ provider: Provider,
914
+ token: GitHubTokenInfo,
915
+ owner: string,
916
+ repo: string,
917
+ rev: string,
918
+ options?: {
919
+ baseUrl?: string;
920
+ avatarSize?: number;
921
+ },
922
+ cancellation?: CancellationToken,
923
+ ): Promise<PullRequest | undefined> {
924
+ const scope = getScopedLogger();
925
+
926
+ interface QueryResult {
927
+ repository:
928
+ | {
929
+ object?: {
930
+ associatedPullRequests?: {
931
+ nodes?: GitHubPullRequestLite[];
932
+ };
933
+ };
934
+ }
935
+ | null
936
+ | undefined;
937
+ }
938
+
939
+ try {
940
+ const query = `query getPullRequestForCommit(
941
+ $owner: String!
942
+ $repo: String!
943
+ $rev: GitObjectID!
944
+ $avatarSize: Int
945
+ ) {
946
+ repository(name: $repo, owner: $owner) {
947
+ object(oid: $rev) {
948
+ ... on Commit {
949
+ associatedPullRequests(first: 2, orderBy: {field: UPDATED_AT, direction: DESC}) {
950
+ nodes {
951
+ ${gqlPullRequestLiteFragment}
952
+ }
953
+ }
954
+ }
955
+ }
956
+ }
957
+ }`;
958
+
959
+ const rsp = await this.graphql<QueryResult>(
960
+ provider,
961
+ token,
962
+ query,
963
+ {
964
+ ...options,
965
+ owner: owner,
966
+ repo: repo,
967
+ rev: rev,
968
+ },
969
+ scope,
970
+ cancellation,
971
+ );
972
+
973
+ // If the pr is not from a fork, keep it e.g. show root pr's on forks, otherwise, ensure the repo owners match
974
+ const prs = rsp?.repository?.object?.associatedPullRequests?.nodes?.filter(
975
+ pr => pr != null && (!pr.repository.isFork || pr.repository.owner.login === owner),
976
+ );
977
+ if (prs == null || prs.length === 0) return undefined;
978
+
979
+ if (prs.length > 1) {
980
+ prs.sort(
981
+ (a, b) =>
982
+ (a.repository.owner.login === owner ? -1 : 1) - (b.repository.owner.login === owner ? -1 : 1) ||
983
+ (a.state === 'MERGED' ? -1 : 1) - (b.state === 'MERGED' ? -1 : 1) ||
984
+ new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),
985
+ );
986
+ }
987
+
988
+ return fromGitHubPullRequestLite(prs[0], provider);
989
+ } catch (ex) {
990
+ if (ex instanceof RequestNotFoundError) return undefined;
991
+
992
+ throw this.handleException(ex, provider, scope);
993
+ }
994
+ }
995
+
996
+ @trace({
997
+ args: (provider, token, owner, repo) => ({
998
+ provider: provider.name,
999
+ token: `<token:${token.microHash}>`,
1000
+ owner: owner,
1001
+ repo: repo,
1002
+ }),
1003
+ })
1004
+ async getRepositoryMetadata(
1005
+ provider: Provider,
1006
+ token: GitHubTokenInfo,
1007
+ owner: string,
1008
+ repo: string,
1009
+ options?: {
1010
+ baseUrl?: string;
1011
+ },
1012
+ cancellation?: CancellationToken,
1013
+ ): Promise<RepositoryMetadata | undefined> {
1014
+ const scope = getScopedLogger();
1015
+
1016
+ interface QueryResult {
1017
+ repository:
1018
+ | {
1019
+ owner: {
1020
+ login: string;
1021
+ };
1022
+ name: string;
1023
+ parent:
1024
+ | {
1025
+ owner: {
1026
+ login: string;
1027
+ };
1028
+ name: string;
1029
+ }
1030
+ | null
1031
+ | undefined;
1032
+ }
1033
+ | null
1034
+ | undefined;
1035
+ }
1036
+
1037
+ try {
1038
+ const query = `query getRepositoryMetadata(
1039
+ $owner: String!
1040
+ $repo: String!
1041
+ ) {
1042
+ repository(name: $repo, owner: $owner) {
1043
+ owner {
1044
+ login
1045
+ }
1046
+ name
1047
+ parent {
1048
+ owner {
1049
+ login
1050
+ }
1051
+ name
1052
+ }
1053
+ }
1054
+ }`;
1055
+
1056
+ const rsp = await this.graphql<QueryResult>(
1057
+ provider,
1058
+ token,
1059
+ query,
1060
+ {
1061
+ ...options,
1062
+ owner: owner,
1063
+ repo: repo,
1064
+ },
1065
+ scope,
1066
+ cancellation,
1067
+ );
1068
+
1069
+ const r = rsp?.repository ?? undefined;
1070
+ if (r == null) return undefined;
1071
+
1072
+ return {
1073
+ provider: provider,
1074
+ owner: r.owner.login,
1075
+ name: r.name,
1076
+ isFork: r.parent != null,
1077
+ parent:
1078
+ r.parent != null
1079
+ ? {
1080
+ owner: r.parent.owner.login,
1081
+ name: r.parent.name,
1082
+ }
1083
+ : undefined,
1084
+ };
1085
+ } catch (ex) {
1086
+ if (ex instanceof RequestNotFoundError) return undefined;
1087
+
1088
+ throw this.handleException(ex, provider, scope);
1089
+ }
1090
+ }
1091
+
1092
+ @trace({
1093
+ args: (token, owner, repo, ref, path) => ({
1094
+ token: `<token:${token.microHash}>`,
1095
+ owner: owner,
1096
+ repo: repo,
1097
+ ref: ref,
1098
+ path: path,
1099
+ }),
1100
+ })
1101
+ async getBlame(
1102
+ token: GitHubTokenInfo,
1103
+ owner: string,
1104
+ repo: string,
1105
+ ref: string,
1106
+ path: string,
1107
+ ): Promise<GitHubBlame> {
1108
+ const scope = getScopedLogger();
1109
+
1110
+ interface QueryResult {
1111
+ viewer: { name: string };
1112
+ repository:
1113
+ | {
1114
+ object: {
1115
+ blame: {
1116
+ ranges: GitHubBlameRange[];
1117
+ };
1118
+ };
1119
+ }
1120
+ | null
1121
+ | undefined;
1122
+ }
1123
+
1124
+ try {
1125
+ const query = `query getBlameRanges(
1126
+ $owner: String!
1127
+ $repo: String!
1128
+ $ref: String!
1129
+ $path: String!
1130
+ ) {
1131
+ viewer { name }
1132
+ repository(owner: $owner, name: $repo) {
1133
+ object(expression: $ref) {
1134
+ ...on Commit {
1135
+ blame(path: $path) {
1136
+ ranges {
1137
+ startingLine
1138
+ endingLine
1139
+ commit {
1140
+ oid
1141
+ parents(first: 3) { nodes { oid } }
1142
+ message
1143
+ additions
1144
+ changedFiles
1145
+ deletions
1146
+ author {
1147
+ avatarUrl
1148
+ date
1149
+ email
1150
+ name
1151
+ }
1152
+ committer {
1153
+ date
1154
+ email
1155
+ name
1156
+ }
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ }
1162
+ }
1163
+ }`;
1164
+ const rsp = await this.graphql<QueryResult>(
1165
+ undefined,
1166
+ token,
1167
+ query,
1168
+ {
1169
+ owner: owner,
1170
+ repo: repo,
1171
+ ref: ref,
1172
+ path: path,
1173
+ },
1174
+ scope,
1175
+ );
1176
+ if (rsp == null) return emptyBlameResult;
1177
+
1178
+ const ranges = rsp.repository?.object?.blame?.ranges;
1179
+ if (ranges == null || ranges.length === 0) return { ranges: [], viewer: rsp.viewer?.name };
1180
+
1181
+ return { ranges: ranges, viewer: rsp.viewer?.name };
1182
+ } catch (ex) {
1183
+ if (ex instanceof RequestNotFoundError) return emptyBlameResult;
1184
+
1185
+ throw this.handleException(ex, undefined, scope);
1186
+ }
1187
+ }
1188
+
1189
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
1190
+ async getBranches(
1191
+ token: GitHubTokenInfo,
1192
+ owner: string,
1193
+ repo: string,
1194
+ options?: { query?: string; cursor?: string; limit?: number },
1195
+ ): Promise<PagedResult<GitHubBranch>> {
1196
+ const scope = getScopedLogger();
1197
+
1198
+ interface QueryResult {
1199
+ repository:
1200
+ | {
1201
+ refs: {
1202
+ pageInfo: {
1203
+ endCursor: string;
1204
+ hasNextPage: boolean;
1205
+ };
1206
+ nodes: GitHubBranch[];
1207
+ };
1208
+ }
1209
+ | null
1210
+ | undefined;
1211
+ }
1212
+
1213
+ try {
1214
+ const query = `query getBranches(
1215
+ $owner: String!
1216
+ $repo: String!
1217
+ $branchQuery: String
1218
+ $cursor: String
1219
+ $limit: Int = 100
1220
+ ) {
1221
+ repository(owner: $owner, name: $repo) {
1222
+ refs(query: $branchQuery, refPrefix: "refs/heads/", first: $limit, after: $cursor) {
1223
+ pageInfo {
1224
+ endCursor
1225
+ hasNextPage
1226
+ }
1227
+ nodes {
1228
+ name
1229
+ target {
1230
+ oid
1231
+ ...on Commit {
1232
+ authoredDate
1233
+ committedDate
1234
+ }
1235
+ }
1236
+ }
1237
+ }
1238
+ }
1239
+ }`;
1240
+
1241
+ const rsp = await this.graphql<QueryResult>(
1242
+ undefined,
1243
+ token,
1244
+ query,
1245
+ {
1246
+ owner: owner,
1247
+ repo: repo,
1248
+ branchQuery: options?.query,
1249
+ cursor: options?.cursor,
1250
+ limit: Math.min(100, options?.limit ?? 100),
1251
+ },
1252
+ scope,
1253
+ );
1254
+ if (rsp == null) return emptyPagedResult;
1255
+
1256
+ const refs = rsp.repository?.refs;
1257
+ if (refs == null) return emptyPagedResult;
1258
+
1259
+ return {
1260
+ paging: {
1261
+ cursor: refs.pageInfo.endCursor,
1262
+ more: refs.pageInfo.hasNextPage,
1263
+ },
1264
+ values: refs.nodes,
1265
+ };
1266
+ } catch (ex) {
1267
+ if (ex instanceof RequestNotFoundError) return emptyPagedResult;
1268
+
1269
+ throw this.handleException(ex, undefined, scope);
1270
+ }
1271
+ }
1272
+
1273
+ @trace({
1274
+ args: (token, owner, repo, ref) => ({
1275
+ token: `<token:${token.microHash}>`,
1276
+ owner: owner,
1277
+ repo: repo,
1278
+ ref: ref,
1279
+ }),
1280
+ })
1281
+ async getCommit(
1282
+ token: GitHubTokenInfo,
1283
+ owner: string,
1284
+ repo: string,
1285
+ ref: string,
1286
+ ): Promise<(GitHubCommit & { viewer?: string }) | undefined> {
1287
+ const scope = getScopedLogger();
1288
+
1289
+ try {
1290
+ const rsp = await this.request(
1291
+ undefined,
1292
+ token,
1293
+ 'GET /repos/{owner}/{repo}/commits/{ref}',
1294
+ {
1295
+ owner: owner,
1296
+ repo: repo,
1297
+ ref: ref,
1298
+ },
1299
+ scope,
1300
+ );
1301
+
1302
+ const result = rsp?.data;
1303
+ if (result == null) return undefined;
1304
+
1305
+ const { commit } = result;
1306
+ return {
1307
+ oid: result.sha,
1308
+ parents: { nodes: result.parents.map(p => ({ oid: p.sha })) },
1309
+ message: commit.message,
1310
+ additions: result.stats?.additions,
1311
+ changedFiles: result.files?.length,
1312
+ deletions: result.stats?.deletions,
1313
+ author: {
1314
+ avatarUrl: result.author?.avatar_url ?? undefined,
1315
+ date: commit.author?.date ?? new Date().toString(),
1316
+ email: commit.author?.email ?? undefined,
1317
+ name: commit.author?.name ?? '',
1318
+ },
1319
+ committer: {
1320
+ date: commit.committer?.date ?? new Date().toString(),
1321
+ email: commit.committer?.email ?? undefined,
1322
+ name: commit.committer?.name ?? '',
1323
+ },
1324
+ files: result.files,
1325
+ };
1326
+ } catch (ex) {
1327
+ if (ex instanceof RequestNotFoundError) return undefined;
1328
+
1329
+ throw this.handleException(ex, undefined, scope);
1330
+ }
1331
+
1332
+ // const results = await this.getCommits(token, owner, repo, ref, { limit: 1 });
1333
+ // if (results.values.length === 0) return undefined;
1334
+
1335
+ // return { ...results.values[0], viewer: results.viewer };
1336
+ }
1337
+
1338
+ @trace({
1339
+ args: (token, owner, repo, ref, path) => ({
1340
+ token: `<token:${token.microHash}>`,
1341
+ owner: owner,
1342
+ repo: repo,
1343
+ ref: ref,
1344
+ path: path,
1345
+ }),
1346
+ })
1347
+ async getCommitForFile(
1348
+ token: GitHubTokenInfo,
1349
+ owner: string,
1350
+ repo: string,
1351
+ ref: string,
1352
+ path: string,
1353
+ ): Promise<(GitHubCommit & { viewer?: string }) | undefined> {
1354
+ if (isSha(ref)) return this.getCommit(token, owner, repo, ref);
1355
+
1356
+ // TODO: optimize this -- only need to get the sha for the ref
1357
+ const results = await this.getCommits(token, owner, repo, ref, { limit: 1, path: path });
1358
+ if (results.values.length === 0) return undefined;
1359
+
1360
+ const commit = await this.getCommit(token, owner, repo, results.values[0].oid);
1361
+ return { ...(commit ?? results.values[0]), viewer: results.viewer };
1362
+ }
1363
+
1364
+ @trace({
1365
+ args: (token, owner, repo, refs, mode, date) => ({
1366
+ token: `<token:${token.microHash}>`,
1367
+ owner: owner,
1368
+ repo: repo,
1369
+ refs: refs,
1370
+ mode: mode,
1371
+ date: date,
1372
+ }),
1373
+ })
1374
+ async getBranchesWithCommits(
1375
+ token: GitHubTokenInfo,
1376
+ owner: string,
1377
+ repo: string,
1378
+ refs: string[],
1379
+ mode: 'contains' | 'pointsAt',
1380
+ date?: Date,
1381
+ ): Promise<string[]> {
1382
+ const scope = getScopedLogger();
1383
+
1384
+ interface QueryResult {
1385
+ repository: {
1386
+ refs: {
1387
+ nodes: {
1388
+ name: string;
1389
+ target: {
1390
+ history: {
1391
+ nodes: { oid: string }[];
1392
+ };
1393
+ };
1394
+ }[];
1395
+ };
1396
+ };
1397
+ }
1398
+
1399
+ const limit = mode === 'contains' ? 10 : 1;
1400
+
1401
+ try {
1402
+ const query = `query getBranchesWithCommits(
1403
+ $owner: String!
1404
+ $repo: String!
1405
+ $since: GitTimestamp!
1406
+ $until: GitTimestamp!
1407
+ ) {
1408
+ repository(owner: $owner, name: $repo) {
1409
+ refs(first: 20, refPrefix: "refs/heads/") {
1410
+ nodes {
1411
+ name
1412
+ target {
1413
+ ... on Commit {
1414
+ history(first: ${limit}, since: $since until: $until) {
1415
+ nodes { oid }
1416
+ }
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ }
1422
+ }`;
1423
+ const rsp = await this.graphql<QueryResult>(
1424
+ undefined,
1425
+ token,
1426
+ query,
1427
+ {
1428
+ owner: owner,
1429
+ repo: repo,
1430
+ since: date?.toISOString(),
1431
+ until: date?.toISOString(),
1432
+ },
1433
+ scope,
1434
+ );
1435
+
1436
+ const nodes = rsp?.repository?.refs?.nodes;
1437
+ if (nodes == null) return [];
1438
+
1439
+ const branches = [];
1440
+
1441
+ for (const branch of nodes) {
1442
+ for (const commit of branch.target.history.nodes) {
1443
+ if (refs.includes(commit.oid)) {
1444
+ branches.push(branch.name);
1445
+ break;
1446
+ }
1447
+ }
1448
+ }
1449
+
1450
+ return branches;
1451
+ } catch (ex) {
1452
+ if (ex instanceof RequestNotFoundError) return [];
1453
+
1454
+ throw this.handleException(ex, undefined, scope);
1455
+ }
1456
+ }
1457
+
1458
+ @trace({
1459
+ args: (token, owner, repo, ref) => ({
1460
+ token: `<token:${token.microHash}>`,
1461
+ owner: owner,
1462
+ repo: repo,
1463
+ ref: ref,
1464
+ }),
1465
+ })
1466
+ async getCommitCount(
1467
+ token: GitHubTokenInfo,
1468
+ owner: string,
1469
+ repo: string,
1470
+ ref: string,
1471
+ ): Promise<number | undefined> {
1472
+ const scope = getScopedLogger();
1473
+
1474
+ interface QueryResult {
1475
+ repository: {
1476
+ ref: {
1477
+ target: {
1478
+ history: { totalCount: number };
1479
+ };
1480
+ };
1481
+ };
1482
+ }
1483
+
1484
+ try {
1485
+ const query = `query getCommitCount(
1486
+ $owner: String!
1487
+ $repo: String!
1488
+ $ref: String!
1489
+ ) {
1490
+ repository(owner: $owner, name: $repo) {
1491
+ ref(qualifiedName: $ref) {
1492
+ target {
1493
+ ... on Commit {
1494
+ history(first: 1) {
1495
+ totalCount
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1500
+ }
1501
+ }`;
1502
+
1503
+ const rsp = await this.graphql<QueryResult>(
1504
+ undefined,
1505
+ token,
1506
+ query,
1507
+ {
1508
+ owner: owner,
1509
+ repo: repo,
1510
+ ref: ref,
1511
+ },
1512
+ scope,
1513
+ );
1514
+
1515
+ const count = rsp?.repository?.ref?.target.history.totalCount;
1516
+ return count;
1517
+ } catch (ex) {
1518
+ if (ex instanceof RequestNotFoundError) return undefined;
1519
+
1520
+ throw this.handleException(ex, undefined, scope);
1521
+ }
1522
+ }
1523
+
1524
+ @trace({
1525
+ args: (token, owner, repo, branch, refs, mode, date) => ({
1526
+ token: `<token:${token.microHash}>`,
1527
+ owner: owner,
1528
+ repo: repo,
1529
+ branch: branch,
1530
+ refs: refs,
1531
+ mode: mode,
1532
+ date: date,
1533
+ }),
1534
+ })
1535
+ async getBranchWithCommit(
1536
+ token: GitHubTokenInfo,
1537
+ owner: string,
1538
+ repo: string,
1539
+ branch: string,
1540
+ refs: string[],
1541
+ mode: 'contains' | 'pointsAt',
1542
+ date?: Date,
1543
+ ): Promise<string[]> {
1544
+ const scope = getScopedLogger();
1545
+
1546
+ interface QueryResult {
1547
+ repository: {
1548
+ ref: {
1549
+ target: {
1550
+ history: {
1551
+ nodes: { oid: string }[];
1552
+ };
1553
+ };
1554
+ };
1555
+ };
1556
+ }
1557
+
1558
+ const limit = mode === 'contains' ? 100 : 1;
1559
+
1560
+ try {
1561
+ const query = `query getBranchWithCommit(
1562
+ $owner: String!
1563
+ $repo: String!
1564
+ $ref: String!
1565
+ $since: GitTimestamp!
1566
+ $until: GitTimestamp!
1567
+ ) {
1568
+ repository(owner: $owner, name: $repo) {
1569
+ ref(qualifiedName: $ref) {
1570
+ target {
1571
+ ... on Commit {
1572
+ history(first: ${limit}, since: $since until: $until) {
1573
+ nodes { oid }
1574
+ }
1575
+ }
1576
+ }
1577
+ }
1578
+ }
1579
+ }`;
1580
+ const rsp = await this.graphql<QueryResult>(
1581
+ undefined,
1582
+ token,
1583
+ query,
1584
+ {
1585
+ owner: owner,
1586
+ repo: repo,
1587
+ ref: `refs/heads/${branch}`,
1588
+ since: date?.toISOString(),
1589
+ until: date?.toISOString(),
1590
+ },
1591
+ scope,
1592
+ );
1593
+
1594
+ const nodes = rsp?.repository?.ref?.target?.history?.nodes;
1595
+ if (nodes == null) return [];
1596
+
1597
+ const branches = [];
1598
+
1599
+ for (const commit of nodes) {
1600
+ if (refs.includes(commit.oid)) {
1601
+ branches.push(branch);
1602
+ break;
1603
+ }
1604
+ }
1605
+
1606
+ return branches;
1607
+ } catch (ex) {
1608
+ if (ex instanceof RequestNotFoundError) return [];
1609
+
1610
+ throw this.handleException(ex, undefined, scope);
1611
+ }
1612
+ }
1613
+
1614
+ @trace({
1615
+ args: (token, owner, repo, ref) => ({
1616
+ token: `<token:${token.microHash}>`,
1617
+ owner: owner,
1618
+ repo: repo,
1619
+ ref: ref,
1620
+ }),
1621
+ })
1622
+ async getCommits(
1623
+ token: GitHubTokenInfo,
1624
+ owner: string,
1625
+ repo: string,
1626
+ ref: string,
1627
+ options?: {
1628
+ after?: string;
1629
+ all?: boolean;
1630
+ authors?: GitUser[];
1631
+ before?: string;
1632
+ limit?: number;
1633
+ path?: string;
1634
+ since?: string | Date;
1635
+ until?: string | Date;
1636
+ },
1637
+ ): Promise<PagedResult<GitHubCommit> & { viewer?: string }> {
1638
+ const scope = getScopedLogger();
1639
+
1640
+ if (options?.limit === 1 && options?.path == null) {
1641
+ return this.getCommitsCoreSingle(token, owner, repo, ref);
1642
+ }
1643
+
1644
+ if (isRevisionRange(ref)) {
1645
+ return this.getCommitsCoreRange(token, owner, repo, ref);
1646
+ }
1647
+
1648
+ interface QueryResult {
1649
+ viewer: { name: string };
1650
+ repository:
1651
+ | {
1652
+ object:
1653
+ | {
1654
+ history: {
1655
+ pageInfo: GitHubPageInfo;
1656
+ nodes: GitHubCommit[];
1657
+ };
1658
+ }
1659
+ | null
1660
+ | undefined;
1661
+ }
1662
+ | null
1663
+ | undefined;
1664
+ }
1665
+
1666
+ try {
1667
+ const query = `query getCommits(
1668
+ $owner: String!
1669
+ $repo: String!
1670
+ $ref: String!
1671
+ $path: String
1672
+ $author: CommitAuthor
1673
+ $after: String
1674
+ $before: String
1675
+ $limit: Int = 100
1676
+ $since: GitTimestamp
1677
+ $until: GitTimestamp
1678
+ ) {
1679
+ viewer { name }
1680
+ repository(name: $repo, owner: $owner) {
1681
+ object(expression: $ref) {
1682
+ ... on Commit {
1683
+ history(first: $limit, author: $author, path: $path, after: $after, before: $before, since: $since, until: $until) {
1684
+ pageInfo {
1685
+ startCursor
1686
+ endCursor
1687
+ hasNextPage
1688
+ hasPreviousPage
1689
+ }
1690
+ nodes {
1691
+ ... on Commit {
1692
+ oid
1693
+ message
1694
+ parents(first: 3) { nodes { oid } }
1695
+ additions
1696
+ changedFiles
1697
+ deletions
1698
+ author {
1699
+ avatarUrl
1700
+ date
1701
+ email
1702
+ name
1703
+ }
1704
+ committer {
1705
+ date
1706
+ email
1707
+ name
1708
+ }
1709
+ }
1710
+ }
1711
+ }
1712
+ }
1713
+ }
1714
+ }
1715
+ }`;
1716
+
1717
+ let authors: { id?: string; emails?: string[] } | undefined;
1718
+ if (options?.authors != null) {
1719
+ if (options.authors.length === 1) {
1720
+ const [author] = options.authors;
1721
+ authors = {
1722
+ id: author.id,
1723
+ emails: author.email ? [author.email] : undefined,
1724
+ };
1725
+ } else {
1726
+ const emails = options.authors.filter(a => a.email).map(a => a.email!);
1727
+ authors = emails.length ? { emails: emails } : undefined;
1728
+ }
1729
+ }
1730
+
1731
+ const rsp = await this.graphql<QueryResult>(
1732
+ undefined,
1733
+ token,
1734
+ query,
1735
+ {
1736
+ owner: owner,
1737
+ repo: repo,
1738
+ ref: ref,
1739
+ after: options?.after,
1740
+ before: options?.before,
1741
+ path: options?.path,
1742
+ author: authors,
1743
+ limit: Math.min(100, options?.limit ?? 100),
1744
+ since: typeof options?.since === 'string' ? options?.since : options?.since?.toISOString(),
1745
+ until: typeof options?.until === 'string' ? options?.until : options?.until?.toISOString(),
1746
+ },
1747
+ scope,
1748
+ );
1749
+ const history = rsp?.repository?.object?.history;
1750
+ if (history == null) return emptyPagedResult;
1751
+
1752
+ return {
1753
+ paging:
1754
+ history.pageInfo.endCursor != null
1755
+ ? {
1756
+ cursor: history.pageInfo.endCursor ?? undefined,
1757
+ more: history.pageInfo.hasNextPage,
1758
+ }
1759
+ : undefined,
1760
+ values: history.nodes,
1761
+ viewer: rsp?.viewer.name,
1762
+ };
1763
+ } catch (ex) {
1764
+ if (ex instanceof RequestNotFoundError) return emptyPagedResult;
1765
+
1766
+ throw this.handleException(ex, undefined, scope);
1767
+ }
1768
+ }
1769
+
1770
+ private async getCommitsCoreRange(
1771
+ token: GitHubTokenInfo,
1772
+ owner: string,
1773
+ repo: string,
1774
+ range: GitRevisionRange,
1775
+ ): Promise<PagedResult<GitHubCommit> & { viewer?: string }> {
1776
+ const scope = getScopedLogger();
1777
+
1778
+ try {
1779
+ const result = await this.getComparison(token, owner, repo, range);
1780
+ if (result == null) return emptyPagedResult;
1781
+
1782
+ return {
1783
+ values: result.commits
1784
+ ?.map<GitHubCommit>(r => ({
1785
+ oid: r.sha,
1786
+ parents: { nodes: r.parents.map(p => ({ oid: p.sha })) },
1787
+ message: r.commit.message,
1788
+ author: {
1789
+ avatarUrl: r.author?.avatar_url ?? undefined,
1790
+ date: r.commit.author?.date ?? r.commit.committer?.date ?? new Date().toString(),
1791
+ email: r.author?.email ?? r.commit.author?.email ?? undefined,
1792
+ name: r.author?.name ?? r.commit.author?.name ?? '',
1793
+ },
1794
+ committer: {
1795
+ date: r.commit.committer?.date ?? new Date().toString(),
1796
+ email: r.committer?.email ?? r.commit.committer?.email ?? undefined,
1797
+ name: r.committer?.name ?? r.commit.committer?.name ?? '',
1798
+ },
1799
+ }))
1800
+ .reverse(),
1801
+ };
1802
+ } catch (ex) {
1803
+ if (ex instanceof RequestNotFoundError) return emptyPagedResult;
1804
+
1805
+ throw this.handleException(ex, undefined, scope);
1806
+ }
1807
+ }
1808
+
1809
+ private async getCommitsCoreSingle(
1810
+ token: GitHubTokenInfo,
1811
+ owner: string,
1812
+ repo: string,
1813
+ ref: string,
1814
+ ): Promise<PagedResult<GitHubCommit> & { viewer?: string }> {
1815
+ const scope = getScopedLogger();
1816
+
1817
+ interface QueryResult {
1818
+ viewer: { name: string };
1819
+ repository: { object: GitHubCommit } | null | undefined;
1820
+ }
1821
+
1822
+ try {
1823
+ const query = `query getCommit(
1824
+ $owner: String!
1825
+ $repo: String!
1826
+ $ref: String!
1827
+ ) {
1828
+ viewer { name }
1829
+ repository(name: $repo owner: $owner) {
1830
+ object(expression: $ref) {
1831
+ ...on Commit {
1832
+ oid
1833
+ parents(first: 3) { nodes { oid } }
1834
+ message
1835
+ additions
1836
+ changedFiles
1837
+ deletions
1838
+ author {
1839
+ avatarUrl
1840
+ date
1841
+ email
1842
+ name
1843
+ }
1844
+ committer {
1845
+ date
1846
+ email
1847
+ name
1848
+ }
1849
+ }
1850
+ }
1851
+ }
1852
+ }`;
1853
+
1854
+ const rsp = await this.graphql<QueryResult>(
1855
+ undefined,
1856
+ token,
1857
+ query,
1858
+ {
1859
+ owner: owner,
1860
+ repo: repo,
1861
+ ref: ref,
1862
+ },
1863
+ scope,
1864
+ );
1865
+ if (rsp == null) return emptyPagedResult;
1866
+
1867
+ const commit = rsp.repository?.object;
1868
+ return commit != null ? { values: [commit], viewer: rsp.viewer.name } : emptyPagedResult;
1869
+ } catch (ex) {
1870
+ if (ex instanceof RequestNotFoundError) return emptyPagedResult;
1871
+
1872
+ throw this.handleException(ex, undefined, scope);
1873
+ }
1874
+ }
1875
+
1876
+ @trace({
1877
+ args: (token, owner, repo, ref) => ({
1878
+ token: `<token:${token.microHash}>`,
1879
+ owner: owner,
1880
+ repo: repo,
1881
+ ref: ref,
1882
+ }),
1883
+ })
1884
+ async getCommitRefs(
1885
+ token: GitHubTokenInfo,
1886
+ owner: string,
1887
+ repo: string,
1888
+ ref: string,
1889
+ options?: {
1890
+ after?: string;
1891
+ before?: string;
1892
+ first?: number;
1893
+ last?: number;
1894
+ path?: string;
1895
+ since?: string;
1896
+ until?: string;
1897
+ },
1898
+ ): Promise<GitHubPagedResult<GitHubCommitRef> | undefined> {
1899
+ const scope = getScopedLogger();
1900
+
1901
+ interface QueryResult {
1902
+ repository:
1903
+ | {
1904
+ object:
1905
+ | {
1906
+ history: {
1907
+ pageInfo: GitHubPageInfo;
1908
+ totalCount: number;
1909
+ nodes: GitHubCommitRef[];
1910
+ };
1911
+ }
1912
+ | null
1913
+ | undefined;
1914
+ }
1915
+ | null
1916
+ | undefined;
1917
+ }
1918
+
1919
+ try {
1920
+ const query = `query getCommitRefs(
1921
+ $owner: String!
1922
+ $repo: String!
1923
+ $ref: String!
1924
+ $after: String
1925
+ $before: String
1926
+ $first: Int
1927
+ $last: Int
1928
+ $path: String
1929
+ $since: GitTimestamp
1930
+ $until: GitTimestamp
1931
+ ) {
1932
+ repository(name: $repo, owner: $owner) {
1933
+ object(expression: $ref) {
1934
+ ... on Commit {
1935
+ history(first: $first, last: $last, path: $path, since: $since, until: $until, after: $after, before: $before) {
1936
+ pageInfo { startCursor, endCursor, hasNextPage, hasPreviousPage }
1937
+ totalCount
1938
+ nodes { oid }
1939
+ }
1940
+ }
1941
+ }
1942
+ }
1943
+ }`;
1944
+
1945
+ const rsp = await this.graphql<QueryResult>(
1946
+ undefined,
1947
+ token,
1948
+ query,
1949
+ {
1950
+ owner: owner,
1951
+ repo: repo,
1952
+ ref: ref,
1953
+ path: options?.path,
1954
+ first: options?.first,
1955
+ last: options?.last,
1956
+ after: options?.after,
1957
+ before: options?.before,
1958
+ since: options?.since,
1959
+ until: options?.until,
1960
+ },
1961
+ scope,
1962
+ );
1963
+ const history = rsp?.repository?.object?.history;
1964
+ if (history == null) return undefined;
1965
+
1966
+ return {
1967
+ pageInfo: history.pageInfo,
1968
+ totalCount: history.totalCount,
1969
+ values: history.nodes,
1970
+ };
1971
+ } catch (ex) {
1972
+ if (ex instanceof RequestNotFoundError) return undefined;
1973
+
1974
+ throw this.handleException(ex, undefined, scope);
1975
+ }
1976
+ }
1977
+
1978
+ @trace({
1979
+ args: (token, owner, repo, ref, date) => ({
1980
+ token: `<token:${token.microHash}>`,
1981
+ owner: owner,
1982
+ repo: repo,
1983
+ ref: ref,
1984
+ date: date,
1985
+ }),
1986
+ })
1987
+ async getTagsWithCommit(
1988
+ token: GitHubTokenInfo,
1989
+ owner: string,
1990
+ repo: string,
1991
+ ref: string,
1992
+ date: Date,
1993
+ ): Promise<string[]> {
1994
+ const scope = getScopedLogger();
1995
+
1996
+ interface QueryResult {
1997
+ repository: {
1998
+ refs: {
1999
+ nodes: {
2000
+ name: string;
2001
+ target: {
2002
+ history: {
2003
+ nodes: { oid: string }[];
2004
+ };
2005
+ };
2006
+ }[];
2007
+ };
2008
+ };
2009
+ }
2010
+
2011
+ try {
2012
+ const query = `query getTagsWithCommit(
2013
+ $owner: String!
2014
+ $repo: String!
2015
+ $since: GitTimestamp!
2016
+ $until: GitTimestamp!
2017
+ ) {
2018
+ repository(owner: $owner, name: $repo) {
2019
+ refs(first: 20, refPrefix: "refs/tags/") {
2020
+ nodes {
2021
+ name
2022
+ target {
2023
+ ... on Commit {
2024
+ history(first: 3, since: $since until: $until) {
2025
+ nodes { oid }
2026
+ }
2027
+ }
2028
+ }
2029
+ }
2030
+ }
2031
+ }
2032
+ }`;
2033
+ const rsp = await this.graphql<QueryResult>(
2034
+ undefined,
2035
+ token,
2036
+ query,
2037
+ {
2038
+ owner: owner,
2039
+ repo: repo,
2040
+ since: date.toISOString(),
2041
+ until: date.toISOString(),
2042
+ },
2043
+ scope,
2044
+ );
2045
+
2046
+ const nodes = rsp?.repository?.refs?.nodes;
2047
+ if (nodes == null) return [];
2048
+
2049
+ const tags = [];
2050
+
2051
+ for (const tag of nodes) {
2052
+ for (const commit of tag.target.history.nodes) {
2053
+ if (commit.oid === ref) {
2054
+ tags.push(tag.name);
2055
+ break;
2056
+ }
2057
+ }
2058
+ }
2059
+
2060
+ return tags;
2061
+ } catch (ex) {
2062
+ if (ex instanceof RequestNotFoundError) return [];
2063
+
2064
+ throw this.handleException(ex, undefined, scope);
2065
+ }
2066
+ }
2067
+
2068
+ @trace({
2069
+ args: (token, owner, repo, ref, path, sha) => ({
2070
+ token: `<token:${token.microHash}>`,
2071
+ owner: owner,
2072
+ repo: repo,
2073
+ ref: ref,
2074
+ path: path,
2075
+ sha: sha,
2076
+ }),
2077
+ })
2078
+ async getNextCommitRefs(
2079
+ token: GitHubTokenInfo,
2080
+ owner: string,
2081
+ repo: string,
2082
+ ref: string,
2083
+ path: string,
2084
+ sha: string,
2085
+ ): Promise<string[]> {
2086
+ // Get the commit date of the current commit
2087
+ const commitDate = await this.getCommitDate(token, owner, repo, sha);
2088
+ if (commitDate == null) return [];
2089
+
2090
+ // Get a resultset (just need the cursor and totals), to get the page info we need to construct a cursor to page backwards
2091
+ let result = await this.getCommitRefs(token, owner, repo, ref, { path: path, first: 1, since: commitDate });
2092
+ if (result == null) return [];
2093
+
2094
+ // Construct a cursor to allow use to walk backwards in time (starting at the tip going back in time until the commit date)
2095
+ const cursor = `${result.pageInfo.startCursor!.split(' ', 1)[0]} ${result.totalCount}`;
2096
+
2097
+ let last;
2098
+ [, last] = cursor.split(' ', 2);
2099
+ // We can't ask for more commits than are left in the cursor (but try to get more to be safe, since the date isn't exact enough)
2100
+ last = Math.min(parseInt(last, 10), 5);
2101
+
2102
+ // Get the set of refs before the cursor
2103
+ result = await this.getCommitRefs(token, owner, repo, ref, { path: path, last: last, before: cursor });
2104
+ if (result == null) return [];
2105
+
2106
+ const nexts: string[] = [];
2107
+
2108
+ for (const { oid } of result.values) {
2109
+ if (oid === sha) break;
2110
+
2111
+ nexts.push(oid);
2112
+ }
2113
+
2114
+ return nexts.reverse();
2115
+ }
2116
+
2117
+ private async getCommitDate(
2118
+ token: GitHubTokenInfo,
2119
+ owner: string,
2120
+ repo: string,
2121
+ sha: string,
2122
+ ): Promise<string | undefined> {
2123
+ const scope = getScopedLogger();
2124
+
2125
+ interface QueryResult {
2126
+ repository:
2127
+ | {
2128
+ object: { committer: { date: string } } | null | undefined;
2129
+ }
2130
+ | null
2131
+ | undefined;
2132
+ }
2133
+
2134
+ try {
2135
+ const query = `query getCommitDate(
2136
+ $owner: String!
2137
+ $repo: String!
2138
+ $sha: GitObjectID!
2139
+ ) {
2140
+ repository(name: $repo, owner: $owner) {
2141
+ object(oid: $sha) {
2142
+ ... on Commit { committer { date } }
2143
+ }
2144
+ }
2145
+ }`;
2146
+
2147
+ const rsp = await this.graphql<QueryResult>(
2148
+ undefined,
2149
+ token,
2150
+ query,
2151
+ {
2152
+ owner: owner,
2153
+ repo: repo,
2154
+ sha: sha,
2155
+ },
2156
+ scope,
2157
+ );
2158
+ const date = rsp?.repository?.object?.committer.date;
2159
+ return date;
2160
+ } catch (ex) {
2161
+ if (ex instanceof RequestNotFoundError) return undefined;
2162
+
2163
+ throw this.handleException(ex, undefined, scope);
2164
+ }
2165
+ }
2166
+
2167
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
2168
+ async getContributors(token: GitHubTokenInfo, owner: string, repo: string): Promise<GitHubContributor[]> {
2169
+ const scope = getScopedLogger();
2170
+
2171
+ // TODO@eamodio implement pagination
2172
+
2173
+ try {
2174
+ const rsp = await this.request(
2175
+ undefined,
2176
+ token,
2177
+ 'GET /repos/{owner}/{repo}/contributors',
2178
+ {
2179
+ owner: owner,
2180
+ repo: repo,
2181
+ per_page: 100,
2182
+ },
2183
+ scope,
2184
+ );
2185
+
2186
+ const result = rsp?.data;
2187
+ if (result == null) return [];
2188
+
2189
+ return rsp.data;
2190
+ } catch (ex) {
2191
+ if (ex instanceof RequestNotFoundError) return [];
2192
+
2193
+ throw this.handleException(ex, undefined, scope);
2194
+ }
2195
+ }
2196
+
2197
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
2198
+ async getDefaultBranchName(token: GitHubTokenInfo, owner: string, repo: string): Promise<string | undefined> {
2199
+ const scope = getScopedLogger();
2200
+
2201
+ interface QueryResult {
2202
+ repository:
2203
+ | {
2204
+ defaultBranchRef: { name: string } | null | undefined;
2205
+ }
2206
+ | null
2207
+ | undefined;
2208
+ }
2209
+
2210
+ try {
2211
+ const query = `query getDefaultBranch(
2212
+ $owner: String!
2213
+ $repo: String!
2214
+ ) {
2215
+ repository(owner: $owner, name: $repo) {
2216
+ defaultBranchRef {
2217
+ name
2218
+ }
2219
+ }
2220
+ }`;
2221
+
2222
+ const rsp = await this.graphql<QueryResult>(
2223
+ undefined,
2224
+ token,
2225
+ query,
2226
+ {
2227
+ owner: owner,
2228
+ repo: repo,
2229
+ },
2230
+ scope,
2231
+ );
2232
+ if (rsp == null) return undefined;
2233
+
2234
+ return rsp.repository?.defaultBranchRef?.name ?? undefined;
2235
+ } catch (ex) {
2236
+ if (ex instanceof RequestNotFoundError) return undefined;
2237
+
2238
+ throw this.handleException(ex, undefined, scope);
2239
+ }
2240
+ }
2241
+
2242
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
2243
+ async getCurrentUser(token: GitHubTokenInfo, owner: string, repo: string): Promise<GitUser | undefined> {
2244
+ const scope = getScopedLogger();
2245
+
2246
+ interface QueryResult {
2247
+ viewer: {
2248
+ name: string;
2249
+ email: string;
2250
+ login: string;
2251
+ id: string;
2252
+ };
2253
+ repository: { viewerPermission: string } | null | undefined;
2254
+ }
2255
+
2256
+ try {
2257
+ const query = `query getCurrentUser(
2258
+ $owner: String!
2259
+ $repo: String!
2260
+ ) {
2261
+ viewer { name, email, login, id }
2262
+ repository(owner: $owner, name: $repo) { viewerPermission }
2263
+ }`;
2264
+
2265
+ const rsp = await this.graphql<QueryResult>(
2266
+ undefined,
2267
+ token,
2268
+ query,
2269
+ {
2270
+ owner: owner,
2271
+ repo: repo,
2272
+ },
2273
+ scope,
2274
+ );
2275
+ if (rsp == null) return undefined;
2276
+
2277
+ return {
2278
+ name: rsp.viewer?.name,
2279
+ email: rsp.viewer?.email,
2280
+ username: rsp.viewer?.login,
2281
+ id: rsp.viewer?.id,
2282
+ };
2283
+ } catch (ex) {
2284
+ if (ex instanceof RequestNotFoundError) return undefined;
2285
+
2286
+ throw this.handleException(ex, undefined, scope);
2287
+ }
2288
+ }
2289
+
2290
+ @trace({
2291
+ args: (token, owner, repo, range) => ({
2292
+ token: `<token:${token.microHash}>`,
2293
+ owner: owner,
2294
+ repo: repo,
2295
+ range: range,
2296
+ }),
2297
+ })
2298
+ async getComparison(
2299
+ token: GitHubTokenInfo,
2300
+ owner: string,
2301
+ repo: string,
2302
+ range: GitRevisionRange,
2303
+ ): Promise<Endpoints['GET /repos/{owner}/{repo}/compare/{basehead}']['response']['data'] | undefined> {
2304
+ const scope = getScopedLogger();
2305
+
2306
+ if (!isRevisionRange(range, 'qualified-triple-dot')) {
2307
+ // GitHub doesn't support the `..` range notation, so convert it to `...` since it will work for many of our usages
2308
+ const parts = getRevisionRangeParts(range);
2309
+ range = createRevisionRange(parts?.left || 'HEAD', parts?.right || 'HEAD', '...');
2310
+ }
2311
+
2312
+ try {
2313
+ const rsp = await this.request(
2314
+ undefined,
2315
+ token,
2316
+ 'GET /repos/{owner}/{repo}/compare/{basehead}',
2317
+ {
2318
+ owner: owner,
2319
+ repo: repo,
2320
+ basehead: range,
2321
+ },
2322
+ scope,
2323
+ );
2324
+
2325
+ const result = rsp?.data;
2326
+ if (result == null) return undefined;
2327
+
2328
+ return result;
2329
+ } catch (ex) {
2330
+ if (ex instanceof RequestNotFoundError) return undefined;
2331
+
2332
+ throw this.handleException(ex, undefined, scope);
2333
+ }
2334
+ }
2335
+
2336
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
2337
+ async getRepositoryVisibility(
2338
+ token: GitHubTokenInfo,
2339
+ owner: string,
2340
+ repo: string,
2341
+ ): Promise<RepositoryVisibility | undefined> {
2342
+ const scope = getScopedLogger();
2343
+
2344
+ interface QueryResult {
2345
+ repository:
2346
+ | {
2347
+ visibility: 'PUBLIC' | 'PRIVATE' | 'INTERNAL';
2348
+ }
2349
+ | null
2350
+ | undefined;
2351
+ }
2352
+
2353
+ try {
2354
+ const query = `query getRepositoryVisibility(
2355
+ $owner: String!
2356
+ $repo: String!
2357
+ ) {
2358
+ repository(owner: $owner, name: $repo) {
2359
+ visibility
2360
+ }
2361
+ }`;
2362
+
2363
+ const rsp = await this.graphql<QueryResult>(
2364
+ undefined,
2365
+ token,
2366
+ query,
2367
+ {
2368
+ owner: owner,
2369
+ repo: repo,
2370
+ },
2371
+ scope,
2372
+ );
2373
+ if (rsp?.repository?.visibility == null) return undefined;
2374
+
2375
+ return rsp.repository.visibility === 'PUBLIC' ? 'public' : 'private';
2376
+ } catch (ex) {
2377
+ if (ex instanceof RequestNotFoundError) return undefined;
2378
+
2379
+ throw this.handleException(ex, undefined, scope);
2380
+ }
2381
+ }
2382
+
2383
+ @trace({ args: (token, owner, repo) => ({ token: `<token:${token.microHash}>`, owner: owner, repo: repo }) })
2384
+ async getTags(
2385
+ token: GitHubTokenInfo,
2386
+ owner: string,
2387
+ repo: string,
2388
+ options?: { query?: string; cursor?: string; limit?: number },
2389
+ ): Promise<PagedResult<GitHubTag>> {
2390
+ const scope = getScopedLogger();
2391
+
2392
+ interface QueryResult {
2393
+ repository:
2394
+ | {
2395
+ refs: {
2396
+ pageInfo: {
2397
+ endCursor: string;
2398
+ hasNextPage: boolean;
2399
+ };
2400
+ nodes: GitHubTag[];
2401
+ };
2402
+ }
2403
+ | null
2404
+ | undefined;
2405
+ }
2406
+
2407
+ try {
2408
+ const query = `query getTags(
2409
+ $owner: String!
2410
+ $repo: String!
2411
+ $tagQuery: String
2412
+ $cursor: String
2413
+ $limit: Int = 100
2414
+ ) {
2415
+ repository(owner: $owner, name: $repo) {
2416
+ refs(query: $tagQuery, refPrefix: "refs/tags/", first: $limit, after: $cursor, orderBy: { field: TAG_COMMIT_DATE, direction: DESC }) {
2417
+ pageInfo {
2418
+ endCursor
2419
+ hasNextPage
2420
+ }
2421
+ nodes {
2422
+ name
2423
+ target {
2424
+ oid
2425
+ ...on Tag {
2426
+ message
2427
+ tagger { date }
2428
+ target {
2429
+ ...on Commit {
2430
+ oid
2431
+ authoredDate
2432
+ committedDate
2433
+ message
2434
+ }
2435
+ }
2436
+ }
2437
+ }
2438
+ }
2439
+ }
2440
+ }
2441
+ }`;
2442
+
2443
+ const rsp = await this.graphql<QueryResult>(
2444
+ undefined,
2445
+ token,
2446
+ query,
2447
+ {
2448
+ owner: owner,
2449
+ repo: repo,
2450
+ tagQuery: options?.query,
2451
+ cursor: options?.cursor,
2452
+ limit: Math.min(100, options?.limit ?? 100),
2453
+ },
2454
+ scope,
2455
+ );
2456
+ if (rsp == null) return emptyPagedResult;
2457
+
2458
+ const refs = rsp.repository?.refs;
2459
+ if (refs == null) return emptyPagedResult;
2460
+
2461
+ return {
2462
+ paging: {
2463
+ cursor: refs.pageInfo.endCursor,
2464
+ more: refs.pageInfo.hasNextPage,
2465
+ },
2466
+ values: refs.nodes,
2467
+ };
2468
+ } catch (ex) {
2469
+ if (ex instanceof RequestNotFoundError) return emptyPagedResult;
2470
+
2471
+ throw this.handleException(ex, undefined, scope);
2472
+ }
2473
+ }
2474
+
2475
+ @trace({
2476
+ args: (token, owner, repo, ref, path) => ({
2477
+ token: `<token:${token.microHash}>`,
2478
+ owner: owner,
2479
+ repo: repo,
2480
+ ref: ref,
2481
+ path: path,
2482
+ }),
2483
+ })
2484
+ async resolveReference(
2485
+ token: GitHubTokenInfo,
2486
+ owner: string,
2487
+ repo: string,
2488
+ ref: string,
2489
+ path?: string,
2490
+ ): Promise<string | undefined> {
2491
+ const scope = getScopedLogger();
2492
+
2493
+ try {
2494
+ if (!path) {
2495
+ interface QueryResult {
2496
+ repository: { object: GitHubCommitRef } | null | undefined;
2497
+ }
2498
+
2499
+ const query = `query resolveReference(
2500
+ $owner: String!
2501
+ $repo: String!
2502
+ $ref: String!
2503
+ ) {
2504
+ repository(owner: $owner, name: $repo) {
2505
+ object(expression: $ref) {
2506
+ oid
2507
+ }
2508
+ }
2509
+ }`;
2510
+
2511
+ const rsp = await this.graphql<QueryResult>(
2512
+ undefined,
2513
+ token,
2514
+ query,
2515
+ {
2516
+ owner: owner,
2517
+ repo: repo,
2518
+ ref: ref,
2519
+ },
2520
+ scope,
2521
+ );
2522
+ return rsp?.repository?.object?.oid ?? undefined;
2523
+ }
2524
+
2525
+ interface QueryResult {
2526
+ repository:
2527
+ | {
2528
+ object: {
2529
+ history: {
2530
+ nodes: GitHubCommitRef[];
2531
+ };
2532
+ };
2533
+ }
2534
+ | null
2535
+ | undefined;
2536
+ }
2537
+
2538
+ const query = `query resolveReference(
2539
+ $owner: String!
2540
+ $repo: String!
2541
+ $ref: String!
2542
+ $path: String!
2543
+ ) {
2544
+ repository(owner: $owner, name: $repo) {
2545
+ object(expression: $ref) {
2546
+ ... on Commit {
2547
+ history(first: 1, path: $path) {
2548
+ nodes { oid }
2549
+ }
2550
+ }
2551
+ }
2552
+ }
2553
+ }`;
2554
+
2555
+ const rsp = await this.graphql<QueryResult>(
2556
+ undefined,
2557
+ token,
2558
+ query,
2559
+ {
2560
+ owner: owner,
2561
+ repo: repo,
2562
+ ref: ref,
2563
+ path: path,
2564
+ },
2565
+ scope,
2566
+ );
2567
+ return rsp?.repository?.object?.history.nodes?.[0]?.oid ?? undefined;
2568
+ } catch (ex) {
2569
+ if (ex instanceof RequestNotFoundError) return undefined;
2570
+
2571
+ throw this.handleException(ex, undefined, scope);
2572
+ }
2573
+ }
2574
+
2575
+ @trace({ args: (token, query) => ({ token: `<token:${token.microHash}>`, query: query }) })
2576
+ async searchCommits(
2577
+ token: GitHubTokenInfo,
2578
+ query: string,
2579
+ options?: {
2580
+ cursor?: string;
2581
+ limit?: number;
2582
+ order?: 'asc' | 'desc' | undefined;
2583
+ sort?: 'author-date' | 'committer-date' | undefined;
2584
+ },
2585
+ ): Promise<GitHubPagedResult<GitHubCommit> | undefined> {
2586
+ const scope = getScopedLogger();
2587
+
2588
+ const limit = Math.min(100, options?.limit ?? 100);
2589
+
2590
+ let page;
2591
+ let pageSize;
2592
+ let previousCount;
2593
+ if (options?.cursor != null) {
2594
+ [page, pageSize, previousCount] = options.cursor.split(' ', 3);
2595
+ page = parseInt(page, 10);
2596
+ // TODO@eamodio need to figure out how allow different page sizes if the limit changes
2597
+ pageSize = parseInt(pageSize, 10);
2598
+ previousCount = parseInt(previousCount, 10);
2599
+ } else {
2600
+ page = 1;
2601
+ pageSize = limit;
2602
+ previousCount = 0;
2603
+ }
2604
+
2605
+ try {
2606
+ const rsp = await this.request(
2607
+ undefined,
2608
+ token,
2609
+ 'GET /search/commits',
2610
+ {
2611
+ q: query,
2612
+ sort: options?.sort,
2613
+ order: options?.order,
2614
+ per_page: pageSize,
2615
+ page: page,
2616
+ },
2617
+ scope,
2618
+ );
2619
+
2620
+ const data = rsp?.data;
2621
+ if (data == null || data.items.length === 0) return undefined;
2622
+
2623
+ const commits = data.items.map<GitHubCommit>(result => ({
2624
+ oid: result.sha,
2625
+ parents: { nodes: result.parents.map(p => ({ oid: p.sha! })) },
2626
+ message: result.commit.message,
2627
+ author: {
2628
+ avatarUrl: result.author?.avatar_url ?? undefined,
2629
+ date: result.commit.author?.date ?? result.commit.committer?.date ?? new Date().toString(),
2630
+ email: result.author?.email ?? result.commit.author?.email ?? undefined,
2631
+ name: result.author?.name ?? result.commit.author?.name ?? '',
2632
+ },
2633
+ committer: {
2634
+ date: result.commit.committer?.date ?? result.committer?.date ?? new Date().toString(),
2635
+ email: result.committer?.email ?? result.commit.committer?.email ?? undefined,
2636
+ name: result.committer?.name ?? result.commit.committer?.name ?? '',
2637
+ },
2638
+ }));
2639
+
2640
+ const count = previousCount + data.items.length;
2641
+ const hasMore = data.incomplete_results || data.total_count > count;
2642
+
2643
+ return {
2644
+ pageInfo: {
2645
+ startCursor: `${page} ${pageSize} ${previousCount}`,
2646
+ endCursor: hasMore ? `${page + 1} ${pageSize} ${count}` : undefined,
2647
+ hasPreviousPage: data.total_count > 0 && page > 1,
2648
+ hasNextPage: hasMore,
2649
+ },
2650
+ totalCount: data.total_count,
2651
+ values: commits,
2652
+ };
2653
+ } catch (ex) {
2654
+ if (ex instanceof RequestNotFoundError) return undefined;
2655
+
2656
+ throw this.handleException(ex, undefined, scope);
2657
+ }
2658
+ }
2659
+
2660
+ @trace({ args: (token, query) => ({ token: `<token:${token.microHash}>`, query: query }) })
2661
+ async searchCommitShas(
2662
+ token: GitHubTokenInfo,
2663
+ query: string,
2664
+ options?: {
2665
+ cursor?: string;
2666
+ limit?: number;
2667
+ order?: 'asc' | 'desc' | undefined;
2668
+ sort?: 'author-date' | 'committer-date' | undefined;
2669
+ },
2670
+ ): Promise<GitHubPagedResult<{ sha: string; authorDate: number; committerDate: number }> | undefined> {
2671
+ const scope = getScopedLogger();
2672
+
2673
+ const limit = Math.min(100, options?.limit ?? 100);
2674
+
2675
+ let page;
2676
+ let pageSize;
2677
+ let previousCount;
2678
+ if (options?.cursor != null) {
2679
+ [page, pageSize, previousCount] = options.cursor.split(' ', 3);
2680
+ page = parseInt(page, 10);
2681
+ // TODO@eamodio need to figure out how allow different page sizes if the limit changes
2682
+ pageSize = parseInt(pageSize, 10);
2683
+ previousCount = parseInt(previousCount, 10);
2684
+ } else {
2685
+ page = 1;
2686
+ pageSize = limit;
2687
+ previousCount = 0;
2688
+ }
2689
+
2690
+ try {
2691
+ const rsp = await this.request(
2692
+ undefined,
2693
+ token,
2694
+ 'GET /search/commits',
2695
+ {
2696
+ q: query,
2697
+ sort: options?.sort,
2698
+ order: options?.order,
2699
+ per_page: pageSize,
2700
+ page: page,
2701
+ },
2702
+ scope,
2703
+ );
2704
+
2705
+ const data = rsp?.data;
2706
+ if (data == null || data.items.length === 0) return undefined;
2707
+
2708
+ const count = previousCount + data.items.length;
2709
+ const hasMore = data.incomplete_results || data.total_count > count;
2710
+
2711
+ return {
2712
+ pageInfo: {
2713
+ startCursor: `${page} ${pageSize} ${previousCount}`,
2714
+ endCursor: hasMore ? `${page + 1} ${pageSize} ${count}` : undefined,
2715
+ hasPreviousPage: data.total_count > 0 && page > 1,
2716
+ hasNextPage: hasMore,
2717
+ },
2718
+ totalCount: data.total_count,
2719
+ values: data.items.map(r => ({
2720
+ sha: r.sha,
2721
+ authorDate: new Date(r.commit.author.date).getTime(),
2722
+ committerDate: new Date(r.commit.committer?.date ?? r.commit.author.date).getTime(),
2723
+ })),
2724
+ };
2725
+ } catch (ex) {
2726
+ if (ex instanceof RequestNotFoundError) return undefined;
2727
+
2728
+ throw this.handleException(ex, undefined, scope);
2729
+ }
2730
+ }
2731
+
2732
+ private _enterpriseVersions = new Map<string, Version | null>();
2733
+
2734
+ @trace({ args: (provider, token) => ({ provider: provider?.name, token: `<token:${token.microHash}>` }) })
2735
+ private async getEnterpriseVersion(
2736
+ provider: Provider | undefined,
2737
+ token: GitHubTokenInfo,
2738
+ options?: { baseUrl?: string },
2739
+ ): Promise<Version | undefined> {
2740
+ const { accessToken } = token;
2741
+ let version = this._enterpriseVersions.get(accessToken);
2742
+ if (version != null) return version;
2743
+ if (version === null) return undefined;
2744
+
2745
+ const scope = getScopedLogger();
2746
+
2747
+ try {
2748
+ const rsp = await this.request(provider, token, 'GET /meta', options, scope);
2749
+ const v = (rsp?.data as unknown as { installed_version: string | null | undefined })?.installed_version;
2750
+ version = v ? fromString(v) : null;
2751
+ } catch (_ex) {
2752
+ debugger;
2753
+ version = null;
2754
+ }
2755
+
2756
+ this._enterpriseVersions.set(accessToken, version);
2757
+ return version ?? undefined;
2758
+ }
2759
+
2760
+ private async graphql<T>(
2761
+ provider: Provider | undefined,
2762
+ token: GitHubTokenInfo,
2763
+ query: string,
2764
+ variables: RequestParameters,
2765
+ scope: ScopedLogger | undefined,
2766
+ cancellation?: CancellationToken | undefined,
2767
+ ): Promise<T | undefined> {
2768
+ const { accessToken, ...tokenInfo } = token;
2769
+ try {
2770
+ let aborter: AbortController | undefined;
2771
+ if (cancellation != null) {
2772
+ if (cancellation.isCancellationRequested) throw new CancellationError();
2773
+
2774
+ aborter = new AbortController();
2775
+ cancellation.onCancellationRequested(() => aborter!.abort());
2776
+
2777
+ variables = {
2778
+ ...variables,
2779
+ request: { ...variables?.request, signal: aborter.signal },
2780
+ };
2781
+ }
2782
+
2783
+ return await this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () =>
2784
+ this.getDefaults(accessToken, graphql)(query, variables),
2785
+ );
2786
+ } catch (ex) {
2787
+ if (ex instanceof GraphqlResponseError) {
2788
+ switch (ex.errors?.[0]?.type) {
2789
+ case 'NOT_FOUND':
2790
+ throw new RequestNotFoundError(ex);
2791
+ case 'FORBIDDEN':
2792
+ throw new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);
2793
+ case 'RATE_LIMITED': {
2794
+ let resetAt: number | undefined;
2795
+
2796
+ const reset = ex.headers?.['x-ratelimit-reset'];
2797
+ if (reset != null) {
2798
+ resetAt = parseInt(reset, 10);
2799
+ if (Number.isNaN(resetAt)) {
2800
+ resetAt = undefined;
2801
+ }
2802
+ }
2803
+
2804
+ throw new RequestRateLimitError(ex, accessToken, resetAt);
2805
+ }
2806
+ }
2807
+
2808
+ if (Logger.isDebugging) {
2809
+ this.config.onDebugError?.(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`);
2810
+ }
2811
+ } else if (ex instanceof RequestError || ex.name === 'AbortError') {
2812
+ this.handleRequestError(provider, token, ex, scope);
2813
+ } else if (Logger.isDebugging) {
2814
+ this.config.onDebugError?.(`GitHub request failed: ${ex.message}`);
2815
+ }
2816
+
2817
+ throw ex;
2818
+ }
2819
+ }
2820
+
2821
+ private async request<R extends keyof Endpoints>(
2822
+ provider: Provider | undefined,
2823
+ token: GitHubTokenInfo,
2824
+ route: R,
2825
+ options: (Endpoints[R]['parameters'] & RequestParameters) | undefined,
2826
+ scope: ScopedLogger | undefined,
2827
+ cancellation?: CancellationToken | undefined,
2828
+ ): Promise<Endpoints[R]['response']> {
2829
+ const { accessToken } = token;
2830
+ try {
2831
+ if (cancellation != null) {
2832
+ if (cancellation.isCancellationRequested) throw new CancellationError();
2833
+
2834
+ const aborter = new AbortController();
2835
+ cancellation.onCancellationRequested(() => aborter.abort());
2836
+ options = { ...options, request: { ...options?.request, signal: aborter.signal } };
2837
+ }
2838
+
2839
+ return (await this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () =>
2840
+ this.getDefaults(accessToken, request)(route as string, options),
2841
+ )) as Endpoints[R]['response'];
2842
+ } catch (ex) {
2843
+ if (ex instanceof RequestError || ex.name === 'AbortError') {
2844
+ this.handleRequestError(provider, token, ex, scope);
2845
+ } else if (Logger.isDebugging) {
2846
+ this.config.onDebugError?.(`GitHub request failed: ${ex.message}`);
2847
+ }
2848
+
2849
+ throw ex;
2850
+ }
2851
+ }
2852
+
2853
+ private _defaults = new Map<typeof request | typeof graphql, Map<string, typeof request | typeof graphql>>();
2854
+ private getDefaults(token: string, rqst: typeof request): typeof request;
2855
+ private getDefaults(token: string, gql: typeof graphql): typeof graphql;
2856
+ private getDefaults(
2857
+ token: string,
2858
+ requestOrGraphQL: typeof request | typeof graphql,
2859
+ ): typeof request | typeof graphql {
2860
+ let map = this._defaults.get(requestOrGraphQL);
2861
+ if (map == null) {
2862
+ map = new Map();
2863
+ this._defaults.set(requestOrGraphQL, map);
2864
+ }
2865
+
2866
+ let defaults = map.get(token);
2867
+ if (defaults == null) {
2868
+ const configFetch = this.config.fetch;
2869
+ const configIsWeb = this.config.isWeb;
2870
+ defaults = requestOrGraphQL.defaults({
2871
+ headers: {
2872
+ authorization: `token ${token}`,
2873
+ },
2874
+ request: {
2875
+ fetch: configIsWeb
2876
+ ? (url: string, options: { headers?: Record<string, string> }) => {
2877
+ if (options.headers != null) {
2878
+ // Strip out the user-agent (since it causes warnings in a webworker)
2879
+ const { 'user-agent': userAgent, ...headers } = options.headers;
2880
+ if (userAgent) {
2881
+ options.headers = headers;
2882
+ }
2883
+ }
2884
+ return configFetch(url, options);
2885
+ }
2886
+ : configFetch,
2887
+ hook:
2888
+ Logger.enabled('trace') || Logger.isDebugging
2889
+ ? async (rqst: typeof request, options: any) => {
2890
+ const sw = maybeStopWatch(`[GITHUB] ${options.method} ${options.url}`, {
2891
+ log: { onlyExit: true },
2892
+ });
2893
+ try {
2894
+ return await rqst(options);
2895
+ } finally {
2896
+ let message;
2897
+ try {
2898
+ if (typeof options.query === 'string') {
2899
+ const match = /(^[^({\n]+)/.exec(options.query);
2900
+ message = ` ${match?.[1].trim() ?? options.query}`;
2901
+ }
2902
+ } catch {}
2903
+ sw?.stop({ message: message });
2904
+ }
2905
+ }
2906
+ : undefined,
2907
+ },
2908
+ });
2909
+ map.set(token, defaults);
2910
+ }
2911
+
2912
+ return defaults;
2913
+ }
2914
+
2915
+ private handleRequestError(
2916
+ provider: Provider | undefined,
2917
+ token: GitHubTokenInfo,
2918
+ ex: RequestError | (Error & { name: 'AbortError' }),
2919
+ scope: ScopedLogger | undefined,
2920
+ ): void {
2921
+ if (ex.name === 'AbortError') throw new CancellationError(ex);
2922
+
2923
+ const { accessToken, ...tokenInfo } = token;
2924
+ switch (ex.status) {
2925
+ case 404: // Not found
2926
+ case 410: // Gone
2927
+ case 422: // Unprocessable Entity
2928
+ throw new RequestNotFoundError(ex);
2929
+ // case 429: //Too Many Requests
2930
+ case 401: // Unauthorized
2931
+ throw new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);
2932
+ case 403: // Forbidden
2933
+ if (ex.message.includes('rate limit')) {
2934
+ let resetAt: number | undefined;
2935
+
2936
+ const reset = ex.response?.headers?.['x-ratelimit-reset'];
2937
+ if (reset != null) {
2938
+ resetAt = parseInt(reset, 10);
2939
+ if (Number.isNaN(resetAt)) {
2940
+ resetAt = undefined;
2941
+ }
2942
+ }
2943
+
2944
+ throw new RequestRateLimitError(ex, accessToken, resetAt);
2945
+ }
2946
+ throw new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);
2947
+ case 500: // Internal Server Error
2948
+ scope?.error(ex);
2949
+ if (ex.response != null) {
2950
+ provider?.trackRequestException();
2951
+ this.config.onRequestError?.(
2952
+ provider,
2953
+ `${provider?.name ?? 'GitHub'} failed to respond and might be experiencing issues.${
2954
+ provider == null || provider.id === 'github'
2955
+ ? ' Please visit the [GitHub status page](https://githubstatus.com) for more information.'
2956
+ : ''
2957
+ }`,
2958
+ );
2959
+ }
2960
+ return;
2961
+ case 502: // Bad Gateway
2962
+ scope?.error(ex);
2963
+ // GitHub seems to return this status code for timeouts
2964
+ if (ex.message.includes('timeout')) {
2965
+ provider?.trackRequestException();
2966
+ this.config.onRequestError?.(provider, `${provider?.name ?? 'GitHub'} request timed out`);
2967
+ return;
2968
+ }
2969
+ break;
2970
+ case 503: // Service Unavailable
2971
+ scope?.error(ex);
2972
+ provider?.trackRequestException();
2973
+ this.config.onRequestError?.(
2974
+ provider,
2975
+ `${provider?.name ?? 'GitHub'} failed to respond and might be experiencing issues.${
2976
+ provider == null || provider.id === 'github'
2977
+ ? ' Please visit the [GitHub status page](https://githubstatus.com) for more information.'
2978
+ : ''
2979
+ }`,
2980
+ );
2981
+ return;
2982
+ default:
2983
+ if (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);
2984
+ break;
2985
+ }
2986
+
2987
+ scope?.error(ex);
2988
+ if (Logger.isDebugging) {
2989
+ this.config.onDebugError?.(
2990
+ `GitHub request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,
2991
+ );
2992
+ }
2993
+ }
2994
+
2995
+ private handleException(
2996
+ ex: Error,
2997
+ provider: Provider | undefined,
2998
+ scope: ScopedLogger | undefined,
2999
+ silent?: boolean,
3000
+ ): Error {
3001
+ scope?.error(ex);
3002
+ // debugger;
3003
+
3004
+ if (ex instanceof AuthenticationError && !silent) {
3005
+ void this.showAuthenticationErrorMessage(ex, provider);
3006
+ }
3007
+ return ex;
3008
+ }
3009
+
3010
+ private async showAuthenticationErrorMessage(ex: AuthenticationError, provider: Provider | undefined) {
3011
+ if (ex.reason === AuthenticationErrorReason.Unauthorized || ex.reason === AuthenticationErrorReason.Forbidden) {
3012
+ const reauthenticated = await this.config.onAuthenticationFailure?.(ex, provider);
3013
+ if (reauthenticated) {
3014
+ this.resetCaches();
3015
+ this._onDidReauthenticate.fire();
3016
+ }
3017
+ }
3018
+ }
3019
+
3020
+ private async createEnterpriseAvatarUrl(
3021
+ provider: Provider | undefined,
3022
+ token: GitHubTokenInfo,
3023
+ baseUrl: string,
3024
+ email: string,
3025
+ avatarSize: number | undefined,
3026
+ ): Promise<string | undefined> {
3027
+ avatarSize = avatarSize ?? 16;
3028
+ const { accessToken } = token;
3029
+
3030
+ const version = await this.getEnterpriseVersion(provider, token, { baseUrl: baseUrl });
3031
+ if (satisfies(version, '>= 3.0.0')) {
3032
+ let url: string | undefined;
3033
+
3034
+ const parts = getGitHubNoReplyAddressParts(email);
3035
+ if (parts != null) {
3036
+ if (parseUri(baseUrl).authority === parts.authority) {
3037
+ if (parts.userId != null) {
3038
+ url = `${baseUrl}/enterprise/avatars/u/${encodeURIComponent(parts.userId)}?s=${avatarSize}`;
3039
+ } else if (parts.login != null) {
3040
+ url = `${baseUrl}/enterprise/avatars/${encodeURIComponent(parts.login)}?s=${avatarSize}`;
3041
+ }
3042
+ }
3043
+ }
3044
+
3045
+ url ??= `${baseUrl}/enterprise/avatars/u/e?email=${encodeURIComponent(email)}&s=${avatarSize}`;
3046
+
3047
+ const configFetch = this.config.fetch;
3048
+ const rsp = await this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () =>
3049
+ configFetch(url, { method: 'GET', headers: { Authorization: `Bearer ${accessToken}` } }),
3050
+ );
3051
+
3052
+ if (rsp.ok) {
3053
+ const data = base64(new Uint8Array(await rsp.arrayBuffer()));
3054
+ const mimeType = rsp.headers.get('content-type');
3055
+ return `data:${mimeType};base64,${data}`;
3056
+ }
3057
+ }
3058
+
3059
+ // The /u/e endpoint automatically falls back to gravatar if not found
3060
+ return `https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(email)}&s=${avatarSize}`;
3061
+ }
3062
+
3063
+ @trace({ args: (provider, token) => ({ provider: provider.name, token: `<token:${token.microHash}>` }) })
3064
+ async searchMyPullRequests(
3065
+ provider: Provider,
3066
+ token: GitHubTokenInfo,
3067
+ options?: {
3068
+ search?: string;
3069
+ user?: string;
3070
+ repos?: string[];
3071
+ baseUrl?: string;
3072
+ avatarSize?: number;
3073
+ silent?: boolean;
3074
+ },
3075
+ cancellation?: CancellationToken,
3076
+ ): Promise<PullRequest[]> {
3077
+ const scope = getScopedLogger();
3078
+
3079
+ const limit = Math.min(100, this.config.getLaunchpadQueryLimit?.() ?? 100);
3080
+
3081
+ try {
3082
+ interface SearchResult {
3083
+ search: {
3084
+ issueCount: number;
3085
+ nodes: GitHubPullRequest[];
3086
+ };
3087
+ viewer: {
3088
+ login: string;
3089
+ };
3090
+ }
3091
+
3092
+ const query = `query searchMyPullRequests(
3093
+ $search: String!
3094
+ $avatarSize: Int
3095
+ ) {
3096
+ search(first: ${limit}, query: $search, type: ISSUE) {
3097
+ issueCount
3098
+ nodes {
3099
+ ...on PullRequest {
3100
+ ${gqlPullRequestFragment}
3101
+ }
3102
+ }
3103
+ }
3104
+ viewer {
3105
+ login
3106
+ }
3107
+ }`;
3108
+
3109
+ let search = options?.search?.trim() ?? '';
3110
+
3111
+ if (options?.user) {
3112
+ search += ` user:${options.user}`;
3113
+ }
3114
+
3115
+ if (options?.repos?.length) {
3116
+ search += ` repo:${options.repos.join(' repo:')}`;
3117
+ }
3118
+
3119
+ // Hack for now, ultimately this should be passed in
3120
+ const ignoredRepos = this.config.getLaunchpadIgnoredRepositories?.() ?? [];
3121
+ if (ignoredRepos.length) {
3122
+ search += ` -repo:${ignoredRepos.join(' -repo:')}`;
3123
+ }
3124
+
3125
+ // Hack for now, ultimately this should be passed in
3126
+ const enabledOrgs = this.config.getLaunchpadIncludedOrganizations?.() ?? [];
3127
+ if (enabledOrgs.length) {
3128
+ search += ` org:${enabledOrgs.join(' org:')}`;
3129
+ } else {
3130
+ // Hack for now, ultimately this should be passed in
3131
+ const ignoredOrgs = this.config.getLaunchpadIgnoredOrganizations?.() ?? [];
3132
+ if (ignoredOrgs.length) {
3133
+ search += ` -org:${ignoredOrgs.join(' -org:')}`;
3134
+ }
3135
+ }
3136
+
3137
+ const rsp = await this.graphql<SearchResult>(
3138
+ provider,
3139
+ token,
3140
+ query,
3141
+ {
3142
+ search: `is:open is:pr involves:@me archived:false ${search}`.trim(),
3143
+ baseUrl: options?.baseUrl,
3144
+ avatarSize: options?.avatarSize,
3145
+ },
3146
+ scope,
3147
+ cancellation,
3148
+ );
3149
+ if (rsp == null) return [];
3150
+
3151
+ const viewer = rsp.viewer.login;
3152
+
3153
+ function toQueryResult(pr: GitHubPullRequest): PullRequest {
3154
+ const reasons = [];
3155
+ if (pr.author.login === viewer) {
3156
+ reasons.push('authored');
3157
+ }
3158
+ if (pr.assignees.nodes.some(a => a.login === viewer)) {
3159
+ reasons.push('assigned');
3160
+ }
3161
+ if (pr.reviewRequests.nodes.some(r => r.requestedReviewer?.login === viewer)) {
3162
+ reasons.push('review-requested');
3163
+ }
3164
+ if (reasons.length === 0) {
3165
+ reasons.push('mentioned');
3166
+ }
3167
+
3168
+ return fromGitHubPullRequest(pr, provider);
3169
+ }
3170
+
3171
+ const results: PullRequest[] = rsp.search.nodes.map(pr => toQueryResult(pr));
3172
+ return results;
3173
+ } catch (ex) {
3174
+ throw this.handleException(ex, provider, scope, options?.silent);
3175
+ }
3176
+ }
3177
+
3178
+ @trace({ args: (provider, token) => ({ provider: provider.name, token: `<token:${token.microHash}>` }) })
3179
+ async searchMyIssues(
3180
+ provider: Provider,
3181
+ token: GitHubTokenInfo,
3182
+ options?: {
3183
+ search?: string;
3184
+ user?: string;
3185
+ repos?: string[];
3186
+ baseUrl?: string;
3187
+ avatarSize?: number;
3188
+ includeBody?: boolean;
3189
+ },
3190
+ cancellation?: CancellationToken,
3191
+ ): Promise<IssueShape[] | undefined> {
3192
+ const scope = getScopedLogger();
3193
+
3194
+ interface SearchResult {
3195
+ authored: {
3196
+ nodes: GitHubIssue[];
3197
+ };
3198
+ assigned: {
3199
+ nodes: GitHubIssue[];
3200
+ };
3201
+ mentioned: {
3202
+ nodes: GitHubIssue[];
3203
+ };
3204
+ }
3205
+
3206
+ const issueFragement = `${gqIssueFragment}${
3207
+ options?.includeBody
3208
+ ? `
3209
+ body
3210
+ `
3211
+ : ''
3212
+ }`;
3213
+
3214
+ const query = `query searchMyIssues(
3215
+ $authored: String!
3216
+ $assigned: String!
3217
+ $mentioned: String!
3218
+ $avatarSize: Int
3219
+ ) {
3220
+ authored: search(first: 100, query: $authored, type: ISSUE) {
3221
+ nodes {
3222
+ ... on Issue {
3223
+ ${issueFragement}
3224
+ }
3225
+ }
3226
+ }
3227
+ assigned: search(first: 100, query: $assigned, type: ISSUE) {
3228
+ nodes {
3229
+ ... on Issue {
3230
+ ${issueFragement}
3231
+ }
3232
+ }
3233
+ }
3234
+ mentioned: search(first: 100, query: $mentioned, type: ISSUE) {
3235
+ nodes {
3236
+ ... on Issue {
3237
+ ${issueFragement}
3238
+ }
3239
+ }
3240
+ }
3241
+ }`;
3242
+
3243
+ let search = options?.search?.trim() ?? '';
3244
+
3245
+ if (options?.user) {
3246
+ search += ` user:${options.user}`;
3247
+ }
3248
+
3249
+ if (options?.repos != null && options.repos.length > 0) {
3250
+ const repo = ' repo:';
3251
+ search += `${repo}${options.repos.join(repo)}`;
3252
+ }
3253
+
3254
+ const baseFilters = 'type:issue is:open archived:false';
3255
+ try {
3256
+ const rsp = await this.graphql<SearchResult>(
3257
+ provider,
3258
+ token,
3259
+ query,
3260
+ {
3261
+ authored: `${search} ${baseFilters} author:@me`.trim(),
3262
+ assigned: `${search} ${baseFilters} assignee:@me`.trim(),
3263
+ mentioned: `${search} ${baseFilters} mentions:@me`.trim(),
3264
+ baseUrl: options?.baseUrl,
3265
+ avatarSize: options?.avatarSize,
3266
+ },
3267
+ scope,
3268
+ cancellation,
3269
+ );
3270
+
3271
+ function toQueryResult(issue: GitHubIssue): IssueShape {
3272
+ return fromGitHubIssue(issue, provider);
3273
+ }
3274
+
3275
+ if (rsp == null) return [];
3276
+
3277
+ const results: IterableIterator<IssueShape> = uniqueBy(
3278
+ [...rsp.assigned.nodes, ...rsp.mentioned.nodes, ...rsp.authored.nodes].map(toQueryResult),
3279
+ r => r.url,
3280
+ (original, _current) => original,
3281
+ );
3282
+ return [...results];
3283
+ } catch (ex) {
3284
+ throw this.handleException(ex, provider, scope);
3285
+ }
3286
+ }
3287
+
3288
+ @trace({ args: (provider, token) => ({ provider: provider.name, token: `<token:${token.microHash}>` }) })
3289
+ async searchPullRequests(
3290
+ provider: Provider,
3291
+ token: GitHubTokenInfo,
3292
+ options?: { search?: string; user?: string; repos?: string[]; baseUrl?: string; avatarSize?: number },
3293
+ cancellation?: CancellationToken,
3294
+ ): Promise<PullRequest[]> {
3295
+ const scope = getScopedLogger();
3296
+
3297
+ interface SearchResult {
3298
+ search: {
3299
+ nodes: GitHubPullRequest[];
3300
+ };
3301
+ }
3302
+
3303
+ try {
3304
+ const query = `query searchPullRequests(
3305
+ $searchQuery: String!
3306
+ $avatarSize: Int
3307
+ ) {
3308
+ search(first: 10, query: $searchQuery, type: ISSUE) {
3309
+ nodes {
3310
+ ...on PullRequest {
3311
+ ${gqlPullRequestFragment}
3312
+ }
3313
+ }
3314
+ }
3315
+ }`;
3316
+
3317
+ let search = options?.search?.trim() ?? '';
3318
+
3319
+ if (options?.user) {
3320
+ search += ` user:${options.user}`;
3321
+ }
3322
+
3323
+ if (options?.repos != null && options.repos.length > 0) {
3324
+ const repo = ' repo:';
3325
+ search += `${repo}${options.repos.join(repo)}`;
3326
+ }
3327
+
3328
+ const rsp = await this.graphql<SearchResult>(
3329
+ provider,
3330
+ token,
3331
+ query,
3332
+ {
3333
+ searchQuery: `is:pr is:open archived:false ${search.trim()}`,
3334
+ baseUrl: options?.baseUrl,
3335
+ avatarSize: options?.avatarSize,
3336
+ },
3337
+ scope,
3338
+ cancellation,
3339
+ );
3340
+ if (rsp == null) return [];
3341
+
3342
+ const results = rsp.search.nodes.map(pr => fromGitHubPullRequest(pr, provider));
3343
+ return results;
3344
+ } catch (ex) {
3345
+ throw this.handleException(ex, provider, scope);
3346
+ }
3347
+ }
3348
+
3349
+ @trace({
3350
+ args: (provider, token, nodeId, expectedSourceSha) => ({
3351
+ provider: provider.name,
3352
+ token: `<token:${token.microHash}>`,
3353
+ nodeId: nodeId,
3354
+ expectedSourceSha: expectedSourceSha,
3355
+ }),
3356
+ })
3357
+ async mergePullRequest(
3358
+ provider: Provider,
3359
+ token: GitHubTokenInfo,
3360
+ nodeId: string,
3361
+ expectedSourceSha: string,
3362
+ options?: { mergeMethod?: PullRequestMergeMethod; baseUrl?: string },
3363
+ cancellation?: CancellationToken,
3364
+ ): Promise<boolean> {
3365
+ const scope = getScopedLogger();
3366
+ interface QueryResult {
3367
+ pullRequest: GitHubPullRequestLite | null | undefined;
3368
+ }
3369
+
3370
+ let githubMergeStrategy;
3371
+ switch (options?.mergeMethod) {
3372
+ case PullRequestMergeMethod.Merge: {
3373
+ githubMergeStrategy = 'MERGE';
3374
+ break;
3375
+ }
3376
+
3377
+ case PullRequestMergeMethod.Rebase: {
3378
+ githubMergeStrategy = 'REBASE';
3379
+ break;
3380
+ }
3381
+
3382
+ case PullRequestMergeMethod.Squash: {
3383
+ githubMergeStrategy = 'SQUASH';
3384
+ break;
3385
+ }
3386
+ }
3387
+
3388
+ try {
3389
+ const query = `mutation mergePullRequest(
3390
+ $id: ID!
3391
+ $expectedSourceSha: GitObjectID!
3392
+ $mergeMethod: PullRequestMergeMethod
3393
+ ) {
3394
+ mergePullRequest(input: { pullRequestId: $id, expectedHeadOid: $expectedSourceSha, mergeMethod: $mergeMethod }) {
3395
+ pullRequest {
3396
+ id
3397
+ }
3398
+ }
3399
+ }`;
3400
+
3401
+ const rsp = await this.graphql<QueryResult>(
3402
+ provider,
3403
+ token,
3404
+ query,
3405
+ {
3406
+ id: nodeId,
3407
+ expectedSourceSha: expectedSourceSha,
3408
+ mergeMethod: githubMergeStrategy,
3409
+ baseUrl: options?.baseUrl,
3410
+ },
3411
+ scope,
3412
+ cancellation,
3413
+ );
3414
+
3415
+ return rsp?.pullRequest?.id === nodeId;
3416
+ } catch (ex) {
3417
+ throw this.handleException(ex, provider, scope);
3418
+ }
3419
+ }
3420
+ }
3421
+
3422
+ function isGitHubDotCom(options?: { baseUrl?: string }) {
3423
+ return options?.baseUrl == null || options.baseUrl === 'https://api.github.com';
3424
+ }