@hunt-labs/bytekit-sdk 0.3.0 → 0.4.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/CHANGELOG.md +66 -0
- package/README.md +27 -3
- package/dist/client.d.ts +66 -11
- package/dist/client.js +159 -45
- package/dist/generated/api.d.ts +17 -7
- package/dist/index.d.ts +3 -3
- package/dist/resources/account.d.ts +14 -9
- package/dist/resources/account.js +20 -15
- package/dist/resources/bulk.d.ts +11 -6
- package/dist/resources/bulk.js +14 -9
- package/dist/resources/fetch.d.ts +44 -15
- package/dist/resources/fetch.js +43 -22
- package/dist/resources/monitors.d.ts +36 -17
- package/dist/resources/monitors.js +12 -12
- package/dist/resources/scrape.d.ts +20 -5
- package/dist/resources/scrape.js +10 -5
- package/dist/resources/screenshots.d.ts +31 -3
- package/dist/resources/screenshots.js +35 -4
- package/dist/resources/search.d.ts +8 -3
- package/dist/resources/search.js +8 -3
- package/dist/resources/sitemap.d.ts +35 -6
- package/dist/resources/sitemap.js +23 -5
- package/dist/resources/usage.d.ts +10 -5
- package/dist/resources/usage.js +12 -7
- package/dist/resources/webhooks.d.ts +9 -4
- package/dist/resources/webhooks.js +10 -5
- package/package.json +1 -1
|
@@ -5,9 +5,14 @@ export class AccountResource {
|
|
|
5
5
|
this.client = client;
|
|
6
6
|
this.apiKeys = new ApiKeysResource(client);
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
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
|
}
|
package/dist/resources/bulk.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
19
|
-
|
|
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 {};
|
package/dist/resources/bulk.js
CHANGED
|
@@ -5,17 +5,22 @@ export class BulkResource {
|
|
|
5
5
|
this.client = client;
|
|
6
6
|
this.screenshots = new BulkScreenshotsResource(client);
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
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 =
|
|
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
|
|
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
|
|
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
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
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 {};
|
package/dist/resources/fetch.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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 +
|
|
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');
|
|
@@ -31,32 +42,42 @@ export class FetchResource {
|
|
|
31
42
|
* Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
|
|
32
43
|
* The body is returned verbatim — a JSON-serving upstream comes back as the
|
|
33
44
|
* raw JSON string, not a parsed object.
|
|
45
|
+
*
|
|
46
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
47
|
+
* optional caller `signal`. It matters most here: the gateway's own ceiling for a
|
|
48
|
+
* fetch is 60 s, so without a per-call budget a slow upstream holds the caller for
|
|
49
|
+
* the constructor default (2 minutes) rather than a duration the caller chose.
|
|
34
50
|
*/
|
|
35
|
-
async create(opts) {
|
|
36
|
-
return toFetchResult(await this.client.requestRaw('POST', '/v1/fetch', opts));
|
|
51
|
+
async create(opts, requestOptions) {
|
|
52
|
+
return toFetchResult(await this.client.requestRaw('POST', '/v1/fetch', opts, requestOptions));
|
|
37
53
|
}
|
|
38
54
|
/**
|
|
39
55
|
* GET /v1/fetch — fetch URL content via query params.
|
|
40
56
|
*
|
|
41
57
|
* Resolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.
|
|
42
58
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
59
|
+
* Accepts only the five params the spec declares for this endpoint. `custom`
|
|
60
|
+
* (#2481) and the `markdown_*` / `with_*` tuning fields (#2539) are POST-body
|
|
61
|
+
* options with no GET query param — they were silently dropped by this builder,
|
|
62
|
+
* so they are now compile errors instead. Use `create()` (POST) for those.
|
|
63
|
+
*
|
|
64
|
+
* The query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list
|
|
65
|
+
* `FetchGetOpts` is derived from, so every accepted option is necessarily
|
|
66
|
+
* serialized.
|
|
67
|
+
*
|
|
68
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
69
|
+
* optional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is
|
|
70
|
+
* 60 s, so a per-call budget is what keeps a slow upstream from holding the caller
|
|
71
|
+
* for the constructor default.
|
|
47
72
|
*/
|
|
48
|
-
async get(opts) {
|
|
73
|
+
async get(opts, requestOptions) {
|
|
49
74
|
const params = new URLSearchParams();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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()}`));
|
|
75
|
+
for (const key of FETCH_GET_QUERY_KEYS) {
|
|
76
|
+
const value = opts[key];
|
|
77
|
+
if (value !== undefined)
|
|
78
|
+
params.set(key, String(value));
|
|
79
|
+
}
|
|
80
|
+
return toFetchResult(await this.client.requestRaw('GET', `/v1/fetch?${params.toString()}`, undefined, requestOptions));
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
class FetchBulkResource {
|
|
@@ -65,11 +86,11 @@ class FetchBulkResource {
|
|
|
65
86
|
this.client = client;
|
|
66
87
|
}
|
|
67
88
|
/** POST /v1/fetch/bulk — create a bulk fetch job */
|
|
68
|
-
create(opts) {
|
|
69
|
-
return this.client.request('POST', '/v1/fetch/bulk', opts);
|
|
89
|
+
create(opts, requestOptions) {
|
|
90
|
+
return this.client.request('POST', '/v1/fetch/bulk', opts, requestOptions);
|
|
70
91
|
}
|
|
71
92
|
/** GET /v1/fetch/bulk/{id} — get a bulk fetch job */
|
|
72
|
-
get(id) {
|
|
73
|
-
return this.client.request('GET', `/v1/fetch/bulk/${id}
|
|
93
|
+
get(id, requestOptions) {
|
|
94
|
+
return this.client.request('GET', `/v1/fetch/bulk/${id}`, undefined, requestOptions);
|
|
74
95
|
}
|
|
75
96
|
}
|
|
@@ -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
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
20
|
+
*/
|
|
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.
|
|
10
35
|
*/
|
|
11
|
-
export type
|
|
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'];
|
|
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. */
|
|
@@ -35,18 +54,18 @@ export declare class MonitorsResource {
|
|
|
35
54
|
* POST /v1/monitors — create a page-change monitor (screenshot or scrape capture).
|
|
36
55
|
* 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
56
|
*/
|
|
38
|
-
create(opts: MonitorCreateRequest): Promise<MonitorCreateResponse>;
|
|
57
|
+
create(opts: MonitorCreateRequest, requestOptions?: RequestOptions): Promise<MonitorCreateResponse>;
|
|
39
58
|
/**
|
|
40
59
|
* GET /v1/monitors — list monitors for the account.
|
|
41
60
|
*
|
|
42
61
|
* `params` is optional and each key is omitted-when-absent, so `list()` with no argument
|
|
43
62
|
* serializes the bare `/v1/monitors` URL unchanged — existing zero-arg callers are unaffected.
|
|
44
63
|
*/
|
|
45
|
-
list(params?: ListMonitorsParams): Promise<ListMonitorsResponse>;
|
|
64
|
+
list(params?: ListMonitorsParams, requestOptions?: RequestOptions): Promise<ListMonitorsResponse>;
|
|
46
65
|
/** GET /v1/monitors/{id} — get a monitor by ID */
|
|
47
|
-
get(id: MonitorId): Promise<MonitorResponse>;
|
|
66
|
+
get(id: MonitorId, requestOptions?: RequestOptions): Promise<MonitorResponse>;
|
|
48
67
|
/** PATCH /v1/monitors/{id} — update a monitor */
|
|
49
|
-
update(id: MonitorId, opts: MonitorUpdateRequest): Promise<UpdateMonitorResponse>;
|
|
68
|
+
update(id: MonitorId, opts: MonitorUpdateRequest, requestOptions?: RequestOptions): Promise<UpdateMonitorResponse>;
|
|
50
69
|
/**
|
|
51
70
|
* DELETE /v1/monitors/{id} — delete a monitor.
|
|
52
71
|
*
|
|
@@ -55,12 +74,12 @@ export declare class MonitorsResource {
|
|
|
55
74
|
* from — hence `Promise<void>`. `client.request()` short-circuits the empty
|
|
56
75
|
* body to `undefined` before it would parse as JSON (#2450).
|
|
57
76
|
*/
|
|
58
|
-
delete(id: MonitorId): Promise<void>;
|
|
77
|
+
delete(id: MonitorId, requestOptions?: RequestOptions): Promise<void>;
|
|
59
78
|
}
|
|
60
79
|
declare class MonitorCapturesResource {
|
|
61
80
|
private readonly client;
|
|
62
81
|
constructor(client: ByteKit);
|
|
63
82
|
/** GET /v1/monitors/{id}/captures — list captures for a monitor */
|
|
64
|
-
list(id: MonitorId): Promise<ListMonitorCapturesResponse>;
|
|
83
|
+
list(id: MonitorId, requestOptions?: RequestOptions): Promise<ListMonitorCapturesResponse>;
|
|
65
84
|
}
|
|
66
85
|
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 {
|
|
@@ -48,7 +48,7 @@ class MonitorCapturesResource {
|
|
|
48
48
|
this.client = client;
|
|
49
49
|
}
|
|
50
50
|
/** GET /v1/monitors/{id}/captures — list captures for a monitor */
|
|
51
|
-
list(id) {
|
|
52
|
-
return this.client.request('GET', `/v1/monitors/${id}/captures
|
|
51
|
+
list(id, requestOptions) {
|
|
52
|
+
return this.client.request('GET', `/v1/monitors/${id}/captures`, undefined, requestOptions);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -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
|
-
|
|
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
|
-
/**
|
|
131
|
-
|
|
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 {};
|
package/dist/resources/scrape.js
CHANGED
|
@@ -43,12 +43,17 @@ class ScrapeBulkResource {
|
|
|
43
43
|
constructor(client) {
|
|
44
44
|
this.client = client;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
/**
|
|
47
|
+
* POST /v1/scrape/bulk — create a bulk scrape job.
|
|
48
|
+
*
|
|
49
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
50
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
51
|
+
*/
|
|
52
|
+
create(opts, requestOptions) {
|
|
53
|
+
return this.client.request('POST', '/v1/scrape/bulk', opts, requestOptions);
|
|
49
54
|
}
|
|
50
55
|
/** GET /v1/scrape/bulk/{id} — get a bulk scrape job */
|
|
51
|
-
get(id) {
|
|
52
|
-
return this.client.request('GET', `/v1/scrape/bulk/${id}
|
|
56
|
+
get(id, requestOptions) {
|
|
57
|
+
return this.client.request('GET', `/v1/scrape/bulk/${id}`, undefined, requestOptions);
|
|
53
58
|
}
|
|
54
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ByteKit } from '../client.js';
|
|
1
|
+
import type { ApiResponse, ByteKit, RequestOptions } from '../client.js';
|
|
2
2
|
import type { operations } from '../generated/api.js';
|
|
3
3
|
import type { ScreenshotId } from '../types.js';
|
|
4
4
|
/** The `createScreenshot` request body exactly as the OpenAPI spec declares it. */
|
|
@@ -55,16 +55,44 @@ export declare class ScreenshotsResource {
|
|
|
55
55
|
* param on `createScreenshot`, distinct from scrape where `async` is a body field. `params` is
|
|
56
56
|
* optional and `async` omitted-when-absent: `create(opts)` with no second argument posts to the
|
|
57
57
|
* bare `/v1/screenshots` URL unchanged — existing single-arg callers are unaffected.
|
|
58
|
+
*
|
|
59
|
+
* `requestOptions` is the THIRD positional parameter (after `params`) so both existing call
|
|
60
|
+
* shapes stay unaffected. It carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
61
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
58
62
|
*/
|
|
59
63
|
create(opts: ScreenshotCreateRequest, params?: {
|
|
60
64
|
async?: boolean;
|
|
61
|
-
}): Promise<ScreenshotCreateResponse>;
|
|
65
|
+
}, requestOptions?: RequestOptions): Promise<ScreenshotCreateResponse>;
|
|
62
66
|
/**
|
|
63
67
|
* GET /v1/screenshots/{id} — poll a screenshot by ID.
|
|
64
68
|
*
|
|
65
69
|
* A terminal-`failed` screenshot returns the `Error` envelope on a 200
|
|
66
70
|
* (issue #2027), so narrow the result before reading `image_url`.
|
|
67
71
|
*/
|
|
68
|
-
get(id: ScreenshotId): Promise<ScreenshotGetResponse>;
|
|
72
|
+
get(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ScreenshotGetResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* POST /v1/screenshots, returning the header set alongside the body (#2547).
|
|
75
|
+
*
|
|
76
|
+
* Same request as `screenshots.create` — same method, path, body and
|
|
77
|
+
* `RequestOptions` precedence — and `data` is exactly what `create()` resolves to.
|
|
78
|
+
* `create()`'s own return type is UNCHANGED; this is an additive sibling.
|
|
79
|
+
*
|
|
80
|
+
* The spec documents the `X-Screenshot-*` family (`ID`, `Status`, `URL`,
|
|
81
|
+
* `Credits-Charged`, `Duration-Ms`, `Created-At`, `Completed-At`, `Expires-At`,
|
|
82
|
+
* `Status-Code`, `Cache`, `Cache-Age`) plus `X-Raw-Bytes` / `X-Billable-Bytes` /
|
|
83
|
+
* `X-Billing-Multiplier`; every one of them is on `headers`.
|
|
84
|
+
*/
|
|
85
|
+
createWithResponse(opts: ScreenshotCreateRequest, params?: {
|
|
86
|
+
async?: boolean;
|
|
87
|
+
}, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotCreateResponse>>;
|
|
88
|
+
/**
|
|
89
|
+
* GET /v1/screenshots/{id}, returning the header set alongside the body (#2547).
|
|
90
|
+
*
|
|
91
|
+
* Same request as `screenshots.get`, and `data` is exactly what `get()`
|
|
92
|
+
* resolves to (including the #2027 failed-envelope arm). `get()`'s own return type is
|
|
93
|
+
* UNCHANGED; this is an additive sibling. The documented `X-Screenshot-*`,
|
|
94
|
+
* `X-Raw-Bytes`, `X-Billable-Bytes` and `X-Billing-Multiplier` headers are on `headers`.
|
|
95
|
+
*/
|
|
96
|
+
getWithResponse(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotGetResponse>>;
|
|
69
97
|
}
|
|
70
98
|
export {};
|