1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.parseAWSExports = void 0;
|
15 | var Logger_1 = require("./Logger");
|
16 | var logger = new Logger_1.ConsoleLogger('Parser');
|
17 | var parseAWSExports = function (config) {
|
18 | var amplifyConfig = {};
|
19 |
|
20 | if (config['aws_mobile_analytics_app_id']) {
|
21 | var Analytics = {
|
22 | AWSPinpoint: {
|
23 | appId: config['aws_mobile_analytics_app_id'],
|
24 | region: config['aws_mobile_analytics_app_region'],
|
25 | },
|
26 | };
|
27 | amplifyConfig.Analytics = Analytics;
|
28 | }
|
29 |
|
30 | if (config['aws_cognito_identity_pool_id'] || config['aws_user_pools_id']) {
|
31 | amplifyConfig.Auth = {
|
32 | userPoolId: config['aws_user_pools_id'],
|
33 | userPoolWebClientId: config['aws_user_pools_web_client_id'],
|
34 | region: config['aws_cognito_region'],
|
35 | identityPoolId: config['aws_cognito_identity_pool_id'],
|
36 | identityPoolRegion: config['aws_cognito_region'],
|
37 | mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable',
|
38 | signUpVerificationMethod: config['aws_cognito_sign_up_verification_method'] || 'code',
|
39 | };
|
40 | }
|
41 |
|
42 | var storageConfig;
|
43 | if (config['aws_user_files_s3_bucket']) {
|
44 | storageConfig = {
|
45 | AWSS3: {
|
46 | bucket: config['aws_user_files_s3_bucket'],
|
47 | region: config['aws_user_files_s3_bucket_region'],
|
48 | dangerouslyConnectToHttpEndpointForTesting: config['aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing'],
|
49 | },
|
50 | };
|
51 | }
|
52 | else {
|
53 | storageConfig = config ? config.Storage || config : {};
|
54 | }
|
55 |
|
56 | if (config['Logging']) {
|
57 | amplifyConfig.Logging = __assign(__assign({}, config['Logging']), { region: config['aws_project_region'] });
|
58 | }
|
59 |
|
60 | if (config['geo']) {
|
61 | amplifyConfig.Geo = Object.assign({}, config.geo);
|
62 | if (config.geo['amazon_location_service']) {
|
63 | amplifyConfig.Geo = {
|
64 | AmazonLocationService: config.geo['amazon_location_service'],
|
65 | };
|
66 | }
|
67 | }
|
68 | amplifyConfig.Analytics = Object.assign({}, amplifyConfig.Analytics, config.Analytics);
|
69 | amplifyConfig.Auth = Object.assign({}, amplifyConfig.Auth, config.Auth);
|
70 | amplifyConfig.Storage = Object.assign({}, storageConfig);
|
71 | amplifyConfig.Logging = Object.assign({}, amplifyConfig.Logging, config.Logging);
|
72 | logger.debug('parse config', config, 'to amplifyconfig', amplifyConfig);
|
73 | return amplifyConfig;
|
74 | };
|
75 | exports.parseAWSExports = parseAWSExports;
|