@aws-amplify/core 6.0.1-console-preview.f63250a.0 → 6.0.1-console-preview.5dc0b68.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/internals/adapter-core/package.json +8 -0
- package/internals/providers/pinpoint/package.json +8 -0
- package/internals/utils/package.json +7 -0
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/index.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.js +2 -2
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib/Cache/AsyncStorageCache.js +3 -3
- package/lib/Cache/BrowserStorageCache.js +5 -5
- package/lib/Cache/InMemoryCache.js +3 -3
- package/lib/Cache/StorageCache.js +1 -1
- package/lib/Cache/Utils/CacheList.js +5 -5
- package/lib/Credentials.js +2 -5
- package/lib/{Hub.d.ts → Hub/index.d.ts} +5 -21
- package/lib/Hub/index.js +151 -0
- package/lib/Hub/types/AuthTypes.d.ts +11 -0
- package/lib/Hub/types/HubTypes.d.ts +28 -0
- package/lib/Hub/types/HubTypes.js +4 -0
- package/lib/Hub/types/index.d.ts +2 -0
- package/lib/Hub/types/index.js +20 -0
- package/lib/I18n/I18n.js +1 -1
- package/lib/I18n/index.js +5 -5
- package/lib/OAuthHelper/FacebookOAuth.js +1 -1
- package/lib/OAuthHelper/GoogleOAuth.js +1 -1
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/RNComponents/index.d.ts +1 -0
- package/lib/RNComponents/index.js +2 -1
- package/lib/RNComponents/isAppInForeground.d.ts +1 -0
- package/lib/RNComponents/isAppInForeground.js +10 -0
- package/lib/ServiceWorker/ServiceWorker.js +9 -9
- package/lib/StorageHelper/localStorage.js +1 -1
- package/lib/StorageHelper/sessionStorage.js +1 -1
- package/lib/UniversalStorage/index.js +1 -1
- package/lib/Util/Constants.d.ts +12 -8
- package/lib/Util/Constants.js +21 -15
- package/lib/{Errors.d.ts → Util/Errors.d.ts} +1 -1
- package/lib/Util/Reachability.js +1 -1
- package/lib/Util/errors/AssertError.js +1 -1
- package/lib/Util/index.d.ts +1 -1
- package/lib/Util/index.js +1 -5
- package/lib/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
- package/lib/adapterCore/error/AmplifyServerContextError.js +35 -0
- package/lib/adapterCore/error/index.d.ts +1 -0
- package/lib/adapterCore/error/index.js +7 -0
- package/lib/adapterCore/index.d.ts +2 -0
- package/lib/adapterCore/index.js +11 -0
- package/lib/adapterCore/serverContext/index.d.ts +2 -0
- package/lib/adapterCore/serverContext/index.js +9 -0
- package/lib/adapterCore/serverContext/serverContext.d.ts +20 -0
- package/lib/adapterCore/serverContext/serverContext.js +42 -0
- package/lib/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
- package/lib/adapterCore/serverContext/serverContextRegistry.js +24 -0
- package/lib/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
- package/lib/adapterCore/serverContext/types/amplifyServer.js +4 -0
- package/lib/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
- package/lib/adapterCore/serverContext/types/cookieStorage.js +4 -0
- package/lib/adapterCore/serverContext/types/index.d.ts +4 -0
- package/lib/adapterCore/serverContext/types/index.js +4 -0
- package/lib/clients/handlers/fetch.js +1 -0
- package/lib/clients/internal/composeServiceApi.d.ts +5 -2
- package/lib/index.d.ts +11 -32
- package/lib/index.js +19 -100
- package/lib/libraryUtils.d.ts +21 -0
- package/lib/libraryUtils.js +105 -0
- package/lib/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/providers/pinpoint/apis/index.js +9 -0
- package/lib/providers/pinpoint/apis/record.d.ts +5 -0
- package/lib/providers/pinpoint/apis/record.js +120 -0
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
- package/lib/providers/pinpoint/apis/updateEndpoint.js +120 -0
- package/lib/providers/pinpoint/index.d.ts +2 -0
- package/lib/providers/pinpoint/index.js +19 -0
- package/lib/providers/pinpoint/types/buffer.d.ts +25 -0
- package/lib/providers/pinpoint/types/buffer.js +4 -0
- package/lib/providers/pinpoint/types/index.d.ts +1 -0
- package/lib/providers/pinpoint/types/index.js +19 -0
- package/lib/providers/pinpoint/types/pinpoint.d.ts +40 -0
- package/lib/providers/pinpoint/types/pinpoint.js +4 -0
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
- package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +278 -0
- package/lib/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
- package/lib/providers/pinpoint/utils/cacheEndpointId.js +61 -0
- package/lib/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib/providers/pinpoint/utils/constants.js +10 -0
- package/lib/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
- package/lib/providers/pinpoint/utils/getCacheKey.js +13 -0
- package/lib/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
- package/lib/providers/pinpoint/utils/getEndpointId.js +62 -0
- package/lib/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
- package/lib/providers/pinpoint/utils/getEventBuffer.js +48 -0
- package/lib/providers/pinpoint/utils/index.d.ts +3 -0
- package/lib/providers/pinpoint/utils/index.js +11 -0
- package/lib/server.d.ts +1 -0
- package/lib/server.js +7 -0
- package/lib/singleton/Amplify.d.ts +36 -0
- package/lib/singleton/Amplify.js +138 -0
- package/lib/singleton/Analytics/types.d.ts +2 -0
- package/lib/singleton/Analytics/types.js +4 -0
- package/lib/singleton/Auth/index.js +15 -12
- package/lib/singleton/Auth/types.d.ts +28 -3
- package/lib/singleton/Auth/utils/index.d.ts +3 -2
- package/lib/singleton/Auth/utils/index.js +15 -1
- package/lib/singleton/Storage/types.d.ts +6 -2
- package/lib/singleton/apis/fetchAuthSession.d.ts +2 -0
- package/lib/singleton/apis/fetchAuthSession.js +11 -0
- package/lib/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
- package/lib/singleton/apis/internal/fetchAuthSession.js +9 -0
- package/lib/singleton/apis/server/fetchAuthSession.d.ts +3 -0
- package/lib/singleton/apis/server/fetchAuthSession.js +11 -0
- package/lib/singleton/index.d.ts +2 -46
- package/lib/singleton/index.js +7 -144
- package/lib/singleton/types.d.ts +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core.d.ts +47 -0
- package/lib/types/core.js +4 -0
- package/lib/types/errors.d.ts +16 -0
- package/lib/types/errors.js +4 -0
- package/lib/types/index.d.ts +4 -1
- package/lib/types/index.js +6 -3
- package/lib/types/logging.d.ts +13 -0
- package/lib/types/logging.js +4 -0
- package/lib/types/storage.d.ts +14 -0
- package/lib/types/storage.js +4 -0
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/index.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.js +1 -1
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib-esm/Cache/AsyncStorageCache.js +1 -1
- package/lib-esm/Cache/BrowserStorageCache.js +1 -1
- package/lib-esm/Cache/InMemoryCache.js +1 -1
- package/lib-esm/Cache/StorageCache.js +2 -2
- package/lib-esm/Cache/Utils/CacheList.js +1 -1
- package/lib-esm/Credentials.js +2 -5
- package/lib-esm/{Hub.d.ts → Hub/index.d.ts} +5 -21
- package/lib-esm/Hub/index.js +148 -0
- package/lib-esm/Hub/types/AuthTypes.d.ts +11 -0
- package/lib-esm/Hub/types/HubTypes.d.ts +28 -0
- package/lib-esm/Hub/types/HubTypes.js +3 -0
- package/lib-esm/Hub/types/index.d.ts +2 -0
- package/lib-esm/Hub/types/index.js +4 -0
- package/lib-esm/I18n/I18n.js +2 -2
- package/lib-esm/I18n/index.js +1 -1
- package/lib-esm/OAuthHelper/FacebookOAuth.js +1 -1
- package/lib-esm/OAuthHelper/GoogleOAuth.js +1 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/RNComponents/index.d.ts +1 -0
- package/lib-esm/RNComponents/index.js +2 -1
- package/lib-esm/RNComponents/isAppInForeground.d.ts +1 -0
- package/lib-esm/RNComponents/isAppInForeground.js +6 -0
- package/lib-esm/ServiceWorker/ServiceWorker.js +3 -3
- package/lib-esm/StorageHelper/localStorage.js +1 -1
- package/lib-esm/StorageHelper/sessionStorage.js +1 -1
- package/lib-esm/UniversalStorage/index.js +1 -1
- package/lib-esm/Util/Constants.d.ts +12 -8
- package/lib-esm/Util/Constants.js +20 -8
- package/lib-esm/{Errors.d.ts → Util/Errors.d.ts} +1 -1
- package/lib-esm/Util/Reachability.js +1 -1
- package/lib-esm/Util/errors/AssertError.js +1 -1
- package/lib-esm/Util/index.d.ts +1 -1
- package/lib-esm/Util/index.js +1 -1
- package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
- package/lib-esm/adapterCore/error/AmplifyServerContextError.js +32 -0
- package/lib-esm/adapterCore/error/index.d.ts +1 -0
- package/lib-esm/adapterCore/error/index.js +3 -0
- package/lib-esm/adapterCore/index.d.ts +2 -0
- package/lib-esm/adapterCore/index.js +4 -0
- package/lib-esm/adapterCore/serverContext/index.d.ts +2 -0
- package/lib-esm/adapterCore/serverContext/index.js +3 -0
- package/lib-esm/adapterCore/serverContext/serverContext.d.ts +20 -0
- package/lib-esm/adapterCore/serverContext/serverContext.js +36 -0
- package/lib-esm/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
- package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +21 -0
- package/lib-esm/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
- package/lib-esm/adapterCore/serverContext/types/amplifyServer.js +3 -0
- package/lib-esm/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
- package/lib-esm/adapterCore/serverContext/types/cookieStorage.js +3 -0
- package/lib-esm/adapterCore/serverContext/types/index.d.ts +4 -0
- package/lib-esm/adapterCore/serverContext/types/index.js +3 -0
- package/lib-esm/clients/handlers/fetch.js +1 -0
- package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -2
- package/lib-esm/index.d.ts +11 -32
- package/lib-esm/index.js +11 -29
- package/lib-esm/libraryUtils.d.ts +21 -0
- package/lib-esm/libraryUtils.js +33 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib-esm/providers/pinpoint/apis/index.js +4 -0
- package/lib-esm/providers/pinpoint/apis/record.d.ts +5 -0
- package/lib-esm/providers/pinpoint/apis/record.js +116 -0
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +116 -0
- package/lib-esm/providers/pinpoint/index.d.ts +2 -0
- package/lib-esm/providers/pinpoint/index.js +3 -0
- package/lib-esm/providers/pinpoint/types/buffer.d.ts +25 -0
- package/lib-esm/providers/pinpoint/types/buffer.js +3 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/types/index.js +3 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +40 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.js +3 -0
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
- package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +275 -0
- package/lib-esm/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +57 -0
- package/lib-esm/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib-esm/providers/pinpoint/utils/constants.js +7 -0
- package/lib-esm/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/getCacheKey.js +9 -0
- package/lib-esm/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/getEndpointId.js +58 -0
- package/lib-esm/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +44 -0
- package/lib-esm/providers/pinpoint/utils/index.d.ts +3 -0
- package/lib-esm/providers/pinpoint/utils/index.js +5 -0
- package/lib-esm/server.d.ts +1 -0
- package/lib-esm/server.js +3 -0
- package/lib-esm/singleton/Amplify.d.ts +36 -0
- package/lib-esm/singleton/Amplify.js +135 -0
- package/lib-esm/singleton/Analytics/types.d.ts +2 -0
- package/lib-esm/singleton/Analytics/types.js +3 -0
- package/lib-esm/singleton/Auth/index.js +14 -11
- package/lib-esm/singleton/Auth/types.d.ts +28 -3
- package/lib-esm/singleton/Auth/utils/index.d.ts +3 -2
- package/lib-esm/singleton/Auth/utils/index.js +13 -0
- package/lib-esm/singleton/Storage/types.d.ts +6 -2
- package/lib-esm/singleton/apis/fetchAuthSession.d.ts +2 -0
- package/lib-esm/singleton/apis/fetchAuthSession.js +7 -0
- package/lib-esm/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
- package/lib-esm/singleton/apis/internal/fetchAuthSession.js +5 -0
- package/lib-esm/singleton/apis/server/fetchAuthSession.d.ts +3 -0
- package/lib-esm/singleton/apis/server/fetchAuthSession.js +7 -0
- package/lib-esm/singleton/index.d.ts +2 -46
- package/lib-esm/singleton/index.js +2 -141
- package/lib-esm/singleton/types.d.ts +3 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/core.d.ts +47 -0
- package/lib-esm/types/core.js +3 -0
- package/lib-esm/types/errors.d.ts +16 -0
- package/lib-esm/types/errors.js +3 -0
- package/lib-esm/types/index.d.ts +4 -1
- package/lib-esm/types/index.js +4 -1
- package/lib-esm/types/logging.d.ts +13 -0
- package/lib-esm/types/logging.js +3 -0
- package/lib-esm/types/storage.d.ts +14 -0
- package/lib-esm/types/storage.js +3 -0
- package/package.json +15 -12
- package/server/package.json +8 -0
- package/src/AwsClients/Pinpoint/index.ts +1 -1
- package/src/AwsClients/Pinpoint/putEvents.ts +1 -1
- package/src/Cache/AsyncStorageCache.ts +1 -1
- package/src/Cache/BrowserStorageCache.ts +1 -1
- package/src/Cache/InMemoryCache.ts +1 -1
- package/src/Cache/StorageCache.ts +2 -2
- package/src/Cache/Utils/CacheList.ts +1 -1
- package/src/Credentials.ts +2 -8
- package/src/Hub/index.ts +204 -0
- package/src/Hub/types/AuthTypes.ts +10 -0
- package/src/Hub/types/HubTypes.ts +46 -0
- package/src/{Providers → Hub/types}/index.ts +3 -1
- package/src/I18n/I18n.ts +2 -2
- package/src/I18n/index.ts +1 -1
- package/src/Logger/ConsoleLogger.ts +1 -2
- package/src/OAuthHelper/FacebookOAuth.ts +1 -1
- package/src/OAuthHelper/GoogleOAuth.ts +1 -1
- package/src/Platform/version.ts +1 -1
- package/src/RNComponents/index.ts +2 -1
- package/src/RNComponents/isAppInForeground.ts +8 -0
- package/src/ServiceWorker/ServiceWorker.ts +3 -3
- package/src/StorageHelper/localStorage.ts +1 -1
- package/src/StorageHelper/sessionStorage.ts +1 -1
- package/src/UniversalStorage/index.ts +1 -1
- package/src/Util/Constants.ts +25 -16
- package/src/{Errors.ts → Util/Errors.ts} +1 -1
- package/src/Util/Reachability.ts +1 -1
- package/src/Util/errors/AssertError.ts +1 -1
- package/src/Util/index.ts +0 -4
- package/src/adapterCore/error/AmplifyServerContextError.ts +23 -0
- package/src/adapterCore/error/index.ts +4 -0
- package/src/adapterCore/index.ts +11 -0
- package/src/adapterCore/serverContext/index.ts +10 -0
- package/src/adapterCore/serverContext/serverContext.ts +54 -0
- package/src/adapterCore/serverContext/serverContextRegistry.ts +31 -0
- package/src/adapterCore/serverContext/types/amplifyServer.ts +29 -0
- package/src/adapterCore/serverContext/types/cookieStorage.ts +43 -0
- package/src/adapterCore/serverContext/types/index.ts +9 -0
- package/src/clients/handlers/fetch.ts +1 -0
- package/src/clients/internal/composeServiceApi.ts +13 -4
- package/src/index.ts +40 -120
- package/src/libraryUtils.ts +102 -0
- package/src/providers/pinpoint/apis/index.ts +5 -0
- package/src/providers/pinpoint/apis/record.ts +90 -0
- package/src/providers/pinpoint/apis/updateEndpoint.ts +82 -0
- package/src/providers/pinpoint/index.ts +5 -0
- package/src/providers/pinpoint/types/buffer.ts +32 -0
- package/{lib-esm/Providers/index.js → src/providers/pinpoint/types/index.ts} +2 -1
- package/src/providers/pinpoint/types/pinpoint.ts +55 -0
- package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +248 -0
- package/src/providers/pinpoint/utils/cacheEndpointId.ts +27 -0
- package/src/providers/pinpoint/utils/constants.ts +8 -0
- package/src/providers/pinpoint/utils/getCacheKey.ts +16 -0
- package/src/providers/pinpoint/utils/getEndpointId.ts +20 -0
- package/src/providers/pinpoint/utils/getEventBuffer.ts +60 -0
- package/src/providers/pinpoint/utils/index.ts +6 -0
- package/src/server.ts +4 -0
- package/src/singleton/Amplify.ts +121 -0
- package/src/singleton/Analytics/types.ts +6 -0
- package/src/singleton/Auth/index.ts +7 -5
- package/src/singleton/Auth/types.ts +38 -6
- package/src/singleton/Auth/utils/index.ts +27 -1
- package/src/singleton/Storage/types.ts +6 -3
- package/src/singleton/apis/fetchAuthSession.ts +12 -0
- package/src/singleton/apis/internal/fetchAuthSession.ts +12 -0
- package/src/singleton/apis/server/fetchAuthSession.ts +16 -0
- package/src/singleton/index.ts +2 -128
- package/src/singleton/types.ts +4 -4
- package/src/types/core.ts +58 -0
- package/src/types/errors.ts +21 -0
- package/src/types/index.ts +5 -1
- package/src/types/logging.ts +24 -0
- package/src/types/storage.ts +19 -0
- package/lib/Hub.js +0 -220
- package/lib/Providers/AWSCloudWatchProvider.d.ts +0 -34
- package/lib/Providers/AWSCloudWatchProvider.js +0 -619
- package/lib/Providers/index.d.ts +0 -1
- package/lib/Providers/index.js +0 -7
- package/lib/constants.d.ts +0 -9
- package/lib/constants.js +0 -22
- package/lib/types/types.d.ts +0 -76
- package/lib-esm/Hub.js +0 -217
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +0 -34
- package/lib-esm/Providers/AWSCloudWatchProvider.js +0 -616
- package/lib-esm/Providers/index.d.ts +0 -1
- package/lib-esm/constants.d.ts +0 -9
- package/lib-esm/constants.js +0 -19
- package/lib-esm/types/types.d.ts +0 -76
- package/src/Hub.ts +0 -236
- package/src/Providers/AWSCloudWatchProvider.ts +0 -540
- package/src/constants.ts +0 -31
- package/src/types/types.ts +0 -104
- /package/lib/{types/types.js → Hub/types/AuthTypes.js} +0 -0
- /package/lib/{Errors.js → Util/Errors.js} +0 -0
- /package/lib/{JS.d.ts → Util/JS.d.ts} +0 -0
- /package/lib/{JS.js → Util/JS.js} +0 -0
- /package/lib-esm/{types/types.js → Hub/types/AuthTypes.js} +0 -0
- /package/lib-esm/{Errors.js → Util/Errors.js} +0 -0
- /package/lib-esm/{JS.d.ts → Util/JS.d.ts} +0 -0
- /package/lib-esm/{JS.js → Util/JS.js} +0 -0
- /package/src/{JS.ts → Util/JS.ts} +0 -0
|
@@ -1,540 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
CloudWatchLogsClient,
|
|
6
|
-
CreateLogGroupCommand,
|
|
7
|
-
CreateLogGroupCommandInput,
|
|
8
|
-
CreateLogGroupCommandOutput,
|
|
9
|
-
CreateLogStreamCommand,
|
|
10
|
-
CreateLogStreamCommandInput,
|
|
11
|
-
CreateLogStreamCommandOutput,
|
|
12
|
-
DescribeLogGroupsCommand,
|
|
13
|
-
DescribeLogGroupsCommandInput,
|
|
14
|
-
DescribeLogGroupsCommandOutput,
|
|
15
|
-
DescribeLogStreamsCommand,
|
|
16
|
-
DescribeLogStreamsCommandInput,
|
|
17
|
-
DescribeLogStreamsCommandOutput,
|
|
18
|
-
GetLogEventsCommand,
|
|
19
|
-
GetLogEventsCommandInput,
|
|
20
|
-
GetLogEventsCommandOutput,
|
|
21
|
-
InputLogEvent,
|
|
22
|
-
LogGroup,
|
|
23
|
-
LogStream,
|
|
24
|
-
PutLogEventsCommand,
|
|
25
|
-
PutLogEventsCommandInput,
|
|
26
|
-
PutLogEventsCommandOutput,
|
|
27
|
-
} from '@aws-sdk/client-cloudwatch-logs';
|
|
28
|
-
import {
|
|
29
|
-
AWSCloudWatchProviderOptions,
|
|
30
|
-
CloudWatchDataTracker,
|
|
31
|
-
LoggingProvider,
|
|
32
|
-
} from '../types/types';
|
|
33
|
-
import { Credentials } from '../Credentials';
|
|
34
|
-
import { ConsoleLogger as Logger } from '../Logger';
|
|
35
|
-
import { getAmplifyUserAgentObject } from '../Platform';
|
|
36
|
-
import { parseAWSExports } from '../parseAWSExports';
|
|
37
|
-
import {
|
|
38
|
-
AWS_CLOUDWATCH_BASE_BUFFER_SIZE,
|
|
39
|
-
AWS_CLOUDWATCH_CATEGORY,
|
|
40
|
-
AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE,
|
|
41
|
-
AWS_CLOUDWATCH_MAX_EVENT_SIZE,
|
|
42
|
-
AWS_CLOUDWATCH_PROVIDER_NAME,
|
|
43
|
-
NO_CREDS_ERROR_STRING,
|
|
44
|
-
RETRY_ERROR_CODES,
|
|
45
|
-
} from '../Util/Constants';
|
|
46
|
-
import { asserts } from '../Util/errors/AssertError';
|
|
47
|
-
import { AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION } from '../constants';
|
|
48
|
-
|
|
49
|
-
const logger = new Logger('AWSCloudWatch');
|
|
50
|
-
|
|
51
|
-
class AWSCloudWatchProvider implements LoggingProvider {
|
|
52
|
-
static readonly PROVIDER_NAME = AWS_CLOUDWATCH_PROVIDER_NAME;
|
|
53
|
-
static readonly CATEGORY = AWS_CLOUDWATCH_CATEGORY;
|
|
54
|
-
|
|
55
|
-
private _config?: AWSCloudWatchProviderOptions;
|
|
56
|
-
private _dataTracker: CloudWatchDataTracker;
|
|
57
|
-
private _currentLogBatch: InputLogEvent[];
|
|
58
|
-
private _timer?: NodeJS.Timer;
|
|
59
|
-
private _nextSequenceToken: string | undefined;
|
|
60
|
-
|
|
61
|
-
constructor(config?: AWSCloudWatchProviderOptions) {
|
|
62
|
-
this.configure(config);
|
|
63
|
-
this._dataTracker = {
|
|
64
|
-
eventUploadInProgress: false,
|
|
65
|
-
logEvents: [],
|
|
66
|
-
};
|
|
67
|
-
this._currentLogBatch = [];
|
|
68
|
-
this._initiateLogPushInterval();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public getProviderName(): string {
|
|
72
|
-
return AWSCloudWatchProvider.PROVIDER_NAME;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public getCategoryName(): string {
|
|
76
|
-
return AWSCloudWatchProvider.CATEGORY;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public getLogQueue(): InputLogEvent[] {
|
|
80
|
-
return this._dataTracker.logEvents;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public configure(
|
|
84
|
-
config?: AWSCloudWatchProviderOptions
|
|
85
|
-
): AWSCloudWatchProviderOptions {
|
|
86
|
-
if (!config) return this._config || {};
|
|
87
|
-
|
|
88
|
-
const conf = Object.assign(
|
|
89
|
-
{},
|
|
90
|
-
this._config,
|
|
91
|
-
parseAWSExports(config).Logging,
|
|
92
|
-
config
|
|
93
|
-
);
|
|
94
|
-
this._config = conf;
|
|
95
|
-
|
|
96
|
-
return this._config;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public async createLogGroup(
|
|
100
|
-
params: CreateLogGroupCommandInput
|
|
101
|
-
): Promise<CreateLogGroupCommandOutput> {
|
|
102
|
-
logger.debug(
|
|
103
|
-
'creating new log group in CloudWatch - ',
|
|
104
|
-
params.logGroupName
|
|
105
|
-
);
|
|
106
|
-
const cmd = new CreateLogGroupCommand(params);
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
const credentialsOK = await this._ensureCredentials();
|
|
110
|
-
if (!credentialsOK) {
|
|
111
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const client = this._initCloudWatchLogs();
|
|
115
|
-
const output = await client.send(cmd);
|
|
116
|
-
return output;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
logger.error(`error creating log group - ${error}`);
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public async getLogGroups(
|
|
124
|
-
params: DescribeLogGroupsCommandInput
|
|
125
|
-
): Promise<DescribeLogGroupsCommandOutput> {
|
|
126
|
-
logger.debug('getting list of log groups');
|
|
127
|
-
|
|
128
|
-
const cmd = new DescribeLogGroupsCommand(params);
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
const credentialsOK = await this._ensureCredentials();
|
|
132
|
-
if (!credentialsOK) {
|
|
133
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const client = this._initCloudWatchLogs();
|
|
137
|
-
const output = await client.send(cmd);
|
|
138
|
-
return output;
|
|
139
|
-
} catch (error) {
|
|
140
|
-
logger.error(`error getting log group - ${error}`);
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public async createLogStream(
|
|
146
|
-
params: CreateLogStreamCommandInput
|
|
147
|
-
): Promise<CreateLogStreamCommandOutput> {
|
|
148
|
-
logger.debug(
|
|
149
|
-
'creating new log stream in CloudWatch - ',
|
|
150
|
-
params.logStreamName
|
|
151
|
-
);
|
|
152
|
-
const cmd = new CreateLogStreamCommand(params);
|
|
153
|
-
|
|
154
|
-
try {
|
|
155
|
-
const credentialsOK = await this._ensureCredentials();
|
|
156
|
-
if (!credentialsOK) {
|
|
157
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const client = this._initCloudWatchLogs();
|
|
161
|
-
const output = await client.send(cmd);
|
|
162
|
-
return output;
|
|
163
|
-
} catch (error) {
|
|
164
|
-
logger.error(`error creating log stream - ${error}`);
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
public async getLogStreams(
|
|
170
|
-
params: DescribeLogStreamsCommandInput
|
|
171
|
-
): Promise<DescribeLogStreamsCommandOutput> {
|
|
172
|
-
logger.debug('getting list of log streams');
|
|
173
|
-
const cmd = new DescribeLogStreamsCommand(params);
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
const credentialsOK = await this._ensureCredentials();
|
|
177
|
-
if (!credentialsOK) {
|
|
178
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const client = this._initCloudWatchLogs();
|
|
182
|
-
const output = await client.send(cmd);
|
|
183
|
-
return output;
|
|
184
|
-
} catch (error) {
|
|
185
|
-
logger.error(`error getting log stream - ${error}`);
|
|
186
|
-
throw error;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public async getLogEvents(
|
|
191
|
-
params: GetLogEventsCommandInput
|
|
192
|
-
): Promise<GetLogEventsCommandOutput> {
|
|
193
|
-
logger.debug('getting log events from stream - ', params.logStreamName);
|
|
194
|
-
const cmd = new GetLogEventsCommand(params);
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
const credentialsOK = await this._ensureCredentials();
|
|
198
|
-
if (!credentialsOK) {
|
|
199
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const client = this._initCloudWatchLogs();
|
|
203
|
-
const output = await client.send(cmd);
|
|
204
|
-
return output;
|
|
205
|
-
} catch (error) {
|
|
206
|
-
logger.error(`error getting log events - ${error}`);
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public pushLogs(logs: InputLogEvent[]): void {
|
|
212
|
-
logger.debug('pushing log events to Cloudwatch...');
|
|
213
|
-
this._dataTracker.logEvents = [...this._dataTracker.logEvents, ...logs];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private async _validateLogGroupExistsAndCreate(
|
|
217
|
-
logGroupName: string
|
|
218
|
-
): Promise<LogGroup | null> {
|
|
219
|
-
if (this._dataTracker.verifiedLogGroup) {
|
|
220
|
-
return this._dataTracker.verifiedLogGroup;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const credentialsOK = await this._ensureCredentials();
|
|
225
|
-
if (!credentialsOK) {
|
|
226
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const currGroups = await this.getLogGroups({
|
|
230
|
-
logGroupNamePrefix: logGroupName,
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
if (!(typeof currGroups === 'string') && currGroups.logGroups) {
|
|
234
|
-
const foundGroups = currGroups.logGroups.filter(
|
|
235
|
-
group => group.logGroupName === logGroupName
|
|
236
|
-
);
|
|
237
|
-
if (foundGroups.length > 0) {
|
|
238
|
-
this._dataTracker.verifiedLogGroup = foundGroups[0];
|
|
239
|
-
|
|
240
|
-
return foundGroups[0];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* If we get to this point, it means that the specified log group does not exist
|
|
246
|
-
* and we should create it.
|
|
247
|
-
*/
|
|
248
|
-
await this.createLogGroup({ logGroupName });
|
|
249
|
-
|
|
250
|
-
return null;
|
|
251
|
-
} catch (err) {
|
|
252
|
-
const errString = `failure during log group search: ${err}`;
|
|
253
|
-
logger.error(errString);
|
|
254
|
-
throw err;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
private async _validateLogStreamExists(
|
|
259
|
-
logGroupName: string,
|
|
260
|
-
logStreamName: string
|
|
261
|
-
): Promise<LogStream | null> {
|
|
262
|
-
try {
|
|
263
|
-
const credentialsOK = await this._ensureCredentials();
|
|
264
|
-
if (!credentialsOK) {
|
|
265
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const currStreams = await this.getLogStreams({
|
|
269
|
-
logGroupName,
|
|
270
|
-
logStreamNamePrefix: logStreamName,
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
if (currStreams.logStreams) {
|
|
274
|
-
const foundStreams = currStreams.logStreams.filter(
|
|
275
|
-
stream => stream.logStreamName === logStreamName
|
|
276
|
-
);
|
|
277
|
-
if (foundStreams.length > 0) {
|
|
278
|
-
this._nextSequenceToken = foundStreams[0].uploadSequenceToken;
|
|
279
|
-
|
|
280
|
-
return foundStreams[0];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* If we get to this point, it means that the specified stream does not
|
|
286
|
-
* exist, and we should create it now.
|
|
287
|
-
*/
|
|
288
|
-
await this.createLogStream({
|
|
289
|
-
logGroupName,
|
|
290
|
-
logStreamName,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
return null;
|
|
294
|
-
} catch (err) {
|
|
295
|
-
const errString = `failure during log stream search: ${err}`;
|
|
296
|
-
logger.error(errString);
|
|
297
|
-
throw err;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
private async _sendLogEvents(
|
|
302
|
-
params: PutLogEventsCommandInput
|
|
303
|
-
): Promise<PutLogEventsCommandOutput | undefined> {
|
|
304
|
-
try {
|
|
305
|
-
const credentialsOK = await this._ensureCredentials();
|
|
306
|
-
if (!credentialsOK) {
|
|
307
|
-
throw new Error(NO_CREDS_ERROR_STRING);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
logger.debug('sending log events to stream - ', params.logStreamName);
|
|
311
|
-
const cmd = new PutLogEventsCommand(params);
|
|
312
|
-
const client = this._initCloudWatchLogs();
|
|
313
|
-
const output = await client.send(cmd);
|
|
314
|
-
|
|
315
|
-
return output;
|
|
316
|
-
} catch (err) {
|
|
317
|
-
const errString = `failure during log push: ${err}`;
|
|
318
|
-
logger.error(errString);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private _initCloudWatchLogs() {
|
|
323
|
-
assertsAWSClouldWatchOptions(this._config);
|
|
324
|
-
return new CloudWatchLogsClient({
|
|
325
|
-
region: this._config.region,
|
|
326
|
-
credentials: this._config.credentials,
|
|
327
|
-
customUserAgent: getAmplifyUserAgentObject(),
|
|
328
|
-
endpoint: this._config.endpoint,
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
private async _ensureCredentials() {
|
|
333
|
-
return await Credentials.get()
|
|
334
|
-
.then((credentials: any) => {
|
|
335
|
-
assertsAWSClouldWatchOptions(this._config);
|
|
336
|
-
if (!credentials) return false;
|
|
337
|
-
const cred = Credentials.shear(credentials);
|
|
338
|
-
logger.debug('set credentials for logging', cred);
|
|
339
|
-
this._config.credentials = cred;
|
|
340
|
-
|
|
341
|
-
return true;
|
|
342
|
-
})
|
|
343
|
-
.catch((error: unknown) => {
|
|
344
|
-
logger.warn('ensure credentials error', error);
|
|
345
|
-
return false;
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private async _getNextSequenceToken(): Promise<string | undefined> {
|
|
350
|
-
assertsAWSClouldWatchOptions(this._config);
|
|
351
|
-
if (this._nextSequenceToken && this._nextSequenceToken.length > 0) {
|
|
352
|
-
return this._nextSequenceToken;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* A sequence token will not exist if any of the following are true:
|
|
357
|
-
* ...the log group does not exist
|
|
358
|
-
* ...the log stream does not exist
|
|
359
|
-
* ...the log stream does exist but has no logs written to it yet
|
|
360
|
-
*/
|
|
361
|
-
try {
|
|
362
|
-
asserts(this._config.logGroupName !== undefined, {
|
|
363
|
-
name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
364
|
-
message: ' log group name is undefined',
|
|
365
|
-
});
|
|
366
|
-
asserts(this._config.logStreamName !== undefined, {
|
|
367
|
-
name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
368
|
-
message: ' log stream name is undefined',
|
|
369
|
-
});
|
|
370
|
-
await this._validateLogGroupExistsAndCreate(this._config.logGroupName);
|
|
371
|
-
|
|
372
|
-
this._nextSequenceToken = undefined;
|
|
373
|
-
|
|
374
|
-
const logStream = await this._validateLogStreamExists(
|
|
375
|
-
this._config.logGroupName,
|
|
376
|
-
this._config.logStreamName
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
if (logStream) {
|
|
380
|
-
this._nextSequenceToken = logStream.uploadSequenceToken;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return this._nextSequenceToken;
|
|
384
|
-
} catch (err) {
|
|
385
|
-
logger.error(`failure while getting next sequence token: ${err}`);
|
|
386
|
-
throw err;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
private async _safeUploadLogEvents(): Promise<
|
|
391
|
-
PutLogEventsCommandOutput | undefined
|
|
392
|
-
> {
|
|
393
|
-
assertsAWSClouldWatchOptions(this._config);
|
|
394
|
-
try {
|
|
395
|
-
/**
|
|
396
|
-
* CloudWatch has restrictions on the size of the log events that get sent up.
|
|
397
|
-
* We need to track both the size of each event and the total size of the batch
|
|
398
|
-
* of logs.
|
|
399
|
-
*
|
|
400
|
-
* We also need to ensure that the logs in the batch are sorted in chronological order.
|
|
401
|
-
* https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
|
|
402
|
-
*/
|
|
403
|
-
const seqToken = await this._getNextSequenceToken();
|
|
404
|
-
const logBatch =
|
|
405
|
-
this._currentLogBatch.length === 0
|
|
406
|
-
? this._getBufferedBatchOfLogs()
|
|
407
|
-
: this._currentLogBatch;
|
|
408
|
-
|
|
409
|
-
const putLogsPayload: PutLogEventsCommandInput = {
|
|
410
|
-
logGroupName: this._config.logGroupName,
|
|
411
|
-
logStreamName: this._config.logStreamName,
|
|
412
|
-
logEvents: logBatch,
|
|
413
|
-
sequenceToken: seqToken,
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
this._dataTracker.eventUploadInProgress = true;
|
|
417
|
-
const sendLogEventsResponse = await this._sendLogEvents(putLogsPayload);
|
|
418
|
-
|
|
419
|
-
this._nextSequenceToken = sendLogEventsResponse?.nextSequenceToken;
|
|
420
|
-
this._dataTracker.eventUploadInProgress = false;
|
|
421
|
-
this._currentLogBatch = [];
|
|
422
|
-
|
|
423
|
-
return sendLogEventsResponse;
|
|
424
|
-
} catch (err) {
|
|
425
|
-
logger.error(`error during _safeUploadLogEvents: ${err}`);
|
|
426
|
-
|
|
427
|
-
if (err instanceof Error && RETRY_ERROR_CODES.includes(err.name)) {
|
|
428
|
-
this._getNewSequenceTokenAndSubmit({
|
|
429
|
-
logEvents: this._currentLogBatch,
|
|
430
|
-
logGroupName: this._config.logGroupName,
|
|
431
|
-
logStreamName: this._config.logStreamName,
|
|
432
|
-
});
|
|
433
|
-
} else {
|
|
434
|
-
this._dataTracker.eventUploadInProgress = false;
|
|
435
|
-
throw err;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
private _getBufferedBatchOfLogs(): InputLogEvent[] {
|
|
441
|
-
/**
|
|
442
|
-
* CloudWatch has restrictions on the size of the log events that get sent up.
|
|
443
|
-
* We need to track both the size of each event and the total size of the batch
|
|
444
|
-
* of logs.
|
|
445
|
-
*
|
|
446
|
-
* We also need to ensure that the logs in the batch are sorted in chronological order.
|
|
447
|
-
* https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
|
|
448
|
-
*/
|
|
449
|
-
let currentEventIdx = 0;
|
|
450
|
-
let totalByteSize = 0;
|
|
451
|
-
|
|
452
|
-
while (currentEventIdx < this._dataTracker.logEvents.length) {
|
|
453
|
-
const currentEvent = this._dataTracker.logEvents[currentEventIdx];
|
|
454
|
-
const eventSize = currentEvent
|
|
455
|
-
? new TextEncoder().encode(currentEvent.message).length +
|
|
456
|
-
AWS_CLOUDWATCH_BASE_BUFFER_SIZE
|
|
457
|
-
: 0;
|
|
458
|
-
if (eventSize > AWS_CLOUDWATCH_MAX_EVENT_SIZE) {
|
|
459
|
-
const errString = `Log entry exceeds maximum size for CloudWatch logs. Log size: ${eventSize}. Truncating log message.`;
|
|
460
|
-
logger.warn(errString);
|
|
461
|
-
|
|
462
|
-
currentEvent.message = currentEvent.message?.substring(0, eventSize);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (totalByteSize + eventSize > AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE)
|
|
466
|
-
break;
|
|
467
|
-
totalByteSize += eventSize;
|
|
468
|
-
currentEventIdx++;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
this._currentLogBatch = this._dataTracker.logEvents.splice(
|
|
472
|
-
0,
|
|
473
|
-
currentEventIdx
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
return this._currentLogBatch;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
private async _getNewSequenceTokenAndSubmit(
|
|
480
|
-
payload: PutLogEventsCommandInput
|
|
481
|
-
): Promise<PutLogEventsCommandOutput | undefined> {
|
|
482
|
-
try {
|
|
483
|
-
this._nextSequenceToken = undefined;
|
|
484
|
-
this._dataTracker.eventUploadInProgress = true;
|
|
485
|
-
|
|
486
|
-
const seqToken = await this._getNextSequenceToken();
|
|
487
|
-
payload.sequenceToken = seqToken;
|
|
488
|
-
const sendLogEventsRepsonse = await this._sendLogEvents(payload);
|
|
489
|
-
|
|
490
|
-
this._dataTracker.eventUploadInProgress = false;
|
|
491
|
-
this._currentLogBatch = [];
|
|
492
|
-
|
|
493
|
-
return sendLogEventsRepsonse;
|
|
494
|
-
} catch (err) {
|
|
495
|
-
logger.error(
|
|
496
|
-
`error when retrying log submission with new sequence token: ${err}`
|
|
497
|
-
);
|
|
498
|
-
this._dataTracker.eventUploadInProgress = false;
|
|
499
|
-
|
|
500
|
-
throw err;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
private _initiateLogPushInterval(): void {
|
|
505
|
-
if (this._timer) {
|
|
506
|
-
clearInterval(this._timer);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
this._timer = setInterval(async () => {
|
|
510
|
-
try {
|
|
511
|
-
if (this._getDocUploadPermissibility()) {
|
|
512
|
-
await this._safeUploadLogEvents();
|
|
513
|
-
}
|
|
514
|
-
} catch (err) {
|
|
515
|
-
logger.error(
|
|
516
|
-
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
}, 2000);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
private _getDocUploadPermissibility(): boolean {
|
|
523
|
-
return (
|
|
524
|
-
(this._dataTracker.logEvents.length !== 0 ||
|
|
525
|
-
this._currentLogBatch.length !== 0) &&
|
|
526
|
-
!this._dataTracker.eventUploadInProgress
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function assertsAWSClouldWatchOptions(
|
|
532
|
-
options?: AWSCloudWatchProviderOptions
|
|
533
|
-
): asserts options {
|
|
534
|
-
return asserts(options !== undefined, {
|
|
535
|
-
name: AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION,
|
|
536
|
-
message: 'AWSCloudWatchProviderOptions cannot be undefined',
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
export { AWSCloudWatchProvider };
|
package/src/constants.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This Symbol is used to reference an internal-only PubSub provider that
|
|
6
|
-
* is used for AppSync/GraphQL subscriptions in the API category.
|
|
7
|
-
*/
|
|
8
|
-
const hasSymbol =
|
|
9
|
-
typeof Symbol !== 'undefined' && typeof Symbol.for === 'function';
|
|
10
|
-
|
|
11
|
-
export const INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = hasSymbol
|
|
12
|
-
? Symbol.for('INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER')
|
|
13
|
-
: '@@INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER';
|
|
14
|
-
|
|
15
|
-
export const USER_AGENT_HEADER = 'x-amz-user-agent';
|
|
16
|
-
|
|
17
|
-
// Error exception code constants
|
|
18
|
-
export const AUTH_CONFING_EXCEPTION = 'AuthConfigException';
|
|
19
|
-
|
|
20
|
-
export const AWS_CLOUD_WATCH_PROVIDER_OPTIONS_EXCEPTION =
|
|
21
|
-
'AWSCloudWatchProviderOptionsException';
|
|
22
|
-
|
|
23
|
-
export const CACHE_LIST_EXCEPTION = 'CacheListException';
|
|
24
|
-
|
|
25
|
-
export const I18N_EXCEPTION = 'I18NException';
|
|
26
|
-
|
|
27
|
-
export const SERVICE_WORKER_EXCEPTION = 'ServiceWorkerException';
|
|
28
|
-
|
|
29
|
-
export const STORAGE_CACHE_EXCEPTION = 'StorageCacheException';
|
|
30
|
-
|
|
31
|
-
export const APPLICATION_ID_EXCEPTION = 'ApplicationIdException';
|
package/src/types/types.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { InputLogEvent, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
5
|
-
import { Credentials } from '@aws-sdk/types';
|
|
6
|
-
|
|
7
|
-
export interface AmplifyConfig {
|
|
8
|
-
Analytics?: object;
|
|
9
|
-
Auth?: object;
|
|
10
|
-
API?: object;
|
|
11
|
-
Logging?: object;
|
|
12
|
-
Storage?: object;
|
|
13
|
-
Cache?: object;
|
|
14
|
-
Geo?: object;
|
|
15
|
-
Notifications?: {
|
|
16
|
-
InAppMessaging?: object;
|
|
17
|
-
};
|
|
18
|
-
ssr?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ICredentials {
|
|
22
|
-
accessKeyId: string;
|
|
23
|
-
sessionToken: string;
|
|
24
|
-
secretAccessKey: string;
|
|
25
|
-
identityId: string;
|
|
26
|
-
authenticated: boolean;
|
|
27
|
-
// Long term creds do not provide an expiration date
|
|
28
|
-
expiration?: Date;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @private
|
|
33
|
-
* Internal use of Amplify only
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
export type DelayFunction = (
|
|
37
|
-
attempt: number,
|
|
38
|
-
args?: any[],
|
|
39
|
-
error?: unknown
|
|
40
|
-
) => number | false;
|
|
41
|
-
|
|
42
|
-
export interface LoggingProvider {
|
|
43
|
-
// return the name of you provider
|
|
44
|
-
getProviderName(): string;
|
|
45
|
-
|
|
46
|
-
// return the name of you category
|
|
47
|
-
getCategoryName(): string;
|
|
48
|
-
|
|
49
|
-
// configure the plugin
|
|
50
|
-
configure(config?: object): object;
|
|
51
|
-
|
|
52
|
-
// take logs and push to provider
|
|
53
|
-
pushLogs(logs: InputLogEvent[]): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface AWSCloudWatchProviderOptions {
|
|
57
|
-
logGroupName?: string;
|
|
58
|
-
logStreamName?: string;
|
|
59
|
-
region?: string;
|
|
60
|
-
credentials?: Credentials;
|
|
61
|
-
endpoint?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface CloudWatchDataTracker {
|
|
65
|
-
eventUploadInProgress: boolean;
|
|
66
|
-
logEvents: InputLogEvent[];
|
|
67
|
-
verifiedLogGroup?: LogGroup;
|
|
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
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|