@gitkraken/core-gitlens 0.5.114 → 0.5.115

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 (138) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/plus/git-github/api/github.d.ts.map +1 -1
  3. package/dist/plus/git-github/api/github.js +37 -37
  4. package/dist/plus/git-github/api/github.js.map +1 -1
  5. package/dist/plus/integrations/collectionMetadata.d.ts +2 -0
  6. package/dist/plus/integrations/collectionMetadata.d.ts.map +1 -1
  7. package/dist/plus/integrations/collectionMetadata.js +17 -1
  8. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  9. package/dist/plus/integrations/context.d.ts +4 -1
  10. package/dist/plus/integrations/context.d.ts.map +1 -1
  11. package/dist/plus/integrations/index.d.ts +1 -0
  12. package/dist/plus/integrations/index.d.ts.map +1 -1
  13. package/dist/plus/integrations/integrationService.d.ts +9 -1
  14. package/dist/plus/integrations/integrationService.d.ts.map +1 -1
  15. package/dist/plus/integrations/integrationService.js +8 -4
  16. package/dist/plus/integrations/integrationService.js.map +1 -1
  17. package/dist/plus/integrations/manager.d.ts +22 -0
  18. package/dist/plus/integrations/manager.d.ts.map +1 -1
  19. package/dist/plus/integrations/models/gitHostIntegration.d.ts +22 -26
  20. package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -1
  21. package/dist/plus/integrations/models/gitHostIntegration.js +92 -47
  22. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  23. package/dist/plus/integrations/models/integration.d.ts +9 -0
  24. package/dist/plus/integrations/models/integration.d.ts.map +1 -1
  25. package/dist/plus/integrations/models/integration.js +52 -19
  26. package/dist/plus/integrations/models/integration.js.map +1 -1
  27. package/dist/plus/integrations/models/issueCache.d.ts +16 -0
  28. package/dist/plus/integrations/models/issueCache.d.ts.map +1 -0
  29. package/dist/plus/integrations/models/issueCache.js +9 -0
  30. package/dist/plus/integrations/models/issueCache.js.map +1 -0
  31. package/dist/plus/integrations/models/issueReads.d.ts +13 -0
  32. package/dist/plus/integrations/models/issueReads.d.ts.map +1 -1
  33. package/dist/plus/integrations/models/issuesIntegration.d.ts +11 -13
  34. package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -1
  35. package/dist/plus/integrations/models/issuesIntegration.js +15 -1
  36. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  37. package/dist/plus/integrations/providers/azureDevOps.d.ts +3 -5
  38. package/dist/plus/integrations/providers/azureDevOps.d.ts.map +1 -1
  39. package/dist/plus/integrations/providers/azureDevOps.js +9 -8
  40. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  41. package/dist/plus/integrations/providers/bitbucket-server.d.ts +3 -5
  42. package/dist/plus/integrations/providers/bitbucket-server.d.ts.map +1 -1
  43. package/dist/plus/integrations/providers/bitbucket-server.js +2 -2
  44. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  45. package/dist/plus/integrations/providers/bitbucket.d.ts +3 -5
  46. package/dist/plus/integrations/providers/bitbucket.d.ts.map +1 -1
  47. package/dist/plus/integrations/providers/bitbucket.js +2 -1
  48. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  49. package/dist/plus/integrations/providers/github.d.ts +3 -5
  50. package/dist/plus/integrations/providers/github.d.ts.map +1 -1
  51. package/dist/plus/integrations/providers/github.js +3 -3
  52. package/dist/plus/integrations/providers/github.js.map +1 -1
  53. package/dist/plus/integrations/providers/gitlab.d.ts +3 -5
  54. package/dist/plus/integrations/providers/gitlab.d.ts.map +1 -1
  55. package/dist/plus/integrations/providers/gitlab.js +2 -2
  56. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  57. package/dist/plus/integrations/providers/jira.d.ts +3 -7
  58. package/dist/plus/integrations/providers/jira.d.ts.map +1 -1
  59. package/dist/plus/integrations/providers/jira.js +35 -22
  60. package/dist/plus/integrations/providers/jira.js.map +1 -1
  61. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +7 -0
  62. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts.map +1 -0
  63. package/dist/plus/integrations/providers/jiraIssueByKey.js +102 -0
  64. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -0
  65. package/dist/plus/integrations/providers/linear.d.ts +3 -7
  66. package/dist/plus/integrations/providers/linear.d.ts.map +1 -1
  67. package/dist/plus/integrations/providers/linear.js +23 -22
  68. package/dist/plus/integrations/providers/linear.js.map +1 -1
  69. package/dist/plus/integrations/providers/models.d.ts +3 -1
  70. package/dist/plus/integrations/providers/models.d.ts.map +1 -1
  71. package/dist/plus/integrations/providers/models.js +10 -4
  72. package/dist/plus/integrations/providers/models.js.map +1 -1
  73. package/dist/plus/integrations/providers/providerErrors.d.ts +7 -0
  74. package/dist/plus/integrations/providers/providerErrors.d.ts.map +1 -0
  75. package/dist/plus/integrations/providers/providerErrors.js +91 -0
  76. package/dist/plus/integrations/providers/providerErrors.js.map +1 -0
  77. package/dist/plus/integrations/providers/providersApi.d.ts +3 -2
  78. package/dist/plus/integrations/providers/providersApi.d.ts.map +1 -1
  79. package/dist/plus/integrations/providers/providersApi.js +18 -52
  80. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  81. package/dist/plus/integrations/providers/trello.d.ts +2 -7
  82. package/dist/plus/integrations/providers/trello.d.ts.map +1 -1
  83. package/dist/plus/integrations/providers/trello.js +3 -1
  84. package/dist/plus/integrations/providers/trello.js.map +1 -1
  85. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +2 -0
  86. package/dist/plus/integrations/providers/utils/providerPaging.d.ts.map +1 -1
  87. package/dist/plus/integrations/providers/utils/providerPaging.js +12 -7
  88. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  89. package/dist/plus/integrations/reads/issueTracker.d.ts.map +1 -1
  90. package/dist/plus/integrations/reads/issueTracker.js +23 -17
  91. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  92. package/dist/plus/integrations/reads/trackerIssue.d.ts +21 -0
  93. package/dist/plus/integrations/reads/trackerIssue.d.ts.map +1 -0
  94. package/dist/plus/integrations/reads/trackerIssue.js +51 -0
  95. package/dist/plus/integrations/reads/trackerIssue.js.map +1 -0
  96. package/dist/plus/integrations/reads/warnings.d.ts +2 -15
  97. package/dist/plus/integrations/reads/warnings.d.ts.map +1 -1
  98. package/dist/plus/integrations/reads/warnings.js +19 -1
  99. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  100. package/dist/plus/integrations/results.d.ts +4 -20
  101. package/dist/plus/integrations/results.d.ts.map +1 -1
  102. package/dist/plus/integrations/results.js.map +1 -1
  103. package/dist/utils/promise.d.ts +2 -0
  104. package/dist/utils/promise.d.ts.map +1 -1
  105. package/dist/utils/promise.js +11 -0
  106. package/dist/utils/promise.js.map +1 -1
  107. package/docs/integrations.md +37 -26
  108. package/docs/kepler-read-api-parity.md +13 -0
  109. package/package.json +2 -2
  110. package/src/plus/git-github/api/github.ts +51 -58
  111. package/src/plus/integrations/collectionMetadata.ts +23 -1
  112. package/src/plus/integrations/context.ts +1 -1
  113. package/src/plus/integrations/index.ts +1 -0
  114. package/src/plus/integrations/integrationService.ts +14 -4
  115. package/src/plus/integrations/manager.ts +22 -0
  116. package/src/plus/integrations/models/gitHostIntegration.ts +117 -129
  117. package/src/plus/integrations/models/integration.ts +56 -22
  118. package/src/plus/integrations/models/issueCache.ts +29 -0
  119. package/src/plus/integrations/models/issueReads.ts +15 -0
  120. package/src/plus/integrations/models/issuesIntegration.ts +38 -8
  121. package/src/plus/integrations/providers/azureDevOps.ts +16 -13
  122. package/src/plus/integrations/providers/bitbucket-server.ts +4 -6
  123. package/src/plus/integrations/providers/bitbucket.ts +3 -4
  124. package/src/plus/integrations/providers/github.ts +5 -7
  125. package/src/plus/integrations/providers/gitlab.ts +4 -6
  126. package/src/plus/integrations/providers/jira.ts +52 -26
  127. package/src/plus/integrations/providers/jiraIssueByKey.ts +155 -0
  128. package/src/plus/integrations/providers/linear.ts +38 -25
  129. package/src/plus/integrations/providers/models.ts +17 -5
  130. package/src/plus/integrations/providers/providerErrors.ts +115 -0
  131. package/src/plus/integrations/providers/providersApi.ts +26 -68
  132. package/src/plus/integrations/providers/trello.ts +5 -4
  133. package/src/plus/integrations/providers/utils/providerPaging.ts +14 -7
  134. package/src/plus/integrations/reads/issueTracker.ts +26 -24
  135. package/src/plus/integrations/reads/trackerIssue.ts +105 -0
  136. package/src/plus/integrations/reads/warnings.ts +23 -17
  137. package/src/plus/integrations/results.ts +4 -20
  138. package/src/utils/promise.ts +15 -0
