@crawlbrulee/sdk 1.1.0 → 1.2.1
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/README.md +40 -26
- package/dist/index.cjs +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -42
- package/dist/index.d.ts +61 -42
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -96,21 +96,19 @@ type BillingEngine = 'http' | 'browser' | 'screenshot' | 'cache';
|
|
|
96
96
|
* webhooks.
|
|
97
97
|
*
|
|
98
98
|
* The response explains its own price:
|
|
99
|
-
* `total_credit_cost = engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost`.
|
|
99
|
+
* `total_credit_cost = engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost + zero_data_retention_credit_cost`.
|
|
100
100
|
*
|
|
101
|
-
* The
|
|
102
|
-
*
|
|
103
|
-
* fall back to the deprecated name: `usage.total_credit_cost ?? usage.credits`.
|
|
101
|
+
* The `*_credit_cost` / `proxy_multiplier` fields are optional in this type
|
|
102
|
+
* because older api versions do not send them.
|
|
104
103
|
*/
|
|
105
104
|
interface Usage {
|
|
106
105
|
/**
|
|
107
106
|
* Credits charged for this request. Always equals
|
|
108
|
-
* `engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost`.
|
|
107
|
+
* `engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost + zero_data_retention_credit_cost`.
|
|
109
108
|
* `0` when nothing is billed: a cache hit, or a page whose status is not
|
|
110
109
|
* billed (see `page_status_code` on the scrape result).
|
|
111
110
|
*
|
|
112
|
-
* Optional only because older api versions do not send it
|
|
113
|
-
* {@link credits} when it is missing.
|
|
111
|
+
* Optional only because older api versions do not send it.
|
|
114
112
|
*/
|
|
115
113
|
total_credit_cost?: number;
|
|
116
114
|
/**
|
|
@@ -130,6 +128,12 @@ interface Usage {
|
|
|
130
128
|
* however many slices it made), otherwise `0`.
|
|
131
129
|
*/
|
|
132
130
|
screenshot_slicing_credit_cost?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Credits added by zero data retention: `1` on a billed, fresh result,
|
|
133
|
+
* otherwise `0`. Absent on an older api version; read it as
|
|
134
|
+
* `usage.zero_data_retention_credit_cost ?? 0`.
|
|
135
|
+
*/
|
|
136
|
+
zero_data_retention_credit_cost?: number;
|
|
133
137
|
/**
|
|
134
138
|
* Engine the delivered result was billed at: `http`, `browser`,
|
|
135
139
|
* `screenshot`, or `cache` (served from cache).
|
|
@@ -140,22 +144,6 @@ interface Usage {
|
|
|
140
144
|
* multiplies the engine base by 5.
|
|
141
145
|
*/
|
|
142
146
|
proxy: ResolvedProxyTier;
|
|
143
|
-
/**
|
|
144
|
-
* Credits charged for this request. Same value as {@link total_credit_cost}.
|
|
145
|
-
*
|
|
146
|
-
* @deprecated Use {@link total_credit_cost}, which always has the same value.
|
|
147
|
-
* This field will be removed in a future version.
|
|
148
|
-
*/
|
|
149
|
-
credits: number;
|
|
150
|
-
/**
|
|
151
|
-
* Screenshot slicing add-on: `1` when slices were made on this request,
|
|
152
|
-
* otherwise `0`. Same value as {@link screenshot_slicing_credit_cost}.
|
|
153
|
-
*
|
|
154
|
-
* @deprecated Use {@link screenshot_slicing_credit_cost}, which always has
|
|
155
|
-
* the same value. Despite its name this is a 0/1 charge, not a count of
|
|
156
|
-
* slices. This field will be removed in a future version.
|
|
157
|
-
*/
|
|
158
|
-
screenshot_slices: number;
|
|
159
147
|
}
|
|
160
148
|
/**
|
|
161
149
|
* Response envelope `response_meta` carried by scrape responses and async-status
|
|
@@ -226,7 +214,7 @@ interface ScreenshotRequest {
|
|
|
226
214
|
* Machine-readable error names returned by the crawlbrulee API. Stable
|
|
227
215
|
* identifiers — clients can switch on them.
|
|
228
216
|
*/
|
|
229
|
-
type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable';
|
|
217
|
+
type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable' | 'zero_data_retention_not_enabled';
|
|
230
218
|
/** Reason a usage allocation was denied (when `error_name = usage_allocation_error`). */
|
|
231
219
|
type UsageAllocationReason = 'credit_limit' | 'concurrency_limit' | 'duplicate_reservation' | 'internal_error';
|
|
232
220
|
/** Snapshot of the org's current usage at the moment the error was raised. */
|
|
@@ -391,6 +379,13 @@ interface ScrapeRequest {
|
|
|
391
379
|
proxy?: ProxyTier;
|
|
392
380
|
/** Optional locale + country emulation. */
|
|
393
381
|
location?: ScrapeLocation;
|
|
382
|
+
/**
|
|
383
|
+
* Keeps the result out of the shared cache; anything stored to deliver it is
|
|
384
|
+
* kept for 24 hours, then deleted. Adds 1 credit. Must be enabled for your
|
|
385
|
+
* organization, or the request fails with {@link ZeroDataRetentionNotEnabledError}.
|
|
386
|
+
* See https://crawlbrulee.com/docs/zero-data-retention.
|
|
387
|
+
*/
|
|
388
|
+
zero_data_retention?: boolean;
|
|
394
389
|
}
|
|
395
390
|
/**
|
|
396
391
|
* Per-job completion webhook, attached when submitting an ASYNC scrape via
|
|
@@ -449,7 +444,10 @@ interface ScreenshotProperties {
|
|
|
449
444
|
interface ScreenshotSlice {
|
|
450
445
|
/** 0-based row index of this slice. */
|
|
451
446
|
row_nr: number;
|
|
452
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* Signed URL to download this slice image. Expires 24 hours after the scrape (for an async scrape, 24 hours after
|
|
449
|
+
* it was submitted). Download the image; don't keep the link.
|
|
450
|
+
*/
|
|
453
451
|
url: string;
|
|
454
452
|
type: 'slice';
|
|
455
453
|
/** Image-level properties of this slice. */
|
|
@@ -457,7 +455,10 @@ interface ScreenshotSlice {
|
|
|
457
455
|
}
|
|
458
456
|
/** Result block returned when a screenshot was requested. */
|
|
459
457
|
interface ScreenshotResult {
|
|
460
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Signed URL to download the full screenshot image. Expires 24 hours after the scrape (for an async scrape, 24 hours
|
|
460
|
+
* after it was submitted). Download the image; don't keep the link.
|
|
461
|
+
*/
|
|
461
462
|
url: string;
|
|
462
463
|
/** Capture mode that was used. */
|
|
463
464
|
type: ScreenshotType;
|
|
@@ -693,6 +694,13 @@ interface MapRequest {
|
|
|
693
694
|
limit?: number;
|
|
694
695
|
/** Optional country emulation. */
|
|
695
696
|
location?: MapLocation;
|
|
697
|
+
/**
|
|
698
|
+
* Keeps the result out of the shared cache; anything stored to deliver it is
|
|
699
|
+
* kept for 24 hours, then deleted. Adds 1 credit. Must be enabled for your
|
|
700
|
+
* organization, or the request fails with {@link ZeroDataRetentionNotEnabledError}.
|
|
701
|
+
* See https://crawlbrulee.com/docs/zero-data-retention.
|
|
702
|
+
*/
|
|
703
|
+
zero_data_retention?: boolean;
|
|
696
704
|
}
|
|
697
705
|
/** Single discovered URL in a map result. */
|
|
698
706
|
interface MapLinkItem {
|
|
@@ -767,21 +775,19 @@ type MapBillingEngine = 'http' | 'cache';
|
|
|
767
775
|
/**
|
|
768
776
|
* Usage accounting returned by the map endpoint. Map requests make no
|
|
769
777
|
* screenshots, so there is no slicing add-on:
|
|
770
|
-
* `total_credit_cost = engine_credit_cost × proxy_multiplier`.
|
|
778
|
+
* `total_credit_cost = engine_credit_cost × proxy_multiplier + zero_data_retention_credit_cost`.
|
|
771
779
|
*
|
|
772
780
|
* The `*_credit_cost` / `proxy_multiplier` fields are optional in this type
|
|
773
|
-
* because older api versions do not send them.
|
|
774
|
-
* back to the deprecated name: `usage.total_credit_cost ?? usage.credits`.
|
|
781
|
+
* because older api versions do not send them.
|
|
775
782
|
*/
|
|
776
783
|
interface MapUsage {
|
|
777
784
|
/**
|
|
778
785
|
* Credits charged for this map request. Always equals
|
|
779
|
-
* `engine_credit_cost × proxy_multiplier`. `0` for a cache hit, and for an
|
|
786
|
+
* `engine_credit_cost × proxy_multiplier + zero_data_retention_credit_cost`. `0` for a cache hit, and for an
|
|
780
787
|
* empty map when the site answered only with statuses we don't bill (a `5xx`,
|
|
781
788
|
* for example) or not at all.
|
|
782
789
|
*
|
|
783
|
-
* Optional only because older api versions do not send it
|
|
784
|
-
* {@link credits} when it is missing.
|
|
790
|
+
* Optional only because older api versions do not send it.
|
|
785
791
|
*/
|
|
786
792
|
total_credit_cost?: number;
|
|
787
793
|
/**
|
|
@@ -794,18 +800,16 @@ interface MapUsage {
|
|
|
794
800
|
* for `advanced`. Always reported, even when the engine cost is `0`.
|
|
795
801
|
*/
|
|
796
802
|
proxy_multiplier?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Credits added by zero data retention: `1` on a billed, fresh result,
|
|
805
|
+
* otherwise `0`. Absent on an older api version; read it as
|
|
806
|
+
* `usage.zero_data_retention_credit_cost ?? 0`.
|
|
807
|
+
*/
|
|
808
|
+
zero_data_retention_credit_cost?: number;
|
|
797
809
|
/** `http` for fresh discovery or `cache` for a cached result. */
|
|
798
810
|
engine: MapBillingEngine;
|
|
799
811
|
/** The proxy tier the server resolved and used (never `auto`). */
|
|
800
812
|
proxy: ResolvedProxyTier;
|
|
801
|
-
/**
|
|
802
|
-
* Credits charged for this map request. Same value as
|
|
803
|
-
* {@link total_credit_cost}.
|
|
804
|
-
*
|
|
805
|
-
* @deprecated Use {@link total_credit_cost}, which always has the same value.
|
|
806
|
-
* This field will be removed in a future version.
|
|
807
|
-
*/
|
|
808
|
-
credits: number;
|
|
809
813
|
}
|
|
810
814
|
/**
|
|
811
815
|
* Response envelope for a map result: map usage plus the map-specific
|
|
@@ -1157,7 +1161,9 @@ declare class CrawlbruleeError extends Error {
|
|
|
1157
1161
|
*
|
|
1158
1162
|
* Not every 403 is a key problem: a 403 carrying `antibot_blocked` is the
|
|
1159
1163
|
* *target site* blocking us and raises {@link AntibotBlockedError} instead.
|
|
1160
|
-
*
|
|
1164
|
+
* A 403 carrying `zero_data_retention_not_enabled` raises
|
|
1165
|
+
* {@link ZeroDataRetentionNotEnabledError}. Only an unrecognized 403 name falls
|
|
1166
|
+
* back to this class.
|
|
1161
1167
|
*/
|
|
1162
1168
|
declare class AuthenticationError extends CrawlbruleeError {
|
|
1163
1169
|
constructor(message: string, options: {
|
|
@@ -1229,6 +1235,19 @@ declare class TargetUnreachableError extends CrawlbruleeError {
|
|
|
1229
1235
|
response?: ApiErrorResponse;
|
|
1230
1236
|
});
|
|
1231
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Raised when you send `zero_data_retention: true` but the option is not
|
|
1240
|
+
* enabled for your organization (HTTP 403, `zero_data_retention_not_enabled`).
|
|
1241
|
+
* The request is not billed. Not an API-key problem, so it is not an
|
|
1242
|
+
* {@link AuthenticationError}. See https://crawlbrulee.com/docs/zero-data-retention.
|
|
1243
|
+
*/
|
|
1244
|
+
declare class ZeroDataRetentionNotEnabledError extends CrawlbruleeError {
|
|
1245
|
+
constructor(message: string, options: {
|
|
1246
|
+
status: number;
|
|
1247
|
+
errorName: ApiErrorName;
|
|
1248
|
+
response?: ApiErrorResponse;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1232
1251
|
/**
|
|
1233
1252
|
* Raised for HTTP 429 responses. When the server included a `retry_after_ms`
|
|
1234
1253
|
* hint in `details` it is surfaced directly on the instance.
|
|
@@ -1429,5 +1448,5 @@ interface VerifyWebhookSignatureOptions {
|
|
|
1429
1448
|
*/
|
|
1430
1449
|
declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<WebhookVerificationResult>;
|
|
1431
1450
|
//#endregion
|
|
1432
|
-
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapLinkItem, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, isCrawlbruleeError, verifyWebhookSignature };
|
|
1451
|
+
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapLinkItem, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
|
|
1433
1452
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -96,21 +96,19 @@ type BillingEngine = 'http' | 'browser' | 'screenshot' | 'cache';
|
|
|
96
96
|
* webhooks.
|
|
97
97
|
*
|
|
98
98
|
* The response explains its own price:
|
|
99
|
-
* `total_credit_cost = engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost`.
|
|
99
|
+
* `total_credit_cost = engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost + zero_data_retention_credit_cost`.
|
|
100
100
|
*
|
|
101
|
-
* The
|
|
102
|
-
*
|
|
103
|
-
* fall back to the deprecated name: `usage.total_credit_cost ?? usage.credits`.
|
|
101
|
+
* The `*_credit_cost` / `proxy_multiplier` fields are optional in this type
|
|
102
|
+
* because older api versions do not send them.
|
|
104
103
|
*/
|
|
105
104
|
interface Usage {
|
|
106
105
|
/**
|
|
107
106
|
* Credits charged for this request. Always equals
|
|
108
|
-
* `engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost`.
|
|
107
|
+
* `engine_credit_cost × proxy_multiplier + screenshot_slicing_credit_cost + zero_data_retention_credit_cost`.
|
|
109
108
|
* `0` when nothing is billed: a cache hit, or a page whose status is not
|
|
110
109
|
* billed (see `page_status_code` on the scrape result).
|
|
111
110
|
*
|
|
112
|
-
* Optional only because older api versions do not send it
|
|
113
|
-
* {@link credits} when it is missing.
|
|
111
|
+
* Optional only because older api versions do not send it.
|
|
114
112
|
*/
|
|
115
113
|
total_credit_cost?: number;
|
|
116
114
|
/**
|
|
@@ -130,6 +128,12 @@ interface Usage {
|
|
|
130
128
|
* however many slices it made), otherwise `0`.
|
|
131
129
|
*/
|
|
132
130
|
screenshot_slicing_credit_cost?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Credits added by zero data retention: `1` on a billed, fresh result,
|
|
133
|
+
* otherwise `0`. Absent on an older api version; read it as
|
|
134
|
+
* `usage.zero_data_retention_credit_cost ?? 0`.
|
|
135
|
+
*/
|
|
136
|
+
zero_data_retention_credit_cost?: number;
|
|
133
137
|
/**
|
|
134
138
|
* Engine the delivered result was billed at: `http`, `browser`,
|
|
135
139
|
* `screenshot`, or `cache` (served from cache).
|
|
@@ -140,22 +144,6 @@ interface Usage {
|
|
|
140
144
|
* multiplies the engine base by 5.
|
|
141
145
|
*/
|
|
142
146
|
proxy: ResolvedProxyTier;
|
|
143
|
-
/**
|
|
144
|
-
* Credits charged for this request. Same value as {@link total_credit_cost}.
|
|
145
|
-
*
|
|
146
|
-
* @deprecated Use {@link total_credit_cost}, which always has the same value.
|
|
147
|
-
* This field will be removed in a future version.
|
|
148
|
-
*/
|
|
149
|
-
credits: number;
|
|
150
|
-
/**
|
|
151
|
-
* Screenshot slicing add-on: `1` when slices were made on this request,
|
|
152
|
-
* otherwise `0`. Same value as {@link screenshot_slicing_credit_cost}.
|
|
153
|
-
*
|
|
154
|
-
* @deprecated Use {@link screenshot_slicing_credit_cost}, which always has
|
|
155
|
-
* the same value. Despite its name this is a 0/1 charge, not a count of
|
|
156
|
-
* slices. This field will be removed in a future version.
|
|
157
|
-
*/
|
|
158
|
-
screenshot_slices: number;
|
|
159
147
|
}
|
|
160
148
|
/**
|
|
161
149
|
* Response envelope `response_meta` carried by scrape responses and async-status
|
|
@@ -226,7 +214,7 @@ interface ScreenshotRequest {
|
|
|
226
214
|
* Machine-readable error names returned by the crawlbrulee API. Stable
|
|
227
215
|
* identifiers — clients can switch on them.
|
|
228
216
|
*/
|
|
229
|
-
type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable';
|
|
217
|
+
type ApiErrorName = 'usage_allocation_error' | 'request_timeout' | 'invalid_url' | 'url_too_long' | 'client_closed_request' | 'reset_password_token_expired' | 'user_not_found' | 'unsupported_url_schema' | 'url_credentials_not_supported' | 'blocked_url' | 'scrape_error' | 'job_failed' | 'incorrect_login_method_used' | 'not_found' | 'invalid_credentials' | 'resource_already_exists' | 'access_denied' | 'internal_server_error' | 'service_unavailable' | 'too_many_requests' | 'unsupported_content' | 'unsupported_screenshot_output' | 'validation_error' | 'antibot_blocked' | 'too_many_redirects' | 'page_too_large' | 'target_unreachable' | 'zero_data_retention_not_enabled';
|
|
230
218
|
/** Reason a usage allocation was denied (when `error_name = usage_allocation_error`). */
|
|
231
219
|
type UsageAllocationReason = 'credit_limit' | 'concurrency_limit' | 'duplicate_reservation' | 'internal_error';
|
|
232
220
|
/** Snapshot of the org's current usage at the moment the error was raised. */
|
|
@@ -391,6 +379,13 @@ interface ScrapeRequest {
|
|
|
391
379
|
proxy?: ProxyTier;
|
|
392
380
|
/** Optional locale + country emulation. */
|
|
393
381
|
location?: ScrapeLocation;
|
|
382
|
+
/**
|
|
383
|
+
* Keeps the result out of the shared cache; anything stored to deliver it is
|
|
384
|
+
* kept for 24 hours, then deleted. Adds 1 credit. Must be enabled for your
|
|
385
|
+
* organization, or the request fails with {@link ZeroDataRetentionNotEnabledError}.
|
|
386
|
+
* See https://crawlbrulee.com/docs/zero-data-retention.
|
|
387
|
+
*/
|
|
388
|
+
zero_data_retention?: boolean;
|
|
394
389
|
}
|
|
395
390
|
/**
|
|
396
391
|
* Per-job completion webhook, attached when submitting an ASYNC scrape via
|
|
@@ -449,7 +444,10 @@ interface ScreenshotProperties {
|
|
|
449
444
|
interface ScreenshotSlice {
|
|
450
445
|
/** 0-based row index of this slice. */
|
|
451
446
|
row_nr: number;
|
|
452
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* Signed URL to download this slice image. Expires 24 hours after the scrape (for an async scrape, 24 hours after
|
|
449
|
+
* it was submitted). Download the image; don't keep the link.
|
|
450
|
+
*/
|
|
453
451
|
url: string;
|
|
454
452
|
type: 'slice';
|
|
455
453
|
/** Image-level properties of this slice. */
|
|
@@ -457,7 +455,10 @@ interface ScreenshotSlice {
|
|
|
457
455
|
}
|
|
458
456
|
/** Result block returned when a screenshot was requested. */
|
|
459
457
|
interface ScreenshotResult {
|
|
460
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Signed URL to download the full screenshot image. Expires 24 hours after the scrape (for an async scrape, 24 hours
|
|
460
|
+
* after it was submitted). Download the image; don't keep the link.
|
|
461
|
+
*/
|
|
461
462
|
url: string;
|
|
462
463
|
/** Capture mode that was used. */
|
|
463
464
|
type: ScreenshotType;
|
|
@@ -693,6 +694,13 @@ interface MapRequest {
|
|
|
693
694
|
limit?: number;
|
|
694
695
|
/** Optional country emulation. */
|
|
695
696
|
location?: MapLocation;
|
|
697
|
+
/**
|
|
698
|
+
* Keeps the result out of the shared cache; anything stored to deliver it is
|
|
699
|
+
* kept for 24 hours, then deleted. Adds 1 credit. Must be enabled for your
|
|
700
|
+
* organization, or the request fails with {@link ZeroDataRetentionNotEnabledError}.
|
|
701
|
+
* See https://crawlbrulee.com/docs/zero-data-retention.
|
|
702
|
+
*/
|
|
703
|
+
zero_data_retention?: boolean;
|
|
696
704
|
}
|
|
697
705
|
/** Single discovered URL in a map result. */
|
|
698
706
|
interface MapLinkItem {
|
|
@@ -767,21 +775,19 @@ type MapBillingEngine = 'http' | 'cache';
|
|
|
767
775
|
/**
|
|
768
776
|
* Usage accounting returned by the map endpoint. Map requests make no
|
|
769
777
|
* screenshots, so there is no slicing add-on:
|
|
770
|
-
* `total_credit_cost = engine_credit_cost × proxy_multiplier`.
|
|
778
|
+
* `total_credit_cost = engine_credit_cost × proxy_multiplier + zero_data_retention_credit_cost`.
|
|
771
779
|
*
|
|
772
780
|
* The `*_credit_cost` / `proxy_multiplier` fields are optional in this type
|
|
773
|
-
* because older api versions do not send them.
|
|
774
|
-
* back to the deprecated name: `usage.total_credit_cost ?? usage.credits`.
|
|
781
|
+
* because older api versions do not send them.
|
|
775
782
|
*/
|
|
776
783
|
interface MapUsage {
|
|
777
784
|
/**
|
|
778
785
|
* Credits charged for this map request. Always equals
|
|
779
|
-
* `engine_credit_cost × proxy_multiplier`. `0` for a cache hit, and for an
|
|
786
|
+
* `engine_credit_cost × proxy_multiplier + zero_data_retention_credit_cost`. `0` for a cache hit, and for an
|
|
780
787
|
* empty map when the site answered only with statuses we don't bill (a `5xx`,
|
|
781
788
|
* for example) or not at all.
|
|
782
789
|
*
|
|
783
|
-
* Optional only because older api versions do not send it
|
|
784
|
-
* {@link credits} when it is missing.
|
|
790
|
+
* Optional only because older api versions do not send it.
|
|
785
791
|
*/
|
|
786
792
|
total_credit_cost?: number;
|
|
787
793
|
/**
|
|
@@ -794,18 +800,16 @@ interface MapUsage {
|
|
|
794
800
|
* for `advanced`. Always reported, even when the engine cost is `0`.
|
|
795
801
|
*/
|
|
796
802
|
proxy_multiplier?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Credits added by zero data retention: `1` on a billed, fresh result,
|
|
805
|
+
* otherwise `0`. Absent on an older api version; read it as
|
|
806
|
+
* `usage.zero_data_retention_credit_cost ?? 0`.
|
|
807
|
+
*/
|
|
808
|
+
zero_data_retention_credit_cost?: number;
|
|
797
809
|
/** `http` for fresh discovery or `cache` for a cached result. */
|
|
798
810
|
engine: MapBillingEngine;
|
|
799
811
|
/** The proxy tier the server resolved and used (never `auto`). */
|
|
800
812
|
proxy: ResolvedProxyTier;
|
|
801
|
-
/**
|
|
802
|
-
* Credits charged for this map request. Same value as
|
|
803
|
-
* {@link total_credit_cost}.
|
|
804
|
-
*
|
|
805
|
-
* @deprecated Use {@link total_credit_cost}, which always has the same value.
|
|
806
|
-
* This field will be removed in a future version.
|
|
807
|
-
*/
|
|
808
|
-
credits: number;
|
|
809
813
|
}
|
|
810
814
|
/**
|
|
811
815
|
* Response envelope for a map result: map usage plus the map-specific
|
|
@@ -1157,7 +1161,9 @@ declare class CrawlbruleeError extends Error {
|
|
|
1157
1161
|
*
|
|
1158
1162
|
* Not every 403 is a key problem: a 403 carrying `antibot_blocked` is the
|
|
1159
1163
|
* *target site* blocking us and raises {@link AntibotBlockedError} instead.
|
|
1160
|
-
*
|
|
1164
|
+
* A 403 carrying `zero_data_retention_not_enabled` raises
|
|
1165
|
+
* {@link ZeroDataRetentionNotEnabledError}. Only an unrecognized 403 name falls
|
|
1166
|
+
* back to this class.
|
|
1161
1167
|
*/
|
|
1162
1168
|
declare class AuthenticationError extends CrawlbruleeError {
|
|
1163
1169
|
constructor(message: string, options: {
|
|
@@ -1229,6 +1235,19 @@ declare class TargetUnreachableError extends CrawlbruleeError {
|
|
|
1229
1235
|
response?: ApiErrorResponse;
|
|
1230
1236
|
});
|
|
1231
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Raised when you send `zero_data_retention: true` but the option is not
|
|
1240
|
+
* enabled for your organization (HTTP 403, `zero_data_retention_not_enabled`).
|
|
1241
|
+
* The request is not billed. Not an API-key problem, so it is not an
|
|
1242
|
+
* {@link AuthenticationError}. See https://crawlbrulee.com/docs/zero-data-retention.
|
|
1243
|
+
*/
|
|
1244
|
+
declare class ZeroDataRetentionNotEnabledError extends CrawlbruleeError {
|
|
1245
|
+
constructor(message: string, options: {
|
|
1246
|
+
status: number;
|
|
1247
|
+
errorName: ApiErrorName;
|
|
1248
|
+
response?: ApiErrorResponse;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1232
1251
|
/**
|
|
1233
1252
|
* Raised for HTTP 429 responses. When the server included a `retry_after_ms`
|
|
1234
1253
|
* hint in `details` it is surfaced directly on the instance.
|
|
@@ -1429,5 +1448,5 @@ interface VerifyWebhookSignatureOptions {
|
|
|
1429
1448
|
*/
|
|
1430
1449
|
declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<WebhookVerificationResult>;
|
|
1431
1450
|
//#endregion
|
|
1432
|
-
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapLinkItem, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, isCrawlbruleeError, verifyWebhookSignature };
|
|
1451
|
+
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapLinkItem, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
|
|
1433
1452
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 0;
|
|
|
10
10
|
/** Environment variable read by `Crawlbrulee.fromEnv()` to source the API key. */
|
|
11
11
|
const ENV_API_KEY = "CRAWLBRULEE_API_KEY";
|
|
12
12
|
/** Identifies the SDK in the `User-Agent` header. Kept in one place for easy bumping. */
|
|
13
|
-
const USER_AGENT = "@crawlbrulee/sdk/1.1
|
|
13
|
+
const USER_AGENT = "@crawlbrulee/sdk/1.2.1 (node)";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/errors.ts
|
|
@@ -55,7 +55,9 @@ var CrawlbruleeError = class extends Error {
|
|
|
55
55
|
*
|
|
56
56
|
* Not every 403 is a key problem: a 403 carrying `antibot_blocked` is the
|
|
57
57
|
* *target site* blocking us and raises {@link AntibotBlockedError} instead.
|
|
58
|
-
*
|
|
58
|
+
* A 403 carrying `zero_data_retention_not_enabled` raises
|
|
59
|
+
* {@link ZeroDataRetentionNotEnabledError}. Only an unrecognized 403 name falls
|
|
60
|
+
* back to this class.
|
|
59
61
|
*/
|
|
60
62
|
var AuthenticationError = class extends CrawlbruleeError {
|
|
61
63
|
constructor(message, options) {
|
|
@@ -123,6 +125,18 @@ var TargetUnreachableError = class extends CrawlbruleeError {
|
|
|
123
125
|
}
|
|
124
126
|
};
|
|
125
127
|
/**
|
|
128
|
+
* Raised when you send `zero_data_retention: true` but the option is not
|
|
129
|
+
* enabled for your organization (HTTP 403, `zero_data_retention_not_enabled`).
|
|
130
|
+
* The request is not billed. Not an API-key problem, so it is not an
|
|
131
|
+
* {@link AuthenticationError}. See https://crawlbrulee.com/docs/zero-data-retention.
|
|
132
|
+
*/
|
|
133
|
+
var ZeroDataRetentionNotEnabledError = class extends CrawlbruleeError {
|
|
134
|
+
constructor(message, options) {
|
|
135
|
+
super(message, options);
|
|
136
|
+
this.name = "ZeroDataRetentionNotEnabledError";
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
126
140
|
* Raised for HTTP 429 responses. When the server included a `retry_after_ms`
|
|
127
141
|
* hint in `details` it is surfaced directly on the instance.
|
|
128
142
|
*
|
|
@@ -279,6 +293,11 @@ function createApiError(body, status) {
|
|
|
279
293
|
errorName: name,
|
|
280
294
|
response
|
|
281
295
|
});
|
|
296
|
+
case "zero_data_retention_not_enabled": return new ZeroDataRetentionNotEnabledError(message, {
|
|
297
|
+
status,
|
|
298
|
+
errorName: name,
|
|
299
|
+
response
|
|
300
|
+
});
|
|
282
301
|
case "invalid_credentials":
|
|
283
302
|
case "access_denied": return new AuthenticationError(message, {
|
|
284
303
|
status,
|
|
@@ -974,5 +993,5 @@ function getSubtle() {
|
|
|
974
993
|
}
|
|
975
994
|
|
|
976
995
|
//#endregion
|
|
977
|
-
export { AntibotBlockedError, AuthenticationError, Crawlbrulee, CrawlbruleeError, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, NotFoundError, PageTooLargeError, RateLimitError, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, UsageAllocationError, ValidationError, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, isCrawlbruleeError, verifyWebhookSignature };
|
|
996
|
+
export { AntibotBlockedError, AuthenticationError, Crawlbrulee, CrawlbruleeError, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, NotFoundError, PageTooLargeError, RateLimitError, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, UsageAllocationError, ValidationError, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
|
|
978
997
|
//# sourceMappingURL=index.js.map
|