UNPKG

3.21 kBJavaScriptView Raw
1var __assign = (this && this.__assign) || function () {
2 __assign = Object.assign || function(t) {
3 for (var s, i = 1, n = arguments.length; i < n; i++) {
4 s = arguments[i];
5 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6 t[p] = s[p];
7 }
8 return t;
9 };
10 return __assign.apply(this, arguments);
11};
12import { ConsoleLogger as Logger } from './Logger';
13var logger = new Logger('Parser');
14export var parseMobileHubConfig = function (config) {
15 var amplifyConfig = {};
16 // Analytics
17 if (config['aws_mobile_analytics_app_id']) {
18 var Analytics = {
19 AWSPinpoint: {
20 appId: config['aws_mobile_analytics_app_id'],
21 region: config['aws_mobile_analytics_app_region'],
22 },
23 };
24 amplifyConfig.Analytics = Analytics;
25 }
26 // Auth
27 if (config['aws_cognito_identity_pool_id'] || config['aws_user_pools_id']) {
28 amplifyConfig.Auth = {
29 userPoolId: config['aws_user_pools_id'],
30 userPoolWebClientId: config['aws_user_pools_web_client_id'],
31 region: config['aws_cognito_region'],
32 identityPoolId: config['aws_cognito_identity_pool_id'],
33 identityPoolRegion: config['aws_cognito_region'],
34 mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable',
35 signUpVerificationMethod: config['aws_cognito_sign_up_verification_method'] || 'code',
36 };
37 }
38 // Storage
39 var storageConfig;
40 if (config['aws_user_files_s3_bucket']) {
41 storageConfig = {
42 AWSS3: {
43 bucket: config['aws_user_files_s3_bucket'],
44 region: config['aws_user_files_s3_bucket_region'],
45 dangerouslyConnectToHttpEndpointForTesting: config['aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing'],
46 },
47 };
48 }
49 else {
50 storageConfig = config ? config.Storage || config : {};
51 }
52 // Logging
53 if (config['Logging']) {
54 amplifyConfig.Logging = __assign(__assign({}, config['Logging']), { region: config['aws_project_region'] });
55 }
56 // Geo
57 if (config['geo']) {
58 amplifyConfig.Geo = Object.assign({}, config.geo);
59 if (config.geo['amazon_location_service']) {
60 amplifyConfig.Geo = {
61 AmazonLocationService: config.geo['amazon_location_service'],
62 };
63 }
64 }
65 amplifyConfig.Analytics = Object.assign({}, amplifyConfig.Analytics, config.Analytics);
66 amplifyConfig.Auth = Object.assign({}, amplifyConfig.Auth, config.Auth);
67 amplifyConfig.Storage = Object.assign({}, storageConfig);
68 amplifyConfig.Logging = Object.assign({}, amplifyConfig.Logging, config.Logging);
69 logger.debug('parse config', config, 'to amplifyconfig', amplifyConfig);
70 return amplifyConfig;
71};
72/**
73 * @deprecated use per-function export
74 */
75var Parser = /** @class */ (function () {
76 function Parser() {
77 }
78 Parser.parseMobilehubConfig = parseMobileHubConfig;
79 return Parser;
80}());
81export { Parser };
82/**
83 * @deprecated use per-function export
84 */
85export default Parser;
86//# sourceMappingURL=Parser.js.map
\No newline at end of file