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