Skip to content

Commit

Permalink
chore: resolve most of the comments from cshfang
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Aug 22, 2024
1 parent 37fece1 commit d30b77e
Show file tree
Hide file tree
Showing 38 changed files with 238 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthError } from '../../../../src/errors/AuthError';
import {
getRegionFromIdentityPoolId,
getRegionFromUserPoolId,
} from '../../../../src/foundation/core/parsers/getRegion';
} from '../../../../src/foundation/core/parsers/regionParsers';

describe('getRegionFromIdentityPoolId()', () => {
it('returns the region from the identity pool id', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('cognitoUserPoolTransferHandler', () => {
});

it('adds the disableCacheMiddlewareFactory at module loading', () => {
console.log(mockComposeTransferHandler);
expect(mockComposeTransferHandler).toHaveBeenCalledTimes(1);

const [core, middleware] = mockComposeTransferHandler.mock.calls[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
parseJsonError,
} from '@aws-amplify/core/internals/aws-client-utils';

import { buildEmptyResponseDeserializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/buildEmptyResponseDeserializer';
import { createEmptyResponseDeserializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/createEmptyResponseDeserializer';
import { AuthError } from '../../../../../../../src/errors/AuthError';

jest.mock('@aws-amplify/core/internals/aws-client-utils');

const mockParseJsonError = jest.mocked(parseJsonError);

describe('buildEmptyResponseDeserializer created response deserializer', () => {
const deserializer = buildEmptyResponseDeserializer();
const deserializer = createEmptyResponseDeserializer();

it('returns undefined for 2xx status code', async () => {
const response: HttpResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
parseJsonError,
} from '@aws-amplify/core/internals/aws-client-utils';

import { buildUserPoolDeserializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/buildUserPoolDeserializer';
import { createUserPoolDeserializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/createUserPoolDeserializer';
import { AuthError } from '../../../../../../../src/errors/AuthError';

jest.mock('@aws-amplify/core/internals/aws-client-utils');
Expand All @@ -13,7 +13,7 @@ const mockParseJsonBody = jest.mocked(parseJsonBody);
const mockParseJsonError = jest.mocked(parseJsonError);

describe('buildUserPoolDeserializer created response deserializer', () => {
const deserializer = buildUserPoolDeserializer();
const deserializer = createUserPoolDeserializer();

it('returns body for 2xx status code', async () => {
const expectedBody = { test: 'test' };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';

import { buildUserPoolSerializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/buildUserPoolSerializer';
import { createUserPoolSerializer } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serialization/createUserPoolSerializer';

describe('buildUserPoolSerializer created request serializer', () => {
test.each(['SignUp', 'InitiateAuth', 'RevokeToken'] as const)(
Expand All @@ -10,7 +10,7 @@ describe('buildUserPoolSerializer created request serializer', () => {
const testEndpoint = {
url: new AmplifyUrl('http://test.com'),
};
const serializer = buildUserPoolSerializer(operation);
const serializer = createUserPoolSerializer(operation);
const result = serializer(testInput, testEndpoint);

expect(result).toEqual({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ServiceClientAPIConfig } from '../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/types/ServiceClient';
import { ServiceClientFactoryInput } from '../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/types';

export const mockServiceClientAPIConfig: ServiceClientAPIConfig = {
export const mockServiceClientAPIConfig: ServiceClientFactoryInput = {
endpointResolver: jest.fn() as jest.MockedFunction<
ServiceClientAPIConfig['endpointResolver']
ServiceClientFactoryInput['endpointResolver']
>,
};
2 changes: 1 addition & 1 deletion packages/auth/src/foundation/core/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
export {
getRegionFromUserPoolId,
getRegionFromIdentityPoolId,
} from './getRegion';
} from './regionParsers';
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
// SPDX-License-Identifier: Apache-2.0
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import { ServiceClientAPIConfig } from './types/ServiceClient';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
} from './shared/serialization';
import {
AssociateSoftwareTokenCommandInput,
AssociateSoftwareTokenCommandOutput,
} from './types/Sdk';
ServiceClientFactoryInput,
} from './types';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createAssociateSoftwareTokenClient = (
config: ServiceClientAPIConfig,
config: ServiceClientFactoryInput,
) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<AssociateSoftwareTokenCommandInput>(
createUserPoolSerializer<AssociateSoftwareTokenCommandInput>(
'AssociateSoftwareToken',
),
buildUserPoolDeserializer<AssociateSoftwareTokenCommandOutput>(),
createUserPoolDeserializer<AssociateSoftwareTokenCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/

import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import {
ChangePasswordCommandInput,
ChangePasswordCommandOutput,
} from './types/Sdk';
import { ServiceClientAPIConfig } from './types/ServiceClient';
ServiceClientFactoryInput,
} from './types';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createChangePasswordClient = (config: ServiceClientAPIConfig) =>
export const createChangePasswordClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ChangePasswordCommandInput>('ChangePassword'),
buildUserPoolDeserializer<ChangePasswordCommandOutput>(),
createUserPoolSerializer<ChangePasswordCommandInput>('ChangePassword'),
createUserPoolDeserializer<ChangePasswordCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/

import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import {
ConfirmDeviceCommandInput,
ConfirmDeviceCommandOutput,
} from './types/Sdk';
import { ServiceClientAPIConfig } from './types/ServiceClient';
ServiceClientFactoryInput,
} from './types';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createConfirmDeviceClient = (config: ServiceClientAPIConfig) =>
export const createConfirmDeviceClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ConfirmDeviceCommandInput>('ConfirmDevice'),
buildUserPoolDeserializer<ConfirmDeviceCommandOutput>(),
createUserPoolSerializer<ConfirmDeviceCommandInput>('ConfirmDevice'),
createUserPoolDeserializer<ConfirmDeviceCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
// SPDX-License-Identifier: Apache-2.0
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import { ServiceClientAPIConfig } from './types/ServiceClient';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
} from './shared/serialization';
import {
ConfirmForgotPasswordCommandInput,
ConfirmForgotPasswordCommandOutput,
} from './types/Sdk';
ServiceClientFactoryInput,
} from './types';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createConfirmForgotPasswordClient = (
config: ServiceClientAPIConfig,
config: ServiceClientFactoryInput,
) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ConfirmForgotPasswordCommandInput>(
createUserPoolSerializer<ConfirmForgotPasswordCommandInput>(
'ConfirmForgotPassword',
),
buildUserPoolDeserializer<ConfirmForgotPasswordCommandOutput>(),
createUserPoolDeserializer<ConfirmForgotPasswordCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import {
ConfirmSignUpCommandInput,
ConfirmSignUpCommandOutput,
} from './types/Sdk';
import { ServiceClientAPIConfig } from './types/ServiceClient';
ServiceClientFactoryInput,
} from './types';

export const createConfirmSignUpClient = (config: ServiceClientAPIConfig) =>
export const createConfirmSignUpClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ConfirmSignUpCommandInput>('ConfirmSignUp'),
buildUserPoolDeserializer<ConfirmSignUpCommandOutput>(),
createUserPoolSerializer<ConfirmSignUpCommandInput>('ConfirmSignUp'),
createUserPoolDeserializer<ConfirmSignUpCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
// SPDX-License-Identifier: Apache-2.0
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import { ServiceClientAPIConfig } from './types/ServiceClient';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
} from './shared/serialization';
import {
DeleteUserAttributesCommandInput,
DeleteUserAttributesCommandOutput,
} from './types/Sdk';
ServiceClientFactoryInput,
} from './types';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createDeleteUserAttributesClient = (
config: ServiceClientAPIConfig,
config: ServiceClientFactoryInput,
) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<DeleteUserAttributesCommandInput>(
createUserPoolSerializer<DeleteUserAttributesCommandInput>(
'DeleteUserAttributes',
),
buildUserPoolDeserializer<DeleteUserAttributesCommandOutput>(),
createUserPoolDeserializer<DeleteUserAttributesCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
// SPDX-License-Identifier: Apache-2.0
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import { ServiceClientAPIConfig } from './types/ServiceClient';
import {
DeleteUserCommandInput,
DeleteUserCommandOutput,
ServiceClientFactoryInput,
} from './types';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildEmptyResponseDeserializer,
buildUserPoolSerializer,
createEmptyResponseDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { DeleteUserCommandInput, DeleteUserCommandOutput } from './types/Sdk';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createDeleteUserClient = (config: ServiceClientAPIConfig) =>
export const createDeleteUserClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<DeleteUserCommandInput>('DeleteUser'),
buildEmptyResponseDeserializer<DeleteUserCommandOutput>(),
createUserPoolSerializer<DeleteUserCommandInput>('DeleteUser'),
createEmptyResponseDeserializer<DeleteUserCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/

import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildEmptyResponseDeserializer,
buildUserPoolSerializer,
createEmptyResponseDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { ServiceClientAPIConfig } from './types/ServiceClient';
import {
ForgetDeviceCommandInput,
ForgetDeviceCommandOutput,
} from './types/Sdk';
ServiceClientFactoryInput,
} from './types';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createForgetDeviceClient = (config: ServiceClientAPIConfig) =>
export const createForgetDeviceClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ForgetDeviceCommandInput>('ForgetDevice'),
buildEmptyResponseDeserializer<ForgetDeviceCommandOutput>(),
createUserPoolSerializer<ForgetDeviceCommandInput>('ForgetDevice'),
createEmptyResponseDeserializer<ForgetDeviceCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
// SPDX-License-Identifier: Apache-2.0
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import { ServiceClientAPIConfig } from './types/ServiceClient';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
buildUserPoolDeserializer,
buildUserPoolSerializer,
} from './shared/serialization';
import {
ForgotPasswordCommandInput,
ForgotPasswordCommandOutput,
} from './types/Sdk';
ServiceClientFactoryInput,
} from './types';
import { cognitoUserPoolTransferHandler } from './shared/handler';
import {
createUserPoolDeserializer,
createUserPoolSerializer,
} from './shared/serialization';
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';

export const createForgotPasswordClient = (config: ServiceClientAPIConfig) =>
export const createForgotPasswordClient = (config: ServiceClientFactoryInput) =>
composeServiceApi(
cognitoUserPoolTransferHandler,
buildUserPoolSerializer<ForgotPasswordCommandInput>('ForgotPassword'),
buildUserPoolDeserializer<ForgotPasswordCommandOutput>(),
createUserPoolSerializer<ForgotPasswordCommandInput>('ForgotPassword'),
createUserPoolDeserializer<ForgotPasswordCommandOutput>(),
{
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
...config,
Expand Down
Loading

0 comments on commit d30b77e

Please sign in to comment.