@hunt-labs/bytekit-sdk 0.3.0 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import type { ByteKit } from '../client.js';
1
+ import type { ByteKit, RequestOptions } from '../client.js';
2
2
  import type { operations } from '../generated/api.js';
3
3
  import type { ApiKeyId } from '../types.js';
4
4
  /**
@@ -37,8 +37,13 @@ export declare class AccountResource {
37
37
  private readonly client;
38
38
  readonly apiKeys: ApiKeysResource;
39
39
  constructor(client: ByteKit);
40
- /** GET /v1/account — get the authenticated account */
41
- get(): Promise<GetAccountResponse>;
40
+ /**
41
+ * GET /v1/account — get the authenticated account.
42
+ *
43
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
44
+ * optional caller `signal`; both override the constructor's `timeoutMs` default.
45
+ */
46
+ get(requestOptions?: RequestOptions): Promise<GetAccountResponse>;
42
47
  }
43
48
  declare class ApiKeysResource {
44
49
  private readonly client;
@@ -49,13 +54,13 @@ declare class ApiKeysResource {
49
54
  * `opts` is optional: the spec declares the request body itself as optional,
50
55
  * so `create()` with no arguments is valid and sends no body.
51
56
  */
52
- create(opts?: CreateApiKeyRequest): Promise<CreateApiKeyResponse>;
57
+ create(opts?: CreateApiKeyRequest, requestOptions?: RequestOptions): Promise<CreateApiKeyResponse>;
53
58
  /** GET /v1/account/api-keys — list all API keys for the account */
54
- list(): Promise<ListApiKeysResponse>;
59
+ list(requestOptions?: RequestOptions): Promise<ListApiKeysResponse>;
55
60
  /** GET /v1/account/api-keys/{id} — get an API key by ID */
56
- get(id: ApiKeyId): Promise<GetApiKeyResponse>;
61
+ get(id: ApiKeyId, requestOptions?: RequestOptions): Promise<GetApiKeyResponse>;
57
62
  /** PATCH /v1/account/api-keys/{id} — update an API key */
58
- update(id: ApiKeyId, opts: UpdateApiKeyRequest): Promise<UpdateApiKeyResponse>;
63
+ update(id: ApiKeyId, opts: UpdateApiKeyRequest, requestOptions?: RequestOptions): Promise<UpdateApiKeyResponse>;
59
64
  /**
60
65
  * DELETE /v1/account/api-keys/{id} — revoke an API key (idempotent).
61
66
  *
@@ -67,8 +72,8 @@ declare class ApiKeysResource {
67
72
  * to `undefined` before it would parse the body as JSON (#2450), so this
68
73
  * method resolves cleanly on the gateway's empty 204 body.
69
74
  */
70
- revoke(id: ApiKeyId): Promise<void>;
75
+ revoke(id: ApiKeyId, requestOptions?: RequestOptions): Promise<void>;
71
76
  /** POST /v1/account/api-keys/{id}/reveal — reveal the plaintext API key value */
72
- reveal(id: ApiKeyId): Promise<RevealApiKeyResponse>;
77
+ reveal(id: ApiKeyId, requestOptions?: RequestOptions): Promise<RevealApiKeyResponse>;
73
78
  }
74
79
  export {};
@@ -5,9 +5,14 @@ export class AccountResource {
5
5
  this.client = client;
6
6
  this.apiKeys = new ApiKeysResource(client);
7
7
  }
8
- /** GET /v1/account — get the authenticated account */
9
- get() {
10
- return this.client.request('GET', '/v1/account');
8
+ /**
9
+ * GET /v1/account — get the authenticated account.
10
+ *
11
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
12
+ * optional caller `signal`; both override the constructor's `timeoutMs` default.
13
+ */
14
+ get(requestOptions) {
15
+ return this.client.request('GET', '/v1/account', undefined, requestOptions);
11
16
  }
12
17
  }
13
18
  class ApiKeysResource {
@@ -21,20 +26,20 @@ class ApiKeysResource {
21
26
  * `opts` is optional: the spec declares the request body itself as optional,
22
27
  * so `create()` with no arguments is valid and sends no body.
23
28
  */
24
- create(opts) {
25
- return this.client.request('POST', '/v1/account/api-keys', opts);
29
+ create(opts, requestOptions) {
30
+ return this.client.request('POST', '/v1/account/api-keys', opts, requestOptions);
26
31
  }
27
32
  /** GET /v1/account/api-keys — list all API keys for the account */
28
- list() {
29
- return this.client.request('GET', '/v1/account/api-keys');
33
+ list(requestOptions) {
34
+ return this.client.request('GET', '/v1/account/api-keys', undefined, requestOptions);
30
35
  }
31
36
  /** GET /v1/account/api-keys/{id} — get an API key by ID */
32
- get(id) {
33
- return this.client.request('GET', `/v1/account/api-keys/${id}`);
37
+ get(id, requestOptions) {
38
+ return this.client.request('GET', `/v1/account/api-keys/${id}`, undefined, requestOptions);
34
39
  }
35
40
  /** PATCH /v1/account/api-keys/{id} — update an API key */
36
- update(id, opts) {
37
- return this.client.request('PATCH', `/v1/account/api-keys/${id}`, opts);
41
+ update(id, opts, requestOptions) {
42
+ return this.client.request('PATCH', `/v1/account/api-keys/${id}`, opts, requestOptions);
38
43
  }
39
44
  /**
40
45
  * DELETE /v1/account/api-keys/{id} — revoke an API key (idempotent).
@@ -47,11 +52,11 @@ class ApiKeysResource {
47
52
  * to `undefined` before it would parse the body as JSON (#2450), so this
48
53
  * method resolves cleanly on the gateway's empty 204 body.
49
54
  */
50
- revoke(id) {
51
- return this.client.request('DELETE', `/v1/account/api-keys/${id}`);
55
+ revoke(id, requestOptions) {
56
+ return this.client.request('DELETE', `/v1/account/api-keys/${id}`, undefined, requestOptions);
52
57
  }
53
58
  /** POST /v1/account/api-keys/{id}/reveal — reveal the plaintext API key value */
54
- reveal(id) {
55
- return this.client.request('POST', `/v1/account/api-keys/${id}/reveal`);
59
+ reveal(id, requestOptions) {
60
+ return this.client.request('POST', `/v1/account/api-keys/${id}/reveal`, undefined, requestOptions);
56
61
  }
57
62
  }
@@ -1,4 +1,4 @@
1
- import type { ByteKit } from '../client.js';
1
+ import type { ByteKit, RequestOptions } from '../client.js';
2
2
  import type { operations } from '../generated/api.js';
3
3
  import type { BulkId } from '../types.js';
4
4
  /** Body of POST /v1/bulk. */
@@ -15,17 +15,22 @@ export declare class BulkResource {
15
15
  private readonly client;
16
16
  readonly screenshots: BulkScreenshotsResource;
17
17
  constructor(client: ByteKit);
18
- /** POST /v1/bulk — create a bulk screenshots job */
19
- create(opts: BulkCreateRequest): Promise<BulkCreateResponse>;
18
+ /**
19
+ * POST /v1/bulk — create a bulk screenshots job.
20
+ *
21
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
22
+ * optional caller `signal`; both override the constructor's `timeoutMs` default.
23
+ */
24
+ create(opts: BulkCreateRequest, requestOptions?: RequestOptions): Promise<BulkCreateResponse>;
20
25
  /** GET /v1/bulk/{id} — get a bulk job status */
21
- get(id: BulkId): Promise<BulkGetResponse>;
26
+ get(id: BulkId, requestOptions?: RequestOptions): Promise<BulkGetResponse>;
22
27
  /** DELETE /v1/bulk/{id} — cancel an in-flight bulk job */
23
- cancel(id: BulkId): Promise<BulkCancelResponse>;
28
+ cancel(id: BulkId, requestOptions?: RequestOptions): Promise<BulkCancelResponse>;
24
29
  }
25
30
  declare class BulkScreenshotsResource {
26
31
  private readonly client;
27
32
  constructor(client: ByteKit);
28
33
  /** GET /v1/bulk/{id}/screenshots — list screenshots in a bulk job */
29
- list(id: BulkId): Promise<ListBulkScreenshotsResponse>;
34
+ list(id: BulkId, requestOptions?: RequestOptions): Promise<ListBulkScreenshotsResponse>;
30
35
  }
31
36
  export {};
@@ -5,17 +5,22 @@ export class BulkResource {
5
5
  this.client = client;
6
6
  this.screenshots = new BulkScreenshotsResource(client);
7
7
  }
8
- /** POST /v1/bulk — create a bulk screenshots job */
9
- create(opts) {
10
- return this.client.request('POST', '/v1/bulk', opts);
8
+ /**
9
+ * POST /v1/bulk — create a bulk screenshots job.
10
+ *
11
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
12
+ * optional caller `signal`; both override the constructor's `timeoutMs` default.
13
+ */
14
+ create(opts, requestOptions) {
15
+ return this.client.request('POST', '/v1/bulk', opts, requestOptions);
11
16
  }
12
17
  /** GET /v1/bulk/{id} — get a bulk job status */
13
- get(id) {
14
- return this.client.request('GET', `/v1/bulk/${id}`);
18
+ get(id, requestOptions) {
19
+ return this.client.request('GET', `/v1/bulk/${id}`, undefined, requestOptions);
15
20
  }
16
21
  /** DELETE /v1/bulk/{id} — cancel an in-flight bulk job */
17
- cancel(id) {
18
- return this.client.request('DELETE', `/v1/bulk/${id}`);
22
+ cancel(id, requestOptions) {
23
+ return this.client.request('DELETE', `/v1/bulk/${id}`, undefined, requestOptions);
19
24
  }
20
25
  }
21
26
  class BulkScreenshotsResource {
@@ -24,7 +29,7 @@ class BulkScreenshotsResource {
24
29
  this.client = client;
25
30
  }
26
31
  /** GET /v1/bulk/{id}/screenshots — list screenshots in a bulk job */
27
- list(id) {
28
- return this.client.request('GET', `/v1/bulk/${id}/screenshots`);
32
+ list(id, requestOptions) {
33
+ return this.client.request('GET', `/v1/bulk/${id}/screenshots`, undefined, requestOptions);
29
34
  }
30
35
  }
@@ -1,4 +1,4 @@
1
- import type { ByteKit } from '../client.js';
1
+ import type { ByteKit, RequestOptions } from '../client.js';
2
2
  import type { operations } from '../generated/api.js';
3
3
  import type { BulkId } from '../types.js';
4
4
  /** Body of POST /v1/fetch/bulk. */
@@ -56,14 +56,29 @@ export interface FetchOpts {
56
56
  */
57
57
  custom?: Record<string, unknown>;
58
58
  }
59
+ /**
60
+ * The query params `GET /v1/fetch` accepts, in serialization order.
61
+ *
62
+ * This is the single source of truth for BOTH halves of the GET path: the
63
+ * {@link FetchGetOpts} key set and the query string the builder emits. Keeping
64
+ * them derived from one list is what makes "accepted by the type but dropped by
65
+ * the serializer" — the #2539 bug — unrepresentable. The list itself is pinned to
66
+ * the generated `getFetch` query type by `_AssertFetchGetQueryKeysCoverSpec`
67
+ * below, so it cannot drift away from the spec silently.
68
+ */
69
+ declare const FETCH_GET_QUERY_KEYS: readonly ["url", "format", "country", "timeout_ms", "cache_ttl"];
70
+ type FetchGetQueryKey = (typeof FETCH_GET_QUERY_KEYS)[number];
59
71
  /**
60
72
  * Options accepted by `fetch.get` (GET /v1/fetch).
61
73
  *
62
- * Identical to {@link FetchOpts} minus `custom`: the spec's `GET /v1/fetch` has
63
- * no `custom` query param, so it is excluded here — passing it is a compile
64
- * error rather than a silently-dropped option (#2481).
74
+ * A strict subset of {@link FetchOpts}: only the five params the spec's
75
+ * `GET /v1/fetch` actually declares. Everything else on the POST body —
76
+ * `custom` (#2481) and the eleven `markdown_*` / `with_*` tuning fields (#2539) —
77
+ * has no GET query param and was silently dropped by the query builder, so it is
78
+ * excluded here and passing it is a compile error. Use `create()` (POST) for
79
+ * those.
65
80
  */
66
- export type FetchGetOpts = Omit<FetchOpts, 'custom'>;
81
+ export type FetchGetOpts = Pick<FetchOpts, FetchGetQueryKey>;
67
82
  /** Cache-lookup outcome reported in the `X-Fetch-Cache` response header. */
68
83
  export type FetchCacheStatus = 'hit' | 'miss' | 'bypass';
69
84
  /**
@@ -71,7 +86,7 @@ export type FetchCacheStatus = 'hit' | 'miss' | 'bypass';
71
86
  *
72
87
  * `/v1/fetch` returns the fetched content AS the response body (text/html,
73
88
  * text/markdown, or raw binary passthrough) with metadata carried in `X-Fetch-*`
74
- * response headers — it is NOT a JSON envelope. `body` is therefore the raw
89
+ * headers on the response — it is NOT a JSON envelope. `body` is therefore the raw
75
90
  * content string, never a parsed object, and the named fields decode the
76
91
  * headers the docs call out. Anything not surfaced here is available on
77
92
  * `headers` (e.g. `X-Fetch-Duration-Ms`, `X-Fetch-Waf-Vendor`).
@@ -104,7 +119,7 @@ export interface FetchResult {
104
119
  custom: string | null;
105
120
  /** The response `Content-Type` (e.g. `text/html`), or `null` if absent. */
106
121
  contentType: string | null;
107
- /** The full response headers, for any `X-Fetch-*` value not surfaced above. */
122
+ /** The full header set on the response, for any `X-Fetch-*` value not surfaced above. */
108
123
  headers: Headers;
109
124
  }
110
125
  export declare class FetchResource {
@@ -117,26 +132,40 @@ export declare class FetchResource {
117
132
  * Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
118
133
  * The body is returned verbatim — a JSON-serving upstream comes back as the
119
134
  * raw JSON string, not a parsed object.
135
+ *
136
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
137
+ * optional caller `signal`. It matters most here: the gateway's own ceiling for a
138
+ * fetch is 60 s, so without a per-call budget a slow upstream holds the caller for
139
+ * the constructor default (2 minutes) rather than a duration the caller chose.
120
140
  */
121
- create(opts: FetchOpts): Promise<FetchResult>;
141
+ create(opts: FetchOpts, requestOptions?: RequestOptions): Promise<FetchResult>;
122
142
  /**
123
143
  * GET /v1/fetch — fetch URL content via query params.
124
144
  *
125
145
  * Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
126
146
  *
127
- * `custom` is intentionally absent from the accepted opts: the spec's
128
- * `GET /v1/fetch` has no `custom` query param and the value was never
129
- * serialized, so passing it is a compile error rather than a silent drop
130
- * (#2481). Use `create()` (POST) when you need to echo a `custom` payload.
147
+ * Accepts only the five params the spec declares for this endpoint. `custom`
148
+ * (#2481) and the `markdown_*` / `with_*` tuning fields (#2539) are POST-body
149
+ * options with no GET query param — they were silently dropped by this builder,
150
+ * so they are now compile errors instead. Use `create()` (POST) for those.
151
+ *
152
+ * The query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list
153
+ * `FetchGetOpts` is derived from, so every accepted option is necessarily
154
+ * serialized.
155
+ *
156
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
157
+ * optional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is
158
+ * 60 s, so a per-call budget is what keeps a slow upstream from holding the caller
159
+ * for the constructor default.
131
160
  */
132
- get(opts: FetchGetOpts): Promise<FetchResult>;
161
+ get(opts: FetchGetOpts, requestOptions?: RequestOptions): Promise<FetchResult>;
133
162
  }
134
163
  declare class FetchBulkResource {
135
164
  private readonly client;
136
165
  constructor(client: ByteKit);
137
166
  /** POST /v1/fetch/bulk — create a bulk fetch job */
138
- create(opts: FetchBulkCreateRequest): Promise<FetchBulkCreateResponse>;
167
+ create(opts: FetchBulkCreateRequest, requestOptions?: RequestOptions): Promise<FetchBulkCreateResponse>;
139
168
  /** GET /v1/fetch/bulk/{id} — get a bulk fetch job */
140
- get(id: BulkId): Promise<FetchBulkGetResponse>;
169
+ get(id: BulkId, requestOptions?: RequestOptions): Promise<FetchBulkGetResponse>;
141
170
  }
142
171
  export {};
@@ -1,9 +1,23 @@
1
+ /**
2
+ * The query params `GET /v1/fetch` accepts, in serialization order.
3
+ *
4
+ * This is the single source of truth for BOTH halves of the GET path: the
5
+ * {@link FetchGetOpts} key set and the query string the builder emits. Keeping
6
+ * them derived from one list is what makes "accepted by the type but dropped by
7
+ * the serializer" — the #2539 bug — unrepresentable. The list itself is pinned to
8
+ * the generated `getFetch` query type by `_AssertFetchGetQueryKeysCoverSpec`
9
+ * below, so it cannot drift away from the spec silently.
10
+ */
11
+ const FETCH_GET_QUERY_KEYS = ['url', 'format', 'country', 'timeout_ms', 'cache_ttl'];
1
12
  const CACHE_STATUSES = ['hit', 'miss', 'bypass'];
2
- /** Build a typed {@link FetchResult} from a raw body + response headers. */
13
+ /** Build a typed {@link FetchResult} from a raw body + its header set. */
3
14
  function toFetchResult(raw) {
4
15
  const { body, bytes, headers } = raw;
5
16
  const creditsRaw = headers.get('X-Fetch-Credits-Charged');
6
- const credits = creditsRaw === null ? NaN : Number(creditsRaw);
17
+ // An empty-but-present header must be treated the same as an absent one: `Number('')`
18
+ // is `0` (finite), so without this check an empty header parsed as a real zero-credit
19
+ // charge instead of "unparseable" (#2595).
20
+ const credits = creditsRaw === null || creditsRaw.trim() === '' ? NaN : Number(creditsRaw);
7
21
  const cacheRaw = headers.get('X-Fetch-Cache');
8
22
  return {
9
23
  body,
@@ -31,32 +45,42 @@ export class FetchResource {
31
45
  * Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
32
46
  * The body is returned verbatim — a JSON-serving upstream comes back as the
33
47
  * raw JSON string, not a parsed object.
48
+ *
49
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
50
+ * optional caller `signal`. It matters most here: the gateway's own ceiling for a
51
+ * fetch is 60 s, so without a per-call budget a slow upstream holds the caller for
52
+ * the constructor default (2 minutes) rather than a duration the caller chose.
34
53
  */
35
- async create(opts) {
36
- return toFetchResult(await this.client.requestRaw('POST', '/v1/fetch', opts));
54
+ async create(opts, requestOptions) {
55
+ return toFetchResult(await this.client.requestRaw('POST', '/v1/fetch', opts, requestOptions));
37
56
  }
38
57
  /**
39
58
  * GET /v1/fetch — fetch URL content via query params.
40
59
  *
41
60
  * Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
42
61
  *
43
- * `custom` is intentionally absent from the accepted opts: the spec's
44
- * `GET /v1/fetch` has no `custom` query param and the value was never
45
- * serialized, so passing it is a compile error rather than a silent drop
46
- * (#2481). Use `create()` (POST) when you need to echo a `custom` payload.
62
+ * Accepts only the five params the spec declares for this endpoint. `custom`
63
+ * (#2481) and the `markdown_*` / `with_*` tuning fields (#2539) are POST-body
64
+ * options with no GET query param — they were silently dropped by this builder,
65
+ * so they are now compile errors instead. Use `create()` (POST) for those.
66
+ *
67
+ * The query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list
68
+ * `FetchGetOpts` is derived from, so every accepted option is necessarily
69
+ * serialized.
70
+ *
71
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
72
+ * optional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is
73
+ * 60 s, so a per-call budget is what keeps a slow upstream from holding the caller
74
+ * for the constructor default.
47
75
  */
48
- async get(opts) {
76
+ async get(opts, requestOptions) {
49
77
  const params = new URLSearchParams();
50
- params.set('url', opts.url);
51
- if (opts.format !== undefined)
52
- params.set('format', opts.format);
53
- if (opts.country !== undefined)
54
- params.set('country', opts.country);
55
- if (opts.timeout_ms !== undefined)
56
- params.set('timeout_ms', String(opts.timeout_ms));
57
- if (opts.cache_ttl !== undefined)
58
- params.set('cache_ttl', String(opts.cache_ttl));
59
- return toFetchResult(await this.client.requestRaw('GET', `/v1/fetch?${params.toString()}`));
78
+ for (const key of FETCH_GET_QUERY_KEYS) {
79
+ const value = opts[key];
80
+ if (value !== undefined)
81
+ params.set(key, String(value));
82
+ }
83
+ return toFetchResult(await this.client.requestRaw('GET', `/v1/fetch?${params.toString()}`, undefined, requestOptions));
60
84
  }
61
85
  }
62
86
  class FetchBulkResource {
@@ -65,11 +89,11 @@ class FetchBulkResource {
65
89
  this.client = client;
66
90
  }
67
91
  /** POST /v1/fetch/bulk — create a bulk fetch job */
68
- create(opts) {
69
- return this.client.request('POST', '/v1/fetch/bulk', opts);
92
+ create(opts, requestOptions) {
93
+ return this.client.request('POST', '/v1/fetch/bulk', opts, requestOptions);
70
94
  }
71
95
  /** GET /v1/fetch/bulk/{id} — get a bulk fetch job */
72
- get(id) {
73
- return this.client.request('GET', `/v1/fetch/bulk/${id}`);
96
+ get(id, requestOptions) {
97
+ return this.client.request('GET', `/v1/fetch/bulk/${id}`, undefined, requestOptions);
74
98
  }
75
99
  }
@@ -1,20 +1,39 @@
1
- import type { ByteKit } from '../client.js';
1
+ import type { ByteKit, RequestOptions } from '../client.js';
2
2
  import type { operations } from '../generated/api.js';
3
3
  import type { MonitorId } from '../types.js';
4
4
  /**
5
5
  * Query params of GET /v1/monitors — all optional, omitted when unset.
6
6
  *
7
- * A `type` alias (not an `interface`) so it carries an implicit index signature and stays
8
- * assignable to {@link toQueryString}'s `Record<string, string | number | undefined>` param
9
- * (interfaces do not get the implicit index signature; type aliases do).
7
+ * DERIVED from the generated `listMonitors` query type (#2547), never hand-authored:
8
+ * `status` was previously typed a bare `string`, so a typo like `'activee'` compiled and
9
+ * only failed as a 422 on the wire. Deriving it pins the filter to the spec enum, exactly
10
+ * as {@link ListWebhookDeliveriesParams} does for `/v1/webhook-deliveries`.
11
+ *
12
+ * Still a `type` alias (not an `interface`) so it carries an implicit index signature and
13
+ * stays assignable to {@link toQueryString}'s `Record<string, string | number | undefined>`
14
+ * param (interfaces do not get the implicit index signature; type aliases do).
15
+ */
16
+ export type ListMonitorsParams = NonNullable<operations['listMonitors']['parameters']['query']>;
17
+ /**
18
+ * Lifecycle status a monitor can be filtered by — the spec enum behind
19
+ * {@link ListMonitorsParams.status}. Exported so callers (and the CLI) can name it.
10
20
  */
11
- export type ListMonitorsParams = {
12
- limit?: number;
13
- cursor?: string;
14
- status?: string;
15
- };
16
- /** Body of POST /v1/monitors. */
17
- export type MonitorCreateRequest = operations['createMonitor']['requestBody']['content']['application/json'];
21
+ export type MonitorStatus = NonNullable<ListMonitorsParams['status']>;
22
+ /** The `createMonitor` request body exactly as the OpenAPI spec declares it. */
23
+ type MonitorRequestSpec = operations['createMonitor']['requestBody']['content']['application/json'];
24
+ /**
25
+ * Body of POST /v1/monitors — `url`, `interval_type`, `webhook_url` required,
26
+ * every other field optional.
27
+ *
28
+ * Same `defaultNonNullable` drift documented on `ScreenshotCreateRequest`
29
+ * (screenshots.ts:12-31, follow-up #2540): the spec's
30
+ * `required: [url, interval_type, webhook_url]` is narrow, but `type`,
31
+ * `change_threshold`, and `notify_on` carry `default:` and `openapi-typescript`
32
+ * v7 promotes them to non-optional in the generated type. Relaxed here so the
33
+ * spec-minimal `create(...)` compiles — still DERIVED from the operation type,
34
+ * never hand-authored.
35
+ */
36
+ export type MonitorCreateRequest = Partial<MonitorRequestSpec> & Pick<MonitorRequestSpec, 'url' | 'interval_type' | 'webhook_url'>;
18
37
  /** 201 payload of POST /v1/monitors. */
19
38
  export type MonitorCreateResponse = operations['createMonitor']['responses'][201]['content']['application/json'];
20
39
  /** 200 payload of GET /v1/monitors — the paginated monitor list. */
@@ -27,6 +46,19 @@ export type MonitorUpdateRequest = operations['updateMonitor']['requestBody']['c
27
46
  export type UpdateMonitorResponse = operations['updateMonitor']['responses'][200]['content']['application/json'];
28
47
  /** 200 payload of GET /v1/monitors/{id}/captures — the paginated capture list. */
29
48
  export type ListMonitorCapturesResponse = operations['listMonitorCaptures']['responses'][200]['content']['application/json'];
49
+ /**
50
+ * Query params of GET /v1/monitors/{id}/captures — `limit`/`cursor`, both optional and
51
+ * omitted when unset.
52
+ *
53
+ * DERIVED from the generated `listMonitorCaptures` query type (#2594), mirroring
54
+ * {@link ListMonitorsParams} — never hand-authored, so a spec drift (a renamed/removed query
55
+ * param) surfaces as a `tsc` error here rather than a silent request-shape mismatch (E1).
56
+ *
57
+ * Still a `type` alias (not an `interface`), for the same implicit-index-signature reason as
58
+ * {@link ListMonitorsParams} — it must stay assignable to {@link toQueryString}'s
59
+ * `Record<string, string | number | undefined>` param.
60
+ */
61
+ export type ListMonitorCapturesParams = NonNullable<operations['listMonitorCaptures']['parameters']['query']>;
30
62
  export declare class MonitorsResource {
31
63
  private readonly client;
32
64
  readonly captures: MonitorCapturesResource;
@@ -35,18 +67,18 @@ export declare class MonitorsResource {
35
67
  * POST /v1/monitors — create a page-change monitor (screenshot or scrape capture).
36
68
  * First-capture behavior is the same for both types: the first capture is a silent baseline (has_change=false, change_pct=null) with no change_detected webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.
37
69
  */
38
- create(opts: MonitorCreateRequest): Promise<MonitorCreateResponse>;
70
+ create(opts: MonitorCreateRequest, requestOptions?: RequestOptions): Promise<MonitorCreateResponse>;
39
71
  /**
40
72
  * GET /v1/monitors — list monitors for the account.
41
73
  *
42
74
  * `params` is optional and each key is omitted-when-absent, so `list()` with no argument
43
75
  * serializes the bare `/v1/monitors` URL unchanged — existing zero-arg callers are unaffected.
44
76
  */
45
- list(params?: ListMonitorsParams): Promise<ListMonitorsResponse>;
77
+ list(params?: ListMonitorsParams, requestOptions?: RequestOptions): Promise<ListMonitorsResponse>;
46
78
  /** GET /v1/monitors/{id} — get a monitor by ID */
47
- get(id: MonitorId): Promise<MonitorResponse>;
79
+ get(id: MonitorId, requestOptions?: RequestOptions): Promise<MonitorResponse>;
48
80
  /** PATCH /v1/monitors/{id} — update a monitor */
49
- update(id: MonitorId, opts: MonitorUpdateRequest): Promise<UpdateMonitorResponse>;
81
+ update(id: MonitorId, opts: MonitorUpdateRequest, requestOptions?: RequestOptions): Promise<UpdateMonitorResponse>;
50
82
  /**
51
83
  * DELETE /v1/monitors/{id} — delete a monitor.
52
84
  *
@@ -55,12 +87,18 @@ export declare class MonitorsResource {
55
87
  * from — hence `Promise<void>`. `client.request()` short-circuits the empty
56
88
  * body to `undefined` before it would parse as JSON (#2450).
57
89
  */
58
- delete(id: MonitorId): Promise<void>;
90
+ delete(id: MonitorId, requestOptions?: RequestOptions): Promise<void>;
59
91
  }
60
92
  declare class MonitorCapturesResource {
61
93
  private readonly client;
62
94
  constructor(client: ByteKit);
63
- /** GET /v1/monitors/{id}/captures — list captures for a monitor */
64
- list(id: MonitorId): Promise<ListMonitorCapturesResponse>;
95
+ /**
96
+ * GET /v1/monitors/{id}/captures — list captures for a monitor.
97
+ *
98
+ * `params` is optional and each key is omitted-when-absent (#2594), so `list(id)` with no
99
+ * second argument serializes the bare `/v1/monitors/{id}/captures` URL unchanged — existing
100
+ * zero-arg callers are unaffected (inverse case).
101
+ */
102
+ list(id: MonitorId, params?: ListMonitorCapturesParams, requestOptions?: RequestOptions): Promise<ListMonitorCapturesResponse>;
65
103
  }
66
104
  export {};
@@ -10,8 +10,8 @@ export class MonitorsResource {
10
10
  * POST /v1/monitors — create a page-change monitor (screenshot or scrape capture).
11
11
  * First-capture behavior is the same for both types: the first capture is a silent baseline (has_change=false, change_pct=null) with no change_detected webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.
12
12
  */
13
- create(opts) {
14
- return this.client.request('POST', '/v1/monitors', opts);
13
+ create(opts, requestOptions) {
14
+ return this.client.request('POST', '/v1/monitors', opts, requestOptions);
15
15
  }
16
16
  /**
17
17
  * GET /v1/monitors — list monitors for the account.
@@ -19,16 +19,16 @@ export class MonitorsResource {
19
19
  * `params` is optional and each key is omitted-when-absent, so `list()` with no argument
20
20
  * serializes the bare `/v1/monitors` URL unchanged — existing zero-arg callers are unaffected.
21
21
  */
22
- list(params) {
23
- return this.client.request('GET', `/v1/monitors${toQueryString(params)}`);
22
+ list(params, requestOptions) {
23
+ return this.client.request('GET', `/v1/monitors${toQueryString(params)}`, undefined, requestOptions);
24
24
  }
25
25
  /** GET /v1/monitors/{id} — get a monitor by ID */
26
- get(id) {
27
- return this.client.request('GET', `/v1/monitors/${id}`);
26
+ get(id, requestOptions) {
27
+ return this.client.request('GET', `/v1/monitors/${id}`, undefined, requestOptions);
28
28
  }
29
29
  /** PATCH /v1/monitors/{id} — update a monitor */
30
- update(id, opts) {
31
- return this.client.request('PATCH', `/v1/monitors/${id}`, opts);
30
+ update(id, opts, requestOptions) {
31
+ return this.client.request('PATCH', `/v1/monitors/${id}`, opts, requestOptions);
32
32
  }
33
33
  /**
34
34
  * DELETE /v1/monitors/{id} — delete a monitor.
@@ -38,8 +38,8 @@ export class MonitorsResource {
38
38
  * from — hence `Promise<void>`. `client.request()` short-circuits the empty
39
39
  * body to `undefined` before it would parse as JSON (#2450).
40
40
  */
41
- delete(id) {
42
- return this.client.request('DELETE', `/v1/monitors/${id}`);
41
+ delete(id, requestOptions) {
42
+ return this.client.request('DELETE', `/v1/monitors/${id}`, undefined, requestOptions);
43
43
  }
44
44
  }
45
45
  class MonitorCapturesResource {
@@ -47,8 +47,14 @@ class MonitorCapturesResource {
47
47
  constructor(client) {
48
48
  this.client = client;
49
49
  }
50
- /** GET /v1/monitors/{id}/captures — list captures for a monitor */
51
- list(id) {
52
- return this.client.request('GET', `/v1/monitors/${id}/captures`);
50
+ /**
51
+ * GET /v1/monitors/{id}/captures — list captures for a monitor.
52
+ *
53
+ * `params` is optional and each key is omitted-when-absent (#2594), so `list(id)` with no
54
+ * second argument serializes the bare `/v1/monitors/{id}/captures` URL unchanged — existing
55
+ * zero-arg callers are unaffected (inverse case).
56
+ */
57
+ list(id, params, requestOptions) {
58
+ return this.client.request('GET', `/v1/monitors/${id}/captures${toQueryString(params)}`, undefined, requestOptions);
53
59
  }
54
60
  }
@@ -1,5 +1,5 @@
1
1
  import type { ByteKit, RequestOptions } from '../client.js';
2
- import type { operations } from '../generated/api.js';
2
+ import type { components, operations } from '../generated/api.js';
3
3
  import type { ScrapeId, BulkId } from '../types.js';
4
4
  /**
5
5
  * Response of POST /v1/scrape — a 200 sync success envelope or a 202 queued
@@ -26,12 +26,22 @@ export type MarkdownLinks = 'inline' | 'references' | 'none' | 'text';
26
26
  export type MarkdownImages = 'inline' | 'references' | 'none' | 'text';
27
27
  /** Tokenizer encoding hint for `token_budget`. */
28
28
  export type TokenEncoding = 'cl100k_base' | 'o200k_base';
29
+ /**
30
+ * A cookie to set before loading the page — the spec's `Cookie` schema verbatim
31
+ * (`name` and `value` required; `domain`, `path`, `secure`, `httpOnly` optional).
32
+ *
33
+ * DERIVED from the generated schema (#2547), never hand-authored: `cookies` was
34
+ * previously an open bag of untyped records, so a nameless cookie compiled and only
35
+ * failed as a 422 on the wire.
36
+ */
37
+ export type ScrapeCookie = components['schemas']['Cookie'];
29
38
  /** Options for POST /v1/scrape. */
30
39
  export interface ScrapeOpts {
31
40
  url: string;
32
41
  formats?: Array<'raw_html' | 'html' | 'markdown' | 'links' | 'images'>;
33
42
  country?: string;
34
- cookies?: Array<Record<string, unknown>>;
43
+ /** Cookies to set before loading the page. `name` and `value` are required (spec `Cookie` schema). */
44
+ cookies?: ScrapeCookie[];
35
45
  headers?: Record<string, string>;
36
46
  delay_ms?: number;
37
47
  /** 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`. */
@@ -127,9 +137,14 @@ export declare class ScrapeResource {
127
137
  declare class ScrapeBulkResource {
128
138
  private readonly client;
129
139
  constructor(client: ByteKit);
130
- /** POST /v1/scrape/bulk — create a bulk scrape job */
131
- create(opts: ScrapeBulkCreateRequest): Promise<ScrapeBulkCreateResponse>;
140
+ /**
141
+ * POST /v1/scrape/bulk — create a bulk scrape job.
142
+ *
143
+ * `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
144
+ * optional caller `signal`; both override the constructor's `timeoutMs` default.
145
+ */
146
+ create(opts: ScrapeBulkCreateRequest, requestOptions?: RequestOptions): Promise<ScrapeBulkCreateResponse>;
132
147
  /** GET /v1/scrape/bulk/{id} — get a bulk scrape job */
133
- get(id: BulkId): Promise<ScrapeBulkGetResponse>;
148
+ get(id: BulkId, requestOptions?: RequestOptions): Promise<ScrapeBulkGetResponse>;
134
149
  }
135
150
  export {};