import { HierarchyBuilder } from './hierarchy-builder.js'; import { HierarchyItem } from './hierarchy-item.js'; import { NormalizedUrl, ParsedUrl } from '@autogram/url-tools'; type ObjectWithUrl = Record & { url: string | URL; }; type UrlInput = string | URL; export declare class UrlHierarchyItem extends HierarchyItem { data: ObjectWithUrl; inferred: boolean; adopted: boolean; get name(): string; set name(input: string); constructor(data: ObjectWithUrl); } /** * Behavioral flags for the UrlHierarchyBuilder class */ export interface UrlHierarchyBuilderOptions { /** * Ignore URL search parameters when constructing the hierarchy; multiple * records with the same url will be collapsed into a single Hierarchy Item. * * @defaultValue `false` */ ignoreSearch?: boolean; /** * Ignore URL hashtags/fragments when constructing the hierarchy; multiple * records with the same url will be collapsed into a single Hierarchy Item. * * @defaultValue `false` */ ignoreHash?: boolean; /** * A strategy for resolving gaps in the URL hierarchy. * * If example.com and example.com/assets/image.jpg both exist, but example.com/assets * does not, a gap in the URL hierarchy exists. * * - ignore: Do not attempt to fix the gap; example.com/assets/image.jpg will become an orphan node, or a new root node if it has its own children. * - adopt: Set the child's parent to its closest ancestor, if one can be found. * - bridge: Fill the gap with new HierarchyItem records * * @defaultValue `adopt` */ gaps?: 'ignore' | 'adopt' | 'bridge'; /** * A strategy for dealing with multiple related subdomains in a URL pool * * - ignore: Subdomains are treated as standalone hosts and will form their own root nodes. * - children: Subdomains are treated as children of their TLD, if it exists as a root node. * * @defaultValue `ignore` */ subdomains?: 'ignore' | 'children'; /** * An optional base URL to use with incomplete or relative URLs */ base?: string; /** * An optional normalizer function to clean up incoming URLs; should accept * a {@link ParsedUrl} and return a {@link ParsedUrl} with alterations. */ normalizer?: (url: ParsedUrl) => NormalizedUrl; } /** * Constructs a hierarchy of nodes based on URL path structures. */ export declare class UrlHierarchyBuilder extends HierarchyBuilder { options: UrlHierarchyBuilderOptions; /** * Creates an instance of UrlHierarchyBuilder. */ constructor(customOptions?: UrlHierarchyBuilderOptions); /** * Given a string, a URL, or an object with a 'url' property, construct a new UrlHierarchyItem. */ makeItem(input: UrlInput): UrlHierarchyItem; /** * Iterate through the HierarchyBuilder's pool of items, and build parent/child * relationships between them. * * @returns A copy of the HierarchyBuilder object, appropriate for chaining. */ populateRelationships(): this; /** * Create a new Parent Item, add any number of existing items as its children, * and add it to the Hierarchy pool as a new root item. */ createRoot(rootName: string, children?: UrlHierarchyItem[]): UrlHierarchyItem; protected findAncestor(child: UrlHierarchyItem): UrlHierarchyItem | undefined; protected normalizeUrlData(input: UrlInput | UserData): NormalizedUrl; protected urlToId(url: NormalizedUrl): string; protected getDistance(ancestor: UrlHierarchyItem, descendant: UrlHierarchyItem): number; protected getDirectParent(ancestor: UrlHierarchyItem, descendant: UrlHierarchyItem): UrlHierarchyItem | undefined; } export {}; //# sourceMappingURL=url-hierarchy-builder.d.ts.map