Skip to content

feat(client): add typed DynamoClient with DI and integration tests#90

Open
j-d-ha wants to merge 27 commits intomainfrom
feature/add-client
Open

feat(client): add typed DynamoClient with DI and integration tests#90
j-d-ha wants to merge 27 commits intomainfrom
feature/add-client

Conversation

@j-d-ha
Copy link
Copy Markdown
Collaborator

@j-d-ha j-d-ha commented Apr 6, 2026

Summary

This PR adds a new LayeredCraft.DynamoMapper.Client package that wraps IAmazonDynamoDB with typed read/write helpers backed by registered IDynamoMapper<TDto> implementations. It also adds dependency injection registration so applications can compose a singleton DynamoClient from mapper registrations, and introduces integration tests against DynamoDB Local to verify the client works end to end with generated mappers. The branch also includes repository-local agent skill updates that were developed alongside the client work.

Changes

  • Add the new LayeredCraft.DynamoMapper.Client project with IDynamoMapper<TDto>, DynamoClient, and DynamoClientBuilder for typed DynamoDB access.
  • Add dependency injection support via AddDynamoClient(...) and DynamoClientServiceBuilder, including mapper registration and optional IAmazonDynamoDB override support.
  • Add the LayeredCraft.DynamoMapper.Client.Tests project with DynamoDB Local integration coverage for GetItemAsync, PutItemAsync, DeleteItemAsync, UpdateItemAsync, QueryAsync, ScanAsync, and DI-based resolution.
  • Seed realistic single-table test data and mapper fixtures so the client is exercised against nested objects, collections, binary data, and update-returned attributes.
  • Update solution and package management files for the new client/test projects and required dependencies.
  • Update repository-local agent skill metadata, including refinements to the dynamo-mapper skill and the addition of the git-workflow skill assets used in this repo.

Validation

  • Ran dotnet test --project test/LayeredCraft.DynamoMapper.Client.Tests/LayeredCraft.DynamoMapper.Client.Tests.csproj
  • Result: 7/7 tests passed
  • Verified builder-based and DI-based client setup against DynamoDB Local, including read, query, scan, write, delete, and update flows.

Release Notes

  • Add a new LayeredCraft.DynamoMapper.Client package that provides mapper-driven typed DynamoDB access plus dependency injection registration helpers.

