@gitkraken/core-gitlens 0.52.0 → 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 +8 -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/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 +5 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +44 -20
- 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 +38 -25
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +376 -141
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +8 -2
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +34 -4
- 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 +13 -2
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +68 -30
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +8 -0
- package/dist/plus/integrations/integrationService.js +148 -36
- 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/publicIntegration.d.ts +0 -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/issueSorts.d.ts +0 -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 +2 -1
- package/dist/plus/integrations/providers/providersApi.js +2 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/docs/integrations.md +36 -0
- package/package.json +2 -2
|
@@ -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);
|
|
@@ -896,6 +905,62 @@ var IntegrationService = class {
|
|
|
896
905
|
return toJiraIssueWriteFailure(ex);
|
|
897
906
|
}
|
|
898
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
|
+
}
|
|
899
964
|
async writeIssue(options) {
|
|
900
965
|
if (options?.action !== "create" && options?.action !== "edit" && options?.action !== "set-state") return {
|
|
901
966
|
ok: false,
|
|
@@ -1122,7 +1187,16 @@ var IntegrationService = class {
|
|
|
1122
1187
|
}), 250);
|
|
1123
1188
|
}
|
|
1124
1189
|
async onSubscriptionChanged() {
|
|
1125
|
-
|
|
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: [] });
|
|
1126
1200
|
}
|
|
1127
1201
|
onUserCheckedIn(e) {
|
|
1128
1202
|
this.syncCloudIntegrations(Boolean(e?.force));
|
|
@@ -1229,38 +1303,60 @@ var IntegrationService = class {
|
|
|
1229
1303
|
for (const [domain, connectionId] of fallbackByDomain) if (!primaryByDomain.has(domain)) primaryByDomain.set(domain, connectionId);
|
|
1230
1304
|
return primaryByDomain;
|
|
1231
1305
|
}
|
|
1232
|
-
|
|
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) {
|
|
1233
1316
|
const scope = getScopedLogger();
|
|
1234
1317
|
const connectedIntegrations = /* @__PURE__ */ new Set();
|
|
1235
1318
|
const domainsById = /* @__PURE__ */ new Map();
|
|
1236
1319
|
const connectionsById = /* @__PURE__ */ new Map();
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
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.`);
|
|
1258
1346
|
}
|
|
1259
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();
|
|
1260
1352
|
const integrations = [];
|
|
1261
1353
|
for await (const integration of this.getSupportedCloudIntegrations(domainsById)) integrations.push(integration);
|
|
1262
|
-
|
|
1263
|
-
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);
|
|
1264
1360
|
this.ctx.hooks?.connection?.onConnectedChanged?.({ integrationIds: [...connectedIntegrations.values()] });
|
|
1265
1361
|
return connectedIntegrations;
|
|
1266
1362
|
}
|
|
@@ -1278,7 +1374,7 @@ var IntegrationService = class {
|
|
|
1278
1374
|
* multiple accounts on the same provider coexist. Only engages when the backend provides
|
|
1279
1375
|
* per-connection ids; otherwise the single-connection flow above already handled the primary.
|
|
1280
1376
|
*/
|
|
1281
|
-
async reconcileCloudConnections(id, connections, forceConnect) {
|
|
1377
|
+
async reconcileCloudConnections(id, connections, forceConnect, authority) {
|
|
1282
1378
|
const scope = getScopedLogger();
|
|
1283
1379
|
const identified = connections.filter((c) => c.id != null);
|
|
1284
1380
|
if (identified.length === 0) return;
|
|
@@ -1288,6 +1384,8 @@ var IntegrationService = class {
|
|
|
1288
1384
|
const syncEligibleIds = /* @__PURE__ */ new Set();
|
|
1289
1385
|
const syncedPrimaryIdsByDomain = /* @__PURE__ */ new Map();
|
|
1290
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));
|
|
1291
1389
|
const repointedDomains = /* @__PURE__ */ new Set();
|
|
1292
1390
|
const signOutMark = this.configuredIntegrationService.getSignOutMark();
|
|
1293
1391
|
const preparedConnections = await Promise.all(identified.map(async (connection) => {
|
|
@@ -1340,10 +1438,13 @@ var IntegrationService = class {
|
|
|
1340
1438
|
try {
|
|
1341
1439
|
if (!this.configuredIntegrationService.serializesCredentialAcquisition(id)) return await fetchConnection();
|
|
1342
1440
|
return await this.configuredIntegrationService.withCredentialAcquisition(id, connection.id, async () => {
|
|
1441
|
+
const acquisitionMark = this.configuredIntegrationService.getStoredWriteMark();
|
|
1343
1442
|
const prepared = await fetchConnection();
|
|
1344
1443
|
if (prepared == null) return void 0;
|
|
1345
1444
|
return await this.configuredIntegrationService.storeSession(id, prepared.providerSession, {
|
|
1346
1445
|
signOutMark,
|
|
1446
|
+
acquisitionMark,
|
|
1447
|
+
sync: authority,
|
|
1347
1448
|
resource: prepared.resource
|
|
1348
1449
|
}) ? {
|
|
1349
1450
|
...prepared,
|
|
@@ -1356,9 +1457,11 @@ var IntegrationService = class {
|
|
|
1356
1457
|
}
|
|
1357
1458
|
}));
|
|
1358
1459
|
for (const prepared of preparedConnections) {
|
|
1460
|
+
if (!authority.isCurrent()) return;
|
|
1359
1461
|
if (prepared == null) continue;
|
|
1360
1462
|
if (prepared.kind === "fetched" && !await this.configuredIntegrationService.storeSession(id, prepared.providerSession, {
|
|
1361
1463
|
signOutMark,
|
|
1464
|
+
sync: authority,
|
|
1362
1465
|
resource: prepared.resource
|
|
1363
1466
|
})) continue;
|
|
1364
1467
|
syncedIds.add(prepared.connection.id);
|
|
@@ -1369,13 +1472,21 @@ var IntegrationService = class {
|
|
|
1369
1472
|
}
|
|
1370
1473
|
const prunedDomains = /* @__PURE__ */ new Set();
|
|
1371
1474
|
if ([...syncEligibleIds].every((connectionId) => syncedIds.has(connectionId))) {
|
|
1372
|
-
const
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
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);
|
|
1377
1484
|
}
|
|
1378
|
-
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;
|
|
1379
1490
|
const primaryAfter = this.getCloudPrimaryConnectionIdsByDomain(id);
|
|
1380
1491
|
const domains = new Set(primaryBefore.keys());
|
|
1381
1492
|
for (const domain of primaryAfter.keys()) domains.add(domain);
|
|
@@ -1466,7 +1577,8 @@ __decorate([debug({ args: (integrationIds) => ({ integrationIds: integrationIds?
|
|
|
1466
1577
|
__decorate([trace({ args: (remoteOrRemotes) => ({ remoteOrRemotes: Array.isArray(remoteOrRemotes) ? remoteOrRemotes.map((rp) => rp.name) : remoteOrRemotes.name }) })], IntegrationService.prototype, "getMyPullRequestsForRemotes", null);
|
|
1467
1578
|
__decorate([debug()], IntegrationService.prototype, "manageCloudIntegrations", null);
|
|
1468
1579
|
__decorate([debug()], IntegrationService.prototype, "reset", null);
|
|
1469
|
-
__decorate([gate()
|
|
1580
|
+
__decorate([gate()], IntegrationService.prototype, "queueCloudSync", null);
|
|
1581
|
+
__decorate([trace()], IntegrationService.prototype, "syncCloudIntegrationsCore", null);
|
|
1470
1582
|
/** Internal factory used by the GitLens host and integration tests that need the full service surface. */
|
|
1471
1583
|
function createIntegrationService(ctx) {
|
|
1472
1584
|
const configured = new ConfiguredIntegrationService(ctx);
|