@gitkraken/core-gitlens 0.38.0 → 0.38.2
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/service.d.ts +4 -1
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/unwatchedCacheValidator.d.ts +26 -4
- package/dist/git/watching/unwatchedCacheValidator.js +110 -10
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git-cli/exec/statWorkers.d.ts +50 -0
- package/dist/git-cli/exec/statWorkers.js +194 -0
- package/dist/git-cli/exec/statWorkers.js.map +1 -0
- package/dist/git-cli/service.d.ts +7 -4
- package/dist/git-cli/service.js +14 -17
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/jira.d.ts +5 -26
- package/dist/plus/integrations/providers/jira.js +76 -103
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +3 -24
- package/dist/plus/integrations/providers/linear.js +58 -74
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +3 -9
- package/dist/plus/integrations/providers/utils/discoveryCache.js +7 -12
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/dist/utils/env/node/exec.d.ts +3 -0
- package/dist/utils/env/node/exec.js +83 -18
- package/dist/utils/env/node/exec.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { chunk } from "../../../utils/array.js";
|
|
2
2
|
import { Logger as _logger } from "../../../utils/logger.js";
|
|
3
3
|
import { mapSettledBounded } from "../../../utils/promise.js";
|
|
4
|
-
import { areEqual } from "../../../utils/object.js";
|
|
5
4
|
import "../constants.js";
|
|
6
5
|
import { isJiraMissingProjectError } from "./providerErrors.js";
|
|
7
6
|
import { toCollectionScopeFailure } from "../collectionMetadata.js";
|
|
@@ -10,7 +9,7 @@ import { providersMetadata, toAccount, toIssueShape, toProviderIssueStates } fro
|
|
|
10
9
|
import { toTokenWithInfo } from "../authentication/models.js";
|
|
11
10
|
import { IssuesIntegration, groupProjectIssuesSearches } from "../models/issuesIntegration.js";
|
|
12
11
|
import { createIssueAutolinkReferences } from "./utils/issueAutolinks.js";
|
|
13
|
-
import { DiscoveryCache, isAutolinkSetExpired
|
|
12
|
+
import { DiscoveryCache, isAutolinkSetExpired } from "./utils/discoveryCache.js";
|
|
14
13
|
import { drainJiraIssues, readUserScopedJiraIssues, searchJiraProjectIssues, summarizePageMetadata, toUniqueJiraIssueShapes } from "./utils/jiraIssueDrains.js";
|
|
15
14
|
import { toJiraIssueEtagFields } from "./jiraIssueByKey.js";
|
|
16
15
|
import { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from "@gitkraken/provider-apis";
|
|
@@ -66,22 +65,13 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
66
65
|
* from it in `_autolinks` (#6176). Cleared with `_projects`, whose generation then refuses those same writes.
|
|
67
66
|
*/
|
|
68
67
|
_projectEvictions = /* @__PURE__ */ new Map();
|
|
69
|
-
/**
|
|
70
|
-
* Moves whenever `_autolinks` is dropped for a list a build reads, so a build that then fails keeps no fallback
|
|
71
|
-
* over lists it didn't read; the next render builds from them instead (#6183). Rule: every writer that stores a
|
|
72
|
-
* different project list for a site must bump it and retire the token's build, through {@link onProjectListStored};
|
|
73
|
-
* the same list stored again does neither while a complete set is kept (#6184). The connect's clear bumps it too.
|
|
74
|
-
* Site-list stores deliberately don't: a build's own site store would then refuse its own fallback. Drops and
|
|
75
|
-
* evictions need no bump: they fail a build's `isCurrent`.
|
|
76
|
-
*/
|
|
77
|
-
_autolinksResets = 0;
|
|
78
68
|
async autolinks() {
|
|
79
69
|
if (!(this.maybeConnected ?? await this.isConnected()) || this._session == null) return [];
|
|
80
70
|
const session = this._session;
|
|
81
71
|
const cached = this._autolinks.get(session.accessToken);
|
|
82
72
|
if (this.connectionExpired === true) return cached?.autolinks ?? [];
|
|
83
|
-
if (cached == null) return this.buildAutolinks(session);
|
|
84
|
-
if (isAutolinkSetExpired(cached)) this.buildAutolinks(session);
|
|
73
|
+
if (cached == null || cached.builtAt === 0 && !cached.complete && cached.autolinks.length === 0) return this.buildAutolinks(session);
|
|
74
|
+
if (cached.builtAt === 0 || isAutolinkSetExpired(cached)) this.buildAutolinks(session);
|
|
85
75
|
return cached.autolinks;
|
|
86
76
|
}
|
|
87
77
|
/**
|
|
@@ -93,80 +83,47 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
93
83
|
const { accessToken } = session;
|
|
94
84
|
let build = this._autolinksBuilds.get(accessToken);
|
|
95
85
|
if (build == null) {
|
|
96
|
-
build = this.buildAutolinksCore(session).finally(() => {
|
|
86
|
+
build = this.buildAutolinksCore(session, () => build).finally(() => {
|
|
97
87
|
if (this._autolinksBuilds.get(accessToken) === build) this._autolinksBuilds.delete(accessToken);
|
|
98
88
|
});
|
|
99
89
|
this._autolinksBuilds.set(accessToken, build);
|
|
100
90
|
}
|
|
101
91
|
return build;
|
|
102
92
|
}
|
|
103
|
-
async buildAutolinksCore(session) {
|
|
93
|
+
async buildAutolinksCore(session, reader) {
|
|
104
94
|
const { accessToken } = session;
|
|
105
95
|
const generation = this._projects.generation;
|
|
106
96
|
const evictions = this._projectEvictions.get(accessToken);
|
|
107
|
-
const resets = this._autolinksResets;
|
|
108
|
-
const held = this._autolinks.get(accessToken);
|
|
109
|
-
const isCurrent = () => this._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions;
|
|
110
|
-
const keep = (autolinks, complete) => {
|
|
111
|
-
const kept = this._autolinks.get(accessToken);
|
|
112
|
-
if (isCurrent() && (complete || kept == null || kept === held || isEmptyAutolinkFallback(kept))) this._autolinks.set(accessToken, {
|
|
113
|
-
autolinks,
|
|
114
|
-
builtAt: Date.now(),
|
|
115
|
-
complete
|
|
116
|
-
});
|
|
117
|
-
return autolinks;
|
|
118
|
-
};
|
|
119
|
-
const keepHeld = () => this._autolinksResets === resets ? keep(held?.autolinks ?? [], false) : held?.autolinks ?? [];
|
|
120
97
|
try {
|
|
121
|
-
const organizations = await this.getProviderResourcesForUser(session);
|
|
122
|
-
if (organizations
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const { values: projects, metadata } = await this.getProviderProjectsForResourcesWithMetadata(session, organizations);
|
|
126
|
-
const current = isCurrent();
|
|
127
|
-
const heldNone = held == null || isEmptyAutolinkFallback(held);
|
|
128
|
-
const failedSites = new Set(metadata?.failures?.map((f) => f.scope?.resourceId));
|
|
129
|
-
const refsOf = (organization, siteProjects) => siteProjects.flatMap((project) => createIssueAutolinkReferences(project.key, `${organization.url}/browse/${project.key}-<num>`, organization));
|
|
130
|
-
const autolinks = [];
|
|
131
|
-
let complete = true;
|
|
132
|
-
for (const organization of organizations) {
|
|
133
|
-
const key = `${accessToken}:${organization.id}`;
|
|
134
|
-
const cachedProjects = current ? this._projects.get(key) : void 0;
|
|
135
|
-
const siteProjects = cachedProjects ?? projects.filter((p) => p.resourceId === organization.id);
|
|
136
|
-
const refs = refsOf(organization, siteProjects);
|
|
137
|
-
autolinks.push(...refs);
|
|
138
|
-
if (cachedProjects != null) continue;
|
|
139
|
-
complete = false;
|
|
140
|
-
if (!(failedSites.has(organization.id) || !siteProjects.length)) continue;
|
|
141
|
-
const stored = heldNone && current ? this._projects.peek(key) : void 0;
|
|
142
|
-
const had = stored != null ? refsOf(organization, stored) : held?.autolinks.filter((ref) => "prefix" in ref && ref.descriptor?.key === organization.id) ?? [];
|
|
143
|
-
const prefixes = new Set(refs.map((r) => r.prefix));
|
|
144
|
-
for (const ref of had) if (!prefixes.has(ref.prefix)) autolinks.push(ref);
|
|
98
|
+
const organizations = await this.getProviderResourcesForUser(session, false, reader);
|
|
99
|
+
if (organizations != null && this._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions) {
|
|
100
|
+
const projects = await this.getProviderProjectsForResourcesWithMetadata(session, organizations, false, reader);
|
|
101
|
+
if ((this._projects.generation !== generation || this._projectEvictions.get(accessToken) !== evictions) && (projects.values.length > 0 || !projects.metadata?.failures?.length)) return organizations.flatMap((organization) => getProjectAutolinks(organization, projects.values.filter((p) => p.resourceId === organization.id)));
|
|
145
102
|
}
|
|
146
|
-
return keep(autolinks, complete && sitesCached());
|
|
147
103
|
} catch (ex) {
|
|
148
104
|
_logger.error(ex, "JiraIntegration.autolinks");
|
|
149
|
-
return keepHeld();
|
|
150
105
|
}
|
|
106
|
+
return this.deriveAutolinks(accessToken, { store: this._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions });
|
|
151
107
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.
|
|
108
|
+
deriveAutolinks(accessToken, options) {
|
|
109
|
+
const organizations = this._organizations.peek(accessToken);
|
|
110
|
+
let complete = this._organizations.get(accessToken) != null;
|
|
111
|
+
const autolinks = [];
|
|
112
|
+
for (const organization of organizations ?? []) {
|
|
113
|
+
const key = `${accessToken}:${organization.id}`;
|
|
114
|
+
complete &&= this._projects.get(key) != null;
|
|
115
|
+
autolinks.push(...getProjectAutolinks(organization, this._projects.peek(key) ?? []));
|
|
116
|
+
}
|
|
117
|
+
if (options?.store !== false) this._autolinks.set(accessToken, {
|
|
118
|
+
autolinks,
|
|
119
|
+
complete,
|
|
120
|
+
builtAt: options?.settled !== false ? Date.now() : this._autolinks.get(accessToken)?.builtAt || (complete ? Date.now() : 0)
|
|
121
|
+
});
|
|
122
|
+
return autolinks;
|
|
123
|
+
}
|
|
124
|
+
onDiscoveryStored(accessToken, reader) {
|
|
125
|
+
if (this._autolinksBuilds.get(accessToken) !== reader?.()) this._autolinksBuilds.delete(accessToken);
|
|
126
|
+
this.deriveAutolinks(accessToken, { settled: false });
|
|
170
127
|
}
|
|
171
128
|
async getProviderAccountForResource(session, resource) {
|
|
172
129
|
const user = await (await this.getProvidersApi()).getCurrentUserForResource(toTokenWithInfo(this.id, session), resource.id);
|
|
@@ -196,18 +153,20 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
196
153
|
*/
|
|
197
154
|
_organizations = new DiscoveryCache();
|
|
198
155
|
_projects = new DiscoveryCache();
|
|
199
|
-
async getProviderResourcesForUser(session, force = false) {
|
|
156
|
+
async getProviderResourcesForUser(session, force = false, reader) {
|
|
200
157
|
const { accessToken } = session;
|
|
201
158
|
const cachedResources = this._organizations.get(accessToken);
|
|
202
159
|
if (cachedResources != null && !force) return cachedResources;
|
|
203
160
|
const generation = this._organizations.generation;
|
|
161
|
+
const started = this._organizations.startRead();
|
|
204
162
|
const organizations = await this.readOrganizations(session);
|
|
205
|
-
if (organizations == null)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
163
|
+
if (organizations == null) return void 0;
|
|
164
|
+
const stored = this._organizations.set(accessToken, organizations, {
|
|
165
|
+
generation,
|
|
166
|
+
read: started
|
|
167
|
+
});
|
|
168
|
+
if (stored === "changed") this.onDiscoveryStored(accessToken, reader);
|
|
169
|
+
return stored === false && this._organizations.generation === generation ? this._organizations.peek(accessToken) : organizations;
|
|
211
170
|
}
|
|
212
171
|
getProviderUncachedResourcesForUser(session) {
|
|
213
172
|
return this.readOrganizations(session);
|
|
@@ -221,7 +180,7 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
221
180
|
async getProviderProjectsForResources(session, resources, force = false) {
|
|
222
181
|
return (await this.getProviderProjectsForResourcesWithMetadata(session, resources, force)).values;
|
|
223
182
|
}
|
|
224
|
-
async getProviderProjectsForResourcesWithMetadata(session, resources, force = false) {
|
|
183
|
+
async getProviderProjectsForResourcesWithMetadata(session, resources, force = false, reader) {
|
|
225
184
|
const { accessToken } = session;
|
|
226
185
|
const projectsCache = this._projects;
|
|
227
186
|
const generation = projectsCache.generation;
|
|
@@ -234,56 +193,68 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
234
193
|
}
|
|
235
194
|
const resourcesWithoutProjects = force ? resources : resources.filter((resource) => !cachedProjects.has(resource.id));
|
|
236
195
|
const read = await this.readProjects(session, resourcesWithoutProjects);
|
|
237
|
-
const values = [
|
|
238
|
-
|
|
196
|
+
const values = [];
|
|
197
|
+
let metadata = read.metadata;
|
|
198
|
+
let changed = false;
|
|
199
|
+
for (const [resourceId, projects] of [...read.complete, ...read.incomplete]) {
|
|
239
200
|
if (this._projectEvictions.get(accessToken) !== evictions) continue;
|
|
240
|
-
|
|
201
|
+
if (projectsCache.set(`${accessToken}:${resourceId}`, projects, {
|
|
241
202
|
generation,
|
|
242
|
-
read: started
|
|
243
|
-
|
|
244
|
-
|
|
203
|
+
read: started,
|
|
204
|
+
complete: read.complete.has(resourceId)
|
|
205
|
+
}) === "changed") changed = true;
|
|
245
206
|
}
|
|
207
|
+
if (changed) this.onDiscoveryStored(accessToken, reader);
|
|
246
208
|
const current = projectsCache.generation === generation && this._projectEvictions.get(accessToken) === evictions;
|
|
247
209
|
for (const resource of resources) {
|
|
248
|
-
const resourceProjects = read.complete.get(resource.id) ?? cachedProjects.get(resource.id);
|
|
210
|
+
const resourceProjects = read.complete.get(resource.id) ?? read.incomplete.get(resource.id) ?? cachedProjects.get(resource.id);
|
|
249
211
|
if (resourceProjects == null) continue;
|
|
250
212
|
const stored = current ? projectsCache.peek(`${accessToken}:${resource.id}`) : void 0;
|
|
251
213
|
values.push(...stored ?? resourceProjects);
|
|
214
|
+
if (stored != null && projectsCache.get(`${accessToken}:${resource.id}`) == null) metadata = mergeCollectionMetadata(metadata, { completeness: "unknown" });
|
|
252
215
|
}
|
|
253
216
|
return {
|
|
254
217
|
values: uniqueProjects(values),
|
|
255
|
-
metadata
|
|
218
|
+
metadata
|
|
256
219
|
};
|
|
257
220
|
}
|
|
258
221
|
async getProviderUncachedProjectsForResourcesWithMetadata(session, resources) {
|
|
259
222
|
const read = await this.readProjects(session, resources);
|
|
260
223
|
return {
|
|
261
|
-
values: uniqueProjects([...read.
|
|
224
|
+
values: uniqueProjects([...read.incomplete.values(), ...read.complete.values()].flat()),
|
|
262
225
|
metadata: read.metadata
|
|
263
226
|
};
|
|
264
227
|
}
|
|
265
228
|
/**
|
|
266
229
|
* Reads the projects of each resource from the provider, apart by whether a resource's list came back complete:
|
|
267
|
-
*
|
|
230
|
+
* incomplete lists remain available for decoration but cannot satisfy a fresh discovery read.
|
|
268
231
|
*/
|
|
269
232
|
async readProjects(session, resources) {
|
|
270
233
|
const complete = /* @__PURE__ */ new Map();
|
|
271
|
-
const
|
|
234
|
+
const incompleteLists = /* @__PURE__ */ new Map();
|
|
272
235
|
let metadata;
|
|
273
236
|
if (resources.length === 0) return {
|
|
274
237
|
complete,
|
|
275
|
-
|
|
238
|
+
incomplete: incompleteLists,
|
|
276
239
|
metadata
|
|
277
240
|
};
|
|
278
241
|
const api = await this.getProvidersApi();
|
|
279
242
|
const tokenWithInfo = toTokenWithInfo(this.id, session);
|
|
280
|
-
(await Promise.allSettled(resources.map(async (resource) =>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
243
|
+
(await Promise.allSettled(resources.map(async (resource) => {
|
|
244
|
+
let readPage = false;
|
|
245
|
+
return {
|
|
246
|
+
resource,
|
|
247
|
+
result: await collectProviderPagedResult(async (cursor) => {
|
|
248
|
+
const page = await api.getJiraProjectsForResource(tokenWithInfo, resource.id, { cursor });
|
|
249
|
+
readPage ||= page != null && (page.values.length > 0 || !page.metadata?.failures?.length);
|
|
250
|
+
return page;
|
|
251
|
+
}, maxPagesPerRequest, {
|
|
252
|
+
providerId: this.id,
|
|
253
|
+
resourceId: resource.id
|
|
254
|
+
}),
|
|
255
|
+
readPage
|
|
256
|
+
};
|
|
257
|
+
}))).forEach((drain, index) => {
|
|
287
258
|
if (drain.status === "rejected") {
|
|
288
259
|
const resource = resources[index];
|
|
289
260
|
if (resource == null) return;
|
|
@@ -296,11 +267,11 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
296
267
|
});
|
|
297
268
|
return;
|
|
298
269
|
}
|
|
299
|
-
const { resource, result } = drain.value;
|
|
270
|
+
const { resource, result, readPage } = drain.value;
|
|
300
271
|
metadata = mergeCollectionMetadata(metadata, result.metadata);
|
|
301
272
|
const projects = result.values.filter((project) => project.resourceId === resource.id).map((project) => ({ ...project }));
|
|
302
273
|
if (result.truncated === true || result.metadata != null && result.metadata.completeness !== "complete") {
|
|
303
|
-
|
|
274
|
+
if (readPage) incompleteLists.set(resource.id, projects);
|
|
304
275
|
if (result.truncated === true && (result.metadata == null || result.metadata.completeness === "complete")) metadata = mergeCollectionMetadata(metadata, { completeness: "partial" });
|
|
305
276
|
return;
|
|
306
277
|
}
|
|
@@ -308,7 +279,7 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
308
279
|
});
|
|
309
280
|
return {
|
|
310
281
|
complete,
|
|
311
|
-
|
|
282
|
+
incomplete: incompleteLists,
|
|
312
283
|
metadata
|
|
313
284
|
};
|
|
314
285
|
}
|
|
@@ -588,7 +559,6 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
588
559
|
}
|
|
589
560
|
async providerOnConnect() {
|
|
590
561
|
this._autolinks.clear();
|
|
591
|
-
this._autolinksResets++;
|
|
592
562
|
if (this._session == null) return;
|
|
593
563
|
const session = this._session;
|
|
594
564
|
const organizations = await this.getProviderResourcesForUser(session, true);
|
|
@@ -608,6 +578,9 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
608
578
|
this._autolinks.clear();
|
|
609
579
|
}
|
|
610
580
|
};
|
|
581
|
+
function getProjectAutolinks(organization, projects) {
|
|
582
|
+
return projects.flatMap((project) => createIssueAutolinkReferences(project.key, `${organization.url}/browse/${project.key}-<num>`, organization));
|
|
583
|
+
}
|
|
611
584
|
/** The projects once each, by site and id. */
|
|
612
585
|
function uniqueProjects(projects) {
|
|
613
586
|
const projectsByIdentity = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jira.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { areEqual } from '@gitlens/utils/object.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration } from '../models/issuesIntegration.js';\nimport type { JiraIssueEtagResponse } from './jiraIssueByKey.js';\nimport { jiraBulkFetchMaxKeys, toJiraIssueEtagFields } from './jiraIssueByKey.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { providersMetadata, toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraMissingProjectError } from './providerErrors.js';\nimport { DiscoveryCache, isAutolinkSetExpired, isEmptyAutolinkFallback } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\n\ttoUniqueJiraIssueShapes,\n} from './utils/jiraIssueDrains.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Jira];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/** A numeric issue id, which Jira's issue reads accept in place of a key. */\nconst numericIssueId = /^\\d+$/;\n\n/**\n * `assignee` and `creator` are user FIELDS: Jira resolves an accountId against the directory, which is the identity\n * that keeps matching once a display name cannot be looked up — a deactivated account, or a profile whose visibility\n * hides the name. Measured against a live site: a deactivated assignee returns its issues by accountId and an empty\n * page by display name, and Jira reports that miss as a successful empty search rather than an error, so the list\n * simply appears empty.\n *\n * `mention` is NOT a user field. It is `comment ~ \"...\"`, a free-text search over comment bodies, so an accountId\n * matches nothing there and the display name is the only value that can. Hence the id is applied to the first two\n * and the handle is kept for the third, rather than swapping `user` wholesale.\n */\nfunction toUserIdentities(user: string, options: IssuesForProjectOptions): { userField: string; mention: string } {\n\treturn { userField: options.userId ?? user, mention: user };\n}\n\nexport type JiraBaseDescriptor = IssueResourceDescriptor;\n\nexport interface JiraOrganizationDescriptor extends JiraBaseDescriptor {\n\turl: string;\n\tavatarUrl: string;\n}\n\nexport interface JiraProjectDescriptor extends JiraBaseDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Jira> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesCloudHostIntegrationId.Jira;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Jira';\n\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.atlassian.com';\n\t}\n\n\t/**\n\t * Built from the sites and their projects, so it follows them: rebuilt when a site's project list changes or the\n\t * caches are dropped, and once {@link isAutolinkSetExpired}: older than the TTL, or than a shorter retry delay when\n\t * the sites or a site's projects couldn't be read whole. An expired set is still served while it is rebuilt in the\n\t * background, because autolinks are read on every render of a commit message and must not wait on the network,\n\t * nor go empty just because nothing read the projects for a while (#5907, #6183).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number; complete: boolean }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\t/**\n\t * Moves, by token, on every missing-project eviction, which drops one site's list without clearing the caches: a\n\t * build or project read that started before it puts neither the list it read back in `_projects` nor what it built\n\t * from it in `_autolinks` (#6176). Cleared with `_projects`, whose generation then refuses those same writes.\n\t */\n\tprivate readonly _projectEvictions = new Map<string, number>();\n\t/**\n\t * Moves whenever `_autolinks` is dropped for a list a build reads, so a build that then fails keeps no fallback\n\t * over lists it didn't read; the next render builds from them instead (#6183). Rule: every writer that stores a\n\t * different project list for a site must bump it and retire the token's build, through {@link onProjectListStored};\n\t * the same list stored again does neither while a complete set is kept (#6184). The connect's clear bumps it too.\n\t * Site-list stores deliberately don't: a build's own site store would then refuse its own fallback. Drops and\n\t * evictions need no bump: they fail a build's `isCurrent`.\n\t */\n\tprivate _autolinksResets = 0;\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\t// A session kept through a failed refresh is expired: building with it would send that token to the provider\n\t\t// on every render, so serve whatever was built before (none after a forced re-sync) until a read refreshes it.\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (isAutolinkSetExpired(cached)) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/**\n\t * One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. A\n\t * drop, a missing-project eviction or a change to a site's project list retires it, so a render after one doesn't\n\t * join a build reading the lists as they were before (#6170, #6176, #6184).\n\t */\n\tprivate buildAutolinks(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tlet build = this._autolinksBuilds.get(accessToken);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => {\n\t\t\t\t// A drop, an eviction or a list change meanwhile retired this build, and the entry may be a later\n\t\t\t\t// one's now.\n\t\t\t\tif (this._autolinksBuilds.get(accessToken) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._projects.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\tconst resets = this._autolinksResets;\n\t\t// What this build falls back on, and carries over for the sites it couldn't read\n\t\tconst held = this._autolinks.get(accessToken);\n\t\t// False once the caches were dropped, or a site's list evicted, since this build started: what it read then is\n\t\t// only an answer for the render that waited on it.\n\t\tconst isCurrent = (): boolean =>\n\t\t\tthis._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions;\n\t\t// Kept even when incomplete, to be retried sooner rather than by every render (#6183). Complete only when built\n\t\t// wholly from the lists as stored now, the site list and every site's projects. Once a list change retired this\n\t\t// build, another may have kept a set meanwhile: a complete set still replaces it, and any replaces an empty\n\t\t// incomplete one, the fallback of a build that read none; otherwise, as it also rests on what only this build\n\t\t// read (its site list, a site cut short) or held, it only replaces the set it held, or none (#6184). Refused, it\n\t\t// still answers the renders waiting on it with its own result, a known limit.\n\t\tconst keep = (\n\t\t\tautolinks: (AutolinkReference | DynamicAutolinkReference)[],\n\t\t\tcomplete: boolean,\n\t\t): (AutolinkReference | DynamicAutolinkReference)[] => {\n\t\t\tconst kept = this._autolinks.get(accessToken);\n\t\t\tif (isCurrent() && (complete || kept == null || kept === held || isEmptyAutolinkFallback(kept))) {\n\t\t\t\tthis._autolinks.set(accessToken, {\n\t\t\t\t\tautolinks: autolinks,\n\t\t\t\t\tbuiltAt: Date.now(),\n\t\t\t\t\tcomplete: complete,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn autolinks;\n\t\t};\n\t\t// Serves the held set until the retry, unless a list was stored meanwhile\n\t\tconst keepHeld = (): (AutolinkReference | DynamicAutolinkReference)[] =>\n\t\t\tthis._autolinksResets === resets ? keep(held?.autolinks ?? [], false) : (held?.autolinks ?? []);\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session);\n\t\t\tif (organizations == null) return keepHeld();\n\n\t\t\t// Whether the site list is still the one stored, expired or not: a read storing a different one since\n\t\t\t// replaced it\n\t\t\tconst sitesCached = (): boolean => areEqual(this._organizations.peek(accessToken), organizations);\n\t\t\tif (!organizations.length) return keep([], sitesCached());\n\n\t\t\t// Served from the cache for every site whose projects are still fresh; only the rest are read.\n\t\t\tconst { values: projects, metadata } = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\tsession,\n\t\t\t\torganizations,\n\t\t\t);\n\n\t\t\t// Each site's projects as cached now, which any read during this build may have refreshed. A site with none\n\t\t\t// cached fresh serves what the read answered for it, its newest list stored when read whole, and, where that\n\t\t\t// read failed or got nothing, the prefixes it had, rather than losing its links until the retry.\n\t\t\tconst current = isCurrent();\n\t\t\t// No set held, as once a list change dropped it, or only the empty fallback a build that read none kept\n\t\t\tconst heldNone = held == null || isEmptyAutolinkFallback(held);\n\t\t\tconst failedSites = new Set(metadata?.failures?.map(f => f.scope?.resourceId));\n\t\t\tconst refsOf = (\n\t\t\t\torganization: JiraOrganizationDescriptor,\n\t\t\t\tsiteProjects: JiraProjectDescriptor[],\n\t\t\t): AutolinkReference[] =>\n\t\t\t\tsiteProjects.flatMap(project =>\n\t\t\t\t\tcreateIssueAutolinkReferences(\n\t\t\t\t\t\tproject.key,\n\t\t\t\t\t\t`${organization.url}/browse/${project.key}-<num>`,\n\t\t\t\t\t\torganization,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\t\tlet complete = true;\n\t\t\tfor (const organization of organizations) {\n\t\t\t\tconst key = `${accessToken}:${organization.id}`;\n\t\t\t\tconst cachedProjects = current ? this._projects.get(key) : undefined;\n\t\t\t\tconst siteProjects = cachedProjects ?? projects.filter(p => p.resourceId === organization.id);\n\t\t\t\tconst refs = refsOf(organization, siteProjects);\n\t\t\t\tautolinks.push(...refs);\n\t\t\t\tif (cachedProjects != null) continue;\n\n\t\t\t\tcomplete = false;\n\t\t\t\t// A site whose read failed, or got nothing, keeps the prefixes it had; one only cut short has none missing\n\t\t\t\tconst failed = failedSites.has(organization.id) || !siteProjects.length;\n\t\t\t\tif (!failed) continue;\n\n\t\t\t\t// Those of the set held, keyed by the site's id (#6183); with none, those of the site's last list stored,\n\t\t\t\t// expired or not, which a list change dropping the set leaves in place (#6184). Known limits, until the\n\t\t\t\t// carry moves into the cache: that list is the last one read whole, so a site read cut short since can\n\t\t\t\t// carry prefixes that read no longer lists; and a site never read whole carries none once the set it was\n\t\t\t\t// carried in is dropped.\n\t\t\t\tconst stored = heldNone && current ? this._projects.peek(key) : undefined;\n\t\t\t\tconst had =\n\t\t\t\t\tstored != null\n\t\t\t\t\t\t? refsOf(organization, stored)\n\t\t\t\t\t\t: (held?.autolinks.filter(\n\t\t\t\t\t\t\t\t(ref): ref is AutolinkReference =>\n\t\t\t\t\t\t\t\t\t'prefix' in ref && ref.descriptor?.key === organization.id,\n\t\t\t\t\t\t\t) ?? []);\n\t\t\t\tconst prefixes = new Set(refs.map(r => r.prefix));\n\t\t\t\tfor (const ref of had) {\n\t\t\t\t\tif (!prefixes.has(ref.prefix)) {\n\t\t\t\t\t\tautolinks.push(ref);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn keep(autolinks, complete && sitesCached());\n\t\t} catch (ex) {\n\t\t\t// Autolinks are decoration: don't fail the render that asked\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t\treturn keepHeld();\n\t\t}\n\t}\n\n\t/**\n\t * A site's project list was stored. A different one drops the autolinks built from the lists, so a build that then\n\t * fails keeps no fallback, and retires the build in flight, which may hold the list as it was. The same one again\n\t * keeps a complete set and the build in flight; otherwise it drops the incomplete set kept, if any, so the next\n\t * render builds from the lists again, and still fences a failing build's fallback (#6183, #6184). Other tokens' sets\n\t * and builds stay; only `_autolinksResets`, shared by all tokens, also stops their failing builds' fallback.\n\t *\n\t * A known limit: a build whose own read stores a different list, or a site's first one (with nothing seeded since a\n\t * start, a clear or an eviction, every first store reads as different), retires itself too. A render in the\n\t * microtasks before that build resumes then starts a second one rather than joining it; that one builds from the\n\t * cache, reading again only the sites the first couldn't read whole. A loss of the sharing core had, with no effect\n\t * on what is kept, and none on an identical list, which retires nothing.\n\t */\n\tprivate onProjectListStored(accessToken: string, stored: 'changed' | 'unchanged'): void {\n\t\tif (stored === 'changed') {\n\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t} else if (this._autolinks.get(accessToken)?.complete === true) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._autolinks.delete(accessToken);\n\t\tthis._autolinksResets++;\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getCurrentUserForResource(toTokenWithInfo(this.id, session), resource.id);\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\t/** Atlassian's account id is the same on every site, so the first site answers for all of them. */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst resource = (await this.getProviderResourcesForUser(session))?.[0];\n\t\treturn resource != null ? this.getProviderAccountForResource(session, resource) : undefined;\n\t}\n\n\t/** The site-list request the resource cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Jira did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Atlassian's `401` for a token missing a scope the request needs, which a reconnect fixes by consenting to it\n\t * again; see `IntegrationBase.isCredentialRefusal`. Atlassian gives the same answer to a malformed request URL,\n\t * so a request the SDK built wrong would read as the credential's too.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 401 && /scope does not match/i.test(refusal.detail ?? '');\n\t}\n\n\t/**\n\t * The sites and the projects discovered under them, both of which expire and are dropped on a re-sync, so a site\n\t * or project created or deleted mid-session is picked up (#5907). Keyed by token, and projects by token and site.\n\t */\n\tprivate readonly _organizations = new DiscoveryCache<JiraOrganizationDescriptor[]>();\n\tprivate readonly _projects = new DiscoveryCache<JiraProjectDescriptor[]>();\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._organizations.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst generation = this._organizations.generation;\n\t\tconst organizations = await this.readOrganizations(session);\n\t\tif (organizations == null) {\n\t\t\tthis._organizations.delete(accessToken);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis._organizations.set(accessToken, organizations, { generation: generation });\n\t\treturn organizations;\n\t}\n\n\tprotected override getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\treturn this.readOrganizations(session);\n\t}\n\n\tprivate async readOrganizations(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\treturn resources?.map(r => ({ ...r, key: r.id }));\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<JiraProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources, force)).values;\n\t}\n\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\tconst started = projectsCache.startRead();\n\n\t\t// Taken before the read, so a clear while it is in flight can't empty what was cached when it started. A forced\n\t\t// read reads every resource, and still keeps a cached list for one it can't read completely.\n\t\tconst cachedProjects = new Map<string, JiraProjectDescriptor[]>();\n\t\tfor (const resource of resources) {\n\t\t\tconst projects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (projects != null) {\n\t\t\t\tcachedProjects.set(resource.id, projects);\n\t\t\t}\n\t\t}\n\t\tconst resourcesWithoutProjects = force\n\t\t\t? resources\n\t\t\t: resources.filter(resource => !cachedProjects.has(resource.id));\n\n\t\tconst read = await this.readProjects(session, resourcesWithoutProjects);\n\t\tconst values = [...read.partial];\n\t\tfor (const [resourceId, projects] of read.complete) {\n\t\t\t// Not stored when the cache was dropped, a list evicted, or a read started after this one stored it, while\n\t\t\t// this read was in flight: what it found is then no longer trusted for the next read.\n\t\t\tif (this._projectEvictions.get(accessToken) !== evictions) continue;\n\n\t\t\tconst stored = projectsCache.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\tgeneration: generation,\n\t\t\t\tread: started,\n\t\t\t});\n\t\t\tif (stored !== false) {\n\t\t\t\tthis.onProjectListStored(accessToken, stored);\n\t\t\t}\n\t\t}\n\t\t// A site read whole, or served from the cache, answers with its newest list stored: this read's own, or the one\n\t\t// a read started after it stored, which this older read must not stand in for, not even once expired (#6184).\n\t\t// Once the cache was dropped or a list evicted meanwhile, only what it found itself.\n\t\tconst current =\n\t\t\tprojectsCache.generation === generation && this._projectEvictions.get(accessToken) === evictions;\n\t\tfor (const resource of resources) {\n\t\t\tconst resourceProjects = read.complete.get(resource.id) ?? cachedProjects.get(resource.id);\n\t\t\tif (resourceProjects == null) continue;\n\n\t\t\tconst stored = current ? projectsCache.peek(`${accessToken}:${resource.id}`) : undefined;\n\t\t\tvalues.push(...(stored ?? resourceProjects));\n\t\t}\n\t\treturn { values: uniqueProjects(values), metadata: read.metadata };\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst read = await this.readProjects(session, resources);\n\t\treturn {\n\t\t\tvalues: uniqueProjects([...read.partial, ...[...read.complete.values()].flat()]),\n\t\t\tmetadata: read.metadata,\n\t\t};\n\t}\n\n\t/**\n\t * Reads the projects of each resource from the provider, apart by whether a resource's list came back complete:\n\t * only a complete one may be cached as the resource's project set.\n\t */\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<{\n\t\tcomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tpartial: JiraProjectDescriptor[];\n\t\tmetadata: CollectionMetadata | undefined;\n\t}> {\n\t\tconst complete = new Map<string, JiraProjectDescriptor[]>();\n\t\tconst partial: JiraProjectDescriptor[] = [];\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tif (resources.length === 0) return { complete: complete, partial: partial, metadata: metadata };\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst drains = await Promise.allSettled(\n\t\t\tresources.map(async resource => ({\n\t\t\t\tresource: resource,\n\t\t\t\tresult: await collectProviderPagedResult(\n\t\t\t\t\tcursor => api.getJiraProjectsForResource(tokenWithInfo, resource.id, { cursor: cursor }),\n\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t),\n\t\t\t})),\n\t\t);\n\n\t\tdrains.forEach((drain, index) => {\n\t\t\tif (drain.status === 'rejected') {\n\t\t\t\tconst resource = resources[index];\n\t\t\t\tif (resource == null) return;\n\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [\n\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { resource, result } = drain.value;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\tconst projects = result.values\n\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t.map(project => ({ ...project }));\n\t\t\tconst incomplete =\n\t\t\t\tresult.truncated === true || (result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tif (incomplete) {\n\t\t\t\tpartial.push(...projects);\n\t\t\t\tif (\n\t\t\t\t\tresult.truncated === true &&\n\t\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t\t) {\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcomplete.set(resource.id, projects);\n\t\t});\n\t\treturn { complete: complete, partial: partial, metadata: metadata };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\t// By key, not name, as the multi-project search: JQL's `project = \"<value>\"` also accepts a name or id, so a\n\t\t// display name equal to another project's key would address that project. The key is the only unambiguous one.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.key, project.resourceId, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.key },\n\t\t\tproviderName: 'Jira',\n\t\t\t// A project this token can no longer see (deleted, or its browse permission removed) holds no issues\n\t\t\t// for it, and the site's project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira project '${project.key}' no longer exists or is not visible`);\n\t\t\t\tconst { accessToken } = session;\n\t\t\t\tthis._projects.delete(`${accessToken}:${project.resourceId}`);\n\t\t\t\t// A build or project read in flight may hold the list just dropped; see `_projectEvictions`.\n\t\t\t\tthis._projectEvictions.set(accessToken, (this._projectEvictions.get(accessToken) ?? 0) + 1);\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user, options),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\n\t}\n\n\t/**\n\t * Searches a site's projects together for a user-scoped read: one JQL names up to\n\t * {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one site and one user scope, past which the SDK refuses\n\t * the call rather than risk a query string Jira rejects.\n\t *\n\t * An unscoped read is never searched across projects: it drains every issue in the project, and its backstop is\n\t * reported as `narrow-scope` per project, which one search across projects could not attribute.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ project, options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t].join('\\0')\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its site and user scope (see `getProjectIssuesSearches`).\n\t\tconst { project, options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\t\t// One project's search is its own read, by the same key and user clauses, so it costs no more to read it as one;\n\t\t// and that read attributes a failure to the project and drops a project list that no longer has it.\n\t\tif (requests.length === 1) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\t// By key, not name: JQL resolves `project = \"<value>\"` against key first, so a name could read another\n\t\t// project's issues.\n\t\tconst projectKeys = requests.map(request => request.project.key);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getIssuesForProjectsPaged(tokenWithInfo, projectKeys, project.resourceId, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\trequests.map(request => request.project.id),\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user, options),\n\t\t\t{\n\t\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId },\n\t\t\t\tproviderName: 'Jira',\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\tconst result = await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation);\n\t\t// This read can only return values, so what the account-wide read reports as missing is at least logged.\n\t\tfor (const failure of result?.metadata?.failures ?? []) {\n\t\t\tLogger.warn(\n\t\t\t\t`searchProviderMyIssues: Jira site '${failure.scope?.resourceId ?? '?'}' was not fully read: ${failure.message ?? failure.kind}`,\n\t\t\t);\n\t\t}\n\t\treturn result?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Each site is drained on its own, so a\n\t * site that fails keeps what it read and is recorded as that site's failure instead of discarding the sites that\n\t * answered; so is an issue a page dropped because it could not be read. A page backstop or a stalled continuation\n\t * makes the read `truncated`. A refused site therefore goes through `confirmScopedAuthFailures`, which publishes it\n\t * as that site's auth warning or, if the credential itself is refused, as the connection's.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst myResources = resources ?? (await this.getProviderResourcesForUser(session));\n\t\tif (!myResources) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst results: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\t// What each page reported failing, summarized at the end so a site whose many pages dropped issues reports\n\t\t// it once (see `summarizePageMetadata`); the pages keep the rest of their metadata, so `truncated` holds.\n\t\tconst pages: CollectionMetadata[] = [];\n\t\tconst readPage = async (resourceId: string, cursor: string | undefined) => {\n\t\t\tconst page = await api.getIssuesForResourceForCurrentUser(tokenWithInfo, resourceId, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (!page.metadata?.failures?.length) return page;\n\n\t\t\tconst { failures: _failures, ...rest } = page.metadata;\n\t\t\tpages.push(page.metadata);\n\t\t\treturn { ...page, metadata: rest };\n\t\t};\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst site = await collectProviderPagedResult(\n\t\t\t\tcursor =>\n\t\t\t\t\t// Cancellation is not truncation: the caller asked for the stop, so the site ends where it is.\n\t\t\t\t\tcancellation?.aborted\n\t\t\t\t\t\t? Promise.resolve({ values: [], paging: { cursor: '{}', more: false } })\n\t\t\t\t\t\t: readPage(resource.id, cursor),\n\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t);\n\t\t\tresults.push(\n\t\t\t\t...site.values\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((result): result is IssueShape => result != null),\n\t\t\t);\n\t\t\ttruncated ||= site.truncated === true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, site.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: key,\n\t\t});\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\tresourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tif (resourceUrl == null) {\n\t\t\tthrow new Error('Jira direct issue reads require a resource URL');\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraIssueByKey(toTokenWithInfo(this.id, session), resourceId, resourceUrl, id);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'batch' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one bulk fetch per site and {@link jiraBulkFetchMaxKeys}\n\t * distinct keys, where {@link getProviderIssueByResourceId} sends one request per issue. A request that throws\n\t * rejects only its own targets' slots, with its error classified as the full read's would be.\n\t *\n\t * A target identified by a numeric issue id, which both reads accept as well as a key, is matched by the returned\n\t * issue's `id`; every other target by its key.\n\t *\n\t * Never proves an absence. Jira silently omits a key it can't find or show (listing it in no `issueErrors` either),\n\t * and answers a moved issue under its new key, which no longer matches the key asked for. Either way the target's\n\t * slot is rejected, so the full read distinguishes a missing issue from a site failure. When no target was\n\t * answered and nothing failed, the check declines, so a batch of only such keys costs a full read, not a failure.\n\t */\n\tprotected override async getProviderIssuesEtagFieldsByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { resourceId: string; identifier: string; resourceUrl?: string }[],\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst slots = new Array<PromiseSettledResult<IssueEtagFields | undefined>>(targets.length);\n\t\tlet answered = false;\n\t\tlet failed = false;\n\n\t\t// Each site's distinct keys, matched case-insensitively as Jira matches them, with the targets asking for each.\n\t\tconst bySite = new Map<string, Map<string, number[]>>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tif (target.resourceUrl == null) {\n\t\t\t\t// Required as the full read requires it, so a check never answers for a target the full read refuses.\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error('Jira direct issue reads require a resource URL'),\n\t\t\t\t};\n\t\t\t\tfailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet keys = bySite.get(target.resourceId);\n\t\t\tif (keys == null) {\n\t\t\t\tkeys = new Map();\n\t\t\t\tbySite.set(target.resourceId, keys);\n\t\t\t}\n\n\t\t\tconst key = target.identifier.toUpperCase();\n\t\t\tlet indices = keys.get(key);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tkeys.set(key, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...bySite].flatMap(([resourceId, keys]) =>\n\t\t\tchunk([...keys], jiraBulkFetchMaxKeys).map(entries => ({ resourceId: resourceId, entries: entries })),\n\t\t);\n\t\tif (!requests.length) return slots;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\tapi.getJiraIssuesEtagFields(\n\t\t\t\ttokenWithInfo,\n\t\t\t\tr.resourceId,\n\t\t\t\tr.entries.map(([key]) => key),\n\t\t\t),\n\t\t);\n\n\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\tconst { entries } = requests[i];\n\t\t\tif (answer.status === 'rejected') {\n\t\t\t\tfailed = true;\n\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (answer.value.errorCount > 0) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\n\t\t\t// By key or id, never by position: Jira returns the issues in its own order, and only the ones it found.\n\t\t\tconst byKey = new Map<string, JiraIssueEtagResponse>();\n\t\t\tconst byId = new Map<string, JiraIssueEtagResponse>();\n\t\t\tfor (const issue of answer.value.issues) {\n\t\t\t\tbyKey.set(issue.key.toUpperCase(), issue);\n\t\t\t\tbyId.set(issue.id, issue);\n\t\t\t}\n\n\t\t\tfor (const [key, indices] of entries) {\n\t\t\t\t// A key target never matches by id, so an issue returned under a different key (moved) is rejected.\n\t\t\t\tconst issue = numericIssueId.test(key) ? byId.get(key) : byKey.get(key);\n\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\tif (issue == null) {\n\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Jira bulk fetch did not return ${key}`) };\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tslot = { status: 'fulfilled', value: toJiraIssueEtagFields(issue) };\n\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of indices) {\n\t\t\t\t\tslots[index] = slot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksResets++;\n\t\tif (this._session == null) return;\n\n\t\tconst session = this._session;\n\t\tconst organizations = await this.getProviderResourcesForUser(session, true);\n\t\tif (organizations?.length) {\n\t\t\tawait this.getProviderProjectsForResources(session, organizations, true);\n\t\t}\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n\n/** The projects once each, by site and id. */\nfunction uniqueProjects(projects: JiraProjectDescriptor[]): JiraProjectDescriptor[] {\n\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\tfor (const project of projects) {\n\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\tprojectsByIdentity.set(identity, project);\n\t\t}\n\t}\n\treturn [...projectsByIdentity.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;AAE3B,MA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AM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,WAAW,MAAM;EACtB,KAAK,iBAAiB,MAAM;CAC7B;CAEA,uBAAgD;EAC/C,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,WAAW,MAAM;CACvB;AACD;;AAGA,SAAS,eAAe,UAA4D;CACnF,MAAM,qCAAqB,IAAI,IAAmC;CAClE,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,WAAW,GAAG,QAAQ,WAAW,GAAG,QAAQ;EAClD,IAAI,CAAC,mBAAmB,IAAI,QAAQ,GACnC,mBAAmB,IAAI,UAAU,OAAO;CAE1C;CACA,OAAO,CAAC,GAAG,mBAAmB,OAAO,CAAC;AACvC"}
|
|
1
|
+
{"version":3,"file":"jira.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration } from '../models/issuesIntegration.js';\nimport type { JiraIssueEtagResponse } from './jiraIssueByKey.js';\nimport { jiraBulkFetchMaxKeys, toJiraIssueEtagFields } from './jiraIssueByKey.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { providersMetadata, toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraMissingProjectError } from './providerErrors.js';\nimport { DiscoveryCache, isAutolinkSetExpired } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\n\ttoUniqueJiraIssueShapes,\n} from './utils/jiraIssueDrains.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Jira];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/** A numeric issue id, which Jira's issue reads accept in place of a key. */\nconst numericIssueId = /^\\d+$/;\n\n/**\n * `assignee` and `creator` are user FIELDS: Jira resolves an accountId against the directory, which is the identity\n * that keeps matching once a display name cannot be looked up — a deactivated account, or a profile whose visibility\n * hides the name. Measured against a live site: a deactivated assignee returns its issues by accountId and an empty\n * page by display name, and Jira reports that miss as a successful empty search rather than an error, so the list\n * simply appears empty.\n *\n * `mention` is NOT a user field. It is `comment ~ \"...\"`, a free-text search over comment bodies, so an accountId\n * matches nothing there and the display name is the only value that can. Hence the id is applied to the first two\n * and the handle is kept for the third, rather than swapping `user` wholesale.\n */\nfunction toUserIdentities(user: string, options: IssuesForProjectOptions): { userField: string; mention: string } {\n\treturn { userField: options.userId ?? user, mention: user };\n}\n\nexport type JiraBaseDescriptor = IssueResourceDescriptor;\n\nexport interface JiraOrganizationDescriptor extends JiraBaseDescriptor {\n\turl: string;\n\tavatarUrl: string;\n}\n\nexport interface JiraProjectDescriptor extends JiraBaseDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Jira> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesCloudHostIntegrationId.Jira;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Jira';\n\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.atlassian.com';\n\t}\n\n\t/**\n\t * Built from the sites and their projects, so it follows them: rebuilt when a site's project list changes or the\n\t * caches are dropped, and once {@link isAutolinkSetExpired}: older than the TTL, or than a shorter retry delay when\n\t * the sites or a site's projects couldn't be read whole. An expired set is still served while it is rebuilt in the\n\t * background, because autolinks are read on every render of a commit message and must not wait on the network,\n\t * nor go empty just because nothing read the projects for a while (#5907, #6183).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number; complete: boolean }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\t/**\n\t * Moves, by token, on every missing-project eviction, which drops one site's list without clearing the caches: a\n\t * build or project read that started before it puts neither the list it read back in `_projects` nor what it built\n\t * from it in `_autolinks` (#6176). Cleared with `_projects`, whose generation then refuses those same writes.\n\t */\n\tprivate readonly _projectEvictions = new Map<string, number>();\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\t// A session kept through a failed refresh is expired: building with it would send that token to the provider\n\t\t// on every render, so serve whatever was built before (none after a forced re-sync) until a read refreshes it.\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null || (cached.builtAt === 0 && !cached.complete && cached.autolinks.length === 0)) {\n\t\t\treturn this.buildAutolinks(session);\n\t\t}\n\n\t\tif (cached.builtAt === 0 || isAutolinkSetExpired(cached)) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/**\n\t * One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. A\n\t * drop, a missing-project eviction or a change to a site's project list retires it, so a render after one doesn't\n\t * join a build reading the lists as they were before (#6170, #6176, #6184).\n\t */\n\tprivate buildAutolinks(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tlet build = this._autolinksBuilds.get(accessToken);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session, () => build).finally(() => {\n\t\t\t\t// A drop, an eviction or a list change meanwhile retired this build, and the entry may be a later\n\t\t\t\t// one's now.\n\t\t\t\tif (this._autolinksBuilds.get(accessToken) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t\treader?: () => Promise<unknown> | undefined,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._projects.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session, false, reader);\n\t\t\tif (\n\t\t\t\torganizations != null &&\n\t\t\t\tthis._projects.generation === generation &&\n\t\t\t\tthis._projectEvictions.get(accessToken) === evictions\n\t\t\t) {\n\t\t\t\tconst projects = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\t\tsession,\n\t\t\t\t\torganizations,\n\t\t\t\t\tfalse,\n\t\t\t\t\treader,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\t(this._projects.generation !== generation ||\n\t\t\t\t\t\tthis._projectEvictions.get(accessToken) !== evictions) &&\n\t\t\t\t\t(projects.values.length > 0 || !projects.metadata?.failures?.length)\n\t\t\t\t) {\n\t\t\t\t\t// Existing waiters own this successful response, but the active generation must not retain it.\n\t\t\t\t\treturn organizations.flatMap(organization =>\n\t\t\t\t\t\tgetProjectAutolinks(\n\t\t\t\t\t\t\torganization,\n\t\t\t\t\t\t\tprojects.values.filter(p => p.resourceId === organization.id),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t}\n\t\treturn this.deriveAutolinks(accessToken, {\n\t\t\tstore: this._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions,\n\t\t});\n\t}\n\n\tprivate deriveAutolinks(\n\t\taccessToken: string,\n\t\toptions?: {\n\t\t\tstore?: boolean;\n\t\t\tsettled?: boolean;\n\t\t},\n\t): (AutolinkReference | DynamicAutolinkReference)[] {\n\t\tconst organizations = this._organizations.peek(accessToken);\n\t\tlet complete = this._organizations.get(accessToken) != null;\n\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\tfor (const organization of organizations ?? []) {\n\t\t\tconst key = `${accessToken}:${organization.id}`;\n\t\t\tcomplete &&= this._projects.get(key) != null;\n\t\t\tautolinks.push(...getProjectAutolinks(organization, this._projects.peek(key) ?? []));\n\t\t}\n\t\tif (options?.store !== false) {\n\t\t\tthis._autolinks.set(accessToken, {\n\t\t\t\tautolinks: autolinks,\n\t\t\t\tcomplete: complete,\n\t\t\t\t// Stores preserve the retry deadline; only a settled build restarts it.\n\t\t\t\tbuiltAt:\n\t\t\t\t\toptions?.settled !== false\n\t\t\t\t\t\t? Date.now()\n\t\t\t\t\t\t: this._autolinks.get(accessToken)?.builtAt || (complete ? Date.now() : 0),\n\t\t\t});\n\t\t}\n\t\treturn autolinks;\n\t}\n\n\tprivate onDiscoveryStored(accessToken: string, reader?: () => Promise<unknown> | undefined): void {\n\t\t// A build's own store must not break sharing before its continuation runs.\n\t\tif (this._autolinksBuilds.get(accessToken) !== reader?.()) {\n\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t}\n\t\tthis.deriveAutolinks(accessToken, { settled: false });\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getCurrentUserForResource(toTokenWithInfo(this.id, session), resource.id);\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\t/** Atlassian's account id is the same on every site, so the first site answers for all of them. */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst resource = (await this.getProviderResourcesForUser(session))?.[0];\n\t\treturn resource != null ? this.getProviderAccountForResource(session, resource) : undefined;\n\t}\n\n\t/** The site-list request the resource cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Jira did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Atlassian's `401` for a token missing a scope the request needs, which a reconnect fixes by consenting to it\n\t * again; see `IntegrationBase.isCredentialRefusal`. Atlassian gives the same answer to a malformed request URL,\n\t * so a request the SDK built wrong would read as the credential's too.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 401 && /scope does not match/i.test(refusal.detail ?? '');\n\t}\n\n\t/**\n\t * The sites and the projects discovered under them, both of which expire and are dropped on a re-sync, so a site\n\t * or project created or deleted mid-session is picked up (#5907). Keyed by token, and projects by token and site.\n\t */\n\tprivate readonly _organizations = new DiscoveryCache<JiraOrganizationDescriptor[]>();\n\tprivate readonly _projects = new DiscoveryCache<JiraProjectDescriptor[]>();\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t\treader?: () => Promise<unknown> | undefined,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._organizations.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst generation = this._organizations.generation;\n\t\tconst started = this._organizations.startRead();\n\t\tconst organizations = await this.readOrganizations(session);\n\t\tif (organizations == null) return undefined;\n\n\t\tconst stored = this._organizations.set(accessToken, organizations, { generation: generation, read: started });\n\t\tif (stored === 'changed') {\n\t\t\tthis.onDiscoveryStored(accessToken, reader);\n\t\t}\n\t\treturn stored === false && this._organizations.generation === generation\n\t\t\t? this._organizations.peek(accessToken)\n\t\t\t: organizations;\n\t}\n\n\tprotected override getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\treturn this.readOrganizations(session);\n\t}\n\n\tprivate async readOrganizations(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\treturn resources?.map(r => ({ ...r, key: r.id }));\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<JiraProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources, force)).values;\n\t}\n\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t\treader?: () => Promise<unknown> | undefined,\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\tconst started = projectsCache.startRead();\n\n\t\t// Taken before the read, so a clear while it is in flight can't empty what was cached when it started. A forced\n\t\t// read reads every resource, and still keeps a cached list for one it can't read completely.\n\t\tconst cachedProjects = new Map<string, JiraProjectDescriptor[]>();\n\t\tfor (const resource of resources) {\n\t\t\tconst projects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (projects != null) {\n\t\t\t\tcachedProjects.set(resource.id, projects);\n\t\t\t}\n\t\t}\n\t\tconst resourcesWithoutProjects = force\n\t\t\t? resources\n\t\t\t: resources.filter(resource => !cachedProjects.has(resource.id));\n\n\t\tconst read = await this.readProjects(session, resourcesWithoutProjects);\n\t\tconst values: JiraProjectDescriptor[] = [];\n\t\tlet metadata = read.metadata;\n\t\tlet changed = false;\n\t\tfor (const [resourceId, projects] of [...read.complete, ...read.incomplete]) {\n\t\t\t// Not stored when the cache was dropped, a list evicted, or a read started after this one stored it, while\n\t\t\t// this read was in flight: what it found is then no longer trusted for the next read.\n\t\t\tif (this._projectEvictions.get(accessToken) !== evictions) continue;\n\n\t\t\tconst stored = projectsCache.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\tgeneration: generation,\n\t\t\t\tread: started,\n\t\t\t\tcomplete: read.complete.has(resourceId),\n\t\t\t});\n\t\t\tif (stored === 'changed') {\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t\tif (changed) {\n\t\t\tthis.onDiscoveryStored(accessToken, reader);\n\t\t}\n\n\t\t// A site read whole, or served from the cache, answers with its newest list stored: this read's own, or the one\n\t\t// a read started after it stored, which this older read must not stand in for, not even once expired (#6184).\n\t\t// Once the cache was dropped or a list evicted meanwhile, only what it found itself.\n\t\tconst current =\n\t\t\tprojectsCache.generation === generation && this._projectEvictions.get(accessToken) === evictions;\n\t\tfor (const resource of resources) {\n\t\t\tconst resourceProjects =\n\t\t\t\tread.complete.get(resource.id) ?? read.incomplete.get(resource.id) ?? cachedProjects.get(resource.id);\n\t\t\tif (resourceProjects == null) continue;\n\n\t\t\tconst stored = current ? projectsCache.peek(`${accessToken}:${resource.id}`) : undefined;\n\t\t\tvalues.push(...(stored ?? resourceProjects));\n\t\t\tif (stored != null && projectsCache.get(`${accessToken}:${resource.id}`) == null) {\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'unknown' });\n\t\t\t}\n\t\t}\n\t\treturn { values: uniqueProjects(values), metadata: metadata };\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst read = await this.readProjects(session, resources);\n\t\treturn {\n\t\t\tvalues: uniqueProjects([...read.incomplete.values(), ...read.complete.values()].flat()),\n\t\t\tmetadata: read.metadata,\n\t\t};\n\t}\n\n\t/**\n\t * Reads the projects of each resource from the provider, apart by whether a resource's list came back complete:\n\t * incomplete lists remain available for decoration but cannot satisfy a fresh discovery read.\n\t */\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<{\n\t\tcomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tincomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tmetadata: CollectionMetadata | undefined;\n\t}> {\n\t\tconst complete = new Map<string, JiraProjectDescriptor[]>();\n\t\tconst incompleteLists = new Map<string, JiraProjectDescriptor[]>();\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tif (resources.length === 0) {\n\t\t\treturn { complete: complete, incomplete: incompleteLists, metadata: metadata };\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst drains = await Promise.allSettled(\n\t\t\tresources.map(async resource => {\n\t\t\t\tlet readPage = false;\n\t\t\t\tconst result = await collectProviderPagedResult(\n\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\tconst page = await api.getJiraProjectsForResource(tokenWithInfo, resource.id, {\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treadPage ||= page != null && (page.values.length > 0 || !page.metadata?.failures?.length);\n\t\t\t\t\t\treturn page;\n\t\t\t\t\t},\n\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t);\n\t\t\t\treturn { resource: resource, result: result, readPage: readPage };\n\t\t\t}),\n\t\t);\n\n\t\tdrains.forEach((drain, index) => {\n\t\t\tif (drain.status === 'rejected') {\n\t\t\t\tconst resource = resources[index];\n\t\t\t\tif (resource == null) return;\n\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [\n\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { resource, result, readPage } = drain.value;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\tconst projects = result.values\n\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t.map(project => ({ ...project }));\n\t\t\tconst incomplete =\n\t\t\t\tresult.truncated === true || (result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tif (incomplete) {\n\t\t\t\tif (readPage) {\n\t\t\t\t\tincompleteLists.set(resource.id, projects);\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tresult.truncated === true &&\n\t\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t\t) {\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcomplete.set(resource.id, projects);\n\t\t});\n\t\treturn { complete: complete, incomplete: incompleteLists, metadata: metadata };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\t// By key, not name, as the multi-project search: JQL's `project = \"<value>\"` also accepts a name or id, so a\n\t\t// display name equal to another project's key would address that project. The key is the only unambiguous one.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.key, project.resourceId, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.key },\n\t\t\tproviderName: 'Jira',\n\t\t\t// A project this token can no longer see (deleted, or its browse permission removed) holds no issues\n\t\t\t// for it, and the site's project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira project '${project.key}' no longer exists or is not visible`);\n\t\t\t\tconst { accessToken } = session;\n\t\t\t\tthis._projects.delete(`${accessToken}:${project.resourceId}`);\n\t\t\t\t// A build or project read in flight may hold the list just dropped; see `_projectEvictions`.\n\t\t\t\tthis._projectEvictions.set(accessToken, (this._projectEvictions.get(accessToken) ?? 0) + 1);\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user, options),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\n\t}\n\n\t/**\n\t * Searches a site's projects together for a user-scoped read: one JQL names up to\n\t * {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one site and one user scope, past which the SDK refuses\n\t * the call rather than risk a query string Jira rejects.\n\t *\n\t * An unscoped read is never searched across projects: it drains every issue in the project, and its backstop is\n\t * reported as `narrow-scope` per project, which one search across projects could not attribute.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ project, options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t].join('\\0')\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its site and user scope (see `getProjectIssuesSearches`).\n\t\tconst { project, options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\t\t// One project's search is its own read, by the same key and user clauses, so it costs no more to read it as one;\n\t\t// and that read attributes a failure to the project and drops a project list that no longer has it.\n\t\tif (requests.length === 1) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\t// By key, not name: JQL resolves `project = \"<value>\"` against key first, so a name could read another\n\t\t// project's issues.\n\t\tconst projectKeys = requests.map(request => request.project.key);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getIssuesForProjectsPaged(tokenWithInfo, projectKeys, project.resourceId, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\trequests.map(request => request.project.id),\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user, options),\n\t\t\t{\n\t\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId },\n\t\t\t\tproviderName: 'Jira',\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\tconst result = await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation);\n\t\t// This read can only return values, so what the account-wide read reports as missing is at least logged.\n\t\tfor (const failure of result?.metadata?.failures ?? []) {\n\t\t\tLogger.warn(\n\t\t\t\t`searchProviderMyIssues: Jira site '${failure.scope?.resourceId ?? '?'}' was not fully read: ${failure.message ?? failure.kind}`,\n\t\t\t);\n\t\t}\n\t\treturn result?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Each site is drained on its own, so a\n\t * site that fails keeps what it read and is recorded as that site's failure instead of discarding the sites that\n\t * answered; so is an issue a page dropped because it could not be read. A page backstop or a stalled continuation\n\t * makes the read `truncated`. A refused site therefore goes through `confirmScopedAuthFailures`, which publishes it\n\t * as that site's auth warning or, if the credential itself is refused, as the connection's.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst myResources = resources ?? (await this.getProviderResourcesForUser(session));\n\t\tif (!myResources) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst results: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\t// What each page reported failing, summarized at the end so a site whose many pages dropped issues reports\n\t\t// it once (see `summarizePageMetadata`); the pages keep the rest of their metadata, so `truncated` holds.\n\t\tconst pages: CollectionMetadata[] = [];\n\t\tconst readPage = async (resourceId: string, cursor: string | undefined) => {\n\t\t\tconst page = await api.getIssuesForResourceForCurrentUser(tokenWithInfo, resourceId, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (!page.metadata?.failures?.length) return page;\n\n\t\t\tconst { failures: _failures, ...rest } = page.metadata;\n\t\t\tpages.push(page.metadata);\n\t\t\treturn { ...page, metadata: rest };\n\t\t};\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst site = await collectProviderPagedResult(\n\t\t\t\tcursor =>\n\t\t\t\t\t// Cancellation is not truncation: the caller asked for the stop, so the site ends where it is.\n\t\t\t\t\tcancellation?.aborted\n\t\t\t\t\t\t? Promise.resolve({ values: [], paging: { cursor: '{}', more: false } })\n\t\t\t\t\t\t: readPage(resource.id, cursor),\n\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t);\n\t\t\tresults.push(\n\t\t\t\t...site.values\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((result): result is IssueShape => result != null),\n\t\t\t);\n\t\t\ttruncated ||= site.truncated === true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, site.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: key,\n\t\t});\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\tresourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tif (resourceUrl == null) {\n\t\t\tthrow new Error('Jira direct issue reads require a resource URL');\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraIssueByKey(toTokenWithInfo(this.id, session), resourceId, resourceUrl, id);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'batch' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one bulk fetch per site and {@link jiraBulkFetchMaxKeys}\n\t * distinct keys, where {@link getProviderIssueByResourceId} sends one request per issue. A request that throws\n\t * rejects only its own targets' slots, with its error classified as the full read's would be.\n\t *\n\t * A target identified by a numeric issue id, which both reads accept as well as a key, is matched by the returned\n\t * issue's `id`; every other target by its key.\n\t *\n\t * Never proves an absence. Jira silently omits a key it can't find or show (listing it in no `issueErrors` either),\n\t * and answers a moved issue under its new key, which no longer matches the key asked for. Either way the target's\n\t * slot is rejected, so the full read distinguishes a missing issue from a site failure. When no target was\n\t * answered and nothing failed, the check declines, so a batch of only such keys costs a full read, not a failure.\n\t */\n\tprotected override async getProviderIssuesEtagFieldsByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { resourceId: string; identifier: string; resourceUrl?: string }[],\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst slots = new Array<PromiseSettledResult<IssueEtagFields | undefined>>(targets.length);\n\t\tlet answered = false;\n\t\tlet failed = false;\n\n\t\t// Each site's distinct keys, matched case-insensitively as Jira matches them, with the targets asking for each.\n\t\tconst bySite = new Map<string, Map<string, number[]>>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tif (target.resourceUrl == null) {\n\t\t\t\t// Required as the full read requires it, so a check never answers for a target the full read refuses.\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error('Jira direct issue reads require a resource URL'),\n\t\t\t\t};\n\t\t\t\tfailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet keys = bySite.get(target.resourceId);\n\t\t\tif (keys == null) {\n\t\t\t\tkeys = new Map();\n\t\t\t\tbySite.set(target.resourceId, keys);\n\t\t\t}\n\n\t\t\tconst key = target.identifier.toUpperCase();\n\t\t\tlet indices = keys.get(key);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tkeys.set(key, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...bySite].flatMap(([resourceId, keys]) =>\n\t\t\tchunk([...keys], jiraBulkFetchMaxKeys).map(entries => ({ resourceId: resourceId, entries: entries })),\n\t\t);\n\t\tif (!requests.length) return slots;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\tapi.getJiraIssuesEtagFields(\n\t\t\t\ttokenWithInfo,\n\t\t\t\tr.resourceId,\n\t\t\t\tr.entries.map(([key]) => key),\n\t\t\t),\n\t\t);\n\n\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\tconst { entries } = requests[i];\n\t\t\tif (answer.status === 'rejected') {\n\t\t\t\tfailed = true;\n\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (answer.value.errorCount > 0) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\n\t\t\t// By key or id, never by position: Jira returns the issues in its own order, and only the ones it found.\n\t\t\tconst byKey = new Map<string, JiraIssueEtagResponse>();\n\t\t\tconst byId = new Map<string, JiraIssueEtagResponse>();\n\t\t\tfor (const issue of answer.value.issues) {\n\t\t\t\tbyKey.set(issue.key.toUpperCase(), issue);\n\t\t\t\tbyId.set(issue.id, issue);\n\t\t\t}\n\n\t\t\tfor (const [key, indices] of entries) {\n\t\t\t\t// A key target never matches by id, so an issue returned under a different key (moved) is rejected.\n\t\t\t\tconst issue = numericIssueId.test(key) ? byId.get(key) : byKey.get(key);\n\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\tif (issue == null) {\n\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Jira bulk fetch did not return ${key}`) };\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tslot = { status: 'fulfilled', value: toJiraIssueEtagFields(issue) };\n\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of indices) {\n\t\t\t\t\tslots[index] = slot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tthis._autolinks.clear();\n\t\tif (this._session == null) return;\n\n\t\tconst session = this._session;\n\t\tconst organizations = await this.getProviderResourcesForUser(session, true);\n\t\tif (organizations?.length) {\n\t\t\tawait this.getProviderProjectsForResources(session, organizations, true);\n\t\t}\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n\nfunction getProjectAutolinks(\n\torganization: JiraOrganizationDescriptor,\n\tprojects: readonly JiraProjectDescriptor[],\n): AutolinkReference[] {\n\treturn projects.flatMap(project =>\n\t\tcreateIssueAutolinkReferences(project.key, `${organization.url}/browse/${project.key}-<num>`, organization),\n\t);\n}\n\n/** The projects once each, by site and id. */\nfunction uniqueProjects(projects: JiraProjectDescriptor[]): JiraProjectDescriptor[] {\n\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\tfor (const project of projects) {\n\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\tprojectsByIdentity.set(identity, project);\n\t\t}\n\t}\n\treturn [...projectsByIdentity.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,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