import type { AtUriString } from '@atproto/lex-schema'; import type { AssociatedSiteStandardRecord, ExternalRecords, SiteStandardDocument, SiteStandardPublication } from '../../hydration/external.js'; /** * Confirm that the supplied SS records actually back `assumedUrl`. The * record-side URL is built by concatenating the publication URL (or the * loose-doc site) with the document's `path` field, then both sides are * canonicalized for equality: lowercase host, query/fragment dropped, * trailing slash stripped. * * Path concatenation is `base + '/' + path` semantics — a leading `/` on * `path` does NOT swallow the base's pathname (the way * `new URL(path, base)` would). So * `'https://atproto.com/blog' + '/indexing-standard-site'` resolves to * `https://atproto.com/blog/indexing-standard-site` regardless of which * side carries the slash. * * Structural validation of the doc/pub pair (matching `site` ↔ pub URI, * no orphan docs that claim a missing publication) happens upstream: in * `getSiteStandardRecordsFromRefs`'s pinned-root/dependency selection * (`hydration/external.ts`), or by `validateStandardSiteRecordsForUrl` over * `getStandardSiteRecordsForUri`'s selection (which alone leaves an orphan * document selected with an absent publication). By the time this * function runs the pair is already known to be structurally consistent, * so we only check whether the records back the URL. * * For document validation, `SUBPATH_FRIENDLY_DOMAINS` (and their * subdomains) accept an assumed URL whose path extends the canonical * record URL with additional segments — these are platforms where each * record's author owns the full subpath space under their claimed URL. * Publication-only validation always requires exact match: there's no * coherent "subpath" of a publication's home page. * * Cases: * - Document + publication: `publication.url + document.path` must * canonicalize to `assumedUrl` (or be a subpath-friendly prefix of it). * - Loose document (web-URL `site`): `document.site + document.path` * must canonicalize to `assumedUrl` (or be a subpath-friendly prefix). * (Doc with at-uri `site` but no publication can't reach this function * — callers reject it.) * - Publication only: `publication.url` must canonicalize exactly to * `assumedUrl`. * - Neither: vacuously valid; the caller short-circuits before we get * here. */ export declare const validateStandardSiteForUrl: (document: { ref: { uri: string; }; info: { record: { site: string; path?: string; }; }; } | undefined, publication: { ref: { uri: string; }; info: { record: { url: string; }; }; } | undefined, assumedUrl: string) => boolean; export type StandardSiteRecordSelection = { document?: AssociatedSiteStandardRecord; publication?: AssociatedSiteStandardRecord; }; /** * Select the Standard.site records backing `canonicalUri` from in-memory * hydrated `records`: the canonical record itself and, for a document whose * `site` is a publication AT-URI, that publication. Stored bodies are checked * against the Lexicon without parsing or defaulting. Nothing is fetched, and a * missing or invalid referenced publication leaves that slot empty while the * document stays selected. */ export declare const getStandardSiteRecordsForUri: (canonicalUri: AtUriString, records: ExternalRecords | undefined) => StandardSiteRecordSelection; /** * Whether the selected records form a valid association that backs * `assumedUrl`. A document naming a publication AT-URI needs exactly that * publication; a supplied publication must be the one the document names. * Standalone publications and documents with a web-URL `site` are valid on * their own. URL comparison is `validateStandardSiteForUrl`; renderability * (e.g. empty titles) is not considered. */ export declare const validateStandardSiteRecordsForUrl: (document: AssociatedSiteStandardRecord | undefined, publication: AssociatedSiteStandardRecord | undefined, assumedUrl: string) => boolean; /** * Estimate reading time in minutes from a plaintext document body. Returns * `undefined` when the input has no countable words. Uses a coarse * `WORDS_PER_MINUTE` heuristic; swap in a more accurate library here if * needed (e.g. `reading-time`). */ export declare const estimateReadingTimeMinutes: (text: string) => number | undefined; //# sourceMappingURL=standard-site.d.ts.map