import type { SysmlIdentity, SysmlIR } from '../sysml-ir/index.js'; /** * A write was made against an identity the current IR does not have. * * Loud on purpose. The alternative — falling back to a name lookup — is how a * write ends up editing the wrong element, which is the failure this whole * module exists to make impossible. */ export declare class StaleIrIdentityError extends Error { readonly identityId: string; constructor(identityId: string, detail: string); } /** The wire form: what a client needs to name an element in a later write. */ export type IrIdentityTable = Record; /** What an index knows about one addressable declaration. */ export interface IrIdentityEntry { identity: SysmlIdentity; /** The Memo element it projects to, when the projection mapped it. */ memoElementId?: string; } export interface IrIdentityIndex { /** Memo element ID → IR identity ID, for elements the projection mapped. */ readonly byMemoElement: IrIdentityTable; /** IR identity ID → the declaration it names. */ readonly byIdentity: ReadonlyMap; } /** * Index one IR for identity resolution. * * Both directions are needed and neither is derivable cheaply from the other: * the client holds Memo element IDs and has to mint an identity from one, and * the server holds an identity and has to find what it names. */ export declare function buildIrIdentityIndex(ir: SysmlIR | undefined): IrIdentityIndex; /** * Rebuild an index from the compact table alone. * * The whole IR is not shipped with a model update — `standardProperties` carry * every declared property of every node, and a surface that only needs to * *address* an element does not need its contents. The identity ID is a * self-describing string, so the table is enough to reconstruct everything the * resolver uses. */ export declare function indexFromIdentityTable(table: IrIdentityTable | undefined): IrIdentityIndex; /** * Read an identity ID back into its parts. * * `file:///…/model/a.sysml#members[0]/members[2]:PartUsage`. The file URI may * itself contain `#` only if percent-encoded, and the metaclass never contains * `:`, so splitting at the first `#` and the last `:` is unambiguous. */ export declare function parseSysmlIdentityId(id: string): SysmlIdentity | undefined; /** * The compact table shipped with a model update. * * The whole IR is not sent: its `standardProperties` carry every declared * property of every node, and a client that only needs to address an element * does not need its contents. */ export declare function irIdentityTable(ir: SysmlIR | undefined): IrIdentityTable; /** * Resolve an identity ID against the current IR, or fail loudly. * * `expectedMemoElementId`, when given, is checked too: an identity that still * exists but now names a different element is exactly as stale as one that has * disappeared, and it is the more dangerous of the two. */ export declare function requireIrIdentity(index: IrIdentityIndex, identityId: string, expectedMemoElementId?: string): IrIdentityEntry; /** The identity a client should quote when it writes to this element. */ export declare function identityForMemoElement(index: IrIdentityIndex, memoElementId: string): string | undefined; /** `members[3]/members[1]` → `[3, 1]`. Any other shape is not a path we minted. */ export declare function parseDeclarationPath(declarationPath: string): number[] | undefined; /** The project-relative file an identity's URI names, given the project root. */ export declare function identityFile(identity: SysmlIdentity, projectRoot: string): string | undefined; /** True when this identity was minted for that project-relative file. */ export declare function identityNamesFile(identity: SysmlIdentity, projectRoot: string, relativePath: string): boolean; /** * Walk a parsed document to the declaration an identity addresses. * * The metaclass is verified, not assumed: a path that still resolves but to a * different kind of declaration means the file was edited underneath this * identity, and continuing would rewrite the wrong lines. */ export declare function resolveDeclarationByIdentity(root: { members?: unknown[]; }, identity: SysmlIdentity): { $type?: string; name?: string; $cstNode?: { offset: number; length: number; }; }; //# sourceMappingURL=ir-identity.d.ts.map