export type ParseIssue = { field: string; message: string; selector?: string | undefined; value?: unknown; }; export type ParseResult = { ok: true; data: T; } | { ok: false; error: ParseError; }; export declare class ParseError extends Error { readonly entityType: string; readonly issues: ParseIssue[]; constructor(entityType: string, issues: ParseIssue[]); } /** Parses an entity `T` from `E`. */ export declare abstract class PsnpParser { protected abstract readonly expectedEntityType: string; private issues; parse(domTarget: E): T; tryParse(domTarget: E): ParseResult; protected abstract _parse(parseTarget: E): T | null; protected addIssue(issue: ParseIssue): void; protected hasIssues(): boolean; protected missing(field: string, selector?: string): null; protected invalid(field: string, value: unknown, message?: string, selector?: string): null; private createError; /** * Given a PSNP url (href or pathname), returns a tuple of the entity ID and serialized name. * * @returns {[number, string]|undefined} A tuple containing the extracted entity ID and serialized name, or `undefined` if extraction fails. * * @example By default, an `index` of 2 is passed: * _extractIdAndTitleFromPsnpUrl({url: "/series/234-rock-band"}); * // Output: [234, "rock-band"] * @example Passing `index` explicitly: * _extractIdAndTitleFromPsnpUrl({url: "/trophy/3-call-of-duty/1-the-end-of-war", index: 3}); * // Output: [1, "the-end-of-war"] */ protected _extractIdAndTitleFromPsnpUrl({ url, index, }: { /** The PSNP URL (href or pathname) */ url: string | null | undefined; /** Index of the `.split("/")` pathname where the ID and serialized name are expected */ index?: 2 | 3; }): [number, string] | undefined; protected throwError(prop: string): void; }