@spider-cloud/spider-client 0.1.87 → 0.2.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 +13 -0
- package/dist/client.js +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +14 -1
- package/package.json +7 -3
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChunkCallbackFunction, Collection, SpiderCoreResponse, SpiderParams, SearchRequestParams, RequestParamsTransform, AIRequestParams, AIStudioTier } from "./config";
|
|
2
|
+
import { SpiderBrowser, type SpiderBrowserOptions } from "spider-browser";
|
|
2
3
|
/**
|
|
3
4
|
* Rate limit state from API response headers.
|
|
4
5
|
*/
|
|
@@ -205,6 +206,18 @@ export declare class Spider {
|
|
|
205
206
|
* @throws {AIStudioSubscriptionRequired} When subscription is not active.
|
|
206
207
|
*/
|
|
207
208
|
aiLinks(url: string, prompt: string, params?: Omit<AIRequestParams, "prompt">): Promise<any>;
|
|
209
|
+
/**
|
|
210
|
+
* Creates a SpiderBrowser instance for WebSocket-based browser automation (CDP/BiDi).
|
|
211
|
+
* @param {Omit<SpiderBrowserOptions, 'apiKey'>} [options] - Browser options (excluding apiKey, which is inherited from the client).
|
|
212
|
+
* @returns {SpiderBrowser} A new SpiderBrowser instance.
|
|
213
|
+
*/
|
|
214
|
+
browser(options?: Omit<SpiderBrowserOptions, "apiKey">): SpiderBrowser;
|
|
215
|
+
/**
|
|
216
|
+
* Generates the API URL for a recording session's video/metadata.
|
|
217
|
+
* @param {string} sessionId - The recording session ID.
|
|
218
|
+
* @returns {string} The full URL to the recording endpoint.
|
|
219
|
+
*/
|
|
220
|
+
static getRecordingVideoUrl(sessionId: string): string;
|
|
208
221
|
/**
|
|
209
222
|
* Handles errors from API requests.
|
|
210
223
|
* @param {Response} response - The fetch response object.
|
package/dist/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Spider = void 0;
|
|
4
4
|
const config_1 = require("./config");
|
|
5
|
+
const spider_browser_1 = require("spider-browser");
|
|
5
6
|
const package_json_1 = require("../package.json");
|
|
6
7
|
const stream_reader_1 = require("./utils/stream-reader");
|
|
7
8
|
const exponential_backoff_1 = require("exponential-backoff");
|
|
@@ -372,6 +373,22 @@ class Spider {
|
|
|
372
373
|
async aiLinks(url, prompt, params = {}) {
|
|
373
374
|
return this._aiApiPost(config_1.APIRoutes.AILinks, { url, prompt, ...params });
|
|
374
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Creates a SpiderBrowser instance for WebSocket-based browser automation (CDP/BiDi).
|
|
378
|
+
* @param {Omit<SpiderBrowserOptions, 'apiKey'>} [options] - Browser options (excluding apiKey, which is inherited from the client).
|
|
379
|
+
* @returns {SpiderBrowser} A new SpiderBrowser instance.
|
|
380
|
+
*/
|
|
381
|
+
browser(options) {
|
|
382
|
+
return new spider_browser_1.SpiderBrowser({ apiKey: this.apiKey, ...options });
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Generates the API URL for a recording session's video/metadata.
|
|
386
|
+
* @param {string} sessionId - The recording session ID.
|
|
387
|
+
* @returns {string} The full URL to the recording endpoint.
|
|
388
|
+
*/
|
|
389
|
+
static getRecordingVideoUrl(sessionId) {
|
|
390
|
+
return `${config_1.APISchema.url}/v1/data/recordings/${sessionId}`;
|
|
391
|
+
}
|
|
375
392
|
/**
|
|
376
393
|
* Handles errors from API requests.
|
|
377
394
|
* @param {Response} response - The fetch response object.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export { Spider } from "./client";
|
|
2
2
|
export { Collection, setBaseUrl, APISchema, AI_STUDIO_RATE_LIMITS, AIStudioInfo, AIStudioSubscriptionRequired, AIStudioRateLimitExceeded, } from "./config";
|
|
3
3
|
export type { SpiderParams, Budget, Viewport, QueryRequest, AIRequestParams, AIStudioTier, } from "./config";
|
|
4
|
+
export { SpiderBrowser, SpiderPage } from "spider-browser";
|
|
5
|
+
export type { SpiderBrowserOptions, SpiderEvents } from "spider-browser";
|
|
6
|
+
export { Agent, act, observe, extract } from "spider-browser";
|
|
7
|
+
export type { AgentOptions, AgentResult, ObserveResult } from "spider-browser";
|
|
8
|
+
export { RetryEngine } from "spider-browser";
|
|
9
|
+
export type { RetryOptions } from "spider-browser";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AIStudioRateLimitExceeded = exports.AIStudioSubscriptionRequired = exports.AIStudioInfo = exports.AI_STUDIO_RATE_LIMITS = exports.APISchema = exports.setBaseUrl = exports.Collection = exports.Spider = void 0;
|
|
3
|
+
exports.RetryEngine = exports.extract = exports.observe = exports.act = exports.Agent = exports.SpiderPage = exports.SpiderBrowser = exports.AIStudioRateLimitExceeded = exports.AIStudioSubscriptionRequired = exports.AIStudioInfo = exports.AI_STUDIO_RATE_LIMITS = exports.APISchema = exports.setBaseUrl = exports.Collection = exports.Spider = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
5
|
Object.defineProperty(exports, "Spider", { enumerable: true, get: function () { return client_1.Spider; } });
|
|
6
6
|
var config_1 = require("./config");
|
|
@@ -11,3 +11,16 @@ Object.defineProperty(exports, "AI_STUDIO_RATE_LIMITS", { enumerable: true, get:
|
|
|
11
11
|
Object.defineProperty(exports, "AIStudioInfo", { enumerable: true, get: function () { return config_1.AIStudioInfo; } });
|
|
12
12
|
Object.defineProperty(exports, "AIStudioSubscriptionRequired", { enumerable: true, get: function () { return config_1.AIStudioSubscriptionRequired; } });
|
|
13
13
|
Object.defineProperty(exports, "AIStudioRateLimitExceeded", { enumerable: true, get: function () { return config_1.AIStudioRateLimitExceeded; } });
|
|
14
|
+
// Browser automation
|
|
15
|
+
var spider_browser_1 = require("spider-browser");
|
|
16
|
+
Object.defineProperty(exports, "SpiderBrowser", { enumerable: true, get: function () { return spider_browser_1.SpiderBrowser; } });
|
|
17
|
+
Object.defineProperty(exports, "SpiderPage", { enumerable: true, get: function () { return spider_browser_1.SpiderPage; } });
|
|
18
|
+
// Browser AI
|
|
19
|
+
var spider_browser_2 = require("spider-browser");
|
|
20
|
+
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return spider_browser_2.Agent; } });
|
|
21
|
+
Object.defineProperty(exports, "act", { enumerable: true, get: function () { return spider_browser_2.act; } });
|
|
22
|
+
Object.defineProperty(exports, "observe", { enumerable: true, get: function () { return spider_browser_2.observe; } });
|
|
23
|
+
Object.defineProperty(exports, "extract", { enumerable: true, get: function () { return spider_browser_2.extract; } });
|
|
24
|
+
// Browser retry & stealth
|
|
25
|
+
var spider_browser_3 = require("spider-browser");
|
|
26
|
+
Object.defineProperty(exports, "RetryEngine", { enumerable: true, get: function () { return spider_browser_3.RetryEngine; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-cloud/spider-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Isomorphic Javascript SDK for Spider Cloud services",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --import tsx --test __tests__/*test.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"prepublishOnly": "npm test && npm run build"
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/index.js",
|
|
11
|
-
"types": "dist/
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist/**/*"
|
|
14
14
|
],
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"sdk",
|
|
18
18
|
"web crawling",
|
|
19
19
|
"web scraping",
|
|
20
|
+
"browser automation",
|
|
21
|
+
"cdp",
|
|
22
|
+
"headless",
|
|
20
23
|
"api",
|
|
21
24
|
"llm scraping"
|
|
22
25
|
],
|
|
@@ -29,6 +32,7 @@
|
|
|
29
32
|
"typescript": "5.7.3"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {
|
|
32
|
-
"exponential-backoff": "^3.1.2"
|
|
35
|
+
"exponential-backoff": "^3.1.2",
|
|
36
|
+
"spider-browser": "^0.2.3"
|
|
33
37
|
}
|
|
34
38
|
}
|