@gitkraken/core-gitlens 0.44.0 → 0.46.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 (255) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/git/models/remote.js +2 -2
  3. package/dist/git/models/remote.js.map +1 -1
  4. package/dist/git/remotes/matcher.js +25 -3
  5. package/dist/git/remotes/matcher.js.map +1 -1
  6. package/dist/git/utils/branchLanded.utils.d.ts +7 -0
  7. package/dist/git/utils/branchLanded.utils.js +10 -1
  8. package/dist/git/utils/branchLanded.utils.js.map +1 -1
  9. package/dist/git/utils/remote.utils.d.ts +1 -0
  10. package/dist/git/utils/remote.utils.js +14 -5
  11. package/dist/git/utils/remote.utils.js.map +1 -1
  12. package/dist/git-cli/parsers/logParser.js +227 -468
  13. package/dist/git-cli/parsers/logParser.js.map +1 -1
  14. package/dist/git-cli/parsers/refParser.js +4 -4
  15. package/dist/git-cli/parsers/refParser.js.map +1 -1
  16. package/dist/git-cli/providers/branches.d.ts +5 -0
  17. package/dist/git-cli/providers/branches.js +25 -21
  18. package/dist/git-cli/providers/branches.js.map +1 -1
  19. package/dist/git-cli/providers/config.js +2 -2
  20. package/dist/git-cli/providers/pausedOperations.js +2 -2
  21. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  22. package/dist/git-cli/providers/staging.js +1 -1
  23. package/dist/ipc/discovery.js +1 -1
  24. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  25. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  26. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  27. package/dist/plus/git-github/api/github.d.ts +13 -1
  28. package/dist/plus/git-github/api/github.js +99 -30
  29. package/dist/plus/git-github/api/github.js.map +1 -1
  30. package/dist/plus/git-github/api/issueWrites.d.ts +9 -2
  31. package/dist/plus/git-github/api/issueWrites.js +61 -31
  32. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  33. package/dist/plus/git-github/api/pullRequestWrites.d.ts +95 -0
  34. package/dist/plus/git-github/api/pullRequestWrites.js +469 -0
  35. package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -0
  36. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +44 -0
  37. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +199 -0
  38. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -0
  39. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +17 -9
  40. package/dist/plus/integrations/authentication/configuredIntegrationService.js +71 -19
  41. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  42. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +9 -40
  43. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +0 -182
  44. package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +5 -2
  45. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +15 -1
  46. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  47. package/dist/plus/integrations/authentication/models.d.ts +0 -1
  48. package/dist/plus/integrations/authentication/models.js +1 -2
  49. package/dist/plus/integrations/authentication/models.js.map +1 -1
  50. package/dist/plus/integrations/authentication/observedAuthenticationProvider.d.ts +1 -0
  51. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +14 -4
  52. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
  53. package/dist/plus/integrations/authentication/rejectedTokenTracker.d.ts +2 -2
  54. package/dist/plus/integrations/authentication/rejectedTokenTracker.js +19 -5
  55. package/dist/plus/integrations/authentication/rejectedTokenTracker.js.map +1 -1
  56. package/dist/plus/integrations/constants.d.ts +0 -10
  57. package/dist/plus/integrations/constants.js +1 -95
  58. package/dist/plus/integrations/constants.js.map +1 -1
  59. package/dist/plus/integrations/context.d.ts +13 -13
  60. package/dist/plus/integrations/index.d.ts +41 -25
  61. package/dist/plus/integrations/index.js +40 -8
  62. package/dist/plus/integrations/index.js.map +1 -1
  63. package/dist/plus/integrations/integrationService.d.ts +20 -22
  64. package/dist/plus/integrations/integrationService.js +80 -9
  65. package/dist/plus/integrations/integrationService.js.map +1 -1
  66. package/dist/plus/integrations/lite.js +1 -1
  67. package/dist/plus/integrations/lite.js.map +1 -1
  68. package/dist/plus/integrations/manager.d.ts +70 -15
  69. package/dist/plus/integrations/models/actionablePullRequest.d.ts +213 -0
  70. package/dist/plus/integrations/models/actionablePullRequest.js +25 -0
  71. package/dist/plus/integrations/models/actionablePullRequest.js.map +1 -0
  72. package/dist/plus/integrations/models/gitHostIntegration.d.ts +13 -46
  73. package/dist/plus/integrations/models/gitHostIntegration.js +15 -4
  74. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  75. package/dist/plus/integrations/models/integration.d.ts +12 -177
  76. package/dist/plus/integrations/models/integration.js +21 -77
  77. package/dist/plus/integrations/models/integration.js.map +1 -1
  78. package/dist/plus/integrations/models/issuesIntegration.d.ts +9 -5
  79. package/dist/plus/integrations/models/issuesIntegration.js +5 -3
  80. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  81. package/dist/plus/integrations/models/publicIntegration.d.ts +252 -0
  82. package/dist/plus/integrations/models/publicIntegration.js +21 -0
  83. package/dist/plus/integrations/models/publicIntegration.js.map +1 -0
  84. package/dist/plus/integrations/providerFilters.d.ts +58 -0
  85. package/dist/plus/integrations/providerFilters.js.map +1 -1
  86. package/dist/plus/integrations/providers/actionablePullRequests.d.ts +19 -0
  87. package/dist/plus/integrations/providers/actionablePullRequests.js +32 -0
  88. package/dist/plus/integrations/providers/actionablePullRequests.js.map +1 -0
  89. package/dist/plus/integrations/providers/apiClients.d.ts +1 -2
  90. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  91. package/dist/plus/integrations/providers/asana.d.ts +3 -2
  92. package/dist/plus/integrations/providers/asana.js +2 -1
  93. package/dist/plus/integrations/providers/asana.js.map +1 -1
  94. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  95. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  96. package/dist/plus/integrations/providers/azure/azure.utils.d.ts +10 -3
  97. package/dist/plus/integrations/providers/azure/azure.utils.js +5 -1
  98. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  99. package/dist/plus/integrations/providers/azure/models.d.ts +1 -5
  100. package/dist/plus/integrations/providers/azure/models.js +1 -1
  101. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  102. package/dist/plus/integrations/providers/azureDevOps.d.ts +8 -5
  103. package/dist/plus/integrations/providers/azureDevOps.js +2 -1
  104. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  105. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +5 -4
  106. package/dist/plus/integrations/providers/azureDevOpsServer.js +3 -1
  107. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  108. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +2 -2
  109. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  110. package/dist/plus/integrations/providers/bitbucket/models.d.ts +1 -1
  111. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  112. package/dist/plus/integrations/providers/bitbucket-server.d.ts +5 -4
  113. package/dist/plus/integrations/providers/bitbucket-server.js +2 -1
  114. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  115. package/dist/plus/integrations/providers/bitbucket.d.ts +4 -3
  116. package/dist/plus/integrations/providers/bitbucket.js +2 -1
  117. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  118. package/dist/plus/integrations/providers/github/github.d.ts +0 -1
  119. package/dist/plus/integrations/providers/github/github.js +1 -1
  120. package/dist/plus/integrations/providers/github/github.js.map +1 -1
  121. package/dist/plus/integrations/providers/github.d.ts +16 -6
  122. package/dist/plus/integrations/providers/github.js +109 -12
  123. package/dist/plus/integrations/providers/github.js.map +1 -1
  124. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
  125. package/dist/plus/integrations/providers/gitlab/gitlab.js +1 -2
  126. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  127. package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +14 -1
  128. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
  129. package/dist/plus/integrations/providers/gitlab/models.d.ts +2 -10
  130. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  131. package/dist/plus/integrations/providers/gitlab.d.ts +7 -5
  132. package/dist/plus/integrations/providers/gitlab.js +2 -1
  133. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  134. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  135. package/dist/plus/integrations/providers/jira-server.d.ts +4 -4
  136. package/dist/plus/integrations/providers/jira-server.js +3 -2
  137. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  138. package/dist/plus/integrations/providers/jira.d.ts +3 -3
  139. package/dist/plus/integrations/providers/jira.js +3 -2
  140. package/dist/plus/integrations/providers/jira.js.map +1 -1
  141. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +1 -1
  142. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  143. package/dist/plus/integrations/providers/linear.d.ts +4 -3
  144. package/dist/plus/integrations/providers/linear.js +3 -2
  145. package/dist/plus/integrations/providers/linear.js.map +1 -1
  146. package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +1 -1
  147. package/dist/plus/integrations/providers/linearIssuesEtag.js +1 -1
  148. package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
  149. package/dist/plus/integrations/providers/metadata.d.ts +136 -0
  150. package/dist/plus/integrations/providers/metadata.js +513 -0
  151. package/dist/plus/integrations/providers/metadata.js.map +1 -0
  152. package/dist/plus/integrations/providers/models.d.ts +10 -206
  153. package/dist/plus/integrations/providers/models.js +8 -539
  154. package/dist/plus/integrations/providers/models.js.map +1 -1
  155. package/dist/plus/integrations/providers/providersApi.d.ts +3 -2
  156. package/dist/plus/integrations/providers/providersApi.js +2 -1
  157. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  158. package/dist/plus/integrations/providers/trello.d.ts +1 -1
  159. package/dist/plus/integrations/providers/trello.js +2 -1
  160. package/dist/plus/integrations/providers/trello.js.map +1 -1
  161. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +2 -0
  162. package/dist/plus/integrations/providers/utils/providerPaging.js +3 -2
  163. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  164. package/dist/plus/integrations/providers/utils.d.ts +119 -10
  165. package/dist/plus/integrations/providers/utils.js +57 -3
  166. package/dist/plus/integrations/providers/utils.js.map +1 -1
  167. package/dist/plus/integrations/reads/autolinks.d.ts +1 -1
  168. package/dist/plus/integrations/reads/autolinks.js +1 -1
  169. package/dist/plus/integrations/reads/autolinks.js.map +1 -1
  170. package/dist/plus/integrations/reads/broaden.d.ts +1 -1
  171. package/dist/plus/integrations/reads/broaden.js +3 -2
  172. package/dist/plus/integrations/reads/broaden.js.map +1 -1
  173. package/dist/plus/integrations/reads/context.d.ts +1 -1
  174. package/dist/plus/integrations/reads/counts.d.ts +1 -88
  175. package/dist/plus/integrations/reads/counts.js +4 -2
  176. package/dist/plus/integrations/reads/counts.js.map +1 -1
  177. package/dist/plus/integrations/reads/currentAccount.d.ts +1 -18
  178. package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
  179. package/dist/plus/integrations/reads/drains.d.ts +3 -4
  180. package/dist/plus/integrations/reads/drains.js +1 -1
  181. package/dist/plus/integrations/reads/drains.js.map +1 -1
  182. package/dist/plus/integrations/reads/etag.d.ts +174 -3
  183. package/dist/plus/integrations/reads/etag.js +69 -14
  184. package/dist/plus/integrations/reads/etag.js.map +1 -1
  185. package/dist/plus/integrations/reads/filters.d.ts +3 -61
  186. package/dist/plus/integrations/reads/filters.js +1 -1
  187. package/dist/plus/integrations/reads/filters.js.map +1 -1
  188. package/dist/plus/integrations/reads/hierarchy.d.ts +1 -1
  189. package/dist/plus/integrations/reads/hierarchy.js +4 -2
  190. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  191. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -102
  192. package/dist/plus/integrations/reads/issueBatch.js +3 -4
  193. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  194. package/dist/plus/integrations/reads/issueTracker.d.ts +1 -1
  195. package/dist/plus/integrations/reads/issueTracker.js +4 -3
  196. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  197. package/dist/plus/integrations/reads/issues.d.ts +1 -1
  198. package/dist/plus/integrations/reads/issues.js +4 -2
  199. package/dist/plus/integrations/reads/issues.js.map +1 -1
  200. package/dist/plus/integrations/reads/paging.d.ts +1 -1
  201. package/dist/plus/integrations/reads/paging.js +1 -1
  202. package/dist/plus/integrations/reads/paging.js.map +1 -1
  203. package/dist/plus/integrations/reads/pullRequestActivity.d.ts +1 -24
  204. package/dist/plus/integrations/reads/pullRequestActivity.js +2 -1
  205. package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -1
  206. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +2 -56
  207. package/dist/plus/integrations/reads/pullRequestBatch.js +23 -3
  208. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
  209. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +1 -47
  210. package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
  211. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  212. package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +1 -15
  213. package/dist/plus/integrations/reads/pullRequestCheckLogs.js +2 -1
  214. package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -1
  215. package/dist/plus/integrations/reads/pullRequests.js +4 -2
  216. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  217. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +1 -16
  218. package/dist/plus/integrations/reads/pullRequestsForCommits.js +2 -1
  219. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -1
  220. package/dist/plus/integrations/reads/resolveRepository.js +10 -5
  221. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  222. package/dist/plus/integrations/reads/searchIssues.js +2 -1
  223. package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
  224. package/dist/plus/integrations/reads/searchPullRequests.js +2 -1
  225. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  226. package/dist/plus/integrations/reads/sweeps.d.ts +1 -1
  227. package/dist/plus/integrations/reads/sweeps.js +3 -2
  228. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  229. package/dist/plus/integrations/reads/warnings.d.ts +1 -1
  230. package/dist/plus/integrations/reads/warnings.js +1 -1
  231. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  232. package/dist/plus/integrations/results.d.ts +324 -2
  233. package/dist/plus/integrations/results.js.map +1 -1
  234. package/dist/plus/integrations/telemetry.d.ts +0 -10
  235. package/dist/plus/integrations/telemetry.js +0 -11
  236. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  237. package/dist/plus/integrations/utils/domain.utils.js +10 -2
  238. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  239. package/dist/plus/integrations/utils/integration.utils.d.ts +1 -6
  240. package/dist/plus/integrations/utils/integration.utils.js +2 -9
  241. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  242. package/dist/utils/env/node/exec.js +2 -2
  243. package/dist/utils/keys/chord.d.ts +13 -2
  244. package/dist/utils/keys/chord.js +76 -17
  245. package/dist/utils/keys/chord.js.map +1 -1
  246. package/dist/utils/keys/keybinding.d.ts +12 -0
  247. package/dist/utils/keys/keybinding.js +52 -2
  248. package/dist/utils/keys/keybinding.js.map +1 -1
  249. package/dist/utils/markdown.d.ts +21 -0
  250. package/dist/utils/markdown.js +33 -1
  251. package/dist/utils/markdown.js.map +1 -1
  252. package/docs/integrations.md +135 -16
  253. package/package.json +5 -1
  254. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +0 -1
  255. package/dist/plus/integrations/telemetry.js.map +0 -1
