@gitkraken/core-gitlens 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/dist/git/cache.js +2 -0
  3. package/dist/git/cache.js.map +1 -1
  4. package/dist/git/models/issue.d.ts +3 -1
  5. package/dist/git/models/issue.js.map +1 -1
  6. package/dist/git/providers/branches.d.ts +4 -2
  7. package/dist/git/utils/issue.utils.d.ts +3 -1
  8. package/dist/git/utils/issue.utils.js +5 -1
  9. package/dist/git/utils/issue.utils.js.map +1 -1
  10. package/dist/git/watching/worktreeSummary.d.ts +20 -9
  11. package/dist/git/watching/worktreeSummary.js +24 -22
  12. package/dist/git/watching/worktreeSummary.js.map +1 -1
  13. package/dist/git-cli/providers/branches.js +26 -4
  14. package/dist/git-cli/providers/branches.js.map +1 -1
  15. package/dist/plus/integrations/models/gitHostIntegration.js +3 -1
  16. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  17. package/dist/plus/integrations/models/integration.js +1 -1
  18. package/dist/plus/integrations/providers/azure/azure.js +3 -2
  19. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  20. package/dist/plus/integrations/providers/azure/models.d.ts +27 -10
  21. package/dist/plus/integrations/providers/azure/models.js +39 -19
  22. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  23. package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +19 -0
  24. package/dist/plus/integrations/providers/azure/workItemStateCategories.js +32 -0
  25. package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -0
  26. package/dist/plus/integrations/providers/azureDevOps.js +5 -5
  27. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  28. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  29. package/dist/plus/integrations/providers/jira-server.js +11 -5
  30. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  31. package/dist/plus/integrations/providers/jira.d.ts +5 -2
  32. package/dist/plus/integrations/providers/jira.js +45 -30
  33. package/dist/plus/integrations/providers/jira.js.map +1 -1
  34. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +3 -4
  35. package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -4
  36. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  37. package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +5 -5
  38. package/dist/plus/integrations/providers/linearIssuesEtag.js +6 -6
  39. package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
  40. package/dist/plus/integrations/providers/models.d.ts +11 -1
  41. package/dist/plus/integrations/providers/models.js +9 -9
  42. package/dist/plus/integrations/providers/models.js.map +1 -1
  43. package/dist/plus/integrations/providers/providersApi.d.ts +30 -32
  44. package/dist/plus/integrations/providers/providersApi.js +149 -46
  45. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  46. package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +27 -15
  47. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +72 -10
  48. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
  49. package/dist/plus/integrations/reads/batchEtags.d.ts +5 -2
  50. package/dist/plus/integrations/reads/batchEtags.js +31 -10
  51. package/dist/plus/integrations/reads/batchEtags.js.map +1 -1
  52. package/dist/plus/integrations/reads/cursors.js +1 -1
  53. package/dist/plus/integrations/reads/drains.d.ts +0 -1
  54. package/dist/plus/integrations/reads/hierarchy.js +2 -2
  55. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  56. package/dist/plus/integrations/reads/hierarchy.utils.d.ts +13 -0
  57. package/dist/plus/integrations/reads/hierarchy.utils.js +26 -1
  58. package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
  59. package/dist/plus/integrations/reads/issueTracker.js +4 -4
  60. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  61. package/dist/plus/integrations/reads/issues.js +1 -1
  62. package/dist/plus/integrations/reads/pullRequestBranches.js +10 -3
  63. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  64. package/dist/plus/integrations/results.d.ts +28 -3
  65. package/dist/plus/integrations/results.js +22 -3
  66. package/dist/plus/integrations/results.js.map +1 -1
  67. package/dist/plus/integrations/utils/integration.utils.d.ts +6 -1
  68. package/dist/plus/integrations/utils/integration.utils.js +8 -1
  69. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  70. package/docs/integrations.md +54 -19
  71. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import { ProviderReference } from "../../../../git/models/remoteProvider.js";
2
2
  import { IssueShape } from "../../../../git/models/issue.js";
3
3
  import { IssueFilter } from "../../providerFilters.js";
4
- import { ProviderIssue } from "../models.js";
4
+ import { JiraIssuePage, ProviderIssue } from "../models.js";
5
5
  import { CollectionMetadata, CollectionScopeFailure } from "@gitkraken/provider-apis";
6
6
  //#region ../plus/integrations/src/providers/utils/jiraIssueDrains.d.ts
7
7
  /**
@@ -14,16 +14,10 @@ export type JiraUserScope = {
14
14
  assigneeLogins?: string[];
15
15
  mentionLogin?: string;
16
16
  };
17
- /** One page of a Jira issue search, whether it names one project or several. */
18
- export type JiraIssuePage = {
19
- data: ProviderIssue[];
20
- hasMore: boolean;
21
- nextCursor: string | undefined;
22
- } | undefined;
23
17
  export type JiraIssuePageFetcher = (scope: JiraUserScope, cursor: string | undefined) => Promise<JiraIssuePage>;
24
18
  /**
25
- * Three states rather than a boolean: the backstop is recoverable by narrowing the scope, a page error or a stalled
26
- * cursor is not, and `ProjectIssuesDrain` makes the caller say which.
19
+ * Three states rather than a boolean: the backstop is recoverable by narrowing the scope, a page error, a stalled
20
+ * cursor or a page that dropped issues is not, and `ProjectIssuesDrain` makes the caller say which.
27
21
  */