@@ -0,0 +1,105 @@
1
+ import type { IssueShape } from '../../../git/models/issue.js';
2
+ import type { IntegrationIds } from '../constants.js';
3
+ import { IssuesCloudHostIntegrationId } from '../constants.js';
4
+ import { isIssuesIntegration } from '../models/issuesIntegration.js';
5
+ import type { ProviderResult, ProviderWarning } from '../results.js';
6
+ import { isIssuesHostIntegrationId } from '../utils/integration.utils.js';
7
+ import type { ProviderReadContext } from './context.js';
8
+ import { runCaptured } from './drains.js';
9
+ import { issueTrackerOnlySurfaceWarning, otherWarning } from './warnings.js';
10
+
11
+ export interface TrackerIssueResult {
12
+ key: string;
13
+ /**
14
+ * The resolved issue, or `undefined` when it provably does not exist or is not visible to this connection.
15
+ * A failed read returns no item and sets `fetchFailed`.
16
+ */
17
+ issue?: IssueShape;
18
+ }
19
+
20
+ /** Issue trackers are cloud-only, so this read takes no `domain`. */
21
+ export async function getTrackerIssue(
22
+ ctx: ProviderReadContext,
23
+ options: {
24
+ providerId: IntegrationIds;
25
+ resourceId: string;
26
+ resourceUrl?: string;
27
+ key: string;
28
+ connectionId?: string;
29
+ },
30
+ ): Promise<ProviderResult<TrackerIssueResult>> {
31
+ const refused = (warning: ProviderWarning): ProviderResult<TrackerIssueResult> => ({
32
+ items: [],
33
+ warnings: [warning],
34
+ fetchFailed: true,
35
+ });
36
+ const surface = 'Issue resolution by key';
37
+
38
+ if (!isIssuesHostIntegrationId(options.providerId)) {
39
+ return refused(issueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, surface));
40
+ }
41
+
42
+ if (options.resourceId.trim().length === 0) {
43
+ return refused(
44
+ otherWarning(options.providerId, undefined, options.connectionId, `${surface} requires a resource id.`),
45
+ );
46
+ }
47
+
48
+ if (options.key.trim().length === 0) {
49
+ return refused(
50
+ otherWarning(options.providerId, undefined, options.connectionId, `${surface} requires an issue key.`),
51
+ );
52
+ }
53
+
54
+ const resourceUrl = options.resourceUrl?.trim() || undefined;
55
+ if (options.providerId === IssuesCloudHostIntegrationId.Jira && resourceUrl == null) {
56
+ return refused(
57
+ otherWarning(
58
+ options.providerId,
59
+ undefined,
60
+ options.connectionId,
61
+ `${surface} requires the Jira resource URL so the result contains a browser link without resource discovery.`,
62
+ ),
63
+ );
64
+ }
65
+
66
+ const integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId);
67
+ if (integration == null) {
68
+ const early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId);
69
+ return { items: [], warnings: early.warnings, fetchFailed: early.fetchFailed || undefined };
70
+ }
71
+ if (!isIssuesIntegration(integration)) {
72
+ return refused(issueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, surface));
73
+ }
74
+ if (!integration.supportsIssueLookupByResourceId) {
75
+ return refused(
76
+ otherWarning(
77
+ options.providerId,
78
+ undefined,
79
+ options.connectionId,
80
+ `${surface} is not supported by '${options.providerId}'; its single-issue read cannot prove an absence, so a miss would not be safe to cache.`,
81
+ ),
82
+ );
83
+ }
84
+
85
+ const domain = ctx.domainForRead(integration, options.providerId, options.connectionId);
86
+ const issue = await runCaptured(
87
+ options.providerId,
88
+ domain,
89
+ options.connectionId,
90
+ () =>
91
+ integration.getIssueByResourceIdResult(options.resourceId, options.key, {
92
+ connectionId: options.connectionId,
93
+ resourceUrl: resourceUrl,
94
+ }),
95
+ { warnOnMissingSession: true },
96
+ );
97
+ if (issue.warning != null) {
98
+ return refused(issue.warning);
99
+ }
100
+
101
+ return {
102
+ items: [{ key: options.key, ...(issue.value != null ? { issue: issue.value } : {}) }],
103
+ warnings: [],
104
+ };
105
+ }
@@ -8,7 +8,7 @@ import type {
8
8
  PullRequestSorting,
9
9
  } from '../providerFilters.js';