@@ -6,6 +6,64 @@ export declare enum IssueFilter {
6
6
  Assignee = "assignee",
7
7
  Mention = "mention"
8
8
  }
9
+ /**
10
+ * What `getSupportedFilters` (`reads/filters.ts`) reports: every vocabulary a provider's reads can express, so a consumer can
11
+ * narrow to it BEFORE issuing a read. See that function for the capability table itself and why intersecting
12
+ * against this is what keeps a filtered read from being refused.
13
+ *
14
+ * Named rather than written inline, because the same shape is the declared return type of THREE declarations that
15
+ * all describe one value — this function, `IntegrationService.getSupportedFilters`, which only forwards to it, and
16
+ * `IntegrationManager.getSupportedFilters`, which publishes it. Spelled out three times, a member added here
17
+ * reached one of them and left the others a compile error away from the truth; that is exactly how the two sort
18
+ * members below came to be written out three times.
19
+ */
20
+ export type SupportedFilters = {
21
+ pullRequests: PullRequestFilter[];
22
+ pullRequestsAccountWide: PullRequestFilter[];
23
+ /**
24
+ * Criteria and scopes the filtered pull-request search can express. Always present; an empty relationship list
25
+ * means the provider exposes no filtered pull-request search.
26
+ */
27
+ pullRequestSearch: PullRequestSearchCapabilities;
28
+ /**
29
+ * Filters the repo-scoped issue read accepts — and, for an issue tracker (Jira/Linear/Trello), its
30
+ * project-scoped read, that being its only issue surface. A tracker therefore reports here and leaves
31
+ * `issuesAccountWide` empty, so intersecting a tracker against that field would read "cannot filter" for a
32
+ * provider that filters fine.
33
+ */
34
+ issues: IssueFilter[];
35
+ issuesAccountWide: IssueFilter[];
36
+ /**
37
+ * What the filtered issue search (and the count probe over the same criteria) can express. Always present: a
38
+ * provider with no filtered issue search reports an empty `relationships` and all-false flags, which is the
39
+ * signal to hide that surface rather than to hide individual chips.
40
+ */
41
+ issueSearch: IssueSearchCapabilities;
42
+ /**
43
+ * Sort keys the repo-scoped issue read can express — and, for an issue tracker, its project-scoped read. Empty
44
+ * means the read can't be ordered, so pass no `sort`.
45
+ *
46
+ * A key here is expressible on ONE provider query. A page spanning several repositories or projects is a merge,
47
+ * and a merge can only order by what a normalized issue carries, so `priority`/`dueDate`/`resolved` are refused
48
+ * there even where they are listed. Read one scope at a time to use them.
49
+ */
50
+ issueSorts: IssueSorting[];
51
+ /**
52
+ * Sort keys the account-wide issue read can express — a different vocabulary, not a subset: for GitLab the two
53
+ * reads are different APIs. Needs no mergeability caveat, because every account-wide read is a union of several
54
+ * queries, so only keys a merge can honor are listed at all. Empty for an issue tracker, which reports under
55
+ * `issueSorts`.
56
+ */
57
+ issueSortsAccountWide: IssueSorting[];
58
+ /**
59
+ * Whether issue list reads can be asked for a `state` other than open (`closed`, `all`). False means
60
+ * only open issues are readable, and the read refuses the other two rather than serving the open list.
61
+ *
62
+ * Includes Azure DevOps Services and Server list reads. Filtered search reports its independent state
63
+ * capability under `issueSearch.states`.
64
+ */
65
+ issueStates: boolean;
66
+ };
9
67
  //#endregion
10
68
  export { type IssueSearchCapabilities, type IssueSearchCriteria, type IssueSearchRelationship, type IssueSortField, type IssueSorting, PullRequestFilter, type PullRequestSearchCapabilities, type PullRequestSearchCriteria, type PullRequestSortField, type PullRequestSorting };
11
69
  //# sourceMappingURL=providerFilters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providerFilters.js","names":[],"sources":["../../../../plus/integrations/src/providerFilters.ts"],"sourcesContent":["export { PullRequestFilter } from '@gitlens/git/models/pullRequest.js';\n\nexport enum IssueFilter {\n\tAuthor = 'author',\n\tAssignee = 'assignee',\n\tMention = 'mention',\n}\n\n/**\n * The filtered issue search's criteria model, re-exported from the git models so it can be reached from here\n * alongside the two filter enums above.\n *\n * It lives in `@gitlens/git` rather than in this package because the provider implementations that translate it\n * to a query — the GitHub API client among them — sit BELOW this package in the dependency graph and can't import\n * from it. {@link IssueSearchRelationship} is a superset of {@link IssueFilter}: it adds the two user-independent\n * relationships (`any-assignee`, `unassigned`) that the user-relative \"my issues\" filters have no way to name.\n */\nexport type {\n\tIssueSearchCapabilities,\n\tIssueSearchCriteria,\n\tIssueSearchRelationship,\n\tIssueSortField,\n\tIssueSorting,\n} from '@gitlens/git/models/issue.js';\n\n/**\n * The filtered pull-request search criteria and its capability table. These live in `@gitlens/git` for the\n * same dependency-direction reason as the issue-search model above: provider API clients translate them below\n * this package and cannot import this facade.\n */\nexport type {\n\tPullRequestSearchCapabilities,\n\tPullRequestSearchCriteria,\n\tPullRequestSortField,\n\tPullRequestSorting,\n} from '@gitlens/git/models/pullRequest.js';\n"],"mappings":";;AAEA,IAAY,cAAL,yBAAA,aAAA;CACN,YAAA,YAAA;CACA,YAAA,cAAA;CACA,YAAA,aAAA;;AACD,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"providerFilters.js","names":[],"sources":["../../../../plus/integrations/src/providerFilters.ts"],"sourcesContent":["import type { IssueSearchCapabilities, IssueSorting } from '@gitlens/git/models/issue.js';\nimport type { PullRequestFilter, PullRequestSearchCapabilities } from '@gitlens/git/models/pullRequest.js';\n\nexport { PullRequestFilter } from '@gitlens/git/models/pullRequest.js';\n\nexport enum IssueFilter {\n\tAuthor = 'author',\n\tAssignee = 'assignee',\n\tMention = 'mention',\n}\n\n/**\n * The filtered issue search's criteria model, re-exported from the git models so it can be reached from here\n * alongside the two filter enums above.\n *\n * It lives in `@gitlens/git` rather than in this package because the provider implementations that translate it\n * to a query — the GitHub API client among them — sit BELOW this package in the dependency graph and can't import\n * from it. {@link IssueSearchRelationship} is a superset of {@link IssueFilter}: it adds the two user-independent\n * relationships (`any-assignee`, `unassigned`) that the user-relative \"my issues\" filters have no way to name.\n */\nexport type {\n\tIssueSearchCapabilities,\n\tIssueSearchCriteria,\n\tIssueSearchRelationship,\n\tIssueSortField,\n\tIssueSorting,\n} from '@gitlens/git/models/issue.js';\n\n/**\n * The filtered pull-request search criteria and its capability table. These live in `@gitlens/git` for the\n * same dependency-direction reason as the issue-search model above: provider API clients translate them below\n * this package and cannot import this facade.\n */\nexport type {\n\tPullRequestSearchCapabilities,\n\tPullRequestSearchCriteria,\n\tPullRequestSortField,\n\tPullRequestSorting,\n} from '@gitlens/git/models/pullRequest.js';\n\n/**\n * What `getSupportedFilters` (`reads/filters.ts`) reports: every vocabulary a provider's reads can express, so a consumer can\n * narrow to it BEFORE issuing a read. See that function for the capability table itself and why intersecting\n * against this is what keeps a filtered read from being refused.\n *\n * Named rather than written inline, because the same shape is the declared return type of THREE declarations that\n * all describe one value — this function, `IntegrationService.getSupportedFilters`, which only forwards to it, and\n * `IntegrationManager.getSupportedFilters`, which publishes it. Spelled out three times, a member added here\n * reached one of them and left the others a compile error away from the truth; that is exactly how the two sort\n * members below came to be written out three times.\n */\nexport type SupportedFilters = {\n\tpullRequests: PullRequestFilter[];\n\tpullRequestsAccountWide: PullRequestFilter[];\n\t/**\n\t * Criteria and scopes the filtered pull-request search can express. Always present; an empty relationship list\n\t * means the provider exposes no filtered pull-request search.\n\t */\n\tpullRequestSearch: PullRequestSearchCapabilities;\n\t/**\n\t * Filters the repo-scoped issue read accepts — and, for an issue tracker (Jira/Linear/Trello), its\n\t * project-scoped read, that being its only issue surface. A tracker therefore reports here and leaves\n\t * `issuesAccountWide` empty, so intersecting a tracker against that field would read \"cannot filter\" for a\n\t * provider that filters fine.\n\t */\n\tissues: IssueFilter[];\n\tissuesAccountWide: IssueFilter[];\n\t/**\n\t * What the filtered issue search (and the count probe over the same criteria) can express. Always present: a\n\t * provider with no filtered issue search reports an empty `relationships` and all-false flags, which is the\n\t * signal to hide that surface rather than to hide individual chips.\n\t */\n\tissueSearch: IssueSearchCapabilities;\n\t/**\n\t * Sort keys the repo-scoped issue read can express — and, for an issue tracker, its project-scoped read. Empty\n\t * means the read can't be ordered, so pass no `sort`.\n\t *\n\t * A key here is expressible on ONE provider query. A page spanning several repositories or projects is a merge,\n\t * and a merge can only order by what a normalized issue carries, so `priority`/`dueDate`/`resolved` are refused\n\t * there even where they are listed. Read one scope at a time to use them.\n\t */\n\tissueSorts: IssueSorting[];\n\t/**\n\t * Sort keys the account-wide issue read can express — a different vocabulary, not a subset: for GitLab the two\n\t * reads are different APIs. Needs no mergeability caveat, because every account-wide read is a union of several\n\t * queries, so only keys a merge can honor are listed at all. Empty for an issue tracker, which reports under\n\t * `issueSorts`.\n\t */\n\tissueSortsAccountWide: IssueSorting[];\n\t/**\n\t * Whether issue list reads can be asked for a `state` other than open (`closed`, `all`). False means\n\t * only open issues are readable, and the read refuses the other two rather than serving the open list.\n\t *\n\t * Includes Azure DevOps Services and Server list reads. Filtered search reports its independent state\n\t * capability under `issueSearch.states`.\n\t */\n\tissueStates: boolean;\n};\n"],"mappings":";;AAKA,IAAY,cAAL,yBAAA,aAAA;CACN,YAAA,YAAA;CACA,YAAA,cAAA;CACA,YAAA,aAAA;;AACD,EAAA,CAAA,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { PullRequest } from "../../../git/models/pullRequest.js";
