@spider-cloud/spider-client 0.0.60 → 0.0.62

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
@@ -1,5 +1,4 @@
1
1
  import { ChunkCallbackFunction, Collection, QueryRequest, SpiderCoreResponse, SpiderParams } from "./config";
2
- export declare const baseUrl: string;
3
2
  /**
4
3
  * Generic params for core request.
5
4
  */
package/dist/client.js CHANGED
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Spider = exports.baseUrl = void 0;
3
+ exports.Spider = void 0;
4
4
  const config_1 = require("./config");
5
5
  const package_json_1 = require("../package.json");
6
6
  const supabase_1 = require("./supabase");
7
7
  const stream_reader_1 = require("./utils/stream-reader");
8
- exports.baseUrl = config_1.APISchema["url"];
9
8
  /**
10
9
  * A class to interact with the Spider API.
11
10
  */
@@ -43,7 +42,7 @@ class Spider {
43
42
  */
44
43
  async _apiPost(endpoint, data, stream, jsonl) {
45
44
  const headers = jsonl ? this.prepareHeadersJsonL : this.prepareHeaders;
46
- const response = await fetch(`${exports.baseUrl}/v1/${endpoint}`, {
45
+ const response = await fetch(`${config_1.APISchema["url"]}/${config_1.ApiVersion.V1}/${endpoint}`, {
47
46
  method: "POST",
48
47
  headers: headers,
49
48
  body: JSON.stringify(data),
@@ -65,7 +64,7 @@ class Spider {
65
64
  */
66
65
  async _apiGet(endpoint) {
67
66
  const headers = this.prepareHeaders;
68
- const response = await fetch(`${exports.baseUrl}/v1/${endpoint}`, {
67
+ const response = await fetch(`${config_1.APISchema["url"]}/${config_1.ApiVersion.V1}/${endpoint}`, {
69
68
  method: "GET",
70
69
  headers: headers,
71
70
  });
@@ -83,7 +82,7 @@ class Spider {
83
82
  */
84
83
  async _apiDelete(endpoint) {
85
84
  const headers = this.prepareHeaders;
86
- const response = await fetch(`${exports.baseUrl}/v1/${endpoint}`, {
85
+ const response = await fetch(`${config_1.APISchema["url"]}/${config_1.ApiVersion.V1}/${endpoint}`, {
87
86
  method: "DELETE",
88
87
  headers,
89
88
  });
@@ -203,7 +202,7 @@ class Spider {
203
202
  ...(limit && { limit: limit.toString() }),
204
203
  ...(expiresIn && { expiresIn: expiresIn.toString() }),
205
204
  });
206
- const endpoint = `${exports.baseUrl}/${config_1.APIRoutes.DataSignUrl}?${params.toString()}`;
205
+ const endpoint = `${config_1.APISchema["url"]}/${config_1.APIRoutes.DataSignUrl}?${params.toString()}`;
207
206
  const headers = this.prepareHeaders;
208
207
  const response = await fetch(endpoint, {
209
208
  method: "GET",
@@ -221,7 +220,7 @@ class Spider {
221
220
  * @returns {Promise<any>} The current credit balance.
222
221
  */
223
222
  async getCredits() {
224
- return this._apiGet("data/credits");
223
+ return this._apiGet(config_1.APIRoutes.DataCredits);
225
224
  }
226
225
  /**
227
226
  * Send a POST request to insert data into a specified table.
@@ -249,7 +248,7 @@ class Spider {
249
248
  async download(query, output) {
250
249
  const headers = this.prepareHeaders;
251
250
  const endpoint = `${config_1.APIRoutes.DataDownload}?${new URLSearchParams(query).toString()}`;
252
- const response = await fetch(`${exports.baseUrl}/v1/${endpoint}`, {
251
+ const response = await fetch(`${config_1.APISchema["url"]}/${config_1.ApiVersion.V1}/${endpoint}`, {
253
252
  method: "GET",
254
253
  headers,
255
254
  });
package/dist/config.d.ts CHANGED
@@ -272,7 +272,7 @@ export declare enum Collection {
272
272
  Webhooks = "webhooks",
273
273
  APIKeys = "api_keys"
274
274
  }
275
- declare enum ApiVersion {
275
+ export declare enum ApiVersion {
276
276
  V1 = "v1"
277
277
  }
278
278
  export declare enum APIRoutes {
@@ -287,7 +287,8 @@ export declare enum APIRoutes {
287
287
  DataCrawlState = "data/crawl_state",
288
288
  DataSignUrl = "data/sign-url",
289
289
  DataDownload = "data/download",
290
- DataQuery = "data/query"
290
+ DataQuery = "data/query",
291
+ DataCredits = "data/credits"
291
292
  }
292
293
  export declare const APISchema: {
293
294
  url: string;
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setBaseUrl = exports.APISchema = exports.APIRoutes = exports.Collection = void 0;
3
+ exports.setBaseUrl = exports.APISchema = exports.APIRoutes = exports.ApiVersion = exports.Collection = void 0;
4
4
  // records that you can query
5
5
  var Collection;
6
6
  (function (Collection) {
@@ -20,7 +20,7 @@ var Collection;
20
20
  var ApiVersion;
21
21
  (function (ApiVersion) {
22
22
  ApiVersion["V1"] = "v1";
23
- })(ApiVersion || (ApiVersion = {}));
23
+ })(ApiVersion || (exports.ApiVersion = ApiVersion = {}));
24
24
  // The API routes paths.
25
25
  var APIRoutes;
26
26
  (function (APIRoutes) {
@@ -48,6 +48,8 @@ var APIRoutes;
48
48
  APIRoutes["DataDownload"] = "data/download";
49
49
  // Perform a query on the global database to grab content without crawling if available.
50
50
  APIRoutes["DataQuery"] = "data/query";
51
+ // Get the credits remaining for an account.
52
+ APIRoutes["DataCredits"] = "data/credits";
51
53
  })(APIRoutes || (exports.APIRoutes = APIRoutes = {}));
52
54
  // The base API target info for Spider Cloud.
53
55
  exports.APISchema = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "Isomorphic Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test __tests__/*test.ts",