@spider-cloud/spider-client 0.1.59 → 0.1.60
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 +2 -2
- package/dist/client.js +9 -3
- package/dist/config.d.ts +22 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChunkCallbackFunction, Collection, QueryRequest, SpiderCoreResponse, SpiderParams, SearchRequestParams } from "./config";
|
|
1
|
+
import { ChunkCallbackFunction, Collection, QueryRequest, SpiderCoreResponse, SpiderParams, SearchRequestParams, RequestParamsTransform } from "./config";
|
|
2
2
|
/**
|
|
3
3
|
* Generic params for core request.
|
|
4
4
|
*/
|
|
@@ -88,7 +88,7 @@ export declare class Spider {
|
|
|
88
88
|
transform(data: {
|
|
89
89
|
html: string;
|
|
90
90
|
url?: string;
|
|
91
|
-
}[], params?:
|
|
91
|
+
}[], params?: RequestParamsTransform): Promise<any>;
|
|
92
92
|
/**
|
|
93
93
|
* Extracts leads from a website.
|
|
94
94
|
* @param {string} url - The URL from which to extract contacts.
|
package/dist/client.js
CHANGED
|
@@ -77,7 +77,7 @@ class Spider {
|
|
|
77
77
|
const response = await (0, exponential_backoff_1.backOff)(() => fetch(`${config_1.APISchema["url"]}/${config_1.ApiVersion.V1}/${endpoint}`, {
|
|
78
78
|
method: "DELETE",
|
|
79
79
|
headers,
|
|
80
|
-
body: JSON.stringify({})
|
|
80
|
+
body: JSON.stringify({}),
|
|
81
81
|
}), {
|
|
82
82
|
numOfAttempts: 5,
|
|
83
83
|
});
|
|
@@ -153,8 +153,14 @@ class Spider {
|
|
|
153
153
|
* @param {object} [params={}] - Configuration parameters for the transformation.
|
|
154
154
|
* @returns {Promise<any>} The transformation result.
|
|
155
155
|
*/
|
|
156
|
-
async transform(data, params = {}) {
|
|
157
|
-
|
|
156
|
+
async transform(data, params = { data: [] }) {
|
|
157
|
+
var _a;
|
|
158
|
+
return this._apiPost(config_1.APIRoutes.Transform, {
|
|
159
|
+
...params,
|
|
160
|
+
data: params.data && Array.isArray(params.data) && ((_a = params.data) === null || _a === void 0 ? void 0 : _a.length)
|
|
161
|
+
? params.data
|
|
162
|
+
: data,
|
|
163
|
+
});
|
|
158
164
|
}
|
|
159
165
|
/**
|
|
160
166
|
* Extracts leads from a website.
|
package/dist/config.d.ts
CHANGED
|
@@ -453,6 +453,28 @@ export interface SearchRequestParams {
|
|
|
453
453
|
/** If true, prioritizes speed over completeness of results */
|
|
454
454
|
quick_search?: boolean;
|
|
455
455
|
}
|
|
456
|
+
export interface Resource {
|
|
457
|
+
/** The HTML to transform (Base64 or binary) */
|
|
458
|
+
html?: Uint8Array | string;
|
|
459
|
+
/** The content to transform (Base64 or binary) */
|
|
460
|
+
content?: Uint8Array | string;
|
|
461
|
+
/** The URL of the HTML, useful for readability transformations */
|
|
462
|
+
url?: string;
|
|
463
|
+
/** The language of the resource */
|
|
464
|
+
lang?: string;
|
|
465
|
+
}
|
|
466
|
+
export interface RequestParamsTransform {
|
|
467
|
+
/** The HTML to transform */
|
|
468
|
+
data: Resource[];
|
|
469
|
+
/** The format to return the content as */
|
|
470
|
+
return_format?: ReturnFormat | null;
|
|
471
|
+
/** Add readability preprocessing content */
|
|
472
|
+
readability?: boolean;
|
|
473
|
+
/** Clean the markdown or text for AI */
|
|
474
|
+
clean?: boolean;
|
|
475
|
+
/** Clean markdown or text, removing footers, navigation, and more */
|
|
476
|
+
clean_full?: boolean;
|
|
477
|
+
}
|
|
456
478
|
export type SpiderCoreResponse = {
|
|
457
479
|
content?: string;
|
|
458
480
|
message?: string;
|