@kumori/aurora-backend-handler 1.0.75 → 1.0.77
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/service-api-service.ts +127 -100
- package/package.json +1 -1
|
@@ -209,100 +209,123 @@ export const restartService = async (data: Service, security: string) => {
|
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
const generateLinkBody = (data: Service, link: Link) => {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
212
|
+
const generateLinkBody = (data: Service, link: Link) => {
|
|
213
|
+
const isOrigin = data.name === link.origin;
|
|
214
|
+
const isTarget = data.name === link.target;
|
|
215
|
+
|
|
216
|
+
const originInClient = isOrigin
|
|
217
|
+
? data.clientChannels.find(
|
|
218
|
+
(channel) =>
|
|
219
|
+
channel.name === link.originChannel ||
|
|
220
|
+
channel.from === link.originChannel,
|
|
221
|
+
)
|
|
222
|
+
: undefined;
|
|
223
|
+
const originInServer = isOrigin
|
|
224
|
+
? data.serverChannels.find(
|
|
225
|
+
(channel) =>
|
|
226
|
+
channel.name === link.originChannel ||
|
|
227
|
+
channel.from === link.originChannel,
|
|
228
|
+
)
|
|
229
|
+
: undefined;
|
|
230
|
+
const originInDuplex = isOrigin
|
|
231
|
+
? data.duplexChannels.find(
|
|
232
|
+
(channel) =>
|
|
233
|
+
channel.name === link.originChannel ||
|
|
234
|
+
channel.from === link.originChannel,
|
|
235
|
+
)
|
|
236
|
+
: undefined;
|
|
237
|
+
const targetInClient = isTarget
|
|
238
|
+
? data.clientChannels.find(
|
|
239
|
+
(channel) =>
|
|
240
|
+
channel.name === link.targetChannel ||
|
|
241
|
+
channel.from === link.targetChannel,
|
|
242
|
+
)
|
|
243
|
+
: undefined;
|
|
244
|
+
const targetInServer = isTarget
|
|
245
|
+
? data.serverChannels.find(
|
|
246
|
+
(channel) =>
|
|
247
|
+
channel.name === link.targetChannel ||
|
|
248
|
+
channel.from === link.targetChannel,
|
|
249
|
+
)
|
|
250
|
+
: undefined;
|
|
251
|
+
const targetInDuplex = isTarget
|
|
252
|
+
? data.duplexChannels.find(
|
|
253
|
+
(channel) =>
|
|
254
|
+
channel.name === link.targetChannel ||
|
|
255
|
+
channel.from === link.targetChannel,
|
|
256
|
+
)
|
|
257
|
+
: undefined;
|
|
258
|
+
|
|
259
|
+
let linkBody;
|
|
260
|
+
if (originInClient) {
|
|
261
|
+
linkBody = {
|
|
262
|
+
client_tenant: data.tenant,
|
|
263
|
+
client_service: data.name,
|
|
264
|
+
client_channel: link.originChannel,
|
|
265
|
+
server_tenant: data.tenant,
|
|
266
|
+
server_service: link.target,
|
|
267
|
+
server_channel: link.targetChannel,
|
|
268
|
+
};
|
|
269
|
+
} else if (targetInClient) {
|
|
270
|
+
linkBody = {
|
|
271
|
+
client_tenant: data.tenant,
|
|
272
|
+
client_service: data.name,
|
|
273
|
+
client_channel: link.targetChannel,
|
|
274
|
+
server_tenant: data.tenant,
|
|
275
|
+
server_service: link.origin,
|
|
276
|
+
server_channel: link.originChannel,
|
|
277
|
+
};
|
|
278
|
+
} else if (originInServer) {
|
|
279
|
+
linkBody = {
|
|
280
|
+
client_tenant: data.tenant,
|
|
281
|
+
client_service: link.target,
|
|
282
|
+
client_channel: link.targetChannel,
|
|
283
|
+
server_tenant: data.tenant,
|
|
284
|
+
server_service: data.name,
|
|
285
|
+
server_channel: link.originChannel,
|
|
286
|
+
};
|
|
287
|
+
} else if (targetInServer) {
|
|
288
|
+
linkBody = {
|
|
289
|
+
client_tenant: data.tenant,
|
|
290
|
+
client_service: link.origin,
|
|
291
|
+
client_channel: link.originChannel,
|
|
292
|
+
server_tenant: data.tenant,
|
|
293
|
+
server_service: data.name,
|
|
294
|
+
server_channel: link.targetChannel,
|
|
295
|
+
};
|
|
296
|
+
} else if (originInDuplex) {
|
|
297
|
+
linkBody = {
|
|
298
|
+
client_tenant: data.tenant,
|
|
299
|
+
client_service: link.target,
|
|
300
|
+
client_channel: link.targetChannel,
|
|
301
|
+
server_tenant: data.tenant,
|
|
302
|
+
server_service: data.name,
|
|
303
|
+
server_channel: link.originChannel,
|
|
304
|
+
};
|
|
305
|
+
} else if (targetInDuplex) {
|
|
306
|
+
linkBody = {
|
|
307
|
+
client_tenant: data.tenant,
|
|
308
|
+
client_service: link.origin,
|
|
309
|
+
client_channel: link.originChannel,
|
|
310
|
+
server_tenant: data.tenant,
|
|
311
|
+
server_service: data.name,
|
|
312
|
+
server_channel: link.targetChannel,
|
|
313
|
+
};
|
|
314
|
+
} else {
|
|
315
|
+
console.warn(
|
|
316
|
+
`No se encontraron canales para el enlace: origin=${link.origin}, target=${link.target}`,
|
|
317
|
+
);
|
|
318
|
+
linkBody = {
|
|
319
|
+
client_tenant: data.tenant,
|
|
320
|
+
client_service: link.origin,
|
|
321
|
+
client_channel: link.originChannel,
|
|
322
|
+
server_tenant: data.tenant,
|
|
323
|
+
server_service: link.target,
|
|
324
|
+
server_channel: link.targetChannel,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return linkBody;
|
|
328
|
+
};
|
|
306
329
|
};
|
|
307
330
|
export const linkPendingServices = async (service: Service, token: string) => {
|
|
308
331
|
const links = pendingLinks.get(service.name);
|
|
@@ -582,7 +605,7 @@ export const updateService = async (
|
|
|
582
605
|
},
|
|
583
606
|
};
|
|
584
607
|
eventHelper.service.publish.updated(updatedService);
|
|
585
|
-
|
|
608
|
+
|
|
586
609
|
const updateNotification: Notification = {
|
|
587
610
|
type: "success",
|
|
588
611
|
subtype: "service-updated",
|
|
@@ -594,11 +617,10 @@ export const updateService = async (
|
|
|
594
617
|
tenant: data.tenant,
|
|
595
618
|
},
|
|
596
619
|
};
|
|
597
|
-
|
|
620
|
+
|
|
598
621
|
eventHelper.notification.publish.creation(updateNotification);
|
|
599
622
|
return response;
|
|
600
623
|
}
|
|
601
|
-
|
|
602
624
|
} catch (err) {
|
|
603
625
|
console.error("Error updating service configuration via WebSocket:", err);
|
|
604
626
|
const notification: Notification = {
|
|
@@ -837,10 +859,15 @@ function getLatestRevision(revisions: Revision[]): number | null {
|
|
|
837
859
|
if (!revisions || revisions.length === 0) {
|
|
838
860
|
return null;
|
|
839
861
|
}
|
|
840
|
-
|
|
862
|
+
|
|
841
863
|
return Math.max(...revisions.map((revision) => Number(revision.id)));
|
|
842
864
|
}
|
|
843
|
-
export async function restartInstance(
|
|
865
|
+
export async function restartInstance(
|
|
866
|
+
service: Service,
|
|
867
|
+
roleId: string,
|
|
868
|
+
instanceId: string,
|
|
869
|
+
token: string,
|
|
870
|
+
) {
|
|
844
871
|
try {
|
|
845
872
|
await initializeGlobalWebSocketClient(token);
|
|
846
873
|
const status = getWebSocketStatus();
|
|
@@ -855,7 +882,7 @@ export async function restartInstance(service: Service, roleId: string, instance
|
|
|
855
882
|
revisionBody,
|
|
856
883
|
30000,
|
|
857
884
|
"RESTART_INSTANCE",
|
|
858
|
-
service.name
|
|
885
|
+
service.name,
|
|
859
886
|
);
|
|
860
887
|
const notification: Notification = {
|
|
861
888
|
type: "success",
|