@kumori/aurora-backend-handler 1.1.57 → 1.1.59
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.
|
@@ -169,11 +169,14 @@ export const syncAccountStatusFromNotifications = (
|
|
|
169
169
|
const accountName: string = notification.data?.account;
|
|
170
170
|
if (!accountName) continue;
|
|
171
171
|
|
|
172
|
-
const
|
|
172
|
+
const accountTenant: string = notification.data?.tenant ?? "";
|
|
173
|
+
const accountKey = accountTenant ? `${accountTenant}/${accountName}` : accountName;
|
|
174
|
+
|
|
175
|
+
const account = accountsMap.get(accountKey);
|
|
173
176
|
if (!account || ACCOUNT_ERROR_STATUSES.has(account.status)) continue;
|
|
174
177
|
|
|
175
178
|
const code: string = notification.info_content?.code ?? "";
|
|
176
|
-
accountsMap.set(
|
|
179
|
+
accountsMap.set(accountKey, {
|
|
177
180
|
...account,
|
|
178
181
|
status: resolveErrorStatus(code),
|
|
179
182
|
});
|
|
@@ -194,7 +197,8 @@ export const handleAccountEvent = ({
|
|
|
194
197
|
extractCloudProviderCredentials(eventData);
|
|
195
198
|
const accountLabels: Record<string, string> = eventData.meta.labels;
|
|
196
199
|
const hasCredentials = "__axebow::managedCredentials" in accountLabels;
|
|
197
|
-
const
|
|
200
|
+
const accountKey = accountTenantId ? `${accountTenantId}/${entityId}` : entityId;
|
|
201
|
+
const existingAccount = accountsMap.get(accountKey);
|
|
198
202
|
const accountStatus = determineAccountStatus(eventData, existingAccount);
|
|
199
203
|
|
|
200
204
|
const newAccount: Account = {
|
|
@@ -357,7 +361,6 @@ export const handleAccountOperationError = ({
|
|
|
357
361
|
const notification: Notification = {
|
|
358
362
|
type: "error",
|
|
359
363
|
subtype: errEntry.subtype,
|
|
360
|
-
title: errEntry.title,
|
|
361
364
|
date: Date.now().toString(),
|
|
362
365
|
status: "unread",
|
|
363
366
|
info_content: {
|
|
@@ -56,7 +56,8 @@ export const handleEnvironmentEvent = ({
|
|
|
56
56
|
}: HandleEnvironmentEventParams): HandleEnvironmentEventResult => {
|
|
57
57
|
const tenantId = parentParts.tenant;
|
|
58
58
|
const accountId = parentParts.account;
|
|
59
|
-
const
|
|
59
|
+
const accountKey = tenantId ? `${tenantId}/${accountId}` : accountId;
|
|
60
|
+
const relatedAccount = accountsMap.get(accountKey);
|
|
60
61
|
let cloudProviderName = relatedAccount?.cloudProvider?.name || "";
|
|
61
62
|
|
|
62
63
|
let pendingCloudProviderUpdate: { environmentId: string; accountId: string } | null = null;
|
|
@@ -68,7 +69,8 @@ export const handleEnvironmentEvent = ({
|
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
const
|
|
72
|
+
const envKey = tenantId && accountId ? `${tenantId}/${accountId}/${entityId}` : entityId;
|
|
73
|
+
const existingEnvironment = environmentsMap.get(envKey);
|
|
72
74
|
|
|
73
75
|
const newEnvironment: Environment = {
|
|
74
76
|
id: entityId,
|
|
@@ -250,7 +252,6 @@ export const handleEnvironmentOperationError = ({
|
|
|
250
252
|
const envErrorNotification: Notification = {
|
|
251
253
|
type: "error",
|
|
252
254
|
subtype: envErrEntry.subtype,
|
|
253
|
-
title: envErrEntry.title,
|
|
254
255
|
date: Date.now().toString(),
|
|
255
256
|
status: "unread",
|
|
256
257
|
info_content: {
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -676,7 +676,8 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
676
676
|
envEventResult.pendingCloudProviderUpdate,
|
|
677
677
|
);
|
|
678
678
|
}
|
|
679
|
-
|
|
679
|
+
const envSetKey = parentParts.tenant && parentParts.account ? `${parentParts.tenant}/${parentParts.account}/${entityId}` : entityId;
|
|
680
|
+
environmentsMap.set(envSetKey, envEventResult.environment);
|
|
680
681
|
const envTenant = tenantsMap.get(envEventResult.tenantId);
|
|
681
682
|
if (!envTenant) {
|
|
682
683
|
pendingEnvironments.push({
|
|
@@ -710,12 +711,16 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
710
711
|
}
|
|
711
712
|
if (revisionResult.updatedEnvironment) {
|
|
712
713
|
const envId = revisionResult.updatedService?.environment;
|
|
713
|
-
|
|
714
|
-
|
|
714
|
+
const envRevTenant = revisionResult.updatedEnvironment.tenant;
|
|
715
|
+
const envRevAccount = revisionResult.updatedEnvironment.account;
|
|
716
|
+
const envRevKey = envRevTenant && envRevAccount && envId ? `${envRevTenant}/${envRevAccount}/${envId}` : envId;
|
|
717
|
+
if (envRevKey) environmentsMap.set(envRevKey, revisionResult.updatedEnvironment);
|
|
715
718
|
}
|
|
716
719
|
if (revisionResult.updatedAccount) {
|
|
717
720
|
const accId = revisionResult.updatedService?.account;
|
|
718
|
-
|
|
721
|
+
const accRevTenant = revisionResult.updatedAccount.tenant;
|
|
722
|
+
const accRevKey = accRevTenant && accId ? `${accRevTenant}/${accId}` : accId;
|
|
723
|
+
if (accRevKey) accountsMap.set(accRevKey, revisionResult.updatedAccount);
|
|
719
724
|
}
|
|
720
725
|
if (revisionResult.pendingRevisionError) {
|
|
721
726
|
pendingRevisionErrors.push(revisionResult.pendingRevisionError);
|
|
@@ -808,7 +813,8 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
808
813
|
});
|
|
809
814
|
|
|
810
815
|
if (!message.payload.deleted) {
|
|
811
|
-
|
|
816
|
+
const accountKey = parentParts.tenant ? `${parentParts.tenant}/${entityId}` : entityId;
|
|
817
|
+
accountsMap.set(accountKey, accountResult.account);
|
|
812
818
|
updateEnvironmentsCloudProvider(entityId, eventData.spec.api);
|
|
813
819
|
}
|
|
814
820
|
break;
|
|
@@ -1395,16 +1401,18 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1395
1401
|
originalData: originalData as Account,
|
|
1396
1402
|
});
|
|
1397
1403
|
|
|
1404
|
+
const accTenant = (originalData as Account)?.tenant;
|
|
1405
|
+
const accSuccessKey = accTenant ? `${accTenant}/${entityName}` : entityName;
|
|
1398
1406
|
if (accSuccessResult.shouldDelete) {
|
|
1399
|
-
const acc = accountsMap.get(
|
|
1407
|
+
const acc = accountsMap.get(accSuccessKey);
|
|
1400
1408
|
if (acc) {
|
|
1401
|
-
accountsMap.delete(
|
|
1409
|
+
accountsMap.delete(accSuccessKey);
|
|
1402
1410
|
eventHelper.notification.publish.creation(
|
|
1403
1411
|
accSuccessResult.notification,
|
|
1404
1412
|
);
|
|
1405
1413
|
}
|
|
1406
1414
|
} else if (accSuccessResult.updatedAccount) {
|
|
1407
|
-
accountsMap.set(
|
|
1415
|
+
accountsMap.set(accSuccessKey, accSuccessResult.updatedAccount);
|
|
1408
1416
|
if (accSuccessResult.eventType === "created") {
|
|
1409
1417
|
eventHelper.account.publish.created(accSuccessResult.updatedAccount);
|
|
1410
1418
|
} else if (accSuccessResult.eventType === "updated") {
|
|
@@ -1423,10 +1431,12 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1423
1431
|
originalData: originalData as Environment,
|
|
1424
1432
|
});
|
|
1425
1433
|
|
|
1434
|
+
const envOrigData = originalData as Environment;
|
|
1435
|
+
const envSuccessKey = envOrigData?.tenant && envOrigData?.account ? `${envOrigData.tenant}/${envOrigData.account}/${entityName}` : entityName;
|
|
1426
1436
|
if (envSuccessResult.shouldDelete) {
|
|
1427
|
-
environmentsMap.delete(
|
|
1437
|
+
environmentsMap.delete(envSuccessKey);
|
|
1428
1438
|
} else if (envSuccessResult.updatedEnvironment) {
|
|
1429
|
-
environmentsMap.set(
|
|
1439
|
+
environmentsMap.set(envSuccessKey, envSuccessResult.updatedEnvironment);
|
|
1430
1440
|
if (envSuccessResult.notification) {
|
|
1431
1441
|
eventHelper.notification.publish.creation(
|
|
1432
1442
|
envSuccessResult.notification,
|
|
@@ -1527,10 +1537,12 @@ const handleOperationError = (operation: PendingOperation, error: any) => {
|
|
|
1527
1537
|
error,
|
|
1528
1538
|
});
|
|
1529
1539
|
|
|
1540
|
+
const accErrorTenant = (originalData as Account)?.tenant;
|
|
1541
|
+
const accErrorKey = accErrorTenant ? `${accErrorTenant}/${entityName}` : entityName;
|
|
1530
1542
|
if (accErrorResult.shouldDelete) {
|
|
1531
|
-
accountsMap.delete(
|
|
1543
|
+
accountsMap.delete(accErrorKey);
|
|
1532
1544
|
} else if (accErrorResult.updatedAccount) {
|
|
1533
|
-
accountsMap.set(
|
|
1545
|
+
accountsMap.set(accErrorKey, accErrorResult.updatedAccount);
|
|
1534
1546
|
}
|
|
1535
1547
|
|
|
1536
1548
|
if (accErrorResult.eventType === "creationError") {
|
|
@@ -1557,7 +1569,9 @@ const handleOperationError = (operation: PendingOperation, error: any) => {
|
|
|
1557
1569
|
eventHelper.environment.publish.deletionError(originalData);
|
|
1558
1570
|
}
|
|
1559
1571
|
eventHelper.notification.publish.creation(envErrorResult.notification);
|
|
1560
|
-
|
|
1572
|
+
const envErrOrigData = originalData as Environment;
|
|
1573
|
+
const envErrorKey = envErrOrigData?.tenant && envErrOrigData?.account ? `${envErrOrigData.tenant}/${envErrOrigData.account}/${entityName}` : entityName;
|
|
1574
|
+
environmentsMap.set(envErrorKey, envErrorResult.updatedEnvironment);
|
|
1561
1575
|
break;
|
|
1562
1576
|
}
|
|
1563
1577
|
setTimeout(async () => {
|
|
@@ -1588,7 +1602,8 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1588
1602
|
}
|
|
1589
1603
|
if (keyParts.environment && !keyParts.service) {
|
|
1590
1604
|
const environmentName = keyParts.environment;
|
|
1591
|
-
const
|
|
1605
|
+
const envDeleteKey = tenantName && keyParts.account ? `${tenantName}/${keyParts.account}/${environmentName}` : environmentName;
|
|
1606
|
+
const deletedEnv = environmentsMap.get(envDeleteKey)!;
|
|
1592
1607
|
eventHelper.environment.publish.deleted(deletedEnv);
|
|
1593
1608
|
const envNotification: Notification = {
|
|
1594
1609
|
type: "success",
|
|
@@ -1603,11 +1618,12 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1603
1618
|
},
|
|
1604
1619
|
};
|
|
1605
1620
|
eventHelper.notification.publish.creation(envNotification);
|
|
1606
|
-
environmentsMap.delete(
|
|
1621
|
+
environmentsMap.delete(envDeleteKey);
|
|
1607
1622
|
}
|
|
1608
1623
|
if (keyParts.account && !keyParts.environment) {
|
|
1609
1624
|
const accountName = keyParts.account;
|
|
1610
|
-
const
|
|
1625
|
+
const accountDeleteKey = tenantName ? `${tenantName}/${accountName}` : accountName;
|
|
1626
|
+
const deletedAccount = accountsMap.get(accountDeleteKey)!;
|
|
1611
1627
|
eventHelper.account.publish.deleted(deletedAccount);
|
|
1612
1628
|
const accountNotification: Notification = {
|
|
1613
1629
|
type: "success",
|
|
@@ -1621,7 +1637,7 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1621
1637
|
},
|
|
1622
1638
|
};
|
|
1623
1639
|
eventHelper.notification.publish.creation(accountNotification);
|
|
1624
|
-
accountsMap.delete(
|
|
1640
|
+
accountsMap.delete(accountDeleteKey);
|
|
1625
1641
|
}
|
|
1626
1642
|
if (keyParts.domain) {
|
|
1627
1643
|
const domainName = keyParts.domain;
|
|
@@ -1901,7 +1917,8 @@ const loadReportingForEnvironment = async (environment: Environment) => {
|
|
|
1901
1917
|
reportingData !== null &&
|
|
1902
1918
|
Array.isArray(reportingData)
|
|
1903
1919
|
) {
|
|
1904
|
-
const
|
|
1920
|
+
const envReportKey = environment.tenant && environment.account ? `${environment.tenant}/${environment.account}/${environment.id}` : environment.id;
|
|
1921
|
+
const updatedEnvironment = environmentsMap.get(envReportKey);
|
|
1905
1922
|
|
|
1906
1923
|
if (!updatedEnvironment) {
|
|
1907
1924
|
console.warn(`Environment ${environment.id} not found in map`);
|
|
@@ -1932,7 +1949,7 @@ const loadReportingForEnvironment = async (environment: Environment) => {
|
|
|
1932
1949
|
);
|
|
1933
1950
|
}
|
|
1934
1951
|
|
|
1935
|
-
environmentsMap.set(
|
|
1952
|
+
environmentsMap.set(envReportKey, updatedEnvironment);
|
|
1936
1953
|
}
|
|
1937
1954
|
} catch (error) {
|
|
1938
1955
|
console.error(
|