@gitkraken/core-gitlens 0.45.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 (235) hide show
  1. package/CHANGELOG.md +27 -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/plus/git-github/api/github.d.ts +6 -1
  20. package/dist/plus/git-github/api/github.js +14 -4
  21. package/dist/plus/git-github/api/github.js.map +1 -1
  22. package/dist/plus/git-github/api/issueWrites.d.ts +6 -1
  23. package/dist/plus/git-github/api/issueWrites.js +61 -31
  24. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  25. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +44 -0
  26. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +199 -0
  27. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -0
  28. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +7 -0
  29. package/dist/plus/integrations/authentication/configuredIntegrationService.js +53 -7
  30. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  31. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +2 -38
  32. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +0 -199
  33. package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +4 -2
  34. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +12 -1
  35. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  36. package/dist/plus/integrations/authentication/models.d.ts +0 -1
  37. package/dist/plus/integrations/authentication/models.js +1 -2
  38. package/dist/plus/integrations/authentication/models.js.map +1 -1
  39. package/dist/plus/integrations/constants.d.ts +0 -10
  40. package/dist/plus/integrations/constants.js +1 -95
  41. package/dist/plus/integrations/constants.js.map +1 -1
  42. package/dist/plus/integrations/context.d.ts +13 -13
  43. package/dist/plus/integrations/index.d.ts +39 -24
  44. package/dist/plus/integrations/index.js +40 -8
  45. package/dist/plus/integrations/index.js.map +1 -1
  46. package/dist/plus/integrations/integrationService.d.ts +15 -22
  47. package/dist/plus/integrations/integrationService.js +39 -12
  48. package/dist/plus/integrations/integrationService.js.map +1 -1
  49. package/dist/plus/integrations/lite.js +1 -1
  50. package/dist/plus/integrations/lite.js.map +1 -1
  51. package/dist/plus/integrations/manager.d.ts +65 -17
  52. package/dist/plus/integrations/models/actionablePullRequest.d.ts +213 -0
  53. package/dist/plus/integrations/models/actionablePullRequest.js +25 -0
  54. package/dist/plus/integrations/models/actionablePullRequest.js.map +1 -0
  55. package/dist/plus/integrations/models/gitHostIntegration.d.ts +13 -46
  56. package/dist/plus/integrations/models/gitHostIntegration.js +15 -4
  57. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  58. package/dist/plus/integrations/models/integration.d.ts +10 -175
  59. package/dist/plus/integrations/models/integration.js +11 -72
  60. package/dist/plus/integrations/models/integration.js.map +1 -1
  61. package/dist/plus/integrations/models/issuesIntegration.d.ts +9 -5
  62. package/dist/plus/integrations/models/issuesIntegration.js +5 -3
  63. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  64. package/dist/plus/integrations/models/publicIntegration.d.ts +252 -0
  65. package/dist/plus/integrations/models/publicIntegration.js +21 -0
  66. package/dist/plus/integrations/models/publicIntegration.js.map +1 -0
  67. package/dist/plus/integrations/providerFilters.d.ts +58 -0
  68. package/dist/plus/integrations/providerFilters.js.map +1 -1
  69. package/dist/plus/integrations/providers/actionablePullRequests.d.ts +19 -0
  70. package/dist/plus/integrations/providers/actionablePullRequests.js +32 -0
  71. package/dist/plus/integrations/providers/actionablePullRequests.js.map +1 -0
  72. package/dist/plus/integrations/providers/apiClients.d.ts +1 -2
  73. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  74. package/dist/plus/integrations/providers/asana.d.ts +3 -2
  75. package/dist/plus/integrations/providers/asana.js +2 -1
  76. package/dist/plus/integrations/providers/asana.js.map +1 -1
  77. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  78. package/dist/plus/integrations/providers/azure/azure.utils.d.ts +10 -3
  79. package/dist/plus/integrations/providers/azure/azure.utils.js +5 -1
  80. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  81. package/dist/plus/integrations/providers/azure/models.d.ts +1 -5
  82. package/dist/plus/integrations/providers/azure/models.js +1 -1
  83. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  84. package/dist/plus/integrations/providers/azureDevOps.d.ts +8 -5
  85. package/dist/plus/integrations/providers/azureDevOps.js +2 -1
  86. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  87. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +5 -4
  88. package/dist/plus/integrations/providers/azureDevOpsServer.js +3 -1
  89. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  90. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +2 -2
  91. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  92. package/dist/plus/integrations/providers/bitbucket/models.d.ts +1 -1
  93. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  94. package/dist/plus/integrations/providers/bitbucket-server.d.ts +5 -4
  95. package/dist/plus/integrations/providers/bitbucket-server.js +2 -1
  96. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  97. package/dist/plus/integrations/providers/bitbucket.d.ts +4 -3
  98. package/dist/plus/integrations/providers/bitbucket.js +2 -1
  99. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  100. package/dist/plus/integrations/providers/github/github.d.ts +0 -1
  101. package/dist/plus/integrations/providers/github/github.js +1 -1
  102. package/dist/plus/integrations/providers/github/github.js.map +1 -1
  103. package/dist/plus/integrations/providers/github.d.ts +11 -6
  104. package/dist/plus/integrations/providers/github.js +70 -26
  105. package/dist/plus/integrations/providers/github.js.map +1 -1
  106. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
  107. package/dist/plus/integrations/providers/gitlab/gitlab.js +1 -2
  108. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  109. package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +14 -1
  110. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
  111. package/dist/plus/integrations/providers/gitlab/models.d.ts +2 -10
  112. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  113. package/dist/plus/integrations/providers/gitlab.d.ts +7 -5
  114. package/dist/plus/integrations/providers/gitlab.js +2 -1
  115. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  116. package/dist/plus/integrations/providers/jira-server.d.ts +4 -4
  117. package/dist/plus/integrations/providers/jira-server.js +3 -2
  118. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  119. package/dist/plus/integrations/providers/jira.d.ts +3 -3
  120. package/dist/plus/integrations/providers/jira.js +3 -2
  121. package/dist/plus/integrations/providers/jira.js.map +1 -1
  122. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +1 -1
  123. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  124. package/dist/plus/integrations/providers/linear.d.ts +4 -3
  125. package/dist/plus/integrations/providers/linear.js +3 -2
  126. package/dist/plus/integrations/providers/linear.js.map +1 -1
  127. package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +1 -1
  128. package/dist/plus/integrations/providers/linearIssuesEtag.js +1 -1
  129. package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
  130. package/dist/plus/integrations/providers/metadata.d.ts +136 -0
  131. package/dist/plus/integrations/providers/metadata.js +513 -0
  132. package/dist/plus/integrations/providers/metadata.js.map +1 -0
  133. package/dist/plus/integrations/providers/models.d.ts +10 -206
  134. package/dist/plus/integrations/providers/models.js +8 -539
  135. package/dist/plus/integrations/providers/models.js.map +1 -1
  136. package/dist/plus/integrations/providers/providersApi.d.ts +3 -2
  137. package/dist/plus/integrations/providers/providersApi.js +2 -1
  138. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  139. package/dist/plus/integrations/providers/trello.d.ts +1 -1
  140. package/dist/plus/integrations/providers/trello.js +2 -1
  141. package/dist/plus/integrations/providers/trello.js.map +1 -1
  142. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +2 -0
  143. package/dist/plus/integrations/providers/utils/providerPaging.js +3 -2
  144. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  145. package/dist/plus/integrations/providers/utils.d.ts +119 -10
  146. package/dist/plus/integrations/providers/utils.js +57 -3
  147. package/dist/plus/integrations/providers/utils.js.map +1 -1
  148. package/dist/plus/integrations/reads/autolinks.d.ts +1 -1
  149. package/dist/plus/integrations/reads/autolinks.js +1 -1
  150. package/dist/plus/integrations/reads/autolinks.js.map +1 -1
  151. package/dist/plus/integrations/reads/broaden.d.ts +1 -1
  152. package/dist/plus/integrations/reads/broaden.js +3 -2
  153. package/dist/plus/integrations/reads/broaden.js.map +1 -1
  154. package/dist/plus/integrations/reads/context.d.ts +1 -1
  155. package/dist/plus/integrations/reads/counts.d.ts +1 -88
  156. package/dist/plus/integrations/reads/counts.js +4 -2
  157. package/dist/plus/integrations/reads/counts.js.map +1 -1
  158. package/dist/plus/integrations/reads/currentAccount.d.ts +1 -18
  159. package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
  160. package/dist/plus/integrations/reads/drains.d.ts +3 -3
  161. package/dist/plus/integrations/reads/drains.js +1 -1
  162. package/dist/plus/integrations/reads/drains.js.map +1 -1
  163. package/dist/plus/integrations/reads/etag.d.ts +174 -3
  164. package/dist/plus/integrations/reads/etag.js +69 -14
  165. package/dist/plus/integrations/reads/etag.js.map +1 -1
  166. package/dist/plus/integrations/reads/filters.d.ts +3 -61
  167. package/dist/plus/integrations/reads/filters.js +1 -1
  168. package/dist/plus/integrations/reads/filters.js.map +1 -1
  169. package/dist/plus/integrations/reads/hierarchy.d.ts +1 -1
  170. package/dist/plus/integrations/reads/hierarchy.js +4 -2
  171. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  172. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -102
  173. package/dist/plus/integrations/reads/issueBatch.js +3 -4
  174. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  175. package/dist/plus/integrations/reads/issueTracker.d.ts +1 -1
  176. package/dist/plus/integrations/reads/issueTracker.js +4 -3
  177. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  178. package/dist/plus/integrations/reads/issues.d.ts +1 -1
  179. package/dist/plus/integrations/reads/issues.js +4 -2
  180. package/dist/plus/integrations/reads/issues.js.map +1 -1
  181. package/dist/plus/integrations/reads/paging.d.ts +1 -1
  182. package/dist/plus/integrations/reads/paging.js +1 -1
  183. package/dist/plus/integrations/reads/paging.js.map +1 -1
  184. package/dist/plus/integrations/reads/pullRequestActivity.d.ts +1 -24
  185. package/dist/plus/integrations/reads/pullRequestActivity.js +2 -1
  186. package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -1
  187. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +2 -56
  188. package/dist/plus/integrations/reads/pullRequestBatch.js +23 -3
  189. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
  190. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +1 -47
  191. package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
  192. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  193. package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +1 -15
  194. package/dist/plus/integrations/reads/pullRequestCheckLogs.js +2 -1
  195. package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -1
  196. package/dist/plus/integrations/reads/pullRequests.js +4 -2
  197. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  198. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +1 -16
  199. package/dist/plus/integrations/reads/pullRequestsForCommits.js +2 -1
  200. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -1
  201. package/dist/plus/integrations/reads/resolveRepository.js +10 -5
  202. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  203. package/dist/plus/integrations/reads/searchIssues.js +2 -1
  204. package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
  205. package/dist/plus/integrations/reads/searchPullRequests.js +2 -1
  206. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  207. package/dist/plus/integrations/reads/sweeps.d.ts +1 -1
  208. package/dist/plus/integrations/reads/sweeps.js +3 -2
  209. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  210. package/dist/plus/integrations/reads/warnings.d.ts +1 -1
  211. package/dist/plus/integrations/reads/warnings.js +1 -1
  212. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  213. package/dist/plus/integrations/results.d.ts +324 -2
  214. package/dist/plus/integrations/results.js.map +1 -1
  215. package/dist/plus/integrations/telemetry.d.ts +0 -10
  216. package/dist/plus/integrations/telemetry.js +0 -11
  217. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  218. package/dist/plus/integrations/utils/domain.utils.js +10 -2
  219. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  220. package/dist/plus/integrations/utils/integration.utils.d.ts +1 -6
  221. package/dist/plus/integrations/utils/integration.utils.js +2 -9
  222. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  223. package/dist/utils/keys/chord.d.ts +13 -2
  224. package/dist/utils/keys/chord.js +76 -17
  225. package/dist/utils/keys/chord.js.map +1 -1
  226. package/dist/utils/keys/keybinding.d.ts +12 -0
  227. package/dist/utils/keys/keybinding.js +52 -2
  228. package/dist/utils/keys/keybinding.js.map +1 -1
  229. package/dist/utils/markdown.d.ts +21 -0
  230. package/dist/utils/markdown.js +33 -1
  231. package/dist/utils/markdown.js.map +1 -1
  232. package/docs/integrations.md +99 -16
  233. package/package.json +5 -1
  234. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +0 -1
  235. package/dist/plus/integrations/telemetry.js.map +0 -1
