workflow

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeString

func SanitizeString(input string) string

Types

type FileInfo

type FileInfo struct {
	Name string
	Data []byte
}

type Runner

type Runner interface {
	Next(ctx context.Context) (*WorkflowStepResult, error)
}

type RunnerImpl

type RunnerImpl struct {
	// contains filtered or unexported fields
}

func (*RunnerImpl) Next

type RunnerMock

type RunnerMock struct {
	// NextFunc mocks the Next method.
	NextFunc func(ctx context.Context) (*WorkflowStepResult, error)
	// contains filtered or unexported fields
}

RunnerMock is a mock implementation of Runner.

func TestSomethingThatUsesRunner(t *testing.T) {

	// make and configure a mocked Runner
	mockedRunner := &RunnerMock{
		NextFunc: func(ctx context.Context) (*WorkflowStepResult, error) {
			panic("mock out the Next method")
		},
	}

	// use mockedRunner in code that requires Runner
	// and then make assertions.

}

func (*RunnerMock) Next

func (mock *RunnerMock) Next(ctx context.Context) (*WorkflowStepResult, error)

Next calls NextFunc.

func (*RunnerMock) NextCalls

func (mock *RunnerMock) NextCalls() []struct {
	Ctx context.Context
}

NextCalls gets all the calls that were made to Next. Check the length with:

len(mockedRunner.NextCalls())

type StartWorklfowRequest

type StartWorklfowRequest struct {
	Variables   map[string]any `json:"variables"`
	Model       string         `json:"model"`
	ImageModel  string         `json:"image_model"`
	Temperature float64        `json:"temperature"`
}

type StepContext

type StepContext struct {
	Table  string `json:"table"`
	Column string `json:"column"`
}

func (StepContext) AsMap

func (s StepContext) AsMap() map[string]string

type Workflow

type Workflow struct {
	ID          string                    `json:"id"`
	Name        string                    `json:"name"`
	Description string                    `json:"description"`
	Variables   []schema.WorkflowVariable `json:"variables"`
	Steps       []schema.WorkflowStep     `json:"steps"`
}

type WorkflowAction

type WorkflowAction string
const (
	WorkflowActionShowMessage WorkflowAction = "ShowMessage"
	WorkflowActionGenerate    WorkflowAction = "Genetate"
	WorkflowActionExport      WorkflowAction = "Export"
)

type WorkflowAutofillPayload

type WorkflowAutofillPayload struct {
	Count          any      `json:"count"`
	Batch          any      `json:"batch"`
	Table          string   `json:"table"`
	Columns        []string `json:"columns"`
	ContextColumns []string `json:"context_columns"`
}

type WorkflowCreateColumnParams

