@superutils/fetch 1.4.2 → 1.5.1
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/README.md +7 -7
- package/dist/browser/index.min.js +1124 -0
- package/dist/browser/index.min.js.map +1 -0
- package/dist/index.cjs +477 -0
- package/dist/index.d.cts +915 -0
- package/dist/index.d.ts +189 -183
- package/dist/index.js +97 -119
- package/package.json +15 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _superutils_promise from '@superutils/promise';
|
|
2
|
-
import { RetryOptions, RetryIfFunc, TimeoutOptions,
|
|
3
|
-
export { DeferredAsyncOptions, ResolveError, ResolveIgnored } from '@superutils/promise';
|
|
4
|
-
import { ValueOrPromise } from '@superutils/core';
|
|
2
|
+
import { RetryOptions, RetryIfFunc, TimeoutOptions, IPromisE_Timeout, DeferredAsyncOptions } from '@superutils/promise';
|
|
3
|
+
export { DeferredAsyncOptions, ResolveError, ResolveIgnored, TIMEOUT_FALLBACK, TIMEOUT_MAX, TimeoutPromise } from '@superutils/promise';
|
|
4
|
+
import { ValueOrPromise, DropFirst } from '@superutils/core';
|
|
5
5
|
|
|
6
6
|
/** Commonly used content types for easier access */
|
|
7
7
|
declare const ContentType: {
|
|
@@ -207,29 +207,41 @@ type FetchInterceptorResult<Args extends unknown[] = FetchArgsInterceptor> = Int
|
|
|
207
207
|
*/
|
|
208
208
|
type FetchInterceptors = {
|
|
209
209
|
/** Request error interceptors/transformers. See {@link FetchInterceptorError} for more details. */
|
|
210
|
-
error?: FetchInterceptorError[];
|
|
210
|
+
error?: FetchInterceptorError | FetchInterceptorError[];
|
|
211
211
|
/** Request request interceptors/transformers. See {@link FetchInterceptorRequest} for more details. */
|
|
212
|
-
request?: FetchInterceptorRequest[];
|
|
212
|
+
request?: FetchInterceptorRequest | FetchInterceptorRequest[];
|
|
213
213
|
/** Request response interceptors/transformers. See {@link FetchInterceptorResponse} for more details. */
|
|
214
|
-
response?: FetchInterceptorResponse[];
|
|
214
|
+
response?: FetchInterceptorResponse | FetchInterceptorResponse[];
|
|
215
215
|
/** Request result interceptors/transformers. See {@link FetchInterceptorResult} for more details. */
|
|
216
|
-
result?: FetchInterceptorResult[];
|
|
216
|
+
result?: FetchInterceptorResult | FetchInterceptorResult[];
|
|
217
|
+
};
|
|
218
|
+
/** Interceptors after merging should only be array of functions */
|
|
219
|
+
type FetchInterceptorsMerged = {
|
|
220
|
+
error: FetchInterceptorError[];
|
|
221
|
+
request: FetchInterceptorRequest[];
|
|
222
|
+
response: FetchInterceptorResponse[];
|
|
223
|
+
result: FetchInterceptorResult[];
|
|
217
224
|
};
|
|
218
225
|
|
|
219
|
-
|
|
220
|
-
Options extends FetchOptions = FetchOptions> = Target extends FetchOptions ? {
|
|
226
|
+
/** Exclude properties of `Target` from `Options`. `headers` will always be included */
|
|
227
|
+
type ExcludeOptions<Target, Options extends FetchOptions = FetchOptions> = Target extends FetchOptions ? {
|
|
221
228
|
headers?: Options['headers'];
|
|
222
229
|
} & Omit<Options, 'headers' | keyof Target> & Partial<Record<Exclude<keyof Target, 'headers'>, never>> : Options;
|
|
230
|
+
/** Exclude properties of `Target` from {@link PostOptions} */
|
|
223
231
|
type ExcludePostOptions<Target> = ExcludeOptions<Target, PostOptions>;
|
|
232
|
+
/** Extract the first macthing `FetchAs` from `T` array. If none matches, use `Fallback` */
|
|
233
|
+
type ExtractAs<T extends unknown[], //FetchOptions/FetchAs/...
|
|
234
|
+
Fallback = FetchAs.json> = T['length'] extends 0 ? Fallback : T[0] extends FetchAs ? T[0] : T[0] extends {
|
|
235
|
+
as: infer OptAs;
|
|
236
|
+
} ? OptAs extends FetchAs ? OptAs : ExtractAs<DropFirst<T>, Fallback> : ExtractAs<DropFirst<T>, Fallback>;
|
|
237
|
+
type ExtractFetchAs<T, TFallback = FetchAs.json> = T extends FetchAs ? T : T extends {
|
|
238
|
+
as: infer As;
|
|
239
|
+
} ? As extends FetchAs ? As : TFallback : TFallback;
|
|
224
240
|
type FetchArgs = [url: string | URL, options?: FetchOptions];
|
|
225
241
|
type FetchArgsInterceptor = [
|
|
226
242
|
url: string | URL,
|
|
227
243
|
options: FetchOptionsInterceptor
|
|
228
244
|
];
|
|
229
|
-
/** Extract `FetchAs` from `FetchOptions` */
|
|
230
|
-
type FetchAsFromOptions<TOptions, TFallback = FetchAs.json> = TOptions extends {
|
|
231
|
-
as: infer As;
|
|
232
|
-
} ? As extends FetchAs ? As : TFallback : TFallback;
|
|
233
245
|
/** Custom fetch options (not used by built-in `fetch()`*/
|
|
234
246
|
type FetchCustomOptions = {
|
|
235
247
|
/**
|
|
@@ -269,9 +281,9 @@ type FetchCustomOptions = {
|
|
|
269
281
|
validateUrl?: boolean;
|
|
270
282
|
} & FetchRetryOptions & TimeoutOptions<[]>;
|
|
271
283
|
/** Default args */
|
|
272
|
-
type FetchDeferredArgs
|
|
284
|
+
type FetchDeferredArgs = [
|
|
273
285
|
url?: string | URL,
|
|
274
|
-
options?: Omit<FetchOptions, 'abortCtrl'
|
|
286
|
+
options?: Omit<FetchOptions, 'abortCtrl'>
|
|
275
287
|
];
|
|
276
288
|
type FetchErrMsgs = {
|
|
277
289
|
/** Error message to be used when request is aborted without specifying a message */
|
|
@@ -305,13 +317,13 @@ type FetchOptionsInterceptor = Omit<FetchOptions, 'as' | 'errMsgs' | 'intercepto
|
|
|
305
317
|
errMsgs: Required<FetchErrMsgs>;
|
|
306
318
|
headers: Headers;
|
|
307
319
|
/** Interceptors/transformers for fetch requests. See {@link FetchInterceptors} for more details. */
|
|
308
|
-
interceptors:
|
|
320
|
+
interceptors: FetchInterceptorsMerged;
|
|
309
321
|
timeout: number;
|
|
310
322
|
} & FetchRetryOptions;
|
|
311
323
|
/**
|
|
312
324
|
* Result types for specific parsers ("as": FetchAs)
|
|
313
325
|
*/
|
|
314
|
-
type FetchResult<T> = {
|
|
326
|
+
type FetchResult<T = unknown> = {
|
|
315
327
|
arrayBuffer: ArrayBuffer;
|
|
316
328
|
blob: Blob;
|
|
317
329
|
bytes: Uint8Array<ArrayBuffer>;
|
|
@@ -320,6 +332,7 @@ type FetchResult<T> = {
|
|
|
320
332
|
text: string;
|
|
321
333
|
response: Response;
|
|
322
334
|
};
|
|
335
|
+
type GetFetchResult<As = unknown, T = never> = [T] extends [never] ? FetchResult[As extends unknown[] ? ExtractAs<As> : As extends FetchAs ? As : FetchAs.json] : T;
|
|
323
336
|
/**
|
|
324
337
|
* Fetch retry options
|
|
325
338
|
*/
|
|
@@ -335,10 +348,10 @@ type FetchRetryOptions = Omit<Partial<RetryOptions>, 'retry' | 'retryIf'> & {
|
|
|
335
348
|
retryIf?: RetryIfFunc<Response>;
|
|
336
349
|
};
|
|
337
350
|
type PostBody = Record<string, unknown> | BodyInit | null;
|
|
338
|
-
type PostArgs
|
|
351
|
+
type PostArgs = [
|
|
339
352
|
url: string | URL,
|
|
340
353
|
data?: PostBody | (() => PostBody),
|
|
341
|
-
options?:
|
|
354
|
+
options?: PostOptions
|
|
342
355
|
];
|
|
343
356
|
/**
|
|
344
357
|
* Dynamic arguments for deferred post-like methods.
|
|
@@ -373,16 +386,16 @@ type PostArgs<OmitMethod = false> = [
|
|
|
373
386
|
* f4().then(console.log, console.warn)
|
|
374
387
|
* ```
|
|
375
388
|
*/
|
|
376
|
-
type PostDeferredCbArgs<
|
|
389
|
+
type PostDeferredCbArgs<DefaultUrl = undefined, DefaultData = undefined, Options = PostArgs[2], PostArgsReq extends unknown[] = Required<PostArgs>, _url = undefined extends DefaultUrl ? undefined : DefaultUrl, _data = undefined extends DefaultData ? undefined : DefaultData> = [_url, _data] extends [PostArgsReq[0], undefined] ? [
|
|
377
390
|
data?: PostArgs[1],
|
|
378
391
|
options?: PostArgs[2]
|
|
379
392
|
] : [
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
] extends [undefined,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
] extends [
|
|
393
|
+
_url,
|
|
394
|
+
_data
|
|
395
|
+
] extends [undefined, PostArgsReq[1]] ? [url: PostArgs[0], options?: PostArgs[2]] : [
|
|
396
|
+
_url,
|
|
397
|
+
_data
|
|
398
|
+
] extends [PostArgsReq[0], PostArgsReq[1]] ? [options?: PostArgs[2]] : [url: PostArgs[0], data?: PostArgs[1], options?: Options];
|
|
386
399
|
/** Request options for POST-like methods that allow "options.body" */
|
|
387
400
|
type PostOptions = {
|
|
388
401
|
/** Default: `'post'` */
|
|
@@ -404,6 +417,17 @@ declare class FetchError extends Error {
|
|
|
404
417
|
});
|
|
405
418
|
}
|
|
406
419
|
|
|
420
|
+
type IPromise_Fetch<T = unknown> = Omit<IPromisE_Timeout<T>, 'abortCtrl'> & {
|
|
421
|
+
/** An `AbortController` instance to control the request. */
|
|
422
|
+
abortCtrl: AbortController;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Defines client generic parameter T based on fixed options.
|
|
427
|
+
*
|
|
428
|
+
* If `fixedOptions.as` is defined and not `FetcAs.json`, then `T` will be `never`.
|
|
429
|
+
*/
|
|
430
|
+
type ClientData<FixedOptions> = ExtractAs<[FixedOptions]> extends FetchAs.json ? unknown : never;
|
|
407
431
|
/**
|
|
408
432
|
* Create a reusable fetch client with shared options. The returned function comes attached with a
|
|
409
433
|
* `.deferred()` function for debounce and throttle behavior.
|
|
@@ -436,7 +460,7 @@ declare class FetchError extends Error {
|
|
|
436
460
|
* },
|
|
437
461
|
* {
|
|
438
462
|
* // default defer options (can be overridden)
|
|
439
|
-
*
|
|
463
|
+
* delay: 300,
|
|
440
464
|
* retry: 2, // If request fails, retry up to two more times
|
|
441
465
|
* },
|
|
442
466
|
* )
|
|
@@ -460,17 +484,13 @@ declare class FetchError extends Error {
|
|
|
460
484
|
* .then(console.log, console.warn)
|
|
461
485
|
* ```
|
|
462
486
|
*/
|
|
463
|
-
declare const createClient: <
|
|
487
|
+
declare const createClient: <FixedOptions extends FetchOptions | undefined, CommonOptions extends ExcludeOptions<FixedOptions> | undefined, CommonDelay extends number>(
|
|
464
488
|
/** Mandatory fetch options that cannot be overriden by individual request */
|
|
465
|
-
fixedOptions?:
|
|
489
|
+
fixedOptions?: FixedOptions,
|
|
466
490
|
/** Common fetch options that can be overriden by individual request */
|
|
467
|
-
commonOptions?: FetchOptions &
|
|
468
|
-
<T =
|
|
469
|
-
|
|
470
|
-
};
|
|
471
|
-
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined = string | URL | undefined, DefaultOptions extends ExcludeOptions<FixedOpts> | undefined = ExcludeOptions<FixedOpts> | undefined>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultOptions?: DefaultOptions): <TResult = unknown, TOptions_1 extends ExcludeOptions<FixedOpts> | undefined = ExcludeOptions<FixedOpts> | undefined, TAs_1 extends FetchAs = FixedAs extends FetchAs ? FixedAs : FetchAsFromOptions<TOptions_1, FetchAsFromOptions<CommonOpts>>, TReturn_1 = FetchResult<TResult>[TAs_1]>(...args: DefaultUrl extends undefined ? [url: FetchArgs[0], options?: TOptions_1] : [options?: TOptions_1]) => Omit<_superutils_promise.IPromisE_Timeout<TReturn_1>, "abortCtrl"> & {
|
|
472
|
-
abortCtrl: AbortController;
|
|
473
|
-
};
|
|
491
|
+
commonOptions?: FetchOptions & CommonOptions, commonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>) => {
|
|
492
|
+
<T extends ClientData<FixedOptions> = never, TOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result = GetFetchResult<[FixedOptions, TOptions, CommonOptions], T>>(url: FetchArgs[0], options?: TOptions): IPromise_Fetch<Result>;
|
|
493
|
+
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined = string | URL | undefined, DefaultOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultOptions?: DefaultOptions): <T extends ClientData<FixedOptions> = never, TOptions_1 extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result_1 = GetFetchResult<[FixedOptions, TOptions_1, DefaultOptions, CommonOptions], T>>(...args: DefaultUrl extends undefined ? [url: FetchArgs[0], options?: TOptions_1] : [options?: TOptions_1]) => IPromise_Fetch<Result_1>;
|
|
474
494
|
};
|
|
475
495
|
|
|
476
496
|
/**
|
|
@@ -506,7 +526,7 @@ commonOptions?: FetchOptions & CommonOpts, commonDeferOptions?: DeferredAsyncOpt
|
|
|
506
526
|
* // create a deferred client using "postClient"
|
|
507
527
|
* const updateProduct = postClient.deferred(
|
|
508
528
|
* {
|
|
509
|
-
*
|
|
529
|
+
* delay: 300, // debounce duration
|
|
510
530
|
* onResult: console.log, // prints only successful results
|
|
511
531
|
* },
|
|
512
532
|
* 'https://dummyjson.com/products/add',
|
|
@@ -519,21 +539,32 @@ commonOptions?: FetchOptions & CommonOpts, commonDeferOptions?: DeferredAsyncOpt
|
|
|
519
539
|
* updateProduct({ title: 'New title 2' }) // executed
|
|
520
540
|
* ```
|
|
521
541
|
*/
|
|
522
|
-
declare const createPostClient: <
|
|
542
|
+
declare const createPostClient: <FixedOptions extends PostOptions | undefined, CommonOptions extends ExcludePostOptions<FixedOptions> | undefined, CommonDelay extends number = number>(
|
|
523
543
|
/** Mandatory fetch options that cannot be overriden by individual request */
|
|
524
|
-
fixedOptions?:
|
|
544
|
+
fixedOptions?: FixedOptions,
|
|
525
545
|
/** Common fetch options that can be overriden by individual request */
|
|
526
|
-
commonOptions?: PostOptions &
|
|
527
|
-
<T =
|
|
528
|
-
|
|
529
|
-
};
|
|
530
|
-
deferred<ThisArg, Delay extends CommonDelay | number, DefaultOptions extends ExcludePostOptions<FixedOpts> | undefined = ExcludePostOptions<FixedOpts> | undefined, DefaultUrl extends PostArgs[0] | undefined = string | URL | undefined, DefaultData extends PostArgs[1] = PostBody | (() => PostBody) | undefined>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultData?: DefaultData, defaultOptions?: DefaultOptions): <TResult = unknown, TOptions_1 extends ExcludePostOptions<FixedOpts> | undefined = ExcludePostOptions<FixedOpts> | undefined, TAs_1 extends FetchAs = FixedAs extends FetchAs ? FixedAs : FetchAsFromOptions<TOptions_1, FetchAsFromOptions<CommonOpts>>, TReturn_1 = FetchResult<TResult>[TAs_1]>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, TOptions_1>) => Omit<_superutils_promise.IPromisE_Timeout<TReturn_1>, "abortCtrl"> & {
|
|
531
|
-
abortCtrl: AbortController;
|
|
532
|
-
};
|
|
546
|
+
commonOptions?: PostOptions & CommonOptions, commonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>) => {
|
|
547
|
+
<T extends ClientData<FixedOptions> = never, Options extends ExcludePostOptions<FixedOptions> | undefined = ExcludePostOptions<FixedOptions> | undefined, Result = GetFetchResult<[FixedOptions, Options, CommonOptions], T>>(url: PostArgs[0], data?: PostArgs[1], options?: Options): IPromise_Fetch<Result>;
|
|
548
|
+
deferred<ThisArg, DefaultUrl extends PostArgs[0] | undefined, DefaultData extends PostArgs[1] | undefined, DefaultOptions extends ExcludePostOptions<FixedOptions> | undefined = ExcludePostOptions<FixedOptions> | undefined, Delay extends CommonDelay | number = number>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultData?: DefaultData, defaultOptions?: DefaultOptions): <T extends ClientData<FixedOptions> = never, Options_1 extends ExcludePostOptions<FixedOptions> | undefined = ExcludePostOptions<FixedOptions> | undefined, TReturn = GetFetchResult<[FixedOptions, Options_1, DefaultOptions, CommonOptions], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options_1>) => IPromise_Fetch<TReturn>;
|
|
533
549
|
};
|
|
534
550
|
|
|
535
|
-
/**
|
|
536
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Gracefully executes interceptors and returns the processed value.
|
|
553
|
+
* If the value is not transformed (by returning a new value) by the interceptors,
|
|
554
|
+
* the original value is returned.
|
|
555
|
+
*
|
|
556
|
+
* @param value value to be passed to the interceptors
|
|
557
|
+
* @param signal The AbortController used to monitor the request status. If the signal is aborted (e.g. due to
|
|
558
|
+
* timeout or manual cancellation), the interceptor chain halts immediately. Note: This does not interrupt the
|
|
559
|
+
* currently executing interceptor, but prevents subsequent ones from running.
|
|
560
|
+
* @param interceptors interceptor/transformer callbacks
|
|
561
|
+
* @param args (optional) common arguments to be supplied to all the interceptors in addition to
|
|
562
|
+
* the `value' which will always be the first argument.
|
|
563
|
+
*
|
|
564
|
+
* Interceptor arguments: `[value, ...args]`
|
|
565
|
+
*/
|
|
566
|
+
declare const executeInterceptors: <T, TArgs extends unknown[]>(value: T, signal?: AbortSignal, interceptors?: Interceptor<T, TArgs>[], ...args: TArgs) => Promise<T>;
|
|
567
|
+
|
|
537
568
|
/**
|
|
538
569
|
* Extended `fetch` with timeout, retry, and other options. Automatically parses as JSON by default on success.
|
|
539
570
|
*
|
|
@@ -552,184 +583,202 @@ declare const MAX_TIMEOUT = 2147483647;
|
|
|
552
583
|
* .then(product => console.log(product))
|
|
553
584
|
* ```
|
|
554
585
|
*/
|
|
555
|
-
declare const fetch: {
|
|
556
|
-
<T, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.
|
|
557
|
-
/** An `AbortController` instance to control the request. */
|
|
558
|
-
abortCtrl: AbortController;
|
|
559
|
-
};
|
|
586
|
+
declare const fetch$1: {
|
|
587
|
+
<T = unknown, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url: string | URL, options?: FetchOptions & TOptions): IPromise_Fetch<TReturn>;
|
|
560
588
|
/** Default fetch options */
|
|
561
589
|
defaults: FetchOptionsDefault;
|
|
562
590
|
};
|
|
563
591
|
|
|
564
592
|
/**
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
* @param url request URL
|
|
568
|
-
* @param options (optional) Standard `fetch` options extended with "FetchCustomOptions"
|
|
593
|
+
* Merge one or more {@link FetchOptions}
|
|
569
594
|
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
595
|
+
* Notes:
|
|
596
|
+
* - item properties will be prioritized in the order of sequence they were passed in
|
|
597
|
+
* - the following properties will be merged
|
|
598
|
+
* * `errMsgs`
|
|
599
|
+
* * `headers`
|
|
600
|
+
* * `interceptors`
|
|
601
|
+
* - all other properties will simply override previous values
|
|
573
602
|
*
|
|
574
|
-
*
|
|
575
|
-
* .then(response => response.json())
|
|
576
|
-
* .then(console.log, console.error)
|
|
577
|
-
* ```
|
|
603
|
+
* @returns combined
|
|
578
604
|
*/
|
|
579
|
-
declare const
|
|
580
|
-
<T = Response, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url: FetchArgs[0], options?: Parameters<typeof fetch<T, TOptions, TAs, TReturn>>[1]): Omit<_superutils_promise.IPromisE_Timeout<TReturn>, "abortCtrl"> & {
|
|
581
|
-
abortCtrl: AbortController;
|
|
582
|
-
};
|
|
583
|
-
defaults: FetchOptionsDefault;
|
|
584
|
-
};
|
|
605
|
+
declare const mergeOptions: (...allOptions: (FetchOptions | undefined)[]) => FetchOptionsInterceptor;
|
|
585
606
|
|
|
586
607
|
declare const methods: {
|
|
587
608
|
/** Make HTTP requests with method GET */
|
|
588
609
|
get: {
|
|
589
|
-
<T =
|
|
610
|
+
<T extends unknown = never, TOptions extends ({
|
|
590
611
|
headers?: HeadersInit | undefined;
|
|
591
612
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
592
613
|
headers?: HeadersInit | undefined;
|
|
593
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
594
|
-
|
|
595
|
-
}
|
|
614
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
615
|
+
method: string;
|
|
616
|
+
}, TOptions, ({
|
|
617
|
+
headers?: HeadersInit | undefined;
|
|
618
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
596
619
|
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = string | URL | undefined, DefaultOptions extends ({
|
|
597
620
|
headers?: HeadersInit | undefined;
|
|
598
621
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
599
622
|
headers?: HeadersInit | undefined;
|
|
600
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay
|
|
623
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, TOptions extends ({
|
|
601
624
|
headers?: HeadersInit | undefined;
|
|
602
625
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
603
626
|
headers?: HeadersInit | undefined;
|
|
604
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
605
|
-
|
|
606
|
-
}
|
|
627
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
628
|
+
method: string;
|
|
629
|
+
}, TOptions, DefaultOptions, ({
|
|
630
|
+
headers?: HeadersInit | undefined;
|
|
631
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: string | URL, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
607
632
|
};
|
|
608
633
|
/** Make HTTP requests with method HEAD */
|
|
609
634
|
head: {
|
|
610
|
-
<T =
|
|
635
|
+
<T extends unknown = never, TOptions extends ({
|
|
611
636
|
headers?: HeadersInit | undefined;
|
|
612
637
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
613
638
|
headers?: HeadersInit | undefined;
|
|
614
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
615
|
-
|
|
616
|
-
}
|
|
639
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
640
|
+
method: string;
|
|
641
|
+
}, TOptions, ({
|
|
642
|
+
headers?: HeadersInit | undefined;
|
|
643
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
617
644
|
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = string | URL | undefined, DefaultOptions extends ({
|
|
618
645
|
headers?: HeadersInit | undefined;
|
|
619
646
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
620
647
|
headers?: HeadersInit | undefined;
|
|
621
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay
|
|
648
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, TOptions extends ({
|
|
622
649
|
headers?: HeadersInit | undefined;
|
|
623
650
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
624
651
|
headers?: HeadersInit | undefined;
|
|
625
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
626
|
-
|
|
627
|
-
}
|
|
652
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
653
|
+
method: string;
|
|
654
|
+
}, TOptions, DefaultOptions, ({
|
|
655
|
+
headers?: HeadersInit | undefined;
|
|
656
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: string | URL, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
628
657
|
};
|
|
629
658
|
/** Make HTTP requests with method OPTIONS */
|
|
630
659
|
options: {
|
|
631
|
-
<T =
|
|
660
|
+
<T extends unknown = never, TOptions extends ({
|
|
632
661
|
headers?: HeadersInit | undefined;
|
|
633
662
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
634
663
|
headers?: HeadersInit | undefined;
|
|
635
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
636
|
-
|
|
637
|
-
}
|
|
664
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
665
|
+
method: string;
|
|
666
|
+
}, TOptions, ({
|
|
667
|
+
headers?: HeadersInit | undefined;
|
|
668
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
638
669
|
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = string | URL | undefined, DefaultOptions extends ({
|
|
639
670
|
headers?: HeadersInit | undefined;
|
|
640
671
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
641
672
|
headers?: HeadersInit | undefined;
|
|
642
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay
|
|
673
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, TOptions extends ({
|
|
643
674
|
headers?: HeadersInit | undefined;
|
|
644
675
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
645
676
|
headers?: HeadersInit | undefined;
|
|
646
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
647
|
-
|
|
648
|
-
}
|
|
677
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
678
|
+
method: string;
|
|
679
|
+
}, TOptions, DefaultOptions, ({
|
|
680
|
+
headers?: HeadersInit | undefined;
|
|
681
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: string | URL, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
649
682
|
};
|
|
650
683
|
/** Make HTTP requests with method DELETE */
|
|
651
684
|
delete: {
|
|
652
|
-
<T =
|
|
685
|
+
<T extends unknown = never, Options extends ({
|
|
653
686
|
headers?: HeadersInit | undefined;
|
|
654
687
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
655
688
|
headers?: HeadersInit | undefined;
|
|
656
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
657
|
-
|
|
658
|
-
}
|
|
659
|
-
|
|
689
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
690
|
+
method: "delete";
|
|
691
|
+
}, Options, ({
|
|
692
|
+
headers?: HeadersInit | undefined;
|
|
693
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: PostArgs[0], data?: PostArgs[1], options?: Options | undefined): IPromise_Fetch<Result>;
|
|
694
|
+
deferred<ThisArg, DefaultUrl extends PostArgs[0] | undefined, DefaultData extends PostArgs[1] | undefined, DefaultOptions extends ({
|
|
660
695
|
headers?: HeadersInit | undefined;
|
|
661
696
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
662
697
|
headers?: HeadersInit | undefined;
|
|
663
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
698
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Delay extends number = number>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultData?: DefaultData | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, Options extends ({
|
|
664
699
|
headers?: HeadersInit | undefined;
|
|
665
700
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
666
701
|
headers?: HeadersInit | undefined;
|
|
667
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
668
|
-
|
|
669
|
-
}
|
|
702
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, TReturn = GetFetchResult<[{
|
|
703
|
+
method: "delete";
|
|
704
|
+
}, Options, DefaultOptions, ({
|
|
705
|
+
headers?: HeadersInit | undefined;
|
|
706
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: string | URL, data: PostBody | (() => PostBody), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
670
707
|
};
|
|
671
708
|
/** Make HTTP requests with method PATCH */
|
|
672
709
|
patch: {
|
|
673
|
-
<T =
|
|
710
|
+
<T extends unknown = never, Options extends ({
|
|
674
711
|
headers?: HeadersInit | undefined;
|
|
675
712
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
676
713
|
headers?: HeadersInit | undefined;
|
|
677
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
|
|
714
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
715
|
+
method: "patch";
|
|
716
|
+
}, Options, ({
|
|
717
|
+
headers?: HeadersInit | undefined;
|
|
718
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: PostArgs[0], data?: PostArgs[1], options?: Options | undefined): IPromise_Fetch<Result>;
|
|
719
|
+
deferred<ThisArg, DefaultUrl extends PostArgs[0] | undefined, DefaultData extends PostArgs[1] | undefined, DefaultOptions extends ({
|
|
681
720
|
headers?: HeadersInit | undefined;
|
|
682
721
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
683
722
|
headers?: HeadersInit | undefined;
|
|
684
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
723
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Delay extends number = number>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultData?: DefaultData | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, Options extends ({
|
|
685
724
|
headers?: HeadersInit | undefined;
|
|
686
725
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
687
726
|
headers?: HeadersInit | undefined;
|
|
688
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
689
|
-
|
|
690
|
-
}
|
|
727
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, TReturn = GetFetchResult<[{
|
|
728
|
+
method: "patch";
|
|
729
|
+
}, Options, DefaultOptions, ({
|
|
730
|
+
headers?: HeadersInit | undefined;
|
|
731
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: string | URL, data: PostBody | (() => PostBody), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
691
732
|
};
|
|
692
733
|
/** Make HTTP requests with method POST */
|
|
693
734
|
post: {
|
|
694
|
-
<T =
|
|
735
|
+
<T extends unknown = never, Options extends ({
|
|
695
736
|
headers?: HeadersInit | undefined;
|
|
696
737
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
697
738
|
headers?: HeadersInit | undefined;
|
|
698
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
699
|
-
|
|
700
|
-
}
|
|
701
|
-
|
|
739
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
740
|
+
method: "post";
|
|
741
|
+
}, Options, ({
|
|
742
|
+
headers?: HeadersInit | undefined;
|
|
743
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: PostArgs[0], data?: PostArgs[1], options?: Options | undefined): IPromise_Fetch<Result>;
|
|
744
|
+
deferred<ThisArg, DefaultUrl extends PostArgs[0] | undefined, DefaultData extends PostArgs[1] | undefined, DefaultOptions extends ({
|
|
702
745
|
headers?: HeadersInit | undefined;
|
|
703
746
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
704
747
|
headers?: HeadersInit | undefined;
|
|
705
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
748
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Delay extends number = number>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultData?: DefaultData | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, Options extends ({
|
|
706
749
|
headers?: HeadersInit | undefined;
|
|
707
750
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
708
751
|
headers?: HeadersInit | undefined;
|
|
709
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
710
|
-
|
|
711
|
-
}
|
|
752
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, TReturn = GetFetchResult<[{
|
|
753
|
+
method: "post";
|
|
754
|
+
}, Options, DefaultOptions, ({
|
|
755
|
+
headers?: HeadersInit | undefined;
|
|
756
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: string | URL, data: PostBody | (() => PostBody), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
712
757
|
};
|
|
713
758
|
/** Make HTTP requests with method PUT */
|
|
714
759
|
put: {
|
|
715
|
-
<T =
|
|
760
|
+
<T extends unknown = never, Options extends ({
|
|
716
761
|
headers?: HeadersInit | undefined;
|
|
717
762
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
718
763
|
headers?: HeadersInit | undefined;
|
|
719
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
|
|
764
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Result = GetFetchResult<[{
|
|
765
|
+
method: "put";
|
|
766
|
+
}, Options, ({
|
|
767
|
+
headers?: HeadersInit | undefined;
|
|
768
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: PostArgs[0], data?: PostArgs[1], options?: Options | undefined): IPromise_Fetch<Result>;
|
|
769
|
+
deferred<ThisArg, DefaultUrl extends PostArgs[0] | undefined, DefaultData extends PostArgs[1] | undefined, DefaultOptions extends ({
|
|
723
770
|
headers?: HeadersInit | undefined;
|
|
724
771
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
725
772
|
headers?: HeadersInit | undefined;
|
|
726
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
773
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, Delay extends number = number>(deferOptions?: _superutils_promise.DeferredAsyncOptions<ThisArg, Delay> | undefined, defaultUrl?: DefaultUrl | undefined, defaultData?: DefaultData | undefined, defaultOptions?: DefaultOptions | undefined): <T extends unknown = never, Options extends ({
|
|
727
774
|
headers?: HeadersInit | undefined;
|
|
728
775
|
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
729
776
|
headers?: HeadersInit | undefined;
|
|
730
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined,
|
|
731
|
-
|
|
732
|
-
}
|
|
777
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined, TReturn = GetFetchResult<[{
|
|
778
|
+
method: "put";
|
|
779
|
+
}, Options, DefaultOptions, ({
|
|
780
|
+
headers?: HeadersInit | undefined;
|
|
781
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: string | URL, data: PostBody | (() => PostBody), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
733
782
|
};
|
|
734
783
|
};
|
|
735
784
|
/**
|
|
@@ -796,9 +845,12 @@ declare const methods: {
|
|
|
796
845
|
*
|
|
797
846
|
* Default: `30_000`
|
|
798
847
|
*
|
|
848
|
+
*
|
|
849
|
+
*
|
|
799
850
|
* ---
|
|
800
851
|
*
|
|
801
|
-
* @example
|
|
852
|
+
* @example
|
|
853
|
+
* #### Drop-in replacement for built-in fetch
|
|
802
854
|
*
|
|
803
855
|
* ```javascript
|
|
804
856
|
* import fetch from '@superutils/fetch'
|
|
@@ -808,7 +860,8 @@ declare const methods: {
|
|
|
808
860
|
* .then(console.log, console.error)
|
|
809
861
|
* ```
|
|
810
862
|
*
|
|
811
|
-
* @example
|
|
863
|
+
* @example
|
|
864
|
+
* #### Method specific function with JSON parsing by default
|
|
812
865
|
* ```javascript
|
|
813
866
|
* import fetch from '@superutils/fetch'
|
|
814
867
|
*
|
|
@@ -824,7 +877,8 @@ declare const methods: {
|
|
|
824
877
|
* ```
|
|
825
878
|
*
|
|
826
879
|
*
|
|
827
|
-
* @example
|
|
880
|
+
* @example
|
|
881
|
+
* #### Set default options.
|
|
828
882
|
*
|
|
829
883
|
* Options' default values (excluding `as` and `method`) can be configured to be EFFECTIVE GLOBALLY.
|
|
830
884
|
*
|
|
@@ -856,54 +910,6 @@ declare const methods: {
|
|
|
856
910
|
* })
|
|
857
911
|
* ```
|
|
858
912
|
*/
|
|
859
|
-
declare const
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Gracefully executes interceptors and returns the processed value.
|
|
863
|
-
* If the value is not transformed (by returning a new value) by the interceptors,
|
|
864
|
-
* the original value is returned.
|
|
865
|
-
*
|
|
866
|
-
* @param value value to be passed to the interceptors
|
|
867
|
-
* @param signal The AbortController used to monitor the request status. If the signal is aborted (e.g. due to
|
|
868
|
-
* timeout or manual cancellation), the interceptor chain halts immediately. Note: This does not interrupt the
|
|
869
|
-
* currently executing interceptor, but prevents subsequent ones from running.
|
|
870
|
-
* @param interceptors interceptor/transformer callbacks
|
|
871
|
-
* @param args (optional) common arguments to be supplied to all the interceptors in addition to
|
|
872
|
-
* the `value' which will always be the first argument.
|
|
873
|
-
*
|
|
874
|
-
* Interceptor arguments: `[value, ...args]`
|
|
875
|
-
*/
|
|
876
|
-
declare const executeInterceptors: <T, TArgs extends unknown[]>(value: T, signal?: AbortSignal, interceptors?: Interceptor<T, TArgs>[], ...args: TArgs) => Promise<T>;
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Executes the built-in `fetch()` (or a custom `fetchFunc` if provided) with support for automatic retries.
|
|
880
|
-
*
|
|
881
|
-
* If `options.retry` is greater than 0, the request will be retried if it fails or if the response is not OK,
|
|
882
|
-
* unless overridden by `options.retryIf`.
|
|
883
|
-
*
|
|
884
|
-
* @param url The request URL.
|
|
885
|
-
* @param options (optional) Fetch options, including retry settings.
|
|
886
|
-
*
|
|
887
|
-
* @returns A promise resolving to the Response.
|
|
888
|
-
*/
|
|
889
|
-
declare const getResponse: (url: FetchArgs[0], options?: FetchArgs[1]) => Promise<Response>;
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* Merge one or more {@link FetchOptions}
|
|
893
|
-
*
|
|
894
|
-
* Notes:
|
|
895
|
-
* - item properties will be prioritized in the order of sequence they were passed in
|
|
896
|
-
* - the following properties will be merged
|
|
897
|
-
* * `errMsgs`
|
|
898
|
-
* * `headers`
|
|
899
|
-
* * `interceptors`
|
|
900
|
-
* - all other properties will simply override previous values
|
|
901
|
-
*
|
|
902
|
-
* @returns combined
|
|
903
|
-
*/
|
|
904
|
-
declare const mergeFetchOptions: (...allOptions: FetchOptions[]) => FetchOptionsInterceptor;
|
|
905
|
-
|
|
906
|
-
/** Merges partial fetch options ignoring empty or undefined. Otherwise, will return the first argument. */
|
|
907
|
-
declare const mergePartialOptions: (...optionsAr: (Partial<FetchOptions> | undefined)[]) => Partial<FetchOptions> | undefined;
|
|
913
|
+
declare const fetch: typeof fetch$1 & typeof methods;
|
|
908
914
|
|
|
909
|
-
export { ContentType, type ExcludeOptions, type ExcludePostOptions, type
|
|
915
|
+
export { type ClientData, ContentType, type ExcludeOptions, type ExcludePostOptions, type ExtractAs, type ExtractFetchAs, type FetchArgs, type FetchArgsInterceptor, FetchAs, type FetchCustomOptions, type FetchDeferredArgs, type FetchErrMsgs, FetchError, type FetchFunc, type FetchInterceptorError, type FetchInterceptorRequest, type FetchInterceptorResponse, type FetchInterceptorResult, type FetchInterceptors, type FetchInterceptorsMerged, type FetchOptions, type FetchOptionsDefault, type FetchOptionsInterceptor, type FetchResult, type FetchRetryOptions, type GetFetchResult, type IPromise_Fetch, type Interceptor, type PostArgs, type PostBody, type PostDeferredCbArgs, type PostOptions, createClient, createPostClient, fetch as default, executeInterceptors, fetch, mergeOptions };
|