@@ -15,20 +15,78 @@ never leaks `@gitkraken/provider-apis` types, so a consumer depends on this pack
15
15
 
16
16
  ## 1. Entry points
17
17
 
18
- | Subpath | Use it for |
19
- | ---------------------------------------------------- | ---------------------------------------------------------------------------------- |
20
- | `@gitkraken/core-gitlens/plus/integrations/index.js` | The session-managed facade: manager factory, public types, and connection helpers. |
21
- | `@gitkraken/core-gitlens/plus/integrations/lite.js` | Stateless, token-scoped single reads (no storage/auth lifecycle). See §10. |
22
- | `@gitkraken/core-gitlens/git/models/*.js` | The returned models (`PullRequestShape`, `IssueShape`, …). |
23
-
24
- Everything else under `plus/integrations/**` is internal. `IntegrationService`, the `GitHostIntegration`
25
- models, and the provider clients are deliberately **not** on the facade: they change without a semver bump.
18
+ | Subpath | Use it for |
19
+ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
20
+ | `@gitkraken/core-gitlens/plus/integrations/index.js` | The session-managed facade: manager factory, public types, and connection helpers. |
21
+ | `@gitkraken/core-gitlens/plus/integrations/lite.js` | Stateless, token-scoped single reads (no storage/auth lifecycle). See §10. |
22
+ | `@gitkraken/core-gitlens/plus/integrations/constants.js` | Integration ids and simple checks on them. No runtime imports, so webviews can import it. |
23
+ | `@gitkraken/core-gitlens/git/models/*.js` | The returned models (`PullRequestShape`, `IssueShape`, …). |
24
+
25
+ Everything else under `plus/integrations/**` is internal. `IntegrationService`, the integration implementation
26
+ classes, and the provider clients are deliberately **not** on the facade: they change without a semver bump. What
27
+ `manager.get(...)` hands out are interface-only views, `GitHostIntegration`, `IssuesIntegration` and
28
+ `Integration` (their union), with the guards `isIntegration`, `isGitHostIntegration` and `isIssuesIntegration` to
29
+ narrow them; use the guards, not `instanceof`.
26
30
  `manager.js` / `results.js` are not published subpaths either — their types are re-exported through
