recker 1.0.2-0 → 1.0.4

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 (287) hide show
  1. package/LICENSE +0 -2
  2. package/README.md +121 -72
  3. package/dist/cache/memory-storage.d.ts.map +1 -1
  4. package/dist/cache/memory-storage.js +7 -1
  5. package/dist/constants/http-status.d.ts +74 -0
  6. package/dist/constants/http-status.d.ts.map +1 -0
  7. package/dist/constants/http-status.js +156 -0
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +6 -6
  10. package/dist/cookies/memory-cookie-jar.d.ts +31 -0
  11. package/dist/cookies/memory-cookie-jar.d.ts.map +1 -0
  12. package/dist/cookies/memory-cookie-jar.js +210 -0
  13. package/dist/core/client.d.ts +9 -0
  14. package/dist/core/client.d.ts.map +1 -1
  15. package/dist/core/client.js +252 -53
  16. package/dist/core/errors.d.ts +18 -2
  17. package/dist/core/errors.d.ts.map +1 -1
  18. package/dist/core/errors.js +66 -5
  19. package/dist/core/index.d.ts +6 -0
  20. package/dist/core/index.d.ts.map +1 -0
  21. package/dist/core/index.js +5 -0
  22. package/dist/core/request-promise.d.ts.map +1 -1
  23. package/dist/core/request-promise.js +8 -2
  24. package/dist/core/request.d.ts +7 -1
  25. package/dist/core/request.d.ts.map +1 -1
  26. package/dist/core/request.js +32 -0
  27. package/dist/core/response.d.ts +2 -0
  28. package/dist/core/response.d.ts.map +1 -1
  29. package/dist/core/response.js +44 -19
  30. package/dist/events/request-events.d.ts +48 -0
  31. package/dist/events/request-events.d.ts.map +1 -0
  32. package/dist/events/request-events.js +85 -0
  33. package/dist/index.d.ts +28 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +28 -2
  36. package/dist/mcp/client.d.ts.map +1 -1
  37. package/dist/mcp/client.js +16 -5
  38. package/dist/mcp/contract.d.ts +77 -0
  39. package/dist/mcp/contract.d.ts.map +1 -0
  40. package/dist/mcp/contract.js +278 -0
  41. package/dist/mcp/types.d.ts +1 -0
  42. package/dist/mcp/types.d.ts.map +1 -1
  43. package/dist/plugins/auth.d.ts +45 -0
  44. package/dist/plugins/auth.d.ts.map +1 -0
  45. package/dist/plugins/auth.js +268 -0
  46. package/dist/plugins/cache.d.ts +7 -1
  47. package/dist/plugins/cache.d.ts.map +1 -1
  48. package/dist/plugins/cache.js +470 -49
  49. package/dist/plugins/circuit-breaker.js +1 -1
  50. package/dist/plugins/compression.d.ts.map +1 -1
  51. package/dist/plugins/compression.js +3 -3
  52. package/dist/plugins/dedup.d.ts.map +1 -1
  53. package/dist/plugins/dedup.js +2 -1
  54. package/dist/plugins/graphql.d.ts +4 -3
  55. package/dist/plugins/graphql.d.ts.map +1 -1
  56. package/dist/plugins/graphql.js +24 -5
  57. package/dist/plugins/grpc-web.d.ts +80 -0
  58. package/dist/plugins/grpc-web.d.ts.map +1 -0
  59. package/dist/plugins/grpc-web.js +261 -0
  60. package/dist/plugins/har-player.d.ts.map +1 -1
  61. package/dist/plugins/har-player.js +11 -2
  62. package/dist/plugins/hls.d.ts +33 -0
  63. package/dist/plugins/hls.d.ts.map +1 -0
  64. package/dist/plugins/hls.js +225 -0
  65. package/dist/plugins/http2-push.d.ts +64 -0
  66. package/dist/plugins/http2-push.d.ts.map +1 -0
  67. package/dist/plugins/http2-push.js +274 -0
  68. package/dist/plugins/http3.d.ts +76 -0
  69. package/dist/plugins/http3.d.ts.map +1 -0
  70. package/dist/plugins/http3.js +231 -0
  71. package/dist/plugins/interface-rotator.d.ts +10 -0
  72. package/dist/plugins/interface-rotator.d.ts.map +1 -0
  73. package/dist/plugins/interface-rotator.js +57 -0
  74. package/dist/plugins/jsonrpc.d.ts +76 -0
  75. package/dist/plugins/jsonrpc.d.ts.map +1 -0
  76. package/dist/plugins/jsonrpc.js +143 -0
  77. package/dist/plugins/logger.d.ts +8 -5
  78. package/dist/plugins/logger.d.ts.map +1 -1
  79. package/dist/plugins/logger.js +66 -30
  80. package/dist/plugins/odata.d.ts +182 -0
  81. package/dist/plugins/odata.d.ts.map +1 -0
  82. package/dist/plugins/odata.js +561 -0
  83. package/dist/plugins/retry.d.ts +1 -0
  84. package/dist/plugins/retry.d.ts.map +1 -1
  85. package/dist/plugins/retry.js +26 -2
  86. package/dist/plugins/scrape.d.ts +22 -0
  87. package/dist/plugins/scrape.d.ts.map +1 -0
  88. package/dist/plugins/scrape.js +87 -0
  89. package/dist/plugins/soap.d.ts +73 -0
  90. package/dist/plugins/soap.d.ts.map +1 -0
  91. package/dist/plugins/soap.js +347 -0
  92. package/dist/plugins/user-agent.d.ts +8 -0
  93. package/dist/plugins/user-agent.d.ts.map +1 -0
  94. package/dist/plugins/user-agent.js +46 -0
  95. package/dist/plugins/xml.d.ts +10 -0
  96. package/dist/plugins/xml.d.ts.map +1 -0
  97. package/dist/plugins/xml.js +194 -0
  98. package/dist/presets/anthropic.d.ts +7 -0
  99. package/dist/presets/anthropic.d.ts.map +1 -0
  100. package/dist/presets/anthropic.js +17 -0
  101. package/dist/presets/azure-openai.d.ts +9 -0
  102. package/dist/presets/azure-openai.d.ts.map +1 -0
  103. package/dist/presets/azure-openai.js +25 -0
  104. package/dist/presets/cloudflare.d.ts +13 -0
  105. package/dist/presets/cloudflare.d.ts.map +1 -0
  106. package/dist/presets/cloudflare.js +39 -0
  107. package/dist/presets/cohere.d.ts +6 -0
  108. package/dist/presets/cohere.d.ts.map +1 -0
  109. package/dist/presets/cohere.js +16 -0
  110. package/dist/presets/deepseek.d.ts +6 -0
  111. package/dist/presets/deepseek.d.ts.map +1 -0
  112. package/dist/presets/deepseek.js +16 -0
  113. package/dist/presets/digitalocean.d.ts +6 -0
  114. package/dist/presets/digitalocean.d.ts.map +1 -0
  115. package/dist/presets/digitalocean.js +16 -0
  116. package/dist/presets/discord.d.ts +7 -0
  117. package/dist/presets/discord.d.ts.map +1 -0
  118. package/dist/presets/discord.js +17 -0
  119. package/dist/presets/fireworks.d.ts +6 -0
  120. package/dist/presets/fireworks.d.ts.map +1 -0
  121. package/dist/presets/fireworks.js +16 -0
  122. package/dist/presets/gemini.d.ts +6 -0
  123. package/dist/presets/gemini.d.ts.map +1 -0
  124. package/dist/presets/gemini.js +16 -0
  125. package/dist/presets/github.d.ts +7 -0
  126. package/dist/presets/github.d.ts.map +1 -0
  127. package/dist/presets/github.js +17 -0
  128. package/dist/presets/gitlab.d.ts +7 -0
  129. package/dist/presets/gitlab.d.ts.map +1 -0
  130. package/dist/presets/gitlab.js +16 -0
  131. package/dist/presets/groq.d.ts +6 -0
  132. package/dist/presets/groq.d.ts.map +1 -0
  133. package/dist/presets/groq.js +16 -0
  134. package/dist/presets/huggingface.d.ts +6 -0
  135. package/dist/presets/huggingface.d.ts.map +1 -0
  136. package/dist/presets/huggingface.js +16 -0
  137. package/dist/presets/index.d.ts +28 -0
  138. package/dist/presets/index.d.ts.map +1 -0
  139. package/dist/presets/index.js +27 -0
  140. package/dist/presets/linear.d.ts +6 -0
  141. package/dist/presets/linear.d.ts.map +1 -0
  142. package/dist/presets/linear.js +16 -0
  143. package/dist/presets/mistral.d.ts +6 -0
  144. package/dist/presets/mistral.d.ts.map +1 -0
  145. package/dist/presets/mistral.js +16 -0
  146. package/dist/presets/notion.d.ts +7 -0
  147. package/dist/presets/notion.d.ts.map +1 -0
  148. package/dist/presets/notion.js +17 -0
  149. package/dist/presets/openai.d.ts +8 -0
  150. package/dist/presets/openai.d.ts.map +1 -0
  151. package/dist/presets/openai.js +23 -0
  152. package/dist/presets/perplexity.d.ts +6 -0
  153. package/dist/presets/perplexity.d.ts.map +1 -0
  154. package/dist/presets/perplexity.js +16 -0
  155. package/dist/presets/registry.d.ts +20 -0
  156. package/dist/presets/registry.d.ts.map +1 -0
  157. package/dist/presets/registry.js +311 -0
  158. package/dist/presets/replicate.d.ts +6 -0
  159. package/dist/presets/replicate.d.ts.map +1 -0
  160. package/dist/presets/replicate.js +16 -0
  161. package/dist/presets/slack.d.ts +6 -0
  162. package/dist/presets/slack.d.ts.map +1 -0
  163. package/dist/presets/slack.js +16 -0
  164. package/dist/presets/stripe.d.ts +8 -0
  165. package/dist/presets/stripe.d.ts.map +1 -0
  166. package/dist/presets/stripe.js +23 -0
  167. package/dist/presets/supabase.d.ts +7 -0
  168. package/dist/presets/supabase.d.ts.map +1 -0
  169. package/dist/presets/supabase.js +18 -0
  170. package/dist/presets/together.d.ts +6 -0
  171. package/dist/presets/together.d.ts.map +1 -0
  172. package/dist/presets/together.js +16 -0
  173. package/dist/presets/twilio.d.ts +7 -0
  174. package/dist/presets/twilio.d.ts.map +1 -0
  175. package/dist/presets/twilio.js +17 -0
  176. package/dist/presets/vercel.d.ts +7 -0
  177. package/dist/presets/vercel.d.ts.map +1 -0
  178. package/dist/presets/vercel.js +23 -0
  179. package/dist/presets/xai.d.ts +7 -0
  180. package/dist/presets/xai.d.ts.map +1 -0
  181. package/dist/presets/xai.js +17 -0
  182. package/dist/protocols/ftp.d.ts +63 -0
  183. package/dist/protocols/ftp.d.ts.map +1 -0
  184. package/dist/protocols/ftp.js +388 -0
  185. package/dist/protocols/index.d.ts +4 -0
  186. package/dist/protocols/index.d.ts.map +1 -0
  187. package/dist/protocols/index.js +3 -0
  188. package/dist/protocols/sftp.d.ts +65 -0
  189. package/dist/protocols/sftp.d.ts.map +1 -0
  190. package/dist/protocols/sftp.js +346 -0
  191. package/dist/protocols/telnet.d.ts +50 -0
  192. package/dist/protocols/telnet.d.ts.map +1 -0
  193. package/dist/protocols/telnet.js +139 -0
  194. package/dist/runner/request-runner.d.ts.map +1 -1
  195. package/dist/runner/request-runner.js +1 -0
  196. package/dist/scrape/document.d.ts +44 -0
  197. package/dist/scrape/document.d.ts.map +1 -0
  198. package/dist/scrape/document.js +198 -0
  199. package/dist/scrape/element.d.ts +50 -0
  200. package/dist/scrape/element.d.ts.map +1 -0
  201. package/dist/scrape/element.js +176 -0
  202. package/dist/scrape/extractors.d.ts +17 -0
  203. package/dist/scrape/extractors.d.ts.map +1 -0
  204. package/dist/scrape/extractors.js +356 -0
  205. package/dist/scrape/index.d.ts +5 -0
  206. package/dist/scrape/index.d.ts.map +1 -0
  207. package/dist/scrape/index.js +3 -0
  208. package/dist/scrape/types.d.ts +108 -0
  209. package/dist/scrape/types.d.ts.map +1 -0
  210. package/dist/scrape/types.js +1 -0
  211. package/dist/testing/index.d.ts +3 -0
  212. package/dist/testing/index.d.ts.map +1 -0
  213. package/dist/testing/index.js +1 -0
  214. package/dist/testing/mock.d.ts +58 -0
  215. package/dist/testing/mock.d.ts.map +1 -0
  216. package/dist/testing/mock.js +252 -0
  217. package/dist/transport/fetch.d.ts.map +1 -1
  218. package/dist/transport/fetch.js +12 -4
  219. package/dist/transport/undici.d.ts +17 -1
  220. package/dist/transport/undici.d.ts.map +1 -1
  221. package/dist/transport/undici.js +708 -47
  222. package/dist/types/index.d.ts +111 -10
  223. package/dist/types/index.d.ts.map +1 -1
  224. package/dist/types/index.js +1 -1
  225. package/dist/types/logger.d.ts +17 -0
  226. package/dist/types/logger.d.ts.map +1 -0
  227. package/dist/types/logger.js +66 -0
  228. package/dist/utils/agent-manager.d.ts.map +1 -1
  229. package/dist/utils/agent-manager.js +20 -4
  230. package/dist/utils/body.d.ts.map +1 -1
  231. package/dist/utils/body.js +14 -2
  232. package/dist/utils/charset.d.ts +16 -0
  233. package/dist/utils/charset.d.ts.map +1 -0
  234. package/dist/utils/charset.js +169 -0
  235. package/dist/utils/client-pool.d.ts +21 -0
  236. package/dist/utils/client-pool.d.ts.map +1 -0
  237. package/dist/utils/client-pool.js +49 -0
  238. package/dist/utils/concurrency.d.ts.map +1 -1
  239. package/dist/utils/concurrency.js +8 -4
  240. package/dist/utils/dns-toolkit.d.ts +13 -0
  241. package/dist/utils/dns-toolkit.d.ts.map +1 -0
  242. package/dist/utils/dns-toolkit.js +48 -0
  243. package/dist/utils/doh.d.ts.map +1 -1
  244. package/dist/utils/doh.js +16 -3
  245. package/dist/utils/download.d.ts +15 -0
  246. package/dist/utils/download.d.ts.map +1 -0
  247. package/dist/utils/download.js +44 -0
  248. package/dist/utils/env-proxy.d.ts +13 -0
  249. package/dist/utils/env-proxy.d.ts.map +1 -0
  250. package/dist/utils/env-proxy.js +105 -0
  251. package/dist/utils/header-parser.d.ts +15 -1
  252. package/dist/utils/header-parser.d.ts.map +1 -1
  253. package/dist/utils/header-parser.js +161 -1
  254. package/dist/utils/link-header.d.ts +70 -0
  255. package/dist/utils/link-header.d.ts.map +1 -0
  256. package/dist/utils/link-header.js +190 -0
  257. package/dist/utils/progress.d.ts +7 -2
  258. package/dist/utils/progress.d.ts.map +1 -1
  259. package/dist/utils/progress.js +48 -15
  260. package/dist/utils/rdap.d.ts +17 -0
  261. package/dist/utils/rdap.d.ts.map +1 -0
  262. package/dist/utils/rdap.js +32 -0
  263. package/dist/utils/request-pool.d.ts.map +1 -1
  264. package/dist/utils/request-pool.js +4 -3
  265. package/dist/utils/sse.d.ts.map +1 -1
  266. package/dist/utils/sse.js +8 -2
  267. package/dist/utils/status-codes.d.ts +84 -0
  268. package/dist/utils/status-codes.d.ts.map +1 -0
  269. package/dist/utils/status-codes.js +204 -0
  270. package/dist/utils/streaming.d.ts.map +1 -1
  271. package/dist/utils/streaming.js +1 -0
  272. package/dist/utils/tls-inspector.d.ts +21 -0
  273. package/dist/utils/tls-inspector.d.ts.map +1 -0
  274. package/dist/utils/tls-inspector.js +39 -0
  275. package/dist/utils/try-fn.d.ts.map +1 -1
  276. package/dist/utils/try-fn.js +11 -5
  277. package/dist/utils/upload.d.ts +1 -0
  278. package/dist/utils/upload.d.ts.map +1 -1
  279. package/dist/utils/upload.js +20 -3
  280. package/dist/utils/user-agent.d.ts +9 -9
  281. package/dist/utils/user-agent.js +9 -9
  282. package/dist/utils/whois.d.ts.map +1 -1
  283. package/dist/utils/whois.js +11 -2
  284. package/dist/websocket/client.d.ts +29 -1
  285. package/dist/websocket/client.d.ts.map +1 -1
  286. package/dist/websocket/client.js +145 -13
  287. package/package.json +45 -8
