Skip to content

Commit

Permalink
Merge branch 'main' into api-docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP authored Nov 29, 2022
2 parents 40fbab5 + fa7d6c6 commit 275b737
Show file tree
Hide file tree
Showing 9 changed files with 636 additions and 27 deletions.
70 changes: 68 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ commands:
browser:
type: string
default: ''
amplifyjs_dir:
# optional - dir to amplify js workspace
type: string
default: ''
steps:
- run:
name: 'Install << parameters.test_name >> sample'
Expand All @@ -118,12 +122,12 @@ commands:
name: 'Run cypress tests for << parameters.test_name >> sample on dev'
command: |
cd ~/amplify-js-samples-staging
~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> dev' -n 3
~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> dev << parameters.amplifyjs_dir >>' -n 3
- run:
name: 'Run cypress tests for << parameters.test_name >> sample on prod'
command: |
cd ~/amplify-js-samples-staging
~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> prod' -n 3
~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> prod << parameters.amplifyjs_dir >>' -n 3
- store_artifacts:
path: ~/amplify-js-samples-staging/cypress/videos
- store_artifacts:
Expand Down Expand Up @@ -483,6 +487,23 @@ jobs:
sample_name: amplify-authenticator
spec: custom-authenticator
browser: << parameters.browser >>
integ_javascript_auth:
parameters:
browser:
type: string
executor: js-test-executor
<<: *test_env_vars
working_directory: ~/amplify-js-samples-staging/samples
steps:
- prepare_test_env
- integ_test_js:
test_name: 'JavaScript Auth CDN'
framework: javascript
category: auth
sample_name: auth-cdn
spec: auth-cdn
browser: << parameters.browser >>
amplifyjs_dir: ~/amplify-js
integ_vue_auth:
parameters:
browser:
Expand Down Expand Up @@ -1109,6 +1130,31 @@ jobs:
test_name: 'Token revocation'
category: 'auth'
spec: 'token-revocation'
integ_javascript_geo:
parameters:
browser:
type: string
executor: js-test-executor
<<: *test_env_vars
working_directory: ~/amplify-js-samples-staging/samples
steps:
- prepare_test_env
- integ_test_js:
test_name: 'Display Map'
framework: javascript
category: geo
sample_name: display-map-static
spec: display-map-static
browser: << parameters.browser >>
amplifyjs_dir: ~/amplify-js
- integ_test_js:
test_name: 'Search Outside Map'
framework: javascript
category: geo
sample_name: search-outside-map-static
spec: search-outside-map-static
browser: << parameters.browser >>
amplifyjs_dir: ~/amplify-js
integ_react_geo:
parameters:
browser:
Expand Down Expand Up @@ -1462,6 +1508,15 @@ workflows:
matrix:
parameters:
<<: *test_browsers
- integ_javascript_auth:
requires:
- integ_setup
- build
filters:
<<: *releasable_branches
matrix:
parameters:
<<: *test_browsers
- integ_react_datastore:
requires:
- integ_setup
Expand Down Expand Up @@ -1729,6 +1784,15 @@ workflows:
# matrix:
# parameters:
# <<: *test_browsers
- integ_javascript_geo:
requires:
- integ_setup
- build
filters:
<<: *releasable_branches
matrix:
parameters:
browser: [chrome]
- integ_react_geo:
requires:
- integ_setup
Expand Down Expand Up @@ -1848,6 +1912,7 @@ workflows:
- integ_react_auth_1
- integ_react_auth_2
- integ_angular_auth
# - integ_javascript_auth # TODO: enable it when CDN deployment is automated
- integ_vue_auth
- integ_rn_ios_storage
- integ_rn_ios_storage_multipart_progress
Expand All @@ -1860,6 +1925,7 @@ workflows:
# - integ_duplicate_packages
- integ_auth_test_cypress_no_ui
- integ_react_graphql_api
# - integ_javascript_geo # TODO: enable it when CDN deployment is automated
- integ_react_geo
- integ_next_datastore_owner_auth
- integ_react_datastore_custom_pk_unconnected_models
Expand Down
26 changes: 13 additions & 13 deletions packages/aws-amplify-react-native/src/Auth/AuthPiece.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

import React from 'react';
import { Keyboard } from 'react-native';
import { Auth, Logger, JS, I18n } from 'aws-amplify';
import { Auth, Logger, I18n } from 'aws-amplify';
import { isEmpty } from '@aws-amplify/core';

import AmplifyTheme, { AmplifyThemeType } from '../AmplifyTheme';
import AmplifyMessageMap from '../AmplifyMessageMap';
import { FormField, PhoneField } from '../AmplifyUI';
import TEST_ID from '../AmplifyTestIDs';
import { OnStateChangeType, UsernameAttributesType } from '../../types';
import { setTestId } from '../Utils'
import { setTestId } from '../Utils';

