@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
|
@@ -10,10 +10,14 @@ export class ScreenshotsResource {
|
|
|
10
10
|
* param on `createScreenshot`, distinct from scrape where `async` is a body field. `params` is
|
|
11
11
|
* optional and `async` omitted-when-absent: `create(opts)` with no second argument posts to the
|
|
12
12
|
* bare `/v1/screenshots` URL unchanged — existing single-arg callers are unaffected.
|
|
13
|
+
*
|
|
14
|
+
* `requestOptions` is the THIRD positional parameter (after `params`) so both existing call
|
|
15
|
+
* shapes stay unaffected. It carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
16
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
13
17
|
*/
|
|
14
|
-
create(opts, params) {
|
|
18
|
+
create(opts, params, requestOptions) {
|
|
15
19
|
const suffix = params?.async === true ? '?async=true' : '';
|
|
16
|
-
return this.client.request('POST', `/v1/screenshots${suffix}`, opts);
|
|
20
|
+
return this.client.request('POST', `/v1/screenshots${suffix}`, opts, requestOptions);
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* GET /v1/screenshots/{id} — poll a screenshot by ID.
|
|
@@ -21,7 +25,34 @@ export class ScreenshotsResource {
|
|
|
21
25
|
* A terminal-`failed` screenshot returns the `Error` envelope on a 200
|
|
22
26
|
* (issue #2027), so narrow the result before reading `image_url`.
|
|
23
27
|
*/
|
|
24
|
-
get(id) {
|
|
25
|
-
return this.client.request('GET', `/v1/screenshots/${id}
|
|
28
|
+
get(id, requestOptions) {
|
|
29
|
+
return this.client.request('GET', `/v1/screenshots/${id}`, undefined, requestOptions);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* POST /v1/screenshots, returning the header set alongside the body (#2547).
|
|
33
|
+
*
|
|
34
|
+
* Same request as `screenshots.create` — same method, path, body and
|
|
35
|
+
* `RequestOptions` precedence — and `data` is exactly what `create()` resolves to.
|
|
36
|
+
* `create()`'s own return type is UNCHANGED; this is an additive sibling.
|
|
37
|
+
*
|
|
38
|
+
* The spec documents the `X-Screenshot-*` family (`ID`, `Status`, `URL`,
|
|
39
|
+
* `Credits-Charged`, `Duration-Ms`, `Created-At`, `Completed-At`, `Expires-At`,
|
|
40
|
+
* `Status-Code`, `Cache`, `Cache-Age`) plus `X-Raw-Bytes` / `X-Billable-Bytes` /
|
|
41
|
+
* `X-Billing-Multiplier`; every one of them is on `headers`.
|
|
42
|
+
*/
|
|
43
|
+
createWithResponse(opts, params, requestOptions) {
|
|
44
|
+
const suffix = params?.async === true ? '?async=true' : '';
|
|
45
|
+
return this.client.requestWithResponse('POST', `/v1/screenshots${suffix}`, opts, requestOptions);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* GET /v1/screenshots/{id}, returning the header set alongside the body (#2547).
|
|
49
|
+
*
|
|
50
|
+
* Same request as `screenshots.get`, and `data` is exactly what `get()`
|
|
51
|
+
* resolves to (including the #2027 failed-envelope arm). `get()`'s own return type is
|
|
52
|
+
* UNCHANGED; this is an additive sibling. The documented `X-Screenshot-*`,
|
|
53
|
+
* `X-Raw-Bytes`, `X-Billable-Bytes` and `X-Billing-Multiplier` headers are on `headers`.
|
|
54
|
+
*/
|
|
55
|
+
getWithResponse(id, requestOptions) {
|
|
56
|
+
return this.client.requestWithResponse('GET', `/v1/screenshots/${id}`, undefined, requestOptions);
|
|
26
57
|
}
|
|
27
58
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { ByteKit } from '../client.js';
|
|
1
|
+
import type { ByteKit, RequestOptions } from '../client.js';
|
|
2
2
|
import type { SearchOpts, SearchResponse } from '../types.js';
|
|
3
3
|
export declare class SearchResource {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor(client: ByteKit);
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* POST /v1/search — run a web search and return ranked organic results.
|
|
8
|
+
*
|
|
9
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
10
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
11
|
+
*/
|
|
12
|
+
query(opts: SearchOpts, requestOptions?: RequestOptions): Promise<SearchResponse>;
|
|
8
13
|
}
|
package/dist/resources/search.js
CHANGED
|
@@ -3,8 +3,13 @@ export class SearchResource {
|
|
|
3
3
|
constructor(client) {
|
|
4
4
|
this.client = client;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* POST /v1/search — run a web search and return ranked organic results.
|
|
8
|
+
*
|
|
9
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
10
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
11
|
+
*/
|
|
12
|
+
query(opts, requestOptions) {
|
|
13
|
+
return this.client.request('POST', '/v1/search', opts, requestOptions);
|
|
9
14
|
}
|
|
10
15
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
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 { SitemapId } from '../types.js';
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** The `createSitemap` request body exactly as the OpenAPI spec declares it. */
|
|
5
|
+
type SitemapRequestSpec = operations['createSitemap']['requestBody']['content']['application/json'];
|
|
6
|
+
/**
|
|
7
|
+
* Body of POST /v1/sitemap — `url` is required, every other field optional.
|
|
8
|
+
*
|
|
9
|
+
* Same `defaultNonNullable` drift documented on `ScreenshotCreateRequest`
|
|
10
|
+
* (screenshots.ts:12-31, follow-up #2540): the spec says `required: [url]`
|
|
11
|
+
* (openapi.yaml `SitemapRequest`) but 7 sibling fields carry `default:`, which
|
|
12
|
+
* `openapi-typescript` v7's `defaultNonNullable` transform promotes to
|
|
13
|
+
* non-optional in the generated type. Relaxed here so the spec-minimal
|
|
14
|
+
* `create({ url })` compiles — still DERIVED from the operation type, never
|
|
15
|
+
* hand-authored.
|
|
16
|
+
*/
|
|
17
|
+
export type SitemapCreateRequest = Partial<SitemapRequestSpec> & Pick<SitemapRequestSpec, 'url'>;
|
|
6
18
|
/** 202 payload of POST /v1/sitemap — sitemap crawls are always async. */
|
|
7
19
|
export type SitemapCreateResponse = operations['createSitemap']['responses'][202]['content']['application/json'];
|
|
8
20
|
/** 200 payload of GET /v1/sitemap/{id}. */
|
|
@@ -10,8 +22,25 @@ export type SitemapGetResponse = operations['getSitemap']['responses'][200]['con
|
|
|
10
22
|
export declare class SitemapResource {
|
|
11
23
|
private readonly client;
|
|
12
24
|
constructor(client: ByteKit);
|
|
13
|
-
/**
|
|
14
|
-
|
|
25
|
+
/**
|
|
26
|
+
* POST /v1/sitemap — start a sitemap crawl.
|
|
27
|
+
*
|
|
28
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
29
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
30
|
+
*/
|
|
31
|
+
create(opts: SitemapCreateRequest, requestOptions?: RequestOptions): Promise<SitemapCreateResponse>;
|
|
15
32
|
/** GET /v1/sitemap/{id} — get a sitemap job by ID */
|
|
16
|
-
get(id: SitemapId): Promise<SitemapGetResponse>;
|
|
33
|
+
get(id: SitemapId, requestOptions?: RequestOptions): Promise<SitemapGetResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* GET /v1/sitemap/{id}, returning the header set alongside the body (#2547).
|
|
36
|
+
*
|
|
37
|
+
* Same request as `sitemap.get` — same method, path and `RequestOptions`
|
|
38
|
+
* precedence — and `data` is exactly what `get()` resolves to. `get()`'s own return type
|
|
39
|
+
* is UNCHANGED; this is an additive sibling, not a replacement.
|
|
40
|
+
*
|
|
41
|
+
* The spec documents `X-Sitemap-ID`, `X-Raw-Bytes`, `X-Billing-Multiplier` and
|
|
42
|
+
* `X-Billable-Bytes` on this endpoint's 200; every one of them is on `headers`.
|
|
43
|
+
*/
|
|
44
|
+
getWithResponse(id: SitemapId, requestOptions?: RequestOptions): Promise<ApiResponse<SitemapGetResponse>>;
|
|
17
45
|
}
|
|
46
|
+
export {};
|
|
@@ -3,12 +3,30 @@ export class SitemapResource {
|
|
|
3
3
|
constructor(client) {
|
|
4
4
|
this.client = client;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* POST /v1/sitemap — start a sitemap crawl.
|
|
8
|
+
*
|
|
9
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
10
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
11
|
+
*/
|
|
12
|
+
create(opts, requestOptions) {
|
|
13
|
+
return this.client.request('POST', '/v1/sitemap', opts, requestOptions);
|
|
9
14
|
}
|
|
10
15
|
/** GET /v1/sitemap/{id} — get a sitemap job by ID */
|
|
11
|
-
get(id) {
|
|
12
|
-
return this.client.request('GET', `/v1/sitemap/${id}
|
|
16
|
+
get(id, requestOptions) {
|
|
17
|
+
return this.client.request('GET', `/v1/sitemap/${id}`, undefined, requestOptions);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* GET /v1/sitemap/{id}, returning the header set alongside the body (#2547).
|
|
21
|
+
*
|
|
22
|
+
* Same request as `sitemap.get` — same method, path and `RequestOptions`
|
|
23
|
+
* precedence — and `data` is exactly what `get()` resolves to. `get()`'s own return type
|
|
24
|
+
* is UNCHANGED; this is an additive sibling, not a replacement.
|
|
25
|
+
*
|
|
26
|
+
* The spec documents `X-Sitemap-ID`, `X-Raw-Bytes`, `X-Billing-Multiplier` and
|
|
27
|
+
* `X-Billable-Bytes` on this endpoint's 200; every one of them is on `headers`.
|
|
28
|
+
*/
|
|
29
|
+
getWithResponse(id, requestOptions) {
|
|
30
|
+
return this.client.requestWithResponse('GET', `/v1/sitemap/${id}`, undefined, requestOptions);
|
|
13
31
|
}
|
|
14
32
|
}
|
|
@@ -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
|
/** 200 payload of GET /v1/usage — current billing period usage summary. */
|
|
4
4
|
export type GetUsageResponse = operations['getUsage']['responses'][200]['content']['application/json'];
|
|
@@ -16,16 +16,21 @@ export type GetUsageByEndpointResponse = operations['getUsageByEndpoint']['respo
|
|
|
16
16
|
export declare class UsageResource {
|
|
17
17
|
private readonly client;
|
|
18
18
|
constructor(client: ByteKit);
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* GET /v1/usage — get current billing period usage.
|
|
21
|
+
*
|
|
22
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
23
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
24
|
+
*/
|
|
25
|
+
get(requestOptions?: RequestOptions): Promise<GetUsageResponse>;
|
|
21
26
|
/**
|
|
22
27
|
* GET /v1/usage/daily — get daily usage breakdown.
|
|
23
28
|
* Default range is the last 30 days; max range is 366 days.
|
|
24
29
|
*/
|
|
25
|
-
daily(params?: GetUsageDailyParams): Promise<GetUsageDailyResponse>;
|
|
30
|
+
daily(params?: GetUsageDailyParams, requestOptions?: RequestOptions): Promise<GetUsageDailyResponse>;
|
|
26
31
|
/**
|
|
27
32
|
* GET /v1/usage/by-endpoint — get per-endpoint bandwidth breakdown.
|
|
28
33
|
* Default range is the last 30 days; max range is 366 days.
|
|
29
34
|
*/
|
|
30
|
-
byEndpoint(params?: GetUsageByEndpointParams): Promise<GetUsageByEndpointResponse>;
|
|
35
|
+
byEndpoint(params?: GetUsageByEndpointParams, requestOptions?: RequestOptions): Promise<GetUsageByEndpointResponse>;
|
|
31
36
|
}
|
package/dist/resources/usage.js
CHANGED
|
@@ -4,22 +4,27 @@ export class UsageResource {
|
|
|
4
4
|
constructor(client) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* GET /v1/usage — get current billing period usage.
|
|
9
|
+
*
|
|
10
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
11
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
12
|
+
*/
|
|
13
|
+
get(requestOptions) {
|
|
14
|
+
return this.client.request('GET', '/v1/usage', undefined, requestOptions);
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* GET /v1/usage/daily — get daily usage breakdown.
|
|
13
18
|
* Default range is the last 30 days; max range is 366 days.
|
|
14
19
|
*/
|
|
15
|
-
daily(params) {
|
|
16
|
-
return this.client.request('GET', `/v1/usage/daily${toQueryString(params)}
|
|
20
|
+
daily(params, requestOptions) {
|
|
21
|
+
return this.client.request('GET', `/v1/usage/daily${toQueryString(params)}`, undefined, requestOptions);
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* GET /v1/usage/by-endpoint — get per-endpoint bandwidth breakdown.
|
|
20
25
|
* Default range is the last 30 days; max range is 366 days.
|
|
21
26
|
*/
|
|
22
|
-
byEndpoint(params) {
|
|
23
|
-
return this.client.request('GET', `/v1/usage/by-endpoint${toQueryString(params)}
|
|
27
|
+
byEndpoint(params, requestOptions) {
|
|
28
|
+
return this.client.request('GET', `/v1/usage/by-endpoint${toQueryString(params)}`, undefined, requestOptions);
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -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 { WebhookDeliveryId } from '../types.js';
|
|
4
4
|
/**
|
|
@@ -13,8 +13,13 @@ export type RetryWebhookDeliveryResponse = operations['retryWebhookDelivery']['r
|
|
|
13
13
|
export declare class WebhooksResource {
|
|
14
14
|
private readonly client;
|
|
15
15
|
constructor(client: ByteKit);
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* GET /v1/webhook-deliveries — list webhook deliveries.
|
|
18
|
+
*
|
|
19
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
20
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
21
|
+
*/
|
|
22
|
+
list(params?: ListWebhookDeliveriesParams, requestOptions?: RequestOptions): Promise<ListWebhookDeliveriesResponse>;
|
|
18
23
|
/** POST /v1/webhook-deliveries/{id}/retry — requeue a failed or exhausted delivery. */
|
|
19
|
-
retry(id: WebhookDeliveryId): Promise<RetryWebhookDeliveryResponse>;
|
|
24
|
+
retry(id: WebhookDeliveryId, requestOptions?: RequestOptions): Promise<RetryWebhookDeliveryResponse>;
|
|
20
25
|
}
|
|
@@ -4,12 +4,17 @@ export class WebhooksResource {
|
|
|
4
4
|
constructor(client) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* GET /v1/webhook-deliveries — list webhook deliveries.
|
|
9
|
+
*
|
|
10
|
+
* `requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an
|
|
11
|
+
* optional caller `signal`; both override the constructor's `timeoutMs` default.
|
|
12
|
+
*/
|
|
13
|
+
list(params, requestOptions) {
|
|
14
|
+
return this.client.request('GET', `/v1/webhook-deliveries${toQueryString(params)}`, undefined, requestOptions);
|
|
10
15
|
}
|
|
11
16
|
/** POST /v1/webhook-deliveries/{id}/retry — requeue a failed or exhausted delivery. */
|
|
12
|
-
retry(id) {
|
|
13
|
-
return this.client.request('POST', `/v1/webhook-deliveries/${id}/retry
|
|
17
|
+
retry(id, requestOptions) {
|
|
18
|
+
return this.client.request('POST', `/v1/webhook-deliveries/${id}/retry`, undefined, requestOptions);
|
|
14
19
|
}
|
|
15
20
|
}
|