@crawlbrulee/sdk 1.4.0 → 1.6.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/dist/index.d.cts CHANGED
@@ -72,10 +72,14 @@ declare class HttpClient {
72
72
  /**
73
73
  * Proxy tier used to route the fetch.
74
74
  *
75
- * - `basic` — datacenter proxy, lowest cost.
75
+ * - `basic` — basic proxy, lowest cost.
76
76
  * - `advanced` — enhanced proxy tier with a higher success rate.
77
- * - `auto` — start at the basic tier and escalate to advanced on failure;
78
- * billed at the delivered tier. This is the default when `proxy` is omitted.
77
+ * - `auto` — we start with the lightest way to get the page and step up our
78
+ * effort on our own when a site needs more: a stronger proxy, a real browser,
79
+ * or both (a map steps up the proxy only). Billed at the delivered tier. This
80
+ * is the default when `proxy` is omitted.
81
+ *
82
+ * See https://crawlbrulee.com/docs/proxies#how-auto-works.
79
83
  */
80
84
  type ProxyTier = 'basic' | 'advanced' | 'auto';
81
85
  /**
@@ -157,6 +161,11 @@ interface ResponseMeta {
157
161
  type ScreenshotType = 'viewport' | 'full_page';
158
162
  /** Emulated device class for the viewport (drives default width/height). */
159
163
  type ScreenshotDeviceMode = 'desktop' | 'mobile';
164
+ /**
165
+ * Which theme to ask the site for: `light` (the default) or `dark`. See
166
+ * {@link ScreenshotRequest.color_scheme}.
167
+ */
168
+ type ScreenshotColorScheme = 'light' | 'dark';
160
169
  /** A `wait` action: pause for `ms` milliseconds before the next step. */
161
170
  interface ScreenshotWaitAction {
162
171
  type: 'wait';
@@ -205,6 +214,14 @@ interface ScreenshotRequest {
205
214
  viewport?: ScreenshotViewport;
206
215
  /** Emulate desktop or mobile. Defaults to `desktop`. */
207
216
  device_mode?: ScreenshotDeviceMode;
217
+ /**
218
+ * `light` (the default) or `dark`. `dark` asks the site for its dark theme,
219
+ * if it has one, and the screenshot shows it. A site without a dark theme,
220
+ * or whose dark theme is only a switch on the page, looks the same as with
221
+ * `light`. When the request also asks for `extract.pdf`, the PDF shows the
222
+ * dark theme too. No extra credits.
223
+ */
224
+ color_scheme?: ScreenshotColorScheme;
208
225
  /** Pre-capture actions (waits and scrolls). Maximum 5 entries. */
209
226
  actions_before?: ScreenshotBeforeAction[];
210
227
  /** Post-capture actions (e.g. slice into tiles). Maximum 1 entry. */
@@ -214,7 +231,7 @@ interface ScreenshotRequest {
214
231
  * Machine-readable error names returned by the crawlbrulee API. Stable
215
232
  * identifiers — clients can switch on them.
216
233
  */
217
- type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable' | 'zero_data_retention_not_enabled';
234
+ type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'unsupported_pdf_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable' | 'zero_data_retention_not_enabled';
218
235
  /** Reason a usage allocation was denied (when `error_name = usage_allocation_error`). */
219
236
  type UsageAllocationReason = 'credit_limit' | 'concurrency_limit' | 'duplicate_reservation' | 'internal_error';
220
237
  /** Snapshot of the org's current usage at the moment the error was raised. */
@@ -357,17 +374,20 @@ type ScrapeElementValue = string | ScrapeElementObject | (string | ScrapeElement
357
374
  /**
358
375
  * Which content formats to extract from the scraped page. Every field is
359
376
  * optional; the server defaults are noted on each field. The default request
360
- * extracts `{ metadata: true, cleaned_html: true }`.
377
+ * extracts `{ markdown: true, metadata: true }`. Naming other formats keeps
378
+ * these two on; set `markdown: false` or `metadata: false` to turn one off.
361
379
  *
362
380
  * `extract` only selects what is returned — changing it does not change whether
363
- * an otherwise identical request can be served from cache.
381
+ * an otherwise identical request can be served from cache. The exceptions are
382
+ * `screenshot` and `pdf`: a cached copy answers them only when it has a
383
+ * screenshot or PDF made with the same settings.
364
384
  */
365
385
  interface ScrapeExtract {
366
386
  /** Extract page metadata (title, description, OG/Twitter tags, etc.). Default `true`. */
367
387
  metadata?: boolean;
368
- /** Extract cleaned HTML: the page body with scripts, styles, ads and cookie banners removed. Default `true`. */
388
+ /** Extract cleaned HTML: the page body with scripts, styles, ads and cookie banners removed. Default `false`. */
369
389
  cleaned_html?: boolean;
370
- /** Extract the page as clean Markdown. Default `false`. */
390
+ /** Extract the page as clean Markdown. Default `true`. */
371
391
  markdown?: boolean;
372
392
  /**
373
393
  * Return the raw, unprocessed HTML. Default `false`. Capped at 10 000 000
@@ -399,6 +419,77 @@ interface ScrapeExtract {
399
419
  elements?: ScrapeElements;
400
420
  /** Capture a screenshot. Omit to skip; set to a `ScreenshotRequest` to enable. */
401
421
  screenshot?: ScreenshotRequest;
422
+ /**
423
+ * Save the page as a PDF. Omit to skip; set to a {@link PdfRequest} to
424
+ * enable, where `{}` takes every default. The PDF comes back on the
425
+ * top-level `pdf` field. See {@link PdfRequest}.
426
+ */
427
+ pdf?: PdfRequest;
428
+ }
429
+ /**
430
+ * How a PDF lays out the page:
431
+ *
432
+ * - `pages` (the default): the page on sheets of paper, laid out as in the
433
+ * browser window and shrunk to fit the paper width.
434
+ * - `single_page`: one page as wide as the browser window and as tall as the
435
+ * web page, up to 15 000 px.
436
+ */
437
+ type PdfLayout = 'pages' | 'single_page';
438
+ /** Paper size for a PDF with `layout: 'pages'`. */
439
+ type PdfPaper = 'a4' | 'letter';
440
+ /**
441
+ * Which style of the site a PDF shows: `screen` (the default), the page as it
442
+ * looks on screen, or `print`, the site's own print style.
443
+ */
444
+ type PdfMedia = 'screen' | 'print';
445
+ /**
446
+ * PDF settings. Pass this on `extract.pdf`; `{}` takes every default.
447
+ *
448
+ * The PDF is a real document with selectable text and working links,
449
+ * backgrounds printed, and no header or footer added. The request runs in a
450
+ * browser. It costs what a screenshot costs, and a PDF and a screenshot in one
451
+ * request are billed once. When the PDF can't be made (it would be over 50 MB,
452
+ * it takes too long, or the page could not be loaded), the rest of the scrape
453
+ * still comes back with the `pdf_unavailable` warning, and the request costs
454
+ * what it costs without the PDF.
455
+ *
456
+ * A cached copy of the page answers only when it has a PDF made with the same
457
+ * settings, in the same browser window (the screenshot's `device_mode`,
458
+ * `viewport` and `color_scheme`, when the request also asks for a screenshot).
459
+ * `cache.max_age: 0` always makes a new one.
460
+ *
461
+ * A PDF on its own is made with the light theme: the PDF has no color setting
462
+ * of its own.
463
+ * When the same request also asks for a screenshot with
464
+ * `color_scheme: 'dark'`, the PDF is dark too.
465
+ *
466
+ * ```ts
467
+ * const pdf: PdfRequest = { paper: 'letter', landscape: true }
468
+ * ```
469
+ */
470
+ interface PdfRequest {
471
+ /**
472
+ * `pages` (default): the page on sheets of paper, laid out as in the browser
473
+ * window (the desktop default, or the screenshot's device and viewport when
474
+ * the request also asks for one) and shrunk to fit the paper width.
475
+ * `single_page`: one page as wide as the browser window and as tall as the
476
+ * web page, up to 15 000 px; a taller page goes on over more pages, with the
477
+ * `pdf_single_page_overflow` warning.
478
+ */
479
+ layout?: PdfLayout;
480
+ /** Paper size for `layout: 'pages'`. Defaults to `a4`. Not allowed with `single_page`. */
481
+ paper?: PdfPaper;
482
+ /**
483
+ * Turn the paper sideways, for `layout: 'pages'`. Defaults to `false`. Not
484
+ * allowed with `single_page`.
485
+ */
486
+ landscape?: boolean;
487
+ /**
488
+ * `screen` (default): the page as it looks on screen. `print`: the site's
489
+ * own print style, which on many sites hides menus and images; a site
490
+ * without one looks as on screen.
491
+ */
492
+ media?: PdfMedia;
402
493
  }
403
494
  /**
404
495
  * What is removed from the page before any output is built.
@@ -426,11 +517,11 @@ interface ScrapeCleanup {
426
517
  /**
427
518
  * Cache settings for a scrape request. `max_age` is the only cache control.
428
519
  * A cached result has to match the url, the screenshot setup (type, viewport,
429
- * device mode), `cleanup.ads_and_popups`, `cleanup.exclude_selectors` and
430
- * `location.locale`, and `require_js: true` only matches browser-rendered
431
- * results. A non-zero `actions_before` wait or scroll disables caching for that
432
- * request. A request with `headers` or `cookies` never reads from or writes to
433
- * the cache.
520
+ * device mode, color scheme), the PDF settings, `cleanup.ads_and_popups`,
521
+ * `cleanup.exclude_selectors` and `location.locale`, and `require_js: true`
522
+ * only matches browser-rendered results. A non-zero `actions_before` wait or
523
+ * scroll disables caching for that request. A request with `headers` or
524
+ * `cookies` never reads from or writes to the cache.
434
525
  */
435
526
  interface ScrapeCache {
436
527
  /**
@@ -470,13 +561,15 @@ interface ScrapeRequest {
470
561
  * parameter is kept verbatim.
471
562
  */
472
563
  url: string;
473
- /** Which content formats to extract. Defaults to `metadata + cleaned_html`. */
564
+ /** Which content formats to extract. Defaults to `markdown + metadata`. */
474
565
  extract?: ScrapeExtract;
475
566
  /** Cache settings for this request. */
476
567
  cache?: ScrapeCache;
477
568
  /**
478
- * Use a headless browser to render JavaScript before scraping. Adds latency
479
- * and credits — only enable when the page requires it. Default `false`.
569
+ * Go straight to a headless browser to render JavaScript before scraping.
570
+ * Without it, we still move to a browser on our own when a page needs one;
571
+ * set it when you already know the page needs JavaScript, to save time.
572
+ * Default `false`.
480
573
  */
481
574
  require_js?: boolean;
482
575
  /**
@@ -488,8 +581,10 @@ interface ScrapeRequest {
488
581
  */
489
582
  cleanup?: ScrapeCleanup;
490
583
  /**
491
- * Proxy tier to use for fetching. Defaults to `auto` (tries the basic tier
492
- * first, escalates to advanced on failure; billed at the delivered tier).
584
+ * Proxy tier. Defaults to `auto`: we start with the lightest way to get the
585
+ * page and step up our effort on our own when a site needs more (a stronger
586
+ * proxy, a real browser, or both), billed at the delivered tier. `basic` or
587
+ * `advanced` pins the tier.
493
588
  */
494
589
  proxy?: ProxyTier;
495
590
  /** Optional locale + country emulation. */
@@ -614,6 +709,17 @@ interface ScreenshotResult {
614
709
  /** Tile slices, present only when the `slice` `actions_after` was requested. */
615
710
  slices?: ScreenshotSlice[];
616
711
  }
712
+ /** Result block returned when a PDF was requested and could be made. */
713
+ interface PdfResult {
714
+ /**
715
+ * Signed URL to download the PDF. Expires 24 hours after the scrape (for an
716
+ * async scrape, 24 hours after it was submitted; fetching the result again
717
+ * does not extend it). Download the file; don't keep the link.
718
+ */
719
+ url: string;
720
+ /** Size of the PDF file in bytes. */
721
+ bytes: number;
722
+ }
617
723
  /** A single inline image discovered on the page. */
618
724
  interface PageInlineImage {
619
725
  /**
@@ -679,6 +785,8 @@ interface ScrapeMetadata {
679
785
  * - `elements_truncated` — at least one `elements` value hit a limit: a list
680
786
  * was cut, or a value too large to return is `null` (never cut short). See
681
787
  * https://crawlbrulee.com/docs/scrape/targeted-extraction for the limits.
788
+ * - `pdf_single_page_overflow` — a `single_page` PDF was taller than the
789
+ * 15 000 px page limit, so it goes on over more pages.
682
790
  *
683
791
  * Unavailability — that section's extraction failed, so the field is omitted
684
792
  * or empty while the rest of the scrape succeeded. These let you tell "the page
@@ -689,6 +797,10 @@ interface ScrapeMetadata {
689
797
  * - `metadata_unavailable` — metadata extraction failed.
690
798
  * - `screenshot_unavailable` — a screenshot was asked for, but the page came
691
799
  * back without one. The rest of the result is there.
800
+ * - `pdf_unavailable` — a PDF was asked for, but the page came back without
801
+ * one: it would have been over 50 MB, it did not finish in time, or the page
802
+ * could not be loaded in a browser (the site answered an empty error page,
803
+ * for example). The rest of the result is there.
692
804
  *
693
805
  * Request notices:
694
806
  *
@@ -702,7 +814,7 @@ interface ScrapeMetadata {
702
814
  * its own, so new scrapes never send it. It stays in the union because results
703
815
  * stored before that change can still carry it. Don't rely on it in new code.
704
816
  */
705
- type ScrapeWarningCode = 'screenshot_truncated' | 'links_truncated' | 'inline_images_truncated' | 'raw_html_truncated' | 'metadata_truncated' | 'elements_truncated' | 'links_unavailable' | 'inline_images_unavailable' | 'metadata_unavailable' | 'screenshot_unavailable' | 'custom_user_agent';
817
+ type ScrapeWarningCode = 'screenshot_truncated' | 'links_truncated' | 'inline_images_truncated' | 'raw_html_truncated' | 'metadata_truncated' | 'elements_truncated' | 'pdf_single_page_overflow' | 'links_unavailable' | 'inline_images_unavailable' | 'metadata_unavailable' | 'screenshot_unavailable' | 'pdf_unavailable' | 'custom_user_agent';
706
818
  /**
707
819
  * Successful response from `POST /api/scrape` and `GET /api/scrape/result/:jobId`.
708
820
  *
@@ -731,7 +843,7 @@ interface ScrapeResponse {
731
843
  * you, for example `if (page.page_status_code === 404)`.
732
844
  *
733
845
  * Billing follows this status: 2xx and 4xx pages are billed, except 403,
734
- * 407, 408, 429 and 451; 5xx pages are never billed.
846
+ * 407, 408, 429, 444 and 451; 5xx pages are never billed.
735
847
  *
736
848
  * Optional only because older api versions do not send it.
737
849
  */
@@ -743,7 +855,7 @@ interface ScrapeResponse {
743
855
  * content type (e.g. asking for `metadata` or `elements` of a JSON file).
744
856
  */
745
857
  unsupported_fields?: string[];
746
- /** Page content converted to clean Markdown (when `extract.markdown`). */
858
+ /** Page content converted to clean Markdown (when `extract.markdown`, on by default). */
747
859
  markdown?: string;
748
860
  /** Cleaned HTML of the main page content (when `extract.cleaned_html`). */
749
861
  cleaned_html?: string;
@@ -767,17 +879,42 @@ interface ScrapeResponse {
767
879
  * can't be captured; when you also requested other outputs those are still
768
880
  * returned and this field is left out (so it reads back as `undefined`), with
769
881
  * a `screenshot_unavailable` warning on `warnings` to tell this case apart —
770
- * guard with `page.screenshot?.url`. A screenshot-only request
771
- * that can't deliver fails instead of returning an empty response: a `422`
882
+ * guard with `page.screenshot?.url`. A screenshot-only request (every other
883
+ * format off: `markdown: false` and `metadata: false`, and no `cleaned_html`,
884
+ * `raw_html`, `links`, `images` or `elements`) that can't deliver fails
885
+ * instead of returning an empty response: a `422`
772
886
  * with `unsupported_screenshot_output` when the content type can't be
773
887
  * screenshotted, a `500` when the capture itself failed — and isn't billed.
888
+ * A request with only a screenshot and a PDF counts as screenshot-only here.
889
+ *
890
+ * An async job like that ends `failed` and isn't billed either: reading its
891
+ * result throws the same `422` ({@link ValidationError}) when the content
892
+ * type can't be captured, or a `400` `job_failed` when no capture could be
893
+ * made.
774
894
  */
775
895
  screenshot?: ScreenshotResult;
896
+ /**
897
+ * The PDF of the page (when `extract.pdf` and it could be made). When it
898
+ * can't be made, this field is left out and `warnings` carries
899
+ * `pdf_unavailable`, while the rest of the scrape comes back. Guard with
900
+ * `page.pdf?.url`. A PDF-only request (every other format off:
901
+ * `markdown: false` and `metadata: false`, and no `cleaned_html`,
902
+ * `raw_html`, `links`, `images`, `elements` or screenshot) whose content
903
+ * type can't be made into a PDF fails with a `422`
904
+ * `unsupported_pdf_output` ({@link ValidationError}) and isn't billed; when
905
+ * no PDF could be made, it fails with a `500` and isn't billed.
906
+ *
907
+ * An async job like that ends `failed` and isn't billed either: reading its
908
+ * result throws the same `422` when the content type can't be made into a
909
+ * PDF, or a `400` `job_failed` when no PDF could be made.
910
+ */
911
+ pdf?: PdfResult;
776
912
  /** Extracted page metadata (when `extract.metadata`, on by default). */
777
913
  metadata?: ScrapeMetadata;
778
914
  /**
779
- * Non-error notices about the scrape — an output was capped (`*_truncated`)
780
- * or could not be extracted (`*_unavailable`); see {@link ScrapeWarningCode}
915
+ * Non-error notices about the scrape: an output was capped (`*_truncated`,
916
+ * `pdf_single_page_overflow`) or could not be extracted (`*_unavailable`);
917
+ * see {@link ScrapeWarningCode}
781
918
  * for what each one means. The codes are stable and safe to switch on, but
782
919
  * the array stays widened to `string` so a newly introduced code doesn't
783
920
  * break your build.
@@ -826,30 +963,106 @@ interface MapLocation {
826
963
  /** ISO 3166-1 alpha-2 country code (e.g. `US`). Case-insensitive. */
827
964
  country?: string;
828
965
  }
966
+ /**
967
+ * What a map returns, sent as {@link MapRequest.entries}: `pages` (page
968
+ * addresses, the default), `sitemaps` (sitemap files, of type `sitemap` or
969
+ * `sitemap_index`) or `all` (both).
970
+ */
971
+ type MapEntries = 'pages' | 'sitemaps' | 'all';
829
972
  /** Request body for `POST /api/map`. */
830
973
  interface MapRequest {
831
- /** The website URL to map. */
974
+ /**
975
+ * The website URL to map. A map always covers the whole site, so the path,
976
+ * query string and fragment are dropped.
977
+ */
832
978
  url: string;
833
979
  /**
834
- * Proxy tier to use for fetching. Defaults to `auto` (tries the basic tier
835
- * first, escalates to advanced on failure; billed at the delivered tier).
980
+ * Proxy tier. Defaults to `auto`: we start on basic and move to a stronger
981
+ * proxy on our own when a site needs it, billed at the delivered tier.
982
+ * `basic` or `advanced` pins the tier.
836
983
  */
837
984
  proxy?: ProxyTier;
838
- /** Only use sitemap.xml — skip homepage link extraction. Default `false`. */
985
+ /**
986
+ * Use the sitemaps only: leave out the links found on the home page.
987
+ * Default `false`. A map with `modified_since` or `sitemap_url` never adds
988
+ * home page links.
989
+ */
839
990
  sitemap_only?: boolean;
840
991
  /** Filter which link types to include. */
841
992
  types?: MapTypes;
842
- /** Cache settings for this request. */
993
+ /**
994
+ * Cache settings for this request. A request with `modified_since` is always
995
+ * mapped fresh, so `cache.max_age` does nothing there.
996
+ */
843
997
  cache?: MapCache;
844
998
  /**
845
- * Maximum number of URLs to discover and store in the map. Must be in
846
- * `(0, 100 000]`. Defaults to 5 000.
999
+ * Start from this sitemap file, as a full http or https address. It must be
1000
+ * on the same site as `url`, or on a host the site's robots.txt names, such
1001
+ * as a CDN. Left out, the map starts from
1002
+ * the site's own top sitemap files.
1003
+ *
1004
+ * Use it to map a very large site in several calls: list the site's sitemap
1005
+ * files first, then read each one with `sitemap_url`.
1006
+ */
1007
+ sitemap_url?: string;
1008
+ /**
1009
+ * How many levels of nested sitemaps to follow: `0` to `3`, default `3`.
1010
+ * The sdk does not check the range: the api answers a higher value with a
1011
+ * `400`, which raises {@link ValidationError}.
1012
+ *
1013
+ * With `sitemap_url`, level 0 is that file, and it is read. Without it,
1014
+ * level 0 is the list of the site's top sitemap files, which `depth: 0`
1015
+ * returns without reading their entries. A top file found at one of the
1016
+ * usual addresses can still show as `sitemap_index`, because finding it
1017
+ * shows its kind.
1018
+ *
1019
+ * A sitemap index holds only sitemap files, so reading one at a low depth
1020
+ * with `entries: 'pages'` returns no pages. Ask with `entries: 'sitemaps'`
1021
+ * or a higher depth.
1022
+ *
1023
+ * `{ depth: 1, entries: 'sitemaps' }` lists the site's top sitemap files and
1024
+ * every file they list, in one call. A listed file shows as `sitemap` until
1025
+ * a map opens it, even when it is a sitemap index itself. To go deeper, read
1026
+ * a listed file with `sitemap_url`, or ask with a higher depth. A large site
1027
+ * can reach `max_results` or a discovery limit first;
1028
+ * {@link MapTruncation.discovery_cap_reason} then says which.
1029
+ */
1030
+ depth?: number;
1031
+ /**
1032
+ * What to return: `pages` (the default), `sitemaps` or `all`. See
1033
+ * {@link MapEntries}.
1034
+ */
1035
+ entries?: MapEntries;
1036
+ /**
1037
+ * An ISO 8601 date and time with a zone, such as `2026-11-01T00:00:00Z`.
1038
+ * Only entries whose `lastmod` is at or after it come back. An entry with no
1039
+ * `lastmod` is left out, so every entry returned matches; links found on the
1040
+ * home page have no `lastmod`, so none of them is returned.
1041
+ *
1042
+ * Every sitemap file is read whatever its own `lastmod`, and each entry
1043
+ * returned, a page or a sitemap file, is judged by its own `lastmod`. With
1044
+ * `entries: 'sitemaps'`, a sitemap file is returned when its own `lastmod`
1045
+ * matches, not when a page in it does: to find the pages that changed, ask
1046
+ * with `entries: 'pages'`.
1047
+ *
1048
+ * A request with this field is always mapped fresh: it never reads from or
1049
+ * adds to the cache, and each call is priced as a fresh map.
1050
+ */
1051
+ modified_since?: string;
1052
+ /**
1053
+ * The most entries the map finds, counting only the kind asked for in
1054
+ * `entries`. Must be in `(0, 100 000]`. Defaults to 5 000.
847
1055
  *
848
- * Sitemap discovery stops as soon as this many URLs have been found, so a
849
- * smaller value is a cheaper and faster crawl, not just a shorter answer. A
850
- * map that stopped this way comes back with exactly `max_urls` links and
851
- * {@link MapTruncation.discovery_cap_reason} set to `max_urls` — ask again
852
- * with a higher `max_urls` to get more.
1056
+ * Discovery stops as soon as this many have been found, so a smaller value
1057
+ * is a faster and lighter map, not just a shorter answer. A map that stopped
1058
+ * this way has {@link MapTruncation.discovery_cap_reason} set to
1059
+ * `max_results`; ask again with a higher `max_results` to get more.
1060
+ */
1061
+ max_results?: number;
1062
+ /**
1063
+ * @deprecated Use {@link MapRequest.max_results}, which means the same. When
1064
+ * both are sent, only `max_results` is used. The api removes `max_urls` on
1065
+ * 2027-02-01.
853
1066
  */
854
1067
  max_urls?: number;
855
1068
  /** 1-based page number for paginated results. Defaults to 1. */
@@ -868,6 +1081,23 @@ interface MapRequest {
868
1081
  */
869
1082
  zero_data_retention?: boolean;
870
1083
  }
1084
+ /**
1085
+ * What a link in a map result is:
1086
+ *
1087
+ * - `page`: a page address.
1088
+ * - `sitemap_index`: a sitemap file that this map found to be a sitemap index
1089
+ * (a file that lists other sitemap files), whether it read all of the file,
1090
+ * part of it, or only its start. Such a file can also be in
1091
+ * {@link MapTruncation.unread_sitemaps} when this map did not read all of
1092
+ * it.
1093
+ * - `sitemap`: any other sitemap file: one that lists pages, or one whose kind
1094
+ * this map did not learn (past `depth`, or it could not be read).
1095
+ *
1096
+ * Read a `sitemap` or `sitemap_index` file with `sitemap_url` in another call.
1097
+ * A file on another site is read that way only when the site's robots.txt
1098
+ * names its host.
1099
+ */
1100
+ type MapLinkType = 'page' | 'sitemap' | 'sitemap_index';
871
1101
  /** Single discovered URL in a map result. */
872
1102
  interface MapLinkItem {
873
1103
  /**
@@ -875,12 +1105,27 @@ interface MapLinkItem {
875
1105
  * it returns.
876
1106
  */
877
1107
  url: string;
1108
+ /**
1109
+ * `page` for a page address; `sitemap` or `sitemap_index` for a sitemap file
1110
+ * you can read with `sitemap_url` in another call (see {@link MapLinkType}).
1111
+ * A link found on the home page is a `page`.
1112
+ */
1113
+ type: MapLinkType;
1114
+ /**
1115
+ * The entry's `lastmod` from the sitemap, as an ISO 8601 date and time in
1116
+ * UTC, or `null` when the sitemap gives none or it can't be read. Always
1117
+ * `null` for a link found on the home page.
1118
+ */
1119
+ lastmod: string | null;
878
1120
  }
879
1121
  /** Pagination details on a map response. */
880
1122
  interface MapPagination {
881
1123
  page: number;
882
1124
  limit: number;
883
- /** Total number of URLs in the stored map. */
1125
+ /**
1126
+ * How many links this answer holds across all its pages, after `entries`,
1127
+ * `types` and `max_results` are applied.
1128
+ */
884
1129
  total: number;
885
1130
  total_pages: number;
886
1131
  has_more: boolean;
@@ -889,34 +1134,49 @@ interface MapPagination {
889
1134
  * Which limit stopped sitemap discovery first, or `null` when nothing stopped
890
1135
  * it.
891
1136
  *
892
- * - `max_urls` — your own {@link MapRequest.max_urls} was reached. This is the
893
- * only reason you can do something about from the request: ask again with a
894
- * higher one.
895
- * - `time` — discovery ran out of its time budget.
896
- * - `file_budget` — the site has more sitemap files than one request reads.
897
- * - `depth` — the site's sitemap indexes nest too deeply.
898
- * - `file_size` — a sitemap file was too large to read.
899
- * - `unread_files` — a sitemap file the site publishes could not be read at all
900
- * this time: the request for it failed or was rate limited, or the file was
901
- * not a readable sitemap. This one is often temporary, so asking again later
902
- * can return more.
1137
+ * - `max_results`: your own {@link MapRequest.max_results} was reached. Ask
1138
+ * again with a higher one to get more.
1139
+ * - `depth`: there are sitemap files past the `depth` you asked for. That is
1140
+ * the answer to the depth you chose, not a fault: with `depth: 0` it is how
1141
+ * a site's top sitemap files are listed, and with `depth: 1` and
1142
+ * `entries: 'sitemaps'` how the top files and every file they list are
1143
+ * listed. The files past it are in {@link MapTruncation.unread_sitemaps};
1144
+ * read each one with `sitemap_url`, or ask with a higher depth.
1145
+ * - `time`: discovery ran out of its time budget.
1146
+ * - `file_budget`: the site has more sitemap files than one request reads.
1147
+ * - `file_size`: a sitemap file was too large. A file that says up front
1148
+ * that it is over the size limit is not downloaded: nothing comes back from
1149
+ * it, and it is listed in {@link MapTruncation.unread_sitemaps}. A file of
1150
+ * pages that turns out too large while it is read returns the links in its
1151
+ * first part. Any other file that turns out too large, such as a sitemap
1152
+ * index, returns nothing and is listed.
1153
+ * - `unread_files`: a sitemap file the site publishes could not be read whole
1154
+ * this time (the request failed or was rate limited, the download broke off,
1155
+ * or the file was not a readable sitemap). When a download broke off, the
1156
+ * links received before the break are returned, and the file is listed in
1157
+ * `unread_sitemaps`. Asking again later can return more.
903
1158
  */
904
- type MapDiscoveryCapReason = 'max_urls' | 'time' | 'file_budget' | 'depth' | 'file_size' | 'unread_files';
1159
+ type MapDiscoveryCapReason = 'max_results' | 'time' | 'file_budget' | 'depth' | 'file_size' | 'unread_files';
905
1160
  /** Information about whether the stored or returned map was truncated. */
906
1161
  interface MapTruncation {
907
- /** Whether the stored map hit the 100 000-URL storage cap. */
1162
+ /** Whether the map found more than 100 000 URLs, the most one map holds, so some were left out. */
908
1163
  storage_capped: boolean;
909
1164
  /**
910
- * Whether more links were eligible than `max_urls`, so the list was trimmed.
911
- * Discovery itself stops at `max_urls`, so this is normally `true` only when
912
- * home-page links pushed the total past it. A map that ran into the
913
- * `max_urls` limit during discovery reports `response_capped: false` and
914
- * signals the stop through {@link discovery_cap_reason} instead.
1165
+ * Whether more links were eligible than `max_results`, so the list was
1166
+ * trimmed. Discovery itself stops at `max_results`, so this is normally
1167
+ * `true` only when home-page links pushed the total past it. A discovery
1168
+ * stop shows on {@link discovery_cap_reason} instead.
915
1169
  */
916
1170
  response_capped: boolean;
917
- /** Total URLs found before the `max_urls` cap was applied. */
1171
+ /** Total links found before `max_results` was applied. */
1172
+ total_before_max_results: number;
1173
+ /**
1174
+ * @deprecated Use {@link MapTruncation.total_before_max_results}, which
1175
+ * always has the same value. The api removes `total_before_max_urls` on
1176
+ * 2027-02-01.
1177
+ */
918
1178
  total_before_max_urls: number;
919
- /** Total URLs detected during discovery before the storage cap was applied. */
1179
+ /** Total URLs found, before the 100 000-URL limit of one map. */
920
1180
  total_detected_before_storage_cap: number;
921
1181
  /**
922
1182
  * Whether sitemap discovery stopped before it had read every sitemap file it
@@ -924,15 +1184,24 @@ interface MapTruncation {
924
1184
  */
925
1185
  discovery_capped: boolean;
926
1186
  /**
927
- * How many sitemap files were skipped or only partly read during discovery,
928
- * because a file was too large, could not be fetched, or a discovery limit
929
- * was reached. Integer `>= 0`.
1187
+ * How many sitemap files were skipped or only partly read during discovery.
1188
+ * Integer `>= 0`.
930
1189
  */
931
1190
  sitemaps_skipped: number;
1191
+ /**
1192
+ * The sitemap files this call knew about but did not read whole, because a
1193
+ * limit stopped it, the file could not be read, or its download broke off.
1194
+ * Read each one with `sitemap_url` in another call, except a file that says
1195
+ * it is over the size limit: no call reads that one. Up to 1 000 addresses;
1196
+ * empty when every file was read.
1197
+ *
1198
+ * When this list is full, send the same request with `entries: 'sitemaps'`
1199
+ * to get every sitemap file as a link, paged.
1200
+ */
1201
+ unread_sitemaps: string[];
932
1202
  /**
933
1203
  * Which limit stopped sitemap discovery first, or `null` when nothing did.
934
- * Only `max_urls` is something you can change from the request. `unread_files`
935
- * is often temporary, so asking again later can return more.
1204
+ * See {@link MapDiscoveryCapReason}.
936
1205
  */
937
1206
  discovery_cap_reason: MapDiscoveryCapReason | null;
938
1207
  }
@@ -989,9 +1258,10 @@ interface MapResponseMeta {
989
1258
  /** Success response from `POST /api/map`. */
990
1259
  interface MapResponse {
991
1260
  /**
992
- * The current page of discovered URLs.
1261
+ * The current page of discovered URLs, each with its `type` and `lastmod`.
993
1262
  *
994
- * Ordering is stable, with the most useful links first.
1263
+ * Ordering is stable, with the most useful links first. The site root is
1264
+ * listed only when a sitemap lists it.
995
1265
  */
996
1266
  links: MapLinkItem[];
997
1267
  /** Usage, pagination, and truncation metadata for the result set. */
@@ -1269,8 +1539,17 @@ declare class Crawlbrulee {
1269
1539
  */
1270
1540
  waitForScrape(jobId: string, options?: WaitForScrapeOptions): Promise<ScrapeResponse>;
1271
1541
  /**
1272
- * Build (or return a cached) site link-map for a domain. Combines sitemap
1273
- * discovery with the freshest cached homepage scrape when available.
1542
+ * Build (or return a cached) link map of a site from its sitemaps, plus the
1543
+ * links on its home page. Every link is `{ url, type, lastmod }`.
1544
+ *
1545
+ * By default the map reads the site's top sitemap files and two levels of
1546
+ * nested ones, and returns pages. Use `sitemap_url` to read one sitemap file,
1547
+ * so a very large site can be mapped in several calls. When the site answers
1548
+ * `429` for the file in `sitemap_url`, for its robots.txt or for one of its
1549
+ * top sitemap files, the map raises
1550
+ * {@link RateLimitError} and is not billed.
1551
+ *
1552
+ * See https://crawlbrulee.com/docs/map/sitemaps#map-a-very-large-or-deep-site-in-several-calls.
1274
1553
  */
1275
1554
  map(request: MapRequest, options?: RequestOptions): Promise<MapResponse>;
1276
1555
  /**
@@ -1614,5 +1893,5 @@ interface VerifyWebhookSignatureOptions {
1614
1893
  */
1615
1894
  declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<WebhookVerificationResult>;
1616
1895
  //#endregion
1617
- export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapLinkItem, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeCookie, ScrapeElementFieldSpec, ScrapeElementLeafSpec, ScrapeElementNestedFieldSpec, ScrapeElementObject, ScrapeElementOutput, ScrapeElementSpec, ScrapeElementValue, ScrapeElements, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
1896
+ export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapEntries, MapLinkItem, MapLinkType, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, PdfLayout, PdfMedia, PdfPaper, PdfRequest, PdfResult, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeCookie, ScrapeElementFieldSpec, ScrapeElementLeafSpec, ScrapeElementNestedFieldSpec, ScrapeElementObject, ScrapeElementOutput, ScrapeElementSpec, ScrapeElementValue, ScrapeElements, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotColorScheme, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
1618
1897
  //# sourceMappingURL=index.d.cts.map