1 | import { EventEmitter } from 'node:events';
|
2 | import { type GaxiosResponse } from 'gaxios';
|
3 | import { type CheckOptions } from './options.js';
|
4 | import { Queue } from './queue.js';
|
5 | export { getConfig } from './config.js';
|
6 | export declare enum LinkState {
|
7 | OK = "OK",
|
8 | BROKEN = "BROKEN",
|
9 | SKIPPED = "SKIPPED"
|
10 | }
|
11 | export type RetryInfo = {
|
12 | url: string;
|
13 | secondsUntilRetry: number;
|
14 | status: number;
|
15 | };
|
16 | export type LinkResult = {
|
17 | url: string;
|
18 | status?: number;
|
19 | state: LinkState;
|
20 | parent?: string;
|
21 | failureDetails?: Array<Error | GaxiosResponse>;
|
22 | };
|
23 | export type CrawlResult = {
|
24 | passed: boolean;
|
25 | links: LinkResult[];
|
26 | };
|
27 | type CrawlOptions = {
|
28 | url: URL;
|
29 | parent?: string;
|
30 | crawl: boolean;
|
31 | results: LinkResult[];
|
32 | cache: Set<string>;
|
33 | delayCache: Map<string, number>;
|
34 | retryErrorsCache: Map<string, number>;
|
35 | checkOptions: CheckOptions;
|
36 | queue: Queue;
|
37 | rootPath: string;
|
38 | retry: boolean;
|
39 | retryErrors: boolean;
|
40 | retryErrorsCount: number;
|
41 | retryErrorsJitter: number;
|
42 | };
|
43 |
|
44 |
|
45 |
|
46 | export declare class LinkChecker extends EventEmitter {
|
47 | on(event: 'link', listener: (result: LinkResult) => void): this;
|
48 | on(event: 'pagestart', listener: (link: string) => void): this;
|
49 | on(event: 'retry', listener: (details: RetryInfo) => void): this;
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 | check(options_: CheckOptions): Promise<{
|
56 | links: LinkResult[];
|
57 | passed: boolean;
|
58 | }>;
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | crawl(options: CrawlOptions): Promise<void>;
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | shouldRetryAfter(response: GaxiosResponse, options: CrawlOptions): boolean;
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 | shouldRetryOnError(status: number, options: CrawlOptions): boolean;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | export declare function check(options: CheckOptions): Promise<{
|
87 | links: LinkResult[];
|
88 | passed: boolean;
|
89 | }>;
|
90 | export type { CheckOptions } from './options.js';
|