Skip to content

Commit

Permalink
release: Amplify JS release (#13502)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Jun 17, 2024
2 parents 61b2bf1 + de6b06d commit 5c6b6f1
Show file tree
Hide file tree
Showing 72 changed files with 488 additions and 366 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
'packages/api/__tests__',
'packages/api-graphql/__tests__',
// 'packages/api-rest/__tests__',
'packages/auth/__tests__',
// 'packages/auth/__tests__',
// 'packages/aws-amplify/__tests__',
// 'packages/core/__tests__',
'packages/datastore/__tests__',
Expand Down Expand Up @@ -82,9 +82,11 @@ module.exports = {
'logout_uri',
'id_token',
'access_token',
'refresh_token',
'token_type',
'expires_in',
'error_description',
'error_message',
// exceptions for the notifications package
'campaign_id',
'delivery_type',
Expand Down
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@
/packages/aws-amplify/package.json @aws-amplify/amplify-js-admins
/.circleci/ @aws-amplify/amplify-js @aws-amplify/amplify-devops
/.github/ @aws-amplify/amplify-js-admins
/packages/auth @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/aws-amplify/src/adapter-core @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/adapterCore @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/singleton @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/utils/convert @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/utils/WordArray.ts @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/storage @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/utils/generateRandomString.ts @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/utils/globalHelpers @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/utils/urlSafeDecode.ts @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/awsClients/cognitoIdentity @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/clients/internal @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
/packages/core/src/Hub @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
7 changes: 0 additions & 7 deletions .github/canary-config/canary-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ tests:
browser: [chrome, firefox]
timeout_minutes: 45
retry_count: 10
- test_name: integ_react_datastore_websocket_disruption
desc: 'DataStore - WebSocket Disruption'
framework: react
category: datastore
sample_name: [websocket-disruption]
spec: websocket-disruption
browser: [chrome, firefox]
# can un comment when ever fixed
# - test_name: integ_next_datastore_owner_auth
# desc: 'next owner auth'
Expand Down
17 changes: 10 additions & 7 deletions .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,6 @@ tests:
sample_name: [v2/amplify-docs-examples]
spec: amplify-docs-examples
browser: [chrome]
- test_name: integ_react_datastore_websocket_disruption
desc: 'DataStore - WebSocket Disruption'
framework: react
category: datastore
sample_name: [websocket-disruption]
spec: websocket-disruption
browser: *minimal_browser_list
- test_name: integ_vanilla_js_datastore_basic_crud
desc: 'Vanilla JS + Webpack 4 + DataStore - Basic CRUD'
framework: javascript
Expand Down Expand Up @@ -846,3 +839,13 @@ tests:
# sample_name: duplicate-packages
# spec: duplicate-packages
# browser: *minimal_browser_list

# SSR context isolation
- test_name: integ_ssr_context_isolation
desc: 'SSR Context Isolation'
framework: next
category: ssr-adapter
sample_name: ssr-context-isolation
spec: ssr-context-isolation
yarn_script: ci:ssr-context-isolation
browser: [chrome]
60 changes: 37 additions & 23 deletions .github/workflows/callable-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ on:
retry_count:
required: true
type: number
yarn_script:
required: false
type: string

env:
AMPLIFY_DIR: /home/runner/work/amplify-js/amplify-js/amplify-js
Expand Down Expand Up @@ -80,19 +83,24 @@ jobs:
E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
E2E_YARN_SCRIPT: ${{ inputs.yarn_script }}
run: |
../amplify-js/scripts/retry-yarn-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
dev \
$E2E_BACKEND \
$E2E_AMPLIFY_JS_DIR" \
-n $E2E_RETRY_COUNT
if [ -z "$E2E_YARN_SCRIPT" ]; then
../amplify-js/scripts/retry-yarn-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
dev \
$E2E_BACKEND \
$E2E_AMPLIFY_JS_DIR" \
$E2E_YARN_SCRIPT \
-n $E2E_RETRY_COUNT
else
echo "Skipping specialized yarn script execution in the dev environment."
fi
- name: Run cypress tests for ${{ inputs.test_name }} prod
shell: bash
working-directory: amplify-js-samples-staging
Expand All @@ -106,18 +114,24 @@ jobs:
E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
E2E_YARN_SCRIPT: ${{ inputs.yarn_script }}
run: |
../amplify-js/scripts/retry-yarn-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
prod \
$E2E_BACKEND \
$E2E_AMPLIFY_JS_DIR" \
-n $E2E_RETRY_COUNT
if [ -z "$E2E_YARN_SCRIPT" ]; then
../amplify-js/scripts/retry-yarn-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_CATEGORY \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
prod \
$E2E_BACKEND \
$E2E_AMPLIFY_JS_DIR" \
$E2E_YARN_SCRIPT \
-n $E2E_RETRY_COUNT
else
yarn "$E2E_YARN_SCRIPT"
fi
- name: Upload artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: failure()
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/callable-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
backend: ${{ matrix.integ-config.backend }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
retry_count: ${{ matrix.integ-config.retry_count || 3 }}
yarn_script: ${{ matrix.integ-config.yarn_script || '' }}

# e2e-test-runner-headless:
# name: E2E test runnner_headless
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches: ['*']
pull_request:
branches: ['main', 'next/main', 'next/release']
branches: ['main', 'release', 'next/main', 'next/release']
schedule:
# Run every Tuesday at midnight GMT
- cron: '0 0 * * 2'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
push:
branches:
- next/main
- replace-with-your-branch

jobs:
e2e:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Our default implementation works with Amazon Web Services (AWS), but AWS Amplify

#### Visit our [documentation site](https://docs.amplify.aws/) to learn more about AWS Amplify. Please see the [Amplify JavaScript](https://docs.amplify.aws/lib/q/platform/js/) page for information around the full list of features we support.

- [Demo Applications](https://github.com/aws-amplify/amplify-js-samples)
- [Contributing](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md)

### Features
Expand Down
3 changes: 0 additions & 3 deletions packages/auth/__tests__/mockData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// keeping this so that jest does not complain
test('should do nothing', () => {});

// device tracking mock device data
export const mockDeviceArray = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
import { AmplifyErrorCode } from '@aws-amplify/core/internals/utils';

import { assertServiceError } from '../../../src/errors/utils/assertServiceError';
import { AuthError } from '../../../src/errors/AuthError';
import { InitiateAuthException } from '../../../src/providers/cognito/types/errors';

describe('asserts service errors', () => {
test('it should throw an unknown error when error is null', () => {
try {
const error = null;
expect(assertServiceError(error)).toThrow();
} catch (error: any) {
expect(error).toBeInstanceOf(AuthError);
expect(error.name).toBe(AmplifyErrorCode.Unknown);
}
const error = null;
expect(() => {
assertServiceError(error);
}).toThrow(
new AuthError({
name: AmplifyErrorCode.Unknown,
message: 'An unknown error has occurred.',
underlyingError: error,
}),
);
});

test('it should throw an unknown error when error is a TypeError', () => {
try {
const error = new TypeError('TypeError');
expect(assertServiceError(error)).toThrow();
} catch (error: any) {
expect(error).toBeInstanceOf(AuthError);
expect(error.name).toBe(AmplifyErrorCode.Unknown);
}
const error = new TypeError('TypeError');
expect(() => {
assertServiceError(error);
}).toThrow(
new AuthError({
name: AmplifyErrorCode.Unknown,
message: 'An unknown error has occurred.',
underlyingError: error,
}),
);
});

test('it should throw an unknown error when error does not have a name', () => {
try {
const error = new Error('Error');
expect(assertServiceError(error)).toThrow();
} catch (error: any) {
expect(error).toBeInstanceOf(AuthError);
expect(error.name).toBe(AmplifyErrorCode.Unknown);
}
const error = new Error('Error');
expect(() => {
assertServiceError(error);
}).toThrow(
new AuthError({
name: AmplifyErrorCode.Unknown,
message: 'An unknown error has occurred.',
underlyingError: error,
}),
);
});

test('it should not throw if the error is coming from the service', () => {
const error = new Error('Service Error');
error.name = InitiateAuthException.InternalErrorException;
expect(assertServiceError(error)).toBeUndefined();
expect(() => {
assertServiceError(error);
}).not.toThrow();
});
});
6 changes: 4 additions & 2 deletions packages/auth/__tests__/providers/cognito/autoSignIn.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { Amplify } from 'aws-amplify';

import {
cognitoUserPoolsTokenProvider,
signUp,
} from '../../../src/providers/cognito';
import { autoSignIn } from '../../../src/providers/cognito/apis/autoSignIn';
import * as signUpClient from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
import { authAPITestParams } from './testUtils/authApiTestParams';
import {
RespondToAuthChallengeCommandOutput,
SignUpCommandOutput,
} from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider/types';
import { Amplify } from 'aws-amplify';
import * as initiateAuthHelpers from '../../../src/providers/cognito/utils/signInHelpers';
import { AuthError } from '../../../src/errors/AuthError';

import { authAPITestParams } from './testUtils/authApiTestParams';

jest.mock('../../../src/providers/cognito/utils/dispatchSignedInHubEvent');
jest.mock('@aws-amplify/core/internals/utils', () => ({
...jest.requireActual('@aws-amplify/core/internals/utils'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

import { Amplify } from '@aws-amplify/core';

import { AuthError } from '../../../src/errors/AuthError';
import { AuthValidationErrorCode } from '../../../src/errors/types/validation';
import { confirmResetPassword } from '../../../src/providers/cognito';
import { ConfirmForgotPasswordException } from '../../../src/providers/cognito/types/errors';
import { confirmForgotPassword } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';

import { authAPITestParams } from './testUtils/authApiTestParams';
import { getMockError } from './testUtils/data';
import { setUpGetConfig } from './testUtils/setUpGetConfig';
Expand Down Expand Up @@ -42,9 +44,9 @@ describe('confirmResetPassword', () => {
});

it('should call the confirmForgotPassword and return void', async () => {
expect(
await confirmResetPassword(authAPITestParams.confirmResetPasswordRequest),
).toBeUndefined();
await expect(
confirmResetPassword(authAPITestParams.confirmResetPasswordRequest),
).resolves.toBeUndefined();
expect(mockConfirmForgotPassword).toHaveBeenCalled();
});

Expand Down Expand Up @@ -135,7 +137,7 @@ describe('confirmResetPassword', () => {
});

it('should add UserContextData', async () => {
window['AmazonCognitoAdvancedSecurityData'] = {
(window as any).AmazonCognitoAdvancedSecurityData = {
getData() {
return 'abcd';
},
Expand All @@ -162,6 +164,6 @@ describe('confirmResetPassword', () => {
},
}),
);
window['AmazonCognitoAdvancedSecurityData'] = undefined;
(window as any).AmazonCognitoAdvancedSecurityData = undefined;
});
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Amplify } from '@aws-amplify/core';

import { AuthError } from '../../../src/errors/AuthError';
import { AuthValidationErrorCode } from '../../../src/errors/types/validation';
import { authAPITestParams } from './testUtils/authApiTestParams';
import { confirmSignIn } from '../../../src/providers/cognito/apis/confirmSignIn';
import { RespondToAuthChallengeException } from '../../../src/providers/cognito/types/errors';
import { respondToAuthChallenge } from '../../../src/providers/cognito/utils/clients/CognitoIdentityProvider';
import { signInStore } from '../../../src/providers/cognito/utils/signInStore';

import { getMockError } from './testUtils/data';
import { setUpGetConfig } from './testUtils/setUpGetConfig';
import { signInStore } from '../../../src/providers/cognito/utils/signInStore';
import { authAPITestParams } from './testUtils/authApiTestParams';

jest.mock('@aws-amplify/core', () => ({
...(jest.createMockFromModule('@aws-amplify/core') as object),
Expand All @@ -21,7 +23,7 @@ jest.mock('../../../src/providers/cognito/utils/signInStore');
describe('confirmSignIn API error path cases:', () => {
const challengeName = 'SELECT_MFA_TYPE';
const signInSession = '1234234232';
const username = authAPITestParams.user1.username;
const { username } = authAPITestParams.user1;
// assert mocks
const mockStoreGetState = signInStore.getState as jest.Mock;
const mockRespondToAuthChallenge = respondToAuthChallenge as jest.Mock;
Expand Down
Loading

0 comments on commit 5c6b6f1

Please sign in to comment.