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

253 lines
5.7 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
2024-08-08 14:26:07 +03:00
variant downloads {
download(download-request),
chunk(chunk-request),
progress(progress-update),
size(size-update),
}
2024-08-06 21:06:43 +03:00
record download-request {
package-id: package-id,
2024-08-08 14:26:07 +03:00
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,
2024-05-27 02:40:41 +03:00
}
2024-08-08 14:26:07 +03:00
record download-response {
success: bool,
error: option<string>,
}
record chunk-request {
package-id: package-id,
version-hash: string,
offset: u64,
length: u64,
}
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};
record on-chain-app {
metadata-uri: string,
metadata-hash: string,
// this might be a thing internally, but could also just be fetched on demand
// would negate them becoming outdated
metadata: option<metadata-file>,
}
record metadata-file {
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
record get-app {
app: package-id,
2024-05-27 02:40:41 +03:00
}
2024-08-06 21:06:43 +03:00
record get-app-response {
app: on-chain-app,
2024-05-27 02:40:41 +03:00
}
2024-08-06 21:06:43 +03:00
// add variant
// and these:
// start-mirroring(package-id),
// stop-mirroring(package-id),
// start-auto-update(package-id),
// stop-auto-update(package-id),
2024-05-27 02:40: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};
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>>,
}
variant request {
remote(remote-request),
local(local-request),
}
variant response {
remote(remote-response),
local(local-response),
}
variant remote-request {
download(remote-download-request),
}
record remote-download-request {
package-id: package-id,
desired-version-hash: option<string>,
}
variant remote-response {
download-approved,
download-denied(reason),
}
variant reason {
no-package,
not-mirroring,
hash-mismatch(hash-mismatch),
file-not-found,
worker-spawn-failed
}
record hash-mismatch {
requested: string,
have: string,
}
2024-05-27 02:40:41 +03:00
variant local-request {
2024-08-08 14:26:07 +03:00
new-package(new-package-request),
download(download-request),
install(package-id),
2024-05-27 02:40:41 +03:00
uninstall(package-id),
2024-08-08 14:26:07 +03:00
start-mirroring(package-id),
stop-mirroring(package-id),
start-auto-update(package-id),
stop-auto-update(package-id),
2024-05-27 02:40:41 +03:00
rebuild-index,
apis,
get-api(package-id),
}
2024-08-08 14:26:07 +03:00
record new-package-request {
package-id: package-id,
metadata: onchain-metadata,
mirror: bool,
}
2024-05-27 02:40:41 +03:00
2024-08-08 14:26:07 +03:00
record download-request {
package-id: package-id,
download-from: string,
mirror: bool,
auto-update: bool,
desired-version-hash: option<string>,
}
2024-05-27 02:40:41 +03:00
variant local-response {
2024-08-08 14:26:07 +03:00
new-package-response(new-package-response),
download-response(download-response),
2024-05-27 02:40:41 +03:00
install-response(install-response),
uninstall-response(uninstall-response),
2024-08-08 14:26:07 +03:00
mirror-response(mirror-response),
auto-update-response(auto-update-response),
2024-05-27 02:40:41 +03:00
rebuild-index-response(rebuild-index-response),
apis-response(apis-response),
get-api-response(get-api-response),
}
2024-08-08 14:26:07 +03:00
enum new-package-response {
success,
no-blob,
install-failed,
already-exists,
}
variant download-response {
started,
bad-response,
denied(reason),
already-exists,
already-downloading,
}
2024-05-27 02:40:41 +03:00
enum install-response {
success,
failure, // TODO
}
enum uninstall-response {
success,
failure, // TODO
}
2024-08-08 14:26:07 +03:00
enum mirror-response {
success,
failure, // TODO
}
enum auto-update-response {
success,
failure, // TODO
}
enum rebuild-index-response {
success,
failure, // TODO
}
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, // TODO
}
}
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;
}