@spider-cloud/spider-client 0.0.70 → 0.0.72

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
@@ -148,24 +148,6 @@ spider
148
148
  - **`deleteData(table, params)`**: Delete records from the DB.
149
149
  - **`createSignedUrl(domain, params)`**: Download the records from the DB.
150
150
 
151
- ## Supabase
152
-
153
- You can use [Supabase](https://supabase.com/docs/reference/javascript) to directly connect to instances and write your own logic. First, you need to install `@supabase/supabase-js` since this package does not include the dependency by default. This keeps the bundle size small and allows for lazy imports of the client.
154
-
155
- ```ts
156
- const spiderClient = new Spider({ apiKey: process.env.SPIDER_API_KEY });
157
-
158
- // first init the supabase client to get the anon_key from the server.
159
- await spiderClient.init_supabase();
160
-
161
- const auth = await spiderClient.supabase?.auth.signInWithPassword({
162
- email: process.env.SPIDER_EMAIL || "",
163
- password: process.env.SPIDER_PASSWORD || "",
164
- });
165
-
166
- // now you can do anything with spiderClient.supabase
167
- ```
168
-
169
151
  ## Error Handling
170
152
 
171
153
  The SDK provides robust error handling and will throw exceptions when it encounters critical issues. Always use `.catch()` on promises to handle these errors gracefully.
package/dist/client.d.ts CHANGED
@@ -20,14 +20,6 @@ export declare class Spider {
20
20
  * @throws Will throw an error if the API key is not provided.
21
21
  */
22
22
  constructor(props?: SpiderConfig);
23
- /**
24
- * Init a supabase client.
25
- */
26
- init_supabase(): Promise<void>;
27
- /**
28
- * The supabase client to manage data.
29
- */
30
- get supabase(): import("@supabase/supabase-js").SupabaseClient<any, "public", any>;
31
23
  /**
32
24
  * Internal method to handle POST requests.
33
25
  * @param {string} endpoint - The API endpoint to which the POST request should be sent.
package/dist/client.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Spider = void 0;
4
4
  const config_1 = require("./config");
5
5
  const package_json_1 = require("../package.json");
6
- const supabase_1 = require("./supabase");
7
6
  const stream_reader_1 = require("./utils/stream-reader");
8
7
  /**
9
8
  * A class to interact with the Spider API.
@@ -21,18 +20,6 @@ class Spider {
21
20
  throw new Error("No API key provided");
22
21
  }
23
22
  }
24
- /**
25
- * Init a supabase client.
26
- */
27
- async init_supabase() {
28
- return await supabase_1.Supabase.init();
29
- }
30
- /**
31
- * The supabase client to manage data.
32
- */
33
- get supabase() {
34
- return supabase_1.Supabase.client;
35
- }
36
23
  /**
37
24
  * Internal method to handle POST requests.
38
25
  * @param {string} endpoint - The API endpoint to which the POST request should be sent.
package/dist/config.d.ts CHANGED
@@ -38,6 +38,37 @@ interface Timeout {
38
38
  secs: number;
39
39
  nanos: number;
40
40
  }
41
+ /**
42
+ * Represents the webhook configuration.
43
+ * @typedef {Object} WebhookSettings
44
+ * @property {Object} object - The webhook configuration.
45
+ */
46
+ interface WebhookSettings {
47
+ /**
48
+ * The URL or endpoint where the webhook information will be sent.
49
+ */
50
+ destination: string;
51
+ /**
52
+ * Flag to indicate an action should be taken when all credits are depleted.
53
+ */
54
+ on_credits_depleted: boolean;
55
+ /**
56
+ * Flag to indicate an action should be taken when half of the credits are depleted.
57
+ */
58
+ on_credits_half_depleted: boolean;
59
+ /**
60
+ * Flag to trigger a notification on a website status update event.
61
+ */
62
+ on_website_status: boolean;
63
+ /**
64
+ * Flag to send information about a new page find, such as links and data size.
65
+ */
66
+ on_find: boolean;
67
+ /**
68
+ * Flag to handle the metadata of a new page that has been found.
69
+ */
70
+ on_find_metadata: boolean;
71
+ }
41
72
  /**
42
73
  * Represents the idle network configuration.
43
74
  * @typedef {Object} IdleNetwork
@@ -126,6 +157,7 @@ export type WebAutomation = {
126
157
  } | {
127
158
  InfiniteScroll: number;
128
159
  };
160
+ export type ReturnFormat = "markdown" | "commonmark" | "raw" | "text" | "html2text" | "bytes" | "xml" | "empty";
129
161
  export type WebAutomationMap = Record<string, WebAutomation[]>;
130
162
  export type ExecutionScriptsMap = Record<string, string>;
131
163
  export declare enum RedirectPolicy {
@@ -149,9 +181,9 @@ export interface SpiderParams {
149
181
  */
150
182
  limit?: number;
151
183
  /**
152
- * The format in which the result should be returned.
184
+ * The format in which the result should be returned. When setting the return format as an array a object is returned mapping by the name.
153
185
  */
154
- return_format?: "markdown" | "commonmark" | "raw" | "text" | "html2text" | "bytes";
186
+ return_format?: ReturnFormat | ReturnFormat[];
155
187
  /**
156
188
  * Specifies whether to only visit the top-level domain.
157
189
  */
@@ -224,6 +256,10 @@ export interface SpiderParams {
224
256
  * Specifies whether the response data should be stored.
225
257
  */
226
258
  store_data?: boolean;
259
+ /**
260
+ * Use webhooks to send data.
261
+ */
262
+ webhooks?: WebhookSettings;
227
263
  /**
228
264
  * Configuration settings for GPT (general purpose texture mappings).
229
265
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "Isomorphic Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test __tests__/*test.ts",
@@ -23,10 +23,9 @@
23
23
  "author": "Jeff Mendez<jeff@a11ywatch.com>",
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@supabase/supabase-js": "^2.45.0",
27
- "@types/node": "20.14.2",
26
+ "@types/node": "22.7.5",
28
27
  "dotenv": "^16.4.5",
29
- "tsx": "^4.16.5",
30
- "typescript": "5.4.5"
28
+ "tsx": "^4.19.1",
29
+ "typescript": "5.6.3"
31
30
  }
32
31
  }
@@ -1,7 +0,0 @@
1
- import type { SupabaseClient } from "@supabase/supabase-js";
2
- export declare class Supabase {
3
- private static instance?;
4
- private static initPromise?;
5
- static init(): Promise<void>;
6
- static get client(): SupabaseClient;
7
- }
package/dist/supabase.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Supabase = void 0;
27
- class Supabase {
28
- // Initialize the Supabase client
29
- static async init() {
30
- if (Supabase.instance) {
31
- return;
32
- }
33
- if (Supabase.initPromise) {
34
- return Supabase.initPromise;
35
- }
36
- Supabase.initPromise = (async () => {
37
- const windowExists = typeof window !== "undefined";
38
- const { createClient } = await Promise.resolve().then(() => __importStar(require("@supabase/supabase-js")));
39
- try {
40
- const response = await fetch("https://api.spider.cloud/data/anon_key");
41
- if (!response.ok) {
42
- throw new Error(`Failed to fetch anon key: ${response.statusText}`);
43
- }
44
- const { data } = await response.json();
45
- Supabase.instance = createClient("https://api-data.spider.cloud", String(data), {
46
- auth: {
47
- persistSession: windowExists,
48
- autoRefreshToken: windowExists,
49
- },
50
- });
51
- }
52
- catch (error) {
53
- Promise.reject("Failed to initialize Supabase client: " + error);
54
- }
55
- finally {
56
- Supabase.initPromise = undefined; // Clear the init promise
57
- }
58
- })();
59
- return Supabase.initPromise;
60
- }
61
- // Get the Supabase client instance
62
- static get client() {
63
- if (!Supabase.instance) {
64
- throw new Error("Supabase client is not initialized. Call Supabase.init() first.");
65
- }
66
- return Supabase.instance;
67
- }
68
- }
69
- exports.Supabase = Supabase;