Add Repository<T> interface + ITemporalEntity + IHistoryRepository<T> #7
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated from uwe.admin/webapp-scaffold#8 per the Option A decision (C++ work belongs in oatpp-authkit, not the TypeScript frontend scaffold).
Implementation lands under
oatpp-authkit/include/oatpp-authkit/repo/alongsideauth/,db/,dto/,handler/. Tests underoatpp-authkit/test/matching the existing plain-executable + REQUIRE-macro style oftest_negotiation.cpp/test_json_serialization.cpp. README v0.1 table appended.Part of a structural refactor: move from per-entity
*Dbclients to a sharedRepository<T>abstraction. This issue lands the interfaces only in oatpp-authkit. No behavior change yet, no concrete implementations, no callers updated.Scope
Add to webapp-scaffold:
Repository<TDto>— pure abstract interface, temporal-agnostic:findByEntityId(entityId)list(filter)save(dto)— generates a random UUID ifentity_idis null on the DTO; otherwise uses the caller-supplied id (mixed allocation policy)softDelete(entityId)ITemporalEntity— DTO mixin/marker requiringentity_id,valid_from,valid_untilIHistoryRepository<TDto>— separate interface forhistory(entityId), only implemented by repositories that wrap temporal entitiesTemporalAt— value type: "live" or a specific point in timeActorContext— placeholder for who is performing the action (used by the scope-guard decorator in the next issue)Out of scope
*Dbcallers in fewo-webappAcceptance
Repository<MockDto>exists, demonstrating the contract without touching SQLDecisions (from planning discussion)
entity_idallocation: mixed — client passes id OR repository allocates a random UUID if nullRepository<T>shape: pure abstract interface (not C++20 concept)IHistoryRepository<T>, not onRepository<T>Agent Evaluation
Feasibility: Easy. The host repo decision is settled (Option A → oatpp-authkit), and the issue body is explicit about layout (
include/oatpp-authkit/repo/), test style (plain executable + REQUIRE matchingtest_negotiation.cpp), and the four design decisions (mixed UUID allocation, no UnitOfWork, abstract interface not concept, separateIHistoryRepository<T>). Nothing here requires further design discussion.Impact: High and structural. This is the foundation header set the whole
Repository<T>rollout sits on (oatpp-authkit #8 decorators, fewo-webapp #457 pilot, fewo-webapp #458 phases 4-7). The interfaces are also reusable across other oatpp-authkit consumers, fitting the library's "distilled from fewo-webapp's hardened stack" charter.Effort: Small (~150 LOC headers + ~120 LOC test).
Recommendation: Accept.
Implementation plan
include/oatpp-authkit/repo/directory.Repository.hpp—template <class TDto> class Repository { virtual ~Repository(); virtual oatpp::Object<TDto> findByEntityId(const oatpp::String&) = 0; virtual oatpp::Vector<oatpp::Object<TDto>> list(...) = 0; virtual void save(oatpp::Object<TDto>) = 0; virtual void softDelete(const oatpp::String&) = 0; };—savesemantics: ifdto->entity_idis null, generate a UUID v4; otherwise use the supplied value.ITemporalEntity.hpp—struct ITemporalEntity { static_assert(...) }or a documentation comment + concept-stylerequirescheck at decorator site (since the decision was abstract interface, plain inheritance is fine).IHistoryRepository.hpp—template <class TDto> class IHistoryRepository { virtual oatpp::Vector<oatpp::Object<TDto>> history(const oatpp::String&) = 0; };TemporalAt.hpp—struct TemporalAt { enum Kind { Live, At } kind; v_int64 timestamp; static TemporalAt live(); static TemporalAt at(v_int64); };ActorContext.hpp— minimal placeholderstruct ActorContext { oatpp::String userId; oatpp::Vector<oatpp::String> allowedScopes; };— extend in the scope-guard decorator issue if needed.test/test_repository_interface.cpp:MockDto(entity_id + name).InMemoryRepo : Repository<MockDto>using astd::unordered_map.save(null-id)allocates UUID;save(supplied-id)reuses it;findByEntityIdround-trips;softDeleteremoves.test/CMakeLists.txt:add_executable(test_repository_interface ...),add_test(NAME repository_interface ...).repo/headers.cmake -B build -DOATPP_AUTHKIT_BUILD_TESTS=ON && cmake --build build && ctest --test-dir buildclean.Decision needed
None — design decisions all settled in the issue body and prior cross-repo discussion. Owner can add
acceptedto unblock implementation.Evaluation carried over from closed uwe.admin/webapp-scaffold#8; the migration comment at the top of this issue body summarises the prior eval. No additional design questions remain.
Re-evaluation
Acknowledged — owner's note confirms the evaluation carries over from the closed scaffold ticket and no new design questions remain. Original eval (Small effort, Accept recommendation, plan in this thread) stands as-is. Ready for the
acceptedlabel to unblock implementation.Implemented #7 → commit
a0c61b3— 5 headers underinclude/oatpp-authkit/repo/, in-memory test fake covering mixed-id allocation / find / list / softDelete / TemporalAt / ActorContext / ITemporalEntity marker; all 5 ctest targets pass; README updated. Unblocks decorator work in #8 and the fewo-webapp pilot at uwe.admin/fewo-webapp#457.