@gitkraken/core-gitlens 0.51.1 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/dist/_types/provider-apis/types/exportedTypes/github.d.ts +75 -0
- package/dist/_types/provider-apis/types/exportedTypes/types.d.ts +7 -0
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/issueWrites.js +1 -1
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +10 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +75 -23
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.d.ts +49 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js +118 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +45 -25
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +409 -141
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +12 -3
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +39 -7
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +6 -0
- package/dist/plus/integrations/authentication/models.js +9 -1
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.d.ts +17 -2
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +84 -16
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +9 -0
- package/dist/plus/integrations/integrationService.js +182 -39
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +3 -0
- package/dist/plus/integrations/models/integration.d.ts +4 -0
- package/dist/plus/integrations/models/integration.js +61 -16
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueRelationships.d.ts +31 -0
- package/dist/plus/integrations/models/issueRelationships.js +0 -0
- package/dist/plus/integrations/models/workItemWrites.d.ts +34 -2
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +4 -3
- package/dist/plus/integrations/providers/azureDevOps.js +6 -6
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +3 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js +14 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.d.ts +4 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +34 -2
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.d.ts +5 -2
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +57 -14
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +8 -0
- package/dist/plus/integrations/providers/github.js +162 -2
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.d.ts +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +33 -14
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providerErrors.d.ts +1 -0
- package/dist/plus/integrations/providers/providerErrors.js +1 -2
- package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +10 -4
- package/dist/plus/integrations/providers/providersApi.js +21 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +61 -0
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ import { ConfiguredIntegrationDescriptor, SessionPublication } from "./authentic
|
|
|
13
13
|
import { CloudGitSelfManagedHostIntegrationIds, GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, SupportedCloudIntegrationIds } from "./constants.js";
|
|
14
14
|
import { Source } from "./telemetry.js";
|
|
15
15
|
import { AzurePullRequestCreateCapabilityOptions, AzurePullRequestCreateCapabilityResult, AzurePullRequestWriteOptions, AzurePullRequestWriteResult, AzurePullRequestWriteTargetOptions, AzurePullRequestWriteTargetResult } from "./models/azurePullRequestWrites.js";
|
|
16
|
+
import { CaptureRelationshipCurrency, IssueRelationshipWriteOptions, IssueRelationshipWriteResult, IssueRelationshipsOptions, IssueRelationshipsResult } from "./models/issueRelationships.js";
|
|
16
17
|
import { IssueTrackerCreateOptions, IssueTrackerCreateOptionsResult, IssueTrackerDeleteOptions, IssueTrackerIssueWriteOptions, IssueTrackerIssueWriteOptionsResult, IssueTrackerWriteOptions, IssueTrackerWriteResult, IssueTrackerWriteTargetOptions, IssueTrackerWriteTargetResult } from "./models/issueTrackerWrites.js";
|
|
17
18
|
import { WorkItemAddress, WorkItemCreateOptions, WorkItemCreateOptionsResult, WorkItemDeleteOptions, WorkItemDeleteResult, WorkItemWriteOptions, WorkItemWriteOptionsResult, WorkItemWriteResult, WorkItemWriteTargetOptions, WorkItemWriteTargetResult } from "./models/workItemWrites.js";
|
|
18
19
|
import { IssueFilter, SupportedFilters } from "./providerFilters.js";
|
|
@@ -537,6 +538,9 @@ export declare class IntegrationService implements Disposable, IntegrationManage
|
|
|
537
538
|
deleteIssueTrackerIssue(options: IssueTrackerDeleteOptions): Promise<IssueTrackerWriteResult>;
|
|
538
539
|
resolveIssueTrackerIssueWriteTarget(options: IssueTrackerWriteTargetOptions): Promise<IssueTrackerWriteTargetResult>;
|
|
539
540
|
private withJiraIssueWriter;
|
|
541
|
+
getIssueRelationships(options: IssueRelationshipsOptions, isHostSessionCurrent?: () => boolean, captureCurrency?: CaptureRelationshipCurrency): Promise<IssueRelationshipsResult>;
|
|
542
|
+
writeIssueRelationship(options: IssueRelationshipWriteOptions, isHostSessionCurrent?: () => boolean, captureCurrency?: CaptureRelationshipCurrency): Promise<IssueRelationshipWriteResult>;
|
|
543
|
+
private getIssueRelationshipConnection;
|
|
540
544
|
writeIssue(options: IssueWriteOptions): Promise<IssueWriteResult>;
|
|
541
545
|
deleteIssue(options: IssueDeleteOptions): Promise<IssueWriteResult>;
|
|
542
546
|
resolveIssueWriteTarget(options: IssueWriteTargetOptions): Promise<IssueWriteTargetResult>;
|
|
@@ -592,6 +596,7 @@ export declare class IntegrationService implements Disposable, IntegrationManage
|
|
|
592
596
|
private onAuthenticationSessionsChanged;
|
|
593
597
|
private onIntegrationConnectionChanged;
|
|
594
598
|
private onSubscriptionChanged;
|
|
599
|
+
private retireCloudAccount;
|
|
595
600
|
private onUserCheckedIn;
|
|
596
601
|
private _providersApi;
|
|
597
602
|
private getProvidersApi;
|
|
@@ -602,10 +607,14 @@ export declare class IntegrationService implements Disposable, IntegrationManage
|
|
|
602
607
|
private findCachedById;
|
|
603
608
|
private getCachedForDomain;
|
|
604
609
|
onSessionPublishing(id: IntegrationIds, publication: SessionPublication, domains: readonly (string | undefined)[]): void;
|
|
610
|
+
private isUnprovenRepoint;
|
|
605
611
|
private getConfiguredCloudConnection;
|
|
606
612
|
private getConfiguredConnectionDomain;
|
|
607
613
|
private getCloudPrimaryConnectionIdsByDomain;
|
|
614
|
+
private cloudSyncQueue;
|
|
608
615
|
private syncCloudIntegrations;
|
|
616
|
+
private queueCloudSync;
|
|
617
|
+
private syncCloudIntegrationsCore;
|
|
609
618
|
/**
|
|
610
619
|
* Whether the user has locally disconnected this provider/host. Mirrors the integration model's
|
|
611
620
|
* `connected:${key}` workspace flag (key = id for cloud, `${id}:${domain}` for self-managed), which is
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { filterMap, flatten } from "../../utils/iterable.js";
|
|
2
2
|
import { CancellationError, raceWithTimeout } from "../../utils/cancellation.js";
|
|
3
|
+
import { Logger as _logger } from "../../utils/logger.js";
|
|
3
4
|
import { getScopedLogger } from "../../utils/logger.scoped.js";
|
|
4
5
|
import { mapSettledBounded } from "../../utils/promise.js";
|
|
5
6
|
import { debug, trace } from "../../utils/decorators/log.js";
|
|
@@ -84,6 +85,9 @@ var IntegrationService = class {
|
|
|
84
85
|
if (domain != null && isSelfManagedHostIntegrationId(integrationId) && !areDomainsOnSameHost(integration.domain, domain)) continue;
|
|
85
86
|
integration.onSessionsRemoving(connectionId, cloud);
|
|
86
87
|
}
|
|
88
|
+
}), configuredIntegrationService.onCloudLogout((departing) => {
|
|
89
|
+
this.cloudSyncQueue = Promise.resolve();
|
|
90
|
+
for (const connection of departing) this.getCachedForDomain(connection.integrationId, connection.domain)?.onCloudConnectionRetired(connection.id, connection.retained);
|
|
87
91
|
}), ctx.config.onDidChange((e) => {
|
|
88
92
|
if (e.remotes) this._ignoreSSLErrors.clear();
|
|
89
93
|
}), ctx.account.onDidChangeSessions(this.onAuthenticationSessionsChanged, this), ctx.account.onDidCheckIn(this.onUserCheckedIn, this), ctx.account.onDidChange(this.onSubscriptionChanged, this), this._onDidChangeIntegrationConnection.event(this.onIntegrationConnectionChanged, this));
|
|
@@ -155,12 +159,17 @@ var IntegrationService = class {
|
|
|
155
159
|
let integration = this.getCached(id, domain);
|
|
156
160
|
if (integration == null) {
|
|
157
161
|
switch (id) {
|
|
158
|
-
case "github":
|
|
159
|
-
|
|
162
|
+
case "github": {
|
|
163
|
+
const { GitHubIntegration } = await import(
|
|
160
164
|
/* webpackChunkName: "integrations" */
|
|
161
165
|
"./providers/github.js"
|
|
162
|
-
)
|
|
166
|
+
);
|
|
167
|
+
if (this._disposed) throw new CancellationError();
|
|
168
|
+
const cached = this.getCached(id);
|
|
169
|
+
if (cached != null) return cached;
|
|
170
|
+
integration = new GitHubIntegration(this.ctx, this.authenticationService, this.getProvidersApi.bind(this), this._onDidChangeIntegrationConnection);
|
|
163
171
|
break;
|
|
172
|
+
}
|
|
164
173
|
case "cloud-github-enterprise":
|
|
165
174
|
if (domain == null) {
|
|
166
175
|
integration = this.findCachedById(id);
|
|
@@ -820,7 +829,7 @@ var IntegrationService = class {
|
|
|
820
829
|
return this.withWorkItemWriter(input, (writer) => writer.delete(input));
|
|
821
830
|
}
|
|
822
831
|
async withWorkItemWriter(input, run) {
|
|
823
|
-
if (input.providerId !== "azureDevOps") return {
|
|
832
|
+
if (input.providerId !== "azureDevOps" && input.providerId !== "azure-devops-server") return {
|
|
824
833
|
ok: false,
|
|
825
834
|
reason: "unsupported",
|
|
826
835
|
mutationDispatched: false
|
|
@@ -831,7 +840,12 @@ var IntegrationService = class {
|
|
|
831
840
|
mutationDispatched: false
|
|
832
841
|
};
|
|
833
842
|
try {
|
|
834
|
-
|
|
843
|
+
let writer;
|
|
844
|
+
if (input.providerId === "azureDevOps") writer = await (await this.get(input.providerId)).getWorkItemWriter(input);
|
|
845
|
+
else {
|
|
846
|
+
const integration = await this.getIntegrationForRead(input.providerId, input.connectionId, input.domain);
|
|
847
|
+
writer = integration?.id === "azure-devops-server" ? await integration.getWorkItemWriter(input) : void 0;
|
|
848
|
+
}
|
|
835
849
|
return writer == null ? {
|
|
836
850
|
ok: false,
|
|
837
851
|
reason: "no-connection",
|
|
@@ -891,6 +905,62 @@ var IntegrationService = class {
|
|
|
891
905
|
return toJiraIssueWriteFailure(ex);
|
|
892
906
|
}
|
|
893
907
|
}
|
|
908
|
+
async getIssueRelationships(options, isHostSessionCurrent, captureCurrency) {
|
|
909
|
+
if (options == null) return {
|
|
910
|
+
ok: false,
|
|
911
|
+
reason: "invalid-input"
|
|
912
|
+
};
|
|
913
|
+
const input = structuredClone(options);
|
|
914
|
+
const target = await this.getIssueRelationshipConnection(input, isHostSessionCurrent);
|
|
915
|
+
return target.ok ? target.integration.getIssueRelationships(input, target.isCurrent, captureCurrency) : target;
|
|
916
|
+
}
|
|
917
|
+
async writeIssueRelationship(options, isHostSessionCurrent, captureCurrency) {
|
|
918
|
+
if (options == null) return {
|
|
919
|
+
ok: false,
|
|
920
|
+
reason: "invalid-input",
|
|
921
|
+
mutationDispatched: false,
|
|
922
|
+
outcome: "not-sent"
|
|
923
|
+
};
|
|
924
|
+
const input = structuredClone(options);
|
|
925
|
+
if (input.action === "add" && input.replaceParent !== void 0 && !input.expectedConnectionProof) return {
|
|
926
|
+
ok: false,
|
|
927
|
+
reason: "invalid-input",
|
|
928
|
+
mutationDispatched: false,
|
|
929
|
+
outcome: "not-sent"
|
|
930
|
+
};
|
|
931
|
+
const target = await this.getIssueRelationshipConnection(input, isHostSessionCurrent);
|
|
932
|
+
return target.ok ? target.integration.writeIssueRelationship(input, target.isCurrent, captureCurrency) : {
|
|
933
|
+
...target,
|
|
934
|
+
mutationDispatched: false,
|
|
935
|
+
outcome: "not-sent"
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
async getIssueRelationshipConnection(options, isHostSessionCurrent) {
|
|
939
|
+
if (options.providerId !== "github") return {
|
|
940
|
+
ok: false,
|
|
941
|
+
reason: "unsupported"
|
|
942
|
+
};
|
|
943
|
+
const selectionCurrent = await this.configuredIntegrationService.captureConfiguredConnection(options.providerId, options.connectionId);
|
|
944
|
+
const target = await this.getGitHubWriteConnection(options, "issue");
|
|
945
|
+
if (this._disposed) return {
|
|
946
|
+
ok: false,
|
|
947
|
+
reason: "no-connection"
|
|
948
|
+
};
|
|
949
|
+
if (!target.ok) return target;
|
|
950
|
+
if (!selectionCurrent?.()) return {
|
|
951
|
+
ok: false,
|
|
952
|
+
reason: "no-connection"
|
|
953
|
+
};
|
|
954
|
+
if (target.integration.id !== "github") return {
|
|
955
|
+
ok: false,
|
|
956
|
+
reason: "unsupported"
|
|
957
|
+
};
|
|
958
|
+
return {
|
|
959
|
+
ok: true,
|
|
960
|
+
integration: target.integration,
|
|
961
|
+
isCurrent: () => selectionCurrent() && (isHostSessionCurrent == null || isHostSessionCurrent())
|
|
962
|
+
};
|
|
963
|
+
}
|
|
894
964
|
async writeIssue(options) {
|
|
895
965
|
if (options?.action !== "create" && options?.action !== "edit" && options?.action !== "set-state") return {
|
|
896
966
|
ok: false,
|
|
@@ -1117,7 +1187,16 @@ var IntegrationService = class {
|
|
|
1117
1187
|
}), 250);
|
|
1118
1188
|
}
|
|
1119
1189
|
async onSubscriptionChanged() {
|
|
1120
|
-
|
|
1190
|
+
const mark = this.configuredIntegrationService.beginCloudSync();
|
|
1191
|
+
if (await this.ctx.account.getAccount() == null) try {
|
|
1192
|
+
await this.retireCloudAccount(mark);
|
|
1193
|
+
} catch (ex) {
|
|
1194
|
+
_logger.error(ex, "IntegrationService.onSubscriptionChanged");
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
async retireCloudAccount(mark) {
|
|
1198
|
+
const logout = await this.configuredIntegrationService.retireCloudAccount(mark);
|
|
1199
|
+
if (!this._disposed && logout?.isCurrent()) this.ctx.hooks?.connection?.onConnectedChanged?.({ integrationIds: [] });
|
|
1121
1200
|
}
|
|
1122
1201
|
onUserCheckedIn(e) {
|
|
1123
1202
|
this.syncCloudIntegrations(Boolean(e?.force));
|
|
@@ -1200,6 +1279,10 @@ var IntegrationService = class {
|
|
|
1200
1279
|
integration.onSessionPublishing(publication);
|
|
1201
1280
|
}
|
|
1202
1281
|
}
|
|
1282
|
+
isUnprovenRepoint(id, connection) {
|
|
1283
|
+
const current = this.configuredIntegrationService.getConfigured(id, { cloud: true }).find((c) => c.id === connection.id)?.baseUrl;
|
|
1284
|
+
return current != null && Boolean(connection.domain?.trim()) && !sameConfiguredBaseUrl(current, connection.domain);
|
|
1285
|
+
}
|
|
1203
1286
|
getConfiguredCloudConnection(id, connectionId) {
|
|
1204
1287
|
const connection = this.configuredIntegrationService.getConfigured(id, { cloud: true }).find((c) => c.id === connectionId);
|
|
1205
1288
|
if (connection == null) throw new Error(`Connection '${connectionId}' is not configured for '${id}'`);
|
|
@@ -1220,38 +1303,60 @@ var IntegrationService = class {
|
|
|
1220
1303
|
for (const [domain, connectionId] of fallbackByDomain) if (!primaryByDomain.has(domain)) primaryByDomain.set(domain, connectionId);
|
|
1221
1304
|
return primaryByDomain;
|
|
1222
1305
|
}
|
|
1223
|
-
|
|
1306
|
+
cloudSyncQueue = Promise.resolve();
|
|
1307
|
+
syncCloudIntegrations(forceConnect) {
|
|
1308
|
+
return this.queueCloudSync(forceConnect, this.configuredIntegrationService.lastCloudLogout);
|
|
1309
|
+
}
|
|
1310
|
+
queueCloudSync(forceConnect, lastLogout) {
|
|
1311
|
+
const result = this.cloudSyncQueue.then(() => this.configuredIntegrationService.lastCloudLogout === lastLogout ? this.syncCloudIntegrationsCore(forceConnect) : void 0);
|
|
1312
|
+
this.cloudSyncQueue = result.then(() => {}, () => {});
|
|
1313
|
+
return result;
|
|
1314
|
+
}
|
|
1315
|
+
async syncCloudIntegrationsCore(forceConnect) {
|
|
1224
1316
|
const scope = getScopedLogger();
|
|
1225
1317
|
const connectedIntegrations = /* @__PURE__ */ new Set();
|
|
1226
1318
|
const domainsById = /* @__PURE__ */ new Map();
|
|
1227
1319
|
const connectionsById = /* @__PURE__ */ new Map();
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1320
|
+
const listMark = this.configuredIntegrationService.beginCloudSync();
|
|
1321
|
+
const account = await this.ctx.account.getAccount();
|
|
1322
|
+
if (this._disposed) return;
|
|
1323
|
+
if (account == null) {
|
|
1324
|
+
await this.retireCloudAccount(listMark);
|
|
1325
|
+
return connectedIntegrations;
|
|
1326
|
+
}
|
|
1327
|
+
const connections = await this.authenticationService.cloudIntegrations.getConnections();
|
|
1328
|
+
if (connections == null) return;
|
|
1329
|
+
for (const p of connections) {
|
|
1330
|
+
const integrationId = toIntegrationId[p.provider];
|
|
1331
|
+
if (integrationId == null) continue;
|
|
1332
|
+
connectedIntegrations.add(integrationId);
|
|
1333
|
+
const list = connectionsById.get(integrationId);
|
|
1334
|
+
if (list != null) list.push(p);
|
|
1335
|
+
else connectionsById.set(integrationId, [p]);
|
|
1336
|
+
if (p.domain?.length > 0) {
|
|
1337
|
+
const host = hostFromDomain(p.domain);
|
|
1338
|
+
if (host != null) {
|
|
1339
|
+
let domains = domainsById.get(integrationId);
|
|
1340
|
+
if (domains == null) {
|
|
1341
|
+
domains = /* @__PURE__ */ new Set();
|
|
1342
|
+
domainsById.set(integrationId, domains);
|
|
1343
|
+
}
|
|
1344
|
+
domains.add(host);
|
|
1345
|
+
} else scope?.warn(`Invalid domain for ${integrationId} integration: ${p.domain}. Ignoring.`);
|
|
1249
1346
|
}
|
|
1250
1347
|
}
|
|
1348
|
+
if ((await this.ctx.account.getAccount())?.id !== account.id || this._disposed) return;
|
|
1349
|
+
const authority = await this.configuredIntegrationService.acceptCloudSync(listMark, connectionsById);
|
|
1350
|
+
const currentConnections = () => new Set(this.configuredIntegrationService.getConfigured(void 0, { cloud: true }).map((c) => c.integrationId));
|
|
1351
|
+
if (authority == null) return currentConnections();
|
|
1251
1352
|
const integrations = [];
|
|
1252
1353
|
for await (const integration of this.getSupportedCloudIntegrations(domainsById)) integrations.push(integration);
|
|
1253
|
-
|
|
1254
|
-
await Promise.all(
|
|
1354
|
+
if (!authority.isCurrent()) return currentConnections();
|
|
1355
|
+
await Promise.all(integrations.map((integration) => integration.syncListedCloudConnection(this.getCloudConnectionState(integration, connectedIntegrations, domainsById), forceConnect, authority)));
|
|
1356
|
+
if (!authority.isCurrent()) return currentConnections();
|
|
1357
|
+
await Promise.all(Array.from(connectionsById, ([integrationId, connections]) => this.reconcileCloudConnections(integrationId, connections, forceConnect, authority)));
|
|
1358
|
+
if (!authority.isCurrent()) return currentConnections();
|
|
1359
|
+
for (const integration of integrations) if (this.configuredIntegrationService.hasNewCloudConnection(integration.id, integration.domain, listMark)) connectedIntegrations.add(integration.id);
|
|
1255
1360
|
this.ctx.hooks?.connection?.onConnectedChanged?.({ integrationIds: [...connectedIntegrations.values()] });
|
|
1256
1361
|
return connectedIntegrations;
|
|
1257
1362
|
}
|
|
@@ -1269,7 +1374,7 @@ var IntegrationService = class {
|
|
|
1269
1374
|
* multiple accounts on the same provider coexist. Only engages when the backend provides
|
|
1270
1375
|
* per-connection ids; otherwise the single-connection flow above already handled the primary.
|
|
1271
1376
|
*/
|
|
1272
|
-
async reconcileCloudConnections(id, connections, forceConnect) {
|
|
1377
|
+
async reconcileCloudConnections(id, connections, forceConnect, authority) {
|
|
1273
1378
|
const scope = getScopedLogger();
|
|
1274
1379
|
const identified = connections.filter((c) => c.id != null);
|
|
1275
1380
|
if (identified.length === 0) return;
|
|
@@ -1279,6 +1384,8 @@ var IntegrationService = class {
|
|
|
1279
1384
|
const syncEligibleIds = /* @__PURE__ */ new Set();
|
|
1280
1385
|
const syncedPrimaryIdsByDomain = /* @__PURE__ */ new Map();
|
|
1281
1386
|
const existingById = new Map(this.configuredIntegrationService.getConfigured(id, { cloud: true }).map((c) => [c.id, c]));
|
|
1387
|
+
const liveIds = new Set(identified.map((c) => c.id));
|
|
1388
|
+
const pruneCandidates = [...existingById.values()].filter((c) => !liveIds.has(c.id));
|
|
1282
1389
|
const repointedDomains = /* @__PURE__ */ new Set();
|
|
1283
1390
|
const signOutMark = this.configuredIntegrationService.getSignOutMark();
|
|
1284
1391
|
const preparedConnections = await Promise.all(identified.map(async (connection) => {
|
|
@@ -1298,9 +1405,17 @@ var IntegrationService = class {
|
|
|
1298
1405
|
host
|
|
1299
1406
|
};
|
|
1300
1407
|
if (baseUrlChanged && cached != null) repointedDomains.add(host);
|
|
1301
|
-
|
|
1408
|
+
const fetchConnection = async () => {
|
|
1302
1409
|
const session = await cloudIntegrations.getConnectionSession(id, void 0, connection.id);
|
|
1303
1410
|
if (session == null) return void 0;
|
|
1411
|
+
if (this.configuredIntegrationService.serializesCredentialAcquisition(id) && (session.id != null && session.id !== connection.id || Boolean(session.domain?.trim()) && !sameConfiguredBaseUrl(session.domain, connection.domain))) {
|
|
1412
|
+
scope?.warn(`Skipping connection '${connection.id}' for ${id}: token issued for another connection`);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (this.configuredIntegrationService.serializesCredentialAcquisition(id) && !session.domain?.trim() && this.isUnprovenRepoint(id, connection)) {
|
|
1416
|
+
scope?.warn(`Skipping connection '${connection.id}' for ${id}: token does not confirm its moved address`);
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1304
1419
|
let providerSession = toProviderSession(id, connection, session, host, cached?.baseUrl);
|
|
1305
1420
|
const existing = existingById.get(connection.id);
|
|
1306
1421
|
const accountName = normalizeAccountName(connection.accountName) ?? normalizeAccountName(existing?.accountName) ?? await this.resolveAccountName(id, host, providerSession);
|
|
@@ -1319,15 +1434,34 @@ var IntegrationService = class {
|
|
|
1319
1434
|
providerSession,
|
|
1320
1435
|
resource
|
|
1321
1436
|
};
|
|
1437
|
+
};
|
|
1438
|
+
try {
|
|
1439
|
+
if (!this.configuredIntegrationService.serializesCredentialAcquisition(id)) return await fetchConnection();
|
|
1440
|
+
return await this.configuredIntegrationService.withCredentialAcquisition(id, connection.id, async () => {
|
|
1441
|
+
const acquisitionMark = this.configuredIntegrationService.getStoredWriteMark();
|
|
1442
|
+
const prepared = await fetchConnection();
|
|
1443
|
+
if (prepared == null) return void 0;
|
|
1444
|
+
return await this.configuredIntegrationService.storeSession(id, prepared.providerSession, {
|
|
1445
|
+
signOutMark,
|
|
1446
|
+
acquisitionMark,
|
|
1447
|
+
sync: authority,
|
|
1448
|
+
resource: prepared.resource
|
|
1449
|
+
}) ? {
|
|
1450
|
+
...prepared,
|
|
1451
|
+
kind: "published"
|
|
1452
|
+
} : void 0;
|
|
1453
|
+
});
|
|
1322
1454
|
} catch (ex) {
|
|
1323
1455
|
scope?.warn(`Failed to sync connection '${connection.id}' for ${id}: ${ex instanceof Error ? ex.message : String(ex)}`);
|
|
1324
1456
|
return;
|
|
1325
1457
|
}
|
|
1326
1458
|
}));
|
|
1327
1459
|
for (const prepared of preparedConnections) {
|
|
1460
|
+
if (!authority.isCurrent()) return;
|
|
1328
1461
|
if (prepared == null) continue;
|
|
1329
1462
|
if (prepared.kind === "fetched" && !await this.configuredIntegrationService.storeSession(id, prepared.providerSession, {
|
|
1330
1463
|
signOutMark,
|
|
1464
|
+
sync: authority,
|
|
1331
1465
|
resource: prepared.resource
|
|
1332
1466
|
})) continue;
|
|
1333
1467
|
syncedIds.add(prepared.connection.id);
|
|
@@ -1338,13 +1472,21 @@ var IntegrationService = class {
|
|
|
1338
1472
|
}
|
|
1339
1473
|
const prunedDomains = /* @__PURE__ */ new Set();
|
|
1340
1474
|
if ([...syncEligibleIds].every((connectionId) => syncedIds.has(connectionId))) {
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1475
|
+
for (const descriptor of pruneCandidates) if (await this.configuredIntegrationService.deleteStoredSessions(id, {
|
|
1476
|
+
connectionId: descriptor.id,
|
|
1477
|
+
domain: descriptor.domain ?? "",
|
|
1478
|
+
cloud: true,
|
|
1479
|
+
scopes: []
|
|
1480
|
+
}, true, {
|
|
1481
|
+
unobservedSince: authority.mark,
|
|
1482
|
+
sync: authority
|
|
1483
|
+
})) prunedDomains.add(isSelfManagedHostIntegrationId(id) ? descriptor.domain : void 0);
|
|
1346
1484
|
}
|
|
1347
|
-
for (const connectionId of syncedPrimaryIdsByDomain
|
|
1485
|
+
for (const [domain, connectionId] of syncedPrimaryIdsByDomain) await this.configuredIntegrationService.setPrimaryConnection(id, connectionId, {
|
|
1486
|
+
sync: authority,
|
|
1487
|
+
domain
|
|
1488
|
+
});
|
|
1489
|
+
if (!authority.isCurrent()) return;
|
|
1348
1490
|
const primaryAfter = this.getCloudPrimaryConnectionIdsByDomain(id);
|
|
1349
1491
|
const domains = new Set(primaryBefore.keys());
|
|
1350
1492
|
for (const domain of primaryAfter.keys()) domains.add(domain);
|
|
@@ -1435,7 +1577,8 @@ __decorate([debug({ args: (integrationIds) => ({ integrationIds: integrationIds?
|
|
|
1435
1577
|
__decorate([trace({ args: (remoteOrRemotes) => ({ remoteOrRemotes: Array.isArray(remoteOrRemotes) ? remoteOrRemotes.map((rp) => rp.name) : remoteOrRemotes.name }) })], IntegrationService.prototype, "getMyPullRequestsForRemotes", null);
|
|
1436
1578
|
__decorate([debug()], IntegrationService.prototype, "manageCloudIntegrations", null);
|
|
1437
1579
|
__decorate([debug()], IntegrationService.prototype, "reset", null);
|
|
1438
|
-
__decorate([gate()
|
|
1580
|
+
__decorate([gate()], IntegrationService.prototype, "queueCloudSync", null);
|
|
1581
|
+
__decorate([trace()], IntegrationService.prototype, "syncCloudIntegrationsCore", null);
|
|
1439
1582
|
/** Internal factory used by the GitLens host and integration tests that need the full service surface. */
|
|
1440
1583
|
function createIntegrationService(ctx) {
|
|
1441
1584
|
const configured = new ConfiguredIntegrationService(ctx);
|