OmnyStoreClient class

The client SDK: an OmnyStoreApi backed by a remote OmnyStore server.

Web-compatible. Nothing here imports dart:io; the only transport is package:http, so the same code runs on the Dart VM, in Flutter, and compiled to JavaScript in a browser.

final client = OmnyStoreClient(baseUrl: 'https://store.example.com');

final latest = await client.latestRelease('omnyagent');
final update = await client.checkForUpdates(
  packageReference: 'omnyagent',
  currentVersion: Version.parse('1.0.0'),
  channel: ReleaseChannel.beta,
  platform: 'macos-arm64',
);
if (update.isInstallable) {
  final bytes = await client.downloadAsset(update.asset!.id);
}

Errors keep their type across the network. The server sends a code with every failure and this client rebuilds the original exception from it, so on ReleaseNotFoundException and on ChecksumMismatchException work exactly as they do against an embedded store. That is what lets code written against OmnyStoreApi move between embedded and remote with no changes.

Uploads. attachAsset streams on the VM. In a browser the underlying HTTP client cannot stream a request body, so the artifact is buffered first — fine for the sizes a browser uploads, and the reason CI publishing should run on the VM.

Implemented types

Constructors

OmnyStoreClient({required Object baseUrl, AuthProvider auth = const AnonymousAuthProvider(), Duration timeout = const Duration(seconds: 30), String? userAgent, Client? httpClient})
Creates a client for the server at baseUrl.

Properties

apiPath String
The base path every versioned endpoint hangs off.
no setter
auth AuthProvider
Supplies credentials for each request.
final
baseUrl Uri
The server's base URL (https://store.example.com), without the /api/v1 suffix.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
How long to wait for a response before giving up.
final
userAgent String
The user-agent sent with every request.
final

Methods

asset(String id) Future<Asset?>
The asset with id, or null.
override
assetByName(String releaseId, String name) Future<Asset?>
The asset named name within releaseId, or null.
override
assetDownloadUrl(String assetId) Uri
The URL an artifact is fetched from.
attachAsset({required String releaseId, required String name, required Stream<List<int>> data, int? length, String contentType = 'application/octet-stream', String? expectedSha256, String? platform, String? kind, Map<String, String> metadata = const {}}) Future<Asset>
Attaches an asset named name to releaseId, streaming data into storage.
override
checkForUpdates({required String packageReference, required Version currentVersion, ReleaseChannel? channel, String? platform}) Future<UpdateInfo>
Answers "is there a newer version of packageReference than currentVersion, on channel, for platform?".
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 name under projectId.
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 name under organizationId.
override
deleteAsset(String id) Future<void>
Deletes the asset with id and its stored bytes on every provider.
override
deleteOrganization(String id, {bool force = false}) Future<void>
Deletes the organization with id and everything under it.
override
deletePackage(String id, {bool force = false}) Future<void>
Deletes the package with id. force is required if it has releases.
override
deleteProject(String id, {bool force = false}) Future<void>
Deletes the project with id. force is required if it has packages.
override
deleteRelease(String id) Future<void>
Deletes the release with id, its assets and their stored bytes.
override
downloadAsset(String id, {ByteRange? range}) Future<Uint8List>
Downloads the asset with id into memory and verifies its checksum.
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 id from.
override
health() Future<Map<String, dynamic>>
The server's health document.
latestAny(String packageReference) Future<Release?>
The newest offerable release of packageReference on any channel.
override
latestBeta(String packageReference) Future<Release?>
The newest offerable beta release of packageReference, or null.
override
latestChannel(String packageReference, ReleaseChannel channel, {bool exact = false}) Future<Release?>
The newest release of packageReference a client on channel would accept, or null.
override
latestDev(String packageReference) Future<Release?>
The newest offerable dev release of packageReference, or null.
override
latestRelease(String packageReference) Future<Release?>
The newest offerable stable release of packageReference, or null.
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 projectId or organizationId, or every package when both are null.
override
listProjects({String? organizationId}) Future<List<Project>>
Projects of organizationId, or every project when it is null.
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 packageReference matching query, 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 to range.
override
organization(String id) Future<Organization?>
The organization with id, or null.
override
organizationByName(String name) Future<Organization?>
The organization named name, or null.
override
package(String id) Future<Package?>
The package with id, or null.
override
packageByName(String projectId, String name) Future<Package?>
The package named name within projectId, or null.
override
project(String id) Future<Project?>
The project with id, or null.
override
projectByName(String organizationId, String name) Future<Project?>
The project named name within organizationId, or null.
override
promoteRelease(String releaseId, ReleaseChannel channel, {String? notes}) Future<Release>
Promotes releaseId to channel by 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 version of the package packageReference resolves to.
override
recordDownload({required String assetId, String? clientAddress, String? userAgent, String? principalId, String? providerId, int? bytesServed}) Future<DownloadRecord>
Records that the asset with assetId was downloaded, and increments its counter.
override
release(String id) Future<Release?>
The release with id, or null.
override
releaseByVersion(String packageReference, Version version) Future<Release?>
The release of packageReference at version, or null.
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