@jeffusion/bungee-core 6.5.1 → 6.7.0
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.
|
@@ -7479,16 +7479,16 @@ function parseRoutes(value, catalog, context) {
|
|
|
7479
7479
|
context.add("duplicate_path", `${itemPath}.path`, "Route path must be unique");
|
|
7480
7480
|
else
|
|
7481
7481
|
paths.add(path);
|
|
7482
|
-
const
|
|
7482
|
+
const endpointCandidates = Array.isArray(object.endpoints) ? object.endpoints : [];
|
|
7483
|
+
const referenceCandidates = Array.isArray(object.service_references) ? object.service_references : [];
|
|
7484
|
+
const sharedPositions = normalizePositions([...endpointCandidates, ...referenceCandidates], itemPath, context, (offset) => offset < endpointCandidates.length ? `${itemPath}.endpoints[${offset}]` : `${itemPath}.service_references[${offset - endpointCandidates.length}]`);
|
|
7485
|
+
const references = parseReferences(object.service_references, `${itemPath}.service_references`, context, sharedPositions.slice(endpointCandidates.length), "service_references" in object);
|
|
7483
7486
|
const hasService = references.length > 0;
|
|
7484
7487
|
if ("service_references" in object && !hasService)
|
|
7485
7488
|
context.add("invalid_value", `${itemPath}.service_references`, "Service route requires at least one reference");
|
|
7486
|
-
const endpointCount =
|
|
7489
|
+
const endpointCount = endpointCandidates.length;
|
|
7487
7490
|
const policies = copyKnown(object, ROUTE_KEYS, itemPath, context);
|
|
7488
7491
|
validateRouteDomain(object, itemPath, hasService, endpointCount, context);
|
|
7489
|
-
if (hasService && object.endpoints !== undefined) {
|
|
7490
|
-
context.add("conflicting_owner", `${itemPath}.endpoints`, "A service route cannot own upstreams");
|
|
7491
|
-
}
|
|
7492
7492
|
const base = {
|
|
7493
7493
|
...policies,
|
|
7494
7494
|
id,
|
|
@@ -7496,10 +7496,15 @@ function parseRoutes(value, catalog, context) {
|
|
|
7496
7496
|
path,
|
|
7497
7497
|
plugins: parsePlugins(object.plugins, `${itemPath}.plugins`, catalog, context, "plugins" in object)
|
|
7498
7498
|
};
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7499
|
+
const endpoints = parseUpstreams(object.endpoints, `${itemPath}.endpoints`, catalog, context, "endpoints" in object, sharedPositions);
|
|
7500
|
+
if (hasService) {
|
|
7501
|
+
routes.push({
|
|
7502
|
+
...base,
|
|
7503
|
+
service_references: references,
|
|
7504
|
+
...endpoints.length ? { endpoints } : {}
|
|
7505
|
+
});
|
|
7506
|
+
} else
|
|
7507
|
+
routes.push({ ...base, endpoints });
|
|
7503
7508
|
});
|
|
7504
7509
|
return routes.sort((left, right) => left.position - right.position);
|
|
7505
7510
|
}
|
|
@@ -9484,14 +9489,20 @@ function readRawActiveAggregate(db) {
|
|
|
9484
9489
|
endpoints: takeGroup(upstreams, `service:${row.id}`),
|
|
9485
9490
|
plugins: takeGroup(bindings, `service:${row.id}`)
|
|
9486
9491
|
}));
|
|
9487
|
-
const routes = sqliteAll(db, "SELECT id,position,path,policy_json FROM routes ORDER BY position").map((row) =>
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9492
|
+
const routes = sqliteAll(db, "SELECT id,position,path,policy_json FROM routes ORDER BY position").map((row) => {
|
|
9493
|
+
const key = `route:${row.id}`;
|
|
9494
|
+
const hasReferences = references.has(key);
|
|
9495
|
+
const endpoints = takeGroup(upstreams, key);
|
|
9496
|
+
return {
|
|
9497
|
+
...parseCanonicalObject(row.policy_json, "route policy_json", ROUTE_RESERVED),
|
|
9498
|
+
id: requireUuid(row.id, "routes.id"),
|
|
9499
|
+
position: requireSafeInteger(row.position, "routes.position"),
|
|
9500
|
+
path: row.path,
|
|
9501
|
+
...hasReferences ? takeReferences(key) : {},
|
|
9502
|
+
...!hasReferences || endpoints.length ? { endpoints } : {},
|
|
9503
|
+
plugins: takeGroup(bindings, key)
|
|
9504
|
+
};
|
|
9505
|
+
});
|
|
9495
9506
|
const activations = sqliteAll(db, "SELECT plugin_name FROM plugin_activations ORDER BY plugin_name");
|
|
9496
9507
|
const input = { logical_configuration: {
|
|
9497
9508
|
...readSettings(db),
|