rezo 1.0.30 → 1.0.31

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 (60) hide show
  1. package/dist/adapters/curl.cjs +8 -10
  2. package/dist/adapters/curl.js +8 -10
  3. package/dist/adapters/entries/curl.d.ts +169 -313
  4. package/dist/adapters/entries/fetch.d.ts +169 -313
  5. package/dist/adapters/entries/http.d.ts +169 -313
  6. package/dist/adapters/entries/http2.d.ts +169 -313
  7. package/dist/adapters/entries/react-native.d.ts +169 -313
  8. package/dist/adapters/entries/xhr.d.ts +169 -313
  9. package/dist/adapters/fetch.cjs +10 -7
  10. package/dist/adapters/fetch.js +10 -7
  11. package/dist/adapters/http.cjs +9 -12
  12. package/dist/adapters/http.js +9 -12
  13. package/dist/adapters/http2.cjs +6 -11
  14. package/dist/adapters/http2.js +6 -11
  15. package/dist/adapters/index.cjs +6 -6
  16. package/dist/adapters/react-native.cjs +4 -4
  17. package/dist/adapters/react-native.js +4 -4
  18. package/dist/adapters/xhr.cjs +4 -4
  19. package/dist/adapters/xhr.js +4 -4
  20. package/dist/cache/index.cjs +13 -13
  21. package/dist/cache/universal-response-cache.cjs +156 -0
  22. package/dist/cache/universal-response-cache.js +155 -0
  23. package/dist/core/rezo.cjs +2 -8
  24. package/dist/core/rezo.js +2 -8
  25. package/dist/crawler.d.ts +163 -313
  26. package/dist/entries/crawler.cjs +5 -5
  27. package/dist/index.cjs +24 -24
  28. package/dist/index.d.ts +169 -313
  29. package/dist/platform/browser.d.ts +169 -313
  30. package/dist/platform/bun.d.ts +169 -313
  31. package/dist/platform/deno.d.ts +169 -313
  32. package/dist/platform/node.d.ts +169 -313
  33. package/dist/platform/react-native.d.ts +169 -313
  34. package/dist/platform/worker.d.ts +169 -313
  35. package/dist/plugin/crawler.cjs +1 -1
  36. package/dist/plugin/crawler.js +1 -1
  37. package/dist/plugin/index.cjs +36 -36
  38. package/dist/proxy/index.cjs +4 -4
  39. package/dist/queue/index.cjs +8 -8
  40. package/dist/responses/buildResponse.cjs +15 -15
  41. package/dist/responses/buildResponse.js +15 -15
  42. package/dist/responses/universal/download.cjs +23 -0
  43. package/dist/responses/universal/download.js +22 -0
  44. package/dist/responses/universal/event-emitter.cjs +104 -0
  45. package/dist/responses/universal/event-emitter.js +102 -0
  46. package/dist/responses/universal/index.cjs +11 -0
  47. package/dist/responses/universal/index.js +4 -0
  48. package/dist/responses/universal/stream.cjs +32 -0
  49. package/dist/responses/universal/stream.js +31 -0
  50. package/dist/responses/universal/upload.cjs +23 -0
  51. package/dist/responses/universal/upload.js +22 -0
  52. package/dist/utils/cookies.browser.cjs +63 -0
  53. package/dist/utils/cookies.browser.js +61 -0
  54. package/dist/utils/form-data.cjs +212 -189
  55. package/dist/utils/form-data.js +212 -189
  56. package/dist/utils/http-config.cjs +28 -15
  57. package/dist/utils/http-config.js +28 -15
  58. package/package.json +11 -4
  59. package/dist/types/cookies.cjs +0 -394
  60. package/dist/types/cookies.js +0 -391
package/dist/crawler.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import NodeFormData from 'form-data';
2
1
  import { Blob as Blob$1 } from 'node:buffer';
3
- import { EventEmitter } from 'node:events';
4
2
  import { Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
5
3
  import { Agent as HttpsAgent } from 'node:https';
6
4
  import { Socket } from 'node:net';
7
- import { Readable, Readable as ReadableType, Writable, WritableOptions } from 'node:stream';
8
5
  import { SecureContext, TLSSocket } from 'node:tls';
9
6
  import { Cookie as TouchCookie, CookieJar as TouchCookieJar, CreateCookieOptions } from 'tough-cookie';
10
7
 
@@ -532,82 +529,123 @@ export interface Cookies {
532
529
  string: string;
533
530
  setCookiesString: string[];
534
531
  }
535
- export interface ReadableOptions {
536
- highWaterMark?: number;
537
- encoding?: string;
538
- objectMode?: boolean;
539
- read?(this: ReadableType, size: number): void;
540
- destroy?(this: ReadableType, error: Error | null, callback: (error: Error | null) => void): void;
541
- autoDestroy?: boolean;
542
- }
543
- export interface Options extends ReadableOptions {
544
- writable?: boolean;
545
- readable?: boolean;
546
- dataSize?: number;
547
- maxDataSize?: number;
548
- pauseStreams?: boolean;
549
- }
550
- declare class RezoFormData extends NodeFormData {
551
- constructor(options?: Options);
532
+ declare class RezoFormData {
533
+ private _fd;
534
+ private _cachedContentType;
535
+ private _cachedBuffer;
536
+ constructor();
552
537
  /**
553
- * Get field entries as array of [name, value] pairs
554
- * @returns {Promise<Array<[string, any]>>} Array of field entries
538
+ * Append a field to the form data
539
+ * @param name - Field name
540
+ * @param value - Field value (string, Blob, or Buffer)
541
+ * @param filename - Optional filename for file uploads
542
+ * @warning Buffer is only available in Node.js/Bun/Deno. Use Blob for browser/React Native.
555
543
  */
556
- getFieldEntries(): Promise<Array<[
544
+ append(name: string, value: string | Blob | Buffer, filename?: string): void;
545
+ /**
546
+ * Set a field in the form data (replaces existing)
547
+ * @param name - Field name
548
+ * @param value - Field value (string, Blob, or Buffer)
549
+ * @param filename - Optional filename for file uploads
550
+ * @warning Buffer is only available in Node.js/Bun/Deno. Use Blob for browser/React Native.
551
+ */
552
+ set(name: string, value: string | Blob | Buffer, filename?: string): void;
553
+ get(name: string): FormDataEntryValue | null;
554
+ getAll(name: string): FormDataEntryValue[];
555
+ has(name: string): boolean;
556
+ delete(name: string): void;
557
+ entries(): IterableIterator<[
557
558
  string,
558
- any
559
- ]>>;
559
+ FormDataEntryValue
560
+ ]>;
561
+ keys(): IterableIterator<string>;
562
+ values(): IterableIterator<FormDataEntryValue>;
563
+ forEach(callback: (value: FormDataEntryValue, key: string, parent: FormData) => void): void;
564
+ [Symbol.iterator](): IterableIterator<[
565
+ string,
566
+ FormDataEntryValue
567
+ ]>;
560
568
  /**
561
- * Convert to native FormData
562
- * @returns {Promise<FormData | null>}
569
+ * Get the underlying native FormData
563
570
  */
564
- toNativeFormData(): Promise<FormData | null>;
571
+ toNativeFormData(): FormData;
565
572
  /**
566
- * Create RezoFormData from native FormData
567
- * @param {FormData} formData - Native FormData object
568
- * @param {Options} options - Optional RezoFormData options
569
- * @returns {Promise<RezoFormData>}
573
+ * Invalidate cached values when form data changes
574
+ */
575
+ private _invalidateCache;
576
+ /**
577
+ * Build and cache the Response for extracting headers and body
578
+ */
579
+ private _buildResponse;
580
+ /**
581
+ * Get boundary extracted from Content-Type header
582
+ * Must be called after getContentTypeAsync() to get accurate value
583
+ */
584
+ getBoundary(): string;
585
+ /**
586
+ * Get content type with boundary
587
+ * Returns cached value if available, otherwise returns undefined
588
+ * Use getContentTypeAsync() for guaranteed result
589
+ */
590
+ getContentType(): string | undefined;
591
+ /**
592
+ * Get content type asynchronously with proper boundary
593
+ */
594
+ getContentTypeAsync(): Promise<string>;
595
+ /**
596
+ * Get headers for HTTP request
597
+ * Use getHeadersAsync() for complete headers with boundary
598
+ */
599
+ getHeaders(): Record<string, string>;
600
+ /**
601
+ * Get headers asynchronously with proper Content-Type and boundary
602
+ */
603
+ getHeadersAsync(): Promise<Record<string, string>>;
604
+ /**
605
+ * Get length synchronously - returns cached value if available
606
+ * Use getLength() for guaranteed result
570
607
  */
571
- static fromNativeFormData(formData: FormData, options?: Options): Promise<RezoFormData>;
608
+ getLengthSync(): number | undefined;
572
609
  /**
573
- * Get the content type header for this form data
574
- * @returns {string} Content type with boundary
610
+ * Get length asynchronously (works in all environments)
575
611
  */
576
- getContentType(): string;
612
+ getLength(): Promise<number>;
577
613
  /**
578
- * Convert form data to Buffer
579
- * @returns {Buffer} Form data as buffer
614
+ * Get buffer synchronously - returns cached value if available
615
+ * Use toBuffer() for guaranteed result
616
+ * @warning Only works in Node.js/Bun/Deno. Returns null in browser/React Native.
580
617
  */
581
- toBuffer(): Buffer;
618
+ getBuffer(): Buffer | null;
619
+ /**
620
+ * Convert to Buffer asynchronously
621
+ * @warning Only works in Node.js/Bun/Deno. Use toArrayBuffer() for browser/React Native.
622
+ */
623
+ toBuffer(): Promise<Buffer>;
624
+ /**
625
+ * Convert to ArrayBuffer asynchronously (works in all environments)
626
+ */
627
+ toArrayBuffer(): Promise<ArrayBuffer>;
628
+ /**
629
+ * Convert to Uint8Array asynchronously (works in all environments)
630
+ */
631
+ toUint8Array(): Promise<Uint8Array>;
582
632
  /**
583
633
  * Create RezoFormData from object
584
- * Properly handles nested objects by JSON.stringify-ing them
585
- * @param {Record<string, any>} obj - Object to convert
586
- * @param {Options} options - Optional RezoFormData options
587
- * @returns {RezoFormData}
634
+ * Handles nested objects, arrays, Blobs, Files, and Buffers
588
635
  */
589
- static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
636
+ static fromObject(obj: Record<string, unknown>): RezoFormData;
590
637
  /**
591
- * Helper to append a value to FormData with proper type handling
592
- * @param {RezoFormData} formData - The form data to append to
593
- * @param {string} key - The field name
594
- * @param {any} value - The value to append
638
+ * Create RezoFormData from native FormData
595
639
  */
596
- private static appendValue;
640
+ static fromNativeFormData(formData: FormData): RezoFormData;
597
641
  /**
598
- * Convert to URL query string
599
- * Warning: File, Blob, and binary data will be omitted
600
- * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
601
- * @returns {Promise<string>} URL query string
642
+ * Convert to URL query string (only string values, binary data omitted)
602
643
  */
603
- toUrlQueryString(convertBinaryToBase64?: boolean): Promise<string>;
644
+ toUrlQueryString(): string;
604
645
  /**
605
- * Convert to URLSearchParams object
606
- * Warning: File, Blob, and binary data will be omitted
607
- * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
608
- * @returns {Promise<URLSearchParams>} URLSearchParams object
646
+ * Convert to URLSearchParams (only string values, binary data omitted)
609
647
  */
610
- toURLSearchParams(convertBinaryToBase64?: boolean): Promise<URLSearchParams>;
648
+ toURLSearchParams(): URLSearchParams;
611
649
  }
612
650
  /**
613
651
  * Emitted when request is initiated
@@ -853,115 +891,44 @@ export type SanitizedRezoConfig = Omit<RezoConfig, "data"> & {
853
891
  data?: never;
854
892
  };
855
893
  /**
856
- * Event map for StreamResponse - defines all available events and their signatures
894
+ * Standard RezoResponse for non-streaming requests
895
+ * Contains response data, status, headers, cookies, and execution metadata
857
896
  */
858
- export interface StreamResponseEvents {
859
- close: [
860
- ];
861
- drain: [
862
- ];
863
- error: [
864
- err: RezoError
865
- ];
866
- finish: [
867
- info: StreamFinishEvent
868
- ];
869
- done: [
870
- info: StreamFinishEvent
871
- ];
872
- start: [
873
- info: RequestStartEvent
874
- ];
875
- initiated: [
876
- ];
877
- headers: [
878
- info: ResponseHeadersEvent
879
- ];
880
- cookies: [
881
- cookies: Cookie[]
882
- ];
883
- status: [
884
- status: number,
885
- statusText: string
886
- ];
887
- redirect: [
888
- info: RedirectEvent
889
- ];
890
- progress: [
891
- progress: ProgressEvent$1
892
- ];
893
- data: [
894
- chunk: Buffer | string
895
- ];
896
- pipe: [
897
- src: Readable
898
- ];
899
- unpipe: [
900
- src: Readable
901
- ];
897
+ export interface RezoResponse<T = any> {
898
+ data: T;
899
+ status: number;
900
+ statusText: string;
901
+ finalUrl: string;
902
+ cookies: Cookies;
903
+ headers: RezoHeaders;
904
+ contentType: string | undefined;
905
+ contentLength: number;
906
+ urls: string[];
907
+ config: RezoConfig;
902
908
  }
903
909
  /**
904
- * Complete type-safe event method overrides for StreamResponse
905
- * All event listener methods return 'this' for chaining
910
+ * Platform-agnostic base interface for event-emitting responses
911
+ * Can be implemented by both Node.js EventEmitter and browser-safe implementations
906
912
  */
907
- export interface StreamResponseEventOverrides {
908
- on<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
909
- on(event: string | symbol, listener: (...args: any[]) => void): this;
910
- once<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
911
- once(event: string | symbol, listener: (...args: any[]) => void): this;
912
- addListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
913
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
914
- prependListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
915
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
916
- prependOnceListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
917
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
918
- }
919
- declare class StreamResponse extends Writable implements StreamResponseEventOverrides {
920
- private _finished;
921
- private _encoding?;
922
- constructor(opts?: WritableOptions);
923
- /**
924
- * Set encoding for string chunks
925
- * @param encoding - Buffer encoding (utf8, ascii, etc.)
926
- * @returns this for chaining
927
- */
928
- setEncoding(encoding: BufferEncoding): this;
929
- /**
930
- * Get current encoding
931
- */
932
- getEncoding(): BufferEncoding | undefined;
933
- /**
934
- * Check if stream has finished
935
- */
936
- isFinished(): boolean;
937
- /**
938
- * Mark stream as finished (internal use)
939
- * @internal
940
- */
941
- _markFinished(): void;
942
- /**
943
- * Internal write implementation required by Writable
944
- * Emits 'data' event for each chunk received
945
- * @internal
946
- */
947
- _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
913
+ export interface BaseEventEmitter {
948
914
  on(event: string | symbol, listener: (...args: any[]) => void): this;
949
915
  once(event: string | symbol, listener: (...args: any[]) => void): this;
950
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
951
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
952
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
953
916
  off(event: string | symbol, listener: (...args: any[]) => void): this;
917
+ emit(event: string | symbol, ...args: any[]): boolean;
954
918
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
955
919
  removeAllListeners(event?: string | symbol): this;
920
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
956
921
  }
957
922
  /**
958
- * Complete type-safe event method overrides for DownloadResponse
959
- * All event listener methods return 'this' for chaining
923
+ * RezoStreamResponse - For responseType: 'stream'
924
+ * Platform-agnostic interface for streaming responses
925
+ * Emits 'data' events for response body chunks
960
926
  */
961
- export interface DownloadResponseEventOverrides {
927
+ export interface RezoStreamResponse extends BaseEventEmitter {
928
+ on(event: "data", listener: (chunk: Uint8Array | string) => void): this;
962
929
  on(event: "error", listener: (err: RezoError) => void): this;
963
- on(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
964
- on(event: "done", listener: (info: DownloadFinishEvent) => void): this;
930
+ on(event: "finish", listener: (info: StreamFinishEvent) => void): this;
931
+ on(event: "done", listener: (info: StreamFinishEvent) => void): this;
965
932
  on(event: "start", listener: (info: RequestStartEvent) => void): this;
966
933
  on(event: "initiated", listener: () => void): this;
967
934
  on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
@@ -970,9 +937,10 @@ export interface DownloadResponseEventOverrides {
970
937
  on(event: "redirect", listener: (info: RedirectEvent) => void): this;
971
938
  on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
972
939
  on(event: string | symbol, listener: (...args: any[]) => void): this;
940
+ once(event: "data", listener: (chunk: Uint8Array | string) => void): this;
973
941
  once(event: "error", listener: (err: RezoError) => void): this;
974
- once(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
975
- once(event: "done", listener: (info: DownloadFinishEvent) => void): this;
942
+ once(event: "finish", listener: (info: StreamFinishEvent) => void): this;
943
+ once(event: "done", listener: (info: StreamFinishEvent) => void): this;
976
944
  once(event: "start", listener: (info: RequestStartEvent) => void): this;
977
945
  once(event: "initiated", listener: () => void): this;
978
946
  once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
@@ -981,74 +949,54 @@ export interface DownloadResponseEventOverrides {
981
949
  once(event: "redirect", listener: (info: RedirectEvent) => void): this;
982
950
  once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
983
951
  once(event: string | symbol, listener: (...args: any[]) => void): this;
984
- addListener(event: "error", listener: (err: RezoError) => void): this;
985
- addListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
986
- addListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
987
- addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
988
- addListener(event: "initiated", listener: () => void): this;
989
- addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
990
- addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
991
- addListener(event: "status", listener: (status: number, statusText: string) => void): this;
992
- addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
993
- addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
994
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
995
- prependListener(event: "error", listener: (err: RezoError) => void): this;
996
- prependListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
997
- prependListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
998
- prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
999
- prependListener(event: "initiated", listener: () => void): this;
1000
- prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
1001
- prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
1002
- prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
1003
- prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
1004
- prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1005
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1006
- prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
1007
- prependOnceListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
1008
- prependOnceListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
1009
- prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
1010
- prependOnceListener(event: "initiated", listener: () => void): this;
1011
- prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
1012
- prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
1013
- prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
1014
- prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
1015
- prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1016
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
952
+ isFinished(): boolean;
953
+ setEncoding?(encoding: string): this;
954
+ getEncoding?(): string | undefined;
1017
955
  }
1018
- declare class DownloadResponse extends EventEmitter implements DownloadResponseEventOverrides {
1019
- /** File name (basename or fullname) */
956
+ /**
957
+ * RezoDownloadResponse - For fileName/saveTo options
958
+ * Platform-agnostic interface for file downloads
959
+ * Streams response body directly to file
960
+ */
961
+ export interface RezoDownloadResponse extends BaseEventEmitter {
1020
962
  fileName: string;
1021
- /** Target URL */
1022
963
  url: string;
1023
- /** HTTP status code (set when headers received) */
1024
964
  status?: number;
1025
- /** HTTP status text (set when headers received) */
1026
965
  statusText?: string;
1027
- private _finished;
1028
- constructor(fileName: string, url: string);
1029
- /**
1030
- * Check if download has finished
1031
- */
1032
- isFinished(): boolean;
1033
- /**
1034
- * Mark download as finished (internal use)
1035
- * @internal
1036
- */
1037
- _markFinished(): void;
966
+ on(event: "error", listener: (err: RezoError) => void): this;
967
+ on(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
968
+ on(event: "done", listener: (info: DownloadFinishEvent) => void): this;
969
+ on(event: "start", listener: (info: RequestStartEvent) => void): this;
970
+ on(event: "initiated", listener: () => void): this;
971
+ on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
972
+ on(event: "cookies", listener: (cookies: Cookie[]) => void): this;
973
+ on(event: "status", listener: (status: number, statusText: string) => void): this;
974
+ on(event: "redirect", listener: (info: RedirectEvent) => void): this;
975
+ on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1038
976
  on(event: string | symbol, listener: (...args: any[]) => void): this;
977
+ once(event: "error", listener: (err: RezoError) => void): this;
978
+ once(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
979
+ once(event: "done", listener: (info: DownloadFinishEvent) => void): this;
980
+ once(event: "start", listener: (info: RequestStartEvent) => void): this;
981
+ once(event: "initiated", listener: () => void): this;
982
+ once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
983
+ once(event: "cookies", listener: (cookies: Cookie[]) => void): this;
984
+ once(event: "status", listener: (status: number, statusText: string) => void): this;
985
+ once(event: "redirect", listener: (info: RedirectEvent) => void): this;
986
+ once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1039
987
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1040
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1041
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1042
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1043
- off(event: string | symbol, listener: (...args: any[]) => void): this;
1044
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
1045
- removeAllListeners(event?: string | symbol): this;
988
+ isFinished(): boolean;
1046
989
  }
1047
990
  /**
1048
- * Complete type-safe event method overrides for UploadResponse
1049
- * All event listener methods return 'this' for chaining
991
+ * RezoUploadResponse - For responseType: 'upload'
992
+ * Platform-agnostic interface for file uploads
993
+ * Tracks upload progress and includes server response body
1050
994
  */
1051
- export interface UploadResponseEventOverrides {
995
+ export interface RezoUploadResponse extends BaseEventEmitter {
996
+ url: string;
997
+ fileName?: string;
998
+ status?: number;
999
+ statusText?: string;
1052
1000
  on(event: "error", listener: (err: RezoError) => void): this;
1053
1001
  on(event: "finish", listener: (info: UploadFinishEvent) => void): this;
1054
1002
  on(event: "done", listener: (info: UploadFinishEvent) => void): this;
@@ -1071,105 +1019,7 @@ export interface UploadResponseEventOverrides {
1071
1019
  once(event: "redirect", listener: (info: RedirectEvent) => void): this;
1072
1020
  once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1073
1021
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1074
- addListener(event: "error", listener: (err: RezoError) => void): this;
1075
- addListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
1076
- addListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
1077
- addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
1078
- addListener(event: "initiated", listener: () => void): this;
1079
- addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
1080
- addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
1081
- addListener(event: "status", listener: (status: number, statusText: string) => void): this;
1082
- addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
1083
- addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1084
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1085
- prependListener(event: "error", listener: (err: RezoError) => void): this;
1086
- prependListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
1087
- prependListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
1088
- prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
1089
- prependListener(event: "initiated", listener: () => void): this;
1090
- prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
1091
- prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
1092
- prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
1093
- prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
1094
- prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1095
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1096
- prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
1097
- prependOnceListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
1098
- prependOnceListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
1099
- prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
1100
- prependOnceListener(event: "initiated", listener: () => void): this;
1101
- prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
1102
- prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
1103
- prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
1104
- prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
1105
- prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
1106
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1107
- }
1108
- declare class UploadResponse extends EventEmitter implements UploadResponseEventOverrides {
1109
- /** Target URL */
1110
- url: string;
1111
- /** File name if uploading a file */
1112
- fileName?: string;
1113
- /** HTTP status code (set when headers received) */
1114
- status?: number;
1115
- /** HTTP status text (set when headers received) */
1116
- statusText?: string;
1117
- private _finished;
1118
- constructor(url: string, fileName?: string);
1119
- /**
1120
- * Check if upload has finished
1121
- */
1122
1022
  isFinished(): boolean;
1123
- /**
1124
- * Mark upload as finished (internal use)
1125
- * @internal
1126
- */
1127
- _markFinished(): void;
1128
- on(event: string | symbol, listener: (...args: any[]) => void): this;
1129
- once(event: string | symbol, listener: (...args: any[]) => void): this;
1130
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1131
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1132
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1133
- off(event: string | symbol, listener: (...args: any[]) => void): this;
1134
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
1135
- removeAllListeners(event?: string | symbol): this;
1136
- }
1137
- /**
1138
- * Standard RezoResponse for non-streaming requests
1139
- * Contains response data, status, headers, cookies, and execution metadata
1140
- */
1141
- export interface RezoResponse<T = any> {
1142
- data: T;
1143
- status: number;
1144
- statusText: string;
1145
- finalUrl: string;
1146
- cookies: Cookies;
1147
- headers: RezoHeaders;
1148
- contentType: string | undefined;
1149
- contentLength: number;
1150
- urls: string[];
1151
- config: RezoConfig;
1152
- }
1153
- /**
1154
- * RezoStreamResponse - For responseType: 'stream'
1155
- * Extends StreamResponse class (EventEmitter)
1156
- * Emits 'data' events for response body chunks
1157
- */
1158
- export interface RezoStreamResponse extends StreamResponse {
1159
- }
1160
- /**
1161
- * RezoDownloadResponse - For fileName/saveTo options
1162
- * Extends DownloadResponse class (EventEmitter)
1163
- * Streams response body directly to file
1164
- */
1165
- export interface RezoDownloadResponse extends DownloadResponse {
1166
- }
1167
- /**
1168
- * RezoUploadResponse - For responseType: 'upload'
1169
- * Extends UploadResponse class (EventEmitter)
1170
- * Tracks upload progress and includes server response body
1171
- */
1172
- export interface RezoUploadResponse extends UploadResponse {
1173
1023
  }
1174
1024
  /**
1175
1025
  * Rezo ProxyManager Types
@@ -1,5 +1,5 @@
1
- const _mod_rmr6y9 = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_rmr6y9.Crawler;;
3
- const _mod_b09fov = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_b09fov.CrawlerOptions;
5
- exports.Domain = _mod_b09fov.Domain;;
1
+ const _mod_q7mq9m = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_q7mq9m.Crawler;;
3
+ const _mod_9mic21 = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_9mic21.CrawlerOptions;
5
+ exports.Domain = _mod_9mic21.Domain;;
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_a2uu3a = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_a2uu3a.Rezo;
3
- exports.createRezoInstance = _mod_a2uu3a.createRezoInstance;
4
- exports.createDefaultInstance = _mod_a2uu3a.createDefaultInstance;;
5
- const _mod_tu09se = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_tu09se.RezoError;
7
- exports.RezoErrorCode = _mod_tu09se.RezoErrorCode;;
8
- const _mod_y3keed = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_y3keed.RezoHeaders;;
10
- const _mod_goh1u6 = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_goh1u6.RezoFormData;;
12
- const _mod_ku4hh5 = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_ku4hh5.RezoCookieJar;
14
- exports.Cookie = _mod_ku4hh5.Cookie;;
15
- const _mod_f06gp2 = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_f06gp2.createDefaultHooks;
17
- exports.mergeHooks = _mod_f06gp2.mergeHooks;;
18
- const _mod_tx60cr = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_tx60cr.ProxyManager;;
20
- const _mod_wz29v4 = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_wz29v4.RezoQueue;
22
- exports.HttpQueue = _mod_wz29v4.HttpQueue;
23
- exports.Priority = _mod_wz29v4.Priority;
24
- exports.HttpMethodPriority = _mod_wz29v4.HttpMethodPriority;;
1
+ const _mod_mu55lz = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_mu55lz.Rezo;
3
+ exports.createRezoInstance = _mod_mu55lz.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_mu55lz.createDefaultInstance;;
5
+ const _mod_biu41k = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_biu41k.RezoError;
7
+ exports.RezoErrorCode = _mod_biu41k.RezoErrorCode;;
8
+ const _mod_srgybz = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_srgybz.RezoHeaders;;
10
+ const _mod_mobns4 = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_mobns4.RezoFormData;;
12
+ const _mod_lw3ion = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_lw3ion.RezoCookieJar;
14
+ exports.Cookie = _mod_lw3ion.Cookie;;
15
+ const _mod_kxlq8z = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_kxlq8z.createDefaultHooks;
17
+ exports.mergeHooks = _mod_kxlq8z.mergeHooks;;
18
+ const _mod_bmob8s = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_bmob8s.ProxyManager;;
20
+ const _mod_b4w3zk = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_b4w3zk.RezoQueue;
22
+ exports.HttpQueue = _mod_b4w3zk.HttpQueue;
23
+ exports.Priority = _mod_b4w3zk.Priority;
24
+ exports.HttpMethodPriority = _mod_b4w3zk.HttpMethodPriority;;
25
25
  const { RezoError } = require('./errors/rezo-error.cjs');
26
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
27
27
  const Cancel = exports.Cancel = RezoError;