import "server-only"; import { SYSTEM_COMMANDS } from "../../domains/system/commands/system-commands"; import type { HousekeepingCommand } from "./registry"; import { registerHousekeepingCommand, sealHousekeepingCommandRegistry, } from "./registry"; type PreserveHousekeepingCommand = Definition extends HousekeepingCommand ? Definition : never; type HousekeepingCommandTuple = Commands & { readonly [Index in keyof Commands]: PreserveHousekeepingCommand< Commands[Index] >; }; export function defineHousekeepingCommands< const Commands extends readonly unknown[], >(...commands: HousekeepingCommandTuple): Commands { return commands; } export function registerHousekeepingCommands< const Commands extends readonly unknown[], >(commands: HousekeepingCommandTuple): void { for (const command of commands) { registerHousekeepingCommand( command as unknown as HousekeepingCommand, ); } } const currentHousekeepingCommands = defineHousekeepingCommands( ...SYSTEM_COMMANDS, ); registerHousekeepingCommands(currentHousekeepingCommands); sealHousekeepingCommandRegistry(); export const housekeepingCommandRegistryReady = true;