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

refactor: allow creation of JS resolvers with S3 assets #2884

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

atierian
Copy link
Member

@atierian atierian commented Sep 18, 2024

Important

No snapshots were harmed in the making of this PR.
No behavioral changes are included in this PR. This is prerequisite work to allow S3 asset JS resolver functions.

This is followup work to #2812.

Description of changes

  • Adds a few types to represent VTL and JS runtime mapping templates (reference).
export type VTLRuntimeTemplate = { requestMappingTemplate?: MappingTemplateProvider; responseMappingTemplate?: MappingTemplateProvider };
export type JSRuntimeTemplate = { codeMappingTemplate: MappingTemplateProvider };
export type FunctionRuntimeTemplate = VTLRuntimeTemplate | JSRuntimeTemplate;
  • Updates addToSlot to take FunctionRuntimeTemplate (reference)

  • Adds S3MappingJSResolverFunctionCode class for JS runtime specific S3MappingTemplateProvider (reference)

  • Adds MappingTemplate.s3MappingFunctionCodeFromString function to allow creation of (S3) asset based JS runtime resolver functions. (reference)

  • Updates TransformerResolver APIs and implementation to accept new FunctionRuntimeTemplate type.

  • Updates TransformerResolver API callsites in various transformers for new FunctionRuntimeTemplate type. See commits for individual changes made to each transformer. Commit names follow the format "update <name>-transformer for FunctionRuntimeTemplate input" for reviewing changes in isolation.

  • Updates conversation and generation transformers to use JSRuntimeTemplate.

Note

I recommend conducting a very surface level review of the conversation and generation changes. This PR is a prerequisite to two follow up PRs (for conversation and generation respectively) that migrate to using S3 asset based resolver functions. The majority of the conversation and generation transformer specific changes in this PR are again changed in these subsequent PRs. This was done to isolate the changes in the PR as much as possible, while not breaking the conversation and generation transformers.

CDK / CloudFormation Parameters Changed

N/A

Issue #, if available

N/A

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Any CDK or CloudFormation parameter changes are called out explicitly

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

@atierian atierian changed the title refactor: allow creation of JS resolvers with via S3 Assets refactor: allow creation of JS resolvers with S3 assets Sep 18, 2024
@atierian atierian marked this pull request as ready for review September 18, 2024 23:05
@atierian atierian requested review from a team as code owners September 18, 2024 23:05
@atierian atierian marked this pull request as draft September 19, 2024 13:49
@atierian
Copy link
Member Author

Converted to draft while I explore a lower impact alternative.

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.

1 participant