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

245 lines
5.2 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-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),
get-files(option<package-id>),
add-download(add-download-request),
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
}
record remote-download-request {
package-id: package-id,
worker-address: string,
desired-version-hash: string,
}
record download-error {
kind: download-error-types,
reason: option<string>,
}
enum download-error-types {
no-package,
not-mirroring,
hash-mismatch,
file-not-found,
worker-spawn-failed,
2024-08-08 14:26:07 +03:00
}
record chunk-request {
package-id: package-id,
version-hash: string,
offset: u64,
length: u64,
}
record entry {
name: string,
is-file: bool,
size: option<u64>,
manifest: option<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 {
get-app(get-app-response),
get-apps(get-apps-response),
get-our-apps(get-our-apps-response),
auto-update-started,
auto-update-stopped,
error(chain-error),
}
record chain-error {
kind: chain-error-types,
reason: option<string>,
}
enum chain-error-types {
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-13 17:27:41 +03:00
record get-apps-response {
apps: list<onchain-app>,
2024-08-13 17:27:41 +03:00
}
2024-08-06 21:06:43 +03:00
record get-app-response {
app: option<onchain-app>,
2024-05-27 02:40:41 +03:00
}
2024-08-13 17:27:41 +03:00
record get-our-apps-response {
apps: list<onchain-app>,
2024-08-13 17:27:41 +03:00
}
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),
error(error-types),
2024-08-08 14:26:07 +03:00
}
variant error-types {
chain(chain-error),
download(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;
}