Explorer

html-ui.run-parts

description
GET /run-parts?project=&branch=&part=: the expression of the part (@<part>) and every part it may use, as CBOR ({expression, parts: [{id, cbor}]}), for running the program in the browser (html-ui.browser-run-script). The parts are those of the branch and the ones outside it that they refer to (with the references in quote, like definy_run_io). No type check
type
Fn(project: String, branch: String, part: String) -> @definy.service-io
expression
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)
                            ))
                          }
                        ])
                      )
                  )
              )
          }
      )
  }
visibility
public
html-ui.run-parts (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: fJMtlqN7kcoLHxYPduNe4qqSTNSzW5nqomVMpET_y5A
content hash: sHlPWNudpNFg_M5GzYoDG53A7UotMw6WqOHa6h9M-P8