@hyperbrowser/sdk
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -5,2 +5,3 @@ import { HyperbrowserConfig } from "./types/config"; | ||
import { CrawlService } from "./services/crawl"; | ||
import { ProfilesService } from "./services/profiles"; | ||
export declare class HyperbrowserError extends Error { | ||
@@ -14,3 +15,4 @@ statusCode?: number | undefined; | ||
readonly crawl: CrawlService; | ||
readonly profiles: ProfilesService; | ||
constructor(config: HyperbrowserConfig); | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
const crawl_1 = require("./services/crawl"); | ||
const profiles_1 = require("./services/profiles"); | ||
class HyperbrowserError extends Error { | ||
@@ -20,10 +21,12 @@ constructor(message, statusCode) { | ||
const baseUrl = config.baseUrl || "https://app.hyperbrowser.ai"; | ||
const timeout = config.timeout || 30000; | ||
if (!apiKey) { | ||
throw new HyperbrowserError("API key is required"); | ||
} | ||
this.sessions = new sessions_1.SessionsService(apiKey, baseUrl); | ||
this.scrape = new scrape_1.ScrapeService(apiKey, baseUrl); | ||
this.crawl = new crawl_1.CrawlService(apiKey, baseUrl); | ||
this.sessions = new sessions_1.SessionsService(apiKey, baseUrl, timeout); | ||
this.scrape = new scrape_1.ScrapeService(apiKey, baseUrl, timeout); | ||
this.crawl = new crawl_1.CrawlService(apiKey, baseUrl, timeout); | ||
this.profiles = new profiles_1.ProfilesService(apiKey, baseUrl, timeout); | ||
} | ||
} | ||
exports.HyperbrowserClient = HyperbrowserClient; |
@@ -5,4 +5,5 @@ import { RequestInit } from "node-fetch"; | ||
protected readonly baseUrl: string; | ||
constructor(apiKey: string, baseUrl: string); | ||
protected readonly timeout: number; | ||
constructor(apiKey: string, baseUrl: string, timeout?: number); | ||
protected request<T>(path: string, init?: RequestInit, params?: Record<string, string | number | undefined>): Promise<T>; | ||
} |
@@ -10,5 +10,6 @@ "use strict"; | ||
class BaseService { | ||
constructor(apiKey, baseUrl) { | ||
constructor(apiKey, baseUrl, timeout = 30000) { | ||
this.apiKey = apiKey; | ||
this.baseUrl = baseUrl; | ||
this.timeout = timeout; | ||
} | ||
@@ -27,2 +28,3 @@ async request(path, init, params) { | ||
...init, | ||
timeout: this.timeout, | ||
headers: { | ||
@@ -29,0 +31,0 @@ "x-api-key": this.apiKey, |
export interface HyperbrowserConfig { | ||
apiKey: string; | ||
baseUrl?: string; | ||
timeout?: number; | ||
} |
@@ -5,2 +5,3 @@ export { HyperbrowserConfig } from "./config"; | ||
export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session"; | ||
export { ProfileResponse, CreateProfileResponse } from "./profile"; | ||
export { ScrapeJobStatus, CrawlJobStatus, Country, ISO639_1, OperatingSystem, Platform, } from "./constants"; |
@@ -34,2 +34,6 @@ import { Country, ISO639_1, OperatingSystem, Platform } from "./constants"; | ||
} | ||
export interface CreateSessionProfile { | ||
id?: string; | ||
persistChanges?: boolean; | ||
} | ||
export interface CreateSessionParams { | ||
@@ -52,2 +56,3 @@ useStealth?: boolean; | ||
enableWebRecording?: boolean; | ||
profile?: CreateSessionProfile; | ||
} | ||
@@ -54,0 +59,0 @@ export interface SessionRecording { |
{ | ||
"name": "@hyperbrowser/sdk", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Node SDK for Hyperbrowser API", | ||
@@ -5,0 +5,0 @@ "author": "", |
31135
33
720