@kumori/aurora-backend-handler 1.1.82 → 1.1.84
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/api/tenant-api-service.ts +2 -1
- package/helpers/token-helper.ts +50 -1
- package/helpers/user-helper.ts +2 -1
- package/package.json +2 -2
- package/websocket-manager.ts +35 -24
package/helpers/token-helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClusterToken, Token, UserData } from "@kumori/aurora-interfaces";
|
|
1
|
+
import { ClusterToken, errors, Notification, Token, UserData } from "@kumori/aurora-interfaces";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
interface HandleTokenEventParams {
|
|
@@ -107,4 +107,53 @@ export const handleTokenOperationSuccess = ({
|
|
|
107
107
|
return {
|
|
108
108
|
token: tokenWithData,
|
|
109
109
|
};
|
|
110
|
+
};
|
|
111
|
+
interface HandleTokenDeletionParams {
|
|
112
|
+
tokenId: string;
|
|
113
|
+
tokenMap: Map<string, Token>;
|
|
114
|
+
userData: UserData;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface HandleTokenDeletionResult {
|
|
118
|
+
removed: boolean;
|
|
119
|
+
updatedUserTokens: Token[];
|
|
120
|
+
notification: Notification | null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const handleTokenDeletion = ({
|
|
124
|
+
tokenId,
|
|
125
|
+
tokenMap,
|
|
126
|
+
userData,
|
|
127
|
+
}: HandleTokenDeletionParams): HandleTokenDeletionResult => {
|
|
128
|
+
const tokenIndex = userData.tokens.findIndex((t) => t.name === tokenId);
|
|
129
|
+
if (tokenIndex === -1) {
|
|
130
|
+
return {
|
|
131
|
+
removed: false,
|
|
132
|
+
updatedUserTokens: userData.tokens,
|
|
133
|
+
notification: null,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const deletedToken = userData.tokens[tokenIndex];
|
|
138
|
+
const updatedUserTokens = [...userData.tokens];
|
|
139
|
+
updatedUserTokens.splice(tokenIndex, 1);
|
|
140
|
+
tokenMap.delete(tokenId);
|
|
141
|
+
|
|
142
|
+
const notification: Notification = {
|
|
143
|
+
type: "success",
|
|
144
|
+
subtype: errors.user.tokenDeleted.subtype,
|
|
145
|
+
date: Date.now().toString(),
|
|
146
|
+
status: "unread",
|
|
147
|
+
callToAction: false,
|
|
148
|
+
data: {
|
|
149
|
+
tokenName: deletedToken.name,
|
|
150
|
+
tenant: deletedToken.tenant,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
removed: true,
|
|
156
|
+
updatedUserTokens,
|
|
157
|
+
notification,
|
|
158
|
+
};
|
|
110
159
|
};
|
package/helpers/user-helper.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Tenant,
|
|
6
6
|
UserData,
|
|
7
7
|
tenantRole,
|
|
8
|
+
UserStatus
|
|
8
9
|
} from "@kumori/aurora-interfaces";
|
|
9
10
|
|
|
10
11
|
interface HandleUserEventParams {
|
|
@@ -173,6 +174,6 @@ export const handleUserDelete = (): UserData => {
|
|
|
173
174
|
axebowPlan: "freemium",
|
|
174
175
|
companyName: "",
|
|
175
176
|
rol: "",
|
|
176
|
-
status:
|
|
177
|
+
status: UserStatus.NOT_LOGGED,
|
|
177
178
|
};
|
|
178
179
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumori/aurora-backend-handler",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.84",
|
|
4
4
|
"description": "backend handler",
|
|
5
5
|
"main": "backend-handler.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"glob": "^11.0.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@kumori/aurora-interfaces": "^1.0.
|
|
14
|
+
"@kumori/aurora-interfaces": "^1.0.20",
|
|
15
15
|
"@kumori/kumori-dsl-generator": "1.0.7",
|
|
16
16
|
"@kumori/kumori-module-generator": "^1.1.6",
|
|
17
17
|
"ts-node": "^10.9.2",
|
package/websocket-manager.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
Token,
|
|
21
21
|
User,
|
|
22
22
|
UserData,
|
|
23
|
+
UserStatus
|
|
23
24
|
} from "@kumori/aurora-interfaces";
|
|
24
25
|
import { loadMarketplaceItemsForTenant } from "./api/marketplace-api-service";
|
|
25
26
|
import { getReporting } from "./api/reporting-api-service";
|
|
@@ -69,6 +70,7 @@ import {
|
|
|
69
70
|
} from "./helpers/plan-helper";
|
|
70
71
|
import { handleRegistryEvent } from "./helpers/registry-helper";
|
|
71
72
|
import {
|
|
73
|
+
handleTokenDeletion,
|
|
72
74
|
handleTokenEvent,
|
|
73
75
|
handleTokenOperationSuccess,
|
|
74
76
|
} from "./helpers/token-helper";
|
|
@@ -349,7 +351,7 @@ export const initializeGlobalWebSocketClient = async (
|
|
|
349
351
|
message.error?.code === "_unknown_user_" &&
|
|
350
352
|
message.error?.content !== "Unknown proposed user."
|
|
351
353
|
) {
|
|
352
|
-
userData.status =
|
|
354
|
+
userData.status = UserStatus.UNKNOWN;
|
|
353
355
|
user = new User(userData);
|
|
354
356
|
eventHelper.user.publish.loaded(user);
|
|
355
357
|
}
|
|
@@ -375,7 +377,7 @@ export const initializeGlobalWebSocketClient = async (
|
|
|
375
377
|
|
|
376
378
|
wsConnection?.addEventListener("error", (error) => {
|
|
377
379
|
console.error("Global WebSocket error:", error);
|
|
378
|
-
userData.status =
|
|
380
|
+
userData.status = UserStatus.NOT_LOGGED;
|
|
379
381
|
user = new User(userData);
|
|
380
382
|
eventHelper.user.publish.loaded(user);
|
|
381
383
|
connectionPromise = null;
|
|
@@ -1509,10 +1511,27 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1509
1511
|
}
|
|
1510
1512
|
break;
|
|
1511
1513
|
case "token":
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1514
|
+
if (action === "DELETE") {
|
|
1515
|
+
const deletedTokenId = entityName.split("/").pop();
|
|
1516
|
+
if (deletedTokenId) {
|
|
1517
|
+
const tokenDeletionResult = handleTokenDeletion({
|
|
1518
|
+
tokenId: deletedTokenId,
|
|
1519
|
+
tokenMap,
|
|
1520
|
+
userData,
|
|
1521
|
+
});
|
|
1522
|
+
if (tokenDeletionResult.removed) {
|
|
1523
|
+
userData.tokens = tokenDeletionResult.updatedUserTokens;
|
|
1524
|
+
eventHelper.notification.publish.creation(
|
|
1525
|
+
tokenDeletionResult.notification!,
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
} else {
|
|
1530
|
+
const tokenSuccessResult = handleTokenOperationSuccess({
|
|
1531
|
+
responsePayload: response.payload,
|
|
1532
|
+
});
|
|
1533
|
+
tokenMap.set(tokenSuccessResult.token.name, tokenSuccessResult.token);
|
|
1534
|
+
}
|
|
1516
1535
|
break;
|
|
1517
1536
|
case "user":
|
|
1518
1537
|
if (action === "DELETE") {
|
|
@@ -1893,24 +1912,16 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1893
1912
|
}
|
|
1894
1913
|
}
|
|
1895
1914
|
if (keyParts.token && keyParts.user) {
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
status: "unread",
|
|
1907
|
-
callToAction: false,
|
|
1908
|
-
data: {
|
|
1909
|
-
tokenName: deletedToken.name,
|
|
1910
|
-
tenant: deletedToken.tenant,
|
|
1911
|
-
},
|
|
1912
|
-
};
|
|
1913
|
-
eventHelper.notification.publish.creation(tokenNotification);
|
|
1915
|
+
const tokenDeletionResult = handleTokenDeletion({
|
|
1916
|
+
tokenId: keyParts.token,
|
|
1917
|
+
tokenMap,
|
|
1918
|
+
userData,
|
|
1919
|
+
});
|
|
1920
|
+
if (tokenDeletionResult.removed) {
|
|
1921
|
+
userData.tokens = tokenDeletionResult.updatedUserTokens;
|
|
1922
|
+
eventHelper.notification.publish.creation(
|
|
1923
|
+
tokenDeletionResult.notification!,
|
|
1924
|
+
);
|
|
1914
1925
|
}
|
|
1915
1926
|
}
|
|
1916
1927
|
rebuildHierarchy();
|