27
31
  `index.js`, so import them from there.
28
32
 
29
33
  > If a type you need to name isn't exported from `index.js`, that's a bug in this package — file it rather
30
34
  > than re-declaring the shape downstream, which silently drifts.
31
35
 
36
+ ### 1.1 Integration objects
37
+
38
+ A view from `manager.get(...)` has the members below, grouped; the doc comments in `publicIntegration.ts` are the
39
+ contract.
40
+
41
+ - **Identity and state** (both kinds): `type`, `id`, `name`, `icon`, `domain`, `maybeConnected`.
42
+ - **Connection** (both kinds): `access()`, `connect(source)`, `isConnected()`, `getCredential(source)`, and, on a git
43
+ host, `disconnect()`.
44
+ - **Issues and links** (both kinds): `getIssue`, `getLinkedIssueOrPullRequest`, `autolinks()`.
45
+ - **Git-host reads** (`GitHostIntegration` only): the current account and an account for a commit, repository
46
+ metadata and default branch, SSH signing keys, pull requests (by id, branch, commit or URL, the current user's,
47
+ and free-text search), stacked pull requests (only where the host has a stacks concept), `mergePullRequest`, and
48
+ the merge-queue actions `enqueuePullRequest` and `dequeuePullRequest` (GitHub.com only; every other host answers
49
+ `unsupported`), with the optional `getMergeQueueEntriesByPullRequestNumber`.
50
+
51
+ `getCredential(source)` is the only way to a token. It returns `{ providerId, accessToken }`, refreshed first when it
52
+ has expired, or `undefined` when the integration isn't connected or the refresh failed. An unexpired token is returned
53
+ as is, so one the provider has since revoked still comes back. Session objects and `authProvider` are not exposed.
54
+ `sessionFingerprint` (a hash of the session's token) appears only on `IntegrationCacheDescriptor`, which tells a
55
+ consumer-owned cache when to invalidate.
56
+
57
+ The manager members added for integration objects:
58
+
59
+ - `get(id, domain?)`: the view for an id. A cloud id always resolves; a self-managed one needs `domain` and resolves
60
+ to `undefined` when no connection names that host.
61
+ - `connectCloudIntegrations(options?, source?)`: runs the host's cloud connect flow for the given ids (all when
62
+ omitted), re-syncs, and resolves whether a requested integration became connected.
63
+ - `manageCloudIntegrations(source?)`: opens the host's cloud integrations management and re-syncs on return.
64
+ - `reset()`: resets every integration's local connection state.
65
+ - `getMyPullRequests(integrationIds?, cancellation?, options?)` and `getMyIssues(integrationIds?, options?)`: the
66
+ current user's items across integrations, as `IntegrationResult`s.
67
+ - `ignoreSSLErrors(integration)`: the `ignoreSSLErrors` setting of the remote configured for that host, if any.
68
+ - `github`: the shared `GitHubApi` client, for a host running its own GitHub-backed git provider.
69
+ Host-oriented (it hands out a whole client, not a read), so expect it to narrow.
70
+
71
+ **Actionable pull requests.** `toActionablePullRequestInput(pr)` turns a `PullRequestShape` into the input
72
+ `getActionablePullRequests(...)` categorizes (Launchpad's categories), adding the entity-identifier `uuid` that keys
73
+ pins and snoozes. The `ActionablePullRequest*` types are GitLens-owned copies, so the provider SDK stays out of your
74
+ types.
75
+
76
+ **Entity identifiers.** `encodeEntityIdentifier(input)` and `decodeEntityIdentifier(encoded)` are the string form
77
+ Launchpad keys pins and snoozes by. `EntityIdentifierInput` is a union with one arm per provider and entity type the
78
+ codec encodes, each requiring the fields it can't encode without. `encodeEntityIdentifier` and
79
+ `getEntityIdentifierInput(pr)` throw when an arm misses a required field:
80
+
81
+ - Bitbucket and Bitbucket Server need `repoId`.
82
+ - Azure DevOps and Azure DevOps Server need an organization, a project and, for pull requests, `repoId`.
83
+ - Jira (and Jira Server) issues need a project (`projectId`).
84
+ - Trello issues need an account or organization and a project.
85
+ - GitHub and GitLab (and their self-hosted variants) need nothing extra.
86
+
87
+ Linear isn't encodable, and Jira and Trello have no pull request arm. `getEntityIdentifierInput(pr)` also throws for
88
+ a pull request from a provider with no arm.
89
+
32
90
  ## 2. Building the runtime
33
91
 
34
92
  `createIntegrationManager(ctx)` takes one argument: an `IntegrationManagerContext`. It is the **single**
@@ -41,7 +99,7 @@ broader `IntegrationServiceContext` is internal and is not part of the published
41
99
  | `account` | yes | The GitKraken account and the GK-cloud connect/manage round-trips. Return `undefined` from `getAccount` if you don't use GK cloud (see below). |
42
100
  | `config` | yes | `getRemoteConfigs()` (self-managed hosts, SSL/protocol overrides), launchpad knobs, optional `getPullRequestReadOptions()` (`{ mergeQueue: true }` opts GitHub.com reads in to merge-queue data, unless a read says otherwise), a change event. |
43
101
  | `http` | yes | `fetch` + `wrapForForcedInsecureSSL` + `isWeb` + a User-Agent string. |
44
- | `cache` | no | `IntegrationManagerCacheProvider`, whose only method is `getCurrentAccount`. Omit it for correct uncached reads; implement it for a long-lived manager to deduplicate provider identity lookups. |
102
+ | `cache` | no | `IntegrationManagerCacheProvider`: `getCurrentAccount` is required; the repository, pull-request and issue lookups and `deletePullRequests` are optional (see below). Omit it for correct uncached reads. |
45
103
  | `repositories` | yes | `getOpenRemotes()`; used only by the "across open repos" helpers. `async () => []` is fine. |
46
104
  | `hooks` | no | Auth strategy override, reauth/disconnect prompts, outbound behavioral events. |
47
105
 
@@ -50,10 +108,22 @@ A complete, type-checked, dependency-free example (including the optional-cache
50
108
  It runs against the packed artifact in CI, so it catches missing exports as well as source-level mistakes:
51
109
  use that file's `buildRuntime()` as your starting point.
52
110
 
53
- The cache callback receives only `{ id, domain }`, a loader, and cache controls (`connectionId`, `etag`,
54
- expiry). It never exposes GitLens' internal `IntegrationBase` / `GitHostIntegration` classes or requires
55
- stubs for unrelated repository, pull-request, or issue caches. The fixture uses the package's public
56
- `PromiseCache` utility, but any cache with the same behavior is valid.
111
+ Each cache method gets the lookup's arguments, an `IntegrationCacheDescriptor`, a loader (called on a miss), and
112
+ cache controls (`connectionId`, `etag`, expiry). The optional methods are:
113
+
114
+ - `getRepositoryMetadata`, `getRepositoryDefaultBranch`: repository lookups.
115
+ - `getPullRequestForSha`, `getPullRequestForBranch`, `getPullRequest`: pull-request lookups by commit, branch, or id.
116
+ - `getIssue`, `getIssueOrPullRequest`: issue lookups by id.
117
+ - `deletePullRequests()`: evicts every cached pull request (a merge can change pull requests no caller can name).
118
+
119
+ A method you omit means no caching for that read: its loader runs on every call (and `deletePullRequests` is a
120
+ no-op). Call a method as `cache.method(...)`; the manager never detaches it, so a class instance works.
121
+
122
+ The descriptor is `{ id, domain, maybeConnected, sessionFingerprint }`, not the integration class. Its getters read
123
+ through to the live integration each time they are read, so the values are live, not snapshots. Key entries by `id`
124
+ and `domain`, and treat `maybeConnected` and `sessionFingerprint` as the entry's etag: when either changes (a
125
+ reconnect, a token change) the entry must miss. The descriptor is `undefined` for lookups with no integration.
126
+ The fixture uses the package's public `PromiseCache` utility, but any cache with the same behavior is valid.
57
127
 
58
128
  ### Authentication
59
129
 
@@ -823,16 +893,25 @@ What holds for all of them:
823
893
  - An Asana task's tags are its labels and its likes, a thumbs-up on the task, its reactions. Its comments are stories, which a task doesn't
824
894
  count, so reading them would cost a request per task. Asana has no batch read.
825
895
 
826
- ### GitHub.com issue writes
896
+ ### GitHub issue writes
827
897
 
828
898
  Use the selected GitHub connection ID from `getConfigured()` together with `providerId`, `owner`, and `repo`.
829
899
  Core resolves the repository and issue with that account before sending the mutation to GitHub. Issue numbers
830
900
  are scoped to their repository. For an existing issue, pass its `number` and the `expectedNodeId` from the
831
901
  issue read. Core verifies that the node still belongs to the requested repository and number.
832
902
 
903
+ For GitHub Enterprise Server, use `providerId: 'cloud-github-enterprise'` and pass `domain` with the
904
+ selected connection's host and port, or its HTTP(S) origin. Core pins the configured origin before
905
+ contacting the instance. Issue and repository node IDs belong to that installation. The instance's GraphQL schema, the
906
+ repository's settings, and the credentials determine which operations are available. Deletion also requires
907
+ permission under the enterprise and organization policies. Pass `expectedLogin` when the caller has
908
+ selected or confirmed an account by login. Core verifies the viewer with the same credential it uses for
909
+ the operation and returns `no-connection` if the login differs. Core checks that the selected Server
910
+ credential is current again before dispatch.
911
+
833
912
  | Method | Operation |
834
913
  | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
835
- | `resolveIssueWriteTarget` | Verify an existing issue and return its canonical `nodeId`. Use it to serialize writes and publication across aliases or transfers. |
914
+ | `resolveIssueWriteTarget` | Verify an existing issue and return its canonical `nodeId` and current snapshot. Use it to serialize writes across aliases or transfers. |
836
915
  | `writeIssue` | Pass `action: 'create'` with a `title` and an optional `body`. |
837
916
  | `writeIssue` | Pass `action: 'edit'` with at least one of `title` or `body`. An empty body clears the description. |
838
917
  | `writeIssue` | Pass `action: 'set-state'`. Use `state: 'open'` to reopen, or `state: 'closed'` with `reason: 'completed'` or `'not_planned'`. |
@@ -844,9 +923,13 @@ report a different repository if a transfer happened after preflight. In that ca
844
923
  `deletedFromDifferentRepository: true` preserves the confirmation. Use the node ID to reconcile deletion
845
924
  and refresh affected lists and details. The snapshot still describes the earlier address.
846
925
 
926
+ Pass `intent: 'delete'` to `resolveIssueWriteTarget` before asking for deletion confirmation. It checks whether
927
+ the selected account may delete the issue and returns the snapshot to show for confirmation.
928
+
847
929
  An `ok: false` result contains a typed reason. GitHub can report inaccessible private resources as
848
930
  `not-found`. Check GitHub before retrying an `unknown` result, since GitHub may have applied the mutation
849
- before the response was lost.
931
+ before the response was lost. For an Enterprise failure with `mutationDispatched: false`, Core stopped
932
+ before sending a mutation.
850
933
 
851
934
  ### GitHub.com pull request writes
852
935
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.45.0",
4
+ "version": "0.46.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",
@@ -198,6 +198,10 @@
198
198
  "types": "./dist/plus/git-github/providers/github/*.d.ts",
199
199
  "default": "./dist/plus/git-github/providers/github/*.js"
200
200
  },
