scrapfly-sdk 0.10.3 → 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.
Files changed (166) hide show
  1. package/esm/browserconfig.d.ts +70 -1
  2. package/esm/browserconfig.d.ts.map +1 -1
  3. package/esm/browserconfig.js +44 -1
  4. package/esm/client.d.ts +33 -0
  5. package/esm/client.d.ts.map +1 -1
  6. package/esm/client.js +33 -5
  7. package/esm/crawl.d.ts +4 -0
  8. package/esm/crawl.d.ts.map +1 -1
  9. package/esm/crawl.js +4 -0
  10. package/esm/crawlerresult.d.ts +7 -0
  11. package/esm/crawlerresult.d.ts.map +1 -1
  12. package/esm/errors.d.ts +43 -0
  13. package/esm/errors.d.ts.map +1 -1
  14. package/esm/errors.js +43 -16
  15. package/esm/extractionconfig.d.ts +54 -9
  16. package/esm/extractionconfig.d.ts.map +1 -1
  17. package/esm/extractionconfig.js +37 -13
  18. package/esm/logger.d.ts +1 -0
  19. package/esm/logger.d.ts.map +1 -1
  20. package/esm/logger.js +1 -0
  21. package/esm/main.d.ts +27 -0
  22. package/esm/main.d.ts.map +1 -1
  23. package/esm/main.js +27 -0
  24. package/esm/monitoringconfig.d.ts +48 -11
  25. package/esm/monitoringconfig.d.ts.map +1 -1
  26. package/esm/monitoringconfig.js +14 -0
  27. package/esm/result.d.ts +2 -0
  28. package/esm/result.d.ts.map +1 -1
  29. package/esm/scrapeconfig.d.ts +10 -8
  30. package/esm/scrapeconfig.d.ts.map +1 -1
  31. package/esm/scrapeconfig.js +10 -8
  32. package/esm/screenshotconfig.d.ts +59 -26
  33. package/esm/screenshotconfig.d.ts.map +1 -1
  34. package/esm/screenshotconfig.js +38 -26
  35. package/esm/webhookserver.d.ts +24 -0
  36. package/esm/webhookserver.d.ts.map +1 -1
  37. package/esm/webhookserver.js +24 -0
  38. package/package.json +1 -1
  39. package/script/browserconfig.d.ts +70 -1
  40. package/script/browserconfig.d.ts.map +1 -1
  41. package/script/browserconfig.js +44 -1
  42. package/script/client.d.ts +33 -0
  43. package/script/client.d.ts.map +1 -1
  44. package/script/client.js +33 -5
  45. package/script/crawl.d.ts +4 -0
  46. package/script/crawl.d.ts.map +1 -1
  47. package/script/crawl.js +4 -0
  48. package/script/crawlerresult.d.ts +7 -0
  49. package/script/crawlerresult.d.ts.map +1 -1
  50. package/script/errors.d.ts +43 -0
  51. package/script/errors.d.ts.map +1 -1
  52. package/script/errors.js +43 -16
  53. package/script/extractionconfig.d.ts +54 -9
  54. package/script/extractionconfig.d.ts.map +1 -1
  55. package/script/extractionconfig.js +37 -13
  56. package/script/logger.d.ts +1 -0
  57. package/script/logger.d.ts.map +1 -1
  58. package/script/logger.js +1 -0
  59. package/script/main.d.ts +27 -0
  60. package/script/main.d.ts.map +1 -1
  61. package/script/main.js +27 -0
  62. package/script/monitoringconfig.d.ts +48 -11
  63. package/script/monitoringconfig.d.ts.map +1 -1
  64. package/script/monitoringconfig.js +14 -0
  65. package/script/result.d.ts +2 -0
  66. package/script/result.d.ts.map +1 -1
  67. package/script/scrapeconfig.d.ts +10 -8
  68. package/script/scrapeconfig.d.ts.map +1 -1
  69. package/script/scrapeconfig.js +10 -8
  70. package/script/screenshotconfig.d.ts +59 -26
  71. package/script/screenshotconfig.d.ts.map +1 -1
  72. package/script/screenshotconfig.js +38 -26
  73. package/script/webhookserver.d.ts +24 -0
  74. package/script/webhookserver.d.ts.map +1 -1
  75. package/script/webhookserver.js +24 -0
  76. package/src/_dnt.shims.ts +64 -0
  77. package/src/batch.ts +272 -0
  78. package/src/browserconfig.ts +187 -0
  79. package/src/client.ts +1637 -0
  80. package/src/crawl.ts +255 -0
  81. package/src/crawlerconfig.ts +363 -0
  82. package/src/crawlerresult.ts +478 -0
  83. package/src/deps/jsr.io/@std/path/1.0.1/_common/assert_path.ts +10 -0
  84. package/src/deps/jsr.io/@std/path/1.0.1/_common/basename.ts +53 -0
  85. package/src/deps/jsr.io/@std/path/1.0.1/_common/common.ts +26 -0
  86. package/src/deps/jsr.io/@std/path/1.0.1/_common/constants.ts +49 -0
  87. package/src/deps/jsr.io/@std/path/1.0.1/_common/dirname.ts +9 -0
  88. package/src/deps/jsr.io/@std/path/1.0.1/_common/format.ts +25 -0
  89. package/src/deps/jsr.io/@std/path/1.0.1/_common/from_file_url.ts +10 -0
  90. package/src/deps/jsr.io/@std/path/1.0.1/_common/glob_to_reg_exp.ts +290 -0
  91. package/src/deps/jsr.io/@std/path/1.0.1/_common/normalize.ts +9 -0
  92. package/src/deps/jsr.io/@std/path/1.0.1/_common/normalize_string.ts +74 -0
  93. package/src/deps/jsr.io/@std/path/1.0.1/_common/relative.ts +10 -0
  94. package/src/deps/jsr.io/@std/path/1.0.1/_common/strip_trailing_separators.ts +25 -0
  95. package/src/deps/jsr.io/@std/path/1.0.1/_common/to_file_url.ts +17 -0
  96. package/src/deps/jsr.io/@std/path/1.0.1/_os.ts +31 -0
  97. package/src/deps/jsr.io/@std/path/1.0.1/basename.ts +35 -0
  98. package/src/deps/jsr.io/@std/path/1.0.1/common.ts +35 -0
  99. package/src/deps/jsr.io/@std/path/1.0.1/constants.ts +18 -0
  100. package/src/deps/jsr.io/@std/path/1.0.1/dirname.ts +28 -0
  101. package/src/deps/jsr.io/@std/path/1.0.1/extname.ts +27 -0
  102. package/src/deps/jsr.io/@std/path/1.0.1/format.ts +30 -0
  103. package/src/deps/jsr.io/@std/path/1.0.1/from_file_url.ts +30 -0
  104. package/src/deps/jsr.io/@std/path/1.0.1/glob_to_regexp.ts +94 -0
  105. package/src/deps/jsr.io/@std/path/1.0.1/is_absolute.ts +30 -0
  106. package/src/deps/jsr.io/@std/path/1.0.1/is_glob.ts +49 -0
  107. package/src/deps/jsr.io/@std/path/1.0.1/join.ts +28 -0
  108. package/src/deps/jsr.io/@std/path/1.0.1/join_globs.ts +42 -0
  109. package/src/deps/jsr.io/@std/path/1.0.1/mod.ts +55 -0
  110. package/src/deps/jsr.io/@std/path/1.0.1/normalize.ts +31 -0
  111. package/src/deps/jsr.io/@std/path/1.0.1/normalize_glob.ts +45 -0
  112. package/src/deps/jsr.io/@std/path/1.0.1/parse.ts +44 -0
  113. package/src/deps/jsr.io/@std/path/1.0.1/posix/_util.ts +10 -0
  114. package/src/deps/jsr.io/@std/path/1.0.1/posix/basename.ts +39 -0
  115. package/src/deps/jsr.io/@std/path/1.0.1/posix/constants.ts +15 -0
  116. package/src/deps/jsr.io/@std/path/1.0.1/posix/dirname.ts +55 -0
  117. package/src/deps/jsr.io/@std/path/1.0.1/posix/extname.ts +73 -0
  118. package/src/deps/jsr.io/@std/path/1.0.1/posix/format.ts +31 -0
  119. package/src/deps/jsr.io/@std/path/1.0.1/posix/from_file_url.ts +25 -0
  120. package/src/deps/jsr.io/@std/path/1.0.1/posix/glob_to_regexp.ts +94 -0
  121. package/src/deps/jsr.io/@std/path/1.0.1/posix/is_absolute.ts +25 -0
  122. package/src/deps/jsr.io/@std/path/1.0.1/posix/join.ts +27 -0
  123. package/src/deps/jsr.io/@std/path/1.0.1/posix/join_globs.ts +44 -0
  124. package/src/deps/jsr.io/@std/path/1.0.1/posix/normalize.ts +41 -0
  125. package/src/deps/jsr.io/@std/path/1.0.1/posix/normalize_glob.ts +42 -0
  126. package/src/deps/jsr.io/@std/path/1.0.1/posix/parse.ts +121 -0
  127. package/src/deps/jsr.io/@std/path/1.0.1/posix/relative.ts +103 -0
  128. package/src/deps/jsr.io/@std/path/1.0.1/posix/resolve.ts +69 -0
  129. package/src/deps/jsr.io/@std/path/1.0.1/posix/to_file_url.ts +32 -0
  130. package/src/deps/jsr.io/@std/path/1.0.1/posix/to_namespaced_path.ts +21 -0
  131. package/src/deps/jsr.io/@std/path/1.0.1/relative.ts +32 -0
  132. package/src/deps/jsr.io/@std/path/1.0.1/resolve.ts +32 -0
  133. package/src/deps/jsr.io/@std/path/1.0.1/to_file_url.ts +30 -0
  134. package/src/deps/jsr.io/@std/path/1.0.1/to_namespaced_path.ts +31 -0
  135. package/src/deps/jsr.io/@std/path/1.0.1/types.ts +40 -0
  136. package/src/deps/jsr.io/@std/path/1.0.1/windows/_util.ts +28 -0
  137. package/src/deps/jsr.io/@std/path/1.0.1/windows/basename.ts +48 -0
  138. package/src/deps/jsr.io/@std/path/1.0.1/windows/constants.ts +15 -0
  139. package/src/deps/jsr.io/@std/path/1.0.1/windows/dirname.ts +114 -0
  140. package/src/deps/jsr.io/@std/path/1.0.1/windows/extname.ts +86 -0
  141. package/src/deps/jsr.io/@std/path/1.0.1/windows/format.ts +31 -0
  142. package/src/deps/jsr.io/@std/path/1.0.1/windows/from_file_url.ts +34 -0
  143. package/src/deps/jsr.io/@std/path/1.0.1/windows/glob_to_regexp.ts +92 -0
  144. package/src/deps/jsr.io/@std/path/1.0.1/windows/is_absolute.ts +40 -0
  145. package/src/deps/jsr.io/@std/path/1.0.1/windows/join.ts +72 -0
  146. package/src/deps/jsr.io/@std/path/1.0.1/windows/join_globs.ts +45 -0
  147. package/src/deps/jsr.io/@std/path/1.0.1/windows/normalize.ts +132 -0
  148. package/src/deps/jsr.io/@std/path/1.0.1/windows/normalize_glob.ts +42 -0
  149. package/src/deps/jsr.io/@std/path/1.0.1/windows/parse.ts +184 -0
  150. package/src/deps/jsr.io/@std/path/1.0.1/windows/relative.ts +128 -0
  151. package/src/deps/jsr.io/@std/path/1.0.1/windows/resolve.ts +174 -0
  152. package/src/deps/jsr.io/@std/path/1.0.1/windows/to_file_url.ts +38 -0
  153. package/src/deps/jsr.io/@std/path/1.0.1/windows/to_namespaced_path.ts +60 -0
  154. package/src/deps.ts +4 -0
  155. package/src/errors.ts +82 -0
  156. package/src/extractionconfig.ts +217 -0
  157. package/src/logger.ts +53 -0
  158. package/src/main.ts +88 -0
  159. package/src/monitoringconfig.ts +88 -0
  160. package/src/polyfill.ts +37 -0
  161. package/src/result.ts +340 -0
  162. package/src/scrapeconfig.ts +450 -0
  163. package/src/screenshotconfig.ts +237 -0
  164. package/src/types.ts +2 -0
  165. package/src/utils.ts +86 -0
  166. package/src/webhookserver.ts +90 -0
