forked from BuilderIO/gpt-crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
57 lines (51 loc) · 1.44 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { z } from 'zod';
import type { Page } from "playwright";
const Page: z.ZodType<Page> = z.any();
export const configSchema = z.object({
/**
* URL to start the crawl
* @example "https://www.builder.io/c/docs/developers"
* @default ""
*/
url: z.string(),
/**
* Pattern to match against for links on a page to subsequently crawl
* @example "https://www.builder.io/c/docs/**"
* @default ""
*/
match: z.string().or(z.array(z.string())),
/**
* Selector to grab the inner text from
* @example ".docs-builder-container"
* @default ""
*/
selector: z.string().optional(),
/**
* Don't crawl more than this many pages
* @default 50
*/
maxPagesToCrawl: z.number().int().positive(),
/**
* File name for the finished data
* @default "output.json"
*/
outputFileName: z.string(),
/** Optional cookie to be set. E.g. for Cookie Consent */
cookie: z.object({
name: z.string(),
value: z.string(),
}).optional(),
/** Optional function to run for each page found */
onVisitPage: z.function()
.args(z.object({
page: Page,
pushData: z.function()
.args(z.any())
.returns(z.promise(z.void()))
}))
.returns(z.promise(z.void()))
.optional(),
/** Optional timeout for waiting for a selector to appear */
waitForSelectorTimeout: z.number().int().nonnegative().optional(),
});
export type Config = z.infer<typeof configSchema>;