@hyperbrowser/sdk
Advanced tools
Comparing version 0.2.0 to 0.3.0
import { Response } from "node-fetch"; | ||
import { HyperbrowserConfig } from "./types/config"; | ||
import { BasicResponse, SessionDetail, SessionListParams, SessionListResponse } from "./types/session"; | ||
import { BasicResponse, CreateSessionParams, SessionDetail, SessionListParams, SessionListResponse } from "./types/session"; | ||
export declare class HyperbrowserError extends Error { | ||
@@ -17,4 +17,5 @@ statusCode?: number | undefined; | ||
* Create a new browser session | ||
* @param params Configuration parameters for the new session | ||
*/ | ||
createSession(): Promise<SessionDetail>; | ||
createSession(params?: CreateSessionParams): Promise<SessionDetail>; | ||
/** | ||
@@ -21,0 +22,0 @@ * Get details of an existing session |
@@ -77,6 +77,10 @@ "use strict"; | ||
* Create a new browser session | ||
* @param params Configuration parameters for the new session | ||
*/ | ||
async createSession() { | ||
async createSession(params) { | ||
try { | ||
return await this.request("/session", { method: "POST" }); | ||
return await this.request("/session", { | ||
method: "POST", | ||
body: params ? JSON.stringify(params) : undefined, | ||
}); | ||
} | ||
@@ -83,0 +87,0 @@ catch (error) { |
@@ -0,1 +1,2 @@ | ||
import { Country, ISO639_1, OperatingSystem, Platform } from "./constants"; | ||
export type SessionStatus = "active" | "closed" | "error"; | ||
@@ -28,1 +29,18 @@ export interface BasicResponse { | ||
} | ||
export interface ScreenConfig { | ||
maxWidth: number; | ||
maxHeight: number; | ||
minWidth: number; | ||
minHeight: number; | ||
} | ||
export interface CreateSessionParams { | ||
proxyServer?: string; | ||
proxyServerPassword?: string; | ||
proxyServerUsername?: string; | ||
proxyCountry?: Country; | ||
operatingSystems?: OperatingSystem[]; | ||
device?: ("desktop" | "mobile")[]; | ||
platform?: Platform[]; | ||
locales?: ISO639_1[]; | ||
screen?: ScreenConfig; | ||
} |
{ | ||
"name": "@hyperbrowser/sdk", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Node SDK for Hyperbrowser API", | ||
@@ -5,0 +5,0 @@ "author": "", |
15529
15
285