@gitkraken/core-gitlens 0.11.1 → 0.13.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 (201) hide show
  1. package/CHANGELOG.md +84 -1
  2. package/dist/git/cache.d.ts +84 -29
  3. package/dist/git/cache.js +188 -54
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/features.d.ts +1 -1
  6. package/dist/git/features.js +4 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/models/branch.d.ts +15 -2
  9. package/dist/git/models/branch.js +27 -5
  10. package/dist/git/models/branch.js.map +1 -1
  11. package/dist/git/models/issue.d.ts +3 -1
  12. package/dist/git/models/issue.js.map +1 -1
  13. package/dist/git/models/status.js +1 -1
  14. package/dist/git/models/worktree.d.ts +4 -1
  15. package/dist/git/models/worktree.js +4 -2
  16. package/dist/git/models/worktree.js.map +1 -1
  17. package/dist/git/providers/branches.d.ts +73 -8
  18. package/dist/git/providers/pausedOperations.d.ts +6 -0
  19. package/dist/git/providers/provider.d.ts +34 -2
  20. package/dist/git/providers/status.d.ts +8 -2
  21. package/dist/git/remotes/azure-devops.js +61 -53
  22. package/dist/git/remotes/azure-devops.js.map +1 -1
  23. package/dist/git/service.d.ts +8 -5
  24. package/dist/git/service.js +16 -8
  25. package/dist/git/service.js.map +1 -1
  26. package/dist/git/utils/branch.utils.d.ts +8 -1
  27. package/dist/git/utils/branch.utils.js +30 -1
  28. package/dist/git/utils/branch.utils.js.map +1 -1
  29. package/dist/git/utils/issue.utils.d.ts +3 -1
  30. package/dist/git/utils/issue.utils.js +5 -1
  31. package/dist/git/utils/issue.utils.js.map +1 -1
  32. package/dist/git/watching/changeEvent.d.ts +13 -2
  33. package/dist/git/watching/changeEvent.js +17 -3
  34. package/dist/git/watching/changeEvent.js.map +1 -1
  35. package/dist/git/watching/gitDirPoller.d.ts +111 -0
  36. package/dist/git/watching/gitDirPoller.js +266 -0
  37. package/dist/git/watching/gitDirPoller.js.map +1 -0
  38. package/dist/git/watching/provider.d.ts +16 -0
  39. package/dist/git/watching/watchGroup.d.ts +40 -4
  40. package/dist/git/watching/watchGroup.js +143 -17
  41. package/dist/git/watching/watchGroup.js.map +1 -1
  42. package/dist/git/watching/watchService.d.ts +70 -1
  43. package/dist/git/watching/watchService.js +158 -13
  44. package/dist/git/watching/watchService.js.map +1 -1
  45. package/dist/git/watching/watchSession.d.ts +44 -0
  46. package/dist/git/watching/watchSession.js +91 -6
  47. package/dist/git/watching/watchSession.js.map +1 -1
  48. package/dist/git/watching/watcherPatterns.d.ts +21 -0
  49. package/dist/git/watching/watcherPatterns.js +67 -1
  50. package/dist/git/watching/watcherPatterns.js.map +1 -1
  51. package/dist/git/watching/worktreeSummary.d.ts +34 -7
  52. package/dist/git/watching/worktreeSummary.js +39 -12
  53. package/dist/git/watching/worktreeSummary.js.map +1 -1
  54. package/dist/git-cli/cliGitProvider.d.ts +34 -2
  55. package/dist/git-cli/cliGitProvider.js +119 -17
  56. package/dist/git-cli/cliGitProvider.js.map +1 -1
  57. package/dist/git-cli/exec/commandClassifier.d.ts +15 -0
  58. package/dist/git-cli/exec/commandClassifier.js +48 -2
  59. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  60. package/dist/git-cli/exec/git.d.ts +15 -3
  61. package/dist/git-cli/exec/git.js +38 -17
  62. package/dist/git-cli/exec/git.js.map +1 -1
  63. package/dist/git-cli/exec/gitQueue.d.ts +2 -0
  64. package/dist/git-cli/exec/gitQueue.js +2 -1
  65. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  66. package/dist/git-cli/exec/indexLock.d.ts +38 -0
  67. package/dist/git-cli/exec/indexLock.js +150 -0
  68. package/dist/git-cli/exec/indexLock.js.map +1 -0
  69. package/dist/git-cli/parsers/worktreeParser.js +42 -2
  70. package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
  71. package/dist/git-cli/providers/branches.d.ts +109 -10
  72. package/dist/git-cli/providers/branches.js +624 -131
  73. package/dist/git-cli/providers/branches.js.map +1 -1
  74. package/dist/git-cli/providers/config.d.ts +9 -5
  75. package/dist/git-cli/providers/config.js +60 -27
  76. package/dist/git-cli/providers/config.js.map +1 -1
  77. package/dist/git-cli/providers/operations.d.ts +17 -0
  78. package/dist/git-cli/providers/operations.js +153 -96
  79. package/dist/git-cli/providers/operations.js.map +1 -1
  80. package/dist/git-cli/providers/pausedOperations.d.ts +8 -0
  81. package/dist/git-cli/providers/pausedOperations.js +60 -40
  82. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  83. package/dist/git-cli/providers/refs.js +11 -8
  84. package/dist/git-cli/providers/refs.js.map +1 -1
  85. package/dist/git-cli/providers/remotes.js +19 -10
  86. package/dist/git-cli/providers/remotes.js.map +1 -1
  87. package/dist/git-cli/providers/staging.js +40 -15
  88. package/dist/git-cli/providers/staging.js.map +1 -1
  89. package/dist/git-cli/providers/stash.d.ts +2 -0
  90. package/dist/git-cli/providers/stash.js +33 -18
  91. package/dist/git-cli/providers/stash.js.map +1 -1
  92. package/dist/git-cli/providers/status.d.ts +3 -1
  93. package/dist/git-cli/providers/status.js +38 -20
  94. package/dist/git-cli/providers/status.js.map +1 -1
  95. package/dist/git-cli/providers/tags.js +6 -4
  96. package/dist/git-cli/providers/tags.js.map +1 -1
  97. package/dist/git-cli/providers/worktrees.d.ts +1 -0
  98. package/dist/git-cli/providers/worktrees.js +60 -31
  99. package/dist/git-cli/providers/worktrees.js.map +1 -1
  100. package/dist/git-cli/service.d.ts +6 -0
  101. package/dist/git-cli/service.js +5 -2
  102. package/dist/git-cli/service.js.map +1 -1
  103. package/dist/ipc/discovery.js +1 -1
  104. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  105. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  106. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  107. package/dist/plus/git-github/providers/github/status.d.ts +3 -1
  108. package/dist/plus/git-github/providers/github/status.js +1 -1
  109. package/dist/plus/git-github/providers/github/status.js.map +1 -1
  110. package/dist/plus/integrations/collectionMetadata.d.ts +13 -2
  111. package/dist/plus/integrations/collectionMetadata.js +14 -2
  112. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  113. package/dist/plus/integrations/index.d.ts +2 -2
  114. package/dist/plus/integrations/index.js.map +1 -1
  115. package/dist/plus/integrations/integrationService.d.ts +1 -0
  116. package/dist/plus/integrations/integrationService.js +1 -1
  117. package/dist/plus/integrations/integrationService.js.map +1 -1
  118. package/dist/plus/integrations/manager.d.ts +1 -0
  119. package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -5
  120. package/dist/plus/integrations/models/gitHostIntegration.js +109 -30
  121. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  122. package/dist/plus/integrations/models/integration.js +1 -1
  123. package/dist/plus/integrations/models/issueReads.d.ts +17 -4
  124. package/dist/plus/integrations/providers/apiClients.d.ts +2 -0
  125. package/dist/plus/integrations/providers/apiClients.js +7 -1
  126. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  127. package/dist/plus/integrations/providers/azure/azure.d.ts +5 -4
  128. package/dist/plus/integrations/providers/azure/azure.js +38 -77
  129. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  130. package/dist/plus/integrations/providers/azure/azure.utils.js +20 -17
  131. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  132. package/dist/plus/integrations/providers/azure/models.d.ts +27 -10
  133. package/dist/plus/integrations/providers/azure/models.js +40 -20
  134. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  135. package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +23 -0
  136. package/dist/plus/integrations/providers/azure/workItemStateCategories.js +84 -0
  137. package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -0
  138. package/dist/plus/integrations/providers/azureDevOps.d.ts +44 -0
  139. package/dist/plus/integrations/providers/azureDevOps.js +113 -22
  140. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  141. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +45 -1
  142. package/dist/plus/integrations/providers/azureDevOpsServer.js +121 -6
  143. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  144. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  145. package/dist/plus/integrations/providers/jira-server.js +29 -19
  146. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  147. package/dist/plus/integrations/providers/jira.d.ts +5 -2
  148. package/dist/plus/integrations/providers/jira.js +63 -44
  149. package/dist/plus/integrations/providers/jira.js.map +1 -1
  150. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +3 -4
  151. package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -4
  152. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  153. package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +5 -5
  154. package/dist/plus/integrations/providers/linearIssuesEtag.js +6 -6
  155. package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
  156. package/dist/plus/integrations/providers/models.d.ts +12 -3
  157. package/dist/plus/integrations/providers/models.js +16 -9
  158. package/dist/plus/integrations/providers/models.js.map +1 -1
  159. package/dist/plus/integrations/providers/providersApi.d.ts +21 -33
  160. package/dist/plus/integrations/providers/providersApi.js +159 -49
  161. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  162. package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +49 -15
  163. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +132 -10
  164. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
  165. package/dist/plus/integrations/providers/utils/providerPaging.js +8 -2
  166. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  167. package/dist/plus/integrations/reads/cursors.js +1 -1
  168. package/dist/plus/integrations/reads/drains.d.ts +0 -1
  169. package/dist/plus/integrations/reads/filters.d.ts +3 -3
  170. package/dist/plus/integrations/reads/filters.js.map +1 -1
  171. package/dist/plus/integrations/reads/hierarchy.js +2 -2
  172. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  173. package/dist/plus/integrations/reads/hierarchy.utils.d.ts +13 -0
  174. package/dist/plus/integrations/reads/hierarchy.utils.js +26 -1
  175. package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
  176. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -1
  177. package/dist/plus/integrations/reads/issueBatch.js +1 -1
  178. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  179. package/dist/plus/integrations/reads/issueTracker.js +27 -18
  180. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  181. package/dist/plus/integrations/reads/issues.d.ts +2 -1
  182. package/dist/plus/integrations/reads/issues.js +19 -4
  183. package/dist/plus/integrations/reads/issues.js.map +1 -1
  184. package/dist/plus/integrations/reads/pullRequestBatch.js +1 -1
  185. package/dist/plus/integrations/reads/resolveRepository.js +12 -3
  186. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  187. package/dist/plus/integrations/reads/warnings.d.ts +11 -4
  188. package/dist/plus/integrations/reads/warnings.js +15 -5
  189. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  190. package/dist/plus/integrations/results.d.ts +48 -4
  191. package/dist/plus/integrations/results.js +33 -13
  192. package/dist/plus/integrations/results.js.map +1 -1
  193. package/dist/plus/integrations/utils/integration.utils.d.ts +6 -1
  194. package/dist/plus/integrations/utils/integration.utils.js +8 -1
  195. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  196. package/dist/utils/env/node/exec.js +2 -2
  197. package/dist/utils/promiseCache.d.ts +10 -0
  198. package/dist/utils/promiseCache.js +17 -2
  199. package/dist/utils/promiseCache.js.map +1 -1
  200. package/docs/integrations.md +93 -31
  201. package/package.json +2 -2
