@spider-cloud/spider-client 0.0.31 → 0.0.33

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
@@ -107,6 +107,17 @@ export declare class Spider {
107
107
  * @returns {Promise<any>} The crawl state data.
108
108
  */
109
109
  getCrawlState(url: string, params?: GenericParams): Promise<any>;
110
+ /**
111
+ * Downloads files from the specified user's storage.
112
+ * @param {string} [domain] - The domain for the user's storage. If not provided, downloads all files.
113
+ * @param {number} [page] - The page number for pagination.
114
+ * @param {number} [limit] - The number of files to return per page.
115
+ * @returns {Promise<Response>} The response containing the file stream.
116
+ */
117
+ downloadFiles(domain?: string, options?: {
118
+ page?: number;
119
+ limit?: number;
120
+ }): Promise<Response>;
110
121
  /**
111
122
  * Retrieves the number of credits available on the account.
112
123
  * @returns {Promise<any>} The current credit balance.
package/dist/client.js CHANGED
@@ -160,6 +160,31 @@ class Spider {
160
160
  async getCrawlState(url, params = {}) {
161
161
  return this._apiPost("data/crawl_state", { url: url, ...params });
162
162
  }
163
+ /**
164
+ * Downloads files from the specified user's storage.
165
+ * @param {string} [domain] - The domain for the user's storage. If not provided, downloads all files.
166
+ * @param {number} [page] - The page number for pagination.
167
+ * @param {number} [limit] - The number of files to return per page.
168
+ * @returns {Promise<Response>} The response containing the file stream.
169
+ */
170
+ async downloadFiles(domain, options) {
171
+ const { page, limit } = options !== null && options !== void 0 ? options : {};
172
+ const params = new URLSearchParams({
173
+ ...(domain && { domain }),
174
+ ...(page && { page: page.toString() }),
175
+ ...(limit && { limit: limit.toString() }),
176
+ });
177
+ const endpoint = `https://api.spider.cloud/v1/data/storage?${params.toString()}`;
178
+ const headers = this.prepareHeaders();
179
+ const response = await fetch(endpoint, {
180
+ method: "GET",
181
+ headers,
182
+ });
183
+ if (!response.ok) {
184
+ this.handleError(response, `Cannot download files`);
185
+ }
186
+ return response;
187
+ }
163
188
  /**
164
189
  * Retrieves the number of credits available on the account.
165
190
  * @returns {Promise<any>} The current credit balance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "A Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "jest",