refactor(housekeeping): adopt ase route namespace

This commit is contained in:
Simo committed 2026-08-26 20:44:38 +02:00
1 parent 74756dfed2
commit f72a2b6c74
32 files changed
+388 -264

No files matched your search

@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import type { CanonicalHousekeepingHref } from "../contracts";
import { toHousekeepingHref } from "./href";
describe("toHousekeepingHref", () => {
it("keeps the canonical operations root unchanged", () => {
expect(toHousekeepingHref("/ase", "canonical")).toBe("/ase");
});
it("maps a canonical domain route to the preview namespace", () => {
expect(toHousekeepingHref("/ase/people/users", "preview")).toBe(
"/ase-next/people/users",
);
});
it("rejects paths outside the canonical ase namespace", () => {
expect(() =>
toHousekeepingHref("/admin" as CanonicalHousekeepingHref, "canonical"),
).toThrow("invalid canonical housekeeping href");
});
});
@@ -0,0 +1,15 @@
import type {
CanonicalHousekeepingHref,
HousekeepingSurface,
} from "../contracts";
export function toHousekeepingHref(
href: CanonicalHousekeepingHref,
surface: HousekeepingSurface,
): CanonicalHousekeepingHref | `/ase-next${string}` {
if (href !== "/ase" && !href.startsWith("/ase/")) {
throw new Error(`invalid canonical housekeeping href: ${href}`);
}
return surface === "canonical" ? href : href.replace(/^\/ase/, "/ase-next");
}