@gitkraken/core-gitlens 0.5.102 → 0.5.104
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.
- package/CHANGELOG.md +26 -1
- package/dist/git/models/issue.d.ts +78 -0
- package/dist/git/models/issue.d.ts.map +1 -1
- package/dist/git/models/issue.js.map +1 -1
- package/dist/plus/git-github/api/config.d.ts +12 -0
- package/dist/plus/git-github/api/config.d.ts.map +1 -1
- package/dist/plus/git-github/api/config.js +12 -1
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +77 -7
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +241 -120
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueSearchQuery.d.ts +70 -0
- package/dist/plus/git-github/api/issueSearchQuery.d.ts.map +1 -0
- package/dist/plus/git-github/api/issueSearchQuery.js +143 -0
- package/dist/plus/git-github/api/issueSearchQuery.js.map +1 -0
- package/dist/plus/integrations/collectionMetadata.d.ts +15 -1
- package/dist/plus/integrations/collectionMetadata.d.ts.map +1 -1
- package/dist/plus/integrations/collectionMetadata.js +21 -2
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -0
- package/dist/plus/integrations/index.d.ts.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +39 -2
- package/dist/plus/integrations/integrationService.d.ts.map +1 -1
- package/dist/plus/integrations/integrationService.js +17 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +88 -2
- package/dist/plus/integrations/manager.d.ts.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +61 -3
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +3 -46
- package/dist/plus/integrations/models/integration.d.ts.map +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueReads.d.ts +70 -0
- package/dist/plus/integrations/models/issueReads.d.ts.map +1 -0
- package/dist/plus/integrations/models/issueReads.js +2 -0
- package/dist/plus/integrations/models/issueReads.js.map +1 -0
- package/dist/plus/integrations/providerFilters.d.ts +10 -0
- package/dist/plus/integrations/providerFilters.d.ts.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +26 -3
- package/dist/plus/integrations/providers/github.d.ts.map +1 -1
- package/dist/plus/integrations/providers/github.js +34 -0
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +22 -0
- package/dist/plus/integrations/providers/models.d.ts.map +1 -1
- package/dist/plus/integrations/providers/models.js +26 -0
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/reads/broaden.d.ts +10 -0
- package/dist/plus/integrations/reads/broaden.d.ts.map +1 -1
- package/dist/plus/integrations/reads/broaden.js.map +1 -1
- package/dist/plus/integrations/reads/counts.d.ts +64 -0
- package/dist/plus/integrations/reads/counts.d.ts.map +1 -0
- package/dist/plus/integrations/reads/counts.js +164 -0
- package/dist/plus/integrations/reads/counts.js.map +1 -0
- package/dist/plus/integrations/reads/filters.d.ts +63 -1
- package/dist/plus/integrations/reads/filters.d.ts.map +1 -1
- package/dist/plus/integrations/reads/filters.js +125 -0
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.d.ts.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.js +34 -17
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts.map +1 -1
- package/dist/plus/integrations/reads/issues.js +22 -41
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/paging.d.ts +59 -0
- package/dist/plus/integrations/reads/paging.d.ts.map +1 -1
- package/dist/plus/integrations/reads/paging.js +60 -0
- package/dist/plus/integrations/reads/paging.js.map +1 -1
- package/dist/plus/integrations/reads/searchIssues.d.ts +55 -0
- package/dist/plus/integrations/reads/searchIssues.d.ts.map +1 -0
- package/dist/plus/integrations/reads/searchIssues.js +144 -0
- package/dist/plus/integrations/reads/searchIssues.js.map +1 -0
- package/dist/plus/integrations/reads/warnings.d.ts +33 -3
- package/dist/plus/integrations/reads/warnings.d.ts.map +1 -1
- package/dist/plus/integrations/reads/warnings.js +87 -6
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/docs/integrations.md +110 -2
- package/docs/kepler-read-api-parity.md +57 -0
- package/package.json +1 -1
- package/src/git/models/issue.ts +81 -0
- package/src/plus/git-github/api/config.ts +13 -0
- package/src/plus/git-github/api/github.ts +332 -148
- package/src/plus/git-github/api/issueSearchQuery.ts +165 -0
- package/src/plus/integrations/collectionMetadata.ts +22 -3
- package/src/plus/integrations/index.ts +5 -0
- package/src/plus/integrations/integrationService.ts +47 -1
- package/src/plus/integrations/manager.ts +88 -2
- package/src/plus/integrations/models/gitHostIntegration.ts +102 -2
- package/src/plus/integrations/models/integration.ts +7 -46
- package/src/plus/integrations/models/issueReads.ts +73 -0
- package/src/plus/integrations/providerFilters.ts +15 -0
- package/src/plus/integrations/providers/github.ts +64 -2
- package/src/plus/integrations/providers/models.ts +49 -0
- package/src/plus/integrations/reads/broaden.ts +10 -0
- package/src/plus/integrations/reads/counts.ts +285 -0
- package/src/plus/integrations/reads/filters.ts +162 -1
- package/src/plus/integrations/reads/hierarchy.ts +43 -32
- package/src/plus/integrations/reads/issues.ts +22 -45
- package/src/plus/integrations/reads/paging.ts +102 -0
- package/src/plus/integrations/reads/searchIssues.ts +252 -0
- package/src/plus/integrations/reads/warnings.ts +129 -11
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { IntegrationIds } from '../constants.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
IssueFilter,
|
|
4
|
+
IssueSearchCapabilities,
|
|
5
|
+
IssueSearchCriteria,
|
|
6
|
+
IssueSearchRelationship,
|
|
7
|
+
PullRequestFilter,
|
|
8
|
+
} from '../providerFilters.js';
|
|
9
|
+
import type { ProviderRepoInput, ProviderReposInput } from '../providers/models.js';
|
|
3
10
|
import { providersMetadata } from '../providers/models.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
@@ -79,6 +86,139 @@ export function resolveAccountWideIssueFilters(
|
|
|
79
86
|
return { filters: filters, unsupported: false };
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
/** Why {@link resolveIssueSearchCriteria} refused a criteria set, so the caller can word the refusal exactly. */
|
|
90
|
+
export type IssueSearchCriteriaRejection =
|
|
91
|
+
/** The provider has no filtered issue search at all. */
|
|
92
|
+
| { reason: 'unsupported-search' }
|
|
93
|
+
/** The provider has one, but can't express these criteria server-side. */
|
|
94
|
+
| { reason: 'unsupported-criteria'; criteria: string[] }
|
|
95
|
+
/** `any-assignee` and `unassigned` partition the scope between them; asking for both asks for nothing. */
|
|
96
|
+
| { reason: 'contradictory-relationships' };
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Validates a filtered issue search's criteria against {@link ProviderMetadata.supportedIssueSearch}.
|
|
100
|
+
*
|
|
101
|
+
* All-or-nothing like its three siblings above, and for the same reason: a criterion dropped because the
|
|
102
|
+
* provider can't express it would serve a WIDER result than was asked for, and narrowing the returned page
|
|
103
|
+
* afterward would leave `items` describing a different result set than the `hasMore`/`cursor` the provider
|
|
104
|
+
* produced with it. So an inexpressible set is refused whole and the caller surfaces a warning.
|
|
105
|
+
*
|
|
106
|
+
* Unlike the sibling validators this also rejects a set that is internally contradictory, because this criteria
|
|
107
|
+
* model is the only one with two members that partition the scope between them (`any-assignee` ∪ `unassigned` =
|
|
108
|
+
* everything, ∩ = nothing). Silently keeping one would answer a question the caller didn't ask.
|
|
109
|
+
*
|
|
110
|
+
* `undefined` (or an empty relationship list plus no other criterion) is a valid UNNARROWED search of the given
|
|
111
|
+
* scope, not an error — the caller's `repos`/`org` is what bounds it.
|
|
112
|
+
*/
|
|
113
|
+
export function resolveIssueSearchCriteria(
|
|
114
|
+
id: IntegrationIds,
|
|
115
|
+
criteria: IssueSearchCriteria | undefined,
|
|
116
|
+
): { rejection?: IssueSearchCriteriaRejection } {
|
|
117
|
+
const supported = providersMetadata[id]?.supportedIssueSearch;
|
|
118
|
+
if (supported == null) return { rejection: { reason: 'unsupported-search' } };
|
|
119
|
+
if (criteria == null) return {};
|
|
120
|
+
|
|
121
|
+
const relationships = criteria.relationships;
|
|
122
|
+
if (relationships?.includes('any-assignee') && relationships.includes('unassigned')) {
|
|
123
|
+
return { rejection: { reason: 'contradictory-relationships' } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const unsupported: string[] = [];
|
|
127
|
+
for (const relationship of relationships ?? []) {
|
|
128
|
+
if (!supported.relationships.includes(relationship)) {
|
|
129
|
+
unsupported.push(`relationships:${relationship}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Only a criterion the caller actually SET can be unsupported. `false`/empty means "don't narrow on this",
|
|
133
|
+
// which every provider can honor by doing nothing, so it must not be validated as a request.
|
|
134
|
+
if (criteria.text != null && criteria.text.trim().length > 0 && !supported.text) {
|
|
135
|
+
unsupported.push('text');
|
|
136
|
+
}
|
|
137
|
+
if (criteria.labels?.length && !supported.labels) {
|
|
138
|
+
unsupported.push('labels');
|
|
139
|
+
}
|
|
140
|
+
if (criteria.milestone != null && !supported.milestone) {
|
|
141
|
+
unsupported.push('milestone');
|
|
142
|
+
}
|
|
143
|
+
if (criteria.updatedAfter != null && !supported.updatedAfter) {
|
|
144
|
+
unsupported.push('updatedAfter');
|
|
145
|
+
}
|
|
146
|
+
if (criteria.createdAfter != null && !supported.createdAfter) {
|
|
147
|
+
unsupported.push('createdAfter');
|
|
148
|
+
}
|
|
149
|
+
if (criteria.withoutLinkedPullRequest === true && !supported.withoutLinkedPullRequest) {
|
|
150
|
+
unsupported.push('withoutLinkedPullRequest');
|
|
151
|
+
}
|
|
152
|
+
// `'open'` is every provider's own default, so asking for it needs no state capability.
|
|
153
|
+
if (criteria.state != null && criteria.state !== 'open' && !supported.states) {
|
|
154
|
+
unsupported.push('state');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (unsupported.length > 0) return { rejection: { reason: 'unsupported-criteria', criteria: unsupported } };
|
|
158
|
+
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The relationships that bound a filtered issue search to the CURRENT USER, and so can stand in for a
|
|
164
|
+
* repository/org scope.
|
|
165
|
+
*
|
|
166
|
+
* Derived from the union rather than spelled out per call site, because the distinction it encodes is the whole
|
|
167
|
+
* reason the scope rule exists: `any-assignee` and `unassigned` are deliberately absent — they describe the
|
|
168
|
+
* ISSUE, not the caller, so neither reduces the search to anyone's own world (measured: unscoped `no:assignee`
|
|
169
|
+
* matches ~45 million issues on GitHub).
|
|
170
|
+
*/
|
|
171
|
+
const userScopingIssueSearchRelationships: readonly IssueSearchRelationship[] = ['authored', 'assigned', 'mentioned'];
|
|
172
|
+
|
|
173
|
+
/** What a provider with NO filtered issue search reports: nothing expressible, spelled out rather than absent. */
|
|
174
|
+
const unsupportedIssueSearchCapabilities: IssueSearchCapabilities = {
|
|
175
|
+
relationships: [],
|
|
176
|
+
text: false,
|
|
177
|
+
labels: false,
|
|
178
|
+
milestone: false,
|
|
179
|
+
updatedAfter: false,
|
|
180
|
+
createdAfter: false,
|
|
181
|
+
withoutLinkedPullRequest: false,
|
|
182
|
+
states: false,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** Why a filtered issue search's scope was refused, or `undefined` when it is usable. */
|
|
186
|
+
export type IssueSearchScopeRejection =
|
|
187
|
+
/** No repositories, no org, and no user-relative relationship: a search of the whole host. */
|
|
188
|
+
| 'unscoped'
|
|
189
|
+
/** Repositories given as ids. A search names repositories by PATH, so ids can't express a scope. */
|
|
190
|
+
| 'repo-ids';
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Validates that a filtered issue search is scoped at all, and narrows `repos` to the descriptor form the
|
|
194
|
+
* provider query needs.
|
|
195
|
+
*
|
|
196
|
+
* Shared by `searchIssuesPage` and `countIssues` because a count computed under different constraints than the
|
|
197
|
+
* read it previews is a WRONG number rather than a missing one. The rejection is returned as a reason code, not a
|
|
198
|
+
* warning: the two callers word it differently (whole-read vs naming the offending scope's key), and wording is
|
|
199
|
+
* the warning layer's business.
|
|
200
|
+
*
|
|
201
|
+
* The two rejections are mutually exclusive — `repo-ids` requires repositories and `unscoped` requires none — so
|
|
202
|
+
* the order they're checked in cannot change the outcome.
|
|
203
|
+
*/
|
|
204
|
+
export function resolveIssueSearchScope(
|
|
205
|
+
repos: ProviderReposInput | undefined,
|
|
206
|
+
org: string | undefined,
|
|
207
|
+
criteria: IssueSearchCriteria | undefined,
|
|
208
|
+
): { rejection?: IssueSearchScopeRejection; repos?: ProviderRepoInput[] } {
|
|
209
|
+
if (repos?.length) {
|
|
210
|
+
// `ProviderReposInput` is a union of descriptor and id arrays; only the descriptor form is usable here.
|
|
211
|
+
if (repos.some(r => typeof r === 'string' || typeof r === 'number')) return { rejection: 'repo-ids' };
|
|
212
|
+
|
|
213
|
+
return { repos: repos as ProviderRepoInput[] };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (org != null && org.length > 0) return {};
|
|
217
|
+
if (criteria?.relationships?.some(r => userScopingIssueSearchRelationships.includes(r)) === true) return {};
|
|
218
|
+
|
|
219
|
+
return { rejection: 'unscoped' };
|
|
220
|
+
}
|
|
221
|
+
|
|
82
222
|
/**
|
|
83
223
|
* The filters `listPullRequestsPage`/`listIssuesPage` (and the sweeps) accept for a provider, so a caller can
|
|
84
224
|
* narrow to what the provider can express BEFORE issuing the read.
|
|
@@ -103,6 +243,11 @@ export function resolveAccountWideIssueFilters(
|
|
|
103
243
|
* {@link IntegrationService.listIssueTrackerIssuesPage} validates against, and leaves `issuesAccountWide`
|
|
104
244
|
* empty. Reading a tracker's capability off `issuesAccountWide` therefore under-reports it.
|
|
105
245
|
*
|
|
246
|
+
* `issueSearch` is a third, wider surface: the FILTERED issue search (`searchIssuesPage`, and the `countIssues`
|
|
247
|
+
* probe over the same criteria), which is not bound to the user at all. It is a record of per-criterion flags
|
|
248
|
+
* rather than a list, because its criteria aren't a single kind. An empty `relationships` means the provider has
|
|
249
|
+
* no filtered issue search — hide the surface, not just its chips.
|
|
250
|
+
*
|
|
106
251
|
* Note this is a CAPABILITY table — "what the provider can express" — not a recommendation. A consumer
|
|
107
252
|
* matching another tool's behavior may deliberately pass fewer filters than are listed here (or none, where an
|
|
108
253
|
* already-scoped read would only be narrowed by them). Intersecting against this table is what keeps a
|
|
@@ -113,12 +258,28 @@ export function getSupportedFilters(providerId: IntegrationIds): {
|
|
|
113
258
|
pullRequestsAccountWide: PullRequestFilter[];
|
|
114
259
|
issues: IssueFilter[];
|
|
115
260
|
issuesAccountWide: IssueFilter[];
|
|
261
|
+
issueSearch: IssueSearchCapabilities;
|
|
116
262
|
} {
|
|
117
263
|
const metadata = providersMetadata[providerId];
|
|
264
|
+
const issueSearch = metadata?.supportedIssueSearch;
|
|
118
265
|
return {
|
|
119
266
|
pullRequests: [...(metadata?.supportedPullRequestFilters ?? [])],
|
|
120
267
|
pullRequestsAccountWide: [...(metadata?.supportedAccountWidePullRequestFilters ?? [])],
|
|
121
268
|
issues: [...(metadata?.supportedIssueFilters ?? [])],
|
|
122
269
|
issuesAccountWide: [...(metadata?.supportedAccountWideIssueFilters ?? [])],
|
|
270
|
+
// Always an object, never `undefined`: a provider WITHOUT a filtered issue search reports one whose
|
|
271
|
+
// `relationships` is empty and whose flags are all false, so a consumer reads capabilities the same way
|
|
272
|
+
// for every provider (and an empty `relationships` is the signal to hide the surface itself).
|
|
273
|
+
//
|
|
274
|
+
// Spread over the all-false baseline rather than defaulting each flag: a criterion added to
|
|
275
|
+
// `IssueSearchCapabilities` then can't be forgotten here and silently reported as `undefined` (which a
|
|
276
|
+
// consumer's `if (caps.x)` would read as unsupported — right answer, wrong reason, and untyped).
|
|
277
|
+
// `supportedIssueSearch` is typed as the complete shape, so no member can arrive as an explicit undefined.
|
|
278
|
+
issueSearch: {
|
|
279
|
+
...unsupportedIssueSearchCapabilities,
|
|
280
|
+
...issueSearch,
|
|
281
|
+
// Copied, so mutating the result can't corrupt the metadata table.
|
|
282
|
+
relationships: [...(issueSearch?.relationships ?? [])],
|
|
283
|
+
},
|
|
123
284
|
};
|
|
124
285
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '../constants.js';
|
|
11
11
|
import type { ListOrgsOptions, ListProjectsOptions } from '../manager.js';
|
|
12
12
|
import { isIssuesIntegration } from '../models/issuesIntegration.js';
|
|
13
|
+
import type { ProviderHierarchyResult } from '../providers/models.js';
|
|
13
14
|
import { toProviderRepositoryShape } from '../providers/models.js';
|
|
14
15
|
import type {
|
|
15
16
|
ProviderOrganization,
|
|
@@ -35,7 +36,46 @@ import {
|
|
|
35
36
|
withProviderContext,
|
|
36
37
|
} from './hierarchy.utils.js';
|
|
37
38
|
import { pageToCursor, refusedPage, resolveContinuation, resolveCurrentPage, toProviderPageInfo } from './paging.js';
|
|
38
|
-
import { gitHostOnlySurfaceWarning, otherWarning } from './warnings.js';
|
|
39
|
+
import { gitHostOnlySurfaceWarning, otherWarning, truncationWarning } from './warnings.js';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Folds a flat hierarchy result's incompleteness into `warnings`, returning whether it leaves the read
|
|
43
|
+
* non-authoritative. The single funnel for both hierarchy reads, so neither can drift from the other on any of
|
|
44
|
+
* the four decisions it makes:
|
|
45
|
+
*
|
|
46
|
+
* - The metadata is assessed FIRST, so the truncation warning can tell whether it already explained this gap.
|
|
47
|
+
* Ordered deliberately: emitting first meant an expired credential produced BOTH a typed `auth` warning and
|
|
48
|
+
* an unclassifiable one for the same cause, and a consumer routing on classification showed the second as
|
|
49
|
+
* "this provider failed to load", with a remedy that doesn't exist, next to the reconnect prompt that was the
|
|
50
|
+
* actual fix.
|
|
51
|
+
* - The read states the truncation itself only when the metadata reported nothing — the rule
|
|
52
|
+
* `assessCollectionMetadata` applies to its own generic fallback. Whatever the metadata reported already names
|
|
53
|
+
* this provider and says something stronger, so restating it costs a false verdict and adds no information.
|
|
54
|
+
* - `'exhausted'`, never `'page-budget'`: `truncated` is one boolean here, so a drain that stopped at its page
|
|
55
|
+
* budget is indistinguishable from one whose cursor stalled, and `IncompleteReadCause` makes `'exhausted'`
|
|
56
|
+
* the default whenever a raisable budget is not demonstrably the cause.
|
|
57
|
+
* - A truncation counts as non-authoritative even though the omission above asserts the read succeeded. Unlike
|
|
58
|
+
* paged repository reads, a flattened hierarchy result has no page object on which to carry incompleteness,
|
|
59
|
+
* so `fetchFailed` is the only signal a consumer has that the list is short.
|
|
60
|
+
*/
|
|
61
|
+
function mergeHierarchyIncompleteness(
|
|
62
|
+
warnings: ProviderWarning[],
|
|
63
|
+
id: IntegrationIds,
|
|
64
|
+
domain: string | undefined,
|
|
65
|
+
connectionId: string | undefined,
|
|
66
|
+
result: Pick<ProviderHierarchyResult<unknown>, 'truncated' | 'metadata'>,
|
|
67
|
+
readKind: 'Organization' | 'Project',
|
|
68
|
+
): boolean {
|
|
69
|
+
const assessment = mergeAssessmentInto(warnings, id, domain, connectionId, result.metadata);
|
|
70
|
+
if (!result.truncated) return assessment.fetchFailed || assessment.truncated;
|
|
71
|
+
|
|
72
|
+
if (!assessment.reported) {
|
|
73
|
+
// Deduped like every other `truncationWarning` emission (see `drains.ts`), not plain-pushed: no caller can
|
|
74
|
+
// collide with it today, but nothing about this funnel guarantees a third read won't.
|
|
75
|
+
appendDedupedWarning(warnings, truncationWarning(id, domain, connectionId, readKind, 'exhausted'));
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
39
79
|
|
|
40
80
|
export async function listOrgs(
|
|
41
81
|
ctx: ProviderReadContext,
|
|
@@ -103,22 +143,8 @@ export async function listOrgs(
|
|
|
103
143
|
);
|
|
104
144
|
if (value != null) {
|
|
105
145
|
items.push(...value.values.map(org => withProviderContext(id, org)));
|
|
106
|
-
if (value.truncated) {
|
|
107
|
-
warnings.push(
|
|
108
|
-
otherWarning(
|
|
109
|
-
id,
|
|
110
|
-
domain,
|
|
111
|
-
connectionId,
|
|
112
|
-
'Organization listing was truncated before the upstream results were exhausted.',
|
|
113
|
-
),
|
|
114
|
-
);
|
|
115
|
-
// `ProviderResult` has no page object on which to carry truncation. Mark the flat
|
|
116
|
-
// hierarchy result incomplete so consumers don't treat omitted orgs as authoritative.
|
|
117
|
-
fetchFailed = true;
|
|
118
|
-
}
|
|
119
146
|
|
|
120
|
-
|
|
121
|
-
if (assessment.fetchFailed || assessment.truncated) {
|
|
147
|
+
if (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, value, 'Organization')) {
|
|
122
148
|
fetchFailed = true;
|
|
123
149
|
}
|
|
124
150
|
}
|
|
@@ -200,22 +226,7 @@ export async function listProjects(
|
|
|
200
226
|
if (projects != null) {
|
|
201
227
|
items.push(...projects.values.map(project => withProviderContext(id, project)));
|
|
202
228
|
|
|
203
|
-
if (projects
|
|
204
|
-
warnings.push(
|
|
205
|
-
otherWarning(
|
|
206
|
-
id,
|
|
207
|
-
domain,
|
|
208
|
-
connectionId,
|
|
209
|
-
'Project listing was truncated before the upstream results were exhausted.',
|
|
210
|
-
),
|
|
211
|
-
);
|
|
212
|
-
// Unlike paged repository reads, this flattened hierarchy result has no continuation
|
|
213
|
-
// or page metadata. `fetchFailed` is its structural non-authoritative signal.
|
|
214
|
-
fetchFailed = true;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const assessment = mergeAssessmentInto(warnings, id, domain, connectionId, projects.metadata);
|
|
218
|
-
if (assessment.fetchFailed || assessment.truncated) {
|
|
229
|
+
if (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, projects, 'Project')) {
|
|
219
230
|
fetchFailed = true;
|
|
220
231
|
}
|
|
221
232
|
}
|
|
@@ -6,7 +6,7 @@ import type { IssueFilter, ProviderReposInput } from '../providers/models.js';
|
|
|
6
6
|
import { PagingMode, providersMetadata } from '../providers/models.js';
|
|
7
7
|
import { mergeCollectionMetadata } from '../providers/utils/providerPaging.js';
|
|
8
8
|
import type { ProviderPagedResult, ProviderWarning } from '../results.js';
|
|
9
|
-
import {
|
|
9
|
+
import { reconcileOmissionsWithFailure } from '../results.js';
|
|
10
10
|
import {
|
|
11
11
|
isGitHostIntegration,
|
|
12
12
|
isIssuesHostIntegrationId,
|
|
@@ -16,6 +16,7 @@ import type { ProviderReadContext } from './context.js';
|
|
|
16
16
|
import { runCaptured } from './drains.js';
|
|
17
17
|
import { resolveAccountWideIssueFilters } from './filters.js';
|
|
18
18
|
import {
|
|
19
|
+
drainFlatPagesToRequestedPage,
|
|
19
20
|
drainToRequestedPage,
|
|
20
21
|
isPageNumberAdvanceable,
|
|
21
22
|
pageToCursor,
|
|
@@ -121,6 +122,11 @@ export async function listIssuesPage(
|
|
|
121
122
|
);
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
// GitHub expresses "any assignee" as `assignee:*`, which is meaningless without a scope: unscoped it
|
|
126
|
+
// matches millions of issues across all of GitHub instead of the user's own world. ANY scope makes it
|
|
127
|
+
// meaningful (one repository, several, or an org) — it is specifically THIS branch, the account-wide read,
|
|
128
|
+
// that has none to offer. Scope the read to repositories (or use `searchIssuesPage`, whose criteria model
|
|
129
|
+
// takes `any-assignee` alongside a `repos`/`org` scope) rather than reading unscoped.
|
|
124
130
|
if (
|
|
125
131
|
options.includeAllAssignees === true &&
|
|
126
132
|
(options.providerId === GitCloudHostIntegrationId.GitHub ||
|
|
@@ -185,51 +191,22 @@ export async function listIssuesPage(
|
|
|
185
191
|
{ warnOnMissingSession: warnOnMissingSession },
|
|
186
192
|
);
|
|
187
193
|
const first = await readAccountWidePage(options.cursor);
|
|
188
|
-
let value = first.value;
|
|
189
194
|
const warnings = first.warning != null ? [first.warning] : [];
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
appendDedupedWarning(warnings, next.warning);
|
|
206
|
-
}
|
|
207
|
-
if (next.value == null) {
|
|
208
|
-
pageFetchFailed = pageFetchFailed || next.warning != null;
|
|
209
|
-
value = undefined;
|
|
210
|
-
requestedPageMissing = true;
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
value = next.value;
|
|
215
|
-
allMetadata = mergeCollectionMetadata(allMetadata, value.metadata);
|
|
216
|
-
currentTruncated = currentTruncated || value.truncated;
|
|
217
|
-
currentPage = value.page ?? currentPage + 1;
|
|
218
|
-
// A provider that hands back the same cursor isn't advancing; stop rather than loop forever.
|
|
219
|
-
if (usableCursor(value.cursor) === nextCursor) {
|
|
220
|
-
currentTruncated = true;
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// A numbered page beyond the provider's terminal cursor is genuinely empty. Never return or
|
|
226
|
-
// relabel the last available page as the requested one.
|
|
227
|
-
if (currentPage < page) {
|
|
228
|
-
requestedPageMissing = true;
|
|
229
|
-
}
|
|
230
|
-
} else if (options.cursor == null && page > 1) {
|
|
231
|
-
requestedPageMissing = true;
|
|
232
|
-
}
|
|
195
|
+
// Merged across the walked pages, so a per-scope failure reported on an earlier page isn't lost by
|
|
196
|
+
// paging past it — the one thing this read accumulates that the filtered search doesn't.
|
|
197
|
+
let allMetadata = first.value?.metadata;
|
|
198
|
+
const drained = await drainFlatPagesToRequestedPage(first, {
|
|
199
|
+
requestedPage: page,
|
|
200
|
+
suppliedCursor: options.cursor,
|
|
201
|
+
warnings: warnings,
|
|
202
|
+
readPage: readAccountWidePage,
|
|
203
|
+
fold: p => {
|
|
204
|
+
allMetadata = mergeCollectionMetadata(allMetadata, p.metadata);
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
const { value, currentPage, requestedPageMissing } = drained;
|
|
208
|
+
const currentTruncated = drained.truncated;
|
|
209
|
+
const pageFetchFailed = drained.fetchFailed;
|
|
233
210
|
|
|
234
211
|
// GitHub, GitLab, and Azure implement an account-wide issue search; a provider that doesn't (Bitbucket
|
|
235
212
|
// exposes no issues at all, and `supportsIssues` already short-circuits it above) returns `undefined`
|
|
@@ -180,6 +180,108 @@ export function resolveCurrentPage(options: {
|
|
|
180
180
|
return options.pageAdvanceable ? options.requestedPage : 1;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* One page of a FLAT cursor-paged provider read — the shape both issue reads' providers return directly.
|
|
185
|
+
*
|
|
186
|
+
* `hasMore` is optional because one of the two providers leaves it off on a terminal page; absent reads as "no
|
|
187
|
+
* more", which is what a provider that reported no continuation means.
|
|
188
|
+
*/
|
|
189
|
+
export interface FlatPage {
|
|
190
|
+
cursor?: string;
|
|
191
|
+
hasMore?: boolean;
|
|
192
|
+
page?: number;
|
|
193
|
+
truncated: boolean;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** What {@link drainFlatPagesToRequestedPage} established by walking. */
|
|
197
|
+
export interface FlatDrainResult<T extends FlatPage> {
|
|
198
|
+
/** The requested page, or `undefined` when a page failed mid-walk (which also sets `fetchFailed`). */
|
|
199
|
+
value: T | undefined;
|
|
200
|
+
/** The position actually reached — 1 when nothing advanced. */
|
|
201
|
+
currentPage: number;
|
|
202
|
+
truncated: boolean;
|
|
203
|
+
/** True when the requested page is past the provider's last one, so it is genuinely EMPTY. */
|
|
204
|
+
requestedPageMissing: boolean;
|
|
205
|
+
fetchFailed: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Walks a FLAT cursor-paged read forward to a requested page number, for a provider whose pages are
|
|
210
|
+
* `{cursor, hasMore, page, truncated}` rather than the SDK's `PagedResult` wrapper.
|
|
211
|
+
*
|
|
212
|
+
* The sibling of {@link drainToRequestedPage}, not a replacement for it: that one normalizes SDK `paging` through
|
|
213
|
+
* {@link toProviderPageInfo}, which retains only cursors whose JSON declares `type`/`cursors` — and the composite
|
|
214
|
+
* cursor of a GitHub aliased search declares neither, so it would be dropped and the walk would never advance.
|
|
215
|
+
* Two shapes genuinely need two entry points; what they must NOT have is two copies of the rules below, which is
|
|
216
|
+
* what this exists to prevent (see this module's own note on drift).
|
|
217
|
+
*
|
|
218
|
+
* The rules, all of them subtle enough to be worth stating once:
|
|
219
|
+
* - The empty-cursor sentinel is filtered, so a provider claiming another page without handing back a usable
|
|
220
|
+
* continuation is not re-read with `'{}'` (which it would answer with page 1 again).
|
|
221
|
+
* - A provider that returns the SAME cursor isn't advancing: stop, and report the read as truncated rather than
|
|
222
|
+
* looping forever or publishing a short page as complete.
|
|
223
|
+
* - A page requested past the provider's terminal cursor is that EMPTY page N — never the last available page
|
|
224
|
+
* relabeled, per {@link ProviderPageInfo.currentPage}.
|
|
225
|
+
* - A page that fails mid-walk latches `fetchFailed` and leaves no value, so the caller can tell "the read broke"
|
|
226
|
+
* from "the page was genuinely empty".
|
|
227
|
+
*
|
|
228
|
+
* `fold` is the one thing the callers differ on — one merges SDK collection metadata across the walked pages, the
|
|
229
|
+
* other keeps the largest reported match count — so it is a callback rather than a branch.
|
|
230
|
+
*/
|
|
231
|
+
export async function drainFlatPagesToRequestedPage<T extends FlatPage>(
|
|
232
|
+
first: { value?: T; warning?: ProviderWarning },
|
|
233
|
+
options: {
|
|
234
|
+
requestedPage: number;
|
|
235
|
+
suppliedCursor: string | undefined;
|
|
236
|
+
warnings: ProviderWarning[];
|
|
237
|
+
readPage: (cursor: string) => Promise<{ value?: T; warning?: ProviderWarning }>;
|
|
238
|
+
fold?: (page: T) => void;
|
|
239
|
+
},
|
|
240
|
+
): Promise<FlatDrainResult<T>> {
|
|
241
|
+
let value = first.value;
|
|
242
|
+
let fetchFailed = first.warning != null && value == null;
|
|
243
|
+
let currentPage = value?.page ?? 1;
|
|
244
|
+
let truncated = value?.truncated ?? false;
|
|
245
|
+
|
|
246
|
+
const walkable = options.suppliedCursor == null && options.requestedPage > 1;
|
|
247
|
+
if (walkable && value != null) {
|
|
248
|
+
for (
|
|
249
|
+
let nextCursor = usableCursor(value.cursor);
|
|
250
|
+
currentPage < options.requestedPage && value.hasMore === true && nextCursor != null;
|
|
251
|
+
nextCursor = usableCursor(value.cursor)
|
|
252
|
+
) {
|
|
253
|
+
const next = await options.readPage(nextCursor);
|
|
254
|
+
if (next.warning != null) {
|
|
255
|
+
appendDedupedWarning(options.warnings, next.warning);
|
|
256
|
+
}
|
|
257
|
+
if (next.value == null) {
|
|
258
|
+
fetchFailed = next.warning != null;
|
|
259
|
+
value = undefined;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
value = next.value;
|
|
264
|
+
truncated = truncated || value.truncated;
|
|
265
|
+
options.fold?.(value);
|
|
266
|
+
currentPage = value.page ?? currentPage + 1;
|
|
267
|
+
if (usableCursor(value.cursor) === nextCursor) {
|
|
268
|
+
truncated = true;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
value: value,
|
|
276
|
+
currentPage: currentPage,
|
|
277
|
+
truncated: truncated,
|
|
278
|
+
// Every case reduces to "a page was asked for by number and the walk fell short", including the one where
|
|
279
|
+
// no walk ran at all because the first page was already terminal.
|
|
280
|
+
requestedPageMissing: walkable && currentPage < options.requestedPage,
|
|
281
|
+
fetchFailed: fetchFailed,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
183
285
|
/** The mutable state {@link drainToRequestedPage} carries across the pages it walks. */
|
|
184
286
|
export interface DrainState<T> {
|
|
185
287
|
items: T[];
|