OmnyStore class
The registry, backed by local repositories and one object store.
This is the whole system in a single process: create organizations,
projects and packages, publish releases, attach artifacts, serve downloads
and answer update checks. Everything else in the package is a way to reach
an OmnyStore — the REST API server exposes one, a node is one, the hub
federates several, and the client SDK speaks to one across the network.
final store = OmnyStore(
repositories: MemoryRepositories(),
storage: LocalObjectStorage('/var/lib/omnystore'),
);
final org = await store.createOrganization(name: 'acme');
final project = await store.createProject(
organizationId: org.id, name: 'agent',
);
final package = await store.createPackage(
projectId: project.id, name: 'omnyagent',
);
final release = await store.publishRelease(
packageReference: package.id,
version: Version.parse('1.0.0'),
);
await store.attachAsset(
releaseId: release.id,
name: 'omnyagent-linux-x64.tar.gz',
data: File('build/omnyagent-linux-x64.tar.gz').openRead(),
);
await store.latestRelease('omnyagent'); // => 1.0.0
No global state. clock, idGenerator and logger are injected, so
tests fix time, get deterministic ids, and assert on log output without a
singleton anywhere. Two OmnyStores in one process share nothing.
Business rules live here, not in the repositories. Name validation, referential integrity, release immutability and cascade rules are enforced in this class, so they hold identically whether the backing store is in-memory, SQL or a remote node.
- Implemented types
Constructors
-
OmnyStore({required StoreRepositories repositories, required ObjectStorage storage, Clock clock = const SystemClock(), IdGenerator? idGenerator, Logger logger = const NoopLogger(), String? providerId, Set<
String> organizations = const {}, bool servesAllOrganizations = true}) -
Creates a store over
repositoriesandstorage.
Properties
- clock → Clock
-
The time source. Injected so tests can fix
now.final - hashCode → int
-
The hash code for this object.
no setterinherited
- idGenerator → IdGenerator
-
The identifier generator. Injected so tests get deterministic ids.
final
- logger → Logger
-
Structured logging. Defaults to a no-op: embedding OmnyStore never writes
to stdout unless the application asks for it.
final
-
organizations
→ Set<
String> -
The organizations this store serves, when it runs as a node. Empty with
servesAllOrganizations means "everything local".
final
- providerId → String
-
This store's provider id, recorded on the placements it writes.
final
- repositories → StoreRepositories
-
The metadata repositories.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- servesAllOrganizations → bool
-
Whether this store serves every organization — the single-server default.
final
- storage → ObjectStorage
-
Where asset bytes live.
final
Methods
-
asset(
String id) → Future< Asset?> -
The asset with
id, ornull.override -
assetByName(
String releaseId, String name) → Future< Asset?> -
The asset named
namewithinreleaseId, ornull.override -
attachAsset(
{required String releaseId, required String name, required Stream< List< data, int? length, String contentType = 'application/octet-stream', String? expectedSha256, String? platform, String? kind, Map<int> >String, String> metadata = const {}}) → Future<Asset> -
Attaches an asset named
nametoreleaseId, streamingdatainto storage.override -
checkForUpdates(
{required String packageReference, required Version currentVersion, ReleaseChannel? channel, String? platform}) → Future< UpdateInfo> -
Answers "is there a newer version of
packageReferencethancurrentVersion, onchannel, forplatform?".override -
close(
) → Future< void> -
Releases any resources held (HTTP clients, storage handles).
override
-
createOrganization(
{required String name, String? displayName, String? description, String? website, Map< String, String> metadata = const {}}) → Future<Organization> -
Creates an organization named
name.override -
createPackage(
{required String projectId, required String name, String? displayName, String? description, ReleaseChannel defaultChannel = ReleaseChannel.release, List< String> platforms = const [], Map<String, String> metadata = const {}}) → Future<Package> -
Creates a package named
nameunderprojectId.override -
createProject(
{required String organizationId, required String name, String? displayName, String? description, String? repository, String? website, Map< String, String> metadata = const {}}) → Future<Project> -
Creates a project named
nameunderorganizationId.override -
deleteAsset(
String id) → Future< void> -
Deletes the asset with
idand its stored bytes on every provider.override -
deleteOrganization(
String id, {bool force = false}) → Future< void> -
Deletes the organization with
idand everything under it.override -
deletePackage(
String id, {bool force = false}) → Future< void> -
Deletes the package with
id.forceis required if it has releases.override -
deleteProject(
String id, {bool force = false}) → Future< void> -
Deletes the project with
id.forceis required if it has packages.override -
deleteRelease(
String id) → Future< void> -
Deletes the release with
id, its assets and their stored bytes.override -
describeProvider(
{ProviderKind kind = ProviderKind.hub, DataPlaneMode? dataPlane, String? baseUrl, Map< String, String> labels = const {}, int priority = 0, int? capacityBytes}) → Future<ProviderDescriptor> - This store's own provider descriptor, as reported to a hub and by listProviders.
-
downloadStats(
String packageReference, {DateTime? from, DateTime? to}) → Future< DownloadStats> -
Aggregated download statistics for
packageReference.override -
downloadTarget(
String id, {Duration expiresIn = const Duration(minutes: 15)}) → Future< DownloadTarget> -
Where a client should fetch the asset with
idfrom.override -
latestAny(
String packageReference) → Future< Release?> -
The newest offerable release of
packageReferenceon any channel.override -
latestBeta(
String packageReference) → Future< Release?> -
The newest offerable beta release of
packageReference, ornull.override -
latestChannel(
String packageReference, ReleaseChannel channel, {bool exact = false}) → Future< Release?> -
The newest release of
packageReferencea client onchannelwould accept, ornull.override -
latestDev(
String packageReference) → Future< Release?> -
The newest offerable dev release of
packageReference, ornull.override -
latestRelease(
String packageReference) → Future< Release?> -
The newest offerable stable release of
packageReference, ornull.override -
listAssets(
String releaseId) → Future< List< Asset> > -
Assets of
releaseId, ordered by name.override -
listDownloads(
String packageReference, {int? limit, DateTime? from, DateTime? to}) → Future< List< DownloadRecord> > -
Download records for
packageReference, newest first.override -
listOrganizations(
) → Future< List< Organization> > -
Every organization, ordered by name.
override
-
listPackages(
{String? projectId, String? organizationId}) → Future< List< Package> > -
Packages of
projectIdororganizationId, or every package when both arenull.override -
listProjects(
{String? organizationId}) → Future< List< Project> > -
Projects of
organizationId, or every project when it isnull.override -
listProviders(
{String? organization}) → Future< List< ProviderDescriptor> > -
The storage providers this store knows about.
override
-
listReleases(
String packageReference, {ReleaseQuery query = const ReleaseQuery()}) → Future< List< Release> > -
Releases of
packageReferencematchingquery, newest first.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAsset(
String id, {ByteRange? range}) → Future< AssetDownload> -
Opens the bytes of the asset with
id, optionally restricted torange.override -
organization(
String id) → Future< Organization?> -
The organization with
id, ornull.override -
organizationByName(
String name) → Future< Organization?> -
The organization named
name, ornull.override -
package(
String id) → Future< Package?> -
The package with
id, ornull.override -
packageByName(
String projectId, String name) → Future< Package?> -
The package named
namewithinprojectId, ornull.override -
project(
String id) → Future< Project?> -
The project with
id, ornull.override -
projectByName(
String organizationId, String name) → Future< Project?> -
The project named
namewithinorganizationId, ornull.override -
promoteRelease(
String releaseId, ReleaseChannel channel, {String? notes}) → Future< Release> -
Promotes
releaseIdtochannelby publishing its artifacts under a new version carrying that channel's tag.override -
publishRelease(
{required String packageReference, required Version version, String? title, String? notes, String? tag, bool draft = false, Map< String, String> metadata = const {}}) → Future<Release> -
Publishes
versionof the packagepackageReferenceresolves to.override -
recordDownload(
{required String assetId, String? clientAddress, String? userAgent, String? principalId, String? providerId, int? bytesServed}) → Future< DownloadRecord> -
Records that the asset with
assetIdwas downloaded, and increments its counter.override -
release(
String id) → Future< Release?> -
The release with
id, ornull.override -
releaseByVersion(
String packageReference, Version version) → Future< Release?> -
The release of
packageReferenceatversion, ornull.override -
resolvePackage(
String reference) → Future< Package> -
Resolves a package from an id or a bare name.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateOrganization(
String id, {String? displayName, String? description, String? website, Map< String, String> ? metadata}) → Future<Organization> -
Updates the mutable fields of the organization with
id.override -
updatePackage(
String id, {String? displayName, String? description, ReleaseChannel? defaultChannel, List< String> ? platforms, Map<String, String> ? metadata}) → Future<Package> -
Updates the mutable fields of the package with
id.override -
updateProject(
String id, {String? displayName, String? description, String? repository, String? website, Map< String, String> ? metadata}) → Future<Project> -
Updates the mutable fields of the project with
id.override -
updateRelease(
String id, {String? title, String? notes, String? tag, bool? draft, bool? yanked, String? yankedReason, Map< String, String> ? metadata}) → Future<Release> -
Updates a release's mutable metadata: notes, title, draft state, and
yanking.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited