nectar/kinode/packages/app_store/api/app_store:sys-v0.wit

258 lines
5.6 KiB
Plaintext
Raw Normal View History

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
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
local-download(local-download-request),
2024-08-20 17:16:48 +03:00
auto-update(auto-update-request),
download-complete(download-complete-request),
get-files(option<package-id>),
2024-08-16 01:23:47 +03:00
remove-file(remove-file-request),
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
}
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,
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,
}
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 {
no-package,
not-mirroring,
2024-08-15 15:26:17 +03:00
hash-mismatch(hash-mismatch),
file-not-found,
worker-spawn-failed,
http-client-error,
blob-not-found,
vfs-error,
2024-08-08 14:26:07 +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 {
name: string,
2024-08-15 17:15:55 +03:00
mirroring: bool,
}
2024-08-16 01:23:47 +03:00
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,
}
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};
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),
}
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>),
auto-update-started,
auto-update-stopped,
error(chain-error),
}
2024-08-15 15:26:17 +03:00
variant chain-error {
no-package,
}
2024-08-08 18:52:53 +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,
metadata: option<onchain-metadata>,
2024-08-13 17:27:41 +03:00
auto-update: bool,
2024-08-08 18:52:53 +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>,
properties: onchain-properties,
2024-08-06 21:06:43 +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-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};
use chain.{onchain-metadata, chain-error};
use downloads.{download-error};
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-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),
install(install-package-request),
2024-05-27 02:40:41 +03:00
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),
}
2024-08-08 14:26:07 +03:00
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,
}
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,
failure,
2024-05-27 02:40:41 +03:00
}
enum uninstall-response {
success,
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,
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;
}