@quiltt/core 3.5.5 → 3.6.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/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
+ export * from './api'
2
+ export * from './storage'
1
3
  export * from './configuration'
2
4
  export * from './JsonWebToken'
3
5
  export * from './Observable'
4
- export * from './Storage'
5
6
  export * from './Timeoutable'
6
- export * from './api'
7
7
  export * from './types'
@@ -88,5 +88,3 @@ export class LocalStorage<T> {
88
88
  }
89
89
  }
90
90
  }
91
-
92
- export default LocalStorage
@@ -39,5 +39,3 @@ export class MemoryStorage<T> {
39
39
  }
40
40
  }
41
41
  }
42
-
43
- export default MemoryStorage
@@ -83,9 +83,6 @@ export class Storage<T> {
83
83
  }
84
84
  }
85
85
 
86
- export * from './Local'
87
- export * from './Memory'
88
-
89
86
  /**
90
87
  * This is an singleton to share the memory states across all instances; This
91
88
  * basically acts like shared memory when there is no localStorage.
@@ -0,0 +1,3 @@
1
+ export * from './Local'
2
+ export * from './Memory'
3
+ export * from './Storage'
@@ -1,52 +0,0 @@
1
- import type { AxiosRequestConfig as RequestConfig } from 'axios'
2
- import Axios from 'axios'
3
-
4
- export type { AxiosResponse } from 'axios'
5
- export type AxiosRequestConfig<D = any> = RequestConfig<D> & {
6
- retry: boolean
7
- }
8
-
9
- const RETRY_DELAY = 150 // ms
10
- const RETRIES = 10 // 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500 = 8.250s
11
-
12
- // Create an axios singleton for Quiltt, to prevent mutating other instances
13
- const axios = Axios.create()
14
-
15
- // Example: axios.get(url, { retry: true })
16
- axios.interceptors.response.use(undefined, (error) => {
17
- const { config, message, response } = error
18
- const messageLower = message.toLowerCase()
19
-
20
- if (!config || !config.retry) {
21
- return Promise.reject(error)
22
- }
23
-
24
- // Retry Network timeout, Network errors, and Too Many Requests
25
- if (
26
- !(
27
- messageLower.includes('timeout') ||
28
- messageLower.includes('network error') ||
29
- response?.status === 429
30
- )
31
- ) {
32
- return Promise.reject(error)
33
- }
34
-
35
- if (config.retriesRemaining === undefined) {
36
- config.retriesRemaining = RETRIES - 1
37
- } else if (config.retriesRemaining === 1) {
38
- return Promise.reject(error)
39
- } else {
40
- config.retriesRemaining -= 1
41
- }
42
-
43
- const delay = new Promise<void>((resolve) => {
44
- setTimeout(() => resolve(), RETRY_DELAY * (RETRIES - config.retriesRemaining))
45
- })
46
-
47
- return delay.then(() => axios(config))
48
- })
49
-
50
- export { axios }
51
-
52
- export default axios