@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.
@@ -43,12 +43,17 @@ class ScrapeBulkResource {
43
43
  constructor(client) {
44
44
  this.client = client;
45
45
  }
46
- /** POST /v1/scrape/bulk — create a bulk scrape job */
47
- create(opts) {
48
- return this.client.request('POST', '/v1/scrape/bulk', opts);
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 {};
@@ -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
- /** POST /v1/search — run a web search and return ranked organic results. */
7
- query(opts: SearchOpts): Promise<SearchResponse>;
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
  }
@@ -3,8 +3,13 @@ export class SearchResource {
3
3
  constructor(client) {
4
4
  this.client = client;
5
5
  }
6
- /** POST /v1/search — run a web search and return ranked organic results. */
7
- query(opts) {
8
- return this.client.request('POST', '/v1/search', opts);
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
- /** Body of POST /v1/sitemap. */
5
- export type SitemapCreateRequest = operations['createSitemap']['requestBody']['content']['application/json'];
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
- /** POST /v1/sitemap — start a sitemap crawl */
14
- create(opts: SitemapCreateRequest): Promise<SitemapCreateResponse>;
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
- /** POST /v1/sitemap — start a sitemap crawl */
7
- create(opts) {
8
- return this.client.request('POST', '/v1/sitemap', opts);
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
- /** GET /v1/usage — get current billing period usage. */
20
- get(): Promise<GetUsageResponse>;
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
  }
@@ -4,22 +4,27 @@ export class UsageResource {
4
4
  constructor(client) {
5
5
  this.client = client;
6
6
  }
7
- /** GET /v1/usage — get current billing period usage. */
8
- get() {
9
- return this.client.request('GET', '/v1/usage');
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
- /** GET /v1/webhook-deliveries — list webhook deliveries. */
17
- list(params?: ListWebhookDeliveriesParams): Promise<ListWebhookDeliveriesResponse>;
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
- /** GET /v1/webhook-deliveries — list webhook deliveries. */
8
- list(params) {
9
- return this.client.request('GET', `/v1/webhook-deliveries${toQueryString(params)}`);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Official TypeScript SDK for the ByteKit API",
5
5
  "license": "MIT",
6
6
  "type": "module",