2
+ import { ActionablePullRequestAccount, ActionablePullRequestEnrichedItems, ActionablePullRequestFields, ActionablePullRequestInput } from "../models/actionablePullRequest.js";
3
+ //#region ../plus/integrations/src/providers/actionablePullRequests.d.ts
4
+ /**
5
+ * Converts a pull request into the input {@link getActionablePullRequests} categorizes, with the entity-identifier
6
+ * `uuid` that keys its pins and snoozes.
7
+ */
8
+ export declare function toActionablePullRequestInput(pr: PullRequest): ActionablePullRequestInput;
9
+ /**
10
+ * Categorizes pull requests for the viewer (Launchpad's action categories), using provider-apis' categorizer.
11
+ *
12
+ * Generic so a caller's extra properties survive: the categorizer spreads each input into its output. The casts
13
+ * only cross the SDK's nominal string enums, whose values the neutral types share (see the parity test).
14
+ */
15
+ export declare function getActionablePullRequests<T extends ActionablePullRequestInput>(pullRequests: T[], viewer: Pick<ActionablePullRequestAccount, 'id'> | null, options?: {
16
+ enrichedItemsByUniqueId?: ActionablePullRequestEnrichedItems;
17
+ }): (T & ActionablePullRequestFields)[];
18
+ //#endregion
19
+ //# sourceMappingURL=actionablePullRequests.d.ts.map
@@ -0,0 +1,32 @@
1
+ import "../constants.js";
2
+ import "./pullRequestReviews.js";
3
+ import { GitPullRequestMergeableState as GitPullRequestMergeableState$1, toProviderPullRequest } from "./models.js";
4
+ import { encodeEntityIdentifier, getEntityIdentifierInput } from "./utils.js";
5
+ import { GitProviderUtils } from "@gitkraken/provider-apis";
6
+ //#region ../plus/integrations/src/providers/actionablePullRequests.ts
7
+ /**
8
+ * Converts a pull request into the input {@link getActionablePullRequests} categorizes, with the entity-identifier
9
+ * `uuid` that keys its pins and snoozes.
10
+ */
11
+ function toActionablePullRequestInput(pr) {
12
+ const { reviews, mergeableState, ...providerPr } = toProviderPullRequest(pr);
13
+ return {
14
+ ...providerPr,
15
+ mergeableState: mergeableState ?? (pr.provider.id === "bitbucket" ? GitPullRequestMergeableState$1.Mergeable : GitPullRequestMergeableState$1.Unknown),
16
+ reviews: reviews?.filter((r) => r.state !== "DISMISSED") ?? null,
17
+ uuid: encodeEntityIdentifier(getEntityIdentifierInput(pr))
18
+ };
19
+ }
20
+ /**
21
+ * Categorizes pull requests for the viewer (Launchpad's action categories), using provider-apis' categorizer.
22
+ *
23
+ * Generic so a caller's extra properties survive: the categorizer spreads each input into its output. The casts
24
+ * only cross the SDK's nominal string enums, whose values the neutral types share (see the parity test).
25
+ */
26
+ function getActionablePullRequests(pullRequests, viewer, options) {
27
+ return GitProviderUtils.getActionablePullRequests(pullRequests, viewer, options);
28
+ }
29
+ //#endregion
30
+ export { getActionablePullRequests, toActionablePullRequestInput };
31
+
32
+ //# sourceMappingURL=actionablePullRequests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionablePullRequests.js","names":["GitPullRequestMergeableState"],"sources":["../../../../../plus/integrations/src/providers/actionablePullRequests.ts"],"sourcesContent":["import type { GitPullRequestReviewState, PullRequestWithUniqueID } from '@gitkraken/provider-apis';\nimport { GitProviderUtils } from '@gitkraken/provider-apis';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport type {\n\tActionablePullRequestAccount,\n\tActionablePullRequestEnrichedItems,\n\tActionablePullRequestFields,\n\tActionablePullRequestInput,\n} from '../models/actionablePullRequest.js';\nimport { GitPullRequestMergeableState, toProviderPullRequest } from './models.js';\nimport type { ProviderPullRequestReview } from './pullRequestReviews.js';\nimport { providerPullRequestReviewStateDismissed } from './pullRequestReviews.js';\nimport { encodeEntityIdentifier, getEntityIdentifierInput } from './utils.js';\n\n// Launchpad's categorization over provider-apis' categorizer. Kept apart from `models.ts` so the public facade can\n// re-export these: their signatures are in the neutral `ActionablePullRequest*` types, and the SDK stays an\n// implementation detail of this module.\n\n/**\n * Converts a pull request into the input {@link getActionablePullRequests} categorizes, with the entity-identifier\n * `uuid` that keys its pins and snoozes.\n */\nexport function toActionablePullRequestInput(pr: PullRequest): ActionablePullRequestInput {\n\tconst { reviews, mergeableState, ...providerPr } = toProviderPullRequest(pr);\n\t// Built as the SDK's own type, which the neutral one mirrors, so a field the SDK requires can't go missing.\n\tconst input: PullRequestWithUniqueID = {\n\t\t...providerPr,\n\t\t// The SDK's type requires a mergeability, and its categorizer only acts on a known one, so an unfetched\n\t\t// one goes over as its own `UNKNOWN`. Except on Bitbucket Cloud, which reports no mergeability at all:\n\t\t// Launchpad's \"Ready to merge\" needs one, so its rows go over as `MERGEABLE`, as provider-apis' own\n\t\t// Bitbucket rows already do.\n\t\tmergeableState:\n\t\t\tmergeableState ??\n\t\t\t(pr.provider.id === GitCloudHostIntegrationId.Bitbucket\n\t\t\t\t? GitPullRequestMergeableState.Mergeable\n\t\t\t\t: GitPullRequestMergeableState.Unknown),\n\t\t// The SDK boundary: `getActionablePullRequests` categorizes by review state and only knows\n\t\t// provider-apis' own vocabulary, so the locally-added dismissed state is dropped here rather than\n\t\t// handed over as a value it would fall through on. Our own projection keeps it — see\n\t\t// `providerPullRequestReviewStateDismissed`. `commitOid` rides along on the surviving reviews: it is an\n\t\t// extra property the SDK ignores, not a value it could misread.\n\t\treviews:\n\t\t\treviews?.filter(\n\t\t\t\t(r): r is ProviderPullRequestReview & { state: GitPullRequestReviewState } =>\n\t\t\t\t\tr.state !== providerPullRequestReviewStateDismissed,\n\t\t\t) ?? null,\n\t\tuuid: encodeEntityIdentifier(getEntityIdentifierInput(pr)),\n\t};\n\treturn input;\n}\n\n/**\n * Categorizes pull requests for the viewer (Launchpad's action categories), using provider-apis' categorizer.\n *\n * Generic so a caller's extra properties survive: the categorizer spreads each input into its output. The casts\n * only cross the SDK's nominal string enums, whose values the neutral types share (see the parity test).\n */\nexport function getActionablePullRequests<T extends ActionablePullRequestInput>(\n\tpullRequests: T[],\n\tviewer: Pick<ActionablePullRequestAccount, 'id'> | null,\n\toptions?: { enrichedItemsByUniqueId?: ActionablePullRequestEnrichedItems },\n): (T & ActionablePullRequestFields)[] {\n\treturn GitProviderUtils.getActionablePullRequests(\n\t\tpullRequests as unknown as PullRequestWithUniqueID[],\n\t\tviewer,\n\t\toptions,\n\t) as unknown as (T & ActionablePullRequestFields)[];\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,6BAA6B,IAA6C;CACzF,MAAM,EAAE,SAAS,gBAAgB,GAAG,eAAe,sBAAsB,EAAE;CAyB3E,OAAO;EAtBN,GAAG;EAKH,gBACC,mBACC,GAAG,SAAS,OAAA,cACVA,+BAA6B,YAC7BA,+BAA6B;EAMjC,SACC,SAAS,QACP,MACA,EAAE,UAAA,WACJ,KAAK;EACN,MAAM,uBAAuB,yBAAyB,EAAE,CAAC;CAE/C;AACZ;;;;;;;AAQA,SAAgB,0BACf,cACA,QACA,SACsC;CACtC,OAAO,iBAAiB,0BACvB,cACA,QACA,OACD;AACD"}
@@ -1,12 +1,11 @@
1
1
  import { Disposable } from "../../../utils/disposable.js";
2
2
  import { GitHubApi } from "../../git-github/api/github.js";
3
+ import { IntegrationServiceContext } from "../context.js";
3
4
  import { AzureWorkItemStatesCache } from "./azure/workItemStateCategories.js";
4
5
  import { AzureWorkItemDescriptionsCache } from "./azure/workItemDescriptions.js";
5
6
  import { AzureDevOpsApi } from "./azure/azure.js";
6
7
  import { BitbucketApi } from "./bitbucket/bitbucket.js";
7
- import "./github/github.js";
8
8
  import { GitLabApi } from "./gitlab/gitlab.js";
9
- import { IntegrationServiceContext } from "../context.js";
10
9
  //#region ../plus/integrations/src/providers/apiClients.d.ts