@@ -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
@@ -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;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;CAI5D;AAGD,qBAAa,iBAAkB,SAAQ,aAAa;CAAG;AAEvD,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAE3D,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAE3D,qBAAa,kBAAmB,SAAQ,aAAa;CAAG;AAGxD,qBAAa,WAAY,SAAQ,aAAa;CAAG;AACjD,qBAAa,gBAAiB,SAAQ,aAAa;CAAG;AAGtD,qBAAa,SAAU,SAAQ,aAAa;CAAG;AAC/C,qBAAa,iBAAkB,SAAQ,SAAS;CAAG;AACnD,qBAAa,uBAAwB,SAAQ,iBAAiB;CAAG;AACjE,qBAAa,uBAAwB,SAAQ,uBAAuB;CAAG;AAEvE,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AAEpD,qBAAa,cAAe,SAAQ,kBAAkB;CAAG;AAEzD,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AACjD,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,qBAAa,mBAAoB,SAAQ,SAAS;CAAG;AAErD,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,qBAAa,gBAAiB,SAAQ,SAAS;CAAG;AAClD,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AAEtD,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AA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CAAG;AACjD,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,6FAA6F;AAC7F,qBAAa,mBAAoB,SAAQ,SAAS;CAAG;AACrD,2GAA2G;AAC3G,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,4EAA4E;AAC5E,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AACvD,oFAAoF;AACpF,qBAAa,gBAAiB,SAAQ,SAAS;CAAG;AAClD,qEAAqE;AACrE,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AACvD,iFAAiF;AACjF,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AACtD,+FAA+F;AAC/F,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AACtD,8EAA8E;AAC9E,qBAAa,yBAA0B,SAAQ,SAAS;CAAG;AAC3D,wDAAwD;AACxD,qBAAa,iBAAkB,SAAQ,SAAS;CAAG;AACnD,mDAAmD;AACnD,qBAAa,kBAAmB,SAAQ,kBAAkB;CAAG;AAC7D,mDAAmD;AACnD,qBAAa,kBAAmB,SAAQ,kBAAkB;CAAG;AAC7D;;;;;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
- // raised when scrape config is invalid
29
+ /** Raised when a ScrapeConfig is constructed with invalid parameters. */
18
30
  class ScrapeConfigError extends ScrapflyError {
19
31
  }