@@ -0,0 +1,57 @@
1
+ import { Agent } from 'undici';
2
+ import { networkInterfaces } from 'node:os';
3
+ export function interfaceRotator(options = {}) {
4
+ const strategy = options.strategy || 'round-robin';
5
+ const familyFilter = options.family || 'IPv4';
6
+ const excludeInternal = options.excludeInternal !== false;
7
+ let ips = options.ips || [];
8
+ if (ips.length === 0) {
9
+ const nets = networkInterfaces();
10
+ for (const name of Object.keys(nets)) {
11
+ if (options.interface) {
12
+ if (typeof options.interface === 'string' && name !== options.interface)
13
+ continue;
14
+ if (options.interface instanceof RegExp && !options.interface.test(name))
15
+ continue;
16
+ }
17
+ const netInfo = nets[name];
18
+ if (!netInfo)
19
+ continue;
20
+ for (const net of netInfo) {
21
+ if (excludeInternal && net.internal)
22
+ continue;
23
+ if (familyFilter !== 'both' && net.family !== familyFilter)
24
+ continue;
25
+ ips.push(net.address);
26
+ }
27
+ }
28
+ }
29
+ if (ips.length === 0) {
30
+ return () => { };
31
+ }
32
+ const agents = ips.map(ip => ({
33
+ ip,
34
+ agent: new Agent({
35
+ connect: {
36
+ localAddress: ip,
37
+ keepAlive: true,
38
+ timeout: 10000
39
+ }
40
+ })
41
+ }));
42
+ let index = 0;
43
+ return (client) => {
44
+ client.beforeRequest((req) => {
45
+ let selected;
46
+ if (strategy === 'random') {
47
+ selected = agents[Math.floor(Math.random() * agents.length)];
48
+ }
49
+ else {
50
+ selected = agents[index];
51
+ index = (index + 1) % agents.length;
52
+ }
53
+ req._dispatcher = selected.agent;
54
+ req._localAddress = selected.ip;
55
+ });
56
+ };
57
+ }
@@ -0,0 +1,76 @@
1
+ import type { Client } from '../core/client.js';
2
+ import type { RequestOptions } from '../types/index.js';
3
+ export interface JsonRpcRequest {
4
+ jsonrpc: '2.0';
5
+ method: string;
6
+ params?: unknown[] | Record<string, unknown>;
7
+ id?: string | number | null;
8
+ }
9
+ export interface JsonRpcResponse<T = unknown> {
10
+ jsonrpc: '2.0';
11
+ result?: T;
12
+ error?: JsonRpcError;
13
+ id: string | number | null;
14
+ }
15
+ export interface JsonRpcError {
16
+ code: number;
17
+ message: string;
18
+ data?: unknown;
19
+ }
20
+ export interface JsonRpcBatchResponse<T = unknown> {
21
+ responses: JsonRpcResponse<T>[];
22
+ errors: JsonRpcError[];
23
+ hasErrors: boolean;
24
+ }
25
+ export declare const JsonRpcErrorCodes: {
26
+ readonly PARSE_ERROR: -32700;
27
+ readonly INVALID_REQUEST: -32600;
28
+ readonly METHOD_NOT_FOUND: -32601;
29
+ readonly INVALID_PARAMS: -32602;
30
+ readonly INTERNAL_ERROR: -32603;
31
+ readonly SERVER_ERROR: -32000;
32
+ };
33
+ export declare class JsonRpcException extends Error {
34
+ readonly code: number;
35
+ readonly data?: unknown;
36
+ constructor(error: JsonRpcError);
37
+ static isParseError(error: JsonRpcException): boolean;
38
+ static isInvalidRequest(error: JsonRpcException): boolean;
39
+ static isMethodNotFound(error: JsonRpcException): boolean;
40
+ static isInvalidParams(error: JsonRpcException): boolean;
41
+ static isInternalError(error: JsonRpcException): boolean;
42
+ static isServerError(error: JsonRpcException): boolean;
43
+ }
44
+ export interface JsonRpcClientOptions {
45
+ endpoint: string;
46
+ requestOptions?: RequestOptions;
47
+ autoId?: boolean;
48
+ idGenerator?: () => string | number;
49
+ throwOnError?: boolean;
50
+ }
51
+ export declare class JsonRpcClient {
52
+ private client;
53
+ private options;
54
+ private idCounter;
55
+ constructor(client: Client, options: JsonRpcClientOptions);
56
+ call<T = unknown>(method: string, params?: unknown[] | Record<string, unknown>, options?: RequestOptions): Promise<T>;
57
+ notify(method: string, params?: unknown[] | Record<string, unknown>, options?: RequestOptions): Promise<void>;
58
+ batch<T = unknown>(requests: Array<{
59
+ method: string;
60
+ params?: unknown[] | Record<string, unknown>;
61
+ id?: string | number;
62
+ }>, options?: RequestOptions): Promise<JsonRpcBatchResponse<T>>;
63
+ getFromBatch<T>(batch: JsonRpcBatchResponse<T>, id: string | number): T | undefined;
64
+ proxy<T extends Record<string, (...args: unknown[]) => unknown>>(): {
65
+ [K in keyof T]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
66
+ };
67
+ private sendRequest;
68
+ }
69
+ export declare function createJsonRpcClient(client: Client, options: JsonRpcClientOptions): JsonRpcClient;
70
+ export declare function jsonrpc(): (client: Client) => void;
71
+ declare module '../core/client.js' {
72
+ interface Client {
73
+ jsonrpc(endpoint: string, options?: Omit<JsonRpcClientOptions, 'endpoint'>): JsonRpcClient;
74
+ }
75
+ }
76
+ //# sourceMappingURL=jsonrpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/plugins/jsonrpc.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAChC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,EAAE,OAAO,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1,143 @@
1
+ export const JsonRpcErrorCodes = {
2
+ PARSE_ERROR: -32700,
3
+ INVALID_REQUEST: -32600,
4
+ METHOD_NOT_FOUND: -32601,
5
+ INVALID_PARAMS: -32602,
6
+ INTERNAL_ERROR: -32603,
7
+ SERVER_ERROR: -32000,
8
+ };
9
+ export class JsonRpcException extends Error {
10
+ code;
11
+ data;
12
+ constructor(error) {
13
+ super(error.message);
14
+ this.name = 'JsonRpcException';
15
+ this.code = error.code;
16
+ this.data = error.data;
17
+ }
18
+ static isParseError(error) {
19
+ return error.code === JsonRpcErrorCodes.PARSE_ERROR;
20
+ }
21
+ static isInvalidRequest(error) {
22
+ return error.code === JsonRpcErrorCodes.INVALID_REQUEST;
23
+ }
24
+ static isMethodNotFound(error) {
25
+ return error.code === JsonRpcErrorCodes.METHOD_NOT_FOUND;
26
+ }
27
+ static isInvalidParams(error) {
28
+ return error.code === JsonRpcErrorCodes.INVALID_PARAMS;
29
+ }
30
+ static isInternalError(error) {
31
+ return error.code === JsonRpcErrorCodes.INTERNAL_ERROR;
32
+ }
33
+ static isServerError(error) {
34
+ return error.code >= -32099 && error.code <= -32000;
35
+ }
36
+ }
37
+ export class JsonRpcClient {
38
+ client;
39
+ options;
40
+ idCounter = 0;
41
+ constructor(client, options) {
42
+ this.client = client;
43
+ this.options = {
44
+ endpoint: options.endpoint,
45
+ requestOptions: options.requestOptions ?? {},
46
+ autoId: options.autoId ?? true,
47
+ idGenerator: options.idGenerator ?? (() => ++this.idCounter),
48
+ throwOnError: options.throwOnError ?? true,
49
+ };
50
+ }
51
+ async call(method, params, options) {
52
+ const id = this.options.autoId ? this.options.idGenerator() : null;
53
+ const request = {
54
+ jsonrpc: '2.0',
55
+ method,
56
+ id,
57
+ };
58
+ if (params !== undefined) {
59
+ request.params = params;
60
+ }
61
+ const response = await this.sendRequest(request, options);
62
+ if (response.error) {
63
+ if (this.options.throwOnError) {
64
+ throw new JsonRpcException(response.error);
65
+ }
66
+ return undefined;
67
+ }
68
+ return response.result;
69
+ }
70
+ async notify(method, params, options) {
71
+ const request = {
72
+ jsonrpc: '2.0',
73
+ method,
74
+ };
75
+ if (params !== undefined) {
76
+ request.params = params;
77
+ }
78
+ await this.client.post(this.options.endpoint, {
79
+ ...this.options.requestOptions,
80
+ ...options,
81
+ json: request,
82
+ });
83
+ }
84
+ async batch(requests, options) {
85
+ const batchRequests = requests.map((req, index) => ({
86
+ jsonrpc: '2.0',
87
+ method: req.method,
88
+ params: req.params,
89
+ id: req.id ?? (this.options.autoId ? this.options.idGenerator() : index),
90
+ }));
91
+ const response = await this.client.post(this.options.endpoint, {
92
+ ...this.options.requestOptions,
93
+ ...options,
94
+ json: batchRequests,
95
+ });
96
+ const responses = await response.json();
97
+ const errors = responses
98
+ .filter((r) => !!r.error)
99
+ .map((r) => r.error);
100
+ return {
101
+ responses,
102
+ errors,
103
+ hasErrors: errors.length > 0,
104
+ };
105
+ }
106
+ getFromBatch(batch, id) {
107
+ const response = batch.responses.find((r) => r.id === id);
108
+ if (response?.error && this.options.throwOnError) {
109
+ throw new JsonRpcException(response.error);
110
+ }
111
+ return response?.result;
112
+ }
113
+ proxy() {
114
+ return new Proxy({}, {
115
+ get: (_, method) => {
116
+ return (...args) => {
117
+ if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0])) {
118
+ return this.call(method, args[0]);
119
+ }
120
+ return this.call(method, args);
121
+ };
122
+ },
123
+ });
124
+ }
125
+ async sendRequest(request, options) {
126
+ const response = await this.client.post(this.options.endpoint, {
127
+ ...this.options.requestOptions,
128
+ ...options,
129
+ json: request,
130
+ });
131
+ return response.json();
132
+ }
133
+ }
134
+ export function createJsonRpcClient(client, options) {
135
+ return new JsonRpcClient(client, options);
136
+ }
137
+ export function jsonrpc() {
138
+ return (client) => {
139
+ client.jsonrpc = (endpoint, options) => {
140
+ return createJsonRpcClient(client, { endpoint, ...options });
141
+ };
142
+ };
143
+ }
@@ -1,11 +1,14 @@
1
1
  import { Plugin, ReckerRequest } from '../types/index.js';
