@@ -8,13 +8,15 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
8
8
*
9
9
* @param {string } apiKey - Your ScrapeGraph AI API key
10
10
* @param {string } url - The starting URL for the crawl
11
- * @param {string } prompt - The prompt to guide the crawl and extraction
12
- * @param {Object|ZodType } schema - JSON schema or Zod schema defining the structure of the extracted data
11
+ * @param {string|null } prompt - The prompt to guide the crawl and extraction (null for markdown mode)
12
+ * @param {Object|ZodType|null } schema - JSON schema or Zod schema defining the structure of the extracted data (null for markdown mode)
13
13
* @param {Object } [options] - Optional crawl parameters
14
+ * @param {boolean } [options.extractionMode=true] - true for AI extraction, false for markdown conversion (NO AI/LLM)
14
15
* @param {boolean } [options.cacheWebsite=true] - Whether to cache the website content
15
16
* @param {number } [options.depth=2] - Maximum depth of the crawl (1-10)
16
17
* @param {number } [options.maxPages=2] - Maximum number of pages to crawl (1-100)
17
18
* @param {boolean } [options.sameDomainOnly=true] - Whether to only crawl pages from the same domain
19
+ * @param {boolean } [options.sitemap] - Whether to use sitemap for better page discovery
18
20
* @param {number } [options.batchSize=1] - Batch size for processing pages (1-10)
19
21
* @returns {Promise<Object> } The crawl job response
20
22
* @throws {Error } Throws an error if the HTTP request fails
@@ -33,13 +35,15 @@ export async function crawl(
33
35
'Content-Type' : 'application/json' ,
34
36
} ;
35
37
36
- let schemaPayload ;
37
- if ( schema instanceof ZodType ) {
38
- schemaPayload = zodToJsonSchema ( schema ) ;
39
- } else if ( typeof schema === 'object' && schema !== null ) {
40
- schemaPayload = schema ;
41
- } else {
42
- throw new Error ( 'The schema must be a Zod schema or a plain object' ) ;
38
+ let schemaPayload = null ;
39
+ if ( schema !== null && schema !== undefined ) {
40
+ if ( schema instanceof ZodType ) {
41
+ schemaPayload = zodToJsonSchema ( schema ) ;
42
+ } else if ( typeof schema === 'object' ) {
43
+ schemaPayload = schema ;
44
+ } else {
45
+ throw new Error ( 'The schema must be a Zod schema, a plain object, or null' ) ;
46
+ }
43
47
}
44
48
45
49
const {
0 commit comments