@aws-amplify/core 6.0.1-api-v6-models.8035dfc.0 → 6.0.1-api-v6-models.572a7b5.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/lib/Cache/StorageCache.d.ts +14 -31
- package/lib/Cache/StorageCache.js +97 -102
- package/lib/Cache/StorageCache.native.d.ts +19 -0
- package/lib/Cache/StorageCache.native.js +164 -0
- package/{lib-esm/Cache/AsyncStorageCache.d.ts → lib/Cache/StorageCacheCommon.d.ts} +124 -99
- package/lib/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +494 -432
- package/lib/Cache/constants.d.ts +6 -0
- package/lib/Cache/constants.js +17 -0
- package/lib/Cache/index.d.ts +2 -0
- package/lib/Cache/index.js +7 -0
- package/lib/Cache/types/cache.d.ts +38 -0
- package/lib/Cache/types/index.d.ts +1 -1
- package/lib/Cache/types/index.js +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.js +2 -1
- package/lib/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib/Cache/utils/cacheHelpers.js +51 -0
- package/lib/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib/Cache/utils/index.d.ts +2 -0
- package/lib/Cache/utils/index.js +12 -0
- package/lib/I18n/I18n.js +1 -6
- package/lib/Platform/types.d.ts +18 -8
- package/lib/Platform/types.js +10 -2
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +1 -0
- package/lib/Reachability/Reachability.js +42 -1
- package/lib/ServiceWorker/ServiceWorker.js +69 -17
- package/lib/ServiceWorker/index.d.ts +0 -12
- package/lib/ServiceWorker/index.js +0 -12
- package/lib/Signer/Signer.js +3 -2
- package/lib/awsClients/cognitoIdentity/base.js +2 -1
- package/lib/awsClients/pinpoint/base.js +2 -1
- package/lib/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib/awsClients/pinpoint/putEvents.js +2 -1
- package/lib/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib/errors/errorHelpers.d.ts +2 -0
- package/lib/errors/errorHelpers.js +20 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +3 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +9 -6
- package/lib/libraryUtils.d.ts +8 -7
- package/lib/libraryUtils.js +17 -17
- package/lib/parseAWSExports.js +34 -19
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib/providers/pinpoint/apis/record.js +8 -24
- package/lib/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib/providers/pinpoint/index.d.ts +2 -2
- package/lib/providers/pinpoint/index.js +4 -2
- package/lib/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib/providers/pinpoint/types/errors.js +15 -0
- package/lib/providers/pinpoint/types/index.d.ts +1 -0
- package/lib/providers/pinpoint/types/index.js +3 -0
- package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib/providers/pinpoint/utils/index.js +3 -1
- package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib/providers/pinpoint/utils/resolveEndpointId.js +85 -0
- package/lib/singleton/Amplify.d.ts +2 -2
- package/lib/singleton/Amplify.js +6 -5
- package/lib/singleton/Auth/types.d.ts +3 -3
- package/lib/singleton/Cache/types.d.ts +18 -0
- package/lib/singleton/Cache/types.js +4 -0
- package/lib/singleton/Interactions/types.d.ts +21 -0
- package/lib/singleton/Interactions/types.js +4 -0
- package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib/singleton/Notifications/PushNotification/types.js +4 -0
- package/lib/singleton/Notifications/types.d.ts +3 -1
- package/lib/singleton/types.d.ts +3 -3
- package/lib/storage/CookieStorage.js +8 -5
- package/lib/storage/DefaultStorage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/errors.d.ts +1 -0
- package/lib/types/errors.js +1 -0
- package/lib/utils/amplifyUrl/index.d.ts +13 -0
- package/lib/utils/amplifyUrl/index.js +10 -0
- package/lib/utils/amplifyUrl/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUrl/polyfill.js +4 -0
- package/lib/utils/amplifyUrl/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/index.d.ts +3 -0
- package/lib/utils/amplifyUuid/index.js +9 -0
- package/lib/utils/amplifyUuid/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUuid/polyfill.js +4 -0
- package/lib/utils/amplifyUuid/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/polyfill.native.js +6 -0
- package/lib/utils/deepFreeze.d.ts +1 -0
- package/lib/utils/deepFreeze.js +38 -0
- package/lib/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +4 -4
- package/lib/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +4 -4
- package/lib/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +6 -18
- package/lib/utils/getClientInfo/index.d.ts +1 -0
- package/lib/utils/getClientInfo/index.js +7 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -1
- package/lib/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.js +55 -0
- package/lib/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib/utils/sessionListener/SessionListener.native.js +54 -0
- package/lib/utils/sessionListener/index.d.ts +2 -0
- package/lib/utils/sessionListener/index.js +7 -0
- package/lib/utils/sessionListener/types.d.ts +6 -0
- package/lib/utils/sessionListener/types.js +4 -0
- package/lib-esm/Cache/StorageCache.d.ts +14 -31
- package/lib-esm/Cache/StorageCache.js +97 -102
- package/lib-esm/Cache/StorageCache.native.d.ts +19 -0
- package/lib-esm/Cache/StorageCache.native.js +161 -0
- package/{lib/Cache/AsyncStorageCache.d.ts → lib-esm/Cache/StorageCacheCommon.d.ts} +124 -99
- package/lib-esm/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +493 -430
- package/lib-esm/Cache/constants.d.ts +6 -0
- package/lib-esm/Cache/constants.js +14 -0
- package/lib-esm/Cache/index.d.ts +2 -0
- package/lib-esm/Cache/index.js +4 -0
- package/lib-esm/Cache/types/cache.d.ts +38 -0
- package/lib-esm/Cache/types/index.d.ts +1 -1
- package/lib-esm/Cache/types/index.js +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.js +1 -1
- package/lib-esm/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib-esm/Cache/utils/cacheHelpers.js +44 -0
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib-esm/Cache/utils/index.d.ts +2 -0
- package/lib-esm/Cache/utils/index.js +4 -0
- package/lib-esm/I18n/I18n.js +1 -6
- package/lib-esm/Platform/types.d.ts +18 -8
- package/lib-esm/Platform/types.js +10 -2
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.d.ts +1 -0
- package/lib-esm/Reachability/Reachability.js +43 -2
- package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
- package/lib-esm/ServiceWorker/index.d.ts +0 -12
- package/lib-esm/ServiceWorker/index.js +0 -12
- package/lib-esm/Signer/Signer.js +3 -2
- package/lib-esm/awsClients/cognitoIdentity/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib-esm/awsClients/pinpoint/putEvents.js +2 -1
- package/lib-esm/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib-esm/errors/errorHelpers.d.ts +2 -0
- package/lib-esm/errors/errorHelpers.js +17 -0
- package/lib-esm/errors/index.d.ts +1 -0
- package/lib-esm/errors/index.js +1 -0
- package/lib-esm/index.d.ts +4 -4
- package/lib-esm/index.js +5 -4
- package/lib-esm/libraryUtils.d.ts +8 -7
- package/lib-esm/libraryUtils.js +7 -7
- package/lib-esm/parseAWSExports.js +34 -19
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/record.js +9 -25
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib-esm/providers/pinpoint/index.d.ts +2 -2
- package/lib-esm/providers/pinpoint/index.js +2 -1
- package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib-esm/providers/pinpoint/types/errors.js +12 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/types/index.js +1 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/utils/index.js +1 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
- package/lib-esm/singleton/Amplify.d.ts +2 -2
- package/lib-esm/singleton/Amplify.js +6 -5
- package/lib-esm/singleton/Auth/types.d.ts +3 -3
- package/lib-esm/singleton/Cache/types.d.ts +18 -0
- package/lib-esm/singleton/Cache/types.js +3 -0
- package/lib-esm/singleton/Interactions/types.d.ts +21 -0
- package/lib-esm/singleton/Interactions/types.js +3 -0
- package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
- package/lib-esm/singleton/Notifications/types.d.ts +3 -1
- package/lib-esm/singleton/types.d.ts +3 -3
- package/lib-esm/storage/CookieStorage.js +5 -5
- package/lib-esm/storage/DefaultStorage.js +2 -2
- package/lib-esm/storage/utils.d.ts +1 -1
- package/lib-esm/storage/utils.js +1 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/errors.d.ts +1 -0
- package/lib-esm/types/errors.js +1 -0
- package/lib-esm/utils/amplifyUrl/index.d.ts +13 -0
- package/lib-esm/utils/amplifyUrl/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/index.d.ts +3 -0
- package/lib-esm/utils/amplifyUuid/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/polyfill.native.js +4 -0
- package/lib-esm/utils/deepFreeze.d.ts +1 -0
- package/lib-esm/utils/deepFreeze.js +34 -0
- package/lib-esm/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib-esm/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +2 -2
- package/lib-esm/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib-esm/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib-esm/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +2 -2
- package/lib-esm/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +4 -14
- package/lib-esm/utils/getClientInfo/index.d.ts +1 -0
- package/lib-esm/utils/getClientInfo/index.js +3 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +2 -0
- package/lib-esm/utils/sessionListener/SessionListener.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.js +52 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.d.ts +10 -0
- package/lib-esm/utils/sessionListener/SessionListener.native.js +51 -0
- package/lib-esm/utils/sessionListener/index.d.ts +2 -0
- package/lib-esm/utils/sessionListener/index.js +4 -0
- package/lib-esm/utils/sessionListener/types.d.ts +6 -0
- package/lib-esm/utils/sessionListener/types.js +3 -0
- package/package.json +9 -19
- package/src/Cache/StorageCache.native.ts +65 -0
- package/src/Cache/StorageCache.ts +61 -158
- package/src/Cache/StorageCacheCommon.ts +577 -0
- package/src/Cache/constants.ts +18 -0
- package/src/Cache/index.ts +6 -0
- package/src/Cache/types/cache.ts +51 -0
- package/src/Cache/types/index.ts +4 -4
- package/src/Cache/{Utils → utils}/CacheList.ts +185 -185
- package/src/Cache/utils/cacheHelpers.ts +52 -0
- package/src/Cache/{Utils → utils}/errorHelpers.ts +0 -4
- package/src/Cache/{Utils → utils}/index.ts +4 -5
- package/src/I18n/I18n.ts +1 -6
- package/src/Platform/types.ts +20 -11
- package/src/Platform/version.ts +1 -1
- package/src/Reachability/Reachability.ts +22 -2
- package/src/ServiceWorker/ServiceWorker.ts +20 -17
- package/src/ServiceWorker/index.ts +0 -12
- package/src/Signer/Signer.ts +3 -2
- package/src/awsClients/cognitoIdentity/base.ts +4 -1
- package/src/awsClients/pinpoint/base.ts +2 -1
- package/src/awsClients/pinpoint/getInAppMessages.ts +2 -1
- package/src/awsClients/pinpoint/putEvents.ts +2 -1
- package/src/awsClients/pinpoint/updateEndpoint.ts +2 -1
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -2
- package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +2 -1
- package/src/errors/errorHelpers.ts +20 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +8 -4
- package/src/libraryUtils.ts +17 -11
- package/src/parseAWSExports.ts +28 -9
- package/src/providers/pinpoint/apis/flushEvents.ts +2 -2
- package/src/providers/pinpoint/apis/record.ts +14 -28
- package/src/providers/pinpoint/apis/updateEndpoint.ts +6 -6
- package/src/providers/pinpoint/index.ts +6 -2
- package/src/providers/pinpoint/types/errors.ts +12 -0
- package/src/providers/pinpoint/types/index.ts +1 -0
- package/src/providers/pinpoint/types/pinpoint.ts +3 -2
- package/src/providers/pinpoint/utils/index.ts +1 -0
- package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
- package/src/singleton/Amplify.ts +10 -8
- package/src/singleton/Auth/types.ts +3 -3
- package/src/singleton/Cache/types.ts +27 -0
- package/src/singleton/Interactions/types.ts +29 -0
- package/src/singleton/Notifications/PushNotification/types.ts +6 -0
- package/src/singleton/Notifications/types.ts +3 -1
- package/src/singleton/types.ts +3 -5
- package/src/storage/CookieStorage.ts +5 -9
- package/src/storage/DefaultStorage.ts +2 -2
- package/src/storage/utils.ts +1 -1
- package/src/types/errors.ts +1 -0
- package/src/utils/amplifyUrl/index.ts +9 -0
- package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.ts → utils/amplifyUrl/polyfill.native.ts} +1 -0
- package/src/utils/amplifyUuid/index.ts +9 -0
- package/src/utils/amplifyUuid/polyfill.native.ts +6 -0
- package/src/utils/amplifyUuid/polyfill.ts +4 -0
- package/src/utils/deepFreeze.ts +16 -0
- package/src/{ClientDevice/android.ts → utils/getClientInfo/getClientInfo.android.ts} +2 -2
- package/src/{ClientDevice/ios.ts → utils/getClientInfo/getClientInfo.ios.ts} +3 -3
- package/src/{ClientDevice/browser.ts → utils/getClientInfo/getClientInfo.ts} +4 -16
- package/src/utils/getClientInfo/index.ts +4 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/sessionListener/SessionListener.native.ts +70 -0
- package/src/utils/sessionListener/SessionListener.ts +74 -0
- package/src/utils/sessionListener/index.ts +6 -0
- package/src/utils/sessionListener/types.ts +11 -0
- package/lib/Amplify.d.ts +0 -29
- package/lib/Amplify.js +0 -118
- package/lib/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib/Cache/BrowserStorageCache.js +0 -456
- package/lib/Cache/InMemoryCache.d.ts +0 -129
- package/lib/Cache/InMemoryCache.js +0 -342
- package/lib/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib/Cache/Utils/CacheUtils.js +0 -86
- package/lib/Cache/Utils/index.d.ts +0 -2
- package/lib/Cache/Utils/index.js +0 -16
- package/lib/Cache/reactnative.d.ts +0 -3
- package/lib/Cache/reactnative.js +0 -8
- package/lib/Cache/types/Cache.d.ts +0 -55
- package/lib/ClientDevice/index.d.ts +0 -23
- package/lib/ClientDevice/index.js +0 -18
- package/lib/ClientDevice/reactnative.d.ts +0 -7
- package/lib/ClientDevice/reactnative.js +0 -24
- package/lib-esm/Amplify.d.ts +0 -29
- package/lib-esm/Amplify.js +0 -115
- package/lib-esm/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib-esm/Cache/BrowserStorageCache.js +0 -453
- package/lib-esm/Cache/InMemoryCache.d.ts +0 -129
- package/lib-esm/Cache/InMemoryCache.js +0 -339
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib-esm/Cache/Utils/CacheUtils.js +0 -79
- package/lib-esm/Cache/Utils/index.d.ts +0 -2
- package/lib-esm/Cache/Utils/index.js +0 -4
- package/lib-esm/Cache/reactnative.d.ts +0 -3
- package/lib-esm/Cache/reactnative.js +0 -6
- package/lib-esm/Cache/types/Cache.d.ts +0 -55
- package/lib-esm/ClientDevice/index.d.ts +0 -23
- package/lib-esm/ClientDevice/index.js +0 -15
- package/lib-esm/ClientDevice/reactnative.d.ts +0 -7
- package/lib-esm/ClientDevice/reactnative.js +0 -21
- package/src/Amplify.ts +0 -106
- package/src/Cache/AsyncStorageCache.ts +0 -495
- package/src/Cache/BrowserStorageCache.ts +0 -504
- package/src/Cache/CHANGELOG.md +0 -1239
- package/src/Cache/InMemoryCache.ts +0 -347
- package/src/Cache/Utils/CacheUtils.ts +0 -90
- package/src/Cache/reactnative.ts +0 -9
- package/src/Cache/types/Cache.ts +0 -75
- package/src/ClientDevice/index.ts +0 -14
- package/src/ClientDevice/reactnative.ts +0 -18
- package/lib/Cache/types/{Cache.js → cache.js} +0 -0
- package/lib/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +1 -1
- /package/lib-esm/Cache/types/{Cache.js → cache.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → utils/amplifyUrl/polyfill.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.js → utils/amplifyUrl/polyfill.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → utils/amplifyUrl/polyfill.native.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → lib-esm/utils/amplifyUuid/polyfill.d.ts} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.js → lib-esm/utils/amplifyUuid/polyfill.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → lib-esm/utils/amplifyUuid/polyfill.native.d.ts} +0 -0
- /package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.ts → utils/amplifyUrl/polyfill.ts} +0 -0
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageCacheCommon } from './StorageCacheCommon';
|
|
2
|
+
import { Cache, CacheConfig } from './types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Customized storage based on the SessionStorage or LocalStorage with LRU implemented
|
|
5
5
|
*/
|
|
6
|
-
export declare class StorageCache {
|
|
7
|
-
|
|
6
|
+
export declare class StorageCache extends StorageCacheCommon implements Cache {
|
|
7
|
+
storage: Storage;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param config - Custom configuration for this instance.
|
|
9
|
+
* initialize the cache
|
|
10
|
+
* @param config - the configuration of the cache
|
|
12
11
|
*/
|
|
13
12
|
constructor(config?: CacheConfig);
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
protected getAllCacheKeys(options?: {
|
|
14
|
+
omitSizeKey?: boolean;
|
|
15
|
+
}): Promise<string[]>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
* @return - the item which has the meta-data and the value
|
|
17
|
+
* Return a new instance of cache with customized configuration.
|
|
18
|
+
* @param {Object} config - the customized configuration
|
|
19
|
+
* @return {Object} - the new instance of Cache
|
|
22
20
|
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Set custom configuration for the cache instance.
|
|
26
|
-
*
|
|
27
|
-
* @param config - customized configuration (without keyPrefix, which can't be changed)
|
|
28
|
-
*
|
|
29
|
-
* @return - the current configuration
|
|
30
|
-
*/
|
|
31
|
-
configure(config?: Omit<CacheConfig, 'keyPrefix'>): CacheConfig;
|
|
32
|
-
/**
|
|
33
|
-
* Returns an appropriate configuration for the Cache instance. Will apply any custom configuration for this
|
|
34
|
-
* instance on top of the global configuration. Default configuration will be applied in all cases.
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
protected get cacheConfig(): CacheConfig;
|
|
21
|
+
createInstance(config: CacheConfig): Cache;
|
|
39
22
|
}
|
|
@@ -1,121 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
4
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
56
|
exports.StorageCache = void 0;
|
|
6
|
-
var Utils_1 = require("./Utils");
|
|
7
57
|
var Logger_1 = require("../Logger");
|
|
8
|
-
var
|
|
58
|
+
var KeyValueStorage_1 = require("../storage/KeyValueStorage");
|
|
59
|
+
var utils_1 = require("../storage/utils");
|
|
60
|
+
var constants_1 = require("./constants");
|
|
61
|
+
var StorageCacheCommon_1 = require("./StorageCacheCommon");
|
|
62
|
+
var utils_2 = require("./utils");
|
|
63
|
+
var logger = new Logger_1.ConsoleLogger('Cache');
|
|
9
64
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
65
|
+
* Customized storage based on the SessionStorage or LocalStorage with LRU implemented
|
|
12
66
|
*/
|
|
13
|
-
var StorageCache = /** @class */ (function () {
|
|
67
|
+
var StorageCache = /** @class */ (function (_super) {
|
|
68
|
+
__extends(StorageCache, _super);
|
|
14
69
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param config - Custom configuration for this instance.
|
|
70
|
+
* initialize the cache
|
|
71
|
+
* @param config - the configuration of the cache
|
|
18
72
|
*/
|
|
19
73
|
function StorageCache(config) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
74
|
+
var _this = this;
|
|
75
|
+
var storage = (0, utils_1.getLocalStorageWithFallback)();
|
|
76
|
+
_this = _super.call(this, { config: config, keyValueStorage: new KeyValueStorage_1.KeyValueStorage(storage) }) || this;
|
|
77
|
+
_this.storage = storage;
|
|
78
|
+
_this.getItem = _this.getItem.bind(_this);
|
|
79
|
+
_this.setItem = _this.setItem.bind(_this);
|
|
80
|
+
_this.removeItem = _this.removeItem.bind(_this);
|
|
81
|
+
return _this;
|
|
25
82
|
}
|
|
26
|
-
StorageCache.prototype.
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
// Set 5MB limit
|
|
46
|
-
var cacheLimit = 5 * 1024 * 1024;
|
|
47
|
-
if (this.cacheConfig.capacityInBytes > cacheLimit) {
|
|
48
|
-
logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');
|
|
49
|
-
tempInstanceConfig.capacityInBytes = Utils_1.defaultConfig.capacityInBytes;
|
|
50
|
-
}
|
|
51
|
-
// Apply sanitized values to the instance config
|
|
52
|
-
if (Object.keys(tempInstanceConfig).length > 0) {
|
|
53
|
-
this.instanceConfig = tempInstanceConfig;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* produce a JSON object with meta-data and data value
|
|
58
|
-
* @param value - the value of the item
|
|
59
|
-
* @param options - optional, the specified meta-data
|
|
60
|
-
*
|
|
61
|
-
* @return - the item which has the meta-data and the value
|
|
62
|
-
*/
|
|
63
|
-
StorageCache.prototype.fillCacheItem = function (key, value, options) {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
var ret = {
|
|
66
|
-
key: key,
|
|
67
|
-
data: value,
|
|
68
|
-
timestamp: (0, Utils_1.getCurrTime)(),
|
|
69
|
-
visitedTime: (0, Utils_1.getCurrTime)(),
|
|
70
|
-
priority: (_a = options.priority) !== null && _a !== void 0 ? _a : 0,
|
|
71
|
-
expires: (_b = options.expires) !== null && _b !== void 0 ? _b : 0,
|
|
72
|
-
type: typeof value,
|
|
73
|
-
byteSize: 0,
|
|
74
|
-
};
|
|
75
|
-
ret.byteSize = (0, Utils_1.getByteLength)(JSON.stringify(ret));
|
|
76
|
-
// for accurate size
|
|
77
|
-
ret.byteSize = (0, Utils_1.getByteLength)(JSON.stringify(ret));
|
|
78
|
-
return ret;
|
|
83
|
+
StorageCache.prototype.getAllCacheKeys = function (options) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var omitSizeKey, keys, i, key;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
omitSizeKey = (options !== null && options !== void 0 ? options : {}).omitSizeKey;
|
|
88
|
+
keys = [];
|
|
89
|
+
for (i = 0; i < this.storage.length; i++) {
|
|
90
|
+
key = this.storage.key(i);
|
|
91
|
+
if (omitSizeKey && key === (0, utils_2.getCurrentSizeKey)(this.config.keyPrefix)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (key === null || key === void 0 ? void 0 : key.startsWith(this.config.keyPrefix)) {
|
|
95
|
+
keys.push(key.substring(this.config.keyPrefix.length));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [2 /*return*/, keys];
|
|
99
|
+
});
|
|
100
|
+
});
|
|
79
101
|
};
|
|
80
102
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
*
|
|
85
|
-
* @return - the current configuration
|
|
103
|
+
* Return a new instance of cache with customized configuration.
|
|
104
|
+
* @param {Object} config - the customized configuration
|
|
105
|
+
* @return {Object} - the new instance of Cache
|
|
86
106
|
*/
|
|
87
|
-
StorageCache.prototype.
|
|
88
|
-
if (config) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
this.instanceConfig = this.instanceConfig
|
|
93
|
-
? Object.assign({}, this.instanceConfig, config)
|
|
94
|
-
: config;
|
|
107
|
+
StorageCache.prototype.createInstance = function (config) {
|
|
108
|
+
if (!config.keyPrefix || config.keyPrefix === constants_1.defaultConfig.keyPrefix) {
|
|
109
|
+
logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
|
|
110
|
+
config.keyPrefix = utils_2.getCurrentTime.toString();
|
|
95
111
|
}
|
|
96
|
-
|
|
97
|
-
return this.cacheConfig;
|
|
112
|
+
return new StorageCache(config);
|
|
98
113
|
};
|
|
99
|
-
Object.defineProperty(StorageCache.prototype, "cacheConfig", {
|
|
100
|
-
/**
|
|
101
|
-
* Returns an appropriate configuration for the Cache instance. Will apply any custom configuration for this
|
|
102
|
-
* instance on top of the global configuration. Default configuration will be applied in all cases.
|
|
103
|
-
*
|
|
104
|
-
* @internal
|
|
105
|
-
*/
|
|
106
|
-
get: function () {
|
|
107
|
-
// const globalCacheConfig = Amplify.getConfig().Cache || {};
|
|
108
|
-
var globalCacheConfig = {};
|
|
109
|
-
if (this.instanceConfig) {
|
|
110
|
-
return Object.assign({}, Utils_1.defaultConfig, globalCacheConfig, this.instanceConfig);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return Object.assign({}, Utils_1.defaultConfig, globalCacheConfig);
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
enumerable: false,
|
|
117
|
-
configurable: true
|
|
118
|
-
});
|
|
119
114
|
return StorageCache;
|
|
120
|
-
}());
|
|
115
|
+
}(StorageCacheCommon_1.StorageCacheCommon));
|
|
121
116
|
exports.StorageCache = StorageCache;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StorageCacheCommon } from './StorageCacheCommon';
|
|
2
|
+
import { Cache, CacheConfig } from './types';
|
|
3
|
+
export declare class StorageCache extends StorageCacheCommon implements Cache {
|
|
4
|
+
/**
|
|
5
|
+
* initialize the cache
|
|
6
|
+
* @param config - the configuration of the cache
|
|
7
|
+
*/
|
|
8
|
+
constructor(config?: CacheConfig);
|
|
9
|
+
protected getAllCacheKeys(options?: {
|
|
10
|
+
omitSizeKey?: boolean;
|
|
11
|
+
}): Promise<string[]>;
|
|
12
|
+
protected getAllStorageKeys(): Promise<readonly string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Return a new instance of cache with customized configuration.
|
|
15
|
+
* @param {Object} config - the customized configuration
|
|
16
|
+
* @return {Object} - the new instance of Cache
|
|
17
|
+
*/
|
|
18
|
+
createInstance(config: CacheConfig): Cache;
|
|
19
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var __values = (this && this.__values) || function(o) {
|
|
56
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
57
|
+
if (m) return m.call(o);
|
|
58
|
+
if (o && typeof o.length === "number") return {
|
|
59
|
+
next: function () {
|
|
60
|
+
if (o && i >= o.length) o = void 0;
|
|
61
|
+
return { value: o && o[i++], done: !o };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.StorageCache = void 0;
|
|
68
|
+
var react_native_1 = require("@aws-amplify/react-native");
|
|
69
|
+
var Logger_1 = require("../Logger");
|
|
70
|
+
var constants_1 = require("./constants");
|
|
71
|
+
var StorageCacheCommon_1 = require("./StorageCacheCommon");
|
|
72
|
+
var utils_1 = require("./utils");
|
|
73
|
+
var logger = new Logger_1.ConsoleLogger('StorageCache');
|
|
74
|
+
var AsyncStorage = (0, react_native_1.loadAsyncStorage)();
|
|
75
|
+
/*
|
|
76
|
+
* Customized cache which based on the AsyncStorage with LRU implemented
|
|
77
|
+
*/
|
|
78
|
+
var StorageCache = /** @class */ (function (_super) {
|
|
79
|
+
__extends(StorageCache, _super);
|
|
80
|
+
/**
|
|
81
|
+
* initialize the cache
|
|
82
|
+
* @param config - the configuration of the cache
|
|
83
|
+
*/
|
|
84
|
+
function StorageCache(config) {
|
|
85
|
+
var _this = _super.call(this, { config: config, keyValueStorage: AsyncStorage }) || this;
|
|
86
|
+
_this.getItem = _this.getItem.bind(_this);
|
|
87
|
+
_this.setItem = _this.setItem.bind(_this);
|
|
88
|
+
_this.removeItem = _this.removeItem.bind(_this);
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
StorageCache.prototype.getAllCacheKeys = function (options) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var omitSizeKey, keys, _a, _b, key, e_1_1;
|
|
94
|
+
var e_1, _c;
|
|
95
|
+
return __generator(this, function (_d) {
|
|
96
|
+
switch (_d.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
omitSizeKey = (options !== null && options !== void 0 ? options : {}).omitSizeKey;
|
|
99
|
+
keys = [];
|
|
100
|
+
_d.label = 1;
|
|
101
|
+
case 1:
|
|
102
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
103
|
+
return [4 /*yield*/, AsyncStorage.getAllKeys()];
|
|
104
|
+
case 2:
|
|
105
|
+
_a = __values.apply(void 0, [_d.sent()]), _b = _a.next();
|
|
106
|
+
_d.label = 3;
|
|
107
|
+
case 3:
|
|
108
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
109
|
+
key = _b.value;
|
|
110
|
+
if (omitSizeKey && key === (0, utils_1.getCurrentSizeKey)(this.config.keyPrefix)) {
|
|
111
|
+
return [3 /*break*/, 4];
|
|
112
|
+
}
|
|
113
|
+
if (key === null || key === void 0 ? void 0 : key.startsWith(this.config.keyPrefix)) {
|
|
114
|
+
keys.push(key.substring(this.config.keyPrefix.length));
|
|
115
|
+
}
|
|
116
|
+
_d.label = 4;
|
|
117
|
+
case 4:
|
|
118
|
+
_b = _a.next();
|
|
119
|
+
return [3 /*break*/, 3];
|
|
120
|
+
case 5: return [3 /*break*/, 8];
|
|
121
|
+
case 6:
|
|
122
|
+
e_1_1 = _d.sent();
|
|
123
|
+
e_1 = { error: e_1_1 };
|
|
124
|
+
return [3 /*break*/, 8];
|
|
125
|
+
case 7:
|
|
126
|
+
try {
|
|
127
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
128
|
+
}
|
|
129
|
+
finally { if (e_1) throw e_1.error; }
|
|
130
|
+
return [7 /*endfinally*/];
|
|
131
|
+
case 8: return [2 /*return*/, keys];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
StorageCache.prototype.getAllStorageKeys = function () {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
try {
|
|
140
|
+
return [2 /*return*/, AsyncStorage.getAllKeys()];
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
logger.warn("getAllKeys failed! ".concat(e));
|
|
144
|
+
return [2 /*return*/, []];
|
|
145
|
+
}
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Return a new instance of cache with customized configuration.
|
|
152
|
+
* @param {Object} config - the customized configuration
|
|
153
|
+
* @return {Object} - the new instance of Cache
|
|
154
|
+
*/
|
|
155
|
+
StorageCache.prototype.createInstance = function (config) {
|
|
156
|
+
if (!config.keyPrefix || config.keyPrefix === constants_1.defaultConfig.keyPrefix) {
|
|
157
|
+
logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
|
|
158
|
+
config.keyPrefix = utils_1.getCurrentTime.toString();
|
|
159
|
+
}
|
|
160
|
+
return new StorageCache(config);
|
|
161
|
+
};
|
|
162
|
+
return StorageCache;
|
|
163
|
+
}(StorageCacheCommon_1.StorageCacheCommon));
|
|
164
|
+
exports.StorageCache = StorageCache;
|