simplify route bindings in config

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2024-01-20 11:16:25 +01:00
parent 475fd94380
commit 86346c2c11
5 changed files with 36 additions and 13 deletions
@@ -37,15 +37,13 @@ describe('collectRouteIds', () => {
createPlugin({ id: 'test', routes: { ref }, externalRoutes: { extRef } }),
]);
expect(Object.fromEntries(collected.routes)).toEqual({
'plugin.test.routes.ref': ref,
'test.ref': ref,
});
expect(Object.fromEntries(collected.externalRoutes)).toEqual({
'plugin.test.externalRoutes.extRef': extRef,
'test.extRef': extRef,
});
expect(String(ref)).toBe('RouteRef{plugin.test.routes.ref}');
expect(String(extRef)).toBe(
'ExternalRouteRef{plugin.test.externalRoutes.extRef}',
);
expect(String(ref)).toBe('RouteRef{test.ref}');
expect(String(extRef)).toBe('ExternalRouteRef{test.extRef}');
});
});
@@ -47,7 +47,7 @@ export function collectRouteIds(features: FrontendFeature[]): RouteRefsById {
}
for (const [name, ref] of Object.entries(feature.routes)) {
const refId = `plugin.${feature.id}.routes.${name}`;
const refId = `${feature.id}.${name}`;
if (routesById.has(refId)) {
throw new Error(`Unexpected duplicate route '${refId}'`);
}
@@ -62,7 +62,7 @@ export function collectRouteIds(features: FrontendFeature[]): RouteRefsById {
}
}
for (const [name, ref] of Object.entries(feature.externalRoutes)) {
const refId = `plugin.${feature.id}.externalRoutes.${name}`;
const refId = `${feature.id}.${name}`;
if (externalRoutesById.has(refId)) {
throw new Error(`Unexpected duplicate external route '${refId}'`);
}