@kumori/aurora-backend-handler 1.0.45 → 1.0.46

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.
@@ -613,7 +613,7 @@ export const deleteAccount = async (account: Account, security: Security) => {
613
613
  credentials: {
614
614
  username: account.cloudProvider.username,
615
615
  password: account.cloudProvider.password,
616
- project_id: account.cloudProvider?.project_id || "",
616
+ project_id: account.cloudProvider.project_id || "",
617
617
  },
618
618
  },
619
619
  };
@@ -628,7 +628,7 @@ export const deleteAccount = async (account: Account, security: Security) => {
628
628
  username: account.cloudProvider.username,
629
629
  password: account.cloudProvider.password,
630
630
  domain: account.cloudProvider.domain,
631
- project_id: account.cloudProvider?.project_id || "",
631
+ project_id: account.cloudProvider.project_id || "",
632
632
  },
633
633
  },
634
634
  };
@@ -7,6 +7,7 @@ import {
7
7
  makeGlobalWebSocketRequest,
8
8
  } from "../websocket-manager";
9
9
  import { Link, Notification, Service } from "@kumori/aurora-interfaces";
10
+ import { Revision } from "@kumori/aurora-interfaces/interfaces/revision-interface";
10
11
  let pendingLinks = new Map<string, Link[]>();