Notes for Reviewers

  • Primary review surface: src/LayeredCraft.DynamoMapper.Client/* and test/LayeredCraft.DynamoMapper.Client.Tests/*.
  • The .agents/skills/*, .claude/skills/*, and skills/* changes are repository-local automation/documentation updates and can be reviewed separately from the runtime client behavior.

@j-d-ha j-d-ha changed the title feat(testing): add DynamoDB client test coverage feat(testing): add DynamoDB client Apr 6, 2026
@j-d-ha j-d-ha changed the title feat(testing): add DynamoDB client feat(client): add typed DynamoClient with DI and integration tests Apr 7, 2026
j-d-ha added 26 commits April 8, 2026 08:31
- Added `LayeredCraft.DynamoMapper.Client` project with initial setup.
- Defined `IDynamoMapper` interface for mapping DTOs to/from DynamoDB items.
- Integrated `AWSSDK.DynamoDBv2` package as a dependency.
- Updated solution file to include the new project.
- Removed redundant configurations and entries in `.DotSettings`.
- Improved formatting and alignment for settings keys.
- Simplified the file structure by reducing unnecessary verbosity.
- Added `DynamoClient` to interact with DynamoDB using registered mappers.
- Introduced `DynamoClientBuilder` for flexible client configuration.
- Updated `IDynamoMapper` interface to remove static methods and simplify implementation.
- Renamed `LayeredCraft.DynamoClient` namespace to `LayeredCraft.DynamoMapper.Client`.
- Updated references in `IDynamoMapper`, `DynamoClient`, and `DynamoClientBuilder`.
…moDB client

- Updated `_dynamoDbClient` private field to `AmazonDynamoDb` public property.
- Replaced references to `_dynamoDbClient` with `AmazonDynamoDb` in methods.
- Changed `GetItemAsync` to return `Task<T?>` and use `await` for asynchronous processing.
- Improved null check logic by verifying `result.Item.Count` instead of relying on `Result`.
…Client and its builder

- Added XML documentation for all public methods and properties.
- Introduced convenience methods in `DynamoClient`: `PutItemAsync`, `DeleteItemAsync`, `UpdateItemAsync`, `QueryAsync`, and `ScanAsync`.
- Enhanced `DynamoClientBuilder` with descriptive summaries for method functionality.
- Disabled `MemberCanBePrivate.Global` inspection in `DynamoClient.cs` to improve readability.
- Added `LayeredCraft.DynamoMapper.Client.Tests` project with initial setup.
- Included `AWSSDK.DynamoDBv2` and `xUnit` packages as dependencies.
- Updated solution file to reference the new test project.
- Configured `xunit.runner.json` for test execution.
- Added project references for required dependencies in the test project.
- Created `.claude/skills/dynamo-mapper` directory to enable skill integration.
- Introduced initial setup for DynamoMapper skill in the project.
- Added `.agents/skills/git-workflow` directory with documentation, examples, templates, and shared logic.
- Introduced workflows for branching, committing, and pull requests, adhering to conventional commits.
- Defined `Skill` metadata in `SKILL.md` for intent-specific routing and execution.
- Included safety rules, scope detection, and file inclusion policy for robust and transparent handling.
- Configured templates for pull requests, release notes, and validation reporting.
- Created initial examples for feature, fix, and CI scenarios.
…odels

- Added mappers (`UserProfileMapper`, `ProjectRecordMapper`, `TaskRecordMapper`) for testing DynamoMapper.
- Introduced data models (`UserProfile`, `ProjectRecord`, `TaskRecord`, etc.) for testing purposes.
- Set up `DynamoDbFixture` using `Testcontainers.DynamoDb` for integration tests.
- Updated test project dependencies, including `Testcontainers.DynamoDb`.
- Configured `LayeredCraft.DynamoMapper.Client.Tests.csproj` for analyzer and runtime references.
- Updated documentation to clarify mapper classes can be instance-based or static.
- Adjusted examples to include non-static mapper declarations and methods.
- Added guidance to avoid assumptions that mappers or methods must be static.
…tests

- Introduced `TestDataSamples` for sample user profiles, project records, and task records.
- Populated data models to improve test coverage and simulation realism.
- Enhanced `DynamoDbFixture` with table creation for integration tests.
- Added batch item writer to preload sample data in `DynamoDbFixture`.
- Introduced tests for `GetItemAsync`, `QueryAsync`, `ScanAsync`, `PutItemAsync`, `DeleteItemAsync`,
  and `UpdateItemAsync` methods.
- Verified CRUD operations and query behaviors using seeded test data.
- Enhanced test coverage for mapper handling and integration setup.
- Refined null check logic in `GetItemAsync` to handle edge cases efficiently.
- Introduced `DynamoClientServiceBuilder` for configuring `DynamoClient` in DI containers.
- Added `DynamoClientServiceCollectionExtensions` to simplify `DynamoClient` registration.
- Enabled mapper registration via `AddMapper` and Amazon DynamoDB client injection.
- Updated `DynamoClientBuilder` to support instance-based mappers via type registration.
- Enhanced tests to verify `AddDynamoClient` functionality and client resolution from DI.
- Updated project dependencies to include `Microsoft.Extensions.DependencyInjection`.
…pport

- Added `GetItemResponse<T>` model to encapsulate `GetItem` results with mapped DTO support.
- Extended `DynamoClient` with `ExecuteStatementAsync` methods for PartiQL query execution.
- Updated `GetItemAsync` to return `GetItemResponse<T>` for enriched result handling.
- Added integration tests for new methods including typed and raw PartiQL responses.
- Enhanced existing tests to validate `MappedItem` usage in response processing.
…ryResponse model

- Updated `PutItemAsync` and `DeleteItemAsync` to return detailed responses: `PutItemResponse` and `DeleteItemResponse`.
- Enhanced `UpdateItemAsync` to return `UpdateItemResponse` for consistency with other methods.
- Modified `QueryAsync` to return the new `QueryResponse<T>` model, providing enriched result handling.
- Added `QueryResponse<T>` class to encapsulate raw query response details and mapped DTO items.
- Improved type safety and clarity in DynamoDB result processing.
…StatementResponse models

- Introduced `ScanResponse<T>` and `ExecuteStatementResponse<T>` models for enriched result handling.
- Updated `DynamoClient` methods to use the new models, improving type safety and clarity.
- Enhanced `UpdateItemAsync` to return mapped DTOs when attributes are present.
- Updated tests to validate usage of `MappedItems` and new response models across multiple scenarios.
…nsions and update usage

- Added `AttributeValueConverterExtensions` with methods for converting common types to `AttributeValue`.
- Refactored `DynamoClientTests` to use the new extension methods for cleaner attribute creation.
- Improved test readability and reliability by replacing inline `AttributeValue` creation with extensions.
- Verified compatibility with existing tests to ensure no regressions.
- Replaced inline assertions (`.Should().Be` and `.NotBeTrue`) with `BeEquivalentTo` for consistency.
- Refactored tests to use helper methods for creating `AttributeValue` objects (e.g., `StringAttribute`, `NumberAttribute`).
- Removed `AssertNullAttribute` in favor of `BeEquivalentTo(NullAttribute())`.
- Improved test readability and alignment with FluentAssertions best practices.
…moClient

- Removed `ExecuteStatementAsync` method that returned raw DynamoDB responses.
- Kept the typed `ExecuteStatementAsync<T>` method for mapped DTO handling.
- Simplified the `DynamoClient` interface by eliminating unused raw response handling.
…h mapped attributes

- Introduced `DeleteItemResponse<T>`, `PutItemResponse<T>`, and `UpdateItemResponse<T>` models.
- Enhanced `DynamoClient` methods (`PutItemAsync`, `DeleteItemAsync`, `UpdateItemAsync`) to return enriched responses.
- Updated integration tests to validate new response handling and mapped attributes (`MappedItem`).
- Refactored test scenarios for CRUD operations to improve coverage and validation consistency.
- Introduced `.opencode/opencode.jsonc` for defining code formatting instructions and tools.
- Configured `cs-jb-formatter` for formatting `.cs`, `.props`, and `.csproj` files using JetBrains cleanup tool.
- Configured `mdformat` for `.md` files with MkDocs and frontmatter support.
- Added file exclusions for `.agents`, `.claude`, and `.opencode` directories.
- Added `.claude/hooks/format.py` for handling C# and Markdown file formatting.
- Configured `format.py` to use JetBrains cleanup tool for C# and `mdformat` for Markdown.
- Integrated format hook into `.claude/settings.json` to trigger after tool usage.
- Supported exclusions for `.agents`, `.claude`, and `.opencode` directories.
…path

- Updated `format.py` to retrieve `DOTSETTINGS_FILE` via environment variable for better configurability.
- Added `env.DOTSETTINGS_FILE` entry in `.claude/settings.json` for default file path configuration.
@j-d-ha j-d-ha force-pushed the feature/add-client branch from beff52d to 4153f8b Compare April 8, 2026 12:31
@j-d-ha j-d-ha marked this pull request as ready for review April 19, 2026 21:58
@github-actions github-actions Bot added the type: feat New feature label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant