Explorer

definy.resolve-snapshot-contents

description
Find the contents of the parts of a snapshot by evaluating their definitions in the snapshot (docs/part-definition.md, docs/service.md)
type
Fn(
  parts: List<@definy.snapshot-check-source-part>,
  resolutions: List<List<@definy.resolution-cache-entry>>,
  then: Fn(parts: List<@definy.snapshot-check-part>, fresh: List<@definy.snapshot-check-part>) -> @definy.service-io
) -> @definy.service-io
expression
fn(parts$0, then$1, resolutions$12) =>
  let immediate$2 = @core.list-fold(
      T: @definy.snapshot-check-source-part,
      A: Record{
        contents: List<@definy.resolved-part-content>,
        pending: List<@definy.pending-definition>,
        fresh: List<@definy.snapshot-check-part>
      },
      reducer: fn(acc$3, item$4) =>
        match @definy.resolution-for(resolutions: $12, content_hash: $4.content_hash) {
          #some(hit$7) =>
            {
              contents: @core.list-append(list: $3.contents, item: {id: $4.id, content: $7.content}),
              pending: $3.pending,
              fresh: $3.fresh
            },
          #none(_) =>
            match $4.definition {
              #none(_) =>
                $3,
              #some(definition$5) =>
                match @definy.immediate-part-content(definition: $5) {
                  #some(#some(content$6)) =>
                    {
                      contents: @core.list-append(list: $3.contents, item: {id: $4.id, content: $6}),
                      pending: $3.pending,
                      fresh: @core.list-append(
                        list: $3.fresh,
                        item: {
                          id: $4.id,
                          name: $4.name,
                          module_name: $4.module_name,
                          module_id: $4.module_id,
                          module_visibility: $4.module_visibility,
                          content_hash: $4.content_hash,
                          content: #some($6),
                          definition_check: #none
                        }
                      )
                    },
                  #some(#none(_)) =>
                    $3,
                  #none(_) =>
                    {
                      contents: $3.contents,
                      pending: @core.list-append(list: $3.pending, item: {id: $4.id, definition: $5}),
                      fresh: $3.fresh
                    }
                }
            }
        },
      init: {contents: [], pending: [], fresh: []},
      xs: $0
    );
  match @core.equal(left: @core.list-length(value: $2.pending), right: 0) {
    true =>
      $1(
        parts: @definy.snapshot-check-parts-of(sources: $0, contents: $2.contents, evaluated: []),
        fresh: $2.fresh
      ),
    false =>
      @definy.collect-evaluation-parts(
        frontier: @core.list-fold(
          T: @definy.pending-definition,
          A: List<String>,
          reducer: fn(acc$7, item$8) =>
            @definy.evaluated-part-references(expr: $8.definition, ids: $7),
          init: [],
          xs: $2.pending
        ),
        seen: [],
        external: [],
        sources: $0,
        contents: $2.contents,
        then: fn(external$9) =>
          @definy.evaluate-pending-definitions(
            pending: $2.pending,
            contents: $2.contents,
            external: $9,
            evaluated: [],
            then: fn(contents$10, evaluated$11) =>
              $1(
                parts: @definy.snapshot-check-parts-of(sources: $0, contents: $10, evaluated: $11),
                fresh: $2.fresh
              )
          )
      )
  }
visibility
public
definy.resolve-snapshot-contents (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: nWpdZEOz9HZkCCyX_Np9ed-nsAw0lRpH9QE1ENDpemc
content hash: a-lsX2DqiCZwVbq-Y1f8AjKCAJNO2zbI_YUeWHi6Wok