@kumori/aurora-backend-handler 1.1.4 → 1.1.6
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/helpers/user-helper.ts +27 -31
- package/package.json +1 -1
- package/websocket-manager.ts +25 -2
package/helpers/user-helper.ts
CHANGED
|
@@ -46,38 +46,34 @@ export const handleUserEvent = ({
|
|
|
46
46
|
if (!userTenants.includes(key)) {
|
|
47
47
|
const tenantToDelete = tenantsMap.get(key);
|
|
48
48
|
if (tenantToDelete) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const onlyOneUser = tenantToDelete.users.length === 1;
|
|
52
|
-
const isSoloOwner =
|
|
53
|
-
onlyOneUser && tenantToDelete.users[0].role === tenantRole.OWNER;
|
|
49
|
+
const onlyOneUser = tenantToDelete.users.length === 1;
|
|
50
|
+
const isSoloOwner = onlyOneUser && tenantToDelete.users[0].role === tenantRole.OWNER;
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
52
|
+
if (isSoloOwner) {
|
|
53
|
+
eventHelper.tenant.publish.deleted(tenantToDelete);
|
|
54
|
+
const tenantDeletedNotification: Notification = {
|
|
55
|
+
type: "success",
|
|
56
|
+
subtype: "tenant-deleted",
|
|
57
|
+
date: Date.now().toString(),
|
|
58
|
+
callToAction: false,
|
|
59
|
+
status: "unread",
|
|
60
|
+
data: {
|
|
61
|
+
tenant: tenantToDelete.name,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
eventHelper.notification.publish.creation(tenantDeletedNotification);
|
|
65
|
+
} else {
|
|
66
|
+
const userRemovedNotification: Notification = {
|
|
67
|
+
type: "info",
|
|
68
|
+
subtype: "user-removed-from-tenant",
|
|
69
|
+
date: Date.now().toString(),
|
|
70
|
+
callToAction: false,
|
|
71
|
+
status: "unread",
|
|
72
|
+
data: {
|
|
73
|
+
tenant: tenantToDelete.name,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
eventHelper.notification.publish.creation(userRemovedNotification);
|
|
81
77
|
}
|
|
82
78
|
deletedTenantKeys.push(key);
|
|
83
79
|
}
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -192,6 +192,7 @@ const REPORTING_ITERATIONS = 5;
|
|
|
192
192
|
const REPORTING_INTERVAL = 1000;
|
|
193
193
|
let hasLoadedReportingOnce = false;
|
|
194
194
|
let recentlyUpdatedServices = new Map<string, Service>();
|
|
195
|
+
let pendingTenantStatus = new Map<string, string>();
|
|
195
196
|
/**
|
|
196
197
|
* Helper function to safely stringify error objects
|
|
197
198
|
*/
|
|
@@ -639,6 +640,18 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
639
640
|
parseKeyPath,
|
|
640
641
|
eventHelper,
|
|
641
642
|
});
|
|
643
|
+
Object.entries(eventData.status.tenants).forEach(
|
|
644
|
+
([tenantId, tenantInfo]: [string, any]) => {
|
|
645
|
+
if (tenantInfo.status === "rejected") {
|
|
646
|
+
const tenant = tenantsMap.get(tenantId);
|
|
647
|
+
if (tenant) {
|
|
648
|
+
tenantsMap.set(tenantId, { ...tenant, status: "leaving" });
|
|
649
|
+
} else {
|
|
650
|
+
pendingTenantStatus.set(tenantId, "leaving");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
);
|
|
642
655
|
userData = userEventResult.userData;
|
|
643
656
|
tempProviders = userEventResult.tempProviders;
|
|
644
657
|
userEventResult.deletedTenantKeys.forEach((key) => {
|
|
@@ -850,6 +863,12 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
850
863
|
}
|
|
851
864
|
|
|
852
865
|
tenantsMap.set(entityId, newTenant);
|
|
866
|
+
if (pendingTenantStatus.has(entityId)) {
|
|
867
|
+
const pendingStatus = pendingTenantStatus.get(entityId)!;
|
|
868
|
+
tenantsMap.set(entityId, { ...newTenant, status: pendingStatus });
|
|
869
|
+
pendingTenantStatus.delete(entityId);
|
|
870
|
+
}
|
|
871
|
+
|
|
853
872
|
loadMarketplaceItemsForTenant(entityId, "") //TODO Move to helper
|
|
854
873
|
.then((items) => {
|
|
855
874
|
const tenant = tenantsMap.get(entityId);
|
|
@@ -952,13 +971,17 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
952
971
|
break;
|
|
953
972
|
|
|
954
973
|
case "ca":
|
|
955
|
-
const caResult = handleCAEvent(
|
|
974
|
+
const caResult = handleCAEvent(
|
|
975
|
+
eventData,
|
|
976
|
+
parentParts,
|
|
977
|
+
tenantsMap,
|
|
978
|
+
hasRequestingServices,
|
|
979
|
+
);
|
|
956
980
|
processResourceResult(
|
|
957
981
|
caResult,
|
|
958
982
|
tenantsMap,
|
|
959
983
|
pendingDomains,
|
|
960
984
|
eventHelper,
|
|
961
|
-
|
|
962
985
|
);
|
|
963
986
|
break;
|
|
964
987
|
|