mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-20 23:21:36 +03:00
248 lines
5.4 KiB
Plaintext
248 lines
5.4 KiB
Plaintext
interface downloads {
|
|
//
|
|
// download API as presented by download:app_store:sys-v0
|
|
//
|
|
|
|
use standard.{package-id};
|
|
|
|
variant download-requests {
|
|
// remote only
|
|
remote-download(remote-download-request),
|
|
chunk(chunk-request),
|
|
progress(progress-update),
|
|
size(size-update),
|
|
// local only
|
|
local-download(local-download-request),
|
|
download-complete(download-complete-request),
|
|
get-files(option<package-id>),
|
|
remove-file(remove-file-request),
|
|
add-download(add-download-request),
|
|
start-mirroring(package-id),
|
|
stop-mirroring(package-id),
|
|
}
|
|
|
|
variant download-responses {
|
|
success,
|
|
error(download-error),
|
|
get-files(list<entry>),
|
|
}
|
|
|
|
record local-download-request {
|
|
package-id: package-id,
|
|
download-from: string,
|
|
desired-version-hash: string,
|
|
}
|
|
|
|
record remote-download-request {
|
|
package-id: package-id,
|
|
worker-address: string,
|
|
desired-version-hash: string,
|
|
}
|
|
|
|
variant download-error {
|
|
no-package,
|
|
not-mirroring,
|
|
hash-mismatch(hash-mismatch),
|
|
file-not-found,
|
|
worker-spawn-failed,
|
|
}
|
|
|
|
record download-complete-request {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
error: option<download-error>,
|
|
}
|
|
|
|
record hash-mismatch {
|
|
desired: string,
|
|
actual: string,
|
|
}
|
|
|
|
record chunk-request {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
offset: u64,
|
|
length: u64,
|
|
}
|
|
|
|
variant entry {
|
|
file(file-entry),
|
|
dir(dir-entry),
|
|
}
|
|
|
|
record file-entry {
|
|
name: string,
|
|
size: u64,
|
|
manifest: string,
|
|
}
|
|
|
|
record dir-entry {
|
|
name: string,
|
|
mirroring: bool,
|
|
}
|
|
|
|
record remove-file-request {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
}
|
|
|
|
// part of new-package-request local-only flow.
|
|
record add-download-request {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
mirror: bool,
|
|
}
|
|
|
|
record progress-update {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
downloaded: u64,
|
|
total: u64,
|
|
}
|
|
|
|
record size-update {
|
|
package-id: package-id,
|
|
size: u64,
|
|
}
|
|
}
|
|
|
|
interface chain {
|
|
//
|
|
// on-chain API as presented by chain:app_store:sys-v0
|
|
//
|
|
|
|
use standard.{package-id};
|
|
|
|
variant chain-requests {
|
|
get-app(package-id),
|
|
get-apps,
|
|
get-our-apps,
|
|
start-auto-update(package-id),
|
|
stop-auto-update(package-id),
|
|
}
|
|
|
|
variant chain-responses {
|
|
get-app(option<onchain-app>),
|
|
get-apps(list<onchain-app>),
|
|
get-our-apps(list<onchain-app>),
|
|
auto-update-started,
|
|
auto-update-stopped,
|
|
error(chain-error),
|
|
}
|
|
|
|
variant chain-error {
|
|
no-package,
|
|
}
|
|
|
|
record onchain-app {
|
|
package-id: package-id,
|
|
tba: string,
|
|
metadata-uri: string,
|
|
metadata-hash: string,
|
|
metadata: option<onchain-metadata>,
|
|
auto-update: bool,
|
|
}
|
|
|
|
record onchain-metadata {
|
|
name: option<string>,
|
|
description: option<string>,
|
|
image: option<string>,
|
|
external-url: option<string>,
|
|
animation-url: option<string>,
|
|
properties: onchain-properties,
|
|
}
|
|
|
|
record onchain-properties {
|
|
package-name: string,
|
|
publisher: string,
|
|
current-version: string,
|
|
mirrors: list<string>,
|
|
code-hashes: list<tuple<string, string>>,
|
|
license: option<string>,
|
|
screenshots: option<list<string>>,
|
|
wit-version: option<u32>,
|
|
dependencies: option<list<string>>,
|
|
}
|
|
}
|
|
|
|
interface main {
|
|
//
|
|
// app store API as presented by main:app_store:sys-v0
|
|
//
|
|
|
|
use standard.{package-id};
|
|
use chain.{onchain-metadata, chain-error};
|
|
use downloads.{download-error};
|
|
|
|
variant request {
|
|
local(local-request),
|
|
}
|
|
|
|
variant response {
|
|
local(local-response),
|
|
chain-error(chain-error),
|
|
download-error(download-error),
|
|
}
|
|
|
|
variant local-request {
|
|
new-package(new-package-request),
|
|
install(install-package-request),
|
|
uninstall(package-id),
|
|
apis,
|
|
get-api(package-id),
|
|
}
|
|
|
|
variant local-response {
|
|
new-package-response(new-package-response),
|
|
install-response(install-response),
|
|
uninstall-response(uninstall-response),
|
|
apis-response(apis-response),
|
|
get-api-response(get-api-response),
|
|
}
|
|
|
|
|
|
record new-package-request {
|
|
package-id: package-id,
|
|
mirror: bool,
|
|
}
|
|
|
|
record install-package-request {
|
|
package-id: package-id,
|
|
metadata: option<onchain-metadata>, // if None == local sideload package.
|
|
version-hash: string,
|
|
}
|
|
|
|
enum new-package-response {
|
|
success,
|
|
no-blob,
|
|
install-failed,
|
|
already-exists,
|
|
}
|
|
|
|
enum install-response {
|
|
success,
|
|
failure,
|
|
}
|
|
|
|
enum uninstall-response {
|
|
success,
|
|
failure,
|
|
}
|
|
|
|
record apis-response {
|
|
apis: list<package-id>,
|
|
}
|
|
|
|
// the API itself will be in response blob if success!
|
|
enum get-api-response {
|
|
success,
|
|
failure,
|
|
}
|
|
}
|
|
|
|
world app-store-sys-v0 {
|
|
import main;
|
|
import downloads;
|
|
import chain;
|
|
include process-v0;
|
|
} |