@kumori/aurora-backend-handler 1.1.105 → 1.1.106
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/account-api-service.ts +13 -13
- package/api/deploy-service-helper.ts +11 -34
- package/api/environment-api-service.ts +19 -19
- package/api/marketplace-api-service.ts +5 -5
- package/api/resources-api-service.ts +33 -33
- package/api/service-api-service.ts +28 -28
- package/api/tenant-api-service.ts +60 -60
- package/api/user-api-service.ts +10 -11
- package/backend-handler.ts +20 -21
- package/helpers/account-helper.ts +10 -9
- package/helpers/environment-helper.ts +7 -6
- package/helpers/token-helper.ts +3 -3
- package/helpers/user-helper.ts +4 -7
- package/package.json +3 -3
- package/test/deploy-service-helper.test.ts +0 -9
- package/websocket-manager.ts +5 -23
package/api/user-api-service.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Account,
|
|
9
9
|
Container,
|
|
10
10
|
Environment,
|
|
11
|
-
|
|
11
|
+
getWuiErrorCode,
|
|
12
12
|
Instance,
|
|
13
13
|
MarketplaceItem,
|
|
14
14
|
Organization,
|
|
@@ -94,7 +94,6 @@ export const loadUserData = async () => {
|
|
|
94
94
|
|
|
95
95
|
const userData: UserData = {
|
|
96
96
|
id: userResponse.userRecord.id.name,
|
|
97
|
-
created: userResponse.userRecord.meta.created,
|
|
98
97
|
name: userResponse.userRecord.spec.userinfo.name,
|
|
99
98
|
surname: userResponse.userRecord.spec.userinfo.surname,
|
|
100
99
|
provider: [{ name: provider, email: email || "", password: "" }],
|
|
@@ -1049,7 +1048,7 @@ export const updateUser = async (user: User) => {
|
|
|
1049
1048
|
spec: {
|
|
1050
1049
|
name: user.name,
|
|
1051
1050
|
surname: user.surname,
|
|
1052
|
-
discoveryMethod:
|
|
1051
|
+
discoveryMethod: user.discoveryMethod,
|
|
1053
1052
|
companyName: user.companyName,
|
|
1054
1053
|
companyRole: user.rol,
|
|
1055
1054
|
},
|
|
@@ -1064,10 +1063,10 @@ export const updateUser = async (user: User) => {
|
|
|
1064
1063
|
eventHelper.user.publish.updated(user);
|
|
1065
1064
|
eventHelper.notification.publish.creation({
|
|
1066
1065
|
type: "success",
|
|
1067
|
-
subtype:
|
|
1066
|
+
subtype: "user-updated",
|
|
1068
1067
|
date: Date.now().toString(),
|
|
1069
1068
|
status: "unread",
|
|
1070
|
-
|
|
1069
|
+
notificationType: "regular",
|
|
1071
1070
|
data: { user: user.name },
|
|
1072
1071
|
});
|
|
1073
1072
|
} catch (error) {
|
|
@@ -1079,10 +1078,10 @@ export const updateUser = async (user: User) => {
|
|
|
1079
1078
|
eventHelper.user.publish.updateError(user);
|
|
1080
1079
|
eventHelper.notification.publish.creation({
|
|
1081
1080
|
type: "error",
|
|
1082
|
-
subtype:
|
|
1081
|
+
subtype: getWuiErrorCode("user", "modifyUserInfo", (error as any).error.code) ?? "user-update-error",
|
|
1083
1082
|
date: Date.now().toString(),
|
|
1084
1083
|
status: "unread",
|
|
1085
|
-
|
|
1084
|
+
notificationType: "regular",
|
|
1086
1085
|
info_content: {
|
|
1087
1086
|
code: (error as any).error.code,
|
|
1088
1087
|
message: (error as any).error.content,
|
|
@@ -1107,10 +1106,10 @@ export const deleteUSer = async (user: User, security: string) => {
|
|
|
1107
1106
|
);
|
|
1108
1107
|
eventHelper.notification.publish.creation({
|
|
1109
1108
|
type: "success",
|
|
1110
|
-
subtype:
|
|
1109
|
+
subtype: "user-deleted",
|
|
1111
1110
|
date: Date.now().toString(),
|
|
1112
1111
|
status: "unread",
|
|
1113
|
-
|
|
1112
|
+
notificationType: "regular",
|
|
1114
1113
|
data: { user: user.name },
|
|
1115
1114
|
});
|
|
1116
1115
|
return response;
|
|
@@ -1118,10 +1117,10 @@ export const deleteUSer = async (user: User, security: string) => {
|
|
|
1118
1117
|
console.error("Error deleting user:", error);
|
|
1119
1118
|
eventHelper.notification.publish.creation({
|
|
1120
1119
|
type: "error",
|
|
1121
|
-
subtype:
|
|
1120
|
+
subtype: getWuiErrorCode("user", "deleteUser", (error as any).error.code) ?? "user-delete-error",
|
|
1122
1121
|
date: Date.now().toString(),
|
|
1123
1122
|
status: "unread",
|
|
1124
|
-
|
|
1123
|
+
notificationType: "regular",
|
|
1125
1124
|
info_content: {
|
|
1126
1125
|
code: (error as any).error.code,
|
|
1127
1126
|
message: (error as any).error.content,
|
package/backend-handler.ts
CHANGED
|
@@ -68,7 +68,6 @@ import { getPlanProviders } from "./api/planProvider-api-service";
|
|
|
68
68
|
import {
|
|
69
69
|
Account,
|
|
70
70
|
Environment,
|
|
71
|
-
errors,
|
|
72
71
|
Link,
|
|
73
72
|
MarketplaceItem,
|
|
74
73
|
MarketplaceService,
|
|
@@ -612,10 +611,10 @@ export class BackendHandler {
|
|
|
612
611
|
const updatedCb = (data: string) => {
|
|
613
612
|
const upgradeNotification: Notification = {
|
|
614
613
|
type: "success",
|
|
615
|
-
subtype:
|
|
614
|
+
subtype: "plan-upgrade",
|
|
616
615
|
date: Date.now().toString(),
|
|
617
616
|
status: "unread",
|
|
618
|
-
|
|
617
|
+
notificationType: "regular",
|
|
619
618
|
data: {
|
|
620
619
|
plan: data,
|
|
621
620
|
},
|
|
@@ -642,10 +641,10 @@ export class BackendHandler {
|
|
|
642
641
|
const downgradedCb = (data: string) => {
|
|
643
642
|
const downgradeNotification: Notification = {
|
|
644
643
|
type: "success",
|
|
645
|
-
subtype:
|
|
644
|
+
subtype: "plan-downgrade",
|
|
646
645
|
date: Date.now().toString(),
|
|
647
646
|
status: "unread",
|
|
648
|
-
|
|
647
|
+
notificationType: "regular",
|
|
649
648
|
data: {
|
|
650
649
|
plan: data,
|
|
651
650
|
},
|
|
@@ -678,10 +677,10 @@ export class BackendHandler {
|
|
|
678
677
|
const createdCb = (data: Environment) => {
|
|
679
678
|
const envNotification: Notification = {
|
|
680
679
|
type: "success",
|
|
681
|
-
subtype:
|
|
680
|
+
subtype: "environment-created",
|
|
682
681
|
date: Date.now().toString(),
|
|
683
682
|
status: "unread",
|
|
684
|
-
|
|
683
|
+
notificationType: "regular",
|
|
685
684
|
data: {
|
|
686
685
|
environment: data.name,
|
|
687
686
|
account: data.account,
|
|
@@ -762,10 +761,10 @@ export class BackendHandler {
|
|
|
762
761
|
const deployedCb = (data: Service) => {
|
|
763
762
|
const deploymentSuccessNotification: Notification = {
|
|
764
763
|
type: "success",
|
|
765
|
-
subtype:
|
|
764
|
+
subtype: "deployment-success",
|
|
766
765
|
date: Date.now().toString(),
|
|
767
766
|
status: "unread",
|
|
768
|
-
|
|
767
|
+
notificationType: "regular",
|
|
769
768
|
data: {
|
|
770
769
|
service: data.name,
|
|
771
770
|
tenant: data.tenant,
|
|
@@ -777,7 +776,7 @@ export class BackendHandler {
|
|
|
777
776
|
const deploymentErrorCb = (data: Service) => {
|
|
778
777
|
const deploymentErrorNotification: Notification = {
|
|
779
778
|
type: "error",
|
|
780
|
-
subtype:
|
|
779
|
+
subtype: "deployment-error",
|
|
781
780
|
date: Date.now().toString(),
|
|
782
781
|
status: "unread",
|
|
783
782
|
info_content: {
|
|
@@ -785,7 +784,7 @@ export class BackendHandler {
|
|
|
785
784
|
message: data.error?.message || "",
|
|
786
785
|
timestamp: data.error?.timestamp || "",
|
|
787
786
|
},
|
|
788
|
-
|
|
787
|
+
notificationType: "regular",
|
|
789
788
|
data: {
|
|
790
789
|
service: data.name,
|
|
791
790
|
tenant: data.tenant,
|
|
@@ -798,10 +797,10 @@ export class BackendHandler {
|
|
|
798
797
|
deployService(data, token);
|
|
799
798
|
const deploymentSuccessNotification: Notification = {
|
|
800
799
|
type: "info",
|
|
801
|
-
subtype:
|
|
800
|
+
subtype: "deployment-in-progress",
|
|
802
801
|
date: Date.now().toString(),
|
|
803
802
|
status: "unread",
|
|
804
|
-
|
|
803
|
+
notificationType: "regular",
|
|
805
804
|
data: {
|
|
806
805
|
service: data.name,
|
|
807
806
|
tenant: data.tenant,
|
|
@@ -829,10 +828,10 @@ export class BackendHandler {
|
|
|
829
828
|
const updatedCb = (data: Service) => {
|
|
830
829
|
const deploymentNotification: Notification = {
|
|
831
830
|
type: "success",
|
|
832
|
-
subtype:
|
|
831
|
+
subtype: "deployment-updated",
|
|
833
832
|
date: Date.now().toString(),
|
|
834
833
|
status: "unread",
|
|
835
|
-
|
|
834
|
+
notificationType: "regular",
|
|
836
835
|
data: {
|
|
837
836
|
service: data.name,
|
|
838
837
|
tenant: data.tenant,
|
|
@@ -854,10 +853,10 @@ export class BackendHandler {
|
|
|
854
853
|
const deleteCb = (data: Service) => {
|
|
855
854
|
const deploymentNotification: Notification = {
|
|
856
855
|
type: "info",
|
|
857
|
-
subtype:
|
|
856
|
+
subtype: "deployment-deleting",
|
|
858
857
|
date: Date.now().toString(),
|
|
859
858
|
status: "unread",
|
|
860
|
-
|
|
859
|
+
notificationType: "regular",
|
|
861
860
|
data: {
|
|
862
861
|
service: data.name,
|
|
863
862
|
tenant: data.tenant,
|
|
@@ -874,10 +873,10 @@ export class BackendHandler {
|
|
|
874
873
|
const deletedCb = (data: Service) => {
|
|
875
874
|
const deploymentNotification: Notification = {
|
|
876
875
|
type: "success",
|
|
877
|
-
subtype:
|
|
876
|
+
subtype: "deployment-deleted",
|
|
878
877
|
date: Date.now().toString(),
|
|
879
878
|
status: "unread",
|
|
880
|
-
|
|
879
|
+
notificationType: "regular",
|
|
881
880
|
data: {
|
|
882
881
|
service: data.name,
|
|
883
882
|
tenant: data.tenant,
|
|
@@ -1090,10 +1089,10 @@ export class BackendHandler {
|
|
|
1090
1089
|
const deletedCb = (data: Resource) => {
|
|
1091
1090
|
const resourceNotification: Notification = {
|
|
1092
1091
|
type: "success",
|
|
1093
|
-
subtype:
|
|
1092
|
+
subtype: "resource-deleted",
|
|
1094
1093
|
date: Date.now().toString(),
|
|
1095
1094
|
status: "unread",
|
|
1096
|
-
|
|
1095
|
+
notificationType: "regular",
|
|
1097
1096
|
data: {
|
|
1098
1097
|
resource: data.name,
|
|
1099
1098
|
type: data.type,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account,
|
|
1
|
+
import { Account, getWuiErrorCode, Notification } from "@kumori/aurora-interfaces";
|
|
2
2
|
const CREDENTIAL_ERROR_CODES = new Set([
|
|
3
3
|
"_error_retrieving_credentials_",
|
|
4
4
|
"_invalid_account_credentials_",
|
|
@@ -289,10 +289,10 @@ export const handleAccountOperationSuccess = ({
|
|
|
289
289
|
shouldDelete: true,
|
|
290
290
|
notification: {
|
|
291
291
|
type: "success",
|
|
292
|
-
subtype:
|
|
292
|
+
subtype: "account-deleted",
|
|
293
293
|
date: Date.now().toString(),
|
|
294
294
|
status: "unread",
|
|
295
|
-
|
|
295
|
+
notificationType: "regular",
|
|
296
296
|
data: { account: originalData.name, tenant: originalData.tenant },
|
|
297
297
|
},
|
|
298
298
|
eventType: "deleted",
|
|
@@ -308,10 +308,10 @@ export const handleAccountOperationSuccess = ({
|
|
|
308
308
|
shouldDelete: false,
|
|
309
309
|
notification: {
|
|
310
310
|
type: "success",
|
|
311
|
-
subtype: isCreate ?
|
|
311
|
+
subtype: isCreate ? "account-created" : "account-updated",
|
|
312
312
|
date: Date.now().toString(),
|
|
313
313
|
status: "unread",
|
|
314
|
-
|
|
314
|
+
notificationType: "regular",
|
|
315
315
|
data: { account: updatedAccount.name, tenant: updatedAccount.tenant },
|
|
316
316
|
},
|
|
317
317
|
eventType: isCreate ? "created" : "updated",
|
|
@@ -326,7 +326,7 @@ export const handleAccountOperationSuccess = ({
|
|
|
326
326
|
subtype: "account-unknown",
|
|
327
327
|
date: Date.now().toString(),
|
|
328
328
|
status: "unread",
|
|
329
|
-
|
|
329
|
+
notificationType: "regular",
|
|
330
330
|
data: {},
|
|
331
331
|
},
|
|
332
332
|
eventType: null,
|
|
@@ -357,10 +357,11 @@ export const handleAccountOperationError = ({
|
|
|
357
357
|
const errorCode: string = error?.error?.code ?? error?.code ?? "";
|
|
358
358
|
const errorStatus = resolveErrorStatus(errorCode);
|
|
359
359
|
|
|
360
|
-
const
|
|
360
|
+
const errSubtype = isCreate ? "account-creation-error" : isUpdate ? "account-update-error" : "account-deletion-error";
|
|
361
|
+
const errMethod = isCreate ? "createAccount" : isUpdate ? "updateAccount" : "deleteAccount";
|
|
361
362
|
const notification: Notification = {
|
|
362
363
|
type: "error",
|
|
363
|
-
subtype:
|
|
364
|
+
subtype: getWuiErrorCode("account", errMethod, errorCode) ?? errSubtype,
|
|
364
365
|
date: Date.now().toString(),
|
|
365
366
|
status: "unread",
|
|
366
367
|
info_content: {
|
|
@@ -369,7 +370,7 @@ export const handleAccountOperationError = ({
|
|
|
369
370
|
error?.error?.content ?? error?.error?.message ?? "Unknown error",
|
|
370
371
|
timestamp: error?.error?.timestamp ?? Date.now().toString(),
|
|
371
372
|
},
|
|
372
|
-
|
|
373
|
+
notificationType: "regular",
|
|
373
374
|
data: {
|
|
374
375
|
account:
|
|
375
376
|
entityName || originalData?.name || originalData?.account || "unknown",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, Environment,
|
|
1
|
+
import { Account, Environment, getWuiErrorCode, Notification } from "@kumori/aurora-interfaces";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -184,10 +184,10 @@ export const handleEnvironmentOperationSuccess = ({
|
|
|
184
184
|
|
|
185
185
|
const envNotification: Notification = {
|
|
186
186
|
type: "success",
|
|
187
|
-
subtype:
|
|
187
|
+
subtype: "environment-cleaned",
|
|
188
188
|
date: Date.now().toString(),
|
|
189
189
|
status: "unread",
|
|
190
|
-
|
|
190
|
+
notificationType: "regular",
|
|
191
191
|
data: {
|
|
192
192
|
environment: envData.name,
|
|
193
193
|
account: envData.account,
|
|
@@ -249,10 +249,11 @@ export const handleEnvironmentOperationError = ({
|
|
|
249
249
|
? "updateError"
|
|
250
250
|
: "deletionError";
|
|
251
251
|
|
|
252
|
-
const
|
|
252
|
+
const envErrSubtype = action === "CREATE" ? "environment-creation-error" : action === "UPDATE" ? "environment-update-error" : "environment-deletion-error";
|
|
253
|
+
const envErrMethod = action === "CREATE" ? "createEnvironment" : action === "UPDATE" ? "updateEnvironment" : "deleteEnvironment";
|
|
253
254
|
const envErrorNotification: Notification = {
|
|
254
255
|
type: "error",
|
|
255
|
-
subtype:
|
|
256
|
+
subtype: getWuiErrorCode("environment", envErrMethod, error?.error?.code || "UNKNOWN_ERROR") ?? envErrSubtype,
|
|
256
257
|
date: Date.now().toString(),
|
|
257
258
|
status: "unread",
|
|
258
259
|
info_content: {
|
|
@@ -260,7 +261,7 @@ export const handleEnvironmentOperationError = ({
|
|
|
260
261
|
message: error?.error?.content || error?.error?.message || "Unknown error",
|
|
261
262
|
timestamp: error?.error?.timestamp || "",
|
|
262
263
|
},
|
|
263
|
-
|
|
264
|
+
notificationType: "regular",
|
|
264
265
|
data: {
|
|
265
266
|
environment: originalData.name,
|
|
266
267
|
account: originalData.account,
|
package/helpers/token-helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClusterToken,
|
|
1
|
+
import { ClusterToken, Notification, Token, UserData } from "@kumori/aurora-interfaces";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
interface HandleTokenEventParams {
|
|
@@ -161,10 +161,10 @@ export const handleTokenDeletion = ({
|
|
|
161
161
|
|
|
162
162
|
const notification: Notification = {
|
|
163
163
|
type: "success",
|
|
164
|
-
subtype:
|
|
164
|
+
subtype: "token-deleted",
|
|
165
165
|
date: Date.now().toString(),
|
|
166
166
|
status: "unread",
|
|
167
|
-
|
|
167
|
+
notificationType: "regular",
|
|
168
168
|
data: {
|
|
169
169
|
tokenName: deletedToken.name,
|
|
170
170
|
tenant: deletedToken.tenant,
|
package/helpers/user-helper.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
errors,
|
|
3
2
|
Notification,
|
|
4
3
|
Plan,
|
|
5
4
|
Tenant,
|
|
@@ -62,9 +61,9 @@ export const handleUserEvent = ({
|
|
|
62
61
|
eventHelper.tenant.publish.deleted(tenantToDelete);
|
|
63
62
|
const tenantDeletedNotification: Notification = {
|
|
64
63
|
type: "success",
|
|
65
|
-
subtype:
|
|
64
|
+
subtype: "tenant-deleted",
|
|
66
65
|
date: Date.now().toString(),
|
|
67
|
-
|
|
66
|
+
notificationType: "regular",
|
|
68
67
|
status: "unread",
|
|
69
68
|
data: {
|
|
70
69
|
tenant: tenantToDelete.name,
|
|
@@ -76,9 +75,9 @@ export const handleUserEvent = ({
|
|
|
76
75
|
} else {
|
|
77
76
|
const userRemovedNotification: Notification = {
|
|
78
77
|
type: "info",
|
|
79
|
-
subtype:
|
|
78
|
+
subtype: "user-removed-from-tenant",
|
|
80
79
|
date: Date.now().toString(),
|
|
81
|
-
|
|
80
|
+
notificationType: "regular",
|
|
82
81
|
status: "unread",
|
|
83
82
|
data: {
|
|
84
83
|
tenant: tenantToDelete.name,
|
|
@@ -138,7 +137,6 @@ export const handleUserEvent = ({
|
|
|
138
137
|
}
|
|
139
138
|
const userData: UserData = {
|
|
140
139
|
id: userId,
|
|
141
|
-
created: eventData.meta?.created || currentUserData.created || "",
|
|
142
140
|
name: eventData.spec.userinfo.name,
|
|
143
141
|
surname: eventData.spec.userinfo.surname,
|
|
144
142
|
provider: providers,
|
|
@@ -164,7 +162,6 @@ export const handleUserEvent = ({
|
|
|
164
162
|
export const handleUserDelete = (): UserData => {
|
|
165
163
|
return {
|
|
166
164
|
id: "",
|
|
167
|
-
created: "",
|
|
168
165
|
name: "",
|
|
169
166
|
surname: "",
|
|
170
167
|
provider: [],
|
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.106",
|
|
4
4
|
"description": "backend handler",
|
|
5
5
|
"main": "backend-handler.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"glob": "^11.0.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@kumori/aurora-interfaces": "^1.0.
|
|
15
|
-
"@kumori/kumori-dsl-generator": "1.0.
|
|
14
|
+
"@kumori/aurora-interfaces": "^1.0.31",
|
|
15
|
+
"@kumori/kumori-dsl-generator": "1.0.7",
|
|
16
16
|
"@kumori/kumori-module-generator": "^1.1.6",
|
|
17
17
|
"ts-node": "^10.9.2",
|
|
18
18
|
"uuid": "^11.1.0",
|
|
@@ -196,15 +196,6 @@ describe("handleParametersToGenerateData", () => {
|
|
|
196
196
|
expect(result.environment).toContainEqual({ varName: "res1", secret: "res1" });
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
-
it("maneja formResources de tipo secret con key (montado en path)", () => {
|
|
200
|
-
const result = handleParametersToGenerateData([], [
|
|
201
|
-
{ name: "mySuperSecretSecret", type: "secret", key: "/mysecret" },
|
|
202
|
-
]);
|
|
203
|
-
expect(result.resources).toContainEqual({ secret: { name: "mySuperSecretSecret" } });
|
|
204
|
-
expect(result.fileSystem).toContainEqual({ path: "/mysecret", resourceSecret: "mySuperSecretSecret" });
|
|
205
|
-
expect(result.environment).not.toContainEqual({ varName: "mySuperSecretSecret", secret: "mySuperSecretSecret" });
|
|
206
|
-
});
|
|
207
|
-
|
|
208
199
|
it("maneja formResources de tipo volume", () => {
|
|
209
200
|
const result = handleParametersToGenerateData([], [
|
|
210
201
|
{ name: "vol1", type: "volume", key: "/mnt/data" },
|
package/websocket-manager.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { v7 as uuidv7 } from "uuid";
|
|
2
2
|
import { environment } from "./environment";
|
|
3
|
-
import { AccountStatus } from "@kumori/aurora-interfaces/enums/accountStatusEnum";
|
|
4
3
|
import {
|
|
5
4
|
Account,
|
|
6
5
|
Channel,
|
|
7
6
|
ClusterToken,
|
|
8
7
|
Environment,
|
|
9
|
-
errors,
|
|
10
8
|
Instance,
|
|
11
9
|
MarketplaceItem,
|
|
12
10
|
Notification,
|
|
@@ -153,7 +151,6 @@ let currentToken: string | null = null;
|
|
|
153
151
|
let connectionPromise: Promise<WebSocket> | null = null;
|
|
154
152
|
let userData: UserData = {
|
|
155
153
|
id: "",
|
|
156
|
-
created: "",
|
|
157
154
|
name: "",
|
|
158
155
|
surname: "",
|
|
159
156
|
provider: [],
|
|
@@ -664,17 +661,6 @@ export const closeGlobalWebSocketConnection = () => {
|
|
|
664
661
|
});
|
|
665
662
|
};
|
|
666
663
|
|
|
667
|
-
const computePromotionInfo = (
|
|
668
|
-
tenants: Tenant[],
|
|
669
|
-
): { completedSteps: number; remainingDays: number } => {
|
|
670
|
-
const hasValidCredentialsAccount = tenants.some((tenant) =>
|
|
671
|
-
tenant.accounts?.some((account) => account.status === AccountStatus.ACTIVE),
|
|
672
|
-
);
|
|
673
|
-
const hasDeployedService = tenants.some((tenant) => tenant.services?.length > 0);
|
|
674
|
-
const completedSteps = (hasValidCredentialsAccount ? 1 : 0) + (hasDeployedService ? 1 : 0);
|
|
675
|
-
return { completedSteps, remainingDays: 7 };
|
|
676
|
-
};
|
|
677
|
-
|
|
678
664
|
const rebuildHierarchy = () => {
|
|
679
665
|
const preservedUserData = { ...userData };
|
|
680
666
|
|
|
@@ -709,7 +695,6 @@ const rebuildHierarchy = () => {
|
|
|
709
695
|
});
|
|
710
696
|
userData = {
|
|
711
697
|
id: preservedUserData.id,
|
|
712
|
-
created: preservedUserData.created,
|
|
713
698
|
name: preservedUserData.name,
|
|
714
699
|
surname: preservedUserData.surname,
|
|
715
700
|
provider: preservedUserData.provider.map((p) => ({ ...p })),
|
|
@@ -730,7 +715,6 @@ const rebuildHierarchy = () => {
|
|
|
730
715
|
notifications: preservedUserData.notifications || [],
|
|
731
716
|
plans: preservedUserData.plans || [],
|
|
732
717
|
discoveryMethod: preservedUserData.discoveryMethod,
|
|
733
|
-
promotionInfo: computePromotionInfo(Array.from(tenantsMap.values())),
|
|
734
718
|
};
|
|
735
719
|
};
|
|
736
720
|
const handleEvent = async (message: WSMessage) => {
|
|
@@ -963,7 +947,7 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
963
947
|
) {
|
|
964
948
|
const roleNotification: Notification = {
|
|
965
949
|
type: "info",
|
|
966
|
-
subtype:
|
|
950
|
+
subtype: "tenant-role-changed",
|
|
967
951
|
date: Date.now().toString(),
|
|
968
952
|
status: "unread",
|
|
969
953
|
notificationType: "regular",
|
|
@@ -1765,7 +1749,7 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1765
1749
|
eventHelper.environment.publish.deleted(deletedEnv);
|
|
1766
1750
|
const envNotification: Notification = {
|
|
1767
1751
|
type: "success",
|
|
1768
|
-
subtype:
|
|
1752
|
+
subtype: "environment-deleted",
|
|
1769
1753
|
date: Date.now().toString(),
|
|
1770
1754
|
notificationType: "regular",
|
|
1771
1755
|
status: "unread",
|
|
@@ -1785,7 +1769,7 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1785
1769
|
eventHelper.account.publish.deleted(deletedAccount);
|
|
1786
1770
|
const accountNotification: Notification = {
|
|
1787
1771
|
type: "success",
|
|
1788
|
-
subtype:
|
|
1772
|
+
subtype: "account-deleted",
|
|
1789
1773
|
date: Date.now().toString(),
|
|
1790
1774
|
notificationType: "regular",
|
|
1791
1775
|
status: "unread",
|
|
@@ -1923,7 +1907,7 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1923
1907
|
tenantsMap.set(tenantName, registryTenant);
|
|
1924
1908
|
const registryNotification: Notification = {
|
|
1925
1909
|
type: "success",
|
|
1926
|
-
subtype:
|
|
1910
|
+
subtype: "registry-deleted",
|
|
1927
1911
|
date: Date.now().toString(),
|
|
1928
1912
|
status: "unread",
|
|
1929
1913
|
notificationType: "regular",
|
|
@@ -1979,7 +1963,7 @@ const handleDeleteEvent = async (message: WSMessage) => {
|
|
|
1979
1963
|
if (deletedLinkInfo) {
|
|
1980
1964
|
const unlinkNotification: Notification = {
|
|
1981
1965
|
type: "success",
|
|
1982
|
-
subtype:
|
|
1966
|
+
subtype: "service-unlinked",
|
|
1983
1967
|
date: Date.now().toString(),
|
|
1984
1968
|
status: "unread",
|
|
1985
1969
|
notificationType: "regular",
|
|
@@ -2146,7 +2130,6 @@ export const updateUserComplete = (updatedUserData: UserData): User => {
|
|
|
2146
2130
|
|
|
2147
2131
|
userData = {
|
|
2148
2132
|
id: updatedUserData.id || userData.id,
|
|
2149
|
-
created: updatedUserData.created || userData.created,
|
|
2150
2133
|
name: updatedUserData.name || userData.name,
|
|
2151
2134
|
surname: updatedUserData.surname || userData.surname,
|
|
2152
2135
|
provider: updatedUserData.provider || userData.provider || [],
|
|
@@ -2167,7 +2150,6 @@ export const updateUserComplete = (updatedUserData: UserData): User => {
|
|
|
2167
2150
|
status: updatedUserData.status,
|
|
2168
2151
|
discoveryMethod:
|
|
2169
2152
|
updatedUserData.discoveryMethod || userData.discoveryMethod,
|
|
2170
|
-
promotionInfo: computePromotionInfo(updatedUserData.tenants || userData.tenants || []),
|
|
2171
2153
|
};
|
|
2172
2154
|
user = new User(
|
|
2173
2155
|
userData,
|