Skip to content

Commit

Permalink
release(required): Amplify JS release (#13301)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashika112 authored Apr 29, 2024
2 parents 6ea1be9 + 8fb751a commit 784deb7
Show file tree
Hide file tree
Showing 94 changed files with 4,928 additions and 905 deletions.
9 changes: 9 additions & 0 deletions .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,15 @@ tests:
spec: multi-part-copy
browser: *minimal_browser_list

# GEN2 STORAGE
- test_name: integ_react_storage
desc: 'React Storage Gen2'
framework: react
category: storage
sample_name: [storage-gen2]
spec: storage-gen2
browser: *minimal_browser_list

# INAPPMESSAGING
- test_name: integ_in_app_messaging
desc: 'React InApp Messaging'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/callable-canary-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
prebuild-macos:
uses: ./.github/workflows/callable-prebuild-amplify-js.yml
with:
runs_on: macos-latest
runs_on: macos-12
prebuild-samples-staging:
secrets: inherit
uses: ./.github/workflows/callable-prebuild-samples-staging.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/callable-e2e-test-detox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
e2e-test:
name: E2E-Detox ${{ inputs.test_name }}
runs-on: macos-latest
runs-on: macos-12
timeout-minutes: ${{ inputs.timeout_minutes }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/callable-release-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
prebuild-macos:
uses: ./.github/workflows/callable-prebuild-amplify-js.yml
with:
runs_on: macos-latest
runs_on: macos-12
prebuild-samples-staging:
secrets: inherit
uses: ./.github/workflows/callable-prebuild-samples-staging.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ResourcesConfig } from '@aws-amplify/core';
import { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';

import {
generateServerClientUsingCookies,
generateServerClientUsingReqRes,
} from '../../src/api';
import {
createRunWithAmplifyServerContext,
getAmplifyConfig,
} from '../../src/utils';
import { createRunWithAmplifyServerContext } from '../../src/utils';
import { NextApiRequestMock, NextApiResponseMock } from '../mocks/headers';
import { createServerRunnerForAPI } from '../../src/api/createServerRunnerForAPI';

Expand All @@ -34,13 +32,16 @@ const mockAmplifyConfig: ResourcesConfig = {

jest.mock('../../src/utils', () => ({
createRunWithAmplifyServerContext: jest.fn(() => jest.fn()),
getAmplifyConfig: jest.fn(() => mockAmplifyConfig),
createCookieStorageAdapterFromNextServerContext: jest.fn(),
}));
jest.mock('@aws-amplify/core/internals/utils', () => ({
...jest.requireActual('@aws-amplify/core/internals/utils'),
parseAmplifyConfig: jest.fn(() => mockAmplifyConfig),
}));

jest.mock('aws-amplify/adapter-core');

const mockGetAmplifyConfig = getAmplifyConfig as jest.Mock;
const mockParseAmplifyConfig = parseAmplifyConfig as jest.Mock;
const mockCreateRunWithAmplifyServerContext =
createRunWithAmplifyServerContext as jest.Mock;

Expand Down Expand Up @@ -77,7 +78,7 @@ describe('generateServerClient', () => {

it('should call getAmlifyConfig', async () => {
generateServerClientUsingReqRes({ config: mockAmplifyConfig });
expect(mockGetAmplifyConfig).toHaveBeenCalled();
expect(mockParseAmplifyConfig).toHaveBeenCalled();
});

// TODO: figure out proper mocks and unskip
Expand Down
17 changes: 12 additions & 5 deletions packages/adapter-nextjs/__tests__/createServerRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock(
describe('createServerRunner', () => {
let createServerRunner: any;

const mockParseAWSExports = jest.fn();
const mockParseAmplifyConfig = jest.fn();
const mockCreateAWSCredentialsAndIdentityIdProvider = jest.fn();
const mockCreateKeyValueStorageFromCookieStorageAdapter = jest.fn();
const mockCreateUserPoolsTokenProvider = jest.fn();
Expand All @@ -48,23 +48,23 @@ describe('createServerRunner', () => {
runWithAmplifyServerContext: mockRunWithAmplifyServerContextCore,
}));
jest.doMock('@aws-amplify/core/internals/utils', () => ({
parseAWSExports: mockParseAWSExports,
parseAmplifyConfig: mockParseAmplifyConfig,
}));

({ createServerRunner } = require('../src'));
});

afterEach(() => {
mockParseAWSExports.mockClear();
mockParseAmplifyConfig.mockClear();
mockCreateAWSCredentialsAndIdentityIdProvider.mockClear();
mockCreateKeyValueStorageFromCookieStorageAdapter.mockClear();
mockCreateUserPoolsTokenProvider.mockClear();
mockRunWithAmplifyServerContextCore.mockClear();
});

it('calls parseAWSExports when the config object is imported from amplify configuration file', () => {
it('calls parseAmplifyConfig when the config object is imported from amplify configuration file', () => {
createServerRunner({ config: { aws_project_region: 'us-west-2' } });
expect(mockParseAWSExports).toHaveBeenCalled();
expect(mockParseAmplifyConfig).toHaveBeenCalled();
});

it('returns runWithAmplifyServerContext function', () => {
Expand All @@ -85,6 +85,9 @@ describe('createServerRunner', () => {
},
},
};

mockParseAmplifyConfig.mockReturnValue(mockAmplifyConfigWithoutAuth);

const { runWithAmplifyServerContext } = createServerRunner({
config: mockAmplifyConfigWithoutAuth,
});
Expand All @@ -99,6 +102,10 @@ describe('createServerRunner', () => {
});

describe('when amplifyConfig.Auth is defined', () => {
beforeEach(() => {
mockParseAmplifyConfig.mockReturnValue(mockAmplifyConfig);
});

describe('when nextServerContext is null (opt-in unauthenticated role)', () => {
it('should create auth providers with sharedInMemoryStorage', () => {
const { runWithAmplifyServerContext } = createServerRunner({
Expand Down
46 changes: 0 additions & 46 deletions packages/adapter-nextjs/__tests__/utils/getAmplifyConfig.test.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/adapter-nextjs/src/api/createServerRunnerForAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// SPDX-License-Identifier: Apache-2.0

import { ResourcesConfig } from '@aws-amplify/core';
import { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';

import { createRunWithAmplifyServerContext, getAmplifyConfig } from '../utils';
import { createRunWithAmplifyServerContext } from '../utils';
import { NextServer } from '../types';

export const createServerRunnerForAPI = ({
config,
}: NextServer.CreateServerRunnerInput): NextServer.CreateServerRunnerOutput & {
resourcesConfig: ResourcesConfig;
} => {
const amplifyConfig = getAmplifyConfig(config);
const amplifyConfig = parseAmplifyConfig(config);

return {
runWithAmplifyServerContext: createRunWithAmplifyServerContext({
Expand Down
8 changes: 5 additions & 3 deletions packages/adapter-nextjs/src/api/generateServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
V6ClientSSRCookies,
V6ClientSSRRequest,
} from '@aws-amplify/api-graphql';
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
import {
GraphQLAuthMode,
parseAmplifyConfig,
} from '@aws-amplify/core/internals/utils';

import { NextServer } from '../types';
import { getAmplifyConfig } from '../utils';

import { createServerRunnerForAPI } from './createServerRunnerForAPI';

Expand Down Expand Up @@ -98,7 +100,7 @@ export function generateServerClientUsingCookies<
export function generateServerClientUsingReqRes<
T extends Record<any, any> = never,
>({ config, authMode, authToken }: ReqClientParams): V6ClientSSRRequest<T> {
const amplifyConfig = getAmplifyConfig(config);
const amplifyConfig = parseAmplifyConfig(config);

return generateClient<T>({
config: amplifyConfig,
Expand Down
5 changes: 3 additions & 2 deletions packages/adapter-nextjs/src/createServerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

import { ResourcesConfig } from 'aws-amplify';
import { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';

import { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils';
import { createRunWithAmplifyServerContext } from './utils';
import { NextServer } from './types';

/**
Expand All @@ -27,7 +28,7 @@ import { NextServer } from './types';
export const createServerRunner: NextServer.CreateServerRunner = ({
config,
}) => {
const amplifyConfig = getAmplifyConfig(config);
const amplifyConfig = parseAmplifyConfig(config);

return {
runWithAmplifyServerContext: createRunWithAmplifyServerContext({
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-nextjs/src/types/NextServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { GetServerSidePropsContext as NextGetServerSidePropsContext } from 'next';
import { NextRequest, NextResponse } from 'next/server.js';
import { cookies } from 'next/headers.js';
import { LegacyConfig } from 'aws-amplify/adapter-core';
import { AmplifyOutputs, LegacyConfig } from 'aws-amplify/adapter-core';
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
import { ResourcesConfig } from '@aws-amplify/core';

Expand Down Expand Up @@ -74,7 +74,7 @@ export declare namespace NextServer {
) => Promise<OperationResult>;

export interface CreateServerRunnerInput {
config: ResourcesConfig | LegacyConfig;
config: ResourcesConfig | LegacyConfig | AmplifyOutputs;
}

export interface CreateServerRunnerOutput {
Expand Down
13 changes: 0 additions & 13 deletions packages/adapter-nextjs/src/utils/getAmplifyConfig.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/adapter-nextjs/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export { getAmplifyConfig } from './getAmplifyConfig';
export { createRunWithAmplifyServerContext } from './createRunWithAmplifyServerContext';
Loading

0 comments on commit 784deb7

Please sign in to comment.