@aws-amplify/core
Version:
Core category of aws-amplify
1 lines • 3.69 kB
Source Map (JSON)
{"version":3,"file":"Amplify.mjs","sources":["../../../src/singleton/Amplify.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthClass } from './Auth';\nimport { Hub, AMPLIFY_SYMBOL } from '../Hub';\nimport { parseAWSExports } from '../parseAWSExports';\nimport { deepFreeze } from '../utils';\nexport class AmplifyClass {\n constructor() {\n this.resourcesConfig = {};\n this.libraryOptions = {};\n this.Auth = new AuthClass();\n }\n /**\n * Configures Amplify for use with your back-end resources.\n *\n * @remarks\n * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently\n * provided values will be used after configuration.\n *\n * @remarks\n * `configure` can be used to specify additional library options where available for supported categories.\n *\n * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.\n * @param libraryOptions - Additional options for customizing the behavior of the library.\n */\n configure(resourcesConfig, libraryOptions) {\n let resolvedResourceConfig;\n if (Object.keys(resourcesConfig).some(key => key.startsWith('aws_'))) {\n resolvedResourceConfig = parseAWSExports(resourcesConfig);\n }\n else {\n resolvedResourceConfig = resourcesConfig;\n }\n this.resourcesConfig = resolvedResourceConfig;\n if (libraryOptions) {\n this.libraryOptions = libraryOptions;\n }\n // Make resource config immutable\n this.resourcesConfig = deepFreeze(this.resourcesConfig);\n this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);\n Hub.dispatch('core', {\n event: 'configure',\n data: resourcesConfig,\n }, 'Configure', AMPLIFY_SYMBOL);\n }\n /**\n * Provides access to the current back-end resource configuration for the Library.\n *\n * @returns Returns the immutable back-end resource configuration.\n */\n getConfig() {\n return this.resourcesConfig;\n }\n}\n/**\n * The `Amplify` utility is used to configure the library.\n *\n * @remarks\n * `Amplify` is responsible for orchestrating cross-category communication within the library.\n */\nexport const Amplify = new AmplifyClass();\n"],"names":[],"mappings":";;;;;;;AAAA;AAC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