fn(project$0, branch$1, part$2) =>
match @definy.parse-expression-text(text: @core.string-concat(left: "@", right: $2)) {
#error(message$3) =>
@definy.rpc-error(code: "invalid_argument", message: $3),
#ok(expression$4) =>
@definy.read-snapshots(
then: fn(commits$5) =>
match @definy.run-expression-snapshots(
arguments: #object<@definy.json>([
{key: "project", value: #string<@definy.json>($0)},
{key: "branch", value: #string<@definy.json>($1)}
]),
commits: $5
) {
#error(message$6) =>
@definy.rpc-error(code: "not_found", message: $6),
#ok(branch$7) =>
@definy.read-part-contents(
parts: @definy.snapshot-parts-flat(commits: $7, index: 0),
then: fn(parts$8) =>
let local$9 = @html-ui.local-closure(
frontier: @core.expression-part-references(expr: $4, ids: []),
parts: @definy.run-expression-parts(parts: $8),
acc: []
);
@definy.collect-evaluation-parts(
frontier: @definy.run-io-frontier(expression: $4, parts: $9),
seen: @core.list-map(
T: Record{id: String, expression: @core.expression},
U: String,
f: fn(item$10) =>
$10.id,
xs: $9
),
external: [],
sources: [],
contents: [],
then: fn(external$11) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{
key: "expressionBytes",
value: #string<@definy.json>(@definy.expression-cbor-base64(expression: $4))
},
{
key: "parts",
value: #array<@definy.json>(@core.list-map(
T: Record{id: String, expression: @core.expression},
U: @definy.json,
f: fn(item$12) =>
#object<@definy.json>([
{key: "id", value: #string<@definy.json>($12.id)},
{
key: "cborBytes",
value: #string<@definy.json>(@definy.expression-cbor-base64(expression: $12.expression))
}
]),
xs: @core.list-concat(left: $9, right: $11)
))
}
])
)
)
)
}
)
}