recker 1.0.79 → 1.0.80-next.70ea84d

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 (196) hide show
  1. package/dist/browser/browser/mini.d.ts +2 -2
  2. package/dist/browser/browser/recker-mini.d.ts +8 -8
  3. package/dist/browser/browser/recker.d.ts +11 -8
  4. package/dist/browser/browser/recker.js +54 -6
  5. package/dist/browser/core/client.d.ts +15 -10
  6. package/dist/browser/core/client.js +54 -38
  7. package/dist/browser/index.iife.min.js +129 -130
  8. package/dist/browser/index.min.js +129 -130
  9. package/dist/browser/index.mini.iife.js +5697 -636
  10. package/dist/browser/index.mini.iife.min.js +47 -48
  11. package/dist/browser/index.mini.min.js +47 -48
  12. package/dist/browser/index.mini.umd.js +5697 -636
  13. package/dist/browser/index.mini.umd.min.js +47 -48
  14. package/dist/browser/index.umd.min.js +129 -130
  15. package/dist/browser/mini.d.ts +2 -2
  16. package/dist/browser/plugins/proxy-rotator.d.ts +2 -2
  17. package/dist/browser/plugins/proxy-rotator.js +6 -28
  18. package/dist/browser/recker-mini.d.ts +8 -8
  19. package/dist/browser/recker.d.ts +11 -8
  20. package/dist/browser/recker.js +54 -6
  21. package/dist/browser/scrape/document.js +2 -2
  22. package/dist/browser/scrape/element.js +7 -1
  23. package/dist/browser/scrape/parser/nodes/html.js +1 -1
  24. package/dist/browser/scrape/spider.d.ts +52 -0
  25. package/dist/browser/scrape/spider.js +620 -38
  26. package/dist/browser/scrape/types.d.ts +2 -0
  27. package/dist/browser/search/google.d.ts +26 -1
  28. package/dist/browser/search/google.js +427 -45
  29. package/dist/browser/seo/analyzer.d.ts +1 -0
  30. package/dist/browser/seo/analyzer.js +144 -1
  31. package/dist/browser/seo/index.d.ts +1 -1
  32. package/dist/browser/seo/keyword-campaign-analyzer.d.ts +2 -0
  33. package/dist/browser/seo/keyword-campaign-analyzer.js +538 -0
  34. package/dist/browser/seo/keyword-campaign-seed-advanced.d.ts +17 -0
  35. package/dist/browser/seo/keyword-campaign-seed-advanced.js +269 -0
  36. package/dist/browser/seo/keyword-campaign-seed-core.d.ts +29 -0
  37. package/dist/browser/seo/keyword-campaign-seed-core.js +525 -0
  38. package/dist/browser/seo/keyword-campaign-shared.d.ts +165 -0
  39. package/dist/browser/seo/keyword-campaign-shared.js +59 -0
  40. package/dist/browser/seo/keyword-campaign.d.ts +4 -107
  41. package/dist/browser/seo/keyword-campaign.js +2 -380
  42. package/dist/browser/seo/keywords.js +5 -22
  43. package/dist/browser/seo/types.d.ts +19 -0
  44. package/dist/browser/transport/curl.d.ts +5 -1
  45. package/dist/browser/transport/curl.js +207 -50
  46. package/dist/browser/transport/undici.d.ts +4 -3
  47. package/dist/browser/transport/undici.js +123 -49
  48. package/dist/browser/types/index.d.ts +9 -3
  49. package/dist/browser/utils/binary-manager.js +26 -3
  50. package/dist/browser/utils/block-detector.d.ts +8 -0
  51. package/dist/browser/utils/block-detector.js +542 -7
  52. package/dist/cli/commands/hls-runner.js +5 -4
  53. package/dist/cli/commands/live-runner.js +5 -4
  54. package/dist/cli/commands/loadtest-runner.js +3 -2
  55. package/dist/cli/commands/search.d.ts +2 -0
  56. package/dist/cli/commands/search.js +105 -0
  57. package/dist/cli/commands/seo-runner.js +9 -7
  58. package/dist/cli/commands/seo.js +140 -1
  59. package/dist/cli/commands/serve.js +75 -131
  60. package/dist/cli/commands/server-runner.js +59 -82
  61. package/dist/cli/commands/spider-runner.d.ts +37 -1
  62. package/dist/cli/commands/spider-runner.js +134 -10
  63. package/dist/cli/commands/spider.d.ts +18 -1
  64. package/dist/cli/commands/spider.js +457 -27
  65. package/dist/cli/events/handlers/cli.js +30 -1
  66. package/dist/cli/events/handlers/tui.js +26 -0
  67. package/dist/cli/events/types.d.ts +27 -0
  68. package/dist/cli/handler.d.ts +2 -12
  69. package/dist/cli/handler.js +20 -15
  70. package/dist/cli/handlers/protocols.js +39 -12
  71. package/dist/cli/handlers/search.d.ts +2 -0
  72. package/dist/cli/handlers/search.js +171 -0
  73. package/dist/cli/handlers/seo-analyze.d.ts +1 -0
  74. package/dist/cli/handlers/seo-analyze.js +666 -0
  75. package/dist/cli/handlers/seo-robots.d.ts +1 -0
  76. package/dist/cli/handlers/seo-robots.js +76 -0
  77. package/dist/cli/handlers/seo-serp.d.ts +54 -0
  78. package/dist/cli/handlers/seo-serp.js +243 -0
  79. package/dist/cli/handlers/seo-sitemap.d.ts +1 -0
  80. package/dist/cli/handlers/seo-sitemap.js +55 -0
  81. package/dist/cli/handlers/seo-spider.d.ts +1 -0
  82. package/dist/cli/handlers/seo-spider.js +334 -0
  83. package/dist/cli/handlers/seo.d.ts +8 -4
  84. package/dist/cli/handlers/seo.js +294 -442
  85. package/dist/cli/handlers/spider.js +94 -17
  86. package/dist/cli/handlers/streaming.js +5 -1
  87. package/dist/cli/index.js +11 -2
  88. package/dist/cli/presets.d.ts +1 -1
  89. package/dist/cli/presets.js +15 -4
  90. package/dist/cli/tui/app.js +6 -1
  91. package/dist/cli/tui/components/rich-response.d.ts +72 -0
  92. package/dist/cli/tui/components/rich-response.js +117 -0
  93. package/dist/cli/tui/executor-commands/background.js +30 -24
  94. package/dist/cli/tui/executor-commands/testing.js +3 -2
  95. package/dist/cli/tui/hooks/useDomains.d.ts +17 -0
  96. package/dist/cli/tui/hooks/useHelp.js +15 -2
  97. package/dist/cli/tui/job-manager.d.ts +4 -4
  98. package/dist/cli/tui/job-manager.js +5 -1
  99. package/dist/cli/tui/spider-tui.d.ts +63 -0
  100. package/dist/cli/tui/spider-tui.js +120 -2
  101. package/dist/cli/types.d.ts +12 -0
  102. package/dist/cli/types.js +1 -0
  103. package/dist/cli/utils/option-helpers.d.ts +10 -0
  104. package/dist/cli/utils/option-helpers.js +63 -0
  105. package/dist/cli/utils/score-color.d.ts +11 -0
  106. package/dist/cli/utils/score-color.js +11 -0
  107. package/dist/cli/utils/serp-campaign.d.ts +53 -0
  108. package/dist/cli/utils/serp-campaign.js +53 -0
  109. package/dist/cli/utils/serp-config.d.ts +26 -0
  110. package/dist/cli/utils/serp-config.js +125 -0
  111. package/dist/core/client.d.ts +15 -10
  112. package/dist/core/client.js +54 -38
  113. package/dist/index.d.ts +1 -0
  114. package/dist/index.js +1 -0
  115. package/dist/mcp/cli.js +35 -34
  116. package/dist/mcp/client.d.ts +2 -2
  117. package/dist/mcp/client.js +20 -2
  118. package/dist/mcp/contract.d.ts +1 -1
  119. package/dist/mcp/profiles.js +5 -1
  120. package/dist/mcp/prompts/index.js +8 -4
  121. package/dist/mcp/resources/index.js +46 -23
  122. package/dist/mcp/server.js +9 -6
  123. package/dist/mcp/tools/protocols.js +9 -2
  124. package/dist/mcp/tools/registry.js +13 -3
  125. package/dist/mcp/tools/seo.js +427 -2
  126. package/dist/mcp/types.d.ts +5 -1
  127. package/dist/plugins/proxy-rotator.d.ts +2 -2
  128. package/dist/plugins/proxy-rotator.js +6 -28
  129. package/dist/raffel/client.d.ts +38 -0
  130. package/dist/raffel/client.js +282 -0
  131. package/dist/raffel/index.d.ts +2 -0
  132. package/dist/raffel/index.js +2 -0
  133. package/dist/raffel/types.d.ts +40 -0
  134. package/dist/raffel/types.js +14 -0
  135. package/dist/recker.d.ts +13 -7
  136. package/dist/recker.js +58 -6
  137. package/dist/scrape/document.js +2 -2
  138. package/dist/scrape/element.js +7 -1
  139. package/dist/scrape/parser/nodes/html.js +1 -1
  140. package/dist/scrape/spider.d.ts +52 -0
  141. package/dist/scrape/spider.js +620 -38
  142. package/dist/scrape/types.d.ts +2 -0
  143. package/dist/search/google.d.ts +26 -1
  144. package/dist/search/google.js +427 -45
  145. package/dist/search/index.d.ts +1 -1
  146. package/dist/seo/analyzer.d.ts +1 -0
  147. package/dist/seo/analyzer.js +144 -1
  148. package/dist/seo/index.d.ts +1 -1
  149. package/dist/seo/keyword-campaign-analyzer.d.ts +2 -0
  150. package/dist/seo/keyword-campaign-analyzer.js +538 -0
  151. package/dist/seo/keyword-campaign-seed-advanced.d.ts +17 -0
  152. package/dist/seo/keyword-campaign-seed-advanced.js +269 -0
  153. package/dist/seo/keyword-campaign-seed-core.d.ts +29 -0
  154. package/dist/seo/keyword-campaign-seed-core.js +525 -0
  155. package/dist/seo/keyword-campaign-shared.d.ts +165 -0
  156. package/dist/seo/keyword-campaign-shared.js +59 -0
  157. package/dist/seo/keyword-campaign.d.ts +4 -107
  158. package/dist/seo/keyword-campaign.js +2 -380
  159. package/dist/seo/keywords.js +5 -22
  160. package/dist/seo/types.d.ts +19 -0
  161. package/dist/template/index.d.ts +1 -1
  162. package/dist/template/types.d.ts +0 -2
  163. package/dist/testing/index.d.ts +1 -22
  164. package/dist/testing/index.js +1 -11
  165. package/dist/transport/curl.d.ts +5 -1
  166. package/dist/transport/curl.js +207 -50
  167. package/dist/transport/undici.d.ts +4 -3
  168. package/dist/transport/undici.js +123 -49
  169. package/dist/types/index.d.ts +9 -3
  170. package/dist/utils/binary-manager.js +26 -3
  171. package/dist/utils/block-detector.d.ts +8 -0
  172. package/dist/utils/block-detector.js +542 -7
  173. package/dist/version.js +1 -1
  174. package/package.json +12 -1
  175. package/dist/testing/mock-dns-server.d.ts +0 -69
  176. package/dist/testing/mock-dns-server.js +0 -269
  177. package/dist/testing/mock-ftp-server.d.ts +0 -89
  178. package/dist/testing/mock-ftp-server.js +0 -562
  179. package/dist/testing/mock-hls-server.d.ts +0 -80
  180. package/dist/testing/mock-hls-server.js +0 -381
  181. package/dist/testing/mock-http-server.d.ts +0 -124
  182. package/dist/testing/mock-http-server.js +0 -343
  183. package/dist/testing/mock-proxy-server.d.ts +0 -108
  184. package/dist/testing/mock-proxy-server.js +0 -615
  185. package/dist/testing/mock-sse-server.d.ts +0 -76
  186. package/dist/testing/mock-sse-server.js +0 -291
  187. package/dist/testing/mock-telnet-server.d.ts +0 -59
  188. package/dist/testing/mock-telnet-server.js +0 -274
  189. package/dist/testing/mock-udp-server.d.ts +0 -43
  190. package/dist/testing/mock-udp-server.js +0 -188
  191. package/dist/testing/mock-websocket-server.d.ts +0 -76
  192. package/dist/testing/mock-websocket-server.js +0 -334
  193. package/dist/testing/mock-whois-server.d.ts +0 -56
  194. package/dist/testing/mock-whois-server.js +0 -234
  195. package/dist/testing/proxy-certs.d.ts +0 -19
  196. package/dist/testing/proxy-certs.js +0 -208
