-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathresolveConfig.ts
More file actions
40 lines (34 loc) · 929 Bytes
/
resolveConfig.ts
File metadata and controls
40 lines (34 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { Amplify } from '@aws-amplify/core';
import {
AnalyticsValidationErrorCode,
assertValidationError,
} from '../../../errors';
import { DEFAULT_KINESIS_CONFIG } from './constants';
export const resolveConfig = () => {
Amplify.assertConfigured();
const config = Amplify.getConfig().Analytics?.Kinesis;
const {
region,
bufferSize = DEFAULT_KINESIS_CONFIG.bufferSize,
flushSize = DEFAULT_KINESIS_CONFIG.flushSize,
flushInterval = DEFAULT_KINESIS_CONFIG.flushInterval,
resendLimit,
} = {
...DEFAULT_KINESIS_CONFIG,
...config,
};
assertValidationError(!!region, AnalyticsValidationErrorCode.NoRegion);
assertValidationError(
flushSize < bufferSize,
AnalyticsValidationErrorCode.InvalidFlushSize,
);
return {
region,
bufferSize,
flushSize,
flushInterval,
resendLimit,
};
};