@@ -435,6 +435,7 @@ export interface IntegrationManager {
435
435
  summary?: boolean;
436
436
  }): Promise<ProviderPagedResult<PullRequestShape>>;
437
437
  listIssuesPage(options: {
438
+ state?: IssueStateFilter;
438
439
  providerId: IntegrationIds;
439
440
  repos?: ProviderRepositoriesInput;
440
441
  /**
@@ -44,11 +44,46 @@ type MyPullRequestsForReposOptions = {
44
44
  /** Requests the lightweight row shape without per-row build status or commit count. */
45
45
  summary?: boolean;
46
46
  };
47
+ /** A repository as the batch and branch reads name it. */
48
+ type RepositoryCoordinate = {
49
+ owner: string;
50
+ repo: string;
51
+ project?: string;
52
+ };
47
53
  export declare abstract class GitHostIntegration<ID extends IntegrationIds = IntegrationIds, T extends ResourceDescriptor = ResourceDescriptor> extends IntegrationBase<ID> {
48
54
  readonly type: IntegrationType;
49
55
  /** The self-managed installation `session` addresses, validated against this integration's host. */
50
56
  protected getSelfManagedInstallationUrl(session: ProviderAuthenticationSession): string;
51
57
  protected getSelfManagedApiBaseUrl(session: ProviderAuthenticationSession): string;
58
+ /**
59
+ * The repositories the repo-scoped, batch and branch reads address, given the coordinates their caller named, in
60
+ * order: those, unless the host names a caller's repository differently than the caller parsed it (see the Azure
61
+ * DevOps Server override). `unsettled` flags a coordinate the host couldn't place, read as given; a batch or
62
+ * branch slot that then reads nothing is rejected rather than reported as absent ({@link rejectUnsettledMisses}).
63
+ */
64
+ protected resolveRepositoryCoordinates<T extends RepositoryCoordinate>(_session: ProviderAuthenticationSession, coordinates: readonly T[], _cancellation?: AbortSignal): Promise<{
65
+ coordinates: readonly T[];
66
+ unsettled?: readonly boolean[];
67
+ }>;
68
+ /**
69
+ * {@link resolveRepositoryCoordinates} for the repository descriptors the list and search reads take: those, unless
70
+ * the host overrides both.
71
+ */
72
+ protected resolveRepositoryInputs(_session: ProviderAuthenticationSession, repos: readonly ProviderRepoInput[], _cancellation?: AbortSignal): Promise<ProviderRepoInput[]>;
73
+ /**
74
+ * The repositories a repo-scoped read of `repos` addresses ({@link resolveRepositoryInputs}), for a caller that
75
+ * shapes the read by them before making it. Resolves the session as that read does, and fails as it would: a
76
+ * session that can't be resolved is the read's own failure (refreshing a refused token is claimed here), so the
77
+ * caller reports it rather than making the read. Settling that fails leaves `repos` as given, for the read to
78
+ * settle or report.
79
+ */
80
+ resolveRepositoryScopes(repos: ProviderReposInput, connectionId?: string): Promise<IntegrationResult<ProviderReposInput>>;
81
+ /**
82
+ * A batch or branch read's slots, settled against the repositories {@link resolveRepositoryCoordinates} settled
83
+ * its coordinates to: a miss for one it couldn't settle is rejected ({@link rejectUnsettledMisses}), and a refusal
84
+ * is recorded against the repository the host read rather than the caller's parse of it.
85
+ */
86
+ private settleResolvedSlots;
52
87
  /** The base the repository-list reads hand the provider client for a self-managed host. */
53
88
  protected getRepositoriesApiBaseUrl(session: ProviderAuthenticationSession, _repos: ProviderReposInput): string;
54
89
  getAccountForEmail(repo: T, email: string, options?: {
@@ -83,9 +118,10 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
83
118
  }): Promise<ProviderRepository | undefined>;
84
119
  /**
85
120
  * Settles what one repository's refusal of the credential means, as a batch read settles a refused target (see
86
- * `IntegrationBase.settleBatchRefusals`): the scope failure it is recorded as, against that repository (and, on
87
- * Azure DevOps, its project), with its cause named once the credential checks out. A refused credential throws
88
- * its own error, which the caller reports for the connection instead of the repository's refusal.
121
+ * `IntegrationBase.settleBatchRefusals`): the scope failure it is recorded as, against that repository as the host
122
+ * names it (and, on Azure DevOps, its project), with its cause named once the credential checks out. `name` names
123
+ * the repository alone, as a batch target does. A refused credential throws its own error, which the caller reports
124
+ * for the connection instead of the repository's refusal.
89
125
  */
90
126
  settleRepositoryRefusal(repo: {
91
127
  owner: string;
@@ -254,7 +290,7 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
254
290
  * thrown errors and validation failures into `{ error }` so callers can surface them as warnings
255
291
  * rather than swallowing them to `undefined`.
256
292
  */
257
- getMyIssuesForReposResult(reposOrRepoIds: ProviderReposInput, options?: MyIssuesForReposOptions, connectionId?: string): Promise<IntegrationResult<(PagedResult<ProviderIssue> & {
293
+ getMyIssuesForReposResult(repos: ProviderReposInput, options?: MyIssuesForReposOptions, connectionId?: string): Promise<IntegrationResult<(PagedResult<ProviderIssue> & {
258
294
  metadata?: CollectionMetadata;
259
295
  }) | undefined>>;
260
296
  /**
@@ -277,7 +313,7 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
277
313
  * thrown errors and validation failures into `{ error }` so callers can surface them as warnings
278
314
  * rather than swallowing them to `undefined`.
279
315
  */
280
- getMyPullRequestsForReposResult(reposOrRepoIds: ProviderReposInput, options?: MyPullRequestsForReposOptions, connectionId?: string): Promise<IntegrationResult<ProviderApiPagedResult<ProviderPullRequest> | undefined>>;
316
+ getMyPullRequestsForReposResult(repos: ProviderReposInput, options?: MyPullRequestsForReposOptions, connectionId?: string): Promise<IntegrationResult<ProviderApiPagedResult<ProviderPullRequest> | undefined>>;
281
317
  /** Account-wide (or repo-scoped) search for the current user's pull requests. */
282
318
  searchMyPullRequests(repos?: T | T[], cancellation?: AbortSignal, options?: SearchMyPullRequestsOptions & {
283
319
  connectionId?: string;
@@ -5,6 +5,7 @@ import { Logger as _logger } from "../../../utils/logger.js";
5
5
  import { getScopedLogger } from "../../../utils/logger.scoped.js";
6
6
  import { trace } from "../../../utils/decorators/log.js";
7
7
  import __decorate from "../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
8
+ import { RequestNotFoundError } from "../../../git/errors.js";
8
9
  import { gate } from "../../../utils/decorators/gate.js";
9
10
  import "../../../git/models/pullRequest.js";
10
11
  import { toError } from "../errors.js";
@@ -13,10 +14,10 @@ import { isAzureProviderId } from "../providers/providerErrors.js";
13
14
  import { throwIfCallerContractError, toCollectionFailureError, toCollectionScopeFailure } from "../collectionMetadata.js";
14
15
  import { toTokenWithInfo } from "../authentication/models.js";
15
16
  import "../providerFilters.js";
16
- import { mergeCollectionMetadata, throwIfAllSettledFailed } from "../providers/utils/providerPaging.js";
17
17
  import { areDomainsOnSameHost } from "../utils/domain.utils.js";
18
18
  import { getSelfManagedBaseUrl, isGitSelfManagedHostIntegrationId } from "../utils/integration.utils.js";
19
- import { toIssueShape, toProviderIssueStates, toProviderPullRequestStates } from "../providers/models.js";
19
+ import { mergeCollectionMetadata, throwIfAllSettledFailed } from "../providers/utils/providerPaging.js";
20
+ import { isRepoIdsInput, toIssueShape, toProviderIssueStates, toProviderPullRequestStates } from "../providers/models.js";
20
21
  import { IntegrationBase, isReadSessionFailure } from "./integration.js";
21
22
  //#region ../plus/integrations/src/models/gitHostIntegration.ts
22
23
  /**
@@ -30,6 +31,18 @@ function sendsBasicCredential(providerId, session) {
30
31
  return isAzureProviderId(providerId) ? session.type !== "oauth" : void 0;
31
32
  }
32
33
  /**
34
+ * Rejects each slot that read nothing (`isMiss`) for a coordinate whose repository couldn't be settled (see
35
+ * {@link GitHostIntegration.resolveRepositoryCoordinates}): it may have addressed another repository, so its miss is
36
+ * not a proven absence a caller may cache.
37
+ */
38
+ function rejectUnsettledMisses(slots, unsettled, isMiss) {
39
+ if (!unsettled?.some(Boolean)) return slots;
40
+ return slots.map((slot, i) => unsettled[i] && slot.status === "fulfilled" && isMiss(slot.value) ? {
41
+ status: "rejected",
42
+ reason: /* @__PURE__ */ new Error("Nothing read for a repository that couldn't be settled")
43
+ } : slot);
44
+ }
45
+ /**
33
46
  * Rejects a read the provider can't serve as asked: logs the reason and returns it as the `{ error }` half of an
34
47
  * {@link IntegrationResult}, timed from `start`.
35
48
  *
@@ -70,6 +83,47 @@ var GitHostIntegration = class extends IntegrationBase {
70
83
  default: return baseUrl;
71
84
  }
72
85
  }
86
+ /**
87
+ * The repositories the repo-scoped, batch and branch reads address, given the coordinates their caller named, in
88
+ * order: those, unless the host names a caller's repository differently than the caller parsed it (see the Azure
89
+ * DevOps Server override). `unsettled` flags a coordinate the host couldn't place, read as given; a batch or
90
+ * branch slot that then reads nothing is rejected rather than reported as absent ({@link rejectUnsettledMisses}).
91
+ */
92
+ resolveRepositoryCoordinates(_session, coordinates, _cancellation) {
93
+ return Promise.resolve({ coordinates });
94
+ }
95
+ /**
96
+ * {@link resolveRepositoryCoordinates} for the repository descriptors the list and search reads take: those, unless
97
+ * the host overrides both.
98
+ */
99
+ resolveRepositoryInputs(_session, repos, _cancellation) {
100
+ return Promise.resolve([...repos]);
101
+ }
102
+ /**
103
+ * The repositories a repo-scoped read of `repos` addresses ({@link resolveRepositoryInputs}), for a caller that
104
+ * shapes the read by them before making it. Resolves the session as that read does, and fails as it would: a
105
+ * session that can't be resolved is the read's own failure (refreshing a refused token is claimed here), so the
106
+ * caller reports it rather than making the read. Settling that fails leaves `repos` as given, for the read to
107
+ * settle or report.
108
+ */
109
+ async resolveRepositoryScopes(repos, connectionId) {
110
+ if (isRepoIdsInput(repos)) return { value: repos };
111
+ const session = await this.resolveReadSession(connectionId, void 0);
112
+ if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
113
+ try {
114
+ return { value: await this.resolveRepositoryInputs(session, repos) };
115
+ } catch {
116
+ return { value: repos };
117
+ }
118
+ }
119
+ /**
120
+ * A batch or branch read's slots, settled against the repositories {@link resolveRepositoryCoordinates} settled
121
+ * its coordinates to: a miss for one it couldn't settle is rejected ({@link rejectUnsettledMisses}), and a refusal
122
+ * is recorded against the repository the host read rather than the caller's parse of it.
123
+ */
124
+ settleResolvedSlots(session, resolved, slots, isMiss, options) {
125
+ return this.settleBatchRefusals(session, resolved.coordinates, rejectUnsettledMisses(slots, resolved.unsettled, isMiss), options);
126
+ }
73
127
  /** The base the repository-list reads hand the provider client for a self-managed host. */
74
128
  getRepositoriesApiBaseUrl(session, _repos) {
75
129
  return this.getSelfManagedApiBaseUrl(session);
@@ -122,12 +176,17 @@ var GitHostIntegration = class extends IntegrationBase {
122
176
  async getDefaultBranch(repo, options) {
123
177
  const scope = getScopedLogger();
124
178
  if (await this.prepareSessionLookup() != null) return void 0;
125
- return this.ctx.cache.getRepositoryDefaultBranch(repo, this, () => ({ value: (async () => {
179
+ return this.ctx.cache.getRepositoryDefaultBranch(repo, this, (cacheable) => ({ value: (async () => {
126
180
  try {
127
181
  const result = await this.getProviderDefaultBranch(this._session, repo, options?.cancellation);
182
+ if (result == null && options?.cancellation?.aborted) {
183
+ cacheable.invalidate();
184
+ return;
185
+ }
128
186
  this.resetRequestExceptionCount("getDefaultBranch");
129
187
  return result;
130
188
  } catch (ex) {
189
+ if (!(ex instanceof RequestNotFoundError)) cacheable.invalidate();
131
190
  this.handleProviderException("getDefaultBranch", ex, { scope });
132
191
  return;
133
192
  }
@@ -135,18 +194,20 @@ var GitHostIntegration = class extends IntegrationBase {
135
194
  }
136
195
  /**
137
196
  * Settles what one repository's refusal of the credential means, as a batch read settles a refused target (see
138
- * `IntegrationBase.settleBatchRefusals`): the scope failure it is recorded as, against that repository (and, on
139
- * Azure DevOps, its project), with its cause named once the credential checks out. A refused credential throws
140
- * its own error, which the caller reports for the connection instead of the repository's refusal.
197
+ * `IntegrationBase.settleBatchRefusals`): the scope failure it is recorded as, against that repository as the host
198
+ * names it (and, on Azure DevOps, its project), with its cause named once the credential checks out. `name` names
199
+ * the repository alone, as a batch target does. A refused credential throws its own error, which the caller reports
200
+ * for the connection instead of the repository's refusal.
141
201
  */
142
202
  async settleRepositoryRefusal(repo, refusal) {
143
203
  const session = await this.resolveReadSessionOrThrow(repo.connectionId, void 0);
144
204
  if (session == null) return void 0;
145
- const [slot] = await this.settleBatchRefusals(session, [{
205
+ const { coordinates } = await this.resolveRepositoryCoordinates(session, [{
146
206
  owner: repo.owner,
147
207
  repo: repo.name,
148
208
  project: repo.project
149
- }], [{
209
+ }]);
210
+ const [slot] = await this.settleBatchRefusals(session, coordinates, [{
150
211
  status: "rejected",
151
212
  reason: refusal
152
213
  }]);
@@ -155,12 +216,17 @@ var GitHostIntegration = class extends IntegrationBase {
155
216
  async getRepositoryMetadata(repo, options) {
156
217
  const scope = getScopedLogger();
157
218
  if (await this.prepareSessionLookup() != null) return void 0;
158
- return this.ctx.cache.getRepositoryMetadata(repo, this, () => ({ value: (async () => {
219
+ return this.ctx.cache.getRepositoryMetadata(repo, this, (cacheable) => ({ value: (async () => {
159
220
  try {
160
221
  const result = await this.getProviderRepositoryMetadata(this._session, repo, options?.cancellation);
222
+ if (result == null && options?.cancellation?.aborted) {
223
+ cacheable.invalidate();
224
+ return;
225
+ }
161
226
  this.resetRequestExceptionCount("getRepositoryMetadata");
162
227
  return result;
163
228
  } catch (ex) {
229
+ if (!(ex instanceof RequestNotFoundError)) cacheable.invalidate();
164
230
  this.handleProviderException("getRepositoryMetadata", ex, { scope });
165
231
  return;
166
232
  }
@@ -464,17 +530,19 @@ var GitHostIntegration = class extends IntegrationBase {
464
530
  * thrown errors and validation failures into `{ error }` so callers can surface them as warnings
465
531
  * rather than swallowing them to `undefined`.
466
532
  */
467
- async getMyIssuesForReposResult(reposOrRepoIds, options, connectionId) {
533
+ async getMyIssuesForReposResult(repos, options, connectionId) {
468
534
  const scope = getScopedLogger();
469
535
  const providerId = this.authProvider.id;
470
536
  const states = toProviderIssueStates(options?.state);
471
537
  const session = await this.resolveReadSession(connectionId, scope);
472
538
  if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
473
539
  const start = performance.now();
540
+ let resolvedRepos;
474
541
  let customUrl;
475
542
  let api;
476
543
  try {
477
- customUrl = options?.customUrl ?? (isGitSelfManagedHostIntegrationId(providerId) ? this.getRepositoriesApiBaseUrl(session, reposOrRepoIds) : void 0);
544
+ resolvedRepos = isRepoIdsInput(repos) ? repos : await this.resolveRepositoryInputs(session, repos);
545
+ customUrl = options?.customUrl ?? (isGitSelfManagedHostIntegrationId(providerId) ? this.getRepositoriesApiBaseUrl(session, resolvedRepos) : void 0);
478
546
  api = await this.getProvidersApi();
479
547
  } catch (ex) {
480
548
  this.handleProviderException("getIssuesForRepos", ex, {
@@ -486,6 +554,7 @@ var GitHostIntegration = class extends IntegrationBase {
486
554
  duration: performance.now() - start
487
555
  };
488
556
  }
557
+ const reposOrRepoIds = resolvedRepos;
489
558
  const repoIdsInput = api.isRepoIdsInput(reposOrRepoIds);
490
559
  if (providerId !== "gitlab" && (repoIdsInput || isAzureProviderId(providerId) && !reposOrRepoIds.every((repo) => repo.project != null && repo.namespace != null))) return unsupportedRead(`Unsupported input for provider ${providerId}`, start, "getIssuesForRepos");
491
560
  let getIssuesOptions;
@@ -571,6 +640,8 @@ var GitHostIntegration = class extends IntegrationBase {
571
640
  }
572
641
  const { projectInput: _projectInput, results } = outcome.value;
573
642
  data.push(...results.values);
643
+ if (results.paging?.truncated) truncated = true;
644
+ metadata = mergeCollectionMetadata(metadata, results.metadata);
574
645
  if (results.paging?.more) {
575
646
  hasMore = true;
576
647
  cursor.cursors.push({
@@ -792,17 +863,19 @@ var GitHostIntegration = class extends IntegrationBase {
792
863
  * thrown errors and validation failures into `{ error }` so callers can surface them as warnings
793
864
  * rather than swallowing them to `undefined`.
794
865
  */
795
- async getMyPullRequestsForReposResult(reposOrRepoIds, options, connectionId) {
866
+ async getMyPullRequestsForReposResult(repos, options, connectionId) {
796
867
  const scope = getScopedLogger();
797
868
  const providerId = this.authProvider.id;
798
869
  const states = toProviderPullRequestStates(options?.state);
799
870
  const session = await this.resolveReadSession(connectionId, scope);
800
871
  if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
801
872
  const start = performance.now();
873
+ let resolvedRepos;
802
874
  let customUrl;
803
875
  let api;
804
876
  try {
805
- customUrl = options?.customUrl ?? (isGitSelfManagedHostIntegrationId(providerId) ? this.getRepositoriesApiBaseUrl(session, reposOrRepoIds) : void 0);
877
+ resolvedRepos = isRepoIdsInput(repos) ? repos : await this.resolveRepositoryInputs(session, repos);
878
+ customUrl = options?.customUrl ?? (isGitSelfManagedHostIntegrationId(providerId) ? this.getRepositoriesApiBaseUrl(session, resolvedRepos) : void 0);
806
879
  api = await this.getProvidersApi();
807
880
  } catch (ex) {
808
881
  this.handleProviderException("getPullRequestsForRepos", ex, {
@@ -814,6 +887,7 @@ var GitHostIntegration = class extends IntegrationBase {
814
887
  duration: performance.now() - start
815
888
  };
816
889
  }
890
+ const reposOrRepoIds = resolvedRepos;
817
891
  if (providerId !== "gitlab" && (api.isRepoIdsInput(reposOrRepoIds) || isAzureProviderId(providerId) && !reposOrRepoIds.every((repo) => repo.project != null && repo.namespace != null))) return unsupportedRead(`Unsupported input for provider ${providerId}`, start);
818
892
  let getPullRequestsOptions;
819
893
  if (options?.filters != null) {
@@ -1228,7 +1302,8 @@ var GitHostIntegration = class extends IntegrationBase {
1228
1302
  const start = performance.now();
1229
1303
  let slots;
1230
1304
  try {
1231
- slots = await this.getProviderIssuesBatch?.(session, coordinates, cancellation);
1305
+ const targets = await this.resolveRepositoryCoordinates(session, coordinates, cancellation);
1306
+ slots = await this.getProviderIssuesBatch?.(session, targets.coordinates, cancellation);
1232
1307
  if (slots == null) {
1233
1308
  this.resetRequestExceptionCount("getIssuesBatch");
1234
1309
  return {
@@ -1236,9 +1311,9 @@ var GitHostIntegration = class extends IntegrationBase {
1236
1311
  duration: performance.now() - start
1237
1312
  };
1238
1313
  }
1239
- const settled = await this.settleBatchRefusals(session, coordinates, slots);
1314
+ const settled = await this.settleResolvedSlots(session, targets, slots, (issue) => issue == null);
1240
1315
  this.resetRequestExceptionCount("getIssuesBatch");
1241
- this.reportDeferredRequestFailures(slots, false);
1316
+ this.reportDeferredRequestFailures(settled, false);
1242
1317
  return {
1243
1318
  value: settled,
1244
1319
  duration: performance.now() - start
@@ -1279,7 +1354,8 @@ var GitHostIntegration = class extends IntegrationBase {
1279
1354
  const start = performance.now();
1280
1355
  let slots;
1281
1356
  try {
1282
- slots = await this.getProviderPullRequestsBatch?.(session, coordinates, options, cancellation);
1357
+ const targets = await this.resolveRepositoryCoordinates(session, coordinates, cancellation);
1358
+ slots = await this.getProviderPullRequestsBatch?.(session, targets.coordinates, options, cancellation);
1283
1359
  if (slots == null) {
1284
1360
  this.resetRequestExceptionCount("getPullRequestsBatch");
1285
1361
  return {
@@ -1287,9 +1363,9 @@ var GitHostIntegration = class extends IntegrationBase {
1287
1363
  duration: performance.now() - start
1288
1364
  };
1289
1365
  }
1290
- const settled = await this.settleBatchRefusals(session, coordinates, slots);
1366
+ const settled = await this.settleResolvedSlots(session, targets, slots, (pr) => pr == null);
1291
1367
  this.resetRequestExceptionCount("getPullRequestsBatch");
1292
- this.reportDeferredRequestFailures(slots, false);
1368
+ this.reportDeferredRequestFailures(settled, false);
1293
1369
  return {
1294
1370
  value: settled,
1295
1371
  duration: performance.now() - start
@@ -1326,13 +1402,14 @@ var GitHostIntegration = class extends IntegrationBase {
1326
1402
  if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
1327
1403
  const start = performance.now();
1328
1404
  try {
1329
- const slots = await this.getProviderIssuesEtagFields?.(session, coordinates, options, cancellation);
1330
- if (slots == null) return {
1405
+ const targets = await this.resolveRepositoryCoordinates(session, coordinates, cancellation);
1406
+ const read = await this.getProviderIssuesEtagFields?.(session, targets.coordinates, options, cancellation);
1407
+ if (read == null) return {
1331
1408
  value: void 0,
1332
1409
  duration: performance.now() - start
1333
1410
  };
1334
- const settled = await this.settleBatchRefusals(session, coordinates, slots, { keepOtherFailures: true });
1335
- if (slots.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getIssuesEtagFields");
1411
+ const settled = await this.settleResolvedSlots(session, targets, read, (fields) => fields == null, { keepOtherFailures: true });
1412
+ if (settled.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getIssuesEtagFields");
1336
1413
  return {
1337
1414
  value: settled,
1338
1415
  duration: performance.now() - start
@@ -1362,13 +1439,14 @@ var GitHostIntegration = class extends IntegrationBase {
1362
1439
  if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
1363
1440
  const start = performance.now();
1364
1441
  try {
1365
- const slots = await this.getProviderPullRequestsEtagFields?.(session, coordinates, options, cancellation);
1366
- if (slots == null) return {
1442
+ const targets = await this.resolveRepositoryCoordinates(session, coordinates, cancellation);
1443
+ const read = await this.getProviderPullRequestsEtagFields?.(session, targets.coordinates, options, cancellation);
1444
+ if (read == null) return {
1367
1445
  value: void 0,
1368
1446
  duration: performance.now() - start
1369
1447
  };
1370
- const settled = await this.settleBatchRefusals(session, coordinates, slots, { keepOtherFailures: true });
1371
- if (slots.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getPullRequestsEtagFields");
1448
+ const settled = await this.settleResolvedSlots(session, targets, read, (fields) => fields == null, { keepOtherFailures: true });
1449
+ if (settled.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getPullRequestsEtagFields");
1372
1450
  return {
1373
1451
  value: settled,
1374
1452
  duration: performance.now() - start
@@ -1406,7 +1484,8 @@ var GitHostIntegration = class extends IntegrationBase {
1406
1484
  const start = performance.now();
1407
1485
  let slots;
1408
1486
  try {
1409
- slots = await this.getProviderPullRequestsForBranches?.(session, targets, options, cancellation);
1487
+ const resolved = await this.resolveRepositoryCoordinates(session, targets, cancellation);
1488
+ slots = await this.getProviderPullRequestsForBranches?.(session, resolved.coordinates, options, cancellation);
1410
1489
  if (slots == null) {
1411
1490
  this.resetRequestExceptionCount("getPullRequestsForBranches");
1412
1491
  return {
@@ -1414,9 +1493,9 @@ var GitHostIntegration = class extends IntegrationBase {
1414
1493
  duration: performance.now() - start
1415
1494
  };
1416
1495
  }
1417
- const settled = await this.settleBatchRefusals(session, targets, slots);
1496
+ const settled = await this.settleResolvedSlots(session, resolved, slots, (found) => found.pullRequests.length === 0 && !found.truncated);
1418
1497
  this.resetRequestExceptionCount("getPullRequestsForBranches");
1419
- this.reportDeferredRequestFailures(slots, false);
1498
+ this.reportDeferredRequestFailures(settled, false);
1420
1499
  return {
1421
1500
  value: settled,
1422
1501
  duration: performance.now() - start