/// import { RoomName } from "../position/types"; type CacheableObject = RoomObject & _HasId; /** A partially cached {@link RoomObject} with {@link Id} */ export type CachedObject = Partial & { id: Id; pos: RoomPosition; room?: undefined; } & Tag.OpaqueTag<"CachedObject">; /** * Check if {@link o} is real or just cached. * @param o object to check * @returns whether the object is cached or not */ export declare function isCachedObject(o: T | CachedObject): o is CachedObject; /** * Try to get real {@link RoomObject} from cached one. * @param o object to restore * @returns real {@link RoomObject} or null */ export declare function restoreCachedObject(o: (CachedObject & { id: Id; }) | T): T | null; interface CacheOpts { /** Try to update the data if age is greater than this */ refresh?: number; /** Data is invalid if age is greater than this */ ttl?: number; /** Fallback function when room not found */ fallback?: (name: RoomName) => C[]; } type FindCacheableConstant = FIND_HOSTILE_CREEPS | FIND_SOURCES | FIND_DROPPED_RESOURCES | FIND_STRUCTURES | FIND_HOSTILE_STRUCTURES | FIND_HOSTILE_SPAWNS | FIND_CONSTRUCTION_SITES | FIND_MY_CONSTRUCTION_SITES | FIND_HOSTILE_CONSTRUCTION_SITES | FIND_MINERALS | FIND_NUKES | FIND_TOMBSTONES | FIND_HOSTILE_POWER_CREEPS | FIND_DEPOSITS | FIND_RUINS; /** * Like {@link Room.find} with {@link CachedObject} * @param type kind of find query * @param defaultOpts optional parameters * @returns an array of {@link CachedObject} */ export declare function findCached, V extends FindTypes[K] = FindTypes[K]>(type: K, defaultOpts: CacheOpts & Partial> & PartialIfExtends<{ map: (v: V) => Untag; }, CachedObject, C>): (name: RoomName, opts?: CacheOpts) => readonly C[]; type PartialIfExtends = A extends B ? Partial : T; type Untag = Omit; export {};