mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-20 23:21:36 +03:00
226 lines
5.0 KiB
Plaintext
226 lines
5.0 KiB
Plaintext
interface downloads {
|
|
//
|
|
// download API as presented by download:app_store:sys-v0
|
|
//
|
|
|
|
use standard.{package-id};
|
|
|
|
variant downloads {
|
|
// local and remote
|
|
download(download-request),
|
|
chunk(chunk-request),
|
|
progress(progress-update),
|
|
size(size-update),
|
|
// local only
|
|
get-files(option<package-id>),
|
|
add-download(add-download-request),
|
|
}
|
|
|
|
record download-request {
|
|
package-id: package-id,
|
|
download-from: option<string>, // note, might be too much implicit complexity,
|
|
// but: download-from received locally, is an instruction where to download-from
|
|
// and if received from remote, is an instruction where to send, where the "download-from" came from.
|
|
desired-version-hash: string,
|
|
}
|
|
|
|
record download-response {
|
|
success: bool,
|
|
error: option<string>,
|
|
}
|
|
|
|
record chunk-request {
|
|
package-id: package-id,
|
|
version-hash: string,
|
|
offset: u64,
|
|
length: u64,
|
|
}
|
|
|
|
|
|
record entry {
|
|
name: string,
|
|
is-file: bool,
|
|
size: option<u64>,
|
|
}
|
|
|
|
// not part of remote protocol, mainly for UI viewing.
|
|
record available-files {
|
|
files: list<entry>,
|
|
}
|
|
|
|
// 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 chains {
|
|
get-app(package-id),
|
|
get-apps,
|
|
get-our-apps,
|
|
start-auto-update(package-id),
|
|
stop-auto-update(package-id),
|
|
}
|
|
|
|
record on-chain-app {
|
|
package-id: package-id,
|
|
tba: string,
|
|
metadata-uri: string,
|
|
metadata-hash: string,
|
|
metadata: option<on-chain-metadata>,
|
|
auto-update: bool,
|
|
}
|
|
|
|
record on-chain-metadata {
|
|
name: option<string>,
|
|
description: option<string>,
|
|
image: option<string>,
|
|
external-url: option<string>,
|
|
animation-url: option<string>,
|
|
properties: on-chain-properties,
|
|
}
|
|
|
|
record on-chain-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>>,
|
|
}
|
|
|
|
record get-apps-response {
|
|
apps: list<on-chain-app>,
|
|
}
|
|
|
|
record get-app-response {
|
|
app: option<on-chain-app>,
|
|
}
|
|
|
|
record get-our-apps-response {
|
|
apps: list<on-chain-app>,
|
|
}
|
|
}
|
|
|
|
interface main {
|
|
//
|
|
// app store API as presented by main:app_store:sys-v0
|
|
//
|
|
|
|
use standard.{package-id};
|
|
use chain.{on-chain-metadata};
|
|
|
|
|
|
// general error type used by both chain: and downloads:
|
|
// todo: add variant for types to match on
|
|
|
|
record error {
|
|
reason: string,
|
|
}
|
|
|
|
variant request {
|
|
local(local-request),
|
|
}
|
|
|
|
variant response {
|
|
local(local-response),
|
|
}
|
|
|
|
// variant reason {
|
|
// no-package,
|
|
// not-mirroring,
|
|
// hash-mismatch(hash-mismatch),
|
|
// file-not-found,
|
|
// worker-spawn-failed
|
|
// }
|
|
|
|
// record hash-mismatch {
|
|
// requested: string,
|
|
// have: string,
|
|
// }
|
|
|
|
variant local-request {
|
|
new-package(new-package-request),
|
|
install(install-package-request),
|
|
uninstall(package-id),
|
|
apis,
|
|
get-api(package-id),
|
|
}
|
|
|
|
record new-package-request {
|
|
package-id: package-id,
|
|
mirror: bool,
|
|
}
|
|
|
|
record install-package-request {
|
|
package-id: package-id,
|
|
metadata: option<on-chain-metadata>, // if None == local sideload package.
|
|
version-hash: string,
|
|
}
|
|
|
|
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),
|
|
}
|
|
|
|
enum new-package-response {
|
|
success,
|
|
no-blob,
|
|
install-failed,
|
|
already-exists,
|
|
}
|
|
|
|
enum install-response {
|
|
success,
|
|
failure, // TODO
|
|
}
|
|
|
|
enum uninstall-response {
|
|
success,
|
|
failure, // TODO
|
|
}
|
|
|
|
record apis-response {
|
|
apis: list<package-id>,
|
|
}
|
|
|
|
// the API itself will be in response blob if success!
|
|
enum get-api-response {
|
|
success,
|
|
failure, // TODO
|
|
}
|
|
}
|
|
|
|
world app-store-sys-v0 {
|
|
import main;
|
|
import downloads;
|
|
import chain;
|
|
include process-v0;
|
|
} |