11
12
  /**
12
13
  * Function to deploy a service
@@ -15,13 +16,13 @@ let pendingLinks = new Map<string, Link[]>();
15
16
  export const deployService = async (data: Service, token: string) => {
16
17
  try {
17
18
  const url = new URL(
18
- `${environment.apiServer.baseUrl}/api/${environment.apiServer.apiVersion}/tenant/${data.tenant}/service/${data.name}`,
19
+ `${environment.apiServer.baseUrl}/api/${environment.apiServer.apiVersion}/tenant/${data.tenant}/service/${data.name}`
19
20
  );
20
21
  url.searchParams.append("dryrun", "false");
21
22
  url.searchParams.append("accept", "true");
22
23
  url.searchParams.append("wait", "30000");
23
24
  url.searchParams.append("validate", "true");
24
- if (data.dsl) {
25
+ if(data.dsl){
25
26
  url.searchParams.append("dsl", "true");
26
27
  }
27
28
  if (data.serviceData) {
@@ -32,7 +33,7 @@ export const deployService = async (data: Service, token: string) => {
32
33
  JSON.stringify({
33
34
  targetAccount: data.account,
34
35
  targetEnvironment: data.environment,
35
- }),
36
+ })
36
37
  );
37
38
  formData.append("labels", JSON.stringify({ project: data.project }));
38
39
  formData.append("comment", " ");
@@ -47,7 +48,7 @@ export const deployService = async (data: Service, token: string) => {
47
48
  const jsonResponse = await response.json();
48
49
 
49
50
  const isTimeout = jsonResponse?.events?.some(
50
- (event: any) => event.content === "_timeout_",
51
+ (event: any) => event.content === "_timeout_"
51
52
  );
52
53
 
53
54
  if (isTimeout) {
@@ -80,7 +81,7 @@ export const deployService = async (data: Service, token: string) => {
80
81
  const jsonResponse = await response.json();
81
82
 
82
83
  const isTimeout = jsonResponse?.events?.some(
83
- (event: any) => event.content === "_timeout_",
84
+ (event: any) => event.content === "_timeout_"
84
85
  );
85
86
 
86
87
  if (isTimeout) {
@@ -110,7 +111,7 @@ export const redeployService = async (data: Service) => {
110
111
  try {
111
112
  const formData = await deployServiceHelper(data);
112
113
  const url = new URL(
113
- `${environment.apiServer.baseUrl}/api/${environment.apiServer.apiVersion}/tenant/${data.tenant}/service/${data.name}/revision/${data.currentRevision}`,
114
+ `${environment.apiServer.baseUrl}/api/${environment.apiServer.apiVersion}/tenant/${data.tenant}/service/${data.name}/revision/${data.currentRevision}`
114
115
  );
115
116
  url.searchParams.append("dryrun", "false");
116
117
  url.searchParams.append("accept", "true");
@@ -129,7 +130,7 @@ export const redeployService = async (data: Service) => {
129
130
  const jsonResponse = await response.json();
130
131
 
131
132
  const isTimeout = jsonResponse?.events?.some(
132
- (event: any) => event.content === "_timeout_",
133
+ (event: any) => event.content === "_timeout_"
133
134
  );
134
135
 
135
136
  if (isTimeout) {
@@ -162,7 +163,7 @@ export const deleteService = async (data: Service, security: string) => {
162
163
  deleteBody,
163
164
  30000,
164
165
  "DELETE",
165
- data.name,
166
+ data.name
166
167
  );
167
168
  return response;
168
169
  } catch (err) {
@@ -187,7 +188,7 @@ export const restartService = async (data: Service, security: string) => {
187
188
  restartBody,
188
189
  30000,
189
190
  "RESTART",
190
- data.name,
191
+ data.name
191
192
  );
192
193
 
193
194
  const updatedService: Service = {
@@ -210,33 +211,27 @@ export const restartService = async (data: Service, security: string) => {
210
211
  const generateLinkBody = (data: Service, link: Link) => {
211
212
  const originInClient = data.clientChannels.find(
212
213
  (channel) =>
213
- channel.name === link.originChannel ||
214
- channel.from === link.originChannel,
214
+ channel.name === link.originChannel || channel.from === link.originChannel
215
215
  );
216
216
  const originInServer = data.serverChannels.find(
217
217
  (channel) =>
218
- channel.name === link.originChannel ||
219
- channel.from === link.originChannel,
218
+ channel.name === link.originChannel || channel.from === link.originChannel
220
219
  );
221
220
  const originInDuplex = data.duplexChannels.find(
222
221
  (channel) =>
223
- channel.name === link.originChannel ||
224
- channel.from === link.originChannel,
222
+ channel.name === link.originChannel || channel.from === link.originChannel
225
223
  );
226
224
  const targetInClient = data.clientChannels.find(
227
225
  (channel) =>
228
- channel.name === link.targetChannel ||
229
- channel.from === link.targetChannel,
226
+ channel.name === link.targetChannel || channel.from === link.targetChannel
230
227
  );
231
228
  const targetInServer = data.serverChannels.find(
232
229
  (channel) =>
233
- channel.name === link.targetChannel ||
234
- channel.from === link.targetChannel,
230
+ channel.name === link.targetChannel || channel.from === link.targetChannel
235
231
  );
236
232
  const targetInDuplex = data.duplexChannels.find(
237
233
  (channel) =>
238
- channel.name === link.targetChannel ||
239
- channel.from === link.targetChannel,
234
+ channel.name === link.targetChannel || channel.from === link.targetChannel
240
235
  );
241
236
 
242
237
  let linkBody;
@@ -296,7 +291,7 @@ const generateLinkBody = (data: Service, link: Link) => {
296
291
  };
297
292
  } else {
298
293
  console.warn(
299
- `No se encontraron canales para el enlace: origin=${link.origin}, target=${link.target}`,
294
+ `No se encontraron canales para el enlace: origin=${link.origin}, target=${link.target}`
300
295
  );
301
296
  linkBody = {
302
297
  client_tenant: data.tenant,
@@ -324,7 +319,7 @@ export const linkPendingServices = async (service: Service, token: string) => {
324
319
  linkBody,
325
320
  30000,
326
321
  "LINK",
327
- service.name,
322
+ service.name
328
323
  );
329
324
 
330
325
  const notification: Notification = {
@@ -358,7 +353,7 @@ export const linkPendingServices = async (service: Service, token: string) => {
358
353
  };
359
354
  eventHelper.notification.publish.creation(notification);
360
355
  }
361
- }),
356
+ })
362
357
  );
363
358
  }
364
359
  };
@@ -380,7 +375,7 @@ export const requestRevisionData = async (service: Service, token: string) => {
380
375
  "GET_REVISION",
381
376
  service.name,
382
377
  "service",
383
- service,
378
+ service
384
379
  );
385
380
  return response;
386
381
  } catch (err) {
@@ -577,33 +572,33 @@ export const updateService = async (
577
572
  "UPDATE_CONFIG",
578
573
  data.name,
579
574
  );
575
+ const updatedService: Service = {
576
+ ...data,
577
+ status: {
578
+ code: "PENDING",
579
+ message: "",
580
+ timestamp: "",
581
+ args: [],
582
+ },
583
+ };
584
+ eventHelper.service.publish.updated(updatedService);
585
+
586
+ const updateNotification: Notification = {
587
+ type: "success",
588
+ subtype: "service-updated",
589
+ date: Date.now().toString(),
590
+ status: "unread",
591
+ callToAction: false,
592
+ data: {
593
+ service: data.name,
594
+ tenant: data.tenant,
595
+ },
596
+ };
597
+
598
+ eventHelper.notification.publish.creation(updateNotification);
599
+ return response;
580
600
  }
581
601
 
582
- const updatedService: Service = {
583
- ...data,
584
- status: {
585
- code: "PENDING",
586
- message: "",
587
- timestamp: "",
588
- args: [],
589
- },
590
- };
591
- eventHelper.service.publish.updated(updatedService);
592
-
593
- const updateNotification: Notification = {
594
- type: "success",
595
- subtype: "service-updated",
596
- date: Date.now().toString(),
597
- status: "unread",
598
- callToAction: false,
599
- data: {
600
- service: data.name,
601
- tenant: data.tenant,
602
- },
603
- };
604
-
605
- eventHelper.notification.publish.creation(updateNotification);
606
- return response;
607
602
  } catch (err) {
608
603
  console.error("Error updating service configuration via WebSocket:", err);
609
604
  const notification: Notification = {
@@ -628,7 +623,7 @@ export const updateService = async (
628
623
  };
629
624
  export const unlinkServices = async (service: Service, token: string) => {
630
625
  const deleteLinks: Link[] = service.links.filter(
631
- (link) => link.delete === true,
626
+ (link) => link.delete === true
632
627
  );
633
628
  if (deleteLinks.length > 0) {
634
629
  await Promise.all(
@@ -643,7 +638,7 @@ export const unlinkServices = async (service: Service, token: string) => {
643
638
  unlinkBody,
644
639
  30000,
645
640
  "UNLINK",
646
- service.name,
641
+ service.name
647
642
  );
648
643
 
649
644
  const unlinkNotification: Notification = {
@@ -679,7 +674,7 @@ export const unlinkServices = async (service: Service, token: string) => {
679
674
  };
680
675
  eventHelper.notification.publish.creation(notification);
681
676
  }
682
- }),
677
+ })
683
678
  );
684
679
  }
685
680
  };
@@ -704,7 +699,7 @@ export const updateServiceLinks = async (link: Link, token: string) => {
704
699
  linkBody,
705
700
  30000,
706
701
  "UNLINK",
707
- link.origin,
702
+ link.origin
708
703
  );
709
704
 
710
705
  // const unlinkNotification: Notification = {
@@ -750,7 +745,7 @@ export const updateServiceLinks = async (link: Link, token: string) => {
750
745
  linkBody,
751
746
  30000,
752
747
  "LINK",
753
- link.origin,
748
+ link.origin
754
749
  );
755
750
 
756
751
  const notification: Notification = {
@@ -806,7 +801,7 @@ export const changeRevision = async (data: Service, token: string) => {
806
801
  revisionBody,
807
802
  30000,
808
803
  "UPDATE_REVISION",
809
- data.name,
804
+ data.name
810
805
  );
811
806
  const notification: Notification = {
812
807
  type: "success",
@@ -838,10 +833,10 @@ export const changeRevision = async (data: Service, token: string) => {
838
833
  eventHelper.notification.publish.creation(notification);
839
834
  }
840
835
  };
841
- function getLatestRevision(revisions: string[]): number | null {
836
+ function getLatestRevision(revisions: Revision[]): number | null {
842
837
  if (!revisions || revisions.length === 0) {
843
838
  return null;
844
839
  }
845
-
846
- return Math.max(...revisions.map(Number));
847
- }
840
+
841
+ return Math.max(...revisions.map((revision) => Number(revision.id)));
842
+ }