@hyperbrowser/sdk 0.9.0 → 0.10.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/dist/client.d.ts CHANGED
@@ -2,6 +2,7 @@ import { HyperbrowserConfig } from "./types/config";
2
2
  import { SessionsService } from "./services/sessions";
3
3
  import { ScrapeService } from "./services/scrape";
4
4
  import { CrawlService } from "./services/crawl";
5
+ import { ProfilesService } from "./services/profiles";
5
6
  export declare class HyperbrowserError extends Error {
6
7
  statusCode?: number | undefined;
7
8
  constructor(message: string, statusCode?: number | undefined);
@@ -10,5 +11,6 @@ export declare class HyperbrowserClient {
10
11
  readonly sessions: SessionsService;
11
12
  readonly scrape: ScrapeService;
12
13
  readonly crawl: CrawlService;
14
+ readonly profiles: ProfilesService;
13
15
  constructor(config: HyperbrowserConfig);
14
16
  }
package/dist/client.js CHANGED
@@ -4,6 +4,7 @@ exports.HyperbrowserClient = exports.HyperbrowserError = void 0;
4
4
  const sessions_1 = require("./services/sessions");
5
5
  const scrape_1 = require("./services/scrape");
6
6
  const crawl_1 = require("./services/crawl");
7
+ const profiles_1 = require("./services/profiles");
7
8
  class HyperbrowserError extends Error {
8
9
  constructor(message, statusCode) {
9
10
  super(`[Hyperbrowser]: ${message}`);
@@ -16,12 +17,14 @@ class HyperbrowserClient {
16
17
  constructor(config) {
17
18
  const apiKey = config.apiKey;
18
19
  const baseUrl = config.baseUrl || "https://app.hyperbrowser.ai";
20
+ const timeout = config.timeout || 30000;
19
21
  if (!apiKey) {
20
22
  throw new HyperbrowserError("API key is required");
21
23
  }
22
- this.sessions = new sessions_1.SessionsService(apiKey, baseUrl);
23
- this.scrape = new scrape_1.ScrapeService(apiKey, baseUrl);
24
- this.crawl = new crawl_1.CrawlService(apiKey, baseUrl);
24
+ this.sessions = new sessions_1.SessionsService(apiKey, baseUrl, timeout);
25
+ this.scrape = new scrape_1.ScrapeService(apiKey, baseUrl, timeout);
26
+ this.crawl = new crawl_1.CrawlService(apiKey, baseUrl, timeout);
27
+ this.profiles = new profiles_1.ProfilesService(apiKey, baseUrl, timeout);
25
28
  }
26
29
  }
27
30
  exports.HyperbrowserClient = HyperbrowserClient;
@@ -2,6 +2,7 @@ import { RequestInit } from "node-fetch";
2
2
  export declare class BaseService {
3
3
  protected readonly apiKey: string;
4
4
  protected readonly baseUrl: string;
5
- constructor(apiKey: string, baseUrl: string);
5
+ protected readonly timeout: number;
6
+ constructor(apiKey: string, baseUrl: string, timeout?: number);
6
7
  protected request<T>(path: string, init?: RequestInit, params?: Record<string, string | number | undefined>): Promise<T>;
7
8
  }
@@ -7,9 +7,10 @@ exports.BaseService = void 0;
7
7
  const node_fetch_1 = __importDefault(require("node-fetch"));
8
8
  const client_1 = require("../client");
9
9
  class BaseService {
10
- constructor(apiKey, baseUrl) {
10
+ constructor(apiKey, baseUrl, timeout = 30000) {
11
11
  this.apiKey = apiKey;
12
12
  this.baseUrl = baseUrl;
13
+ this.timeout = timeout;
13
14
  }
14
15
  async request(path, init, params) {
15
16
  try {
@@ -23,6 +24,7 @@ class BaseService {
23
24
  }
24
25
  const response = await (0, node_fetch_1.default)(url.toString(), {
25
26
  ...init,
27
+ timeout: this.timeout,
26
28
  headers: {
27
29
  "x-api-key": this.apiKey,
28
30
  "Content-Type": "application/json",
@@ -0,0 +1,19 @@
1
+ import { BaseService } from "./base";
2
+ import { ProfileResponse, CreateProfileResponse } from "../types/profile";
3
+ import { BasicResponse } from "../types";
4
+ export declare class ProfilesService extends BaseService {
5
+ /**
6
+ * Create a new profile
7
+ */
8
+ create(): Promise<CreateProfileResponse>;
9
+ /**
10
+ * Get details of an existing profile
11
+ * @param id The ID of the profile to get
12
+ */
13
+ get(id: string): Promise<ProfileResponse>;
14
+ /**
15
+ * Delete an existing profile
16
+ * @param id The ID of the profile to delete
17
+ */
18
+ delete(id: string): Promise<BasicResponse>;
19
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProfilesService = void 0;
4
+ const base_1 = require("./base");
5
+ const client_1 = require("../client");
6
+ class ProfilesService extends base_1.BaseService {
7
+ /**
8
+ * Create a new profile
9
+ */
10
+ async create() {
11
+ try {
12
+ return await this.request("/profile", {
13
+ method: "POST",
14
+ });
15
+ }
16
+ catch (error) {
17
+ if (error instanceof client_1.HyperbrowserError) {
18
+ throw error;
19
+ }
20
+ throw new client_1.HyperbrowserError("Failed to create profile", undefined);
21
+ }
22
+ }
23
+ /**
24
+ * Get details of an existing profile
25
+ * @param id The ID of the profile to get
26
+ */
27
+ async get(id) {
28
+ try {
29
+ return await this.request(`/profile/${id}`);
30
+ }
31
+ catch (error) {
32
+ if (error instanceof client_1.HyperbrowserError) {
33
+ throw error;
34
+ }
35
+ throw new client_1.HyperbrowserError(`Failed to get profile ${id}`, undefined);
36
+ }
37
+ }
38
+ /**
39
+ * Delete an existing profile
40
+ * @param id The ID of the profile to delete
41
+ */
42
+ async delete(id) {
43
+ try {
44
+ return await this.request(`/profile/${id}`, {
45
+ method: "DELETE",
46
+ });
47
+ }
48
+ catch (error) {
49
+ if (error instanceof client_1.HyperbrowserError) {
50
+ throw error;
51
+ }
52
+ throw new client_1.HyperbrowserError(`Failed to delete profile ${id}`, undefined);
53
+ }
54
+ }
55
+ }
56
+ exports.ProfilesService = ProfilesService;
@@ -1,4 +1,5 @@
1
1
  export interface HyperbrowserConfig {
2
2
  apiKey: string;
3
3
  baseUrl?: string;
4
+ timeout?: number;
4
5
  }
@@ -2,4 +2,5 @@ export { HyperbrowserConfig } from "./config";
2
2
  export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobResponse, GetCrawlJobParams, } from "./crawl";
3
3
  export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, } from "./scrape";
4
4
  export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session";
5
+ export { ProfileResponse, CreateProfileResponse } from "./profile";
5
6
  export { ScrapeJobStatus, CrawlJobStatus, Country, ISO639_1, OperatingSystem, Platform, } from "./constants";
@@ -0,0 +1,9 @@
1
+ export interface CreateProfileResponse {
2
+ id: string;
3
+ }
4
+ export interface ProfileResponse {
5
+ id: string;
6
+ teamId: string;
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,6 +31,10 @@ export interface ScreenConfig {
31
31
  width: number;
32
32
  height: number;
33
33
  }
34
+ export interface CreateSessionProfile {
35
+ id?: string;
36
+ persistChanges?: boolean;
37
+ }
34
38
  export interface CreateSessionParams {
35
39
  useStealth?: boolean;
36
40
  useProxy?: boolean;
@@ -48,6 +52,7 @@ export interface CreateSessionParams {
48
52
  trackers?: boolean;
49
53
  annoyances?: boolean;
50
54
  enableWebRecording?: boolean;
55
+ profile?: CreateSessionProfile;
51
56
  }
52
57
  export interface SessionRecording {
53
58
  type: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",