fn(request$0, http_request$9000) =>
@definy.read-rpc-authorization(
request: $9000,
then: fn(authorization$1) =>
match $1 {
#anonymous(_) =>
@definy.rpc-error(code: "unauthenticated", message: "RunService/RunIo requires an Authorization header"),
#invalid(message$2) =>
@definy.rpc-error(code: "unauthenticated", message: $2),
#account(account_id$3) =>
@definy.is-admin-account(
account_id: $3,
then: fn(is_admin$4) =>
match $4 {
false =>
@definy.rpc-error(
code: "permission_denied",
message: "Only the administrators of this server (DEFINY_ADMIN_ACCOUNT_IDS) can run programs on it"
),
true =>
#read_host_settings<@definy.service-io>({
then: fn(settings$5) =>
match $5.run_expressions {
false =>
@definy.rpc-error(
code: "failed_precondition",
message: "This server cannot run programs (only a definy server on Node.js such as node host.js can). Run it in the browser"
),
true =>
#run_wasi_io<@definy.service-io>({
wasm: match @definy.json-get-string(value: $0, key: "wasmBase64") {
#some(wasm$6) =>
$6,
#none(_) =>
""
},
parts: match @definy.json-get(value: $0, key: "parts") {
#some(#array(items$7)) =>
@definy.json-wasi-io-parts(items: $7),
_ =>
[]
},
then: fn(result$8) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{key: "ok", value: #boolean<@definy.json>($8.ok)},
{key: "message", value: #string<@definy.json>($8.message)},
{
key: "steps",
value: #array<@definy.json>(@core.list-map(
T: String,
U: @definy.json,
f: fn(item$9) =>
#string<@definy.json>($9),
xs: $8.steps
))
}
])
)
})
}
})
}
)
}
)