201
+ "./plus/integrations/constants.js": {
202
+ "types": "./dist/plus/integrations/constants.d.ts",
203
+ "default": "./dist/plus/integrations/constants.js"
204
+ },
201
205
  "./plus/integrations/index.js": {
202
206
  "types": "./dist/plus/integrations/index.d.ts",
203
207
  "default": "./dist/plus/integrations/index.js"
@@ -1 +0,0 @@
1
- {"version":3,"file":"integrationAuthenticationProvider.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/integrationAuthenticationProvider.ts"],"sourcesContent":["import { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { Sources } from '../telemetry.js';\nimport { areDomainsOnSameHost } from '../utils/domain.utils.js';\nimport { isNonExpiringZeroTokenIntegrationId, isSelfManagedHostIntegrationId } from '../utils/integration.utils.js';\nimport type { ConfiguredIntegrationService } from './configuredIntegrationService.js';\nimport type { IntegrationAuthenticationService } from './integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession } from './models.js';\nimport { isSupportedCloudIntegrationId } from './models.js';\n\nconst maxSmallIntegerV8 = 2 ** 30 - 1; // Max number that can be stored in V8's smis (small integers)\n\nexport interface IntegrationAuthenticationProviderDescriptor {\n\tid: IntegrationIds;\n\tscopes: string[];\n}\n\nexport interface IntegrationAuthenticationSessionDescriptor {\n\tdomain: string;\n\tscopes: string[];\n\t/** When set, reads/deletes only the matching storage variant. */\n\tcloud?: boolean;\n\t/**\n\t * Targets a specific connection when a provider has multiple accounts connected. When omitted,\n\t * operations resolve to the provider's primary connection (see\n\t * {@link ConfiguredIntegrationService.resolveConnectionId}).\n\t */\n\tconnectionId?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Options for {@link IntegrationAuthenticationProvider.getSession}. The two variants keep `sync` exclusive\n * with the interactive flags: a sync resolves whatever the cloud already has, so it must never open a connect\n * window.\n *\n * `refreshRejectedToken` marks the stored token as known-refused by the provider (an `AuthenticationError` on\n * a previous read), which forces a cloud `/refresh` even when the token's expiry still claims it is valid —\n * the case a purely time-based refresh cannot see. The refresh token itself never reaches the client: the GK\n * cloud performs the exchange server-side.\n *\n * `refetch` (sync only) fetches a fresh token instead of serving the stored one, WITHOUT deleting the stored one\n * first: it is replaced only once the fetch returns a session. A forced re-sync used to delete it up front, so a\n * fetch that failed transiently (a GK API 429 or 5xx) left the connection with no token at all, and every read\n * until the next good sync reported it as gone (gitkraken/kepler#3546).\n */\ntype RejectedTokenRefreshOptions = {\n\trefreshRejectedToken?: boolean;\n\t/** A captured rejection only applies while the session still carries the credential GitHub refused. */\n\tisRejectedToken?: (accessToken: string | undefined) => boolean;\n};\n\nexport type GetSessionOptions = RejectedTokenRefreshOptions &\n\t(\n\t\t| {\n\t\t\t\tcreateIfNeeded?: boolean;\n\t\t\t\tforceNewSession?: boolean;\n\t\t\t\tsync?: never;\n\t\t\t\trefetch?: never;\n\t\t\t\tsource?: Sources;\n\t\t }\n\t\t| {\n\t\t\t\tcreateIfNeeded?: never;\n\t\t\t\tforceNewSession?: never;\n\t\t\t\tsync: boolean;\n\t\t\t\trefetch?: boolean;\n\t\t\t\tsource?: Sources;\n\t\t }\n\t);\n\n/**\n * What {@link IntegrationAuthenticationProviderBase.getSession} passes down once it has decided the stored\n * session can't be served as-is. `refreshIfExpired` is its own conclusion, not a caller's option.\n */\ntype GetNewSessionOptions = GetSessionOptions & { refreshIfExpired?: boolean };\n\nexport interface IntegrationAuthenticationProvider extends Disposable {\n\t/**\n\t * Clears the stored secret for one connection only (never the whole provider). Unlike\n\t * {@link deleteAllSessions}, this by default leaves the descriptor in `integrations:configured` — its\n\t * primary caller is a forced re-sync, which needs `getConfigured()` to keep reporting the connection\n\t * while a fresh session is fetched to replace the deleted secret. Implementers should not treat this as\n\t * a full disconnect. Pass `preserveConfigured: false` to also drop the descriptor (e.g. when the\n\t * re-sync's replacement fetch failed and the connection should no longer be reported as connected).\n\t */\n\tdeleteSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: { preserveConfigured?: boolean; signOutMark?: number },\n\t): Promise<void>;\n\tdeleteAllSessions(descriptor?: IntegrationAuthenticationSessionDescriptor): Promise<void>;\n\t/**\n\t * Resolves the session for `descriptor`, from storage when it is still usable and from the cloud\n\t * otherwise. See {@link GetSessionOptions}.\n\t */\n\tgetSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: GetSessionOptions,\n\t): Promise<ProviderAuthenticationSession | undefined>;\n\tget onDidChange(): Event<void>;\n}\n\nabstract class IntegrationAuthenticationProviderBase<\n\tID extends IntegrationIds = IntegrationIds,\n> implements IntegrationAuthenticationProvider {\n\tprotected readonly disposables: Disposable[] = [];\n\n\tconstructor(\n\t\tprotected readonly authenticationService: IntegrationAuthenticationService,\n\t\tprotected readonly configuredIntegrationService: ConfiguredIntegrationService,\n\t) {}\n\n\tdispose(): void {\n\t\tthis.disposables.forEach(d => d.dispose());\n\t}\n\n\tprivate readonly _onDidChange = new Emitter<void>();\n\tget onDidChange(): Event<void> {\n\t\treturn this._onDidChange.event;\n\t}\n\n\tprotected abstract get authProviderId(): ID;\n\n\t@trace()\n\tasync deleteSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: { preserveConfigured?: boolean; signOutMark?: number },\n\t): Promise<void> {\n\t\tconst domain = isSelfManagedHostIntegrationId(this.authProviderId) ? descriptor?.domain : undefined;\n\t\tconst configured = this.configuredIntegrationService.getConfigured(this.authProviderId, {\n\t\t\tdomain: domain,\n\t\t});\n\n\t\t// Scope the descriptor to cloud so resolveConnectionId targets the cloud variant's id: this is a\n\t\t// cloud-only delete, and a mixed local+cloud connection whose local descriptor is primary would\n\t\t// otherwise resolve the local id and leave the cloud secret intact.\n\t\tconst deleted = await this.configuredIntegrationService.deleteStoredSessions(\n\t\t\tthis.authProviderId,\n\t\t\t{ ...descriptor, cloud: true },\n\t\t\ttrue,\n\t\t\t{ preserveConfigured: options?.preserveConfigured ?? true, signOutMark: options?.signOutMark },\n\t\t);\n\n\t\tif (deleted && configured?.length) {\n\t\t\tthis.fireChange();\n\t\t}\n\t}\n\n\t@trace()\n\tasync deleteAllSessions(descriptor?: IntegrationAuthenticationSessionDescriptor): Promise<void> {\n\t\t// Self-managed providers group every host under one provider id, so scope the clear to this\n\t\t// descriptor's host when given; for cloud providers the domain stays undefined here, clearing every account.\n\t\tconst domain = isSelfManagedHostIntegrationId(this.authProviderId) ? descriptor?.domain : undefined;\n\t\tconst configured = this.configuredIntegrationService.getConfigured(this.authProviderId, {\n\t\t\tdomain: domain,\n\t\t});\n\n\t\tawait this.configuredIntegrationService.deleteAllStoredSessions(this.authProviderId, undefined, domain);\n\n\t\tif (configured?.length) {\n\t\t\tthis.fireChange();\n\t\t}\n\t}\n\n\t@trace()\n\tasync getSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: GetSessionOptions,\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tlet session;\n\t\tlet previousToken;\n\t\tlet refetched: ProviderAuthenticationSession | undefined;\n\t\tlet signOutMark: number;\n\t\tif (options?.forceNewSession) {\n\t\t\tif (isSelfManagedHostIntegrationId(this.authProviderId)) {\n\t\t\t\tconst connectionId =\n\t\t\t\t\tdescriptor.connectionId ||\n\t\t\t\t\tthis.configuredIntegrationService.getConfiguredConnectionId(\n\t\t\t\t\t\tthis.authProviderId,\n\t\t\t\t\t\tdescriptor.domain,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\t!this.configuredIntegrationService.isConnectionConfiguredForHost(\n\t\t\t\t\t\tthis.authProviderId,\n\t\t\t\t\t\tconnectionId,\n\t\t\t\t\t\tdescriptor.domain,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tdescriptor = { ...descriptor, connectionId: connectionId };\n\t\t\t}\n\t\t\t// Cloud-only delete (see deleteSession): scope to cloud so the cloud variant's id is cleared even\n\t\t\t// when a mixed local+cloud connection's local descriptor is primary. A sign-out, so a token fetched before\n\t\t\t// it is not stored back; the mark is taken after it, so this session's own fetch is not refused.\n\t\t\tawait this.configuredIntegrationService.deleteStoredSessions(\n\t\t\t\tthis.authProviderId,\n\t\t\t\t{ ...descriptor, cloud: true },\n\t\t\t\ttrue,\n\t\t\t\t{ signOut: true, preserveConfigured: isSelfManagedHostIntegrationId(this.authProviderId) },\n\t\t\t);\n\t\t\tsignOutMark = this.configuredIntegrationService.getSignOutMark();\n\t\t} else {\n\t\t\t// Taken before the stored-token read (a sign-out landing during the read is ordered after it by the storage\n\t\t\t// lock, so it counts either way).\n\t\t\tsignOutMark = this.configuredIntegrationService.getSignOutMark();\n\t\t\tconst stored = await this.configuredIntegrationService.getStoredSession(\n\t\t\t\tthis.authProviderId,\n\t\t\t\toptions?.sync ? { ...descriptor, cloud: true } : descriptor,\n\t\t\t);\n\t\t\tpreviousToken = stored?.accessToken;\n\t\t\tif (options?.sync && options.refetch) {\n\t\t\t\trefetched = stored;\n\t\t\t} else {\n\t\t\t\tsession = stored;\n\t\t\t}\n\t\t}\n\n\t\tconst isExpiredSession = session?.expiresAt != null && new Date(session.expiresAt).getTime() < Date.now();\n\t\t// A rejected token has to re-resolve even when the stored session looks perfectly healthy: that is\n\t\t// the whole point — the provider refused it while its expiry still says valid. Without this the\n\t\t// stored session short-circuits here and the refresh below is never reached.\n\t\tconst scopedRecovery = options?.isRejectedToken?.(session?.accessToken) === true;\n\t\tconst refreshRejectedToken = scopedRecovery || (options?.refreshRejectedToken === true && session != null);\n\t\tif (session == null || isExpiredSession || refreshRejectedToken) {\n\t\t\tsession = await this.getNewSession(descriptor, {\n\t\t\t\t...options,\n\t\t\t\trefreshIfExpired: isExpiredSession,\n\t\t\t\trefreshRejectedToken: refreshRejectedToken,\n\t\t\t\tisRejectedToken: scopedRecovery ? options?.isRejectedToken : undefined,\n\t\t\t});\n\t\t\tif (\n\t\t\t\tsession == null &&\n\t\t\t\toptions?.refetch &&\n\t\t\t\trefetched != null &&\n\t\t\t\tthis.configuredIntegrationService.isSessionRetiredSince(this.authProviderId, refetched, signOutMark)\n\t\t\t) {\n\t\t\t\tthrow new CancellationError();\n\t\t\t}\n\n\t\t\tif (session != null) {\n\t\t\t\tconst stored = await this.configuredIntegrationService.storeSession(this.authProviderId, session, {\n\t\t\t\t\tsignOutMark: signOutMark,\n\t\t\t\t\texpectedStoredAccessToken: scopedRecovery ? previousToken : undefined,\n\t\t\t\t});\n\t\t\t\tif (!stored) {\n\t\t\t\t\t// A disconnect leaves no credential here. A recovery can leave a replacement for this same\n\t\t\t\t\t// connection, which a forced sync must not interpret as a disconnect and delete.\n\t\t\t\t\tsession = await this.configuredIntegrationService.getStoredSession(this.authProviderId, {\n\t\t\t\t\t\t...descriptor,\n\t\t\t\t\t\tconnectionId: session.id,\n\t\t\t\t\t\tcloud: session.cloud,\n\t\t\t\t\t});\n\t\t\t\t\toptions?.isRejectedToken?.(session?.accessToken);\n\t\t\t\t} else if (refetched?.id != null && refetched.id !== session.id) {\n\t\t\t\t\t// The replacement belongs to a different connection (the cloud's primary moved to another\n\t\t\t\t\t// account), so it was stored beside the one it replaces rather than over it. Drop the old token\n\t\t\t\t\t// as the up-front delete used to, or an unscoped read would keep resolving it until the next sync.\n\t\t\t\t\tawait this.configuredIntegrationService.deleteStoredSessions(\n\t\t\t\t\t\tthis.authProviderId,\n\t\t\t\t\t\t{ ...descriptor, connectionId: refetched.id, cloud: true },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t{ preserveConfigured: true },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (previousToken !== session?.accessToken) {\n\t\t\tthis.fireChange();\n\t\t}\n\n\t\treturn session;\n\t}\n\n\tprotected abstract getNewSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: GetNewSessionOptions,\n\t): Promise<ProviderAuthenticationSession | undefined>;\n\n\tprotected fireChange(): void {\n\t\tqueueMicrotask(() => this._onDidChange.fire());\n\t}\n}\n\nexport class CloudIntegrationAuthenticationProvider<\n\tID extends IntegrationIds = IntegrationIds,\n> extends IntegrationAuthenticationProviderBase<ID> {\n\tconstructor(\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tconfiguredIntegrationService: ConfiguredIntegrationService,\n\t\tprivate readonly _authProviderId: ID,\n\t) {\n\t\tsuper(authenticationService, configuredIntegrationService);\n\t}\n\n\tprotected get authProviderId(): ID {\n\t\treturn this._authProviderId;\n\t}\n\n\tprotected override async getNewSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: GetNewSessionOptions,\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tif (options?.forceNewSession) {\n\t\t\tif ((await this.disconnectCloudSession(descriptor)) === 'failure') {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tvoid this.connectCloudSession(false, options?.source);\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// TODO: This is a stopgap to make sure we're not hammering the api on automatic calls to get the session.\n\t\t// Ultimately we want to timestamp calls to syncCloudIntegrations and use that to determine whether we should\n\t\t// make the call or not.\n\t\t// `refreshRejectedToken` joins the list for the same reason `refreshIfExpired` is on it: both mean the\n\t\t// session in hand is known-unusable, so skipping the cloud round trip would just re-serve it.\n\t\tlet session =\n\t\t\toptions?.refreshIfExpired ||\n\t\t\toptions?.refreshRejectedToken ||\n\t\t\toptions?.createIfNeeded ||\n\t\t\toptions?.forceNewSession ||\n\t\t\toptions?.sync\n\t\t\t\t? await this.getCloudSession(descriptor, options)\n\t\t\t\t: undefined;\n\n\t\tconst shouldCreateSession = options?.createIfNeeded && session == null;\n\t\tif (shouldCreateSession) {\n\t\t\tconst connected = await this.connectCloudSession(true, options?.source);\n\t\t\tif (!connected) return undefined;\n\n\t\t\t// This should get us the session we just created with connectCloudSession, because a syncCloudIntegrations run from\n\t\t\t// integration service should have resulted in it being created and stored by this provider\n\t\t\tsession = await this.getSession(descriptor, { source: options?.source });\n\t\t}\n\t\treturn session;\n\t}\n\n\tprivate connectCloudSession(skipIfConnected: boolean, source: Sources | undefined): Promise<boolean> {\n\t\t// Capture in a const so the type guard narrows it to `SupportedCloudIntegrationIds` (a getter\n\t\t// access wouldn't narrow), letting us call the service directly without a cast.\n\t\tconst id = this.authProviderId;\n\t\tif (isSupportedCloudIntegrationId(id)) {\n\t\t\treturn this.authenticationService.connectCloudIntegrations(\n\t\t\t\t{ integrationIds: [id], skipIfConnected: skipIfConnected, skipPreSync: true },\n\t\t\t\t{\n\t\t\t\t\tsource: source ?? 'integrations',\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\taction: 'connect',\n\t\t\t\t\t\tintegration: id,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn Promise.resolve(false);\n\t}\n\n\tprivate async getCloudSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t\toptions?: RejectedTokenRefreshOptions,\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst loggedIn = (await this.authenticationService.ctx.account.getAccount()) != null;\n\t\tif (!loggedIn) return undefined;\n\n\t\tconst cloudIntegrations = this.authenticationService.cloudIntegrations;\n\t\t// An unscoped descriptor (no explicit connectionId) would fetch the provider-global primary via\n\t\t// `v1/provider-tokens/<provider>`. For a self-managed provider spanning multiple hosts that primary\n\t\t// can belong to a different host, so a forced sync of host A would hydrate host B's token here (before\n\t\t// reconcile corrects storage). Scope to this host's own configured connection when we have one; fall\n\t\t// through to the provider-scoped path only when nothing is configured yet (legacy/first sync).\n\t\tconst connectionId =\n\t\t\tdescriptor.connectionId ??\n\t\t\t(isSelfManagedHostIntegrationId(this.authProviderId)\n\t\t\t\t? this.configuredIntegrationService.getConfiguredConnectionId(\n\t\t\t\t\t\tthis.authProviderId,\n\t\t\t\t\t\tdescriptor.domain,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t)\n\t\t\t\t: undefined);\n\t\t// Refuses a session issued for a DIFFERENT host than the one this connection is keyed by, which would\n\t\t// otherwise let host B's token serve host A.\n\t\t//\n\t\t// A session that names no host is accepted ONLY when it was fetched by a connection id WE have stored\n\t\t// for this host. That descriptor is what ties the token to the host, so an absent domain then means the\n\t\t// backend did not say rather than that the token belongs elsewhere, and refusing it would strand the\n\t\t// refresh.\n\t\t//\n\t\t// A non-null id is not enough on its own: `descriptor.connectionId` can come from the caller, and with\n\t\t// no id at all the fetch goes to the provider-GLOBAL primary endpoint whose token can belong to any\n\t\t// configured host. In both of those cases a domainless response must be refused, or a token would be\n\t\t// bound to — and sent to — a host it was never issued for.\n\t\tconst scopedToThisHost = this.configuredIntegrationService.isConnectionConfiguredForHost(\n\t\t\tthis.authProviderId,\n\t\t\tconnectionId,\n\t\t\tdescriptor.domain,\n\t\t);\n\t\tconst isForAnotherHost = (session: { domain: string } | undefined) =>\n\t\t\tsession != null &&\n\t\t\tisSelfManagedHostIntegrationId(this.authProviderId) &&\n\t\t\t(!scopedToThisHost || Boolean(session.domain?.trim())) &&\n\t\t\t!areDomainsOnSameHost(session.domain, descriptor.domain);\n\n\t\tlet session = await cloudIntegrations.getConnectionSession(this.authProviderId, undefined, connectionId);\n\t\tif (isForAnotherHost(session)) return undefined;\n\t\tif (options?.isRejectedToken != null && session?.id != null && session.id !== connectionId) return undefined;\n\n\t\t// GitHub, the cloud self-managed hosts, and Trello return `expiresIn: 0` for a token that never\n\t\t// expires; left as 0 the session would be built with `expiresAt = now` and rejected as expired on the\n\t\t// next resolution. Map it to the maximum expiry so it isn't refreshed frequently.\n\t\tif (session?.expiresIn === 0 && isNonExpiringZeroTokenIntegrationId(this.authProviderId)) {\n\t\t\tsession.expiresIn = maxSmallIntegerV8; // maximum expiration length\n\t\t}\n\n\t\t// `expiresIn < 60` is a PREDICTION that the token is about to lapse, and it is the only trigger the\n\t\t// refresh used to have. It cannot see a token the provider has already refused while the backend\n\t\t// still believes it is valid — a revoked grant, retired scopes, an app removed from the org — where\n\t\t// `expiresIn` stays high and the doomed token is re-sent on every read. `refreshRejectedToken` is\n\t\t// the observed counterpart: the caller saw the provider reject this exact token, so refresh it\n\t\t// regardless of what its expiry claims.\n\t\tif (\n\t\t\tsession != null &&\n\t\t\t(session.expiresIn < 60 ||\n\t\t\t\t(options?.refreshRejectedToken && (options.isRejectedToken?.(session.accessToken) ?? true)))\n\t\t) {\n\t\t\tsession = await cloudIntegrations.getConnectionSession(\n\t\t\t\tthis.authProviderId,\n\t\t\t\tsession.accessToken,\n\t\t\t\tconnectionId,\n\t\t\t);\n\t\t\tif (isForAnotherHost(session)) return undefined;\n\t\t\tif (options?.isRejectedToken != null && session?.id != null && session.id !== connectionId) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (!session) return undefined;\n\n\t\tlet sessionProtocol;\n\t\t// Only derive a protocol from a domain carrying an explicit scheme; a bare `host:port` (e.g. a\n\t\t// self-managed `ghe.example.com:8443`) parses the host as the protocol, corrupting the value.\n\t\tif (/^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(session.domain)) {\n\t\t\ttry {\n\t\t\t\tsessionProtocol = new URL(session.domain).protocol;\n\t\t\t} catch {\n\t\t\t\tsessionProtocol = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t// Prefer the backend's per-connection token id (multi-account); fall back to the resolved\n\t\t\t// primary/legacy connection id so existing single-connection storage keys are preserved.\n\t\t\tid: session.id ?? this.configuredIntegrationService.resolveConnectionId(this.authProviderId, descriptor),\n\t\t\taccessToken: session.accessToken,\n\t\t\tscopes: descriptor.scopes,\n\t\t\taccount: {\n\t\t\t\tid: '',\n\t\t\t\tlabel: '',\n\t\t\t},\n\t\t\tcloud: true,\n\t\t\ttype: session.type,\n\t\t\texpiresAt: new Date(session.expiresIn * 1000 + Date.now()),\n\t\t\t// Note: do not use the session's domain, because the format is different than in our model\n\t\t\tdomain: descriptor.domain,\n\t\t\t// That format difference is exactly what `baseUrl` is for: the descriptor's domain is the\n\t\t\t// normalized host this connection is keyed by, so a context path only survives on the wire value.\n\t\t\t// When the backend reports no domain at all, KEEP the address already configured rather than\n\t\t\t// writing `undefined` — `writeSecret` mirrors this onto the descriptor, so falling back to the\n\t\t\t// bare host here would drop a context path the user never changed on the next refresh.\n\t\t\tbaseUrl:\n\t\t\t\tsession.domain ||\n\t\t\t\tthis.configuredIntegrationService.getConfiguredBaseUrl(\n\t\t\t\t\tthis.authProviderId,\n\t\t\t\t\tconnectionId,\n\t\t\t\t\tdescriptor.domain,\n\t\t\t\t),\n\t\t\tprotocol: sessionProtocol ?? undefined,\n\t\t\t// Carried for providers whose client needs an app key alongside the token (e.g. Trello).\n\t\t\tappKey: session.appKey,\n\t\t};\n\t}\n\n\tprivate async disconnectCloudSession(\n\t\tdescriptor: IntegrationAuthenticationSessionDescriptor,\n\t): Promise<'skip' | 'success' | 'failure'> {\n\t\tconst loggedIn = (await this.authenticationService.ctx.account.getAccount()) != null;\n\t\tif (!loggedIn) return 'skip';\n\n\t\tconst cloudIntegrations = this.authenticationService.cloudIntegrations;\n\t\tif (!(await cloudIntegrations.disconnect(this.authProviderId, descriptor.connectionId))) return 'failure';\n\n\t\tif (isSelfManagedHostIntegrationId(this.authProviderId)) {\n\t\t\tawait this.deleteSession(descriptor, { preserveConfigured: false });\n\t\t}\n\n\t\treturn 'success';\n\t}\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,oBAAoB,KAAK,KAAK;AA2FpC,IAAe,wCAAf,MAE+C;CAI1B;CACA;CAJpB,cAA+C,CAAC;CAEhD,YACC,uBACA,8BACC;EAFkB,KAAA,wBAAA;EACA,KAAA,+BAAA;CACjB;CAEH,UAAgB;EACf,KAAK,YAAY,SAAQ,MAAK,EAAE,QAAQ,CAAC;CAC1C;CAEA,eAAgC,IAAI,QAAc;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EACnB;EAGD,OAAO;GAGN,IAAI,QAAQ,MAAM,KAAK,6BAA6B,oBAAoB,KAAK,gBAAgB,UAAU;GACvG,aAAa,QAAQ;GACrB,QAAQ,WAAW;GACnB,SAAS;IACR,IAAI;IACJ,OAAO;GACR;GACA,OAAO;GACP,MAAM,QAAQ;GACd,WAAW,IAAI,KAAK,QAAQ,YAAY,MAAO,KAAK,IAAI,CAAC;GAEzD,QAAQ,WAAW;GAMnB,SACC,QAAQ,UACR,KAAK,6BAA6B,qBACjC,KAAK,gBACL,cACA,WAAW,MACZ;GACD,UAAU,mBAAmB,KAAA;GAE7B,QAAQ,QAAQ;EACjB;CACD;CAEA,MAAc,uBACb,YAC0C;EAE1C,IAAI,EADc,MAAM,KAAK,sBAAsB,IAAI,QAAQ,WAAW,KAAM,OACjE,OAAO;EAGtB,IAAI,CAAE,MADoB,KAAK,sBAAsB,kBACvB,WAAW,KAAK,gBAAgB,WAAW,YAAY,GAAI,OAAO;EAEhG,IAAI,+BAA+B,KAAK,cAAc,GACrD,MAAM,KAAK,cAAc,YAAY,EAAE,oBAAoB,MAAM,CAAC;EAGnE,OAAO;CACR;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"telemetry.js","names":[],"sources":["../../../../plus/integrations/src/telemetry.ts"],"sourcesContent":["/**\n * Telemetry-source types used by the integrations package.\n *\n * Mirrors the shape of the host's `Source` / `Sources` types from\n * `src/constants.telemetry.ts` but intentionally widens `source` to a plain\n * `string` so the package doesn't depend on the host's enumerated union.\n * The host passes its typed `Source` directly — TypeScript's structural\n * subtyping accepts the narrower type here.\n */\nexport type Source = {\n\tsource: string;\n\tcorrelationId?: string;\n\n\tdetail?: unknown;\n};\n\nexport type Sources = string;\n\n/**\n * Maps a telemetry `source`/`detail` to the `&context=` value the package appends when building\n * cloud-connect URLs. Owned here in the package (the host no longer carries a duplicate copy).\n */\nexport const sourceToContext: { [source: string]: string | undefined } = {\n\tlaunchpad: 'launchpad',\n};\n\nexport const detailToContext: { [detail: string]: string | undefined } = {\n\tmcp: 'mcp',\n};\n"],"mappings":";;;;;AAsBA,MAAa,kBAA4D,EACxE,WAAW,YACZ;AAEA,MAAa,kBAA4D,EACxE,KAAK,MACN"}