@hunt-labs/bytekit-sdk 0.2.0 → 0.3.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 +142 -0
- package/README.md +63 -17
- package/dist/allowlist.d.ts +1 -1
- package/dist/allowlist.js +7 -0
- package/dist/client.d.ts +49 -10
- package/dist/client.js +81 -21
- package/dist/index.d.ts +9 -3
- package/dist/index.js +1 -1
- package/dist/resources/account.d.ts +6 -7
- package/dist/resources/account.js +3 -4
- package/dist/resources/bulk.d.ts +18 -7
- package/dist/resources/fetch.d.ts +98 -10
- package/dist/resources/fetch.js +33 -6
- package/dist/resources/monitors.d.ts +50 -11
- package/dist/resources/monitors.js +17 -4
- package/dist/resources/query-string.d.ts +10 -0
- package/dist/resources/query-string.js +20 -0
- package/dist/resources/scrape.d.ts +28 -4
- package/dist/resources/screenshots.d.ts +13 -4
- package/dist/resources/screenshots.js +11 -3
- package/dist/resources/search.d.ts +2 -2
- package/dist/resources/sitemap.d.ts +11 -4
- package/dist/resources/usage.d.ts +31 -0
- package/dist/resources/usage.js +25 -0
- package/dist/resources/webhooks.d.ts +20 -0
- package/dist/resources/webhooks.js +15 -0
- package/dist/types.d.ts +7 -4
- package/dist/types.js +1 -1
- package/package.json +6 -10
- package/dist/resources/recordings.d.ts +0 -10
- package/dist/resources/recordings.js +0 -14
- package/dist/test-helpers/signal-aware-never-resolver.d.ts +0 -9
- package/dist/test-helpers/signal-aware-never-resolver.js +0 -25
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { toQueryString } from './query-string.js';
|
|
2
|
+
export class UsageResource {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
/** GET /v1/usage — get current billing period usage. */
|
|
8
|
+
get() {
|
|
9
|
+
return this.client.request('GET', '/v1/usage');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* GET /v1/usage/daily — get daily usage breakdown.
|
|
13
|
+
* Default range is the last 30 days; max range is 366 days.
|
|
14
|
+
*/
|
|
15
|
+
daily(params) {
|
|
16
|
+
return this.client.request('GET', `/v1/usage/daily${toQueryString(params)}`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* GET /v1/usage/by-endpoint — get per-endpoint bandwidth breakdown.
|
|
20
|
+
* Default range is the last 30 days; max range is 366 days.
|
|
21
|
+
*/
|
|
22
|
+
byEndpoint(params) {
|
|
23
|
+
return this.client.request('GET', `/v1/usage/by-endpoint${toQueryString(params)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ByteKit } from '../client.js';
|
|
2
|
+
import type { operations } from '../generated/api.js';
|
|
3
|
+
import type { WebhookDeliveryId } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Query params of GET /v1/webhook-deliveries.
|
|
6
|
+
* Derived from the generated OpenAPI types so it stays in sync with the spec.
|
|
7
|
+
*/
|
|
8
|
+
export type ListWebhookDeliveriesParams = NonNullable<operations['listWebhookDeliveries']['parameters']['query']>;
|
|
9
|
+
/** 200 payload of GET /v1/webhook-deliveries. */
|
|
10
|
+
export type ListWebhookDeliveriesResponse = operations['listWebhookDeliveries']['responses'][200]['content']['application/json'];
|
|
11
|
+
/** 200 payload of POST /v1/webhook-deliveries/{id}/retry. */
|
|
12
|
+
export type RetryWebhookDeliveryResponse = operations['retryWebhookDelivery']['responses'][200]['content']['application/json'];
|
|
13
|
+
export declare class WebhooksResource {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: ByteKit);
|
|
16
|
+
/** GET /v1/webhook-deliveries — list webhook deliveries. */
|
|
17
|
+
list(params?: ListWebhookDeliveriesParams): Promise<ListWebhookDeliveriesResponse>;
|
|
18
|
+
/** POST /v1/webhook-deliveries/{id}/retry — requeue a failed or exhausted delivery. */
|
|
19
|
+
retry(id: WebhookDeliveryId): Promise<RetryWebhookDeliveryResponse>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toQueryString } from './query-string.js';
|
|
2
|
+
export class WebhooksResource {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
/** GET /v1/webhook-deliveries — list webhook deliveries. */
|
|
8
|
+
list(params) {
|
|
9
|
+
return this.client.request('GET', `/v1/webhook-deliveries${toQueryString(params)}`);
|
|
10
|
+
}
|
|
11
|
+
/** 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`);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prefixed-ID branded types for all
|
|
2
|
+
* Prefixed-ID branded types for all ByteKit resource identifiers.
|
|
3
3
|
*
|
|
4
4
|
* These mirror the `ss_`, `rec_`, `bulk_`, etc. prefixes used at the API
|
|
5
5
|
* boundary (internal rows use raw UUIDs).
|
|
6
6
|
*/
|
|
7
7
|
export type ScrapeId = `sc_${string}`;
|
|
8
8
|
export type ScreenshotId = `ss_${string}`;
|
|
9
|
-
export type RecordingId = `rec_${string}`;
|
|
10
9
|
export type BulkId = `bulk_${string}`;
|
|
11
10
|
export type MonitorId = `mon_${string}`;
|
|
12
11
|
export type SitemapId = `sm_${string}`;
|
|
13
12
|
export type ApiKeyId = `ak_${string}`;
|
|
13
|
+
export type WebhookDeliveryId = `wh_${string}`;
|
|
14
14
|
/** Which search index to query. `web` (default), `news`, or `images`. */
|
|
15
15
|
export type SearchType = 'web' | 'news' | 'images';
|
|
16
16
|
/** Recency window for search results (maps to the upstream time filter). */
|
|
@@ -66,8 +66,11 @@ export interface SearchResult {
|
|
|
66
66
|
url: string;
|
|
67
67
|
/** Short text excerpt for the result. Omitted for `images` results. */
|
|
68
68
|
snippet: string;
|
|
69
|
-
/**
|
|
70
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Published date when the provider reports one, else `null`. Present for
|
|
71
|
+
* `web`/`news` results; omitted entirely (`undefined`) for `images` results.
|
|
72
|
+
*/
|
|
73
|
+
date?: string | null;
|
|
71
74
|
/** Publisher / source name. Present for `news` and `images` results. */
|
|
72
75
|
source?: string;
|
|
73
76
|
/** Hosting-page domain of the result. Present only for `images` results. */
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunt-labs/bytekit-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official TypeScript SDK for the ByteKit API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,14 +22,9 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"CHANGELOG.md"
|
|
26
27
|
],
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"openapi-typescript": "7.13.0",
|
|
29
|
-
"tsx": "*",
|
|
30
|
-
"typescript": "^5.4.5",
|
|
31
|
-
"vitest": "^1.6.0"
|
|
32
|
-
},
|
|
33
28
|
"engines": {
|
|
34
29
|
"node": ">=18"
|
|
35
30
|
},
|
|
@@ -49,10 +44,11 @@
|
|
|
49
44
|
],
|
|
50
45
|
"homepage": "https://bytekit.com/docs",
|
|
51
46
|
"bugs": {
|
|
52
|
-
"email": "support@bytekit.com"
|
|
47
|
+
"email": "support@bytekit.com",
|
|
48
|
+
"url": "https://bytekit.com/contact"
|
|
53
49
|
},
|
|
54
50
|
"scripts": {
|
|
55
|
-
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc && mkdir -p dist/generated && cp src/generated/api.d.ts dist/generated/api.d.ts",
|
|
51
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json && mkdir -p dist/generated && cp src/generated/api.d.ts dist/generated/api.d.ts",
|
|
56
52
|
"gen:types": "openapi-typescript ../../docs/api/openapi.yaml -o src/generated/api.d.ts",
|
|
57
53
|
"gen:types-check": "pnpm gen:types && git diff --exit-code src/generated/api.d.ts",
|
|
58
54
|
"generate:docs": "tsx scripts/generate-docs.ts",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RapidCrawl } from '../client.js';
|
|
2
|
-
import type { RecordingId } from '../types.js';
|
|
3
|
-
export declare class RecordingsResource {
|
|
4
|
-
private readonly client;
|
|
5
|
-
constructor(client: RapidCrawl);
|
|
6
|
-
/** POST /v1/recordings — start a recording */
|
|
7
|
-
create(opts: Record<string, unknown>): Promise<unknown>;
|
|
8
|
-
/** GET /v1/recordings/{id} — poll a recording by ID */
|
|
9
|
-
get(id: RecordingId): Promise<unknown>;
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export class RecordingsResource {
|
|
2
|
-
client;
|
|
3
|
-
constructor(client) {
|
|
4
|
-
this.client = client;
|
|
5
|
-
}
|
|
6
|
-
/** POST /v1/recordings — start a recording */
|
|
7
|
-
create(opts) {
|
|
8
|
-
return this.client.request('POST', '/v1/recordings', opts);
|
|
9
|
-
}
|
|
10
|
-
/** GET /v1/recordings/{id} — poll a recording by ID */
|
|
11
|
-
get(id) {
|
|
12
|
-
return this.client.request('GET', `/v1/recordings/${id}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A `fetch` mock that never settles until the request's own signal aborts.
|
|
3
|
-
*
|
|
4
|
-
* Shared between `client.test.ts` and `resources/__tests__/scrape.test.ts` (#2424 code review
|
|
5
|
-
* cr-3) — both suites need a `fetch` stand-in that hangs forever except for reacting to the
|
|
6
|
-
* abort signal the SDK attaches, so timeout/abort-ordering tests can assert on elapsed time and
|
|
7
|
-
* error code without a real network call.
|
|
8
|
-
*/
|
|
9
|
-
export declare function signalAwareNeverResolver(): (url: string, init: RequestInit) => Promise<Response>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Test-only fixture, compiled like any other `src` file (not excluded from the tsc build):
|
|
2
|
-
// excluding it broke ESLint's typed-lint project-service resolution (it requires every linted
|
|
3
|
-
// file to be part of the tsconfig `include` set). The tradeoff is a small compiled fixture
|
|
4
|
-
// landing in `dist/test-helpers/` alongside the package's real exports — negligible, and no
|
|
5
|
-
// consumer imports it (it's not re-exported from `index.ts`).
|
|
6
|
-
/**
|
|
7
|
-
* A `fetch` mock that never settles until the request's own signal aborts.
|
|
8
|
-
*
|
|
9
|
-
* Shared between `client.test.ts` and `resources/__tests__/scrape.test.ts` (#2424 code review
|
|
10
|
-
* cr-3) — both suites need a `fetch` stand-in that hangs forever except for reacting to the
|
|
11
|
-
* abort signal the SDK attaches, so timeout/abort-ordering tests can assert on elapsed time and
|
|
12
|
-
* error code without a real network call.
|
|
13
|
-
*/
|
|
14
|
-
export function signalAwareNeverResolver() {
|
|
15
|
-
return (_url, init) => new Promise((_resolve, reject) => {
|
|
16
|
-
const signal = init.signal;
|
|
17
|
-
if (!signal)
|
|
18
|
-
return; // hangs — only used by tests that always pass a signal
|
|
19
|
-
if (signal.aborted) {
|
|
20
|
-
reject(signal.reason);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
signal.addEventListener('abort', () => reject(signal.reason));
|
|
24
|
-
});
|
|
25
|
-
}
|