@spider-cloud/spider-client 0.0.53 → 0.0.56

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
@@ -28,6 +28,73 @@ export interface ChunkingAlg {
28
28
  type: ChunkingAlgType;
29
29
  value: number;
30
30
  }
31
+ /**
32
+ * Represents a timeout configuration.
33
+ * @typedef {Object} Timeout
34
+ * @property {number} secs - The number of seconds.
35
+ * @property {number} nanos - The number of nanoseconds.
36
+ */
37
+ interface Timeout {
38
+ secs: number;
39
+ nanos: number;
40
+ }
41
+ /**
42
+ * Represents the idle network configuration.
43
+ * @typedef {Object} IdleNetwork
44
+ * @property {Timeout} timeout - The timeout configuration.
45
+ */
46
+ interface IdleNetwork {
47
+ timeout: Timeout;
48
+ }
49
+ /**
50
+ * Represents the selector configuration.
51
+ * @typedef {Object} Selector
52
+ * @property {Timeout} timeout - The timeout configuration.
53
+ * @property {string} selector - The CSS selector to wait for.
54
+ */
55
+ interface Selector {
56
+ timeout: Timeout;
57
+ selector: string;
58
+ }
59
+ /**
60
+ * Represents the delay configuration.
61
+ * @typedef {Object} Delay
62
+ * @property {Timeout} timeout - The timeout configuration.
63
+ */
64
+ interface Delay {
65
+ timeout: Timeout;
66
+ }
67
+ /**
68
+ * Represents the wait_for configuration.
69
+ * @typedef {Object} WaitFor
70
+ * @property {IdleNetwork} [idle_network] - Configuration to wait for network to be idle.
71
+ * @property {Selector} [selector] - Configuration to wait for a CSS selector.
72
+ * @property {Delay} [delay] - Configuration to wait for a delay.
73
+ * @property {boolean} [page_navigations] - Whether to wait for page navigations.
74
+ */
75
+ interface WaitFor {
76
+ idle_network?: IdleNetwork;
77
+ selector?: Selector;
78
+ delay?: Delay;
79
+ page_navigations?: boolean;
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
+ }
31
98
  /**
32
99
  * Represents the options available for making a spider request.
33
100
  */
@@ -176,6 +243,10 @@ export interface SpiderParams {
176
243
  * The chunking algorithm to use.
177
244
  */
178
245
  chunking_alg?: ChunkingAlg;
246
+ /**
247
+ * The wait for events on the page. You need to make your `request` `chrome` or `smart`.
248
+ */
249
+ wait_for?: WaitFor;
179
250
  }
180
251
  export type SpiderCoreResponse = {
181
252
  content?: string;
@@ -185,3 +256,4 @@ export type SpiderCoreResponse = {
185
256
  url?: string;
186
257
  };
187
258
  export type ChunkCallbackFunction = (data: SpiderCoreResponse) => void;
259
+ export {};
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.53",
3
+ "version": "0.0.56",
4
4
  "description": "Isomorphic Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test __tests__/*test.ts",