@iflow-mcp/jakeliume-webpeel 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +313 -0
- package/dist/cache.d.ts +30 -0
- package/dist/cache.js +139 -0
- package/dist/cli/commands/auth.d.ts +5 -0
- package/dist/cli/commands/auth.js +411 -0
- package/dist/cli/commands/doctor.d.ts +37 -0
- package/dist/cli/commands/doctor.js +371 -0
- package/dist/cli/commands/fetch.d.ts +6 -0
- package/dist/cli/commands/fetch.js +1345 -0
- package/dist/cli/commands/guide.d.ts +2 -0
- package/dist/cli/commands/guide.js +183 -0
- package/dist/cli/commands/interact.d.ts +5 -0
- package/dist/cli/commands/interact.js +840 -0
- package/dist/cli/commands/jobs.d.ts +5 -0
- package/dist/cli/commands/jobs.js +997 -0
- package/dist/cli/commands/monitor.d.ts +12 -0
- package/dist/cli/commands/monitor.js +197 -0
- package/dist/cli/commands/observe.d.ts +12 -0
- package/dist/cli/commands/observe.js +158 -0
- package/dist/cli/commands/screenshot.d.ts +5 -0
- package/dist/cli/commands/screenshot.js +282 -0
- package/dist/cli/commands/search.d.ts +5 -0
- package/dist/cli/commands/search.js +1021 -0
- package/dist/cli/commands/setup.d.ts +13 -0
- package/dist/cli/commands/setup.js +244 -0
- package/dist/cli/commands/skill.d.ts +15 -0
- package/dist/cli/commands/skill.js +195 -0
- package/dist/cli/utils.d.ts +84 -0
- package/dist/cli/utils.js +806 -0
- package/dist/cli-auth.d.ts +75 -0
- package/dist/cli-auth.js +369 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +99 -0
- package/dist/core/actions.d.ts +69 -0
- package/dist/core/actions.js +495 -0
- package/dist/core/agent.d.ts +98 -0
- package/dist/core/agent.js +558 -0
- package/dist/core/answer.d.ts +42 -0
- package/dist/core/answer.js +395 -0
- package/dist/core/application-tracker.d.ts +84 -0
- package/dist/core/application-tracker.js +184 -0
- package/dist/core/apply.d.ts +162 -0
- package/dist/core/apply.js +816 -0
- package/dist/core/auth-detection.d.ts +35 -0
- package/dist/core/auth-detection.js +358 -0
- package/dist/core/auto-extract.d.ts +82 -0
- package/dist/core/auto-extract.js +604 -0
- package/dist/core/auto-interact.d.ts +23 -0
- package/dist/core/auto-interact.js +246 -0
- package/dist/core/bm25-filter.d.ts +66 -0
- package/dist/core/bm25-filter.js +288 -0
- package/dist/core/branding.d.ts +54 -0
- package/dist/core/branding.js +234 -0
- package/dist/core/browser-fetch.d.ts +323 -0
- package/dist/core/browser-fetch.js +1600 -0
- package/dist/core/browser-pool.d.ts +91 -0
- package/dist/core/browser-pool.js +550 -0
- package/dist/core/budget.d.ts +42 -0
- package/dist/core/budget.js +324 -0
- package/dist/core/business-intel.d.ts +47 -0
- package/dist/core/business-intel.js +279 -0
- package/dist/core/cache.d.ts +13 -0
- package/dist/core/cache.js +121 -0
- package/dist/core/cf-worker-proxy.d.ts +32 -0
- package/dist/core/cf-worker-proxy.js +87 -0
- package/dist/core/challenge-detection.d.ts +26 -0
- package/dist/core/challenge-detection.js +468 -0
- package/dist/core/change-tracking.d.ts +75 -0
- package/dist/core/change-tracking.js +276 -0
- package/dist/core/chunker.d.ts +46 -0
- package/dist/core/chunker.js +249 -0
- package/dist/core/chunking.d.ts +42 -0
- package/dist/core/chunking.js +181 -0
- package/dist/core/circuit-breaker.d.ts +44 -0
- package/dist/core/circuit-breaker.js +85 -0
- package/dist/core/content-pruner.d.ts +47 -0
- package/dist/core/content-pruner.js +425 -0
- package/dist/core/cookie-cache.d.ts +60 -0
- package/dist/core/cookie-cache.js +163 -0
- package/dist/core/crawl-checkpoint.d.ts +54 -0
- package/dist/core/crawl-checkpoint.js +104 -0
- package/dist/core/crawler.d.ts +84 -0
- package/dist/core/crawler.js +349 -0
- package/dist/core/cross-verify.d.ts +27 -0
- package/dist/core/cross-verify.js +93 -0
- package/dist/core/deep-fetch.d.ts +74 -0
- package/dist/core/deep-fetch.js +405 -0
- package/dist/core/deep-research.d.ts +141 -0
- package/dist/core/deep-research.js +972 -0
- package/dist/core/design-analysis.d.ts +70 -0
- package/dist/core/design-analysis.js +490 -0
- package/dist/core/design-compare.d.ts +38 -0
- package/dist/core/design-compare.js +264 -0
- package/dist/core/diff.d.ts +61 -0
- package/dist/core/diff.js +289 -0
- package/dist/core/dns-cache.d.ts +20 -0
- package/dist/core/dns-cache.js +198 -0
- package/dist/core/documents.d.ts +23 -0
- package/dist/core/documents.js +123 -0
- package/dist/core/domain-memory.d.ts +66 -0
- package/dist/core/domain-memory.js +163 -0
- package/dist/core/domain-verify.d.ts +40 -0
- package/dist/core/domain-verify.js +379 -0
- package/dist/core/engine-ranker.d.ts +112 -0
- package/dist/core/engine-ranker.js +395 -0
- package/dist/core/extract-inline.d.ts +38 -0
- package/dist/core/extract-inline.js +215 -0
- package/dist/core/extract-listings.d.ts +38 -0
- package/dist/core/extract-listings.js +461 -0
- package/dist/core/extract.d.ts +9 -0
- package/dist/core/extract.js +139 -0
- package/dist/core/fetch-cache.d.ts +57 -0
- package/dist/core/fetch-cache.js +95 -0
- package/dist/core/fetcher.d.ts +13 -0
- package/dist/core/fetcher.js +12 -0
- package/dist/core/google-cache.d.ts +29 -0
- package/dist/core/google-cache.js +180 -0
- package/dist/core/google-serp-parser.d.ts +82 -0
- package/dist/core/google-serp-parser.js +287 -0
- package/dist/core/hotel-search.d.ts +122 -0
- package/dist/core/hotel-search.js +382 -0
- package/dist/core/http-fetch.d.ts +72 -0
- package/dist/core/http-fetch.js +820 -0
- package/dist/core/human.d.ts +175 -0
- package/dist/core/human.js +680 -0
- package/dist/core/image-caption.d.ts +44 -0
- package/dist/core/image-caption.js +271 -0
- package/dist/core/jobs.d.ts +75 -0
- package/dist/core/jobs.js +634 -0
- package/dist/core/json-ld.d.ts +15 -0
- package/dist/core/json-ld.js +617 -0
- package/dist/core/language-detect.d.ts +18 -0
- package/dist/core/language-detect.js +135 -0
- package/dist/core/links.d.ts +10 -0
- package/dist/core/links.js +44 -0
- package/dist/core/llm-extract.d.ts +71 -0
- package/dist/core/llm-extract.js +507 -0
- package/dist/core/llm-provider.d.ts +100 -0
- package/dist/core/llm-provider.js +702 -0
- package/dist/core/local-search.d.ts +60 -0
- package/dist/core/local-search.js +308 -0
- package/dist/core/logger.d.ts +28 -0
- package/dist/core/logger.js +104 -0
- package/dist/core/map.d.ts +33 -0
- package/dist/core/map.js +127 -0
- package/dist/core/markdown.d.ts +92 -0
- package/dist/core/markdown.js +809 -0
- package/dist/core/metadata.d.ts +34 -0
- package/dist/core/metadata.js +422 -0
- package/dist/core/observe.d.ts +113 -0
- package/dist/core/observe.js +395 -0
- package/dist/core/ocr.d.ts +12 -0
- package/dist/core/ocr.js +33 -0
- package/dist/core/paginate.d.ts +31 -0
- package/dist/core/paginate.js +106 -0
- package/dist/core/pdf.d.ts +8 -0
- package/dist/core/pdf.js +25 -0
- package/dist/core/peel-tls.d.ts +25 -0
- package/dist/core/peel-tls.js +220 -0
- package/dist/core/pipeline.d.ts +132 -0
- package/dist/core/pipeline.js +1666 -0
- package/dist/core/profiles.d.ts +61 -0
- package/dist/core/profiles.js +350 -0
- package/dist/core/prompt-guard.d.ts +30 -0
- package/dist/core/prompt-guard.js +119 -0
- package/dist/core/proxy-config.d.ts +90 -0
- package/dist/core/proxy-config.js +172 -0
- package/dist/core/quick-answer.d.ts +53 -0
- package/dist/core/quick-answer.js +833 -0
- package/dist/core/rate-governor.d.ts +80 -0
- package/dist/core/rate-governor.js +238 -0
- package/dist/core/readability.d.ts +57 -0
- package/dist/core/readability.js +533 -0
- package/dist/core/research.d.ts +66 -0
- package/dist/core/research.js +270 -0
- package/dist/core/retry.d.ts +60 -0
- package/dist/core/retry.js +119 -0
- package/dist/core/safe-browsing.d.ts +30 -0
- package/dist/core/safe-browsing.js +206 -0
- package/dist/core/schema-extraction.d.ts +66 -0
- package/dist/core/schema-extraction.js +352 -0
- package/dist/core/schema-postprocess.d.ts +32 -0
- package/dist/core/schema-postprocess.js +469 -0
- package/dist/core/schema-templates.d.ts +19 -0
- package/dist/core/schema-templates.js +143 -0
- package/dist/core/screenshot.d.ts +224 -0
- package/dist/core/screenshot.js +207 -0
- package/dist/core/search-engines.d.ts +25 -0
- package/dist/core/search-engines.js +182 -0
- package/dist/core/search-provider.d.ts +243 -0
- package/dist/core/search-provider.js +1629 -0
- package/dist/core/searxng-provider.d.ts +35 -0
- package/dist/core/searxng-provider.js +105 -0
- package/dist/core/selective-evidence.d.ts +151 -0
- package/dist/core/selective-evidence.js +389 -0
- package/dist/core/site-search.d.ts +44 -0
- package/dist/core/site-search.js +252 -0
- package/dist/core/sitemap.d.ts +23 -0
- package/dist/core/sitemap.js +105 -0
- package/dist/core/source-credibility.d.ts +29 -0
- package/dist/core/source-credibility.js +584 -0
- package/dist/core/source-scoring.d.ts +166 -0
- package/dist/core/source-scoring.js +396 -0
- package/dist/core/stemmer.d.ts +38 -0
- package/dist/core/stemmer.js +509 -0
- package/dist/core/strategies.d.ts +104 -0
- package/dist/core/strategies.js +1044 -0
- package/dist/core/strategy-hooks.d.ts +145 -0
- package/dist/core/strategy-hooks.js +74 -0
- package/dist/core/structured-extract.d.ts +43 -0
- package/dist/core/structured-extract.js +550 -0
- package/dist/core/summarize.d.ts +17 -0
- package/dist/core/summarize.js +78 -0
- package/dist/core/synonyms.d.ts +42 -0
- package/dist/core/synonyms.js +184 -0
- package/dist/core/system-monitor.d.ts +61 -0
- package/dist/core/system-monitor.js +133 -0
- package/dist/core/table-format.d.ts +30 -0
- package/dist/core/table-format.js +146 -0
- package/dist/core/threat-feeds.d.ts +23 -0
- package/dist/core/threat-feeds.js +104 -0
- package/dist/core/timing.d.ts +21 -0
- package/dist/core/timing.js +33 -0
- package/dist/core/transcript-export.d.ts +47 -0
- package/dist/core/transcript-export.js +107 -0
- package/dist/core/user-agents.d.ts +82 -0
- package/dist/core/user-agents.js +239 -0
- package/dist/core/vertical-search.d.ts +54 -0
- package/dist/core/vertical-search.js +158 -0
- package/dist/core/watch-manager.d.ts +175 -0
- package/dist/core/watch-manager.js +416 -0
- package/dist/core/watch.d.ts +101 -0
- package/dist/core/watch.js +389 -0
- package/dist/core/youtube.d.ts +130 -0
- package/dist/core/youtube.js +1175 -0
- package/dist/ee/challenge-re-export.d.ts +1 -0
- package/dist/ee/challenge-re-export.js +1 -0
- package/dist/ee/challenge-solver.d.ts +72 -0
- package/dist/ee/challenge-solver.js +720 -0
- package/dist/ee/domain-extractors.d.ts +8 -0
- package/dist/ee/domain-extractors.js +8 -0
- package/dist/ee/domain-intel.d.ts +16 -0
- package/dist/ee/domain-intel.js +133 -0
- package/dist/ee/extractors/allrecipes.d.ts +2 -0
- package/dist/ee/extractors/allrecipes.js +120 -0
- package/dist/ee/extractors/amazon.d.ts +2 -0
- package/dist/ee/extractors/amazon.js +78 -0
- package/dist/ee/extractors/arxiv.d.ts +2 -0
- package/dist/ee/extractors/arxiv.js +137 -0
- package/dist/ee/extractors/bestbuy.d.ts +2 -0
- package/dist/ee/extractors/bestbuy.js +78 -0
- package/dist/ee/extractors/carscom.d.ts +2 -0
- package/dist/ee/extractors/carscom.js +121 -0
- package/dist/ee/extractors/coingecko.d.ts +2 -0
- package/dist/ee/extractors/coingecko.js +134 -0
- package/dist/ee/extractors/craigslist.d.ts +2 -0
- package/dist/ee/extractors/craigslist.js +92 -0
- package/dist/ee/extractors/devto.d.ts +2 -0
- package/dist/ee/extractors/devto.js +135 -0
- package/dist/ee/extractors/ebay.d.ts +2 -0
- package/dist/ee/extractors/ebay.js +90 -0
- package/dist/ee/extractors/espn.d.ts +2 -0
- package/dist/ee/extractors/espn.js +260 -0
- package/dist/ee/extractors/etsy.d.ts +2 -0
- package/dist/ee/extractors/etsy.js +52 -0
- package/dist/ee/extractors/facebook.d.ts +2 -0
- package/dist/ee/extractors/facebook.js +46 -0
- package/dist/ee/extractors/github.d.ts +2 -0
- package/dist/ee/extractors/github.js +196 -0
- package/dist/ee/extractors/google-flights.d.ts +2 -0
- package/dist/ee/extractors/google-flights.js +176 -0
- package/dist/ee/extractors/hackernews.d.ts +2 -0
- package/dist/ee/extractors/hackernews.js +147 -0
- package/dist/ee/extractors/imdb.d.ts +2 -0
- package/dist/ee/extractors/imdb.js +172 -0
- package/dist/ee/extractors/index.d.ts +26 -0
- package/dist/ee/extractors/index.js +247 -0
- package/dist/ee/extractors/instagram.d.ts +2 -0
- package/dist/ee/extractors/instagram.js +102 -0
- package/dist/ee/extractors/kalshi.d.ts +2 -0
- package/dist/ee/extractors/kalshi.js +121 -0
- package/dist/ee/extractors/kayak-cars.d.ts +2 -0
- package/dist/ee/extractors/kayak-cars.js +270 -0
- package/dist/ee/extractors/linkedin.d.ts +2 -0
- package/dist/ee/extractors/linkedin.js +113 -0
- package/dist/ee/extractors/medium.d.ts +2 -0
- package/dist/ee/extractors/medium.js +130 -0
- package/dist/ee/extractors/news.d.ts +4 -0
- package/dist/ee/extractors/news.js +173 -0
- package/dist/ee/extractors/npm.d.ts +2 -0
- package/dist/ee/extractors/npm.js +86 -0
- package/dist/ee/extractors/pdf.d.ts +2 -0
- package/dist/ee/extractors/pdf.js +108 -0
- package/dist/ee/extractors/pinterest.d.ts +2 -0
- package/dist/ee/extractors/pinterest.js +34 -0
- package/dist/ee/extractors/polymarket.d.ts +2 -0
- package/dist/ee/extractors/polymarket.js +358 -0
- package/dist/ee/extractors/producthunt.d.ts +2 -0
- package/dist/ee/extractors/producthunt.js +88 -0
- package/dist/ee/extractors/pubmed.d.ts +2 -0
- package/dist/ee/extractors/pubmed.js +162 -0
- package/dist/ee/extractors/pypi.d.ts +2 -0
- package/dist/ee/extractors/pypi.js +80 -0
- package/dist/ee/extractors/reddit.d.ts +2 -0
- package/dist/ee/extractors/reddit.js +438 -0
- package/dist/ee/extractors/redfin.d.ts +2 -0
- package/dist/ee/extractors/redfin.js +156 -0
- package/dist/ee/extractors/semanticscholar.d.ts +2 -0
- package/dist/ee/extractors/semanticscholar.js +131 -0
- package/dist/ee/extractors/shared.d.ts +12 -0
- package/dist/ee/extractors/shared.js +76 -0
- package/dist/ee/extractors/soundcloud.d.ts +2 -0
- package/dist/ee/extractors/soundcloud.js +34 -0
- package/dist/ee/extractors/sportsbetting.d.ts +2 -0
- package/dist/ee/extractors/sportsbetting.js +37 -0
- package/dist/ee/extractors/spotify.d.ts +2 -0
- package/dist/ee/extractors/spotify.js +34 -0
- package/dist/ee/extractors/stackoverflow.d.ts +2 -0
- package/dist/ee/extractors/stackoverflow.js +61 -0
- package/dist/ee/extractors/substack.d.ts +2 -0
- package/dist/ee/extractors/substack.js +115 -0
- package/dist/ee/extractors/substackroot.d.ts +2 -0
- package/dist/ee/extractors/substackroot.js +46 -0
- package/dist/ee/extractors/tiktok.d.ts +2 -0
- package/dist/ee/extractors/tiktok.js +29 -0
- package/dist/ee/extractors/tradingview.d.ts +2 -0
- package/dist/ee/extractors/tradingview.js +182 -0
- package/dist/ee/extractors/twitch.d.ts +2 -0
- package/dist/ee/extractors/twitch.js +36 -0
- package/dist/ee/extractors/twitter.d.ts +2 -0
- package/dist/ee/extractors/twitter.js +327 -0
- package/dist/ee/extractors/types.d.ts +14 -0
- package/dist/ee/extractors/types.js +1 -0
- package/dist/ee/extractors/walmart.d.ts +2 -0
- package/dist/ee/extractors/walmart.js +50 -0
- package/dist/ee/extractors/weather.d.ts +2 -0
- package/dist/ee/extractors/weather.js +133 -0
- package/dist/ee/extractors/wikipedia.d.ts +4 -0
- package/dist/ee/extractors/wikipedia.js +235 -0
- package/dist/ee/extractors/yelp.d.ts +2 -0
- package/dist/ee/extractors/yelp.js +216 -0
- package/dist/ee/extractors/youtube.d.ts +2 -0
- package/dist/ee/extractors/youtube.js +189 -0
- package/dist/ee/extractors/zillow.d.ts +54 -0
- package/dist/ee/extractors/zillow.js +247 -0
- package/dist/ee/extractors-re-export.d.ts +1 -0
- package/dist/ee/extractors-re-export.js +1 -0
- package/dist/ee/premium-hooks.d.ts +20 -0
- package/dist/ee/premium-hooks.js +50 -0
- package/dist/ee/spa-detection.d.ts +2 -0
- package/dist/ee/spa-detection.js +2 -0
- package/dist/ee/stability.d.ts +4 -0
- package/dist/ee/stability.js +29 -0
- package/dist/ee/swr-cache.d.ts +14 -0
- package/dist/ee/swr-cache.js +34 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +291 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.js +2 -0
- package/dist/integrations/langchain.d.ts +64 -0
- package/dist/integrations/langchain.js +115 -0
- package/dist/integrations/llamaindex.d.ts +50 -0
- package/dist/integrations/llamaindex.js +91 -0
- package/dist/mcp/handlers/act.d.ts +5 -0
- package/dist/mcp/handlers/act.js +34 -0
- package/dist/mcp/handlers/definitions.d.ts +6 -0
- package/dist/mcp/handlers/definitions.js +395 -0
- package/dist/mcp/handlers/extract.d.ts +7 -0
- package/dist/mcp/handlers/extract.js +135 -0
- package/dist/mcp/handlers/fetch.d.ts +6 -0
- package/dist/mcp/handlers/fetch.js +98 -0
- package/dist/mcp/handlers/find.d.ts +5 -0
- package/dist/mcp/handlers/find.js +137 -0
- package/dist/mcp/handlers/index.d.ts +13 -0
- package/dist/mcp/handlers/index.js +63 -0
- package/dist/mcp/handlers/legacy.d.ts +25 -0
- package/dist/mcp/handlers/legacy.js +450 -0
- package/dist/mcp/handlers/meta.d.ts +6 -0
- package/dist/mcp/handlers/meta.js +40 -0
- package/dist/mcp/handlers/monitor.d.ts +5 -0
- package/dist/mcp/handlers/monitor.js +41 -0
- package/dist/mcp/handlers/observe.d.ts +8 -0
- package/dist/mcp/handlers/observe.js +37 -0
- package/dist/mcp/handlers/read.d.ts +6 -0
- package/dist/mcp/handlers/read.js +78 -0
- package/dist/mcp/handlers/see.d.ts +5 -0
- package/dist/mcp/handlers/see.js +75 -0
- package/dist/mcp/handlers/types.d.ts +29 -0
- package/dist/mcp/handlers/types.js +28 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.js +108 -0
- package/dist/mcp/smart-router.d.ts +23 -0
- package/dist/mcp/smart-router.js +178 -0
- package/dist/server/app.d.ts +14 -0
- package/dist/server/app.js +632 -0
- package/dist/server/auth-store.d.ts +28 -0
- package/dist/server/auth-store.js +88 -0
- package/dist/server/bull-queues.d.ts +60 -0
- package/dist/server/bull-queues.js +90 -0
- package/dist/server/email-service.d.ts +55 -0
- package/dist/server/email-service.js +291 -0
- package/dist/server/job-queue.d.ts +100 -0
- package/dist/server/job-queue.js +145 -0
- package/dist/server/logger.d.ts +10 -0
- package/dist/server/logger.js +37 -0
- package/dist/server/middleware/audit-log.d.ts +14 -0
- package/dist/server/middleware/audit-log.js +73 -0
- package/dist/server/middleware/auth.d.ts +35 -0
- package/dist/server/middleware/auth.js +225 -0
- package/dist/server/middleware/rate-limit.d.ts +50 -0
- package/dist/server/middleware/rate-limit.js +270 -0
- package/dist/server/middleware/scope-guard.d.ts +25 -0
- package/dist/server/middleware/scope-guard.js +45 -0
- package/dist/server/middleware/url-validator.d.ts +15 -0
- package/dist/server/middleware/url-validator.js +201 -0
- package/dist/server/openapi.yaml +6418 -0
- package/dist/server/pg-auth-store.d.ts +146 -0
- package/dist/server/pg-auth-store.js +576 -0
- package/dist/server/pg-job-queue.d.ts +59 -0
- package/dist/server/pg-job-queue.js +375 -0
- package/dist/server/routes/activity.d.ts +6 -0
- package/dist/server/routes/activity.js +79 -0
- package/dist/server/routes/admin-active.d.ts +7 -0
- package/dist/server/routes/admin-active.js +120 -0
- package/dist/server/routes/admin-stats.d.ts +7 -0
- package/dist/server/routes/admin-stats.js +176 -0
- package/dist/server/routes/agent.d.ts +24 -0
- package/dist/server/routes/agent.js +480 -0
- package/dist/server/routes/answer.d.ts +5 -0
- package/dist/server/routes/answer.js +125 -0
- package/dist/server/routes/ask.d.ts +28 -0
- package/dist/server/routes/ask.js +295 -0
- package/dist/server/routes/batch.d.ts +6 -0
- package/dist/server/routes/batch.js +493 -0
- package/dist/server/routes/cache-warm.d.ts +25 -0
- package/dist/server/routes/cache-warm.js +212 -0
- package/dist/server/routes/cli-usage.d.ts +6 -0
- package/dist/server/routes/cli-usage.js +127 -0
- package/dist/server/routes/compat.d.ts +23 -0
- package/dist/server/routes/compat.js +652 -0
- package/dist/server/routes/crawl.d.ts +13 -0
- package/dist/server/routes/crawl.js +287 -0
- package/dist/server/routes/deep-fetch.d.ts +8 -0
- package/dist/server/routes/deep-fetch.js +57 -0
- package/dist/server/routes/deep-research.d.ts +11 -0
- package/dist/server/routes/deep-research.js +232 -0
- package/dist/server/routes/demo.d.ts +24 -0
- package/dist/server/routes/demo.js +517 -0
- package/dist/server/routes/do.d.ts +8 -0
- package/dist/server/routes/do.js +72 -0
- package/dist/server/routes/extract.d.ts +14 -0
- package/dist/server/routes/extract.js +325 -0
- package/dist/server/routes/feed.d.ts +15 -0
- package/dist/server/routes/feed.js +311 -0
- package/dist/server/routes/fetch-queue.d.ts +13 -0
- package/dist/server/routes/fetch-queue.js +357 -0
- package/dist/server/routes/fetch.d.ts +7 -0
- package/dist/server/routes/fetch.js +1274 -0
- package/dist/server/routes/go.d.ts +14 -0
- package/dist/server/routes/go.js +81 -0
- package/dist/server/routes/health.d.ts +11 -0
- package/dist/server/routes/health.js +141 -0
- package/dist/server/routes/jobs.d.ts +7 -0
- package/dist/server/routes/jobs.js +574 -0
- package/dist/server/routes/map.d.ts +11 -0
- package/dist/server/routes/map.js +116 -0
- package/dist/server/routes/mcp.d.ts +14 -0
- package/dist/server/routes/mcp.js +197 -0
- package/dist/server/routes/metrics.d.ts +37 -0
- package/dist/server/routes/metrics.js +149 -0
- package/dist/server/routes/oauth.d.ts +9 -0
- package/dist/server/routes/oauth.js +396 -0
- package/dist/server/routes/playground.d.ts +17 -0
- package/dist/server/routes/playground.js +283 -0
- package/dist/server/routes/reader.d.ts +18 -0
- package/dist/server/routes/reader.js +192 -0
- package/dist/server/routes/research.d.ts +14 -0
- package/dist/server/routes/research.js +482 -0
- package/dist/server/routes/screenshot.d.ts +22 -0
- package/dist/server/routes/screenshot.js +820 -0
- package/dist/server/routes/search.d.ts +6 -0
- package/dist/server/routes/search.js +874 -0
- package/dist/server/routes/session.d.ts +17 -0
- package/dist/server/routes/session.js +548 -0
- package/dist/server/routes/share.d.ts +18 -0
- package/dist/server/routes/share.js +462 -0
- package/dist/server/routes/smart-search/handlers/cars.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/cars.js +102 -0
- package/dist/server/routes/smart-search/handlers/flights.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/flights.js +72 -0
- package/dist/server/routes/smart-search/handlers/general.d.ts +13 -0
- package/dist/server/routes/smart-search/handlers/general.js +717 -0
- package/dist/server/routes/smart-search/handlers/hotels.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/hotels.js +88 -0
- package/dist/server/routes/smart-search/handlers/products.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/products.js +1309 -0
- package/dist/server/routes/smart-search/handlers/rental.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/rental.js +154 -0
- package/dist/server/routes/smart-search/handlers/restaurants.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/restaurants.js +225 -0
- package/dist/server/routes/smart-search/handlers/transit-verdict.d.ts +41 -0
- package/dist/server/routes/smart-search/handlers/transit-verdict.js +224 -0
- package/dist/server/routes/smart-search/index.d.ts +19 -0
- package/dist/server/routes/smart-search/index.js +546 -0
- package/dist/server/routes/smart-search/intent.d.ts +3 -0
- package/dist/server/routes/smart-search/intent.js +264 -0
- package/dist/server/routes/smart-search/llm.d.ts +16 -0
- package/dist/server/routes/smart-search/llm.js +70 -0
- package/dist/server/routes/smart-search/sources/reddit.d.ts +18 -0
- package/dist/server/routes/smart-search/sources/reddit.js +34 -0
- package/dist/server/routes/smart-search/sources/yelp.d.ts +25 -0
- package/dist/server/routes/smart-search/sources/yelp.js +171 -0
- package/dist/server/routes/smart-search/sources/youtube.d.ts +8 -0
- package/dist/server/routes/smart-search/sources/youtube.js +9 -0
- package/dist/server/routes/smart-search/types.d.ts +81 -0
- package/dist/server/routes/smart-search/types.js +1 -0
- package/dist/server/routes/smart-search/utils.d.ts +20 -0
- package/dist/server/routes/smart-search/utils.js +146 -0
- package/dist/server/routes/stats.d.ts +6 -0
- package/dist/server/routes/stats.js +71 -0
- package/dist/server/routes/stripe.d.ts +15 -0
- package/dist/server/routes/stripe.js +296 -0
- package/dist/server/routes/transcript-export.d.ts +10 -0
- package/dist/server/routes/transcript-export.js +178 -0
- package/dist/server/routes/usage.d.ts +9 -0
- package/dist/server/routes/usage.js +279 -0
- package/dist/server/routes/users.d.ts +8 -0
- package/dist/server/routes/users.js +1867 -0
- package/dist/server/routes/watch.d.ts +15 -0
- package/dist/server/routes/watch.js +309 -0
- package/dist/server/routes/webhooks.d.ts +26 -0
- package/dist/server/routes/webhooks.js +170 -0
- package/dist/server/routes/youtube.d.ts +6 -0
- package/dist/server/routes/youtube.js +130 -0
- package/dist/server/sentry.d.ts +14 -0
- package/dist/server/sentry.js +104 -0
- package/dist/server/types.d.ts +15 -0
- package/dist/server/types.js +7 -0
- package/dist/server/utils/response.d.ts +44 -0
- package/dist/server/utils/response.js +69 -0
- package/dist/server/utils/sse.d.ts +22 -0
- package/dist/server/utils/sse.js +38 -0
- package/dist/types.d.ts +552 -0
- package/dist/types.js +39 -0
- package/llms.txt +105 -0
- package/package.json +189 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-LD Structured Data Extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts and converts JSON-LD (schema.org) data to clean markdown.
|
|
5
|
+
* Handles Recipe, Product, Article, FAQPage, HowTo, Event, LocalBusiness, Review.
|
|
6
|
+
* This is a FIRST-CLASS content source — tried before HTML DOM parsing.
|
|
7
|
+
*/
|
|
8
|
+
import * as cheerio from 'cheerio';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Helpers
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/** Strip HTML tags from text fields (some sites put HTML in JSON-LD text) */
|
|
13
|
+
function stripHtml(text) {
|
|
14
|
+
if (!text || typeof text !== 'string')
|
|
15
|
+
return '';
|
|
16
|
+
return text.replace(/<[^>]*>/g, '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, ' ').trim();
|
|
17
|
+
}
|
|
18
|
+
/** Extract a string value from an object that may be a string or { name, '@value' } */
|
|
19
|
+
function str(val) {
|
|
20
|
+
if (!val)
|
|
21
|
+
return '';
|
|
22
|
+
if (typeof val === 'string')
|
|
23
|
+
return stripHtml(val);
|
|
24
|
+
if (typeof val === 'object') {
|
|
25
|
+
if (val['@value'])
|
|
26
|
+
return stripHtml(String(val['@value']));
|
|
27
|
+
if (val.name)
|
|
28
|
+
return stripHtml(val.name);
|
|
29
|
+
if (val.text)
|
|
30
|
+
return stripHtml(val.text);
|
|
31
|
+
}
|
|
32
|
+
return stripHtml(String(val));
|
|
33
|
+
}
|
|
34
|
+
/** Extract author name from author field (may be string, object, or array) */
|
|
35
|
+
function authorName(author) {
|
|
36
|
+
if (!author)
|
|
37
|
+
return '';
|
|
38
|
+
if (typeof author === 'string')
|
|
39
|
+
return stripHtml(author);
|
|
40
|
+
if (Array.isArray(author))
|
|
41
|
+
return author.map(a => str(a.name || a)).filter(Boolean).join(', ');
|
|
42
|
+
return str(author.name || author);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse ISO 8601 duration to human-readable string.
|
|
46
|
+
* PT20M → "20 min", PT1H30M → "1 hr 30 min", P2DT3H → "2 days 3 hr"
|
|
47
|
+
*/
|
|
48
|
+
function parseIso8601Duration(duration) {
|
|
49
|
+
if (!duration || typeof duration !== 'string')
|
|
50
|
+
return '';
|
|
51
|
+
// Remove the leading P
|
|
52
|
+
const match = duration.match(/^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);
|
|
53
|
+
if (!match)
|
|
54
|
+
return duration;
|
|
55
|
+
const days = parseInt(match[1] || '0', 10);
|
|
56
|
+
const hours = parseInt(match[2] || '0', 10);
|
|
57
|
+
const minutes = parseInt(match[3] || '0', 10);
|
|
58
|
+
const seconds = parseInt(match[4] || '0', 10);
|
|
59
|
+
const parts = [];
|
|
60
|
+
if (days)
|
|
61
|
+
parts.push(`${days} day${days > 1 ? 's' : ''}`);
|
|
62
|
+
if (hours)
|
|
63
|
+
parts.push(`${hours} hr`);
|
|
64
|
+
if (minutes)
|
|
65
|
+
parts.push(`${minutes} min`);
|
|
66
|
+
if (seconds && !days && !hours && !minutes)
|
|
67
|
+
parts.push(`${seconds} sec`);
|
|
68
|
+
return parts.join(' ') || duration;
|
|
69
|
+
}
|
|
70
|
+
/** Extract availability from schema.org URL like "https://schema.org/InStock" */
|
|
71
|
+
function parseAvailability(availability) {
|
|
72
|
+
if (!availability)
|
|
73
|
+
return '';
|
|
74
|
+
// Extract just the last part after last / or #
|
|
75
|
+
const last = availability.split(/[/#]/).pop() || availability;
|
|
76
|
+
// Convert CamelCase to space-separated: InStock → In Stock
|
|
77
|
+
return last.replace(/([A-Z])/g, ' $1').trim();
|
|
78
|
+
}
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Main extractor
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
export function extractJsonLd(html) {
|
|
83
|
+
const $ = cheerio.load(html);
|
|
84
|
+
const scripts = [];
|
|
85
|
+
$('script[type="application/ld+json"]').each((_, el) => {
|
|
86
|
+
try {
|
|
87
|
+
const raw = $(el).html();
|
|
88
|
+
if (!raw)
|
|
89
|
+
return;
|
|
90
|
+
const parsed = JSON.parse(raw);
|
|
91
|
+
// Handle @graph arrays
|
|
92
|
+
if (parsed['@graph']) {
|
|
93
|
+
scripts.push(...parsed['@graph']);
|
|
94
|
+
}
|
|
95
|
+
else if (Array.isArray(parsed)) {
|
|
96
|
+
scripts.push(...parsed);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
scripts.push(parsed);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch { /* skip malformed JSON-LD */ }
|
|
103
|
+
});
|
|
104
|
+
if (scripts.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
// Try each converter in priority order
|
|
107
|
+
for (const item of scripts) {
|
|
108
|
+
const type = item['@type'];
|
|
109
|
+
if (!type)
|
|
110
|
+
continue;
|
|
111
|
+
const typeStr = Array.isArray(type) ? type[0] : type;
|
|
112
|
+
switch (typeStr) {
|
|
113
|
+
case 'Recipe': {
|
|
114
|
+
const r = convertRecipe(item);
|
|
115
|
+
if (r)
|
|
116
|
+
return r;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'Product': {
|
|
120
|
+
const r = convertProduct(item);
|
|
121
|
+
if (r)
|
|
122
|
+
return r;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case 'Article':
|
|
126
|
+
case 'NewsArticle':
|
|
127
|
+
case 'BlogPosting':
|
|
128
|
+
case 'TechArticle': {
|
|
129
|
+
const r = convertArticle(item);
|
|
130
|
+
if (r)
|
|
131
|
+
return r;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case 'FAQPage': {
|
|
135
|
+
const r = convertFAQ(item);
|
|
136
|
+
if (r)
|
|
137
|
+
return r;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'HowTo': {
|
|
141
|
+
const r = convertHowTo(item);
|
|
142
|
+
if (r)
|
|
143
|
+
return r;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'Event': {
|
|
147
|
+
const r = convertEvent(item);
|
|
148
|
+
if (r)
|
|
149
|
+
return r;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'LocalBusiness':
|
|
153
|
+
case 'Restaurant':
|
|
154
|
+
case 'Store': {
|
|
155
|
+
const r = convertLocalBusiness(item);
|
|
156
|
+
if (r)
|
|
157
|
+
return r;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case 'Review': {
|
|
161
|
+
const r = convertReview(item);
|
|
162
|
+
if (r)
|
|
163
|
+
return r;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
// Converters
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
function convertRecipe(item) {
|
|
174
|
+
const name = str(item.name);
|
|
175
|
+
const ingredients = Array.isArray(item.recipeIngredient)
|
|
176
|
+
? item.recipeIngredient.map((i) => str(i)).filter(Boolean)
|
|
177
|
+
: [];
|
|
178
|
+
// Require at minimum a name and at least one ingredient
|
|
179
|
+
if (!name || ingredients.length === 0)
|
|
180
|
+
return null;
|
|
181
|
+
// Parse instructions — can be string[], HowToStep[], or HowToSection[]
|
|
182
|
+
const rawInstructions = item.recipeInstructions;
|
|
183
|
+
const instructions = [];
|
|
184
|
+
if (rawInstructions) {
|
|
185
|
+
const list = Array.isArray(rawInstructions) ? rawInstructions : [rawInstructions];
|
|
186
|
+
for (const inst of list) {
|
|
187
|
+
if (typeof inst === 'string') {
|
|
188
|
+
const t = stripHtml(inst);
|
|
189
|
+
if (t)
|
|
190
|
+
instructions.push(t);
|
|
191
|
+
}
|
|
192
|
+
else if (inst['@type'] === 'HowToStep') {
|
|
193
|
+
const t = str(inst.text || inst.name);
|
|
194
|
+
if (t)
|
|
195
|
+
instructions.push(t);
|
|
196
|
+
}
|
|
197
|
+
else if (inst['@type'] === 'HowToSection') {
|
|
198
|
+
// Section with nested steps
|
|
199
|
+
const steps = Array.isArray(inst.itemListElement) ? inst.itemListElement : [];
|
|
200
|
+
for (const step of steps) {
|
|
201
|
+
const t = str(step.text || step.name);
|
|
202
|
+
if (t)
|
|
203
|
+
instructions.push(t);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const description = str(item.description);
|
|
209
|
+
const prepTime = item.prepTime ? parseIso8601Duration(item.prepTime) : '';
|
|
210
|
+
const cookTime = item.cookTime ? parseIso8601Duration(item.cookTime) : '';
|
|
211
|
+
const totalTime = item.totalTime ? parseIso8601Duration(item.totalTime) : '';
|
|
212
|
+
const recipeYield = str(item.recipeYield);
|
|
213
|
+
// Nutrition
|
|
214
|
+
const nutrition = item.nutrition || {};
|
|
215
|
+
const calories = str(nutrition.calories);
|
|
216
|
+
const fat = str(nutrition.fatContent);
|
|
217
|
+
const protein = str(nutrition.proteinContent);
|
|
218
|
+
const carbs = str(nutrition.carbohydrateContent);
|
|
219
|
+
// Rating
|
|
220
|
+
const rating = item.aggregateRating;
|
|
221
|
+
const ratingValue = rating ? str(rating.ratingValue) : '';
|
|
222
|
+
const ratingCount = rating ? str(rating.ratingCount || rating.reviewCount) : '';
|
|
223
|
+
// Author
|
|
224
|
+
const author = authorName(item.author);
|
|
225
|
+
const lines = [];
|
|
226
|
+
lines.push(`# ${name}`);
|
|
227
|
+
lines.push('');
|
|
228
|
+
if (description) {
|
|
229
|
+
lines.push(description);
|
|
230
|
+
lines.push('');
|
|
231
|
+
}
|
|
232
|
+
// Times row
|
|
233
|
+
const timeParts = [];
|
|
234
|
+
if (prepTime)
|
|
235
|
+
timeParts.push(`**Prep Time:** ${prepTime}`);
|
|
236
|
+
if (cookTime)
|
|
237
|
+
timeParts.push(`**Cook Time:** ${cookTime}`);
|
|
238
|
+
if (totalTime)
|
|
239
|
+
timeParts.push(`**Total:** ${totalTime}`);
|
|
240
|
+
if (timeParts.length > 0) {
|
|
241
|
+
lines.push(timeParts.join(' | '));
|
|
242
|
+
}
|
|
243
|
+
const yieldParts = [];
|
|
244
|
+
if (recipeYield)
|
|
245
|
+
yieldParts.push(`**Servings:** ${recipeYield}`);
|
|
246
|
+
if (calories)
|
|
247
|
+
yieldParts.push(`**Calories:** ${calories}`);
|
|
248
|
+
if (yieldParts.length > 0) {
|
|
249
|
+
lines.push(yieldParts.join(' | '));
|
|
250
|
+
}
|
|
251
|
+
if (timeParts.length > 0 || yieldParts.length > 0)
|
|
252
|
+
lines.push('');
|
|
253
|
+
// Ingredients
|
|
254
|
+
lines.push('## Ingredients');
|
|
255
|
+
for (const ing of ingredients) {
|
|
256
|
+
lines.push(`- ${ing}`);
|
|
257
|
+
}
|
|
258
|
+
lines.push('');
|
|
259
|
+
// Instructions
|
|
260
|
+
if (instructions.length > 0) {
|
|
261
|
+
lines.push('## Instructions');
|
|
262
|
+
instructions.forEach((inst, i) => {
|
|
263
|
+
lines.push(`${i + 1}. ${inst}`);
|
|
264
|
+
});
|
|
265
|
+
lines.push('');
|
|
266
|
+
}
|
|
267
|
+
// Nutrition section
|
|
268
|
+
const nutritionParts = [];
|
|
269
|
+
if (calories)
|
|
270
|
+
nutritionParts.push(`Calories: ${calories}`);
|
|
271
|
+
if (fat)
|
|
272
|
+
nutritionParts.push(`Fat: ${fat}`);
|
|
273
|
+
if (protein)
|
|
274
|
+
nutritionParts.push(`Protein: ${protein}`);
|
|
275
|
+
if (carbs)
|
|
276
|
+
nutritionParts.push(`Carbs: ${carbs}`);
|
|
277
|
+
if (nutritionParts.length > 0) {
|
|
278
|
+
lines.push('## Nutrition');
|
|
279
|
+
lines.push(nutritionParts.join(' | '));
|
|
280
|
+
lines.push('');
|
|
281
|
+
}
|
|
282
|
+
// Footer
|
|
283
|
+
const footerParts = [];
|
|
284
|
+
if (author)
|
|
285
|
+
footerParts.push(`Source: ${author}`);
|
|
286
|
+
if (ratingValue) {
|
|
287
|
+
const ratingStr = ratingCount ? `Rating: ${ratingValue}/5 (${ratingCount} reviews)` : `Rating: ${ratingValue}/5`;
|
|
288
|
+
footerParts.push(ratingStr);
|
|
289
|
+
}
|
|
290
|
+
if (footerParts.length > 0) {
|
|
291
|
+
lines.push(`*${footerParts.join(' | ')}*`);
|
|
292
|
+
}
|
|
293
|
+
const content = lines.join('\n').trim();
|
|
294
|
+
return {
|
|
295
|
+
found: true,
|
|
296
|
+
type: 'Recipe',
|
|
297
|
+
content,
|
|
298
|
+
title: name,
|
|
299
|
+
data: item,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function convertProduct(item) {
|
|
303
|
+
const name = str(item.name);
|
|
304
|
+
if (!name)
|
|
305
|
+
return null;
|
|
306
|
+
const description = str(item.description);
|
|
307
|
+
const brand = item.brand ? str(item.brand.name || item.brand) : '';
|
|
308
|
+
const sku = str(item.sku || item.mpn);
|
|
309
|
+
// Handle offers as single object or array (take lowest price)
|
|
310
|
+
let price = '';
|
|
311
|
+
let currency = '';
|
|
312
|
+
let availability = '';
|
|
313
|
+
if (item.offers) {
|
|
314
|
+
const offersArr = Array.isArray(item.offers) ? item.offers : [item.offers];
|
|
315
|
+
let lowestPrice = Infinity;
|
|
316
|
+
let lowestOffer = offersArr[0];
|
|
317
|
+
for (const offer of offersArr) {
|
|
318
|
+
const p = parseFloat(str(offer.price));
|
|
319
|
+
if (!isNaN(p) && p < lowestPrice) {
|
|
320
|
+
lowestPrice = p;
|
|
321
|
+
lowestOffer = offer;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
price = str(lowestOffer.price);
|
|
325
|
+
currency = str(lowestOffer.priceCurrency);
|
|
326
|
+
availability = lowestOffer.availability ? parseAvailability(str(lowestOffer.availability)) : '';
|
|
327
|
+
}
|
|
328
|
+
const rating = item.aggregateRating;
|
|
329
|
+
const ratingValue = rating ? str(rating.ratingValue) : '';
|
|
330
|
+
const ratingCount = rating ? str(rating.reviewCount || rating.ratingCount) : '';
|
|
331
|
+
const lines = [];
|
|
332
|
+
lines.push(`# ${name}`);
|
|
333
|
+
lines.push('');
|
|
334
|
+
if (description) {
|
|
335
|
+
lines.push(description);
|
|
336
|
+
lines.push('');
|
|
337
|
+
}
|
|
338
|
+
if (price) {
|
|
339
|
+
lines.push(`**Price:** ${price}${currency ? ' ' + currency : ''}`);
|
|
340
|
+
}
|
|
341
|
+
if (availability) {
|
|
342
|
+
lines.push(`**Availability:** ${availability}`);
|
|
343
|
+
}
|
|
344
|
+
if (brand) {
|
|
345
|
+
lines.push(`**Brand:** ${brand}`);
|
|
346
|
+
}
|
|
347
|
+
if (ratingValue) {
|
|
348
|
+
const ratingStr = ratingCount ? `${ratingValue}/5 (${ratingCount} reviews)` : `${ratingValue}/5`;
|
|
349
|
+
lines.push(`**Rating:** ${ratingStr}`);
|
|
350
|
+
}
|
|
351
|
+
if (sku) {
|
|
352
|
+
lines.push(`**SKU:** ${sku}`);
|
|
353
|
+
}
|
|
354
|
+
const content = lines.join('\n').trim();
|
|
355
|
+
return {
|
|
356
|
+
found: true,
|
|
357
|
+
type: 'Product',
|
|
358
|
+
content,
|
|
359
|
+
title: name,
|
|
360
|
+
data: item,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function convertArticle(item) {
|
|
364
|
+
const headline = str(item.headline || item.name);
|
|
365
|
+
if (!headline)
|
|
366
|
+
return null;
|
|
367
|
+
const articleBody = str(item.articleBody);
|
|
368
|
+
// If articleBody is missing, return null (let HTML pipeline handle it)
|
|
369
|
+
if (!articleBody)
|
|
370
|
+
return null;
|
|
371
|
+
const author = authorName(item.author);
|
|
372
|
+
const datePublished = str(item.datePublished);
|
|
373
|
+
const dateModified = str(item.dateModified);
|
|
374
|
+
const typeStr = Array.isArray(item['@type']) ? item['@type'][0] : (item['@type'] || 'Article');
|
|
375
|
+
const lines = [];
|
|
376
|
+
lines.push(`# ${headline}`);
|
|
377
|
+
lines.push('');
|
|
378
|
+
const metaParts = [];
|
|
379
|
+
if (author)
|
|
380
|
+
metaParts.push(`By ${author}`);
|
|
381
|
+
if (datePublished)
|
|
382
|
+
metaParts.push(`Published: ${datePublished}`);
|
|
383
|
+
if (dateModified)
|
|
384
|
+
metaParts.push(`Modified: ${dateModified}`);
|
|
385
|
+
if (metaParts.length > 0) {
|
|
386
|
+
lines.push(`*${metaParts.join(' | ')}*`);
|
|
387
|
+
lines.push('');
|
|
388
|
+
}
|
|
389
|
+
lines.push(articleBody);
|
|
390
|
+
const content = lines.join('\n').trim();
|
|
391
|
+
return {
|
|
392
|
+
found: true,
|
|
393
|
+
type: typeStr,
|
|
394
|
+
content,
|
|
395
|
+
title: headline,
|
|
396
|
+
data: item,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function convertFAQ(item) {
|
|
400
|
+
const mainEntity = Array.isArray(item.mainEntity) ? item.mainEntity : [];
|
|
401
|
+
if (mainEntity.length === 0)
|
|
402
|
+
return null;
|
|
403
|
+
const lines = [];
|
|
404
|
+
lines.push('# Frequently Asked Questions');
|
|
405
|
+
lines.push('');
|
|
406
|
+
for (const q of mainEntity) {
|
|
407
|
+
const question = str(q.name);
|
|
408
|
+
const answer = q.acceptedAnswer ? str(q.acceptedAnswer.text) : '';
|
|
409
|
+
if (!question)
|
|
410
|
+
continue;
|
|
411
|
+
lines.push(`## ${question}`);
|
|
412
|
+
if (answer) {
|
|
413
|
+
lines.push(answer);
|
|
414
|
+
}
|
|
415
|
+
lines.push('');
|
|
416
|
+
}
|
|
417
|
+
const content = lines.join('\n').trim();
|
|
418
|
+
if (content.length < 50)
|
|
419
|
+
return null;
|
|
420
|
+
return {
|
|
421
|
+
found: true,
|
|
422
|
+
type: 'FAQPage',
|
|
423
|
+
content,
|
|
424
|
+
title: 'Frequently Asked Questions',
|
|
425
|
+
data: item,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function convertHowTo(item) {
|
|
429
|
+
const name = str(item.name);
|
|
430
|
+
if (!name)
|
|
431
|
+
return null;
|
|
432
|
+
const description = str(item.description);
|
|
433
|
+
// Collect steps from step or itemListElement
|
|
434
|
+
const stepsRaw = item.step || item.itemListElement || [];
|
|
435
|
+
const steps = [];
|
|
436
|
+
const stepsList = Array.isArray(stepsRaw) ? stepsRaw : [stepsRaw];
|
|
437
|
+
for (const step of stepsList) {
|
|
438
|
+
if (typeof step === 'string') {
|
|
439
|
+
const t = stripHtml(step);
|
|
440
|
+
if (t)
|
|
441
|
+
steps.push(t);
|
|
442
|
+
}
|
|
443
|
+
else if (step['@type'] === 'HowToStep') {
|
|
444
|
+
const t = str(step.text || step.name);
|
|
445
|
+
if (t)
|
|
446
|
+
steps.push(t);
|
|
447
|
+
}
|
|
448
|
+
else if (step['@type'] === 'HowToSection') {
|
|
449
|
+
const nested = Array.isArray(step.itemListElement) ? step.itemListElement : [];
|
|
450
|
+
for (const s of nested) {
|
|
451
|
+
const t = str(s.text || s.name);
|
|
452
|
+
if (t)
|
|
453
|
+
steps.push(t);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (steps.length === 0)
|
|
458
|
+
return null;
|
|
459
|
+
const totalTime = item.totalTime ? parseIso8601Duration(item.totalTime) : '';
|
|
460
|
+
const estimatedCost = item.estimatedCost ? str(item.estimatedCost.value || item.estimatedCost) : '';
|
|
461
|
+
const lines = [];
|
|
462
|
+
lines.push(`# ${name}`);
|
|
463
|
+
lines.push('');
|
|
464
|
+
if (description) {
|
|
465
|
+
lines.push(description);
|
|
466
|
+
lines.push('');
|
|
467
|
+
}
|
|
468
|
+
if (totalTime)
|
|
469
|
+
lines.push(`**Total Time:** ${totalTime}`);
|
|
470
|
+
if (estimatedCost)
|
|
471
|
+
lines.push(`**Estimated Cost:** ${estimatedCost}`);
|
|
472
|
+
if (totalTime || estimatedCost)
|
|
473
|
+
lines.push('');
|
|
474
|
+
lines.push('## Steps');
|
|
475
|
+
steps.forEach((step, i) => {
|
|
476
|
+
lines.push(`${i + 1}. ${step}`);
|
|
477
|
+
});
|
|
478
|
+
const content = lines.join('\n').trim();
|
|
479
|
+
return {
|
|
480
|
+
found: true,
|
|
481
|
+
type: 'HowTo',
|
|
482
|
+
content,
|
|
483
|
+
title: name,
|
|
484
|
+
data: item,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function convertEvent(item) {
|
|
488
|
+
const name = str(item.name);
|
|
489
|
+
if (!name)
|
|
490
|
+
return null;
|
|
491
|
+
const description = str(item.description);
|
|
492
|
+
const startDate = str(item.startDate);
|
|
493
|
+
const endDate = str(item.endDate);
|
|
494
|
+
const location = item.location ? str(item.location.name || item.location.address || item.location) : '';
|
|
495
|
+
const organizer = item.organizer ? str(item.organizer.name || item.organizer) : '';
|
|
496
|
+
const url = str(item.url);
|
|
497
|
+
const lines = [];
|
|
498
|
+
lines.push(`# ${name}`);
|
|
499
|
+
lines.push('');
|
|
500
|
+
if (description) {
|
|
501
|
+
lines.push(description);
|
|
502
|
+
lines.push('');
|
|
503
|
+
}
|
|
504
|
+
if (startDate)
|
|
505
|
+
lines.push(`**Date:** ${startDate}${endDate ? ' – ' + endDate : ''}`);
|
|
506
|
+
if (location)
|
|
507
|
+
lines.push(`**Location:** ${location}`);
|
|
508
|
+
if (organizer)
|
|
509
|
+
lines.push(`**Organizer:** ${organizer}`);
|
|
510
|
+
if (url)
|
|
511
|
+
lines.push(`**URL:** ${url}`);
|
|
512
|
+
const content = lines.join('\n').trim();
|
|
513
|
+
return {
|
|
514
|
+
found: true,
|
|
515
|
+
type: 'Event',
|
|
516
|
+
content,
|
|
517
|
+
title: name,
|
|
518
|
+
data: item,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function convertLocalBusiness(item) {
|
|
522
|
+
const name = str(item.name);
|
|
523
|
+
if (!name)
|
|
524
|
+
return null;
|
|
525
|
+
const description = str(item.description);
|
|
526
|
+
const typeStr = Array.isArray(item['@type']) ? item['@type'][0] : (item['@type'] || 'LocalBusiness');
|
|
527
|
+
// Address
|
|
528
|
+
const addr = item.address;
|
|
529
|
+
let address = '';
|
|
530
|
+
if (addr) {
|
|
531
|
+
if (typeof addr === 'string') {
|
|
532
|
+
address = addr;
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
const parts = [addr.streetAddress, addr.addressLocality, addr.addressRegion, addr.postalCode, addr.addressCountry].filter(Boolean);
|
|
536
|
+
address = parts.join(', ');
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const phone = str(item.telephone);
|
|
540
|
+
const url = str(item.url);
|
|
541
|
+
const priceRange = str(item.priceRange);
|
|
542
|
+
const servesCuisine = item.servesCuisine ? (Array.isArray(item.servesCuisine) ? item.servesCuisine.join(', ') : str(item.servesCuisine)) : '';
|
|
543
|
+
const rating = item.aggregateRating;
|
|
544
|
+
const ratingValue = rating ? str(rating.ratingValue) : '';
|
|
545
|
+
const ratingCount = rating ? str(rating.reviewCount || rating.ratingCount) : '';
|
|
546
|
+
// Hours
|
|
547
|
+
const hours = item.openingHours;
|
|
548
|
+
let hoursStr = '';
|
|
549
|
+
if (hours) {
|
|
550
|
+
hoursStr = Array.isArray(hours) ? hours.join(', ') : str(hours);
|
|
551
|
+
}
|
|
552
|
+
const lines = [];
|
|
553
|
+
lines.push(`# ${name}`);
|
|
554
|
+
lines.push('');
|
|
555
|
+
if (description) {
|
|
556
|
+
lines.push(description);
|
|
557
|
+
lines.push('');
|
|
558
|
+
}
|
|
559
|
+
if (address)
|
|
560
|
+
lines.push(`**Address:** ${address}`);
|
|
561
|
+
if (phone)
|
|
562
|
+
lines.push(`**Phone:** ${phone}`);
|
|
563
|
+
if (url)
|
|
564
|
+
lines.push(`**Website:** ${url}`);
|
|
565
|
+
if (priceRange)
|
|
566
|
+
lines.push(`**Price Range:** ${priceRange}`);
|
|
567
|
+
if (servesCuisine)
|
|
568
|
+
lines.push(`**Cuisine:** ${servesCuisine}`);
|
|
569
|
+
if (hoursStr)
|
|
570
|
+
lines.push(`**Hours:** ${hoursStr}`);
|
|
571
|
+
if (ratingValue) {
|
|
572
|
+
const ratingStr = ratingCount ? `${ratingValue}/5 (${ratingCount} reviews)` : `${ratingValue}/5`;
|
|
573
|
+
lines.push(`**Rating:** ${ratingStr}`);
|
|
574
|
+
}
|
|
575
|
+
const content = lines.join('\n').trim();
|
|
576
|
+
return {
|
|
577
|
+
found: true,
|
|
578
|
+
type: typeStr,
|
|
579
|
+
content,
|
|
580
|
+
title: name,
|
|
581
|
+
data: item,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function convertReview(item) {
|
|
585
|
+
const itemReviewed = item.itemReviewed ? str(item.itemReviewed.name || item.itemReviewed) : '';
|
|
586
|
+
const author = authorName(item.author);
|
|
587
|
+
const reviewBody = str(item.reviewBody);
|
|
588
|
+
if (!reviewBody)
|
|
589
|
+
return null;
|
|
590
|
+
const ratingValue = item.reviewRating ? str(item.reviewRating.ratingValue) : '';
|
|
591
|
+
const bestRating = item.reviewRating ? str(item.reviewRating.bestRating || '5') : '5';
|
|
592
|
+
const datePublished = str(item.datePublished);
|
|
593
|
+
const title = itemReviewed ? `Review: ${itemReviewed}` : (author ? `Review by ${author}` : 'Review');
|
|
594
|
+
const lines = [];
|
|
595
|
+
lines.push(`# ${title}`);
|
|
596
|
+
lines.push('');
|
|
597
|
+
const metaParts = [];
|
|
598
|
+
if (author)
|
|
599
|
+
metaParts.push(`By ${author}`);
|
|
600
|
+
if (ratingValue)
|
|
601
|
+
metaParts.push(`Rating: ${ratingValue}/${bestRating}`);
|
|
602
|
+
if (datePublished)
|
|
603
|
+
metaParts.push(datePublished);
|
|
604
|
+
if (metaParts.length > 0) {
|
|
605
|
+
lines.push(`*${metaParts.join(' | ')}*`);
|
|
606
|
+
lines.push('');
|
|
607
|
+
}
|
|
608
|
+
lines.push(reviewBody);
|
|
609
|
+
const content = lines.join('\n').trim();
|
|
610
|
+
return {
|
|
611
|
+
found: true,
|
|
612
|
+
type: 'Review',
|
|
613
|
+
content,
|
|
614
|
+
title,
|
|
615
|
+
data: item,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight language detection from URL hostname TLD.
|
|
3
|
+
* No external dependencies — pure TLD → language mapping.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Detect the primary language from a URL based on the hostname TLD.
|
|
7
|
+
* Returns a BCP-47 language tag (e.g. 'ja', 'zh-TW') or null if unknown.
|
|
8
|
+
*
|
|
9
|
+
* Handles:
|
|
10
|
+
* - Simple ccTLDs: example.jp → 'ja'
|
|
11
|
+
* - Second-level ccTLDs: example.co.jp → 'ja'
|
|
12
|
+
* - No match for generic TLDs (.com, .org, .net, etc.): returns null
|
|
13
|
+
*
|
|
14
|
+
* @param url - The full URL string
|
|
15
|
+
* @returns BCP-47 language tag or null
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectLanguageFromUrl(url: string): string | null;
|
|
18
|
+
export declare function buildAcceptLanguageHeader(languages: string[]): string;
|