@kumori/aurora-backend-handler 1.1.13 → 1.1.15
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/helpers/service-helper.ts +13 -8
- package/package.json +1 -1
- package/websocket-manager.ts +24 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Channel, Service, Tenant, Usage } from "@kumori/aurora-interfaces";
|
|
1
|
+
import { Channel, Resource, Service, Tenant, Usage } from "@kumori/aurora-interfaces";
|
|
2
2
|
import { Revision } from "@kumori/aurora-interfaces/interfaces/revision-interface";
|
|
3
3
|
import { getTimestamp } from "../utils/utils";
|
|
4
4
|
|
|
@@ -458,7 +458,7 @@ export const handleServiceOperationError = ({
|
|
|
458
458
|
export const mapChannelsFromApiData = (
|
|
459
459
|
apiData: any,
|
|
460
460
|
entityId: string,
|
|
461
|
-
|
|
461
|
+
existingResources?: Resource[],
|
|
462
462
|
): {
|
|
463
463
|
serverChannels: Channel[];
|
|
464
464
|
clientChannels: Channel[];
|
|
@@ -486,12 +486,17 @@ export const mapChannelsFromApiData = (
|
|
|
486
486
|
collectPublic(apiData.client);
|
|
487
487
|
collectPublic(apiData.duplex);
|
|
488
488
|
|
|
489
|
-
const mapChannels = (section: any, target: Channel[]
|
|
489
|
+
const mapChannels = (section: any, target: Channel[]) => {
|
|
490
490
|
if (!section) return;
|
|
491
491
|
Object.entries(section).forEach(
|
|
492
492
|
([channelName, channelData]: [string, any]) => {
|
|
493
493
|
if (channelName.endsWith(inboundSuffix)) return;
|
|
494
|
-
const
|
|
494
|
+
const hasGatewayResource = existingResources?.some(
|
|
495
|
+
(r) =>
|
|
496
|
+
(r.type === "port" || r.type === "domain") &&
|
|
497
|
+
(r.name === `${channelName}_port` || r.name === `${channelName}_domain`),
|
|
498
|
+
) ?? false;
|
|
499
|
+
|
|
495
500
|
target.push({
|
|
496
501
|
name: channelName,
|
|
497
502
|
from: entityId,
|
|
@@ -499,15 +504,15 @@ export const mapChannelsFromApiData = (
|
|
|
499
504
|
protocol: channelData.protocol as "http" | "tcp" | "https",
|
|
500
505
|
port: channelData.port,
|
|
501
506
|
portNum: channelData.port,
|
|
502
|
-
isPublic: publicChannelNames.has(channelName) ||
|
|
507
|
+
isPublic: publicChannelNames.has(channelName) || hasGatewayResource,
|
|
503
508
|
});
|
|
504
509
|
},
|
|
505
510
|
);
|
|
506
511
|
};
|
|
507
512
|
|
|
508
|
-
mapChannels(apiData.server, serverChannels
|
|
509
|
-
mapChannels(apiData.client, clientChannels
|
|
510
|
-
mapChannels(apiData.duplex, duplexChannels
|
|
513
|
+
mapChannels(apiData.server, serverChannels);
|
|
514
|
+
mapChannels(apiData.client, clientChannels);
|
|
515
|
+
mapChannels(apiData.duplex, duplexChannels);
|
|
511
516
|
|
|
512
517
|
return { serverChannels, clientChannels, duplexChannels };
|
|
513
518
|
};
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -1274,11 +1274,7 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1274
1274
|
const channelsInfo = mapChannelsFromApiData(
|
|
1275
1275
|
response.payload.data,
|
|
1276
1276
|
serviceName,
|
|
1277
|
-
|
|
1278
|
-
serverChannels: service.serverChannels,
|
|
1279
|
-
clientChannels: service.clientChannels,
|
|
1280
|
-
duplexChannels: service.duplexChannels
|
|
1281
|
-
}
|
|
1277
|
+
service.resources,
|
|
1282
1278
|
);
|
|
1283
1279
|
service.serverChannels = channelsInfo.serverChannels;
|
|
1284
1280
|
service.clientChannels = channelsInfo.clientChannels;
|
|
@@ -1295,7 +1291,7 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1295
1291
|
svcSuccessResult.revisionData
|
|
1296
1292
|
) {
|
|
1297
1293
|
try {
|
|
1298
|
-
|
|
1294
|
+
let updatedService = processRevisionData(
|
|
1299
1295
|
svcSuccessResult.updatedService!,
|
|
1300
1296
|
svcSuccessResult.revisionData,
|
|
1301
1297
|
revisionsMap,
|
|
@@ -1315,6 +1311,28 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1315
1311
|
};
|
|
1316
1312
|
}
|
|
1317
1313
|
|
|
1314
|
+
const resources = updatedService.resources || [];
|
|
1315
|
+
if (resources.length > 0) {
|
|
1316
|
+
const applyIsPublic = (channels: Channel[]): Channel[] =>
|
|
1317
|
+
channels.map((ch) => ({
|
|
1318
|
+
...ch,
|
|
1319
|
+
isPublic:
|
|
1320
|
+
ch.isPublic ||
|
|
1321
|
+
resources.some(
|
|
1322
|
+
(r) =>
|
|
1323
|
+
(r.type === "port" || r.type === "domain") &&
|
|
1324
|
+
(r.name === `${ch.name}_port` || r.name === `${ch.name}_domain`),
|
|
1325
|
+
),
|
|
1326
|
+
}));
|
|
1327
|
+
|
|
1328
|
+
updatedService = {
|
|
1329
|
+
...updatedService,
|
|
1330
|
+
serverChannels: applyIsPublic(updatedService.serverChannels || []),
|
|
1331
|
+
clientChannels: applyIsPublic(updatedService.clientChannels || []),
|
|
1332
|
+
duplexChannels: applyIsPublic(updatedService.duplexChannels || []),
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1318
1336
|
servicesMap.set(svcSuccessResult.serviceId, updatedService);
|
|
1319
1337
|
|
|
1320
1338
|
if (updatedService.role && updatedService.role.length > 0) {
|