2024-08-08 14:26:07 +03:00
|
|
|
interface downloads {
|
2024-05-27 02:40:41 +03:00
|
|
|
//
|
2024-08-06 21:06:43 +03:00
|
|
|
// download API as presented by download:app_store:sys-v0
|
2024-05-27 02:40:41 +03:00
|
|
|
//
|
|
|
|
|
2024-05-29 00:51:55 +03:00
|
|
|
use standard.{package-id};
|
2024-08-20 17:16:48 +03:00
|
|
|
use chain.{onchain-metadata};
|
2024-05-27 02:40:41 +03:00
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
variant download-requests {
|
|
|
|
// remote only
|
|
|
|
remote-download(remote-download-request),
|
2024-08-08 14:26:07 +03:00
|
|
|
chunk(chunk-request),
|
|
|
|
progress(progress-update),
|
|
|
|
size(size-update),
|
2024-08-14 12:05:12 +03:00
|
|
|
// local only
|
2024-08-15 14:14:09 +03:00
|
|
|
local-download(local-download-request),
|
2024-08-20 17:16:48 +03:00
|
|
|
auto-update(auto-update-request),
|
2024-08-16 22:23:27 +03:00
|
|
|
download-complete(download-complete-request),
|
2024-08-09 19:23:36 +03:00
|
|
|
get-files(option<package-id>),
|
2024-08-16 01:23:47 +03:00
|
|
|
remove-file(remove-file-request),
|
2024-08-13 03:32:52 +03:00
|
|
|
add-download(add-download-request),
|
2024-08-15 17:15:55 +03:00
|
|
|
start-mirroring(package-id),
|
|
|
|
stop-mirroring(package-id),
|
2024-08-08 14:26:07 +03:00
|
|
|
}
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
variant download-responses {
|
|
|
|
success,
|
|
|
|
error(download-error),
|
|
|
|
get-files(list<entry>),
|
|
|
|
}
|
|
|
|
|
|
|
|
record local-download-request {
|
2024-08-06 21:06:43 +03:00
|
|
|
package-id: package-id,
|
2024-08-15 14:14:09 +03:00
|
|
|
download-from: string,
|
2024-08-08 14:26:07 +03:00
|
|
|
desired-version-hash: string,
|
2024-05-27 02:40:41 +03:00
|
|
|
}
|
|
|
|
|
2024-08-20 17:16:48 +03:00
|
|
|
record auto-update-request {
|
|
|
|
package-id: package-id,
|
|
|
|
metadata: onchain-metadata,
|
|
|
|
}
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
record remote-download-request {
|
|
|
|
package-id: package-id,
|
|
|
|
worker-address: string,
|
|
|
|
desired-version-hash: string,
|
|
|
|
}
|
|
|
|
|
2024-08-15 15:26:17 +03:00
|
|
|
variant download-error {
|
2024-08-15 14:14:09 +03:00
|
|
|
no-package,
|
|
|
|
not-mirroring,
|
2024-08-15 15:26:17 +03:00
|
|
|
hash-mismatch(hash-mismatch),
|
2024-08-15 14:14:09 +03:00
|
|
|
file-not-found,
|
|
|
|
worker-spawn-failed,
|
2024-08-19 18:39:48 +03:00
|
|
|
http-client-error,
|
|
|
|
blob-not-found,
|
|
|
|
vfs-error,
|
2024-08-08 14:26:07 +03:00
|
|
|
}
|
|
|
|
|
2024-08-16 22:23:27 +03:00
|
|
|
record download-complete-request {
|
|
|
|
package-id: package-id,
|
|
|
|
version-hash: string,
|
|
|
|
error: option<download-error>,
|
|
|
|
}
|
|
|
|
|
2024-08-15 15:26:17 +03:00
|
|
|
record hash-mismatch {
|
|
|
|
desired: string,
|
|
|
|
actual: string,
|
|
|
|
}
|
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
record chunk-request {
|
|
|
|
package-id: package-id,
|
|
|
|
version-hash: string,
|
|
|
|
offset: u64,
|
|
|
|
length: u64,
|
|
|
|
}
|
|
|
|
|
2024-08-15 17:15:55 +03:00
|
|
|
variant entry {
|
|
|
|
file(file-entry),
|
|
|
|
dir(dir-entry),
|
|
|
|
}
|
|
|
|
|
|
|
|
record file-entry {
|
|
|
|
name: string,
|
|
|
|
size: u64,
|
|
|
|
manifest: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
record dir-entry {
|
2024-08-09 19:23:36 +03:00
|
|
|
name: string,
|
2024-08-15 17:15:55 +03:00
|
|
|
mirroring: bool,
|
2024-08-09 19:23:36 +03:00
|
|
|
}
|
|
|
|
|
2024-08-16 01:23:47 +03:00
|
|
|
record remove-file-request {
|
|
|
|
package-id: package-id,
|
|
|
|
version-hash: string,
|
|
|
|
}
|
|
|
|
|
2024-08-13 03:32:52 +03:00
|
|
|
// part of new-package-request local-only flow.
|
|
|
|
record add-download-request {
|
|
|
|
package-id: package-id,
|
|
|
|
version-hash: string,
|
|
|
|
mirror: bool,
|
|
|
|
}
|
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
record progress-update {
|
|
|
|
package-id: package-id,
|
|
|
|
version-hash: string,
|
|
|
|
downloaded: u64,
|
|
|
|
total: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
record size-update {
|
|
|
|
package-id: package-id,
|
|
|
|
size: u64,
|
2024-08-06 21:06:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface chain {
|
|
|
|
//
|
|
|
|
// on-chain API as presented by chain:app_store:sys-v0
|
|
|
|
//
|
|
|
|
|
|
|
|
use standard.{package-id};
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
variant chain-requests {
|
2024-08-08 18:52:53 +03:00
|
|
|
get-app(package-id),
|
2024-08-13 17:27:41 +03:00
|
|
|
get-apps,
|
|
|
|
get-our-apps,
|
2024-08-08 18:52:53 +03:00
|
|
|
start-auto-update(package-id),
|
|
|
|
stop-auto-update(package-id),
|
|
|
|
}
|
2024-08-15 14:14:09 +03:00
|
|
|
|
|
|
|
variant chain-responses {
|
2024-08-15 15:26:17 +03:00
|
|
|
get-app(option<onchain-app>),
|
|
|
|
get-apps(list<onchain-app>),
|
|
|
|
get-our-apps(list<onchain-app>),
|
2024-08-15 14:14:09 +03:00
|
|
|
auto-update-started,
|
|
|
|
auto-update-stopped,
|
|
|
|
error(chain-error),
|
|
|
|
}
|
|
|
|
|
2024-08-15 15:26:17 +03:00
|
|
|
variant chain-error {
|
2024-08-15 14:14:09 +03:00
|
|
|
no-package,
|
|
|
|
}
|
2024-08-08 18:52:53 +03:00
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
record onchain-app {
|
2024-08-13 17:27:41 +03:00
|
|
|
package-id: package-id,
|
|
|
|
tba: string,
|
2024-08-06 21:06:43 +03:00
|
|
|
metadata-uri: string,
|
|
|
|
metadata-hash: string,
|
2024-08-15 14:14:09 +03:00
|
|
|
metadata: option<onchain-metadata>,
|
2024-08-13 17:27:41 +03:00
|
|
|
auto-update: bool,
|
2024-08-08 18:52:53 +03:00
|
|
|
}
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
record onchain-metadata {
|
2024-08-08 18:52:53 +03:00
|
|
|
name: option<string>,
|
|
|
|
description: option<string>,
|
|
|
|
image: option<string>,
|
|
|
|
external-url: option<string>,
|
|
|
|
animation-url: option<string>,
|
2024-08-15 14:14:09 +03:00
|
|
|
properties: onchain-properties,
|
2024-08-06 21:06:43 +03:00
|
|
|
}
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
record onchain-properties {
|
2024-05-27 02:40:41 +03:00
|
|
|
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>>,
|
|
|
|
}
|
2024-08-06 21:06:43 +03:00
|
|
|
}
|
2024-05-31 04:27:19 +03:00
|
|
|
|
2024-08-06 21:06:43 +03:00
|
|
|
interface main {
|
|
|
|
//
|
2024-08-08 14:26:07 +03:00
|
|
|
// app store API as presented by main:app_store:sys-v0
|
2024-08-06 21:06:43 +03:00
|
|
|
//
|
2024-05-27 02:40:41 +03:00
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
use standard.{package-id};
|
2024-08-15 14:14:09 +03:00
|
|
|
use chain.{onchain-metadata, chain-error};
|
|
|
|
use downloads.{download-error};
|
2024-08-13 03:32:52 +03:00
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
variant request {
|
|
|
|
local(local-request),
|
|
|
|
}
|
|
|
|
|
|
|
|
variant response {
|
|
|
|
local(local-response),
|
2024-08-15 15:26:17 +03:00
|
|
|
chain-error(chain-error),
|
|
|
|
download-error(download-error),
|
2024-08-15 14:14:09 +03:00
|
|
|
}
|
2024-08-08 14:26:07 +03:00
|
|
|
|
2024-05-27 02:40:41 +03:00
|
|
|
variant local-request {
|
2024-08-08 14:26:07 +03:00
|
|
|
new-package(new-package-request),
|
2024-08-13 03:32:52 +03:00
|
|
|
install(install-package-request),
|
2024-05-27 02:40:41 +03:00
|
|
|
uninstall(package-id),
|
|
|
|
apis,
|
|
|
|
get-api(package-id),
|
|
|
|
}
|
|
|
|
|
2024-08-15 14:14:09 +03:00
|
|
|
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),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
record new-package-request {
|
|
|
|
package-id: package-id,
|
|
|
|
mirror: bool,
|
|
|
|
}
|
2024-08-13 03:32:52 +03:00
|
|
|
|
|
|
|
record install-package-request {
|
|
|
|
package-id: package-id,
|
2024-08-15 14:14:09 +03:00
|
|
|
metadata: option<onchain-metadata>, // if None == local sideload package.
|
2024-08-13 03:32:52 +03:00
|
|
|
version-hash: string,
|
|
|
|
}
|
2024-05-27 02:40:41 +03:00
|
|
|
|
2024-08-08 14:26:07 +03:00
|
|
|
enum new-package-response {
|
|
|
|
success,
|
|
|
|
no-blob,
|
|
|
|
install-failed,
|
|
|
|
already-exists,
|
|
|
|
}
|
|
|
|
|
2024-05-27 02:40:41 +03:00
|
|
|
enum install-response {
|
|
|
|
success,
|
2024-08-15 14:14:09 +03:00
|
|
|
failure,
|
2024-05-27 02:40:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
enum uninstall-response {
|
|
|
|
success,
|
2024-08-15 14:14:09 +03:00
|
|
|
failure,
|
2024-05-27 02:40:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
record apis-response {
|
|
|
|
apis: list<package-id>,
|
|
|
|
}
|
|
|
|
|
|
|
|
// the API itself will be in response blob if success!
|
|
|
|
enum get-api-response {
|
|
|
|
success,
|
2024-08-15 14:14:09 +03:00
|
|
|
failure,
|
2024-05-27 02:40:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
world app-store-sys-v0 {
|
|
|
|
import main;
|
2024-08-08 14:26:07 +03:00
|
|
|
import downloads;
|
2024-08-06 21:06:43 +03:00
|
|
|
import chain;
|
2024-05-27 02:40:41 +03:00
|
|
|
include process-v0;
|
|
|
|
}
|