github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/lib/changes.go (about)

     1  package lib
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/qri-io/qri/changes"
     7  )
     8  
     9  // ChangeReportParams defines parameters for diffing two sources
    10  type ChangeReportParams struct {
    11  	LeftRef  string `schema:"leftRef" json:"leftRef"`
    12  	RightRef string `schema:"rightRef" json:"rightRef"`
    13  }
    14  
    15  // ChangeReport is a simple utility type declaration
    16  type ChangeReport = changes.ChangeReportResponse
    17  
    18  // Changes resolves the requested datasets and tries to generate a change report
    19  func (m DiffMethods) Changes(ctx context.Context, p *ChangeReportParams) (*ChangeReport, error) {
    20  	got, _, err := m.d.Dispatch(ctx, dispatchMethodName(m, "changes"), p)
    21  	if res, ok := got.(*ChangeReport); ok {
    22  		return res, err
    23  	}
    24  	return nil, dispatchReturnError(got, err)
    25  }
    26  
    27  // Changes generates report of changes between two datasets
    28  func (diffImpl) Changes(scope scope, p *ChangeReportParams) (*ChangeReport, error) {
    29  	svc := changes.New(scope.Loader(), scope.Stats())
    30  	return svc.Report(scope.Context(), p.LeftRef, p.RightRef)
    31  }