10
10
  import { providersMetadata } from '../providers/models.js';
11
- import type { ProviderWarning } from '../results.js';
11
+ import type { ProviderWarning, ProviderWarningOmissionRecovery } from '../results.js';
12
12
  import type { IssueSearchCriteriaRejection, PullRequestSearchCriteriaRejection } from './filters.js';
13
13
  import type { UnmergeableIssueSort, UnsupportedIssueSortRejection } from './ordering.js';
14
14
 
@@ -101,21 +101,23 @@ export function issueTrackerOnlySurfaceWarning(
101
101
  );
102
102
  }
103
103
 
104
- /**
105
- * Why a read the facade drove itself returned less than everything. The two questions a consumer cannot
106
- * answer from `truncated` or from the message, kept together because they are decided together:
107
- *
108
- * - `interrupted`: the read did NOT succeed — the session went away, a later page failed. It leaves an unread
109
- * tail like the others, but it is a failure: it sets `fetchFailed`, and a retry is exactly the right move.
110
- * Gets no omission at all, since the omission asserts the opposite.
111
- * - `page-budget`: the drain stopped at its own `maxPages`, with a usable cursor still in hand. The items ARE
112
- * reachable and were simply not fetched, so re-running with a higher budget returns them.
113
- * - `exhausted`: everything else that succeeded and came back short — the provider capped the page it served,
114
- * advertised another page without a usable cursor (or with one it had already handed out), or a read could
115
- * not confirm it had drained everything. The default of the three: choose it whenever a raisable budget is
116
- * not demonstrably what stopped the read, so a consumer is never offered a fetch that cannot deliver.
117
- */
118
- export type IncompleteReadCause = 'interrupted' | 'page-budget' | 'exhausted';
104
+ /** Why a facade-driven read returned fewer results than requested. */
105
+ export type IncompleteReadCause = 'interrupted' | 'page-budget' | 'exhausted' | 'scope-too-large';
106
+
107
+ function recoveryForIncompleteReadCause(cause: IncompleteReadCause): ProviderWarningOmissionRecovery {
108
+ switch (cause) {
109
+ case 'page-budget':
110
+ return 'page-budget';
111
+ case 'scope-too-large':
112
+ return 'narrow-scope';
113
+ case 'interrupted':
114
+ case 'exhausted':
115
+ return 'none';
116
+ default:
117
+ cause satisfies never;
118
+ return 'none';
119
+ }
120
+ }
119
121
 
