Files
floci/src/main/java
AgustinBertagna 113c7d7e7d feat(appsync): Phase 4 — VTL Engine (#1288)
* feat(appsync): add VTL engine core infrastructure

Add ReturnSignal exception for #return directive, AppSyncVtlResult record
for evaluation results, and ReturnDirective custom Velocity directive.

* feat(appsync): wire AppSyncUtil to VTL context

Add errorList and authTypeValue fields with setters. Change authType()
to return configured value. Change appendError() overloads to accumulate
errors in internal list. Add toJson() exclusion for selectionSetList and
selectionSetGraphQL. Add base64Encode(String) overload.

* feat(appsync): add VTL engine context and evaluator

AppSyncVtlContext builds the  map with all aliases (, ,
, , , , ). AppSyncVtlEngine evaluates VTL
templates using Apache Velocity with AppSync-specific context variables,
custom #return directive, and VtlErrorSignal/ReturnSignal handling.

* chore(appsync): add GraalVM reflection config for VTL engine classes

Register AppSyncVtlEngine, AppSyncVtlContext, ReturnDirective, and
all Phase 3 util classes for native image reflection.

* test(appsync): add VTL engine unit tests

89 tests across categories A-J covering context variables, util methods,
error handling, appendError accumulation, #return directive, authType,
velocity directives, pipeline simulation, and edge cases. Validates
AWS AppSync behavior: null references render as literal text, #return
clears buffer, .error() clears output, var silent references.

* fix(appsync): set $context.prev to null for unit resolvers

AWS AppSync does not initialize $context.prev in unit (non-pipeline)
resolvers. It is null, not an empty map. Accessing $ctx.prev in a unit
resolver renders the literal text (e.g. "$ctx.prev") in non-strict
Velocity mode, matching AWS behavior.

* fix(appsync): accept Object in $util.qr() and $util.quiet()

AWS AppSync defines qr/quiet as accepting any Object, not just String.
The previous String signature caused method resolution failures in
Velocity when non-String values (Integer, Boolean, List, Map, or method
return values like Map.put) were passed. Changed to Object to match AWS.

* fix(appsync): remove dead exception handling in VTL engine

Velocity wraps exceptions thrown by method calls inside a generic
Exception, but exceptions thrown by custom directives (ReturnSignal)
propagate directly. The catch(VtlErrorSignal) and ReturnSignal unwrap
branches were dead code. Simplified to only unwrap VtlErrorSignal from
wrapped method exceptions.

* test(appsync): update and add tests for AWS parity and full coverage

Updates:
- j11: $context.prev default is now null (not empty map)
- j11b/j11c: undefined prev renders as literal text
- qr/quiet: expanded with Integer, Boolean, List, Map arguments

New tests for 100% coverage:
- c21: $util.transform accessible from VTL
- e6: appendError with errorInfo (4-arg overload)
- getTransform_returnsInstance: getter coverage
- escapeJavaScript_controlCharDefault: control char <0x20 branch
- toJson_mapWithFieldNameOnlyDoesNotFilter: fieldName-only branch
- toJson_serializationFailureReturnsNull: JsonProcessingException catch
- appendError_withErrorInfo: errorInfo non-null branch
2026-06-28 17:25:49 -05:00
..