File tree Expand file tree Collapse file tree 5 files changed +15
-10
lines changed
Expand file tree Collapse file tree 5 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
2+ import type { ApiCrawlOptions } from "scrapegraph-js" ;
23import { createClient } from "../lib/client.js" ;
34import * as log from "../lib/log.js" ;
45
@@ -38,7 +39,7 @@ export default defineCommand({
3839 out . docs ( "https://docs.scrapegraphai.com/api-reference/crawl" ) ;
3940 const sgai = await createClient ( ! ! args . json ) ;
4041
41- const crawlOptions : Record < string , unknown > = { } ;
42+ const crawlOptions : ApiCrawlOptions = { } ;
4243 if ( args [ "max-pages" ] ) crawlOptions . maxPages = Number ( args [ "max-pages" ] ) ;
4344 if ( args [ "max-depth" ] ) crawlOptions . maxDepth = Number ( args [ "max-depth" ] ) ;
4445 if ( args [ "max-links-per-page" ] )
@@ -53,7 +54,7 @@ export default defineCommand({
5354 out . start ( "Crawling" ) ;
5455 const t0 = performance . now ( ) ;
5556 try {
56- const job = await sgai . crawl . start ( args . url , crawlOptions as any ) ;
57+ const job = await sgai . crawl . start ( args . url , crawlOptions ) ;
5758 const jobId = ( job . data as { id : string } ) . id ;
5859
5960 if ( ! jobId ) {
Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
2+ import type { ApiExtractOptions } from "scrapegraph-js" ;
23import { createClient } from "../lib/client.js" ;
34import * as log from "../lib/log.js" ;
45
@@ -41,14 +42,14 @@ export default defineCommand({
4142 if ( args . headers ) fetchConfig . headers = JSON . parse ( args . headers ) ;
4243 if ( args . country ) fetchConfig . country = args . country ;
4344
44- const extractOptions : Record < string , unknown > = { prompt : args . prompt } ;
45+ const extractOptions : ApiExtractOptions = { prompt : args . prompt } ;
4546 if ( args . schema ) extractOptions . schema = JSON . parse ( args . schema ) ;
4647 if ( Object . keys ( fetchConfig ) . length > 0 ) extractOptions . fetchConfig = fetchConfig ;
4748
4849 out . start ( "Extracting" ) ;
4950 const t0 = performance . now ( ) ;
5051 try {
51- const result = await sgai . extract ( args . url , extractOptions as any ) ;
52+ const result = await sgai . extract ( args . url , extractOptions ) ;
5253 out . stop ( Math . round ( performance . now ( ) - t0 ) ) ;
5354 out . result ( result . data ) ;
5455 } catch ( err ) {
Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
2+ import type { ApiScrapeOptions } from "scrapegraph-js" ;
23import { createClient } from "../lib/client.js" ;
34import * as log from "../lib/log.js" ;
45
@@ -28,13 +29,13 @@ export default defineCommand({
2829 if ( args . stealth ) fetchConfig . stealth = true ;
2930 if ( args . headers ) fetchConfig . headers = JSON . parse ( args . headers ) ;
3031
31- const scrapeOptions : Record < string , unknown > = { format : "markdown" } ;
32+ const scrapeOptions : ApiScrapeOptions = { format : "markdown" } ;
3233 if ( Object . keys ( fetchConfig ) . length > 0 ) scrapeOptions . fetchConfig = fetchConfig ;
3334
3435 out . start ( "Converting to markdown" ) ;
3536 const t0 = performance . now ( ) ;
3637 try {
37- const result = await sgai . scrape ( args . url , scrapeOptions as any ) ;
38+ const result = await sgai . scrape ( args . url , scrapeOptions ) ;
3839 out . stop ( Math . round ( performance . now ( ) - t0 ) ) ;
3940 out . result ( result . data ) ;
4041 } catch ( err ) {
Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
2+ import type { ApiScrapeOptions } from "scrapegraph-js" ;
23import { createClient } from "../lib/client.js" ;
34import * as log from "../lib/log.js" ;
45
@@ -105,13 +106,13 @@ export default defineCommand({
105106 }
106107 } ) ;
107108
108- const scrapeOptions : Record < string , unknown > = { formats } ;
109+ const scrapeOptions : ApiScrapeOptions = { formats } ;
109110 if ( Object . keys ( fetchConfig ) . length > 0 ) scrapeOptions . fetchConfig = fetchConfig ;
110111
111112 out . start ( "Scraping" ) ;
112113 const t0 = performance . now ( ) ;
113114 try {
114- const result = await sgai . scrape ( args . url , scrapeOptions as any ) ;
115+ const result = await sgai . scrape ( args . url , scrapeOptions ) ;
115116 out . stop ( Math . round ( performance . now ( ) - t0 ) ) ;
116117 out . result ( result . data ) ;
117118 } catch ( err ) {
Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
2+ import type { ApiSearchOptions } from "scrapegraph-js" ;
23import { createClient } from "../lib/client.js" ;
34import * as log from "../lib/log.js" ;
45
@@ -48,7 +49,7 @@ export default defineCommand({
4849 out . docs ( "https://docs.scrapegraphai.com/api-reference/search" ) ;
4950 const sgai = await createClient ( ! ! args . json ) ;
5051
51- const searchOptions : Record < string , unknown > = { } ;
52+ const searchOptions : ApiSearchOptions = { } ;
5253 if ( args [ "num-results" ] ) searchOptions . numResults = Number ( args [ "num-results" ] ) ;
5354 if ( args . schema ) searchOptions . schema = JSON . parse ( args . schema ) ;
5455 if ( args . prompt ) searchOptions . prompt = args . prompt ;
@@ -61,7 +62,7 @@ export default defineCommand({
6162 out . start ( "Searching" ) ;
6263 const t0 = performance . now ( ) ;
6364 try {
64- const result = await sgai . search ( args . query , searchOptions as any ) ;
65+ const result = await sgai . search ( args . query , searchOptions ) ;
6566 out . stop ( Math . round ( performance . now ( ) - t0 ) ) ;
6667 out . result ( result . data ) ;
6768 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments