package maf:bindings;
interface bindings {
use wasi:io/poll@0.2.6.{pollable};
variant message {
binary(list<u8>),
text(string),
}
variant hook-body {
json(string),
none
}
variant send-error {
closed,
buffer-full,
}
variant hook-request-error {
init-consumed,
}
resource user {
meta: func() -> user-meta;
listen-message: func() -> result<future-message, listen-error>;
send: func(message: message) -> result<_, send-error>;
}
record user-meta {
id: tuple<u64, u64>,
auth: option<string>,
}
record request {
user: user,
path: string,
}
resource future-message {
subscribe: func() -> result<pollable, listen-error>;
get: func() -> result<message, listen-error>;
}
resource future-user {
subscribe: func() -> result<pollable, listen-error>;
get: func() -> result<user, listen-error>;
}
variant hook-request-caller {
service
}
record hook-request-init {
caller: hook-request-caller,
method: string,
data: hook-body,
}
resource hook-request {
init: func() -> result<hook-request-init, hook-request-error>;
respond: func(response: hook-body) -> result<_, send-error>;
}
resource future-hook-request {
subscribe: func() -> result<pollable, listen-error>;
get: func() -> result<hook-request, listen-error>;
}
variant listen-error {
already-listening,
not-ready,
closed
}
variant meta-visibility {
public,
private
}
record meta-entry {
visibility: meta-visibility,
value: string,
}
listen-user: func() -> result<future-user, listen-error>;
listen-hook-request: func() -> result<future-hook-request, listen-error>;
report-app-schema: func(schema: string);
set-meta: func(visibility: meta-visibility, key: string, value: string) -> option<meta-entry>;
get-meta: func(key: string) -> option<meta-entry>;
delete-meta: func(key: string) -> option<meta-entry>;
list-meta: func() -> list<tuple<string, meta-entry>>;
}
world imports {
import bindings;
export run: func() -> result;
export dry-run: func() -> result;
}