@kumori/aurora-backend-handler 1.0.131 → 1.0.132
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/token-helper.ts +15 -0
- package/package.json +1 -1
- package/websocket-manager.ts +22 -7
package/helpers/token-helper.ts
CHANGED
|
@@ -97,6 +97,21 @@ export const handleTokenEvent = ({
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
+
export const applyKnownTokenData = (
|
|
101
|
+
tokens: Token[],
|
|
102
|
+
tokenMap: Map<string, Token>
|
|
103
|
+
): Token[] =>
|
|
104
|
+
tokens.map((userToken) => {
|
|
105
|
+
const known = tokenMap.get(userToken.name);
|
|
106
|
+
if (!known) return userToken;
|
|
107
|
+
const token = known.token || userToken.token;
|
|
108
|
+
const lastUsed = known.lastUsed || userToken.lastUsed;
|
|
109
|
+
if (token === userToken.token && lastUsed === userToken.lastUsed) {
|
|
110
|
+
return userToken;
|
|
111
|
+
}
|
|
112
|
+
return { ...userToken, token, lastUsed };
|
|
113
|
+
});
|
|
114
|
+
|
|
100
115
|
interface HandleTokenOperationSuccessParams {
|
|
101
116
|
responsePayload: any;
|
|
102
117
|
}
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -73,6 +73,7 @@ import {
|
|
|
73
73
|
} from "./helpers/plan-helper";
|
|
74
74
|
import { handleRegistryEvent } from "./helpers/registry-helper";
|
|
75
75
|
import {
|
|
76
|
+
applyKnownTokenData,
|
|
76
77
|
handleTokenDeletion,
|
|
77
78
|
handleTokenEvent,
|
|
78
79
|
handleTokenOperationSuccess,
|
|
@@ -723,11 +724,13 @@ const rebuildHierarchy = () => {
|
|
|
723
724
|
notificationsEnabled: preservedUserData.notificationsEnabled,
|
|
724
725
|
organizations: Array.from(organizationsMap.values()),
|
|
725
726
|
clusterTokens: Array.from(clusterTokensMap.values()),
|
|
726
|
-
tokens: (
|
|
727
|
-
tokenMap.size > 0
|
|
727
|
+
tokens: applyKnownTokenData(
|
|
728
|
+
(tokenMap.size > 0
|
|
728
729
|
? (preservedUserData.tokens || []).filter(t => tokenMap.has(t.name))
|
|
729
730
|
: (preservedUserData.tokens || [])
|
|
730
|
-
|
|
731
|
+
).filter(t => !deletedTokenIds.has(t.name)),
|
|
732
|
+
tokenMap,
|
|
733
|
+
),
|
|
731
734
|
tenants: Array.from(tenantsMap.values()),
|
|
732
735
|
axebowPlan: preservedUserData.axebowPlan,
|
|
733
736
|
companyName: preservedUserData.companyName,
|
|
@@ -906,6 +909,7 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
906
909
|
...serviceResult.updatedPendingRevisionErrors,
|
|
907
910
|
);
|
|
908
911
|
|
|
912
|
+
const isFirstSightingOfService = !servicesMap.has(serviceResult.serviceFullKey);
|
|
909
913
|
const resolvedService = resolveServiceStatus(serviceResult.service);
|
|
910
914
|
servicesMap.set(serviceResult.serviceFullKey, resolvedService);
|
|
911
915
|
|
|
@@ -928,6 +932,14 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
928
932
|
eventHelper.service.publish.deployed(resolvedService);
|
|
929
933
|
}
|
|
930
934
|
}
|
|
935
|
+
if (
|
|
936
|
+
isFirstSightingOfService &&
|
|
937
|
+
resolvedService.error &&
|
|
938
|
+
resolvedService.status?.code !== "REMOVING_SERVICE" &&
|
|
939
|
+
!eventData.meta?.deleted
|
|
940
|
+
) {
|
|
941
|
+
eventHelper.service.publish.deploymentError(resolvedService);
|
|
942
|
+
}
|
|
931
943
|
const serviceState = eventData.status?.state?.code;
|
|
932
944
|
if (serviceState === "SERVICE_READY") {
|
|
933
945
|
const serviceKey = `${parentParts.tenant}/${entityId}`;
|
|
@@ -2170,10 +2182,13 @@ export const updateUserComplete = (updatedUserData: UserData): User => {
|
|
|
2170
2182
|
const localOnlyTokens = (userData.tokens || []).filter(
|
|
2171
2183
|
(t) => !incomingTokenNames.has(t.name)
|
|
2172
2184
|
);
|
|
2173
|
-
const mergedTokens =
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2185
|
+
const mergedTokens = applyKnownTokenData(
|
|
2186
|
+
[...(updatedUserData.tokens || []), ...localOnlyTokens]
|
|
2187
|
+
.filter((t, index, arr) => arr.findIndex(x => x.name === t.name) === index)
|
|
2188
|
+
.filter(t => tokenMap.size === 0 || tokenMap.has(t.name))
|
|
2189
|
+
.filter(t => !deletedTokenIds.has(t.name)),
|
|
2190
|
+
tokenMap,
|
|
2191
|
+
);
|
|
2177
2192
|
|
|
2178
2193
|
userData = {
|
|
2179
2194
|
id: updatedUserData.id || userData.id,
|