nectar/kinode/packages/app_store/api/app_store:sys-v0.wit
2024-08-06 21:06:43 +03:00

133 lines
3.1 KiB
Plaintext

interface download {
//
// download API as presented by download:app_store:sys-v0
//
use standard.{package-id};
record download-request {
package-id: package-id,
download-from: string,
desired-version-hash: option<string>,
}
// I wonder if these should be long-running instead.
// updates from FT worker or lack of them might come back as updates first, which is fine.
// the approve/deny is useful but not guaranteed, could be an intra process thing, separate request.
variant download-response {
started,
bad-response,
denied(reason),
already-exists,
already-downloading,
}
}
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 {
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-app {
app: package-id,
}
record get-app-response {
app: on-chain-app,
}
// add variant
// and these:
// start-mirroring(package-id),
// stop-mirroring(package-id),
// start-auto-update(package-id),
// stop-auto-update(package-id),
}
interface main {
//
// app store API as presented by :app_store:sys-v0
//
variant local-request {
install(package-id), // bytes in blob?
uninstall(package-id),
rebuild-index,
apis,
get-api(package-id),
}
use standard.{package-id};
// find a place for these, error type for each world.
// 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-response {
install-response(install-response),
uninstall-response(uninstall-response),
rebuild-index-response(rebuild-index-response),
apis-response(apis-response),
get-api-response(get-api-response),
}
enum install-response {
success,
failure, // TODO
}
enum uninstall-response {
success,
failure, // TODO
}
// TODO: not sure where exactly these should be
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 download;
import chain;
include process-v0;
}