Skip to content

Commit

Permalink
chore: Sync console-preview with next/main (#12311)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Oct 16, 2023
2 parents 5a31ca1 + af3dbdd commit 8f82e46
Show file tree
Hide file tree
Showing 19 changed files with 660 additions and 706 deletions.
1,066 changes: 533 additions & 533 deletions .github/integ-config/integ-all.yml

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions .github/workflows/callable-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,32 @@ jobs:
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
retry_count: ${{ matrix.integ-config.retry_count || 3 }}

# e2e-test-runner-headless:
# name: E2E test runnner_headless
# needs: e2e-prep
# secrets: inherit
# strategy:
# matrix:
# integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config-headless) }}
# fail-fast: false
# uses: ./.github/workflows/callable-e2e-test-headless.yml
# with:
# test_name: ${{ matrix.integ-config.test_name }}
# category: ${{ matrix.integ-config.category }}
# spec: ${{ matrix.integ-config.spec || '' }}
# timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
# retry_count: ${{ matrix.integ-config.retry_count || 3 }}
e2e-test-runner-headless:
name: E2E test runnner_headless
needs: e2e-prep
secrets: inherit
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config-headless) }}
fail-fast: false
uses: ./.github/workflows/callable-e2e-test-headless.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
category: ${{ matrix.integ-config.category }}
spec: ${{ matrix.integ-config.spec || '' }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
retry_count: ${{ matrix.integ-config.retry_count || 3 }}

# detox-e2e-test-runner:
# name: E2E test runner
# needs: e2e-prep
# strategy:
# matrix:
# integ-config: ${{ fromJson(needs.e2e-prep.outputs.detox-integ-config) }}
# fail-fast: false
# secrets: inherit
# uses: ./.github/workflows/callable-e2e-test-detox.yml
# with:
# test_name: ${{ matrix.integ-config.test_name }}
# working_directory: ${{ matrix.integ-config.working_directory }}
# timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 45 }}
detox-e2e-test-runner:
name: E2E test runner
needs: e2e-prep
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.detox-integ-config) }}
fail-fast: false
secrets: inherit
uses: ./.github/workflows/callable-e2e-test-detox.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
working_directory: ${{ matrix.integ-config.working_directory }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 45 }}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SERVICE_NAME = 'cognito-idp';
*/
const endpointResolver = ({ region }: EndpointResolverOptions) => {
const authConfig = Amplify.getConfig().Auth?.Cognito;
const customURL = authConfig?.endpoint;
const customURL = authConfig?.userPoolEndpoint;
const defaultURL = new AmplifyUrl(
`https://${SERVICE_NAME}.${region}.${getDnsSuffix(region)}`
);
Expand Down
1 change: 1 addition & 0 deletions packages/aws-amplify/__tests__/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('aws-amplify Exports', () => {
Array [
"Hub",
"I18n",
"ServiceWorker",
]
`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/*
This file maps exports from `aws-amplify/utils`.
*/
export { Hub, I18n } from '@aws-amplify/core';
export { Hub, I18n, ServiceWorker } from '@aws-amplify/core';
3 changes: 2 additions & 1 deletion packages/core/__tests__/ServiceWorker.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AmplifyError, ServiceWorker } from '../src/libraryUtils';
import { AmplifyError } from '../src/libraryUtils';
import { ServiceWorker } from '../src';
import { ServiceWorkerErrorCode } from '../src/ServiceWorker/errorHelpers';

describe('ServiceWorker test', () => {
Expand Down
106 changes: 0 additions & 106 deletions packages/core/src/Amplify.ts

This file was deleted.

37 changes: 20 additions & 17 deletions packages/core/src/ServiceWorker/ServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

import { ConsoleLogger as Logger } from '../Logger';
import { isBrowser } from '../utils';
import { Amplify } from '../Amplify';
import { AmplifyError } from '../errors';
import { assert, ServiceWorkerErrorCode } from './errorHelpers';
import { record } from '../providers/pinpoint';
import { Amplify, fetchAuthSession } from '../singleton';

/**
* Provides a means to registering a service worker in the browser
* and communicating with it via postMessage events.
Expand Down Expand Up @@ -205,15 +207,25 @@ export class ServiceWorkerClass {
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state
**/
_setupListeners() {
this.serviceWorker.addEventListener('statechange', event => {
this.serviceWorker.addEventListener('statechange', async event => {
const currentState = this.serviceWorker.state;
this._logger.debug(`ServiceWorker statechange: ${currentState}`);
Amplify.Analytics;
if (isAmplifyWithAnalytics(Amplify)) {
(Amplify as AmplifyWithAnalytics).Analytics.record({
name: 'ServiceWorker',
attributes: {
state: currentState,

const { appId, region } = Amplify.getConfig().Analytics?.Pinpoint ?? {};
const { credentials } = await fetchAuthSession();

if (appId && region && credentials) {
// Pinpoint is configured, record an event
record({
appId,
region,
category: 'Core',
credentials,
event: {
name: 'ServiceWorker',
attributes: {
state: currentState,
},
},
});
}
Expand All @@ -223,12 +235,3 @@ export class ServiceWorkerClass {
});
}
}

type AmplifyWithAnalytics = {
Analytics: {
record: Function;
};
};
function isAmplifyWithAnalytics(amplify: any): amplify is AmplifyWithAnalytics {
return amplify.Analytics && typeof amplify.Analytics.record === 'function';
}
12 changes: 0 additions & 12 deletions packages/core/src/ServiceWorker/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/**
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ export { Cache } from './Cache';

// Internationalization utilities
export { I18n } from './I18n';

// Service worker
export { ServiceWorker } from './ServiceWorker';
3 changes: 0 additions & 3 deletions packages/core/src/libraryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ export {
} from './Platform/types';
export { setCustomUserAgent } from './Platform/customUserAgent';

// Service worker
export { ServiceWorker } from './ServiceWorker';

// Other utilities & constants
export { BackgroundProcessManager } from './BackgroundProcessManager';
export { Mutex } from './Mutex';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/providers/pinpoint/types/pinpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UserProfile } from '../../../types';

export type SupportedCategory =
| 'Analytics'
| 'Core'
| 'InAppMessaging'
| 'PushNotification';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/singleton/Auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ export type AuthIdentityPoolConfig = {
Cognito: CognitoIdentityPoolConfig & {
userPoolClientId?: never;
userPoolId?: never;
userPoolEndpoint?: never;
loginWith?: never;
signUpVerificationMethod?: never;
userAttributes?: never;
mfa?: never;
passwordFormat?: never;
endpoint?: never;
};
};

Expand All @@ -137,6 +137,7 @@ export type AuthUserPoolConfig = {
export type CognitoUserPoolConfig = {
userPoolClientId: string;
userPoolId: string;
userPoolEndpoint?: string;
signUpVerificationMethod?: 'code' | 'link';
loginWith?: {
oauth?: OAuthConfig;
Expand All @@ -157,7 +158,6 @@ export type CognitoUserPoolConfig = {
requireNumbers?: boolean;
requireSpecialCharacters?: boolean;
};
endpoint?: string;
};

export type OAuthConfig = {
Expand Down
4 changes: 3 additions & 1 deletion packages/notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
"files": [
"lib",
"lib-esm",
"src"
"src",
"in-app-messaging",
"push-notifications"
],
"dependencies": {
"lodash": "^4.17.21"
Expand Down
12 changes: 12 additions & 0 deletions packages/notifications/src/inAppMessaging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ export {
onMessageDismissed,
onMessageActionTaken,
notifyMessageInteraction,
IdentifyUserInput,
DispatchEventInput,
SetConflictHandlerInput,
OnMessageActionTakenInput,
OnMessageDismissedInput,
OnMessageDisplayedInput,
OnMessageReceivedInput,
NotifyMessageInteractionInput,
OnMessageReceivedOutput,
OnMessageActionTakenOutput,
OnMessageDismissedOutput,
OnMessageDisplayedOutput,
} from './providers/pinpoint';
25 changes: 24 additions & 1 deletion packages/notifications/src/inAppMessaging/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,27 @@ export {
onMessageDismissed,
onMessageActionTaken,
notifyMessageInteraction,
} from './pinpoint/apis';
IdentifyUserInput,
DispatchEventInput,
SetConflictHandlerInput,
OnMessageActionTakenInput,
OnMessageDismissedInput,
OnMessageDisplayedInput,
OnMessageReceivedInput,
NotifyMessageInteractionInput,
OnMessageReceivedOutput,
OnMessageActionTakenOutput,
OnMessageDismissedOutput,
OnMessageDisplayedOutput,
} from './pinpoint';

export {
InAppMessage,
InAppMessageAction,
InAppMessageContent,
InAppMessageLayout,
InAppMessageTextAlign,
InAppMessageButton,
InAppMessageImage,
InAppMessageStyle,
} from '../types';
Loading

0 comments on commit 8f82e46

Please sign in to comment.