diff --git a/packages/adapter-nextjs/src/types/NextServer.ts b/packages/adapter-nextjs/src/types/NextServer.ts index 5c3d093b795..285a413757e 100644 --- a/packages/adapter-nextjs/src/types/NextServer.ts +++ b/packages/adapter-nextjs/src/types/NextServer.ts @@ -4,7 +4,10 @@ import { GetServerSidePropsContext as NextGetServerSidePropsContext } from 'next'; import { NextRequest, NextResponse } from 'next/server.js'; import { cookies } from 'next/headers.js'; -import { AmplifyOutputs, LegacyConfig } from 'aws-amplify/adapter-core'; +import { + AmplifyOutputsUnknown, + LegacyConfig, +} from 'aws-amplify/adapter-core/internals'; import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core'; import { ResourcesConfig } from '@aws-amplify/core'; @@ -74,7 +77,7 @@ export declare namespace NextServer { ) => Promise; export interface CreateServerRunnerInput { - config: ResourcesConfig | LegacyConfig | AmplifyOutputs; + config: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown; } export interface CreateServerRunnerOutput { diff --git a/packages/aws-amplify/adapter-core/internals/package.json b/packages/aws-amplify/adapter-core/internals/package.json new file mode 100644 index 00000000000..afd44aeac94 --- /dev/null +++ b/packages/aws-amplify/adapter-core/internals/package.json @@ -0,0 +1,7 @@ +{ + "name": "aws-amplify/adapter-core/internals", + "types": "../../dist/esm/adapter-core/internals.d.ts", + "main": "../../dist/cjs/adapter-core/internals.js", + "module": "../../dist/esm/adapter-core/internals.mjs", + "sideEffects": false +} diff --git a/packages/aws-amplify/src/adapter-core/index.ts b/packages/aws-amplify/src/adapter-core/index.ts index 755f8c12b42..46d085925d2 100644 --- a/packages/aws-amplify/src/adapter-core/index.ts +++ b/packages/aws-amplify/src/adapter-core/index.ts @@ -8,7 +8,9 @@ export { createUserPoolsTokenProvider, } from './authProvidersFactories/cognito'; export { + /** @deprecated This type is deprecated and will be removed in future versions. */ LegacyConfig, + /** @deprecated This type is deprecated and will be removed in future versions. */ AmplifyOutputs, } from '@aws-amplify/core/internals/utils'; export { diff --git a/packages/aws-amplify/src/adapter-core/internals.ts b/packages/aws-amplify/src/adapter-core/internals.ts new file mode 100644 index 00000000000..d2ce97296ca --- /dev/null +++ b/packages/aws-amplify/src/adapter-core/internals.ts @@ -0,0 +1,7 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +export { + LegacyConfig, + AmplifyOutputsUnknown, +} from '@aws-amplify/core/internals/utils'; diff --git a/packages/aws-amplify/src/initSingleton.ts b/packages/aws-amplify/src/initSingleton.ts index b5de7deb56a..8ec3005f3dc 100644 --- a/packages/aws-amplify/src/initSingleton.ts +++ b/packages/aws-amplify/src/initSingleton.ts @@ -8,7 +8,7 @@ import { defaultStorage, } from '@aws-amplify/core'; import { - AmplifyOutputs, + AmplifyOutputsUnknown, LegacyConfig, parseAmplifyConfig, } from '@aws-amplify/core/internals/utils'; @@ -32,7 +32,7 @@ export const DefaultAmplify = { * Amplify.configure(config); */ configure( - resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputs, + resourceConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, libraryOptions?: LibraryOptions, ): void { const resolvedResourceConfig = parseAmplifyConfig(resourceConfig); diff --git a/packages/core/src/libraryUtils.ts b/packages/core/src/libraryUtils.ts index 7e073d153b8..16dfdca898a 100644 --- a/packages/core/src/libraryUtils.ts +++ b/packages/core/src/libraryUtils.ts @@ -24,7 +24,10 @@ export { export { parseAWSExports } from './parseAWSExports'; export { isAmplifyOutputs, parseAmplifyOutputs } from './parseAmplifyOutputs'; export { LegacyConfig } from './singleton/types'; -export { AmplifyOutputs } from './singleton/AmplifyOutputs/types'; +export { + AmplifyOutputs, + AmplifyOutputsUnknown, +} from './singleton/AmplifyOutputs/types'; export { ADD_OAUTH_LISTENER } from './singleton/constants'; export { amplifyUuid } from './utils/amplifyUuid'; export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl'; diff --git a/packages/core/src/parseAmplifyOutputs.ts b/packages/core/src/parseAmplifyOutputs.ts index 328ddf67f5b..9f03001cfa9 100644 --- a/packages/core/src/parseAmplifyOutputs.ts +++ b/packages/core/src/parseAmplifyOutputs.ts @@ -19,7 +19,6 @@ import { } from './singleton/Auth/types'; import { NotificationsConfig } from './singleton/Notifications/types'; import { - AmplifyOutputs, AmplifyOutputsAnalyticsProperties, AmplifyOutputsAuthProperties, AmplifyOutputsCustomProperties, @@ -28,6 +27,7 @@ import { AmplifyOutputsNotificationsProperties, AmplifyOutputsStorageBucketProperties, AmplifyOutputsStorageProperties, + AmplifyOutputsUnknown, } from './singleton/AmplifyOutputs/types'; import { AnalyticsConfig, @@ -40,10 +40,10 @@ import { } from './singleton/types'; export function isAmplifyOutputs( - config: ResourcesConfig | LegacyConfig | AmplifyOutputs, -): config is AmplifyOutputs { + config: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, +): config is AmplifyOutputsUnknown { // version format initially will be '1' but is expected to be something like x.y where x is major and y minor version - const { version } = config as AmplifyOutputs; + const { version } = config as AmplifyOutputsUnknown; if (!version) { return false; @@ -291,7 +291,7 @@ function parseNotifications( } export function parseAmplifyOutputs( - amplifyOutputs: AmplifyOutputs, + amplifyOutputs: AmplifyOutputsUnknown, ): ResourcesConfig { const resourcesConfig: ResourcesConfig = {}; diff --git a/packages/core/src/singleton/Amplify.ts b/packages/core/src/singleton/Amplify.ts index 76d4e5be9b4..80a577bbc9a 100644 --- a/packages/core/src/singleton/Amplify.ts +++ b/packages/core/src/singleton/Amplify.ts @@ -5,7 +5,7 @@ import { deepFreeze } from '../utils'; import { parseAmplifyConfig } from '../libraryUtils'; import { - AmplifyOutputs, + AmplifyOutputsUnknown, AuthConfig, LegacyConfig, LibraryOptions, @@ -49,7 +49,7 @@ export class AmplifyClass { * @param libraryOptions - Additional options for customizing the behavior of the library. */ configure( - resourcesConfig: ResourcesConfig | LegacyConfig | AmplifyOutputs, + resourcesConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, libraryOptions?: LibraryOptions, ): void { const resolvedResourceConfig = parseAmplifyConfig(resourcesConfig); diff --git a/packages/core/src/singleton/AmplifyOutputs/types.ts b/packages/core/src/singleton/AmplifyOutputs/types.ts index 1209ea92d6f..c5f148fdf9e 100644 --- a/packages/core/src/singleton/AmplifyOutputs/types.ts +++ b/packages/core/src/singleton/AmplifyOutputs/types.ts @@ -115,7 +115,19 @@ export interface AmplifyOutputsNotificationsProperties { channels: string[]; } +/** @deprecated Use {@link AmplifyOutputsUnknown} instead. */ export interface AmplifyOutputs { + version?: string; + storage?: AmplifyOutputsStorageProperties; + auth?: AmplifyOutputsAuthProperties; + analytics?: AmplifyOutputsAnalyticsProperties; + geo?: AmplifyOutputsGeoProperties; + data?: AmplifyOutputsDataProperties; + custom?: AmplifyOutputsCustomProperties; + notifications?: AmplifyOutputsNotificationsProperties; +} + +export interface AmplifyOutputsUnknown { version?: string; storage?: unknown; auth?: unknown; diff --git a/packages/core/src/singleton/types.ts b/packages/core/src/singleton/types.ts index 3419be9a1ec..ec40efea1ef 100644 --- a/packages/core/src/singleton/types.ts +++ b/packages/core/src/singleton/types.ts @@ -27,7 +27,7 @@ import { import { NotificationsConfig } from './Notifications/types'; import { InteractionsConfig } from './Interactions/types'; -export { AmplifyOutputs } from './AmplifyOutputs/types'; +export { AmplifyOutputsUnknown } from './AmplifyOutputs/types'; /** * Compatibility type representing the Amplify Gen 1 configuration file schema. This type should not be used directly. diff --git a/packages/core/src/utils/parseAmplifyConfig.ts b/packages/core/src/utils/parseAmplifyConfig.ts index 424f71a7102..0d89ac8f0d7 100644 --- a/packages/core/src/utils/parseAmplifyConfig.ts +++ b/packages/core/src/utils/parseAmplifyConfig.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { ResourcesConfig } from '../index'; -import { AmplifyOutputs } from '../singleton/AmplifyOutputs/types'; +import { AmplifyOutputsUnknown } from '../singleton/AmplifyOutputs/types'; import { LegacyConfig } from '../singleton/types'; import { parseAWSExports } from '../parseAWSExports'; import { isAmplifyOutputs, parseAmplifyOutputs } from '../parseAmplifyOutputs'; @@ -14,7 +14,7 @@ import { isAmplifyOutputs, parseAmplifyOutputs } from '../parseAmplifyOutputs'; * @return A ResourcesConfig for the provided configuration object. */ export const parseAmplifyConfig = ( - amplifyConfig: ResourcesConfig | LegacyConfig | AmplifyOutputs, + amplifyConfig: ResourcesConfig | LegacyConfig | AmplifyOutputsUnknown, ): ResourcesConfig => { if (Object.keys(amplifyConfig).some(key => key.startsWith('aws_'))) { return parseAWSExports(amplifyConfig);