scrapfly-sdk 0.10.4 → 0.10.5
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/esm/browserconfig.d.ts +70 -1
- package/esm/browserconfig.d.ts.map +1 -1
- package/esm/browserconfig.js +44 -1
- package/esm/client.d.ts +33 -0
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +33 -5
- package/esm/crawl.d.ts +4 -0
- package/esm/crawl.d.ts.map +1 -1
- package/esm/crawl.js +4 -0
- package/esm/crawlerresult.d.ts +7 -0
- package/esm/crawlerresult.d.ts.map +1 -1
- package/esm/errors.d.ts +43 -0
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +43 -16
- package/esm/extractionconfig.d.ts +54 -9
- package/esm/extractionconfig.d.ts.map +1 -1
- package/esm/extractionconfig.js +37 -13
- package/esm/logger.d.ts +1 -0
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +1 -0
- package/esm/main.d.ts +27 -0
- package/esm/main.d.ts.map +1 -1
- package/esm/main.js +27 -0
- package/esm/monitoringconfig.d.ts +48 -11
- package/esm/monitoringconfig.d.ts.map +1 -1
- package/esm/monitoringconfig.js +14 -0
- package/esm/result.d.ts +2 -0
- package/esm/result.d.ts.map +1 -1
- package/esm/scrapeconfig.d.ts +10 -8
- package/esm/scrapeconfig.d.ts.map +1 -1
- package/esm/scrapeconfig.js +10 -8
- package/esm/screenshotconfig.d.ts +59 -26
- package/esm/screenshotconfig.d.ts.map +1 -1
- package/esm/screenshotconfig.js +38 -26
- package/esm/webhookserver.d.ts +24 -0
- package/esm/webhookserver.d.ts.map +1 -1
- package/esm/webhookserver.js +24 -0
- package/package.json +1 -1
- package/script/browserconfig.d.ts +70 -1
- package/script/browserconfig.d.ts.map +1 -1
- package/script/browserconfig.js +44 -1
- package/script/client.d.ts +33 -0
- package/script/client.d.ts.map +1 -1
- package/script/client.js +33 -5
- package/script/crawl.d.ts +4 -0
- package/script/crawl.d.ts.map +1 -1
- package/script/crawl.js +4 -0
- package/script/crawlerresult.d.ts +7 -0
- package/script/crawlerresult.d.ts.map +1 -1
- package/script/errors.d.ts +43 -0
- package/script/errors.d.ts.map +1 -1
- package/script/errors.js +43 -16
- package/script/extractionconfig.d.ts +54 -9
- package/script/extractionconfig.d.ts.map +1 -1
- package/script/extractionconfig.js +37 -13
- package/script/logger.d.ts +1 -0
- package/script/logger.d.ts.map +1 -1
- package/script/logger.js +1 -0
- package/script/main.d.ts +27 -0
- package/script/main.d.ts.map +1 -1
- package/script/main.js +27 -0
- package/script/monitoringconfig.d.ts +48 -11
- package/script/monitoringconfig.d.ts.map +1 -1
- package/script/monitoringconfig.js +14 -0
- package/script/result.d.ts +2 -0
- package/script/result.d.ts.map +1 -1
- package/script/scrapeconfig.d.ts +10 -8
- package/script/scrapeconfig.d.ts.map +1 -1
- package/script/scrapeconfig.js +10 -8
- package/script/screenshotconfig.d.ts +59 -26
- package/script/screenshotconfig.d.ts.map +1 -1
- package/script/screenshotconfig.js +38 -26
- package/script/webhookserver.d.ts +24 -0
- package/script/webhookserver.d.ts.map +1 -1
- package/script/webhookserver.js +24 -0
- package/src/browserconfig.ts +70 -1
- package/src/client.ts +34 -6
- package/src/crawl.ts +4 -0
- package/src/crawlerresult.ts +7 -0
- package/src/errors.ts +43 -16
- package/src/extractionconfig.ts +58 -16
- package/src/logger.ts +2 -0
- package/src/main.ts +27 -0
- package/src/monitoringconfig.ts +49 -11
- package/src/result.ts +2 -0
- package/src/scrapeconfig.ts +10 -8
- package/src/screenshotconfig.ts +59 -26
- package/src/webhookserver.ts +24 -0
package/script/errors.d.ts
CHANGED
|
@@ -1,57 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for every error thrown by the Scrapfly SDK.
|
|
3
|
+
*
|
|
4
|
+
* Concrete subclasses distinguish config-level, HTTP-level, and
|
|
5
|
+
* API-specific failures so callers can catch the exact category they
|
|
6
|
+
* care about without string-matching on error messages.
|
|
7
|
+
*/
|
|
1
8
|
export declare class ScrapflyError extends Error {
|
|
9
|
+
/** Extra context carried alongside the error message (response body, request params, etc.). */
|
|
2
10
|
args: Record<string, any>;
|
|
11
|
+
/**
|
|
12
|
+
* @param message Human-readable description of the failure.
|
|
13
|
+
* @param args Optional structured context to attach to the error.
|
|
14
|
+
*/
|
|
3
15
|
constructor(message: string, args?: Record<string, any>);
|
|
4
16
|
}
|
|
17
|
+
/** Raised when a ScrapeConfig is constructed with invalid parameters. */
|
|
5
18
|
export declare class ScrapeConfigError extends ScrapflyError {
|
|
6
19
|
}
|
|
20
|
+
/** Raised when a ScreenshotConfig is constructed with invalid parameters. */
|
|
7
21
|
export declare class ScreenshotConfigError extends ScrapflyError {
|
|
8
22
|
}
|
|
23
|
+
/** Raised when an ExtractionConfig is constructed with invalid parameters. */
|
|
9
24
|
export declare class ExtractionConfigError extends ScrapflyError {
|
|
10
25
|
}
|
|
26
|
+
/** Raised when a CrawlerConfig is constructed with invalid parameters. */
|
|
11
27
|
export declare class CrawlerConfigError extends ScrapflyError {
|
|
12
28
|
}
|
|
29
|
+
/** Raised when scrape parameters cannot be encoded into a request. */
|
|
13
30
|
export declare class EncodeError extends ScrapflyError {
|
|
14
31
|
}
|
|
32
|
+
/** Raised when a response carries an unexpected or unsupported Content-Type. */
|
|
15
33
|
export declare class ContentTypeError extends ScrapflyError {
|
|
16
34
|
}
|
|
35
|
+
/** Base error for every HTTP-level failure surfaced by the SDK. */
|
|
17
36
|
export declare class HttpError extends ScrapflyError {
|
|
18
37
|
}
|
|
38
|
+
/** Raised when the upstream target returned an error to Scrapfly. */
|
|
19
39
|
export declare class UpstreamHttpError extends HttpError {
|
|
20
40
|
}
|
|
41
|
+
/** Raised when the upstream target returned a 4xx client error. */
|
|
21
42
|
export declare class UpstreamHttpClientError extends UpstreamHttpError {
|
|
22
43
|
}
|
|
44
|
+
/** Raised when the upstream target returned a 5xx server error. */
|
|
23
45
|
export declare class UpstreamHttpServerError extends UpstreamHttpClientError {
|
|
24
46
|
}
|
|
47
|
+
/** Raised when the Scrapfly API itself returned a 4xx client error. */
|
|
25
48
|
export declare class ApiHttpClientError extends HttpError {
|
|
26
49
|
}
|
|
50
|
+
/** Raised when the API key provided to the client is missing, invalid, or revoked. */
|
|
27
51
|
export declare class BadApiKeyError extends ApiHttpClientError {
|
|
28
52
|
}
|
|
53
|
+
/** Raised when the request is rate-limited (HTTP 429). */
|
|
29
54
|
export declare class TooManyRequests extends HttpError {
|
|
30
55
|
}
|
|
56
|
+
/** Raised when the Scrapfly API returned a 5xx server error. */
|
|
31
57
|
export declare class ApiHttpServerError extends HttpError {
|
|
32
58
|
}
|
|
59
|
+
/** Raised when a scrape call fails for a reason not captured by a more specific subclass. */
|
|
33
60
|
export declare class ScrapflyScrapeError extends HttpError {
|
|
34
61
|
}
|
|
62
|
+
/** Raised when proxy settings do not match an available proxy (invalid pool, unsupported country, ...). */
|
|
35
63
|
export declare class ScrapflyProxyError extends HttpError {
|
|
36
64
|
}
|
|
65
|
+
/** Raised when the request is throttled by Scrapfly (e.g. burst limits). */
|
|
37
66
|
export declare class ScrapflyThrottleError extends HttpError {
|
|
38
67
|
}
|
|
68
|
+
/** Raised when Scrapfly failed to bypass anti-scraping protection on the target. */
|
|
39
69
|
export declare class ScrapflyAspError extends HttpError {
|
|
40
70
|
}
|
|
71
|
+
/** Raised when a scheduled scrape cannot be created or fulfilled. */
|
|
41
72
|
export declare class ScrapflyScheduleError extends HttpError {
|
|
42
73
|
}
|
|
74
|
+
/** Raised when a webhook is invalid or cannot be delivered (e.g. full queue). */
|
|
43
75
|
export declare class ScrapflyWebhookError extends HttpError {
|
|
44
76
|
}
|
|
77
|
+
/** Raised when a session is accessed concurrently in a way that violates session semantics. */
|
|
45
78
|
export declare class ScrapflySessionError extends HttpError {
|
|
46
79
|
}
|
|
80
|
+
/** Raised when concurrent requests exceed the account's concurrency limit. */
|
|
47
81
|
export declare class TooManyConcurrentRequests extends HttpError {
|
|
48
82
|
}
|
|
83
|
+
/** Raised when the account is out of scrape credits. */
|
|
49
84
|
export declare class QuotaLimitReached extends HttpError {
|
|
50
85
|
}
|
|
86
|
+
/** Raised for screenshot-API-specific failures. */
|
|
51
87
|
export declare class ScreenshotApiError extends ApiHttpClientError {
|
|
52
88
|
}
|
|
89
|
+
/** Raised for extraction-API-specific failures. */
|
|
53
90
|
export declare class ExtractionApiError extends ApiHttpClientError {
|
|
54
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Raised for crawler-API-specific failures.
|
|
94
|
+
*
|
|
95
|
+
* Covers crawler job lifecycle errors such as ALREADY_STARTED,
|
|
96
|
+
* NOT_STARTED, FAILED, CANCELLED, TIMEOUT, etc.
|
|
97
|
+
*/
|
|
55
98
|
export declare class ScrapflyCrawlerError extends HttpError {
|
|
56
99
|
}
|
|
57
100
|
//# sourceMappingURL=errors.d.ts.map
|
package/script/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE1B;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;CAI5D;AAED,yEAAyE;AACzE,qBAAa,iBAAkB,SAAQ,aAAa;CAAG;AACvD,6EAA6E;AAC7E,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAC3D,8EAA8E;AAC9E,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAC3D,0EAA0E;AA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GAKG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;CAAG"}
|
package/script/errors.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ScrapflyCrawlerError = exports.ExtractionApiError = exports.ScreenshotApiError = exports.QuotaLimitReached = exports.TooManyConcurrentRequests = exports.ScrapflySessionError = exports.ScrapflyWebhookError = exports.ScrapflyScheduleError = exports.ScrapflyAspError = exports.ScrapflyThrottleError = exports.ScrapflyProxyError = exports.ScrapflyScrapeError = exports.ApiHttpServerError = exports.TooManyRequests = exports.BadApiKeyError = exports.ApiHttpClientError = exports.UpstreamHttpServerError = exports.UpstreamHttpClientError = exports.UpstreamHttpError = exports.HttpError = exports.ContentTypeError = exports.EncodeError = exports.CrawlerConfigError = exports.ExtractionConfigError = exports.ScreenshotConfigError = exports.ScrapeConfigError = exports.ScrapflyError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base class for every error thrown by the Scrapfly SDK.
|
|
6
|
+
*
|
|
7
|
+
* Concrete subclasses distinguish config-level, HTTP-level, and
|
|
8
|
+
* API-specific failures so callers can catch the exact category they
|
|
9
|
+
* care about without string-matching on error messages.
|
|
10
|
+
*/
|
|
4
11
|
class ScrapflyError extends Error {
|
|
12
|
+
/**
|
|
13
|
+
* @param message Human-readable description of the failure.
|
|
14
|
+
* @param args Optional structured context to attach to the error.
|
|
15
|
+
*/
|
|
5
16
|
constructor(message, args = {}) {
|
|
6
17
|
super(message);
|
|
18
|
+
/** Extra context carried alongside the error message (response body, request params, etc.). */
|
|
7
19
|
Object.defineProperty(this, "args", {
|
|
8
20
|
enumerable: true,
|
|
9
21
|
configurable: true,
|
|
@@ -14,97 +26,112 @@ class ScrapflyError extends Error {
|
|
|
14
26
|
}
|
|
15
27
|
}
|
|
16
28
|
exports.ScrapflyError = ScrapflyError;
|
|
17
|
-
|
|
29
|
+
/** Raised when a ScrapeConfig is constructed with invalid parameters. */
|
|
18
30
|
class ScrapeConfigError extends ScrapflyError {
|
|
19
31
|
}
|
|
20
32
|
exports.ScrapeConfigError = ScrapeConfigError;
|
|
21
|
-
|
|
33
|
+
/** Raised when a ScreenshotConfig is constructed with invalid parameters. */
|
|
22
34
|
class ScreenshotConfigError extends ScrapflyError {
|
|
23
35
|
}
|
|
24
36
|
exports.ScreenshotConfigError = ScreenshotConfigError;
|
|
25
|
-
|
|
37
|
+
/** Raised when an ExtractionConfig is constructed with invalid parameters. */
|
|
26
38
|
class ExtractionConfigError extends ScrapflyError {
|
|
27
39
|
}
|
|
28
40
|
exports.ExtractionConfigError = ExtractionConfigError;
|
|
29
|
-
|
|
41
|
+
/** Raised when a CrawlerConfig is constructed with invalid parameters. */
|
|
30
42
|
class CrawlerConfigError extends ScrapflyError {
|
|
31
43
|
}
|
|
32
44
|
exports.CrawlerConfigError = CrawlerConfigError;
|
|
33
|
-
|
|
45
|
+
/** Raised when scrape parameters cannot be encoded into a request. */
|
|
34
46
|
class EncodeError extends ScrapflyError {
|
|
35
47
|
}
|
|
36
48
|
exports.EncodeError = EncodeError;
|
|
49
|
+
/** Raised when a response carries an unexpected or unsupported Content-Type. */
|
|
37
50
|
class ContentTypeError extends ScrapflyError {
|
|
38
51
|
}
|
|
39
52
|
exports.ContentTypeError = ContentTypeError;
|
|
40
|
-
|
|
53
|
+
/** Base error for every HTTP-level failure surfaced by the SDK. */
|
|
41
54
|
class HttpError extends ScrapflyError {
|
|
42
55
|
}
|
|
43
56
|
exports.HttpError = HttpError;
|
|
57
|
+
/** Raised when the upstream target returned an error to Scrapfly. */
|
|
44
58
|
class UpstreamHttpError extends HttpError {
|
|
45
59
|
}
|
|
46
60
|
exports.UpstreamHttpError = UpstreamHttpError;
|
|
61
|
+
/** Raised when the upstream target returned a 4xx client error. */
|
|
47
62
|
class UpstreamHttpClientError extends UpstreamHttpError {
|
|
48
63
|
}
|
|
49
64
|
exports.UpstreamHttpClientError = UpstreamHttpClientError;
|
|
65
|
+
/** Raised when the upstream target returned a 5xx server error. */
|
|
50
66
|
class UpstreamHttpServerError extends UpstreamHttpClientError {
|
|
51
67
|
}
|
|
52
68
|
exports.UpstreamHttpServerError = UpstreamHttpServerError;
|
|
69
|
+
/** Raised when the Scrapfly API itself returned a 4xx client error. */
|
|
53
70
|
class ApiHttpClientError extends HttpError {
|
|
54
71
|
}
|
|
55
72
|
exports.ApiHttpClientError = ApiHttpClientError;
|
|
56
|
-
|
|
73
|
+
/** Raised when the API key provided to the client is missing, invalid, or revoked. */
|
|
57
74
|
class BadApiKeyError extends ApiHttpClientError {
|
|
58
75
|
}
|
|
59
76
|
exports.BadApiKeyError = BadApiKeyError;
|
|
77
|
+
/** Raised when the request is rate-limited (HTTP 429). */
|
|
60
78
|
class TooManyRequests extends HttpError {
|
|
61
79
|
}
|
|
62
80
|
exports.TooManyRequests = TooManyRequests;
|
|
81
|
+
/** Raised when the Scrapfly API returned a 5xx server error. */
|
|
63
82
|
class ApiHttpServerError extends HttpError {
|
|
64
83
|
}
|
|
65
84
|
exports.ApiHttpServerError = ApiHttpServerError;
|
|
85
|
+
/** Raised when a scrape call fails for a reason not captured by a more specific subclass. */
|
|
66
86
|
class ScrapflyScrapeError extends HttpError {
|
|
67
87
|
}
|
|
68
88
|
exports.ScrapflyScrapeError = ScrapflyScrapeError;
|
|
69
|
-
|
|
89
|
+
/** Raised when proxy settings do not match an available proxy (invalid pool, unsupported country, ...). */
|
|
70
90
|
class ScrapflyProxyError extends HttpError {
|
|
71
91
|
}
|
|
72
92
|
exports.ScrapflyProxyError = ScrapflyProxyError;
|
|
93
|
+
/** Raised when the request is throttled by Scrapfly (e.g. burst limits). */
|
|
73
94
|
class ScrapflyThrottleError extends HttpError {
|
|
74
95
|
}
|
|
75
96
|
exports.ScrapflyThrottleError = ScrapflyThrottleError;
|
|
76
|
-
|
|
97
|
+
/** Raised when Scrapfly failed to bypass anti-scraping protection on the target. */
|
|
77
98
|
class ScrapflyAspError extends HttpError {
|
|
78
99
|
}
|
|
79
100
|
exports.ScrapflyAspError = ScrapflyAspError;
|
|
101
|
+
/** Raised when a scheduled scrape cannot be created or fulfilled. */
|
|
80
102
|
class ScrapflyScheduleError extends HttpError {
|
|
81
103
|
}
|
|
82
104
|
exports.ScrapflyScheduleError = ScrapflyScheduleError;
|
|
83
|
-
|
|
105
|
+
/** Raised when a webhook is invalid or cannot be delivered (e.g. full queue). */
|
|
84
106
|
class ScrapflyWebhookError extends HttpError {
|
|
85
107
|
}
|
|
86
108
|
exports.ScrapflyWebhookError = ScrapflyWebhookError;
|
|
87
|
-
|
|
109
|
+
/** Raised when a session is accessed concurrently in a way that violates session semantics. */
|
|
88
110
|
class ScrapflySessionError extends HttpError {
|
|
89
111
|
}
|
|
90
112
|
exports.ScrapflySessionError = ScrapflySessionError;
|
|
91
|
-
|
|
113
|
+
/** Raised when concurrent requests exceed the account's concurrency limit. */
|
|
92
114
|
class TooManyConcurrentRequests extends HttpError {
|
|
93
115
|
}
|
|
94
116
|
exports.TooManyConcurrentRequests = TooManyConcurrentRequests;
|
|
95
|
-
|
|
117
|
+
/** Raised when the account is out of scrape credits. */
|
|
96
118
|
class QuotaLimitReached extends HttpError {
|
|
97
119
|
}
|
|
98
120
|
exports.QuotaLimitReached = QuotaLimitReached;
|
|
99
|
-
|
|
121
|
+
/** Raised for screenshot-API-specific failures. */
|
|
100
122
|
class ScreenshotApiError extends ApiHttpClientError {
|
|
101
123
|
}
|
|
102
124
|
exports.ScreenshotApiError = ScreenshotApiError;
|
|
103
|
-
|
|
125
|
+
/** Raised for extraction-API-specific failures. */
|
|
104
126
|
class ExtractionApiError extends ApiHttpClientError {
|
|
105
127
|
}
|
|
106
128
|
exports.ExtractionApiError = ExtractionApiError;
|
|
107
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Raised for crawler-API-specific failures.
|
|
131
|
+
*
|
|
132
|
+
* Covers crawler job lifecycle errors such as ALREADY_STARTED,
|
|
133
|
+
* NOT_STARTED, FAILED, CANCELLED, TIMEOUT, etc.
|
|
134
|
+
*/
|
|
108
135
|
class ScrapflyCrawlerError extends HttpError {
|
|
109
136
|
}
|
|
110
137
|
exports.ScrapflyCrawlerError = ScrapflyCrawlerError;
|
|
@@ -1,50 +1,95 @@
|
|
|
1
|
+
/** Compression format declared for documents submitted to the Extraction API. */
|
|
1
2
|
export declare enum CompressionFormat {
|
|
2
|
-
/**
|
|
3
|
-
Document compression format.
|
|
4
|
-
|
|
5
|
-
Attributes:
|
|
6
|
-
GZIP: gzip format.
|
|
7
|
-
ZSTD: zstd format.
|
|
8
|
-
DEFLATE: deflate.
|
|
9
|
-
"""
|
|
10
|
-
*/
|
|
3
|
+
/** gzip compression. */
|
|
11
4
|
GZIP = "gzip",
|
|
5
|
+
/** zstd compression. */
|
|
12
6
|
ZSTD = "zstd",
|
|
7
|
+
/** DEFLATE compression. */
|
|
13
8
|
DEFLATE = "deflate"
|
|
14
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* User-facing options accepted by {@link ExtractionConfig}. See the
|
|
12
|
+
* [Extraction API reference](https://scrapfly.io/docs/extraction-api)
|
|
13
|
+
* for the authoritative list of valid values.
|
|
14
|
+
*/
|
|
15
15
|
type ExtractionConfigOptions = {
|
|
16
|
+
/** Document body to extract from. */
|
|
16
17
|
body: string;
|
|
18
|
+
/** Content-Type of the body (e.g. "text/html"). */
|
|
17
19
|
content_type: string;
|
|
20
|
+
/** URL associated with the document (used for link resolution). */
|
|
18
21
|
url?: string;
|
|
22
|
+
/** Character set of the document. */
|
|
19
23
|
charset?: string;
|
|
24
|
+
/** Name of a saved extraction template. */
|
|
20
25
|
extraction_template?: string;
|
|
26
|
+
/** Inline extraction template, used instead of a saved one. */
|
|
21
27
|
extraction_ephemeral_template?: object;
|
|
28
|
+
/** Natural-language prompt for LLM-based extraction. */
|
|
22
29
|
extraction_prompt?: string;
|
|
30
|
+
/** Override the LLM model used for prompt-based extraction. */
|
|
23
31
|
extraction_model?: string;
|
|
32
|
+
/** Whether the provided body is already compressed. */
|
|
24
33
|
is_document_compressed?: boolean;
|
|
34
|
+
/** Compression format of the body. See {@link CompressionFormat}. */
|
|
25
35
|
document_compression_format?: 'gzip' | 'zstd' | 'deflate' | CompressionFormat;
|
|
36
|
+
/** Webhook name to notify when extraction completes. */
|
|
26
37
|
webhook?: string;
|
|
38
|
+
/** Request timeout in milliseconds. */
|
|
27
39
|
timeout?: number;
|
|
40
|
+
/** @deprecated Use {@link extraction_template} instead. */
|
|
28
41
|
template?: string;
|
|
42
|
+
/** @deprecated Use {@link extraction_ephemeral_template} instead. */
|
|
29
43
|
ephemeral_template?: object;
|
|
30
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for an Extraction API call. Holds the document to
|
|
47
|
+
* extract from and the template/prompt/model that should drive the
|
|
48
|
+
* extraction.
|
|
49
|
+
*/
|
|
31
50
|
export declare class ExtractionConfig {
|
|
51
|
+
/** Document body. */
|
|
32
52
|
body: string | Uint8Array;
|
|
53
|
+
/** Content-Type of the body. */
|
|
33
54
|
content_type: string;
|
|
55
|
+
/** URL associated with the document. */
|
|
34
56
|
url?: string;
|
|
57
|
+
/** Character set of the document. */
|
|
35
58
|
charset?: string;
|
|
59
|
+
/** Saved extraction template name. */
|
|
36
60
|
extraction_template?: string;
|
|
61
|
+
/** Inline extraction template. */
|
|
37
62
|
extraction_ephemeral_template?: object;
|
|
63
|
+
/** Natural-language extraction prompt. */
|
|
38
64
|
extraction_prompt?: string;
|
|
65
|
+
/** LLM model override for prompt-based extraction. */
|
|
39
66
|
extraction_model?: string;
|
|
67
|
+
/** Whether the body is pre-compressed. */
|
|
40
68
|
is_document_compressed?: boolean;
|
|
69
|
+
/** Compression format of the body. */
|
|
41
70
|
document_compression_format?: 'gzip' | 'zstd' | 'deflate' | CompressionFormat;
|
|
71
|
+
/** Webhook name to notify on completion. */
|
|
42
72
|
webhook?: string;
|
|
73
|
+
/** Request timeout in milliseconds. */
|
|
43
74
|
timeout?: number;
|
|
75
|
+
/** @deprecated Use {@link extraction_template} instead. */
|
|
44
76
|
template?: string;
|
|
77
|
+
/** @deprecated Use {@link extraction_ephemeral_template} instead. */
|
|
45
78
|
ephemeral_template?: object;
|
|
79
|
+
/**
|
|
80
|
+
* @param options See {@link ExtractionConfigOptions}.
|
|
81
|
+
* @throws {@link errors.ExtractionConfigError} if an unknown option is supplied.
|
|
82
|
+
*/
|
|
46
83
|
constructor(options: ExtractionConfigOptions);
|
|
47
84
|
private validateOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Encode this config as the query-string parameters sent to the
|
|
87
|
+
* Extraction API.
|
|
88
|
+
*
|
|
89
|
+
* @param options.key Scrapfly API key.
|
|
90
|
+
* @returns A record suitable for `URLSearchParams` construction.
|
|
91
|
+
* @throws {@link ExtractionConfigError} on conflicting or incompatible options.
|
|
92
|
+
*/
|
|
48
93
|
toApiParams(options: {
|
|
49
94
|
key: string;
|
|
50
95
|
}): Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractionconfig.d.ts","sourceRoot":"","sources":["../src/extractionconfig.ts"],"names":[],"mappings":"AAIA,oBAAY,iBAAiB;IAC3B
|
|
1
|
+
{"version":3,"file":"extractionconfig.d.ts","sourceRoot":"","sources":["../src/extractionconfig.ts"],"names":[],"mappings":"AAIA,iFAAiF;AACjF,oBAAY,iBAAiB;IAC3B,wBAAwB;IACxB,IAAI,SAAS;IACb,wBAAwB;IACxB,IAAI,SAAS;IACb,2BAA2B;IAC3B,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,KAAK,uBAAuB,GAAG;IAC7B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC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;IAEjB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;gBACS,OAAO,EAAE,uBAAuB;IAyC5C,OAAO,CAAC,eAAe;IASvB;;;;;;;OAOG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAmE3D"}
|
|
@@ -27,102 +27,119 @@ exports.ExtractionConfig = exports.CompressionFormat = void 0;
|
|
|
27
27
|
const errors = __importStar(require("./errors.js"));
|
|
28
28
|
const utils_js_1 = require("./utils.js");
|
|
29
29
|
const errors_js_1 = require("./errors.js");
|
|
30
|
+
/** Compression format declared for documents submitted to the Extraction API. */
|
|
30
31
|
var CompressionFormat;
|
|
31
32
|
(function (CompressionFormat) {
|
|
32
|
-
/**
|
|
33
|
-
Document compression format.
|
|
34
|
-
|
|
35
|
-
Attributes:
|
|
36
|
-
GZIP: gzip format.
|
|
37
|
-
ZSTD: zstd format.
|
|
38
|
-
DEFLATE: deflate.
|
|
39
|
-
"""
|
|
40
|
-
*/
|
|
33
|
+
/** gzip compression. */
|
|
41
34
|
CompressionFormat["GZIP"] = "gzip";
|
|
35
|
+
/** zstd compression. */
|
|
42
36
|
CompressionFormat["ZSTD"] = "zstd";
|
|
37
|
+
/** DEFLATE compression. */
|
|
43
38
|
CompressionFormat["DEFLATE"] = "deflate";
|
|
44
39
|
})(CompressionFormat || (exports.CompressionFormat = CompressionFormat = {}));
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for an Extraction API call. Holds the document to
|
|
42
|
+
* extract from and the template/prompt/model that should drive the
|
|
43
|
+
* extraction.
|
|
44
|
+
*/
|
|
45
45
|
class ExtractionConfig {
|
|
46
|
+
/**
|
|
47
|
+
* @param options See {@link ExtractionConfigOptions}.
|
|
48
|
+
* @throws {@link errors.ExtractionConfigError} if an unknown option is supplied.
|
|
49
|
+
*/
|
|
46
50
|
constructor(options) {
|
|
51
|
+
/** Document body. */
|
|
47
52
|
Object.defineProperty(this, "body", {
|
|
48
53
|
enumerable: true,
|
|
49
54
|
configurable: true,
|
|
50
55
|
writable: true,
|
|
51
56
|
value: void 0
|
|
52
57
|
});
|
|
58
|
+
/** Content-Type of the body. */
|
|
53
59
|
Object.defineProperty(this, "content_type", {
|
|
54
60
|
enumerable: true,
|
|
55
61
|
configurable: true,
|
|
56
62
|
writable: true,
|
|
57
63
|
value: void 0
|
|
58
64
|
});
|
|
65
|
+
/** URL associated with the document. */
|
|
59
66
|
Object.defineProperty(this, "url", {
|
|
60
67
|
enumerable: true,
|
|
61
68
|
configurable: true,
|
|
62
69
|
writable: true,
|
|
63
70
|
value: void 0
|
|
64
71
|
});
|
|
72
|
+
/** Character set of the document. */
|
|
65
73
|
Object.defineProperty(this, "charset", {
|
|
66
74
|
enumerable: true,
|
|
67
75
|
configurable: true,
|
|
68
76
|
writable: true,
|
|
69
77
|
value: void 0
|
|
70
78
|
});
|
|
79
|
+
/** Saved extraction template name. */
|
|
71
80
|
Object.defineProperty(this, "extraction_template", {
|
|
72
81
|
enumerable: true,
|
|
73
82
|
configurable: true,
|
|
74
83
|
writable: true,
|
|
75
84
|
value: void 0
|
|
76
|
-
});
|
|
85
|
+
});
|
|
86
|
+
/** Inline extraction template. */
|
|
77
87
|
Object.defineProperty(this, "extraction_ephemeral_template", {
|
|
78
88
|
enumerable: true,
|
|
79
89
|
configurable: true,
|
|
80
90
|
writable: true,
|
|
81
91
|
value: void 0
|
|
82
|
-
});
|
|
92
|
+
});
|
|
93
|
+
/** Natural-language extraction prompt. */
|
|
83
94
|
Object.defineProperty(this, "extraction_prompt", {
|
|
84
95
|
enumerable: true,
|
|
85
96
|
configurable: true,
|
|
86
97
|
writable: true,
|
|
87
98
|
value: void 0
|
|
88
99
|
});
|
|
100
|
+
/** LLM model override for prompt-based extraction. */
|
|
89
101
|
Object.defineProperty(this, "extraction_model", {
|
|
90
102
|
enumerable: true,
|
|
91
103
|
configurable: true,
|
|
92
104
|
writable: true,
|
|
93
105
|
value: void 0
|
|
94
106
|
});
|
|
107
|
+
/** Whether the body is pre-compressed. */
|
|
95
108
|
Object.defineProperty(this, "is_document_compressed", {
|
|
96
109
|
enumerable: true,
|
|
97
110
|
configurable: true,
|
|
98
111
|
writable: true,
|
|
99
112
|
value: void 0
|
|
100
113
|
});
|
|
114
|
+
/** Compression format of the body. */
|
|
101
115
|
Object.defineProperty(this, "document_compression_format", {
|
|
102
116
|
enumerable: true,
|
|
103
117
|
configurable: true,
|
|
104
118
|
writable: true,
|
|
105
119
|
value: void 0
|
|
106
120
|
});
|
|
121
|
+
/** Webhook name to notify on completion. */
|
|
107
122
|
Object.defineProperty(this, "webhook", {
|
|
108
123
|
enumerable: true,
|
|
109
124
|
configurable: true,
|
|
110
125
|
writable: true,
|
|
111
126
|
value: void 0
|
|
112
127
|
});
|
|
128
|
+
/** Request timeout in milliseconds. */
|
|
113
129
|
Object.defineProperty(this, "timeout", {
|
|
114
130
|
enumerable: true,
|
|
115
131
|
configurable: true,
|
|
116
132
|
writable: true,
|
|
117
133
|
value: void 0
|
|
118
134
|
});
|
|
119
|
-
|
|
135
|
+
/** @deprecated Use {@link extraction_template} instead. */
|
|
120
136
|
Object.defineProperty(this, "template", {
|
|
121
137
|
enumerable: true,
|
|
122
138
|
configurable: true,
|
|
123
139
|
writable: true,
|
|
124
140
|
value: void 0
|
|
125
141
|
});
|
|
142
|
+
/** @deprecated Use {@link extraction_ephemeral_template} instead. */
|
|
126
143
|
Object.defineProperty(this, "ephemeral_template", {
|
|
127
144
|
enumerable: true,
|
|
128
145
|
configurable: true,
|
|
@@ -169,11 +186,18 @@ class ExtractionConfig {
|
|
|
169
186
|
}
|
|
170
187
|
}
|
|
171
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Encode this config as the query-string parameters sent to the
|
|
191
|
+
* Extraction API.
|
|
192
|
+
*
|
|
193
|
+
* @param options.key Scrapfly API key.
|
|
194
|
+
* @returns A record suitable for `URLSearchParams` construction.
|
|
195
|
+
* @throws {@link ExtractionConfigError} on conflicting or incompatible options.
|
|
196
|
+
*/
|
|
172
197
|
toApiParams(options) {
|
|
173
198
|
const params = {
|
|
174
199
|
key: options.key,
|
|
175
200
|
};
|
|
176
|
-
// params.body = this.body;
|
|
177
201
|
params.content_type = this.content_type;
|
|
178
202
|
if (this.url) {
|
|
179
203
|
params.url = encodeURI(this.url);
|
package/script/logger.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ declare class Logger {
|
|
|
15
15
|
setLevel(level: string): void;
|
|
16
16
|
}
|
|
17
17
|
export default Logger;
|
|
18
|
+
/** Shared logger instance used by the SDK. Callers can set its log level to silence or unmute output. */
|
|
18
19
|
export declare const log: Logger;
|
|
19
20
|
//# sourceMappingURL=logger.d.ts.map
|
package/script/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,aAAK,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,cAAM,MAAM;IACV,OAAO,CAAC,KAAK,CAAW;IACjB,IAAI,EAAE,MAAM,CAAC;gBAER,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,QAAwB;IAKzD,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAO9B;AAED,eAAe,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,aAAK,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,cAAM,MAAM;IACV,OAAO,CAAC,KAAK,CAAW;IACjB,IAAI,EAAE,MAAM,CAAC;gBAER,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,QAAwB;IAKzD,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAO9B;AAED,eAAe,MAAM,CAAC;AAEtB,yGAAyG;AACzG,eAAO,MAAM,GAAG,EAAE,MAA+B,CAAC"}
|
package/script/logger.js
CHANGED
package/script/main.d.ts
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Scrapfly SDK for TypeScript / JavaScript
|
|
3
|
+
*
|
|
4
|
+
* Official client library for the [Scrapfly](https://scrapfly.io) web
|
|
5
|
+
* scraping API. Provides typed wrappers around the Scrape, Screenshot,
|
|
6
|
+
* Extraction, Crawler, Monitoring, and Cloud Browser APIs.
|
|
7
|
+
*
|
|
8
|
+
* ## Quick start
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { ScrapflyClient, ScrapeConfig } from '@scrapfly/scrapfly-sdk';
|
|
12
|
+
*
|
|
13
|
+
* const client = new ScrapflyClient({ key: 'your-api-key' });
|
|
14
|
+
* const result = await client.scrape(new ScrapeConfig({
|
|
15
|
+
* url: 'https://web-scraping.dev/products',
|
|
16
|
+
* render_js: true,
|
|
17
|
+
* asp: true,
|
|
18
|
+
* }));
|
|
19
|
+
* console.log(result.content);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* See the [Scrapfly docs](https://scrapfly.io/docs) for the full API
|
|
23
|
+
* reference.
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
1
27
|
export { ScrapflyClient } from './client.js';
|
|
2
28
|
export { Format as ScrapeFormat, FormatOption as ScrapeFormatOptions, ScrapeConfig, ScreenshotFlags, } from './scrapeconfig.js';
|
|
3
29
|
export { Format as ScreenshotFormat, Options as ScreenshotOptions, ScreenshotConfig, VisionDeficiency, } from './screenshotconfig.js';
|
|
4
30
|
export { ExtractionConfig } from './extractionconfig.js';
|
|
5
31
|
export { BrowserConfig, ProxyPool, OperatingSystem } from './browserconfig.js';
|
|
6
32
|
export type { BrowserConfigOptions } from './browserconfig.js';
|
|
33
|
+
/** Namespace of every error class the SDK can throw. See {@link ScrapflyError}. */
|
|
7
34
|
export * as errors from './errors.js';
|
|
8
35
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
9
36
|
export type { AccountData, ClassifyOptions, ClassifyResult, ConfigData, ContextData, ResultData, ScreenshotMetadata } from './result.js';
|
package/script/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,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EACpB,wBAAwB,EACxB,gBAAgB,EAChB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/script/main.js
CHANGED
|
@@ -24,6 +24,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.verifySignature = exports.createServer = exports.log = exports.parseCrawlerWebhook = exports.CrawlerUrls = exports.CrawlerStatus = exports.CrawlerContents = exports.CrawlerArtifact = exports.Crawl = exports.CrawlerConfig = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.OperatingSystem = exports.ProxyPool = exports.BrowserConfig = exports.ExtractionConfig = exports.VisionDeficiency = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* # Scrapfly SDK for TypeScript / JavaScript
|
|
29
|
+
*
|
|
30
|
+
* Official client library for the [Scrapfly](https://scrapfly.io) web
|
|
31
|
+
* scraping API. Provides typed wrappers around the Scrape, Screenshot,
|
|
32
|
+
* Extraction, Crawler, Monitoring, and Cloud Browser APIs.
|
|
33
|
+
*
|
|
34
|
+
* ## Quick start
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { ScrapflyClient, ScrapeConfig } from '@scrapfly/scrapfly-sdk';
|
|
38
|
+
*
|
|
39
|
+
* const client = new ScrapflyClient({ key: 'your-api-key' });
|
|
40
|
+
* const result = await client.scrape(new ScrapeConfig({
|
|
41
|
+
* url: 'https://web-scraping.dev/products',
|
|
42
|
+
* render_js: true,
|
|
43
|
+
* asp: true,
|
|
44
|
+
* }));
|
|
45
|
+
* console.log(result.content);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* See the [Scrapfly docs](https://scrapfly.io/docs) for the full API
|
|
49
|
+
* reference.
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
27
53
|
var client_js_1 = require("./client.js");
|
|
28
54
|
Object.defineProperty(exports, "ScrapflyClient", { enumerable: true, get: function () { return client_js_1.ScrapflyClient; } });
|
|
29
55
|
var scrapeconfig_js_1 = require("./scrapeconfig.js");
|
|
@@ -42,6 +68,7 @@ var browserconfig_js_1 = require("./browserconfig.js");
|
|
|
42
68
|
Object.defineProperty(exports, "BrowserConfig", { enumerable: true, get: function () { return browserconfig_js_1.BrowserConfig; } });
|
|
43
69
|
Object.defineProperty(exports, "ProxyPool", { enumerable: true, get: function () { return browserconfig_js_1.ProxyPool; } });
|
|
44
70
|
Object.defineProperty(exports, "OperatingSystem", { enumerable: true, get: function () { return browserconfig_js_1.OperatingSystem; } });
|
|
71
|
+
/** Namespace of every error class the SDK can throw. See {@link ScrapflyError}. */
|
|
45
72
|
exports.errors = __importStar(require("./errors.js"));
|
|
46
73
|
var result_js_1 = require("./result.js");
|
|
47
74
|
Object.defineProperty(exports, "ExtractionResult", { enumerable: true, get: function () { return result_js_1.ExtractionResult; } });
|