@gitkraken/core-gitlens 0.54.0 → 0.56.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.
- package/CHANGELOG.md +21 -1
- package/dist/git/cache.js +3 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +14 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -1
- package/dist/git/utils/pullRequest.utils.js +9 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +2 -0
- package/dist/git-cli/providers/pausedOperations.js +104 -40
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +2 -0
- package/dist/plus/git-github/api/github.js +16 -6
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts +1 -0
- package/dist/plus/git-github/api/pullRequestSearchQuery.js +29 -5
- package/dist/plus/git-github/api/pullRequestSearchQuery.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +3 -0
- package/dist/plus/integrations/fieldPresence.js +7 -1
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +11 -2
- package/dist/plus/integrations/integrationService.js +75 -3
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +17 -2
- package/dist/plus/integrations/models/bitbucketPullRequestWrites.d.ts +217 -0
- package/dist/plus/integrations/models/bitbucketPullRequestWrites.js +0 -0
- package/dist/plus/integrations/models/integration.d.ts +2 -1
- package/dist/plus/integrations/models/integration.js +6 -0
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
- package/dist/plus/integrations/models/pullRequestReads.d.ts +2 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.d.ts +0 -3
- package/dist/plus/integrations/providers/azure/writeIdentity.js +4 -12
- package/dist/plus/integrations/providers/azure/writeIdentity.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +0 -2
- package/dist/plus/integrations/providers/azureDevOps.js +1 -7
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWrites.js +24 -26
- package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +4 -3
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +22 -21
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +4 -0
- package/dist/plus/integrations/providers/bitbucket.js +8 -0
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.d.ts +13 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js +88 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.d.ts +14 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js +36 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.d.ts +47 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js +795 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js.map +1 -0
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/metadata.js +6 -3
- package/dist/plus/integrations/providers/metadata.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -0
- package/dist/plus/integrations/providers/providersApi.js +5 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils/writeInputs.d.ts +7 -0
- package/dist/plus/integrations/providers/utils/writeInputs.js +17 -0
- package/dist/plus/integrations/providers/utils/writeInputs.js.map +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/filters.js +13 -1
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +3 -3
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +3 -3
- package/dist/plus/integrations/reads/searchPullRequests.js +4 -3
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +20 -6
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +1 -0
- package/dist/plus/integrations/reads/warnings.js +7 -2
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +7 -0
- package/dist/plus/integrations/results.js.map +1 -1
- package/docs/integrations.md +188 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region ../plus/integrations/src/providers/utils/writeInputs.d.ts
|
|
2
|
+
export declare function isWriteIdentifier(value: unknown): value is string;
|
|
3
|
+
export declare function isPositiveInt32(value: unknown): value is number;
|
|
4
|
+
export declare function sameIdentifier(actual: unknown, expected: string): boolean;
|
|
5
|
+
export declare function isCommitSha(sha: unknown): sha is string;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=writeInputs.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../plus/integrations/src/providers/utils/writeInputs.ts
|
|
2
|
+
function isWriteIdentifier(value) {
|
|
3
|
+
return typeof value === "string" && value.length > 0 && value.trim() === value && ![...value].some((character) => character < " " || character === "");
|
|
4
|
+
}
|
|
5
|
+
function isPositiveInt32(value) {
|
|
6
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 2147483647;
|
|
7
|
+
}
|
|
8
|
+
function sameIdentifier(actual, expected) {
|
|
9
|
+
return typeof actual === "string" && actual.toLowerCase() === expected.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function isCommitSha(sha) {
|
|
12
|
+
return typeof sha === "string" && /^(?!0{40}$)[\da-f]{40}$/i.test(sha);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { isCommitSha, isPositiveInt32, isWriteIdentifier, sameIdentifier };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=writeInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeInputs.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/writeInputs.ts"],"sourcesContent":["export function isWriteIdentifier(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\tvalue.trim() === value &&\n\t\t![...value].some(character => character < ' ' || character === '\\x7f')\n\t);\n}\n\nexport function isPositiveInt32(value: unknown): value is number {\n\treturn typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 2147483647;\n}\n\nexport function sameIdentifier(actual: unknown, expected: string): boolean {\n\treturn typeof actual === 'string' && actual.toLowerCase() === expected.toLowerCase();\n}\n\nexport function isCommitSha(sha: unknown): sha is string {\n\treturn typeof sha === 'string' && /^(?!0{40}$)[\\da-f]{40}$/i.test(sha);\n}\n"],"mappings":";AAAA,SAAgB,kBAAkB,OAAiC;CAClE,OACC,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,KAAK,MAAM,SACjB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAK,cAAa,YAAY,OAAO,cAAc,GAAM;AAEvE;AAEA,SAAgB,gBAAgB,OAAiC;CAChE,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,SAAS;AACtF;AAEA,SAAgB,eAAe,QAAiB,UAA2B;CAC1E,OAAO,OAAO,WAAW,YAAY,OAAO,YAAY,MAAM,SAAS,YAAY;AACpF;AAEA,SAAgB,YAAY,KAA6B;CACxD,OAAO,OAAO,QAAQ,YAAY,2BAA2B,KAAK,GAAG;AACtE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourceDescriptor } from "../../../git/models/resourceDescriptor.js";
|
|
2
2
|
import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
|
|
3
3
|
import { IntegrationIds } from "../constants.js";
|
|
4
|
+
import "../providerFilters.js";
|
|
4
5
|
import { ProviderWarning } from "../results.js";
|
|
5
6
|
import { ProviderSweepTarget, PullRequestSweepOptions } from "../manager.js";
|
|
6
7
|
import { IntegrationResult } from "../models/publicIntegration.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isValidPullRequestChangedSince } from "../../../git/utils/pullRequest.utils.js";
|
|
1
2
|
import { providersMetadata } from "../providers/metadata.js";
|
|
2
3
|
//#region ../plus/integrations/src/reads/filters.ts
|
|
3
4
|
/**
|
|
@@ -50,11 +51,21 @@ function resolvePullRequestSearchCriteria(id, criteria) {
|
|
|
50
51
|
if (criteria.includeArchived === true && !supported.includeArchived) unsupported.push("includeArchived");
|
|
51
52
|
if (criteria.draft != null && !supported.draft) unsupported.push("draft");
|
|
52
53
|
if (criteria.sort != null && !supported.sorts.includes(criteria.sort)) unsupported.push(`sort:${criteria.sort}`);
|
|
54
|
+
if (criteria.changedSince != null) unsupported.push(...unsupportedChangedSinceCriteria(criteria, criteria.changedSince, supported.changedSince));
|
|
53
55
|
return unsupported.length > 0 ? { rejection: {
|
|
54
56
|
reason: "unsupported-criteria",
|
|
55
57
|
criteria: unsupported
|
|
56
58
|
} } : {};
|
|
57
59
|
}
|
|
60
|
+
function unsupportedChangedSinceCriteria(criteria, changedSince, supported) {
|
|
61
|
+
if (!supported) return ["changedSince"];
|
|
62
|
+
const unsupported = [];
|
|
63
|
+
if (!isValidPullRequestChangedSince(changedSince)) unsupported.push(`changedSince:${JSON.stringify(changedSince)} (expected YYYY-MM-DDTHH:MM:SSZ)`);
|
|
64
|
+
for (const state of criteria.states ?? []) if (state !== "all") unsupported.push(`changedSince with states:${state}`);
|
|
65
|
+
if (criteria.sort != null && criteria.sort !== "updated:asc") unsupported.push(`changedSince with sort:${criteria.sort}`);
|
|
66
|
+
if (new Set(criteria.relationships).size > 1) unsupported.push("changedSince with several relationships");
|
|
67
|
+
return unsupported;
|
|
68
|
+
}
|
|
58
69
|
/**
|
|
59
70
|
* Validates the search boundary independently from its criteria. A current-user relationship is itself a safe
|
|
60
71
|
* account-wide boundary; without one, a repository or organization scope is mandatory.
|
|
@@ -185,7 +196,8 @@ const unsupportedPullRequestSearchCapabilities = {
|
|
|
185
196
|
draft: false,
|
|
186
197
|
repositoryScope: false,
|
|
187
198
|
organizationScope: false,
|
|
188
|
-
sorts: []
|
|
199
|
+
sorts: [],
|
|
200
|
+
changedSince: false
|
|
189
201
|
};
|
|
190
202
|
/**
|
|
191
203
|
* Whether a scope name reaches the provider NAMING THE SAME SCOPE — the one rule behind every `unusable-scope`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","names":[],"sources":["../../../../../plus/integrations/src/reads/filters.ts"],"sourcesContent":["import type { IntegrationIds } from '../constants.js';\nimport type {\n\tIssueFilter,\n\tIssueSearchCapabilities,\n\tIssueSearchCriteria,\n\tIssueSearchRelationship,\n\tPullRequestFilter,\n\tPullRequestSearchCapabilities,\n\tPullRequestSearchCriteria,\n\tSupportedFilters,\n} from '../providerFilters.js';\nimport { providersMetadata } from '../providers/metadata.js';\nimport type { ProviderRepoInput, ProviderReposInput } from '../providers/models.js';\n\n/**\n * Validation of a caller-supplied relationship filter set against what a provider can express server-side.\n *\n * Every one of these is ALL-OR-NOTHING, and deliberately so: dropping the members a provider can't express\n * would silently widen the read past what was asked for (requesting Author+Mention on a host without Mention\n * would return every authored item rather than the requested set), and narrowing the returned page afterward\n * would leave `items` describing a different result set than the `hasMore`/`cursor` the provider produced with\n * it. So an inexpressible set is refused whole, and the caller surfaces a warning instead of reading unfiltered.\n *\n * The three differ only in WHICH capability they check, because they govern three different provider queries —\n * see `IntegrationManager.getSupportedFilters`, which exposes the same capability table so a consumer can\n * intersect against it and never reach a refusal.\n */\nexport interface ResolvedFilters<T> {\n\tfilters?: T[];\n\tunsupported: boolean;\n}\n\n/**\n * Validates a repo-scoped PR filter set, so an unsupported filter never trips the read core's \"Unsupported\n * filters\" guard. `unsupported: true` when the caller DID request filters and the provider can't express even\n * ONE of them — the exact negation of the read core's `providerSupportsPullRequestFilters` (`every`), so this\n * can only ever pre-empt that guard, never disagree with it.\n *\n * Returns `{ filters }` (possibly undefined when none were requested — an unfiltered read is intended). Genuine\n * \"my pull requests\" self-scoping is delivered by the account-wide path\n * (`GitHostIntegration.getMyPullRequestsForUserResult`); this only governs the optional repo-scoped narrowing.\n */\nexport function resolvePullRequestFilters(\n\tid: IntegrationIds,\n\tfilters: PullRequestFilter[] | undefined,\n): ResolvedFilters<PullRequestFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedPullRequestFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: filters, unsupported: false };\n}\n\n/**\n * Validates an account-wide PR relationship union independently from the repo-scoped capability. Dropping an\n * unsupported member would change the requested OR set, so validation is all-or-nothing.\n */\nexport function resolveAccountWidePullRequestFilters(\n\tid: IntegrationIds,\n\tfilters: PullRequestFilter[] | undefined,\n): ResolvedFilters<PullRequestFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedAccountWidePullRequestFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: [...new Set(filters)], unsupported: false };\n}\n\n/** Why {@link resolvePullRequestSearchCriteria} refused a criteria set. */\nexport type PullRequestSearchCriteriaRejection =\n\t/** The provider has no filtered pull-request search. */\n\t| { reason: 'unsupported-search' }\n\t/** The provider has one, but cannot express every requested criterion server-side. */\n\t| { reason: 'unsupported-criteria'; criteria: string[] };\n\n/**\n * Validates filtered pull-request search criteria all-or-nothing. Dropping an unsupported criterion would\n * widen the provider query while leaving its page and cursor describing the wider set, so the facade refuses the\n * request before any upstream call instead.\n */\nexport function resolvePullRequestSearchCriteria(\n\tid: IntegrationIds,\n\tcriteria: PullRequestSearchCriteria | undefined,\n): { rejection?: PullRequestSearchCriteriaRejection } {\n\tconst supported = providersMetadata[id]?.supportedPullRequestSearch;\n\tif (supported == null || supported.relationships.length === 0) {\n\t\treturn { rejection: { reason: 'unsupported-search' } };\n\t}\n\tif (criteria == null) return {};\n\n\tconst unsupported: string[] = [];\n\tfor (const relationship of criteria.relationships ?? []) {\n\t\tif (!supported.relationships.includes(relationship)) {\n\t\t\tunsupported.push(`relationships:${relationship}`);\n\t\t}\n\t}\n\tfor (const state of criteria.states ?? []) {\n\t\tif (!supported.states.includes(state)) {\n\t\t\tunsupported.push(`states:${state}`);\n\t\t}\n\t}\n\tif (criteria.text != null && criteria.text.trim().length > 0 && !supported.text) {\n\t\tunsupported.push('text');\n\t}\n\tif (criteria.updatedAfter != null && !supported.updatedAfter) {\n\t\tunsupported.push('updatedAfter');\n\t}\n\tif (criteria.createdAfter != null && !supported.createdAfter) {\n\t\tunsupported.push('createdAfter');\n\t}\n\tif (criteria.includeArchived === true && !supported.includeArchived) {\n\t\tunsupported.push('includeArchived');\n\t}\n\t// `!= null`, not truthy: `draft: false` (only ready-for-review) is as much a request as `draft: true`.\n\tif (criteria.draft != null && !supported.draft) {\n\t\tunsupported.push('draft');\n\t}\n\t// Folded into the same `unsupported-criteria` rejection rather than its own reason, so a caller asking for one\n\t// inexpressible filter and one inexpressible sort learns about both at once. `updated:desc` is always in\n\t// `sorts` for a usable search, so the omitted (default) case never rejects.\n\tif (criteria.sort != null && !supported.sorts.includes(criteria.sort)) {\n\t\tunsupported.push(`sort:${criteria.sort}`);\n\t}\n\n\treturn unsupported.length > 0 ? { rejection: { reason: 'unsupported-criteria', criteria: unsupported } } : {};\n}\n\n/** Why a filtered pull-request search's repository/organization boundary was refused. */\nexport type PullRequestSearchScopeRejection =\n\t| { reason: 'unscoped' }\n\t| { reason: 'repo-ids' }\n\t| { reason: 'unsupported-repository-scope' }\n\t| { reason: 'unsupported-organization-scope' }\n\t/** Scope names a query cannot carry AS GIVEN; see {@link unusableSearchScopeNames}. */\n\t| { reason: 'unusable-scope'; scopes: string[] };\n\n/**\n * Validates the search boundary independently from its criteria. A current-user relationship is itself a safe\n * account-wide boundary; without one, a repository or organization scope is mandatory.\n *\n * Scope names go through the same {@link unusableSearchScopeNames} rule the issue search uses — shared rather\n * than re-derived, because the defect is identical on both reads.\n */\nexport function resolvePullRequestSearchScope(\n\tid: IntegrationIds,\n\trepos: ProviderReposInput | undefined,\n\torg: string | undefined,\n\tcriteria: PullRequestSearchCriteria | undefined,\n): { rejection?: PullRequestSearchScopeRejection; repos?: ProviderRepoInput[] } {\n\tconst supported = providersMetadata[id]?.supportedPullRequestSearch;\n\tlet resolvedRepos: ProviderRepoInput[] | undefined;\n\n\tif (repos?.length) {\n\t\tif (repos.some(r => typeof r === 'string' || typeof r === 'number')) {\n\t\t\treturn { rejection: { reason: 'repo-ids' } };\n\t\t}\n\t\tif (supported?.repositoryScope !== true) return { rejection: { reason: 'unsupported-repository-scope' } };\n\n\t\tresolvedRepos = repos as ProviderRepoInput[];\n\t}\n\n\tconst hasOrganizationScope = org != null && org.length > 0;\n\tif (hasOrganizationScope && supported?.organizationScope !== true) {\n\t\treturn { rejection: { reason: 'unsupported-organization-scope' } };\n\t}\n\n\t// After the capability checks and before the \"is it scoped at all\" rule: a scope the provider cannot express\n\t// at all is the more fundamental refusal, and an unusable value that WAS supplied must not be reported as a\n\t// missing one. `org` is passed bare, matching the issue twin — the helper applies its own empty-means-\n\t// unsupplied guard, so re-testing `hasOrganizationScope` here would only make the two resolvers look like\n\t// they differ.\n\tconst unusable = unusableSearchScopeNames(id, org, resolvedRepos);\n\tif (unusable.length > 0) return { rejection: { reason: 'unusable-scope', scopes: unusable } };\n\n\tif (resolvedRepos != null || hasOrganizationScope || (criteria?.relationships?.length ?? 0) > 0) {\n\t\treturn { repos: resolvedRepos };\n\t}\n\n\treturn { rejection: { reason: 'unscoped' } };\n}\n\n/**\n * Validates a caller-provided issue filter set against what the provider's ACCOUNT-WIDE issue read can express\n * server-side (`ProviderMetadata.supportedAccountWideIssueFilters`), which is a different — usually narrower —\n * set than the repo-scoped `ProviderMetadata.supportedIssueFilters`.\n *\n * Dropping the unexpressible members would silently widen the read back toward the provider's own union\n * (authored ∪ assigned ∪ mentioned for GitHub), which is the opposite of what a caller narrowing to\n * `[Assignee]` asked for.\n */\nexport function resolveAccountWideIssueFilters(\n\tid: IntegrationIds,\n\tfilters: IssueFilter[] | undefined,\n): ResolvedFilters<IssueFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedAccountWideIssueFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: filters, unsupported: false };\n}\n\n/** Why {@link resolveIssueSearchCriteria} refused a criteria set, so the caller can word the refusal exactly. */\nexport type IssueSearchCriteriaRejection =\n\t/** The provider has no filtered issue search at all. */\n\t| { reason: 'unsupported-search' }\n\t/** The provider has one, but can't express these criteria server-side. */\n\t| { reason: 'unsupported-criteria'; criteria: string[] }\n\t/** `any-assignee` and `unassigned` partition the scope between them; asking for both asks for nothing. */\n\t| { reason: 'contradictory-relationships' };\n\n/**\n * Whether a provider exposes the FILTERED issue search at all — the one predicate a caller can check BEFORE\n * building criteria, so a read that would only be refused is never issued.\n *\n * The same test {@link resolveIssueSearchCriteria} makes for its `unsupported-search` rejection, named rather\n * than re-derived at each call site: a caller writing `supportedIssueSearch != null` itself is a copy free to\n * disagree with the validator about what \"has a search\" means. `broadenIssues` reads it to pick its engine —\n * the org-scoped search where there is one, the repository drain where there isn't — which is a CHOICE rather\n * than a refusal, so it needs the predicate without the rejection.\n */\nexport function supportsFilteredIssueSearch(id: IntegrationIds): boolean {\n\treturn providersMetadata[id]?.supportedIssueSearch != null;\n}\n\n/**\n * Validates a filtered issue search's criteria against {@link ProviderMetadata.supportedIssueSearch}.\n *\n * All-or-nothing like its three siblings above, and for the same reason: a criterion dropped because the\n * provider can't express it would serve a WIDER result than was asked for, and narrowing the returned page\n * afterward would leave `items` describing a different result set than the `hasMore`/`cursor` the provider\n * produced with it. So an inexpressible set is refused whole and the caller surfaces a warning.\n *\n * Unlike the sibling validators this also rejects a set that is internally contradictory, because this criteria\n * model is the only one with two members that partition the scope between them (`any-assignee` ∪ `unassigned` =\n * everything, ∩ = nothing). Silently keeping one would answer a question the caller didn't ask.\n *\n * `undefined` (or an empty relationship list plus no other criterion) is a valid UNNARROWED search of the given\n * scope, not an error — the caller's `repos`/`org` is what bounds it.\n */\nexport function resolveIssueSearchCriteria(\n\tid: IntegrationIds,\n\tcriteria: IssueSearchCriteria | undefined,\n): { rejection?: IssueSearchCriteriaRejection } {\n\tconst supported = providersMetadata[id]?.supportedIssueSearch;\n\tif (supported == null) return { rejection: { reason: 'unsupported-search' } };\n\tif (criteria == null) return {};\n\n\tconst relationships = criteria.relationships;\n\tif (relationships?.includes('any-assignee') && relationships.includes('unassigned')) {\n\t\treturn { rejection: { reason: 'contradictory-relationships' } };\n\t}\n\n\tconst unsupported: string[] = [];\n\tfor (const relationship of relationships ?? []) {\n\t\tif (!supported.relationships.includes(relationship)) {\n\t\t\tunsupported.push(`relationships:${relationship}`);\n\t\t}\n\t}\n\t// Only a criterion the caller actually SET can be unsupported. `false`/empty means \"don't narrow on this\",\n\t// which every provider can honor by doing nothing, so it must not be validated as a request.\n\tif (criteria.text != null && criteria.text.trim().length > 0 && !supported.text) {\n\t\tunsupported.push('text');\n\t}\n\tif (criteria.labels?.length && !supported.labels) {\n\t\tunsupported.push('labels');\n\t}\n\tif (criteria.milestone != null && !supported.milestone) {\n\t\tunsupported.push('milestone');\n\t}\n\tif (criteria.updatedAfter != null && !supported.updatedAfter) {\n\t\tunsupported.push('updatedAfter');\n\t}\n\tif (criteria.createdAfter != null && !supported.createdAfter) {\n\t\tunsupported.push('createdAfter');\n\t}\n\tif (criteria.withoutLinkedPullRequest === true && !supported.withoutLinkedPullRequest) {\n\t\tunsupported.push('withoutLinkedPullRequest');\n\t}\n\t// `'open'` is every provider's own default, so asking for it needs no state capability.\n\tif (criteria.state != null && criteria.state !== 'open' && !supported.states) {\n\t\tunsupported.push('state');\n\t}\n\t// Folded into the same `unsupported-criteria` rejection rather than given its own reason, so a caller asking\n\t// for one inexpressible filter and one inexpressible sort learns about both at once instead of fixing them one\n\t// refusal at a time. The `sorts` list is `supported`'s own, so this needs no branch on which surface it is.\n\tif (criteria.sort != null && !supported.sorts.includes(criteria.sort)) {\n\t\tunsupported.push(`sort:${criteria.sort}`);\n\t}\n\n\tif (unsupported.length > 0) return { rejection: { reason: 'unsupported-criteria', criteria: unsupported } };\n\n\treturn {};\n}\n\n/**\n * The relationships that bound a filtered issue search to the CURRENT USER, and so can stand in for a\n * repository/org scope.\n *\n * Derived from the union rather than spelled out per call site, because the distinction it encodes is the whole\n * reason the scope rule exists: `any-assignee` and `unassigned` are deliberately absent — they describe the\n * ISSUE, not the caller, so neither reduces the search to anyone's own world (measured: unscoped `no:assignee`\n * matches ~45 million issues on GitHub).\n */\nconst userScopingIssueSearchRelationships: readonly IssueSearchRelationship[] = ['authored', 'assigned', 'mentioned'];\n\n/** What a provider with NO filtered issue search reports: nothing expressible, spelled out rather than absent. */\nconst unsupportedIssueSearchCapabilities: IssueSearchCapabilities = {\n\trelationships: [],\n\ttext: false,\n\tlabels: false,\n\tmilestone: false,\n\tupdatedAfter: false,\n\tcreatedAfter: false,\n\twithoutLinkedPullRequest: false,\n\tstates: false,\n\tsorts: [],\n};\n\n/** What a provider with no filtered pull-request search reports. */\nconst unsupportedPullRequestSearchCapabilities: PullRequestSearchCapabilities = {\n\trelationships: [],\n\tstates: [],\n\ttext: false,\n\tupdatedAfter: false,\n\tcreatedAfter: false,\n\tincludeArchived: false,\n\tdraft: false,\n\trepositoryScope: false,\n\torganizationScope: false,\n\tsorts: [],\n};\n\n/** Why a filtered issue search's scope was refused, or `undefined` when it is usable. */\nexport type IssueSearchScopeRejection =\n\t/** No repositories, no org, and no user-relative relationship: a search of the whole host. */\n\t| { reason: 'unscoped' }\n\t/** Repositories given as ids. A search names repositories by PATH, so ids can't express a scope. */\n\t| { reason: 'repo-ids' }\n\t/** Scope names a query cannot carry AS GIVEN; see {@link unusableSearchScopeNames}. */\n\t| { reason: 'unusable-scope'; scopes: string[] };\n\n/**\n * Whether a scope name reaches the provider NAMING THE SAME SCOPE — the one rule behind every `unusable-scope`\n * refusal, and the canonical home for its reasoning: the call sites point here rather than restating it.\n *\n * The defect it exists to prevent: the boundary is checked against the value AS SUPPLIED while the request is\n * built from the value AFTER the provider sanitizes it, so a name a query cannot spell produces a read that is no\n * longer the read that was authorized. Three outcomes, all of which LOOK LIKE SUCCESS, so there is nothing for a\n * consumer to branch on:\n * - **emptied** — a value of only quotes/whitespace/control characters emits no scope qualifier at all. A scope is\n * also what makes a relationship-less read legal, so the request carries neither and every item on the host\n * matches: measured at 52 million issues across unrelated accounts.\n * - **altered** — a quote inside a real name sanitizes to a real but DIFFERENT scope (`git\"kraken` -> `gitkraken`),\n * whose answer looks entirely normal.\n * - **split** — whitespace delimits qualifiers, so `my org` emits `org:my org`: a search of `my` additionally\n * filtered by the free text `org`. Measured against the live API this is a wrong NARROWING rather than a\n * widening — `org:gitkraken bar` returns 12 where `org:gitkraken` returns 379.\n *\n * Refusing beats sanitizing, and the count probes are why it matters most: they deliberately apply exactly the\n * qualifiers their search would, so a sanitized scope makes the count AGREE with the wrong search rather than\n * disagree with it, and a consumer cross-checking \"N matched\" cannot detect it by construction. Nor can it\n * pre-empt the rule — the free-text sanitizing rules are published precisely so a caller can mirror them, the\n * scope rules are not — so only the caller knows which scope it meant, and the refusal goes back to it NAMING the\n * offending value.\n *\n * Provider-NEUTRAL by design, and deliberately not an import of GitHub's `sanitizeGitHubQualifierValue`: this\n * module validates for every provider, and a GitHub-specific rule reaching in here would be wrong for the next\n * one that declares a search. The character class below is stated as the common part of any query language,\n * because each class breaks a query on its own terms — a quote closes its own qualifier, a control character\n * cannot appear at all, whitespace delimits the next qualifier.\n *\n * A provider that never puts a scope name into a query string declares\n * {@link ProviderMetadata.exactSearchScopeNames}, and only blank names and control characters are refused for it:\n * Azure DevOps Server addresses a collection or repository as an encoded URL segment and matches a project against\n * the names discovery reported, so a space or a quote reaches it naming the same scope — and its names legitimately\n * contain both.\n *\n * EDGES ARE STRIPPED before the test, which is what keeps the predicate no stricter than the provider's own\n * sanitizing — the invariant that makes refusing safe to add, since it means this can only reject a name the\n * provider would have altered, never one it would have resolved correctly. Leading and trailing whitespace AND\n * control characters both qualify: a sanitizer maps a control character to a space, then collapses and trims, so\n * `'gitkraken\\n'` and `'gitkraken\\u0000'` alike emit `org:gitkraken` — the scope that was asked for. Note this\n * is wider than `String.trim()`, which leaves control characters in place.\n *\n * None of the three outcomes above survives the stripping, so the rule loses nothing: an all-edge value still\n * empties, an INNER space or control character still splits (`'git\\u0000kraken'` emits `git kraken`, two\n * tokens), and a quote still alters wherever it sits.\n */\nfunction isUsableSearchScopeName(id: IntegrationIds, name: string): boolean {\n\tconst stripped = stripSearchScopeEdges(name);\n\tif (providersMetadata[id]?.exactSearchScopeNames === true) {\n\t\t// eslint-disable-next-line no-control-regex\n\t\treturn stripped.length > 0 && !/[\\u0000-\\u001f\\u007f]/.test(stripped);\n\t}\n\n\t// eslint-disable-next-line no-control-regex\n\treturn stripped.length > 0 && !/[\"\\u0000-\\u001f\\u007f\\s]/.test(stripped);\n}\n\n/** The leading/trailing run a provider's sanitizing removes — see {@link isUsableSearchScopeName}. */\nfunction stripSearchScopeEdges(value: string): string {\n\t// eslint-disable-next-line no-control-regex\n\treturn value.replace(/^[\\s\\u0000-\\u001f\\u007f]+|[\\s\\u0000-\\u001f\\u007f]+$/g, '');\n}\n\n/**\n * The scope names a search cannot carry as given, as the strings to name in the refusal — empty when every one is\n * usable. See {@link isUsableSearchScopeName} for the rule and why it refuses rather than sanitizes.\n */\nfunction unusableSearchScopeNames(\n\tid: IntegrationIds,\n\torg: string | undefined,\n\trepos: readonly ProviderRepoInput[] | undefined,\n): string[] {\n\tconst unusable: string[] = [];\n\n\t// An EMPTY org is \"no org supplied\" and falls through to the remaining scopes; any other unusable value WAS\n\t// supplied, so it is refused rather than dropped.\n\tif (org != null && org.length > 0 && !isUsableSearchScopeName(id, org)) {\n\t\tunusable.push(org);\n\t}\n\n\t// A `repo:` qualifier names a repository by its JOINED `namespace/name` path, which is the value the rule\n\t// below is applied to. Both halves are read defensively, through the SAME locals the label is built from: the\n\t// descriptor form is only narrowed from a union by an element-type check, so a half-built descriptor reaches\n\t// here as `undefined` and must refuse rather than throw out of a facade that reports refusals as warnings —\n\t// and reporting it as `undefined/a` would name a value the caller never passed.\n\tfor (const repo of repos ?? []) {\n\t\tconst namespace = repo.namespace ?? '';\n\t\tconst name = repo.name ?? '';\n\t\tconst path = `${namespace}/${name}`;\n\t\t// BOTH the composite and each half, because neither sees what the other does:\n\t\t// - the composite catches an offender the halves cannot, since an edge of a half is an INTERIOR character\n\t\t// of the path — `{ 'git ', 'kraken' }` has two usable-looking halves and emits `repo:git /kraken`.\n\t\t// - the halves catch a BLANK one the composite cannot, since that offender sits at a composite EDGE where\n\t\t// stripping removes it — `' /a'` strips to `'/a'`, a perfectly spellable qualifier naming no repository.\n\t\t// Each half is measured after the same stripping, so `' '` and `''` are one case rather than two.\n\t\tif (\n\t\t\t!isUsableSearchScopeName(id, path) ||\n\t\t\tstripSearchScopeEdges(namespace).length === 0 ||\n\t\t\tstripSearchScopeEdges(name).length === 0\n\t\t) {\n\t\t\tunusable.push(path);\n\t\t}\n\t}\n\n\treturn unusable;\n}\n\n/**\n * Validates that a filtered issue search is scoped at all, and narrows `repos` to the descriptor form the\n * provider query needs.\n *\n * Shared by `searchIssuesPage` and `countIssues` because a count computed under different constraints than the\n * read it previews is a WRONG number rather than a missing one. The rejection is returned as a reason code, not a\n * warning: the two callers word it differently (whole-read vs naming the offending scope's key), and wording is\n * the warning layer's business.\n *\n * `repo-ids` and `unscoped` are mutually exclusive — one requires repositories and the other requires none — so\n * their relative order is free. `unusable-scope` is NOT: it must precede `unscoped`, so a value that was supplied\n * but cannot be used is never reported as a missing one.\n *\n * Every scope name is checked for naming the same scope after the provider sanitizes it, not merely for being\n * non-empty, and that distinction is a SECURITY one rather than a nicety — see {@link isUsableSearchScopeName}.\n */\nexport function resolveIssueSearchScope(\n\tid: IntegrationIds,\n\trepos: ProviderReposInput | undefined,\n\torg: string | undefined,\n\tcriteria: IssueSearchCriteria | undefined,\n): { rejection?: IssueSearchScopeRejection; repos?: ProviderRepoInput[] } {\n\tlet resolvedRepos: ProviderRepoInput[] | undefined;\n\n\tif (repos?.length) {\n\t\t// `ProviderReposInput` is a union of descriptor and id arrays; only the descriptor form is usable here.\n\t\tif (repos.some(r => typeof r === 'string' || typeof r === 'number')) {\n\t\t\treturn { rejection: { reason: 'repo-ids' } };\n\t\t}\n\n\t\tresolvedRepos = repos as ProviderRepoInput[];\n\t}\n\n\t// Checked BEFORE the \"is it scoped at all\" rule below, so an unusable value is never reported as a missing\n\t// one: it was supplied, and telling the caller to pass a scope it already passed names the wrong defect.\n\tconst unusable = unusableSearchScopeNames(id, org, resolvedRepos);\n\tif (unusable.length > 0) return { rejection: { reason: 'unusable-scope', scopes: unusable } };\n\n\tif (resolvedRepos != null) return { repos: resolvedRepos };\n\tif (org != null && org.length > 0) return {};\n\tif (criteria?.relationships?.some(r => userScopingIssueSearchRelationships.includes(r)) === true) return {};\n\n\treturn { rejection: { reason: 'unscoped' } };\n}\n\n/**\n * The filters `listPullRequestsPage`/`listIssuesPage` (and the sweeps) accept for a provider, so a caller can\n * narrow to what the provider can express BEFORE issuing the read.\n *\n * This matters because the filter contract is all-or-nothing: a set containing even one unsupported filter is\n * refused outright ({@link resolvePullRequestFilters}) rather than silently narrowed, since falling through to\n * an unfiltered fetch would return every PR instead of the user's. Without this accessor a consumer had to\n * hardcode its own copy of the table — reachable only by importing the internal `providers/models.js`\n * subpath — and a copy that drifts turns a supported read into an empty page with `fetchFailed`.\n *\n * Empty means \"no filter of that kind is expressible\": either the provider has no such surface (issue trackers\n * have no pull requests; Bitbucket exposes no issues) or its metadata declares none. Callers should treat it as\n * \"don't pass filters\", not as an error. Returns copies, so mutating the result can't corrupt the metadata.\n *\n * `issues` and `issuesAccountWide` are separate because the repo-scoped and account-wide issue reads are\n * different provider queries with different filter surfaces, and the same `filters` input is validated against\n * whichever one the read uses (`repos` present or not). `issuesAccountWide` is generally the narrower of the\n * two: GitLab, for instance, can express `Assignee` and `Author` account-wide, but not `Mention`.\n *\n * That split describes the GIT-HOST reads only. An issue tracker (Jira/Linear/Trello) has neither — its issues\n * live under resource → project — so it reports its filters under `issues`, which is what\n * {@link IntegrationService.listIssueTrackerIssuesPage} validates against, and leaves `issuesAccountWide`\n * empty. Reading a tracker's capability off `issuesAccountWide` therefore under-reports it.\n *\n * `issueSearch` is a third, wider surface: the FILTERED issue search (`searchIssuesPage`, and the `countIssues`\n * probe over the same criteria), which is not bound to the user at all. It is a record of per-criterion flags\n * rather than a list, because its criteria aren't a single kind. An empty `relationships` means the provider has\n * no filtered issue search — hide the surface, not just its chips.\n *\n * `pullRequestSearch` describes the separate filtered PR search. Its table declares each criteria vocabulary\n * plus repository/organization scope support; an empty relationship list means the search itself is absent.\n *\n * `issueSorts` / `issueSortsAccountWide` / `issueSearch.sorts` are the ORDERING vocabulary of those same three\n * issue reads, split the same way and for the same reason (GitLab's repo-scoped read is GraphQL and its\n * account-wide read is REST, with genuinely different sort vocabularies). Empty means the read can't be ordered,\n * so pass no `sort`; a key not listed refuses the whole read exactly like an inexpressible filter. Note a key\n * listed here is expressible on ONE provider query: a read that fans out across projects can only honor a key\n * derivable from a normalized issue, so it refuses `priority`/`dueDate`/`resolved` on top of this table.\n *\n * Note this is a CAPABILITY table — \"what the provider can express\" — not a recommendation. A consumer\n * matching another tool's behavior may deliberately pass fewer filters than are listed here (or none, where an\n * already-scoped read would only be narrowed by them). Intersecting against this table is what keeps a\n * filtered read from being refused; it isn't a directive to use every filter in it.\n */\nexport function getSupportedFilters(providerId: IntegrationIds): SupportedFilters {\n\tconst metadata = providersMetadata[providerId];\n\tconst issueSearch = metadata?.supportedIssueSearch;\n\tconst pullRequestSearch = metadata?.supportedPullRequestSearch;\n\treturn {\n\t\tpullRequests: [...(metadata?.supportedPullRequestFilters ?? [])],\n\t\tpullRequestsAccountWide: [...(metadata?.supportedAccountWidePullRequestFilters ?? [])],\n\t\tpullRequestSearch: {\n\t\t\t...unsupportedPullRequestSearchCapabilities,\n\t\t\t...pullRequestSearch,\n\t\t\trelationships: [...(pullRequestSearch?.relationships ?? [])],\n\t\t\tstates: [...(pullRequestSearch?.states ?? [])],\n\t\t\t// Copied, so mutating the result can't corrupt the metadata table.\n\t\t\tsorts: [...(pullRequestSearch?.sorts ?? [])],\n\t\t},\n\t\tissues: [...(metadata?.supportedIssueFilters ?? [])],\n\t\tissuesAccountWide: [...(metadata?.supportedAccountWideIssueFilters ?? [])],\n\t\t// Always an object, never `undefined`: a provider WITHOUT a filtered issue search reports one whose\n\t\t// `relationships` is empty and whose flags are all false, so a consumer reads capabilities the same way\n\t\t// for every provider (and an empty `relationships` is the signal to hide the surface itself).\n\t\t//\n\t\t// Spread over the all-false baseline rather than defaulting each flag: a criterion added to\n\t\t// `IssueSearchCapabilities` then can't be forgotten here and silently reported as `undefined` (which a\n\t\t// consumer's `if (caps.x)` would read as unsupported — right answer, wrong reason, and untyped).\n\t\t// `supportedIssueSearch` is typed as the complete shape, so no member can arrive as an explicit undefined.\n\t\tissueSearch: {\n\t\t\t...unsupportedIssueSearchCapabilities,\n\t\t\t...issueSearch,\n\t\t\t// Copied, so mutating the result can't corrupt the metadata table.\n\t\t\trelationships: [...(issueSearch?.relationships ?? [])],\n\t\t\tsorts: [...(issueSearch?.sorts ?? [])],\n\t\t},\n\t\tissueSorts: [...(metadata?.supportedIssueSorts ?? [])],\n\t\tissueSortsAccountWide: [...(metadata?.supportedAccountWideIssueSorts ?? [])],\n\t\tissueStates: metadata?.supportsIssueStates === true,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AA0CA,SAAgB,0BACf,IACA,SACqC;CACrC,IAAI,WAAW,QAAQ,QAAQ,WAAW,GAAG,OAAO,EAAE,aAAa,MAAM;CAEzE,MAAM,YAAY,kBAAkB,GAAG,EAAE;CACzC,IAAI,aAAa,QAAQ,QAAQ,MAAK,MAAK,CAAC,UAAU,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,aAAa,KAAK;CAE/F,OAAO;EAAW;EAAS,aAAa;CAAM;AAC/C;;;;;AAMA,SAAgB,qCACf,IACA,SACqC;CACrC,IAAI,WAAW,QAAQ,QAAQ,WAAW,GAAG,OAAO,EAAE,aAAa,MAAM;CAEzE,MAAM,YAAY,kBAAkB,GAAG,EAAE;CACzC,IAAI,aAAa,QAAQ,QAAQ,MAAK,MAAK,CAAC,UAAU,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,aAAa,KAAK;CAE/F,OAAO;EAAE,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;EAAG,aAAa;CAAM;AAC7D;;;;;;AAcA,SAAgB,iCACf,IACA,UACqD;CACrD,MAAM,YAAY,kBAAkB,GAAG,EAAE;CACzC,IAAI,aAAa,QAAQ,UAAU,cAAc,WAAW,GAC3D,OAAO,EAAE,WAAW,EAAE,QAAQ,qBAAqB,EAAE;CAEtD,IAAI,YAAY,MAAM,OAAO,CAAC;CAE9B,MAAM,cAAwB,CAAC;CAC/B,KAAK,MAAM,gBAAgB,SAAS,iBAAi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K,oCAAoC,SAAS,CAAC,CAAC,MAAM,MAAM,OAAO,CAAC;CAE1G,OAAO,EAAE,WAAW,EAAE,QAAQ,WAAW,EAAE;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,oBAAoB,YAA8C;CACjF,MAAM,WAAW,kBAAkB;CACnC,MAAM,cAAc,UAAU;CAC9B,MAAM,oBAAoB,UAAU;CACpC,OAAO;EACN,cAAc,CAAC,GAAI,UAAU,+BAA+B,CAAC,CAAE;EAC/D,yBAAyB,CAAC,GAAI,UAAU,0CAA0C,CAAC,CAAE;EACrF,mBAAmB;GAClB,GAAG;GACH,GAAG;GACH,eAAe,CAAC,GAAI,mBAAmB,iBAAiB,CAAC,CAAE;GAC3D,QAAQ,CAAC,GAAI,mBAAmB,UAAU,CAAC,CAAE;GAE7C,OAAO,CAAC,GAAI,mBAAmB,SAAS,CAAC,CAAE;EAC5C;EACA,QAAQ,CAAC,GAAI,UAAU,yBAAyB,CAAC,CAAE;EACnD,mBAAmB,CAAC,GAAI,UAAU,oCAAoC,CAAC,CAAE;EASzE,aAAa;GACZ,GAAG;GACH,GAAG;GAEH,eAAe,CAAC,GAAI,aAAa,iBAAiB,CAAC,CAAE;GACrD,OAAO,CAAC,GAAI,aAAa,SAAS,CAAC,CAAE;EACtC;EACA,YAAY,CAAC,GAAI,UAAU,uBAAuB,CAAC,CAAE;EACrD,uBAAuB,CAAC,GAAI,UAAU,kCAAkC,CAAC,CAAE;EAC3E,aAAa,UAAU,wBAAwB;CAChD;AACD"}
|
|
1
|
+
{"version":3,"file":"filters.js","names":[],"sources":["../../../../../plus/integrations/src/reads/filters.ts"],"sourcesContent":["import { isValidPullRequestChangedSince } from '@gitlens/git/utils/pullRequest.utils.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type {\n\tIssueFilter,\n\tIssueSearchCapabilities,\n\tIssueSearchCriteria,\n\tIssueSearchRelationship,\n\tPullRequestFilter,\n\tPullRequestSearchCapabilities,\n\tPullRequestSearchCriteria,\n\tSupportedFilters,\n} from '../providerFilters.js';\nimport { providersMetadata } from '../providers/metadata.js';\nimport type { ProviderRepoInput, ProviderReposInput } from '../providers/models.js';\n\n/**\n * Validation of a caller-supplied relationship filter set against what a provider can express server-side.\n *\n * Every one of these is ALL-OR-NOTHING, and deliberately so: dropping the members a provider can't express\n * would silently widen the read past what was asked for (requesting Author+Mention on a host without Mention\n * would return every authored item rather than the requested set), and narrowing the returned page afterward\n * would leave `items` describing a different result set than the `hasMore`/`cursor` the provider produced with\n * it. So an inexpressible set is refused whole, and the caller surfaces a warning instead of reading unfiltered.\n *\n * The three differ only in WHICH capability they check, because they govern three different provider queries —\n * see `IntegrationManager.getSupportedFilters`, which exposes the same capability table so a consumer can\n * intersect against it and never reach a refusal.\n */\nexport interface ResolvedFilters<T> {\n\tfilters?: T[];\n\tunsupported: boolean;\n}\n\n/**\n * Validates a repo-scoped PR filter set, so an unsupported filter never trips the read core's \"Unsupported\n * filters\" guard. `unsupported: true` when the caller DID request filters and the provider can't express even\n * ONE of them — the exact negation of the read core's `providerSupportsPullRequestFilters` (`every`), so this\n * can only ever pre-empt that guard, never disagree with it.\n *\n * Returns `{ filters }` (possibly undefined when none were requested — an unfiltered read is intended). Genuine\n * \"my pull requests\" self-scoping is delivered by the account-wide path\n * (`GitHostIntegration.getMyPullRequestsForUserResult`); this only governs the optional repo-scoped narrowing.\n */\nexport function resolvePullRequestFilters(\n\tid: IntegrationIds,\n\tfilters: PullRequestFilter[] | undefined,\n): ResolvedFilters<PullRequestFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedPullRequestFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: filters, unsupported: false };\n}\n\n/**\n * Validates an account-wide PR relationship union independently from the repo-scoped capability. Dropping an\n * unsupported member would change the requested OR set, so validation is all-or-nothing.\n */\nexport function resolveAccountWidePullRequestFilters(\n\tid: IntegrationIds,\n\tfilters: PullRequestFilter[] | undefined,\n): ResolvedFilters<PullRequestFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedAccountWidePullRequestFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: [...new Set(filters)], unsupported: false };\n}\n\n/** Why {@link resolvePullRequestSearchCriteria} refused a criteria set. */\nexport type PullRequestSearchCriteriaRejection =\n\t/** The provider has no filtered pull-request search. */\n\t| { reason: 'unsupported-search' }\n\t/** The provider has one, but cannot express every requested criterion server-side. */\n\t| { reason: 'unsupported-criteria'; criteria: string[] };\n\n/**\n * Validates filtered pull-request search criteria all-or-nothing. Dropping an unsupported criterion would\n * widen the provider query while leaving its page and cursor describing the wider set, so the facade refuses the\n * request before any upstream call instead.\n */\nexport function resolvePullRequestSearchCriteria(\n\tid: IntegrationIds,\n\tcriteria: PullRequestSearchCriteria | undefined,\n): { rejection?: PullRequestSearchCriteriaRejection } {\n\tconst supported = providersMetadata[id]?.supportedPullRequestSearch;\n\tif (supported == null || supported.relationships.length === 0) {\n\t\treturn { rejection: { reason: 'unsupported-search' } };\n\t}\n\tif (criteria == null) return {};\n\n\tconst unsupported: string[] = [];\n\tfor (const relationship of criteria.relationships ?? []) {\n\t\tif (!supported.relationships.includes(relationship)) {\n\t\t\tunsupported.push(`relationships:${relationship}`);\n\t\t}\n\t}\n\tfor (const state of criteria.states ?? []) {\n\t\tif (!supported.states.includes(state)) {\n\t\t\tunsupported.push(`states:${state}`);\n\t\t}\n\t}\n\tif (criteria.text != null && criteria.text.trim().length > 0 && !supported.text) {\n\t\tunsupported.push('text');\n\t}\n\tif (criteria.updatedAfter != null && !supported.updatedAfter) {\n\t\tunsupported.push('updatedAfter');\n\t}\n\tif (criteria.createdAfter != null && !supported.createdAfter) {\n\t\tunsupported.push('createdAfter');\n\t}\n\tif (criteria.includeArchived === true && !supported.includeArchived) {\n\t\tunsupported.push('includeArchived');\n\t}\n\t// `!= null`, not truthy: `draft: false` (only ready-for-review) is as much a request as `draft: true`.\n\tif (criteria.draft != null && !supported.draft) {\n\t\tunsupported.push('draft');\n\t}\n\t// Folded into the same `unsupported-criteria` rejection rather than its own reason, so a caller asking for one\n\t// inexpressible filter and one inexpressible sort learns about both at once. `updated:desc` is always in\n\t// `sorts` for a usable search, so the omitted (default) case never rejects.\n\tif (criteria.sort != null && !supported.sorts.includes(criteria.sort)) {\n\t\tunsupported.push(`sort:${criteria.sort}`);\n\t}\n\tif (criteria.changedSince != null) {\n\t\tunsupported.push(...unsupportedChangedSinceCriteria(criteria, criteria.changedSince, supported.changedSince));\n\t}\n\n\treturn unsupported.length > 0 ? { rejection: { reason: 'unsupported-criteria', criteria: unsupported } } : {};\n}\n\nfunction unsupportedChangedSinceCriteria(\n\tcriteria: PullRequestSearchCriteria,\n\tchangedSince: string,\n\tsupported: boolean,\n): string[] {\n\tif (!supported) return ['changedSince'];\n\n\tconst unsupported: string[] = [];\n\tif (!isValidPullRequestChangedSince(changedSince)) {\n\t\tunsupported.push(`changedSince:${JSON.stringify(changedSince)} (expected YYYY-MM-DDTHH:MM:SSZ)`);\n\t}\n\tfor (const state of criteria.states ?? []) {\n\t\tif (state !== 'all') {\n\t\t\tunsupported.push(`changedSince with states:${state}`);\n\t\t}\n\t}\n\tif (criteria.sort != null && criteria.sort !== 'updated:asc') {\n\t\tunsupported.push(`changedSince with sort:${criteria.sort}`);\n\t}\n\tif (new Set(criteria.relationships).size > 1) {\n\t\tunsupported.push('changedSince with several relationships');\n\t}\n\treturn unsupported;\n}\n\n/** Why a filtered pull-request search's repository/organization boundary was refused. */\nexport type PullRequestSearchScopeRejection =\n\t| { reason: 'unscoped' }\n\t| { reason: 'repo-ids' }\n\t| { reason: 'unsupported-repository-scope' }\n\t| { reason: 'unsupported-organization-scope' }\n\t/** Scope names a query cannot carry AS GIVEN; see {@link unusableSearchScopeNames}. */\n\t| { reason: 'unusable-scope'; scopes: string[] };\n\n/**\n * Validates the search boundary independently from its criteria. A current-user relationship is itself a safe\n * account-wide boundary; without one, a repository or organization scope is mandatory.\n *\n * Scope names go through the same {@link unusableSearchScopeNames} rule the issue search uses — shared rather\n * than re-derived, because the defect is identical on both reads.\n */\nexport function resolvePullRequestSearchScope(\n\tid: IntegrationIds,\n\trepos: ProviderReposInput | undefined,\n\torg: string | undefined,\n\tcriteria: PullRequestSearchCriteria | undefined,\n): { rejection?: PullRequestSearchScopeRejection; repos?: ProviderRepoInput[] } {\n\tconst supported = providersMetadata[id]?.supportedPullRequestSearch;\n\tlet resolvedRepos: ProviderRepoInput[] | undefined;\n\n\tif (repos?.length) {\n\t\tif (repos.some(r => typeof r === 'string' || typeof r === 'number')) {\n\t\t\treturn { rejection: { reason: 'repo-ids' } };\n\t\t}\n\t\tif (supported?.repositoryScope !== true) return { rejection: { reason: 'unsupported-repository-scope' } };\n\n\t\tresolvedRepos = repos as ProviderRepoInput[];\n\t}\n\n\tconst hasOrganizationScope = org != null && org.length > 0;\n\tif (hasOrganizationScope && supported?.organizationScope !== true) {\n\t\treturn { rejection: { reason: 'unsupported-organization-scope' } };\n\t}\n\n\t// After the capability checks and before the \"is it scoped at all\" rule: a scope the provider cannot express\n\t// at all is the more fundamental refusal, and an unusable value that WAS supplied must not be reported as a\n\t// missing one. `org` is passed bare, matching the issue twin — the helper applies its own empty-means-\n\t// unsupplied guard, so re-testing `hasOrganizationScope` here would only make the two resolvers look like\n\t// they differ.\n\tconst unusable = unusableSearchScopeNames(id, org, resolvedRepos);\n\tif (unusable.length > 0) return { rejection: { reason: 'unusable-scope', scopes: unusable } };\n\n\tif (resolvedRepos != null || hasOrganizationScope || (criteria?.relationships?.length ?? 0) > 0) {\n\t\treturn { repos: resolvedRepos };\n\t}\n\n\treturn { rejection: { reason: 'unscoped' } };\n}\n\n/**\n * Validates a caller-provided issue filter set against what the provider's ACCOUNT-WIDE issue read can express\n * server-side (`ProviderMetadata.supportedAccountWideIssueFilters`), which is a different — usually narrower —\n * set than the repo-scoped `ProviderMetadata.supportedIssueFilters`.\n *\n * Dropping the unexpressible members would silently widen the read back toward the provider's own union\n * (authored ∪ assigned ∪ mentioned for GitHub), which is the opposite of what a caller narrowing to\n * `[Assignee]` asked for.\n */\nexport function resolveAccountWideIssueFilters(\n\tid: IntegrationIds,\n\tfilters: IssueFilter[] | undefined,\n): ResolvedFilters<IssueFilter> {\n\tif (filters == null || filters.length === 0) return { unsupported: false };\n\n\tconst supported = providersMetadata[id]?.supportedAccountWideIssueFilters;\n\tif (supported == null || filters.some(f => !supported.includes(f))) return { unsupported: true };\n\n\treturn { filters: filters, unsupported: false };\n}\n\n/** Why {@link resolveIssueSearchCriteria} refused a criteria set, so the caller can word the refusal exactly. */\nexport type IssueSearchCriteriaRejection =\n\t/** The provider has no filtered issue search at all. */\n\t| { reason: 'unsupported-search' }\n\t/** The provider has one, but can't express these criteria server-side. */\n\t| { reason: 'unsupported-criteria'; criteria: string[] }\n\t/** `any-assignee` and `unassigned` partition the scope between them; asking for both asks for nothing. */\n\t| { reason: 'contradictory-relationships' };\n\n/**\n * Whether a provider exposes the FILTERED issue search at all — the one predicate a caller can check BEFORE\n * building criteria, so a read that would only be refused is never issued.\n *\n * The same test {@link resolveIssueSearchCriteria} makes for its `unsupported-search` rejection, named rather\n * than re-derived at each call site: a caller writing `supportedIssueSearch != null` itself is a copy free to\n * disagree with the validator about what \"has a search\" means. `broadenIssues` reads it to pick its engine —\n * the org-scoped search where there is one, the repository drain where there isn't — which is a CHOICE rather\n * than a refusal, so it needs the predicate without the rejection.\n */\nexport function supportsFilteredIssueSearch(id: IntegrationIds): boolean {\n\treturn providersMetadata[id]?.supportedIssueSearch != null;\n}\n\n/**\n * Validates a filtered issue search's criteria against {@link ProviderMetadata.supportedIssueSearch}.\n *\n * All-or-nothing like its three siblings above, and for the same reason: a criterion dropped because the\n * provider can't express it would serve a WIDER result than was asked for, and narrowing the returned page\n * afterward would leave `items` describing a different result set than the `hasMore`/`cursor` the provider\n * produced with it. So an inexpressible set is refused whole and the caller surfaces a warning.\n *\n * Unlike the sibling validators this also rejects a set that is internally contradictory, because this criteria\n * model is the only one with two members that partition the scope between them (`any-assignee` ∪ `unassigned` =\n * everything, ∩ = nothing). Silently keeping one would answer a question the caller didn't ask.\n *\n * `undefined` (or an empty relationship list plus no other criterion) is a valid UNNARROWED search of the given\n * scope, not an error — the caller's `repos`/`org` is what bounds it.\n */\nexport function resolveIssueSearchCriteria(\n\tid: IntegrationIds,\n\tcriteria: IssueSearchCriteria | undefined,\n): { rejection?: IssueSearchCriteriaRejection } {\n\tconst supported = providersMetadata[id]?.supportedIssueSearch;\n\tif (supported == null) return { rejection: { reason: 'unsupported-search' } };\n\tif (criteria == null) return {};\n\n\tconst relationships = criteria.relationships;\n\tif (relationships?.includes('any-assignee') && relationships.includes('unassigned')) {\n\t\treturn { rejection: { reason: 'contradictory-relationships' } };\n\t}\n\n\tconst unsupported: string[] = [];\n\tfor (const relationship of relationships ?? []) {\n\t\tif (!supported.relationships.includes(relationship)) {\n\t\t\tunsupported.push(`relationships:${relationship}`);\n\t\t}\n\t}\n\t// Only a criterion the caller actually SET can be unsupported. `false`/empty means \"don't narrow on this\",\n\t// which every provider can honor by doing nothing, so it must not be validated as a request.\n\tif (criteria.text != null && criteria.text.trim().length > 0 && !supported.text) {\n\t\tunsupported.push('text');\n\t}\n\tif (criteria.labels?.length && !supported.labels) {\n\t\tunsupported.push('labels');\n\t}\n\tif (criteria.milestone != null && !supported.milestone) {\n\t\tunsupported.push('milestone');\n\t}\n\tif (criteria.updatedAfter != null && !supported.updatedAfter) {\n\t\tunsupported.push('updatedAfter');\n\t}\n\tif (criteria.createdAfter != null && !supported.createdAfter) {\n\t\tunsupported.push('createdAfter');\n\t}\n\tif (criteria.withoutLinkedPullRequest === true && !supported.withoutLinkedPullRequest) {\n\t\tunsupported.push('withoutLinkedPullRequest');\n\t}\n\t// `'open'` is every provider's own default, so asking for it needs no state capability.\n\tif (criteria.state != null && criteria.state !== 'open' && !supported.states) {\n\t\tunsupported.push('state');\n\t}\n\t// Folded into the same `unsupported-criteria` rejection rather than given its own reason, so a caller asking\n\t// for one inexpressible filter and one inexpressible sort learns about both at once instead of fixing them one\n\t// refusal at a time. The `sorts` list is `supported`'s own, so this needs no branch on which surface it is.\n\tif (criteria.sort != null && !supported.sorts.includes(criteria.sort)) {\n\t\tunsupported.push(`sort:${criteria.sort}`);\n\t}\n\n\tif (unsupported.length > 0) return { rejection: { reason: 'unsupported-criteria', criteria: unsupported } };\n\n\treturn {};\n}\n\n/**\n * The relationships that bound a filtered issue search to the CURRENT USER, and so can stand in for a\n * repository/org scope.\n *\n * Derived from the union rather than spelled out per call site, because the distinction it encodes is the whole\n * reason the scope rule exists: `any-assignee` and `unassigned` are deliberately absent — they describe the\n * ISSUE, not the caller, so neither reduces the search to anyone's own world (measured: unscoped `no:assignee`\n * matches ~45 million issues on GitHub).\n */\nconst userScopingIssueSearchRelationships: readonly IssueSearchRelationship[] = ['authored', 'assigned', 'mentioned'];\n\n/** What a provider with NO filtered issue search reports: nothing expressible, spelled out rather than absent. */\nconst unsupportedIssueSearchCapabilities: IssueSearchCapabilities = {\n\trelationships: [],\n\ttext: false,\n\tlabels: false,\n\tmilestone: false,\n\tupdatedAfter: false,\n\tcreatedAfter: false,\n\twithoutLinkedPullRequest: false,\n\tstates: false,\n\tsorts: [],\n};\n\n/** What a provider with no filtered pull-request search reports. */\nconst unsupportedPullRequestSearchCapabilities: PullRequestSearchCapabilities = {\n\trelationships: [],\n\tstates: [],\n\ttext: false,\n\tupdatedAfter: false,\n\tcreatedAfter: false,\n\tincludeArchived: false,\n\tdraft: false,\n\trepositoryScope: false,\n\torganizationScope: false,\n\tsorts: [],\n\tchangedSince: false,\n};\n\n/** Why a filtered issue search's scope was refused, or `undefined` when it is usable. */\nexport type IssueSearchScopeRejection =\n\t/** No repositories, no org, and no user-relative relationship: a search of the whole host. */\n\t| { reason: 'unscoped' }\n\t/** Repositories given as ids. A search names repositories by PATH, so ids can't express a scope. */\n\t| { reason: 'repo-ids' }\n\t/** Scope names a query cannot carry AS GIVEN; see {@link unusableSearchScopeNames}. */\n\t| { reason: 'unusable-scope'; scopes: string[] };\n\n/**\n * Whether a scope name reaches the provider NAMING THE SAME SCOPE — the one rule behind every `unusable-scope`\n * refusal, and the canonical home for its reasoning: the call sites point here rather than restating it.\n *\n * The defect it exists to prevent: the boundary is checked against the value AS SUPPLIED while the request is\n * built from the value AFTER the provider sanitizes it, so a name a query cannot spell produces a read that is no\n * longer the read that was authorized. Three outcomes, all of which LOOK LIKE SUCCESS, so there is nothing for a\n * consumer to branch on:\n * - **emptied** — a value of only quotes/whitespace/control characters emits no scope qualifier at all. A scope is\n * also what makes a relationship-less read legal, so the request carries neither and every item on the host\n * matches: measured at 52 million issues across unrelated accounts.\n * - **altered** — a quote inside a real name sanitizes to a real but DIFFERENT scope (`git\"kraken` -> `gitkraken`),\n * whose answer looks entirely normal.\n * - **split** — whitespace delimits qualifiers, so `my org` emits `org:my org`: a search of `my` additionally\n * filtered by the free text `org`. Measured against the live API this is a wrong NARROWING rather than a\n * widening — `org:gitkraken bar` returns 12 where `org:gitkraken` returns 379.\n *\n * Refusing beats sanitizing, and the count probes are why it matters most: they deliberately apply exactly the\n * qualifiers their search would, so a sanitized scope makes the count AGREE with the wrong search rather than\n * disagree with it, and a consumer cross-checking \"N matched\" cannot detect it by construction. Nor can it\n * pre-empt the rule — the free-text sanitizing rules are published precisely so a caller can mirror them, the\n * scope rules are not — so only the caller knows which scope it meant, and the refusal goes back to it NAMING the\n * offending value.\n *\n * Provider-NEUTRAL by design, and deliberately not an import of GitHub's `sanitizeGitHubQualifierValue`: this\n * module validates for every provider, and a GitHub-specific rule reaching in here would be wrong for the next\n * one that declares a search. The character class below is stated as the common part of any query language,\n * because each class breaks a query on its own terms — a quote closes its own qualifier, a control character\n * cannot appear at all, whitespace delimits the next qualifier.\n *\n * A provider that never puts a scope name into a query string declares\n * {@link ProviderMetadata.exactSearchScopeNames}, and only blank names and control characters are refused for it:\n * Azure DevOps Server addresses a collection or repository as an encoded URL segment and matches a project against\n * the names discovery reported, so a space or a quote reaches it naming the same scope — and its names legitimately\n * contain both.\n *\n * EDGES ARE STRIPPED before the test, which is what keeps the predicate no stricter than the provider's own\n * sanitizing — the invariant that makes refusing safe to add, since it means this can only reject a name the\n * provider would have altered, never one it would have resolved correctly. Leading and trailing whitespace AND\n * control characters both qualify: a sanitizer maps a control character to a space, then collapses and trims, so\n * `'gitkraken\\n'` and `'gitkraken\\u0000'` alike emit `org:gitkraken` — the scope that was asked for. Note this\n * is wider than `String.trim()`, which leaves control characters in place.\n *\n * None of the three outcomes above survives the stripping, so the rule loses nothing: an all-edge value still\n * empties, an INNER space or control character still splits (`'git\\u0000kraken'` emits `git kraken`, two\n * tokens), and a quote still alters wherever it sits.\n */\nfunction isUsableSearchScopeName(id: IntegrationIds, name: string): boolean {\n\tconst stripped = stripSearchScopeEdges(name);\n\tif (providersMetadata[id]?.exactSearchScopeNames === true) {\n\t\t// eslint-disable-next-line no-control-regex\n\t\treturn stripped.length > 0 && !/[\\u0000-\\u001f\\u007f]/.test(stripped);\n\t}\n\n\t// eslint-disable-next-line no-control-regex\n\treturn stripped.length > 0 && !/[\"\\u0000-\\u001f\\u007f\\s]/.test(stripped);\n}\n\n/** The leading/trailing run a provider's sanitizing removes — see {@link isUsableSearchScopeName}. */\nfunction stripSearchScopeEdges(value: string): string {\n\t// eslint-disable-next-line no-control-regex\n\treturn value.replace(/^[\\s\\u0000-\\u001f\\u007f]+|[\\s\\u0000-\\u001f\\u007f]+$/g, '');\n}\n\n/**\n * The scope names a search cannot carry as given, as the strings to name in the refusal — empty when every one is\n * usable. See {@link isUsableSearchScopeName} for the rule and why it refuses rather than sanitizes.\n */\nfunction unusableSearchScopeNames(\n\tid: IntegrationIds,\n\torg: string | undefined,\n\trepos: readonly ProviderRepoInput[] | undefined,\n): string[] {\n\tconst unusable: string[] = [];\n\n\t// An EMPTY org is \"no org supplied\" and falls through to the remaining scopes; any other unusable value WAS\n\t// supplied, so it is refused rather than dropped.\n\tif (org != null && org.length > 0 && !isUsableSearchScopeName(id, org)) {\n\t\tunusable.push(org);\n\t}\n\n\t// A `repo:` qualifier names a repository by its JOINED `namespace/name` path, which is the value the rule\n\t// below is applied to. Both halves are read defensively, through the SAME locals the label is built from: the\n\t// descriptor form is only narrowed from a union by an element-type check, so a half-built descriptor reaches\n\t// here as `undefined` and must refuse rather than throw out of a facade that reports refusals as warnings —\n\t// and reporting it as `undefined/a` would name a value the caller never passed.\n\tfor (const repo of repos ?? []) {\n\t\tconst namespace = repo.namespace ?? '';\n\t\tconst name = repo.name ?? '';\n\t\tconst path = `${namespace}/${name}`;\n\t\t// BOTH the composite and each half, because neither sees what the other does:\n\t\t// - the composite catches an offender the halves cannot, since an edge of a half is an INTERIOR character\n\t\t// of the path — `{ 'git ', 'kraken' }` has two usable-looking halves and emits `repo:git /kraken`.\n\t\t// - the halves catch a BLANK one the composite cannot, since that offender sits at a composite EDGE where\n\t\t// stripping removes it — `' /a'` strips to `'/a'`, a perfectly spellable qualifier naming no repository.\n\t\t// Each half is measured after the same stripping, so `' '` and `''` are one case rather than two.\n\t\tif (\n\t\t\t!isUsableSearchScopeName(id, path) ||\n\t\t\tstripSearchScopeEdges(namespace).length === 0 ||\n\t\t\tstripSearchScopeEdges(name).length === 0\n\t\t) {\n\t\t\tunusable.push(path);\n\t\t}\n\t}\n\n\treturn unusable;\n}\n\n/**\n * Validates that a filtered issue search is scoped at all, and narrows `repos` to the descriptor form the\n * provider query needs.\n *\n * Shared by `searchIssuesPage` and `countIssues` because a count computed under different constraints than the\n * read it previews is a WRONG number rather than a missing one. The rejection is returned as a reason code, not a\n * warning: the two callers word it differently (whole-read vs naming the offending scope's key), and wording is\n * the warning layer's business.\n *\n * `repo-ids` and `unscoped` are mutually exclusive — one requires repositories and the other requires none — so\n * their relative order is free. `unusable-scope` is NOT: it must precede `unscoped`, so a value that was supplied\n * but cannot be used is never reported as a missing one.\n *\n * Every scope name is checked for naming the same scope after the provider sanitizes it, not merely for being\n * non-empty, and that distinction is a SECURITY one rather than a nicety — see {@link isUsableSearchScopeName}.\n */\nexport function resolveIssueSearchScope(\n\tid: IntegrationIds,\n\trepos: ProviderReposInput | undefined,\n\torg: string | undefined,\n\tcriteria: IssueSearchCriteria | undefined,\n): { rejection?: IssueSearchScopeRejection; repos?: ProviderRepoInput[] } {\n\tlet resolvedRepos: ProviderRepoInput[] | undefined;\n\n\tif (repos?.length) {\n\t\t// `ProviderReposInput` is a union of descriptor and id arrays; only the descriptor form is usable here.\n\t\tif (repos.some(r => typeof r === 'string' || typeof r === 'number')) {\n\t\t\treturn { rejection: { reason: 'repo-ids' } };\n\t\t}\n\n\t\tresolvedRepos = repos as ProviderRepoInput[];\n\t}\n\n\t// Checked BEFORE the \"is it scoped at all\" rule below, so an unusable value is never reported as a missing\n\t// one: it was supplied, and telling the caller to pass a scope it already passed names the wrong defect.\n\tconst unusable = unusableSearchScopeNames(id, org, resolvedRepos);\n\tif (unusable.length > 0) return { rejection: { reason: 'unusable-scope', scopes: unusable } };\n\n\tif (resolvedRepos != null) return { repos: resolvedRepos };\n\tif (org != null && org.length > 0) return {};\n\tif (criteria?.relationships?.some(r => userScopingIssueSearchRelationships.includes(r)) === true) return {};\n\n\treturn { rejection: { reason: 'unscoped' } };\n}\n\n/**\n * The filters `listPullRequestsPage`/`listIssuesPage` (and the sweeps) accept for a provider, so a caller can\n * narrow to what the provider can express BEFORE issuing the read.\n *\n * This matters because the filter contract is all-or-nothing: a set containing even one unsupported filter is\n * refused outright ({@link resolvePullRequestFilters}) rather than silently narrowed, since falling through to\n * an unfiltered fetch would return every PR instead of the user's. Without this accessor a consumer had to\n * hardcode its own copy of the table — reachable only by importing the internal `providers/models.js`\n * subpath — and a copy that drifts turns a supported read into an empty page with `fetchFailed`.\n *\n * Empty means \"no filter of that kind is expressible\": either the provider has no such surface (issue trackers\n * have no pull requests; Bitbucket exposes no issues) or its metadata declares none. Callers should treat it as\n * \"don't pass filters\", not as an error. Returns copies, so mutating the result can't corrupt the metadata.\n *\n * `issues` and `issuesAccountWide` are separate because the repo-scoped and account-wide issue reads are\n * different provider queries with different filter surfaces, and the same `filters` input is validated against\n * whichever one the read uses (`repos` present or not). `issuesAccountWide` is generally the narrower of the\n * two: GitLab, for instance, can express `Assignee` and `Author` account-wide, but not `Mention`.\n *\n * That split describes the GIT-HOST reads only. An issue tracker (Jira/Linear/Trello) has neither — its issues\n * live under resource → project — so it reports its filters under `issues`, which is what\n * {@link IntegrationService.listIssueTrackerIssuesPage} validates against, and leaves `issuesAccountWide`\n * empty. Reading a tracker's capability off `issuesAccountWide` therefore under-reports it.\n *\n * `issueSearch` is a third, wider surface: the FILTERED issue search (`searchIssuesPage`, and the `countIssues`\n * probe over the same criteria), which is not bound to the user at all. It is a record of per-criterion flags\n * rather than a list, because its criteria aren't a single kind. An empty `relationships` means the provider has\n * no filtered issue search — hide the surface, not just its chips.\n *\n * `pullRequestSearch` describes the separate filtered PR search. Its table declares each criteria vocabulary\n * plus repository/organization scope support; an empty relationship list means the search itself is absent.\n *\n * `issueSorts` / `issueSortsAccountWide` / `issueSearch.sorts` are the ORDERING vocabulary of those same three\n * issue reads, split the same way and for the same reason (GitLab's repo-scoped read is GraphQL and its\n * account-wide read is REST, with genuinely different sort vocabularies). Empty means the read can't be ordered,\n * so pass no `sort`; a key not listed refuses the whole read exactly like an inexpressible filter. Note a key\n * listed here is expressible on ONE provider query: a read that fans out across projects can only honor a key\n * derivable from a normalized issue, so it refuses `priority`/`dueDate`/`resolved` on top of this table.\n *\n * Note this is a CAPABILITY table — \"what the provider can express\" — not a recommendation. A consumer\n * matching another tool's behavior may deliberately pass fewer filters than are listed here (or none, where an\n * already-scoped read would only be narrowed by them). Intersecting against this table is what keeps a\n * filtered read from being refused; it isn't a directive to use every filter in it.\n */\nexport function getSupportedFilters(providerId: IntegrationIds): SupportedFilters {\n\tconst metadata = providersMetadata[providerId];\n\tconst issueSearch = metadata?.supportedIssueSearch;\n\tconst pullRequestSearch = metadata?.supportedPullRequestSearch;\n\treturn {\n\t\tpullRequests: [...(metadata?.supportedPullRequestFilters ?? [])],\n\t\tpullRequestsAccountWide: [...(metadata?.supportedAccountWidePullRequestFilters ?? [])],\n\t\tpullRequestSearch: {\n\t\t\t...unsupportedPullRequestSearchCapabilities,\n\t\t\t...pullRequestSearch,\n\t\t\trelationships: [...(pullRequestSearch?.relationships ?? [])],\n\t\t\tstates: [...(pullRequestSearch?.states ?? [])],\n\t\t\t// Copied, so mutating the result can't corrupt the metadata table.\n\t\t\tsorts: [...(pullRequestSearch?.sorts ?? [])],\n\t\t},\n\t\tissues: [...(metadata?.supportedIssueFilters ?? [])],\n\t\tissuesAccountWide: [...(metadata?.supportedAccountWideIssueFilters ?? [])],\n\t\t// Always an object, never `undefined`: a provider WITHOUT a filtered issue search reports one whose\n\t\t// `relationships` is empty and whose flags are all false, so a consumer reads capabilities the same way\n\t\t// for every provider (and an empty `relationships` is the signal to hide the surface itself).\n\t\t//\n\t\t// Spread over the all-false baseline rather than defaulting each flag: a criterion added to\n\t\t// `IssueSearchCapabilities` then can't be forgotten here and silently reported as `undefined` (which a\n\t\t// consumer's `if (caps.x)` would read as unsupported — right answer, wrong reason, and untyped).\n\t\t// `supportedIssueSearch` is typed as the complete shape, so no member can arrive as an explicit undefined.\n\t\tissueSearch: {\n\t\t\t...unsupportedIssueSearchCapabilities,\n\t\t\t...issueSearch,\n\t\t\t// Copied, so mutating the result can't corrupt the metadata table.\n\t\t\trelationships: [...(issueSearch?.relationships ?? [])],\n\t\t\tsorts: [...(issueSearch?.sorts ?? [])],\n\t\t},\n\t\tissueSorts: [...(metadata?.supportedIssueSorts ?? [])],\n\t\tissueSortsAccountWide: [...(metadata?.supportedAccountWideIssueSorts ?? [])],\n\t\tissueStates: metadata?.supportsIssueStates === true,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AA2CA,SAAg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
|
|
|
1
1
|
import { githubGraphQLInt32Max, isAzureProviderId, isGitHubProviderId } from "../providers/providerErrors.js";
|
|
2
2
|
import { isIssuesHostIntegrationId } from "../utils/integration.utils.js";
|
|
3
|
-
import { findInvalidPullRequestEtagInclude, normalizePullRequestEtagIncludes, pullRequestEtag, pullRequestEtagFieldsFromShape
|
|
3
|
+
import { findInvalidPullRequestEtagInclude, normalizePullRequestEtagIncludes, pullRequestEtag, pullRequestEtagFieldsFromShape } from "./etag.js";
|
|
4
4
|
import { isGitHostIntegration } from "../models/publicIntegration.js";
|
|
5
|
-
import { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from "./warnings.js";
|
|
5
|
+
import { gitHostOnlySurfaceWarning, otherWarning, unknownPullRequestEtagIncludeWarning, unsupportedWarning } from "./warnings.js";
|
|
6
6
|
import { getCurrentAccountIdentity, runCaptured } from "./drains.js";
|
|
7
7
|
import { readEtaggedBatch } from "./batchEtags.js";
|
|
8
8
|
import { findDuplicateKey, trimCoordinateFields, unresolvedIntegration } from "./issueBatch.js";
|
|
@@ -42,7 +42,7 @@ async function getPullRequestsBatch(ctx, options) {
|
|
|
42
42
|
const duplicateKey = findDuplicateKey(options.targets);
|
|
43
43
|
if (duplicateKey != null) return refused(otherWarning(options.providerId, void 0, options.connectionId, `Duplicate pull request batch target key '${duplicateKey}'; keys identify results, so each must be unique.`));
|
|
44
44
|
const invalidInclude = findInvalidPullRequestEtagInclude(options.etagIncludes ?? []);
|
|
45
|
-
if (invalidInclude != null) return refused(
|
|
45
|
+
if (invalidInclude != null) return refused(unknownPullRequestEtagIncludeWarning(options.providerId, void 0, options.connectionId, invalidInclude));
|
|
46
46
|
const targets = options.targets.map(trimCoordinateFields);
|
|
47
47
|
const invalid = findInvalidTarget(options.providerId, targets);
|
|
48
48
|
if (invalid != null) return refused(otherWarning(options.providerId, void 0, options.connectionId, invalid));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullRequestBatch.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestBatch.ts"],"sourcesContent":["import type { IntegrationIds } from '../constants.js';\nimport { isGitHostIntegration } from '../models/publicIntegration.js';\nimport { githubGraphQLInt32Max, isAzureProviderId, isGitHubProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning, PullRequestBatchResult, PullRequestBatchTarget } from '../results.js';\nimport { isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { readEtaggedBatch } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport type { PullRequestEtagInclude } from './etag.js';\nimport {\n\tfindInvalidPullRequestEtagInclude,\n\tnormalizePullRequestEtagIncludes,\n\tpullRequestEtag,\n\tpullRequestEtagFieldsFromShape,\n\tpullRequestEtagIncludes,\n} from './etag.js';\nimport { findDuplicateKey, trimCoordinateFields, unresolvedIntegration } from './issueBatch.js';\nimport { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from './warnings.js';\n\n/**\n * The BATCH pull request read: resolve N pull requests, in any state, BY COORDINATE — the pull-request twin of\n * `getIssuesBatch`, and for the same reason. \"Does this exact pull request exist\" is an identity question; a\n * paged list can only answer it by walking the whole scope, so a miss stays unproven and the walk repeats forever.\n * Here an absent slot is a PROVEN ABSENCE a caller can cache.\n *\n * Deliberately NOT routed through `Integration.getPullRequest`: that read answers `undefined` both when not\n * connected and on any failure, and caches through `IntegrationCacheProvider.getPullRequest`, whose key carries no\n * connection and whose by-id bucket never expires a miss.\n *\n * ONE integration call per invocation when no target carries an `etag`, whatever the target count: the manager makes\n * a single `getPullRequestsBatchResult` call and the integration fans its targets out (chunked for GitHub/GHE, one\n * request per target with bounded concurrency everywhere else) and settles each independently, so one bad target\n * never spends more than its own slot — see `GitHostIntegration.getPullRequestsBatchResult`.\n *\n * With etags, up to THREE on a host with a cheap check (GitHub/GHE, GitLab, Azure DevOps and Bitbucket Cloud so far):\n * the cheap check of the targets that carry one, a full read of the targets that don't, started alongside it, and a\n * full read of the targets whose etag no longer matches — see `readEtaggedBatch`. A host without a cheap check still\n * makes one call.\n */\n\nexport async function getPullRequestsBatch(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\ttargets: readonly PullRequestBatchTarget[];\n\t\tconnectionId?: string;\n\t\t/**\n\t\t * Explicit self-managed host domain. Used only when the requested connection has no configured domain;\n\t\t * it must come from the trusted authentication configuration, not repository or remote data.\n\t\t */\n\t\tdomain?: string;\n\t\t/**\n\t\t * Widens every etag to the listed inputs, each of which a host changes without moving the pull request's\n\t\t * update time, and each of which costs its own fields in the cheap check. `'checks'` is the check rollup.\n\t\t * Order and repeats don't matter. An unknown value refuses the whole call. Changes only which etag is\n\t\t * computed; the full read is the same. Calls that differ in this set never match each other's etags.\n\t\t */\n\t\tetagIncludes?: readonly PullRequestEtagInclude[];\n\t\t/** See {@link IntegrationManager.getPullRequestsBatch}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.getPullRequestsBatch}. */\n\t\tcheckRuns?: boolean;\n\t},\n): Promise<ProviderResult<PullRequestBatchResult>> {\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestBatchResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Batch pull request resolution';\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tif (options.targets.length === 0) return { items: [], warnings: [] };\n\n\tconst duplicateKey = findDuplicateKey(options.targets);\n\tif (duplicateKey != null) {\n\t\t// Refuses the whole call rather than deduping: two results under one key make matching ambiguous for EVERY\n\t\t// target, not just the repeated one.\n\t\treturn refused(\n\t\t\totherWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`Duplicate pull request batch target key '${duplicateKey}'; keys identify results, so each must be unique.`,\n\t\t\t),\n\t\t);\n\t}\n\n\t// Same as a bad target: refused whole before any request, naming the value and what's allowed.\n\tconst invalidInclude = findInvalidPullRequestEtagInclude(options.etagIncludes ?? []);\n\tif (invalidInclude != null) {\n\t\treturn refused(\n\t\t\totherWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`Unknown pull request etag include '${invalidInclude}'; expected one of ${pullRequestEtagIncludes.map(i => `'${i}'`).join(', ')}.`,\n\t\t\t),\n\t\t);\n\t}\n\n\t// The validated value must be the one sent to the provider, so every string field is trimmed once here.\n\tconst targets = options.targets.map(trimCoordinateFields);\n\n\t// Deterministic caller bugs, refused like a duplicate key rather than sent upstream to fail one by one.\n\tconst invalid = findInvalidTarget(options.providerId, targets);\n\tif (invalid != null) {\n\t\treturn refused(otherWarning(options.providerId, undefined, options.connectionId, invalid));\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\treturn unresolvedIntegration(ctx, options.providerId, options.connectionId, options.domain);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst etagIncludes = normalizePullRequestEtagIncludes(options.etagIncludes ?? []);\n\t// Resolved once, so the cheap check and the full read select the same data and their etags agree even if the host's\n\t// setting changes while the call is in flight.\n\tconst mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;\n\tconst checkRuns = options.checkRuns === true;\n\tconst toCoordinate = (t: PullRequestBatchTarget) => ({\n\t\towner: t.owner,\n\t\trepo: t.repo,\n\t\tnumber: t.number,\n\t\tproject: t.project,\n\t});\n\n\t// Read once per invocation, however many full reads it takes, and only when one does: a call whose every\n\t// target is unchanged has no row to resolve authorship for.\n\tlet currentAccount: Promise<{ id: string; username?: string } | undefined> | undefined;\n\n\tconst result = await readEtaggedBatch({\n\t\tproviderId: options.providerId,\n\t\tdomain: domain,\n\t\tconnectionId: options.connectionId,\n\t\ttargets: targets,\n\t\tsupportsEtags: integration.supportsPullRequestEtags,\n\t\treadFull: batch =>\n\t\t\trunCaptured(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tasync () =>\n\t\t\t\t\tintegration.getPullRequestsBatchResult(\n\t\t\t\t\t\tbatch.map(toCoordinate),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcurrentAccount: await (currentAccount ??= getCurrentAccountIdentity(\n\t\t\t\t\t\t\t\tintegration,\n\t\t\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t\t)),\n\t\t\t\t\t\t\tmergeQueue: mergeQueue,\n\t\t\t\t\t\t\tcheckRuns: checkRuns,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t),\n\t\t\t\t// A missing session must surface as a connection warning, including on the primary path, which\n\t\t\t\t// otherwise reads it as \"not connected\" and says nothing.\n\t\t\t\t{ warnOnMissingSession: true },\n\t\t\t),\n\t\treadEtagFields: batch =>\n\t\t\trunCaptured(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t() =>\n\t\t\t\t\tintegration.getPullRequestsEtagFieldsResult(\n\t\t\t\t\t\tbatch.map(toCoordinate),\n\t\t\t\t\t\t{ etagIncludes: etagIncludes, mergeQueue: mergeQueue, checkRuns: checkRuns },\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t),\n\t\t\t\t{ warnOnMissingSession: true },\n\t\t\t),\n\t\titemEtag: pr => pullRequestEtag(pullRequestEtagFieldsFromShape(pr), etagIncludes),\n\t\tfieldsEtag: fields => pullRequestEtag(fields, etagIncludes),\n\t\tunsupportedWarning: () =>\n\t\t\tunsupportedWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`${surface} is not supported by '${options.providerId}'; resolve pull requests individually instead.`,\n\t\t\t),\n\t});\n\n\treturn {\n\t\titems: result.items.map(row => ({\n\t\t\tkey: row.key,\n\t\t\t...(row.value != null ? { pullRequest: row.value } : {}),\n\t\t\t...(row.unchanged ? { unchanged: true as const } : {}),\n\t\t\t...(row.etag != null ? { etag: row.etag } : {}),\n\t\t})),\n\t\twarnings: result.warnings,\n\t\tfetchFailed: result.fetchFailed,\n\t};\n}\n\nfunction findInvalidTarget(providerId: IntegrationIds, targets: readonly PullRequestBatchTarget[]): string | undefined {\n\tconst requiresProject = isAzureProviderId(providerId);\n\tconst isGitHub = isGitHubProviderId(providerId);\n\tfor (const target of targets) {\n\t\tif (!Number.isSafeInteger(target.number) || target.number <= 0) {\n\t\t\treturn `Pull request batch target '${target.key}' has number ${target.number}; expected a positive integer.`;\n\t\t}\n\t\tif (isGitHub && target.number > githubGraphQLInt32Max) {\n\t\t\treturn `Pull request batch target '${target.key}' has number ${target.number}; GitHub numbers are 32-bit and cannot exceed ${githubGraphQLInt32Max}.`;\n\t\t}\n\t\tif (target.owner.length === 0 || target.repo.length === 0) {\n\t\t\treturn `Pull request batch target '${target.key}' requires a non-empty owner and repo.`;\n\t\t}\n\t\tif (requiresProject && !target.project) {\n\t\t\treturn `Pull request batch target '${target.key}' requires a project for '${providerId}'.`;\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,eAAsB,qBACrB,KACA,SAqBkD;CAClD,MAAM,WAAW,aAAsE;EACtF,OAAO,CAAC;EACR,UAAU,CAAC,OAAO;EAClB,aAAa;CACd;CACA,MAAM,UAAU;CAEhB,IAAI,0BAA0B,QAAQ,UAAU,GAC/C,OAAO,QAAQ,0BAA0B,QAAQ,YAAY,KAAA,GAAW,Q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AAc,OAAO,MAAM,KAAK,OAAO,UAAU,GAC5D,OAAO,8BAA8B,OAAO,IAAI,eAAe,OAAO,OAAO;EAE9E,IAAI,YAAY,OAAO,SAAA,YACtB,OAAO,8BAA8B,OAAO,IAAI,eAAe,OAAO,OAAO,gDAAgD,sBAAsB;EAEpJ,IAAI,OAAO,MAAM,WAAW,KAAK,OAAO,KAAK,WAAW,GACvD,OAAO,8BAA8B,OAAO,IAAI;EAEjD,IAAI,mBAAmB,CAAC,OAAO,SAC9B,OAAO,8BAA8B,OAAO,IAAI,4BAA4B,WAAW;CAEzF;AAED"}
|
|
1
|
+
{"version":3,"file":"pullRequestBatch.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestBatch.ts"],"sourcesContent":["import type { IntegrationIds } from '../constants.js';\nimport { isGitHostIntegration } from '../models/publicIntegration.js';\nimport { githubGraphQLInt32Max, isAzureProviderId, isGitHubProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning, PullRequestBatchResult, PullRequestBatchTarget } from '../results.js';\nimport { isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { readEtaggedBatch } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport type { PullRequestEtagInclude } from './etag.js';\nimport {\n\tfindInvalidPullRequestEtagInclude,\n\tnormalizePullRequestEtagIncludes,\n\tpullRequestEtag,\n\tpullRequestEtagFieldsFromShape,\n} from './etag.js';\nimport { findDuplicateKey, trimCoordinateFields, unresolvedIntegration } from './issueBatch.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\totherWarning,\n\tunknownPullRequestEtagIncludeWarning,\n\tunsupportedWarning,\n} from './warnings.js';\n\n/**\n * The BATCH pull request read: resolve N pull requests, in any state, BY COORDINATE — the pull-request twin of\n * `getIssuesBatch`, and for the same reason. \"Does this exact pull request exist\" is an identity question; a\n * paged list can only answer it by walking the whole scope, so a miss stays unproven and the walk repeats forever.\n * Here an absent slot is a PROVEN ABSENCE a caller can cache.\n *\n * Deliberately NOT routed through `Integration.getPullRequest`: that read answers `undefined` both when not\n * connected and on any failure, and caches through `IntegrationCacheProvider.getPullRequest`, whose key carries no\n * connection and whose by-id bucket never expires a miss.\n *\n * ONE integration call per invocation when no target carries an `etag`, whatever the target count: the manager makes\n * a single `getPullRequestsBatchResult` call and the integration fans its targets out (chunked for GitHub/GHE, one\n * request per target with bounded concurrency everywhere else) and settles each independently, so one bad target\n * never spends more than its own slot — see `GitHostIntegration.getPullRequestsBatchResult`.\n *\n * With etags, up to THREE on a host with a cheap check (GitHub/GHE, GitLab, Azure DevOps and Bitbucket Cloud so far):\n * the cheap check of the targets that carry one, a full read of the targets that don't, started alongside it, and a\n * full read of the targets whose etag no longer matches — see `readEtaggedBatch`. A host without a cheap check still\n * makes one call.\n */\n\nexport async function getPullRequestsBatch(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\ttargets: readonly PullRequestBatchTarget[];\n\t\tconnectionId?: string;\n\t\t/**\n\t\t * Explicit self-managed host domain. Used only when the requested connection has no configured domain;\n\t\t * it must come from the trusted authentication configuration, not repository or remote data.\n\t\t */\n\t\tdomain?: string;\n\t\t/**\n\t\t * Widens every etag to the listed inputs, each of which a host changes without moving the pull request's\n\t\t * update time, and each of which costs its own fields in the cheap check. `'checks'` is the check rollup.\n\t\t * Order and repeats don't matter. An unknown value refuses the whole call. Changes only which etag is\n\t\t * computed; the full read is the same. Calls that differ in this set never match each other's etags.\n\t\t */\n\t\tetagIncludes?: readonly PullRequestEtagInclude[];\n\t\t/** See {@link IntegrationManager.getPullRequestsBatch}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.getPullRequestsBatch}. */\n\t\tcheckRuns?: boolean;\n\t},\n): Promise<ProviderResult<PullRequestBatchResult>> {\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestBatchResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Batch pull request resolution';\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tif (options.targets.length === 0) return { items: [], warnings: [] };\n\n\tconst duplicateKey = findDuplicateKey(options.targets);\n\tif (duplicateKey != null) {\n\t\t// Refuses the whole call rather than deduping: two results under one key make matching ambiguous for EVERY\n\t\t// target, not just the repeated one.\n\t\treturn refused(\n\t\t\totherWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`Duplicate pull request batch target key '${duplicateKey}'; keys identify results, so each must be unique.`,\n\t\t\t),\n\t\t);\n\t}\n\n\t// Same as a bad target: refused whole before any request, naming the value and what's allowed.\n\tconst invalidInclude = findInvalidPullRequestEtagInclude(options.etagIncludes ?? []);\n\tif (invalidInclude != null) {\n\t\treturn refused(\n\t\t\tunknownPullRequestEtagIncludeWarning(options.providerId, undefined, options.connectionId, invalidInclude),\n\t\t);\n\t}\n\n\t// The validated value must be the one sent to the provider, so every string field is trimmed once here.\n\tconst targets = options.targets.map(trimCoordinateFields);\n\n\t// Deterministic caller bugs, refused like a duplicate key rather than sent upstream to fail one by one.\n\tconst invalid = findInvalidTarget(options.providerId, targets);\n\tif (invalid != null) {\n\t\treturn refused(otherWarning(options.providerId, undefined, options.connectionId, invalid));\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\treturn unresolvedIntegration(ctx, options.providerId, options.connectionId, options.domain);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst etagIncludes = normalizePullRequestEtagIncludes(options.etagIncludes ?? []);\n\t// Resolved once, so the cheap check and the full read select the same data and their etags agree even if the host's\n\t// setting changes while the call is in flight.\n\tconst mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;\n\tconst checkRuns = options.checkRuns === true;\n\tconst toCoordinate = (t: PullRequestBatchTarget) => ({\n\t\towner: t.owner,\n\t\trepo: t.repo,\n\t\tnumber: t.number,\n\t\tproject: t.project,\n\t});\n\n\t// Read once per invocation, however many full reads it takes, and only when one does: a call whose every\n\t// target is unchanged has no row to resolve authorship for.\n\tlet currentAccount: Promise<{ id: string; username?: string } | undefined> | undefined;\n\n\tconst result = await readEtaggedBatch({\n\t\tproviderId: options.providerId,\n\t\tdomain: domain,\n\t\tconnectionId: options.connectionId,\n\t\ttargets: targets,\n\t\tsupportsEtags: integration.supportsPullRequestEtags,\n\t\treadFull: batch =>\n\t\t\trunCaptured(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tasync () =>\n\t\t\t\t\tintegration.getPullRequestsBatchResult(\n\t\t\t\t\t\tbatch.map(toCoordinate),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcurrentAccount: await (currentAccount ??= getCurrentAccountIdentity(\n\t\t\t\t\t\t\t\tintegration,\n\t\t\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t\t)),\n\t\t\t\t\t\t\tmergeQueue: mergeQueue,\n\t\t\t\t\t\t\tcheckRuns: checkRuns,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t),\n\t\t\t\t// A missing session must surface as a connection warning, including on the primary path, which\n\t\t\t\t// otherwise reads it as \"not connected\" and says nothing.\n\t\t\t\t{ warnOnMissingSession: true },\n\t\t\t),\n\t\treadEtagFields: batch =>\n\t\t\trunCaptured(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t() =>\n\t\t\t\t\tintegration.getPullRequestsEtagFieldsResult(\n\t\t\t\t\t\tbatch.map(toCoordinate),\n\t\t\t\t\t\t{ etagIncludes: etagIncludes, mergeQueue: mergeQueue, checkRuns: checkRuns },\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t),\n\t\t\t\t{ warnOnMissingSession: true },\n\t\t\t),\n\t\titemEtag: pr => pullRequestEtag(pullRequestEtagFieldsFromShape(pr), etagIncludes),\n\t\tfieldsEtag: fields => pullRequestEtag(fields, etagIncludes),\n\t\tunsupportedWarning: () =>\n\t\t\tunsupportedWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`${surface} is not supported by '${options.providerId}'; resolve pull requests individually instead.`,\n\t\t\t),\n\t});\n\n\treturn {\n\t\titems: result.items.map(row => ({\n\t\t\tkey: row.key,\n\t\t\t...(row.value != null ? { pullRequest: row.value } : {}),\n\t\t\t...(row.unchanged ? { unchanged: true as const } : {}),\n\t\t\t...(row.etag != null ? { etag: row.etag } : {}),\n\t\t})),\n\t\twarnings: result.warnings,\n\t\tfetchFailed: result.fetchFailed,\n\t};\n}\n\nfunction findInvalidTarget(providerId: IntegrationIds, targets: readonly PullRequestBatchTarget[]): string | undefined {\n\tconst requiresProject = isAzureProviderId(providerId);\n\tconst isGitHub = isGitHubProviderId(providerId);\n\tfor (const target of targets) {\n\t\tif (!Number.isSafeInteger(target.number) || target.number <= 0) {\n\t\t\treturn `Pull request batch target '${target.key}' has number ${target.number}; expected a positive integer.`;\n\t\t}\n\t\tif (isGitHub && target.number > githubGraphQLInt32Max) {\n\t\t\treturn `Pull request batch target '${target.key}' has number ${target.number}; GitHub numbers are 32-bit and cannot exceed ${githubGraphQLInt32Max}.`;\n\t\t}\n\t\tif (target.owner.length === 0 || target.repo.length === 0) {\n\t\t\treturn `Pull request batch target '${target.key}' requires a non-empty owner and repo.`;\n\t\t}\n\t\tif (requiresProject && !target.project) {\n\t\t\treturn `Pull request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AAM,IAAI,KAAK,IAAI,CAAC;EAC9C,EAAE;EACF,UAAU,OAAO;EACjB,aAAa,OAAO;CACrB;AACD;AAEA,SAAS,kBAAkB,YAA4B,SAAgE;CACtH,MAAM,kBAAkB,kBAAkB,UAAU;CACpD,MAAM,WAAW,mBAAmB,UAAU;CAC9C,KAAK,MAAM,UAAU,SAAS;EAC7B,IAAI,CAAC,OAAO,cAAc,OAAO,MAAM,KAAK,OAAO,UAAU,GAC5D,OAAO,8BAA8B,OAAO,IAAI,eAAe,OAAO,OAAO;EAE9E,IAAI,YAAY,OAAO,SAAA,YACtB,OAAO,8BAA8B,OAAO,IAAI,eAAe,OAAO,OAAO,gDAAgD,sBAAsB;EAEpJ,IAAI,OAAO,MAAM,WAAW,KAAK,OAAO,KAAK,WAAW,GACvD,OAAO,8BAA8B,OAAO,IAAI;EAEjD,IAAI,mBAAmB,CAAC,OAAO,SAC9B,OAAO,8BAA8B,OAAO,IAAI,4BAA4B,WAAW;CAEzF;AAED"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PullRequestSearchCriteria
|
|
1
|
+
import { PullRequestSearchCriteria } from "../../../git/models/pullRequest.js";
|
|
2
2
|
import { IntegrationIds } from "../constants.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ProviderPullRequestSearchResult } from "../results.js";
|
|
4
4
|
import { ProviderReposInput } from "../providers/models.js";
|
|
5
5
|
import { ProviderReadContext } from "./context.js";
|
|
6
6
|
//#region ../plus/integrations/src/reads/searchPullRequests.d.ts
|
|
@@ -31,6 +31,6 @@ export declare function searchPullRequestsPage(ctx: ProviderReadContext, options
|
|
|
31
31
|
mergeQueue?: boolean;
|
|
32
32
|
/** See {@link IntegrationManager.searchPullRequestsPage}. */
|
|
33
33
|
cancellation?: AbortSignal;
|
|
34
|
-
}): Promise<
|
|
34
|
+
}): Promise<ProviderPullRequestSearchResult>;
|
|
35
35
|
//#endregion
|
|
36
36
|
//# sourceMappingURL=searchPullRequests.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CancellationError } from "../../../utils/cancellation.js";
|
|
2
|
-
import "../../../git/
|
|
2
|
+
import { effectivePullRequestSearchSort } from "../../../git/utils/pullRequest.utils.js";
|
|
3
3
|
import { mergeAssessmentInto } from "../collectionMetadata.js";
|
|
4
4
|
import { isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from "../utils/integration.utils.js";
|
|
5
5
|
import { isGitHostIntegration } from "../models/publicIntegration.js";
|
|
@@ -86,7 +86,7 @@ async function searchPullRequestsPage(ctx, options) {
|
|
|
86
86
|
truncated: drained.truncated
|
|
87
87
|
}, void 0);
|
|
88
88
|
const truncated = continuation.truncated || assessment.truncated;
|
|
89
|
-
if (truncated && warnings.length === 0) warnings.push(pullRequestSearchCapResultWarning(options.providerId, domain, options.connectionId, totalCount, options.criteria
|
|
89
|
+
if (truncated && warnings.length === 0) warnings.push(pullRequestSearchCapResultWarning(options.providerId, domain, options.connectionId, totalCount, effectivePullRequestSearchSort(options.criteria), limitReached) ?? truncationWarning(options.providerId, domain, options.connectionId, "Pull request search", "exhausted"));
|
|
90
90
|
return {
|
|
91
91
|
items,
|
|
92
92
|
warnings,
|
|
@@ -102,7 +102,8 @@ async function searchPullRequestsPage(ctx, options) {
|
|
|
102
102
|
},
|
|
103
103
|
hasMore: continuation.hasMore,
|
|
104
104
|
cursor: continuation.cursor,
|
|
105
|
-
fetchFailed: drained.fetchFailed || assessment.fetchFailed || void 0
|
|
105
|
+
fetchFailed: drained.fetchFailed || assessment.fetchFailed || void 0,
|
|
106
|
+
openCount: requestedPageMissing ? void 0 : value?.openCount
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchPullRequests.js","names":[],"sources":["../../../../../plus/integrations/src/reads/searchPullRequests.ts"],"sourcesContent":["import type { PullRequestSearchCriteria, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { defaultPullRequestSort } from '@gitlens/git/models/pullRequest.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { isGitHostIntegration } from '../models/publicIntegration.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport type { ProviderPagedResult, ProviderWarning } from '../results.js';\nimport { isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from './filters.js';\nimport {\n\tdrainFlatPagesToRequestedPage,\n\trefusedPage,\n\tresolveContinuation,\n\tresolveCurrentPage,\n\tusableCursor,\n} from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\totherWarning,\n\tpullRequestSearchCapResultWarning,\n\ttruncationWarning,\n\tunsupportedPullRequestSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * Pull requests matching structured criteria over a repository/organization or current-user relationship scope.\n *\n * The read is deliberately separate from `listPullRequestsPage`: the list has provider-specific \"my PRs\"\n * semantics and no text channel, while this method promises a sanitized query, an ordering the caller chooses\n * (`criteria.sort`, defaulting to most-recently-updated-first) and that is applied to the merged page as a whole,\n * one upstream request per cursor-threaded page, and a quantified omission at the provider's result ceiling that\n * names the order the reachable window was selected under.\n */\nexport async function searchPullRequestsPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\trepos?: ProviderReposInput;\n\t\torg?: string;\n\t\tcriteria?: PullRequestSearchCriteria;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\t/** Per relationship × state facet, not per page; see {@link IntegrationManager.searchPullRequestsPage}. */\n\t\titemsPerPage?: number;\n\t\tforceSync?: boolean;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tsummary?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tcancellation?: AbortSignal;\n\t},\n): Promise<ProviderPagedResult<PullRequestShape>> {\n\tconst cancellation = options.cancellation;\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tconst refused = (warning: ProviderWarning) => refusedPage<PullRequestShape>(1, [warning], true);\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\t// Every refusal below resolves as a failed page, which a cancelled caller must never receive.\n\tif (cancellation?.aborted) throw new CancellationError();\n\tif (integration == null) {\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(1, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\n\n\tconst resolved = resolvePullRequestSearchCriteria(options.providerId, options.criteria);\n\tif (resolved.rejection != null) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tresolved.rejection,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst scope = resolvePullRequestSearchScope(options.providerId, options.repos, options.org, options.criteria);\n\tswitch (scope.rejection?.reason) {\n\t\tcase 'unscoped':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search must be scoped: pass `repos`, `org`, or at least one current-user relationship.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'repo-ids':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search cannot be scoped by repository id; pass repository descriptors (namespace + name) instead.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'unsupported-repository-scope':\n\t\tcase 'unsupported-organization-scope':\n\t\t\treturn refused(\n\t\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\t\treason: 'unsupported-criteria',\n\t\t\t\t\tcriteria: [\n\t\t\t\t\t\tscope.rejection.reason === 'unsupported-repository-scope'\n\t\t\t\t\t\t\t? 'repositoryScope'\n\t\t\t\t\t\t\t: 'organizationScope',\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t// A scope the query cannot spell, refused rather than sanitized — see `isUsableSearchScopeName`.\n\t\tcase 'unusable-scope':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\tunusableSearchScopeMessage('pull request search scopes', scope.rejection.scopes),\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tconst readPage = async (cursor: string | undefined) => {\n\t\tconst read = await runCaptured(\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\t() =>\n\t\t\t\tintegration.searchPullRequestsPageResult(\n\t\t\t\t\t{\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: options.org,\n\t\t\t\t\t\tcriteria: options.criteria,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tpageSize: options.itemsPerPage,\n\t\t\t\t\t\tsummary: options.summary,\n\t\t\t\t\t\tmergeQueue: options.mergeQueue,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\t\t// The aborted request comes back as a failed read; a cancelled caller is owed the cancellation instead, and\n\t\t// a drain walking to a page number must stop here rather than read its next page.\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn read;\n\t};\n\n\tconst first = await readPage(options.cursor);\n\tconst warnings = first.warning != null ? [first.warning] : [];\n\tlet totalCount = first.value?.totalCount;\n\t// Facets whose rows are missing while their siblings answered. A page reports the walk's completeness so far, not\n\t// just its own requests: a failure dropped for good repeats on every later page, while one that recovered on a\n\t// retry drops out because its rows came back. So the latest page read is the one to assess, including when a later\n\t// page fails the walk outright — never union the pages, which would bring a recovered failure back.\n\tlet lastMetadata = first.value?.metadata;\n\tlet limitReached = first.value?.limitReached === true;\n\tconst drained = await drainFlatPagesToRequestedPage(first, {\n\t\trequestedPage: page,\n\t\tsuppliedCursor: options.cursor,\n\t\twarnings: warnings,\n\t\treadPage: readPage,\n\t\tfold: p => {\n\t\t\tif (p.totalCount != null) {\n\t\t\t\ttotalCount = Math.max(totalCount ?? 0, p.totalCount);\n\t\t\t}\n\t\t\tlastMetadata = p.metadata;\n\t\t\tlimitReached ||= p.limitReached === true;\n\t\t},\n\t});\n\tconst { value, currentPage, requestedPageMissing } = drained;\n\tconst assessment = mergeAssessmentInto(warnings, options.providerId, domain, options.connectionId, lastMetadata);\n\n\tif (value == null && warnings.length === 0) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\treason: 'unsupported-search',\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst items = requestedPageMissing ? [] : (value?.values ?? []);\n\tconst continuation = resolveContinuation(\n\t\t{\n\t\t\thasMore: requestedPageMissing ? false : (value?.hasMore ?? false),\n\t\t\tcursor: requestedPageMissing ? undefined : usableCursor(value?.cursor),\n\t\t\ttruncated: drained.truncated,\n\t\t},\n\t\tundefined,\n\t);\n\t// A facet that failed while its siblings answered leaves the result incomplete, as `listPullRequestsPage` reports\n\t// it; its warning is already in `warnings`, so it adds no generic one below.\n\tconst truncated = continuation.truncated || assessment.truncated;\n\tif (truncated && warnings.length === 0) {\n\t\twarnings.push(\n\t\t\tpullRequestSearchCapResultWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\ttotalCount,\n\t\t\t\toptions.criteria?.sort ?? defaultPullRequestSort,\n\t\t\t\tlimitReached,\n\t\t\t) ??\n\t\t\t\ttruncationWarning(options.providerId, domain, options.connectionId, 'Pull request search', 'exhausted'),\n\t\t);\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tpage: {\n\t\t\tcurrentPage: requestedPageMissing\n\t\t\t\t? page\n\t\t\t\t: resolveCurrentPage({\n\t\t\t\t\t\tproviderPage: currentPage,\n\t\t\t\t\t\trequestedPage: page,\n\t\t\t\t\t\tsuppliedCursor: options.cursor,\n\t\t\t\t\t\tpageAdvanceable: false,\n\t\t\t\t\t}),\n\t\t\titemsPerPage: items.length,\n\t\t\ttruncated: truncated || undefined,\n\t\t},\n\t\thasMore: continuation.hasMore,\n\t\tcursor: continuation.cursor,\n\t\tfetchFailed: drained.fetchFailed || assessment.fetchFailed || undefined,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,uBACrB,KACA,SA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,UAAU,QAAQ,YAAY,QAAQ,QAAQ,cAAc,YAAY;CAE/G,IAAI,SAAS,QAAQ,SAAS,WAAW,GACxC,OAAO,QACN,4CAA4C,QAAQ,YAAY,QAAQ,QAAQ,cAAc,EAC7F,QAAQ,qBACT,CAAC,CACF;CAGD,MAAM,QAAQ,uBAAuB,CAAC,IAAK,OAAO,UAAU,CAAC;CAC7D,MAAM,eAAe,oBACpB;EACC,SAAS,uBAAuB,QAAS,OAAO,WAAW;EAC3D,QAAQ,uBAAuB,KAAA,IAAY,aAAa,OAAO,MAAM;EACrE,WAAW,QAAQ;CACpB,GACA,KAAA,CACD;CAGA,MAAM,YAAY,aAAa,aAAa,WAAW;CACvD,IAAI,aAAa,SAAS,WAAW,GACpC,SAAS,KACR,kCACC,QAAQ,YACR,QACA,QAAQ,cACR,YACA,QAAQ,UAAU,QAAA,gBAClB,YACD,KACC,kBAAkB,QAAQ,YAAY,QAAQ,QAAQ,cAAc,uBAAuB,WAAW,CACxG;CAGD,OAAO;EACC;EACG;EACV,MAAM;GACL,aAAa,uBACV,OACA,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,gBAAgB,QAAQ;IACxB,iBAAiB;GAClB,CAAC;GACH,cAAc,MAAM;GACpB,WAAW,aAAa,KAAA;EACzB;EACA,SAAS,aAAa;EACtB,QAAQ,aAAa;EACrB,aAAa,QAAQ,eAAe,WAAW,eAAe,KAAA;CAC/D;AACD"}
|
|
1
|
+
{"version":3,"file":"searchPullRequests.js","names":[],"sources":["../../../../../plus/integrations/src/reads/searchPullRequests.ts"],"sourcesContent":["import type { PullRequestSearchCriteria, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { effectivePullRequestSearchSort } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { isGitHostIntegration } from '../models/publicIntegration.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport type { ProviderPullRequestSearchResult, ProviderWarning } from '../results.js';\nimport { isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from './filters.js';\nimport {\n\tdrainFlatPagesToRequestedPage,\n\trefusedPage,\n\tresolveContinuation,\n\tresolveCurrentPage,\n\tusableCursor,\n} from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\totherWarning,\n\tpullRequestSearchCapResultWarning,\n\ttruncationWarning,\n\tunsupportedPullRequestSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * Pull requests matching structured criteria over a repository/organization or current-user relationship scope.\n *\n * The read is deliberately separate from `listPullRequestsPage`: the list has provider-specific \"my PRs\"\n * semantics and no text channel, while this method promises a sanitized query, an ordering the caller chooses\n * (`criteria.sort`, defaulting to most-recently-updated-first) and that is applied to the merged page as a whole,\n * one upstream request per cursor-threaded page, and a quantified omission at the provider's result ceiling that\n * names the order the reachable window was selected under.\n */\nexport async function searchPullRequestsPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\trepos?: ProviderReposInput;\n\t\torg?: string;\n\t\tcriteria?: PullRequestSearchCriteria;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\t/** Per relationship × state facet, not per page; see {@link IntegrationManager.searchPullRequestsPage}. */\n\t\titemsPerPage?: number;\n\t\tforceSync?: boolean;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tsummary?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tcancellation?: AbortSignal;\n\t},\n): Promise<ProviderPullRequestSearchResult> {\n\tconst cancellation = options.cancellation;\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tconst refused = (warning: ProviderWarning) => refusedPage<PullRequestShape>(1, [warning], true);\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\t// Every refusal below resolves as a failed page, which a cancelled caller must never receive.\n\tif (cancellation?.aborted) throw new CancellationError();\n\tif (integration == null) {\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(1, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\n\n\tconst resolved = resolvePullRequestSearchCriteria(options.providerId, options.criteria);\n\tif (resolved.rejection != null) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tresolved.rejection,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst scope = resolvePullRequestSearchScope(options.providerId, options.repos, options.org, options.criteria);\n\tswitch (scope.rejection?.reason) {\n\t\tcase 'unscoped':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search must be scoped: pass `repos`, `org`, or at least one current-user relationship.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'repo-ids':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search cannot be scoped by repository id; pass repository descriptors (namespace + name) instead.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'unsupported-repository-scope':\n\t\tcase 'unsupported-organization-scope':\n\t\t\treturn refused(\n\t\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\t\treason: 'unsupported-criteria',\n\t\t\t\t\tcriteria: [\n\t\t\t\t\t\tscope.rejection.reason === 'unsupported-repository-scope'\n\t\t\t\t\t\t\t? 'repositoryScope'\n\t\t\t\t\t\t\t: 'organizationScope',\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t// A scope the query cannot spell, refused rather than sanitized — see `isUsableSearchScopeName`.\n\t\tcase 'unusable-scope':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\tunusableSearchScopeMessage('pull request search scopes', scope.rejection.scopes),\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tconst readPage = async (cursor: string | undefined) => {\n\t\tconst read = await runCaptured(\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\t() =>\n\t\t\t\tintegration.searchPullRequestsPageResult(\n\t\t\t\t\t{\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: options.org,\n\t\t\t\t\t\tcriteria: options.criteria,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tpageSize: options.itemsPerPage,\n\t\t\t\t\t\tsummary: options.summary,\n\t\t\t\t\t\tmergeQueue: options.mergeQueue,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\t\t// The aborted request comes back as a failed read; a cancelled caller is owed the cancellation instead, and\n\t\t// a drain walking to a page number must stop here rather than read its next page.\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn read;\n\t};\n\n\tconst first = await readPage(options.cursor);\n\tconst warnings = first.warning != null ? [first.warning] : [];\n\tlet totalCount = first.value?.totalCount;\n\t// Facets whose rows are missing while their siblings answered. A page reports the walk's completeness so far, not\n\t// just its own requests: a failure dropped for good repeats on every later page, while one that recovered on a\n\t// retry drops out because its rows came back. So the latest page read is the one to assess, including when a later\n\t// page fails the walk outright — never union the pages, which would bring a recovered failure back.\n\tlet lastMetadata = first.value?.metadata;\n\tlet limitReached = first.value?.limitReached === true;\n\tconst drained = await drainFlatPagesToRequestedPage(first, {\n\t\trequestedPage: page,\n\t\tsuppliedCursor: options.cursor,\n\t\twarnings: warnings,\n\t\treadPage: readPage,\n\t\tfold: p => {\n\t\t\tif (p.totalCount != null) {\n\t\t\t\ttotalCount = Math.max(totalCount ?? 0, p.totalCount);\n\t\t\t}\n\t\t\tlastMetadata = p.metadata;\n\t\t\tlimitReached ||= p.limitReached === true;\n\t\t},\n\t});\n\tconst { value, currentPage, requestedPageMissing } = drained;\n\tconst assessment = mergeAssessmentInto(warnings, options.providerId, domain, options.connectionId, lastMetadata);\n\n\tif (value == null && warnings.length === 0) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\treason: 'unsupported-search',\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst items = requestedPageMissing ? [] : (value?.values ?? []);\n\tconst continuation = resolveContinuation(\n\t\t{\n\t\t\thasMore: requestedPageMissing ? false : (value?.hasMore ?? false),\n\t\t\tcursor: requestedPageMissing ? undefined : usableCursor(value?.cursor),\n\t\t\ttruncated: drained.truncated,\n\t\t},\n\t\tundefined,\n\t);\n\t// A facet that failed while its siblings answered leaves the result incomplete, as `listPullRequestsPage` reports\n\t// it; its warning is already in `warnings`, so it adds no generic one below.\n\tconst truncated = continuation.truncated || assessment.truncated;\n\tif (truncated && warnings.length === 0) {\n\t\twarnings.push(\n\t\t\tpullRequestSearchCapResultWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\ttotalCount,\n\t\t\t\teffectivePullRequestSearchSort(options.criteria),\n\t\t\t\tlimitReached,\n\t\t\t) ??\n\t\t\t\ttruncationWarning(options.providerId, domain, options.connectionId, 'Pull request search', 'exhausted'),\n\t\t);\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tpage: {\n\t\t\tcurrentPage: requestedPageMissing\n\t\t\t\t? page\n\t\t\t\t: resolveCurrentPage({\n\t\t\t\t\t\tproviderPage: currentPage,\n\t\t\t\t\t\trequestedPage: page,\n\t\t\t\t\t\tsuppliedCursor: options.cursor,\n\t\t\t\t\t\tpageAdvanceable: false,\n\t\t\t\t\t}),\n\t\t\titemsPerPage: items.length,\n\t\t\ttruncated: truncated || undefined,\n\t\t},\n\t\thasMore: continuation.hasMore,\n\t\tcursor: continuation.cursor,\n\t\tfetchFailed: drained.fetchFailed || assessment.fetchFailed || undefined,\n\t\topenCount: requestedPageMissing ? undefined : value?.openCount,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,uBACrB,KACA,SAmB2C;CAC3C,MAAM,eAAe,QAAQ;CAC7B,IAAI,cAAc,SAAS,MAAM,IAAI,kBAAkB;CAEvD,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,QAAQ,CAAC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AC7F,QAAQ,qBACT,CAAC,CACF;CAGD,MAAM,QAAQ,uBAAuB,CAAC,IAAK,OAAO,UAAU,CAAC;CAC7D,MAAM,eAAe,oBACpB;EACC,SAAS,uBAAuB,QAAS,OAAO,WAAW;EAC3D,QAAQ,uBAAuB,KAAA,IAAY,aAAa,OAAO,MAAM;EACrE,WAAW,QAAQ;CACpB,GACA,KAAA,CACD;CAGA,MAAM,YAAY,aAAa,aAAa,WAAW;CACvD,IAAI,aAAa,SAAS,WAAW,GACpC,SAAS,KACR,kCACC,QAAQ,YACR,QACA,QAAQ,cACR,YACA,+BAA+B,QAAQ,QAAQ,GAC/C,YACD,KACC,kBAAkB,QAAQ,YAAY,QAAQ,QAAQ,cAAc,uBAAuB,WAAW,CACxG;CAGD,OAAO;EACC;EACG;EACV,MAAM;GACL,aAAa,uBACV,OACA,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,gBAAgB,QAAQ;IACxB,iBAAiB;GAClB,CAAC;GACH,cAAc,MAAM;GACpB,WAAW,aAAa,KAAA;EACzB;EACA,SAAS,aAAa;EACtB,QAAQ,aAAa;EACrB,aAAa,QAAQ,eAAe,WAAW,eAAe,KAAA;EAC9D,WAAW,uBAAuB,KAAA,IAAY,OAAO;CACtD;AACD"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { mapBounded } from "../../../utils/promise.js";
|
|
2
|
+
import { PullRequest } from "../../../git/models/pullRequest.js";
|
|
3
|
+
import { isGitHubProviderId } from "../providers/providerErrors.js";
|
|
2
4
|
import { appendDedupedWarning } from "../results.js";
|
|
5
|
+
import { isPullRequestRowAsCompleteAsBatch } from "../fieldPresence.js";
|
|
3
6
|
import "../providers/utils/providerPaging.js";
|
|
4
7
|
import { isIssuesHostIntegrationId } from "../utils/integration.utils.js";
|
|
5
8
|
import { toPullRequestRow } from "../providers/models.js";
|
|
9
|
+
import { findInvalidPullRequestEtagInclude, pullRequestEtag, pullRequestEtagFieldsFromShape } from "./etag.js";
|
|
6
10
|
import { isGitHostIntegration } from "../models/publicIntegration.js";
|
|
7
|
-
import { gitHostOnlySurfaceWarning, noConnectionWarning, unsupportedAccountWidePullRequestFiltersWarning, unsupportedFiltersWarning } from "./warnings.js";
|
|
11
|
+
import { gitHostOnlySurfaceWarning, noConnectionWarning, unknownPullRequestEtagIncludeWarning, unsupportedAccountWidePullRequestFiltersWarning, unsupportedFiltersWarning } from "./warnings.js";
|
|
8
12
|
import { drainPullRequests, getPullRequestViewers, resolvePullRequestSweepTargets } from "./drains.js";
|
|
9
13
|
import { resolveAccountWidePullRequestFilters, resolvePullRequestFilters } from "./filters.js";
|
|
10
14
|
//#region ../plus/integrations/src/reads/sweeps.ts
|
|
15
|
+
function withEtag(row, etag) {
|
|
16
|
+
return Object.assign(Object.create(PullRequest.prototype), row, { etag });
|
|
17
|
+
}
|
|
11
18
|
/**
|
|
12
19
|
* Drain ONE sweep target. Extracted from the fan-out so the fan-out callback has a single exit: every
|
|
13
20
|
* per-target observation (see `onTargetSettled`) is then reported in one place instead of at each of this
|
|
@@ -20,7 +27,6 @@ async function sweepTarget(ctx, options, target, attributeUnavailableProviders)
|
|
|
20
27
|
const { providerId: id, connectionId, domain: requestedDomain } = target;
|
|
21
28
|
const repos = target.repos ?? options?.repos ?? [];
|
|
22
29
|
const maxPages = options?.maxPages ?? 100;
|
|
23
|
-
/** A target that never reached a drain: the provider itself failed, so its slice is empty and attributed. */
|
|
24
30
|
const rejectedTarget = (warnings) => ({
|
|
25
31
|
items: [],
|
|
26
32
|
warnings,
|
|
@@ -43,15 +49,23 @@ async function sweepTarget(ctx, options, target, attributeUnavailableProviders)
|
|
|
43
49
|
const requestedFilters = target.filters ?? options?.filters;
|
|
44
50
|
const resolved = accountWide ? resolveAccountWidePullRequestFilters(id, requestedFilters) : resolvePullRequestFilters(id, requestedFilters);
|
|
45
51
|
if (resolved.unsupported) return rejectedTarget([accountWide ? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? []) : unsupportedFiltersWarning(id, domain, connectionId)]);
|
|
52
|
+
const etagIncludes = options?.etagIncludes;
|
|
53
|
+
const invalidInclude = etagIncludes != null ? findInvalidPullRequestEtagInclude(etagIncludes) : void 0;
|
|
54
|
+
if (invalidInclude != null) return rejectedTarget([unknownPullRequestEtagIncludeWarning(id, domain, connectionId, invalidInclude)]);
|
|
46
55
|
const drain = await drainPullRequests(integration, id, domain, repos, options?.states, resolved.filters, options, connectionId, maxPages, attributeUnavailableProviders);
|
|
47
56
|
const viewers = await getPullRequestViewers(integration, connectionId, drain.items);
|
|
48
57
|
const projection = accountWide ? options?.includeReviews ? "account" : "account-summary" : "repos";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
const mergeQueue = etagIncludes != null && (options?.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true);
|
|
59
|
+
const items = drain.items.map((pr, i) => {
|
|
60
|
+
const row = toPullRequestRow(pr, integration, {
|
|
52
61
|
currentAccount: viewers[i],
|
|
53
62
|
projection
|
|
54
|
-
})
|
|
63
|
+
});
|
|
64
|
+
return etagIncludes != null && isGitHubProviderId(id) && isPullRequestRowAsCompleteAsBatch(row, { mergeQueue }) ? withEtag(row, pullRequestEtag(pullRequestEtagFieldsFromShape(row), etagIncludes)) : row;
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
...drain,
|
|
68
|
+
items,
|
|
55
69
|
providerId: id
|
|
56
70
|
};
|
|
57
71
|
}
|