/** * @file * * Mock of Obsidian's `BasesViewConfig`, the settings of one view in a Bases file. */ import type { BasesPropertyId as BasesPropertyIdOriginal, BasesSortConfig as BasesSortConfigOriginal, BasesViewConfig as BasesViewConfigOriginal, Value as ValueOriginal } from 'obsidian'; import type { BasesView } from './BasesView.mjs'; /** * Mock of Obsidian's `BasesViewConfig`: the in-memory form of one entry in a Bases file's `views` section. * * The mock keeps options, display names, property order and sort in memory; it evaluates no formulas. */ export declare class BasesViewConfig { /** * The user-facing name of the view. */ name: string; private readonly config; private readonly displayNames; private order; private sort; /** * Creates an empty view configuration. * * @param query - The Base's query; only forwarded to the construction hook. * @param type - The view type id; only forwarded to the construction hook. * @param name - The user-facing name of the view. */ protected constructor(query: string, type: string, name: string); /** * Mock-only factory: creates a view configuration, spyable via `vi.spyOn(BasesViewConfig, 'create__')`. * * @param query - The Base's query. * @param type - The view type id. * @param name - The user-facing name of the view. * @returns The new view configuration. */ static create__(query: string, type: string, name: string): BasesViewConfig; /** * Mock-only: views a value typed as Obsidian's `BasesViewConfig` as this mock. * * @param value - The value typed as the original `BasesViewConfig`. * @returns The same object, typed as the mock. */ static fromOriginalType__(value: BasesViewConfigOriginal): BasesViewConfig; /** * Mock-only: views this mock as Obsidian's `BasesViewConfig` type. * * @returns The same object, typed as the original `BasesViewConfig`. */ asOriginalType__(): BasesViewConfigOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(BasesViewConfig.prototype, 'constructor__')`. * * @param _query - The query the configuration was created with. * @param _type - The view type id the configuration was created with. * @param _name - The name the configuration was created with. */ constructor__(_query: string, _type: string, _name: string): void; /** * Reads a user-configured view option. * * @param key - The option key. * @returns The value stored with {@link BasesViewConfig.set}, or `undefined` when none is. */ get(key: string): unknown; /** * Reads a user-configured option as a property id. * * @param key - The option key. * @returns The stored value when it is a string, otherwise `null`. Unlike Obsidian, the mock does not validate * the id. */ getAsPropertyId(key: string): BasesPropertyIdOriginal | null; /** * Gets the user-facing name of a property. * * @param propertyId - The property id, such as `note.status`. * @returns The name set with {@link BasesViewConfig.setDisplayName__}, otherwise the id without its type prefix. */ getDisplayName(propertyId: BasesPropertyIdOriginal): string; /** * Evaluates a configured option as a formula in the context of the current Base. The mock evaluates nothing. * * @param _view - The view to evaluate the formula for. * @param _key - The option key holding the formula. * @returns Always `NullValue.value`, the singleton Obsidian answers with on each of its four * non-evaluating paths: a missing key, a value that is not a string, a formula that parses to an error, * and a formula that throws while evaluating. */ getEvaluatedFormula(_view: BasesView, _key: string): ValueOriginal; /** * Gets the ordered list of properties the view displays, such as a table's visible columns. * * @returns The order last set with {@link BasesViewConfig.setOrder}, initially empty. */ getOrder(): BasesPropertyIdOriginal[]; /** * Gets the view's sort configuration. * * @returns The sort last set with {@link BasesViewConfig.setSort__}, initially empty. */ getSort(): BasesSortConfigOriginal[]; /** * Stores a configuration value for the view, in memory in the mock. * * @param key - The option key. * @param value - The value to store. */ set(key: string, value: unknown): void; /** * Mock-only: simulates the user renaming a property, which {@link BasesViewConfig.getDisplayName} then returns. * * @param propertyId - The property id. * @param displayName - The name to show for it. */ setDisplayName__(propertyId: BasesPropertyIdOriginal, displayName: string): void; /** * Sets the ordered list of displayed properties returned by {@link BasesViewConfig.getOrder}. * * @param order - The property ids, in display order. */ setOrder(order: BasesPropertyIdOriginal[]): void; /** * Mock-only: simulates the user configuring the sort returned by {@link BasesViewConfig.getSort}. * * @param sort - The sort configuration. */ setSort__(sort: BasesSortConfigOriginal[]): void; }