id_registry 2.0.0
id_registry: ^2.0.0 copied to clipboard
Cross-collection uniqueness, validation and id generation for id_pair_set identifiers, with failures as values and pluggable storage.
2.0.0 - 2026-09-19 #
Rebuilt around the two guarantees a registry exists to provide: a refused registration changes nothing, and two callers never get the same id.
Changed #
- Failures are values.
register,unregister,generateIdandclearanswer withEither<IdRegistryFailure, …>instead of throwing (fpdart^1.2.0).DuplicateIdExceptionandValidationExceptionare gone. registeris atomic. Every id is validated and checked before any is written, and a failed write undoes what was written, so a refusal leaves the registry untouched. Previously the set was written id by id and the throw landed mid-loop, leaving a half-registered batch.- Mutating calls are serialised. Two concurrent
generateIdcalls used to compute the same next integer and hand out the same id; two concurrent registrations could both pass the check pass. - Auto-increment uses the stored counter instead of re-reading every code on every mint, seeded from the highest existing numeric code so a registry restored from storage resumes rather than colliding. The counter API is now live rather than dead weight, and the probe still skips existing codes, so a lost counter can waste an id but cannot produce a duplicate.
clear()is symmetric: registrations, validators, generators and counters all go. Previously validators were dropped while generators stayed.- Storage contracts answer with
Either, and the file-backed store writes through on every mutation before reporting success. IdStoragetakes discreteidType/idCodeparameters.- SDK constraint is now
>=3.10.0 <4.0.0;equatabledropped (nothing in the package is a value object any more).
Added #
IdRegistryFailureandIdStorageFailure, sealed hierarchies per layer, with a repository that maps storage failures upward.codesForandidTypeson the repository, andcounterFor/setCounteras first-class storage operations.CachedIdStorage, and a shared storage contract suite run against all three adapters.- CI: format,
dart analyze --fatal-infos --fatal-warnings, tests, the example, and a publish dry-run.
Removed #
IdRegistry(renamedIdRegistryRepositoryImpl),DuplicateIdException,ValidationException, andIdValidators(the static helpers — useIsbnIdValidator,Isbn13IdValidator,OrcidIdValidator).IdStorage.getCounter/setCounterare no longer dead API: they arecounterFor/setCounterand the generator uses them.