import { Paths } from '../../utils/index.js'; import { World } from '../../domain/index.js'; import type { IWorldRepository, WorldWithServerStatus } from '../../application/ports/outbound/IWorldRepository.js'; import type { IWorldAssignmentPort } from '../../application/ports/outbound/IWorldAssignmentPort.js'; import type { IContainerRuntimePort } from '../../application/ports/outbound/IContainerRuntimePort.js'; /** * World layout descriptor returned by findWorldLayout */ export interface WorldLayout { /** Absolute path to the directory that contains level.dat */ mainDir: string; /** Absolute path to the nether satellite directory, if present */ nether?: string; /** Absolute path to the_end satellite directory, if present */ theEnd?: string; } /** * Recursively find all level.dat files under rootDir, pick the shallowest * one, and detect split-dimension satellite sibling directories. * * Exported so that unit tests can exercise it with plain directory fixtures. */ export declare function findWorldLayout(rootDir: string): Promise; /** * WorldRepository * Implements IWorldRepository for world data access. * * A world is "locked" when a server's LEVEL points at it (#670, ADR-0002): * isLocked/lockedBy mean "assigned". worlds/.locks is never read or written. */ export declare class WorldRepository implements IWorldRepository { private readonly paths; private readonly worldsDir; private readonly assignments; private readonly runtime; /** * @param runtime Runtime status of the assigned servers (#665). Defaults to * the Docker adapter the legacy facade used. */ constructor(paths?: Paths, assignments?: IWorldAssignmentPort, runtime?: IContainerRuntimePort); /** * Get all worlds */ findAll(): Promise; /** * Find world by name */ findByName(name: string): Promise; /** * Listings are read-only, so an unreadable servers/ shows every world as * unassigned; assignment changes go through the port and fail there (R7). */ private snapshot; private load; /** * Check if world exists */ exists(name: string): Promise; /** * Get unlocked worlds */ findUnlocked(): Promise; /** * Get locked worlds */ findLocked(): Promise; /** * Get worlds locked by a specific server */ findByServer(serverName: string): Promise; /** * List world names */ listNames(): Promise; /** * Get all worlds with their server status * Returns worlds categorized by availability */ findAllWithServerStatus(): Promise; /** * Delete a world directory. * Also deletes split-dimension satellites (_nether, _the_end). * Returns true if the main world was deleted. */ delete(name: string): Promise; /** * Create a new world directory with optional seed */ create(name: string, seed?: string): Promise; /** * Get seed for a world from .meta file */ getSeed(name: string): Promise; /** * Import a world from a .zip archive at zipPath. * 1. Throws if worlds/ already exists. * 2. Extracts zip into a fresh temp dir. * 3. Calls assembleWorld to move files to their final locations. * 4. Cleans up the temp dir (even on error). * 5. On error after creating target dirs, rolls back. */ importFromZip(name: string, zipPath: string): Promise; /** * Extract a zip file into destDir with defenses against: * - decompression bombs (cumulative uncompressed-size + entry-count caps, * pre-checked from the central directory and re-checked while streaming), and * - zip-slip (every entry is resolved and confirmed to stay within destDir). */ private extractZip; /** * Assemble an extracted world tree into the worlds/ directory. * Detects the world layout, moves the main dir and satellites. * Writes a .meta file in the main world dir. */ private assembleWorld; /** * Move a directory from src to dest. * Falls back to recursive copy + rm when rename fails (cross-device EXDEV). */ private moveDir; /** * Get directory size recursively */ private getDirectorySize; } //# sourceMappingURL=WorldRepository.d.ts.map