Repository navigation
Open
Labels
enhancementNew feature or request
Description
Context
effect-domain is a backend-free aggregate kernel: commands, pure decide functions and events, with an all-or-nothing Transaction.atomically as the consistency boundary. Its core landed in effect-domain#1. The apps that adopt it expose JSON:API through this library, and that stays the only API.
Decided shape
- JSON:API is the transfer layer, not the domain model. Resources stay hand-written with
Resource.make. A resource often lines up with an entity and a collection with an aggregate, but the mapping is explicit. - The mapping lives in effect-domain, as
@thomasfosterau/effect-domain-jsonapi. It maps a create, update, delete or atomic operation to commands, and an aggregate's state back to a resource (toResource,toCommand). effect-jsonapi never depends on effect-domain. - An
atomic:operationsrequest runs in one transaction: every operation commits, or none does. Several commands, often on several aggregates, inside oneatomically.
What effect-jsonapi may need
The adapter should need only public API. While building it, check:
- One boundary per atomic request.
ResourceHandlers'Transactseam wraps each write. For an atomic request the adapter opens one transaction around the whole document; a per-writeTransactmust then join it (a savepoint, or a no-op) rather than open its own. - Server-side atomic processing.
EndpointandAtomicmodel the request and result documents; executing one (dispatch per operation,lidresolution across operations,atomic:resultsin order, errors pointed at/atomic:operations/<i>) is left to the application today. If every adopter would write the same loop, a small processor here with a per-operation callback would serve effect-domain-jsonapi and plain handlers alike. - Errors from tagged failures. A command's rejection is a
Schema.TaggedError; the adapter maps it to a JSON:API error object (422 for a rule, 409 forVersionConflict, 404 forAggregateNotFound). ConfirmApiError/ServerErrorstake that mapping without private imports. - Optional: a helper that drafts a
Resourcefrom an aggregate's state schema, as a convenience only. A hand-writtenResource.makestays the definition.
Anything effect-jsonapi has to change gets its own PR here; the adapter itself goes in effect-domain.
Acceptance
effect-domain-jsonapi serves one aggregate's create, update and delete, and an atomic request spanning two aggregates that rolls back entirely when the second operation's command is rejected, using only effect-jsonapi's public exports.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity