@kumori/aurora-backend-handler 1.0.48 → 1.0.50

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.
@@ -222,7 +222,6 @@ export const createAccount = async (account: Account, security: Security) => {
222
222
  username: account.cloudProvider.username || "",
223
223
  password: account.cloudProvider.password || "",
224
224
  region: account.cloudProvider?.region || "",
225
- project_id: account.cloudProvider?.project_id || "",
226
225
  }
227
226
  : {
228
227
  method: providerName,
@@ -334,7 +333,6 @@ export const createAccount = async (account: Account, security: Security) => {
334
333
  password: account.cloudProvider.password || "",
335
334
  region: account.cloudProvider?.region || "",
336
335
  domain: account.cloudProvider?.domain || "",
337
- project_id: account.cloudProvider?.project_id || "",
338
336
  }
339
337
  : {
340
338
  method: providerName,
@@ -613,7 +611,6 @@ export const deleteAccount = async (account: Account, security: Security) => {
613
611
  credentials: {
614
612
  username: account.cloudProvider.username,
615
613
  password: account.cloudProvider.password,
616
- project_id: account.cloudProvider?.project_id || "",
617
614
  },
618
615
  },
619
616
  };
@@ -628,7 +625,6 @@ export const deleteAccount = async (account: Account, security: Security) => {
628
625
  username: account.cloudProvider.username,
629
626
  password: account.cloudProvider.password,
630
627
  domain: account.cloudProvider.domain,
631
- project_id: account.cloudProvider?.project_id || "",
632
628
  },
633
629
  },
634
630
  };
@@ -994,7 +990,6 @@ export const updateAccount = async (account: Account, security: Security) => {
994
990
  username: account.cloudProvider.username || "",
995
991
  password: account.cloudProvider.password || "",
996
992
  region: account.cloudProvider?.region || "",
997
- project_id: account.cloudProvider?.project_id || "",
998
993
  }
999
994
  : {
1000
995
  method: providerName,
@@ -1104,7 +1099,6 @@ export const updateAccount = async (account: Account, security: Security) => {
1104
1099
  password: account.cloudProvider.password || "",
1105
1100
  region: account.cloudProvider?.region || "",
1106
1101
  domain: account.cloudProvider?.domain || "",
1107
- project_id: account.cloudProvider?.project_id || "",
1108
1102
  }
1109
1103
  : {
1110
1104
  method: providerName,
@@ -208,6 +208,9 @@ export const restartService = async (data: Service, security: string) => {
208
208
  }
209
209
  };
210
210
  const generateLinkBody = (data: Service, link: Link) => {
211
+ console.log("[Backend Handler] generateLinkBody - Link:", link);
212
+ console.log("[Backend Handler] generateLinkBody - Service:", data);
213
+
211
214
  const originInClient = data.clientChannels.find(
212
215
  (channel) =>
213
216
  channel.name === link.originChannel ||
@@ -238,7 +241,30 @@ const generateLinkBody = (data: Service, link: Link) => {
238
241
  channel.name === link.targetChannel ||
239
242
  channel.from === link.targetChannel,
240
243
  );
241
-
244
+ console.log(
245
+ "[Backend Handler] generateLinkBody - Origin in client:",
246
+ originInClient,
247
+ );
248
+ console.log(
249
+ "[Backend Handler] generateLinkBody - Origin in server:",
250
+ originInServer,
251
+ );
252
+ console.log(
253
+ "[Backend Handler] generateLinkBody - Origin in duplex:",
254
+ originInDuplex,
255
+ );
256
+ console.log(
257
+ "[Backend Handler] generateLinkBody - Target in client:",
258
+ targetInClient,
259
+ );
260
+ console.log(
261
+ "[Backend Handler] generateLinkBody - Target in server:",
262
+ targetInServer,
263
+ );
264
+ console.log(
265
+ "[Backend Handler] generateLinkBody - Target in duplex:",
266
+ targetInDuplex,
267
+ );
242
268
  let linkBody;
243
269
  if (originInClient) {
244
270
  linkBody = {
@@ -307,6 +333,8 @@ const generateLinkBody = (data: Service, link: Link) => {
307
333
  server_channel: link.targetChannel,
308
334
  };
309
335
  }
336
+
337
+ console.log("[Backend Handler] generateLinkBody - Link body:", linkBody);
310
338
  return linkBody;
311
339
  };
312
340
  export const linkPendingServices = async (service: Service, token: string) => {
@@ -407,177 +435,137 @@ export const updateService = async (
407
435
  // pendingLinks.set(data.name, newLinksToCreate);
408
436
  // await linkPendingServices(serviceWithNewLinks, token);
409
437
  // }
410
- const url = new URL(
411
- `${environment.apiServer.baseUrl}/api/${environment.apiServer.apiVersion}/tenant/${data.tenant}/service/${data.name}/revision/${data.currentRevision}`,
412
- );
413
- if (data.dsl) {
414
- url.searchParams.append("dsl", "true");
415
- }
416
- if (data.serviceData) {
417
- const formData = new FormData();
418
- formData.append("type", "update-bundle");
419
- formData.append("bundle", data.serviceData);
420
- formData.append(
421
- "meta",
422
- JSON.stringify({
423
- targetAccount: data.account,
424
- targetEnvironment: data.environment,
425
- }),
426
- );
427
- formData.append("labels", JSON.stringify({ project: data.project }));
428
- formData.append("comment", " ");
429
- const response = await fetch(url.toString(), {
430
- method: "POST",
431
- body: formData,
438
+
439
+ const parameterObject: Record<string, any> = {};
440
+ if (data.parameters && data.parameters.length > 0) {
441
+ data.parameters.forEach((param) => {
442
+ const key = param.configKey || param.name;
443
+ const paramType = param.type?.toLowerCase();
444
+ if (paramType === "number" || paramType === "integer") {
445
+ parameterObject[key] = Number(param.value) || 0;
446
+ } else if (paramType === "boolean") {
447
+ parameterObject[key] = param.value === "true";
448
+ } else {
449
+ parameterObject[key] = param.value;
450
+ }
432
451
  });
433
- if (!response.ok) {
434
- throw new Error(`HTTP error! status: ${response.status}`);
435
- }
452
+ }
436
453
 
437
- const jsonResponse = await response.json();
438
- const isTimeout = jsonResponse?.events?.some(
439
- (event: any) => event.content === "_timeout_",
440
- );
454
+ const resourceObject: Record<string, any> = {};
455
+ if (data.resources && data.resources.length > 0) {
456
+ data.resources.forEach((resource) => {
457
+ if (resource.type === "volume") {
458
+ resourceObject[resource.name] = {
459
+ volume: {
460
+ kind: "storage",
461
+ size: parseInt(resource.value) || 1,
462
+ unit: "G",
463
+ type: resource.kind,
464
+ },
465
+ };
466
+ } else if (resource.type === "secret") {
467
+ resourceObject[resource.name] = {
468
+ secret: `${data.tenant}/${resource.value}`,
469
+ };
470
+ } else if (resource.type === "domain") {
471
+ resourceObject[resource.name] = {
472
+ domain: `${data.tenant}/${resource.value}`,
473
+ };
474
+ } else if (resource.type === "ca") {
475
+ resourceObject[resource.name] = {
476
+ ca: `${data.tenant}/${resource.value}`,
477
+ };
478
+ } else if (resource.type === "certificate") {
479
+ resourceObject[resource.name] = {
480
+ certificate: `${data.tenant}/${resource.value}`,
481
+ };
482
+ } else if (resource.type === "port") {
483
+ resourceObject[resource.name] = {
484
+ port: `${data.tenant}/${resource.value}`,
485
+ };
486
+ }
487
+ });
488
+ }
441
489
 
442
- if (isTimeout) {
443
- console.error("Timeout en la petición:", {
444
- isOk: false,
445
- code: "TIMEOUT",
446
- error: "_timeout_",
447
- });
490
+ let previousRevision = 1;
491
+ if (data.currentRevision) {
492
+ previousRevision = parseInt(data.currentRevision.toString(), 10);
493
+ if (isNaN(previousRevision)) {
494
+ console.warn("currentRevision is not a valid number, using 1");
495
+ previousRevision = 1;
448
496
  }
449
497
  } else {
450
- const parameterObject: Record<string, any> = {};
451
- if (data.parameters && data.parameters.length > 0) {
452
- data.parameters.forEach((param) => {
453
- const key = param.configKey || param.name;
454
- const paramType = param.type?.toLowerCase();
455
- if (paramType === "number" || paramType === "integer") {
456
- parameterObject[key] = Number(param.value) || 0;
457
- } else if (paramType === "boolean") {
458
- parameterObject[key] = param.value === "true";
459
- } else {
460
- parameterObject[key] = param.value;
461
- }
462
- });
463
- }
464
-
465
- const resourceObject: Record<string, any> = {};
466
- if (data.resources && data.resources.length > 0) {
467
- data.resources.forEach((resource) => {
468
- if (resource.type === "volume") {
469
- resourceObject[resource.name] = {
470
- volume: {
471
- kind: "storage",
472
- size: parseInt(resource.value) || 1,
473
- unit: "G",
474
- type: resource.kind,
475
- },
476
- };
477
- } else if (resource.type === "secret") {
478
- resourceObject[resource.name] = {
479
- secret: `${data.tenant}/${resource.value}`,
480
- };
481
- } else if (resource.type === "domain") {
482
- resourceObject[resource.name] = {
483
- domain: `${data.tenant}/${resource.value}`,
484
- };
485
- } else if (resource.type === "ca") {
486
- resourceObject[resource.name] = {
487
- ca: `${data.tenant}/${resource.value}`,
488
- };
489
- } else if (resource.type === "certificate") {
490
- resourceObject[resource.name] = {
491
- certificate: `${data.tenant}/${resource.value}`,
492
- };
493
- } else if (resource.type === "port") {
494
- resourceObject[resource.name] = {
495
- port: `${data.tenant}/${resource.value}`,
496
- };
497
- }
498
- });
499
- }
500
-
501
- let previousRevision = 1;
502
- if (data.currentRevision) {
503
- previousRevision = parseInt(data.currentRevision.toString(), 10);
504
- if (isNaN(previousRevision)) {
505
- console.warn("currentRevision is not a valid number, using 1");
506
- previousRevision = 1;
507
- }
508
- } else {
509
- previousRevision = getLatestRevision(data.revisions) || 1;
510
- }
498
+ previousRevision = getLatestRevision(data.revisions) || 1;
499
+ }
511
500
 
512
- const scaleConfig: any = {};
513
- if (data.role && data.role.length > 0) {
514
- scaleConfig.detail = {};
515
- data.role.forEach((role) => {
516
- scaleConfig.detail[role.name] = {
517
- hsize: role.hsize || scale || data.minReplicas || 1,
518
- };
519
- });
520
- } else {
521
- scaleConfig.hsize = scale || data.minReplicas || 1;
522
- }
523
- const meta = {
524
- scaling: {
525
- simple:
526
- data.role?.reduce(
527
- (acc, role) => {
528
- if (role.scalling && role.name) {
529
- acc[role.name] = {
530
- scale_up: {
531
- cpu: Math.min(parseInt(role.scalling.cpu.up) || 0, 100),
532
- memory: Math.min(
533
- parseInt(role.scalling.memory.up) || 0,
534
- 100,
535
- ),
536
- },
537
- scale_down: {
538
- cpu: Math.min(parseInt(role.scalling.cpu.down) || 0, 100),
539
- memory: Math.min(
540
- parseInt(role.scalling.memory.down) || 0,
541
- 100,
542
- ),
543
- },
544
- hysteresis: parseInt(role.scalling.histeresys) || 0,
545
- min_replicas: role.scalling.instances.min || 0,
546
- max_replicas: role.scalling.instances.max || 0,
547
- };
548
- }
549
- return acc;
550
- },
551
- {} as Record<string, any>,
552
- ) || {},
553
- },
554
- };
501
+ const scaleConfig: any = {};
502
+ if (data.role && data.role.length > 0) {
503
+ scaleConfig.detail = {};
504
+ data.role.forEach((role) => {
505
+ scaleConfig.detail[role.name] = {
506
+ hsize: role.hsize || scale || data.minReplicas || 1,
507
+ };
508
+ });
509
+ } else {
510
+ scaleConfig.hsize = scale || data.minReplicas || 1;
511
+ }
512
+ const meta = {
513
+ scaling: {
514
+ simple:
515
+ data.role?.reduce(
516
+ (acc, role) => {
517
+ if (role.scalling && role.name) {
518
+ acc[role.name] = {
519
+ scale_up: {
520
+ cpu: Math.min(parseInt(role.scalling.cpu.up) || 0, 100),
521
+ memory: Math.min(
522
+ parseInt(role.scalling.memory.up) || 0,
523
+ 100,
524
+ ),
525
+ },
526
+ scale_down: {
527
+ cpu: Math.min(parseInt(role.scalling.cpu.down) || 0, 100),
528
+ memory: Math.min(
529
+ parseInt(role.scalling.memory.down) || 0,
530
+ 100,
531
+ ),
532
+ },
533
+ hysteresis: parseInt(role.scalling.histeresys) || 0,
534
+ min_replicas: role.scalling.instances.min || 0,
535
+ max_replicas: role.scalling.instances.max || 0,
536
+ };
537
+ }
538
+ return acc;
539
+ },
540
+ {} as Record<string, any>,
541
+ ) || {},
542
+ },
543
+ };
555
544
 
556
- const updateBody = {
557
- spec: {
558
- type: "update-config",
559
- comment: "Service configuration update",
560
- config: {
561
- parameter: parameterObject,
562
- resource: resourceObject,
563
- resilience: 0,
564
- scale: scaleConfig,
565
- },
566
- meta: meta,
545
+ const updateBody = {
546
+ spec: {
547
+ type: "update-config",
548
+ comment: "Service configuration update",
549
+ config: {
550
+ parameter: parameterObject,
551
+ resource: resourceObject,
552
+ resilience: 0,
553
+ scale: scaleConfig,
567
554
  },
568
- tenant: data.tenant,
569
- service: data.name,
570
- previous: previousRevision,
571
- };
555
+ meta: meta,
556
+ },
557
+ tenant: data.tenant,
558
+ service: data.name,
559
+ previous: previousRevision,
560
+ };
572
561
 
573
- const response = await makeGlobalWebSocketRequest(
574
- "revision:update_revision",
575
- updateBody,
576
- 30000,
577
- "UPDATE_CONFIG",
578
- data.name,
579
- );
580
- }
562
+ const response = await makeGlobalWebSocketRequest(
563
+ "revision:update_revision",
564
+ updateBody,
565
+ 30000,
566
+ "UPDATE_CONFIG",
567
+ data.name,
568
+ );
581
569
 
582
570
  const updatedService: Service = {
583
571
  ...data,
@@ -57,7 +57,6 @@ const extractCloudProviderCredentials = (
57
57
  authUrl: eventData.spec.credentials.openstack?.auth?.auth_url || "",
58
58
  credentialId: eventData.spec.credentials.openstack?.auth?.application_credential_id || "",
59
59
  credentialSecret: eventData.spec.credentials.openstack?.auth?.application_credential_secret || "",
60
- project_id: eventData.spec.credentials.openstack?.auth?.project_id || "",
61
60
  };
62
61
  } else if (eventData.spec.credentials.aws) {
63
62
  providerType = "aws";
@@ -32,6 +32,7 @@ export const handleLinkEvent = ({
32
32
  const serverChannel = eventData.spec.server_channel;
33
33
  const linkServiceServer = `${eventData.spec.server_tenant}/${serverService}`;
34
34
  const linkServiceClient = `${eventData.spec.client_tenant}/${clientService}`;
35
+ const isBeeingDeleted : boolean = !!eventData.meta.deleted;
35
36
  const clientToServerLink: Link = {
36
37
  name: linkId,
37
38
  origin: clientService,
@@ -40,6 +41,7 @@ export const handleLinkEvent = ({
40
41
  targetChannel: serverChannel,
41
42
  client: clientChannel,
42
43
  server: serverChannel,
44
+ delete: isBeeingDeleted,
43
45
  };
44
46
 
45
47
  const serverToClientLink: Link = {
@@ -50,6 +52,7 @@ export const handleLinkEvent = ({
50
52
  targetChannel: serverChannel,
51
53
  client: clientChannel,
52
54
  server: serverChannel,
55
+ delete: isBeeingDeleted,
53
56
  };
54
57
  let updatedServerService: Service | null = null;
55
58
  let serverServiceFound = false;
@@ -253,21 +253,25 @@ const updateServiceWithRevision = (
253
253
  const existingRevisionIndex = existingService.revisions.findIndex(
254
254
  (rev) => rev === entityId,
255
255
  );
256
- const updatedRevisions =
257
- existingRevisionIndex === -1
258
- ? [...existingService.revisions, entityId]
259
- : existingService.revisions;
260
- const currentRevisionTimestamp = Number(existingService.currentRevision) || 0;
261
- const incomingRevisionTimestamp = Number(entityId) || 0;
262
- const updatedCurrentRevision =
263
- incomingRevisionTimestamp > currentRevisionTimestamp
264
- ? entityId
265
- : existingService.currentRevision;
256
+ const shouldIncludeInList =
257
+ newRevision.errorCode !== "COMPUTE_ERROR" &&
258
+ eventData.status?.error?.code !== "COMPUTE_ERROR";
259
+
260
+ let updatedRevisions;
261
+ if (shouldIncludeInList) {
262
+ updatedRevisions =
263
+ existingRevisionIndex === -1
264
+ ? [...existingService.revisions, entityId]
265
+ : existingService.revisions;
266
+ } else {
267
+ updatedRevisions = existingService.revisions.filter(
268
+ (rev) => rev !== entityId,
269
+ );
270
+ }
266
271
 
267
272
  const updatedService: Service = {
268
273
  ...existingService,
269
274
  revisions: updatedRevisions,
270
- currentRevision: updatedCurrentRevision,
271
275
  role: roles.length > 0 ? roles : existingService.role,
272
276
  usage: newRevision.usage,
273
277
  startedAt: newRevision.createdAt || existingService.startedAt,
@@ -524,39 +528,52 @@ export const processRevisionData = (
524
528
  revisionData: any,
525
529
  ): Service => {
526
530
  const { solution } = revisionData;
531
+
532
+ const config = revisionData?.config?.config || {};
533
+ const parameters = extractParametersFromConfig(
534
+ config.parameter || {},
535
+ );
536
+ const resources = extractResources(config.resource || {});
537
+
527
538
  const deploymentName = solution.top || service.name;
528
539
  const deployment = solution.deployments[deploymentName];
529
540
 
530
541
  if (!deployment) {
531
- console.warn(
532
- `No deployment found with name ${deploymentName} in solution. Available deployments:`,
533
- Object.keys(solution.deployments),
534
- );
535
542
  const firstDeploymentKey = Object.keys(solution.deployments)[0];
536
543
  if (firstDeploymentKey) {
537
- console.warn(`Using first available deployment: ${firstDeploymentKey}`);
538
544
  return processDeployment(
539
545
  service,
540
546
  solution.deployments[firstDeploymentKey],
541
547
  revisionData,
548
+ parameters,
549
+ resources,
542
550
  );
543
551
  }
544
- return service;
552
+ return {
553
+ ...service,
554
+ parameters: parameters,
555
+ resources: resources,
556
+ };
545
557
  }
546
558
 
547
- return processDeployment(service, deployment, revisionData);
559
+ return processDeployment(
560
+ service,
561
+ deployment,
562
+ revisionData,
563
+ parameters,
564
+ resources,
565
+ );
548
566
  };
567
+
549
568
  export const processDeployment = (
550
569
  service: Service,
551
570
  deployment: any,
552
571
  revisionData: any,
572
+ parameters: { [key: string]: string }[],
573
+ resources: Resource[],
553
574
  ): Service => {
554
575
  const artifact = deployment.artifact;
555
576
  const deploymentConfig = deployment.config || {};
556
- const serviceResources = extractResources(deploymentConfig.resource || {});
557
- const allServiceParameters = extractParametersFromConfig(
558
- deploymentConfig.parameter || {},
559
- );
560
577
 
561
578
  const rolesDefinition = artifact.description?.role || {};
562
579
  const hasRoles = Object.keys(rolesDefinition).length > 0;
@@ -565,19 +582,6 @@ export const processDeployment = (
565
582
  if (hasRoles) {
566
583
  Object.entries(rolesDefinition).forEach(
567
584
  ([roleName, roleData]: [string, any]) => {
568
- const fileSystemParameters = extractParametersFromFilesystem(
569
- roleData.artifact.description?.code?.[roleName]?.mapping
570
- ?.filesystem || [],
571
- allServiceParameters,
572
- );
573
- allServiceParameters.push(...fileSystemParameters);
574
- const fileSystemResources = extractResourcesFromFilesystem(
575
- roleData.artifact.description?.code?.[roleName]?.mapping
576
- ?.filesystem || [],
577
- serviceResources,
578
- );
579
- serviceResources.push(...fileSystemResources);
580
- const roleResources = extractResources(roleData.config?.resource || {});
581
585
  const existingRole = service.role.find((r) => r.name === roleName);
582
586
  let hsize = 1;
583
587
  if (roleData.config?.scale?.hsize !== undefined) {
@@ -597,8 +601,8 @@ export const processDeployment = (
597
601
  logo: service.logo,
598
602
  description:
599
603
  roleData.artifact?.ref?.module || roleData.ref?.module || "",
600
- resource: roleResources,
601
- parameters: allServiceParameters,
604
+ resource: resources,
605
+ parameters: parameters,
602
606
  hsize: hsize,
603
607
  category: hasDuplex || hasVolumeResource ? "stateful" : "",
604
608
  };
@@ -608,17 +612,14 @@ export const processDeployment = (
608
612
  ) {
609
613
  role.scalling = processScalingConfig(deployment.meta);
610
614
  }
611
-
612
615
  updatedRoles.push(role);
613
616
  },
614
617
  );
615
618
  } else {
616
619
  let hsize = 1;
617
-
618
620
  if (deploymentConfig.scale?.hsize !== undefined) {
619
621
  hsize = deploymentConfig.scale.hsize;
620
622
  }
621
-
622
623
  if (deploymentConfig.scale?.detail?.[""]?.hsize !== undefined) {
623
624
  hsize = deploymentConfig.scale.detail[""].hsize;
624
625
  }
@@ -630,8 +631,8 @@ export const processDeployment = (
630
631
  description:
631
632
  artifact.ref?.module ||
632
633
  (artifact.description?.builtin ? "Builtin Service" : ""),
633
- resource: serviceResources,
634
- parameters: allServiceParameters,
634
+ resource: resources,
635
+ parameters: parameters,
635
636
  hsize: hsize,
636
637
  ...(deployment.meta?.scaling &&
637
638
  Object.keys(deployment.meta.scaling.simple || {}).length > 0 && {
@@ -643,8 +644,8 @@ export const processDeployment = (
643
644
 
644
645
  return {
645
646
  ...service,
646
- resources: serviceResources,
647
- parameters: allServiceParameters,
647
+ resources: resources,
648
+ parameters: parameters,
648
649
  role: updatedRoles,
649
650
  };
650
651
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumori/aurora-backend-handler",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
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.6",
14
+ "@kumori/aurora-interfaces": "^1.0.4",
15
15
  "@kumori/kumori-dsl-generator": "^1.0.3",
16
16
  "@kumori/kumori-module-generator": "^1.1.6",
17
17
  "ts-node": "^10.9.2",
@@ -784,11 +784,36 @@ const handleEvent = async (message: WSMessage) => {
784
784
  break;
785
785
 
786
786
  case "tenant":
787
+ const existingTenant = tenantsMap.get(entityId);
787
788
  const newTenant: Tenant = handleTenantEvent(
788
789
  entityId,
789
790
  eventData,
790
791
  userData,
791
792
  );
793
+ if (existingTenant) {
794
+ if (
795
+ !newTenant.resources?.length &&
796
+ existingTenant.resources?.length
797
+ ) {
798
+ newTenant.resources = existingTenant.resources;
799
+ }
800
+ if (!newTenant.registry?.length && existingTenant.registry?.length) {
801
+ newTenant.registry = existingTenant.registry;
802
+ }
803
+ if (!newTenant.services?.length && existingTenant.services?.length) {
804
+ newTenant.services = existingTenant.services;
805
+ }
806
+ if (
807
+ !newTenant.environments?.length &&
808
+ existingTenant.environments?.length
809
+ ) {
810
+ newTenant.environments = existingTenant.environments;
811
+ }
812
+ if (!newTenant.projects?.length && existingTenant.projects?.length) {
813
+ newTenant.projects = existingTenant.projects;
814
+ }
815
+ }
816
+
792
817
  tenantsMap.set(entityId, newTenant);
793
818
  loadMarketplaceItemsForTenant(entityId, "") //TODO Move to helper
794
819
  .then((items) => {
@@ -1131,7 +1156,12 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
1131
1156
  tenantsMap.set(entityName, newTenant);
1132
1157
  eventHelper.tenant.publish.created(newTenant);
1133
1158
  } else if (action === "UPDATE") {
1134
- const updatedTenant = { ...originalData, status: "active" };
1159
+ const existingTenant = tenantsMap.get(entityName);
1160
+ const updatedTenant = {
1161
+ ...existingTenant,
1162
+ ...originalData,
1163
+ status: "active",
1164
+ };
1135
1165
  tenantsMap.set(entityName, updatedTenant);
1136
1166
  eventHelper.tenant.publish.updated(updatedTenant);
1137
1167
  }