import { StorageService } from "../../models"; /** * A service following [the template pattern]{@link https://en.wikipedia.org/wiki/Template_method_pattern} * for object storage and retrieval. * * This decouples storage and interpolation from object retrieval, so commands * can delegate those responsibilities and focus on commanding. */ export declare class ObjectService { private storageService; /** * Creates an instance of an ObjectService. * * @param {StorageService} storageService The storage service to back the * ObjectService with. * @returns {ObjectService} An ObjectService instance. * @class * @template T */ constructor(storageService: StorageService); /** * Gets an object by name, and optionally by location. * * @param {string} name The name of the object. * @param {string} location The location of the object. If null, some default * should be used. * @returns {Promise} The object, if found. * @throws If the object cannot be read from that location. * @template T */ get(name: string, location?: string): Promise; /** * Gets an existing object by name, and optionally by location. * * @param {string} name The name of the object. * @param {string} location The location of the object. If null, some default * should be used. * * @returns {Promise} The object, if found: Null otherwise. * @template T */ getIfExists(name: string, location?: string): Promise; /** * Sets an object by name, and optionally by location. * * @param {string} name The name of the object to store. * @param {T} obj The instance of the object to store. * @param {string} location The place to store the object. If null, some * default should be used. * * @template T */ set(name: string, obj: T, location?: string): Promise; /** * Parses an object. The default implementation is backed by JSON.parse or yaml.parse * If this method is used with classes and not just DTOs, this method should be * overridden. * * @param {string} content The JSON object to parse. * @param {string} fileName The name of the file to parse * @returns {T} The parsed object. * @template T */ parse(content: string, fileName: string): T; /** * List all files in a location * * @param {string} location Location to list files * @returns {Promise} List of files */ list(location?: string): Promise; /** * A protected method to find an object. If storage is tree-like, for example, * the definition of find might recursively search towards the root. * * @param {string} name The name of the object to find. * @param {string} startingLocation The location to start in storage. If null, * the search starts at the default location. * * @returns {Promise} The object in JSON format if found: * Otherwise, undefined. */ protected find(name: string, startingLocation?: string): Promise; /** * A protected method to read an object. * * @param {string} name The name of the object to read. * @param {string} location The location to read in storage. If null, reads * from the default location. * * @returns {Promise} The object in JSON format if an * object of that name exists in that location: Otherwise, undefined. */ protected read(name: string, location?: string): Promise; /** * A protected method to write an object. * * @param {string} name The name of the object to write. * @param {string} content The serialized object to write. * @param {string} location The location to write in storage. If null, writes * to the default location. * * @returns {Promise} Whether the write was successful. */ protected write(name: string, content: string, location?: string): Promise; /** * A virtual method to interpolate variables into some provided content. * * @param {string} content Content with variables defined. * * @returns {string} The content with variables replaced. */ protected interpolate(content: string): string; /** * Serializes a DTO. * * @param {T} content A DTO. * @param {string} fileName Name of file * @returns {string} The content turned into a JSON string. * @template T The type to stringify */ protected stringify(content: T, fileName: string): string; private isYamlFile; private isJsonFile; }