@@ -6,8 +6,8 @@ export declare class MiniRequestPromise<T = unknown> implements Promise<Response
6
6
  private readonly p;
7
7
  constructor(promise: Promise<Response>);
8
8
  get [Symbol.toStringTag](): string;
9
- then<TResult1 = Response, TResult2 = never>(onfulfilled?: ((value: Response) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
10
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<Response | TResult>;
9
+ then<TResult1 = Response, TResult2 = never>(onfulfilled?: ((value: Response) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
10
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<Response | TResult>;
11
11
  finally(onfinally?: (() => void) | null): Promise<Response>;
12
12
  json<R = T>(): Promise<R>;
13
13
  text(): Promise<string>;
@@ -2,14 +2,14 @@ import { Client, type ExtendedClientOptions } from '../core/client.js';
2
2
  import { type RequestPromise } from '../core/request-promise.js';
3
3
  import type { RequestOptions } from '../types/index.js';
4
4
  import { simulateNetwork } from '../plugins/network-simulation.js';
5
- export declare function get(url: string, options?: RequestOptions): RequestPromise;
6
- export declare function post(url: string, options?: RequestOptions): RequestPromise;
7
- export declare function put(url: string, options?: RequestOptions): RequestPromise;
8
- export declare function patch(url: string, options?: RequestOptions): RequestPromise;
9
- export declare function del(url: string, options?: RequestOptions): RequestPromise;
10
- export declare function head(url: string, options?: RequestOptions): RequestPromise;
11
- export declare function options(url: string, options?: RequestOptions): RequestPromise;
12
- export declare function purge(url: string, options?: RequestOptions): RequestPromise;
5
+ export declare function get<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
6
+ export declare function post<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
7
+ export declare function put<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
8
+ export declare function patch<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
9
+ export declare function del<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
10
+ export declare function head<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
11
+ export declare function options<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
12
+ export declare function purge<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
13
13
  export declare function ws(url: string, protocols?: string | string[]): WebSocket;
14
14
  export declare const recker: {
15
15
  get: typeof get;
@@ -4,14 +4,17 @@ import type { RequestOptions } from '../types/index.js';
4
4
  import { analyzeSeo } from '../seo/analyzer.js';
5
5
  import { createAI } from '../ai/index.js';
6
6
  import { simulateNetwork } from '../plugins/network-simulation.js';
7
- export declare function get(url: string, options?: RequestOptions): RequestPromise;
8
- export declare function post(url: string, options?: RequestOptions): RequestPromise;
9
- export declare function put(url: string, options?: RequestOptions): RequestPromise;
10
- export declare function patch(url: string, options?: RequestOptions): RequestPromise;
11
- export declare function del(url: string, options?: RequestOptions): RequestPromise;
12
- export declare function head(url: string, options?: RequestOptions): RequestPromise;
13
- export declare function options(url: string, options?: RequestOptions): RequestPromise;
14
- export declare function purge(url: string, options?: RequestOptions): RequestPromise;
7
+ export declare function get<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
8
+ export declare function post<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
9
+ export declare function post<T = unknown>(url: string, body?: unknown, options?: RequestOptions): RequestPromise<T>;
10
+ export declare function put<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
11
+ export declare function put<T = unknown>(url: string, body?: unknown, options?: RequestOptions): RequestPromise<T>;
12
+ export declare function patch<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
13
+ export declare function patch<T = unknown>(url: string, body?: unknown, options?: RequestOptions): RequestPromise<T>;
14
+ export declare function del<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
15
+ export declare function head<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
16
+ export declare function options<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
17
+ export declare function purge<T = unknown>(url: string, options?: RequestOptions): RequestPromise<T>;
15
18
  export declare function ws(url: string, protocols?: string | string[]): WebSocket;
16
19
  export declare const recker: {
17
20
  get: typeof get;
@@ -5,6 +5,51 @@ import { createAI } from '../ai/index.js';
5
5
  import { harRecorder } from '../plugins/har-recorder.js';
6
6
  import { simulateNetwork } from '../plugins/network-simulation.js';
7
7
  let _defaultClient = null;
8
+ const REQUEST_OPTIONS_HINTS = new Set([
9
+ 'method',
10
+ 'headers',
11
+ 'body',
12
+ 'json',
13
+ 'form',
14
+ 'xml',
15
+ 'yaml',
16
+ 'csv',
17
+ 'timeout',
18
+ 'params',
19
+ 'searchParams',
20
+ 'retry',
21
+ 'hooks',
22
+ 'throwHttpErrors',
23
+ 'signal',
24
+ 'http2',
25
+ 'followRedirects',
26
+ 'maxRedirects',
27
+ 'beforeRedirect',
28
+ 'maxResponseSize',
29
+ 'useCurl',
30
+ 'proxy',
31
+ 'dns',
32
+ 'tls',
33
+ 'policySource',
34
+ 'policyTags',
35
+ 'traceId',
36
+ 'correlationId',
37
+ 'tenant',
38
+ 'retryOn404',
39
+ 'retryOn5xx',
40
+ ]);
41
+ function isRequestOptions(value) {
42
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
43
+ return false;
44
+ }
45
+ return Object.keys(value).some((key) => REQUEST_OPTIONS_HINTS.has(key));
46
+ }
47
+ function resolveRequestBodyAndOptions(bodyOrOptions, options) {
48
+ if (options === undefined && isRequestOptions(bodyOrOptions)) {
49
+ return { body: undefined, options: bodyOrOptions };
50
+ }
51
+ return { body: bodyOrOptions, options: options || {} };
52
+ }
8
53
  function getDefaultClient() {
9
54
  if (!_defaultClient) {
10
55
  _defaultClient = createClient({
@@ -16,14 +61,17 @@ function getDefaultClient() {
16
61
  export function get(url, options) {
17
62
  return getDefaultClient().get(url, options);
18
63
  }
19
- export function post(url, options) {
20
- return getDefaultClient().post(url, options);
64
+ export function post(url, bodyOrOptions, options) {
65
+ const resolved = resolveRequestBodyAndOptions(bodyOrOptions, options);
66
+ return getDefaultClient().post(url, resolved.body, resolved.options);
21
67
  }
22
- export function put(url, options) {
23
- return getDefaultClient().put(url, options);
68
+ export function put(url, bodyOrOptions, options) {
69
+ const resolved = resolveRequestBodyAndOptions(bodyOrOptions, options);
70
+ return getDefaultClient().put(url, resolved.body, resolved.options);
24
71
  }
25
- export function patch(url, options) {
26
- return getDefaultClient().patch(url, options);
72
+ export function patch(url, bodyOrOptions, options) {
73
+ const resolved = resolveRequestBodyAndOptions(bodyOrOptions, options);
74
+ return getDefaultClient().patch(url, resolved.body, resolved.options);
27
75
  }
28
76
  export function del(url, options) {
29
77
  return getDefaultClient().delete(url, options);
@@ -22,6 +22,7 @@ interface BatchRequestOptions<T = ReckerResponse> {
22
22
  signal?: AbortSignal;
23
23
  deadlineMs?: number;
24
24
  }
25
+ type RequestWithBodyOptions = Omit<RequestOptions, 'method'>;
25
26
  export interface ExtendedClientOptions extends ClientOptions {
26
27
  retry?: RetryOptions;
27
28
  cache?: ClientCacheConfig;
@@ -36,6 +37,7 @@ export declare class Client {
36
37
  private hooks;
37
38
  private transport;
38
39
  private curlTransport?;
40
+ private proxyConfig?;
39
41
  private defaultHeaders;
40
42
  private defaultHeadersObj;
41
43
  private defaultParams;
@@ -104,28 +106,31 @@ export declare class Client {
104
106
  };
105
107
  }>;
106
108
  private requestWithBody;
107
- post<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
108
- put<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
109
- patch<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
109
+ post<T = unknown>(path: string, options?: RequestWithBodyOptions): RequestPromise<T>;
110
+ post<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
111
+ put<T = unknown>(path: string, options?: RequestWithBodyOptions): RequestPromise<T>;
112
+ put<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
113
+ patch<T = unknown>(path: string, options?: RequestWithBodyOptions): RequestPromise<T>;
114
+ patch<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
110
115
  delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
111
116
  head<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
112
117
  options<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
113
118
  trace<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
114
119
  connect<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
115
120
  purge<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
116
- propfind<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
117
- proppatch<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
121
+ propfind<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
122
+ proppatch<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
118
123
  mkcol<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
119
124
  copy<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
120
125
  move<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
121
- lock<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
126
+ lock<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
122
127
  unlock<T = unknown>(path: string, options?: Omit<RequestOptions, 'method'>): RequestPromise<T>;
123
- link<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
124
- unlink<T = unknown>(path: string, body?: any, options?: Omit<RequestOptions, 'method' | 'body'>): RequestPromise<T>;
128
+ link<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
129
+ unlink<T = unknown>(path: string, body?: unknown, options?: RequestWithBodyOptions): RequestPromise<T>;
125
130
  scrape(path: string, options?: RequestOptions): ScrapePromise<ReckerResponse>;
126
131
  paginate<T>(path: string, options?: RequestOptions & PaginationOptions<T>): AsyncGenerator<T>;
127
- pages<T = any>(path: string, options?: RequestOptions & PaginationOptions): AsyncGenerator<PageResult<T>>;
128
- page<T = any>(path: string, pageNumber: number, options?: RequestOptions & {
132
+ pages<T = unknown>(path: string, options?: RequestOptions & PaginationOptions): AsyncGenerator<PageResult<T>>;
133
+ page<T = unknown>(path: string, pageNumber: number, options?: RequestOptions & {
129
134
  pageParam?: string;
130
135
  }): RequestPromise<T>;
131
136
  getAll<T>(path: string, options?: RequestOptions & PaginationOptions<T>): Promise<T[]>;
@@ -28,8 +28,34 @@ import { ReckerWebSocket } from '../websocket/client.js';
28
28
  import { whois as performWhois, isDomainAvailable } from '../utils/whois.js';
29
29
  import { MemoryCookieJar } from '../cookies/memory-cookie-jar.js';
30
30
  import { scrape as scrapeHelper } from '../plugins/scrape.js';
31
+ const toError = (error) => error instanceof Error ? error : new Error(String(error));
32
+ const BODY_OPTION_HINTS = [
33
+ 'json',
34
+ 'form',
35
+ 'xml',
36
+ 'yaml',
37
+ 'csv',
38
+ 'body',
39
+ 'headers',
40
+ 'timeout',
41
+ 'retry',
42
+ 'hooks',
43
+ 'searchParams',
44
+ 'params',
45
+ 'beforeRedirect',
46
+ 'maxRedirects',
47
+ 'followRedirects',
48
+ 'http2',
49
+ 'useCurl',
50
+ ];
31
51
  function isNodeRuntime() {
32
- return typeof globalThis !== 'undefined' && Boolean(globalThis.process?.versions?.node);
52
+ const maybeNodeGlobal = globalThis;
53
+ return typeof globalThis !== 'undefined' && Boolean(maybeNodeGlobal.process?.versions?.node);
54
+ }
55
+ function isRequestWithBodyOptions(value) {
56
+ if (!isPlainObject(value))
57
+ return false;
58
+ return BODY_OPTION_HINTS.some((key) => Object.prototype.hasOwnProperty.call(value, key));
33
59
  }
34
60
  class LazyTransport {
35
61
  factory;
@@ -67,7 +93,7 @@ class LazyTransport {
67
93
  await this.resolving;
68
94
  }
69
95
  }
70
- function createLazyCurlTransport() {
96
+ function createLazyCurlTransport(proxy) {
71
97
  if (!isNodeRuntime()) {
72
98
  return {
73
99
  async dispatch(req) {
@@ -77,7 +103,7 @@ function createLazyCurlTransport() {
77
103
  }
78
104
  return new LazyTransport(async () => {
79
105
  const { CurlTransport } = await import('../transport/curl.js');
80
- return new CurlTransport();
106
+ return new CurlTransport(proxy);
81
107
  });
82
108
  }
83
109
  class LazyCacheStorage {
@@ -179,6 +205,7 @@ export class Client {
179
205
  hooks;
180
206
  transport;
181
207
  curlTransport;
208
+ proxyConfig;
182
209
  defaultHeaders;
183
210
  defaultHeadersObj;
184
211
  defaultParams;
@@ -222,6 +249,7 @@ export class Client {
222
249
  this.defaultParams = options.defaults?.params || {};
223
250
  this.paginationConfig = options.pagination;
224
251
  this.maxResponseSize = options.maxResponseSize;
252
+ this.proxyConfig = options.proxy;
225
253
  const runtimeEventBus = options.runtimeEventBus;
226
254
  if (runtimeEventBus) {
227
255
  this.runtimeEventBus = {
@@ -254,7 +282,7 @@ export class Client {
254
282
  else if (options.useCurl) {
255
283
  if (this.debugEnabled)
256
284
  console.log('[DEBUG] Using Curl Transport');
257
- this.transport = createLazyCurlTransport();
285
+ this.transport = createLazyCurlTransport(options.proxy);
258
286
  this.transportKind = 'curl';
259
287
  }
260
288
  else if (isNodeRuntime()) {
@@ -290,8 +318,9 @@ export class Client {
290
318
  this.transportKind = 'undici';
291
319
  }
292
320
  else {
293
- if (this.debugEnabled)
294
- console.log('[DEBUG] Using Fetch Transport');
321
+ if (this.debugEnabled && this.logger) {
322
+ this.logger.debug('Using Fetch Transport');
323
+ }
295
324
  this.transport = new FetchTransport();
296
325
  this.transportKind = 'fetch';
297
326
  }
@@ -317,7 +346,8 @@ export class Client {
317
346
  interval: this.concurrencyConfig.interval
318
347
  });
319
348
  registerPlugin((client) => {
320
- client.middlewares.unshift(this.requestPool.asMiddleware());
349
+ const pluginClient = client;
350
+ pluginClient.middlewares?.unshift(this.requestPool.asMiddleware());
321
351
  }, {
322
352
  name: 'recker:request-pool',
323
353
  priority: 130,
@@ -525,7 +555,7 @@ export class Client {
525
555
  try {
526
556
  if (req.useCurl && this.transportKind !== 'curl') {
527
557
  if (!this.curlTransport) {
528
- this.curlTransport = createLazyCurlTransport();
558
+ this.curlTransport = createLazyCurlTransport(this.proxyConfig);
529
559
  }
530
560
  const response = await this.curlTransport.dispatch(req);
531
561
  if (context) {
@@ -552,7 +582,7 @@ export class Client {
552
582
  this.runtimeEventBus.emit('transport:error', {
553
583
  context,
554
584
  req,
555
- error: error instanceof Error ? error : new Error(String(error))
585
+ error: toError(error)
556
586
  });
557
587
  }
558
588
  throw error;
@@ -768,7 +798,7 @@ export class Client {
768
798
  });
769
799
  return response;
770
800
  }, (error) => {
771
- const requestError = error instanceof Error ? error : new Error(String(error));
801
+ const requestError = toError(error);
772
802
  this.runtimeEventBus.emit('request:failed', {
773
803
  context: requestContext,
774
804
  req,
@@ -849,7 +879,7 @@ export class Client {
849
879
  });
850
880
  return response;
851
881
  }, (error) => {
852
- const requestError = error instanceof Error ? error : new Error(String(error));
882
+ const requestError = toError(error);
853
883
  this.runtimeEventBus.emit('request:failed', {
854
884
  context: requestContext,
855
885
  req,
@@ -873,8 +903,9 @@ export class Client {
873
903
  return this.request(path, { ...options, method: 'GET' });
874
904
  }
875
905
  async warmup() {
876
- if (this.transport && 'warmup' in this.transport && typeof this.transport.warmup === 'function') {
877
- await this.transport.warmup();
906
+ const transport = this.transport;
907
+ if (transport?.warmup) {
908
+ await transport.warmup();
878
909
  }
879
910
  }
880
911
  async batch(requests, options = {}) {
@@ -899,29 +930,14 @@ export class Client {
899
930
  }
900
931
  requestWithBody(method, path, bodyOrOptions, options) {
901
932
  let actualBody = bodyOrOptions;
902
- let actualOptions = options;
903
- const isOptionsEmpty = actualOptions === undefined ||
904
- (typeof actualOptions === 'object' && actualOptions !== null && Object.keys(actualOptions).length === 0);
905
- if (isOptionsEmpty && isPlainObject(bodyOrOptions)) {
906
- const potentialOptions = bodyOrOptions;
907
- if (potentialOptions.json !== undefined ||
908
- potentialOptions.form !== undefined ||
909
- potentialOptions.xml !== undefined ||
910
- potentialOptions.yaml !== undefined ||
911
- potentialOptions.csv !== undefined ||
912
- potentialOptions.body !== undefined ||
913
- potentialOptions.headers !== undefined ||
914
- potentialOptions.timeout !== undefined ||
915
- potentialOptions.retry !== undefined ||
916
- potentialOptions.hooks !== undefined ||
917
- potentialOptions.searchParams !== undefined ||
918
- potentialOptions.params !== undefined) {
919
- actualOptions = bodyOrOptions;
920
- actualBody = undefined;
921
- }
922
- }
923
- actualOptions = actualOptions || {};
924
- const { json, form, xml, yaml, csv, ...restOptions } = actualOptions;
933
+ let actualOptions = options || {};
934
+ const isOptionsEmpty = options === undefined
935
+ || (isPlainObject(options) && Object.keys(options).length === 0);
936
+ if (isOptionsEmpty && isRequestWithBodyOptions(bodyOrOptions)) {
937
+ actualOptions = bodyOrOptions;
938
+ actualBody = undefined;
939
+ }
940
+ const { json, form, xml, yaml, csv, body: explicitBody, ...restOptions } = actualOptions;
925
941
  let finalBody = actualBody;
926
942
  let explicitContentType;
927
943
  if (form !== undefined) {
@@ -944,8 +960,8 @@ export class Client {
944
960
  finalBody = serializeCsv(csv);
945
961
  explicitContentType = 'text/csv';
946
962
  }
947
- else if (restOptions.body !== undefined) {
948
- finalBody = restOptions.body;
963
+ else if (explicitBody !== undefined) {
964
+ finalBody = explicitBody;
949
965
  }
950
966
  const { body: processedBody, contentType } = processBody(finalBody);
951
967
  const headers = new Headers(restOptions.headers);