@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
65 lines • 2.85 kB
TypeScript
/**
* Whether the text is a plain ASCII integer.
*
* Python's `int()` also accepts unicode digits and TS `parseInt` accepts a
* digit-prefixed tail, so this is the one spelling both languages can agree
* on for numeric path segments.
*/
export declare function asciiDigits(text: string): boolean;
/**
* Whether the text is shaped like a YYYY-MM-DD date.
*
* Shape only, not a calendar check: the dated-message backends mint their
* date directories from real timestamps, so a shaped-but-absent date
* resolves through the listing like any other name. A backend that must
* refuse impossible dates (gcal, whose day dirs exist by construction)
* validates with its own calendar-aware check instead.
*/
export declare function isoDateShaped(text: string): boolean;
/**
* How one dynamic path segment encodes its value.
*
* `suffix` is the extension the segment carries ('.json'); empty for bare
* names. `validate` is an extra shape check on the decoded payload; a
* failing payload means the segment does not match the scope at all.
* `pathSafe` marks a free-form value rendered path-safe and reversibly:
* `/` becomes `∕` (U+2215), a value already holding `∕` or `⁄` (U+2044) has
* that character prefixed with `⁄`, and a blank or dot-led value is prefixed
* with `⁄` as well, so every value has a segment that lists, opens and
* `decode`s back to exactly what `encode` rendered. The group
* levels of the table-shaped backends (qdrant, lancedb) are this shape: a
* segment there becomes an equality filter, so it has to name exactly one
* value.
*/
export declare class Codec {
readonly suffix: string;
readonly validate: ((text: string) => boolean) | null;
readonly pathSafe: boolean;
constructor(init?: {
suffix?: string;
validate?: (text: string) => boolean;
pathSafe?: boolean;
});
/** Decode a path segment, null when it does not fit. */
decode(text: string): string | null;
/** Render a value back into a path segment. */
encode(value: string): string;
/**
* The value prefix a rendered-name prefix stands for.
*
* What a backend pushes into its query when a glob's literal head narrows
* a listing: every value whose rendering starts with `prefix` starts with
* this, so the pushdown loses nothing, and the caller keeps only the
* rendered names that really start with `prefix`. A head cut inside an
* escape pair ends on a lead that could open either escaped character; the
* decode drops it.
*/
prefixValue(prefix: string): string;
}
export declare const RAW: Codec;
export declare const JSON_NAME: Codec;
export declare const JSONL_NAME: Codec;
export declare const INT_JSON: Codec;
export declare const DATE: Codec;
export declare const PATH_SAFE: Codec;
//# sourceMappingURL=codec.d.ts.map