lissa 1.0.1 → 1.0.2

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 (2) hide show
  1. package/lib/index.d.ts +17 -17
  2. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -417,7 +417,7 @@ export declare class ResponseError extends Error {
417
417
  *
418
418
  * Retry requests on connection errors or server errors
419
419
  */
420
- export declare const retry: (options: RetryOptions) => Plugin;
420
+ export declare const retry: (options?: RetryOptions) => Plugin;
421
421
 
422
422
  export type CustomRetryError = {
423
423
  /** custom retry type have to be returned by shouldRetry hook */
@@ -425,10 +425,10 @@ export type CustomRetryError = {
425
425
  };
426
426
 
427
427
  export type RetryOptions = CustomRetryError & {
428
- onConnectionError: number;
429
- onGatewayError: number;
430
- on429: number;
431
- onServerError: number;
428
+ onConnectionError?: number;
429
+ onGatewayError?: number;
430
+ on429?: number;
431
+ onServerError?: number;
432
432
 
433
433
  /**
434
434
  * Decide if the occurred error should trigger a retry.
@@ -439,38 +439,38 @@ export type RetryOptions = CustomRetryError & {
439
439
  * maximum retries can be configured as `on${errorType}`. Return "CustomError"
440
440
  * and define the retries as { onCustomError: 3 }
441
441
  */
442
- shouldRetry(
442
+ shouldRetry?: (
443
443
  errorType: void | 'ConnectionError' | 'GatewayError' | '429' | 'ServerError',
444
444
  error: ResponseError | ConnectionError | GeneralErrorResponse,
445
- ): void | false | string;
445
+ ) => void | false | string;
446
446
 
447
447
  /**
448
448
  * Hook into the retry logic after the retry is triggered and before the delay
449
449
  * is awaited. Use beforeRetry e. g. if you want to change how long the delay
450
450
  * should be or to notify a customer that the connection is lost.
451
451
  */
452
- beforeRetry(
452
+ beforeRetry?: (
453
453
  retry: { attempt: number, delay: number },
454
454
  error: ResponseError | ConnectionError | GeneralErrorResponse,
455
- ): void | { attempt: number, delay: number };
455
+ ) => void | { attempt: number, delay: number };
456
456
 
457
457
  /**
458
458
  * Hook into the retry logic after the delay is awaited and before the request
459
459
  * gets resend. Use onRetry e. g. if you want to log that a retry is running now
460
460
  */
461
- onRetry(
461
+ onRetry?: (
462
462
  retry: { attempt: number, delay: number },
463
463
  error: ResponseError | ConnectionError | GeneralErrorResponse,
464
- ): void;
464
+ ) => void;
465
465
 
466
466
  /**
467
467
  * Hook into the retry logic after a request was successful. Use onSuccess
468
468
  * e. g. if you want to dismiss a connection lost notification
469
469
  */
470
- onSuccess(
470
+ onSuccess?: (
471
471
  retry: { attempt: number, delay: number },
472
472
  res: ResultValue,
473
- ): void;
473
+ ) => void;
474
474
  };
475
475
 
476
476
  /**
@@ -478,26 +478,26 @@ export type RetryOptions = CustomRetryError & {
478
478
  *
479
479
  * Aborts leading or trailing requests to the same endpoint (depends on configured strategy [default is leading])
480
480
  */
481
- export declare const dedupe: (options: DedupeOptions) => Plugin;
481
+ export declare const dedupe: (options?: DedupeOptions) => Plugin;
482
482
 
483
483
  export type DedupeOptions = {
484
484
  /**
485
485
  * Which request methods should be deduped. Defaults to "get"
486
486
  */
487
- methods: HttpMethod[];
487
+ methods?: HttpMethod[];
488
488
 
489
489
  /**
490
490
  * How to build the endpoint identifier. Defaults to url + method.
491
491
  * Return false to skip dedupe logic.
492
492
  */
493
- getIdentifier: (options: LissaOptions) => any;
493
+ getIdentifier?: (options: LissaOptions) => any;
494
494
 
495
495
  /**
496
496
  * Define default strategy. Abort leading requests on new request or abort
497
497
  * trailing new requests until first finishes. Can be also configured
498
498
  * individually by adding a dedupe param to the request options.
499
499
  */
500
- defaultStrategy: 'leading' | 'trailing';
500
+ defaultStrategy?: 'leading' | 'trailing';
501
501
  };
502
502
 
503
503
  // Named exports are also params of the default export
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lissa",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A lightweight, extensible HTTP client for modern JavaScript applications with fluent api syntax, hooks, plugins and more.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",