11
10
  /**
12
11
  * The per-provider API clients, owned and built by the package. `GitLabApi`/`BitbucketApi`/`AzureDevOpsApi`
@@ -1 +1 @@
1
- {"version":3,"file":"apiClients.js","names":[],"sources":["../../../../../plus/integrations/src/providers/apiClients.ts"],"sourcesContent":["import type { Disposable } from '@gitlens/utils/disposable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { AzureDevOpsApi } from './azure/azure.js';\nimport { AzureWorkItemDescriptionsCache } from './azure/workItemDescriptions.js';\nimport { AzureWorkItemStatesCache } from './azure/workItemStateCategories.js';\nimport type { BitbucketApi } from './bitbucket/bitbucket.js';\nimport type { GitHubApi } from './github/github.js';\nimport type { GitLabApi } from './gitlab/gitlab.js';\n\n/**\n * The per-provider API clients, owned and built by the package. `GitLabApi`/`BitbucketApi`/`AzureDevOpsApi`\n * live in the package; `GitHubApi` comes from `@gitlens/git-github` (shared with the host's GitHub git\n * provider, which reads the manager's memoized instance via `manager.github`). `undefined` is tolerated for\n * offline/limited runtimes.\n */\nexport interface ApiClients {\n\treadonly azureWorkItemStates: AzureWorkItemStatesCache;\n\treadonly azureWorkItemDescriptions: AzureWorkItemDescriptionsCache;\n\treadonly github: Promise<GitHubApi | undefined>;\n\treadonly gitlab: Promise<GitLabApi | undefined>;\n\treadonly gitlabIfBuilt?: Promise<GitLabApi | undefined>;\n\treadonly bitbucket: Promise<BitbucketApi | undefined>;\n\treadonly azure: Promise<AzureDevOpsApi | undefined>;\n}\n\n/**\n * Lazily constructs + memoizes the API clients from the runtime context, pushing each to `disposables` for\n * teardown. Mirrors the lazy-chunked construction the host's `Container` did before the package took\n * ownership (the host used to build these and inject them back through the context — a pure round-trip).\n */\nexport function createApiClients(ctx: IntegrationServiceContext, disposables: Disposable[]): ApiClients {\n\tconst azureWorkItemStates = new AzureWorkItemStatesCache();\n\tconst azureWorkItemDescriptions = new AzureWorkItemDescriptionsCache();\n\tdisposables.push(\n\t\tctx.config.onDidChange(e => {\n\t\t\tif (e.httpProxy) {\n\t\t\t\tazureWorkItemStates.clear();\n\t\t\t\tazureWorkItemDescriptions.clear();\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tdispose: () => {\n\t\t\t\tazureWorkItemStates.clear();\n\t\t\t\tazureWorkItemDescriptions.clear();\n\t\t\t},\n\t\t},\n\t);\n\tlet github: Promise<GitHubApi | undefined> | undefined;\n\tlet gitlab: Promise<GitLabApi | undefined> | undefined;\n\tlet bitbucket: Promise<BitbucketApi | undefined> | undefined;\n\tlet azure: Promise<AzureDevOpsApi | undefined> | undefined;\n\n\tconst build = async <T extends Disposable>(load: () => Promise<T>): Promise<T | undefined> => {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst api = await load();\n\t\t\tdisposables.push(api);\n\t\t\treturn api;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to construct integration API client');\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\treturn {\n\t\tazureWorkItemStates: azureWorkItemStates,\n\t\tazureWorkItemDescriptions: azureWorkItemDescriptions,\n\t\tget github() {\n\t\t\treturn (github ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './github/github.js')).createGitHubApi(ctx),\n\t\t\t));\n\t\t},\n\t\tget gitlab() {\n\t\t\treturn (gitlab ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './gitlab/gitlab.js')).createGitLabApi(ctx),\n\t\t\t));\n\t\t},\n\t\tget gitlabIfBuilt() {\n\t\t\treturn gitlab;\n\t\t},\n\t\tget bitbucket() {\n\t\t\treturn (bitbucket ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './bitbucket/bitbucket.js')).createBitbucketApi(\n\t\t\t\t\tctx,\n\t\t\t\t),\n\t\t\t));\n\t\t},\n\t\tget azure() {\n\t\t\treturn (azure ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './azure/azure.js')).createAzureDevOpsApi(\n\t\t\t\t\tctx,\n\t\t\t\t\tazureWorkItemStates,\n\t\t\t\t\tazureWorkItemDescriptions,\n\t\t\t\t),\n\t\t\t));\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,iBAAiB,KAAgC,aAAuC;CACvG,MAAM,sBAAsB,IAAI,yBAAyB;CACzD,MAAM,4BAA4B,IAAI,+BAA+B;CACrE,YAAY,KACX,IAAI,OAAO,aAAY,MAAK;EAC3B,IAAI,EAAE,WAAW;GAChB,oBAAoB,MAAM;GAC1B,0BAA0B,MAAM;EACjC;CACD,CAAC,GACD,EACC,eAAe;EACd,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;CACjC,EACD,CACD;CACA,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,QAAQ,OAA6B,SAAmD;EAC7F,MAAM,QAAQ,gBAAgB;EAC9B,IAAI;GACH,MAAM,MAAM,MAAM,KAAK;GACvB,YAAY,KAAK,GAAG;GACpB,OAAO;EACR,SAAS,IAAI;GACZ,OAAO,MAAM,IAAI,4CAA4C;GAC7D;EACD;CACD;CAEA,OAAO;EACe;EACM;EAC3B,IAAI,SAAS;GACZ,OAAQ,WAAW,MAAM,aACvB,MAAM;;IAA8C;EAAqB,CAAE,gBAAgB,GAAG,CAChG;EACD;EACA,IAAI,SAAS;GACZ,OAAQ,WAAW,MAAM,aACvB,MAAM;;IAA8C;EAAqB,CAAE,gBAAgB,GAAG,CAChG;EACD;EACA,IAAI,gBAAgB;GACnB,OAAO;EACR;EACA,IAAI,YAAY;GACf,OAAQ,cAAc,MAAM,aAC1B,MAAM;;IAA8C;EAA2B,CAAE,mBACjF,GACD,CACD;EACD;EACA,IAAI,QAAQ;GACX,OAAQ,UAAU,MAAM,aACtB,MAAM;;IAA8C;EAAmB,CAAE,qBACzE,KACA,qBACA,yBACD,CACD;EACD;CACD;AACD"}
1
+ {"version":3,"file":"apiClients.js","names":[],"sources":["../../../../../plus/integrations/src/providers/apiClients.ts"],"sourcesContent":["import type { GitHubApi } from '@gitlens/git-github/api/github.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { AzureDevOpsApi } from './azure/azure.js';\nimport { AzureWorkItemDescriptionsCache } from './azure/workItemDescriptions.js';\nimport { AzureWorkItemStatesCache } from './azure/workItemStateCategories.js';\nimport type { BitbucketApi } from './bitbucket/bitbucket.js';\nimport type { GitLabApi } from './gitlab/gitlab.js';\n\n/**\n * The per-provider API clients, owned and built by the package. `GitLabApi`/`BitbucketApi`/`AzureDevOpsApi`\n * live in the package; `GitHubApi` comes from `@gitlens/git-github` (shared with the host's GitHub git\n * provider, which reads the manager's memoized instance via `manager.github`). `undefined` is tolerated for\n * offline/limited runtimes.\n */\nexport interface ApiClients {\n\treadonly azureWorkItemStates: AzureWorkItemStatesCache;\n\treadonly azureWorkItemDescriptions: AzureWorkItemDescriptionsCache;\n\treadonly github: Promise<GitHubApi | undefined>;\n\treadonly gitlab: Promise<GitLabApi | undefined>;\n\treadonly gitlabIfBuilt?: Promise<GitLabApi | undefined>;\n\treadonly bitbucket: Promise<BitbucketApi | undefined>;\n\treadonly azure: Promise<AzureDevOpsApi | undefined>;\n}\n\n/**\n * Lazily constructs + memoizes the API clients from the runtime context, pushing each to `disposables` for\n * teardown. Mirrors the lazy-chunked construction the host's `Container` did before the package took\n * ownership (the host used to build these and inject them back through the context — a pure round-trip).\n */\nexport function createApiClients(ctx: IntegrationServiceContext, disposables: Disposable[]): ApiClients {\n\tconst azureWorkItemStates = new AzureWorkItemStatesCache();\n\tconst azureWorkItemDescriptions = new AzureWorkItemDescriptionsCache();\n\tdisposables.push(\n\t\tctx.config.onDidChange(e => {\n\t\t\tif (e.httpProxy) {\n\t\t\t\tazureWorkItemStates.clear();\n\t\t\t\tazureWorkItemDescriptions.clear();\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tdispose: () => {\n\t\t\t\tazureWorkItemStates.clear();\n\t\t\t\tazureWorkItemDescriptions.clear();\n\t\t\t},\n\t\t},\n\t);\n\tlet github: Promise<GitHubApi | undefined> | undefined;\n\tlet gitlab: Promise<GitLabApi | undefined> | undefined;\n\tlet bitbucket: Promise<BitbucketApi | undefined> | undefined;\n\tlet azure: Promise<AzureDevOpsApi | undefined> | undefined;\n\n\tconst build = async <T extends Disposable>(load: () => Promise<T>): Promise<T | undefined> => {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst api = await load();\n\t\t\tdisposables.push(api);\n\t\t\treturn api;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to construct integration API client');\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\treturn {\n\t\tazureWorkItemStates: azureWorkItemStates,\n\t\tazureWorkItemDescriptions: azureWorkItemDescriptions,\n\t\tget github() {\n\t\t\treturn (github ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './github/github.js')).createGitHubApi(ctx),\n\t\t\t));\n\t\t},\n\t\tget gitlab() {\n\t\t\treturn (gitlab ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './gitlab/gitlab.js')).createGitLabApi(ctx),\n\t\t\t));\n\t\t},\n\t\tget gitlabIfBuilt() {\n\t\t\treturn gitlab;\n\t\t},\n\t\tget bitbucket() {\n\t\t\treturn (bitbucket ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './bitbucket/bitbucket.js')).createBitbucketApi(\n\t\t\t\t\tctx,\n\t\t\t\t),\n\t\t\t));\n\t\t},\n\t\tget azure() {\n\t\t\treturn (azure ??= build(async () =>\n\t\t\t\t(await import(/* webpackChunkName: \"integrations\" */ './azure/azure.js')).createAzureDevOpsApi(\n\t\t\t\t\tctx,\n\t\t\t\t\tazureWorkItemStates,\n\t\t\t\t\tazureWorkItemDescriptions,\n\t\t\t\t),\n\t\t\t));\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,iBAAiB,KAAgC,aAAuC;CACvG,MAAM,sBAAsB,IAAI,yBAAyB;CACzD,MAAM,4BAA4B,IAAI,+BAA+B;CACrE,YAAY,KACX,IAAI,OAAO,aAAY,MAAK;EAC3B,IAAI,EAAE,WAAW;GAChB,oBAAoB,MAAM;GAC1B,0BAA0B,MAAM;EACjC;CACD,CAAC,GACD,EACC,eAAe;EACd,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;CACjC,EACD,CACD;CACA,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,QAAQ,OAA6B,SAAmD;EAC7F,MAAM,QAAQ,gBAAgB;EAC9B,IAAI;GACH,MAAM,MAAM,MAAM,KAAK;GACvB,YAAY,KAAK,GAAG;GACpB,OAAO;EACR,SAAS,IAAI;GACZ,OAAO,MAAM,IAAI,4CAA4C;GAC7D;EACD;CACD;CAEA,OAAO;EACe;EACM;EAC3B,IAAI,SAAS;GACZ,OAAQ,WAAW,MAAM,aACvB,MAAM;;IAA8C;EAAqB,CAAE,gBAAgB,GAAG,CAChG;EACD;EACA,IAAI,SAAS;GACZ,OAAQ,WAAW,MAAM,aACvB,MAAM;;IAA8C;EAAqB,CAAE,gBAAgB,GAAG,CAChG;EACD;EACA,IAAI,gBAAgB;GACnB,OAAO;EACR;EACA,IAAI,YAAY;GACf,OAAQ,cAAc,MAAM,aAC1B,MAAM;;IAA8C;EAA2B,CAAE,mBACjF,GACD,CACD;EACD;EACA,IAAI,QAAQ;GACX,OAAQ,UAAU,MAAM,aACtB,MAAM;;IAA8C;EAAmB,CAAE,qBACzE,KACA,qBACA,yBACD,CACD;EACD;CACD;AACD"}
@@ -4,10 +4,11 @@ import { Issue, IssueShape } from "../../../git/models/issue.js";
4
4
  import { Account } from "../../../git/models/author.js";
5
5
  import { ProviderAuthenticationSession } from "../authentication/models.js";
6
6
  import { IssuesCloudHostIntegrationId } from "../constants.js";
7
- import { ProviderApiCollectionResult, ProviderMetadata } from "./models.js";
7
+ import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
8
+ import { ProviderMetadata } from "./metadata.js";
8
9
  import { AccountWideIssuesResult, IssuesForProjectOptions, ProjectIssuesDrain, ProjectIssuesRequest, SearchMyIssuesOptions } from "../models/issueReads.js";
9
10
  import { IssuesIntegration } from "../models/issuesIntegration.js";
10
- import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
11
+ import { ProviderApiCollectionResult } from "./models.js";
11
12
  //#region ../plus/integrations/src/providers/asana.d.ts
12
13
  declare const metadata: ProviderMetadata & {
13
14
  id: IssuesCloudHostIntegrationId.Asana;
@@ -5,8 +5,9 @@ import { isIssueResourceDescriptor } from "../../../git/utils/resourceDescriptor
5
5
  import { IntegrationReadUnavailableError, toError } from "../errors.js";
6
6
  import { throwIfCallerContractError, toCollectionScopeFailure } from "../collectionMetadata.js";
7
7
  import { collectProviderPagedResult, mergeCollectionMetadata } from "./utils/providerPaging.js";
8
- import { fromProviderIssue, providersMetadata, toIssueProviderState, toIssueShape, toProviderIssueStates } from "./models.js";
8
+ import { providersMetadata } from "./metadata.js";
9
9
  import { toTokenWithInfo } from "../authentication/models.js";
10
+ import { fromProviderIssue, toIssueProviderState, toIssueShape, toProviderIssueStates } from "./models.js";
10
11
  import { IssuesIntegration, groupProjectIssuesSearches } from "../models/issuesIntegration.js";
11
12
  //#region ../plus/integrations/src/providers/asana.ts
12
13
  const metadata = providersMetadata.asana;
@@ -1 +1 @@
1
- {"version":3,"file":"asana.js","names":[],"sources":["../../../../../plus/integrations/src/providers/asana.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure, IssueProjectMembership } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { Issue, IssueProject, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { throwIfCallerContractError, toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IntegrationReadUnavailableError, toError } from '../errors.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 { ProviderApiCollectionResult, ProviderIssue } from './models.js';\nimport {\n\tfromProviderIssue,\n\tprovidersMetadata,\n\ttoIssueProviderState,\n\ttoIssueShape,\n\ttoProviderIssueStates,\n} from './models.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata.asana;\ntype AsanaIntegrationId = typeof metadata.id;\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n/** Long enough to span one tracker read, short enough that a profile change shows on the next. */\nconst recentAccountTTL = 60 * 1000;\n/** The workspace and project discovery backstop: provider-apis pages them 100 at a time, so 2,000 of each. */\nconst maxDiscoveryPages = 20;\n/** The task drain's backstop, per project or per workspace: 1,000 tasks at the SDK's 100-per-page. */\nconst maxTaskPages = 10;\n\n/** An Asana project, naming the workspace it belongs to so its tasks can be encoded and its account resolved. */\nexport interface AsanaProjectDescriptor extends IssueResourceDescriptor {\n\tresourceId: string;\n\tresourceName: string;\n}\n\nexport class AsanaIntegration extends IssuesIntegration<AsanaIntegrationId> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\n\toverride get id(): AsanaIntegrationId {\n\t\treturn metadata.id;\n\t}\n\tprotected override get key(): 'asana' {\n\t\treturn 'asana';\n\t}\n\toverride get name(): string {\n\t\treturn metadata.name;\n\t}\n\toverride get domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\t/**\n\t * Always asks Asana: the host's current-account cache decides when this runs. An Asana user is the same in every\n\t * workspace, so the answer is lent briefly to the per-workspace lookup a tracker read makes right after it.\n\t */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst account = await this.fetchAccount(session);\n\t\tif (account != null) {\n\t\t\tthis._recentAccounts.set(session.accessToken, Promise.resolve(account));\n\t\t}\n\t\treturn account;\n\t}\n\n\tprotected override getProviderUncachedAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this.fetchAccount(session);\n\t}\n\n\tprotected override getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this._recentAccounts.getOrCreate(session.accessToken, () => this.fetchAccount(session), {\n\t\t\tevictWhen: account => account == null,\n\t\t});\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._recentAccounts.clear();\n\t}\n\n\tprivate readonly _recentAccounts = new PromiseCache<string, Account | undefined>({\n\t\tcapacity: 10,\n\t\tcreateTTL: recentAccountTTL,\n\t});\n\n\tprivate async fetchAccount(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getAsanaCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (user == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: this,\n\t\t\tid: user.id,\n\t\t\tname: user.name ?? undefined,\n\t\t\t// Asana has no usernames; the SDK reports the display name as the handle.\n\t\t\tusername: user.username ?? undefined,\n\t\t\temail: user.email ?? undefined,\n\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t};\n\t}\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<IssueResourceDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst workspaces = await collectProviderPagedResult(\n\t\t\tcursor => api.getAsanaWorkspacesForCurrentUser(tokenWithInfo, { cursor: cursor }),\n\t\t\tmaxDiscoveryPages,\n\t\t);\n\t\t// Resource discovery has no completeness to report, so a user past the backstop is logged rather than refused:\n\t\t// the workspaces read still hold their projects.\n\t\tif (workspaces.truncated) {\n\t\t\tLogger.warn(`Asana workspace discovery stopped after ${workspaces.values.length} workspaces`);\n\t\t}\n\t\treturn workspaces.values.map(w => ({ key: w.id, id: w.id, name: w.name }));\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: ResourceDescriptor[],\n\t): Promise<AsanaProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources)).values;\n\t}\n\n\t/**\n\t * Each workspace's unarchived projects, drained per workspace. A workspace whose drain failed or ran out of pages\n\t * keeps what it read and is recorded in the metadata, so one large or unreadable workspace doesn't hide the rest.\n\t */\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<AsanaProjectDescriptor>> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst values: AsanaProjectDescriptor[] = [];\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tfor (const workspace of resources.filter(isIssueResourceDescriptor)) {\n\t\t\tconst scope: CollectionScopeFailure['scope'] = { providerId: this.id, resourceId: workspace.id };\n\t\t\tconst projects = await collectProviderPagedResult(\n\t\t\t\tcursor => api.getAsanaProjectsForWorkspace(tokenWithInfo, workspace.id, { cursor: cursor }),\n\t\t\t\tmaxDiscoveryPages,\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tvalues.push(\n\t\t\t\t...projects.values.map(p => ({\n\t\t\t\t\tkey: p.id,\n\t\t\t\t\tid: p.id,\n\t\t\t\t\tname: p.name,\n\t\t\t\t\tresourceId: workspace.id,\n\t\t\t\t\tresourceName: workspace.name,\n\t\t\t\t})),\n\t\t\t);\n\t\t\tcollectionMetadata = mergeCollectionMetadata(\n\t\t\t\tcollectionMetadata,\n\t\t\t\tprojects.truncated && !projects.metadata?.failures?.length\n\t\t\t\t\t? mergeCollectionMetadata(projects.metadata, {\n\t\t\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\t\t\tomissions: [{ kind: 'pagination-incomplete', scope: scope }],\n\t\t\t\t\t\t})\n\t\t\t\t\t: projects.metadata,\n\t\t\t);\n\t\t}\n\n\t\treturn collectionMetadata != null ? { values: values, metadata: collectionMetadata } : { values: values };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\t/**\n\t * A project's tasks, narrowed to the viewer's by assignee after the drain: Asana's task list takes a project or\n\t * an assignee, never both. So a user-scoped read of a busy project spends its page budget on other people's\n\t * tasks, and a truncated one can't be recovered by a narrower scope.\n\t */\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tif (!isAsanaProjectDescriptor(project)) return undefined;\n\n\t\tlet viewerId: string | undefined;\n\t\tif (options?.user != null) {\n\t\t\tviewerId = options.userId ?? (await this.getProviderAccountForResource(session, project))?.id;\n\t\t\t// Without the viewer the read can't be scoped to \"my issues\": the unfiltered project would leak everyone\n\t\t\t// else's tasks, and an empty list would read as \"nothing assigned to me\".\n\t\t\tif (viewerId == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\t\tmetadata.name,\n\t\t\t\t\t'could not resolve the current user to scope issues to',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst drain = await this.drainTasks(session, { projectId: project.id }, options, {\n\t\t\tproviderId: this.id,\n\t\t\tresourceId: project.resourceId,\n\t\t\tprojectId: project.id,\n\t\t});\n\n\t\tconst issueProject = toIssueProject(project);\n\t\tconst values = drain.values.flatMap(issue => {\n\t\t\tif (viewerId != null && !issue.assignees.some(a => a.id === viewerId)) return [];\n\n\t\t\tconst shape = toIssueShape(issue, this, { projection: 'project' });\n\t\t\treturn shape == null ? [] : [{ ...shape, project: issueProject } satisfies IssueShape];\n\t\t});\n\n\t\treturn drain.truncated\n\t\t\t? { values: values, truncated: true, recovery: 'none', metadata: drain.metadata }\n\t\t\t: { values: values, truncated: false, metadata: drain.metadata };\n\t}\n\n\t/**\n\t * Searches every project of one workspace together when the read is scoped to the viewer: Asana's \"my tasks\" read\n\t * takes the workspace and the assignee, so one drain answers all of them, where reading project by project would\n\t * drain every task of every project only to keep the viewer's.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(requests, ({ project, options }) =>\n\t\t\toptions.user != null && isAsanaProjectDescriptor(project)\n\t\t\t\t? [\n\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t].join('\\0')\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\t/**\n\t * The viewer's tasks in one workspace, split into the requested projects. A task outside them (in another project,\n\t * or in none, only in the user's My Tasks) belongs to no project of this read and is left out.\n\t *\n\t * A task can be in several projects (a sprint board and each customer's own board, say), and an unscoped task read\n\t * reports only the first one Asana lists as its `project`. So it is filed under every requested project among its\n\t * memberships (`projectMemberships`), with its section in that project as its state, as the per-project fallback\n\t * would list it.\n\t */\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\tconst projects = requests.map(request => request.project).filter(isAsanaProjectDescriptor);\n\t\tif (projects.length !== requests.length) return undefined;\n\n\t\t// Every request of a search shares the workspace and every option read here (see `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tconst drain = await this.drainTasks(\n\t\t\tsession,\n\t\t\t{ workspaceId: projects[0].resourceId },\n\t\t\toptions,\n\t\t\t// Never published: an incomplete search is read again project by project, which records its own failures.\n\t\t\t{ providerId: this.id, resourceId: projects[0].resourceId },\n\t\t);\n\t\t// An incomplete search says nothing about which of its projects it covered, so only the per-project reads can\n\t\t// report each one's completeness.\n\t\tif (drain.truncated || (drain.metadata != null && drain.metadata.completeness !== 'complete')) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst indexById = new Map(projects.map((project, index) => [project.id, index]));\n\t\tconst split = projects.map((): IssueShape[] => []);\n\t\tfor (const task of drain.values) {\n\t\t\tconst shape = toIssueShape(task, this, { projection: 'project' });\n\t\t\tif (shape == null) continue;\n\n\t\t\t// Only the section differs between a task's projects: whether it is closed is the task's own.\n\t\t\tfor (const { index, state } of toRequestedProjectPlacements(task, indexById)) {\n\t\t\t\tsplit[index].push({\n\t\t\t\t\t...shape,\n\t\t\t\t\tproject: toIssueProject(projects[index]),\n\t\t\t\t\tproviderState: toIssueProviderState(state),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn split;\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * The tasks assigned to the viewer, one drain per workspace (Asana requires the workspace alongside the\n\t * assignee). Reads every workspace the user belongs to unless `resources` names some. A workspace that can't be\n\t * read is recorded in the metadata and the others are still returned; only when none could be read does the read\n\t * throw. Cancellation stops between workspaces and is not reported as truncation: the caller asked for the read to\n\t * stop.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst workspaces = (resources ?? (await this.getProviderResourcesForUser(session)) ?? []).filter(\n\t\t\tisIssueResourceDescriptor,\n\t\t);\n\n\t\tconst values: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tlet firstError: Error | undefined;\n\t\tlet workspacesRead = 0;\n\t\tfor (const workspace of workspaces) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst scope: CollectionScopeFailure['scope'] = { providerId: this.id, resourceId: workspace.id };\n\t\t\tlet drain: Awaited<ReturnType<AsanaIntegration['drainTasks']>>;\n\t\t\ttry {\n\t\t\t\tdrain = await this.drainTasks(session, { workspaceId: workspace.id }, options, scope);\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\tthrowIfCallerContractError(ex);\n\n\t\t\t\tfirstError ??= toError(ex);\n\t\t\t\ttruncated = true;\n\t\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [toCollectionScopeFailure(scope, ex)],\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tworkspacesRead++;\n\t\t\ttruncated ||= drain.truncated;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, drain.metadata);\n\t\t\tfor (const issue of drain.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'account' });\n\t\t\t\tif (shape != null) {\n\t\t\t\t\tvalues.push({ ...shape, project: toAsanaIssueProject(issue, workspace) });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Every workspace failed: an empty \"my issues\" would read as \"nothing assigned to me\".\n\t\tif (workspacesRead === 0 && firstError != null) throw firstError;\n\n\t\treturn { values: values, truncated: truncated, metadata: collectionMetadata };\n\t}\n\n\t/**\n\t * Follows a task read's cursor up to {@link maxTaskPages}. `truncated` is set when the backstop stopped it with\n\t * pages left, or when a page after the first failed (recorded under `scope`, keeping the prefix). A failure on the\n\t * first page throws, so the caller sees an error rather than an empty success.\n\t */\n\tprivate async drainTasks(\n\t\tsession: ProviderAuthenticationSession,\n\t\tread: { projectId: string } | { workspaceId: string },\n\t\toptions: Pick<IssuesForProjectOptions, 'state' | 'sort'> | undefined,\n\t\tscope: CollectionScopeFailure['scope'],\n\t): Promise<{ values: ProviderIssue[]; truncated: boolean; metadata?: CollectionMetadata }> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tlet pagesRead = 0;\n\t\tlet firstPageError: Error | undefined;\n\t\tconst drain = await collectProviderPagedResult(\n\t\t\tasync cursor => {\n\t\t\t\tconst pageOptions = { cursor: cursor, states: states, sort: options?.sort };\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await ('projectId' in read\n\t\t\t\t\t\t? api.getAsanaIssuesForProject(tokenWithInfo, read.projectId, pageOptions)\n\t\t\t\t\t\t: api.getAsanaIssuesForCurrentUser(tokenWithInfo, read.workspaceId, pageOptions));\n\t\t\t\t\tpagesRead++;\n\t\t\t\t\treturn page;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (pagesRead === 0) {\n\t\t\t\t\t\tfirstPageError = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\tmaxTaskPages,\n\t\t\tscope,\n\t\t);\n\t\tif (firstPageError != null) throw firstPageError;\n\n\t\treturn { values: drain.values, truncated: drain.truncated === true, metadata: drain.metadata };\n\t}\n\n\tprotected override getProviderLinkedIssueOrPullRequest(\n\t\t_session: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t\t_id: { id: string; key: string },\n\t\t_type: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\t// Asana task references are gids in a permalink URL, never a short key a commit message would carry.\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/** `resource` is the task's workspace; `id` is the task gid, which is also what an Asana issue reports as its id. */\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tif (!isIssueResourceDescriptor(resource)) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getAsanaIssue(toTokenWithInfo(this.id, session), id);\n\t\treturn issue != null\n\t\t\t? fromProviderIssue(issue, this, { projection: 'point', project: toAsanaIssueProject(issue, resource) })\n\t\t\t: undefined;\n\t}\n}\n\nfunction isAsanaProjectDescriptor(project: ResourceDescriptor): project is AsanaProjectDescriptor {\n\treturn isIssueResourceDescriptor(project) && typeof project.resourceId === 'string';\n}\n\n/**\n * Each requested project a task is in, by its index in the read, with the task's state as that project would list it:\n * its section there, since the unscoped read reports the first membership's.\n */\nfunction toRequestedProjectPlacements(\n\tissue: ProviderIssue,\n\tindexById: ReadonlyMap<string, number>,\n): { index: number; state: ProviderIssue['state'] }[] {\n\tconst memberships = issue.projectMemberships;\n\tif (memberships == null) {\n\t\tconst index = issue.project?.id != null ? indexById.get(issue.project.id) : undefined;\n\t\treturn index != null ? [{ index: index, state: issue.state }] : [];\n\t}\n\n\tconst placements: { index: number; state: ProviderIssue['state'] }[] = [];\n\tfor (const membership of memberships) {\n\t\tconst index = indexById.get(membership.project.id);\n\t\tif (index == null || placements.some(p => p.index === index)) continue;\n\n\t\tplacements.push({ index: index, state: getProjectMembershipState(issue, membership) });\n\t}\n\treturn placements;\n}\n\n/**\n * Mirrors provider-apis' state for a task read scoped to the membership's project; the parity test in `asana.test.ts`\n * runs both through provider-apis' own normalization to keep them agreeing.\n */\nfunction getProjectMembershipState(issue: ProviderIssue, membership: IssueProjectMembership): ProviderIssue['state'] {\n\tif (issue.project?.id === membership.project.id) return issue.state;\n\n\tconst completed = issue.closedDate != null;\n\tif (membership.section != null) {\n\t\treturn {\n\t\t\tid: membership.section.id,\n\t\t\tname: membership.section.name,\n\t\t\tcolor: null,\n\t\t\t...(completed ? { category: 'DONE' as const } : {}),\n\t\t};\n\t}\n\treturn completed ? { name: 'Completed', color: null, category: 'DONE' } : null;\n}\n\nfunction toIssueProject(project: AsanaProjectDescriptor): IssueProject {\n\treturn { id: project.id, name: project.name, resourceId: project.resourceId, resourceName: project.resourceName };\n}\n\n/**\n * The project an issue read outside a project reports. An Asana issue entity identifier is keyed by the task's\n * workspace, which the SDK reports beside the project rather than in it, so this always names the workspace as the\n * resource. A task in no project (only in someone's My Tasks) reports the workspace as its project too, so its\n * branch associations stay round-trippable.\n */\nfunction toAsanaIssueProject(issue: ProviderIssue, workspace: IssueResourceDescriptor): IssueProject {\n\tconst resourceId = issue.workspaceId ?? workspace.id;\n\tconst resourceName = resourceId === workspace.id ? workspace.name : '';\n\treturn issue.project?.id != null\n\t\t? { id: issue.project.id, name: issue.project.name, resourceId: resourceId, resourceName: resourceName }\n\t\t: { id: resourceId, name: resourceName, resourceId: resourceId, resourceName: resourceName };\n}\n"],"mappings":";;;;;;;;;;;AAgCA,MAAM,WAAW,kBAAkB;AAEnC,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;;AAE/E,MAAM,mBAAmB;;AAEzB,MAAM,oBAAoB;;AAE1B,MAAM,eAAe;AAQrB,IAAa,mBAAb,cAAsC,kBAAsC;CAC3E,eAAqE;CAErE,IAAa,KAAyB;EACrC,OAAO,SAAS;CACjB;CACA,IAAuB,MAAe;EACrC,OAAO;CACR;CACA,IAAa,OAAe;EAC3B,OAAO,SAAS;CACjB;CACA,IAAa,SAAiB;EAC7B,OAAO,SAAS;CACjB;;;;;CAMA,MAAyB,0BACxB,SAC+B;EAC/B,MAAM,UAAU,MAAM,KAAK,aAAa,OAAO;EAC/C,IAAI,WAAW,MACd,KAAK,gBAAgB,IAAI,QAAQ,aAAa,QAAQ,QAAQ,OAAO,CAAC;EAEvE,OAAO;CACR;CAEA,sCACC,SACA,WAC+B;EAC/B,OAAO,KAAK,aAAa,OAAO;CACjC;CAEA,8BACC,SACA,WAC+B;EAC/B,OAAO,KAAK,gBAAgB,YAAY,QAAQ,mBAAmB,KAAK,aAAa,OAAO,GAAG,EAC9F,YAAW,YAAW,WAAW,KAClC,CAAC;CACF;CAEA,uBAAgD;EAC/C,KAAK,gBAAgB,MAAM;CAC5B;CAEA,kBAAmC,IAAI,aAA0C;EAChF,UAAU;EACV,WAAW;CACZ,CAAC;CAED,MAAc,aAAa,SAAsE;EAEhG,MAAM,OAAO,OAAM,MADD,KAAK,gBAAgB,EAAA,CAChB,oBAA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GAAS;GAAO,OAAO,MAAM;EAAM,CAAC,IAAI,CAAC;CAClE;CAEA,MAAM,aAAiE,CAAC;CACxE,KAAK,MAAM,cAAc,aAAa;EACrC,MAAM,QAAQ,UAAU,IAAI,WAAW,QAAQ,EAAE;EACjD,IAAI,SAAS,QAAQ,WAAW,MAAK,MAAK,EAAE,UAAU,KAAK,GAAG;EAE9D,WAAW,KAAK;GAAS;GAAO,OAAO,0BAA0B,OAAO,UAAU;EAAE,CAAC;CACtF;CACA,OAAO;AACR;;;;;AAMA,SAAS,0BAA0B,OAAsB,YAA4D;CACpH,IAAI,MAAM,SAAS,OAAO,WAAW,QAAQ,IAAI,OAAO,MAAM;CAE9D,MAAM,YAAY,MAAM,cAAc;CACtC,IAAI,WAAW,WAAW,MACzB,OAAO;EACN,IAAI,WAAW,QAAQ;EACvB,MAAM,WAAW,QAAQ;EACzB,OAAO;EACP,GAAI,YAAY,EAAE,UAAU,OAAgB,IAAI,CAAC;CAClD;CAED,OAAO,YAAY;EAAE,MAAM;EAAa,OAAO;EAAM,UAAU;CAAO,IAAI;AAC3E;AAEA,SAAS,eAAe,SAA+C;CACtE,OAAO;EAAE,IAAI,QAAQ;EAAI,MAAM,QAAQ;EAAM,YAAY,QAAQ;EAAY,cAAc,QAAQ;CAAa;AACjH;;;;;;;AAQA,SAAS,oBAAoB,OAAsB,WAAkD;CACpG,MAAM,aAAa,MAAM,eAAe,UAAU;CAClD,MAAM,eAAe,eAAe,UAAU,KAAK,UAAU,OAAO;CACpE,OAAO,MAAM,SAAS,MAAM,OACzB;EAAE,IAAI,MAAM,QAAQ;EAAI,MAAM,MAAM,QAAQ;EAAkB;EAA0B;CAAa,IACrG;EAAE,IAAI;EAAY,MAAM;EAA0B;EAA0B;CAAa;AAC7F"}
1
+ {"version":3,"file":"asana.js","names":[],"sources":["../../../../../plus/integrations/src/providers/asana.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure, IssueProjectMembership } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { Issue, IssueProject, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { throwIfCallerContractError, toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IntegrationReadUnavailableError, toError } from '../errors.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 { providersMetadata } from './metadata.js';\nimport type { ProviderApiCollectionResult, ProviderIssue } from './models.js';\nimport { fromProviderIssue, toIssueProviderState, toIssueShape, toProviderIssueStates } from './models.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata.asana;\ntype AsanaIntegrationId = typeof metadata.id;\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n/** Long enough to span one tracker read, short enough that a profile change shows on the next. */\nconst recentAccountTTL = 60 * 1000;\n/** The workspace and project discovery backstop: provider-apis pages them 100 at a time, so 2,000 of each. */\nconst maxDiscoveryPages = 20;\n/** The task drain's backstop, per project or per workspace: 1,000 tasks at the SDK's 100-per-page. */\nconst maxTaskPages = 10;\n\n/** An Asana project, naming the workspace it belongs to so its tasks can be encoded and its account resolved. */\nexport interface AsanaProjectDescriptor extends IssueResourceDescriptor {\n\tresourceId: string;\n\tresourceName: string;\n}\n\nexport class AsanaIntegration extends IssuesIntegration<AsanaIntegrationId> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\n\toverride get id(): AsanaIntegrationId {\n\t\treturn metadata.id;\n\t}\n\tprotected override get key(): 'asana' {\n\t\treturn 'asana';\n\t}\n\toverride get name(): string {\n\t\treturn metadata.name;\n\t}\n\toverride get domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\t/**\n\t * Always asks Asana: the host's current-account cache decides when this runs. An Asana user is the same in every\n\t * workspace, so the answer is lent briefly to the per-workspace lookup a tracker read makes right after it.\n\t */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst account = await this.fetchAccount(session);\n\t\tif (account != null) {\n\t\t\tthis._recentAccounts.set(session.accessToken, Promise.resolve(account));\n\t\t}\n\t\treturn account;\n\t}\n\n\tprotected override getProviderUncachedAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this.fetchAccount(session);\n\t}\n\n\tprotected override getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this._recentAccounts.getOrCreate(session.accessToken, () => this.fetchAccount(session), {\n\t\t\tevictWhen: account => account == null,\n\t\t});\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._recentAccounts.clear();\n\t}\n\n\tprivate readonly _recentAccounts = new PromiseCache<string, Account | undefined>({\n\t\tcapacity: 10,\n\t\tcreateTTL: recentAccountTTL,\n\t});\n\n\tprivate async fetchAccount(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getAsanaCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (user == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: this,\n\t\t\tid: user.id,\n\t\t\tname: user.name ?? undefined,\n\t\t\t// Asana has no usernames; the SDK reports the display name as the handle.\n\t\t\tusername: user.username ?? undefined,\n\t\t\temail: user.email ?? undefined,\n\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t};\n\t}\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<IssueResourceDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst workspaces = await collectProviderPagedResult(\n\t\t\tcursor => api.getAsanaWorkspacesForCurrentUser(tokenWithInfo, { cursor: cursor }),\n\t\t\tmaxDiscoveryPages,\n\t\t);\n\t\t// Resource discovery has no completeness to report, so a user past the backstop is logged rather than refused:\n\t\t// the workspaces read still hold their projects.\n\t\tif (workspaces.truncated) {\n\t\t\tLogger.warn(`Asana workspace discovery stopped after ${workspaces.values.length} workspaces`);\n\t\t}\n\t\treturn workspaces.values.map(w => ({ key: w.id, id: w.id, name: w.name }));\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: ResourceDescriptor[],\n\t): Promise<AsanaProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources)).values;\n\t}\n\n\t/**\n\t * Each workspace's unarchived projects, drained per workspace. A workspace whose drain failed or ran out of pages\n\t * keeps what it read and is recorded in the metadata, so one large or unreadable workspace doesn't hide the rest.\n\t */\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<AsanaProjectDescriptor>> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst values: AsanaProjectDescriptor[] = [];\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tfor (const workspace of resources.filter(isIssueResourceDescriptor)) {\n\t\t\tconst scope: CollectionScopeFailure['scope'] = { providerId: this.id, resourceId: workspace.id };\n\t\t\tconst projects = await collectProviderPagedResult(\n\t\t\t\tcursor => api.getAsanaProjectsForWorkspace(tokenWithInfo, workspace.id, { cursor: cursor }),\n\t\t\t\tmaxDiscoveryPages,\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tvalues.push(\n\t\t\t\t...projects.values.map(p => ({\n\t\t\t\t\tkey: p.id,\n\t\t\t\t\tid: p.id,\n\t\t\t\t\tname: p.name,\n\t\t\t\t\tresourceId: workspace.id,\n\t\t\t\t\tresourceName: workspace.name,\n\t\t\t\t})),\n\t\t\t);\n\t\t\tcollectionMetadata = mergeCollectionMetadata(\n\t\t\t\tcollectionMetadata,\n\t\t\t\tprojects.truncated && !projects.metadata?.failures?.length\n\t\t\t\t\t? mergeCollectionMetadata(projects.metadata, {\n\t\t\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\t\t\tomissions: [{ kind: 'pagination-incomplete', scope: scope }],\n\t\t\t\t\t\t})\n\t\t\t\t\t: projects.metadata,\n\t\t\t);\n\t\t}\n\n\t\treturn collectionMetadata != null ? { values: values, metadata: collectionMetadata } : { values: values };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\t/**\n\t * A project's tasks, narrowed to the viewer's by assignee after the drain: Asana's task list takes a project or\n\t * an assignee, never both. So a user-scoped read of a busy project spends its page budget on other people's\n\t * tasks, and a truncated one can't be recovered by a narrower scope.\n\t */\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tif (!isAsanaProjectDescriptor(project)) return undefined;\n\n\t\tlet viewerId: string | undefined;\n\t\tif (options?.user != null) {\n\t\t\tviewerId = options.userId ?? (await this.getProviderAccountForResource(session, project))?.id;\n\t\t\t// Without the viewer the read can't be scoped to \"my issues\": the unfiltered project would leak everyone\n\t\t\t// else's tasks, and an empty list would read as \"nothing assigned to me\".\n\t\t\tif (viewerId == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\t\tmetadata.name,\n\t\t\t\t\t'could not resolve the current user to scope issues to',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst drain = await this.drainTasks(session, { projectId: project.id }, options, {\n\t\t\tproviderId: this.id,\n\t\t\tresourceId: project.resourceId,\n\t\t\tprojectId: project.id,\n\t\t});\n\n\t\tconst issueProject = toIssueProject(project);\n\t\tconst values = drain.values.flatMap(issue => {\n\t\t\tif (viewerId != null && !issue.assignees.some(a => a.id === viewerId)) return [];\n\n\t\t\tconst shape = toIssueShape(issue, this, { projection: 'project' });\n\t\t\treturn shape == null ? [] : [{ ...shape, project: issueProject } satisfies IssueShape];\n\t\t});\n\n\t\treturn drain.truncated\n\t\t\t? { values: values, truncated: true, recovery: 'none', metadata: drain.metadata }\n\t\t\t: { values: values, truncated: false, metadata: drain.metadata };\n\t}\n\n\t/**\n\t * Searches every project of one workspace together when the read is scoped to the viewer: Asana's \"my tasks\" read\n\t * takes the workspace and the assignee, so one drain answers all of them, where reading project by project would\n\t * drain every task of every project only to keep the viewer's.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(requests, ({ project, options }) =>\n\t\t\toptions.user != null && isAsanaProjectDescriptor(project)\n\t\t\t\t? [\n\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t].join('\\0')\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\t/**\n\t * The viewer's tasks in one workspace, split into the requested projects. A task outside them (in another project,\n\t * or in none, only in the user's My Tasks) belongs to no project of this read and is left out.\n\t *\n\t * A task can be in several projects (a sprint board and each customer's own board, say), and an unscoped task read\n\t * reports only the first one Asana lists as its `project`. So it is filed under every requested project among its\n\t * memberships (`projectMemberships`), with its section in that project as its state, as the per-project fallback\n\t * would list it.\n\t */\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\tconst projects = requests.map(request => request.project).filter(isAsanaProjectDescriptor);\n\t\tif (projects.length !== requests.length) return undefined;\n\n\t\t// Every request of a search shares the workspace and every option read here (see `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tconst drain = await this.drainTasks(\n\t\t\tsession,\n\t\t\t{ workspaceId: projects[0].resourceId },\n\t\t\toptions,\n\t\t\t// Never published: an incomplete search is read again project by project, which records its own failures.\n\t\t\t{ providerId: this.id, resourceId: projects[0].resourceId },\n\t\t);\n\t\t// An incomplete search says nothing about which of its projects it covered, so only the per-project reads can\n\t\t// report each one's completeness.\n\t\tif (drain.truncated || (drain.metadata != null && drain.metadata.completeness !== 'complete')) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst indexById = new Map(projects.map((project, index) => [project.id, index]));\n\t\tconst split = projects.map((): IssueShape[] => []);\n\t\tfor (const task of drain.values) {\n\t\t\tconst shape = toIssueShape(task, this, { projection: 'project' });\n\t\t\tif (shape == null) continue;\n\n\t\t\t// Only the section differs between a task's projects: whether it is closed is the task's own.\n\t\t\tfor (const { index, state } of toRequestedProjectPlacements(task, indexById)) {\n\t\t\t\tsplit[index].push({\n\t\t\t\t\t...shape,\n\t\t\t\t\tproject: toIssueProject(projects[index]),\n\t\t\t\t\tproviderState: toIssueProviderState(state),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn split;\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * The tasks assigned to the viewer, one drain per workspace (Asana requires the workspace alongside the\n\t * assignee). Reads every workspace the user belongs to unless `resources` names some. A workspace that can't be\n\t * read is recorded in the metadata and the others are still returned; only when none could be read does the read\n\t * throw. Cancellation stops between workspaces and is not reported as truncation: the caller asked for the read to\n\t * stop.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst workspaces = (resources ?? (await this.getProviderResourcesForUser(session)) ?? []).filter(\n\t\t\tisIssueResourceDescriptor,\n\t\t);\n\n\t\tconst values: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tlet firstError: Error | undefined;\n\t\tlet workspacesRead = 0;\n\t\tfor (const workspace of workspaces) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst scope: CollectionScopeFailure['scope'] = { providerId: this.id, resourceId: workspace.id };\n\t\t\tlet drain: Awaited<ReturnType<AsanaIntegration['drainTasks']>>;\n\t\t\ttry {\n\t\t\t\tdrain = await this.drainTasks(session, { workspaceId: workspace.id }, options, scope);\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\tthrowIfCallerContractError(ex);\n\n\t\t\t\tfirstError ??= toError(ex);\n\t\t\t\ttruncated = true;\n\t\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [toCollectionScopeFailure(scope, ex)],\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tworkspacesRead++;\n\t\t\ttruncated ||= drain.truncated;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, drain.metadata);\n\t\t\tfor (const issue of drain.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'account' });\n\t\t\t\tif (shape != null) {\n\t\t\t\t\tvalues.push({ ...shape, project: toAsanaIssueProject(issue, workspace) });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Every workspace failed: an empty \"my issues\" would read as \"nothing assigned to me\".\n\t\tif (workspacesRead === 0 && firstError != null) throw firstError;\n\n\t\treturn { values: values, truncated: truncated, metadata: collectionMetadata };\n\t}\n\n\t/**\n\t * Follows a task read's cursor up to {@link maxTaskPages}. `truncated` is set when the backstop stopped it with\n\t * pages left, or when a page after the first failed (recorded under `scope`, keeping the prefix). A failure on the\n\t * first page throws, so the caller sees an error rather than an empty success.\n\t */\n\tprivate async drainTasks(\n\t\tsession: ProviderAuthenticationSession,\n\t\tread: { projectId: string } | { workspaceId: string },\n\t\toptions: Pick<IssuesForProjectOptions, 'state' | 'sort'> | undefined,\n\t\tscope: CollectionScopeFailure['scope'],\n\t): Promise<{ values: ProviderIssue[]; truncated: boolean; metadata?: CollectionMetadata }> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tlet pagesRead = 0;\n\t\tlet firstPageError: Error | undefined;\n\t\tconst drain = await collectProviderPagedResult(\n\t\t\tasync cursor => {\n\t\t\t\tconst pageOptions = { cursor: cursor, states: states, sort: options?.sort };\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await ('projectId' in read\n\t\t\t\t\t\t? api.getAsanaIssuesForProject(tokenWithInfo, read.projectId, pageOptions)\n\t\t\t\t\t\t: api.getAsanaIssuesForCurrentUser(tokenWithInfo, read.workspaceId, pageOptions));\n\t\t\t\t\tpagesRead++;\n\t\t\t\t\treturn page;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (pagesRead === 0) {\n\t\t\t\t\t\tfirstPageError = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\tmaxTaskPages,\n\t\t\tscope,\n\t\t);\n\t\tif (firstPageError != null) throw firstPageError;\n\n\t\treturn { values: drain.values, truncated: drain.truncated === true, metadata: drain.metadata };\n\t}\n\n\tprotected override getProviderLinkedIssueOrPullRequest(\n\t\t_session: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t\t_id: { id: string; key: string },\n\t\t_type: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\t// Asana task references are gids in a permalink URL, never a short key a commit message would carry.\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/** `resource` is the task's workspace; `id` is the task gid, which is also what an Asana issue reports as its id. */\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tif (!isIssueResourceDescriptor(resource)) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getAsanaIssue(toTokenWithInfo(this.id, session), id);\n\t\treturn issue != null\n\t\t\t? fromProviderIssue(issue, this, { projection: 'point', project: toAsanaIssueProject(issue, resource) })\n\t\t\t: undefined;\n\t}\n}\n\nfunction isAsanaProjectDescriptor(project: ResourceDescriptor): project is AsanaProjectDescriptor {\n\treturn isIssueResourceDescriptor(project) && typeof project.resourceId === 'string';\n}\n\n/**\n * Each requested project a task is in, by its index in the read, with the task's state as that project would list it:\n * its section there, since the unscoped read reports the first membership's.\n */\nfunction toRequestedProjectPlacements(\n\tissue: ProviderIssue,\n\tindexById: ReadonlyMap<string, number>,\n): { index: number; state: ProviderIssue['state'] }[] {\n\tconst memberships = issue.projectMemberships;\n\tif (memberships == null) {\n\t\tconst index = issue.project?.id != null ? indexById.get(issue.project.id) : undefined;\n\t\treturn index != null ? [{ index: index, state: issue.state }] : [];\n\t}\n\n\tconst placements: { index: number; state: ProviderIssue['state'] }[] = [];\n\tfor (const membership of memberships) {\n\t\tconst index = indexById.get(membership.project.id);\n\t\tif (index == null || placements.some(p => p.index === index)) continue;\n\n\t\tplacements.push({ index: index, state: getProjectMembershipState(issue, membership) });\n\t}\n\treturn placements;\n}\n\n/**\n * Mirrors provider-apis' state for a task read scoped to the membership's project; the parity test in `asana.test.ts`\n * runs both through provider-apis' own normalization to keep them agreeing.\n */\nfunction getProjectMembershipState(issue: ProviderIssue, membership: IssueProjectMembership): ProviderIssue['state'] {\n\tif (issue.project?.id === membership.project.id) return issue.state;\n\n\tconst completed = issue.closedDate != null;\n\tif (membership.section != null) {\n\t\treturn {\n\t\t\tid: membership.section.id,\n\t\t\tname: membership.section.name,\n\t\t\tcolor: null,\n\t\t\t...(completed ? { category: 'DONE' as const } : {}),\n\t\t};\n\t}\n\treturn completed ? { name: 'Completed', color: null, category: 'DONE' } : null;\n}\n\nfunction toIssueProject(project: AsanaProjectDescriptor): IssueProject {\n\treturn { id: project.id, name: project.name, resourceId: project.resourceId, resourceName: project.resourceName };\n}\n\n/**\n * The project an issue read outside a project reports. An Asana issue entity identifier is keyed by the task's\n * workspace, which the SDK reports beside the project rather than in it, so this always names the workspace as the\n * resource. A task in no project (only in someone's My Tasks) reports the workspace as its project too, so its\n * branch associations stay round-trippable.\n */\nfunction toAsanaIssueProject(issue: ProviderIssue, workspace: IssueResourceDescriptor): IssueProject {\n\tconst resourceId = issue.workspaceId ?? workspace.id;\n\tconst resourceName = resourceId === workspace.id ? workspace.name : '';\n\treturn issue.project?.id != null\n\t\t? { id: issue.project.id, name: issue.project.name, resourceId: resourceId, resourceName: resourceName }\n\t\t: { id: resourceId, name: resourceName, resourceId: resourceId, resourceName: resourceName };\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,WAAW,kBAAkB;AAEnC,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;;AAE/E,MAAM,mBAAmB;;AAEzB,MAAM,oBAAoB;;AAE1B,MAAM,eAAe;AAQrB,IAAa,mBAAb,cAAsC,kBAAsC;CAC3E,eAAqE;CAErE,IAAa,KAAyB;EACrC,OAAO,SAAS;CACjB;CACA,IAAuB,MAAe;EACrC,OAAO;CACR;CACA,IAAa,OAAe;EAC3B,OAAO,SAAS;CACjB;CACA,IAAa,SAAiB;EAC7B,OAAO,SAAS;CACjB;;;;;CAMA,MAAyB,0BACxB,SAC+B;EAC/B,MAAM,UAAU,MAAM,KAAK,aAAa,OAAO;EAC/C,IAAI,WAAW,MACd,KAAK,gBAAgB,IAAI,QAAQ,aAAa,QAAQ,QAAQ,OAAO,CAAC;EAEvE,OAAO;CACR;CAEA,sCACC,SACA,WAC+B;EAC/B,OAAO,KAAK,aAAa,OAAO;CACjC;CAEA,8BACC,SACA,WAC+B;EAC/B,OAAO,KAAK,gBAAgB,YAAY,QAAQ,mBAAmB,KAAK,aAAa,OAAO,GAAG,EAC9F,YAAW,YAAW,WAAW,KAClC,CAAC;CACF;CAEA,uBAAgD;EAC/C,KAAK,gBAAgB,MAAM;CAC5B;CAEA,kBAAmC,IAAI,aAA0C;EAChF,UAAU;EACV,WAAW;CACZ,CAAC;CAED,MAAc,aAAa,SAAsE;EAEhG,MAAM,OAAO,OAAM,MADD,KAAK,gBAAgB,EAAA,CAChB,oBAAoB,gBAAgB,KAAK,IAAI,OAAO,CAAC;EAC5E,IAAI,QAAQ,MAAM,OAAO,KA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E,CAAC;CACxE,KAAK,MAAM,cAAc,aAAa;EACrC,MAAM,QAAQ,UAAU,IAAI,WAAW,QAAQ,EAAE;EACjD,IAAI,SAAS,QAAQ,WAAW,MAAK,MAAK,EAAE,UAAU,KAAK,GAAG;EAE9D,WAAW,KAAK;GAAS;GAAO,OAAO,0BAA0B,OAAO,UAAU;EAAE,CAAC;CACtF;CACA,OAAO;AACR;;;;;AAMA,SAAS,0BAA0B,OAAsB,YAA4D;CACpH,IAAI,MAAM,SAAS,OAAO,WAAW,QAAQ,IAAI,OAAO,MAAM;CAE9D,MAAM,YAAY,MAAM,cAAc;CACtC,IAAI,WAAW,WAAW,MACzB,OAAO;EACN,IAAI,WAAW,QAAQ;EACvB,MAAM,WAAW,QAAQ;EACzB,OAAO;EACP,GAAI,YAAY,EAAE,UAAU,OAAgB,IAAI,CAAC;CAClD;CAED,OAAO,YAAY;EAAE,MAAM;EAAa,OAAO;EAAM,UAAU;CAAO,IAAI;AAC3E;AAEA,SAAS,eAAe,SAA+C;CACtE,OAAO;EAAE,IAAI,QAAQ;EAAI,MAAM,QAAQ;EAAM,YAAY,QAAQ;EAAY,cAAc,QAAQ;CAAa;AACjH;;;;;;;AAQA,SAAS,oBAAoB,OAAsB,WAAkD;CACpG,MAAM,aAAa,MAAM,eAAe,UAAU;CAClD,MAAM,eAAe,eAAe,UAAU,KAAK,UAAU,OAAO;CACpE,OAAO,MAAM,SAAS,MAAM,OACzB;EAAE,IAAI,MAAM,QAAQ;EAAI,MAAM,MAAM,QAAQ;EAAkB;EAA0B;CAAa,IACrG;EAAE,IAAI;EAAY,MAAM;EAA0B;EAA0B;CAAa;AAC7F"}
@@ -7,12 +7,12 @@ import { UnidentifiedAuthor } from "../../../../git/models/author.js";
7
7
  import { DefaultBranch } from "../../../../git/models/defaultBranch.js";
8
8
  import { RepositoryMetadata } from "../../../../git/models/repositoryMetadata.js";
9
9
  import { TokenWithInfo } from "../../authentication/models.js";
10
+ import { IntegrationServiceContext } from "../../context.js";
10
11
  import { AzureProjectDescriptor, AzureWorkItemStateCategory } from "./models.js";
11
12
  import { AzureWorkItemStatesCache } from "./workItemStateCategories.js";
12
13
  import { AzureWorkItemDescriptionsCache } from "./workItemDescriptions.js";
13
14
  import { ProviderIssueSearchPage } from "../../models/issueReads.js";
14
15
  import { ProviderApiConfig } from "../apiConfig.js";
15
- import { IntegrationServiceContext } from "../../context.js";
16
16
  //#region ../plus/integrations/src/providers/azure/azure.d.ts
17
17
  type WorkItemSearchOptions = {
18
18
  baseUrl: string;
@@ -7,9 +7,9 @@ import { trace } from "../../../../utils/decorators/log.js";
7
7
  import { PromiseCache } from "../../../../utils/promiseCache.js";
8
8
  import __decorate from "../../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
9
  import { AuthenticationError, RequestClientError, RequestNotFoundError, RequestRateLimitError, getDeferredRequestFailure, reportRequestFailure } from "../../../../git/errors.js";
10
- import { sha256, uuid } from "../../../../utils/crypto.js";
11
10
  import { maybeStopWatch } from "../../../../utils/stopwatch.js";
12
11
  import { base64 } from "../../../../utils/base64.js";
12
+ import { sha256, uuid } from "../../../../utils/crypto.js";
13
13
  import { effectiveIssueSort } from "../../../../git/utils/issue.utils.js";
14
14
  import { ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
15
15
  import { CommitReadRefusedError, isCommitReadRefusal, isNotFoundResponse, throwProviderError } from "../providerErrors.js";
@@ -1,10 +1,17 @@
1
1
  import { PullRequestUrlIdentity } from "../../../../git/utils/pullRequest.utils.js";
2
2
  import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from "../../constants.js";
3
- import { AzureRepositoryDescriptor } from "./models.js";
4
3
  //#region ../plus/integrations/src/providers/azure/azure.utils.d.ts
5
4
  export type AzureDevOpsIntegrationIds = GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer;
6
- /** The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. */
7
- export declare function getAzureRepositoryIdentity(repo: Pick<AzureRepositoryDescriptor, 'owner' | 'name' | 'project'>): {
5
+ /**
6
+ * The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. Takes the
7
+ * descriptor structurally rather than as `AzureRepositoryDescriptor`, so the facade can export it without its
8
+ * declaration reaching the provider models.
9
+ */
10
+ export declare function getAzureRepositoryIdentity(repo: {
11
+ owner: string;
12
+ name: string;
13
+ project?: string;
14
+ }): {
8
15
  resourceName: string;
9
16
  projectName?: string;
10
17
  repositoryName: string;
@@ -1,7 +1,11 @@
1
1
  import { isVsts, parseAzureHttpsUrl } from "../../../../git/remotes/azure-devops.js";
2
2
  import { decodePathSegment } from "../../utils/domain.utils.js";
3
3
  //#region ../plus/integrations/src/providers/azure/azure.utils.ts
4
- /** The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. */
4
+ /**
5
+ * The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. Takes the
6
+ * descriptor structurally rather than as `AzureRepositoryDescriptor`, so the facade can export it without its
7
+ * declaration reaching the provider models.
8
+ */
5
9
  function getAzureRepositoryIdentity(repo) {
6
10
  const match = /^([^/]+)\/_git\/([^/]+)$/i.exec(repo.name);
7
11
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"azure.utils.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/azure/azure.utils.ts"],"sourcesContent":["import { isVsts, parseAzureHttpsUrl } from '@gitlens/git/remotes/azure-devops.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport type { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from '../../constants.js';\nimport { decodePathSegment } from '../../utils/domain.utils.js';\nimport type { AzureRepositoryDescriptor } from './models.js';\n\nexport type AzureDevOpsIntegrationIds =\n\t| GitCloudHostIntegrationId.AzureDevOps\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\n/** The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. */\nexport function getAzureRepositoryIdentity(repo: Pick<AzureRepositoryDescriptor, 'owner' | 'name' | 'project'>): {\n\tresourceName: string;\n\tprojectName?: string;\n\trepositoryName: string;\n} {\n\tconst match = /^([^/]+)\\/_git\\/([^/]+)$/i.exec(repo.name);\n\treturn {\n\t\tresourceName: repo.owner,\n\t\tprojectName: repo.project ?? match?.[1],\n\t\trepositoryName: match?.[2] ?? repo.name,\n\t};\n}\n\n/**\n * Decodes one segment of an address path as a virtual directory names it: an encoded `/` stays encoded, so the segment\n * stays one segment of the `/`-joined directory.\n */\nexport function decodeAzurePathSegment(segment: string): string {\n\treturn decodePathSegment(segment.replace(/%2F/gi, '%252F'));\n}\n\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n): (PullRequestUrlIdentity & { provider: undefined }) | undefined;\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n\tid: AzureDevOpsIntegrationIds,\n): (PullRequestUrlIdentity & { provider: AzureDevOpsIntegrationIds }) | undefined;\n/**\n * Parses a pasted Azure DevOps pull request URL (`…/_git/{repo}/pullrequest/{id}`) into `{org}/{project}`:\n * - dev.azure.com and `{org}.visualstudio.com`, read by the remote's own parser (`parseAzureHttpsUrl`)\n * - `{collection}/{project}/_git/…` on Server, where a leading virtual directory such as `tfs/` is dropped: the\n * identity has no field for it, so the read relies on the connection's configured URL including it\n * - `{collection}/_git/…` on Server, where the project is named after the repo\n */\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n\tid?: AzureDevOpsIntegrationIds,\n): (PullRequestUrlIdentity & { provider: AzureDevOpsIntegrationIds | undefined }) | undefined {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(search);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\tconst rawSegments = url.pathname.split('/').filter(Boolean);\n\tconst segments = rawSegments.map(decodePathSegment);\n\tconst gitIndex = segments.findIndex(s => s.toLowerCase() === '_git');\n\tif (gitIndex < 0) return undefined;\n\n\tconst repo = segments[gitIndex + 1];\n\tconst prNumber = segments[gitIndex + 3];\n\tif (repo == null || segments[gitIndex + 2] !== 'pullrequest' || prNumber == null) return undefined;\n\n\tlet org: string;\n\tlet project: string;\n\tif (isVsts(url.hostname) || url.hostname.toLowerCase() === 'dev.azure.com') {\n\t\t// A cloud repository URL reads exactly as its remote does (org from the host or the path, the legacy\n\t\t// `DefaultCollection` segment, a project named after its repo), so hand the remote's parser the URL cut after\n\t\t// the repository\n\t\tconst repoUrl = new URL(url.href);\n\t\trepoUrl.pathname = rawSegments.slice(0, gitIndex + 2).join('/');\n\t\ttry {\n\t\t\t[org, project] = parseAzureHttpsUrl(repoUrl);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t} else {\n\t\tif (gitIndex < 1) return undefined;\n\n\t\torg = gitIndex === 1 ? segments[0] : segments[gitIndex - 2];\n\t\tproject = gitIndex === 1 ? repo : segments[gitIndex - 1];\n\t}\n\n\treturn { ownerAndRepo: `${org}/${project}`, prNumber: prNumber, provider: id };\n}\n"],"mappings":";;;;AAWA,SAAgB,2BAA2B,MAIzC;CACD,MAAM,QAAQ,4BAA4B,KAAK,KAAK,IAAI;CACxD,OAAO;EACN,cAAc,KAAK;EACnB,aAAa,KAAK,WAAW,QAAQ;EACrC,gBAAgB,QAAQ,MAAM,KAAK;CACpC;AACD;;;;;AAMA,SAAgB,uBAAuB,SAAyB;CAC/D,OAAO,kBAAkB,QAAQ,QAAQ,SAAS,OAAO,CAAC;AAC3D;;;;;;;;AAgBA,SAAgB,wCACf,QACA,IAC6F;CAC7F,IAAI;CACJ,IAAI;EACH,MAAM,IAAI,IAAI,MAAM;CACrB,QAAQ;EACP;CACD;CAEA,MAAM,cAAc,IAAI,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC1D,MAAM,WAAW,YAAY,IAAI,iBAAiB;CAClD,MAAM,WAAW,SAAS,WAAU,MAAK,EAAE,YAAY,MAAM,MAAM;CACnE,IAAI,WAAW,GAAG,OAAO,KAAA;CAEzB,MAAM,OAAO,SAAS,WAAW;CACjC,MAAM,WAAW,SAAS,WAAW;CACrC,IAAI,QAAQ,QAAQ,SAAS,WAAW,OAAO,iBAAiB,YAAY,MAAM,OAAO,KAAA;CAEzF,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO,IAAI,QAAQ,KAAK,IAAI,SAAS,YAAY,MAAM,iBAAiB;EAI3E,MAAM,UAAU,IAAI,IAAI,IAAI,IAAI;EAChC,QAAQ,WAAW,YAAY,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG;EAC9D,IAAI;GACH,CAAC,KAAK,WAAW,mBAAmB,OAAO;EAC5C,QAAQ;GACP;EACD;CACD,OAAO;EACN,IAAI,WAAW,GAAG,OAAO,KAAA;EAEzB,MAAM,aAAa,IAAI,SAAS,KAAK,SAAS,WAAW;EACzD,UAAU,aAAa,IAAI,OAAO,SAAS,WAAW;CACvD;CAEA,OAAO;EAAE,cAAc,GAAG,IAAI,GAAG;EAAqB;EAAU,UAAU;CAAG;AAC9E"}
1
+ {"version":3,"file":"azure.utils.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/azure/azure.utils.ts"],"sourcesContent":["import { isVsts, parseAzureHttpsUrl } from '@gitlens/git/remotes/azure-devops.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport type { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from '../../constants.js';\nimport { decodePathSegment } from '../../utils/domain.utils.js';\n\nexport type AzureDevOpsIntegrationIds =\n\t| GitCloudHostIntegrationId.AzureDevOps\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\n/**\n * The project and repository an Azure repository descriptor names, its `{project}/_git/{repo}` name parsed. Takes the\n * descriptor structurally rather than as `AzureRepositoryDescriptor`, so the facade can export it without its\n * declaration reaching the provider models.\n */\nexport function getAzureRepositoryIdentity(repo: { owner: string; name: string; project?: string }): {\n\tresourceName: string;\n\tprojectName?: string;\n\trepositoryName: string;\n} {\n\tconst match = /^([^/]+)\\/_git\\/([^/]+)$/i.exec(repo.name);\n\treturn {\n\t\tresourceName: repo.owner,\n\t\tprojectName: repo.project ?? match?.[1],\n\t\trepositoryName: match?.[2] ?? repo.name,\n\t};\n}\n\n/**\n * Decodes one segment of an address path as a virtual directory names it: an encoded `/` stays encoded, so the segment\n * stays one segment of the `/`-joined directory.\n */\nexport function decodeAzurePathSegment(segment: string): string {\n\treturn decodePathSegment(segment.replace(/%2F/gi, '%252F'));\n}\n\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n): (PullRequestUrlIdentity & { provider: undefined }) | undefined;\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n\tid: AzureDevOpsIntegrationIds,\n): (PullRequestUrlIdentity & { provider: AzureDevOpsIntegrationIds }) | undefined;\n/**\n * Parses a pasted Azure DevOps pull request URL (`…/_git/{repo}/pullrequest/{id}`) into `{org}/{project}`:\n * - dev.azure.com and `{org}.visualstudio.com`, read by the remote's own parser (`parseAzureHttpsUrl`)\n * - `{collection}/{project}/_git/…` on Server, where a leading virtual directory such as `tfs/` is dropped: the\n * identity has no field for it, so the read relies on the connection's configured URL including it\n * - `{collection}/_git/…` on Server, where the project is named after the repo\n */\nexport function getAzurePullRequestIdentityFromMaybeUrl(\n\tsearch: string,\n\tid?: AzureDevOpsIntegrationIds,\n): (PullRequestUrlIdentity & { provider: AzureDevOpsIntegrationIds | undefined }) | undefined {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(search);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\tconst rawSegments = url.pathname.split('/').filter(Boolean);\n\tconst segments = rawSegments.map(decodePathSegment);\n\tconst gitIndex = segments.findIndex(s => s.toLowerCase() === '_git');\n\tif (gitIndex < 0) return undefined;\n\n\tconst repo = segments[gitIndex + 1];\n\tconst prNumber = segments[gitIndex + 3];\n\tif (repo == null || segments[gitIndex + 2] !== 'pullrequest' || prNumber == null) return undefined;\n\n\tlet org: string;\n\tlet project: string;\n\tif (isVsts(url.hostname) || url.hostname.toLowerCase() === 'dev.azure.com') {\n\t\t// A cloud repository URL reads exactly as its remote does (org from the host or the path, the legacy\n\t\t// `DefaultCollection` segment, a project named after its repo), so hand the remote's parser the URL cut after\n\t\t// the repository\n\t\tconst repoUrl = new URL(url.href);\n\t\trepoUrl.pathname = rawSegments.slice(0, gitIndex + 2).join('/');\n\t\ttry {\n\t\t\t[org, project] = parseAzureHttpsUrl(repoUrl);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t} else {\n\t\tif (gitIndex < 1) return undefined;\n\n\t\torg = gitIndex === 1 ? segments[0] : segments[gitIndex - 2];\n\t\tproject = gitIndex === 1 ? repo : segments[gitIndex - 1];\n\t}\n\n\treturn { ownerAndRepo: `${org}/${project}`, prNumber: prNumber, provider: id };\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,2BAA2B,MAIzC;CACD,MAAM,QAAQ,4BAA4B,KAAK,KAAK,IAAI;CACxD,OAAO;EACN,cAAc,KAAK;EACnB,aAAa,KAAK,WAAW,QAAQ;EACrC,gBAAgB,QAAQ,MAAM,KAAK;CACpC;AACD;;;;;AAMA,SAAgB,uBAAuB,SAAyB;CAC/D,OAAO,kBAAkB,QAAQ,QAAQ,SAAS,OAAO,CAAC;AAC3D;;;;;;;;AAgBA,SAAgB,wCACf,QACA,IAC6F;CAC7F,IAAI;CACJ,IAAI;EACH,MAAM,IAAI,IAAI,MAAM;CACrB,QAAQ;EACP;CACD;CAEA,MAAM,cAAc,IAAI,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC1D,MAAM,WAAW,YAAY,IAAI,iBAAiB;CAClD,MAAM,WAAW,SAAS,WAAU,MAAK,EAAE,YAAY,MAAM,MAAM;CACnE,IAAI,WAAW,GAAG,OAAO,KAAA;CAEzB,MAAM,OAAO,SAAS,WAAW;CACjC,MAAM,WAAW,SAAS,WAAW;CACrC,IAAI,QAAQ,QAAQ,SAAS,WAAW,OAAO,iBAAiB,YAAY,MAAM,OAAO,KAAA;CAEzF,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO,IAAI,QAAQ,KAAK,IAAI,SAAS,YAAY,MAAM,iBAAiB;EAI3E,MAAM,UAAU,IAAI,IAAI,IAAI,IAAI;EAChC,QAAQ,WAAW,YAAY,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG;EAC9D,IAAI;GACH,CAAC,KAAK,WAAW,mBAAmB,OAAO;EAC5C,QAAQ;GACP;EACD;CACD,OAAO;EACN,IAAI,WAAW,GAAG,OAAO,KAAA;EAEzB,MAAM,aAAa,IAAI,SAAS,KAAK,SAAS,WAAW;EACzD,UAAU,aAAa,IAAI,OAAO,SAAS,WAAW;CACvD;CAEA,OAAO;EAAE,cAAc,GAAG,IAAI,GAAG;EAAqB;EAAU,UAAU;CAAG;AAC9E"}
@@ -3,8 +3,8 @@ import { Provider } from "../../../../git/models/remoteProvider.js";
3
3
  import { IssueOrPullRequestState } from "../../../../git/models/issueOrPullRequest.js";
4
4
  import { Issue as Issue$1, IssueProjection, IssueProviderState } from "../../../../git/models/issue.js";
5
5
  import { PullRequest, PullRequestMember, PullRequestMergeableState, PullRequestProjection, PullRequestReviewDecision, PullRequestReviewState, PullRequestReviewer } from "../../../../git/models/pullRequest.js";
6
+ import { IssueEtagFields, PullRequestEtagFields, PullRequestEtagInclude } from "../../reads/etag.js";
6
7
  import { ProviderIssue } from "../models.js";
7
- import { IssueEtagFields, PullRequestEtagFields, PullRequestEtagInclude } from "../../models/integration.js";
8
8
  import { AzureWorkItemHtmlField } from "@gitkraken/provider-apis";
9
9
  //#region ../plus/integrations/src/providers/azure/models.d.ts
10
10
  export declare const vstsHostnameSuffix = ".visualstudio.com";
@@ -34,10 +34,6 @@ export interface AzureRemoteRepositoryDescriptor extends ResourceDescriptor {
34
34
  cloneUrlHttps?: string;
35
35
  cloneUrlSsh?: string;
36
36
  }
37
- export interface AzureProjectInputDescriptor extends ResourceDescriptor {
38
- owner: string;
39
- name: string;
40
- }
41
37
  export type AzureWorkItemStateCategory = 'Proposed' | 'InProgress' | 'Resolved' | 'Completed' | 'Removed';
42
38
  /**
43
39
  * The workflow category of an Azure DevOps state category, as a work item type's states endpoint reports it:
@@ -4,7 +4,7 @@ import { PullRequest } from "../../../../git/models/pullRequest.js";
4
4
  import { isTerminalIssueStateCategory } from "../../../../git/utils/issue.utils.js";
5
5
  import { decideProviderReviewDecision, fromPullRequestReviewDecision, toCompletedReviews, toReviewRequests } from "../pullRequestReviews.js";
6
6
  import { GitPullRequestMergeableState as GitPullRequestMergeableState$1, GitPullRequestReviewState as GitPullRequestReviewState$1, GitPullRequestState as GitPullRequestState$1, fromProviderPullRequestMergeableState, fromProviderPullRequestState, toIssueBodyField, toIssueViewer } from "../models.js";
7
- import { pullRequestRevision } from "../../models/integration.js";
7
+ import { pullRequestRevision } from "../../reads/etag.js";
8
8
  import { copyReadProvenance } from "@gitkraken/provider-apis/read-provenance";
9
9
  import { getAzureWorkItemDescription } from "@gitkraken/provider-apis";
10
10
  //#region ../plus/integrations/src/providers/azure/models.ts