@hunt-labs/bytekit-sdk 0.9.1 → 0.9.3

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/CHANGELOG.md CHANGED
@@ -10,6 +10,49 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.9.3] - 2026-09-04
14
+
15
+ ### Changed
16
+
17
+ - Regenerated `src/generated/api.d.ts` against the corrected queued-scrape `status_url`
18
+ documentation (#3925). `status_url` is a root-relative path, never an absolute URI: join it
19
+ onto the API base URL you called (`https://api.bytekit.com`, no trailing slash) to get the URL
20
+ to poll. The spec had declared it `format: uri` with an absolute example, which no server has
21
+ ever emitted; the emitted value is unchanged, so no client behaviour moves.
22
+ - Regenerated `src/generated/api.d.ts` against the documented proxy-tier response headers
23
+ (#3926). `X-Scrape-Proxy-Tier-Label` now documents that it reports the tier that ACTUALLY
24
+ served a scrape — after any escalation, never the tier first attempted — that it is
25
+ diagnostic only, and that it is omitted on a cache hit, which replayed stored bytes and ran
26
+ no tier. The deprecated numeric `X-Scrape-Proxy-Tier` documents the legacy `1` datacenter /
27
+ `2` residential / `3` mobile vocabulary and its omission for the lean-browser tier. Types are
28
+ unchanged; only the documentation on them moved.
29
+
30
+ ## [0.9.2] - 2026-09-03
31
+
32
+ ### Changed
33
+
34
+ - **Breaking (API):** the scrape `formats` vocabulary is now `raw | markdown | links | images`
35
+ (#3775). The unprocessed-source format is called `raw` — it has returned JSON, XML and plain
36
+ text alongside HTML since #1853, so the old raw-HTML name misdescribed it — and the
37
+ cleaned-article-HTML format is gone. The server accepts no alias for either retired value, so
38
+ a request naming one now comes back `422` with the new set in the message. Update `formats`
39
+ and read the content back from `formats.raw`:
40
+
41
+ ```ts
42
+ const result = await client.scrape.create({ url, formats: ['raw', 'markdown'] });
43
+ console.log(result.formats.raw);
44
+ ```
45
+
46
+ - Regenerated `src/generated/api.d.ts` against the documented `402` contract (#3784). Every
47
+ quota-enforced operation now declares `402` through one shared `PaymentRequired` response, and
48
+ the `X-Quota-*` headers are referenced by the operations that actually emit them. Types only —
49
+ no runtime behavior changed.
50
+
51
+ - The generated `events` field description on the scrape request type now documents the
52
+ widened server default (`queued`, `completed`, `failed`) and that a caller may send an
53
+ explicit subset to receive fewer deliveries (#3777). Types/docs only — this regeneration
54
+ followed a server-side default change; the SDK carried no logic tied to the old default.
55
+
13
56
  ## [0.9.1] - 2026-08-25
14
57
 
15
58
  ### Fixed
package/README.md CHANGED
@@ -56,7 +56,7 @@ const client = new ByteKit({
56
56
  ```ts
57
57
  const result = await client.scrape.create({
58
58
  url: 'https://example.com',
59
- formats: ['markdown', 'html'],
59
+ formats: ['markdown', 'raw'],
60
60
  });
61
61
  ```
62
62
 
@@ -816,11 +816,19 @@ export interface paths {
816
816
  path?: never;
817
817
  cookie?: never;
818
818
  };
819
- get?: never;
819
+ /**
820
+ * Read a scheduled plan change
821
+ * @description The plan change booked for the end of the current period, if any, reconstructed from the Stripe subscription schedule on each call. Both fields are null when nothing is booked, including while the schedule stays attached for one further interval after a change has already landed.
822
+ */
823
+ get: operations["getPlanChange"];
820
824
  put?: never;
821
825
  /** Change subscription plan */
822
826
  post: operations["changePlan"];
823
- delete?: never;
827
+ /**
828
+ * Revoke a scheduled plan change
829
+ * @description Cancels a plan change booked for the end of the current period. The subscription simply renews on the plan it is already on.
830
+ */
831
+ delete: operations["revokePlanChange"];
824
832
  options?: never;
825
833
  head?: never;
826
834
  patch?: never;
@@ -1343,13 +1351,13 @@ export interface components {
1343
1351
  name: string;
1344
1352
  /**
1345
1353
  * @description Monthly subscription price in cents.
1346
- * @example 49900
1354
+ * @example 34900
1347
1355
  */
1348
1356
  price_cents: number;
1349
1357
  /**
1350
1358
  * Format: int64
1351
- * @description Included bandwidth per period, in bytes (binary GiB).
1352
- * @example 100000000000
1359
+ * @description Included bandwidth per period, in bytes (decimal GB = 1,000,000,000 bytes).
1360
+ * @example 125000000000
1353
1361
  */
1354
1362
  included_bytes: number;
1355
1363
  /**
@@ -1359,7 +1367,7 @@ export interface components {
1359
1367
  included_credits: number;
1360
1368
  /**
1361
1369
  * @description Bandwidth top-up price per MB, in cents.
1362
- * @example 0.25
1370
+ * @example 0.2
1363
1371
  */
1364
1372
  topup_price_per_mb_cents: number;
1365
1373
  /**
@@ -1521,10 +1529,10 @@ export interface components {
1521
1529
  url: string;
1522
1530
  /**
1523
1531
  * @default [
1524
- * "raw_html"
1532
+ * "raw"
1525
1533
  * ]
1526
1534
  */
1527
- formats: ("raw_html" | "html" | "markdown" | "links" | "images")[];
1535
+ formats: ("raw" | "markdown" | "links" | "images")[];
1528
1536
  /** @default US */
1529
1537
  country: string;
1530
1538
  /** @default 0 */
@@ -1539,7 +1547,9 @@ export interface components {
1539
1547
  */
1540
1548
  webhook_url?: string;
1541
1549
  /**
1550
+ * @description Webhook event types to deliver when webhook_url is set. Defaults to all three (queued, completed, failed); send an explicit subset to receive fewer.
1542
1551
  * @default [
1552
+ * "queued",
1543
1553
  * "completed",
1544
1554
  * "failed"
1545
1555
  * ]
@@ -1572,7 +1582,7 @@ export interface components {
1572
1582
  markdown_filter_images?: boolean;
1573
1583
  /** @description When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`. */
1574
1584
  markdown_include_media?: boolean;
1575
- /** @description When true, enables markdown-pipeline and tag-filter warnings for affected `html` and `markdown` requests. Artifact availability warnings such as `artifact_unavailable` may appear independently of this flag. */
1585
+ /** @description When true, enables markdown-pipeline and tag-filter warnings for requests that include the `markdown` format. Artifact availability warnings such as `artifact_unavailable` may appear independently of this flag. */
1576
1586
  markdown_include_warnings?: boolean;
1577
1587
  /** @description When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`. */
1578
1588
  markdown_include_stats?: boolean;
@@ -1590,17 +1600,17 @@ export interface components {
1590
1600
  */
1591
1601
  mobile: boolean;
1592
1602
  /**
1593
- * @description When true (default), base64-encoded `data:` image sources are stripped from the HTML before markdown conversion and from the `html` format output. Set to false to preserve base64 images in the pipeline output. Does not affect `raw_html`, which always returns the original HTML unchanged.
1603
+ * @description When true (default), base64-encoded `data:` image sources are stripped from the HTML before markdown conversion. Set to false to preserve base64 images in the pipeline output. Does not affect `raw`, which always returns the original source unchanged.
1594
1604
  * @default true
1595
1605
  */
1596
1606
  remove_base64_images: boolean;
1597
1607
  /**
1598
- * @description HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in the `html` and `markdown` output. Applied before `exclude_tags`. Does not affect `raw_html`, which always returns the full page.
1608
+ * @description HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in the `markdown` output. Applied before `exclude_tags`. Does not affect `raw`, which always returns the full page.
1599
1609
  * @default []
1600
1610
  */
1601
1611
  include_tags: string[];
1602
1612
  /**
1603
- * @description HTML element names (not CSS selectors) to strip from the `html` and `markdown` output. Applied after `include_tags` when both are present. Does not affect `raw_html`, which always returns the full page.
1613
+ * @description HTML element names (not CSS selectors) to strip from the `markdown` output. Applied after `include_tags` when both are present. Does not affect `raw`, which always returns the full page.
1604
1614
  * @default []
1605
1615
  */
1606
1616
  exclude_tags: string[];
@@ -1670,8 +1680,8 @@ export interface components {
1670
1680
  truncated: boolean;
1671
1681
  };
1672
1682
  ScrapeFormats: {
1673
- raw_html?: string;
1674
- html?: string;
1683
+ /** @description The untouched upstream source of whatever the URL served — HTML, JSON, XML or plain text. */
1684
+ raw?: string;
1675
1685
  markdown?: string;
1676
1686
  /** @description Plain URL strings by default. When markdownIncludeMedia=true, an array of ScrapeScoredLink objects. */
1677
1687
  links?: string[] | components["schemas"]["ScrapeScoredLink"][];
@@ -1709,8 +1719,7 @@ export interface components {
1709
1719
  * "status_code": 200,
1710
1720
  * "retrieved_at": "2025-01-15T12:00:00Z",
1711
1721
  * "formats": {
1712
- * "raw_html": "<html><body><h1>Hello World</h1><p>Example page with a <a href=\"/about\">link</a> and an image.</p></body></html>",
1713
- * "html": "<html><body><h1>Hello World</h1><p>Example page with a <a href=\"/about\">link</a> and an image.</p></body></html>",
1722
+ * "raw": "<html><body><h1>Hello World</h1><p>Example page with a <a href=\"/about\">link</a> and an image.</p></body></html>",
1714
1723
  * "markdown": "# Hello World\n\nExample page with a [link](/about) and an image.\n\n![Alt text](https://example.com/photo.png)",
1715
1724
  * "links": [
1716
1725
  * {
@@ -1871,7 +1880,7 @@ export interface components {
1871
1880
  * "status": "queued",
1872
1881
  * "id": "sc_01j9abc123",
1873
1882
  * "url": "https://example.com",
1874
- * "status_url": "https://api.bytekit.com/v1/scrape/sc_01j9abc123",
1883
+ * "status_url": "/v1/scrape/sc_01j9abc123",
1875
1884
  * "queued_at": "2025-01-15T12:00:00Z",
1876
1885
  * "events": []
1877
1886
  * }
@@ -1891,7 +1900,7 @@ export interface components {
1891
1900
  id: string;
1892
1901
  /** Format: uri */
1893
1902
  url: string;
1894
- /** Format: uri */
1903
+ /** @description Root-relative path to poll for this job's terminal envelope — not an absolute URI. Join it onto the base URL of the server you called (see `servers`; they carry no trailing slash) to get the pollable URL, e.g. `https://api.bytekit.com` + `/v1/scrape/sc_01j9abc123`. */
1895
1904
  status_url: string;
1896
1905
  /** Format: date-time */
1897
1906
  queued_at: string;
@@ -2226,7 +2235,7 @@ export interface components {
2226
2235
  consecutive_failures: number;
2227
2236
  /** @description Error code from the most recent failed capture, if any. */
2228
2237
  last_error_code: string | null;
2229
- /** @description Reason the monitor was auto-suspended (e.g. "auto_suspended_consecutive_failures"), if applicable. */
2238
+ /** @description Reason the monitor was auto-suspended, if applicable. `insufficient_balance` means the account ran out of spendable balance; `auto_suspended_consecutive_failures` means the monitor failed too many times in a row. Either way the monitor stops capturing until it is reactivated by sending `status: "active"` to `PATCH /v1/monitors/{id}`. */
2230
2239
  suspension_reason: string | null;
2231
2240
  metadata: Record<string, never> | null;
2232
2241
  /** Format: date-time */
@@ -2615,7 +2624,7 @@ export interface components {
2615
2624
  purchased_topup_bytes: number;
2616
2625
  /** @description Bytes remaining in starter-grant lots, after active refund reservations. Purchased top-up bytes are excluded. */
2617
2626
  granted_topup_bytes: number;
2618
- /** @description Unspent subscription allowance carried over from earlier billing periods: bytes remaining in allowance lots granted before the current period started, after active refund reservations. Carried value is spent before the current period's allowance, so this falls to `0` before `limit_bytes` reaches the current allowance alone. */
2627
+ /** @description Unspent subscription allowance carried over from earlier billing periods: bytes remaining in allowance lots granted before the current period started, after active refund reservations. While your plan tier is unchanged, earlier lots are drawn first, so carried-over allowance is spent before the current period's; after an upgrade, allowance acquired at the higher tier is drawn first. Value is spent in one order: your plan's included allowance, including any rollover from earlier periods, then purchased top-ups, then the one-time starter grant. */
2619
2628
  rollover_bytes: number;
2620
2629
  };
2621
2630
  CreditBalance: {
@@ -2632,7 +2641,48 @@ export interface components {
2632
2641
  rollover_credits: number;
2633
2642
  };
2634
2643
  };
2635
- responses: never;
2644
+ responses: {
2645
+ /**
2646
+ * @description Payment required. The account cannot fund this request, and no work was
2647
+ * performed. The unified `Error` envelope carries one of the billing codes
2648
+ * below in `error.code`; match on the code, never on the prose.
2649
+ *
2650
+ * - `quota_exceeded` — the enforced balance for this request's meter is
2651
+ * exhausted. Capture endpoints (`/v1/scrape`, `/v1/fetch`,
2652
+ * `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter
2653
+ * bandwidth; `/v1/search` meters credits.
2654
+ * - `spending_cap_reached` — the request would push overage spend past the
2655
+ * account's configured cap. Only reachable on a custom overage-enabled
2656
+ * plan; standard plans stop at `quota_exceeded`.
2657
+ * - `billing_entitlement_impaired` — the paid subscription is in a payment
2658
+ * impairment (e.g. `past_due`). `error.message` names the reason.
2659
+ * - `billing_entitlement_expired` — the paid subscription entitlement
2660
+ * period has ended, or its dunning grace period has run out.
2661
+ *
2662
+ * Not retryable as-is: settle the balance, raise the cap, or restore the
2663
+ * subscription first. This response carries no `X-Quota-*` headers — they
2664
+ * travel with the 2xx responses of the operations that emit them.
2665
+ */
2666
+ PaymentRequired: {
2667
+ headers: {
2668
+ [name: string]: unknown;
2669
+ };
2670
+ content: {
2671
+ /**
2672
+ * @example {
2673
+ * "status": "failed",
2674
+ * "error": {
2675
+ * "code": "quota_exceeded",
2676
+ * "message": "Monthly bandwidth quota exhausted.",
2677
+ * "http_status": 402,
2678
+ * "failed_at": "2026-01-15T12:00:00Z"
2679
+ * }
2680
+ * }
2681
+ */
2682
+ "application/json": components["schemas"]["Error"];
2683
+ };
2684
+ };
2685
+ };
2636
2686
  parameters: {
2637
2687
  /**
2638
2688
  * @description Optional. Identifies which published ByteKit client sent the request, as
@@ -2673,8 +2723,8 @@ export interface components {
2673
2723
  XQuotaUsed: number;
2674
2724
  /** @description Remaining quota in the billing period. */
2675
2725
  XQuotaRemaining: number;
2676
- /** @description ISO 8601 timestamp when the billing period ends. */
2677
- XQuotaReset: string;
2726
+ /** @description Unix epoch second at which the current billing period ends — the same unit as `X-RateLimit-Reset`, not an ISO 8601 timestamp (issue #1538). */
2727
+ XQuotaReset: number;
2678
2728
  /** @description Maximum concurrent jobs allowed. */
2679
2729
  XConcurrencyLimit: number;
2680
2730
  /** @description Currently active concurrent jobs. */
@@ -3156,7 +3206,7 @@ export interface operations {
3156
3206
  "X-Screenshot-Status"?: string;
3157
3207
  /** @description The originally requested URL. */
3158
3208
  "X-Screenshot-URL"?: string;
3159
- /** @description Credits charged for this screenshot. */
3209
+ /** @description Legacy credit weight for this capture (1, 2 or 4, doubling for `full_page` and again for retina/mobile). It is recorded for reporting only — screenshots are billed on bandwidth, not credits: the charge is the Phase 1 wire bytes x 1.5, and zero when Phase 1 is skipped or fails. */
3160
3210
  "X-Screenshot-Credits-Charged"?: number;
3161
3211
  /** @description Handler elapsed time in milliseconds. */
3162
3212
  "X-Screenshot-Duration-Ms"?: number;
@@ -3178,6 +3228,10 @@ export interface operations {
3178
3228
  "X-Screenshot-Cache"?: "hit" | "miss" | "bypass";
3179
3229
  /** @description Age of the cached screenshot in seconds. Present only on cache hits. */
3180
3230
  "X-Screenshot-Cache-Age"?: number;
3231
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3232
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3233
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3234
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3181
3235
  [name: string]: unknown;
3182
3236
  };
3183
3237
  content: {
@@ -3193,7 +3247,7 @@ export interface operations {
3193
3247
  "X-Screenshot-Status"?: string;
3194
3248
  /** @description The originally requested URL. */
3195
3249
  "X-Screenshot-URL"?: string;
3196
- /** @description Credits charged for this screenshot. */
3250
+ /** @description Legacy credit weight for this capture (1, 2 or 4, doubling for `full_page` and again for retina/mobile). It is recorded for reporting only — screenshots are billed on bandwidth, not credits: the charge is the Phase 1 wire bytes x 1.5, and zero when Phase 1 is skipped or fails. */
3197
3251
  "X-Screenshot-Credits-Charged"?: number;
3198
3252
  /** @description Handler elapsed time in milliseconds. */
3199
3253
  "X-Screenshot-Duration-Ms"?: number;
@@ -3207,6 +3261,10 @@ export interface operations {
3207
3261
  "X-Billable-Bytes"?: number;
3208
3262
  /** @description Billing multiplier applied to raw bytes to compute billable bytes. A rendering of the response body's `billing` node, which is the authoritative surface: it names each factor that composed this value. Where the two disagree, the node is correct. */
3209
3263
  "X-Billing-Multiplier"?: number;
3264
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3265
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3266
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3267
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3210
3268
  [name: string]: unknown;
3211
3269
  };
3212
3270
  content: {
@@ -3232,15 +3290,7 @@ export interface operations {
3232
3290
  "application/json": components["schemas"]["Error"];
3233
3291
  };
3234
3292
  };
3235
- /** @description Quota exceeded. */
3236
- 402: {
3237
- headers: {
3238
- [name: string]: unknown;
3239
- };
3240
- content: {
3241
- "application/json": components["schemas"]["Error"];
3242
- };
3243
- };
3293
+ 402: components["responses"]["PaymentRequired"];
3244
3294
  /**
3245
3295
  * @description Validation error, or a screenshot that failed inside the sync hold.
3246
3296
  * The two carry DIFFERENT bodies (issue #2679):
@@ -3272,6 +3322,10 @@ export interface operations {
3272
3322
  headers: {
3273
3323
  /** @description Stable screenshot identifier (matches `id` in the resource body). Emitted only on the failed-capture variant; absent on a request-validation failure. */
3274
3324
  "X-Screenshot-ID"?: string;
3325
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3326
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3327
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3328
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3275
3329
  [name: string]: unknown;
3276
3330
  };
3277
3331
  content: {
@@ -3349,7 +3403,7 @@ export interface operations {
3349
3403
  * @example {
3350
3404
  * "url": "https://example.com",
3351
3405
  * "formats": [
3352
- * "raw_html",
3406
+ * "raw",
3353
3407
  * "markdown"
3354
3408
  * ],
3355
3409
  * "markdown_mode": "article",
@@ -3396,7 +3450,7 @@ export interface operations {
3396
3450
  "X-Raw-Bytes"?: number;
3397
3451
  /** @description Chargeable bytes after applying the billing multiplier. Equals round(X-Raw-Bytes × X-Billing-Multiplier). */
3398
3452
  "X-Billable-Bytes"?: number;
3399
- /** @description Bandwidth cost multiplier (e.g. 1.0 for raw_html-only, 1.5 for +markdown/html). Cache hits compose the endpoint format factor: raw 0.5, markdown 0.75. Excludes the `clean_markdown` surcharge: when `clean_markdown: true` and the clean succeeded, the settled usage is 3× this header's value, so this header does not predict the amount you are billed. The response body's `billing` node is the authoritative surface — it DOES carry the `clean_markdown` factor, so its `multiplier` and `billed_bytes` are what you are charged. Where the two disagree, the node is correct. */
3453
+ /** @description Bandwidth cost multiplier (e.g. 1.0 for a `raw`-only scrape, 1.5 when `markdown` is also requested). Cache hits compose the endpoint format factor, which is a separate number from this one: 0.5 for an unprocessed-source scrape, 0.75 with markdown. Excludes the `clean_markdown` surcharge: when `clean_markdown: true` and the clean succeeded, the settled usage is 3× this header's value, so this header does not predict the amount you are billed. The response body's `billing` node is the authoritative surface — it DOES carry the `clean_markdown` factor, so its `multiplier` and `billed_bytes` are what you are charged. Where the two disagree, the node is correct. */
3400
3454
  "X-Billing-Multiplier"?: number;
3401
3455
  /** @description Credits charged for this scrape (multiplier applied to base 1.0 per format). */
3402
3456
  "X-Scrape-Credits-Charged"?: number;
@@ -3420,12 +3474,16 @@ export interface operations {
3420
3474
  "X-Scrape-Markdown-URL"?: string;
3421
3475
  /** @description Byte length of the markdown artifact. Present only on fast-path responses when formats includes markdown. */
3422
3476
  "X-Scrape-Markdown-Length"?: number;
3423
- /** @description Numeric proxy tier used (diagnostic). Deprecated — use X-Scrape-Proxy-Tier-Label. */
3477
+ /** @description Legacy numeric form of the tier that served: 1 datacenter, 2 residential, 3 mobile. Omitted for the lean-browser tier, which has no numeric form. Deprecated — use X-Scrape-Proxy-Tier-Label. */
3424
3478
  "X-Scrape-Proxy-Tier"?: number;
3425
- /** @description Human-readable proxy tier label (e.g. residential, datacenter). Present on fast-path responses. */
3479
+ /** @description The proxy tier that actually served this request's fetch, after any escalation — never the tier first attempted. One of datacenter, residential, mobile, lean. Diagnostic only: it is never an input to routing, billing, caching or escalation. Present on sync fast-path responses. Omitted on a cache hit, which replayed stored bytes and ran no tier, and on responses the fast path did not serve. */
3426
3480
  "X-Scrape-Proxy-Tier-Label"?: string;
3427
3481
  /** @description WAF vendor detected on the target, if any (diagnostic). May be "suspected" when a low-confidence fail-open block marker was served. Omitted when no WAF is detected. */
3428
3482
  "X-Scrape-Waf"?: string;
3483
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3484
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3485
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3486
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3429
3487
  [name: string]: unknown;
3430
3488
  };
3431
3489
  content: {
@@ -3439,6 +3497,10 @@ export interface operations {
3439
3497
  "X-Scrape-ID"?: string;
3440
3498
  /** @description Always `queued` on a 202 response. */
3441
3499
  "X-Scrape-Status"?: "queued";
3500
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3501
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3502
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3503
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3442
3504
  [name: string]: unknown;
3443
3505
  };
3444
3506
  content: {
@@ -3464,6 +3526,7 @@ export interface operations {
3464
3526
  "application/json": components["schemas"]["Error"];
3465
3527
  };
3466
3528
  };
3529
+ 402: components["responses"]["PaymentRequired"];
3467
3530
  /** @description Validation error. */
3468
3531
  422: {
3469
3532
  headers: {
@@ -3539,7 +3602,7 @@ export interface operations {
3539
3602
  * {
3540
3603
  * "url": "https://example.com",
3541
3604
  * "formats": [
3542
- * "raw_html",
3605
+ * "raw",
3543
3606
  * "markdown"
3544
3607
  * ],
3545
3608
  * "custom": {
@@ -3555,7 +3618,7 @@ export interface operations {
3555
3618
  * ],
3556
3619
  * "defaults": {
3557
3620
  * "formats": [
3558
- * "raw_html"
3621
+ * "raw"
3559
3622
  * ],
3560
3623
  * "country": "US"
3561
3624
  * },
@@ -3572,7 +3635,7 @@ export interface operations {
3572
3635
  items?: {
3573
3636
  /** Format: uri */
3574
3637
  url: string;
3575
- formats?: ("raw_html" | "html" | "markdown" | "links" | "images")[];
3638
+ formats?: ("raw" | "markdown" | "links" | "images")[];
3576
3639
  country?: string;
3577
3640
  delay_ms?: number;
3578
3641
  timeout_ms?: number;
@@ -3602,10 +3665,10 @@ export interface operations {
3602
3665
  defaults?: {
3603
3666
  /**
3604
3667
  * @default [
3605
- * "raw_html"
3668
+ * "raw"
3606
3669
  * ]
3607
3670
  */
3608
- formats?: ("raw_html" | "html" | "markdown" | "links" | "images")[];
3671
+ formats?: ("raw" | "markdown" | "links" | "images")[];
3609
3672
  /** @default US */
3610
3673
  country?: string;
3611
3674
  /** @default 0 */
@@ -3651,6 +3714,10 @@ export interface operations {
3651
3714
  /** @description Bulk scrape job accepted. */
3652
3715
  202: {
3653
3716
  headers: {
3717
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3718
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3719
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3720
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3654
3721
  [name: string]: unknown;
3655
3722
  };
3656
3723
  content: {
@@ -3694,6 +3761,7 @@ export interface operations {
3694
3761
  "application/json": components["schemas"]["Error"];
3695
3762
  };
3696
3763
  };
3764
+ 402: components["responses"]["PaymentRequired"];
3697
3765
  /**
3698
3766
  * @description Validation error. `bulk_too_large` is returned when the item count
3699
3767
  * exceeds the account plan's `max_bulk_size` cap (also surfaced as
@@ -3842,6 +3910,10 @@ export interface operations {
3842
3910
  "X-Billing-Multiplier"?: number;
3843
3911
  /** @description Back-compat duplicate of `X-Billing-Multiplier` — identical value on every path. Prefer `X-Billing-Multiplier`; this alias is retained for clients that read the `X-Fetch-*` header family. */
3844
3912
  "X-Fetch-Billing-Multiplier"?: number;
3913
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
3914
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
3915
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
3916
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3845
3917
  [name: string]: unknown;
3846
3918
  };
3847
3919
  content: {
@@ -3857,6 +3929,7 @@ export interface operations {
3857
3929
  "application/json": components["schemas"]["Error"];
3858
3930
  };
3859
3931
  };
3932
+ 402: components["responses"]["PaymentRequired"];
3860
3933
  /** @description Validation error (e.g. slow-path-only field). */
3861
3934
  422: {
3862
3935
  headers: {
@@ -3963,6 +4036,10 @@ export interface operations {
3963
4036
  "X-Billing-Multiplier"?: number;
3964
4037
  /** @description Back-compat duplicate of `X-Billing-Multiplier` — identical value on every path. Prefer `X-Billing-Multiplier`; this alias is retained for clients that read the `X-Fetch-*` header family. */
3965
4038
  "X-Fetch-Billing-Multiplier"?: number;
4039
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
4040
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
4041
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
4042
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
3966
4043
  [name: string]: unknown;
3967
4044
  };
3968
4045
  content: {
@@ -3978,6 +4055,7 @@ export interface operations {
3978
4055
  "application/json": components["schemas"]["Error"];
3979
4056
  };
3980
4057
  };
4058
+ 402: components["responses"]["PaymentRequired"];
3981
4059
  /** @description Validation error (e.g. malformed JSON, unsupported fetch format, or slow-path-only field). */
3982
4060
  422: {
3983
4061
  headers: {
@@ -4077,6 +4155,10 @@ export interface operations {
4077
4155
  /** @description Fetch bulk job accepted. */
4078
4156
  202: {
4079
4157
  headers: {
4158
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
4159
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
4160
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
4161
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
4080
4162
  [name: string]: unknown;
4081
4163
  };
4082
4164
  content: {
@@ -4120,6 +4202,7 @@ export interface operations {
4120
4202
  "application/json": components["schemas"]["Error"];
4121
4203
  };
4122
4204
  };
4205
+ 402: components["responses"]["PaymentRequired"];
4123
4206
  /**
4124
4207
  * @description Validation error. `bulk_too_large` is returned when the item count
4125
4208
  * exceeds the account plan's `max_bulk_size` cap (also surfaced as
@@ -4359,7 +4442,7 @@ export interface operations {
4359
4442
  * "type": "scrape",
4360
4443
  * "formats": [
4361
4444
  * "markdown",
4362
- * "html"
4445
+ * "raw"
4363
4446
  * ],
4364
4447
  * "include_html": true,
4365
4448
  * "wait_until": "networkidle",
@@ -4375,7 +4458,7 @@ export interface operations {
4375
4458
  * "device": "desktop",
4376
4459
  * "country": "US",
4377
4460
  * "formats": [
4378
- * "raw_html"
4461
+ * "raw"
4379
4462
  * ],
4380
4463
  * "device_scale_factor": 2
4381
4464
  * },
@@ -4412,7 +4495,7 @@ export interface operations {
4412
4495
  language?: string | null;
4413
4496
  dark_mode?: boolean;
4414
4497
  /** @description Scrape output formats (scrape entries). */
4415
- formats?: ("raw_html" | "html" | "markdown" | "links" | "images")[];
4498
+ formats?: ("raw" | "markdown" | "links" | "images")[];
4416
4499
  /** @enum {string} */
4417
4500
  wait_until?: "load" | "domcontentloaded" | "networkidle";
4418
4501
  wait_for_selector?: string | null;
@@ -4465,7 +4548,7 @@ export interface operations {
4465
4548
  language?: string | null;
4466
4549
  /** @default false */
4467
4550
  dark_mode?: boolean;
4468
- formats?: ("raw_html" | "html" | "markdown" | "links" | "images")[];
4551
+ formats?: ("raw" | "markdown" | "links" | "images")[];
4469
4552
  /**
4470
4553
  * @default load
4471
4554
  * @enum {string}
@@ -4501,6 +4584,10 @@ export interface operations {
4501
4584
  /** @description Bulk job accepted. */
4502
4585
  202: {
4503
4586
  headers: {
4587
+ "X-Quota-Limit": components["headers"]["XQuotaLimit"];
4588
+ "X-Quota-Used": components["headers"]["XQuotaUsed"];
4589
+ "X-Quota-Remaining": components["headers"]["XQuotaRemaining"];
4590
+ "X-Quota-Reset": components["headers"]["XQuotaReset"];
4504
4591
  [name: string]: unknown;
4505
4592
  };
4506
4593
  content: {
@@ -4544,6 +4631,7 @@ export interface operations {
4544
4631
  "application/json": components["schemas"]["Error"];
4545
4632
  };
4546
4633
  };
4634
+ 402: components["responses"]["PaymentRequired"];
4547
4635
  /**
4548
4636
  * @description Validation error. `bulk_too_large` is returned when the item count
4549
4637
  * exceeds the account plan's `max_bulk_size` cap (also surfaced as
@@ -5063,6 +5151,7 @@ export interface operations {
5063
5151
  "application/json": components["schemas"]["Error"];
5064
5152
  };
5065
5153
  };
5154
+ 402: components["responses"]["PaymentRequired"];
5066
5155
  /** @description Validation error. */
5067
5156
  422: {
5068
5157
  headers: {
@@ -5267,15 +5356,7 @@ export interface operations {
5267
5356
  "application/json": components["schemas"]["Error"];
5268
5357
  };
5269
5358
  };
5270
- /** @description Payment required. Either the account is out of credits (`quota_exceeded`), or a custom overage-enabled plan would cross its configured overage spending cap (`spending_cap_reached`). */
5271
- 402: {
5272
- headers: {
5273
- [name: string]: unknown;
5274
- };
5275
- content: {
5276
- "application/json": components["schemas"]["Error"];
5277
- };
5278
- };
5359
+ 402: components["responses"]["PaymentRequired"];
5279
5360
  /** @description Rate limit exceeded (`rate_limited`). Carries the `X-RateLimit-Limit`/`X-RateLimit-Remaining`/`X-RateLimit-Reset` triplet and a `Retry-After` header. The window is per-second for a bearer API key, or the 60-request/60-second Clerk session window when authenticated via `resolveDualAuth` — `Retry-After` reflects whichever window applies to the request. */
5280
5361
  429: {
5281
5362
  headers: {
@@ -5437,15 +5518,7 @@ export interface operations {
5437
5518
  "application/json": components["schemas"]["Error"];
5438
5519
  };
5439
5520
  };
5440
- /** @description Bandwidth quota exhausted (`quota_exceeded`). */
5441
- 402: {
5442
- headers: {
5443
- [name: string]: unknown;
5444
- };
5445
- content: {
5446
- "application/json": components["schemas"]["Error"];
5447
- };
5448
- };
5521
+ 402: components["responses"]["PaymentRequired"];
5449
5522
  /** @description Endpoint not available (feature flag disabled). */
5450
5523
  404: {
5451
5524
  headers: {
@@ -5556,11 +5629,11 @@ export interface operations {
5556
5629
  bytes_bulk: number;
5557
5630
  bytes_scrape: number;
5558
5631
  bytes_monitor: number;
5559
- /** @description The spendable byte budget for this period, summed over the account's value lots: the allowance granted for the current period, plus unspent allowance carried over from earlier periods, plus purchased top-up and starter-grant bytes. Carried-over value is spent first, so this figure falls as it is consumed. */
5632
+ /** @description The spendable byte budget for this period, summed over the account's value lots: the allowance granted for the current period, plus unspent allowance carried over from earlier periods, plus purchased top-up and starter-grant bytes. The figure falls as those lots are consumed. */
5560
5633
  bytes_limit: number;
5561
5634
  /** @description Bytes still available across every active lot, after active refund reservations. */
5562
5635
  bytes_remaining: number;
5563
- /** @description Unspent allowance carried over from earlier billing periods. */
5636
+ /** @description Unspent allowance carried over from earlier billing periods. Value is spent in one order: your plan's included allowance, including any rollover from earlier periods, then purchased top-ups, then the one-time starter grant. */
5564
5637
  rollover_bytes: number;
5565
5638
  /** @description Bytes remaining in purchased top-up and starter-grant lots. Subscription allowance is excluded. */
5566
5639
  topup_bytes: number;
@@ -5676,7 +5749,7 @@ export interface operations {
5676
5749
  endpoint: "screenshots" | "recordings" | "scrape" | "scrape_md" | "fetch" | "fetch_md" | "crawl" | "crawl_links" | "sitemap" | "monitors";
5677
5750
  /** @description Raw upstream wire bytes for the endpoint. Screenshot and recording rows created before issue 2179 may reflect legacy billable Phase 1 bytes because exact raw totals cannot be recovered after per-job rounding. */
5678
5751
  raw_bytes: number;
5679
- /** @description Billing multiplier applied to raw bytes (e.g. 1.5 for screenshots/recordings/scrape_md/crawl, 1.0 otherwise). */
5752
+ /** @description Billing multiplier applied to raw bytes, enumerated for every `endpoint` value above — there is no catch-all default: 1.5 for `screenshots`, `recordings`, `scrape_md`, `fetch_md` and `crawl`; 1.0 for `scrape`, `fetch`, `crawl_links`, `sitemap` and `monitors`. Requesting Markdown output moves a request from the plain endpoint key to its `_md` key, so a Markdown scrape AND a Markdown fetch both bill at 1.5× (#3779). Source of truth: `ENDPOINT_BILLING_MULTIPLIER` in packages/scrape-shared/src/billing-multipliers.ts. */
5680
5753
  multiplier: number;
5681
5754
  /** @description raw_bytes × multiplier, rounded. */
5682
5755
  billable_bytes: number;
@@ -5913,10 +5986,10 @@ export interface operations {
5913
5986
  content: {
5914
5987
  "application/json": {
5915
5988
  /**
5916
- * @description Bytes to purchase. Allowed tiers — 5, 25, 50, 75, 100 GB.
5989
+ * @description Bytes to purchase. Allowed tiers — 5, 25, 50, 75, 100 GB (1 GB = 1,000,000,000 bytes).
5917
5990
  * @enum {integer}
5918
5991
  */
5919
- bytes: 5368709120 | 26843545600 | 53687091200 | 80530636800 | 107374182400;
5992
+ bytes: 5000000000 | 25000000000 | 50000000000 | 75000000000 | 100000000000;
5920
5993
  /**
5921
5994
  * Format: uri
5922
5995
  * @description Redirect target after a completed Checkout.
@@ -6070,6 +6143,52 @@ export interface operations {
6070
6143
  };
6071
6144
  };
6072
6145
  };
6146
+ getPlanChange: {
6147
+ parameters: {
6148
+ query?: never;
6149
+ header?: never;
6150
+ path?: never;
6151
+ cookie?: never;
6152
+ };
6153
+ requestBody?: never;
6154
+ responses: {
6155
+ /** @description Successful response. */
6156
+ 200: {
6157
+ headers: {
6158
+ [name: string]: unknown;
6159
+ };
6160
+ content: {
6161
+ "application/json": {
6162
+ /** @description The plan the subscription switches to, or null. */
6163
+ pending_plan_slug: string | null;
6164
+ /**
6165
+ * Format: date-time
6166
+ * @description When the booked change lands, or null.
6167
+ */
6168
+ pending_effective_at: string | null;
6169
+ };
6170
+ };
6171
+ };
6172
+ /** @description No subscription. */
6173
+ 400: {
6174
+ headers: {
6175
+ [name: string]: unknown;
6176
+ };
6177
+ content: {
6178
+ "application/json": components["schemas"]["Error"];
6179
+ };
6180
+ };
6181
+ /** @description The Stripe subscription schedule could not be read. */
6182
+ 502: {
6183
+ headers: {
6184
+ [name: string]: unknown;
6185
+ };
6186
+ content: {
6187
+ "application/json": components["schemas"]["Error"];
6188
+ };
6189
+ };
6190
+ };
6191
+ };
6073
6192
  changePlan: {
6074
6193
  parameters: {
6075
6194
  query?: never;
@@ -6086,13 +6205,28 @@ export interface operations {
6086
6205
  };
6087
6206
  };
6088
6207
  responses: {
6089
- /** @description Successful response. */
6208
+ /** @description Upgrades apply immediately (`changed: true`). Downgrades are booked for the end of the paid period (`changed: false`, `pending: true`) so the customer keeps the allowance they already paid for and nothing is prorated. */
6090
6209
  200: {
6091
6210
  headers: {
6092
6211
  [name: string]: unknown;
6093
6212
  };
6094
6213
  content: {
6095
- "application/json": Record<string, never>;
6214
+ "application/json": {
6215
+ /** @description Whether the subscription was re-priced now. */
6216
+ changed: boolean;
6217
+ /** @description Present and true when the change is booked for a later date. */
6218
+ pending?: boolean;
6219
+ previous_plan: string;
6220
+ new_plan: string;
6221
+ subscription_id: string;
6222
+ /**
6223
+ * Format: date-time
6224
+ * @description When a booked change lands. Absent on an immediate change.
6225
+ */
6226
+ effective_at?: string;
6227
+ /** @description Stripe proration behaviour applied. Absent on a booked change. */
6228
+ proration?: string;
6229
+ };
6096
6230
  };
6097
6231
  };
6098
6232
  /** @description No subscription, same plan, or invalid plan. */
@@ -6106,6 +6240,40 @@ export interface operations {
6106
6240
  };
6107
6241
  };
6108
6242
  };
6243
+ revokePlanChange: {
6244
+ parameters: {
6245
+ query?: never;
6246
+ header?: never;
6247
+ path?: never;
6248
+ cookie?: never;
6249
+ };
6250
+ requestBody?: never;
6251
+ responses: {
6252
+ /** @description Successful response. */
6253
+ 200: {
6254
+ headers: {
6255
+ [name: string]: unknown;
6256
+ };
6257
+ content: {
6258
+ "application/json": {
6259
+ revoked: boolean;
6260
+ /** @description The plan the subscription stays on. */
6261
+ plan: string;
6262
+ subscription_id: string;
6263
+ };
6264
+ };
6265
+ };
6266
+ /** @description No subscription, or no scheduled plan change to revoke. */
6267
+ 400: {
6268
+ headers: {
6269
+ [name: string]: unknown;
6270
+ };
6271
+ content: {
6272
+ "application/json": components["schemas"]["Error"];
6273
+ };
6274
+ };
6275
+ };
6276
+ };
6109
6277
  listInvoices: {
6110
6278
  parameters: {
6111
6279
  query?: {
@@ -6207,13 +6375,13 @@ export interface operations {
6207
6375
  content: {
6208
6376
  "application/json": {
6209
6377
  enabled: boolean;
6210
- /** @description Min 1 MB. Required when enabled. */
6378
+ /** @description Min 1 MB (1,000,000 bytes). Required when enabled. */
6211
6379
  threshold_bytes?: number;
6212
6380
  /**
6213
- * @description Allowed tiers — 5, 25, 50, 75, 100 GB. Required when enabled.
6381
+ * @description Allowed tiers — 5, 25, 50, 75, 100 GB (1 GB = 1,000,000,000 bytes). Required when enabled.
6214
6382
  * @enum {integer}
6215
6383
  */
6216
- amount_bytes?: 5368709120 | 26843545600 | 53687091200 | 80530636800 | 107374182400;
6384
+ amount_bytes?: 5000000000 | 25000000000 | 50000000000 | 75000000000 | 100000000000;
6217
6385
  /** @description $1-$1000. Required when enabled. */
6218
6386
  monthly_cap_cents?: number;
6219
6387
  };
@@ -29,7 +29,7 @@ export type TokenEncoding = 'cl100k_base' | 'o200k_base';
29
29
  /** Options for POST /v1/scrape. */
30
30
  export interface ScrapeOpts {
31
31
  url: string;
32
- formats?: Array<'raw_html' | 'html' | 'markdown' | 'links' | 'images'>;
32
+ formats?: Array<'raw' | 'markdown' | 'links' | 'images'>;
33
33
  country?: string;
34
34
  delay_ms?: number;
35
35
  /** SERVER-side scrape budget in ms — how long the gateway may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`. */
@@ -65,11 +65,11 @@ export interface ScrapeOpts {
65
65
  token_encoding?: TokenEncoding;
66
66
  /** When true, emulate a mobile device (mobile UA + viewport). Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently. */
67
67
  mobile?: boolean;
68
- /** When true (default), base64-encoded `data:` image sources are stripped before markdown conversion and from `html` output. Set false to preserve them. Does not affect `raw_html`. */
68
+ /** When true (default), base64-encoded `data:` image sources are stripped before markdown conversion. Set false to preserve them. Does not affect `raw`. */
69
69
  remove_base64_images?: boolean;
70
- /** HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `html`/`markdown` output. Applied before `exclude_tags`. Does not affect `raw_html`. */
70
+ /** HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `markdown` output. Applied before `exclude_tags`. Does not affect `raw`. */
71
71
  include_tags?: string[];
72
- /** HTML element names (not CSS selectors) to strip from `html`/`markdown` output. Applied after `include_tags`. Does not affect `raw_html`. */
72
+ /** HTML element names (not CSS selectors) to strip from `markdown` output. Applied after `include_tags`. Does not affect `raw`. */
73
73
  exclude_tags?: string[];
74
74
  /** When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds. */
75
75
  clean_markdown?: boolean;
package/dist/version.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * outbound request carries — see the emit site in `client.ts`. The header name is spelled
6
6
  * only there, so issue #2905's pre-merge gate 1 counts exactly one occurrence in `src/`.
7
7
  */
8
- export declare const SDK_VERSION = "0.9.1";
8
+ export declare const SDK_VERSION = "0.9.3";
package/dist/version.js CHANGED
@@ -9,4 +9,4 @@
9
9
  * outbound request carries — see the emit site in `client.ts`. The header name is spelled
10
10
  * only there, so issue #2905's pre-merge gate 1 counts exactly one occurrence in `src/`.
11
11
  */
12
- export const SDK_VERSION = '0.9.1';
12
+ export const SDK_VERSION = '0.9.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-sdk",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Official TypeScript SDK for the ByteKit API",
5
5
  "license": "MIT",
6
6
  "type": "module",