type WorkflowCreateColumnParams struct {
	Table       string `json:"table"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

type WorkflowCreateTablePayload

type WorkflowCreateTablePayload struct {
	SchemaFile string                       `json:"schema_file"`
	OnExists   schema.WorkflowTableOnExists `json:"on_exists"`
	Request    table.TableGenRequest        `json:"request"`
	Datasets   []string                     `json:"datasets"`
}

type WorkflowDeleteColumnParams

type WorkflowDeleteColumnParams struct {
	Table  string `json:"table"`
	Column string `json:"column"`
}

type WorkflowDeleteTableParams

type WorkflowDeleteTableParams struct {
	Table string `json:"table"`
}

type WorkflowExportTableParams

type WorkflowExportTableParams struct {
	Table string `json:"table"`
	Path  string `json:"path"`
}

type WorkflowGeneratePayload

type WorkflowGeneratePayload struct {
	Count any    `json:"count"`
	Batch any    `json:"batch"`
	Table string `json:"table"`
}

type WorkflowImportFileParams

type WorkflowImportFileParams struct {
	Table    string `json:"table"`
	Name     string `json:"name"`
	File     string `json:"file"`
	Prompt   string `json:"prompt"`
	Truncate bool   `json:"truncate"`
}

type WorkflowService

type WorkflowService interface {
	Get(ctx context.Context, wf string) (*ent.Workflow, error)
	Delete(ctx context.Context, wf string) error
	Create(ctx context.Context, wf *Workflow) (string, error)
	Update(ctx context.Context, id string, wf *Workflow) (string, error)
	Start(ctx context.Context, id string, request StartWorklfowRequest) (Runner, error)
	List(ctx context.Context) ([]*ent.Workflow, error)
}

type WorkflowServiceImpl

type WorkflowServiceImpl struct {
	// contains filtered or unexported fields
}

func NewWorkflowService

func NewWorkflowService(db *ent.Client, table table.TableService) *WorkflowServiceImpl

func (*WorkflowServiceImpl) Create

func (w *WorkflowServiceImpl) Create(ctx context.Context, wf *Workflow) (string, error)

func (*WorkflowServiceImpl) Delete

func (w *WorkflowServiceImpl) Delete(ctx context.Context, wf string) error

func (*WorkflowServiceImpl) Get

func (*WorkflowServiceImpl) List

func (w *WorkflowServiceImpl) List(ctx context.Context) ([]*ent.Workflow, error)

func (*WorkflowServiceImpl) Start

func (*WorkflowServiceImpl) Update

func (w *WorkflowServiceImpl) Update(ctx context.Context, id string, wf *Workflow) (string, error)

type WorkflowServiceMock

type WorkflowServiceMock struct {
	// CreateFunc mocks the Create method.
	CreateFunc func(ctx context.Context, wf *Workflow) (string, error)

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, wf string) error

	// GetFunc mocks the Get method.
	GetFunc func(ctx context.Context, wf string) (*ent.Workflow, error)

	// ListFunc mocks the List method.
	ListFunc func(ctx context.Context) ([]*ent.Workflow, error)

	// StartFunc mocks the Start method.
	StartFunc func(ctx context.Context, id string, request StartWorklfowRequest) (Runner, error)

	// UpdateFunc mocks the Update method.
	UpdateFunc func(ctx context.Context, id string, wf *Workflow) (string, error)
	// contains filtered or unexported fields
}

WorkflowServiceMock is a mock implementation of WorkflowService.

func TestSomethingThatUsesWorkflowService(t *testing.T) {

	// make and configure a mocked WorkflowService
	mockedWorkflowService := &WorkflowServiceMock{
		CreateFunc: func(ctx context.Context, wf *Workflow) (string, error) {
			panic("mock out the Create method")
		},
		DeleteFunc: func(ctx context.Context, wf string) error {
			panic("mock out the Delete method")
		},
		GetFunc: func(ctx context.Context, wf string) (*ent.Workflow, error) {
			panic("mock out the Get method")
		},
		ListFunc: func(ctx context.Context) ([]*ent.Workflow, error) {
			panic("mock out the List method")
		},
		StartFunc: func(ctx context.Context, id string, request StartWorklfowRequest) (Runner, error) {
			panic("mock out the Start method")
		},
		UpdateFunc: func(ctx context.Context, id string, wf *Workflow) (string, error) {
			panic("mock out the Update method")
		},
	}

	// use mockedWorkflowService in code that requires WorkflowService
	// and then make assertions.

}

func (*WorkflowServiceMock) Create

func (mock *WorkflowServiceMock) Create(ctx context.Context, wf *Workflow) (string, error)

Create calls CreateFunc.

func (*WorkflowServiceMock) CreateCalls

func (mock *WorkflowServiceMock) CreateCalls() []struct {
	Ctx context.Context
	Wf  *Workflow
}

CreateCalls gets all the calls that were made to Create. Check the length with:

len(mockedWorkflowService.CreateCalls())

func (*WorkflowServiceMock) Delete

func (mock *WorkflowServiceMock) Delete(ctx context.Context, wf string) error

Delete calls DeleteFunc.

func (*WorkflowServiceMock) DeleteCalls

func (mock *WorkflowServiceMock) DeleteCalls() []struct {
	Ctx context.Context
	Wf  string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedWorkflowService.DeleteCalls())

func (*WorkflowServiceMock) Get

func (mock *WorkflowServiceMock) Get(ctx context.Context, wf string) (*ent.Workflow, error)

Get calls GetFunc.

func (*WorkflowServiceMock) GetCalls

func (mock *WorkflowServiceMock) GetCalls() []struct {
	Ctx context.Context
	Wf  string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedWorkflowService.GetCalls())

func (*WorkflowServiceMock) List

func (mock *WorkflowServiceMock) List(ctx context.Context) ([]*ent.Workflow, error)

List calls ListFunc.

func (*WorkflowServiceMock) ListCalls

func (mock *WorkflowServiceMock) ListCalls() []struct {
	Ctx context.Context
}

ListCalls gets all the calls that were made to List. Check the length with:

len(mockedWorkflowService.ListCalls())

func (*WorkflowServiceMock) Start

func (mock *WorkflowServiceMock) Start(ctx context.Context, id string, request StartWorklfowRequest) (Runner, error)

Start calls StartFunc.

func (*WorkflowServiceMock) StartCalls

func (mock *WorkflowServiceMock) StartCalls() []struct {
	Ctx     context.Context
	ID      string
	Request StartWorklfowRequest
}

StartCalls gets all the calls that were made to Start. Check the length with:

len(mockedWorkflowService.StartCalls())

func (*WorkflowServiceMock) Update

func (mock *WorkflowServiceMock) Update(ctx context.Context, id string, wf *Workflow) (string, error)

Update calls UpdateFunc.

func (*WorkflowServiceMock) UpdateCalls

func (mock *WorkflowServiceMock) UpdateCalls() []struct {
	Ctx context.Context
	ID  string
	Wf  *Workflow
}

UpdateCalls gets all the calls that were made to Update. Check the length with:

len(mockedWorkflowService.UpdateCalls())

type WorkflowSimple

type WorkflowSimple struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type WorkflowStepResult

type WorkflowStepResult struct {
	Action     WorkflowAction
	Message    string
	ExportData string
	ExportPath string
	Generator  table.RowsGenerator
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL