rezo 1.0.30 → 1.0.32

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 +165 -0
  22. package/dist/cache/universal-response-cache.js +162 -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/index.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
 
@@ -309,82 +306,129 @@ export interface Cookies {
309
306
  string: string;
310
307
  setCookiesString: string[];
311
308
  }
312
- export interface ReadableOptions {
313
- highWaterMark?: number;
314
- encoding?: string;
315
- objectMode?: boolean;
316
- read?(this: ReadableType, size: number): void;
317
- destroy?(this: ReadableType, error: Error | null, callback: (error: Error | null) => void): void;
318
- autoDestroy?: boolean;
319
- }
320
- export interface Options extends ReadableOptions {
321
- writable?: boolean;
322
- readable?: boolean;
323
- dataSize?: number;
324
- maxDataSize?: number;
325
- pauseStreams?: boolean;
326
- }
327
- export declare class RezoFormData extends NodeFormData {
328
- constructor(options?: Options);
309
+ /**
310
+ * Universal FormData wrapper using native FormData API
311
+ * Works in Node.js 18+, Bun, Deno, browsers, CF Workers, edge runtimes
312
+ *
313
+ * @module utils/form-data
314
+ */
315
+ export declare class RezoFormData {
316
+ private _fd;
317
+ private _cachedContentType;
318
+ private _cachedBuffer;
319
+ constructor();
329
320
  /**
330
- * Get field entries as array of [name, value] pairs
331
- * @returns {Promise<Array<[string, any]>>} Array of field entries
321
+ * Append a field to the form data
322
+ * @param name - Field name
323
+ * @param value - Field value (string, Blob, or Buffer)
324
+ * @param filename - Optional filename for file uploads
325
+ * @warning Buffer is only available in Node.js/Bun/Deno. Use Blob for browser/React Native.
332
326
  */
333
- getFieldEntries(): Promise<Array<[
327
+ append(name: string, value: string | Blob | Buffer, filename?: string): void;
328
+ /**
329
+ * Set a field in the form data (replaces existing)
330
+ * @param name - Field name
331
+ * @param value - Field value (string, Blob, or Buffer)
332
+ * @param filename - Optional filename for file uploads
333
+ * @warning Buffer is only available in Node.js/Bun/Deno. Use Blob for browser/React Native.
334
+ */
335
+ set(name: string, value: string | Blob | Buffer, filename?: string): void;
336
+ get(name: string): FormDataEntryValue | null;
337
+ getAll(name: string): FormDataEntryValue[];
338
+ has(name: string): boolean;
339
+ delete(name: string): void;
340
+ entries(): IterableIterator<[
334
341
  string,
335
- any
336
- ]>>;
342
+ FormDataEntryValue
343
+ ]>;
344
+ keys(): IterableIterator<string>;
345
+ values(): IterableIterator<FormDataEntryValue>;
346
+ forEach(callback: (value: FormDataEntryValue, key: string, parent: FormData) => void): void;
347
+ [Symbol.iterator](): IterableIterator<[
348
+ string,
349
+ FormDataEntryValue
350
+ ]>;
337
351
  /**
338
- * Convert to native FormData
339
- * @returns {Promise<FormData | null>}
352
+ * Get the underlying native FormData
340
353
  */
341
- toNativeFormData(): Promise<FormData | null>;
354
+ toNativeFormData(): FormData;
342
355
  /**
343
- * Create RezoFormData from native FormData
344
- * @param {FormData} formData - Native FormData object
345
- * @param {Options} options - Optional RezoFormData options
346
- * @returns {Promise<RezoFormData>}
356
+ * Invalidate cached values when form data changes
357
+ */
358
+ private _invalidateCache;
359
+ /**
360
+ * Build and cache the Response for extracting headers and body
347
361
  */
348
- static fromNativeFormData(formData: FormData, options?: Options): Promise<RezoFormData>;
362
+ private _buildResponse;
349
363
  /**
350
- * Get the content type header for this form data
351
- * @returns {string} Content type with boundary
364
+ * Get boundary extracted from Content-Type header
365
+ * Must be called after getContentTypeAsync() to get accurate value
352
366
  */
353
- getContentType(): string;
367
+ getBoundary(): string;
368
+ /**
369
+ * Get content type with boundary
370
+ * Returns cached value if available, otherwise returns undefined
371
+ * Use getContentTypeAsync() for guaranteed result
372
+ */
373
+ getContentType(): string | undefined;
354
374
  /**
355
- * Convert form data to Buffer
356
- * @returns {Buffer} Form data as buffer
375
+ * Get content type asynchronously with proper boundary
357
376
  */
358
- toBuffer(): Buffer;
377
+ getContentTypeAsync(): Promise<string>;
378
+ /**
379
+ * Get headers for HTTP request
380
+ * Use getHeadersAsync() for complete headers with boundary
381
+ */
382
+ getHeaders(): Record<string, string>;
383
+ /**
384
+ * Get headers asynchronously with proper Content-Type and boundary
385
+ */
386
+ getHeadersAsync(): Promise<Record<string, string>>;
387
+ /**
388
+ * Get length synchronously - returns cached value if available
389
+ * Use getLength() for guaranteed result
390
+ */
391
+ getLengthSync(): number | undefined;
392
+ /**
393
+ * Get length asynchronously (works in all environments)
394
+ */
395
+ getLength(): Promise<number>;
396
+ /**
397
+ * Get buffer synchronously - returns cached value if available
398
+ * Use toBuffer() for guaranteed result
399
+ * @warning Only works in Node.js/Bun/Deno. Returns null in browser/React Native.
400
+ */
401
+ getBuffer(): Buffer | null;
402
+ /**
403
+ * Convert to Buffer asynchronously
404
+ * @warning Only works in Node.js/Bun/Deno. Use toArrayBuffer() for browser/React Native.
405
+ */
406
+ toBuffer(): Promise<Buffer>;
407
+ /**
408
+ * Convert to ArrayBuffer asynchronously (works in all environments)
409
+ */
410
+ toArrayBuffer(): Promise<ArrayBuffer>;
411
+ /**
412
+ * Convert to Uint8Array asynchronously (works in all environments)
413
+ */
414
+ toUint8Array(): Promise<Uint8Array>;
359
415
  /**
360
416
  * Create RezoFormData from object
361
- * Properly handles nested objects by JSON.stringify-ing them
362
- * @param {Record<string, any>} obj - Object to convert
363
- * @param {Options} options - Optional RezoFormData options
364
- * @returns {RezoFormData}
417
+ * Handles nested objects, arrays, Blobs, Files, and Buffers
365
418
  */
366
- static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
419
+ static fromObject(obj: Record<string, unknown>): RezoFormData;
367
420
  /**
368
- * Helper to append a value to FormData with proper type handling
369
- * @param {RezoFormData} formData - The form data to append to
370
- * @param {string} key - The field name
371
- * @param {any} value - The value to append
421
+ * Create RezoFormData from native FormData
372
422
  */
373
- private static appendValue;
423
+ static fromNativeFormData(formData: FormData): RezoFormData;
374
424
  /**
375
- * Convert to URL query string
376
- * Warning: File, Blob, and binary data will be omitted
377
- * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
378
- * @returns {Promise<string>} URL query string
425
+ * Convert to URL query string (only string values, binary data omitted)
379
426
  */
380
- toUrlQueryString(convertBinaryToBase64?: boolean): Promise<string>;
427
+ toUrlQueryString(): string;
381
428
  /**
382
- * Convert to URLSearchParams object
383
- * Warning: File, Blob, and binary data will be omitted
384
- * @param {boolean} convertBinaryToBase64 - Convert binary data to base64 strings
385
- * @returns {Promise<URLSearchParams>} URLSearchParams object
429
+ * Convert to URLSearchParams (only string values, binary data omitted)
386
430
  */
387
- toURLSearchParams(convertBinaryToBase64?: boolean): Promise<URLSearchParams>;
431
+ toURLSearchParams(): URLSearchParams;
388
432
  }
389
433
  /**
390
434
  * Emitted when request is initiated
@@ -630,115 +674,44 @@ export type SanitizedRezoConfig = Omit<RezoConfig, "data"> & {
630
674
  data?: never;
631
675
  };
632
676
  /**
633
- * Event map for StreamResponse - defines all available events and their signatures
677
+ * Standard RezoResponse for non-streaming requests
678
+ * Contains response data, status, headers, cookies, and execution metadata
634
679
  */
635
- export interface StreamResponseEvents {
636
- close: [
637
- ];
638
- drain: [
639
- ];
640
- error: [
641
- err: RezoError
642
- ];
643
- finish: [
644
- info: StreamFinishEvent
645
- ];
646
- done: [
647
- info: StreamFinishEvent
648
- ];
649
- start: [
650
- info: RequestStartEvent
651
- ];
652
- initiated: [
653
- ];
654
- headers: [
655
- info: ResponseHeadersEvent
656
- ];
657
- cookies: [
658
- cookies: Cookie[]
659
- ];
660
- status: [
661
- status: number,
662
- statusText: string
663
- ];
664
- redirect: [
665
- info: RedirectEvent
666
- ];
667
- progress: [
668
- progress: ProgressEvent$1
669
- ];
670
- data: [
671
- chunk: Buffer | string
672
- ];
673
- pipe: [
674
- src: Readable
675
- ];
676
- unpipe: [
677
- src: Readable
678
- ];
680
+ export interface RezoResponse<T = any> {
681
+ data: T;
682
+ status: number;
683
+ statusText: string;
684
+ finalUrl: string;
685
+ cookies: Cookies;
686
+ headers: RezoHeaders;
687
+ contentType: string | undefined;
688
+ contentLength: number;
689
+ urls: string[];
690
+ config: RezoConfig;
679
691
  }
680
692
  /**
681
- * Complete type-safe event method overrides for StreamResponse
682
- * All event listener methods return 'this' for chaining
693
+ * Platform-agnostic base interface for event-emitting responses
694
+ * Can be implemented by both Node.js EventEmitter and browser-safe implementations
683
695
  */
684
- export interface StreamResponseEventOverrides {
685
- on<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
686
- on(event: string | symbol, listener: (...args: any[]) => void): this;
687
- once<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
688
- once(event: string | symbol, listener: (...args: any[]) => void): this;
689
- addListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
690
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
691
- prependListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
692
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
693
- prependOnceListener<K extends keyof StreamResponseEvents>(event: K, listener: (...args: StreamResponseEvents[K]) => void): this;
694
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
695
- }
696
- declare class StreamResponse extends Writable implements StreamResponseEventOverrides {
697
- private _finished;
698
- private _encoding?;
699
- constructor(opts?: WritableOptions);
700
- /**
701
- * Set encoding for string chunks
702
- * @param encoding - Buffer encoding (utf8, ascii, etc.)
703
- * @returns this for chaining
704
- */
705
- setEncoding(encoding: BufferEncoding): this;
706
- /**
707
- * Get current encoding
708
- */
709
- getEncoding(): BufferEncoding | undefined;
710
- /**
711
- * Check if stream has finished
712
- */
713
- isFinished(): boolean;
714
- /**
715
- * Mark stream as finished (internal use)
716
- * @internal
717
- */
718
- _markFinished(): void;
719
- /**
720
- * Internal write implementation required by Writable
721
- * Emits 'data' event for each chunk received
722
- * @internal
723
- */
724
- _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
696
+ export interface BaseEventEmitter {
725
697
  on(event: string | symbol, listener: (...args: any[]) => void): this;
726
698
  once(event: string | symbol, listener: (...args: any[]) => void): this;
727
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
728
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
729
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
730
699
  off(event: string | symbol, listener: (...args: any[]) => void): this;
700
+ emit(event: string | symbol, ...args: any[]): boolean;
731
701
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
732
702
  removeAllListeners(event?: string | symbol): this;
703
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
733
704
  }
734
705
  /**
735
- * Complete type-safe event method overrides for DownloadResponse
736
- * All event listener methods return 'this' for chaining
706
+ * RezoStreamResponse - For responseType: 'stream'
707
+ * Platform-agnostic interface for streaming responses
708
+ * Emits 'data' events for response body chunks
737
709
  */
738
- export interface DownloadResponseEventOverrides {
710
+ export interface RezoStreamResponse extends BaseEventEmitter {
711
+ on(event: "data", listener: (chunk: Uint8Array | string) => void): this;
739
712
  on(event: "error", listener: (err: RezoError) => void): this;
740
- on(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
741
- on(event: "done", listener: (info: DownloadFinishEvent) => void): this;
713
+ on(event: "finish", listener: (info: StreamFinishEvent) => void): this;
714
+ on(event: "done", listener: (info: StreamFinishEvent) => void): this;
742
715
  on(event: "start", listener: (info: RequestStartEvent) => void): this;
743
716
  on(event: "initiated", listener: () => void): this;
744
717
  on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
@@ -747,9 +720,10 @@ export interface DownloadResponseEventOverrides {
747
720
  on(event: "redirect", listener: (info: RedirectEvent) => void): this;
748
721
  on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
749
722
  on(event: string | symbol, listener: (...args: any[]) => void): this;
723
+ once(event: "data", listener: (chunk: Uint8Array | string) => void): this;
750
724
  once(event: "error", listener: (err: RezoError) => void): this;
751
- once(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
752
- once(event: "done", listener: (info: DownloadFinishEvent) => void): this;
725
+ once(event: "finish", listener: (info: StreamFinishEvent) => void): this;
726
+ once(event: "done", listener: (info: StreamFinishEvent) => void): this;
753
727
  once(event: "start", listener: (info: RequestStartEvent) => void): this;
754
728
  once(event: "initiated", listener: () => void): this;
755
729
  once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
@@ -758,74 +732,54 @@ export interface DownloadResponseEventOverrides {
758
732
  once(event: "redirect", listener: (info: RedirectEvent) => void): this;
759
733
  once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
760
734
  once(event: string | symbol, listener: (...args: any[]) => void): this;
761
- addListener(event: "error", listener: (err: RezoError) => void): this;
762
- addListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
763
- addListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
764
- addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
765
- addListener(event: "initiated", listener: () => void): this;
766
- addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
767
- addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
768
- addListener(event: "status", listener: (status: number, statusText: string) => void): this;
769
- addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
770
- addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
771
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
772
- prependListener(event: "error", listener: (err: RezoError) => void): this;
773
- prependListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
774
- prependListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
775
- prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
776
- prependListener(event: "initiated", listener: () => void): this;
777
- prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
778
- prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
779
- prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
780
- prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
781
- prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
782
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
783
- prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
784
- prependOnceListener(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
785
- prependOnceListener(event: "done", listener: (info: DownloadFinishEvent) => void): this;
786
- prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
787
- prependOnceListener(event: "initiated", listener: () => void): this;
788
- prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
789
- prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
790
- prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
791
- prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
792
- prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
793
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
735
+ isFinished(): boolean;
736
+ setEncoding?(encoding: string): this;
737
+ getEncoding?(): string | undefined;
794
738
  }
795
- declare class DownloadResponse extends EventEmitter implements DownloadResponseEventOverrides {
796
- /** File name (basename or fullname) */
739
+ /**
740
+ * RezoDownloadResponse - For fileName/saveTo options
741
+ * Platform-agnostic interface for file downloads
742
+ * Streams response body directly to file
743
+ */
744
+ export interface RezoDownloadResponse extends BaseEventEmitter {
797
745
  fileName: string;
798
- /** Target URL */
799
746
  url: string;
800
- /** HTTP status code (set when headers received) */
801
747
  status?: number;
802
- /** HTTP status text (set when headers received) */
803
748
  statusText?: string;
804
- private _finished;
805
- constructor(fileName: string, url: string);
806
- /**
807
- * Check if download has finished
808
- */
809
- isFinished(): boolean;
810
- /**
811
- * Mark download as finished (internal use)
812
- * @internal
813
- */
814
- _markFinished(): void;
749
+ on(event: "error", listener: (err: RezoError) => void): this;
750
+ on(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
751
+ on(event: "done", listener: (info: DownloadFinishEvent) => void): this;
752
+ on(event: "start", listener: (info: RequestStartEvent) => void): this;
753
+ on(event: "initiated", listener: () => void): this;
754
+ on(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
755
+ on(event: "cookies", listener: (cookies: Cookie[]) => void): this;
756
+ on(event: "status", listener: (status: number, statusText: string) => void): this;
757
+ on(event: "redirect", listener: (info: RedirectEvent) => void): this;
758
+ on(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
815
759
  on(event: string | symbol, listener: (...args: any[]) => void): this;
760
+ once(event: "error", listener: (err: RezoError) => void): this;
761
+ once(event: "finish", listener: (info: DownloadFinishEvent) => void): this;
762
+ once(event: "done", listener: (info: DownloadFinishEvent) => void): this;
763
+ once(event: "start", listener: (info: RequestStartEvent) => void): this;
764
+ once(event: "initiated", listener: () => void): this;
765
+ once(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
766
+ once(event: "cookies", listener: (cookies: Cookie[]) => void): this;
767
+ once(event: "status", listener: (status: number, statusText: string) => void): this;
768
+ once(event: "redirect", listener: (info: RedirectEvent) => void): this;
769
+ once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
816
770
  once(event: string | symbol, listener: (...args: any[]) => void): this;
817
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
818
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
819
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
820
- off(event: string | symbol, listener: (...args: any[]) => void): this;
821
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
822
- removeAllListeners(event?: string | symbol): this;
771
+ isFinished(): boolean;
823
772
  }
824
773
  /**
825
- * Complete type-safe event method overrides for UploadResponse
826
- * All event listener methods return 'this' for chaining
774
+ * RezoUploadResponse - For responseType: 'upload'
775
+ * Platform-agnostic interface for file uploads
776
+ * Tracks upload progress and includes server response body
827
777
  */
828
- export interface UploadResponseEventOverrides {
778
+ export interface RezoUploadResponse extends BaseEventEmitter {
779
+ url: string;
780
+ fileName?: string;
781
+ status?: number;
782
+ statusText?: string;
829
783
  on(event: "error", listener: (err: RezoError) => void): this;
830
784
  on(event: "finish", listener: (info: UploadFinishEvent) => void): this;
831
785
  on(event: "done", listener: (info: UploadFinishEvent) => void): this;
@@ -848,105 +802,7 @@ export interface UploadResponseEventOverrides {
848
802
  once(event: "redirect", listener: (info: RedirectEvent) => void): this;
849
803
  once(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
850
804
  once(event: string | symbol, listener: (...args: any[]) => void): this;
851
- addListener(event: "error", listener: (err: RezoError) => void): this;
852
- addListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
853
- addListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
854
- addListener(event: "start", listener: (info: RequestStartEvent) => void): this;
855
- addListener(event: "initiated", listener: () => void): this;
856
- addListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
857
- addListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
858
- addListener(event: "status", listener: (status: number, statusText: string) => void): this;
859
- addListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
860
- addListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
861
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
862
- prependListener(event: "error", listener: (err: RezoError) => void): this;
863
- prependListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
864
- prependListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
865
- prependListener(event: "start", listener: (info: RequestStartEvent) => void): this;
866
- prependListener(event: "initiated", listener: () => void): this;
867
- prependListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
868
- prependListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
869
- prependListener(event: "status", listener: (status: number, statusText: string) => void): this;
870
- prependListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
871
- prependListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
872
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
873
- prependOnceListener(event: "error", listener: (err: RezoError) => void): this;
874
- prependOnceListener(event: "finish", listener: (info: UploadFinishEvent) => void): this;
875
- prependOnceListener(event: "done", listener: (info: UploadFinishEvent) => void): this;
876
- prependOnceListener(event: "start", listener: (info: RequestStartEvent) => void): this;
877
- prependOnceListener(event: "initiated", listener: () => void): this;
878
- prependOnceListener(event: "headers", listener: (info: ResponseHeadersEvent) => void): this;
879
- prependOnceListener(event: "cookies", listener: (cookies: Cookie[]) => void): this;
880
- prependOnceListener(event: "status", listener: (status: number, statusText: string) => void): this;
881
- prependOnceListener(event: "redirect", listener: (info: RedirectEvent) => void): this;
882
- prependOnceListener(event: "progress", listener: (progress: ProgressEvent$1) => void): this;
883
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
884
- }
885
- declare class UploadResponse extends EventEmitter implements UploadResponseEventOverrides {
886
- /** Target URL */
887
- url: string;
888
- /** File name if uploading a file */
889
- fileName?: string;
890
- /** HTTP status code (set when headers received) */
891
- status?: number;
892
- /** HTTP status text (set when headers received) */
893
- statusText?: string;
894
- private _finished;
895
- constructor(url: string, fileName?: string);
896
- /**
897
- * Check if upload has finished
898
- */
899
805
  isFinished(): boolean;
900
- /**
901
- * Mark upload as finished (internal use)
902
- * @internal
903
- */
904
- _markFinished(): void;
905
- on(event: string | symbol, listener: (...args: any[]) => void): this;
906
- once(event: string | symbol, listener: (...args: any[]) => void): this;
907
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
908
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
909
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
910
- off(event: string | symbol, listener: (...args: any[]) => void): this;
911
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
912
- removeAllListeners(event?: string | symbol): this;
913
- }
914
- /**
915
- * Standard RezoResponse for non-streaming requests
916
- * Contains response data, status, headers, cookies, and execution metadata
917
- */
918
- export interface RezoResponse<T = any> {
919
- data: T;
920
- status: number;
921
- statusText: string;
922
- finalUrl: string;
923
- cookies: Cookies;
924
- headers: RezoHeaders;
925
- contentType: string | undefined;
926
- contentLength: number;
927
- urls: string[];
928
- config: RezoConfig;
929
- }
930
- /**
931
- * RezoStreamResponse - For responseType: 'stream'
932
- * Extends StreamResponse class (EventEmitter)
933
- * Emits 'data' events for response body chunks
934
- */
935
- export interface RezoStreamResponse extends StreamResponse {
936
- }
937
- /**
938
- * RezoDownloadResponse - For fileName/saveTo options
939
- * Extends DownloadResponse class (EventEmitter)
940
- * Streams response body directly to file
941
- */
942
- export interface RezoDownloadResponse extends DownloadResponse {
943
- }
944
- /**
945
- * RezoUploadResponse - For responseType: 'upload'
946
- * Extends UploadResponse class (EventEmitter)
947
- * Tracks upload progress and includes server response body
948
- */
949
- export interface RezoUploadResponse extends UploadResponse {
950
806
  }
951
807
  /**
952
808
  * Rezo ProxyManager Types