import type { SlimType } from '@idfkit/schemas'; import type { IdfObject } from './object.js'; /** * Per-object-type prototype carrying real accessors for every field. * * The Python library resolves `zone.ceiling_height` through `__getattr__`. The * mechanical translation of that is a `Proxy`, which we deliberately do not use: * proxies defeat V8's inline caches, and more importantly they are invisible to * TypeScript, so nothing would autocomplete. Instead each object type gets one * prototype with `Object.defineProperty` accessors, built once and shared by * every instance of that type. Property access is then an ordinary monomorphic * lookup, and the generated `.d.ts` interfaces describe it statically. * * Shapes are keyed by the schema definition object rather than by type name. * Because the schema bundle is content-addressed, `Zone` in 9.4.0 and `Zone` in * 26.1.0 are the same frozen definition, so they share one shape and one * prototype. Cross-version documents stay monomorphic for free. */ export declare class ObjectShape { readonly typeName: string; readonly type: SlimType; readonly proto: object; /** Field names in IDF positional order, excluding the name field. */ readonly fields: readonly string[]; /** Fields that point into a reference list, i.e. foreign keys. */ readonly refFields: readonly string[]; /** * Fields *inside* the extensible group that point into a reference list. * * Kept separate from `refFields` because these live in `type.x.fields`, not * the positional field list, and so need the repeat index to address them. * Ignoring them is not cosmetic: `ZoneList`, `Branch`, and the supply/return * paths carry all of their references here, so leaving them out of the graph * makes `rename()` silently produce a broken model. */ readonly extensibleRefFields: readonly string[]; /** Fields whose value declares a name other objects may reference. */ readonly keyFields: readonly string[]; /** Extensible array key (`vertices`), if this type has one. */ readonly extensibleKey: string | undefined; /** Whether the object carries a name (most do; `Version` does not). */ readonly named: boolean; constructor(typeName: string, type: SlimType, base: object); } /** * Get (or build) the shape for an object type. * * `base` is `IdfObject.prototype`, threaded in rather than imported to keep * this module free of a cycle with `object.ts`. */ export declare function shapeFor(typeName: string, type: SlimType, base: object): ObjectShape; /** Number of distinct shapes built, for tests and diagnostics. */ export declare function shapeOf(obj: IdfObject): ObjectShape; /** * Schema spellings of a choice field's values, folded for lookup. * * `Map>`. A field with no * string choices is absent rather than present and empty, so a lookup that misses costs * nothing. */ export type ChoiceSpellings = ReadonlyMap>; /** The two field lists a type has: its positional fields, and one repeat of its extensible group. */ export interface TypeChoiceSpellings { /** By positional field name. */ readonly fields: ChoiceSpellings; /** By field name inside one extensible repeat, e.g. `Branch`'s `component_object_type`. */ readonly extensible: ChoiceSpellings; } /** * Get (or build) the choice spellings for an object type. * * Keyed by the definition rather than by the type name, for the reason the shape cache is: * definitions are content-addressed, so `Zone` in 9.4.0 and in 26.1.0 are one frozen object * and share one table. * * Built on demand and not in `ObjectShape`'s constructor, because only the epJSON writer asks: * a parse, an edit, and an IDF write never touch a table this would have folded 5,713 enums * into. */ export declare function choiceSpellingsFor(type: SlimType): TypeChoiceSpellings; /** * The choice spelling a value stands for, or the value unchanged. * * A value that matches no choice is returned as it came, which is what leaves an invalid value * for `validateDocument` to report: canonicalising is not validating, and a writer that * silently repaired a value nobody declared would hide the fault rather than fix it. */ export declare function spellChoice(value: string, spellings: ReadonlyMap | undefined): string; //# sourceMappingURL=shape.d.ts.map