120
122
  /**
121
123
  * Builds the warning for a read that returned less than everything, carrying the two facts a consumer cannot
@@ -143,7 +145,7 @@ export function incompleteReadWarning(
143
145
  ...warning,
144
146
  omission: {
145
147
  kind: 'pagination-incomplete',
146
- recovery: cause === 'page-budget' ? 'page-budget' : 'none',
148
+ recovery: recoveryForIncompleteReadCause(cause),
147
149
  },
148
150
  };
149
151
  }
@@ -192,6 +194,10 @@ function truncationMessage(id: IntegrationIds, readKind: TruncatedReadKind, caus
192
194
  return `${readKind} read for '${id}' stopped at its page budget; more results can be read by raising it.`;
193
195
  case 'exhausted':
194
196
  return `${readKind} read for '${id}' was truncated and cannot be continued; results may be incomplete.`;
197
+ case 'scope-too-large':
198
+ // Says what is true — the scope is larger than a read of it — rather than blaming the provider for a
199
+ // ceiling that is ours, and names the remedy that exists, since no retry or budget has one.
200
+ return `${readKind} read for '${id}' covers more than one read can return; narrow the scope to read the rest.`;
195
201
  }
196
202
  // No `default`: `IncompleteReadCause` is declared in this file, so `noImplicitReturns` already fails the
197
203
  // build here if a cause is added without its own wording. (`collectionOmissionMessage`'s `satisfies never`
@@ -35,27 +35,11 @@ export type ProviderWarningKind = 'auth' | 'rate-limit' | 'not-found' | 'no-conn
35
35
  export type ProviderWarningOmissionKind = 'provider-limit' | 'recovery-budget' | 'pagination-incomplete';
36
36
 
37
37
  /**
38
- * What, if anything, would fetch the withheld results the question `kind` cannot answer.
39
- *
40
- * `kind` says WHY results are missing, and two omissions of the same kind can need opposite handling: a drain
41
- * that stopped at a caller-settable page budget and a provider that advertised another page without a usable
42
- * cursor are both `pagination-incomplete`, but only the first can be fetched. A consumer offering a "load
43
- * more" affordance gates it on this, never on `kind`.
44
- *
45
- * - `none`: nothing the consumer can call returns the missing items — a provider-enforced cap, an internal
46
- * budget it does not control, or a continuation the provider refused to hand back. Say the results are
47
- * capped; do not offer to fetch more.
48
- * - `page-budget`: re-run the SAME read with a higher page budget (`maxPages` on the sweep options). Note this
49
- * re-reads from the start rather than continuing — a sweep exposes no cursor — so it is a deliberate,
50
- * user-initiated action, not something to retry automatically.
51
- *
52
- * Required, not optional: an absent value would be indistinguishable from `none` while actually meaning "this
53
- * producer didn't say", which is the ambiguity {@link ProviderWarning.omission} exists to remove. And a
54
- * conservative union on purpose — it names only what a producer can PROVE. A value is added when some layer
55
- * can vouch for it, never so that a plausible-looking case has something to map to; see
56
- * `collectionMetadata.ts` for the SDK shape that looks recoverable and is not.
38
+ * How a consumer can recover omitted results. `page-budget` reruns with a larger budget; `narrow-scope`
39
+ * requests a smaller server-side scope; `none` promises neither. Switch on the exact value because only
40
+ * `page-budget` is a fetch-more action.
57
41
  */