20
32
  exports.ScrapeConfigError = ScrapeConfigError;
21
- // raised when screenshot config is invalid
33
+ /** Raised when a ScreenshotConfig is constructed with invalid parameters. */
22
34
  class ScreenshotConfigError extends ScrapflyError {
23
35
  }
24
36
  exports.ScreenshotConfigError = ScreenshotConfigError;
25
- // raised when extraction config is invalid
37
+ /** Raised when an ExtractionConfig is constructed with invalid parameters. */
26
38
  class ExtractionConfigError extends ScrapflyError {
27
39
  }
28
40
  exports.ExtractionConfigError = ExtractionConfigError;
29
- // raised when crawler config is invalid
41
+ /** Raised when a CrawlerConfig is constructed with invalid parameters. */
30
42
  class CrawlerConfigError extends ScrapflyError {
31
43
  }
32
44
  exports.CrawlerConfigError = CrawlerConfigError;
33
- // raised when scrape parameters cannot be encoded
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
- // Base error for all http related operations
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
- // raised when API key provided to client is not valid or not existant
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
- // raised when proxy settings don't match available proxies (e.g. invalid proxy pool, country setting)
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
- // raised when ScrapFly fails to bypass anti-scraping protection
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
- // raised when Webhook is invalid or cannot be fulfilled (i.e. full queue)
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
- // raised when session is access concurrently
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
- // raised when concurrent requests exceed account limits
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
- // raised when account is out of scrape credits
117
+ /** Raised when the account is out of scrape credits. */
96
118
  class QuotaLimitReached extends HttpError {
97
119
  }