const logger = new Logger('AuthPiece');

Expand Down Expand Up @@ -48,10 +49,10 @@ export interface IAuthPieceState {
username?: string;
}

export default class AuthPiece<
Props extends IAuthPieceProps,
State extends IAuthPieceState
> extends React.Component<Props, State> {
export default class AuthPiece<Props extends IAuthPieceProps, State extends IAuthPieceState> extends React.Component<
Props,
State
> {
_isHidden: boolean;
_validAuthStates: String[];

Expand Down Expand Up @@ -86,7 +87,7 @@ export default class AuthPiece<
return (
<FormField
theme={theme}
onChangeText={text => this.setState({ email: text })}
onChangeText={(text) => this.setState({ email: text })}
label={I18n.get('Email')}
placeholder={I18n.get('Enter your email')}
required={true}
Expand All @@ -99,7 +100,7 @@ export default class AuthPiece<
<PhoneField
theme={theme}
key={'phone_number'}
onChangeText={text => this.setState({ phone_number: text })}
onChangeText={(text) => this.setState({ phone_number: text })}
label={I18n.get('Phone Number')}
placeholder={I18n.get('Enter your phone number')}
keyboardType="phone-pad"
Expand All @@ -112,7 +113,7 @@ export default class AuthPiece<
return (
<FormField
theme={theme}
onChangeText={text => this.setState({ username: text })}
onChangeText={(text) => this.setState({ username: text })}
label={I18n.get(this.getUsernameLabel())}
placeholder={I18n.get('Enter your username')}
required={true}
Expand All @@ -135,9 +136,9 @@ export default class AuthPiece<
}

checkContact(user: any) {
Auth.verifiedContact(user).then(data => {
Auth.verifiedContact(user).then((data) => {
logger.debug('verified user attributes', data);
if (!JS.isEmpty(data.verified)) {
if (!isEmpty(data.verified)) {
this.changeState('signedIn', user);
} else {
user = Object.assign(user, data);
Expand All @@ -158,8 +159,7 @@ export default class AuthPiece<
msg = JSON.stringify(err);
}

const map =
this.props.errorMessage || this.props.messageMap || AmplifyMessageMap;
const map = this.props.errorMessage || this.props.messageMap || AmplifyMessageMap;
msg = typeof map === 'string' ? map : map(msg);
this.setState({ error: msg });
Keyboard.dismiss();
Expand Down
6 changes: 4 additions & 2 deletions packages/aws-amplify-react-native/src/Auth/Authenticator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
*/

import React, { FC, ReactNode } from 'react';
import { Auth, Analytics, Logger, Hub, JS } from 'aws-amplify';
import { Auth, Analytics, Logger, Hub } from 'aws-amplify';
import { isEmpty } from '@aws-amplify/core';

import AmplifyTheme, { AmplifyThemeType } from '../AmplifyTheme';
import AmplifyMessageMap from '../AmplifyMessageMap';
import { Container } from '../AmplifyUI';
Expand Down Expand Up @@ -157,7 +159,7 @@ export default class Authenticator extends React.Component<IAuthenticatorProps,
try {
const data = await Auth.verifiedContact(user);
logger.debug('verified user attributes', data);
if (!JS.isEmpty(data.verified)) {
if (!isEmpty(data.verified)) {
this.handleStateChange('signedIn', user);
} else {
user = Object.assign(user, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import React from 'react';
import { View } from 'react-native';
import { Auth, I18n, Logger, JS } from 'aws-amplify';
import { Auth, I18n, Logger } from 'aws-amplify';
import {
AmplifyButton,
FormField,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify-react-native/src/Auth/withOAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Linking } from 'react-native';

import { Logger, Hub } from '@aws-amplify/core';
import {
default as Auth,
Auth,
CognitoHostedUIIdentityProvider,
} from '@aws-amplify/auth';

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify-react-native/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { default as AmplifyCore, I18n } from 'aws-amplify';
import { Amplify as AmplifyCore, I18n } from 'aws-amplify';
import dict from './AmplifyI18n';

export { default as AmplifyTheme } from './AmplifyTheme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,17 @@ export class CommonSQLiteAdapter implements StorageAdapter {
);
}

return records.map(record =>
this.modelInstanceCreator(modelConstructor, record)
);
// Remove related-model fields. They're all `null` in the database,
// and any that happen to be required will result in a false validation
// error when DataStore attempts to initialize with `null`.
// These fields aren't actually needed here. DataStore will use the FK's
// from the schema model.
return records.map(record => {
for (const r of relations) {
delete record[r.fieldName];
}
return this.modelInstanceCreator(modelConstructor, record);
});
}

async query<T extends PersistentModel>(
Expand Down
Loading

0 comments on commit 275b737

Please sign in to comment.