@spider-cloud/spider-client 0.0.13 → 0.0.16

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/README.md CHANGED
@@ -25,7 +25,9 @@ Before using the SDK, you will need to provide it with your API key. Obtain an A
25
25
  Here's a basic example to demonstrate how to use the SDK:
26
26
 
27
27
  ```javascript
28
- import { Spider } from "@spider-cloud/spider-client";
28
+ import pkg from '@spider-cloud/spider-client';
29
+
30
+ const { default: Spider } = pkg;
29
31
 
30
32
  // Initialize the SDK with your API key
31
33
  const app = new Spider({ apiKey: "YOUR_API_KEY" });
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Configuration interface for Spider.
4
3
  */
@@ -8,14 +7,14 @@ export interface SpiderConfig {
8
7
  /**
9
8
  * A class to interact with the Spider API.
10
9
  */
11
- export declare class Spider {
10
+ export default class Spider {
12
11
  private apiKey?;
13
12
  /**
14
13
  * Create an instance of Spider.
15
14
  * @param {string | null} apiKey - The API key used to authenticate to the Spider API. If null, attempts to source from environment variables.
16
15
  * @throws Will throw an error if the API key is not provided.
17
16
  */
18
- constructor({ apiKey }: SpiderConfig);
17
+ constructor(props?: SpiderConfig);
19
18
  /**
20
19
  * Internal method to handle POST requests.
21
20
  * @param {string} endpoint - The API endpoint to which the POST request should be sent.
@@ -36,7 +35,7 @@ export declare class Spider {
36
35
  * @param {object} [params={}] - Additional parameters for the scraping request.
37
36
  * @returns {Promise<any>} The scraped data from the URL.
38
37
  */
39
- scrapeUrl(url: string, params?: {}): Promise<unknown>;
38
+ scrapeUrl(url: string, params?: {}): Promise<any>;
40
39
  /**
41
40
  * Initiates a crawling job starting from the specified URL.
42
41
  * @param {string} url - The URL to start crawling.
@@ -44,47 +43,47 @@ export declare class Spider {
44
43
  * @param {boolean} [stream=false] - Whether to receive the response as a stream.
45
44
  * @returns {Promise<any | Response>} The result of the crawl, either structured data or a Response object if streaming.
46
45
  */
47
- crawlUrl(url: string, params?: {}, stream?: boolean): Promise<unknown>;
46
+ crawlUrl(url: string, params?: {}, stream?: boolean): Promise<any>;
48
47
  /**
49
48
  * Retrieves all links from the specified URL.
50
49
  * @param {string} url - The URL from which to gather links.
51
50
  * @param {object} [params={}] - Additional parameters for the request.
52
51
  * @returns {Promise<any>} A list of links extracted from the URL.
53
52
  */
54
- links(url: string, params?: {}): Promise<unknown>;
53
+ links(url: string, params?: {}): Promise<any>;
55
54
  /**
56
55
  * Takes a screenshot of the specified URL.
57
56
  * @param {string} url - The URL to screenshot.
58
57
  * @param {object} [params={}] - Configuration parameters for the screenshot.
59
58
  * @returns {Promise<any>} The screenshot data.
60
59
  */
61
- screenshot(url: string, params?: {}): Promise<unknown>;
60
+ screenshot(url: string, params?: {}): Promise<any>;
62
61
  /**
63
62
  * Extracts contact information from the specified URL.
64
63
  * @param {string} url - The URL from which to extract contacts.
65
64
  * @param {object} [params={}] - Configuration parameters for the extraction.
66
65
  * @returns {Promise<any>} The contact information extracted.
67
66
  */
68
- extractContacts(url: string, params?: {}): Promise<unknown>;
67
+ extractContacts(url: string, params?: {}): Promise<any>;
69
68
  /**
70
69
  * Applies labeling to data extracted from a specified URL.
71
70
  * @param {string} url - The URL to label.
72
71
  * @param {object} [params={}] - Configuration parameters for labeling.
73
72
  * @returns {Promise<any>} The labeled data.
74
73
  */
75
- label(url: string, params?: {}): Promise<unknown>;
74
+ label(url: string, params?: {}): Promise<any>;
76
75
  /**
77
76
  * Check the crawl state of the website.
78
77
  * @param {string} url - The URL to check.
79
78
  * @param {object} [params={}] - Configuration parameters for crawl state. Can also pass in "domain" instead of the url to query.
80
79
  * @returns {Promise<any>} The crawl state data.
81
80
  */
82
- getCrawlState(url: string, params?: {}): Promise<unknown>;
81
+ getCrawlState(url: string, params?: {}): Promise<any>;
83
82
  /**
84
83
  * Retrieves the number of credits available on the account.
85
84
  * @returns {Promise<any>} The current credit balance.
86
85
  */
87
- getCredits(): Promise<unknown>;
86
+ getCredits(): Promise<any>;
88
87
  /**
89
88
  * Prepares common headers for each API request.
90
89
  * @returns {HeadersInit} A headers object for fetch requests.
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Spider = void 0;
4
3
  /**
5
4
  * A class to interact with the Spider API.
6
5
  */
@@ -10,8 +9,9 @@ class Spider {
10
9
  * @param {string | null} apiKey - The API key used to authenticate to the Spider API. If null, attempts to source from environment variables.
11
10
  * @throws Will throw an error if the API key is not provided.
12
11
  */
13
- constructor({ apiKey = null }) {
14
- this.apiKey = apiKey || process?.env?.SPIDER_API_KEY;
12
+ constructor(props) {
13
+ var _a;
14
+ this.apiKey = (props === null || props === void 0 ? void 0 : props.apiKey) || ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.SPIDER_API_KEY);
15
15
  if (!this.apiKey) {
16
16
  throw new Error("No API key provided");
17
17
  }
@@ -149,4 +149,4 @@ class Spider {
149
149
  throw new Error(`Failed to ${action}. Status code: ${response.status}.`);
150
150
  }
151
151
  }
152
- exports.Spider = Spider;
152
+ exports.default = Spider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.13",
3
+ "version": "0.0.16",
4
4
  "description": "A Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "jest",