2
- export interface LoggerOptions {
3
- log?: (message: string) => void;
4
- logError?: (message: string, error: any) => void;
2
+ import { Logger } from '../types/logger.js';
3
+ export interface LoggerPluginOptions {
4
+ logger?: Logger;
5
+ level?: 'debug' | 'info';
5
6
  showHeaders?: boolean;
6
7
  showBody?: boolean;
7
- colors?: boolean;
8
+ showTimings?: boolean;
8
9
  }
9
- export declare function logger(options?: LoggerOptions): Plugin;
10
+ export declare function logger(options?: LoggerPluginOptions): Plugin;
10
11
  export declare function toCurl(req: ReckerRequest): string;
12
+ export type { Logger } from '../types/logger.js';
13
+ export { consoleLogger, silentLogger, createLevelLogger } from '../types/logger.js';
11
14
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/plugins/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAcD,wBAAgB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CAkD1D;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA4BjD"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/plugins/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAiB,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAiBlC,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAMzB,WAAW,CAAC,EAAE,OAAO,CAAC;IAMtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAMnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAyCD,wBAAgB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAoGhE;AAaD,wBAAgB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA8BjD;AAGD,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,50 +1,84 @@
1
- const ANSI = {
2
- RESET: "\x1b[0m",
3
- BOLD: "\x1b[1m",
4
- DIM: "\x1b[2m",
5
- RED: "\x1b[31m",
6
- GREEN: "\x1b[32m",
7
- YELLOW: "\x1b[33m",
8
- BLUE: "\x1b[34m",
9
- MAGENTA: "\x1b[35m",
10
- CYAN: "\x1b[36m",
11
- };
1
+ import { consoleLogger } from '../types/logger.js';
12
2
  export function logger(options = {}) {
13
- const log = options.log || console.log;
14
- const logError = options.logError || console.error;
3
+ const log = options.logger || consoleLogger;
4
+ const level = options.level || 'info';
15
5
  const showHeaders = options.showHeaders || false;
16
6
  const showBody = options.showBody || false;
17
- const useColors = options.colors !== false;
18
- const c = (color, text) => useColors ? `${ANSI[color]}${text}${ANSI.RESET}` : text;
7
+ const showTimings = options.showTimings !== false;
19
8
  const timers = new WeakMap();
9
+ const logFn = level === 'debug' ? log.debug.bind(log) : log.info.bind(log);
20
10
  return (client) => {
21
11
  client.beforeRequest((req) => {
22
12
  timers.set(req, performance.now());
23
- const method = c('BLUE', req.method.padEnd(7));
24
- const url = c('CYAN', req.url);
25
- log(`${c('BOLD', '-->')} ${method} ${url}`);
13
+ const logData = {
14
+ type: 'request',
15
+ method: req.method,
16
+ url: req.url,
17
+ };
26
18
  if (showHeaders) {
27
- req.headers.forEach((v, k) => log(` ${c('DIM', k)}: ${v}`));
19
+ const headers = {};
20
+ req.headers.forEach((v, k) => {
21
+ if (k.toLowerCase() === 'authorization') {
22
+ headers[k] = '[REDACTED]';
23
+ }
24
+ else {
25
+ headers[k] = v;
26
+ }
27
+ });
28
+ logData.headers = headers;
28
29
  }
29
30
  if (showBody && req.body) {
30
- log(` ${c('DIM', 'Body')}: ${typeof req.body === 'string' ? req.body : '[Object/Stream]'}`);
31
+ if (typeof req.body === 'string') {
32
+ try {
33
+ logData.body = JSON.parse(req.body);
34
+ }
35
+ catch {
36
+ logData.body = req.body;
37
+ }
38
+ }
39
+ else {
40
+ logData.body = '[Stream/Binary]';
41
+ }
31
42
  }
43
+ logFn(logData, `→ ${req.method} ${req.url}`);
32
44
  });
33
45
  client.afterResponse((req, res) => {
34
46
  const start = timers.get(req);
35
- const duration = start ? (performance.now() - start).toFixed(0) + 'ms' : '?';
36
- const statusColor = res.ok ? 'GREEN' : 'RED';
37
- const status = c(statusColor, String(res.status));
38
- const statusText = c(statusColor, res.statusText);
39
- log(`${c('BOLD', '<--')} ${c('BLUE', req.method.padEnd(7))} ${c('CYAN', req.url)} ${status} ${statusText} ${c('YELLOW', duration)}`);
47
+ const duration = start ? Math.round(performance.now() - start) : 0;
48
+ const logData = {
49
+ type: 'response',
50
+ method: req.method,
51
+ url: req.url,
52
+ status: res.status,
53
+ statusText: res.statusText,
54
+ ok: res.ok,
55
+ duration,
56
+ };
40
57
  if (showHeaders) {
41
- res.headers.forEach((v, k) => log(` ${c('DIM', k)}: ${v}`));
58
+ const headers = {};
59
+ res.headers.forEach((v, k) => (headers[k] = v));
60
+ logData.headers = headers;
42
61
  }
62
+ if (showTimings && res.timings) {
63
+ logData.timings = res.timings;
64
+ }
65
+ const contentLength = res.headers.get('content-length');
66
+ if (contentLength) {
67
+ logData.size = parseInt(contentLength, 10);
68
+ }
69
+ logFn(logData, `← ${res.status} ${req.method} ${req.url} (${duration}ms)`);
43
70
  });
44
71
  client.onError((err, req) => {
45
72
  const start = timers.get(req);
46
- const duration = start ? (performance.now() - start).toFixed(0) + 'ms' : '?';
47
- logError(`${c('RED', '!!!')} ${c('BLUE', req.method)} ${c('CYAN', req.url)} ${c('RED', err.message)} ${c('YELLOW', duration)}`, err);
73
+ const duration = start ? Math.round(performance.now() - start) : 0;
74
+ log.error({
75
+ type: 'error',
76
+ method: req.method,
77
+ url: req.url,
78
+ error: err.message,
79
+ errorName: err.name,
80
+ duration,
81
+ }, `✖ ${req.method} ${req.url} - ${err.message}`);
48
82
  });
49
83
  };
50
84
  }
@@ -55,7 +89,8 @@ export function toCurl(req) {
55
89
  }
56
90
  parts.push(`'${req.url}'`);
57
91
  req.headers.forEach((value, key) => {
58
- parts.push(`-H '${key}: ${value}'`);
92
+ const displayValue = key.toLowerCase() === 'authorization' ? '[REDACTED]' : value;
93
+ parts.push(`-H '${key}: ${displayValue}'`);
59
94
  });
60
95
  if (req.body) {
61
96
  if (typeof req.body === 'string') {
@@ -68,5 +103,6 @@ export function toCurl(req) {
68
103
  parts.push(`-d '[Body]'`);
69
104
  }
70
105
  }
71
- return parts.join(' ');
106
+ return parts.join(' \\\n ');
72
107
  }
108
+ export { consoleLogger, silentLogger, createLevelLogger } from '../types/logger.js';
@@ -0,0 +1,182 @@
1
+ import type { Client } from '../core/client.js';
2
+ import type { RequestOptions } from '../types/index.js';
3
+ export interface ODataOptions {
4
+ serviceRoot: string;
5
+ version?: '4.0' | '4.01';
6
+ maxPageSize?: number;
7
+ requestOptions?: RequestOptions;
8
+ }
9
+ export interface ODataQueryOptions {
10
+ $select?: string | string[];
11
+ $expand?: string | string[] | ExpandOption[];
12
+ $filter?: string | FilterExpression;
13
+ $orderby?: string | OrderByOption[];
14
+ $top?: number;
15
+ $skip?: number;
16
+ $count?: boolean;
17
+ $search?: string;
18
+ $format?: 'json' | 'xml' | 'atom';
19
+ [key: string]: unknown;
20
+ }
21
+ export interface ExpandOption {
22
+ property: string;
23
+ select?: string[];
24
+ expand?: ExpandOption[];
25
+ filter?: string | FilterExpression;
26
+ orderby?: string | OrderByOption[];
27
+ top?: number;
28
+ skip?: number;
29
+ count?: boolean;
30
+ }
31
+ export interface OrderByOption {
32
+ property: string;
33
+ direction?: 'asc' | 'desc';
34
+ }
35
+ export interface FilterExpression {
36
+ and?: FilterExpression[];
37
+ or?: FilterExpression[];
38
+ not?: FilterExpression;
39
+ eq?: [string, unknown];
40
+ ne?: [string, unknown];
41
+ gt?: [string, unknown];
42
+ ge?: [string, unknown];
43
+ lt?: [string, unknown];
44
+ le?: [string, unknown];
45
+ contains?: [string, string];
46
+ startswith?: [string, string];
47
+ endswith?: [string, string];
48
+ raw?: string;
49
+ }
50
+ export interface ODataResponse<T = unknown> {
51
+ '@odata.context'?: string;
52
+ '@odata.count'?: number;
53
+ '@odata.nextLink'?: string;
54
+ value?: T[];
55
+ [key: string]: unknown;
56
+ }
57
+ export interface ODataEntityResponse<T = unknown> extends ODataResponse<T> {
58
+ '@odata.etag'?: string;
59
+ }
60
+ export interface ODataError {
61
+ error: {
62
+ code: string;
63
+ message: string;
64
+ target?: string;
65
+ details?: Array<{
66
+ code: string;
67
+ message: string;
68
+ target?: string;
69
+ }>;
70
+ innererror?: {
71
+ message?: string;
72
+ type?: string;
73
+ stacktrace?: string;
74
+ };
75
+ };
76
+ }
77
+ export declare class ODataException extends Error {
78
+ readonly code: string;
79
+ readonly target?: string;
80
+ readonly details?: Array<{
81
+ code: string;
82
+ message: string;
83
+ target?: string;
84
+ }>;
85
+ readonly innererror?: {
86
+ message?: string;
87
+ type?: string;
88
+ stacktrace?: string;
89
+ };
90
+ constructor(error: ODataError['error']);
91
+ }
92
+ export declare class ODataQueryBuilder<T = unknown> {
93
+ private client;
94
+ private entitySet;
95
+ private entityKey?;
96
+ private queryOptions;
97
+ private requestOptions?;
98
+ constructor(client: ODataClient, entitySet: string);
99
+ key(key: string | number | Record<string, unknown>): this;
100
+ select(...properties: string[]): this;
101
+ expand(...properties: (string | ExpandOption)[]): this;
102
+ filter(filter: string | FilterExpression | ((builder: FilterBuilder) => FilterBuilder)): this;
103
+ orderBy(property: string, direction?: 'asc' | 'desc'): this;
104
+ top(count: number): this;
105
+ skip(count: number): this;
106
+ count(include?: boolean): this;
107
+ search(term: string): this;
108
+ custom(key: string, value: unknown): this;
109
+ options(options: RequestOptions): this;
110
+ get(): Promise<ODataResponse<T>>;
111
+ getAll(): AsyncGenerator<T, void, unknown>;
112
+ toUrl(): string;
113
+ }
114
+ export declare class FilterBuilder {
115
+ private parts;
116
+ eq(property: string, value: unknown): this;
117
+ ne(property: string, value: unknown): this;
118
+ gt(property: string, value: unknown): this;
119
+ ge(property: string, value: unknown): this;
120
+ lt(property: string, value: unknown): this;
121
+ le(property: string, value: unknown): this;
122
+ contains(property: string, value: string): this;
123
+ startswith(property: string, value: string): this;
124
+ endswith(property: string, value: string): this;
125
+ isNull(property: string): this;
126
+ isNotNull(property: string): this;
127
+ in(property: string, values: unknown[]): this;
128
+ and(): this;
129
+ or(): this;
130
+ not(): this;
131
+ group(builder: (b: FilterBuilder) => FilterBuilder): this;
132
+ raw(expression: string): this;
133
+ build(): string;
134
+ private formatValue;
135
+ private escapeString;
136
+ }
137
+ export declare class ODataClient {
138
+ private client;
139
+ private options;
140
+ constructor(client: Client, options: ODataOptions);
141
+ query<T = unknown>(entitySet: string): ODataQueryBuilder<T>;
142
+ get<T = unknown>(entitySet: string, key?: string | number | Record<string, unknown>, queryOptions?: ODataQueryOptions, requestOptions?: RequestOptions): Promise<ODataResponse<T>>;
143
+ getById<T = unknown>(entitySet: string, key: string | number | Record<string, unknown>, queryOptions?: ODataQueryOptions, requestOptions?: RequestOptions): Promise<T>;
144
+ getNextPage<T = unknown>(nextLink: string): Promise<ODataResponse<T>>;
145
+ create<T = unknown>(entitySet: string, entity: Partial<T>, requestOptions?: RequestOptions): Promise<T>;
146
+ update<T = unknown>(entitySet: string, key: string | number | Record<string, unknown>, entity: Partial<T>, requestOptions?: RequestOptions): Promise<T>;
147
+ replace<T = unknown>(entitySet: string, key: string | number | Record<string, unknown>, entity: T, requestOptions?: RequestOptions): Promise<T>;
148
+ delete(entitySet: string, key: string | number | Record<string, unknown>, requestOptions?: RequestOptions): Promise<void>;
149
+ action<T = unknown>(action: string, params?: Record<string, unknown>, requestOptions?: RequestOptions): Promise<T>;
150
+ function<T = unknown>(func: string, params?: Record<string, unknown>, requestOptions?: RequestOptions): Promise<T>;
151
+ batch(requests: Array<{
152
+ method: string;
153
+ url: string;
154
+ body?: unknown;
155
+ headers?: Record<string, string>;
156
+ }>, requestOptions?: RequestOptions): Promise<Array<{
157
+ status: number;
158
+ body: unknown;
159
+ }>>;
160
+ getMetadata(): Promise<string>;
161
+ buildUrl(entitySet: string, key?: string | number | Record<string, unknown>, queryOptions?: ODataQueryOptions): string;
162
+ private getHeaders;
163
+ private request;
164
+ private handleResponse;
165
+ private formatKey;
166
+ private formatKeyValue;
167
+ private buildQueryString;
168
+ private formatExpand;
169
+ private formatExpandOption;
170
+ private formatOrderBy;
171
+ private formatFilterExpression;
172
+ private formatFilterValue;
173
+ private parseBatchResponse;
174
+ }
175
+ export declare function createODataClient(client: Client, options: ODataOptions): ODataClient;
176
+ export declare function odata(): (client: Client) => void;
177
+ declare module '../core/client.js' {
178
+ interface Client {
179
+ odata(serviceRoot: string, options?: Omit<ODataOptions, 'serviceRoot'>): ODataClient;
180
+ }
181
+ }
182
+ //# sourceMappingURL=odata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odata.d.ts","sourceRoot":"","sources":["../../src/plugins/odata.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AAMxE,MAAM,WAAW,YAAY;IAE3B,WAAW,EAAE,MAAM,CAAC;IAEpB,OAA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