28
22
  export type JiraIssuesDrain = {
29
23
  issues: ProviderIssue[];
@@ -37,7 +31,7 @@ export type JiraUserScopedRead = {
37
31
  };
38
32
  export type JiraDrainOptions = {
39
33
  maxPages: number;
40
- /** Where a failure that stops the drain is recorded. */
34
+ /** Where a failure that stops the drain, or that a page reported, is recorded. */
41
35
  failureScope: CollectionScopeFailure['scope'];
42
36
  /** Names the provider in the failures this drain synthesizes. */
43
37
  providerName: string;
@@ -47,10 +41,27 @@ export type JiraDrainOptions = {
47
41
  */
48
42
  isEmptyFailure?: (ex: unknown) => boolean;
49
43
  };
44
+ /**
45
+ * A search page's metadata with its failures recorded under `scope`. provider-apis scopes a page failure to what it
46
+ * searched (a Cloud site, or nothing below the provider on Data Center, which would publish it as a failure of the
47
+ * whole connection); the caller knows what it read, e.g. one project. Omissions keep their own scope.
48
+ */
49
+ export declare function withFailureScope(metadata: CollectionMetadata, scope: CollectionScopeFailure['scope']): CollectionMetadata;
50
+ /**
51
+ * Folds what a drain's pages reported into one metadata, with one failure per scope and kind however many pages
52
+ * reported one. provider-apis reports the issues a page dropped per page, naming that page's keys, so the failures
53
+ * of a drain over many unreadable pages never dedupe and would publish one warning per page. The first page's
54
+ * failure is kept, naming its keys, and says how many more pages dropped issues too.
55
+ */
56
+ export declare function summarizePageMetadata(pages: readonly CollectionMetadata[]): CollectionMetadata | undefined;
50
57
  /**
51
58
  * Follows a search's cursor up to `maxPages`. A page failure after the first page leaves the already-drained prefix
52
59
  * intact and records the failure instead of re-throwing and discarding the prefix; if nothing was fetched yet, the
53
60
  * throw propagates so the caller sees a hard error rather than an empty partial success.
61
+ *
62
+ * A page that dropped issues it could not read (its metadata says so) makes the drain `incomplete` without stopping
63
+ * it: the issues it did read and the pages after it are kept, and its failures are recorded under `failureScope`,
64
+ * which names what this drain reads (e.g. one project) more narrowly than the site the SDK searched.
54
65
  */
55
66
  export declare function drainJiraIssues(fetchPage: JiraIssuePageFetcher, scope: JiraUserScope, options: JiraDrainOptions): Promise<JiraIssuesDrain>;
56
67
  /**
@@ -72,11 +83,12 @@ export declare function readUserScopedJiraIssues(fetchPage: JiraIssuePageFetcher
72
83
  export declare function toUniqueJiraIssueShapes(issues: readonly ProviderIssue[], provider: ProviderReference): IssueShape[];
73
84
  /**
74
85
  * Reads the current user's issues of several projects with one search per relationship, split back to the projects
75
- * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete or an issue belongs
76
- * to no requested project, so the caller reads them one by one: a search's pages are global to its project set, and
77
- * an incomplete one says nothing about which of its projects it covered. Its failures are therefore never
78
- * published, and the waste is bounded by one project's page budget, paid only by a search that needed more than
79
- * that or failed partway.
86
+ * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete (including a page
87
+ * that dropped an issue it could not read) or an issue belongs to no requested project, so the caller reads them one
88
+ * by one: a search's pages are global to its project set, and an incomplete one says nothing about which of its
89
+ * projects it covered. Its failures are therefore never published, and the waste is bounded by one project's page
90
+ * budget, paid by a search that needed more than that or did not read cleanly. An issue that stays unreadable makes
91
+ * every such search pay it, as Linear's does for an incomplete search.
80
92
  */
81
93
  export declare function searchJiraProjectIssues(fetchPage: JiraIssuePageFetcher, projectIds: readonly string[], filters: readonly IssueFilter[] | undefined, identities: {
82
94
  userField: string;
@@ -1,20 +1,76 @@
1
1
  import { Logger as _logger } from "../../../../utils/logger.js";
2
- import { throwIfCallerContractError, toCollectionScopeFailure } from "../../collectionMetadata.js";
2
+ import { collectionScopeKey } from "../../results.js";
3
+ import { isIncompleteCollection, throwIfCallerContractError, toCollectionScopeFailure } from "../../collectionMetadata.js";
3
4
  import "../../providerFilters.js";
4
5
  import { mergeCollectionMetadata } from "./providerPaging.js";
5
6
  import { toIssueShape } from "../models.js";
6
7
  import { splitProjectIssuesSearch } from "../../models/issuesIntegration.js";
7
8
  //#region ../plus/integrations/src/providers/utils/jiraIssueDrains.ts
8
9
  /**
10
+ * A search page's metadata with its failures recorded under `scope`. provider-apis scopes a page failure to what it
11
+ * searched (a Cloud site, or nothing below the provider on Data Center, which would publish it as a failure of the
12
+ * whole connection); the caller knows what it read, e.g. one project. Omissions keep their own scope.
13
+ */
14
+ function withFailureScope(metadata, scope) {
15
+ if (metadata.failures == null) return metadata;
16
+ return {
17
+ ...metadata,
18
+ failures: metadata.failures.map((failure) => ({
19
+ ...failure,
20
+ scope
21
+ }))
22
+ };
23
+ }
24
+ /**
25
+ * Folds what a drain's pages reported into one metadata, with one failure per scope and kind however many pages
26
+ * reported one. provider-apis reports the issues a page dropped per page, naming that page's keys, so the failures
27
+ * of a drain over many unreadable pages never dedupe and would publish one warning per page. The first page's
28
+ * failure is kept, naming its keys, and says how many more pages dropped issues too.
29
+ */
30
+ function summarizePageMetadata(pages) {
31
+ let summary;
32
+ const failures = /* @__PURE__ */ new Map();
33
+ for (const { failures: pageFailures, ...page } of pages) {
34
+ summary = mergeCollectionMetadata(summary, page);
35
+ for (const failure of pageFailures ?? []) {
36
+ const key = `${collectionScopeKey(failure.scope)}\0${failure.kind}`;
37
+ const group = failures.get(key);
38
+ if (group == null) failures.set(key, {
39
+ failure,
40
+ pages: 1
41
+ });
42
+ else group.pages++;
43
+ }
44
+ }
45
+ if (failures.size === 0) return summary;
46
+ return mergeCollectionMetadata(summary, {
47
+ completeness: "partial",
48
+ failures: Array.from(failures.values(), ({ failure, pages: count }) => count === 1 ? failure : {
49
+ ...failure,
50
+ message: `${failure.message != null ? `${failure.message} ` : ""}Issues on ${count - 1} more ${count === 2 ? "page" : "pages"} could not be read either.`
51
+ })
52
+ });
53
+ }
54
+ /**
9
55
  * Follows a search's cursor up to `maxPages`. A page failure after the first page leaves the already-drained prefix
10
56
  * intact and records the failure instead of re-throwing and discarding the prefix; if nothing was fetched yet, the
11
57
  * throw propagates so the caller sees a hard error rather than an empty partial success.
58
+ *
59
+ * A page that dropped issues it could not read (its metadata says so) makes the drain `incomplete` without stopping
60
+ * it: the issues it did read and the pages after it are kept, and its failures are recorded under `failureScope`,
61
+ * which names what this drain reads (e.g. one project) more narrowly than the site the SDK searched.
12
62
  */
13
63
  async function drainJiraIssues(fetchPage, scope, options) {
14
64
  const issues = [];
15
65
  let cursor;
16
66
  let status = "complete";
17
67
  let metadata;
68
+ const pages = [];
69
+ const recordPage = (pageMetadata) => {
70
+ if (pageMetadata == null || !isIncompleteCollection(pageMetadata) && !pageMetadata.failures?.length) return;
71
+ status = "incomplete";
72
+ pages.push(withFailureScope(pageMetadata, options.failureScope));
73
+ };
18
74
  const stopIncomplete = (ex) => {
19
75
  status = "incomplete";
20
76
  metadata = mergeCollectionMetadata(metadata, {
@@ -27,13 +83,14 @@ async function drainJiraIssues(fetchPage, scope, options) {
27
83
  try {
28
84
  result = await fetchPage(scope, cursor);
29
85
  } catch (ex) {
30
- if (issues.length === 0) {
86
+ if (issues.length === 0 && pages.length === 0) {
31
87
  if (options.isEmptyFailure?.(ex)) return {
32
88
  issues: [],
33
89
  status: "complete"
34
90
  };
35
91
  throw ex;
36
92
  }
93
+ if (issues.length === 0 && options.isEmptyFailure?.(ex)) break;
37
94
  stopIncomplete(ex);
38
95
  break;
39
96
  }
@@ -43,18 +100,22 @@ async function drainJiraIssues(fetchPage, scope, options) {
43
100
  break;
44
101
  }
45
102
  issues.push(...result.data);
103
+ recordPage(result.metadata);
46
104
  if (!result.hasMore) break;
47
105
  if (result.nextCursor == null || result.nextCursor === cursor) {
48
106
  stopIncomplete(/* @__PURE__ */ new Error(`${options.providerName} returned no advancing issue continuation`));
49
107
  break;
50
108
  }
51
109
  cursor = result.nextCursor;
52
- if (i === options.maxPages - 1) status = "backstop";
110
+ if (i === options.maxPages - 1) {
111
+ if (status === "complete") status = "backstop";
112
+ else stopIncomplete(/* @__PURE__ */ new Error(`${options.providerName} issue drain stopped at the ${options.maxPages}-page backstop`));
113
+ }
53
114
  }
54
115
  return {
55
116
  issues,
56
117
  status,
57
- metadata
118
+ metadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata)
58
119
  };
59
120
  }
60
121
  /**
@@ -122,11 +183,12 @@ function toUniqueJiraIssueShapes(issues, provider) {
122
183
  }
123
184
  /**
124
185
  * Reads the current user's issues of several projects with one search per relationship, split back to the projects
125
- * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete or an issue belongs
126
- * to no requested project, so the caller reads them one by one: a search's pages are global to its project set, and
127
- * an incomplete one says nothing about which of its projects it covered. Its failures are therefore never
128
- * published, and the waste is bounded by one project's page budget, paid only by a search that needed more than
129
- * that or failed partway.
186
+ * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete (including a page
187
+ * that dropped an issue it could not read) or an issue belongs to no requested project, so the caller reads them one
188
+ * by one: a search's pages are global to its project set, and an incomplete one says nothing about which of its
189
+ * projects it covered. Its failures are therefore never published, and the waste is bounded by one project's page
190
+ * budget, paid by a search that needed more than that or did not read cleanly. An issue that stays unreadable makes
191
+ * every such search pay it, as Linear's does for an incomplete search.
130
192
  */
131
193
  async function searchJiraProjectIssues(fetchPage, projectIds, filters, identities, options, provider) {
132
194
  const read = await readUserScopedJiraIssues(fetchPage, filters, identities, options);
@@ -134,6 +196,6 @@ async function searchJiraProjectIssues(fetchPage, projectIds, filters, identitie
134
196
  return splitProjectIssuesSearch(projectIds, read.issues, (issue) => issue.project?.id ?? void 0)?.map((issues) => toUniqueJiraIssueShapes(issues, provider));
135
197
  }
136
198
  //#endregion
137
- export { drainJiraIssues, readUserScopedJiraIssues, searchJiraProjectIssues, toUniqueJiraIssueShapes };
199
+ export { drainJiraIssues, readUserScopedJiraIssues, searchJiraProjectIssues, summarizePageMetadata, toUniqueJiraIssueShapes, withFailureScope };
138
200
 
139
201
  //# sourceMappingURL=jiraIssueDrains.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jiraIssueDrains.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/jiraIssueDrains.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { IssueShape } from '@gitlens/git/models/issue.js';\nimport type { ProviderReference } from '@gitlens/git/models/remoteProvider.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { throwIfCallerContractError, toCollectionScopeFailure } from '../../collectionMetadata.js';\nimport { splitProjectIssuesSearch } from '../../models/issuesIntegration.js';\nimport { IssueFilter } from '../../providerFilters.js';\nimport type { ProviderIssue } from '../models.js';\nimport { toIssueShape } from '../models.js';\nimport { mergeCollectionMetadata } from './providerPaging.js';\n\n/**\n * The issue drains Jira Cloud and Jira Server share. Their reads differ only in how a page is addressed (a site's\n * `resourceId` vs an instance's `baseUrl`) and in which identity a user field takes, so the page fetch and the\n * identities come in as arguments and the bookkeeping is written once.\n */\n\nexport type JiraUserScope = { authorLogin?: string; assigneeLogins?: string[]; mentionLogin?: string };\n\n/** One page of a Jira issue search, whether it names one project or several. */\nexport type JiraIssuePage = { data: ProviderIssue[]; hasMore: boolean; nextCursor: string | undefined } | undefined;\nexport type JiraIssuePageFetcher = (scope: JiraUserScope, cursor: string | undefined) => Promise<JiraIssuePage>;\n\n/**\n * Three states rather than a boolean: the backstop is recoverable by narrowing the scope, a page error or a stalled\n * cursor is not, and `ProjectIssuesDrain` makes the caller say which.\n */\nexport type JiraIssuesDrain = {\n\tissues: ProviderIssue[];\n\tstatus: 'complete' | 'backstop' | 'incomplete';\n\tmetadata?: CollectionMetadata;\n};\n\nexport type JiraUserScopedRead = { issues: ProviderIssue[]; truncated: boolean; metadata?: CollectionMetadata };\n\nexport type JiraDrainOptions = {\n\tmaxPages: number;\n\t/** Where a failure that stops the drain is recorded. */\n\tfailureScope: CollectionScopeFailure['scope'];\n\t/** Names the provider in the failures this drain synthesizes. */\n\tproviderName: string;\n\t/**\n\t * A failure before anything was read that means \"no issues here\" rather than a failed read, e.g. a project this\n\t * connection can no longer see (#5907). Returning true serves the drain as complete and empty.\n\t */\n\tisEmptyFailure?: (ex: unknown) => boolean;\n};\n\n/**\n * Follows a search's cursor up to `maxPages`. A page failure after the first page leaves the already-drained prefix\n * intact and records the failure instead of re-throwing and discarding the prefix; if nothing was fetched yet, the\n * throw propagates so the caller sees a hard error rather than an empty partial success.\n */\nexport async function drainJiraIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\tscope: JiraUserScope,\n\toptions: JiraDrainOptions,\n): Promise<JiraIssuesDrain> {\n\tconst issues: ProviderIssue[] = [];\n\tlet cursor: string | undefined;\n\tlet status: JiraIssuesDrain['status'] = 'complete';\n\tlet metadata: CollectionMetadata | undefined;\n\tconst stopIncomplete = (ex: unknown): void => {\n\t\tstatus = 'incomplete';\n\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\tcompleteness: 'partial',\n\t\t\tfailures: [toCollectionScopeFailure(options.failureScope, ex)],\n\t\t});\n\t};\n\tfor (let i = 0; i < options.maxPages; i++) {\n\t\tlet result: JiraIssuePage;\n\t\ttry {\n\t\t\tresult = await fetchPage(scope, cursor);\n\t\t} catch (ex) {\n\t\t\tif (issues.length === 0) {\n\t\t\t\tif (options.isEmptyFailure?.(ex)) return { issues: [], status: 'complete' };\n\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\tstopIncomplete(ex);\n\t\t\tbreak;\n\t\t}\n\t\tif (result == null) {\n\t\t\tif (cursor == null) break;\n\n\t\t\tstopIncomplete(new Error(`${options.providerName} returned no page after advertising a continuation`));\n\t\t\tbreak;\n\t\t}\n\n\t\tissues.push(...result.data);\n\t\tif (!result.hasMore) break;\n\n\t\t// The provider claims more pages but gave no advancing cursor: we can't continue, so the drain\n\t\t// is incomplete — flag it rather than silently stopping (matches drainPullRequests/Repositories).\n\t\tif (result.nextCursor == null || result.nextCursor === cursor) {\n\t\t\tstopIncomplete(new Error(`${options.providerName} returned no advancing issue continuation`));\n\t\t\tbreak;\n\t\t}\n\n\t\tcursor = result.nextCursor;\n\t\t// Pages remain but this was the last allowed iteration: the backstop stopped the drain, which a\n\t\t// narrower scope would avoid.\n\t\tif (i === options.maxPages - 1) {\n\t\t\tstatus = 'backstop';\n\t\t}\n\t}\n\treturn { issues: issues, status: status, metadata: metadata };\n}\n\n/**\n * Runs one drain per requested relationship and keeps whatever succeeded. Throws only when every relationship failed,\n * so the caller sees a hard error rather than an empty success.\n *\n * `identities` are the values each kind of clause takes, which the providers resolve differently: `userField` scopes\n * `assignee`/`creator`, which are user fields, and `mention` scopes `comment ~ \"...\"`, a free-text search over comment\n * bodies, which only a name can match.\n */\nexport async function readUserScopedJiraIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\trequestedFilters: readonly IssueFilter[] | undefined,\n\tidentities: { userField: string; mention: string },\n\toptions: JiraDrainOptions,\n): Promise<JiraUserScopedRead> {\n\t// A resolved user always scopes the read. Default to the assignee filter (\"my issues\") when no explicit filters\n\t// are given — otherwise a caller that scopes by user but omits filters would fall through to an unscoped fetch\n\t// and get every issue in the project instead of the user's (#5438).\n\tconst filters = requestedFilters?.length ? requestedFilters : [IssueFilter.Assignee];\n\tconst settled = await Promise.allSettled(\n\t\tfilters.map(filter =>\n\t\t\tdrainJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\t{\n\t\t\t\t\tauthorLogin: filter === IssueFilter.Author ? identities.userField : undefined,\n\t\t\t\t\tassigneeLogins: filter === IssueFilter.Assignee ? [identities.userField] : undefined,\n\t\t\t\t\tmentionLogin: filter === IssueFilter.Mention ? identities.mention : undefined,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t),\n\t\t),\n\t);\n\n\t// If every filter branch rejected, the read failed outright — propagate the first rejection instead\n\t// of returning an empty list, which the facade (getIssuesForProjectResult → runCaptured) would\n\t// otherwise surface as a successful \"no issues\" rather than a warning + fetchFailed. The first\n\t// reason is re-thrown as-is (not wrapped in an AggregateError) so the facade can still classify it\n\t// by type (auth/rate-limit) — wrapping would collapse every failure to a generic 'other'. The\n\t// remaining reasons would otherwise be discarded, so log them here to keep them diagnosable.\n\tif (settled.every(r => r.status === 'rejected')) {\n\t\tfor (let i = 1; i < settled.length; i++) {\n\t\t\tconst outcome = settled[i];\n\t\t\tif (outcome.status === 'rejected') {\n\t\t\t\tLogger.error(outcome.reason, `readUserScopedJiraIssues: filter '${filters[i]}' failed`);\n\t\t\t}\n\t\t}\n\t\tthrow settled[0].status === 'rejected'\n\t\t\t? settled[0].reason\n\t\t\t: new Error(`${options.providerName} issue read failed`);\n\t}\n\n\tlet truncated = false;\n\tlet metadata: CollectionMetadata | undefined;\n\tconst issues: ProviderIssue[] = [];\n\tfor (let i = 0; i < settled.length; i++) {\n\t\tconst outcome = settled[i];\n\t\tconst filter = filters[i];\n\t\t// A rejected filter branch (with at least one sibling succeeding) means these issues are incomplete:\n\t\t// keep the sibling results but record a structured failure so the facade can warn on the specific\n\t\t// filter (auth/rate-limit) instead of just a generic truncation flag.\n\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t// Identical for every filter branch, so degrading it would report one failure per branch for a\n\t\t\t// single invalid call — see `throwIfCallerContractError`.\n\t\t\tthrowIfCallerContractError(outcome.reason);\n\n\t\t\ttruncated = true;\n\t\t\tconst failure = toCollectionScopeFailure(options.failureScope, outcome.reason);\n\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\tcompleteness: 'partial',\n\t\t\t\tfailures: [\n\t\t\t\t\t{\n\t\t\t\t\t\t...failure,\n\t\t\t\t\t\tmessage: `Issue filter '${filter}' could not be read${\n\t\t\t\t\t\t\tfailure.message != null ? `: ${failure.message}` : ''\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\tcontinue;\n\t\t}\n\n\t\tif (outcome.value.status !== 'complete') {\n\t\t\ttruncated = true;\n\t\t}\n\t\tif (outcome.value.metadata != null) {\n\t\t\tmetadata = mergeCollectionMetadata(metadata, outcome.value.metadata);\n\t\t}\n\t\tissues.push(...outcome.value.issues);\n\t}\n\treturn { issues: issues, truncated: truncated, metadata: metadata };\n}\n\n/**\n * Each relationship is its own search, so an issue matching two of them arrives twice. Every caller is a tracker\n * project read, so the rows carry the `project` projection.\n */\nexport function toUniqueJiraIssueShapes(issues: readonly ProviderIssue[], provider: ProviderReference): IssueShape[] {\n\tconst resultsById = new Map<string, IssueShape>();\n\tfor (const issue of issues) {\n\t\tconst shape = toIssueShape(issue, provider, { projection: 'project' });\n\t\tif (shape != null && !resultsById.has(shape.id)) {\n\t\t\tresultsById.set(shape.id, shape);\n\t\t}\n\t}\n\treturn [...resultsById.values()];\n}\n\n/**\n * Reads the current user's issues of several projects with one search per relationship, split back to the projects\n * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete or an issue belongs\n * to no requested project, so the caller reads them one by one: a search's pages are global to its project set, and\n * an incomplete one says nothing about which of its projects it covered. Its failures are therefore never\n * published, and the waste is bounded by one project's page budget, paid only by a search that needed more than\n * that or failed partway.\n */\nexport async function searchJiraProjectIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\tprojectIds: readonly string[],\n\tfilters: readonly IssueFilter[] | undefined,\n\tidentities: { userField: string; mention: string },\n\toptions: JiraDrainOptions,\n\tprovider: ProviderReference,\n): Promise<IssueShape[][] | undefined> {\n\tconst read = await readUserScopedJiraIssues(fetchPage, filters, identities, options);\n\tif (read.truncated) return undefined;\n\n\tconst split = splitProjectIssuesSearch(projectIds, read.issues, issue => issue.project?.id ?? undefined);\n\treturn split?.map(issues => toUniqueJiraIssueShapes(issues, provider));\n}\n"],"mappings":";;;;;;;;;;;;AAqDA,eAAsB,gBACrB,WACA,OACA,SAC2B;CAC3B,MAAM,SAA0B,CAAC;CACjC,IAAI;CACJ,IAAI,SAAoC;CACxC,IAAI;CACJ,MAAM,kBAAkB,OAAsB;EAC7C,SAAS;EACT,WAAW,wBAAwB,UAAU;GAC5C,cAAc;GACd,UAAU,CAAC,yBAAyB,QAAQ,cAAc,EAAE,CAAC;EAC9D,CAAC;CACF;CACA,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,UAAU,KAAK;EAC1C,IAAI;EACJ,IAAI;GACH,SAAS,MAAM,UAAU,OAAO,MAAM;EACvC,SAAS,IAAI;GACZ,IAAI,OAAO,WAAW,GAAG;IACxB,IAAI,QAAQ,iBAAiB,EAAE,GAAG,OAAO;KAAE,QAAQ,CAAC;KAAG,QAAQ;IAAW;IAE1E,MAAM;GACP;GAEA,eAAe,EAAE;GACjB;EACD;EACA,IAAI,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],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { IssueShape } from '@gitlens/git/models/issue.js';\nimport type { ProviderReference } from '@gitlens/git/models/remoteProvider.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport {\n\tisIncompleteCollection,\n\tthrowIfCallerContractError,\n\ttoCollectionScopeFailure,\n} from '../../collectionMetadata.js';\nimport { splitProjectIssuesSearch } from '../../models/issuesIntegration.js';\nimport { IssueFilter } from '../../providerFilters.js';\nimport { collectionScopeKey } from '../../results.js';\nimport type { JiraIssuePage, ProviderIssue } from '../models.js';\nimport { toIssueShape } from '../models.js';\nimport { mergeCollectionMetadata } from './providerPaging.js';\n\n/**\n * The issue drains Jira Cloud and Jira Server share. Their reads differ only in how a page is addressed (a site's\n * `resourceId` vs an instance's `baseUrl`) and in which identity a user field takes, so the page fetch and the\n * identities come in as arguments and the bookkeeping is written once.\n */\n\nexport type JiraUserScope = { authorLogin?: string; assigneeLogins?: string[]; mentionLogin?: string };\n\nexport type JiraIssuePageFetcher = (scope: JiraUserScope, cursor: string | undefined) => Promise<JiraIssuePage>;\n\n/**\n * Three states rather than a boolean: the backstop is recoverable by narrowing the scope, a page error, a stalled\n * cursor or a page that dropped issues is not, and `ProjectIssuesDrain` makes the caller say which.\n */\nexport type JiraIssuesDrain = {\n\tissues: ProviderIssue[];\n\tstatus: 'complete' | 'backstop' | 'incomplete';\n\tmetadata?: CollectionMetadata;\n};\n\nexport type JiraUserScopedRead = { issues: ProviderIssue[]; truncated: boolean; metadata?: CollectionMetadata };\n\nexport type JiraDrainOptions = {\n\tmaxPages: number;\n\t/** Where a failure that stops the drain, or that a page reported, is recorded. */\n\tfailureScope: CollectionScopeFailure['scope'];\n\t/** Names the provider in the failures this drain synthesizes. */\n\tproviderName: string;\n\t/**\n\t * A failure before anything was read that means \"no issues here\" rather than a failed read, e.g. a project this\n\t * connection can no longer see (#5907). Returning true serves the drain as complete and empty.\n\t */\n\tisEmptyFailure?: (ex: unknown) => boolean;\n};\n\n/**\n * A search page's metadata with its failures recorded under `scope`. provider-apis scopes a page failure to what it\n * searched (a Cloud site, or nothing below the provider on Data Center, which would publish it as a failure of the\n * whole connection); the caller knows what it read, e.g. one project. Omissions keep their own scope.\n */\nexport function withFailureScope(\n\tmetadata: CollectionMetadata,\n\tscope: CollectionScopeFailure['scope'],\n): CollectionMetadata {\n\tif (metadata.failures == null) return metadata;\n\n\treturn { ...metadata, failures: metadata.failures.map(failure => ({ ...failure, scope: scope })) };\n}\n\n/**\n * Folds what a drain's pages reported into one metadata, with one failure per scope and kind however many pages\n * reported one. provider-apis reports the issues a page dropped per page, naming that page's keys, so the failures\n * of a drain over many unreadable pages never dedupe and would publish one warning per page. The first page's\n * failure is kept, naming its keys, and says how many more pages dropped issues too.\n */\nexport function summarizePageMetadata(pages: readonly CollectionMetadata[]): CollectionMetadata | undefined {\n\tlet summary: CollectionMetadata | undefined;\n\tconst failures = new Map<string, { failure: CollectionScopeFailure; pages: number }>();\n\tfor (const { failures: pageFailures, ...page } of pages) {\n\t\tsummary = mergeCollectionMetadata(summary, page);\n\t\tfor (const failure of pageFailures ?? []) {\n\t\t\tconst key = `${collectionScopeKey(failure.scope)}\\0${failure.kind}`;\n\t\t\tconst group = failures.get(key);\n\t\t\tif (group == null) {\n\t\t\t\tfailures.set(key, { failure: failure, pages: 1 });\n\t\t\t} else {\n\t\t\t\tgroup.pages++;\n\t\t\t}\n\t\t}\n\t}\n\tif (failures.size === 0) return summary;\n\n\treturn mergeCollectionMetadata(summary, {\n\t\tcompleteness: 'partial',\n\t\tfailures: Array.from(failures.values(), ({ failure, pages: count }) =>\n\t\t\tcount === 1\n\t\t\t\t? failure\n\t\t\t\t: {\n\t\t\t\t\t\t...failure,\n\t\t\t\t\t\tmessage: `${failure.message != null ? `${failure.message} ` : ''}Issues on ${count - 1} more ${count === 2 ? 'page' : 'pages'} could not be read either.`,\n\t\t\t\t\t},\n\t\t),\n\t});\n}\n\n/**\n * Follows a search's cursor up to `maxPages`. A page failure after the first page leaves the already-drained prefix\n * intact and records the failure instead of re-throwing and discarding the prefix; if nothing was fetched yet, the\n * throw propagates so the caller sees a hard error rather than an empty partial success.\n *\n * A page that dropped issues it could not read (its metadata says so) makes the drain `incomplete` without stopping\n * it: the issues it did read and the pages after it are kept, and its failures are recorded under `failureScope`,\n * which names what this drain reads (e.g. one project) more narrowly than the site the SDK searched.\n */\nexport async function drainJiraIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\tscope: JiraUserScope,\n\toptions: JiraDrainOptions,\n): Promise<JiraIssuesDrain> {\n\tconst issues: ProviderIssue[] = [];\n\tlet cursor: string | undefined;\n\tlet status: JiraIssuesDrain['status'] = 'complete';\n\tlet metadata: CollectionMetadata | undefined;\n\tconst pages: CollectionMetadata[] = [];\n\tconst recordPage = (pageMetadata: CollectionMetadata | undefined): void => {\n\t\tif (pageMetadata == null || (!isIncompleteCollection(pageMetadata) && !pageMetadata.failures?.length)) return;\n\n\t\tstatus = 'incomplete';\n\t\tpages.push(withFailureScope(pageMetadata, options.failureScope));\n\t};\n\tconst stopIncomplete = (ex: unknown): void => {\n\t\tstatus = 'incomplete';\n\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\tcompleteness: 'partial',\n\t\t\tfailures: [toCollectionScopeFailure(options.failureScope, ex)],\n\t\t});\n\t};\n\tfor (let i = 0; i < options.maxPages; i++) {\n\t\tlet result: JiraIssuePage;\n\t\ttry {\n\t\t\tresult = await fetchPage(scope, cursor);\n\t\t} catch (ex) {\n\t\t\t// A page that read no issue but reported dropping some (every issue on it was unreadable) is not\n\t\t\t// \"nothing fetched\": its failure is kept rather than lost to the throw or to an empty success.\n\t\t\tconst nothingRead = issues.length === 0 && pages.length === 0;\n\t\t\tif (nothingRead) {\n\t\t\t\tif (options.isEmptyFailure?.(ex)) return { issues: [], status: 'complete' };\n\n\t\t\t\tthrow ex;\n\t\t\t}\n\t\t\t// The project is gone, so it has nothing more to report; what its pages dropped already is.\n\t\t\tif (issues.length === 0 && options.isEmptyFailure?.(ex)) break;\n\n\t\t\tstopIncomplete(ex);\n\t\t\tbreak;\n\t\t}\n\t\tif (result == null) {\n\t\t\tif (cursor == null) break;\n\n\t\t\tstopIncomplete(new Error(`${options.providerName} returned no page after advertising a continuation`));\n\t\t\tbreak;\n\t\t}\n\n\t\tissues.push(...result.data);\n\t\trecordPage(result.metadata);\n\t\tif (!result.hasMore) break;\n\n\t\t// The provider claims more pages but gave no advancing cursor: we can't continue, so the drain\n\t\t// is incomplete — flag it rather than silently stopping (matches drainPullRequests/Repositories).\n\t\tif (result.nextCursor == null || result.nextCursor === cursor) {\n\t\t\tstopIncomplete(new Error(`${options.providerName} returned no advancing issue continuation`));\n\t\t\tbreak;\n\t\t}\n\n\t\tcursor = result.nextCursor;\n\t\t// Pages remain but this was the last allowed iteration: the backstop stopped the drain, which a\n\t\t// narrower scope would avoid. A drain already incomplete stays so (narrowing can't recover a dropped\n\t\t// issue), so its metadata says the backstop also stopped it rather than only naming the dropped issues.\n\t\tif (i === options.maxPages - 1) {\n\t\t\tif (status === 'complete') {\n\t\t\t\tstatus = 'backstop';\n\t\t\t} else {\n\t\t\t\tstopIncomplete(\n\t\t\t\t\tnew Error(`${options.providerName} issue drain stopped at the ${options.maxPages}-page backstop`),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tissues: issues,\n\t\tstatus: status,\n\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t};\n}\n\n/**\n * Runs one drain per requested relationship and keeps whatever succeeded. Throws only when every relationship failed,\n * so the caller sees a hard error rather than an empty success.\n *\n * `identities` are the values each kind of clause takes, which the providers resolve differently: `userField` scopes\n * `assignee`/`creator`, which are user fields, and `mention` scopes `comment ~ \"...\"`, a free-text search over comment\n * bodies, which only a name can match.\n */\nexport async function readUserScopedJiraIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\trequestedFilters: readonly IssueFilter[] | undefined,\n\tidentities: { userField: string; mention: string },\n\toptions: JiraDrainOptions,\n): Promise<JiraUserScopedRead> {\n\t// A resolved user always scopes the read. Default to the assignee filter (\"my issues\") when no explicit filters\n\t// are given — otherwise a caller that scopes by user but omits filters would fall through to an unscoped fetch\n\t// and get every issue in the project instead of the user's (#5438).\n\tconst filters = requestedFilters?.length ? requestedFilters : [IssueFilter.Assignee];\n\tconst settled = await Promise.allSettled(\n\t\tfilters.map(filter =>\n\t\t\tdrainJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\t{\n\t\t\t\t\tauthorLogin: filter === IssueFilter.Author ? identities.userField : undefined,\n\t\t\t\t\tassigneeLogins: filter === IssueFilter.Assignee ? [identities.userField] : undefined,\n\t\t\t\t\tmentionLogin: filter === IssueFilter.Mention ? identities.mention : undefined,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t),\n\t\t),\n\t);\n\n\t// If every filter branch rejected, the read failed outright — propagate the first rejection instead\n\t// of returning an empty list, which the facade (getIssuesForProjectResult → runCaptured) would\n\t// otherwise surface as a successful \"no issues\" rather than a warning + fetchFailed. The first\n\t// reason is re-thrown as-is (not wrapped in an AggregateError) so the facade can still classify it\n\t// by type (auth/rate-limit) — wrapping would collapse every failure to a generic 'other'. The\n\t// remaining reasons would otherwise be discarded, so log them here to keep them diagnosable.\n\tif (settled.every(r => r.status === 'rejected')) {\n\t\tfor (let i = 1; i < settled.length; i++) {\n\t\t\tconst outcome = settled[i];\n\t\t\tif (outcome.status === 'rejected') {\n\t\t\t\tLogger.error(outcome.reason, `readUserScopedJiraIssues: filter '${filters[i]}' failed`);\n\t\t\t}\n\t\t}\n\t\tthrow settled[0].status === 'rejected'\n\t\t\t? settled[0].reason\n\t\t\t: new Error(`${options.providerName} issue read failed`);\n\t}\n\n\tlet truncated = false;\n\tlet metadata: CollectionMetadata | undefined;\n\tconst issues: ProviderIssue[] = [];\n\tfor (let i = 0; i < settled.length; i++) {\n\t\tconst outcome = settled[i];\n\t\tconst filter = filters[i];\n\t\t// A rejected filter branch (with at least one sibling succeeding) means these issues are incomplete:\n\t\t// keep the sibling results but record a structured failure so the facade can warn on the specific\n\t\t// filter (auth/rate-limit) instead of just a generic truncation flag.\n\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t// Identical for every filter branch, so degrading it would report one failure per branch for a\n\t\t\t// single invalid call — see `throwIfCallerContractError`.\n\t\t\tthrowIfCallerContractError(outcome.reason);\n\n\t\t\ttruncated = true;\n\t\t\tconst failure = toCollectionScopeFailure(options.failureScope, outcome.reason);\n\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\tcompleteness: 'partial',\n\t\t\t\tfailures: [\n\t\t\t\t\t{\n\t\t\t\t\t\t...failure,\n\t\t\t\t\t\tmessage: `Issue filter '${filter}' could not be read${\n\t\t\t\t\t\t\tfailure.message != null ? `: ${failure.message}` : ''\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\tcontinue;\n\t\t}\n\n\t\tif (outcome.value.status !== 'complete') {\n\t\t\ttruncated = true;\n\t\t}\n\t\tif (outcome.value.metadata != null) {\n\t\t\tmetadata = mergeCollectionMetadata(metadata, outcome.value.metadata);\n\t\t}\n\t\tissues.push(...outcome.value.issues);\n\t}\n\treturn { issues: issues, truncated: truncated, metadata: metadata };\n}\n\n/**\n * Each relationship is its own search, so an issue matching two of them arrives twice. Every caller is a tracker\n * project read, so the rows carry the `project` projection.\n */\nexport function toUniqueJiraIssueShapes(issues: readonly ProviderIssue[], provider: ProviderReference): IssueShape[] {\n\tconst resultsById = new Map<string, IssueShape>();\n\tfor (const issue of issues) {\n\t\tconst shape = toIssueShape(issue, provider, { projection: 'project' });\n\t\tif (shape != null && !resultsById.has(shape.id)) {\n\t\t\tresultsById.set(shape.id, shape);\n\t\t}\n\t}\n\treturn [...resultsById.values()];\n}\n\n/**\n * Reads the current user's issues of several projects with one search per relationship, split back to the projects\n * in `projectIds` order by each issue's `project.id`. Undefined when the search did not complete (including a page\n * that dropped an issue it could not read) or an issue belongs to no requested project, so the caller reads them one\n * by one: a search's pages are global to its project set, and an incomplete one says nothing about which of its\n * projects it covered. Its failures are therefore never published, and the waste is bounded by one project's page\n * budget, paid by a search that needed more than that or did not read cleanly. An issue that stays unreadable makes\n * every such search pay it, as Linear's does for an incomplete search.\n */\nexport async function searchJiraProjectIssues(\n\tfetchPage: JiraIssuePageFetcher,\n\tprojectIds: readonly string[],\n\tfilters: readonly IssueFilter[] | undefined,\n\tidentities: { userField: string; mention: string },\n\toptions: JiraDrainOptions,\n\tprovider: ProviderReference,\n): Promise<IssueShape[][] | undefined> {\n\tconst read = await readUserScopedJiraIssues(fetchPage, filters, identities, options);\n\tif (read.truncated) return undefined;\n\n\tconst split = splitProjectIssuesSearch(projectIds, read.issues, issue => issue.project?.id ?? undefined);\n\treturn split?.map(issues => toUniqueJiraIssueShapes(issues, provider));\n}\n"],"mappings":";;;;;;;;;;;;;AAwDA,SAAgB,iBACf,UACA,OACqB;CACrB,IAAI,SAAS,YAAY,MAAM,OAAO;CAEtC,OAAO;EAAE,GAAG;EAAU,UAAU,SAAS,SAAS,KAAI,aAAY;GAAE,GAAG;GAAgB;EAAM,EAAE;CAAE;AAClG;;;;;;;AAQA,SAAgB,sBAAsB,OAAsE;CAC3G,IAAI;CACJ,MAAM,2BAAW,IAAI,IAAgE;CACrF,KAAK,MAAM,EAAE,UAAU,cAAc,GAAG,UAAU,OAAO;EACxD,UAAU,wBAAwB,SAAS,IAAI;EAC/C,KAAK,MAAM,WAAW,gBAAgB,CAAC,GAAG;GACzC,MAAM,MAAM,GAAG,mBAAmB,QAAQ,KAAK,EAAE,IAAI,QAAQ;GAC7D,MAAM,QAAQ,SAAS,IAAI,GAAG;GAC9B,IAAI,SAAS,MACZ,SAAS,IAAI,KAAK;IAAW;IAAS,OAAO;GAAE,CAAC;QAEhD,MAAM;EAER;CACD;CACA,IAAI,SAAS,SAAS,GAAG,OAAO;CAEhC,OAAO,wBAAwB,S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
24
  * Failure budget: the cheap check spends no strike toward disconnecting, and shows no notice, unless the credential
25
25
  * is refused. Only the full reads spend, each at most one, so a call spends at most two: in a total outage of a batch
26
26
  * whose every target carries an etag, one, for the full read every target falls through to.
27
+ *
28
+ * Every warning names the targets it concerns (see `ProviderWarning.targetKeys`): the one target a rejected slot
29
+ * belongs to, or every target of an integration call that failed as a whole.
27
30
  */
28
31
  /** One integration call's slots, as `runCaptured` captures them. */
29
32
  export interface CapturedBatch<T> {
@@ -60,10 +63,10 @@ export declare function readEtaggedBatch<Target extends {
60
63
  /**
61
64
  * Appends the warning for a batch target that could not be checked, shared by every batch read: for a refusal, the
62
65
  * scope failure it was recorded as (see `IntegrationBase.settleBatchRefusals`), published as an account-wide read
63
- * publishes one, scoped and with its cause; otherwise, the reason itself.
66
+ * publishes one, scoped and with its cause; otherwise, the reason itself. The warning names the target's key.
64
67
  */
65
68
  export declare function appendBatchSlotWarning(warnings: ProviderWarning[], providerId: IntegrationIds, domain: string | undefined, connectionId: string | undefined, slot: Extract<BatchSlot<unknown>, {
66
69
  status: 'rejected';
67
- }>): void;
70
+ }>, targetKey: string): void;
68
71
  //#endregion
69
72
  //# sourceMappingURL=batchEtags.d.ts.map
@@ -12,17 +12,24 @@ async function readEtaggedBatch(options) {
12
12
  const warnings = [];
13
13
  const rows = /* @__PURE__ */ new Map();
14
14
  let fetchFailed = false;
15
+ const keysOf = (indices) => indices.map((i) => targets[i].key);
15
16
  const settleFull = (indices, { value: slots, warning }) => {
16
- if (warning != null) appendDedupedWarning(warnings, warning);
17
+ if (warning != null) appendDedupedWarning(warnings, {
18
+ ...warning,
19
+ targetKeys: keysOf(indices)
20
+ });
17
21
  if (slots == null) {
18
- if (warning == null) appendDedupedWarning(warnings, options.unsupportedWarning());
22
+ if (warning == null) appendDedupedWarning(warnings, {
23
+ ...options.unsupportedWarning(),
24
+ targetKeys: keysOf(indices)
25
+ });
19
26
  fetchFailed = true;
20
27
  return;
21
28
  }
22
29
  for (let i = 0; i < indices.length; i++) {
23
30
  const slot = slots[i];
24
31
  if (slot.status === "rejected") {
25
- appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot);
32
+ appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, targets[indices[i]].key);
26
33
  fetchFailed = true;
27
34
  continue;
28
35
  }
@@ -45,7 +52,10 @@ async function readEtaggedBatch(options) {
45
52
  const changed = [];
46
53
  const { value: slots, warning } = await options.readEtagFields(select(cheap));
47
54
  if (warning != null && noRetryKinds.includes(warning.kind)) {
48
- appendDedupedWarning(warnings, warning);
55
+ appendDedupedWarning(warnings, {
56
+ ...warning,
57
+ targetKeys: keysOf(cheap)
58
+ });
49
59
  fetchFailed = true;
50
60
  } else if (slots == null) changed.push(...cheap);
51
61
  else for (let i = 0; i < cheap.length; i++) {
@@ -53,13 +63,16 @@ async function readEtaggedBatch(options) {
53
63
  const slot = slots[i];
54
64
  if (slot.status === "rejected") {
55
65
  if (slot.failure != null) {
56
- appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot);
66
+ appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, targets[index].key);
57
67
  fetchFailed = true;
58
68
  continue;
59
69
  }
60
70
  const slotWarning = toProviderWarning(providerId, domain, connectionId, slot.reason);
61
71
  if (noRetryKinds.includes(slotWarning.kind)) {
62
- appendDedupedWarning(warnings, slotWarning);
72
+ appendDedupedWarning(warnings, {
73
+ ...slotWarning,
74
+ targetKeys: [targets[index].key]
75
+ });
63
76
  fetchFailed = true;
64
77
  } else changed.push(index);
65
78
  continue;
@@ -96,17 +109,25 @@ async function readEtaggedBatch(options) {
96
109
  /**
97
110
  * Appends the warning for a batch target that could not be checked, shared by every batch read: for a refusal, the
98
111
  * scope failure it was recorded as (see `IntegrationBase.settleBatchRefusals`), published as an account-wide read
99
- * publishes one, scoped and with its cause; otherwise, the reason itself.
112
+ * publishes one, scoped and with its cause; otherwise, the reason itself. The warning names the target's key.
100
113
  */
101
- function appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot) {
114
+ function appendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, targetKey) {
102
115
  if (slot.failure != null) {
103
- mergeAssessmentInto(warnings, providerId, domain, connectionId, {
116
+ const produced = [];
117
+ mergeAssessmentInto(produced, providerId, domain, connectionId, {
104
118
  completeness: "partial",
105
119
  failures: [slot.failure]
106
120
  });
121
+ for (const warning of produced) appendDedupedWarning(warnings, {
122
+ ...warning,
123
+ targetKeys: [targetKey]
124
+ });
107
125
  return;
108
126
  }
109
- appendDedupedWarning(warnings, toProviderWarning(providerId, domain, connectionId, slot.reason));
127
+ appendDedupedWarning(warnings, {
128
+ ...toProviderWarning(providerId, domain, connectionId, slot.reason),
129
+ targetKeys: [targetKey]
130
+ });
110
131
  }
111
132
  //#endregion
112
133
  export { appendBatchSlotWarning, readEtaggedBatch };
@@ -1 +1 @@
1
- {"version":3,"file":"batchEtags.js","names":[],"sources":["../../../../../plus/integrations/src/reads/batchEtags.ts"],"sourcesContent":["import { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { BatchSlot } from '../models/integration.js';\nimport type { ProviderResult, ProviderWarning, ProviderWarningKind } from '../results.js';\nimport { appendDedupedWarning, toProviderWarning } from '../results.js';\n\n/**\n * The etag flow shared by the batch reads (`getPullRequestsBatch`, and both forms of `getIssuesBatch`): targets that\n * carry the etag of the caller's copy are first asked a cheap \"what is your change state\" question, and only the ones\n * that moved are read in full.\n *\n * - No target carries an etag, or the integration has no cheap check: ONE full read of every target, exactly as\n * before etags existed, with an etag added to each row.\n * - Otherwise up to three integration calls: the full read of the targets with no etag starts at once, in parallel\n * with the cheap check of the others, and the targets whose etag no longer matches get a second full read as soon\n * as the check settles. A call takes the longer of the two paths, never their sum.\n *\n * The cheap check never answers for a target it couldn't check: a target it failed falls through to the full read,\n * which then has the final word (and supplies the warning, should it fail too) — except when the failure was a\n * refused credential or a spent rate limit, which the full read would only hit again; those targets are dropped with\n * the cheap check's warning, as a failed full read drops them. Each target is judged by its own slot's reason, so one\n * target's rate limit never drops another target the check merely failed to answer, nor sends a rate-limited target\n * to the full read; the check's wrappers return every slot as it settled, failing as a whole only on a refused\n * credential (or when the request itself failed).\n *\n * Failure budget: the cheap check spends no strike toward disconnecting, and shows no notice, unless the credential\n * is refused. Only the full reads spend, each at most one, so a call spends at most two: in a total outage of a batch\n * whose every target carries an etag, one, for the full read every target falls through to.\n */\n\n/** One integration call's slots, as `runCaptured` captures them. */\nexport interface CapturedBatch<T> {\n\tvalue?: BatchSlot<T | undefined>[];\n\twarning?: ProviderWarning;\n}\n\n/**\n * One target's answer: read in full (`value`, or proven absent without one), or `unchanged`, when the cheap check\n * proved the caller's copy current. Every row with a `value` carries its `etag`, as does every `unchanged` one.\n */\nexport interface EtaggedBatchRow<T> {\n\tkey: string;\n\tvalue?: T;\n\tetag?: string;\n\tunchanged?: true;\n}\n\n/** Failures a full read would only hit again: a refused credential, a spent rate limit, a connection that's gone. */\nconst noRetryKinds: readonly ProviderWarningKind[] = ['auth', 'rate-limit', 'no-connection'];\n\nexport async function readEtaggedBatch<Target extends { key: string; etag?: string }, Item, Fields>(options: {\n\tproviderId: IntegrationIds;\n\tdomain: string | undefined;\n\tconnectionId: string | undefined;\n\ttargets: readonly Target[];\n\t/** Whether the integration has a cheap check. Decided up front, so a host without one makes one call. */\n\tsupportsEtags: boolean;\n\treadFull: (targets: readonly Target[]) => Promise<CapturedBatch<Item>>;\n\treadEtagFields: (targets: readonly Target[]) => Promise<CapturedBatch<Fields>>;\n\titemEtag: (item: Item) => string;\n\tfieldsEtag: (fields: Fields) => string;\n\t/** The warning for a full read that answered neither slots nor an error: the provider can't batch at all. */\n\tunsupportedWarning: () => ProviderWarning;\n}): Promise<ProviderResult<EtaggedBatchRow<Item>>> {\n\tconst { providerId, domain, connectionId, targets } = options;\n\tconst warnings: ProviderWarning[] = [];\n\tconst rows = new Map<number, EtaggedBatchRow<Item>>();\n\tlet fetchFailed = false;\n\n\tconst settleFull = (indices: readonly number[], { value: slots, warning }: CapturedBatch<Item>): void => {\n\t\tif (warning != null) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t}\n\n\t\tif (slots == null) {\n\t\t\t// Dropped, never reported absent: \"unknown\" and \"proven absent\" must stay distinguishable.\n\t\t\tif (warning == null) {\n\t\t\t\tappendDedupedWarning(warnings, options.unsupportedWarning());\n\t\t\t}\n\t\t\tfetchFailed = true;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = 0; i < indices.length; i++) {\n\t\t\tconst slot = slots[i];\n\t\t\tif (slot.status === 'rejected') {\n\t\t\t\t// Dropped, never reported absent, like a whole-call failure: only THIS target failed.\n\t\t\t\tappendBatchSlotWarning(warnings, providerId, domain, connectionId, slot);\n\t\t\t\tfetchFailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst item = slot.value;\n\t\t\tconst key = targets[indices[i]].key;\n\t\t\trows.set(indices[i], item != null ? { key: key, value: item, etag: options.itemEtag(item) } : { key: key });\n\t\t}\n\t};\n\n\tconst cheap: number[] = [];\n\tconst full: number[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\t(options.supportsEtags && targets[i].etag ? cheap : full).push(i);\n\t}\n\n\tconst select = (indices: readonly number[]): Target[] => indices.map(i => targets[i]);\n\n\tif (!cheap.length) {\n\t\tsettleFull(full, await options.readFull(targets));\n\t} else {\n\t\t// Started before the cheap check is even sent, so the targets it can't answer never wait on it.\n\t\tconst fullRead = full.length ? options.readFull(select(full)) : undefined;\n\n\t\tconst changed: number[] = [];\n\t\tconst { value: slots, warning } = await options.readEtagFields(select(cheap));\n\t\tif (warning != null && noRetryKinds.includes(warning.kind)) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t\tfetchFailed = true;\n\t\t} else if (slots == null) {\n\t\t\t// The check failed some other way, or the provider declined it; the full read decides instead.\n\t\t\tchanged.push(...cheap);\n\t\t} else {\n\t\t\tfor (let i = 0; i < cheap.length; i++) {\n\t\t\t\tconst index = cheap[i];\n\t\t\t\tconst slot = slots[i];\n\t\t\t\tif (slot.status === 'rejected') {\n\t\t\t\t\t// A scoped refusal (`failure`) is the credential refused for that target's scope, which a full read\n\t\t\t\t\t// would hit as well.\n\t\t\t\t\tif (slot.failure != null) {\n\t\t\t\t\t\tappendBatchSlotWarning(warnings, providerId, domain, connectionId, slot);\n\t\t\t\t\t\tfetchFailed = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst slotWarning = toProviderWarning(providerId, domain, connectionId, slot.reason);\n\t\t\t\t\tif (noRetryKinds.includes(slotWarning.kind)) {\n\t\t\t\t\t\tappendDedupedWarning(warnings, slotWarning);\n\t\t\t\t\t\tfetchFailed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchanged.push(index);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst key = targets[index].key;\n\t\t\t\tconst fields = slot.value;\n\t\t\t\tif (fields == null) {\n\t\t\t\t\trows.set(index, { key: key });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst etag = options.fieldsEtag(fields);\n\t\t\t\tif (etag === targets[index].etag) {\n\t\t\t\t\trows.set(index, { key: key, unchanged: true, etag: etag });\n\t\t\t\t} else {\n\t\t\t\t\tchanged.push(index);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst changedRead = changed.length ? options.readFull(select(changed)) : undefined;\n\t\tif (fullRead != null) {\n\t\t\tsettleFull(full, await fullRead);\n\t\t}\n\t\tif (changedRead != null) {\n\t\t\tsettleFull(changed, await changedRead);\n\t\t}\n\t}\n\n\tconst items: EtaggedBatchRow<Item>[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\tconst row = rows.get(i);\n\t\tif (row != null) {\n\t\t\titems.push(row);\n\t\t}\n\t}\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/**\n * Appends the warning for a batch target that could not be checked, shared by every batch read: for a refusal, the\n * scope failure it was recorded as (see `IntegrationBase.settleBatchRefusals`), published as an account-wide read\n * publishes one, scoped and with its cause; otherwise, the reason itself.\n */\nexport function appendBatchSlotWarning(\n\twarnings: ProviderWarning[],\n\tproviderId: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tslot: Extract<BatchSlot<unknown>, { status: 'rejected' }>,\n): void {\n\tif (slot.failure != null) {\n\t\tmergeAssessmentInto(warnings, providerId, domain, connectionId, {\n\t\t\tcompleteness: 'partial',\n\t\t\tfailures: [slot.failure],\n\t\t});\n\t\treturn;\n\t}\n\n\tappendDedupedWarning(warnings, toProviderWarning(providerId, domain, connectionId, slot.reason));\n}\n"],"mappings":";;;;AAgDA,MAAM,eAA+C;CAAC;CAAQ;CAAc;AAAe;AAE3F,eAAsB,iBAA8E,SAajD;CAClD,MAAM,EAAE,YAAY,QAAQ,cAAc,YAAY;CACtD,MAAM,WAA8B,CAAC;CACrC,MAAM,uBAAO,IAAI,IAAmC;CACpD,IAAI,cAAc;CAElB,MAAM,cAAc,SAA4B,EAAE,OAAO,OAAO,cAAyC;EACxG,IAAI,WAAW,MACd,qBAAqB,UAAU,OAAO;EAGvC,IAAI,SAAS,MAAM;GAElB,IAAI,WAAW,MACd,qBAAqB,UAAU,QAAQ,mBAAmB,CAAC;GAE5D,cAAc;GACd;EACD;EAEA,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACxC,MAAM,OAAO,MAAM;GACnB,IAAI,KAAK,WAAW,YAAY;IAE/B,uBAAuB,UAAU,YAAY,QAAQ,cAAc,IAAI;IACvE,cAAc;IACd;GACD;GAEA,MAAM,OAAO,KAAK;GAClB,MAAM,MAAM,QAAQ,QAAQ,GAAG,CAAC;GAChC,KAAK,IAAI,QAAQ,IAAI,QAAQ,OAAO;IAAO;IAAK,OAAO;IAAM,MAAM,QAAQ,SAAS,IAAI;GAAE,IAAI,EAAO,IAAI,CAAC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,OAAO,QAAQ,WAAW,MAAM;GACtC,IAAI,SAAS,QAAQ,MAAM,CAAC,MAC3B,KAAK,IAAI,OAAO;IAAO;IAAK,WAAW;IAAY;GAAK,CAAC;QAEzD,QAAQ,KAAK,KAAK;EAEpB;EAGD,MAAM,cAAc,QAAQ,SAAS,QAAQ,SAAS,OAAO,OAAO,CAAC,IAAI,KAAA;EACzE,IAAI,YAAY,MACf,WAAW,MAAM,MAAM,QAAQ;EAEhC,IAAI,eAAe,MAClB,WAAW,SAAS,MAAM,WAAW;CAEvC;CAEA,MAAM,QAAiC,CAAC;CACxC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACxC,MAAM,MAAM,KAAK,IAAI,CAAC;EACtB,IAAI,OAAO,MACV,MAAM,KAAK,GAAG;CAEhB;CACA,OAAO;EAAS;EAAiB;EAAU,aAAa,eAAe,KAAA;CAAU;AAClF;;;;;;AAOA,SAAgB,uBACf,UACA,YACA,QACA,cACA,MACO;CACP,IAAI,KAAK,WAAW,MAAM;EACzB,oBAAoB,UAAU,YAAY,QAAQ,cAAc;GAC/D,cAAc;GACd,UAAU,CAAC,KAAK,OAAO;EACxB,CAAC;EACD;CACD;CAEA,qBAAqB,UAAU,kBAAkB,YAAY,QAAQ,cAAc,KAAK,MAAM,CAAC;AAChG"}
1
+ {"version":3,"file":"batchEtags.js","names":[],"sources":["../../../../../plus/integrations/src/reads/batchEtags.ts"],"sourcesContent":["import { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { BatchSlot } from '../models/integration.js';\nimport type { ProviderResult, ProviderWarning, ProviderWarningKind } from '../results.js';\nimport { appendDedupedWarning, toProviderWarning } from '../results.js';\n\n/**\n * The etag flow shared by the batch reads (`getPullRequestsBatch`, and both forms of `getIssuesBatch`): targets that\n * carry the etag of the caller's copy are first asked a cheap \"what is your change state\" question, and only the ones\n * that moved are read in full.\n *\n * - No target carries an etag, or the integration has no cheap check: ONE full read of every target, exactly as\n * before etags existed, with an etag added to each row.\n * - Otherwise up to three integration calls: the full read of the targets with no etag starts at once, in parallel\n * with the cheap check of the others, and the targets whose etag no longer matches get a second full read as soon\n * as the check settles. A call takes the longer of the two paths, never their sum.\n *\n * The cheap check never answers for a target it couldn't check: a target it failed falls through to the full read,\n * which then has the final word (and supplies the warning, should it fail too) — except when the failure was a\n * refused credential or a spent rate limit, which the full read would only hit again; those targets are dropped with\n * the cheap check's warning, as a failed full read drops them. Each target is judged by its own slot's reason, so one\n * target's rate limit never drops another target the check merely failed to answer, nor sends a rate-limited target\n * to the full read; the check's wrappers return every slot as it settled, failing as a whole only on a refused\n * credential (or when the request itself failed).\n *\n * Failure budget: the cheap check spends no strike toward disconnecting, and shows no notice, unless the credential\n * is refused. Only the full reads spend, each at most one, so a call spends at most two: in a total outage of a batch\n * whose every target carries an etag, one, for the full read every target falls through to.\n *\n * Every warning names the targets it concerns (see `ProviderWarning.targetKeys`): the one target a rejected slot\n * belongs to, or every target of an integration call that failed as a whole.\n */\n\n/** One integration call's slots, as `runCaptured` captures them. */\nexport interface CapturedBatch<T> {\n\tvalue?: BatchSlot<T | undefined>[];\n\twarning?: ProviderWarning;\n}\n\n/**\n * One target's answer: read in full (`value`, or proven absent without one), or `unchanged`, when the cheap check\n * proved the caller's copy current. Every row with a `value` carries its `etag`, as does every `unchanged` one.\n */\nexport interface EtaggedBatchRow<T> {\n\tkey: string;\n\tvalue?: T;\n\tetag?: string;\n\tunchanged?: true;\n}\n\n/** Failures a full read would only hit again: a refused credential, a spent rate limit, a connection that's gone. */\nconst noRetryKinds: readonly ProviderWarningKind[] = ['auth', 'rate-limit', 'no-connection'];\n\nexport async function readEtaggedBatch<Target extends { key: string; etag?: string }, Item, Fields>(options: {\n\tproviderId: IntegrationIds;\n\tdomain: string | undefined;\n\tconnectionId: string | undefined;\n\ttargets: readonly Target[];\n\t/** Whether the integration has a cheap check. Decided up front, so a host without one makes one call. */\n\tsupportsEtags: boolean;\n\treadFull: (targets: readonly Target[]) => Promise<CapturedBatch<Item>>;\n\treadEtagFields: (targets: readonly Target[]) => Promise<CapturedBatch<Fields>>;\n\titemEtag: (item: Item) => string;\n\tfieldsEtag: (fields: Fields) => string;\n\t/** The warning for a full read that answered neither slots nor an error: the provider can't batch at all. */\n\tunsupportedWarning: () => ProviderWarning;\n}): Promise<ProviderResult<EtaggedBatchRow<Item>>> {\n\tconst { providerId, domain, connectionId, targets } = options;\n\tconst warnings: ProviderWarning[] = [];\n\tconst rows = new Map<number, EtaggedBatchRow<Item>>();\n\tlet fetchFailed = false;\n\n\tconst keysOf = (indices: readonly number[]): string[] => indices.map(i => targets[i].key);\n\n\tconst settleFull = (indices: readonly number[], { value: slots, warning }: CapturedBatch<Item>): void => {\n\t\tif (warning != null) {\n\t\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: keysOf(indices) });\n\t\t}\n\n\t\tif (slots == null) {\n\t\t\t// Dropped, never reported absent: \"unknown\" and \"proven absent\" must stay distinguishable.\n\t\t\tif (warning == null) {\n\t\t\t\tappendDedupedWarning(warnings, { ...options.unsupportedWarning(), targetKeys: keysOf(indices) });\n\t\t\t}\n\t\t\tfetchFailed = true;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = 0; i < indices.length; i++) {\n\t\t\tconst slot = slots[i];\n\t\t\tif (slot.status === 'rejected') {\n\t\t\t\t// Dropped, never reported absent, like a whole-call failure: only THIS target failed.\n\t\t\t\tappendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, targets[indices[i]].key);\n\t\t\t\tfetchFailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst item = slot.value;\n\t\t\tconst key = targets[indices[i]].key;\n\t\t\trows.set(indices[i], item != null ? { key: key, value: item, etag: options.itemEtag(item) } : { key: key });\n\t\t}\n\t};\n\n\tconst cheap: number[] = [];\n\tconst full: number[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\t(options.supportsEtags && targets[i].etag ? cheap : full).push(i);\n\t}\n\n\tconst select = (indices: readonly number[]): Target[] => indices.map(i => targets[i]);\n\n\tif (!cheap.length) {\n\t\tsettleFull(full, await options.readFull(targets));\n\t} else {\n\t\t// Started before the cheap check is even sent, so the targets it can't answer never wait on it.\n\t\tconst fullRead = full.length ? options.readFull(select(full)) : undefined;\n\n\t\tconst changed: number[] = [];\n\t\tconst { value: slots, warning } = await options.readEtagFields(select(cheap));\n\t\tif (warning != null && noRetryKinds.includes(warning.kind)) {\n\t\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: keysOf(cheap) });\n\t\t\tfetchFailed = true;\n\t\t} else if (slots == null) {\n\t\t\t// The check failed some other way, or the provider declined it; the full read decides instead.\n\t\t\tchanged.push(...cheap);\n\t\t} else {\n\t\t\tfor (let i = 0; i < cheap.length; i++) {\n\t\t\t\tconst index = cheap[i];\n\t\t\t\tconst slot = slots[i];\n\t\t\t\tif (slot.status === 'rejected') {\n\t\t\t\t\t// A scoped refusal (`failure`) is the credential refused for that target's scope, which a full read\n\t\t\t\t\t// would hit as well.\n\t\t\t\t\tif (slot.failure != null) {\n\t\t\t\t\t\tappendBatchSlotWarning(warnings, providerId, domain, connectionId, slot, targets[index].key);\n\t\t\t\t\t\tfetchFailed = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst slotWarning = toProviderWarning(providerId, domain, connectionId, slot.reason);\n\t\t\t\t\tif (noRetryKinds.includes(slotWarning.kind)) {\n\t\t\t\t\t\tappendDedupedWarning(warnings, { ...slotWarning, targetKeys: [targets[index].key] });\n\t\t\t\t\t\tfetchFailed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchanged.push(index);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst key = targets[index].key;\n\t\t\t\tconst fields = slot.value;\n\t\t\t\tif (fields == null) {\n\t\t\t\t\trows.set(index, { key: key });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst etag = options.fieldsEtag(fields);\n\t\t\t\tif (etag === targets[index].etag) {\n\t\t\t\t\trows.set(index, { key: key, unchanged: true, etag: etag });\n\t\t\t\t} else {\n\t\t\t\t\tchanged.push(index);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst changedRead = changed.length ? options.readFull(select(changed)) : undefined;\n\t\tif (fullRead != null) {\n\t\t\tsettleFull(full, await fullRead);\n\t\t}\n\t\tif (changedRead != null) {\n\t\t\tsettleFull(changed, await changedRead);\n\t\t}\n\t}\n\n\tconst items: EtaggedBatchRow<Item>[] = [];\n\tfor (let i = 0; i < targets.length; i++) {\n\t\tconst row = rows.get(i);\n\t\tif (row != null) {\n\t\t\titems.push(row);\n\t\t}\n\t}\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/**\n * Appends the warning for a batch target that could not be checked, shared by every batch read: for a refusal, the\n * scope failure it was recorded as (see `IntegrationBase.settleBatchRefusals`), published as an account-wide read\n * publishes one, scoped and with its cause; otherwise, the reason itself. The warning names the target's key.\n */\nexport function appendBatchSlotWarning(\n\twarnings: ProviderWarning[],\n\tproviderId: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tslot: Extract<BatchSlot<unknown>, { status: 'rejected' }>,\n\ttargetKey: string,\n): void {\n\tif (slot.failure != null) {\n\t\tconst produced: ProviderWarning[] = [];\n\t\tmergeAssessmentInto(produced, providerId, domain, connectionId, {\n\t\t\tcompleteness: 'partial',\n\t\t\tfailures: [slot.failure],\n\t\t});\n\t\tfor (const warning of produced) {\n\t\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: [targetKey] });\n\t\t}\n\t\treturn;\n\t}\n\n\tappendDedupedWarning(warnings, {\n\t\t...toProviderWarning(providerId, domain, connectionId, slot.reason),\n\t\ttargetKeys: [targetKey],\n\t});\n}\n"],"mappings":";;;;AAmDA,MAAM,eAA+C;CAAC;CAAQ;CAAc;AAAe;AAE3F,eAAsB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AAO,CAAC,IAAI,KAAA;EACzE,IAAI,YAAY,MACf,WAAW,MAAM,MAAM,QAAQ;EAEhC,IAAI,eAAe,MAClB,WAAW,SAAS,MAAM,WAAW;CAEvC;CAEA,MAAM,QAAiC,CAAC;CACxC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACxC,MAAM,MAAM,KAAK,IAAI,CAAC;EACtB,IAAI,OAAO,MACV,MAAM,KAAK,GAAG;CAEhB;CACA,OAAO;EAAS;EAAiB;EAAU,aAAa,eAAe,KAAA;CAAU;AAClF;;;;;;AAOA,SAAgB,uBACf,UACA,YACA,QACA,cACA,MACA,WACO;CACP,IAAI,KAAK,WAAW,MAAM;EACzB,MAAM,WAA8B,CAAC;EACrC,oBAAoB,UAAU,YAAY,QAAQ,cAAc;GAC/D,cAAc;GACd,UAAU,CAAC,KAAK,OAAO;EACxB,CAAC;EACD,KAAK,MAAM,WAAW,UACrB,qBAAqB,UAAU;GAAE,GAAG;GAAS,YAAY,CAAC,SAAS;EAAE,CAAC;EAEvE;CACD;CAEA,qBAAqB,UAAU;EAC9B,GAAG,kBAAkB,YAAY,QAAQ,cAAc,KAAK,MAAM;EAClE,YAAY,CAAC,SAAS;CACvB,CAAC;AACF"}
@@ -1,5 +1,5 @@
1
- import { toPageCursor } from "../providers/utils/providerPaging.js";
2
1
  import { hostFromDomain } from "../utils/domain.utils.js";
2
+ import { toPageCursor } from "../providers/utils/providerPaging.js";
3
3
  import { pageToCursor } from "./paging.js";
4
4
  //#region ../plus/integrations/src/reads/cursors.ts
5
5
  /** Positive safe integers only, deduped; `undefined` when nothing survives (so the field is omitted). */
@@ -1,7 +1,6 @@
1
1
  import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
2
2
  import { IntegrationIds } from "../constants.js";
3
3
  import { ProviderWarning } from "../results.js";
4
- import "../providerFilters.js";
5
4
  import { ProviderPullRequest, ProviderReposInput, ProviderRepository } from "../providers/models.js";
6
5
  import { GitHostIntegration } from "../models/gitHostIntegration.js";
7
6
  import { IntegrationResult } from "../models/integration.js";
@@ -8,7 +8,7 @@ import { pageToCursor, refusedPage, resolveContinuation, resolveCurrentPage, toP
8
8
  import { gitHostOnlySurfaceWarning, truncationWarning, unsupportedWarning } from "./warnings.js";
9
9
  import { runCaptured } from "./drains.js";
10
10
  import { isIssuesIntegration } from "../models/issuesIntegration.js";
11
- import { assertHierarchyReadTarget, mergeHierarchyResults, orgForProject, resourceMatchesOrg, resourceToOrg, withProviderContext } from "./hierarchy.utils.js";
11
+ import { assertHierarchyReadTarget, mergeHierarchyResults, projectToOrg, resourceMatchesOrg, resourceToOrg, withProviderContext } from "./hierarchy.utils.js";
12
12
  //#region ../plus/integrations/src/reads/hierarchy.ts
13
13
  /**
14
14
  * Folds a flat hierarchy result's incompleteness into `warnings`, returning whether it leaves the read
@@ -145,7 +145,7 @@ async function listProjects(ctx, options) {
145
145
  warnings.push(projectsWarning);
146
146
  if (projects == null) fetchFailed = true;
147
147
  }
148
- if (projects != null) items.push(...projects.values.map((project) => resourceToOrg(id, project, orgForProject(id, project, scopedResources))));
148
+ if (projects != null) items.push(...projects.values.map((project) => projectToOrg(id, project, scopedResources)));
149
149
  const assessment = mergeAssessmentInto(warnings, id, domain, connectionId, projects?.metadata);
150
150
  if (assessment.fetchFailed || assessment.truncated) fetchFailed = true;
151
151
  }