feat(housekeeping): dispatch canonical domain routes

This commit is contained in:
Simo committed 2026-08-28 21:35:08 +02:00
1 parent 2970dff563
commit e5c230ba35
13 files changed
+680 -82

No files matched your search

@@ -23,6 +23,7 @@ export function createHousekeepingRegistry(
const domainIds = new Set<string>();
const routeIds = new Set<string>();
const routeHrefs = new Set<string>();
const routeShapes = new Set<string>();
const registryEntryIds = new Set<string>();
for (const manifest of manifests) {
@@ -83,6 +84,12 @@ export function createHousekeepingRegistry(
}
routeHrefs.add(route.href);
const routeShape = dynamicRouteShape(route.href);
if (routeShape && routeShapes.has(routeShape)) {
throw new Error(`duplicate dynamic route shape: ${routeShape}`);
}
if (routeShape) routeShapes.add(routeShape);
validateNonEmpty(route.labelKey, "route label key");
validateCapability(route.capability);
}
@@ -91,6 +98,20 @@ export function createHousekeepingRegistry(
return { domains: Object.freeze([...manifests]) };
}
function dynamicRouteShape(href: string): string | null {
let hasDynamicSegment = false;
const shape = href
.split("/")
.map((segment) => {
if (!segment.startsWith(":")) return segment;
hasDynamicSegment = true;
return ":";
})
.join("/");
return hasDynamicSegment ? shape : null;
}
function validateOwnedRegistryEntries(
entries: readonly OwnedRegistryEntry[],
owner: HousekeepingDomainManifest["id"],