usecase

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiagramUseCase

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

DiagramUseCase implements the business logic for diagram operations.

func NewDiagramUseCase

func NewDiagramUseCase(repo repository.DiagramRepository) *DiagramUseCase

NewDiagramUseCase creates a new diagram usecase instance.

func (*DiagramUseCase) Create

func (uc *DiagramUseCase) Create(ctx context.Context, id string, content string) error

Create creates a diagram with the given ID and optional content. This is a convenience method that handles both empty and pre-populated diagrams.

func (*DiagramUseCase) CreateDiagram

func (uc *DiagramUseCase) CreateDiagram(ctx context.Context, diagram *entity.Diagram) error

CreateDiagram creates a new diagram programmatically.

func (*DiagramUseCase) ExportDiagram

func (uc *DiagramUseCase) ExportDiagram(ctx context.Context, diagramID string, format entity.ExportFormat) (io.Reader, error)

ExportDiagram exports the diagram to the specified format.

func (*DiagramUseCase) ExportDiagramWithOptions

func (uc *DiagramUseCase) ExportDiagramWithOptions(ctx context.Context, diagramID string, format entity.ExportFormat, options entity.RenderOptions) (io.Reader, error)

ExportDiagramWithOptions exports a stored diagram using typed D2 v0.9 options.

func (*DiagramUseCase) FormatSource

func (uc *DiagramUseCase) FormatSource(ctx context.Context, content string) (string, error)

FormatSource formats valid source without changing stored diagrams.

func (*DiagramUseCase) GetSource

func (uc *DiagramUseCase) GetSource(ctx context.Context, diagramID string) (string, error)

GetSource returns the canonical source for a stored diagram.

func (*DiagramUseCase) RenderDiagram

func (uc *DiagramUseCase) RenderDiagram(ctx context.Context, content string, format entity.ExportFormat, theme *entity.Theme) (io.Reader, error)

RenderDiagram renders D2 text into a diagram.

func (*DiagramUseCase) RenderDiagramWithOptions

func (uc *DiagramUseCase) RenderDiagramWithOptions(ctx context.Context, content string, format entity.ExportFormat, options entity.RenderOptions) (io.Reader, error)

RenderDiagramWithOptions renders D2 text using the typed D2 v0.9 options.

func (*DiagramUseCase) UpdateSource

func (uc *DiagramUseCase) UpdateSource(ctx context.Context, diagramID, content string) (*entity.DiagramValidationResult, error)

UpdateSource validates and atomically replaces a stored diagram's source.

func (*DiagramUseCase) ValidateDiagram

func (uc *DiagramUseCase) ValidateDiagram(ctx context.Context, content, diagramID *string) (*entity.DiagramValidationResult, error)

ValidateDiagram validates raw source or the current source of a stored diagram.

type OracleUseCase

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

OracleUseCase implements business logic for Oracle operations

func NewOracleUseCase

func NewOracleUseCase(repo repository.OracleRepository) *OracleUseCase

NewOracleUseCase creates a new Oracle use case

func (*OracleUseCase) CreateElement

func (uc *OracleUseCase) CreateElement(ctx context.Context, op *entity.OracleOperation) (*entity.OracleResult, error)

CreateElement creates a new diagram element

func (*OracleUseCase) DeleteElement

func (uc *OracleUseCase) DeleteElement(ctx context.Context, op *entity.OracleOperation) (*entity.OracleResult, error)

DeleteElement deletes a diagram element

func (*OracleUseCase) ExecuteOperation

func (uc *OracleUseCase) ExecuteOperation(ctx context.Context, op *entity.OracleOperation) (*entity.OracleResult, error)

ExecuteOperation executes a single Oracle operation based on its type

func (*OracleUseCase) GetChildren

func (uc *OracleUseCase) GetChildren(ctx context.Context, diagramID string, boardPath []string, parentID string) ([]string, error)

GetChildren retrieves child element IDs

func (*OracleUseCase) GetEdge

func (uc *OracleUseCase) GetEdge(ctx context.Context, diagramID string, boardPath []string, edgeID string) (*entity.GraphEdge, error)

GetEdge retrieves edge information

func (*OracleUseCase) GetObject

func (uc *OracleUseCase) GetObject(ctx context.Context, diagramID string, boardPath []string, objectID string) (*entity.GraphObject, error)

GetObject retrieves object information

func (*OracleUseCase) LoadDiagram

func (uc *OracleUseCase) LoadDiagram(ctx context.Context, diagramID string, content string) error

LoadDiagram loads a diagram from D2 text

func (*OracleUseCase) MoveElement

MoveElement moves a diagram element to a new container

func (*OracleUseCase) RenameElement

func (uc *OracleUseCase) RenameElement(ctx context.Context, op *entity.OracleOperation) (*entity.OracleResult, error)

RenameElement renames a diagram element

func (*OracleUseCase) SerializeDiagram

func (uc *OracleUseCase) SerializeDiagram(ctx context.Context, diagramID string) (string, error)

SerializeDiagram converts the current graph state back to D2 text

func (*OracleUseCase) SetAttribute

SetAttribute sets an attribute on a diagram element

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError represents a validation error in the usecase layer.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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