import { ISerializableState } from './common'; import { IChroniclerDescription, IClassifier, IDataEvent, IDisposableAsync, IFormatSettings, IStatusEvent } from './dataEmitter'; /** * Check if any object conforms to the IJsonSerializable interface * @param {unknown} obj * @return {boolean} */ export declare function isJsonSerializable(obj: unknown): boolean; /** * Enforce the object providing controlled * serialization to avoid circuler references */ export interface IJsonSerializable { /** * gets the object in record form to support * serialization and persistence * @return {Record} */ toJSON(): Record; } /** * Basic Chronicler interface that allows persist a * record of the provided object */ export interface IChronicler extends IDisposableAsync, IClassifier, ISerializableState { /** * Save the provided object into a persistent store, * uses the * @return {Promise} * @param {IJsonSerializable|IDataEvent|IStatusEvent} record */ saveRecord(record: IJsonSerializable | IDataEvent | IStatusEvent): Promise; } /** * Additional contract for a chronicler that * persists to a file */ export interface IFileChronicler extends IChronicler { /** * Gets the file name of the current file being used to persist records * @return {string} the active filename */ getCurrentFilename(): string; } /** * Contracts for a chronicler that persists to rotating file stores */ export interface IRotatingFileChronicler extends IFileChronicler { /** * Find all uncompressed record files and compress them * @return {Promise} */ compactLogs(): Promise; /** * Create a new active record file to write to and compress * the old one * @return {Promise} */ rotateLog(): Promise; } /** * Base chronicler */ export declare abstract class BaseChronicler implements IChronicler { protected _id: string; protected _name: string; protected _description: string; /** * Unique id of the chronicler */ get id(): string; /** * Name of the chronicler */ get name(): string; /** * Description of the chronicler */ get description(): string; /** * * @param {IChroniclerDescription} desc */ constructor(desc: IChroniclerDescription); /** * * @param {IJsonSerializable} record * @return {Promise} */ abstract saveRecord(record: IJsonSerializable): Promise; /** * Get the chronicler properties for this instance */ abstract getChroniclerProperties(): unknown; /** * Get the chronicler type for this instance */ abstract getType(): string; /** * Dispose any resources that will not be automatically be cleaned up, * Returns a promise that is resolved when all of the resources have been cleaned up * @return {Promise} */ abstract disposeAsync(): Promise; /** * Gets the chronicler description which is used to recreate the chronicler * @return {IChroniclerDescription} */ protected getChronicerDescription(): IChroniclerDescription; /** * * @param {IFormatSettings} settings * @return {Promise} */ serializeState(settings: IFormatSettings): Promise; }