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