@hunt-labs/bytekit-sdk 0.9.3 → 0.10.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 +96 -0
- package/README.md +26 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +61 -3
- package/dist/generated/api.d.ts +358 -69
- package/dist/index.d.ts +1 -1
- package/dist/resources/account.d.ts +2 -2
- package/dist/resources/account.js +2 -2
- package/dist/resources/bulk.d.ts +14 -2
- package/dist/resources/bulk.js +14 -3
- package/dist/resources/fetch.d.ts +5 -2
- package/dist/resources/fetch.js +16 -5
- package/dist/resources/monitors.d.ts +2 -2
- package/dist/resources/monitors.js +2 -2
- package/dist/resources/scrape.d.ts +43 -6
- package/dist/resources/scrape.js +30 -5
- package/dist/resources/screenshots.d.ts +12 -7
- package/dist/resources/screenshots.js +6 -6
- package/dist/resources/sitemap.d.ts +1 -1
- package/dist/resources/sitemap.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { ScreenshotCreateRequest, ScreenshotCreateResponse, ScreenshotGetRe
|
|
|
8
8
|
export type { FetchOpts, FetchGetOpts, FetchResult, FetchCacheStatus, FetchBulkCreateRequest, FetchBulkCreateResponse, FetchBulkGetResponse, } from './resources/fetch.js';
|
|
9
9
|
export type { MonitorCreateRequest, MonitorCreateResponse, ListMonitorsParams, MonitorStatus, ListMonitorsResponse, MonitorResponse, MonitorUpdateRequest, UpdateMonitorResponse, ListMonitorCapturesResponse, } from './resources/monitors.js';
|
|
10
10
|
export type { SitemapCreateRequest, SitemapCreateResponse, SitemapGetResponse, } from './resources/sitemap.js';
|
|
11
|
-
export type { BulkCreateRequest, BulkCreateResponse, BulkGetResponse, BulkCancelResponse, ListBulkScreenshotsResponse, } from './resources/bulk.js';
|
|
11
|
+
export type { BulkCreateRequest, BulkCreateResponse, BulkGetResponse, BulkCancelResponse, ListBulkScreenshotsResponse, BulkCompletedWebhook, } from './resources/bulk.js';
|
|
12
12
|
export type { GetAccountResponse, ListApiKeysResponse, CreateApiKeyRequest, CreateApiKeyResponse, GetApiKeyResponse, UpdateApiKeyRequest, UpdateApiKeyResponse, RevealApiKeyResponse, } from './resources/account.js';
|
|
13
13
|
export type { GetUsageResponse, GetUsageDailyParams, GetUsageDailyResponse, GetUsageByEndpointParams, GetUsageByEndpointResponse, } from './resources/usage.js';
|
|
14
14
|
export type { ListWebhookDeliveriesParams, ListWebhookDeliveriesResponse, RetryWebhookDeliveryResponse, } from './resources/webhooks.js';
|
|
@@ -69,8 +69,8 @@ declare class ApiKeysResource {
|
|
|
69
69
|
* from — hence `Promise<void>`.
|
|
70
70
|
*
|
|
71
71
|
* `client.request()` short-circuits an empty body (204 or any empty response)
|
|
72
|
-
* to `undefined` before it would parse the body as JSON
|
|
73
|
-
* method resolves cleanly on
|
|
72
|
+
* to `undefined` before it would parse the body as JSON, so this
|
|
73
|
+
* method resolves cleanly on an empty 204 body.
|
|
74
74
|
*/
|
|
75
75
|
revoke(id: ApiKeyId, requestOptions?: RequestOptions): Promise<void>;
|
|
76
76
|
/** POST /v1/account/api-keys/{id}/reveal — reveal the plaintext API key value */
|
|
@@ -50,8 +50,8 @@ class ApiKeysResource {
|
|
|
50
50
|
* from — hence `Promise<void>`.
|
|
51
51
|
*
|
|
52
52
|
* `client.request()` short-circuits an empty body (204 or any empty response)
|
|
53
|
-
* to `undefined` before it would parse the body as JSON
|
|
54
|
-
* method resolves cleanly on
|
|
53
|
+
* to `undefined` before it would parse the body as JSON, so this
|
|
54
|
+
* method resolves cleanly on an empty 204 body.
|
|
55
55
|
*/
|
|
56
56
|
revoke(id, requestOptions) {
|
|
57
57
|
return this.client.request('DELETE', buildPath('/v1/account/api-keys/{id}', { segments: { id } }), undefined, requestOptions);
|
package/dist/resources/bulk.d.ts
CHANGED
|
@@ -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 { BulkId } from '../types.js';
|
|
4
4
|
/** Body of POST /v1/bulk. */
|
|
5
5
|
export type BulkCreateRequest = operations['createBulk']['requestBody']['content']['application/json'];
|
|
@@ -11,6 +11,17 @@ export type BulkGetResponse = operations['getBulk']['responses'][200]['content']
|
|
|
11
11
|
export type BulkCancelResponse = operations['deleteBulk']['responses'][200]['content']['application/json'];
|
|
12
12
|
/** 200 payload of GET /v1/bulk/{id}/screenshots. */
|
|
13
13
|
export type ListBulkScreenshotsResponse = operations['listBulkScreenshots']['responses'][200]['content']['application/json'];
|
|
14
|
+
/**
|
|
15
|
+
* Body ByteKit POSTs to your webhook endpoint with `X-ByteKit-Event: bulk.completed`.
|
|
16
|
+
*
|
|
17
|
+
* #4340: indexed from `components` rather than `operations` because no operation
|
|
18
|
+
* `$ref`s this schema — it describes a request WE make to the customer's server,
|
|
19
|
+
* not a response they read from ours. It is still generated output: the alias
|
|
20
|
+
* below indexes `src/generated/api.d.ts`, so it cannot drift from the spec.
|
|
21
|
+
*/
|
|
22
|
+
export type BulkCompletedWebhook = components['schemas']['BulkCompletedWebhook'];
|
|
23
|
+
/** Cursor, page-size, and item-status filters for mixed bulk recovery. */
|
|
24
|
+
export type BulkPageParams = NonNullable<operations['listBulkScreenshots']['parameters']['query']>;
|
|
14
25
|
export declare class BulkResource {
|
|
15
26
|
private readonly client;
|
|
16
27
|
readonly screenshots: BulkScreenshotsResource;
|
|
@@ -30,7 +41,8 @@ export declare class BulkResource {
|
|
|
30
41
|
declare class BulkScreenshotsResource {
|
|
31
42
|
private readonly client;
|
|
32
43
|
constructor(client: ByteKit);
|
|
33
|
-
/** GET /v1/bulk/{id}/screenshots — list
|
|
44
|
+
/** GET /v1/bulk/{id}/screenshots — list items in a mixed bulk job */
|
|
34
45
|
list(id: BulkId, requestOptions?: RequestOptions): Promise<ListBulkScreenshotsResponse>;
|
|
46
|
+
list(id: BulkId, pageParams: BulkPageParams, requestOptions?: RequestOptions): Promise<ListBulkScreenshotsResponse>;
|
|
35
47
|
}
|
|
36
48
|
export {};
|
package/dist/resources/bulk.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildPath } from '../client.js';
|
|
2
|
+
import { toQueryString } from './query-string.js';
|
|
2
3
|
export class BulkResource {
|
|
3
4
|
client;
|
|
4
5
|
screenshots;
|
|
@@ -29,8 +30,18 @@ class BulkScreenshotsResource {
|
|
|
29
30
|
constructor(client) {
|
|
30
31
|
this.client = client;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
list(id, pageParamsOrRequestOptions = {}, requestOptions) {
|
|
34
|
+
const hasPageParams = requestOptions !== undefined ||
|
|
35
|
+
'cursor' in pageParamsOrRequestOptions ||
|
|
36
|
+
'limit' in pageParamsOrRequestOptions ||
|
|
37
|
+
'status' in pageParamsOrRequestOptions;
|
|
38
|
+
const pageParams = hasPageParams ? pageParamsOrRequestOptions : {};
|
|
39
|
+
const resolvedRequestOptions = hasPageParams
|
|
40
|
+
? requestOptions
|
|
41
|
+
: pageParamsOrRequestOptions;
|
|
42
|
+
return this.client.request('GET', buildPath('/v1/bulk/{id}/screenshots', {
|
|
43
|
+
segments: { id },
|
|
44
|
+
query: toQueryString(pageParams),
|
|
45
|
+
}), undefined, resolvedRequestOptions);
|
|
35
46
|
}
|
|
36
47
|
}
|
|
@@ -7,6 +7,8 @@ export type FetchBulkCreateRequest = operations['createFetchBulk']['requestBody'
|
|
|
7
7
|
export type FetchBulkCreateResponse = operations['createFetchBulk']['responses'][202]['content']['application/json'];
|
|
8
8
|
/** 200 payload of GET /v1/fetch/bulk/{id}. */
|
|
9
9
|
export type FetchBulkGetResponse = operations['getFetchBulk']['responses'][200]['content']['application/json'];
|
|
10
|
+
/** Cursor, page-size, and item-status filters for fetch-bulk recovery. */
|
|
11
|
+
export type FetchBulkPageParams = NonNullable<operations['getFetchBulk']['parameters']['query']>;
|
|
10
12
|
/**
|
|
11
13
|
* Options for fetch endpoints.
|
|
12
14
|
*
|
|
@@ -108,7 +110,7 @@ export declare class FetchResource {
|
|
|
108
110
|
* raw JSON string, not a parsed object.
|
|
109
111
|
*
|
|
110
112
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
111
|
-
* optional caller `signal`. It matters most here:
|
|
113
|
+
* optional caller `signal`. It matters most here: ByteKit's own ceiling for a
|
|
112
114
|
* fetch is 60 s, so without a per-call budget a slow upstream holds the caller for
|
|
113
115
|
* the constructor default (2 minutes) rather than a duration the caller chose.
|
|
114
116
|
*/
|
|
@@ -126,7 +128,7 @@ export declare class FetchResource {
|
|
|
126
128
|
* serialized.
|
|
127
129
|
*
|
|
128
130
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
129
|
-
* optional caller `signal`. As on `create`,
|
|
131
|
+
* optional caller `signal`. As on `create`, ByteKit's own ceiling for a fetch is
|
|
130
132
|
* 60 s, so a per-call budget is what keeps a slow upstream from holding the caller
|
|
131
133
|
* for the constructor default.
|
|
132
134
|
*/
|
|
@@ -139,5 +141,6 @@ declare class FetchBulkResource {
|
|
|
139
141
|
create(opts: FetchBulkCreateRequest, requestOptions?: RequestOptions): Promise<FetchBulkCreateResponse>;
|
|
140
142
|
/** GET /v1/fetch/bulk/{id} — get a bulk fetch job */
|
|
141
143
|
get(id: BulkId, requestOptions?: RequestOptions): Promise<FetchBulkGetResponse>;
|
|
144
|
+
get(id: BulkId, pageParams: FetchBulkPageParams, requestOptions?: RequestOptions): Promise<FetchBulkGetResponse>;
|
|
142
145
|
}
|
|
143
146
|
export {};
|
package/dist/resources/fetch.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildPath } from '../client.js';
|
|
2
|
+
import { toQueryString } from './query-string.js';
|
|
2
3
|
/**
|
|
3
4
|
* The query params `GET /v1/fetch` accepts, in serialization order.
|
|
4
5
|
*
|
|
@@ -48,7 +49,7 @@ export class FetchResource {
|
|
|
48
49
|
* raw JSON string, not a parsed object.
|
|
49
50
|
*
|
|
50
51
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
51
|
-
* optional caller `signal`. It matters most here:
|
|
52
|
+
* optional caller `signal`. It matters most here: ByteKit's own ceiling for a
|
|
52
53
|
* fetch is 60 s, so without a per-call budget a slow upstream holds the caller for
|
|
53
54
|
* the constructor default (2 minutes) rather than a duration the caller chose.
|
|
54
55
|
*/
|
|
@@ -68,7 +69,7 @@ export class FetchResource {
|
|
|
68
69
|
* serialized.
|
|
69
70
|
*
|
|
70
71
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
71
|
-
* optional caller `signal`. As on `create`,
|
|
72
|
+
* optional caller `signal`. As on `create`, ByteKit's own ceiling for a fetch is
|
|
72
73
|
* 60 s, so a per-call budget is what keeps a slow upstream from holding the caller
|
|
73
74
|
* for the constructor default.
|
|
74
75
|
*/
|
|
@@ -91,8 +92,18 @@ class FetchBulkResource {
|
|
|
91
92
|
create(opts, requestOptions) {
|
|
92
93
|
return this.client.request('POST', '/v1/fetch/bulk', opts, requestOptions);
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
get(id, pageParamsOrRequestOptions = {}, requestOptions) {
|
|
96
|
+
const hasPageParams = requestOptions !== undefined ||
|
|
97
|
+
'cursor' in pageParamsOrRequestOptions ||
|
|
98
|
+
'limit' in pageParamsOrRequestOptions ||
|
|
99
|
+
'status' in pageParamsOrRequestOptions;
|
|
100
|
+
const pageParams = hasPageParams ? pageParamsOrRequestOptions : {};
|
|
101
|
+
const resolvedRequestOptions = hasPageParams
|
|
102
|
+
? requestOptions
|
|
103
|
+
: pageParamsOrRequestOptions;
|
|
104
|
+
return this.client.request('GET', buildPath('/v1/fetch/bulk/{id}', {
|
|
105
|
+
segments: { id },
|
|
106
|
+
query: toQueryString(pageParams),
|
|
107
|
+
}), undefined, resolvedRequestOptions);
|
|
97
108
|
}
|
|
98
109
|
}
|
|
@@ -85,7 +85,7 @@ export declare class MonitorsResource {
|
|
|
85
85
|
* Returns 204 No Content (`operations['deleteMonitor']['responses'][204]`
|
|
86
86
|
* declares `content?: never`), so there is no JSON arm to derive a payload
|
|
87
87
|
* from — hence `Promise<void>`. `client.request()` short-circuits the empty
|
|
88
|
-
* body to `undefined` before it would parse as JSON
|
|
88
|
+
* body to `undefined` before it would parse as JSON.
|
|
89
89
|
*/
|
|
90
90
|
delete(id: MonitorId, requestOptions?: RequestOptions): Promise<void>;
|
|
91
91
|
}
|
|
@@ -95,7 +95,7 @@ declare class MonitorCapturesResource {
|
|
|
95
95
|
/**
|
|
96
96
|
* GET /v1/monitors/{id}/captures — list captures for a monitor.
|
|
97
97
|
*
|
|
98
|
-
* `params` is optional and each key is omitted-when-absent
|
|
98
|
+
* `params` is optional and each key is omitted-when-absent, so `list(id)` with no
|
|
99
99
|
* second argument serializes the bare `/v1/monitors/{id}/captures` URL unchanged — existing
|
|
100
100
|
* zero-arg callers are unaffected (inverse case).
|
|
101
101
|
*/
|
|
@@ -37,7 +37,7 @@ export class MonitorsResource {
|
|
|
37
37
|
* Returns 204 No Content (`operations['deleteMonitor']['responses'][204]`
|
|
38
38
|
* declares `content?: never`), so there is no JSON arm to derive a payload
|
|
39
39
|
* from — hence `Promise<void>`. `client.request()` short-circuits the empty
|
|
40
|
-
* body to `undefined` before it would parse as JSON
|
|
40
|
+
* body to `undefined` before it would parse as JSON.
|
|
41
41
|
*/
|
|
42
42
|
delete(id, requestOptions) {
|
|
43
43
|
return this.client.request('DELETE', buildPath('/v1/monitors/{id}', { segments: { id } }), undefined, requestOptions);
|
|
@@ -51,7 +51,7 @@ class MonitorCapturesResource {
|
|
|
51
51
|
/**
|
|
52
52
|
* GET /v1/monitors/{id}/captures — list captures for a monitor.
|
|
53
53
|
*
|
|
54
|
-
* `params` is optional and each key is omitted-when-absent
|
|
54
|
+
* `params` is optional and each key is omitted-when-absent, so `list(id)` with no
|
|
55
55
|
* second argument serializes the bare `/v1/monitors/{id}/captures` URL unchanged — existing
|
|
56
56
|
* zero-arg callers are unaffected (inverse case).
|
|
57
57
|
*/
|
|
@@ -2,9 +2,29 @@ import type { ByteKit, RequestOptions } from '../client.js';
|
|
|
2
2
|
import type { operations } from '../generated/api.js';
|
|
3
3
|
import type { ScrapeId, BulkId } from '../types.js';
|
|
4
4
|
/**
|
|
5
|
-
* Response of POST /v1/scrape — a 200
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Response of POST /v1/scrape — the WIRE union: a 200 terminal envelope or a 202
|
|
6
|
+
* queued receipt.
|
|
7
|
+
*
|
|
8
|
+
* What `scrape.create` RESOLVES to is narrower than this type: the `failed` member
|
|
9
|
+
* is delivered as a thrown `ByteKitError`, not as a value (#1870), so a resolved
|
|
10
|
+
* response is `success` or `queued`. The union stays honest about what the server
|
|
11
|
+
* sends — `requestRaw` and any hand-rolled transport still see the failure body.
|
|
12
|
+
*
|
|
13
|
+
* The shape follows from the request, in this order:
|
|
14
|
+
*
|
|
15
|
+
* 1. `async: true` → 202 receipt, immediately. Poll `scrape.get(id)`.
|
|
16
|
+
* 2. Otherwise a request that needs a full page render — today that is
|
|
17
|
+
* `delay_ms > 0` — is held open until the render reaches a terminal state
|
|
18
|
+
* and returns 200 with that state: the content envelope on success, or the
|
|
19
|
+
* `failed` error envelope when the render itself failed. If the render is
|
|
20
|
+
* still running when the server's hold window expires (28 s by default), it
|
|
21
|
+
* returns the 202 receipt instead and the job continues in the background —
|
|
22
|
+
* so a receipt can arrive without your ever asking for one.
|
|
23
|
+
* 3. Otherwise the fast HTTP path returns the 200 content envelope, typically
|
|
24
|
+
* in under a second. A fetch that fails outright is a `failed` envelope on
|
|
25
|
+
* that same 200, with `id: null`, because it ends before any job exists.
|
|
26
|
+
*
|
|
27
|
+
* So a 202 is never a surprise: you either asked for it, or the hold expired.
|
|
8
28
|
*/
|
|
9
29
|
export type ScrapeCreateResponse = operations['createScrape']['responses'][200]['content']['application/json'] | operations['createScrape']['responses'][202]['content']['application/json'];
|
|
10
30
|
/**
|
|
@@ -18,6 +38,8 @@ export type ScrapeBulkCreateRequest = operations['createScrapeBulk']['requestBod
|
|
|
18
38
|
export type ScrapeBulkCreateResponse = operations['createScrapeBulk']['responses'][202]['content']['application/json'];
|
|
19
39
|
/** Response of GET /v1/scrape/bulk/{id}. */
|
|
20
40
|
export type ScrapeBulkGetResponse = operations['getScrapeBulk']['responses'][200]['content']['application/json'];
|
|
41
|
+
/** Cursor, page-size, and item-status filters for scrape-bulk recovery. */
|
|
42
|
+
export type ScrapeBulkPageParams = NonNullable<operations['getScrapeBulk']['parameters']['query']>;
|
|
21
43
|
/** Markdown processing mode for the pipeline. */
|
|
22
44
|
export type MarkdownMode = 'article' | 'raw' | 'llm';
|
|
23
45
|
/** Link rendering style in the markdown output. */
|
|
@@ -32,7 +54,7 @@ export interface ScrapeOpts {
|
|
|
32
54
|
formats?: Array<'raw' | 'markdown' | 'links' | 'images'>;
|
|
33
55
|
country?: string;
|
|
34
56
|
delay_ms?: number;
|
|
35
|
-
/** SERVER-side scrape budget in ms — how long the
|
|
57
|
+
/** SERVER-side scrape budget in ms — how long the server may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`. */
|
|
36
58
|
timeout_ms?: number;
|
|
37
59
|
async?: boolean;
|
|
38
60
|
webhook_url?: string;
|
|
@@ -96,8 +118,22 @@ export declare class ScrapeResource {
|
|
|
96
118
|
/**
|
|
97
119
|
* POST /v1/scrape — create a scrape job.
|
|
98
120
|
*
|
|
99
|
-
* Resolves to the 200 success envelope
|
|
100
|
-
*
|
|
121
|
+
* Resolves to the 200 `success` content envelope or the 202 queued receipt;
|
|
122
|
+
* narrow on `status` to tell them apart. A TERMINAL FAILURE THROWS: the server
|
|
123
|
+
* delivers it as a `failed` envelope on HTTP 200 (a definitive upstream outcome
|
|
124
|
+
* is a result, not a transport error), and this method converts it into the
|
|
125
|
+
* `ByteKitError` you already catch — `err.code`, `err.message`, and `err.status`
|
|
126
|
+
* 200. `scrape.get(id)` is unchanged and still returns `failed` as data.
|
|
127
|
+
*
|
|
128
|
+
* See {@link ScrapeCreateResponse} for the full precedence: `async: true` receipts
|
|
129
|
+
* immediately, a browser-path request without it is held open until the render
|
|
130
|
+
* reaches a terminal state (200) or the server's hold window expires (202 — a
|
|
131
|
+
* receipt you did not ask for), and everything else takes the fast path (200).
|
|
132
|
+
*
|
|
133
|
+
* A held request therefore occupies the connection for as long as the render
|
|
134
|
+
* takes, up to the server's hold window (28 s by default) — well inside this
|
|
135
|
+
* SDK's 120 s default `timeoutMs`, but worth raising `requestTimeoutMs` if you
|
|
136
|
+
* lowered it.
|
|
101
137
|
*
|
|
102
138
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
103
139
|
* optional caller `signal`; both override the constructor's `timeoutMs` default. They
|
|
@@ -121,5 +157,6 @@ declare class ScrapeBulkResource {
|
|
|
121
157
|
create(opts: ScrapeBulkCreateRequest, requestOptions?: RequestOptions): Promise<ScrapeBulkCreateResponse>;
|
|
122
158
|
/** GET /v1/scrape/bulk/{id} — get a bulk scrape job */
|
|
123
159
|
get(id: BulkId, requestOptions?: RequestOptions): Promise<ScrapeBulkGetResponse>;
|
|
160
|
+
get(id: BulkId, pageParams: ScrapeBulkPageParams, requestOptions?: RequestOptions): Promise<ScrapeBulkGetResponse>;
|
|
124
161
|
}
|
|
125
162
|
export {};
|
package/dist/resources/scrape.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildPath } from '../client.js';
|
|
2
|
+
import { toQueryString } from './query-string.js';
|
|
2
3
|
export class ScrapeResource {
|
|
3
4
|
client;
|
|
4
5
|
bulk;
|
|
@@ -9,8 +10,22 @@ export class ScrapeResource {
|
|
|
9
10
|
/**
|
|
10
11
|
* POST /v1/scrape — create a scrape job.
|
|
11
12
|
*
|
|
12
|
-
* Resolves to the 200 success envelope
|
|
13
|
-
*
|
|
13
|
+
* Resolves to the 200 `success` content envelope or the 202 queued receipt;
|
|
14
|
+
* narrow on `status` to tell them apart. A TERMINAL FAILURE THROWS: the server
|
|
15
|
+
* delivers it as a `failed` envelope on HTTP 200 (a definitive upstream outcome
|
|
16
|
+
* is a result, not a transport error), and this method converts it into the
|
|
17
|
+
* `ByteKitError` you already catch — `err.code`, `err.message`, and `err.status`
|
|
18
|
+
* 200. `scrape.get(id)` is unchanged and still returns `failed` as data.
|
|
19
|
+
*
|
|
20
|
+
* See {@link ScrapeCreateResponse} for the full precedence: `async: true` receipts
|
|
21
|
+
* immediately, a browser-path request without it is held open until the render
|
|
22
|
+
* reaches a terminal state (200) or the server's hold window expires (202 — a
|
|
23
|
+
* receipt you did not ask for), and everything else takes the fast path (200).
|
|
24
|
+
*
|
|
25
|
+
* A held request therefore occupies the connection for as long as the render
|
|
26
|
+
* takes, up to the server's hold window (28 s by default) — well inside this
|
|
27
|
+
* SDK's 120 s default `timeoutMs`, but worth raising `requestTimeoutMs` if you
|
|
28
|
+
* lowered it.
|
|
14
29
|
*
|
|
15
30
|
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
16
31
|
* optional caller `signal`; both override the constructor's `timeoutMs` default. They
|
|
@@ -40,8 +55,18 @@ class ScrapeBulkResource {
|
|
|
40
55
|
create(opts, requestOptions) {
|
|
41
56
|
return this.client.request('POST', '/v1/scrape/bulk', opts, requestOptions);
|
|
42
57
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
get(id, pageParamsOrRequestOptions = {}, requestOptions) {
|
|
59
|
+
const hasPageParams = requestOptions !== undefined ||
|
|
60
|
+
'cursor' in pageParamsOrRequestOptions ||
|
|
61
|
+
'limit' in pageParamsOrRequestOptions ||
|
|
62
|
+
'status' in pageParamsOrRequestOptions;
|
|
63
|
+
const pageParams = hasPageParams ? pageParamsOrRequestOptions : {};
|
|
64
|
+
const resolvedRequestOptions = hasPageParams
|
|
65
|
+
? requestOptions
|
|
66
|
+
: pageParamsOrRequestOptions;
|
|
67
|
+
return this.client.request('GET', buildPath('/v1/scrape/bulk/{id}', {
|
|
68
|
+
segments: { id },
|
|
69
|
+
query: toQueryString(pageParams),
|
|
70
|
+
}), undefined, resolvedRequestOptions);
|
|
46
71
|
}
|
|
47
72
|
}
|
|
@@ -30,7 +30,12 @@ type ScreenshotRequestSpec = operations['createScreenshot']['requestBody']['cont
|
|
|
30
30
|
export type ScreenshotCreateRequest = Partial<ScreenshotRequestSpec> & Pick<ScreenshotRequestSpec, 'url'>;
|
|
31
31
|
/**
|
|
32
32
|
* Response of POST /v1/screenshots — 200 (captured synchronously) or 202
|
|
33
|
-
* (
|
|
33
|
+
* (pending). A 202 has TWO causes, not one: the caller passed `async: true`, so
|
|
34
|
+
* the capture was queued immediately; or the request ran synchronously and the
|
|
35
|
+
* gateway's bounded sync hold expired before the capture finished — that hold is
|
|
36
|
+
* sourced from `SYNC_HOLD_TIMEOUT_MS` (default 28s), so it is a configured bound
|
|
37
|
+
* rather than a fixed guarantee. A plain `create(opts)` call therefore reaches
|
|
38
|
+
* the pending arm too. Both status codes carry the *same* `ScreenshotResponse`
|
|
34
39
|
* schema in the spec, so the type is a single derivation rather than a `200 | 202`
|
|
35
40
|
* union (an identical-constituent union trips `no-duplicate-type-constituents`).
|
|
36
41
|
* Narrow on `status` to tell a completed capture from a pending one.
|
|
@@ -66,12 +71,12 @@ export declare class ScreenshotsResource {
|
|
|
66
71
|
/**
|
|
67
72
|
* GET /v1/screenshots/{id} — poll a screenshot by ID.
|
|
68
73
|
*
|
|
69
|
-
* A terminal-`failed` screenshot returns the `Error` envelope on a 200
|
|
70
|
-
*
|
|
74
|
+
* A terminal-`failed` screenshot returns the `Error` envelope on a 200,
|
|
75
|
+
* so narrow the result before reading `image_url`.
|
|
71
76
|
*/
|
|
72
77
|
get(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ScreenshotGetResponse>;
|
|
73
78
|
/**
|
|
74
|
-
* POST /v1/screenshots, returning the header set alongside the body
|
|
79
|
+
* POST /v1/screenshots, returning the header set alongside the body.
|
|
75
80
|
*
|
|
76
81
|
* Same request as `screenshots.create` — same method, path, body and
|
|
77
82
|
* `RequestOptions` precedence — and `data` is exactly what `create()` resolves to.
|
|
@@ -86,10 +91,10 @@ export declare class ScreenshotsResource {
|
|
|
86
91
|
async?: boolean;
|
|
87
92
|
}, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotCreateResponse>>;
|
|
88
93
|
/**
|
|
89
|
-
* GET /v1/screenshots/{id}, returning the header set alongside the body
|
|
94
|
+
* GET /v1/screenshots/{id}, returning the header set alongside the body.
|
|
90
95
|
*
|
|
91
96
|
* Same request as `screenshots.get`, and `data` is exactly what `get()`
|
|
92
|
-
* resolves to (including the
|
|
97
|
+
* resolves to (including the failed-envelope arm). `get()`'s own return type is
|
|
93
98
|
* UNCHANGED; this is an additive sibling.
|
|
94
99
|
*
|
|
95
100
|
* Call it for the typed body, NOT for header metadata: the spec declares
|
|
@@ -97,7 +102,7 @@ export declare class ScreenshotsResource {
|
|
|
97
102
|
* none, so `headers` carries only the transport's own entries (`Content-Type`, …).
|
|
98
103
|
* The `X-Screenshot-*` / `X-Raw-Bytes` / `X-Billable-Bytes` / `X-Billing-Multiplier`
|
|
99
104
|
* family is emitted by `POST /v1/screenshots` — use `screenshots.createWithResponse`
|
|
100
|
-
* to read it
|
|
105
|
+
* to read it. This matches `ByteKit.requestWithResponse` and the README,
|
|
101
106
|
* which are the truth for what this endpoint emits.
|
|
102
107
|
*/
|
|
103
108
|
getWithResponse(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotGetResponse>>;
|
|
@@ -23,14 +23,14 @@ export class ScreenshotsResource {
|
|
|
23
23
|
/**
|
|
24
24
|
* GET /v1/screenshots/{id} — poll a screenshot by ID.
|
|
25
25
|
*
|
|
26
|
-
* A terminal-`failed` screenshot returns the `Error` envelope on a 200
|
|
27
|
-
*
|
|
26
|
+
* A terminal-`failed` screenshot returns the `Error` envelope on a 200,
|
|
27
|
+
* so narrow the result before reading `image_url`.
|
|
28
28
|
*/
|
|
29
29
|
get(id, requestOptions) {
|
|
30
30
|
return this.client.request('GET', buildPath('/v1/screenshots/{id}', { segments: { id } }), undefined, requestOptions);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* POST /v1/screenshots, returning the header set alongside the body
|
|
33
|
+
* POST /v1/screenshots, returning the header set alongside the body.
|
|
34
34
|
*
|
|
35
35
|
* Same request as `screenshots.create` — same method, path, body and
|
|
36
36
|
* `RequestOptions` precedence — and `data` is exactly what `create()` resolves to.
|
|
@@ -46,10 +46,10 @@ export class ScreenshotsResource {
|
|
|
46
46
|
return this.client.requestWithResponse('POST', buildPath('/v1/screenshots', { query: suffix }), opts, requestOptions);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* GET /v1/screenshots/{id}, returning the header set alongside the body
|
|
49
|
+
* GET /v1/screenshots/{id}, returning the header set alongside the body.
|
|
50
50
|
*
|
|
51
51
|
* Same request as `screenshots.get`, and `data` is exactly what `get()`
|
|
52
|
-
* resolves to (including the
|
|
52
|
+
* resolves to (including the failed-envelope arm). `get()`'s own return type is
|
|
53
53
|
* UNCHANGED; this is an additive sibling.
|
|
54
54
|
*
|
|
55
55
|
* Call it for the typed body, NOT for header metadata: the spec declares
|
|
@@ -57,7 +57,7 @@ export class ScreenshotsResource {
|
|
|
57
57
|
* none, so `headers` carries only the transport's own entries (`Content-Type`, …).
|
|
58
58
|
* The `X-Screenshot-*` / `X-Raw-Bytes` / `X-Billable-Bytes` / `X-Billing-Multiplier`
|
|
59
59
|
* family is emitted by `POST /v1/screenshots` — use `screenshots.createWithResponse`
|
|
60
|
-
* to read it
|
|
60
|
+
* to read it. This matches `ByteKit.requestWithResponse` and the README,
|
|
61
61
|
* which are the truth for what this endpoint emits.
|
|
62
62
|
*/
|
|
63
63
|
// NOTE (#2957): the doc block above deliberately spells sibling method names in plain
|
|
@@ -32,7 +32,7 @@ export declare class SitemapResource {
|
|
|
32
32
|
/** GET /v1/sitemap/{id} — get a sitemap job by ID */
|
|
33
33
|
get(id: SitemapId, requestOptions?: RequestOptions): Promise<SitemapGetResponse>;
|
|
34
34
|
/**
|
|
35
|
-
* GET /v1/sitemap/{id}, returning the header set alongside the body
|
|
35
|
+
* GET /v1/sitemap/{id}, returning the header set alongside the body.
|
|
36
36
|
*
|
|
37
37
|
* Same request as `sitemap.get` — same method, path and `RequestOptions`
|
|
38
38
|
* precedence — and `data` is exactly what `get()` resolves to. `get()`'s own return type
|
|
@@ -18,7 +18,7 @@ export class SitemapResource {
|
|
|
18
18
|
return this.client.request('GET', buildPath('/v1/sitemap/{id}', { segments: { id } }), undefined, requestOptions);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* GET /v1/sitemap/{id}, returning the header set alongside the body
|
|
21
|
+
* GET /v1/sitemap/{id}, returning the header set alongside the body.
|
|
22
22
|
*
|
|
23
23
|
* Same request as `sitemap.get` — same method, path and `RequestOptions`
|
|
24
24
|
* precedence — and `data` is exactly what `get()` resolves to. `get()`'s own return type
|
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.
|
|
8
|
+
export declare const SDK_VERSION = "0.10.0";
|
package/dist/version.js
CHANGED