@kumori/aurora-backend-handler 1.1.103 → 1.1.104
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/package.json +1 -1
- package/websocket-manager.ts +14 -0
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { v7 as uuidv7 } from "uuid";
|
|
2
2
|
import { environment } from "./environment";
|
|
3
|
+
import { AccountStatus } from "@kumori/aurora-interfaces/enums/accountStatusEnum";
|
|
3
4
|
import {
|
|
4
5
|
Account,
|
|
5
6
|
Channel,
|
|
@@ -662,6 +663,17 @@ export const closeGlobalWebSocketConnection = () => {
|
|
|
662
663
|
});
|
|
663
664
|
};
|
|
664
665
|
|
|
666
|
+
const computePromotionInfo = (
|
|
667
|
+
tenants: Tenant[],
|
|
668
|
+
): { completedSteps: number; remainingDays: number } => {
|
|
669
|
+
const hasValidCredentialsAccount = tenants.some((tenant) =>
|
|
670
|
+
tenant.accounts?.some((account) => account.status === AccountStatus.ACTIVE),
|
|
671
|
+
);
|
|
672
|
+
const hasDeployedService = tenants.some((tenant) => tenant.services?.length > 0);
|
|
673
|
+
const completedSteps = (hasValidCredentialsAccount ? 1 : 0) + (hasDeployedService ? 1 : 0);
|
|
674
|
+
return { completedSteps, remainingDays: 7 };
|
|
675
|
+
};
|
|
676
|
+
|
|
665
677
|
const rebuildHierarchy = () => {
|
|
666
678
|
const preservedUserData = { ...userData };
|
|
667
679
|
|
|
@@ -716,6 +728,7 @@ const rebuildHierarchy = () => {
|
|
|
716
728
|
notifications: preservedUserData.notifications || [],
|
|
717
729
|
plans: preservedUserData.plans || [],
|
|
718
730
|
discoveryMethod: preservedUserData.discoveryMethod,
|
|
731
|
+
promotionInfo: computePromotionInfo(Array.from(tenantsMap.values())),
|
|
719
732
|
};
|
|
720
733
|
};
|
|
721
734
|
const handleEvent = async (message: WSMessage) => {
|
|
@@ -2151,6 +2164,7 @@ export const updateUserComplete = (updatedUserData: UserData): User => {
|
|
|
2151
2164
|
status: updatedUserData.status,
|
|
2152
2165
|
discoveryMethod:
|
|
2153
2166
|
updatedUserData.discoveryMethod || userData.discoveryMethod,
|
|
2167
|
+
promotionInfo: computePromotionInfo(updatedUserData.tenants || userData.tenants || []),
|
|
2154
2168
|
};
|
|
2155
2169
|
user = new User(
|
|
2156
2170
|
userData,
|