@gitkraken/core-gitlens 0.40.0 → 0.43.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 +25 -1
- package/dist/git/models/issue.d.ts +2 -0
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts +4 -0
- package/dist/git/models/pullRequest.d.ts +57 -1
- package/dist/git/models/pullRequest.js +5 -1
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/pullRequestActivity.d.ts +55 -0
- package/dist/git/models/pullRequestActivity.js +0 -0
- package/dist/git/utils/pullRequest.utils.js +3 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +1 -0
- package/dist/git/watching/worktreeSummary.js +34 -2
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +19 -0
- package/dist/plus/git-github/api/aliasedQuery.js +21 -0
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -0
- package/dist/plus/git-github/api/cancellation.d.ts +4 -0
- package/dist/plus/git-github/api/cancellation.js +9 -0
- package/dist/plus/git-github/api/cancellation.js.map +1 -0
- package/dist/plus/git-github/api/checkRunLogs.d.ts +31 -0
- package/dist/plus/git-github/api/checkRunLogs.js +252 -0
- package/dist/plus/git-github/api/checkRunLogs.js.map +1 -0
- package/dist/plus/git-github/api/checkRuns.d.ts +26 -0
- package/dist/plus/git-github/api/checkRuns.js +191 -0
- package/dist/plus/git-github/api/checkRuns.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +23 -6
- package/dist/plus/git-github/api/github.js +174 -39
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +3 -2
- package/dist/plus/git-github/api/issueWrites.js +10 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestActivity.d.ts +19 -0
- package/dist/plus/git-github/api/pullRequestActivity.js +355 -0
- package/dist/plus/git-github/api/pullRequestActivity.js.map +1 -0
- package/dist/plus/git-github/models.d.ts +100 -4
- package/dist/plus/git-github/models.js +142 -6
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +10 -5
- package/dist/plus/integrations/fieldPresence.js +46 -25
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +5 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +26 -1
- package/dist/plus/integrations/integrationService.js +22 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +86 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +68 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +21 -2
- package/dist/plus/integrations/models/integration.js +20 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +20 -14
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.js +7 -3
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +18 -13
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +15 -6
- package/dist/plus/integrations/providers/github.js +65 -5
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +12 -6
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.js +5 -2
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/models.js +9 -4
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +10 -7
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.js +3 -1
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/etag.js +20 -5
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestActivity.d.ts +36 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js +103 -0
- package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -0
- package/dist/plus/integrations/reads/pullRequestBatch.d.ts +4 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +5 -2
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -0
- package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +27 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js +92 -0
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -0
- package/docs/integrations.md +111 -14
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../constants.js";
|
|
2
2
|
import { getIssueFieldPresence } from "../fieldPresence.js";
|
|
3
3
|
import { issueNamesPeople } from "../providers/models.js";
|
|
4
|
-
import { issueEtagIncludes, linearSyncedWithEtagKeys, pullRequestEtagIncludes, pullRequestRevision } from "../models/integration.js";
|
|
4
|
+
import { issueEtagIncludes, linearSyncedWithEtagKeys, pullRequestCheckRunsEtag, pullRequestEtagIncludes, pullRequestRevision } from "../models/integration.js";
|
|
5
5
|
//#region ../plus/integrations/src/reads/etag.ts
|
|
6
6
|
/**
|
|
7
7
|
* The etags the batch reads hand back (`getPullRequestsBatch`, `getIssuesBatch`): an opaque stamp of an item's
|
|
@@ -9,10 +9,11 @@ import { issueEtagIncludes, linearSyncedWithEtagKeys, pullRequestEtagIncludes, p
|
|
|
9
9
|
*
|
|
10
10
|
* Computed by core, never the provider's HTTP ETag, and from the fields alone — not the item's id, since the
|
|
11
11
|
* caller's key already identifies the target and ids cross vocabularies between reads. Not hashed: the stamp IS
|
|
12
|
-
* the serialized fields, so two different change states can never collide into a false `unchanged` — except for
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* the serialized fields, so two different change states can never collide into a false `unchanged` — except for two
|
|
13
|
+
* 64-bit hashes, where a collision (about 2^-64) is the only way a change can hide: an Azure DevOps pull request's
|
|
14
|
+
* `revision`, of the fields Azure changes without a timestamp, and a GitHub pull request's `checkRuns`, of its head's
|
|
15
|
+
* checks, which keeps the stamp the same length at any number of checks. The prefix names the scheme (`pr1`, `is1`)
|
|
16
|
+
* and every include it covers ({@link PullRequestEtagInclude}, {@link IssueEtagInclude}), in canonical order
|
|
16
17
|
* (`pr1+mergeable+checks:`, `is1+reactions:`), so two different sets can never collide even when their values do (a
|
|
17
18
|
* `null` mergeability and a `null` rollup). A stamp from another scheme or another set just compares unequal and
|
|
18
19
|
* costs a full read.
|
|
@@ -40,6 +41,7 @@ function pullRequestEtagFieldsFromShape(pr) {
|
|
|
40
41
|
};
|
|
41
42
|
if (pr.mergeQueueRemoval != null) fields.mergeQueueRemovedAt = pr.mergeQueueRemoval.removedAt;
|
|
42
43
|
if (pr.mergeQueueRequired != null) fields.mergeQueueRead = true;
|
|
44
|
+
if (pr.checkRuns != null) fields.checkRuns = pullRequestCheckRunsEtag(pr.checkRuns, pr.checkRunsTruncated === true);
|
|
43
45
|
return fields;
|
|
44
46
|
}
|
|
45
47
|
function issueEtagFieldsFromShape(issue) {
|
|
@@ -87,6 +89,19 @@ function pullRequestEtag(fields, includes) {
|
|
|
87
89
|
]);
|
|
88
90
|
if (fields.mergeQueueRemovedAt != null) state.push(["merge-queue-removed", timeOf(fields.mergeQueueRemovedAt)]);
|
|
89
91
|
if (fields.mergeQueueRead) state.push(["merge-queue-read"]);
|
|
92
|
+
if (fields.checkRuns != null) {
|
|
93
|
+
const { hash, count, truncated } = fields.checkRuns;
|
|
94
|
+
state.push(truncated ? [
|
|
95
|
+
"check-runs",
|
|
96
|
+
hash,
|
|
97
|
+
count,
|
|
98
|
+
"truncated"
|
|
99
|
+
] : [
|
|
100
|
+
"check-runs",
|
|
101
|
+
hash,
|
|
102
|
+
count
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
90
105
|
if (covered.length === 0) return `pr1:${JSON.stringify(state)}`;
|
|
91
106
|
for (const include of covered) switch (include) {
|
|
92
107
|
case "mergeable":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etag.js","names":[],"sources":["../../../../../plus/integrations/src/reads/etag.ts"],"sourcesContent":["import type { IssueShape } from '@gitlens/git/models/issue.js';\nimport type { PullRequest, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n} from '../constants.js';\nimport { getIssueFieldPresence } from '../fieldPresence.js';\nimport type {\n\tIssueEtagFields,\n\tIssueEtagInclude,\n\tPullRequestEtagFields,\n\tPullRequestEtagInclude,\n} from '../models/integration.js';\nimport {\n\tazureWorkItemDescriptionRule,\n\tazureWorkItemViewerRule,\n\tissueEtagIncludes,\n\tlinearSyncedWithEtagKeys,\n\tpullRequestEtagIncludes,\n\tpullRequestRevision,\n} from '../models/integration.js';\nimport { issueNamesPeople } from '../providers/models.js';\n\n/**\n * The etags the batch reads hand back (`getPullRequestsBatch`, `getIssuesBatch`): an opaque stamp of an item's\n * change state, which a caller sends back so a cheap check can answer \"unchanged\" without a full read.\n *\n * Computed by core, never the provider's HTTP ETag, and from the fields alone — not the item's id, since the\n * caller's key already identifies the target and ids cross vocabularies between reads. Not hashed: the stamp IS\n * the serialized fields, so two different change states can never collide into a false `unchanged` — except for an\n * Azure DevOps pull request's `revision`, a 64-bit hash of the fields Azure changes without a timestamp, where a\n * collision (about 2^-64) is the only way a change can hide. The prefix names the scheme (`pr1`, `is1`) and every\n * include it covers ({@link PullRequestEtagInclude}, {@link IssueEtagInclude}), in canonical order\n * (`pr1+mergeable+checks:`, `is1+reactions:`), so two different sets can never collide even when their values do (a\n * `null` mergeability and a `null` rollup). A stamp from another scheme or another set just compares unequal and\n * costs a full read.\n */\n\n/**\n * Azure DevOps: a pull request there keeps no update time, so its etag adds a {@link pullRequestRevision}, and a work\n * item's etag adds the rule its body is read by (see `azureWorkItemDescriptionRule`).\n */\nconst azureProviderIds: ReadonlySet<string> = new Set([\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n]);\n\nexport function pullRequestEtagFieldsFromShape(pr: PullRequestShape): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: pr.state,\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: pr.updatedDate,\n\t\theadSha: pr.refs?.head.sha,\n\t\tmergeableState: pr.mergeableState,\n\t\treviewDecision: pr.reviewDecision,\n\t\t// On the class, not the shape: every provider's mapper builds a `PullRequest`. Read by name rather than by\n\t\t// `instanceof`, which a second copy of the model module fails, silently dropping the rollup from every full\n\t\t// row's etag so that no cheap check ever matches it again.\n\t\tstatusCheckRollupState: 'statusCheckRollupState' in pr ? (pr as PullRequest).statusCheckRollupState : undefined,\n\t};\n\t// Read defensively, as `timeOf` reads the date: a row without a provider must not fail the read.\n\tif (pr.provider != null && azureProviderIds.has(pr.provider.id)) {\n\t\tfields.revision = pullRequestRevision(pr);\n\t}\n\tif (pr.viewerUnresolved) {\n\t\tfields.viewerUnresolved = true;\n\t}\n\tif (pr.mergeQueue != null) {\n\t\tfields.mergeQueue = { state: pr.mergeQueue.state, enqueuedAt: pr.mergeQueue.enqueuedAt };\n\t}\n\tif (pr.mergeQueueRemoval != null) {\n\t\tfields.mergeQueueRemovedAt = pr.mergeQueueRemoval.removedAt;\n\t}\n\t// `mergeQueueRequired` is GitHub's non-null `isMergeQueueEnabled`, so only a row from a read that selected the\n\t// merge-queue data has it.\n\tif (pr.mergeQueueRequired != null) {\n\t\tfields.mergeQueueRead = true;\n\t}\n\treturn fields;\n}\n\nexport function issueEtagFieldsFromShape(issue: IssueShape): IssueEtagFields {\n\tconst fields: IssueEtagFields = { state: issue.state, updatedDate: issue.updatedDate };\n\t// Only where the row's read really fetched reactions: elsewhere a count is a placeholder or a tracker's votes,\n\t// which no cheap check reads, so taking it would fail every check of that row under `'reactions'`.\n\tif (\n\t\tissue.thumbsUpCount != null &&\n\t\tissue.provider != null &&\n\t\tgetIssueFieldPresence(issue)?.reactions === 'fetched'\n\t) {\n\t\tfields.thumbsUpCount = issue.thumbsUpCount;\n\t}\n\tif (issue.provider != null && azureProviderIds.has(issue.provider.id)) {\n\t\tfields.descriptionRule = azureWorkItemDescriptionRule;\n\t\t// A row read while its organization's identity couldn't be must not compare unchanged, or it would be kept\n\t\t// without a viewer until the work item changes. Also a row that names someone and has neither field: one held\n\t\t// from before `viewerUnresolved` existed.\n\t\tif (!issue.viewerUnresolved && (issue.viewer != null || !issueNamesPeople(issue))) {\n\t\t\tfields.viewerRule = azureWorkItemViewerRule;\n\t\t}\n\t}\n\tif (issue.provider?.id === IssuesCloudHostIntegrationId.Linear) {\n\t\tfields.syncedWithKeys = issue.syncedWith != null ? linearSyncedWithEtagKeys(issue.syncedWith) : null;\n\t}\n\treturn fields;\n}\n\n/**\n * The distinct `includes` in canonical order, whatever order and repetition the caller gave. Values it doesn't know\n * are dropped, so a caller validates them first (see {@link findInvalidPullRequestEtagInclude}).\n */\nexport function normalizePullRequestEtagIncludes(\n\tincludes: readonly PullRequestEtagInclude[],\n): readonly PullRequestEtagInclude[] {\n\treturn pullRequestEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't a {@link PullRequestEtagInclude}, if any. */\nexport function findInvalidPullRequestEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(pullRequestEtagIncludes as readonly string[]).includes(include));\n}\n\n/**\n * Each of `includes` adds one input — mergeability, review decision or check rollup — which a host may change\n * without moving `updatedDate`. An input that isn't listed is left out, so its churn never forces a full read.\n */\nexport function pullRequestEtag(fields: PullRequestEtagFields, includes: readonly PullRequestEtagInclude[]): string {\n\tconst covered = normalizePullRequestEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, fields.isDraft ?? null, timeOf(fields.updatedDate), fields.headSha ?? null];\n\t// Only where it is set, so every other host's etag stays exactly what it was.\n\tif (fields.revision != null) {\n\t\tstate.push(fields.revision);\n\t}\n\tif (fields.viewerUnresolved) {\n\t\tstate.push('viewer-unresolved');\n\t}\n\t// Only while queued, so a pull request outside any queue keeps exactly the etag it always had, and joining,\n\t// moving through or leaving the queue (none of which moves the update time) still reads as a change. Tagged, so\n\t// it can never read as another input.\n\tif (fields.mergeQueue != null) {\n\t\tstate.push(['merge-queue', fields.mergeQueue.state, timeOf(fields.mergeQueue.enqueuedAt)]);\n\t}\n\t// Likewise only while the pull request's latest merge-queue event is a removal, so a pull request removed between\n\t// two checks, which neither moves its update time nor shows a queue entry at either check, still reads as a change.\n\tif (fields.mergeQueueRemovedAt != null) {\n\t\tstate.push(['merge-queue-removed', timeOf(fields.mergeQueueRemovedAt)]);\n\t}\n\t// Whenever the read selected the merge-queue data, so an etag from such a read never equals one from a read that\n\t// didn't, even for a pull request that was never queued, whose state is otherwise identical. Tagged, like the\n\t// terms above. A read that didn't select it adds nothing, so it computes the etag it did before.\n\tif (fields.mergeQueueRead) {\n\t\tstate.push(['merge-queue-read']);\n\t}\n\n\tif (covered.length === 0) return `pr1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'mergeable':\n\t\t\t\tstate.push(fields.mergeableState ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'reviewDecision':\n\t\t\t\tstate.push(fields.reviewDecision ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'checks':\n\t\t\t\tstate.push(fields.statusCheckRollupState ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `pr1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/** The issue twin of {@link normalizePullRequestEtagIncludes}; validate with {@link findInvalidIssueEtagInclude}. */\nexport function normalizeIssueEtagIncludes(includes: readonly IssueEtagInclude[]): readonly IssueEtagInclude[] {\n\treturn issueEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't an {@link IssueEtagInclude}, if any. */\nexport function findInvalidIssueEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(issueEtagIncludes as readonly string[]).includes(include));\n}\n\n/** `'reactions'` adds the thumbs-up count, which a host changes without moving `updatedDate`. */\nexport function issueEtag(fields: IssueEtagFields, includes: readonly IssueEtagInclude[]): string {\n\tconst covered = normalizeIssueEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, timeOf(fields.updatedDate)];\n\t// Only where it is set, so every other provider's etag stays exactly what it was.\n\tif (fields.descriptionRule != null) {\n\t\tstate.push(fields.descriptionRule);\n\t}\n\tif (fields.viewerRule != null) {\n\t\tstate.push(fields.viewerRule);\n\t}\n\t// Only where it is set, so every other provider's etag stays exactly what it was. An unknown list is spelled\n\t// apart from every known one, so it never compares unchanged.\n\tif (fields.syncedWithKeys !== undefined) {\n\t\tstate.push(fields.syncedWithKeys === null ? 'synced-with:unknown' : ['synced-with', ...fields.syncedWithKeys]);\n\t}\n\tif (covered.length === 0) return `is1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'reactions':\n\t\t\t\tstate.push(fields.thumbsUpCount ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `is1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/**\n * Never throws: an etag is computed for every fully read row, so a mapper that hands over a missing or unparseable\n * date must not fail the whole read. Such a row's etag just won't match a cheap check's, which always has a date,\n * so the cost is a full read, never a false `unchanged`.\n */\nfunction timeOf(date: Date): number | null {\n\tconst time = new Date(date).getTime();\n\treturn Number.isNaN(time) ? null : time;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,mCAAwC,IAAI,IAAI,CAAA,eAAA,qBAGtD,CAAC;AAED,SAAgB,+BAA+B,IAA6C;CAC3F,MAAM,SAAgC;EACrC,OAAO,GAAG;EACV,SAAS,GAAG;EACZ,aAAa,GAAG;EAChB,SAAS,GAAG,MAAM,KAAK;EACvB,gBAAgB,GAAG;EACnB,gBAAgB,GAAG;EAInB,wBAAwB,4BAA4B,KAAM,GAAmB,yBAAyB,KAAA;CACvG;CAEA,IAAI,GAAG,YAAY,QAAQ,iBAAiB,IAAI,GAAG,SAAS,EAAE,GAC7D,OAAO,WAAW,oBAAoB,EAAE;CAEzC,IAAI,GAAG,kBACN,OAAO,mBAAmB;CAE3B,IAAI,GAAG,cAAc,MACpB,OAAO,aAAa;EAAE,OAAO,GAAG,WAAW;EAAO,YAAY,GAAG,WAAW;CAAW;CAExF,IAAI,GAAG,qBAAqB,MAC3B,OAAO,sBAAsB,GAAG,kBAAkB;CAInD,IAAI,GAAG,sBAAsB,MAC5B,OAAO,iBAAiB;CAEzB,OAAO;AACR;AAEA,SAAgB,yBAAyB,OAAoC;CAC5E,MAAM,SAA0B;EAAE,OAAO,MAAM;EAAO,aAAa,MAAM;CAAY;CAGrF,IACC,MAAM,iBAAiB,QACvB,MAAM,YAAY,QAClB,sBAAsB,KAAK,CAAC,EAAE,cAAc,WAE5C,OAAO,gBAAgB,MAAM;CAE9B,IAAI,M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KAAK,UACJ,MAAM,KAAK,OAAO,0BAA0B,IAAI;CAElD;CAGD,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,KAAK,UAAU,KAAK;AACxD;;AAGA,SAAgB,2BAA2B,UAAoE;CAC9G,OAAO,kBAAkB,QAAO,YAAW,SAAS,SAAS,OAAO,CAAC;AACtE;;AAGA,SAAgB,4BAA4B,UAAiD;CAC5F,OAAO,SAAS,MAAK,YAAW,CAAE,kBAAwC,SAAS,OAAO,CAAC;AAC5F;;AAGA,SAAgB,UAAU,QAAyB,UAA+C;CACjG,MAAM,UAAU,2BAA2B,QAAQ;CACnD,MAAM,QAAmB,CAAC,OAAO,OAAO,OAAO,OAAO,WAAW,CAAC;CAElE,IAAI,OAAO,mBAAmB,MAC7B,MAAM,KAAK,OAAO,eAAe;CAElC,IAAI,OAAO,cAAc,MACxB,MAAM,KAAK,OAAO,UAAU;CAI7B,IAAI,OAAO,mBAAmB,KAAA,GAC7B,MAAM,KAAK,OAAO,mBAAmB,OAAO,wBAAwB,CAAC,eAAe,GAAG,OAAO,cAAc,CAAC;CAE9G,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,KAAK,UAAU,KAAK;CAE5D,KAAK,MAAM,WAAW,SACrB,QAAQ,SAAR;EACC,KAAK,aACJ,MAAM,KAAK,OAAO,iBAAiB,IAAI;CAEzC;CAGD,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,KAAK,UAAU,KAAK;AACxD;;;;;;AAOA,SAAS,OAAO,MAA2B;CAC1C,MAAM,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,QAAQ;CACpC,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO;AACpC"}
|
|
1
|
+
{"version":3,"file":"etag.js","names":[],"sources":["../../../../../plus/integrations/src/reads/etag.ts"],"sourcesContent":["import type { IssueShape } from '@gitlens/git/models/issue.js';\nimport type { PullRequest, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n} from '../constants.js';\nimport { getIssueFieldPresence } from '../fieldPresence.js';\nimport type {\n\tIssueEtagFields,\n\tIssueEtagInclude,\n\tPullRequestEtagFields,\n\tPullRequestEtagInclude,\n} from '../models/integration.js';\nimport {\n\tazureWorkItemDescriptionRule,\n\tazureWorkItemViewerRule,\n\tissueEtagIncludes,\n\tlinearSyncedWithEtagKeys,\n\tpullRequestCheckRunsEtag,\n\tpullRequestEtagIncludes,\n\tpullRequestRevision,\n} from '../models/integration.js';\nimport { issueNamesPeople } from '../providers/models.js';\n\n/**\n * The etags the batch reads hand back (`getPullRequestsBatch`, `getIssuesBatch`): an opaque stamp of an item's\n * change state, which a caller sends back so a cheap check can answer \"unchanged\" without a full read.\n *\n * Computed by core, never the provider's HTTP ETag, and from the fields alone — not the item's id, since the\n * caller's key already identifies the target and ids cross vocabularies between reads. Not hashed: the stamp IS\n * the serialized fields, so two different change states can never collide into a false `unchanged` — except for two\n * 64-bit hashes, where a collision (about 2^-64) is the only way a change can hide: an Azure DevOps pull request's\n * `revision`, of the fields Azure changes without a timestamp, and a GitHub pull request's `checkRuns`, of its head's\n * checks, which keeps the stamp the same length at any number of checks. The prefix names the scheme (`pr1`, `is1`)\n * and every include it covers ({@link PullRequestEtagInclude}, {@link IssueEtagInclude}), in canonical order\n * (`pr1+mergeable+checks:`, `is1+reactions:`), so two different sets can never collide even when their values do (a\n * `null` mergeability and a `null` rollup). A stamp from another scheme or another set just compares unequal and\n * costs a full read.\n */\n\n/**\n * Azure DevOps: a pull request there keeps no update time, so its etag adds a {@link pullRequestRevision}, and a work\n * item's etag adds the rule its body is read by (see `azureWorkItemDescriptionRule`).\n */\nconst azureProviderIds: ReadonlySet<string> = new Set([\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n]);\n\nexport function pullRequestEtagFieldsFromShape(pr: PullRequestShape): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: pr.state,\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: pr.updatedDate,\n\t\theadSha: pr.refs?.head.sha,\n\t\tmergeableState: pr.mergeableState,\n\t\treviewDecision: pr.reviewDecision,\n\t\t// On the class, not the shape: every provider's mapper builds a `PullRequest`. Read by name rather than by\n\t\t// `instanceof`, which a second copy of the model module fails, silently dropping the rollup from every full\n\t\t// row's etag so that no cheap check ever matches it again.\n\t\tstatusCheckRollupState: 'statusCheckRollupState' in pr ? (pr as PullRequest).statusCheckRollupState : undefined,\n\t};\n\t// Read defensively, as `timeOf` reads the date: a row without a provider must not fail the read.\n\tif (pr.provider != null && azureProviderIds.has(pr.provider.id)) {\n\t\tfields.revision = pullRequestRevision(pr);\n\t}\n\tif (pr.viewerUnresolved) {\n\t\tfields.viewerUnresolved = true;\n\t}\n\tif (pr.mergeQueue != null) {\n\t\tfields.mergeQueue = { state: pr.mergeQueue.state, enqueuedAt: pr.mergeQueue.enqueuedAt };\n\t}\n\tif (pr.mergeQueueRemoval != null) {\n\t\tfields.mergeQueueRemovedAt = pr.mergeQueueRemoval.removedAt;\n\t}\n\t// `mergeQueueRequired` is GitHub's non-null `isMergeQueueEnabled`, so only a row from a read that selected the\n\t// merge-queue data has it.\n\tif (pr.mergeQueueRequired != null) {\n\t\tfields.mergeQueueRead = true;\n\t}\n\tif (pr.checkRuns != null) {\n\t\tfields.checkRuns = pullRequestCheckRunsEtag(pr.checkRuns, pr.checkRunsTruncated === true);\n\t}\n\treturn fields;\n}\n\nexport function issueEtagFieldsFromShape(issue: IssueShape): IssueEtagFields {\n\tconst fields: IssueEtagFields = { state: issue.state, updatedDate: issue.updatedDate };\n\t// Only where the row's read really fetched reactions: elsewhere a count is a placeholder or a tracker's votes,\n\t// which no cheap check reads, so taking it would fail every check of that row under `'reactions'`.\n\tif (\n\t\tissue.thumbsUpCount != null &&\n\t\tissue.provider != null &&\n\t\tgetIssueFieldPresence(issue)?.reactions === 'fetched'\n\t) {\n\t\tfields.thumbsUpCount = issue.thumbsUpCount;\n\t}\n\tif (issue.provider != null && azureProviderIds.has(issue.provider.id)) {\n\t\tfields.descriptionRule = azureWorkItemDescriptionRule;\n\t\t// A row read while its organization's identity couldn't be must not compare unchanged, or it would be kept\n\t\t// without a viewer until the work item changes. Also a row that names someone and has neither field: one held\n\t\t// from before `viewerUnresolved` existed.\n\t\tif (!issue.viewerUnresolved && (issue.viewer != null || !issueNamesPeople(issue))) {\n\t\t\tfields.viewerRule = azureWorkItemViewerRule;\n\t\t}\n\t}\n\tif (issue.provider?.id === IssuesCloudHostIntegrationId.Linear) {\n\t\tfields.syncedWithKeys = issue.syncedWith != null ? linearSyncedWithEtagKeys(issue.syncedWith) : null;\n\t}\n\treturn fields;\n}\n\n/**\n * The distinct `includes` in canonical order, whatever order and repetition the caller gave. Values it doesn't know\n * are dropped, so a caller validates them first (see {@link findInvalidPullRequestEtagInclude}).\n */\nexport function normalizePullRequestEtagIncludes(\n\tincludes: readonly PullRequestEtagInclude[],\n): readonly PullRequestEtagInclude[] {\n\treturn pullRequestEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't a {@link PullRequestEtagInclude}, if any. */\nexport function findInvalidPullRequestEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(pullRequestEtagIncludes as readonly string[]).includes(include));\n}\n\n/**\n * Each of `includes` adds one input — mergeability, review decision or check rollup — which a host may change\n * without moving `updatedDate`. An input that isn't listed is left out, so its churn never forces a full read.\n */\nexport function pullRequestEtag(fields: PullRequestEtagFields, includes: readonly PullRequestEtagInclude[]): string {\n\tconst covered = normalizePullRequestEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, fields.isDraft ?? null, timeOf(fields.updatedDate), fields.headSha ?? null];\n\t// Only where it is set, so every other host's etag stays exactly what it was.\n\tif (fields.revision != null) {\n\t\tstate.push(fields.revision);\n\t}\n\tif (fields.viewerUnresolved) {\n\t\tstate.push('viewer-unresolved');\n\t}\n\t// Only while queued, so a pull request outside any queue keeps exactly the etag it always had, and joining,\n\t// moving through or leaving the queue (none of which moves the update time) still reads as a change. Tagged, so\n\t// it can never read as another input.\n\tif (fields.mergeQueue != null) {\n\t\tstate.push(['merge-queue', fields.mergeQueue.state, timeOf(fields.mergeQueue.enqueuedAt)]);\n\t}\n\t// Likewise only while the pull request's latest merge-queue event is a removal, so a pull request removed between\n\t// two checks, which neither moves its update time nor shows a queue entry at either check, still reads as a change.\n\tif (fields.mergeQueueRemovedAt != null) {\n\t\tstate.push(['merge-queue-removed', timeOf(fields.mergeQueueRemovedAt)]);\n\t}\n\t// Whenever the read selected the merge-queue data, so an etag from such a read never equals one from a read that\n\t// didn't, even for a pull request that was never queued, whose state is otherwise identical. Tagged, like the\n\t// terms above. A read that didn't select it adds nothing, so it computes the etag it did before.\n\tif (fields.mergeQueueRead) {\n\t\tstate.push(['merge-queue-read']);\n\t}\n\tif (fields.checkRuns != null) {\n\t\tconst { hash, count, truncated } = fields.checkRuns;\n\t\tstate.push(truncated ? ['check-runs', hash, count, 'truncated'] : ['check-runs', hash, count]);\n\t}\n\n\tif (covered.length === 0) return `pr1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'mergeable':\n\t\t\t\tstate.push(fields.mergeableState ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'reviewDecision':\n\t\t\t\tstate.push(fields.reviewDecision ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'checks':\n\t\t\t\tstate.push(fields.statusCheckRollupState ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `pr1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/** The issue twin of {@link normalizePullRequestEtagIncludes}; validate with {@link findInvalidIssueEtagInclude}. */\nexport function normalizeIssueEtagIncludes(includes: readonly IssueEtagInclude[]): readonly IssueEtagInclude[] {\n\treturn issueEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't an {@link IssueEtagInclude}, if any. */\nexport function findInvalidIssueEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(issueEtagIncludes as readonly string[]).includes(include));\n}\n\n/** `'reactions'` adds the thumbs-up count, which a host changes without moving `updatedDate`. */\nexport function issueEtag(fields: IssueEtagFields, includes: readonly IssueEtagInclude[]): string {\n\tconst covered = normalizeIssueEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, timeOf(fields.updatedDate)];\n\t// Only where it is set, so every other provider's etag stays exactly what it was.\n\tif (fields.descriptionRule != null) {\n\t\tstate.push(fields.descriptionRule);\n\t}\n\tif (fields.viewerRule != null) {\n\t\tstate.push(fields.viewerRule);\n\t}\n\t// Only where it is set, so every other provider's etag stays exactly what it was. An unknown list is spelled\n\t// apart from every known one, so it never compares unchanged.\n\tif (fields.syncedWithKeys !== undefined) {\n\t\tstate.push(fields.syncedWithKeys === null ? 'synced-with:unknown' : ['synced-with', ...fields.syncedWithKeys]);\n\t}\n\tif (covered.length === 0) return `is1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'reactions':\n\t\t\t\tstate.push(fields.thumbsUpCount ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `is1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/**\n * Never throws: an etag is computed for every fully read row, so a mapper that hands over a missing or unparseable\n * date must not fail the whole read. Such a row's etag just won't match a cheap check's, which always has a date,\n * so the cost is a full read, never a false `unchanged`.\n */\nfunction timeOf(date: Date): number | null {\n\tconst time = new Date(date).getTime();\n\treturn Number.isNaN(time) ? null : time;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,mCAAwC,IAAI,IAAI,CAAA,eAAA,qBAGtD,CAAC;AAED,SAAgB,+BAA+B,IAA6C;CAC3F,MAAM,SAAgC;EACrC,OAAO,GAAG;EACV,SAAS,GAA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CAC5F,OAAO,SAAS,MAAK,YAAW,CAAE,kBAAwC,SAAS,OAAO,CAAC;AAC5F;;AAGA,SAAgB,UAAU,QAAyB,UAA+C;CACjG,MAAM,UAAU,2BAA2B,QAAQ;CACnD,MAAM,QAAmB,CAAC,OAAO,OAAO,OAAO,OAAO,WAAW,CAAC;CAElE,IAAI,OAAO,mBAAmB,MAC7B,MAAM,KAAK,OAAO,eAAe;CAElC,IAAI,OAAO,cAAc,MACxB,MAAM,KAAK,OAAO,UAAU;CAI7B,IAAI,OAAO,mBAAmB,KAAA,GAC7B,MAAM,KAAK,OAAO,mBAAmB,OAAO,wBAAwB,CAAC,eAAe,GAAG,OAAO,cAAc,CAAC;CAE9G,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,KAAK,UAAU,KAAK;CAE5D,KAAK,MAAM,WAAW,SACrB,QAAQ,SAAR;EACC,KAAK,aACJ,MAAM,KAAK,OAAO,iBAAiB,IAAI;CAEzC;CAGD,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,KAAK,UAAU,KAAK;AACxD;;;;;;AAOA,SAAS,OAAO,MAA2B;CAC1C,MAAM,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,QAAQ;CACpC,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO;AACpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PullRequestActivityItem } from "../../../git/models/pullRequestActivity.js";
|
|
2
|
+
import { IntegrationIds } from "../constants.js";
|
|
3
|
+
import { ProviderResult } from "../results.js";
|
|
4
|
+
import { ProviderReadContext } from "./context.js";
|
|
5
|
+
//#region ../plus/integrations/src/reads/pullRequestActivity.d.ts
|
|
6
|
+
/** One pull request whose activity to read, echoed back under the caller's own `key`. */
|
|
7
|
+
export interface PullRequestActivityTarget {
|
|
8
|
+
/** Caller-owned identifier, echoed on the result. Must be unique. */
|
|
9
|
+
key: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
repo: string;
|
|
12
|
+
number: number;
|
|
13
|
+
/** The {@link PullRequestActivityResult.cursor} of this pull request's last read. Omit it, or send `''`, for a first read. */
|
|
14
|
+
cursor?: string;
|
|
15
|
+
}
|
|
16
|
+
/** The answer for one {@link PullRequestActivityTarget}. */
|
|
17
|
+
export interface PullRequestActivityResult {
|
|
18
|
+
key: string;
|
|
19
|
+
/** New activity after the target's cursor, in GitHub's timeline order. A review's inline comments follow the review. */
|
|
20
|
+
items: readonly PullRequestActivityItem[];
|
|
21
|
+
/** Opaque: send it back as the target's `cursor` on the next read. */
|
|
22
|
+
cursor: string;
|
|
23
|
+
/** More items follow this page; read again with `cursor`. */
|
|
24
|
+
hasMore: boolean;
|
|
25
|
+
/** The pull request (or its repository) does not exist or is not visible to this connection. */
|
|
26
|
+
notFound?: true;
|
|
27
|
+
}
|
|
28
|
+
export declare function getPullRequestActivity(ctx: ProviderReadContext, options: {
|
|
29
|
+
providerId: IntegrationIds;
|
|
30
|
+
connectionId?: string;
|
|
31
|
+
domain?: string;
|
|
32
|
+
targets: readonly PullRequestActivityTarget[];
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): Promise<ProviderResult<PullRequestActivityResult>>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//# sourceMappingURL=pullRequestActivity.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { githubGraphQLInt32Max, isGitHubProviderId } from "../providers/providerErrors.js";
|
|
2
|
+
import { appendDedupedWarning } from "../results.js";
|
|
3
|
+
import { isGitHostIntegration, isIssuesHostIntegrationId } from "../utils/integration.utils.js";
|
|
4
|
+
import { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from "./warnings.js";
|
|
5
|
+
import { runCaptured } from "./drains.js";
|
|
6
|
+
import { appendBatchSlotWarning } from "./batchEtags.js";
|
|
7
|
+
import { findDuplicateKey, unresolvedIntegration } from "./issueBatch.js";
|
|
8
|
+
//#region ../plus/integrations/src/reads/pullRequestActivity.ts
|
|
9
|
+
const defaultLimit = 30;
|
|
10
|
+
const maxLimit = 100;
|
|
11
|
+
async function getPullRequestActivity(ctx, options) {
|
|
12
|
+
const { providerId, connectionId } = options;
|
|
13
|
+
const refused = (warning) => ({
|
|
14
|
+
items: [],
|
|
15
|
+
warnings: [warning],
|
|
16
|
+
fetchFailed: true
|
|
17
|
+
});
|
|
18
|
+
const surface = "Reading pull request activity";
|
|
19
|
+
if (isIssuesHostIntegrationId(providerId)) return refused(gitHostOnlySurfaceWarning(providerId, void 0, connectionId, surface));
|
|
20
|
+
if (!isGitHubProviderId(providerId)) return refused(unsupportedWarning(providerId, void 0, connectionId, `${surface} is not supported by '${providerId}'; only GitHub and GitHub Enterprise serve pull request activity.`));
|
|
21
|
+
const limit = options.limit ?? defaultLimit;
|
|
22
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > maxLimit) return refused(otherWarning(providerId, void 0, connectionId, `Pull request activity limit ${limit} is invalid; expected an integer from 1 to ${maxLimit}.`));
|
|
23
|
+
if (options.targets.length === 0) return {
|
|
24
|
+
items: [],
|
|
25
|
+
warnings: []
|
|
26
|
+
};
|
|
27
|
+
const duplicateKey = findDuplicateKey(options.targets);
|
|
28
|
+
if (duplicateKey != null) return refused(otherWarning(providerId, void 0, connectionId, `Duplicate pull request activity target key '${duplicateKey}'; keys identify results, so each must be unique.`));
|
|
29
|
+
const targets = options.targets.map((t) => ({
|
|
30
|
+
...t,
|
|
31
|
+
owner: t.owner.trim(),
|
|
32
|
+
repo: t.repo.trim(),
|
|
33
|
+
cursor: t.cursor || void 0
|
|
34
|
+
}));
|
|
35
|
+
const invalid = findInvalidTarget(targets);
|
|
36
|
+
if (invalid != null) return refused(otherWarning(providerId, void 0, connectionId, invalid));
|
|
37
|
+
const integration = await ctx.getIntegrationForRead(providerId, connectionId, options.domain);
|
|
38
|
+
if (integration == null) return unresolvedIntegration(ctx, providerId, connectionId, options.domain);
|
|
39
|
+
if (!isGitHostIntegration(integration)) return refused(gitHostOnlySurfaceWarning(providerId, void 0, connectionId, surface));
|
|
40
|
+
const domain = ctx.domainForRead(integration, providerId, connectionId, options.domain);
|
|
41
|
+
const { value: slots, warning } = await runCaptured(providerId, domain, connectionId, () => integration.getPullRequestActivityResult(targets.map((t) => ({
|
|
42
|
+
owner: t.owner,
|
|
43
|
+
repo: t.repo,
|
|
44
|
+
number: t.number,
|
|
45
|
+
cursor: t.cursor
|
|
46
|
+
})), { limit }, void 0, connectionId), { warnOnMissingSession: true });
|
|
47
|
+
const warnings = [];
|
|
48
|
+
const keys = targets.map((t) => t.key);
|
|
49
|
+
if (warning != null) appendDedupedWarning(warnings, {
|
|
50
|
+
...warning,
|
|
51
|
+
targetKeys: keys
|
|
52
|
+
});
|
|
53
|
+
if (slots == null) {
|
|
54
|
+
if (warning == null) appendDedupedWarning(warnings, {
|
|
55
|
+
...unsupportedWarning(providerId, domain, connectionId, `${surface} is not supported by '${providerId}'.`),
|
|
56
|
+
targetKeys: keys
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
items: [],
|
|
60
|
+
warnings,
|
|
61
|
+
fetchFailed: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const items = [];
|
|
65
|
+
let fetchFailed = false;
|
|
66
|
+
for (let i = 0; i < targets.length; i++) {
|
|
67
|
+
const slot = slots[i];
|
|
68
|
+
const target = targets[i];
|
|
69
|
+
if (slot.status === "rejected") {
|
|
70
|
+
appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, target.key);
|
|
71
|
+
fetchFailed = true;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
items.push(slot.value != null ? {
|
|
75
|
+
key: target.key,
|
|
76
|
+
items: slot.value.items,
|
|
77
|
+
cursor: slot.value.cursor,
|
|
78
|
+
hasMore: slot.value.hasMore
|
|
79
|
+
} : {
|
|
80
|
+
key: target.key,
|
|
81
|
+
items: [],
|
|
82
|
+
cursor: target.cursor ?? "",
|
|
83
|
+
hasMore: false,
|
|
84
|
+
notFound: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
items,
|
|
89
|
+
warnings,
|
|
90
|
+
fetchFailed: fetchFailed || void 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function findInvalidTarget(targets) {
|
|
94
|
+
for (const target of targets) {
|
|
95
|
+
if (!Number.isSafeInteger(target.number) || target.number <= 0) return `Pull request activity target '${target.key}' has number ${target.number}; expected a positive integer.`;
|
|
96
|
+
if (target.number > 2147483647) return `Pull request activity target '${target.key}' has number ${target.number}; GitHub numbers are 32-bit and cannot exceed ${githubGraphQLInt32Max}.`;
|
|
97
|
+
if (target.owner.length === 0 || target.repo.length === 0) return `Pull request activity target '${target.key}' requires a non-empty owner and repo.`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { getPullRequestActivity };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=pullRequestActivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullRequestActivity.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestActivity.ts"],"sourcesContent":["import type { PullRequestActivityItem } from '@gitlens/git/models/pullRequestActivity.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { githubGraphQLInt32Max, isGitHubProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { appendBatchSlotWarning } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { findDuplicateKey, unresolvedIntegration } from './issueBatch.js';\nimport { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from './warnings.js';\n\n/** One pull request whose activity to read, echoed back under the caller's own `key`. */\nexport interface PullRequestActivityTarget {\n\t/** Caller-owned identifier, echoed on the result. Must be unique. */\n\tkey: string;\n\towner: string;\n\trepo: string;\n\tnumber: number;\n\t/** The {@link PullRequestActivityResult.cursor} of this pull request's last read. Omit it, or send `''`, for a first read. */\n\tcursor?: string;\n}\n\n/** The answer for one {@link PullRequestActivityTarget}. */\nexport interface PullRequestActivityResult {\n\tkey: string;\n\t/** New activity after the target's cursor, in GitHub's timeline order. A review's inline comments follow the review. */\n\titems: readonly PullRequestActivityItem[];\n\t/** Opaque: send it back as the target's `cursor` on the next read. */\n\tcursor: string;\n\t/** More items follow this page; read again with `cursor`. */\n\thasMore: boolean;\n\t/** The pull request (or its repository) does not exist or is not visible to this connection. */\n\tnotFound?: true;\n}\n\nconst defaultLimit = 30;\nconst maxLimit = 100;\n\nexport async function getPullRequestActivity(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t\ttargets: readonly PullRequestActivityTarget[];\n\t\tlimit?: number;\n\t},\n): Promise<ProviderResult<PullRequestActivityResult>> {\n\tconst { providerId, connectionId } = options;\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestActivityResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Reading pull request activity';\n\n\tif (isIssuesHostIntegrationId(providerId)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(providerId, undefined, connectionId, surface));\n\t}\n\tif (!isGitHubProviderId(providerId)) {\n\t\treturn refused(\n\t\t\tunsupportedWarning(\n\t\t\t\tproviderId,\n\t\t\t\tundefined,\n\t\t\t\tconnectionId,\n\t\t\t\t`${surface} is not supported by '${providerId}'; only GitHub and GitHub Enterprise serve pull request activity.`,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst limit = options.limit ?? defaultLimit;\n\tif (!Number.isInteger(limit) || limit < 1 || limit > maxLimit) {\n\t\treturn refused(\n\t\t\totherWarning(\n\t\t\t\tproviderId,\n\t\t\t\tundefined,\n\t\t\t\tconnectionId,\n\t\t\t\t`Pull request activity limit ${limit} is invalid; expected an integer from 1 to ${maxLimit}.`,\n\t\t\t),\n\t\t);\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\treturn refused(\n\t\t\totherWarning(\n\t\t\t\tproviderId,\n\t\t\t\tundefined,\n\t\t\t\tconnectionId,\n\t\t\t\t`Duplicate pull request activity target key '${duplicateKey}'; keys identify results, so each must be unique.`,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst targets = options.targets.map(t => ({\n\t\t...t,\n\t\towner: t.owner.trim(),\n\t\trepo: t.repo.trim(),\n\t\tcursor: t.cursor || undefined,\n\t}));\n\tconst invalid = findInvalidTarget(targets);\n\tif (invalid != null) return refused(otherWarning(providerId, undefined, connectionId, invalid));\n\n\tconst integration = await ctx.getIntegrationForRead(providerId, connectionId, options.domain);\n\tif (integration == null) return unresolvedIntegration(ctx, providerId, connectionId, options.domain);\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(providerId, undefined, connectionId, surface));\n\t}\n\n\tconst domain = ctx.domainForRead(integration, providerId, connectionId, options.domain);\n\tconst { value: slots, warning } = await runCaptured(\n\t\tproviderId,\n\t\tdomain,\n\t\tconnectionId,\n\t\t() =>\n\t\t\tintegration.getPullRequestActivityResult(\n\t\t\t\ttargets.map(t => ({ owner: t.owner, repo: t.repo, number: t.number, cursor: t.cursor })),\n\t\t\t\t{ limit: limit },\n\t\t\t\tundefined,\n\t\t\t\tconnectionId,\n\t\t\t),\n\t\t{ warnOnMissingSession: true },\n\t);\n\n\tconst warnings: ProviderWarning[] = [];\n\tconst keys = targets.map(t => t.key);\n\tif (warning != null) {\n\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: keys });\n\t}\n\tif (slots == null) {\n\t\tif (warning == null) {\n\t\t\tappendDedupedWarning(warnings, {\n\t\t\t\t...unsupportedWarning(\n\t\t\t\t\tproviderId,\n\t\t\t\t\tdomain,\n\t\t\t\t\tconnectionId,\n\t\t\t\t\t`${surface} is not supported by '${providerId}'.`,\n\t\t\t\t),\n\t\t\t\ttargetKeys: keys,\n\t\t\t});\n\t\t}\n\t\treturn { items: [], warnings: warnings, fetchFailed: true };\n\t}\n\n\tconst items: PullRequestActivityResult[] = [];\n\tlet fetchFailed = false;\n\tfor (let i = 0; i < targets.length; i++) {\n\t\tconst slot = slots[i];\n\t\tconst target = targets[i];\n\t\tif (slot.status === 'rejected') {\n\t\t\tappendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, target.key);\n\t\t\tfetchFailed = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push(\n\t\t\tslot.value != null\n\t\t\t\t? { key: target.key, items: slot.value.items, cursor: slot.value.cursor, hasMore: slot.value.hasMore }\n\t\t\t\t: { key: target.key, items: [], cursor: target.cursor ?? '', hasMore: false, notFound: true },\n\t\t);\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\nfunction findInvalidTarget(targets: readonly PullRequestActivityTarget[]): string | undefined {\n\tfor (const target of targets) {\n\t\tif (!Number.isSafeInteger(target.number) || target.number <= 0) {\n\t\t\treturn `Pull request activity target '${target.key}' has number ${target.number}; expected a positive integer.`;\n\t\t}\n\t\tif (target.number > githubGraphQLInt32Max) {\n\t\t\treturn `Pull request activity 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 activity target '${target.key}' requires a non-empty owner and repo.`;\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";;;;;;;;AAoCA,MAAM,eAAe;AACrB,MAAM,WAAW;AAEjB,eAAsB,uBACrB,KACA,SAOqD;CACrD,MAAM,EAAE,YAAY,iBAAiB;CACrC,MAAM,WAAW,aAAyE;EACzF,OAAO,CAAC;EACR,UAAU,CAAC,OAAO;EAClB,aAAa;CACd;C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,MAAM,KAAK,OAAO,UAAU,GAC5D,OAAO,iCAAiC,OAAO,IAAI,eAAe,OAAO,OAAO;EAEjF,IAAI,OAAO,SAAA,YACV,OAAO,iCAAiC,OAAO,IAAI,eAAe,OAAO,OAAO,gDAAgD,sBAAsB;EAEvJ,IAAI,OAAO,MAAM,WAAW,KAAK,OAAO,KAAK,WAAW,GACvD,OAAO,iCAAiC,OAAO,IAAI;CAErD;AAED"}
|
|
@@ -68,7 +68,8 @@ export interface PullRequestBatchResult {
|
|
|
68
68
|
* an update time), plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it
|
|
69
69
|
* back as {@link PullRequestBatchTarget.etag}. An etag from another scheme or another `etagIncludes` set simply
|
|
70
70
|
* compares unequal and costs a full read, never a false `unchanged` — and so does one from a read that selected
|
|
71
|
-
* merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`)
|
|
71
|
+
* merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`), or check runs
|
|
72
|
+
* (`checkRuns`), when the other didn't.
|
|
72
73
|
* Reactions are never an input: a host can add one without moving the update time, so an `unchanged` copy's
|
|
73
74
|
* `thumbsUpCount` may be stale.
|
|
74
75
|
*/
|
|
@@ -94,6 +95,8 @@ export declare function getPullRequestsBatch(ctx: ProviderReadContext, options:
|
|
|
94
95
|
etagIncludes?: readonly PullRequestEtagInclude[];
|
|
95
96
|
/** See {@link IntegrationManager.getPullRequestsBatch}. */
|
|
96
97
|
mergeQueue?: boolean;
|
|
98
|
+
/** See {@link IntegrationManager.getPullRequestsBatch}. */
|
|
99
|
+
checkRuns?: boolean;
|
|
97
100
|
}): Promise<ProviderResult<PullRequestBatchResult>>;
|
|
98
101
|
//#endregion
|
|
99
102
|
//# sourceMappingURL=pullRequestBatch.d.ts.map
|
|
@@ -32,6 +32,7 @@ async function getPullRequestsBatch(ctx, options) {
|
|
|
32
32
|
const domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);
|
|
33
33
|
const etagIncludes = normalizePullRequestEtagIncludes(options.etagIncludes ?? []);
|
|
34
34
|
const mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;
|
|
35
|
+
const checkRuns = options.checkRuns === true;
|
|
35
36
|
const toCoordinate = (t) => ({
|
|
36
37
|
owner: t.owner,
|
|
37
38
|
repo: t.repo,
|
|
@@ -47,11 +48,13 @@ async function getPullRequestsBatch(ctx, options) {
|
|
|
47
48
|
supportsEtags: integration.supportsPullRequestEtags,
|
|
48
49
|
readFull: (batch) => runCaptured(options.providerId, domain, options.connectionId, async () => integration.getPullRequestsBatchResult(batch.map(toCoordinate), {
|
|
49
50
|
currentAccount: await (currentAccount ??= getCurrentAccountIdentity(integration, options.connectionId)),
|
|
50
|
-
mergeQueue
|
|
51
|
+
mergeQueue,
|
|
52
|
+
checkRuns
|
|
51
53
|
}, void 0, options.connectionId), { warnOnMissingSession: true }),
|
|
52
54
|
readEtagFields: (batch) => runCaptured(options.providerId, domain, options.connectionId, () => integration.getPullRequestsEtagFieldsResult(batch.map(toCoordinate), {
|
|
53
55
|
etagIncludes,
|
|
54
|
-
mergeQueue
|
|
56
|
+
mergeQueue,
|
|
57
|
+
checkRuns
|
|
55
58
|
}, void 0, options.connectionId), { warnOnMissingSession: true }),
|
|
56
59
|
itemEtag: (pr) => pullRequestEtag(pullRequestEtagFieldsFromShape(pr), etagIncludes),
|
|
57
60
|
fieldsEtag: (fields) => pullRequestEtag(fields, etagIncludes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullRequestBatch.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestBatch.ts"],"sourcesContent":["import type { PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { PullRequestEtagInclude } from '../models/integration.js';\nimport { pullRequestEtagIncludes } from '../models/integration.js';\nimport { githubGraphQLInt32Max, isAzureProviderId, isGitHubProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { readEtaggedBatch } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport {\n\tfindInvalidPullRequestEtagInclude,\n\tnormalizePullRequestEtagIncludes,\n\tpullRequestEtag,\n\tpullRequestEtagFieldsFromShape,\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\n/** One pull request to resolve, identified by coordinate and echoed back under the caller's own `key`. */\nexport interface PullRequestBatchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or\n\t * Azure DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Pull request number, GitLab merge request iid, or Azure DevOps pull request id. */\n\tnumber: number;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/**\n\t * The {@link PullRequestBatchResult.etag} of the copy the caller holds. When the host can check it cheaply and\n\t * it still matches, the pull request isn't read again and comes back `unchanged`.\n\t */\n\tetag?: string;\n}\n\n/**\n * The answer for one {@link PullRequestBatchTarget}, in one of four states:\n * - `{ key, pullRequest, etag }` — read in full, whatever its state. Every fully read row carries an `etag`,\n * whether or not the caller sent one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT: it does not exist, or is not visible to this connection.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface PullRequestBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved pull request, whatever its state, or `undefined` when it PROVABLY does not exist (or is not\n\t * visible to this connection) — or when it is `unchanged`. A target whose read FAILED is not returned at\n\t * all and sets `fetchFailed`.\n\t */\n\tpullRequest?: PullRequestShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the pull request's change state — its\n\t * state, draft flag, update time and head commit (on Azure DevOps, also a revision of the fields it changes without\n\t * an update time), plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it\n\t * back as {@link PullRequestBatchTarget.etag}. An etag from another scheme or another `etagIncludes` set simply\n\t * compares unequal and costs a full read, never a false `unchanged` — and so does one from a read that selected\n\t * merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`) when the other didn't.\n\t * Reactions are never an input: a host can add one without moving the update time, so an `unchanged` copy's\n\t * `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `pullRequest` is absent because nothing was read. */\n\tunchanged?: true;\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},\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 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},\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 },\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":";;;;;;;;;AA8FA,eAAsB,qBACrB,KACA,SAmBkD;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,QAAQ,cAAc,OAAO,CAAC;CAGvG,IAAI,QAAQ,QAAQ,WAAW,GAAG,OAAO;EAAE,OAAO,CAAC;EAAG,UAAU,CAAC;CAAE;CAEnE,MAAM,eAAe,iBAAiB,QAAQ,OAAO;CACrD,IAAI,gBAAgB,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AAK,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 { PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { PullRequestEtagInclude } from '../models/integration.js';\nimport { pullRequestEtagIncludes } from '../models/integration.js';\nimport { githubGraphQLInt32Max, isAzureProviderId, isGitHubProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { readEtaggedBatch } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport {\n\tfindInvalidPullRequestEtagInclude,\n\tnormalizePullRequestEtagIncludes,\n\tpullRequestEtag,\n\tpullRequestEtagFieldsFromShape,\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\n/** One pull request to resolve, identified by coordinate and echoed back under the caller's own `key`. */\nexport interface PullRequestBatchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or\n\t * Azure DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Pull request number, GitLab merge request iid, or Azure DevOps pull request id. */\n\tnumber: number;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/**\n\t * The {@link PullRequestBatchResult.etag} of the copy the caller holds. When the host can check it cheaply and\n\t * it still matches, the pull request isn't read again and comes back `unchanged`.\n\t */\n\tetag?: string;\n}\n\n/**\n * The answer for one {@link PullRequestBatchTarget}, in one of four states:\n * - `{ key, pullRequest, etag }` — read in full, whatever its state. Every fully read row carries an `etag`,\n * whether or not the caller sent one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT: it does not exist, or is not visible to this connection.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface PullRequestBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved pull request, whatever its state, or `undefined` when it PROVABLY does not exist (or is not\n\t * visible to this connection) — or when it is `unchanged`. A target whose read FAILED is not returned at\n\t * all and sets `fetchFailed`.\n\t */\n\tpullRequest?: PullRequestShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the pull request's change state — its\n\t * state, draft flag, update time and head commit (on Azure DevOps, also a revision of the fields it changes without\n\t * an update time), plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it\n\t * back as {@link PullRequestBatchTarget.etag}. An etag from another scheme or another `etagIncludes` set simply\n\t * compares unequal and costs a full read, never a false `unchanged` — and so does one from a read that selected\n\t * merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`), or check runs\n\t * (`checkRuns`), when the other didn't.\n\t * Reactions are never an input: a host can add one without moving the update time, so an `unchanged` copy's\n\t * `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `pullRequest` is absent because nothing was read. */\n\tunchanged?: true;\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":";;;;;;;;;AA+FA,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,QAAQ,cAAc,OAAO,CAAC;CAGvG,IAAI,QAAQ,QAAQ,WAAW,GAAG,OAAO;EAAE,OAAO,CAAC;EAAG,UAAU,CAAC;CAAE;CAEnE,MAAM,eAAe,iBAAiB,QAAQ,OAAO;CACrD,IAAI,gBAAgB,MAGnB,OAAO,QACN,aACC,QAAQ,YACR,KAAA,GACA,QAAQ,cACR,4CAA4C,aAAa,kDAC1D,CACD;CAID,MAAM,iBAAiB,kCAAkC,QAAQ,gBAAgB,CAAC,CAAC;CACnF,IAAI,kBAAkB,MACrB,OAAO,QACN,aACC,QAAQ,YACR,KAAA,GACA,QAAQ,cACR,sCAAsC,eAAe,qBAAqB,wBAAwB,KAAI,MAAK,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,EACjI,CACD;CAID,MAAM,UAAU,QAAQ,QAAQ,IAAI,oBAAoB;CAGxD,MAAM,UAAU,kBAAkB,QAAQ,YAAY,OAAO;CAC7D,IAAI,WAAW,MACd,OAAO,QAAQ,aAAa,QAAQ,YAAY,KAAA,GAAW,QAAQ,cAAc,OAAO,CAAC;CAG1F,MAAM,cAAc,MAAM,IAAI,sBAAsB,QAAQ,YAAY,QAAQ,cAAc,QAAQ,MAAM;CAC5G,IAAI,eAAe,MAClB,OAAO,sBAAsB,KAAK,QAAQ,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B,KAAK,IAAI;GACT,GAAI,IAAI,SAAS,OAAO,EAAE,aAAa,IAAI,MAAM,IAAI,CAAC;GACtD,GAAI,IAAI,YAAY,EAAE,WAAW,KAAc,IAAI,CAAC;GACpD,GAAI,IAAI,QAAQ,OAAO,EAAE,MAAM,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"}
|
|
@@ -59,6 +59,8 @@ export declare function getPullRequestsForBranches(ctx: ProviderReadContext, opt
|
|
|
59
59
|
domain?: string;
|
|
60
60
|
/** See {@link IntegrationManager.getPullRequestsForBranches}. */
|
|
61
61
|
mergeQueue?: boolean;
|
|
62
|
+
/** See {@link IntegrationManager.getPullRequestsForBranches}. */
|
|
63
|
+
checkRuns?: boolean;
|
|
62
64
|
}): Promise<ProviderResult<PullRequestBranchResult>>;
|
|
63
65
|
//#endregion
|
|
64
66
|
//# sourceMappingURL=pullRequestBranches.d.ts.map
|
|
@@ -57,7 +57,8 @@ async function getPullRequestsForBranches(ctx, options) {
|
|
|
57
57
|
})), {
|
|
58
58
|
currentAccount,
|
|
59
59
|
limit: pullRequestsForBranchLimit,
|
|
60
|
-
mergeQueue
|
|
60
|
+
mergeQueue,
|
|
61
|
+
checkRuns: options.checkRuns === true
|
|
61
62
|
}, void 0, options.connectionId), { warnOnMissingSession: true });
|
|
62
63
|
const allKeys = targets.map((t) => t.key);
|
|
63
64
|
if (warning != null) appendDedupedWarning(warnings, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullRequestBranches.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestBranches.ts"],"sourcesContent":["import type { PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { GitSelfManagedHostIntegrationId } from '../constants.js';\nimport { isAzureProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { appendBatchSlotWarning } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport { findDuplicateKey, trimCoordinateFields, unresolvedIntegration } from './issueBatch.js';\nimport { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from './warnings.js';\n\n/**\n * The pull-requests-by-branch read: for each branch, every pull request whose head is that branch, in any state.\n * A relationship-free point read — unlike the account-wide sweeps, it finds a teammate's pull request from the\n * user's branch — so an empty list is a PROVEN \"none\" a caller can cache.\n *\n * ONE integration call per invocation, whatever the target count, settling each target independently — see\n * `GitHostIntegration.getPullRequestsForBranchesResult`. Uncached, and not routed through the integration's\n * `getPullRequestForBranch`, which caches through `IntegrationCacheProvider.getPullRequestForBranch`, answers one\n * pull request, and on several hosts looks the branch ref up, answering \"none\" once a merged branch is deleted.\n */\n\n/** Pull requests returned per target. */\nconst pullRequestsForBranchLimit = 10;\n\n/** One branch whose pull requests to find, echoed back under the caller's own `key`. */\nexport interface PullRequestBranchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * The repository the pull requests are OPENED AGAINST (their base), as in `PullRequestBatchTarget`: GitHub\n\t * owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or Azure\n\t * DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/** The head branch's short name, without `refs/heads/`. */\n\tbranch: string;\n\t/**\n\t * Owner (GitHub user or org, GitLab namespace, Bitbucket workspace) of the repository the branch lives in, when\n\t * it's a fork. Omitted, or equal to `owner` (ignoring case), means the branch lives in the base repository itself,\n\t * so a caller can pass the owner of whichever remote the branch was pushed to. On GitLab this is the whole\n\t * namespace path, as `owner` is, so a remote's first-slash split can't be passed for either.\n\t *\n\t * A different owner is refused on Bitbucket Data Center and Azure DevOps, where a fork can't be found by its\n\t * owner.\n\t */\n\theadOwner?: string;\n}\n\n/** The answer for one {@link PullRequestBranchTarget}. */\nexport interface PullRequestBranchResult {\n\tkey: string;\n\t/**\n\t * Every pull request whose head is this branch, in ANY state — open, closed and merged — most recently updated\n\t * first, up to a per-target cap. An empty array is a PROVEN \"none\" unless `truncated` is set. A target whose\n\t * read failed is not returned at all.\n\t */\n\tpullRequests: PullRequestShape[];\n\t/**\n\t * Set when a pull request that wasn't returned could still match: more matched than the cap, or the host held\n\t * more pull requests of this branch name than it returned and couldn't rule them out. GitHub/GHE rule them out\n\t * with a second request filtered by head owner, so there it means more than the cap truly match. That request\n\t * can't see a pull request from a since-deleted fork, so on GitHub/GHE such a pull request outside the first\n\t * request's page can be missing even when this is not set.\n\t */\n\ttruncated?: boolean;\n}\n\nexport async function getPullRequestsForBranches(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\ttargets: readonly PullRequestBranchTarget[];\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/** See {@link IntegrationManager.getPullRequestsForBranches}. */\n\t\tmergeQueue?: boolean;\n\t},\n): Promise<ProviderResult<PullRequestBranchResult>> {\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestBranchResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Pull requests by branch';\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 branch target key '${duplicateKey}'; keys identify results, so each must be unique.`,\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\t// `branch` is left alone: a git ref name can't carry surrounding whitespace, so a padded one is refused below\n\t// rather than being silently repaired.\n\tconst targets = options.targets.map(target => ({\n\t\t...trimCoordinateFields(target),\n\t\theadOwner: target.headOwner?.trim(),\n\t}));\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\t// Resolved once, so the by-name query and the batch read that settles a truncated target select the same data\n\t// and one target's rows never disagree on it, even if the host's setting changes while the call is in flight.\n\tconst mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;\n\tconst currentAccount = await getCurrentAccountIdentity(integration, options.connectionId);\n\n\tconst warnings: ProviderWarning[] = [];\n\tlet fetchFailed = false;\n\n\tconst { value: slots, warning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() =>\n\t\t\tintegration.getPullRequestsForBranchesResult(\n\t\t\t\ttargets.map(t => ({\n\t\t\t\t\towner: t.owner,\n\t\t\t\t\trepo: t.repo,\n\t\t\t\t\tproject: t.project,\n\t\t\t\t\tbranch: t.branch,\n\t\t\t\t\theadOwner: forkOwner(t),\n\t\t\t\t})),\n\t\t\t\t{ currentAccount: currentAccount, limit: pullRequestsForBranchLimit, mergeQueue: mergeQueue },\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t),\n\t\t// A missing session must surface as a connection warning, including on the primary path, which\n\t\t// otherwise reads it as \"not connected\" and says nothing.\n\t\t{ warnOnMissingSession: true },\n\t);\n\tconst allKeys = targets.map(t => t.key);\n\tif (warning != null) {\n\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: allKeys });\n\t}\n\n\tif (slots == null) {\n\t\t// Dropped, never reported as \"none\": \"unknown\" and \"proven none\" must stay distinguishable.\n\t\tif (warning == null) {\n\t\t\tappendDedupedWarning(warnings, {\n\t\t\t\t...unsupportedWarning(\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`${surface} is not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t\ttargetKeys: allKeys,\n\t\t\t});\n\t\t}\n\t\treturn { items: [], warnings: warnings, fetchFailed: true };\n\t}\n\n\tconst items: PullRequestBranchResult[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\tconst slot = slots[i];\n\t\tif (slot.status === 'rejected') {\n\t\t\t// Dropped, never reported as \"none\", like a whole-call failure.\n\t\t\tappendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot, targets[i].key);\n\t\t\tfetchFailed = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push({\n\t\t\tkey: targets[i].key,\n\t\t\tpullRequests: slot.value.pullRequests,\n\t\t\t...(slot.value.truncated ? { truncated: true } : {}),\n\t\t});\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/** The owner of the fork the branch lives in, or `undefined` for a branch in the base repository. */\nfunction forkOwner(target: PullRequestBranchTarget): string | undefined {\n\treturn target.headOwner == null || equalsIgnoreCase(target.headOwner, target.owner) ? undefined : target.headOwner;\n}\n\nfunction findInvalidTarget(\n\tproviderId: IntegrationIds,\n\ttargets: readonly PullRequestBranchTarget[],\n): string | undefined {\n\tconst isAzure = isAzureProviderId(providerId);\n\tconst isBitbucketServer = providerId === GitSelfManagedHostIntegrationId.BitbucketServer;\n\tfor (const target of targets) {\n\t\tif (target.owner.length === 0 || target.repo.length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a non-empty owner and repo.`;\n\t\t}\n\t\tif (target.branch.trim().length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a non-empty branch.`;\n\t\t}\n\t\t// Sent as is, a padded name matches no branch and answers a cacheable \"none\".\n\t\tif (target.branch !== target.branch.trim()) {\n\t\t\treturn `Pull request branch target '${target.key}' has branch '${target.branch}'; a branch name can't start or end with whitespace.`;\n\t\t}\n\t\tif (target.branch.startsWith('refs/')) {\n\t\t\treturn `Pull request branch target '${target.key}' has branch '${target.branch}'; pass the branch's short name, without 'refs/heads/'.`;\n\t\t}\n\t\tif (isAzure && !target.project) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a project for '${providerId}'.`;\n\t\t}\n\t\tif (target.headOwner?.length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' has an empty headOwner; omit it for a branch in the base repository.`;\n\t\t}\n\t\tif (forkOwner(target) != null) {\n\t\t\tif (isAzure) {\n\t\t\t\treturn `Pull request branch target '${target.key}' has a headOwner other than its owner, which '${providerId}' can't honor: an Azure DevOps fork shares its organization, so its owner can't identify it.`;\n\t\t\t}\n\t\t\tif (isBitbucketServer) {\n\t\t\t\treturn `Pull request branch target '${target.key}' has a headOwner other than its owner, which '${providerId}' can't honor: Bitbucket Data Center finds a branch's pull requests only through the repository the branch lives in, and a fork's repository can't be derived from its owner.`;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,6BAA6B;AAiDnC,eAAsB,2BACrB,KACA,SAYmD;CACnD,MAAM,WAAW,aAAuE;EACvF,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,QAAQ,cAAc,OAAO,CAAC;CAGvG,IAAI,QAAQ,QAAQ,WAAW,GAAG,OAAO;EAAE,OAAO,CAAC;EAAG,UAAU,CAAC;CAAE;CAEnE,MAAM,eAAe,iBAAiB,QAAQ,OAAO;CACrD,IAAI,gBAAgB,MAGnB,OAAO,QACN,aACC,QAAQ,YACR,KAAA,GACA,QAAQ,cACR,6CAA6C,aAAa,kDAC3D,CACD;CAMD,MAAM,UAAU,QAAQ,QAAQ,KAAI,YAAW;EAC9C,GAAG,qBAAqB,MAAM;EAC9B,WAAW,OAAO,WAAW,KAAK;CACnC,EAAE;CAGF,MAAM,UAAU,kBAAkB,QAAQ,YAAY,OAAO;CAC7D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AO,IAAI;EAElD,IAAI,UAAU,MAAM,KAAK,MAAM;GAC9B,IAAI,SACH,OAAO,+BAA+B,OAAO,IAAI,iDAAiD,WAAW;GAE9G,IAAI,mBACH,OAAO,+BAA+B,OAAO,IAAI,iDAAiD,WAAW;EAE/G;CACD;AAED"}
|
|
1
|
+
{"version":3,"file":"pullRequestBranches.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestBranches.ts"],"sourcesContent":["import type { PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { GitSelfManagedHostIntegrationId } from '../constants.js';\nimport { isAzureProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { appendBatchSlotWarning } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { getCurrentAccountIdentity, runCaptured } from './drains.js';\nimport { findDuplicateKey, trimCoordinateFields, unresolvedIntegration } from './issueBatch.js';\nimport { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from './warnings.js';\n\n/**\n * The pull-requests-by-branch read: for each branch, every pull request whose head is that branch, in any state.\n * A relationship-free point read — unlike the account-wide sweeps, it finds a teammate's pull request from the\n * user's branch — so an empty list is a PROVEN \"none\" a caller can cache.\n *\n * ONE integration call per invocation, whatever the target count, settling each target independently — see\n * `GitHostIntegration.getPullRequestsForBranchesResult`. Uncached, and not routed through the integration's\n * `getPullRequestForBranch`, which caches through `IntegrationCacheProvider.getPullRequestForBranch`, answers one\n * pull request, and on several hosts looks the branch ref up, answering \"none\" once a merged branch is deleted.\n */\n\n/** Pull requests returned per target. */\nconst pullRequestsForBranchLimit = 10;\n\n/** One branch whose pull requests to find, echoed back under the caller's own `key`. */\nexport interface PullRequestBranchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * The repository the pull requests are OPENED AGAINST (their base), as in `PullRequestBatchTarget`: GitHub\n\t * owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or Azure\n\t * DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/** The head branch's short name, without `refs/heads/`. */\n\tbranch: string;\n\t/**\n\t * Owner (GitHub user or org, GitLab namespace, Bitbucket workspace) of the repository the branch lives in, when\n\t * it's a fork. Omitted, or equal to `owner` (ignoring case), means the branch lives in the base repository itself,\n\t * so a caller can pass the owner of whichever remote the branch was pushed to. On GitLab this is the whole\n\t * namespace path, as `owner` is, so a remote's first-slash split can't be passed for either.\n\t *\n\t * A different owner is refused on Bitbucket Data Center and Azure DevOps, where a fork can't be found by its\n\t * owner.\n\t */\n\theadOwner?: string;\n}\n\n/** The answer for one {@link PullRequestBranchTarget}. */\nexport interface PullRequestBranchResult {\n\tkey: string;\n\t/**\n\t * Every pull request whose head is this branch, in ANY state — open, closed and merged — most recently updated\n\t * first, up to a per-target cap. An empty array is a PROVEN \"none\" unless `truncated` is set. A target whose\n\t * read failed is not returned at all.\n\t */\n\tpullRequests: PullRequestShape[];\n\t/**\n\t * Set when a pull request that wasn't returned could still match: more matched than the cap, or the host held\n\t * more pull requests of this branch name than it returned and couldn't rule them out. GitHub/GHE rule them out\n\t * with a second request filtered by head owner, so there it means more than the cap truly match. That request\n\t * can't see a pull request from a since-deleted fork, so on GitHub/GHE such a pull request outside the first\n\t * request's page can be missing even when this is not set.\n\t */\n\ttruncated?: boolean;\n}\n\nexport async function getPullRequestsForBranches(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\ttargets: readonly PullRequestBranchTarget[];\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/** See {@link IntegrationManager.getPullRequestsForBranches}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.getPullRequestsForBranches}. */\n\t\tcheckRuns?: boolean;\n\t},\n): Promise<ProviderResult<PullRequestBranchResult>> {\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestBranchResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Pull requests by branch';\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 branch target key '${duplicateKey}'; keys identify results, so each must be unique.`,\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\t// `branch` is left alone: a git ref name can't carry surrounding whitespace, so a padded one is refused below\n\t// rather than being silently repaired.\n\tconst targets = options.targets.map(target => ({\n\t\t...trimCoordinateFields(target),\n\t\theadOwner: target.headOwner?.trim(),\n\t}));\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\t// Resolved once, so the by-name query and the batch read that settles a truncated target select the same data\n\t// and one target's rows never disagree on it, even if the host's setting changes while the call is in flight.\n\tconst mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;\n\tconst currentAccount = await getCurrentAccountIdentity(integration, options.connectionId);\n\n\tconst warnings: ProviderWarning[] = [];\n\tlet fetchFailed = false;\n\n\tconst { value: slots, warning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() =>\n\t\t\tintegration.getPullRequestsForBranchesResult(\n\t\t\t\ttargets.map(t => ({\n\t\t\t\t\towner: t.owner,\n\t\t\t\t\trepo: t.repo,\n\t\t\t\t\tproject: t.project,\n\t\t\t\t\tbranch: t.branch,\n\t\t\t\t\theadOwner: forkOwner(t),\n\t\t\t\t})),\n\t\t\t\t{\n\t\t\t\t\tcurrentAccount: currentAccount,\n\t\t\t\t\tlimit: pullRequestsForBranchLimit,\n\t\t\t\t\tmergeQueue: mergeQueue,\n\t\t\t\t\tcheckRuns: options.checkRuns === true,\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t),\n\t\t// A missing session must surface as a connection warning, including on the primary path, which\n\t\t// otherwise reads it as \"not connected\" and says nothing.\n\t\t{ warnOnMissingSession: true },\n\t);\n\tconst allKeys = targets.map(t => t.key);\n\tif (warning != null) {\n\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: allKeys });\n\t}\n\n\tif (slots == null) {\n\t\t// Dropped, never reported as \"none\": \"unknown\" and \"proven none\" must stay distinguishable.\n\t\tif (warning == null) {\n\t\t\tappendDedupedWarning(warnings, {\n\t\t\t\t...unsupportedWarning(\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`${surface} is not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t\ttargetKeys: allKeys,\n\t\t\t});\n\t\t}\n\t\treturn { items: [], warnings: warnings, fetchFailed: true };\n\t}\n\n\tconst items: PullRequestBranchResult[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\tconst slot = slots[i];\n\t\tif (slot.status === 'rejected') {\n\t\t\t// Dropped, never reported as \"none\", like a whole-call failure.\n\t\t\tappendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot, targets[i].key);\n\t\t\tfetchFailed = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push({\n\t\t\tkey: targets[i].key,\n\t\t\tpullRequests: slot.value.pullRequests,\n\t\t\t...(slot.value.truncated ? { truncated: true } : {}),\n\t\t});\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/** The owner of the fork the branch lives in, or `undefined` for a branch in the base repository. */\nfunction forkOwner(target: PullRequestBranchTarget): string | undefined {\n\treturn target.headOwner == null || equalsIgnoreCase(target.headOwner, target.owner) ? undefined : target.headOwner;\n}\n\nfunction findInvalidTarget(\n\tproviderId: IntegrationIds,\n\ttargets: readonly PullRequestBranchTarget[],\n): string | undefined {\n\tconst isAzure = isAzureProviderId(providerId);\n\tconst isBitbucketServer = providerId === GitSelfManagedHostIntegrationId.BitbucketServer;\n\tfor (const target of targets) {\n\t\tif (target.owner.length === 0 || target.repo.length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a non-empty owner and repo.`;\n\t\t}\n\t\tif (target.branch.trim().length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a non-empty branch.`;\n\t\t}\n\t\t// Sent as is, a padded name matches no branch and answers a cacheable \"none\".\n\t\tif (target.branch !== target.branch.trim()) {\n\t\t\treturn `Pull request branch target '${target.key}' has branch '${target.branch}'; a branch name can't start or end with whitespace.`;\n\t\t}\n\t\tif (target.branch.startsWith('refs/')) {\n\t\t\treturn `Pull request branch target '${target.key}' has branch '${target.branch}'; pass the branch's short name, without 'refs/heads/'.`;\n\t\t}\n\t\tif (isAzure && !target.project) {\n\t\t\treturn `Pull request branch target '${target.key}' requires a project for '${providerId}'.`;\n\t\t}\n\t\tif (target.headOwner?.length === 0) {\n\t\t\treturn `Pull request branch target '${target.key}' has an empty headOwner; omit it for a branch in the base repository.`;\n\t\t}\n\t\tif (forkOwner(target) != null) {\n\t\t\tif (isAzure) {\n\t\t\t\treturn `Pull request branch target '${target.key}' has a headOwner other than its owner, which '${providerId}' can't honor: an Azure DevOps fork shares its organization, so its owner can't identify it.`;\n\t\t\t}\n\t\t\tif (isBitbucketServer) {\n\t\t\t\treturn `Pull request branch target '${target.key}' has a headOwner other than its owner, which '${providerId}' can't honor: Bitbucket Data Center finds a branch's pull requests only through the repository the branch lives in, and a fork's repository can't be derived from its owner.`;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,6BAA6B;AAiDnC,eAAsB,2BACrB,KACA,SAcmD;CACnD,MAAM,WAAW,aAAuE;EACvF,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,QAAQ,cAAc,OAAO,CAAC;CAGvG,IAAI,QAAQ,QAAQ,WAAW,GAAG,OAAO;EAAE,OAAO,CAAC;EAAG,UAAU,CAAC;CAAE;CAEnE,MAAM,eAAe,iBAAiB,QAAQ,OAAO;CACrD,IAAI,gBAAgB,MAGnB,OAAO,QACN,aACC,QAAQ,YACR,KAAA,GACA,QAAQ,cACR,6CAA6C,aAAa,kDAC3D,CACD;CAMD,MAAM,UAAU,QAAQ,QAAQ,KAAI,YAAW;EAC9C,GAAG,qBAAqB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,WAAW,CAAC,OAAO,SACtB,OAAO,+BAA+B,OAAO,IAAI,4BAA4B,WAAW;EAEzF,IAAI,OAAO,WAAW,WAAW,GAChC,OAAO,+BAA+B,OAAO,IAAI;EAElD,IAAI,UAAU,MAAM,KAAK,MAAM;GAC9B,IAAI,SACH,OAAO,+BAA+B,OAAO,IAAI,iDAAiD,WAAW;GAE9G,IAAI,mBACH,OAAO,+BAA+B,OAAO,IAAI,iDAAiD,WAAW;EAE/G;CACD;AAED"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PullRequestCheckLog } from "../../../git/models/pullRequest.js";
|
|
2
|
+
import { IntegrationIds } from "../constants.js";
|
|
3
|
+
import { ProviderResult } from "../results.js";
|
|
4
|
+
import { ProviderReadContext } from "./context.js";
|
|
5
|
+
//#region ../plus/integrations/src/reads/pullRequestCheckLogs.d.ts
|
|
6
|
+
/** One check whose log to read, echoed back under the caller's own `key`. */
|
|
7
|
+
export interface PullRequestCheckLogTarget {
|
|
8
|
+
/** Caller-owned identifier, echoed on the result. Must be unique. */
|
|
9
|
+
key: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
repo: string;
|
|
12
|
+
/** A `PullRequestCheckRun.id` from a batch pull request read, as it came. */
|
|
13
|
+
checkRunId: string;
|
|
14
|
+
}
|
|
15
|
+
/** The answer for one {@link PullRequestCheckLogTarget}: exactly one of `log` and `unavailable` is set. */
|
|
16
|
+
export type PullRequestCheckLogResult = PullRequestCheckLog & {
|
|
17
|
+
readonly key: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function getPullRequestCheckLogs(ctx: ProviderReadContext, options: {
|
|
20
|
+
providerId: IntegrationIds;
|
|
21
|
+
connectionId?: string;
|
|
22
|
+
domain?: string;
|
|
23
|
+
targets: readonly PullRequestCheckLogTarget[];
|
|
24
|
+
tailLines?: number;
|
|
25
|
+
}): Promise<ProviderResult<PullRequestCheckLogResult>>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//# sourceMappingURL=pullRequestCheckLogs.d.ts.map
|