/// import { Interval } from 'ohm-js/index'; import { MatchResult } from 'ohm-js'; declare const META_PATH = "_meta"; type Attrs = Attr[]; type FieldType = 'scalar' | 'set'; type FieldOptionals = { desc?: string; displayFn?: displayFn; }; type displayFn = (v: V) => string; declare abstract class AbstractField { readonly name: string; readonly path: string; readonly desc?: string; readonly displayFn?: displayFn; abstract readonly type: FieldType; constructor(name: string, path: string, optionals?: FieldOptionals); value(value: V, desc?: string): ValueDef; is(other: AbstractField): boolean; find(attrs: Attr[]): Attr | undefined; findAll(attrs: Attr[]): Attrs; } declare class Field extends AbstractField { type: FieldType; } declare class SetField extends AbstractField { type: FieldType; } declare class ValueDef { readonly field: Field; readonly value: V; readonly desc?: string; readonly footnotes: string[]; constructor(field: Field, value: V, desc?: string, footnotes?: string[]); notes(...footnotes: string[]): ValueDef; at(...intervals: Interval[]): Attr; atSource(...source: Source[]): Attr; absent(): Attr; matches(o: RailID): boolean; compare(other: ValueDef): boolean; displayValue(): string; } declare class Attr { readonly def: ValueDef; readonly source: Source; readonly footnotes: string[]; constructor(def: ValueDef, source: Source, footnotes: string[]); compare(other: Attr): boolean; } declare const CodeType: Field<"UIC">; type ChecksumStatus = 'Passed' | 'Failed' | 'Absent'; declare const ChecksumStatus: Field; type ParseWarningType = 'unknown-value' | 'unexpected-value' | 'conflict' | 'checksum'; type ParseWarning = { type: ParseWarningType; subType?: string; msg: string; }; declare const ParseWarnings: SetField; interface RailID { [META_PATH]: { type: string; input: { cleanInput: string; rawInput: string; }; fields: FieldMap; warnings: ParseWarning[]; }; } interface FieldMap { [path: string]: FieldMeta; } type FieldMeta = ScalarFieldMeta | SetFieldMeta; interface AbstractFieldMeta { type: FieldType; name: string; desc: string; path: string; } interface ValueMeta { value: V; displayValue: string; desc: string; footnotes: string[]; source: Source; } interface ScalarFieldMeta extends AbstractFieldMeta { type: 'scalar'; valueMeta: ValueMeta; } interface SetFieldMeta extends AbstractFieldMeta { type: 'set'; valueMetas: ValueMeta[]; } type Source = number[]; declare const omitMarkdown: (result: RailID) => void; declare const result: (attrs: Attr[], cleanInput: string, rawInput: string, options?: Options) => RailID; declare class ParseError extends Error { type: string; cleanInput: string; rawInput: string; position: number; expected: string; found: string; incompleteInput: boolean; friendlyMessage: string; constructor(result: MatchResult, cleanInput: string, rawInput: string); } declare const isParseError: (o: any) => boolean; type Country = { code: number; short: string; long: string; }; type KeeperStatus = 'in use' | 'blocked' | 'revoked'; interface KeeperDef { vkm: string; status: KeeperStatus; country: string; company: string; website?: string; otif?: boolean; } type YesNo = 'Yes' | 'No'; type YesNoMaybe = 'Yes' | 'No' | 'Maybe'; type SpeedUnit = 'km/h' | 'm/h'; type SpeedRange = { min: number; max?: number; unit: SpeedUnit; } | { min?: number; max: number; unit: SpeedUnit; }; declare const displaySpeedRange: (s: SpeedRange) => string; type ValueRange = { type: 'exact'; value: number; } | { type: 'min'; max: number; } | { type: 'max'; min: number; } | { type: 'between'; min: number; max: number; }; type AxleCount = ValueRange; declare const displayAxleCount: (ac: AxleCount) => string; type LoadLimitVal = { axles: AxleCount; loadLimit: ValueRange; unit: 'tons'; }; type VehicleLength = { type: 'static'; length: ValueRange; unit: 'meters'; } | { type: 'with-axles'; withAxles: AxleCount; length: ValueRange; unit: 'meters'; }; declare const displayVehicleLength: (l: VehicleLength) => string; type Options = { /** * Whether to include field metadata in the result such as field names, * descriptions, footnotes, sourcemaps, human-friendly display values, * etc. (default: `true`) */ metadata?: boolean; /** * Field/value metadata (descriptions, footnotes, etc) are expressed in * Markdown syntax. Setting this to `false` renders these values as * plain text. (default: `true`) */ markdown?: boolean; /** * Log level (default: `warn`) */ logLevel?: 'debug' | 'warn' | 'error' | 'none'; }; declare const Defaults: Options; declare const _default: (rawInput: string, options?: Options) => RailID; export { AxleCount, ChecksumStatus, CodeType, Country, Defaults, FieldMap, FieldMeta, KeeperDef, LoadLimitVal, META_PATH, Options, ParseError, ParseWarning, ParseWarnings, RailID, ScalarFieldMeta, SetFieldMeta, Source, SpeedRange, SpeedUnit, ValueMeta, ValueRange, VehicleLength, YesNo, YesNoMaybe, _default as default, displayAxleCount, displaySpeedRange, displayVehicleLength, isParseError, omitMarkdown, result };