98
120
  exports.QuotaLimitReached = QuotaLimitReached;
99
- // raised with Scrapfly screenshot API related errors
121
+ /** Raised for screenshot-API-specific failures. */
100
122
  class ScreenshotApiError extends ApiHttpClientError {
101
123
  }
102
124
  exports.ScreenshotApiError = ScreenshotApiError;
103
- // raised with Scrapfly extraction API related errors
125
+ /** Raised for extraction-API-specific failures. */
104
126
  class ExtractionApiError extends ApiHttpClientError {
105
127
  }
106
128
  exports.ExtractionApiError = ExtractionApiError;
107
- // raised with Scrapfly crawler API related errors (job lifecycle: ALREADY_STARTED, NOT_STARTED, FAILED, CANCELLED, TIMEOUT, etc.)
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":"extractionconf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,MAAM,CAAC;IAClB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,qBAAqB;IACrB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,sCAAsC;IACtC,2BAA2B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAAC;IAC9E,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;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
- }); // saved template name
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
- }); // ephemeraly declared json template
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
- // // deprecated options
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);
@@ -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
@@ -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;AACtB,eAAO,MAAM,GAAG,EAAE,MAA+B,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
@@ -55,4 +55,5 @@ class Logger {
55
55
  }
56
56
  }
57
57
  exports.default = Logger;
58
+ /** Shared logger instance used by the SDK. Callers can set its log level to silence or unmute output. */
58
59
  exports.log = new Logger('scrapfly');
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';
@@ -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,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGzI,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,Y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B,CAAC;AAC/D,mFAAmF;AACnF,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGzI,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,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; } });