amplify-category-api
amplify-category-api copied to clipboard
refactor: allow creation of JS resolvers with S3 assets
[!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 https://github.com/aws-amplify/amplify-category-api/pull/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
addToSlotto takeFunctionRuntimeTemplate(reference) -
Adds
S3MappingJSResolverFunctionCodeclass for JS runtime specificS3MappingTemplateProvider(reference) -
Adds
MappingTemplate.s3MappingFunctionCodeFromStringfunction to allow creation of (S3) asset based JS runtime resolver functions. (reference) -
Updates
TransformerResolverAPIs and implementation to accept newFunctionRuntimeTemplatetype. -
Updates
TransformerResolverAPI callsites in various transformers for newFunctionRuntimeTemplatetype. 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
- [x] PR description included
- [x]
yarn testpasses - [x] 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.