@aws-amplify/core 5.8.2 → 6.0.1-console-preview.7919075.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/README.md +3 -0
- package/lib/Amplify.d.ts +18 -17
- package/lib/Amplify.js +9 -0
- package/lib/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib/Cache/AsyncStorageCache.js +744 -0
- package/lib/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib/Cache/BrowserStorageCache.js +469 -0
- package/lib/Cache/InMemoryCache.d.ts +129 -0
- package/lib/Cache/InMemoryCache.js +349 -0
- package/lib/Cache/StorageCache.d.ts +39 -0
- package/lib/Cache/StorageCache.js +121 -0
- package/lib/Cache/Utils/CacheList.d.ts +89 -0
- package/lib/Cache/Utils/CacheList.js +196 -0
- package/lib/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib/Cache/Utils/CacheUtils.js +88 -0
- package/lib/Cache/Utils/index.d.ts +2 -0
- package/lib/Cache/Utils/index.js +16 -0
- package/lib/Cache/reactnative.d.ts +3 -0
- package/lib/Cache/reactnative.js +8 -0
- package/lib/Cache/types/Cache.d.ts +55 -0
- package/lib/Cache/types/Cache.js +4 -0
- package/lib/Cache/types/index.d.ts +1 -0
- package/lib/Cache/types/index.js +19 -0
- package/lib/ClientDevice/android.js +3 -2
- package/lib/ClientDevice/ios.d.ts +2 -2
- package/lib/ClientDevice/ios.js +3 -2
- package/lib/ClientDevice/reactnative.js +3 -2
- package/lib/Credentials.d.ts +1 -1
- package/lib/Credentials.js +2 -1
- package/lib/Errors.d.ts +19 -0
- package/lib/Errors.js +50 -1
- package/lib/Hub.js +1 -0
- package/lib/I18n/I18n.d.ts +29 -9
- package/lib/I18n/I18n.js +30 -5
- package/lib/I18n/index.d.ts +18 -5
- package/lib/I18n/index.js +35 -5
- package/lib/I18n/types.d.ts +4 -1
- package/lib/I18n/types.js +3 -0
- package/lib/JS.d.ts +6 -6
- package/lib/Logger/ConsoleLogger.d.ts +11 -11
- package/lib/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib/Platform/detectFramework.js +2 -1
- package/lib/Platform/detection/Next.d.ts +1 -1
- package/lib/Platform/detection/React.js +1 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib/Providers/AWSCloudWatchProvider.js +35 -12
- package/lib/RNComponents/index.d.ts +1 -1
- package/lib/RNComponents/reactnative.js +3 -2
- package/lib/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib/ServiceWorker/ServiceWorker.js +37 -11
- package/lib/Signer.d.ts +14 -1
- package/lib/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib/StorageHelper/cookieStorage.js +167 -0
- package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib/StorageHelper/inMemoryStorage.js +82 -0
- package/lib/StorageHelper/index.d.ts +7 -3
- package/lib/StorageHelper/index.js +9 -1
- package/lib/StorageHelper/localStorage.d.ts +32 -0
- package/lib/StorageHelper/localStorage.js +114 -0
- package/lib/StorageHelper/reactnative.d.ts +71 -1
- package/lib/StorageHelper/reactnative.js +154 -10
- package/lib/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib/StorageHelper/sessionStorage.js +114 -0
- package/lib/UniversalStorage/index.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib/Util/BackgroundProcessManager.js +1 -0
- package/lib/Util/DateUtils.d.ts +12 -1
- package/lib/Util/Reachability.js +7 -5
- package/lib/Util/Reachability.native.d.ts +3 -2
- package/lib/Util/StringUtils.js +3 -10
- package/lib/Util/errors/AssertError.d.ts +2 -0
- package/lib/Util/errors/AssertError.js +11 -0
- package/lib/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib/clients/middleware/retry/middleware.js +13 -13
- package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib/clients/serde/responseInfo.js +1 -1
- package/lib/clients/types/aws.d.ts +4 -0
- package/lib/clients/types/index.d.ts +1 -1
- package/lib/constants.d.ts +7 -0
- package/lib/constants.js +9 -1
- package/lib/index.d.ts +18 -4
- package/lib/index.js +32 -5
- package/lib/parseAWSExports.d.ts +1 -1
- package/lib/singleton/Auth/index.d.ts +30 -0
- package/lib/singleton/Auth/index.js +133 -0
- package/lib/singleton/Auth/types.d.ts +95 -0
- package/lib/singleton/Auth/types.js +6 -0
- package/lib/singleton/Auth/utils/index.d.ts +5 -0
- package/lib/singleton/Auth/utils/index.js +52 -0
- package/lib/singleton/Storage/types.d.ts +14 -0
- package/lib/singleton/Storage/types.js +4 -0
- package/lib/singleton/index.d.ts +46 -0
- package/lib/singleton/index.js +160 -0
- package/lib/singleton/types.d.ts +21 -0
- package/lib/singleton/types.js +4 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types.d.ts +31 -1
- package/lib/types/types.js +2 -0
- package/lib-esm/Amplify.d.ts +18 -17
- package/lib-esm/Amplify.js +9 -0
- package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +3 -10
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/base.d.ts +2 -10
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +6 -0
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +2 -2
- package/lib-esm/Cache/AsyncStorageCache.d.ts +154 -0
- package/lib-esm/Cache/AsyncStorageCache.js +737 -0
- package/lib-esm/Cache/BrowserStorageCache.d.ts +166 -0
- package/lib-esm/Cache/BrowserStorageCache.js +466 -0
- package/lib-esm/Cache/InMemoryCache.d.ts +129 -0
- package/lib-esm/Cache/InMemoryCache.js +346 -0
- package/lib-esm/Cache/StorageCache.d.ts +39 -0
- package/lib-esm/Cache/StorageCache.js +118 -0
- package/lib-esm/Cache/Utils/CacheList.d.ts +89 -0
- package/lib-esm/Cache/Utils/CacheList.js +194 -0
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +25 -0
- package/lib-esm/Cache/Utils/CacheUtils.js +81 -0
- package/lib-esm/Cache/Utils/index.d.ts +2 -0
- package/lib-esm/Cache/Utils/index.js +4 -0
- package/lib-esm/Cache/reactnative.d.ts +3 -0
- package/lib-esm/Cache/reactnative.js +6 -0
- package/lib-esm/Cache/types/Cache.d.ts +55 -0
- package/lib-esm/Cache/types/Cache.js +3 -0
- package/lib-esm/Cache/types/index.d.ts +1 -0
- package/lib-esm/Cache/types/index.js +3 -0
- package/lib-esm/ClientDevice/android.js +1 -0
- package/lib-esm/ClientDevice/ios.d.ts +2 -2
- package/lib-esm/ClientDevice/ios.js +1 -0
- package/lib-esm/ClientDevice/reactnative.js +1 -0
- package/lib-esm/Credentials.d.ts +1 -1
- package/lib-esm/Credentials.js +2 -1
- package/lib-esm/Errors.d.ts +19 -0
- package/lib-esm/Errors.js +49 -0
- package/lib-esm/Hub.js +1 -0
- package/lib-esm/I18n/I18n.d.ts +29 -9
- package/lib-esm/I18n/I18n.js +30 -5
- package/lib-esm/I18n/index.d.ts +18 -5
- package/lib-esm/I18n/index.js +35 -5
- package/lib-esm/I18n/types.d.ts +4 -1
- package/lib-esm/I18n/types.js +3 -0
- package/lib-esm/JS.d.ts +6 -6
- package/lib-esm/Logger/ConsoleLogger.d.ts +11 -11
- package/lib-esm/OAuthHelper/GoogleOAuth.js +2 -1
- package/lib-esm/Platform/detectFramework.js +2 -1
- package/lib-esm/Platform/detection/Next.d.ts +1 -1
- package/lib-esm/Platform/detection/React.js +1 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +2 -2
- package/lib-esm/Providers/AWSCloudWatchProvider.js +33 -10
- package/lib-esm/RNComponents/index.d.ts +1 -1
- package/lib-esm/RNComponents/reactnative.js +1 -0
- package/lib-esm/ServiceWorker/ServiceWorker.d.ts +4 -4
- package/lib-esm/ServiceWorker/ServiceWorker.js +37 -11
- package/lib-esm/Signer.d.ts +14 -1
- package/lib-esm/StorageHelper/cookieStorage.d.ts +13 -0
- package/lib-esm/StorageHelper/cookieStorage.js +141 -0
- package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
- package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
- package/lib-esm/StorageHelper/index.d.ts +7 -3
- package/lib-esm/StorageHelper/index.js +4 -0
- package/lib-esm/StorageHelper/localStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/localStorage.js +111 -0
- package/lib-esm/StorageHelper/reactnative.d.ts +71 -1
- package/lib-esm/StorageHelper/reactnative.js +153 -9
- package/lib-esm/StorageHelper/sessionStorage.d.ts +32 -0
- package/lib-esm/StorageHelper/sessionStorage.js +111 -0
- package/lib-esm/UniversalStorage/index.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.d.ts +2 -2
- package/lib-esm/Util/BackgroundProcessManager.js +1 -0
- package/lib-esm/Util/DateUtils.d.ts +12 -1
- package/lib-esm/Util/Reachability.js +5 -3
- package/lib-esm/Util/Reachability.native.d.ts +3 -2
- package/lib-esm/Util/StringUtils.js +3 -10
- package/lib-esm/Util/errors/AssertError.d.ts +2 -0
- package/lib-esm/Util/errors/AssertError.js +7 -0
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -13
- package/lib-esm/clients/middleware/retry/isClockSkewError.js +1 -1
- package/lib-esm/clients/middleware/retry/middleware.d.ts +1 -1
- package/lib-esm/clients/middleware/retry/middleware.js +13 -13
- package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
- package/lib-esm/clients/serde/responseInfo.js +1 -1
- package/lib-esm/clients/types/aws.d.ts +4 -0
- package/lib-esm/clients/types/index.d.ts +1 -1
- package/lib-esm/constants.d.ts +7 -0
- package/lib-esm/constants.js +8 -0
- package/lib-esm/index.d.ts +18 -4
- package/lib-esm/index.js +15 -3
- package/lib-esm/parseAWSExports.d.ts +1 -1
- package/lib-esm/singleton/Auth/index.d.ts +30 -0
- package/lib-esm/singleton/Auth/index.js +129 -0
- package/lib-esm/singleton/Auth/types.d.ts +95 -0
- package/lib-esm/singleton/Auth/types.js +5 -0
- package/lib-esm/singleton/Auth/utils/index.d.ts +5 -0
- package/lib-esm/singleton/Auth/utils/index.js +45 -0
- package/lib-esm/singleton/Storage/types.d.ts +14 -0
- package/lib-esm/singleton/Storage/types.js +3 -0
- package/lib-esm/singleton/index.d.ts +46 -0
- package/lib-esm/singleton/index.js +156 -0
- package/lib-esm/singleton/types.d.ts +21 -0
- package/lib-esm/singleton/types.js +3 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/types.d.ts +31 -1
- package/lib-esm/types/types.js +2 -0
- package/package.json +38 -15
- package/src/Amplify.ts +9 -3
- package/src/AwsClients/CognitoIdentity/base.ts +2 -1
- package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +13 -6
- package/src/AwsClients/Pinpoint/base.ts +6 -2
- package/src/AwsClients/Pinpoint/getInAppMessages.ts +1 -1
- package/src/AwsClients/Pinpoint/putEvents.ts +6 -0
- package/src/AwsClients/Pinpoint/updateEndpoint.ts +2 -2
- package/src/Cache/AsyncStorageCache.ts +500 -0
- package/src/Cache/BrowserStorageCache.ts +517 -0
- package/src/Cache/CHANGELOG.md +1227 -0
- package/src/Cache/InMemoryCache.ts +354 -0
- package/src/Cache/StorageCache.ts +157 -0
- package/src/Cache/Utils/CacheList.ts +198 -0
- package/src/Cache/Utils/CacheUtils.ts +92 -0
- package/src/Cache/Utils/index.ts +11 -0
- package/src/Cache/reactnative.ts +9 -0
- package/src/Cache/types/Cache.ts +75 -0
- package/src/Cache/types/index.ts +4 -0
- package/src/ClientDevice/android.ts +1 -1
- package/src/ClientDevice/ios.ts +2 -2
- package/src/ClientDevice/reactnative.ts +1 -1
- package/src/Credentials.ts +19 -17
- package/src/Errors.ts +41 -0
- package/src/Hub.ts +1 -0
- package/src/I18n/I18n.ts +40 -12
- package/src/I18n/index.ts +45 -12
- package/src/I18n/types.ts +3 -0
- package/src/JS.ts +24 -17
- package/src/Logger/ConsoleLogger.ts +10 -10
- package/src/OAuthHelper/FacebookOAuth.ts +2 -2
- package/src/OAuthHelper/GoogleOAuth.ts +9 -6
- package/src/Platform/detectFramework.ts +1 -1
- package/src/Platform/detection/React.ts +5 -3
- package/src/Platform/version.ts +1 -1
- package/src/Providers/AWSCloudWatchProvider.ts +39 -14
- package/src/RNComponents/index.ts +1 -1
- package/src/RNComponents/reactnative.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +58 -18
- package/src/Signer.ts +22 -3
- package/src/StorageHelper/cookieStorage.ts +99 -0
- package/src/StorageHelper/inMemoryStorage.ts +32 -0
- package/src/StorageHelper/index.ts +6 -1
- package/src/StorageHelper/localStorage.ts +60 -0
- package/src/StorageHelper/reactnative.ts +94 -14
- package/src/StorageHelper/sessionStorage.ts +60 -0
- package/src/Util/BackgroundProcessManager.ts +33 -9
- package/src/Util/DateUtils.ts +14 -5
- package/src/Util/Reachability.native.ts +3 -2
- package/src/Util/Reachability.ts +9 -7
- package/src/Util/Retry.ts +2 -1
- package/src/Util/StringUtils.ts +3 -10
- package/src/Util/errors/AssertError.ts +11 -0
- package/src/clients/handlers/fetch.ts +2 -2
- package/src/clients/middleware/retry/defaultRetryDecider.ts +12 -6
- package/src/clients/middleware/retry/isClockSkewError.ts +1 -1
- package/src/clients/middleware/retry/middleware.ts +9 -9
- package/src/clients/middleware/signing/middleware.ts +1 -1
- package/src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts +1 -1
- package/src/clients/serde/responseInfo.ts +2 -1
- package/src/clients/types/aws.ts +10 -0
- package/src/clients/types/index.ts +1 -0
- package/src/constants.ts +16 -0
- package/src/global.d.ts +11 -0
- package/src/index.ts +66 -4
- package/src/parseAWSExports.ts +1 -1
- package/src/singleton/Auth/index.ts +113 -0
- package/src/singleton/Auth/types.ts +129 -0
- package/src/singleton/Auth/utils/index.ts +68 -0
- package/src/singleton/Storage/types.ts +21 -0
- package/src/singleton/index.ts +144 -0
- package/src/singleton/types.ts +48 -0
- package/src/types/types.ts +38 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { AuthClass } from './Auth';
|
|
4
|
+
import { Hub } from '../Hub';
|
|
5
|
+
import { LibraryOptions, ResourcesConfig } from './types';
|
|
6
|
+
import { AmplifyError } from '../Errors';
|
|
7
|
+
import { FetchAuthSessionOptions } from './Auth/types';
|
|
8
|
+
|
|
9
|
+
// TODO(v6): add default AuthTokenStore for each platform
|
|
10
|
+
|
|
11
|
+
class AmplifyClass {
|
|
12
|
+
resourcesConfig: ResourcesConfig;
|
|
13
|
+
libraryOptions: LibraryOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Cross-category Auth utilities.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
public readonly Auth: AuthClass;
|
|
20
|
+
constructor() {
|
|
21
|
+
this.resourcesConfig = {};
|
|
22
|
+
this.Auth = new AuthClass();
|
|
23
|
+
|
|
24
|
+
// TODO(v6): add default providers for getting started
|
|
25
|
+
this.libraryOptions = {
|
|
26
|
+
Auth: {
|
|
27
|
+
tokenProvider: {
|
|
28
|
+
getTokens: () => {
|
|
29
|
+
throw new AmplifyError({
|
|
30
|
+
message: 'No tokenProvider provided',
|
|
31
|
+
name: 'MissingTokenProvider',
|
|
32
|
+
recoverySuggestion:
|
|
33
|
+
'Make sure to call Amplify.configure in your app with a tokenProvider',
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Configures Amplify for use with your back-end resources.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* `configure` can be used to specify additional library options where available for supported categories.
|
|
46
|
+
*
|
|
47
|
+
* @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
|
|
48
|
+
* @param libraryOptions - Additional options for customizing the behavior of the library.
|
|
49
|
+
*/
|
|
50
|
+
configure(
|
|
51
|
+
resourcesConfig: ResourcesConfig,
|
|
52
|
+
libraryOptions: LibraryOptions = {}
|
|
53
|
+
): void {
|
|
54
|
+
this.resourcesConfig = mergeResourceConfig(
|
|
55
|
+
this.resourcesConfig,
|
|
56
|
+
resourcesConfig
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
this.libraryOptions = mergeLibraryOptions(
|
|
60
|
+
this.libraryOptions,
|
|
61
|
+
libraryOptions
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
this.Auth.configure(this.resourcesConfig.Auth!, this.libraryOptions.Auth);
|
|
65
|
+
|
|
66
|
+
Hub.dispatch(
|
|
67
|
+
'core',
|
|
68
|
+
{
|
|
69
|
+
event: 'configure',
|
|
70
|
+
data: resourcesConfig,
|
|
71
|
+
},
|
|
72
|
+
'Configure'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Provides access to the current back-end resource configuration for the Library.
|
|
78
|
+
*
|
|
79
|
+
* @returns Returns the current back-end resource configuration.
|
|
80
|
+
*/
|
|
81
|
+
getConfig(): ResourcesConfig {
|
|
82
|
+
return JSON.parse(JSON.stringify(this.resourcesConfig));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The `Amplify` utility is used to configure the library.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* `Amplify` is responsible for orchestrating cross-category communication within the library.
|
|
91
|
+
*/
|
|
92
|
+
export const AmplifyV6 = new AmplifyClass();
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns current session tokens and credentials
|
|
96
|
+
*
|
|
97
|
+
* @param options{FetchAuthSessionOptions} - Options for fetching session.
|
|
98
|
+
*
|
|
99
|
+
* @returns Returns a promise that will resolve with fresh authentication tokens.
|
|
100
|
+
*/
|
|
101
|
+
export const fetchAuthSession = (options: FetchAuthSessionOptions) => {
|
|
102
|
+
return AmplifyV6.Auth.fetchAuthSession(options);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// TODO(v6): validate until which level this will nested, during Amplify.configure API review.
|
|
106
|
+
function mergeResourceConfig(
|
|
107
|
+
existingConfig: ResourcesConfig,
|
|
108
|
+
newConfig: ResourcesConfig
|
|
109
|
+
): ResourcesConfig {
|
|
110
|
+
const resultConfig: Record<string, any> = {};
|
|
111
|
+
|
|
112
|
+
for (const category of Object.keys(existingConfig)) {
|
|
113
|
+
resultConfig[category] = existingConfig[category as keyof ResourcesConfig];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const category of Object.keys(newConfig)) {
|
|
117
|
+
resultConfig[category] = {
|
|
118
|
+
...resultConfig[category],
|
|
119
|
+
...newConfig[category as keyof ResourcesConfig],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return resultConfig;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function mergeLibraryOptions(
|
|
127
|
+
existingConfig: LibraryOptions,
|
|
128
|
+
newConfig: LibraryOptions
|
|
129
|
+
): LibraryOptions {
|
|
130
|
+
const resultConfig: Record<string, any> = {};
|
|
131
|
+
|
|
132
|
+
for (const category of Object.keys(existingConfig)) {
|
|
133
|
+
resultConfig[category] = existingConfig[category as keyof LibraryOptions];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
for (const category of Object.keys(newConfig)) {
|
|
137
|
+
resultConfig[category] = {
|
|
138
|
+
...resultConfig[category],
|
|
139
|
+
...newConfig[category as keyof LibraryOptions],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return resultConfig;
|
|
144
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AuthConfig,
|
|
6
|
+
LibraryAuthOptions,
|
|
7
|
+
UserPoolConfig,
|
|
8
|
+
IdentityPoolConfig,
|
|
9
|
+
UserPoolConfigAndIdentityPoolConfig,
|
|
10
|
+
GetCredentialsOptions,
|
|
11
|
+
} from './Auth/types';
|
|
12
|
+
import {
|
|
13
|
+
LibraryStorageOptions,
|
|
14
|
+
StorageAccessLevel,
|
|
15
|
+
StorageConfig,
|
|
16
|
+
} from './Storage/types';
|
|
17
|
+
import {
|
|
18
|
+
CacheConfig
|
|
19
|
+
} from '../Cache/types';
|
|
20
|
+
import { I18nOptions } from '../I18n/types';
|
|
21
|
+
|
|
22
|
+
export type ResourcesConfig = {
|
|
23
|
+
API?: {};
|
|
24
|
+
Analytics?: {};
|
|
25
|
+
Auth?: AuthConfig;
|
|
26
|
+
Cache?: CacheConfig;
|
|
27
|
+
DataStore?: {};
|
|
28
|
+
I18n?: I18nOptions;
|
|
29
|
+
Interactions?: {};
|
|
30
|
+
Notifications?: {};
|
|
31
|
+
Predictions?: {};
|
|
32
|
+
Storage?: StorageConfig;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type LibraryOptions = {
|
|
36
|
+
Auth?: LibraryAuthOptions;
|
|
37
|
+
Storage?: LibraryStorageOptions;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
AuthConfig,
|
|
42
|
+
UserPoolConfig,
|
|
43
|
+
IdentityPoolConfig,
|
|
44
|
+
UserPoolConfigAndIdentityPoolConfig,
|
|
45
|
+
GetCredentialsOptions,
|
|
46
|
+
StorageAccessLevel,
|
|
47
|
+
StorageConfig,
|
|
48
|
+
};
|
package/src/types/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
import { InputLogEvent, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
4
5
|
import { Credentials } from '@aws-sdk/types';
|
|
5
6
|
|
|
@@ -35,7 +36,7 @@ export interface ICredentials {
|
|
|
35
36
|
export type DelayFunction = (
|
|
36
37
|
attempt: number,
|
|
37
38
|
args?: any[],
|
|
38
|
-
error?:
|
|
39
|
+
error?: unknown
|
|
39
40
|
) => number | false;
|
|
40
41
|
|
|
41
42
|
export interface LoggingProvider {
|
|
@@ -65,3 +66,39 @@ export interface CloudWatchDataTracker {
|
|
|
65
66
|
logEvents: InputLogEvent[];
|
|
66
67
|
verifiedLogGroup?: LogGroup;
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
export type ErrorParams = {
|
|
71
|
+
message: string;
|
|
72
|
+
name: string;
|
|
73
|
+
recoverySuggestion?: string;
|
|
74
|
+
underlyingError?: Error | unknown;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type AmplifyErrorMap<ErrorCode extends string> = {
|
|
78
|
+
[name in ErrorCode]: {
|
|
79
|
+
message: string;
|
|
80
|
+
recoverySuggestion?: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ServiceError = {
|
|
85
|
+
name: string;
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export interface KeyValueStorageInterface {
|
|
90
|
+
setItem(key: string, value: string): Promise<void>;
|
|
91
|
+
getItem(key: string): Promise<string | null>;
|
|
92
|
+
removeItem(key: string): Promise<void>;
|
|
93
|
+
clear(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type SameSite = 'strict' | 'lax' | 'none';
|
|
97
|
+
|
|
98
|
+
export type CookieStorageData = {
|
|
99
|
+
domain?: string;
|
|
100
|
+
path?: string;
|
|
101
|
+
expires?: number;
|
|
102
|
+
secure?: boolean;
|
|
103
|
+
sameSite?: SameSite;
|
|
104
|
+
};
|