@hyperbrowser/sdk 0.11.0 → 0.12.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.
@@ -1,12 +1,11 @@
1
- import { CreateExtensionResponse, ListExtensionsResponse } from "../types/extension";
1
+ import { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse } from "../types/extension";
2
2
  import { BaseService } from "./base";
3
3
  export declare class ExtensionService extends BaseService {
4
4
  /**
5
5
  * Upload an extension to hyperbrowser
6
- * @param {string} filePath Path to a zipped extension. Extension must be Manifest V3 compliant.
7
- * @param {string} [fileName] Name to give to the extension.
6
+ * @param params Configuration parameters for the new extension
8
7
  */
9
- create(filePath: string, fileName?: string | undefined): Promise<CreateExtensionResponse>;
8
+ create(params: CreateExtensionParams): Promise<CreateExtensionResponse>;
10
9
  /**
11
10
  * List all uploaded extensions for the account
12
11
  */
@@ -27,19 +27,18 @@ async function checkFileExists(filePath) {
27
27
  class ExtensionService extends base_1.BaseService {
28
28
  /**
29
29
  * Upload an extension to hyperbrowser
30
- * @param {string} filePath Path to a zipped extension. Extension must be Manifest V3 compliant.
31
- * @param {string} [fileName] Name to give to the extension.
30
+ * @param params Configuration parameters for the new extension
32
31
  */
33
- async create(filePath, fileName) {
32
+ async create(params) {
34
33
  try {
35
- await checkFileExists(filePath);
34
+ await checkFileExists(params.filePath);
36
35
  const form = new form_data_1.default();
37
- form.append("file", await promises_1.default.readFile(filePath), {
38
- filename: node_path_1.default.basename(filePath),
36
+ form.append("file", await promises_1.default.readFile(params.filePath), {
37
+ filename: node_path_1.default.basename(params.filePath),
39
38
  contentType: "application/zip",
40
39
  });
41
- if (fileName) {
42
- form.append("name", fileName);
40
+ if (params.name) {
41
+ form.append("name", params.name);
43
42
  }
44
43
  const response = await this.request("/extensions/add", {
45
44
  method: "POST",
@@ -1,3 +1,7 @@
1
+ export interface CreateExtensionParams {
2
+ filePath: string;
3
+ name?: string;
4
+ }
1
5
  interface ExtensionResponse {
2
6
  name: string;
3
7
  id: string;
@@ -3,4 +3,5 @@ export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobRespon
3
3
  export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, } from "./scrape";
4
4
  export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session";
5
5
  export { ProfileResponse, CreateProfileResponse } from "./profile";
6
+ export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
6
7
  export { ScrapeJobStatus, CrawlJobStatus, Country, ISO639_1, OperatingSystem, Platform, } from "./constants";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",