fn(request$0) =>
let hash$1 = @definy.string-trim(
value: match @definy.json-get-string(value: $0, key: "contentHash") {
#some(text$2) =>
$2,
#none(_) =>
""
}
);
match @core.equal(left: $1, right: "") {
true =>
match @definy.json-get-strings(value: $0, key: "contentHashes") {
#none(_) =>
@definy.rpc-error(code: "invalid_argument", message: "contentHash or contentHashes is required"),
#some(hashes$3) =>
@definy.store-read-contents(
content_hashes: $3,
then: fn(items$4) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{key: "items", value: #array<@definy.json>(@definy.found-content-items-json(items: $4, index: 0))}
])
)
)
},
false =>
@definy.store-read-contents(
content_hashes: [$1],
then: fn(items$5) =>
match @core.list-get(list: $5, index: 0) {
#none(_) =>
@definy.rpc-error(
code: "not_found",
message: @core.string-concat(left: @core.string-concat(left: "Content '", right: $1), right: "' not found")
),
#some(element$97001) =>
match $97001 {
#none(_) =>
@definy.rpc-error(
code: "not_found",
message: @core.string-concat(left: @core.string-concat(left: "Content '", right: $1), right: "' not found")
),
#some(item$6) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([{key: "item", value: @definy.content-item-json(item: $6)}])
)
}
}
)
}