/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import type { PathParseResult, PathSegment } from './path-types.js'; /** * Parse a declaration path: dotted, index-free, block types written as plain * segments (`content.photoBlock.gallery.alt`). * * Every segment comes back as `kind: 'field'`. Item indices are a parse * error rather than something silently dropped — a caller writing * `files[0].caption` where a declaration is expected has made a category * mistake, and saying so is more useful than quietly addressing every item. */ export declare function parseDeclarationPath(path: string): PathParseResult; /** * Parse an instance path: dotted field names with bracket item selectors, * either positional (`gallery[1]`) or by stable id (`gallery[id=abc]`). * * Blocks carry no discriminator here — the addressed item resolves its own * `_type` — so a block hop is just the blocks field name followed by an * item selector. */ export declare function parseInstancePath(path: string): PathParseResult; /** * Serialise segments as a declaration path. Index and id segments are * dropped, so this doubles as the instance → declaration projection when * applied to instance segments. */ export declare function formatDeclarationPath(segments: readonly PathSegment[]): string; /** Serialise segments as an instance path, rendering selectors in brackets. */ export declare function formatInstancePath(segments: readonly PathSegment[]): string; /** * Drop the item selectors from a path, leaving the declaration it addresses. * * This is the projection several call sites hand-roll with a regex today. * Doing it over segments rather than raw text is what makes it safe: a field * legitimately named `0` is a `field` segment and survives, where a * string-level `/^\d+$/` filter would silently delete it. */ export declare function toDeclarationSegments(segments: readonly PathSegment[]): readonly PathSegment[];