Explorer

definy.with-branch-part-contents

description
Read the latest snapshot of a branch, the part named part (module.name) and the contents of all the parts of the snapshot, or answer an MCP error
type
Fn(
  project: String,
  branch: String,
  part: String,
  then: Fn(
    commit: @definy.event-snapshot,
    target: @definy.snapshot-check-part,
    parts: List<@definy.snapshot-check-part>
  ) -> @definy.service-io
) -> @definy.service-io
expression
fn(project$0, branch$1, part$2, then$3) =>
  @definy.read-branch-snapshot(
    project: $0,
    branch: $1,
    then: fn(commit$4, commits$5) =>
      match $4 {
        #none(_) =>
          @definy.mcp-text-error(
            text: @std.string-join(items: ["Branch ", $1, " of project ", $0, " was not found"], separator: "")
          ),
        #some(found$6) =>
          let stored$7 = @definy.snapshot-parts(modules: $6.commit.modules, index: 0);
          match @definy.stored-part-find(parts: $7, name: $2, index: 0) {
            #none(_) =>
              @definy.mcp-text-error(
                text: @std.string-join(items: ["Part ", $2, " was not found in branch ", $1, " of project ", $0], separator: "")
              ),
            #some(target$8) =>
              @definy.read-part-contents(
                parts: $7,
                then: fn(parts$9) =>
                  match @core.list-find-last-by-field(list: $9, field: "id", value: $8.id) {
                    #some(resolved$10) =>
                      $3(commit: $6, target: $10, parts: $9),
                    #none(_) =>
                      @definy.mcp-text-error(text: "The part could not be read")
                  }
              )
          }
      }
  )
visibility
public
definy.with-branch-part-contents (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: vxiWi1xqwxvDIDh_EfNxU8RIhWj9ED6OQcpM4KT30v4
content hash: rA7fvtm81ZX4E3EcjxiHkRWBYvz4ZSNhELUVbGEJ910