Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cognito): revert re-organization and use @internal instead so that base class is not exported #11056

Merged
merged 8 commits into from
Nov 6, 2020

Conversation

shivlaks
Copy link
Contributor

@shivlaks shivlaks commented Oct 23, 2020

This reverts commit from #10925 which folded all implementations of UserPoolIdentityProviderBase
into a single file.

It was desirable to maintain our original code organization but we also did not want to export the base class
In light of guidance provided in aws/jsii#2159, reverted back to original code organization and added
the @internal decorator on the base class in a private directory


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Oct 23, 2020

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 23, 2020
@shivlaks shivlaks self-assigned this Oct 23, 2020
@shivlaks shivlaks added the @aws-cdk/aws-cognito Related to Amazon Cognito label Oct 23, 2020
@shivlaks
Copy link
Contributor Author

hey @RomainMuller - I added the @internal instead of reorganizing the structure we preferred on UserPoolIdentityProviderBase and UserPoolIdentityProviderBase and UserPoolIdentityProviderProps

when running yarn package, I did verify that neither class is in the TypeScript declaration file, but the compiled
JavaScript still has the UserPoolIdentityProviderBase class:

/**
 * Options to integrate with the various social identity providers.
 *
 * @internal
 */
class UserPoolIdentityProviderBase extends core_1.Resource {
    constructor(scope, id, props) {
        super(scope, id);
        this.props = props;
        props.userPool.registerIdentityProvider(this);
    }
    /**
     * @experimental
     */
    configureAttributeMapping() {
        if (!this.props.attributeMapping) {
            return undefined;
        }
        let mapping = {};
        mapping = Object.entries(this.props.attributeMapping)
            .filter(([k, _]) => k !== 'custom') // 'custom' handled later separately
            .reduce((agg, [k, v]) => {
            return { ...agg, [attr_names_1.StandardAttributeNames[k]]: v.attributeName };
        }, mapping);
        if (this.props.attributeMapping.custom) {
            mapping = Object.entries(this.props.attributeMapping.custom).reduce((agg, [k, v]) => {
                return { ...agg, [k]: v.attributeName };
            }, mapping);
        }
        if (Object.keys(mapping).length === 0) {
            return undefined;
        }
        return mapping;
    }
}
exports.UserPoolIdentityProviderBase = UserPoolIdentityProviderBase;

I'm admittedly unsure about how to verify that the @internal achieves the desired effect. Any pointers/hints would be much appreciated!

@shivlaks shivlaks marked this pull request as ready for review October 23, 2020 07:02
@shivlaks shivlaks marked this pull request as draft October 23, 2020 07:34
@shivlaks
Copy link
Contributor Author

builddown failing on modules that depend on the cognito module with:

$ cdk-build
[2020-10-23T00:35:21.105] [ERROR] jsii/compiler - Compilation errors prevented the JSII assembly from being created
dist/js/package/lib/user-pool-idps/amazon.d.ts:2:10 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderBase'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dist/js/package/lib/user-pool-idps/amazon.d.ts:2:40 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderProps'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dist/js/package/lib/user-pool-idps/facebook.d.ts:2:10 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderBase'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dist/js/package/lib/user-pool-idps/facebook.d.ts:2:40 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderProps'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dist/js/package/lib/user-pool-idps/google.d.ts:2:10 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderBase'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dist/js/package/lib/user-pool-idps/google.d.ts:2:40 - error TS2305: Module '"./base"' has no exported member 'UserPoolIdentityProviderProps'.

2 import { UserPoolIdentityProviderBase, UserPoolIdentityProviderProps } from './base';
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: /Users/shivlaks/code/aws-cdk/node_modules/jsii/bin/jsii --silence-warnings=reserved-word exited with error code 1
Build failed.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@RomainMuller
Copy link
Contributor

This needs aws/jsii#2172

@shivlaks shivlaks marked this pull request as ready for review November 2, 2020 16:34
@shivlaks shivlaks changed the title chore(cognito): revert re-organization and use @internal instead to prevent exporting base class chore(cognito): revert re-organization and use @internal instead so that base class is not exported Nov 2, 2020
@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit dfbf97b into master Nov 6, 2020
@mergify mergify bot deleted the shivlaks/cognito-user-pool-idp-reorg branch November 6, 2020 14:24
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 03f934e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants