Explorer

definy.decode-stored-snapshot-summary

description
The light summary of a stored project snapshot (the same as definy.snapshot-cache-entry-summary of definy.decode-stored-snapshot) read directly from the event: its modules have their IDs but no parts. It does not read the parts or compute their IDs (core.module-part-ids), so it is much lighter than the full snapshot. none if the event is not a project snapshot
type
Fn(signed_event_bytes: String) -> Union{#none, #some(@definy.stored-snapshot)}
expression
fn(signed_event_bytes$0) =>
  match @std.base64-to-bytes(text: $0) {
    #none(_) =>
      #none,
    #some(bytes$1) =>
      match @definy.decode-signed-event-with(
          bytes: $1,
          content: fn(cbor$2) =>
            @definy.snapshot-cbor-without-parts(cbor: $2)
        ) {
        #decoded(decoded$3) =>
          match $3.content {
            #project_commit(commit$4) =>
              #some({
                account_id: @core.bytes-to-base64url(bytes: $3.account_id_bytes),
                project_name: $4.project_name,
                branch: $4.branch,
                time_ms: $3.time_ms,
                message: $4.message,
                parent_commit_hash: $4.parent_commit_hash,
                merged_commit_hash: $4.merged_commit_hash,
                modules: @core.list-map(
                  T: @core.project-snapshot-module,
                  U: @definy.stored-snapshot-module,
                  f: fn(item$5) =>
                    {
                      name: $5.name,
                      id: @core.module-id(module_name: $5.name),
                      description: $5.description,
                      visibility: $5.visibility,
                      parts: []
                    },
                  xs: $4.modules
                )
              }),
            _ =>
              #none
          },
        #invalid(_) =>
          #none
      }
  }
visibility
public
definy.decode-stored-snapshot-summary (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: XlBpYICW7UVqCR2-NzXP--8iguMNyM6YNhAdafkkmtk
content hash: OxwZ2XcQ4Gx33rwtHluLWWdwNUcBgnFq-QXIN8zpRes