/** * @file * * Mock of Obsidian's `ObjectValue`, the Bases value wrapping an object. */ import type { ObjectValue as ObjectValueOriginal } from 'obsidian'; import { NotNullValue } from './NotNullValue.mjs'; import { Value } from './Value.mjs'; /** * Mock of Obsidian's `ObjectValue`, a Bases value wrapping an object whose properties are `Value`s or raw * data. A raw property is converted to a `Value` the first time {@link ObjectValue.get} reads it. */ export declare class ObjectValue extends NotNullValue { data: Record; /** * The value type's identifier, `'Object'` - Obsidian's own name for this class of value. */ static type: string; /** * The lucide icon name standing for this value's type. * * `lucide-list` rather than an object-shaped glyph, which is Obsidian's own choice, not a copy error. */ icon: string; /** * Creates a value wrapping `data`. * * @param data - The object to wrap, stored as {@link ObjectValue.data}. The object passed in, not a copy. */ constructor(data: Record); /** * Mock-only factory: creates an object value, spyable via `vi.spyOn(ObjectValue, 'create__')`. * * @param data - The object to wrap. * @returns The new object value. */ static create__(data: Record): ObjectValue; /** * Mock-only: views a value typed as Obsidian's `ObjectValue` as this mock. * * @param value - The value typed as the original `ObjectValue`. * @returns The same object, typed as the mock. */ static fromOriginalType3__(value: ObjectValueOriginal): ObjectValue; /** * Mock-only: views this mock as Obsidian's `ObjectValue` type. * * @returns The same object, typed as the original `ObjectValue`. */ asOriginalType3__(): ObjectValueOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(ObjectValue.prototype, 'constructor3__')`. * * @param _data - The object the value was created with. */ constructor3__(_data: unknown): void; /** * Compares this object with another, as Obsidian does: key by key, rather than by the two objects' * string forms. * * @param other - The object to compare with. * @returns `true` when the two wrap the SAME object; `false` when their key counts differ or a key of * this one is missing from the other; otherwise whether every key's value is `Value.equals` to the * other's, each side read through {@link ObjectValue.get} so a raw property is converted first. * Obsidian walks the keys twice, checking presence and then equality; one walk answers the same. */ equals(other: this): boolean; /** * Looks up the value stored under a key. * * @param key - The property name to look up. * @returns `NullValue.value` when the object has no own property under that key. A `Value` property as * it is. Any other property converted by {@link ObjectValue.lazyEvaluator}, which replaces it in * {@link ObjectValue.data}. */ get(key: string): Value; /** * Looks up the value stored under a key, ignoring the case of the key. * * @param key - The property name to look up. * @returns The value under the key itself when the object owns it, otherwise the value under the first * key that differs from it only in case, and otherwise `NullValue.value`. */ getInsensitive(key: string): Value; /** * Reports whether the wrapped object has no own enumerable keys. * * @returns Whether the object has no keys. */ isEmpty(): boolean; /** * Reports whether the value counts as true in a Bases formula. * * @returns Whether the object has at least one key. */ isTruthy(): boolean; /** * Lists the property keys {@link ObjectValue.objectAccess} answers for. * * @returns The wrapped object's own enumerable keys. It REPLACES the inherited list rather than adding to * it, as Obsidian's own override does. */ keys(): string[]; /** * Converts a raw property to a `Value`, as Obsidian's default evaluator does. * * @param _key - The property's name. * @param raw - The raw property. * @returns `NullValue.value` for `null`, `undefined` or a function; a `StringValue`, `NumberValue` * (`NaN` excluded) or `BooleanValue` for a primitive; a `ListValue` over a copy of an array; a * `DateValue` over a copy of a `Date`; and an `ObjectValue` over a shallow copy of any other object. * @throws {Error} For any other raw property, such as a `symbol`, a `bigint` or `NaN`. */ lazyEvaluator(_key: string, raw: unknown): Value; /** * Reads a named property of the wrapped object. * * @param key - The property key, matched without regard to case. * @returns Whatever {@link ObjectValue.getInsensitive} answers, so an unknown key gives `NullValue.value` * rather than the `null` the base answers. */ objectAccess(key: string): null | Value; /** * Renders the object as a string. * * @returns The JSON of an object mapping each own key to the string form of its value, as * {@link ObjectValue.get} reads it. */ toString(): string; /** * Gets the object's property values as they are stored, without converting them. * * @returns The raw property values, each still a `Value` or raw data. */ valuesRaw(): unknown[]; }