@d1g1tal/transportr 2.2.0 → 3.0.0
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.
- package/CHANGELOG.md +304 -0
- package/README.md +846 -491
- package/dist/{media-types.d.ts → content-type.d.ts} +2 -2
- package/dist/{media-types.js → content-type.js} +2 -2
- package/dist/content-type.js.map +7 -0
- package/dist/{headers.d.ts → request-header.d.ts} +2 -2
- package/dist/{headers.js → request-header.js} +2 -2
- package/dist/request-header.js.map +7 -0
- package/dist/{methods.d.ts → request-method.d.ts} +3 -3
- package/dist/{methods.js → request-method.js} +2 -2
- package/dist/request-method.js.map +7 -0
- package/dist/{response-headers.d.ts → response-header.d.ts} +2 -2
- package/dist/{response-headers.js → response-header.js} +2 -2
- package/dist/response-header.js.map +7 -0
- package/dist/transportr.d.ts +368 -282
- package/dist/transportr.js +7 -2
- package/dist/transportr.js.map +4 -4
- package/package.json +19 -19
- package/dist/headers.js.map +0 -7
- package/dist/media-types.js.map +0 -7
- package/dist/methods.js.map +0 -7
- package/dist/response-headers.js.map +0 -7
package/dist/transportr.d.ts
CHANGED
|
@@ -43,10 +43,143 @@ declare class ResponseStatus {
|
|
|
43
43
|
toString(): string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
type Function<P = any, R = unknown> = (...args: P[]) => R;
|
|
47
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
48
|
+
type JsonArray<T = any> = T extends any ? Array<JsonValue<T>> : never;
|
|
49
|
+
type JsonObject<T = any> = T extends any ? {
|
|
50
|
+
[K in keyof T as JsonValue<T[K]> extends never ? never : K]: JsonValue<T[K]>;
|
|
51
|
+
} : Record<string, any>;
|
|
52
|
+
type JsonValue<T = any> = T extends JsonPrimitive ? T : T extends {
|
|
53
|
+
toJSON: () => infer R;
|
|
54
|
+
} ? R : T extends Function | undefined ? never : T extends Array<infer U> ? JsonArray<U> : T extends Record<string, any> ? JsonObject<T> : Json;
|
|
55
|
+
type Json = JsonPrimitive | JsonObject | JsonArray;
|
|
56
|
+
type JsonString<T = unknown> = string & {
|
|
57
|
+
source: T;
|
|
58
|
+
};
|
|
59
|
+
/** The expected response body types returned from a fetch handler. */
|
|
60
|
+
type ResponseBody = Json | Document | DocumentFragment | HTMLImageElement | Blob | ArrayBuffer | FormData | string | ReadableStream<Uint8Array> | void | null;
|
|
61
|
+
/** A parsed Server-Sent Event per the EventStream specification. */
|
|
62
|
+
type ServerSentEvent = {
|
|
63
|
+
/** The event type (defaults to 'message'). */
|
|
64
|
+
event: string;
|
|
65
|
+
/** The event data payload. */
|
|
66
|
+
data: string;
|
|
67
|
+
/** The last event ID string, if provided by the server. */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Reconnection time in milliseconds, if provided by the server. */
|
|
70
|
+
retry: number | undefined;
|
|
71
|
+
};
|
|
72
|
+
/** Progress information for download/upload tracking. */
|
|
73
|
+
type DownloadProgress = {
|
|
74
|
+
/** Number of bytes transferred so far. */
|
|
75
|
+
loaded: number;
|
|
76
|
+
/** Total number of bytes, or null if unknown (no Content-Length). */
|
|
77
|
+
total: number | null;
|
|
78
|
+
/** Percentage complete (0–100), or null if total is unknown. */
|
|
79
|
+
percentage: number | null;
|
|
80
|
+
};
|
|
81
|
+
/** Result tuple for error-as-value handling. Success: [true, data]. Error: [false, E]. */
|
|
82
|
+
type Result<T, E = Error> = [true, T] | [false, E];
|
|
83
|
+
/** Retry event information emitted during retry attempts. */
|
|
84
|
+
type RetryInfo = {
|
|
85
|
+
/** Current retry attempt number (1-based). */
|
|
86
|
+
attempt: number;
|
|
87
|
+
/** HTTP status code that triggered the retry, if available. */
|
|
88
|
+
status?: number;
|
|
89
|
+
/** Error message that triggered the retry, if available. */
|
|
90
|
+
error?: string;
|
|
91
|
+
/** The HTTP method of the request. */
|
|
92
|
+
method: string;
|
|
93
|
+
/** The request path. */
|
|
94
|
+
path: string | undefined;
|
|
95
|
+
/** Timing information at the point of retry. */
|
|
96
|
+
timing: RequestTiming;
|
|
97
|
+
};
|
|
98
|
+
/** Timing information for a request lifecycle. */
|
|
99
|
+
type RequestTiming = {
|
|
100
|
+
/** Timestamp when the request started (ms since epoch). */
|
|
101
|
+
start: number;
|
|
102
|
+
/** Timestamp when the response was received (ms since epoch). */
|
|
103
|
+
end: number;
|
|
104
|
+
/** Total duration in milliseconds. */
|
|
105
|
+
duration: number;
|
|
106
|
+
};
|
|
107
|
+
/** Options for constructing an {@link HttpError}. */
|
|
108
|
+
type HttpErrorOptions = {
|
|
109
|
+
message?: string;
|
|
110
|
+
cause?: Error;
|
|
111
|
+
entity?: ResponseBody;
|
|
112
|
+
/** The request URL. */
|
|
113
|
+
url?: URL;
|
|
114
|
+
/** The HTTP method used. */
|
|
115
|
+
method?: string;
|
|
116
|
+
/** Request timing information. */
|
|
117
|
+
timing?: RequestTiming;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* An error that represents an HTTP error response.
|
|
122
|
+
* @author D1g1talEntr0py <jason.dimeo@gmail.com>
|
|
123
|
+
*/
|
|
124
|
+
declare class HttpError extends Error {
|
|
125
|
+
private readonly _entity;
|
|
126
|
+
private readonly responseStatus;
|
|
127
|
+
private readonly _url;
|
|
128
|
+
private readonly _method;
|
|
129
|
+
private readonly _timing;
|
|
130
|
+
/**
|
|
131
|
+
* Creates an instance of HttpError.
|
|
132
|
+
* @param status The status code and status text of the {@link Response}.
|
|
133
|
+
* @param httpErrorOptions The http error options.
|
|
134
|
+
*/
|
|
135
|
+
constructor(status: ResponseStatus, { message, cause, entity, url, method, timing }?: HttpErrorOptions);
|
|
136
|
+
/**
|
|
137
|
+
* It returns the value of the private variable #entity.
|
|
138
|
+
* @returns The entity property of the class.
|
|
139
|
+
*/
|
|
140
|
+
get entity(): ResponseBody;
|
|
141
|
+
/**
|
|
142
|
+
* It returns the status code of the {@link Response}.
|
|
143
|
+
* @returns The status code of the {@link Response}.
|
|
144
|
+
*/
|
|
145
|
+
get statusCode(): number;
|
|
146
|
+
/**
|
|
147
|
+
* It returns the status text of the {@link Response}.
|
|
148
|
+
* @returns The status code and status text of the {@link Response}.
|
|
149
|
+
*/
|
|
150
|
+
get statusText(): string;
|
|
151
|
+
/**
|
|
152
|
+
* The request URL that caused the error.
|
|
153
|
+
* @returns The URL or undefined.
|
|
154
|
+
*/
|
|
155
|
+
get url(): URL | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* The HTTP method that was used for the failed request.
|
|
158
|
+
* @returns The method string or undefined.
|
|
159
|
+
*/
|
|
160
|
+
get method(): string | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* Timing information for the failed request.
|
|
163
|
+
* @returns The timing object or undefined.
|
|
164
|
+
*/
|
|
165
|
+
get timing(): RequestTiming | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* A String value representing the name of the error.
|
|
168
|
+
* @returns The name of the error.
|
|
169
|
+
*/
|
|
170
|
+
get name(): string;
|
|
171
|
+
/**
|
|
172
|
+
* A String value that is used in the creation of the default string
|
|
173
|
+
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
174
|
+
* @returns The default string description of this object.
|
|
175
|
+
*/
|
|
176
|
+
get [Symbol.toStringTag](): string;
|
|
177
|
+
}
|
|
178
|
+
|
|
46
179
|
/**
|
|
47
180
|
* Defining a constant object with all the HTTP request headers.
|
|
48
181
|
*/
|
|
49
|
-
declare const
|
|
182
|
+
declare const RequestHeader: {
|
|
50
183
|
/**
|
|
51
184
|
* Content-Types that are acceptable for the response. See Content negotiation. Permanent.
|
|
52
185
|
*
|
|
@@ -295,7 +428,7 @@ declare const HttpRequestHeader: {
|
|
|
295
428
|
* A collection of some of the available HTTP media types.
|
|
296
429
|
* @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | IANA Media Types}
|
|
297
430
|
*/
|
|
298
|
-
declare const
|
|
431
|
+
declare const ContentType: {
|
|
299
432
|
/** Advanced Audio Coding (AAC) */
|
|
300
433
|
readonly AAC: "audio/aac";
|
|
301
434
|
/** AbiWord */
|
|
@@ -450,102 +583,6 @@ declare const HttpMediaType: {
|
|
|
450
583
|
readonly '7Z': "application/x-7z-compressed";
|
|
451
584
|
};
|
|
452
585
|
|
|
453
|
-
type Function<P = any, R = unknown> = (...args: P[]) => R;
|
|
454
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
455
|
-
type JsonArray<T = any> = T extends any ? Array<JsonValue<T>> : never;
|
|
456
|
-
type JsonObject<T = any> = T extends any ? {
|
|
457
|
-
[K in keyof T as JsonValue<T[K]> extends never ? never : K]: JsonValue<T[K]>;
|
|
458
|
-
} : Record<string, any>;
|
|
459
|
-
type JsonValue<T = any> = T extends JsonPrimitive ? T : T extends {
|
|
460
|
-
toJSON: () => infer R;
|
|
461
|
-
} ? R : T extends Function | undefined ? never : T extends Array<infer U> ? JsonArray<U> : T extends Record<string, any> ? JsonObject<T> : Json;
|
|
462
|
-
type Json = JsonPrimitive | JsonObject | JsonArray;
|
|
463
|
-
type JsonString<T = unknown> = string & {
|
|
464
|
-
source: T;
|
|
465
|
-
};
|
|
466
|
-
/** The expected response body types returned from a fetch handler. */
|
|
467
|
-
type ResponseBody = Json | Document | DocumentFragment | HTMLImageElement | Blob | ArrayBuffer | FormData | string | ReadableStream<Uint8Array> | void | null;
|
|
468
|
-
/** Timing information for a request lifecycle. */
|
|
469
|
-
type RequestTiming = {
|
|
470
|
-
/** Timestamp when the request started (ms since epoch). */
|
|
471
|
-
start: number;
|
|
472
|
-
/** Timestamp when the response was received (ms since epoch). */
|
|
473
|
-
end: number;
|
|
474
|
-
/** Total duration in milliseconds. */
|
|
475
|
-
duration: number;
|
|
476
|
-
};
|
|
477
|
-
/** Options for constructing an {@link HttpError}. */
|
|
478
|
-
type HttpErrorOptions = {
|
|
479
|
-
message?: string;
|
|
480
|
-
cause?: Error;
|
|
481
|
-
entity?: ResponseBody;
|
|
482
|
-
/** The request URL. */
|
|
483
|
-
url?: URL;
|
|
484
|
-
/** The HTTP method used. */
|
|
485
|
-
method?: string;
|
|
486
|
-
/** Request timing information. */
|
|
487
|
-
timing?: RequestTiming;
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* An error that represents an HTTP error response.
|
|
492
|
-
* @author D1g1talEntr0py <jason.dimeo@gmail.com>
|
|
493
|
-
*/
|
|
494
|
-
declare class HttpError extends Error {
|
|
495
|
-
private readonly _entity;
|
|
496
|
-
private readonly responseStatus;
|
|
497
|
-
private readonly _url;
|
|
498
|
-
private readonly _method;
|
|
499
|
-
private readonly _timing;
|
|
500
|
-
/**
|
|
501
|
-
* Creates an instance of HttpError.
|
|
502
|
-
* @param status The status code and status text of the {@link Response}.
|
|
503
|
-
* @param httpErrorOptions The http error options.
|
|
504
|
-
*/
|
|
505
|
-
constructor(status: ResponseStatus, { message, cause, entity, url, method, timing }?: HttpErrorOptions);
|
|
506
|
-
/**
|
|
507
|
-
* It returns the value of the private variable #entity.
|
|
508
|
-
* @returns The entity property of the class.
|
|
509
|
-
*/
|
|
510
|
-
get entity(): ResponseBody;
|
|
511
|
-
/**
|
|
512
|
-
* It returns the status code of the {@link Response}.
|
|
513
|
-
* @returns The status code of the {@link Response}.
|
|
514
|
-
*/
|
|
515
|
-
get statusCode(): number;
|
|
516
|
-
/**
|
|
517
|
-
* It returns the status text of the {@link Response}.
|
|
518
|
-
* @returns The status code and status text of the {@link Response}.
|
|
519
|
-
*/
|
|
520
|
-
get statusText(): string;
|
|
521
|
-
/**
|
|
522
|
-
* The request URL that caused the error.
|
|
523
|
-
* @returns The URL or undefined.
|
|
524
|
-
*/
|
|
525
|
-
get url(): URL | undefined;
|
|
526
|
-
/**
|
|
527
|
-
* The HTTP method that was used for the failed request.
|
|
528
|
-
* @returns The method string or undefined.
|
|
529
|
-
*/
|
|
530
|
-
get method(): string | undefined;
|
|
531
|
-
/**
|
|
532
|
-
* Timing information for the failed request.
|
|
533
|
-
* @returns The timing object or undefined.
|
|
534
|
-
*/
|
|
535
|
-
get timing(): RequestTiming | undefined;
|
|
536
|
-
/**
|
|
537
|
-
* A String value representing the name of the error.
|
|
538
|
-
* @returns The name of the error.
|
|
539
|
-
*/
|
|
540
|
-
get name(): string;
|
|
541
|
-
/**
|
|
542
|
-
* A String value that is used in the creation of the default string
|
|
543
|
-
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
544
|
-
* @returns The default string description of this object.
|
|
545
|
-
*/
|
|
546
|
-
get [Symbol.toStringTag](): string;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
586
|
type Prettify<T> = T extends infer U ? {
|
|
550
587
|
[K in keyof U]: U[K];
|
|
551
588
|
} : never;
|
|
@@ -559,7 +596,7 @@ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPT
|
|
|
559
596
|
type RequestBodyMethod = Extract<RequestMethod, 'POST' | 'PUT' | 'PATCH' | 'DELETE'>;
|
|
560
597
|
type RequestNoBodyMethod = Exclude<RequestMethod, RequestBodyMethod>;
|
|
561
598
|
type RequestHeaders = Prettify<TypedHeaders & {
|
|
562
|
-
[K in Exclude<typeof
|
|
599
|
+
[K in Exclude<typeof RequestHeader[keyof typeof RequestHeader], keyof TypedHeaders>]?: string;
|
|
563
600
|
} & HeadersInit>;
|
|
564
601
|
type SearchParameters = URLSearchParams | string | string[][] | Record<string, string | number | boolean>;
|
|
565
602
|
type AuthorizationScheme = 'Basic' | 'Bearer' | 'Digest' | 'HOBA' | 'Mutual' | 'Negotiate' | 'OAuth' | 'SCRAM-SHA-1' | 'SCRAM-SHA-256' | 'vapid';
|
|
@@ -582,11 +619,11 @@ type AbortConfiguration = {
|
|
|
582
619
|
signal?: AbortSignal | null;
|
|
583
620
|
timeout?: number;
|
|
584
621
|
};
|
|
585
|
-
type MediaTypeValues = LiteralUnion<typeof
|
|
622
|
+
type MediaTypeValues = LiteralUnion<typeof ContentType[keyof typeof ContentType]>;
|
|
586
623
|
type TypedHeaders = {
|
|
587
|
-
[
|
|
588
|
-
[
|
|
589
|
-
[
|
|
624
|
+
[RequestHeader.AUTHORIZATION]?: `${AuthorizationScheme} ${string}` | AuthorizationScheme;
|
|
625
|
+
[RequestHeader.ACCEPT]?: MediaTypeValues;
|
|
626
|
+
[RequestHeader.CONTENT_TYPE]?: MediaTypeValues;
|
|
590
627
|
};
|
|
591
628
|
type EventRegistration = Subscription;
|
|
592
629
|
type MethodBody = {
|
|
@@ -610,6 +647,12 @@ type RequestOptions = Prettify<{
|
|
|
610
647
|
dedupe?: boolean;
|
|
611
648
|
/** XSRF/CSRF protection. When set (or true), reads a cookie and sets a request header. */
|
|
612
649
|
xsrf?: boolean | XsrfOptions;
|
|
650
|
+
/** Callback invoked with download progress information. Only works when the response has a body stream. */
|
|
651
|
+
onDownloadProgress?: (progress: DownloadProgress) => void;
|
|
652
|
+
/** Callback invoked with upload progress as the request body is sent. Requires ReadableStream request body support. */
|
|
653
|
+
onUploadProgress?: (progress: DownloadProgress) => void;
|
|
654
|
+
/** When false, methods return Result tuples instead of throwing. Defaults to true (throw on error). */
|
|
655
|
+
unwrap?: boolean;
|
|
613
656
|
} & Omit<RequestInit, 'headers'> & MethodBody>;
|
|
614
657
|
/** Configuration for retry behavior on failed requests. */
|
|
615
658
|
type RetryOptions = {
|
|
@@ -645,6 +688,21 @@ type HookOptions = {
|
|
|
645
688
|
};
|
|
646
689
|
/** Fully resolved retry configuration with all defaults applied. */
|
|
647
690
|
type NormalizedRetryOptions = Required<RetryOptions>;
|
|
691
|
+
/** Maps request event names to their typed data payloads. */
|
|
692
|
+
type RequestEventDataMap = {
|
|
693
|
+
configured: RequestOptions;
|
|
694
|
+
success: ResponseBody;
|
|
695
|
+
error: HttpError;
|
|
696
|
+
aborted: undefined;
|
|
697
|
+
timeout: undefined;
|
|
698
|
+
retry: RetryInfo;
|
|
699
|
+
complete: {
|
|
700
|
+
timing: RequestTiming;
|
|
701
|
+
};
|
|
702
|
+
'all-complete': undefined;
|
|
703
|
+
};
|
|
704
|
+
/** A typed event handler where the data parameter matches the event name. */
|
|
705
|
+
type TypedRequestEventHandler<E extends keyof RequestEventDataMap> = (event: Event, data: RequestEventDataMap[E]) => void;
|
|
648
706
|
/** Options for the internal publish helper. */
|
|
649
707
|
type PublishOptions = {
|
|
650
708
|
name: string;
|
|
@@ -658,11 +716,12 @@ declare const endsWithSlashRegEx: RegExp;
|
|
|
658
716
|
declare const XSRF_COOKIE_NAME = "XSRF-TOKEN";
|
|
659
717
|
/** Default XSRF header name */
|
|
660
718
|
declare const XSRF_HEADER_NAME = "X-XSRF-TOKEN";
|
|
661
|
-
type MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN';
|
|
719
|
+
type MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN' | 'EVENT_STREAM' | 'NDJSON';
|
|
662
720
|
declare const mediaTypes: {
|
|
663
721
|
[key in MediaTypeKey]: MediaType;
|
|
664
722
|
};
|
|
665
723
|
declare const defaultMediaType: string;
|
|
724
|
+
declare const defaultOrigin: string;
|
|
666
725
|
/** Constant object for caching policies */
|
|
667
726
|
declare const RequestCachingPolicy: {
|
|
668
727
|
readonly DEFAULT: "default";
|
|
@@ -753,26 +812,26 @@ declare class Transportr {
|
|
|
753
812
|
readonly OMIT: "omit";
|
|
754
813
|
readonly SAME_ORIGIN: "same-origin";
|
|
755
814
|
};
|
|
756
|
-
/** Request
|
|
757
|
-
static readonly
|
|
815
|
+
/** Request Mode */
|
|
816
|
+
static readonly RequestMode: {
|
|
758
817
|
readonly CORS: "cors";
|
|
759
818
|
readonly NAVIGATE: "navigate";
|
|
760
819
|
readonly NO_CORS: "no-cors";
|
|
761
820
|
readonly SAME_ORIGIN: "same-origin";
|
|
762
821
|
};
|
|
763
|
-
/** Request
|
|
764
|
-
static readonly
|
|
822
|
+
/** Request Priority */
|
|
823
|
+
static readonly RequestPriority: {
|
|
765
824
|
readonly HIGH: "high";
|
|
766
825
|
readonly LOW: "low";
|
|
767
826
|
readonly AUTO: "auto";
|
|
768
827
|
};
|
|
769
|
-
/** Redirect
|
|
770
|
-
static readonly
|
|
828
|
+
/** Redirect Policy */
|
|
829
|
+
static readonly RedirectPolicy: {
|
|
771
830
|
readonly ERROR: "error";
|
|
772
831
|
readonly FOLLOW: "follow";
|
|
773
832
|
readonly MANUAL: "manual";
|
|
774
833
|
};
|
|
775
|
-
/** Referrer
|
|
834
|
+
/** Referrer Policy */
|
|
776
835
|
static readonly ReferrerPolicy: {
|
|
777
836
|
readonly NO_REFERRER: "no-referrer";
|
|
778
837
|
readonly NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade";
|
|
@@ -783,19 +842,19 @@ declare class Transportr {
|
|
|
783
842
|
readonly STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin";
|
|
784
843
|
readonly UNSAFE_URL: "unsafe-url";
|
|
785
844
|
};
|
|
786
|
-
/** Request
|
|
787
|
-
static readonly
|
|
845
|
+
/** Request Event */
|
|
846
|
+
static readonly RequestEvent: typeof RequestEvent;
|
|
788
847
|
/** Default Request Options */
|
|
789
848
|
private static readonly defaultRequestOptions;
|
|
790
849
|
/**
|
|
791
|
-
* Returns a {@link EventRegistration} used for subscribing to global events.
|
|
850
|
+
* Returns a {@link EventRegistration} used for subscribing to global events with typed data.
|
|
792
851
|
*
|
|
793
852
|
* @param event The event to subscribe to.
|
|
794
|
-
* @param handler The event handler.
|
|
853
|
+
* @param handler The event handler with typed data parameter.
|
|
795
854
|
* @param context The context to bind the handler to.
|
|
796
855
|
* @returns A new {@link EventRegistration} instance.
|
|
797
856
|
*/
|
|
798
|
-
static register(event:
|
|
857
|
+
static register<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;
|
|
799
858
|
/**
|
|
800
859
|
* Removes a {@link EventRegistration} from the global event handler.
|
|
801
860
|
*
|
|
@@ -809,6 +868,29 @@ declare class Transportr {
|
|
|
809
868
|
* This will also clear the {@link Transportr#signalControllers} set.
|
|
810
869
|
*/
|
|
811
870
|
static abortAll(): void;
|
|
871
|
+
/**
|
|
872
|
+
* Executes multiple requests concurrently and resolves when all complete.
|
|
873
|
+
* @param requests An array of promises from Transportr request methods.
|
|
874
|
+
* @returns A promise resolving to an array of all results.
|
|
875
|
+
*/
|
|
876
|
+
static all<T extends readonly Promise<unknown>[]>(requests: T): Promise<{
|
|
877
|
+
-readonly [K in keyof T]: Awaited<T[K]>;
|
|
878
|
+
}>;
|
|
879
|
+
/**
|
|
880
|
+
* Races multiple requests concurrently. The first to settle wins; all others are aborted.
|
|
881
|
+
* Each factory receives an AbortSignal that the caller should pass to the request options.
|
|
882
|
+
* @template T The expected result type.
|
|
883
|
+
* @param requests An array of functions that accept an AbortSignal and return a promise.
|
|
884
|
+
* @returns A promise resolving to the first settled result.
|
|
885
|
+
* @example
|
|
886
|
+
* ```typescript
|
|
887
|
+
* const result = await Transportr.race([
|
|
888
|
+
* (signal) => api.getJson('/primary', { signal }),
|
|
889
|
+
* (signal) => api.getJson('/fallback', { signal })
|
|
890
|
+
* ]);
|
|
891
|
+
* ```
|
|
892
|
+
*/
|
|
893
|
+
static race<T>(requests: ReadonlyArray<(signal: AbortSignal) => Promise<T>>): Promise<T>;
|
|
812
894
|
/**
|
|
813
895
|
* Registers a custom content-type response handler.
|
|
814
896
|
* The handler will be matched against response content-type headers using MediaType matching.
|
|
@@ -848,14 +930,14 @@ declare class Transportr {
|
|
|
848
930
|
*/
|
|
849
931
|
get baseUrl(): URL;
|
|
850
932
|
/**
|
|
851
|
-
* Registers an event handler with a {@link Transportr} instance.
|
|
933
|
+
* Registers an event handler with a {@link Transportr} instance with typed data.
|
|
852
934
|
*
|
|
853
935
|
* @param event The name of the event to listen for.
|
|
854
936
|
* @param handler The function to call when the event is triggered.
|
|
855
937
|
* @param context The context to bind to the handler.
|
|
856
938
|
* @returns An object that can be used to remove the event handler.
|
|
857
939
|
*/
|
|
858
|
-
register(event:
|
|
940
|
+
register<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;
|
|
859
941
|
/**
|
|
860
942
|
* Unregisters an event handler from a {@link Transportr} instance.
|
|
861
943
|
*
|
|
@@ -877,172 +959,176 @@ declare class Transportr {
|
|
|
877
959
|
*/
|
|
878
960
|
clearHooks(): this;
|
|
879
961
|
/**
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* This function returns a promise that resolves to the result of a request to the specified path with
|
|
886
|
-
* the specified options, where the method is GET.
|
|
887
|
-
*
|
|
888
|
-
* @async
|
|
889
|
-
* @param path The path to the resource you want to get.
|
|
890
|
-
* @param options The options for the request.
|
|
891
|
-
* @returns A promise that resolves to the response of the request.
|
|
892
|
-
*/
|
|
893
|
-
get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
894
|
-
/**
|
|
895
|
-
* This function makes a POST request to the given path with the given body and options.
|
|
896
|
-
*
|
|
897
|
-
* @async
|
|
898
|
-
* @template T The expected response type (defaults to ResponseBody)
|
|
899
|
-
* @param path The path to the endpoint you want to call.
|
|
900
|
-
* @param options The options for the request.
|
|
901
|
-
* @returns A promise that resolves to the response body.
|
|
902
|
-
*/
|
|
903
|
-
post<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
904
|
-
/**
|
|
905
|
-
* This function returns a promise that resolves to the result of a request to the specified path with
|
|
906
|
-
* the specified options, where the method is PUT.
|
|
962
|
+
* Updates the instance's default options after construction.
|
|
963
|
+
* Mirrors what the constructor accepts: headers and searchParams are merged onto
|
|
964
|
+
* the existing defaults; all other options overwrite the current value; hooks
|
|
965
|
+
* are appended via {@link addHooks}.
|
|
907
966
|
*
|
|
908
|
-
* @
|
|
909
|
-
* @
|
|
910
|
-
* @param path The path to the endpoint you want to call.
|
|
911
|
-
* @param options The options for the request.
|
|
912
|
-
* @returns The return value of the #request method.
|
|
913
|
-
*/
|
|
914
|
-
put<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
915
|
-
/**
|
|
916
|
-
* It takes a path and options, and returns a request with the method set to PATCH.
|
|
917
|
-
*
|
|
918
|
-
* @async
|
|
919
|
-
* @template T The expected response type (defaults to ResponseBody)
|
|
920
|
-
* @param path The path to the endpoint you want to hit.
|
|
921
|
-
* @param options The options for the request.
|
|
922
|
-
* @returns A promise that resolves to the response of the request.
|
|
923
|
-
*/
|
|
924
|
-
patch<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
925
|
-
/**
|
|
926
|
-
* It takes a path and options, and returns a request with the method set to DELETE.
|
|
927
|
-
*
|
|
928
|
-
* @async
|
|
929
|
-
* @param path The path to the resource you want to access.
|
|
930
|
-
* @param options The options for the request.
|
|
931
|
-
* @returns The result of the request.
|
|
932
|
-
*/
|
|
933
|
-
delete<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
934
|
-
/**
|
|
935
|
-
* Returns the response headers of a request to the given path.
|
|
936
|
-
*
|
|
937
|
-
* @async
|
|
938
|
-
* @param path The path to the resource you want to access.
|
|
939
|
-
* @param options The options for the request.
|
|
940
|
-
* @returns A promise that resolves to the response object.
|
|
941
|
-
*/
|
|
942
|
-
head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
|
|
943
|
-
/**
|
|
944
|
-
* It returns a promise that resolves to the allowed request methods for the given resource path.
|
|
945
|
-
*
|
|
946
|
-
* @async
|
|
947
|
-
* @param path The path to the resource.
|
|
948
|
-
* @param options The options for the request.
|
|
949
|
-
* @returns A promise that resolves to an array of allowed request methods for this resource.
|
|
950
|
-
*/
|
|
951
|
-
options(path?: string | RequestOptions, options?: RequestOptions): Promise<string[] | undefined>;
|
|
952
|
-
/**
|
|
953
|
-
* It takes a path and options, and makes a request to the server
|
|
954
|
-
* @async
|
|
955
|
-
* @param path The path to the endpoint you want to hit.
|
|
956
|
-
* @param options The options for the request.
|
|
957
|
-
* @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
|
|
958
|
-
* @throws {HttpError} If an error occurs during the request.
|
|
959
|
-
*/
|
|
960
|
-
request<T = unknown>(path?: string | RequestOptions, options?: RequestOptions): Promise<TypedResponse<T>>;
|
|
961
|
-
/**
|
|
962
|
-
* It gets the JSON representation of the resource at the given path.
|
|
963
|
-
*
|
|
964
|
-
* @async
|
|
965
|
-
* @template T The expected JSON response type (defaults to JsonObject)
|
|
966
|
-
* @param path The path to the resource.
|
|
967
|
-
* @param options The options object to pass to the request.
|
|
968
|
-
* @returns A promise that resolves to the response body as a typed JSON value.
|
|
969
|
-
*/
|
|
970
|
-
getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined>;
|
|
971
|
-
/**
|
|
972
|
-
* It gets the XML representation of the resource at the given path.
|
|
973
|
-
*
|
|
974
|
-
* @async
|
|
975
|
-
* @param path The path to the resource you want to get.
|
|
976
|
-
* @param options The options for the request.
|
|
977
|
-
* @returns The result of the function call to #get.
|
|
978
|
-
*/
|
|
979
|
-
getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined>;
|
|
980
|
-
/**
|
|
981
|
-
* Get the HTML content of the specified path.
|
|
982
|
-
* When a selector is provided, returns only the first matching element from the parsed document.
|
|
983
|
-
*
|
|
984
|
-
* @async
|
|
985
|
-
* @param path The path to the resource.
|
|
986
|
-
* @param options The options for the request.
|
|
987
|
-
* @param selector An optional CSS selector to extract a specific element from the parsed HTML.
|
|
988
|
-
* @returns A promise that resolves to a Document, an Element (if selector matched), or void.
|
|
989
|
-
*/
|
|
990
|
-
getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined>;
|
|
991
|
-
/**
|
|
992
|
-
* It returns a promise that resolves to the HTML fragment at the given path.
|
|
993
|
-
* When a selector is provided, returns only the first matching element from the parsed fragment.
|
|
994
|
-
*
|
|
995
|
-
* @async
|
|
996
|
-
* @param path The path to the resource.
|
|
997
|
-
* @param options The options for the request.
|
|
998
|
-
* @param selector An optional CSS selector to extract a specific element from the parsed fragment.
|
|
999
|
-
* @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.
|
|
1000
|
-
*/
|
|
1001
|
-
getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined>;
|
|
1002
|
-
/**
|
|
1003
|
-
* It gets a script from the server, and appends the script to the Document HTMLHeadElement
|
|
1004
|
-
* @param path The path to the script.
|
|
1005
|
-
* @param options The options for the request.
|
|
1006
|
-
* @returns A promise that resolves to void.
|
|
1007
|
-
*/
|
|
1008
|
-
getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
|
|
1009
|
-
/**
|
|
1010
|
-
* Gets a stylesheet from the server, and adds it as a Blob URL.
|
|
1011
|
-
* @param path The path to the stylesheet.
|
|
1012
|
-
* @param options The options for the request.
|
|
1013
|
-
* @returns A promise that resolves to void.
|
|
1014
|
-
*/
|
|
1015
|
-
getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
|
|
1016
|
-
/**
|
|
1017
|
-
* It returns a blob from the specified path.
|
|
1018
|
-
* @param path The path to the resource.
|
|
1019
|
-
* @param options The options for the request.
|
|
1020
|
-
* @returns A promise that resolves to a Blob or void.
|
|
1021
|
-
*/
|
|
1022
|
-
getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined>;
|
|
1023
|
-
/**
|
|
1024
|
-
* It returns a promise that resolves to an `HTMLImageElement`.
|
|
1025
|
-
* The object URL created to load the image is automatically revoked to prevent memory leaks.
|
|
1026
|
-
* Works in both browser and Node.js (via JSDOM) environments.
|
|
1027
|
-
* @param path The path to the image.
|
|
1028
|
-
* @param options The options for the request.
|
|
1029
|
-
* @returns A promise that resolves to an `HTMLImageElement` or `void`.
|
|
1030
|
-
*/
|
|
1031
|
-
getImage(path?: string, options?: RequestOptions): Promise<HTMLImageElement | undefined>;
|
|
1032
|
-
/**
|
|
1033
|
-
* It gets a buffer from the specified path
|
|
1034
|
-
* @param path The path to the resource.
|
|
1035
|
-
* @param options The options for the request.
|
|
1036
|
-
* @returns A promise that resolves to an ArrayBuffer or void.
|
|
967
|
+
* @param options The options to apply. Accepts the same shape as the constructor.
|
|
968
|
+
* @returns This instance for method chaining.
|
|
1037
969
|
*/
|
|
1038
|
-
|
|
970
|
+
configure({ headers, searchParams, hooks, ...options }: RequestOptions): this;
|
|
1039
971
|
/**
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
* @param options The options for the request.
|
|
1043
|
-
* @returns A promise that resolves to a ReadableStream, null, or void.
|
|
972
|
+
* Tears down this instance: clears all instance subscriptions and hooks.
|
|
973
|
+
* The instance should not be used after calling this method.
|
|
1044
974
|
*/
|
|
1045
|
-
|
|
975
|
+
destroy(): void;
|
|
976
|
+
/** Returns a Result tuple instead of throwing. */
|
|
977
|
+
get<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
978
|
+
unwrap: false;
|
|
979
|
+
}): Promise<Result<T | undefined>>;
|
|
980
|
+
/** Returns a Result tuple instead of throwing. */
|
|
981
|
+
get<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
982
|
+
unwrap: false;
|
|
983
|
+
}): Promise<Result<T | undefined>>;
|
|
984
|
+
/** Returns a Result tuple instead of throwing. */
|
|
985
|
+
post<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
986
|
+
unwrap: false;
|
|
987
|
+
}): Promise<Result<T | undefined>>;
|
|
988
|
+
/** Returns a Result tuple instead of throwing. */
|
|
989
|
+
post<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
990
|
+
unwrap: false;
|
|
991
|
+
}): Promise<Result<T | undefined>>;
|
|
992
|
+
/** Returns a Result tuple instead of throwing. */
|
|
993
|
+
put<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
994
|
+
unwrap: false;
|
|
995
|
+
}): Promise<Result<T | undefined>>;
|
|
996
|
+
/** Returns a Result tuple instead of throwing. */
|
|
997
|
+
put<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
998
|
+
unwrap: false;
|
|
999
|
+
}): Promise<Result<T | undefined>>;
|
|
1000
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1001
|
+
patch<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
1002
|
+
unwrap: false;
|
|
1003
|
+
}): Promise<Result<T | undefined>>;
|
|
1004
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1005
|
+
patch<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
1006
|
+
unwrap: false;
|
|
1007
|
+
}): Promise<Result<T | undefined>>;
|
|
1008
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1009
|
+
delete<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
1010
|
+
unwrap: false;
|
|
1011
|
+
}): Promise<Result<T | undefined>>;
|
|
1012
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1013
|
+
delete<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
1014
|
+
unwrap: false;
|
|
1015
|
+
}): Promise<Result<T | undefined>>;
|
|
1016
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1017
|
+
head<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
|
|
1018
|
+
unwrap: false;
|
|
1019
|
+
}): Promise<Result<T | undefined>>;
|
|
1020
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1021
|
+
head<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
|
|
1022
|
+
unwrap: false;
|
|
1023
|
+
}): Promise<Result<T | undefined>>;
|
|
1024
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1025
|
+
options(path: string | undefined, options: RequestOptions & {
|
|
1026
|
+
unwrap: false;
|
|
1027
|
+
}): Promise<Result<string[] | undefined>>;
|
|
1028
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1029
|
+
options(path: RequestOptions & {
|
|
1030
|
+
unwrap: false;
|
|
1031
|
+
}): Promise<Result<string[] | undefined>>;
|
|
1032
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1033
|
+
request<T = unknown>(path: string | undefined, options: RequestOptions & {
|
|
1034
|
+
unwrap: false;
|
|
1035
|
+
}): Promise<Result<TypedResponse<T>>>;
|
|
1036
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1037
|
+
request<T = unknown>(path: RequestOptions & {
|
|
1038
|
+
unwrap: false;
|
|
1039
|
+
}): Promise<Result<TypedResponse<T>>>;
|
|
1040
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1041
|
+
getJson(path: string | undefined, options: RequestOptions & {
|
|
1042
|
+
unwrap: false;
|
|
1043
|
+
}): Promise<Result<Json | undefined>>;
|
|
1044
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1045
|
+
getJson(path: RequestOptions & {
|
|
1046
|
+
unwrap: false;
|
|
1047
|
+
}): Promise<Result<Json | undefined>>;
|
|
1048
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1049
|
+
getXml(path: string | undefined, options: RequestOptions & {
|
|
1050
|
+
unwrap: false;
|
|
1051
|
+
}): Promise<Result<Document | undefined>>;
|
|
1052
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1053
|
+
getXml(path: RequestOptions & {
|
|
1054
|
+
unwrap: false;
|
|
1055
|
+
}): Promise<Result<Document | undefined>>;
|
|
1056
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1057
|
+
getHtml(path: string | undefined, options: RequestOptions & {
|
|
1058
|
+
unwrap: false;
|
|
1059
|
+
}, selector?: string): Promise<Result<Document | Element | null | undefined>>;
|
|
1060
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1061
|
+
getHtml(path: RequestOptions & {
|
|
1062
|
+
unwrap: false;
|
|
1063
|
+
}): Promise<Result<Document | Element | null | undefined>>;
|
|
1064
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1065
|
+
getHtmlFragment(path: string | undefined, options: RequestOptions & {
|
|
1066
|
+
unwrap: false;
|
|
1067
|
+
}, selector?: string): Promise<Result<DocumentFragment | Element | null | undefined>>;
|
|
1068
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1069
|
+
getHtmlFragment(path: RequestOptions & {
|
|
1070
|
+
unwrap: false;
|
|
1071
|
+
}): Promise<Result<DocumentFragment | Element | null | undefined>>;
|
|
1072
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1073
|
+
getScript(path: string | undefined, options: RequestOptions & {
|
|
1074
|
+
unwrap: false;
|
|
1075
|
+
}): Promise<Result<void>>;
|
|
1076
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1077
|
+
getScript(path: RequestOptions & {
|
|
1078
|
+
unwrap: false;
|
|
1079
|
+
}): Promise<Result<void>>;
|
|
1080
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1081
|
+
getStylesheet(path: string | undefined, options: RequestOptions & {
|
|
1082
|
+
unwrap: false;
|
|
1083
|
+
}): Promise<Result<void>>;
|
|
1084
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1085
|
+
getStylesheet(path: RequestOptions & {
|
|
1086
|
+
unwrap: false;
|
|
1087
|
+
}): Promise<Result<void>>;
|
|
1088
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1089
|
+
getBlob(path: string | undefined, options: RequestOptions & {
|
|
1090
|
+
unwrap: false;
|
|
1091
|
+
}): Promise<Result<Blob | undefined>>;
|
|
1092
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1093
|
+
getBlob(path: RequestOptions & {
|
|
1094
|
+
unwrap: false;
|
|
1095
|
+
}): Promise<Result<Blob | undefined>>;
|
|
1096
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1097
|
+
getImage(path: string | undefined, options: RequestOptions & {
|
|
1098
|
+
unwrap: false;
|
|
1099
|
+
}): Promise<Result<HTMLImageElement | undefined>>;
|
|
1100
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1101
|
+
getBuffer(path: string | undefined, options: RequestOptions & {
|
|
1102
|
+
unwrap: false;
|
|
1103
|
+
}): Promise<Result<ArrayBuffer | undefined>>;
|
|
1104
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1105
|
+
getBuffer(path: RequestOptions & {
|
|
1106
|
+
unwrap: false;
|
|
1107
|
+
}): Promise<Result<ArrayBuffer | undefined>>;
|
|
1108
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1109
|
+
getStream(path: string | undefined, options: RequestOptions & {
|
|
1110
|
+
unwrap: false;
|
|
1111
|
+
}): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;
|
|
1112
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1113
|
+
getStream(path: RequestOptions & {
|
|
1114
|
+
unwrap: false;
|
|
1115
|
+
}): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;
|
|
1116
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1117
|
+
getEventStream(path: string | undefined, options: RequestOptions & {
|
|
1118
|
+
unwrap: false;
|
|
1119
|
+
}): Promise<Result<AsyncIterable<ServerSentEvent>>>;
|
|
1120
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1121
|
+
getEventStream(path: RequestOptions & {
|
|
1122
|
+
unwrap: false;
|
|
1123
|
+
}): Promise<Result<AsyncIterable<ServerSentEvent>>>;
|
|
1124
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1125
|
+
getJsonStream<T = Json>(path: string | undefined, options: RequestOptions & {
|
|
1126
|
+
unwrap: false;
|
|
1127
|
+
}): Promise<Result<AsyncIterable<T>>>;
|
|
1128
|
+
/** Returns a Result tuple instead of throwing. */
|
|
1129
|
+
getJsonStream<T = Json>(path: RequestOptions & {
|
|
1130
|
+
unwrap: false;
|
|
1131
|
+
}): Promise<Result<AsyncIterable<T>>>;
|
|
1046
1132
|
/**
|
|
1047
1133
|
* Handles a GET request.
|
|
1048
1134
|
* @async
|
|
@@ -1168,5 +1254,5 @@ declare class Transportr {
|
|
|
1168
1254
|
get [Symbol.toStringTag](): string;
|
|
1169
1255
|
}
|
|
1170
1256
|
|
|
1171
|
-
export {
|
|
1172
|
-
export type { AbortConfiguration, AbortEvent, AbortSignalEvent, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Entries, EventRegistration, HookOptions, NormalizedRetryOptions, PublishOptions, ReadOnlyEntries, RequestBody, RequestBodyMethod, RequestEventHandler, RequestHeaders, RequestLifecycleEvent, RequestMethod, RequestOptions, ResponseHandler, RetryOptions, SearchParameters, TimeoutEvent, TypedArray, TypedResponse, XsrfOptions };
|
|
1257
|
+
export { ContentType, DownloadProgress, HttpError, HttpErrorOptions, Json, JsonArray, JsonObject, JsonPrimitive, JsonString, JsonValue, RequestCachingPolicy, RequestEvent, RequestHeader, RequestTiming, ResponseBody, ResponseStatus, Result, RetryInfo, ServerSentEvent, SignalErrors, SignalEvents, Transportr, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, defaultOrigin, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, requestBodyMethods, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut, timeoutEvent };
|
|
1258
|
+
export type { AbortConfiguration, AbortEvent, AbortSignalEvent, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Entries, EventRegistration, HookOptions, NormalizedRetryOptions, PublishOptions, ReadOnlyEntries, RequestBody, RequestBodyMethod, RequestEventDataMap, RequestEventHandler, RequestHeaders, RequestLifecycleEvent, RequestMethod, RequestOptions, ResponseHandler, RetryOptions, SearchParameters, TimeoutEvent, TypedArray, TypedRequestEventHandler, TypedResponse, XsrfOptions };
|