@kumori/aurora-backend-handler 1.0.76 → 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 +126 -121
- package/package.json +1 -1
|
@@ -210,121 +210,122 @@ export const restartService = async (data: Service, security: string) => {
|
|
|
210
210
|
};
|
|
211
211
|
const generateLinkBody = (data: Service, link: Link) => {
|
|
212
212
|
const generateLinkBody = (data: Service, link: Link) => {
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
+
};
|
|
328
329
|
};
|
|
329
330
|
export const linkPendingServices = async (service: Service, token: string) => {
|
|
330
331
|
const links = pendingLinks.get(service.name);
|
|
@@ -604,7 +605,7 @@ export const updateService = async (
|
|
|
604
605
|
},
|
|
605
606
|
};
|
|
606
607
|
eventHelper.service.publish.updated(updatedService);
|
|
607
|
-
|
|
608
|
+
|
|
608
609
|
const updateNotification: Notification = {
|
|
609
610
|
type: "success",
|
|
610
611
|
subtype: "service-updated",
|
|
@@ -616,11 +617,10 @@ export const updateService = async (
|
|
|
616
617
|
tenant: data.tenant,
|
|
617
618
|
},
|
|
618
619
|
};
|
|
619
|
-
|
|
620
|
+
|
|
620
621
|
eventHelper.notification.publish.creation(updateNotification);
|
|
621
622
|
return response;
|
|
622
623
|
}
|
|
623
|
-
|
|
624
624
|
} catch (err) {
|
|
625
625
|
console.error("Error updating service configuration via WebSocket:", err);
|
|
626
626
|
const notification: Notification = {
|
|
@@ -859,10 +859,15 @@ function getLatestRevision(revisions: Revision[]): number | null {
|
|
|
859
859
|
if (!revisions || revisions.length === 0) {
|
|
860
860
|
return null;
|
|
861
861
|
}
|
|
862
|
-
|
|
862
|
+
|
|
863
863
|
return Math.max(...revisions.map((revision) => Number(revision.id)));
|
|
864
864
|
}
|
|
865
|
-
export async function restartInstance(
|
|
865
|
+
export async function restartInstance(
|
|
866
|
+
service: Service,
|
|
867
|
+
roleId: string,
|
|
868
|
+
instanceId: string,
|
|
869
|
+
token: string,
|
|
870
|
+
) {
|
|
866
871
|
try {
|
|
867
872
|
await initializeGlobalWebSocketClient(token);
|
|
868
873
|
const status = getWebSocketStatus();
|
|
@@ -877,7 +882,7 @@ export async function restartInstance(service: Service, roleId: string, instance
|
|
|
877
882
|
revisionBody,
|
|
878
883
|
30000,
|
|
879
884
|
"RESTART_INSTANCE",
|
|
880
|
-
service.name
|
|
885
|
+
service.name,
|
|
881
886
|
);
|
|
882
887
|
const notification: Notification = {
|
|
883
888
|
type: "success",
|