Explorer

definy.read-snapshot-content

description
Read the content of a stored project snapshot event (with module descriptions and part content hashes)
type
Fn(
  event_hash: String,
  then: Fn(commit: Union{#none, #some(@core.project-snapshot)}) -> @definy.service-io
) -> @definy.service-io
expression
fn(event_hash$0, then$1) =>
  @definy.store-read-events(
    event_hashes: [$0],
    then: fn(events$2) =>
      $1(
        commit: match @core.list-get(list: $2, index: 0) {
          #some(element$3) =>
            match $3 {
              #some(event$4) =>
                match @std.base64-to-bytes(text: $4.signed_event_bytes) {
                  #some(bytes$5) =>
                    match @definy.decode-signed-event(bytes: $5) {
                      #decoded(decoded$6) =>
                        match $6.content {
                          #project_commit(commit$7) =>
                            #some($7),
                          _ =>
                            #none
                        },
                      #invalid(_) =>
                        #none
                    },
                  #none(_) =>
                    #none
                },
              #none(_) =>
                #none
            },
          #none(_) =>
            #none
        }
      )
  )
visibility
public
definy.read-snapshot-content (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: JJz-rVnWyrS7Lrgb2YkWny5QP6uWjHGXk6Xsj1lpCPo
content hash: RzwMWlSaER_XcuCb71Dza16JQUrRa6vgKNSJDJi70SY