@gitkraken/core-gitlens 0.5.108 → 0.5.110
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 +49 -1
- package/dist/git/models/issue.d.ts +70 -0
- package/dist/git/models/issue.d.ts.map +1 -1
- package/dist/git/models/issue.js +17 -0
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +81 -0
- package/dist/git/models/pullRequest.d.ts.map +1 -1
- package/dist/git/models/pullRequest.js +15 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/issue.utils.d.ts +41 -1
- package/dist/git/utils/issue.utils.d.ts.map +1 -1
- package/dist/git/utils/issue.utils.js +80 -0
- package/dist/git/utils/issue.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +11 -1
- package/dist/git/utils/pullRequest.utils.d.ts.map +1 -1
- package/dist/git/utils/pullRequest.utils.js +40 -0
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +70 -10
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +284 -31
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueSearchQuery.d.ts +49 -5
- package/dist/plus/git-github/api/issueSearchQuery.d.ts.map +1 -1
- package/dist/plus/git-github/api/issueSearchQuery.js +64 -6
- package/dist/plus/git-github/api/issueSearchQuery.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts +27 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.js +73 -6
- package/dist/plus/git-github/api/pullRequestSearchQuery.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +17 -5
- package/dist/plus/git-github/models.d.ts.map +1 -1
- package/dist/plus/git-github/models.js +14 -1
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.d.ts +18 -0
- package/dist/plus/integrations/collectionMetadata.d.ts.map +1 -1
- package/dist/plus/integrations/collectionMetadata.js +24 -0
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +31 -10
- package/dist/plus/integrations/integrationService.d.ts.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +85 -31
- package/dist/plus/integrations/manager.d.ts.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +18 -31
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +29 -1
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -1
- 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 +63 -1
- package/dist/plus/integrations/models/issueReads.d.ts.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.d.ts +7 -21
- package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providerFilters.d.ts +2 -2
- package/dist/plus/integrations/providerFilters.d.ts.map +1 -1
- package/dist/plus/integrations/providers/accounts.d.ts +6 -0
- package/dist/plus/integrations/providers/accounts.d.ts.map +1 -0
- package/dist/plus/integrations/providers/accounts.js +30 -0
- package/dist/plus/integrations/providers/accounts.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.js +1 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +9 -0
- package/dist/plus/integrations/providers/github.d.ts.map +1 -1
- package/dist/plus/integrations/providers/github.js +115 -135
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.d.ts +9 -0
- package/dist/plus/integrations/providers/gitlab.d.ts.map +1 -1
- package/dist/plus/integrations/providers/gitlab.js +24 -4
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +36 -0
- package/dist/plus/integrations/providers/issueSorts.d.ts.map +1 -0
- package/dist/plus/integrations/providers/issueSorts.js +76 -0
- package/dist/plus/integrations/providers/issueSorts.js.map +1 -0
- package/dist/plus/integrations/providers/jira.d.ts +3 -9
- package/dist/plus/integrations/providers/jira.d.ts.map +1 -1
- package/dist/plus/integrations/providers/jira.js +5 -1
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +24 -9
- package/dist/plus/integrations/providers/linear.d.ts.map +1 -1
- package/dist/plus/integrations/providers/linear.js +63 -5
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +76 -38
- package/dist/plus/integrations/providers/models.d.ts.map +1 -1
- package/dist/plus/integrations/providers/models.js +91 -105
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +18 -3
- package/dist/plus/integrations/providers/providersApi.d.ts.map +1 -1
- package/dist/plus/integrations/providers/providersApi.js +24 -7
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/pullRequestReviews.d.ts +50 -0
- package/dist/plus/integrations/providers/pullRequestReviews.d.ts.map +1 -0
- package/dist/plus/integrations/providers/pullRequestReviews.js +99 -0
- package/dist/plus/integrations/providers/pullRequestReviews.js.map +1 -0
- package/dist/plus/integrations/providers/trello.d.ts +3 -9
- package/dist/plus/integrations/providers/trello.d.ts.map +1 -1
- package/dist/plus/integrations/providers/trello.js +1 -0
- package/dist/plus/integrations/providers/trello.js.map +1 -1
- package/dist/plus/integrations/providers/utils/providerPaging.d.ts.map +1 -1
- package/dist/plus/integrations/providers/utils/providerPaging.js +5 -1
- package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
- package/dist/plus/integrations/reads/broaden.d.ts +6 -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 +63 -1
- package/dist/plus/integrations/reads/counts.d.ts.map +1 -1
- package/dist/plus/integrations/reads/counts.js +146 -2
- package/dist/plus/integrations/reads/counts.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +7 -1
- package/dist/plus/integrations/reads/drains.d.ts.map +1 -1
- package/dist/plus/integrations/reads/drains.js +13 -2
- package/dist/plus/integrations/reads/drains.js.map +1 -1
- package/dist/plus/integrations/reads/filters.d.ts +59 -9
- package/dist/plus/integrations/reads/filters.d.ts.map +1 -1
- package/dist/plus/integrations/reads/filters.js +39 -0
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.d.ts +18 -1
- package/dist/plus/integrations/reads/issueTracker.d.ts.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +40 -3
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts +27 -3
- package/dist/plus/integrations/reads/issues.d.ts.map +1 -1
- package/dist/plus/integrations/reads/issues.js +223 -123
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/ordering.d.ts +101 -0
- package/dist/plus/integrations/reads/ordering.d.ts.map +1 -0
- package/dist/plus/integrations/reads/ordering.js +48 -0
- package/dist/plus/integrations/reads/ordering.js.map +1 -0
- package/dist/plus/integrations/reads/searchIssues.d.ts +7 -2
- package/dist/plus/integrations/reads/searchIssues.d.ts.map +1 -1
- package/dist/plus/integrations/reads/searchIssues.js +9 -3
- package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +4 -3
- package/dist/plus/integrations/reads/searchPullRequests.d.ts.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.js +6 -4
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +1 -1
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +35 -3
- package/dist/plus/integrations/reads/warnings.d.ts.map +1 -1
- package/dist/plus/integrations/reads/warnings.js +58 -4
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +15 -0
- package/dist/plus/integrations/results.d.ts.map +1 -1
- package/dist/plus/integrations/results.js.map +1 -1
- package/docs/integrations.md +76 -10
- package/docs/kepler-read-api-parity.md +9 -0
- package/package.json +2 -2
- package/src/git/models/issue.ts +73 -0
- package/src/git/models/pullRequest.ts +84 -0
- package/src/git/utils/issue.utils.ts +91 -1
- package/src/git/utils/pullRequest.utils.ts +50 -0
- package/src/plus/git-github/api/github.ts +356 -36
- package/src/plus/git-github/api/issueSearchQuery.ts +67 -7
- package/src/plus/git-github/api/pullRequestSearchQuery.ts +81 -7
- package/src/plus/git-github/models.ts +29 -5
- package/src/plus/integrations/collectionMetadata.ts +24 -0
- package/src/plus/integrations/integrationService.ts +40 -12
- package/src/plus/integrations/manager.ts +89 -35
- package/src/plus/integrations/models/gitHostIntegration.ts +47 -31
- package/src/plus/integrations/models/integration.ts +1 -0
- package/src/plus/integrations/models/issueReads.ts +65 -1
- package/src/plus/integrations/models/issuesIntegration.ts +7 -6
- package/src/plus/integrations/providerFilters.ts +8 -1
- package/src/plus/integrations/providers/accounts.ts +34 -0
- package/src/plus/integrations/providers/azureDevOps.ts +1 -0
- package/src/plus/integrations/providers/github.ts +134 -144
- package/src/plus/integrations/providers/gitlab.ts +29 -10
- package/src/plus/integrations/providers/issueSorts.ts +89 -0
- package/src/plus/integrations/providers/jira.ts +9 -3
- package/src/plus/integrations/providers/linear.ts +77 -8
- package/src/plus/integrations/providers/models.ts +185 -128
- package/src/plus/integrations/providers/providersApi.ts +51 -13
- package/src/plus/integrations/providers/pullRequestReviews.ts +122 -0
- package/src/plus/integrations/providers/trello.ts +4 -3
- package/src/plus/integrations/providers/utils/providerPaging.ts +6 -1
- package/src/plus/integrations/reads/broaden.ts +6 -0
- package/src/plus/integrations/reads/counts.ts +281 -3
- package/src/plus/integrations/reads/drains.ts +12 -2
- package/src/plus/integrations/reads/filters.ts +92 -8
- package/src/plus/integrations/reads/issueTracker.ts +78 -4
- package/src/plus/integrations/reads/issues.ts +386 -194
- package/src/plus/integrations/reads/ordering.ts +124 -0
- package/src/plus/integrations/reads/searchIssues.ts +15 -3
- package/src/plus/integrations/reads/searchPullRequests.ts +12 -4
- package/src/plus/integrations/reads/sweeps.ts +1 -1
- package/src/plus/integrations/reads/warnings.ts +84 -2
- package/src/plus/integrations/results.ts +15 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { IssueShape, IssueSorting } from '../../../git/models/issue.js';
|
|
2
|
+
import { defaultIssueSort } from '../../../git/models/issue.js';
|
|
3
|
+
import { getIssueComparator } from '../../../git/utils/issue.utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* How an issue read decides what order to request, and how to order a page it assembled itself.
|
|
7
|
+
*
|
|
8
|
+
* Its own module rather than more of `filters.ts` because it answers a different question. That file validates what
|
|
9
|
+
* a caller asked to NARROW to; this one resolves what a caller asked to ORDER by — and unlike a filter, an order
|
|
10
|
+
* doesn't only have to be expressible by the provider, it also has to survive the read's own merging. Every issue
|
|
11
|
+
* read makes both decisions in the same shape, so they are resolved here once rather than at each read.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Why {@link resolveIssueSort} refused a key, carrying what the refusal has to say — the same shape
|
|
16
|
+
* `IssueSearchCriteriaRejection` uses for the filtered search, and for the same reason.
|
|
17
|
+
*
|
|
18
|
+
* The payload travels WITH the rejection rather than being re-read at the warning: the check already held both
|
|
19
|
+
* values, so handing them back is what lets a caller word the refusal without re-deriving anything TypeScript
|
|
20
|
+
* can no longer narrow (which is how this grew five non-null assertions), and it makes it impossible for the
|
|
21
|
+
* message to name a supported list the check didn't use.
|
|
22
|
+
*/
|
|
23
|
+
export type UnsupportedIssueSortRejection = {
|
|
24
|
+
reason: 'unsupported-sort';
|
|
25
|
+
/** The key the caller asked for. Non-optional, unlike the `sort` a successful resolve returns. */
|
|
26
|
+
requested: IssueSorting;
|
|
27
|
+
/** Every key this surface CAN express, for the message. `undefined` when the read can't be ordered at all. */
|
|
28
|
+
supported: IssueSorting[] | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the order an issue read should request: validates a caller-supplied key against what one provider
|
|
33
|
+
* surface can express server-side, and supplies this facade's default when the caller asked for none.
|
|
34
|
+
*
|
|
35
|
+
* Three outcomes, and each is a decision rather than a convenience:
|
|
36
|
+
* - A key the surface can't express is REJECTED and the read refused whole, never resolved to the nearest
|
|
37
|
+
* supported key. Same reason a dropped filter isn't dropped: the provider serves at most a bounded window of
|
|
38
|
+
* matches, so a list ordered by something else is a DIFFERENT subset than the one asked for, and the cursor that
|
|
39
|
+
* comes with it describes that other subset — indistinguishable, from the result, from the order requested.
|
|
40
|
+
* - An omitted key becomes {@link defaultIssueSort}, because leaving it to the provider is what makes the same
|
|
41
|
+
* read return different things on different hosts (Azure by creation, Jira by nothing at all). The default is
|
|
42
|
+
* this facade's promise; the SDK deliberately has no opinion.
|
|
43
|
+
* - An omitted key on a surface that can't express even the default returns `undefined`, leaving that provider's
|
|
44
|
+
* own order. A default the caller never asked for must not refuse a read that works today.
|
|
45
|
+
*
|
|
46
|
+
* Takes the supported list rather than an `IntegrationIds`, unlike the filter validators, because which list
|
|
47
|
+
* applies is the CALLER's decision — `supportedIssueSorts` for a repo-scoped or tracker read,
|
|
48
|
+
* `supportedAccountWideIssueSorts` for an account-wide one — and that branch already exists at the call site
|
|
49
|
+
* (`repos` present or not). Resolving it in here would duplicate it.
|
|
50
|
+
*/
|
|
51
|
+
export function resolveIssueSort(
|
|
52
|
+
supported: IssueSorting[] | undefined,
|
|
53
|
+
sort: IssueSorting | undefined,
|
|
54
|
+
): { rejection?: UnsupportedIssueSortRejection; sort?: IssueSorting } {
|
|
55
|
+
if (sort == null) {
|
|
56
|
+
return supported?.includes(defaultIssueSort) ? { sort: defaultIssueSort } : {};
|
|
57
|
+
}
|
|
58
|
+
if (!supported?.includes(sort)) {
|
|
59
|
+
return { rejection: { reason: 'unsupported-sort', requested: sort, supported: supported } };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { sort: sort };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Why a merged page can't honor the key it was given: the read fans out over several provider queries and no
|
|
67
|
+
* normalized issue carries the field to merge on.
|
|
68
|
+
*
|
|
69
|
+
* Named for the same reason {@link UnsupportedIssueSortRejection} is, and kept separate from it because the two
|
|
70
|
+
* refusals are different claims: that one says the PROVIDER can't express the key, this one says the provider
|
|
71
|
+
* can but this READ's shape can't — the same key against the same provider succeeds on a single scope.
|
|
72
|
+
*/
|
|
73
|
+
export type UnmergeableIssueSort = {
|
|
74
|
+
/** The key the caller asked for, which a single-scope read of this provider would have honored. */
|
|
75
|
+
requested: IssueSorting;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* What a read does with the order it resolved, once it also knows whether the page it is about to build MERGES
|
|
80
|
+
* several provider queries.
|
|
81
|
+
*
|
|
82
|
+
* Both facts are bound here, at the one point a read knows them, rather than consulted separately at the refusal
|
|
83
|
+
* and again at the sort. That is the difference this type buys: `merged` and the comparator were each tested twice
|
|
84
|
+
* per read, and the two tests are the same decision — whether the requested order survives this page's shape.
|
|
85
|
+
*/
|
|
86
|
+
export type IssueOrdering = {
|
|
87
|
+
/** The key to send to the provider, or `undefined` to leave the provider's own order. */
|
|
88
|
+
readonly sort: IssueSorting | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Set when the requested key cannot be honored: this page merges several queries, and no normalized issue
|
|
91
|
+
* carries the field to merge on. The read refuses rather than serving concatenated per-scope runs, which would
|
|
92
|
+
* look ordered without being so. `undefined` for a single-query page, where the provider did the ordering.
|
|
93
|
+
*
|
|
94
|
+
* Carries the key rather than being a bare flag, for the same reason {@link UnsupportedIssueSortRejection}
|
|
95
|
+
* does: the refusal needs it, and re-reading `sort` at the call site needs an assertion for an invariant this
|
|
96
|
+
* type would otherwise not express.
|
|
97
|
+
*/
|
|
98
|
+
readonly unmergeable: UnmergeableIssueSort | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Orders a merged page. A no-op for a single-query page (the provider already ordered it, and re-sorting could
|
|
101
|
+
* only reproduce that order while hiding a provider that ignored the key) and for a read with no key at all.
|
|
102
|
+
*
|
|
103
|
+
* Returns a new array rather than sorting in place: the input is often the provider's own `values`, and a read
|
|
104
|
+
* that mutates what it was handed is a surprise waiting for the next caller to share that reference.
|
|
105
|
+
*/
|
|
106
|
+
order(items: IssueShape[]): IssueShape[];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Binds a resolved sort key to the shape of the page about to be built.
|
|
111
|
+
*
|
|
112
|
+
* `merged` is the caller's own count of provider queries reduced to the only thing that matters: GitHub sends one
|
|
113
|
+
* search however many repositories are named, GitLab one per repository, Azure and the trackers one per project,
|
|
114
|
+
* and every account-wide read is a union of several. Above one, the union is what gets published, and only a field
|
|
115
|
+
* an {@link IssueShape} carries can order it.
|
|
116
|
+
*/
|
|
117
|
+
export function toIssueOrdering(sort: IssueSorting | undefined, merged: boolean): IssueOrdering {
|
|
118
|
+
const comparator = sort != null ? getIssueComparator(sort) : undefined;
|
|
119
|
+
return {
|
|
120
|
+
sort: sort,
|
|
121
|
+
unmergeable: merged && sort != null && comparator == null ? { requested: sort } : undefined,
|
|
122
|
+
order: (items: IssueShape[]) => (merged && comparator != null ? [...items].sort(comparator) : items),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IssueSearchCriteria, IssueShape } from '../../../git/models/issue.js';
|
|
2
|
+
import { effectiveIssueSort } from '../../../git/utils/issue.utils.js';
|
|
2
3
|
import type { IntegrationIds } from '../constants.js';
|
|
3
4
|
import type { ProviderReposInput } from '../providers/models.js';
|
|
4
5
|
import type { ProviderPagedResult, ProviderWarning } from '../results.js';
|
|
@@ -40,8 +41,13 @@ import {
|
|
|
40
41
|
* for the same reason `broaden.ts`, `sweeps.ts` and `issueTracker.ts` are separate files.
|
|
41
42
|
*
|
|
42
43
|
* Contract details worth knowing before calling:
|
|
43
|
-
* - Ordering is
|
|
44
|
-
*
|
|
44
|
+
* - Ordering is `criteria.sort`, most-recently-updated-first by default, and validated like every other criterion
|
|
45
|
+
* against `getSupportedFilters().issueSearch.sorts`. SOME order is always requested — a "show the N most recent"
|
|
46
|
+
* policy at the provider's result ceiling is only correct under a guaranteed one, and the ceiling warning names
|
|
47
|
+
* the key it selected the window under. A key the provider can't express refuses the read rather than serving a
|
|
48
|
+
* differently-ordered result; do not change it mid-pagination (a cursor is bound to the order it was made under,
|
|
49
|
+
* and threading it under a different key is refused with a warning + `fetchFailed` — drop the cursor and read
|
|
50
|
+
* from the first page instead).
|
|
45
51
|
* - Paging is cursor-only. `page` alone walks 1..N internally (O(N) requests); a page past the last one is an
|
|
46
52
|
* empty page N, never page N−1 relabeled.
|
|
47
53
|
* - At the provider's result ceiling the read SUCCEEDS and reports an omission carrying the total match count,
|
|
@@ -214,7 +220,13 @@ export async function searchIssuesPage(
|
|
|
214
220
|
// warning carrying the total. Anything else truncated (an unusable continuation, a provider that stopped
|
|
215
221
|
// advancing) falls back to the generic wording.
|
|
216
222
|
warnings.push(
|
|
217
|
-
issueSearchCapResultWarning(
|
|
223
|
+
issueSearchCapResultWarning(
|
|
224
|
+
options.providerId,
|
|
225
|
+
domain,
|
|
226
|
+
options.connectionId,
|
|
227
|
+
totalCount,
|
|
228
|
+
effectiveIssueSort(options.criteria?.sort),
|
|
229
|
+
) ??
|
|
218
230
|
truncationWarning(
|
|
219
231
|
options.providerId,
|
|
220
232
|
domain,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PullRequestSearchCriteria, PullRequestShape } from '../../../git/models/pullRequest.js';
|
|
2
|
+
import { defaultPullRequestSort } from '../../../git/models/pullRequest.js';
|
|
2
3
|
import type { IntegrationIds } from '../constants.js';
|
|
3
4
|
import type { ProviderReposInput } from '../providers/models.js';
|
|
4
5
|
import type { ProviderPagedResult, ProviderWarning } from '../results.js';
|
|
@@ -29,9 +30,10 @@ import {
|
|
|
29
30
|
* Pull requests matching structured criteria over a repository/organization or current-user relationship scope.
|
|
30
31
|
*
|
|
31
32
|
* The read is deliberately separate from `listPullRequestsPage`: the list has provider-specific "my PRs"
|
|
32
|
-
* semantics and no text channel, while this method promises a sanitized query,
|
|
33
|
-
*
|
|
34
|
-
* ceiling
|
|
33
|
+
* semantics and no text channel, while this method promises a sanitized query, an ordering the caller chooses
|
|
34
|
+
* (`criteria.sort`, defaulting to most-recently-updated-first) and that is applied to the merged page as a whole,
|
|
35
|
+
* one upstream request per cursor-threaded page, and a quantified omission at the provider's result ceiling that
|
|
36
|
+
* names the order the reachable window was selected under.
|
|
35
37
|
*/
|
|
36
38
|
export async function searchPullRequestsPage(
|
|
37
39
|
ctx: ProviderReadContext,
|
|
@@ -183,7 +185,13 @@ export async function searchPullRequestsPage(
|
|
|
183
185
|
const truncated = continuation.truncated;
|
|
184
186
|
if (truncated && warnings.length === 0) {
|
|
185
187
|
warnings.push(
|
|
186
|
-
pullRequestSearchCapResultWarning(
|
|
188
|
+
pullRequestSearchCapResultWarning(
|
|
189
|
+
options.providerId,
|
|
190
|
+
domain,
|
|
191
|
+
options.connectionId,
|
|
192
|
+
totalCount,
|
|
193
|
+
options.criteria?.sort ?? defaultPullRequestSort,
|
|
194
|
+
) ??
|
|
187
195
|
truncationWarning(options.providerId, domain, options.connectionId, 'Pull request search', 'exhausted'),
|
|
188
196
|
);
|
|
189
197
|
}
|
|
@@ -2,12 +2,15 @@ import type { IntegrationIds } from '../constants.js';
|
|
|
2
2
|
import type {
|
|
3
3
|
IssueFilter,
|
|
4
4
|
IssueSearchCapabilities,
|
|
5
|
+
IssueSorting,
|
|
5
6
|
PullRequestFilter,
|
|
6
7
|
PullRequestSearchCapabilities,
|
|
8
|
+
PullRequestSorting,
|
|
7
9
|
} from '../providerFilters.js';
|
|
8
10
|
import { providersMetadata } from '../providers/models.js';
|
|
9
11
|
import type { ProviderWarning } from '../results.js';
|
|
10
12
|
import type { IssueSearchCriteriaRejection, PullRequestSearchCriteriaRejection } from './filters.js';
|
|
13
|
+
import type { UnmergeableIssueSort, UnsupportedIssueSortRejection } from './ordering.js';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* The warnings the provider facade raises on its OWN terms, as opposed to the ones derived from a caught
|
|
@@ -284,9 +287,13 @@ function describePullRequestSearchCapabilities(capabilities: PullRequestSearchCa
|
|
|
284
287
|
...(capabilities.relationships.length ? [`relationships:${capabilities.relationships.join('|')}`] : []),
|
|
285
288
|
...(capabilities.states.length ? [`states:${capabilities.states.join('|')}`] : []),
|
|
286
289
|
...(capabilities.text ? ['text'] : []),
|
|
290
|
+
...(capabilities.updatedAfter ? ['updatedAfter'] : []),
|
|
291
|
+
...(capabilities.createdAfter ? ['createdAfter'] : []),
|
|
287
292
|
...(capabilities.includeArchived ? ['includeArchived'] : []),
|
|
293
|
+
...(capabilities.draft ? ['draft'] : []),
|
|
288
294
|
...(capabilities.repositoryScope ? ['repository scope'] : []),
|
|
289
295
|
...(capabilities.organizationScope ? ['organization scope'] : []),
|
|
296
|
+
...(capabilities.sorts.length ? [`sorts:${capabilities.sorts.join('|')}`] : []),
|
|
290
297
|
].join(', ');
|
|
291
298
|
}
|
|
292
299
|
|
|
@@ -343,9 +350,71 @@ function describeIssueSearchCapabilities(capabilities: IssueSearchCapabilities):
|
|
|
343
350
|
return [
|
|
344
351
|
...capabilities.relationships.map(r => `relationships:${r}`),
|
|
345
352
|
...flags.filter(([, supported]) => supported).map(([name]) => name),
|
|
353
|
+
...capabilities.sorts.map(s => `sort:${s}`),
|
|
346
354
|
].join(', ');
|
|
347
355
|
}
|
|
348
356
|
|
|
357
|
+
/**
|
|
358
|
+
* Warning for an issue read asked to order by a key its provider can't express server-side.
|
|
359
|
+
*
|
|
360
|
+
* Separate from {@link unsupportedIssueSearchCriteriaWarning} because it serves the reads that take `sort` as an
|
|
361
|
+
* OPTION rather than as a criterion — repo-scoped, account-wide, and issue-tracker — where there is no criteria
|
|
362
|
+
* set to fold it into. The filtered search keeps reporting it as one more `unsupported-criteria` entry, so a
|
|
363
|
+
* caller there still gets a single refusal listing everything at once.
|
|
364
|
+
*
|
|
365
|
+
* Takes the rejection the check produced rather than a re-read supported list: which of the two tables applies is
|
|
366
|
+
* the caller's own branch (`repos` present or not), so reading it back here — or threading it by hand — would be
|
|
367
|
+
* free to disagree with the check that refused.
|
|
368
|
+
*/
|
|
369
|
+
export function unsupportedIssueSortWarning(
|
|
370
|
+
id: IntegrationIds,
|
|
371
|
+
domain: string | undefined,
|
|
372
|
+
connectionId: string | undefined,
|
|
373
|
+
rejection: UnsupportedIssueSortRejection,
|
|
374
|
+
): ProviderWarning {
|
|
375
|
+
return otherWarning(
|
|
376
|
+
id,
|
|
377
|
+
domain,
|
|
378
|
+
connectionId,
|
|
379
|
+
unsupportedNarrowingMessage(id, 'issue sort', rejection.requested, (rejection.supported ?? []).join(', ')),
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Warning for a merged issue read asked to order by a key that no normalized issue carries.
|
|
385
|
+
*
|
|
386
|
+
* The distinction this exists to make is not about the provider: the provider orders by `priority` perfectly well
|
|
387
|
+
* within ONE project. It is about the read, which fans out over several and merges the results here, where the
|
|
388
|
+
* only fields available are the ones {@link IssueShape} models. Serving the concatenated per-scope runs would look
|
|
389
|
+
* ordered without being so, which is why this refuses instead — and why the message says WHY, since the same key
|
|
390
|
+
* against the same provider succeeds on a single-scope read.
|
|
391
|
+
*
|
|
392
|
+
* What a read fans out OVER differs by read, hence the `scope`: repositories, projects, or — where one query is
|
|
393
|
+
* issued per requested relationship and the runs are unioned within a single project (Jira) — the filters
|
|
394
|
+
* themselves. Naming the wrong one would tell a caller to narrow something that isn't what merged.
|
|
395
|
+
*/
|
|
396
|
+
export function unmergeableIssueSortWarning(
|
|
397
|
+
id: IntegrationIds,
|
|
398
|
+
domain: string | undefined,
|
|
399
|
+
connectionId: string | undefined,
|
|
400
|
+
unmergeable: UnmergeableIssueSort,
|
|
401
|
+
scope: 'repositories' | 'projects' | 'filters',
|
|
402
|
+
): ProviderWarning {
|
|
403
|
+
// Both forms are spelled out rather than depluralized at runtime: the message needs each, and
|
|
404
|
+
// `'repositories'.replace(/s$/, '')` is `'repositorie'`.
|
|
405
|
+
const nouns = {
|
|
406
|
+
repositories: { many: 'repositories', one: 'repository' },
|
|
407
|
+
projects: { many: 'projects', one: 'project' },
|
|
408
|
+
filters: { many: 'issue relationships', one: 'relationship' },
|
|
409
|
+
}[scope];
|
|
410
|
+
return otherWarning(
|
|
411
|
+
id,
|
|
412
|
+
domain,
|
|
413
|
+
connectionId,
|
|
414
|
+
`Cannot order by '${unmergeable.requested}' across several ${nouns.many}: this read merges their results, and a normalized issue carries no such field to merge on. Read one ${nouns.one} at a time, or order by a date, title, comment or reaction count.`,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
349
418
|
/**
|
|
350
419
|
* The omission for a filtered issue search that hit the provider's RESULT CEILING: more issues matched than the
|
|
351
420
|
* provider will ever serve for one query, however it is paged.
|
|
@@ -356,6 +425,10 @@ function describeIssueSearchCapabilities(capabilities: IssueSearchCapabilities):
|
|
|
356
425
|
* 'none'` because the items past the ceiling are UNREACHABLE, not merely unfetched: no budget, no retry, and no
|
|
357
426
|
* cursor would return them. Narrowing the criteria is the only way through, which is a decision for the caller.
|
|
358
427
|
*
|
|
428
|
+
* The message names the ORDER, and has to now that ordering is an option: the reachable window is the top `limit`
|
|
429
|
+
* under that key, so "the 1.000 most recent" is a true sentence only while the key is the default one. The same
|
|
430
|
+
* value goes on the omission, so a consumer wording its own sentence doesn't have to remember what it asked for.
|
|
431
|
+
*
|
|
359
432
|
* Returns `undefined` when the provider declares no ceiling, so the caller falls back to the generic wording
|
|
360
433
|
* rather than reporting a limit it invented.
|
|
361
434
|
*/
|
|
@@ -364,18 +437,20 @@ export function issueSearchCapResultWarning(
|
|
|
364
437
|
domain: string | undefined,
|
|
365
438
|
connectionId: string | undefined,
|
|
366
439
|
totalCount: number | undefined,
|
|
440
|
+
sort: IssueSorting,
|
|
367
441
|
): ProviderWarning | undefined {
|
|
368
442
|
const limit = providersMetadata[id]?.issueSearchResultLimit;
|
|
369
443
|
if (limit == null) return undefined;
|
|
370
444
|
// Below the ceiling this warning would be a false claim; the caller's truncation had another cause.
|
|
371
445
|
if (totalCount == null || totalCount <= limit) return undefined;
|
|
372
446
|
|
|
447
|
+
const [field, direction] = sort.split(':');
|
|
373
448
|
return {
|
|
374
449
|
...otherWarning(
|
|
375
450
|
id,
|
|
376
451
|
domain,
|
|
377
452
|
connectionId,
|
|
378
|
-
`Issue search matched ${totalCount} results, but '${id}' serves at most ${limit}; narrow the search to read the rest.`,
|
|
453
|
+
`Issue search matched ${totalCount} results, but '${id}' serves at most ${limit}, ordered by ${field} ${direction}ending; narrow the search to read the rest.`,
|
|
379
454
|
),
|
|
380
455
|
omission: {
|
|
381
456
|
kind: 'provider-limit',
|
|
@@ -383,6 +458,7 @@ export function issueSearchCapResultWarning(
|
|
|
383
458
|
recovery: 'none',
|
|
384
459
|
limit: limit,
|
|
385
460
|
totalCount: totalCount,
|
|
461
|
+
sort: sort,
|
|
386
462
|
},
|
|
387
463
|
};
|
|
388
464
|
}
|
|
@@ -393,22 +469,28 @@ export function pullRequestSearchCapResultWarning(
|
|
|
393
469
|
domain: string | undefined,
|
|
394
470
|
connectionId: string | undefined,
|
|
395
471
|
totalCount: number | undefined,
|
|
472
|
+
sort: PullRequestSorting,
|
|
396
473
|
): ProviderWarning | undefined {
|
|
397
474
|
const limit = providersMetadata[id]?.pullRequestSearchResultLimit;
|
|
398
475
|
if (limit == null || totalCount == null || totalCount <= limit) return undefined;
|
|
399
476
|
|
|
477
|
+
// Name the order: the reachable window is the first `limit` under THIS sort, and a different key reaches a
|
|
478
|
+
// different subset, so a ceiling message that omits it can't say which slice was served. Same reasoning as
|
|
479
|
+
// `issueSearchCapResultWarning`.
|
|
480
|
+
const [field, direction] = sort.split(':');
|
|
400
481
|
return {
|
|
401
482
|
...otherWarning(
|
|
402
483
|
id,
|
|
403
484
|
domain,
|
|
404
485
|
connectionId,
|
|
405
|
-
`Pull request search matched ${totalCount} results, but '${id}' serves at most ${limit}; narrow the search to read the rest.`,
|
|
486
|
+
`Pull request search matched ${totalCount} results, but '${id}' serves at most ${limit}, ordered by ${field} ${direction}ending; narrow the search to read the rest.`,
|
|
406
487
|
),
|
|
407
488
|
omission: {
|
|
408
489
|
kind: 'provider-limit',
|
|
409
490
|
recovery: 'none',
|
|
410
491
|
limit: limit,
|
|
411
492
|
totalCount: totalCount,
|
|
493
|
+
sort: sort,
|
|
412
494
|
},
|
|
413
495
|
};
|
|
414
496
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AuthenticationError, RequestNotFoundError, RequestRateLimitError } from '../../git/errors.js';
|
|
2
|
+
import type { IssueSorting } from '../../git/models/issue.js';
|
|
3
|
+
import type { PullRequestSorting } from '../../git/models/pullRequest.js';
|
|
2
4
|
import type { IntegrationIds } from './constants.js';
|
|
3
5
|
|
|
4
6
|
export interface ConnectionStateChangeEvent {
|
|
@@ -77,6 +79,19 @@ export interface ProviderWarningOmission {
|
|
|
77
79
|
limit?: number;
|
|
78
80
|
/** Total matches the provider reported, when it reports one. Only GitHub's search cap does today. */
|
|
79
81
|
totalCount?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The order the reachable window was selected under, as `field:direction`, when the omission is a result
|
|
84
|
+
* ceiling.
|
|
85
|
+
*
|
|
86
|
+
* Present so a consumer can word its own "N matched, showing the first M" without assuming WHICH M: the
|
|
87
|
+
* provider serves the top M under this key, so the sentence is only true if it names it. Absent for every
|
|
88
|
+
* omission that isn't a ceiling, where no window was selected by an order.
|
|
89
|
+
*
|
|
90
|
+
* A union of both vocabularies rather than the issue one alone: `PullRequestSorting` happens to be a subset
|
|
91
|
+
* today, so narrowing this to {@link IssueSorting} would still compile while describing only half the reads
|
|
92
|
+
* that set it — and would break the day the PR search gains a key the issue search has no name for.
|
|
93
|
+
*/
|
|
94
|
+
sort?: IssueSorting | PullRequestSorting;
|
|
80
95
|
/** Which repository / project / resource was affected, when one is attributed. */
|
|
81
96
|
scope?: ProviderWarningOmissionScope;
|
|
82
97
|
}
|