mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(appsync): Phase 3 — $util runtime library for VTL resolvers (#1223)
* test(appsync): add remaining SDK tests and fix listDomainNames field name
- Add 4 SDK tests: getIntrospectionSchema, listDomainNames, getFunction, listResolversByFunction
- Fix listDomainNames response field from 'domainNames' to 'domainNameConfigs' (AWS SDK v2 expects domainNameConfigs)
- Update integration test assertion to match corrected field name
* feat(appsync): add $util runtime library for VTL resolvers
Standalone utility library matching AWS AppSync $util namespace.
Validated against official AWS AppSync documentation.
Classes:
- VtlErrorSignal: exception for $util.error() and $util.unauthorized()
- AppSyncUtil: top-level $util with error/validate/type-check methods
- StrUtil: $util.str (toUpper, toLower, toReplace, normalize)
- TimeUtil: $util.time (12 methods, epochMilliSeconds-based per AWS)
- MathUtil: $util.math (roundNum, minVal, maxVal, randomDouble, randomWithinRange)
- DynamoDbUtil: $util.dynamodb (24 methods: value + JSON variants)
- TransformUtil: $util.transform (DynamoDB filter, Elasticsearch DSL, subscription filter)
- ListUtil: $util.list (copyAndRetainAll, copyAndRemoveAll, sortList)
- MapUtil: $util.map (copyAndRetainAllKeys, copyAndRemoveAllKeys)
* test(appsync): add unit tests for $util runtime library
234 test cases covering all $util methods with edge cases:
- AppSyncUtilTest: root methods, error, validate, type checks (85 tests)
- DynamoDbUtilTest: DynamoDB attribute value conversion (47 tests)
- StrUtilTest: string operations (21 tests)
- TimeUtilTest: time operations (21 tests)
- MathUtilTest: math operations (19 tests)
- ListUtilTest: list operations (17 tests)
- TransformUtilTest: filter/DSL conversion (12 tests)
- MapUtilTest: map operations (12 tests)
* fix(appsync): fix DynamoDbUtil *Json methods and refactor utils
- Fix 10 *Json methods to return JSON String instead of Map
- Add private helpers: toJson(Map), base64Encode(String) to DynamoDbUtil
- Extract parseInput(Object) helper in TransformUtil to remove duplication
- Chain qr() to quiet() in AppSyncUtil
- Chain validate() overloads in AppSyncUtil
- Update tests to verify *Json methods return correct JSON strings
* fix(appsync): address review feedback on $util methods
- toMapValues: return inner map without M wrapper (matches AWS: toMapValues = toMap.get("M"))
- toBinary/toBinarySet: wrap input as-is, don't re-encode base64
- str.normalize: use Unicode normalization (NFC/NFD/NFKC/NFKD) instead of whitespace collapse
- typeOf: return exact AWS values (Null/Number/String/Map/List/Boolean/Object)
- unauthorized: errorType 'Unauthorized' not 'UnauthorizedException'
- nowISO8601: always include 3 fractional digits per AWS format
- Mark transform.* methods as not-yet-implemented (complex expression building)
- Update all affected tests
* fix(appsync): change default errorType from UnknownError to Unknown
Research confirms AWS AppSync uses 'Unknown' as default errorType when
$util.error(message) is called without errorType argument.
* chore(appsync): remove dead base64Encode helper from DynamoDbUtil
This commit is contained in:
1 parent
61c3a07199
commit
e20f7d83d2
20 files changed
+2402
-2
No files matched your search
@@ -875,6 +875,76 @@ class AppSyncTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
// ── SDK Coverage Gaps ─────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
@Order(116)
|
||||
void getIntrospectionSchema() {
|
||||
GetIntrospectionSchemaResponse resp = client.getIntrospectionSchema(
|
||||
GetIntrospectionSchemaRequest.builder()
|
||||
.apiId(apiId)
|
||||
.format("SDL")
|
||||
.build());
|
||||
|
||||
assertThat(resp.schema()).isNotNull();
|
||||
String schema = resp.schema().asUtf8String();
|
||||
assertThat(schema).contains("type Query");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(117)
|
||||
void listDomainNames() {
|
||||
CreateDomainNameResponse created = client.createDomainName(
|
||||
CreateDomainNameRequest.builder()
|
||||
.domainName("list-test-" + java.util.UUID.randomUUID().toString().substring(0, 8) + ".example.com")
|
||||
.certificateArn("arn:aws:acm:us-east-1:000000000000:certificate/test")
|
||||
.build());
|
||||
|
||||
ListDomainNamesResponse resp = client.listDomainNames(
|
||||
ListDomainNamesRequest.builder()
|
||||
.build());
|
||||
|
||||
assertThat(resp.domainNameConfigs()).isNotEmpty();
|
||||
|
||||
client.deleteDomainName(DeleteDomainNameRequest.builder()
|
||||
.domainName(created.domainNameConfig().domainName())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(118)
|
||||
void getFunction() {
|
||||
String fnId = client.listFunctions(ListFunctionsRequest.builder()
|
||||
.apiId(apiId)
|
||||
.build())
|
||||
.functions().get(0).functionId();
|
||||
|
||||
GetFunctionResponse resp = client.getFunction(GetFunctionRequest.builder()
|
||||
.apiId(apiId)
|
||||
.functionId(fnId)
|
||||
.build());
|
||||
|
||||
assertThat(resp.functionConfiguration()).isNotNull();
|
||||
assertThat(resp.functionConfiguration().functionId()).isEqualTo(fnId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(119)
|
||||
void listResolversByFunction() {
|
||||
String fnId = client.listFunctions(ListFunctionsRequest.builder()
|
||||
.apiId(apiId)
|
||||
.build())
|
||||
.functions().get(0).functionId();
|
||||
|
||||
ListResolversByFunctionResponse resp = client.listResolversByFunction(
|
||||
ListResolversByFunctionRequest.builder()
|
||||
.apiId(apiId)
|
||||
.functionId(fnId)
|
||||
.build());
|
||||
|
||||
assertThat(resp).isNotNull();
|
||||
}
|
||||
|
||||
// ── Error Handling ─────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user