feat(housekeeping): integrate studio operations
CI / check (pull_request) Successful in 38s
CI / release (pull_request) Skipped
CI / deploy (pull_request) Skipped

This commit is contained in:
Simo committed 2026-08-30 15:29:58 +02:00
1 parent 020c06f172
commit 2e95a106e0
36 files changed
+2296 -60

No files matched your search

@@ -28,17 +28,41 @@ export const HOTEL_PRIMARY_ROUTE_IDS = [
] as const;
export type HotelPrimaryRouteId = (typeof HOTEL_PRIMARY_ROUTE_IDS)[number];
export const HOTEL_STUDIO_ROUTE_IDS = [
"hotel.studio.audit",
"hotel.studio.badges",
"hotel.studio.clone",
"hotel.studio.clothing",
"hotel.studio.effects",
"hotel.studio.furni",
"hotel.studio.maintenance",
"hotel.studio.pets",
"hotel.studio.repair-icons",
"hotel.studio.sync",
"hotel.studio.upload",
] as const;
export type HotelStudioRouteId = (typeof HOTEL_STUDIO_ROUTE_IDS)[number];
export type HotelRouteId = HotelPrimaryRouteId | HotelStudioRouteId;
export const HOTEL_STUDIO_OPERATION_BY_ROUTE = Object.freeze({
"hotel.studio.badges": "badge",
"hotel.studio.clone": "clone",
"hotel.studio.clothing": "clothing",
"hotel.studio.effects": "effect",
"hotel.studio.furni": "furni",
"hotel.studio.maintenance": "maintenance",
"hotel.studio.pets": "pet",
"hotel.studio.repair-icons": "repair-icons",
"hotel.studio.sync": "sync",
"hotel.studio.upload": "upload",
} as const);
function route<const Id extends HotelPrimaryRouteId>(
id: Id,
href: CanonicalHousekeepingHref,
permissions: readonly string[],
): HousekeepingRouteDefinition & { readonly id: Id } {
return {
id,
href,
labelKey: `pages.housekeeping.routes.${id}`,
capability: anyCapability(...permissions),
};
return routeDefinition(id, href, permissions);
}
export const HOTEL_PRIMARY_ROUTES = [
@@ -69,18 +93,70 @@ export const HOTEL_PRIMARY_ROUTES = [
).map(([id, href]) => route(id, href, [PERMS.RADIO_VIEW])),
] as const satisfies readonly HousekeepingRouteDefinition[];
function studioRoute<const Id extends HotelStudioRouteId>(
id: Id,
href: CanonicalHousekeepingHref,
): HousekeepingRouteDefinition & { readonly id: Id } {
return routeDefinition(
id,
href,
id === "hotel.studio.maintenance"
? [PERMS.CATALOG_EDIT]
: [PERMS.ASSETS_IMPORT],
);
}
function routeDefinition<const Id extends HotelRouteId>(
id: Id,
href: CanonicalHousekeepingHref,
permissions: readonly string[],
): HousekeepingRouteDefinition & { readonly id: Id } {
return {
id,
href,
labelKey: `pages.housekeeping.routes.${id}`,
capability: anyCapability(...permissions),
};
}
export const HOTEL_STUDIO_ROUTES = [
studioRoute("hotel.studio.audit", "/ase/hotel/studio/audit"),
studioRoute("hotel.studio.badges", "/ase/hotel/studio/badges"),
studioRoute("hotel.studio.clone", "/ase/hotel/studio/clone"),
studioRoute("hotel.studio.clothing", "/ase/hotel/studio/clothing"),
studioRoute("hotel.studio.effects", "/ase/hotel/studio/effects"),
studioRoute("hotel.studio.furni", "/ase/hotel/studio/furni"),
studioRoute("hotel.studio.maintenance", "/ase/hotel/studio/maintenance"),
studioRoute("hotel.studio.pets", "/ase/hotel/studio/pets"),
studioRoute("hotel.studio.repair-icons", "/ase/hotel/studio/repair-icons"),
studioRoute("hotel.studio.sync", "/ase/hotel/studio/sync"),
studioRoute("hotel.studio.upload", "/ase/hotel/studio/upload"),
] as const satisfies readonly HousekeepingRouteDefinition[];
export const HOTEL_ROUTE_IDS = [
...HOTEL_PRIMARY_ROUTE_IDS,
...HOTEL_STUDIO_ROUTE_IDS,
] as const;
export const HOTEL_ROUTES = [
...HOTEL_PRIMARY_ROUTES,
...HOTEL_STUDIO_ROUTES,
] as const satisfies readonly HousekeepingRouteDefinition[];
const ROUTE_BY_ID = new Map(
HOTEL_PRIMARY_ROUTES.map((definition) => [definition.id, definition]),
HOTEL_ROUTES.map((definition) => [definition.id, definition]),
);
export function hotelRouteById(
id: HotelPrimaryRouteId,
): HousekeepingRouteDefinition {
export function hotelRouteById(id: HotelRouteId): HousekeepingRouteDefinition {
const definition = ROUTE_BY_ID.get(id);
if (!definition) throw new Error(`unknown Hotel route: ${id}`);
return definition;
}
export function hotelStudioOperationKind(id: HotelStudioRouteId) {
if (id === "hotel.studio.audit") return null;
return HOTEL_STUDIO_OPERATION_BY_ROUTE[id];
}
export function hotelRouteGroup(id: HotelPrimaryRouteId): HotelRouteGroup {
if (id === "hotel.navigation") return "navigation";
return id.startsWith("hotel.radio.") ? "radio" : "rooms";