/** * Every place a subject address can appear on disk, and the surgery that moves * one. A rename is only honest if it is total: an address left behind is a * dangling reference or, worse, a selector that silently stops matching. The * enumeration below is the single statement of where those addresses live, and * `test/subject-references.test.ts` derives the same set from the JSON Schemas * so a new reference field cannot be added without landing here too. */ /** The four on-disk document kinds that can name a subject. */ export type SubjectReferenceGroup = 'document' | 'projection' | 'evidence' | 'adapter-mapping'; /** * How the address is spelled at a position. * - `declaration`: the subject's own local id, always bare, in its own document. * - `reference`: bare local id (meaning "this document") or fully qualified. * - `qualified`: always `document#local`, optionally with a `~aspect` suffix * (claim addresses are minted that way - see `compiler.ts`). */ export type SubjectReferenceForm = 'declaration' | 'reference' | 'qualified'; export interface SubjectReferencePosition { readonly group: SubjectReferenceGroup; /** * Key path from the document root; `*` matches every element of a * collection, which is every index of a sequence and every value of a * mapping whose keys are open. Both spell `*` because the schema, not the * position, is what decides which one a path lands on: `items` and * `patternProperties` are the same shape of "and now, each of these". */ readonly path: readonly string[]; readonly form: SubjectReferenceForm; } export declare const SUBJECT_REFERENCE_POSITIONS: readonly SubjectReferencePosition[]; /** * Positions that carry reference *syntax* but are not subject addresses, with * the reason. Kept as data because the schema-derived completeness test asserts * that the two lists together account for every reference-typed position: an * omission has to be argued for here rather than forgotten. */ export declare const EXCLUDED_REFERENCE_POSITIONS: readonly { readonly group: SubjectReferenceGroup; readonly path: readonly string[]; readonly reason: string; }[]; export interface SubjectReferenceHit { /** JSON pointer into the document, for diagnostics. */ readonly pointer: string; /** Qualified address with any `~aspect` suffix removed. */ readonly address: string; readonly form: SubjectReferenceForm; /** Source offsets of the scalar's own bytes, quotes included. */ readonly start: number; readonly end: number; /** The scalar exactly as written, quotes included. */ readonly raw: string; } export interface SubjectReferenceScan { /** The document's own id, `''` when it declares none. */ readonly documentId: string; readonly hits: readonly SubjectReferenceHit[]; /** * Pointers at reference positions that hold an alias node. The walker cannot * re-point one, so a rename refuses rather than silently leaving it behind. */ readonly aliases: readonly string[]; } /** * Every subject address a file of this group holds. Pure read: the parse is * thrown away, so callers stay free to splice the original bytes. */ export declare const scanSubjectReferences: (source: string, group: SubjectReferenceGroup) => SubjectReferenceScan; export interface SubjectRename { /** Qualified address as declared today. */ readonly from: string; /** Qualified address it should have had; the document part never moves. */ readonly to: string; } export type SubjectRewriteResult = { readonly ok: true; readonly source: string; /** Pointers this rewrite moved, in document order. */ readonly moved: readonly string[]; } | { readonly ok: false; readonly aliases: readonly string[]; }; /** * Re-points every reference to `rename.from` in one file. Only the matched * scalars' own bytes change - nothing is re-rendered, so byte identity holds * everywhere else, a bare reference stays bare, a qualified one stays * qualified, a `~aspect` suffix survives, and the original quoting is kept. */ export declare const rewriteSubjectReferences: (source: string, group: SubjectReferenceGroup, rename: SubjectRename) => SubjectRewriteResult; /** * Local ids of the architecture states a document declares. States share the * `document#local` spelling with subjects but not the id space, so a rename * whose old or new id collides with one cannot be re-pointed unambiguously and * is refused instead. */ export declare const declaredStateIds: (source: string) => readonly string[];