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

Lex v2 integration #17

Merged
merged 61 commits into from
Jul 8, 2021
Merged

Lex v2 integration #17

merged 61 commits into from
Jul 8, 2021

Conversation

tehzwen
Copy link
Contributor

@tehzwen tehzwen commented Jul 7, 2021

This is a big one! If everyone can please have look at it I'd appreciate it!

  • Added Lex V2 Resources
  • Removed V1 Unused resources
  • Added tests
  • Updated documentation
  • Project management changes etc

tehzwen and others added 30 commits June 7, 2021 09:16
* Add handler for bot create
* Remove handlers from library as these will be defined in custom stack
* Edit bot class to JSON stringify package as without this, errors with integers in properties for custom resource
* Add intent and locale classes for custom resources
* Add slot and slottype custom resource classes
    * Add bot alias custom resource class
* Update classes to provide reference to the custom resource created in them
* Update interfaces to use proper Ids as they should
* Add V2 resources for lex intent priorities
* Update data types for new resources
* Move files around for more logical organization of resources
* Change CDK stacks to be more dynamic and less hardcoded/rigid
* Start updating Documentation (WIP)
* Add documentation for v2
* Add eslint to project and fix linting errors/warnings
* Setup nock as an HTTP stubbing library so our test suite doesn't
  make any live requests.
* Setup some basic foundational helpers for test fixtures so we
  can easily reference test events.
* Setup jest with a global init script so we can prep our test
  suite execution.
* Enable JSInterop config for typescript so that we can properly
  reference JS modules from our TS code.
* Enable JSON module resolution in TypeScript so we can easily
  reference test fixtures.
* Make the Lex V2 Bot handler defined as a module so node can use
  import/export.
* Write test expectations for the bot v2 create action. We'll
  need to continue writing tests for the others.
feat(test-coverage): Bot V2 Handler
* Add check for V2 handlers and use NodejsFunction as default for them to automatically build lambda including aws sdk v3
* Use a globalSetup script to configure the test suite instead as
  that's a more common pattern.
* Add tests for the `update` and  `delete` actions as well as
  error cases.
* Fix an issue in our error handling where we would re-throw the
  error as a new Error instance (losing the original error type
  in the process).
* Remove a variable declaration that was not needed.
chore(test-coverage): Bot V2 Handler
* Add test coverage for intent v2 handler
* Update readme with updated information on deployment of resources stack
* Add full test coverage for the lex v2 slot handler implementation.
* Remove the `try/catch` blocks for the v2 slot handler and the
  v2 bot handler as it wasn't really necessary. We were logging the
  error to STDOUT then re-throwing the error. We'll get a stacktrace
  by default when an error is thrown in the first place.
* Refactor the v2 bot handler to use `switch/case` for consistency
  with other custom resource handlers.
* Ensure we wrap switch statement cases with curly braces to ensure
  we define a lexical scope for the case. This prevents the
  interpreter from thinking it's declaring the same constant
  multiple times when parsing code (See [1]).
* Build a simple and basic "logger" that can be disabled for the
  test suite by setting the `TEST=1` environment variable. We could
  include a package like `pino`, but this is a very simple approach
  that reduces complexity for our use-case.

[1]: https://stackoverflow.com/questions/35746371/error-duplicate-const-declaration-in-switch-case-statement/35746467#35746467
* Prefer the use of the ES6 spread (`...`) operator to clone
  AWS SDK parameters rather than modify a shared `params` object.
chore(test-coverage): Slot Resources
chore(test-coverage): Intent V2 Handler
* Add full test coverage for the Lex V2 Slot Type custom resource
  handler.
* Refactor the handler to include a lexical scope (curly braces)
  for switch statement cases so that we can declare the `response`
  constant for each case.
* Prefer the use of the spread (`...`) operator for building
  SDK requests so we don't need to mutate a shared object.
* Update test description to match the actual test case.
chore(test-coverage): Slot Type Resources
tehzwen and others added 20 commits July 6, 2021 09:46
chore(test-coverage): Intent Priority Resources
chore(test-coverage): Bot Version V2 Handler
* Write tests for CDK classes (not the stacks)
* Rename some folders to use consistent casing
…m-resources into test-coverage-cdk-classes-bot-version

* Write CDK class test for lex-bot-version
…sion

Test coverage cdk classes bot version
* Delete all unused v1 resources and handlers
* Update documentation to reflect change
* To be consistent with our existing node applications, we're
  going to use yarn over npm for package management when developing.
* Remove scripts that were explicitly referencing `npm`. It looks like
  most of these scripts were executing git commands and performing
  lint orior to release of a new version on npm. We should be able
  to release manually when necessary.
* Add a LICENSE file and specify the MIT license!
* Remove the package-lock.json in favour of yarn.lock.
* Fix a test that was using `console.error` to output debug data.
* Alphabetize the IAM role actions used for custom resource
  handler lambda functions.
* Remove the `iam:PassRole` action from the first policy on the
  IAM role as we add it in a separate policy immediately after.
* Reduce the constraint on `@aws-cdk/*` package resolution using
  the caret (`^`) directive. We want to have the package manager
  resolve to the same version that is specified in the host
  application.
chore(yarn): Yarn for Development
* Add tests for cdk base stack and custom resources stack
* Update CDK test to look for new IAM Policy
* Add CDK Assert 1.111 to project for testing
* Remove duplicate license
🐘
This PR adds a unit tests ci for gh actions to lint then run tests

- Added eslint config
- Added ci file
- Fixed simple linting errors, quotes, trailing commas etc
- Added eslint disable rules in files where needed

ADO LINK: https://dev.azure.com/AMA-Ent/AMA-Ent/_boards/board/t/Red%20Team/Stories/?workitem=25882
* The custom resource provider function was always exporting
  with a `-intentProvider` prefix. There's already a reosurce
  type namespace in the export name, so we do need this suffix.
* Set coverage thresholds for lines and statements to 100% 🚀
* Add `esbuild` as a dev dependency so that CDK doesn't try to
  spin up a local docker container when bundling the functions
  for the test suite.
ADO-25882 - Lex V2 Provisioning Tooling
@tehzwen tehzwen requested a review from a team as a code owner July 7, 2021 20:26
jessedoyle
jessedoyle previously approved these changes Jul 7, 2021
Copy link
Contributor

@jessedoyle jessedoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Copy link
Member

@mvandenbeuken mvandenbeuken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good team. Just a few comments.

__fixtures__/v2/events/bot/update.json Outdated Show resolved Hide resolved
__fixtures__/v2/events/intent/create.json Outdated Show resolved Hide resolved
src/v2/handlers/lex-bot-alias/package.json Show resolved Hide resolved
src/v2/handlers/lex-bot-locale/index.js Outdated Show resolved Hide resolved
src/v2/handlers/lex-intent/index.js Outdated Show resolved Hide resolved
* Remove developer names from all test fixtures.
* Add in sanitized fixtures.
* Remove package-lock for all handlers and add yarn.lock instead
* Update intent handler to reflect common style of other handlers, remove unnecessary comment
Copy link
Member

@mvandenbeuken mvandenbeuken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work all! Approved!

@tehzwen tehzwen merged commit 2007adb into master Jul 8, 2021
@tehzwen tehzwen deleted the lex-v2-integration branch July 8, 2021 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants