@spider-cloud/spider-client 0.0.54 → 0.0.58

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,4 +1,4 @@
1
- import { ChunkCallbackFunction, SpiderCoreResponse, SpiderParams } from "./config";
1
+ import { ChunkCallbackFunction, QueryRequest, SpiderCoreResponse, SpiderParams } from "./config";
2
2
  /**
3
3
  * Generic params for core request.
4
4
  */
@@ -148,6 +148,12 @@ export declare class Spider {
148
148
  * @returns {Promise<any>} The response from the server.
149
149
  */
150
150
  getData(table: string, params: GenericParams | Record<string, any>): Promise<any>;
151
+ /**
152
+ * Perform a query to get a document.
153
+ * @param {QueryRequest} params - The query parameters for data retrieval.
154
+ * @returns {Promise<any>} The response from the server.
155
+ */
156
+ query(query: QueryRequest): Promise<any>;
151
157
  /**
152
158
  * Send a DELETE request to remove data from a specified table.
153
159
  * @param {string} table - The table name in the database.
package/dist/client.js CHANGED
@@ -237,6 +237,14 @@ class Spider {
237
237
  async getData(table, params) {
238
238
  return this._apiGet(`data/${table}?${new URLSearchParams(params).toString()}`);
239
239
  }
240
+ /**
241
+ * Perform a query to get a document.
242
+ * @param {QueryRequest} params - The query parameters for data retrieval.
243
+ * @returns {Promise<any>} The response from the server.
244
+ */
245
+ async query(query) {
246
+ return this._apiGet(`data/query?${new URLSearchParams(query).toString()}`);
247
+ }
240
248
  /**
241
249
  * Send a DELETE request to remove data from a specified table.
242
250
  * @param {string} table - The table name in the database.
package/dist/config.d.ts CHANGED
@@ -78,6 +78,23 @@ interface WaitFor {
78
78
  delay?: Delay;
79
79
  page_navigations?: boolean;
80
80
  }
81
+ /**
82
+ * Represents the query API endpoint request to get documents from the global spider collection.
83
+ */
84
+ export interface QueryRequest {
85
+ /**
86
+ * The exact URL to get.
87
+ */
88
+ url?: string;
89
+ /**
90
+ * The domain to get a document from.
91
+ */
92
+ domain?: string;
93
+ /**
94
+ * The path of the webpage to get the document. This is used with the domain key.
95
+ */
96
+ pathname?: string;
97
+ }
81
98
  /**
82
99
  * Represents the options available for making a spider request.
83
100
  */
@@ -230,6 +247,10 @@ export interface SpiderParams {
230
247
  * The wait for events on the page. You need to make your `request` `chrome` or `smart`.
231
248
  */
232
249
  wait_for?: WaitFor;
250
+ /**
251
+ * Disable request interception when running 'request' as 'chrome' or 'smart'. This can help when the page uses 3rd party or external scripts to load content.
252
+ */
253
+ disable_intercept?: boolean;
233
254
  }
234
255
  export type SpiderCoreResponse = {
235
256
  content?: string;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Spider } from "./client";
2
- export type { SpiderParams, Budget, Viewport } from "./config";
2
+ export type { SpiderParams, Budget, Viewport, QueryRequest } from "./config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.54",
3
+ "version": "0.0.58",
4
4
  "description": "Isomorphic Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test __tests__/*test.ts",