58
- export type ProviderWarningOmissionRecovery = 'none' | 'page-budget';
42
+ export type ProviderWarningOmissionRecovery = 'none' | 'page-budget' | 'narrow-scope';
59
43
 
60
44
  /** Which repository / project / resource an omission is attributed to. All fields optional; a scope may name none. */
61
45
  export interface ProviderWarningOmissionScope {
@@ -121,6 +121,21 @@ export async function mapBounded<T, R>(
121
121
  return results;
122
122
  }
123
123
 
124
+ /** Settles each task without stopping the sliding window when one of them rejects. */
125
+ export function mapSettledBounded<T, R>(
126
+ items: readonly T[],
127
+ concurrency: number,
128
+ task: (item: T, index: number) => Promise<R>,
129
+ ): Promise<PromiseSettledResult<Awaited<R>>[]> {
130
+ return mapBounded(items, concurrency, async (item, index): Promise<PromiseSettledResult<Awaited<R>>> => {
131
+ try {
132
+ return { status: 'fulfilled', value: await task(item, index) };
133
+ } catch (reason) {
134
+ return { status: 'rejected', reason: reason };
135
+ }
136
+ });
137
+ }
138
+
124
139
  export class PromiseCancelledError<T extends Promise<any> = Promise<any>> extends Error {
125
140
  constructor(
126
141
  public readonly promise: T,